@dartcom/ui-kit 10.1.23 → 10.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/layers/leaflet/config/constants.d.ts +3 -1
- package/dist/components/layers/leaflet/config/constants.d.ts.map +1 -1
- package/dist/components/layers/leaflet/config/schema.d.ts +4 -0
- package/dist/components/layers/leaflet/config/schema.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/camera/ui/forms/create/schema.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/camera/ui/forms/schema.d.ts +1 -1
- package/dist/components/layers/leaflet/layers/camera/ui/forms/schema.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/pillar/config/constants.d.ts +5 -0
- package/dist/components/layers/leaflet/layers/pillar/config/constants.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/pillar/index.d.ts +1 -0
- package/dist/components/layers/leaflet/layers/pillar/index.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/pillar/lib/types.d.ts +14 -9
- package/dist/components/layers/leaflet/layers/pillar/lib/types.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/create.d.ts +5 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/create.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/create.stories.d.ts +7 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/create.stories.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/index.d.ts +3 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/index.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/schema.d.ts +4 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/schema.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/types.d.ts +6 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/create/types.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/index.d.ts +3 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/index.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/schema.d.ts +11 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/schema.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/index.d.ts +3 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/index.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/schema.d.ts +4 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/schema.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/types.d.ts +9 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/types.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/update.d.ts +5 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/update.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/update.stories.d.ts +7 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/forms/update/update.stories.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/index.d.ts +2 -0
- package/dist/components/layers/leaflet/layers/pillar/ui/index.d.ts.map +1 -0
- package/dist/components/layers/leaflet/layers/traffic-sign/ui/forms/create/schema.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/traffic-sign/ui/forms/schema.d.ts +1 -1
- package/dist/components/layers/leaflet/layers/traffic-sign/ui/forms/schema.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/traffic-signal/ui/forms/create/schema.d.ts.map +1 -1
- package/dist/components/layers/leaflet/layers/traffic-signal/ui/forms/schema.d.ts +1 -1
- package/dist/components/layers/leaflet/layers/traffic-signal/ui/forms/schema.d.ts.map +1 -1
- package/dist/index.cjs +448 -278
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7,7 +7,7 @@ import*as e from"react";import t,{forwardRef as n,useRef as r,useCallback as i,u
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var ol,al,ll=(il||(il=1,"production"===process.env.NODE_ENV?tl.exports=function(){if(Qa)return nl;Qa=1;var e=t,n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=e.useState,i=e.useEffect,s=e.useLayoutEffect,o=e.useDebugValue;function a(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!n(e,r)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),l=r({inst:{value:n,getSnapshot:t}}),u=l[0].inst,c=l[1];return s(function(){u.value=n,u.getSnapshot=t,a(u)&&c({inst:u})},[e,n,t]),i(function(){return a(u)&&c({inst:u}),e(function(){a(u)&&c({inst:u})})},[e]),o(n),n};return nl.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,nl}():tl.exports=(rl||(rl=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=t,r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=n.useState,s=n.useEffect,o=n.useLayoutEffect,a=n.useDebugValue,l=!1,u=!1,c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(t,c){l||void 0===n.startTransition||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=c();if(!u){var d=c();r(h,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var f=(d=i({inst:{value:h,getSnapshot:c}}))[0].inst,p=d[1];return o(function(){f.value=h,f.getSnapshot=c,e(f)&&p({inst:f})},[t,h,c]),s(function(){return e(f)&&p({inst:f}),t(function(){e(f)&&p({inst:f})})},[t]),a(h),h};sl.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),sl)),tl.exports);function ul(e){e.reaction=new Ni("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),null===(t=e.onStoreChange)||void 0===t||t.call(e)})}var cl=!0,hl="function"==typeof Symbol&&Symbol.for,dl=null!==(al=null===(ol=Object.getOwnPropertyDescriptor(function(){},"name"))||void 0===ol?void 0:ol.configurable)&&void 0!==al&&al,fl=hl?Symbol.for("react.forward_ref"):"function"==typeof n&&n(function(e){return null}).$$typeof,pl=hl?Symbol.for("react.memo"):"function"==typeof h&&h(function(e){return null}).$$typeof;function gl(e,r){if(process.env.NODE_ENV,pl&&e.$$typeof===pl)throw new Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var i=!1,s=e,o=e.displayName||e.name;if(fl&&e.$$typeof===fl&&(i=!0,"function"!=typeof(s=e.render)))throw new Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var a,l,u=function(e,n){return function(e,n){void 0===n&&(n="observed");var r=t.useRef(null);if(!r.current){var i={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:n,subscribe:function(e){return el.unregister(i),i.onStoreChange=e,i.reaction||(ul(i),i.stateVersion=Symbol()),function(){var e;i.onStoreChange=null,null===(e=i.reaction)||void 0===e||e.dispose(),i.reaction=null}},getSnapshot:function(){return i.stateVersion}};r.current=i}var s,o,a=r.current;if(a.reaction||(ul(a),el.register(r,a,a)),t.useDebugValue(a.reaction,Ya),ll.useSyncExternalStore(a.subscribe,a.getSnapshot,a.getSnapshot),a.reaction.track(function(){try{s=e()}catch(e){o=e}}),o)throw o;return s}(function(){return s(e,n)},o)};return u.displayName=e.displayName,dl&&Object.defineProperty(u,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(u.contextTypes=e.contextTypes,"production"!==process.env.NODE_ENV&&cl&&(cl=!1,console.warn("[mobx-react-lite] Support for Legacy Context in function components will be removed in the next major release."))),i&&(u=n(u)),u=h(u),a=e,l=u,Object.keys(a).forEach(function(e){ml[e]||Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(a,e))}),"production"!==process.env.NODE_ENV&&Object.defineProperty(u,"contextTypes",{set:function(){var e,t;throw new Error("[mobx-react-lite] `".concat(this.displayName||(null===(e=this.type)||void 0===e?void 0:e.displayName)||(null===(t=this.type)||void 0===t?void 0:t.name)||"Component",".contextTypes` must be set before applying `observer`."))}}),u}var ml={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};process.env.NODE_ENV,function(e){e||(e=Xa,"production"!==process.env.NODE_ENV&&console.warn("[MobX] Failed to get unstable_batched updates from react-dom / react-native")),os({reactionScheduler:e})}(v),el.finalizeAllImmediately;var _l=gl(({onUnauthorized:t,children:n})=>(e.useEffect(()=>{Io.isUnauthorized&&t()},[Io.isUnauthorized]),b(e.Fragment,{children:n})));function yl(e,t){if(void 0!==e.one&&1===t)return e.one;const n=t%10,r=t%100;return 1===n&&11!==r?e.singularNominative.replace("{{count}}",String(t)):n>=2&&n<=4&&(r<10||r>20)?e.singularGenitive.replace("{{count}}",String(t)):e.pluralGenitive.replace("{{count}}",String(t))}function vl(e){return(t,n)=>n?.addSuffix?n.comparison&&n.comparison>0?e.future?yl(e.future,t):"через "+yl(e.regular,t):e.past?yl(e.past,t):yl(e.regular,t)+" назад":yl(e.regular,t)}const bl={lessThanXSeconds:vl({regular:{one:"меньше секунды",singularNominative:"меньше {{count}} секунды",singularGenitive:"меньше {{count}} секунд",pluralGenitive:"меньше {{count}} секунд"},future:{one:"меньше, чем через секунду",singularNominative:"меньше, чем через {{count}} секунду",singularGenitive:"меньше, чем через {{count}} секунды",pluralGenitive:"меньше, чем через {{count}} секунд"}}),xSeconds:vl({regular:{singularNominative:"{{count}} секунда",singularGenitive:"{{count}} секунды",pluralGenitive:"{{count}} секунд"},past:{singularNominative:"{{count}} секунду назад",singularGenitive:"{{count}} секунды назад",pluralGenitive:"{{count}} секунд назад"},future:{singularNominative:"через {{count}} секунду",singularGenitive:"через {{count}} секунды",pluralGenitive:"через {{count}} секунд"}}),halfAMinute:(e,t)=>t?.addSuffix?t.comparison&&t.comparison>0?"через полминуты":"полминуты назад":"полминуты",lessThanXMinutes:vl({regular:{one:"меньше минуты",singularNominative:"меньше {{count}} минуты",singularGenitive:"меньше {{count}} минут",pluralGenitive:"меньше {{count}} минут"},future:{one:"меньше, чем через минуту",singularNominative:"меньше, чем через {{count}} минуту",singularGenitive:"меньше, чем через {{count}} минуты",pluralGenitive:"меньше, чем через {{count}} минут"}}),xMinutes:vl({regular:{singularNominative:"{{count}} минута",singularGenitive:"{{count}} минуты",pluralGenitive:"{{count}} минут"},past:{singularNominative:"{{count}} минуту назад",singularGenitive:"{{count}} минуты назад",pluralGenitive:"{{count}} минут назад"},future:{singularNominative:"через {{count}} минуту",singularGenitive:"через {{count}} минуты",pluralGenitive:"через {{count}} минут"}}),aboutXHours:vl({regular:{singularNominative:"около {{count}} часа",singularGenitive:"около {{count}} часов",pluralGenitive:"около {{count}} часов"},future:{singularNominative:"приблизительно через {{count}} час",singularGenitive:"приблизительно через {{count}} часа",pluralGenitive:"приблизительно через {{count}} часов"}}),xHours:vl({regular:{singularNominative:"{{count}} час",singularGenitive:"{{count}} часа",pluralGenitive:"{{count}} часов"}}),xDays:vl({regular:{singularNominative:"{{count}} день",singularGenitive:"{{count}} дня",pluralGenitive:"{{count}} дней"}}),aboutXWeeks:vl({regular:{singularNominative:"около {{count}} недели",singularGenitive:"около {{count}} недель",pluralGenitive:"около {{count}} недель"},future:{singularNominative:"приблизительно через {{count}} неделю",singularGenitive:"приблизительно через {{count}} недели",pluralGenitive:"приблизительно через {{count}} недель"}}),xWeeks:vl({regular:{singularNominative:"{{count}} неделя",singularGenitive:"{{count}} недели",pluralGenitive:"{{count}} недель"}}),aboutXMonths:vl({regular:{singularNominative:"около {{count}} месяца",singularGenitive:"около {{count}} месяцев",pluralGenitive:"около {{count}} месяцев"},future:{singularNominative:"приблизительно через {{count}} месяц",singularGenitive:"приблизительно через {{count}} месяца",pluralGenitive:"приблизительно через {{count}} месяцев"}}),xMonths:vl({regular:{singularNominative:"{{count}} месяц",singularGenitive:"{{count}} месяца",pluralGenitive:"{{count}} месяцев"}}),aboutXYears:vl({regular:{singularNominative:"около {{count}} года",singularGenitive:"около {{count}} лет",pluralGenitive:"около {{count}} лет"},future:{singularNominative:"приблизительно через {{count}} год",singularGenitive:"приблизительно через {{count}} года",pluralGenitive:"приблизительно через {{count}} лет"}}),xYears:vl({regular:{singularNominative:"{{count}} год",singularGenitive:"{{count}} года",pluralGenitive:"{{count}} лет"}}),overXYears:vl({regular:{singularNominative:"больше {{count}} года",singularGenitive:"больше {{count}} лет",pluralGenitive:"больше {{count}} лет"},future:{singularNominative:"больше, чем через {{count}} год",singularGenitive:"больше, чем через {{count}} года",pluralGenitive:"больше, чем через {{count}} лет"}}),almostXYears:vl({regular:{singularNominative:"почти {{count}} год",singularGenitive:"почти {{count}} года",pluralGenitive:"почти {{count}} лет"},future:{singularNominative:"почти через {{count}} год",singularGenitive:"почти через {{count}} года",pluralGenitive:"почти через {{count}} лет"}})};function xl(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const wl={date:xl({formats:{full:"EEEE, d MMMM y 'г.'",long:"d MMMM y 'г.'",medium:"d MMM y 'г.'",short:"dd.MM.y"},defaultWidth:"full"}),time:xl({formats:{full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},defaultWidth:"full"}),dateTime:xl({formats:{any:"{{date}}, {{time}}"},defaultWidth:"any"})},Al=Symbol.for("constructDateFrom");function El(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&Al in e?e[Al](t):e instanceof Date?new e.constructor(t):new Date(t)}let Sl={};function Tl(e,t){const n=Sl,r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=(s=e,o=t?.in,El(o||s,s));var s,o;const a=i.getDay(),l=(a<r?7:0)+a-r;return i.setDate(i.getDate()-l),i.setHours(0,0,0,0),i}function kl(e,t,n){const[r,i]=function(e,...t){const n=El.bind(null,e||t.find(e=>"object"==typeof e));return t.map(n)}(n?.in,e,t);return+Tl(r,n)===+Tl(i,n)}const Ol=["воскресенье","понедельник","вторник","среду","четверг","пятницу","субботу"];function Rl(e){const t=Ol[e];return 2===e?"'во "+t+" в' p":"'в "+t+" в' p"}const Cl={lastWeek:(e,t,n)=>{const r=e.getDay();return kl(e,t,n)?Rl(r):function(e){const t=Ol[e];switch(e){case 0:return"'в прошлое "+t+" в' p";case 1:case 2:case 4:return"'в прошлый "+t+" в' p";case 3:case 5:case 6:return"'в прошлую "+t+" в' p"}}(r)},yesterday:"'вчера в' p",today:"'сегодня в' p",tomorrow:"'завтра в' p",nextWeek:(e,t,n)=>{const r=e.getDay();return kl(e,t,n)?Rl(r):function(e){const t=Ol[e];switch(e){case 0:return"'в следующее "+t+" в' p";case 1:case 2:case 4:return"'в следующий "+t+" в' p";case 3:case 5:case 6:return"'в следующую "+t+" в' p"}}(r)},other:"P"};function Pl(e){return(t,n)=>{let r;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,i=n?.width?String(n.width):t;r=e.formattingValues[i]||e.formattingValues[t]}else{const t=e.defaultWidth,i=n?.width?String(n.width):e.defaultWidth;r=e.values[i]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}const Ml={ordinalNumber:(e,t)=>{const n=Number(e),r=t?.unit;let i;return i="date"===r?"-е":"week"===r||"minute"===r||"second"===r?"-я":"-й",n+i},era:Pl({values:{narrow:["до н.э.","н.э."],abbreviated:["до н. э.","н. э."],wide:["до нашей эры","нашей эры"]},defaultWidth:"wide"}),quarter:Pl({values:{narrow:["1","2","3","4"],abbreviated:["1-й кв.","2-й кв.","3-й кв.","4-й кв."],wide:["1-й квартал","2-й квартал","3-й квартал","4-й квартал"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Pl({values:{narrow:["Я","Ф","М","А","М","И","И","А","С","О","Н","Д"],abbreviated:["янв.","фев.","март","апр.","май","июнь","июль","авг.","сент.","окт.","нояб.","дек."],wide:["январь","февраль","март","апрель","май","июнь","июль","август","сентябрь","октябрь","ноябрь","декабрь"]},defaultWidth:"wide",formattingValues:{narrow:["Я","Ф","М","А","М","И","И","А","С","О","Н","Д"],abbreviated:["янв.","фев.","мар.","апр.","мая","июн.","июл.","авг.","сент.","окт.","нояб.","дек."],wide:["января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"]},defaultFormattingWidth:"wide"}),day:Pl({values:{narrow:["В","П","В","С","Ч","П","С"],short:["вс","пн","вт","ср","чт","пт","сб"],abbreviated:["вск","пнд","втр","срд","чтв","птн","суб"],wide:["воскресенье","понедельник","вторник","среда","четверг","пятница","суббота"]},defaultWidth:"wide"}),dayPeriod:Pl({values:{narrow:{am:"ДП",pm:"ПП",midnight:"полн.",noon:"полд.",morning:"утро",afternoon:"день",evening:"веч.",night:"ночь"},abbreviated:{am:"ДП",pm:"ПП",midnight:"полн.",noon:"полд.",morning:"утро",afternoon:"день",evening:"веч.",night:"ночь"},wide:{am:"ДП",pm:"ПП",midnight:"полночь",noon:"полдень",morning:"утро",afternoon:"день",evening:"вечер",night:"ночь"}},defaultWidth:"any",formattingValues:{narrow:{am:"ДП",pm:"ПП",midnight:"полн.",noon:"полд.",morning:"утра",afternoon:"дня",evening:"веч.",night:"ночи"},abbreviated:{am:"ДП",pm:"ПП",midnight:"полн.",noon:"полд.",morning:"утра",afternoon:"дня",evening:"веч.",night:"ночи"},wide:{am:"ДП",pm:"ПП",midnight:"полночь",noon:"полдень",morning:"утра",afternoon:"дня",evening:"вечера",night:"ночи"}},defaultFormattingWidth:"wide"})};function Nl(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const o=s[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(a)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;return}(a,e=>e.test(o)):function(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;return}(a,e=>e.test(o));let u;u=e.valueCallback?e.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;return{value:u,rest:t.slice(o.length)}}}const Il={ordinalNumber:(Dl={matchPattern:/^(\d+)(-?(е|я|й|ое|ье|ая|ья|ый|ой|ий|ый))?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(Dl.matchPattern);if(!n)return null;const r=n[0],i=e.match(Dl.parsePattern);if(!i)return null;let s=Dl.valueCallback?Dl.valueCallback(i[0]):i[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:Nl({matchPatterns:{narrow:/^((до )?н\.?\s?э\.?)/i,abbreviated:/^((до )?н\.?\s?э\.?)/i,wide:/^(до нашей эры|нашей эры|наша эра)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^д/i,/^н/i]},defaultParseWidth:"any"}),quarter:Nl({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^[1234](-?[ыои]?й?)? кв.?/i,wide:/^[1234](-?[ыои]?й?)? квартал/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Nl({matchPatterns:{narrow:/^[яфмаисонд]/i,abbreviated:/^(янв|фев|март?|апр|ма[йя]|июн[ья]?|июл[ья]?|авг|сент?|окт|нояб?|дек)\.?/i,wide:/^(январ[ья]|феврал[ья]|марта?|апрел[ья]|ма[йя]|июн[ья]|июл[ья]|августа?|сентябр[ья]|октябр[ья]|октябр[ья]|ноябр[ья]|декабр[ья])/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^я/i,/^ф/i,/^м/i,/^а/i,/^м/i,/^и/i,/^и/i,/^а/i,/^с/i,/^о/i,/^н/i,/^я/i],any:[/^я/i,/^ф/i,/^мар/i,/^ап/i,/^ма[йя]/i,/^июн/i,/^июл/i,/^ав/i,/^с/i,/^о/i,/^н/i,/^д/i]},defaultParseWidth:"any"}),day:Nl({matchPatterns:{narrow:/^[впсч]/i,short:/^(вс|во|пн|по|вт|ср|чт|че|пт|пя|сб|су)\.?/i,abbreviated:/^(вск|вос|пнд|пон|втр|вто|срд|сре|чтв|чет|птн|пят|суб).?/i,wide:/^(воскресень[ея]|понедельника?|вторника?|сред[аы]|четверга?|пятниц[аы]|суббот[аы])/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^в/i,/^п/i,/^в/i,/^с/i,/^ч/i,/^п/i,/^с/i],any:[/^в[ос]/i,/^п[он]/i,/^в/i,/^ср/i,/^ч/i,/^п[ят]/i,/^с[уб]/i]},defaultParseWidth:"any"}),dayPeriod:Nl({matchPatterns:{narrow:/^([дп]п|полн\.?|полд\.?|утр[оа]|день|дня|веч\.?|ноч[ьи])/i,abbreviated:/^([дп]п|полн\.?|полд\.?|утр[оа]|день|дня|веч\.?|ноч[ьи])/i,wide:/^([дп]п|полночь|полдень|утр[оа]|день|дня|вечера?|ноч[ьи])/i},defaultMatchWidth:"wide",parsePatterns:{any:{am:/^дп/i,pm:/^пп/i,midnight:/^полн/i,noon:/^полд/i,morning:/^у/i,afternoon:/^д[ен]/i,evening:/^в/i,night:/^н/i}},defaultParseWidth:"any"})};var Dl;const Fl={code:"ru",formatDistance:(e,t,n)=>bl[e](t,n),formatLong:wl,formatRelative:(e,t,n,r)=>{const i=Cl[e];return"function"==typeof i?i(t,n,r):i},localize:Ml,match:Il,options:{weekStartsOn:1,firstWeekContainsDate:1}},zl=e=>b(A,{...e,dateAdapter:E,adapterLocale:Fl}),Ll=({items:t,onOpen:n,defaultValue:r=null})=>{const[i,s]=e.useState(r),o=e.useCallback(()=>{s(null)},[]);e.useEffect(()=>{r&&s(r)},[r]);const a=e.useId();return b(T,{id:a,children:t.map(({value:e,summary:t,getDetails:r})=>{const l=`${a}-accordion-${e}`;return x(k,{expanded:e===i,children:[b(O,{expandIcon:b(S,{}),onClick:()=>{s(t=>t===e?null:(n?.(e),e))},"aria-controls":`${l}-content`,id:`${l}-header`,children:t}),b(R,{children:r({onClose:o})})]},l)})})},jl=e=>{const{children:t,variant:n="contained",loading:r,icon:i,sx:s,...o}=e;return i?b(Z,{...o,loading:r,children:i}):b(C,{sx:{whiteSpace:"nowrap",padding:"5px 15px",textTransform:"none",...s},loading:r,loadingPosition:"start",variant:n,...o,children:t})},Vl=e.forwardRef(function(e,t){return b(P,{direction:"up",ref:t,...e})}),Ul=({notification:t,onDelete:n})=>{const r=e.useId(),[i,s]=e.useState(!1),o=()=>{s(!1)};return x(e.Fragment,{children:[t?b(M,{title:t.title,children:b(N,{onClick:e=>{e.stopPropagation(),s(!0)},children:b(K,{fontSize:"small",color:"error"})})}):b(N,{onClick:e=>{e.stopPropagation(),n()},children:b(K,{fontSize:"small",color:"error"})}),t?x(I,{slots:{transition:Vl},open:i,onClose:o,children:[b(D,{id:`${r}-dialog-title`,children:t.title}),b(F,{children:b(z,{id:`${r}-dialog-text`,children:t.description})}),x(L,{children:[b(C,{variant:"contained",color:"error",sx:{textTransform:"none"},onClick:o,children:"Отмена"}),b(C,{variant:"contained",sx:{textTransform:"none"},onClick:()=>{n(),o()},children:"Подтвердить"})]})]}):null]})},Bl={reset:Q,edit:X,move:Y},Gl=({title:t,iconProps:n,...r})=>{const i=e.useId(),s=Bl[n.name];return t?b(M,{title:t,children:b(N,{id:i,...r,children:b(s,{fontSize:"medium",color:n.color??"primary"})})}):b(N,{id:i,...r,children:b(s,{fontSize:"medium",color:n.color??"primary"})})},$l=j("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1}),ql=({children:e,accept:t,onFilesLoad:n,...r})=>x(jl,{...r,component:"label",variant:"contained",startIcon:b(J,{}),children:[e,b($l,{type:"file",accept:t,onChange:e=>{const{target:{files:t}}=e;t&&n({event:e,files:t})},multiple:!0})]}),Hl=({children:e,sx:t={},...n})=>b(T,{...n,sx:{padding:"20px 15px",borderRadius:"10px",boxShadow:"0px 8px 24px 0px rgba(0,0,0,0.3)",maxHeight:"80vh",maxWidth:"90vw",overflowX:"auto",...t},children:e});var Wl=e=>"checkbox"===e.type,Zl=e=>e instanceof Date,Kl=e=>null==e;const Xl=e=>"object"==typeof e;var Yl=e=>!Kl(e)&&!Array.isArray(e)&&Xl(e)&&!Zl(e),Ql=e=>Yl(e)&&e.target?Wl(e.target)?e.target.checked:e.target.value:e,Jl=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),eu="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function tu(e){if(e instanceof Date)return new Date(e);const t="undefined"!=typeof FileList&&e instanceof FileList;if(eu&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!(n||Yl(e)&&(e=>{const t=e.constructor&&e.constructor.prototype;return Yl(t)&&t.hasOwnProperty("isPrototypeOf")})(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=tu(e[t]));return r}var nu=e=>/^\w*$/.test(e),ru=e=>void 0===e,iu=e=>Array.isArray(e)?e.filter(Boolean):[],su=e=>iu(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ou=(e,t,n)=>{if(!t||!Yl(e))return n;const r=(nu(t)?[t]:su(t)).reduce((e,t)=>Kl(e)?e:e[t],e);return ru(r)||r===e?ru(e[t])?n:e[t]:r},au=e=>"boolean"==typeof e,lu=e=>"function"==typeof e,uu=(e,t,n)=>{let r=-1;const i=nu(t)?[t]:su(t),s=i.length,o=s-1;for(;++r<s;){const t=i[r];let s=n;if(r!==o){const n=e[t];s=Yl(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=s,e=e[t]}};const cu="blur",hu="focusout",du="change",fu="onBlur",pu="onChange",gu="onSubmit",mu="onTouched",_u="all",yu="max",vu="min",bu="maxLength",xu="minLength",wu="pattern",Au="required",Eu="validate",Su=t.createContext(null);Su.displayName="HookFormContext";const Tu=()=>t.useContext(Su),ku=e=>{const{children:n,...r}=e;return t.createElement(Su.Provider,{value:r},n)};var Ou=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const i=s;return t._proxyFormState[i]!==_u&&(t._proxyFormState[i]=!r||_u),n&&(n[i]=!0),e[i]}});return i};const Ru="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;var Cu=e=>"string"==typeof e,Pu=(e,t,n,r,i)=>Cu(e)?(r&&t.watch.add(e),ou(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),ou(n,e))):(r&&(t.watchAll=!0),n),Mu=e=>Kl(e)||!Xl(e);function Nu(e,t,n=new WeakSet){if(Mu(e)||Mu(t))return Object.is(e,t);if(Zl(e)&&Zl(t))return e.getTime()===t.getTime();const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const s of r){const r=e[s];if(!i.includes(s))return!1;if("ref"!==s){const e=t[s];if(Zl(r)&&Zl(e)||Yl(r)&&Yl(e)||Array.isArray(r)&&Array.isArray(e)?!Nu(r,e,n):!Object.is(r,e))return!1}}return!0}function Iu(e){const n=Tu(),{name:r,disabled:i,control:s=n.control,shouldUnregister:o,defaultValue:a,exact:l=!0}=e,u=Jl(s._names.array,r),c=t.useMemo(()=>ou(s._formValues,r,ou(s._defaultValues,r,a)),[s,r,a]),h=function(e){const n=Tu(),{control:r=n.control,name:i,defaultValue:s,disabled:o,exact:a,compute:l}=e||{},u=t.useRef(s),c=t.useRef(l),h=t.useRef(void 0),d=t.useRef(r),f=t.useRef(i);c.current=l;const[p,g]=t.useState(()=>{const e=r._getWatch(i,u.current);return c.current?c.current(e):e}),m=t.useCallback(e=>{const t=Pu(i,r._names,e||r._formValues,!1,u.current);return c.current?c.current(t):t},[r._formValues,r._names,i]),_=t.useCallback(e=>{if(!o){const t=Pu(i,r._names,e||r._formValues,!1,u.current);if(c.current){const e=c.current(t);Nu(e,h.current)||(g(e),h.current=e)}else g(t)}},[r._formValues,r._names,o,i]);Ru(()=>(d.current===r&&Nu(f.current,i)||(d.current=r,f.current=i,_()),r._subscribe({name:i,formState:{values:!0},exact:a,callback:e=>{_(e.values)}})),[r,a,i,_]),t.useEffect(()=>r._removeUnmounted());const y=d.current!==r,v=f.current,b=t.useMemo(()=>{if(o)return null;const e=!y&&!Nu(v,i);return y||e?m():null},[o,y,i,v,m]);return null!==b?b:p}({control:s,name:r,defaultValue:c,exact:l}),d=function(e){const n=Tu(),{control:r=n.control,disabled:i,name:s,exact:o}=e||{},[a,l]=t.useState(r._formState),u=t.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ru(()=>r._subscribe({name:s,formState:u.current,exact:o,callback:e=>{!i&&l({...r._formState,...e})}}),[s,i,o]),t.useEffect(()=>{u.current.isValid&&r._setValid(!0)},[r]),t.useMemo(()=>Ou(a,r,u.current,!1),[a,r])}({control:s,name:r,exact:l}),f=t.useRef(e),p=t.useRef(void 0),g=t.useRef(s.register(r,{...e.rules,value:h,...au(e.disabled)?{disabled:e.disabled}:{}}));f.current=e;const m=t.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ou(d.errors,r)},isDirty:{enumerable:!0,get:()=>!!ou(d.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!ou(d.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!ou(d.validatingFields,r)},error:{enumerable:!0,get:()=>ou(d.errors,r)}}),[d,r]),_=t.useCallback(e=>g.current.onChange({target:{value:Ql(e),name:r},type:du}),[r]),y=t.useCallback(()=>g.current.onBlur({target:{value:ou(s._formValues,r),name:r},type:cu}),[r,s._formValues]),v=t.useCallback(e=>{const t=ou(s._fields,r);t&&t._f&&e&&(t._f.ref={focus:()=>lu(e.focus)&&e.focus(),select:()=>lu(e.select)&&e.select(),setCustomValidity:t=>lu(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>lu(e.reportValidity)&&e.reportValidity()})},[s._fields,r]),b=t.useMemo(()=>({name:r,value:h,...au(i)||d.disabled?{disabled:d.disabled||i}:{},onChange:_,onBlur:y,ref:v}),[r,i,d.disabled,_,y,v,h]);return t.useEffect(()=>{const e=s._options.shouldUnregister||o,t=p.current;t&&t!==r&&!u&&s.unregister(t),s.register(r,{...f.current.rules,...au(f.current.disabled)?{disabled:f.current.disabled}:{}});const n=(e,t)=>{const n=ou(s._fields,e);n&&n._f&&(n._f.mount=t)};if(n(r,!0),e){const e=tu(ou(s._options.defaultValues,r,f.current.defaultValue));uu(s._defaultValues,r,e),ru(ou(s._formValues,r))&&uu(s._formValues,r,e)}return!u&&s.register(r),p.current=r,()=>{(u?e&&!s._state.action:e)?s.unregister(r):n(r,!1)}},[r,s,u,o]),t.useEffect(()=>{s._setDisabledField({disabled:i,name:r})},[i,r,s]),t.useMemo(()=>({field:b,formState:d,fieldState:m}),[b,d,m])}const Du=e=>e.render(Iu(e));var Fu=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},zu=e=>Array.isArray(e)?e:[e],Lu=()=>{let e=[];return{get observers(){return e},next:t=>{for(const n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function ju(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const i=e[r],s=t[r];if(i&&Yl(i)&&s){const e=ju(i,s);Yl(e)&&(n[r]=e)}else e[r]&&(n[r]=s)}return n}var Vu=e=>Yl(e)&&!Object.keys(e).length,Uu=e=>"file"===e.type,Bu=e=>{if(!eu)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Gu=e=>"select-multiple"===e.type,$u=e=>"radio"===e.type,qu=e=>Bu(e)&&e.isConnected;function Hu(e,t){const n=Array.isArray(t)?t:nu(t)?[t]:su(t),r=1===n.length?e:function(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ru(e)?r++:e[t[r++]];return e}(e,n),i=n.length-1,s=n[i];return r&&delete r[s],0!==i&&(Yl(r)&&Vu(r)||Array.isArray(r)&&function(e){for(const t in e)if(e.hasOwnProperty(t)&&!ru(e[t]))return!1;return!0}(r))&&Hu(e,n.slice(0,-1)),e}function Wu(e){return Array.isArray(e)||Yl(e)&&!(e=>{for(const t in e)if(lu(e[t]))return!0;return!1})(e)}function Zu(e,t={}){for(const n in e){const r=e[n];Wu(r)?(t[n]=Array.isArray(r)?[]:{},Zu(r,t[n])):ru(r)||(t[n]=!0)}return t}function Ku(e,t,n){n||(n=Zu(t));for(const r in e){const i=e[r];if(Wu(i))ru(t)||Mu(n[r])?n[r]=Zu(i,Array.isArray(i)?[]:{}):Ku(i,Kl(t)?{}:t[r],n[r]);else{const e=t[r];n[r]=!Nu(i,e)}}return n}const Xu={value:!1,isValid:!1},Yu={value:!0,isValid:!0};var Qu=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ru(e[0].attributes.value)?ru(e[0].value)||""===e[0].value?Yu:{value:e[0].value,isValid:!0}:Yu:Xu}return Xu},Ju=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ru(e)?e:t?""===e?NaN:e?+e:e:n&&Cu(e)?new Date(e):r?r(e):e;const ec={isValid:!1,value:null};var tc=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,ec):ec;function nc(e){const t=e.ref;return Uu(t)?t.files:$u(t)?tc(e.refs).value:Gu(t)?[...t.selectedOptions].map(({value:e})=>e):Wl(t)?Qu(e.refs).value:Ju(ru(t.value)?e.ref.value:t.value,e)}var rc=e=>e instanceof RegExp,ic=e=>ru(e)?e:rc(e)?e.source:Yl(e)?rc(e.value)?e.value.source:e.value:e,sc=e=>({isOnSubmit:!e||e===gu,isOnBlur:e===fu,isOnChange:e===pu,isOnAll:e===_u,isOnTouch:e===mu});const oc="AsyncFunction";var ac=e=>!!e&&!!e.validate&&!!(lu(e.validate)&&e.validate.constructor.name===oc||Yl(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===oc)),lc=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))));const uc=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const n=ou(e,i);if(n){const{_f:e,...s}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r)return!0;if(e.ref&&t(e.ref,e.name)&&!r)return!0;if(uc(s,t))break}else if(Yl(s)&&uc(s,t))break}}};function cc(e,t,n){const r=ou(e,n);if(r||nu(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const r=i.join("."),s=ou(t,r),o=ou(e,r);if(s&&!Array.isArray(s)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};if(o&&o.root&&o.root.type)return{name:`${r}.root`,error:o.root};i.pop()}return{name:n}}var hc=(e,t,n)=>{const r=zu(ou(e,n));return uu(r,"root",t[n]),uu(e,n,r),e};function dc(e,t,n="validate"){if(Cu(e)||Array.isArray(e)&&e.every(Cu)||au(e)&&!e)return{type:n,message:Cu(e)?e:"",ref:t}}var fc=e=>Yl(e)&&!rc(e)?e:{value:e,message:""},pc=async(e,t,n,r,i,s)=>{const{ref:o,refs:a,required:l,maxLength:u,minLength:c,min:h,max:d,pattern:f,validate:p,name:g,valueAsNumber:m,mount:_}=e._f,y=ou(n,g);if(!_||t.has(g))return{};const v=a?a[0]:o,b=e=>{i&&v.reportValidity&&(v.setCustomValidity(au(e)?"":e||""),v.reportValidity())},x={},w=$u(o),A=Wl(o),E=w||A,S=(m||Uu(o))&&ru(o.value)&&ru(y)||Bu(o)&&""===o.value||""===y||Array.isArray(y)&&!y.length,T=Fu.bind(null,g,r,x),k=(e,t,n,r=bu,i=xu)=>{const s=e?t:n;x[g]={type:e?r:i,message:s,ref:o,...T(e?r:i,s)}};if(s?!Array.isArray(y)||!y.length:l&&(!E&&(S||Kl(y))||au(y)&&!y||A&&!Qu(a).isValid||w&&!tc(a).isValid)){const{value:e,message:t}=Cu(l)?{value:!!l,message:l}:fc(l);if(e&&(x[g]={type:Au,message:t,ref:v,...T(Au,t)},!r))return b(t),x}if(!(S||Kl(h)&&Kl(d))){let e,t;const n=fc(d),i=fc(h);if(Kl(y)||isNaN(y)){const r=o.valueAsDate||new Date(y),s=e=>new Date((new Date).toDateString()+" "+e),a="time"==o.type,l="week"==o.type;Cu(n.value)&&y&&(e=a?s(y)>s(n.value):l?y>n.value:r>new Date(n.value)),Cu(i.value)&&y&&(t=a?s(y)<s(i.value):l?y<i.value:r<new Date(i.value))}else{const r=o.valueAsNumber||(y?+y:y);Kl(n.value)||(e=r>n.value),Kl(i.value)||(t=r<i.value)}if((e||t)&&(k(!!e,n.message,i.message,yu,vu),!r))return b(x[g].message),x}if((u||c)&&!S&&(Cu(y)||s&&Array.isArray(y))){const e=fc(u),t=fc(c),n=!Kl(e.value)&&y.length>+e.value,i=!Kl(t.value)&&y.length<+t.value;if((n||i)&&(k(n,e.message,t.message),!r))return b(x[g].message),x}if(f&&!S&&Cu(y)){const{value:e,message:t}=fc(f);if(rc(e)&&!y.match(e)&&(x[g]={type:wu,message:t,ref:o,...T(wu,t)},!r))return b(t),x}if(p)if(lu(p)){const e=dc(await p(y,n),v);if(e&&(x[g]={...e,...T(Eu,e.message)},!r))return b(e.message),x}else if(Yl(p)){let e={};for(const t in p){if(!Vu(e)&&!r)break;const i=dc(await p[t](y,n),v,t);i&&(e={...i,...T(t,i.message)},b(i.message),r&&(x[g]=e))}if(!Vu(e)&&(x[g]={ref:v,...e},!r))return x}return b(!0),x};const gc={mode:gu,reValidateMode:pu,shouldFocusError:!0};function mc(e={}){let t,n={...gc,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:lu(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},s=(Yl(n.defaultValues)||Yl(n.values))&&tu(n.defaultValues||n.values)||{},o=n.shouldUnregister?{}:tu(s),a={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0;const c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...c};let d={...h};const f={array:Lu(),state:Lu()},p=n.criteriaMode===_u,g=async e=>{if(!a.keepIsValid&&!n.disabled&&(h.isValid||d.isValid||e)){let e;n.resolver?(e=Vu((await b()).errors),m()):e=await x(i,!0),e!==r.isValid&&f.state.next({isValid:e})}},m=(e,t)=>{!n.disabled&&(h.isValidating||h.validatingFields||d.isValidating||d.validatingFields)&&((e||Array.from(l.mount)).forEach(e=>{e&&(t?uu(r.validatingFields,e,t):Hu(r.validatingFields,e))}),f.state.next({validatingFields:r.validatingFields,isValidating:!Vu(r.validatingFields)}))},_=(e,t,n,r)=>{const l=ou(i,e);if(l){const i=ou(o,e,ru(n)?ou(s,e):n);ru(i)||r&&r.defaultChecked||t?uu(o,e,t?i:nc(l._f)):E(e,i),a.mount&&!a.action&&g()}},y=(e,t,i,o,a)=>{let l=!1,u=!1;const c={name:e};if(!n.disabled){if(!i||o){(h.isDirty||d.isDirty)&&(u=r.isDirty,r.isDirty=c.isDirty=w(),l=u!==c.isDirty);const n=Nu(ou(s,e),t);u=!!ou(r.dirtyFields,e),n?Hu(r.dirtyFields,e):uu(r.dirtyFields,e,!0),c.dirtyFields=r.dirtyFields,l=l||(h.dirtyFields||d.dirtyFields)&&u!==!n}if(i){const t=ou(r.touchedFields,e);t||(uu(r.touchedFields,e,i),c.touchedFields=r.touchedFields,l=l||(h.touchedFields||d.touchedFields)&&t!==i)}l&&a&&f.state.next(c)}return l?c:{}},v=(e,i,s,o)=>{const a=ou(r.errors,e),l=(h.isValid||d.isValid)&&au(i)&&r.isValid!==i;var c;if(n.delayError&&s?(c=()=>((e,t)=>{uu(r.errors,e,t),f.state.next({errors:r.errors})})(e,s),t=e=>{clearTimeout(u),u=setTimeout(c,e)},t(n.delayError)):(clearTimeout(u),t=null,s?uu(r.errors,e,s):Hu(r.errors,e)),(s?!Nu(a,s):a)||!Vu(o)||l){const t={...o,...l&&au(i)?{isValid:i}:{},errors:r.errors,name:e};r={...r,...t},f.state.next(t)}},b=async e=>{m(e,!0);const t=await n.resolver(o,n.context,((e,t,n,r)=>{const i={};for(const n of e){const e=ou(t,n);e&&uu(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}})(e||l.mount,i,n.criteriaMode,n.shouldUseNativeValidation));return t},x=async(e,t,i={valid:!0})=>{for(const s in e){const a=e[s];if(a){const{_f:e,...s}=a;if(e){const s=l.array.has(e.name),u=a._f&&ac(a._f);u&&h.validatingFields&&m([e.name],!0);const c=await pc(a,l.disabled,o,p,n.shouldUseNativeValidation&&!t,s);if(u&&h.validatingFields&&m([e.name]),c[e.name]&&(i.valid=!1,t))break;!t&&(ou(c,e.name)?s?hc(r.errors,c,e.name):uu(r.errors,e.name,c[e.name]):Hu(r.errors,e.name))}!Vu(s)&&await x(s,t,i)}}return i.valid},w=(e,t)=>!n.disabled&&(e&&t&&uu(o,e,t),!Nu(C(),s)),A=(e,t,n)=>Pu(e,l,{...a.mount?o:ru(t)?s:Cu(e)?{[e]:t}:t},n,t),E=(e,t,n={})=>{const r=ou(i,e);let s=t;if(r){const n=r._f;n&&(!n.disabled&&uu(o,e,Ju(t,n)),s=Bu(n.ref)&&Kl(t)?"":t,Gu(n.ref)?[...n.ref.options].forEach(e=>e.selected=s.includes(e.value)):n.refs?Wl(n.ref)?n.refs.forEach(e=>{e.defaultChecked&&e.disabled||(Array.isArray(s)?e.checked=!!s.find(t=>t===e.value):e.checked=s===e.value||!!s)}):n.refs.forEach(e=>e.checked=e.value===s):Uu(n.ref)?n.ref.value="":(n.ref.value=s,n.ref.type||f.state.next({name:e,values:tu(o)})))}(n.shouldDirty||n.shouldTouch)&&y(e,s,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&R(e)},S=(e,t,n)=>{for(const r in t){if(!t.hasOwnProperty(r))return;const s=t[r],o=e+"."+r,a=ou(i,o);(l.array.has(e)||Yl(s)||a&&!a._f)&&!Zl(s)?S(o,s,n):E(o,s,n)}},T=(e,t,n={})=>{const u=ou(i,e),c=l.array.has(e),p=tu(t);uu(o,e,p),c?(f.array.next({name:e,values:tu(o)}),(h.isDirty||h.dirtyFields||d.isDirty||d.dirtyFields)&&n.shouldDirty&&f.state.next({name:e,dirtyFields:Ku(s,o),isDirty:w(e,p)})):!u||u._f||Kl(p)?E(e,p,n):S(e,p,n),lc(e,l)&&f.state.next({...r,name:e}),f.state.next({name:a.mount?e:void 0,values:tu(o)})},k=async e=>{a.mount=!0;const s=e.target;let u=s.name,c=!0;const _=ou(i,u),w=e=>{c=Number.isNaN(e)||Zl(e)&&isNaN(e.getTime())||Nu(e,ou(o,u,e))},A=sc(n.mode),E=sc(n.reValidateMode);if(_){let a,T;const k=s.type?nc(_._f):Ql(e),O=e.type===cu||e.type===hu,C=!((S=_._f).mount&&(S.required||S.min||S.max||S.maxLength||S.minLength||S.pattern||S.validate)||n.resolver||ou(r.errors,u)||_._f.deps)||((e,t,n,r,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:!(n?r.isOnChange:i.isOnChange)||e))(O,ou(r.touchedFields,u),r.isSubmitted,E,A),P=lc(u,l,O);uu(o,u,k),O?s&&s.readOnly||(_._f.onBlur&&_._f.onBlur(e),t&&t(0)):_._f.onChange&&_._f.onChange(e);const M=y(u,k,O),N=!Vu(M)||P;if(!O&&f.state.next({name:u,type:e.type,values:tu(o)}),C)return(h.isValid||d.isValid)&&("onBlur"===n.mode?O&&g():O||g()),N&&f.state.next({name:u,...P?{}:M});if(!O&&P&&f.state.next({...r}),n.resolver){const{errors:e}=await b([u]);if(m([u]),w(k),c){const t=cc(r.errors,i,u),n=cc(e,i,t.name||u);a=n.error,u=n.name,T=Vu(e)}}else m([u],!0),a=(await pc(_,l.disabled,o,p,n.shouldUseNativeValidation))[u],m([u]),w(k),c&&(a?T=!1:(h.isValid||d.isValid)&&(T=await x(i,!0)));c&&(_._f.deps&&(!Array.isArray(_._f.deps)||_._f.deps.length>0)&&R(_._f.deps),v(u,T,a,M))}var S},O=(e,t)=>{if(ou(r.errors,t)&&e.focus)return e.focus(),1},R=async(e,t={})=>{let s,o;const a=zu(e);if(n.resolver){const t=await(async e=>{const{errors:t}=await b(e);if(m(e),e)for(const n of e){const e=ou(t,n);e?uu(r.errors,n,e):Hu(r.errors,n)}else r.errors=t;return t})(ru(e)?e:a);s=Vu(t),o=e?!a.some(e=>ou(t,e)):s}else e?(o=(await Promise.all(a.map(async e=>{const t=ou(i,e);return await x(t&&t._f?{[e]:t}:t)}))).every(Boolean),(o||r.isValid)&&g()):o=s=await x(i);return f.state.next({...!Cu(e)||(h.isValid||d.isValid)&&s!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:s}:{},errors:r.errors}),t.shouldFocus&&!o&&uc(i,O,e?a:l.mount),o},C=(e,t)=>{let n={...a.mount?o:s};return t&&(n=ju(t.dirtyFields?r.dirtyFields:r.touchedFields,n)),ru(e)?n:Cu(e)?ou(n,e):e.map(e=>ou(n,e))},P=(e,t)=>({invalid:!!ou((t||r).errors,e),isDirty:!!ou((t||r).dirtyFields,e),error:ou((t||r).errors,e),isValidating:!!ou(r.validatingFields,e),isTouched:!!ou((t||r).touchedFields,e)}),M=(e,t,n)=>{const s=(ou(i,e,{_f:{}})._f||{}).ref,o=ou(r.errors,e)||{},{ref:a,message:l,type:u,...c}=o;uu(r.errors,e,{...c,...t,ref:s}),f.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&s&&s.focus&&s.focus()},N=e=>f.state.subscribe({next:t=>{var n,i,a;n=e.name,i=t.name,a=e.exact,n&&i&&n!==i&&!zu(n).some(e=>e&&(a?e===i:e.startsWith(i)||i.startsWith(e)))||!((e,t,n,r)=>{n(e);const{name:i,...s}=e;return Vu(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(e=>t[e]===(!r||_u))})(t,e.formState||h,U,e.reRenderRoot)||e.callback({values:{...o},...r,...t,defaultValues:s})}}).unsubscribe,I=(e,t={})=>{for(const a of e?zu(e):l.mount)l.mount.delete(a),l.array.delete(a),t.keepValue||(Hu(i,a),Hu(o,a)),!t.keepError&&Hu(r.errors,a),!t.keepDirty&&Hu(r.dirtyFields,a),!t.keepTouched&&Hu(r.touchedFields,a),!t.keepIsValidating&&Hu(r.validatingFields,a),!n.shouldUnregister&&!t.keepDefaultValue&&Hu(s,a);f.state.next({values:tu(o)}),f.state.next({...r,...t.keepDirty?{isDirty:w()}:{}}),!t.keepIsValid&&g()},D=({disabled:e,name:t})=>{(au(e)&&a.mount||e||l.disabled.has(t))&&(e?l.disabled.add(t):l.disabled.delete(t))},F=(e,t={})=>{let r=ou(i,e);const o=au(t.disabled)||au(n.disabled);return uu(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),l.mount.add(e),r?D({disabled:au(t.disabled)?t.disabled:n.disabled,name:e}):_(e,!0,t.value),{...o?{disabled:t.disabled||n.disabled}:{},...n.progressive?{required:!!t.required,min:ic(t.min),max:ic(t.max),minLength:ic(t.minLength),maxLength:ic(t.maxLength),pattern:ic(t.pattern)}:{},name:e,onChange:k,onBlur:k,ref:o=>{if(o){F(e,t),r=ou(i,e);const n=ru(o.value)&&o.querySelectorAll&&o.querySelectorAll("input,select,textarea")[0]||o,a=(e=>$u(e)||Wl(e))(n),l=r._f.refs||[];if(a?l.find(e=>e===n):n===r._f.ref)return;uu(i,e,{_f:{...r._f,...a?{refs:[...l.filter(qu),n,...Array.isArray(ou(s,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),_(e,!1,void 0,n)}else r=ou(i,e,{}),r._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&(!Jl(l.array,e)||!a.action)&&l.unMount.add(e)}}},z=()=>n.shouldFocusError&&uc(i,O,l.mount),L=(e,t)=>async s=>{let a;s&&(s.preventDefault&&s.preventDefault(),s.persist&&s.persist());let u=tu(o);if(f.state.next({isSubmitting:!0}),n.resolver){const{errors:e,values:t}=await b();m(),r.errors=e,u=tu(t)}else await x(i);if(l.disabled.size)for(const e of l.disabled)Hu(u,e);if(Hu(r.errors,"root"),Vu(r.errors)){f.state.next({errors:{}});try{await e(u,s)}catch(e){a=e}}else t&&await t({...r.errors},s),z(),setTimeout(z);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Vu(r.errors)&&!a,submitCount:r.submitCount+1,errors:r.errors}),a)throw a},j=(e,t={})=>{const u=e?tu(e):s,c=tu(u),d=Vu(e),p=d?s:c;if(t.keepDefaultValues||(s=u),!t.keepValues){if(t.keepDirtyValues){const e=new Set([...l.mount,...Object.keys(Ku(s,o))]);for(const t of Array.from(e))ou(r.dirtyFields,t)?uu(p,t,ou(o,t)):T(t,ou(p,t))}else{if(eu&&ru(e))for(const e of l.mount){const t=ou(i,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(Bu(e)){const t=e.closest("form");if(t){t.reset();break}}}}if(t.keepFieldsRef)for(const e of l.mount)T(e,ou(p,e));else i={}}o=n.shouldUnregister?t.keepDefaultValues?tu(s):{}:tu(p),f.array.next({values:{...p}}),f.state.next({values:{...p}})}l={mount:t.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!h.isValid||!!t.keepIsValid||!!t.keepDirtyValues||!n.shouldUnregister&&!Vu(p),a.watch=!!n.shouldUnregister,a.keepIsValid=!!t.keepIsValid,a.action=!1,t.keepErrors||(r.errors={}),f.state.next({submitCount:t.keepSubmitCount?r.submitCount:0,isDirty:!d&&(t.keepDirty?r.isDirty:!(!t.keepDefaultValues||Nu(e,s))),isSubmitted:!!t.keepIsSubmitted&&r.isSubmitted,dirtyFields:d?{}:t.keepDirtyValues?t.keepDefaultValues&&o?Ku(s,o):r.dirtyFields:t.keepDefaultValues&&e?Ku(s,e):t.keepDirty?r.dirtyFields:{},touchedFields:t.keepTouched?r.touchedFields:{},errors:t.keepErrors?r.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1,defaultValues:s})},V=(e,t)=>j(lu(e)?e(o):e,{...n.resetOptions,...t}),U=e=>{r={...r,...e}},B={control:{register:F,unregister:I,getFieldState:P,handleSubmit:L,setError:M,_subscribe:N,_runSchema:b,_updateIsValidating:m,_focusError:z,_getWatch:A,_getDirty:w,_setValid:g,_setFieldArray:(e,t=[],l,u,c=!0,p=!0)=>{if(u&&l&&!n.disabled){if(a.action=!0,p&&Array.isArray(ou(i,e))){const t=l(ou(i,e),u.argA,u.argB);c&&uu(i,e,t)}if(p&&Array.isArray(ou(r.errors,e))){const t=l(ou(r.errors,e),u.argA,u.argB);c&&uu(r.errors,e,t),((e,t)=>{!iu(ou(e,t)).length&&Hu(e,t)})(r.errors,e)}if((h.touchedFields||d.touchedFields)&&p&&Array.isArray(ou(r.touchedFields,e))){const t=l(ou(r.touchedFields,e),u.argA,u.argB);c&&uu(r.touchedFields,e,t)}(h.dirtyFields||d.dirtyFields)&&(r.dirtyFields=Ku(s,o)),f.state.next({name:e,isDirty:w(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else uu(o,e,t)},_setDisabledField:D,_setErrors:e=>{r.errors=e,f.state.next({errors:r.errors,isValid:!1})},_getFieldArray:e=>iu(ou(a.mount?o:s,e,n.shouldUnregister?ou(s,e,[]):[])),_reset:j,_resetDefaultValues:()=>lu(n.defaultValues)&&n.defaultValues().then(e=>{V(e,n.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:()=>{for(const e of l.unMount){const t=ou(i,e);t&&(t._f.refs?t._f.refs.every(e=>!qu(e)):!qu(t._f.ref))&&I(e)}l.unMount=new Set},_disableForm:e=>{au(e)&&(f.state.next({disabled:e}),uc(i,(t,n)=>{const r=ou(i,n);r&&(t.disabled=r._f.disabled||e,Array.isArray(r._f.refs)&&r._f.refs.forEach(t=>{t.disabled=r._f.disabled||e}))},0,!1))},_subjects:f,_proxyFormState:h,get _fields(){return i},get _formValues(){return o},get _state(){return a},set _state(e){a=e},get _defaultValues(){return s},get _names(){return l},set _names(e){l=e},get _formState(){return r},get _options(){return n},set _options(e){n={...n,...e}}},subscribe:e=>(a.mount=!0,d={...d,...e.formState},N({...e,formState:{...c,...e.formState}})),trigger:R,register:F,handleSubmit:L,watch:(e,t)=>lu(e)?f.state.subscribe({next:n=>"values"in n&&e(A(void 0,t),n)}):A(e,t,!0),setValue:T,getValues:C,reset:V,resetField:(e,t={})=>{ou(i,e)&&(ru(t.defaultValue)?T(e,tu(ou(s,e))):(T(e,t.defaultValue),uu(s,e,tu(t.defaultValue))),t.keepTouched||Hu(r.touchedFields,e),t.keepDirty||(Hu(r.dirtyFields,e),r.isDirty=t.defaultValue?w(e,tu(ou(s,e))):w()),t.keepError||(Hu(r.errors,e),h.isValid&&g()),f.state.next({...r}))},clearErrors:e=>{e&&zu(e).forEach(e=>Hu(r.errors,e)),f.state.next({errors:e?r.errors:{}})},unregister:I,setError:M,setFocus:(e,t={})=>{const n=ou(i,e),r=n&&n._f;if(r){const e=r.refs?r.refs[0]:r.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&lu(e.select)&&e.select()})}},getFieldState:P};return{...B,formControl:B}}var _c=()=>{if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=(16*Math.random()+e)%16|0;return("x"==t?n:3&n|8).toString(16)})},yc=(e,t,n={})=>n.shouldFocus||ru(n.shouldFocus)?n.focusName||`${e}.${ru(n.focusIndex)?t:n.focusIndex}.`:"",vc=(e,t)=>[...e,...zu(t)],bc=e=>Array.isArray(e)?e.map(()=>{}):void 0;function xc(e,t,n){return[...e.slice(0,t),...zu(n),...e.slice(t)]}var wc=(e,t,n)=>Array.isArray(e)?(ru(e[n])&&(e[n]=void 0),e.splice(n,0,e.splice(t,1)[0]),e):[],Ac=(e,t)=>[...zu(t),...zu(e)];var Ec=(e,t)=>ru(t)?[]:function(e,t){let n=0;const r=[...e];for(const e of t)r.splice(e-n,1),n++;return iu(r).length?r:[]}(e,zu(t).sort((e,t)=>e-t)),Sc=(e,t,n)=>{[e[t],e[n]]=[e[n],e[t]]},Tc=(e,t,n)=>(e[t]=n,e);function kc(e){const n=Tu(),{control:r=n.control,name:i,keyName:s="id",shouldUnregister:o,rules:a}=e,[l,u]=t.useState(r._getFieldArray(i)),c=t.useRef(r._getFieldArray(i).map(_c)),h=t.useRef(!1);r._names.array.add(i),t.useMemo(()=>a&&l.length>=0&&r.register(i,a),[r,i,l.length,a]),Ru(()=>r._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===i||!t){const t=ou(e,i);Array.isArray(t)&&(u(t),c.current=t.map(_c))}}}).unsubscribe,[r,i]);const d=t.useCallback(e=>{h.current=!0,r._setFieldArray(i,e)},[r,i]);return t.useEffect(()=>{if(r._state.action=!1,lc(i,r._names)&&r._subjects.state.next({...r._formState}),h.current&&(!sc(r._options.mode).isOnSubmit||r._formState.isSubmitted)&&!sc(r._options.reValidateMode).isOnSubmit)if(r._options.resolver)r._runSchema([i]).then(e=>{r._updateIsValidating([i]);const t=ou(e.errors,i),n=ou(r._formState.errors,i);(n?!t&&n.type||t&&(n.type!==t.type||n.message!==t.message):t&&t.type)&&(t?uu(r._formState.errors,i,t):Hu(r._formState.errors,i),r._subjects.state.next({errors:r._formState.errors}))});else{const e=ou(r._fields,i);!e||!e._f||sc(r._options.reValidateMode).isOnSubmit&&sc(r._options.mode).isOnSubmit||pc(e,r._names.disabled,r._formValues,r._options.criteriaMode===_u,r._options.shouldUseNativeValidation,!0).then(e=>!Vu(e)&&r._subjects.state.next({errors:hc(r._formState.errors,e,i)}))}r._subjects.state.next({name:i,values:tu(r._formValues)}),r._names.focus&&uc(r._fields,(e,t)=>{if(r._names.focus&&t.startsWith(r._names.focus)&&e.focus)return e.focus(),1}),r._names.focus="",r._setValid(),h.current=!1},[l,i,r]),t.useEffect(()=>(!ou(r._formValues,i)&&r._setFieldArray(i),()=>{r._options.shouldUnregister||o?r.unregister(i):((e,t)=>{const n=ou(r._fields,e);n&&n._f&&(n._f.mount=t)})(i,!1)}),[i,r,s,o]),{swap:t.useCallback((e,t)=>{const n=r._getFieldArray(i);Sc(n,e,t),Sc(c.current,e,t),d(n),u(n),r._setFieldArray(i,n,Sc,{argA:e,argB:t},!1)},[d,i,r]),move:t.useCallback((e,t)=>{const n=r._getFieldArray(i);wc(n,e,t),wc(c.current,e,t),d(n),u(n),r._setFieldArray(i,n,wc,{argA:e,argB:t},!1)},[d,i,r]),prepend:t.useCallback((e,t)=>{const n=zu(tu(e)),s=Ac(r._getFieldArray(i),n);r._names.focus=yc(i,0,t),c.current=Ac(c.current,n.map(_c)),d(s),u(s),r._setFieldArray(i,s,Ac,{argA:bc(e)})},[d,i,r]),append:t.useCallback((e,t)=>{const n=zu(tu(e)),s=vc(r._getFieldArray(i),n);r._names.focus=yc(i,s.length-1,t),c.current=vc(c.current,n.map(_c)),d(s),u(s),r._setFieldArray(i,s,vc,{argA:bc(e)})},[d,i,r]),remove:t.useCallback(e=>{const t=Ec(r._getFieldArray(i),e);c.current=Ec(c.current,e),d(t),u(t),!Array.isArray(ou(r._fields,i))&&uu(r._fields,i,void 0),r._setFieldArray(i,t,Ec,{argA:e})},[d,i,r]),insert:t.useCallback((e,t,n)=>{const s=zu(tu(t)),o=xc(r._getFieldArray(i),e,s);r._names.focus=yc(i,e,n),c.current=xc(c.current,e,s.map(_c)),d(o),u(o),r._setFieldArray(i,o,xc,{argA:e,argB:bc(t)})},[d,i,r]),update:t.useCallback((e,t)=>{const n=tu(t),s=Tc(r._getFieldArray(i),e,n);c.current=[...s].map((t,n)=>t&&n!==e?c.current[n]:_c()),d(s),u([...s]),r._setFieldArray(i,s,Tc,{argA:e,argB:n},!0,!1)},[d,i,r]),replace:t.useCallback(e=>{const t=zu(tu(e));c.current=t.map(_c),d([...t]),u([...t]),r._setFieldArray(i,[...t],e=>e,{},!0,!1)},[d,i,r]),fields:t.useMemo(()=>l.map((e,t)=>({...e,[s]:c.current[t]||_c()})),[l,s])}}function Oc(e={}){const n=t.useRef(void 0),r=t.useRef(void 0),[i,s]=t.useState({isDirty:!1,isValidating:!1,isLoading:lu(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:lu(e.defaultValues)?void 0:e.defaultValues});if(!n.current)if(e.formControl)n.current={...e.formControl,formState:i},e.defaultValues&&!lu(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:t,...r}=mc(e);n.current={...r,formState:i}}const o=n.current.control;return o._options=e,Ru(()=>{const e=o._subscribe({formState:o._proxyFormState,callback:()=>s({...o._formState}),reRenderRoot:!0});return s(e=>({...e,isReady:!0})),o._formState.isReady=!0,e},[o]),t.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),t.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),t.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),t.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),t.useEffect(()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==i.isDirty&&o._subjects.state.next({isDirty:e})}},[o,i.isDirty]),t.useEffect(()=>{var t;e.values&&!Nu(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),(null===(t=o._options.resetOptions)||void 0===t?void 0:t.keepIsValid)||o._setValid(),r.current=e.values,s(e=>({...e}))):o._resetDefaultValues()},[o,e.values]),t.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),n.current.formState=Ou(i,o),n.current}const Rc=({sx:e,...t})=>b(se,{variant:"body1",sx:{color:"var(--color-white)",cursor:"default",...e},...t}),Cc=ne(ee)({padding:0,marginRight:"5px",marginLeft:"10px","& .MuiSvgIcon-root":{color:"var(--color-orange-medium)"}});function Pc({label:t,name:n,...r}){const i=e.useId(),{control:s,setValue:o,watch:a}=Tu(),l=a(n),u=`${i}-${n}-${String(l)}`;return b(Du,{control:s,name:n,render:({field:e})=>{const{value:n,name:i}=e;return t?b(te,{color:"white",control:b(Cc,{...r,checked:n,onChange:(e,t)=>{o(i,t,{shouldValidate:!0})}}),label:b(Rc,{children:t})}):b(Cc,{...r,checked:n,onChange:(e,t)=>{o(i,t,{shouldValidate:!0})}})}},u)}var Mc=function(t){var n=t.as,r=t.errors,i=t.name,s=t.message,o=t.render,a=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)t.indexOf(n=s[r])>=0||(i[n]=e[n]);return i}(t,["as","errors","name","message","render"]),l=Tu(),u=ou(r||l.formState.errors,i);if(!u)return null;var c=u.message,h=u.types,d=Object.assign({},a,{children:c||s});return e.isValidElement(n)?e.cloneElement(n,d):o?o({message:c||s,messages:h}):e.createElement(n||e.Fragment,d)};function Nc({name:e}){const{palette:t}=V(),{formState:{errors:n}}=Tu();return b(Mc,{errors:n,name:e,render:({message:e})=>b(Rc,{variant:"body2",style:{color:t.error.main},children:e})})}function Ic({form:e,sx:t={},onSubmit:n,children:r}){const{handleSubmit:i}=e;return b(ku,{...e,children:b(T,{component:"form",sx:{display:"grid",gap:"15px",...t},onSubmit:i(n),children:r})})}const Dc=()=>Tu(),Fc=e=>b(U,{size:"small",...e});function zc({name:t,...n}){const{control:r}=Tu(),i=e.useId();return b(Du,{control:r,name:t,render:({field:e})=>x(T,{sx:({spacing:e})=>({display:"grid",width:"100%",gap:e(1)}),children:[b(oe,{...n,...e,id:i,slots:{field:Fc}}),b(Nc,{name:t})]})})}const Lc=({text:e="Нет данных"})=>b(B,{variant:"body2",sx:{textAlign:"center",color:"var(--gray-light-color)"},children:e});function jc({items:t,columnsCount:n=1,getContent:r,title:i,getKey:s,onClick:o,sx:a,isShowNoData:l=!0}){const u=0===t.length;return x(T,{sx:{display:"grid",gridTemplateColumns:"1fr",gap:"15px",...a?.root},children:[i?b(B,{variant:"h6",noWrap:!0,sx:{textAlign:"center",fontWeight:700,...a?.title},children:i}):null,u?b(e.Fragment,{children:l?b(Lc,{}):null}):b(G,{sx:{display:"grid",gridTemplateColumns:`repeat(${n}, 1fr)`,gap:"15px",...a?.list},disablePadding:!0,children:t.map((e,t)=>b($,{onClick:()=>o?.(e,t),sx:{...a?.item},disablePadding:!0,children:r(e,t)},s(e,t)))})]})}const Vc="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function Uc(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function Bc(e){return"nodeType"in e}function Gc(e){var t,n;return e?Uc(e)?e:Bc(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function $c(e){const{Document:t}=Gc(e);return e instanceof t}function qc(e){return!Uc(e)&&e instanceof Gc(e).HTMLElement}function Hc(e){return e instanceof Gc(e).SVGElement}function Wc(e){return e?Uc(e)?e.document:Bc(e)?$c(e)?e:qc(e)||Hc(e)?e.ownerDocument:document:document:document}const Zc=Vc?u:s;function Kc(e){const t=r(e);return Zc(()=>{t.current=e}),i(function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)},[])}function Xc(e,t){void 0===t&&(t=[e]);const n=r(e);return Zc(()=>{n.current!==e&&(n.current=e)},t),n}function Yc(e,t){const n=r();return l(()=>{const t=e(n.current);return n.current=t,t},[...t])}function Qc(e){const t=Kc(e),n=r(null),s=i(e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e},[]);return[n,s]}function Jc(e){const t=r();return s(()=>{t.current=e},[e]),t.current}let eh={};function th(e,t){return l(()=>{if(t)return t;const n=null==eh[e]?0:eh[e]+1;return eh[e]=n,e+"-"+n},[e,t])}function nh(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>{const r=Object.entries(n);for(const[n,i]of r){const r=t[n];null!=r&&(t[n]=r+e*i)}return t},{...t})}}const rh=nh(1),ih=nh(-1);function sh(e){if(!e)return!1;const{KeyboardEvent:t}=Gc(e.target);return t&&e instanceof t}function oh(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=Gc(e.target);return t&&e instanceof t}(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const ah=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ah.Translate.toString(e),ah.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),lh="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function uh(e){return e.matches(lh)?e:e.querySelector(lh)}const ch={display:"none"};function hh(e){let{id:n,value:r}=e;return t.createElement("div",{id:n,style:ch},r)}function dh(e){let{id:n,announcement:r,ariaLiveType:i="assertive"}=e;return t.createElement("div",{id:n,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":i,"aria-atomic":!0},r)}const fh=g(null);const ph={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},gh={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function mh(e){let{announcements:n=gh,container:r,hiddenTextDescribedById:o,screenReaderInstructions:a=ph}=e;const{announce:u,announcement:h}=function(){const[e,t]=p("");return{announce:i(e=>{null!=e&&t(e)},[]),announcement:e}}(),d=th("DndLiveRegion"),[f,g]=p(!1);if(s(()=>{g(!0)},[]),function(e){const t=c(fh);s(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}(l(()=>({onDragStart(e){let{active:t}=e;u(n.onDragStart({active:t}))},onDragMove(e){let{active:t,over:r}=e;n.onDragMove&&u(n.onDragMove({active:t,over:r}))},onDragOver(e){let{active:t,over:r}=e;u(n.onDragOver({active:t,over:r}))},onDragEnd(e){let{active:t,over:r}=e;u(n.onDragEnd({active:t,over:r}))},onDragCancel(e){let{active:t,over:r}=e;u(n.onDragCancel({active:t,over:r}))}}),[u,n])),!f)return null;const m=t.createElement(t.Fragment,null,t.createElement(hh,{id:o,value:a.draggable}),t.createElement(dh,{id:d,announcement:h}));return r?y(m,r):m}var _h;function yh(){}!function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"}(_h||(_h={}));const vh=Object.freeze({x:0,y:0});function bh(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xh(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function wh(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Ah(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const Eh=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=Ah(t,t.left,t.top),s=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=bh(Ah(r),i);s.push({id:t,data:{droppableContainer:e,value:n}})}}return s.sort(xh)};function Sh(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;if(r<i&&n<s){const n=t.width*t.height,r=e.width*e.height,i=o*a;return Number((i/(n+r-i)).toFixed(4))}return 0}const Th=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=[];for(const e of r){const{id:r}=e,s=n.get(r);if(s){const n=Sh(s,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(wh)};function kh(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:vh}function Oh(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}const Rh=Oh(1);const Ch={ignoreTransform:!1};function Ph(e,t){void 0===t&&(t=Ch);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=Gc(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=function(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}(t);if(!r)return e;const{scaleX:i,scaleY:s,x:o,y:a}=r,l=e.left-o-(1-i)*parseFloat(n),u=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=i?e.width/i:e.width,h=s?e.height/s:e.height;return{width:c,height:h,top:u,right:l+c,bottom:u+h,left:l}}(n,t,r))}const{top:r,left:i,width:s,height:o,bottom:a,right:l}=n;return{top:r,left:i,width:s,height:o,bottom:a,right:l}}function Mh(e){return Ph(e,{ignoreTransform:!0})}function Nh(e,t){const n=[];return e?function r(i){if(null!=t&&n.length>=t)return n;if(!i)return n;if($c(i)&&null!=i.scrollingElement&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!qc(i)||Hc(i))return n;if(n.includes(i))return n;const s=Gc(e).getComputedStyle(i);return i!==e&&function(e,t){void 0===t&&(t=Gc(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(e=>{const r=t[e];return"string"==typeof r&&n.test(r)})}(i,s)&&n.push(i),function(e,t){return void 0===t&&(t=Gc(e).getComputedStyle(e)),"fixed"===t.position}(i,s)?n:r(i.parentNode)}(e):n}function Ih(e){const[t]=Nh(e,1);return null!=t?t:null}function Dh(e){return Vc&&e?Uc(e)?e:Bc(e)?$c(e)||e===Wc(e).scrollingElement?window:qc(e)?e:null:null:null}function Fh(e){return Uc(e)?e.scrollX:e.scrollLeft}function zh(e){return Uc(e)?e.scrollY:e.scrollTop}function Lh(e){return{x:Fh(e),y:zh(e)}}var jh;function Vh(e){return!(!Vc||!e)&&e===document.scrollingElement}function Uh(e){const t={x:0,y:0},n=Vh(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(jh||(jh={}));const Bh={x:.2,y:.2};function Gh(e,t,n,r,i){let{top:s,left:o,right:a,bottom:l}=n;void 0===r&&(r=10),void 0===i&&(i=Bh);const{isTop:u,isBottom:c,isLeft:h,isRight:d}=Uh(e),f={x:0,y:0},p={x:0,y:0},g=t.height*i.y,m=t.width*i.x;return!u&&s<=t.top+g?(f.y=jh.Backward,p.y=r*Math.abs((t.top+g-s)/g)):!c&&l>=t.bottom-g&&(f.y=jh.Forward,p.y=r*Math.abs((t.bottom-g-l)/g)),!d&&a>=t.right-m?(f.x=jh.Forward,p.x=r*Math.abs((t.right-m-a)/m)):!h&&o<=t.left+m&&(f.x=jh.Backward,p.x=r*Math.abs((t.left+m-o)/m)),{direction:f,speed:p}}function $h(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function qh(e){return e.reduce((e,t)=>rh(e,Lh(t)),vh)}const Hh=[["x",["left","right"],function(e){return e.reduce((e,t)=>e+Fh(t),0)}],["y",["top","bottom"],function(e){return e.reduce((e,t)=>e+zh(t),0)}]];class Wh{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Nh(t),r=qh(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,i]of Hh)for(const s of t)Object.defineProperty(this,s,{get:()=>{const t=i(n),o=r[e]-t;return this.rect[s]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Zh{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)})},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function Kh(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var Xh,Yh;function Qh(e){e.preventDefault()}function Jh(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(Xh||(Xh={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"}(Yh||(Yh={}));const ed={start:[Yh.Space,Yh.Enter],cancel:[Yh.Esc],end:[Yh.Space,Yh.Enter,Yh.Tab]},td=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Yh.Right:return{...n,x:n.x+25};case Yh.Left:return{...n,x:n.x-25};case Yh.Down:return{...n,y:n.y+25};case Yh.Up:return{...n,y:n.y-25}}};class nd{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Zh(Wc(t)),this.windowListeners=new Zh(Gc(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Xh.Resize,this.handleCancel),this.windowListeners.add(Xh.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Xh.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=Ph),!e)return;const{top:n,left:r,bottom:i,right:s}=t(e);Ih(e)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(vh)}handleKeyDown(e){if(sh(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:i=ed,coordinateGetter:s=td,scrollBehavior:o="smooth"}=r,{code:a}=e;if(i.end.includes(a))return void this.handleEnd(e);if(i.cancel.includes(a))return void this.handleCancel(e);const{collisionRect:l}=n.current,u=l?{x:l.left,y:l.top}:vh;this.referenceCoordinates||(this.referenceCoordinates=u);const c=s(e,{active:t,context:n.current,currentCoordinates:u});if(c){const t=ih(c,u),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(const n of i){const i=e.code,{isTop:s,isRight:a,isLeft:l,isBottom:u,maxScroll:h,minScroll:d}=Uh(n),f=$h(n),p={x:Math.min(i===Yh.Right?f.right-f.width/2:f.right,Math.max(i===Yh.Right?f.left:f.left+f.width/2,c.x)),y:Math.min(i===Yh.Down?f.bottom-f.height/2:f.bottom,Math.max(i===Yh.Down?f.top:f.top+f.height/2,c.y))},g=i===Yh.Right&&!a||i===Yh.Left&&!l,m=i===Yh.Down&&!u||i===Yh.Up&&!s;if(g&&p.x!==c.x){const e=n.scrollLeft+t.x,s=i===Yh.Right&&e<=h.x||i===Yh.Left&&e>=d.x;if(s&&!t.y)return void n.scrollTo({left:e,behavior:o});r.x=s?n.scrollLeft-e:i===Yh.Right?n.scrollLeft-h.x:n.scrollLeft-d.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}if(m&&p.y!==c.y){const e=n.scrollTop+t.y,s=i===Yh.Down&&e<=h.y||i===Yh.Up&&e>=d.y;if(s&&!t.x)return void n.scrollTo({top:e,behavior:o});r.y=s?n.scrollTop-e:i===Yh.Down?n.scrollTop-h.y:n.scrollTop-d.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,rh(ih(c,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function rd(e){return Boolean(e&&"distance"in e)}function id(e){return Boolean(e&&"delay"in e)}nd.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=ed,onActivation:i}=t,{active:s}=n;const{code:o}=e.nativeEvent;if(r.start.includes(o)){const t=s.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==i||i({event:e.nativeEvent}),!0)}return!1}}];class sd{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=Gc(e);return e instanceof t?e:Wc(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:i}=e,{target:s}=i;this.props=e,this.events=t,this.document=Wc(s),this.documentListeners=new Zh(this.document),this.listeners=new Zh(n),this.windowListeners=new Zh(Gc(s)),this.initialCoordinates=null!=(r=oh(i))?r:vh,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Xh.Resize,this.handleCancel),this.windowListeners.add(Xh.DragStart,Qh),this.windowListeners.add(Xh.VisibilityChange,this.handleCancel),this.windowListeners.add(Xh.ContextMenu,Qh),this.documentListeners.add(Xh.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(id(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(rd(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Xh.Click,Jh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Xh.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:i}=this,{onMove:s,options:{activationConstraint:o}}=i;if(!r)return;const a=null!=(t=oh(e))?t:vh,l=ih(r,a);if(!n&&o){if(rd(o)){if(null!=o.tolerance&&Kh(l,o.tolerance))return this.handleCancel();if(Kh(l,o.distance))return this.handleStart()}return id(o)&&Kh(l,o.tolerance)?this.handleCancel():void this.handlePending(o,l)}e.cancelable&&e.preventDefault(),s(a)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Yh.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const od={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ad extends sd{constructor(e){const{event:t}=e,n=Wc(t.target);super(e,od,n)}}ad.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const ld={move:{name:"mousemove"},end:{name:"mouseup"}};var ud;!function(e){e[e.RightClick=2]="RightClick"}(ud||(ud={}));(class extends sd{constructor(e){super(e,ld,Wc(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==ud.RightClick&&(null==r||r({event:n}),!0)}}];const cd={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var hd,dd;function fd(e){let{acceleration:t,activator:n=hd.Pointer,canScroll:o,draggingRect:a,enabled:u,interval:c=5,order:h=dd.TreeOrder,pointerCoordinates:d,scrollableAncestors:f,scrollableAncestorRects:p,delta:g,threshold:m}=e;const _=function(e){let{delta:t,disabled:n}=e;const r=Jc(t);return Yc(e=>{if(n||!r||!e)return pd;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[jh.Backward]:e.x[jh.Backward]||-1===i.x,[jh.Forward]:e.x[jh.Forward]||1===i.x},y:{[jh.Backward]:e.y[jh.Backward]||-1===i.y,[jh.Forward]:e.y[jh.Forward]||1===i.y}}},[n,t,r])}({delta:g,disabled:!u}),[y,v]=function(){const e=r(null);return[i((t,n)=>{e.current=setInterval(t,n)},[]),i(()=>{null!==e.current&&(clearInterval(e.current),e.current=null)},[])]}(),b=r({x:0,y:0}),x=r({x:0,y:0}),w=l(()=>{switch(n){case hd.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case hd.DraggableRect:return a}},[n,a,d]),A=r(null),E=i(()=>{const e=A.current;if(!e)return;const t=b.current.x*x.current.x,n=b.current.y*x.current.y;e.scrollBy(t,n)},[]),S=l(()=>h===dd.TreeOrder?[...f].reverse():f,[h,f]);s(()=>{if(u&&f.length&&w){for(const e of S){if(!1===(null==o?void 0:o(e)))continue;const n=f.indexOf(e),r=p[n];if(!r)continue;const{direction:i,speed:s}=Gh(e,r,w,t,m);for(const e of["x","y"])_[e][i[e]]||(s[e]=0,i[e]=0);if(s.x>0||s.y>0)return v(),A.current=e,y(E,c),b.current=s,void(x.current=i)}b.current={x:0,y:0},x.current={x:0,y:0},v()}else v()},[t,E,o,v,u,c,JSON.stringify(w),JSON.stringify(_),y,f,S,p,JSON.stringify(m)])}(class extends sd{constructor(e){super(e,cd)}static setup(){return window.addEventListener(cd.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(cd.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:i}=n;return!(i.length>1)&&(null==r||r({event:n}),!0)}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(hd||(hd={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(dd||(dd={}));const pd={x:{[jh.Backward]:!1,[jh.Forward]:!1},y:{[jh.Backward]:!1,[jh.Forward]:!1}};var gd,md;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(gd||(gd={})),function(e){e.Optimized="optimized"}(md||(md={}));const _d=new Map;function yd(e,t){return Yc(n=>e?n||("function"==typeof t?t(e):e):null,[t,e])}function vd(e){let{callback:t,disabled:n}=e;const r=Kc(t),i=l(()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)},[n]);return s(()=>()=>null==i?void 0:i.disconnect(),[i]),i}function bd(e){return new Wh(Ph(e),e)}function xd(e,t,n){void 0===t&&(t=bd);const[r,i]=p(null);function o(){i(r=>{if(!e)return null;var i;if(!1===e.isConnected)return null!=(i=null!=r?r:n)?i:null;const s=t(e);return JSON.stringify(r)===JSON.stringify(s)?r:s})}const a=function(e){let{callback:t,disabled:n}=e;const r=Kc(t),i=l(()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)},[r,n]);return s(()=>()=>null==i?void 0:i.disconnect(),[i]),i}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){o();break}}}}),u=vd({callback:o});return Zc(()=>{o(),e?(null==u||u.observe(e),null==a||a.observe(document.body,{childList:!0,subtree:!0})):(null==u||u.disconnect(),null==a||a.disconnect())},[e]),r}const wd=[];function Ad(e,t){void 0===t&&(t=[]);const n=r(null);return s(()=>{n.current=null},t),s(()=>{const t=e!==vh;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?ih(e,n.current):vh}function Ed(e){return l(()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null,[e])}const Sd=[];function Td(e){let{measure:t}=e;const[n,r]=p(null),s=i(e=>{for(const{target:n}of e)if(qc(n)){r(e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t]),o=vd({callback:s}),a=i(e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return qc(t)?t:e}(e);null==o||o.disconnect(),n&&(null==o||o.observe(n)),r(n?t(n):null)},[t,o]),[u,c]=Qc(a);return l(()=>({nodeRef:u,rect:n,setRef:c}),[n,u,c])}const kd=[{sensor:ad,options:{}},{sensor:nd,options:{}}],Od={current:{}},Rd={draggable:{measure:Mh},droppable:{measure:Mh,strategy:gd.WhileDragging,frequency:md.Optimized},dragOverlay:{measure:Ph}};class Cd extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const Pd={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Cd,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:yh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Rd,measureDroppableContainers:yh,windowRect:null,measuringScheduled:!1},Md=g({activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:yh,draggableNodes:new Map,over:null,measureDroppableContainers:yh}),Nd=g(Pd);function Id(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Cd}}}function Dd(e,t){switch(t.type){case _h.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case _h.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case _h.DragEnd:case _h.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case _h.RegisterDroppable:{const{element:n}=t,{id:r}=n,i=new Cd(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case _h.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const o=new Cd(e.droppable.containers);return o.set(n,{...s,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case _h.UnregisterDroppable:{const{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Cd(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function Fd(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:i}=c(Md),o=Jc(r),a=Jc(null==n?void 0:n.id);return s(()=>{if(!t&&!r&&o&&null!=a){if(!sh(o))return;if(document.activeElement===o.target)return;const e=i.get(a);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=uh(e);if(t){t.focus();break}}})}},[r,t,i,a,o]),null}const zd=g({...vh,scaleX:1,scaleY:1});var Ld;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(Ld||(Ld={}));const jd=h(function(e){var n,o,a,u;let{id:c,accessibility:h,autoScroll:d=!0,children:f,sensors:g=kd,collisionDetection:_=Th,measuring:y,modifiers:b,...x}=e;const w=m(Dd,void 0,Id),[A,E]=w,[S,T]=function(){const[e]=p(()=>new Set),t=i(t=>(e.add(t),()=>e.delete(t)),[e]);return[i(t=>{let{type:n,event:r}=t;e.forEach(e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)})},[e]),t]}(),[k,O]=p(Ld.Uninitialized),R=k===Ld.Initialized,{draggable:{active:C,nodes:P,translate:M},droppable:{containers:N}}=A,I=null!=C?P.get(C):null,D=r({initial:null,translated:null}),F=l(()=>{var e;return null!=C?{id:C,data:null!=(e=null==I?void 0:I.data)?e:Od,rect:D}:null},[C,I]),z=r(null),[L,j]=p(null),[V,U]=p(null),B=Xc(x,Object.values(x)),G=th("DndDescribedBy",c),$=l(()=>N.getEnabled(),[N]),q=l(()=>({draggable:{...Rd.draggable,...null==H?void 0:H.draggable},droppable:{...Rd.droppable,...null==H?void 0:H.droppable},dragOverlay:{...Rd.dragOverlay,...null==H?void 0:H.dragOverlay}}),[null==(H=y)?void 0:H.draggable,null==H?void 0:H.droppable,null==H?void 0:H.dragOverlay]);var H;const{droppableRects:W,measureDroppableContainers:Z,measuringScheduled:K}=function(e,t){let{dragging:n,dependencies:o,config:a}=t;const[l,u]=p(null),{frequency:c,measure:h,strategy:d}=a,f=r(e),g=function(){switch(d){case gd.Always:return!1;case gd.BeforeDragging:return n;default:return!n}}(),m=Xc(g),_=i(function(e){void 0===e&&(e=[]),m.current||u(t=>null===t?e:t.concat(e.filter(e=>!t.includes(e))))},[m]),y=r(null),v=Yc(t=>{if(g&&!n)return _d;if(!t||t===_d||f.current!==e||null!=l){const t=new Map;for(let n of e){if(!n)continue;if(l&&l.length>0&&!l.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new Wh(h(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,l,n,g,h]);return s(()=>{f.current=e},[e]),s(()=>{g||_()},[n,g]),s(()=>{l&&l.length>0&&u(null)},[JSON.stringify(l)]),s(()=>{g||"number"!=typeof c||null!==y.current||(y.current=setTimeout(()=>{_(),y.current=null},c))},[c,g,_,...o]),{droppableRects:v,measureDroppableContainers:_,measuringScheduled:null!=l}}($,{dragging:R,dependencies:[M.x,M.y],config:q.droppable}),X=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return Yc(e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null},[r,t])}(P,C),Y=l(()=>V?oh(V):null,[V]),Q=function(){const e=!1===(null==L?void 0:L.autoScrollEnabled),t="object"==typeof d?!1===d.enabled:!1===d,n=R&&!e&&!t;if("object"==typeof d)return{...d,enabled:n};return{enabled:n}}(),J=function(e,t){return yd(e,t)}(X,q.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:i,config:s=!0}=e;const o=r(!1),{x:a,y:l}="boolean"==typeof s?{x:s,y:s}:s;Zc(()=>{if(!a&&!l||!t)return void(o.current=!1);if(o.current||!i)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=kh(n(e),i);if(a||(r.x=0),l||(r.y=0),o.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=Ih(e);t&&t.scrollBy({top:r.y,left:r.x})}},[t,a,l,i,n])}({activeNode:null!=C?P.get(C):null,config:Q.layoutShiftCompensation,initialRect:J,measure:q.draggable.measure});const ee=xd(X,q.draggable.measure,J),te=xd(X?X.parentElement:null),ne=r({activatorEvent:null,active:null,activeNode:X,collisionRect:null,collisions:null,droppableRects:W,draggableNodes:P,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),re=N.getNodeFor(null==(n=ne.current.over)?void 0:n.id),ie=Td({measure:q.dragOverlay.measure}),se=null!=(o=ie.nodeRef.current)?o:X,oe=R?null!=(a=ie.rect)?a:ee:null,ae=Boolean(ie.nodeRef.current&&ie.rect),le=kh(ue=ae?null:ee,yd(ue));var ue;const ce=Ed(se?Gc(se):null),he=function(e){const t=r(e),n=Yc(n=>e?n&&n!==wd&&e&&t.current&&e.parentNode===t.current.parentNode?n:Nh(e):wd,[e]);return s(()=>{t.current=e},[e]),n}(R?null!=re?re:X:null),de=function(e,t){void 0===t&&(t=Ph);const[n]=e,r=Ed(n?Gc(n):null),[i,s]=p(Sd);function o(){s(()=>e.length?e.map(e=>Vh(e)?r:new Wh(t(e),e)):Sd)}const a=vd({callback:o});return Zc(()=>{null==a||a.disconnect(),o(),e.forEach(e=>null==a?void 0:a.observe(e))},[e]),i}(he),fe=function(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}(b,{transform:{x:M.x-le.x,y:M.y-le.y,scaleX:1,scaleY:1},activatorEvent:V,active:F,activeNodeRect:ee,containerNodeRect:te,draggingNodeRect:oe,over:ne.current.over,overlayNodeRect:ie.rect,scrollableAncestors:he,scrollableAncestorRects:de,windowRect:ce}),pe=Y?rh(Y,M):null,ge=function(e){const[t,n]=p(null),o=r(e),a=i(e=>{const t=Dh(e.target);t&&n(e=>e?(e.set(t,Lh(t)),new Map(e)):null)},[]);return s(()=>{const t=o.current;if(e!==t){r(t);const i=e.map(e=>{const t=Dh(e);return t?(t.addEventListener("scroll",a,{passive:!0}),[t,Lh(t)]):null}).filter(e=>null!=e);n(i.length?new Map(i):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach(e=>{const t=Dh(e);null==t||t.removeEventListener("scroll",a)})}},[a,e]),l(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>rh(e,t),vh):qh(e):vh,[e,t])}(he),me=Ad(ge),_e=Ad(ge,[ee]),ye=rh(fe,me),ve=oe?Rh(oe,fe):null,be=F&&ve?_({active:F,collisionRect:ve,droppableRects:W,droppableContainers:$,pointerCoordinates:pe}):null,xe=function(e,t){if(!e||0===e.length)return null;const[n]=e;return n[t]}(be,"id"),[we,Ae]=p(null),Ee=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(ae?fe:rh(fe,_e),null!=(u=null==we?void 0:we.rect)?u:null,ee),Se=r(null),Te=i((e,t)=>{let{sensor:n,options:r}=t;if(null==z.current)return;const i=P.get(z.current);if(!i)return;const s=e.nativeEvent,o=new n({active:z.current,activeNode:i,event:s,options:r,context:ne,onAbort(e){if(!P.get(e))return;const{onDragAbort:t}=B.current,n={id:e};null==t||t(n),S({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!P.get(e))return;const{onDragPending:i}=B.current,s={id:e,constraint:t,initialCoordinates:n,offset:r};null==i||i(s),S({type:"onDragPending",event:s})},onStart(e){const t=z.current;if(null==t)return;const n=P.get(t);if(!n)return;const{onDragStart:r}=B.current,i={activatorEvent:s,active:{id:t,data:n.data,rect:D}};v(()=>{null==r||r(i),O(Ld.Initializing),E({type:_h.DragStart,initialCoordinates:e,active:t}),S({type:"onDragStart",event:i}),j(Se.current),U(s)})},onMove(e){E({type:_h.DragMove,coordinates:e})},onEnd:a(_h.DragEnd),onCancel:a(_h.DragCancel)});function a(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ne.current;let o=null;if(t&&i){const{cancelDrop:a}=B.current;if(o={activatorEvent:s,active:t,collisions:n,delta:i,over:r},e===_h.DragEnd&&"function"==typeof a){await Promise.resolve(a(o))&&(e=_h.DragCancel)}}z.current=null,v(()=>{E({type:e}),O(Ld.Uninitialized),Ae(null),j(null),U(null),Se.current=null;const t=e===_h.DragEnd?"onDragEnd":"onDragCancel";if(o){const e=B.current[t];null==e||e(o),S({type:t,event:o})}})}}Se.current=o},[P]),ke=i((e,t)=>(n,r)=>{const i=n.nativeEvent,s=P.get(r);if(null!==z.current||!s||i.dndKit||i.defaultPrevented)return;const o={active:s};!0===e(n,t.options,o)&&(i.dndKit={capturedBy:t.sensor},z.current=r,Te(n,t))},[P,Te]),Oe=function(e,t){return l(()=>e.reduce((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}))]},[]),[e,t])}(g,ke);!function(e){s(()=>{if(!Vc)return;const t=e.map(e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()});return()=>{for(const e of t)null==e||e()}},e.map(e=>{let{sensor:t}=e;return t}))}(g),Zc(()=>{ee&&k===Ld.Initializing&&O(Ld.Initialized)},[ee,k]),s(()=>{const{onDragMove:e}=B.current,{active:t,activatorEvent:n,collisions:r,over:i}=ne.current;if(!t||!n)return;const s={active:t,activatorEvent:n,collisions:r,delta:{x:ye.x,y:ye.y},over:i};v(()=>{null==e||e(s),S({type:"onDragMove",event:s})})},[ye.x,ye.y]),s(()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ne.current;if(!e||null==z.current||!t||!i)return;const{onDragOver:s}=B.current,o=r.get(xe),a=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:a};v(()=>{Ae(a),null==s||s(l),S({type:"onDragOver",event:l})})},[xe]),Zc(()=>{ne.current={activatorEvent:V,active:F,activeNode:X,collisionRect:ve,collisions:be,droppableRects:W,draggableNodes:P,draggingNode:se,draggingNodeRect:oe,droppableContainers:N,over:we,scrollableAncestors:he,scrollAdjustedTranslate:ye},D.current={initial:oe,translated:ve}},[F,X,be,ve,P,se,oe,W,N,we,he,ye]),fd({...Q,delta:M,draggingRect:ve,pointerCoordinates:pe,scrollableAncestors:he,scrollableAncestorRects:de});const Re=l(()=>({active:F,activeNode:X,activeNodeRect:ee,activatorEvent:V,collisions:be,containerNodeRect:te,dragOverlay:ie,draggableNodes:P,droppableContainers:N,droppableRects:W,over:we,measureDroppableContainers:Z,scrollableAncestors:he,scrollableAncestorRects:de,measuringConfiguration:q,measuringScheduled:K,windowRect:ce}),[F,X,ee,V,be,te,ie,P,N,W,we,Z,he,de,q,K,ce]),Ce=l(()=>({activatorEvent:V,activators:Oe,active:F,activeNodeRect:ee,ariaDescribedById:{draggable:G},dispatch:E,draggableNodes:P,over:we,measureDroppableContainers:Z}),[V,Oe,F,ee,E,G,P,we,Z]);return t.createElement(fh.Provider,{value:T},t.createElement(Md.Provider,{value:Ce},t.createElement(Nd.Provider,{value:Re},t.createElement(zd.Provider,{value:Ee},f)),t.createElement(Fd,{disabled:!1===(null==h?void 0:h.restoreFocus)})),t.createElement(mh,{...h,hiddenTextDescribedById:G}))}),Vd=g(null),Ud="button";function Bd(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e;const s=th("Draggable"),{activators:o,activatorEvent:a,active:u,activeNodeRect:h,ariaDescribedById:d,draggableNodes:f,over:p}=c(Md),{role:g=Ud,roleDescription:m="draggable",tabIndex:_=0}=null!=i?i:{},y=(null==u?void 0:u.id)===t,v=c(y?zd:Vd),[b,x]=Qc(),[w,A]=Qc(),E=function(e,t){return l(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}(o,t),S=Xc(n);Zc(()=>(f.set(t,{id:t,key:s,node:b,activatorNode:w,data:S}),()=>{const e=f.get(t);e&&e.key===s&&f.delete(t)}),[f,t]);return{active:u,activatorEvent:a,activeNodeRect:h,attributes:l(()=>({role:g,tabIndex:_,"aria-disabled":r,"aria-pressed":!(!y||g!==Ud)||void 0,"aria-roledescription":m,"aria-describedby":d.draggable}),[r,g,_,y,m,d.draggable]),isDragging:y,listeners:r?void 0:E,node:b,over:p,setNodeRef:x,setActivatorNodeRef:A,transform:v}}const Gd={timeout:25};function $d(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function qd(e,t){return e.reduce((e,n,r)=>{const i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Hd(e){return null!==e&&e>=0}const Wd=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e;const s=$d(t,r,n),o=t[i],a=s[i];return a&&o?{x:a.left-o.left,y:a.top-o.top,scaleX:a.width/o.width,scaleY:a.height/o.height}:null},Zd={scaleX:1,scaleY:1},Kd=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:o}=e;const a=null!=(t=s[n])?t:r;if(!a)return null;if(i===n){const e=s[o];return e?{x:0,y:n<o?e.top+e.height-(a.top+a.height):e.top-a.top,...Zd}:null}const l=function(e,t,n){const r=e[t],i=e[t-1],s=e[t+1];if(!r)return 0;if(n<t)return i?r.top-(i.top+i.height):s?s.top-(r.top+r.height):0;return s?s.top-(r.top+r.height):i?r.top-(i.top+i.height):0}(s,i,n);return i>n&&i<=o?{x:0,y:-a.height-l,...Zd}:i<n&&i>=o?{x:0,y:a.height+l,...Zd}:{x:0,y:0,...Zd}};const Xd="Sortable",Yd=t.createContext({activeIndex:-1,containerId:Xd,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Wd,disabled:{draggable:!1,droppable:!1}});function Qd(e){let{children:n,id:i,items:o,strategy:a=Wd,disabled:u=!1}=e;const{active:h,dragOverlay:d,droppableRects:f,over:p,measureDroppableContainers:g}=c(Nd),m=th(Xd,i),_=Boolean(null!==d.rect),y=l(()=>o.map(e=>"object"==typeof e&&"id"in e?e.id:e),[o]),v=null!=h,b=h?y.indexOf(h.id):-1,x=p?y.indexOf(p.id):-1,w=r(y),A=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(y,w.current),E=-1!==x&&-1===b||A,S=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(u);Zc(()=>{A&&v&&g(y)},[A,y,v,g]),s(()=>{w.current=y},[y]);const T=l(()=>({activeIndex:b,containerId:m,disabled:S,disableTransforms:E,items:y,overIndex:x,useDragOverlay:_,sortedRects:qd(y,f),strategy:a}),[b,m,S.draggable,S.droppable,E,y,x,f,_,a]);return t.createElement(Yd.Provider,{value:T},n)}const Jd=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return $d(n,r,i).indexOf(t)},ef=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:a,previousContainerId:l,transition:u}=e;return!(!u||!r)&&((a===s||i!==o)&&(!!n||o!==i&&t===l))},tf={duration:200,easing:"ease"},nf="transform",rf=ah.Transition.toString({property:nf,duration:0,easing:"linear"}),sf={roleDescription:"sortable"};function of(e){let{animateLayoutChanges:t=ef,attributes:n,disabled:o,data:a,getNewIndex:u=Jd,id:h,strategy:d,resizeObserverConfig:f,transition:g=tf}=e;const{items:m,containerId:_,activeIndex:y,disabled:v,disableTransforms:b,sortedRects:x,overIndex:w,useDragOverlay:A,strategy:E}=c(Yd),S=function(e,t){var n,r;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(o,v),T=m.indexOf(h),k=l(()=>({sortable:{containerId:_,index:T,items:m},...a}),[_,a,T,m]),O=l(()=>m.slice(m.indexOf(h)),[m,h]),{rect:R,node:C,isOver:P,setNodeRef:M}=function(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:a}=e;const l=th("Droppable"),{active:u,dispatch:h,over:d,measureDroppableContainers:f}=c(Md),p=r({disabled:n}),g=r(!1),m=r(null),_=r(null),{disabled:y,updateMeasurementsFor:v,timeout:b}={...Gd,...a},x=Xc(null!=v?v:o),w=vd({callback:i(()=>{g.current?(null!=_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{f(Array.isArray(x.current)?x.current:[x.current]),_.current=null},b)):g.current=!0},[b]),disabled:y||!u}),A=i((e,t)=>{w&&(t&&(w.unobserve(t),g.current=!1),e&&w.observe(e))},[w]),[E,S]=Qc(A),T=Xc(t);return s(()=>{w&&E.current&&(w.disconnect(),g.current=!1,w.observe(E.current))},[E,w]),s(()=>(h({type:_h.RegisterDroppable,element:{id:o,key:l,disabled:n,node:E,rect:m,data:T}}),()=>h({type:_h.UnregisterDroppable,key:l,id:o})),[o]),s(()=>{n!==p.current.disabled&&(h({type:_h.SetDroppableDisabled,id:o,key:l,disabled:n}),p.current.disabled=n)},[o,l,n,h]),{active:u,rect:m,isOver:(null==d?void 0:d.id)===o,node:E,over:d,setNodeRef:S}}({id:h,data:k,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...f}}),{active:N,activatorEvent:I,activeNodeRect:D,attributes:F,setNodeRef:z,listeners:L,isDragging:j,over:V,setActivatorNodeRef:U,transform:B}=Bd({id:h,data:k,attributes:{...sf,...n},disabled:S.draggable}),G=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l(()=>e=>{t.forEach(t=>t(e))},t)}(M,z),$=Boolean(N),q=$&&!b&&Hd(y)&&Hd(w),H=!A&&j,W=H&&q?B:null,Z=q?null!=W?W:(null!=d?d:E)({rects:x,activeNodeRect:D,activeIndex:y,overIndex:w,index:T}):null,K=Hd(y)&&Hd(w)?u({id:h,items:m,activeIndex:y,overIndex:w}):T,X=null==N?void 0:N.id,Y=r({activeId:X,items:m,newIndex:K,containerId:_}),Q=m!==Y.current.items,J=t({active:N,containerId:_,isDragging:j,isSorting:$,id:h,index:T,items:m,newIndex:Y.current.newIndex,previousItems:Y.current.items,previousContainerId:Y.current.containerId,transition:g,wasDragging:null!=Y.current.activeId}),ee=function(e){let{disabled:t,index:n,node:i,rect:o}=e;const[a,l]=p(null),u=r(n);return Zc(()=>{if(!t&&n!==u.current&&i.current){const e=o.current;if(e){const t=Ph(i.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&l(n)}}n!==u.current&&(u.current=n)},[t,n,i,o]),s(()=>{a&&l(null)},[a]),a}({disabled:!J,index:T,node:C,rect:R});return s(()=>{$&&Y.current.newIndex!==K&&(Y.current.newIndex=K),_!==Y.current.containerId&&(Y.current.containerId=_),m!==Y.current.items&&(Y.current.items=m)},[$,K,_,m]),s(()=>{if(X===Y.current.activeId)return;if(null!=X&&null==Y.current.activeId)return void(Y.current.activeId=X);const e=setTimeout(()=>{Y.current.activeId=X},50);return()=>clearTimeout(e)},[X]),{active:N,activeIndex:y,attributes:F,data:k,rect:R,index:T,newIndex:K,items:m,isOver:P,isSorting:$,isDragging:j,listeners:L,node:C,overIndex:w,over:V,setNodeRef:G,setActivatorNodeRef:U,setDroppableNodeRef:M,setDraggableNodeRef:z,transform:null!=ee?ee:Z,transition:function(){if(ee||Q&&Y.current.newIndex===T)return rf;if(H&&!sh(I)||!g)return;if($||J)return ah.Transition.toString({...g,property:nf});return}()}}Yh.Down,Yh.Right,Yh.Up,Yh.Left;const af=({id:e,sx:t,children:n})=>{const{isDragging:r}=Bd({id:e}),{attributes:i,listeners:s,setNodeRef:o,transform:a,transition:l}=of({id:e,strategy:Kd,transition:{duration:300,easing:"cubic-bezier(0.25, 1, 0.5, 1)"}}),u={...t?.default,...r?t?.dragging:{},transform:ah.Translate.toString(a),transition:l,cursor:"pointer"};return b(T,{ref:o,style:u,...s,...i,children:n})};function lf({items:e,getItem:t,getId:n,onDragEnd:r,sx:i,title:s,draggableSx:o}){const a=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l(()=>[...t].filter(e=>null!=e),[...t])}(l(()=>({sensor:u,options:null!=c?c:{}}),[u=ad,c={activationConstraint:{distance:8}}]));var u,c;return b(jd,{sensors:a,collisionDetection:Eh,onDragEnd:t=>{const{active:i,over:s}=t,o=e.findIndex(e=>n(e)===i.id),a=e.findIndex(e=>n(e)===s?.id),l=$d(e,o,a);r(l)},children:b(Qd,{items:e.map(n),strategy:Kd,children:b(jc,{items:e,sx:i,title:s,getKey:n,getContent:(e,r)=>{const i=n(e);return b(af,{id:i,sx:o,children:t(e,r)},i)}})})})}const uf=g(null),cf={didCatch:!1,error:null};class hf extends d{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=cf}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(null!==e){for(var t,n,r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];null===(t=(n=this.props).onReset)||void 0===t||t.call(n,{args:i,reason:"imperative-api"}),this.setState(cf)}}componentDidCatch(e,t){var n,r;null===(n=(r=this.props).onError)||void 0===n||n.call(r,e,t)}componentDidUpdate(e,t){const{didCatch:n}=this.state,{resetKeys:r}=this.props;var i,s;n&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}(e.resetKeys,r)&&(null===(i=(s=this.props).onReset)||void 0===i||i.call(s,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(cf))}render(){const{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:s}=this.state;let a=e;if(i){const e={error:s,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)a=t(e);else if(n)a=o(n,e);else{if(void 0===r)throw s;a=r}}return o(uf.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}const df=({error:e,resetErrorBoundary:t})=>x(T,{role:"alert",sx:{padding:"20px",background:"#fee"},children:[b(B,{variant:"h2",children:"Ошибка приложения"}),b(B,{variant:"body1",color:"error",children:e.message}),b(jl,{onClick:t,children:"Попробовать снова"})]}),ff=({children:e,FallbackComponent:t=df})=>b(hf,{FallbackComponent:t,children:e});function pf(t){const{name:n,type:r}=t,i=e.useId(),{control:s}=Tu();return b(Du,{name:n,control:s,render:({field:e})=>x(T,{sx:({spacing:e})=>({display:"grid",width:"100%",gap:e(1)}),children:[b(Fc,{id:i,size:"small",...t,...e,onChange:t=>{const{target:n}=t,{value:i}=n;if("number"===r)""===i?e.onChange():e.onChange(Number(i));else e.onChange(t)}}),b(Nc,{name:n})]})})}var gf,mf;!function(e){e.ONE_WAY='"OneWay"',e.POINT_ADDRESS='"PointAddress"',e.BUILDING_AREA='"MapBuildingECArea"',e.BUILTUP_AREA='"MapAdminBuiltupArea"',e.ADMIN_AREA='"MapAdminArea"',e.OCEAN_AREA='"MapOceanArea"',e.OCEAN_AREA_LABEL='"MapOceanAreaLabel"',e.FACILITY_AREA='"MapFacilityArea"',e.FACILITY_AREA_LABEL='"MapFacilityAreaLabel"',e.LANDUSE_AREA='"MapLanduseArea"',e.LANDUSE_AREA_LABEL='"MapLanduseAreaLabel"',e.NATURE_FIELD='"MapNatureField"',e.NATURE_FOREST='"MapNatureForest"',e.LINK='"Link"',e.RAILROAD_LINK='"MapRailroadLink"',e.WATER_LINK='"MapWaterLink"',e.WATER_AREA='"MapWaterArea"',e.WATER_AREA_LABEL='"MapWaterAreaLabel"',e.WATER_LAKE_LABEL='"MapWaterLakeLabel"',e.POI='"POI"',e.CITY_POI='"CityPOI"',e.CONDITIONS='"Conditions"',e.ROAD_POLY='"RoadPoly"',e.PARKING_LINE='"ParkingLine"',e.LINE_MARKING_LINE='"LaneMarkingLine"',e.LINE_MARKING_POLY='"LaneMarkingPoly"',e.TRAFFIC_SIGN='"TrafficSign"',e.TRAFFIC_SIGNAL='"TrafficSignal"',e.CAMERA='"Camera"',e.PILLAR='"Pillar"'}(gf||(gf={})),function(e){e.TILE="tile",e.NATURE_TILE="nature_tile",e.MSK="msk"}(mf||(mf={}));const _f=new class{constructor(){}log({message:e,context:t,meta:n}){console.log(t,e,n)}warn({message:e,context:t,meta:n}){console.warn(t,e,n)}error({message:e,context:t,meta:n}){console.error(t,e,n)}};var yf,vf;!function(e){e.GET="GET",e.DELETE="DELETE",e.PUT="PUT",e.POST="POST"}(yf||(yf={})),function(e){e.TOP_RIGHT="top-right",e.BOTTOM_RIGHT="bottom-right",e.BOTTOM_LEFT="bottom-left",e.TOP_LEFT="top-left"}(vf||(vf={}));const bf="https://dalganmap.ru/api",xf=256,wf="https://dalganmap.ru/api-image/images",Af={[mf.TILE]:`${bf}/tiles/get_tile/{z}/{x}/{y}.mvt`,[mf.NATURE_TILE]:`${bf}/tiles/get_nature_tile/{z}/{x}/{y}.mvt`,[mf.MSK]:"http://89.108.118.23:3070/tiles/get_tile/{z}/{x}/{y}.mvt"},Ef=e=>{const t=[],n={source:e,layer:gf.ROAD_POLY},r={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'Road';\n\n return isFilter;\n }",draw:{polygons:{color:"#BABCC2"}}},i={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'Tram';\n\n return isFilter;\n }",draw:{polygons:{color:"#ADA8A8"}}},s={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'Curb';\n\n return isFilter;\n }",draw:{polygons:{color:"#D2D9E6"}}},o={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'Bridge';\n\n return isFilter;\n }",draw:{polygons:{color:"#E1DFDD"}}};return t.push(r,i,s,o),t},Sf=e=>{const t=[],n={source:e,layer:gf.LINE_MARKING_POLY},r={id:sn(),data:n,filter:"function() {\n const { poly_number } = feature;\n\n const isFilter = poly_number === '1.14.1';\n\n return isFilter;\n }",draw:{styles:{zebra_crossing:{attributes:{a_angle:"function() {\n return feature.angle;\n }"}}}}},i={id:sn(),data:n,filter:"function() {\n const { poly_number } = feature;\n\n const isFilter = poly_number === '1.18';\n\n return isFilter;\n }",draw:{polygons:{color:"white"}}};return t.push(i,r),t},Tf=e=>{const t=[],n={source:e,layer:gf.LINE_MARKING_LINE},r="white",i=.5,s={id:sn(),data:n,sublayers:{1.1:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.1';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i}}},1.5:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.5';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,dash:[4,10]}}},1.6:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.6';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,dash:[5,5]}}},"1.16.1":{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.16.1';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i}}},1.7:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.7';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,dash:[4,10]}}},"1.7-blue":{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.7blue';\n\n return isFilter;\n }",draw:{lines:{color:"blue",width:i,dash:[4,10]}}},"1.14.3":{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.14.3';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,dash:[3,8]}}},1.12:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.12';\n\n return isFilter;\n }",draw:{lines:{color:r,width:1.5}}},"1.17.1":{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.17.1';\n\n return isFilter;\n }",draw:{lines:{color:"yellow",width:i}}},1.26:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.26';\n\n return isFilter;\n }",draw:{lines:{color:"yellow",width:i}}}}},o={"1.3-left":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.3';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:-.5}}},"1.3-right":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.3';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:i}}},"1.11r-left":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.11r';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:-.5}}},"1.11r-right":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.11r';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:i,dash:[5,5]}}},"1.11l-left":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.11l';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:-.5,dash:[5,5]}}},"1.11l-right":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.11l';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:i}}},"1.25-left":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.25';\n\n return isFilter;\n }",draw:{lines:{color:r,width:1,offset:-.5,dash:[1,1],dash_background_color:[0,0,0,0]}}},"1.25-right":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.25';\n\n return isFilter;\n }",draw:{lines:{color:"rgba(0,0,0,0)",width:1,offset:.5,dash:[1,1],dash_background_color:[1,1,1]}}}};return t.push(s,...Object.values(o)),t},kf=e=>{const t=[],n={source:e,layer:gf.PARKING_LINE},r={id:sn(),data:n,draw:{lines:{color:"white",width:1}}};return t.push(r),t},Of={tsodd_id:0,dit_id:0},Rf=["future_maintanance_date","placement_date","rapair_performed_date","verification_date","warranty_expr_date"],Cf={future_maintanance_date:new Date,placement_date:new Date,rapair_performed_date:new Date,verification_date:new Date,warranty_expr_date:new Date},Pf={future_maintanance_date:(new Date).toISOString(),placement_date:(new Date).toISOString(),rapair_performed_date:(new Date).toISOString(),verification_date:(new Date).toISOString(),warranty_expr_date:(new Date).toISOString()};var Mf;!function(e){e.ACTIVE="Действующий",e.INACTIVE="Недействующий",e.TEMPORARY="Временный"}(Mf||(Mf={}));const Nf=Object.values(Mf).map(e=>({label:e,value:e})),If={traffic_signal_id:"",traffic_sign_id:"",camera_id:"",dit_id:"",dop_id:"",tsodd_id:"",pillar_id:"",dops:"",signal_model:"Модель",comment:"Комментарий",direction:"Направление",status:"Статус",traffic_sign_number:"Номер знака",traffic_sign_title:"Название знака",traffic_sign_value:"Значение",traffic_sign_type:"Тип знака",lat:"Широта",lon:"Долгота",future_maintanance_date:"Дата следующего обслуживания",placement_date:"Дата установки",rapair_performed_date:"Дата последнего ремонта",verification_date:"Дата поверки",warranty_expr_date:"Дата окончания гарантии",dop_sign_number:"Номер знака",dop_sign_text:"Текст на табличке",dop_sign_title:"Название знака",camera_model:"Модель",fixing_type:"Тип нарушения"},Df="dd.MM.yyyy";var Ff,zf;var Lf,jf,Vf=function(){if(zf)return Ff;function e(e){this._maxSize=e,this.clear()}zf=1,e.prototype.clear=function(){this._size=0,this._values=Object.create(null)},e.prototype.get=function(e){return this._values[e]},e.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var t=/[^.^\]^[]+|(?=\[\]|\.\.)/g,n=/^\d+$/,r=/^\d/,i=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,s=/^\s*(['"]?)(.*?)(\1)\s*$/,o=new e(512),a=new e(512),l=new e(512);function u(e){return o.get(e)||o.set(e,c(e).map(function(e){return e.replace(s,"$2")}))}function c(e){return e.match(t)||[""]}function h(e){return"string"==typeof e&&e&&-1!==["'",'"'].indexOf(e.charAt(0))}function d(e){return!h(e)&&(function(e){return e.match(r)&&!e.match(n)}(e)||function(e){return i.test(e)}(e))}return Ff={Cache:e,split:c,normalizePath:u,setter:function(e){var t=u(e);return a.get(e)||a.set(e,function(e,n){for(var r=0,i=t.length,s=e;r<i-1;){var o=t[r];if("__proto__"===o||"constructor"===o||"prototype"===o)return e;s=s[t[r++]]}s[t[r]]=n})},getter:function(e,t){var n=u(e);return l.get(e)||l.set(e,function(e){for(var r=0,i=n.length;r<i;){if(null==e&&t)return;e=e[n[r++]]}return e})},join:function(e){return e.reduce(function(e,t){return e+(h(t)||n.test(t)?"["+t+"]":(e?".":"")+t)},"")},forEach:function(e,t,n){!function(e,t,n){var r,i,s,o,a=e.length;for(i=0;i<a;i++)(r=e[i])&&(d(r)&&(r='"'+r+'"'),s=!(o=h(r))&&/^\d+$/.test(r),t.call(n,r,o,s,i,e))}(Array.isArray(e)?e:c(e),t,n)}},Ff}();var Uf,Bf=function(){if(jf)return Lf;jf=1;const e=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,t=t=>t.match(e)||[],n=e=>e[0].toUpperCase()+e.slice(1),r=(e,n)=>t(e).join(n).toLowerCase(),i=e=>t(e).reduce((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`,"");return Lf={words:t,upperFirst:n,camelCase:i,pascalCase:e=>n(i(e)),snakeCase:e=>r(e,"_"),kebabCase:e=>r(e,"-"),sentenceCase:e=>n(r(e," ")),titleCase:e=>t(e).map(n).join(" ")}}(),Gf={exports:{}};var $f=function(){if(Uf)return Gf.exports;function e(e,t){var n=e.length,r=new Array(n),i={},s=n,o=function(e){for(var t=new Map,n=0,r=e.length;n<r;n++){var i=e[n];t.has(i[0])||t.set(i[0],new Set),t.has(i[1])||t.set(i[1],new Set),t.get(i[0]).add(i[1])}return t}(t),a=function(e){for(var t=new Map,n=0,r=e.length;n<r;n++)t.set(e[n],n);return t}(e);for(t.forEach(function(e){if(!a.has(e[0])||!a.has(e[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});s--;)i[s]||l(e[s],s,new Set);return r;function l(e,t,s){if(s.has(e)){var u;try{u=", node was:"+JSON.stringify(e)}catch(e){u=""}throw new Error("Cyclic dependency"+u)}if(!a.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(!i[t]){i[t]=!0;var c=o.get(e)||new Set;if(t=(c=Array.from(c)).length){s.add(e);do{var h=c[--t];l(h,a.get(h),s)}while(t);s.delete(e)}r[--n]=e}}}return Uf=1,Gf.exports=function(t){return e(function(e){for(var t=new Set,n=0,r=e.length;n<r;n++){var i=e[n];t.add(i[0]),t.add(i[1])}return Array.from(t)}(t),t)},Gf.exports.array=e,Gf.exports}(),qf=fe($f);const Hf=Object.prototype.toString,Wf=Error.prototype.toString,Zf=RegExp.prototype.toString,Kf="undefined"!=typeof Symbol?Symbol.prototype.toString:()=>"",Xf=/^Symbol\((.*)\)(.*)$/;function Yf(e,t=!1){if(null==e||!0===e||!1===e)return""+e;const n=typeof e;if("number"===n)return function(e){return e!=+e?"NaN":0===e&&1/e<0?"-0":""+e}(e);if("string"===n)return t?`"${e}"`:e;if("function"===n)return"[Function "+(e.name||"anonymous")+"]";if("symbol"===n)return Kf.call(e).replace(Xf,"Symbol($1)");const r=Hf.call(e).slice(8,-1);return"Date"===r?isNaN(e.getTime())?""+e:e.toISOString(e):"Error"===r||e instanceof Error?"["+Wf.call(e)+"]":"RegExp"===r?Zf.call(e):null}function Qf(e,t){let n=Yf(e,t);return null!==n?n:JSON.stringify(e,function(e,n){let r=Yf(this[e],t);return null!==r?r:n},2)}function Jf(e){return null==e?[]:[].concat(e)}let ep,tp,np,rp=/\$\{\s*(\w+)\s*\}/g;ep=Symbol.toStringTag;class ip{constructor(e,t,n,r){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[ep]="Error",this.name="ValidationError",this.value=t,this.path=n,this.type=r,this.errors=[],this.inner=[],Jf(e).forEach(e=>{if(sp.isError(e)){this.errors.push(...e.errors);const t=e.inner.length?e.inner:[e];this.inner.push(...t)}else this.errors.push(e)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}tp=Symbol.hasInstance,np=Symbol.toStringTag;class sp extends Error{static formatError(e,t){const n=t.label||t.path||"this";return t=Object.assign({},t,{path:n,originalPath:t.path}),"string"==typeof e?e.replace(rp,(e,n)=>Qf(t[n])):"function"==typeof e?e(t):e}static isError(e){return e&&"ValidationError"===e.name}constructor(e,t,n,r,i){const s=new ip(e,t,n,r);if(i)return s;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[np]="Error",this.name=s.name,this.message=s.message,this.type=s.type,this.value=s.value,this.path=s.path,this.errors=s.errors,this.inner=s.inner,Error.captureStackTrace&&Error.captureStackTrace(this,sp)}static[tp](e){return ip[Symbol.hasInstance](e)||super[Symbol.hasInstance](e)}}let op={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:n,originalValue:r})=>{const i=null!=r&&r!==n?` (cast from the value \`${Qf(r,!0)}\`).`:".";return"mixed"!==t?`${e} must be a \`${t}\` type, but the final value was: \`${Qf(n,!0)}\``+i:`${e} must match the configured type. The validated value was: \`${Qf(n,!0)}\``+i}},ap={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},lp={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},up={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},cp={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},hp={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},dp={notType:e=>{const{path:t,value:n,spec:r}=e,i=r.types.length;if(Array.isArray(n)){if(n.length<i)return`${t} tuple value has too few items, expected a length of ${i} but got ${n.length} for value: \`${Qf(n,!0)}\``;if(n.length>i)return`${t} tuple value has too many items, expected a length of ${i} but got ${n.length} for value: \`${Qf(n,!0)}\``}return sp.formatError(op.notType,e)}};Object.assign(Object.create(null),{mixed:op,string:ap,number:lp,date:up,object:cp,array:hp,boolean:{isValue:"${path} field must be ${value}"},tuple:dp});const fp=e=>e&&e.__isYupSchema__;class pp{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:r,otherwise:i}=t,s="function"==typeof n?n:(...e)=>e.every(e=>e===n);return new pp(e,(e,t)=>{var n;let o=s(...e)?r:i;return null!=(n=null==o?void 0:o(t))?n:t})}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let n=this.refs.map(e=>e.getValue(null==t?void 0:t.value,null==t?void 0:t.parent,null==t?void 0:t.context)),r=this.fn(n,e,t);if(void 0===r||r===e)return e;if(!fp(r))throw new TypeError("conditions must return a schema object");return r.resolve(t)}}const gp="$",mp=".";class _p{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,"string"!=typeof e)throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),""===e)throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===gp,this.isValue=this.key[0]===mp,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?gp:this.isValue?mp:"";this.path=this.key.slice(n.length),this.getter=this.path&&Vf.getter(this.path,!0),this.map=t.map}getValue(e,t,n){let r=this.isContext?n:this.isValue?e:t;return this.getter&&(r=this.getter(r||{})),this.map&&(r=this.map(r)),r}cast(e,t){return this.getValue(e,null==t?void 0:t.parent,null==t?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}_p.prototype.__isYupRef=!0;const yp=e=>null==e;function vp(e){function t({value:t,path:n="",options:r,originalValue:i,schema:s},o,a){const{name:l,test:u,params:c,message:h,skipAbsent:d}=e;let{parent:f,context:p,abortEarly:g=s.spec.abortEarly,disableStackTrace:m=s.spec.disableStackTrace}=r;const _={value:t,parent:f,context:p};function y(e={}){const r=bp(Object.assign({value:t,originalValue:i,label:s.spec.label,path:e.path||n,spec:s.spec,disableStackTrace:e.disableStackTrace||m},c,e.params),_),o=new sp(sp.formatError(e.message||h,r),t,r.path,e.type||l,r.disableStackTrace);return o.params=r,o}const v=g?o:a;let b={path:n,parent:f,type:l,from:r.from,createError:y,resolve:e=>xp(e,_),options:r,originalValue:i,schema:s};const x=e=>{sp.isError(e)?v(e):e?a(null):v(y())},w=e=>{sp.isError(e)?v(e):o(e)};if(d&&yp(t))return x(!0);let A;try{var E;if(A=u.call(b,t,b),"function"==typeof(null==(E=A)?void 0:E.then)){if(r.sync)throw new Error(`Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(A).then(x,w)}}catch(e){return void w(e)}x(A)}return t.OPTIONS=e,t}function bp(e,t){if(!e)return e;for(const n of Object.keys(e))e[n]=xp(e[n],t);return e}function xp(e,t){return _p.isRef(e)?e.getValue(t.value,t.parent,t.context):e}function wp(e,t,n,r=n){let i,s,o;return t?(Vf.forEach(t,(a,l,u)=>{let c=l?a.slice(1,a.length-1):a,h="tuple"===(e=e.resolve({context:r,parent:i,value:n})).type,d=u?parseInt(c,10):0;if(e.innerType||h){if(h&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${o}" must contain an index to the tuple element, e.g. "${o}[0]"`);if(n&&d>=n.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${t}. because there is no value at that index. `);i=n,n=n&&n[d],e=h?e.spec.types[d]:e.innerType}if(!u){if(!e.fields||!e.fields[c])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${o} which is a type: "${e.type}")`);i=n,n=n&&n[c],e=e.fields[c]}s=c,o=l?"["+a+"]":"."+a}),{schema:e,parent:i,parentPath:s}):{parent:i,parentPath:t,schema:e}}class Ap extends Set{describe(){const e=[];for(const t of this.values())e.push(_p.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const n of this.values())t.push(e(n));return t}clone(){return new Ap(this.values())}merge(e,t){const n=this.clone();return e.forEach(e=>n.add(e)),t.forEach(e=>n.delete(e)),n}}function Ep(e,t=new Map){if(fp(e)||!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);let n;if(e instanceof Date)n=new Date(e.getTime()),t.set(e,n);else if(e instanceof RegExp)n=new RegExp(e),t.set(e,n);else if(Array.isArray(e)){n=new Array(e.length),t.set(e,n);for(let r=0;r<e.length;r++)n[r]=Ep(e[r],t)}else if(e instanceof Map){n=new Map,t.set(e,n);for(const[r,i]of e.entries())n.set(r,Ep(i,t))}else if(e instanceof Set){n=new Set,t.set(e,n);for(const r of e)n.add(Ep(r,t))}else{if(!(e instanceof Object))throw Error(`Unable to clone ${e}`);n={},t.set(e,n);for(const[r,i]of Object.entries(e))n[r]=Ep(i,t)}return n}function Sp(e){if(null==e||!e.length)return;const t=[];let n="",r=!1,i=!1;for(let s=0;s<e.length;s++){const o=e[s];"["!==o||i?"]"!==o||i?'"'!==o?"."!==o||r||i?n+=o:n&&(t.push(n),n=""):i=!i:(n&&(/^\d+$/.test(n)?t.push(n):t.push(n.replace(/^"|"$/g,"")),n=""),r=!1):(n&&(t.push(...n.split(".").filter(Boolean)),n=""),r=!0)}return n&&t.push(...n.split(".").filter(Boolean)),t}function Tp(e,t){var n;if((null==(n=e.inner)||!n.length)&&e.errors.length)return function(e,t){const n=t?`${t}.${e.path}`:e.path;return e.errors.map(e=>({message:e,path:Sp(n)}))}(e,t);const r=t?`${t}.${e.path}`:e.path;return e.inner.flatMap(e=>Tp(e,r))}class kp{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new Ap,this._blacklist=new Ap,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(op.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},null==e?void 0:e.spec),this.withMutation(e=>{e.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=Ep(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(0===e.length)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let n=e(this);return this._mutate=t,n}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&"mixed"!==this.type)throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,n=e.clone();const r=Object.assign({},t.spec,n.spec);return n.spec=r,n.internalTests=Object.assign({},t.internalTests,n.internalTests),n._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),n._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),n.tests=t.tests,n.exclusiveTests=t.exclusiveTests,n.withMutation(t=>{e.tests.forEach(e=>{t.test(e.OPTIONS)})}),n.transforms=[...t.transforms,...n.transforms],n}isType(e){return null==e?!(!this.spec.nullable||null!==e)||!(!this.spec.optional||void 0!==e):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let n=t.conditions;t=t.clone(),t.conditions=[],t=n.reduce((t,n)=>n.resolve(t,e),t),t=t.resolve(e)}return t}resolveOptions(e){var t,n,r,i;return Object.assign({},e,{from:e.from||[],strict:null!=(t=e.strict)?t:this.spec.strict,abortEarly:null!=(n=e.abortEarly)?n:this.spec.abortEarly,recursive:null!=(r=e.recursive)?r:this.spec.recursive,disableStackTrace:null!=(i=e.disableStackTrace)?i:this.spec.disableStackTrace})}cast(e,t={}){let n=this.resolve(Object.assign({},t,{value:e})),r="ignore-optionality"===t.assert,i=n._cast(e,t);if(!1!==t.assert&&!n.isType(i)){if(r&&yp(i))return i;let s=Qf(e),o=Qf(i);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}". \n\nattempted value: ${s} \n`+(o!==s?`result of cast: ${o}`:""))}return i}_cast(e,t){let n=void 0===e?e:this.transforms.reduce((n,r)=>r.call(this,n,e,this,t),e);return void 0===n&&(n=this.getDefault(t)),n}_validate(e,t={},n,r){let{path:i,originalValue:s=e,strict:o=this.spec.strict}=t,a=e;o||(a=this._cast(a,Object.assign({assert:!1},t)));let l=[];for(let e of Object.values(this.internalTests))e&&l.push(e);this.runTests({path:i,value:a,originalValue:s,options:t,tests:l},n,e=>{if(e.length)return r(e,a);this.runTests({path:i,value:a,originalValue:s,options:t,tests:this.tests},n,r)})}runTests(e,t,n){let r=!1,{tests:i,value:s,originalValue:o,path:a,options:l}=e,u=e=>{r||(r=!0,t(e,s))},c=e=>{r||(r=!0,n(e,s))},h=i.length,d=[];if(!h)return c([]);let f={value:s,originalValue:o,path:a,options:l,schema:this};for(let e=0;e<i.length;e++){(0,i[e])(f,u,function(e){e&&(Array.isArray(e)?d.push(...e):d.push(e)),--h<=0&&c(d)})}}asNestedTest({key:e,index:t,parent:n,parentPath:r,originalParent:i,options:s}){const o=null!=e?e:t;if(null==o)throw TypeError("Must include `key` or `index` for nested validations");const a="number"==typeof o;let l=n[o];const u=Object.assign({},s,{strict:!0,parent:n,value:l,originalValue:i[o],key:void 0,[a?"index":"key"]:o,path:a||o.includes(".")?`${r||""}[${a?o:`"${o}"`}]`:(r?`${r}.`:"")+e});return(e,t,n)=>this.resolve(u)._validate(l,u,t,n)}validate(e,t){var n;let r=this.resolve(Object.assign({},t,{value:e})),i=null!=(n=null==t?void 0:t.disableStackTrace)?n:r.spec.disableStackTrace;return new Promise((n,s)=>r._validate(e,t,(e,t)=>{sp.isError(e)&&(e.value=t),s(e)},(e,t)=>{e.length?s(new sp(e,t,void 0,void 0,i)):n(t)}))}validateSync(e,t){var n;let r,i=this.resolve(Object.assign({},t,{value:e})),s=null!=(n=null==t?void 0:t.disableStackTrace)?n:i.spec.disableStackTrace;return i._validate(e,Object.assign({},t,{sync:!0}),(e,t)=>{throw sp.isError(e)&&(e.value=t),e},(t,n)=>{if(t.length)throw new sp(t,e,void 0,void 0,s);r=n}),r}isValid(e,t){return this.validate(e,t).then(()=>!0,e=>{if(sp.isError(e))return!1;throw e})}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(e){if(sp.isError(e))return!1;throw e}}_getDefault(e){let t=this.spec.default;return null==t?t:"function"==typeof t?t.call(this,e):Ep(t)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){if(0===arguments.length)return this._getDefault();return this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const n=this.clone({nullable:e});return n.internalTests.nullable=vp({message:t,name:"nullable",test(e){return null!==e||this.schema.spec.nullable}}),n}optionality(e,t){const n=this.clone({optional:e});return n.internalTests.optionality=vp({message:t,name:"optionality",test(e){return void 0!==e||this.schema.spec.optional}}),n}optional(){return this.optionality(!0)}defined(e=op.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=op.notNull){return this.nullability(!1,e)}required(e=op.required){return this.clone().withMutation(t=>t.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(t=1===e.length?"function"==typeof e[0]?{test:e[0]}:e[0]:2===e.length?{name:e[0],test:e[1]}:{name:e[0],message:e[1],test:e[2]},void 0===t.message&&(t.message=op.default),"function"!=typeof t.test)throw new TypeError("`test` is a required parameters");let n=this.clone(),r=vp(t),i=t.exclusive||t.name&&!0===n.exclusiveTests[t.name];if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(n.exclusiveTests[t.name]=!!t.exclusive),n.tests=n.tests.filter(e=>{if(e.OPTIONS.name===t.name){if(i)return!1;if(e.OPTIONS.test===r.OPTIONS.test)return!1}return!0}),n.tests.push(r),n}when(e,t){Array.isArray(e)||"string"==typeof e||(t=e,e=".");let n=this.clone(),r=Jf(e).map(e=>new _p(e));return r.forEach(e=>{e.isSibling&&n.deps.push(e.key)}),n.conditions.push("function"==typeof t?new pp(r,t):pp.fromOptions(r,t)),n}typeError(e){let t=this.clone();return t.internalTests.typeError=vp({message:e,name:"typeError",skipAbsent:!0,test(e){return!!this.schema._typeCheck(e)||this.createError({params:{type:this.schema.type}})}}),t}oneOf(e,t=op.oneOf){let n=this.clone();return e.forEach(e=>{n._whitelist.add(e),n._blacklist.delete(e)}),n.internalTests.whiteList=vp({message:t,name:"oneOf",skipAbsent:!0,test(e){let t=this.schema._whitelist,n=t.resolveAll(this.resolve);return!!n.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:n}})}}),n}notOneOf(e,t=op.notOneOf){let n=this.clone();return e.forEach(e=>{n._blacklist.add(e),n._whitelist.delete(e)}),n.internalTests.blacklist=vp({message:t,name:"notOneOf",test(e){let t=this.schema._blacklist,n=t.resolveAll(this.resolve);return!n.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:n}})}}),n}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:n,meta:r,optional:i,nullable:s}=t.spec,o={meta:r,label:n,optional:i,nullable:s,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.filter((e,t,n)=>n.findIndex(t=>t.OPTIONS.name===e.OPTIONS.name)===t).map(t=>{const n=t.OPTIONS.params&&e?bp(Object.assign({},t.OPTIONS.params),e):t.OPTIONS.params;return{name:t.OPTIONS.name,params:n}})};return o}get"~standard"(){const e=this,t={version:1,vendor:"yup",async validate(t){try{return{value:await e.validate(t,{abortEarly:!1})}}catch(e){if(e instanceof sp)return{issues:Tp(e)};throw e}}};return t}}kp.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])kp.prototype[`${e}At`]=function(t,n,r={}){const{parent:i,parentPath:s,schema:o}=wp(this,t,n,r.context);return o[e](i&&i[s],Object.assign({},r,{parent:i,path:t}))};for(const e of["equals","is"])kp.prototype[e]=kp.prototype.oneOf;for(const e of["not","nope"])kp.prototype[e]=kp.prototype.notOneOf;const Op=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function Rp(e){var t,n;const r=Op.exec(e);return r?{year:Cp(r[1]),month:Cp(r[2],1)-1,day:Cp(r[3],1),hour:Cp(r[4]),minute:Cp(r[5]),second:Cp(r[6]),millisecond:r[7]?Cp(r[7].substring(0,3)):0,precision:null!=(t=null==(n=r[7])?void 0:n.length)?t:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:Cp(r[10]),minuteOffset:Cp(r[11])}:null}function Cp(e,t=0){return Number(e)||t}let Pp=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Mp=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Np=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Ip=new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"),Dp=e=>yp(e)||e===e.trim(),Fp={}.toString();function zp(){return new Lp}class Lp extends kp{constructor(){super({type:"string",check:e=>(e instanceof String&&(e=e.valueOf()),"string"==typeof e)}),this.withMutation(()=>{this.transform((e,t)=>{if(!this.spec.coerce||this.isType(e))return e;if(Array.isArray(e))return e;const n=null!=e&&e.toString?e.toString():e;return n===Fp?e:n})})}required(e){return super.required(e).withMutation(t=>t.test({message:e||op.required,name:"required",skipAbsent:!0,test:e=>!!e.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(e=>"required"!==e.OPTIONS.name),e))}length(e,t=ap.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(t){return t.length===this.resolve(e)}})}min(e,t=ap.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t.length>=this.resolve(e)}})}max(e,t=ap.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(t){return t.length<=this.resolve(e)}})}matches(e,t){let n,r,i=!1;return t&&("object"==typeof t?({excludeEmptyString:i=!1,message:n,name:r}=t):n=t),this.test({name:r||"matches",message:n||ap.matches,params:{regex:e},skipAbsent:!0,test:t=>""===t&&i||-1!==t.search(e)})}email(e=ap.email){return this.matches(Pp,{name:"email",message:e,excludeEmptyString:!0})}url(e=ap.url){return this.matches(Mp,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=ap.uuid){return this.matches(Np,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let t,n,r="";return e&&("object"==typeof e?({message:r="",allowOffset:t=!1,precision:n}=e):r=e),this.matches(Ip,{name:"datetime",message:r||ap.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:r||ap.datetime_offset,params:{allowOffset:t},skipAbsent:!0,test:e=>{if(!e||t)return!0;const n=Rp(e);return!!n&&!!n.z}}).test({name:"datetime_precision",message:r||ap.datetime_precision,params:{precision:n},skipAbsent:!0,test:e=>{if(!e||null==n)return!0;const t=Rp(e);return!!t&&t.precision===n}})}ensure(){return this.default("").transform(e=>null===e?"":e)}trim(e=ap.trim){return this.transform(e=>null!=e?e.trim():e).test({message:e,name:"trim",test:Dp})}lowercase(e=ap.lowercase){return this.transform(e=>yp(e)?e:e.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>yp(e)||e===e.toLowerCase()})}uppercase(e=ap.uppercase){return this.transform(e=>yp(e)?e:e.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>yp(e)||e===e.toUpperCase()})}}zp.prototype=Lp.prototype;function jp(){return new Vp}class Vp extends kp{constructor(){super({type:"number",check:e=>(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&!(e=>e!=+e)(e))}),this.withMutation(()=>{this.transform((e,t)=>{if(!this.spec.coerce)return e;let n=e;if("string"==typeof n){if(n=n.replace(/\s/g,""),""===n)return NaN;n=+n}return this.isType(n)||null===n?n:parseFloat(n)})})}min(e,t=lp.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t>=this.resolve(e)}})}max(e,t=lp.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(t){return t<=this.resolve(e)}})}lessThan(e,t=lp.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(t){return t<this.resolve(e)}})}moreThan(e,t=lp.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(t){return t>this.resolve(e)}})}positive(e=lp.positive){return this.moreThan(0,e)}negative(e=lp.negative){return this.lessThan(0,e)}integer(e=lp.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:e=>Number.isInteger(e)})}truncate(){return this.transform(e=>yp(e)?e:0|e)}round(e){var t;let n=["ceil","floor","round","trunc"];if("trunc"===(e=(null==(t=e)?void 0:t.toLowerCase())||"round"))return this.truncate();if(-1===n.indexOf(e.toLowerCase()))throw new TypeError("Only valid options for round() are: "+n.join(", "));return this.transform(t=>yp(t)?t:Math[e](t))}}jp.prototype=Vp.prototype;let Up=new Date("");function Bp(){return new Gp}class Gp extends kp{constructor(){super({type:"date",check(e){return t=e,"[object Date]"===Object.prototype.toString.call(t)&&!isNaN(e.getTime());var t}}),this.withMutation(()=>{this.transform((e,t)=>!this.spec.coerce||this.isType(e)||null===e?e:(e=function(e){const t=Rp(e);if(!t)return Date.parse?Date.parse(e):Number.NaN;if(void 0===t.z&&void 0===t.plusMinus)return new Date(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond).valueOf();let n=0;return"Z"!==t.z&&void 0!==t.plusMinus&&(n=60*t.hourOffset+t.minuteOffset,"+"===t.plusMinus&&(n=0-n)),Date.UTC(t.year,t.month,t.day,t.hour,t.minute+n,t.second,t.millisecond)}(e),isNaN(e)?Gp.INVALID_DATE:new Date(e)))})}prepareParam(e,t){let n;if(_p.isRef(e))n=e;else{let r=this.cast(e);if(!this._typeCheck(r))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);n=r}return n}min(e,t=up.min){let n=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(e){return e>=this.resolve(n)}})}max(e,t=up.max){let n=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(e){return e<=this.resolve(n)}})}}function $p(e,t){let n=1/0;return e.some((e,r)=>{var i;if(null!=(i=t.path)&&i.includes(e))return n=r,!0}),n}function qp(e){return(t,n)=>$p(e,t)-$p(e,n)}Gp.INVALID_DATE=Up,Bp.prototype=Gp.prototype,Bp.INVALID_DATE=Up;const Hp=(e,t,n)=>{if("string"!=typeof e)return e;let r=e;try{r=JSON.parse(e)}catch(e){}return n.isType(r)?r:e};function Wp(e){if("fields"in e){const t={};for(const[n,r]of Object.entries(e.fields))t[n]=Wp(r);return e.setFields(t)}if("array"===e.type){const t=e.optional();return t.innerType&&(t.innerType=Wp(t.innerType)),t}return"tuple"===e.type?e.optional().clone({types:e.spec.types.map(Wp)}):"optional"in e?e.optional():e}let Zp=e=>"[object Object]"===Object.prototype.toString.call(e);function Kp(e,t){let n=Object.keys(e.fields);return Object.keys(t).filter(e=>-1===n.indexOf(e))}const Xp=qp([]);function Yp(e){return new Qp(e)}class Qp extends kp{constructor(e){super({type:"object",check:e=>Zp(e)||"function"==typeof e}),this.fields=Object.create(null),this._sortErrors=Xp,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,t={}){var n;let r=super._cast(e,t);if(void 0===r)return this.getDefault(t);if(!this._typeCheck(r))return r;let i=this.fields,s=null!=(n=t.stripUnknown)?n:this.spec.noUnknown,o=[].concat(this._nodes,Object.keys(r).filter(e=>!this._nodes.includes(e))),a={},l=Object.assign({},t,{parent:a,__validating:t.__validating||!1}),u=!1;for(const e of o){let n=i[e],o=e in r,c=r[e];if(n){let i;l.path=(t.path?`${t.path}.`:"")+e,n=n.resolve({value:c,context:t.context,parent:a});let s=n instanceof kp?n.spec:void 0,o=null==s?void 0:s.strict;if(null!=s&&s.strip){u=u||e in r;continue}i=t.__validating&&o?c:n.cast(c,l),void 0!==i&&(a[e]=i)}else o&&!s&&(a[e]=c);o===e in a&&a[e]===c||(u=!0)}return u?a:r}_validate(e,t={},n,r){let{from:i=[],originalValue:s=e,recursive:o=this.spec.recursive}=t;t.from=[{schema:this,value:s},...i],t.__validating=!0,t.originalValue=s,super._validate(e,t,n,(e,i)=>{if(!o||!Zp(i))return void r(e,i);s=s||i;let a=[];for(let e of this._nodes){let n=this.fields[e];n&&!_p.isRef(n)&&a.push(n.asNestedTest({options:t,key:e,parent:i,parentPath:t.path,originalParent:s}))}this.runTests({tests:a,value:i,originalValue:s,options:t},n,t=>{r(t.sort(this._sortErrors).concat(e),i)})})}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),n=t.fields;for(let[e,t]of Object.entries(this.fields)){const r=n[e];n[e]=void 0===r?t:r}return t.withMutation(t=>t.setFields(n,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let t={};return this._nodes.forEach(n=>{var r;const i=this.fields[n];let s=e;null!=(r=s)&&r.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[n]})),t[n]=i&&"getDefault"in i?i.getDefault(s):void 0}),t}setFields(e,t){let n=this.clone();return n.fields=e,n._nodes=function(e,t=[]){let n=[],r=new Set,i=new Set(t.map(([e,t])=>`${e}-${t}`));function s(e,t){let s=Vf.split(e)[0];r.add(s),i.has(`${t}-${s}`)||n.push([t,s])}for(const t of Object.keys(e)){let n=e[t];r.add(t),_p.isRef(n)&&n.isSibling?s(n.path,t):fp(n)&&"deps"in n&&n.deps.forEach(e=>s(e,t))}return qf.array(Array.from(r),n).reverse()}(e,t),n._sortErrors=qp(Object.keys(e)),t&&(n._excludedEdges=t),n}shape(e,t=[]){return this.clone().withMutation(n=>{let r=n._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),r=[...n._excludedEdges,...t]),n.setFields(Object.assign(n.fields,e),r)})}partial(){const e={};for(const[t,n]of Object.entries(this.fields))e[t]="optional"in n&&n.optional instanceof Function?n.optional():n;return this.setFields(e)}deepPartial(){return Wp(this)}pick(e){const t={};for(const n of e)this.fields[n]&&(t[n]=this.fields[n]);return this.setFields(t,this._excludedEdges.filter(([t,n])=>e.includes(t)&&e.includes(n)))}omit(e){const t=[];for(const n of Object.keys(this.fields))e.includes(n)||t.push(n);return this.pick(t)}from(e,t,n){let r=Vf.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return((e,t)=>{const n=[...Vf.normalizePath(t)];if(1===n.length)return n[0]in e;let r=n.pop(),i=Vf.getter(Vf.join(n),!0)(e);return!(!i||!(r in i))})(i,e)&&(s=Object.assign({},i),n||delete s[e],s[t]=r(i)),s})}json(){return this.transform(Hp)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||cp.exact,test(e){if(null==e)return!0;const t=Kp(this.schema,e);return 0===t.length||this.createError({params:{properties:t.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,t=cp.noUnknown){"boolean"!=typeof e&&(t=e,e=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:t,test(t){if(null==t)return!0;const n=Kp(this.schema,t);return!e||0===n.length||this.createError({params:{unknown:n.join(", ")}})}});return n.spec.noUnknown=e,n}unknown(e=!0,t=cp.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform(t=>{if(!t)return t;const n={};for(const r of Object.keys(t))n[e(r)]=t[r];return n})}camelCase(){return this.transformKeys(Bf.camelCase)}snakeCase(){return this.transformKeys(Bf.snakeCase)}constantCase(){return this.transformKeys(e=>Bf.snakeCase(e).toUpperCase())}describe(e){const t=(e?this.resolve(e):this).clone(),n=super.describe(e);n.fields={};for(const[i,s]of Object.entries(t.fields)){var r;let t=e;null!=(r=t)&&r.value&&(t=Object.assign({},t,{parent:t.value,value:t.value[i]})),n.fields[i]=s.describe(t)}return n}}function Jp(e){return new eg(e)}Yp.prototype=Qp.prototype;class eg extends kp{constructor(e){super({type:"array",spec:{types:e},check:e=>Array.isArray(e)}),this.innerType=void 0,this.innerType=e}_cast(e,t){const n=super._cast(e,t);if(!this._typeCheck(n)||!this.innerType)return n;let r=!1;const i=n.map((e,i)=>{const s=this.innerType.cast(e,Object.assign({},t,{path:`${t.path||""}[${i}]`,parent:n,originalValue:e,value:e,index:i}));return s!==e&&(r=!0),s});return r?i:n}_validate(e,t={},n,r){var i;let s=this.innerType,o=null!=(i=t.recursive)?i:this.spec.recursive;null!=t.originalValue&&t.originalValue,super._validate(e,t,n,(i,a)=>{var l;if(!o||!s||!this._typeCheck(a))return void r(i,a);let u=new Array(a.length);for(let n=0;n<a.length;n++){var c;u[n]=s.asNestedTest({options:t,index:n,parent:a,parentPath:t.path,originalParent:null!=(c=t.originalValue)?c:e})}this.runTests({value:a,tests:u,originalValue:null!=(l=t.originalValue)?l:e,options:t},n,e=>r(e.concat(i),a))})}clone(e){const t=super.clone(e);return t.innerType=this.innerType,t}json(){return this.transform(Hp)}concat(e){let t=super.concat(e);return t.innerType=this.innerType,e.innerType&&(t.innerType=t.innerType?t.innerType.concat(e.innerType):e.innerType),t}of(e){let t=this.clone();if(!fp(e))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+Qf(e));return t.innerType=e,t.spec=Object.assign({},t.spec,{types:e}),t}length(e,t=hp.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(t){return t.length===this.resolve(e)}})}min(e,t){return t=t||hp.min,this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t.length>=this.resolve(e)}})}max(e,t){return t=t||hp.max,this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(t){return t.length<=this.resolve(e)}})}ensure(){return this.default(()=>[]).transform((e,t)=>this._typeCheck(e)?e:null==t?[]:[].concat(t))}compact(e){let t=e?(t,n,r)=>!e(t,n,r):e=>!!e;return this.transform(e=>null!=e?e.filter(t):e)}describe(e){const t=(e?this.resolve(e):this).clone(),n=super.describe(e);if(t.innerType){var r;let i=e;null!=(r=i)&&r.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[0]})),n.innerType=t.innerType.describe(i)}return n}}Jp.prototype=eg.prototype;const tg="Данное поле обязательно для заполнения",ng=()=>zp(),rg=(e=tg)=>ng().required(e),ig=jp(),sg=ig.required(tg),og=Jp(),ag=Bp().required(tg),lg={future_maintanance_date:ag,placement_date:ag,rapair_performed_date:ag,verification_date:ag,warranty_expr_date:ag},ug={lat:sg,lon:sg},cg=j(T)(()=>{const{spacing:e}=V();return{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:e(2)}}),hg=j(T)(()=>{const{spacing:e}=V();return{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:e(2),justifyItems:"flex-start"}});var dg={global:{links:{getIsConstruction:"function (feature) {\n const { construction } = feature;\n\n return construction;\n}\n",getIsFunctionalClass:"function (feature) {\n const { functional_class, access_id } = feature;\n\n return functional_class === 5 && access_id === 32;\n}\n",getIsLowMobility:"function (feature) {\n const { functional_class, low_mobility } = feature;\n\n return functional_class === 5 && low_mobility === 1;\n}\n"}},cameras:{camera1:{type:"perspective",vanishing_point:[0,-500]}},textures:{arrow:{url:"https://dalganmap.ru/api-image/images/arrow-20.png",sprites:{base:[0,0,20,20]}},"traffic-signal":{url:"https://dalganmap.ru/api-image/images/conditions/traffic-signal.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},pedestrian_crossing:{url:"https://dalganmap.ru/api-image/images/conditions/pedestrian_crossing.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},physical:{url:"https://dalganmap.ru/api-image/images/conditions/physical.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},gate:{url:"https://dalganmap.ru/api-image/images/conditions/gate.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_3578:{url:"https://dalganmap.ru/api-image/images/POI/3578.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5813:{url:"https://dalganmap.ru/api-image/images/POI/5813.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5541:{url:"https://dalganmap.ru/api-image/images/POI/5541.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5540:{url:"https://dalganmap.ru/api-image/images/POI/5540.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9530(Mail)":{url:"https://dalganmap.ru/api-image/images/POI/mail.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9530(Delivery)":{url:"https://dalganmap.ru/api-image/images/POI/delivery.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5400:{url:"https://dalganmap.ru/api-image/images/POI/5400.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_6000:{url:"https://dalganmap.ru/api-image/images/POI/6000.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_9565:{url:"https://dalganmap.ru/api-image/images/POI/9565.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_9583:{url:"https://dalganmap.ru/api-image/images/POI/9583.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_8060:{url:"https://dalganmap.ru/api-image/images/POI/8060.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5511:{url:"https://dalganmap.ru/api-image/images/POI/5511.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5512:{url:"https://dalganmap.ru/api-image/images/POI/5512.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5800:{url:"https://dalganmap.ru/api-image/images/POI/5800.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5999:{url:"https://dalganmap.ru/api-image/images/POI/5999.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7011:{url:"https://dalganmap.ru/api-image/images/POI/7011.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7389:{url:"https://dalganmap.ru/api-image/images/POI/7389.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7832:{url:"https://dalganmap.ru/api-image/images/POI/7832.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7929:{url:"https://dalganmap.ru/api-image/images/POI/7929.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7990:{url:"https://dalganmap.ru/api-image/images/POI/7990.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7999:{url:"https://dalganmap.ru/api-image/images/POI/7999.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_8410:{url:"https://dalganmap.ru/api-image/images/POI/8410.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_9517:{url:"https://dalganmap.ru/api-image/images/POI/9517.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_9718:{url:"https://dalganmap.ru/api-image/images/POI/9718.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(mosque)":{url:"https://dalganmap.ru/api-image/images/POI/9992_mosque.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(church)":{url:"https://dalganmap.ru/api-image/images/POI/9992_church.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(temple)":{url:"https://dalganmap.ru/api-image/images/POI/9992_temple.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(davidStar)":{url:"https://dalganmap.ru/api-image/images/POI/9992_davidStar.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(mortar)":{url:"https://dalganmap.ru/api-image/images/POI/9992_mortar.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_4100(metro)":{url:"https://dalganmap.ru/api-image/images/POI/4100_metro.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_4100(diameter)":{url:"https://dalganmap.ru/api-image/images/POI/4100_diameter.png",filtering:"mipmap",sprites:{base:[0,0,41,15]}},POI_4013:{url:"https://dalganmap.ru/api-image/images/POI/4013.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}}},layers:null,styles:{buildings:{base:"polygons",shaders:{blocks:{color:"color.rgb;\n"}}}},lights:{light1:{type:"directional",direction:[.1,.5,-1],diffuse:.7,ambient:.5}},sources:null};const fg=e=>{const t=[],n={source:e,layer:gf.BUILDING_AREA,minzoom:15},r={id:sn(),data:n,extruded:{draw:{polygons:{style:"buildings",extrude:"function() {\n return $zoom >= 17;\n }"}}},draw:{polygons:{color:"#DDB07B",height:{property:"height"}},lines:{color:"#DB933F",width:"2px",cap:"round",join:"round"}}};return t.push(r),t},pg=e=>{const t=[],n={source:e,layer:gf.BUILTUP_AREA},r={id:sn(),data:n,draw:{polygons:{color:"#CFC8C8"}}};return t.push(r),t},gg=e=>{const t=[],n={source:e,layer:gf.ADMIN_AREA},r={id:sn(),data:n,draw:{polygons:{color:"#D3D2CF"}}},i={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'R';\n\n return isFilter;\n }",draw:{lines:{color:"#696969",width:"1px",cap:"round",join:"round"}}},s={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'D' && $zoom >= 12;\n\n return isFilter;\n }",draw:{lines:{color:"#696969",dash:[4,7],width:"1px",cap:"round",join:"round"}}};return t.push(r,i,s),t},mg={size:20,extension:"png",apiName:"camera"},_g={comment:null,camera_model:null,fixing_type:[],direction:0,status:Mf.ACTIVE},yg={...Of,...Cf,..._g},vg=e=>{const t=[],n={source:e,layer:gf.CAMERA},r={},i="camera";r[i]={url:`${wf}/msk/${i}/${i}_${mg.size}.${mg.extension}`,filtering:"mipmap",sprites:{base:[0,0,mg.size,mg.size]}};const s={id:sn(),data:n,draw:{points:{collide:!1,texture:i,size:mg.size,sprite:"base",placement:"midpoint"}},textures:r,sublayers:{}};return t.push(s),t},bg=e=>e.map(e=>({value:e})),xg=e=>e.map(({value:e})=>e);function wg({name:t,items:n,label:r,sx:i,getLabel:s,getValue:o,getKey:a}){const{watch:l,resetField:u,setValue:c}=Tu(),h=l(t),d=e.useId(),f=n.find(e=>o(e)===h)??null;return b(q,{value:f,options:n,id:d,getOptionLabel:e=>s(e),getOptionKey:e=>a(e),sx:{minWidth:150,...i},size:"small",onChange:(e,n)=>{n?c(t,o(n)):u(t)},renderInput:e=>b(Fc,{...e,label:r})})}var Ag=gl(()=>{const{control:e,register:t,resetField:n}=Tu(),{fields:r,append:i,remove:s}=kc({control:e,name:"fixing_type"});return b(Hl,{children:x(T,{sx:({spacing:e})=>({display:"grid",gap:e(2)}),children:[x(T,{sx:({spacing:e})=>({display:"flex",gap:e(1),alignItems:"center",margin:"0 auto"}),children:[b(Rc,{sx:{textAlign:"center",fontWeight:700},variant:"h6",children:"Нарушения"}),b(Gl,{title:"Сброс нарушений",iconProps:{name:"reset",color:"warning"},color:"warning",onClick:()=>{n("fixing_type")}})]}),b(T,{sx:({spacing:e})=>({display:"grid",gap:e(2)}),children:r.map(({id:e},n)=>x(T,{sx:({spacing:e})=>({display:"flex",gap:e(2),alignItems:"center"}),children:[b(pf,{...t(`fixing_type.${n}.value`),label:"Название нарушения",rows:4,fullWidth:!0,multiline:!0}),b(Ul,{onDelete:()=>{s(n)}})]},e))}),b(jl,{onClick:()=>{i({value:""})},children:"Добавить нарушение"})]})})});const Eg=Yp().shape({value:rg()}).required(),Sg={camera_model:ng().nullable(),fixing_type:og.of(Eg).required(),status:rg(),comment:ng().nullable(),direction:ig.nullable()},Tg={camera_id:rg(),dit_id:sg,tsodd_id:sg,pillar_id:ng().nullable()},kg=Yp().shape({dit_id:Tg.dit_id,tsodd_id:Tg.tsodd_id,...Sg,...lg}),Og=(e,t,n)=>{if(e&&"reportValidity"in e){const r=ou(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Rg=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?Og(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>Og(t,n,e))}},Cg=(e,t)=>{t.shouldUseNativeValidation&&Rg(e,t);const n={};for(const r in e){const i=ou(t.fields,r),s=Object.assign(e[r]||{},{ref:i&&i.ref});if(Pg(t.names||Object.keys(e),r)){const e=Object.assign({},ou(n,r));uu(e,"root",s),uu(n,r,e)}else uu(n,r,s)}return n},Pg=(e,t)=>{const n=Mg(t);return e.some(e=>Mg(e).match(`^${n}\\.\\d+`))};function Mg(e){return e.replace(/\]|\[/g,"")}function Ng(e,t,n){return void 0===n&&(n={}),function(r,i,s){try{return Promise.resolve(function(o,a){try{var l=(null!=t&&t.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e["sync"===n.mode?"validateSync":"validate"](r,Object.assign({abortEarly:!1},t,{context:i}))).then(function(e){return s.shouldUseNativeValidation&&Rg({},s),{values:n.raw?Object.assign({},r):e,errors:{}}}))}catch(e){return a(e)}return l&&l.then?l.then(void 0,a):l}(0,function(e){if(!e.inner)throw e;return{values:{},errors:Cg((t=e,n=!s.shouldUseNativeValidation&&"all"===s.criteriaMode,(t.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var r=e[t.path].types,i=r&&r[t.type];e[t.path]=Fu(t.path,n,e,t.type,i?[].concat(i,t.message):t.message)}return e},{})),s)};var t,n}))}catch(e){return Promise.reject(e)}}}var Ig=gl(({onSubmit:t})=>{const n=e.useId(),r=Oc({resolver:Ng(kg),defaultValues:{...yg,fixing_type:yg.fixing_type.map(e=>({value:e}))}}),{register:i,formState:{errors:s}}=r;return e.useEffect(()=>{Object.keys(s).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignCreateForm",meta:s})},[s]),x(Ic,{form:r,onSubmit:e=>{const{fixing_type:n}=e;t({...e,fixing_type:xg(n)})},children:[b(wg,{...i("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(Ag,{}),b(pf,{...i("camera_model"),label:If.camera_model}),b(pf,{...i("comment"),label:If.comment}),b(pf,{...i("direction"),label:If.direction,type:"number"}),b(cg,{children:Rf.map(e=>b(zc,{...i(e),label:If[e],format:Df},`${n}-${e}`))}),b(jl,{type:"submit",children:"Сохранить"})]})});const Dg=Yp().shape({...lg,...ug,...Tg,...Sg});var Fg=gl(({camera:t,getButtons:n,onSubmit:r,onDelete:i})=>{const s=e.useId(),o=e.useMemo(()=>{const{fixing_type:e}=t;return{...t,...cy(t),fixing_type:bg(e)}},[t]),a=Oc({resolver:Ng(Dg),defaultValues:o}),{reset:l,register:u,formState:{errors:c}}=a;return e.useEffect(()=>{Object.keys(c).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignUpdateForm",meta:c})},[c]),e.useEffect(()=>{l(o)},[o]),x(Ic,{form:a,onSubmit:e=>{const{fixing_type:t}=e;r({...e,fixing_type:xg(t)})},children:[b(wg,{...u("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(Ag,{}),b(pf,{...u("camera_model"),label:If.signal_model}),b(pf,{...u("comment"),label:If.comment}),b(pf,{...u("direction"),label:If.direction,type:"number"}),b(cg,{children:Rf.map(e=>b(zc,{...u(e),label:If[e],format:Df},`${s}-${e}`))}),x(hg,{children:[b(jl,{type:"submit",fullWidth:!0,children:"Сохранить"}),x(hg,{children:[b(Ul,{notification:{title:"Удалить камеру",description:"Вы действительно хотите удалить данную камеру?"},onDelete:()=>{i(t)}}),n?.(t)]})]})]})});const zg=e=>{const t=[],n={source:e,layer:gf.CITY_POI},r={id:sn(),data:n,filter:"function() {\n const { capital_order8, capital_order2, capital_order1, poi_name, priority } = feature;\n\n if ($zoom >= 9 && $zoom < 13) {\n return priority < 8;\n }\n\n if ($zoom <= 11) {\n return capital_order8 === 'Y';\n }\n\n if ($zoom >= 15) {\n return capital_order2 !== 'Y';\n }\n\n return true;\n }\n ",draw:{text:{text_source:"poi_name",priority:"function () {\n const { priority } = feature;\n\n if ($zoom <= 15) {\n return priority;\n }\n\n return 1;\n }\n ",font:{fill:"black",size:"function() {\n const { capital_order8 } = feature;\n\n if (capital_order8 === 'Y') {\n return '16px';\n }\n\n return '12px';\n }",weight:"function() {\n const { capital_order2 } = feature;\n\n if (capital_order2 === 'Y') {\n return 'bold';\n }\n\n return 'normal';\n }",stroke:{color:"white",width:"2px"}}}}};return t.push(r),t};var Lg;!function(e){e.traffic_signal="traffic_signal",e.pedestrian_crossing="pedestrian_crossing",e.physical="physical",e.gate="gate"}(Lg||(Lg={}));const jg=e=>{const t=[],n={},r={source:e,layer:gf.CONDITIONS},i={id:sn(),data:r};return Object.values(Lg).forEach(e=>{n[`_${e}`]={filter:`function() {\n const { type } = feature;\n\n const isShow = type === '${e}';\n\n return isShow;\n }`,draw:{points:{texture:e,sprite:"base",placement:"midpoint"}}}}),i.sublayers=n,t.push(i),t},Vg=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.FACILITY_AREA},draw:{polygons:{color:"function() {\n const { feature_type } = feature;\n\n switch (feature_type) {\n case '2000408': {\n return '#DBBAC4';\n }\n\n case '1900403': {\n return '#B6C3C7';\n }\n\n case '1907403': {\n return '#A3B9C0';\n }\n\n case '2000123': {\n return '#E4BA7D';\n }\n\n case '2000124': {\n return '#BFE6E3';\n }\n\n case '2000200': {\n return '#A0A9A8';\n }\n\n case '2000403': {\n return '#AF7136';\n }\n\n case '2000420': {\n return '#89AC76';\n }\n\n case '2000457': {\n return '#9494C0';\n }\n\n default: {\n return '#E1D4D4';\n }\n }\n }",order:"function() {\n const { feature_type } = feature;\n\n switch (feature_type) {\n case '1907403': {\n return 301;\n }\n\n default: {\n return 300;\n }\n }\n }"},lines:{color:"#857F7F",width:"2px",cap:"round",join:"round"}}},r={id:sn(),data:{source:e,layer:gf.FACILITY_AREA_LABEL},draw:{text:{text_source:"name",font:{fill:"function() {\n const { feature_type } = feature;\n\n switch(feature_type) {\n case '1900403':\n case '1907403': {\n return '#256D7B';\n }\n\n case '2000420':\n case '2000460':\n case '2000123': {\n return '#00541F';\n }\n\n case '2000408': {\n return '#5E2129';\n }\n\n case '2000124': {\n return '#3E5F8A';\n }\n\n case '2000200': {\n return '#464451';\n }\n\n case '2000403': {\n return '#B03F35';\n }\n\n case '2000457': {\n return '#6A5ACD';\n }\n\n case '1700215':\n case '900159':\n case '900158': {\n return '#474A51';\n }\n\n default: {\n return black;\n }\n }\n }",size:"12px",stroke:{color:"white",width:"3px"}}}}};return t.push(n,r),t},Ug=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.LANDUSE_AREA},draw:{polygons:{color:"function() {\n const { feature_type } = feature;\n\n switch (feature_type) {\n case '509998': {\n return '#ECD175';\n }\n\n case '600102':\n case '900140': {\n return '#3E9A8C';\n }\n\n case '900202':\n case '900130':\n case '900150':\n case '900103': {\n return '#96BE7D';\n }\n\n case '9997010': {\n return null;\n }\n }\n }",order:"function() {\n const { feature_type } = feature;\n\n switch(feature_type) {\n case '900150':\n case '900130':\n case '509998': {\n return 300;\n }\n\n default: {\n return 299;\n }\n }\n }"}}},r={id:sn(),data:{source:e,layer:gf.LANDUSE_AREA_LABEL},filter:"function() {\n return $zoom >= 15;\n }",draw:{text:{text_source:"name",font:{size:"13px",fill:"function() {\n const { feature_type } = feature;\n\n switch(feature_type) {\n case '509998': {\n return '#CD7F32';\n }\n\n default: {\n return '#00541F';\n }\n }\n }",stroke:{color:"white",width:"3px"}}}}};return t.push(n,r),t},Bg=[-1,-.5,-.3,0,.3,.5,.7,1,1.5,2],Gg=[[5],[4,3],[2,1]],$g="function() {\n const { functional_class, tunnel, tollway } = feature;\n\n const alpha = tunnel ? 0.89 : 1;\n\n const getRGB = (hex, alpha) => {\n const r = +(parseInt(hex.slice(1, 3), 16) / 255).toFixed(2);\n const g = +(parseInt(hex.slice(3, 5), 16) / 255).toFixed(2);\n const b = +(parseInt(hex.slice(5, 7), 16) / 255).toFixed(2);\n\n return [r, g, b, alpha];\n }\n\n if (tollway) {\n return '#D72740';\n }\n\n switch (functional_class) {\n case 1:\n case 2: {\n const color = getRGB('#D1747F', alpha);\n\n return color;\n }\n\n case 3:\n case 4: {\n const color = getRGB('#B1A7AA', alpha);\n\n return color;\n }\n\n case 5: {\n const color = getRGB('#D5CEC3', alpha);\n\n return color;\n }\n }\n}",qg="function() {\n const { functional_class, road_number } = feature;\n\n const getScale = () => {\n if ($zoom <= 15 && $zoom >= 14) { return 7; }\n\n if ($zoom <= 13 && $zoom >= 12) { return 9; }\n\n if ($zoom <= 5) { return 400; }\n\n if ($zoom <= 7) { return 200; }\n\n if ($zoom < 12) { return 50; }\n\n return 1;\n }\n\n const scale = getScale();\n\n switch(functional_class) {\n case 1:\n case 2: {\n return 8 * scale;\n }\n\n case 3:\n case 4: {\n return 7 * scale;\n }\n\n case 5: {\n if (Boolean(road_number)) {\n return 7 * scale;\n }\n\n return 6;\n }\n }\n}",Hg=e=>{const t=[],n={source:e,layer:gf.LINK},r={id:sn(),data:n,draw:{text:{text_source:"road_number",font:{fill:"#181bff",size:"16px",weight:"bold",underline:!0,background:{color:"black"}}}}};t.push(r);const i={text_source:"street_name",font:{fill:"black",size:"14px",stroke:{color:"white",width:"3px"}}},s=()=>({text:i,lines:{color:$g,width:qg,cap:"round",join:"round"}}),o=()=>({lines:{color:$g,width:qg,outline:{color:"function() {\n const { functional_class, access_id, tollway } = feature;\n\n if (tollway) {\n return '#B9263B';\n }\n\n switch(functional_class) {\n case 5: {\n return '#989898';\n }\n\n case 3:\n case 4: {\n return '#8F6E78';\n }\n\n case 1:\n case 2: {\n return '#9A414B';\n }\n }\n}",width:"function() {\n const { functional_class, access_id } = feature;\n\n switch(functional_class) {\n case 5: {\n switch (access_id) {\n case 32: {\n return 0;\n }\n\n default: {\n return 1;\n }\n }\n }\n\n default: {\n return 1;\n }\n }\n}"}}});return Bg.forEach(e=>{const r=[],i=[];if(0===e)Gg.forEach(t=>{const a=[],l=[];t.forEach(t=>{const r={id:sn(),data:n,filter:`function() {\n const { functional_class, z_lvl = 0.0 } = feature;\n\n const isFilter = +z_lvl === ${e} && +functional_class === ${t};\n\n return isFilter;\n }`,draw:s(),sublayers:{construction:{filter:"function() {\n return global.links.getIsConstruction(feature);\n }",draw:{lines:{width:3,color:"#9AA096",dash:[2,1]}}},functionalClassAccessId32:{filter:"function() {\n return global.links.getIsFunctionalClass(feature);\n }",draw:{lines:{width:2,color:"#9AA096",dash:[2,1]}}},lowMobility:{filter:"function() {\n return global.links.getIsLowMobility(feature);\n }",draw:{lines:{width:4}}}}},i={id:sn(),data:n,filter:`function() {\n const { functional_class, z_lvl = 0.0 } = feature;\n\n const isFilter = +z_lvl === ${e} && +functional_class === ${t} && !global.links.getIsConstruction(feature) && !global.links.getIsFunctionalClass(feature);\n\n\n return isFilter;\n }`,draw:o(),sublayers:{lowMobility:{filter:"function() {\n return global.links.getIsLowMobility(feature);\n }",draw:{lines:{width:4}}}}};a.push(r),l.push(i)}),r.push(...a),i.push(...l)});else{const t=(e=>`function() {\n const { z_lvl = 0.0 } = feature;\n\n const isFilter = +z_lvl === ${e};\n\n return isFilter;\n }`)(e),a={id:sn(),data:n,filter:t,draw:s()},l={id:sn(),data:n,filter:t,draw:o()};r.push(a),i.push(l)}t.push(...i,...r)}),t},Wg=()=>{const e=[],t={source:mf.NATURE_TILE,layer:gf.NATURE_FIELD},n={id:sn(),data:t,draw:{polygons:{color:"#EBEEC7"}}};return e.push(n),e},Zg=()=>{const e=[],t={source:mf.NATURE_TILE,layer:gf.NATURE_FOREST},n={id:sn(),data:t,draw:{polygons:{color:"function() {\n const { feature_type } = feature;\n\n switch (feature_type) {\n case '900202': {\n return '#96BE7D';\n }\n\n default : {\n return null;\n }\n }\n }"}}};return e.push(n),e},Kg=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.OCEAN_AREA},draw:{polygons:{color:"#7DBEE4"}}},r={id:sn(),data:{source:e,layer:gf.OCEAN_AREA_LABEL},draw:{text:{text_source:"name",font:{fill:"#0A80C4",size:"18px",stroke:{color:"white",width:"3px"}}}}};return t.push(n,r),t},Xg=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.ONE_WAY},draw:{points:{texture:"arrow",sprite:"base",angle:"function() {\n const { bearing } = feature;\n \n return bearing;\n }\n "}}};return t.push(n),t},Yg={size:20,extension:"png"},Qg=e=>{const t=[],n={source:e,layer:gf.PILLAR},r={},i="pillar",s=`${wf}/msk/${i}/${i}_${Yg.size}.${Yg.extension}`;r[i]={url:s,filtering:"mipmap",sprites:{base:[0,0,Yg.size,Yg.size]}};const o={id:sn(),data:n,draw:{points:{collide:!1,texture:i,size:Yg.size,sprite:"base",placement:"midpoint"}},textures:r,sublayers:{}};return t.push(o),t},Jg='function() {\n const { poi_name, cat_id } = feature;\n\n switch (+cat_id) {\n case 4100: {\n const text = poi_name.replaceAll(/(Метро-|Станция-|МЦД-)/g, "");\n\n return text;\n }\n\n default: {\n return poi_name;\n }\n }\n}',em=[3578,4013,4100,5400,5511,5512,5540,5541,5800,5813,5999,6e3,7011,7389,7832,7929,7990,8060,8410,9517,9530,9565,9583,9718,9992],tm=e=>{const t={};switch(e){case 4100:t[`_${e}-metro`]={filter:`function() {\n const { poi_name, cat_id } = feature;\n\n const isMetro = poi_name.startsWith('Метро-');\n const isStation = poi_name.startsWith('Станция-');\n\n const isCatId = +cat_id === ${e};\n\n const isFilter = isCatId && (isMetro || isStation);\n\n return isFilter;\n }`,draw:{points:nm({texture:`POI_${e}(metro)`})}},t[`_${e}-diameter`]={filter:`function() {\n const { cat_id, poi_name } = feature;\n\n const isDiameter = poi_name.startsWith('МЦД-');\n\n const isCatId = +cat_id === ${e};\n\n const isFilter = isCatId && isDiameter;\n\n return isFilter;\n }`,draw:{points:nm({texture:`POI_${e}(diameter)`,size:[41,15]})}};break;case 9530:t[`_${e}-mail`]={filter:`function() {\n const { cat_id, poi_name = '' } = feature;\n\n const isCatId = +cat_id === ${e};\n\n const isMail = poi_name.startsWith('Почта');\n\n const isFilter = isCatId && isMail;\n\n return isFilter;\n }`,draw:{points:nm({texture:`POI_${e}(Mail)`})}},t[`_${e}-delivery`]={filter:`function() {\n const { cat_id, poi_name = '' } = feature;\n\n const isCatId = +cat_id === ${e};\n \n const isMail = poi_name.startsWith('Почта');\n\n const isFilter = isCatId && !isMail;\n\n return isFilter;\n }`,draw:{points:nm({texture:`POI_${e}(Delivery)`})}};break;case 9992:{const n={mosque:1,church:2,temple:3,davidStar:4,mortar:6};Object.entries(n).forEach(([n,r])=>{t[`_${e}-${n}`]={filter:`function() {\n const { cat_id, subcat_id } = feature;\n\n const isCatId = +cat_id === ${e};\n const isSubcatId = +subcat_id === ${r};\n\n const isFilter = isCatId && isSubcatId;\n\n return isFilter;\n }`,draw:{points:nm({texture:`POI_${e}(${n})`})}}});break}default:t[`_${e}`]={filter:`function() {\n const { cat_id } = feature;\n\n const isFilter = +cat_id === ${e};\n\n return isFilter;\n }`,draw:{points:nm({texture:`POI_${e}`})}}}return t},nm=({texture:e,size:t=20})=>({texture:e,size:t,sprite:"base",placement:"midpoint"}),rm=em.reduce((e,t)=>({...e,...tm(t)}),{}),im=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.POI},draw:{points:{text:{text_source:Jg,font:{fill:"#464544",size:"12px"}}}},sublayers:rm};return t.push(n),t},sm=e=>{const t=[],n={source:e,layer:gf.POINT_ADDRESS,minzoom:15},r={id:sn(),data:n,draw:{text:{text_source:"address",font:{fill:"black",size:"12px"}}}};return t.push(r),t},om=e=>{const t=[],n={source:e,layer:gf.RAILROAD_LINK},r={id:sn(),data:n,draw:{lines:{color:"#A3A8A",width:5,dash:[1,2],dash_background_color:[0,0,0],join:"round"}}};return t.push(r),t},am={1.1:{title:"Железнодорожный переезд со шлагбаумом",height:20,type:"Предупреждающие знаки"},1.2:{title:"Железнодорожный переезд без шлагбаума",height:20,type:"Предупреждающие знаки"},"1.3.1":{title:"Однопутная железная дорога",height:20,type:"Предупреждающие знаки"},"1.3.2":{title:"Многопутная железная дорога",height:20,type:"Предупреждающие знаки"},"1.4.1":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.2":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.3":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.4":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.5":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.6":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},1.5:{title:"Пересечение с трамвайной линией",height:20,type:"Предупреждающие знаки"},1.6:{title:"Пересечение равнозначных дорог",height:20,type:"Предупреждающие знаки"},1.7:{title:"Пересечение с круговым движением",height:20,type:"Предупреждающие знаки"},1.8:{title:"Светофорное регулирование",height:20,type:"Предупреждающие знаки"},1.9:{title:"Разводной мост",height:20,type:"Предупреждающие знаки"},"1.10":{title:"Выезд на набережную",height:20,type:"Предупреждающие знаки"},"1.11.1":{title:"Опасный поворот (правый)",height:20,type:"Предупреждающие знаки"},"1.11.2":{title:"Опасный поворот (левый)",height:20,type:"Предупреждающие знаки"},"1.12.1":{title:"Опасные повороты",height:20,type:"Предупреждающие знаки"},"1.12.2":{title:"Опасные повороты",height:20,type:"Предупреждающие знаки"},1.13:{title:"Крутой спуск",height:20,type:"Предупреждающие знаки"},1.14:{title:"Крутой подъём",height:20,type:"Предупреждающие знаки"},1.15:{title:"Скользкая дорога",height:20,type:"Предупреждающие знаки"},1.16:{title:"Неровная дорога",height:20,type:"Предупреждающие знаки"},1.17:{title:"Искусственная неровность",height:20,type:"Предупреждающие знаки"},1.18:{title:"Выброс гравия",height:20,type:"Предупреждающие знаки"},1.19:{title:"Опасная обочина",height:20,type:"Предупреждающие знаки"},"1.20.1":{title:"Сужение дороги",height:20,type:"Предупреждающие знаки"},"1.20.2":{title:"Сужение дороги",height:20,type:"Предупреждающие знаки"},"1.20.3":{title:"Сужение дороги",height:20,type:"Предупреждающие знаки"},1.21:{title:"Двустороннее движение",height:20,type:"Предупреждающие знаки"},1.22:{title:"Пешеходный переход",height:20,type:"Предупреждающие знаки"},1.23:{title:"Дети",height:20,type:"Предупреждающие знаки"},1.24:{title:"Пересечение с велосипедной дорожкой или велопешеходной дорожкой",height:20,type:"Предупреждающие знаки"},1.25:{title:"Дорожные работы",height:20,type:"Предупреждающие знаки"},1.26:{title:"Перегон скота",height:20,type:"Предупреждающие знаки"},1.27:{title:"Дикие животные",height:20,type:"Предупреждающие знаки"},1.28:{title:"Падение камней",height:20,type:"Предупреждающие знаки"},1.29:{title:"Боковой ветер",height:20,type:"Предупреждающие знаки"},"1.30":{title:"Низколетящие самолёты",height:20,type:"Предупреждающие знаки"},1.31:{title:"Тоннель",height:20,type:"Предупреждающие знаки"},1.32:{title:"Затор",height:20,type:"Предупреждающие знаки"},1.33:{title:"Прочие опасности",height:20,type:"Предупреждающие знаки"},"1.34.1 A":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.1 B":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.1 C":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.2 A":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.2 B":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.2 C":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.3 A":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.3 B":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},1.35:{title:"Участок перекрёстка",height:20,type:"Предупреждающие знаки"},2.1:{title:"Главная дорога",height:20,type:"Знаки приоритета"},2.2:{title:"Конец главной дороги",height:20,type:"Знаки приоритета"},"2.3.1":{title:"Пересечение со второстепенной дорогой",height:20,type:"Знаки приоритета"},"2.3.2":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.3":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.4":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.5":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.6":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.7":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},2.4:{title:"Уступите дорогу",height:20,type:"Знаки приоритета"},2.5:{title:"Движение без остановки запрещено",height:20,type:"Знаки приоритета"},2.6:{title:"Преимущество встречного движения",height:20,type:"Знаки приоритета"},2.7:{title:"Преимущество перед встречным движением",height:20,type:"Знаки приоритета"},3.1:{title:"Въезд запрещён",height:20,type:"Запрещающие знаки"},3.2:{title:"Движение запрещено",height:20,type:"Запрещающие знаки"},3.3:{title:"Движение механических транспортных средств запрещено",height:20,type:"Запрещающие знаки"},3.4:{title:"Движение грузовых автомобилей запрещено",height:20,type:"Запрещающие знаки"},3.5:{title:"Движение мотоциклов запрещено",height:20,type:"Запрещающие знаки"},3.6:{title:"Движение тракторов запрещено",height:20,type:"Запрещающие знаки"},3.7:{title:"Движение с прицепом запрещено",height:20,type:"Запрещающие знаки"},3.8:{title:"Движение гужевых повозок запрещено",height:20,type:"Запрещающие знаки"},3.9:{title:"Движение на велосипедах запрещено",height:20,type:"Запрещающие знаки"},"3.10":{title:"Движение пешеходов запрещено",height:20,type:"Запрещающие знаки"},3.11:{title:"Ограничение массы",height:20,type:"Запрещающие знаки"},3.12:{title:"Ограничение массы, приходящейся на ось транспортного средства",height:20,type:"Запрещающие знаки"},3.13:{title:"Ограничение высоты",height:20,type:"Запрещающие знаки"},3.14:{title:"Ограничение ширины",height:20,type:"Запрещающие знаки"},3.15:{title:"Ограничение длины",height:20,type:"Запрещающие знаки"},3.16:{title:"Ограничение минимальной дистанции",height:20,type:"Запрещающие знаки"},"3.17.1":{title:"Таможня",height:20,type:"Запрещающие знаки"},"3.17.2":{title:"Опасность",height:20,type:"Запрещающие знаки"},"3.17.3":{title:"Контроль",height:20,type:"Запрещающие знаки"},"3.18.1":{title:"Поворот направо запрещён",height:20,type:"Запрещающие знаки"},"3.18.2":{title:"Поворот налево запрещён",height:20,type:"Запрещающие знаки"},3.19:{title:"Разворот запрещён",height:20,type:"Запрещающие знаки"},"3.20":{title:"Обгон запрещён",height:20,type:"Запрещающие знаки"},3.21:{title:"Конец зоны запрещения обгона",height:20,type:"Запрещающие знаки"},3.22:{title:"Обгон грузовым автомобилям запрещён",height:20,type:"Запрещающие знаки"},3.23:{title:"Конец зоны запрещения обгона грузовым автомобилям",height:20,type:"Запрещающие знаки"},"3.24-50":{title:"Ограничение максимальной скорости",height:20,type:"Запрещающие знаки"},"3.25-50":{title:"Конец зоны ограничения максимальной скорости",height:20,type:"Запрещающие знаки"},3.26:{title:"Подача звукового сигнала запрещена",height:20,type:"Запрещающие знаки"},3.27:{title:"Остановка запрещена",height:20,type:"Запрещающие знаки"},3.28:{title:"Стоянка запрещена",height:20,type:"Запрещающие знаки"},3.29:{title:"Стоянка запрещена по нечётным числам месяца.",height:20,type:"Запрещающие знаки"},"3.30":{title:"Стоянка запрещена по чётным числам месяца",height:20,type:"Запрещающие знаки"},3.31:{title:"Конец зоны всех ограничений",height:20,type:"Запрещающие знаки"},3.32:{title:"Движение транспортных средств с опасными грузами запрещено",height:20,type:"Запрещающие знаки"},3.33:{title:"Движение транспортных средств с взрывчатыми и легковоспламеняющимися грузами запрещено",height:20,type:"Запрещающие знаки"},3.34:{title:"Движение автобусов запрещено",height:20,type:"Запрещающие знаки"},3.35:{title:"Движение на средствах индивидуальной мобильности запрещено",height:20,type:"Запрещающие знаки"},"4.1.1":{title:"Движение прямо",height:20,type:"Предписывающие знаки"},"4.1.2":{title:"Движение направо",height:20,type:"Предписывающие знаки"},"4.1.3":{title:"Движение налево",height:20,type:"Предписывающие знаки"},"4.1.4":{title:"Движение прямо или направо",height:20,type:"Предписывающие знаки"},"4.1.5":{title:"Движение прямо или налево",height:20,type:"Предписывающие знаки"},"4.1.6":{title:"Движение направо или налево",height:20,type:"Предписывающие знаки"},"4.2.1":{title:"Объезд препятствия справа",height:20,type:"Предписывающие знаки"},"4.2.2":{title:"Объезд препятствия слева",height:20,type:"Предписывающие знаки"},"4.2.3":{title:"Объезд препятствия справа или слева",height:20,type:"Предписывающие знаки"},4.3:{title:"Круговое движение",height:20,type:"Предписывающие знаки"},"4.4.1":{title:"Велосипедная дорожка",height:20,type:"Предписывающие знаки"},"4.4.2":{title:"Конец велосипедной дорожки",height:20,type:"Предписывающие знаки"},"4.5.1":{title:"Пешеходная дорожка",height:20,type:"Предписывающие знаки"},"4.5.2":{title:"Пешеходная и велосипедная дорожка с совмещённым движением",height:20,type:"Предписывающие знаки"},"4.5.3":{title:"Конец пешеходной и велосипедной дорожки с совмещённым движением",height:20,type:"Предписывающие знаки"},"4.5.4":{title:"Пешеходная и велосипедная дорожка с разделением движения",height:20,type:"Предписывающие знаки"},"4.5.5":{title:"Пешеходная и велосипедная дорожка с разделением движения",height:20,type:"Предписывающие знаки"},"4.5.6":{title:"Конец пешеходной и велосипедной дорожки с разделением движения",height:20,type:"Предписывающие знаки"},"4.5.7":{title:"Конец пешеходной и велосипедной дорожки с разделением движения",height:20,type:"Предписывающие знаки"},"4.6-50":{title:"Ограничение минимальной скорости",height:20,type:"Предписывающие знаки"},"4.7-50":{title:"Конец зоны ограничения минимальной скорости",height:20,type:"Предписывающие знаки"},"4.8.1":{title:"Направление движения транспортных средств с опасными грузами",height:30,type:"Предписывающие знаки"},"4.8.2":{title:"Направление движения транспортных средств с опасными грузами",height:30,type:"Предписывающие знаки"},"4.8.3":{title:"Направление движения транспортных средств с опасными грузами",height:30,type:"Предписывающие знаки"},5.1:{title:"Автомагистраль",height:30,type:"Знаки особых предписаний"},5.2:{title:"Конец автомагистрали",height:30,type:"Знаки особых предписаний"},5.3:{title:"Дорога для автомобилей",height:30,type:"Знаки особых предписаний"},5.4:{title:"Конец дороги для автомобилей",height:30,type:"Знаки особых предписаний"},5.5:{title:"Дорога с односторонним движением",height:20,type:"Знаки особых предписаний"},5.6:{title:"Конец дороги с односторонним движением",height:20,type:"Знаки особых предписаний"},"5.7.1":{title:"Выезд на дорогу с односторонним движением",height:20,type:"Знаки особых предписаний"},"5.7.2":{title:"Выезд на дорогу с односторонним движением",height:20,type:"Знаки особых предписаний"},5.8:{title:"Реверсивное движение",height:20,type:"Знаки особых предписаний"},5.9:{title:"Конец реверсивного движения",height:20,type:"Знаки особых предписаний"},"5.10":{title:"Выезд на дорогу с реверсивным движением",height:20,type:"Знаки особых предписаний"},"5.11.1":{title:"Дорога с полосой для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.11.2":{title:"Дорога с полосой для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.12.1":{title:"Конец дороги с полосой для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.12.2":{title:"Конец дороги с полосой для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.13.1":{title:"Выезд на дорогу с полосой для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.13.2":{title:"Выезд на дорогу с полосой для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.13.3":{title:"Выезд на дорогу с полосой для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.13.4":{title:"Выезд на дорогу с полосой для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.14.1":{title:"Полоса для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.14.2":{title:"Полоса для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.14.3":{title:"Конец полосы для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.14.4":{title:"Конец полосы для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.15.1":{title:"Направления движения по полосам",height:20,type:"Знаки особых предписаний"},"5.15.2 A":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 B":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 C":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 D":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 E":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 F":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 G":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 H":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 I":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 K":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.3 A":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.3 B":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.3 C":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.4 A":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.4 B":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.5":{title:"Конец полосы",height:20,type:"Знаки особых предписаний"},"5.15.6":{title:"Конец полосы",height:20,type:"Знаки особых предписаний"},"5.15.7 A":{title:"Направление движения по полосам",height:20,type:"Знаки особых предписаний"},"5.15.7 B":{title:"Направление движения по полосам",height:20,type:"Знаки особых предписаний"},"5.15.7 C":{title:"Направление движения по полосам",height:20,type:"Знаки особых предписаний"},"5.15.8":{title:"Число полос",height:20,type:"Знаки особых предписаний"},5.16:{title:"Место остановки автобуса и (или) троллейбуса",height:30,type:"Знаки особых предписаний"},5.17:{title:"Место остановки трамвая",height:30,type:"Знаки особых предписаний"},5.18:{title:"Место стоянки легковых такси",height:30,type:"Знаки особых предписаний"},"5.19.1":{title:"Пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.19.2":{title:"Пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.19.3":{title:"Диагональный пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.19.4 A":{title:"Диагональный пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.19.4 B":{title:"Диагональный пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.20":{title:"Искусственная неровность",height:20,type:"Знаки особых предписаний"},5.21:{title:"Жилая зона",height:30,type:"Знаки особых предписаний"},5.22:{title:"Конец жилой зоны",height:30,type:"Знаки особых предписаний"},"5.23.1":{title:"Начало населённого пункта",height:20,type:"Знаки особых предписаний"},"5.23.2":{title:"Начало населённого пункта",height:20,type:"Знаки особых предписаний"},"5.24.1":{title:"Конец населённого пункта",height:20,type:"Знаки особых предписаний"},"5.24.2":{title:"Конец населённого пункта",height:20,type:"Знаки особых предписаний"},5.25:{title:"Начало населённого пункта",height:20,type:"Знаки особых предписаний"},5.26:{title:"Конец населённого пункта",height:20,type:"Знаки особых предписаний"},5.27:{title:"Зона с ограничением стоянки",height:30,type:"Знаки особых предписаний"},5.28:{title:"Конец зоны с ограничением стоянки",height:30,type:"Знаки особых предписаний"},5.29:{title:"Зона регулируемой стоянки",height:30,type:"Знаки особых предписаний"},"5.30":{title:"Конец зоны регулируемой стоянки",height:30,type:"Знаки особых предписаний"},5.31:{title:"Зона с ограничением максимальной скорости",height:30,type:"Знаки особых предписаний"},5.32:{title:"Конец зоны с ограничением максимальной скорости",height:30,type:"Знаки особых предписаний"},5.33:{title:"Пешеходная зона",height:30,type:"Знаки особых предписаний"},5.34:{title:"Конец пешеходной зоны",height:30,type:"Знаки особых предписаний"},5.35:{title:"Зона с ограничением экологического класса механических транспортных средств",height:30,type:"Знаки особых предписаний"},5.36:{title:"Конец зоны с ограничением экологического класса механических транспортных средств",height:30,type:"Знаки особых предписаний"},"5.37 A":{title:"Зона с ограничением экологического класса по видам транспортных средств",height:30,type:"Знаки особых предписаний"},"5.37 B":{title:"Зона с ограничением экологического класса по видам транспортных средств",height:30,type:"Знаки особых предписаний"},"5.38 A":{title:"Конец зоны с ограничением экологического класса по видам транспортных средств",height:30,type:"Знаки особых предписаний"},"5.38 B":{title:"Конец зоны с ограничением экологического класса по видам транспортных средств",height:30,type:"Знаки особых предписаний"},5.39:{title:"Велосипедная зона",height:30,type:"Знаки особых предписаний"},"5.40":{title:"Конец велосипедной зоны",height:30,type:"Знаки особых предписаний"},6.1:{title:"Общие ограничения максимальной скорости",height:30,type:"Информационные знаки"},"6.2-50":{title:"Рекомендуемая скорость",height:20,type:"Информационные знаки"},"6.3.1":{title:"Место для разворота",height:20,type:"Информационные знаки"},"6.3.2":{title:"Зона для разворота",height:20,type:"Информационные знаки"},"6.4 A":{title:"Парковка (парковочное место)",height:20,type:"Информационные знаки"},"6.4 B":{title:"Парковка (платные услуги)",height:20,type:"Информационные знаки"},"6.4 C":{title:"Парковка (только для инвалидов)",height:20,type:"Информационные знаки"},6.5:{title:"Полоса аварийной остановки",height:20,type:"Информационные знаки"},6.6:{title:"Подземный пешеходный переход",height:20,type:"Информационные знаки"},6.7:{title:"Надземный пешеходный переход",height:20,type:"Информационные знаки"},"6.8.1":{title:"Тупик",height:20,type:"Информационные знаки"},"6.8.2":{title:"Тупик",height:20,type:"Информационные знаки"},"6.8.3":{title:"Тупик",height:20,type:"Информационные знаки"},"6.9.1 A":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 B":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 C":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 D":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 E":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 F":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.2 A":{title:"Предварительный указатель направления",height:20,type:"Информационные знаки"},"6.9.2 B":{title:"Предварительный указатель направления",height:20,type:"Информационные знаки"},"6.9.2 C":{title:"Предварительный указатель направления",height:20,type:"Информационные знаки"},"6.9.3":{title:"Схема движения",height:20,type:"Информационные знаки"},"6.10.1 A":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 B":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 C":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 D":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 E":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 F":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 G":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.2 A":{title:"Указатель направления",height:20,type:"Информационные знаки"},"6.10.2 B":{title:"Указатель направления",height:20,type:"Информационные знаки"},"6.11 A":{title:"Наименование объекта",height:20,type:"Информационные знаки"},"6.11 B":{title:"Наименование объекта",height:20,type:"Информационные знаки"},"6.11 C":{title:"Наименование объекта",height:20,type:"Информационные знаки"},"6.11 D":{title:"Наименование объекта",height:20,type:"Информационные знаки"},"6.12 A":{title:"Указатель расстояний",height:20,type:"Информационные знаки"},"6.12 B":{title:"Указатель расстояний",height:20,type:"Информационные знаки"},"6.12 C":{title:"Указатель расстояний",height:20,type:"Информационные знаки"},"6.13 A":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.13 B":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.13 C":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.13 D":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.13 E":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.14.1 A":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.1 B":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.1 C":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.1 D":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.2 A":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.2 B":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.2 C":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.15.1":{title:"Направление движения для грузовых автомобилей",height:20,type:"Информационные знаки"},"6.15.2":{title:"Направление движения для грузовых автомобилей",height:20,type:"Информационные знаки"},"6.15.3":{title:"Направление движения для грузовых автомобилей",height:20,type:"Информационные знаки"},6.16:{title:"Стоп-линия",height:20,type:"Информационные знаки"},6.17:{title:"Схема объезда",height:25,type:"Информационные знаки"},"6.18.1":{title:"Направление объезда",height:20,type:"Информационные знаки"},"6.18.2":{title:"Направление объезда",height:20,type:"Информационные знаки"},"6.18.3":{title:"Направление объезда",height:20,type:"Информационные знаки"},"6.19.1":{title:"Предварительный указатель перестроения на другую проезжую часть",height:25,type:"Информационные знаки"},"6.19.2":{title:"Предварительный указатель перестроения на другую проезжую часть",height:25,type:"Информационные знаки"},"6.20.1":{title:"Аварийный выход",height:20,type:"Информационные знаки"},"6.20.2":{title:"Аварийный выход",height:20,type:"Информационные знаки"},"6.21.1":{title:"Направление движения к аварийному выходу",height:20,type:"Информационные знаки"},"6.21.2":{title:"Направление движения к аварийному выходу",height:20,type:"Информационные знаки"},6.22:{title:"Фотовидеофиксация",height:20,type:"Информационные знаки"},7.1:{title:"Пункт медицинской помощи",height:30,type:"Знаки сервиса"},7.2:{title:"Больница",height:30,type:"Знаки сервиса"},7.3:{title:"Автозаправочная станция",height:30,type:"Знаки сервиса"},7.4:{title:"Техническое обслуживание автомобилей",height:30,type:"Знаки сервиса"},7.5:{title:"Мойка автомобилей",height:30,type:"Знаки сервиса"},7.6:{title:"Телефон",height:30,type:"Знаки сервиса"},7.7:{title:"Пункт питания",height:30,type:"Знаки сервиса"},7.8:{title:"Питьевая вода",height:30,type:"Знаки сервиса"},7.9:{title:"Гостиница или мотель",height:30,type:"Знаки сервиса"},"7.10":{title:"Кемпинг",height:30,type:"Знаки сервиса"},7.11:{title:"Место отдыха",height:30,type:"Знаки сервиса"},7.12:{title:"Пост ДПС",height:30,type:"Знаки сервиса"},7.13:{title:"Полиция",height:30,type:"Знаки сервиса"},"7.14.1":{title:"Пункт таможенного контроля",height:30,type:"Знаки сервиса"},"7.14.2":{title:"Пункт транспортного контроля",height:30,type:"Знаки сервиса"},7.15:{title:"Зона приёма радиостанции, передающей информацию о дорожном движении",height:30,type:"Знаки сервиса"},7.16:{title:"Зона радиосвязи с аварийными службами",height:30,type:"Знаки сервиса"},7.17:{title:"Бассейн или пляж",height:30,type:"Знаки сервиса"},7.18:{title:"Туалет",height:30,type:"Знаки сервиса"},7.19:{title:"Телефон экстренной связи",height:30,type:"Знаки сервиса"},"7.20":{title:"Огнетушитель",height:30,type:"Знаки сервиса"},7.21:{title:"Автозаправочная станция с возможностью зарядки электромобилей",height:30,type:"Знаки сервиса"}},lm={"8.1.1":{title:"Расстояние до объекта",height:20,type:"Знаки дополнительной информации"},"8.1.2":{title:"Расстояние до объекта",height:20,type:"Знаки дополнительной информации"},"8.1.3":{title:"Расстояние до объекта",height:20,type:"Знаки дополнительной информации"},"8.1.4":{title:"Расстояние до объекта",height:20,type:"Знаки дополнительной информации"},"8.2.1":{title:"Зона действия",height:20,type:"Знаки дополнительной информации"},"8.2.2":{title:"Зона действия",height:40,type:"Знаки дополнительной информации"},"8.2.3":{title:"Зона действия",height:40,type:"Знаки дополнительной информации"},"8.2.4":{title:"Зона действия",height:40,type:"Знаки дополнительной информации"},"8.2.5":{title:"Зона действия",height:20,type:"Знаки дополнительной информации"},"8.2.6":{title:"Зона действия",height:20,type:"Знаки дополнительной информации"},"8.3.1":{title:"Направления действия",height:20,type:"Знаки дополнительной информации"},"8.3.2":{title:"Направления действия",height:20,type:"Знаки дополнительной информации"},"8.3.3":{title:"Направления действия",height:20,type:"Знаки дополнительной информации"},"8.4.1":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.2":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.3.1":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.3.2":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.4":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.5":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.6":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.7.1":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.7.2":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.8":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.9":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.10":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.11":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.12":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.13":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.14":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.15":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.5.1":{title:"Субботние, воскресные и праздничные дни",height:20,type:"Знаки дополнительной информации"},"8.5.2":{title:"Рабочие дни",height:20,type:"Знаки дополнительной информации"},"8.5.3":{title:"Дни недели",height:20,type:"Знаки дополнительной информации"},"8.5.4":{title:"Время действия",height:20,type:"Знаки дополнительной информации"},"8.5.5":{title:"Время действия",height:20,type:"Знаки дополнительной информации"},"8.5.6":{title:"Время действия",height:20,type:"Знаки дополнительной информации"},"8.5.7":{title:"Время действия",height:20,type:"Знаки дополнительной информации"},"8.6.1":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.2":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.3":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.4":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.5":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.6":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.7":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.8":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.9":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},8.7:{title:"Стоянка с неработающим двигателем",height:20,type:"Знаки дополнительной информации"},8.8:{title:"Платные услуги",height:20,type:"Знаки дополнительной информации"},"8.9.1":{title:"Ограничение продолжительности стоянки",height:20,type:"Знаки дополнительной информации"},"8.9.2":{title:"Стоянка только для владельцев парковочных разрешений",height:20,type:"Знаки дополнительной информации"},"8.9.3":{title:"Стоянка только транспортных средств дипломатического корпуса",height:20,type:"Знаки дополнительной информации"},"8.10":{title:"Место для осмотра автомобилей",height:20,type:"Знаки дополнительной информации"},8.11:{title:"Ограничение разрешённой максимальной массы",height:20,type:"Знаки дополнительной информации"},8.12:{title:"Опасная обочина",height:20,type:"Знаки дополнительной информации"},8.13:{title:"Направление главной дороги",height:20,type:"Знаки дополнительной информации"},"8.13 B":{title:"Направление главной дороги",height:20,type:"Знаки дополнительной информации"},8.14:{title:"Полоса движения",height:20,type:"Знаки дополнительной информации"},8.15:{title:"Слепые пешеходы",height:20,type:"Знаки дополнительной информации"},8.16:{title:"Влажное покрытие",height:20,type:"Знаки дополнительной информации"},8.17:{title:"Инвалиды",height:20,type:"Знаки дополнительной информации"},8.18:{title:"Кроме инвалидов",height:20,type:"Знаки дополнительной информации"},8.19:{title:"Класс опасного груза",height:20,type:"Знаки дополнительной информации"},"8.20.1":{title:"Тип тележки транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.20.2":{title:"Тип тележки транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.21.1":{title:"Вид маршрутного транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.21.2":{title:"Вид маршрутного транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.21.3":{title:"Вид маршрутного транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.22.1":{title:"Препятствие",height:68,type:"Знаки дополнительной информации"},"8.22.2":{title:"Препятствие",height:68,type:"Знаки дополнительной информации"},"8.22.3":{title:"Препятствие",height:68,type:"Знаки дополнительной информации"},8.24:{title:"Работает эвакуатор",height:20,type:"Знаки дополнительной информации"},8.25:{title:"Экологический класс транспортного средства",height:20,type:"Знаки дополнительной информации"},8.26:{title:"Зарядка электромобилей",height:20,type:"Знаки дополнительной информации"}},um={...am,...lm},cm=Object.entries(am)[0],hm=Object.entries(lm)[0],dm={comment:"",direction:0,traffic_sign_value:"",traffic_sign_number:cm[0],traffic_sign_title:cm[1].title,traffic_sign_type:cm[1].type,status:Mf.ACTIVE},fm={traffic_sign_id:sn()},pm={traffic_sign_id:sn(),dop_id:sn()},gm={comment:"",dop_sign_number:hm[0],dop_sign_title:hm[1].title,dop_sign_text:"",status:Mf.ACTIVE},mm={...Of,...Cf,...dm,dops:[]},_m={...Cf,...gm},ym={fileName:"traffic-sign",apiName:"traffic_sign",extension:"svg",dopsCount:2,widths:{map:20,preview:40}},vm={title:"Дорожные знаки"},bm={title:"Дополнительная информация"},xm=e=>{const t=[],n={source:e,layer:gf.TRAFFIC_SIGN},r={},i={};Object.keys(am).forEach(e=>{const t=`${ym.fileName}-${e}`,{height:n}=am[e],s=wm({type:"map",number:e});r[t]={url:s,filtering:"mipmap",sprites:{base:[0,0,ym.widths.map,n]}},i[t]={filter:`function() {\n const { traffic_sign_number } = feature;\n\n const isFilter = traffic_sign_number === '${e}';\n\n return isFilter;\n }`,draw:{points:{collide:!1,texture:t,size:[ym.widths.map,n],sprite:"base",placement:"midpoint"}}}});const s={id:sn(),data:n,textures:r,sublayers:i};return t.push(s),t},wm=({type:e,number:t})=>{const n=ym.widths[e];return`${wf}/msk/${ym.fileName}_${n}/${t}.${ym.extension}`},Am=()=>{const e=new Set,t=[];return Object.values(am).forEach(({title:t})=>{e.add(t)}),e.forEach(e=>{t.push({label:e,value:e})}),t},Em=e=>{const t={};e.forEach(({traffic_sign_number:e,traffic_sign_title:n,traffic_sign_type:r,height:i})=>{t[e]={title:n,height:Number(i),type:r}}),rn(t)},Sm=e=>um[e].title;var Tm=gl(({disabled:e=!1,onClick:t})=>b(jl,{sx:{margin:"0 auto"},onClick:t,disabled:e,children:"Добавить табличку"}));const km=({items:t,initialValue:n,onChange:r})=>{const[i,s]=e.useState(()=>n??t[0].value),o=e.useId();return e.useEffect(()=>{n&&s(n)},[n]),x(ae,{value:i,children:[b(T,{sx:{borderBottom:1,borderColor:"divider"},children:b(le,{"aria-label":`tabs-${o}`,onChange:(e,t)=>{s(t),r?.(t)},children:t.map(({label:e,value:t})=>b(H,{label:e,value:t,sx:{textTransform:"none"}},`${o}-tab-${t}`))})}),t.map(({content:e,value:t})=>b(ue,{value:t,children:e},`${o}-tab-panel-${t}`))]})},Om="newDops";var Rm=gl(({index:t,onDelete:n})=>{const{setValue:r,register:i,watch:s}=Tu(),o=s(`${Om}.${t}`),{dop_sign_number:a}=o,l=e.useId();return x(T,{id:l,sx:{display:"grid",gap:"12px"},children:[b(Ll,{items:[{value:1,summary:x(T,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[b(Ul,{notification:{title:"Удалить табличку",description:"Вы действительно хотите удалить данную табличку?"},onDelete:n}),b(Mm,{number:a})]}),getDetails:({onClose:e})=>b(N_,{pageSize:5,filtered:{type:!1},trafficSigns:lm,onSelect:({title:n,number:i})=>{r(`${Om}.${t}.dop_sign_number`,i),r(`${Om}.${t}.dop_sign_title`,n),e()}})}]}),b(wg,{...i(`${Om}.${t}.status`),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...i(`${Om}.${t}.comment`),label:If.comment}),b(pf,{...i(`${Om}.${t}.dop_sign_text`),label:If.dop_sign_text}),b(cg,{children:Rf.map(e=>b(zc,{...i(`${Om}.${t}.${e}`),label:If[e],format:Df},`${l}-${e}`))})]})});const Cm="oldDops";var Pm=gl(({index:t,onDelete:n,onUpdate:r})=>{const i=e.useId(),{register:s,setValue:o,watch:a}=Tu(),l=a(`${Cm}.${t}`),{dop_sign_number:u}=l;return x(T,{id:i,sx:{display:"grid",gap:"12px"},children:[b(Ll,{items:[{value:1,summary:x(T,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[b(Ul,{notification:{title:"Удалить табличку",description:"Вы действительно хотите удалить данную табличку?"},onDelete:()=>{n(l)}}),b(Mm,{number:u})]}),getDetails:({onClose:e})=>b(N_,{pageSize:5,filtered:{type:!1},trafficSigns:lm,onSelect:({title:n,number:r})=>{o(`${Cm}.${t}.dop_sign_number`,r),o(`${Cm}.${t}.dop_sign_title`,n),e()}})}]}),b(wg,{...s(`${Cm}.${t}.status`),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...s(`${Cm}.${t}.comment`),label:If.comment}),b(pf,{...s(`${Cm}.${t}.dop_sign_text`),label:If.dop_sign_text}),b(cg,{children:Rf.map(e=>b(zc,{...s(`${Cm}.${t}.${e}`),label:If[e],format:Df},`${i}-${e}`))}),b(jl,{onClick:()=>{r(l)},children:"Сохранить"})]})});var Mm=gl(({number:e})=>{const t=Sm(e);return x(T,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[b(C_,{number:e}),x(B,{children:[t," (",e,")"]})]})});
|
|
10
|
+
*/var ol,al,ll=(il||(il=1,"production"===process.env.NODE_ENV?tl.exports=function(){if(Qa)return nl;Qa=1;var e=t,n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=e.useState,i=e.useEffect,s=e.useLayoutEffect,o=e.useDebugValue;function a(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!n(e,r)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),l=r({inst:{value:n,getSnapshot:t}}),u=l[0].inst,c=l[1];return s(function(){u.value=n,u.getSnapshot=t,a(u)&&c({inst:u})},[e,n,t]),i(function(){return a(u)&&c({inst:u}),e(function(){a(u)&&c({inst:u})})},[e]),o(n),n};return nl.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,nl}():tl.exports=(rl||(rl=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=t,r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=n.useState,s=n.useEffect,o=n.useLayoutEffect,a=n.useDebugValue,l=!1,u=!1,c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(t,c){l||void 0===n.startTransition||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=c();if(!u){var d=c();r(h,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var f=(d=i({inst:{value:h,getSnapshot:c}}))[0].inst,p=d[1];return o(function(){f.value=h,f.getSnapshot=c,e(f)&&p({inst:f})},[t,h,c]),s(function(){return e(f)&&p({inst:f}),t(function(){e(f)&&p({inst:f})})},[t]),a(h),h};sl.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),sl)),tl.exports);function ul(e){e.reaction=new Ni("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),null===(t=e.onStoreChange)||void 0===t||t.call(e)})}var cl=!0,hl="function"==typeof Symbol&&Symbol.for,dl=null!==(al=null===(ol=Object.getOwnPropertyDescriptor(function(){},"name"))||void 0===ol?void 0:ol.configurable)&&void 0!==al&&al,fl=hl?Symbol.for("react.forward_ref"):"function"==typeof n&&n(function(e){return null}).$$typeof,pl=hl?Symbol.for("react.memo"):"function"==typeof h&&h(function(e){return null}).$$typeof;function gl(e,r){if(process.env.NODE_ENV,pl&&e.$$typeof===pl)throw new Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var i=!1,s=e,o=e.displayName||e.name;if(fl&&e.$$typeof===fl&&(i=!0,"function"!=typeof(s=e.render)))throw new Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var a,l,u=function(e,n){return function(e,n){void 0===n&&(n="observed");var r=t.useRef(null);if(!r.current){var i={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:n,subscribe:function(e){return el.unregister(i),i.onStoreChange=e,i.reaction||(ul(i),i.stateVersion=Symbol()),function(){var e;i.onStoreChange=null,null===(e=i.reaction)||void 0===e||e.dispose(),i.reaction=null}},getSnapshot:function(){return i.stateVersion}};r.current=i}var s,o,a=r.current;if(a.reaction||(ul(a),el.register(r,a,a)),t.useDebugValue(a.reaction,Ya),ll.useSyncExternalStore(a.subscribe,a.getSnapshot,a.getSnapshot),a.reaction.track(function(){try{s=e()}catch(e){o=e}}),o)throw o;return s}(function(){return s(e,n)},o)};return u.displayName=e.displayName,dl&&Object.defineProperty(u,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(u.contextTypes=e.contextTypes,"production"!==process.env.NODE_ENV&&cl&&(cl=!1,console.warn("[mobx-react-lite] Support for Legacy Context in function components will be removed in the next major release."))),i&&(u=n(u)),u=h(u),a=e,l=u,Object.keys(a).forEach(function(e){ml[e]||Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(a,e))}),"production"!==process.env.NODE_ENV&&Object.defineProperty(u,"contextTypes",{set:function(){var e,t;throw new Error("[mobx-react-lite] `".concat(this.displayName||(null===(e=this.type)||void 0===e?void 0:e.displayName)||(null===(t=this.type)||void 0===t?void 0:t.name)||"Component",".contextTypes` must be set before applying `observer`."))}}),u}var ml={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};process.env.NODE_ENV,function(e){e||(e=Xa,"production"!==process.env.NODE_ENV&&console.warn("[MobX] Failed to get unstable_batched updates from react-dom / react-native")),os({reactionScheduler:e})}(v),el.finalizeAllImmediately;var _l=gl(({onUnauthorized:t,children:n})=>(e.useEffect(()=>{Io.isUnauthorized&&t()},[Io.isUnauthorized]),b(e.Fragment,{children:n})));function yl(e,t){if(void 0!==e.one&&1===t)return e.one;const n=t%10,r=t%100;return 1===n&&11!==r?e.singularNominative.replace("{{count}}",String(t)):n>=2&&n<=4&&(r<10||r>20)?e.singularGenitive.replace("{{count}}",String(t)):e.pluralGenitive.replace("{{count}}",String(t))}function vl(e){return(t,n)=>n?.addSuffix?n.comparison&&n.comparison>0?e.future?yl(e.future,t):"через "+yl(e.regular,t):e.past?yl(e.past,t):yl(e.regular,t)+" назад":yl(e.regular,t)}const bl={lessThanXSeconds:vl({regular:{one:"меньше секунды",singularNominative:"меньше {{count}} секунды",singularGenitive:"меньше {{count}} секунд",pluralGenitive:"меньше {{count}} секунд"},future:{one:"меньше, чем через секунду",singularNominative:"меньше, чем через {{count}} секунду",singularGenitive:"меньше, чем через {{count}} секунды",pluralGenitive:"меньше, чем через {{count}} секунд"}}),xSeconds:vl({regular:{singularNominative:"{{count}} секунда",singularGenitive:"{{count}} секунды",pluralGenitive:"{{count}} секунд"},past:{singularNominative:"{{count}} секунду назад",singularGenitive:"{{count}} секунды назад",pluralGenitive:"{{count}} секунд назад"},future:{singularNominative:"через {{count}} секунду",singularGenitive:"через {{count}} секунды",pluralGenitive:"через {{count}} секунд"}}),halfAMinute:(e,t)=>t?.addSuffix?t.comparison&&t.comparison>0?"через полминуты":"полминуты назад":"полминуты",lessThanXMinutes:vl({regular:{one:"меньше минуты",singularNominative:"меньше {{count}} минуты",singularGenitive:"меньше {{count}} минут",pluralGenitive:"меньше {{count}} минут"},future:{one:"меньше, чем через минуту",singularNominative:"меньше, чем через {{count}} минуту",singularGenitive:"меньше, чем через {{count}} минуты",pluralGenitive:"меньше, чем через {{count}} минут"}}),xMinutes:vl({regular:{singularNominative:"{{count}} минута",singularGenitive:"{{count}} минуты",pluralGenitive:"{{count}} минут"},past:{singularNominative:"{{count}} минуту назад",singularGenitive:"{{count}} минуты назад",pluralGenitive:"{{count}} минут назад"},future:{singularNominative:"через {{count}} минуту",singularGenitive:"через {{count}} минуты",pluralGenitive:"через {{count}} минут"}}),aboutXHours:vl({regular:{singularNominative:"около {{count}} часа",singularGenitive:"около {{count}} часов",pluralGenitive:"около {{count}} часов"},future:{singularNominative:"приблизительно через {{count}} час",singularGenitive:"приблизительно через {{count}} часа",pluralGenitive:"приблизительно через {{count}} часов"}}),xHours:vl({regular:{singularNominative:"{{count}} час",singularGenitive:"{{count}} часа",pluralGenitive:"{{count}} часов"}}),xDays:vl({regular:{singularNominative:"{{count}} день",singularGenitive:"{{count}} дня",pluralGenitive:"{{count}} дней"}}),aboutXWeeks:vl({regular:{singularNominative:"около {{count}} недели",singularGenitive:"около {{count}} недель",pluralGenitive:"около {{count}} недель"},future:{singularNominative:"приблизительно через {{count}} неделю",singularGenitive:"приблизительно через {{count}} недели",pluralGenitive:"приблизительно через {{count}} недель"}}),xWeeks:vl({regular:{singularNominative:"{{count}} неделя",singularGenitive:"{{count}} недели",pluralGenitive:"{{count}} недель"}}),aboutXMonths:vl({regular:{singularNominative:"около {{count}} месяца",singularGenitive:"около {{count}} месяцев",pluralGenitive:"около {{count}} месяцев"},future:{singularNominative:"приблизительно через {{count}} месяц",singularGenitive:"приблизительно через {{count}} месяца",pluralGenitive:"приблизительно через {{count}} месяцев"}}),xMonths:vl({regular:{singularNominative:"{{count}} месяц",singularGenitive:"{{count}} месяца",pluralGenitive:"{{count}} месяцев"}}),aboutXYears:vl({regular:{singularNominative:"около {{count}} года",singularGenitive:"около {{count}} лет",pluralGenitive:"около {{count}} лет"},future:{singularNominative:"приблизительно через {{count}} год",singularGenitive:"приблизительно через {{count}} года",pluralGenitive:"приблизительно через {{count}} лет"}}),xYears:vl({regular:{singularNominative:"{{count}} год",singularGenitive:"{{count}} года",pluralGenitive:"{{count}} лет"}}),overXYears:vl({regular:{singularNominative:"больше {{count}} года",singularGenitive:"больше {{count}} лет",pluralGenitive:"больше {{count}} лет"},future:{singularNominative:"больше, чем через {{count}} год",singularGenitive:"больше, чем через {{count}} года",pluralGenitive:"больше, чем через {{count}} лет"}}),almostXYears:vl({regular:{singularNominative:"почти {{count}} год",singularGenitive:"почти {{count}} года",pluralGenitive:"почти {{count}} лет"},future:{singularNominative:"почти через {{count}} год",singularGenitive:"почти через {{count}} года",pluralGenitive:"почти через {{count}} лет"}})};function xl(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const wl={date:xl({formats:{full:"EEEE, d MMMM y 'г.'",long:"d MMMM y 'г.'",medium:"d MMM y 'г.'",short:"dd.MM.y"},defaultWidth:"full"}),time:xl({formats:{full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},defaultWidth:"full"}),dateTime:xl({formats:{any:"{{date}}, {{time}}"},defaultWidth:"any"})},Al=Symbol.for("constructDateFrom");function El(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&Al in e?e[Al](t):e instanceof Date?new e.constructor(t):new Date(t)}let Sl={};function Tl(e,t){const n=Sl,r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=(s=e,o=t?.in,El(o||s,s));var s,o;const a=i.getDay(),l=(a<r?7:0)+a-r;return i.setDate(i.getDate()-l),i.setHours(0,0,0,0),i}function kl(e,t,n){const[r,i]=function(e,...t){const n=El.bind(null,e||t.find(e=>"object"==typeof e));return t.map(n)}(n?.in,e,t);return+Tl(r,n)===+Tl(i,n)}const Ol=["воскресенье","понедельник","вторник","среду","четверг","пятницу","субботу"];function Rl(e){const t=Ol[e];return 2===e?"'во "+t+" в' p":"'в "+t+" в' p"}const Cl={lastWeek:(e,t,n)=>{const r=e.getDay();return kl(e,t,n)?Rl(r):function(e){const t=Ol[e];switch(e){case 0:return"'в прошлое "+t+" в' p";case 1:case 2:case 4:return"'в прошлый "+t+" в' p";case 3:case 5:case 6:return"'в прошлую "+t+" в' p"}}(r)},yesterday:"'вчера в' p",today:"'сегодня в' p",tomorrow:"'завтра в' p",nextWeek:(e,t,n)=>{const r=e.getDay();return kl(e,t,n)?Rl(r):function(e){const t=Ol[e];switch(e){case 0:return"'в следующее "+t+" в' p";case 1:case 2:case 4:return"'в следующий "+t+" в' p";case 3:case 5:case 6:return"'в следующую "+t+" в' p"}}(r)},other:"P"};function Pl(e){return(t,n)=>{let r;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,i=n?.width?String(n.width):t;r=e.formattingValues[i]||e.formattingValues[t]}else{const t=e.defaultWidth,i=n?.width?String(n.width):e.defaultWidth;r=e.values[i]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}const Ml={ordinalNumber:(e,t)=>{const n=Number(e),r=t?.unit;let i;return i="date"===r?"-е":"week"===r||"minute"===r||"second"===r?"-я":"-й",n+i},era:Pl({values:{narrow:["до н.э.","н.э."],abbreviated:["до н. э.","н. э."],wide:["до нашей эры","нашей эры"]},defaultWidth:"wide"}),quarter:Pl({values:{narrow:["1","2","3","4"],abbreviated:["1-й кв.","2-й кв.","3-й кв.","4-й кв."],wide:["1-й квартал","2-й квартал","3-й квартал","4-й квартал"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Pl({values:{narrow:["Я","Ф","М","А","М","И","И","А","С","О","Н","Д"],abbreviated:["янв.","фев.","март","апр.","май","июнь","июль","авг.","сент.","окт.","нояб.","дек."],wide:["январь","февраль","март","апрель","май","июнь","июль","август","сентябрь","октябрь","ноябрь","декабрь"]},defaultWidth:"wide",formattingValues:{narrow:["Я","Ф","М","А","М","И","И","А","С","О","Н","Д"],abbreviated:["янв.","фев.","мар.","апр.","мая","июн.","июл.","авг.","сент.","окт.","нояб.","дек."],wide:["января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"]},defaultFormattingWidth:"wide"}),day:Pl({values:{narrow:["В","П","В","С","Ч","П","С"],short:["вс","пн","вт","ср","чт","пт","сб"],abbreviated:["вск","пнд","втр","срд","чтв","птн","суб"],wide:["воскресенье","понедельник","вторник","среда","четверг","пятница","суббота"]},defaultWidth:"wide"}),dayPeriod:Pl({values:{narrow:{am:"ДП",pm:"ПП",midnight:"полн.",noon:"полд.",morning:"утро",afternoon:"день",evening:"веч.",night:"ночь"},abbreviated:{am:"ДП",pm:"ПП",midnight:"полн.",noon:"полд.",morning:"утро",afternoon:"день",evening:"веч.",night:"ночь"},wide:{am:"ДП",pm:"ПП",midnight:"полночь",noon:"полдень",morning:"утро",afternoon:"день",evening:"вечер",night:"ночь"}},defaultWidth:"any",formattingValues:{narrow:{am:"ДП",pm:"ПП",midnight:"полн.",noon:"полд.",morning:"утра",afternoon:"дня",evening:"веч.",night:"ночи"},abbreviated:{am:"ДП",pm:"ПП",midnight:"полн.",noon:"полд.",morning:"утра",afternoon:"дня",evening:"веч.",night:"ночи"},wide:{am:"ДП",pm:"ПП",midnight:"полночь",noon:"полдень",morning:"утра",afternoon:"дня",evening:"вечера",night:"ночи"}},defaultFormattingWidth:"wide"})};function Nl(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const o=s[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(a)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;return}(a,e=>e.test(o)):function(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;return}(a,e=>e.test(o));let u;u=e.valueCallback?e.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;return{value:u,rest:t.slice(o.length)}}}const Il={ordinalNumber:(Dl={matchPattern:/^(\d+)(-?(е|я|й|ое|ье|ая|ья|ый|ой|ий|ый))?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(Dl.matchPattern);if(!n)return null;const r=n[0],i=e.match(Dl.parsePattern);if(!i)return null;let s=Dl.valueCallback?Dl.valueCallback(i[0]):i[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:Nl({matchPatterns:{narrow:/^((до )?н\.?\s?э\.?)/i,abbreviated:/^((до )?н\.?\s?э\.?)/i,wide:/^(до нашей эры|нашей эры|наша эра)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^д/i,/^н/i]},defaultParseWidth:"any"}),quarter:Nl({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^[1234](-?[ыои]?й?)? кв.?/i,wide:/^[1234](-?[ыои]?й?)? квартал/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Nl({matchPatterns:{narrow:/^[яфмаисонд]/i,abbreviated:/^(янв|фев|март?|апр|ма[йя]|июн[ья]?|июл[ья]?|авг|сент?|окт|нояб?|дек)\.?/i,wide:/^(январ[ья]|феврал[ья]|марта?|апрел[ья]|ма[йя]|июн[ья]|июл[ья]|августа?|сентябр[ья]|октябр[ья]|октябр[ья]|ноябр[ья]|декабр[ья])/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^я/i,/^ф/i,/^м/i,/^а/i,/^м/i,/^и/i,/^и/i,/^а/i,/^с/i,/^о/i,/^н/i,/^я/i],any:[/^я/i,/^ф/i,/^мар/i,/^ап/i,/^ма[йя]/i,/^июн/i,/^июл/i,/^ав/i,/^с/i,/^о/i,/^н/i,/^д/i]},defaultParseWidth:"any"}),day:Nl({matchPatterns:{narrow:/^[впсч]/i,short:/^(вс|во|пн|по|вт|ср|чт|че|пт|пя|сб|су)\.?/i,abbreviated:/^(вск|вос|пнд|пон|втр|вто|срд|сре|чтв|чет|птн|пят|суб).?/i,wide:/^(воскресень[ея]|понедельника?|вторника?|сред[аы]|четверга?|пятниц[аы]|суббот[аы])/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^в/i,/^п/i,/^в/i,/^с/i,/^ч/i,/^п/i,/^с/i],any:[/^в[ос]/i,/^п[он]/i,/^в/i,/^ср/i,/^ч/i,/^п[ят]/i,/^с[уб]/i]},defaultParseWidth:"any"}),dayPeriod:Nl({matchPatterns:{narrow:/^([дп]п|полн\.?|полд\.?|утр[оа]|день|дня|веч\.?|ноч[ьи])/i,abbreviated:/^([дп]п|полн\.?|полд\.?|утр[оа]|день|дня|веч\.?|ноч[ьи])/i,wide:/^([дп]п|полночь|полдень|утр[оа]|день|дня|вечера?|ноч[ьи])/i},defaultMatchWidth:"wide",parsePatterns:{any:{am:/^дп/i,pm:/^пп/i,midnight:/^полн/i,noon:/^полд/i,morning:/^у/i,afternoon:/^д[ен]/i,evening:/^в/i,night:/^н/i}},defaultParseWidth:"any"})};var Dl;const Fl={code:"ru",formatDistance:(e,t,n)=>bl[e](t,n),formatLong:wl,formatRelative:(e,t,n,r)=>{const i=Cl[e];return"function"==typeof i?i(t,n,r):i},localize:Ml,match:Il,options:{weekStartsOn:1,firstWeekContainsDate:1}},zl=e=>b(A,{...e,dateAdapter:E,adapterLocale:Fl}),Ll=({items:t,onOpen:n,defaultValue:r=null})=>{const[i,s]=e.useState(r),o=e.useCallback(()=>{s(null)},[]);e.useEffect(()=>{r&&s(r)},[r]);const a=e.useId();return b(T,{id:a,children:t.map(({value:e,summary:t,getDetails:r})=>{const l=`${a}-accordion-${e}`;return x(k,{expanded:e===i,children:[b(O,{expandIcon:b(S,{}),onClick:()=>{s(t=>t===e?null:(n?.(e),e))},"aria-controls":`${l}-content`,id:`${l}-header`,children:t}),b(R,{children:r({onClose:o})})]},l)})})},jl=e=>{const{children:t,variant:n="contained",loading:r,icon:i,sx:s,...o}=e;return i?b(Z,{...o,loading:r,children:i}):b(C,{sx:{whiteSpace:"nowrap",padding:"5px 15px",textTransform:"none",...s},loading:r,loadingPosition:"start",variant:n,...o,children:t})},Vl=e.forwardRef(function(e,t){return b(P,{direction:"up",ref:t,...e})}),Ul=({notification:t,onDelete:n})=>{const r=e.useId(),[i,s]=e.useState(!1),o=()=>{s(!1)};return x(e.Fragment,{children:[t?b(M,{title:t.title,children:b(N,{onClick:e=>{e.stopPropagation(),s(!0)},children:b(K,{fontSize:"small",color:"error"})})}):b(N,{onClick:e=>{e.stopPropagation(),n()},children:b(K,{fontSize:"small",color:"error"})}),t?x(I,{slots:{transition:Vl},open:i,onClose:o,children:[b(D,{id:`${r}-dialog-title`,children:t.title}),b(F,{children:b(z,{id:`${r}-dialog-text`,children:t.description})}),x(L,{children:[b(C,{variant:"contained",color:"error",sx:{textTransform:"none"},onClick:o,children:"Отмена"}),b(C,{variant:"contained",sx:{textTransform:"none"},onClick:()=>{n(),o()},children:"Подтвердить"})]})]}):null]})},Bl={reset:Q,edit:X,move:Y},Gl=({title:t,iconProps:n,...r})=>{const i=e.useId(),s=Bl[n.name];return t?b(M,{title:t,children:b(N,{id:i,...r,children:b(s,{fontSize:"medium",color:n.color??"primary"})})}):b(N,{id:i,...r,children:b(s,{fontSize:"medium",color:n.color??"primary"})})},$l=j("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1}),ql=({children:e,accept:t,onFilesLoad:n,...r})=>x(jl,{...r,component:"label",variant:"contained",startIcon:b(J,{}),children:[e,b($l,{type:"file",accept:t,onChange:e=>{const{target:{files:t}}=e;t&&n({event:e,files:t})},multiple:!0})]}),Hl=({children:e,sx:t={},...n})=>b(T,{...n,sx:{padding:"20px 15px",borderRadius:"10px",boxShadow:"0px 8px 24px 0px rgba(0,0,0,0.3)",maxHeight:"80vh",maxWidth:"90vw",overflowX:"auto",...t},children:e});var Wl=e=>"checkbox"===e.type,Zl=e=>e instanceof Date,Kl=e=>null==e;const Xl=e=>"object"==typeof e;var Yl=e=>!Kl(e)&&!Array.isArray(e)&&Xl(e)&&!Zl(e),Ql=e=>Yl(e)&&e.target?Wl(e.target)?e.target.checked:e.target.value:e,Jl=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),eu="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function tu(e){if(e instanceof Date)return new Date(e);const t="undefined"!=typeof FileList&&e instanceof FileList;if(eu&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!(n||Yl(e)&&(e=>{const t=e.constructor&&e.constructor.prototype;return Yl(t)&&t.hasOwnProperty("isPrototypeOf")})(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=tu(e[t]));return r}var nu=e=>/^\w*$/.test(e),ru=e=>void 0===e,iu=e=>Array.isArray(e)?e.filter(Boolean):[],su=e=>iu(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ou=(e,t,n)=>{if(!t||!Yl(e))return n;const r=(nu(t)?[t]:su(t)).reduce((e,t)=>Kl(e)?e:e[t],e);return ru(r)||r===e?ru(e[t])?n:e[t]:r},au=e=>"boolean"==typeof e,lu=e=>"function"==typeof e,uu=(e,t,n)=>{let r=-1;const i=nu(t)?[t]:su(t),s=i.length,o=s-1;for(;++r<s;){const t=i[r];let s=n;if(r!==o){const n=e[t];s=Yl(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=s,e=e[t]}};const cu="blur",hu="focusout",du="change",fu="onBlur",pu="onChange",gu="onSubmit",mu="onTouched",_u="all",yu="max",vu="min",bu="maxLength",xu="minLength",wu="pattern",Au="required",Eu="validate",Su=t.createContext(null);Su.displayName="HookFormContext";const Tu=()=>t.useContext(Su),ku=e=>{const{children:n,...r}=e;return t.createElement(Su.Provider,{value:r},n)};var Ou=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const i=s;return t._proxyFormState[i]!==_u&&(t._proxyFormState[i]=!r||_u),n&&(n[i]=!0),e[i]}});return i};const Ru="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;var Cu=e=>"string"==typeof e,Pu=(e,t,n,r,i)=>Cu(e)?(r&&t.watch.add(e),ou(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),ou(n,e))):(r&&(t.watchAll=!0),n),Mu=e=>Kl(e)||!Xl(e);function Nu(e,t,n=new WeakSet){if(Mu(e)||Mu(t))return Object.is(e,t);if(Zl(e)&&Zl(t))return e.getTime()===t.getTime();const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const s of r){const r=e[s];if(!i.includes(s))return!1;if("ref"!==s){const e=t[s];if(Zl(r)&&Zl(e)||Yl(r)&&Yl(e)||Array.isArray(r)&&Array.isArray(e)?!Nu(r,e,n):!Object.is(r,e))return!1}}return!0}function Iu(e){const n=Tu(),{name:r,disabled:i,control:s=n.control,shouldUnregister:o,defaultValue:a,exact:l=!0}=e,u=Jl(s._names.array,r),c=t.useMemo(()=>ou(s._formValues,r,ou(s._defaultValues,r,a)),[s,r,a]),h=function(e){const n=Tu(),{control:r=n.control,name:i,defaultValue:s,disabled:o,exact:a,compute:l}=e||{},u=t.useRef(s),c=t.useRef(l),h=t.useRef(void 0),d=t.useRef(r),f=t.useRef(i);c.current=l;const[p,g]=t.useState(()=>{const e=r._getWatch(i,u.current);return c.current?c.current(e):e}),m=t.useCallback(e=>{const t=Pu(i,r._names,e||r._formValues,!1,u.current);return c.current?c.current(t):t},[r._formValues,r._names,i]),_=t.useCallback(e=>{if(!o){const t=Pu(i,r._names,e||r._formValues,!1,u.current);if(c.current){const e=c.current(t);Nu(e,h.current)||(g(e),h.current=e)}else g(t)}},[r._formValues,r._names,o,i]);Ru(()=>(d.current===r&&Nu(f.current,i)||(d.current=r,f.current=i,_()),r._subscribe({name:i,formState:{values:!0},exact:a,callback:e=>{_(e.values)}})),[r,a,i,_]),t.useEffect(()=>r._removeUnmounted());const y=d.current!==r,v=f.current,b=t.useMemo(()=>{if(o)return null;const e=!y&&!Nu(v,i);return y||e?m():null},[o,y,i,v,m]);return null!==b?b:p}({control:s,name:r,defaultValue:c,exact:l}),d=function(e){const n=Tu(),{control:r=n.control,disabled:i,name:s,exact:o}=e||{},[a,l]=t.useState(r._formState),u=t.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ru(()=>r._subscribe({name:s,formState:u.current,exact:o,callback:e=>{!i&&l({...r._formState,...e})}}),[s,i,o]),t.useEffect(()=>{u.current.isValid&&r._setValid(!0)},[r]),t.useMemo(()=>Ou(a,r,u.current,!1),[a,r])}({control:s,name:r,exact:l}),f=t.useRef(e),p=t.useRef(void 0),g=t.useRef(s.register(r,{...e.rules,value:h,...au(e.disabled)?{disabled:e.disabled}:{}}));f.current=e;const m=t.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ou(d.errors,r)},isDirty:{enumerable:!0,get:()=>!!ou(d.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!ou(d.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!ou(d.validatingFields,r)},error:{enumerable:!0,get:()=>ou(d.errors,r)}}),[d,r]),_=t.useCallback(e=>g.current.onChange({target:{value:Ql(e),name:r},type:du}),[r]),y=t.useCallback(()=>g.current.onBlur({target:{value:ou(s._formValues,r),name:r},type:cu}),[r,s._formValues]),v=t.useCallback(e=>{const t=ou(s._fields,r);t&&t._f&&e&&(t._f.ref={focus:()=>lu(e.focus)&&e.focus(),select:()=>lu(e.select)&&e.select(),setCustomValidity:t=>lu(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>lu(e.reportValidity)&&e.reportValidity()})},[s._fields,r]),b=t.useMemo(()=>({name:r,value:h,...au(i)||d.disabled?{disabled:d.disabled||i}:{},onChange:_,onBlur:y,ref:v}),[r,i,d.disabled,_,y,v,h]);return t.useEffect(()=>{const e=s._options.shouldUnregister||o,t=p.current;t&&t!==r&&!u&&s.unregister(t),s.register(r,{...f.current.rules,...au(f.current.disabled)?{disabled:f.current.disabled}:{}});const n=(e,t)=>{const n=ou(s._fields,e);n&&n._f&&(n._f.mount=t)};if(n(r,!0),e){const e=tu(ou(s._options.defaultValues,r,f.current.defaultValue));uu(s._defaultValues,r,e),ru(ou(s._formValues,r))&&uu(s._formValues,r,e)}return!u&&s.register(r),p.current=r,()=>{(u?e&&!s._state.action:e)?s.unregister(r):n(r,!1)}},[r,s,u,o]),t.useEffect(()=>{s._setDisabledField({disabled:i,name:r})},[i,r,s]),t.useMemo(()=>({field:b,formState:d,fieldState:m}),[b,d,m])}const Du=e=>e.render(Iu(e));var Fu=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},zu=e=>Array.isArray(e)?e:[e],Lu=()=>{let e=[];return{get observers(){return e},next:t=>{for(const n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function ju(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const i=e[r],s=t[r];if(i&&Yl(i)&&s){const e=ju(i,s);Yl(e)&&(n[r]=e)}else e[r]&&(n[r]=s)}return n}var Vu=e=>Yl(e)&&!Object.keys(e).length,Uu=e=>"file"===e.type,Bu=e=>{if(!eu)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Gu=e=>"select-multiple"===e.type,$u=e=>"radio"===e.type,qu=e=>Bu(e)&&e.isConnected;function Hu(e,t){const n=Array.isArray(t)?t:nu(t)?[t]:su(t),r=1===n.length?e:function(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ru(e)?r++:e[t[r++]];return e}(e,n),i=n.length-1,s=n[i];return r&&delete r[s],0!==i&&(Yl(r)&&Vu(r)||Array.isArray(r)&&function(e){for(const t in e)if(e.hasOwnProperty(t)&&!ru(e[t]))return!1;return!0}(r))&&Hu(e,n.slice(0,-1)),e}function Wu(e){return Array.isArray(e)||Yl(e)&&!(e=>{for(const t in e)if(lu(e[t]))return!0;return!1})(e)}function Zu(e,t={}){for(const n in e){const r=e[n];Wu(r)?(t[n]=Array.isArray(r)?[]:{},Zu(r,t[n])):ru(r)||(t[n]=!0)}return t}function Ku(e,t,n){n||(n=Zu(t));for(const r in e){const i=e[r];if(Wu(i))ru(t)||Mu(n[r])?n[r]=Zu(i,Array.isArray(i)?[]:{}):Ku(i,Kl(t)?{}:t[r],n[r]);else{const e=t[r];n[r]=!Nu(i,e)}}return n}const Xu={value:!1,isValid:!1},Yu={value:!0,isValid:!0};var Qu=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ru(e[0].attributes.value)?ru(e[0].value)||""===e[0].value?Yu:{value:e[0].value,isValid:!0}:Yu:Xu}return Xu},Ju=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ru(e)?e:t?""===e?NaN:e?+e:e:n&&Cu(e)?new Date(e):r?r(e):e;const ec={isValid:!1,value:null};var tc=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,ec):ec;function nc(e){const t=e.ref;return Uu(t)?t.files:$u(t)?tc(e.refs).value:Gu(t)?[...t.selectedOptions].map(({value:e})=>e):Wl(t)?Qu(e.refs).value:Ju(ru(t.value)?e.ref.value:t.value,e)}var rc=e=>e instanceof RegExp,ic=e=>ru(e)?e:rc(e)?e.source:Yl(e)?rc(e.value)?e.value.source:e.value:e,sc=e=>({isOnSubmit:!e||e===gu,isOnBlur:e===fu,isOnChange:e===pu,isOnAll:e===_u,isOnTouch:e===mu});const oc="AsyncFunction";var ac=e=>!!e&&!!e.validate&&!!(lu(e.validate)&&e.validate.constructor.name===oc||Yl(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===oc)),lc=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))));const uc=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const n=ou(e,i);if(n){const{_f:e,...s}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r)return!0;if(e.ref&&t(e.ref,e.name)&&!r)return!0;if(uc(s,t))break}else if(Yl(s)&&uc(s,t))break}}};function cc(e,t,n){const r=ou(e,n);if(r||nu(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const r=i.join("."),s=ou(t,r),o=ou(e,r);if(s&&!Array.isArray(s)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};if(o&&o.root&&o.root.type)return{name:`${r}.root`,error:o.root};i.pop()}return{name:n}}var hc=(e,t,n)=>{const r=zu(ou(e,n));return uu(r,"root",t[n]),uu(e,n,r),e};function dc(e,t,n="validate"){if(Cu(e)||Array.isArray(e)&&e.every(Cu)||au(e)&&!e)return{type:n,message:Cu(e)?e:"",ref:t}}var fc=e=>Yl(e)&&!rc(e)?e:{value:e,message:""},pc=async(e,t,n,r,i,s)=>{const{ref:o,refs:a,required:l,maxLength:u,minLength:c,min:h,max:d,pattern:f,validate:p,name:g,valueAsNumber:m,mount:_}=e._f,y=ou(n,g);if(!_||t.has(g))return{};const v=a?a[0]:o,b=e=>{i&&v.reportValidity&&(v.setCustomValidity(au(e)?"":e||""),v.reportValidity())},x={},w=$u(o),A=Wl(o),E=w||A,S=(m||Uu(o))&&ru(o.value)&&ru(y)||Bu(o)&&""===o.value||""===y||Array.isArray(y)&&!y.length,T=Fu.bind(null,g,r,x),k=(e,t,n,r=bu,i=xu)=>{const s=e?t:n;x[g]={type:e?r:i,message:s,ref:o,...T(e?r:i,s)}};if(s?!Array.isArray(y)||!y.length:l&&(!E&&(S||Kl(y))||au(y)&&!y||A&&!Qu(a).isValid||w&&!tc(a).isValid)){const{value:e,message:t}=Cu(l)?{value:!!l,message:l}:fc(l);if(e&&(x[g]={type:Au,message:t,ref:v,...T(Au,t)},!r))return b(t),x}if(!(S||Kl(h)&&Kl(d))){let e,t;const n=fc(d),i=fc(h);if(Kl(y)||isNaN(y)){const r=o.valueAsDate||new Date(y),s=e=>new Date((new Date).toDateString()+" "+e),a="time"==o.type,l="week"==o.type;Cu(n.value)&&y&&(e=a?s(y)>s(n.value):l?y>n.value:r>new Date(n.value)),Cu(i.value)&&y&&(t=a?s(y)<s(i.value):l?y<i.value:r<new Date(i.value))}else{const r=o.valueAsNumber||(y?+y:y);Kl(n.value)||(e=r>n.value),Kl(i.value)||(t=r<i.value)}if((e||t)&&(k(!!e,n.message,i.message,yu,vu),!r))return b(x[g].message),x}if((u||c)&&!S&&(Cu(y)||s&&Array.isArray(y))){const e=fc(u),t=fc(c),n=!Kl(e.value)&&y.length>+e.value,i=!Kl(t.value)&&y.length<+t.value;if((n||i)&&(k(n,e.message,t.message),!r))return b(x[g].message),x}if(f&&!S&&Cu(y)){const{value:e,message:t}=fc(f);if(rc(e)&&!y.match(e)&&(x[g]={type:wu,message:t,ref:o,...T(wu,t)},!r))return b(t),x}if(p)if(lu(p)){const e=dc(await p(y,n),v);if(e&&(x[g]={...e,...T(Eu,e.message)},!r))return b(e.message),x}else if(Yl(p)){let e={};for(const t in p){if(!Vu(e)&&!r)break;const i=dc(await p[t](y,n),v,t);i&&(e={...i,...T(t,i.message)},b(i.message),r&&(x[g]=e))}if(!Vu(e)&&(x[g]={ref:v,...e},!r))return x}return b(!0),x};const gc={mode:gu,reValidateMode:pu,shouldFocusError:!0};function mc(e={}){let t,n={...gc,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:lu(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},s=(Yl(n.defaultValues)||Yl(n.values))&&tu(n.defaultValues||n.values)||{},o=n.shouldUnregister?{}:tu(s),a={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0;const c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...c};let d={...h};const f={array:Lu(),state:Lu()},p=n.criteriaMode===_u,g=async e=>{if(!a.keepIsValid&&!n.disabled&&(h.isValid||d.isValid||e)){let e;n.resolver?(e=Vu((await b()).errors),m()):e=await x(i,!0),e!==r.isValid&&f.state.next({isValid:e})}},m=(e,t)=>{!n.disabled&&(h.isValidating||h.validatingFields||d.isValidating||d.validatingFields)&&((e||Array.from(l.mount)).forEach(e=>{e&&(t?uu(r.validatingFields,e,t):Hu(r.validatingFields,e))}),f.state.next({validatingFields:r.validatingFields,isValidating:!Vu(r.validatingFields)}))},_=(e,t,n,r)=>{const l=ou(i,e);if(l){const i=ou(o,e,ru(n)?ou(s,e):n);ru(i)||r&&r.defaultChecked||t?uu(o,e,t?i:nc(l._f)):E(e,i),a.mount&&!a.action&&g()}},y=(e,t,i,o,a)=>{let l=!1,u=!1;const c={name:e};if(!n.disabled){if(!i||o){(h.isDirty||d.isDirty)&&(u=r.isDirty,r.isDirty=c.isDirty=w(),l=u!==c.isDirty);const n=Nu(ou(s,e),t);u=!!ou(r.dirtyFields,e),n?Hu(r.dirtyFields,e):uu(r.dirtyFields,e,!0),c.dirtyFields=r.dirtyFields,l=l||(h.dirtyFields||d.dirtyFields)&&u!==!n}if(i){const t=ou(r.touchedFields,e);t||(uu(r.touchedFields,e,i),c.touchedFields=r.touchedFields,l=l||(h.touchedFields||d.touchedFields)&&t!==i)}l&&a&&f.state.next(c)}return l?c:{}},v=(e,i,s,o)=>{const a=ou(r.errors,e),l=(h.isValid||d.isValid)&&au(i)&&r.isValid!==i;var c;if(n.delayError&&s?(c=()=>((e,t)=>{uu(r.errors,e,t),f.state.next({errors:r.errors})})(e,s),t=e=>{clearTimeout(u),u=setTimeout(c,e)},t(n.delayError)):(clearTimeout(u),t=null,s?uu(r.errors,e,s):Hu(r.errors,e)),(s?!Nu(a,s):a)||!Vu(o)||l){const t={...o,...l&&au(i)?{isValid:i}:{},errors:r.errors,name:e};r={...r,...t},f.state.next(t)}},b=async e=>{m(e,!0);const t=await n.resolver(o,n.context,((e,t,n,r)=>{const i={};for(const n of e){const e=ou(t,n);e&&uu(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}})(e||l.mount,i,n.criteriaMode,n.shouldUseNativeValidation));return t},x=async(e,t,i={valid:!0})=>{for(const s in e){const a=e[s];if(a){const{_f:e,...s}=a;if(e){const s=l.array.has(e.name),u=a._f&&ac(a._f);u&&h.validatingFields&&m([e.name],!0);const c=await pc(a,l.disabled,o,p,n.shouldUseNativeValidation&&!t,s);if(u&&h.validatingFields&&m([e.name]),c[e.name]&&(i.valid=!1,t))break;!t&&(ou(c,e.name)?s?hc(r.errors,c,e.name):uu(r.errors,e.name,c[e.name]):Hu(r.errors,e.name))}!Vu(s)&&await x(s,t,i)}}return i.valid},w=(e,t)=>!n.disabled&&(e&&t&&uu(o,e,t),!Nu(C(),s)),A=(e,t,n)=>Pu(e,l,{...a.mount?o:ru(t)?s:Cu(e)?{[e]:t}:t},n,t),E=(e,t,n={})=>{const r=ou(i,e);let s=t;if(r){const n=r._f;n&&(!n.disabled&&uu(o,e,Ju(t,n)),s=Bu(n.ref)&&Kl(t)?"":t,Gu(n.ref)?[...n.ref.options].forEach(e=>e.selected=s.includes(e.value)):n.refs?Wl(n.ref)?n.refs.forEach(e=>{e.defaultChecked&&e.disabled||(Array.isArray(s)?e.checked=!!s.find(t=>t===e.value):e.checked=s===e.value||!!s)}):n.refs.forEach(e=>e.checked=e.value===s):Uu(n.ref)?n.ref.value="":(n.ref.value=s,n.ref.type||f.state.next({name:e,values:tu(o)})))}(n.shouldDirty||n.shouldTouch)&&y(e,s,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&R(e)},S=(e,t,n)=>{for(const r in t){if(!t.hasOwnProperty(r))return;const s=t[r],o=e+"."+r,a=ou(i,o);(l.array.has(e)||Yl(s)||a&&!a._f)&&!Zl(s)?S(o,s,n):E(o,s,n)}},T=(e,t,n={})=>{const u=ou(i,e),c=l.array.has(e),p=tu(t);uu(o,e,p),c?(f.array.next({name:e,values:tu(o)}),(h.isDirty||h.dirtyFields||d.isDirty||d.dirtyFields)&&n.shouldDirty&&f.state.next({name:e,dirtyFields:Ku(s,o),isDirty:w(e,p)})):!u||u._f||Kl(p)?E(e,p,n):S(e,p,n),lc(e,l)&&f.state.next({...r,name:e}),f.state.next({name:a.mount?e:void 0,values:tu(o)})},k=async e=>{a.mount=!0;const s=e.target;let u=s.name,c=!0;const _=ou(i,u),w=e=>{c=Number.isNaN(e)||Zl(e)&&isNaN(e.getTime())||Nu(e,ou(o,u,e))},A=sc(n.mode),E=sc(n.reValidateMode);if(_){let a,T;const k=s.type?nc(_._f):Ql(e),O=e.type===cu||e.type===hu,C=!((S=_._f).mount&&(S.required||S.min||S.max||S.maxLength||S.minLength||S.pattern||S.validate)||n.resolver||ou(r.errors,u)||_._f.deps)||((e,t,n,r,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:!(n?r.isOnChange:i.isOnChange)||e))(O,ou(r.touchedFields,u),r.isSubmitted,E,A),P=lc(u,l,O);uu(o,u,k),O?s&&s.readOnly||(_._f.onBlur&&_._f.onBlur(e),t&&t(0)):_._f.onChange&&_._f.onChange(e);const M=y(u,k,O),N=!Vu(M)||P;if(!O&&f.state.next({name:u,type:e.type,values:tu(o)}),C)return(h.isValid||d.isValid)&&("onBlur"===n.mode?O&&g():O||g()),N&&f.state.next({name:u,...P?{}:M});if(!O&&P&&f.state.next({...r}),n.resolver){const{errors:e}=await b([u]);if(m([u]),w(k),c){const t=cc(r.errors,i,u),n=cc(e,i,t.name||u);a=n.error,u=n.name,T=Vu(e)}}else m([u],!0),a=(await pc(_,l.disabled,o,p,n.shouldUseNativeValidation))[u],m([u]),w(k),c&&(a?T=!1:(h.isValid||d.isValid)&&(T=await x(i,!0)));c&&(_._f.deps&&(!Array.isArray(_._f.deps)||_._f.deps.length>0)&&R(_._f.deps),v(u,T,a,M))}var S},O=(e,t)=>{if(ou(r.errors,t)&&e.focus)return e.focus(),1},R=async(e,t={})=>{let s,o;const a=zu(e);if(n.resolver){const t=await(async e=>{const{errors:t}=await b(e);if(m(e),e)for(const n of e){const e=ou(t,n);e?uu(r.errors,n,e):Hu(r.errors,n)}else r.errors=t;return t})(ru(e)?e:a);s=Vu(t),o=e?!a.some(e=>ou(t,e)):s}else e?(o=(await Promise.all(a.map(async e=>{const t=ou(i,e);return await x(t&&t._f?{[e]:t}:t)}))).every(Boolean),(o||r.isValid)&&g()):o=s=await x(i);return f.state.next({...!Cu(e)||(h.isValid||d.isValid)&&s!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:s}:{},errors:r.errors}),t.shouldFocus&&!o&&uc(i,O,e?a:l.mount),o},C=(e,t)=>{let n={...a.mount?o:s};return t&&(n=ju(t.dirtyFields?r.dirtyFields:r.touchedFields,n)),ru(e)?n:Cu(e)?ou(n,e):e.map(e=>ou(n,e))},P=(e,t)=>({invalid:!!ou((t||r).errors,e),isDirty:!!ou((t||r).dirtyFields,e),error:ou((t||r).errors,e),isValidating:!!ou(r.validatingFields,e),isTouched:!!ou((t||r).touchedFields,e)}),M=(e,t,n)=>{const s=(ou(i,e,{_f:{}})._f||{}).ref,o=ou(r.errors,e)||{},{ref:a,message:l,type:u,...c}=o;uu(r.errors,e,{...c,...t,ref:s}),f.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&s&&s.focus&&s.focus()},N=e=>f.state.subscribe({next:t=>{var n,i,a;n=e.name,i=t.name,a=e.exact,n&&i&&n!==i&&!zu(n).some(e=>e&&(a?e===i:e.startsWith(i)||i.startsWith(e)))||!((e,t,n,r)=>{n(e);const{name:i,...s}=e;return Vu(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(e=>t[e]===(!r||_u))})(t,e.formState||h,U,e.reRenderRoot)||e.callback({values:{...o},...r,...t,defaultValues:s})}}).unsubscribe,I=(e,t={})=>{for(const a of e?zu(e):l.mount)l.mount.delete(a),l.array.delete(a),t.keepValue||(Hu(i,a),Hu(o,a)),!t.keepError&&Hu(r.errors,a),!t.keepDirty&&Hu(r.dirtyFields,a),!t.keepTouched&&Hu(r.touchedFields,a),!t.keepIsValidating&&Hu(r.validatingFields,a),!n.shouldUnregister&&!t.keepDefaultValue&&Hu(s,a);f.state.next({values:tu(o)}),f.state.next({...r,...t.keepDirty?{isDirty:w()}:{}}),!t.keepIsValid&&g()},D=({disabled:e,name:t})=>{(au(e)&&a.mount||e||l.disabled.has(t))&&(e?l.disabled.add(t):l.disabled.delete(t))},F=(e,t={})=>{let r=ou(i,e);const o=au(t.disabled)||au(n.disabled);return uu(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),l.mount.add(e),r?D({disabled:au(t.disabled)?t.disabled:n.disabled,name:e}):_(e,!0,t.value),{...o?{disabled:t.disabled||n.disabled}:{},...n.progressive?{required:!!t.required,min:ic(t.min),max:ic(t.max),minLength:ic(t.minLength),maxLength:ic(t.maxLength),pattern:ic(t.pattern)}:{},name:e,onChange:k,onBlur:k,ref:o=>{if(o){F(e,t),r=ou(i,e);const n=ru(o.value)&&o.querySelectorAll&&o.querySelectorAll("input,select,textarea")[0]||o,a=(e=>$u(e)||Wl(e))(n),l=r._f.refs||[];if(a?l.find(e=>e===n):n===r._f.ref)return;uu(i,e,{_f:{...r._f,...a?{refs:[...l.filter(qu),n,...Array.isArray(ou(s,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),_(e,!1,void 0,n)}else r=ou(i,e,{}),r._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&(!Jl(l.array,e)||!a.action)&&l.unMount.add(e)}}},z=()=>n.shouldFocusError&&uc(i,O,l.mount),L=(e,t)=>async s=>{let a;s&&(s.preventDefault&&s.preventDefault(),s.persist&&s.persist());let u=tu(o);if(f.state.next({isSubmitting:!0}),n.resolver){const{errors:e,values:t}=await b();m(),r.errors=e,u=tu(t)}else await x(i);if(l.disabled.size)for(const e of l.disabled)Hu(u,e);if(Hu(r.errors,"root"),Vu(r.errors)){f.state.next({errors:{}});try{await e(u,s)}catch(e){a=e}}else t&&await t({...r.errors},s),z(),setTimeout(z);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Vu(r.errors)&&!a,submitCount:r.submitCount+1,errors:r.errors}),a)throw a},j=(e,t={})=>{const u=e?tu(e):s,c=tu(u),d=Vu(e),p=d?s:c;if(t.keepDefaultValues||(s=u),!t.keepValues){if(t.keepDirtyValues){const e=new Set([...l.mount,...Object.keys(Ku(s,o))]);for(const t of Array.from(e))ou(r.dirtyFields,t)?uu(p,t,ou(o,t)):T(t,ou(p,t))}else{if(eu&&ru(e))for(const e of l.mount){const t=ou(i,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(Bu(e)){const t=e.closest("form");if(t){t.reset();break}}}}if(t.keepFieldsRef)for(const e of l.mount)T(e,ou(p,e));else i={}}o=n.shouldUnregister?t.keepDefaultValues?tu(s):{}:tu(p),f.array.next({values:{...p}}),f.state.next({values:{...p}})}l={mount:t.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!h.isValid||!!t.keepIsValid||!!t.keepDirtyValues||!n.shouldUnregister&&!Vu(p),a.watch=!!n.shouldUnregister,a.keepIsValid=!!t.keepIsValid,a.action=!1,t.keepErrors||(r.errors={}),f.state.next({submitCount:t.keepSubmitCount?r.submitCount:0,isDirty:!d&&(t.keepDirty?r.isDirty:!(!t.keepDefaultValues||Nu(e,s))),isSubmitted:!!t.keepIsSubmitted&&r.isSubmitted,dirtyFields:d?{}:t.keepDirtyValues?t.keepDefaultValues&&o?Ku(s,o):r.dirtyFields:t.keepDefaultValues&&e?Ku(s,e):t.keepDirty?r.dirtyFields:{},touchedFields:t.keepTouched?r.touchedFields:{},errors:t.keepErrors?r.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1,defaultValues:s})},V=(e,t)=>j(lu(e)?e(o):e,{...n.resetOptions,...t}),U=e=>{r={...r,...e}},B={control:{register:F,unregister:I,getFieldState:P,handleSubmit:L,setError:M,_subscribe:N,_runSchema:b,_updateIsValidating:m,_focusError:z,_getWatch:A,_getDirty:w,_setValid:g,_setFieldArray:(e,t=[],l,u,c=!0,p=!0)=>{if(u&&l&&!n.disabled){if(a.action=!0,p&&Array.isArray(ou(i,e))){const t=l(ou(i,e),u.argA,u.argB);c&&uu(i,e,t)}if(p&&Array.isArray(ou(r.errors,e))){const t=l(ou(r.errors,e),u.argA,u.argB);c&&uu(r.errors,e,t),((e,t)=>{!iu(ou(e,t)).length&&Hu(e,t)})(r.errors,e)}if((h.touchedFields||d.touchedFields)&&p&&Array.isArray(ou(r.touchedFields,e))){const t=l(ou(r.touchedFields,e),u.argA,u.argB);c&&uu(r.touchedFields,e,t)}(h.dirtyFields||d.dirtyFields)&&(r.dirtyFields=Ku(s,o)),f.state.next({name:e,isDirty:w(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else uu(o,e,t)},_setDisabledField:D,_setErrors:e=>{r.errors=e,f.state.next({errors:r.errors,isValid:!1})},_getFieldArray:e=>iu(ou(a.mount?o:s,e,n.shouldUnregister?ou(s,e,[]):[])),_reset:j,_resetDefaultValues:()=>lu(n.defaultValues)&&n.defaultValues().then(e=>{V(e,n.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:()=>{for(const e of l.unMount){const t=ou(i,e);t&&(t._f.refs?t._f.refs.every(e=>!qu(e)):!qu(t._f.ref))&&I(e)}l.unMount=new Set},_disableForm:e=>{au(e)&&(f.state.next({disabled:e}),uc(i,(t,n)=>{const r=ou(i,n);r&&(t.disabled=r._f.disabled||e,Array.isArray(r._f.refs)&&r._f.refs.forEach(t=>{t.disabled=r._f.disabled||e}))},0,!1))},_subjects:f,_proxyFormState:h,get _fields(){return i},get _formValues(){return o},get _state(){return a},set _state(e){a=e},get _defaultValues(){return s},get _names(){return l},set _names(e){l=e},get _formState(){return r},get _options(){return n},set _options(e){n={...n,...e}}},subscribe:e=>(a.mount=!0,d={...d,...e.formState},N({...e,formState:{...c,...e.formState}})),trigger:R,register:F,handleSubmit:L,watch:(e,t)=>lu(e)?f.state.subscribe({next:n=>"values"in n&&e(A(void 0,t),n)}):A(e,t,!0),setValue:T,getValues:C,reset:V,resetField:(e,t={})=>{ou(i,e)&&(ru(t.defaultValue)?T(e,tu(ou(s,e))):(T(e,t.defaultValue),uu(s,e,tu(t.defaultValue))),t.keepTouched||Hu(r.touchedFields,e),t.keepDirty||(Hu(r.dirtyFields,e),r.isDirty=t.defaultValue?w(e,tu(ou(s,e))):w()),t.keepError||(Hu(r.errors,e),h.isValid&&g()),f.state.next({...r}))},clearErrors:e=>{e&&zu(e).forEach(e=>Hu(r.errors,e)),f.state.next({errors:e?r.errors:{}})},unregister:I,setError:M,setFocus:(e,t={})=>{const n=ou(i,e),r=n&&n._f;if(r){const e=r.refs?r.refs[0]:r.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&lu(e.select)&&e.select()})}},getFieldState:P};return{...B,formControl:B}}var _c=()=>{if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=(16*Math.random()+e)%16|0;return("x"==t?n:3&n|8).toString(16)})},yc=(e,t,n={})=>n.shouldFocus||ru(n.shouldFocus)?n.focusName||`${e}.${ru(n.focusIndex)?t:n.focusIndex}.`:"",vc=(e,t)=>[...e,...zu(t)],bc=e=>Array.isArray(e)?e.map(()=>{}):void 0;function xc(e,t,n){return[...e.slice(0,t),...zu(n),...e.slice(t)]}var wc=(e,t,n)=>Array.isArray(e)?(ru(e[n])&&(e[n]=void 0),e.splice(n,0,e.splice(t,1)[0]),e):[],Ac=(e,t)=>[...zu(t),...zu(e)];var Ec=(e,t)=>ru(t)?[]:function(e,t){let n=0;const r=[...e];for(const e of t)r.splice(e-n,1),n++;return iu(r).length?r:[]}(e,zu(t).sort((e,t)=>e-t)),Sc=(e,t,n)=>{[e[t],e[n]]=[e[n],e[t]]},Tc=(e,t,n)=>(e[t]=n,e);function kc(e){const n=Tu(),{control:r=n.control,name:i,keyName:s="id",shouldUnregister:o,rules:a}=e,[l,u]=t.useState(r._getFieldArray(i)),c=t.useRef(r._getFieldArray(i).map(_c)),h=t.useRef(!1);r._names.array.add(i),t.useMemo(()=>a&&l.length>=0&&r.register(i,a),[r,i,l.length,a]),Ru(()=>r._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===i||!t){const t=ou(e,i);Array.isArray(t)&&(u(t),c.current=t.map(_c))}}}).unsubscribe,[r,i]);const d=t.useCallback(e=>{h.current=!0,r._setFieldArray(i,e)},[r,i]);return t.useEffect(()=>{if(r._state.action=!1,lc(i,r._names)&&r._subjects.state.next({...r._formState}),h.current&&(!sc(r._options.mode).isOnSubmit||r._formState.isSubmitted)&&!sc(r._options.reValidateMode).isOnSubmit)if(r._options.resolver)r._runSchema([i]).then(e=>{r._updateIsValidating([i]);const t=ou(e.errors,i),n=ou(r._formState.errors,i);(n?!t&&n.type||t&&(n.type!==t.type||n.message!==t.message):t&&t.type)&&(t?uu(r._formState.errors,i,t):Hu(r._formState.errors,i),r._subjects.state.next({errors:r._formState.errors}))});else{const e=ou(r._fields,i);!e||!e._f||sc(r._options.reValidateMode).isOnSubmit&&sc(r._options.mode).isOnSubmit||pc(e,r._names.disabled,r._formValues,r._options.criteriaMode===_u,r._options.shouldUseNativeValidation,!0).then(e=>!Vu(e)&&r._subjects.state.next({errors:hc(r._formState.errors,e,i)}))}r._subjects.state.next({name:i,values:tu(r._formValues)}),r._names.focus&&uc(r._fields,(e,t)=>{if(r._names.focus&&t.startsWith(r._names.focus)&&e.focus)return e.focus(),1}),r._names.focus="",r._setValid(),h.current=!1},[l,i,r]),t.useEffect(()=>(!ou(r._formValues,i)&&r._setFieldArray(i),()=>{r._options.shouldUnregister||o?r.unregister(i):((e,t)=>{const n=ou(r._fields,e);n&&n._f&&(n._f.mount=t)})(i,!1)}),[i,r,s,o]),{swap:t.useCallback((e,t)=>{const n=r._getFieldArray(i);Sc(n,e,t),Sc(c.current,e,t),d(n),u(n),r._setFieldArray(i,n,Sc,{argA:e,argB:t},!1)},[d,i,r]),move:t.useCallback((e,t)=>{const n=r._getFieldArray(i);wc(n,e,t),wc(c.current,e,t),d(n),u(n),r._setFieldArray(i,n,wc,{argA:e,argB:t},!1)},[d,i,r]),prepend:t.useCallback((e,t)=>{const n=zu(tu(e)),s=Ac(r._getFieldArray(i),n);r._names.focus=yc(i,0,t),c.current=Ac(c.current,n.map(_c)),d(s),u(s),r._setFieldArray(i,s,Ac,{argA:bc(e)})},[d,i,r]),append:t.useCallback((e,t)=>{const n=zu(tu(e)),s=vc(r._getFieldArray(i),n);r._names.focus=yc(i,s.length-1,t),c.current=vc(c.current,n.map(_c)),d(s),u(s),r._setFieldArray(i,s,vc,{argA:bc(e)})},[d,i,r]),remove:t.useCallback(e=>{const t=Ec(r._getFieldArray(i),e);c.current=Ec(c.current,e),d(t),u(t),!Array.isArray(ou(r._fields,i))&&uu(r._fields,i,void 0),r._setFieldArray(i,t,Ec,{argA:e})},[d,i,r]),insert:t.useCallback((e,t,n)=>{const s=zu(tu(t)),o=xc(r._getFieldArray(i),e,s);r._names.focus=yc(i,e,n),c.current=xc(c.current,e,s.map(_c)),d(o),u(o),r._setFieldArray(i,o,xc,{argA:e,argB:bc(t)})},[d,i,r]),update:t.useCallback((e,t)=>{const n=tu(t),s=Tc(r._getFieldArray(i),e,n);c.current=[...s].map((t,n)=>t&&n!==e?c.current[n]:_c()),d(s),u([...s]),r._setFieldArray(i,s,Tc,{argA:e,argB:n},!0,!1)},[d,i,r]),replace:t.useCallback(e=>{const t=zu(tu(e));c.current=t.map(_c),d([...t]),u([...t]),r._setFieldArray(i,[...t],e=>e,{},!0,!1)},[d,i,r]),fields:t.useMemo(()=>l.map((e,t)=>({...e,[s]:c.current[t]||_c()})),[l,s])}}function Oc(e={}){const n=t.useRef(void 0),r=t.useRef(void 0),[i,s]=t.useState({isDirty:!1,isValidating:!1,isLoading:lu(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:lu(e.defaultValues)?void 0:e.defaultValues});if(!n.current)if(e.formControl)n.current={...e.formControl,formState:i},e.defaultValues&&!lu(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:t,...r}=mc(e);n.current={...r,formState:i}}const o=n.current.control;return o._options=e,Ru(()=>{const e=o._subscribe({formState:o._proxyFormState,callback:()=>s({...o._formState}),reRenderRoot:!0});return s(e=>({...e,isReady:!0})),o._formState.isReady=!0,e},[o]),t.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),t.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),t.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),t.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),t.useEffect(()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==i.isDirty&&o._subjects.state.next({isDirty:e})}},[o,i.isDirty]),t.useEffect(()=>{var t;e.values&&!Nu(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),(null===(t=o._options.resetOptions)||void 0===t?void 0:t.keepIsValid)||o._setValid(),r.current=e.values,s(e=>({...e}))):o._resetDefaultValues()},[o,e.values]),t.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),n.current.formState=Ou(i,o),n.current}const Rc=({sx:e,...t})=>b(se,{variant:"body1",sx:{color:"var(--color-white)",cursor:"default",...e},...t}),Cc=ne(ee)({padding:0,marginRight:"5px",marginLeft:"10px","& .MuiSvgIcon-root":{color:"var(--color-orange-medium)"}});function Pc({label:t,name:n,...r}){const i=e.useId(),{control:s,setValue:o,watch:a}=Tu(),l=a(n),u=`${i}-${n}-${String(l)}`;return b(Du,{control:s,name:n,render:({field:e})=>{const{value:n,name:i}=e;return t?b(te,{color:"white",control:b(Cc,{...r,checked:n,onChange:(e,t)=>{o(i,t,{shouldValidate:!0})}}),label:b(Rc,{children:t})}):b(Cc,{...r,checked:n,onChange:(e,t)=>{o(i,t,{shouldValidate:!0})}})}},u)}var Mc=function(t){var n=t.as,r=t.errors,i=t.name,s=t.message,o=t.render,a=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)t.indexOf(n=s[r])>=0||(i[n]=e[n]);return i}(t,["as","errors","name","message","render"]),l=Tu(),u=ou(r||l.formState.errors,i);if(!u)return null;var c=u.message,h=u.types,d=Object.assign({},a,{children:c||s});return e.isValidElement(n)?e.cloneElement(n,d):o?o({message:c||s,messages:h}):e.createElement(n||e.Fragment,d)};function Nc({name:e}){const{palette:t}=V(),{formState:{errors:n}}=Tu();return b(Mc,{errors:n,name:e,render:({message:e})=>b(Rc,{variant:"body2",style:{color:t.error.main},children:e})})}function Ic({form:e,sx:t={},onSubmit:n,children:r}){const{handleSubmit:i}=e;return b(ku,{...e,children:b(T,{component:"form",sx:{display:"grid",gap:"15px",...t},onSubmit:i(n),children:r})})}const Dc=()=>Tu(),Fc=e=>b(U,{size:"small",...e});function zc({name:t,...n}){const{control:r}=Tu(),i=e.useId();return b(Du,{control:r,name:t,render:({field:e})=>x(T,{sx:({spacing:e})=>({display:"grid",width:"100%",gap:e(1)}),children:[b(oe,{...n,...e,id:i,slots:{field:Fc}}),b(Nc,{name:t})]})})}const Lc=({text:e="Нет данных"})=>b(B,{variant:"body2",sx:{textAlign:"center",color:"var(--gray-light-color)"},children:e});function jc({items:t,columnsCount:n=1,getContent:r,title:i,getKey:s,onClick:o,sx:a,isShowNoData:l=!0}){const u=0===t.length;return x(T,{sx:{display:"grid",gridTemplateColumns:"1fr",gap:"15px",...a?.root},children:[i?b(B,{variant:"h6",noWrap:!0,sx:{textAlign:"center",fontWeight:700,...a?.title},children:i}):null,u?b(e.Fragment,{children:l?b(Lc,{}):null}):b(G,{sx:{display:"grid",gridTemplateColumns:`repeat(${n}, 1fr)`,gap:"15px",...a?.list},disablePadding:!0,children:t.map((e,t)=>b($,{onClick:()=>o?.(e,t),sx:{...a?.item},disablePadding:!0,children:r(e,t)},s(e,t)))})]})}const Vc="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function Uc(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function Bc(e){return"nodeType"in e}function Gc(e){var t,n;return e?Uc(e)?e:Bc(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function $c(e){const{Document:t}=Gc(e);return e instanceof t}function qc(e){return!Uc(e)&&e instanceof Gc(e).HTMLElement}function Hc(e){return e instanceof Gc(e).SVGElement}function Wc(e){return e?Uc(e)?e.document:Bc(e)?$c(e)?e:qc(e)||Hc(e)?e.ownerDocument:document:document:document}const Zc=Vc?u:s;function Kc(e){const t=r(e);return Zc(()=>{t.current=e}),i(function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)},[])}function Xc(e,t){void 0===t&&(t=[e]);const n=r(e);return Zc(()=>{n.current!==e&&(n.current=e)},t),n}function Yc(e,t){const n=r();return l(()=>{const t=e(n.current);return n.current=t,t},[...t])}function Qc(e){const t=Kc(e),n=r(null),s=i(e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e},[]);return[n,s]}function Jc(e){const t=r();return s(()=>{t.current=e},[e]),t.current}let eh={};function th(e,t){return l(()=>{if(t)return t;const n=null==eh[e]?0:eh[e]+1;return eh[e]=n,e+"-"+n},[e,t])}function nh(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>{const r=Object.entries(n);for(const[n,i]of r){const r=t[n];null!=r&&(t[n]=r+e*i)}return t},{...t})}}const rh=nh(1),ih=nh(-1);function sh(e){if(!e)return!1;const{KeyboardEvent:t}=Gc(e.target);return t&&e instanceof t}function oh(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=Gc(e.target);return t&&e instanceof t}(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const ah=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ah.Translate.toString(e),ah.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),lh="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function uh(e){return e.matches(lh)?e:e.querySelector(lh)}const ch={display:"none"};function hh(e){let{id:n,value:r}=e;return t.createElement("div",{id:n,style:ch},r)}function dh(e){let{id:n,announcement:r,ariaLiveType:i="assertive"}=e;return t.createElement("div",{id:n,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":i,"aria-atomic":!0},r)}const fh=g(null);const ph={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},gh={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function mh(e){let{announcements:n=gh,container:r,hiddenTextDescribedById:o,screenReaderInstructions:a=ph}=e;const{announce:u,announcement:h}=function(){const[e,t]=p("");return{announce:i(e=>{null!=e&&t(e)},[]),announcement:e}}(),d=th("DndLiveRegion"),[f,g]=p(!1);if(s(()=>{g(!0)},[]),function(e){const t=c(fh);s(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}(l(()=>({onDragStart(e){let{active:t}=e;u(n.onDragStart({active:t}))},onDragMove(e){let{active:t,over:r}=e;n.onDragMove&&u(n.onDragMove({active:t,over:r}))},onDragOver(e){let{active:t,over:r}=e;u(n.onDragOver({active:t,over:r}))},onDragEnd(e){let{active:t,over:r}=e;u(n.onDragEnd({active:t,over:r}))},onDragCancel(e){let{active:t,over:r}=e;u(n.onDragCancel({active:t,over:r}))}}),[u,n])),!f)return null;const m=t.createElement(t.Fragment,null,t.createElement(hh,{id:o,value:a.draggable}),t.createElement(dh,{id:d,announcement:h}));return r?y(m,r):m}var _h;function yh(){}!function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"}(_h||(_h={}));const vh=Object.freeze({x:0,y:0});function bh(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xh(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function wh(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Ah(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const Eh=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=Ah(t,t.left,t.top),s=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=bh(Ah(r),i);s.push({id:t,data:{droppableContainer:e,value:n}})}}return s.sort(xh)};function Sh(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;if(r<i&&n<s){const n=t.width*t.height,r=e.width*e.height,i=o*a;return Number((i/(n+r-i)).toFixed(4))}return 0}const Th=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=[];for(const e of r){const{id:r}=e,s=n.get(r);if(s){const n=Sh(s,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(wh)};function kh(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:vh}function Oh(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}const Rh=Oh(1);const Ch={ignoreTransform:!1};function Ph(e,t){void 0===t&&(t=Ch);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=Gc(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=function(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}(t);if(!r)return e;const{scaleX:i,scaleY:s,x:o,y:a}=r,l=e.left-o-(1-i)*parseFloat(n),u=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=i?e.width/i:e.width,h=s?e.height/s:e.height;return{width:c,height:h,top:u,right:l+c,bottom:u+h,left:l}}(n,t,r))}const{top:r,left:i,width:s,height:o,bottom:a,right:l}=n;return{top:r,left:i,width:s,height:o,bottom:a,right:l}}function Mh(e){return Ph(e,{ignoreTransform:!0})}function Nh(e,t){const n=[];return e?function r(i){if(null!=t&&n.length>=t)return n;if(!i)return n;if($c(i)&&null!=i.scrollingElement&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!qc(i)||Hc(i))return n;if(n.includes(i))return n;const s=Gc(e).getComputedStyle(i);return i!==e&&function(e,t){void 0===t&&(t=Gc(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(e=>{const r=t[e];return"string"==typeof r&&n.test(r)})}(i,s)&&n.push(i),function(e,t){return void 0===t&&(t=Gc(e).getComputedStyle(e)),"fixed"===t.position}(i,s)?n:r(i.parentNode)}(e):n}function Ih(e){const[t]=Nh(e,1);return null!=t?t:null}function Dh(e){return Vc&&e?Uc(e)?e:Bc(e)?$c(e)||e===Wc(e).scrollingElement?window:qc(e)?e:null:null:null}function Fh(e){return Uc(e)?e.scrollX:e.scrollLeft}function zh(e){return Uc(e)?e.scrollY:e.scrollTop}function Lh(e){return{x:Fh(e),y:zh(e)}}var jh;function Vh(e){return!(!Vc||!e)&&e===document.scrollingElement}function Uh(e){const t={x:0,y:0},n=Vh(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(jh||(jh={}));const Bh={x:.2,y:.2};function Gh(e,t,n,r,i){let{top:s,left:o,right:a,bottom:l}=n;void 0===r&&(r=10),void 0===i&&(i=Bh);const{isTop:u,isBottom:c,isLeft:h,isRight:d}=Uh(e),f={x:0,y:0},p={x:0,y:0},g=t.height*i.y,m=t.width*i.x;return!u&&s<=t.top+g?(f.y=jh.Backward,p.y=r*Math.abs((t.top+g-s)/g)):!c&&l>=t.bottom-g&&(f.y=jh.Forward,p.y=r*Math.abs((t.bottom-g-l)/g)),!d&&a>=t.right-m?(f.x=jh.Forward,p.x=r*Math.abs((t.right-m-a)/m)):!h&&o<=t.left+m&&(f.x=jh.Backward,p.x=r*Math.abs((t.left+m-o)/m)),{direction:f,speed:p}}function $h(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function qh(e){return e.reduce((e,t)=>rh(e,Lh(t)),vh)}const Hh=[["x",["left","right"],function(e){return e.reduce((e,t)=>e+Fh(t),0)}],["y",["top","bottom"],function(e){return e.reduce((e,t)=>e+zh(t),0)}]];class Wh{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Nh(t),r=qh(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,i]of Hh)for(const s of t)Object.defineProperty(this,s,{get:()=>{const t=i(n),o=r[e]-t;return this.rect[s]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Zh{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)})},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function Kh(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var Xh,Yh;function Qh(e){e.preventDefault()}function Jh(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(Xh||(Xh={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"}(Yh||(Yh={}));const ed={start:[Yh.Space,Yh.Enter],cancel:[Yh.Esc],end:[Yh.Space,Yh.Enter,Yh.Tab]},td=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Yh.Right:return{...n,x:n.x+25};case Yh.Left:return{...n,x:n.x-25};case Yh.Down:return{...n,y:n.y+25};case Yh.Up:return{...n,y:n.y-25}}};class nd{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Zh(Wc(t)),this.windowListeners=new Zh(Gc(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Xh.Resize,this.handleCancel),this.windowListeners.add(Xh.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Xh.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=Ph),!e)return;const{top:n,left:r,bottom:i,right:s}=t(e);Ih(e)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(vh)}handleKeyDown(e){if(sh(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:i=ed,coordinateGetter:s=td,scrollBehavior:o="smooth"}=r,{code:a}=e;if(i.end.includes(a))return void this.handleEnd(e);if(i.cancel.includes(a))return void this.handleCancel(e);const{collisionRect:l}=n.current,u=l?{x:l.left,y:l.top}:vh;this.referenceCoordinates||(this.referenceCoordinates=u);const c=s(e,{active:t,context:n.current,currentCoordinates:u});if(c){const t=ih(c,u),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(const n of i){const i=e.code,{isTop:s,isRight:a,isLeft:l,isBottom:u,maxScroll:h,minScroll:d}=Uh(n),f=$h(n),p={x:Math.min(i===Yh.Right?f.right-f.width/2:f.right,Math.max(i===Yh.Right?f.left:f.left+f.width/2,c.x)),y:Math.min(i===Yh.Down?f.bottom-f.height/2:f.bottom,Math.max(i===Yh.Down?f.top:f.top+f.height/2,c.y))},g=i===Yh.Right&&!a||i===Yh.Left&&!l,m=i===Yh.Down&&!u||i===Yh.Up&&!s;if(g&&p.x!==c.x){const e=n.scrollLeft+t.x,s=i===Yh.Right&&e<=h.x||i===Yh.Left&&e>=d.x;if(s&&!t.y)return void n.scrollTo({left:e,behavior:o});r.x=s?n.scrollLeft-e:i===Yh.Right?n.scrollLeft-h.x:n.scrollLeft-d.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}if(m&&p.y!==c.y){const e=n.scrollTop+t.y,s=i===Yh.Down&&e<=h.y||i===Yh.Up&&e>=d.y;if(s&&!t.x)return void n.scrollTo({top:e,behavior:o});r.y=s?n.scrollTop-e:i===Yh.Down?n.scrollTop-h.y:n.scrollTop-d.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,rh(ih(c,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function rd(e){return Boolean(e&&"distance"in e)}function id(e){return Boolean(e&&"delay"in e)}nd.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=ed,onActivation:i}=t,{active:s}=n;const{code:o}=e.nativeEvent;if(r.start.includes(o)){const t=s.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==i||i({event:e.nativeEvent}),!0)}return!1}}];class sd{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=Gc(e);return e instanceof t?e:Wc(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:i}=e,{target:s}=i;this.props=e,this.events=t,this.document=Wc(s),this.documentListeners=new Zh(this.document),this.listeners=new Zh(n),this.windowListeners=new Zh(Gc(s)),this.initialCoordinates=null!=(r=oh(i))?r:vh,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Xh.Resize,this.handleCancel),this.windowListeners.add(Xh.DragStart,Qh),this.windowListeners.add(Xh.VisibilityChange,this.handleCancel),this.windowListeners.add(Xh.ContextMenu,Qh),this.documentListeners.add(Xh.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(id(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(rd(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Xh.Click,Jh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Xh.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:i}=this,{onMove:s,options:{activationConstraint:o}}=i;if(!r)return;const a=null!=(t=oh(e))?t:vh,l=ih(r,a);if(!n&&o){if(rd(o)){if(null!=o.tolerance&&Kh(l,o.tolerance))return this.handleCancel();if(Kh(l,o.distance))return this.handleStart()}return id(o)&&Kh(l,o.tolerance)?this.handleCancel():void this.handlePending(o,l)}e.cancelable&&e.preventDefault(),s(a)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Yh.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const od={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ad extends sd{constructor(e){const{event:t}=e,n=Wc(t.target);super(e,od,n)}}ad.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const ld={move:{name:"mousemove"},end:{name:"mouseup"}};var ud;!function(e){e[e.RightClick=2]="RightClick"}(ud||(ud={}));(class extends sd{constructor(e){super(e,ld,Wc(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==ud.RightClick&&(null==r||r({event:n}),!0)}}];const cd={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var hd,dd;function fd(e){let{acceleration:t,activator:n=hd.Pointer,canScroll:o,draggingRect:a,enabled:u,interval:c=5,order:h=dd.TreeOrder,pointerCoordinates:d,scrollableAncestors:f,scrollableAncestorRects:p,delta:g,threshold:m}=e;const _=function(e){let{delta:t,disabled:n}=e;const r=Jc(t);return Yc(e=>{if(n||!r||!e)return pd;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[jh.Backward]:e.x[jh.Backward]||-1===i.x,[jh.Forward]:e.x[jh.Forward]||1===i.x},y:{[jh.Backward]:e.y[jh.Backward]||-1===i.y,[jh.Forward]:e.y[jh.Forward]||1===i.y}}},[n,t,r])}({delta:g,disabled:!u}),[y,v]=function(){const e=r(null);return[i((t,n)=>{e.current=setInterval(t,n)},[]),i(()=>{null!==e.current&&(clearInterval(e.current),e.current=null)},[])]}(),b=r({x:0,y:0}),x=r({x:0,y:0}),w=l(()=>{switch(n){case hd.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case hd.DraggableRect:return a}},[n,a,d]),A=r(null),E=i(()=>{const e=A.current;if(!e)return;const t=b.current.x*x.current.x,n=b.current.y*x.current.y;e.scrollBy(t,n)},[]),S=l(()=>h===dd.TreeOrder?[...f].reverse():f,[h,f]);s(()=>{if(u&&f.length&&w){for(const e of S){if(!1===(null==o?void 0:o(e)))continue;const n=f.indexOf(e),r=p[n];if(!r)continue;const{direction:i,speed:s}=Gh(e,r,w,t,m);for(const e of["x","y"])_[e][i[e]]||(s[e]=0,i[e]=0);if(s.x>0||s.y>0)return v(),A.current=e,y(E,c),b.current=s,void(x.current=i)}b.current={x:0,y:0},x.current={x:0,y:0},v()}else v()},[t,E,o,v,u,c,JSON.stringify(w),JSON.stringify(_),y,f,S,p,JSON.stringify(m)])}(class extends sd{constructor(e){super(e,cd)}static setup(){return window.addEventListener(cd.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(cd.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:i}=n;return!(i.length>1)&&(null==r||r({event:n}),!0)}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(hd||(hd={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(dd||(dd={}));const pd={x:{[jh.Backward]:!1,[jh.Forward]:!1},y:{[jh.Backward]:!1,[jh.Forward]:!1}};var gd,md;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(gd||(gd={})),function(e){e.Optimized="optimized"}(md||(md={}));const _d=new Map;function yd(e,t){return Yc(n=>e?n||("function"==typeof t?t(e):e):null,[t,e])}function vd(e){let{callback:t,disabled:n}=e;const r=Kc(t),i=l(()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)},[n]);return s(()=>()=>null==i?void 0:i.disconnect(),[i]),i}function bd(e){return new Wh(Ph(e),e)}function xd(e,t,n){void 0===t&&(t=bd);const[r,i]=p(null);function o(){i(r=>{if(!e)return null;var i;if(!1===e.isConnected)return null!=(i=null!=r?r:n)?i:null;const s=t(e);return JSON.stringify(r)===JSON.stringify(s)?r:s})}const a=function(e){let{callback:t,disabled:n}=e;const r=Kc(t),i=l(()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)},[r,n]);return s(()=>()=>null==i?void 0:i.disconnect(),[i]),i}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){o();break}}}}),u=vd({callback:o});return Zc(()=>{o(),e?(null==u||u.observe(e),null==a||a.observe(document.body,{childList:!0,subtree:!0})):(null==u||u.disconnect(),null==a||a.disconnect())},[e]),r}const wd=[];function Ad(e,t){void 0===t&&(t=[]);const n=r(null);return s(()=>{n.current=null},t),s(()=>{const t=e!==vh;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?ih(e,n.current):vh}function Ed(e){return l(()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null,[e])}const Sd=[];function Td(e){let{measure:t}=e;const[n,r]=p(null),s=i(e=>{for(const{target:n}of e)if(qc(n)){r(e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t]),o=vd({callback:s}),a=i(e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return qc(t)?t:e}(e);null==o||o.disconnect(),n&&(null==o||o.observe(n)),r(n?t(n):null)},[t,o]),[u,c]=Qc(a);return l(()=>({nodeRef:u,rect:n,setRef:c}),[n,u,c])}const kd=[{sensor:ad,options:{}},{sensor:nd,options:{}}],Od={current:{}},Rd={draggable:{measure:Mh},droppable:{measure:Mh,strategy:gd.WhileDragging,frequency:md.Optimized},dragOverlay:{measure:Ph}};class Cd extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const Pd={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Cd,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:yh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Rd,measureDroppableContainers:yh,windowRect:null,measuringScheduled:!1},Md=g({activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:yh,draggableNodes:new Map,over:null,measureDroppableContainers:yh}),Nd=g(Pd);function Id(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Cd}}}function Dd(e,t){switch(t.type){case _h.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case _h.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case _h.DragEnd:case _h.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case _h.RegisterDroppable:{const{element:n}=t,{id:r}=n,i=new Cd(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case _h.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const o=new Cd(e.droppable.containers);return o.set(n,{...s,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case _h.UnregisterDroppable:{const{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Cd(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function Fd(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:i}=c(Md),o=Jc(r),a=Jc(null==n?void 0:n.id);return s(()=>{if(!t&&!r&&o&&null!=a){if(!sh(o))return;if(document.activeElement===o.target)return;const e=i.get(a);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=uh(e);if(t){t.focus();break}}})}},[r,t,i,a,o]),null}const zd=g({...vh,scaleX:1,scaleY:1});var Ld;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(Ld||(Ld={}));const jd=h(function(e){var n,o,a,u;let{id:c,accessibility:h,autoScroll:d=!0,children:f,sensors:g=kd,collisionDetection:_=Th,measuring:y,modifiers:b,...x}=e;const w=m(Dd,void 0,Id),[A,E]=w,[S,T]=function(){const[e]=p(()=>new Set),t=i(t=>(e.add(t),()=>e.delete(t)),[e]);return[i(t=>{let{type:n,event:r}=t;e.forEach(e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)})},[e]),t]}(),[k,O]=p(Ld.Uninitialized),R=k===Ld.Initialized,{draggable:{active:C,nodes:P,translate:M},droppable:{containers:N}}=A,I=null!=C?P.get(C):null,D=r({initial:null,translated:null}),F=l(()=>{var e;return null!=C?{id:C,data:null!=(e=null==I?void 0:I.data)?e:Od,rect:D}:null},[C,I]),z=r(null),[L,j]=p(null),[V,U]=p(null),B=Xc(x,Object.values(x)),G=th("DndDescribedBy",c),$=l(()=>N.getEnabled(),[N]),q=l(()=>({draggable:{...Rd.draggable,...null==H?void 0:H.draggable},droppable:{...Rd.droppable,...null==H?void 0:H.droppable},dragOverlay:{...Rd.dragOverlay,...null==H?void 0:H.dragOverlay}}),[null==(H=y)?void 0:H.draggable,null==H?void 0:H.droppable,null==H?void 0:H.dragOverlay]);var H;const{droppableRects:W,measureDroppableContainers:Z,measuringScheduled:K}=function(e,t){let{dragging:n,dependencies:o,config:a}=t;const[l,u]=p(null),{frequency:c,measure:h,strategy:d}=a,f=r(e),g=function(){switch(d){case gd.Always:return!1;case gd.BeforeDragging:return n;default:return!n}}(),m=Xc(g),_=i(function(e){void 0===e&&(e=[]),m.current||u(t=>null===t?e:t.concat(e.filter(e=>!t.includes(e))))},[m]),y=r(null),v=Yc(t=>{if(g&&!n)return _d;if(!t||t===_d||f.current!==e||null!=l){const t=new Map;for(let n of e){if(!n)continue;if(l&&l.length>0&&!l.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new Wh(h(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,l,n,g,h]);return s(()=>{f.current=e},[e]),s(()=>{g||_()},[n,g]),s(()=>{l&&l.length>0&&u(null)},[JSON.stringify(l)]),s(()=>{g||"number"!=typeof c||null!==y.current||(y.current=setTimeout(()=>{_(),y.current=null},c))},[c,g,_,...o]),{droppableRects:v,measureDroppableContainers:_,measuringScheduled:null!=l}}($,{dragging:R,dependencies:[M.x,M.y],config:q.droppable}),X=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return Yc(e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null},[r,t])}(P,C),Y=l(()=>V?oh(V):null,[V]),Q=function(){const e=!1===(null==L?void 0:L.autoScrollEnabled),t="object"==typeof d?!1===d.enabled:!1===d,n=R&&!e&&!t;if("object"==typeof d)return{...d,enabled:n};return{enabled:n}}(),J=function(e,t){return yd(e,t)}(X,q.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:i,config:s=!0}=e;const o=r(!1),{x:a,y:l}="boolean"==typeof s?{x:s,y:s}:s;Zc(()=>{if(!a&&!l||!t)return void(o.current=!1);if(o.current||!i)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=kh(n(e),i);if(a||(r.x=0),l||(r.y=0),o.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=Ih(e);t&&t.scrollBy({top:r.y,left:r.x})}},[t,a,l,i,n])}({activeNode:null!=C?P.get(C):null,config:Q.layoutShiftCompensation,initialRect:J,measure:q.draggable.measure});const ee=xd(X,q.draggable.measure,J),te=xd(X?X.parentElement:null),ne=r({activatorEvent:null,active:null,activeNode:X,collisionRect:null,collisions:null,droppableRects:W,draggableNodes:P,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),re=N.getNodeFor(null==(n=ne.current.over)?void 0:n.id),ie=Td({measure:q.dragOverlay.measure}),se=null!=(o=ie.nodeRef.current)?o:X,oe=R?null!=(a=ie.rect)?a:ee:null,ae=Boolean(ie.nodeRef.current&&ie.rect),le=kh(ue=ae?null:ee,yd(ue));var ue;const ce=Ed(se?Gc(se):null),he=function(e){const t=r(e),n=Yc(n=>e?n&&n!==wd&&e&&t.current&&e.parentNode===t.current.parentNode?n:Nh(e):wd,[e]);return s(()=>{t.current=e},[e]),n}(R?null!=re?re:X:null),de=function(e,t){void 0===t&&(t=Ph);const[n]=e,r=Ed(n?Gc(n):null),[i,s]=p(Sd);function o(){s(()=>e.length?e.map(e=>Vh(e)?r:new Wh(t(e),e)):Sd)}const a=vd({callback:o});return Zc(()=>{null==a||a.disconnect(),o(),e.forEach(e=>null==a?void 0:a.observe(e))},[e]),i}(he),fe=function(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}(b,{transform:{x:M.x-le.x,y:M.y-le.y,scaleX:1,scaleY:1},activatorEvent:V,active:F,activeNodeRect:ee,containerNodeRect:te,draggingNodeRect:oe,over:ne.current.over,overlayNodeRect:ie.rect,scrollableAncestors:he,scrollableAncestorRects:de,windowRect:ce}),pe=Y?rh(Y,M):null,ge=function(e){const[t,n]=p(null),o=r(e),a=i(e=>{const t=Dh(e.target);t&&n(e=>e?(e.set(t,Lh(t)),new Map(e)):null)},[]);return s(()=>{const t=o.current;if(e!==t){r(t);const i=e.map(e=>{const t=Dh(e);return t?(t.addEventListener("scroll",a,{passive:!0}),[t,Lh(t)]):null}).filter(e=>null!=e);n(i.length?new Map(i):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach(e=>{const t=Dh(e);null==t||t.removeEventListener("scroll",a)})}},[a,e]),l(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>rh(e,t),vh):qh(e):vh,[e,t])}(he),me=Ad(ge),_e=Ad(ge,[ee]),ye=rh(fe,me),ve=oe?Rh(oe,fe):null,be=F&&ve?_({active:F,collisionRect:ve,droppableRects:W,droppableContainers:$,pointerCoordinates:pe}):null,xe=function(e,t){if(!e||0===e.length)return null;const[n]=e;return n[t]}(be,"id"),[we,Ae]=p(null),Ee=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(ae?fe:rh(fe,_e),null!=(u=null==we?void 0:we.rect)?u:null,ee),Se=r(null),Te=i((e,t)=>{let{sensor:n,options:r}=t;if(null==z.current)return;const i=P.get(z.current);if(!i)return;const s=e.nativeEvent,o=new n({active:z.current,activeNode:i,event:s,options:r,context:ne,onAbort(e){if(!P.get(e))return;const{onDragAbort:t}=B.current,n={id:e};null==t||t(n),S({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!P.get(e))return;const{onDragPending:i}=B.current,s={id:e,constraint:t,initialCoordinates:n,offset:r};null==i||i(s),S({type:"onDragPending",event:s})},onStart(e){const t=z.current;if(null==t)return;const n=P.get(t);if(!n)return;const{onDragStart:r}=B.current,i={activatorEvent:s,active:{id:t,data:n.data,rect:D}};v(()=>{null==r||r(i),O(Ld.Initializing),E({type:_h.DragStart,initialCoordinates:e,active:t}),S({type:"onDragStart",event:i}),j(Se.current),U(s)})},onMove(e){E({type:_h.DragMove,coordinates:e})},onEnd:a(_h.DragEnd),onCancel:a(_h.DragCancel)});function a(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ne.current;let o=null;if(t&&i){const{cancelDrop:a}=B.current;if(o={activatorEvent:s,active:t,collisions:n,delta:i,over:r},e===_h.DragEnd&&"function"==typeof a){await Promise.resolve(a(o))&&(e=_h.DragCancel)}}z.current=null,v(()=>{E({type:e}),O(Ld.Uninitialized),Ae(null),j(null),U(null),Se.current=null;const t=e===_h.DragEnd?"onDragEnd":"onDragCancel";if(o){const e=B.current[t];null==e||e(o),S({type:t,event:o})}})}}Se.current=o},[P]),ke=i((e,t)=>(n,r)=>{const i=n.nativeEvent,s=P.get(r);if(null!==z.current||!s||i.dndKit||i.defaultPrevented)return;const o={active:s};!0===e(n,t.options,o)&&(i.dndKit={capturedBy:t.sensor},z.current=r,Te(n,t))},[P,Te]),Oe=function(e,t){return l(()=>e.reduce((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}))]},[]),[e,t])}(g,ke);!function(e){s(()=>{if(!Vc)return;const t=e.map(e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()});return()=>{for(const e of t)null==e||e()}},e.map(e=>{let{sensor:t}=e;return t}))}(g),Zc(()=>{ee&&k===Ld.Initializing&&O(Ld.Initialized)},[ee,k]),s(()=>{const{onDragMove:e}=B.current,{active:t,activatorEvent:n,collisions:r,over:i}=ne.current;if(!t||!n)return;const s={active:t,activatorEvent:n,collisions:r,delta:{x:ye.x,y:ye.y},over:i};v(()=>{null==e||e(s),S({type:"onDragMove",event:s})})},[ye.x,ye.y]),s(()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ne.current;if(!e||null==z.current||!t||!i)return;const{onDragOver:s}=B.current,o=r.get(xe),a=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:a};v(()=>{Ae(a),null==s||s(l),S({type:"onDragOver",event:l})})},[xe]),Zc(()=>{ne.current={activatorEvent:V,active:F,activeNode:X,collisionRect:ve,collisions:be,droppableRects:W,draggableNodes:P,draggingNode:se,draggingNodeRect:oe,droppableContainers:N,over:we,scrollableAncestors:he,scrollAdjustedTranslate:ye},D.current={initial:oe,translated:ve}},[F,X,be,ve,P,se,oe,W,N,we,he,ye]),fd({...Q,delta:M,draggingRect:ve,pointerCoordinates:pe,scrollableAncestors:he,scrollableAncestorRects:de});const Re=l(()=>({active:F,activeNode:X,activeNodeRect:ee,activatorEvent:V,collisions:be,containerNodeRect:te,dragOverlay:ie,draggableNodes:P,droppableContainers:N,droppableRects:W,over:we,measureDroppableContainers:Z,scrollableAncestors:he,scrollableAncestorRects:de,measuringConfiguration:q,measuringScheduled:K,windowRect:ce}),[F,X,ee,V,be,te,ie,P,N,W,we,Z,he,de,q,K,ce]),Ce=l(()=>({activatorEvent:V,activators:Oe,active:F,activeNodeRect:ee,ariaDescribedById:{draggable:G},dispatch:E,draggableNodes:P,over:we,measureDroppableContainers:Z}),[V,Oe,F,ee,E,G,P,we,Z]);return t.createElement(fh.Provider,{value:T},t.createElement(Md.Provider,{value:Ce},t.createElement(Nd.Provider,{value:Re},t.createElement(zd.Provider,{value:Ee},f)),t.createElement(Fd,{disabled:!1===(null==h?void 0:h.restoreFocus)})),t.createElement(mh,{...h,hiddenTextDescribedById:G}))}),Vd=g(null),Ud="button";function Bd(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e;const s=th("Draggable"),{activators:o,activatorEvent:a,active:u,activeNodeRect:h,ariaDescribedById:d,draggableNodes:f,over:p}=c(Md),{role:g=Ud,roleDescription:m="draggable",tabIndex:_=0}=null!=i?i:{},y=(null==u?void 0:u.id)===t,v=c(y?zd:Vd),[b,x]=Qc(),[w,A]=Qc(),E=function(e,t){return l(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}(o,t),S=Xc(n);Zc(()=>(f.set(t,{id:t,key:s,node:b,activatorNode:w,data:S}),()=>{const e=f.get(t);e&&e.key===s&&f.delete(t)}),[f,t]);return{active:u,activatorEvent:a,activeNodeRect:h,attributes:l(()=>({role:g,tabIndex:_,"aria-disabled":r,"aria-pressed":!(!y||g!==Ud)||void 0,"aria-roledescription":m,"aria-describedby":d.draggable}),[r,g,_,y,m,d.draggable]),isDragging:y,listeners:r?void 0:E,node:b,over:p,setNodeRef:x,setActivatorNodeRef:A,transform:v}}const Gd={timeout:25};function $d(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function qd(e,t){return e.reduce((e,n,r)=>{const i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Hd(e){return null!==e&&e>=0}const Wd=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e;const s=$d(t,r,n),o=t[i],a=s[i];return a&&o?{x:a.left-o.left,y:a.top-o.top,scaleX:a.width/o.width,scaleY:a.height/o.height}:null},Zd={scaleX:1,scaleY:1},Kd=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:o}=e;const a=null!=(t=s[n])?t:r;if(!a)return null;if(i===n){const e=s[o];return e?{x:0,y:n<o?e.top+e.height-(a.top+a.height):e.top-a.top,...Zd}:null}const l=function(e,t,n){const r=e[t],i=e[t-1],s=e[t+1];if(!r)return 0;if(n<t)return i?r.top-(i.top+i.height):s?s.top-(r.top+r.height):0;return s?s.top-(r.top+r.height):i?r.top-(i.top+i.height):0}(s,i,n);return i>n&&i<=o?{x:0,y:-a.height-l,...Zd}:i<n&&i>=o?{x:0,y:a.height+l,...Zd}:{x:0,y:0,...Zd}};const Xd="Sortable",Yd=t.createContext({activeIndex:-1,containerId:Xd,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Wd,disabled:{draggable:!1,droppable:!1}});function Qd(e){let{children:n,id:i,items:o,strategy:a=Wd,disabled:u=!1}=e;const{active:h,dragOverlay:d,droppableRects:f,over:p,measureDroppableContainers:g}=c(Nd),m=th(Xd,i),_=Boolean(null!==d.rect),y=l(()=>o.map(e=>"object"==typeof e&&"id"in e?e.id:e),[o]),v=null!=h,b=h?y.indexOf(h.id):-1,x=p?y.indexOf(p.id):-1,w=r(y),A=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(y,w.current),E=-1!==x&&-1===b||A,S=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(u);Zc(()=>{A&&v&&g(y)},[A,y,v,g]),s(()=>{w.current=y},[y]);const T=l(()=>({activeIndex:b,containerId:m,disabled:S,disableTransforms:E,items:y,overIndex:x,useDragOverlay:_,sortedRects:qd(y,f),strategy:a}),[b,m,S.draggable,S.droppable,E,y,x,f,_,a]);return t.createElement(Yd.Provider,{value:T},n)}const Jd=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return $d(n,r,i).indexOf(t)},ef=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:a,previousContainerId:l,transition:u}=e;return!(!u||!r)&&((a===s||i!==o)&&(!!n||o!==i&&t===l))},tf={duration:200,easing:"ease"},nf="transform",rf=ah.Transition.toString({property:nf,duration:0,easing:"linear"}),sf={roleDescription:"sortable"};function of(e){let{animateLayoutChanges:t=ef,attributes:n,disabled:o,data:a,getNewIndex:u=Jd,id:h,strategy:d,resizeObserverConfig:f,transition:g=tf}=e;const{items:m,containerId:_,activeIndex:y,disabled:v,disableTransforms:b,sortedRects:x,overIndex:w,useDragOverlay:A,strategy:E}=c(Yd),S=function(e,t){var n,r;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(o,v),T=m.indexOf(h),k=l(()=>({sortable:{containerId:_,index:T,items:m},...a}),[_,a,T,m]),O=l(()=>m.slice(m.indexOf(h)),[m,h]),{rect:R,node:C,isOver:P,setNodeRef:M}=function(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:a}=e;const l=th("Droppable"),{active:u,dispatch:h,over:d,measureDroppableContainers:f}=c(Md),p=r({disabled:n}),g=r(!1),m=r(null),_=r(null),{disabled:y,updateMeasurementsFor:v,timeout:b}={...Gd,...a},x=Xc(null!=v?v:o),w=vd({callback:i(()=>{g.current?(null!=_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{f(Array.isArray(x.current)?x.current:[x.current]),_.current=null},b)):g.current=!0},[b]),disabled:y||!u}),A=i((e,t)=>{w&&(t&&(w.unobserve(t),g.current=!1),e&&w.observe(e))},[w]),[E,S]=Qc(A),T=Xc(t);return s(()=>{w&&E.current&&(w.disconnect(),g.current=!1,w.observe(E.current))},[E,w]),s(()=>(h({type:_h.RegisterDroppable,element:{id:o,key:l,disabled:n,node:E,rect:m,data:T}}),()=>h({type:_h.UnregisterDroppable,key:l,id:o})),[o]),s(()=>{n!==p.current.disabled&&(h({type:_h.SetDroppableDisabled,id:o,key:l,disabled:n}),p.current.disabled=n)},[o,l,n,h]),{active:u,rect:m,isOver:(null==d?void 0:d.id)===o,node:E,over:d,setNodeRef:S}}({id:h,data:k,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...f}}),{active:N,activatorEvent:I,activeNodeRect:D,attributes:F,setNodeRef:z,listeners:L,isDragging:j,over:V,setActivatorNodeRef:U,transform:B}=Bd({id:h,data:k,attributes:{...sf,...n},disabled:S.draggable}),G=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l(()=>e=>{t.forEach(t=>t(e))},t)}(M,z),$=Boolean(N),q=$&&!b&&Hd(y)&&Hd(w),H=!A&&j,W=H&&q?B:null,Z=q?null!=W?W:(null!=d?d:E)({rects:x,activeNodeRect:D,activeIndex:y,overIndex:w,index:T}):null,K=Hd(y)&&Hd(w)?u({id:h,items:m,activeIndex:y,overIndex:w}):T,X=null==N?void 0:N.id,Y=r({activeId:X,items:m,newIndex:K,containerId:_}),Q=m!==Y.current.items,J=t({active:N,containerId:_,isDragging:j,isSorting:$,id:h,index:T,items:m,newIndex:Y.current.newIndex,previousItems:Y.current.items,previousContainerId:Y.current.containerId,transition:g,wasDragging:null!=Y.current.activeId}),ee=function(e){let{disabled:t,index:n,node:i,rect:o}=e;const[a,l]=p(null),u=r(n);return Zc(()=>{if(!t&&n!==u.current&&i.current){const e=o.current;if(e){const t=Ph(i.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&l(n)}}n!==u.current&&(u.current=n)},[t,n,i,o]),s(()=>{a&&l(null)},[a]),a}({disabled:!J,index:T,node:C,rect:R});return s(()=>{$&&Y.current.newIndex!==K&&(Y.current.newIndex=K),_!==Y.current.containerId&&(Y.current.containerId=_),m!==Y.current.items&&(Y.current.items=m)},[$,K,_,m]),s(()=>{if(X===Y.current.activeId)return;if(null!=X&&null==Y.current.activeId)return void(Y.current.activeId=X);const e=setTimeout(()=>{Y.current.activeId=X},50);return()=>clearTimeout(e)},[X]),{active:N,activeIndex:y,attributes:F,data:k,rect:R,index:T,newIndex:K,items:m,isOver:P,isSorting:$,isDragging:j,listeners:L,node:C,overIndex:w,over:V,setNodeRef:G,setActivatorNodeRef:U,setDroppableNodeRef:M,setDraggableNodeRef:z,transform:null!=ee?ee:Z,transition:function(){if(ee||Q&&Y.current.newIndex===T)return rf;if(H&&!sh(I)||!g)return;if($||J)return ah.Transition.toString({...g,property:nf});return}()}}Yh.Down,Yh.Right,Yh.Up,Yh.Left;const af=({id:e,sx:t,children:n})=>{const{isDragging:r}=Bd({id:e}),{attributes:i,listeners:s,setNodeRef:o,transform:a,transition:l}=of({id:e,strategy:Kd,transition:{duration:300,easing:"cubic-bezier(0.25, 1, 0.5, 1)"}}),u={...t?.default,...r?t?.dragging:{},transform:ah.Translate.toString(a),transition:l,cursor:"pointer"};return b(T,{ref:o,style:u,...s,...i,children:n})};function lf({items:e,getItem:t,getId:n,onDragEnd:r,sx:i,title:s,draggableSx:o}){const a=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l(()=>[...t].filter(e=>null!=e),[...t])}(l(()=>({sensor:u,options:null!=c?c:{}}),[u=ad,c={activationConstraint:{distance:8}}]));var u,c;return b(jd,{sensors:a,collisionDetection:Eh,onDragEnd:t=>{const{active:i,over:s}=t,o=e.findIndex(e=>n(e)===i.id),a=e.findIndex(e=>n(e)===s?.id),l=$d(e,o,a);r(l)},children:b(Qd,{items:e.map(n),strategy:Kd,children:b(jc,{items:e,sx:i,title:s,getKey:n,getContent:(e,r)=>{const i=n(e);return b(af,{id:i,sx:o,children:t(e,r)},i)}})})})}const uf=g(null),cf={didCatch:!1,error:null};class hf extends d{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=cf}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(null!==e){for(var t,n,r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];null===(t=(n=this.props).onReset)||void 0===t||t.call(n,{args:i,reason:"imperative-api"}),this.setState(cf)}}componentDidCatch(e,t){var n,r;null===(n=(r=this.props).onError)||void 0===n||n.call(r,e,t)}componentDidUpdate(e,t){const{didCatch:n}=this.state,{resetKeys:r}=this.props;var i,s;n&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}(e.resetKeys,r)&&(null===(i=(s=this.props).onReset)||void 0===i||i.call(s,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(cf))}render(){const{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:s}=this.state;let a=e;if(i){const e={error:s,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)a=t(e);else if(n)a=o(n,e);else{if(void 0===r)throw s;a=r}}return o(uf.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}const df=({error:e,resetErrorBoundary:t})=>x(T,{role:"alert",sx:{padding:"20px",background:"#fee"},children:[b(B,{variant:"h2",children:"Ошибка приложения"}),b(B,{variant:"body1",color:"error",children:e.message}),b(jl,{onClick:t,children:"Попробовать снова"})]}),ff=({children:e,FallbackComponent:t=df})=>b(hf,{FallbackComponent:t,children:e});function pf(t){const{name:n,type:r}=t,i=e.useId(),{control:s}=Tu();return b(Du,{name:n,control:s,render:({field:e})=>x(T,{sx:({spacing:e})=>({display:"grid",width:"100%",gap:e(1)}),children:[b(Fc,{id:i,size:"small",...t,...e,onChange:t=>{const{target:n}=t,{value:i}=n;if("number"===r)""===i?e.onChange():e.onChange(Number(i));else e.onChange(t)}}),b(Nc,{name:n})]})})}var gf,mf;!function(e){e.ONE_WAY='"OneWay"',e.POINT_ADDRESS='"PointAddress"',e.BUILDING_AREA='"MapBuildingECArea"',e.BUILTUP_AREA='"MapAdminBuiltupArea"',e.ADMIN_AREA='"MapAdminArea"',e.OCEAN_AREA='"MapOceanArea"',e.OCEAN_AREA_LABEL='"MapOceanAreaLabel"',e.FACILITY_AREA='"MapFacilityArea"',e.FACILITY_AREA_LABEL='"MapFacilityAreaLabel"',e.LANDUSE_AREA='"MapLanduseArea"',e.LANDUSE_AREA_LABEL='"MapLanduseAreaLabel"',e.NATURE_FIELD='"MapNatureField"',e.NATURE_FOREST='"MapNatureForest"',e.LINK='"Link"',e.RAILROAD_LINK='"MapRailroadLink"',e.WATER_LINK='"MapWaterLink"',e.WATER_AREA='"MapWaterArea"',e.WATER_AREA_LABEL='"MapWaterAreaLabel"',e.WATER_LAKE_LABEL='"MapWaterLakeLabel"',e.POI='"POI"',e.CITY_POI='"CityPOI"',e.CONDITIONS='"Conditions"',e.ROAD_POLY='"RoadPoly"',e.PARKING_LINE='"ParkingLine"',e.LINE_MARKING_LINE='"LaneMarkingLine"',e.LINE_MARKING_POLY='"LaneMarkingPoly"',e.TRAFFIC_SIGN='"TrafficSign"',e.TRAFFIC_SIGNAL='"TrafficSignal"',e.CAMERA='"Camera"',e.PILLAR='"Pillar"'}(gf||(gf={})),function(e){e.TILE="tile",e.NATURE_TILE="nature_tile",e.MSK="msk"}(mf||(mf={}));const _f=new class{constructor(){}log({message:e,context:t,meta:n}){console.log(t,e,n)}warn({message:e,context:t,meta:n}){console.warn(t,e,n)}error({message:e,context:t,meta:n}){console.error(t,e,n)}};var yf,vf;!function(e){e.GET="GET",e.DELETE="DELETE",e.PUT="PUT",e.POST="POST"}(yf||(yf={})),function(e){e.TOP_RIGHT="top-right",e.BOTTOM_RIGHT="bottom-right",e.BOTTOM_LEFT="bottom-left",e.TOP_LEFT="top-left"}(vf||(vf={}));const bf="https://dalganmap.ru/api",xf=256,wf="https://dalganmap.ru/api-image/images",Af={[mf.TILE]:`${bf}/tiles/get_tile/{z}/{x}/{y}.mvt`,[mf.NATURE_TILE]:`${bf}/tiles/get_nature_tile/{z}/{x}/{y}.mvt`,[mf.MSK]:"http://89.108.118.23:3070/tiles/get_tile/{z}/{x}/{y}.mvt"},Ef=e=>{const t=[],n={source:e,layer:gf.ROAD_POLY},r={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'Road';\n\n return isFilter;\n }",draw:{polygons:{color:"#BABCC2"}}},i={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'Tram';\n\n return isFilter;\n }",draw:{polygons:{color:"#ADA8A8"}}},s={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'Curb';\n\n return isFilter;\n }",draw:{polygons:{color:"#D2D9E6"}}},o={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'Bridge';\n\n return isFilter;\n }",draw:{polygons:{color:"#E1DFDD"}}};return t.push(r,i,s,o),t},Sf=e=>{const t=[],n={source:e,layer:gf.LINE_MARKING_POLY},r={id:sn(),data:n,filter:"function() {\n const { poly_number } = feature;\n\n const isFilter = poly_number === '1.14.1';\n\n return isFilter;\n }",draw:{styles:{zebra_crossing:{attributes:{a_angle:"function() {\n return feature.angle;\n }"}}}}},i={id:sn(),data:n,filter:"function() {\n const { poly_number } = feature;\n\n const isFilter = poly_number === '1.18';\n\n return isFilter;\n }",draw:{polygons:{color:"white"}}};return t.push(i,r),t},Tf=e=>{const t=[],n={source:e,layer:gf.LINE_MARKING_LINE},r="white",i=.5,s={id:sn(),data:n,sublayers:{1.1:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.1';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i}}},1.5:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.5';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,dash:[4,10]}}},1.6:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.6';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,dash:[5,5]}}},"1.16.1":{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.16.1';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i}}},1.7:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.7';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,dash:[4,10]}}},"1.7-blue":{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.7blue';\n\n return isFilter;\n }",draw:{lines:{color:"blue",width:i,dash:[4,10]}}},"1.14.3":{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.14.3';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,dash:[3,8]}}},1.12:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.12';\n\n return isFilter;\n }",draw:{lines:{color:r,width:1.5}}},"1.17.1":{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.17.1';\n\n return isFilter;\n }",draw:{lines:{color:"yellow",width:i}}},1.26:{filter:"function () {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.26';\n\n return isFilter;\n }",draw:{lines:{color:"yellow",width:i}}}}},o={"1.3-left":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.3';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:-.5}}},"1.3-right":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.3';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:i}}},"1.11r-left":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.11r';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:-.5}}},"1.11r-right":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.11r';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:i,dash:[5,5]}}},"1.11l-left":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.11l';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:-.5,dash:[5,5]}}},"1.11l-right":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.11l';\n\n return isFilter;\n }",draw:{lines:{color:r,width:i,offset:i}}},"1.25-left":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.25';\n\n return isFilter;\n }",draw:{lines:{color:r,width:1,offset:-.5,dash:[1,1],dash_background_color:[0,0,0,0]}}},"1.25-right":{id:sn(),data:n,filter:"function() {\n const { lane_number } = feature;\n\n const isFilter = lane_number === '1.25';\n\n return isFilter;\n }",draw:{lines:{color:"rgba(0,0,0,0)",width:1,offset:.5,dash:[1,1],dash_background_color:[1,1,1]}}}};return t.push(s,...Object.values(o)),t},kf=e=>{const t=[],n={source:e,layer:gf.PARKING_LINE},r={id:sn(),data:n,draw:{lines:{color:"white",width:1}}};return t.push(r),t},Of={tsodd_id:0,dit_id:0},Rf=["future_maintanance_date","placement_date","rapair_performed_date","verification_date","warranty_expr_date"],Cf={future_maintanance_date:new Date,placement_date:new Date,rapair_performed_date:new Date,verification_date:new Date,warranty_expr_date:new Date},Pf={future_maintanance_date:(new Date).toISOString(),placement_date:(new Date).toISOString(),rapair_performed_date:(new Date).toISOString(),verification_date:(new Date).toISOString(),warranty_expr_date:(new Date).toISOString()};var Mf;!function(e){e.ACTIVE="Действующий",e.INACTIVE="Недействующий",e.TEMPORARY="Временный"}(Mf||(Mf={}));const Nf=Object.values(Mf).map(e=>({label:e,value:e})),If={traffic_signal_id:"",traffic_sign_id:"",camera_id:"",dit_id:"",dop_id:"",tsodd_id:"",pillar_id:"",dops:"",signal_model:"Модель",comment:"Комментарий",direction:"Направление",status:"Статус",height:"Высота",description:"Описание",traffic_sign_number:"Номер знака",traffic_sign_title:"Название знака",traffic_sign_value:"Значение",traffic_sign_type:"Тип знака",lat:"Широта",lon:"Долгота",future_maintanance_date:"Дата следующего обслуживания",placement_date:"Дата установки",rapair_performed_date:"Дата последнего ремонта",verification_date:"Дата поверки",warranty_expr_date:"Дата окончания гарантии",dop_sign_number:"Номер знака",dop_sign_text:"Текст на табличке",dop_sign_title:"Название знака",camera_model:"Модель",fixing_type:"Тип нарушения",signs:"Дорожные знаки",signals:"Светофоры",cameras:"Камеры"},Df="dd.MM.yyyy";var Ff,zf;var Lf,jf,Vf=function(){if(zf)return Ff;function e(e){this._maxSize=e,this.clear()}zf=1,e.prototype.clear=function(){this._size=0,this._values=Object.create(null)},e.prototype.get=function(e){return this._values[e]},e.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var t=/[^.^\]^[]+|(?=\[\]|\.\.)/g,n=/^\d+$/,r=/^\d/,i=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,s=/^\s*(['"]?)(.*?)(\1)\s*$/,o=new e(512),a=new e(512),l=new e(512);function u(e){return o.get(e)||o.set(e,c(e).map(function(e){return e.replace(s,"$2")}))}function c(e){return e.match(t)||[""]}function h(e){return"string"==typeof e&&e&&-1!==["'",'"'].indexOf(e.charAt(0))}function d(e){return!h(e)&&(function(e){return e.match(r)&&!e.match(n)}(e)||function(e){return i.test(e)}(e))}return Ff={Cache:e,split:c,normalizePath:u,setter:function(e){var t=u(e);return a.get(e)||a.set(e,function(e,n){for(var r=0,i=t.length,s=e;r<i-1;){var o=t[r];if("__proto__"===o||"constructor"===o||"prototype"===o)return e;s=s[t[r++]]}s[t[r]]=n})},getter:function(e,t){var n=u(e);return l.get(e)||l.set(e,function(e){for(var r=0,i=n.length;r<i;){if(null==e&&t)return;e=e[n[r++]]}return e})},join:function(e){return e.reduce(function(e,t){return e+(h(t)||n.test(t)?"["+t+"]":(e?".":"")+t)},"")},forEach:function(e,t,n){!function(e,t,n){var r,i,s,o,a=e.length;for(i=0;i<a;i++)(r=e[i])&&(d(r)&&(r='"'+r+'"'),s=!(o=h(r))&&/^\d+$/.test(r),t.call(n,r,o,s,i,e))}(Array.isArray(e)?e:c(e),t,n)}},Ff}();var Uf,Bf=function(){if(jf)return Lf;jf=1;const e=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,t=t=>t.match(e)||[],n=e=>e[0].toUpperCase()+e.slice(1),r=(e,n)=>t(e).join(n).toLowerCase(),i=e=>t(e).reduce((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`,"");return Lf={words:t,upperFirst:n,camelCase:i,pascalCase:e=>n(i(e)),snakeCase:e=>r(e,"_"),kebabCase:e=>r(e,"-"),sentenceCase:e=>n(r(e," ")),titleCase:e=>t(e).map(n).join(" ")}}(),Gf={exports:{}};var $f=function(){if(Uf)return Gf.exports;function e(e,t){var n=e.length,r=new Array(n),i={},s=n,o=function(e){for(var t=new Map,n=0,r=e.length;n<r;n++){var i=e[n];t.has(i[0])||t.set(i[0],new Set),t.has(i[1])||t.set(i[1],new Set),t.get(i[0]).add(i[1])}return t}(t),a=function(e){for(var t=new Map,n=0,r=e.length;n<r;n++)t.set(e[n],n);return t}(e);for(t.forEach(function(e){if(!a.has(e[0])||!a.has(e[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});s--;)i[s]||l(e[s],s,new Set);return r;function l(e,t,s){if(s.has(e)){var u;try{u=", node was:"+JSON.stringify(e)}catch(e){u=""}throw new Error("Cyclic dependency"+u)}if(!a.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(!i[t]){i[t]=!0;var c=o.get(e)||new Set;if(t=(c=Array.from(c)).length){s.add(e);do{var h=c[--t];l(h,a.get(h),s)}while(t);s.delete(e)}r[--n]=e}}}return Uf=1,Gf.exports=function(t){return e(function(e){for(var t=new Set,n=0,r=e.length;n<r;n++){var i=e[n];t.add(i[0]),t.add(i[1])}return Array.from(t)}(t),t)},Gf.exports.array=e,Gf.exports}(),qf=fe($f);const Hf=Object.prototype.toString,Wf=Error.prototype.toString,Zf=RegExp.prototype.toString,Kf="undefined"!=typeof Symbol?Symbol.prototype.toString:()=>"",Xf=/^Symbol\((.*)\)(.*)$/;function Yf(e,t=!1){if(null==e||!0===e||!1===e)return""+e;const n=typeof e;if("number"===n)return function(e){return e!=+e?"NaN":0===e&&1/e<0?"-0":""+e}(e);if("string"===n)return t?`"${e}"`:e;if("function"===n)return"[Function "+(e.name||"anonymous")+"]";if("symbol"===n)return Kf.call(e).replace(Xf,"Symbol($1)");const r=Hf.call(e).slice(8,-1);return"Date"===r?isNaN(e.getTime())?""+e:e.toISOString(e):"Error"===r||e instanceof Error?"["+Wf.call(e)+"]":"RegExp"===r?Zf.call(e):null}function Qf(e,t){let n=Yf(e,t);return null!==n?n:JSON.stringify(e,function(e,n){let r=Yf(this[e],t);return null!==r?r:n},2)}function Jf(e){return null==e?[]:[].concat(e)}let ep,tp,np,rp=/\$\{\s*(\w+)\s*\}/g;ep=Symbol.toStringTag;class ip{constructor(e,t,n,r){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[ep]="Error",this.name="ValidationError",this.value=t,this.path=n,this.type=r,this.errors=[],this.inner=[],Jf(e).forEach(e=>{if(sp.isError(e)){this.errors.push(...e.errors);const t=e.inner.length?e.inner:[e];this.inner.push(...t)}else this.errors.push(e)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}tp=Symbol.hasInstance,np=Symbol.toStringTag;class sp extends Error{static formatError(e,t){const n=t.label||t.path||"this";return t=Object.assign({},t,{path:n,originalPath:t.path}),"string"==typeof e?e.replace(rp,(e,n)=>Qf(t[n])):"function"==typeof e?e(t):e}static isError(e){return e&&"ValidationError"===e.name}constructor(e,t,n,r,i){const s=new ip(e,t,n,r);if(i)return s;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[np]="Error",this.name=s.name,this.message=s.message,this.type=s.type,this.value=s.value,this.path=s.path,this.errors=s.errors,this.inner=s.inner,Error.captureStackTrace&&Error.captureStackTrace(this,sp)}static[tp](e){return ip[Symbol.hasInstance](e)||super[Symbol.hasInstance](e)}}let op={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:n,originalValue:r})=>{const i=null!=r&&r!==n?` (cast from the value \`${Qf(r,!0)}\`).`:".";return"mixed"!==t?`${e} must be a \`${t}\` type, but the final value was: \`${Qf(n,!0)}\``+i:`${e} must match the configured type. The validated value was: \`${Qf(n,!0)}\``+i}},ap={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},lp={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},up={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},cp={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},hp={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},dp={notType:e=>{const{path:t,value:n,spec:r}=e,i=r.types.length;if(Array.isArray(n)){if(n.length<i)return`${t} tuple value has too few items, expected a length of ${i} but got ${n.length} for value: \`${Qf(n,!0)}\``;if(n.length>i)return`${t} tuple value has too many items, expected a length of ${i} but got ${n.length} for value: \`${Qf(n,!0)}\``}return sp.formatError(op.notType,e)}};Object.assign(Object.create(null),{mixed:op,string:ap,number:lp,date:up,object:cp,array:hp,boolean:{isValue:"${path} field must be ${value}"},tuple:dp});const fp=e=>e&&e.__isYupSchema__;class pp{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:r,otherwise:i}=t,s="function"==typeof n?n:(...e)=>e.every(e=>e===n);return new pp(e,(e,t)=>{var n;let o=s(...e)?r:i;return null!=(n=null==o?void 0:o(t))?n:t})}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let n=this.refs.map(e=>e.getValue(null==t?void 0:t.value,null==t?void 0:t.parent,null==t?void 0:t.context)),r=this.fn(n,e,t);if(void 0===r||r===e)return e;if(!fp(r))throw new TypeError("conditions must return a schema object");return r.resolve(t)}}const gp="$",mp=".";class _p{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,"string"!=typeof e)throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),""===e)throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===gp,this.isValue=this.key[0]===mp,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?gp:this.isValue?mp:"";this.path=this.key.slice(n.length),this.getter=this.path&&Vf.getter(this.path,!0),this.map=t.map}getValue(e,t,n){let r=this.isContext?n:this.isValue?e:t;return this.getter&&(r=this.getter(r||{})),this.map&&(r=this.map(r)),r}cast(e,t){return this.getValue(e,null==t?void 0:t.parent,null==t?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}_p.prototype.__isYupRef=!0;const yp=e=>null==e;function vp(e){function t({value:t,path:n="",options:r,originalValue:i,schema:s},o,a){const{name:l,test:u,params:c,message:h,skipAbsent:d}=e;let{parent:f,context:p,abortEarly:g=s.spec.abortEarly,disableStackTrace:m=s.spec.disableStackTrace}=r;const _={value:t,parent:f,context:p};function y(e={}){const r=bp(Object.assign({value:t,originalValue:i,label:s.spec.label,path:e.path||n,spec:s.spec,disableStackTrace:e.disableStackTrace||m},c,e.params),_),o=new sp(sp.formatError(e.message||h,r),t,r.path,e.type||l,r.disableStackTrace);return o.params=r,o}const v=g?o:a;let b={path:n,parent:f,type:l,from:r.from,createError:y,resolve:e=>xp(e,_),options:r,originalValue:i,schema:s};const x=e=>{sp.isError(e)?v(e):e?a(null):v(y())},w=e=>{sp.isError(e)?v(e):o(e)};if(d&&yp(t))return x(!0);let A;try{var E;if(A=u.call(b,t,b),"function"==typeof(null==(E=A)?void 0:E.then)){if(r.sync)throw new Error(`Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(A).then(x,w)}}catch(e){return void w(e)}x(A)}return t.OPTIONS=e,t}function bp(e,t){if(!e)return e;for(const n of Object.keys(e))e[n]=xp(e[n],t);return e}function xp(e,t){return _p.isRef(e)?e.getValue(t.value,t.parent,t.context):e}function wp(e,t,n,r=n){let i,s,o;return t?(Vf.forEach(t,(a,l,u)=>{let c=l?a.slice(1,a.length-1):a,h="tuple"===(e=e.resolve({context:r,parent:i,value:n})).type,d=u?parseInt(c,10):0;if(e.innerType||h){if(h&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${o}" must contain an index to the tuple element, e.g. "${o}[0]"`);if(n&&d>=n.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${t}. because there is no value at that index. `);i=n,n=n&&n[d],e=h?e.spec.types[d]:e.innerType}if(!u){if(!e.fields||!e.fields[c])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${o} which is a type: "${e.type}")`);i=n,n=n&&n[c],e=e.fields[c]}s=c,o=l?"["+a+"]":"."+a}),{schema:e,parent:i,parentPath:s}):{parent:i,parentPath:t,schema:e}}class Ap extends Set{describe(){const e=[];for(const t of this.values())e.push(_p.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const n of this.values())t.push(e(n));return t}clone(){return new Ap(this.values())}merge(e,t){const n=this.clone();return e.forEach(e=>n.add(e)),t.forEach(e=>n.delete(e)),n}}function Ep(e,t=new Map){if(fp(e)||!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);let n;if(e instanceof Date)n=new Date(e.getTime()),t.set(e,n);else if(e instanceof RegExp)n=new RegExp(e),t.set(e,n);else if(Array.isArray(e)){n=new Array(e.length),t.set(e,n);for(let r=0;r<e.length;r++)n[r]=Ep(e[r],t)}else if(e instanceof Map){n=new Map,t.set(e,n);for(const[r,i]of e.entries())n.set(r,Ep(i,t))}else if(e instanceof Set){n=new Set,t.set(e,n);for(const r of e)n.add(Ep(r,t))}else{if(!(e instanceof Object))throw Error(`Unable to clone ${e}`);n={},t.set(e,n);for(const[r,i]of Object.entries(e))n[r]=Ep(i,t)}return n}function Sp(e){if(null==e||!e.length)return;const t=[];let n="",r=!1,i=!1;for(let s=0;s<e.length;s++){const o=e[s];"["!==o||i?"]"!==o||i?'"'!==o?"."!==o||r||i?n+=o:n&&(t.push(n),n=""):i=!i:(n&&(/^\d+$/.test(n)?t.push(n):t.push(n.replace(/^"|"$/g,"")),n=""),r=!1):(n&&(t.push(...n.split(".").filter(Boolean)),n=""),r=!0)}return n&&t.push(...n.split(".").filter(Boolean)),t}function Tp(e,t){var n;if((null==(n=e.inner)||!n.length)&&e.errors.length)return function(e,t){const n=t?`${t}.${e.path}`:e.path;return e.errors.map(e=>({message:e,path:Sp(n)}))}(e,t);const r=t?`${t}.${e.path}`:e.path;return e.inner.flatMap(e=>Tp(e,r))}class kp{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new Ap,this._blacklist=new Ap,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(op.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},null==e?void 0:e.spec),this.withMutation(e=>{e.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=Ep(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(0===e.length)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let n=e(this);return this._mutate=t,n}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&"mixed"!==this.type)throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,n=e.clone();const r=Object.assign({},t.spec,n.spec);return n.spec=r,n.internalTests=Object.assign({},t.internalTests,n.internalTests),n._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),n._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),n.tests=t.tests,n.exclusiveTests=t.exclusiveTests,n.withMutation(t=>{e.tests.forEach(e=>{t.test(e.OPTIONS)})}),n.transforms=[...t.transforms,...n.transforms],n}isType(e){return null==e?!(!this.spec.nullable||null!==e)||!(!this.spec.optional||void 0!==e):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let n=t.conditions;t=t.clone(),t.conditions=[],t=n.reduce((t,n)=>n.resolve(t,e),t),t=t.resolve(e)}return t}resolveOptions(e){var t,n,r,i;return Object.assign({},e,{from:e.from||[],strict:null!=(t=e.strict)?t:this.spec.strict,abortEarly:null!=(n=e.abortEarly)?n:this.spec.abortEarly,recursive:null!=(r=e.recursive)?r:this.spec.recursive,disableStackTrace:null!=(i=e.disableStackTrace)?i:this.spec.disableStackTrace})}cast(e,t={}){let n=this.resolve(Object.assign({},t,{value:e})),r="ignore-optionality"===t.assert,i=n._cast(e,t);if(!1!==t.assert&&!n.isType(i)){if(r&&yp(i))return i;let s=Qf(e),o=Qf(i);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}". \n\nattempted value: ${s} \n`+(o!==s?`result of cast: ${o}`:""))}return i}_cast(e,t){let n=void 0===e?e:this.transforms.reduce((n,r)=>r.call(this,n,e,this,t),e);return void 0===n&&(n=this.getDefault(t)),n}_validate(e,t={},n,r){let{path:i,originalValue:s=e,strict:o=this.spec.strict}=t,a=e;o||(a=this._cast(a,Object.assign({assert:!1},t)));let l=[];for(let e of Object.values(this.internalTests))e&&l.push(e);this.runTests({path:i,value:a,originalValue:s,options:t,tests:l},n,e=>{if(e.length)return r(e,a);this.runTests({path:i,value:a,originalValue:s,options:t,tests:this.tests},n,r)})}runTests(e,t,n){let r=!1,{tests:i,value:s,originalValue:o,path:a,options:l}=e,u=e=>{r||(r=!0,t(e,s))},c=e=>{r||(r=!0,n(e,s))},h=i.length,d=[];if(!h)return c([]);let f={value:s,originalValue:o,path:a,options:l,schema:this};for(let e=0;e<i.length;e++){(0,i[e])(f,u,function(e){e&&(Array.isArray(e)?d.push(...e):d.push(e)),--h<=0&&c(d)})}}asNestedTest({key:e,index:t,parent:n,parentPath:r,originalParent:i,options:s}){const o=null!=e?e:t;if(null==o)throw TypeError("Must include `key` or `index` for nested validations");const a="number"==typeof o;let l=n[o];const u=Object.assign({},s,{strict:!0,parent:n,value:l,originalValue:i[o],key:void 0,[a?"index":"key"]:o,path:a||o.includes(".")?`${r||""}[${a?o:`"${o}"`}]`:(r?`${r}.`:"")+e});return(e,t,n)=>this.resolve(u)._validate(l,u,t,n)}validate(e,t){var n;let r=this.resolve(Object.assign({},t,{value:e})),i=null!=(n=null==t?void 0:t.disableStackTrace)?n:r.spec.disableStackTrace;return new Promise((n,s)=>r._validate(e,t,(e,t)=>{sp.isError(e)&&(e.value=t),s(e)},(e,t)=>{e.length?s(new sp(e,t,void 0,void 0,i)):n(t)}))}validateSync(e,t){var n;let r,i=this.resolve(Object.assign({},t,{value:e})),s=null!=(n=null==t?void 0:t.disableStackTrace)?n:i.spec.disableStackTrace;return i._validate(e,Object.assign({},t,{sync:!0}),(e,t)=>{throw sp.isError(e)&&(e.value=t),e},(t,n)=>{if(t.length)throw new sp(t,e,void 0,void 0,s);r=n}),r}isValid(e,t){return this.validate(e,t).then(()=>!0,e=>{if(sp.isError(e))return!1;throw e})}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(e){if(sp.isError(e))return!1;throw e}}_getDefault(e){let t=this.spec.default;return null==t?t:"function"==typeof t?t.call(this,e):Ep(t)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){if(0===arguments.length)return this._getDefault();return this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const n=this.clone({nullable:e});return n.internalTests.nullable=vp({message:t,name:"nullable",test(e){return null!==e||this.schema.spec.nullable}}),n}optionality(e,t){const n=this.clone({optional:e});return n.internalTests.optionality=vp({message:t,name:"optionality",test(e){return void 0!==e||this.schema.spec.optional}}),n}optional(){return this.optionality(!0)}defined(e=op.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=op.notNull){return this.nullability(!1,e)}required(e=op.required){return this.clone().withMutation(t=>t.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(t=1===e.length?"function"==typeof e[0]?{test:e[0]}:e[0]:2===e.length?{name:e[0],test:e[1]}:{name:e[0],message:e[1],test:e[2]},void 0===t.message&&(t.message=op.default),"function"!=typeof t.test)throw new TypeError("`test` is a required parameters");let n=this.clone(),r=vp(t),i=t.exclusive||t.name&&!0===n.exclusiveTests[t.name];if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(n.exclusiveTests[t.name]=!!t.exclusive),n.tests=n.tests.filter(e=>{if(e.OPTIONS.name===t.name){if(i)return!1;if(e.OPTIONS.test===r.OPTIONS.test)return!1}return!0}),n.tests.push(r),n}when(e,t){Array.isArray(e)||"string"==typeof e||(t=e,e=".");let n=this.clone(),r=Jf(e).map(e=>new _p(e));return r.forEach(e=>{e.isSibling&&n.deps.push(e.key)}),n.conditions.push("function"==typeof t?new pp(r,t):pp.fromOptions(r,t)),n}typeError(e){let t=this.clone();return t.internalTests.typeError=vp({message:e,name:"typeError",skipAbsent:!0,test(e){return!!this.schema._typeCheck(e)||this.createError({params:{type:this.schema.type}})}}),t}oneOf(e,t=op.oneOf){let n=this.clone();return e.forEach(e=>{n._whitelist.add(e),n._blacklist.delete(e)}),n.internalTests.whiteList=vp({message:t,name:"oneOf",skipAbsent:!0,test(e){let t=this.schema._whitelist,n=t.resolveAll(this.resolve);return!!n.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:n}})}}),n}notOneOf(e,t=op.notOneOf){let n=this.clone();return e.forEach(e=>{n._blacklist.add(e),n._whitelist.delete(e)}),n.internalTests.blacklist=vp({message:t,name:"notOneOf",test(e){let t=this.schema._blacklist,n=t.resolveAll(this.resolve);return!n.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:n}})}}),n}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:n,meta:r,optional:i,nullable:s}=t.spec,o={meta:r,label:n,optional:i,nullable:s,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.filter((e,t,n)=>n.findIndex(t=>t.OPTIONS.name===e.OPTIONS.name)===t).map(t=>{const n=t.OPTIONS.params&&e?bp(Object.assign({},t.OPTIONS.params),e):t.OPTIONS.params;return{name:t.OPTIONS.name,params:n}})};return o}get"~standard"(){const e=this,t={version:1,vendor:"yup",async validate(t){try{return{value:await e.validate(t,{abortEarly:!1})}}catch(e){if(e instanceof sp)return{issues:Tp(e)};throw e}}};return t}}kp.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])kp.prototype[`${e}At`]=function(t,n,r={}){const{parent:i,parentPath:s,schema:o}=wp(this,t,n,r.context);return o[e](i&&i[s],Object.assign({},r,{parent:i,path:t}))};for(const e of["equals","is"])kp.prototype[e]=kp.prototype.oneOf;for(const e of["not","nope"])kp.prototype[e]=kp.prototype.notOneOf;const Op=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function Rp(e){var t,n;const r=Op.exec(e);return r?{year:Cp(r[1]),month:Cp(r[2],1)-1,day:Cp(r[3],1),hour:Cp(r[4]),minute:Cp(r[5]),second:Cp(r[6]),millisecond:r[7]?Cp(r[7].substring(0,3)):0,precision:null!=(t=null==(n=r[7])?void 0:n.length)?t:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:Cp(r[10]),minuteOffset:Cp(r[11])}:null}function Cp(e,t=0){return Number(e)||t}let Pp=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Mp=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Np=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Ip=new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"),Dp=e=>yp(e)||e===e.trim(),Fp={}.toString();function zp(){return new Lp}class Lp extends kp{constructor(){super({type:"string",check:e=>(e instanceof String&&(e=e.valueOf()),"string"==typeof e)}),this.withMutation(()=>{this.transform((e,t)=>{if(!this.spec.coerce||this.isType(e))return e;if(Array.isArray(e))return e;const n=null!=e&&e.toString?e.toString():e;return n===Fp?e:n})})}required(e){return super.required(e).withMutation(t=>t.test({message:e||op.required,name:"required",skipAbsent:!0,test:e=>!!e.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(e=>"required"!==e.OPTIONS.name),e))}length(e,t=ap.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(t){return t.length===this.resolve(e)}})}min(e,t=ap.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t.length>=this.resolve(e)}})}max(e,t=ap.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(t){return t.length<=this.resolve(e)}})}matches(e,t){let n,r,i=!1;return t&&("object"==typeof t?({excludeEmptyString:i=!1,message:n,name:r}=t):n=t),this.test({name:r||"matches",message:n||ap.matches,params:{regex:e},skipAbsent:!0,test:t=>""===t&&i||-1!==t.search(e)})}email(e=ap.email){return this.matches(Pp,{name:"email",message:e,excludeEmptyString:!0})}url(e=ap.url){return this.matches(Mp,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=ap.uuid){return this.matches(Np,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let t,n,r="";return e&&("object"==typeof e?({message:r="",allowOffset:t=!1,precision:n}=e):r=e),this.matches(Ip,{name:"datetime",message:r||ap.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:r||ap.datetime_offset,params:{allowOffset:t},skipAbsent:!0,test:e=>{if(!e||t)return!0;const n=Rp(e);return!!n&&!!n.z}}).test({name:"datetime_precision",message:r||ap.datetime_precision,params:{precision:n},skipAbsent:!0,test:e=>{if(!e||null==n)return!0;const t=Rp(e);return!!t&&t.precision===n}})}ensure(){return this.default("").transform(e=>null===e?"":e)}trim(e=ap.trim){return this.transform(e=>null!=e?e.trim():e).test({message:e,name:"trim",test:Dp})}lowercase(e=ap.lowercase){return this.transform(e=>yp(e)?e:e.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>yp(e)||e===e.toLowerCase()})}uppercase(e=ap.uppercase){return this.transform(e=>yp(e)?e:e.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>yp(e)||e===e.toUpperCase()})}}zp.prototype=Lp.prototype;function jp(){return new Vp}class Vp extends kp{constructor(){super({type:"number",check:e=>(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&!(e=>e!=+e)(e))}),this.withMutation(()=>{this.transform((e,t)=>{if(!this.spec.coerce)return e;let n=e;if("string"==typeof n){if(n=n.replace(/\s/g,""),""===n)return NaN;n=+n}return this.isType(n)||null===n?n:parseFloat(n)})})}min(e,t=lp.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t>=this.resolve(e)}})}max(e,t=lp.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(t){return t<=this.resolve(e)}})}lessThan(e,t=lp.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(t){return t<this.resolve(e)}})}moreThan(e,t=lp.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(t){return t>this.resolve(e)}})}positive(e=lp.positive){return this.moreThan(0,e)}negative(e=lp.negative){return this.lessThan(0,e)}integer(e=lp.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:e=>Number.isInteger(e)})}truncate(){return this.transform(e=>yp(e)?e:0|e)}round(e){var t;let n=["ceil","floor","round","trunc"];if("trunc"===(e=(null==(t=e)?void 0:t.toLowerCase())||"round"))return this.truncate();if(-1===n.indexOf(e.toLowerCase()))throw new TypeError("Only valid options for round() are: "+n.join(", "));return this.transform(t=>yp(t)?t:Math[e](t))}}jp.prototype=Vp.prototype;let Up=new Date("");function Bp(){return new Gp}class Gp extends kp{constructor(){super({type:"date",check(e){return t=e,"[object Date]"===Object.prototype.toString.call(t)&&!isNaN(e.getTime());var t}}),this.withMutation(()=>{this.transform((e,t)=>!this.spec.coerce||this.isType(e)||null===e?e:(e=function(e){const t=Rp(e);if(!t)return Date.parse?Date.parse(e):Number.NaN;if(void 0===t.z&&void 0===t.plusMinus)return new Date(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond).valueOf();let n=0;return"Z"!==t.z&&void 0!==t.plusMinus&&(n=60*t.hourOffset+t.minuteOffset,"+"===t.plusMinus&&(n=0-n)),Date.UTC(t.year,t.month,t.day,t.hour,t.minute+n,t.second,t.millisecond)}(e),isNaN(e)?Gp.INVALID_DATE:new Date(e)))})}prepareParam(e,t){let n;if(_p.isRef(e))n=e;else{let r=this.cast(e);if(!this._typeCheck(r))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);n=r}return n}min(e,t=up.min){let n=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(e){return e>=this.resolve(n)}})}max(e,t=up.max){let n=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(e){return e<=this.resolve(n)}})}}function $p(e,t){let n=1/0;return e.some((e,r)=>{var i;if(null!=(i=t.path)&&i.includes(e))return n=r,!0}),n}function qp(e){return(t,n)=>$p(e,t)-$p(e,n)}Gp.INVALID_DATE=Up,Bp.prototype=Gp.prototype,Bp.INVALID_DATE=Up;const Hp=(e,t,n)=>{if("string"!=typeof e)return e;let r=e;try{r=JSON.parse(e)}catch(e){}return n.isType(r)?r:e};function Wp(e){if("fields"in e){const t={};for(const[n,r]of Object.entries(e.fields))t[n]=Wp(r);return e.setFields(t)}if("array"===e.type){const t=e.optional();return t.innerType&&(t.innerType=Wp(t.innerType)),t}return"tuple"===e.type?e.optional().clone({types:e.spec.types.map(Wp)}):"optional"in e?e.optional():e}let Zp=e=>"[object Object]"===Object.prototype.toString.call(e);function Kp(e,t){let n=Object.keys(e.fields);return Object.keys(t).filter(e=>-1===n.indexOf(e))}const Xp=qp([]);function Yp(e){return new Qp(e)}class Qp extends kp{constructor(e){super({type:"object",check:e=>Zp(e)||"function"==typeof e}),this.fields=Object.create(null),this._sortErrors=Xp,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,t={}){var n;let r=super._cast(e,t);if(void 0===r)return this.getDefault(t);if(!this._typeCheck(r))return r;let i=this.fields,s=null!=(n=t.stripUnknown)?n:this.spec.noUnknown,o=[].concat(this._nodes,Object.keys(r).filter(e=>!this._nodes.includes(e))),a={},l=Object.assign({},t,{parent:a,__validating:t.__validating||!1}),u=!1;for(const e of o){let n=i[e],o=e in r,c=r[e];if(n){let i;l.path=(t.path?`${t.path}.`:"")+e,n=n.resolve({value:c,context:t.context,parent:a});let s=n instanceof kp?n.spec:void 0,o=null==s?void 0:s.strict;if(null!=s&&s.strip){u=u||e in r;continue}i=t.__validating&&o?c:n.cast(c,l),void 0!==i&&(a[e]=i)}else o&&!s&&(a[e]=c);o===e in a&&a[e]===c||(u=!0)}return u?a:r}_validate(e,t={},n,r){let{from:i=[],originalValue:s=e,recursive:o=this.spec.recursive}=t;t.from=[{schema:this,value:s},...i],t.__validating=!0,t.originalValue=s,super._validate(e,t,n,(e,i)=>{if(!o||!Zp(i))return void r(e,i);s=s||i;let a=[];for(let e of this._nodes){let n=this.fields[e];n&&!_p.isRef(n)&&a.push(n.asNestedTest({options:t,key:e,parent:i,parentPath:t.path,originalParent:s}))}this.runTests({tests:a,value:i,originalValue:s,options:t},n,t=>{r(t.sort(this._sortErrors).concat(e),i)})})}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),n=t.fields;for(let[e,t]of Object.entries(this.fields)){const r=n[e];n[e]=void 0===r?t:r}return t.withMutation(t=>t.setFields(n,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let t={};return this._nodes.forEach(n=>{var r;const i=this.fields[n];let s=e;null!=(r=s)&&r.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[n]})),t[n]=i&&"getDefault"in i?i.getDefault(s):void 0}),t}setFields(e,t){let n=this.clone();return n.fields=e,n._nodes=function(e,t=[]){let n=[],r=new Set,i=new Set(t.map(([e,t])=>`${e}-${t}`));function s(e,t){let s=Vf.split(e)[0];r.add(s),i.has(`${t}-${s}`)||n.push([t,s])}for(const t of Object.keys(e)){let n=e[t];r.add(t),_p.isRef(n)&&n.isSibling?s(n.path,t):fp(n)&&"deps"in n&&n.deps.forEach(e=>s(e,t))}return qf.array(Array.from(r),n).reverse()}(e,t),n._sortErrors=qp(Object.keys(e)),t&&(n._excludedEdges=t),n}shape(e,t=[]){return this.clone().withMutation(n=>{let r=n._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),r=[...n._excludedEdges,...t]),n.setFields(Object.assign(n.fields,e),r)})}partial(){const e={};for(const[t,n]of Object.entries(this.fields))e[t]="optional"in n&&n.optional instanceof Function?n.optional():n;return this.setFields(e)}deepPartial(){return Wp(this)}pick(e){const t={};for(const n of e)this.fields[n]&&(t[n]=this.fields[n]);return this.setFields(t,this._excludedEdges.filter(([t,n])=>e.includes(t)&&e.includes(n)))}omit(e){const t=[];for(const n of Object.keys(this.fields))e.includes(n)||t.push(n);return this.pick(t)}from(e,t,n){let r=Vf.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return((e,t)=>{const n=[...Vf.normalizePath(t)];if(1===n.length)return n[0]in e;let r=n.pop(),i=Vf.getter(Vf.join(n),!0)(e);return!(!i||!(r in i))})(i,e)&&(s=Object.assign({},i),n||delete s[e],s[t]=r(i)),s})}json(){return this.transform(Hp)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||cp.exact,test(e){if(null==e)return!0;const t=Kp(this.schema,e);return 0===t.length||this.createError({params:{properties:t.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,t=cp.noUnknown){"boolean"!=typeof e&&(t=e,e=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:t,test(t){if(null==t)return!0;const n=Kp(this.schema,t);return!e||0===n.length||this.createError({params:{unknown:n.join(", ")}})}});return n.spec.noUnknown=e,n}unknown(e=!0,t=cp.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform(t=>{if(!t)return t;const n={};for(const r of Object.keys(t))n[e(r)]=t[r];return n})}camelCase(){return this.transformKeys(Bf.camelCase)}snakeCase(){return this.transformKeys(Bf.snakeCase)}constantCase(){return this.transformKeys(e=>Bf.snakeCase(e).toUpperCase())}describe(e){const t=(e?this.resolve(e):this).clone(),n=super.describe(e);n.fields={};for(const[i,s]of Object.entries(t.fields)){var r;let t=e;null!=(r=t)&&r.value&&(t=Object.assign({},t,{parent:t.value,value:t.value[i]})),n.fields[i]=s.describe(t)}return n}}function Jp(e){return new eg(e)}Yp.prototype=Qp.prototype;class eg extends kp{constructor(e){super({type:"array",spec:{types:e},check:e=>Array.isArray(e)}),this.innerType=void 0,this.innerType=e}_cast(e,t){const n=super._cast(e,t);if(!this._typeCheck(n)||!this.innerType)return n;let r=!1;const i=n.map((e,i)=>{const s=this.innerType.cast(e,Object.assign({},t,{path:`${t.path||""}[${i}]`,parent:n,originalValue:e,value:e,index:i}));return s!==e&&(r=!0),s});return r?i:n}_validate(e,t={},n,r){var i;let s=this.innerType,o=null!=(i=t.recursive)?i:this.spec.recursive;null!=t.originalValue&&t.originalValue,super._validate(e,t,n,(i,a)=>{var l;if(!o||!s||!this._typeCheck(a))return void r(i,a);let u=new Array(a.length);for(let n=0;n<a.length;n++){var c;u[n]=s.asNestedTest({options:t,index:n,parent:a,parentPath:t.path,originalParent:null!=(c=t.originalValue)?c:e})}this.runTests({value:a,tests:u,originalValue:null!=(l=t.originalValue)?l:e,options:t},n,e=>r(e.concat(i),a))})}clone(e){const t=super.clone(e);return t.innerType=this.innerType,t}json(){return this.transform(Hp)}concat(e){let t=super.concat(e);return t.innerType=this.innerType,e.innerType&&(t.innerType=t.innerType?t.innerType.concat(e.innerType):e.innerType),t}of(e){let t=this.clone();if(!fp(e))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+Qf(e));return t.innerType=e,t.spec=Object.assign({},t.spec,{types:e}),t}length(e,t=hp.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(t){return t.length===this.resolve(e)}})}min(e,t){return t=t||hp.min,this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t.length>=this.resolve(e)}})}max(e,t){return t=t||hp.max,this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(t){return t.length<=this.resolve(e)}})}ensure(){return this.default(()=>[]).transform((e,t)=>this._typeCheck(e)?e:null==t?[]:[].concat(t))}compact(e){let t=e?(t,n,r)=>!e(t,n,r):e=>!!e;return this.transform(e=>null!=e?e.filter(t):e)}describe(e){const t=(e?this.resolve(e):this).clone(),n=super.describe(e);if(t.innerType){var r;let i=e;null!=(r=i)&&r.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[0]})),n.innerType=t.innerType.describe(i)}return n}}Jp.prototype=eg.prototype;const tg="Данное поле обязательно для заполнения",ng=()=>zp(),rg=(e=tg)=>ng().required(e),ig=jp(),sg=ig.required(tg),og=Jp(),ag=Bp().required(tg),lg={future_maintanance_date:ag,placement_date:ag,rapair_performed_date:ag,verification_date:ag,warranty_expr_date:ag},ug={lat:sg,lon:sg},cg={dit_id:sg,tsodd_id:sg},hg=j(T)(()=>{const{spacing:e}=V();return{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:e(2)}}),dg=j(T)(()=>{const{spacing:e}=V();return{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:e(2),justifyItems:"flex-start"}});var fg={global:{links:{getIsConstruction:"function (feature) {\n const { construction } = feature;\n\n return construction;\n}\n",getIsFunctionalClass:"function (feature) {\n const { functional_class, access_id } = feature;\n\n return functional_class === 5 && access_id === 32;\n}\n",getIsLowMobility:"function (feature) {\n const { functional_class, low_mobility } = feature;\n\n return functional_class === 5 && low_mobility === 1;\n}\n"}},cameras:{camera1:{type:"perspective",vanishing_point:[0,-500]}},textures:{arrow:{url:"https://dalganmap.ru/api-image/images/arrow-20.png",sprites:{base:[0,0,20,20]}},"traffic-signal":{url:"https://dalganmap.ru/api-image/images/conditions/traffic-signal.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},pedestrian_crossing:{url:"https://dalganmap.ru/api-image/images/conditions/pedestrian_crossing.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},physical:{url:"https://dalganmap.ru/api-image/images/conditions/physical.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},gate:{url:"https://dalganmap.ru/api-image/images/conditions/gate.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_3578:{url:"https://dalganmap.ru/api-image/images/POI/3578.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5813:{url:"https://dalganmap.ru/api-image/images/POI/5813.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5541:{url:"https://dalganmap.ru/api-image/images/POI/5541.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5540:{url:"https://dalganmap.ru/api-image/images/POI/5540.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9530(Mail)":{url:"https://dalganmap.ru/api-image/images/POI/mail.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9530(Delivery)":{url:"https://dalganmap.ru/api-image/images/POI/delivery.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5400:{url:"https://dalganmap.ru/api-image/images/POI/5400.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_6000:{url:"https://dalganmap.ru/api-image/images/POI/6000.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_9565:{url:"https://dalganmap.ru/api-image/images/POI/9565.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_9583:{url:"https://dalganmap.ru/api-image/images/POI/9583.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_8060:{url:"https://dalganmap.ru/api-image/images/POI/8060.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5511:{url:"https://dalganmap.ru/api-image/images/POI/5511.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5512:{url:"https://dalganmap.ru/api-image/images/POI/5512.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5800:{url:"https://dalganmap.ru/api-image/images/POI/5800.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_5999:{url:"https://dalganmap.ru/api-image/images/POI/5999.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7011:{url:"https://dalganmap.ru/api-image/images/POI/7011.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7389:{url:"https://dalganmap.ru/api-image/images/POI/7389.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7832:{url:"https://dalganmap.ru/api-image/images/POI/7832.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7929:{url:"https://dalganmap.ru/api-image/images/POI/7929.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7990:{url:"https://dalganmap.ru/api-image/images/POI/7990.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_7999:{url:"https://dalganmap.ru/api-image/images/POI/7999.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_8410:{url:"https://dalganmap.ru/api-image/images/POI/8410.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_9517:{url:"https://dalganmap.ru/api-image/images/POI/9517.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},POI_9718:{url:"https://dalganmap.ru/api-image/images/POI/9718.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(mosque)":{url:"https://dalganmap.ru/api-image/images/POI/9992_mosque.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(church)":{url:"https://dalganmap.ru/api-image/images/POI/9992_church.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(temple)":{url:"https://dalganmap.ru/api-image/images/POI/9992_temple.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(davidStar)":{url:"https://dalganmap.ru/api-image/images/POI/9992_davidStar.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_9992(mortar)":{url:"https://dalganmap.ru/api-image/images/POI/9992_mortar.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_4100(metro)":{url:"https://dalganmap.ru/api-image/images/POI/4100_metro.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}},"POI_4100(diameter)":{url:"https://dalganmap.ru/api-image/images/POI/4100_diameter.png",filtering:"mipmap",sprites:{base:[0,0,41,15]}},POI_4013:{url:"https://dalganmap.ru/api-image/images/POI/4013.png",filtering:"mipmap",sprites:{base:[0,0,20,20]}}},layers:null,styles:{buildings:{base:"polygons",shaders:{blocks:{color:"color.rgb;\n"}}}},lights:{light1:{type:"directional",direction:[.1,.5,-1],diffuse:.7,ambient:.5}},sources:null};const pg=e=>{const t=[],n={source:e,layer:gf.BUILDING_AREA,minzoom:15},r={id:sn(),data:n,extruded:{draw:{polygons:{style:"buildings",extrude:"function() {\n return $zoom >= 17;\n }"}}},draw:{polygons:{color:"#DDB07B",height:{property:"height"}},lines:{color:"#DB933F",width:"2px",cap:"round",join:"round"}}};return t.push(r),t},gg=e=>{const t=[],n={source:e,layer:gf.BUILTUP_AREA},r={id:sn(),data:n,draw:{polygons:{color:"#CFC8C8"}}};return t.push(r),t},mg=e=>{const t=[],n={source:e,layer:gf.ADMIN_AREA},r={id:sn(),data:n,draw:{polygons:{color:"#D3D2CF"}}},i={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'R';\n\n return isFilter;\n }",draw:{lines:{color:"#696969",width:"1px",cap:"round",join:"round"}}},s={id:sn(),data:n,filter:"function() {\n const { type } = feature;\n\n const isFilter = type === 'D' && $zoom >= 12;\n\n return isFilter;\n }",draw:{lines:{color:"#696969",dash:[4,7],width:"1px",cap:"round",join:"round"}}};return t.push(r,i,s),t},_g={size:20,extension:"png",apiName:"camera"},yg={comment:null,camera_model:null,fixing_type:[],direction:0,status:Mf.ACTIVE},vg={...Of,...Cf,...yg},bg=e=>{const t=[],n={source:e,layer:gf.CAMERA},r={},i="camera";r[i]={url:`${wf}/msk/${i}/${i}_${_g.size}.${_g.extension}`,filtering:"mipmap",sprites:{base:[0,0,_g.size,_g.size]}};const s={id:sn(),data:n,draw:{points:{collide:!1,texture:i,size:_g.size,sprite:"base",placement:"midpoint"}},textures:r,sublayers:{}};return t.push(s),t},xg=e=>e.map(e=>({value:e})),wg=e=>e.map(({value:e})=>e);function Ag({name:t,items:n,label:r,sx:i,getLabel:s,getValue:o,getKey:a}){const{watch:l,resetField:u,setValue:c}=Tu(),h=l(t),d=e.useId(),f=n.find(e=>o(e)===h)??null;return b(q,{value:f,options:n,id:d,getOptionLabel:e=>s(e),getOptionKey:e=>a(e),sx:{minWidth:150,...i},size:"small",onChange:(e,n)=>{n?c(t,o(n)):u(t)},renderInput:e=>b(Fc,{...e,label:r})})}var Eg=gl(()=>{const{control:e,register:t,resetField:n}=Tu(),{fields:r,append:i,remove:s}=kc({control:e,name:"fixing_type"});return b(Hl,{children:x(T,{sx:({spacing:e})=>({display:"grid",gap:e(2)}),children:[x(T,{sx:({spacing:e})=>({display:"flex",gap:e(1),alignItems:"center",margin:"0 auto"}),children:[b(Rc,{sx:{textAlign:"center",fontWeight:700},variant:"h6",children:"Нарушения"}),b(Gl,{title:"Сброс нарушений",iconProps:{name:"reset",color:"warning"},color:"warning",onClick:()=>{n("fixing_type")}})]}),b(T,{sx:({spacing:e})=>({display:"grid",gap:e(2)}),children:r.map(({id:e},n)=>x(T,{sx:({spacing:e})=>({display:"flex",gap:e(2),alignItems:"center"}),children:[b(pf,{...t(`fixing_type.${n}.value`),label:"Название нарушения",rows:4,fullWidth:!0,multiline:!0}),b(Ul,{onDelete:()=>{s(n)}})]},e))}),b(jl,{onClick:()=>{i({value:""})},children:"Добавить нарушение"})]})})});const Sg=Yp().shape({value:rg()}).required(),Tg={camera_model:ng().nullable(),fixing_type:og.of(Sg).required(),status:rg(),comment:ng().nullable(),direction:ig.nullable()},kg={...cg,camera_id:rg(),pillar_id:ng().nullable()},Og=Yp().shape({...cg,...lg,...Tg}),Rg=(e,t,n)=>{if(e&&"reportValidity"in e){const r=ou(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Cg=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?Rg(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>Rg(t,n,e))}},Pg=(e,t)=>{t.shouldUseNativeValidation&&Cg(e,t);const n={};for(const r in e){const i=ou(t.fields,r),s=Object.assign(e[r]||{},{ref:i&&i.ref});if(Mg(t.names||Object.keys(e),r)){const e=Object.assign({},ou(n,r));uu(e,"root",s),uu(n,r,e)}else uu(n,r,s)}return n},Mg=(e,t)=>{const n=Ng(t);return e.some(e=>Ng(e).match(`^${n}\\.\\d+`))};function Ng(e){return e.replace(/\]|\[/g,"")}function Ig(e,t,n){return void 0===n&&(n={}),function(r,i,s){try{return Promise.resolve(function(o,a){try{var l=(null!=t&&t.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e["sync"===n.mode?"validateSync":"validate"](r,Object.assign({abortEarly:!1},t,{context:i}))).then(function(e){return s.shouldUseNativeValidation&&Cg({},s),{values:n.raw?Object.assign({},r):e,errors:{}}}))}catch(e){return a(e)}return l&&l.then?l.then(void 0,a):l}(0,function(e){if(!e.inner)throw e;return{values:{},errors:Pg((t=e,n=!s.shouldUseNativeValidation&&"all"===s.criteriaMode,(t.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var r=e[t.path].types,i=r&&r[t.type];e[t.path]=Fu(t.path,n,e,t.type,i?[].concat(i,t.message):t.message)}return e},{})),s)};var t,n}))}catch(e){return Promise.reject(e)}}}var Dg=gl(({onSubmit:t})=>{const n=e.useId(),r=Oc({resolver:Ig(Og),defaultValues:{...vg,fixing_type:vg.fixing_type.map(e=>({value:e}))}}),{register:i,formState:{errors:s}}=r;return e.useEffect(()=>{Object.keys(s).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignCreateForm",meta:s})},[s]),x(Ic,{form:r,onSubmit:e=>{const{fixing_type:n}=e;t({...e,fixing_type:wg(n)})},children:[b(Ag,{...i("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(Eg,{}),b(pf,{...i("camera_model"),label:If.camera_model}),b(pf,{...i("comment"),label:If.comment}),b(pf,{...i("direction"),label:If.direction,type:"number"}),b(hg,{children:Rf.map(e=>b(zc,{...i(e),label:If[e],format:Df},`${n}-${e}`))}),b(jl,{type:"submit",children:"Сохранить"})]})});const Fg=Yp().shape({...lg,...ug,...kg,...Tg});var zg=gl(({camera:t,getButtons:n,onSubmit:r,onDelete:i})=>{const s=e.useId(),o=e.useMemo(()=>{const{fixing_type:e}=t;return{...t,...by(t),fixing_type:xg(e)}},[t]),a=Oc({resolver:Ig(Fg),defaultValues:o}),{reset:l,register:u,formState:{errors:c}}=a;return e.useEffect(()=>{Object.keys(c).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignUpdateForm",meta:c})},[c]),e.useEffect(()=>{l(o)},[o]),x(Ic,{form:a,onSubmit:e=>{const{fixing_type:t}=e;r({...e,fixing_type:wg(t)})},children:[b(Ag,{...u("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(Eg,{}),b(pf,{...u("camera_model"),label:If.signal_model}),b(pf,{...u("comment"),label:If.comment}),b(pf,{...u("direction"),label:If.direction,type:"number"}),b(hg,{children:Rf.map(e=>b(zc,{...u(e),label:If[e],format:Df},`${s}-${e}`))}),x(dg,{children:[b(jl,{type:"submit",fullWidth:!0,children:"Сохранить"}),x(dg,{children:[b(Ul,{notification:{title:"Удалить камеру",description:"Вы действительно хотите удалить данную камеру?"},onDelete:()=>{i(t)}}),n?.(t)]})]})]})});const Lg=e=>{const t=[],n={source:e,layer:gf.CITY_POI},r={id:sn(),data:n,filter:"function() {\n const { capital_order8, capital_order2, capital_order1, poi_name, priority } = feature;\n\n if ($zoom >= 9 && $zoom < 13) {\n return priority < 8;\n }\n\n if ($zoom <= 11) {\n return capital_order8 === 'Y';\n }\n\n if ($zoom >= 15) {\n return capital_order2 !== 'Y';\n }\n\n return true;\n }\n ",draw:{text:{text_source:"poi_name",priority:"function () {\n const { priority } = feature;\n\n if ($zoom <= 15) {\n return priority;\n }\n\n return 1;\n }\n ",font:{fill:"black",size:"function() {\n const { capital_order8 } = feature;\n\n if (capital_order8 === 'Y') {\n return '16px';\n }\n\n return '12px';\n }",weight:"function() {\n const { capital_order2 } = feature;\n\n if (capital_order2 === 'Y') {\n return 'bold';\n }\n\n return 'normal';\n }",stroke:{color:"white",width:"2px"}}}}};return t.push(r),t};var jg;!function(e){e.traffic_signal="traffic_signal",e.pedestrian_crossing="pedestrian_crossing",e.physical="physical",e.gate="gate"}(jg||(jg={}));const Vg=e=>{const t=[],n={},r={source:e,layer:gf.CONDITIONS},i={id:sn(),data:r};return Object.values(jg).forEach(e=>{n[`_${e}`]={filter:`function() {\n const { type } = feature;\n\n const isShow = type === '${e}';\n\n return isShow;\n }`,draw:{points:{texture:e,sprite:"base",placement:"midpoint"}}}}),i.sublayers=n,t.push(i),t},Ug=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.FACILITY_AREA},draw:{polygons:{color:"function() {\n const { feature_type } = feature;\n\n switch (feature_type) {\n case '2000408': {\n return '#DBBAC4';\n }\n\n case '1900403': {\n return '#B6C3C7';\n }\n\n case '1907403': {\n return '#A3B9C0';\n }\n\n case '2000123': {\n return '#E4BA7D';\n }\n\n case '2000124': {\n return '#BFE6E3';\n }\n\n case '2000200': {\n return '#A0A9A8';\n }\n\n case '2000403': {\n return '#AF7136';\n }\n\n case '2000420': {\n return '#89AC76';\n }\n\n case '2000457': {\n return '#9494C0';\n }\n\n default: {\n return '#E1D4D4';\n }\n }\n }",order:"function() {\n const { feature_type } = feature;\n\n switch (feature_type) {\n case '1907403': {\n return 301;\n }\n\n default: {\n return 300;\n }\n }\n }"},lines:{color:"#857F7F",width:"2px",cap:"round",join:"round"}}},r={id:sn(),data:{source:e,layer:gf.FACILITY_AREA_LABEL},draw:{text:{text_source:"name",font:{fill:"function() {\n const { feature_type } = feature;\n\n switch(feature_type) {\n case '1900403':\n case '1907403': {\n return '#256D7B';\n }\n\n case '2000420':\n case '2000460':\n case '2000123': {\n return '#00541F';\n }\n\n case '2000408': {\n return '#5E2129';\n }\n\n case '2000124': {\n return '#3E5F8A';\n }\n\n case '2000200': {\n return '#464451';\n }\n\n case '2000403': {\n return '#B03F35';\n }\n\n case '2000457': {\n return '#6A5ACD';\n }\n\n case '1700215':\n case '900159':\n case '900158': {\n return '#474A51';\n }\n\n default: {\n return black;\n }\n }\n }",size:"12px",stroke:{color:"white",width:"3px"}}}}};return t.push(n,r),t},Bg=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.LANDUSE_AREA},draw:{polygons:{color:"function() {\n const { feature_type } = feature;\n\n switch (feature_type) {\n case '509998': {\n return '#ECD175';\n }\n\n case '600102':\n case '900140': {\n return '#3E9A8C';\n }\n\n case '900202':\n case '900130':\n case '900150':\n case '900103': {\n return '#96BE7D';\n }\n\n case '9997010': {\n return null;\n }\n }\n }",order:"function() {\n const { feature_type } = feature;\n\n switch(feature_type) {\n case '900150':\n case '900130':\n case '509998': {\n return 300;\n }\n\n default: {\n return 299;\n }\n }\n }"}}},r={id:sn(),data:{source:e,layer:gf.LANDUSE_AREA_LABEL},filter:"function() {\n return $zoom >= 15;\n }",draw:{text:{text_source:"name",font:{size:"13px",fill:"function() {\n const { feature_type } = feature;\n\n switch(feature_type) {\n case '509998': {\n return '#CD7F32';\n }\n\n default: {\n return '#00541F';\n }\n }\n }",stroke:{color:"white",width:"3px"}}}}};return t.push(n,r),t},Gg=[-1,-.5,-.3,0,.3,.5,.7,1,1.5,2],$g=[[5],[4,3],[2,1]],qg="function() {\n const { functional_class, tunnel, tollway } = feature;\n\n const alpha = tunnel ? 0.89 : 1;\n\n const getRGB = (hex, alpha) => {\n const r = +(parseInt(hex.slice(1, 3), 16) / 255).toFixed(2);\n const g = +(parseInt(hex.slice(3, 5), 16) / 255).toFixed(2);\n const b = +(parseInt(hex.slice(5, 7), 16) / 255).toFixed(2);\n\n return [r, g, b, alpha];\n }\n\n if (tollway) {\n return '#D72740';\n }\n\n switch (functional_class) {\n case 1:\n case 2: {\n const color = getRGB('#D1747F', alpha);\n\n return color;\n }\n\n case 3:\n case 4: {\n const color = getRGB('#B1A7AA', alpha);\n\n return color;\n }\n\n case 5: {\n const color = getRGB('#D5CEC3', alpha);\n\n return color;\n }\n }\n}",Hg="function() {\n const { functional_class, road_number } = feature;\n\n const getScale = () => {\n if ($zoom <= 15 && $zoom >= 14) { return 7; }\n\n if ($zoom <= 13 && $zoom >= 12) { return 9; }\n\n if ($zoom <= 5) { return 400; }\n\n if ($zoom <= 7) { return 200; }\n\n if ($zoom < 12) { return 50; }\n\n return 1;\n }\n\n const scale = getScale();\n\n switch(functional_class) {\n case 1:\n case 2: {\n return 8 * scale;\n }\n\n case 3:\n case 4: {\n return 7 * scale;\n }\n\n case 5: {\n if (Boolean(road_number)) {\n return 7 * scale;\n }\n\n return 6;\n }\n }\n}",Wg=e=>{const t=[],n={source:e,layer:gf.LINK},r={id:sn(),data:n,draw:{text:{text_source:"road_number",font:{fill:"#181bff",size:"16px",weight:"bold",underline:!0,background:{color:"black"}}}}};t.push(r);const i={text_source:"street_name",font:{fill:"black",size:"14px",stroke:{color:"white",width:"3px"}}},s=()=>({text:i,lines:{color:qg,width:Hg,cap:"round",join:"round"}}),o=()=>({lines:{color:qg,width:Hg,outline:{color:"function() {\n const { functional_class, access_id, tollway } = feature;\n\n if (tollway) {\n return '#B9263B';\n }\n\n switch(functional_class) {\n case 5: {\n return '#989898';\n }\n\n case 3:\n case 4: {\n return '#8F6E78';\n }\n\n case 1:\n case 2: {\n return '#9A414B';\n }\n }\n}",width:"function() {\n const { functional_class, access_id } = feature;\n\n switch(functional_class) {\n case 5: {\n switch (access_id) {\n case 32: {\n return 0;\n }\n\n default: {\n return 1;\n }\n }\n }\n\n default: {\n return 1;\n }\n }\n}"}}});return Gg.forEach(e=>{const r=[],i=[];if(0===e)$g.forEach(t=>{const a=[],l=[];t.forEach(t=>{const r={id:sn(),data:n,filter:`function() {\n const { functional_class, z_lvl = 0.0 } = feature;\n\n const isFilter = +z_lvl === ${e} && +functional_class === ${t};\n\n return isFilter;\n }`,draw:s(),sublayers:{construction:{filter:"function() {\n return global.links.getIsConstruction(feature);\n }",draw:{lines:{width:3,color:"#9AA096",dash:[2,1]}}},functionalClassAccessId32:{filter:"function() {\n return global.links.getIsFunctionalClass(feature);\n }",draw:{lines:{width:2,color:"#9AA096",dash:[2,1]}}},lowMobility:{filter:"function() {\n return global.links.getIsLowMobility(feature);\n }",draw:{lines:{width:4}}}}},i={id:sn(),data:n,filter:`function() {\n const { functional_class, z_lvl = 0.0 } = feature;\n\n const isFilter = +z_lvl === ${e} && +functional_class === ${t} && !global.links.getIsConstruction(feature) && !global.links.getIsFunctionalClass(feature);\n\n\n return isFilter;\n }`,draw:o(),sublayers:{lowMobility:{filter:"function() {\n return global.links.getIsLowMobility(feature);\n }",draw:{lines:{width:4}}}}};a.push(r),l.push(i)}),r.push(...a),i.push(...l)});else{const t=(e=>`function() {\n const { z_lvl = 0.0 } = feature;\n\n const isFilter = +z_lvl === ${e};\n\n return isFilter;\n }`)(e),a={id:sn(),data:n,filter:t,draw:s()},l={id:sn(),data:n,filter:t,draw:o()};r.push(a),i.push(l)}t.push(...i,...r)}),t},Zg=()=>{const e=[],t={source:mf.NATURE_TILE,layer:gf.NATURE_FIELD},n={id:sn(),data:t,draw:{polygons:{color:"#EBEEC7"}}};return e.push(n),e},Kg=()=>{const e=[],t={source:mf.NATURE_TILE,layer:gf.NATURE_FOREST},n={id:sn(),data:t,draw:{polygons:{color:"function() {\n const { feature_type } = feature;\n\n switch (feature_type) {\n case '900202': {\n return '#96BE7D';\n }\n\n default : {\n return null;\n }\n }\n }"}}};return e.push(n),e},Xg=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.OCEAN_AREA},draw:{polygons:{color:"#7DBEE4"}}},r={id:sn(),data:{source:e,layer:gf.OCEAN_AREA_LABEL},draw:{text:{text_source:"name",font:{fill:"#0A80C4",size:"18px",stroke:{color:"white",width:"3px"}}}}};return t.push(n,r),t},Yg=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.ONE_WAY},draw:{points:{texture:"arrow",sprite:"base",angle:"function() {\n const { bearing } = feature;\n \n return bearing;\n }\n "}}};return t.push(n),t},Qg={size:20,extension:"png",apiName:"pillar"},Jg={description:"",height:0,comment:""},em={signs:[],signals:[],cameras:[]},tm={...Of,...Cf,...Jg},nm=e=>{const t=[],n={source:e,layer:gf.PILLAR},r={},i="pillar",s=`${wf}/msk/${i}/${i}_${Qg.size}.${Qg.extension}`;r[i]={url:s,filtering:"mipmap",sprites:{base:[0,0,Qg.size,Qg.size]}};const o={id:sn(),data:n,draw:{points:{collide:!1,texture:i,size:Qg.size,sprite:"base",placement:"midpoint"}},textures:r,sublayers:{}};return t.push(o),t},rm={comment:ng().nullable(),description:ng().nullable(),height:ig.nullable()},im={...cg,pillar_id:rg()},sm=Yp().shape({...cg,...lg,...rm});var om=gl(({onSubmit:t})=>{const n=e.useId(),r=Oc({resolver:Ig(sm),defaultValues:{...tm}}),{register:i,formState:{errors:s}}=r;return e.useEffect(()=>{Object.keys(s).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignCreateForm",meta:s})},[s]),x(Ic,{form:r,onSubmit:t,children:[b(pf,{...i("description"),label:If.description}),b(pf,{...i("height"),label:If.height,type:"number"}),b(pf,{...i("comment"),label:If.comment}),b(hg,{children:Rf.map(e=>b(zc,{...i(e),label:If[e],format:Df},`${n}-${e}`))}),b(jl,{type:"submit",children:"Сохранить"})]})});const am={1.1:{title:"Железнодорожный переезд со шлагбаумом",height:20,type:"Предупреждающие знаки"},1.2:{title:"Железнодорожный переезд без шлагбаума",height:20,type:"Предупреждающие знаки"},"1.3.1":{title:"Однопутная железная дорога",height:20,type:"Предупреждающие знаки"},"1.3.2":{title:"Многопутная железная дорога",height:20,type:"Предупреждающие знаки"},"1.4.1":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.2":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.3":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.4":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.5":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},"1.4.6":{title:"Приближение к железнодорожному переезду",height:40,type:"Предупреждающие знаки"},1.5:{title:"Пересечение с трамвайной линией",height:20,type:"Предупреждающие знаки"},1.6:{title:"Пересечение равнозначных дорог",height:20,type:"Предупреждающие знаки"},1.7:{title:"Пересечение с круговым движением",height:20,type:"Предупреждающие знаки"},1.8:{title:"Светофорное регулирование",height:20,type:"Предупреждающие знаки"},1.9:{title:"Разводной мост",height:20,type:"Предупреждающие знаки"},"1.10":{title:"Выезд на набережную",height:20,type:"Предупреждающие знаки"},"1.11.1":{title:"Опасный поворот (правый)",height:20,type:"Предупреждающие знаки"},"1.11.2":{title:"Опасный поворот (левый)",height:20,type:"Предупреждающие знаки"},"1.12.1":{title:"Опасные повороты",height:20,type:"Предупреждающие знаки"},"1.12.2":{title:"Опасные повороты",height:20,type:"Предупреждающие знаки"},1.13:{title:"Крутой спуск",height:20,type:"Предупреждающие знаки"},1.14:{title:"Крутой подъём",height:20,type:"Предупреждающие знаки"},1.15:{title:"Скользкая дорога",height:20,type:"Предупреждающие знаки"},1.16:{title:"Неровная дорога",height:20,type:"Предупреждающие знаки"},1.17:{title:"Искусственная неровность",height:20,type:"Предупреждающие знаки"},1.18:{title:"Выброс гравия",height:20,type:"Предупреждающие знаки"},1.19:{title:"Опасная обочина",height:20,type:"Предупреждающие знаки"},"1.20.1":{title:"Сужение дороги",height:20,type:"Предупреждающие знаки"},"1.20.2":{title:"Сужение дороги",height:20,type:"Предупреждающие знаки"},"1.20.3":{title:"Сужение дороги",height:20,type:"Предупреждающие знаки"},1.21:{title:"Двустороннее движение",height:20,type:"Предупреждающие знаки"},1.22:{title:"Пешеходный переход",height:20,type:"Предупреждающие знаки"},1.23:{title:"Дети",height:20,type:"Предупреждающие знаки"},1.24:{title:"Пересечение с велосипедной дорожкой или велопешеходной дорожкой",height:20,type:"Предупреждающие знаки"},1.25:{title:"Дорожные работы",height:20,type:"Предупреждающие знаки"},1.26:{title:"Перегон скота",height:20,type:"Предупреждающие знаки"},1.27:{title:"Дикие животные",height:20,type:"Предупреждающие знаки"},1.28:{title:"Падение камней",height:20,type:"Предупреждающие знаки"},1.29:{title:"Боковой ветер",height:20,type:"Предупреждающие знаки"},"1.30":{title:"Низколетящие самолёты",height:20,type:"Предупреждающие знаки"},1.31:{title:"Тоннель",height:20,type:"Предупреждающие знаки"},1.32:{title:"Затор",height:20,type:"Предупреждающие знаки"},1.33:{title:"Прочие опасности",height:20,type:"Предупреждающие знаки"},"1.34.1 A":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.1 B":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.1 C":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.2 A":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.2 B":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.2 C":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.3 A":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},"1.34.3 B":{title:"Направление поворота",height:20,type:"Предупреждающие знаки"},1.35:{title:"Участок перекрёстка",height:20,type:"Предупреждающие знаки"},2.1:{title:"Главная дорога",height:20,type:"Знаки приоритета"},2.2:{title:"Конец главной дороги",height:20,type:"Знаки приоритета"},"2.3.1":{title:"Пересечение со второстепенной дорогой",height:20,type:"Знаки приоритета"},"2.3.2":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.3":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.4":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.5":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.6":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},"2.3.7":{title:"Примыкание второстепенной дороги",height:20,type:"Знаки приоритета"},2.4:{title:"Уступите дорогу",height:20,type:"Знаки приоритета"},2.5:{title:"Движение без остановки запрещено",height:20,type:"Знаки приоритета"},2.6:{title:"Преимущество встречного движения",height:20,type:"Знаки приоритета"},2.7:{title:"Преимущество перед встречным движением",height:20,type:"Знаки приоритета"},3.1:{title:"Въезд запрещён",height:20,type:"Запрещающие знаки"},3.2:{title:"Движение запрещено",height:20,type:"Запрещающие знаки"},3.3:{title:"Движение механических транспортных средств запрещено",height:20,type:"Запрещающие знаки"},3.4:{title:"Движение грузовых автомобилей запрещено",height:20,type:"Запрещающие знаки"},3.5:{title:"Движение мотоциклов запрещено",height:20,type:"Запрещающие знаки"},3.6:{title:"Движение тракторов запрещено",height:20,type:"Запрещающие знаки"},3.7:{title:"Движение с прицепом запрещено",height:20,type:"Запрещающие знаки"},3.8:{title:"Движение гужевых повозок запрещено",height:20,type:"Запрещающие знаки"},3.9:{title:"Движение на велосипедах запрещено",height:20,type:"Запрещающие знаки"},"3.10":{title:"Движение пешеходов запрещено",height:20,type:"Запрещающие знаки"},3.11:{title:"Ограничение массы",height:20,type:"Запрещающие знаки"},3.12:{title:"Ограничение массы, приходящейся на ось транспортного средства",height:20,type:"Запрещающие знаки"},3.13:{title:"Ограничение высоты",height:20,type:"Запрещающие знаки"},3.14:{title:"Ограничение ширины",height:20,type:"Запрещающие знаки"},3.15:{title:"Ограничение длины",height:20,type:"Запрещающие знаки"},3.16:{title:"Ограничение минимальной дистанции",height:20,type:"Запрещающие знаки"},"3.17.1":{title:"Таможня",height:20,type:"Запрещающие знаки"},"3.17.2":{title:"Опасность",height:20,type:"Запрещающие знаки"},"3.17.3":{title:"Контроль",height:20,type:"Запрещающие знаки"},"3.18.1":{title:"Поворот направо запрещён",height:20,type:"Запрещающие знаки"},"3.18.2":{title:"Поворот налево запрещён",height:20,type:"Запрещающие знаки"},3.19:{title:"Разворот запрещён",height:20,type:"Запрещающие знаки"},"3.20":{title:"Обгон запрещён",height:20,type:"Запрещающие знаки"},3.21:{title:"Конец зоны запрещения обгона",height:20,type:"Запрещающие знаки"},3.22:{title:"Обгон грузовым автомобилям запрещён",height:20,type:"Запрещающие знаки"},3.23:{title:"Конец зоны запрещения обгона грузовым автомобилям",height:20,type:"Запрещающие знаки"},"3.24-50":{title:"Ограничение максимальной скорости",height:20,type:"Запрещающие знаки"},"3.25-50":{title:"Конец зоны ограничения максимальной скорости",height:20,type:"Запрещающие знаки"},3.26:{title:"Подача звукового сигнала запрещена",height:20,type:"Запрещающие знаки"},3.27:{title:"Остановка запрещена",height:20,type:"Запрещающие знаки"},3.28:{title:"Стоянка запрещена",height:20,type:"Запрещающие знаки"},3.29:{title:"Стоянка запрещена по нечётным числам месяца.",height:20,type:"Запрещающие знаки"},"3.30":{title:"Стоянка запрещена по чётным числам месяца",height:20,type:"Запрещающие знаки"},3.31:{title:"Конец зоны всех ограничений",height:20,type:"Запрещающие знаки"},3.32:{title:"Движение транспортных средств с опасными грузами запрещено",height:20,type:"Запрещающие знаки"},3.33:{title:"Движение транспортных средств с взрывчатыми и легковоспламеняющимися грузами запрещено",height:20,type:"Запрещающие знаки"},3.34:{title:"Движение автобусов запрещено",height:20,type:"Запрещающие знаки"},3.35:{title:"Движение на средствах индивидуальной мобильности запрещено",height:20,type:"Запрещающие знаки"},"4.1.1":{title:"Движение прямо",height:20,type:"Предписывающие знаки"},"4.1.2":{title:"Движение направо",height:20,type:"Предписывающие знаки"},"4.1.3":{title:"Движение налево",height:20,type:"Предписывающие знаки"},"4.1.4":{title:"Движение прямо или направо",height:20,type:"Предписывающие знаки"},"4.1.5":{title:"Движение прямо или налево",height:20,type:"Предписывающие знаки"},"4.1.6":{title:"Движение направо или налево",height:20,type:"Предписывающие знаки"},"4.2.1":{title:"Объезд препятствия справа",height:20,type:"Предписывающие знаки"},"4.2.2":{title:"Объезд препятствия слева",height:20,type:"Предписывающие знаки"},"4.2.3":{title:"Объезд препятствия справа или слева",height:20,type:"Предписывающие знаки"},4.3:{title:"Круговое движение",height:20,type:"Предписывающие знаки"},"4.4.1":{title:"Велосипедная дорожка",height:20,type:"Предписывающие знаки"},"4.4.2":{title:"Конец велосипедной дорожки",height:20,type:"Предписывающие знаки"},"4.5.1":{title:"Пешеходная дорожка",height:20,type:"Предписывающие знаки"},"4.5.2":{title:"Пешеходная и велосипедная дорожка с совмещённым движением",height:20,type:"Предписывающие знаки"},"4.5.3":{title:"Конец пешеходной и велосипедной дорожки с совмещённым движением",height:20,type:"Предписывающие знаки"},"4.5.4":{title:"Пешеходная и велосипедная дорожка с разделением движения",height:20,type:"Предписывающие знаки"},"4.5.5":{title:"Пешеходная и велосипедная дорожка с разделением движения",height:20,type:"Предписывающие знаки"},"4.5.6":{title:"Конец пешеходной и велосипедной дорожки с разделением движения",height:20,type:"Предписывающие знаки"},"4.5.7":{title:"Конец пешеходной и велосипедной дорожки с разделением движения",height:20,type:"Предписывающие знаки"},"4.6-50":{title:"Ограничение минимальной скорости",height:20,type:"Предписывающие знаки"},"4.7-50":{title:"Конец зоны ограничения минимальной скорости",height:20,type:"Предписывающие знаки"},"4.8.1":{title:"Направление движения транспортных средств с опасными грузами",height:30,type:"Предписывающие знаки"},"4.8.2":{title:"Направление движения транспортных средств с опасными грузами",height:30,type:"Предписывающие знаки"},"4.8.3":{title:"Направление движения транспортных средств с опасными грузами",height:30,type:"Предписывающие знаки"},5.1:{title:"Автомагистраль",height:30,type:"Знаки особых предписаний"},5.2:{title:"Конец автомагистрали",height:30,type:"Знаки особых предписаний"},5.3:{title:"Дорога для автомобилей",height:30,type:"Знаки особых предписаний"},5.4:{title:"Конец дороги для автомобилей",height:30,type:"Знаки особых предписаний"},5.5:{title:"Дорога с односторонним движением",height:20,type:"Знаки особых предписаний"},5.6:{title:"Конец дороги с односторонним движением",height:20,type:"Знаки особых предписаний"},"5.7.1":{title:"Выезд на дорогу с односторонним движением",height:20,type:"Знаки особых предписаний"},"5.7.2":{title:"Выезд на дорогу с односторонним движением",height:20,type:"Знаки особых предписаний"},5.8:{title:"Реверсивное движение",height:20,type:"Знаки особых предписаний"},5.9:{title:"Конец реверсивного движения",height:20,type:"Знаки особых предписаний"},"5.10":{title:"Выезд на дорогу с реверсивным движением",height:20,type:"Знаки особых предписаний"},"5.11.1":{title:"Дорога с полосой для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.11.2":{title:"Дорога с полосой для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.12.1":{title:"Конец дороги с полосой для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.12.2":{title:"Конец дороги с полосой для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.13.1":{title:"Выезд на дорогу с полосой для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.13.2":{title:"Выезд на дорогу с полосой для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.13.3":{title:"Выезд на дорогу с полосой для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.13.4":{title:"Выезд на дорогу с полосой для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.14.1":{title:"Полоса для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.14.2":{title:"Полоса для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.14.3":{title:"Конец полосы для маршрутных транспортных средств",height:20,type:"Знаки особых предписаний"},"5.14.4":{title:"Конец полосы для велосипедистов",height:20,type:"Знаки особых предписаний"},"5.15.1":{title:"Направления движения по полосам",height:20,type:"Знаки особых предписаний"},"5.15.2 A":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 B":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 C":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 D":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 E":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 F":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 G":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 H":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 I":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.2 K":{title:"Направления движения по полосе",height:20,type:"Знаки особых предписаний"},"5.15.3 A":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.3 B":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.3 C":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.4 A":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.4 B":{title:"Начало полосы",height:20,type:"Знаки особых предписаний"},"5.15.5":{title:"Конец полосы",height:20,type:"Знаки особых предписаний"},"5.15.6":{title:"Конец полосы",height:20,type:"Знаки особых предписаний"},"5.15.7 A":{title:"Направление движения по полосам",height:20,type:"Знаки особых предписаний"},"5.15.7 B":{title:"Направление движения по полосам",height:20,type:"Знаки особых предписаний"},"5.15.7 C":{title:"Направление движения по полосам",height:20,type:"Знаки особых предписаний"},"5.15.8":{title:"Число полос",height:20,type:"Знаки особых предписаний"},5.16:{title:"Место остановки автобуса и (или) троллейбуса",height:30,type:"Знаки особых предписаний"},5.17:{title:"Место остановки трамвая",height:30,type:"Знаки особых предписаний"},5.18:{title:"Место стоянки легковых такси",height:30,type:"Знаки особых предписаний"},"5.19.1":{title:"Пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.19.2":{title:"Пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.19.3":{title:"Диагональный пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.19.4 A":{title:"Диагональный пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.19.4 B":{title:"Диагональный пешеходный переход",height:20,type:"Знаки особых предписаний"},"5.20":{title:"Искусственная неровность",height:20,type:"Знаки особых предписаний"},5.21:{title:"Жилая зона",height:30,type:"Знаки особых предписаний"},5.22:{title:"Конец жилой зоны",height:30,type:"Знаки особых предписаний"},"5.23.1":{title:"Начало населённого пункта",height:20,type:"Знаки особых предписаний"},"5.23.2":{title:"Начало населённого пункта",height:20,type:"Знаки особых предписаний"},"5.24.1":{title:"Конец населённого пункта",height:20,type:"Знаки особых предписаний"},"5.24.2":{title:"Конец населённого пункта",height:20,type:"Знаки особых предписаний"},5.25:{title:"Начало населённого пункта",height:20,type:"Знаки особых предписаний"},5.26:{title:"Конец населённого пункта",height:20,type:"Знаки особых предписаний"},5.27:{title:"Зона с ограничением стоянки",height:30,type:"Знаки особых предписаний"},5.28:{title:"Конец зоны с ограничением стоянки",height:30,type:"Знаки особых предписаний"},5.29:{title:"Зона регулируемой стоянки",height:30,type:"Знаки особых предписаний"},"5.30":{title:"Конец зоны регулируемой стоянки",height:30,type:"Знаки особых предписаний"},5.31:{title:"Зона с ограничением максимальной скорости",height:30,type:"Знаки особых предписаний"},5.32:{title:"Конец зоны с ограничением максимальной скорости",height:30,type:"Знаки особых предписаний"},5.33:{title:"Пешеходная зона",height:30,type:"Знаки особых предписаний"},5.34:{title:"Конец пешеходной зоны",height:30,type:"Знаки особых предписаний"},5.35:{title:"Зона с ограничением экологического класса механических транспортных средств",height:30,type:"Знаки особых предписаний"},5.36:{title:"Конец зоны с ограничением экологического класса механических транспортных средств",height:30,type:"Знаки особых предписаний"},"5.37 A":{title:"Зона с ограничением экологического класса по видам транспортных средств",height:30,type:"Знаки особых предписаний"},"5.37 B":{title:"Зона с ограничением экологического класса по видам транспортных средств",height:30,type:"Знаки особых предписаний"},"5.38 A":{title:"Конец зоны с ограничением экологического класса по видам транспортных средств",height:30,type:"Знаки особых предписаний"},"5.38 B":{title:"Конец зоны с ограничением экологического класса по видам транспортных средств",height:30,type:"Знаки особых предписаний"},5.39:{title:"Велосипедная зона",height:30,type:"Знаки особых предписаний"},"5.40":{title:"Конец велосипедной зоны",height:30,type:"Знаки особых предписаний"},6.1:{title:"Общие ограничения максимальной скорости",height:30,type:"Информационные знаки"},"6.2-50":{title:"Рекомендуемая скорость",height:20,type:"Информационные знаки"},"6.3.1":{title:"Место для разворота",height:20,type:"Информационные знаки"},"6.3.2":{title:"Зона для разворота",height:20,type:"Информационные знаки"},"6.4 A":{title:"Парковка (парковочное место)",height:20,type:"Информационные знаки"},"6.4 B":{title:"Парковка (платные услуги)",height:20,type:"Информационные знаки"},"6.4 C":{title:"Парковка (только для инвалидов)",height:20,type:"Информационные знаки"},6.5:{title:"Полоса аварийной остановки",height:20,type:"Информационные знаки"},6.6:{title:"Подземный пешеходный переход",height:20,type:"Информационные знаки"},6.7:{title:"Надземный пешеходный переход",height:20,type:"Информационные знаки"},"6.8.1":{title:"Тупик",height:20,type:"Информационные знаки"},"6.8.2":{title:"Тупик",height:20,type:"Информационные знаки"},"6.8.3":{title:"Тупик",height:20,type:"Информационные знаки"},"6.9.1 A":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 B":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 C":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 D":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 E":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.1 F":{title:"Предварительный указатель направлений",height:20,type:"Информационные знаки"},"6.9.2 A":{title:"Предварительный указатель направления",height:20,type:"Информационные знаки"},"6.9.2 B":{title:"Предварительный указатель направления",height:20,type:"Информационные знаки"},"6.9.2 C":{title:"Предварительный указатель направления",height:20,type:"Информационные знаки"},"6.9.3":{title:"Схема движения",height:20,type:"Информационные знаки"},"6.10.1 A":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 B":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 C":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 D":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 E":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 F":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.1 G":{title:"Указатель направлений",height:20,type:"Информационные знаки"},"6.10.2 A":{title:"Указатель направления",height:20,type:"Информационные знаки"},"6.10.2 B":{title:"Указатель направления",height:20,type:"Информационные знаки"},"6.11 A":{title:"Наименование объекта",height:20,type:"Информационные знаки"},"6.11 B":{title:"Наименование объекта",height:20,type:"Информационные знаки"},"6.11 C":{title:"Наименование объекта",height:20,type:"Информационные знаки"},"6.11 D":{title:"Наименование объекта",height:20,type:"Информационные знаки"},"6.12 A":{title:"Указатель расстояний",height:20,type:"Информационные знаки"},"6.12 B":{title:"Указатель расстояний",height:20,type:"Информационные знаки"},"6.12 C":{title:"Указатель расстояний",height:20,type:"Информационные знаки"},"6.13 A":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.13 B":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.13 C":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.13 D":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.13 E":{title:"Километровый знак",height:20,type:"Информационные знаки"},"6.14.1 A":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.1 B":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.1 C":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.1 D":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.2 A":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.2 B":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.14.2 C":{title:"Номер маршрута",height:20,type:"Информационные знаки"},"6.15.1":{title:"Направление движения для грузовых автомобилей",height:20,type:"Информационные знаки"},"6.15.2":{title:"Направление движения для грузовых автомобилей",height:20,type:"Информационные знаки"},"6.15.3":{title:"Направление движения для грузовых автомобилей",height:20,type:"Информационные знаки"},6.16:{title:"Стоп-линия",height:20,type:"Информационные знаки"},6.17:{title:"Схема объезда",height:25,type:"Информационные знаки"},"6.18.1":{title:"Направление объезда",height:20,type:"Информационные знаки"},"6.18.2":{title:"Направление объезда",height:20,type:"Информационные знаки"},"6.18.3":{title:"Направление объезда",height:20,type:"Информационные знаки"},"6.19.1":{title:"Предварительный указатель перестроения на другую проезжую часть",height:25,type:"Информационные знаки"},"6.19.2":{title:"Предварительный указатель перестроения на другую проезжую часть",height:25,type:"Информационные знаки"},"6.20.1":{title:"Аварийный выход",height:20,type:"Информационные знаки"},"6.20.2":{title:"Аварийный выход",height:20,type:"Информационные знаки"},"6.21.1":{title:"Направление движения к аварийному выходу",height:20,type:"Информационные знаки"},"6.21.2":{title:"Направление движения к аварийному выходу",height:20,type:"Информационные знаки"},6.22:{title:"Фотовидеофиксация",height:20,type:"Информационные знаки"},7.1:{title:"Пункт медицинской помощи",height:30,type:"Знаки сервиса"},7.2:{title:"Больница",height:30,type:"Знаки сервиса"},7.3:{title:"Автозаправочная станция",height:30,type:"Знаки сервиса"},7.4:{title:"Техническое обслуживание автомобилей",height:30,type:"Знаки сервиса"},7.5:{title:"Мойка автомобилей",height:30,type:"Знаки сервиса"},7.6:{title:"Телефон",height:30,type:"Знаки сервиса"},7.7:{title:"Пункт питания",height:30,type:"Знаки сервиса"},7.8:{title:"Питьевая вода",height:30,type:"Знаки сервиса"},7.9:{title:"Гостиница или мотель",height:30,type:"Знаки сервиса"},"7.10":{title:"Кемпинг",height:30,type:"Знаки сервиса"},7.11:{title:"Место отдыха",height:30,type:"Знаки сервиса"},7.12:{title:"Пост ДПС",height:30,type:"Знаки сервиса"},7.13:{title:"Полиция",height:30,type:"Знаки сервиса"},"7.14.1":{title:"Пункт таможенного контроля",height:30,type:"Знаки сервиса"},"7.14.2":{title:"Пункт транспортного контроля",height:30,type:"Знаки сервиса"},7.15:{title:"Зона приёма радиостанции, передающей информацию о дорожном движении",height:30,type:"Знаки сервиса"},7.16:{title:"Зона радиосвязи с аварийными службами",height:30,type:"Знаки сервиса"},7.17:{title:"Бассейн или пляж",height:30,type:"Знаки сервиса"},7.18:{title:"Туалет",height:30,type:"Знаки сервиса"},7.19:{title:"Телефон экстренной связи",height:30,type:"Знаки сервиса"},"7.20":{title:"Огнетушитель",height:30,type:"Знаки сервиса"},7.21:{title:"Автозаправочная станция с возможностью зарядки электромобилей",height:30,type:"Знаки сервиса"}},lm={"8.1.1":{title:"Расстояние до объекта",height:20,type:"Знаки дополнительной информации"},"8.1.2":{title:"Расстояние до объекта",height:20,type:"Знаки дополнительной информации"},"8.1.3":{title:"Расстояние до объекта",height:20,type:"Знаки дополнительной информации"},"8.1.4":{title:"Расстояние до объекта",height:20,type:"Знаки дополнительной информации"},"8.2.1":{title:"Зона действия",height:20,type:"Знаки дополнительной информации"},"8.2.2":{title:"Зона действия",height:40,type:"Знаки дополнительной информации"},"8.2.3":{title:"Зона действия",height:40,type:"Знаки дополнительной информации"},"8.2.4":{title:"Зона действия",height:40,type:"Знаки дополнительной информации"},"8.2.5":{title:"Зона действия",height:20,type:"Знаки дополнительной информации"},"8.2.6":{title:"Зона действия",height:20,type:"Знаки дополнительной информации"},"8.3.1":{title:"Направления действия",height:20,type:"Знаки дополнительной информации"},"8.3.2":{title:"Направления действия",height:20,type:"Знаки дополнительной информации"},"8.3.3":{title:"Направления действия",height:20,type:"Знаки дополнительной информации"},"8.4.1":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.2":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.3.1":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.3.2":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.4":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.5":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.6":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.7.1":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.7.2":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.8":{title:"Вид транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.9":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.10":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.11":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.12":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.13":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.14":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.4.15":{title:"Кроме вида транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.5.1":{title:"Субботние, воскресные и праздничные дни",height:20,type:"Знаки дополнительной информации"},"8.5.2":{title:"Рабочие дни",height:20,type:"Знаки дополнительной информации"},"8.5.3":{title:"Дни недели",height:20,type:"Знаки дополнительной информации"},"8.5.4":{title:"Время действия",height:20,type:"Знаки дополнительной информации"},"8.5.5":{title:"Время действия",height:20,type:"Знаки дополнительной информации"},"8.5.6":{title:"Время действия",height:20,type:"Знаки дополнительной информации"},"8.5.7":{title:"Время действия",height:20,type:"Знаки дополнительной информации"},"8.6.1":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.2":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.3":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.4":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.5":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.6":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.7":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.8":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},"8.6.9":{title:"Способ постановки транспортного средства на стоянку",height:20,type:"Знаки дополнительной информации"},8.7:{title:"Стоянка с неработающим двигателем",height:20,type:"Знаки дополнительной информации"},8.8:{title:"Платные услуги",height:20,type:"Знаки дополнительной информации"},"8.9.1":{title:"Ограничение продолжительности стоянки",height:20,type:"Знаки дополнительной информации"},"8.9.2":{title:"Стоянка только для владельцев парковочных разрешений",height:20,type:"Знаки дополнительной информации"},"8.9.3":{title:"Стоянка только транспортных средств дипломатического корпуса",height:20,type:"Знаки дополнительной информации"},"8.10":{title:"Место для осмотра автомобилей",height:20,type:"Знаки дополнительной информации"},8.11:{title:"Ограничение разрешённой максимальной массы",height:20,type:"Знаки дополнительной информации"},8.12:{title:"Опасная обочина",height:20,type:"Знаки дополнительной информации"},8.13:{title:"Направление главной дороги",height:20,type:"Знаки дополнительной информации"},"8.13 B":{title:"Направление главной дороги",height:20,type:"Знаки дополнительной информации"},8.14:{title:"Полоса движения",height:20,type:"Знаки дополнительной информации"},8.15:{title:"Слепые пешеходы",height:20,type:"Знаки дополнительной информации"},8.16:{title:"Влажное покрытие",height:20,type:"Знаки дополнительной информации"},8.17:{title:"Инвалиды",height:20,type:"Знаки дополнительной информации"},8.18:{title:"Кроме инвалидов",height:20,type:"Знаки дополнительной информации"},8.19:{title:"Класс опасного груза",height:20,type:"Знаки дополнительной информации"},"8.20.1":{title:"Тип тележки транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.20.2":{title:"Тип тележки транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.21.1":{title:"Вид маршрутного транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.21.2":{title:"Вид маршрутного транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.21.3":{title:"Вид маршрутного транспортного средства",height:20,type:"Знаки дополнительной информации"},"8.22.1":{title:"Препятствие",height:68,type:"Знаки дополнительной информации"},"8.22.2":{title:"Препятствие",height:68,type:"Знаки дополнительной информации"},"8.22.3":{title:"Препятствие",height:68,type:"Знаки дополнительной информации"},8.24:{title:"Работает эвакуатор",height:20,type:"Знаки дополнительной информации"},8.25:{title:"Экологический класс транспортного средства",height:20,type:"Знаки дополнительной информации"},8.26:{title:"Зарядка электромобилей",height:20,type:"Знаки дополнительной информации"}},um={...am,...lm},cm=Object.entries(am)[0],hm=Object.entries(lm)[0],dm={comment:"",direction:0,traffic_sign_value:"",traffic_sign_number:cm[0],traffic_sign_title:cm[1].title,traffic_sign_type:cm[1].type,status:Mf.ACTIVE},fm={traffic_sign_id:sn()},pm={traffic_sign_id:sn(),dop_id:sn()},gm={comment:"",dop_sign_number:hm[0],dop_sign_title:hm[1].title,dop_sign_text:"",status:Mf.ACTIVE},mm={...Of,...Cf,...dm,dops:[]},_m={...Cf,...gm},ym={fileName:"traffic-sign",apiName:"traffic_sign",extension:"svg",dopsCount:2,widths:{map:20,preview:40}},vm={title:"Дорожные знаки"},bm={title:"Дополнительная информация"},xm=e=>{const t=[],n={source:e,layer:gf.TRAFFIC_SIGN},r={},i={};Object.keys(am).forEach(e=>{const t=`${ym.fileName}-${e}`,{height:n}=am[e],s=wm({type:"map",number:e});r[t]={url:s,filtering:"mipmap",sprites:{base:[0,0,ym.widths.map,n]}},i[t]={filter:`function() {\n const { traffic_sign_number } = feature;\n\n const isFilter = traffic_sign_number === '${e}';\n\n return isFilter;\n }`,draw:{points:{collide:!1,texture:t,size:[ym.widths.map,n],sprite:"base",placement:"midpoint"}}}});const s={id:sn(),data:n,textures:r,sublayers:i};return t.push(s),t},wm=({type:e,number:t})=>{const n=ym.widths[e];return`${wf}/msk/${ym.fileName}_${n}/${t}.${ym.extension}`},Am=()=>{const e=new Set,t=[];return Object.values(am).forEach(({title:t})=>{e.add(t)}),e.forEach(e=>{t.push({label:e,value:e})}),t},Em=e=>{const t={};e.forEach(({traffic_sign_number:e,traffic_sign_title:n,traffic_sign_type:r,height:i})=>{t[e]={title:n,height:Number(i),type:r}}),rn(t)},Sm=e=>um[e].title;var Tm=gl(({disabled:e=!1,onClick:t})=>b(jl,{sx:{margin:"0 auto"},onClick:t,disabled:e,children:"Добавить табличку"}));const km=({items:t,initialValue:n,onChange:r})=>{const[i,s]=e.useState(()=>n??t[0].value),o=e.useId();return e.useEffect(()=>{n&&s(n)},[n]),x(ae,{value:i,children:[b(T,{sx:{borderBottom:1,borderColor:"divider"},children:b(le,{"aria-label":`tabs-${o}`,onChange:(e,t)=>{s(t),r?.(t)},children:t.map(({label:e,value:t})=>b(H,{label:e,value:t,sx:{textTransform:"none"}},`${o}-tab-${t}`))})}),t.map(({content:e,value:t})=>b(ue,{value:t,children:e},`${o}-tab-panel-${t}`))]})},Om="newDops";var Rm=gl(({index:t,onDelete:n})=>{const{setValue:r,register:i,watch:s}=Tu(),o=s(`${Om}.${t}`),{dop_sign_number:a}=o,l=e.useId();return x(T,{id:l,sx:{display:"grid",gap:"12px"},children:[b(Ll,{items:[{value:1,summary:x(T,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[b(Ul,{notification:{title:"Удалить табличку",description:"Вы действительно хотите удалить данную табличку?"},onDelete:n}),b(Mm,{number:a})]}),getDetails:({onClose:e})=>b(N_,{pageSize:5,filtered:{type:!1},trafficSigns:lm,onSelect:({title:n,number:i})=>{r(`${Om}.${t}.dop_sign_number`,i),r(`${Om}.${t}.dop_sign_title`,n),e()}})}]}),b(Ag,{...i(`${Om}.${t}.status`),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...i(`${Om}.${t}.comment`),label:If.comment}),b(pf,{...i(`${Om}.${t}.dop_sign_text`),label:If.dop_sign_text}),b(hg,{children:Rf.map(e=>b(zc,{...i(`${Om}.${t}.${e}`),label:If[e],format:Df},`${l}-${e}`))})]})});const Cm="oldDops";var Pm=gl(({index:t,onDelete:n,onUpdate:r})=>{const i=e.useId(),{register:s,setValue:o,watch:a}=Tu(),l=a(`${Cm}.${t}`),{dop_sign_number:u}=l;return x(T,{id:i,sx:{display:"grid",gap:"12px"},children:[b(Ll,{items:[{value:1,summary:x(T,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[b(Ul,{notification:{title:"Удалить табличку",description:"Вы действительно хотите удалить данную табличку?"},onDelete:()=>{n(l)}}),b(Mm,{number:u})]}),getDetails:({onClose:e})=>b(N_,{pageSize:5,filtered:{type:!1},trafficSigns:lm,onSelect:({title:n,number:r})=>{o(`${Cm}.${t}.dop_sign_number`,r),o(`${Cm}.${t}.dop_sign_title`,n),e()}})}]}),b(Ag,{...s(`${Cm}.${t}.status`),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...s(`${Cm}.${t}.comment`),label:If.comment}),b(pf,{...s(`${Cm}.${t}.dop_sign_text`),label:If.dop_sign_text}),b(hg,{children:Rf.map(e=>b(zc,{...s(`${Cm}.${t}.${e}`),label:If[e],format:Df},`${i}-${e}`))}),b(jl,{onClick:()=>{r(l)},children:"Сохранить"})]})});var Mm=gl(({number:e})=>{const t=Sm(e);return x(T,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[b(C_,{number:e}),x(B,{children:[t," (",e,")"]})]})});
|
|
11
11
|
/**
|
|
12
12
|
* table-core
|
|
13
13
|
*
|
|
@@ -28,5 +28,5 @@ import*as e from"react";import t,{forwardRef as n,useRef as r,useCallback as i,u
|
|
|
28
28
|
*
|
|
29
29
|
* @license MIT
|
|
30
30
|
*/
|
|
31
|
-
function R_(t,n){return t?function(e){return"function"==typeof e&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}(r=t)||"function"==typeof r||function(e){return"object"==typeof e&&"symbol"==typeof e.$$typeof&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}(r)?e.createElement(t,n):t:null;var r}var C_=gl(({number:t})=>{const n=e.useId(),r=e.useRef(null),i=wm({type:"preview",number:t}),{height:s}=um[t];return b("img",{src:i,id:n,width:ym.widths.preview,height:2*s,ref:r,alt:`traffic-sign-${t}`})});const P_={height:"",title:If.traffic_sign_title,type:If.traffic_sign_type,number:If.traffic_sign_number};var M_=gl(({options:e,label:t,column:n})=>{const r=n.getFilterValue(),i=e.find(({value:e})=>e===r);return b(q,{value:i??null,options:e,id:n.id,getOptionLabel:({label:e})=>e,getOptionKey:({value:e})=>e,size:"small",onChange:(e,t)=>{t?n.setFilterValue(t.value):n.setFilterValue(null)},renderInput:e=>b(Fc,{...e,label:t})})});var N_=gl(({pageSize:t=15,defaultValues:n,filtered:r={},onSelect:i,trafficSigns:s})=>{const[o,a]=e.useState({}),[l,u]=e.useState([]),[c,h]=e.useState({pageIndex:0,pageSize:t}),d={accessor:(e,t)=>"function"==typeof e?{...t,accessorFn:e}:{...t,accessorKey:e},display:e=>e,group:e=>e},f=e.useMemo(()=>{const e=[{id:"image",header:()=>b(jl,{onClick:()=>{u([])},children:"Очистить все"}),cell:({row:{original:e}})=>b(C_,{number:e.number})},d.accessor("title",{cell:e=>b(Rc,{variant:"body2",sx:{textAlign:"center",cursor:"inherit"},children:e.getValue()}),footer:e=>e.column.id,header:()=>b(Rc,{variant:"body1",fontWeight:700,children:"Название знака"}),meta:{isFiltered:r?.title??!0}}),d.accessor("number",{cell:e=>{const t=e.getValue();return b(Rc,{variant:"body2",sx:{textAlign:"center",cursor:"inherit"},children:t})},footer:e=>e.column.id,header:()=>b(Rc,{variant:"body1",fontWeight:700,children:"Номер знака"}),filterFn:({original:e},t)=>{const n=l.find(e=>e.id===t);if(n){return n.value===e.number||null===n.value}return!0},meta:{isFiltered:r?.number??!0}}),d.accessor("type",{cell:e=>b(Rc,{variant:"body2",sx:{textAlign:"center",cursor:"inherit"},children:e.getValue()}),footer:e=>e.column.id,header:()=>b(Rc,{variant:"body1",fontWeight:700,children:"Тип знака"}),meta:{isFiltered:r?.type??!0}})];return e},[l,r]),p=e.useMemo(()=>{const e=Object.entries(s).map(([e,t])=>({...t,number:e}));return e},[s]),g=function(t){const n={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[r]=e.useState(()=>({current:k_(n)})),[i,s]=e.useState(()=>r.current.initialState);return r.current.setOptions(e=>({...e,...t,state:{...i,...t.state},onStateChange:e=>{s(e),null==t.onStateChange||t.onStateChange(e)}})),r.current}({data:p,columns:f,state:{columnFilters:l,rowSelection:o,pagination:c},enableRowSelection:!0,onColumnFiltersChange:u,onRowSelectionChange:a,onPaginationChange:h,getCoreRowModel:e=>Fm(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,s){void 0===i&&(i=0);const o=[];for(let l=0;l<t.length;l++){const u=Bm(e,e._getRowId(t[l],l,s),t[l],l,i,0,null==s?void 0:s.id);var a;n.flatRows.push(u),n.rowsById[u.id]=u,o.push(u),e.options.getSubRows&&(u.originalSubRows=e.options.getSubRows(t[l],l),null!=(a=u.originalSubRows)&&a.length&&(u.subRows=r(u.originalSubRows,i+1,u)))}return o};return n.rows=r(t),n},zm(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex())),getFilteredRowModel:e=>Fm(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{if(!t.rows.length||(null==n||!n.length)&&!r){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}const i=[],s=[];(null!=n?n:[]).forEach(t=>{var n;const r=e.getColumn(t.id);if(!r)return;const s=r.getFilterFn();s?i.push({id:t.id,filterFn:s,resolvedValue:null!=(n=null==s.resolveFilterValue?void 0:s.resolveFilterValue(t.value))?n:t.value}):"production"!==process.env.NODE_ENV&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${r.id}.`)});const o=(null!=n?n:[]).map(e=>e.id),a=e.getGlobalFilterFn(),l=e.getAllLeafColumns().filter(e=>e.getCanGlobalFilter());let u,c;r&&a&&l.length&&(o.push("__global__"),l.forEach(e=>{var t;s.push({id:e.id,filterFn:a,resolvedValue:null!=(t=null==a.resolveFilterValue?void 0:a.resolveFilterValue(r))?t:r})}));for(let e=0;e<t.flatRows.length;e++){const n=t.flatRows[e];if(n.columnFilters={},i.length)for(let e=0;e<i.length;e++){u=i[e];const t=u.id;n.columnFilters[t]=u.filterFn(n,t,u.resolvedValue,e=>{n.columnFiltersMeta[t]=e})}if(s.length){for(let e=0;e<s.length;e++){c=s[e];const t=c.id;if(c.filterFn(n,t,c.resolvedValue,e=>{n.columnFiltersMeta[t]=e})){n.columnFilters.__global__=!0;break}}!0!==n.columnFilters.__global__&&(n.columnFilters.__global__=!1)}}return O_(t.rows,e=>{for(let t=0;t<o.length;t++)if(!1===e.columnFilters[o[t]])return!1;return!0},e)},zm(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex())),getSortedRowModel:e=>Fm(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||null==t||!t.length)return n;const r=e.getState().sorting,i=[],s=r.filter(t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()}),o={};s.forEach(t=>{const n=e.getColumn(t.id);n&&(o[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});const a=e=>{const t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let r=0;r<s.length;r+=1){var n;const i=s[r],a=o[i.id],l=a.sortUndefined,u=null!=(n=null==i?void 0:i.desc)&&n;let c=0;if(l){const n=void 0===e.getValue(i.id),r=void 0===t.getValue(i.id);if(n||r){if("first"===l)return n?-1:1;if("last"===l)return n?1:-1;c=n&&r?0:n?l:-l}}if(0===c&&(c=a.sortingFn(e,t,i.id)),0!==c)return u&&(c*=-1),a.invertSorting&&(c*=-1),c}return e.index-t.index}),t.forEach(e=>{var t;i.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=a(e.subRows))}),t};return{rows:a(n.rows),flatRows:i,rowsById:n.rowsById}},zm(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex())),getPaginationRowModel:e=>Fm(()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded],(t,n)=>{if(!n.rows.length)return n;const{pageSize:r,pageIndex:i}=t;let{rows:s,flatRows:o,rowsById:a}=n;const l=r*i,u=l+r;let c;s=s.slice(l,u),c=e.options.paginateExpandedRows?{rows:s,flatRows:o,rowsById:a}:function(e){const t=[],n=e=>{var r;t.push(e),null!=(r=e.subRows)&&r.length&&e.getIsExpanded()&&e.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}({rows:s,flatRows:o,rowsById:a}),c.flatRows=[];const h=e=>{c.flatRows.push(e),e.subRows.length&&e.subRows.forEach(h)};return c.rows.forEach(h),c},zm(e.options,"debugTable","getPaginationRowModel"))}),m=e.useMemo(()=>{const e=new Set,t=[],n=new Set,r=[],i=new Set,s=[];return g.getCoreRowModel().rows.map(({original:{number:t,title:r,type:s}})=>{e.add(t),n.add(r),i.add(s)}),e.forEach(e=>{t.push({label:e,value:e})}),n.forEach(e=>{r.push({label:e,value:e})}),i.forEach(e=>{s.push({label:e,value:e})}),{number:t,title:r,type:s}},[g]);return e.useEffect(()=>{if(n){const e=[];Object.entries(n).forEach(([t,n])=>{e.push({id:t,value:n})}),u(e)}},[n]),x(T,{sx:{display:"grid",justifyItems:"center",gap:"10px"},children:[x(T,{component:"table",sx:{border:"1px solid black",borderCollapse:"collapse","td, th":{border:"1px solid black",padding:"10px"}},children:[b("thead",{children:g.getHeaderGroups().map(e=>b("tr",{style:{border:"1px solid black"},children:e.headers.map(e=>{const t=e.id,n=e.column.columnDef.meta;return b("th",{colSpan:e.colSpan,children:e.isPlaceholder?null:x(T,{sx:{display:"grid",gap:"12px",minWidth:200,padding:"8px 0"},children:[b(T,{sx:{display:"flex",justifyItems:"center",justifyContent:"center",gap:"12px"},children:R_(e.column.columnDef.header,e.getContext())}),n?.isFiltered?b(M_,{label:P_[t],column:e.column,options:m[t]??[]}):null]})},e.id)})},e.id))}),b("tbody",{children:g.getRowModel().rows.map(e=>b(T,{component:"tr",onClick:()=>{i(e.original),u([])},children:e.getVisibleCells().map(e=>b(T,{component:"td",sx:{cursor:"pointer",width:e.column.getSize()},children:b(T,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:R_(e.column.columnDef.cell,e.getContext())})},e.id))},e.id))})]}),x(T,{sx:{display:"flex",alignItems:"center",gap:"10px"},children:[x(T,{sx:{display:"flex",gap:"8px"},children:[b(jl,{variant:"outlined",size:"small",onClick:()=>g.setPageIndex(0),disabled:!g.getCanPreviousPage(),"aria-label":"move all right",children:"<<"}),b(jl,{variant:"outlined",size:"small",onClick:()=>g.previousPage(),disabled:!g.getCanPreviousPage(),"aria-label":"move all right",children:"<"}),b(jl,{variant:"outlined",size:"small",onClick:()=>g.nextPage(),disabled:!g.getCanNextPage(),"aria-label":"move all right",children:">"}),b(jl,{variant:"outlined",size:"small",onClick:()=>g.setPageIndex(g.getPageCount()-1),disabled:!g.getCanNextPage(),"aria-label":"move all right",children:">>"})]}),x(Rc,{fontWeight:700,children:[g.getState().pagination.pageIndex+1," из ",g.getPageCount()]})]})]})});const I_=rg(),D_={traffic_sign_id:rg(),dop_id:rg()},F_={dop_sign_number:rg(),dop_sign_title:rg(),status:I_,dop_sign_text:ng().nullable(),comment:ng().nullable()},z_=Yp().shape({...D_,...F_,...lg}),L_=Yp().shape({...F_,...lg}),j_={traffic_sign_type:rg(),traffic_sign_number:rg(),traffic_sign_title:rg(),status:I_,comment:ng().nullable(),traffic_sign_value:ng().nullable(),direction:ig.nullable()},V_={traffic_sign_id:rg(),dit_id:sg,tsodd_id:sg,pillar_id:ng().nullable()},U_=Yp().shape({dit_id:V_.dit_id,tsodd_id:V_.tsodd_id,...j_,...lg,newDops:og.max(ym.dopsCount).of(L_).required()});var B_=gl(({onSubmit:t})=>{const n=e.useId(),r=Oc({resolver:Ng(U_),defaultValues:{...mm}}),{control:i,register:s,setValue:o,watch:a,formState:{errors:l}}=r,u=kc({control:i,name:"newDops"}),c=a("traffic_sign_number");return e.useEffect(()=>{Object.keys(l).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignCreateForm",meta:l})},[l]),x(Ic,{form:r,onSubmit:t,children:[b(km,{items:[{label:vm.title,value:1,content:x(T,{sx:{display:"grid",gap:"12px"},children:[b(Ll,{items:[{value:1,summary:b(Mm,{number:c}),getDetails:({onClose:e})=>b(N_,{trafficSigns:am,pageSize:5,onSelect:({title:t,number:n,type:r})=>{o("traffic_sign_number",n),o("traffic_sign_title",t),o("traffic_sign_type",r),e()}})}]}),b(wg,{...s("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...s("traffic_sign_value"),label:If.traffic_sign_value}),b(pf,{...s("comment"),label:If.comment}),b(pf,{...s("direction"),label:If.direction,type:"number"}),b(cg,{children:Rf.map(e=>b(zc,{...s(e),label:If[e],format:Df},`${n}-${e}`))})]})},{label:bm.title,value:2,content:x(T,{sx:{display:"grid",gap:"24px"},children:[b(Tm,{disabled:u.fields.length===ym.dopsCount,onClick:()=>{u.append({..._m})}}),u.fields.map(({id:e},t)=>b(Hl,{children:b(Rm,{onDelete:()=>{u.remove(t)},index:t})},e))]})}]}),b(jl,{type:"submit",children:"Сохранить"})]})});const G_=Yp().shape({...lg,...ug,...V_,...j_,oldDops:Jp().max(ym.dopsCount).of(z_).required(),newDops:Jp().max(ym.dopsCount).of(L_).required()});var $_=gl(({trafficSign:t,onSubmit:n,onDelete:r,onDeleteDop:i,onUpdateDop:s,getButtons:o})=>{const a=e.useId(),l=e.useMemo(()=>{const{dops:e,traffic_sign_id:n}=t;return{...t,...cy(t),oldDops:e.map(e=>({...e,traffic_sign_id:n,...cy(e)})),newDops:[]}},[t]),u=Oc({resolver:Ng(G_),defaultValues:l}),{reset:c,control:h,register:d,setValue:f,watch:p,formState:{errors:g}}=u,m=kc({control:h,name:"oldDops"}),_=kc({control:h,name:"newDops"}),y=e.useMemo(()=>m.fields.length+_.fields.length<ym.dopsCount,[m.fields.length,_.fields.length]),v=p("traffic_sign_number");return e.useEffect(()=>{Object.keys(g).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignUpdateForm",meta:g})},[g]),e.useEffect(()=>{c(l)},[t]),x(Ic,{form:u,onSubmit:n,children:[b(km,{items:[{label:vm.title,value:1,content:x(T,{sx:{display:"grid",gap:"12px"},children:[b(Ll,{items:[{value:1,summary:x(T,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[b(Ul,{notification:{title:"Удалить дорожный знак",description:"Вы действительно хотите удалить данный дорожный знак?"},onDelete:()=>{r(t)}}),b(Mm,{number:v})]}),getDetails:({onClose:e})=>b(N_,{trafficSigns:am,pageSize:5,onSelect:({title:t,number:n,type:r})=>{f("traffic_sign_number",n),f("traffic_sign_title",t),f("traffic_sign_type",r),e()}})}]}),b(wg,{...d("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...d("traffic_sign_value"),label:If.traffic_sign_value}),b(pf,{...d("comment"),label:If.comment}),b(pf,{...d("direction"),label:If.direction,type:"number"}),b(cg,{children:Rf.map(e=>b(zc,{...d(e),label:If[e],format:Df},`${a}-${e}`))})]})},{label:bm.title,value:2,content:x(T,{sx:{display:"grid",gap:"24px"},children:[b(Tm,{disabled:!y,onClick:()=>{_.append({..._m})}}),m.fields.map(({id:e},t)=>b(Hl,{children:b(Pm,{index:t,onDelete:i,onUpdate:s})},e)),_.fields.map(({id:e},t)=>b(Hl,{children:b(Rm,{onDelete:()=>{_.remove(t)},index:t})},e))]})}]}),x(hg,{children:[b(jl,{type:"submit",children:"Сохранить"}),o?.(t)]})]})});const q_={size:20,extension:"svg",apiName:"traffic_signal"},H_={direction:0,status:Mf.ACTIVE},W_={...Of,...Cf,...H_},Z_=e=>{const t=[],n={source:e,layer:gf.TRAFFIC_SIGNAL},r={},i="traffic_signal",s=`${wf}/msk/${i}/${i}_${q_.size}.${q_.extension}`;r[i]={url:s,filtering:"mipmap",sprites:{base:[0,0,q_.size,q_.size]}};const o={id:sn(),data:n,draw:{points:{collide:!1,texture:i,size:q_.size,sprite:"base",placement:"midpoint"}},textures:r,sublayers:{}};return t.push(o),t},K_={status:rg(),signal_model:ng().nullable(),comment:ng().nullable(),direction:ig.nullable()},X_={traffic_signal_id:rg(),dit_id:sg,tsodd_id:sg,pillar_id:ng().nullable()},Y_=Yp().shape({dit_id:X_.dit_id,tsodd_id:X_.tsodd_id,...K_,...lg});var Q_=gl(({onSubmit:t})=>{const n=e.useId(),r=Oc({resolver:Ng(Y_),defaultValues:{...W_}}),{register:i,formState:{errors:s}}=r;return e.useEffect(()=>{Object.keys(s).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignCreateForm",meta:s})},[s]),x(Ic,{form:r,onSubmit:t,children:[b(wg,{...i("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...i("signal_model"),label:If.signal_model}),b(pf,{...i("comment"),label:If.comment}),b(pf,{...i("direction"),label:If.direction,type:"number"}),b(cg,{children:Rf.map(e=>b(zc,{...i(e),label:If[e],format:Df},`${n}-${e}`))}),b(jl,{type:"submit",children:"Сохранить"})]})});const J_=Yp().shape({...X_,...lg,...ug,...K_});var ey=gl(({trafficSignal:t,onSubmit:n,onDelete:r,getButtons:i})=>{const s=e.useId(),o=e.useMemo(()=>({...t,...cy(t)}),[t]),a=Oc({resolver:Ng(J_),defaultValues:o}),{reset:l,register:u,formState:{errors:c}}=a;return e.useEffect(()=>{Object.keys(c).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignUpdateForm",meta:c})},[c]),e.useEffect(()=>{l(o)},[o]),x(Ic,{form:a,onSubmit:n,children:[b(wg,{...u("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...u("signal_model"),label:If.signal_model}),b(pf,{...u("comment"),label:If.comment}),b(pf,{...u("direction"),label:If.direction,type:"number"}),b(cg,{children:Rf.map(e=>b(zc,{...u(e),label:If[e],format:Df},`${s}-${e}`))}),x(hg,{children:[b(jl,{type:"submit",fullWidth:!0,children:"Сохранить"}),x(hg,{children:[b(Ul,{notification:{title:"Удалить светофор",description:"Вы действительно хотите удалить данный светофор?"},onDelete:()=>{r(t)}}),i?.(t)]})]})]})});const ty=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.WATER_AREA},draw:{polygons:{color:"#7DBEE4"},lines:{color:"#7DBEE4",width:20,cap:"round",join:"round"}}},r={id:sn(),data:{source:e,layer:gf.WATER_AREA_LABEL},filter:"function() {\n const { display_class } = feature;\n\n if ($zoom >= 14) {\n return true;\n } else {\n return display_class <= 4;\n }\n }",draw:{text:{text_source:"name",font:{fill:"#0A80C4",size:"14px",stroke:{color:"white",width:"3px"}}}}},i={id:sn(),data:{source:e,layer:gf.WATER_LAKE_LABEL},filter:"function() {\n const { display_class } = feature;\n\n if ($zoom >= 14) {\n return true;\n } else {\n return display_class <= 4;\n }\n }",draw:{text:{text_source:"name",font:{fill:"#0A80C4",size:"14px",stroke:{color:"white",width:"3px"}}}}};return t.push(n,r,i),t},ny=e=>{const t=[],n={},r={source:e,layer:gf.WATER_LINK},i={id:sn(),data:r};return n.geometry={draw:{lines:{color:"#7DBEE4",width:5,cap:"round",join:"round"}}},n.text={filter:"function() {\n return $zoom >= 10;\n }",draw:{text:{text_source:"name",font:{fill:"#0A80C4",size:"14px",stroke:{color:"white",width:"3px"}}}}},i.sublayers=n,t.push(i),t},ry=({id:e,data:{source:t,layer:n}})=>`${e}-${t}-${n}`,iy=({layer:e,order:t,eventHandlers:n})=>{const r=structuredClone(e),{draw:i,sublayers:s}=r,o=Boolean(n?.[e.data.layer]);if(i){const{points:e,lines:n,polygons:s,text:a,styles:l}=i;e&&(i.points={...structuredClone(e),order:t,interactive:o}),n&&(i.lines={...structuredClone(n),order:t,interactive:o}),s&&(i.polygons={...structuredClone(s),order:t,interactive:o}),a&&(i.text={...structuredClone(a),order:t,interactive:o}),l&&(i.styles=Object.entries(l).reduce((e,[n,r])=>({...e,[n]:{...structuredClone(r),order:t}}),{})),r.draw=structuredClone(i)}return s&&(Object.entries(s).forEach(([e,n])=>{if(n){const{draw:r}=n;if(r){const{points:e,lines:i,polygons:s,text:a}=r;a&&(r.text={...structuredClone(a),order:t,interactive:o}),e&&(r.points={...structuredClone(e),order:t,interactive:o}),i&&(r.lines={...structuredClone(i),order:t,interactive:o}),s&&(r.polygons={...structuredClone(s),order:t,interactive:o}),n.draw=structuredClone(r)}s[e]=structuredClone(n)}}),r.sublayers=structuredClone(s)),r},sy=e=>{const t=gg(e),n=Wg(),r=Zg(),i=pg(e),s=Vg(e),o=Ug(e),a=ty(e),l=Kg(e),u=[];if(e===mf.MSK)u.push(...t,...i,...s,...o,...a,...l);else u.push(...t,...i,...s,...n,...r,...o,...a,...l);return u},oy=e=>{const t=Hg(e),n=om(e),r=ny(e),i=Xg(e),s=jg(e),o=[...r,...n,...t];if(e===mf.MSK);else o.push(...i,...s);return o},ay=e=>{const t=im(e),n=zg(e);return[...t,...sm(e),...n,...xm(e),...Z_(e),...vg(e),...Qg(e)]},ly=e=>{const t=[],n=fg(e),r=sy(e),i=oy(e),s=ay(e),o=Ef(e),a=Sf(e),l=Tf(e),u=kf(e);if(e===mf.MSK)t.push(...r,...i,...o,...a,...l,...u,...n,...s);else t.push(...r,...i,...n,...s);return t},uy=e=>`${e.getFullYear()}-${`${e.getUTCMonth()+1}`.padStart(2,"0")}-${`${e.getUTCDate()}`.padStart(2,"0")}`,cy=e=>{const t=structuredClone(Cf);return Rf.forEach(n=>{const r=new Date(e[n]);t[n]=r}),t},hy=e=>{const t=structuredClone(Pf);return Rf.forEach(n=>{const r=uy(e[n]);t[n]=r}),t},dy=({eventHandlers:t})=>{const[n,r]=e.useState(null),[i,s]=e.useState(null),o=e.useMemo(()=>{if(null===n)return null;const{scene:e}=n;return e},[n]),a=e.useCallback(()=>{Promise.resolve().then(function(){return ox}).then(()=>{if(window.Tangram){const e=window.Tangram.leafletLayer({scene:dg}),{scene:n}=e;n.subscribe({load:({config:e})=>{s(e)}}),e.on("load",()=>{e.setSelectionEvents({click:({feature:e,leaflet_event:n})=>{if(e){const{source_layer:r,properties:i}=e;t?.[r]?.click?.({leaflet_event:n,properties:i})}},hover:({feature:e,leaflet_event:n})=>{if(e){const{source_layer:r,properties:i}=e;t?.[r]?.hover?.({leaflet_event:n,properties:i})}}})}),r(e)}})},[t]),l=e.useCallback(e=>{i?e(i):_f.warn({message:"Config не инициализирована"})},[i]),u=e.useCallback(e=>{l(t=>{o?e({config:t,scene:o}):_f.warn({message:"Scene не инициализирована"})})},[l,o]),c=e.useCallback(e=>{u(({config:t,scene:n})=>{const r=Af[e];t.sources[e]={tile_size:256,url:r,type:"MVT"},n.updateConfig({rebuild:!0})})},[u]),h=e.useCallback(e=>{u(({config:t,scene:n})=>{delete t.sources[e],n.updateConfig({rebuild:!0})})},[u]),d=e.useCallback(e=>{let t=null;return l(n=>{t=structuredClone(n.sources[e])}),t},[l]),f=e.useCallback((e,t)=>{u(({config:n,scene:r})=>{n.sources[e].url=t,r.updateConfig({rebuild:!0})})},[u]),p=e.useCallback(e=>{h(e),c(e)},[h,c]),g=e.useCallback(e=>{u(({config:n,scene:r})=>{const i=b().length+1,s=iy({layer:e,order:i,eventHandlers:t}),o=ry(s),{sublayers:a,draw:l,textures:u}=s;if(l){const{styles:e}=l;e&&(s.draw={...structuredClone(s.draw),...structuredClone(e)})}n.layers[o]={...structuredClone(s),...structuredClone(a)},n.textures={...structuredClone(n.textures),...structuredClone(u)},r.updateConfig({rebuild:!0})})},[u]),m=e.useCallback(e=>{const t=ry(e);u(({config:e,scene:n})=>{delete e.layers[t],n.updateConfig({rebuild:!0})})},[u]),_=e.useCallback(({name:e,style:t})=>{u(({config:n,scene:r})=>{n.styles[e]=structuredClone(t),r.updateConfig({rebuild:!0})})},[u]),y=e.useCallback(e=>{let t=!0;const n=ry(e);return l(e=>{const{visible:r=!0}=e.layers[n];t=r}),t},[ry,l]),v=e.useCallback(({layer:e,visible:t})=>{const n=ry(e);u(({config:e,scene:r})=>{e.layers[n].visible=t,r.updateConfig({rebuild:!0})})},[u]),b=e.useCallback(()=>{const e=[];return l(t=>{e.push(...Object.keys(t.layers))}),e},[l]),x=e.useCallback(()=>{l(e=>{const{layers:t}=e;Object.values(t).forEach(m)})},[l,m]),w=e.useCallback(()=>{const e=[];return l(t=>{e.push(...Object.keys(t.sources))}),e},[i]);return e.useEffect(()=>(Uo.instance.isValidApiKey&&a(),()=>{r(null),s(null)}),[Uo.instance.isValidApiKey]),e.useEffect(()=>{_({name:"zebra_crossing",style:{base:"polygons",lighting:!1,shaders:{attributes:{a_angle:{type:"float",default:0}},uniforms:{u_stripe_width:1},blocks:{filter:"\n vec3 pos = worldPosition().xyz;\n\n float ang = radians(a_angle);\n\n vec2 dir = vec2(sin(ang), cos(ang));\n\n float positionAlongLine = dot(pos.xy, dir);\n\n float stripe = step(1.0, mod(positionAlongLine / u_stripe_width, 2.0));\n\n color.rgb = mix(vec3(1.0, 1.0, 1.0), vec3(1.0, 0.8, 0.0), stripe);\n \n color.a = 1.0;\n "}}}}),Object.values(mf).forEach(c)},[_,c]),{layer:n,scene:o,config:i,addSource:c,getSource:d,updateSource:f,reloadSource:p,addLayer:g,removeLayer:m,addStyle:_,getLayerVisibility:y,toggleLayerVisibility:v,getSources:w,getLayers:b,removeLayers:x}},fy=g(null);function py(){return function(){const e=_(fy);if(null==e)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return e}().map}const gy=({source:t})=>{const{layer:n,addLayer:r}=dy({}),i=py();return e.useEffect(()=>{n&&i.addLayer(n)},[n]),e.useEffect(()=>{ly(t).map(r)},[r,t]),null},my=({color:e="inherit"})=>b(W,{color:e}),_y={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",bgcolor:"background.paper",border:"2px solid #000",boxShadow:24,p:4,maxHeight:"90vh",overflowX:"auto",overflowY:"auto"};var yy,vy=gl(({name:t,children:n,onClose:r,onOpen:i})=>{const s=e.useId(),o=Mo.getIsVisible(t);return e.useEffect(()=>{o?i?.({name:t}):r?.({name:t})},[o]),b(he,{open:o,onClose:()=>{Mo.closeModal(t)},"aria-labelledby":`modal-${s}-title`,"aria-describedby":`modal-${s}-description`,children:b(ce,{sx:({breakpoints:e})=>({..._y,[e.up("sm")]:{minWidth:400},[e.down("sm")]:{minWidth:"80vw"}}),children:n})})}),by={exports:{}};var xy=(yy||(yy=1,by.exports=function e(){var t,n="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n?n:{},r=!n.document&&!!n.postMessage,i=n.IS_PAPA_WORKER||!1,s={},o=0,a={};function l(e){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(e){var t=v(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null),this._handle=new f(t),(this._handle.streamer=this)._config=t}.call(this,e),this.parseChunk=function(e,t){var r=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<r){let t=this._config.newline;t||(s=this._config.quoteChar||'"',t=this._handle.guessLineEndings(e,s)),e=[...e.split(t).slice(r)].join(t)}this.isFirstChunk&&x(this._config.beforeFirstChunk)&&void 0!==(s=this._config.beforeFirstChunk(e))&&(e=s),this.isFirstChunk=!1,this._halted=!1,r=this._partialLine+e;var s=(this._partialLine="",this._handle.parse(r,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(e=s.meta.cursor,this._finished||(this._partialLine=r.substring(e-this._baseIndex),this._baseIndex=e),s&&s.data&&(this._rowCount+=s.data.length),r=this._finished||this._config.preview&&this._rowCount>=this._config.preview,i)n.postMessage({results:s,workerId:a.WORKER_ID,finished:r});else if(x(this._config.chunk)&&!t){if(this._config.chunk(s,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=s=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(s.data),this._completeResults.errors=this._completeResults.errors.concat(s.errors),this._completeResults.meta=s.meta),this._completed||!r||!x(this._config.complete)||s&&s.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),r||s&&s.meta.paused||this._nextChunk(),s}this._halted=!0},this._sendError=function(e){x(this._config.error)?this._config.error(e):i&&this._config.error&&n.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function u(e){var t;(e=e||{}).chunkSize||(e.chunkSize=a.RemoteChunkSize),l.call(this,e),this._nextChunk=r?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),r||(t.onload=b(this._chunkLoaded,this),t.onerror=b(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!r),this._config.downloadRequestHeaders){var e,n=this._config.downloadRequestHeaders;for(e in n)t.setRequestHeader(e,n[e])}var i;this._config.chunkSize&&(i=this._start+this._config.chunkSize-1,t.setRequestHeader("Range","bytes="+this._start+"-"+i));try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}r&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize||t.responseText.length,this._finished=!this._config.chunkSize||this._start>=(e=>null!==(e=e.getResponseHeader("Content-Range"))?parseInt(e.substring(e.lastIndexOf("/")+1)):-1)(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){e=t.statusText||e,this._sendError(new Error(e))}}function c(e){(e=e||{}).chunkSize||(e.chunkSize=a.LocalChunkSize),l.call(this,e);var t,n,r="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,n=e.slice||e.webkitSlice||e.mozSlice,r?((t=new FileReader).onload=b(this._chunkLoaded,this),t.onerror=b(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var e=this._input,i=(this._config.chunkSize&&(i=Math.min(this._start+this._config.chunkSize,this._input.size),e=n.call(e,this._start,i)),t.readAsText(e,this._config.encoding));r||this._chunkLoaded({target:{result:i}})},this._chunkLoaded=function(e){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function h(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){var e,n;if(!this._finished)return e=this._config.chunkSize,t=e?(n=t.substring(0,e),t.substring(e)):(n=t,""),this._finished=!t,this.parseChunk(n)}}function d(e){l.call(this,e=e||{});var t=[],n=!0,r=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){r&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):n=!0},this._streamData=b(function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),n&&(n=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}},this),this._streamError=b(function(e){this._streamCleanUp(),this._sendError(e)},this),this._streamEnd=b(function(){this._streamCleanUp(),r=!0,this._streamData("")},this),this._streamCleanUp=b(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function f(e){var t,n,r,i,s=Math.pow(2,53),o=-s,l=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,u=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,c=this,h=0,d=0,f=!1,m=!1,_=[],y={data:[],errors:[],meta:{}};function b(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function w(){if(y&&r&&(E("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),r=!1),e.skipEmptyLines&&(y.data=y.data.filter(function(e){return!b(e)})),A()){if(y)if(Array.isArray(y.data[0])){for(var t=0;A()&&t<y.data.length;t++)y.data[t].forEach(c);y.data.splice(0,1)}else y.data.forEach(c);function c(t,n){x(e.transformHeader)&&(t=e.transformHeader(t,n)),_.push(t)}}function n(t,n){for(var r=e.header?{}:[],i=0;i<t.length;i++){var a=i,c=t[i];c=((t,n)=>(t=>(e.dynamicTypingFunction&&void 0===e.dynamicTyping[t]&&(e.dynamicTyping[t]=e.dynamicTypingFunction(t)),!0===(e.dynamicTyping[t]||e.dynamicTyping)))(t)?"true"===n||"TRUE"===n||"false"!==n&&"FALSE"!==n&&((e=>{if(l.test(e)&&(e=parseFloat(e),o<e&&e<s))return 1})(n)?parseFloat(n):u.test(n)?new Date(n):""===n?null:n):n)(a=e.header?i>=_.length?"__parsed_extra":_[i]:a,c=e.transform?e.transform(c,a):c),"__parsed_extra"===a?(r[a]=r[a]||[],r[a].push(c)):r[a]=c}return e.header&&(i>_.length?E("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+i,d+n):i<_.length&&E("FieldMismatch","TooFewFields","Too few fields: expected "+_.length+" fields but parsed "+i,d+n)),r}var i;y&&(e.header||e.dynamicTyping||e.transform)&&(i=1,!y.data.length||Array.isArray(y.data[0])?(y.data=y.data.map(n),i=y.data.length):y.data=n(y.data,0),e.header&&y.meta&&(y.meta.fields=_),d+=i)}function A(){return e.header&&0===_.length}function E(e,t,n,r){e={type:e,code:t,message:n},void 0!==r&&(e.row=r),y.errors.push(e)}x(e.step)&&(i=e.step,e.step=function(t){y=t,A()?w():(w(),0!==y.data.length&&(h+=t.data.length,e.preview&&h>e.preview?n.abort():(y.data=y.data[0],i(y,c))))}),this.parse=function(i,s,o){var l=e.quoteChar||'"';return e.newline||(e.newline=this.guessLineEndings(i,l)),r=!1,e.delimiter?x(e.delimiter)&&(e.delimiter=e.delimiter(i),y.meta.delimiter=e.delimiter):((l=((t,n,r,i,s)=>{var o,l,u,c;s=s||[",","\t","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var h=0;h<s.length;h++){for(var d,f=s[h],p=0,m=0,_=0,y=(u=void 0,new g({comments:i,delimiter:f,newline:n,preview:10}).parse(t)),v=0;v<y.data.length;v++)r&&b(y.data[v])?_++:(m+=d=y.data[v].length,void 0===u?u=d:0<d&&(p+=Math.abs(d-u),u=d));0<y.data.length&&(m/=y.data.length-_),(void 0===l||p<=l)&&(void 0===c||c<m)&&1.99<m&&(l=p,o=f,c=m)}return{successful:!!(e.delimiter=o),bestDelimiter:o}})(i,e.newline,e.skipEmptyLines,e.comments,e.delimitersToGuess)).successful?e.delimiter=l.bestDelimiter:(r=!0,e.delimiter=a.DefaultDelimiter),y.meta.delimiter=e.delimiter),l=v(e),e.preview&&e.header&&l.preview++,t=i,n=new g(l),y=n.parse(t,s,o),w(),f?{meta:{paused:!0}}:y||{meta:{paused:!1}}},this.paused=function(){return f},this.pause=function(){f=!0,n.abort(),t=x(e.chunk)?"":t.substring(n.getCharIndex())},this.resume=function(){c.streamer._halted?(f=!1,c.streamer.parseChunk(t,!0)):setTimeout(c.resume,3)},this.aborted=function(){return m},this.abort=function(){m=!0,n.abort(),y.meta.aborted=!0,x(e.complete)&&e.complete(y),t=""},this.guessLineEndings=function(e,t){e=e.substring(0,1048576),t=new RegExp(p(t)+"([^]*?)"+p(t),"gm");var n=(e=e.replace(t,"")).split("\r");if(e=1<(t=e.split("\n")).length&&t[0].length<n[0].length,1===n.length||e)return"\n";for(var r=0,i=0;i<n.length;i++)"\n"===n[i][0]&&r++;return r>=n.length/2?"\r\n":"\r"}}function p(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g(e){var t=(e=e||{}).delimiter,n=e.newline,r=e.comments,i=e.step,s=e.preview,o=e.fastMode,l=null,u=!1,c=null==e.quoteChar?'"':e.quoteChar,h=c;if(void 0!==e.escapeChar&&(h=e.escapeChar),("string"!=typeof t||-1<a.BAD_DELIMITERS.indexOf(t))&&(t=","),r===t)throw new Error("Comment character same as delimiter");!0===r?r="#":("string"!=typeof r||-1<a.BAD_DELIMITERS.indexOf(r))&&(r=!1),"\n"!==n&&"\r"!==n&&"\r\n"!==n&&(n="\n");var d=0,f=!1;this.parse=function(a,g,m){if("string"!=typeof a)throw new Error("Input must be a string");var _=a.length,y=t.length,v=n.length,b=r.length,w=x(i),A=[],E=[],S=[],T=d=0;if(!a)return L();if(o||!1!==o&&-1===a.indexOf(c)){for(var k=a.split(n),O=0;O<k.length;O++){if(S=k[O],d+=S.length,O!==k.length-1)d+=n.length;else if(m)return L();if(!r||S.substring(0,b)!==r){if(w){if(A=[],I(S.split(t)),j(),f)return L()}else I(S.split(t));if(s&&s<=O)return A=A.slice(0,s),L(!0)}}return L()}for(var R=a.indexOf(t,d),C=a.indexOf(n,d),P=new RegExp(p(h)+p(c),"g"),M=a.indexOf(c,d);;)if(a[d]===c)for(M=d,d++;;){if(-1===(M=a.indexOf(c,M+1)))return m||E.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:A.length,index:d}),F();if(M===_-1)return F(a.substring(d,M).replace(P,c));if(c===h&&a[M+1]===h)M++;else if(c===h||0===M||a[M-1]!==h){-1!==R&&R<M+1&&(R=a.indexOf(t,M+1));var N=D(-1===(C=-1!==C&&C<M+1?a.indexOf(n,M+1):C)?R:Math.min(R,C));if(a.substr(M+1+N,y)===t){S.push(a.substring(d,M).replace(P,c)),a[d=M+1+N+y]!==c&&(M=a.indexOf(c,d)),R=a.indexOf(t,d),C=a.indexOf(n,d);break}if(N=D(C),a.substring(M+1+N,M+1+N+v)===n){if(S.push(a.substring(d,M).replace(P,c)),z(M+1+N+v),R=a.indexOf(t,d),M=a.indexOf(c,d),w&&(j(),f))return L();if(s&&A.length>=s)return L(!0);break}E.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:A.length,index:d}),M++}}else if(r&&0===S.length&&a.substring(d,d+b)===r){if(-1===C)return L();d=C+v,C=a.indexOf(n,d),R=a.indexOf(t,d)}else if(-1!==R&&(R<C||-1===C))S.push(a.substring(d,R)),d=R+y,R=a.indexOf(t,d);else{if(-1===C)break;if(S.push(a.substring(d,C)),z(C+v),w&&(j(),f))return L();if(s&&A.length>=s)return L(!0)}return F();function I(e){A.push(e),T=d}function D(e){var t=0;return-1!==e&&(e=a.substring(M+1,e))&&""===e.trim()?e.length:t}function F(e){return m||(void 0===e&&(e=a.substring(d)),S.push(e),d=_,I(S),w&&j()),L()}function z(e){d=e,I(S),S=[],C=a.indexOf(n,d)}function L(r){if(e.header&&!g&&A.length&&!u){var i=A[0],s=Object.create(null),o=new Set(i);let t=!1;for(let n=0;n<i.length;n++){let r=i[n];if(s[r=x(e.transformHeader)?e.transformHeader(r,n):r]){let e,a=s[r];for(;e=r+"_"+a,a++,o.has(e););o.add(e),i[n]=e,s[r]++,t=!0,(l=null===l?{}:l)[e]=r}else s[r]=1,i[n]=r;o.add(r)}t&&console.warn("Duplicate headers found and renamed."),u=!0}return{data:A,errors:E,meta:{delimiter:t,linebreak:n,aborted:f,truncated:!!r,cursor:T+(g||0),renamedHeaders:l}}}function j(){i(L()),A=[],E=[]}},this.abort=function(){f=!0},this.getCharIndex=function(){return d}}function m(e){var t=e.data,n=s[t.workerId],r=!1;if(t.error)n.userError(t.error,t.file);else if(t.results&&t.results.data){var i={abort:function(){r=!0,_(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:y,resume:y};if(x(n.userStep)){for(var o=0;o<t.results.data.length&&(n.userStep({data:t.results.data[o],errors:t.results.errors,meta:t.results.meta},i),!r);o++);delete t.results}else x(n.userChunk)&&(n.userChunk(t.results,i,t.file),delete t.results)}t.finished&&!r&&_(t.workerId,t.results)}function _(e,t){var n=s[e];x(n.userComplete)&&n.userComplete(t),n.terminate(),delete s[e]}function y(){throw new Error("Not implemented.")}function v(e){if("object"!=typeof e||null===e)return e;var t,n=Array.isArray(e)?[]:{};for(t in e)n[t]=v(e[t]);return n}function b(e,t){return function(){e.apply(t,arguments)}}function x(e){return"function"==typeof e}return a.parse=function(t,r){var i=(r=r||{}).dynamicTyping||!1;if(x(i)&&(r.dynamicTypingFunction=i,i={}),r.dynamicTyping=i,r.transform=!!x(r.transform)&&r.transform,!r.worker||!a.WORKERS_SUPPORTED)return i=null,a.NODE_STREAM_INPUT,"string"==typeof t?(t=(e=>65279!==e.charCodeAt(0)?e:e.slice(1))(t),i=new(r.download?u:h)(r)):!0===t.readable&&x(t.read)&&x(t.on)?i=new d(r):(n.File&&t instanceof File||t instanceof Object)&&(i=new c(r)),i.stream(t);(i=(()=>{var t;return!!a.WORKERS_SUPPORTED&&(t=(()=>{var t=n.URL||n.webkitURL||null,r=e.toString();return a.BLOB_URL||(a.BLOB_URL=t.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",r,")();"],{type:"text/javascript"})))})(),(t=new n.Worker(t)).onmessage=m,t.id=o++,s[t.id]=t)})()).userStep=r.step,i.userChunk=r.chunk,i.userComplete=r.complete,i.userError=r.error,r.step=x(r.step),r.chunk=x(r.chunk),r.complete=x(r.complete),r.error=x(r.error),delete r.worker,i.postMessage({input:t,config:r,workerId:i.id})},a.unparse=function(e,t){var n=!1,r=!0,i=",",s="\r\n",o='"',l=o+o,u=!1,c=null,h=!1,d=((()=>{if("object"==typeof t){if("string"!=typeof t.delimiter||a.BAD_DELIMITERS.filter(function(e){return-1!==t.delimiter.indexOf(e)}).length||(i=t.delimiter),"boolean"!=typeof t.quotes&&"function"!=typeof t.quotes&&!Array.isArray(t.quotes)||(n=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(u=t.skipEmptyLines),"string"==typeof t.newline&&(s=t.newline),"string"==typeof t.quoteChar&&(o=t.quoteChar),"boolean"==typeof t.header&&(r=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+o),t.escapeFormulae instanceof RegExp?h=t.escapeFormulae:"boolean"==typeof t.escapeFormulae&&t.escapeFormulae&&(h=/^[=+\-@\t\r].*$/)}})(),new RegExp(p(o),"g"));if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return f(null,e,u);if("object"==typeof e[0])return f(c||Object.keys(e[0]),e,u)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),f(e.fields||[],e.data||[],u);throw new Error("Unable to serialize unrecognized input");function f(e,t,n){var o="",a=("string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t)),Array.isArray(e)&&0<e.length),l=!Array.isArray(t[0]);if(a&&r){for(var u=0;u<e.length;u++)0<u&&(o+=i),o+=g(e[u],u);0<t.length&&(o+=s)}for(var c=0;c<t.length;c++){var h=(a?e:t[c]).length,d=!1,f=a?0===Object.keys(t[c]).length:0===t[c].length;if(n&&!a&&(d="greedy"===n?""===t[c].join("").trim():1===t[c].length&&0===t[c][0].length),"greedy"===n&&a){for(var p=[],m=0;m<h;m++){var _=l?e[m]:m;p.push(t[c][_])}d=""===p.join("").trim()}if(!d){for(var y=0;y<h;y++){0<y&&!f&&(o+=i);var v=a&&l?e[y]:y;o+=g(t[c][v],y)}c<t.length-1&&(!n||0<h&&!f)&&(o+=s)}}return o}function g(e,t){var r,s;return null==e?"":e.constructor===Date?JSON.stringify(e).slice(1,25):(s=!1,h&&"string"==typeof e&&h.test(e)&&(e="'"+e,s=!0),r=e.toString().replace(d,l),(s=s||!0===n||"function"==typeof n&&n(e,t)||Array.isArray(n)&&n[t]||((e,t)=>{for(var n=0;n<t.length;n++)if(-1<e.indexOf(t[n]))return!0;return!1})(r,a.BAD_DELIMITERS)||-1<r.indexOf(i)||" "===r.charAt(0)||" "===r.charAt(r.length-1))?o+r+o:r)}},a.RECORD_SEP=String.fromCharCode(30),a.UNIT_SEP=String.fromCharCode(31),a.BYTE_ORDER_MARK="\ufeff",a.BAD_DELIMITERS=["\r","\n",'"',a.BYTE_ORDER_MARK],a.WORKERS_SUPPORTED=!r&&!!n.Worker,a.NODE_STREAM_INPUT=1,a.LocalChunkSize=10485760,a.RemoteChunkSize=5242880,a.DefaultDelimiter=",",a.Parser=g,a.ParserHandle=f,a.NetworkStreamer=u,a.FileStreamer=c,a.StringStreamer=h,a.ReadableStreamStreamer=d,n.jQuery&&((t=n.jQuery).fn.parse=function(e){var r=e.config||{},i=[];return this.each(function(e){if("INPUT"!==t(this).prop("tagName").toUpperCase()||"file"!==t(this).attr("type").toLowerCase()||!n.FileReader||!this.files||0===this.files.length)return!0;for(var s=0;s<this.files.length;s++)i.push({file:this.files[s],inputElem:this,instanceConfig:t.extend({},r)})}),s(),this;function s(){if(0===i.length)x(e.complete)&&e.complete();else{var n,r,s,l,u=i[0];if(x(e.before)){var c=e.before(u.file,u.inputElem);if("object"==typeof c){if("abort"===c.action)return n="AbortError",r=u.file,s=u.inputElem,l=c.reason,void(x(e.error)&&e.error({name:n},r,s,l));if("skip"===c.action)return void o();"object"==typeof c.config&&(u.instanceConfig=t.extend(u.instanceConfig,c.config))}else if("skip"===c)return void o()}var h=u.instanceConfig.complete;u.instanceConfig.complete=function(e){x(h)&&h(e,u.file,u.inputElem),o()},a.parse(u.file,u.instanceConfig)}}function o(){i.splice(0,1),s()}}),i&&(n.onmessage=function(e){e=e.data,void 0===a.WORKER_ID&&e&&(a.WORKER_ID=e.workerId),"string"==typeof e.input?n.postMessage({workerId:a.WORKER_ID,results:a.parse(e.input,e.config),finished:!0}):(n.File&&e.input instanceof File||e.input instanceof Object)&&(e=a.parse(e.input,e.config))&&n.postMessage({workerId:a.WORKER_ID,results:e,finished:!0})}),(u.prototype=Object.create(l.prototype)).constructor=u,(c.prototype=Object.create(l.prototype)).constructor=c,(h.prototype=Object.create(h.prototype)).constructor=h,(d.prototype=Object.create(l.prototype)).constructor=d,a}()),by.exports),wy=fe(xy);function Ay(e,t){return wy.parse(e,t)}function Ey(e,t){wy.parse(e,Object.assign({},{download:!0},t))}function Sy(e,t){return void 0===t&&(t={}),wy.unparse(e,t)}"function"==typeof SuppressedError&&SuppressedError,wy.BAD_DELIMITERS,wy.RECORD_SEP,wy.UNIT_SEP,wy.WORKERS_SUPPORTED,wy.LocalChunkSize,wy.DefaultDelimiter;const Ty=({onDataParsed:t,onError:n,delimiter:r=",",header:i=!0,dynamicTyping:s=!0,skipEmptyLines:o=!0,worker:a=!1})=>{const{readString:l}={readString:Ay,readRemoteFile:Ey,jsonToCSV:Sy},[u,c]=e.useState(!1),[h,d]=e.useState(null);return b(ql,{accept:".csv",loading:u,error:h,onFilesLoad:({files:e})=>{const u=e[0];c(!0),d(null),u.text().then(e=>{l(e,{delimiter:r,header:i,dynamicTyping:s,skipEmptyLines:o,worker:a,complete:e=>{if(e.errors.length>0){const t=e.errors.map(({type:e,message:t})=>`${e}: ${t}`).join("; ");d(t),n?.(new Error(t))}else{const n=e.data,r=e.meta.fields||[];t?.(n,r)}},error:e=>{const t=e.message||"Ошибка при парсинге CSV";d(t),n?.(new Error(t))}})}).catch(e=>{const t=e instanceof Error?e.message:"Неизвестная ошибка";d(t),n?.(new Error(t))}).finally(()=>{c(!1)})},children:"Загрузить файлы csv"})};var ky={createDocument:function(e){return(new DOMParser).parseFromString(e.trim(),"text/xml")}},Oy=Uint8Array,Ry=Uint16Array,Cy=Int32Array,Py=new Oy([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),My=new Oy([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ny=new Oy([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Iy=function(e,t){for(var n=new Ry(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new Cy(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return{b:n,r:i}},Dy=Iy(Py,2),Fy=Dy.b,zy=Dy.r;Fy[28]=258,zy[258]=28;for(var Ly=Iy(My,0).b,jy=new Ry(32768),Vy=0;Vy<32768;++Vy){var Uy=(43690&Vy)>>1|(21845&Vy)<<1;Uy=(61680&(Uy=(52428&Uy)>>2|(13107&Uy)<<2))>>4|(3855&Uy)<<4,jy[Vy]=((65280&Uy)>>8|(255&Uy)<<8)>>1}var By=function(e,t,n){for(var r=e.length,i=0,s=new Ry(t);i<r;++i)e[i]&&++s[e[i]-1];var o,a=new Ry(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(n){o=new Ry(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var u=i<<4|e[i],c=t-e[i],h=a[e[i]-1]++<<c,d=h|(1<<c)-1;h<=d;++h)o[jy[h]>>l]=u}else for(o=new Ry(r),i=0;i<r;++i)e[i]&&(o[i]=jy[a[e[i]-1]++]>>15-e[i]);return o},Gy=new Oy(288);for(Vy=0;Vy<144;++Vy)Gy[Vy]=8;for(Vy=144;Vy<256;++Vy)Gy[Vy]=9;for(Vy=256;Vy<280;++Vy)Gy[Vy]=7;for(Vy=280;Vy<288;++Vy)Gy[Vy]=8;var $y=new Oy(32);for(Vy=0;Vy<32;++Vy)$y[Vy]=5;var qy=By(Gy,9,1),Hy=By($y,5,1),Wy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Zy=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},Ky=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Xy=function(e){return(e+7)/8|0},Yy=function(e,t,n){return(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length),new Oy(e.subarray(t,n))},Qy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Jy=function(e,t,n){var r=new Error(t||Qy[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Jy),!n)throw r;return r},ev=new Oy(0),tv=function(e,t){return e[t]|e[t+1]<<8},nv=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},rv=function(e,t){return nv(e,t)+4294967296*nv(e,t+4)};function iv(e,t){return function(e,t,n,r){var i=e.length,s=r?r.length:0;if(!i||t.f&&!t.l)return n||new Oy(0);var o=!n,a=o||2!=t.i,l=t.i;o&&(n=new Oy(3*i));var u=function(e){var t=n.length;if(e>t){var r=new Oy(Math.max(2*t,e));r.set(n),n=r}},c=t.f||0,h=t.p||0,d=t.b||0,f=t.l,p=t.d,g=t.m,m=t.n,_=8*i;do{if(!f){c=Zy(e,h,1);var y=Zy(e,h+1,3);if(h+=3,!y){var v=e[(C=Xy(h)+4)-4]|e[C-3]<<8,b=C+v;if(b>i){l&&Jy(0);break}a&&u(d+v),n.set(e.subarray(C,b),d),t.b=d+=v,t.p=h=8*b,t.f=c;continue}if(1==y)f=qy,p=Hy,g=9,m=5;else if(2==y){var x=Zy(e,h,31)+257,w=Zy(e,h+10,15)+4,A=x+Zy(e,h+5,31)+1;h+=14;for(var E=new Oy(A),S=new Oy(19),T=0;T<w;++T)S[Ny[T]]=Zy(e,h+3*T,7);h+=3*w;var k=Wy(S),O=(1<<k)-1,R=By(S,k,1);for(T=0;T<A;){var C,P=R[Zy(e,h,O)];if(h+=15&P,(C=P>>4)<16)E[T++]=C;else{var M=0,N=0;for(16==C?(N=3+Zy(e,h,3),h+=2,M=E[T-1]):17==C?(N=3+Zy(e,h,7),h+=3):18==C&&(N=11+Zy(e,h,127),h+=7);N--;)E[T++]=M}}var I=E.subarray(0,x),D=E.subarray(x);g=Wy(I),m=Wy(D),f=By(I,g,1),p=By(D,m,1)}else Jy(1);if(h>_){l&&Jy(0);break}}a&&u(d+131072);for(var F=(1<<g)-1,z=(1<<m)-1,L=h;;L=h){var j=(M=f[Ky(e,h)&F])>>4;if((h+=15&M)>_){l&&Jy(0);break}if(M||Jy(2),j<256)n[d++]=j;else{if(256==j){L=h,f=null;break}var V=j-254;if(j>264){var U=Py[T=j-257];V=Zy(e,h,(1<<U)-1)+Fy[T],h+=U}var B=p[Ky(e,h)&z],G=B>>4;if(B||Jy(3),h+=15&B,D=Ly[G],G>3&&(U=My[G],D+=Ky(e,h)&(1<<U)-1,h+=U),h>_){l&&Jy(0);break}a&&u(d+131072);var $=d+V;if(d<D){var q=s-D,H=Math.min(D,$);for(q+d<0&&Jy(3);d<H;++d)n[d]=r[q+d]}for(;d<$;++d)n[d]=n[d-D]}}t.l=f,t.p=L,t.b=d,t.f=c,f&&(c=1,t.m=g,t.d=p,t.n=m)}while(!c);return d!=n.length&&o?Yy(n,0,d):n.subarray(0,d)}(e,{i:2},t&&t.out,t&&t.dictionary)}var sv="undefined"!=typeof TextDecoder&&new TextDecoder;try{sv.decode(ev,{stream:!0})}catch(wy){}function ov(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(sv)return sv.decode(e);var i=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Yy(e,n-1)};i?3==i?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&i?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}}(e),s=i.s;return(n=i.r).length&&Jy(8),s}var av=function(e,t){return t+30+tv(e,t+26)+tv(e,t+28)},lv=function(e,t,n){var r=tv(e,t+28),i=ov(e.subarray(t+46,t+46+r),!(2048&tv(e,t+8))),s=t+46+r,o=nv(e,t+20),a=n&&4294967295==o?uv(e,s):[o,nv(e,t+24),nv(e,t+42)],l=a[0],u=a[1],c=a[2];return[tv(e,t+10),l,u,i,s+tv(e,t+30)+tv(e,t+32),c]},uv=function(e,t){for(;1!=tv(e,t);t+=4+tv(e,t+2));return[rv(e,t+12),rv(e,t+4),rv(e,t+20)]};function cv(e){var t=function(e){for(var t={},n=e.length-22;101010256!=nv(e,n);--n)(!n||e.length-n>65558)&&Jy(13);var r=tv(e,n+8);if(!r)return{};var i=nv(e,n+16),s=4294967295==i||65535==r;if(s){var o=nv(e,n-12);(s=101075792==nv(e,o))&&(r=nv(e,o+32),i=nv(e,o+48))}for(var a=0;a<r;++a){var l=lv(e,i,s),u=l[0],c=l[1],h=l[2],d=l[3],f=l[4],p=l[5],g=av(e,p);i=f,u?8==u?t[d]=iv(e.subarray(g,g+c),{out:new Oy(h)}):Jy(14,"unknown compression type "+u):t[d]=Yy(e,g,g+c)}return t}(new Uint8Array(e));return Promise.resolve(function(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];t[i]=ov(e[i])}return t}(t))}function hv(e,t){for(var n=0;n<e.childNodes.length;){var r=e.childNodes[n];if(1===r.nodeType&&gv(r)===t)return r;n++}}function dv(e,t){for(var n=[],r=0;r<e.childNodes.length;){var i=e.childNodes[r];1===i.nodeType&&gv(i)===t&&n.push(i),r++}return n}function fv(e,t,n){for(var r=0;r<e.childNodes.length;){var i=e.childNodes[r];t?1===i.nodeType&&gv(i)===t&&n(i,r):n(i,r),r++}}var pv=/.+\:/;function gv(e){return e.tagName.replace(pv,"")}function mv(e){if(1!==e.nodeType)return e.textContent;for(var t="<"+gv(e),n=0;n<e.attributes.length;)t+=" "+e.attributes[n].name+'="'+e.attributes[n].value+'"',n++;t+=">";for(var r=0;r<e.childNodes.length;)t+=mv(e.childNodes[r]),r++;return t+="</"+gv(e)+">"}function _v(e){var t,n,r=e.documentElement;return t=function(e){var t=hv(e,"t");if(t)return t.textContent;var n="";return fv(e,"r",function(e){n+=hv(e,"t").textContent}),n},n=[],fv(r,"si",function(e,r){n.push(t(e,r))}),n}function yv(e,t){var n=t.createDocument(e),r={},i=function(e){return hv(e.documentElement,"workbookPr")}(n);i&&"1"===i.getAttribute("date1904")&&(r.epoch1904=!0),r.sheets=[];return function(e){return dv(hv(e.documentElement,"sheets"),"sheet")}(n).forEach(function(e){e.getAttribute("name")&&r.sheets.push({id:e.getAttribute("sheetId"),name:e.getAttribute("name"),relationId:e.getAttribute("r:id")})}),r}function vv(e,t){var n=t.createDocument(e),r={sheets:{},sharedStrings:void 0,styles:void 0};return function(e){return dv(e.documentElement,"Relationship")}(n).forEach(function(e){var t=e.getAttribute("Target");switch(e.getAttribute("Type")){case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles":r.styles=bv(t);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings":r.sharedStrings=bv(t);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":r.sheets[e.getAttribute("Id")]=bv(t)}}),r}function bv(e){return"/"===e[0]?e.slice(1):"xl/"+e}function xv(e){"@babel/helpers - typeof";return xv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xv(e)}function wv(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Av(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wv(Object(n),!0).forEach(function(t){Ev(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wv(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ev(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==xv(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!==xv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===xv(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Sv(e,t){if(!e)return{};var n=t.createDocument(e),r=function(e){var t=hv(e.documentElement,"cellStyleXfs");return t?dv(t,"xf"):[]}(n).map(kv),i=function(e){var t=hv(e.documentElement,"numFmts");return t?dv(t,"numFmt"):[]}(n).map(Tv).reduce(function(e,t){return e[t.id]=t,e},[]);return function(e){var t=hv(e.documentElement,"cellXfs");return t?dv(t,"xf"):[]}(n).map(function(e){return e.hasAttribute("xfId")?Av(Av({},r[e.xfId]),kv(e,i)):kv(e,i)})}function Tv(e){return{id:e.getAttribute("numFmtId"),template:e.getAttribute("formatCode")}}function kv(e,t){var n={};if(e.hasAttribute("numFmtId")){var r=e.getAttribute("numFmtId");t[r]?n.numberFormat=t[r]:n.numberFormat={id:r}}return n}function Ov(e,t){t&&t.epoch1904&&(e+=1462);return new Date(Math.round(24*(e-25569)*36e5))}function Rv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Cv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cv(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Cv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Pv(e,t,n){if(e){var r=t[e];if(!r)throw new Error("Cell style not found: ".concat(e));if(!r.numberFormat)return!1;if(Mv.indexOf(Number(r.numberFormat.id))>=0||n.dateFormat&&r.numberFormat.template===n.dateFormat||!1!==n.smartDateParser&&r.numberFormat.template&&function(e){for(var t,n=Rv((e=(e=(e=e.toLowerCase()).replace(Nv,"")).replace(Iv,"")).split(/\W+/));!(t=n()).done;){var r=t.value;if(Dv.indexOf(r)<0)return!1}return!0}(r.numberFormat.template))return!0}}var Mv=[14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57],Nv=/^\[\$-414\]/,Iv=/;@$/;var Dv=["ss","mm","h","hh","am","pm","d","dd","m","mm","mmm","mmmm","yy","yyyy","e"];function Fv(e,t,n){var r=n.getInlineStringValue,i=n.getInlineStringXml,s=n.getStyleId,o=n.styles,a=n.values,l=n.properties,u=n.options;switch(t||(t="n"),t){case"str":e=zv(e,u);break;case"inlineStr":if(void 0===(e=r()))throw new Error('Unsupported "inline string" cell value structure: '.concat(i()));e=zv(e,u);break;case"s":var c=Number(e);if(isNaN(c))throw new Error('Invalid "shared" string index: '.concat(e));if(c>=a.length)throw new Error('An out-of-bounds "shared" string index: '.concat(e));e=zv(e=a[c],u);break;case"b":if("1"===e)e=!0;else{if("0"!==e)throw new Error('Unsupported "boolean" cell value: '.concat(e));e=!1}break;case"z":e=void 0;break;case"e":e=function(e){switch(e){case 0:return"#NULL!";case 7:return"#DIV/0!";case 15:return"#VALUE!";case 23:return"#REF!";case 29:return"#NAME?";case 36:return"#NUM!";case 42:return"#N/A";case 43:return"#GETTING_DATA";default:return"#ERROR_".concat(e)}}(e);break;case"d":if(void 0===e)break;var h=new Date(e);if(isNaN(h.valueOf()))throw new Error('Unsupported "date" cell value: '.concat(e));e=h;break;case"n":if(void 0===e)break;e=Pv(s(),o,u)?Ov(e=Lv(e),l):(u.parseNumber||Lv)(e);break;default:throw new TypeError("Cell type not supported: ".concat(t))}return void 0===e&&(e=null),e}function zv(e,t){return!1!==t.trim&&(e=e.trim()),""===e&&(e=void 0),e}function Lv(e){var t=Number(e);if(isNaN(t))throw new Error('Invalid "numeric" cell value: '.concat(e));return t}var jv=["","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function Vv(e){for(var t=0,n=0;n<e.length;)t*=26,t+=jv.indexOf(e[n]),n++;return t}function Uv(e){return e=e.split(/(\d+)/),[parseInt(e[1]),Vv(e[0].trim())]}function Bv(e,t,n,r,i,s,o){var a,l=Uv(e.getAttribute("r")),u=function(e,t){return hv(t,"v")}(0,e),c=u&&u.textContent;return e.hasAttribute("t")&&(a=e.getAttribute("t")),{row:l[0],column:l[1],value:Fv(c,a,{getInlineStringValue:function(){return function(e,t){if(t.firstChild&&"is"===gv(t.firstChild)&&t.firstChild.firstChild&&"t"===gv(t.firstChild.firstChild))return t.firstChild.firstChild.textContent}(0,e)},getInlineStringXml:function(){return mv(e)},getStyleId:function(){return e.getAttribute("s")},styles:i,values:r,properties:s,options:o})}}function Gv(e,t,n,r,i,s){var o=function(e){var t=hv(e.documentElement,"sheetData"),n=[];return fv(t,"row",function(e){fv(e,"c",function(e){n.push(e)})}),n}(e);return 0===o.length?[]:o.map(function(e){return Bv(e,0,0,n,r,i,s)})}function $v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,s,o,a=[],l=!0,u=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return a}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return qv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qv(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Hv(e){var t=function(e){var t=hv(e.documentElement,"dimension");if(t)return t.getAttribute("ref")}(e);if(t)return 1===(t=t.split(":").map(Uv).map(function(e){var t=$v(e,2);return{row:t[0],column:t[1]}})).length&&(t=[t[0],t[0]]),t}function Wv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Zv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Zv(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Zv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Kv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xv(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Xv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Yv(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,s,o,a=[],l=!0,u=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return a}}(e,t)||Qv(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qv(e,t){if(e){if("string"==typeof e)return Jv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Jv(e,t):void 0}}function Jv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function eb(e,t){var n=e.dimensions,r=e.cells;if(0===r.length)return[];var i=Yv(n,2);i[0];for(var s=i[1],o=s.column,a=s.row,l=new Array(a),u=0;u<a;){l[u]=new Array(o);for(var c=0;c<o;)l[u][c]=null,c++;u++}for(var h,d=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=Qv(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(h=d()).done;){var f=h.value,p=f.row-1,g=f.column-1;g<o&&p<a&&(l[p][g]=f.value)}var m=t.rowIndexSourceMap;if(m)for(var _=0;_<l.length;)m[_]=_,_++;return l=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.rowIndexSourceMap,r=t.accessor,i=void 0===r?function(e){return e}:r,s=t.onlyTrimAtTheEnd,o=e.length-1;o>=0;){for(var a,l=!0,u=Wv(e[o]);!(a=u()).done;)if(null!==i(a.value)){l=!1;break}if(l)e.splice(o,1),n&&n.splice(o,1);else if(s)break;o--}return e}(function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.accessor,r=void 0===n?function(e){return e}:n,i=t.onlyTrimAtTheEnd,s=e[0].length-1;s>=0;){for(var o,a=!0,l=Kv(e);!(o=l()).done;)if(null!==r(o.value[s])){a=!1;break}if(a)for(var u=0;u<e.length;)e[u].splice(s,1),u++;else if(i)break;s--}return e}(l,{onlyTrimAtTheEnd:!0}),{onlyTrimAtTheEnd:!0,rowIndexSourceMap:m}),t.transformData&&(l=t.transformData(l)),l}function tb(e){"@babel/helpers - typeof";return tb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},tb(e)}function nb(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return rb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rb(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function rb(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ib(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sb(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ib(Object(n),!0).forEach(function(t){ob(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ib(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ob(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==tb(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!==tb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===tb(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ab(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.sheet||(n=sb({sheet:1},n));var r=function(t){if(!e[t])throw new Error('"'.concat(t,'" file not found inside the *.xlsx file zip archive'));return e[t]},i=vv(r("xl/_rels/workbook.xml.rels"),t),s=i.sharedStrings?function(e,t){return e?_v(t.createDocument(e)):[]}(r(i.sharedStrings),t):[],o=i.styles?Sv(r(i.styles),t):{},a=yv(r("xl/workbook.xml"),t);if(n.getSheets)return a.sheets.map(function(e){return{name:e.name}});var l=function(e,t){if("number"==typeof e){var n=t[e-1];return n&&n.relationId}for(var r,i=nb(t);!(r=i()).done;){var s=r.value;if(s.name===e)return s.relationId}}(n.sheet,a.sheets);if(!l||!i.sheets[l])throw function(e,t){var n=t&&t.map(function(e,t){return'"'.concat(e.name,'" (#').concat(t+1,")")}).join(", ");return new Error("Sheet ".concat("number"==typeof e?"#"+e:'"'+e+'"'," not found in the *.xlsx file.").concat(t?" Available sheets: "+n+".":""))}(n.sheet,a.sheets);var u=function(e,t,n,r,i,s){var o=t.createDocument(e),a=Gv(o,0,n,r,i,s),l=Hv(o)||function(e){var t=function(e,t){return e-t},n=e.map(function(e){return e.row}).sort(t),r=e.map(function(e){return e.column}).sort(t),i=n[0],s=n[n.length-1];return[{row:i,column:r[0]},{row:s,column:r[r.length-1]}]}(a);return{cells:a,dimensions:l}}(r(i.sheets[l]),t,s,o,a,n),c=eb(u,n=sb({rowIndexSourceMap:[]},n));return n.properties?{data:c,properties:a}:c}function lb(e){"@babel/helpers - typeof";return lb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lb(e)}function ub(e){var t=db();return function(){var n,r=pb(e);if(t){var i=pb(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"===lb(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function cb(e){var t="function"==typeof Map?new Map:void 0;return cb=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return hb(e,arguments,pb(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),fb(r,e)},cb(e)}function hb(e,t,n){return hb=db()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&fb(i,n.prototype),i},hb.apply(null,arguments)}function db(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function fb(e,t){return fb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},fb(e,t)}function pb(e){return pb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},pb(e)}var gb=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fb(e,t)}(n,cb(Error));var e,t=ub(n);function n(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(r=t.call(this,"invalid")).reason=e,r}return e=n,Object.defineProperty(e,"prototype",{writable:!1}),e}();function mb(e){if("string"==typeof e){var t=e;if(e=Number(e),String(e)!==t)throw new gb("not_a_number")}if("number"!=typeof e)throw new gb("not_a_number");if(isNaN(e))throw new gb("invalid_number");if(!isFinite(e))throw new gb("out_of_bounds");return e}function _b(e){if("string"==typeof e)return e;if("number"==typeof e){if(isNaN(e))throw new gb("invalid_number");if(!isFinite(e))throw new gb("out_of_bounds");return String(e)}throw new gb("not_a_string")}function yb(e){if("boolean"==typeof e)return e;throw new gb("not_a_boolean")}var vb=["isColumnOriented","ignoreEmptyRows","rowIndexSourceMap"];function bb(e){"@babel/helpers - typeof";return bb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},bb(e)}function xb(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,s,o,a=[],l=!0,u=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return a}}(e,t)||wb(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function wb(e,t){if(e){if("string"==typeof e)return Ab(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ab(e,t):void 0}}function Ab(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Eb(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Sb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tb(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Sb(Object(n),!0).forEach(function(t){kb(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sb(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kb(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==bb(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!==bb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===bb(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ob={schemaPropertyValueForMissingColumn:void 0,schemaPropertyValueForMissingValue:null,schemaPropertyShouldSkipRequiredValidationForMissingColumn:function(){return!1},getEmptyObjectValue:function(){return null},getEmptyArrayValue:function(){return null},isColumnOriented:!1,ignoreEmptyRows:!0,arrayValueSeparator:","};function Rb(e,t,n){var r=n=n?Tb(Tb({},Ob),n):Ob,i=r.isColumnOriented,s=r.ignoreEmptyRows,o=r.rowIndexSourceMap,a=Eb(r,vb),l=o&&o.slice();!function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t],i=e[r];if("object"===bb(i.type)&&!Array.isArray(i.type))throw new Error("When defining a nested schema, use a `schema` property instead of a `type` property");if(!i.schema&&!i.column)throw new Error('"column" not defined for schema entry "'.concat(r,'".'))}}(t),i&&(e=Ib(e)),s&&(e=e.filter(function(e,t){return!e.every(function(e){return null===e})||(l&&l.splice(t,1),!1)}));for(var u=e[0],c=[],h=[],d=1;d<e.length;d++){var f=Cb(t,e[d],d,void 0,u,h,a);c.push(f)}if(l)for(var p,g=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=wb(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(h);!(p=g()).done;){var m=p.value;m.row=l[m.row-1]+1}return{rows:c,errors:h}}function Cb(e,t,n,r,i,s,o){for(var a={},l=!0,u=function(e){var t=e.schemaEntry,r=e.value,i=e.error,s=e.reason,o={error:i,row:n+1,column:t.column,value:r};return s&&(o.reason=s),t.type&&(o.type=t.type),o},c=[],h=function(){var h,p,g,m,_=f[d],y=e[_],v=_,b=y.column,x="".concat(r||"",".").concat(v),w=i.indexOf(b),A=w<0;if(A||(h=t[w]),y.schema)p=Cb(y.schema,t,n,x,i,s,o);else if(A)"schemaPropertyValueForMissingColumn"in o&&(p=o.schemaPropertyValueForMissingColumn);else if(void 0===h)"schemaPropertyValueForMissingValue"in o&&(p=o.schemaPropertyValueForMissingValue);else if(null===h)"schemaPropertyValueForMissingValue"in o&&(p=o.schemaPropertyValueForMissingValue);else if(Array.isArray(y.type)){var E=function(e,t){var n=[],r=0;for(;r<e.length;){var i=xb(Nb(e,t,r),2),s=i[0];r+=i[1]+t.length,n.push(s.trim())}return n}(h,o.arrayValueSeparator).map(function(e){if(!g){var t=Pb(e,y,o);return t.error&&(p=e,g=t.error,m=t.reason),t.value}});if(!g){var S=E.every(Db);p=S?o.getEmptyArrayValue(E,{path:x}):E}}else{var T=Pb(h,y,o);g=T.error,m=T.reason,p=g?h:T.value}!g&&Db(p)&&y.required&&c.push({schemaEntry:y,value:p,isMissingColumn:A}),g?s.push(u({schemaEntry:y,value:p,error:g,reason:m})):(l&&!Db(p)&&(l=!1),void 0!==p&&(a[v]=p))},d=0,f=Object.keys(e);d<f.length;d++)h();if(l)return o.getEmptyObjectValue(a,{path:r});for(var p=0,g=c;p<g.length;p++){var m=g[p],_=m.schemaEntry,y=m.value;if(!(m.isMissingColumn&&o.schemaPropertyShouldSkipRequiredValidationForMissingColumn(_.column,{object:a}))){var v=_.required;("boolean"==typeof v?v:v(a))&&s.push(u({schemaEntry:_,value:y,error:"required"}))}}return a}function Pb(e,t,n){if(null===e)return{value:null};var r;if(t.parse)throw new Error("`schemaEntry.parse` property was renamed to `schemaEntry.type`");if(r=t.type?function(e,t,n){switch(t){case String:return Mb(e,_b);case Number:return Mb(e,mb);case Date:return Mb(e,function(e){return function(e,t){var n=t.properties;if(e instanceof Date){if(isNaN(e.valueOf()))throw new gb("out_of_bounds");return e}if("number"==typeof e){if(isNaN(e))throw new gb("invalid_number");if(!isFinite(e))throw new gb("out_of_bounds");var r=Ov(e,n);if(isNaN(r.valueOf()))throw new gb("out_of_bounds");return r}throw new gb("not_a_date")}(e,{properties:n.properties})});case Boolean:return Mb(e,yb);default:if("function"==typeof t)return Mb(e,t);throw new Error("Unsupported schema type: ".concat(t&&t.name||t))}}(e,Array.isArray(t.type)?t.type[0]:t.type,n):{value:e},r.error)return r;if(null!==r.value){if(t.oneOf&&t.oneOf.indexOf(r.value)<0)return{error:"invalid",reason:"unknown"};if(t.validate)try{t.validate(r.value)}catch(e){return{error:e.message}}}return r}function Mb(e,t){try{var n=t(e);return void 0===n?{value:null}:{value:n}}catch(e){var r={error:e.message};return e.reason&&(r.reason=e.reason),r}}function Nb(e,t,n){for(var r=0,i="";n+r<e.length;){var s=e[n+r];if(s===t)return[i,r];if('"'===s){var o=Nb(e,'"',n+r+1);i+=o[0],r+=1+o[1]+1}else i+=s,r++}return[i,r]}var Ib=function(e){return e[0].map(function(t,n){return e.map(function(e){return e[n]})})};function Db(e){return null==e}function Fb(e){"@babel/helpers - typeof";return Fb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fb(e)}var zb=["schema"];function Lb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jb(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lb(Object(n),!0).forEach(function(t){Vb(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lb(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Vb(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Fb(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!==Fb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Fb(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ub(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Bb(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(t=e,t instanceof File||t instanceof Blob?t.arrayBuffer().then(cv):cv(t)).then(function(e){return function(e,t,n){var r=n.schema,i=Ub(n,zb);if(i.map)throw new Error("`map` option was removed. Pass a `schema` option instead.");var s=ab(e,t,jb(jb({},i),{},{properties:r||i.properties}));return r?Rb(s.data,r,jb(jb({},i),{},{properties:s.properties})):s}(e,ky,n)})}const Gb=({onParsed:t})=>{const[n,r]=e.useState(!1);return b(ql,{accept:".xlsx, .xls",loading:n,onFilesLoad:({files:e})=>{const n=e[0];r(!0),Bb(n).then(e=>{t(e)}).finally(()=>{r(!1)})},children:"Загрузить файлы excel"})},$b=({children:t,configOptions:n})=>{const[r,i]=e.useState(null),[s,o]=e.useState("");return e.useEffect(()=>(Uo.initialize({...n,onCheck:e=>{const{valid:t,reason:r}=e;o(r),i(t),n.onCheck?.(e)}}),()=>{Uo.deactivate()}),[n]),null===r?b(my,{color:"primary"}):r?b(e.Fragment,{children:t}):b(B,{color:"error",children:s})},qb=new class{#W;#j;#d;#Z;#K;#X;#Y;#Q;constructor(e={}){this.#W=e.queryCache||new Va,this.#j=e.mutationCache||new za,this.#d=e.defaultOptions||{},this.#Z=new Map,this.#K=new Map,this.#X=0}mount(){this.#X++,1===this.#X&&(this.#Y=pa.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#W.onFocus())}),this.#Q=ya.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#W.onOnline())}))}unmount(){this.#X--,0===this.#X&&(this.#Y?.(),this.#Y=void 0,this.#Q?.(),this.#Q=void 0)}isFetching(e){return this.#W.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#j.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#W.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#W.build(this,t),r=n.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ko(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#W.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=this.#W.get(r.queryHash),s=i?.state.data,o=function(e,t){return"function"==typeof e?e(t):e}(t,s);if(void 0!==o)return this.#W.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return _a.batch(()=>this.#W.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#W.get(t.queryHash)?.state}removeQueries(e){const t=this.#W;_a.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){const n=this.#W;return _a.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=_a.batch(()=>this.#W.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Ho).catch(Ho)}invalidateQueries(e,t={}){return _a.batch(()=>(this.#W.findAll(e).forEach(e=>{e.invalidate()}),"none"===e?.refetchType?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=_a.batch(()=>this.#W.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Ho)),"paused"===e.state.fetchStatus?Promise.resolve():t}));return Promise.all(r).then(Ho)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const n=this.#W.build(this,t);return n.isStaleByTime(Ko(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ho).catch(Ho)}fetchInfiniteQuery(e){return e.behavior=Na(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ho).catch(Ho)}ensureInfiniteQueryData(e){return e.behavior=Na(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ya.isOnline()?this.#j.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#W}getMutationCache(){return this.#j}getDefaultOptions(){return this.#d}setDefaultOptions(e){this.#d=e}setQueryDefaults(e,t){this.#Z.set(ea(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#Z.values()],n={};return t.forEach(t=>{ta(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#K.set(ea(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#K.values()],n={};return t.forEach(t=>{ta(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#d.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Jo(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ha&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#d.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#W.clear(),this.#j.clear()}},Hb=e=>b(Ga,{...e,client:qb}),Wb=({children:e,themeOptions:t})=>{const n=re(t);return b(ie,{theme:n,children:e})},Zb=({children:e,configOptions:t,themeOptions:n})=>b(Jt,{children:b(Hb,{children:b(Lo,{children:b(Wb,{themeOptions:n,children:b(zl,{children:b($b,{configOptions:t,children:e})})})})})}),Kb=()=>{const{enqueueSnackbar:e}=c(De);return({variant:t,message:n})=>{e({variant:t,message:n,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:3e3,hideIconVariant:!0})}},Xb=()=>{const e=Kb();return t=>{const{response:n}=t;if(n){const{data:t}=n;if(t){const{detail:n}=t;n&&n.forEach(t=>{e({variant:"error",message:t})})}}}},Yb=()=>Za({mutationKey:["logout-mutation"],mutationFn:async e=>await Uo.instance.apiService.post({url:"logout"}),onError:Xb(),onSuccess:()=>{qb.invalidateQueries({queryKey:["user"]})}}),Qb=()=>Za({mutationKey:["sign-in-mutation"],mutationFn:async({body:{username:e,password:t}})=>{const n=tn({username:e,password:en(t)});return await Uo.instance.apiService.post({url:"token",body:n,config:{headers:{"Content-Type":"application/x-www-form-urlencoded"}}})}}),Jb=({children:e})=>b(T,{sx:{display:"flex",alignItems:"center",height:"100vh",width:"100vw",overflow:"hidden"},children:b(T,{sx:{margin:"auto",maxWidth:"400px",width:"100%"},children:b(Hl,{children:e})})}),ex=Yp().shape({username:zp().required(),password:zp().required()}),tx=({onSuccessSignIn:t})=>{const n=Yb(),r=Qb(),i=Kb(),s=Oc({defaultValues:{username:"",password:""},resolver:Ng(ex)}),{register:o,formState:{isValid:a}}=s;return e.useEffect(()=>{n.mutate()},[]),e.useEffect(()=>{if(r.error){const{response:e}=r.error;if(e){const{data:{detail:t}}=e;i({message:t,variant:"error"})}}},[r.error]),e.useEffect(()=>{r.data&&t(r.data)},[r.data]),b(Jb,{children:x(Ic,{form:s,onSubmit:e=>{r.mutate({body:e})},sx:{justifyContent:"center",justifyItems:"center",alignContent:"center",alignItems:"center"},children:[b(B,{variant:"h4",children:"Authorization"}),b(pf,{...o("username"),label:"Login",placeholder:"Enter your login"}),b(pf,{...o("password"),label:"Password",placeholder:"Enter your password",type:"password"}),b(jl,{type:"submit",disabled:!a,children:"Sign in"})]})})};var nx,rx,ix={};function sx(e,t){if(nx)if(rx){var n="var shared_chunk = {}; ("+nx+")(shared_chunk); ("+rx+")(shared_chunk);",r={};nx(r),(ix=t(r)).workerURL=window.URL.createObjectURL(new Blob([n],{type:"text/javascript"}))}else rx=t;else nx=t}sx(0,function(e){const t={};try{window instanceof Window&&window.document instanceof HTMLDocument&&(t.is_worker=!1,t.is_main=!0)}catch(e){t.is_worker=!0,t.is_main=!1,self.window={document:{}},self.document=self.window.document}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==n(t)?t:t+""}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s,o="v0.22.0",a=s={},l=0,u={};function c(e){var t=[];"string"==typeof e&&(t=e.split("."),e=t.pop());var n=s.targets;for(let e=0;e<t.length;e++){if(!n[t[e]])return[];n=n[t[e]]}return[e,n]}function h(e,t=null,n=null,r=[]){if(!e)return r;if(Array.isArray(e))e.forEach((t,n)=>h(t,e,n,r));else if("object"==typeof e)if(e instanceof ArrayBuffer)r.push({object:e,parent:t,property:n});else if(e.buffer instanceof ArrayBuffer)r.push({object:e.buffer,parent:t,property:n});else for(let t in e)h(e[t],e,t,r);return r}function d(e){Array.isArray(e)&&e.filter(e=>e.parent&&e.property).forEach(e=>delete e.parent[e.property])}s.targets={},s.addTarget=function(e,t){s.targets[e]=t},s.removeTarget=function(e){e&&delete s.targets[e]},s.withTransferables=function(...e){if(!(this instanceof s.withTransferables))return new s.withTransferables(...e);this.value=e,this.transferables=h(this.value)},t.is_main&&(s.postMessage=function(e,t,...n){if(Array.isArray(e))return Promise.all(e.map(e=>s.postMessage(e,t,...n)));let r={};"object"==typeof t&&(r=t,t=t.method);var i=new Promise((e,r)=>{u[l]={method:t,message:n,resolve:e,reject:r}});let o,a=[];return n&&1===n.length&&n[0]instanceof s.withTransferables&&(a=n[0].transferables,n=n[0].value),o={type:"main_send",message_id:l,method:t,message:n},r.stringify&&(o=JSON.stringify(o)),e.postMessage(o,a.map(e=>e.object)),d(a),a.length>0&&m("trace",`'${t}' transferred ${a.length} objects to worker thread`),l++,i},s.addWorker=function(e){if(!(e instanceof Worker))throw Error("Worker broker could not add non-Worker object",e);e.addEventListener("message",function(t){let n="string"==typeof t.data?JSON.parse(t.data):t.data,r=n.message_id;if("worker_reply"===n.type)u[r]&&(n.error?u[r].reject(n.error):u[r].resolve(n.message),delete u[r]);else if("worker_send"===n.type&&null!=r){let t,i,o,a,l;try{if([a,o]=c(n.method),!o)throw Error(`Worker broker could not dispatch message type ${n.method} on target ${n.target} because no object with that name is registered on main thread`);if(l="function"==typeof o[a]&&o[a],!l)throw Error(`Worker broker could not dispatch message type ${n.method} on target ${n.target} because object has no method with that name`);t=l.apply(o,n.message)}catch(e){i=e}let u,h=[];t instanceof Promise?t.then(t=>{t instanceof s.withTransferables&&(h=t.transferables,t=t.value[0]),u={type:"main_reply",message_id:r,message:t},e.postMessage(u,h.map(e=>e.object)),d(h),h.length>0&&m("trace",`'${a}' transferred ${h.length} objects to worker thread`)},t=>{e.postMessage({type:"main_reply",message_id:r,error:t instanceof Error?`${t.message}: ${t.stack}`:t})}):(t instanceof s.withTransferables&&(h=t.transferables,t=t.value[0]),u={type:"main_reply",message_id:r,message:t,error:i instanceof Error?`${i.message}: ${i.stack}`:i},e.postMessage(u,h.map(e=>e.object)),d(h),h.length>0&&m("trace",`'${a}' transferred ${h.length} objects to worker thread`))}})},s.getMessages=function(){return u},s.getMessageId=function(){return l}),t.is_worker&&(s.postMessage=function(e,...t){let n={};"object"==typeof e&&(n=e,e=e.method);var r=new Promise((n,r)=>{u[l]={method:e,message:t,resolve:n,reject:r}});let i,o=[];return t&&1===t.length&&t[0]instanceof s.withTransferables&&(o=t[0].transferables,t=t[0].value),i={type:"worker_send",message_id:l,method:e,message:t},n.stringify&&(i=JSON.stringify(i)),self.postMessage(i,o.map(e=>e.object)),d(o),o.length>0&&m("trace",`'${e}' transferred ${o.length} objects to main thread`),l++,r},self.addEventListener("message",function(e){let t="string"==typeof e.data?JSON.parse(e.data):e.data,n=t.message_id;if("main_reply"===t.type)u[n]&&(t.error?u[n].reject(t.error):u[n].resolve(t.message),delete u[n]);else if("main_send"===t.type&&null!=n){let r,i,o,a,l;try{if([a,o]=c(t.method),!o)throw Error(`Worker broker could not dispatch message type ${t.method} on target ${t.target} because no object with that name is registered on main thread`);if(l="function"==typeof o[a]&&o[a],!l)throw Error(`Worker broker could not dispatch message type ${t.method} because worker has no method with that name`);r=l.apply(o,t.message)}catch(e){i=e}let u,h=[];r instanceof Promise?r.then(e=>{e instanceof s.withTransferables&&(h=e.transferables,e=e.value[0]),u={type:"worker_reply",message_id:n,message:e},self.postMessage(u,h.map(e=>e.object)),d(h),h.length>0&&m("trace",`'${a}' transferred ${h.length} objects to main thread`)},e=>{self.postMessage({type:"worker_reply",message_id:n,error:e instanceof Error?`${e.message}: ${e.stack}`:e})}):(r instanceof s.withTransferables&&(h=r.transferables,r=r.value[0]),u={type:"worker_reply",message_id:n,message:r,error:i instanceof Error?`${i.message}: ${i.stack}`:i},self.postMessage(u,h.map(e=>e.object)),d(h),h.length>0&&m("trace",`'${a}' transferred ${h.length} objects to main thread`))}}));const f={silent:-1,error:0,warn:1,info:2,debug:3,trace:4},p={};let g={};function m(e,...n){let r="object"==typeof e?e.level:e;if(f[r]<=f[m.level]){if(t.is_worker)return a.postMessage({method:"_logProxy",stringify:!0},e,...n);{if("object"==typeof e&&!0===e.once){if(g[JSON.stringify(n)])return Promise.resolve(!1);g[JSON.stringify(n)]=!0}let i=function(e){if(t.is_main)return p[e]=p[e]||(console[e]?console[e]:console.log).bind(console),p[e]}(r);n.length>1?i(`Tangram ${o} [${r}]: ${n[0]}`,...n.slice(1)):i(`Tangram ${o} [${r}]: ${n[0]}`)}return Promise.resolve(!0)}return Promise.resolve(!1)}m.level="info",m.workers=null,m.setLevel=function(e){m.level=e,t.is_main&&Array.isArray(m.workers)&&a.postMessage(m.workers,"_logSetLevelProxy",e)},t.is_main&&(m.setWorkers=function(e){m.workers=e},m.reset=function(){g={}}),a.addTarget("_logProxy",m),a.addTarget("_logSetLevelProxy",m.setLevel);const _={};let y;a.addTarget("Utils",_),_.isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},_.isMicrosoft=function(){return/(Trident\/7.0|Edge[ /](\d+[.\d]+))/i.test(navigator.userAgent)},_._requests={},_._proxy_requests={},_.io=function(e,n=6e4,r="text",i="GET",s={},o=null,l=!1){if(t.is_worker&&_.isMicrosoft())return m("debug","Proxying request for URL to worker",e),o&&(_._proxy_requests[o]=!0),a.postMessage("Utils.io",e,n,r,i,s,o,!0);var u=new XMLHttpRequest,c=new Promise((t,o)=>{if(u.open(i,e,!0),u.timeout=n,u.responseType=r,s&&"object"==typeof s)for(let e in s)u.setRequestHeader(e,s[e]);u.onload=()=>{200===u.status?["text","json"].indexOf(u.responseType)>-1?t({body:u.responseText,status:u.status}):t({body:u.response,status:u.status}):204===u.status?t({body:null,status:u.status}):o(Error("Request error with a status of "+u.statusText))},u.onerror=e=>{o(Error("There was a network error"+e.toString()))},u.ontimeout=e=>{o(Error("timeout "+e.toString()))},u.send()});return c=c.then(e=>(o&&delete _._requests[o],l?a.withTransferables(e):e)),o&&(_._requests[o]=u),c},_.cancelRequest=function(e){if(t.is_worker&&_._proxy_requests[e])return a.postMessage("Utils.cancelRequest",e);_._requests[e]?(m("trace",`Cancelling network request key '${e}'`),_._requests[e].abort(),delete _._requests[e]):m("trace",`Could not find network request key '${e}'`)},_.serializeWithFunctions=function(e){return"function"==typeof e?e.toString():JSON.stringify(e,function(e,t){return"function"==typeof t?t.toString():t})},_.use_high_density_display=!0,_.updateDevicePixelRatio=function(){let e=_.device_pixel_ratio;return _.device_pixel_ratio=_.use_high_density_display&&window.devicePixelRatio||1,_.device_pixel_ratio!==e},t.is_main&&_.updateDevicePixelRatio(),_.isPowerOf2=function(e){return!(e&e-1)},_.interpolate=function(e,t,n){if(!Array.isArray(t)||!Array.isArray(t[0]))return t;if(t.length<1)return t;var r,i,s,o,a;if(e<=t[0][0])o=t[0][1],"function"==typeof n&&(o=n(o));else if(e>=t[t.length-1][0])o=t[t.length-1][1],"function"==typeof n&&(o=n(o));else for(var l=0;l<t.length-1;l++)if(e>=t[l][0]&&e<t[l+1][0]){if(r=t[l][0],i=t[l+1][0],Array.isArray(t[l][1])){o=[];for(var u=0;u<t[l][1].length;u++)"function"==typeof n?(a=n(t[l][1][u]),s=n(t[l+1][1][u])-a,o[u]=s*(e-r)/(i-r)+a):(s=t[l+1][1][u]-t[l][1][u],o[u]=s*(e-r)/(i-r)+t[l][1][u])}else"function"==typeof n?(a=n(t[l][1]),o=(s=n(t[l+1][1])-a)*(e-r)/(i-r)+a):o=(s=t[l+1][1]-t[l][1])*(e-r)/(i-r)+t[l][1];break}return o},_.toCSSColor=function(e){if(null!=e)return 1===e[3]?`rgb(${e.slice(0,3).map(e=>Math.round(255*e)).join(", ")})`:`rgba(${e.map((e,t)=>t<3&&Math.round(255*e)||e).join(", ")})`};var v=y={draw_label_collision_boxes:!1,draw_label_texture_boxes:!1,suppress_label_fade_in:!1,suppress_label_snap_animation:!1,show_hidden_labels:!1,layer_stats:!1,wireframe:!1};function b(e){if("string"==typeof e&&-1===e.search(/^(data|blob):/)){let t=e.indexOf("?");t>-1&&(e=e.substr(0,t));let n=e.indexOf("#");return n>-1&&(e=e.substr(0,n)),e.substr(0,e.lastIndexOf("/")+1)||""}return""}function x(e){if("string"==typeof e)return!(e.search(/^(http|https|data|blob):/)>-1||"//"===e.substr(0,2))}let w;function A(e,t){e=e.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null===n?"":decodeURIComponent(n[1].replace(/\+/g," "))}const E={id:0,queue:[],max_time:20,start_time:null,state:{},add(e){e.id=E.id++,e.max_time=e.max_time||E.max_time,e.pause_factor=e.pause_factor||1;let t=new Promise((t,n)=>{e.resolve=t,e.reject=n});return e.promise=t,e.elapsed=0,e.total_elapsed=0,e.stats={calls:0},this.queue.push(e),this.start_time=this.start_time||performance.now(),this.elapsed=performance.now()-this.start_time,(this.elapsed<E.max_time||e.immediate)&&this.process(e),e.promise},remove(e){let t=this.queue.indexOf(e);t>-1&&this.queue.splice(t,1)},process(e){if(!this.state.user_moving_view||!1!==e.user_moving_view)return e.pause?(e.pause--,!0):(e.stats.calls++,e.start_time=performance.now(),e.run(e))},processAll(){this.start_time=this.start_time||performance.now();for(let e=0;e<this.queue.length;e++){let t=this.queue[e];if(!0!==this.process(t)&&(t.pause||(t.pause=t.elapsed>t.max_time?t.pause_factor:0),t.total_elapsed+=t.elapsed),this.elapsed=performance.now()-this.start_time,this.elapsed>=E.max_time){this.start_time=null;break}}},finish(e,t){return e.elapsed=performance.now()-e.start_time,e.total_elapsed+=e.elapsed,this.remove(e),e.resolve(t),e.promise},cancel(e){let t;e.cancel instanceof Function&&(t=e.cancel(e)),e.resolve(t)},shouldContinue(e){return e.elapsed=performance.now()-e.start_time,this.elapsed=performance.now()-this.start_time,e.elapsed<e.max_time&&this.elapsed<E.max_time},removeForTile(e){for(let t=this.queue.length-1;t>=0;t--)this.queue[t].tile_id===e&&(this.cancel(this.queue[t]),this.queue.splice(t,1))},setState(e){this.state=e}};function S(e){let t=[];return Object.assign(e,{subscribe(e){-1===t.indexOf(e)&&t.push(e)},unsubscribe(e){let n=t.indexOf(e);n>-1&&t.splice(n,1)},unsubscribeAll(){t=[]},trigger(e,...n){t.forEach(t=>{if("function"==typeof t[e])try{t[e](...n)}catch(t){m("warn",`Caught exception in listener for event '${e}':`,t)}})},hasSubscribersFor(e){let n=!1;return t.forEach(t=>{"function"==typeof t[e]&&(n=!0)}),n}})}function T(e,t){let n={};return t.forEach(t=>n[t]=e[t]),n}class k{constructor(e,t,n={}){n=k.sliceOptions(n),this.gl=e,this.texture=e.createTexture(),this.texture&&(this.valid=!0),this.bind(),this.name=t,this.retain_count=0,this.config_type=null,this.loading=null,this.loaded=!1,this.filtering=n.filtering,this.density=n.density||1,this.sprites=n.sprites,this.texcoords={},this.sizes={},this.css_sizes={},this.aspects={},this.setData(1,1,new Uint8Array([0,0,0,0]),{filtering:"nearest"}),this.loaded=!1,k.textures[this.name]&&(this.retain_count=k.textures[this.name].retain_count,k.textures[this.name].retain_count=0,k.textures[this.name].destroy()),k.textures[this.name]=this,k.texture_configs[this.name]=JSON.stringify(Object.assign({name:t},n)),this.load(n),m("trace",`creating Texture ${this.name}`)}destroy({force:e}={}){this.retain_count>0&&!e?m("error",`Texture '${this.name}': destroying texture with retain count of '${this.retain_count}'`):this.valid&&(this.gl.deleteTexture(this.texture),this.texture=null,k.textures[this.name]===this&&(delete k.textures[this.name],delete k.texture_configs[this.name]),this.valid=!1,m("trace",`destroying Texture ${this.name}`))}retain(){this.retain_count++}release(){this.retain_count<=0&&m("error",`Texture '${this.name}': releasing texture with retain count of '${this.retain_count}'`),this.retain_count--,this.retain_count<=0&&this.destroy()}bind(e=0){this.valid&&(k.activeUnit!==e&&(this.gl.activeTexture(this.gl.TEXTURE0+e),k.activeUnit=e,k.boundTexture=null),k.boundTexture!==this.texture&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),k.boundTexture=this.texture))}load(e){return e?(this.loading=null,"string"==typeof e.url?(this.config_type="url",this.setUrl(e.url,e)):e.element?(this.config_type="element",this.setElement(e.element,e)):e.data&&e.width&&e.height&&(this.config_type="data",this.setData(e.width,e.height,e.data,e)),this.loading=this.loading&&this.loading.then(()=>(this.calculateSprites(),this))||Promise.resolve(this),this.loading):this.loading||Promise.resolve(this)}setUrl(e,t={}){if(this.valid)return this.url=e,this.loading=new Promise(e=>{let n=new Image;n.onload=()=>{try{if("data:"===this.url.slice(0,5)){const e=document.createElement("canvas"),r=e.getContext("2d");e.width=n.width,e.height=n.height,r.drawImage(n,0,0),this.setElement(e,t)}else this.setElement(n,t)}catch(e){this.loaded=!1,m("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,e,t),k.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:e,texture:t})}this.loaded=!0,e(this)},n.onerror=n=>{this.loaded=!1,m("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,n,t),k.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:n,texture:t}),e(this)},_.isSafari()&&"data:"===this.url.slice(0,5)||(n.crossOrigin="anonymous"),n.src=this.url}),this.loading}setData(e,t,n,r={}){return this.width=e,this.height=t,Array.isArray(n)&&(n=new Uint8Array(n)),this.update(n,r),this.setFiltering(r),this.loaded=!0,this.loading=Promise.resolve(this),this.loading}setElement(e,t){let n=e;if("string"==typeof e&&(e=document.querySelector(e)),e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement)this.update(e,t),this.setFiltering(t);else{this.loaded=!1;let e=`the 'element' parameter (\`element: ${JSON.stringify(n)}\`) must be a CSS `;e+="selector string, or a <canvas>, <image> or <video> object",m("warn",`Texture '${this.name}': ${e}`,t),k.trigger("warning",{message:`Failed to load texture because ${e}`,texture:t})}return this.loaded=!0,this.loading=Promise.resolve(this),this.loading}update(e,t={}){this.valid&&(this.bind(),e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLImageElement&&e.complete?(this.width=e.width,this.height=e.height,this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1!==t.UNPACK_FLIP_Y_WEBGL),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.UNPACK_PREMULTIPLY_ALPHA_WEBGL||!1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e)):(this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,null),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,null),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.width,this.height,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e)),k.trigger("update",this))}setFiltering(e={}){if(this.valid){e.filtering=e.filtering||"linear";var t=this.gl;this.bind(),_.isPowerOf2(this.width)&&_.isPowerOf2(this.height)?(this.power_of_2=!0,t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,e.TEXTURE_WRAP_S||e.repeat&&t.REPEAT||t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,e.TEXTURE_WRAP_T||e.repeat&&t.REPEAT||t.CLAMP_TO_EDGE),"mipmap"===e.filtering?(this.filtering="mipmap",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.generateMipmap(t.TEXTURE_2D)):"linear"===e.filtering?(this.filtering="linear",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)):"nearest"===e.filtering&&(this.filtering="nearest",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST))):(this.power_of_2=!1,t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),"nearest"===e.filtering?(this.filtering="nearest",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)):(this.filtering="linear",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR))),k.trigger("update",this)}}calculateSprites(){if(this.sprites)for(let e in this.sprites){let t=this.sprites[e];this.texcoords[e]=k.getTexcoordsForSprite([t[0],t[1]],[t[2],t[3]],[this.width,this.height]),this.sizes[e]=[t[2],t[3]],this.css_sizes[e]=[t[2]/this.density,t[3]/this.density],this.aspects[e]=t[2]/t[3]}}byteSize(){return Math.round(this.width*this.height*4*("mipmap"==this.filtering?1.33:1))}}k.create=function(e,t,n){return new k(e,t,n)},k.retain=function(e){k.textures[e]&&k.textures[e].retain()},k.release=function(e){k.textures[e]&&k.textures[e].release()},k.destroy=function(e){Object.keys(k.textures).forEach(t=>{var n=k.textures[t];n.gl===e&&n.destroy({force:!0})})},k.getSpriteInfo=function(e,t){let n=k.textures[e];return n&&{size:n.sizes[t],css_size:n.css_sizes[t],aspect:n.aspects[t],texcoords:n.texcoords[t]}},k.getTexcoordsForSprite=function(e,t,n){var r=n[1]-e[1]-t[1];return[e[0]/n[0],r/n[1],(t[0]+e[0])/n[0],(t[1]+r)/n[1]]},k.createFromObject=function(e,t){let n=[];if(t)for(let r in t){let i=t[r];if(i.skip_create)continue;if(!k.changed(r,i))continue;let s=k.create(e,r,i);n.push(s.loading)}return Promise.all(n)},k.default="__default",k.createDefault=function(e){return k.create(e,k.default)},k.sliceOptions=function(e){return{filtering:e.filtering,sprites:e.sprites,url:e.url,element:e.element,data:e.data,width:e.width,height:e.height,density:e.density,repeat:e.repeat,TEXTURE_WRAP_S:e.TEXTURE_WRAP_S,TEXTURE_WRAP_T:e.TEXTURE_WRAP_T,UNPACK_FLIP_Y_WEBGL:e.UNPACK_FLIP_Y_WEBGL,UNPACK_PREMULTIPLY_ALPHA_WEBGL:e.UNPACK_PREMULTIPLY_ALPHA_WEBGL}},k.changed=function(e,t){let n=k.textures[e];if(n){if("element"===n.config_type||null!=t.element)return!0;if(t=k.sliceOptions(t),k.texture_configs[e]===JSON.stringify(Object.assign({name:e},t)))return!1}return!0},k.getInfo=function(e){if(e||(e=Object.keys(k.textures)),Array.isArray(e))return Promise.all(e.map(e=>k.getInfo(e)));var t=k.textures[e];return t?(t.loading||Promise.resolve(t)).then(()=>({name:t.name,width:t.width,height:t.height,density:t.density,css_size:[t.width/t.density,t.height/t.density],aspect:t.width/t.height,sprites:t.sprites,texcoords:t.texcoords,sizes:t.sizes,css_sizes:t.css_sizes,aspects:t.aspects,filtering:t.filtering,power_of_2:t.power_of_2,valid:t.valid})):Promise.resolve(null)},k.syncTexturesToWorker=function(e){return a.postMessage("Texture.getInfo",e).then(e=>(e&&e.filter(e=>e).forEach(e=>k.textures[e.name]=e),k.textures))},k.getMaxTextureSize=function(e){return e.getParameter(e.MAX_TEXTURE_SIZE)},k.textures={},k.texture_configs={},k.boundTexture=null,k.activeUnit=null,a.addTarget("Texture",k),S(k);var O={parseUniforms:function(e={}){var t=[];for(const[n,r]of Object.entries(e))if("number"==typeof r)t.push({type:"float",method:"1f",name:n,value:r,path:[n]});else if(Array.isArray(r)){if("number"==typeof r[0])r.length>=2&&r.length<=4?t.push({type:"vec"+r.length,method:r.length+"fv",name:n,value:r,path:[n]}):r.length>4&&t.push({type:"float[]",method:"1fv",name:n+"[0]",value:r,path:[n]});else if("string"==typeof r[0])for(let e=0;e<r.length;e++)t.push({type:"sampler2D",method:"1i",name:n+"["+e+"]",value:r[e],path:[n,e]});else if(Array.isArray(r[0])&&"number"==typeof r[0][0]&&r[0].length>=2&&r[0].length<=4)for(let e=0;e<r.length;e++)t.push({type:"vec"+r[0].length,method:r[0].length+"fv",name:n+"["+e+"]",value:r[e],path:[n,e]})}else"boolean"==typeof r?t.push({type:"bool",method:"1i",name:n,value:r,path:[n]}):"string"==typeof r&&t.push({type:"sampler2D",method:"1i",name:n,value:r,path:[n]});return t},defineVariable:function(e,t){var n,r;if("number"==typeof t)n="float";else if(Array.isArray(t))"number"==typeof t[0]?t.length>=2&&t.length<=4?n="vec"+t.length:(n="float",r=t.length):"string"==typeof t[0]?(n="sampler2D",r=t.length):Array.isArray(t[0])&&"number"==typeof t[0][0]&&t[0].length>=2&&t[0].length<=4&&(n="vec"+t[0].length,r=t.length);else if("boolean"==typeof t)n="bool";else{if("string"!=typeof t)return;n="sampler2D"}var i="";return i+=`${n} ${e}`,r&&(i+=`[${r}]`),i+";\n"},defineUniform:function(e,t){var n=O.defineVariable(e,t);if(n)return"uniform "+n},expandVec3:function(e,t=1){let n;if(Array.isArray(e)){if(2!==e.length)return e;n=[...e,t].map(parseFloat)}else n=[e,e,e].map(parseFloat);if(n&&n.every(e=>"number"==typeof e&&!isNaN(e)))return n},expandVec4:function(e,t=1){let n;if(Array.isArray(e)){if(3!==e.length)return e;n=[...e,t].map(parseFloat)}else n=[e,e,e,t].map(parseFloat);if(n&&n.every(e=>"number"==typeof e&&!isNaN(e)))return n}};let R=[];function C(e,t){let n=R.filter(t=>t[0]===e)[0];return n=n&&n[1],n||(R.push([e,{}]),n=R[R.length-1][1]),n[t]||(n[t]=e.getExtension(t)),n[t]}function P(e){var t,n,r=0;if(0===e.length)return r;for(t=0,n=e.length;t<n;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return r}function M(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var N,I,D=(I||(I=1,N=function(e){e=String(e);for(var t,n=[];t=e.match(/ERROR\:([^\n]+)/);){e=e.slice(t.index+1);var r=(o=t[1].trim()).split(":"),i=r.slice(2).join(":").trim(),s=parseInt(r[0],10),o=parseInt(r[1],10);n.push({message:i,file:s,line:o})}return n}),N),F=M(D);const z=/^\s*#pragma.*$/gm,L=/\\\s*\n/gm;class j{constructor(e,t,n,r){r=r||{},this.gl=e,this.program=null,this.compiled=!1,this.compiling=!1,this.error=null,this.defines=Object.assign({},r.defines||{}),this.blocks=Object.assign({},r.blocks||{}),this.block_scopes=Object.assign({},r.block_scopes||{}),this.extensions=r.extensions||[],this.dependent_uniforms=r.uniforms,this.uniforms={},this.attribs={},this.vertex_source=t,this.fragment_source=n,this.id=j.id++,this.name=r.name}destroy(){this.gl.useProgram(null),this.gl.deleteProgram(this.program),this.program=null,this.uniforms={},this.attribs={},this.compiled=!1}use(){this.compiled&&(j.current!==this&&this.gl.useProgram(this.program),j.current=this)}compile(){if(this.compiling)throw new Error(`ShaderProgram.compile(): skipping for ${this.id} (${this.name}) because already compiling`);this.compiling=!0,this.compiled=!1,this.error=null,this.computed_vertex_source=this.vertex_source,this.computed_fragment_source=this.fragment_source;let e=this.checkExtensions();var t,n=this.buildDefineList(),r=this.buildShaderBlockList();for(var i in r){var s=r[i];if(s&&(!Array.isArray(s)||0!==s.length)){t=new RegExp("^\\s*#pragma\\s+tangram:\\s+"+i+"\\s*$","m");var o=this.computed_vertex_source.match(t),a=this.computed_fragment_source.match(t);if(null!=o||null!=a){var l="";s.forEach(e=>{let t=`${e.scope}, ${e.key}, ${e.num}`;l+=`\n// tangram-block-start: ${t}\n`,l+=e.source,l+=`\n// tangram-block-end: ${t}\n`}),null!=o&&(this.computed_vertex_source=this.computed_vertex_source.replace(t,l)),null!=a&&(this.computed_fragment_source=this.computed_fragment_source.replace(t,l)),n["TANGRAM_BLOCK_"+i.replace(/[\s-]+/g,"_").toUpperCase()]=!0}}}this.computed_vertex_source=this.computed_vertex_source.replace(z,""),this.computed_fragment_source=this.computed_fragment_source.replace(z,""),this.ensureUniforms(this.dependent_uniforms);let u="",c=this.gl.getShaderPrecisionFormat(this.gl.FRAGMENT_SHADER,this.gl.HIGH_FLOAT);u=c&&c.precision>0?"precision highp float;\n":"precision mediump float;\n",n.TANGRAM_VERTEX_SHADER=!0,n.TANGRAM_FRAGMENT_SHADER=!1,this.computed_vertex_source=u+j.buildDefineString(n)+this.computed_vertex_source,n.TANGRAM_VERTEX_SHADER=!1,n.TANGRAM_FRAGMENT_SHADER=!0,this.computed_fragment_source=j.buildExtensionString(e)+u+j.buildDefineString(n)+this.computed_fragment_source,this.computed_vertex_source=this.computed_vertex_source.replace(L,""),this.computed_fragment_source=this.computed_fragment_source.replace(L,"");try{this.program=j.updateProgram(this.gl,this.program,this.computed_vertex_source,this.computed_fragment_source),this.compiled=!0,this.compiling=!1}catch(e){throw this.program=null,this.compiled=!1,this.compiling=!1,this.error=e,this.error.vertex_shader_source=this.computed_vertex_source,this.error.fragment_shader_source=this.computed_fragment_source,"vertex"!==e.type&&"fragment"!==e.type||(this.shader_errors=e.errors,this.shader_errors.forEach(t=>{t.type=e.type,t.block=this.block(e.type,t.line),t.line=this.block(e.type,t.line)}),this.error.shader_errors=this.shader_errors),e}this.computed_vertex_source=null,this.computed_fragment_source=null,this.use(),this.refreshUniforms(),this.refreshAttributes()}buildDefineList(){var e,t={};for(e in j.defines)t[e]=j.defines[e];for(e in this.defines)t[e]=this.defines[e];return t}buildShaderBlockList(){let e,t={};for(e in j.blocks)t[e]=[],Array.isArray(j.blocks[e])?t[e].push(...j.blocks[e].map((t,n)=>({key:e,source:t,num:n,scope:"ShaderProgram"}))):t[e]=[{key:e,source:j.blocks[e],num:0,scope:"ShaderProgram"}];for(e in this.blocks)if(t[e]=t[e]||[],Array.isArray(this.blocks[e])){let n=this.block_scopes&&this.block_scopes[e]||[],r=null,i=0;for(let s=0;s<this.blocks[e].length;s++)n[s]!==r&&(r=n[s],i=0),t[e].push({key:e,source:this.blocks[e][s],num:i,scope:r||this.name}),i++}else t[e].push({key:e,source:this.blocks[e],num:0,scope:this.name});return t}ensureUniforms(e){if(!e)return;const t=Object.entries(e).map(([e,t])=>O.defineUniform(e,t)).filter(e=>e);this.computed_vertex_source=t.join("\n")+this.computed_vertex_source,this.computed_fragment_source=t.join("\n")+this.computed_fragment_source}setUniforms(e,t=!0){this.compiled&&(t&&(this.texture_unit=0),O.parseUniforms(e).forEach(({name:e,type:t,value:n,method:r})=>{"sampler2D"===t?this.setTextureUniform(e,n):this.uniform(r,e,n)}))}saveUniforms(e){let t=e||this.uniforms;for(let e in t){let t=this.uniforms[e];t&&(t.saved_value=t.value)}this.saved_texture_unit=this.texture_unit||0}restoreUniforms(e){let t=e||this.uniforms;for(let e in t){let t=this.uniforms[e];t&&t.saved_value&&(t.value=t.saved_value,this.updateUniform(t))}this.texture_unit=this.saved_texture_unit||0}setTextureUniform(e,t){var n=k.textures[t];null!=n?(n.bind(this.texture_unit),this.uniform("1i",e,this.texture_unit),this.texture_unit++):m("warn",`Cannot find texture '${t}'`)}uniform(e,t,n){if(!this.compiled)return;this.uniforms[t]=this.uniforms[t]||{};let r=this.uniforms[t];r.name=t,void 0===r.location&&(r.location=this.gl.getUniformLocation(this.program,t)),r.method=e,r.value=n,this.updateUniform(r)}updateUniform(e){this.compiled&&e&&null!=e.location&&(this.use(),this.commitUniform(e))}commitUniform(e){let t=e.location,n=e.value;switch(e.method){case"1i":this.gl.uniform1i(t,n);break;case"1f":this.gl.uniform1f(t,n);break;case"2f":this.gl.uniform2f(t,n[0],n[1]);break;case"3f":this.gl.uniform3f(t,n[0],n[1],n[2]);break;case"4f":this.gl.uniform4f(t,n[0],n[1],n[2],n[3]);break;case"1iv":this.gl.uniform1iv(t,n);break;case"3iv":this.gl.uniform3iv(t,n);break;case"1fv":this.gl.uniform1fv(t,n);break;case"2fv":this.gl.uniform2fv(t,n);break;case"3fv":this.gl.uniform3fv(t,n);break;case"4fv":this.gl.uniform4fv(t,n);break;case"Matrix3fv":this.gl.uniformMatrix3fv(t,!1,n);break;case"Matrix4fv":this.gl.uniformMatrix4fv(t,!1,n)}}refreshUniforms(){if(this.compiled)for(var e in this.uniforms){let t=this.uniforms[e];t.location=this.gl.getUniformLocation(this.program,e),this.updateUniform(t)}}refreshAttributes(){this.attribs={}}attribute(e){if(this.compiled){var t=this.attribs[e]=this.attribs[e]||{};return null!=t.location||(t.name=e,t.location=this.gl.getAttribLocation(this.program,e)),t}}source(e){return"vertex"===e?this.computed_vertex_source:"fragment"===e?this.computed_fragment_source:void 0}lines(e){let t=this.source(e);return t?t.split("\n"):[]}line(e,t){let n=this.lines(e);if(n)return n[t]}block(e,t){let n,r=this.lines(e);for(let e=0;e<t&&e<r.length;e++){let t=r[e],i=t.match(/\/\/ tangram-block-start: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/);i&&i.length>1?n={scope:i[1],name:i[2],num:i[3]}:(i=t.match(/\/\/ tangram-block-end: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/),i&&i.length>1&&(n=null)),n&&(n.line=null==n.line?-1:n.line+1,n.source=t)}return n}checkExtensions(){let e=[];return this.extensions.forEach(t=>{let n=C(this.gl,t),r=`TANGRAM_EXTENSION_${t}`;this.defines[r]=null!=n,n?e.push(t):m("debug",`Could not enable extension '${t}'`)}),e}}j.id=0,j.current=null,j.defines={},j.blocks={},j.reset=function(){j.programs_by_source={},j.shaders_by_source={}},j.reset(),j.buildDefineString=function(e){var t="";for(var n in e)null!=e[n]&&!1!==e[n]&&("boolean"==typeof e[n]&&!0===e[n]?t+="#define "+n+"\n":"number"==typeof e[n]&&Math.floor(e[n])===e[n]?t+="#define "+n+" "+e[n].toFixed(1)+"\n":t+="#define "+n+" "+e[n]+"\n");return t},j.buildExtensionString=function(e){let t="";return(e=e||[]).forEach(e=>{t+=`#ifdef GL_${e}\n#extension GL_${e} : enable\n#endif\n`}),t},j.addBlock=function(e,...t){j.blocks[e]=j.blocks[e]||[],j.blocks[e].push(...t)},j.removeBlock=function(e){j.blocks[e]=[]},j.replaceBlock=function(e,...t){j.removeBlock(e),j.addBlock(e,...t)},j.updateProgram=function(e,t,n,r){let i=P(e._tangram_id+"::"+n+"::"+r);if(j.programs_by_source[i])return m("trace","Reusing identical source GL program object"),j.programs_by_source[i];var s=j.createShader(e,n,e.VERTEX_SHADER),o=j.createShader(e,r,e.FRAGMENT_SHADER);if(e.useProgram(null),null!=t)for(var a=e.getAttachedShaders(t),l=0;l<a.length;l++)e.detachShader(t,a[l]);else t=e.createProgram();if(null==s||null==o)return t;if(e.attachShader(t,s),e.attachShader(t,o),e.bindAttribLocation(t,0,"a_position"),e.linkProgram(t),!e.getProgramParameter(t,e.LINK_STATUS)){let i=new Error(`WebGL program error:\n VALIDATE_STATUS: ${e.getProgramParameter(t,e.VALIDATE_STATUS)}\n ERROR: ${e.getError()}\n --- Vertex Shader ---\n ${n}\n --- Fragment Shader ---\n ${r}`);throw Object.assign(new Error(i),{type:"program"})}return j.programs_by_source[i]=t,t},j.createShader=function(e,t,n){let r=P(e._tangram_id+"::"+t);if(j.shaders_by_source[r])return m("trace","Reusing identical source GL shader object"),j.shaders_by_source[r];let i=e.createShader(n);if(e.shaderSource(i,t),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)){let t=n===e.VERTEX_SHADER?"vertex":"fragment",r=e.getShaderInfoLog(i),s=F(r);throw Object.assign(new Error(r),{type:t,errors:s})}return j.shaders_by_source[r]=i,i};var V,U={disabled:!1,bound_vao:[],init(e){let t;!0!==this.disabled&&(t=C(e,"OES_vertex_array_object")),null!=t?m("info","Vertex Array Object extension available"):!0!==this.disabled?m("warn","Vertex Array Object extension NOT available"):m("warn","Vertex Array Object extension force disabled")},getExtension(e,t){if(!0!==this.disabled)return C(e,t)},create(e,t,n){let r={};r.setup=t,r.teardown=n;let i=this.getExtension(e,"OES_vertex_array_object");return null!=i&&(r._vao=i.createVertexArrayOES(),i.bindVertexArrayOES(r._vao)),r.setup(),r},getCurrentBinding(e){let t=this.bound_vao.filter(t=>t[0]===e)[0];return t&&t[1]},setCurrentBinding(e,t){let n=this.bound_vao,r=n.filter(t=>t[0]===e)[0];null==r?n.push([e,t]):r[1]=t},bind(e,t){let n=this.getExtension(e,"OES_vertex_array_object");if(null!=t)null!=n&&null!=t._vao?(n.bindVertexArrayOES(t._vao),this.setCurrentBinding(e,t)):t.setup();else{let t=this.getCurrentBinding(e);null!=n?n.bindVertexArrayOES(null):null!=t&&"function"==typeof t.teardown&&t.teardown(),this.setCurrentBinding(e,null)}},destroy(e,t){let n=this.getExtension(e,"OES_vertex_array_object");null!=n&&null!=t&&null!=t._vao&&(n.deleteVertexArrayOES(t._vao),t._vao=null)}};function B(e,...t){for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let t in r){let n=r[t];null===n||"object"!=typeof n||Array.isArray(n)?void 0!==n&&(e[t]=n):null===e[t]||"object"!=typeof e[t]||Array.isArray(e[t])?e[t]=B({},n):e[t]=B(e[t],n)}}return e}var G=V={};V.default_source_max_zoom=18,V.default_view_max_zoom=20,V.max_style_zoom=25,V.tile_size=256,V.half_circumference_meters=20037508.342789244,V.circumference_meters=2*V.half_circumference_meters,V.min_zoom_meters_per_pixel=V.circumference_meters/V.tile_size;let $=[];V.metersPerPixel=function(e){return $[e]=$[e]||V.min_zoom_meters_per_pixel/Math.pow(2,e),$[e]};let q=[];V.metersPerTile=function(e){return q[e]=q[e]||V.circumference_meters/Math.pow(2,e),q[e]},V.tile_scale=4096,V.units_per_pixel=V.tile_scale/V.tile_size,V.height_scale=16;let H=[];V.unitsPerMeter=function(e){return H[e]=H[e]||V.tile_scale/(V.tile_size*V.metersPerPixel(e)),H[e]},V.metersForTile=function(e){return{x:e.x*V.circumference_meters/Math.pow(2,e.z)-V.half_circumference_meters,y:-(e.y*V.circumference_meters/Math.pow(2,e.z)-V.half_circumference_meters)}},V.tileForMeters=function([e,t],n){return{x:Math.floor((e+V.half_circumference_meters)/(V.circumference_meters/Math.pow(2,n))),y:Math.floor((-t+V.half_circumference_meters)/(V.circumference_meters/Math.pow(2,n))),z:n}},V.wrapTile=function({x:e,y:t,z:n},r={x:!0,y:!1}){var i=(1<<n)-1;return r.x&&(e&=i),r.y&&(t&=i),{x:e,y:t,z:n}},V.metersToLatLng=function(e){return e[0]/=V.half_circumference_meters,e[1]/=V.half_circumference_meters,e[1]=(2*Math.atan(Math.exp(e[1]*Math.PI))-Math.PI/2)/Math.PI,e[0]*=180,e[1]*=180,e},V.latLngToMeters=function(e){return e[1]=Math.log(Math.tan(e[1]*Math.PI/360+Math.PI/4))/Math.PI,e[1]*=V.half_circumference_meters,e[0]*=V.half_circumference_meters/180,e},V.tileSpaceToLatlng=function(e,t,n){const r=V.unitsPerMeter(t);return V.transformGeometry(e,e=>{e[0]=e[0]/r+n.x,e[1]=e[1]/r+n.y,V.metersToLatLng(e)}),e},V.copyGeometry=function(e){if(null==e)return;let t={type:e.type};return"Point"===e.type?t.coordinates=[e.coordinates[0],e.coordinates[1]]:"LineString"===e.type||"MultiPoint"===e.type?t.coordinates=e.coordinates.map(e=>[e[0],e[1]]):"Polygon"===e.type||"MultiLineString"===e.type?t.coordinates=e.coordinates.map(e=>e.map(e=>[e[0],e[1]])):"MultiPolygon"===e.type&&(t.coordinates=e.coordinates.map(e=>e.map(e=>e.map(e=>[e[0],e[1]])))),t},V.transformGeometry=function(e,t){null!=e&&("Point"===e.type?t(e.coordinates):"LineString"===e.type||"MultiPoint"===e.type?e.coordinates.forEach(t):"Polygon"===e.type||"MultiLineString"===e.type?e.coordinates.forEach(e=>e.forEach(t)):"MultiPolygon"===e.type&&e.coordinates.forEach(e=>{e.forEach(e=>e.forEach(t))}))},V.boxIntersect=function(e,t){return!(t.sw.x>e.ne.x||t.ne.x<e.sw.x||t.sw.y>e.ne.y||t.ne.y<e.sw.y)},V.findBoundingBox=function(e){for(var t=1/0,n=-1/0,r=1/0,i=-1/0,s=e[0].length,o=0;o<s;o++){var a=e[0][o];a[0]<t&&(t=a[0]),a[1]<r&&(r=a[1]),a[0]>n&&(n=a[0]),a[1]>i&&(i=a[1])}return[t,r,n,i]},V.geometryType=function(e){return"Polygon"===e||"MultiPolygon"===e?"polygon":"LineString"===e||"MultiLineString"===e?"line":"Point"===e||"MultiPoint"===e?"point":void 0},V.centroid=function(e,t=!0){if(!e||0===e.length)return;let n,r=0,i=0,s=0,o=e[0],a=o.length;t&&(n=o[0],o=o.map(e=>[e[0]-n[0],e[1]-n[1]]));for(let e=0,t=a-1;e<a;t=e,e++){let n=o[e],a=o[t],l=n[1]*a[0]-a[1]*n[0];r+=(n[0]+a[0])*l,i+=(n[1]+a[1])*l,s+=3*l}if(!s)return;let l=[r/s,i/s];return t&&(l[0]+=n[0],l[1]+=n[1]),l},V.multiCentroid=function(e){let t=0,n=null;for(let r=0;r<e.length;r++){let i=V.centroid(e[r]);i&&(n=n||[0,0],n[0]+=i[0],n[1]+=i[1],t++)}return t>0&&(n[0]/=t,n[1]/=t),n},V.signedPolygonRingAreaSum=function(e){let t=0,n=e.length;for(let r=0;r<n-1;r++){let n=e[r],i=e[r+1];t+=n[0]*i[1]-i[0]*n[1]}return t+=e[n-1][0]*e[0][1]-e[0][0]*e[n-1][1],t},V.polygonRingArea=function(e){return Math.abs(V.signedPolygonRingAreaSum(e))/2},V.polygonArea=function(e){if(e)return V.polygonRingArea(e[0])},V.multiPolygonArea=function(e){let t=0;for(let n=0;n<e.length;n++)t+=V.polygonArea(e[n]);return t},V.ringWinding=function(e){let t=V.signedPolygonRingAreaSum(e);return t>0?"CW":t<0?"CCW":void 0};const W={functions:{},num_functions:0,num_cached:0};function Z(e,t){if("string"==typeof e)e=K(e,t);else if(null!=e&&"object"==typeof e)for(let n in e)e[n]=Z(e[n],t);return e}function K(e,t){let n="string"==typeof e&&e.match(/^\s*function[^(]*\(([^)]*)\)\s*?\{([\s\S]*)\}$/m);if(n&&n.length>2)try{const e=n[2],r="function"==typeof t?t(e):e,i=P(r);if(void 0===W.functions[i]){let t=n[1].length>0&&n[1].split(",").map(e=>e.trim()).filter(e=>e);t=t.length>0?t:["context"],W.functions[i]=new Function(t.toString(),r),W.functions[i].source=e,W.num_functions++}else W.num_cached++;return W.functions[i]}catch(t){return e}return e}var X,Y={},Q=M(function(){if(X)return Y;X=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return(e=Math.round(e))<0?0:e>255?255:e}function n(e){return e<0?0:e>1?1:e}function r(e){return"%"===e[e.length-1]?t(parseFloat(e)/100*255):t(parseInt(e))}function i(e){return"%"===e[e.length-1]?n(parseFloat(e)/100):n(parseFloat(e))}function s(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}try{Y.parseCSSColor=function(n){var o,a=n.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(o=parseInt(a.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===a.length&&(o=parseInt(a.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=a.indexOf("("),u=a.indexOf(")");if(-1!==l&&u+1===a.length){var c=a.substr(0,l),h=a.substr(l+1,u-(l+1)).split(","),d=1;switch(c){case"rgba":if(4!==h.length)return null;d=i(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),d];case"hsla":if(4!==h.length)return null;d=i(h.pop());case"hsl":if(3!==h.length)return null;var f=(parseFloat(h[0])%360+360)%360/360,p=i(h[1]),g=i(h[2]),m=g<=.5?g*(p+1):g+p-g*p,_=2*g-m;return[t(255*s(_,m,f+1/3)),t(255*s(_,m,f)),t(255*s(_,m,f-1/3)),d];default:return null}}return null}}catch(e){}return Y}());const J={},ee=e=>Math.max(e,0),te=e=>isNaN(e)?0:e,ne=e=>Array.isArray(e)?e.map(parseFloat).map(te):te(parseFloat(e)),re=e=>Array.isArray(e)?e.map(ne).map(ee):ee(ne(e));Object.assign(J,{clampPositive:ee,noNaN:te,parseNumber:ne,parsePositiveNumber:re}),J.wrapFunction=function(e){return`\n var feature = context.feature.properties;\n var global = context.global;\n var $zoom = context.zoom;\n var $layer = context.layer;\n var $source = context.source;\n var $geometry = context.geometry;\n var $meters_per_pixel = context.meters_per_pixel;\n var $id = context.id;\n\n var val = (function(){ ${e} }());\n\n if (typeof val === 'number' && isNaN(val)) {\n val = null; // convert NaNs to nulls\n }\n\n return val;\n `},J.zeroPair=Object.freeze([0,0]),J.defaults={color:[1,1,1,1],width:1,size:1,extrude:!1,height:20,min_height:0,order:0,z:0,outline:{color:[0,0,0,0],width:0},material:{ambient:1,diffuse:1}},J.macros={"Style.color.pseudoRandomColor":function(){return[parseInt(feature.id,16)/100%1*.7,parseInt(feature.id,16)/1e4%1*.7,parseInt(feature.id,16)/1e6%1*.7,1]},"Style.color.randomColor":function(){return[.7*Math.random(),.7*Math.random(),.7*Math.random(),1]}},J.getFeatureParseContext=function(e,t,n){return{feature:e,id:e.id,tile:t,global:n,zoom:t.style_z,geometry:G.geometryType(e.geometry.type),meters_per_pixel:t.meters_per_pixel,meters_per_pixel_sq:t.meters_per_pixel_sq,units_per_meter_overzoom:t.units_per_meter_overzoom}};const ie={STATIC:0,DYNAMIC:1,ZOOM:2};J.CACHE_TYPE=ie,J.createPropertyCache=function(e,t=null,n=null){if(null==e)return;if(e.value)return{value:e.value,zoom:e.zoom?{}:null,type:e.type};let r={value:e,type:ie.STATIC};return Array.isArray(r.value)&&Array.isArray(r.value[0])?(r.zoom={},r.type=ie.ZOOM):"function"==typeof r.value&&(r.type=ie.DYNAMIC,r.dynamic_transform="function"==typeof n?n:null),"function"==typeof t&&(r.zoom?r.value=r.value.map((e,n)=>[e[0],t(e[1],n)]):"function"!=typeof r.value&&(r.value=t(r.value,0))),r},J.createColorPropertyCache=function(e){return J.createPropertyCache(e,e=>"Style.color.pseudoRandomColor"===e?K(J.wrapFunction(J.macros["Style.color.pseudoRandomColor"])):"Style.color.randomColor"===e?J.macros["Style.color.randomColor"]:e)};const se=e=>"string"==typeof e&&"%"===e[e.length-1],oe=e=>"auto"===e,ae=e=>se(e)||oe(e),le="'size' can specify either width or height as derived from aspect ratio, but not both";function ue(e,t){return J.createPropertyCache(e.value,(n,r)=>(Array.isArray(n)?(n=n.map((t,n)=>e.has_ratio[r][n]?t:re(t)).map((n,i)=>e.has_pct[r][i]?t.css_size[i]*n/100:n),e.has_ratio[r][0]?n[0]=n[1]*t.aspect:e.has_ratio[r][1]&&(n[1]=n[0]/t.aspect)):(n=re(n),n=e.has_pct[r]?t.css_size.map(e=>e*n/100):[n,n]),n))}function ce(e,t){try{return e(t)}catch(n){m("warn",`Property function in layer '${t.layers[t.layers.length-1]}' failed with\n`,`error ${n.stack}\n`,`function '${e.source}'\n`,t.feature,t)}}J.createPointSizePropertyCache=function(e,t){let n=null,r=null;if(se(e))n=[!0];else if(Array.isArray(e)){if(Array.isArray(e[0])){if(e.some(e=>Array.isArray(e[1])?e[1].some(e=>ae(e)):se(e[1]))&&(n=e.map(e=>Array.isArray(e[1])?e[1].map(e=>se(e)):se(e[1])),r=e.map(e=>Array.isArray(e[1])&&e[1].map(e=>oe(e))),r.some(e=>Array.isArray(e)&&e.every(e=>e))))throw le}else if(e.some(ae)&&(n=[e.map(se)],r=[e.map(oe)],r[0].every(e=>e)))throw le}else if(oe(e))throw"this value only allowed as half of an array, eg [16px, auto]:";if(n||r){if(!t)throw"% or 'auto' keywords can only be used to specify point size when a texture is defined";(e={value:e}).has_pct=n,e.has_ratio=r,e.sprites={}}else e=J.createPropertyCache(e,re);return e},J.evalCachedPointSizeProperty=function(e,t,n,r){if(null!=e)return e.has_pct||e.has_ratio?t?(e.sprites[t.sprite]||(e.sprites[t.sprite]=ue(e,t)),J.evalCachedProperty(e.sprites[t.sprite],r)):(e.texture=e.texture||ue(e,n),J.evalCachedProperty(e.texture,r)):J.evalCachedProperty(e,r)},J.evalCachedProperty=function(e,t){return null==e?void 0:e.dynamic?ce(e.dynamic,t):e.static?e.static:e.zoom&&e.zoom[t.zoom]?e.zoom[t.zoom]:"function"==typeof e.value?(e.dynamic_transform?e.dynamic=function(t){return e.dynamic_transform(e.value(t))}:e.dynamic=e.value,ce(e.dynamic,t)):Array.isArray(e.value)&&Array.isArray(e.value[0])?(e.zoom=e.zoom||{},e.zoom[t.zoom]=_.interpolate(t.zoom,e.value),e.zoom[t.zoom]):(e.static=e.value,e.static)},J.convertUnits=function(e,t){if(null!=e.value)return"px"===e.units?e.value*G.metersPerPixel(t.zoom):e.value;if("string"==typeof e)"px"===e.trim().slice(-2)?(e=ne(e),e*=G.metersPerPixel(t.zoom)):e=ne(e);else if(Array.isArray(e))return Array.isArray(e[0])?e.map(e=>[e[0],J.convertUnits(e[1],t)]):e.map(e=>J.convertUnits(e,t));return e},J.parseUnits=function(e){var t={value:ne(e)};return 0!==t.value&&"string"==typeof e&&"px"===e.trim().slice(-2)&&(t.units="px"),t},J.evalCachedDistanceProperty=function(e,t){return null==e?void 0:e.dynamic?ce(e.dynamic,t):e.zoom&&e.zoom[t.zoom]?e.zoom[t.zoom]:"function"==typeof e.value?(e.dynamic=e.value,ce(e.dynamic,t)):e.zoom?(e.zoom[t.zoom]=_.interpolate(t.zoom,e.value,e=>J.convertUnits(e,t)),e.zoom[t.zoom]):J.convertUnits(e.value,t)},J.string_colors={},J.colorForString=function(e){if(J.string_colors[e])return J.string_colors[e];let t=Q.parseCSSColor(e);return t&&4===t.length?(t[0]/=255,t[1]/=255,t[2]/=255):t=J.defaults.color,J.string_colors[e]=t,t},J.evalCachedColorProperty=function(e,t={}){if(null!=e){if(e.dynamic){let n=ce(e.dynamic,t);return"string"==typeof n&&(n=J.colorForString(n)),n&&null==n[3]&&(n[3]=1),n}if(e.static)return e.static;if(e.zoom&&e.zoom[t.zoom])return e.zoom[t.zoom];if("function"==typeof e.value){e.dynamic=e.value;let n=ce(e.dynamic,t);return"string"==typeof n&&(n=J.colorForString(n)),n&&null==n[3]&&(n[3]=1),n}if("string"==typeof e.value)return e.static=J.colorForString(e.value),e.static;if(e.zoom){if(!e.zoom_preprocessed){for(let t=0;t<e.value.length;t++){let n=e.value[t];n&&"string"==typeof n[1]&&(n[1]=J.colorForString(n[1]))}e.zoom_preprocessed=!0}return e.zoom[t.zoom]=_.interpolate(t.zoom,e.value),e.zoom[t.zoom][3]=e.zoom[t.zoom][3]||1,e.zoom[t.zoom]}return e.static=e.value.map(e=>e),e.static&&null==e.static[3]&&(e.static[3]=1),e.static}},J.evalCachedColorPropertyWithAlpha=function(e,t,n){const r=J.evalCachedColorProperty(e,n);if(null!=r&&null!=t){const e=J.evalCachedProperty(t,n);if(null!=e)return[r[0],r[1],r[2],e]}return r},J.parseColor=function(e,t={}){if("function"==typeof e&&(e=ce(e,t)),"string"==typeof e)e=J.colorForString(e);else if(Array.isArray(e)&&Array.isArray(e[0])){for(let t=0;t<e.length;t++){let n=e[t];"string"==typeof n[1]&&(n[1]=J.colorForString(n[1]))}t.zoom&&(e=_.interpolate(t.zoom,e))}return Array.isArray(e)?null==(e=e.map(e=>e))[3]&&(e[3]=1):e=[0,0,0,1],e},J.calculateOrder=function(e,t){return"function"==typeof e?e=ce(e,t):"string"==typeof e&&(e=t.feature.properties[e]?t.feature.properties[e]:re(e)),e},J.evalProperty=function(e,t){return"function"==typeof e?ce(e,t):e};class he{constructor(e,t,n){this.gl=e,this.workers=t,this._lock_fn="function"==typeof n&&n,this.init()}init(){this.requests={},this.feature=null,this.read_delay=0,this.read_delay_timer=null,this.pixels=null,this.fbo=this.gl.createFramebuffer(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.fbo),this.fbo_size={width:256,height:256};var e=k.create(this.gl,"__selection_fbo",{filtering:"nearest"});e.setData(this.fbo_size.width,this.fbo_size.height,null,{filtering:"nearest"}),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e.texture,0);var t=this.gl.createRenderbuffer();this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,t),this.gl.renderbufferStorage(this.gl.RENDERBUFFER,this.gl.DEPTH_COMPONENT16,this.fbo_size.width,this.fbo_size.height),this.gl.framebufferRenderbuffer(this.gl.FRAMEBUFFER,this.gl.DEPTH_ATTACHMENT,this.gl.RENDERBUFFER,t),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null)}destroy(){this.gl&&this.fbo&&(this.gl.deleteFramebuffer(this.fbo),this.fbo=null,this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null))}get locked(){return this._lock_fn&&this._lock_fn()||!1}bind(){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.fbo),this.gl.viewport(0,0,this.fbo_size.width,this.fbo_size.height),this.gl.clearColor(...he.defaultColor)}getFeatureAt(e,{radius:t}){return!e||e.x<0||e.y<0||e.x>1||e.y>1?Promise.resolve({feature:null,changed:!1}):new Promise((n,r)=>{this.selection_request_id=this.selection_request_id+1||0,this.requests[this.selection_request_id]={id:this.selection_request_id,point:e,radius:t,resolve:n,reject:r}})}pendingRequests(){return Object.keys(this.requests).length?this.requests:null}hasPendingRequests(){return null!=this.pendingRequests()}clearPendingRequests(){for(var e in this.requests){var t=this.requests[e];t.sent||(t.reject({request:t}),delete this.requests[e])}}read(){null!=this.read_delay_timer&&clearTimeout(this.read_delay_timer),this.read_delay_timer=setTimeout(()=>{if(!this.locked){var e=this.gl;for(var t in e.bindFramebuffer(e.FRAMEBUFFER,this.fbo),this.requests){var n=this.requests[t];if(n.sent)continue;let r,i,s=255,{point:o,radius:l}=n;if(l){let e=Math.min(this.fbo_size.width,this.fbo_size.height);i={x:Math.min(Math.ceil(2*l.x*this.fbo_size.width),e),y:Math.min(Math.ceil(2*l.y*this.fbo_size.height),e)}}else l={x:0,y:0},i={x:1,y:1};if((null==this.pixels||this.pixels.byteLength<i.x*i.y*4)&&(this.pixels=new Uint8Array(i.x*i.y*4)),this.pixels.fill instanceof Function)this.pixels.fill(0);else for(let e=0;e<this.pixels.length;e++)this.pixels[e]=0;e.readPixels(Math.round((o.x-l.x)*this.fbo_size.width),Math.round((1-o.y-l.y)*this.fbo_size.height),i.x,i.y,e.RGBA,e.UNSIGNED_BYTE,this.pixels);let u=4*(Math.round(i.y/2)*i.x+Math.round(i.x/2)),c=this.pixels[u]+(this.pixels[u+1]<<8)+(this.pixels[u+2]<<16);if(c>0)r=c+(this.pixels[u+3]<<24)>>>0,s=this.pixels[u+3];else{let e=-1>>>0;u=0;for(let t=0;t<i.y;t++)for(let n=0;n<i.x;n++,u+=4)if(c=this.pixels[u]+(this.pixels[u+1]<<8)+(this.pixels[u+2]<<16),c>0){let o=(n-i.x/2)*(n-i.x/2)+(t-i.y/2)*(t-i.y/2);o<=e&&(r=c+(this.pixels[u+3]<<24)>>>0,s=this.pixels[u+3],e=o)}}255!==s?null!=this.workers[s]&&a.postMessage(this.workers[s],"self.getFeatureSelection",{id:n.id,key:r}).then(e=>{this.finishRead(e)}):this.finishRead({id:n.id}),n.sent=!0}e.bindFramebuffer(e.FRAMEBUFFER,null)}},this.read_delay)}finishRead(e){var t=this.requests[e.id];if(t){var n=e.feature,r=!1;(null!=n&&null==this.feature||null==n&&null!=this.feature||null!=n&&null!=this.feature&&JSON.stringify(n)!==JSON.stringify(this.feature))&&(r=!0),this.feature=n,t.resolve({feature:n,changed:r,request:t}),delete this.requests[e.id]}else m("error","FeatureSelection.finishRead(): could not find message",e)}static makeEntry(e){this.map_entry++;var t=255&this.map_entry,n=this.map_entry>>8&255,r=this.map_entry>>16&255,i=this.map_prefix,s=t/255,o=n/255,a=r/255,l=i/255,u=t+(n<<8)+(r<<16)+(i<<24)>>>0;return this.map[u]={color:[s,o,a,l]},this.map_size++,this.tiles[e.key]||(this.tiles[e.key]={entries:[],tile:{key:e.key,coords:e.coords,style_z:e.style_z,source:e.source,generation:e.generation}}),this.tiles[e.key].entries.push(u),this.map[u]}static makeColor(e,t,n){var r=this.makeEntry(t);return r.feature={id:e.id,properties:e.properties,source_name:n.source,source_layer:n.layer,layers:n.layers,tile:this.tiles[t.key].tile},r.color}static reset(e){Array.isArray(e)?e.forEach(e=>this.clearSource(e)):(this.tiles={},this.map={},this.map_size=0,this.map_entry=0)}static clearSource(e){for(let t in this.tiles)this.tiles[t].tile.source===e&&this.clearTile(t)}static clearTile(e){this.tiles[e]&&(this.tiles[e].entries.forEach(e=>delete this.map[e]),this.map_size-=this.tiles[e].entries.length,delete this.tiles[e])}static getMapSize(){return this.map_size}static setPrefix(e){this.map_prefix=e}}var de;he.map={},he.tiles={},he.map_size=0,he.map_entry=0,he.map_prefix=0,he.defaultColor=[0,0,0,1];var fe=de={};de.BYTE=5120,de.UNSIGNED_BYTE=5121,de.SHORT=5122,de.UNSIGNED_SHORT=5123,de.INT=5124,de.UNSIGNED_INT=5125,de.FLOAT=5126;class pe{constructor(e,t,n,r,i){i=i||{},this.gl=e,this.vertex_data=t,this.element_data=n,this.vertex_layout=r,this.vertex_buffer=this.gl.createBuffer(),this.buffer_size=this.vertex_data.byteLength,this.draw_mode=i.draw_mode||this.gl.TRIANGLES,this.data_usage=i.data_usage||this.gl.STATIC_DRAW,this.vertices_per_geometry=3,this.uniforms=i.uniforms,this.textures=i.textures,this.retain=i.retain||!1,this.created_at=+new Date,this.fade_in_time=i.fade_in_time||0,this.vertex_count=this.vertex_data.byteLength/this.vertex_layout.stride,this.element_count=0,this.vaos={},this.toggle_element_array=!1,this.element_data?(this.toggle_element_array=!0,this.element_count=this.element_data.length,this.geometry_count=this.element_count/this.vertices_per_geometry,this.element_type=this.element_data.constructor===Uint16Array?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT,this.element_buffer=this.gl.createBuffer(),this.buffer_size+=this.element_data.byteLength,this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.element_buffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.element_data,this.data_usage)):this.geometry_count=this.vertex_count/this.vertices_per_geometry,this.upload(),this.retain||(delete this.vertex_data,delete this.element_data),this.valid=!0}render(e={}){if(!this.valid)return!1;var t=e.program||j.current;t.use(),this.uniforms&&(t.saveUniforms(this.uniforms),t.setUniforms(this.uniforms,!1));let n=(+new Date-this.created_at)/1e3;return t.uniform("1f","u_visible_time",n),this.bind(t),this.toggle_element_array?this.gl.drawElements(this.draw_mode,this.element_count,this.element_type,0):this.gl.drawArrays(this.draw_mode,0,this.vertex_count),U.bind(this.gl,null),this.uniforms&&t.restoreUniforms(this.uniforms),n<this.fade_in_time}bind(e){let t=this.vaos[e.id];t?U.bind(this.gl,t):this.vaos[e.id]=U.create(this.gl,()=>{this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertex_buffer),this.toggle_element_array&&this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.element_buffer),this.vertex_layout.enableDynamicAttributes(this.gl,e)}),this.vertex_layout.enableStaticAttributes(this.gl,e)}upload(){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertex_buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertex_data,this.data_usage)}destroy(){if(!this.valid)return!1;this.valid=!1;for(let e in this.vaos)U.destroy(this.gl,this.vaos[e]);return this.gl.deleteBuffer(this.vertex_buffer),this.vertex_buffer=null,this.element_buffer&&(this.gl.deleteBuffer(this.element_buffer),this.element_buffer=null),delete this.vertex_data,delete this.element_data,this.textures&&this.textures.forEach(e=>k.release(e)),!0}}const ge=["emission","ambient","diffuse","specular"];class me{constructor(e){e=e||{},ge.forEach(t=>{const n=e[t];null!=n&&(n.texture?this[t]={texture:n.texture,mapping:n.mapping||"spheremap",scale:O.expandVec3(null!=n.scale?n.scale:1),amount:O.expandVec4(null!=n.amount?n.amount:1)}:"number"==typeof n||Array.isArray(n)?this[t]={amount:O.expandVec4(n)}:this[t]="string"==typeof n?{amount:J.parseColor(n)}:n)}),this.specular&&(this.specular.shininess=e.shininess?parseFloat(e.shininess):.2),null!=e.normal&&(this.normal={texture:e.normal.texture,mapping:e.normal.mapping||"triplanar",scale:O.expandVec3(null!=e.normal.scale?e.normal.scale:1),amount:null!=e.normal.amount?e.normal.amount:1})}static isValid(e){return null!=e&&(null!=e.emission||null!=e.ambient||null!=e.diffuse||null!=e.specular)}inject(e){ge.forEach(t=>{let n=`TANGRAM_MATERIAL_${t.toUpperCase()}`,r=n+"_TEXTURE";e.defines[n]=null!=this[t],this[t]&&this[t].texture&&(e.defines[r]=!0,e.defines[r+"_"+this[t].mapping.toUpperCase()]=!0,e.defines[`TANGRAM_MATERIAL_TEXTURE_${this[t].mapping.toUpperCase()}`]=!0,e.texcoords=e.texcoords||"uv"===this[t].mapping)}),this.normal&&this.normal.texture&&(e.defines.TANGRAM_MATERIAL_NORMAL_TEXTURE=!0,e.defines["TANGRAM_MATERIAL_NORMAL_TEXTURE_"+this.normal.mapping.toUpperCase()]=!0,e.defines[`TANGRAM_MATERIAL_TEXTURE_${this.normal.mapping.toUpperCase()}`]=!0,e.texcoords=e.texcoords||"uv"===this.normal.mapping),e.replaceShaderBlock(me.block,"/*\n\nDefines globals:\nmaterial\nlight_accumulator_*\n\n*/\n\n\n// MATERIALS\n//\nstruct Material {\n #ifdef TANGRAM_MATERIAL_EMISSION\n vec4 emission;\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\n vec3 emissionScale;\n #endif\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT\n vec4 ambient;\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\n vec3 ambientScale;\n #endif\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n vec4 diffuse;\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\n vec3 diffuseScale;\n #endif\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n vec4 specular;\n float shininess;\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\n vec3 specularScale;\n #endif\n #endif\n\n\n #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\n vec3 normalScale;\n float normalAmount;\n #endif\n};\n\n// Note: uniform is copied to a global instance to allow modification\nuniform Material u_material;\nMaterial material;\n\n#ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\nuniform sampler2D u_material_emission_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\nuniform sampler2D u_material_ambient_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\nuniform sampler2D u_material_diffuse_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\nuniform sampler2D u_material_specular_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\nuniform sampler2D u_material_normal_texture;\n#endif\n\n// Global light accumulators for each property\nvec4 light_accumulator_ambient = vec4(vec3(0.0), 1.);\nvec4 light_accumulator_diffuse = vec4(vec3(0.0), 1.);\n#ifdef TANGRAM_MATERIAL_SPECULAR\n vec4 light_accumulator_specular = vec4(vec3(0.0), 1.);\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_SPHEREMAP\nvec4 getSphereMap (in sampler2D _tex, in vec3 _eyeToPoint, in vec3 _normal, in vec2 _skew) {\n // Normalized vector from camera to surface\n vec3 eye = normalize(_eyeToPoint);\n\n // Adjust for camera skew\n eye.xy -= _skew;\n eye = normalize(eye);\n\n // Reflection of eye off of surface normal\n vec3 r = reflect(eye, _normal);\n\n // Map reflected vector onto the surface of a sphere\n r.z += 1.0;\n float m = 2. * length(r);\n\n // Adjust xy to account for spherical shape, and center in middle of texture\n vec2 uv = r.xy / m + .5;\n\n // Sample the environment map\n return texture2D(_tex, uv);\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_TRIPLANAR\nvec3 getTriPlanarBlend (in vec3 _normal) {\n vec3 blending = abs(_normal);\n blending = normalize(max(blending, 0.00001));\n float b = (blending.x + blending.y + blending.z);\n return blending / b;\n}\n\nvec4 getTriPlanar (in sampler2D _tex, in vec3 _pos, in vec3 _normal, in vec3 _scale) {\n vec3 blending = getTriPlanarBlend(_normal);\n vec4 xaxis = texture2D(_tex, fract(_pos.yz * _scale.x));\n vec4 yaxis = texture2D(_tex, fract(_pos.xz * _scale.y));\n vec4 zaxis = texture2D(_tex, fract(_pos.xy * _scale.z));\n return xaxis * blending.x + yaxis * blending.y + zaxis * blending.z;\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_PLANAR\nvec4 getPlanar (in sampler2D _tex, in vec3 _pos, in vec2 _scale) {\n return texture2D( _tex, fract(_pos.xy * _scale.x) );\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\nvoid calculateNormal (inout vec3 _normal) {\n // Get NORMALMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_UV\n _normal += texture2D(u_material_normal_texture, fract(v_texcoord*material.normalScale.xy)).rgb*2.0-1.0;\n #endif\n\n #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_PLANAR\n vec3 normalTex = getPlanar(u_material_normal_texture, v_world_position.xyz, material.normalScale.xy).rgb*2.0-1.0;\n _normal += normalTex;\n #endif\n\n #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_TRIPLANAR\n vec3 normalTex = getTriPlanar(u_material_normal_texture, v_world_position.xyz, _normal, material.normalScale).rgb*2.0-1.0;\n _normal += normalTex;\n #endif\n\n _normal = normalize(_normal);\n}\n#endif\n\nvoid calculateMaterial (in vec3 _eyeToPoint, inout vec3 _normal) {\n // get EMISSION TEXTUREMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_UV\n material.emission *= texture2D(u_material_emission_texture,v_texcoord);\n #endif\n\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_PLANAR\n material.emission *= getPlanar(u_material_emission_texture, v_world_position.xyz, material.emissionScale.xy);\n #endif\n\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_TRIPLANAR\n material.emission *= getTriPlanar(u_material_emission_texture, v_world_position.xyz, _normal, material.emissionScale);\n #endif\n\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_SPHEREMAP\n material.emission *= getSphereMap(u_material_emission_texture, _eyeToPoint, _normal, u_vanishing_point);\n #endif\n #endif\n\n // get AMBIENT TEXTUREMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_UV\n material.ambient *= texture2D(u_material_ambient_texture,v_texcoord);\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_PLANAR\n material.ambient *= getPlanar(u_material_ambient_texture, v_world_position.xyz, material.ambientScale.xy);\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_TRIPLANAR\n material.ambient *= getTriPlanar(u_material_ambient_texture, v_world_position.xyz, _normal, material.ambientScale);\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_SPHEREMAP\n material.ambient *= getSphereMap(u_material_ambient_texture, _eyeToPoint, _normal, u_vanishing_point);\n #endif\n #endif\n\n // get DIFFUSE TEXTUREMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_UV\n material.diffuse *= texture2D(u_material_diffuse_texture,v_texcoord);\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_PLANAR\n material.diffuse *= getPlanar(u_material_diffuse_texture, v_world_position.xyz, material.diffuseScale.xy);\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_TRIPLANAR\n material.diffuse *= getTriPlanar(u_material_diffuse_texture, v_world_position.xyz, _normal, material.diffuseScale);\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_SPHEREMAP\n material.diffuse *= getSphereMap(u_material_diffuse_texture, _eyeToPoint, _normal, u_vanishing_point);\n #endif\n #endif\n\n // get SPECULAR TEXTUREMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_UV\n material.specular *= texture2D(u_material_specular_texture,v_texcoord);\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_PLANAR\n material.specular *= getPlanar(u_material_specular_texture, v_world_position.xyz, material.specularScale.xy);\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_TRIPLANAR\n material.specular *= getTriPlanar(u_material_specular_texture, v_world_position.xyz, _normal, material.specularScale);\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_SPHEREMAP\n material.specular *= getSphereMap(u_material_specular_texture, _eyeToPoint, _normal, u_vanishing_point);\n #endif\n #endif\n}\n","Material"),e.addShaderBlock("setup","\nmaterial = u_material;\n","Material")}setupProgram(e){ge.forEach(t=>{this[t]&&(this[t].texture?(e.setTextureUniform(`u_material_${t}_texture`,this[t].texture),e.uniform("3fv",`u_material.${t}Scale`,this[t].scale),e.uniform("4fv",`u_material.${t}`,this[t].amount)):this[t].amount&&e.uniform("4fv",`u_material.${t}`,this[t].amount))}),this.specular&&e.uniform("1f","u_material.shininess",this.specular.shininess),this.normal&&this.normal.texture&&(e.setTextureUniform("u_material_normal_texture",this.normal.texture),e.uniform("3fv","u_material.normalScale",this.normal.scale),e.uniform("1f","u_material.normalAmount",this.normal.amount))}}var _e;me.block="material";var ye=_e={};_e.copy=function(e){for(var t=[],n=e.length,r=0;r<n;r++)t[r]=e[r];return t},_e.neg=function(e){for(var t=[],n=e.length,r=0;r<n;r++)t[r]=-e[r];return t},_e.add=function(e,t){for(var n=[],r=Math.min(e.length,t.length),i=0;i<r;i++)n[i]=e[i]+t[i];return n},_e.sub=function(e,t){for(var n=[],r=Math.min(e.length,t.length),i=0;i<r;i++)n[i]=e[i]-t[i];return n},_e.signed_area=function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])},_e.mult=function(e,t){var n,r=[],i=e.length;if("number"==typeof t)for(n=0;n<i;n++)r[n]=e[n]*t;else for(i=Math.min(e.length,t.length),n=0;n<i;n++)r[n]=e[n]*t[n];return r},_e.div=function(e,t){var n,r=[];if("number"==typeof t)for(n=0;n<e.length;n++)r[n]=e[n]/t;else{var i=Math.min(e.length,t.length);for(n=0;n<i;n++)r[n]=e[n]/t[n]}return r},_e.perp=function(e,t){return[t[1]-e[1],e[0]-t[0]]},_e.rot=function(e,t){var n=Math.cos(t),r=Math.sin(t);return[e[0]*n-e[1]*r,e[0]*r+e[1]*n]},_e.angle=function([e,t]){return Math.atan2(t,e)},_e.angleBetween=function(e,t){var n=_e.dot(_e.normalize(_e.copy(e)),_e.normalize(_e.copy(t)));return n>1&&(n=1),Math.acos(n)},_e.isEqual=function(e,t){for(var n=e.length,r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0},_e.lengthSq=function(e){return 2===e.length?e[0]*e[0]+e[1]*e[1]:e.length>=3?e[0]*e[0]+e[1]*e[1]+e[2]*e[2]:0},_e.length=function(e){return Math.sqrt(_e.lengthSq(e))},_e.normalize=function(e){var t;if(2===e.length){if(1===(t=e[0]*e[0]+e[1]*e[1]))return e;0!==(t=Math.sqrt(t))?(e[0]/=t,e[1]/=t):(e[0]=0,e[1]=0)}else if(e.length>=3){if(1===(t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2]))return e;0!==(t=Math.sqrt(t))?(e[0]/=t,e[1]/=t,e[2]/=t):(e[0]=0,e[1]=0,e[2]=0)}return e},_e.cross=function(e,t){return 2===e.length?e[0]*t[1]-e[1]*t[0]:3===e.length?[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]:void 0},_e.dot=function(e,t){for(var n=0,r=Math.min(e.length,t.length),i=0;i<r;i++)n+=e[i]*t[i];return n};class ve{constructor(e,t){this.name=t.name,this.view=e,null==t.ambient||"number"==typeof t.ambient?this.ambient=O.expandVec3(t.ambient||0):this.ambient=J.parseColor(t.ambient).slice(0,3),null==t.diffuse||"number"==typeof t.diffuse?this.diffuse=O.expandVec3(null!=t.diffuse?t.diffuse:1):this.diffuse=J.parseColor(t.diffuse).slice(0,3),null==t.specular||"number"==typeof t.specular?this.specular=O.expandVec3(t.specular||0):this.specular=J.parseColor(t.specular).slice(0,3)}static create(e,t){if(ve.types[t.type])return new ve.types[t.type](e,t)}static setMode(e,t){!0===e&&(e="fragment"),e=ve.enabled&&(null!=e?e:"fragment"),t.defines.TANGRAM_LIGHTING_FRAGMENT="fragment"===e,t.defines.TANGRAM_LIGHTING_VERTEX="vertex"===e}static inject(e){if(j.removeBlock(ve.block),!ve.enabled)return;let t="";if(e&&Object.keys(e).length>0){let n={};for(let t in e)n[e[t].type]=!0;for(let e in n)ve.types[e].inject();for(let n in e)e[n].inject(),t+=`calculateLight(${n}, _eyeToPoint, _normal);\n`}let n=`\n vec4 calculateLighting(in vec3 _eyeToPoint, in vec3 _normal, in vec4 _color) {\n\n // Do initial material calculations over normal, emission, ambient, diffuse and specular values\n calculateMaterial(_eyeToPoint,_normal);\n\n // Un roll the loop of individual ligths to calculate\n ${t}\n\n // Final light intensity calculation\n vec4 color = vec4(vec3(0.), _color.a); // start with vertex color alpha\n\n #ifdef TANGRAM_MATERIAL_EMISSION\n color.rgb = material.emission.rgb;\n color.a *= material.emission.a;\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT\n color.rgb += light_accumulator_ambient.rgb * _color.rgb * material.ambient.rgb;\n color.a *= material.ambient.a;\n #else\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n color.rgb += light_accumulator_ambient.rgb * _color.rgb * material.diffuse.rgb;\n #endif\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n color.rgb += light_accumulator_diffuse.rgb * _color.rgb * material.diffuse.rgb;\n color.a *= material.diffuse.a;\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n color.rgb += light_accumulator_specular.rgb * material.specular.rgb;\n color.a *= material.specular.a;\n #endif\n\n // Clamp final color\n color = clamp(color, 0.0, 1.0);\n\n return color;\n }`;j.addBlock(ve.block,n)}inject(){let e=`\n uniform ${this.struct_name} u_${this.name};\n ${this.struct_name} ${this.name};\n `,t=`\n ${this.name} = u_${this.name};\n\n `;j.addBlock(ve.block,e),j.addBlock("setup",t)}update(){}setupProgram(e){e.uniform("3fv",`u_${this.name}.ambient`,this.ambient),e.uniform("3fv",`u_${this.name}.diffuse`,this.diffuse),e.uniform("3fv",`u_${this.name}.specular`,this.specular)}}ve.types={},ve.block="lighting",ve.enabled=!0,ve.types.ambient=class extends ve{constructor(e,t){super(e,t),this.type="ambient",this.struct_name="AmbientLight"}static inject(){j.addBlock(ve.block,"/*\n\nExpected globals:\nlight_accumulator_*\n\n*/\n\nstruct AmbientLight {\n vec3 ambient;\n};\n\nvoid calculateLight(in AmbientLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n light_accumulator_ambient.rgb += _light.ambient;\n}\n")}setupProgram(e){e.uniform("3fv",`u_${this.name}.ambient`,this.ambient)}},ve.types.directional=class extends ve{constructor(e,t){if(super(e,t),this.type="directional",this.struct_name="DirectionalLight",t.direction)this._direction=t.direction;else{let e=135,n=Math.sin(60*Math.PI/180);this._direction=[Math.cos(Math.PI*e/180)*n,Math.sin(Math.PI*e/180)*n,-.5],null==t.ambient&&(this.ambient=O.expandVec3(.5))}this.direction=this._direction.map(parseFloat)}get direction(){return this._direction}set direction(e){this._direction=ye.normalize(ye.copy(e))}static inject(){j.addBlock(ve.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct DirectionalLight {\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n vec3 direction;\n};\n\nvoid calculateLight(in DirectionalLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n light_accumulator_ambient.rgb += _light.ambient;\n\n float nDotVP = clamp(dot(_normal, -_light.direction), 0.0, 1.0);\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n light_accumulator_diffuse.rgb += _light.diffuse * nDotVP;\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n float pf = 0.0;\n if (nDotVP > 0.0) {\n vec3 reflectVector = reflect(_light.direction, _normal);\n float eyeDotR = max(dot(normalize(_eyeToPoint), reflectVector), 0.0);\n pf = pow(eyeDotR, material.shininess);\n }\n light_accumulator_specular.rgb += _light.specular * pf;\n #endif\n}\n")}setupProgram(e){super.setupProgram(e),e.uniform("3fv",`u_${this.name}.direction`,this.direction)}};class be extends ve{constructor(e,t){super(e,t),this.type="point",this.struct_name="PointLight",this.position=t.position||[0,0,"100px"],this.position_eye=[],this.origin=t.origin||"ground",this.attenuation=isNaN(parseFloat(t.attenuation))?0:parseFloat(t.attenuation),t.radius?Array.isArray(t.radius)&&2===t.radius.length?this.radius=t.radius:this.radius=[null,t.radius]:this.radius=null}static inject(){j.addBlock(ve.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct PointLight {\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n vec4 position;\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n float attenuationExponent;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n float innerRadius;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float outerRadius;\n#endif\n};\n\nvoid calculateLight(in PointLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n float dist = length(_light.position.xyz - _eyeToPoint);\n\n // Compute vector from surface to light position\n vec3 VP = (_light.position.xyz - _eyeToPoint) / dist;\n\n // Normalize the vector from surface to light position\n float nDotVP = clamp(dot(VP, _normal), 0.0, 1.0);\n\n // Attenuation defaults\n float attenuation = 1.0;\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n float Rin = 1.0;\n float e = _light.attenuationExponent;\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n Rin = _light.innerRadius;\n #endif\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float Rdiff = _light.outerRadius-Rin;\n float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n attenuation = 1.0-(pow(d,e));\n #else\n // If no outer is provide behaves like:\n // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n float d = max(0.0,dist-Rin)/Rin+1.0;\n attenuation = clamp(1.0/(pow(d,e)), 0.0, 1.0);\n #endif\n #else\n float Rin = 0.0;\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n Rin = _light.innerRadius;\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float Rdiff = _light.outerRadius-Rin;\n float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n attenuation = 1.0-d*d;\n #else\n // If no outer is provide behaves like:\n // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n float d = max(0.0,dist-Rin)/Rin+1.0;\n attenuation = clamp(1.0/d, 0.0, 1.0);\n #endif\n #else\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float d = clamp(dist/_light.outerRadius, 0.0, 1.0);\n attenuation = 1.0-d*d;\n #else\n attenuation = 1.0;\n #endif\n #endif\n #endif\n\n // Computer accumulators\n light_accumulator_ambient.rgb += _light.ambient * attenuation;\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n light_accumulator_diffuse.rgb += _light.diffuse * nDotVP * attenuation;\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n float pf = 0.0; // power factor for shiny speculars\n if (nDotVP > 0.0) {\n vec3 reflectVector = reflect(-VP, _normal);\n float eyeDotR = max(0.0, dot(-normalize(_eyeToPoint), reflectVector));\n pf = pow(eyeDotR, material.shininess);\n }\n\n light_accumulator_specular.rgb += _light.specular * pf * attenuation;\n #endif\n}\n")}inject(){super.inject(),j.defines.TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT=0!==this.attenuation,j.defines.TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS=null!=this.radius&&null!=this.radius[0],j.defines.TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS=null!=this.radius}update(){this.updateEyePosition()}updateEyePosition(){if("world"===this.origin){const e=G.latLngToMeters([...this.position]);this.position_eye[0]=e[0]-this.view.camera.position_meters[0],this.position_eye[1]=e[1]-this.view.camera.position_meters[1],this.position_eye[2]=J.convertUnits(this.position[2],{zoom:this.view.zoom,meters_per_pixel:G.metersPerPixel(this.view.zoom)}),this.position_eye[2]=this.position_eye[2]-this.view.camera.position_meters[2]}else"ground"!==this.origin&&"camera"!==this.origin||(this.position_eye=J.convertUnits(this.position,{zoom:this.view.zoom,meters_per_pixel:G.metersPerPixel(this.view.zoom)}),"ground"===this.origin&&(this.position_eye[2]=this.position_eye[2]-this.view.camera.position_meters[2]));this.position_eye[3]=1}setupProgram(e){super.setupProgram(e),e.uniform("4fv",`u_${this.name}.position`,this.position_eye),j.defines.TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT&&e.uniform("1f",`u_${this.name}.attenuationExponent`,this.attenuation),j.defines.TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS&&e.uniform("1f",`u_${this.name}.innerRadius`,J.convertUnits(this.radius[0],{zoom:this.view.zoom,meters_per_pixel:G.metersPerPixel(this.view.zoom)})),j.defines.TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS&&e.uniform("1f",`u_${this.name}.outerRadius`,J.convertUnits(this.radius[1],{zoom:this.view.zoom,meters_per_pixel:G.metersPerPixel(this.view.zoom)}))}}ve.types.point=be,ve.types.spotlight=class extends be{constructor(e,t){super(e,t),this.type="spotlight",this.struct_name="SpotLight",this.direction=this._direction=(t.direction||[0,0,-1]).map(parseFloat),this.exponent=t.exponent?parseFloat(t.exponent):.2,this.angle=t.angle?parseFloat(t.angle):20}get direction(){return this._direction}set direction(e){this._direction=ye.normalize(ye.copy(e))}static inject(){j.addBlock(ve.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct SpotLight {\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n vec4 position;\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n float attenuationExponent;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n float innerRadius;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float outerRadius;\n#endif\n\n vec3 direction;\n float spotCosCutoff;\n float spotExponent;\n};\n\nvoid calculateLight(in SpotLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n float dist = length(_light.position.xyz - _eyeToPoint);\n\n // Compute vector from surface to light position\n vec3 VP = (_light.position.xyz - _eyeToPoint) / dist;\n\n // normal . light direction\n float nDotVP = clamp(dot(_normal, VP), 0.0, 1.0);\n\n // Attenuation defaults\n float attenuation = 1.0;\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n float Rin = 1.0;\n float e = _light.attenuationExponent;\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n Rin = _light.innerRadius;\n #endif\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float Rdiff = _light.outerRadius-Rin;\n float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n attenuation = 1.0-(pow(d,e));\n #else\n // If no outer is provide behaves like:\n // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n float d = max(0.0,dist-Rin)/Rin+1.0;\n attenuation = clamp(1.0/(pow(d,e)), 0.0, 1.0);\n #endif\n #else\n float Rin = 0.0;\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n Rin = _light.innerRadius;\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float Rdiff = _light.outerRadius-Rin;\n float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n attenuation = 1.0-d*d;\n #else\n // If no outer is provide behaves like:\n // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n float d = max(0.0,dist-Rin)/Rin+1.0;\n attenuation = clamp(1.0/d, 0.0, 1.0);\n #endif\n #else\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float d = clamp(dist/_light.outerRadius, 0.0, 1.0);\n attenuation = 1.0-d*d;\n #else\n attenuation = 1.0;\n #endif\n #endif\n #endif\n\n // spotlight attenuation factor\n float spotAttenuation = 0.0;\n\n // See if point on surface is inside cone of illumination\n float spotDot = clamp(dot(-VP, _light.direction), 0.0, 1.0);\n\n if (spotDot >= _light.spotCosCutoff) {\n spotAttenuation = pow(spotDot, _light.spotExponent);\n }\n\n light_accumulator_ambient.rgb += _light.ambient * attenuation * spotAttenuation;\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n light_accumulator_diffuse.rgb += _light.diffuse * nDotVP * attenuation * spotAttenuation;\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n // Power factor for shiny speculars\n float pf = 0.0;\n if (nDotVP > 0.0) {\n vec3 reflectVector = reflect(-VP, _normal);\n float eyeDotR = max(dot(-normalize(_eyeToPoint), reflectVector), 0.0);\n pf = pow(eyeDotR, material.shininess);\n }\n light_accumulator_specular.rgb += _light.specular * pf * attenuation * spotAttenuation;\n #endif\n}\n")}setupProgram(e){super.setupProgram(e),e.uniform("3fv",`u_${this.name}.direction`,this.direction),e.uniform("1f",`u_${this.name}.spotCosCutoff`,Math.cos(3.14159*this.angle/180)),e.uniform("1f",`u_${this.name}.spotExponent`,this.exponent)}};class xe extends Error{constructor(e){super(),this.name="MethodNotImplemented",this.message="Method "+e+" must be implemented in subclass"}}class we{constructor(e,t){this.validate(e),this.config=e,this.sources=t,this.id=e.id,this.name=e.name,this.pad_scale=e.pad_scale||1e-5,this.default_winding=null,this.rasters=[],Array.isArray(e.rasters)&&e.rasters.forEach(e=>{-1===this.rasters.indexOf(e)&&this.rasters.push(e)}),this.preprocess=e.preprocess,"function"==typeof this.preprocess&&this.preprocess.bind(this),this.transform=e.transform,"function"==typeof this.transform&&this.transform.bind(this),this.extra_data=e.extra_data,this.scripts=e.scripts,this.setZooms(e),this.zoom_offset=null!=e.zoom_offset?e.zoom_offset:0,this.zoom_offset<0&&(m({level:"warn",once:!0},`Data source '${this.name}' zoom_offset must not be negative – setting to 0.`),this.zoom_offset=0),this.setTileSize(e.tile_size),this.min_display_zoom=Math.max(e.min_display_zoom||0,this.zooms[0]),this.max_display_zoom=null!=e.max_display_zoom?e.max_display_zoom:null}static register(e,t){e&&t&&(we.types[e]=t)}static create(e,t){if("function"==typeof we.types[e.type]){const n=we.types[e.type](e);if(n)return new n(e,t)}}static tileLayoutChanged(e,t){if(!e||!t)return!0;const n=["max_zoom","zooms","min_display_zoom","max_display_zoom","bounds","tile_size","zoom_offset"],r=T(e.config,n),i=T(t.config,n);return JSON.stringify(r)!==JSON.stringify(i)}static projectData(e){var t=+new Date;for(var n in e.layers)for(var r=e.layers[n].features.length,i=0;i<r;i++){var s=e.layers[n].features[i];G.transformGeometry(s.geometry,this.projectCoord)}void 0!==e.debug&&(e.debug.projection=+new Date-t)}static projectCoord(e){G.latLngToMeters(e)}static scaleData(e,{coords:{z:t},min:n}){let r=G.unitsPerMeter(t);for(var i in e.layers)for(var s=e.layers[i].features.length,o=0;o<s;o++){var a=e.layers[i].features[o];G.transformGeometry(a.geometry,e=>{e[0]=(e[0]-n.x)*r,e[1]=(e[1]-n.y)*r*-1})}}load(e){return e.source_data={},e.source_data.layers={},e.pad_scale=this.pad_scale,e.rasters=[...this.rasters],this._load(e).then(e=>{for(let t in e.source_data.layers){let n=e.source_data.layers[t];n&&n.features&&n.features.forEach(e=>{G.transformGeometry(e.geometry,e=>{e[1]=-e[1],this.pad_scale&&(e[0]=Math.round(e[0]*(1+this.pad_scale)-G.tile_scale*this.pad_scale/2),e[1]=Math.round(e[1]*(1+this.pad_scale)-G.tile_scale*this.pad_scale/2))}),this.updateDefaultWinding(e.geometry)})}return e.default_winding=this.default_winding||"CCW",e})}_load(){throw new xe("_load")}copyTileData(e,t){return m("trace",`Copy tile data from ${e.key} to ${t.key}`),t.source_data={layers:e.source_data.layers},t.rasters=[...e.rasters],t.pad_scale=e.pad_scale,t.default_winding=e.default_winding,t}setZooms({max_zoom:e,zooms:t}){if(this.max_zoom=null!=e?e:G.default_source_max_zoom,Array.isArray(t))this.zooms=t,this.max_zoom=this.zooms[this.zooms.length-1];else{this.zooms=[];for(let e=0;e<=this.max_zoom;e++)this.zooms[e]=e}}setTileSize(e){this.tile_size=e||256,("number"!=typeof this.tile_size||this.tile_size<256||!_.isPowerOf2(this.tile_size))&&(m({level:"warn",once:!0},`Data source '${this.name}': 'tile_size' parameter must be a number that is a power of 2 greater than or equal to 256, but was '${e}'`),this.tile_size=256),this.zoom_bias=Math.log2(this.tile_size)-8+this.zoom_offset}updateDefaultWinding(e){return null==this.default_winding&&("Polygon"===e.type?this.default_winding=G.ringWinding(e.coordinates[0]):"MultiPolygon"===e.type&&(this.default_winding=G.ringWinding(e.coordinates[0][0]))),this.default_winding}includesTile(e,t){if(e.z<this.min_display_zoom||null!=this.max_display_zoom&&t>this.max_display_zoom)return!1;for(let t=0;t<this.rasters.length;t++){const n=this.rasters[t];if(this.sources[n]&&this.sources[n]!==this&&!this.sources[n].includesTile(e,e.z))return!1}return!0}validate(){}}we.types={};let Ae=0;class Ee extends we{constructor(e,t){super(e,t),this.response_type="";let[n,r]=function(e,t){if(!t||0===Object.keys(t).length)return[e,[]];var n=e.indexOf("?"),r=e.indexOf("#"),i="";r>-1&&(i=e.slice(r),e=e.slice(0,r)),-1===n&&(n=e.length,e+="?"),n++;var s="",o=[];for(var a in t)""===A(a,e)?s+=`${a}=${t[a]}&`:o.push([a,t[a]]);return[e=e.slice(0,n)+s+e.slice(n)+i,o]}(e.url,e.url_params);this.url=n,r.forEach(([t,n])=>{m({level:"warn",once:!0},`Data source '${this.name}': parameter '${t}' already present in URL '${e.url}', skipping value '${t}=${n}' specified in 'url_params'`)}),e.request_headers&&"object"==typeof e.request_headers&&(this.request_headers=e.request_headers)}_load(e){let t=this.formatURL(this.url,e),n=e.source_data;return n.url=t,e.debug=e.debug||{},e.debug.network=+new Date,new Promise(r=>{let i=Ae+++"-"+t,s=_.io(t,6e4,this.response_type,"GET",this.request_headers,i);n.request_id=i,n.error=null,s.then(({body:t})=>{e.debug.response_size=t&&(t.length||t.byteLength),e.debug.network=+new Date-e.debug.network,e.debug.parsing=+new Date,null!=t&&"function"==typeof this.preprocess&&(t=this.preprocess(t)),(t=t instanceof Promise?t:Promise.resolve(t)).then(t=>{null!=t?this.parseSourceData(e,n,t):n.layers={},e.debug.parsing=+new Date-e.debug.parsing,r(e)})}).catch(t=>{n.error=t.stack,r(e)})})}validate(e){if("string"!=typeof e.url)throw Error("Network data source must provide a string `url` property")}formatURL(){throw new xe("formatURL")}parseSourceData(){throw new xe("parseSourceData")}}class Se extends Ee{constructor(e,t){super(e,t),this.tiled=!0,this.bounds=this.parseBounds(e),this.builds_geometry_tiles=!1,this.tms=!0===e.tms,this.url&&this.url.search("{s}")>-1&&(Array.isArray(e.url_subdomains)&&e.url_subdomains.length>0?(this.url_subdomains=e.url_subdomains,this.next_url_subdomain=0):m({level:"warn",once:!0},`Data source '${this.name}': source URL includes '{s}' subdomain marker ('${this.url}'), but no subdomains were specified in 'url_subdomains' parameter`)),this.url&&this.url.search("{r}")>-1&&(Array.isArray(e.url_density_scales)&&e.url_density_scales.length>0?this.url_density_scales=e.url_density_scales:this.url_density_scales=[1,2])}parseBounds(e){if(Array.isArray(e.bounds)&&4===e.bounds.length){const[t,n,r,i]=e.bounds;return{latlng:[...e.bounds],meters:{min:G.latLngToMeters([t,i]),max:G.latLngToMeters([r,n])},tiles:{min:{},max:{}}}}}checkBounds(e,t){if(t){e=G.wrapTile(e);let n=t.tiles.min[e.z];n||(n=t.tiles.min[e.z]=G.tileForMeters(t.meters.min,e.z));let r=t.tiles.max[e.z];if(r||(r=t.tiles.max[e.z]=G.tileForMeters(t.meters.max,e.z)),e.y<n.y||e.y>r.y)return!1;if(n.x<=r.x){if(e.x<n.x||e.x>r.x)return!1}else if(e.x>r.x&&e.x<n.x)return!1}return!0}includesTile(e,t){return!!super.includesTile(e,t)&&!!this.checkBounds(e,this.bounds)}formatURL(e,t){let n=G.wrapTile(t.coords,{x:!0});this.tms&&(n.y=Math.pow(2,n.z)-1-n.y);let r=e.replace("{x}",n.x).replace("{y}",n.y).replace("{z}",n.z).replace("{r}",this.getDensityModifier()).replace("{q}",this.toQuadKey(n));return null!=this.url_subdomains&&(r=r.replace("{s}",this.url_subdomains[this.next_url_subdomain]),this.next_url_subdomain=(this.next_url_subdomain+1)%this.url_subdomains.length),r}getDensityModifier(){if(this.url_density_scales){const e=_.device_pixel_ratio;let t=this.url_density_scales.filter(t=>e>=t).reverse()[0];if(t=null!=t?t:this.url_density_scales[0],t>1)return`@${t}x`}return""}toQuadKey({x:e,y:t,z:n}){let r="";for(let i=n;i>0;i--){let n=0,s=1<<i-1;e&s&&n++,t&s&&(n+=2),r+=n.toString()}return r}static urlHasTilePattern(e){return e&&(e.search("{x}")>-1&&e.search("{y}")>-1&&e.search("{z}")>-1||e.search("{q}")>-1)}}const Te={coord(e){return{x:e.x,y:e.y,z:e.z,key:this.coordKey(e)}},coordKey:({x:e,y:t,z:n})=>e+"/"+t+"/"+n,key(e,t,n){if(!(e.y<0||e.y>=1<<e.z||e.z<0))return[t.name,e.x,e.y,e.z,n].join("/")},normalizedKey(e,t,n){return this.key(this.normalizedCoord(e,t),t,n)},normalizedCoord(e,t){return t.zoom_bias&&(e=this.coordAtZoom(e,Math.max(e.z-t.zoom_bias,t.zooms[0]))),this.coordForTileZooms(e,t.zooms)},coordAtZoom({x:e,y:t,z:n},r){if(n!==(r=Math.max(0,r))){let i=Math.pow(2,n-r);e=Math.floor(e/i),t=Math.floor(t/i),n=r}return this.coord({x:e,y:t,z:n})},coordForTileZooms({x:e,y:t,z:n},r){const i=this.findZoomInRange(n,r);return i!==n?this.coordAtZoom({x:e,y:t,z:n},i):this.coord({x:e,y:t,z:n})},findZoomInRange:(e,t)=>t.filter(t=>e>=t).reverse()[0]||t[0],isDescendant(e,t){if(t.z>e.z){let{x:n,y:r}=this.coordAtZoom(t,e.z);return e.x===n&&e.y===r}return!1},parent({coords:e,source:t,style_z:n}){if(n>0){n--;const r=Math.max(n-t.zoom_bias,t.zooms[0]),i=this.coordForTileZooms(this.coordAtZoom(e,r),t.zooms);return i.z>n?null:{key:this.key(i,t,n),coords:i,style_z:n,source:t}}},children({coords:e,source:t,style_z:n},r={}){n++;const i=this.coordForTileZooms(this.coordAtZoom(e,n-t.zoom_bias),t.zooms);if(i.z===e.z)return[{key:this.key(i,t,n),coords:i,style_z:n,source:t}];{const s=this.key(i,t,n);if(r[t.id]=r[t.id]||{},null==r[t.id][s]){const o=Math.pow(2,i.z-e.z),a=e.x*o,l=e.y*o;let u=[];for(let e=a;e<a+o;e++)for(let r=l;r<l+o;r++){let s=this.coord({x:e,y:r,z:i.z});u.push({key:this.key(s,t,n),coords:s,style_z:n,source:t})}r[t.id][s]=u}return r[t.id][s]}}};class ke extends Se{constructor(e,t){super(e,t),-1===this.rasters.indexOf(this.name)&&this.rasters.unshift(this.name),this.filtering=e.filtering,this.textures={}}async load(e){e.source_data={},e.source_data.layers={},e.pad_scale=this.pad_scale,e.rasters=[...this.rasters];let t=G.tile_scale;return e.source_data.layers={_default:{type:"FeatureCollection",features:[{geometry:{type:"Polygon",coordinates:[[[0,0],[t,0],[t,-t],[0,-t],[0,0]]]},properties:{}}]}},e.default_winding="CW",e}async tileTexture(e){let t=this.adjustRasterTileZoom(e),n=t.key;if(!this.textures[n]){let e=this.formatURL(this.url,{coords:t});this.textures[n]={name:e,url:e,filtering:this.filtering,coords:t}}return this.textures[n]}adjustRasterTileZoom(e){let t=e.coords;const n=this.sources[e.source];if(n!==this){let r=this.zoom_bias-n.zoom_bias;r>0?t=Te.normalizedCoord(e.coords,{zoom_bias:r,zooms:this.zooms}):(r<0&&m({level:"warn",once:!0},`Raster source '${this.name}' supports higher zoom detail than source '${n.name}' it's attached to. Downsampling this source ${-r} extra zoom levels to match.`),t=Te.coordForTileZooms(t,this.zooms))}return t}}class Oe extends ke{constructor(e,t){super(e,t),this.load_image={},this.alpha=null!=e.alpha?Math.max(Math.min(e.alpha,1),0):null,this.mask_alpha=!0,this.preserve_tiles_within_zoom=0,this.max_display_density=e.max_display_density,Array.isArray(e.composite)?this.images=e.composite.map(e=>({url:e.url,bounds:this.parseBounds(e),alpha:null!=e.alpha?Math.max(Math.min(e.alpha,1),0):null})):this.images=[{url:this.url,bounds:this.bounds,alpha:this.alpha}]}async tileTexture(e,{blend:t,generation:n}){let r=this.adjustRasterTileZoom(e);const i="opaque"!==t,s=`raster-${this.name}-${r.key}-${i?"alpha":"opaque"}-${n}`;if(k.textures[s])return{name:s,coords:r,skip_create:!0};let o=_.device_pixel_ratio;this.max_display_density&&(o=Math.min(o,this.max_display_density)),o*=2;const a=document.createElement("canvas"),l=a.getContext("2d");a.width=this.tile_size*o,a.height=this.tile_size*o,l.imageSmoothingEnabled="nearest"!==this.filtering;const u=this.images.filter(t=>this.checkBounds(e.coords,t.bounds));return await Promise.all(u.map(t=>{const n=i?null!=t.alpha?t.alpha:this.alpha:1;return this.drawImage(t.url,t.bounds,n,e,o,l)})),{name:s,element:a,filtering:this.filtering,coords:r}}async drawImage(e,t,n,r,i,s){const o=P(e);this.load_image[o]=this.load_image[o]||this.loadImage(e);const a=await this.load_image[o],l=G.metersPerPixel(r.coords.z)/i/(this.tile_size/G.tile_size),u=(t.meters.min[0]-r.min.x)/l,c=-(t.meters.min[1]-r.min.y)/l,h=(t.meters.max[0]-t.meters.min[0])/l,d=-(t.meters.max[1]-t.meters.min[1])/l;s.globalAlpha=null!=n?n:1,s.drawImage(a,u,c,h,d)}loadImage(e){return new Promise(t=>{let n=new Image;n.onload=()=>t(n),n.onerror=n=>{m("warn",`Raster source '${this.name}': failed to load url: '${e}'`,n),t(null)},_.isSafari()&&"data:"===e.slice(0,5)||(n.crossOrigin="anonymous"),n.src=e})}includesTile(e,t){return!!we.prototype.includesTile.call(this,e,t)&&this.images.some(t=>this.checkBounds(e,t.bounds))}validate(e){let t="Raster data source must provide a string `url` parameter, or an array of `composite` raster ";t+="image objects that each have a `url` parameter";let n="Raster data source must provide a `bounds` parameter, or an array of `composite` raster ";if(n+="image objects that each have a `bounds` parameter",Array.isArray(e.composite)){if(e.composite.some(e=>"string"!=typeof e.url))throw Error(t);if(e.composite.some(e=>!(Array.isArray(e.bounds)&&4===e.bounds.length)))throw Error(n);if(null!=e.url||null!=e.bounds)throw Error("Raster data source must have *either* a single image specified as `url` and `bounds `parameters, or an array of `composite` raster image objects, each with `url` and `bounds`.")}else{if("string"!=typeof e.url)throw Error(t);if(!Array.isArray(e.bounds)||4!==e.bounds.length)throw Error(n)}}}function Re(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Re(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Re(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}we.register("Raster",e=>ke.urlHasTilePattern(e.url)?ke:Oe);var Pe={init({generation:e,styles:t,sources:n={},introspection:r}={}){this.setGeneration(e),this.styles=t,this.sources=n,this.defines=Object.prototype.hasOwnProperty.call(this,"defines")&&this.defines||{},this.shaders=Object.prototype.hasOwnProperty.call(this,"shaders")&&this.shaders||{},this.introspection=r||!1,this.selection=this.selection||this.introspection||!1,this.compile_setup=!1,this.program=null,this.selection_program=null,this.feature_style={},this.vertex_template=[],this.tile_data={},this.stencil_proxy_tiles=!0,this.variants={},this.vertex_layouts={},this.defines.TANGRAM_WORLD_POSITION_WRAP=1e5,this.blend=this.blend||"opaque","opaque"!==this.blend?null==this.blend_order&&(this.blend_order=this.default_blend_orders[this.blend]):this.blend_order=this.default_blend_orders[this.blend],this.defines[`TANGRAM_BLEND_${this.blend.toUpperCase()}`]=!0,this.removeShaderBlock("setup"),this.material instanceof me||(me.isValid(this.material)||(this.material=J.defaults.material),this.material=new me(this.material)),this.material.inject(this),ve.setMode(this.lighting,this),this.setupRasters(),this.setupCustomAttributes(),this.initialized=!0},destroy(){this.program&&(this.program.destroy(),this.program=null),this.selection_program&&(this.selection_program.destroy(),this.selection_program=null),a.removeTarget(this.main_thread_target),this.gl=null,this.initialized=!1},reset(){},baseStyle(){return this.base||this.name},setGeneration(e){this.generation=e,this.main_thread_target=["Style",this.name,this.generation].join("_"),t.is_main&&a.addTarget(this.main_thread_target,this)},startData(e){this.tile_data[e.id]=this.tile_data[e.id]||{meshes:{},uniforms:{},textures:[]}},async endData(e){var t=this.tile_data[e.id];if(this.tile_data[e.id]=null,t&&Object.keys(t.meshes).length>0){for(let e in t.meshes){let n=t.meshes[e];0!==n.vertex_data.vertex_count?(n.vertex_data.end(),n.vertex_elements=n.vertex_data.element_buffer,n.vertex_data=n.vertex_data.vertex_buffer):delete t.meshes[e]}return this.buildRasterTextures(e,t)}return null},hasDataForTile(e){return null!=this.tile_data[e.id]},getTileMesh(e,t){const n=this.tile_data[e.id].meshes;if(null==n[t.key]){const e=this.vertexLayoutForMeshVariant(t);n[t.key]={variant:t,vertex_data:e.createVertexData()}}return n[t.key]},vertexLayoutForMeshVariant(){},meshVariantTypeForDraw(){},addFeature(e,t,n){let r=n.tile;if(r.generation!==this.generation)return;this.tile_data[r.id]||this.startData(r);let i=this.parseFeature(e,t,n);i&&this.buildGeometry(e.geometry,i,n)>0&&(e.generation=this.generation)},buildGeometry(e,t,n){let r;if("Polygon"===e.type?r=this.buildPolygons([e.coordinates],t,n):"MultiPolygon"===e.type?r=this.buildPolygons(e.coordinates,t,n):"LineString"===e.type?r=this.buildLines([e.coordinates],t,n):"MultiLineString"===e.type?r=this.buildLines(e.coordinates,t,n):"Point"===e.type?r=this.buildPoints([e.coordinates],t,n):"MultiPoint"===e.type&&(r=this.buildPoints(e.coordinates,t,n)),r>0&&v.layer_stats){let e=n.tile;e.debug.layers=e.debug.layers||{list:{},tree:{}};let t=e.debug.layers.list,i=e.debug.layers.tree,s={};n.layers.forEach(e=>{Me(t,e,1,r,{[this.name]:r},{[this.baseStyle()]:r});let n=i,o=s,a=e.split(":");for(let e=0;e<a.length;e++){let t=a[e];n[t]=n[t]||{features:0,geoms:0,styles:{},base:{}},null==o[t]&&(o[t]={},Me(n,t,1,r,{[this.name]:r},{[this.baseStyle()]:r})),e<a.length-1&&(n[t].layers=n[t].layers||{}),n=n[t].layers,o=o[t]}})}return r},parseFeature(e,t,n){try{var r=this.feature_style;if(r.order=this.parseOrder(t.order,n),null==r.order&&"overlay"!==this.blend){let e=`Layer '${t.layers.join(", ")}', draw group '${t.group}': `;return e+="'order' parameter is required unless blend mode is 'overlay'",null!=t.order&&(e+="; 'order' was set to a dynamic value (e.g. string tied to feature property, ",e+="or JS function), but evaluated to null for one or more features"),void m({level:"warn",once:!0},e)}if(!(r=this._parseFeature(e,t,n)))return;if(this.shaders.attributes){r.attributes=r.attributes||{};for(const e in this.shaders.attributes)r.attributes[e]=J.evalCachedProperty(t.attributes&&t.attributes[e],n),"number"!=typeof r.attributes[e]&&(r.attributes[e]=0)}return this.selection?r.interactive=J.evalProperty(t.interactive,n):r.interactive=!1,!0===r.interactive?r.selection_color=he.makeColor(e,n.tile,n):r.selection_color=he.defaultColor,r}catch(t){m("error","Style.parseFeature: style parsing error",e,r,t.stack)}},_parseFeature(){return this.feature_style},preprocess(e){if(!e.preprocessed){if(this.draw)for(let t in this.draw){let n=this.draw[t];"object"!=typeof n||Array.isArray(n)?null==e[t]&&(e[t]=n):e[t]=B({},n,e[t])}if(this.selection?this.introspection&&(e.interactive=!0):e.interactive=!1,!(e=this._preprocess(e)))return;if(this.shaders.attributes){e.attributes=e.attributes||{};for(const t in this.shaders.attributes)e.attributes[t]=J.createPropertyCache(null!=e.attributes[t]?e.attributes[t]:0)}e.preprocessed=!0}return e},_preprocess:e=>e,parseOrder:(e,t)=>"number"!=typeof e?J.calculateOrder(e,t):e,scaleOrder:e=>2*e,parseColor(e,t){return e?J.evalCachedColorProperty(e,t):this.shaders.blocks.color||this.shaders.blocks.filter?J.defaults.color:void 0},buildPolygons:()=>0,buildLines:()=>0,buildPoints:()=>0,setGL(e){this.gl=e,this.max_texture_size=k.getMaxTextureSize(this.gl)},makeMesh(e,t,n={}){let r=this.vertexLayoutForMeshVariant(n.variant);return v.wireframe?(t=function(e){const t=new Uint16Array(2*e.length);for(let n=0;n<e.length;n+=3)t.set([e[n],e[n+1],e[n+1],e[n+2],e[n+2],e[n]],2*n);return t}(t),new pe(this.gl,e,t,r,Ce(Ce({},n),{},{draw_mode:this.gl.LINES}))):new pe(this.gl,e,t,r,n)},render:e=>e.render(),getProgram(e="program"){this.compileSetup();const t=this[e];if(t&&!t.error){if(!t.compiled){m("debug",`Compiling style '${this.name}', program key '${e}'`);try{t.compile()}catch(t){throw m("error",`Style: error compiling program for style '${this.name}' (program key '${e}')`,this,t.stack,t.type,t.shader_errors),t}}return t}},compileSetup(){if(!this.compile_setup){if(!this.gl)throw new Error(`style.compile(): skipping for ${this.name} because no GL context`);var e=this.buildDefineList();if(this.selection){var t=Object.assign({},e);t.TANGRAM_FEATURE_SELECTION=!0}var n=this.shaders&&this.shaders.blocks,r=this.shaders&&this.shaders.block_scopes,i=Object.assign({},this.shaders&&this.shaders.uniforms);for(let e in i)null==i[e]&&m({level:"warn",once:!0},`Style '${this.name}' has invalid uniform '${e}': uniform values must be non-null`);var s=this.shaders&&this.shaders.extensions;"string"==typeof s&&(s=[s]),this.program=new j(this.gl,this.vertex_shader_src,this.fragment_shader_src,{name:this.name,defines:e,uniforms:i,blocks:n,block_scopes:r,extensions:s}),this.selection?this.selection_program=new j(this.gl,this.vertex_shader_src,"// Fragment shader for feature selection passes\n// Renders in silhouette according to selection (picking) color, or black if none defined\n\n#ifdef TANGRAM_FEATURE_SELECTION\n varying vec4 v_selection_color;\n#endif\n\nvoid main (void) {\n #ifdef TANGRAM_FEATURE_SELECTION\n gl_FragColor = v_selection_color;\n #else\n gl_FragColor = vec4(0., 0., 0., 1.);\n #endif\n}\n",{name:this.name+" (selection)",defines:t,uniforms:i,blocks:n,block_scopes:r,extensions:s}):this.selection_program=null,this.compile_setup=!0}},addShaderBlock(e,t,n=null){this.shaders.blocks=this.shaders.blocks||{},this.shaders.blocks[e]=this.shaders.blocks[e]||[],this.shaders.blocks[e].push(t),this.shaders.block_scopes=this.shaders.block_scopes||{},this.shaders.block_scopes[e]=this.shaders.block_scopes[e]||[],this.shaders.block_scopes[e].push(n)},removeShaderBlock(e){this.shaders.blocks&&(this.shaders.blocks[e]=null),this.shaders.block_scopes&&(this.shaders.block_scopes[e]=null)},replaceShaderBlock(e,t,n=null){this.removeShaderBlock(e),this.addShaderBlock(e,t,n)},buildDefineList(){var e={};if(null!=this.defines)for(var t in this.defines)e[t]=this.defines[t];if(null!=this.shaders&&null!=this.shaders.defines)for(t in this.shaders.defines)e[t]=this.shaders.defines[t];return e},hasRasters(){return["color","normal","custom"].indexOf(this.raster)>-1},setupRasters(){if(!this.hasRasters())return;"color"===this.raster?this.defines.TANGRAM_RASTER_TEXTURE_COLOR=!0:"normal"===this.raster&&(this.defines.TANGRAM_RASTER_TEXTURE_NORMAL=!0);let e=Object.keys(this.sources).filter(e=>this.sources[e]instanceof ke).length;if(this.defines.TANGRAM_NUM_RASTER_SOURCES=`${e}`,e>0){const t=Object.keys(this.sources).filter(e=>this.sources[e].mask_alpha).length;this.defines.TANGRAM_HAS_MASKED_RASTERS=t>0,this.defines.TANGRAM_ALL_MASKED_RASTERS=t===e,this.defines.TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING=!0,this.replaceShaderBlock("raster","// Uniforms defining raster textures and macros for accessing them\n\n#ifdef TANGRAM_FRAGMENT_SHADER\nuniform sampler2D u_rasters[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture samplers\nuniform vec2 u_raster_sizes[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture sizes (width/height in pixels)\nuniform vec3 u_raster_offsets[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture UV starting offset for tile\n\n// Raster sources can optionally mask by the alpha channel (render with only full or no alpha, based on a threshold),\n// which is used for handling transparency outside the raster image when rendering with opaque blending\n#if defined(TANGRAM_HAS_MASKED_RASTERS) && !defined(TANGRAM_ALL_MASKED_RASTERS) // only add uniform if we need it\nuniform bool u_raster_mask_alpha;\n#endif\n\n// Note: the raster accessors below are #defines rather than functions to\n// avoid issues with constant integer expressions for array indices\n\n// Adjusts UVs in model space to account for raster tile texture overzooming\n// (applies scale and offset adjustments)\n#define adjustRasterUV(raster_index, uv) \\\n ((uv) * u_raster_offsets[raster_index].z + u_raster_offsets[raster_index].xy)\n\n// Returns the UVs of the current model position for a raster sampler\n#define currentRasterUV(raster_index) \\\n (adjustRasterUV(raster_index, v_modelpos_base_zoom.xy))\n\n// Returns pixel location in raster tile texture at current model position\n#define currentRasterPixel(raster_index) \\\n (currentRasterUV(raster_index) * rasterPixelSize(raster_index))\n\n// Samples a raster tile texture for the current model position\n#define sampleRaster(raster_index) \\\n (texture2D(u_rasters[raster_index], currentRasterUV(raster_index)))\n\n// Samples a raster tile texture for a given pixel\n#define sampleRasterAtPixel(raster_index, pixel) \\\n (texture2D(u_rasters[raster_index], (pixel) / rasterPixelSize(raster_index)))\n\n// Returns size of raster sampler in pixels\n#define rasterPixelSize(raster_index) \\\n (u_raster_sizes[raster_index])\n\n#endif\n","Raster")}},async buildRasterTextures(e,t){if(!this.hasRasters())return t;if(0===e.rasters.length)return t;let n;try{n=await a.postMessage(`${this.main_thread_target}.loadTextures`,{coords:e.coords,source:e.source,rasters:e.rasters,min:e.min,max:e.max})}catch(e){return t}if(!n||n.length<1)return t;if(n.some(e=>!e.loaded))return null;t.uniforms.u_raster_mask_alpha=!0===this.sources[e.rasters[0]].mask_alpha;const r=t.uniforms.u_rasters=[],i=t.uniforms.u_raster_sizes=[],s=t.uniforms.u_raster_offsets=[];return n.forEach(n=>{const o=n.index;if(r[o]=n.name,t.textures.push(n.name),i[o]=[n.width,n.height],e.coords.z>n.coords.z){let t=e.coords.z-n.coords.z,r=Math.pow(2,t);s[o]=[(e.coords.x%r+r)%r/r,(r-1-e.coords.y%r)/r,1/r]}else s[o]=[0,0,1]}),t},async loadTextures(e){let t={},n={},r=[];e.rasters.map(e=>this.sources[e]).filter(e=>e).forEach((i,s)=>{i instanceof ke&&r.push(i.tileTexture(e,this).then(e=>{t[e.name]=e,n[e.name]=s}))}),await Promise.all(r),await k.createFromObject(this.gl,t);let i=await Promise.all(Object.keys(t).map(e=>k.textures[e]&&k.textures[e].load()).filter(e=>e));return i.forEach(e=>e.retain()),i.map(e=>({name:e.name,width:e.width,height:e.height,loaded:e.loaded,index:n[e.name],coords:t[e.name].coords}))},setupCustomAttributes(){if(this.shaders.attributes)for(const[e,t]of Object.entries(this.shaders.attributes))"float"===t.type&&(!1!==t.varying?(this.addShaderBlock("attributes",`\n #ifdef TANGRAM_VERTEX_SHADER\n attribute float a_${e};\n varying float v_${e};\n #define ${e} a_${e}\n #else\n varying float v_${e};\n #define ${e} v_${e}\n #endif\n `),this.addShaderBlock("setup",`#ifdef TANGRAM_VERTEX_SHADER\nv_${e} = a_${e};\n#endif`)):this.addShaderBlock("attributes",`\n #ifdef TANGRAM_VERTEX_SHADER\n attribute float a_${e};\n #define ${e} a_${e}\n #endif\n `))},addCustomAttributesToAttributeList(e){if(this.shaders.attributes)for(const[t,n]of Object.entries(this.shaders.attributes))"float"===n.type&&e.push({name:`a_${t}`,size:1,type:fe.FLOAT,normalized:!1});return e},addCustomAttributesToVertexTemplate(e,t){if(this.shaders.attributes)for(let n in this.shaders.attributes)this.vertex_template[t++]=null!=e.attributes[n]?e.attributes[n]:0},setup(){this.setUniforms(),this.material.setupProgram(j.current)},setUniforms(){var e,t=j.current;t&&t.setUniforms(null===(e=this.shaders)||void 0===e?void 0:e.uniforms,!0)},render_states:{opaque:{depth_test:!0,depth_write:!0},translucent:{depth_test:!0,depth_write:!0},add:{depth_test:!0,depth_write:!1},multiply:{depth_test:!0,depth_write:!1},inlay:{depth_test:!0,depth_write:!1},overlay:{depth_test:!1,depth_write:!1}},default_blend_orders:{opaque:Number.MIN_SAFE_INTEGER,add:1,multiply:2,inlay:3,translucent:4,overlay:5},getBlendOrderForDraw(e){return"opaque"!==this.blend&&null!=e.blend_order?e.blend_order:this.blend_order}};function Me(e,t,n,r,i,s){e[t]=e[t]||{features:0,geoms:0,styles:{},base:{}},e[t].features+=n,e[t].geoms+=r;for(let n in i)e[t].styles[n]=e[t].styles[n]||0,e[t].styles[n]+=i[n];for(let n in s)e[t].base[n]=e[t].base[n]||0,e[t].base[n]+=s[n]}let Ne=Math.pow(2,16)-1,Ie=!1;class De{constructor(){this.array=[],this.has_overflown=!1}push(e){this.has_overflown&&!Ie||e>Ne&&(this.has_overflown=!0,!Ie)||this.array.push(e)}end(){if(this.array.length){let t=(e=this.array,new(this.has_overflown&&Ie?Uint32Array:Uint16Array)(e));return this.array=[],this.has_overflown=!1,t}return!1;var e}}De.setElementIndexUint=function(e){Ie=e};let Fe={[fe.FLOAT]:Float32Array,[fe.BYTE]:Int8Array,[fe.UNSIGNED_BYTE]:Uint8Array,[fe.INT]:Int32Array,[fe.UNSIGNED_INT]:Uint32Array,[fe.SHORT]:Int16Array,[fe.UNSIGNED_SHORT]:Uint16Array};class ze{constructor(e,{prealloc:t=500}={}){this.vertex_layout=e,this.vertex_elements=new De,this.stride=this.vertex_layout.stride,ze.array_pool.length>0?(this.vertex_buffer=ze.array_pool.pop(),this.byte_length=this.vertex_buffer.byteLength,this.size=Math.floor(this.byte_length/this.stride),m("trace",`VertexData: reused buffer of bytes ${this.byte_length}, ${this.size} vertices`)):(this.size=t,this.byte_length=this.stride*this.size,this.vertex_buffer=new Uint8Array(this.byte_length)),this.offset=0,this.vertex_count=0,this.realloc_count=0,this.setBufferViews(),this.setAddVertexFunction()}setBufferViews(){this.views={},this.views[fe.UNSIGNED_BYTE]=this.vertex_buffer,this.vertex_layout.dynamic_attribs.forEach(e=>{if(null==this.views[e.type]){var t=Fe[e.type];this.views[e.type]=new t(this.vertex_buffer.buffer)}})}checkBufferSize(){if(this.offset+this.stride>this.byte_length){this.size=Math.floor(1.5*this.size),this.size-=this.size%4,this.byte_length=this.stride*this.size;var e=new Uint8Array(this.byte_length);e.set(this.vertex_buffer),ze.array_pool.push(this.vertex_buffer),this.vertex_buffer=e,this.setBufferViews(),this.realloc_count++}}setAddVertexFunction(){this.vertexLayoutAddVertex=this.vertex_layout.getAddVertexFunction()}addVertex(e){this.checkBufferSize(),this.vertexLayoutAddVertex(e,this.views,this.offset),this.offset+=this.stride,this.vertex_count++}end(){return this.vertex_buffer=this.vertex_buffer.subarray(0,this.offset),this.element_buffer=this.vertex_elements.end(),m("trace",`VertexData: ${this.size} vertices total, realloc count ${this.realloc_count}`),this}}ze.array_pool=[];class Le{constructor(e){this.attribs=e,this.dynamic_attribs=this.attribs.filter(e=>null==e.static),this.static_attribs=this.attribs.filter(e=>null!=e.static),this.components=[],this.index={},this.offset={},this.stride=0;let t=0,n=0;for(let e=0;e<this.attribs.length;e++){let r=this.attribs[e];if(null==r.static){r.offset=this.stride,r.byte_size=r.size;let e=0;switch(r.type){case fe.FLOAT:case fe.INT:case fe.UNSIGNED_INT:r.byte_size*=4,e=2;break;case fe.SHORT:case fe.UNSIGNED_SHORT:r.byte_size*=2,e=1}3&r.byte_size&&(r.byte_size+=4-(3&r.byte_size)),this.stride+=r.byte_size;let i=r.offset>>e;for(let t=0;t<r.size;t++)this.components.push({type:r.type,shift:e,offset:i++,index:n++});this.index[r.name]=t,t+=r.size,this.offset[r.name]=r.offset}else r.static=Array.isArray(r.static)?r.static:[r.static],r.method=`vertexAttrib${r.static.length}fv`}}enableDynamicAttributes(e,t){for(const t in Le.enabled_attribs)e.disableVertexAttribArray(t);Le.enabled_attribs={},this.dynamic_attribs.forEach(n=>{const r=t.attribute(n.name).location;-1!==r&&(e.enableVertexAttribArray(r),e.vertexAttribPointer(r,n.size,n.type,n.normalized,this.stride,n.offset),Le.enabled_attribs[r]=t)})}enableStaticAttributes(e,t){this.static_attribs.forEach(n=>{const r=t.attribute(n.name).location;-1!==r&&e[n.method]instanceof Function&&(e.enableVertexAttribArray(r),e[n.method](r,n.static),e.disableVertexAttribArray(r))})}createVertexData(){return new ze(this)}getAddVertexFunction(){return null==this.addVertex&&this.createAddVertexFunction(),this.addVertex}createAddVertexFunction(){let e=P(JSON.stringify(this.attribs));if(null==Le.add_vertex_funcs[e]){let t,n=["var t, o;"],r=[...this.components];r.sort((e,t)=>e.type!==t.type?e.type-t.type:e.index-t.index);for(let e=0;e<r.length;e++){let i=r[e];t!==i.type&&(n.push(`t = vs[${i.type}];`),n.push(`o = off${i.shift?" >> "+i.shift:""};`),t=i.type),n.push(`t[o + ${i.offset}] = v[${i.index}];`)}n=n.join("\n");let i=new Function("v","vs","off",n);Le.add_vertex_funcs[e]=i}this.addVertex=Le.add_vertex_funcs[e]}}Le.enabled_attribs={},Le.add_vertex_funcs={};const je=[{x:0,y:0},{x:G.tile_scale,y:-G.tile_scale}],Ve=[0,0,1,1];function Ue(e,t,n){let r=je[0],i=je[1];return e[0]<=r.x+n&&t[0]<=r.x+n||e[0]>=i.x-n&&t[0]>=i.x-n||e[1]>=r.y-n&&t[1]>=r.y-n||e[1]<=i.y+n&&t[1]<=i.y+n}function Be(e,t){t=t||0;let n=je[0],r=je[1];return e[0]<=n.x+t||e[0]>=r.x-t||e[1]>=n.y-t||e[1]<=r.y+t}var Ge,$e={exports:{}},qe=function(){if(Ge)return $e.exports;function e(e,i,s){s=s||2;var o,a,c,h,f,p,g,m=i&&i.length,_=m?i[0]*s:e.length,y=t(e,0,_,s,!0),v=[];if(!y||y.next===y.prev)return v;if(m&&(y=function(e,r,i,s){var o,a,c,h=[];for(o=0,a=r.length;o<a;o++)(c=t(e,r[o]*s,o<a-1?r[o+1]*s:e.length,s,!1))===c.next&&(c.steiner=!0),h.push(d(c));for(h.sort(l),o=0;o<h.length;o++)u(h[o],i),i=n(i,i.next);return i}(e,i,y,s)),e.length>80*s){o=c=e[0],a=h=e[1];for(var b=s;b<_;b+=s)(f=e[b])<o&&(o=f),(p=e[b+1])<a&&(a=p),f>c&&(c=f),p>h&&(h=p);g=0!==(g=Math.max(c-o,h-a))?1/g:0}return r(y,v,s,o,a,g),v}function t(e,t,n,r,i){var s,o;if(i===S(e,t,n,r)>0)for(s=t;s<n;s+=r)o=w(s,e[s],e[s+1],o);else for(s=n-r;s>=t;s-=r)o=w(s,e[s],e[s+1],o);return o&&m(o,o.next)&&(A(o),o=o.next),o}function n(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!m(r,r.next)&&0!==g(r.prev,r,r.next))r=r.next;else{if(A(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function r(e,t,l,u,c,d,f){if(e){!f&&d&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=h(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,s,o,a,l,u=1;do{for(n=e,e=null,s=null,o=0;n;){for(o++,r=n,a=0,t=0;t<u&&(a++,r=r.nextZ);t++);for(l=u;a>0||l>0&&r;)0!==a&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;n=r}s.nextZ=null,u*=2}while(o>1)}(i)}(e,u,c,d);for(var p,g,m=e;e.prev!==e.next;)if(p=e.prev,g=e.next,d?s(e,u,c,d):i(e))t.push(p.i/l),t.push(e.i/l),t.push(g.i/l),A(e),e=g.next,m=g.next;else if((e=g)===m){f?1===f?r(e=o(n(e),t,l),t,l,u,c,d,2):2===f&&a(e,t,l,u,c,d):r(n(e),t,l,u,c,d,1);break}}}function i(e){var t=e.prev,n=e,r=e.next;if(g(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(f(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&g(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function s(e,t,n,r){var i=e.prev,s=e,o=e.next;if(g(i,s,o)>=0)return!1;for(var a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,u=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,c=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,d=h(a,l,t,n,r),p=h(u,c,t,n,r),m=e.prevZ,_=e.nextZ;m&&m.z>=d&&_&&_.z<=p;){if(m!==e.prev&&m!==e.next&&f(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&g(m.prev,m,m.next)>=0)return!1;if(m=m.prevZ,_!==e.prev&&_!==e.next&&f(i.x,i.y,s.x,s.y,o.x,o.y,_.x,_.y)&&g(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;m&&m.z>=d;){if(m!==e.prev&&m!==e.next&&f(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&g(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;_&&_.z<=p;){if(_!==e.prev&&_!==e.next&&f(i.x,i.y,s.x,s.y,o.x,o.y,_.x,_.y)&&g(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function o(e,t,r){var i=e;do{var s=i.prev,o=i.next.next;!m(s,o)&&_(s,i,i.next,o)&&b(s,o)&&b(o,s)&&(t.push(s.i/r),t.push(i.i/r),t.push(o.i/r),A(i),A(i.next),i=e=o),i=i.next}while(i!==e);return n(i)}function a(e,t,i,s,o,a){var l=e;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&p(l,u)){var c=x(l,u);return l=n(l,l.next),c=n(c,c.next),r(l,t,i,s,o,a),void r(c,t,i,s,o,a)}u=u.next}l=l.next}while(l!==e)}function l(e,t){return e.x-t.x}function u(e,t){if(t=function(e,t){var n,r=t,i=e.x,s=e.y,o=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>o){if(o=a,a===i){if(s===r.y)return r;if(s===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===o)return n;var l,u=n,h=n.x,d=n.y,p=1/0;r=n;do{i>=r.x&&r.x>=h&&i!==r.x&&f(s<d?i:o,s,h,d,s<d?o:i,s,r.x,r.y)&&(l=Math.abs(s-r.y)/(i-r.x),b(r,e)&&(l<p||l===p&&(r.x>n.x||r.x===n.x&&c(n,r)))&&(n=r,p=l)),r=r.next}while(r!==u);return n}(e,t),t){var r=x(t,e);n(t,t.next),n(r,r.next)}}function c(e,t){return g(e.prev,e,t.prev)<0&&g(t.next,e,e.next)<0}function h(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function d(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function f(e,t,n,r,i,s,o,a){return(i-o)*(t-a)-(e-o)*(s-a)>=0&&(e-o)*(r-a)-(n-o)*(t-a)>=0&&(n-o)*(s-a)-(i-o)*(r-a)>=0}function p(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&_(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(b(e,t)&&b(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&i<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(g(e.prev,e,t.prev)||g(e,t.prev,t))||m(e,t)&&g(e.prev,e,e.next)>0&&g(t.prev,t,t.next)>0)}function g(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function m(e,t){return e.x===t.x&&e.y===t.y}function _(e,t,n,r){var i=v(g(e,t,n)),s=v(g(e,t,r)),o=v(g(n,r,e)),a=v(g(n,r,t));return i!==s&&o!==a||!(0!==i||!y(e,n,t))||!(0!==s||!y(e,r,t))||!(0!==o||!y(n,e,r))||!(0!==a||!y(n,t,r))}function y(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function v(e){return e>0?1:e<0?-1:0}function b(e,t){return g(e.prev,e,e.next)<0?g(e,t,e.next)>=0&&g(e,e.prev,t)>=0:g(e,t,e.prev)<0||g(e,e.next,t)<0}function x(e,t){var n=new E(e.i,e.x,e.y),r=new E(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function w(e,t,n,r){var i=new E(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function A(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function E(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S(e,t,n,r){for(var i=0,s=t,o=n-r;s<n;s+=r)i+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return i}return Ge=1,$e.exports=e,$e.exports.default=e,e.deviation=function(e,t,n,r){var i=t&&t.length,s=i?t[0]*n:e.length,o=Math.abs(S(e,0,s,n));if(i)for(var a=0,l=t.length;a<l;a++){var u=t[a]*n,c=a<l-1?t[a+1]*n:e.length;o-=Math.abs(S(e,u,c,n))}var h=0;for(a=0;a<r.length;a+=3){var d=r[a]*n,f=r[a+1]*n,p=r[a+2]*n;h+=Math.abs((e[d]-e[p])*(e[f+1]-e[d+1])-(e[d]-e[f])*(e[p+1]-e[d+1]))}return 0===o&&0===h?0:Math.abs((h-o)/o)},e.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var s=0;s<e[i].length;s++)for(var o=0;o<t;o++)n.vertices.push(e[i][s][o]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n},$e.exports}(),He=M(qe);function We(e,t,n=0,r=e.length-1,i=Ke){for(;r>n;){if(r-n>600){const s=r-n+1,o=t-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);We(e,t,Math.max(n,Math.floor(t-o*l/s+u)),Math.min(r,Math.floor(t+(s-o)*l/s+u)),i)}const s=e[t];let o=n,a=r;for(Ze(e,n,t),i(e[r],s)>0&&Ze(e,n,r);o<a;){for(Ze(e,o,a),o++,a--;i(e[o],s)<0;)o++;for(;i(e[a],s)>0;)a--}0===i(e[n],s)?Ze(e,n,a):(a++,Ze(e,a,r)),a<=t&&(n=a+1),t<=a&&(r=a-1)}}function Ze(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Ke(e,t){return e<t?-1:e>t?1:0}const Xe=[0,0,1];function Ye(e,t,n,{texcoord_index:r,texcoord_scale:i,texcoord_normalize:s}){let o,a,l,u,c,h,d,f,p,g,m,_,y=t.vertex_elements,v=e.length,b=0;r&&(s=s||1,[o,a,l,u]=i||Ve);for(let i=0;i<v;i++){const v=500;let w=e[i];w.length>v&&(w=[...w],We(w,v,1,w.length-1,(e,t)=>t.area-e.area),w=w.slice(0,v));const A=(x=He.flatten(w),He(x.vertices,x.holes,x.dimensions)),E=A.length,S=t.vertex_count;if(E){r&&([c,h,d,f]=G.findBoundingBox(w),p=d-c,g=f-h,m=(l-o)/p,_=(u-a)/g);for(let e=0;e<w.length;e++){let i=w[e];for(let e=0;e<i.length;e++){let l=i[e];n[0]=l[0],n[1]=l[1],r&&(n[r+0]=((l[0]-c)*m+o)*s,n[r+1]=((l[1]-h)*_+a)*s),t.addVertex(n)}}for(let e=0;e<E;e++)y.push(S+A[e]);b+=E/3}}var x;return b}var Qe='uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_tile_proxy_order_offset;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\n\nuniform mat4 u_model;\nuniform mat4 u_modelView;\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nattribute vec4 a_position;\nattribute vec4 a_color;\n\n// Optional normal attribute, otherwise default to up\n#ifdef TANGRAM_NORMAL_ATTRIBUTE\n attribute vec3 a_normal;\n #define TANGRAM_NORMAL a_normal\n#else\n #define TANGRAM_NORMAL vec3(0., 0., 1.)\n#endif\n\n// Optional dynamic line extrusion\n#ifdef TANGRAM_EXTRUDE_LINES\n attribute vec2 a_extrude; // extrusion direction in xy plane\n attribute vec2 a_offset; // offset direction in xy plane\n\n // Polygon and line styles have slightly different VBO layouts, saving memory by optimizing vertex packing.\n // All lines have a width scaling factor, but only some have a height (position.z) or offset.\n // The vertex height is stored in different attributes to account for this.\n attribute vec2 a_z_and_offset_scale; // stores vertex height in x, and offset scaling factor in y\n #define TANGRAM_POSITION_Z a_z_and_offset_scale.x // vertex height is stored in separate line-specific attrib\n #define TANGRAM_OFFSET_SCALING a_z_and_offset_scale.y // zoom scaling factor for line offset\n #define TANGRAM_WIDTH_SCALING a_position.z // zoom scaling factor for line width (stored in position attrib)\n\n uniform float u_v_scale_adjust; // scales texture UVs for line dash patterns w/fractional pixel width\n#else\n #define TANGRAM_POSITION_Z a_position.z // vertex height\n#endif\n\nvarying vec4 v_position;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvarying vec4 v_world_position;\n\n// Optional texture UVs\n#if defined(TANGRAM_TEXTURE_COORDS) || defined(TANGRAM_EXTRUDE_LINES)\n attribute vec2 a_texcoord;\n varying vec2 v_texcoord;\n#endif\n\n// Optional model position varying for tile coordinate zoom\n#ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n varying vec4 v_modelpos_base_zoom;\n#endif\n\n#if defined(TANGRAM_LIGHTING_VERTEX)\n varying vec4 v_lighting;\n#endif\n\n#define TANGRAM_UNPACK_SCALING(x) (x / 1024.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvoid main() {\n // Initialize globals\n #pragma tangram: setup\n\n // Texture UVs\n #ifdef TANGRAM_TEXTURE_COORDS\n v_texcoord = a_texcoord;\n #ifdef TANGRAM_EXTRUDE_LINES\n v_texcoord.y *= u_v_scale_adjust;\n #endif\n #endif\n\n // Pass model position to fragment shader\n #ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n v_modelpos_base_zoom = modelPositionBaseZoom();\n #endif\n\n // Position\n vec4 position = vec4(a_position.xy, TANGRAM_POSITION_Z / TANGRAM_HEIGHT_SCALE, 1.); // convert height back to meters\n\n #ifdef TANGRAM_EXTRUDE_LINES\n vec2 _extrude = a_extrude.xy;\n vec2 _offset = a_offset.xy;\n\n // Adjust line width based on zoom level, to prevent proxied lines\n // from being either too small or too big.\n // "Flattens" the zoom between 1-2 to peg it to 1 (keeps lines from\n // prematurely shrinking), then interpolate and clamp to 4 (keeps lines\n // from becoming too small when far away).\n float _dz = clamp(u_map_position.z - u_tile_origin.z, 0., 4.);\n _dz += step(1., _dz) * (1. - _dz) + mix(0., 2., clamp((_dz - 2.) / 2., 0., 1.));\n\n // Interpolate line width between zooms\n float _mdz = (_dz - 0.5) * 2.; // zoom from mid-point\n _extrude -= _extrude * TANGRAM_UNPACK_SCALING(TANGRAM_WIDTH_SCALING) * _mdz;\n\n // Interpolate line offset between zooms\n // Scales from the larger value to the smaller one\n float _dwdz = TANGRAM_UNPACK_SCALING(TANGRAM_OFFSET_SCALING);\n float _sdwdz = sign(step(0., _dwdz) - 0.5); // sign indicates "direction" of scaling\n _offset -= _offset * abs(_dwdz) * ((1.-step(0., _sdwdz)) - (_dz * -_sdwdz)); // scale "up" or "down"\n\n // Scale line width and offset to be consistent in screen space\n float _ssz = exp2(-_dz - (u_tile_origin.z - u_tile_origin.w));\n _extrude *= _ssz;\n _offset *= _ssz;\n\n // Modify line width before extrusion\n #ifdef TANGRAM_BLOCK_WIDTH\n float width = 1.;\n #pragma tangram: width\n _extrude *= width;\n #endif\n\n position.xy += _extrude + _offset;\n #endif\n\n // World coordinates for 3d procedural textures\n v_world_position = wrapWorldPosition(u_model * position);\n\n // Adjust for tile and view position\n position = u_modelView * position;\n\n // Modify position before camera projection\n #pragma tangram: position\n\n // Setup varyings\n v_position = position;\n v_normal = normalize(u_normalMatrix * TANGRAM_NORMAL);\n v_color = a_color;\n\n #if defined(TANGRAM_LIGHTING_VERTEX)\n // Vertex lighting\n vec3 normal = v_normal;\n\n // Modify normal before lighting\n #pragma tangram: normal\n\n // Pass lighting intensity to fragment shader\n v_lighting = calculateLighting(position.xyz - u_eye, normal, vec4(1.));\n #endif\n\n // Camera\n cameraProjection(position);\n\n // +1 is to keep all layers including proxies > 0\n applyLayerOrder(a_position.w + u_tile_proxy_order_offset + 1., position);\n\n gl_Position = position;\n}\n',Je="uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\n\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nvarying vec4 v_position;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvarying vec4 v_world_position;\n\n#ifdef TANGRAM_EXTRUDE_LINES\n uniform bool u_has_line_texture;\n uniform sampler2D u_texture;\n uniform float u_texture_ratio;\n uniform vec4 u_dash_background_color;\n uniform float u_has_dash;\n#endif\n\n#define TANGRAM_NORMAL v_normal\n\n#if defined(TANGRAM_TEXTURE_COORDS) || defined(TANGRAM_EXTRUDE_LINES)\n varying vec2 v_texcoord;\n#endif\n\n#ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n varying vec4 v_modelpos_base_zoom;\n#endif\n\n#if defined(TANGRAM_LIGHTING_VERTEX)\n varying vec4 v_lighting;\n#endif\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvoid main (void) {\n // Initialize globals\n #pragma tangram: setup\n\n vec4 color = v_color;\n vec3 normal = TANGRAM_NORMAL;\n\n // Apply raster to vertex color\n #ifdef TANGRAM_RASTER_TEXTURE_COLOR\n vec4 _raster_color = sampleRaster(0);\n\n #if defined(TANGRAM_BLEND_OPAQUE) || defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n // Raster sources can optionally mask by the alpha channel, which will render with only full or no alpha.\n // This is used for handling transparency outside the raster image in some blend modes,\n // which either don't support alpha, or would cause transparent pixels to write to the depth buffer,\n // obscuring geometry underneath.\n #ifdef TANGRAM_HAS_MASKED_RASTERS // skip masking logic if no masked raster sources\n #ifndef TANGRAM_ALL_MASKED_RASTERS // skip source check for masking if *all* raster sources are masked\n if (u_raster_mask_alpha) {\n #else\n {\n #endif\n #if defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n if (_raster_color.a < TANGRAM_EPSILON) {\n discard;\n }\n #else // TANGRAM_BLEND_OPAQUE\n if (_raster_color.a < 1. - TANGRAM_EPSILON) {\n discard;\n }\n // only allow full alpha in opaque blend mode (avoids artifacts blending w/canvas tile background)\n _raster_color.a = 1.;\n #endif\n }\n #endif\n #endif\n\n color *= _raster_color; // multiplied to tint texture color\n #endif\n\n // Apply line texture\n #ifdef TANGRAM_EXTRUDE_LINES\n { // enclose in scope to avoid leakage of internal variables\n if (u_has_line_texture) {\n vec2 _line_st = vec2(v_texcoord.x, fract(v_texcoord.y / u_texture_ratio));\n vec4 _line_color = texture2D(u_texture, _line_st);\n\n // If the line has a dash pattern, the line texture indicates if the current fragment should be\n // the dash foreground or background color. If the line doesn't have a dash pattern,\n // the line texture color is used directly (but also tinted by the vertex color).\n color = mix(\n color * _line_color, // no dash: tint the line texture with the vertex color\n mix(u_dash_background_color, color, _line_color.a), // choose dash foreground or background color\n u_has_dash // 0 if no dash, 1 if has dash\n );\n\n // Use alpha discard test as a lower-quality substitute for blending\n #if defined(TANGRAM_BLEND_OPAQUE)\n if (color.a < TANGRAM_ALPHA_TEST) {\n discard;\n }\n #endif\n }\n }\n #endif\n\n // First, get normal from raster tile (if applicable)\n #ifdef TANGRAM_RASTER_TEXTURE_NORMAL\n normal = normalize(sampleRaster(0).rgb * 2. - 1.);\n #endif\n\n // Second, alter normal with normal map texture (if applicable)\n #if defined(TANGRAM_LIGHTING_FRAGMENT) && defined(TANGRAM_MATERIAL_NORMAL_TEXTURE)\n calculateNormal(normal);\n #endif\n\n // Normal modification applied here for fragment lighting or no lighting,\n // and in vertex shader for vertex lighting\n #if !defined(TANGRAM_LIGHTING_VERTEX)\n #pragma tangram: normal\n #endif\n\n // Color modification before lighting is applied\n #pragma tangram: color\n\n #if defined(TANGRAM_LIGHTING_FRAGMENT)\n // Calculate per-fragment lighting\n color = calculateLighting(v_position.xyz - u_eye, normal, color);\n #elif defined(TANGRAM_LIGHTING_VERTEX)\n // Apply lighting intensity interpolated from vertex shader\n color *= v_lighting;\n #endif\n\n // Post-processing effects (modify color after lighting)\n #pragma tangram: filter\n\n gl_FragColor = color;\n}\n";const et=Object.create(Pe);Object.assign(et,{name:"polygons",built_in:!0,vertex_shader_src:Qe,fragment_shader_src:Je,selection:!0,init(){Pe.init.apply(this,arguments),this.defines.TANGRAM_NORMAL_ATTRIBUTE=!0,this.defines.TANGRAM_TEXTURE_COORDS=this.texcoords},_parseFeature(e,t,n){var r=this.feature_style;return r.color=this.parseColor(t.color,n),r.color?(r.alpha=J.evalCachedProperty(t.alpha,n),r.variant=t.variant,r.z=J.evalCachedDistanceProperty(t.z,n)||J.defaults.z,r.z*=G.height_scale,r.extrude=J.evalProperty(t.extrude,n),r.extrude&&(!0===r.extrude?(r.height=e.properties.height||J.defaults.height,r.min_height=e.properties.min_height||J.defaults.min_height):"number"==typeof r.extrude?(r.height=r.extrude,r.min_height=0):Array.isArray(r.extrude)&&(r.min_height=r.extrude[0],r.height=r.extrude[1]),r.height*=G.height_scale,r.min_height*=G.height_scale),r.tile_edges=t.tile_edges,r):null},_preprocess(e){return e.color=J.createColorPropertyCache(e.color),e.alpha=J.createPropertyCache(e.alpha),e.z=J.createPropertyCache(e.z,J.parseUnits),this.computeVariant(e),e},computeVariant(e){const t=e.interactive?1:0,n=null!=e.extrude?1:0,r=this.texcoords?1:0,i=this.getBlendOrderForDraw(e),s=[t,n,r,i].join("/");e.variant=s,null==this.variants[s]&&(this.variants[s]={key:s,blend_order:i,mesh_order:0,selection:t,normal:n,texcoords:r})},vertexLayoutForMeshVariant(e){if(null==this.vertex_layouts[e.key]){const t=[{name:"a_position",size:4,type:fe.SHORT,normalized:!1},{name:"a_normal",size:3,type:fe.BYTE,normalized:!0,static:e.normal?null:[0,0,1]},{name:"a_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_texcoord",size:2,type:fe.UNSIGNED_SHORT,normalized:!0,static:e.texcoords?null:[0,0]}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.key]=new Le(t)}return this.vertex_layouts[e.key]},meshVariantTypeForDraw(e){return this.variants[e.variant]},makeVertexTemplate(e,t){let n=0;return this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=e.z||0,this.vertex_template[n++]=this.scaleOrder(e.order),t.variant.normal&&(this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=127),this.vertex_template[n++]=255*e.color[0],this.vertex_template[n++]=255*e.color[1],this.vertex_template[n++]=255*e.color[2],this.vertex_template[n++]=255*(null!=e.alpha?e.alpha:e.color[3]),t.variant.selection&&(this.vertex_template[n++]=255*e.selection_color[0],this.vertex_template[n++]=255*e.selection_color[1],this.vertex_template[n++]=255*e.selection_color[2],this.vertex_template[n++]=255*e.selection_color[3]),t.variant.texcoords&&(this.vertex_template[n++]=0,this.vertex_template[n++]=0),this.addCustomAttributesToVertexTemplate(e,n),this.vertex_template},buildPolygons(e,t,n){let r=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),i=r.vertex_data,s=i.vertex_layout,o=this.makeVertexTemplate(t,r),a={texcoord_index:s.index.a_texcoord,texcoord_normalize:65535,remove_tile_edges:!t.tile_edges,tile_edge_tolerance:G.tile_scale*n.tile.pad_scale*4,winding:n.winding};return t.extrude&&t.height?function(e,t,n,r,i,s,o,a,{remove_tile_edges:l,tile_edge_tolerance:u,texcoord_index:c,texcoord_scale:h,texcoord_normalize:d,winding:f}){var p=t+(r||0),g=t+n;s[2]=g;var m=Ye(e,i,s,{texcoord_index:c,texcoord_scale:h,texcoord_normalize:d}),_=i.vertex_elements,y=i.vertex_count;if(c){d=d||1;var[v,b,x,w]=h||Ve,A=[[v,w],[v,b],[x,b],[x,w]]}for(var E=e.length,S=0;S<E;S++)for(var T=e[S],k=0;k<T.length;k++)for(var O=T[k],R=0;R<O.length-1;R++){if(l&&Ue(O[R],O[R+1],u))continue;let e,t;"CCW"===f?(e=R,t=R+1):(e=R+1,t=R);var C=[[O[t][0],O[t][1],g],[O[t][0],O[t][1],p],[O[e][0],O[e][1],p],[O[e][0],O[e][1],g]];let n=ye.normalize([O[t][0]-O[e][0],O[t][1]-O[e][1],0]),r=ye.cross(Xe,n);s[o+0]=r[0]*a,s[o+1]=r[1]*a,s[o+2]=r[2]*a;for(var P=0;P<C.length;P++)s[0]=C[P][0],s[1]=C[P][1],s[2]=C[P][2],c&&(s[c+0]=A[P][0]*d,s[c+1]=A[P][1]*d),i.addVertex(s);_.push(y+0),_.push(y+1),_.push(y+2),_.push(y+2),_.push(y+3),_.push(y+0),y+=4,m+=2}return m}(e,t.z,t.height,t.min_height,i,o,s.index.a_normal,127,a):Ye(e,i,o,a)}});const tt=[0,0],nt={butt:0,square:1,round:2},rt={miter:0,bevel:1,round:2},it=G.tile_scale,st=[0,0],ot=[1,0],at=[.5,0];function lt(e,t){if(!(e.length<2)){var n,r,i,s,{join_type:o,cap_type:a,closed_polygon:l,remove_tile_edges:u,tile_edge_tolerance:c,v_scale:h,miter_len_sq:d}=t,f=null!=t.texcoord_index,p=0;if(l&&o===rt.miter){var g=function(e){if(Be(e[0]))return 0;for(var t=0;t<e.length;t++)if(Be(e[e.length-1-t]))return e.length-1-t;return 0}(e);if(0!==g){var m=function(e,t){var n=[];for(let i=0;i<e.length;i++){var r=(i+t)%e.length;0!==r&&n.push(e[r])}return n.push(n[0]),n}(e,g);return t.extra_lines=t.extra_lines||[],void t.extra_lines.push(m)}}var _=0,y=e.length-1,v=0;for(n=e[_],r=e[_+1];ye.isEqual(n,r);)if(n=r,r=e[1+ ++_],v++,_===e.length-1)return;for(;ye.isEqual(e[y],e[y-1]);)if(v++,0===--y)return;if(!(e.length<2+v))if(s=ye.normalize(ye.perp(n,r)),u&&Ue(n,r,c)){var b=ut(e,_,c);b&&(t.extra_lines=t.extra_lines||[],t.extra_lines.push(b))}else{l?function(e,t,n,r,i){if(void 0===r||Be(e))pt(e,n,n,1,0,i,1),pt(e,n,n,0,0,i,-1);else{r===rt.miter?ht(0,e,t,n,i.miter_len_sq,!0,i):dt(r,0,e,t,n,!0,i)}}(n,i=ye.normalize(ye.perp(e[y-1],n)),s,o,t):(Be(n)||(_t(n,p,s,a,!0,t),f&&a!==nt.butt&&(p+=.5*h*t.texcoord_width)),pt(n,s,s,1,p,t,1),pt(n,s,s,0,p,t,-1)),f&&(p+=h*ye.length(ye.sub(r,n)));for(var x=_+1;x<y;x++){var w=x,A=x+1;if(n=e[w],r=e[A],!ye.isEqual(n,r)){if(u&&Ue(n,r,c)){pt(n,s,s,1,p,t,1),pt(n,s,s,0,p,t,-1),ft(1,t);var E=ut(e,w+1,c);return void(E&&(t.extra_lines=t.extra_lines||[],t.extra_lines.push(E)))}i=s,s=ye.normalize(ye.perp(n,r)),o===rt.miter?ht(p,n,i,s,d,!1,t):dt(o,p,n,i,s,!1,t),f&&(p+=h*ye.length(ye.sub(r,n)))}}n=r,i=s,l?function(e,t,n,r,i,s){if(Be(e))pt(e,t,t,1,i,s,1),pt(e,t,t,0,i,s,-1),ft(1,s);else{var o=ct(t,n);r===rt.miter&&ye.lengthSq(o)>s.miter_len_sq&&(r=rt.bevel),r===rt.miter?(pt(e,o,t,1,i,s,1),pt(e,o,t,0,i,s,-1),ft(1,s)):(pt(e,t,t,1,i,s,1),pt(e,t,t,0,i,s,-1),ft(1,s))}}(n,i,s=ye.normalize(ye.perp(n,e[1])),o,p,t):(pt(n,i,s,1,p,t,1),pt(n,i,s,0,p,t,-1),ft(1,t),Be(n)||_t(n,p,i,a,!1,t))}}}function ut(e,t,n){for(var r=t;e[r+1]&&Ue(e[r],e[r+1],n);)r++;return e.length-r>=2&&e.slice(r)}function ct(e,t){var n=ye.normalize(ye.add(e,t)),r=2/(1+Math.abs(ye.dot(e,n)));return ye.mult(n,r*r)}function ht(e,t,n,r,i,s,o){var a=ct(n,r);ye.lengthSq(a)>i?dt(rt.bevel,e,t,n,r,s,o):(pt(t,a,a,1,e,o,1),pt(t,a,a,0,e,o,-1),s||ft(1,o))}function dt(e,t,n,r,i,s,o){var a=ct(r,i),l=i[0]*r[1]-i[1]*r[0]>0;null!=o.texcoord_index&&(st[1]=t,ot[1]=t),l?(pt(n,a,a,1,t,o,1),pt(n,r,a,0,t,o,-1),s||ft(1,o),mt(n,ye.neg(r),a,ye.neg(i),a,st,ot,st,!1,e===rt.bevel,o),pt(n,a,a,1,t,o,1),pt(n,i,a,0,t,o,-1)):(pt(n,r,a,1,t,o,1),pt(n,a,a,0,t,o,-1),s||ft(1,o),mt(n,r,ye.neg(a),i,a,ot,st,ot,!1,e===rt.bevel,o),pt(n,i,a,1,t,o,1),pt(n,a,a,0,t,o,-1))}function ft(e,t){for(var n=t.vertex_data.vertex_elements,r=t.vertex_data.vertex_count-2*e-2,i=0;i<e;i++)n.push(r+2*i+2),n.push(r+2*i+1),n.push(r+2*i+0),n.push(r+2*i+2),n.push(r+2*i+3),n.push(r+2*i+1),t.geom_count+=2}function pt(e,t,n,r,i,s,o){var a=s.vertex_template,l=s.vertex_data;a[0]=e[0],a[1]=e[1];let u=s.half_width*o;a[s.extrude_index+0]=t[0]*u,a[s.extrude_index+1]=t[1]*u,s.offset&&(a[s.offset_index+0]=n[0]*s.offset,a[s.offset_index+1]=n[1]*s.offset),null!=s.texcoord_index&&(a[s.texcoord_index+0]=65535*r,a[s.texcoord_index+1]=65535*i),l.addVertex(a)}var gt=[0,0];function mt(e,t,n,r,i,s,o,a,l,u,c){for(var h=t[0]*r[1]-t[1]*r[0],d=ye.dot(t,r),f=Math.atan2(h,d);f>=Math.PI;)f-=2*Math.PI;if(u)p=1;else{var p=function(e,t){e<0&&(e=-e);var n=t>10?Math.log2(t/5):1;return Math.ceil(e/Math.PI*n)}(f,c.half_width);if(p<1)return}var g=c.vertex_data.vertex_count,m=c.vertex_data.vertex_elements;pt(e,n,i,o[0],o[1],c,1),pt(e,t,i,s[0],s[1],c,1);var _=t,y=null!=c.texcoord_index;if(y)if(l)var v=ye.sub(s,o);else{gt=ye.copy(s);var b=ye.div(ye.sub(a,s),p)}var x=f/p;let w,A,E=f<0?-1:1;h>0?(w=2,A=1):(w=1,A=2);for(var S=0;S<p;S++)0===S&&f<0&&(_=ye.neg(_)),_=ye.rot(_,x),y&&(l?(v=ye.rot(v,x),gt[0]=v[0]+o[0],gt[1]=v[1]*c.texcoord_width*c.v_scale+o[1]):gt=ye.add(gt,b)),pt(e,_,i,gt[0],gt[1],c,E),m.push(g+S+w),m.push(g),m.push(g+S+A)}function _t(e,t,n,r,i,s){var o=ye.neg(n),a=null!=s.texcoord_index;switch(r){case nt.square:var l;i?(l=[n[1],-n[0]],pt(e,ye.add(n,l),n,1,t,s,1),pt(e,ye.add(o,l),n,0,t,s,1),a&&(t+=.5*s.texcoord_width*s.v_scale),pt(e,n,n,1,t,s,1),pt(e,o,n,0,t,s,1)):(l=[-n[1],n[0]],pt(e,n,n,1,t,s,1),pt(e,o,n,0,t,s,1),a&&(t+=.5*s.texcoord_width*s.v_scale),pt(e,ye.add(n,l),n,1,t,s,1),pt(e,ye.add(o,l),n,0,t,s,1)),ft(1,s);break;case nt.round:var u,c,h=st,d=ot,f=at;i?(u=n,c=o,a&&(t+=.5*s.texcoord_width*s.v_scale,h=ot,d=st,f=at)):(u=o,c=n),a&&(st[1]=t,ot[1]=t,at[1]=t),mt(e,u,tt,c,n,h,f,d,!0,!1,s);break;case nt.butt:return}}const yt=[255,255,255,255],vt=[0,0,0,0],bt=Object.create(Pe);Object.assign(bt,{name:"lines",built_in:!0,vertex_shader_src:Qe,fragment_shader_src:Je,selection:!0,init(){Pe.init.apply(this,arguments),this.defines.TANGRAM_EXTRUDE_LINES=!0,this.defines.TANGRAM_TEXTURE_COORDS=!0,this.outline_feature_style={},this.inline_feature_style=this.feature_style,this.dash_textures={}},calcDistance:(e,t)=>J.evalCachedDistanceProperty(e,t)||0,calcDistanceNextZoom(e,t){t.zoom++;let n=this.calcDistance(e,t);return t.zoom--,n},calcWidth(e,t,n){let r,i=this.calcDistance(e.width,n);if(!(i<0)){if(r=e.next_width?this.calcDistanceNextZoom(e.next_width,n):i/2,0===i&&0===r||r<0)return!1;if(t.width_unscaled=i,t.next_width_unscaled=r,e.next_width){r*=2;let e=.5*(i+r);t.width=e*n.units_per_meter_overzoom,t.width_scale=1-r/e}else t.width=i*n.units_per_meter_overzoom,t.width_scale=0;return e.texcoords&&(e.inline_texcoord_width?t.texcoord_width=e.inline_texcoord_width:t.texcoord_width=(t.width_unscaled||t.next_width_unscaled)*n.units_per_meter_overzoom/n.tile.overzoom2),!0}},calcOffset(e,t,n){if(e.offset_precalc)t.offset=e.offset_precalc,t.offset_scale=e.offset_scale_precalc;else if(e.offset){let r=this.calcDistance(e.offset,n);if(e.next_offset){let i=2*this.calcDistanceNextZoom(e.next_offset,n);Math.abs(r)>=Math.abs(i)?(t.offset=r*n.units_per_meter_overzoom,t.offset_scale=0!==r?1-i/r:0):(t.offset=i*n.units_per_meter_overzoom,t.offset_scale=0!==i?-1*(1-r/i):0)}else t.offset=r*n.units_per_meter_overzoom,t.offset_scale=0}else t.offset=0,t.offset_scale=0},_parseFeature(e,t,n){var r=this.feature_style;if(!1!==this.calcWidth(t,r,n)&&(this.calcOffset(t,r,n),r.color=this.parseColor(t.color,n),r.color)){if(r.alpha=J.evalCachedProperty(t.alpha,n),r.variant=t.variant,r.z=J.evalCachedDistanceProperty(t.z,n)||J.defaults.z,r.height=e.properties.height||J.defaults.height,r.extrude=J.evalProperty(t.extrude,n),r.extrude&&("number"==typeof r.extrude?r.height=r.extrude:Array.isArray(r.extrude)&&(r.height=r.extrude[1])),r.extrude&&r.height&&(r.z+=r.height),r.z*=G.height_scale,r.cap=t.cap,r.join=t.join,r.miter_limit=t.miter_limit,r.tile_edges=t.tile_edges,r.outline=r.outline||{width:{},next_width:{},preprocessed:!0},t.outline&&!1!==t.outline.visible&&t.outline.color&&t.outline.width){let e=2*this.calcDistance(t.outline.width,n),i=2*this.calcDistanceNextZoom(t.outline.next_width,n);0===e&&0===i||e<0||i<0?(r.outline.width.value=null,r.outline.next_width.value=null,r.outline.color=null,r.outline.inline_texcoord_width=null,r.outline.texcoords=!1):(r.outline.width.value=e+r.width_unscaled,r.outline.next_width.value=i+r.next_width_unscaled,r.outline.inline_texcoord_width=r.texcoord_width,r.outline.offset_precalc=r.offset,r.outline.offset_scale_precalc=r.offset_scale,r.outline.color=t.outline.color,r.outline.alpha=t.outline.alpha,r.outline.interactive=t.outline.interactive,r.outline.cap=t.outline.cap,r.outline.join=t.outline.join,r.outline.miter_limit=t.outline.miter_limit,r.outline.texcoords=t.outline.texcoords,r.outline.extrude=t.outline.extrude,r.outline.z=t.outline.z,r.outline.style=t.outline.style,r.outline.variant=t.outline.variant,t.outline.order?r.outline.order=this.parseOrder(t.outline.order,n):r.outline.order=r.order,r.outline.order>r.order&&(r.outline.order=r.order),r.outline.order-=.5)}else r.outline.width.value=null,r.outline.next_width.value=null,r.outline.color=null,r.outline.inline_texcoord_width=null;return r}},_preprocess(e){if(e.color=J.createColorPropertyCache(e.color),e.alpha=J.createPropertyCache(e.alpha),e.width=J.createPropertyCache(e.width,J.parseUnits),e.width&&e.width.type!==J.CACHE_TYPE.STATIC&&(e.next_width=J.createPropertyCache(e.width,J.parseUnits)),e.offset=e.offset&&J.createPropertyCache(e.offset,J.parseUnits),e.offset&&e.offset.type!==J.CACHE_TYPE.STATIC&&(e.next_offset=J.createPropertyCache(e.offset,J.parseUnits)),e.z=J.createPropertyCache(e.z,J.parseUnits),e.dash=void 0!==e.dash?e.dash:this.dash,e.dash_key=e.dash&&this.dashTextureKey(e.dash),e.dash_background_color=void 0!==e.dash_background_color?e.dash_background_color:this.dash_background_color,e.dash_background_color=e.dash_background_color&&J.parseColor(e.dash_background_color),e.texture_merged=e.dash_key||(void 0!==e.texture?e.texture:this.texture),e.texcoords=this.texcoords||e.texture_merged?1:0,this.computeVariant(e),e.outline){e.outline.is_outline=!0,e.outline.style=e.outline.style||this.name,e.outline.color=J.createColorPropertyCache(e.outline.color),e.outline.alpha=J.createPropertyCache(e.outline.alpha),e.outline.width=J.createPropertyCache(e.outline.width,J.parseUnits),e.outline.next_width=J.createPropertyCache(e.outline.width,J.parseUnits),e.outline.interactive=null!=e.outline.interactive?e.outline.interactive:e.interactive,e.outline.cap=e.outline.cap||e.cap,e.outline.join=e.outline.join||e.join,e.outline.miter_limit=null!=e.outline.miter_limit?e.outline.miter_limit:e.miter_limit,e.outline.offset=e.offset,e.outline.extrude=e.extrude,e.outline.z=e.z;let t=this.styles[e.outline.style];t?(e.outline.dash=void 0!==e.outline.dash?e.outline.dash:t.dash,e.outline.texture=void 0!==e.outline.texture?e.outline.texture:t.texture,null!=e.outline.dash?(e.outline.dash_key=e.outline.dash&&this.dashTextureKey(e.outline.dash),e.outline.texture_merged=e.outline.dash_key):null===e.outline.dash||null!=e.outline.texture?(e.outline.dash_key=null,e.outline.texture_merged=e.outline.texture):(e.outline.dash=e.dash,e.outline.dash_key=e.outline.dash&&this.dashTextureKey(e.outline.dash),e.outline.texture_merged=e.outline.dash_key),e.outline.dash_background_color=void 0!==e.outline.dash_background_color?e.outline.dash_background_color:t.dash_background_color,e.outline.dash_background_color=void 0!==e.outline.dash_background_color?e.outline.dash_background_color:e.dash_background_color,e.outline.dash_background_color=e.outline.dash_background_color&&J.parseColor(e.outline.dash_background_color),e.outline.texcoords=t.texcoords||e.outline.texture_merged?1:0,void 0===e.outline.blend_order&&null!=e.blend_order&&(e.outline.blend_order=e.blend_order),t.computeVariant(e.outline)):(m({level:"warn",once:!0},`Layer group '${e.layers.join(", ")}': line 'outline' specifies non-existent draw style '${e.outline.style}' (or maybe the style is defined but is missing a 'base' or has another error), skipping outlines for features matching this layer group`),e.outline=null)}return e},dashTextureKey:e=>"__dash_"+JSON.stringify(e),getDashTexture(e){let t=this.dashTextureKey(e);if(null==this.dash_textures[t]){this.dash_textures[t]=!0;const n=function(e,t={}){const n=t.dash_color||yt,r=t.background_color||vt,i=e,s=t.scale||1;i.length%2==1&&Array.prototype.push.apply(i,i);let o=!0,a=[];for(let e=0;e<i.length;e++){let t=Math.floor(i[e]*s);for(let e=0;e<t;e++)Array.prototype.push.apply(a,o?n:r);o=!o}return a.reverse(),a=new Uint8Array(a),{pixels:a,length:a.length/4}}(e,{scale:20});k.create(this.gl,t,{data:n.pixels,height:n.length,width:1,filtering:"nearest"})}},async endData(e){const t=await Pe.endData.call(this,e);if(t){t.uniforms.u_has_line_texture=!1,t.uniforms.u_texture=k.default,t.uniforms.u_v_scale_adjust=G.tile_scale;let n=[];for(let r in t.meshes){let i=t.meshes[r].variant;if(i.texture){let s=t.meshes[r].uniforms=t.meshes[r].uniforms||{};if(s.u_has_line_texture=!0,s.u_texture=i.texture,s.u_texture_ratio=1,i.dash&&(s.u_v_scale_adjust=20*G.tile_scale,s.u_has_dash=null!=i.dash_background_color?1:0,s.u_dash_background_color=i.dash_background_color||[0,0,0,0]),i.dash_key&&null==this.dash_textures[i.dash_key]){this.dash_textures[i.dash_key]=!0;try{await a.postMessage(this.main_thread_target+".getDashTexture",i.dash)}catch(e){m("trace",`${this.name}: line dash texture create failed because style no longer on main thread`)}}if(null==k.textures[i.texture])n.push(k.syncTexturesToWorker([i.texture]).then(e=>{let t=e[i.texture];t&&(s.u_texture_ratio=t.height/t.width)}));else{let e=k.textures[i.texture];s.u_texture_ratio=e.height/e.width}}}await Promise.all(n)}return t},computeVariant(e){let t=e.offset?1:0;t+="/"+e.texcoords,t+="/"+(e.interactive?1:0),t+="/"+(e.extrude||e.z?1:0),t+="/"+e.is_outline,e.dash_key&&(t+=e.dash_key,e.dash_background_color&&(t+=e.dash_background_color)),e.texture_merged&&(t+=e.texture_merged);const n=this.getBlendOrderForDraw(e);t+="/"+n,t=P(t),e.variant=t,null==this.variants[t]&&(this.variants[t]={key:t,blend_order:n,mesh_order:e.is_outline?0:1,selection:e.interactive?1:0,offset:e.offset?1:0,z_or_offset:e.offset||e.extrude||e.z?1:0,texcoords:e.texcoords,texture:e.texture_merged,dash:e.dash,dash_key:e.dash_key,dash_background_color:e.dash_background_color})},vertexLayoutForMeshVariant(e){if(null==this.vertex_layouts[e.key]){const t=[{name:"a_position",size:4,type:fe.SHORT,normalized:!1},{name:"a_extrude",size:2,type:fe.SHORT,normalized:!1},{name:"a_offset",size:2,type:fe.SHORT,normalized:!1,static:e.offset?null:[0,0]},{name:"a_z_and_offset_scale",size:2,type:fe.SHORT,normalized:!1,static:e.z_or_offset?null:[0,0]},{name:"a_texcoord",size:2,type:fe.UNSIGNED_SHORT,normalized:!0,static:e.texcoords?null:[0,0]},{name:"a_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.key]=new Le(t)}return this.vertex_layouts[e.key]},meshVariantTypeForDraw(e){return this.variants[e.variant]},makeVertexTemplate(e,t){let n=0;return this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=1024*e.width_scale,this.vertex_template[n++]=this.scaleOrder(e.order),this.vertex_template[n++]=0,this.vertex_template[n++]=0,t.variant.offset&&(this.vertex_template[n++]=0,this.vertex_template[n++]=0),t.variant.z_or_offset&&(this.vertex_template[n++]=e.z||0,this.vertex_template[n++]=1024*e.offset_scale),t.variant.texcoords&&(this.vertex_template[n++]=0,this.vertex_template[n++]=0),this.vertex_template[n++]=255*e.color[0],this.vertex_template[n++]=255*e.color[1],this.vertex_template[n++]=255*e.color[2],this.vertex_template[n++]=255*(null!=e.alpha?e.alpha:e.color[3]),t.variant.selection&&(this.vertex_template[n++]=255*e.selection_color[0],this.vertex_template[n++]=255*e.selection_color[1],this.vertex_template[n++]=255*e.selection_color[2],this.vertex_template[n++]=255*e.selection_color[3]),this.addCustomAttributesToVertexTemplate(e,n),this.vertex_template},buildLines(e,t,n,r){if(this.feature_style=this.outline_feature_style,t.outline&&null!=t.outline.color&&null!=t.outline.width.value){var i=this.styles[t.outline.style];i&&i.addFeature(n.feature,t.outline,n)}this.feature_style=this.inline_feature_style;let s=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),o=s.vertex_data,a=o.vertex_layout;return function(e,t,n,r,i,s,o,a){var l,u=t.cap?nt[t.cap]:nt.butt,c=t.join?rt[t.join]:rt.miter;if(c===rt.miter){const e=t.miter_limit||3;var h=e*e}i.a_texcoord&&(l=1/(t.texcoord_width*it));var d={closed_polygon:s,remove_tile_edges:o,tile_edge_tolerance:a,miter_len_sq:h,join_type:c,cap_type:u,vertex_data:n,vertex_template:r,half_width:t.width/2,extrude_index:i.a_extrude,offset_index:i.a_offset,v_scale:l,texcoord_index:i.a_texcoord,texcoord_width:t.texcoord_width,offset:t.offset,geom_count:0};for(let t=0;t<e.length;t++)lt(e[t],d);if(d.extra_lines)for(let e=0;e<d.extra_lines.length;e++)lt(d.extra_lines[e],d);return d.geom_count}(e,t,o,this.makeVertexTemplate(t,s),a.index,r&&r.closed_polygon,!t.tile_edges&&r&&r.remove_tile_edges,G.tile_scale*n.tile.pad_scale*2)},buildPolygons(e,t,n){let r=0;for(let i=0;i<e.length;i++)r+=this.buildLines(e[i],t,n,{closed_polygon:!0,remove_tile_edges:!0});return r}});const xt=128/Math.PI,wt=16384/Math.PI,At=[0,2,2,0],Et=[1,1,3,3],St=new Array(4),Tt=["left","top-left","bottom-left"],kt=["right","top-right","bottom-right"],Ot=["top","top-left","top-right"],Rt=["bottom","bottom-left","bottom-right"],Ct={computeOffset(e,t,n,r=null){if(!n||"center"===n)return e;let i=[e[0],e[1]];return r=r||this.default_buffer,this.isLeftAnchor(n)?(i[0]-=t[0]/2,"left"===n&&(i[0]-=r[0])):this.isRightAnchor(n)&&(i[0]+=t[0]/2,"right"===n&&(i[0]+=r[1])),this.isTopAnchor(n)?(i[1]-=t[1]/2,"top"===n&&(i[1]-=r[2])):this.isBottomAnchor(n)&&(i[1]+=t[1]/2,"bottom"===n&&(i[1]+=r[3])),i},alignForAnchor(e){if(e&&"center"!==e){if(this.isLeftAnchor(e))return"right";if(this.isRightAnchor(e))return"left"}return"center"},isLeftAnchor:e=>Tt.indexOf(e)>-1,isRightAnchor:e=>kt.indexOf(e)>-1,isTopAnchor:e=>Ot.indexOf(e)>-1,isBottomAnchor:e=>Rt.indexOf(e)>-1,default_buffer:[2.5,2.5,1.5,.75],zero_buffer:[0,0,0,0]};function Pt(e,t){return!(e[2]<t[0]||e[0]>t[2]||e[3]<t[1]||e[1]>t[3])}const Mt=[[1,0],[0,1]],Nt=[],It=[];let Dt,Ft,zt,Lt;class jt{constructor(e,t,n,r,i){this.dimension=[r/2,i/2],this.angle=n,this.centroid=[e,t],this.quad=null,this.axis_0=null,this.axis_1=null,this.update()}toJSON(){return{x:this.centroid[0],y:this.centroid[1],a:this.angle,w:this.dimension[0],h:this.dimension[1]}}getExtent(){return 0===this.angle?[this.quad[0],this.quad[1],this.quad[4],this.quad[5]]:[Math.min(this.quad[0],this.quad[2],this.quad[4],this.quad[6]),Math.min(this.quad[1],this.quad[3],this.quad[5],this.quad[7]),Math.max(this.quad[0],this.quad[2],this.quad[4],this.quad[6]),Math.max(this.quad[1],this.quad[3],this.quad[5],this.quad[7])]}updateAxes(){this.axis_0=ye.normalize([this.quad[4]-this.quad[6],this.quad[5]-this.quad[7]]),this.axis_1=ye.normalize([this.quad[4]-this.quad[2],this.quad[5]-this.quad[3]])}update(){const e=this.centroid,t=this.dimension[0],n=this.dimension[1];if(0===this.angle)this.quad=[e[0]-t,e[1]-n,e[0]+t,e[1]-n,e[0]+t,e[1]+n,e[0]-t,e[1]+n],this.axis_0=Mt[0],this.axis_1=Mt[1];else{let r=Math.cos(this.angle)*t,i=Math.sin(this.angle)*t,s=-Math.sin(this.angle)*n,o=Math.cos(this.angle)*n;this.quad=[e[0]-r-s,e[1]-i-o,e[0]+r-s,e[1]+i-o,e[0]+r+s,e[1]+i+o,e[0]-r+s,e[1]-i+o],this.updateAxes()}}static projectToAxis(e,t,n){let r=e.quad;return Dt=r[0]*t[0]+r[1]*t[1],Ft=r[2]*t[0]+r[3]*t[1],zt=r[4]*t[0]+r[5]*t[1],Lt=r[6]*t[0]+r[7]*t[1],n[0]=Math.min(Dt,Ft,zt,Lt),n[1]=Math.max(Dt,Ft,zt,Lt),n}static axisCollide(e,t,n,r){return jt.projectToAxis(e,n,Nt),jt.projectToAxis(t,n,It),!(It[0]>Nt[1]||It[1]<Nt[0]||(jt.projectToAxis(e,r,Nt),jt.projectToAxis(t,r,It),It[0]>Nt[1]||It[1]<Nt[0]))}static intersect(e,t){return jt.axisCollide(e,t,e.axis_0,e.axis_1)&&jt.axisCollide(e,t,t.axis_0,t.axis_1)}}class Vt{constructor(e,t={}){this.id=Vt.nextLabelId(),this.type="",this.size=e,this.layout=t,this.position=null,this.angle=0,this.anchor=Array.isArray(this.layout.anchor)?this.layout.anchor[0]:this.layout.anchor,this.placed=null,this.offset=t.offset,this.unit_scale=this.layout.units_per_pixel,this.aabb=null,this.obb=null,this.align="center",this.throw_away=!1}toJSON(){return{id:this.id,type:this.type,obb:this.obb.toJSON(),position:this.position,angle:this.angle,size:this.size,offset:this.offset,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:Ut(this.layout)}}update(){this.align=this.layout.align||Ct.alignForAnchor(this.anchor)}occluded(e,t=null){let n=!1,r=e.aabb,i=e.obb;return r.length>0&&function(e,t,n){for(let r=0;r<t.length&&(!Pt(e,t[r])||null==n(r));r++);}(this.aabb,r,e=>{if(!t||r[e]!==t.aabb)return 0===this.obb.angle&&0===i[e].angle||jt.intersect(this.obb,i[e])?(n=!0,!0):void 0}),n}inTileBounds(){return this.aabb[0]>=0&&this.aabb[1]>-G.tile_scale&&this.aabb[0]<G.tile_scale&&this.aabb[1]<=0||this.aabb[2]>=0&&this.aabb[3]>-G.tile_scale&&this.aabb[2]<G.tile_scale&&this.aabb[3]<=0}mayRepeatAcrossTiles(){if(this.layout.collide)return!0;const e=this.layout.repeat_distance;return 0!==e&&(Math.abs(this.position[0])<e||Math.abs(this.position[0]-G.tile_scale)<e||Math.abs(this.position[1])<e||Math.abs(-(this.position[1]-G.tile_scale))<e)}discard(e,t=null){return!!this.throw_away||this.occluded(e,t)}}function Ut(e){return{priority:e.priority,collide:e.collide,repeat_distance:e.repeat_distance,repeat_group:e.repeat_group,buffer:e.buffer,italic:e.italic}}Vt.add=function(e,t){if(e.placed=!0,e.aabb&&(t.aabb.push(e.aabb),t.obb.push(e.obb)),e.aabbs)for(let n=0;n<e.aabbs.length;n++)t.aabb.push(e.aabbs[n]),t.obb.push(e.obbs[n])},Vt.id=0,Vt.id_prefix=0,Vt.id_multiplier=0,Vt.nextLabelId=function(){return Vt.id_prefix+Vt.id++*Vt.id_multiplier},Vt.epsilon=.9999;class Bt{constructor(e,t){this.key=e,this.repeat_dist=t,this.repeat_dist_sq=this.repeat_dist*this.repeat_dist,this.positions=[]}check(e){let t=e.position;for(let e=0;e<this.positions.length;e++){let n=this.positions[e],r=t[0]-n[0],i=t[1]-n[1];if(r*r+i*i<this.repeat_dist_sq)return!0}}add(e){e&&e.position&&this.positions.push(e.position)}static clear(e){this.groups[e]={}}static check(e,t,n){if(t.repeat_distance&&t.repeat_group&&this.groups[n][t.repeat_group])return this.groups[n][t.repeat_group].check(e)}static add(e,t,n){t.repeat_distance&&t.repeat_group&&(null==this.groups[n][t.repeat_group]&&(this.groups[n][t.repeat_group]=new Bt(t.repeat_group,t.repeat_distance*t.repeat_scale)),this.groups[n][t.repeat_group].add(e))}}Bt.groups={};class Gt{constructor(e,t){this.anchor=e,this.span=t,this.cells={}}addLabel(e){e.aabb&&this.addLabelBboxes(e,e.aabb),e.aabbs&&e.aabbs.forEach(t=>this.addLabelBboxes(e,t))}addLabelBboxes(e,t){const n=[Math.max(Math.floor((t[0]-this.anchor.x)/this.span),0),Math.max(Math.floor(-(t[1]-this.anchor.y)/this.span),0),Math.max(Math.floor((t[2]-this.anchor.x)/this.span),0),Math.max(Math.floor(-(t[3]-this.anchor.y)/this.span),0)];e.cells=[];for(let t=n[1];t<=n[3];t++){this.cells[t]=this.cells[t]||{};for(let r=n[0];r<=n[2];r++)this.cells[t][r]=this.cells[t][r]||{aabb:[],obb:[]},e.cells.push(this.cells[t][r])}}}const $t={tiles:{},grid:null,initGrid(e){this.grid=null==e?null:new Gt(e.anchor,e.span)},startTile(e,{apply_repeat_groups:t=!0,return_hidden:n=!1}={}){let r=this.tiles[e]={bboxes:{aabb:[],obb:[]},objects:{},labels:{},styles:{},repeat:t,return_hidden:n};null==r.complete&&(r.complete=new Promise((e,t)=>{r.resolve=e,r.reject=t}))},resetTile(e){delete this.tiles[e]},abortTile(e){this.tiles[e]&&this.tiles[e].resolve&&this.tiles[e].resolve([]),this.resetTile(e)},addStyle(e,t){this.tiles[t].styles[e]=!0},collide(e,t,n){let r=this.tiles[n];if(!r)return m("trace","Collision.collide() called with null tile",n,this.tiles,t,e),Promise.resolve([]);let i=r.objects;for(let n=0;n<e.length;n++){let r=e[n],s=r.label.layout.priority;i[s]=i[s]||{},i[s][t]=i[s][t]||[],i[s][t].push(r)}return delete r.styles[t],0===Object.keys(r.styles).length&&this.endTile(n),r.complete.then(()=>(r.resolve=null,r.labels[t]||[]))},endTile(e){let t=this.tiles[e],n=t.labels;this.grid&&this.addLabelsToGrid(e),t.repeat&&Bt.clear(e);let r=Object.keys(t.objects).sort((e,t)=>e-t);for(let i=0;i<r.length;i++){let s=t.objects[r[i]];if(s)for(let r in s){let i=s[r];n[r]=n[r]||[];for(let s=0;s<i.length;s++){let o=i[s];this.canBePlaced(o,e,o.linked,t)?o.linked?this.canBePlaced(o.linked,e,o,t)?(o.show=!0,(o.label.breach||o.linked.label.breach)&&(o.label.breach=!0,o.linked.label.breach=!0),(o.label.may_repeat_across_tiles||o.linked.label.may_repeat_across_tiles)&&(o.label.may_repeat_across_tiles=!0,o.linked.label.may_repeat_across_tiles=!0),n[r].push(o),this.place(o,e,t),this.place(o.linked,e,t)):t.return_hidden&&(o.show=!1,n[r].push(o)):(o.show=!0,n[r].push(o),this.place(o,e,t)):t.return_hidden&&(o.show=!1,n[r].push(o))}}}delete this.tiles[e],t.resolve()},addLabelsToGrid(e){const t=this.tiles[e];for(const e in t.objects){const n=t.objects[e];if(n)for(const e in n)n[e].forEach(e=>this.grid.addLabel(e.label))}},canBePlaced(e,t,n=null,{repeat:r=!0}={}){let i=e.label,s=e.label.layout;if(null!=i.placed)return i.placed;let o=!s.collide;if(o||(o=this.grid&&i.cells?i.cells.reduce((e,t)=>(e&&i.discard(t,n&&n.label)&&(e=!1),e),!0):!i.discard(this.tiles[t].bboxes,n&&n.label)),o){if(!r||!Bt.check(i,s,t))return!0;i.placed=!1}else s.collide&&(i.placed=!1);return i.placed},place({label:e},t,{repeat:n=!0}){null==e.placed&&(n&&Bt.add(e,e.layout,t),this.grid&&e.cells?e.cells.forEach(t=>Vt.add(e,t)):Vt.add(e,this.tiles[t].bboxes))}};class qt extends Vt{constructor(e,t,n,r=0){super(t,n),this.type="point",this.position=[e[0],e[1]],this.angle=r,this.parent=this.layout.parent,this.update(),this.start_anchor_index=1,this.degenerate=!(this.size[0]||this.size[1]||this.layout.buffer[0]||this.layout.buffer[1]),this.throw_away=!1}update(){super.update(),this.computeOffset(),this.updateBBoxes()}computeOffset(){if(this.offset=[this.layout.offset[0],this.layout.offset[1]],this.parent){let e=this.parent;this.offset=Ct.computeOffset(this.offset,e.size,e.anchor,Ct.zero_buffer),this.offset=Ct.computeOffset(this.offset,e.size,this.anchor,Ct.zero_buffer),e.offset!==J.zeroPair&&(this.offset===J.zeroPair?this.offset=e.offset:(this.offset[0]+=e.offset[0],this.offset[1]+=e.offset[1]))}this.offset=Ct.computeOffset(this.offset,this.size,this.anchor)}updateBBoxes(){let e=(this.size[0]+2*this.layout.buffer[0])*this.unit_scale*Vt.epsilon,t=(this.size[1]+2*this.layout.buffer[1])*this.unit_scale*Vt.epsilon;this.layout.italic&&(e+=5*this.unit_scale),this.obb=new jt(this.position[0]+this.offset[0]*this.unit_scale,this.position[1]-this.offset[1]*this.unit_scale,-this.angle,e,t),this.aabb=this.obb.getExtent(),this.inTileBounds&&(this.breach=!this.inTileBounds()),this.mayRepeatAcrossTiles&&(this.may_repeat_across_tiles=this.mayRepeatAcrossTiles())}discard(e,t=null){if(this.degenerate)return!1;if(super.discard(e,t)){if(Array.isArray(this.layout.anchor))for(let n=this.start_anchor_index;n<this.layout.anchor.length;n++)if(this.anchor=this.layout.anchor[n],this.update(),!super.discard(e,t))return!1;return!0}return!1}}qt.PLACEMENT={VERTEX:0,MIDPOINT:1,SPACED:2,CENTROID:3};const Ht=qt.PLACEMENT;function Wt(e,t,n){const r=[],i=n.placement,s=Math.max(t[0],t[1])*n.placement_min_length_ratio*n.units_per_pixel;if(i===Ht.SPACED){let i=function(e,t,n){let r=n.units_per_pixel,i=(n.placement_spacing||80)*r,s=function(e){let t=0;for(let n=0;n<e.length-1;n++)t+=Kt(e[n],e[n+1]);return t}(e);if(s<=t)return!1;let o=Math.max(Math.floor(s/i),1),a=[],l=[],u=.5*(s-(o-1)*i);for(let r=0;r<o;r++){let{position:r,angle:s}=Xt(e,u,t,n);null!=r&&null!=s&&(a.push(r),l.push(s)),u+=i}return{positions:a,angles:l}}(e,s,n);if(!i)return[];let o=i.positions,a=i.angles;for(let e=0;e<o.length;e++){let i=o[e],s=a[e];!0!==n.tile_edges&&Be(i)||r.push(new qt(i,t,n,s))}}else if(i===Ht.VERTEX){let i,s;for(let o=0;o<e.length-1;o++)if(i=e[o],s=e[o+1],!0===n.tile_edges||!Be(i)){const e=Zt(i,s,n.angle);r.push(new qt(i,t,n,e))}const o=Zt(i,s,n.angle);r.push(new qt(s,t,n,o))}else if(i===Ht.MIDPOINT)for(let i=0;i<e.length-1;i++){let o=e[i],a=e[i+1],l=[.5*(o[0]+a[0]),.5*(o[1]+a[1])];if((!0===n.tile_edges||!Be(l))&&(!s||Kt(o,a)>s)){const e=Zt(o,a,n.angle);r.push(new qt(l,t,n,e))}}return r}function Zt(e,t,n=0){return"auto"===n?Math.atan2(t[0]-e[0],t[1]-e[1]):n}function Kt(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2))}function Xt(e,t,n,r){let i,s,o=0;for(let a=0;a<e.length-1;a++){let l=e[a],u=e[a+1];const c=Kt(l,u);if(!(c<=n)&&(o+=c,o>t)){i=Yt(l,u,o-t),s=Zt(l,u,r.angle);break}}return{position:i,angle:s}}function Yt(e,t,n){let r=n/Kt(e,t);return[r*e[0]+(1-r)*t[0],r*e[1]+(1-r)*t[1]]}const Qt={key:e=>[e.style,e.weight,e.family,e.px_size,e.fill,e.stroke,e.stroke_width,e.underline_width,e.background_color,e.background_width,e.background_stroke_color,e.background_stroke_width,e.transform,e.text_wrap,e.max_lines,e.supersample,_.device_pixel_ratio].join("/"),defaults:{style:"normal",weight:"normal",size:"12px",px_size:12,family:"Helvetica",fill:[1,1,1,1],text_wrap:15,max_lines:5,align:"center"},compute(e,t){const n={};e.font=e.font||this.defaults,n.supersample=e.supersample_text?1.5:1,n.can_articulate=e.can_articulate,n.fill=J.evalCachedColorPropertyWithAlpha(e.font.fill,e.font.alpha,t),n.fill=_.toCSSColor(n.fill),e.font.stroke&&e.font.stroke.color&&(n.stroke=J.evalCachedColorPropertyWithAlpha(e.font.stroke.color,e.font.stroke.alpha,t),n.stroke=_.toCSSColor(n.stroke),n.stroke_width=J.evalCachedProperty(e.font.stroke.width,t)),!0!==e.font.underline||n.can_articulate||(n.underline_width=1.5*n.supersample),e.font.background&&!n.can_articulate&&(n.background_color=J.evalCachedColorPropertyWithAlpha(e.font.background.color,e.font.background.alpha,t),n.background_color=_.toCSSColor(n.background_color),n.background_color&&(n.background_width=J.evalCachedProperty(e.font.background.width,t)),n.background_stroke_color=e.font.background.stroke&&e.font.background.stroke.color&&J.evalCachedColorPropertyWithAlpha(e.font.background.stroke.color,e.font.background.stroke.alpha,t),n.background_stroke_color&&(n.background_stroke_color=_.toCSSColor(n.background_stroke_color),n.background_stroke_width=null!=e.font.background.stroke.width?J.evalCachedProperty(e.font.background.stroke.width,t):1)),n.weight=J.evalCachedProperty(e.font.weight,t)||this.defaults.weight,"number"==typeof n.weight&&(n.weight=Math.min(Math.max(n.weight,1),1e3)),e.font.family?(n.family=e.font.family,n.family!==this.defaults.family&&(n.family+=", "+this.defaults.family)):n.family=this.defaults.family,n.style=e.font.style||this.defaults.style,n.transform=e.font.transform,n.px_size=J.evalCachedProperty(e.font.px_size,t)*n.supersample,n.font_css=this.fontCSS(n);let r=e.text_wrap;return null!=r||n.can_articulate||(r=!0),!0===r&&(r=this.defaults.text_wrap),n.text_wrap=r,n.max_lines=e.max_lines||this.defaults.max_lines,n},fontCSS:({style:e,weight:t,px_size:n,family:r})=>[e,t,n+"px",r].filter(e=>e).join(" ")};var Jt,en,tn={exports:{}},nn=M((Jt||(Jt=1,en=tn,function(){function e(e,t){document.addEventListener?e.addEventListener("scroll",t,!1):e.attachEvent("scroll",t)}function t(e){this.a=document.createElement("div"),this.a.setAttribute("aria-hidden","true"),this.a.appendChild(document.createTextNode(e)),this.b=document.createElement("span"),this.c=document.createElement("span"),this.h=document.createElement("span"),this.f=document.createElement("span"),this.g=-1,this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.b.appendChild(this.h),this.c.appendChild(this.f),this.a.appendChild(this.b),this.a.appendChild(this.c)}function n(e,t){e.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;left:-999px;white-space:nowrap;font:"+t+";"}function r(e){var t=e.a.offsetWidth,n=t+100;return e.f.style.width=n+"px",e.c.scrollLeft=n,e.b.scrollLeft=e.b.scrollWidth+100,e.g!==t&&(e.g=t,!0)}function i(t,n){function i(){var e=s;r(e)&&e.a.parentNode&&n(e.g)}var s=t;e(t.b,i),e(t.c,i),r(t)}function s(e,t){var n=t||{};this.family=e,this.style=n.style||"normal",this.weight=n.weight||"normal",this.stretch=n.stretch||"normal"}var o=null,a=null,l=null,u=null;function c(){if(null===l){var e=document.createElement("div");try{e.style.font="condensed 100px sans-serif"}catch(e){}l=""!==e.style.font}return l}function h(e,t){return[e.style,e.weight,c()?e.stretch:"","100px",t].join(" ")}s.prototype.load=function(e,r){var s=this,l=e||"BESbswy",c=0,d=r||3e3,f=(new Date).getTime();return new Promise(function(e,r){var p;if(null===u&&(u=!!document.fonts),(p=u)&&(null===a&&(a=/OS X.*Version\/10\..*Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),p=!a),p){p=new Promise(function(e,t){!function n(){(new Date).getTime()-f>=d?t():document.fonts.load(h(s,'"'+s.family+'"'),l).then(function(t){1<=t.length?e():setTimeout(n,25)},function(){t()})}()});var g=new Promise(function(e,t){c=setTimeout(t,d)});Promise.race([g,p]).then(function(){clearTimeout(c),e(s)},function(){r(s)})}else!function(e){document.body?e():document.addEventListener?document.addEventListener("DOMContentLoaded",function t(){document.removeEventListener("DOMContentLoaded",t),e()}):document.attachEvent("onreadystatechange",function t(){"interactive"!=document.readyState&&"complete"!=document.readyState||(document.detachEvent("onreadystatechange",t),e())})}(function(){function a(){var t;(t=-1!=m&&-1!=_||-1!=m&&-1!=y||-1!=_&&-1!=y)&&((t=m!=_&&m!=y&&_!=y)||(null===o&&(t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),o=!!t&&(536>parseInt(t[1],10)||536===parseInt(t[1],10)&&11>=parseInt(t[2],10))),t=o&&(m==v&&_==v&&y==v||m==b&&_==b&&y==b||m==x&&_==x&&y==x)),t=!t),t&&(w.parentNode&&w.parentNode.removeChild(w),clearTimeout(c),e(s))}var u=new t(l),p=new t(l),g=new t(l),m=-1,_=-1,y=-1,v=-1,b=-1,x=-1,w=document.createElement("div");w.dir="ltr",n(u,h(s,"sans-serif")),n(p,h(s,"serif")),n(g,h(s,"monospace")),w.appendChild(u.a),w.appendChild(p.a),w.appendChild(g.a),document.body.appendChild(w),v=u.a.offsetWidth,b=p.a.offsetWidth,x=g.a.offsetWidth,function e(){if((new Date).getTime()-f>=d)w.parentNode&&w.parentNode.removeChild(w),r(s);else{var t=document.hidden;!0!==t&&void 0!==t||(m=u.a.offsetWidth,_=p.a.offsetWidth,y=g.a.offsetWidth,a()),c=setTimeout(e,50)}}(),i(u,function(e){m=e,a()}),n(u,h(s,'"'+s.family+'",sans-serif')),i(p,function(e){_=e,a()}),n(p,h(s,'"'+s.family+'",serif')),i(g,function(e){y=e,a()}),n(g,h(s,'"'+s.family+'",monospace'))})})},en.exports=s}()),tn.exports));const rn={fonts_loaded:Promise.resolve(),last_loaded:null,loadFonts(e){const t=JSON.stringify(e)===this.last_loaded;if(e&&!t){const t=[];for(const n in e)Array.isArray(e[n])?e[n].forEach(e=>t.push(this.loadFontFace(n,e))):t.push(this.loadFontFace(n,e[n]));this.last_loaded=JSON.stringify(e),this.fonts_loaded=Promise.all(t.filter(e=>e))}return this.fonts_loaded},async loadFontFace(e,t){if(null==t||"object"!=typeof t&&"external"!==t)return;const n={family:e};"object"==typeof t&&(Object.assign(n,t),"string"==typeof t.url&&await this.injectFontFace(n));try{n.weight="string"==typeof n.weight?n.weight.split(" ")[0]:n.weight;const t=new nn(e,n);await t.load(),m("debug",`Font face '${e}' is available`,n)}catch(t){m("warn",`Font face '${e}' is NOT available`,n,t)}},async injectFontFace({family:e,url:t,weight:n,style:r}){void 0===this.supports_native_font_loading&&(this.supports_native_font_loading=void 0!==window.FontFace);let i=t;if("blob:"===t.slice(0,5)){i=(await _.io(t,6e4,"arraybuffer")).body;let e=new Uint8Array(i);if(this.supports_native_font_loading)i=e;else{let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i="data:font/opentype;base64,"+btoa(t)}}if(this.supports_native_font_loading){let t;"string"==typeof i?t=new FontFace(e,`url(${encodeURI(i)})`,{weight:n,style:r}):i instanceof Uint8Array&&(t=new FontFace(e,i,{weight:n,style:r})),document.fonts.add(t),m("trace","Adding FontFace to document.fonts:",t)}else{let t=`\n @font-face {\n font-family: '${e}';\n font-weight: ${n||"normal"};\n font-style: ${r||"normal"};\n src: url(${encodeURI(i)});\n }`,s=document.createElement("style");s.appendChild(document.createTextNode("")),document.head.appendChild(s),s.sheet.insertRule(t,0),m("trace","Injecting CSS font face:",t)}}},sn=new RegExp("[֑-߿יִ-﷽ﹰ-ﻼ]");function on(e){return sn.test(e)}const an="\0-/:-@[-`{-¿×÷ʹ-˿ -⯿‐-\u2029 -⯿",ln=new RegExp("["+an+"]+");function un(e){return ln.test(e)}const cn=new RegExp("^["+an+"-ۿ]+"),hn=new RegExp("["+an+"آ-إاد-زوٱ-ٷڈ-ڙۄ-ۋۏےۓۮۯ]"),dn=new RegExp("^[ؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ۭ]+"),fn="[̀-֑ͯ-ׇֽֿׁׂׅׄަ-ްऀ-ःऺ-ौॎॏ॑-ॗॢॣঁ-ঃ়া-ৌৗৢৣਁ-ਃ਼-ੌੑઁ-ઃ઼ા-ૌૢૣଁ-ଃ଼ା-ୌୖୗୢୣஂா-்ௗఀ-ఃా-ౌౕౖౢౣಁ-ಃ಼ಾ-ೌೕೖೢೣഁ-ഃാ-ൌൎൗൢൣංඃ්-ෟෲෳัิ-ฺ็-๎ັິ-ຼ່-ໍ༹༘༙༵༷༾༿ཱ-ྃ྆྇ྍ-ྼ࿆ါ-း်-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ឴-៑៓ᩕ-ᩞᩡ-᩼᷀-᷿⃐-]",pn=new RegExp(`^.(?:${fn}+)?([्্੍્୍్್്྄္្᩠᩿]\\W(?:${fn}+)?)*`),gn={Mongolian:"᠀-"},mn=Object.keys(gn).map(e=>gn[e]).join(""),_n=new RegExp("["+mn+"]");function yn(e,t,n){const r=t?1:2;if(e.length<r)return[e];let i=e;if(n.segment[i])return n.stats.segment_hits++,n.segment[i];let s=[];if(cn.exec(e)){s=e.split(hn);let t=-1;for(var o=0;o<s.length-1;o++){if(o>0){let e=dn.exec(s[o]);e&&(s[o]=s[o].substring(e[0].length),s[o-1]+=e[0],t+=e[0].length)}t+=1+s[o].length,s[o]+=e.slice(t,t+1)}e=""}for(;e.length;){let t="",n=e,i=0;for(;i<r&&n.length;i++){let e=(pn.exec(n)||n)[0];t+=e,n=n.substring(e.length)}s.push(t),e=e.substring(t.length)}return t&&s.reverse(),n.stats.segment_misses++,n.segment[i]=s,s}class vn{constructor(e,t=1/0,n=1/0){this.width=0,this.height=0,this.lines=[],this.max_lines=t,this.text_wrap=n,this.context=e}createLine(e){return this.lines.length<this.max_lines&&new bn(e,this.text_wrap)}push(e){if(this.lines.length<this.max_lines){let t=this.context.measureText(e.text).width;return e.width=t,t>this.width&&(this.width=Math.ceil(t)),this.lines.push(e),this.height+=e.height,!0}return this.addEllipsis(),!1}advance(e,t){return!!this.push(e)&&this.createLine(t)}addEllipsis(){let e=this.lines[this.lines.length-1],t=Math.ceil(this.context.measureText(vn.ellipsis).width);e.append(vn.ellipsis),e.width+=t,e.width>this.width&&(this.width=e.width)}finish(e){e?this.push(e):this.addEllipsis()}static parse(e,t,n,r,i){let s;s="number"==typeof t?e.split(" "):[e];let o=new vn(i,n,t),a=o.createLine(r);for(let e=0;e<s.length;e++){let n=s[e].split("\n"),i=0===e;for(let s=0;s<n.length&&a;s++){let l=n[s];on(l)&&un(l[l.length-1])&&(l+="");let u=i?l:" "+l;if(t&&e>0&&a.exceedsTextwrap(u)){if(a=o.advance(a,r),!a)break;a.append(l),i=!0}else a.append(u);s<n.length-1&&(a=o.advance(a,r),i=!0)}e===s.length-1&&o.finish(a)}return o}}vn.ellipsis="...";class bn{constructor(e=0,t=0){this.chars=0,this.text="",this.height=Math.ceil(e),this.text_wrap=t}append(e){this.chars+=e.length,this.text+=e}exceedsTextwrap(e){return e.length+this.chars>this.text_wrap}}function xn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xn(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}class An{constructor(){this.createCanvas(),this.vertical_text_buffer=8,this.horizontal_text_buffer=4,this.background_size=4}createCanvas(){this.canvas=document.createElement("canvas"),this.canvas.style.backgroundColor="transparent",this.context=this.canvas.getContext("2d")}resize(e,t){this.canvas.width=e,this.canvas.height=t,this.context.clearRect(0,0,e,t)}setFont({font_css:e,fill:t,stroke:n,stroke_width:r,px_size:i,supersample:s}){this.px_size=i;let o=this.context,a=_.device_pixel_ratio*s;n&&r>0&&(o.strokeStyle=n,o.lineWidth=r*a),o.fillStyle=t,o.font=e,o.miterLimit=2}async textSizes(e,t){return await rn.loadFonts(),E.add({type:"textSizes",run:this.processTextSizesTask.bind(this),texts:t,tile_id:e,cursor:{styles:Object.keys(t),texts:null,style_idx:null,text_idx:null}})}processTextSizesTask(e){let{cursor:t,texts:n}=e;for(t.style_idx=t.style_idx||0;t.style_idx<t.styles.length;){let i=t.styles[t.style_idx];null==t.text_idx&&(t.text_idx=0,t.texts=Object.keys(n[i]));let s=n[i],o=!0;for(;t.text_idx<t.texts.length;){let n=t.texts[t.text_idx],a=s[n],l=a.text_settings;if(o&&(this.setFont(l),o=!1),a.size=this.textSize(i,n,l).size,l.can_articulate){let e=!1,t=!1;if(on(n)&&(un(n)?e=!0:t=!0),a.isRTL=e,a.no_curving=t||(r=n,_n.test(r)),a.vertical_buffer=this.vertical_text_buffer,a.segment_sizes=[],!a.no_curving){let t=yn(n,e,An.cache);a.segments=t;for(let e=0;e<t.length;e++)a.segment_sizes.push(this.textSize(i,t[e],l).size)}}if(t.text_idx++,!E.shouldContinue(e))return!1}t.text_idx=null,t.style_idx++}var r;return E.finish(e,n),!0}textSize(e,t,{transform:n,text_wrap:r,max_lines:i,stroke_width:s=0,background_color:o,background_stroke_width:a=0,background_width:l,underline_width:u=0,supersample:c}){if(An.cache.text[e]=An.cache.text[e]||{},An.cache.text[e][t])return An.cache.stats.text_hits++,An.cache.text[e][t];An.cache.stats.text_misses++,An.cache.text_count++;const h=_.device_pixel_ratio*c,d=this.applyTextTransform(t,n),f=this.context,p=this.vertical_text_buffer*h,g=(s+this.horizontal_text_buffer)*h;l=null!=l?l:this.background_size;const m=o||a?(l+a)*h:0,y=(2+u+(u?s+1:0))*h,v=this.px_size+y;let{width:b,height:x,lines:w}=vn.parse(d,r,i,v,f);b+=2*m,x+=2*m;let A=[b/h,x/h],E=[b+2*g,x+2*p],S=[E[0]/h,E[1]/h];return An.cache.text[e][t]={lines:w,size:{collision_size:A,texture_size:E,logical_size:S,horizontal_buffer:g,vertical_buffer:p,dpr:h,line_height:v,background_size:m}},An.cache.text[e][t]}drawTextMultiLine(e,[t,n],r,i,s){const{dpr:o,collision_size:a,texture_size:l,line_height:u,horizontal_buffer:c,vertical_buffer:h}=r;if(i.background_color||i.background_stroke_color){const e=i.background_stroke_color,r=(i.background_stroke_width||0)*o;this.context.save(),i.background_color&&(this.context.fillStyle=i.background_color,this.context.fillRect(t+c+("curved"===s?l[0]:0)+r,n+h+r,o*a[0]-2*r,o*a[1]-2*r)),e&&r&&(this.context.strokeStyle=e,this.context.lineWidth=r,this.context.strokeRect(t+c+("curved"===s?l[0]:0)+.5*r,n+h+.5*r,o*a[0]-r,o*a[1]-r)),this.context.restore()}const d=i.underline_width||0,f=i.stroke_width||0;let p=n-(d?.5*(d+f+1)*o:0);for(let n=0;n<e.length;n++){let o=e[n];this.drawTextLine(o,[t,p],r,i,s),p+=u}this.drawTextDebug([t,n],r,s)}drawTextLine(e,[t,n],r,i,s){const{stroke:o,stroke_width:a,transform:l,align:u="center"}=i,{horizontal_buffer:c,vertical_buffer:h,texture_size:d,background_size:f,line_height:p,dpr:g}=r,m=(i.underline_width||0)*g,_=this.applyTextTransform(e.text,l);let y;"left"===u?y=t+c+f:"center"===u?y=t+d[0]/2-e.width/2:"right"===u&&(y=t+d[0]-e.width-c-f);const v=n+.75*h+p+f-.5*m,b=o&&a>0&&"curved"===s?d[0]:0;if(m){this.context.save(),this.context.strokeStyle=this.context.fillStyle,this.context.lineWidth=m;const t=v+(.5*a+2)*g+.5*this.context.lineWidth;this.context.beginPath(),this.context.moveTo(y+b,t),this.context.lineTo(y+b+e.width,t),this.context.stroke(),this.context.restore()}o&&a>0&&this.context.strokeText(_,y+b,v),this.context.fillText(_,y,v)}drawTextDebug([e,t],n,r){const{dpr:i,horizontal_buffer:s,vertical_buffer:o,texture_size:a,collision_size:l}=n;v.draw_label_collision_boxes&&(this.context.save(),this.context.strokeStyle="blue",this.context.lineWidth=2,this.context.strokeRect(e+s,t+o,i*l[0],i*l[1]),"curved"===r&&this.context.strokeRect(e+a[0]+s,t+o,i*l[0],i*l[1]),this.context.restore()),v.draw_label_texture_boxes&&(this.context.save(),this.context.strokeStyle="green",this.context.lineWidth=2,this.context.strokeRect(e+2,t+2,a[0]-4,a[1]-4),"curved"===r&&this.context.strokeRect(e+2+a[0],t+2,a[0]-4,a[1]-4),this.context.restore())}rasterize(e,t,n,r,i){return E.add({type:"rasterizeLabels",run:this.processRasterizeTask.bind(this),cancel:this.cancelRasterizeTask.bind(this),pause_factor:2,user_moving_view:!1,texts:e,textures:t,texture_prefix:r,gl:i,tile_id:n,cursor:{styles:Object.keys(e),texts:null,style_idx:0,text_idx:null,texture_idx:0,texture_resize:!0,texture_names:[]}})}processRasterizeTask(e){let t,{cursor:n,texts:r,textures:i}=e;for(;n.texture_idx<e.textures.length;){for(t=i[n.texture_idx],n.texture_resize&&(n.texture_resize=!1,this.resize(...t.texture_size));n.style_idx<n.styles.length;){let i=n.styles[n.style_idx];null==n.text_idx&&(n.text_idx=0,n.texts=Object.keys(r[i]));let s=r[i],o=!0;for(;n.text_idx<n.texts.length;){let r=n.texts[n.text_idx],a=s[r],l=a.text_settings;if(o&&(this.setFont(l),o=!1),l.can_articulate){a.texcoords=a.texcoords||{};for(let e=0;e<a.type.length;e++){let s=a.type[e];if("straight"===s){if(a.textures[e]!==n.texture_idx)continue;let o,u=a.isRTL?r.split().reverse().join():r,c=t.texcoord_cache[i][u];if(c.texcoord)o=c.texcoord;else{let e=c.texture_position,{size:n,lines:r}=this.textSize(i,u,l);this.drawTextMultiLine(r,e,n,l,s),o=k.getTexcoordsForSprite(e,n.texture_size,t.texture_size),c.texcoord=o}a.texcoords[s]={texcoord:o,texture_id:c.texture_id}}else if("curved"===s){let r=a.segments;a.texcoords.curved=a.texcoords.curved||[],a.texcoords_stroke=a.texcoords_stroke||[];for(let o=0;o<r.length;o++){if(a.textures[e][o]!==n.texture_idx)continue;let u,c,h=r[o],d=t.texcoord_cache[i][h];if(d.texcoord)u=d.texcoord,c=d.texcoord_stroke,a.texcoords_stroke.push(c);else{let e=d.texture_position,{size:n,lines:r}=this.textSize(i,h,l);this.drawTextMultiLine(r,e,n,l,s),u=k.getTexcoordsForSprite(e,n.texture_size,t.texture_size);let o=[e[0]+n.texture_size[0],e[1]];c=k.getTexcoordsForSprite(o,n.texture_size,t.texture_size),d.texcoord=u,d.texcoord_stroke=c,a.texcoords_stroke.push(c)}a.texcoords.curved.push({texcoord:u,texture_id:d.texture_id})}}}}else{let e=this.textSize(i,r,l).lines;const s=wn({},l);for(let r in a.align)a.align[r].texture_id===n.texture_idx&&(s.align=r,this.drawTextMultiLine(e,a.align[r].texture_position,a.size,s),a.align[r].texcoords=k.getTexcoordsForSprite(a.align[r].texture_position,a.size.texture_size,t.texture_size))}if(n.text_idx++,!E.shouldContinue(e))return!1}n.text_idx=null,n.style_idx++}let s=e.texture_prefix+n.texture_idx;k.create(e.gl,s,{element:this.canvas,filtering:"linear",UNPACK_PREMULTIPLY_ALPHA_WEBGL:!0}),k.retain(s),n.texture_names.push(s),n.texture_idx++,n.texture_resize=!0,n.style_idx=0}return E.finish(e,n.texture_names),!0}cancelRasterizeTask(e){m("trace",`RasterizeTask: release textures [${e.cursor.texture_names.join(", ")}]`),e.cursor.texture_names.forEach(e=>k.release(e))}setTextureTextPositions(e,t){let n={cx:0,cy:0,width:0,height:0,column_width:0,texture_id:0,texcoord_cache:{}},r=[];for(let i in e){let s=e[i];for(let e in s){let o,a=s[e];if(a.text_settings.can_articulate){a.textures=[],n.texcoord_cache[i]=n.texcoord_cache[i]||{};for(let s=0;s<a.type.length;s++){let l=a.type[s];if("straight"===l){let l=a.isRTL?e.split().reverse().join():e;if(!n.texcoord_cache[i][l]){let e=a.size.texture_size;o=this.placeText(e[0],e[1],i,n,r,t),n.texcoord_cache[i][l]={texture_id:n.texture_id,texture_position:o}}a.textures[s]=n.texture_id}else if("curved"===l){a.textures[s]=[];for(let e=0;e<a.segment_sizes.length;e++){let l=a.segments[e];if(!n.texcoord_cache[i][l]){let s=a.segment_sizes[e].texture_size,u=2*s[0];o=this.placeText(u,s[1],i,n,r,t),n.texcoord_cache[i][l]={texture_id:n.texture_id,texture_position:o}}a.textures[s].push(n.texture_id)}}}}else{let e=a.size.texture_size;for(let s in a.align)o=this.placeText(e[0],e[1],i,n,r,t),a.align[s].texture_id=n.texture_id,a.align[s].texture_position=o}}}return n.column_width>0&&n.height>0&&(r[n.texture_id]={texture_size:[n.width,n.height],texcoord_cache:n.texcoord_cache}),r}placeText(e,t,n,r,i,s){let o;return r.cy+t>s?(r.cx+=r.column_width,r.cy=0,r.column_width=e):r.column_width=Math.max(r.column_width,e),r.cx+r.column_width<=s?(o=[r.cx,r.cy],r.cy+=t,r.height=Math.max(r.height,r.cy),r.width=Math.max(r.width,r.cx+r.column_width)):(i[r.texture_id]={texture_size:[r.width,r.height],texcoord_cache:r.texcoord_cache},r.texcoord_cache={},r.texcoord_cache[n]={},r.texture_id++,r.cx=0,r.cy=t,r.column_width=e,r.width=e,r.height=t,o=[0,0]),o}applyTextTransform(e,t){return"capitalize"===t?e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1)}):"uppercase"===t?e.toUpperCase():"lowercase"===t?e.toLowerCase():e}static fontPixelSize(e){if(null==e)return;e="string"==typeof e?e:String(e);let[,t,n]=e.match(An.font_size_re)||[];return n=n||"px","em"===n?t*=16:"pt"===n?t/=.75:"%"===n&&(t/=6.25),t=J.parsePositiveNumber(t),t*=_.device_pixel_ratio,t}static pruneTextCache(){An.cache.text_count>An.cache.text_count_max&&(An.cache.text={},An.cache.text_count=0,m("debug","TextCanvas: pruning text cache")),Object.keys(An.cache.segment).length>An.cache.segment_count_max&&(An.cache.segment={},m("debug","TextCanvas: pruning segment cache"))}}function En(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}An.font_size_re=/((?:[0-9]*\.)?[0-9]+)\s*(px|pt|em|%)?/,An.cache={text:{},text_count:0,text_count_max:2e3,segment:{},segment_count_max:2e3,stats:{text_hits:0,text_misses:0,segment_hits:0,segment_misses:0}};let Sn=0;const Tn={resetText(){t.is_main?this.canvas=new An:t.is_worker&&(this.texts={})},freeText(e){delete this.texts[e.id]},parseTextFeature(e,t,n,r){let i=this.parseTextSource(e,t,n);if(null==i||""===i)return;let s=Qt.compute(t,n),o=Qt.key(s);this.texts[r.id]=this.texts[r.id]||{};let a=this.texts[r.id][o]=this.texts[r.id][o]||{};if(i instanceof Object){let l=[],u=i.left+"-"+i.right;for(let c in i){let h=i[c];if(!h)continue;let d=this.computeTextLayout({},e,t,n,r,h,s,u,c);a[h]||(a[h]={text_settings:s,ref:0}),l.push({draw:t,text:h,text_settings_key:o,layout:d})}return l.length>0&&l}{let l=this.computeTextLayout({},e,t,n,r,i,s);return a[i]||(a[i]={text_settings:s,ref:0}),{draw:t,text:i,text_settings_key:o,layout:l}}},parseTextSource(e,t,n){let r,i=t.text_source||"name";if(null==i||Array.isArray(i)||"object"!=typeof i)r=this.parseTextSourceValue(i,e,n);else{r={};for(let t in i)r[t]=this.parseTextSourceValue(i[t],e,n)}return r},parseTextSourceValue(e,t,n){let r;if(Array.isArray(e)){for(let i=0;i<e.length;i++)if("string"==typeof e[i]?r=t.properties[e[i]]:"function"==typeof e[i]&&(r=e[i](n)),r)return r}else"string"==typeof e?r=t.properties[e]:e instanceof Function&&(r=e(n));return r},async prepareTextLabels(e,t){if(0===Object.keys(this.texts[e.id]||{}).length)return[];try{const n=await a.postMessage(this.main_thread_target+".calcTextSizes",e.id,this.texts[e.id]);return e.canceled?(m("trace",`Style ${this.name}: stop tile build because tile was canceled: ${e.key}, post-calcTextSizes()`),[]):(this.texts[e.id]=n||[],n?this.buildTextLabels(e,t):($t.abortTile(e.id),[]))}catch(t){return $t.abortTile(e.id),[]}},async collideAndRenderTextLabels(e,t,n){let r=await this.prepareTextLabels(e,n);if(0===r.length)return $t.collide([],t,e.id),{};if(r=await $t.collide(r,t,e.id),e.canceled)return m("trace",`stop tile build because tile was canceled: ${e.key}, post-collide()`),{};let s=this.texts[e.id];if(null==s||0===r.length)return{};this.cullTextStyles(s,r),r.forEach(e=>{let t=e.text_settings_key,n=s[t]&&s[t][e.text];n.text_settings.can_articulate?(n.type||(n.type=[]),-1===n.type.indexOf(e.label.type)&&n.type.push(e.label.type)):(n.align=n.align||{},n.align[e.label.align]={})});try{const t=await a.postMessage(this.main_thread_target+".rasterizeTexts",e.id,e.key,s);return e.canceled?(m("trace",`stop tile build because tile was canceled: ${e.key}, post-rasterizeTexts()`),{}):function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?En(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):En(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({labels:r},t)}catch(e){return{}}},cullTextStyles(e,t){for(let n=0;n<t.length;n++){let r=t[n];e[r.text_settings_key][r.text].ref++}for(let t in e)for(let n in e[t])e[t][n].ref<1&&delete e[t][n];for(let t in e)0===Object.keys(e[t]).length&&delete e[t]},calcTextSizes(e,t){return this.canvas.textSizes(e,t)},async rasterizeTexts(e,t,n){let r=new An,i=Math.min(this.max_texture_size,2048),s=r.setTextureTextPositions(n,i),o=["labels",this.name,t,e,Sn,""].join("-");return Sn++,s=await r.rasterize(n,s,e,o,this.gl),s?{texts:n,textures:s}:{}},preprocessText(e){if(e&&e.font&&"object"==typeof e.font)return e.font.weight=J.createPropertyCache(e.font.weight),e.font.fill=J.createPropertyCache(e.font.fill||Qt.defaults.fill),e.font.alpha=J.createPropertyCache(e.font.alpha),e.font.stroke&&(e.font.stroke.color=J.createPropertyCache(e.font.stroke.color),e.font.stroke.alpha=J.createPropertyCache(e.font.stroke.alpha)),e.font.background&&(e.font.background.color=J.createPropertyCache(e.font.background.color),e.font.background.alpha=J.createPropertyCache(e.font.background.alpha),e.font.background.width=J.createPropertyCache(e.font.background.width,J.parsePositiveNumber),e.font.background.stroke&&(e.font.background.stroke.color=J.createPropertyCache(e.font.background.stroke.color),e.font.background.stroke.alpha=J.createPropertyCache(e.font.background.stroke.alpha))),e.font.px_size=J.createPropertyCache(e.font.size||Qt.defaults.size,An.fontPixelSize,An.fontPixelSize),e.font.stroke&&null!=e.font.stroke.width&&(e.font.stroke.width=J.createPropertyCache(e.font.stroke.width,J.parsePositiveNumber)),e.font.background&&e.font.background.stroke&&null!=e.font.background.stroke.width&&(e.font.background.stroke.width=J.createPropertyCache(e.font.background.stroke.width,J.parsePositiveNumber)),e.offset=J.createPropertyCache(e.offset,e=>Array.isArray(e)&&e.map(J.parseNumber)),e.buffer=J.createPropertyCache(e.buffer,e=>(Array.isArray(e)?e:[e,e]).map(J.parsePositiveNumber)),e.repeat_distance=J.createPropertyCache(e.repeat_distance,J.parsePositiveNumber),e},computeTextLayout(e,t,n,r,i,s,o,a,l){let u=e||{};return u=this.computeLayout(u,t,n,r,i),null==n.repeat_distance&&(u.repeat_distance="point"===r.geometry?0:G.tile_size,u.repeat_distance&&(u.repeat_distance*=u.units_per_pixel,u.repeat_scale=1,"function"==typeof n.repeat_group?u.repeat_group=n.repeat_group(r):u.repeat_group=n.repeat_group)),u.repeat_distance&&(a&&(u.repeat_group+="/"+a),u.repeat_group+="/"+s),u.subdiv=i.overzoom2,u.align=n.align,u.italic="normal"!==o.style,"right"===l?u.orientation=1:"left"===l&&(u.orientation=-1),u}};var kn,On,Rn,Cn,Pn,Mn,Nn,In,Dn,Fn,zn,Ln,jn,Vn,Un,Bn,Gn=M(On?kn:(On=1,kn=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],m=t[14],_=t[15],y=n*a-r*o,v=n*l-i*o,b=n*u-s*o,x=r*l-i*a,w=r*u-s*a,A=i*u-s*l,E=c*g-h*p,S=c*m-d*p,T=c*_-f*p,k=h*m-d*g,O=h*_-f*g,R=d*_-f*m,C=y*R-v*O+b*k+x*T-w*S+A*E;return C?(C=1/C,e[0]=(a*R-l*O+u*k)*C,e[1]=(l*T-o*R-u*S)*C,e[2]=(o*O-a*T+u*E)*C,e[3]=(i*O-r*R-s*k)*C,e[4]=(n*R-i*T+s*S)*C,e[5]=(r*T-n*O-s*E)*C,e[6]=(g*A-m*w+_*x)*C,e[7]=(m*b-p*A-_*v)*C,e[8]=(p*w-g*b+_*y)*C,e):null})),$n=M(Cn?Rn:(Cn=1,Rn=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=c*o-a*u,d=-c*s+a*l,f=u*s-o*l,p=n*h+r*d+i*f;return p?(p=1/p,e[0]=h*p,e[1]=(-c*r+i*u)*p,e[2]=(a*r-i*o)*p,e[3]=d*p,e[4]=(c*n-i*l)*p,e[5]=(-a*n+i*s)*p,e[6]=f*p,e[7]=(-u*n+r*l)*p,e[8]=(o*n-r*s)*p,e):null})),qn=M(Mn?Pn:(Mn=1,Pn=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],g=t[12],m=t[13],_=t[14],y=t[15],v=n[0],b=n[1],x=n[2],w=n[3];return e[0]=v*r+b*a+x*h+w*g,e[1]=v*i+b*l+x*d+w*m,e[2]=v*s+b*u+x*f+w*_,e[3]=v*o+b*c+x*p+w*y,v=n[4],b=n[5],x=n[6],w=n[7],e[4]=v*r+b*a+x*h+w*g,e[5]=v*i+b*l+x*d+w*m,e[6]=v*s+b*u+x*f+w*_,e[7]=v*o+b*c+x*p+w*y,v=n[8],b=n[9],x=n[10],w=n[11],e[8]=v*r+b*a+x*h+w*g,e[9]=v*i+b*l+x*d+w*m,e[10]=v*s+b*u+x*f+w*_,e[11]=v*o+b*c+x*p+w*y,v=n[12],b=n[13],x=n[14],w=n[15],e[12]=v*r+b*a+x*h+w*g,e[13]=v*i+b*l+x*d+w*m,e[14]=v*s+b*u+x*f+w*_,e[15]=v*o+b*c+x*p+w*y,e})),Hn=M(In?Nn:(In=1,Nn=function(e,t,n){var r,i,s,o,a,l,u,c,h,d,f,p,g=n[0],m=n[1],_=n[2];return t===e?(e[12]=t[0]*g+t[4]*m+t[8]*_+t[12],e[13]=t[1]*g+t[5]*m+t[9]*_+t[13],e[14]=t[2]*g+t[6]*m+t[10]*_+t[14],e[15]=t[3]*g+t[7]*m+t[11]*_+t[15]):(r=t[0],i=t[1],s=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],e[0]=r,e[1]=i,e[2]=s,e[3]=o,e[4]=a,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=f,e[11]=p,e[12]=r*g+a*m+h*_+t[12],e[13]=i*g+l*m+d*_+t[13],e[14]=s*g+u*m+f*_+t[14],e[15]=o*g+c*m+p*_+t[15]),e})),Wn=M(Fn?Dn:(Fn=1,Dn=function(e,t,n){var r=n[0],i=n[1],s=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e})),Zn=M(Ln?zn:(Ln=1,zn=function(e,t,n,r,i){var s=1/Math.tan(t/2),o=1/(r-i);return e[0]=s/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+r)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*r*o,e[15]=0,e}));function Kn(){return Vn?jn:(Vn=1,jn=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e})}var Xn,Yn,Qn=function(){if(Bn)return Un;Bn=1;var e=Kn();return Un=function(t,n,r,i){var s,o,a,l,u,c,h,d,f,p,g=n[0],m=n[1],_=n[2],y=i[0],v=i[1],b=i[2],x=r[0],w=r[1],A=r[2];return Math.abs(g-x)<1e-6&&Math.abs(m-w)<1e-6&&Math.abs(_-A)<1e-6?e(t):(h=g-x,d=m-w,f=_-A,s=v*(f*=p=1/Math.sqrt(h*h+d*d+f*f))-b*(d*=p),o=b*(h*=p)-y*f,a=y*d-v*h,(p=Math.sqrt(s*s+o*o+a*a))?(s*=p=1/p,o*=p,a*=p):(s=0,o=0,a=0),l=d*a-f*o,u=f*s-h*a,c=h*o-d*s,(p=Math.sqrt(l*l+u*u+c*c))?(l*=p=1/p,u*=p,c*=p):(l=0,u=0,c=0),t[0]=s,t[1]=l,t[2]=h,t[3]=0,t[4]=o,t[5]=u,t[6]=d,t[7]=0,t[8]=a,t[9]=c,t[10]=f,t[11]=0,t[12]=-(s*g+o*m+a*_),t[13]=-(l*g+u*m+c*_),t[14]=-(h*g+d*m+f*_),t[15]=1,t)}}(),Jn=M(Qn),er=M(Kn()),tr=M(Yn?Xn:(Yn=1,Xn=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}));const nr={fromValues(e,t,n){var r=new Float64Array(3);return r[0]=e,r[1]=t,r[2]=n,r}},rr={normalFromMat4:Gn,invert:$n},ir={multiply:qn,translate:Hn,scale:Wn,perspective:Zn,lookAt:Jn,identity:er,copy:tr};class sr{constructor(e,t,n={}){this.view=t,this.position=n.position,this.zoom=n.zoom}static create(e,t,n){switch(n.type){case"isometric":return new ar(e,t,n);case"flat":return new lr(e,t,n);default:return new or(e,t,n)}}update(){}setupProgram(){}updateView(){if(this.position||this.zoom){var e={};this.position&&(e={lng:this.position[0],lat:this.position[1],zoom:this.position[2]}),this.zoom&&(e.zoom=this.zoom),this.view.setView(e)}}setupMatrices(e,t){ir.multiply(e.model_view32,this.view_matrix,e.model),t.uniform("Matrix4fv","u_modelView",e.model_view32),rr.normalFromMat4(e.normal32,e.model_view32),rr.invert(e.inverse_normal32,e.normal32),t.uniform("Matrix3fv","u_normalMatrix",e.normal32),t.uniform("Matrix3fv","u_inverseNormalMatrix",e.inverse_normal32)}}class or extends sr{constructor(e,t,n={}){super(e,t,n),this.type="perspective",this.focal_length=n.focal_length,this.fov=n.fov,this.focal_length||this.fov||(this.focal_length=[[16,2],[17,2.5],[18,3],[19,4],[20,6]]),this.vanishing_point=n.vanishing_point||[0,0],this.vanishing_point=this.vanishing_point.map(parseFloat),this.vanishing_point_skew=[],this.position_meters=null,this.view_matrix=new Float64Array(16),this.projection_matrix=new Float32Array(16),j.replaceBlock("camera","\n uniform mat4 u_projection;\n uniform vec3 u_eye;\n uniform vec2 u_vanishing_point;\n\n void cameraProjection (inout vec4 position) {\n position = u_projection * position;\n }")}constrainCamera({view_height:e,height:t,focal_length:n,fov:r}){return t?(n=2*t/e,r=2*Math.atan(1/n)):(n?r=2*Math.atan(1/n):r&&(r=r*Math.PI/180,n=1/Math.tan(r/2)),t=e/2*n),{view_height:e,height:t,focal_length:n,fov:r}}updateMatrices(){var e=this.view.size.css.height*this.view.meters_per_pixel,{height:t,fov:n}=this.constrainCamera({view_height:e,focal_length:_.interpolate(this.view.zoom,this.focal_length),fov:_.interpolate(this.view.zoom,this.fov)}),r=[this.view.center.meters.x,this.view.center.meters.y,t];this.position_meters=r,ir.lookAt(this.view_matrix,nr.fromValues(r[0],r[1],0),nr.fromValues(r[0],r[1],-1),nr.fromValues(0,1,0)),ir.perspective(this.projection_matrix,n,this.view.aspect,1,2*t),this.vanishing_point_skew[0]=this.vanishing_point[0]/this.view.size.css.width,this.vanishing_point_skew[1]=this.vanishing_point[1]/this.view.size.css.height,this.projection_matrix[8]=2*-this.vanishing_point_skew[0],this.projection_matrix[9]=2*-this.vanishing_point_skew[1],ir.translate(this.projection_matrix,this.projection_matrix,nr.fromValues(e/2*this.view.aspect*(2*-this.vanishing_point_skew[0]),e/2*(2*-this.vanishing_point_skew[1]),0)),ir.translate(this.projection_matrix,this.projection_matrix,nr.fromValues(0,0,-t))}update(){super.update(),this.updateMatrices()}setupProgram(e){e.uniform("Matrix4fv","u_projection",this.projection_matrix),e.uniform("3f","u_eye",[0,0,this.position_meters[2]]),e.uniform("2fv","u_vanishing_point",this.vanishing_point_skew)}}class ar extends sr{constructor(e,t,n={}){super(e,t,n),this.type="isometric",this.axis=n.axis||{x:0,y:1},2===this.axis.length&&(this.axis={x:this.axis[0],y:this.axis[1]}),this.position_meters=null,this.viewport_height=null,this.view_matrix=new Float64Array(16),this.projection_matrix=new Float32Array(16),j.replaceBlock("camera","\n uniform mat4 u_projection;\n uniform vec3 u_eye;\n uniform vec2 u_vanishing_point;\n\n void cameraProjection (inout vec4 position) {\n position = u_projection * position;\n // position.xy += position.z * u_isometric_axis;\n\n // Reverse z for depth buffer so up is negative,\n // and scale down values so objects higher than one screen height will not get clipped\n // pull forward slightly to avoid going past far clipping plane\n position.z = -position.z / 100. + 1. - 0.001;\n }")}update(){super.update(),this.viewport_height=this.view.size.css.height*this.view.meters_per_pixel;var e=[this.view.center.meters.x,this.view.center.meters.y,this.viewport_height];this.position_meters=e,ir.identity(this.view_matrix),ir.translate(this.view_matrix,this.view_matrix,nr.fromValues(-e[0],-e[1],0)),ir.identity(this.projection_matrix),this.projection_matrix[8]=this.axis.x/this.view.aspect,this.projection_matrix[9]=this.axis.y,ir.scale(this.projection_matrix,this.projection_matrix,nr.fromValues(2/this.view.size.meters.x,2/this.view.size.meters.y,2/this.view.size.meters.y))}setupProgram(e){e.uniform("Matrix4fv","u_projection",this.projection_matrix),e.uniform("3fv","u_eye",[0,0,this.viewport_height]),e.uniform("2fv","u_vanishing_point",[0,0])}}class lr extends ar{constructor(e,t,n={}){super(e,t,n),this.type="flat"}update(){this.axis.x=0,this.axis.y=0,super.update()}}const ur=qt.PLACEMENT,cr=Object.create(Pe),hr="__shader_point";Object.assign(cr,Tn),Object.assign(cr,{name:"points",built_in:!0,vertex_shader_src:"uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_tile_proxy_order_offset;\nuniform bool u_tile_fade_in;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\nuniform float u_visible_time;\nuniform bool u_view_panning;\nuniform float u_view_pan_snap_timer;\n\nuniform mat4 u_model;\nuniform mat4 u_modelView;\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nattribute vec4 a_position;\nattribute vec4 a_shape;\nattribute vec4 a_color;\nattribute vec2 a_texcoord;\nattribute vec2 a_offset;\n\nuniform float u_point_type;\n\n#ifdef TANGRAM_CURVED_LABEL\n attribute vec4 a_offsets;\n attribute vec4 a_pre_angles;\n attribute vec4 a_angles;\n#endif\n\nvarying vec4 v_color;\nvarying vec2 v_texcoord;\nvarying vec4 v_world_position;\nvarying float v_alpha_factor;\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n attribute float a_outline_edge;\n attribute vec4 a_outline_color;\n\n varying float v_outline_edge;\n varying vec4 v_outline_color;\n varying float v_aa_offset;\n#endif\n\n#ifdef TANGRAM_SHOW_HIDDEN_LABELS\n varying float v_label_hidden;\n#endif\n\n#define TANGRAM_PI 3.14159265359\n#define TANGRAM_NORMAL vec3(0., 0., 1.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvec2 rotate2D(vec2 _st, float _angle) {\n return mat2(cos(_angle),-sin(_angle),\n sin(_angle),cos(_angle)) * _st;\n}\n\n#ifdef TANGRAM_CURVED_LABEL\n // Assumes stops are [0, 0.33, 0.66, 0.99];\n float mix4linear(vec4 v, float x) {\n x = clamp(x, 0., 1.);\n return mix(mix(v[0], v[1], 3. * x),\n mix(v[1],\n mix(v[2], v[3], 3. * (max(x, .66) - .66)),\n 3. * (clamp(x, .33, .66) - .33)),\n step(0.33, x)\n );\n }\n#endif\n\nvoid main() {\n // Initialize globals\n #pragma tangram: setup\n\n // discard hidden labels by collapsing into degenerate triangle\n #ifndef TANGRAM_SHOW_HIDDEN_LABELS\n if (a_shape.w == 0.) {\n gl_Position = vec4(0., 0., 0., 1.);\n return;\n }\n #else\n // highlight hidden label in fragment shader for debugging\n if (a_shape.w == 0.) {\n v_label_hidden = 1.; // label debug testing\n }\n else {\n v_label_hidden = 0.;\n }\n #endif\n\n v_alpha_factor = 1.0;\n v_color = a_color;\n v_texcoord = a_texcoord; // UV from vertex attribute\n\n #ifdef TANGRAM_HAS_SHADER_POINTS\n v_outline_color = a_outline_color;\n v_outline_edge = a_outline_edge;\n\n if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n // use point dimensions for UVs instead (ignore attribute), add antialiasing info for fragment shader\n float _size = abs(a_shape.x / 128.); // radius in pixels\n v_texcoord = sign(a_shape.xy) * (_size + 1.) / _size;\n _size += 2.;\n v_aa_offset = 2. / _size;\n }\n #endif\n\n // Position\n vec4 position = u_modelView * vec4(a_position.xyz, 1.);\n\n // Apply positioning and scaling in screen space\n vec2 _shape = a_shape.xy / 256.; // values have an 8-bit fraction\n vec2 _offset = vec2(a_offset.x, -a_offset.y); // flip y to make it point down\n float _theta = a_shape.z / 4096.;\n\n #ifdef TANGRAM_CURVED_LABEL\n //TODO: potential bug? null is passed in for non-curved labels, otherwise the first offset will be 0\n if (a_offsets[0] != 0.){\n vec4 _angles_scaled = (TANGRAM_PI / 16384.) * a_angles;\n vec4 _pre_angles_scaled = (TANGRAM_PI / 128.) * a_pre_angles;\n vec4 _offsets_scaled = (1. / 64.) * a_offsets;\n\n float _zoom = clamp(u_map_position.z - u_tile_origin.z, 0., 1.); //fract(u_map_position.z);\n float _pre_angle = mix4linear(_pre_angles_scaled, _zoom);\n float _angle = mix4linear(_angles_scaled, _zoom);\n float _offset_curve = mix4linear(_offsets_scaled, _zoom);\n\n _shape = rotate2D(_shape, _pre_angle); // rotate in place\n _shape.x += _offset_curve; // offset for curved label segment\n _shape = rotate2D(_shape, _angle); // rotate relative to curved label anchor\n _shape += rotate2D(_offset, _theta); // offset if specified in the scene file\n }\n else {\n _shape = rotate2D(_shape + _offset, _theta);\n }\n #else\n _shape = rotate2D(_shape + _offset, _theta);\n #endif\n\n // Fade in (if requested) based on time mesh has been visible.\n // Value passed to fragment shader in the v_alpha_factor varying\n #ifdef TANGRAM_FADE_IN_RATE\n if (u_tile_fade_in) {\n v_alpha_factor *= clamp(u_visible_time * TANGRAM_FADE_IN_RATE, 0., 1.);\n }\n #endif\n\n // World coordinates for 3d procedural textures\n v_world_position = u_model * position;\n v_world_position.xy += _shape * u_meters_per_pixel;\n v_world_position = wrapWorldPosition(v_world_position);\n\n // Modify position before camera projection\n #pragma tangram: position\n\n cameraProjection(position);\n\n #ifdef TANGRAM_LAYER_ORDER\n // +1 is to keep all layers including proxies > 0\n applyLayerOrder(a_position.w + u_tile_proxy_order_offset + 1., position);\n #endif\n\n // Apply pixel offset in screen-space\n // Multiply by 2 is because screen is 2 units wide Normalized Device Coords (and u_resolution device pixels wide)\n // Device pixel ratio adjustment is because shape is in logical pixels\n position.xy += _shape * position.w * 2. * u_device_pixel_ratio / u_resolution;\n #ifdef TANGRAM_HAS_SHADER_POINTS\n if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n // enlarge by 1px to catch missed MSAA fragments\n position.xy += sign(_shape) * position.w * u_device_pixel_ratio / u_resolution;\n }\n #endif\n\n // Snap to pixel grid\n // Only applied to fully upright sprites/labels (not shader-drawn points), while panning is not active\n #ifdef TANGRAM_HAS_SHADER_POINTS\n if (!u_view_panning && (abs(_theta) < TANGRAM_EPSILON) && u_point_type != TANGRAM_POINT_TYPE_SHADER) {\n #else\n if (!u_view_panning && (abs(_theta) < TANGRAM_EPSILON)) {\n #endif\n vec2 _position_fract = fract((((position.xy / position.w) + 1.) * .5) * u_resolution);\n vec2 _position_snap = position.xy + ((step(0.5, _position_fract) - _position_fract) * position.w * 2. / u_resolution);\n\n // Animate the snapping to smooth the transition and make it less noticeable\n #ifdef TANGRAM_VIEW_PAN_SNAP_RATE\n position.xy = mix(position.xy, _position_snap, clamp(u_view_pan_snap_timer * TANGRAM_VIEW_PAN_SNAP_RATE, 0., 1.));\n #else\n position.xy = _position_snap;\n #endif\n }\n\n gl_Position = position;\n}\n",fragment_shader_src:"uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\nuniform float u_visible_time;\n\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nuniform sampler2D u_texture;\nuniform float u_point_type;\nuniform bool u_apply_color_blocks;\n\nvarying vec4 v_color;\nvarying vec2 v_texcoord;\nvarying vec4 v_world_position;\nvarying float v_alpha_factor;\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n varying vec4 v_outline_color;\n varying float v_outline_edge;\n varying float v_aa_offset;\n#endif\n\n#ifdef TANGRAM_SHOW_HIDDEN_LABELS\n varying float v_label_hidden;\n#endif\n\n#define TANGRAM_NORMAL vec3(0., 0., 1.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n //l is the distance from the center to the fragment, R is the radius of the drawn point\n float _tangram_antialias(float l, float R){\n float low = R - v_aa_offset;\n float high = R + v_aa_offset;\n return 1. - smoothstep(low, high, l);\n }\n#endif\n\nvoid main (void) {\n // Initialize globals\n #pragma tangram: setup\n\n vec4 color = v_color;\n\n #ifdef TANGRAM_HAS_SHADER_POINTS\n // Only apply shader blocks to point, not to attached text (N.B.: for compatibility with ES)\n if (u_point_type == TANGRAM_POINT_TYPE_TEXTURE) { // sprite texture\n color *= texture2D(u_texture, v_texcoord);\n }\n else if (u_point_type == TANGRAM_POINT_TYPE_LABEL) { // label texture\n color = texture2D(u_texture, v_texcoord);\n color.rgb /= max(color.a, 0.001); // un-multiply canvas texture\n }\n else if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n // Mask of outermost circle, either outline or point boundary\n float _d = length(v_texcoord); // distance to this fragment from the point center\n float _outer_alpha = _tangram_antialias(_d, 1.);\n float _fill_alpha = _tangram_antialias(_d, 1. - (v_outline_edge * 0.5)) * color.a;\n float _stroke_alpha = (_outer_alpha - _tangram_antialias(_d, 1. - v_outline_edge)) * v_outline_color.a;\n\n // Apply alpha compositing with stroke 'over' fill.\n #ifdef TANGRAM_BLEND_ADD\n color.a = _stroke_alpha + _fill_alpha;\n color.rgb = color.rgb * _fill_alpha + v_outline_color.rgb * _stroke_alpha;\n #else // TANGRAM_BLEND_OVERLAY (and fallback for not implemented blending modes)\n color.a = _stroke_alpha + _fill_alpha * (1. - _stroke_alpha);\n color.rgb = mix(color.rgb * _fill_alpha, v_outline_color.rgb, _stroke_alpha) / max(color.a, 0.001); // avoid divide by zero\n #endif\n }\n #else\n // If shader points not supported, assume label texture\n color = texture2D(u_texture, v_texcoord);\n color.rgb /= max(color.a, 0.001); // un-multiply canvas texture\n #endif\n\n // Shader blocks for color/filter are only applied for sprites, shader points, and standalone text,\n // NOT for text attached to a point (N.B.: for compatibility with ES)\n if (u_apply_color_blocks) {\n #pragma tangram: color\n #pragma tangram: filter\n }\n\n color.a *= v_alpha_factor;\n\n // highlight hidden label in fragment shader for debugging\n #ifdef TANGRAM_SHOW_HIDDEN_LABELS\n if (v_label_hidden > 0.) {\n color.a *= 0.5;\n color.rgb = vec3(1., 0., 0.);\n }\n #endif\n\n // Use alpha test as a lower-quality substitute\n // For opaque and translucent: avoid transparent pixels writing to depth buffer, obscuring geometry underneath\n // For multiply: avoid transparent pixels multiplying geometry underneath to zero/full black\n #if defined(TANGRAM_BLEND_OPAQUE) || defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n if (color.a < TANGRAM_ALPHA_TEST) {\n discard;\n }\n #endif\n\n // Make points more visible in wireframe debug mode\n #ifdef TANGRAM_WIREFRAME\n color = vec4(vec3(0.5), 1.); // use gray outline for textured points\n #ifdef TANGRAM_HAS_SHADER_POINTS\n if (u_point_type == TANGRAM_POINT_TYPE_SHADER) {\n color = vec4(v_color.rgb, 1.); // use original vertex color outline for shader points\n }\n #endif\n #endif\n\n gl_FragColor = color;\n}\n",selection:!0,collision:!0,blend:"overlay",init(e={}){Pe.init.call(this,e),this.setupDefines(),this.defines.TANGRAM_HAS_SHADER_POINTS=!0,this.defines.TANGRAM_POINT_TYPE_TEXTURE=1,this.defines.TANGRAM_POINT_TYPE_LABEL=2,this.defines.TANGRAM_POINT_TYPE_SHADER=3,this.collision_group_points=this.name+"-points",this.collision_group_text=this.name+"-text",this.stencil_proxy_tiles=!1,this.reset()},setupDefines(){"overlay"!==this.blend&&(this.defines.TANGRAM_LAYER_ORDER=!0),!0===v.suppress_label_fade_in?(this.fade_in_time=0,this.defines.TANGRAM_FADE_IN_RATE=null):(this.fade_in_time=.15,this.defines.TANGRAM_FADE_IN_RATE=1/this.fade_in_time),!0!==v.suppress_label_snap_animation&&(this.defines.TANGRAM_VIEW_PAN_SNAP_RATE=2),!0===v.show_hidden_labels&&(this.defines.TANGRAM_SHOW_HIDDEN_LABELS=!0),!0===v.wireframe&&(this.defines.TANGRAM_WIREFRAME=!0)},reset(){this.queues={},this.resetText(),this.texture_missing_sprites={}},addFeature(e,t,n){let r=n.tile;if(r.generation!==this.generation)return;let i,s={};if(s.color=this.parseColor(t.color,n),s.texture=t.texture,s.label_texture=null,s.blend_order=t.blend_order,!s.color&&!s.texture)return;if(s.alpha=J.evalCachedProperty(t.alpha,n),this.hasSprites(s)){if(i=this.parseSprite(s,t,n),!i)return void m({level:"debug",once:!0},`Layer group '${t.layers.join(", ")}' uses a texture '${s.texture}', but doesn't specify which sprite to draw. Features that match this layer group won't be drawn without specifying the sprite with the 'sprite' or 'sprite_default' properties. The merged draw parameters for this layer group are:`,t).then(n=>{n&&m("debug",`Example feature for layer group '${t.layers.join(", ")}'`,e)});s.texcoords=i.texcoords}else if(t.sprite)return void m({level:"warn",once:!0},`Layer group '${t.layers.join(", ")}' specifies sprite '${t.sprite}', but the texture '${t.texture}' doesn't define any sprites. Features that match this layer group won't be drawn. The merged draw parameters for this layer group are:`,t);if(this.calcSize(t,s,i,n),t.outline&&(s.outline_width=J.evalCachedProperty(t.outline.width,n)||J.defaults.outline.width,s.outline_color=this.parseColor(t.outline.color,n)),s.outline_edge_pct=0,s.outline_width&&s.outline_color){let e=s.outline_width;s.size[0]+=e,s.size[1]+=e,s.outline_edge_pct=e/Math.min(s.size[0],s.size[1])*2,s.outline_alpha=J.evalCachedProperty(t.outline.alpha,n)}s.size[0]=Math.min(s.size[0],256),s.size[1]=Math.min(s.size[1],256),s.placement=t.placement,s.placement_min_length_ratio=J.evalCachedProperty(t.placement_min_length_ratio,n),s.placement===ur.SPACED&&t.placement_spacing&&(s.placement_spacing=J.evalCachedProperty(t.placement_spacing,n)),s.angle=J.evalProperty(t.angle,n)||0,s.z=J.evalCachedDistanceProperty(t.z,n)||J.defaults.z,s.tile_edges=t.tile_edges,this.computeLayout(s,e,t,n,r);let o=t.text&&!1!==t.text.visible&&this.parseTextFeature(e,t.text,n,r);Array.isArray(o)&&(o=null,m({level:"warn",once:!0},`Layer group '${t.layers.join(", ")}': cannot use boundary labels (e.g. 'text_source: { left: ..., right: ... }') for 'text' labels attached to 'points'; provided 'text_source' value was ${JSON.stringify(t.text.text_source)}`)),o&&(o.layout.parent=s,o.layout.priority=t.text.priority?Math.max(o.layout.priority,s.priority+.5):s.priority+.5,$t.addStyle(this.collision_group_text,r.id)),this.queueFeature({feature:e,draw:t,context:n,style:s,text_feature:o},r),$t.addStyle(this.collision_group_points,r.id)},calcSize(e,t,n,r){if(t.size=e.size,t.size){if(t.size=J.evalCachedPointSizeProperty(e.size,n,k.textures[t.texture],r),null==t.size)return void m({level:"warn",once:!0},`Layer group '${e.layers.join(", ")}': 'size' (${JSON.stringify(e.size.value)}) couldn't be interpreted, features that match this layer group won't be drawn`);"number"==typeof t.size&&(t.size=[t.size,t.size])}else t.size=n&&n.css_size||[16,16]},hasSprites:e=>e.texture&&k.textures[e.texture]&&k.textures[e.texture].sprites,getSpriteInfo(e,t){let n=k.textures[e.texture].sprites[t]&&k.getSpriteInfo(e.texture,t);return t&&!n?(this.texture_missing_sprites[e.texture]=this.texture_missing_sprites[e.texture]||{},this.texture_missing_sprites[e.texture][t]||(m("debug",`Style: in style '${this.name}', could not find sprite '${t}' for texture '${e.texture}'`),this.texture_missing_sprites[e.texture][t]=!0)):n&&(n.sprite=t),n},parseSprite(e,t,n){let r=J.evalProperty(t.sprite,n);return this.getSpriteInfo(e,r)||this.getSpriteInfo(e,t.sprite_default)},queueFeature(e,t){this.tile_data[t.id]&&this.queues[t.id]||this.startData(t),this.queues[t.id]=this.queues[t.id]||[],this.queues[t.id].push(e)},async endData(e){if(e.canceled)return m("trace",`Style ${this.name}: stop tile build because tile was canceled: ${e.key}`),null;let t=this.queues[e.id];delete this.queues[e.id];let n=[],r=[];t.forEach(e=>{let t=e.style,i=e.feature,s=i.geometry,o=this.buildLabels(t.size,s,t);for(let s=0;s<o.length;s++){let a=o[s],l={feature:i,draw:e.draw,context:e.context,style:t,label:a};if(r.push(l),e.text_feature){let t={feature:i,draw:e.text_feature.draw,context:e.context,text:e.text_feature.text,text_settings_key:e.text_feature.text_settings_key,layout:e.text_feature.layout,point_label:a,linked:l};n.push(t),e.draw.text.optional||(l.linked=t)}}});const[,{labels:i,texts:s,textures:o}]=await Promise.all([$t.collide(r,this.collision_group_points,e.id).then(e=>{e.forEach(e=>{this.feature_style=e.style,this.feature_style.label=e.label,this.feature_style.linked=e.linked,Pe.addFeature.call(this,e.feature,e.draw,e.context)})}),this.collideAndRenderTextLabels(e,this.collision_group_text,n)]);i&&s&&i.forEach(e=>{let t=e.text_settings_key,n=s[t]&&s[t][e.text],r=this.feature_style;r.label=e.label,r.linked=e.linked,r.size=n.size.logical_size,r.texcoords=n.align[e.label.align].texcoords,r.label_texture=o[n.align[e.label.align].texture_id],r.blend_order=e.draw.blend_order,Pe.addFeature.call(this,e.feature,e.draw,e.context)}),this.freeText(e);const a=await Pe.endData.call(this,e);return a&&o&&o.length&&(a.textures=a.textures||[],a.textures.push(...o)),a},_preprocess(e){e.color=J.createColorPropertyCache(e.color),e.alpha=J.createPropertyCache(e.alpha),e.texture=void 0!==e.texture?e.texture:this.texture,e.blend_order=this.getBlendOrderForDraw(e),e.outline&&(e.outline.color=J.createColorPropertyCache(e.outline.color),e.outline.alpha=J.createPropertyCache(e.outline.alpha),e.outline.width=J.createPropertyCache(e.outline.width,J.parsePositiveNumber)),e.z=J.createPropertyCache(e.z,J.parseUnits);try{e.size=J.createPointSizePropertyCache(e.size,e.texture)}catch(t){return m({level:"warn",once:!0},`Layer group '${e.layers.join(", ")}': ${t} (${JSON.stringify(e.size)}), features that match this layer group won't be drawn.`),null}if(e.offset=J.createPropertyCache(e.offset,e=>Array.isArray(e)&&e.map(J.parseNumber)),e.buffer=J.createPropertyCache(e.buffer,e=>(Array.isArray(e)?e:[e,e]).map(J.parsePositiveNumber)),e.repeat_distance=J.createPropertyCache(e.repeat_distance,J.parseNumber),e.placement=ur[e.placement&&e.placement.toUpperCase()],null==e.placement&&(e.placement=ur.VERTEX),e.placement_spacing=null!=e.placement_spacing?e.placement_spacing:80,e.placement_spacing=J.createPropertyCache(e.placement_spacing,J.parsePositiveNumber),e.placement_min_length_ratio=null!=e.placement_min_length_ratio?e.placement_min_length_ratio:1,e.placement_min_length_ratio=J.createPropertyCache(e.placement_min_length_ratio,J.parsePositiveNumber),"number"==typeof e.angle)e.angle=e.angle*Math.PI/180;else if("function"==typeof e.angle){const t=e.angle;e.angle=e=>t(e)*Math.PI/180}else e.angle=e.angle||0;return e.text=this.preprocessText(e.text),e.text&&(e.text.key=e.key,e.text.group=e.group,e.text.layers=e.layers,e.text.order=e.order,e.text.blend_order=e.blend_order,e.text.repeat_group=null!=e.text.repeat_group?e.text.repeat_group:e.repeat_group,e.text.anchor=e.text.anchor||this.default_anchor,e.text.optional="boolean"==typeof e.text.optional&&e.text.optional,e.text.interactive=e.text.interactive||e.interactive),e},default_anchor:["bottom","top","right","left"],computeLayout(e,t,n,r,i){let s=e||{};s.id=t,s.units_per_pixel=i.units_per_pixel||1,s.collide=!1!==n.collide,s.anchor=n.anchor,s.offset=J.evalCachedProperty(n.offset,r)||J.zeroPair,s.buffer=J.evalCachedProperty(n.buffer,r)||J.zeroPair,s.repeat_distance=J.evalCachedProperty(n.repeat_distance,r),s.repeat_distance&&(s.repeat_distance*=s.units_per_pixel,s.repeat_scale=1,"function"==typeof n.repeat_group?s.repeat_group=n.repeat_group(r):s.repeat_group=n.repeat_group||r.layer);let o=n.priority;return null!=o?"function"==typeof o&&(o=o(r)):o=-1>>>0,s.priority=o,s},buildTextLabels(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],s=this.texts[e.id][i.text_settings_key][i.text].size.collision_size;i.label=new qt(i.point_label.position,s,i.layout),n.push(i)}return n},buildLabels(e,t,n){let r=[];if("Point"===t.type)r.push(new qt(t.coordinates,e,n,n.angle));else if("MultiPoint"===t.type){let i=t.coordinates;for(let t=0;t<i.length;++t){let s=i[t];r.push(new qt(s,e,n,n.angle))}}else if("LineString"===t.type){let i=Wt(t.coordinates,e,n);for(let e=0;e<i.length;++e)r.push(i[e])}else if("MultiLineString"===t.type){let i=t.coordinates;for(let t=0;t<i.length;t++){let s=Wt(i[t],e,n);for(let e=0;e<s.length;++e)r.push(s[e])}}else if("Polygon"===t.type)if(n.placement===ur.CENTROID){let i=G.centroid(t.coordinates);i&&r.push(new qt(i,e,n,n.angle))}else{let i=t.coordinates;for(let t=0;t<i.length;t++){let s=Wt(i[t],e,n);for(let e=0;e<s.length;++e)r.push(s[e])}}else if("MultiPolygon"===t.type)if(n.placement===ur.CENTROID){let i=G.multiCentroid(t.coordinates);i&&r.push(new qt(i,e,n,n.angle))}else{let i=t.coordinates;for(let t=0;t<i.length;t++){let s=i[t];for(let t=0;t<s.length;t++){let i=Wt(s[t],e,n);for(let e=0;e<i.length;++e)r.push(i[e])}}}return r},makeVertexTemplate(e,t,n=!0){let r=0;this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=e.z||0,this.vertex_template[r++]=this.scaleOrder(e.order),this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=e.label.layout.collide?0:1,t.variant.shader_point||(this.vertex_template[r++]=0,this.vertex_template[r++]=0),this.vertex_template[r++]=0,this.vertex_template[r++]=0;const i=e.color||J.defaults.color;if(this.vertex_template[r++]=255*i[0],this.vertex_template[r++]=255*i[1],this.vertex_template[r++]=255*i[2],this.vertex_template[r++]=255*(null!=e.alpha?e.alpha:i[3]),t.variant.selection&&(this.vertex_template[r++]=255*e.selection_color[0],this.vertex_template[r++]=255*e.selection_color[1],this.vertex_template[r++]=255*e.selection_color[2],this.vertex_template[r++]=255*e.selection_color[3]),t.variant.shader_point){const t=e.outline_color||J.defaults.outline.color;this.vertex_template[r++]=255*t[0],this.vertex_template[r++]=255*t[1],this.vertex_template[r++]=255*t[2],this.vertex_template[r++]=255*(null!=e.outline_alpha?e.outline_alpha:t[3]),this.vertex_template[r++]=e.outline_edge_pct||J.defaults.outline.width}return n&&this.addCustomAttributesToVertexTemplate(e,r),this.vertex_template},buildQuad:(e,t,n,r,i,s,o,a,l,u,c)=>t[0]<=0||t[1]<=0?0:function(e,t,n,r,i,s,o,a,l,u,c,h){const d=128*i[0],f=128*i[1];St[0]=-d,St[1]=-f,St[2]=d,St[3]=f;const p=c||Ve,g=t.vertex_elements;let m=t.vertex_count;for(let i=0;i<4;i++)n[r.a_position+0]=e[0],n[r.a_position+1]=e[1],n[r.a_shape+0]=St[At[i]],n[r.a_shape+1]=St[Et[i]],n[r.a_shape+2]=l,n[r.a_offset+0]=s[0],n[r.a_offset+1]=s[1],r.a_texcoord&&(n[r.a_texcoord+0]=65535*p[At[i]],n[r.a_texcoord+1]=65535*p[Et[i]]),h&&(n[r.a_pre_angles+0]=xt*a[0],n[r.a_pre_angles+1]=xt*a[1],n[r.a_pre_angles+2]=xt*a[2],n[r.a_pre_angles+3]=xt*a[3],n[r.a_angles+0]=wt*u[0],n[r.a_angles+1]=wt*u[1],n[r.a_angles+2]=wt*u[2],n[r.a_angles+3]=wt*u[3],n[r.a_offsets+0]=64*o[0],n[r.a_offsets+1]=64*o[1],n[r.a_offsets+2]=64*o[2],n[r.a_offsets+3]=64*o[3]),t.addVertex(n);return g.push(m+0),g.push(m+1),g.push(m+2),g.push(m+2),g.push(m+3),g.push(m+0),2}(e,u,c,u.vertex_layout.index,t,s,o,i,4096*n,r,a,l),build(e,t){let n=e.label;return"curved"===n.type?this.buildCurvedLabel(n,e,t):this.buildStraightLabel(n,e,t)},buildStraightLabel(e,t,n){let r,i,s=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),o=this.makeVertexTemplate(t,s);"point"!==e.type?(r=t.size[e.type],i=t.texcoords[e.type].texcoord):(r=t.size,i=t.texcoords),s.uniforms=s.uniforms||{},t.label_texture?(s.uniforms.u_texture=t.label_texture,s.uniforms.u_point_type=2,s.uniforms.u_apply_color_blocks=!1):t.texture?(s.uniforms.u_texture=t.texture,s.uniforms.u_point_type=1,s.uniforms.u_apply_color_blocks=!0):(s.uniforms.u_texture=k.default,s.uniforms.u_point_type=3,s.uniforms.u_apply_color_blocks=!0);let a=e.offset,l=this.buildQuad(e.position,r,e.angle,null,null,a,null,i,!1,s.vertex_data,o);const u=t.linked&&t.linked.label.id;return this.trackLabel(e,u,s,l,n),l},buildCurvedLabel(e,t,n){let r,i,s=0;for(let o=0;o<e.num_segments;o++){let a=t.size[e.type][o],l=t.texcoords_stroke[o];t.label_texture=t.label_textures[o],r=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),i=this.makeVertexTemplate(t,r),r.uniforms=r.uniforms||{},r.uniforms.u_texture=t.label_texture,r.uniforms.u_point_type=2,r.uniforms.u_apply_color_blocks=!1;let u=e.offset||[0,0],c=e.position,h=e.angles[o],d=e.offsets[o],f=e.pre_angles[o],p=this.buildQuad(c,a,e.angle,h,f,u,d,l,!0,r.vertex_data,i);s+=p;const g=t.linked&&t.linked.label.id;this.trackLabel(e,g,r,p,n)}for(let o=0;o<e.num_segments;o++){let a=t.size[e.type][o],l=t.texcoords[e.type][o].texcoord;t.label_texture=t.label_textures[o],r=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),i=this.makeVertexTemplate(t,r),r.uniforms=r.uniforms||{},r.uniforms.u_texture=t.label_texture,r.uniforms.u_point_type=2,r.uniforms.u_apply_color_blocks=!1;let u=e.offset||[0,0],c=e.position,h=e.angles[o],d=e.offsets[o],f=e.pre_angles[o],p=this.buildQuad(c,a,e.angle,h,f,u,d,l,!0,r.vertex_data,i);s+=p;const g=t.linked&&t.linked.label.id;this.trackLabel(e,g,r,p,n)}return s},trackLabel(e,t,n,r){if(e.layout.collide||e.may_repeat_across_tiles){n.labels=n.labels||{},n.labels[e.id]=n.labels[e.id]||{container:{label:e.toJSON(),linked:t},ranges:[]};const i=2*r,s=n.vertex_data.offset-n.vertex_data.stride*i;n.labels[e.id].ranges.push([s,i])}},buildLines(e,t,n){return this.build(t,n)},buildPoints(e,t,n){return this.build(t,n)},buildPolygons(e,t,n){return this.build(t,n)},vertexLayoutForMeshVariant(e){if(null==this.vertex_layouts[e.shader_point]){const t=[{name:"a_position",size:4,type:fe.SHORT,normalized:!1},{name:"a_shape",size:4,type:fe.SHORT,normalized:!1},{name:"a_texcoord",size:2,type:fe.UNSIGNED_SHORT,normalized:!0,static:e.shader_point?[0,0]:null},{name:"a_offset",size:2,type:fe.SHORT,normalized:!1},{name:"a_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_outline_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.shader_point?null:[0,0,0,0]},{name:"a_outline_edge",size:1,type:fe.FLOAT,normalized:!1,static:e.shader_point?null:0}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.shader_point]=new Le(t)}return this.vertex_layouts[e.shader_point]},meshVariantTypeForDraw(e){const t=e.label_texture||e.texture||hr,n=t+"/"+e.blend_order;return null==this.variants[n]&&(this.variants[n]={key:n,selection:1,shader_point:t===hr,blend_order:e.blend_order,mesh_order:e.label_texture?1:0}),this.variants[n]},makeMesh(e,t,n={}){return n=Object.assign({},n,{fade_in_time:this.fade_in_time}),Pe.makeMesh.call(this,e,t,n)}});const dr=[0,.33,.66,.99];let fr=function(e,t,n,r){const i=[{type:"straight",tolerance:r.no_curving?1.8:1.5},{type:"curved"},{type:"straight",tolerance:2.3}];for(let s=0;s<i.length;s++){let o,a=i[s];if("straight"===a.type?o=new gr(t,n,r,a.tolerance):"curved"===a.type&&!r.no_curving&&n.length>2&&(o=new mr(e,n,r)),o&&!o.throw_away)return o}return!1};class pr{constructor(e){this.id=Vt.nextLabelId(),this.layout=e,this.position=[],this.angle=0,this.offset=e.offset.slice(),this.unit_scale=this.layout.units_per_pixel,this.obbs=[],this.aabbs=[],this.type="",this.throw_away=!1}toJSON(){return{id:this.id,type:this.type,position:this.position,size:this.size,offset:this.offset,angle:this.angle,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:Ut(this.layout)}}static splitLineByOrientation(e){let t=[e[0]],n=0,r=0,i=0,s=t,o=!1;for(let a=1;a<e.length;a++){let l=e[a],u=e[a-1],c=ye.length(ye.sub(l,u));l[0]>u[0]?1===i?(t.push(l),n+=c,n>r&&(s=t,r=n,o=!1)):(t=[u,l],n=c,n>r&&(s=t,r=n,o=!1),i=1):l[0]<u[0]?-1===i?(t.unshift(l),n+=c,n>r&&(s=t,r=n,o=!0)):(t=[l,u],n=c,n>r&&(s=t,r=n,o=!0),i=-1):(-1===i?t.unshift(l):(t.push(l),i=1),n+=c,n>r&&(s=t,r=n,o=-1===i))}return[s,o]}discard(e,t=null){if(this.throw_away)return!0;for(let n=0;n<this.obbs.length;n++){let r={aabb:this.aabbs[n],obb:this.obbs[n]};if(Vt.prototype.occluded.call(r,e,t))return!0}return!1}inTileBounds(){for(let e=0;e<this.aabbs.length;e++){let t={aabb:this.aabbs[e]};if(!Vt.prototype.inTileBounds.call(t))return!1}return!0}static createOBB(e,t,n,r,i,s,o){let a=e[0],l=e[1];return!s||0===s[0]&&0===s[1]||(a+=(s=ye.rot(s,i))[0]*o,l-=s[1]*o),new jt(a,l,-r,t,n)}}class gr extends pr{constructor(e,t,n,r){super(n),this.type="straight",this.size=e,this.throw_away=!this.fit(e,t,n,r)}fit(e,t,n,r){let i,s=this.unit_scale;[t,i]=pr.splitLineByOrientation(t),"number"==typeof n.orientation&&(this.offset[1]+=1.2*(e[1]-n.vertical_buffer),i&&(this.offset[1]*=-1),-1===n.orientation&&(this.offset[1]*=-1));let o=vr(t),a=e[0]*s;for(let i=0;i<t.length-1;i++){let s,l=t[i],u=0,c=0,h=i+1;for(;h<t.length;){let d=t[h-1],f=t[h],p=yr(d,f);if(h!==i+1&&(u+=br(p,s)),Math.abs(u)>.1)break;if(c+=o[h-1],_r(c,a)<r){let t=ye.mult(ye.add(l,f),.5);return this.angle=-p,Math.abs(this.angle-Math.PI/2)<.01&&(this.angle=-Math.PI/2,"number"==typeof n.orientation&&(this.offset[1]*=-1)),this.position=t,this.updateBBoxes(this.position,e,this.angle,this.angle,this.offset),!0}s=p,h++}}return!1}updateBBoxes(e,t,n,r,i){let s=this.unit_scale;this.obbs=[],this.aabbs=[];let o=(t[0]+2*this.layout.buffer[0])*s*Vt.epsilon,a=(t[1]+2*this.layout.buffer[1])*s*Vt.epsilon,l=pr.createOBB(e,o,a,n,r,i,s),u=l.getExtent();this.obbs.push(l),this.aabbs.push(u),this.inTileBounds&&(this.breach=!this.inTileBounds()),this.mayRepeatAcrossTiles&&(this.may_repeat_across_tiles=this.mayRepeatAcrossTiles())}}class mr extends pr{constructor(e,t,n){super(n),this.type="curved",this.angles=[],this.pre_angles=[],this.offsets=[],this.num_segments=e.length,this.sizes=e,this.throw_away=!this.fit(this.sizes,t,n)}toJSON(){return{id:this.id,type:this.type,obbs:this.obbs.map(e=>e.toJSON()),position:this.position,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:Ut(this.layout)}}fit(e,t,n){let r,i=this.unit_scale,s=Math.max(...e.map(e=>e[1])),o=s*i;[t,r]=pr.splitLineByOrientation(t),"number"==typeof n.orientation&&(this.offset[1]+=1.2*(s-n.vertical_buffer),r&&(this.offset[1]*=-1),-1===n.orientation&&(this.offset[1]*=-1));let a=vr(t),l=e.map(e=>e[0]*i),u=a.reduce((e,t)=>e+t,0),c=l.reduce((e,t)=>e+t,0);if(c>u)return!1;let h=t.length-1;if(h-0<2)return!1;let d=mr.curvaturePlacement(t,u,a,c,0,h),f=t[d];if(-1===d||h-d<2)return!1;this.position=f;for(var p=0;p<l.length;p++){this.offsets[p]=[],this.angles[p]=[],this.pre_angles[p]=[];for(var g=0;g<dr.length;g++){let e=dr[g],[n,r]=mr.scaleLine(e,t);f=n[d];let{positions:s,offsets:a,angles:u,pre_angles:c}=mr.placeAtIndex(d,n,r,l),h=a.map(e=>Math.sqrt(e[0]*e[0]+e[1]*e[1])/i);if(0===e){this.angle=1/u.length*u.reduce((e,t)=>e+t);for(let e=0;e<s.length;e++){let t=s[e],n=c[e],r=l[e],a=n+u[e],h=this.angle,d=pr.createOBB(t,r,o,a,h,this.offset,i),f=d.getExtent();this.obbs.push(d),this.aabbs.push(f)}}this.offsets[p].push(h[p]),this.angles[p].push(u[p]),this.pre_angles[p].push(c[p])}}return!0}static curvaturePlacement(e,t,n,r,i,s){i=i||0,s=s||e.length-1;var o=[];for(let t=i+1;t<s;t++){var a=e[t-1],l=e[t],u=e[t+1],c=ye.perp(l,a),h=ye.perp(u,l),d=ye.angleBetween(c,h);d>1&&(d=1/0),o.push(d)}o.push(1/0);var f=[],p=[],g=i,m=0;for(let e=0;e<i;e++)m+=n[e];for(;m+r<t;){for(var _=m+r,y=m,v=g,b=0;v<s&&y+n[v]<_&&(b+=o[v])!==1/0;)y+=n[v],v++;if(0===b)return g;var x=b/(v-g);f.push(b),p.push(x),m+=n[g],g++}if(0===f.length)return-1;var w=Math.min.apply(null,f),A=p[f.indexOf(w)];return w<1.3&&A<.4?f.indexOf(w):-1}static scaleLine(e,t){var n=[t[0]],r=[];return t.forEach((i,s)=>{if(s!==t.length-1){var o=ye.sub(t[s+1],t[s]),a=ye.mult(o,1+e);n.push(ye.add(n[s],a)),r.push(ye.length(a))}}),[n,r]}static placeAtIndex(e,t,n,r){let i=t[e],[s,o]=mr.getIndicesAndOffsets(e,n,r),a=mr.getPositionsFromIndicesAndOffsets(t,s,o),[l,u,c]=mr.getAnglesFromIndicesAndOffsets(i,s,t,a);return{positions:a,offsets:l,angles:u,pre_angles:c}}static getIndicesAndOffsets(e,t,n){let r=n.length,i=[],s=[],o=0,a=0,l=0;for(;o<r;){let u=n[o];for(;o<r&&a+.5*u<=l+t[e];){let t=a-l+.5*u;s.push(t),i.push(e),a+=u,o++,u=n[o]}l+=t[e],e++}return[i,s]}static getPositionsFromIndicesAndOffsets(e,t,n){let r=[];for(let i=0;i<t.length;i++){let s=t[i],o=n[i],a=yr(e[s],e[s+1]),l=ye.rot([o,0],a),u=ye.add(e[s],l);r.push(u)}return r}static getAnglesFromIndicesAndOffsets(e,t,n,r){let i=[],s=[],o=[];for(let a=0;a<r.length;a++){let l=r[a],u=t[a],c=ye.sub(l,e),h=-ye.angle(c),d=-yr(n[u],n[u+1])-h;if(a>0){let e=i[a-1],t=s[a-1];Math.abs(h-e)>Math.PI&&(h+=h>e?-2*Math.PI:2*Math.PI),Math.abs(t-d)>Math.PI&&(d+=d>t?-2*Math.PI:2*Math.PI)}i.push(h),s.push(d),o.push(c)}return[o,i,s]}}function _r(e,t){return t/e}function yr(e,t){let n=ye.sub(t,e);return ye.angle(n)}function vr(e){let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1],s=Math.hypot(r[0]-i[0],r[1]-i[1]);t.push(s)}return t}function br(e,t){let n,r;for(e>t?(n=t,r=e):(n=e,r=t);r-n>Math.PI;)n+=2*Math.PI;return Math.abs(r-n)}let xr=Object.create(cr);Object.assign(xr,{name:"text",super:cr,built_in:!0,init(e={}){Pe.init.call(this,e),this.setupDefines(),this.defines.TANGRAM_HAS_SHADER_POINTS=!1,this.defines.TANGRAM_CURVED_LABEL=!0,this.reset()},makeVertexTemplate(e,t){this.super.makeVertexTemplate.call(this,e,t,!1);let n=t.vertex_data.vertex_layout.index.a_pre_angles;for(let e=0;e<12;e++)this.vertex_template[n++]=0;return this.addCustomAttributesToVertexTemplate(e,n),this.vertex_template},reset(){this.queues={},this.resetText()},addFeature(e,t,n){let r=n.tile;if(r.generation!==this.generation)return;let i=e.geometry.type;t.can_articulate="LineString"===i||"MultiLineString"===i,t.supersample_text="LineString"===i||"MultiLineString"===i;let s=this.parseTextFeature(e,t,n,r);s&&(s instanceof Array?s.forEach(t=>{t.feature=e,t.context=n,t.layout.vertex=!1,this.queueFeature(t,r)}):(s.feature=e,s.context=n,s.layout.vertex=!1,this.queueFeature(s,r)),$t.addStyle(this.name,r.id))},async endData(e){let t=this.queues[e.id];delete this.queues[e.id];const{labels:n,texts:r,textures:i}=await this.collideAndRenderTextLabels(e,this.name,t);n&&r&&(this.texts[e.id]=r,n.forEach(t=>{let n=t.text_settings_key,r=this.texts[e.id][n]&&this.texts[e.id][n][t.text],s=this.feature_style;s.label=t.label,r.text_settings.can_articulate?(s.size={},s.texcoords={},"straight"===t.label.type?(s.size.straight=r.size.logical_size,s.texcoords.straight=r.texcoords.straight,s.label_texture=i[r.texcoords.straight.texture_id]):(s.size.curved=r.segment_sizes.map(function(e){return e.logical_size}),s.texcoords_stroke=r.texcoords_stroke,s.texcoords.curved=r.texcoords.curved,s.label_textures=r.texcoords.curved.map(e=>i[e.texture_id]))):(s.size=r.size.logical_size,s.texcoords=r.align[t.label.align].texcoords,s.label_texture=i[r.align[t.label.align].texture_id]),s.blend_order=t.draw.blend_order,Pe.addFeature.call(this,t.feature,t.draw,t.context)})),this.freeText(e);const s=await Pe.endData.call(this,e);if(s){i&&i.length&&s.textures.push(...i);for(let e in s.meshes)s.meshes[e].uniforms.u_apply_color_blocks=!0}return s},_preprocess(e){return e.blend_order=this.getBlendOrderForDraw(e),this.preprocessText(e)},buildTextLabels(e,t){let n=[];for(let i=0;i<t.length;i++){let s,o=t[i],a=this.texts[e.id][o.text_settings_key][o.text];if(o.layout.vertical_buffer=a.vertical_buffer,a.text_settings.can_articulate){var r=a.segment_sizes.map(e=>e.collision_size);o.layout.no_curving=a.no_curving,s=this.buildLabels(r,o.feature.geometry,o.layout,a.size.collision_size)}else s=this.buildLabels(a.size.collision_size,o.feature.geometry,o.layout);for(let e=0;e<s.length;e++){let t=Object.create(o);t.label=s[e],n.push(t)}}return n},buildLabels(e,t,n,r){let i=[];if("LineString"===t.type)Array.prototype.push.apply(i,this.buildLineLabels(t.coordinates,e,n,r));else if("MultiLineString"===t.type){let s=t.coordinates;for(let t=0;t<s.length;++t)Array.prototype.push.apply(i,this.buildLineLabels(s[t],e,n,r))}else if("Point"===t.type)i.push(new qt(t.coordinates,e,n));else if("MultiPoint"===t.type){let r=t.coordinates;for(let t=0;t<r.length;++t)i.push(new qt(r[t],e,n))}else if("Polygon"===t.type){let r=G.centroid(t.coordinates);r&&i.push(new qt(r,e,n))}else if("MultiPolygon"===t.type){let r=G.multiCentroid(t.coordinates);r&&i.push(new qt(r,e,n))}return i},buildLineLabels(e,t,n,r){let i=[],s=Math.min(n.subdiv,e.length-1);if(s>1){let o=(e.length-1)/s;for(let a=0;a<s;a++){let s=Math.floor(a*o),l=Math.floor((a+1)*o)+1,u=e.slice(s,l),c=fr(t,r,u,n);c&&i.push(c)}}if(i.length<s){let s=fr(t,r,e,n);s&&i.push(s)}return i},vertexLayoutForMeshVariant(e){if(null==this.vertex_layouts[e.shader_point]){const t=[{name:"a_position",size:4,type:fe.SHORT,normalized:!1},{name:"a_shape",size:4,type:fe.SHORT,normalized:!1},{name:"a_texcoord",size:2,type:fe.UNSIGNED_SHORT,normalized:!0},{name:"a_offset",size:2,type:fe.SHORT,normalized:!1},{name:"a_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_pre_angles",size:4,type:fe.BYTE,normalized:!1},{name:"a_angles",size:4,type:fe.SHORT,normalized:!1},{name:"a_offsets",size:4,type:fe.UNSIGNED_SHORT,normalized:!1}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.shader_point]=new Le(t)}return this.vertex_layouts[e.shader_point]}}),xr.texture_id=0;let wr=Object.create(et);function Ar(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Er(e){return null!=e}function Sr(e){return"("+e+")"}function Tr(e){return"string"==typeof e?'"'+e+'"':e}function kr(e){return"$"===e[0]?"context['"+e.substring(1)+"']":e.indexOf(".")>-1?-1===e.indexOf("\\.")?`context.feature.properties${e.split(".").map(e=>"['"+e+"']").join("")}`:`context.feature.properties${e.replace(/\\\./g,"__TANGRAM_DELIMITER__").split(".").map(e=>e.replace(/__TANGRAM_DELIMITER__/g,".")).map(e=>"['"+e+"']").join("")}`:"context.feature.properties['"+e+"']"}function Or(e,t){return Sr(Tr(t)+" === "+kr(e))}function Rr(e,t){return Sr(`${"["+t.map(Tr).join(",")+"]"}.indexOf(${kr(e)}) > -1`)}function Cr(e,t){return Sr(e.filter(Er).map(function(e){return Sr(e.join(" && "))}).join(" "+t+" "))}function Pr(e,t,n){return t&&t.length>0?Cr(t.map(function(e){return Lr(e,n)}),"||"):"true"}function Mr(e,t,n){return t&&t.length>0?Cr(t.map(function(e){return Lr(e,n)}),"&&"):"true"}function Nr(e,t,n){return"!"+Sr(Lr(t,n).join(" && "))}function Ir(e,t,n){return"!"+Sr(Pr(0,t,n))}function Dr(e,t){return Sr(kr(e)+(t?" != ":" == ")+"null")}function Fr(e,t,n){var r=[],i=n&&"function"==typeof n.rangeTransform&&n.rangeTransform;if(t.max){var s=i?i(t.max):t.max;r.push(kr(e)+" < "+s)}if(t.min){var o=i?o=i(t.min):t.min;r.push(kr(e)+" >= "+o)}return Sr(r.join(" && "))}function zr(e,t){let n=[];if(t.includes_any){const r="["+(Array.isArray(t.includes_any)?t.includes_any:[t.includes_any]).map(Tr).join(",")+"]";n.push(`${kr(e)} != null && ${r}.some(function(v) { return ${kr(e)}.indexOf(v) > -1 })`)}if(t.includes_all){const r="["+(Array.isArray(t.includes_all)?t.includes_all:[t.includes_all]).map(Tr).join(",")+"]";n.push(`${kr(e)} != null && ${r}.every(function(v) { return ${kr(e)}.indexOf(v) > -1 })`)}return Sr(n.join(" && "))}function Lr(e,t){var n=[];if("function"==typeof e)return[Sr(e.toString()+"(context)")];if(Array.isArray(e))return[Pr(0,e,t)];if(null==e)return["true"];for(var r=Object.keys(e),i=0;i<r.length;i++){var s=r[i],o=e[s],a=typeof o;if("string"===a||"number"===a)n.push(Or(s,o));else if("boolean"===a)n.push(Dr(s,o));else if("not"===s)n.push(Nr(0,o,t));else if("any"===s)n.push(Pr(0,o,t));else if("all"===s)n.push(Mr(0,o,t));else if("none"===s)n.push(Ir(0,o,t));else if(Array.isArray(o))n.push(Rr(s,o));else if("object"===a&&null!=o)o.max||o.min?n.push(Fr(s,o,t)):(o.includes_any||o.includes_all)&&n.push(zr(s,o));else{if(null!=o)throw new Error("Unknown Query syntax: "+o);n.push(" true ")}}return 0===r.length?["true"]:n}function jr(e,t){return null==e?function(){return!0}:new Function("context","return "+Sr(Lr(e,t).join(" && "))+";")}Object.assign(wr,{name:"raster",super:et,built_in:!0,init(){this.raster=this.raster||"color",this.super.init.apply(this,arguments),this.selection=!1},_preprocess(e){return e.color=e.color||J.defaults.color,this.super._preprocess.apply(this,arguments)}});const Vr=["filter","draw","visible","enabled","data","exclusive","priority"];let Ur={};function Br(e,t){let n,r=0;for(let t=0;t<e.length;t++)e[t].length>r&&(r=e[t].length);if(0===r)return null;let i={visible:!0};for(let s=0;s<r;s++)n=[],e.forEach(e=>{e[s]&&e[s][t]&&-1===n.indexOf(e[s][t])&&n.push(e[s][t])}),0!==n.length&&B(i,...n);return!1===i.visible?null:i}const Gr=["any","all","not","none"];class $r{constructor({layer:e,name:t,parent:n,draw:r,visible:i,enabled:s,filter:o,exclusive:a,priority:l,styles:u}){if(this.id=$r.id++,this.config_data=e.data,this.parent=n,this.name=t,this.full_name=this.parent?this.parent.full_name+":"+this.name:this.name,this.draw=r,this.filter=o,this.exclusive=!0===a,this.priority=null!=l?l:Number.MAX_SAFE_INTEGER,this.styles=u,this.is_built=!1,s=void 0===s?i:s,this.enabled=!1!==s,this.draw)for(let e in this.draw)if(this.draw[e]=null==this.draw[e]?{}:this.draw[e],"object"!=typeof this.draw[e]){let t=`Draw group '${e}' for layer ${this.full_name} is invalid, must be an object, `;t+=`but was set to \`${e}: ${this.draw[e]}\` instead`,m("warn",t),delete this.draw[e]}}build(){m("trace",`Building layer '${this.full_name}'`),this.buildFilter(),this.buildDraw(),this.is_built=!0}buildDraw(){this.draw=Z(this.draw,J.wrapFunction),this.calculatedDraw=function(e){let t=[];if(e.parent){let n=e.parent.calculatedDraw||[];t.push(...n)}return t.push(e.draw),t}(this)}buildFilter(){this.filter_original=this.filter,this.filter=Z(this.filter,J.wrapFunction);let e=typeof this.filter;if(null!=this.filter&&"object"!==e&&"function"!==e){let e=`Filter for layer ${this.full_name} is invalid, filter value must be an object or function, `;return e+=`but was set to \`filter: ${this.filter}\` instead`,void m("warn",e)}try{this.buildZooms(),this.buildPropMatches(),null!=this.filter&&("function"==typeof this.filter||Object.keys(this.filter).length>0)?this.filter=jr(this.filter,Wr):this.filter=null}catch(e){let t=`Filter for layer ${this.full_name} is invalid, \`filter: ${JSON.stringify(this.filter)}\` `;t+=`failed with error '${e.message}', stack trace: ${e.stack}`,m("warn",t)}}buildZooms(){let e=this.filter&&this.filter.$zoom,t=typeof e;if(null!=e){if(this.zooms={},"number"===t)this.zooms[e]=!0;else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.zooms[e[t]]=!0;else if("object"===t&&(null!=e.min||null!=e.max)){let t=e.min||0,n=e.max||G.max_style_zoom;for(let e=t;e<n;e++)this.zooms[e]=!0}delete this.filter.$zoom}}buildPropMatches(){this.filter&&!Array.isArray(this.filter)&&"function"!=typeof this.filter&&Object.keys(this.filter).forEach(e=>{if(-1===Gr.indexOf(e)){let t=this.filter[e],n=typeof t,r=Array.isArray(t);if(!r&&"string"!==n&&"number"!==n)return;"$"===e[0]?(this.context_prop_matches=this.context_prop_matches||[],this.context_prop_matches.push([e.substring(1),r?t:[t]]),delete this.filter[e]):-1===e.indexOf(".")&&(this.feature_prop_matches=this.feature_prop_matches||[],this.feature_prop_matches.push([e,r?t:[t]]),delete this.filter[e])}})}doPropMatches(e){if(this.feature_prop_matches)for(let t=0;t<this.feature_prop_matches.length;t++){let n=this.feature_prop_matches[t],r=e.feature.properties[n[0]];if(null==r||-1===n[1].indexOf(r))return!1}if(this.context_prop_matches)for(let t=0;t<this.context_prop_matches.length;t++){let n=this.context_prop_matches[t],r=e[n[0]];if(null==r||-1===n[1].indexOf(r))return!1}return!0}doesMatch(e){if(!this.enabled)return!1;if(this.is_built||this.build(),null!=this.zooms&&!this.zooms[e.zoom])return!1;if(!this.doPropMatches(e))return!1;let t;if(this.filter instanceof Function)try{t=this.filter(e)}catch(t){let n=`Filter for this ${this.full_name}: \`filter: ${this.filter_original}\` `;n+=`failed with error '${t.message}', stack trace: ${t.stack}`,m("error",n,e.feature)}else t=null==this.filter;return!!t&&(this.children_to_parse&&(function(e,t,n){for(let r in t){let i=t[r];if("object"!=typeof i||Array.isArray(i)){let t=`Layer value must be an object: cannot create layer '${r}: ${JSON.stringify(i)}'`;t+=`, under parent layer '${e.full_name}'.`,n[e.name]&&(t+=` The parent name '${e.name}' is also the name of a style, did you mean to create a 'draw' group`,e.parent&&(t+=` under '${e.parent.name}'`),t+=" instead?"),m("warn",t)}else Kr(r,i,e,n)}e.layers.sort((e,t)=>{if(e.exclusive<t.exclusive)return 1;if(e.exclusive>t.exclusive)return-1;const n=e.exclusive?1:-1;return e.priority>t.priority?n:e.priority<t.priority?-n:e.full_name<t.full_name?n:e.full_name>t.full_name?-n:void 0})}(this,this.children_to_parse,this.styles),delete this.children_to_parse),!0)}}$r.id=0;class qr extends $r{constructor(e){super(e),this.is_leaf=!0}}class Hr extends $r{constructor(e){super(e),this.is_tree=!0,this.layers=e.layers||[]}addLayer(e){this.layers.push(e)}buildDrawGroups(e){let t=[],n=[];if(Xr(e,[this],t,n),t.length>0){let e=function(e){if(e.length>1){for(var t=e[0],n=1;n<e.length;n++)t+="/"+e[n];return t}return e[0]}(n);if(void 0===Ur[e]){let n=t.map(e=>e&&!1!==e.visible&&e.calculatedDraw),r={};for(let e=0;e<n.length;e++){let t=n[e];if(t)for(let e=0;e<t.length;e++){let n=t[e];for(let e in n)r[e]=!0}}for(let i in r)Ur[e]=Ur[e]||{},Ur[e][i]=Br(n,i),Ur[e][i]?(Ur[e][i].key=e+"/"+i,Ur[e][i].layers=t.map(e=>e&&e.full_name),Ur[e][i].group=i):delete Ur[e][i];Ur[e]&&0===Object.keys(Ur[e]).length&&(Ur[e]=null)}return Ur[e]}}}const Wr={rangeTransform:e=>"string"==typeof e&&"px2"===e.trim().slice(-3)?`${parseFloat(e)} * context.meters_per_pixel_sq`:e};function Zr(e){return Vr.indexOf(e)>-1}function Kr(e,t,n,r){let i={name:e,layer:t=null==t?{}:t,parent:n,styles:r},[s,o]=function(e){let t={},n={};for(let r in e)Zr(r)?t[r]=e[r]:n[r]=e[r];return[t,n]}(t),a=(l=o,0===Object.keys(l).length);var l;let u;u=a&&null!=n?qr:Hr;let c=new u(Object.assign(i,s));return c.enabled&&(n&&n.addLayer(c),c.children_to_parse=a?null:o),c}function Xr(e,t,n,r){let i=!1,s=!1;if(0!==t.length){for(let o=0;o<t.length;o++){let a=t[o];if(a.is_leaf){if(a.doesMatch(e)&&(i=!0,n.push(a),r.push(a.id),a.exclusive))break}else if(a.is_tree&&a.doesMatch(e)&&(i=!0,s=Xr(e,a.layers,n,r),s||(n.push(a),r.push(a.id)),a.exclusive))break}return i}}function Yr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yr(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}let Jr=0,ei=0;class ti{constructor({coords:e,style_z:t,source:n,workers:r,view:i}){this.id=Jr++,this.view=i,this.source=n,this.generation=null,this.valid=!0,this.visible=!1,this.proxy_for=null,this.proxied_as=null,this.proxy_level=0,this.proxy_order_offset=0,this.fade_in=!0,this.loading=!1,this.loaded=!1,this.built=!1,this.labeled=!1,this.error=null,this.debug={},this.style_z=t,this.coords=Te.normalizedCoord(e,this.source),this.key=Te.key(this.coords,this.source,this.style_z),this.overzoom=Math.max(this.style_z-this.coords.z,0),this.overzoom2=Math.pow(2,this.overzoom),this.min=G.metersForTile(this.coords),this.max=G.metersForTile({x:this.coords.x+1,y:this.coords.y+1,z:this.coords.z}),this.span={x:this.max.x-this.min.x,y:-(this.max.y-this.min.y)},this.bounds={sw:{x:this.min.x,y:this.max.y},ne:{x:this.max.x,y:this.min.y}},this.meters_per_pixel=G.metersPerPixel(this.style_z),this.meters_per_pixel_sq=this.meters_per_pixel*this.meters_per_pixel,this.units_per_pixel=G.units_per_pixel/this.overzoom2,this.units_per_meter_overzoom=G.unitsPerMeter(this.coords.z)*this.overzoom2,this.preserve_tiles_within_zoom=this.source.preserve_tiles_within_zoom,this.meshes={},this.new_mesh_styles=[],this.pending_label_meshes=null,this.setWorker(r)}freeResources(){for(let e in this.meshes)this.meshes[e].forEach(e=>e.destroy());if(this.meshes={},this.pending_label_meshes)for(let e in this.pending_label_meshes)this.pending_label_meshes[e].forEach(e=>e.destroy());this.pending_label_meshes=null}destroy(){E.removeForTile(this.id),this.workerMessage("self.removeTile",this.key),this.freeResources(),this.worker=null,this.valid=!1}buildAsMessage(){return{id:this.id,key:this.key,source:this.source.name,coords:this.coords,min:this.min,max:this.max,units_per_pixel:this.units_per_pixel,meters_per_pixel:this.meters_per_pixel,meters_per_pixel_sq:this.meters_per_pixel_sq,units_per_meter_overzoom:this.units_per_meter_overzoom,style_z:this.style_z,overzoom:this.overzoom,overzoom2:this.overzoom2,generation:this.generation,debug:this.debug}}setWorker(e){this.source.tiled?this.worker_id=Math.abs(this.coords.x+this.coords.y+this.coords.z)%e.length:this.worker_id=this.source.id%e.length,this.worker=e[this.worker_id]}workerMessage(...e){return a.postMessage(this.worker,...e)}build(e,{fade_in:t=!0}={}){return this.generation=e,this.fade_in=t,this.loaded||(this.loading=!0,this.built=!1,this.labeled=!1),this.workerMessage("self.buildTile",{tile:this.buildAsMessage()}).catch(e=>{throw e})}static cancel(e){e&&(e.canceled=!0,e.source_data&&e.source_data.request_id&&(_.cancelRequest(e.source_data.request_id),e.source_data.request_id=null),ti.abortBuild(e))}static buildGeometry(e,{scene_id:t,layers:n,styles:r,global:i}){let s=e.source_data;e.debug.building=+new Date,e.debug.feature_count=0,e.debug.layers=null,$t.startTile(e.id,{apply_repeat_groups:!0});for(let t in n){let o=n[t];if(!o||!o.config_data){m("warn",`Layer ${t} was defined without a geometry data source and will not be rendered.`);continue}if(o.config_data.source!==e.source)continue;let a=ti.getDataForSource(s,o.config_data,t);for(let n=0;n<a.length;n++){let s=a[n],l=s.geom;if(l)for(let n=0;n<l.features.length;n++){let a=l.features[n];if(null==a.geometry)continue;let u=J.getFeatureParseContext(a,e,i);u.winding=e.default_winding,u.source=e.source,u.layer=s.layer;let c=o.buildDrawGroups(u,!0);if(c){for(let e in c){let n=c[e],i=n.style||e,s=r[i];s?(n=s.preprocess(n),null!=n&&!1!==n.visible&&(u.layers=n.layers,s.addFeature(a,n,u))):m("warn",`Style '${i}' not found, skipping layer '${t}':`,n,a)}e.debug.feature_count++}}}}e.debug.building=+new Date-e.debug.building;let o=this.stylesForTile(e,r).map(e=>r[e]);ti.buildStyleGroups(e,o,t,e=>e.collision?"collision":"non-collision")}static stylesForTile(e,t){let n=[];for(let r in t)t[r].hasDataForTile(e)&&n.push(r);return n}static buildStyleGroups(e,t,n,r){const i=t.reduce((e,t)=>{const n=r(t);return e[n]=e[n]||[],e[n].push(t),e},{});if(0===Object.keys(i).length)return a.postMessage(`TileManager_${n}.buildTileStylesCompleted`,a.withTransferables({tile:ti.slice(e),progress:{start:!0,done:!0}})),void $t.resetTile(e.id);const s={};for(const t in i)ti.buildStyleGroup({group_name:t,groups:i,tile:e,progress:s,scene_id:n})}static async buildStyleGroup({group_name:e,groups:t,tile:n,progress:r,scene_id:i}){const s=t[e],o={};try{await Promise.all(s.map(async function(e){const t=await e.endData(n);t&&(o[e.name]=t)})),m("trace",`Finished style group '${e}' for tile ${n.key}`),t[e]=null,Object.keys(t).every(e=>null==t[e])&&(r.done=!0),a.postMessage(`TileManager_${i}.buildTileStylesCompleted`,a.withTransferables({tile:Qr(Qr({},ti.slice(n)),{},{mesh_data:o}),progress:r})),r.done&&$t.resetTile(n.id)}catch(t){m("error",`Error for style group '${e}' for tile ${n.key}`,t&&t.stack||t)}}static getDataForSource(e,t,n){var r=[];if(null!=t&&null!=e&&null!=e.layers)if(!0===t.all_layers){null!=t.layer&&m({level:"warn",once:!0},`Layer ${n} includes both 'all_layers: true' and an explicit 'layer' keyword in its 'data' block. 'all_layers: true' takes precedence, 'layer' will be ignored.`);for(const t in e.layers)r.push({layer:t,geom:e.layers[t]})}else!t.layer&&e.layers._default?r.push({geom:e.layers._default}):!t.layer&&n?r.push({layer:n,geom:e.layers[n]}):"string"==typeof t.layer?r.push({layer:t.layer,geom:e.layers[t.layer]}):Array.isArray(t.layer)&&t.layer.forEach(t=>{r.push({layer:t,geom:e.layers[t]})});return r}buildMeshes(e,t){if(this.error)return;this.build_id=ei++,t.start&&(this.debug.geometry_count=0,this.debug.buffer_size=0);let n={},r=this.mesh_data;if(r)for(let t in r){for(let i in r[t].meshes){let s=r[t].meshes[i];if(s.vertex_data){if(!e[t]){m("warn",`Could not create mesh because style '${t}' not found, for tile ${this.key}, aborting tile`);break}let i=Object.assign({},r[t]);i.uniforms=Object.assign({},i.uniforms,s.uniforms),i.variant=s.variant,s.labels&&(i.retain=!0);let o=e[t].makeMesh(s.vertex_data,s.vertex_elements,i);o.variant=i.variant,o.labels=s.labels,n[t]=n[t]||[],n[t].push(o),null==o.variant.mesh_order&&(o.variant.mesh_order=n[t].length-1),this.debug.buffer_size+=o.buffer_size,this.debug.geometry_count+=o.geometry_count}}n[t]&&n[t].sort((e,t)=>{let n=e.variant.mesh_order,r=t.variant.mesh_order;return null==n?1:null==r||n<r?-1:1})}delete this.mesh_data;for(let t in n)e[t].collision?(this.pending_label_meshes=this.pending_label_meshes||{},this.pending_label_meshes[t]=n[t]):(this.meshes[t]&&this.meshes[t].forEach(e=>e.destroy()),this.meshes[t]=n[t],this.new_mesh_styles.push(t));if(t.done){for(let e in this.meshes)-1!==this.new_mesh_styles.indexOf(e)||this.pending_label_meshes&&null!=this.pending_label_meshes[e]||(this.meshes[e].forEach(e=>e.destroy()),delete this.meshes[e]);this.new_mesh_styles=[],this.debug.geometry_ratio=(this.debug.geometry_count/this.debug.feature_count).toFixed(1)}this.printDebug(t)}pendingLabelStyleCount(){return this.pending_label_meshes?Object.keys(this.pending_label_meshes).length:0}swapPendingLabels(){if(this.labeled=!0,this.pending_label_meshes){for(let e in this.pending_label_meshes)this.meshes[e]&&this.meshes[e].forEach(e=>e.destroy()),this.meshes[e]=this.pending_label_meshes[e];this.pending_label_meshes=null}}static abortBuild(e){if(E.removeForTile(e.id),$t.abortTile(e.id),e.mesh_data)for(let t in e.mesh_data){let n=e.mesh_data[t].textures;n&&n.forEach(t=>{let n=k.textures[t];n&&(m("trace",`releasing texture ${t} for tile ${e.key}`),n.release())})}}setProxyFor(e){e?(this.visible=!0,this.proxy_for=this.proxy_for||[],this.proxy_for.push(e),this.proxy_order_offset=1,e.proxied_as=e.style_z>this.style_z?"child":"parent",this.proxy_level=Math.abs(e.style_z-this.style_z)):(this.proxy_for=null,this.proxy_order_offset=0,this.proxy_level=0)}isProxy(){return null!=this.proxy_for}shouldProxyForStyle(e){return!this.proxy_for||this.proxy_for.some(t=>null==t.meshes[e])}setupProgram({model:e,model32:t},n){n.uniform("4fv","u_tile_origin",[this.min.x,this.min.y,this.style_z,this.coords.z]),n.uniform("1f","u_tile_proxy_order_offset",this.proxy_order_offset),ir.identity(e),ir.translate(e,e,nr.fromValues(this.min.x,this.min.y,0)),ir.scale(e,e,nr.fromValues(this.span.x/G.tile_scale,this.span.y/G.tile_scale,1)),ir.copy(t,e),n.uniform("Matrix4fv","u_model",t),n.uniform("1i","u_tile_fade_in",this.fade_in&&"child"!==this.proxied_as)}static slice(e,t){let n=["id","key","loading","loaded","generation","error","debug"];Array.isArray(t)&&n.push(...t);var r={};for(let t=0;t<n.length;t++){const i=n[t];r[i]=e[i]}return r}merge(e){return this.loading=e.loading,this.loaded=e.loaded,this.generation=e.generation,this.error=e.error,this.mesh_data=e.mesh_data,this.debug=B(this.debug,e.debug),this}printDebug(e){const t=["layers"];let n={};for(let e in this.debug)-1===t.indexOf(e)&&(n[e]=this.debug[e]);m("debug",`Tile ${e.done?"(done)":""}: debug for ${this.key}: [ ${JSON.stringify(n)} ]`)}}function ni(e,t){for(let n in e){let r=e[n];Me(t,n,r.features,r.geoms,r.styles,r.base),r.layers&&(t[n].layers=t[n].layers||{},ni(r.layers,t[n].layers))}}ti.coord_children={};var ri,ii,si,oi={};var ai,li,ui,ci,hi,di,fi,pi,gi,mi=function(){if(si)return ii;si=1,ii=t;var e=(ri||(ri=1,oi.read=function(e,t,n,r,i){var s,o,a=8*i-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+e[t+h],h+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=256*o+e[t+h],h+=d,c-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),s-=u}return(f?-1:1)*o*Math.pow(2,s-r)},oi.write=function(e,t,n,r,i,s){var o,a,l,u=8*s-i-1,c=(1<<u)-1,h=c>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:s-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(t*l-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[n+f]=255&o,f+=p,o/=256,u-=8);e[n+f-p]|=128*g}),oi);function t(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}t.Varint=0,t.Fixed64=1,t.Bytes=2,t.Fixed32=5;var n=4294967296,r=1/n;function i(e){return e.type===t.Bytes?e.readVarint()+e.pos:e.pos+1}function s(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function o(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.ceil(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function a(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function l(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function u(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function c(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function h(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function d(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function f(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function p(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function g(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function m(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function _(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function y(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}return t.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,s=this.pos;this.type=7&r,e(i,t,this),this.pos===s&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=m(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=y(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=m(this.buf,this.pos)+m(this.buf,this.pos+4)*n;return this.pos+=8,e},readSFixed64:function(){var e=m(this.buf,this.pos)+y(this.buf,this.pos+4)*n;return this.pos+=8,e},readFloat:function(){var t=e.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=e.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(e){var t,n,r=this.buf;return t=127&(n=r[this.pos++]),n<128?t:(t|=(127&(n=r[this.pos++]))<<7,n<128?t:(t|=(127&(n=r[this.pos++]))<<14,n<128?t:(t|=(127&(n=r[this.pos++]))<<21,n<128?t:function(e,t,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return s(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return s(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return s(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return s(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return s(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return s(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=function(e,t,n){for(var r="",i=t;i<n;){var s,o,a,l=e[i],u=null,c=l>239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(s=e[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&((u=(15&l)<<12|(63&s)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&((u=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,this.pos,e);return this.pos=e,t},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){var n=i(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var n=7&e;if(n===t.Varint)for(;this.buf[this.pos++]>127;);else if(n===t.Bytes)this.pos=this.readVarint()+this.pos;else if(n===t.Fixed32)this.pos+=4;else{if(n!==t.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),_(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),_(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),_(this.buf,-1&e,this.pos),_(this.buf,Math.floor(e*r),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),_(this.buf,-1&e,this.pos),_(this.buf,Math.floor(e*r),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos]=127&e}(n,0,t),function(e,t){var n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var r,i,s=0;s<t.length;s++){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){r>56319||s+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&o(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),e.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),e.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var r=this.pos-n;r>=128&&o(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,n,r){this.writeTag(e,t.Bytes),this.writeRawMessage(n,r)},writePackedVarint:function(e,t){this.writeMessage(e,a,t)},writePackedSVarint:function(e,t){this.writeMessage(e,l,t)},writePackedBoolean:function(e,t){this.writeMessage(e,h,t)},writePackedFloat:function(e,t){this.writeMessage(e,u,t)},writePackedDouble:function(e,t){this.writeMessage(e,c,t)},writePackedFixed32:function(e,t){this.writeMessage(e,d,t)},writePackedSFixed32:function(e,t){this.writeMessage(e,f,t)},writePackedFixed64:function(e,t){this.writeMessage(e,p,t)},writePackedSFixed64:function(e,t){this.writeMessage(e,g,t)},writeBytesField:function(e,n){this.writeTag(e,t.Bytes),this.writeBytes(n)},writeFixed32Field:function(e,n){this.writeTag(e,t.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(e,n){this.writeTag(e,t.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(e,n){this.writeTag(e,t.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(e,n){this.writeTag(e,t.Fixed64),this.writeSFixed64(n)},writeVarintField:function(e,n){this.writeTag(e,t.Varint),this.writeVarint(n)},writeSVarintField:function(e,n){this.writeTag(e,t.Varint),this.writeSVarint(n)},writeStringField:function(e,n){this.writeTag(e,t.Bytes),this.writeString(n)},writeFloatField:function(e,n){this.writeTag(e,t.Fixed32),this.writeFloat(n)},writeDoubleField:function(e,n){this.writeTag(e,t.Fixed64),this.writeDouble(n)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}},ii}(),_i=M(mi),yi={};function vi(){if(ci)return ui;ci=1;var e=function(){if(li)return ai;function e(e,t){this.x=e,this.y=t}return li=1,ai=e,e.prototype={clone:function(){return new e(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[0]*this.x+e[1]*this.y,n=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=n,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),n=Math.sin(e),r=t*this.x-n*this.y,i=n*this.x+t*this.y;return this.x=r,this.y=i,this},_rotateAround:function(e,t){var n=Math.cos(e),r=Math.sin(e),i=t.x+n*(this.x-t.x)-r*(this.y-t.y),s=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=i,this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},e.convert=function(t){return t instanceof e?t:Array.isArray(t)?new e(t[0],t[1]):t},ai}();function t(e,t,r,i,s){this.properties={},this.extent=r,this.type=0,this._pbf=e,this._geometry=-1,this._keys=i,this._values=s,e.readFields(n,this,t)}function n(e,t,n){1==e?t.id=n.readVarint():2==e?function(e,t){for(var n=e.readVarint()+e.pos;e.pos<n;){var r=t._keys[e.readVarint()],i=t._values[e.readVarint()];t.properties[r]=i}}(n,t):3==e?t.type=n.readVarint():4==e&&(t._geometry=n.pos)}function r(e){for(var t,n,r=0,i=0,s=e.length,o=s-1;i<s;o=i++)t=e[i],r+=((n=e[o]).x-t.x)*(t.y+n.y);return r}return ui=t,t.types=["Unknown","Point","LineString","Polygon"],t.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var n,r=t.readVarint()+t.pos,i=1,s=0,o=0,a=0,l=[];t.pos<r;){if(!s){var u=t.readVarint();i=7&u,s=u>>3}if(s--,1===i||2===i)o+=t.readSVarint(),a+=t.readSVarint(),1===i&&(n&&l.push(n),n=[]),n.push(new e(o,a));else{if(7!==i)throw new Error("unknown command "+i);n&&n.push(n[0].clone())}}return n&&l.push(n),l},t.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,r=0,i=0,s=0,o=1/0,a=-1/0,l=1/0,u=-1/0;e.pos<t;){if(!r){var c=e.readVarint();n=7&c,r=c>>3}if(r--,1===n||2===n)(i+=e.readSVarint())<o&&(o=i),i>a&&(a=i),(s+=e.readSVarint())<l&&(l=s),s>u&&(u=s);else if(7!==n)throw new Error("unknown command "+n)}return[o,l,a,u]},t.prototype.toGeoJSON=function(e,n,i){var s,o,a=this.extent*Math.pow(2,i),l=this.extent*e,u=this.extent*n,c=this.loadGeometry(),h=t.types[this.type];function d(e){for(var t=0;t<e.length;t++){var n=e[t],r=180-360*(n.y+u)/a;e[t]=[360*(n.x+l)/a-180,360/Math.PI*Math.atan(Math.exp(r*Math.PI/180))-90]}}switch(this.type){case 1:var f=[];for(s=0;s<c.length;s++)f[s]=c[s][0];d(c=f);break;case 2:for(s=0;s<c.length;s++)d(c[s]);break;case 3:for(c=function(e){var t=e.length;if(t<=1)return[e];for(var n,i,s=[],o=0;o<t;o++){var a=r(e[o]);0!==a&&(void 0===i&&(i=a<0),i===a<0?(n&&s.push(n),n=[e[o]]):n.push(e[o]))}return n&&s.push(n),s}(c),s=0;s<c.length;s++)for(o=0;o<c[s].length;o++)d(c[s][o])}1===c.length?c=c[0]:h="Multi"+h;var p={type:"Feature",geometry:{type:h,coordinates:c},properties:this.properties};return"id"in this&&(p.id=this.id),p},ui}function bi(){if(di)return hi;di=1;var e=vi();function t(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(n,this,t),this.length=this._features.length}function n(e,t,n){15===e?t.version=n.readVarint():1===e?t.name=n.readString():5===e?t.extent=n.readVarint():2===e?t._features.push(n.pos):3===e?t._keys.push(n.readString()):4===e&&t._values.push(function(e){for(var t=null,n=e.readVarint()+e.pos;e.pos<n;){var r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(n))}return hi=t,t.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var n=this._pbf.readVarint()+this._pbf.pos;return new e(this._pbf,n,this.extent,this._keys,this._values)},hi}var xi=(gi||(gi=1,yi.VectorTile=function(){if(pi)return fi;pi=1;var e=bi();function t(t,n,r){if(3===t){var i=new e(r,r.readVarint()+r.pos);i.length&&(n[i.name]=i)}}return fi=function(e,n){this.layers=e.readFields(t,{},n)},fi}(),yi.VectorTileFeature=vi(),yi.VectorTileLayer=bi()),yi);const wi=["{","["];class Ai extends Se{constructor(e,t){super(e,t),this.response_type="arraybuffer",!0===e.parse_json?this.parse_json_type=1:Array.isArray(e.parse_json)?(this.parse_json_type=2,this.parse_json_prop_list=e.parse_json):(null!=e.parse_json&&m({level:"warn",once:!0},`Data source '${this.name}': 'parse_json' parameter should be 'true', or an array of property names (was '${JSON.stringify(e.parse_json)}')`),this.parse_json_type=0)}parseSourceData(e,t,n){var r=new Uint8Array(n),i=new _i(r);if(t.data=new xi.VectorTile(i),t.layers=this.toGeoJSON(t.data),"function"==typeof this.transform){const n={min:Object.assign({},e.min),max:Object.assign({},e.max),coords:Object.assign({},e.coords)};t.layers=this.transform(t.layers,this.extra_data,n)}delete t.data}toGeoJSON(e){var t={};for(var n in e.layers){for(var r=e.layers[n],i=G.tile_scale/r.extent,s={type:"FeatureCollection",features:[]},o=0;o<r.length;o++){var a=r.feature(o),l={type:"Feature",geometry:{},id:a.id,properties:a.properties};this.parseJSONProperties(l);for(var u=l.geometry,c=a.loadGeometry(),h=0;h<c.length;h++)for(var d=c[h],f=0;f<d.length;f++)d[f]=[d[f].x*i,d[f].y*i];u.coordinates=c,"Point"===xi.VectorTileFeature.types[a.type]?1===c.length?(u.type="Point",u.coordinates=u.coordinates[0][0]):(u.type="MultiPoint",u.coordinates=u.coordinates[0]):"LineString"===xi.VectorTileFeature.types[a.type]?1===c.length?(u.type="LineString",u.coordinates=u.coordinates[0]):u.type="MultiLineString":"Polygon"===xi.VectorTileFeature.types[a.type]&&(u=Ei(u)),s.features.push(l)}t[n]=s}return t}parseJSONProperties(e){if(0!==this.parse_json_type){const t=e.properties;if(2===this.parse_json_type)this.parse_json_prop_list.forEach(e=>{try{t[e]=JSON.parse(t[e])}catch(e){}});else for(const n in t)if(wi.indexOf(t[n][0])>-1)try{t[n]=JSON.parse(t[n])}catch(e){}}}}function Ei(e){let t,n=[],r=[];for(let i=0;i<e.coordinates.length;i++){let s=e.coordinates[i],o=G.ringWinding(s);null!=o&&(t=t||o,o===t&&r.length>0&&(n.push(r),r=[]),r.push(s))}return r.length>0&&n.push(r),1===n.length?(e.type="Polygon",e.coordinates=n[0]):n.length>1?(e.type="MultiPolygon",e.coordinates=n):e=null,e}function Si(e,t,n,r){for(var i,s=r,o=n-t>>1,a=n-t,l=e[t],u=e[t+1],c=e[n],h=e[n+1],d=t+3;d<n;d+=3){var f=Ti(e[d],e[d+1],l,u,c,h);if(f>s)i=d,s=f;else if(f===s){var p=Math.abs(d-o);p<a&&(i=d,a=p)}}s>r&&(i-t>3&&Si(e,t,i,r),e[i+2]=s,n-i>3&&Si(e,i,n,r))}function Ti(e,t,n,r,i,s){var o=i-n,a=s-r;if(0!==o||0!==a){var l=((e-n)*o+(t-r)*a)/(o*o+a*a);l>1?(n=i,r=s):l>0&&(n+=o*l,r+=a*l)}return(o=e-n)*o+(a=t-r)*a}function ki(e,t,n,r){var i={id:void 0===e?null:e,type:t,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,n=e.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)Oi(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r<t.length;r++)Oi(e,t[r]);else if("MultiPolygon"===n)for(r=0;r<t.length;r++)for(var i=0;i<t[r].length;i++)Oi(e,t[r][i])}(i),i}function Oi(e,t){for(var n=0;n<t.length;n+=3)e.minX=Math.min(e.minX,t[n]),e.minY=Math.min(e.minY,t[n+1]),e.maxX=Math.max(e.maxX,t[n]),e.maxY=Math.max(e.maxY,t[n+1])}function Ri(e,t,n,r){if(t.geometry){var i=t.geometry.coordinates,s=t.geometry.type,o=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2),a=[],l=t.id;if(n.promoteId?l=t.properties[n.promoteId]:n.generateId&&(l=r||0),"Point"===s)Ci(i,a);else if("MultiPoint"===s)for(var u=0;u<i.length;u++)Ci(i[u],a);else if("LineString"===s)Pi(i,a,o,!1);else if("MultiLineString"===s){if(n.lineMetrics){for(u=0;u<i.length;u++)a=[],Pi(i[u],a,o,!1),e.push(ki(l,"LineString",a,t.properties));return}Mi(i,a,o,!1)}else if("Polygon"===s)Mi(i,a,o,!0);else{if("MultiPolygon"!==s){if("GeometryCollection"===s){for(u=0;u<t.geometry.geometries.length;u++)Ri(e,{id:l,geometry:t.geometry.geometries[u],properties:t.properties},n,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(u=0;u<i.length;u++){var c=[];Mi(i[u],c,o,!0),a.push(c)}}e.push(ki(l,s,a,t.properties))}}function Ci(e,t){t.push(Ni(e[0])),t.push(Ii(e[1])),t.push(0)}function Pi(e,t,n,r){for(var i,s,o=0,a=0;a<e.length;a++){var l=Ni(e[a][0]),u=Ii(e[a][1]);t.push(l),t.push(u),t.push(0),a>0&&(o+=r?(i*u-l*s)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-s,2))),i=l,s=u}var c=t.length-3;t[2]=1,Si(t,0,c,n),t[c+2]=1,t.size=Math.abs(o),t.start=0,t.end=t.size}function Mi(e,t,n,r){for(var i=0;i<e.length;i++){var s=[];Pi(e[i],s,n,r),t.push(s)}}function Ni(e){return e/360+.5}function Ii(e){var t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function Di(e,t,n,r,i,s,o,a){if(r/=t,s>=(n/=t)&&o<r)return e;if(o<n||s>=r)return null;for(var l=[],u=0;u<e.length;u++){var c=e[u],h=c.geometry,d=c.type,f=0===i?c.minX:c.minY,p=0===i?c.maxX:c.maxY;if(f>=n&&p<r)l.push(c);else if(!(p<n||f>=r)){var g=[];if("Point"===d||"MultiPoint"===d)Fi(h,g,n,r,i);else if("LineString"===d)zi(h,g,n,r,i,!1,a.lineMetrics);else if("MultiLineString"===d)ji(h,g,n,r,i,!1);else if("Polygon"===d)ji(h,g,n,r,i,!0);else if("MultiPolygon"===d)for(var m=0;m<h.length;m++){var _=[];ji(h[m],_,n,r,i,!0),_.length&&g.push(_)}if(g.length){if(a.lineMetrics&&"LineString"===d){for(m=0;m<g.length;m++)l.push(ki(c.id,d,g[m],c.tags));continue}"LineString"!==d&&"MultiLineString"!==d||(1===g.length?(d="LineString",g=g[0]):d="MultiLineString"),"Point"!==d&&"MultiPoint"!==d||(d=3===g.length?"Point":"MultiPoint"),l.push(ki(c.id,d,g,c.tags))}}}return l.length?l:null}function Fi(e,t,n,r,i){for(var s=0;s<e.length;s+=3){var o=e[s+i];o>=n&&o<=r&&(t.push(e[s]),t.push(e[s+1]),t.push(e[s+2]))}}function zi(e,t,n,r,i,s,o){for(var a,l,u=Li(e),c=0===i?Ui:Bi,h=e.start,d=0;d<e.length-3;d+=3){var f=e[d],p=e[d+1],g=e[d+2],m=e[d+3],_=e[d+4],y=0===i?f:p,v=0===i?m:_,b=!1;o&&(a=Math.sqrt(Math.pow(f-m,2)+Math.pow(p-_,2))),y<n?v>n&&(l=c(u,f,p,m,_,n),o&&(u.start=h+a*l)):y>r?v<r&&(l=c(u,f,p,m,_,r),o&&(u.start=h+a*l)):Vi(u,f,p,g),v<n&&y>=n&&(l=c(u,f,p,m,_,n),b=!0),v>r&&y<=r&&(l=c(u,f,p,m,_,r),b=!0),!s&&b&&(o&&(u.end=h+a*l),t.push(u),u=Li(e)),o&&(h+=a)}var x=e.length-3;f=e[x],p=e[x+1],g=e[x+2],(y=0===i?f:p)>=n&&y<=r&&Vi(u,f,p,g),x=u.length-3,s&&x>=3&&(u[x]!==u[0]||u[x+1]!==u[1])&&Vi(u,u[0],u[1],u[2]),u.length&&t.push(u)}function Li(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ji(e,t,n,r,i,s){for(var o=0;o<e.length;o++)zi(e[o],t,n,r,i,s,!1)}function Vi(e,t,n,r){e.push(t),e.push(n),e.push(r)}function Ui(e,t,n,r,i,s){var o=(s-t)/(r-t);return e.push(s),e.push(n+(i-n)*o),e.push(1),o}function Bi(e,t,n,r,i,s){var o=(s-n)/(i-n);return e.push(t+(r-t)*o),e.push(s),e.push(1),o}function Gi(e,t){for(var n=[],r=0;r<e.length;r++){var i,s=e[r],o=s.type;if("Point"===o||"MultiPoint"===o||"LineString"===o)i=$i(s.geometry,t);else if("MultiLineString"===o||"Polygon"===o){i=[];for(var a=0;a<s.geometry.length;a++)i.push($i(s.geometry[a],t))}else if("MultiPolygon"===o)for(i=[],a=0;a<s.geometry.length;a++){for(var l=[],u=0;u<s.geometry[a].length;u++)l.push($i(s.geometry[a][u],t));i.push(l)}n.push(ki(s.id,o,i,s.tags))}return n}function $i(e,t){var n=[];n.size=e.size,void 0!==e.start&&(n.start=e.start,n.end=e.end);for(var r=0;r<e.length;r+=3)n.push(e[r]+t,e[r+1],e[r+2]);return n}function qi(e,t){if(e.transformed)return e;var n,r,i,s=1<<e.z,o=e.x,a=e.y;for(n=0;n<e.features.length;n++){var l=e.features[n],u=l.geometry,c=l.type;if(l.geometry=[],1===c)for(r=0;r<u.length;r+=2)l.geometry.push(Hi(u[r],u[r+1],t,s,o,a));else for(r=0;r<u.length;r++){var h=[];for(i=0;i<u[r].length;i+=2)h.push(Hi(u[r][i],u[r][i+1],t,s,o,a));l.geometry.push(h)}}return e.transformed=!0,e}function Hi(e,t,n,r,i,s){return[Math.round(n*(e*r-i)),Math.round(n*(t*r-s))]}function Wi(e,t,n,r,i){for(var s=t===i.maxZoom?0:i.tolerance/((1<<t)*i.extent),o={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:n,y:r,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){o.numFeatures++,Zi(o,e[a],s,i);var l=e[a].minX,u=e[a].minY,c=e[a].maxX,h=e[a].maxY;l<o.minX&&(o.minX=l),u<o.minY&&(o.minY=u),c>o.maxX&&(o.maxX=c),h>o.maxY&&(o.maxY=h)}return o}function Zi(e,t,n,r){var i=t.geometry,s=t.type,o=[];if("Point"===s||"MultiPoint"===s)for(var a=0;a<i.length;a+=3)o.push(i[a]),o.push(i[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===s)Ki(o,i,e,n,!1,!1);else if("MultiLineString"===s||"Polygon"===s)for(a=0;a<i.length;a++)Ki(o,i[a],e,n,"Polygon"===s,0===a);else if("MultiPolygon"===s)for(var l=0;l<i.length;l++){var u=i[l];for(a=0;a<u.length;a++)Ki(o,u[a],e,n,!0,0===a)}if(o.length){var c=t.tags||null;if("LineString"===s&&r.lineMetrics){for(var h in c={},t.tags)c[h]=t.tags[h];c.mapbox_clip_start=i.start/i.size,c.mapbox_clip_end=i.end/i.size}var d={geometry:o,type:"Polygon"===s||"MultiPolygon"===s?3:"LineString"===s||"MultiLineString"===s?2:1,tags:c};null!==t.id&&(d.id=t.id),e.features.push(d)}}function Ki(e,t,n,r,i,s){var o=r*r;if(r>0&&t.size<(i?o:r))n.numPoints+=t.length/3;else{for(var a=[],l=0;l<t.length;l+=3)(0===r||t[l+2]>o)&&(n.numSimplified++,a.push(t[l]),a.push(t[l+1])),n.numPoints++;i&&function(e,t){for(var n=0,r=0,i=e.length,s=i-2;r<i;s=r,r+=2)n+=(e[r]-e[s])*(e[r+1]+e[s+1]);if(n>0===t)for(r=0,i=e.length;r<i/2;r+=2){var o=e[r],a=e[r+1];e[r]=e[i-2-r],e[r+1]=e[i-1-r],e[i-2-r]=o,e[i-1-r]=a}}(a,s),e.push(a)}}function Xi(e,t){return new Yi(e,t)}function Yi(e,t){var n=(t=this.options=function(e,t){for(var n in t)e[n]=t[n];return e}(Object.create(this.options),t)).debug;if(n&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(e,t){var n=[];if("FeatureCollection"===e.type)for(var r=0;r<e.features.length;r++)Ri(n,e.features[r],t,r);else"Feature"===e.type?Ri(n,e,t):Ri(n,{geometry:e},t);return n}(e,t);this.tiles={},this.tileCoords=[],n&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=function(e,t){var n=t.buffer/t.extent,r=e,i=Di(e,1,-1-n,n,0,-1,2,t),s=Di(e,1,1-n,2+n,0,-1,2,t);return(i||s)&&(r=Di(e,1,-n,1+n,0,-1,2,t)||[],i&&(r=Gi(i,1).concat(r)),s&&(r=r.concat(Gi(s,-1)))),r}(r,t),r.length&&this.splitTile(r,0,0,0),n&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function Qi(e,t,n){return 32*((1<<e)*n+t)+e}we.register("MVT",()=>Ai),Yi.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Yi.prototype.splitTile=function(e,t,n,r,i,s,o){for(var a=[e,t,n,r],l=this.options,u=l.debug;a.length;){r=a.pop(),n=a.pop(),t=a.pop(),e=a.pop();var c=1<<t,h=Qi(t,n,r),d=this.tiles[h];if(!d&&(u>1&&console.time("creation"),d=this.tiles[h]=Wi(e,t,n,r,l),this.tileCoords.push({z:t,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,n,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(d.source=e,i){if(t===l.maxZoom||t===i)continue;var p=1<<i-t;if(n!==Math.floor(s/p)||r!==Math.floor(o/p))continue}else if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue;if(d.source=null,0!==e.length){u>1&&console.time("clipping");var g,m,_,y,v,b,x=.5*l.buffer/l.extent,w=.5-x,A=.5+x,E=1+x;g=m=_=y=null,v=Di(e,c,n-x,n+A,0,d.minX,d.maxX,l),b=Di(e,c,n+w,n+E,0,d.minX,d.maxX,l),e=null,v&&(g=Di(v,c,r-x,r+A,1,d.minY,d.maxY,l),m=Di(v,c,r+w,r+E,1,d.minY,d.maxY,l),v=null),b&&(_=Di(b,c,r-x,r+A,1,d.minY,d.maxY,l),y=Di(b,c,r+w,r+E,1,d.minY,d.maxY,l),b=null),u>1&&console.timeEnd("clipping"),a.push(g||[],t+1,2*n,2*r),a.push(m||[],t+1,2*n,2*r+1),a.push(_||[],t+1,2*n+1,2*r),a.push(y||[],t+1,2*n+1,2*r+1)}}},Yi.prototype.getTile=function(e,t,n){var r=this.options,i=r.extent,s=r.debug;if(e<0||e>24)return null;var o=1<<e,a=Qi(e,t=(t%o+o)%o,n);if(this.tiles[a])return qi(this.tiles[a],i);s>1&&console.log("drilling down to z%d-%d-%d",e,t,n);for(var l,u=e,c=t,h=n;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[Qi(u,c,h)];return l&&l.source?(s>1&&console.log("found parent tile z%d-%d-%d",u,c,h),s>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,e,t,n),s>1&&console.timeEnd("drilling down"),this.tiles[a]?qi(this.tiles[a],i):null):null};class Ji extends Ee{constructor(e,t){super(e,t),this.load_data=null,this.tile_indexes={},this.setTileSize(512),this.pad_scale=0}_load(e){return this.load_data||(this.load_data=super._load({source_data:{layers:{}}}).then(e=>{e.source_data.error&&m("warn",`data source load error(s) for source '${this.name}', URL '${this.url}': ${e.source_data.error}`);let t=e.source_data.layers;for(let e in t)this.tile_indexes[e]=Xi(t[e],{maxZoom:this.max_zoom,tolerance:1.5,extent:G.tile_scale,buffer:1e-4});return this.loaded=!0,e})),this.load_data.then(()=>{for(let t in this.tile_indexes)e.source_data.layers[t]=this.getTileFeatures(e,t);return e})}getTileFeatures(e,t){let n,r=G.wrapTile(e.coords,{x:!0}),i=this.tile_indexes[t].getTile(r.z,r.x,r.y);if(i&&i.features){n={type:"FeatureCollection",features:[]};for(let e=0;e<i.features.length;e++){const t=i.features[e];let r={type:"Feature",geometry:{},id:t.id,properties:t.tags};if(1===t.type)r.geometry.coordinates=t.geometry.map(e=>[e[0],e[1]]),r.geometry.type="MultiPoint";else{if(2!==t.type&&3!==t.type)continue;if(r.geometry.coordinates=t.geometry.map(e=>e.map(e=>[e[0],e[1]])),2===t.type)r.geometry.type="MultiLineString";else if(r.geometry=Ei(r.geometry),null==r.geometry)continue}n.features.push(r)}}return n}formatURL(){return this.url}parseSourceData(e,t,n){let r="string"==typeof n?JSON.parse(n):n,i=this.getLayers(r);t.layers=this.preprocessLayers(i,e)}preprocessLayers(e,t){for(let t in e){let n=e[t];n.features=this.preprocessFeatures(n.features)}if("function"==typeof this.transform){const n={min:Object.assign({},t.min),max:Object.assign({},t.max),coords:Object.assign({},t.coords)};1===Object.keys(e).length&&e._default?e._default=this.transform(e._default,this.extra_data,n):e=this.transform(e,this.extra_data,n)}return e}preprocessFeatures(e){if(e=e.filter(e=>null!=e.geometry),this.config.generate_label_centroids){let t=[],n={label_placement:!0};e.forEach(e=>{let r,i;if("Polygon"===e.geometry.type)r=e.geometry.coordinates,i=ts(r,e.id,e.properties,n),t.push(i);else if("MultiPolygon"===e.geometry.type){r=e.geometry.coordinates;let s=-1/0,o=0;for(let e=0;e<r.length;e++){let t=G.polygonArea(r[e]);t>s&&(s=t,o=e)}i=ts(r[o],e.id,e.properties,n),t.push(i)}}),t=t.filter(e=>e),Array.prototype.push.apply(e,t)}return e}getLayers(e){return"Feature"===e.type?{_default:{type:"FeatureCollection",features:[e]}}:"FeatureCollection"===e.type?{_default:e}:e}}class es extends Se{constructor(e,t){super(e,t)}parseSourceData(e,t,n){let r="string"==typeof n?JSON.parse(n):n;this.prepareGeoJSON(r,e,t)}prepareGeoJSON(e,t,n){if("function"==typeof this.transform){const n={min:Object.assign({},t.min),max:Object.assign({},t.max),coords:Object.assign({},t.coords)};e=this.transform(e,this.extra_data,n)}n.layers=Ji.prototype.getLayers(e);let r={coords:t.coords,min:G.metersForTile(G.wrapTile(t.coords,{x:!0}))};we.projectData(n),we.scaleData(n,r)}}function ts(e,t,n,r){let i=G.centroid(e);if(!i)return;let s={};return Object.assign(s,n,r),{type:"Feature",id:t,properties:s,geometry:{type:"Point",coordinates:i}}}function ns(e){return e}function rs(e,t){var n=t.id,r=t.bbox,i=null==t.properties?{}:t.properties,s=function(e,t){var n=function(e){if(null==(t=e.transform))return ns;var t,n,r,i=t.scale[0],s=t.scale[1],o=t.translate[0],a=t.translate[1];return function(e,t){return t||(n=r=0),e[0]=(n+=e[0])*i+o,e[1]=(r+=e[1])*s+a,e}}(e),r=e.arcs;function i(e,t){t.length&&t.pop();for(var i=r[e<0?~e:e],s=0,o=i.length;s<o;++s)t.push(n(i[s].slice(),s));e<0&&function(e,t){for(var n,r=e.length,i=r-t;i<--r;)n=e[i],e[i++]=e[r],e[r]=n}(t,o)}function s(e){return n(e.slice())}function o(e){for(var t=[],n=0,r=e.length;n<r;++n)i(e[n],t);return t.length<2&&t.push(t[0].slice()),t}function a(e){for(var t=o(e);t.length<4;)t.push(t[0].slice());return t}function l(e){return e.map(a)}return function e(t){var n,r=t.type;switch(r){case"GeometryCollection":return{type:r,geometries:t.geometries.map(e)};case"Point":n=s(t.coordinates);break;case"MultiPoint":n=t.coordinates.map(s);break;case"LineString":n=o(t.arcs);break;case"MultiLineString":n=t.arcs.map(o);break;case"Polygon":n=l(t.arcs);break;case"MultiPolygon":n=t.arcs.map(l);break;default:return null}return{type:r,coordinates:n}}(t)}(e,t);return null==n&&null==r?{type:"Feature",properties:i,geometry:s}:null==r?{type:"Feature",id:n,properties:i,geometry:s}:{type:"Feature",id:n,bbox:r,properties:i,geometry:s}}we.register("GeoJSON",e=>es.urlHasTilePattern(e.url)?es:Ji);class is extends Ji{parseSourceData(e,t,n){let r="string"==typeof n?JSON.parse(n):n;r=this.toGeoJSON(r);let i=this.getLayers(r);super.preprocessLayers(i,e),t.layers=i}toGeoJSON(e){if(e.objects&&1===Object.keys(e.objects).length){let t=Object.keys(e.objects)[0];e=ss(e,e.objects[t])}else{let t={};for(let n in e.objects)t[n]=ss(e,e.objects[n]);e=t}return e}}function ss(e,t){let n=function(e,t){return"GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map(function(t){return rs(e,t)})}:rs(e,t)}(e,t);return"Feature"===n.type&&(n={type:"FeatureCollection",features:[n]}),n}class os extends es{constructor(e,t){super(e,t)}parseSourceData(e,t,n){let r="string"==typeof n?JSON.parse(n):n;r=is.prototype.toGeoJSON(r),this.prepareGeoJSON(r,e,t)}}we.register("TopoJSON",e=>os.urlHasTilePattern(e.url)?os:is),e.Collision=$t,e.DataSource=we,e.FeatureSelection=he,e.FilterOptions=Wr,e.FontManager=rn,e.GLSL=O,e.Geo=G,e.Label=Vt,e.LabelLineStraight=gr,e.LabelPoint=qt,e.Light=ve,e.Material=me,e.OBB=jt,e.ShaderProgram=j,e.Style=Pe,e.StyleManager=class{constructor(){this.styles={},this.base_styles={},this.active_styles=[],this.active_blend_orders=[],this.register(Object.create(et)),this.register(Object.create(bt)),this.register(Object.create(cr)),this.register(Object.create(xr)),this.register(Object.create(wr))}init(){j.removeBlock("global"),j.removeBlock("setup"),j.addBlock("global","#ifdef TANGRAM_VERTEX_SHADER\n\n// Apply layer ordering to avoid z-fighting\nvoid applyLayerOrder (float layer, inout vec4 position) {\n position.z -= layer * TANGRAM_LAYER_DELTA * position.w;\n}\n\n// Vertex position in model space: [0, 1] range over the local tile\n// Note positions can be outside that range due to unclipped geometry, geometry higher than a unit cube, etc.\nvec4 modelPosition() {\n return\n vec4(\n a_position.xyz / TANGRAM_TILE_SCALE // scale coords to ~0-1 range\n * exp2(u_tile_origin.z - u_tile_origin.w), // adjust for tile overzooming\n 1.)\n + vec4(0., 1., 0., 0.);\n // NB: additional offset to account for unusual Tangram JS y coords,\n // should be refactored to remove\n}\n\n// Position in model space as above, but according to tile coordinate (as opposed to style) zoom\n// e.g. unadjusted for tile overzooming\nvec4 modelPositionBaseZoom() {\n return\n vec4(\n a_position.xyz / TANGRAM_TILE_SCALE, // scale coords to ~0-1 range\n 1.)\n + vec4(0., 1., 0., 0.); // see note on offset above\n}\n\n#endif\n\n// Vertex position in world coordinates, useful for 3d procedural textures, etc.\nvec4 worldPosition() {\n return v_world_position;\n}\n\n// Optionally wrap world coordinates (allows more precision at higher zooms)\n// e.g. at wrap 1000, the world space will wrap every 1000 meters\n#ifdef TANGRAM_VERTEX_SHADER\n\nvec4 wrapWorldPosition(vec4 world_position) {\n #if defined(TANGRAM_WORLD_POSITION_WRAP)\n vec2 anchor = u_tile_origin.xy - mod(u_tile_origin.xy, TANGRAM_WORLD_POSITION_WRAP);\n world_position.xy -= anchor;\n #endif\n return world_position;\n}\n\n#endif\n\n// Normal in world space\n#if defined(TANGRAM_VERTEX_SHADER)\n\nvec3 worldNormal() {\n return TANGRAM_NORMAL;\n}\n\n#elif defined(TANGRAM_FRAGMENT_SHADER)\n\nvec3 worldNormal() {\n return u_inverseNormalMatrix * TANGRAM_NORMAL;\n}\n\n#endif\n"),j.addBlock("global","// Vertex attribute + varying for feature selection\n#if defined(TANGRAM_FEATURE_SELECTION) && defined(TANGRAM_VERTEX_SHADER)\n attribute vec4 a_selection_color;\n varying vec4 v_selection_color;\n#endif\n"),j.replaceBlock("setup","// Selection pass-specific rendering\n#if defined(TANGRAM_FEATURE_SELECTION) && defined(TANGRAM_VERTEX_SHADER)\n if (a_selection_color.rgb == vec3(0.)) {\n // Discard by forcing invalid triangle if we're in the feature\n // selection pass but have no selection info\n // TODO: in some cases we may actually want non-selectable features to occlude selectable ones?\n gl_Position = vec4(0., 0., 0., 1.);\n return;\n }\n v_selection_color = a_selection_color;\n#endif\n"),j.defines.TANGRAM_EPSILON=1e-5,j.defines.TANGRAM_LAYER_DELTA=1/16384,j.defines.TANGRAM_TILE_SCALE=`vec3(${G.tile_scale}., ${G.tile_scale}., u_meters_per_pixel * ${G.tile_size}.)`,j.defines.TANGRAM_HEIGHT_SCALE=G.height_scale,j.defines.TANGRAM_ALPHA_TEST=.5}destroy(e){Object.keys(this.styles).forEach(t=>{let n=this.styles[t];n.gl===e&&(m("trace",`StyleManager.destroy: destroying render style ${n.name}`),n.base&&this.remove(n.name),n.destroy())})}register(e){this.styles[e.name]=e,this.base_styles[e.name]=e}remove(e){delete this.styles[e]}getActiveStyles(){return this.active_styles}updateActiveStyles(e){return this.active_styles=Object.keys(e.reduce((e,t)=>(Object.keys(t.meshes).forEach(t=>e[t]=!0),e),{})),this.active_styles}getActiveBlendOrders(){return this.active_blend_orders}updateActiveBlendOrders(e){const t=[];e.forEach(e=>{Object.entries(e.meshes).forEach(([e,n])=>{n.forEach(n=>{const r=n.variant.blend_order;let i=t.findIndex(e=>e.blend_order===r);i=i>-1?i:t.push({blend_order:r,styles:[]})-1,-1===t[i].styles.indexOf(e)&&t[i].styles.push(e)})})}),this.active_blend_orders=t.sort((e,t)=>e.blend_order-t.blend_order)}mix(e,t){if(e.mixed)return e;e.mixed={};let n=[];e.mix&&(Array.isArray(e.mix)?n.push(...e.mix):n.push(e.mix),n=n.map(e=>t[e]).filter(t=>t&&t!==e),n.forEach(t=>e.mixed[t.name]=!0)),n.push(e),e.animated=n.some(e=>e&&e.animated),e.texcoords=n.some(e=>e&&e.texcoords),e.base=n.map(e=>e.base).filter(e=>e).pop(),e.lighting=n.map(e=>e.lighting).filter(e=>null!=e).pop(),e.texture=n.map(e=>e.texture).filter(e=>e).pop(),e.raster=n.map(e=>e.raster).filter(e=>null!=e).pop(),e.dash=n.map(e=>e.dash).filter(e=>null!=e).pop(),e.dash_background_color=n.map(e=>e.dash_background_color).filter(e=>null!=e).pop(),n.some(e=>Object.prototype.hasOwnProperty.call(e,"blend")&&e.blend)&&(e.blend=n.map(e=>Object.prototype.hasOwnProperty.call(e,"blend")&&e.blend).filter(e=>e).pop()),e.blend_order=n.map(e=>e.blend_order).filter(e=>null!=e).pop(),e.defines=Object.assign({},...n.map(e=>e.defines).filter(e=>e)),e.material=Object.assign({},...n.map(e=>e.material).filter(e=>e));let r=n.map(e=>e.draw).filter(e=>e);return r.length>0&&(e.draw=B({},...r)),this.mixShaders(e,t,n),e}mixShaders(e,t,n){let r={},i=n.map(e=>e.shaders).filter(e=>e);if(r.defines=Object.assign({},...i.map(e=>e.defines).filter(e=>e)),r.attributes=Object.assign({},...i.map(e=>e.attributes).filter(e=>e)),r.uniforms={},r._uniforms=e.shaders&&e.shaders.uniforms||{},r._uniform_scopes={},n.filter(e=>e.shaders&&e.shaders.uniforms).forEach(e=>{for(let n in e.shaders.uniforms)r._uniform_scopes[n]=e.name,Object.defineProperty(r.uniforms,n,{enumerable:!0,configurable:!0,get:function(){return void 0!==r._uniforms[n]?r._uniforms[n]:t[r._uniform_scopes[n]].shaders.uniforms!==r.uniforms?t[r._uniform_scopes[n]].shaders.uniforms[n]:void 0},set:function(e){r._uniforms[n]=e}})}),r.extensions=Object.keys(i.map(e=>e.extensions).filter(e=>e).reduce((e,t)=>("string"==typeof t?e[t]=!0:t.forEach(t=>e[t]=!0),e),{})||{}),e.shaders&&e.shaders.blocks){e.shaders.block_scopes=e.shaders.block_scopes||{};for(let t in e.shaders.blocks){let n=e.shaders.blocks[t];e.shaders.block_scopes[t]=e.shaders.block_scopes[t]||[],Array.isArray(n)?e.shaders.block_scopes[t].push(...n.map(()=>e.name)):e.shaders.block_scopes[t].push(e.name)}}let s={};return i.forEach(e=>{if(!e.blocks)return;r.blocks=r.blocks||{},r.block_scopes=r.block_scopes||{};let t={};for(let n in e.blocks){let i=e.blocks[n],o=e.block_scopes[n];r.blocks[n]=r.blocks[n]||[],r.block_scopes[n]=r.block_scopes[n]||[],i=Array.isArray(i)?i:[i],o=Array.isArray(o)?o:[o];for(let e=0;e<i.length;e++)s[o[e]]||(t[o[e]]=!0,r.blocks[n].push(i[e]),r.block_scopes[n].push(o[e]))}Object.assign(s,t)}),Object.assign(e.mixed,s),e.shaders=r,e}create(e,t,n={}){let r=B({},t);return r.name=e,r=this.mix(r,n),r.base&&this.base_styles[r.base]?this.styles[e]=r=Object.assign(Object.create(this.base_styles[r.base]),r):r.base=null,r}build(e){const t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ar(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ar(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},e);this.styles&&Object.values(this.styles).forEach(e=>a.removeTarget(e.main_thread_target));const n=["opaque","add","multiply","overlay","inlay","translucent"],r=["polygons","lines","points","text","raster"];for(const e of n)for(const n of r){const r=e+"_"+n;null==t[r]&&(t[r]={base:n,blend:e})}let s=Object.keys(t).sort((e,n)=>this.inheritanceDepth(e,t)-this.inheritanceDepth(n,t));for(let e in this.styles)this.base_styles[e]?this.styles[e].reset():delete this.styles[e];let o={};return s.forEach(e=>{o[e]=this.create(e,t[e],o)}),this.styles}initStyles(e={}){for(let t in this.styles)this.styles[t].init(e)}inheritanceDepth(e,t){let n=0;for(;;){let r=t[e];if(!r)break;if(!r.mix)break;if(n++,Array.isArray(r.mix)){n+=Math.max(...r.mix.map(n=>{if(e!==n)return this.inheritanceDepth(n,t)}));break}if(e===r.mix)break;e=r.mix}return n}},e.StyleParser=J,e.Task=E,e.TextCanvas=An,e.Texture=k,e.Thread=t,e.Tile=ti,e.TileID=Te,e.Utils=_,e.Vector=ye,e.VertexArrayObject=U,e.VertexData=ze,e.VertexElements=De,e.View=class{constructor(e,t){S(this),this.scene=e,this.createMatrices(),this.zoom=null,this.center=null,this.bounds=null,this.meters_per_pixel=null,this.panning=!1,this.panning_stop_at=0,this.pan_snap_timer=0,this.zoom_direction=0,this.user_input_at=0,this.user_input_timeout=50,this.user_input_active=!1,this.size={css:{},device:{},meters:{}},this.aspect=null,this.buffer=0,this.continuous_zoom="boolean"!=typeof t.continuousZoom||t.continuousZoom,this.wrap=!1!==t.wrapView,this.preserve_tiles_within_zoom=1,this.reset()}reset(){this.createCamera()}createCamera(){let e=this.getActiveCamera();e&&(this.camera=sr.create(e,this,this.scene.config.cameras[e]),this.camera.updateView())}getActiveCamera(){if(this.scene.config&&this.scene.config.cameras){for(let e in this.scene.config.cameras)if(this.scene.config.cameras[e].active)return e;let e=Object.keys(this.scene.config.cameras);return e.length&&e[0]}}setActiveCamera(e){let t=this.getActiveCamera();return t===e?e:(this.scene.config.cameras[e]&&(this.scene.config.cameras[e].active=!0,t&&this.scene.config.cameras[t]&&delete this.scene.config.cameras[t].active),this.scene.updateConfig({rebuild:!1,normalize:!1}),this.getActiveCamera())}update(){null!=this.camera&&this.ready()&&this.camera.update(),this.pan_snap_timer=(+new Date-this.panning_stop_at)/1e3,this.user_input_active=+new Date-this.user_input_at<this.user_input_timeout}setViewportSize(e,t){this.size.css={width:e,height:t},this.size.device={width:Math.round(this.size.css.width*_.device_pixel_ratio),height:Math.round(this.size.css.height*_.device_pixel_ratio)},this.aspect=this.size.css.width/this.size.css.height,this.updateBounds()}setView({lng:e,lat:t,zoom:n}={}){var r=!1;return"number"==typeof e&&"number"==typeof t&&(this.center&&e===this.center.lng&&t===this.center.lat||(r=!0,this.center={lng:e,lat:t})),"number"==typeof n&&n!==this.zoom&&(r=!0,this.setZoom(n)),r&&this.updateBounds(),r}setZoom(e){let t=this.tile_zoom,n=this.baseZoom(e);this.continuous_zoom||(e=n),n!==t&&(this.zoom_direction=n>t?1:-1),this.zoom=e,this.tile_zoom=n,this.updateBounds(),this.scene.requestRedraw()}baseZoom(e){return Math.floor(e)}setPanning(e){this.panning=e,this.panning||(this.panning_stop_at=+new Date)}markUserInput(){this.user_input_at=+new Date}ready(){return"number"==typeof this.size.css.width&&"number"==typeof this.size.css.height&&null!=this.center&&"number"==typeof this.zoom}updateBounds(){if(!this.ready())return;this.meters_per_pixel=G.metersPerPixel(this.zoom),this.size.meters={x:this.size.css.width*this.meters_per_pixel,y:this.size.css.height*this.meters_per_pixel};const e=G.latLngToMeters([this.center.lng,this.center.lat]);this.center.meters={x:e[0],y:e[1]},this.center.tile=G.tileForMeters([this.center.meters.x,this.center.meters.y],this.tile_zoom),this.bounds={sw:{x:this.center.meters.x-this.size.meters.x/2,y:this.center.meters.y-this.size.meters.y/2},ne:{x:this.center.meters.x+this.size.meters.x/2,y:this.center.meters.y+this.size.meters.y/2}},this.scene.tile_manager.updateTilesForView(),this.trigger("move"),this.scene.requestRedraw()}findVisibleTileCoordinates(){if(!this.bounds)return[];let e=this.tile_zoom,t=G.tileForMeters([this.bounds.sw.x,this.bounds.sw.y],e),n=G.tileForMeters([this.bounds.ne.x,this.bounds.ne.y],e),r=[t.x-this.buffer,n.x+this.buffer,n.y-this.buffer,t.y+this.buffer];if(!1===this.wrap){let t=(1<<e)-1;r=r.map(e=>Math.min(Math.max(0,e),t))}let i=[];for(let t=r[0];t<=r[1];t++)for(let n=r[2];n<=r[3];n++)i.push(Te.coord({x:t,y:n,z:e}));return i}pruneTilesForView(){this.ready()&&this.scene.tile_manager.removeTiles(e=>{if(e.visible||e.isProxy())return!1;if(e.loading&&e.style_z!==this.tile_zoom)return!0;if(Math.abs(e.style_z-this.tile_zoom)>(null!=e.preserve_tiles_within_zoom?e.preserve_tiles_within_zoom:this.preserve_tiles_within_zoom))return!0;const t=this.meters_per_pixel*G.tile_size,n=Te.coordAtZoom(G.tileForMeters([this.center.meters.x-this.size.meters.x/2-t,this.center.meters.y+this.size.meters.y/2+t],this.tile_zoom),e.coords.z),r=Te.coordAtZoom(G.tileForMeters([this.center.meters.x+this.size.meters.x/2+t,this.center.meters.y-this.size.meters.y/2-t],this.tile_zoom),e.coords.z);return(e.coords.x<n.x||e.coords.x>r.x||e.coords.y<n.y||e.coords.y>r.y)&&(m("trace",`View: remove tile ${e.key} (as ${e.coords.key}) for being too far out of visible area (${n.key}, ${r.key})`),!0)})}createMatrices(){this.matrices={},this.matrices.model=new Float64Array(16),this.matrices.model32=new Float32Array(16),this.matrices.model_view=new Float64Array(16),this.matrices.model_view32=new Float32Array(16),this.matrices.normal=new Float64Array(9),this.matrices.normal32=new Float32Array(9),this.matrices.inverse_normal32=new Float32Array(9)}setupTile(e,t){e.setupProgram(this.matrices,t),this.camera.setupMatrices(this.matrices,t)}setupProgram(e){e.uniform("2fv","u_resolution",[this.size.device.width,this.size.device.height]),e.uniform("3fv","u_map_position",[this.center.meters.x,this.center.meters.y,this.zoom]),e.uniform("1f","u_meters_per_pixel",this.meters_per_pixel),e.uniform("1f","u_device_pixel_ratio",_.device_pixel_ratio),e.uniform("1f","u_view_pan_snap_timer",this.pan_snap_timer),e.uniform("1i","u_view_panning",this.panning),this.camera.setupProgram(e)}isAnimating(){return this.pan_snap_timer<=.5}},e.WorkerBroker=a,e._defineProperty=i,e.addBaseURL=function(e,t){if(!e||!x(e))return e;var n,r="/"!==e[0];if(t?(n=document.createElement("a")).href=t:n=window.location,r)e=b(n.href)+e;else{let t=n.origin;t||(t=n.protocol+"//"+n.host),e=t+e}return e},e.buildFilter=jr,e.cache=W,e.clearFunctionStringCache=function(){W.functions={},W.num_functions=0,W.num_cached=0},e.compileFunctionStrings=Z,e.createObjectURL=function(e){return void 0===w&&(w=window.URL&&window.URL.createObjectURL||window.webkitURL&&window.webkitURL.createObjectURL,"function"!=typeof w&&(w=null,m("warn","window.URL.createObjectURL (or vendor prefix) not found, unable to create local blob URLs"))),w?w(e):e},e.debugSettings=v,e.debugSumLayerStats=function(e){let t={},n={};return e.filter(e=>e.debug.layers).forEach(e=>{Object.keys(e.debug.layers.list).forEach(n=>{let r=e.debug.layers.list[n];Me(t,n,r.features,r.geoms,r.styles,r.base)}),ni(e.debug.layers.tree,n)}),{list:t,tree:n}},e.extensionForURL=function(e){let t=(e=e.split("/").pop()).lastIndexOf(".");if(t>-1)return e.substring(t+1)},e.flattenRelativeURL=function(e){let t=(e||"").split("/");for(let e=1;e<t.length;e++)"."===t[e]?(t.splice(e,1),e--):".."===t[e]&&(e+=0,t.splice(e-1,2),e--);return t.join("/")},e.getAugmentedNamespace=function(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n},e.getDefaultExportFromCjs=M,e.isLocalURL=function(e){if("string"==typeof e)return e.search(/^(data|blob):/)>-1},e.isRelativeURL=x,e.isReserved=Zr,e.layerCache=function(){return Ur},e.log=m,e.mergeDebugSettings=function(e){Object.assign(y,e)},e.mergeObjects=B,e.parseLayers=function(e,t){Ur={};let n={};for(let r in e){let i=e[r];i&&(n[r]=Kr(r,i,null,t))}return n},e.pathForURL=b,e.sliceObject=T,e.subscribeMixin=S,e.version=o}),sx(0,function(e){const t=Object.assign(self,{FeatureSelection:e.FeatureSelection,sources:{},styles:{},layers:{},tiles:{},init(t,n,r,i,s,o,a){return this.scene_id=t,this._worker_id=n,this.num_workers=r,e.log.setLevel(i),e.Utils.device_pixel_ratio=s,e.VertexElements.setElementIndexUint(o),e.FeatureSelection.setPrefix(this._worker_id),this.style_manager=new e.StyleManager,this.importExternalScripts(a),e.Label.id_prefix=n,e.Label.id_multiplier=r,n},importExternalScripts(t){if(0===t.length)return;e.log("debug","loading custom data source scripts in worker:",t);let n=Object.getOwnPropertyNames(window);importScripts(...t),Object.getOwnPropertyNames(window).forEach(e=>{-1===n.indexOf(e)&&(this[e]=window[e])})},updateConfig({config:t,generation:n,introspection:r},i){return t=JSON.parse(t),e.mergeDebugSettings(i),this.generation=n,this.introspection=r,this.global=e.compileFunctionStrings(t.global),this.createDataSources(t),t.styles=e.compileFunctionStrings(t.styles,e.StyleParser.wrapFunction),this.styles=this.style_manager.build(t.styles),this.style_manager.initStyles({generation:this.generation,styles:this.styles,sources:this.sources,introspection:this.introspection}),this.layers=e.parseLayers(t.layers,this.style_manager.styles),this.syncing_textures=this.syncTextures(t.textures),this.configuring=this.syncing_textures.then(()=>{e.log("debug","updated config")}),this.configuring},createDataSources(t){this.last_config_sources=this.config_sources||{},this.config_sources=e.mergeObjects({},t.sources);let n=this.sources,r=[];this.sources={};for(let i in t.sources){if(JSON.stringify(this.last_config_sources[i])===JSON.stringify(t.sources[i])){this.sources[i]=n[i];continue}let s;t.sources[i]=e.compileFunctionStrings(t.sources[i]);try{s=e.DataSource.create(Object.assign({},t.sources[i],{name:i}),this.sources)}catch(e){continue}s&&(this.sources[i]=s,r.push(i))}r.forEach(e=>{for(let t in this.tiles)this.tiles[t].source===e&&delete this.tiles[t]})},awaitConfiguration(){return this.configuring},buildTile({tile:t}){if(null==this.getTile(t.key)||!0!==this.getTile(t.key).loading)return t=this.tiles[t.key]=Object.assign(this.getTile(t.key)||{},t),this.awaitConfiguration().then(()=>{if(!0!==t.loaded)t.loading=!0,t.loaded=!1,t.error=null,this.loadTileSourceData(t).then(()=>{this.getTile(t.key)?(t.source_data.error&&e.log("warn",`tile load error(s) for ${t.key}: ${t.source_data.error}`),t.loading=!1,t.loaded=!0,e.Tile.buildGeometry(t,this)):e.log("trace",`stop tile build after data source load because tile was removed: ${t.key}`)}).catch(n=>{t.loading=!1,t.loaded=!1,t.error=n.stack,e.log("error",`tile load error for ${t.key}: ${t.error}`),e.WorkerBroker.postMessage(`TileManager_${this.scene_id}.buildTileError`,e.Tile.slice(t))});else{e.log("trace",`used worker cache for tile ${t.key}`);try{e.Tile.buildGeometry(t,this)}catch(n){t.error=n.toString(),e.WorkerBroker.postMessage(`TileManager_${this.scene_id}.buildTileError`,e.Tile.slice(t))}}})},loadTileSourceData(e){const t=this.sources[e.source];if(t){for(const n in this.tiles){const r=this.tiles[n];if(r.source===e.source&&r.coords.key===e.coords.key&&r.loaded)return Promise.resolve(t.copyTileData(r,e))}return t.load(e)}return e.source_data={},Promise.resolve(e)},getTile(e){return this.tiles[e]},removeTile(t){var n=this.tiles[t];null!=n&&(!0===n.loading&&(e.log("trace",`cancel tile load for ${t}`),n.loading=!1,e.Tile.cancel(n)),e.FeatureSelection.clearTile(t),delete this.tiles[t],e.log("trace",`remove tile from cache for ${t}`))},queryFeatures({filter:t,visible:n,geometry:r,tile_keys:i}){let s=[],o=i.map(e=>this.tiles[e]).filter(e=>e&&e.loaded);return null!=t&&(t=["{","["].indexOf(t[0])>-1?JSON.parse(t):t,t=e.compileFunctionStrings(t,e.StyleParser.wrapFunction)),t=e.buildFilter(t,e.FilterOptions),o.forEach(i=>{for(let o in i.source_data.layers){let a=i.source_data.layers[o];if(null==a)return;a.features.forEach(a=>{const l=a.generation===this.generation;if(!0===n&&!l||!1===n&&l)return;let u=e.StyleParser.getFeatureParseContext(a,i,this.global);if(u.source=i.source,u.layer=o,u.id=a.id,!t(u))return;let c={type:a.type,id:a.id,properties:Object.assign({},a.properties,{$source:u.source,$layer:u.layer,$geometry:u.geometry,$visible:l})};!0===r&&(c.geometry=e.Geo.copyGeometry(a.geometry),e.Geo.tileSpaceToLatlng(c.geometry,i.coords.z,i.min)),s.push(c)})}}),s},getFeatureSelection({id:t,key:n}={}){var r=e.FeatureSelection.map[n];return{id:t,feature:r&&r.feature}},resetFeatureSelection(t=null){e.FeatureSelection.reset(t)},getFeatureSelectionMapSize:()=>e.FeatureSelection.getMapSize(),syncTextures(t){let n=[];return t&&n.push(...Object.keys(t)),e.log("trace","sync textures to worker:",n),n.length>0?e.Texture.syncTexturesToWorker(n):Promise.resolve()},updateDevicePixelRatio(t){e.Utils.device_pixel_ratio=t},clearFunctionStringCache(){e.clearFunctionStringCache()},profile(e){console.profile(`worker ${this._worker_id}: ${e}`)},profileEnd(e){console.profileEnd(`worker ${this._worker_id}: ${e}`)},debug:{debugSettings:e.debugSettings,layerCache:e.layerCache,functionStringCache:e.cache}});e.WorkerBroker.addTarget("self",t)}),sx(0,function(e){var t,n=t={};let r=0;function i(e,t){var n;const r=t[t.length-1];return null===(n=o(e,t))||void 0===n?void 0:n[r]}function s(e,t,n){const r=t[t.length-1],i=o(e,t);i&&(i[r]=n)}function o(e,t){if(0===t.length)return;let n=e;for(let e=0;e<t.length-1;e++)if(n=n[t[e]],null==n)return;return n}t.getContext=function(e,n){var i=!1;null==e&&((e=document.createElement("canvas")).style.position="absolute",e.style.top=0,e.style.left=0,e.style.zIndex=-1,document.body.appendChild(e),i=!0),e.addEventListener("webglcontextlost",()=>{}),e.addEventListener("webglcontextrestored",()=>{});var s=e.getContext("webgl",n)||e.getContext("experimental-webgl",n);if(!s)throw new Error("Couldn't create WebGL context.");return s._tangram_id=r++,i?(t.resize(s,window.innerWidth,window.innerHeight,n.device_pixel_ratio),window.addEventListener("resize",function(){t.resize(s,window.innerWidth,window.innerHeight,n.device_pixel_ratio)})):t.resize(s,parseFloat(e.style.width),parseFloat(e.style.height),n.device_pixel_ratio),s},t.resize=function(e,t,n,r){r=r||window.devicePixelRatio||1,e.canvas.style.width=t+"px",e.canvas.style.height=n+"px",e.canvas.width=Math.round(t*r),e.canvas.height=Math.round(n*r),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,e.canvas.width,e.canvas.height)};const a="global.",l="__global_prop";function u(e){return(null==e?void 0:e.slice(0,7))===a}function c(e,t){var n;const r=Array.isArray(t)?t:[t],i=o(e,r),s=r[r.length-1];return void 0!==(null==i||null===(n=i[l])||void 0===n?void 0:n[s])}function h(e,t=null,n={}){t=t?t+".":a;for(const r in e){const i=t+r,s=e[r];n[i]=s,"object"!=typeof s||Array.isArray(s)||h(s,i,n)}return n}function d(t,n,r,i){var s;let o;if(null!=r&&null!==(s=r[l])&&void 0!==s&&s[i]?o=r[l][i]:"string"==typeof n&&n.slice(0,7)===a&&(o=n),o){null==r[l]&&Object.defineProperty(r,l,{value:{}}),r[l][i]=o;let n,s=t[o];for(;"string"==typeof s&&s.slice(0,7)===a;){if(n=n||[o],n.indexOf(s)>-1){e.log({level:"warn",once:!0},"Global properties: cyclical reference detected",n),s=null;break}n.push(s),s=t[s]}Object.defineProperty(r,i,{enumerable:!0,get:function(){return s},set:function(e){delete r[l][i],delete r[i],r[i]=e}})}else if(Array.isArray(n))for(let e=0;e<n.length;e++)d(t,n[e],n,e);else if("object"==typeof n)for(const e in n)d(t,n[e],n,e);return n}var f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},p=[],g=[],m="undefined"!=typeof Uint8Array?Uint8Array:Array,_=!1;function y(){_=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)p[t]=e[t],g[e.charCodeAt(t)]=t;g["-".charCodeAt(0)]=62,g["_".charCodeAt(0)]=63}function v(e,t,n){for(var r,i,s=[],o=t;o<n;o+=3)r=(e[o]<<16)+(e[o+1]<<8)+e[o+2],s.push(p[(i=r)>>18&63]+p[i>>12&63]+p[i>>6&63]+p[63&i]);return s.join("")}function b(e){var t;_||y();for(var n=e.length,r=n%3,i="",s=[],o=16383,a=0,l=n-r;a<l;a+=o)s.push(v(e,a,a+o>l?l:a+o));return 1===r?(t=e[n-1],i+=p[t>>2],i+=p[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=p[t>>10],i+=p[t>>4&63],i+=p[t<<2&63],i+="="),s.push(i),s.join("")}function x(e,t,n,r,i){var s,o,a=8*i-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+e[t+h],h+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=256*o+e[t+h],h+=d,c-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),s-=u}return(f?-1:1)*o*Math.pow(2,s-r)}function w(e,t,n,r,i,s){var o,a,l,u=8*s-i-1,c=(1<<u)-1,h=c>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:s-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(t*l-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[n+f]=255&o,f+=p,o/=256,u-=8);e[n+f-p]|=128*g}var A={}.toString,E=Array.isArray||function(e){return"[object Array]"==A.call(e)};O.TYPED_ARRAY_SUPPORT=void 0===f.TYPED_ARRAY_SUPPORT||f.TYPED_ARRAY_SUPPORT;var S=T();function T(){return O.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function k(e,t){if(T()<t)throw new RangeError("Invalid typed array length");return O.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=O.prototype:(null===e&&(e=new O(t)),e.length=t),e}function O(e,t,n){if(!(O.TYPED_ARRAY_SUPPORT||this instanceof O))return new O(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return P(this,e)}return R(this,e,t,n)}function R(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),O.TYPED_ARRAY_SUPPORT?(e=t).__proto__=O.prototype:e=M(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!O.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|D(t,n),i=(e=k(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(I(t)){var n=0|N(t.length);return 0===(e=k(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?k(e,0):M(e,t);if("Buffer"===t.type&&E(t.data))return M(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function C(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function P(e,t){if(C(t),e=k(e,t<0?0:0|N(t)),!O.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function M(e,t){var n=t.length<0?0:0|N(t.length);e=k(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function N(e){if(e>=T())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+T().toString(16)+" bytes");return 0|e}function I(e){return!(null==e||!e._isBuffer)}function D(e,t){if(I(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return le(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return ue(e).length;default:if(r)return le(e).length;t=(""+t).toLowerCase(),r=!0}}function F(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Y(this,t,n);case"utf8":case"utf-8":return W(this,t,n);case"ascii":return K(this,t,n);case"latin1":case"binary":return X(this,t,n);case"base64":return H(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function z(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function L(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=O.from(t,r)),I(t))return 0===t.length?-1:j(e,t,n,r,i);if("number"==typeof t)return t&=255,O.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):j(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function j(e,t,n,r,i){var s,o=1,a=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var c=-1;for(s=n;s<a;s++)if(u(e,s)===u(t,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===l)return c*o}else-1!==c&&(s-=s-c),c=-1}else for(n+l>a&&(n=a-l),s=n;s>=0;s--){for(var h=!0,d=0;d<l;d++)if(u(e,s+d)!==u(t,d)){h=!1;break}if(h)return s}return-1}function V(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[n+o]=a}return o}function U(e,t,n,r){return ce(le(t,e.length-n),e,n,r)}function B(e,t,n,r){return ce(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function G(e,t,n,r){return B(e,t,n,r)}function $(e,t,n,r){return ce(ue(t),e,n,r)}function q(e,t,n,r){return ce(function(e,t){for(var n,r,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(n=e.charCodeAt(o))>>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function H(e,t,n){return 0===t&&n===e.length?b(e):b(e.slice(t,n))}function W(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,l,u=e[i],c=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(c=u);break;case 2:128==(192&(s=e[i+1]))&&(l=(31&u)<<6|63&s)>127&&(c=l);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(l=(15&u)<<12|(63&s)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=h}return function(e){var t=e.length;if(t<=Z)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Z));return n}(r)}O.poolSize=8192,O._augment=function(e){return e.__proto__=O.prototype,e},O.from=function(e,t,n){return R(null,e,t,n)},O.TYPED_ARRAY_SUPPORT&&(O.prototype.__proto__=Uint8Array.prototype,O.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&O[Symbol.species]),O.alloc=function(e,t,n){return function(e,t,n,r){return C(t),t<=0?k(e,t):void 0!==n?"string"==typeof r?k(e,t).fill(n,r):k(e,t).fill(n):k(e,t)}(null,e,t,n)},O.allocUnsafe=function(e){return P(null,e)},O.allocUnsafeSlow=function(e){return P(null,e)},O.isBuffer=he,O.compare=function(e,t){if(!I(e)||!I(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},O.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},O.concat=function(e,t){if(!E(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return O.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=O.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!I(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},O.byteLength=D,O.prototype._isBuffer=!0,O.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)z(this,t,t+1);return this},O.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)z(this,t,t+3),z(this,t+1,t+2);return this},O.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)z(this,t,t+7),z(this,t+1,t+6),z(this,t+2,t+5),z(this,t+3,t+4);return this},O.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?W(this,0,e):F.apply(this,arguments)},O.prototype.equals=function(e){if(!I(e))throw new TypeError("Argument must be a Buffer");return this===e||0===O.compare(this,e)},O.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},O.prototype.compare=function(e,t,n,r,i){if(!I(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(s,o),l=this.slice(r,i),u=e.slice(t,n),c=0;c<a;++c)if(l[c]!==u[c]){s=l[c],o=u[c];break}return s<o?-1:o<s?1:0},O.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},O.prototype.indexOf=function(e,t,n){return L(this,e,t,n,!0)},O.prototype.lastIndexOf=function(e,t,n){return L(this,e,t,n,!1)},O.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return V(this,e,t,n);case"utf8":case"utf-8":return U(this,e,t,n);case"ascii":return B(this,e,t,n);case"latin1":case"binary":return G(this,e,t,n);case"base64":return $(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},O.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;function K(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function X(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function Y(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=t;s<n;++s)i+=ae(e[s]);return i}function Q(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function J(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function ee(e,t,n,r,i,s){if(!I(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function te(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function ne(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function re(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ie(e,t,n,r,i){return i||re(e,0,n,4),w(e,t,n,r,23,4),n+4}function se(e,t,n,r,i){return i||re(e,0,n,8),w(e,t,n,r,52,8),n+8}O.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),O.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=O.prototype;else{var i=t-e;n=new O(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+e]}return n},O.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||J(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},O.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||J(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},O.prototype.readUInt8=function(e,t){return t||J(e,1,this.length),this[e]},O.prototype.readUInt16LE=function(e,t){return t||J(e,2,this.length),this[e]|this[e+1]<<8},O.prototype.readUInt16BE=function(e,t){return t||J(e,2,this.length),this[e]<<8|this[e+1]},O.prototype.readUInt32LE=function(e,t){return t||J(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},O.prototype.readUInt32BE=function(e,t){return t||J(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},O.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||J(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},O.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||J(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},O.prototype.readInt8=function(e,t){return t||J(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},O.prototype.readInt16LE=function(e,t){t||J(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},O.prototype.readInt16BE=function(e,t){t||J(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},O.prototype.readInt32LE=function(e,t){return t||J(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},O.prototype.readInt32BE=function(e,t){return t||J(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},O.prototype.readFloatLE=function(e,t){return t||J(e,4,this.length),x(this,e,!0,23,4)},O.prototype.readFloatBE=function(e,t){return t||J(e,4,this.length),x(this,e,!1,23,4)},O.prototype.readDoubleLE=function(e,t){return t||J(e,8,this.length),x(this,e,!0,52,8)},O.prototype.readDoubleBE=function(e,t){return t||J(e,8,this.length),x(this,e,!1,52,8)},O.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||ee(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s<n&&(i*=256);)this[t+s]=e/i&255;return t+n},O.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||ee(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},O.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,1,255,0),O.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},O.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,65535,0),O.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):te(this,e,t,!0),t+2},O.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,65535,0),O.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):te(this,e,t,!1),t+2},O.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,4294967295,0),O.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ne(this,e,t,!0),t+4},O.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,4294967295,0),O.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},O.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);ee(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o|0)-a&255;return t+n},O.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);ee(this,e,t,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o|0)-a&255;return t+n},O.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,1,127,-128),O.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},O.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,32767,-32768),O.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):te(this,e,t,!0),t+2},O.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,32767,-32768),O.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):te(this,e,t,!1),t+2},O.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,2147483647,-2147483648),O.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ne(this,e,t,!0),t+4},O.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),O.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},O.prototype.writeFloatLE=function(e,t,n){return ie(this,e,t,!0,n)},O.prototype.writeFloatBE=function(e,t,n){return ie(this,e,t,!1,n)},O.prototype.writeDoubleLE=function(e,t,n){return se(this,e,t,!0,n)},O.prototype.writeDoubleBE=function(e,t,n){return se(this,e,t,!1,n)},O.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,s=r-n;if(this===e&&n<t&&t<r)for(i=s-1;i>=0;--i)e[i+t]=this[i+n];else if(s<1e3||!O.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},O.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!O.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var o=I(e)?e:le(new O(e,r).toString()),a=o.length;for(s=0;s<n-t;++s)this[s+t]=o[s%a]}return this};var oe=/[^+\/0-9A-Za-z-_]/g;function ae(e){return e<16?"0"+e.toString(16):e.toString(16)}function le(e,t){var n;t=t||1/0;for(var r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function ue(e){return function(e){var t,n,r,i,s,o;_||y();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===e[a-2]?2:"="===e[a-1]?1:0,o=new m(3*a/4-s),r=s>0?a-4:a;var l=0;for(t=0,n=0;t<r;t+=4,n+=3)i=g[e.charCodeAt(t)]<<18|g[e.charCodeAt(t+1)]<<12|g[e.charCodeAt(t+2)]<<6|g[e.charCodeAt(t+3)],o[l++]=i>>16&255,o[l++]=i>>8&255,o[l++]=255&i;return 2===s?(i=g[e.charCodeAt(t)]<<2|g[e.charCodeAt(t+1)]>>4,o[l++]=255&i):1===s&&(i=g[e.charCodeAt(t)]<<10|g[e.charCodeAt(t+1)]<<4|g[e.charCodeAt(t+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(oe,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function ce(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function he(e){return null!=e&&(!!e._isBuffer||de(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&de(e.slice(0,0))}(e))}function de(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var fe=Object.freeze({__proto__:null,Buffer:O,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),O.alloc(+e)},isBuffer:he,kMaxLength:S});function pe(){throw new Error("setTimeout has not been defined")}function ge(){throw new Error("clearTimeout has not been defined")}var me=pe,_e=ge;function ye(e){if(me===setTimeout)return setTimeout(e,0);if((me===pe||!me)&&setTimeout)return me=setTimeout,setTimeout(e,0);try{return me(e,0)}catch(t){try{return me.call(null,e,0)}catch(t){return me.call(this,e,0)}}}"function"==typeof f.setTimeout&&(me=setTimeout),"function"==typeof f.clearTimeout&&(_e=clearTimeout);var ve,be=[],xe=!1,we=-1;function Ae(){xe&&ve&&(xe=!1,ve.length?be=ve.concat(be):we=-1,be.length&&Ee())}function Ee(){if(!xe){var e=ye(Ae);xe=!0;for(var t=be.length;t;){for(ve=be,be=[];++we<t;)ve&&ve[we].run();we=-1,t=be.length}ve=null,xe=!1,function(e){if(_e===clearTimeout)return clearTimeout(e);if((_e===ge||!_e)&&clearTimeout)return _e=clearTimeout,clearTimeout(e);try{return _e(e)}catch(t){try{return _e.call(null,e)}catch(t){return _e.call(this,e)}}}(e)}}function Se(e,t){this.fun=e,this.array=t}Se.prototype.run=function(){this.fun.apply(null,this.array)};var Te=f.performance||{};function ke(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}Te.now||Te.mozNow||Te.msNow||Te.oNow||Te.webkitNow;var Oe,Re,Ce,Pe,Me,Ne,Ie,De,Fe,ze,Le,je,Ve,Ue,Be,Ge,$e,qe,He,We,Ze,Ke,Xe,Ye,Qe,Je,et,tt,nt,rt,it,st,ot,at,lt={exports:{}},ut=(Oe||(Oe=1,lt.exports=function e(t,n,r){function i(o,a){if(!n[o]){if(!t[o]){if(!a&&ke)return ke(o);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var s=ke,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){var r=e("./utils"),i=e("./support"),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(e){for(var t,n,i,o,a,l,u,c=[],h=0,d=e.length,f=d,p="string"!==r.getTypeOf(e);h<e.length;)f=d-h,i=p?(t=e[h++],n=h<d?e[h++]:0,h<d?e[h++]:0):(t=e.charCodeAt(h++),n=h<d?e.charCodeAt(h++):0,h<d?e.charCodeAt(h++):0),o=t>>2,a=(3&t)<<4|n>>4,l=1<f?(15&n)<<2|i>>6:64,u=2<f?63&i:64,c.push(s.charAt(o)+s.charAt(a)+s.charAt(l)+s.charAt(u));return c.join("")},n.decode=function(e){var t,n,r,o,a,l,u=0,c=0,h="data:";if(e.substr(0,5)===h)throw new Error("Invalid base64 input, it looks like a data url.");var d,f=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===s.charAt(64)&&f--,e.charAt(e.length-2)===s.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=i.uint8array?new Uint8Array(0|f):new Array(0|f);u<e.length;)t=s.indexOf(e.charAt(u++))<<2|(o=s.indexOf(e.charAt(u++)))>>4,n=(15&o)<<4|(a=s.indexOf(e.charAt(u++)))>>2,r=(3&a)<<6|(l=s.indexOf(e.charAt(u++))),d[c++]=t,64!==a&&(d[c++]=n),64!==l&&(d[c++]=r);return d}},{"./support":30,"./utils":32}],2:[function(e,t,n){var r=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");function a(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}a.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,n){return e.pipe(new s).pipe(new o("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){var r=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,n){var r=i,s=0+n;e^=-1;for(var o=0;o<s;o++)e=e>>>8^r[255&(e^t[o])];return~e}(0|t,e,e.length):function(e,t,n){var r=i,s=0+n;e^=-1;for(var o=0;o<s;o++)e=e>>>8^r[255&(e^t.charCodeAt(o))];return~e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),o=e("./stream/GenericWorker"),a=r?"uint8array":"array";function l(e,t){o.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",s.inherits(l,o),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(a,e.data),!1)},l.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){function r(e,t){var n,r="";for(n=0;n<t;n++)r+=String.fromCharCode(255&e),e>>>=8;return r}function i(e,t,n,i,o,c){var h,d,f=e.file,p=e.compression,g=c!==a.utf8encode,m=s.transformTo("string",c(f.name)),_=s.transformTo("string",a.utf8encode(f.name)),y=f.comment,v=s.transformTo("string",c(y)),b=s.transformTo("string",a.utf8encode(y)),x=_.length!==f.name.length,w=b.length!==y.length,A="",E="",S="",T=f.dir,k=f.date,O={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(O.crc32=e.crc32,O.compressedSize=e.compressedSize,O.uncompressedSize=e.uncompressedSize);var R=0;t&&(R|=8),g||!x&&!w||(R|=2048);var C=0,P=0;T&&(C|=16),"UNIX"===o?(P=798,C|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(f.unixPermissions,T)):(P=20,C|=function(e){return 63&(e||0)}(f.dosPermissions)),h=k.getUTCHours(),h<<=6,h|=k.getUTCMinutes(),h<<=5,h|=k.getUTCSeconds()/2,d=k.getUTCFullYear()-1980,d<<=4,d|=k.getUTCMonth()+1,d<<=5,d|=k.getUTCDate(),x&&(E=r(1,1)+r(l(m),4)+_,A+="up"+r(E.length,2)+E),w&&(S=r(1,1)+r(l(v),4)+b,A+="uc"+r(S.length,2)+S);var M="";return M+="\n\0",M+=r(R,2),M+=p.magic,M+=r(h,2),M+=r(d,2),M+=r(O.crc32,4),M+=r(O.compressedSize,4),M+=r(O.uncompressedSize,4),M+=r(m.length,2),M+=r(A.length,2),{fileRecord:u.LOCAL_FILE_HEADER+M+m+A,dirRecord:u.CENTRAL_FILE_HEADER+r(P,2)+M+r(v.length,2)+"\0\0\0\0"+r(C,4)+r(i,4)+m+A+v}}var s=e("../utils"),o=e("../stream/GenericWorker"),a=e("../utf8"),l=e("../crc32"),u=e("../signature");function c(e,t,n,r){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(c,o),c.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},c.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},c.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return u.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},c.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var n=this.bytesWritten-e,i=function(e,t,n,i,o){var a=s.transformTo("string",o(i));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(e,2)+r(e,2)+r(t,4)+r(n,4)+r(a.length,2)+a}(this.dirRecords.length,n,e,this.zipComment,this.encodeFileName);this.push({data:i,meta:{percent:100}})},c.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},c.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(e){t.error(e)}),this},c.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},c.prototype.error=function(e){var t=this._sources;if(!o.prototype.error.call(this,e))return!1;for(var n=0;n<t.length;n++)try{t[n].error(e)}catch(e){}return!0},c.prototype.lock=function(){o.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=c},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,n){var r=e("../compressions"),i=e("./ZipFileWorker");n.generateWorker=function(e,t,n){var s=new i(t.streamFiles,n,t.platform,t.encodeFileName),o=0;try{e.forEach(function(e,n){o++;var i=function(e,t){var n=e||t,i=r[n];if(!i)throw new Error(n+" is not a valid compression method !");return i}(n.options.compression,t.compression),a=n.options.compressionOptions||t.compressionOptions||{},l=n.dir,u=n.date;n._compressWorker(i,a).withStreamInfo("file",{name:e,dir:l,date:u,comment:n.comment||"",unixPermissions:n.unixPermissions,dosPermissions:n.dosPermissions}).pipe(s)}),s.entriesCount=o}catch(e){s.error(e)}return s}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,n){function r(){if(!(this instanceof r))return new r;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new r;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(r.prototype=e("./object")).loadAsync=e("./load"),r.support=e("./support"),r.defaults=e("./defaults"),r.version="3.10.1",r.loadAsync=function(e,t){return(new r).loadAsync(e,t)},r.external=e("./external"),t.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,n){var r=e("./utils"),i=e("./external"),s=e("./utf8"),o=e("./zipEntries"),a=e("./stream/Crc32Probe"),l=e("./nodejsUtils");function u(e){return new i.Promise(function(t,n){var r=e.decompressed.getContentWorker().pipe(new a);r.on("error",function(e){n(e)}).on("end",function(){r.streamInfo.crc32!==e.decompressed.crc32?n(new Error("Corrupted zip : CRC32 mismatch")):t()}).resume()})}t.exports=function(e,t){var n=this;return t=r.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:s.utf8decode}),l.isNode&&l.isStream(e)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then(function(e){var n=new o(t);return n.load(e),n}).then(function(e){var n=[i.Promise.resolve(e)],r=e.files;if(t.checkCRC32)for(var s=0;s<r.length;s++)n.push(u(r[s]));return i.Promise.all(n)}).then(function(e){for(var i=e.shift(),s=i.files,o=0;o<s.length;o++){var a=s[o],l=a.fileNameStr,u=r.resolve(a.fileNameStr);n.file(u,a.decompressed,{binary:!0,optimizedBinaryString:!0,date:a.date,dir:a.dir,comment:a.fileCommentStr.length?a.fileCommentStr:null,unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions,createFolders:t.createFolders}),a.dir||(n.file(u).unsafeOriginalName=l)}return i.zipComment.length&&(n.comment=i.zipComment),n})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,n){var r=e("../utils"),i=e("../stream/GenericWorker");function s(e,t){i.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}r.inherits(s,i),s.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",function(e){t.push({data:e,meta:{percent:0}})}).on("error",function(e){t.isPaused?this.generatedError=e:t.error(e)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})},s.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,n){var r=e("readable-stream").Readable;function i(e,t,n){r.call(this,t),this._helper=e;var i=this;e.on("data",function(e,t){i.push(e)||i._helper.pause(),n&&n(t)}).on("error",function(e){i.emit("error",e)}).on("end",function(){i.push(null)})}e("../utils").inherits(i,r),i.prototype._read=function(){this._helper.resume()},t.exports=i},{"../utils":32,"readable-stream":16}],14:[function(e,t,n){t.exports={isNode:void 0!==O,newBufferFrom:function(e,t){if(O.from&&O.from!==Uint8Array.from)return O.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new O(e,t)},allocBuffer:function(e){if(O.alloc)return O.alloc(e);var t=new O(e);return t.fill(0),t},isBuffer:function(e){return he(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,n){function r(e,t,n){var r,i=s.getTypeOf(t),a=s.extend(n||{},l);a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),"string"==typeof a.unixPermissions&&(a.unixPermissions=parseInt(a.unixPermissions,8)),a.unixPermissions&&16384&a.unixPermissions&&(a.dir=!0),a.dosPermissions&&16&a.dosPermissions&&(a.dir=!0),a.dir&&(e=g(e)),a.createFolders&&(r=p(e))&&m.call(this,r,!0);var h="string"===i&&!1===a.binary&&!1===a.base64;n&&void 0!==n.binary||(a.binary=!h),(t instanceof u&&0===t.uncompressedSize||a.dir||!t||0===t.length)&&(a.base64=!1,a.binary=!0,t="",a.compression="STORE",i="string");var _;_=t instanceof u||t instanceof o?t:d.isNode&&d.isStream(t)?new f(e,t):s.prepareContent(e,t,a.binary,a.optimizedBinaryString,a.base64);var y=new c(e,_,a);this.files[e]=y}var i=e("./utf8"),s=e("./utils"),o=e("./stream/GenericWorker"),a=e("./stream/StreamHelper"),l=e("./defaults"),u=e("./compressedObject"),c=e("./zipObject"),h=e("./generate"),d=e("./nodejsUtils"),f=e("./nodejs/NodejsStreamInputAdapter"),p=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},g=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},m=function(e,t){return t=void 0!==t?t:l.createFolders,e=g(e),this.files[e]||r.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function _(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,n,r;for(t in this.files)r=this.files[t],(n=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(n,r)},filter:function(e){var t=[];return this.forEach(function(n,r){e(n,r)&&t.push(r)}),t},file:function(e,t,n){if(1!==arguments.length)return e=this.root+e,r.call(this,e,t,n),this;if(_(e)){var i=e;return this.filter(function(e,t){return!t.dir&&i.test(e)})}var s=this.files[this.root+e];return s&&!s.dir?s:null},folder:function(e){if(!e)return this;if(_(e))return this.filter(function(t,n){return n.dir&&e.test(t)});var t=this.root+e,n=m.call(this,t),r=this.clone();return r.root=n.name,r},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!==e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var n=this.filter(function(t,n){return n.name.slice(0,e.length)===e}),r=0;r<n.length;r++)delete this.files[n[r].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,n={};try{if((n=s.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=n.type.toLowerCase(),n.compression=n.compression.toUpperCase(),"binarystring"===n.type&&(n.type="string"),!n.type)throw new Error("No output type specified.");s.checkSupport(n.type),"darwin"!==n.platform&&"freebsd"!==n.platform&&"linux"!==n.platform&&"sunos"!==n.platform||(n.platform="UNIX"),"win32"===n.platform&&(n.platform="DOS");var r=n.comment||this.comment||"";t=h.generateWorker(this,n,r)}catch(e){(t=new o("error")).error(e)}return new a(t,n.type||"string",n.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,n){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,n){var r=e("./DataReader");function i(e){r.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data[this.zero+e]},i.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),n=e.charCodeAt(1),r=e.charCodeAt(2),i=e.charCodeAt(3),s=this.length-4;0<=s;--s)if(this.data[s]===t&&this.data[s+1]===n&&this.data[s+2]===r&&this.data[s+3]===i)return s-this.zero;return-1},i.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1),r=e.charCodeAt(2),i=e.charCodeAt(3),s=this.readData(4);return t===s[0]&&n===s[1]&&r===s[2]&&i===s[3]},i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],18:[function(e,t,n){var r=e("../utils");function i(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,n=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){var r=e("./Uint8ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){var r=e("./DataReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){var r=e("./ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){var r=e("../utils"),i=e("../support"),s=e("./ArrayReader"),o=e("./StringReader"),a=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new a(e):i.uint8array?new l(r.transformTo("uint8array",e)):new s(r.transformTo("array",e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){var r=e("./GenericWorker"),i=e("../utils");function s(e){r.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,r),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){var r=e("./GenericWorker"),i=e("../crc32");function s(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,r),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){var r=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){var r=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}r.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n<this._listeners[e].length;n++)this._listeners[e][n].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.end()}),e.on("error",function(e){t.error(e)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=r},{}],29:[function(e,t,n){var r=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),o=e("../base64"),a=e("../support"),l=e("../external"),u=null;if(a.nodestream)try{u=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function c(e,t,n){var o=t;switch(t){case"blob":case"arraybuffer":o="uint8array";break;case"base64":o="string"}try{this._internalType=o,this._outputType=t,this._mimeType=n,r.checkSupport(o),this._worker=e.pipe(new i(o)),e.lock()}catch(e){this._worker=new s("error"),this._worker.error(e)}}c.prototype={accumulate:function(e){return function(e,t){return new l.Promise(function(n,i){var s=[],a=e._internalType,l=e._outputType,u=e._mimeType;e.on("data",function(e,n){s.push(e),t&&t(n)}).on("error",function(e){s=[],i(e)}).on("end",function(){try{var e=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return o.encode(t);default:return r.transformTo(e,t)}}(l,function(e,t){var n,r=0,i=null,s=0;for(n=0;n<t.length;n++)s+=t[n].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(s),n=0;n<t.length;n++)i.set(t[n],r),r+=t[n].length;return i;case"nodebuffer":return O.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(a,s),u);n(e)}catch(e){i(e)}s=[]}).resume()})}(this,e)},on:function(e,t){var n=this;return"data"===e?this._worker.on(e,function(e){t.call(n,e.data,e.meta)}):this._worker.on(e,function(){r.delay(t,arguments,n)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(r.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=c},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,n.nodebuffer=void 0!==O,n.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=0===new Blob([r],{type:"application/zip"}).size}catch(e){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(r),n.blob=0===i.getBlob("application/zip").size}catch(e){n.blob=!1}}}try{n.nodestream=!!e("readable-stream").Readable}catch(e){n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,n){for(var r=e("./utils"),i=e("./support"),s=e("./nodejsUtils"),o=e("./stream/GenericWorker"),a=new Array(256),l=0;l<256;l++)a[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function u(){o.call(this,"utf-8 decode"),this.leftOver=null}function c(){o.call(this,"utf-8 encode")}a[254]=a[254]=1,n.utf8encode=function(e){return i.nodebuffer?s.newBufferFrom(e,"utf-8"):function(e){var t,n,r,s,o,a=e.length,l=0;for(s=0;s<a;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(r=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(r-56320),s++),l+=n<128?1:n<2048?2:n<65536?3:4;for(t=i.uint8array?new Uint8Array(l):new Array(l),s=o=0;o<l;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(r=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(r-56320),s++),n<128?t[o++]=n:(n<2048?t[o++]=192|n>>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,s,o=e.length,l=new Array(2*o);for(t=n=0;t<o;)if((i=e[t++])<128)l[n++]=i;else if(4<(s=a[i]))l[n++]=65533,t+=s-1;else{for(i&=2===s?31:3===s?15:7;1<s&&t<o;)i=i<<6|63&e[t++],s--;1<s?l[n++]=65533:i<65536?l[n++]=i:(i-=65536,l[n++]=55296|i>>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),r.applyFromCharCode(l)}(e=r.transformTo(i.uint8array?"uint8array":"array",e))},r.inherits(u,o),u.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var s=t;(t=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),t.set(s,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}(t),l=t;o!==t.length&&(i.uint8array?(l=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(l=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=u,r.inherits(c,o),c.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=c},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){var r=e("./support"),i=e("./base64"),s=e("./nodejsUtils"),o=e("./external");function a(e){return e}function l(e,t){for(var n=0;n<e.length;++n)t[n]=255&e.charCodeAt(n);return t}e("setimmediate"),n.newBlob=function(e,t){n.checkSupport("blob");try{return new Blob([e],{type:t})}catch(n){try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return r.append(e),r.getBlob(t)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(e,t,n){var r=[],i=0,s=e.length;if(s<=n)return String.fromCharCode.apply(null,e);for(;i<s;)"array"===t||"nodebuffer"===t?r.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+n,s)))):r.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+n,s)))),i+=n;return r.join("")},stringifyByChar:function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},applyCanBeUsed:{uint8array:function(){try{return r.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return r.nodebuffer&&1===String.fromCharCode.apply(null,s.allocBuffer(1)).length}catch(e){return!1}}()}};function c(e){var t=65536,r=n.getTypeOf(e),i=!0;if("uint8array"===r?i=u.applyCanBeUsed.uint8array:"nodebuffer"===r&&(i=u.applyCanBeUsed.nodebuffer),i)for(;1<t;)try{return u.stringifyByChunk(e,r,t)}catch(e){t=Math.floor(t/2)}return u.stringifyByChar(e)}function h(e,t){for(var n=0;n<e.length;n++)t[n]=e[n];return t}n.applyFromCharCode=c;var d={};d.string={string:a,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return d.string.uint8array(e).buffer},uint8array:function(e){return l(e,new Uint8Array(e.length))},nodebuffer:function(e){return l(e,s.allocBuffer(e.length))}},d.array={string:c,array:a,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return s.newBufferFrom(e)}},d.arraybuffer={string:function(e){return c(new Uint8Array(e))},array:function(e){return h(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:a,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return s.newBufferFrom(new Uint8Array(e))}},d.uint8array={string:c,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:a,nodebuffer:function(e){return s.newBufferFrom(e)}},d.nodebuffer={string:c,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return d.nodebuffer.uint8array(e).buffer},uint8array:function(e){return h(e,new Uint8Array(e.length))},nodebuffer:a},n.transformTo=function(e,t){if(t=t||"",!e)return t;n.checkSupport(e);var r=n.getTypeOf(t);return d[r][e](t)},n.resolve=function(e){for(var t=e.split("/"),n=[],r=0;r<t.length;r++){var i=t[r];"."===i||""===i&&0!==r&&r!==t.length-1||(".."===i?n.pop():n.push(i))}return n.join("/")},n.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":r.nodebuffer&&s.isBuffer(e)?"nodebuffer":r.uint8array&&e instanceof Uint8Array?"uint8array":r.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(e){if(!r[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(e){var t,n,r="";for(n=0;n<(e||"").length;n++)r+="\\x"+((t=e.charCodeAt(n))<16?"0":"")+t.toString(16).toUpperCase();return r},n.delay=function(e,t,n){setImmediate(function(){e.apply(n||null,t||[])})},n.inherits=function(e,t){function n(){}n.prototype=t.prototype,e.prototype=new n},n.extend=function(){var e,t,n={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===n[t]&&(n[t]=arguments[e][t]);return n},n.prepareContent=function(e,t,s,a,u){return o.Promise.resolve(t).then(function(e){return r.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new o.Promise(function(t,n){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=function(e){n(e.target.error)},r.readAsArrayBuffer(e)}):e}).then(function(t){var c=n.getTypeOf(t);return c?("arraybuffer"===c?t=n.transformTo("uint8array",t):"string"===c&&(u?t=i.decode(t):s&&!0!==a&&(t=function(e){return l(e,r.uint8array?new Uint8Array(e.length):new Array(e.length))}(t))),t):o.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,n){var r=e("./reader/readerFor"),i=e("./utils"),s=e("./signature"),o=e("./zipEntry"),a=e("./support");function l(e){this.files=[],this.loadOptions=e}l.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(t)+", expected "+i.pretty(e)+")")}},isSignature:function(e,t){var n=this.reader.index;this.reader.setIndex(e);var r=this.reader.readString(4)===t;return this.reader.setIndex(n),r},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=a.uint8array?"uint8array":"array",n=i.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(n)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,n,r=this.zip64EndOfCentralSize-44;0<r;)e=this.reader.readInt(2),t=this.reader.readInt(4),n=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:n}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(e=new o({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(e);var t=e;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var n=this.centralDirOffset+this.centralDirSize;this.zip64&&(n+=20,n+=12+this.zip64EndOfCentralSize);var r=t-n;if(0<r)this.isSignature(t,s.CENTRAL_FILE_HEADER)||(this.reader.zero=r);else if(r<0)throw new Error("Corrupted zip: missing "+Math.abs(r)+" bytes.")},prepareReader:function(e){this.reader=r(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=l},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,n){var r=e("./reader/readerFor"),i=e("./utils"),s=e("./compressedObject"),o=e("./crc32"),a=e("./utf8"),l=e("./compressions"),u=e("./support");function c(e,t){this.options=e,this.loadOptions=t}c.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(e){var t,n;if(e.skip(22),this.fileNameLength=e.readInt(2),n=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(n),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in l)if(Object.prototype.hasOwnProperty.call(l,t)&&l[t].magic===e)return l[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new s(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),n=e.readInt(2),r=e.readData(n),this.extraFields[t]={id:t,length:n,value:r};e.setIndex(i)},handleUTF8:function(){var e=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=a.utf8decode(this.fileName),this.fileCommentStr=a.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var n=i.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(n)}var r=this.findExtraFieldUnicodeComment();if(null!==r)this.fileCommentStr=r;else{var s=i.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(s)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=r(e.value);return 1!==t.readInt(1)||o(this.fileName)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=r(e.value);return 1!==t.readInt(1)||o(this.fileComment)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null}},t.exports=c},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,n){function r(e,t,n){this.name=e,this.dir=n.dir,this.date=n.date,this.comment=n.comment,this.unixPermissions=n.unixPermissions,this.dosPermissions=n.dosPermissions,this._data=t,this._dataBinary=n.binary,this.options={compression:n.compression,compressionOptions:n.compressionOptions}}var i=e("./stream/StreamHelper"),s=e("./stream/DataWorker"),o=e("./utf8"),a=e("./compressedObject"),l=e("./stream/GenericWorker");r.prototype={internalStream:function(e){var t=null,n="string";try{if(!e)throw new Error("No output type specified.");var r="string"===(n=e.toLowerCase())||"text"===n;"binarystring"!==n&&"text"!==n||(n="string"),t=this._decompressWorker();var s=!this._dataBinary;s&&!r&&(t=t.pipe(new o.Utf8EncodeWorker)),!s&&r&&(t=t.pipe(new o.Utf8DecodeWorker))}catch(e){(t=new l("error")).error(e)}return new i(t,n,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof a&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var n=this._decompressWorker();return this._dataBinary||(n=n.pipe(new o.Utf8EncodeWorker)),a.createWorkerFrom(n,e,t)},_decompressWorker:function(){return this._data instanceof a?this._data.getContentWorker():this._data instanceof l?this._data:new s(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],c=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<u.length;h++)r.prototype[u[h]]=c;t.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,n){(function(e){var n,r,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var s=0,o=new i(c),a=e.document.createTextNode("");o.observe(a,{characterData:!0}),n=function(){a.data=s=++s%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){c(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(c,0)};else{var l=new e.MessageChannel;l.port1.onmessage=c,n=function(){l.port2.postMessage(0)}}var u=[];function c(){var e,t;r=!0;for(var n=u.length;n;){for(t=u,u=[],e=-1;++e<n;)t[e]();n=u.length}r=!1}t.exports=function(e){1!==u.push(e)||r||n()}}).call(this,void 0!==f?f:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,n){var r=e("immediate");function i(){}var s={},o=["REJECTED"],a=["FULFILLED"],l=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==i&&f(this,e)}function c(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function h(e,t,n){r(function(){var r;try{r=t(n)}catch(r){return s.reject(e,r)}r===e?s.reject(e,new TypeError("Cannot resolve promise with itself")):s.resolve(e,r)})}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function f(e,t){var n=!1;function r(t){n||(n=!0,s.reject(e,t))}function i(t){n||(n=!0,s.resolve(e,t))}var o=p(function(){t(i,r)});"error"===o.status&&r(o.value)}function p(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}(t.exports=u).prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})},u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===o)return this;var n=new this.constructor(i);return this.state!==l?h(n,this.state===a?e:t,this.outcome):this.queue.push(new c(n,e,t)),n},c.prototype.callFulfilled=function(e){s.resolve(this.promise,e)},c.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},c.prototype.callRejected=function(e){s.reject(this.promise,e)},c.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},s.resolve=function(e,t){var n=p(d,t);if("error"===n.status)return s.reject(e,n.value);var r=n.value;if(r)f(e,r);else{e.state=a,e.outcome=t;for(var i=-1,o=e.queue.length;++i<o;)e.queue[i].callFulfilled(t)}return e},s.reject=function(e,t){e.state=o,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},u.resolve=function(e){return e instanceof this?e:s.resolve(new this(i),e)},u.reject=function(e){var t=new this(i);return s.reject(t,e)},u.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var o=new Array(n),a=0,l=-1,u=new this(i);++l<n;)c(e[l],l);return u;function c(e,i){t.resolve(e).then(function(e){o[i]=e,++a!==n||r||(r=!0,s.resolve(u,o))},function(e){r||(r=!0,s.reject(u,e))})}},u.race=function(e){if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var t=e.length,n=!1;if(!t)return this.resolve([]);for(var r,o=-1,a=new this(i);++o<t;)r=e[o],this.resolve(r).then(function(e){n||(n=!0,s.resolve(a,e))},function(e){n||(n=!0,s.reject(a,e))});return a}},{immediate:36}],38:[function(e,t,n){var r={};(0,e("./lib/utils/common").assign)(r,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,n){var r=e("./zlib/deflate"),i=e("./utils/common"),s=e("./utils/strings"),o=e("./zlib/messages"),a=e("./zlib/zstream"),l=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=i.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var n=r.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==n)throw new Error(o[n]);if(t.header&&r.deflateSetHeader(this.strm,t.header),t.dictionary){var c;if(c="string"==typeof t.dictionary?s.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(n=r.deflateSetDictionary(this.strm,c)))throw new Error(o[n]);this._dict_set=!0}}function c(e,t){var n=new u(t);if(n.push(e,!0),n.err)throw n.msg||o[n.err];return n.result}u.prototype.push=function(e,t){var n,o,a=this.strm,u=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=s.string2buf(e):"[object ArrayBuffer]"===l.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(u),a.next_out=0,a.avail_out=u),1!==(n=r.deflate(a,o))&&0!==n)return this.onEnd(n),!(this.ended=!0);0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(s.buf2binstring(i.shrinkBuf(a.output,a.next_out))):this.onData(i.shrinkBuf(a.output,a.next_out)))}while((0<a.avail_in||0===a.avail_out)&&1!==n);return 4===o?(n=r.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==o||(this.onEnd(0),!(a.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=u,n.deflate=c,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,c(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,n){var r=e("./zlib/inflate"),i=e("./utils/common"),s=e("./utils/strings"),o=e("./zlib/constants"),a=e("./zlib/messages"),l=e("./zlib/zstream"),u=e("./zlib/gzheader"),c=Object.prototype.toString;function h(e){if(!(this instanceof h))return new h(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var n=r.inflateInit2(this.strm,t.windowBits);if(n!==o.Z_OK)throw new Error(a[n]);this.header=new u,r.inflateGetHeader(this.strm,this.header)}function d(e,t){var n=new h(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}h.prototype.push=function(e,t){var n,a,l,u,h,d,f=this.strm,p=this.options.chunkSize,g=this.options.dictionary,m=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof e?f.input=s.binstring2buf(e):"[object ArrayBuffer]"===c.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new i.Buf8(p),f.next_out=0,f.avail_out=p),(n=r.inflate(f,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&g&&(d="string"==typeof g?s.string2buf(g):"[object ArrayBuffer]"===c.call(g)?new Uint8Array(g):g,n=r.inflateSetDictionary(this.strm,d)),n===o.Z_BUF_ERROR&&!0===m&&(n=o.Z_OK,m=!1),n!==o.Z_STREAM_END&&n!==o.Z_OK)return this.onEnd(n),!(this.ended=!0);f.next_out&&(0!==f.avail_out&&n!==o.Z_STREAM_END&&(0!==f.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(l=s.utf8border(f.output,f.next_out),u=f.next_out-l,h=s.buf2string(f.output,l),f.next_out=u,f.avail_out=p-u,u&&i.arraySet(f.output,f.output,l,u,0),this.onData(h)):this.onData(i.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(m=!0)}while((0<f.avail_in||0===f.avail_out)&&n!==o.Z_STREAM_END);return n===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(n=r.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),!(f.avail_out=0))},h.prototype.onData=function(e){this.chunks.push(e)},h.prototype.onEnd=function(e){e===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=h,n.inflate=d,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,d(e,t)},n.ungzip=d},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,n){var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var s=0;s<r;s++)e[i+s]=t[n+s]},flattenChunks:function(e){var t,n,r,i,s,o;for(t=r=0,n=e.length;t<n;t++)r+=e[t].length;for(o=new Uint8Array(r),t=i=0,n=e.length;t<n;t++)s=e[t],o.set(s,i),i+=s.length;return o}},s={arraySet:function(e,t,n,r,i){for(var s=0;s<r;s++)e[i+s]=t[n+s]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,i)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(r)},{}],42:[function(e,t,n){var r=e("./common"),i=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var o=new r.Buf8(256),a=0;a<256;a++)o[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function l(e,t){if(t<65537&&(e.subarray&&s||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",o=0;o<t;o++)n+=String.fromCharCode(e[o]);return n}o[254]=o[254]=1,n.string2buf=function(e){var t,n,i,s,o,a=e.length,l=0;for(s=0;s<a;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),l+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(l),s=o=0;o<l;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),n<128?t[o++]=n:(n<2048?t[o++]=192|n>>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,s,a=t||e.length,u=new Array(2*a);for(n=r=0;n<a;)if((i=e[n++])<128)u[r++]=i;else if(4<(s=o[i]))u[r++]=65533,n+=s-1;else{for(i&=2===s?31:3===s?15:7;1<s&&n<a;)i=i<<6|63&e[n++],s--;1<s?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return l(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+o[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){t.exports=function(e,t,n,r){for(var i=65535&e,s=e>>>16&65535,o=0;0!==n;){for(n-=o=2e3<n?2e3:n;s=s+(i=i+t[r++]|0)|0,--o;);i%=65521,s%=65521}return i|s<<16}},{}],44:[function(e,t,n){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,n){var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var s=r,o=i+n;e^=-1;for(var a=i;a<o;a++)e=e>>>8^s[255&(e^t[a])];return~e}},{}],46:[function(e,t,n){var r,i=e("../utils/common"),s=e("./trees"),o=e("./adler32"),a=e("./crc32"),l=e("./messages"),u=-2,c=258,h=262,d=113;function f(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4<e?9:0)}function g(e){for(var t=e.length;0<=--t;)e[t]=0}function m(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function _(e,t){s._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,m(e.strm)}function y(e,t){e.pending_buf[e.pending++]=t}function v(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function b(e,t){var n,r,i=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-h?e.strstart-(e.w_size-h):0,u=e.window,d=e.w_mask,f=e.prev,p=e.strstart+c,g=u[s+o-1],m=u[s+o];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(n=t)+o]===m&&u[n+o-1]===g&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&s<p);if(r=c-(p-s),s=p-c,o<r){if(e.match_start=t,a<=(o=r))break;g=u[s+o-1],m=u[s+o]}}}while((t=f[t&d])>l&&0!=--i);return o<=e.lookahead?o:e.lookahead}function x(e){var t,n,r,s,l,u,c,d,f,p,g=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=g+(g-h)){for(i.arraySet(e.window,e.window,g,g,0),e.match_start-=g,e.strstart-=g,e.block_start-=g,t=n=e.hash_size;r=e.head[--t],e.head[t]=g<=r?r-g:0,--n;);for(t=n=g;r=e.prev[--t],e.prev[t]=g<=r?r-g:0,--n;);s+=g}if(0===e.strm.avail_in)break;if(u=e.strm,c=e.window,d=e.strstart+e.lookahead,p=void 0,(f=s)<(p=u.avail_in)&&(p=f),n=0===p?0:(u.avail_in-=p,i.arraySet(c,u.input,u.next_in,p,d),1===u.state.wrap?u.adler=o(u.adler,c,p,d):2===u.state.wrap&&(u.adler=a(u.adler,c,p,d)),u.next_in+=p,u.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+3-1])&e.hash_mask,e.prev[l&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=l,l++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<h&&0!==e.strm.avail_in)}function w(e,t){for(var n,r;;){if(e.lookahead<h){if(x(e),e.lookahead<h&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-h&&(e.match_length=b(e,n)),e.match_length>=3)if(r=s._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}function A(e,t){for(var n,r,i;;){if(e.lookahead<h){if(x(e),e.lookahead<h&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-h&&(e.match_length=b(e,n),e.match_length<=5&&(1===e.strategy||3===e.match_length&&4096<e.strstart-e.match_start)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-3,r=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(_(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=s._tr_tally(e,0,e.window[e.strstart-1]))&&_(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=s._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}function E(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}function S(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),g(this.dyn_ltree),g(this.dyn_dtree),g(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),g(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),g(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function T(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:d,e.adler=2===t.wrap?0:1,t.last_flush=0,s._tr_init(t),0):f(e,u)}function k(e){var t=T(e);return 0===t&&function(e){e.window_size=2*e.w_size,g(e.head),e.max_lazy_match=r[e.level].max_lazy,e.good_match=r[e.level].good_length,e.nice_match=r[e.level].nice_length,e.max_chain_length=r[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0}(e.state),t}function O(e,t,n,r,s,o){if(!e)return u;var a=1;if(-1===t&&(t=6),r<0?(a=0,r=-r):15<r&&(a=2,r-=16),s<1||9<s||8!==n||r<8||15<r||t<0||9<t||o<0||4<o)return f(e,u);8===r&&(r=9);var l=new S;return(e.state=l).strm=e,l.wrap=a,l.gzhead=null,l.w_bits=r,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=s+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+3-1)/3),l.window=new i.Buf8(2*l.w_size),l.head=new i.Buf16(l.hash_size),l.prev=new i.Buf16(l.w_size),l.lit_bufsize=1<<s+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new i.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=t,l.strategy=o,l.method=n,k(e)}r=[new E(0,0,0,0,function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(x(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,_(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-h&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(_(e,!1),e.strm.avail_out),1)}),new E(4,4,8,4,w),new E(4,5,16,8,w),new E(4,6,32,32,w),new E(4,4,16,16,A),new E(8,16,32,32,A),new E(8,16,128,128,A),new E(8,32,128,256,A),new E(32,128,258,1024,A),new E(32,258,258,4096,A)],n.deflateInit=function(e,t){return O(e,t,8,15,8,0)},n.deflateInit2=O,n.deflateReset=k,n.deflateResetKeep=T,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?u:(e.state.gzhead=t,0):u},n.deflate=function(e,t){var n,i,o,l;if(!e||!e.state||5<t||t<0)return e?f(e,u):u;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return f(e,0===e.avail_out?-5:u);if(i.strm=e,n=i.last_flush,i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,y(i,31),y(i,139),y(i,8),i.gzhead?(y(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),y(i,255&i.gzhead.time),y(i,i.gzhead.time>>8&255),y(i,i.gzhead.time>>16&255),y(i,i.gzhead.time>>24&255),y(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),y(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(y(i,255&i.gzhead.extra.length),y(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(y(i,0),y(i,0),y(i,0),y(i,0),y(i,0),y(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),y(i,3),i.status=d);else{var h=8+(i.w_bits-8<<4)<<8;h|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(h|=32),h+=31-h%31,i.status=d,v(i,h),0!==i.strstart&&(v(i,e.adler>>>16),v(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),m(e),o=i.pending,i.pending!==i.pending_buf_size));)y(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),m(e),o=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,y(i,l)}while(0!==l);i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),m(e),o=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,y(i,l)}while(0!==l);i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&m(e),i.pending+2<=i.pending_buf_size&&(y(i,255&e.adler),y(i,e.adler>>8&255),e.adler=0,i.status=d)):i.status=d),0!==i.pending){if(m(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return f(e,-5);if(666===i.status&&0!==e.avail_in)return f(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var b=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(x(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,o,a=e.window;;){if(e.lookahead<=c){if(x(e),e.lookahead<=c&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0<e.strstart&&(r=a[i=e.strstart-1])===a[++i]&&r===a[++i]&&r===a[++i]){o=e.strstart+c;do{}while(r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&i<o);e.match_length=c-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=s._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==b&&4!==b||(i.status=666),1===b||3===b)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===b&&(1===t?s._tr_align(i):5!==t&&(s._tr_stored_block(i,0,0,!1),3===t&&(g(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),m(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(y(i,255&e.adler),y(i,e.adler>>8&255),y(i,e.adler>>16&255),y(i,e.adler>>24&255),y(i,255&e.total_in),y(i,e.total_in>>8&255),y(i,e.total_in>>16&255),y(i,e.total_in>>24&255)):(v(i,e.adler>>>16),v(i,65535&e.adler)),m(e),0<i.wrap&&(i.wrap=-i.wrap),0!==i.pending?0:1)},n.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&103!==t&&t!==d&&666!==t?f(e,u):(e.state=null,t===d?f(e,-3):0):u},n.deflateSetDictionary=function(e,t){var n,r,s,a,l,c,h,d,f=t.length;if(!e||!e.state)return u;if(2===(a=(n=e.state).wrap)||1===a&&42!==n.status||n.lookahead)return u;for(1===a&&(e.adler=o(e.adler,t,f,0)),n.wrap=0,f>=n.w_size&&(0===a&&(g(n.head),n.strstart=0,n.block_start=0,n.insert=0),d=new i.Buf8(n.w_size),i.arraySet(d,t,f-n.w_size,n.w_size,0),t=d,f=n.w_size),l=e.avail_in,c=e.next_in,h=e.input,e.avail_in=f,e.next_in=0,e.input=t,x(n);n.lookahead>=3;){for(r=n.strstart,s=n.lookahead-2;n.ins_h=(n.ins_h<<n.hash_shift^n.window[r+3-1])&n.hash_mask,n.prev[r&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=r,r++,--s;);n.strstart=r,n.lookahead=2,x(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=c,e.input=h,e.avail_in=l,n.wrap=a,0},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,n){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,n){t.exports=function(e,t){var n,r,i,s,o,a,l,u,c,h,d,f,p,g,m,_,y,v,b,x,w,A,E,S,T;n=e.state,r=e.next_in,S=e.input,i=r+(e.avail_in-5),s=e.next_out,T=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),l=n.dmax,u=n.wsize,c=n.whave,h=n.wnext,d=n.window,f=n.hold,p=n.bits,g=n.lencode,m=n.distcode,_=(1<<n.lenbits)-1,y=(1<<n.distbits)-1;e:do{p<15&&(f+=S[r++]<<p,p+=8,f+=S[r++]<<p,p+=8),v=g[f&_];t:for(;;){if(f>>>=b=v>>>24,p-=b,0==(b=v>>>16&255))T[s++]=65535&v;else{if(!(16&b)){if(!(64&b)){v=g[(65535&v)+(f&(1<<b)-1)];continue t}if(32&b){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}x=65535&v,(b&=15)&&(p<b&&(f+=S[r++]<<p,p+=8),x+=f&(1<<b)-1,f>>>=b,p-=b),p<15&&(f+=S[r++]<<p,p+=8,f+=S[r++]<<p,p+=8),v=m[f&y];n:for(;;){if(f>>>=b=v>>>24,p-=b,!(16&(b=v>>>16&255))){if(!(64&b)){v=m[(65535&v)+(f&(1<<b)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(w=65535&v,p<(b&=15)&&(f+=S[r++]<<p,(p+=8)<b&&(f+=S[r++]<<p,p+=8)),l<(w+=f&(1<<b)-1)){e.msg="invalid distance too far back",n.mode=30;break e}if(f>>>=b,p-=b,(b=s-o)<w){if(c<(b=w-b)&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(E=d,(A=0)===h){if(A+=u-b,b<x){for(x-=b;T[s++]=d[A++],--b;);A=s-w,E=T}}else if(h<b){if(A+=u+h-b,(b-=h)<x){for(x-=b;T[s++]=d[A++],--b;);if(A=0,h<x){for(x-=b=h;T[s++]=d[A++],--b;);A=s-w,E=T}}}else if(A+=h-b,b<x){for(x-=b;T[s++]=d[A++],--b;);A=s-w,E=T}for(;2<x;)T[s++]=E[A++],T[s++]=E[A++],T[s++]=E[A++],x-=3;x&&(T[s++]=E[A++],1<x&&(T[s++]=E[A++]))}else{for(A=s-w;T[s++]=T[A++],T[s++]=T[A++],T[s++]=T[A++],2<(x-=3););x&&(T[s++]=T[A++],1<x&&(T[s++]=T[A++]))}break}}break}}while(r<i&&s<a);r-=x=p>>3,f&=(1<<(p-=x<<3))-1,e.next_in=r,e.next_out=s,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=s<a?a-s+257:257-(s-a),n.hold=f,n.bits=p}},{}],49:[function(e,t,n){var r=e("../utils/common"),i=e("./adler32"),s=e("./crc32"),o=e("./inffast"),a=e("./inftrees"),l=-2;function u(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function c(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function h(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):l}function d(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,h(e)):l}function f(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?l:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,d(e))):l}function p(e,t){var n,r;return e?(r=new c,(e.state=r).window=null,0!==(n=f(e,t))&&(e.state=null),n):l}var g,m,_=!0;function y(e){if(_){var t;for(g=new r.Buf32(512),m=new r.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,g,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,m,0,e.work,{bits:5}),_=!1}e.lencode=g,e.lenbits=9,e.distcode=m,e.distbits=5}function v(e,t,n,i){var s,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new r.Buf8(o.wsize)),i>=o.wsize?(r.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i<(s=o.wsize-o.wnext)&&(s=i),r.arraySet(o.window,t,n-i,s,o.wnext),(i-=s)?(r.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=s))),0}n.inflateReset=d,n.inflateReset2=f,n.inflateResetKeep=h,n.inflateInit=function(e){return p(e,15)},n.inflateInit2=p,n.inflate=function(e,t){var n,c,h,d,f,p,g,m,_,b,x,w,A,E,S,T,k,O,R,C,P,M,N,I,D=0,F=new r.Buf8(4),z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return l;12===(n=e.state).mode&&(n.mode=13),f=e.next_out,h=e.output,g=e.avail_out,d=e.next_in,c=e.input,p=e.avail_in,m=n.hold,_=n.bits,b=p,x=g,M=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(2&n.wrap&&35615===m){F[n.check=0]=255&m,F[1]=m>>>8&255,n.check=s(n.check,F,2,0),_=m=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&m)<<8)+(m>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&m)){e.msg="unknown compression method",n.mode=30;break}if(_-=4,P=8+(15&(m>>>=4)),0===n.wbits)n.wbits=P;else if(P>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<P,e.adler=n.check=1,n.mode=512&m?10:12,_=m=0;break;case 2:for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(n.flags=m,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=m>>8&1),512&n.flags&&(F[0]=255&m,F[1]=m>>>8&255,n.check=s(n.check,F,2,0)),_=m=0,n.mode=3;case 3:for(;_<32;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.head&&(n.head.time=m),512&n.flags&&(F[0]=255&m,F[1]=m>>>8&255,F[2]=m>>>16&255,F[3]=m>>>24&255,n.check=s(n.check,F,4,0)),_=m=0,n.mode=4;case 4:for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.head&&(n.head.xflags=255&m,n.head.os=m>>8),512&n.flags&&(F[0]=255&m,F[1]=m>>>8&255,n.check=s(n.check,F,2,0)),_=m=0,n.mode=5;case 5:if(1024&n.flags){for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.length=m,n.head&&(n.head.extra_len=m),512&n.flags&&(F[0]=255&m,F[1]=m>>>8&255,n.check=s(n.check,F,2,0)),_=m=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(w=n.length)&&(w=p),w&&(n.head&&(P=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,c,d,w,P)),512&n.flags&&(n.check=s(n.check,c,w,d)),p-=w,d+=w,n.length-=w),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(w=0;P=c[d+w++],n.head&&P&&n.length<65536&&(n.head.name+=String.fromCharCode(P)),P&&w<p;);if(512&n.flags&&(n.check=s(n.check,c,w,d)),p-=w,d+=w,P)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===p)break e;for(w=0;P=c[d+w++],n.head&&P&&n.length<65536&&(n.head.comment+=String.fromCharCode(P)),P&&w<p;);if(512&n.flags&&(n.check=s(n.check,c,w,d)),p-=w,d+=w,P)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(m!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}_=m=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;_<32;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}e.adler=n.check=u(m),_=m=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=f,e.avail_out=g,e.next_in=d,e.avail_in=p,n.hold=m,n.bits=_,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last){m>>>=7&_,_-=7&_,n.mode=27;break}for(;_<3;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}switch(n.last=1&m,_-=1,3&(m>>>=1)){case 0:n.mode=14;break;case 1:if(y(n),n.mode=20,6!==t)break;m>>>=2,_-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}m>>>=2,_-=2;break;case 14:for(m>>>=7&_,_-=7&_;_<32;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if((65535&m)!=(m>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&m,_=m=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(w=n.length){if(p<w&&(w=p),g<w&&(w=g),0===w)break e;r.arraySet(h,c,d,w,f),p-=w,d+=w,g-=w,f+=w,n.length-=w;break}n.mode=12;break;case 17:for(;_<14;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(n.nlen=257+(31&m),m>>>=5,_-=5,n.ndist=1+(31&m),m>>>=5,_-=5,n.ncode=4+(15&m),m>>>=4,_-=4,286<n.nlen||30<n.ndist){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;_<3;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.lens[z[n.have++]]=7&m,m>>>=3,_-=3}for(;n.have<19;)n.lens[z[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,N={bits:n.lenbits},M=a(0,n.lens,0,19,n.lencode,0,n.work,N),n.lenbits=N.bits,M){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;T=(D=n.lencode[m&(1<<n.lenbits)-1])>>>16&255,k=65535&D,!((S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(k<16)m>>>=S,_-=S,n.lens[n.have++]=k;else{if(16===k){for(I=S+2;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(m>>>=S,_-=S,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}P=n.lens[n.have-1],w=3+(3&m),m>>>=2,_-=2}else if(17===k){for(I=S+3;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}_-=S,P=0,w=3+(7&(m>>>=S)),m>>>=3,_-=3}else{for(I=S+7;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}_-=S,P=0,w=11+(127&(m>>>=S)),m>>>=7,_-=7}if(n.have+w>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;w--;)n.lens[n.have++]=P}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,N={bits:n.lenbits},M=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,N),n.lenbits=N.bits,M){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,N={bits:n.distbits},M=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,N),n.distbits=N.bits,M){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=g){e.next_out=f,e.avail_out=g,e.next_in=d,e.avail_in=p,n.hold=m,n.bits=_,o(e,x),f=e.next_out,h=e.output,g=e.avail_out,d=e.next_in,c=e.input,p=e.avail_in,m=n.hold,_=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;T=(D=n.lencode[m&(1<<n.lenbits)-1])>>>16&255,k=65535&D,!((S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(T&&!(240&T)){for(O=S,R=T,C=k;T=(D=n.lencode[C+((m&(1<<O+R)-1)>>O)])>>>16&255,k=65535&D,!(O+(S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}m>>>=O,_-=O,n.back+=O}if(m>>>=S,_-=S,n.back+=S,n.length=k,0===T){n.mode=26;break}if(32&T){n.back=-1,n.mode=12;break}if(64&T){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&T,n.mode=22;case 22:if(n.extra){for(I=n.extra;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.length+=m&(1<<n.extra)-1,m>>>=n.extra,_-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;T=(D=n.distcode[m&(1<<n.distbits)-1])>>>16&255,k=65535&D,!((S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(!(240&T)){for(O=S,R=T,C=k;T=(D=n.distcode[C+((m&(1<<O+R)-1)>>O)])>>>16&255,k=65535&D,!(O+(S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}m>>>=O,_-=O,n.back+=O}if(m>>>=S,_-=S,n.back+=S,64&T){e.msg="invalid distance code",n.mode=30;break}n.offset=k,n.extra=15&T,n.mode=24;case 24:if(n.extra){for(I=n.extra;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.offset+=m&(1<<n.extra)-1,m>>>=n.extra,_-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===g)break e;if(w=x-g,n.offset>w){if((w=n.offset-w)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}A=w>n.wnext?(w-=n.wnext,n.wsize-w):n.wnext-w,w>n.length&&(w=n.length),E=n.window}else E=h,A=f-n.offset,w=n.length;for(g<w&&(w=g),g-=w,n.length-=w;h[f++]=E[A++],--w;);0===n.length&&(n.mode=21);break;case 26:if(0===g)break e;h[f++]=n.length,g--,n.mode=21;break;case 27:if(n.wrap){for(;_<32;){if(0===p)break e;p--,m|=c[d++]<<_,_+=8}if(x-=g,e.total_out+=x,n.total+=x,x&&(e.adler=n.check=n.flags?s(n.check,h,x,f-x):i(n.check,h,x,f-x)),x=g,(n.flags?m:u(m))!==n.check){e.msg="incorrect data check",n.mode=30;break}_=m=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;_<32;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(m!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}_=m=0}n.mode=29;case 29:M=1;break e;case 30:M=-3;break e;case 31:return-4;default:return l}return e.next_out=f,e.avail_out=g,e.next_in=d,e.avail_in=p,n.hold=m,n.bits=_,(n.wsize||x!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&v(e,e.output,e.next_out,x-e.avail_out)?(n.mode=31,-4):(b-=e.avail_in,x-=e.avail_out,e.total_in+=b,e.total_out+=x,n.total+=x,n.wrap&&x&&(e.adler=n.check=n.flags?s(n.check,h,x,e.next_out-x):i(n.check,h,x,e.next_out-x)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0==b&&0===x||4===t)&&0===M&&(M=-5),M)},n.inflateEnd=function(e){if(!e||!e.state)return l;var t=e.state;return t.window&&(t.window=null),e.state=null,0},n.inflateGetHeader=function(e,t){var n;return e&&e.state&&2&(n=e.state).wrap?((n.head=t).done=!1,0):l},n.inflateSetDictionary=function(e,t){var n,r=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?l:11===n.mode&&i(1,t,r,0)!==n.check?-3:v(e,t,r,r)?(n.mode=31,-4):(n.havedict=1,0):l},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,n){var r=e("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,l,u,c,h,d){var f,p,g,m,_,y,v,b,x,w=d.bits,A=0,E=0,S=0,T=0,k=0,O=0,R=0,C=0,P=0,M=0,N=null,I=0,D=new r.Buf16(16),F=new r.Buf16(16),z=null,L=0;for(A=0;A<=15;A++)D[A]=0;for(E=0;E<l;E++)D[t[n+E]]++;for(k=w,T=15;1<=T&&0===D[T];T--);if(T<k&&(k=T),0===T)return u[c++]=20971520,u[c++]=20971520,d.bits=1,0;for(S=1;S<T&&0===D[S];S++);for(k<S&&(k=S),A=C=1;A<=15;A++)if(C<<=1,(C-=D[A])<0)return-1;if(0<C&&(0===e||1!==T))return-1;for(F[1]=0,A=1;A<15;A++)F[A+1]=F[A]+D[A];for(E=0;E<l;E++)0!==t[n+E]&&(h[F[t[n+E]]++]=E);if(y=0===e?(N=z=h,19):1===e?(N=i,I-=257,z=s,L-=257,256):(N=o,z=a,-1),A=S,_=c,R=E=M=0,g=-1,m=(P=1<<(O=k))-1,1===e&&852<P||2===e&&592<P)return 1;for(;;){for(v=A-R,x=h[E]<y?(b=0,h[E]):h[E]>y?(b=z[L+h[E]],N[I+h[E]]):(b=96,0),f=1<<A-R,S=p=1<<O;u[_+(M>>R)+(p-=f)]=v<<24|b<<16|x,0!==p;);for(f=1<<A-1;M&f;)f>>=1;if(0!==f?(M&=f-1,M+=f):M=0,E++,0==--D[A]){if(A===T)break;A=t[n+h[E]]}if(k<A&&(M&m)!==g){for(0===R&&(R=k),_+=S,C=1<<(O=A-R);O+R<T&&!((C-=D[O+R])<=0);)O++,C<<=1;if(P+=1<<O,1===e&&852<P||2===e&&592<P)return 1;u[g=M&m]=k<<24|O<<16|_-c}}return 0!==M&&(u[_+M]=A-R<<24|64<<16),d.bits=k,0}},{"../utils/common":41}],51:[function(e,t,n){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,n){var r=e("../utils/common");function i(e){for(var t=e.length;0<=--t;)e[t]=0}var s=256,o=286,a=30,l=15,u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],c=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],d=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],f=new Array(576);i(f);var p=new Array(60);i(p);var g=new Array(512);i(g);var m=new Array(256);i(m);var _=new Array(29);i(_);var y,v,b,x=new Array(a);function w(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}function A(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function E(e){return e<256?g[e]:g[256+(e>>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function T(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,S(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function k(e,t,n){T(e,n[2*t],n[2*t+1])}function O(e,t){for(var n=0;n|=1&e,e>>>=1,n<<=1,0<--t;);return n>>>1}function R(e,t,n){var r,i,s=new Array(16),o=0;for(r=1;r<=l;r++)s[r]=o=o+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=O(s[a]++,a))}}function C(e){var t;for(t=0;t<o;t++)e.dyn_ltree[2*t]=0;for(t=0;t<a;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function P(e){8<e.bi_valid?S(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function M(e,t,n,r){var i=2*t,s=2*n;return e[i]<e[s]||e[i]===e[s]&&r[t]<=r[n]}function N(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&M(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!M(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function I(e,t,n){var r,i,o,a,l=0;if(0!==e.last_lit)for(;r=e.pending_buf[e.d_buf+2*l]<<8|e.pending_buf[e.d_buf+2*l+1],i=e.pending_buf[e.l_buf+l],l++,0===r?k(e,i,t):(k(e,(o=m[i])+s+1,t),0!==(a=u[o])&&T(e,i-=_[o],a),k(e,o=E(--r),n),0!==(a=c[o])&&T(e,r-=x[o],a)),l<e.last_lit;);k(e,256,t)}function D(e,t){var n,r,i,s=t.dyn_tree,o=t.stat_desc.static_tree,a=t.stat_desc.has_stree,u=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=573,n=0;n<u;n++)0!==s[2*n]?(e.heap[++e.heap_len]=c=n,e.depth[n]=0):s[2*n+1]=0;for(;e.heap_len<2;)s[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,a&&(e.static_len-=o[2*i+1]);for(t.max_code=c,n=e.heap_len>>1;1<=n;n--)N(e,s,n);for(i=u;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],N(e,s,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,s[2*i]=s[2*n]+s[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,s[2*n+1]=s[2*r+1]=i,e.heap[1]=i++,N(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,s,o,a,u=t.dyn_tree,c=t.max_code,h=t.stat_desc.static_tree,d=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,g=t.stat_desc.max_length,m=0;for(s=0;s<=l;s++)e.bl_count[s]=0;for(u[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)g<(s=u[2*u[2*(r=e.heap[n])+1]+1]+1)&&(s=g,m++),u[2*r+1]=s,c<r||(e.bl_count[s]++,o=0,p<=r&&(o=f[r-p]),a=u[2*r],e.opt_len+=a*(s+o),d&&(e.static_len+=a*(h[2*r+1]+o)));if(0!==m){do{for(s=g-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[g]--,m-=2}while(0<m);for(s=g;0!==s;s--)for(r=e.bl_count[s];0!==r;)c<(i=e.heap[--n])||(u[2*i+1]!==s&&(e.opt_len+=(s-u[2*i+1])*u[2*i],u[2*i+1]=s),r--)}}(e,t),R(s,c,e.bl_count)}function F(e,t,n){var r,i,s=-1,o=t[1],a=0,l=7,u=4;for(0===o&&(l=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=o,o=t[2*(r+1)+1],++a<l&&i===o||(a<u?e.bl_tree[2*i]+=a:0!==i?(i!==s&&e.bl_tree[2*i]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=i,u=(a=0)===o?(l=138,3):i===o?(l=6,3):(l=7,4))}function z(e,t,n){var r,i,s=-1,o=t[1],a=0,l=7,u=4;for(0===o&&(l=138,u=3),r=0;r<=n;r++)if(i=o,o=t[2*(r+1)+1],!(++a<l&&i===o)){if(a<u)for(;k(e,i,e.bl_tree),0!=--a;);else 0!==i?(i!==s&&(k(e,i,e.bl_tree),a--),k(e,16,e.bl_tree),T(e,a-3,2)):a<=10?(k(e,17,e.bl_tree),T(e,a-3,3)):(k(e,18,e.bl_tree),T(e,a-11,7));s=i,u=(a=0)===o?(l=138,3):i===o?(l=6,3):(l=7,4)}}i(x);var L=!1;function j(e,t,n,i){T(e,0+(i?1:0),3),function(e,t,n){P(e),S(e,n),S(e,~n),r.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}(e,t,n)}n._tr_init=function(e){L||(function(){var e,t,n,r,i,s=new Array(16);for(r=n=0;r<28;r++)for(_[r]=n,e=0;e<1<<u[r];e++)m[n++]=r;for(m[n-1]=r,r=i=0;r<16;r++)for(x[r]=i,e=0;e<1<<c[r];e++)g[i++]=r;for(i>>=7;r<a;r++)for(x[r]=i<<7,e=0;e<1<<c[r]-7;e++)g[256+i++]=r;for(t=0;t<=l;t++)s[t]=0;for(e=0;e<=143;)f[2*e+1]=8,e++,s[8]++;for(;e<=255;)f[2*e+1]=9,e++,s[9]++;for(;e<=279;)f[2*e+1]=7,e++,s[7]++;for(;e<=287;)f[2*e+1]=8,e++,s[8]++;for(R(f,287,s),e=0;e<a;e++)p[2*e+1]=5,p[2*e]=O(e,5);y=new w(f,u,257,o,l),v=new w(p,c,0,a,l),b=new w(new Array(0),h,0,19,7)}(),L=!0),e.l_desc=new A(e.dyn_ltree,y),e.d_desc=new A(e.dyn_dtree,v),e.bl_desc=new A(e.bl_tree,b),e.bi_buf=0,e.bi_valid=0,C(e)},n._tr_stored_block=j,n._tr_flush_block=function(e,t,n,r){var i,o,a=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<s;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),D(e,e.l_desc),D(e,e.d_desc),a=function(e){var t;for(F(e,e.dyn_ltree,e.l_desc.max_code),F(e,e.dyn_dtree,e.d_desc.max_code),D(e,e.bl_desc),t=18;3<=t&&0===e.bl_tree[2*d[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?j(e,t,n,r):4===e.strategy||o===i?(T(e,2+(r?1:0),3),I(e,f,p)):(T(e,4+(r?1:0),3),function(e,t,n,r){var i;for(T(e,t-257,5),T(e,n-1,5),T(e,r-4,4),i=0;i<r;i++)T(e,e.bl_tree[2*d[i]+1],3);z(e,e.dyn_ltree,t-1),z(e,e.dyn_dtree,n-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),I(e,e.dyn_ltree,e.dyn_dtree)),C(e),r&&P(e)},n._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(m[n]+s+1)]++,e.dyn_dtree[2*E(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){T(e,2,3),k(e,256,f),function(e){16===e.bi_valid?(S(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(e){!function(e){if(!e.setImmediate){var t,n,r,i,s=1,o={},a=!1,l=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,t="[object process]"==={}.toString.call(e.process)?function(e){!function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];be.push(new Se(e,t)),1!==be.length||xe||ye(Ee)}(function(){h(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(i="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",d,!1):e.attachEvent("onmessage",d),function(t){e.postMessage(i+t,"*")}):e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){h(e.data)},function(e){r.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(n=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,n.removeChild(t),t=null},n.appendChild(t)}):function(e){setTimeout(h,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var n=new Array(arguments.length-1),r=0;r<n.length;r++)n[r]=arguments[r+1];var i={callback:e,args:n};return o[s]=i,t(s),s++},u.clearImmediate=c}function c(e){delete o[e]}function h(e){if(a)setTimeout(h,0,e);else{var t=o[e];if(t){a=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(undefined,n)}}(t)}finally{c(e),a=!1}}}}function d(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(i)&&h(+t.data.slice(i.length))}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,void 0!==f?f:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10)),lt.exports),ct=e.getDefaultExportFromCjs(ut),ht={},dt={},ft={};function pt(){if(Re)return ft;function e(e){return null==e}return Re=1,ft.isNothing=e,ft.isObject=function(e){return"object"==typeof e&&null!==e},ft.toArray=function(t){return Array.isArray(t)?t:e(t)?[]:[t]},ft.repeat=function(e,t){var n,r="";for(n=0;n<t;n+=1)r+=e;return r},ft.isNegativeZero=function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},ft.extend=function(e,t){var n,r,i,s;if(t)for(n=0,r=(s=Object.keys(t)).length;n<r;n+=1)e[i=s[n]]=t[i];return e},ft}function gt(){if(Pe)return Ce;function e(e,t){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||"",this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():"")}return Pe=1,e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(e){var t=this.name+": ";return t+=this.reason||"(unknown reason)",!e&&this.mark&&(t+=" "+this.mark.toString()),t},Ce=e}function mt(){if(De)return Ie;De=1;var e=gt(),t=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];return Ie=function(r,i){if(i=i||{},Object.keys(i).forEach(function(n){if(-1===t.indexOf(n))throw new e('Unknown option "'+n+'" is met in definition of "'+r+'" YAML type.')}),this.tag=r,this.kind=i.kind||null,this.resolve=i.resolve||function(){return!0},this.construct=i.construct||function(e){return e},this.instanceOf=i.instanceOf||null,this.predicate=i.predicate||null,this.represent=i.represent||null,this.defaultStyle=i.defaultStyle||null,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}(i.styleAliases||null),-1===n.indexOf(this.kind))throw new e('Unknown kind "'+this.kind+'" is specified for "'+r+'" YAML type.')},Ie}function _t(){if(ze)return Fe;ze=1;var e=pt(),t=gt(),n=mt();function r(e,t,n){var i=[];return e.include.forEach(function(e){n=r(e,t,n)}),e[t].forEach(function(e){n.forEach(function(t,n){t.tag===e.tag&&i.push(n)}),n.push(e)}),n.filter(function(e,t){return-1===i.indexOf(t)})}function i(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new t("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=r(this,"implicit",[]),this.compiledExplicit=r(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,n={};function r(e){n[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(r);return n}(this.compiledImplicit,this.compiledExplicit)}return i.DEFAULT=null,i.create=function(){var r,s;switch(arguments.length){case 1:r=i.DEFAULT,s=arguments[0];break;case 2:r=arguments[0],s=arguments[1];break;default:throw new t("Wrong number of arguments for Schema.create function")}if(r=e.toArray(r),s=e.toArray(s),!r.every(function(e){return e instanceof i}))throw new t("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!s.every(function(e){return e instanceof n}))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new i({include:r,explicit:s})},Fe=i}function yt(){if(je)return Le;je=1;var e=mt();return Le=new e("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}})}function vt(){if(Ue)return Ve;Ue=1;var e=mt();return Ve=new e("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}})}function bt(){if(Ge)return Be;Ge=1;var e=mt();return Be=new e("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})}function xt(){if(qe)return $e;qe=1;var e=_t();return $e=new e({explicit:[yt(),vt(),bt()]})}function wt(){if(We)return He;We=1;var e=mt();return He=new e("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})}function At(){if(Ke)return Ze;Ke=1;var e=mt();return Ze=new e("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})}function Et(){if(Ye)return Xe;Ye=1;var e=pt(),t=mt();function n(e){return 48<=e&&e<=55}function r(e){return 48<=e&&e<=57}return Xe=new t("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,i,s=e.length,o=0,a=!1;if(!s)return!1;if("-"!==(t=e[o])&&"+"!==t||(t=e[++o]),"0"===t){if(o+1===s)return!0;if("b"===(t=e[++o])){for(o++;o<s;o++)if("_"!==(t=e[o])){if("0"!==t&&"1"!==t)return!1;a=!0}return a}if("x"===t){for(o++;o<s;o++)if("_"!==(t=e[o])){if(!(48<=(i=e.charCodeAt(o))&&i<=57||65<=i&&i<=70||97<=i&&i<=102))return!1;a=!0}return a}for(;o<s;o++)if("_"!==(t=e[o])){if(!n(e.charCodeAt(o)))return!1;a=!0}return a}for(;o<s;o++)if("_"!==(t=e[o])){if(":"===t)break;if(!r(e.charCodeAt(o)))return!1;a=!0}return!!a&&(":"!==t||/^(:[0-5]?[0-9])+$/.test(e.slice(o)))},construct:function(e){var t,n,r=e,i=1,s=[];return-1!==r.indexOf("_")&&(r=r.replace(/_/g,"")),"-"!==(t=r[0])&&"+"!==t||("-"===t&&(i=-1),t=(r=r.slice(1))[0]),"0"===r?0:"0"===t?"b"===r[1]?i*parseInt(r.slice(2),2):"x"===r[1]?i*parseInt(r,16):i*parseInt(r,8):-1!==r.indexOf(":")?(r.split(":").forEach(function(e){s.unshift(parseInt(e,10))}),r=0,n=1,s.forEach(function(e){r+=e*n,n*=60}),i*r):i*parseInt(r,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&t%1==0&&!e.isNegativeZero(t)},represent:{binary:function(e){return"0b"+e.toString(2)},octal:function(e){return"0"+e.toString(8)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return"0x"+e.toString(16).toUpperCase()}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Xe}function St(){if(Je)return Qe;Je=1;var e=pt(),t=mt(),n=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?|\\.[0-9_]+(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=/^[-+]?[0-9]+e/;return Qe=new t("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!!n.test(e)},construct:function(e){var t,n,r,i;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,i=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:t.indexOf(":")>=0?(t.split(":").forEach(function(e){i.unshift(parseFloat(e,10))}),t=0,r=1,i.forEach(function(e){t+=e*r,r*=60}),n*t):n*parseFloat(t,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||e.isNegativeZero(t))},represent:function(t,n){var i;if(isNaN(t))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(e.isNegativeZero(t))return"-0.0";return i=t.toString(10),r.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"})}function Tt(){if(tt)return et;tt=1;var e=_t();return et=new e({include:[xt()],implicit:[wt(),At(),Et(),St()]})}function kt(){if(rt)return nt;rt=1;var e=_t();return nt=new e({include:[Tt()]})}function Ot(){if(st)return it;st=1;var e=mt(),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$");return it=new e("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&null!==t.exec(e)},construct:function(e){var n,r,i,s,o,a,l,u,c=0,h=null;if(null===(n=t.exec(e)))throw new Error("Date resolve error");if(r=+n[1],i=+n[2]-1,s=+n[3],!n[4])return new Date(Date.UTC(r,i,s));if(o=+n[4],a=+n[5],l=+n[6],n[7]){for(c=n[7].slice(0,3);c.length<3;)c+="0";c=+c}return n[9]&&(h=6e4*(60*+n[10]+ +(n[11]||0)),"-"===n[9]&&(h=-h)),u=new Date(Date.UTC(r,i,s,o,a,l,c)),h&&u.setTime(u.getTime()-h),u},instanceOf:Date,represent:function(e){return e.toISOString()}})}function Rt(){if(at)return ot;at=1;var e=mt();return ot=new e("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}})}var Ct,Pt,Mt,Nt,It,Dt,Ft,zt,Lt,jt,Vt,Ut,Bt,Gt,$t,qt,Ht,Wt,Zt,Kt,Xt,Yt,Qt=e.getAugmentedNamespace(fe);function Jt(){if(Pt)return Ct;Pt=1;var e=Qt.Buffer,t=mt(),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";return Ct=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,r,i=0,s=e.length,o=n;for(r=0;r<s;r++)if(!((t=o.indexOf(e.charAt(r)))>64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(t){var r,i,s=t.replace(/[\r\n=]/g,""),o=s.length,a=n,l=0,u=[];for(r=0;r<o;r++)r%4==0&&r&&(u.push(l>>16&255),u.push(l>>8&255),u.push(255&l)),l=l<<6|a.indexOf(s.charAt(r));return 0==(i=o%4*6)?(u.push(l>>16&255),u.push(l>>8&255),u.push(255&l)):18===i?(u.push(l>>10&255),u.push(l>>2&255)):12===i&&u.push(l>>4&255),e?new e(u):u},predicate:function(t){return e&&e.isBuffer(t)},represent:function(e){var t,r,i="",s=0,o=e.length,a=n;for(t=0;t<o;t++)t%3==0&&t&&(i+=a[s>>18&63],i+=a[s>>12&63],i+=a[s>>6&63],i+=a[63&s]),s=(s<<8)+e[t];return 0==(r=o%3)?(i+=a[s>>18&63],i+=a[s>>12&63],i+=a[s>>6&63],i+=a[63&s]):2===r?(i+=a[s>>10&63],i+=a[s>>4&63],i+=a[s<<2&63],i+=a[64]):1===r&&(i+=a[s>>2&63],i+=a[s<<4&63],i+=a[64],i+=a[64]),i}}),Ct}function en(){if(Nt)return Mt;Nt=1;var e=mt(),t=Object.prototype.hasOwnProperty,n=Object.prototype.toString;return Mt=new e("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var r,i,s,o,a,l=[],u=e;for(r=0,i=u.length;r<i;r+=1){if(s=u[r],a=!1,"[object Object]"!==n.call(s))return!1;for(o in s)if(t.call(s,o)){if(a)return!1;a=!0}if(!a)return!1;if(-1!==l.indexOf(o))return!1;l.push(o)}return!0},construct:function(e){return null!==e?e:[]}}),Mt}function tn(){if(Dt)return It;Dt=1;var e=mt(),t=Object.prototype.toString;return It=new e("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;var n,r,i,s,o,a=e;for(o=new Array(a.length),n=0,r=a.length;n<r;n+=1){if(i=a[n],"[object Object]"!==t.call(i))return!1;if(1!==(s=Object.keys(i)).length)return!1;o[n]=[s[0],i[s[0]]]}return!0},construct:function(e){if(null===e)return[];var t,n,r,i,s,o=e;for(s=new Array(o.length),t=0,n=o.length;t<n;t+=1)r=o[t],i=Object.keys(r),s[t]=[i[0],r[i[0]]];return s}}),It}function nn(){if(zt)return Ft;zt=1;var e=mt(),t=Object.prototype.hasOwnProperty;return Ft=new e("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;var n,r=e;for(n in r)if(t.call(r,n)&&null!==r[n])return!1;return!0},construct:function(e){return null!==e?e:{}}})}function rn(){if(jt)return Lt;jt=1;var e=_t();return Lt=new e({include:[kt()],implicit:[Ot(),Rt()],explicit:[Jt(),en(),tn(),nn()]})}function sn(){if(Ut)return Vt;Ut=1;var e=mt();return Vt=new e("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:function(){return!0},construct:function(){},predicate:function(e){return void 0===e},represent:function(){return""}})}function on(){if(Gt)return Bt;Gt=1;var e=mt();return Bt=new e("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:function(e){if(null===e)return!1;if(0===e.length)return!1;var t=e,n=/\/([gim]*)$/.exec(e),r="";if("/"===t[0]){if(n&&(r=n[1]),r.length>3)return!1;if("/"!==t[t.length-r.length-1])return!1}return!0},construct:function(e){var t=e,n=/\/([gim]*)$/.exec(e),r="";return"/"===t[0]&&(n&&(r=n[1]),t=t.slice(1,t.length-r.length-1)),new RegExp(t,r)},predicate:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},represent:function(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}})}function an(){if(qt)return $t;var e;qt=1;try{e=ke("esprima")}catch(t){"undefined"!=typeof window&&(e=window.esprima)}var t=mt();return $t=new t("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:function(t){if(null===t)return!1;try{var n="("+t+")",r=e.parse(n,{range:!0});return"Program"===r.type&&1===r.body.length&&"ExpressionStatement"===r.body[0].type&&"FunctionExpression"===r.body[0].expression.type}catch(e){return!1}},construct:function(t){var n,r="("+t+")",i=e.parse(r,{range:!0}),s=[];if("Program"!==i.type||1!==i.body.length||"ExpressionStatement"!==i.body[0].type||"FunctionExpression"!==i.body[0].expression.type)throw new Error("Failed to resolve function");return i.body[0].expression.params.forEach(function(e){s.push(e.name)}),n=i.body[0].expression.body.range,new Function(s,r.slice(n[0]+1,n[1]-1))},predicate:function(e){return"[object Function]"===Object.prototype.toString.call(e)},represent:function(e){return e.toString()}})}function ln(){if(Wt)return Ht;Wt=1;var e=_t();return Ht=e.DEFAULT=new e({include:[rn()],explicit:[sn(),on(),an()]})}var un=function(){if(Yt)return Xt;Yt=1;var e=function(){if(Kt)return ht;Kt=1;var e=function(){if(Zt)return dt;Zt=1;var e=pt(),t=gt(),n=function(){if(Ne)return Me;Ne=1;var e=pt();function t(e,t,n,r,i){this.name=e,this.buffer=t,this.position=n,this.line=r,this.column=i}return t.prototype.getSnippet=function(t,n){var r,i,s,o,a;if(!this.buffer)return null;for(t=t||4,n=n||75,r="",i=this.position;i>0&&-1==="\0\r\n
\u2028\u2029".indexOf(this.buffer.charAt(i-1));)if(i-=1,this.position-i>n/2-1){r=" ... ",i+=5;break}for(s="",o=this.position;o<this.buffer.length&&-1==="\0\r\n
\u2028\u2029".indexOf(this.buffer.charAt(o));)if((o+=1)-this.position>n/2-1){s=" ... ",o-=5;break}return a=this.buffer.slice(i,o),e.repeat(" ",t)+r+a+s+"\n"+e.repeat(" ",t+this.position-i+r.length)+"^"},t.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},Me=t}(),r=rn(),i=ln(),s=Object.prototype.hasOwnProperty,o=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,a=/[\x85\u2028\u2029]/,l=/[,\[\]\{\}]/,u=/^(?:!|!!|![a-z\-]+!)$/i,c=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function h(e){return 10===e||13===e}function d(e){return 9===e||32===e}function f(e){return 9===e||32===e||10===e||13===e}function p(e){return 44===e||91===e||93===e||123===e||125===e}function g(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function m(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"
":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function _(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var y=new Array(256),v=new Array(256),b=0;b<256;b++)y[b]=m(b)?1:0,v[b]=m(b);function x(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||i,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function w(e,r){return new t(r,new n(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function A(e,t){throw w(e,t)}function E(e,t){e.onWarning&&e.onWarning.call(null,w(e,t))}var S={YAML:function(e,t,n){var r,i,s;null!==e.version&&A(e,"duplication of %YAML directive"),1!==n.length&&A(e,"YAML directive accepts exactly one argument"),null===(r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&A(e,"ill-formed argument of the YAML directive"),i=parseInt(r[1],10),s=parseInt(r[2],10),1!==i&&A(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=s<2,1!==s&&2!==s&&E(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var r,i;2!==n.length&&A(e,"TAG directive accepts exactly two arguments"),r=n[0],i=n[1],u.test(r)||A(e,"ill-formed tag handle (first argument) of the TAG directive"),s.call(e.tagMap,r)&&A(e,'there is a previously declared suffix for "'+r+'" tag handle'),c.test(i)||A(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagMap[r]=i}};function T(e,t,n,r){var i,s,a,l;if(t<n){if(l=e.input.slice(t,n),r)for(i=0,s=l.length;i<s;i+=1)9===(a=l.charCodeAt(i))||32<=a&&a<=1114111||A(e,"expected valid JSON character");else o.test(l)&&A(e,"the stream contains non-printable characters");e.result+=l}}function k(t,n,r,i){var o,a,l,u;for(e.isObject(r)||A(t,"cannot merge mappings; the provided source object is unacceptable"),l=0,u=(o=Object.keys(r)).length;l<u;l+=1)a=o[l],s.call(n,a)||(n[a]=r[a],i[a]=!0)}function O(e,t,n,r,i,o){var a,l;if(i=String(i),null===t&&(t={}),"tag:yaml.org,2002:merge"===r)if(Array.isArray(o))for(a=0,l=o.length;a<l;a+=1)k(e,t,o[a],n);else k(e,t,o,n);else e.json||s.call(n,i)||!s.call(t,i)||A(e,"duplicated mapping key"),t[i]=o,delete n[i];return t}function R(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):A(e,"a line break is expected"),e.line+=1,e.lineStart=e.position}function C(e,t,n){for(var r=0,i=e.input.charCodeAt(e.position);0!==i;){for(;d(i);)i=e.input.charCodeAt(++e.position);if(t&&35===i)do{i=e.input.charCodeAt(++e.position)}while(10!==i&&13!==i&&0!==i);if(!h(i))break;for(R(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;32===i;)e.lineIndent++,i=e.input.charCodeAt(++e.position)}return-1!==n&&0!==r&&e.lineIndent<n&&E(e,"deficient indentation"),r}function P(e){var t,n=e.position;return!(45!==(t=e.input.charCodeAt(n))&&46!==t||t!==e.input.charCodeAt(n+1)||t!==e.input.charCodeAt(n+2)||(n+=3,0!==(t=e.input.charCodeAt(n))&&!f(t)))}function M(t,n){1===n?t.result+=" ":n>1&&(t.result+=e.repeat("\n",n-1))}function N(e,t){var n,r,i=e.tag,s=e.anchor,o=[],a=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=o),r=e.input.charCodeAt(e.position);0!==r&&45===r&&f(e.input.charCodeAt(e.position+1));)if(a=!0,e.position++,C(e,!0,-1)&&e.lineIndent<=t)o.push(null),r=e.input.charCodeAt(e.position);else if(n=e.line,F(e,t,3,!1,!0),o.push(e.result),C(e,!0,-1),r=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==r)A(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return!!a&&(e.tag=i,e.anchor=s,e.kind="sequence",e.result=o,!0)}function I(e){var t,n,r,i,o=!1,a=!1;if(33!==(i=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&A(e,"duplication of a tag property"),60===(i=e.input.charCodeAt(++e.position))?(o=!0,i=e.input.charCodeAt(++e.position)):33===i?(a=!0,n="!!",i=e.input.charCodeAt(++e.position)):n="!",t=e.position,o){do{i=e.input.charCodeAt(++e.position)}while(0!==i&&62!==i);e.position<e.length?(r=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):A(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==i&&!f(i);)33===i&&(a?A(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),u.test(n)||A(e,"named tag handle cannot contain such characters"),a=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);r=e.input.slice(t,e.position),l.test(r)&&A(e,"tag suffix cannot contain flow indicator characters")}return r&&!c.test(r)&&A(e,"tag name cannot contain such characters: "+r),o?e.tag=r:s.call(e.tagMap,n)?e.tag=e.tagMap[n]+r:"!"===n?e.tag="!"+r:"!!"===n?e.tag="tag:yaml.org,2002:"+r:A(e,'undeclared tag handle "'+n+'"'),!0}function D(e){var t,n;if(38!==(n=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&A(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!f(n)&&!p(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&A(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function F(t,n,r,i,o){var a,l,u,c,m,b,x,w,E=1,S=!1,k=!1;if(null!==t.listener&&t.listener("open",t),t.tag=null,t.anchor=null,t.kind=null,t.result=null,a=l=u=4===r||3===r,i&&C(t,!0,-1)&&(S=!0,t.lineIndent>n?E=1:t.lineIndent===n?E=0:t.lineIndent<n&&(E=-1)),1===E)for(;I(t)||D(t);)C(t,!0,-1)?(S=!0,u=a,t.lineIndent>n?E=1:t.lineIndent===n?E=0:t.lineIndent<n&&(E=-1)):u=!1;if(u&&(u=S||o),1!==E&&4!==r||(x=1===r||2===r?n:n+1,w=t.position-t.lineStart,1===E?u&&(N(t,w)||function(e,t,n){var r,i,s,o,a=e.tag,l=e.anchor,u={},c={},h=null,p=null,g=null,m=!1,_=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=u),o=e.input.charCodeAt(e.position);0!==o;){if(r=e.input.charCodeAt(e.position+1),s=e.line,63!==o&&58!==o||!f(r)){if(!F(e,n,2,!1,!0))break;if(e.line===s){for(o=e.input.charCodeAt(e.position);d(o);)o=e.input.charCodeAt(++e.position);if(58===o)f(o=e.input.charCodeAt(++e.position))||A(e,"a whitespace character is expected after the key-value separator within a block mapping"),m&&(O(e,u,c,h,p,null),h=p=g=null),_=!0,m=!1,i=!1,h=e.tag,p=e.result;else{if(!_)return e.tag=a,e.anchor=l,!0;A(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!_)return e.tag=a,e.anchor=l,!0;A(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===o?(m&&(O(e,u,c,h,p,null),h=p=g=null),_=!0,m=!0,i=!0):m?(m=!1,i=!0):A(e,"incomplete explicit mapping pair; a key node is missed"),e.position+=1,o=r;if((e.line===s||e.lineIndent>t)&&(F(e,t,4,!0,i)&&(m?p=e.result:g=e.result),m||(O(e,u,c,h,p,g),h=p=g=null),C(e,!0,-1),o=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==o)A(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return m&&O(e,u,c,h,p,null),_&&(e.tag=a,e.anchor=l,e.kind="mapping",e.result=u),_}(t,w,x))||function(e,t){var n,r,i,s,o,a,l,u,c,h,d=!0,p=e.tag,g=e.anchor,m={};if(91===(h=e.input.charCodeAt(e.position)))i=93,a=!1,r=[];else{if(123!==h)return!1;i=125,a=!0,r={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=r),h=e.input.charCodeAt(++e.position);0!==h;){if(C(e,!0,t),(h=e.input.charCodeAt(e.position))===i)return e.position++,e.tag=p,e.anchor=g,e.kind=a?"mapping":"sequence",e.result=r,!0;d||A(e,"missed comma between flow collection entries"),c=null,s=o=!1,63===h&&f(e.input.charCodeAt(e.position+1))&&(s=o=!0,e.position++,C(e,!0,t)),n=e.line,F(e,t,1,!1,!0),u=e.tag,l=e.result,C(e,!0,t),h=e.input.charCodeAt(e.position),!o&&e.line!==n||58!==h||(s=!0,h=e.input.charCodeAt(++e.position),C(e,!0,t),F(e,t,1,!1,!0),c=e.result),a?O(e,r,m,u,l,c):s?r.push(O(e,null,m,u,l,c)):r.push(l),C(e,!0,t),44===(h=e.input.charCodeAt(e.position))?(d=!0,h=e.input.charCodeAt(++e.position)):d=!1}A(e,"unexpected end of the stream within a flow collection")}(t,x)?k=!0:(l&&function(t,n){var r,i,s,o,a,l=1,u=!1,c=n,f=0,p=!1;if(124===(o=t.input.charCodeAt(t.position)))i=!1;else{if(62!==o)return!1;i=!0}for(t.kind="scalar",t.result="";0!==o;)if(43===(o=t.input.charCodeAt(++t.position))||45===o)1===l?l=43===o?3:2:A(t,"repeat of a chomping mode identifier");else{if(!((s=48<=(a=o)&&a<=57?a-48:-1)>=0))break;0===s?A(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):u?A(t,"repeat of an indentation width identifier"):(c=n+s-1,u=!0)}if(d(o)){do{o=t.input.charCodeAt(++t.position)}while(d(o));if(35===o)do{o=t.input.charCodeAt(++t.position)}while(!h(o)&&0!==o)}for(;0!==o;){for(R(t),t.lineIndent=0,o=t.input.charCodeAt(t.position);(!u||t.lineIndent<c)&&32===o;)t.lineIndent++,o=t.input.charCodeAt(++t.position);if(!u&&t.lineIndent>c&&(c=t.lineIndent),h(o))f++;else{if(t.lineIndent<c){3===l?t.result+=e.repeat("\n",f):1===l&&u&&(t.result+="\n");break}for(i?d(o)?(p=!0,t.result+=e.repeat("\n",f+1)):p?(p=!1,t.result+=e.repeat("\n",f+1)):0===f?u&&(t.result+=" "):t.result+=e.repeat("\n",f):t.result+=u?e.repeat("\n",f+1):e.repeat("\n",f),u=!0,f=0,r=t.position;!h(o)&&0!==o;)o=t.input.charCodeAt(++t.position);T(t,r,t.position,!1)}}return!0}(t,x)||function(e,t){var n,r,i;if(39!==(n=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(T(e,r,e.position,!0),39!==(n=e.input.charCodeAt(++e.position)))return!0;r=i=e.position,e.position++}else h(n)?(T(e,r,i,!0),M(e,C(e,!1,t)),r=i=e.position):e.position===e.lineStart&&P(e)?A(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);A(e,"unexpected end of the stream within a single quoted scalar")}(t,x)||function(e,t){var n,r,i,s,o,a,l;if(34!==(a=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;0!==(a=e.input.charCodeAt(e.position));){if(34===a)return T(e,n,e.position,!0),e.position++,!0;if(92===a){if(T(e,n,e.position,!0),h(a=e.input.charCodeAt(++e.position)))C(e,!1,t);else if(a<256&&y[a])e.result+=v[a],e.position++;else if((o=120===(l=a)?2:117===l?4:85===l?8:0)>0){for(i=o,s=0;i>0;i--)(o=g(a=e.input.charCodeAt(++e.position)))>=0?s=(s<<4)+o:A(e,"expected hexadecimal character");e.result+=_(s),e.position++}else A(e,"unknown escape sequence");n=r=e.position}else h(a)?(T(e,n,r,!0),M(e,C(e,!1,t)),n=r=e.position):e.position===e.lineStart&&P(e)?A(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}A(e,"unexpected end of the stream within a double quoted scalar")}(t,x)?k=!0:function(e){var t,n,r;if(42!==(r=e.input.charCodeAt(e.position)))return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!f(r)&&!p(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&A(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),e.anchorMap.hasOwnProperty(n)||A(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],C(e,!0,-1),!0}(t)?(k=!0,null===t.tag&&null===t.anchor||A(t,"alias node should not have any properties")):function(e,t,n){var r,i,s,o,a,l,u,c,g=e.kind,m=e.result;if(f(c=e.input.charCodeAt(e.position))||p(c)||35===c||38===c||42===c||33===c||124===c||62===c||39===c||34===c||37===c||64===c||96===c)return!1;if((63===c||45===c)&&(f(r=e.input.charCodeAt(e.position+1))||n&&p(r)))return!1;for(e.kind="scalar",e.result="",i=s=e.position,o=!1;0!==c;){if(58===c){if(f(r=e.input.charCodeAt(e.position+1))||n&&p(r))break}else if(35===c){if(f(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&P(e)||n&&p(c))break;if(h(c)){if(a=e.line,l=e.lineStart,u=e.lineIndent,C(e,!1,-1),e.lineIndent>=t){o=!0,c=e.input.charCodeAt(e.position);continue}e.position=s,e.line=a,e.lineStart=l,e.lineIndent=u;break}}o&&(T(e,i,s,!1),M(e,e.line-a),i=s=e.position,o=!1),d(c)||(s=e.position+1),c=e.input.charCodeAt(++e.position)}return T(e,i,s,!1),!!e.result||(e.kind=g,e.result=m,!1)}(t,x,1===r)&&(k=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===E&&(k=u&&N(t,w))),null!==t.tag&&"!"!==t.tag)if("?"===t.tag){for(c=0,m=t.implicitTypes.length;c<m;c+=1)if((b=t.implicitTypes[c]).resolve(t.result)){t.result=b.construct(t.result),t.tag=b.tag,null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);break}}else s.call(t.typeMap,t.tag)?(b=t.typeMap[t.tag],null!==t.result&&b.kind!==t.kind&&A(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+b.kind+'", not "'+t.kind+'"'),b.resolve(t.result)?(t.result=b.construct(t.result),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):A(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")):A(t,"unknown tag !<"+t.tag+">");return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||k}function z(e){var t,n,r,i,o=e.position,l=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(i=e.input.charCodeAt(e.position))&&(C(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==i));){for(l=!0,i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!f(i);)i=e.input.charCodeAt(++e.position);for(r=[],(n=e.input.slice(t,e.position)).length<1&&A(e,"directive name must not be less than one character in length");0!==i;){for(;d(i);)i=e.input.charCodeAt(++e.position);if(35===i){do{i=e.input.charCodeAt(++e.position)}while(0!==i&&!h(i));break}if(h(i))break;for(t=e.position;0!==i&&!f(i);)i=e.input.charCodeAt(++e.position);r.push(e.input.slice(t,e.position))}0!==i&&R(e),s.call(S,n)?S[n](e,n,r):E(e,'unknown document directive "'+n+'"')}C(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,C(e,!0,-1)):l&&A(e,"directives end mark is expected"),F(e,e.lineIndent-1,4,!1,!0),C(e,!0,-1),e.checkLineBreaks&&a.test(e.input.slice(o,e.position))&&E(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&P(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,C(e,!0,-1)):e.position<e.length-1&&A(e,"end of the stream or a document separator is expected")}function L(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new x(e,t);for(n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)z(n);return n.documents}function j(e,t,n){var r,i,s=L(e,n);for(r=0,i=s.length;r<i;r+=1)t(s[r])}function V(e,n){var r=L(e,n);if(0!==r.length){if(1===r.length)return r[0];throw new t("expected a single document in the stream, but found more")}}return dt.loadAll=j,dt.load=V,dt.safeLoadAll=function(t,n,i){j(t,n,e.extend({schema:r},i))},dt.safeLoad=function(t,n){return V(t,e.extend({schema:r},n))},dt}();function t(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}return ht.Type=mt(),ht.Schema=_t(),ht.FAILSAFE_SCHEMA=xt(),ht.JSON_SCHEMA=Tt(),ht.CORE_SCHEMA=kt(),ht.DEFAULT_SAFE_SCHEMA=rn(),ht.DEFAULT_FULL_SCHEMA=ln(),ht.load=e.load,ht.loadAll=e.loadAll,ht.safeLoad=e.safeLoad,ht.safeLoadAll=e.safeLoadAll,ht.YAMLException=gt(),ht.MINIMAL_SCHEMA=xt(),ht.SAFE_SCHEMA=rn(),ht.DEFAULT_SCHEMA=ln(),ht.scan=t("scan"),ht.parse=t("parse"),ht.compose=t("compose"),ht.addConstructor=t("addConstructor"),ht}();return Xt=e}(),cn=e.getDefaultExportFromCjs(un);class hn{constructor(t,n,r=null){this.url=t,!n||e.isRelativeURL(n)&&!e.isRelativeURL(this.url)?this.path=e.pathForURL(this.url):this.path=n,this.path_for_parent=n||this.path,this.parent=r,this.container=null,this.parent&&(this.parent.container?this.container=this.parent.container:this.parent.isContainer()&&(this.container=this.parent))}load(){return fn(this.url)}resourceFor(e){return{url:this.urlFor(e),path:this.pathFor(e),type:this.typeFor(e)}}urlFor(t){return u(t)?t:e.isRelativeURL(t)&&this.container?this.parent.urlFor(this.path_for_parent+t):e.addBaseURL(t,this.path)}pathFor(t){return e.pathForURL(t)}typeFor(t){return e.extensionForURL(t)}isContainer(){return!1}}class dn extends hn{constructor(e,t,n){super(e,t,n),this.zip=null,this.files={},this.root=null,this.path=""}isContainer(){return!0}async load(){if(this.zip=new ct,"string"==typeof this.url){const{body:t}=await e.Utils.io(this.url,6e4,"arraybuffer");return await this.zip.loadAsync(t),await this.parseZipFiles(),this.loadRoot()}return this}urlFor(t){return u(t)?t:e.isRelativeURL(t)?this.urlForZipFile(e.flattenRelativeURL(t)):super.urlFor(t)}typeFor(t){return e.isRelativeURL(t)?this.typeForZipFile(t):super.typeFor(t)}loadRoot(){return this.findRoot(),fn(this.urlForZipFile(this.root))}findRoot(){const t=Object.keys(this.files).filter(e=>0===this.files[e].depth).filter(t=>"yaml"===e.extensionForURL(t));if(1===t.length&&(this.root=t[0]),!this.root){let e=`Could not find root scene for bundle '${this.url}': `;throw e+="The zip archive's root level must contain a single scene file with the '.yaml' extension. ",t.length>0?e+=`Found multiple YAML files at the root level: ${t.map(e=>"'"+e+"'").join(", ")}.`:e+="Found NO YAML files at the root level.",Error(e)}}async parseZipFiles(){let t=[],n=[];this.zip.forEach((e,r)=>{r.dir||(t.push(e),n.push(r.async("arraybuffer")))});const r=await Promise.all(n);for(let n=0;n<r.length;n++){let i=t[n],s=i.split("/").length-1;this.files[i]={data:r[n],type:e.extensionForURL(i),depth:s}}}urlForZipFile(t){if(this.files[t])return this.files[t].url||(this.files[t].url=e.createObjectURL(new Blob([this.files[t].data]))),this.files[t].url}typeForZipFile(e){return this.files[e]&&this.files[e].type}}function fn(t){return new Promise((n,r)=>{"string"==typeof t?e.Utils.io(t).then(({body:e})=>{try{n(function(e){return cn.safeLoad(e,{json:!0})}(e))}catch(e){r(e)}},r):(t=Object.assign({},t),n(t))})}const pn={async loadScene(t,{path:n,type:r}={}){const i=[],s={},o=await this.loadSceneRecursive({url:t,path:n,type:r},null,s,i),{config:a,bundle:l}=this.finalize(o);if(!a)throw i[0];return i.length>0&&i.forEach(t=>{const n=`Failed to import scene: ${t.url}`;e.log("error",n,t),this.trigger("error",{type:"scene_import",message:n,error:t,url:t.url})}),{config:a,bundle:l,texture_nodes:s}},async loadSceneRecursive({url:t,path:n,type:r},i,s={},o=[]){if(!t)return{};const a=function(t,n,r,i=null){return null!=i&&"zip"===i||"string"==typeof t&&!e.isLocalURL(t)&&"zip"===e.extensionForURL(t)?new dn(t,n,r):new hn(t,n,r)}(t,n,i,r);try{let t=await a.load();if(null==t.import)return this.normalize(t,a,s),{config:t,bundle:a};Array.isArray(t.import)||(t.import=[t.import]);const n=[];t.import.forEach(t=>{"object"==typeof t&&(t=e.createObjectURL(new Blob([JSON.stringify(t)]))),n.push(a.resourceFor(t))}),delete t.import;const r=n.map(e=>this.loadSceneRecursive(e,a,s,o)),i=(await Promise.all(r)).map(e=>this.normalize(e.config,e.bundle,s)).map(e=>e.config);return this.normalize(t,a,s),t=e.mergeObjects(...i,t),{config:t,bundle:a,texture_nodes:s}}catch(e){return e.url=t,o.push(e),{}}},normalize(e,t,n={}){return this.normalizeDataSources(e,t),this.normalizeFonts(e,t),this.normalizeTextures(e,t),this.collectTextures(e,t,n),{config:e,bundle:t,texture_nodes:n}},normalizeDataSources(e,t){e.sources=e.sources||{};for(const n in e.sources)this.normalizeDataSource(e.sources[n],t);return e},normalizeDataSource(e,t){if(e.url=t.urlFor(e.url),Array.isArray(e.composite)&&e.composite.forEach(e=>e.url=t.urlFor(e.url)),e.scripts){Array.isArray(e.scripts)&&(e.scripts=e.scripts.reduce((e,t)=>(e[t]=t,e),{}));for(const n in e.scripts)e.scripts[n]=t.urlFor(e.scripts[n])}return e},normalizeFonts(e,t){e.fonts=e.fonts||{};const n=Object.values(e.fonts).filter(e=>"external"!==e);for(const e of n)(Array.isArray(e)?e:[e]).forEach(e=>e.url=t.urlFor(e.url));return e},normalizeTextures(e,t){if(e.textures=e.textures||{},e.textures)for(const n in e.textures){const r=e.textures[n];r.url&&(r.url=t.urlFor(r.url))}},collectTextures(t,n,r){if(t.styles)for(const e in t.styles){const i=t.styles[e],s=i.texture;if("string"==typeof s&&!t.textures[s]){const t=["styles",e,"texture"];this.addTextureNode(t,n,r)}i.material&&["emission","ambient","diffuse","specular","normal"].forEach(s=>{const o=null!=i.material[s]&&i.material[s].texture;if("string"==typeof o&&!t.textures[o]){const t=["styles",e,"material",s,"texture"];this.addTextureNode(t,n,r)}})}if(t.styles)for(const i in t.styles){const s=t.styles[i];s.shaders&&s.shaders.uniforms&&e.GLSL.parseUniforms(s.shaders.uniforms).forEach(({type:e,value:s,path:o})=>{if("sampler2D"===e&&"string"==typeof s&&!t.textures[s]){const e=["styles",i,"shaders","uniforms",...o];this.addTextureNode(e,n,r)}})}if(t.layers){const i=[t.layers],s=[["layers"]];for(;i.length>0;){const o=i.pop(),a=s.pop();if("object"==typeof o&&!Array.isArray(o))for(const l in o)if("draw"===l){const e=o[l];for(const i in e){if(e[i].texture){const s=e[i].texture;if("string"==typeof s&&!t.textures[s]){const e=[...a,l,"draw",i,"texture"];this.addTextureNode(e,n,r)}}if(e[i].outline&&e[i].outline.texture){const s=e[i].outline.texture;if("string"==typeof s&&!t.textures[s]){const e=[...a,l,"draw",i,"outline","texture"];this.addTextureNode(e,n,r)}}}}else{if(e.isReserved(l))continue;i.push(o[l]),s.push([...a,l])}}}},addTextureNode(e,t,n){n[JSON.stringify(e)]={path:e,bundle:t}},hoistTextureNodes(e,t,n={}){for(const{path:r,bundle:o}of Object.values(n)){const n=i(e,r);if("string"==typeof n&&null==e.textures[n])if(c(e,r)){const r=t.urlFor(n);e.textures[n]={url:r}}else{const t=o.urlFor(n);e.textures[t]={url:t},s(e,r,t)}}},applyGlobalProperties:e=>e.global&&0!==Object.keys(e.global).length?d(h(e.global),e):e,finalize:({config:e,bundle:t})=>e?(e.global=e.global||{},e.scene=e.scene||{},e.cameras=e.cameras||{},e.lights=e.lights||{},e.styles=e.styles||{},e.layers=e.layers||{},e.camera&&(e.cameras.default=e.camera),0===Object.keys(e.cameras).length&&(e.cameras.default={}),(0===Object.keys(e.lights).length||Object.keys(e.lights).every(t=>!1===e.lights[t].visible))&&(e.lights.default_light={type:"directional"}),{config:e,bundle:t}):{}};e.subscribeMixin(pn);class gn{constructor(){this.tiles={},this.max_proxy_descendant_depth=6,this.max_proxy_ancestor_depth=7,this.children_cache={}}addTile(t){for(this.tiles[t.key]=this.tiles[t.key]||{descendants:0},this.tiles[t.key].tile=t;t.style_z>=0;){if(!(t=e.TileID.parent(t)))return;this.tiles[t.key]||(this.tiles[t.key]={descendants:0}),this.tiles[t.key].descendants++}}removeTile(t){for(this.tiles[t.key]&&(delete this.tiles[t.key].tile,0===this.tiles[t.key].descendants&&delete this.tiles[t.key]);t.style_z>=0;){if(!(t=e.TileID.parent(t)))return;this.tiles[t.key]&&this.tiles[t.key].descendants>0&&(this.tiles[t.key].descendants--,0!==this.tiles[t.key].descendants||this.tiles[t.key].tile||delete this.tiles[t.key])}}getAncestor(t){let n=0;for(;n<this.max_proxy_ancestor_depth;){if(!(t=e.TileID.parent(t)))return;if(this.tiles[t.key]&&this.tiles[t.key].tile&&this.tiles[t.key].tile.loaded)return this.tiles[t.key].tile;n++}}getDescendants(t,n=0){let r=[];if(n<this.max_proxy_descendant_depth){let i=e.TileID.children(t,this.children_cache);if(!i)return;i.forEach(e=>{this.tiles[e.key]&&(this.tiles[e.key].tile&&this.tiles[e.key].tile.loaded?r.push(this.tiles[e.key].tile):this.tiles[e.key].descendants>0&&r.push(...this.getDescendants(e,n+1)))})}return r}}let mn={},_n={};function yn(t,n=null){if(this.obb)return e.Label.prototype.occluded.call(this,t,n);if(this.obbs)for(let r=0;r<this.obbs.length;r++){let i={aabb:this.aabbs[r],obb:this.obbs[r]};if(e.Label.prototype.occluded.call(i,t,n))return!0}return!1}class vn{constructor({scene:t}){this.scene=t,this.tiles={},this.pyramid=new gn,this.visible_coords={},this.queued_coords=[],this.building_tiles=null,this.renderable_tiles=[],this.collision={tile_keys:null,mesh_set:null,zoom:null,zoom_steps:3},this.main_thread_target=["TileManager",this.scene.id].join("_"),e.WorkerBroker.addTarget(this.main_thread_target,this)}destroy(){this.forEachTile(e=>e.destroy()),this.tiles={},this.pyramid=null,this.visible_coords={},this.queued_coords=[],this.scene=null,e.WorkerBroker.removeTarget(this.main_thread_target)}get view(){return this.scene.view}get style_manager(){return this.scene.style_manager}keepTile(e){this.tiles[e.key]=e,this.pyramid.addTile(e)}hasTile(e){return void 0!==this.tiles[e]}forgetTile(e){if(this.hasTile(e)){let t=this.tiles[e];this.pyramid.removeTile(t)}delete this.tiles[e],this.tileBuildStop(e)}removeTile(t){e.log("trace",`tile unload for ${t}`);var n=this.tiles[t];null!=n&&n.destroy(),this.forgetTile(n.key),this.scene.requestRedraw()}forEachTile(e){for(let t in this.tiles)e(this.tiles[t])}removeTiles(e){let t=[];for(let n in this.tiles)e(this.tiles[n])&&t.push(n);for(let e=0;e<t.length;e++){let n=t[e];this.removeTile(n)}}updateTilesForView(){this.visible_coords={};let e=this.view.findVisibleTileCoordinates();for(let t=0;t<e.length;t++){const n=e[t];this.queueCoordinate(n),this.visible_coords[n.key]=n}this.updateTileStates()}updateTileStates(){return this.forEachTile(e=>{this.updateVisibility(e)}),this.loadQueuedCoordinates(),this.updateProxyTiles(),this.view.pruneTilesForView(),this.updateRenderableTiles(),this.style_manager.updateActiveStyles(this.renderable_tiles),this.style_manager.updateActiveBlendOrders(this.renderable_tiles),this.updateLabels()}updateLabels(){var t=this;if(this.scene.building&&!this.scene.building.initial)return Promise.resolve({});const n=this.renderable_tiles.filter(e=>e.valid).filter(e=>e.built);return 0===n.length?Promise.resolve({}):(n.sort((e,t)=>e.build_id<t.build_id?-1:e.build_id>t.build_id?1:0),this.collision.zoom===bn(this.view.zoom,this.collision.zoom_steps)&&this.collision.tile_keys===JSON.stringify(n.map(e=>e.key))&&this.collision.mesh_set===xn(n)?Promise.resolve({}):(this.collision.task||(this.collision.zoom=bn(this.view.zoom,this.collision.zoom_steps),this.collision.tile_keys=JSON.stringify(n.map(e=>e.key)),this.collision.mesh_set=xn(n),this.collision.task={type:"tileManagerUpdateLabels",run:async function(r){const i=await async function(t,n,r=!1){_n=mn,mn={};let i=function(t,n){let r={};t.forEach(t=>{const i=e.Geo.unitsPerMeter(t.coords.z),s=Math.pow(2,n-t.style_z),o=i*s,a=e.Geo.metersPerPixel(n),l=Object.assign({},t.meshes,t.pending_label_meshes);for(let n in l)l[n].forEach(n=>{if(n.labels)for(let s in n.labels){if(t.isProxy()&&!_n[s])continue;const l=n.labels[s].container.label,u=n.labels[s].container.linked,c=n.labels[s].ranges;let h={};if(h.discard=yn.bind(h),h.build_id=t.build_id,Object.assign(h,l),h.layout=Object.assign({},l.layout),h.layout.repeat_scale=.75,h.layout.repeat_distance=h.layout.repeat_distance||0,h.layout.repeat_distance/=o,h.position=[h.position[0]/i+t.min.x,h.position[1]/i+t.min.y],h.unit_scale=a,"point"===h.type)e.LabelPoint.prototype.updateBBoxes.call(h);else if("straight"===h.type)e.LabelLineStraight.prototype.updateBBoxes.call(h,h.position,h.size,h.angle,h.angle,h.offset);else if(l.obbs){const n=l.obbs.map(n=>{let{x:r,y:s,a:a,w:l,h:u}=n;return r=r/i+t.min.x,s=s/i+t.min.y,l/=o,u/=o,new e.OBB(r,s,a,l,u)});h.obbs=n,h.aabbs=n.map(e=>e.getExtent())}r[s]={label:h,linked:u,ranges:c,mesh:n}}})});for(let e in r){const t=r[e];t.linked&&(t.linked=r[t.linked])}return r=Object.keys(r).map(e=>r[e]),r}(t,n);e.Collision.startTile("main",{apply_repeat_groups:!0,return_hidden:!0}),e.Collision.addStyle("main","main");const s=Math.max(0,...Object.values(t).map(e=>Object.values(e.meshes)).flat().map(e=>Math.max(0,...e.map(e=>e.labels?Object.keys(e.labels).length:0)))),o=Math.floor(s/e.Geo.tile_size);o>0?e.Collision.initGrid({anchor:{x:Math.min(...t.map(e=>e.min.x)),y:Math.min(...t.map(e=>e.min.y))},span:t[0].span.x/o}):e.Collision.initGrid();const a=await e.Collision.collide(i,"main","main");let l=[];return a.forEach(e=>{let t=0;!0!==e.show||r&&e.label.breach&&!_n[e.label.id]||(t=1),t&&(mn[e.label.id]=!0);let n=!0;e.ranges.forEach(r=>{if(!n)return;let i=e.mesh;if(!i.valid)return;let s=i.vertex_layout.offset.a_shape,o=i.vertex_layout.stride;for(let e=0;e<r[1];e++){if(i.vertex_data[r[0]+e*o+s+6]===t)return void(n=!1);i.vertex_data[r[0]+e*o+s+6]=t}-1===l.indexOf(i)&&l.push(i)})}),l.forEach(e=>e.upload()),t.forEach(e=>e.swapPendingLabels()),{labels:a,containers:i}}(n,t.collision.zoom,t.isLoadingVisibleTiles());t.scene.requestRedraw(),t.collision.task=null,e.Task.finish(r,i),t.updateTileStates()},immediate:!0},e.Task.add(this.collision.task)),this.collision.task.promise))}updateProxyTiles(){if(0===this.view.zoom_direction)return;this.forEachTile(e=>e.setProxyFor(null));let e=!1;this.forEachTile(t=>{if(t.visible&&!t.labeled){const n=this.pyramid.getAncestor(t);if(n)n.setProxyFor(t),e=!0;else{const n=this.pyramid.getDescendants(t);for(let r=0;r<n.length;r++)n[r].setProxyFor(t),e=!0}}}),e||(this.view.zoom_direction=0)}updateVisibility(t){if(t.visible=!1,t.style_z===this.view.tile_zoom)if(this.visible_coords[t.coords.key])t.visible=!0;else for(let n in this.visible_coords)if(e.TileID.isDescendant(t.coords,this.visible_coords[n])){t.visible=!0;break}}pruneToVisibleTiles(){this.removeTiles(e=>!e.visible)}getRenderableTiles(){return this.renderable_tiles}updateRenderableTiles(){this.renderable_tiles=[];for(let e in this.tiles){let t=this.tiles[e];t.visible&&t.loaded&&this.renderable_tiles.push(t)}return this.renderable_tiles}isLoadingVisibleTiles(){return Object.keys(this.tiles).some(e=>this.tiles[e].visible&&!this.tiles[e].built)}allVisibleTilesLabeled(){return this.renderable_tiles.every(e=>e.labeled)}queueCoordinate(e){this.queued_coords[this.queued_coords.length]=e}loadQueuedCoordinates(){0!==this.queued_coords.length&&(this.queued_coords.sort((t,n)=>{let r=this.view.center.meters,i=e.Geo.metersPerTile(t.z)/2,s=e.Geo.metersForTile(t);s.x+=i,s.y-=i;let o=e.Geo.metersForTile(n);o.x+=i,o.y-=i;let a=Math.abs(r.x-s.x)+Math.abs(r.y-s.y),l=Math.abs(r.x-o.x)+Math.abs(r.y-o.y);return t.center_dist=a,n.center_dist=l,l>a?-1:l===a?0:1}),this.queued_coords.forEach(e=>this.loadCoordinate(e)),this.queued_coords=[])}loadCoordinate(t){if(t.z===this.view.center.tile.z)for(let n in this.scene.sources){let r=this.scene.sources[n];if(!r.builds_geometry_tiles||!r.includesTile(t,this.view.tile_zoom))continue;let i=e.TileID.normalizedKey(t,r,this.view.tile_zoom);if(i&&!this.hasTile(i)){e.log("trace",`load tile ${i}, distance from view center: ${t.center_dist}`);let n=new e.Tile({source:r,coords:t,workers:this.scene.workers,style_z:this.view.baseZoom(t.z),view:this.view});this.keepTile(n),this.buildTile(n)}}}buildTile(e,t){this.tileBuildStart(e.key),this.updateVisibility(e),e.build(this.scene.generation,t)}buildTileStylesCompleted({tile:t,progress:n}){if(null==this.tiles[t.key])e.log("trace",`discarded tile ${t.key} in TileManager.buildTileStylesCompleted because previously removed`),e.Tile.abortBuild(t),this.updateTileStates();else if(t.generation!==this.scene.generation)e.log("trace",`discarded tile ${t.key} in TileManager.buildTileStylesCompleted because built with scene config gen ${t.generation}, current ${this.scene.generation}`),e.Tile.abortBuild(t),this.updateTileStates();else{if(this.tiles[t.key]){if(t.id<this.tiles[t.key].id)return e.log("trace",`discarded tile ${t.key} for id ${t.id} in TileManager.buildTileStylesCompleted because built for discarded tile id`),void e.Tile.abortBuild(t);t=this.tiles[t.key].merge(t)}n.done&&(t.built=!0),t.buildMeshes(this.scene.styles,n),this.updateTileStates(),this.scene.requestRedraw()}n.done&&this.tileBuildStop(t.key)}buildTileError(t){e.log("error",`Error building tile ${t.key}:`,t.error),this.forgetTile(t.key),e.Tile.abortBuild(t)}tileBuildStart(t){this.building_tiles=this.building_tiles||{},this.building_tiles[t]=!0,e.log("trace",`tileBuildStart for ${t}: ${Object.keys(this.building_tiles).length}`)}tileBuildStop(t){this.building_tiles&&(e.log("trace",`tileBuildStop for ${t}: ${Object.keys(this.building_tiles).length}`),delete this.building_tiles[t],this.checkBuildQueue())}checkBuildQueue(){this.building_tiles&&0!==Object.keys(this.building_tiles).length||(this.building_tiles=null,this.scene.tileManagerBuildDone())}getDebugProp(e,t){var n=[];for(var r in this.tiles)null==this.tiles[r].debug[e]||"function"==typeof t&&!0!==t(this.tiles[r])||n.push(this.tiles[r].debug[e]);return n}getDebugSum(e,t){var n=0;for(var r in this.tiles)null==this.tiles[r].debug[e]||"function"==typeof t&&!0!==t(this.tiles[r])||(n+=this.tiles[r].debug[e]);return n}getDebugAverage(e,t){return this.getDebugSum(e,t)/Object.keys(this.tiles).length}}function bn(e,t,n=2){return(Math.floor(e*t)/t).toFixed(n)}function xn(e){return JSON.stringify(Object.entries(e).map(([,e])=>Object.entries(e.meshes).map(([,e])=>e.map(e=>e.created_at))))}class wn{constructor(e,t){t(e),this.value=e,this.setup=t}set(e){JSON.stringify(this.value)!==JSON.stringify(e)&&(this.setup(e),this.value=e)}}class An{constructor(e){this.defaults={},this.defaults.culling=!0,this.defaults.culling_face=e.BACK,this.defaults.blending=!1,this.defaults.blending_src=e.ONE_MINUS_SRC_ALPHA,this.defaults.blending_dst=e.ONE_MINUS_SRC_ALPHA,this.defaults.blending_src_alpha=e.ONE,this.defaults.blending_dst_alpha=e.ONE_MINUS_SRC_ALPHA,this.defaults.depth_write=!0,this.defaults.depth_test=!0,e.depthFunc(e.LESS),this.culling=new wn({cull:this.defaults.culling,face:this.defaults.culling_face},t=>{t.cull?(e.enable(e.CULL_FACE),e.cullFace(t.face)):e.disable(e.CULL_FACE)}),this.blending=new wn({blend:this.defaults.blending,src:this.defaults.blending_src,dst:this.defaults.blending_dst,src_alpha:this.defaults.blending_src_alpha,dst_alpha:this.defaults.blending_dst_alpha},t=>{t.blend?(e.enable(e.BLEND),t.src_alpha&&t.dst_alpha?e.blendFuncSeparate(t.src,t.dst,t.src_alpha,t.dst_alpha):e.blendFunc(t.src,t.dst)):e.disable(e.BLEND)}),this.depth_write=new wn({depth_write:this.defaults.depth_write},t=>{e.depthMask(t.depth_write)}),this.depth_test=new wn({depth_test:this.defaults.depth_test},t=>{t.depth_test?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST)})}}class En{constructor(){this.canvas=null,this.gl=null,this.screenshot_canvas=null,this.screenshot_context=null,this.queue_screenshot=null,this.video_capture=null}setCanvas(e,t){this.canvas=e,this.gl=t}screenshot({background:e}={}){return null!=this.queue_screenshot||(this.queue_screenshot={background:e},this.queue_screenshot.promise=new Promise((e,t)=>{this.queue_screenshot.resolve=e,this.queue_screenshot.reject=t})),this.queue_screenshot.promise}completeScreenshot(){if(null!=this.queue_screenshot){let t=this.canvas.width,n=this.canvas.height,r=new Uint8Array(t*n*4);this.gl.readPixels(0,0,t,n,this.gl.RGBA,this.gl.UNSIGNED_BYTE,r);let i=this.queue_screenshot.background;i=i&&"transparent"!==i?e.StyleParser.parseColor(i).slice(0,3).map(e=>255*e):null;let s=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let o=0;o<t;o++){let a=4*((n-e-1)*t+o),l=4*(e*t+o),u=r[a+3];s[l+0]=255*r[a+0]/u,s[l+1]=255*r[a+1]/u,s[l+2]=255*r[a+2]/u,s[l+3]=u,i&&(u/=255,s[l+0]=s[l+0]*u+i[0]*(1-u),s[l+1]=s[l+1]*u+i[1]*(1-u),s[l+2]=s[l+2]*u+i[2]*(1-u),s[l+3]=255)}this.screenshot_canvas=this.screenshot_canvas||document.createElement("canvas");let o=this.screenshot_canvas;o.width=t,o.height=n,this.screenshot_context=this.screenshot_context||o.getContext("2d");let a=this.screenshot_context,l=new ImageData(s,t,n);a.putImageData(l,0,0);const u=o.toDataURL("image/png"),c=atob(u.slice(22)),h=new Uint8Array(c.length);for(let e=0;e<c.length;++e)h[e]=c.charCodeAt(e);const d=new Blob([h],{type:"image/png"});this.queue_screenshot.resolve({url:u,blob:d,type:"png"}),this.queue_screenshot=null}}startVideoCapture(){if("function"!=typeof window.MediaRecorder||!this.canvas||"function"!=typeof this.canvas.captureStream)return e.log("warn","Video capture (Canvas.captureStream and/or MediaRecorder APIs) not supported by browser"),!1;if(this.video_capture)return e.log("warn","Video capture already in progress, call Scene.stopVideoCapture() first"),!1;try{let t=this.video_capture={};t.chunks=[],t.stream=this.canvas.captureStream(),t.options={mimeType:"video/webm"},t.media_recorder=new MediaRecorder(t.stream,t.options),t.media_recorder.ondataavailable=n=>{if(n.data.size>0&&t.chunks.push(n.data),t.resolve){let n=new Blob(t.chunks,{type:t.options.mimeType}),r=e.createObjectURL(n);t.stream&&(t.stream.getTracks()||[]).forEach(e=>{e.stop(),t.stream.removeTrack(e)}),t.stream=null,t.media_recorder=null,this.video_capture=null,t.resolve({url:r,blob:n,type:"webm"})}},t.media_recorder.start()}catch(t){return this.video_capture=null,e.log("error","Scene video capture failed",t),!1}return!0}stopVideoCapture(){return this.video_capture?(this.video_capture.promise=new Promise((e,t)=>{this.video_capture.resolve=e,this.video_capture.reject=t}),this.video_capture.media_recorder.stop(),this.video_capture.promise):(e.log("warn","No scene video capture in progress, call Scene.startVideoCapture() first"),Promise.resolve({}))}}function Sn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tn(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?Sn(Object(r),!0).forEach(function(n){e._defineProperty(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Sn(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}class kn{constructor(t,n){var r;n=n||{},e.subscribeMixin(this),this.id=kn.id++,this.initialized=!1,this.initializing=null,this.sources={},this.view=new e.View(this,n),this.tile_manager=new vn({scene:this}),this.num_workers=n.numWorkers||2,!0===n.disableVertexArrayObjects&&(e.VertexArrayObject.disabled=!0),e.Utils.use_high_density_display=void 0===n.highDensityDisplay||n.highDensityDisplay,e.Utils.updateDevicePixelRatio(),this.config=null,this.config_source=t,this.config_bundle=null,this.last_valid_config_source=null,this.styles=null,this.style_manager=new e.StyleManager,this.building=null,this.dirty=!0,n.preUpdate&&this.subscribe({pre_update:n.preUpdate}),n.postUpdate&&this.subscribe({post_update:n.postUpdate}),this.render_loop=!n.disableRenderLoop,this.render_loop_active=!1,this.render_loop_stop=!1,this.render_count=0,this.last_render_count=0,this.render_count_changed=!1,this.frame=0,this.last_main_render=-1,this.last_selection_render=-1,this.media_capture=new En,this.selection=null,this.selection_feature_count=0,this.fetching_selection_map=null,this.prev_textures=null,this.introspection=!0===n.introspection,this.times={},this.resetTime(),this.container=n.container,this.canvas=null,this.contextOptions=n.webGLContextOptions,this.lights=null,this.background=null,this.createListeners(),this.updating=0,this.generation=kn.generation,this.last_complete_generation=kn.generation,(r=this).debug={profile(t){console.profile(`main thread: ${t}`),e.WorkerBroker.postMessage(r.workers,"self.profile",t)},profileEnd(t){console.profileEnd(`main thread: ${t}`),e.WorkerBroker.postMessage(r.workers,"self.profileEnd",t)},timeRebuild(t=1,n={}){let i=[],s=()=>{let o=+new Date;r.rebuild(n).then(()=>{if(i.push(+new Date-o),i.length<t)s();else{let n=~~(i.reduce((e,t)=>e+t)/i.length);e.log("info",`Profiled rebuild ${t} times: ${n} avg (${Math.min(...i)} min, ${Math.max(...i)} max)`)}})};s()},geometryCountByStyle(){let e={};return r.tile_manager.getRenderableTiles().forEach(t=>{for(let n in t.meshes)e[n]=e[n]||0,t.meshes[n].forEach(t=>{e[n]+=t.geometry_count})}),e},geometryCountByBaseStyle(){let e=r.debug.geometryCountByStyle(),t={};for(let n in e){let i=r.styles[n].baseStyle();t[i]=t[i]||0,t[i]+=e[n]}return t},geometryCountTotal(){const e=r.debug.geometryCountByStyle();return Object.keys(e).reduce((t,n)=>e[n]+t,0)},geometrySizeByStyle(){let e={};return r.tile_manager.getRenderableTiles().forEach(t=>{for(let n in t.meshes)e[n]=e[n]||0,t.meshes[n].forEach(t=>{e[n]+=t.buffer_size})}),e},geometrySizeByBaseStyle(){let e=r.debug.geometrySizeByStyle(),t={};for(let n in e){let i=r.styles[n].baseStyle();t[i]=t[i]||0,t[i]+=e[n]}return t},geometrySizeTotal(){const e=r.debug.geometrySizeByStyle();return Object.keys(e).reduce((t,n)=>e[n]+t,0)},textureSizeTotal:()=>Object.values(e.Texture.textures).map(e=>e.byteSize()).reduce((e,t)=>e+t),layerStats:()=>e.debugSettings.layer_stats?e.debugSumLayerStats(r.tile_manager.getRenderableTiles()):(e.log("warn","Enable the 'layer_stats' debug setting to collect layer stats"),{}),renderableTilesCount:()=>r.tile_manager.getRenderableTiles().length},this.log_level=n.logLevel||"warn",e.log.setLevel(this.log_level),e.log.reset()}static create(e,t={}){return new kn(e,t)}load(t=null,n={}){var r=this;return this.initializing||(e.log.reset(),this.updating++,this.initialized=!1,this.view_complete=!1,this.times.frame=null,this.times.build=null,(n="string"==typeof n?{base_path:n}:n).blocking=void 0===n.blocking||n.blocking,!1!==this.render_loop&&this.setupRenderLoop(),this.createCanvas(),this.prev_textures=this.config&&Object.keys(this.config.textures),this.initializing=this.loadScene(t,n).then(async function({texture_nodes:t}){await r.createWorkers(),r.destroyFeatureSelection(),e.WorkerBroker.postMessage(r.workers,"self.clearFunctionStringCache");const i="object"==typeof r.config_source||r.hasSubscribersFor("load"),s=r.updateConfig({texture_nodes:t,serialize_funcs:i,normalize:!1,loading:!0,fade_in:!0});!0===n.blocking&&await s,r.freePreviousTextures(),r.updating--,r.initializing=null,r.initialized=!0,r.last_valid_config_source=r.config_source,r.last_valid_options={base_path:n.base_path,file_type:n.file_type},r.requestRedraw()}).catch(t=>{let n,r;if(this.initializing=null,this.updating=0,"YAMLException"===t.name?(n="yaml",r="Error parsing scene YAML"):r="Error initializing scene",this.trigger("error",{type:n,message:r,error:t,url:this.config_source}),r=`Scene.load() failed to load ${JSON.stringify(this.config_source)}: ${t.message}`,this.last_valid_config_source)return e.log("warn",r,t),e.log("info","Scene.load() reverting to last valid configuration"),this.load(this.last_valid_config_source,this.last_valid_base_path);throw e.log("error",r,t),t})),this.initializing}destroy(){if(this.initialized=!1,this.render_loop_stop=!0,this.destroyListeners(),this.destroyFeatureSelection(),this.canvas&&this.canvas.parentNode&&(this.canvas.parentNode.removeChild(this.canvas),this.canvas=null),this.container=null,this.gl){e.Texture.destroy(this.gl),this.style_manager.destroy(this.gl),this.styles={},e.ShaderProgram.reset();let t=this.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this.gl=null}this.sources={},this.destroyWorkers(),this.tile_manager.destroy(),this.tile_manager=null,e.log.reset()}createCanvas(){if(!this.canvas){this.container=this.container||document.body,this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.top=0,this.canvas.style.left=0,this.container.style.backgroundColor="transparent",this.container.appendChild(this.canvas);try{this.gl=n.getContext(this.canvas,Object.assign({alpha:!0,premultipliedAlpha:!0,stencil:!0,device_pixel_ratio:e.Utils.device_pixel_ratio,powerPreference:"high-performance"},this.contextOptions))}catch(e){throw new Error("Couldn't create WebGL context. Your browser may not support WebGL, or it's turned off? Visit http://webglreport.com/ for more info.")}this.resizeMap(this.container.clientWidth,this.container.clientHeight),e.VertexArrayObject.init(this.gl),this.render_states=new An(this.gl),this.media_capture.setCanvas(this.canvas,this.gl)}}updateExternalScripts(){let e=[...this.external_scripts||[]],t=[];if(this.config.scene.scripts)for(let e in this.config.scene.scripts)-1===t.indexOf(this.config.scene.scripts[e])&&t.push(this.config.scene.scripts[e]);for(let e in this.config.sources){let n=this.config.sources[e];if(n.scripts)for(let e in n.scripts)-1===t.indexOf(n.scripts[e])&&t.push(n.scripts[e])}return this.external_scripts=t,!(this.external_scripts.length===e.length&&this.external_scripts.every((t,n)=>t===e[n]))}createWorkers(){return this.updateExternalScripts()&&this.destroyWorkers(),this.workers?Promise.resolve():this.makeWorkers()}makeWorkers(){let t=!!this.gl.getExtension("OES_element_index_uint"),n=[];this.workers=[];for(let r=0;r<this.num_workers;r++){let i=new Worker(ix.workerURL);this.workers[r]=i,e.WorkerBroker.addWorker(i),e.log("debug",`Scene.makeWorkers: initializing worker ${r}`);let s=r;n.push(e.WorkerBroker.postMessage(i,"self.init",this.id,r,this.num_workers,this.log_level,e.Utils.device_pixel_ratio,t,this.external_scripts).then(t=>(e.log("debug",`Scene.makeWorkers: initialized worker ${t}`),t),t=>(e.log("error",`Scene.makeWorkers: failed to initialize worker ${s}:`,t),Promise.reject(t))))}return this.next_worker=0,Promise.all(n).then(()=>{e.log.setWorkers(this.workers)})}destroyWorkers(){this.selection=null,Array.isArray(this.workers)&&(e.log.setWorkers(null),this.workers.forEach(e=>{e.terminate()}),this.workers=null)}ready(){return!(!this.view.ready()||0===Object.keys(this.sources).length)}updateDevicePixelRatio(){e.Utils.updateDevicePixelRatio()&&e.WorkerBroker.postMessage(this.workers,"self.updateDevicePixelRatio",e.Utils.device_pixel_ratio).then(()=>this.rebuild()).then(()=>this.resizeMap(this.view.size.css.width,this.view.size.css.height))}resizeMap(t,r){0===t&&0===r||(this.dirty=!0,this.view.setViewportSize(t,r),this.gl&&n.resize(this.gl,t,r,e.Utils.device_pixel_ratio))}requestRedraw(){this.dirty=!0}immediateRedraw(){this.dirty=!0,this.update()}renderLoop(){this.render_loop_active=!0,this.update(),e.Task.setState({user_moving_view:this.view.user_input_active}),e.Task.processAll(),this.render_loop_stop?(this.render_loop_stop=!1,this.render_loop_active=!1):window.requestAnimationFrame(this.renderLoop.bind(this))}setupRenderLoop(){this.render_loop_active||setTimeout(()=>{this.renderLoop()},0)}update(){let t=this.dirty,n=!!this.selection&&this.selection.hasPendingRequests();var r=!(!1===t&&!1===n||!1===this.initialized||this.updating>0||!1===this.ready());return this.trigger("pre_update",r),this.view.update(),!!r&&(this.dirty=!1,this.updateDevicePixelRatio(),this.render({main:t,selection:n}),this.updateViewComplete(),this.media_capture.completeScreenshot(),this.trigger("post_update",r),(!0===this.animated||this.view.isAnimating())&&(this.dirty=!0),this.frame++,e.log("trace","Scene.render()"),!0)}render({main:t,selection:n}){var r=this.gl;if(this.updateBackground(),Object.keys(this.lights).forEach(e=>this.lights[e].update()),this.render_count_changed=!1,t&&(this.render_count=this.renderPass(),this.last_main_render=this.frame,this.render_count!==this.last_render_count&&(this.render_count_changed=!0,this.logFirstFrame(),this.getFeatureSelectionMapSize().then(t=>{this.selection_feature_count=t,e.log("info",`Scene: rendered ${this.render_count} primitives (${t} features in selection map)`)})),this.last_render_count=this.render_count),n){if(this.view.panning||this.view.user_input_active)return void this.selection.clearPendingRequests();!this.selection.locked&&this.last_selection_render<this.last_main_render&&(this.selection.bind(),this.renderPass("selection_program",{allow_blend:!1}),r.bindFramebuffer(r.FRAMEBUFFER,null),r.viewport(0,0,this.canvas.width,this.canvas.height),r.clearColor(...this.background.computed_color),this.last_selection_render=this.frame),this.selection.read()}return!0}renderPass(t="program",{allow_blend:n}={}){n=null==n||n,this.clearFrame();let r,i=0;const s=this.style_manager.getActiveBlendOrders();for(const{blend_order:o,styles:a}of s)for(let s=0;s<a.length;s++){let l=this.styles[a[s]];if(null==l)continue;if(l.blend!==r){let t=Object.assign({},e.Style.render_states[l.blend],{blend:n&&l.blend});this.setRenderState(t)}const u=n&&l.blend;if("translucent"===u)this.gl.colorMask(!1,!1,!1,!1),this.renderStyle(l.name,t,o),this.gl.colorMask(!0,!0,!0,!0),this.gl.depthFunc(this.gl.EQUAL),this.gl.enable(this.gl.STENCIL_TEST),this.gl.clearStencil(0),this.gl.clear(this.gl.STENCIL_BUFFER_BIT),this.gl.stencilFunc(this.gl.EQUAL,this.gl.ZERO,255),this.gl.stencilOp(this.gl.KEEP,this.gl.KEEP,this.gl.INCR),i+=this.renderStyle(l.name,t,o),this.gl.disable(this.gl.STENCIL_TEST),this.gl.depthFunc(this.gl.LESS);else if("opaque"!==u&&!0===l.stencil_proxy_tiles){const e=this.tile_manager.getRenderableTiles().filter(e=>e.meshes[l.name]).map(e=>e.proxy_level).reduce((e,t)=>(e.indexOf(t)>-1||e.push(t),e),[]).sort();if(e.length>1){this.gl.enable(this.gl.STENCIL_TEST),this.gl.clearStencil(0),this.gl.clear(this.gl.STENCIL_BUFFER_BIT),this.gl.stencilOp(this.gl.KEEP,this.gl.KEEP,this.gl.REPLACE);for(let n=0;n<e.length;n++)this.gl.stencilFunc(this.gl.GEQUAL,e.length-n,255),i+=this.renderStyle(l.name,t,o,e[n]);this.gl.disable(this.gl.STENCIL_TEST)}else i+=this.renderStyle(l.name,t,o)}else i+=this.renderStyle(l.name,t,o);r=l.blend}return i}renderStyle(e,t,n,r=null){let i,s=this.styles[e],o=!0,a=0,l=this.tile_manager.getRenderableTiles().filter(e=>"number"!=typeof r||e.proxy_level===r).map(t=>{if(t.meshes[e])return[t,t.meshes[e].filter(e=>e.variant.blend_order===n)]}).filter(e=>e),u=Math.max(...l.map(([,e])=>Math.max(...e.map(e=>e.variant.mesh_order))));for(let n=0;n<u+1;n++)for(let[r,u]of l){let l=!0;if(!r.shouldProxyForStyle(e))continue;const c=u.filter(e=>e.variant.mesh_order===n);if(0!==c.length){if(!0===o&&(o=!1,i=this.setupStyle(s,t),!i))return 0;c.forEach(e=>{!0===l&&(l=!1,this.view.setupTile(r,i)),s.render(e)&&this.requestRedraw(),a+=e.geometry_count})}}return a}setupStyle(e,t){let n;try{if(n=e.getProgram(t),!n)return}catch(t){return void this.trigger("warning",{type:"styles",message:`Error compiling style ${e.name}`,style:e,shader_errors:e.program&&e.program.shader_errors})}n.use(),e.setup(),n.uniform("1f","u_time",this.animated?(+new Date-this.start_time)/1e3:0),this.view.setupProgram(n);for(let e in this.lights)this.lights[e].setupProgram(n);return n}clearFrame(){this.initialized&&(this.render_states.depth_write.set({depth_write:!0}),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT|this.gl.STENCIL_BUFFER_BIT))}setRenderState({depth_test:e,depth_write:t,cull_face:n,blend:r}={}){if(!this.initialized)return;let i=this.render_states;e=!1!==e&&i.defaults.depth_test,t=!1!==t&&i.defaults.depth_write,n=!1!==n&&i.defaults.culling,r=null!=r?r:i.defaults.blending;let s=this.gl;i.depth_test.set({depth_test:e}),i.depth_write.set({depth_write:t}),i.culling.set({cull:n,face:i.defaults.culling_face}),r?"opaque"===r?i.blending.set({blend:!1}):"overlay"===r||"inlay"===r||"translucent"===r?i.blending.set({blend:!0,src:s.SRC_ALPHA,dst:s.ONE_MINUS_SRC_ALPHA,src_alpha:s.ONE,dst_alpha:s.ONE_MINUS_SRC_ALPHA}):"add"===r?i.blending.set({blend:!0,src:s.ONE,dst:s.ONE}):"multiply"===r&&i.blending.set({blend:!0,src:s.ZERO,dst:s.SRC_COLOR}):i.blending.set({blend:!1})}getFeatureAt(t,{radius:n}={}){if(!this.initialized)return e.log("debug","Scene.getFeatureAt() called before scene was initialized"),Promise.resolve();if(0===this.selection_feature_count)return Promise.resolve();this.selection||this.resetFeatureSelection();let r={x:t.x/this.view.size.css.width,y:t.y/this.view.size.css.height};return n=n>0?{x:n/this.view.size.css.width,y:n/this.view.size.css.height}:null,this.selection.getFeatureAt(r,{radius:n}).then(e=>Object.assign(e,{pixel:t})).catch(e=>Promise.resolve({error:e}))}async queryFeatures({filter:t,unique:n=!0,group_by:r=null,visible:i=null,geometry:s=!1}={}){if(!this.initialized)return[];t=e.Utils.serializeWithFunctions(t);const o=!0===(n="string"==typeof n?[n]:n)||Array.isArray(n)&&n.indexOf("$id")>-1,a=n&&(t=>{const r=Array.isArray(n)?e.sliceObject(t.properties,n):t.properties,i=o?t.id:null;return s?JSON.stringify({geometry:t.geometry,properties:r,id:i}):JSON.stringify({properties:r,id:i})}),l=(r=("string"==typeof r||Array.isArray(r))&&r)&&(t=>Array.isArray(r)?JSON.stringify(e.sliceObject(t,r)):t[r]),u=this.tile_manager.getRenderableTiles().map(e=>e.key),c=await e.WorkerBroker.postMessage(this.workers,"self.queryFeatures",{filter:t,visible:i,geometry:s,tile_keys:u}),h=[],d={},f={};return c.forEach(e=>e.forEach(e=>{if(a){const t=a(e);if(d[t])return;d[t]=!0}if(l){const t=l(e.properties);f[t]=f[t]||[],f[t].push(e)}else h.push(e)})),l?f:h}rebuild({initial:t=!1,new_generation:n=!0,sources:r=null,serialize_funcs:i,profile:s=!1,fade_in:o=!1}={}){return new Promise((a,l)=>{if(this.building){this.building.queued&&this.building.queued.reject&&(e.log("debug","Scene.rebuild: request superceded by a newer call"),this.building.queued.resolve(!1));let u={initial:t,new_generation:n,sources:r,serialize_funcs:i,profile:s,fade_in:o};return this.building.queued={resolve:a,reject:l,options:u},void e.log("trace","Scene.rebuild(): queuing request")}if(this.building={resolve:a,reject:l,initial:t},s&&this.debug.profile("Scene.rebuild"),n){this.generation=++kn.generation;for(let e in this.styles)this.styles[e].setGeneration(this.generation)}this.syncConfigToWorker({serialize_funcs:i}),this.resetWorkerFeatureSelection(r),this.resetTime(),this.tile_manager.pruneToVisibleTiles(),this.tile_manager.forEachTile(e=>{(!r||r.indexOf(e.source.name)>-1)&&this.tile_manager.buildTile(e,{fade_in:o})}),this.tile_manager.updateTilesForView(),this.tile_manager.checkBuildQueue()}).then(()=>{s&&this.debug.profileEnd("Scene.rebuild")})}tileManagerBuildDone(){if(e.TextCanvas.pruneTextCache(),this.building){e.log("info","Scene: build geometry finished"),this.building.resolve&&(this.logFirstBuild(),this.building.resolve(!0));var t=this.building.queued;this.building=null,t?(e.log("debug","Scene: starting queued rebuild() request"),this.rebuild(t.options).then(t.resolve,t.reject)):this.tile_manager.updateLabels()}}async loadScene(t=null,{base_path:n,file_type:r}={}){this.config_source=t||this.config_source,"string"==typeof this.config_source?this.base_path=e.pathForURL(n||this.config_source):this.base_path=e.pathForURL(n),this.config_path=this.base_path;const{config:i,bundle:s,texture_nodes:o}=await pn.loadScene(this.config_source,{path:this.base_path,type:r});return this.config=i,this.config_bundle=s,{texture_nodes:o}}setDataSource(t,n){if(!t||!n||!n.type||!n.url&&!n.data)return void e.log("error","No name provided or not a valid config:",t,n);let r=null==this.config.sources[t],i=this.config.sources[t]=Object.assign({},n);return i.data&&"object"==typeof i.data&&(i.url=e.createObjectURL(new Blob([JSON.stringify(i.data)],{type:"application/json"})),delete i.data),r?this.updateConfig({rebuild:{sources:[t]}}):this.rebuild({sources:[t]})}createDataSources(t=!1){const n=[],r=Object.keys(this.sources);let i=0;for(var s in this.config.sources){const r=this.config.sources[s],o=this.sources[s];try{const t=Tn(Tn({},r),{},{name:s,id:i++});if(this.sources[s]=e.DataSource.create(t,this.sources),!this.sources[s])throw{}}catch(t){delete this.sources[s];const n=`Could not create data source: ${t.message}`;e.log("warn",`Scene: ${n}`,r),this.trigger("warning",{type:"sources",source:r,message:n})}(t||e.DataSource.tileLayoutChanged(this.sources[s],o))&&n.push(s)}r.forEach(e=>{this.config.sources[e]||(delete this.sources[e],n.push(e))}),n.length>0&&this.tile_manager.removeTiles(e=>n.indexOf(e.source.name)>-1);for(let e in this.config.layers){let t=this.config.layers[e];!1!==t.enabled&&t.data&&this.sources[t.data.source]&&(this.sources[t.data.source].builds_geometry_tiles=!0)}}loadTextures(){return e.Texture.createFromObject(this.gl,this.config.textures).then(()=>e.Texture.createDefault(this.gl))}freePreviousTextures(){this.prev_textures&&(this.prev_textures.forEach(t=>{!this.config.textures[t]&&e.Texture.textures[t]&&e.Texture.textures[t].destroy()}),this.prev_textures=null)}updateStyles(){if(!this.initialized&&!this.initializing)throw new Error("Scene.updateStyles() called before scene was initialized");this.styles=this.style_manager.build(this.config.styles),this.style_manager.initStyles(this);for(let e in this.styles)this.styles[e].setGL(this.gl);this.dirty=!0}get animated(){return!1!==this.config.scene.animated&&this.style_manager.getActiveStyles().some(e=>this.styles[e].animated)}getActiveCamera(){return this.view.getActiveCamera()}setActiveCamera(e){return this.view.setActiveCamera(e)}createLights(){this.lights={},e.debugSettings.wireframe&&(e.Light.enabled=!1);for(let t in this.config.lights){if(!this.config.lights[t]||"object"!=typeof this.config.lights[t])continue;let n=this.config.lights[t];n.name=t.replace("-","_"),n.visible=!1!==n.visible,n.visible&&(this.lights[n.name]=e.Light.create(this.view,n))}e.Light.inject(this.lights)}setBackground(){const t=this.config.scene.background;this.background={},t&&t.color&&(this.background.color=e.StyleParser.createColorPropertyCache(t.color)),this.background.color||(this.background.color=e.StyleParser.createColorPropertyCache([0,0,0,0]))}updateBackground(){const t=this.background.computed_color,n=this.background.computed_color=e.StyleParser.evalCachedColorProperty(this.background.color,{zoom:this.view.tile_zoom});t&&!n.some((e,n)=>t[n]!==e)||(1===n[3]?this.canvas.style.backgroundColor=`rgba(${n.map(e=>Math.floor(255*e)).join(", ")})`:this.canvas.style.backgroundColor="transparent",this.gl.clearColor(...n))}setIntrospection(e){return e!==this.introspection?(this.introspection=null!=e&&e,this.updating++,this.updateConfig({normalize:!1}).then(()=>this.updating--)):Promise.resolve()}updateConfig({loading:t=!1,rebuild:n=!0,serialize_funcs:r,texture_nodes:i={},normalize:s=!0,fade_in:o=!1}={}){this.generation=++kn.generation,this.updating++,this.config=pn.applyGlobalProperties(this.config),s&&pn.normalize(this.config,this.config_bundle,i),pn.hoistTextureNodes(this.config,this.config_bundle,i),this.trigger(t?"load":"update",{config:this.config}),this.style_manager.init(),this.view.reset(),this.createLights(),this.createDataSources(t),this.loadTextures(),this.setBackground(),e.FontManager.loadFonts(this.config.fonts),this.updateStyles();let a=n?this.rebuild(Object.assign({initial:t,new_generation:!1,serialize_funcs:r,fade_in:o},"object"==typeof n&&n)):this.syncConfigToWorker({serialize_funcs:r});return this.updating--,this.view.updateBounds(),this.requestRedraw(),a.then(()=>{this.last_render_count=0,this.requestRedraw()})}syncConfigToWorker({serialize_funcs:t=!0}={}){let n=t?e.Utils.serializeWithFunctions(this.config):JSON.stringify(this.config);return e.WorkerBroker.postMessage(this.workers,"self.updateConfig",{config:n,generation:this.generation,introspection:this.introspection},e.debugSettings)}createListeners(){this.listeners={},this.listeners.view={move:()=>this.trigger("move")},this.view.subscribe(this.listeners.view),this.listeners.texture={update:()=>this.dirty=!0,warning:e=>this.trigger("warning",Object.assign({type:"textures"},e))},e.Texture.subscribe(this.listeners.texture),this.listeners.scene_loader={error:e=>this.trigger("error",Object.assign({type:"scene"},e))},pn.subscribe(this.listeners.scene_loader)}destroyListeners(){this.unsubscribeAll(),this.view.unsubscribe(this.listeners.view),e.Texture.unsubscribe(this.listeners.texture),pn.unsubscribe(this.listeners.scene_loader),this.listeners=null}destroyFeatureSelection(){this.selection&&(this.selection.destroy(),this.selection=null)}resetFeatureSelection(){this.selection=new e.FeatureSelection(this.gl,this.workers,()=>this.building),this.last_render_count=0}resetWorkerFeatureSelection(t=null){this.workers&&e.WorkerBroker.postMessage(this.workers,"self.resetFeatureSelection",t)}getFeatureSelectionMapSize(){return null==this.fetching_selection_map&&(this.fetching_selection_map=e.WorkerBroker.postMessage(this.workers,"self.getFeatureSelectionMapSize").then(e=>(this.fetching_selection_map=null,e.reduce((e,t)=>e+t)))),this.fetching_selection_map}resetTime(){this.start_time=+new Date}updateViewComplete(){!this.render_count_changed&&this.generation===this.last_complete_generation||this.building||this.tile_manager.isLoadingVisibleTiles()||!this.tile_manager.allVisibleTilesLabeled()||(this.tile_manager.updateLabels(),this.last_complete_generation=this.generation,this.trigger("view_complete",{first:!0!==this.view_complete}),this.view_complete=!0)}resetViewComplete(){this.last_complete_generation=null}screenshot({background:e="white"}={}){return this.requestRedraw(),this.media_capture.screenshot({background:e})}startVideoCapture(){return this.requestRedraw(),this.media_capture.startVideoCapture()}stopVideoCapture(){return this.media_capture.stopVideoCapture()}logFirstFrame(){0!==this.last_render_count||this.times.first_frame||(this.times.first_frame=+new Date-this.start_time,e.log("debug",`Scene: initial frame time: ${this.times.first_frame}`))}logFirstBuild(){null==this.times.first_build&&(this.times.first_build=+new Date-this.start_time,e.log("debug",`Scene: initial build time: ${this.times.first_build}`))}}var On;kn.id=0,kn.generation=0;const Rn={map:{},scrollWheelZoom:{},doubleClickZoom:{}};var Cn={leafletLayer:function(t){return function(t){if(void 0!==On)return new On(t);if(e.Thread.is_main){let n,r=t.leaflet||window.L,i=r.GridLayer?r.GridLayer:r.TileLayer,s=i===r.GridLayer?"1.x":"0.7.x",o={};return i===r.TileLayer&&(o._addTile=function(){},o._removeTile=function(){},o._reset=function(){i.prototype._reset.apply(this,arguments),this.scene&&this.scene.container&&this.scene.canvas&&this.scene.container.appendChild(this.scene.canvas)}),Object.assign(o,{initialize(e){e.showDebug=!!e.showDebug,r.setOptions(this,e),this.updateTangramDebugSettings(),this.createScene(),this.hooks={},this._updating_tangram=!1},createScene(){this.scene=kn.create(this.options.scene,{numWorkers:this.options.numWorkers,preUpdate:this.options.preUpdate,postUpdate:this.options.postUpdate,continuousZoom:"1.x"===On.leafletVersion,wrapView:!0!==this.options.noWrap,highDensityDisplay:this.options.highDensityDisplay,logLevel:this.options.logLevel,introspection:this.options.introspection,webGLContextOptions:this.options.webGLContextOptions,disableRenderLoop:this.options.disableRenderLoop})},onAdd(t){this.scene||this.createScene(),i.prototype.onAdd.apply(this,arguments),this.hooks.resize=()=>{this._updating_tangram=!0,this.updateSize(),this._updating_tangram=!1},t.on("resize",this.hooks.resize),this.hooks.move=()=>{if(!this._updating_tangram){this._updating_tangram=!0,this.scene.view.setPanning(!0);var n=t.getCenter();n.zoom=Math.max(Math.min(t.getZoom(),t.getMaxZoom()||e.Geo.default_view_max_zoom),t.getMinZoom()),this.scene.view.setView(n),this._mapLayerCount>1&&this.scene.immediateRedraw(),this._updating_tangram=!1}},t.on("move",this.hooks.move),this.hooks.moveend=()=>{this.scene.view.setPanning(!1),this.scene.requestRedraw()},t.on("moveend",this.hooks.moveend),this.hooks.drag=()=>{this.scene.view.markUserInput()},t.on("drag",this.hooks.drag),this._map_pane_observer=new MutationObserver(e=>{e.forEach(()=>this.reverseTransform())}),this._map_pane_observer.observe(t.getPanes().mapPane,{attributes:!0}),this.modifyScrollWheelBehavior(t),this.modifyZoomBehavior(t),this.trackMapLayerCounts(t),this.setupSelectionEventHandlers(t),this.setSelectionEvents(this.options.events,{radius:this.options.selectionRadius}),this.scene.container=this.getContainer(),this.updateSize(),this.updateView(),this.resizeOnFirstVisible(),this.scene.subscribe({move:this.onTangramViewUpdate.bind(this)}),this.scene.load(this.options.scene,{base_path:this.options.sceneBasePath,file_type:this.options.sceneFileType,blocking:!1}).then(()=>{if(!this.options.attribution)for(const[,e]of Object.entries(this.scene.config.sources))e.attribution&&t.attributionControl.addAttribution(e.attribution);this._updating_tangram=!0,this.updateSize(),this.updateView(),this.reverseTransform(),this._updating_tangram=!1,this.fire("init")}).catch(e=>{this.fire("error",e)})},onRemove(e){i.prototype.onRemove.apply(this,arguments),e.off("layeradd layerremove overlayadd overlayremove",this._updateMapLayerCount),e.off("resize",this.hooks.resize),e.off("move",this.hooks.move),e.off("moveend",this.hooks.moveend),e.off("drag",this.hooks.drag),e.off("click",this.hooks.click),e.off("mousemove",this.hooks.mousemove),e.off("mouseout",this.hooks.mouseout),document.removeEventListener("visibilitychange",this.hooks.visibilitychange),this.hooks={},this._map_pane_observer.disconnect(),this.scene&&(this.scene.destroy(),this.scene=null)},createTile(e){var t=e.x+"/"+e.y+"/"+e.z,n=document.createElement("div");if(n.setAttribute("data-tile-key",t),n.style.width="256px",n.style.height="256px",this.options.showDebug){var r=document.createElement("div");r.textContent=t,r.style.position="absolute",r.style.left=0,r.style.top=0,r.style.color="white",r.style.fontSize="16px",r.style.textOutline="1px #000000",r.style.padding="8px",n.appendChild(r),n.style.borderStyle="solid",n.style.borderColor="white",n.style.borderWidth="1px"}return n},modifyScrollWheelBehavior(e){if(this.scene.view.continuous_zoom&&e.scrollWheelZoom&&!1!==this.options.modifyScrollWheel){e.options.zoomSnap=0;const a=e.scrollWheelZoom.enabled();e.scrollWheelZoom.disable(),r.Browser.chrome||r.Browser.safari?e.scrollWheelZoom._onWheelScroll=function(e){var t=r.DomEvent.getWheelDelta(e);this._delta+=t,this._lastMousePos=this._map.mouseEventToContainerPoint(e),this._performZoom(),r.DomEvent.stop(e)}:e.options.wheelDebounceTime=20;const l=(i=function(e){e._moveEnd(!0),e.fire("viewreset")},s=2*e.options.wheelDebounceTime,function(){var e=this,t=arguments;clearTimeout(o),o=setTimeout(function(){o=null,i.apply(e,t)},s)});Rn.scrollWheelZoom._performZoom||(Rn.scrollWheelZoom._performZoom=e.scrollWheelZoom._performZoom);var t=this;e.scrollWheelZoom._performZoom=function(){if(this._map===t._map){var e=this._map,r=e.getZoom();e._stop();var i=this._delta/(4*this._map.options.wheelPxPerZoomLevel);this._delta=0,r+i>=this._map.getMaxZoom()?i=this._map.getMaxZoom()-r:r+i<=this._map.getMinZoom()&&(i=this._map.getMinZoom()-r),i&&("center"===e.options.scrollWheelZoom?n(t,e.getCenter(),r+i):n(t,this._lastMousePos,r+i),l(e))}else Rn.scrollWheelZoom._performZoom.call(this)},a&&e.scrollWheelZoom.enable()}var i,s,o},modifyZoomBehavior(e){if(this.scene.view.continuous_zoom&&!1!==this.options.modifyZoomBehavior){var t=this;const i=function(t,i,s){e._stop();var o=e._zoom;i=r.latLng(i),s=void 0===s?o:s,s=Math.min(s,e.getMaxZoom());var a=Date.now();return e._moveStart(!0),function l(){var u=(Date.now()-a)/75;u<=1?(e._flyToFrame=r.Util.requestAnimFrame(l,e),n(t,i,o+(s-o)*u)):n(t,i,s)._moveEnd(!0)}.call(e),e};if(e.doubleClickZoom){const n=e.doubleClickZoom.enabled();e.doubleClickZoom.disable(),Rn.doubleClickZoom._onDoubleClick||(Rn.doubleClickZoom._onDoubleClick=e.doubleClickZoom._onDoubleClick),e.doubleClickZoom._onDoubleClick=function(e){if(this._map===t._map){var n=this._map,r=n.getZoom(),s=n.options.zoomDelta,o=e.originalEvent.shiftKey?r-s:r+s;"center"===n.options.doubleClickZoom?i(t,n.getCenter(),o):i(t,n.containerPointToLatLng(e.containerPoint),o)}else Rn.doubleClickZoom._onDoubleClick.call(this,e)},n&&e.doubleClickZoom.enable()}e._zoomAnimated&&(Rn.map._animateZoom||(Rn.map._animateZoom=e._animateZoom),e._animateZoom=function(e,n,s,o){this===t._map?(s&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=n,i(t,e,n)),setTimeout(r.Util.bind(this._onZoomTransitionEnd,this),250)):Rn.map._animateZoom.call(this,e,n,s,o)})}},updateView(){var t=this._map.getCenter();t.zoom=Math.max(Math.min(this._map.getZoom(),this._map.getMaxZoom()||e.Geo.default_view_max_zoom),this._map.getMinZoom()),this.scene.view.setView(t)},updateSize(){var e=this._map.getSize();this.scene.resizeMap(e.x,e.y)},resizeOnFirstVisible(){let e=!0;this.hooks.visibilitychange=()=>{e&&(e=!1,this.updateSize())},document.addEventListener("visibilitychange",this.hooks.visibilitychange)},onTangramViewUpdate(){if(!this._map||this._updating_tangram)return;let e=this._map.getCenter(),t=this.scene.view.center;e.lng===t.lng&&e.lat===t.lat&&this._map.getZoom()===this.scene.view.zoom||(this._updating_tangram=!0,this._map.setView([this.scene.view.center.lat,this.scene.view.center.lng],this.scene.view.zoom,{animate:!1}),this._updating_tangram=!1)},render(){this.scene&&this.scene.update()},reverseTransform(){if(this._map&&this.scene&&this.scene.container){var e=this._map.containerPointToLayerPoint([0,0]);r.DomUtil.setPosition(this.scene.container,e)}},setupSelectionEventHandlers(e){this._selection_events={},this._selection_radius=null,this.hooks.click=e=>{"function"==typeof this._selection_events.click&&this.scene.getFeatureAt(e.containerPoint,{radius:this._selection_radius}).then(t=>{let n=Object.assign({},t,{leaflet_event:e});this._selection_events.click(n)})},e.on("click",this.hooks.click),this.hooks.mousemove=e=>{"function"==typeof this._selection_events.hover&&this.scene.getFeatureAt(e.containerPoint,{radius:this._selection_radius}).then(t=>{let n=Object.assign({},t,{leaflet_event:e});this._selection_events.hover(n)})},e.on("mousemove",this.hooks.mousemove),this.hooks.mouseout=e=>{"function"==typeof this._selection_events.hover&&this._selection_events.hover({changed:!0,leaflet_event:e})},e.on("mouseout",this.hooks.mouseout)},setSelectionEvents(e,{radius:t}={}){this._selection_events=Object.assign(this._selection_events,e),this._selection_radius=void 0!==t?t:this._selection_radius},trackMapLayerCounts(e){this._updateMapLayerCount=()=>{let t=e.getPanes().mapPane.childNodes;this._mapLayerCount=0;for(let e=0;e<t.length;e++)this._mapLayerCount+=t[e].childNodes.length},e.on("layeradd layerremove overlayadd overlayremove",this._updateMapLayerCount),this._updateMapLayerCount()},updateTangramDebugSettings(){e.mergeDebugSettings(this.options.debug||{})}}),n=function(e,t,n){var i=e._map,s=e.scene,o=i.getZoomScale(n),a=i.getSize().divideBy(2),l=(t instanceof r.Point?t:i.latLngToContainerPoint(t)).subtract(a).multiplyBy(1-1/o),u=i.containerPointToLatLng(a.add(l));return s&&s.view.markUserInput(),i._move(u,n,{flyTo:!0})},"function"!=typeof(On=i.extend(o)).remove&&(On.prototype.remove=function(){this._map&&this._map.removeLayer(this),this.fire("remove")}),On.layerBaseClass=i,On.leafletVersion=s,new On(t)}}(t)},debug:{log:e.log,yaml:cn,Utils:e.Utils,Geo:e.Geo,Vector:e.Vector,DataSource:e.DataSource,GLSL:e.GLSL,ShaderProgram:e.ShaderProgram,VertexData:e.VertexData,Texture:e.Texture,Material:e.Material,Light:e.Light,Scene:kn,WorkerBroker:e.WorkerBroker,Task:e.Task,StyleManager:e.StyleManager,StyleParser:e.StyleParser,TileID:e.TileID,Collision:e.Collision,FeatureSelection:e.FeatureSelection,TextCanvas:e.TextCanvas,debugSettings:e.debugSettings},version:e.version};return Cn});try{ix.debug.ESM=!0,ix.debug.SHA="d0b887d09a3645aad91a18bd3bd0362d74627da3","object"==typeof window&&(window.Tangram=ix)}catch(wy){}var ox=Object.freeze({__proto__:null});export{yf as API_METHODS,Ll as Accordion,jo as ApiService,tx as AuthPage,No as AuthStore,jl as Button,Ty as CSVUploader,Ig as CameraCreateForm,Fg as CameraUpdateForm,Hl as Card,Pc as Checkbox,_l as DartcomAuthProvider,Lo as DartcomMobxProvider,Zb as DartcomProviders,zc as DateField,Ul as DeleteButton,lf as DragList,ff as ErrorBoundary,Gb as ExcelUploader,Ic as Form,Nc as FormErrorMessage,Uo as GlobalConfig,Gl as IconButton,pf as Input,hg as LayerButtonsContainer,cg as LayerDatesContainer,gy as LeafletLayer,jc as List,my as Loader,zl as LocalizationProvider,vy as Modal,Po as ModalStore,Lc as NoData,vf as PanelsNames,Rc as Paragraph,Hb as QueryProvider,Do as RootStore,wg as Select,gf as SourceLayers,zo as StoreContext,km as Tabs,mf as TangramSourceNames,Tm as TrafficSignAddDopButton,B_ as TrafficSignCreateForm,Rm as TrafficSignDopCreateForm,Pm as TrafficSignDopUpdateForm,C_ as TrafficSignPreviewImage,Mm as TrafficSignPreviewTitle,N_ as TrafficSignTable,$_ as TrafficSignUpdateForm,Q_ as TrafficSignalCreateForm,ey as TrafficSignalUpdateForm,Mf as TrafficStatus,ql as UploadButton,bf as _backendUrl,de as _testApiKeys,um as allTrafficSigns,Io as authStore,mg as cameraConfig,_g as cameraMainFields,em as catIds,rn as copyInformation,Vo as createApiService,yg as defaultCamera,mm as defaultTrafficSign,_m as defaultTrafficSignDop,pm as defaultTrafficSignDopIds,fm as defaultTrafficSignIds,W_ as defaultTrafficSignal,en as encodeString,gg as getAdminAreaLayers,ly as getAllLayers,ay as getAllPointLayers,sy as getAllPolygonLayers,oy as getAllPolylineLayers,uy as getBackendDate,xg as getBackendFixingType,fg as getBuildingLayers,pg as getBuiltupAreaLayers,vg as getCameraLayers,zg as getCityPOILayers,jg as getConditionLayers,on as getCoordinateByLatLng,tm as getDefaultPOI,Vg as getFacilityAreaLayers,bg as getFrontendFixingType,Ug as getLanduseAreaLayers,Tf as getLaneMarkingLineLayers,Sf as getLaneMarkingPolyLayers,hy as getLayerBackendDates,cy as getLayerFrontendDates,ry as getLayerName,Hg as getLinkLayers,Wg as getNatureFieldLayers,Zg as getNatureForestLayers,Kg as getOceanAreaLayers,Xg as getOneWayLayers,im as getPOILayers,nm as getPOITypeLayer,kf as getParkingLineLayers,Qg as getPillarLayers,sm as getPointAddressLayers,om as getRailroadLayers,Ef as getRoadPolyLayers,wm as getTrafficSignImgSrc,xm as getTrafficSignLayers,Sm as getTrafficSignTitleByNumber,Am as getTrafficSignTitlesOptions,Z_ as getTrafficSignalLayers,sn as getUniqueKey,tn as getUrlencodedBody,iy as getValidLayer,ty as getWaterAreaLayers,ny as getWaterLinkLayers,wf as imagesPath,ug as layerCoordinateSchema,Df as layerDateFormat,Rf as layerDatesFields,lg as layerDatesFieldsSchema,Pf as layerDefaultBackendDates,Cf as layerDefaultFrontendDates,Of as layerServiceIds,_f as loggerService,Mo as modalStore,_y as modalStyle,Em as parseTrafficSignCSVFile,Yg as pillarConfig,qb as queryClient,Fo as rootStore,nn as showSnackbar,Af as sourceUrl,Jg as text_source,xf as tile_size,ym as trafficSignConfig,gm as trafficSignDopMainFields,bm as trafficSignDopWords,dm as trafficSignMainFields,vm as trafficSignWords,q_ as trafficSignalConfig,H_ as trafficSignalMainFields,am as trafficSigns,lm as trafficSignsDop,Nf as trafficStatusOptions,If as trafficTitles,Dc as useFormContext,dy as useGetLeafletLayer,Ka as useGetUser,Yb as useLogout,Xb as useShowErrorSnackbar,Kb as useShowSnackbar,Qb as useSignIn};
|
|
31
|
+
function R_(t,n){return t?function(e){return"function"==typeof e&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}(r=t)||"function"==typeof r||function(e){return"object"==typeof e&&"symbol"==typeof e.$$typeof&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}(r)?e.createElement(t,n):t:null;var r}var C_=gl(({number:t})=>{const n=e.useId(),r=e.useRef(null),i=wm({type:"preview",number:t}),{height:s}=um[t];return b("img",{src:i,id:n,width:ym.widths.preview,height:2*s,ref:r,alt:`traffic-sign-${t}`})});const P_={height:"",title:If.traffic_sign_title,type:If.traffic_sign_type,number:If.traffic_sign_number};var M_=gl(({options:e,label:t,column:n})=>{const r=n.getFilterValue(),i=e.find(({value:e})=>e===r);return b(q,{value:i??null,options:e,id:n.id,getOptionLabel:({label:e})=>e,getOptionKey:({value:e})=>e,size:"small",onChange:(e,t)=>{t?n.setFilterValue(t.value):n.setFilterValue(null)},renderInput:e=>b(Fc,{...e,label:t})})});var N_=gl(({pageSize:t=15,defaultValues:n,filtered:r={},onSelect:i,trafficSigns:s})=>{const[o,a]=e.useState({}),[l,u]=e.useState([]),[c,h]=e.useState({pageIndex:0,pageSize:t}),d={accessor:(e,t)=>"function"==typeof e?{...t,accessorFn:e}:{...t,accessorKey:e},display:e=>e,group:e=>e},f=e.useMemo(()=>{const e=[{id:"image",header:()=>b(jl,{onClick:()=>{u([])},children:"Очистить все"}),cell:({row:{original:e}})=>b(C_,{number:e.number})},d.accessor("title",{cell:e=>b(Rc,{variant:"body2",sx:{textAlign:"center",cursor:"inherit"},children:e.getValue()}),footer:e=>e.column.id,header:()=>b(Rc,{variant:"body1",fontWeight:700,children:"Название знака"}),meta:{isFiltered:r?.title??!0}}),d.accessor("number",{cell:e=>{const t=e.getValue();return b(Rc,{variant:"body2",sx:{textAlign:"center",cursor:"inherit"},children:t})},footer:e=>e.column.id,header:()=>b(Rc,{variant:"body1",fontWeight:700,children:"Номер знака"}),filterFn:({original:e},t)=>{const n=l.find(e=>e.id===t);if(n){return n.value===e.number||null===n.value}return!0},meta:{isFiltered:r?.number??!0}}),d.accessor("type",{cell:e=>b(Rc,{variant:"body2",sx:{textAlign:"center",cursor:"inherit"},children:e.getValue()}),footer:e=>e.column.id,header:()=>b(Rc,{variant:"body1",fontWeight:700,children:"Тип знака"}),meta:{isFiltered:r?.type??!0}})];return e},[l,r]),p=e.useMemo(()=>{const e=Object.entries(s).map(([e,t])=>({...t,number:e}));return e},[s]),g=function(t){const n={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[r]=e.useState(()=>({current:k_(n)})),[i,s]=e.useState(()=>r.current.initialState);return r.current.setOptions(e=>({...e,...t,state:{...i,...t.state},onStateChange:e=>{s(e),null==t.onStateChange||t.onStateChange(e)}})),r.current}({data:p,columns:f,state:{columnFilters:l,rowSelection:o,pagination:c},enableRowSelection:!0,onColumnFiltersChange:u,onRowSelectionChange:a,onPaginationChange:h,getCoreRowModel:e=>Fm(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,s){void 0===i&&(i=0);const o=[];for(let l=0;l<t.length;l++){const u=Bm(e,e._getRowId(t[l],l,s),t[l],l,i,0,null==s?void 0:s.id);var a;n.flatRows.push(u),n.rowsById[u.id]=u,o.push(u),e.options.getSubRows&&(u.originalSubRows=e.options.getSubRows(t[l],l),null!=(a=u.originalSubRows)&&a.length&&(u.subRows=r(u.originalSubRows,i+1,u)))}return o};return n.rows=r(t),n},zm(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex())),getFilteredRowModel:e=>Fm(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{if(!t.rows.length||(null==n||!n.length)&&!r){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}const i=[],s=[];(null!=n?n:[]).forEach(t=>{var n;const r=e.getColumn(t.id);if(!r)return;const s=r.getFilterFn();s?i.push({id:t.id,filterFn:s,resolvedValue:null!=(n=null==s.resolveFilterValue?void 0:s.resolveFilterValue(t.value))?n:t.value}):"production"!==process.env.NODE_ENV&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${r.id}.`)});const o=(null!=n?n:[]).map(e=>e.id),a=e.getGlobalFilterFn(),l=e.getAllLeafColumns().filter(e=>e.getCanGlobalFilter());let u,c;r&&a&&l.length&&(o.push("__global__"),l.forEach(e=>{var t;s.push({id:e.id,filterFn:a,resolvedValue:null!=(t=null==a.resolveFilterValue?void 0:a.resolveFilterValue(r))?t:r})}));for(let e=0;e<t.flatRows.length;e++){const n=t.flatRows[e];if(n.columnFilters={},i.length)for(let e=0;e<i.length;e++){u=i[e];const t=u.id;n.columnFilters[t]=u.filterFn(n,t,u.resolvedValue,e=>{n.columnFiltersMeta[t]=e})}if(s.length){for(let e=0;e<s.length;e++){c=s[e];const t=c.id;if(c.filterFn(n,t,c.resolvedValue,e=>{n.columnFiltersMeta[t]=e})){n.columnFilters.__global__=!0;break}}!0!==n.columnFilters.__global__&&(n.columnFilters.__global__=!1)}}return O_(t.rows,e=>{for(let t=0;t<o.length;t++)if(!1===e.columnFilters[o[t]])return!1;return!0},e)},zm(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex())),getSortedRowModel:e=>Fm(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||null==t||!t.length)return n;const r=e.getState().sorting,i=[],s=r.filter(t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()}),o={};s.forEach(t=>{const n=e.getColumn(t.id);n&&(o[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});const a=e=>{const t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let r=0;r<s.length;r+=1){var n;const i=s[r],a=o[i.id],l=a.sortUndefined,u=null!=(n=null==i?void 0:i.desc)&&n;let c=0;if(l){const n=void 0===e.getValue(i.id),r=void 0===t.getValue(i.id);if(n||r){if("first"===l)return n?-1:1;if("last"===l)return n?1:-1;c=n&&r?0:n?l:-l}}if(0===c&&(c=a.sortingFn(e,t,i.id)),0!==c)return u&&(c*=-1),a.invertSorting&&(c*=-1),c}return e.index-t.index}),t.forEach(e=>{var t;i.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=a(e.subRows))}),t};return{rows:a(n.rows),flatRows:i,rowsById:n.rowsById}},zm(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex())),getPaginationRowModel:e=>Fm(()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded],(t,n)=>{if(!n.rows.length)return n;const{pageSize:r,pageIndex:i}=t;let{rows:s,flatRows:o,rowsById:a}=n;const l=r*i,u=l+r;let c;s=s.slice(l,u),c=e.options.paginateExpandedRows?{rows:s,flatRows:o,rowsById:a}:function(e){const t=[],n=e=>{var r;t.push(e),null!=(r=e.subRows)&&r.length&&e.getIsExpanded()&&e.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}({rows:s,flatRows:o,rowsById:a}),c.flatRows=[];const h=e=>{c.flatRows.push(e),e.subRows.length&&e.subRows.forEach(h)};return c.rows.forEach(h),c},zm(e.options,"debugTable","getPaginationRowModel"))}),m=e.useMemo(()=>{const e=new Set,t=[],n=new Set,r=[],i=new Set,s=[];return g.getCoreRowModel().rows.map(({original:{number:t,title:r,type:s}})=>{e.add(t),n.add(r),i.add(s)}),e.forEach(e=>{t.push({label:e,value:e})}),n.forEach(e=>{r.push({label:e,value:e})}),i.forEach(e=>{s.push({label:e,value:e})}),{number:t,title:r,type:s}},[g]);return e.useEffect(()=>{if(n){const e=[];Object.entries(n).forEach(([t,n])=>{e.push({id:t,value:n})}),u(e)}},[n]),x(T,{sx:{display:"grid",justifyItems:"center",gap:"10px"},children:[x(T,{component:"table",sx:{border:"1px solid black",borderCollapse:"collapse","td, th":{border:"1px solid black",padding:"10px"}},children:[b("thead",{children:g.getHeaderGroups().map(e=>b("tr",{style:{border:"1px solid black"},children:e.headers.map(e=>{const t=e.id,n=e.column.columnDef.meta;return b("th",{colSpan:e.colSpan,children:e.isPlaceholder?null:x(T,{sx:{display:"grid",gap:"12px",minWidth:200,padding:"8px 0"},children:[b(T,{sx:{display:"flex",justifyItems:"center",justifyContent:"center",gap:"12px"},children:R_(e.column.columnDef.header,e.getContext())}),n?.isFiltered?b(M_,{label:P_[t],column:e.column,options:m[t]??[]}):null]})},e.id)})},e.id))}),b("tbody",{children:g.getRowModel().rows.map(e=>b(T,{component:"tr",onClick:()=>{i(e.original),u([])},children:e.getVisibleCells().map(e=>b(T,{component:"td",sx:{cursor:"pointer",width:e.column.getSize()},children:b(T,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:R_(e.column.columnDef.cell,e.getContext())})},e.id))},e.id))})]}),x(T,{sx:{display:"flex",alignItems:"center",gap:"10px"},children:[x(T,{sx:{display:"flex",gap:"8px"},children:[b(jl,{variant:"outlined",size:"small",onClick:()=>g.setPageIndex(0),disabled:!g.getCanPreviousPage(),"aria-label":"move all right",children:"<<"}),b(jl,{variant:"outlined",size:"small",onClick:()=>g.previousPage(),disabled:!g.getCanPreviousPage(),"aria-label":"move all right",children:"<"}),b(jl,{variant:"outlined",size:"small",onClick:()=>g.nextPage(),disabled:!g.getCanNextPage(),"aria-label":"move all right",children:">"}),b(jl,{variant:"outlined",size:"small",onClick:()=>g.setPageIndex(g.getPageCount()-1),disabled:!g.getCanNextPage(),"aria-label":"move all right",children:">>"})]}),x(Rc,{fontWeight:700,children:[g.getState().pagination.pageIndex+1," из ",g.getPageCount()]})]})]})});const I_=rg(),D_={traffic_sign_id:rg(),dop_id:rg()},F_={dop_sign_number:rg(),dop_sign_title:rg(),status:I_,dop_sign_text:ng().nullable(),comment:ng().nullable()},z_=Yp().shape({...D_,...F_,...lg}),L_=Yp().shape({...F_,...lg}),j_={traffic_sign_type:rg(),traffic_sign_number:rg(),traffic_sign_title:rg(),status:I_,comment:ng().nullable(),traffic_sign_value:ng().nullable(),direction:ig.nullable()},V_={...cg,traffic_sign_id:rg(),pillar_id:ng().nullable()},U_=Yp().shape({...cg,...lg,...j_,newDops:og.max(ym.dopsCount).of(L_).required()});var B_=gl(({onSubmit:t})=>{const n=e.useId(),r=Oc({resolver:Ig(U_),defaultValues:{...mm}}),{control:i,register:s,setValue:o,watch:a,formState:{errors:l}}=r,u=kc({control:i,name:"newDops"}),c=a("traffic_sign_number");return e.useEffect(()=>{Object.keys(l).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignCreateForm",meta:l})},[l]),x(Ic,{form:r,onSubmit:t,children:[b(km,{items:[{label:vm.title,value:1,content:x(T,{sx:{display:"grid",gap:"12px"},children:[b(Ll,{items:[{value:1,summary:b(Mm,{number:c}),getDetails:({onClose:e})=>b(N_,{trafficSigns:am,pageSize:5,onSelect:({title:t,number:n,type:r})=>{o("traffic_sign_number",n),o("traffic_sign_title",t),o("traffic_sign_type",r),e()}})}]}),b(Ag,{...s("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...s("traffic_sign_value"),label:If.traffic_sign_value}),b(pf,{...s("comment"),label:If.comment}),b(pf,{...s("direction"),label:If.direction,type:"number"}),b(hg,{children:Rf.map(e=>b(zc,{...s(e),label:If[e],format:Df},`${n}-${e}`))})]})},{label:bm.title,value:2,content:x(T,{sx:{display:"grid",gap:"24px"},children:[b(Tm,{disabled:u.fields.length===ym.dopsCount,onClick:()=>{u.append({..._m})}}),u.fields.map(({id:e},t)=>b(Hl,{children:b(Rm,{onDelete:()=>{u.remove(t)},index:t})},e))]})}]}),b(jl,{type:"submit",children:"Сохранить"})]})});const G_=Yp().shape({...lg,...ug,...V_,...j_,oldDops:Jp().max(ym.dopsCount).of(z_).required(),newDops:Jp().max(ym.dopsCount).of(L_).required()});var $_=gl(({trafficSign:t,onSubmit:n,onDelete:r,onDeleteDop:i,onUpdateDop:s,getButtons:o})=>{const a=e.useId(),l=e.useMemo(()=>{const{dops:e,traffic_sign_id:n}=t;return{...t,...by(t),oldDops:e.map(e=>({...e,traffic_sign_id:n,...by(e)})),newDops:[]}},[t]),u=Oc({resolver:Ig(G_),defaultValues:l}),{reset:c,control:h,register:d,setValue:f,watch:p,formState:{errors:g}}=u,m=kc({control:h,name:"oldDops"}),_=kc({control:h,name:"newDops"}),y=e.useMemo(()=>m.fields.length+_.fields.length<ym.dopsCount,[m.fields.length,_.fields.length]),v=p("traffic_sign_number");return e.useEffect(()=>{Object.keys(g).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignUpdateForm",meta:g})},[g]),e.useEffect(()=>{c(l)},[t]),x(Ic,{form:u,onSubmit:n,children:[b(km,{items:[{label:vm.title,value:1,content:x(T,{sx:{display:"grid",gap:"12px"},children:[b(Ll,{items:[{value:1,summary:x(T,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[b(Ul,{notification:{title:"Удалить дорожный знак",description:"Вы действительно хотите удалить данный дорожный знак?"},onDelete:()=>{r(t)}}),b(Mm,{number:v})]}),getDetails:({onClose:e})=>b(N_,{trafficSigns:am,pageSize:5,onSelect:({title:t,number:n,type:r})=>{f("traffic_sign_number",n),f("traffic_sign_title",t),f("traffic_sign_type",r),e()}})}]}),b(Ag,{...d("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...d("traffic_sign_value"),label:If.traffic_sign_value}),b(pf,{...d("comment"),label:If.comment}),b(pf,{...d("direction"),label:If.direction,type:"number"}),b(hg,{children:Rf.map(e=>b(zc,{...d(e),label:If[e],format:Df},`${a}-${e}`))})]})},{label:bm.title,value:2,content:x(T,{sx:{display:"grid",gap:"24px"},children:[b(Tm,{disabled:!y,onClick:()=>{_.append({..._m})}}),m.fields.map(({id:e},t)=>b(Hl,{children:b(Pm,{index:t,onDelete:i,onUpdate:s})},e)),_.fields.map(({id:e},t)=>b(Hl,{children:b(Rm,{onDelete:()=>{_.remove(t)},index:t})},e))]})}]}),x(dg,{children:[b(jl,{type:"submit",children:"Сохранить"}),o?.(t)]})]})});const q_={size:20,extension:"svg",apiName:"traffic_signal"},H_={direction:0,status:Mf.ACTIVE},W_={...Of,...Cf,...H_},Z_=e=>{const t=[],n={source:e,layer:gf.TRAFFIC_SIGNAL},r={},i="traffic_signal",s=`${wf}/msk/${i}/${i}_${q_.size}.${q_.extension}`;r[i]={url:s,filtering:"mipmap",sprites:{base:[0,0,q_.size,q_.size]}};const o={id:sn(),data:n,draw:{points:{collide:!1,texture:i,size:q_.size,sprite:"base",placement:"midpoint"}},textures:r,sublayers:{}};return t.push(o),t},K_={status:rg(),signal_model:ng().nullable(),comment:ng().nullable(),direction:ig.nullable()},X_={...cg,traffic_signal_id:rg(),pillar_id:ng().nullable()},Y_=Yp().shape({...cg,...lg,...K_});var Q_=gl(({onSubmit:t})=>{const n=e.useId(),r=Oc({resolver:Ig(Y_),defaultValues:{...W_}}),{register:i,formState:{errors:s}}=r;return e.useEffect(()=>{Object.keys(s).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignCreateForm",meta:s})},[s]),x(Ic,{form:r,onSubmit:t,children:[b(Ag,{...i("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...i("signal_model"),label:If.signal_model}),b(pf,{...i("comment"),label:If.comment}),b(pf,{...i("direction"),label:If.direction,type:"number"}),b(hg,{children:Rf.map(e=>b(zc,{...i(e),label:If[e],format:Df},`${n}-${e}`))}),b(jl,{type:"submit",children:"Сохранить"})]})});const J_=Yp().shape({...X_,...lg,...ug,...K_});var ey=gl(({trafficSignal:t,onSubmit:n,onDelete:r,getButtons:i})=>{const s=e.useId(),o=e.useMemo(()=>({...t,...by(t)}),[t]),a=Oc({resolver:Ig(J_),defaultValues:o}),{reset:l,register:u,formState:{errors:c}}=a;return e.useEffect(()=>{Object.keys(c).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignUpdateForm",meta:c})},[c]),e.useEffect(()=>{l(o)},[o]),x(Ic,{form:a,onSubmit:n,children:[b(Ag,{...u("status"),label:If.status,items:Nf,getKey:({value:e})=>e,getLabel:({label:e})=>e,getValue:({value:e})=>e}),b(pf,{...u("signal_model"),label:If.signal_model}),b(pf,{...u("comment"),label:If.comment}),b(pf,{...u("direction"),label:If.direction,type:"number"}),b(hg,{children:Rf.map(e=>b(zc,{...u(e),label:If[e],format:Df},`${s}-${e}`))}),x(dg,{children:[b(jl,{type:"submit",fullWidth:!0,children:"Сохранить"}),x(dg,{children:[b(Ul,{notification:{title:"Удалить светофор",description:"Вы действительно хотите удалить данный светофор?"},onDelete:()=>{r(t)}}),i?.(t)]})]})]})});const ty=Yp().shape({...im,...lg,...ug,...rm});var ny=gl(({pillar:t,onSubmit:n,onDelete:r,getButtons:i})=>{const{signs:s,signals:o,cameras:a}=t,l=e.useId(),u=e.useMemo(()=>({...t,...by(t)}),[t]),c=Oc({resolver:Ig(ty),defaultValues:u}),{reset:h,register:d,formState:{errors:f}}=c;return e.useEffect(()=>{Object.keys(f).length>0&&_f.warn({message:"Ошибки валидации формы",context:"TrafficSignUpdateForm",meta:f})},[f]),e.useEffect(()=>{h(u)},[u]),b(Ic,{form:c,onSubmit:n,children:b(km,{items:[{label:"Столб",value:1,content:x(T,{sx:({spacing:e})=>({display:"grid",gap:e(2)}),children:[b(pf,{...d("description"),label:If.description}),b(pf,{...d("height"),label:If.height,type:"number"}),b(pf,{...d("comment"),label:If.comment}),b(hg,{children:Rf.map(e=>b(zc,{...d(e),label:If[e],format:Df},`${l}-${e}`))}),x(dg,{children:[b(jl,{type:"submit",fullWidth:!0,children:"Сохранить"}),x(dg,{children:[b(Ul,{notification:{title:"Удалить светофор",description:"Вы действительно хотите удалить данный светофор?"},onDelete:()=>{r(t)}}),i?.(t)]})]})]})},{label:If.signs,value:2,content:x(T,{sx:({spacing:e})=>({display:"grid",gap:e(2)}),children:[b(Rc,{variant:"h6",sx:{textAlign:"center",fontWeight:700},children:"Создание дорожного знака"}),b(B_,{onSubmit:()=>{}}),b(Rc,{variant:"h6",sx:{textAlign:"center",fontWeight:700},children:"Созданные дорожные знаки"}),s.map(e=>{const{traffic_sign_id:t}=e;return b(Hl,{children:b($_,{trafficSign:e,onSubmit:()=>{},onDelete:()=>{},onUpdateDop:()=>{},onDeleteDop:()=>{}})},t)})]})},{label:If.signals,value:3,content:x(T,{sx:({spacing:e})=>({display:"grid",gap:e(2)}),children:[b(Rc,{variant:"h6",sx:{textAlign:"center",fontWeight:700},children:"Создание светофора"}),b(Q_,{onSubmit:()=>{}}),b(Rc,{variant:"h6",sx:{textAlign:"center",fontWeight:700},children:"Созданные светофоры"}),o.map(e=>{const{traffic_signal_id:t}=e;return b(Hl,{children:b(ey,{trafficSignal:e,onSubmit:()=>{},onDelete:()=>{}})},t)})]})},{label:If.cameras,value:4,content:x(T,{sx:({spacing:e})=>({display:"grid",gap:e(2)}),children:[b(Rc,{variant:"h6",sx:{textAlign:"center",fontWeight:700},children:"Создание камеры"}),b(Dg,{onSubmit:()=>{}}),b(Rc,{variant:"h6",sx:{textAlign:"center",fontWeight:700},children:"Созданные камеры"}),a.map(e=>{const{camera_id:t}=e;return b(Hl,{children:b(zg,{camera:e,onSubmit:()=>{},onDelete:()=>{}})},t)})]})}]})})});const ry='function() {\n const { poi_name, cat_id } = feature;\n\n switch (+cat_id) {\n case 4100: {\n const text = poi_name.replaceAll(/(Метро-|Станция-|МЦД-)/g, "");\n\n return text;\n }\n\n default: {\n return poi_name;\n }\n }\n}',iy=[3578,4013,4100,5400,5511,5512,5540,5541,5800,5813,5999,6e3,7011,7389,7832,7929,7990,8060,8410,9517,9530,9565,9583,9718,9992],sy=e=>{const t={};switch(e){case 4100:t[`_${e}-metro`]={filter:`function() {\n const { poi_name, cat_id } = feature;\n\n const isMetro = poi_name.startsWith('Метро-');\n const isStation = poi_name.startsWith('Станция-');\n\n const isCatId = +cat_id === ${e};\n\n const isFilter = isCatId && (isMetro || isStation);\n\n return isFilter;\n }`,draw:{points:oy({texture:`POI_${e}(metro)`})}},t[`_${e}-diameter`]={filter:`function() {\n const { cat_id, poi_name } = feature;\n\n const isDiameter = poi_name.startsWith('МЦД-');\n\n const isCatId = +cat_id === ${e};\n\n const isFilter = isCatId && isDiameter;\n\n return isFilter;\n }`,draw:{points:oy({texture:`POI_${e}(diameter)`,size:[41,15]})}};break;case 9530:t[`_${e}-mail`]={filter:`function() {\n const { cat_id, poi_name = '' } = feature;\n\n const isCatId = +cat_id === ${e};\n\n const isMail = poi_name.startsWith('Почта');\n\n const isFilter = isCatId && isMail;\n\n return isFilter;\n }`,draw:{points:oy({texture:`POI_${e}(Mail)`})}},t[`_${e}-delivery`]={filter:`function() {\n const { cat_id, poi_name = '' } = feature;\n\n const isCatId = +cat_id === ${e};\n \n const isMail = poi_name.startsWith('Почта');\n\n const isFilter = isCatId && !isMail;\n\n return isFilter;\n }`,draw:{points:oy({texture:`POI_${e}(Delivery)`})}};break;case 9992:{const n={mosque:1,church:2,temple:3,davidStar:4,mortar:6};Object.entries(n).forEach(([n,r])=>{t[`_${e}-${n}`]={filter:`function() {\n const { cat_id, subcat_id } = feature;\n\n const isCatId = +cat_id === ${e};\n const isSubcatId = +subcat_id === ${r};\n\n const isFilter = isCatId && isSubcatId;\n\n return isFilter;\n }`,draw:{points:oy({texture:`POI_${e}(${n})`})}}});break}default:t[`_${e}`]={filter:`function() {\n const { cat_id } = feature;\n\n const isFilter = +cat_id === ${e};\n\n return isFilter;\n }`,draw:{points:oy({texture:`POI_${e}`})}}}return t},oy=({texture:e,size:t=20})=>({texture:e,size:t,sprite:"base",placement:"midpoint"}),ay=iy.reduce((e,t)=>({...e,...sy(t)}),{}),ly=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.POI},draw:{points:{text:{text_source:ry,font:{fill:"#464544",size:"12px"}}}},sublayers:ay};return t.push(n),t},uy=e=>{const t=[],n={source:e,layer:gf.POINT_ADDRESS,minzoom:15},r={id:sn(),data:n,draw:{text:{text_source:"address",font:{fill:"black",size:"12px"}}}};return t.push(r),t},cy=e=>{const t=[],n={source:e,layer:gf.RAILROAD_LINK},r={id:sn(),data:n,draw:{lines:{color:"#A3A8A",width:5,dash:[1,2],dash_background_color:[0,0,0],join:"round"}}};return t.push(r),t},hy=e=>{const t=[],n={id:sn(),data:{source:e,layer:gf.WATER_AREA},draw:{polygons:{color:"#7DBEE4"},lines:{color:"#7DBEE4",width:20,cap:"round",join:"round"}}},r={id:sn(),data:{source:e,layer:gf.WATER_AREA_LABEL},filter:"function() {\n const { display_class } = feature;\n\n if ($zoom >= 14) {\n return true;\n } else {\n return display_class <= 4;\n }\n }",draw:{text:{text_source:"name",font:{fill:"#0A80C4",size:"14px",stroke:{color:"white",width:"3px"}}}}},i={id:sn(),data:{source:e,layer:gf.WATER_LAKE_LABEL},filter:"function() {\n const { display_class } = feature;\n\n if ($zoom >= 14) {\n return true;\n } else {\n return display_class <= 4;\n }\n }",draw:{text:{text_source:"name",font:{fill:"#0A80C4",size:"14px",stroke:{color:"white",width:"3px"}}}}};return t.push(n,r,i),t},dy=e=>{const t=[],n={},r={source:e,layer:gf.WATER_LINK},i={id:sn(),data:r};return n.geometry={draw:{lines:{color:"#7DBEE4",width:5,cap:"round",join:"round"}}},n.text={filter:"function() {\n return $zoom >= 10;\n }",draw:{text:{text_source:"name",font:{fill:"#0A80C4",size:"14px",stroke:{color:"white",width:"3px"}}}}},i.sublayers=n,t.push(i),t},fy=({id:e,data:{source:t,layer:n}})=>`${e}-${t}-${n}`,py=({layer:e,order:t,eventHandlers:n})=>{const r=structuredClone(e),{draw:i,sublayers:s}=r,o=Boolean(n?.[e.data.layer]);if(i){const{points:e,lines:n,polygons:s,text:a,styles:l}=i;e&&(i.points={...structuredClone(e),order:t,interactive:o}),n&&(i.lines={...structuredClone(n),order:t,interactive:o}),s&&(i.polygons={...structuredClone(s),order:t,interactive:o}),a&&(i.text={...structuredClone(a),order:t,interactive:o}),l&&(i.styles=Object.entries(l).reduce((e,[n,r])=>({...e,[n]:{...structuredClone(r),order:t}}),{})),r.draw=structuredClone(i)}return s&&(Object.entries(s).forEach(([e,n])=>{if(n){const{draw:r}=n;if(r){const{points:e,lines:i,polygons:s,text:a}=r;a&&(r.text={...structuredClone(a),order:t,interactive:o}),e&&(r.points={...structuredClone(e),order:t,interactive:o}),i&&(r.lines={...structuredClone(i),order:t,interactive:o}),s&&(r.polygons={...structuredClone(s),order:t,interactive:o}),n.draw=structuredClone(r)}s[e]=structuredClone(n)}}),r.sublayers=structuredClone(s)),r},gy=e=>{const t=mg(e),n=Zg(),r=Kg(),i=gg(e),s=Ug(e),o=Bg(e),a=hy(e),l=Xg(e),u=[];if(e===mf.MSK)u.push(...t,...i,...s,...o,...a,...l);else u.push(...t,...i,...s,...n,...r,...o,...a,...l);return u},my=e=>{const t=Wg(e),n=cy(e),r=dy(e),i=Yg(e),s=Vg(e),o=[...r,...n,...t];if(e===mf.MSK);else o.push(...i,...s);return o},_y=e=>{const t=ly(e),n=Lg(e);return[...t,...uy(e),...n,...xm(e),...Z_(e),...bg(e),...nm(e)]},yy=e=>{const t=[],n=pg(e),r=gy(e),i=my(e),s=_y(e),o=Ef(e),a=Sf(e),l=Tf(e),u=kf(e);if(e===mf.MSK)t.push(...r,...i,...o,...a,...l,...u,...n,...s);else t.push(...r,...i,...n,...s);return t},vy=e=>`${e.getFullYear()}-${`${e.getUTCMonth()+1}`.padStart(2,"0")}-${`${e.getUTCDate()}`.padStart(2,"0")}`,by=e=>{const t=structuredClone(Cf);return Rf.forEach(n=>{const r=new Date(e[n]);t[n]=r}),t},xy=e=>{const t=structuredClone(Pf);return Rf.forEach(n=>{const r=vy(e[n]);t[n]=r}),t},wy=({eventHandlers:t})=>{const[n,r]=e.useState(null),[i,s]=e.useState(null),o=e.useMemo(()=>{if(null===n)return null;const{scene:e}=n;return e},[n]),a=e.useCallback(()=>{Promise.resolve().then(function(){return mx}).then(()=>{if(window.Tangram){const e=window.Tangram.leafletLayer({scene:fg}),{scene:n}=e;n.subscribe({load:({config:e})=>{s(e)}}),e.on("load",()=>{e.setSelectionEvents({click:({feature:e,leaflet_event:n})=>{if(e){const{source_layer:r,properties:i}=e;t?.[r]?.click?.({leaflet_event:n,properties:i})}},hover:({feature:e,leaflet_event:n})=>{if(e){const{source_layer:r,properties:i}=e;t?.[r]?.hover?.({leaflet_event:n,properties:i})}}})}),r(e)}})},[t]),l=e.useCallback(e=>{i?e(i):_f.warn({message:"Config не инициализирована"})},[i]),u=e.useCallback(e=>{l(t=>{o?e({config:t,scene:o}):_f.warn({message:"Scene не инициализирована"})})},[l,o]),c=e.useCallback(e=>{u(({config:t,scene:n})=>{const r=Af[e];t.sources[e]={tile_size:256,url:r,type:"MVT"},n.updateConfig({rebuild:!0})})},[u]),h=e.useCallback(e=>{u(({config:t,scene:n})=>{delete t.sources[e],n.updateConfig({rebuild:!0})})},[u]),d=e.useCallback(e=>{let t=null;return l(n=>{t=structuredClone(n.sources[e])}),t},[l]),f=e.useCallback((e,t)=>{u(({config:n,scene:r})=>{n.sources[e].url=t,r.updateConfig({rebuild:!0})})},[u]),p=e.useCallback(e=>{h(e),c(e)},[h,c]),g=e.useCallback(e=>{u(({config:n,scene:r})=>{const i=b().length+1,s=py({layer:e,order:i,eventHandlers:t}),o=fy(s),{sublayers:a,draw:l,textures:u}=s;if(l){const{styles:e}=l;e&&(s.draw={...structuredClone(s.draw),...structuredClone(e)})}n.layers[o]={...structuredClone(s),...structuredClone(a)},n.textures={...structuredClone(n.textures),...structuredClone(u)},r.updateConfig({rebuild:!0})})},[u]),m=e.useCallback(e=>{const t=fy(e);u(({config:e,scene:n})=>{delete e.layers[t],n.updateConfig({rebuild:!0})})},[u]),_=e.useCallback(({name:e,style:t})=>{u(({config:n,scene:r})=>{n.styles[e]=structuredClone(t),r.updateConfig({rebuild:!0})})},[u]),y=e.useCallback(e=>{let t=!0;const n=fy(e);return l(e=>{const{visible:r=!0}=e.layers[n];t=r}),t},[fy,l]),v=e.useCallback(({layer:e,visible:t})=>{const n=fy(e);u(({config:e,scene:r})=>{e.layers[n].visible=t,r.updateConfig({rebuild:!0})})},[u]),b=e.useCallback(()=>{const e=[];return l(t=>{e.push(...Object.keys(t.layers))}),e},[l]),x=e.useCallback(()=>{l(e=>{const{layers:t}=e;Object.values(t).forEach(m)})},[l,m]),w=e.useCallback(()=>{const e=[];return l(t=>{e.push(...Object.keys(t.sources))}),e},[i]);return e.useEffect(()=>(Uo.instance.isValidApiKey&&a(),()=>{r(null),s(null)}),[Uo.instance.isValidApiKey]),e.useEffect(()=>{_({name:"zebra_crossing",style:{base:"polygons",lighting:!1,shaders:{attributes:{a_angle:{type:"float",default:0}},uniforms:{u_stripe_width:1},blocks:{filter:"\n vec3 pos = worldPosition().xyz;\n\n float ang = radians(a_angle);\n\n vec2 dir = vec2(sin(ang), cos(ang));\n\n float positionAlongLine = dot(pos.xy, dir);\n\n float stripe = step(1.0, mod(positionAlongLine / u_stripe_width, 2.0));\n\n color.rgb = mix(vec3(1.0, 1.0, 1.0), vec3(1.0, 0.8, 0.0), stripe);\n \n color.a = 1.0;\n "}}}}),Object.values(mf).forEach(c)},[_,c]),{layer:n,scene:o,config:i,addSource:c,getSource:d,updateSource:f,reloadSource:p,addLayer:g,removeLayer:m,addStyle:_,getLayerVisibility:y,toggleLayerVisibility:v,getSources:w,getLayers:b,removeLayers:x}},Ay=g(null);function Ey(){return function(){const e=_(Ay);if(null==e)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return e}().map}const Sy=({source:t})=>{const{layer:n,addLayer:r}=wy({}),i=Ey();return e.useEffect(()=>{n&&i.addLayer(n)},[n]),e.useEffect(()=>{yy(t).map(r)},[r,t]),null},Ty=({color:e="inherit"})=>b(W,{color:e}),ky={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",bgcolor:"background.paper",border:"2px solid #000",boxShadow:24,p:4,maxHeight:"90vh",overflowX:"auto",overflowY:"auto"};var Oy,Ry=gl(({name:t,children:n,onClose:r,onOpen:i})=>{const s=e.useId(),o=Mo.getIsVisible(t);return e.useEffect(()=>{o?i?.({name:t}):r?.({name:t})},[o]),b(he,{open:o,onClose:()=>{Mo.closeModal(t)},"aria-labelledby":`modal-${s}-title`,"aria-describedby":`modal-${s}-description`,children:b(ce,{sx:({breakpoints:e})=>({...ky,[e.up("sm")]:{minWidth:400},[e.down("sm")]:{minWidth:"80vw"}}),children:n})})}),Cy={exports:{}};var Py=(Oy||(Oy=1,Cy.exports=function e(){var t,n="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n?n:{},r=!n.document&&!!n.postMessage,i=n.IS_PAPA_WORKER||!1,s={},o=0,a={};function l(e){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(e){var t=v(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null),this._handle=new f(t),(this._handle.streamer=this)._config=t}.call(this,e),this.parseChunk=function(e,t){var r=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<r){let t=this._config.newline;t||(s=this._config.quoteChar||'"',t=this._handle.guessLineEndings(e,s)),e=[...e.split(t).slice(r)].join(t)}this.isFirstChunk&&x(this._config.beforeFirstChunk)&&void 0!==(s=this._config.beforeFirstChunk(e))&&(e=s),this.isFirstChunk=!1,this._halted=!1,r=this._partialLine+e;var s=(this._partialLine="",this._handle.parse(r,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(e=s.meta.cursor,this._finished||(this._partialLine=r.substring(e-this._baseIndex),this._baseIndex=e),s&&s.data&&(this._rowCount+=s.data.length),r=this._finished||this._config.preview&&this._rowCount>=this._config.preview,i)n.postMessage({results:s,workerId:a.WORKER_ID,finished:r});else if(x(this._config.chunk)&&!t){if(this._config.chunk(s,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=s=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(s.data),this._completeResults.errors=this._completeResults.errors.concat(s.errors),this._completeResults.meta=s.meta),this._completed||!r||!x(this._config.complete)||s&&s.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),r||s&&s.meta.paused||this._nextChunk(),s}this._halted=!0},this._sendError=function(e){x(this._config.error)?this._config.error(e):i&&this._config.error&&n.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function u(e){var t;(e=e||{}).chunkSize||(e.chunkSize=a.RemoteChunkSize),l.call(this,e),this._nextChunk=r?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),r||(t.onload=b(this._chunkLoaded,this),t.onerror=b(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!r),this._config.downloadRequestHeaders){var e,n=this._config.downloadRequestHeaders;for(e in n)t.setRequestHeader(e,n[e])}var i;this._config.chunkSize&&(i=this._start+this._config.chunkSize-1,t.setRequestHeader("Range","bytes="+this._start+"-"+i));try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}r&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize||t.responseText.length,this._finished=!this._config.chunkSize||this._start>=(e=>null!==(e=e.getResponseHeader("Content-Range"))?parseInt(e.substring(e.lastIndexOf("/")+1)):-1)(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){e=t.statusText||e,this._sendError(new Error(e))}}function c(e){(e=e||{}).chunkSize||(e.chunkSize=a.LocalChunkSize),l.call(this,e);var t,n,r="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,n=e.slice||e.webkitSlice||e.mozSlice,r?((t=new FileReader).onload=b(this._chunkLoaded,this),t.onerror=b(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var e=this._input,i=(this._config.chunkSize&&(i=Math.min(this._start+this._config.chunkSize,this._input.size),e=n.call(e,this._start,i)),t.readAsText(e,this._config.encoding));r||this._chunkLoaded({target:{result:i}})},this._chunkLoaded=function(e){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function h(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){var e,n;if(!this._finished)return e=this._config.chunkSize,t=e?(n=t.substring(0,e),t.substring(e)):(n=t,""),this._finished=!t,this.parseChunk(n)}}function d(e){l.call(this,e=e||{});var t=[],n=!0,r=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){r&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):n=!0},this._streamData=b(function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),n&&(n=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}},this),this._streamError=b(function(e){this._streamCleanUp(),this._sendError(e)},this),this._streamEnd=b(function(){this._streamCleanUp(),r=!0,this._streamData("")},this),this._streamCleanUp=b(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function f(e){var t,n,r,i,s=Math.pow(2,53),o=-s,l=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,u=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,c=this,h=0,d=0,f=!1,m=!1,_=[],y={data:[],errors:[],meta:{}};function b(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function w(){if(y&&r&&(E("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),r=!1),e.skipEmptyLines&&(y.data=y.data.filter(function(e){return!b(e)})),A()){if(y)if(Array.isArray(y.data[0])){for(var t=0;A()&&t<y.data.length;t++)y.data[t].forEach(c);y.data.splice(0,1)}else y.data.forEach(c);function c(t,n){x(e.transformHeader)&&(t=e.transformHeader(t,n)),_.push(t)}}function n(t,n){for(var r=e.header?{}:[],i=0;i<t.length;i++){var a=i,c=t[i];c=((t,n)=>(t=>(e.dynamicTypingFunction&&void 0===e.dynamicTyping[t]&&(e.dynamicTyping[t]=e.dynamicTypingFunction(t)),!0===(e.dynamicTyping[t]||e.dynamicTyping)))(t)?"true"===n||"TRUE"===n||"false"!==n&&"FALSE"!==n&&((e=>{if(l.test(e)&&(e=parseFloat(e),o<e&&e<s))return 1})(n)?parseFloat(n):u.test(n)?new Date(n):""===n?null:n):n)(a=e.header?i>=_.length?"__parsed_extra":_[i]:a,c=e.transform?e.transform(c,a):c),"__parsed_extra"===a?(r[a]=r[a]||[],r[a].push(c)):r[a]=c}return e.header&&(i>_.length?E("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+i,d+n):i<_.length&&E("FieldMismatch","TooFewFields","Too few fields: expected "+_.length+" fields but parsed "+i,d+n)),r}var i;y&&(e.header||e.dynamicTyping||e.transform)&&(i=1,!y.data.length||Array.isArray(y.data[0])?(y.data=y.data.map(n),i=y.data.length):y.data=n(y.data,0),e.header&&y.meta&&(y.meta.fields=_),d+=i)}function A(){return e.header&&0===_.length}function E(e,t,n,r){e={type:e,code:t,message:n},void 0!==r&&(e.row=r),y.errors.push(e)}x(e.step)&&(i=e.step,e.step=function(t){y=t,A()?w():(w(),0!==y.data.length&&(h+=t.data.length,e.preview&&h>e.preview?n.abort():(y.data=y.data[0],i(y,c))))}),this.parse=function(i,s,o){var l=e.quoteChar||'"';return e.newline||(e.newline=this.guessLineEndings(i,l)),r=!1,e.delimiter?x(e.delimiter)&&(e.delimiter=e.delimiter(i),y.meta.delimiter=e.delimiter):((l=((t,n,r,i,s)=>{var o,l,u,c;s=s||[",","\t","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var h=0;h<s.length;h++){for(var d,f=s[h],p=0,m=0,_=0,y=(u=void 0,new g({comments:i,delimiter:f,newline:n,preview:10}).parse(t)),v=0;v<y.data.length;v++)r&&b(y.data[v])?_++:(m+=d=y.data[v].length,void 0===u?u=d:0<d&&(p+=Math.abs(d-u),u=d));0<y.data.length&&(m/=y.data.length-_),(void 0===l||p<=l)&&(void 0===c||c<m)&&1.99<m&&(l=p,o=f,c=m)}return{successful:!!(e.delimiter=o),bestDelimiter:o}})(i,e.newline,e.skipEmptyLines,e.comments,e.delimitersToGuess)).successful?e.delimiter=l.bestDelimiter:(r=!0,e.delimiter=a.DefaultDelimiter),y.meta.delimiter=e.delimiter),l=v(e),e.preview&&e.header&&l.preview++,t=i,n=new g(l),y=n.parse(t,s,o),w(),f?{meta:{paused:!0}}:y||{meta:{paused:!1}}},this.paused=function(){return f},this.pause=function(){f=!0,n.abort(),t=x(e.chunk)?"":t.substring(n.getCharIndex())},this.resume=function(){c.streamer._halted?(f=!1,c.streamer.parseChunk(t,!0)):setTimeout(c.resume,3)},this.aborted=function(){return m},this.abort=function(){m=!0,n.abort(),y.meta.aborted=!0,x(e.complete)&&e.complete(y),t=""},this.guessLineEndings=function(e,t){e=e.substring(0,1048576),t=new RegExp(p(t)+"([^]*?)"+p(t),"gm");var n=(e=e.replace(t,"")).split("\r");if(e=1<(t=e.split("\n")).length&&t[0].length<n[0].length,1===n.length||e)return"\n";for(var r=0,i=0;i<n.length;i++)"\n"===n[i][0]&&r++;return r>=n.length/2?"\r\n":"\r"}}function p(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g(e){var t=(e=e||{}).delimiter,n=e.newline,r=e.comments,i=e.step,s=e.preview,o=e.fastMode,l=null,u=!1,c=null==e.quoteChar?'"':e.quoteChar,h=c;if(void 0!==e.escapeChar&&(h=e.escapeChar),("string"!=typeof t||-1<a.BAD_DELIMITERS.indexOf(t))&&(t=","),r===t)throw new Error("Comment character same as delimiter");!0===r?r="#":("string"!=typeof r||-1<a.BAD_DELIMITERS.indexOf(r))&&(r=!1),"\n"!==n&&"\r"!==n&&"\r\n"!==n&&(n="\n");var d=0,f=!1;this.parse=function(a,g,m){if("string"!=typeof a)throw new Error("Input must be a string");var _=a.length,y=t.length,v=n.length,b=r.length,w=x(i),A=[],E=[],S=[],T=d=0;if(!a)return L();if(o||!1!==o&&-1===a.indexOf(c)){for(var k=a.split(n),O=0;O<k.length;O++){if(S=k[O],d+=S.length,O!==k.length-1)d+=n.length;else if(m)return L();if(!r||S.substring(0,b)!==r){if(w){if(A=[],I(S.split(t)),j(),f)return L()}else I(S.split(t));if(s&&s<=O)return A=A.slice(0,s),L(!0)}}return L()}for(var R=a.indexOf(t,d),C=a.indexOf(n,d),P=new RegExp(p(h)+p(c),"g"),M=a.indexOf(c,d);;)if(a[d]===c)for(M=d,d++;;){if(-1===(M=a.indexOf(c,M+1)))return m||E.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:A.length,index:d}),F();if(M===_-1)return F(a.substring(d,M).replace(P,c));if(c===h&&a[M+1]===h)M++;else if(c===h||0===M||a[M-1]!==h){-1!==R&&R<M+1&&(R=a.indexOf(t,M+1));var N=D(-1===(C=-1!==C&&C<M+1?a.indexOf(n,M+1):C)?R:Math.min(R,C));if(a.substr(M+1+N,y)===t){S.push(a.substring(d,M).replace(P,c)),a[d=M+1+N+y]!==c&&(M=a.indexOf(c,d)),R=a.indexOf(t,d),C=a.indexOf(n,d);break}if(N=D(C),a.substring(M+1+N,M+1+N+v)===n){if(S.push(a.substring(d,M).replace(P,c)),z(M+1+N+v),R=a.indexOf(t,d),M=a.indexOf(c,d),w&&(j(),f))return L();if(s&&A.length>=s)return L(!0);break}E.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:A.length,index:d}),M++}}else if(r&&0===S.length&&a.substring(d,d+b)===r){if(-1===C)return L();d=C+v,C=a.indexOf(n,d),R=a.indexOf(t,d)}else if(-1!==R&&(R<C||-1===C))S.push(a.substring(d,R)),d=R+y,R=a.indexOf(t,d);else{if(-1===C)break;if(S.push(a.substring(d,C)),z(C+v),w&&(j(),f))return L();if(s&&A.length>=s)return L(!0)}return F();function I(e){A.push(e),T=d}function D(e){var t=0;return-1!==e&&(e=a.substring(M+1,e))&&""===e.trim()?e.length:t}function F(e){return m||(void 0===e&&(e=a.substring(d)),S.push(e),d=_,I(S),w&&j()),L()}function z(e){d=e,I(S),S=[],C=a.indexOf(n,d)}function L(r){if(e.header&&!g&&A.length&&!u){var i=A[0],s=Object.create(null),o=new Set(i);let t=!1;for(let n=0;n<i.length;n++){let r=i[n];if(s[r=x(e.transformHeader)?e.transformHeader(r,n):r]){let e,a=s[r];for(;e=r+"_"+a,a++,o.has(e););o.add(e),i[n]=e,s[r]++,t=!0,(l=null===l?{}:l)[e]=r}else s[r]=1,i[n]=r;o.add(r)}t&&console.warn("Duplicate headers found and renamed."),u=!0}return{data:A,errors:E,meta:{delimiter:t,linebreak:n,aborted:f,truncated:!!r,cursor:T+(g||0),renamedHeaders:l}}}function j(){i(L()),A=[],E=[]}},this.abort=function(){f=!0},this.getCharIndex=function(){return d}}function m(e){var t=e.data,n=s[t.workerId],r=!1;if(t.error)n.userError(t.error,t.file);else if(t.results&&t.results.data){var i={abort:function(){r=!0,_(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:y,resume:y};if(x(n.userStep)){for(var o=0;o<t.results.data.length&&(n.userStep({data:t.results.data[o],errors:t.results.errors,meta:t.results.meta},i),!r);o++);delete t.results}else x(n.userChunk)&&(n.userChunk(t.results,i,t.file),delete t.results)}t.finished&&!r&&_(t.workerId,t.results)}function _(e,t){var n=s[e];x(n.userComplete)&&n.userComplete(t),n.terminate(),delete s[e]}function y(){throw new Error("Not implemented.")}function v(e){if("object"!=typeof e||null===e)return e;var t,n=Array.isArray(e)?[]:{};for(t in e)n[t]=v(e[t]);return n}function b(e,t){return function(){e.apply(t,arguments)}}function x(e){return"function"==typeof e}return a.parse=function(t,r){var i=(r=r||{}).dynamicTyping||!1;if(x(i)&&(r.dynamicTypingFunction=i,i={}),r.dynamicTyping=i,r.transform=!!x(r.transform)&&r.transform,!r.worker||!a.WORKERS_SUPPORTED)return i=null,a.NODE_STREAM_INPUT,"string"==typeof t?(t=(e=>65279!==e.charCodeAt(0)?e:e.slice(1))(t),i=new(r.download?u:h)(r)):!0===t.readable&&x(t.read)&&x(t.on)?i=new d(r):(n.File&&t instanceof File||t instanceof Object)&&(i=new c(r)),i.stream(t);(i=(()=>{var t;return!!a.WORKERS_SUPPORTED&&(t=(()=>{var t=n.URL||n.webkitURL||null,r=e.toString();return a.BLOB_URL||(a.BLOB_URL=t.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",r,")();"],{type:"text/javascript"})))})(),(t=new n.Worker(t)).onmessage=m,t.id=o++,s[t.id]=t)})()).userStep=r.step,i.userChunk=r.chunk,i.userComplete=r.complete,i.userError=r.error,r.step=x(r.step),r.chunk=x(r.chunk),r.complete=x(r.complete),r.error=x(r.error),delete r.worker,i.postMessage({input:t,config:r,workerId:i.id})},a.unparse=function(e,t){var n=!1,r=!0,i=",",s="\r\n",o='"',l=o+o,u=!1,c=null,h=!1,d=((()=>{if("object"==typeof t){if("string"!=typeof t.delimiter||a.BAD_DELIMITERS.filter(function(e){return-1!==t.delimiter.indexOf(e)}).length||(i=t.delimiter),"boolean"!=typeof t.quotes&&"function"!=typeof t.quotes&&!Array.isArray(t.quotes)||(n=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(u=t.skipEmptyLines),"string"==typeof t.newline&&(s=t.newline),"string"==typeof t.quoteChar&&(o=t.quoteChar),"boolean"==typeof t.header&&(r=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+o),t.escapeFormulae instanceof RegExp?h=t.escapeFormulae:"boolean"==typeof t.escapeFormulae&&t.escapeFormulae&&(h=/^[=+\-@\t\r].*$/)}})(),new RegExp(p(o),"g"));if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return f(null,e,u);if("object"==typeof e[0])return f(c||Object.keys(e[0]),e,u)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),f(e.fields||[],e.data||[],u);throw new Error("Unable to serialize unrecognized input");function f(e,t,n){var o="",a=("string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t)),Array.isArray(e)&&0<e.length),l=!Array.isArray(t[0]);if(a&&r){for(var u=0;u<e.length;u++)0<u&&(o+=i),o+=g(e[u],u);0<t.length&&(o+=s)}for(var c=0;c<t.length;c++){var h=(a?e:t[c]).length,d=!1,f=a?0===Object.keys(t[c]).length:0===t[c].length;if(n&&!a&&(d="greedy"===n?""===t[c].join("").trim():1===t[c].length&&0===t[c][0].length),"greedy"===n&&a){for(var p=[],m=0;m<h;m++){var _=l?e[m]:m;p.push(t[c][_])}d=""===p.join("").trim()}if(!d){for(var y=0;y<h;y++){0<y&&!f&&(o+=i);var v=a&&l?e[y]:y;o+=g(t[c][v],y)}c<t.length-1&&(!n||0<h&&!f)&&(o+=s)}}return o}function g(e,t){var r,s;return null==e?"":e.constructor===Date?JSON.stringify(e).slice(1,25):(s=!1,h&&"string"==typeof e&&h.test(e)&&(e="'"+e,s=!0),r=e.toString().replace(d,l),(s=s||!0===n||"function"==typeof n&&n(e,t)||Array.isArray(n)&&n[t]||((e,t)=>{for(var n=0;n<t.length;n++)if(-1<e.indexOf(t[n]))return!0;return!1})(r,a.BAD_DELIMITERS)||-1<r.indexOf(i)||" "===r.charAt(0)||" "===r.charAt(r.length-1))?o+r+o:r)}},a.RECORD_SEP=String.fromCharCode(30),a.UNIT_SEP=String.fromCharCode(31),a.BYTE_ORDER_MARK="\ufeff",a.BAD_DELIMITERS=["\r","\n",'"',a.BYTE_ORDER_MARK],a.WORKERS_SUPPORTED=!r&&!!n.Worker,a.NODE_STREAM_INPUT=1,a.LocalChunkSize=10485760,a.RemoteChunkSize=5242880,a.DefaultDelimiter=",",a.Parser=g,a.ParserHandle=f,a.NetworkStreamer=u,a.FileStreamer=c,a.StringStreamer=h,a.ReadableStreamStreamer=d,n.jQuery&&((t=n.jQuery).fn.parse=function(e){var r=e.config||{},i=[];return this.each(function(e){if("INPUT"!==t(this).prop("tagName").toUpperCase()||"file"!==t(this).attr("type").toLowerCase()||!n.FileReader||!this.files||0===this.files.length)return!0;for(var s=0;s<this.files.length;s++)i.push({file:this.files[s],inputElem:this,instanceConfig:t.extend({},r)})}),s(),this;function s(){if(0===i.length)x(e.complete)&&e.complete();else{var n,r,s,l,u=i[0];if(x(e.before)){var c=e.before(u.file,u.inputElem);if("object"==typeof c){if("abort"===c.action)return n="AbortError",r=u.file,s=u.inputElem,l=c.reason,void(x(e.error)&&e.error({name:n},r,s,l));if("skip"===c.action)return void o();"object"==typeof c.config&&(u.instanceConfig=t.extend(u.instanceConfig,c.config))}else if("skip"===c)return void o()}var h=u.instanceConfig.complete;u.instanceConfig.complete=function(e){x(h)&&h(e,u.file,u.inputElem),o()},a.parse(u.file,u.instanceConfig)}}function o(){i.splice(0,1),s()}}),i&&(n.onmessage=function(e){e=e.data,void 0===a.WORKER_ID&&e&&(a.WORKER_ID=e.workerId),"string"==typeof e.input?n.postMessage({workerId:a.WORKER_ID,results:a.parse(e.input,e.config),finished:!0}):(n.File&&e.input instanceof File||e.input instanceof Object)&&(e=a.parse(e.input,e.config))&&n.postMessage({workerId:a.WORKER_ID,results:e,finished:!0})}),(u.prototype=Object.create(l.prototype)).constructor=u,(c.prototype=Object.create(l.prototype)).constructor=c,(h.prototype=Object.create(h.prototype)).constructor=h,(d.prototype=Object.create(l.prototype)).constructor=d,a}()),Cy.exports),My=fe(Py);function Ny(e,t){return My.parse(e,t)}function Iy(e,t){My.parse(e,Object.assign({},{download:!0},t))}function Dy(e,t){return void 0===t&&(t={}),My.unparse(e,t)}"function"==typeof SuppressedError&&SuppressedError,My.BAD_DELIMITERS,My.RECORD_SEP,My.UNIT_SEP,My.WORKERS_SUPPORTED,My.LocalChunkSize,My.DefaultDelimiter;const Fy=({onDataParsed:t,onError:n,delimiter:r=",",header:i=!0,dynamicTyping:s=!0,skipEmptyLines:o=!0,worker:a=!1})=>{const{readString:l}={readString:Ny,readRemoteFile:Iy,jsonToCSV:Dy},[u,c]=e.useState(!1),[h,d]=e.useState(null);return b(ql,{accept:".csv",loading:u,error:h,onFilesLoad:({files:e})=>{const u=e[0];c(!0),d(null),u.text().then(e=>{l(e,{delimiter:r,header:i,dynamicTyping:s,skipEmptyLines:o,worker:a,complete:e=>{if(e.errors.length>0){const t=e.errors.map(({type:e,message:t})=>`${e}: ${t}`).join("; ");d(t),n?.(new Error(t))}else{const n=e.data,r=e.meta.fields||[];t?.(n,r)}},error:e=>{const t=e.message||"Ошибка при парсинге CSV";d(t),n?.(new Error(t))}})}).catch(e=>{const t=e instanceof Error?e.message:"Неизвестная ошибка";d(t),n?.(new Error(t))}).finally(()=>{c(!1)})},children:"Загрузить файлы csv"})};var zy={createDocument:function(e){return(new DOMParser).parseFromString(e.trim(),"text/xml")}},Ly=Uint8Array,jy=Uint16Array,Vy=Int32Array,Uy=new Ly([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),By=new Ly([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Gy=new Ly([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$y=function(e,t){for(var n=new jy(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new Vy(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return{b:n,r:i}},qy=$y(Uy,2),Hy=qy.b,Wy=qy.r;Hy[28]=258,Wy[258]=28;for(var Zy=$y(By,0).b,Ky=new jy(32768),Xy=0;Xy<32768;++Xy){var Yy=(43690&Xy)>>1|(21845&Xy)<<1;Yy=(61680&(Yy=(52428&Yy)>>2|(13107&Yy)<<2))>>4|(3855&Yy)<<4,Ky[Xy]=((65280&Yy)>>8|(255&Yy)<<8)>>1}var Qy=function(e,t,n){for(var r=e.length,i=0,s=new jy(t);i<r;++i)e[i]&&++s[e[i]-1];var o,a=new jy(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(n){o=new jy(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var u=i<<4|e[i],c=t-e[i],h=a[e[i]-1]++<<c,d=h|(1<<c)-1;h<=d;++h)o[Ky[h]>>l]=u}else for(o=new jy(r),i=0;i<r;++i)e[i]&&(o[i]=Ky[a[e[i]-1]++]>>15-e[i]);return o},Jy=new Ly(288);for(Xy=0;Xy<144;++Xy)Jy[Xy]=8;for(Xy=144;Xy<256;++Xy)Jy[Xy]=9;for(Xy=256;Xy<280;++Xy)Jy[Xy]=7;for(Xy=280;Xy<288;++Xy)Jy[Xy]=8;var ev=new Ly(32);for(Xy=0;Xy<32;++Xy)ev[Xy]=5;var tv=Qy(Jy,9,1),nv=Qy(ev,5,1),rv=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},iv=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},sv=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},ov=function(e){return(e+7)/8|0},av=function(e,t,n){return(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length),new Ly(e.subarray(t,n))},lv=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],uv=function(e,t,n){var r=new Error(t||lv[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,uv),!n)throw r;return r},cv=new Ly(0),hv=function(e,t){return e[t]|e[t+1]<<8},dv=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},fv=function(e,t){return dv(e,t)+4294967296*dv(e,t+4)};function pv(e,t){return function(e,t,n,r){var i=e.length,s=r?r.length:0;if(!i||t.f&&!t.l)return n||new Ly(0);var o=!n,a=o||2!=t.i,l=t.i;o&&(n=new Ly(3*i));var u=function(e){var t=n.length;if(e>t){var r=new Ly(Math.max(2*t,e));r.set(n),n=r}},c=t.f||0,h=t.p||0,d=t.b||0,f=t.l,p=t.d,g=t.m,m=t.n,_=8*i;do{if(!f){c=iv(e,h,1);var y=iv(e,h+1,3);if(h+=3,!y){var v=e[(C=ov(h)+4)-4]|e[C-3]<<8,b=C+v;if(b>i){l&&uv(0);break}a&&u(d+v),n.set(e.subarray(C,b),d),t.b=d+=v,t.p=h=8*b,t.f=c;continue}if(1==y)f=tv,p=nv,g=9,m=5;else if(2==y){var x=iv(e,h,31)+257,w=iv(e,h+10,15)+4,A=x+iv(e,h+5,31)+1;h+=14;for(var E=new Ly(A),S=new Ly(19),T=0;T<w;++T)S[Gy[T]]=iv(e,h+3*T,7);h+=3*w;var k=rv(S),O=(1<<k)-1,R=Qy(S,k,1);for(T=0;T<A;){var C,P=R[iv(e,h,O)];if(h+=15&P,(C=P>>4)<16)E[T++]=C;else{var M=0,N=0;for(16==C?(N=3+iv(e,h,3),h+=2,M=E[T-1]):17==C?(N=3+iv(e,h,7),h+=3):18==C&&(N=11+iv(e,h,127),h+=7);N--;)E[T++]=M}}var I=E.subarray(0,x),D=E.subarray(x);g=rv(I),m=rv(D),f=Qy(I,g,1),p=Qy(D,m,1)}else uv(1);if(h>_){l&&uv(0);break}}a&&u(d+131072);for(var F=(1<<g)-1,z=(1<<m)-1,L=h;;L=h){var j=(M=f[sv(e,h)&F])>>4;if((h+=15&M)>_){l&&uv(0);break}if(M||uv(2),j<256)n[d++]=j;else{if(256==j){L=h,f=null;break}var V=j-254;if(j>264){var U=Uy[T=j-257];V=iv(e,h,(1<<U)-1)+Hy[T],h+=U}var B=p[sv(e,h)&z],G=B>>4;if(B||uv(3),h+=15&B,D=Zy[G],G>3&&(U=By[G],D+=sv(e,h)&(1<<U)-1,h+=U),h>_){l&&uv(0);break}a&&u(d+131072);var $=d+V;if(d<D){var q=s-D,H=Math.min(D,$);for(q+d<0&&uv(3);d<H;++d)n[d]=r[q+d]}for(;d<$;++d)n[d]=n[d-D]}}t.l=f,t.p=L,t.b=d,t.f=c,f&&(c=1,t.m=g,t.d=p,t.n=m)}while(!c);return d!=n.length&&o?av(n,0,d):n.subarray(0,d)}(e,{i:2},t&&t.out,t&&t.dictionary)}var gv="undefined"!=typeof TextDecoder&&new TextDecoder;try{gv.decode(cv,{stream:!0})}catch(My){}function mv(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(gv)return gv.decode(e);var i=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:av(e,n-1)};i?3==i?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&i?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}}(e),s=i.s;return(n=i.r).length&&uv(8),s}var _v=function(e,t){return t+30+hv(e,t+26)+hv(e,t+28)},yv=function(e,t,n){var r=hv(e,t+28),i=mv(e.subarray(t+46,t+46+r),!(2048&hv(e,t+8))),s=t+46+r,o=dv(e,t+20),a=n&&4294967295==o?vv(e,s):[o,dv(e,t+24),dv(e,t+42)],l=a[0],u=a[1],c=a[2];return[hv(e,t+10),l,u,i,s+hv(e,t+30)+hv(e,t+32),c]},vv=function(e,t){for(;1!=hv(e,t);t+=4+hv(e,t+2));return[fv(e,t+12),fv(e,t+4),fv(e,t+20)]};function bv(e){var t=function(e){for(var t={},n=e.length-22;101010256!=dv(e,n);--n)(!n||e.length-n>65558)&&uv(13);var r=hv(e,n+8);if(!r)return{};var i=dv(e,n+16),s=4294967295==i||65535==r;if(s){var o=dv(e,n-12);(s=101075792==dv(e,o))&&(r=dv(e,o+32),i=dv(e,o+48))}for(var a=0;a<r;++a){var l=yv(e,i,s),u=l[0],c=l[1],h=l[2],d=l[3],f=l[4],p=l[5],g=_v(e,p);i=f,u?8==u?t[d]=pv(e.subarray(g,g+c),{out:new Ly(h)}):uv(14,"unknown compression type "+u):t[d]=av(e,g,g+c)}return t}(new Uint8Array(e));return Promise.resolve(function(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];t[i]=mv(e[i])}return t}(t))}function xv(e,t){for(var n=0;n<e.childNodes.length;){var r=e.childNodes[n];if(1===r.nodeType&&Sv(r)===t)return r;n++}}function wv(e,t){for(var n=[],r=0;r<e.childNodes.length;){var i=e.childNodes[r];1===i.nodeType&&Sv(i)===t&&n.push(i),r++}return n}function Av(e,t,n){for(var r=0;r<e.childNodes.length;){var i=e.childNodes[r];t?1===i.nodeType&&Sv(i)===t&&n(i,r):n(i,r),r++}}var Ev=/.+\:/;function Sv(e){return e.tagName.replace(Ev,"")}function Tv(e){if(1!==e.nodeType)return e.textContent;for(var t="<"+Sv(e),n=0;n<e.attributes.length;)t+=" "+e.attributes[n].name+'="'+e.attributes[n].value+'"',n++;t+=">";for(var r=0;r<e.childNodes.length;)t+=Tv(e.childNodes[r]),r++;return t+="</"+Sv(e)+">"}function kv(e){var t,n,r=e.documentElement;return t=function(e){var t=xv(e,"t");if(t)return t.textContent;var n="";return Av(e,"r",function(e){n+=xv(e,"t").textContent}),n},n=[],Av(r,"si",function(e,r){n.push(t(e,r))}),n}function Ov(e,t){var n=t.createDocument(e),r={},i=function(e){return xv(e.documentElement,"workbookPr")}(n);i&&"1"===i.getAttribute("date1904")&&(r.epoch1904=!0),r.sheets=[];return function(e){return wv(xv(e.documentElement,"sheets"),"sheet")}(n).forEach(function(e){e.getAttribute("name")&&r.sheets.push({id:e.getAttribute("sheetId"),name:e.getAttribute("name"),relationId:e.getAttribute("r:id")})}),r}function Rv(e,t){var n=t.createDocument(e),r={sheets:{},sharedStrings:void 0,styles:void 0};return function(e){return wv(e.documentElement,"Relationship")}(n).forEach(function(e){var t=e.getAttribute("Target");switch(e.getAttribute("Type")){case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles":r.styles=Cv(t);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings":r.sharedStrings=Cv(t);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":r.sheets[e.getAttribute("Id")]=Cv(t)}}),r}function Cv(e){return"/"===e[0]?e.slice(1):"xl/"+e}function Pv(e){"@babel/helpers - typeof";return Pv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pv(e)}function Mv(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nv(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Mv(Object(n),!0).forEach(function(t){Iv(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mv(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Iv(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Pv(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!==Pv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Pv(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dv(e,t){if(!e)return{};var n=t.createDocument(e),r=function(e){var t=xv(e.documentElement,"cellStyleXfs");return t?wv(t,"xf"):[]}(n).map(zv),i=function(e){var t=xv(e.documentElement,"numFmts");return t?wv(t,"numFmt"):[]}(n).map(Fv).reduce(function(e,t){return e[t.id]=t,e},[]);return function(e){var t=xv(e.documentElement,"cellXfs");return t?wv(t,"xf"):[]}(n).map(function(e){return e.hasAttribute("xfId")?Nv(Nv({},r[e.xfId]),zv(e,i)):zv(e,i)})}function Fv(e){return{id:e.getAttribute("numFmtId"),template:e.getAttribute("formatCode")}}function zv(e,t){var n={};if(e.hasAttribute("numFmtId")){var r=e.getAttribute("numFmtId");t[r]?n.numberFormat=t[r]:n.numberFormat={id:r}}return n}function Lv(e,t){t&&t.epoch1904&&(e+=1462);return new Date(Math.round(24*(e-25569)*36e5))}function jv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Vv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Vv(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Vv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Uv(e,t,n){if(e){var r=t[e];if(!r)throw new Error("Cell style not found: ".concat(e));if(!r.numberFormat)return!1;if(Bv.indexOf(Number(r.numberFormat.id))>=0||n.dateFormat&&r.numberFormat.template===n.dateFormat||!1!==n.smartDateParser&&r.numberFormat.template&&function(e){for(var t,n=jv((e=(e=(e=e.toLowerCase()).replace(Gv,"")).replace($v,"")).split(/\W+/));!(t=n()).done;){var r=t.value;if(qv.indexOf(r)<0)return!1}return!0}(r.numberFormat.template))return!0}}var Bv=[14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57],Gv=/^\[\$-414\]/,$v=/;@$/;var qv=["ss","mm","h","hh","am","pm","d","dd","m","mm","mmm","mmmm","yy","yyyy","e"];function Hv(e,t,n){var r=n.getInlineStringValue,i=n.getInlineStringXml,s=n.getStyleId,o=n.styles,a=n.values,l=n.properties,u=n.options;switch(t||(t="n"),t){case"str":e=Wv(e,u);break;case"inlineStr":if(void 0===(e=r()))throw new Error('Unsupported "inline string" cell value structure: '.concat(i()));e=Wv(e,u);break;case"s":var c=Number(e);if(isNaN(c))throw new Error('Invalid "shared" string index: '.concat(e));if(c>=a.length)throw new Error('An out-of-bounds "shared" string index: '.concat(e));e=Wv(e=a[c],u);break;case"b":if("1"===e)e=!0;else{if("0"!==e)throw new Error('Unsupported "boolean" cell value: '.concat(e));e=!1}break;case"z":e=void 0;break;case"e":e=function(e){switch(e){case 0:return"#NULL!";case 7:return"#DIV/0!";case 15:return"#VALUE!";case 23:return"#REF!";case 29:return"#NAME?";case 36:return"#NUM!";case 42:return"#N/A";case 43:return"#GETTING_DATA";default:return"#ERROR_".concat(e)}}(e);break;case"d":if(void 0===e)break;var h=new Date(e);if(isNaN(h.valueOf()))throw new Error('Unsupported "date" cell value: '.concat(e));e=h;break;case"n":if(void 0===e)break;e=Uv(s(),o,u)?Lv(e=Zv(e),l):(u.parseNumber||Zv)(e);break;default:throw new TypeError("Cell type not supported: ".concat(t))}return void 0===e&&(e=null),e}function Wv(e,t){return!1!==t.trim&&(e=e.trim()),""===e&&(e=void 0),e}function Zv(e){var t=Number(e);if(isNaN(t))throw new Error('Invalid "numeric" cell value: '.concat(e));return t}var Kv=["","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function Xv(e){for(var t=0,n=0;n<e.length;)t*=26,t+=Kv.indexOf(e[n]),n++;return t}function Yv(e){return e=e.split(/(\d+)/),[parseInt(e[1]),Xv(e[0].trim())]}function Qv(e,t,n,r,i,s,o){var a,l=Yv(e.getAttribute("r")),u=function(e,t){return xv(t,"v")}(0,e),c=u&&u.textContent;return e.hasAttribute("t")&&(a=e.getAttribute("t")),{row:l[0],column:l[1],value:Hv(c,a,{getInlineStringValue:function(){return function(e,t){if(t.firstChild&&"is"===Sv(t.firstChild)&&t.firstChild.firstChild&&"t"===Sv(t.firstChild.firstChild))return t.firstChild.firstChild.textContent}(0,e)},getInlineStringXml:function(){return Tv(e)},getStyleId:function(){return e.getAttribute("s")},styles:i,values:r,properties:s,options:o})}}function Jv(e,t,n,r,i,s){var o=function(e){var t=xv(e.documentElement,"sheetData"),n=[];return Av(t,"row",function(e){Av(e,"c",function(e){n.push(e)})}),n}(e);return 0===o.length?[]:o.map(function(e){return Qv(e,0,0,n,r,i,s)})}function eb(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,s,o,a=[],l=!0,u=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return a}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return tb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tb(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tb(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function nb(e){var t=function(e){var t=xv(e.documentElement,"dimension");if(t)return t.getAttribute("ref")}(e);if(t)return 1===(t=t.split(":").map(Yv).map(function(e){var t=eb(e,2);return{row:t[0],column:t[1]}})).length&&(t=[t[0],t[0]]),t}function rb(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ib(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ib(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ib(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function sb(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ob(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ob(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ob(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ab(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,s,o,a=[],l=!0,u=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return a}}(e,t)||lb(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lb(e,t){if(e){if("string"==typeof e)return ub(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ub(e,t):void 0}}function ub(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function cb(e,t){var n=e.dimensions,r=e.cells;if(0===r.length)return[];var i=ab(n,2);i[0];for(var s=i[1],o=s.column,a=s.row,l=new Array(a),u=0;u<a;){l[u]=new Array(o);for(var c=0;c<o;)l[u][c]=null,c++;u++}for(var h,d=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=lb(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(h=d()).done;){var f=h.value,p=f.row-1,g=f.column-1;g<o&&p<a&&(l[p][g]=f.value)}var m=t.rowIndexSourceMap;if(m)for(var _=0;_<l.length;)m[_]=_,_++;return l=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.rowIndexSourceMap,r=t.accessor,i=void 0===r?function(e){return e}:r,s=t.onlyTrimAtTheEnd,o=e.length-1;o>=0;){for(var a,l=!0,u=rb(e[o]);!(a=u()).done;)if(null!==i(a.value)){l=!1;break}if(l)e.splice(o,1),n&&n.splice(o,1);else if(s)break;o--}return e}(function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.accessor,r=void 0===n?function(e){return e}:n,i=t.onlyTrimAtTheEnd,s=e[0].length-1;s>=0;){for(var o,a=!0,l=sb(e);!(o=l()).done;)if(null!==r(o.value[s])){a=!1;break}if(a)for(var u=0;u<e.length;)e[u].splice(s,1),u++;else if(i)break;s--}return e}(l,{onlyTrimAtTheEnd:!0}),{onlyTrimAtTheEnd:!0,rowIndexSourceMap:m}),t.transformData&&(l=t.transformData(l)),l}function hb(e){"@babel/helpers - typeof";return hb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},hb(e)}function db(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return fb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fb(e,t)}(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function fb(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function pb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function gb(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pb(Object(n),!0).forEach(function(t){mb(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pb(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mb(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==hb(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!==hb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===hb(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _b(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.sheet||(n=gb({sheet:1},n));var r=function(t){if(!e[t])throw new Error('"'.concat(t,'" file not found inside the *.xlsx file zip archive'));return e[t]},i=Rv(r("xl/_rels/workbook.xml.rels"),t),s=i.sharedStrings?function(e,t){return e?kv(t.createDocument(e)):[]}(r(i.sharedStrings),t):[],o=i.styles?Dv(r(i.styles),t):{},a=Ov(r("xl/workbook.xml"),t);if(n.getSheets)return a.sheets.map(function(e){return{name:e.name}});var l=function(e,t){if("number"==typeof e){var n=t[e-1];return n&&n.relationId}for(var r,i=db(t);!(r=i()).done;){var s=r.value;if(s.name===e)return s.relationId}}(n.sheet,a.sheets);if(!l||!i.sheets[l])throw function(e,t){var n=t&&t.map(function(e,t){return'"'.concat(e.name,'" (#').concat(t+1,")")}).join(", ");return new Error("Sheet ".concat("number"==typeof e?"#"+e:'"'+e+'"'," not found in the *.xlsx file.").concat(t?" Available sheets: "+n+".":""))}(n.sheet,a.sheets);var u=function(e,t,n,r,i,s){var o=t.createDocument(e),a=Jv(o,0,n,r,i,s),l=nb(o)||function(e){var t=function(e,t){return e-t},n=e.map(function(e){return e.row}).sort(t),r=e.map(function(e){return e.column}).sort(t),i=n[0],s=n[n.length-1];return[{row:i,column:r[0]},{row:s,column:r[r.length-1]}]}(a);return{cells:a,dimensions:l}}(r(i.sheets[l]),t,s,o,a,n),c=cb(u,n=gb({rowIndexSourceMap:[]},n));return n.properties?{data:c,properties:a}:c}function yb(e){"@babel/helpers - typeof";return yb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yb(e)}function vb(e){var t=wb();return function(){var n,r=Eb(e);if(t){var i=Eb(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"===yb(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function bb(e){var t="function"==typeof Map?new Map:void 0;return bb=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return xb(e,arguments,Eb(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Ab(r,e)},bb(e)}function xb(e,t,n){return xb=wb()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&Ab(i,n.prototype),i},xb.apply(null,arguments)}function wb(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function Ab(e,t){return Ab=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ab(e,t)}function Eb(e){return Eb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Eb(e)}var Sb=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ab(e,t)}(n,bb(Error));var e,t=vb(n);function n(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(r=t.call(this,"invalid")).reason=e,r}return e=n,Object.defineProperty(e,"prototype",{writable:!1}),e}();function Tb(e){if("string"==typeof e){var t=e;if(e=Number(e),String(e)!==t)throw new Sb("not_a_number")}if("number"!=typeof e)throw new Sb("not_a_number");if(isNaN(e))throw new Sb("invalid_number");if(!isFinite(e))throw new Sb("out_of_bounds");return e}function kb(e){if("string"==typeof e)return e;if("number"==typeof e){if(isNaN(e))throw new Sb("invalid_number");if(!isFinite(e))throw new Sb("out_of_bounds");return String(e)}throw new Sb("not_a_string")}function Ob(e){if("boolean"==typeof e)return e;throw new Sb("not_a_boolean")}var Rb=["isColumnOriented","ignoreEmptyRows","rowIndexSourceMap"];function Cb(e){"@babel/helpers - typeof";return Cb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cb(e)}function Pb(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,s,o,a=[],l=!0,u=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return a}}(e,t)||Mb(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Mb(e,t){if(e){if("string"==typeof e)return Nb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nb(e,t):void 0}}function Nb(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ib(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Db(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Fb(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Db(Object(n),!0).forEach(function(t){zb(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Db(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zb(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Cb(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!==Cb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Cb(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Lb={schemaPropertyValueForMissingColumn:void 0,schemaPropertyValueForMissingValue:null,schemaPropertyShouldSkipRequiredValidationForMissingColumn:function(){return!1},getEmptyObjectValue:function(){return null},getEmptyArrayValue:function(){return null},isColumnOriented:!1,ignoreEmptyRows:!0,arrayValueSeparator:","};function jb(e,t,n){var r=n=n?Fb(Fb({},Lb),n):Lb,i=r.isColumnOriented,s=r.ignoreEmptyRows,o=r.rowIndexSourceMap,a=Ib(r,Rb),l=o&&o.slice();!function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t],i=e[r];if("object"===Cb(i.type)&&!Array.isArray(i.type))throw new Error("When defining a nested schema, use a `schema` property instead of a `type` property");if(!i.schema&&!i.column)throw new Error('"column" not defined for schema entry "'.concat(r,'".'))}}(t),i&&(e=$b(e)),s&&(e=e.filter(function(e,t){return!e.every(function(e){return null===e})||(l&&l.splice(t,1),!1)}));for(var u=e[0],c=[],h=[],d=1;d<e.length;d++){var f=Vb(t,e[d],d,void 0,u,h,a);c.push(f)}if(l)for(var p,g=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=Mb(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(h);!(p=g()).done;){var m=p.value;m.row=l[m.row-1]+1}return{rows:c,errors:h}}function Vb(e,t,n,r,i,s,o){for(var a={},l=!0,u=function(e){var t=e.schemaEntry,r=e.value,i=e.error,s=e.reason,o={error:i,row:n+1,column:t.column,value:r};return s&&(o.reason=s),t.type&&(o.type=t.type),o},c=[],h=function(){var h,p,g,m,_=f[d],y=e[_],v=_,b=y.column,x="".concat(r||"",".").concat(v),w=i.indexOf(b),A=w<0;if(A||(h=t[w]),y.schema)p=Vb(y.schema,t,n,x,i,s,o);else if(A)"schemaPropertyValueForMissingColumn"in o&&(p=o.schemaPropertyValueForMissingColumn);else if(void 0===h)"schemaPropertyValueForMissingValue"in o&&(p=o.schemaPropertyValueForMissingValue);else if(null===h)"schemaPropertyValueForMissingValue"in o&&(p=o.schemaPropertyValueForMissingValue);else if(Array.isArray(y.type)){var E=function(e,t){var n=[],r=0;for(;r<e.length;){var i=Pb(Gb(e,t,r),2),s=i[0];r+=i[1]+t.length,n.push(s.trim())}return n}(h,o.arrayValueSeparator).map(function(e){if(!g){var t=Ub(e,y,o);return t.error&&(p=e,g=t.error,m=t.reason),t.value}});if(!g){var S=E.every(qb);p=S?o.getEmptyArrayValue(E,{path:x}):E}}else{var T=Ub(h,y,o);g=T.error,m=T.reason,p=g?h:T.value}!g&&qb(p)&&y.required&&c.push({schemaEntry:y,value:p,isMissingColumn:A}),g?s.push(u({schemaEntry:y,value:p,error:g,reason:m})):(l&&!qb(p)&&(l=!1),void 0!==p&&(a[v]=p))},d=0,f=Object.keys(e);d<f.length;d++)h();if(l)return o.getEmptyObjectValue(a,{path:r});for(var p=0,g=c;p<g.length;p++){var m=g[p],_=m.schemaEntry,y=m.value;if(!(m.isMissingColumn&&o.schemaPropertyShouldSkipRequiredValidationForMissingColumn(_.column,{object:a}))){var v=_.required;("boolean"==typeof v?v:v(a))&&s.push(u({schemaEntry:_,value:y,error:"required"}))}}return a}function Ub(e,t,n){if(null===e)return{value:null};var r;if(t.parse)throw new Error("`schemaEntry.parse` property was renamed to `schemaEntry.type`");if(r=t.type?function(e,t,n){switch(t){case String:return Bb(e,kb);case Number:return Bb(e,Tb);case Date:return Bb(e,function(e){return function(e,t){var n=t.properties;if(e instanceof Date){if(isNaN(e.valueOf()))throw new Sb("out_of_bounds");return e}if("number"==typeof e){if(isNaN(e))throw new Sb("invalid_number");if(!isFinite(e))throw new Sb("out_of_bounds");var r=Lv(e,n);if(isNaN(r.valueOf()))throw new Sb("out_of_bounds");return r}throw new Sb("not_a_date")}(e,{properties:n.properties})});case Boolean:return Bb(e,Ob);default:if("function"==typeof t)return Bb(e,t);throw new Error("Unsupported schema type: ".concat(t&&t.name||t))}}(e,Array.isArray(t.type)?t.type[0]:t.type,n):{value:e},r.error)return r;if(null!==r.value){if(t.oneOf&&t.oneOf.indexOf(r.value)<0)return{error:"invalid",reason:"unknown"};if(t.validate)try{t.validate(r.value)}catch(e){return{error:e.message}}}return r}function Bb(e,t){try{var n=t(e);return void 0===n?{value:null}:{value:n}}catch(e){var r={error:e.message};return e.reason&&(r.reason=e.reason),r}}function Gb(e,t,n){for(var r=0,i="";n+r<e.length;){var s=e[n+r];if(s===t)return[i,r];if('"'===s){var o=Gb(e,'"',n+r+1);i+=o[0],r+=1+o[1]+1}else i+=s,r++}return[i,r]}var $b=function(e){return e[0].map(function(t,n){return e.map(function(e){return e[n]})})};function qb(e){return null==e}function Hb(e){"@babel/helpers - typeof";return Hb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hb(e)}var Wb=["schema"];function Zb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Kb(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zb(Object(n),!0).forEach(function(t){Xb(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zb(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xb(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Hb(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!==Hb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Hb(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yb(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Qb(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(t=e,t instanceof File||t instanceof Blob?t.arrayBuffer().then(bv):bv(t)).then(function(e){return function(e,t,n){var r=n.schema,i=Yb(n,Wb);if(i.map)throw new Error("`map` option was removed. Pass a `schema` option instead.");var s=_b(e,t,Kb(Kb({},i),{},{properties:r||i.properties}));return r?jb(s.data,r,Kb(Kb({},i),{},{properties:s.properties})):s}(e,zy,n)})}const Jb=({onParsed:t})=>{const[n,r]=e.useState(!1);return b(ql,{accept:".xlsx, .xls",loading:n,onFilesLoad:({files:e})=>{const n=e[0];r(!0),Qb(n).then(e=>{t(e)}).finally(()=>{r(!1)})},children:"Загрузить файлы excel"})},ex=({children:t,configOptions:n})=>{const[r,i]=e.useState(null),[s,o]=e.useState("");return e.useEffect(()=>(Uo.initialize({...n,onCheck:e=>{const{valid:t,reason:r}=e;o(r),i(t),n.onCheck?.(e)}}),()=>{Uo.deactivate()}),[n]),null===r?b(Ty,{color:"primary"}):r?b(e.Fragment,{children:t}):b(B,{color:"error",children:s})},tx=new class{#W;#j;#d;#Z;#K;#X;#Y;#Q;constructor(e={}){this.#W=e.queryCache||new Va,this.#j=e.mutationCache||new za,this.#d=e.defaultOptions||{},this.#Z=new Map,this.#K=new Map,this.#X=0}mount(){this.#X++,1===this.#X&&(this.#Y=pa.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#W.onFocus())}),this.#Q=ya.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#W.onOnline())}))}unmount(){this.#X--,0===this.#X&&(this.#Y?.(),this.#Y=void 0,this.#Q?.(),this.#Q=void 0)}isFetching(e){return this.#W.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#j.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#W.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#W.build(this,t),r=n.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ko(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#W.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=this.#W.get(r.queryHash),s=i?.state.data,o=function(e,t){return"function"==typeof e?e(t):e}(t,s);if(void 0!==o)return this.#W.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return _a.batch(()=>this.#W.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#W.get(t.queryHash)?.state}removeQueries(e){const t=this.#W;_a.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){const n=this.#W;return _a.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=_a.batch(()=>this.#W.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Ho).catch(Ho)}invalidateQueries(e,t={}){return _a.batch(()=>(this.#W.findAll(e).forEach(e=>{e.invalidate()}),"none"===e?.refetchType?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=_a.batch(()=>this.#W.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Ho)),"paused"===e.state.fetchStatus?Promise.resolve():t}));return Promise.all(r).then(Ho)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const n=this.#W.build(this,t);return n.isStaleByTime(Ko(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ho).catch(Ho)}fetchInfiniteQuery(e){return e.behavior=Na(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ho).catch(Ho)}ensureInfiniteQueryData(e){return e.behavior=Na(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ya.isOnline()?this.#j.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#W}getMutationCache(){return this.#j}getDefaultOptions(){return this.#d}setDefaultOptions(e){this.#d=e}setQueryDefaults(e,t){this.#Z.set(ea(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#Z.values()],n={};return t.forEach(t=>{ta(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#K.set(ea(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#K.values()],n={};return t.forEach(t=>{ta(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#d.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Jo(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ha&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#d.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#W.clear(),this.#j.clear()}},nx=e=>b(Ga,{...e,client:tx}),rx=({children:e,themeOptions:t})=>{const n=re(t);return b(ie,{theme:n,children:e})},ix=({children:e,configOptions:t,themeOptions:n})=>b(Jt,{children:b(nx,{children:b(Lo,{children:b(rx,{themeOptions:n,children:b(zl,{children:b(ex,{configOptions:t,children:e})})})})})}),sx=()=>{const{enqueueSnackbar:e}=c(De);return({variant:t,message:n})=>{e({variant:t,message:n,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:3e3,hideIconVariant:!0})}},ox=()=>{const e=sx();return t=>{const{response:n}=t;if(n){const{data:t}=n;if(t){const{detail:n}=t;n&&n.forEach(t=>{e({variant:"error",message:t})})}}}},ax=()=>Za({mutationKey:["logout-mutation"],mutationFn:async e=>await Uo.instance.apiService.post({url:"logout"}),onError:ox(),onSuccess:()=>{tx.invalidateQueries({queryKey:["user"]})}}),lx=()=>Za({mutationKey:["sign-in-mutation"],mutationFn:async({body:{username:e,password:t}})=>{const n=tn({username:e,password:en(t)});return await Uo.instance.apiService.post({url:"token",body:n,config:{headers:{"Content-Type":"application/x-www-form-urlencoded"}}})}}),ux=({children:e})=>b(T,{sx:{display:"flex",alignItems:"center",height:"100vh",width:"100vw",overflow:"hidden"},children:b(T,{sx:{margin:"auto",maxWidth:"400px",width:"100%"},children:b(Hl,{children:e})})}),cx=Yp().shape({username:zp().required(),password:zp().required()}),hx=({onSuccessSignIn:t})=>{const n=ax(),r=lx(),i=sx(),s=Oc({defaultValues:{username:"",password:""},resolver:Ig(cx)}),{register:o,formState:{isValid:a}}=s;return e.useEffect(()=>{n.mutate()},[]),e.useEffect(()=>{if(r.error){const{response:e}=r.error;if(e){const{data:{detail:t}}=e;i({message:t,variant:"error"})}}},[r.error]),e.useEffect(()=>{r.data&&t(r.data)},[r.data]),b(ux,{children:x(Ic,{form:s,onSubmit:e=>{r.mutate({body:e})},sx:{justifyContent:"center",justifyItems:"center",alignContent:"center",alignItems:"center"},children:[b(B,{variant:"h4",children:"Authorization"}),b(pf,{...o("username"),label:"Login",placeholder:"Enter your login"}),b(pf,{...o("password"),label:"Password",placeholder:"Enter your password",type:"password"}),b(jl,{type:"submit",disabled:!a,children:"Sign in"})]})})};var dx,fx,px={};function gx(e,t){if(dx)if(fx){var n="var shared_chunk = {}; ("+dx+")(shared_chunk); ("+fx+")(shared_chunk);",r={};dx(r),(px=t(r)).workerURL=window.URL.createObjectURL(new Blob([n],{type:"text/javascript"}))}else fx=t;else dx=t}gx(0,function(e){const t={};try{window instanceof Window&&window.document instanceof HTMLDocument&&(t.is_worker=!1,t.is_main=!0)}catch(e){t.is_worker=!0,t.is_main=!1,self.window={document:{}},self.document=self.window.document}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==n(t)?t:t+""}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s,o="v0.22.0",a=s={},l=0,u={};function c(e){var t=[];"string"==typeof e&&(t=e.split("."),e=t.pop());var n=s.targets;for(let e=0;e<t.length;e++){if(!n[t[e]])return[];n=n[t[e]]}return[e,n]}function h(e,t=null,n=null,r=[]){if(!e)return r;if(Array.isArray(e))e.forEach((t,n)=>h(t,e,n,r));else if("object"==typeof e)if(e instanceof ArrayBuffer)r.push({object:e,parent:t,property:n});else if(e.buffer instanceof ArrayBuffer)r.push({object:e.buffer,parent:t,property:n});else for(let t in e)h(e[t],e,t,r);return r}function d(e){Array.isArray(e)&&e.filter(e=>e.parent&&e.property).forEach(e=>delete e.parent[e.property])}s.targets={},s.addTarget=function(e,t){s.targets[e]=t},s.removeTarget=function(e){e&&delete s.targets[e]},s.withTransferables=function(...e){if(!(this instanceof s.withTransferables))return new s.withTransferables(...e);this.value=e,this.transferables=h(this.value)},t.is_main&&(s.postMessage=function(e,t,...n){if(Array.isArray(e))return Promise.all(e.map(e=>s.postMessage(e,t,...n)));let r={};"object"==typeof t&&(r=t,t=t.method);var i=new Promise((e,r)=>{u[l]={method:t,message:n,resolve:e,reject:r}});let o,a=[];return n&&1===n.length&&n[0]instanceof s.withTransferables&&(a=n[0].transferables,n=n[0].value),o={type:"main_send",message_id:l,method:t,message:n},r.stringify&&(o=JSON.stringify(o)),e.postMessage(o,a.map(e=>e.object)),d(a),a.length>0&&m("trace",`'${t}' transferred ${a.length} objects to worker thread`),l++,i},s.addWorker=function(e){if(!(e instanceof Worker))throw Error("Worker broker could not add non-Worker object",e);e.addEventListener("message",function(t){let n="string"==typeof t.data?JSON.parse(t.data):t.data,r=n.message_id;if("worker_reply"===n.type)u[r]&&(n.error?u[r].reject(n.error):u[r].resolve(n.message),delete u[r]);else if("worker_send"===n.type&&null!=r){let t,i,o,a,l;try{if([a,o]=c(n.method),!o)throw Error(`Worker broker could not dispatch message type ${n.method} on target ${n.target} because no object with that name is registered on main thread`);if(l="function"==typeof o[a]&&o[a],!l)throw Error(`Worker broker could not dispatch message type ${n.method} on target ${n.target} because object has no method with that name`);t=l.apply(o,n.message)}catch(e){i=e}let u,h=[];t instanceof Promise?t.then(t=>{t instanceof s.withTransferables&&(h=t.transferables,t=t.value[0]),u={type:"main_reply",message_id:r,message:t},e.postMessage(u,h.map(e=>e.object)),d(h),h.length>0&&m("trace",`'${a}' transferred ${h.length} objects to worker thread`)},t=>{e.postMessage({type:"main_reply",message_id:r,error:t instanceof Error?`${t.message}: ${t.stack}`:t})}):(t instanceof s.withTransferables&&(h=t.transferables,t=t.value[0]),u={type:"main_reply",message_id:r,message:t,error:i instanceof Error?`${i.message}: ${i.stack}`:i},e.postMessage(u,h.map(e=>e.object)),d(h),h.length>0&&m("trace",`'${a}' transferred ${h.length} objects to worker thread`))}})},s.getMessages=function(){return u},s.getMessageId=function(){return l}),t.is_worker&&(s.postMessage=function(e,...t){let n={};"object"==typeof e&&(n=e,e=e.method);var r=new Promise((n,r)=>{u[l]={method:e,message:t,resolve:n,reject:r}});let i,o=[];return t&&1===t.length&&t[0]instanceof s.withTransferables&&(o=t[0].transferables,t=t[0].value),i={type:"worker_send",message_id:l,method:e,message:t},n.stringify&&(i=JSON.stringify(i)),self.postMessage(i,o.map(e=>e.object)),d(o),o.length>0&&m("trace",`'${e}' transferred ${o.length} objects to main thread`),l++,r},self.addEventListener("message",function(e){let t="string"==typeof e.data?JSON.parse(e.data):e.data,n=t.message_id;if("main_reply"===t.type)u[n]&&(t.error?u[n].reject(t.error):u[n].resolve(t.message),delete u[n]);else if("main_send"===t.type&&null!=n){let r,i,o,a,l;try{if([a,o]=c(t.method),!o)throw Error(`Worker broker could not dispatch message type ${t.method} on target ${t.target} because no object with that name is registered on main thread`);if(l="function"==typeof o[a]&&o[a],!l)throw Error(`Worker broker could not dispatch message type ${t.method} because worker has no method with that name`);r=l.apply(o,t.message)}catch(e){i=e}let u,h=[];r instanceof Promise?r.then(e=>{e instanceof s.withTransferables&&(h=e.transferables,e=e.value[0]),u={type:"worker_reply",message_id:n,message:e},self.postMessage(u,h.map(e=>e.object)),d(h),h.length>0&&m("trace",`'${a}' transferred ${h.length} objects to main thread`)},e=>{self.postMessage({type:"worker_reply",message_id:n,error:e instanceof Error?`${e.message}: ${e.stack}`:e})}):(r instanceof s.withTransferables&&(h=r.transferables,r=r.value[0]),u={type:"worker_reply",message_id:n,message:r,error:i instanceof Error?`${i.message}: ${i.stack}`:i},self.postMessage(u,h.map(e=>e.object)),d(h),h.length>0&&m("trace",`'${a}' transferred ${h.length} objects to main thread`))}}));const f={silent:-1,error:0,warn:1,info:2,debug:3,trace:4},p={};let g={};function m(e,...n){let r="object"==typeof e?e.level:e;if(f[r]<=f[m.level]){if(t.is_worker)return a.postMessage({method:"_logProxy",stringify:!0},e,...n);{if("object"==typeof e&&!0===e.once){if(g[JSON.stringify(n)])return Promise.resolve(!1);g[JSON.stringify(n)]=!0}let i=function(e){if(t.is_main)return p[e]=p[e]||(console[e]?console[e]:console.log).bind(console),p[e]}(r);n.length>1?i(`Tangram ${o} [${r}]: ${n[0]}`,...n.slice(1)):i(`Tangram ${o} [${r}]: ${n[0]}`)}return Promise.resolve(!0)}return Promise.resolve(!1)}m.level="info",m.workers=null,m.setLevel=function(e){m.level=e,t.is_main&&Array.isArray(m.workers)&&a.postMessage(m.workers,"_logSetLevelProxy",e)},t.is_main&&(m.setWorkers=function(e){m.workers=e},m.reset=function(){g={}}),a.addTarget("_logProxy",m),a.addTarget("_logSetLevelProxy",m.setLevel);const _={};let y;a.addTarget("Utils",_),_.isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},_.isMicrosoft=function(){return/(Trident\/7.0|Edge[ /](\d+[.\d]+))/i.test(navigator.userAgent)},_._requests={},_._proxy_requests={},_.io=function(e,n=6e4,r="text",i="GET",s={},o=null,l=!1){if(t.is_worker&&_.isMicrosoft())return m("debug","Proxying request for URL to worker",e),o&&(_._proxy_requests[o]=!0),a.postMessage("Utils.io",e,n,r,i,s,o,!0);var u=new XMLHttpRequest,c=new Promise((t,o)=>{if(u.open(i,e,!0),u.timeout=n,u.responseType=r,s&&"object"==typeof s)for(let e in s)u.setRequestHeader(e,s[e]);u.onload=()=>{200===u.status?["text","json"].indexOf(u.responseType)>-1?t({body:u.responseText,status:u.status}):t({body:u.response,status:u.status}):204===u.status?t({body:null,status:u.status}):o(Error("Request error with a status of "+u.statusText))},u.onerror=e=>{o(Error("There was a network error"+e.toString()))},u.ontimeout=e=>{o(Error("timeout "+e.toString()))},u.send()});return c=c.then(e=>(o&&delete _._requests[o],l?a.withTransferables(e):e)),o&&(_._requests[o]=u),c},_.cancelRequest=function(e){if(t.is_worker&&_._proxy_requests[e])return a.postMessage("Utils.cancelRequest",e);_._requests[e]?(m("trace",`Cancelling network request key '${e}'`),_._requests[e].abort(),delete _._requests[e]):m("trace",`Could not find network request key '${e}'`)},_.serializeWithFunctions=function(e){return"function"==typeof e?e.toString():JSON.stringify(e,function(e,t){return"function"==typeof t?t.toString():t})},_.use_high_density_display=!0,_.updateDevicePixelRatio=function(){let e=_.device_pixel_ratio;return _.device_pixel_ratio=_.use_high_density_display&&window.devicePixelRatio||1,_.device_pixel_ratio!==e},t.is_main&&_.updateDevicePixelRatio(),_.isPowerOf2=function(e){return!(e&e-1)},_.interpolate=function(e,t,n){if(!Array.isArray(t)||!Array.isArray(t[0]))return t;if(t.length<1)return t;var r,i,s,o,a;if(e<=t[0][0])o=t[0][1],"function"==typeof n&&(o=n(o));else if(e>=t[t.length-1][0])o=t[t.length-1][1],"function"==typeof n&&(o=n(o));else for(var l=0;l<t.length-1;l++)if(e>=t[l][0]&&e<t[l+1][0]){if(r=t[l][0],i=t[l+1][0],Array.isArray(t[l][1])){o=[];for(var u=0;u<t[l][1].length;u++)"function"==typeof n?(a=n(t[l][1][u]),s=n(t[l+1][1][u])-a,o[u]=s*(e-r)/(i-r)+a):(s=t[l+1][1][u]-t[l][1][u],o[u]=s*(e-r)/(i-r)+t[l][1][u])}else"function"==typeof n?(a=n(t[l][1]),o=(s=n(t[l+1][1])-a)*(e-r)/(i-r)+a):o=(s=t[l+1][1]-t[l][1])*(e-r)/(i-r)+t[l][1];break}return o},_.toCSSColor=function(e){if(null!=e)return 1===e[3]?`rgb(${e.slice(0,3).map(e=>Math.round(255*e)).join(", ")})`:`rgba(${e.map((e,t)=>t<3&&Math.round(255*e)||e).join(", ")})`};var v=y={draw_label_collision_boxes:!1,draw_label_texture_boxes:!1,suppress_label_fade_in:!1,suppress_label_snap_animation:!1,show_hidden_labels:!1,layer_stats:!1,wireframe:!1};function b(e){if("string"==typeof e&&-1===e.search(/^(data|blob):/)){let t=e.indexOf("?");t>-1&&(e=e.substr(0,t));let n=e.indexOf("#");return n>-1&&(e=e.substr(0,n)),e.substr(0,e.lastIndexOf("/")+1)||""}return""}function x(e){if("string"==typeof e)return!(e.search(/^(http|https|data|blob):/)>-1||"//"===e.substr(0,2))}let w;function A(e,t){e=e.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null===n?"":decodeURIComponent(n[1].replace(/\+/g," "))}const E={id:0,queue:[],max_time:20,start_time:null,state:{},add(e){e.id=E.id++,e.max_time=e.max_time||E.max_time,e.pause_factor=e.pause_factor||1;let t=new Promise((t,n)=>{e.resolve=t,e.reject=n});return e.promise=t,e.elapsed=0,e.total_elapsed=0,e.stats={calls:0},this.queue.push(e),this.start_time=this.start_time||performance.now(),this.elapsed=performance.now()-this.start_time,(this.elapsed<E.max_time||e.immediate)&&this.process(e),e.promise},remove(e){let t=this.queue.indexOf(e);t>-1&&this.queue.splice(t,1)},process(e){if(!this.state.user_moving_view||!1!==e.user_moving_view)return e.pause?(e.pause--,!0):(e.stats.calls++,e.start_time=performance.now(),e.run(e))},processAll(){this.start_time=this.start_time||performance.now();for(let e=0;e<this.queue.length;e++){let t=this.queue[e];if(!0!==this.process(t)&&(t.pause||(t.pause=t.elapsed>t.max_time?t.pause_factor:0),t.total_elapsed+=t.elapsed),this.elapsed=performance.now()-this.start_time,this.elapsed>=E.max_time){this.start_time=null;break}}},finish(e,t){return e.elapsed=performance.now()-e.start_time,e.total_elapsed+=e.elapsed,this.remove(e),e.resolve(t),e.promise},cancel(e){let t;e.cancel instanceof Function&&(t=e.cancel(e)),e.resolve(t)},shouldContinue(e){return e.elapsed=performance.now()-e.start_time,this.elapsed=performance.now()-this.start_time,e.elapsed<e.max_time&&this.elapsed<E.max_time},removeForTile(e){for(let t=this.queue.length-1;t>=0;t--)this.queue[t].tile_id===e&&(this.cancel(this.queue[t]),this.queue.splice(t,1))},setState(e){this.state=e}};function S(e){let t=[];return Object.assign(e,{subscribe(e){-1===t.indexOf(e)&&t.push(e)},unsubscribe(e){let n=t.indexOf(e);n>-1&&t.splice(n,1)},unsubscribeAll(){t=[]},trigger(e,...n){t.forEach(t=>{if("function"==typeof t[e])try{t[e](...n)}catch(t){m("warn",`Caught exception in listener for event '${e}':`,t)}})},hasSubscribersFor(e){let n=!1;return t.forEach(t=>{"function"==typeof t[e]&&(n=!0)}),n}})}function T(e,t){let n={};return t.forEach(t=>n[t]=e[t]),n}class k{constructor(e,t,n={}){n=k.sliceOptions(n),this.gl=e,this.texture=e.createTexture(),this.texture&&(this.valid=!0),this.bind(),this.name=t,this.retain_count=0,this.config_type=null,this.loading=null,this.loaded=!1,this.filtering=n.filtering,this.density=n.density||1,this.sprites=n.sprites,this.texcoords={},this.sizes={},this.css_sizes={},this.aspects={},this.setData(1,1,new Uint8Array([0,0,0,0]),{filtering:"nearest"}),this.loaded=!1,k.textures[this.name]&&(this.retain_count=k.textures[this.name].retain_count,k.textures[this.name].retain_count=0,k.textures[this.name].destroy()),k.textures[this.name]=this,k.texture_configs[this.name]=JSON.stringify(Object.assign({name:t},n)),this.load(n),m("trace",`creating Texture ${this.name}`)}destroy({force:e}={}){this.retain_count>0&&!e?m("error",`Texture '${this.name}': destroying texture with retain count of '${this.retain_count}'`):this.valid&&(this.gl.deleteTexture(this.texture),this.texture=null,k.textures[this.name]===this&&(delete k.textures[this.name],delete k.texture_configs[this.name]),this.valid=!1,m("trace",`destroying Texture ${this.name}`))}retain(){this.retain_count++}release(){this.retain_count<=0&&m("error",`Texture '${this.name}': releasing texture with retain count of '${this.retain_count}'`),this.retain_count--,this.retain_count<=0&&this.destroy()}bind(e=0){this.valid&&(k.activeUnit!==e&&(this.gl.activeTexture(this.gl.TEXTURE0+e),k.activeUnit=e,k.boundTexture=null),k.boundTexture!==this.texture&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),k.boundTexture=this.texture))}load(e){return e?(this.loading=null,"string"==typeof e.url?(this.config_type="url",this.setUrl(e.url,e)):e.element?(this.config_type="element",this.setElement(e.element,e)):e.data&&e.width&&e.height&&(this.config_type="data",this.setData(e.width,e.height,e.data,e)),this.loading=this.loading&&this.loading.then(()=>(this.calculateSprites(),this))||Promise.resolve(this),this.loading):this.loading||Promise.resolve(this)}setUrl(e,t={}){if(this.valid)return this.url=e,this.loading=new Promise(e=>{let n=new Image;n.onload=()=>{try{if("data:"===this.url.slice(0,5)){const e=document.createElement("canvas"),r=e.getContext("2d");e.width=n.width,e.height=n.height,r.drawImage(n,0,0),this.setElement(e,t)}else this.setElement(n,t)}catch(e){this.loaded=!1,m("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,e,t),k.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:e,texture:t})}this.loaded=!0,e(this)},n.onerror=n=>{this.loaded=!1,m("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,n,t),k.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:n,texture:t}),e(this)},_.isSafari()&&"data:"===this.url.slice(0,5)||(n.crossOrigin="anonymous"),n.src=this.url}),this.loading}setData(e,t,n,r={}){return this.width=e,this.height=t,Array.isArray(n)&&(n=new Uint8Array(n)),this.update(n,r),this.setFiltering(r),this.loaded=!0,this.loading=Promise.resolve(this),this.loading}setElement(e,t){let n=e;if("string"==typeof e&&(e=document.querySelector(e)),e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement)this.update(e,t),this.setFiltering(t);else{this.loaded=!1;let e=`the 'element' parameter (\`element: ${JSON.stringify(n)}\`) must be a CSS `;e+="selector string, or a <canvas>, <image> or <video> object",m("warn",`Texture '${this.name}': ${e}`,t),k.trigger("warning",{message:`Failed to load texture because ${e}`,texture:t})}return this.loaded=!0,this.loading=Promise.resolve(this),this.loading}update(e,t={}){this.valid&&(this.bind(),e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLImageElement&&e.complete?(this.width=e.width,this.height=e.height,this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1!==t.UNPACK_FLIP_Y_WEBGL),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.UNPACK_PREMULTIPLY_ALPHA_WEBGL||!1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e)):(this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,null),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,null),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.width,this.height,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e)),k.trigger("update",this))}setFiltering(e={}){if(this.valid){e.filtering=e.filtering||"linear";var t=this.gl;this.bind(),_.isPowerOf2(this.width)&&_.isPowerOf2(this.height)?(this.power_of_2=!0,t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,e.TEXTURE_WRAP_S||e.repeat&&t.REPEAT||t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,e.TEXTURE_WRAP_T||e.repeat&&t.REPEAT||t.CLAMP_TO_EDGE),"mipmap"===e.filtering?(this.filtering="mipmap",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.generateMipmap(t.TEXTURE_2D)):"linear"===e.filtering?(this.filtering="linear",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)):"nearest"===e.filtering&&(this.filtering="nearest",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST))):(this.power_of_2=!1,t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),"nearest"===e.filtering?(this.filtering="nearest",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)):(this.filtering="linear",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR))),k.trigger("update",this)}}calculateSprites(){if(this.sprites)for(let e in this.sprites){let t=this.sprites[e];this.texcoords[e]=k.getTexcoordsForSprite([t[0],t[1]],[t[2],t[3]],[this.width,this.height]),this.sizes[e]=[t[2],t[3]],this.css_sizes[e]=[t[2]/this.density,t[3]/this.density],this.aspects[e]=t[2]/t[3]}}byteSize(){return Math.round(this.width*this.height*4*("mipmap"==this.filtering?1.33:1))}}k.create=function(e,t,n){return new k(e,t,n)},k.retain=function(e){k.textures[e]&&k.textures[e].retain()},k.release=function(e){k.textures[e]&&k.textures[e].release()},k.destroy=function(e){Object.keys(k.textures).forEach(t=>{var n=k.textures[t];n.gl===e&&n.destroy({force:!0})})},k.getSpriteInfo=function(e,t){let n=k.textures[e];return n&&{size:n.sizes[t],css_size:n.css_sizes[t],aspect:n.aspects[t],texcoords:n.texcoords[t]}},k.getTexcoordsForSprite=function(e,t,n){var r=n[1]-e[1]-t[1];return[e[0]/n[0],r/n[1],(t[0]+e[0])/n[0],(t[1]+r)/n[1]]},k.createFromObject=function(e,t){let n=[];if(t)for(let r in t){let i=t[r];if(i.skip_create)continue;if(!k.changed(r,i))continue;let s=k.create(e,r,i);n.push(s.loading)}return Promise.all(n)},k.default="__default",k.createDefault=function(e){return k.create(e,k.default)},k.sliceOptions=function(e){return{filtering:e.filtering,sprites:e.sprites,url:e.url,element:e.element,data:e.data,width:e.width,height:e.height,density:e.density,repeat:e.repeat,TEXTURE_WRAP_S:e.TEXTURE_WRAP_S,TEXTURE_WRAP_T:e.TEXTURE_WRAP_T,UNPACK_FLIP_Y_WEBGL:e.UNPACK_FLIP_Y_WEBGL,UNPACK_PREMULTIPLY_ALPHA_WEBGL:e.UNPACK_PREMULTIPLY_ALPHA_WEBGL}},k.changed=function(e,t){let n=k.textures[e];if(n){if("element"===n.config_type||null!=t.element)return!0;if(t=k.sliceOptions(t),k.texture_configs[e]===JSON.stringify(Object.assign({name:e},t)))return!1}return!0},k.getInfo=function(e){if(e||(e=Object.keys(k.textures)),Array.isArray(e))return Promise.all(e.map(e=>k.getInfo(e)));var t=k.textures[e];return t?(t.loading||Promise.resolve(t)).then(()=>({name:t.name,width:t.width,height:t.height,density:t.density,css_size:[t.width/t.density,t.height/t.density],aspect:t.width/t.height,sprites:t.sprites,texcoords:t.texcoords,sizes:t.sizes,css_sizes:t.css_sizes,aspects:t.aspects,filtering:t.filtering,power_of_2:t.power_of_2,valid:t.valid})):Promise.resolve(null)},k.syncTexturesToWorker=function(e){return a.postMessage("Texture.getInfo",e).then(e=>(e&&e.filter(e=>e).forEach(e=>k.textures[e.name]=e),k.textures))},k.getMaxTextureSize=function(e){return e.getParameter(e.MAX_TEXTURE_SIZE)},k.textures={},k.texture_configs={},k.boundTexture=null,k.activeUnit=null,a.addTarget("Texture",k),S(k);var O={parseUniforms:function(e={}){var t=[];for(const[n,r]of Object.entries(e))if("number"==typeof r)t.push({type:"float",method:"1f",name:n,value:r,path:[n]});else if(Array.isArray(r)){if("number"==typeof r[0])r.length>=2&&r.length<=4?t.push({type:"vec"+r.length,method:r.length+"fv",name:n,value:r,path:[n]}):r.length>4&&t.push({type:"float[]",method:"1fv",name:n+"[0]",value:r,path:[n]});else if("string"==typeof r[0])for(let e=0;e<r.length;e++)t.push({type:"sampler2D",method:"1i",name:n+"["+e+"]",value:r[e],path:[n,e]});else if(Array.isArray(r[0])&&"number"==typeof r[0][0]&&r[0].length>=2&&r[0].length<=4)for(let e=0;e<r.length;e++)t.push({type:"vec"+r[0].length,method:r[0].length+"fv",name:n+"["+e+"]",value:r[e],path:[n,e]})}else"boolean"==typeof r?t.push({type:"bool",method:"1i",name:n,value:r,path:[n]}):"string"==typeof r&&t.push({type:"sampler2D",method:"1i",name:n,value:r,path:[n]});return t},defineVariable:function(e,t){var n,r;if("number"==typeof t)n="float";else if(Array.isArray(t))"number"==typeof t[0]?t.length>=2&&t.length<=4?n="vec"+t.length:(n="float",r=t.length):"string"==typeof t[0]?(n="sampler2D",r=t.length):Array.isArray(t[0])&&"number"==typeof t[0][0]&&t[0].length>=2&&t[0].length<=4&&(n="vec"+t[0].length,r=t.length);else if("boolean"==typeof t)n="bool";else{if("string"!=typeof t)return;n="sampler2D"}var i="";return i+=`${n} ${e}`,r&&(i+=`[${r}]`),i+";\n"},defineUniform:function(e,t){var n=O.defineVariable(e,t);if(n)return"uniform "+n},expandVec3:function(e,t=1){let n;if(Array.isArray(e)){if(2!==e.length)return e;n=[...e,t].map(parseFloat)}else n=[e,e,e].map(parseFloat);if(n&&n.every(e=>"number"==typeof e&&!isNaN(e)))return n},expandVec4:function(e,t=1){let n;if(Array.isArray(e)){if(3!==e.length)return e;n=[...e,t].map(parseFloat)}else n=[e,e,e,t].map(parseFloat);if(n&&n.every(e=>"number"==typeof e&&!isNaN(e)))return n}};let R=[];function C(e,t){let n=R.filter(t=>t[0]===e)[0];return n=n&&n[1],n||(R.push([e,{}]),n=R[R.length-1][1]),n[t]||(n[t]=e.getExtension(t)),n[t]}function P(e){var t,n,r=0;if(0===e.length)return r;for(t=0,n=e.length;t<n;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return r}function M(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var N,I,D=(I||(I=1,N=function(e){e=String(e);for(var t,n=[];t=e.match(/ERROR\:([^\n]+)/);){e=e.slice(t.index+1);var r=(o=t[1].trim()).split(":"),i=r.slice(2).join(":").trim(),s=parseInt(r[0],10),o=parseInt(r[1],10);n.push({message:i,file:s,line:o})}return n}),N),F=M(D);const z=/^\s*#pragma.*$/gm,L=/\\\s*\n/gm;class j{constructor(e,t,n,r){r=r||{},this.gl=e,this.program=null,this.compiled=!1,this.compiling=!1,this.error=null,this.defines=Object.assign({},r.defines||{}),this.blocks=Object.assign({},r.blocks||{}),this.block_scopes=Object.assign({},r.block_scopes||{}),this.extensions=r.extensions||[],this.dependent_uniforms=r.uniforms,this.uniforms={},this.attribs={},this.vertex_source=t,this.fragment_source=n,this.id=j.id++,this.name=r.name}destroy(){this.gl.useProgram(null),this.gl.deleteProgram(this.program),this.program=null,this.uniforms={},this.attribs={},this.compiled=!1}use(){this.compiled&&(j.current!==this&&this.gl.useProgram(this.program),j.current=this)}compile(){if(this.compiling)throw new Error(`ShaderProgram.compile(): skipping for ${this.id} (${this.name}) because already compiling`);this.compiling=!0,this.compiled=!1,this.error=null,this.computed_vertex_source=this.vertex_source,this.computed_fragment_source=this.fragment_source;let e=this.checkExtensions();var t,n=this.buildDefineList(),r=this.buildShaderBlockList();for(var i in r){var s=r[i];if(s&&(!Array.isArray(s)||0!==s.length)){t=new RegExp("^\\s*#pragma\\s+tangram:\\s+"+i+"\\s*$","m");var o=this.computed_vertex_source.match(t),a=this.computed_fragment_source.match(t);if(null!=o||null!=a){var l="";s.forEach(e=>{let t=`${e.scope}, ${e.key}, ${e.num}`;l+=`\n// tangram-block-start: ${t}\n`,l+=e.source,l+=`\n// tangram-block-end: ${t}\n`}),null!=o&&(this.computed_vertex_source=this.computed_vertex_source.replace(t,l)),null!=a&&(this.computed_fragment_source=this.computed_fragment_source.replace(t,l)),n["TANGRAM_BLOCK_"+i.replace(/[\s-]+/g,"_").toUpperCase()]=!0}}}this.computed_vertex_source=this.computed_vertex_source.replace(z,""),this.computed_fragment_source=this.computed_fragment_source.replace(z,""),this.ensureUniforms(this.dependent_uniforms);let u="",c=this.gl.getShaderPrecisionFormat(this.gl.FRAGMENT_SHADER,this.gl.HIGH_FLOAT);u=c&&c.precision>0?"precision highp float;\n":"precision mediump float;\n",n.TANGRAM_VERTEX_SHADER=!0,n.TANGRAM_FRAGMENT_SHADER=!1,this.computed_vertex_source=u+j.buildDefineString(n)+this.computed_vertex_source,n.TANGRAM_VERTEX_SHADER=!1,n.TANGRAM_FRAGMENT_SHADER=!0,this.computed_fragment_source=j.buildExtensionString(e)+u+j.buildDefineString(n)+this.computed_fragment_source,this.computed_vertex_source=this.computed_vertex_source.replace(L,""),this.computed_fragment_source=this.computed_fragment_source.replace(L,"");try{this.program=j.updateProgram(this.gl,this.program,this.computed_vertex_source,this.computed_fragment_source),this.compiled=!0,this.compiling=!1}catch(e){throw this.program=null,this.compiled=!1,this.compiling=!1,this.error=e,this.error.vertex_shader_source=this.computed_vertex_source,this.error.fragment_shader_source=this.computed_fragment_source,"vertex"!==e.type&&"fragment"!==e.type||(this.shader_errors=e.errors,this.shader_errors.forEach(t=>{t.type=e.type,t.block=this.block(e.type,t.line),t.line=this.block(e.type,t.line)}),this.error.shader_errors=this.shader_errors),e}this.computed_vertex_source=null,this.computed_fragment_source=null,this.use(),this.refreshUniforms(),this.refreshAttributes()}buildDefineList(){var e,t={};for(e in j.defines)t[e]=j.defines[e];for(e in this.defines)t[e]=this.defines[e];return t}buildShaderBlockList(){let e,t={};for(e in j.blocks)t[e]=[],Array.isArray(j.blocks[e])?t[e].push(...j.blocks[e].map((t,n)=>({key:e,source:t,num:n,scope:"ShaderProgram"}))):t[e]=[{key:e,source:j.blocks[e],num:0,scope:"ShaderProgram"}];for(e in this.blocks)if(t[e]=t[e]||[],Array.isArray(this.blocks[e])){let n=this.block_scopes&&this.block_scopes[e]||[],r=null,i=0;for(let s=0;s<this.blocks[e].length;s++)n[s]!==r&&(r=n[s],i=0),t[e].push({key:e,source:this.blocks[e][s],num:i,scope:r||this.name}),i++}else t[e].push({key:e,source:this.blocks[e],num:0,scope:this.name});return t}ensureUniforms(e){if(!e)return;const t=Object.entries(e).map(([e,t])=>O.defineUniform(e,t)).filter(e=>e);this.computed_vertex_source=t.join("\n")+this.computed_vertex_source,this.computed_fragment_source=t.join("\n")+this.computed_fragment_source}setUniforms(e,t=!0){this.compiled&&(t&&(this.texture_unit=0),O.parseUniforms(e).forEach(({name:e,type:t,value:n,method:r})=>{"sampler2D"===t?this.setTextureUniform(e,n):this.uniform(r,e,n)}))}saveUniforms(e){let t=e||this.uniforms;for(let e in t){let t=this.uniforms[e];t&&(t.saved_value=t.value)}this.saved_texture_unit=this.texture_unit||0}restoreUniforms(e){let t=e||this.uniforms;for(let e in t){let t=this.uniforms[e];t&&t.saved_value&&(t.value=t.saved_value,this.updateUniform(t))}this.texture_unit=this.saved_texture_unit||0}setTextureUniform(e,t){var n=k.textures[t];null!=n?(n.bind(this.texture_unit),this.uniform("1i",e,this.texture_unit),this.texture_unit++):m("warn",`Cannot find texture '${t}'`)}uniform(e,t,n){if(!this.compiled)return;this.uniforms[t]=this.uniforms[t]||{};let r=this.uniforms[t];r.name=t,void 0===r.location&&(r.location=this.gl.getUniformLocation(this.program,t)),r.method=e,r.value=n,this.updateUniform(r)}updateUniform(e){this.compiled&&e&&null!=e.location&&(this.use(),this.commitUniform(e))}commitUniform(e){let t=e.location,n=e.value;switch(e.method){case"1i":this.gl.uniform1i(t,n);break;case"1f":this.gl.uniform1f(t,n);break;case"2f":this.gl.uniform2f(t,n[0],n[1]);break;case"3f":this.gl.uniform3f(t,n[0],n[1],n[2]);break;case"4f":this.gl.uniform4f(t,n[0],n[1],n[2],n[3]);break;case"1iv":this.gl.uniform1iv(t,n);break;case"3iv":this.gl.uniform3iv(t,n);break;case"1fv":this.gl.uniform1fv(t,n);break;case"2fv":this.gl.uniform2fv(t,n);break;case"3fv":this.gl.uniform3fv(t,n);break;case"4fv":this.gl.uniform4fv(t,n);break;case"Matrix3fv":this.gl.uniformMatrix3fv(t,!1,n);break;case"Matrix4fv":this.gl.uniformMatrix4fv(t,!1,n)}}refreshUniforms(){if(this.compiled)for(var e in this.uniforms){let t=this.uniforms[e];t.location=this.gl.getUniformLocation(this.program,e),this.updateUniform(t)}}refreshAttributes(){this.attribs={}}attribute(e){if(this.compiled){var t=this.attribs[e]=this.attribs[e]||{};return null!=t.location||(t.name=e,t.location=this.gl.getAttribLocation(this.program,e)),t}}source(e){return"vertex"===e?this.computed_vertex_source:"fragment"===e?this.computed_fragment_source:void 0}lines(e){let t=this.source(e);return t?t.split("\n"):[]}line(e,t){let n=this.lines(e);if(n)return n[t]}block(e,t){let n,r=this.lines(e);for(let e=0;e<t&&e<r.length;e++){let t=r[e],i=t.match(/\/\/ tangram-block-start: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/);i&&i.length>1?n={scope:i[1],name:i[2],num:i[3]}:(i=t.match(/\/\/ tangram-block-end: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/),i&&i.length>1&&(n=null)),n&&(n.line=null==n.line?-1:n.line+1,n.source=t)}return n}checkExtensions(){let e=[];return this.extensions.forEach(t=>{let n=C(this.gl,t),r=`TANGRAM_EXTENSION_${t}`;this.defines[r]=null!=n,n?e.push(t):m("debug",`Could not enable extension '${t}'`)}),e}}j.id=0,j.current=null,j.defines={},j.blocks={},j.reset=function(){j.programs_by_source={},j.shaders_by_source={}},j.reset(),j.buildDefineString=function(e){var t="";for(var n in e)null!=e[n]&&!1!==e[n]&&("boolean"==typeof e[n]&&!0===e[n]?t+="#define "+n+"\n":"number"==typeof e[n]&&Math.floor(e[n])===e[n]?t+="#define "+n+" "+e[n].toFixed(1)+"\n":t+="#define "+n+" "+e[n]+"\n");return t},j.buildExtensionString=function(e){let t="";return(e=e||[]).forEach(e=>{t+=`#ifdef GL_${e}\n#extension GL_${e} : enable\n#endif\n`}),t},j.addBlock=function(e,...t){j.blocks[e]=j.blocks[e]||[],j.blocks[e].push(...t)},j.removeBlock=function(e){j.blocks[e]=[]},j.replaceBlock=function(e,...t){j.removeBlock(e),j.addBlock(e,...t)},j.updateProgram=function(e,t,n,r){let i=P(e._tangram_id+"::"+n+"::"+r);if(j.programs_by_source[i])return m("trace","Reusing identical source GL program object"),j.programs_by_source[i];var s=j.createShader(e,n,e.VERTEX_SHADER),o=j.createShader(e,r,e.FRAGMENT_SHADER);if(e.useProgram(null),null!=t)for(var a=e.getAttachedShaders(t),l=0;l<a.length;l++)e.detachShader(t,a[l]);else t=e.createProgram();if(null==s||null==o)return t;if(e.attachShader(t,s),e.attachShader(t,o),e.bindAttribLocation(t,0,"a_position"),e.linkProgram(t),!e.getProgramParameter(t,e.LINK_STATUS)){let i=new Error(`WebGL program error:\n VALIDATE_STATUS: ${e.getProgramParameter(t,e.VALIDATE_STATUS)}\n ERROR: ${e.getError()}\n --- Vertex Shader ---\n ${n}\n --- Fragment Shader ---\n ${r}`);throw Object.assign(new Error(i),{type:"program"})}return j.programs_by_source[i]=t,t},j.createShader=function(e,t,n){let r=P(e._tangram_id+"::"+t);if(j.shaders_by_source[r])return m("trace","Reusing identical source GL shader object"),j.shaders_by_source[r];let i=e.createShader(n);if(e.shaderSource(i,t),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)){let t=n===e.VERTEX_SHADER?"vertex":"fragment",r=e.getShaderInfoLog(i),s=F(r);throw Object.assign(new Error(r),{type:t,errors:s})}return j.shaders_by_source[r]=i,i};var V,U={disabled:!1,bound_vao:[],init(e){let t;!0!==this.disabled&&(t=C(e,"OES_vertex_array_object")),null!=t?m("info","Vertex Array Object extension available"):!0!==this.disabled?m("warn","Vertex Array Object extension NOT available"):m("warn","Vertex Array Object extension force disabled")},getExtension(e,t){if(!0!==this.disabled)return C(e,t)},create(e,t,n){let r={};r.setup=t,r.teardown=n;let i=this.getExtension(e,"OES_vertex_array_object");return null!=i&&(r._vao=i.createVertexArrayOES(),i.bindVertexArrayOES(r._vao)),r.setup(),r},getCurrentBinding(e){let t=this.bound_vao.filter(t=>t[0]===e)[0];return t&&t[1]},setCurrentBinding(e,t){let n=this.bound_vao,r=n.filter(t=>t[0]===e)[0];null==r?n.push([e,t]):r[1]=t},bind(e,t){let n=this.getExtension(e,"OES_vertex_array_object");if(null!=t)null!=n&&null!=t._vao?(n.bindVertexArrayOES(t._vao),this.setCurrentBinding(e,t)):t.setup();else{let t=this.getCurrentBinding(e);null!=n?n.bindVertexArrayOES(null):null!=t&&"function"==typeof t.teardown&&t.teardown(),this.setCurrentBinding(e,null)}},destroy(e,t){let n=this.getExtension(e,"OES_vertex_array_object");null!=n&&null!=t&&null!=t._vao&&(n.deleteVertexArrayOES(t._vao),t._vao=null)}};function B(e,...t){for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let t in r){let n=r[t];null===n||"object"!=typeof n||Array.isArray(n)?void 0!==n&&(e[t]=n):null===e[t]||"object"!=typeof e[t]||Array.isArray(e[t])?e[t]=B({},n):e[t]=B(e[t],n)}}return e}var G=V={};V.default_source_max_zoom=18,V.default_view_max_zoom=20,V.max_style_zoom=25,V.tile_size=256,V.half_circumference_meters=20037508.342789244,V.circumference_meters=2*V.half_circumference_meters,V.min_zoom_meters_per_pixel=V.circumference_meters/V.tile_size;let $=[];V.metersPerPixel=function(e){return $[e]=$[e]||V.min_zoom_meters_per_pixel/Math.pow(2,e),$[e]};let q=[];V.metersPerTile=function(e){return q[e]=q[e]||V.circumference_meters/Math.pow(2,e),q[e]},V.tile_scale=4096,V.units_per_pixel=V.tile_scale/V.tile_size,V.height_scale=16;let H=[];V.unitsPerMeter=function(e){return H[e]=H[e]||V.tile_scale/(V.tile_size*V.metersPerPixel(e)),H[e]},V.metersForTile=function(e){return{x:e.x*V.circumference_meters/Math.pow(2,e.z)-V.half_circumference_meters,y:-(e.y*V.circumference_meters/Math.pow(2,e.z)-V.half_circumference_meters)}},V.tileForMeters=function([e,t],n){return{x:Math.floor((e+V.half_circumference_meters)/(V.circumference_meters/Math.pow(2,n))),y:Math.floor((-t+V.half_circumference_meters)/(V.circumference_meters/Math.pow(2,n))),z:n}},V.wrapTile=function({x:e,y:t,z:n},r={x:!0,y:!1}){var i=(1<<n)-1;return r.x&&(e&=i),r.y&&(t&=i),{x:e,y:t,z:n}},V.metersToLatLng=function(e){return e[0]/=V.half_circumference_meters,e[1]/=V.half_circumference_meters,e[1]=(2*Math.atan(Math.exp(e[1]*Math.PI))-Math.PI/2)/Math.PI,e[0]*=180,e[1]*=180,e},V.latLngToMeters=function(e){return e[1]=Math.log(Math.tan(e[1]*Math.PI/360+Math.PI/4))/Math.PI,e[1]*=V.half_circumference_meters,e[0]*=V.half_circumference_meters/180,e},V.tileSpaceToLatlng=function(e,t,n){const r=V.unitsPerMeter(t);return V.transformGeometry(e,e=>{e[0]=e[0]/r+n.x,e[1]=e[1]/r+n.y,V.metersToLatLng(e)}),e},V.copyGeometry=function(e){if(null==e)return;let t={type:e.type};return"Point"===e.type?t.coordinates=[e.coordinates[0],e.coordinates[1]]:"LineString"===e.type||"MultiPoint"===e.type?t.coordinates=e.coordinates.map(e=>[e[0],e[1]]):"Polygon"===e.type||"MultiLineString"===e.type?t.coordinates=e.coordinates.map(e=>e.map(e=>[e[0],e[1]])):"MultiPolygon"===e.type&&(t.coordinates=e.coordinates.map(e=>e.map(e=>e.map(e=>[e[0],e[1]])))),t},V.transformGeometry=function(e,t){null!=e&&("Point"===e.type?t(e.coordinates):"LineString"===e.type||"MultiPoint"===e.type?e.coordinates.forEach(t):"Polygon"===e.type||"MultiLineString"===e.type?e.coordinates.forEach(e=>e.forEach(t)):"MultiPolygon"===e.type&&e.coordinates.forEach(e=>{e.forEach(e=>e.forEach(t))}))},V.boxIntersect=function(e,t){return!(t.sw.x>e.ne.x||t.ne.x<e.sw.x||t.sw.y>e.ne.y||t.ne.y<e.sw.y)},V.findBoundingBox=function(e){for(var t=1/0,n=-1/0,r=1/0,i=-1/0,s=e[0].length,o=0;o<s;o++){var a=e[0][o];a[0]<t&&(t=a[0]),a[1]<r&&(r=a[1]),a[0]>n&&(n=a[0]),a[1]>i&&(i=a[1])}return[t,r,n,i]},V.geometryType=function(e){return"Polygon"===e||"MultiPolygon"===e?"polygon":"LineString"===e||"MultiLineString"===e?"line":"Point"===e||"MultiPoint"===e?"point":void 0},V.centroid=function(e,t=!0){if(!e||0===e.length)return;let n,r=0,i=0,s=0,o=e[0],a=o.length;t&&(n=o[0],o=o.map(e=>[e[0]-n[0],e[1]-n[1]]));for(let e=0,t=a-1;e<a;t=e,e++){let n=o[e],a=o[t],l=n[1]*a[0]-a[1]*n[0];r+=(n[0]+a[0])*l,i+=(n[1]+a[1])*l,s+=3*l}if(!s)return;let l=[r/s,i/s];return t&&(l[0]+=n[0],l[1]+=n[1]),l},V.multiCentroid=function(e){let t=0,n=null;for(let r=0;r<e.length;r++){let i=V.centroid(e[r]);i&&(n=n||[0,0],n[0]+=i[0],n[1]+=i[1],t++)}return t>0&&(n[0]/=t,n[1]/=t),n},V.signedPolygonRingAreaSum=function(e){let t=0,n=e.length;for(let r=0;r<n-1;r++){let n=e[r],i=e[r+1];t+=n[0]*i[1]-i[0]*n[1]}return t+=e[n-1][0]*e[0][1]-e[0][0]*e[n-1][1],t},V.polygonRingArea=function(e){return Math.abs(V.signedPolygonRingAreaSum(e))/2},V.polygonArea=function(e){if(e)return V.polygonRingArea(e[0])},V.multiPolygonArea=function(e){let t=0;for(let n=0;n<e.length;n++)t+=V.polygonArea(e[n]);return t},V.ringWinding=function(e){let t=V.signedPolygonRingAreaSum(e);return t>0?"CW":t<0?"CCW":void 0};const W={functions:{},num_functions:0,num_cached:0};function Z(e,t){if("string"==typeof e)e=K(e,t);else if(null!=e&&"object"==typeof e)for(let n in e)e[n]=Z(e[n],t);return e}function K(e,t){let n="string"==typeof e&&e.match(/^\s*function[^(]*\(([^)]*)\)\s*?\{([\s\S]*)\}$/m);if(n&&n.length>2)try{const e=n[2],r="function"==typeof t?t(e):e,i=P(r);if(void 0===W.functions[i]){let t=n[1].length>0&&n[1].split(",").map(e=>e.trim()).filter(e=>e);t=t.length>0?t:["context"],W.functions[i]=new Function(t.toString(),r),W.functions[i].source=e,W.num_functions++}else W.num_cached++;return W.functions[i]}catch(t){return e}return e}var X,Y={},Q=M(function(){if(X)return Y;X=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return(e=Math.round(e))<0?0:e>255?255:e}function n(e){return e<0?0:e>1?1:e}function r(e){return"%"===e[e.length-1]?t(parseFloat(e)/100*255):t(parseInt(e))}function i(e){return"%"===e[e.length-1]?n(parseFloat(e)/100):n(parseFloat(e))}function s(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}try{Y.parseCSSColor=function(n){var o,a=n.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(o=parseInt(a.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===a.length&&(o=parseInt(a.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=a.indexOf("("),u=a.indexOf(")");if(-1!==l&&u+1===a.length){var c=a.substr(0,l),h=a.substr(l+1,u-(l+1)).split(","),d=1;switch(c){case"rgba":if(4!==h.length)return null;d=i(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),d];case"hsla":if(4!==h.length)return null;d=i(h.pop());case"hsl":if(3!==h.length)return null;var f=(parseFloat(h[0])%360+360)%360/360,p=i(h[1]),g=i(h[2]),m=g<=.5?g*(p+1):g+p-g*p,_=2*g-m;return[t(255*s(_,m,f+1/3)),t(255*s(_,m,f)),t(255*s(_,m,f-1/3)),d];default:return null}}return null}}catch(e){}return Y}());const J={},ee=e=>Math.max(e,0),te=e=>isNaN(e)?0:e,ne=e=>Array.isArray(e)?e.map(parseFloat).map(te):te(parseFloat(e)),re=e=>Array.isArray(e)?e.map(ne).map(ee):ee(ne(e));Object.assign(J,{clampPositive:ee,noNaN:te,parseNumber:ne,parsePositiveNumber:re}),J.wrapFunction=function(e){return`\n var feature = context.feature.properties;\n var global = context.global;\n var $zoom = context.zoom;\n var $layer = context.layer;\n var $source = context.source;\n var $geometry = context.geometry;\n var $meters_per_pixel = context.meters_per_pixel;\n var $id = context.id;\n\n var val = (function(){ ${e} }());\n\n if (typeof val === 'number' && isNaN(val)) {\n val = null; // convert NaNs to nulls\n }\n\n return val;\n `},J.zeroPair=Object.freeze([0,0]),J.defaults={color:[1,1,1,1],width:1,size:1,extrude:!1,height:20,min_height:0,order:0,z:0,outline:{color:[0,0,0,0],width:0},material:{ambient:1,diffuse:1}},J.macros={"Style.color.pseudoRandomColor":function(){return[parseInt(feature.id,16)/100%1*.7,parseInt(feature.id,16)/1e4%1*.7,parseInt(feature.id,16)/1e6%1*.7,1]},"Style.color.randomColor":function(){return[.7*Math.random(),.7*Math.random(),.7*Math.random(),1]}},J.getFeatureParseContext=function(e,t,n){return{feature:e,id:e.id,tile:t,global:n,zoom:t.style_z,geometry:G.geometryType(e.geometry.type),meters_per_pixel:t.meters_per_pixel,meters_per_pixel_sq:t.meters_per_pixel_sq,units_per_meter_overzoom:t.units_per_meter_overzoom}};const ie={STATIC:0,DYNAMIC:1,ZOOM:2};J.CACHE_TYPE=ie,J.createPropertyCache=function(e,t=null,n=null){if(null==e)return;if(e.value)return{value:e.value,zoom:e.zoom?{}:null,type:e.type};let r={value:e,type:ie.STATIC};return Array.isArray(r.value)&&Array.isArray(r.value[0])?(r.zoom={},r.type=ie.ZOOM):"function"==typeof r.value&&(r.type=ie.DYNAMIC,r.dynamic_transform="function"==typeof n?n:null),"function"==typeof t&&(r.zoom?r.value=r.value.map((e,n)=>[e[0],t(e[1],n)]):"function"!=typeof r.value&&(r.value=t(r.value,0))),r},J.createColorPropertyCache=function(e){return J.createPropertyCache(e,e=>"Style.color.pseudoRandomColor"===e?K(J.wrapFunction(J.macros["Style.color.pseudoRandomColor"])):"Style.color.randomColor"===e?J.macros["Style.color.randomColor"]:e)};const se=e=>"string"==typeof e&&"%"===e[e.length-1],oe=e=>"auto"===e,ae=e=>se(e)||oe(e),le="'size' can specify either width or height as derived from aspect ratio, but not both";function ue(e,t){return J.createPropertyCache(e.value,(n,r)=>(Array.isArray(n)?(n=n.map((t,n)=>e.has_ratio[r][n]?t:re(t)).map((n,i)=>e.has_pct[r][i]?t.css_size[i]*n/100:n),e.has_ratio[r][0]?n[0]=n[1]*t.aspect:e.has_ratio[r][1]&&(n[1]=n[0]/t.aspect)):(n=re(n),n=e.has_pct[r]?t.css_size.map(e=>e*n/100):[n,n]),n))}function ce(e,t){try{return e(t)}catch(n){m("warn",`Property function in layer '${t.layers[t.layers.length-1]}' failed with\n`,`error ${n.stack}\n`,`function '${e.source}'\n`,t.feature,t)}}J.createPointSizePropertyCache=function(e,t){let n=null,r=null;if(se(e))n=[!0];else if(Array.isArray(e)){if(Array.isArray(e[0])){if(e.some(e=>Array.isArray(e[1])?e[1].some(e=>ae(e)):se(e[1]))&&(n=e.map(e=>Array.isArray(e[1])?e[1].map(e=>se(e)):se(e[1])),r=e.map(e=>Array.isArray(e[1])&&e[1].map(e=>oe(e))),r.some(e=>Array.isArray(e)&&e.every(e=>e))))throw le}else if(e.some(ae)&&(n=[e.map(se)],r=[e.map(oe)],r[0].every(e=>e)))throw le}else if(oe(e))throw"this value only allowed as half of an array, eg [16px, auto]:";if(n||r){if(!t)throw"% or 'auto' keywords can only be used to specify point size when a texture is defined";(e={value:e}).has_pct=n,e.has_ratio=r,e.sprites={}}else e=J.createPropertyCache(e,re);return e},J.evalCachedPointSizeProperty=function(e,t,n,r){if(null!=e)return e.has_pct||e.has_ratio?t?(e.sprites[t.sprite]||(e.sprites[t.sprite]=ue(e,t)),J.evalCachedProperty(e.sprites[t.sprite],r)):(e.texture=e.texture||ue(e,n),J.evalCachedProperty(e.texture,r)):J.evalCachedProperty(e,r)},J.evalCachedProperty=function(e,t){return null==e?void 0:e.dynamic?ce(e.dynamic,t):e.static?e.static:e.zoom&&e.zoom[t.zoom]?e.zoom[t.zoom]:"function"==typeof e.value?(e.dynamic_transform?e.dynamic=function(t){return e.dynamic_transform(e.value(t))}:e.dynamic=e.value,ce(e.dynamic,t)):Array.isArray(e.value)&&Array.isArray(e.value[0])?(e.zoom=e.zoom||{},e.zoom[t.zoom]=_.interpolate(t.zoom,e.value),e.zoom[t.zoom]):(e.static=e.value,e.static)},J.convertUnits=function(e,t){if(null!=e.value)return"px"===e.units?e.value*G.metersPerPixel(t.zoom):e.value;if("string"==typeof e)"px"===e.trim().slice(-2)?(e=ne(e),e*=G.metersPerPixel(t.zoom)):e=ne(e);else if(Array.isArray(e))return Array.isArray(e[0])?e.map(e=>[e[0],J.convertUnits(e[1],t)]):e.map(e=>J.convertUnits(e,t));return e},J.parseUnits=function(e){var t={value:ne(e)};return 0!==t.value&&"string"==typeof e&&"px"===e.trim().slice(-2)&&(t.units="px"),t},J.evalCachedDistanceProperty=function(e,t){return null==e?void 0:e.dynamic?ce(e.dynamic,t):e.zoom&&e.zoom[t.zoom]?e.zoom[t.zoom]:"function"==typeof e.value?(e.dynamic=e.value,ce(e.dynamic,t)):e.zoom?(e.zoom[t.zoom]=_.interpolate(t.zoom,e.value,e=>J.convertUnits(e,t)),e.zoom[t.zoom]):J.convertUnits(e.value,t)},J.string_colors={},J.colorForString=function(e){if(J.string_colors[e])return J.string_colors[e];let t=Q.parseCSSColor(e);return t&&4===t.length?(t[0]/=255,t[1]/=255,t[2]/=255):t=J.defaults.color,J.string_colors[e]=t,t},J.evalCachedColorProperty=function(e,t={}){if(null!=e){if(e.dynamic){let n=ce(e.dynamic,t);return"string"==typeof n&&(n=J.colorForString(n)),n&&null==n[3]&&(n[3]=1),n}if(e.static)return e.static;if(e.zoom&&e.zoom[t.zoom])return e.zoom[t.zoom];if("function"==typeof e.value){e.dynamic=e.value;let n=ce(e.dynamic,t);return"string"==typeof n&&(n=J.colorForString(n)),n&&null==n[3]&&(n[3]=1),n}if("string"==typeof e.value)return e.static=J.colorForString(e.value),e.static;if(e.zoom){if(!e.zoom_preprocessed){for(let t=0;t<e.value.length;t++){let n=e.value[t];n&&"string"==typeof n[1]&&(n[1]=J.colorForString(n[1]))}e.zoom_preprocessed=!0}return e.zoom[t.zoom]=_.interpolate(t.zoom,e.value),e.zoom[t.zoom][3]=e.zoom[t.zoom][3]||1,e.zoom[t.zoom]}return e.static=e.value.map(e=>e),e.static&&null==e.static[3]&&(e.static[3]=1),e.static}},J.evalCachedColorPropertyWithAlpha=function(e,t,n){const r=J.evalCachedColorProperty(e,n);if(null!=r&&null!=t){const e=J.evalCachedProperty(t,n);if(null!=e)return[r[0],r[1],r[2],e]}return r},J.parseColor=function(e,t={}){if("function"==typeof e&&(e=ce(e,t)),"string"==typeof e)e=J.colorForString(e);else if(Array.isArray(e)&&Array.isArray(e[0])){for(let t=0;t<e.length;t++){let n=e[t];"string"==typeof n[1]&&(n[1]=J.colorForString(n[1]))}t.zoom&&(e=_.interpolate(t.zoom,e))}return Array.isArray(e)?null==(e=e.map(e=>e))[3]&&(e[3]=1):e=[0,0,0,1],e},J.calculateOrder=function(e,t){return"function"==typeof e?e=ce(e,t):"string"==typeof e&&(e=t.feature.properties[e]?t.feature.properties[e]:re(e)),e},J.evalProperty=function(e,t){return"function"==typeof e?ce(e,t):e};class he{constructor(e,t,n){this.gl=e,this.workers=t,this._lock_fn="function"==typeof n&&n,this.init()}init(){this.requests={},this.feature=null,this.read_delay=0,this.read_delay_timer=null,this.pixels=null,this.fbo=this.gl.createFramebuffer(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.fbo),this.fbo_size={width:256,height:256};var e=k.create(this.gl,"__selection_fbo",{filtering:"nearest"});e.setData(this.fbo_size.width,this.fbo_size.height,null,{filtering:"nearest"}),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e.texture,0);var t=this.gl.createRenderbuffer();this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,t),this.gl.renderbufferStorage(this.gl.RENDERBUFFER,this.gl.DEPTH_COMPONENT16,this.fbo_size.width,this.fbo_size.height),this.gl.framebufferRenderbuffer(this.gl.FRAMEBUFFER,this.gl.DEPTH_ATTACHMENT,this.gl.RENDERBUFFER,t),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null)}destroy(){this.gl&&this.fbo&&(this.gl.deleteFramebuffer(this.fbo),this.fbo=null,this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null))}get locked(){return this._lock_fn&&this._lock_fn()||!1}bind(){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.fbo),this.gl.viewport(0,0,this.fbo_size.width,this.fbo_size.height),this.gl.clearColor(...he.defaultColor)}getFeatureAt(e,{radius:t}){return!e||e.x<0||e.y<0||e.x>1||e.y>1?Promise.resolve({feature:null,changed:!1}):new Promise((n,r)=>{this.selection_request_id=this.selection_request_id+1||0,this.requests[this.selection_request_id]={id:this.selection_request_id,point:e,radius:t,resolve:n,reject:r}})}pendingRequests(){return Object.keys(this.requests).length?this.requests:null}hasPendingRequests(){return null!=this.pendingRequests()}clearPendingRequests(){for(var e in this.requests){var t=this.requests[e];t.sent||(t.reject({request:t}),delete this.requests[e])}}read(){null!=this.read_delay_timer&&clearTimeout(this.read_delay_timer),this.read_delay_timer=setTimeout(()=>{if(!this.locked){var e=this.gl;for(var t in e.bindFramebuffer(e.FRAMEBUFFER,this.fbo),this.requests){var n=this.requests[t];if(n.sent)continue;let r,i,s=255,{point:o,radius:l}=n;if(l){let e=Math.min(this.fbo_size.width,this.fbo_size.height);i={x:Math.min(Math.ceil(2*l.x*this.fbo_size.width),e),y:Math.min(Math.ceil(2*l.y*this.fbo_size.height),e)}}else l={x:0,y:0},i={x:1,y:1};if((null==this.pixels||this.pixels.byteLength<i.x*i.y*4)&&(this.pixels=new Uint8Array(i.x*i.y*4)),this.pixels.fill instanceof Function)this.pixels.fill(0);else for(let e=0;e<this.pixels.length;e++)this.pixels[e]=0;e.readPixels(Math.round((o.x-l.x)*this.fbo_size.width),Math.round((1-o.y-l.y)*this.fbo_size.height),i.x,i.y,e.RGBA,e.UNSIGNED_BYTE,this.pixels);let u=4*(Math.round(i.y/2)*i.x+Math.round(i.x/2)),c=this.pixels[u]+(this.pixels[u+1]<<8)+(this.pixels[u+2]<<16);if(c>0)r=c+(this.pixels[u+3]<<24)>>>0,s=this.pixels[u+3];else{let e=-1>>>0;u=0;for(let t=0;t<i.y;t++)for(let n=0;n<i.x;n++,u+=4)if(c=this.pixels[u]+(this.pixels[u+1]<<8)+(this.pixels[u+2]<<16),c>0){let o=(n-i.x/2)*(n-i.x/2)+(t-i.y/2)*(t-i.y/2);o<=e&&(r=c+(this.pixels[u+3]<<24)>>>0,s=this.pixels[u+3],e=o)}}255!==s?null!=this.workers[s]&&a.postMessage(this.workers[s],"self.getFeatureSelection",{id:n.id,key:r}).then(e=>{this.finishRead(e)}):this.finishRead({id:n.id}),n.sent=!0}e.bindFramebuffer(e.FRAMEBUFFER,null)}},this.read_delay)}finishRead(e){var t=this.requests[e.id];if(t){var n=e.feature,r=!1;(null!=n&&null==this.feature||null==n&&null!=this.feature||null!=n&&null!=this.feature&&JSON.stringify(n)!==JSON.stringify(this.feature))&&(r=!0),this.feature=n,t.resolve({feature:n,changed:r,request:t}),delete this.requests[e.id]}else m("error","FeatureSelection.finishRead(): could not find message",e)}static makeEntry(e){this.map_entry++;var t=255&this.map_entry,n=this.map_entry>>8&255,r=this.map_entry>>16&255,i=this.map_prefix,s=t/255,o=n/255,a=r/255,l=i/255,u=t+(n<<8)+(r<<16)+(i<<24)>>>0;return this.map[u]={color:[s,o,a,l]},this.map_size++,this.tiles[e.key]||(this.tiles[e.key]={entries:[],tile:{key:e.key,coords:e.coords,style_z:e.style_z,source:e.source,generation:e.generation}}),this.tiles[e.key].entries.push(u),this.map[u]}static makeColor(e,t,n){var r=this.makeEntry(t);return r.feature={id:e.id,properties:e.properties,source_name:n.source,source_layer:n.layer,layers:n.layers,tile:this.tiles[t.key].tile},r.color}static reset(e){Array.isArray(e)?e.forEach(e=>this.clearSource(e)):(this.tiles={},this.map={},this.map_size=0,this.map_entry=0)}static clearSource(e){for(let t in this.tiles)this.tiles[t].tile.source===e&&this.clearTile(t)}static clearTile(e){this.tiles[e]&&(this.tiles[e].entries.forEach(e=>delete this.map[e]),this.map_size-=this.tiles[e].entries.length,delete this.tiles[e])}static getMapSize(){return this.map_size}static setPrefix(e){this.map_prefix=e}}var de;he.map={},he.tiles={},he.map_size=0,he.map_entry=0,he.map_prefix=0,he.defaultColor=[0,0,0,1];var fe=de={};de.BYTE=5120,de.UNSIGNED_BYTE=5121,de.SHORT=5122,de.UNSIGNED_SHORT=5123,de.INT=5124,de.UNSIGNED_INT=5125,de.FLOAT=5126;class pe{constructor(e,t,n,r,i){i=i||{},this.gl=e,this.vertex_data=t,this.element_data=n,this.vertex_layout=r,this.vertex_buffer=this.gl.createBuffer(),this.buffer_size=this.vertex_data.byteLength,this.draw_mode=i.draw_mode||this.gl.TRIANGLES,this.data_usage=i.data_usage||this.gl.STATIC_DRAW,this.vertices_per_geometry=3,this.uniforms=i.uniforms,this.textures=i.textures,this.retain=i.retain||!1,this.created_at=+new Date,this.fade_in_time=i.fade_in_time||0,this.vertex_count=this.vertex_data.byteLength/this.vertex_layout.stride,this.element_count=0,this.vaos={},this.toggle_element_array=!1,this.element_data?(this.toggle_element_array=!0,this.element_count=this.element_data.length,this.geometry_count=this.element_count/this.vertices_per_geometry,this.element_type=this.element_data.constructor===Uint16Array?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT,this.element_buffer=this.gl.createBuffer(),this.buffer_size+=this.element_data.byteLength,this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.element_buffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.element_data,this.data_usage)):this.geometry_count=this.vertex_count/this.vertices_per_geometry,this.upload(),this.retain||(delete this.vertex_data,delete this.element_data),this.valid=!0}render(e={}){if(!this.valid)return!1;var t=e.program||j.current;t.use(),this.uniforms&&(t.saveUniforms(this.uniforms),t.setUniforms(this.uniforms,!1));let n=(+new Date-this.created_at)/1e3;return t.uniform("1f","u_visible_time",n),this.bind(t),this.toggle_element_array?this.gl.drawElements(this.draw_mode,this.element_count,this.element_type,0):this.gl.drawArrays(this.draw_mode,0,this.vertex_count),U.bind(this.gl,null),this.uniforms&&t.restoreUniforms(this.uniforms),n<this.fade_in_time}bind(e){let t=this.vaos[e.id];t?U.bind(this.gl,t):this.vaos[e.id]=U.create(this.gl,()=>{this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertex_buffer),this.toggle_element_array&&this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.element_buffer),this.vertex_layout.enableDynamicAttributes(this.gl,e)}),this.vertex_layout.enableStaticAttributes(this.gl,e)}upload(){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertex_buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertex_data,this.data_usage)}destroy(){if(!this.valid)return!1;this.valid=!1;for(let e in this.vaos)U.destroy(this.gl,this.vaos[e]);return this.gl.deleteBuffer(this.vertex_buffer),this.vertex_buffer=null,this.element_buffer&&(this.gl.deleteBuffer(this.element_buffer),this.element_buffer=null),delete this.vertex_data,delete this.element_data,this.textures&&this.textures.forEach(e=>k.release(e)),!0}}const ge=["emission","ambient","diffuse","specular"];class me{constructor(e){e=e||{},ge.forEach(t=>{const n=e[t];null!=n&&(n.texture?this[t]={texture:n.texture,mapping:n.mapping||"spheremap",scale:O.expandVec3(null!=n.scale?n.scale:1),amount:O.expandVec4(null!=n.amount?n.amount:1)}:"number"==typeof n||Array.isArray(n)?this[t]={amount:O.expandVec4(n)}:this[t]="string"==typeof n?{amount:J.parseColor(n)}:n)}),this.specular&&(this.specular.shininess=e.shininess?parseFloat(e.shininess):.2),null!=e.normal&&(this.normal={texture:e.normal.texture,mapping:e.normal.mapping||"triplanar",scale:O.expandVec3(null!=e.normal.scale?e.normal.scale:1),amount:null!=e.normal.amount?e.normal.amount:1})}static isValid(e){return null!=e&&(null!=e.emission||null!=e.ambient||null!=e.diffuse||null!=e.specular)}inject(e){ge.forEach(t=>{let n=`TANGRAM_MATERIAL_${t.toUpperCase()}`,r=n+"_TEXTURE";e.defines[n]=null!=this[t],this[t]&&this[t].texture&&(e.defines[r]=!0,e.defines[r+"_"+this[t].mapping.toUpperCase()]=!0,e.defines[`TANGRAM_MATERIAL_TEXTURE_${this[t].mapping.toUpperCase()}`]=!0,e.texcoords=e.texcoords||"uv"===this[t].mapping)}),this.normal&&this.normal.texture&&(e.defines.TANGRAM_MATERIAL_NORMAL_TEXTURE=!0,e.defines["TANGRAM_MATERIAL_NORMAL_TEXTURE_"+this.normal.mapping.toUpperCase()]=!0,e.defines[`TANGRAM_MATERIAL_TEXTURE_${this.normal.mapping.toUpperCase()}`]=!0,e.texcoords=e.texcoords||"uv"===this.normal.mapping),e.replaceShaderBlock(me.block,"/*\n\nDefines globals:\nmaterial\nlight_accumulator_*\n\n*/\n\n\n// MATERIALS\n//\nstruct Material {\n #ifdef TANGRAM_MATERIAL_EMISSION\n vec4 emission;\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\n vec3 emissionScale;\n #endif\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT\n vec4 ambient;\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\n vec3 ambientScale;\n #endif\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n vec4 diffuse;\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\n vec3 diffuseScale;\n #endif\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n vec4 specular;\n float shininess;\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\n vec3 specularScale;\n #endif\n #endif\n\n\n #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\n vec3 normalScale;\n float normalAmount;\n #endif\n};\n\n// Note: uniform is copied to a global instance to allow modification\nuniform Material u_material;\nMaterial material;\n\n#ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\nuniform sampler2D u_material_emission_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\nuniform sampler2D u_material_ambient_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\nuniform sampler2D u_material_diffuse_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\nuniform sampler2D u_material_specular_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\nuniform sampler2D u_material_normal_texture;\n#endif\n\n// Global light accumulators for each property\nvec4 light_accumulator_ambient = vec4(vec3(0.0), 1.);\nvec4 light_accumulator_diffuse = vec4(vec3(0.0), 1.);\n#ifdef TANGRAM_MATERIAL_SPECULAR\n vec4 light_accumulator_specular = vec4(vec3(0.0), 1.);\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_SPHEREMAP\nvec4 getSphereMap (in sampler2D _tex, in vec3 _eyeToPoint, in vec3 _normal, in vec2 _skew) {\n // Normalized vector from camera to surface\n vec3 eye = normalize(_eyeToPoint);\n\n // Adjust for camera skew\n eye.xy -= _skew;\n eye = normalize(eye);\n\n // Reflection of eye off of surface normal\n vec3 r = reflect(eye, _normal);\n\n // Map reflected vector onto the surface of a sphere\n r.z += 1.0;\n float m = 2. * length(r);\n\n // Adjust xy to account for spherical shape, and center in middle of texture\n vec2 uv = r.xy / m + .5;\n\n // Sample the environment map\n return texture2D(_tex, uv);\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_TRIPLANAR\nvec3 getTriPlanarBlend (in vec3 _normal) {\n vec3 blending = abs(_normal);\n blending = normalize(max(blending, 0.00001));\n float b = (blending.x + blending.y + blending.z);\n return blending / b;\n}\n\nvec4 getTriPlanar (in sampler2D _tex, in vec3 _pos, in vec3 _normal, in vec3 _scale) {\n vec3 blending = getTriPlanarBlend(_normal);\n vec4 xaxis = texture2D(_tex, fract(_pos.yz * _scale.x));\n vec4 yaxis = texture2D(_tex, fract(_pos.xz * _scale.y));\n vec4 zaxis = texture2D(_tex, fract(_pos.xy * _scale.z));\n return xaxis * blending.x + yaxis * blending.y + zaxis * blending.z;\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_PLANAR\nvec4 getPlanar (in sampler2D _tex, in vec3 _pos, in vec2 _scale) {\n return texture2D( _tex, fract(_pos.xy * _scale.x) );\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\nvoid calculateNormal (inout vec3 _normal) {\n // Get NORMALMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_UV\n _normal += texture2D(u_material_normal_texture, fract(v_texcoord*material.normalScale.xy)).rgb*2.0-1.0;\n #endif\n\n #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_PLANAR\n vec3 normalTex = getPlanar(u_material_normal_texture, v_world_position.xyz, material.normalScale.xy).rgb*2.0-1.0;\n _normal += normalTex;\n #endif\n\n #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_TRIPLANAR\n vec3 normalTex = getTriPlanar(u_material_normal_texture, v_world_position.xyz, _normal, material.normalScale).rgb*2.0-1.0;\n _normal += normalTex;\n #endif\n\n _normal = normalize(_normal);\n}\n#endif\n\nvoid calculateMaterial (in vec3 _eyeToPoint, inout vec3 _normal) {\n // get EMISSION TEXTUREMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_UV\n material.emission *= texture2D(u_material_emission_texture,v_texcoord);\n #endif\n\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_PLANAR\n material.emission *= getPlanar(u_material_emission_texture, v_world_position.xyz, material.emissionScale.xy);\n #endif\n\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_TRIPLANAR\n material.emission *= getTriPlanar(u_material_emission_texture, v_world_position.xyz, _normal, material.emissionScale);\n #endif\n\n #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_SPHEREMAP\n material.emission *= getSphereMap(u_material_emission_texture, _eyeToPoint, _normal, u_vanishing_point);\n #endif\n #endif\n\n // get AMBIENT TEXTUREMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_UV\n material.ambient *= texture2D(u_material_ambient_texture,v_texcoord);\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_PLANAR\n material.ambient *= getPlanar(u_material_ambient_texture, v_world_position.xyz, material.ambientScale.xy);\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_TRIPLANAR\n material.ambient *= getTriPlanar(u_material_ambient_texture, v_world_position.xyz, _normal, material.ambientScale);\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_SPHEREMAP\n material.ambient *= getSphereMap(u_material_ambient_texture, _eyeToPoint, _normal, u_vanishing_point);\n #endif\n #endif\n\n // get DIFFUSE TEXTUREMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_UV\n material.diffuse *= texture2D(u_material_diffuse_texture,v_texcoord);\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_PLANAR\n material.diffuse *= getPlanar(u_material_diffuse_texture, v_world_position.xyz, material.diffuseScale.xy);\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_TRIPLANAR\n material.diffuse *= getTriPlanar(u_material_diffuse_texture, v_world_position.xyz, _normal, material.diffuseScale);\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_SPHEREMAP\n material.diffuse *= getSphereMap(u_material_diffuse_texture, _eyeToPoint, _normal, u_vanishing_point);\n #endif\n #endif\n\n // get SPECULAR TEXTUREMAP\n //------------------------------------------------\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_UV\n material.specular *= texture2D(u_material_specular_texture,v_texcoord);\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_PLANAR\n material.specular *= getPlanar(u_material_specular_texture, v_world_position.xyz, material.specularScale.xy);\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_TRIPLANAR\n material.specular *= getTriPlanar(u_material_specular_texture, v_world_position.xyz, _normal, material.specularScale);\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_SPHEREMAP\n material.specular *= getSphereMap(u_material_specular_texture, _eyeToPoint, _normal, u_vanishing_point);\n #endif\n #endif\n}\n","Material"),e.addShaderBlock("setup","\nmaterial = u_material;\n","Material")}setupProgram(e){ge.forEach(t=>{this[t]&&(this[t].texture?(e.setTextureUniform(`u_material_${t}_texture`,this[t].texture),e.uniform("3fv",`u_material.${t}Scale`,this[t].scale),e.uniform("4fv",`u_material.${t}`,this[t].amount)):this[t].amount&&e.uniform("4fv",`u_material.${t}`,this[t].amount))}),this.specular&&e.uniform("1f","u_material.shininess",this.specular.shininess),this.normal&&this.normal.texture&&(e.setTextureUniform("u_material_normal_texture",this.normal.texture),e.uniform("3fv","u_material.normalScale",this.normal.scale),e.uniform("1f","u_material.normalAmount",this.normal.amount))}}var _e;me.block="material";var ye=_e={};_e.copy=function(e){for(var t=[],n=e.length,r=0;r<n;r++)t[r]=e[r];return t},_e.neg=function(e){for(var t=[],n=e.length,r=0;r<n;r++)t[r]=-e[r];return t},_e.add=function(e,t){for(var n=[],r=Math.min(e.length,t.length),i=0;i<r;i++)n[i]=e[i]+t[i];return n},_e.sub=function(e,t){for(var n=[],r=Math.min(e.length,t.length),i=0;i<r;i++)n[i]=e[i]-t[i];return n},_e.signed_area=function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])},_e.mult=function(e,t){var n,r=[],i=e.length;if("number"==typeof t)for(n=0;n<i;n++)r[n]=e[n]*t;else for(i=Math.min(e.length,t.length),n=0;n<i;n++)r[n]=e[n]*t[n];return r},_e.div=function(e,t){var n,r=[];if("number"==typeof t)for(n=0;n<e.length;n++)r[n]=e[n]/t;else{var i=Math.min(e.length,t.length);for(n=0;n<i;n++)r[n]=e[n]/t[n]}return r},_e.perp=function(e,t){return[t[1]-e[1],e[0]-t[0]]},_e.rot=function(e,t){var n=Math.cos(t),r=Math.sin(t);return[e[0]*n-e[1]*r,e[0]*r+e[1]*n]},_e.angle=function([e,t]){return Math.atan2(t,e)},_e.angleBetween=function(e,t){var n=_e.dot(_e.normalize(_e.copy(e)),_e.normalize(_e.copy(t)));return n>1&&(n=1),Math.acos(n)},_e.isEqual=function(e,t){for(var n=e.length,r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0},_e.lengthSq=function(e){return 2===e.length?e[0]*e[0]+e[1]*e[1]:e.length>=3?e[0]*e[0]+e[1]*e[1]+e[2]*e[2]:0},_e.length=function(e){return Math.sqrt(_e.lengthSq(e))},_e.normalize=function(e){var t;if(2===e.length){if(1===(t=e[0]*e[0]+e[1]*e[1]))return e;0!==(t=Math.sqrt(t))?(e[0]/=t,e[1]/=t):(e[0]=0,e[1]=0)}else if(e.length>=3){if(1===(t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2]))return e;0!==(t=Math.sqrt(t))?(e[0]/=t,e[1]/=t,e[2]/=t):(e[0]=0,e[1]=0,e[2]=0)}return e},_e.cross=function(e,t){return 2===e.length?e[0]*t[1]-e[1]*t[0]:3===e.length?[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]:void 0},_e.dot=function(e,t){for(var n=0,r=Math.min(e.length,t.length),i=0;i<r;i++)n+=e[i]*t[i];return n};class ve{constructor(e,t){this.name=t.name,this.view=e,null==t.ambient||"number"==typeof t.ambient?this.ambient=O.expandVec3(t.ambient||0):this.ambient=J.parseColor(t.ambient).slice(0,3),null==t.diffuse||"number"==typeof t.diffuse?this.diffuse=O.expandVec3(null!=t.diffuse?t.diffuse:1):this.diffuse=J.parseColor(t.diffuse).slice(0,3),null==t.specular||"number"==typeof t.specular?this.specular=O.expandVec3(t.specular||0):this.specular=J.parseColor(t.specular).slice(0,3)}static create(e,t){if(ve.types[t.type])return new ve.types[t.type](e,t)}static setMode(e,t){!0===e&&(e="fragment"),e=ve.enabled&&(null!=e?e:"fragment"),t.defines.TANGRAM_LIGHTING_FRAGMENT="fragment"===e,t.defines.TANGRAM_LIGHTING_VERTEX="vertex"===e}static inject(e){if(j.removeBlock(ve.block),!ve.enabled)return;let t="";if(e&&Object.keys(e).length>0){let n={};for(let t in e)n[e[t].type]=!0;for(let e in n)ve.types[e].inject();for(let n in e)e[n].inject(),t+=`calculateLight(${n}, _eyeToPoint, _normal);\n`}let n=`\n vec4 calculateLighting(in vec3 _eyeToPoint, in vec3 _normal, in vec4 _color) {\n\n // Do initial material calculations over normal, emission, ambient, diffuse and specular values\n calculateMaterial(_eyeToPoint,_normal);\n\n // Un roll the loop of individual ligths to calculate\n ${t}\n\n // Final light intensity calculation\n vec4 color = vec4(vec3(0.), _color.a); // start with vertex color alpha\n\n #ifdef TANGRAM_MATERIAL_EMISSION\n color.rgb = material.emission.rgb;\n color.a *= material.emission.a;\n #endif\n\n #ifdef TANGRAM_MATERIAL_AMBIENT\n color.rgb += light_accumulator_ambient.rgb * _color.rgb * material.ambient.rgb;\n color.a *= material.ambient.a;\n #else\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n color.rgb += light_accumulator_ambient.rgb * _color.rgb * material.diffuse.rgb;\n #endif\n #endif\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n color.rgb += light_accumulator_diffuse.rgb * _color.rgb * material.diffuse.rgb;\n color.a *= material.diffuse.a;\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n color.rgb += light_accumulator_specular.rgb * material.specular.rgb;\n color.a *= material.specular.a;\n #endif\n\n // Clamp final color\n color = clamp(color, 0.0, 1.0);\n\n return color;\n }`;j.addBlock(ve.block,n)}inject(){let e=`\n uniform ${this.struct_name} u_${this.name};\n ${this.struct_name} ${this.name};\n `,t=`\n ${this.name} = u_${this.name};\n\n `;j.addBlock(ve.block,e),j.addBlock("setup",t)}update(){}setupProgram(e){e.uniform("3fv",`u_${this.name}.ambient`,this.ambient),e.uniform("3fv",`u_${this.name}.diffuse`,this.diffuse),e.uniform("3fv",`u_${this.name}.specular`,this.specular)}}ve.types={},ve.block="lighting",ve.enabled=!0,ve.types.ambient=class extends ve{constructor(e,t){super(e,t),this.type="ambient",this.struct_name="AmbientLight"}static inject(){j.addBlock(ve.block,"/*\n\nExpected globals:\nlight_accumulator_*\n\n*/\n\nstruct AmbientLight {\n vec3 ambient;\n};\n\nvoid calculateLight(in AmbientLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n light_accumulator_ambient.rgb += _light.ambient;\n}\n")}setupProgram(e){e.uniform("3fv",`u_${this.name}.ambient`,this.ambient)}},ve.types.directional=class extends ve{constructor(e,t){if(super(e,t),this.type="directional",this.struct_name="DirectionalLight",t.direction)this._direction=t.direction;else{let e=135,n=Math.sin(60*Math.PI/180);this._direction=[Math.cos(Math.PI*e/180)*n,Math.sin(Math.PI*e/180)*n,-.5],null==t.ambient&&(this.ambient=O.expandVec3(.5))}this.direction=this._direction.map(parseFloat)}get direction(){return this._direction}set direction(e){this._direction=ye.normalize(ye.copy(e))}static inject(){j.addBlock(ve.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct DirectionalLight {\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n vec3 direction;\n};\n\nvoid calculateLight(in DirectionalLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n light_accumulator_ambient.rgb += _light.ambient;\n\n float nDotVP = clamp(dot(_normal, -_light.direction), 0.0, 1.0);\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n light_accumulator_diffuse.rgb += _light.diffuse * nDotVP;\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n float pf = 0.0;\n if (nDotVP > 0.0) {\n vec3 reflectVector = reflect(_light.direction, _normal);\n float eyeDotR = max(dot(normalize(_eyeToPoint), reflectVector), 0.0);\n pf = pow(eyeDotR, material.shininess);\n }\n light_accumulator_specular.rgb += _light.specular * pf;\n #endif\n}\n")}setupProgram(e){super.setupProgram(e),e.uniform("3fv",`u_${this.name}.direction`,this.direction)}};class be extends ve{constructor(e,t){super(e,t),this.type="point",this.struct_name="PointLight",this.position=t.position||[0,0,"100px"],this.position_eye=[],this.origin=t.origin||"ground",this.attenuation=isNaN(parseFloat(t.attenuation))?0:parseFloat(t.attenuation),t.radius?Array.isArray(t.radius)&&2===t.radius.length?this.radius=t.radius:this.radius=[null,t.radius]:this.radius=null}static inject(){j.addBlock(ve.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct PointLight {\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n vec4 position;\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n float attenuationExponent;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n float innerRadius;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float outerRadius;\n#endif\n};\n\nvoid calculateLight(in PointLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n float dist = length(_light.position.xyz - _eyeToPoint);\n\n // Compute vector from surface to light position\n vec3 VP = (_light.position.xyz - _eyeToPoint) / dist;\n\n // Normalize the vector from surface to light position\n float nDotVP = clamp(dot(VP, _normal), 0.0, 1.0);\n\n // Attenuation defaults\n float attenuation = 1.0;\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n float Rin = 1.0;\n float e = _light.attenuationExponent;\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n Rin = _light.innerRadius;\n #endif\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float Rdiff = _light.outerRadius-Rin;\n float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n attenuation = 1.0-(pow(d,e));\n #else\n // If no outer is provide behaves like:\n // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n float d = max(0.0,dist-Rin)/Rin+1.0;\n attenuation = clamp(1.0/(pow(d,e)), 0.0, 1.0);\n #endif\n #else\n float Rin = 0.0;\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n Rin = _light.innerRadius;\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float Rdiff = _light.outerRadius-Rin;\n float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n attenuation = 1.0-d*d;\n #else\n // If no outer is provide behaves like:\n // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n float d = max(0.0,dist-Rin)/Rin+1.0;\n attenuation = clamp(1.0/d, 0.0, 1.0);\n #endif\n #else\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float d = clamp(dist/_light.outerRadius, 0.0, 1.0);\n attenuation = 1.0-d*d;\n #else\n attenuation = 1.0;\n #endif\n #endif\n #endif\n\n // Computer accumulators\n light_accumulator_ambient.rgb += _light.ambient * attenuation;\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n light_accumulator_diffuse.rgb += _light.diffuse * nDotVP * attenuation;\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n float pf = 0.0; // power factor for shiny speculars\n if (nDotVP > 0.0) {\n vec3 reflectVector = reflect(-VP, _normal);\n float eyeDotR = max(0.0, dot(-normalize(_eyeToPoint), reflectVector));\n pf = pow(eyeDotR, material.shininess);\n }\n\n light_accumulator_specular.rgb += _light.specular * pf * attenuation;\n #endif\n}\n")}inject(){super.inject(),j.defines.TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT=0!==this.attenuation,j.defines.TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS=null!=this.radius&&null!=this.radius[0],j.defines.TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS=null!=this.radius}update(){this.updateEyePosition()}updateEyePosition(){if("world"===this.origin){const e=G.latLngToMeters([...this.position]);this.position_eye[0]=e[0]-this.view.camera.position_meters[0],this.position_eye[1]=e[1]-this.view.camera.position_meters[1],this.position_eye[2]=J.convertUnits(this.position[2],{zoom:this.view.zoom,meters_per_pixel:G.metersPerPixel(this.view.zoom)}),this.position_eye[2]=this.position_eye[2]-this.view.camera.position_meters[2]}else"ground"!==this.origin&&"camera"!==this.origin||(this.position_eye=J.convertUnits(this.position,{zoom:this.view.zoom,meters_per_pixel:G.metersPerPixel(this.view.zoom)}),"ground"===this.origin&&(this.position_eye[2]=this.position_eye[2]-this.view.camera.position_meters[2]));this.position_eye[3]=1}setupProgram(e){super.setupProgram(e),e.uniform("4fv",`u_${this.name}.position`,this.position_eye),j.defines.TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT&&e.uniform("1f",`u_${this.name}.attenuationExponent`,this.attenuation),j.defines.TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS&&e.uniform("1f",`u_${this.name}.innerRadius`,J.convertUnits(this.radius[0],{zoom:this.view.zoom,meters_per_pixel:G.metersPerPixel(this.view.zoom)})),j.defines.TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS&&e.uniform("1f",`u_${this.name}.outerRadius`,J.convertUnits(this.radius[1],{zoom:this.view.zoom,meters_per_pixel:G.metersPerPixel(this.view.zoom)}))}}ve.types.point=be,ve.types.spotlight=class extends be{constructor(e,t){super(e,t),this.type="spotlight",this.struct_name="SpotLight",this.direction=this._direction=(t.direction||[0,0,-1]).map(parseFloat),this.exponent=t.exponent?parseFloat(t.exponent):.2,this.angle=t.angle?parseFloat(t.angle):20}get direction(){return this._direction}set direction(e){this._direction=ye.normalize(ye.copy(e))}static inject(){j.addBlock(ve.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct SpotLight {\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n vec4 position;\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n float attenuationExponent;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n float innerRadius;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float outerRadius;\n#endif\n\n vec3 direction;\n float spotCosCutoff;\n float spotExponent;\n};\n\nvoid calculateLight(in SpotLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n float dist = length(_light.position.xyz - _eyeToPoint);\n\n // Compute vector from surface to light position\n vec3 VP = (_light.position.xyz - _eyeToPoint) / dist;\n\n // normal . light direction\n float nDotVP = clamp(dot(_normal, VP), 0.0, 1.0);\n\n // Attenuation defaults\n float attenuation = 1.0;\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n float Rin = 1.0;\n float e = _light.attenuationExponent;\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n Rin = _light.innerRadius;\n #endif\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float Rdiff = _light.outerRadius-Rin;\n float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n attenuation = 1.0-(pow(d,e));\n #else\n // If no outer is provide behaves like:\n // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n float d = max(0.0,dist-Rin)/Rin+1.0;\n attenuation = clamp(1.0/(pow(d,e)), 0.0, 1.0);\n #endif\n #else\n float Rin = 0.0;\n\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n Rin = _light.innerRadius;\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float Rdiff = _light.outerRadius-Rin;\n float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n attenuation = 1.0-d*d;\n #else\n // If no outer is provide behaves like:\n // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n float d = max(0.0,dist-Rin)/Rin+1.0;\n attenuation = clamp(1.0/d, 0.0, 1.0);\n #endif\n #else\n #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n float d = clamp(dist/_light.outerRadius, 0.0, 1.0);\n attenuation = 1.0-d*d;\n #else\n attenuation = 1.0;\n #endif\n #endif\n #endif\n\n // spotlight attenuation factor\n float spotAttenuation = 0.0;\n\n // See if point on surface is inside cone of illumination\n float spotDot = clamp(dot(-VP, _light.direction), 0.0, 1.0);\n\n if (spotDot >= _light.spotCosCutoff) {\n spotAttenuation = pow(spotDot, _light.spotExponent);\n }\n\n light_accumulator_ambient.rgb += _light.ambient * attenuation * spotAttenuation;\n\n #ifdef TANGRAM_MATERIAL_DIFFUSE\n light_accumulator_diffuse.rgb += _light.diffuse * nDotVP * attenuation * spotAttenuation;\n #endif\n\n #ifdef TANGRAM_MATERIAL_SPECULAR\n // Power factor for shiny speculars\n float pf = 0.0;\n if (nDotVP > 0.0) {\n vec3 reflectVector = reflect(-VP, _normal);\n float eyeDotR = max(dot(-normalize(_eyeToPoint), reflectVector), 0.0);\n pf = pow(eyeDotR, material.shininess);\n }\n light_accumulator_specular.rgb += _light.specular * pf * attenuation * spotAttenuation;\n #endif\n}\n")}setupProgram(e){super.setupProgram(e),e.uniform("3fv",`u_${this.name}.direction`,this.direction),e.uniform("1f",`u_${this.name}.spotCosCutoff`,Math.cos(3.14159*this.angle/180)),e.uniform("1f",`u_${this.name}.spotExponent`,this.exponent)}};class xe extends Error{constructor(e){super(),this.name="MethodNotImplemented",this.message="Method "+e+" must be implemented in subclass"}}class we{constructor(e,t){this.validate(e),this.config=e,this.sources=t,this.id=e.id,this.name=e.name,this.pad_scale=e.pad_scale||1e-5,this.default_winding=null,this.rasters=[],Array.isArray(e.rasters)&&e.rasters.forEach(e=>{-1===this.rasters.indexOf(e)&&this.rasters.push(e)}),this.preprocess=e.preprocess,"function"==typeof this.preprocess&&this.preprocess.bind(this),this.transform=e.transform,"function"==typeof this.transform&&this.transform.bind(this),this.extra_data=e.extra_data,this.scripts=e.scripts,this.setZooms(e),this.zoom_offset=null!=e.zoom_offset?e.zoom_offset:0,this.zoom_offset<0&&(m({level:"warn",once:!0},`Data source '${this.name}' zoom_offset must not be negative – setting to 0.`),this.zoom_offset=0),this.setTileSize(e.tile_size),this.min_display_zoom=Math.max(e.min_display_zoom||0,this.zooms[0]),this.max_display_zoom=null!=e.max_display_zoom?e.max_display_zoom:null}static register(e,t){e&&t&&(we.types[e]=t)}static create(e,t){if("function"==typeof we.types[e.type]){const n=we.types[e.type](e);if(n)return new n(e,t)}}static tileLayoutChanged(e,t){if(!e||!t)return!0;const n=["max_zoom","zooms","min_display_zoom","max_display_zoom","bounds","tile_size","zoom_offset"],r=T(e.config,n),i=T(t.config,n);return JSON.stringify(r)!==JSON.stringify(i)}static projectData(e){var t=+new Date;for(var n in e.layers)for(var r=e.layers[n].features.length,i=0;i<r;i++){var s=e.layers[n].features[i];G.transformGeometry(s.geometry,this.projectCoord)}void 0!==e.debug&&(e.debug.projection=+new Date-t)}static projectCoord(e){G.latLngToMeters(e)}static scaleData(e,{coords:{z:t},min:n}){let r=G.unitsPerMeter(t);for(var i in e.layers)for(var s=e.layers[i].features.length,o=0;o<s;o++){var a=e.layers[i].features[o];G.transformGeometry(a.geometry,e=>{e[0]=(e[0]-n.x)*r,e[1]=(e[1]-n.y)*r*-1})}}load(e){return e.source_data={},e.source_data.layers={},e.pad_scale=this.pad_scale,e.rasters=[...this.rasters],this._load(e).then(e=>{for(let t in e.source_data.layers){let n=e.source_data.layers[t];n&&n.features&&n.features.forEach(e=>{G.transformGeometry(e.geometry,e=>{e[1]=-e[1],this.pad_scale&&(e[0]=Math.round(e[0]*(1+this.pad_scale)-G.tile_scale*this.pad_scale/2),e[1]=Math.round(e[1]*(1+this.pad_scale)-G.tile_scale*this.pad_scale/2))}),this.updateDefaultWinding(e.geometry)})}return e.default_winding=this.default_winding||"CCW",e})}_load(){throw new xe("_load")}copyTileData(e,t){return m("trace",`Copy tile data from ${e.key} to ${t.key}`),t.source_data={layers:e.source_data.layers},t.rasters=[...e.rasters],t.pad_scale=e.pad_scale,t.default_winding=e.default_winding,t}setZooms({max_zoom:e,zooms:t}){if(this.max_zoom=null!=e?e:G.default_source_max_zoom,Array.isArray(t))this.zooms=t,this.max_zoom=this.zooms[this.zooms.length-1];else{this.zooms=[];for(let e=0;e<=this.max_zoom;e++)this.zooms[e]=e}}setTileSize(e){this.tile_size=e||256,("number"!=typeof this.tile_size||this.tile_size<256||!_.isPowerOf2(this.tile_size))&&(m({level:"warn",once:!0},`Data source '${this.name}': 'tile_size' parameter must be a number that is a power of 2 greater than or equal to 256, but was '${e}'`),this.tile_size=256),this.zoom_bias=Math.log2(this.tile_size)-8+this.zoom_offset}updateDefaultWinding(e){return null==this.default_winding&&("Polygon"===e.type?this.default_winding=G.ringWinding(e.coordinates[0]):"MultiPolygon"===e.type&&(this.default_winding=G.ringWinding(e.coordinates[0][0]))),this.default_winding}includesTile(e,t){if(e.z<this.min_display_zoom||null!=this.max_display_zoom&&t>this.max_display_zoom)return!1;for(let t=0;t<this.rasters.length;t++){const n=this.rasters[t];if(this.sources[n]&&this.sources[n]!==this&&!this.sources[n].includesTile(e,e.z))return!1}return!0}validate(){}}we.types={};let Ae=0;class Ee extends we{constructor(e,t){super(e,t),this.response_type="";let[n,r]=function(e,t){if(!t||0===Object.keys(t).length)return[e,[]];var n=e.indexOf("?"),r=e.indexOf("#"),i="";r>-1&&(i=e.slice(r),e=e.slice(0,r)),-1===n&&(n=e.length,e+="?"),n++;var s="",o=[];for(var a in t)""===A(a,e)?s+=`${a}=${t[a]}&`:o.push([a,t[a]]);return[e=e.slice(0,n)+s+e.slice(n)+i,o]}(e.url,e.url_params);this.url=n,r.forEach(([t,n])=>{m({level:"warn",once:!0},`Data source '${this.name}': parameter '${t}' already present in URL '${e.url}', skipping value '${t}=${n}' specified in 'url_params'`)}),e.request_headers&&"object"==typeof e.request_headers&&(this.request_headers=e.request_headers)}_load(e){let t=this.formatURL(this.url,e),n=e.source_data;return n.url=t,e.debug=e.debug||{},e.debug.network=+new Date,new Promise(r=>{let i=Ae+++"-"+t,s=_.io(t,6e4,this.response_type,"GET",this.request_headers,i);n.request_id=i,n.error=null,s.then(({body:t})=>{e.debug.response_size=t&&(t.length||t.byteLength),e.debug.network=+new Date-e.debug.network,e.debug.parsing=+new Date,null!=t&&"function"==typeof this.preprocess&&(t=this.preprocess(t)),(t=t instanceof Promise?t:Promise.resolve(t)).then(t=>{null!=t?this.parseSourceData(e,n,t):n.layers={},e.debug.parsing=+new Date-e.debug.parsing,r(e)})}).catch(t=>{n.error=t.stack,r(e)})})}validate(e){if("string"!=typeof e.url)throw Error("Network data source must provide a string `url` property")}formatURL(){throw new xe("formatURL")}parseSourceData(){throw new xe("parseSourceData")}}class Se extends Ee{constructor(e,t){super(e,t),this.tiled=!0,this.bounds=this.parseBounds(e),this.builds_geometry_tiles=!1,this.tms=!0===e.tms,this.url&&this.url.search("{s}")>-1&&(Array.isArray(e.url_subdomains)&&e.url_subdomains.length>0?(this.url_subdomains=e.url_subdomains,this.next_url_subdomain=0):m({level:"warn",once:!0},`Data source '${this.name}': source URL includes '{s}' subdomain marker ('${this.url}'), but no subdomains were specified in 'url_subdomains' parameter`)),this.url&&this.url.search("{r}")>-1&&(Array.isArray(e.url_density_scales)&&e.url_density_scales.length>0?this.url_density_scales=e.url_density_scales:this.url_density_scales=[1,2])}parseBounds(e){if(Array.isArray(e.bounds)&&4===e.bounds.length){const[t,n,r,i]=e.bounds;return{latlng:[...e.bounds],meters:{min:G.latLngToMeters([t,i]),max:G.latLngToMeters([r,n])},tiles:{min:{},max:{}}}}}checkBounds(e,t){if(t){e=G.wrapTile(e);let n=t.tiles.min[e.z];n||(n=t.tiles.min[e.z]=G.tileForMeters(t.meters.min,e.z));let r=t.tiles.max[e.z];if(r||(r=t.tiles.max[e.z]=G.tileForMeters(t.meters.max,e.z)),e.y<n.y||e.y>r.y)return!1;if(n.x<=r.x){if(e.x<n.x||e.x>r.x)return!1}else if(e.x>r.x&&e.x<n.x)return!1}return!0}includesTile(e,t){return!!super.includesTile(e,t)&&!!this.checkBounds(e,this.bounds)}formatURL(e,t){let n=G.wrapTile(t.coords,{x:!0});this.tms&&(n.y=Math.pow(2,n.z)-1-n.y);let r=e.replace("{x}",n.x).replace("{y}",n.y).replace("{z}",n.z).replace("{r}",this.getDensityModifier()).replace("{q}",this.toQuadKey(n));return null!=this.url_subdomains&&(r=r.replace("{s}",this.url_subdomains[this.next_url_subdomain]),this.next_url_subdomain=(this.next_url_subdomain+1)%this.url_subdomains.length),r}getDensityModifier(){if(this.url_density_scales){const e=_.device_pixel_ratio;let t=this.url_density_scales.filter(t=>e>=t).reverse()[0];if(t=null!=t?t:this.url_density_scales[0],t>1)return`@${t}x`}return""}toQuadKey({x:e,y:t,z:n}){let r="";for(let i=n;i>0;i--){let n=0,s=1<<i-1;e&s&&n++,t&s&&(n+=2),r+=n.toString()}return r}static urlHasTilePattern(e){return e&&(e.search("{x}")>-1&&e.search("{y}")>-1&&e.search("{z}")>-1||e.search("{q}")>-1)}}const Te={coord(e){return{x:e.x,y:e.y,z:e.z,key:this.coordKey(e)}},coordKey:({x:e,y:t,z:n})=>e+"/"+t+"/"+n,key(e,t,n){if(!(e.y<0||e.y>=1<<e.z||e.z<0))return[t.name,e.x,e.y,e.z,n].join("/")},normalizedKey(e,t,n){return this.key(this.normalizedCoord(e,t),t,n)},normalizedCoord(e,t){return t.zoom_bias&&(e=this.coordAtZoom(e,Math.max(e.z-t.zoom_bias,t.zooms[0]))),this.coordForTileZooms(e,t.zooms)},coordAtZoom({x:e,y:t,z:n},r){if(n!==(r=Math.max(0,r))){let i=Math.pow(2,n-r);e=Math.floor(e/i),t=Math.floor(t/i),n=r}return this.coord({x:e,y:t,z:n})},coordForTileZooms({x:e,y:t,z:n},r){const i=this.findZoomInRange(n,r);return i!==n?this.coordAtZoom({x:e,y:t,z:n},i):this.coord({x:e,y:t,z:n})},findZoomInRange:(e,t)=>t.filter(t=>e>=t).reverse()[0]||t[0],isDescendant(e,t){if(t.z>e.z){let{x:n,y:r}=this.coordAtZoom(t,e.z);return e.x===n&&e.y===r}return!1},parent({coords:e,source:t,style_z:n}){if(n>0){n--;const r=Math.max(n-t.zoom_bias,t.zooms[0]),i=this.coordForTileZooms(this.coordAtZoom(e,r),t.zooms);return i.z>n?null:{key:this.key(i,t,n),coords:i,style_z:n,source:t}}},children({coords:e,source:t,style_z:n},r={}){n++;const i=this.coordForTileZooms(this.coordAtZoom(e,n-t.zoom_bias),t.zooms);if(i.z===e.z)return[{key:this.key(i,t,n),coords:i,style_z:n,source:t}];{const s=this.key(i,t,n);if(r[t.id]=r[t.id]||{},null==r[t.id][s]){const o=Math.pow(2,i.z-e.z),a=e.x*o,l=e.y*o;let u=[];for(let e=a;e<a+o;e++)for(let r=l;r<l+o;r++){let s=this.coord({x:e,y:r,z:i.z});u.push({key:this.key(s,t,n),coords:s,style_z:n,source:t})}r[t.id][s]=u}return r[t.id][s]}}};class ke extends Se{constructor(e,t){super(e,t),-1===this.rasters.indexOf(this.name)&&this.rasters.unshift(this.name),this.filtering=e.filtering,this.textures={}}async load(e){e.source_data={},e.source_data.layers={},e.pad_scale=this.pad_scale,e.rasters=[...this.rasters];let t=G.tile_scale;return e.source_data.layers={_default:{type:"FeatureCollection",features:[{geometry:{type:"Polygon",coordinates:[[[0,0],[t,0],[t,-t],[0,-t],[0,0]]]},properties:{}}]}},e.default_winding="CW",e}async tileTexture(e){let t=this.adjustRasterTileZoom(e),n=t.key;if(!this.textures[n]){let e=this.formatURL(this.url,{coords:t});this.textures[n]={name:e,url:e,filtering:this.filtering,coords:t}}return this.textures[n]}adjustRasterTileZoom(e){let t=e.coords;const n=this.sources[e.source];if(n!==this){let r=this.zoom_bias-n.zoom_bias;r>0?t=Te.normalizedCoord(e.coords,{zoom_bias:r,zooms:this.zooms}):(r<0&&m({level:"warn",once:!0},`Raster source '${this.name}' supports higher zoom detail than source '${n.name}' it's attached to. Downsampling this source ${-r} extra zoom levels to match.`),t=Te.coordForTileZooms(t,this.zooms))}return t}}class Oe extends ke{constructor(e,t){super(e,t),this.load_image={},this.alpha=null!=e.alpha?Math.max(Math.min(e.alpha,1),0):null,this.mask_alpha=!0,this.preserve_tiles_within_zoom=0,this.max_display_density=e.max_display_density,Array.isArray(e.composite)?this.images=e.composite.map(e=>({url:e.url,bounds:this.parseBounds(e),alpha:null!=e.alpha?Math.max(Math.min(e.alpha,1),0):null})):this.images=[{url:this.url,bounds:this.bounds,alpha:this.alpha}]}async tileTexture(e,{blend:t,generation:n}){let r=this.adjustRasterTileZoom(e);const i="opaque"!==t,s=`raster-${this.name}-${r.key}-${i?"alpha":"opaque"}-${n}`;if(k.textures[s])return{name:s,coords:r,skip_create:!0};let o=_.device_pixel_ratio;this.max_display_density&&(o=Math.min(o,this.max_display_density)),o*=2;const a=document.createElement("canvas"),l=a.getContext("2d");a.width=this.tile_size*o,a.height=this.tile_size*o,l.imageSmoothingEnabled="nearest"!==this.filtering;const u=this.images.filter(t=>this.checkBounds(e.coords,t.bounds));return await Promise.all(u.map(t=>{const n=i?null!=t.alpha?t.alpha:this.alpha:1;return this.drawImage(t.url,t.bounds,n,e,o,l)})),{name:s,element:a,filtering:this.filtering,coords:r}}async drawImage(e,t,n,r,i,s){const o=P(e);this.load_image[o]=this.load_image[o]||this.loadImage(e);const a=await this.load_image[o],l=G.metersPerPixel(r.coords.z)/i/(this.tile_size/G.tile_size),u=(t.meters.min[0]-r.min.x)/l,c=-(t.meters.min[1]-r.min.y)/l,h=(t.meters.max[0]-t.meters.min[0])/l,d=-(t.meters.max[1]-t.meters.min[1])/l;s.globalAlpha=null!=n?n:1,s.drawImage(a,u,c,h,d)}loadImage(e){return new Promise(t=>{let n=new Image;n.onload=()=>t(n),n.onerror=n=>{m("warn",`Raster source '${this.name}': failed to load url: '${e}'`,n),t(null)},_.isSafari()&&"data:"===e.slice(0,5)||(n.crossOrigin="anonymous"),n.src=e})}includesTile(e,t){return!!we.prototype.includesTile.call(this,e,t)&&this.images.some(t=>this.checkBounds(e,t.bounds))}validate(e){let t="Raster data source must provide a string `url` parameter, or an array of `composite` raster ";t+="image objects that each have a `url` parameter";let n="Raster data source must provide a `bounds` parameter, or an array of `composite` raster ";if(n+="image objects that each have a `bounds` parameter",Array.isArray(e.composite)){if(e.composite.some(e=>"string"!=typeof e.url))throw Error(t);if(e.composite.some(e=>!(Array.isArray(e.bounds)&&4===e.bounds.length)))throw Error(n);if(null!=e.url||null!=e.bounds)throw Error("Raster data source must have *either* a single image specified as `url` and `bounds `parameters, or an array of `composite` raster image objects, each with `url` and `bounds`.")}else{if("string"!=typeof e.url)throw Error(t);if(!Array.isArray(e.bounds)||4!==e.bounds.length)throw Error(n)}}}function Re(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Re(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Re(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}we.register("Raster",e=>ke.urlHasTilePattern(e.url)?ke:Oe);var Pe={init({generation:e,styles:t,sources:n={},introspection:r}={}){this.setGeneration(e),this.styles=t,this.sources=n,this.defines=Object.prototype.hasOwnProperty.call(this,"defines")&&this.defines||{},this.shaders=Object.prototype.hasOwnProperty.call(this,"shaders")&&this.shaders||{},this.introspection=r||!1,this.selection=this.selection||this.introspection||!1,this.compile_setup=!1,this.program=null,this.selection_program=null,this.feature_style={},this.vertex_template=[],this.tile_data={},this.stencil_proxy_tiles=!0,this.variants={},this.vertex_layouts={},this.defines.TANGRAM_WORLD_POSITION_WRAP=1e5,this.blend=this.blend||"opaque","opaque"!==this.blend?null==this.blend_order&&(this.blend_order=this.default_blend_orders[this.blend]):this.blend_order=this.default_blend_orders[this.blend],this.defines[`TANGRAM_BLEND_${this.blend.toUpperCase()}`]=!0,this.removeShaderBlock("setup"),this.material instanceof me||(me.isValid(this.material)||(this.material=J.defaults.material),this.material=new me(this.material)),this.material.inject(this),ve.setMode(this.lighting,this),this.setupRasters(),this.setupCustomAttributes(),this.initialized=!0},destroy(){this.program&&(this.program.destroy(),this.program=null),this.selection_program&&(this.selection_program.destroy(),this.selection_program=null),a.removeTarget(this.main_thread_target),this.gl=null,this.initialized=!1},reset(){},baseStyle(){return this.base||this.name},setGeneration(e){this.generation=e,this.main_thread_target=["Style",this.name,this.generation].join("_"),t.is_main&&a.addTarget(this.main_thread_target,this)},startData(e){this.tile_data[e.id]=this.tile_data[e.id]||{meshes:{},uniforms:{},textures:[]}},async endData(e){var t=this.tile_data[e.id];if(this.tile_data[e.id]=null,t&&Object.keys(t.meshes).length>0){for(let e in t.meshes){let n=t.meshes[e];0!==n.vertex_data.vertex_count?(n.vertex_data.end(),n.vertex_elements=n.vertex_data.element_buffer,n.vertex_data=n.vertex_data.vertex_buffer):delete t.meshes[e]}return this.buildRasterTextures(e,t)}return null},hasDataForTile(e){return null!=this.tile_data[e.id]},getTileMesh(e,t){const n=this.tile_data[e.id].meshes;if(null==n[t.key]){const e=this.vertexLayoutForMeshVariant(t);n[t.key]={variant:t,vertex_data:e.createVertexData()}}return n[t.key]},vertexLayoutForMeshVariant(){},meshVariantTypeForDraw(){},addFeature(e,t,n){let r=n.tile;if(r.generation!==this.generation)return;this.tile_data[r.id]||this.startData(r);let i=this.parseFeature(e,t,n);i&&this.buildGeometry(e.geometry,i,n)>0&&(e.generation=this.generation)},buildGeometry(e,t,n){let r;if("Polygon"===e.type?r=this.buildPolygons([e.coordinates],t,n):"MultiPolygon"===e.type?r=this.buildPolygons(e.coordinates,t,n):"LineString"===e.type?r=this.buildLines([e.coordinates],t,n):"MultiLineString"===e.type?r=this.buildLines(e.coordinates,t,n):"Point"===e.type?r=this.buildPoints([e.coordinates],t,n):"MultiPoint"===e.type&&(r=this.buildPoints(e.coordinates,t,n)),r>0&&v.layer_stats){let e=n.tile;e.debug.layers=e.debug.layers||{list:{},tree:{}};let t=e.debug.layers.list,i=e.debug.layers.tree,s={};n.layers.forEach(e=>{Me(t,e,1,r,{[this.name]:r},{[this.baseStyle()]:r});let n=i,o=s,a=e.split(":");for(let e=0;e<a.length;e++){let t=a[e];n[t]=n[t]||{features:0,geoms:0,styles:{},base:{}},null==o[t]&&(o[t]={},Me(n,t,1,r,{[this.name]:r},{[this.baseStyle()]:r})),e<a.length-1&&(n[t].layers=n[t].layers||{}),n=n[t].layers,o=o[t]}})}return r},parseFeature(e,t,n){try{var r=this.feature_style;if(r.order=this.parseOrder(t.order,n),null==r.order&&"overlay"!==this.blend){let e=`Layer '${t.layers.join(", ")}', draw group '${t.group}': `;return e+="'order' parameter is required unless blend mode is 'overlay'",null!=t.order&&(e+="; 'order' was set to a dynamic value (e.g. string tied to feature property, ",e+="or JS function), but evaluated to null for one or more features"),void m({level:"warn",once:!0},e)}if(!(r=this._parseFeature(e,t,n)))return;if(this.shaders.attributes){r.attributes=r.attributes||{};for(const e in this.shaders.attributes)r.attributes[e]=J.evalCachedProperty(t.attributes&&t.attributes[e],n),"number"!=typeof r.attributes[e]&&(r.attributes[e]=0)}return this.selection?r.interactive=J.evalProperty(t.interactive,n):r.interactive=!1,!0===r.interactive?r.selection_color=he.makeColor(e,n.tile,n):r.selection_color=he.defaultColor,r}catch(t){m("error","Style.parseFeature: style parsing error",e,r,t.stack)}},_parseFeature(){return this.feature_style},preprocess(e){if(!e.preprocessed){if(this.draw)for(let t in this.draw){let n=this.draw[t];"object"!=typeof n||Array.isArray(n)?null==e[t]&&(e[t]=n):e[t]=B({},n,e[t])}if(this.selection?this.introspection&&(e.interactive=!0):e.interactive=!1,!(e=this._preprocess(e)))return;if(this.shaders.attributes){e.attributes=e.attributes||{};for(const t in this.shaders.attributes)e.attributes[t]=J.createPropertyCache(null!=e.attributes[t]?e.attributes[t]:0)}e.preprocessed=!0}return e},_preprocess:e=>e,parseOrder:(e,t)=>"number"!=typeof e?J.calculateOrder(e,t):e,scaleOrder:e=>2*e,parseColor(e,t){return e?J.evalCachedColorProperty(e,t):this.shaders.blocks.color||this.shaders.blocks.filter?J.defaults.color:void 0},buildPolygons:()=>0,buildLines:()=>0,buildPoints:()=>0,setGL(e){this.gl=e,this.max_texture_size=k.getMaxTextureSize(this.gl)},makeMesh(e,t,n={}){let r=this.vertexLayoutForMeshVariant(n.variant);return v.wireframe?(t=function(e){const t=new Uint16Array(2*e.length);for(let n=0;n<e.length;n+=3)t.set([e[n],e[n+1],e[n+1],e[n+2],e[n+2],e[n]],2*n);return t}(t),new pe(this.gl,e,t,r,Ce(Ce({},n),{},{draw_mode:this.gl.LINES}))):new pe(this.gl,e,t,r,n)},render:e=>e.render(),getProgram(e="program"){this.compileSetup();const t=this[e];if(t&&!t.error){if(!t.compiled){m("debug",`Compiling style '${this.name}', program key '${e}'`);try{t.compile()}catch(t){throw m("error",`Style: error compiling program for style '${this.name}' (program key '${e}')`,this,t.stack,t.type,t.shader_errors),t}}return t}},compileSetup(){if(!this.compile_setup){if(!this.gl)throw new Error(`style.compile(): skipping for ${this.name} because no GL context`);var e=this.buildDefineList();if(this.selection){var t=Object.assign({},e);t.TANGRAM_FEATURE_SELECTION=!0}var n=this.shaders&&this.shaders.blocks,r=this.shaders&&this.shaders.block_scopes,i=Object.assign({},this.shaders&&this.shaders.uniforms);for(let e in i)null==i[e]&&m({level:"warn",once:!0},`Style '${this.name}' has invalid uniform '${e}': uniform values must be non-null`);var s=this.shaders&&this.shaders.extensions;"string"==typeof s&&(s=[s]),this.program=new j(this.gl,this.vertex_shader_src,this.fragment_shader_src,{name:this.name,defines:e,uniforms:i,blocks:n,block_scopes:r,extensions:s}),this.selection?this.selection_program=new j(this.gl,this.vertex_shader_src,"// Fragment shader for feature selection passes\n// Renders in silhouette according to selection (picking) color, or black if none defined\n\n#ifdef TANGRAM_FEATURE_SELECTION\n varying vec4 v_selection_color;\n#endif\n\nvoid main (void) {\n #ifdef TANGRAM_FEATURE_SELECTION\n gl_FragColor = v_selection_color;\n #else\n gl_FragColor = vec4(0., 0., 0., 1.);\n #endif\n}\n",{name:this.name+" (selection)",defines:t,uniforms:i,blocks:n,block_scopes:r,extensions:s}):this.selection_program=null,this.compile_setup=!0}},addShaderBlock(e,t,n=null){this.shaders.blocks=this.shaders.blocks||{},this.shaders.blocks[e]=this.shaders.blocks[e]||[],this.shaders.blocks[e].push(t),this.shaders.block_scopes=this.shaders.block_scopes||{},this.shaders.block_scopes[e]=this.shaders.block_scopes[e]||[],this.shaders.block_scopes[e].push(n)},removeShaderBlock(e){this.shaders.blocks&&(this.shaders.blocks[e]=null),this.shaders.block_scopes&&(this.shaders.block_scopes[e]=null)},replaceShaderBlock(e,t,n=null){this.removeShaderBlock(e),this.addShaderBlock(e,t,n)},buildDefineList(){var e={};if(null!=this.defines)for(var t in this.defines)e[t]=this.defines[t];if(null!=this.shaders&&null!=this.shaders.defines)for(t in this.shaders.defines)e[t]=this.shaders.defines[t];return e},hasRasters(){return["color","normal","custom"].indexOf(this.raster)>-1},setupRasters(){if(!this.hasRasters())return;"color"===this.raster?this.defines.TANGRAM_RASTER_TEXTURE_COLOR=!0:"normal"===this.raster&&(this.defines.TANGRAM_RASTER_TEXTURE_NORMAL=!0);let e=Object.keys(this.sources).filter(e=>this.sources[e]instanceof ke).length;if(this.defines.TANGRAM_NUM_RASTER_SOURCES=`${e}`,e>0){const t=Object.keys(this.sources).filter(e=>this.sources[e].mask_alpha).length;this.defines.TANGRAM_HAS_MASKED_RASTERS=t>0,this.defines.TANGRAM_ALL_MASKED_RASTERS=t===e,this.defines.TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING=!0,this.replaceShaderBlock("raster","// Uniforms defining raster textures and macros for accessing them\n\n#ifdef TANGRAM_FRAGMENT_SHADER\nuniform sampler2D u_rasters[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture samplers\nuniform vec2 u_raster_sizes[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture sizes (width/height in pixels)\nuniform vec3 u_raster_offsets[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture UV starting offset for tile\n\n// Raster sources can optionally mask by the alpha channel (render with only full or no alpha, based on a threshold),\n// which is used for handling transparency outside the raster image when rendering with opaque blending\n#if defined(TANGRAM_HAS_MASKED_RASTERS) && !defined(TANGRAM_ALL_MASKED_RASTERS) // only add uniform if we need it\nuniform bool u_raster_mask_alpha;\n#endif\n\n// Note: the raster accessors below are #defines rather than functions to\n// avoid issues with constant integer expressions for array indices\n\n// Adjusts UVs in model space to account for raster tile texture overzooming\n// (applies scale and offset adjustments)\n#define adjustRasterUV(raster_index, uv) \\\n ((uv) * u_raster_offsets[raster_index].z + u_raster_offsets[raster_index].xy)\n\n// Returns the UVs of the current model position for a raster sampler\n#define currentRasterUV(raster_index) \\\n (adjustRasterUV(raster_index, v_modelpos_base_zoom.xy))\n\n// Returns pixel location in raster tile texture at current model position\n#define currentRasterPixel(raster_index) \\\n (currentRasterUV(raster_index) * rasterPixelSize(raster_index))\n\n// Samples a raster tile texture for the current model position\n#define sampleRaster(raster_index) \\\n (texture2D(u_rasters[raster_index], currentRasterUV(raster_index)))\n\n// Samples a raster tile texture for a given pixel\n#define sampleRasterAtPixel(raster_index, pixel) \\\n (texture2D(u_rasters[raster_index], (pixel) / rasterPixelSize(raster_index)))\n\n// Returns size of raster sampler in pixels\n#define rasterPixelSize(raster_index) \\\n (u_raster_sizes[raster_index])\n\n#endif\n","Raster")}},async buildRasterTextures(e,t){if(!this.hasRasters())return t;if(0===e.rasters.length)return t;let n;try{n=await a.postMessage(`${this.main_thread_target}.loadTextures`,{coords:e.coords,source:e.source,rasters:e.rasters,min:e.min,max:e.max})}catch(e){return t}if(!n||n.length<1)return t;if(n.some(e=>!e.loaded))return null;t.uniforms.u_raster_mask_alpha=!0===this.sources[e.rasters[0]].mask_alpha;const r=t.uniforms.u_rasters=[],i=t.uniforms.u_raster_sizes=[],s=t.uniforms.u_raster_offsets=[];return n.forEach(n=>{const o=n.index;if(r[o]=n.name,t.textures.push(n.name),i[o]=[n.width,n.height],e.coords.z>n.coords.z){let t=e.coords.z-n.coords.z,r=Math.pow(2,t);s[o]=[(e.coords.x%r+r)%r/r,(r-1-e.coords.y%r)/r,1/r]}else s[o]=[0,0,1]}),t},async loadTextures(e){let t={},n={},r=[];e.rasters.map(e=>this.sources[e]).filter(e=>e).forEach((i,s)=>{i instanceof ke&&r.push(i.tileTexture(e,this).then(e=>{t[e.name]=e,n[e.name]=s}))}),await Promise.all(r),await k.createFromObject(this.gl,t);let i=await Promise.all(Object.keys(t).map(e=>k.textures[e]&&k.textures[e].load()).filter(e=>e));return i.forEach(e=>e.retain()),i.map(e=>({name:e.name,width:e.width,height:e.height,loaded:e.loaded,index:n[e.name],coords:t[e.name].coords}))},setupCustomAttributes(){if(this.shaders.attributes)for(const[e,t]of Object.entries(this.shaders.attributes))"float"===t.type&&(!1!==t.varying?(this.addShaderBlock("attributes",`\n #ifdef TANGRAM_VERTEX_SHADER\n attribute float a_${e};\n varying float v_${e};\n #define ${e} a_${e}\n #else\n varying float v_${e};\n #define ${e} v_${e}\n #endif\n `),this.addShaderBlock("setup",`#ifdef TANGRAM_VERTEX_SHADER\nv_${e} = a_${e};\n#endif`)):this.addShaderBlock("attributes",`\n #ifdef TANGRAM_VERTEX_SHADER\n attribute float a_${e};\n #define ${e} a_${e}\n #endif\n `))},addCustomAttributesToAttributeList(e){if(this.shaders.attributes)for(const[t,n]of Object.entries(this.shaders.attributes))"float"===n.type&&e.push({name:`a_${t}`,size:1,type:fe.FLOAT,normalized:!1});return e},addCustomAttributesToVertexTemplate(e,t){if(this.shaders.attributes)for(let n in this.shaders.attributes)this.vertex_template[t++]=null!=e.attributes[n]?e.attributes[n]:0},setup(){this.setUniforms(),this.material.setupProgram(j.current)},setUniforms(){var e,t=j.current;t&&t.setUniforms(null===(e=this.shaders)||void 0===e?void 0:e.uniforms,!0)},render_states:{opaque:{depth_test:!0,depth_write:!0},translucent:{depth_test:!0,depth_write:!0},add:{depth_test:!0,depth_write:!1},multiply:{depth_test:!0,depth_write:!1},inlay:{depth_test:!0,depth_write:!1},overlay:{depth_test:!1,depth_write:!1}},default_blend_orders:{opaque:Number.MIN_SAFE_INTEGER,add:1,multiply:2,inlay:3,translucent:4,overlay:5},getBlendOrderForDraw(e){return"opaque"!==this.blend&&null!=e.blend_order?e.blend_order:this.blend_order}};function Me(e,t,n,r,i,s){e[t]=e[t]||{features:0,geoms:0,styles:{},base:{}},e[t].features+=n,e[t].geoms+=r;for(let n in i)e[t].styles[n]=e[t].styles[n]||0,e[t].styles[n]+=i[n];for(let n in s)e[t].base[n]=e[t].base[n]||0,e[t].base[n]+=s[n]}let Ne=Math.pow(2,16)-1,Ie=!1;class De{constructor(){this.array=[],this.has_overflown=!1}push(e){this.has_overflown&&!Ie||e>Ne&&(this.has_overflown=!0,!Ie)||this.array.push(e)}end(){if(this.array.length){let t=(e=this.array,new(this.has_overflown&&Ie?Uint32Array:Uint16Array)(e));return this.array=[],this.has_overflown=!1,t}return!1;var e}}De.setElementIndexUint=function(e){Ie=e};let Fe={[fe.FLOAT]:Float32Array,[fe.BYTE]:Int8Array,[fe.UNSIGNED_BYTE]:Uint8Array,[fe.INT]:Int32Array,[fe.UNSIGNED_INT]:Uint32Array,[fe.SHORT]:Int16Array,[fe.UNSIGNED_SHORT]:Uint16Array};class ze{constructor(e,{prealloc:t=500}={}){this.vertex_layout=e,this.vertex_elements=new De,this.stride=this.vertex_layout.stride,ze.array_pool.length>0?(this.vertex_buffer=ze.array_pool.pop(),this.byte_length=this.vertex_buffer.byteLength,this.size=Math.floor(this.byte_length/this.stride),m("trace",`VertexData: reused buffer of bytes ${this.byte_length}, ${this.size} vertices`)):(this.size=t,this.byte_length=this.stride*this.size,this.vertex_buffer=new Uint8Array(this.byte_length)),this.offset=0,this.vertex_count=0,this.realloc_count=0,this.setBufferViews(),this.setAddVertexFunction()}setBufferViews(){this.views={},this.views[fe.UNSIGNED_BYTE]=this.vertex_buffer,this.vertex_layout.dynamic_attribs.forEach(e=>{if(null==this.views[e.type]){var t=Fe[e.type];this.views[e.type]=new t(this.vertex_buffer.buffer)}})}checkBufferSize(){if(this.offset+this.stride>this.byte_length){this.size=Math.floor(1.5*this.size),this.size-=this.size%4,this.byte_length=this.stride*this.size;var e=new Uint8Array(this.byte_length);e.set(this.vertex_buffer),ze.array_pool.push(this.vertex_buffer),this.vertex_buffer=e,this.setBufferViews(),this.realloc_count++}}setAddVertexFunction(){this.vertexLayoutAddVertex=this.vertex_layout.getAddVertexFunction()}addVertex(e){this.checkBufferSize(),this.vertexLayoutAddVertex(e,this.views,this.offset),this.offset+=this.stride,this.vertex_count++}end(){return this.vertex_buffer=this.vertex_buffer.subarray(0,this.offset),this.element_buffer=this.vertex_elements.end(),m("trace",`VertexData: ${this.size} vertices total, realloc count ${this.realloc_count}`),this}}ze.array_pool=[];class Le{constructor(e){this.attribs=e,this.dynamic_attribs=this.attribs.filter(e=>null==e.static),this.static_attribs=this.attribs.filter(e=>null!=e.static),this.components=[],this.index={},this.offset={},this.stride=0;let t=0,n=0;for(let e=0;e<this.attribs.length;e++){let r=this.attribs[e];if(null==r.static){r.offset=this.stride,r.byte_size=r.size;let e=0;switch(r.type){case fe.FLOAT:case fe.INT:case fe.UNSIGNED_INT:r.byte_size*=4,e=2;break;case fe.SHORT:case fe.UNSIGNED_SHORT:r.byte_size*=2,e=1}3&r.byte_size&&(r.byte_size+=4-(3&r.byte_size)),this.stride+=r.byte_size;let i=r.offset>>e;for(let t=0;t<r.size;t++)this.components.push({type:r.type,shift:e,offset:i++,index:n++});this.index[r.name]=t,t+=r.size,this.offset[r.name]=r.offset}else r.static=Array.isArray(r.static)?r.static:[r.static],r.method=`vertexAttrib${r.static.length}fv`}}enableDynamicAttributes(e,t){for(const t in Le.enabled_attribs)e.disableVertexAttribArray(t);Le.enabled_attribs={},this.dynamic_attribs.forEach(n=>{const r=t.attribute(n.name).location;-1!==r&&(e.enableVertexAttribArray(r),e.vertexAttribPointer(r,n.size,n.type,n.normalized,this.stride,n.offset),Le.enabled_attribs[r]=t)})}enableStaticAttributes(e,t){this.static_attribs.forEach(n=>{const r=t.attribute(n.name).location;-1!==r&&e[n.method]instanceof Function&&(e.enableVertexAttribArray(r),e[n.method](r,n.static),e.disableVertexAttribArray(r))})}createVertexData(){return new ze(this)}getAddVertexFunction(){return null==this.addVertex&&this.createAddVertexFunction(),this.addVertex}createAddVertexFunction(){let e=P(JSON.stringify(this.attribs));if(null==Le.add_vertex_funcs[e]){let t,n=["var t, o;"],r=[...this.components];r.sort((e,t)=>e.type!==t.type?e.type-t.type:e.index-t.index);for(let e=0;e<r.length;e++){let i=r[e];t!==i.type&&(n.push(`t = vs[${i.type}];`),n.push(`o = off${i.shift?" >> "+i.shift:""};`),t=i.type),n.push(`t[o + ${i.offset}] = v[${i.index}];`)}n=n.join("\n");let i=new Function("v","vs","off",n);Le.add_vertex_funcs[e]=i}this.addVertex=Le.add_vertex_funcs[e]}}Le.enabled_attribs={},Le.add_vertex_funcs={};const je=[{x:0,y:0},{x:G.tile_scale,y:-G.tile_scale}],Ve=[0,0,1,1];function Ue(e,t,n){let r=je[0],i=je[1];return e[0]<=r.x+n&&t[0]<=r.x+n||e[0]>=i.x-n&&t[0]>=i.x-n||e[1]>=r.y-n&&t[1]>=r.y-n||e[1]<=i.y+n&&t[1]<=i.y+n}function Be(e,t){t=t||0;let n=je[0],r=je[1];return e[0]<=n.x+t||e[0]>=r.x-t||e[1]>=n.y-t||e[1]<=r.y+t}var Ge,$e={exports:{}},qe=function(){if(Ge)return $e.exports;function e(e,i,s){s=s||2;var o,a,c,h,f,p,g,m=i&&i.length,_=m?i[0]*s:e.length,y=t(e,0,_,s,!0),v=[];if(!y||y.next===y.prev)return v;if(m&&(y=function(e,r,i,s){var o,a,c,h=[];for(o=0,a=r.length;o<a;o++)(c=t(e,r[o]*s,o<a-1?r[o+1]*s:e.length,s,!1))===c.next&&(c.steiner=!0),h.push(d(c));for(h.sort(l),o=0;o<h.length;o++)u(h[o],i),i=n(i,i.next);return i}(e,i,y,s)),e.length>80*s){o=c=e[0],a=h=e[1];for(var b=s;b<_;b+=s)(f=e[b])<o&&(o=f),(p=e[b+1])<a&&(a=p),f>c&&(c=f),p>h&&(h=p);g=0!==(g=Math.max(c-o,h-a))?1/g:0}return r(y,v,s,o,a,g),v}function t(e,t,n,r,i){var s,o;if(i===S(e,t,n,r)>0)for(s=t;s<n;s+=r)o=w(s,e[s],e[s+1],o);else for(s=n-r;s>=t;s-=r)o=w(s,e[s],e[s+1],o);return o&&m(o,o.next)&&(A(o),o=o.next),o}function n(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!m(r,r.next)&&0!==g(r.prev,r,r.next))r=r.next;else{if(A(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function r(e,t,l,u,c,d,f){if(e){!f&&d&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=h(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,s,o,a,l,u=1;do{for(n=e,e=null,s=null,o=0;n;){for(o++,r=n,a=0,t=0;t<u&&(a++,r=r.nextZ);t++);for(l=u;a>0||l>0&&r;)0!==a&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;n=r}s.nextZ=null,u*=2}while(o>1)}(i)}(e,u,c,d);for(var p,g,m=e;e.prev!==e.next;)if(p=e.prev,g=e.next,d?s(e,u,c,d):i(e))t.push(p.i/l),t.push(e.i/l),t.push(g.i/l),A(e),e=g.next,m=g.next;else if((e=g)===m){f?1===f?r(e=o(n(e),t,l),t,l,u,c,d,2):2===f&&a(e,t,l,u,c,d):r(n(e),t,l,u,c,d,1);break}}}function i(e){var t=e.prev,n=e,r=e.next;if(g(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(f(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&g(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function s(e,t,n,r){var i=e.prev,s=e,o=e.next;if(g(i,s,o)>=0)return!1;for(var a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,u=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,c=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,d=h(a,l,t,n,r),p=h(u,c,t,n,r),m=e.prevZ,_=e.nextZ;m&&m.z>=d&&_&&_.z<=p;){if(m!==e.prev&&m!==e.next&&f(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&g(m.prev,m,m.next)>=0)return!1;if(m=m.prevZ,_!==e.prev&&_!==e.next&&f(i.x,i.y,s.x,s.y,o.x,o.y,_.x,_.y)&&g(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;m&&m.z>=d;){if(m!==e.prev&&m!==e.next&&f(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&g(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;_&&_.z<=p;){if(_!==e.prev&&_!==e.next&&f(i.x,i.y,s.x,s.y,o.x,o.y,_.x,_.y)&&g(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function o(e,t,r){var i=e;do{var s=i.prev,o=i.next.next;!m(s,o)&&_(s,i,i.next,o)&&b(s,o)&&b(o,s)&&(t.push(s.i/r),t.push(i.i/r),t.push(o.i/r),A(i),A(i.next),i=e=o),i=i.next}while(i!==e);return n(i)}function a(e,t,i,s,o,a){var l=e;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&p(l,u)){var c=x(l,u);return l=n(l,l.next),c=n(c,c.next),r(l,t,i,s,o,a),void r(c,t,i,s,o,a)}u=u.next}l=l.next}while(l!==e)}function l(e,t){return e.x-t.x}function u(e,t){if(t=function(e,t){var n,r=t,i=e.x,s=e.y,o=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>o){if(o=a,a===i){if(s===r.y)return r;if(s===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===o)return n;var l,u=n,h=n.x,d=n.y,p=1/0;r=n;do{i>=r.x&&r.x>=h&&i!==r.x&&f(s<d?i:o,s,h,d,s<d?o:i,s,r.x,r.y)&&(l=Math.abs(s-r.y)/(i-r.x),b(r,e)&&(l<p||l===p&&(r.x>n.x||r.x===n.x&&c(n,r)))&&(n=r,p=l)),r=r.next}while(r!==u);return n}(e,t),t){var r=x(t,e);n(t,t.next),n(r,r.next)}}function c(e,t){return g(e.prev,e,t.prev)<0&&g(t.next,e,e.next)<0}function h(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function d(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function f(e,t,n,r,i,s,o,a){return(i-o)*(t-a)-(e-o)*(s-a)>=0&&(e-o)*(r-a)-(n-o)*(t-a)>=0&&(n-o)*(s-a)-(i-o)*(r-a)>=0}function p(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&_(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(b(e,t)&&b(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&i<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(g(e.prev,e,t.prev)||g(e,t.prev,t))||m(e,t)&&g(e.prev,e,e.next)>0&&g(t.prev,t,t.next)>0)}function g(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function m(e,t){return e.x===t.x&&e.y===t.y}function _(e,t,n,r){var i=v(g(e,t,n)),s=v(g(e,t,r)),o=v(g(n,r,e)),a=v(g(n,r,t));return i!==s&&o!==a||!(0!==i||!y(e,n,t))||!(0!==s||!y(e,r,t))||!(0!==o||!y(n,e,r))||!(0!==a||!y(n,t,r))}function y(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function v(e){return e>0?1:e<0?-1:0}function b(e,t){return g(e.prev,e,e.next)<0?g(e,t,e.next)>=0&&g(e,e.prev,t)>=0:g(e,t,e.prev)<0||g(e,e.next,t)<0}function x(e,t){var n=new E(e.i,e.x,e.y),r=new E(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function w(e,t,n,r){var i=new E(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function A(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function E(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S(e,t,n,r){for(var i=0,s=t,o=n-r;s<n;s+=r)i+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return i}return Ge=1,$e.exports=e,$e.exports.default=e,e.deviation=function(e,t,n,r){var i=t&&t.length,s=i?t[0]*n:e.length,o=Math.abs(S(e,0,s,n));if(i)for(var a=0,l=t.length;a<l;a++){var u=t[a]*n,c=a<l-1?t[a+1]*n:e.length;o-=Math.abs(S(e,u,c,n))}var h=0;for(a=0;a<r.length;a+=3){var d=r[a]*n,f=r[a+1]*n,p=r[a+2]*n;h+=Math.abs((e[d]-e[p])*(e[f+1]-e[d+1])-(e[d]-e[f])*(e[p+1]-e[d+1]))}return 0===o&&0===h?0:Math.abs((h-o)/o)},e.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var s=0;s<e[i].length;s++)for(var o=0;o<t;o++)n.vertices.push(e[i][s][o]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n},$e.exports}(),He=M(qe);function We(e,t,n=0,r=e.length-1,i=Ke){for(;r>n;){if(r-n>600){const s=r-n+1,o=t-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);We(e,t,Math.max(n,Math.floor(t-o*l/s+u)),Math.min(r,Math.floor(t+(s-o)*l/s+u)),i)}const s=e[t];let o=n,a=r;for(Ze(e,n,t),i(e[r],s)>0&&Ze(e,n,r);o<a;){for(Ze(e,o,a),o++,a--;i(e[o],s)<0;)o++;for(;i(e[a],s)>0;)a--}0===i(e[n],s)?Ze(e,n,a):(a++,Ze(e,a,r)),a<=t&&(n=a+1),t<=a&&(r=a-1)}}function Ze(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Ke(e,t){return e<t?-1:e>t?1:0}const Xe=[0,0,1];function Ye(e,t,n,{texcoord_index:r,texcoord_scale:i,texcoord_normalize:s}){let o,a,l,u,c,h,d,f,p,g,m,_,y=t.vertex_elements,v=e.length,b=0;r&&(s=s||1,[o,a,l,u]=i||Ve);for(let i=0;i<v;i++){const v=500;let w=e[i];w.length>v&&(w=[...w],We(w,v,1,w.length-1,(e,t)=>t.area-e.area),w=w.slice(0,v));const A=(x=He.flatten(w),He(x.vertices,x.holes,x.dimensions)),E=A.length,S=t.vertex_count;if(E){r&&([c,h,d,f]=G.findBoundingBox(w),p=d-c,g=f-h,m=(l-o)/p,_=(u-a)/g);for(let e=0;e<w.length;e++){let i=w[e];for(let e=0;e<i.length;e++){let l=i[e];n[0]=l[0],n[1]=l[1],r&&(n[r+0]=((l[0]-c)*m+o)*s,n[r+1]=((l[1]-h)*_+a)*s),t.addVertex(n)}}for(let e=0;e<E;e++)y.push(S+A[e]);b+=E/3}}var x;return b}var Qe='uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_tile_proxy_order_offset;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\n\nuniform mat4 u_model;\nuniform mat4 u_modelView;\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nattribute vec4 a_position;\nattribute vec4 a_color;\n\n// Optional normal attribute, otherwise default to up\n#ifdef TANGRAM_NORMAL_ATTRIBUTE\n attribute vec3 a_normal;\n #define TANGRAM_NORMAL a_normal\n#else\n #define TANGRAM_NORMAL vec3(0., 0., 1.)\n#endif\n\n// Optional dynamic line extrusion\n#ifdef TANGRAM_EXTRUDE_LINES\n attribute vec2 a_extrude; // extrusion direction in xy plane\n attribute vec2 a_offset; // offset direction in xy plane\n\n // Polygon and line styles have slightly different VBO layouts, saving memory by optimizing vertex packing.\n // All lines have a width scaling factor, but only some have a height (position.z) or offset.\n // The vertex height is stored in different attributes to account for this.\n attribute vec2 a_z_and_offset_scale; // stores vertex height in x, and offset scaling factor in y\n #define TANGRAM_POSITION_Z a_z_and_offset_scale.x // vertex height is stored in separate line-specific attrib\n #define TANGRAM_OFFSET_SCALING a_z_and_offset_scale.y // zoom scaling factor for line offset\n #define TANGRAM_WIDTH_SCALING a_position.z // zoom scaling factor for line width (stored in position attrib)\n\n uniform float u_v_scale_adjust; // scales texture UVs for line dash patterns w/fractional pixel width\n#else\n #define TANGRAM_POSITION_Z a_position.z // vertex height\n#endif\n\nvarying vec4 v_position;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvarying vec4 v_world_position;\n\n// Optional texture UVs\n#if defined(TANGRAM_TEXTURE_COORDS) || defined(TANGRAM_EXTRUDE_LINES)\n attribute vec2 a_texcoord;\n varying vec2 v_texcoord;\n#endif\n\n// Optional model position varying for tile coordinate zoom\n#ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n varying vec4 v_modelpos_base_zoom;\n#endif\n\n#if defined(TANGRAM_LIGHTING_VERTEX)\n varying vec4 v_lighting;\n#endif\n\n#define TANGRAM_UNPACK_SCALING(x) (x / 1024.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvoid main() {\n // Initialize globals\n #pragma tangram: setup\n\n // Texture UVs\n #ifdef TANGRAM_TEXTURE_COORDS\n v_texcoord = a_texcoord;\n #ifdef TANGRAM_EXTRUDE_LINES\n v_texcoord.y *= u_v_scale_adjust;\n #endif\n #endif\n\n // Pass model position to fragment shader\n #ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n v_modelpos_base_zoom = modelPositionBaseZoom();\n #endif\n\n // Position\n vec4 position = vec4(a_position.xy, TANGRAM_POSITION_Z / TANGRAM_HEIGHT_SCALE, 1.); // convert height back to meters\n\n #ifdef TANGRAM_EXTRUDE_LINES\n vec2 _extrude = a_extrude.xy;\n vec2 _offset = a_offset.xy;\n\n // Adjust line width based on zoom level, to prevent proxied lines\n // from being either too small or too big.\n // "Flattens" the zoom between 1-2 to peg it to 1 (keeps lines from\n // prematurely shrinking), then interpolate and clamp to 4 (keeps lines\n // from becoming too small when far away).\n float _dz = clamp(u_map_position.z - u_tile_origin.z, 0., 4.);\n _dz += step(1., _dz) * (1. - _dz) + mix(0., 2., clamp((_dz - 2.) / 2., 0., 1.));\n\n // Interpolate line width between zooms\n float _mdz = (_dz - 0.5) * 2.; // zoom from mid-point\n _extrude -= _extrude * TANGRAM_UNPACK_SCALING(TANGRAM_WIDTH_SCALING) * _mdz;\n\n // Interpolate line offset between zooms\n // Scales from the larger value to the smaller one\n float _dwdz = TANGRAM_UNPACK_SCALING(TANGRAM_OFFSET_SCALING);\n float _sdwdz = sign(step(0., _dwdz) - 0.5); // sign indicates "direction" of scaling\n _offset -= _offset * abs(_dwdz) * ((1.-step(0., _sdwdz)) - (_dz * -_sdwdz)); // scale "up" or "down"\n\n // Scale line width and offset to be consistent in screen space\n float _ssz = exp2(-_dz - (u_tile_origin.z - u_tile_origin.w));\n _extrude *= _ssz;\n _offset *= _ssz;\n\n // Modify line width before extrusion\n #ifdef TANGRAM_BLOCK_WIDTH\n float width = 1.;\n #pragma tangram: width\n _extrude *= width;\n #endif\n\n position.xy += _extrude + _offset;\n #endif\n\n // World coordinates for 3d procedural textures\n v_world_position = wrapWorldPosition(u_model * position);\n\n // Adjust for tile and view position\n position = u_modelView * position;\n\n // Modify position before camera projection\n #pragma tangram: position\n\n // Setup varyings\n v_position = position;\n v_normal = normalize(u_normalMatrix * TANGRAM_NORMAL);\n v_color = a_color;\n\n #if defined(TANGRAM_LIGHTING_VERTEX)\n // Vertex lighting\n vec3 normal = v_normal;\n\n // Modify normal before lighting\n #pragma tangram: normal\n\n // Pass lighting intensity to fragment shader\n v_lighting = calculateLighting(position.xyz - u_eye, normal, vec4(1.));\n #endif\n\n // Camera\n cameraProjection(position);\n\n // +1 is to keep all layers including proxies > 0\n applyLayerOrder(a_position.w + u_tile_proxy_order_offset + 1., position);\n\n gl_Position = position;\n}\n',Je="uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\n\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nvarying vec4 v_position;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvarying vec4 v_world_position;\n\n#ifdef TANGRAM_EXTRUDE_LINES\n uniform bool u_has_line_texture;\n uniform sampler2D u_texture;\n uniform float u_texture_ratio;\n uniform vec4 u_dash_background_color;\n uniform float u_has_dash;\n#endif\n\n#define TANGRAM_NORMAL v_normal\n\n#if defined(TANGRAM_TEXTURE_COORDS) || defined(TANGRAM_EXTRUDE_LINES)\n varying vec2 v_texcoord;\n#endif\n\n#ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n varying vec4 v_modelpos_base_zoom;\n#endif\n\n#if defined(TANGRAM_LIGHTING_VERTEX)\n varying vec4 v_lighting;\n#endif\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvoid main (void) {\n // Initialize globals\n #pragma tangram: setup\n\n vec4 color = v_color;\n vec3 normal = TANGRAM_NORMAL;\n\n // Apply raster to vertex color\n #ifdef TANGRAM_RASTER_TEXTURE_COLOR\n vec4 _raster_color = sampleRaster(0);\n\n #if defined(TANGRAM_BLEND_OPAQUE) || defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n // Raster sources can optionally mask by the alpha channel, which will render with only full or no alpha.\n // This is used for handling transparency outside the raster image in some blend modes,\n // which either don't support alpha, or would cause transparent pixels to write to the depth buffer,\n // obscuring geometry underneath.\n #ifdef TANGRAM_HAS_MASKED_RASTERS // skip masking logic if no masked raster sources\n #ifndef TANGRAM_ALL_MASKED_RASTERS // skip source check for masking if *all* raster sources are masked\n if (u_raster_mask_alpha) {\n #else\n {\n #endif\n #if defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n if (_raster_color.a < TANGRAM_EPSILON) {\n discard;\n }\n #else // TANGRAM_BLEND_OPAQUE\n if (_raster_color.a < 1. - TANGRAM_EPSILON) {\n discard;\n }\n // only allow full alpha in opaque blend mode (avoids artifacts blending w/canvas tile background)\n _raster_color.a = 1.;\n #endif\n }\n #endif\n #endif\n\n color *= _raster_color; // multiplied to tint texture color\n #endif\n\n // Apply line texture\n #ifdef TANGRAM_EXTRUDE_LINES\n { // enclose in scope to avoid leakage of internal variables\n if (u_has_line_texture) {\n vec2 _line_st = vec2(v_texcoord.x, fract(v_texcoord.y / u_texture_ratio));\n vec4 _line_color = texture2D(u_texture, _line_st);\n\n // If the line has a dash pattern, the line texture indicates if the current fragment should be\n // the dash foreground or background color. If the line doesn't have a dash pattern,\n // the line texture color is used directly (but also tinted by the vertex color).\n color = mix(\n color * _line_color, // no dash: tint the line texture with the vertex color\n mix(u_dash_background_color, color, _line_color.a), // choose dash foreground or background color\n u_has_dash // 0 if no dash, 1 if has dash\n );\n\n // Use alpha discard test as a lower-quality substitute for blending\n #if defined(TANGRAM_BLEND_OPAQUE)\n if (color.a < TANGRAM_ALPHA_TEST) {\n discard;\n }\n #endif\n }\n }\n #endif\n\n // First, get normal from raster tile (if applicable)\n #ifdef TANGRAM_RASTER_TEXTURE_NORMAL\n normal = normalize(sampleRaster(0).rgb * 2. - 1.);\n #endif\n\n // Second, alter normal with normal map texture (if applicable)\n #if defined(TANGRAM_LIGHTING_FRAGMENT) && defined(TANGRAM_MATERIAL_NORMAL_TEXTURE)\n calculateNormal(normal);\n #endif\n\n // Normal modification applied here for fragment lighting or no lighting,\n // and in vertex shader for vertex lighting\n #if !defined(TANGRAM_LIGHTING_VERTEX)\n #pragma tangram: normal\n #endif\n\n // Color modification before lighting is applied\n #pragma tangram: color\n\n #if defined(TANGRAM_LIGHTING_FRAGMENT)\n // Calculate per-fragment lighting\n color = calculateLighting(v_position.xyz - u_eye, normal, color);\n #elif defined(TANGRAM_LIGHTING_VERTEX)\n // Apply lighting intensity interpolated from vertex shader\n color *= v_lighting;\n #endif\n\n // Post-processing effects (modify color after lighting)\n #pragma tangram: filter\n\n gl_FragColor = color;\n}\n";const et=Object.create(Pe);Object.assign(et,{name:"polygons",built_in:!0,vertex_shader_src:Qe,fragment_shader_src:Je,selection:!0,init(){Pe.init.apply(this,arguments),this.defines.TANGRAM_NORMAL_ATTRIBUTE=!0,this.defines.TANGRAM_TEXTURE_COORDS=this.texcoords},_parseFeature(e,t,n){var r=this.feature_style;return r.color=this.parseColor(t.color,n),r.color?(r.alpha=J.evalCachedProperty(t.alpha,n),r.variant=t.variant,r.z=J.evalCachedDistanceProperty(t.z,n)||J.defaults.z,r.z*=G.height_scale,r.extrude=J.evalProperty(t.extrude,n),r.extrude&&(!0===r.extrude?(r.height=e.properties.height||J.defaults.height,r.min_height=e.properties.min_height||J.defaults.min_height):"number"==typeof r.extrude?(r.height=r.extrude,r.min_height=0):Array.isArray(r.extrude)&&(r.min_height=r.extrude[0],r.height=r.extrude[1]),r.height*=G.height_scale,r.min_height*=G.height_scale),r.tile_edges=t.tile_edges,r):null},_preprocess(e){return e.color=J.createColorPropertyCache(e.color),e.alpha=J.createPropertyCache(e.alpha),e.z=J.createPropertyCache(e.z,J.parseUnits),this.computeVariant(e),e},computeVariant(e){const t=e.interactive?1:0,n=null!=e.extrude?1:0,r=this.texcoords?1:0,i=this.getBlendOrderForDraw(e),s=[t,n,r,i].join("/");e.variant=s,null==this.variants[s]&&(this.variants[s]={key:s,blend_order:i,mesh_order:0,selection:t,normal:n,texcoords:r})},vertexLayoutForMeshVariant(e){if(null==this.vertex_layouts[e.key]){const t=[{name:"a_position",size:4,type:fe.SHORT,normalized:!1},{name:"a_normal",size:3,type:fe.BYTE,normalized:!0,static:e.normal?null:[0,0,1]},{name:"a_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_texcoord",size:2,type:fe.UNSIGNED_SHORT,normalized:!0,static:e.texcoords?null:[0,0]}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.key]=new Le(t)}return this.vertex_layouts[e.key]},meshVariantTypeForDraw(e){return this.variants[e.variant]},makeVertexTemplate(e,t){let n=0;return this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=e.z||0,this.vertex_template[n++]=this.scaleOrder(e.order),t.variant.normal&&(this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=127),this.vertex_template[n++]=255*e.color[0],this.vertex_template[n++]=255*e.color[1],this.vertex_template[n++]=255*e.color[2],this.vertex_template[n++]=255*(null!=e.alpha?e.alpha:e.color[3]),t.variant.selection&&(this.vertex_template[n++]=255*e.selection_color[0],this.vertex_template[n++]=255*e.selection_color[1],this.vertex_template[n++]=255*e.selection_color[2],this.vertex_template[n++]=255*e.selection_color[3]),t.variant.texcoords&&(this.vertex_template[n++]=0,this.vertex_template[n++]=0),this.addCustomAttributesToVertexTemplate(e,n),this.vertex_template},buildPolygons(e,t,n){let r=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),i=r.vertex_data,s=i.vertex_layout,o=this.makeVertexTemplate(t,r),a={texcoord_index:s.index.a_texcoord,texcoord_normalize:65535,remove_tile_edges:!t.tile_edges,tile_edge_tolerance:G.tile_scale*n.tile.pad_scale*4,winding:n.winding};return t.extrude&&t.height?function(e,t,n,r,i,s,o,a,{remove_tile_edges:l,tile_edge_tolerance:u,texcoord_index:c,texcoord_scale:h,texcoord_normalize:d,winding:f}){var p=t+(r||0),g=t+n;s[2]=g;var m=Ye(e,i,s,{texcoord_index:c,texcoord_scale:h,texcoord_normalize:d}),_=i.vertex_elements,y=i.vertex_count;if(c){d=d||1;var[v,b,x,w]=h||Ve,A=[[v,w],[v,b],[x,b],[x,w]]}for(var E=e.length,S=0;S<E;S++)for(var T=e[S],k=0;k<T.length;k++)for(var O=T[k],R=0;R<O.length-1;R++){if(l&&Ue(O[R],O[R+1],u))continue;let e,t;"CCW"===f?(e=R,t=R+1):(e=R+1,t=R);var C=[[O[t][0],O[t][1],g],[O[t][0],O[t][1],p],[O[e][0],O[e][1],p],[O[e][0],O[e][1],g]];let n=ye.normalize([O[t][0]-O[e][0],O[t][1]-O[e][1],0]),r=ye.cross(Xe,n);s[o+0]=r[0]*a,s[o+1]=r[1]*a,s[o+2]=r[2]*a;for(var P=0;P<C.length;P++)s[0]=C[P][0],s[1]=C[P][1],s[2]=C[P][2],c&&(s[c+0]=A[P][0]*d,s[c+1]=A[P][1]*d),i.addVertex(s);_.push(y+0),_.push(y+1),_.push(y+2),_.push(y+2),_.push(y+3),_.push(y+0),y+=4,m+=2}return m}(e,t.z,t.height,t.min_height,i,o,s.index.a_normal,127,a):Ye(e,i,o,a)}});const tt=[0,0],nt={butt:0,square:1,round:2},rt={miter:0,bevel:1,round:2},it=G.tile_scale,st=[0,0],ot=[1,0],at=[.5,0];function lt(e,t){if(!(e.length<2)){var n,r,i,s,{join_type:o,cap_type:a,closed_polygon:l,remove_tile_edges:u,tile_edge_tolerance:c,v_scale:h,miter_len_sq:d}=t,f=null!=t.texcoord_index,p=0;if(l&&o===rt.miter){var g=function(e){if(Be(e[0]))return 0;for(var t=0;t<e.length;t++)if(Be(e[e.length-1-t]))return e.length-1-t;return 0}(e);if(0!==g){var m=function(e,t){var n=[];for(let i=0;i<e.length;i++){var r=(i+t)%e.length;0!==r&&n.push(e[r])}return n.push(n[0]),n}(e,g);return t.extra_lines=t.extra_lines||[],void t.extra_lines.push(m)}}var _=0,y=e.length-1,v=0;for(n=e[_],r=e[_+1];ye.isEqual(n,r);)if(n=r,r=e[1+ ++_],v++,_===e.length-1)return;for(;ye.isEqual(e[y],e[y-1]);)if(v++,0===--y)return;if(!(e.length<2+v))if(s=ye.normalize(ye.perp(n,r)),u&&Ue(n,r,c)){var b=ut(e,_,c);b&&(t.extra_lines=t.extra_lines||[],t.extra_lines.push(b))}else{l?function(e,t,n,r,i){if(void 0===r||Be(e))pt(e,n,n,1,0,i,1),pt(e,n,n,0,0,i,-1);else{r===rt.miter?ht(0,e,t,n,i.miter_len_sq,!0,i):dt(r,0,e,t,n,!0,i)}}(n,i=ye.normalize(ye.perp(e[y-1],n)),s,o,t):(Be(n)||(_t(n,p,s,a,!0,t),f&&a!==nt.butt&&(p+=.5*h*t.texcoord_width)),pt(n,s,s,1,p,t,1),pt(n,s,s,0,p,t,-1)),f&&(p+=h*ye.length(ye.sub(r,n)));for(var x=_+1;x<y;x++){var w=x,A=x+1;if(n=e[w],r=e[A],!ye.isEqual(n,r)){if(u&&Ue(n,r,c)){pt(n,s,s,1,p,t,1),pt(n,s,s,0,p,t,-1),ft(1,t);var E=ut(e,w+1,c);return void(E&&(t.extra_lines=t.extra_lines||[],t.extra_lines.push(E)))}i=s,s=ye.normalize(ye.perp(n,r)),o===rt.miter?ht(p,n,i,s,d,!1,t):dt(o,p,n,i,s,!1,t),f&&(p+=h*ye.length(ye.sub(r,n)))}}n=r,i=s,l?function(e,t,n,r,i,s){if(Be(e))pt(e,t,t,1,i,s,1),pt(e,t,t,0,i,s,-1),ft(1,s);else{var o=ct(t,n);r===rt.miter&&ye.lengthSq(o)>s.miter_len_sq&&(r=rt.bevel),r===rt.miter?(pt(e,o,t,1,i,s,1),pt(e,o,t,0,i,s,-1),ft(1,s)):(pt(e,t,t,1,i,s,1),pt(e,t,t,0,i,s,-1),ft(1,s))}}(n,i,s=ye.normalize(ye.perp(n,e[1])),o,p,t):(pt(n,i,s,1,p,t,1),pt(n,i,s,0,p,t,-1),ft(1,t),Be(n)||_t(n,p,i,a,!1,t))}}}function ut(e,t,n){for(var r=t;e[r+1]&&Ue(e[r],e[r+1],n);)r++;return e.length-r>=2&&e.slice(r)}function ct(e,t){var n=ye.normalize(ye.add(e,t)),r=2/(1+Math.abs(ye.dot(e,n)));return ye.mult(n,r*r)}function ht(e,t,n,r,i,s,o){var a=ct(n,r);ye.lengthSq(a)>i?dt(rt.bevel,e,t,n,r,s,o):(pt(t,a,a,1,e,o,1),pt(t,a,a,0,e,o,-1),s||ft(1,o))}function dt(e,t,n,r,i,s,o){var a=ct(r,i),l=i[0]*r[1]-i[1]*r[0]>0;null!=o.texcoord_index&&(st[1]=t,ot[1]=t),l?(pt(n,a,a,1,t,o,1),pt(n,r,a,0,t,o,-1),s||ft(1,o),mt(n,ye.neg(r),a,ye.neg(i),a,st,ot,st,!1,e===rt.bevel,o),pt(n,a,a,1,t,o,1),pt(n,i,a,0,t,o,-1)):(pt(n,r,a,1,t,o,1),pt(n,a,a,0,t,o,-1),s||ft(1,o),mt(n,r,ye.neg(a),i,a,ot,st,ot,!1,e===rt.bevel,o),pt(n,i,a,1,t,o,1),pt(n,a,a,0,t,o,-1))}function ft(e,t){for(var n=t.vertex_data.vertex_elements,r=t.vertex_data.vertex_count-2*e-2,i=0;i<e;i++)n.push(r+2*i+2),n.push(r+2*i+1),n.push(r+2*i+0),n.push(r+2*i+2),n.push(r+2*i+3),n.push(r+2*i+1),t.geom_count+=2}function pt(e,t,n,r,i,s,o){var a=s.vertex_template,l=s.vertex_data;a[0]=e[0],a[1]=e[1];let u=s.half_width*o;a[s.extrude_index+0]=t[0]*u,a[s.extrude_index+1]=t[1]*u,s.offset&&(a[s.offset_index+0]=n[0]*s.offset,a[s.offset_index+1]=n[1]*s.offset),null!=s.texcoord_index&&(a[s.texcoord_index+0]=65535*r,a[s.texcoord_index+1]=65535*i),l.addVertex(a)}var gt=[0,0];function mt(e,t,n,r,i,s,o,a,l,u,c){for(var h=t[0]*r[1]-t[1]*r[0],d=ye.dot(t,r),f=Math.atan2(h,d);f>=Math.PI;)f-=2*Math.PI;if(u)p=1;else{var p=function(e,t){e<0&&(e=-e);var n=t>10?Math.log2(t/5):1;return Math.ceil(e/Math.PI*n)}(f,c.half_width);if(p<1)return}var g=c.vertex_data.vertex_count,m=c.vertex_data.vertex_elements;pt(e,n,i,o[0],o[1],c,1),pt(e,t,i,s[0],s[1],c,1);var _=t,y=null!=c.texcoord_index;if(y)if(l)var v=ye.sub(s,o);else{gt=ye.copy(s);var b=ye.div(ye.sub(a,s),p)}var x=f/p;let w,A,E=f<0?-1:1;h>0?(w=2,A=1):(w=1,A=2);for(var S=0;S<p;S++)0===S&&f<0&&(_=ye.neg(_)),_=ye.rot(_,x),y&&(l?(v=ye.rot(v,x),gt[0]=v[0]+o[0],gt[1]=v[1]*c.texcoord_width*c.v_scale+o[1]):gt=ye.add(gt,b)),pt(e,_,i,gt[0],gt[1],c,E),m.push(g+S+w),m.push(g),m.push(g+S+A)}function _t(e,t,n,r,i,s){var o=ye.neg(n),a=null!=s.texcoord_index;switch(r){case nt.square:var l;i?(l=[n[1],-n[0]],pt(e,ye.add(n,l),n,1,t,s,1),pt(e,ye.add(o,l),n,0,t,s,1),a&&(t+=.5*s.texcoord_width*s.v_scale),pt(e,n,n,1,t,s,1),pt(e,o,n,0,t,s,1)):(l=[-n[1],n[0]],pt(e,n,n,1,t,s,1),pt(e,o,n,0,t,s,1),a&&(t+=.5*s.texcoord_width*s.v_scale),pt(e,ye.add(n,l),n,1,t,s,1),pt(e,ye.add(o,l),n,0,t,s,1)),ft(1,s);break;case nt.round:var u,c,h=st,d=ot,f=at;i?(u=n,c=o,a&&(t+=.5*s.texcoord_width*s.v_scale,h=ot,d=st,f=at)):(u=o,c=n),a&&(st[1]=t,ot[1]=t,at[1]=t),mt(e,u,tt,c,n,h,f,d,!0,!1,s);break;case nt.butt:return}}const yt=[255,255,255,255],vt=[0,0,0,0],bt=Object.create(Pe);Object.assign(bt,{name:"lines",built_in:!0,vertex_shader_src:Qe,fragment_shader_src:Je,selection:!0,init(){Pe.init.apply(this,arguments),this.defines.TANGRAM_EXTRUDE_LINES=!0,this.defines.TANGRAM_TEXTURE_COORDS=!0,this.outline_feature_style={},this.inline_feature_style=this.feature_style,this.dash_textures={}},calcDistance:(e,t)=>J.evalCachedDistanceProperty(e,t)||0,calcDistanceNextZoom(e,t){t.zoom++;let n=this.calcDistance(e,t);return t.zoom--,n},calcWidth(e,t,n){let r,i=this.calcDistance(e.width,n);if(!(i<0)){if(r=e.next_width?this.calcDistanceNextZoom(e.next_width,n):i/2,0===i&&0===r||r<0)return!1;if(t.width_unscaled=i,t.next_width_unscaled=r,e.next_width){r*=2;let e=.5*(i+r);t.width=e*n.units_per_meter_overzoom,t.width_scale=1-r/e}else t.width=i*n.units_per_meter_overzoom,t.width_scale=0;return e.texcoords&&(e.inline_texcoord_width?t.texcoord_width=e.inline_texcoord_width:t.texcoord_width=(t.width_unscaled||t.next_width_unscaled)*n.units_per_meter_overzoom/n.tile.overzoom2),!0}},calcOffset(e,t,n){if(e.offset_precalc)t.offset=e.offset_precalc,t.offset_scale=e.offset_scale_precalc;else if(e.offset){let r=this.calcDistance(e.offset,n);if(e.next_offset){let i=2*this.calcDistanceNextZoom(e.next_offset,n);Math.abs(r)>=Math.abs(i)?(t.offset=r*n.units_per_meter_overzoom,t.offset_scale=0!==r?1-i/r:0):(t.offset=i*n.units_per_meter_overzoom,t.offset_scale=0!==i?-1*(1-r/i):0)}else t.offset=r*n.units_per_meter_overzoom,t.offset_scale=0}else t.offset=0,t.offset_scale=0},_parseFeature(e,t,n){var r=this.feature_style;if(!1!==this.calcWidth(t,r,n)&&(this.calcOffset(t,r,n),r.color=this.parseColor(t.color,n),r.color)){if(r.alpha=J.evalCachedProperty(t.alpha,n),r.variant=t.variant,r.z=J.evalCachedDistanceProperty(t.z,n)||J.defaults.z,r.height=e.properties.height||J.defaults.height,r.extrude=J.evalProperty(t.extrude,n),r.extrude&&("number"==typeof r.extrude?r.height=r.extrude:Array.isArray(r.extrude)&&(r.height=r.extrude[1])),r.extrude&&r.height&&(r.z+=r.height),r.z*=G.height_scale,r.cap=t.cap,r.join=t.join,r.miter_limit=t.miter_limit,r.tile_edges=t.tile_edges,r.outline=r.outline||{width:{},next_width:{},preprocessed:!0},t.outline&&!1!==t.outline.visible&&t.outline.color&&t.outline.width){let e=2*this.calcDistance(t.outline.width,n),i=2*this.calcDistanceNextZoom(t.outline.next_width,n);0===e&&0===i||e<0||i<0?(r.outline.width.value=null,r.outline.next_width.value=null,r.outline.color=null,r.outline.inline_texcoord_width=null,r.outline.texcoords=!1):(r.outline.width.value=e+r.width_unscaled,r.outline.next_width.value=i+r.next_width_unscaled,r.outline.inline_texcoord_width=r.texcoord_width,r.outline.offset_precalc=r.offset,r.outline.offset_scale_precalc=r.offset_scale,r.outline.color=t.outline.color,r.outline.alpha=t.outline.alpha,r.outline.interactive=t.outline.interactive,r.outline.cap=t.outline.cap,r.outline.join=t.outline.join,r.outline.miter_limit=t.outline.miter_limit,r.outline.texcoords=t.outline.texcoords,r.outline.extrude=t.outline.extrude,r.outline.z=t.outline.z,r.outline.style=t.outline.style,r.outline.variant=t.outline.variant,t.outline.order?r.outline.order=this.parseOrder(t.outline.order,n):r.outline.order=r.order,r.outline.order>r.order&&(r.outline.order=r.order),r.outline.order-=.5)}else r.outline.width.value=null,r.outline.next_width.value=null,r.outline.color=null,r.outline.inline_texcoord_width=null;return r}},_preprocess(e){if(e.color=J.createColorPropertyCache(e.color),e.alpha=J.createPropertyCache(e.alpha),e.width=J.createPropertyCache(e.width,J.parseUnits),e.width&&e.width.type!==J.CACHE_TYPE.STATIC&&(e.next_width=J.createPropertyCache(e.width,J.parseUnits)),e.offset=e.offset&&J.createPropertyCache(e.offset,J.parseUnits),e.offset&&e.offset.type!==J.CACHE_TYPE.STATIC&&(e.next_offset=J.createPropertyCache(e.offset,J.parseUnits)),e.z=J.createPropertyCache(e.z,J.parseUnits),e.dash=void 0!==e.dash?e.dash:this.dash,e.dash_key=e.dash&&this.dashTextureKey(e.dash),e.dash_background_color=void 0!==e.dash_background_color?e.dash_background_color:this.dash_background_color,e.dash_background_color=e.dash_background_color&&J.parseColor(e.dash_background_color),e.texture_merged=e.dash_key||(void 0!==e.texture?e.texture:this.texture),e.texcoords=this.texcoords||e.texture_merged?1:0,this.computeVariant(e),e.outline){e.outline.is_outline=!0,e.outline.style=e.outline.style||this.name,e.outline.color=J.createColorPropertyCache(e.outline.color),e.outline.alpha=J.createPropertyCache(e.outline.alpha),e.outline.width=J.createPropertyCache(e.outline.width,J.parseUnits),e.outline.next_width=J.createPropertyCache(e.outline.width,J.parseUnits),e.outline.interactive=null!=e.outline.interactive?e.outline.interactive:e.interactive,e.outline.cap=e.outline.cap||e.cap,e.outline.join=e.outline.join||e.join,e.outline.miter_limit=null!=e.outline.miter_limit?e.outline.miter_limit:e.miter_limit,e.outline.offset=e.offset,e.outline.extrude=e.extrude,e.outline.z=e.z;let t=this.styles[e.outline.style];t?(e.outline.dash=void 0!==e.outline.dash?e.outline.dash:t.dash,e.outline.texture=void 0!==e.outline.texture?e.outline.texture:t.texture,null!=e.outline.dash?(e.outline.dash_key=e.outline.dash&&this.dashTextureKey(e.outline.dash),e.outline.texture_merged=e.outline.dash_key):null===e.outline.dash||null!=e.outline.texture?(e.outline.dash_key=null,e.outline.texture_merged=e.outline.texture):(e.outline.dash=e.dash,e.outline.dash_key=e.outline.dash&&this.dashTextureKey(e.outline.dash),e.outline.texture_merged=e.outline.dash_key),e.outline.dash_background_color=void 0!==e.outline.dash_background_color?e.outline.dash_background_color:t.dash_background_color,e.outline.dash_background_color=void 0!==e.outline.dash_background_color?e.outline.dash_background_color:e.dash_background_color,e.outline.dash_background_color=e.outline.dash_background_color&&J.parseColor(e.outline.dash_background_color),e.outline.texcoords=t.texcoords||e.outline.texture_merged?1:0,void 0===e.outline.blend_order&&null!=e.blend_order&&(e.outline.blend_order=e.blend_order),t.computeVariant(e.outline)):(m({level:"warn",once:!0},`Layer group '${e.layers.join(", ")}': line 'outline' specifies non-existent draw style '${e.outline.style}' (or maybe the style is defined but is missing a 'base' or has another error), skipping outlines for features matching this layer group`),e.outline=null)}return e},dashTextureKey:e=>"__dash_"+JSON.stringify(e),getDashTexture(e){let t=this.dashTextureKey(e);if(null==this.dash_textures[t]){this.dash_textures[t]=!0;const n=function(e,t={}){const n=t.dash_color||yt,r=t.background_color||vt,i=e,s=t.scale||1;i.length%2==1&&Array.prototype.push.apply(i,i);let o=!0,a=[];for(let e=0;e<i.length;e++){let t=Math.floor(i[e]*s);for(let e=0;e<t;e++)Array.prototype.push.apply(a,o?n:r);o=!o}return a.reverse(),a=new Uint8Array(a),{pixels:a,length:a.length/4}}(e,{scale:20});k.create(this.gl,t,{data:n.pixels,height:n.length,width:1,filtering:"nearest"})}},async endData(e){const t=await Pe.endData.call(this,e);if(t){t.uniforms.u_has_line_texture=!1,t.uniforms.u_texture=k.default,t.uniforms.u_v_scale_adjust=G.tile_scale;let n=[];for(let r in t.meshes){let i=t.meshes[r].variant;if(i.texture){let s=t.meshes[r].uniforms=t.meshes[r].uniforms||{};if(s.u_has_line_texture=!0,s.u_texture=i.texture,s.u_texture_ratio=1,i.dash&&(s.u_v_scale_adjust=20*G.tile_scale,s.u_has_dash=null!=i.dash_background_color?1:0,s.u_dash_background_color=i.dash_background_color||[0,0,0,0]),i.dash_key&&null==this.dash_textures[i.dash_key]){this.dash_textures[i.dash_key]=!0;try{await a.postMessage(this.main_thread_target+".getDashTexture",i.dash)}catch(e){m("trace",`${this.name}: line dash texture create failed because style no longer on main thread`)}}if(null==k.textures[i.texture])n.push(k.syncTexturesToWorker([i.texture]).then(e=>{let t=e[i.texture];t&&(s.u_texture_ratio=t.height/t.width)}));else{let e=k.textures[i.texture];s.u_texture_ratio=e.height/e.width}}}await Promise.all(n)}return t},computeVariant(e){let t=e.offset?1:0;t+="/"+e.texcoords,t+="/"+(e.interactive?1:0),t+="/"+(e.extrude||e.z?1:0),t+="/"+e.is_outline,e.dash_key&&(t+=e.dash_key,e.dash_background_color&&(t+=e.dash_background_color)),e.texture_merged&&(t+=e.texture_merged);const n=this.getBlendOrderForDraw(e);t+="/"+n,t=P(t),e.variant=t,null==this.variants[t]&&(this.variants[t]={key:t,blend_order:n,mesh_order:e.is_outline?0:1,selection:e.interactive?1:0,offset:e.offset?1:0,z_or_offset:e.offset||e.extrude||e.z?1:0,texcoords:e.texcoords,texture:e.texture_merged,dash:e.dash,dash_key:e.dash_key,dash_background_color:e.dash_background_color})},vertexLayoutForMeshVariant(e){if(null==this.vertex_layouts[e.key]){const t=[{name:"a_position",size:4,type:fe.SHORT,normalized:!1},{name:"a_extrude",size:2,type:fe.SHORT,normalized:!1},{name:"a_offset",size:2,type:fe.SHORT,normalized:!1,static:e.offset?null:[0,0]},{name:"a_z_and_offset_scale",size:2,type:fe.SHORT,normalized:!1,static:e.z_or_offset?null:[0,0]},{name:"a_texcoord",size:2,type:fe.UNSIGNED_SHORT,normalized:!0,static:e.texcoords?null:[0,0]},{name:"a_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.key]=new Le(t)}return this.vertex_layouts[e.key]},meshVariantTypeForDraw(e){return this.variants[e.variant]},makeVertexTemplate(e,t){let n=0;return this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=1024*e.width_scale,this.vertex_template[n++]=this.scaleOrder(e.order),this.vertex_template[n++]=0,this.vertex_template[n++]=0,t.variant.offset&&(this.vertex_template[n++]=0,this.vertex_template[n++]=0),t.variant.z_or_offset&&(this.vertex_template[n++]=e.z||0,this.vertex_template[n++]=1024*e.offset_scale),t.variant.texcoords&&(this.vertex_template[n++]=0,this.vertex_template[n++]=0),this.vertex_template[n++]=255*e.color[0],this.vertex_template[n++]=255*e.color[1],this.vertex_template[n++]=255*e.color[2],this.vertex_template[n++]=255*(null!=e.alpha?e.alpha:e.color[3]),t.variant.selection&&(this.vertex_template[n++]=255*e.selection_color[0],this.vertex_template[n++]=255*e.selection_color[1],this.vertex_template[n++]=255*e.selection_color[2],this.vertex_template[n++]=255*e.selection_color[3]),this.addCustomAttributesToVertexTemplate(e,n),this.vertex_template},buildLines(e,t,n,r){if(this.feature_style=this.outline_feature_style,t.outline&&null!=t.outline.color&&null!=t.outline.width.value){var i=this.styles[t.outline.style];i&&i.addFeature(n.feature,t.outline,n)}this.feature_style=this.inline_feature_style;let s=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),o=s.vertex_data,a=o.vertex_layout;return function(e,t,n,r,i,s,o,a){var l,u=t.cap?nt[t.cap]:nt.butt,c=t.join?rt[t.join]:rt.miter;if(c===rt.miter){const e=t.miter_limit||3;var h=e*e}i.a_texcoord&&(l=1/(t.texcoord_width*it));var d={closed_polygon:s,remove_tile_edges:o,tile_edge_tolerance:a,miter_len_sq:h,join_type:c,cap_type:u,vertex_data:n,vertex_template:r,half_width:t.width/2,extrude_index:i.a_extrude,offset_index:i.a_offset,v_scale:l,texcoord_index:i.a_texcoord,texcoord_width:t.texcoord_width,offset:t.offset,geom_count:0};for(let t=0;t<e.length;t++)lt(e[t],d);if(d.extra_lines)for(let e=0;e<d.extra_lines.length;e++)lt(d.extra_lines[e],d);return d.geom_count}(e,t,o,this.makeVertexTemplate(t,s),a.index,r&&r.closed_polygon,!t.tile_edges&&r&&r.remove_tile_edges,G.tile_scale*n.tile.pad_scale*2)},buildPolygons(e,t,n){let r=0;for(let i=0;i<e.length;i++)r+=this.buildLines(e[i],t,n,{closed_polygon:!0,remove_tile_edges:!0});return r}});const xt=128/Math.PI,wt=16384/Math.PI,At=[0,2,2,0],Et=[1,1,3,3],St=new Array(4),Tt=["left","top-left","bottom-left"],kt=["right","top-right","bottom-right"],Ot=["top","top-left","top-right"],Rt=["bottom","bottom-left","bottom-right"],Ct={computeOffset(e,t,n,r=null){if(!n||"center"===n)return e;let i=[e[0],e[1]];return r=r||this.default_buffer,this.isLeftAnchor(n)?(i[0]-=t[0]/2,"left"===n&&(i[0]-=r[0])):this.isRightAnchor(n)&&(i[0]+=t[0]/2,"right"===n&&(i[0]+=r[1])),this.isTopAnchor(n)?(i[1]-=t[1]/2,"top"===n&&(i[1]-=r[2])):this.isBottomAnchor(n)&&(i[1]+=t[1]/2,"bottom"===n&&(i[1]+=r[3])),i},alignForAnchor(e){if(e&&"center"!==e){if(this.isLeftAnchor(e))return"right";if(this.isRightAnchor(e))return"left"}return"center"},isLeftAnchor:e=>Tt.indexOf(e)>-1,isRightAnchor:e=>kt.indexOf(e)>-1,isTopAnchor:e=>Ot.indexOf(e)>-1,isBottomAnchor:e=>Rt.indexOf(e)>-1,default_buffer:[2.5,2.5,1.5,.75],zero_buffer:[0,0,0,0]};function Pt(e,t){return!(e[2]<t[0]||e[0]>t[2]||e[3]<t[1]||e[1]>t[3])}const Mt=[[1,0],[0,1]],Nt=[],It=[];let Dt,Ft,zt,Lt;class jt{constructor(e,t,n,r,i){this.dimension=[r/2,i/2],this.angle=n,this.centroid=[e,t],this.quad=null,this.axis_0=null,this.axis_1=null,this.update()}toJSON(){return{x:this.centroid[0],y:this.centroid[1],a:this.angle,w:this.dimension[0],h:this.dimension[1]}}getExtent(){return 0===this.angle?[this.quad[0],this.quad[1],this.quad[4],this.quad[5]]:[Math.min(this.quad[0],this.quad[2],this.quad[4],this.quad[6]),Math.min(this.quad[1],this.quad[3],this.quad[5],this.quad[7]),Math.max(this.quad[0],this.quad[2],this.quad[4],this.quad[6]),Math.max(this.quad[1],this.quad[3],this.quad[5],this.quad[7])]}updateAxes(){this.axis_0=ye.normalize([this.quad[4]-this.quad[6],this.quad[5]-this.quad[7]]),this.axis_1=ye.normalize([this.quad[4]-this.quad[2],this.quad[5]-this.quad[3]])}update(){const e=this.centroid,t=this.dimension[0],n=this.dimension[1];if(0===this.angle)this.quad=[e[0]-t,e[1]-n,e[0]+t,e[1]-n,e[0]+t,e[1]+n,e[0]-t,e[1]+n],this.axis_0=Mt[0],this.axis_1=Mt[1];else{let r=Math.cos(this.angle)*t,i=Math.sin(this.angle)*t,s=-Math.sin(this.angle)*n,o=Math.cos(this.angle)*n;this.quad=[e[0]-r-s,e[1]-i-o,e[0]+r-s,e[1]+i-o,e[0]+r+s,e[1]+i+o,e[0]-r+s,e[1]-i+o],this.updateAxes()}}static projectToAxis(e,t,n){let r=e.quad;return Dt=r[0]*t[0]+r[1]*t[1],Ft=r[2]*t[0]+r[3]*t[1],zt=r[4]*t[0]+r[5]*t[1],Lt=r[6]*t[0]+r[7]*t[1],n[0]=Math.min(Dt,Ft,zt,Lt),n[1]=Math.max(Dt,Ft,zt,Lt),n}static axisCollide(e,t,n,r){return jt.projectToAxis(e,n,Nt),jt.projectToAxis(t,n,It),!(It[0]>Nt[1]||It[1]<Nt[0]||(jt.projectToAxis(e,r,Nt),jt.projectToAxis(t,r,It),It[0]>Nt[1]||It[1]<Nt[0]))}static intersect(e,t){return jt.axisCollide(e,t,e.axis_0,e.axis_1)&&jt.axisCollide(e,t,t.axis_0,t.axis_1)}}class Vt{constructor(e,t={}){this.id=Vt.nextLabelId(),this.type="",this.size=e,this.layout=t,this.position=null,this.angle=0,this.anchor=Array.isArray(this.layout.anchor)?this.layout.anchor[0]:this.layout.anchor,this.placed=null,this.offset=t.offset,this.unit_scale=this.layout.units_per_pixel,this.aabb=null,this.obb=null,this.align="center",this.throw_away=!1}toJSON(){return{id:this.id,type:this.type,obb:this.obb.toJSON(),position:this.position,angle:this.angle,size:this.size,offset:this.offset,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:Ut(this.layout)}}update(){this.align=this.layout.align||Ct.alignForAnchor(this.anchor)}occluded(e,t=null){let n=!1,r=e.aabb,i=e.obb;return r.length>0&&function(e,t,n){for(let r=0;r<t.length&&(!Pt(e,t[r])||null==n(r));r++);}(this.aabb,r,e=>{if(!t||r[e]!==t.aabb)return 0===this.obb.angle&&0===i[e].angle||jt.intersect(this.obb,i[e])?(n=!0,!0):void 0}),n}inTileBounds(){return this.aabb[0]>=0&&this.aabb[1]>-G.tile_scale&&this.aabb[0]<G.tile_scale&&this.aabb[1]<=0||this.aabb[2]>=0&&this.aabb[3]>-G.tile_scale&&this.aabb[2]<G.tile_scale&&this.aabb[3]<=0}mayRepeatAcrossTiles(){if(this.layout.collide)return!0;const e=this.layout.repeat_distance;return 0!==e&&(Math.abs(this.position[0])<e||Math.abs(this.position[0]-G.tile_scale)<e||Math.abs(this.position[1])<e||Math.abs(-(this.position[1]-G.tile_scale))<e)}discard(e,t=null){return!!this.throw_away||this.occluded(e,t)}}function Ut(e){return{priority:e.priority,collide:e.collide,repeat_distance:e.repeat_distance,repeat_group:e.repeat_group,buffer:e.buffer,italic:e.italic}}Vt.add=function(e,t){if(e.placed=!0,e.aabb&&(t.aabb.push(e.aabb),t.obb.push(e.obb)),e.aabbs)for(let n=0;n<e.aabbs.length;n++)t.aabb.push(e.aabbs[n]),t.obb.push(e.obbs[n])},Vt.id=0,Vt.id_prefix=0,Vt.id_multiplier=0,Vt.nextLabelId=function(){return Vt.id_prefix+Vt.id++*Vt.id_multiplier},Vt.epsilon=.9999;class Bt{constructor(e,t){this.key=e,this.repeat_dist=t,this.repeat_dist_sq=this.repeat_dist*this.repeat_dist,this.positions=[]}check(e){let t=e.position;for(let e=0;e<this.positions.length;e++){let n=this.positions[e],r=t[0]-n[0],i=t[1]-n[1];if(r*r+i*i<this.repeat_dist_sq)return!0}}add(e){e&&e.position&&this.positions.push(e.position)}static clear(e){this.groups[e]={}}static check(e,t,n){if(t.repeat_distance&&t.repeat_group&&this.groups[n][t.repeat_group])return this.groups[n][t.repeat_group].check(e)}static add(e,t,n){t.repeat_distance&&t.repeat_group&&(null==this.groups[n][t.repeat_group]&&(this.groups[n][t.repeat_group]=new Bt(t.repeat_group,t.repeat_distance*t.repeat_scale)),this.groups[n][t.repeat_group].add(e))}}Bt.groups={};class Gt{constructor(e,t){this.anchor=e,this.span=t,this.cells={}}addLabel(e){e.aabb&&this.addLabelBboxes(e,e.aabb),e.aabbs&&e.aabbs.forEach(t=>this.addLabelBboxes(e,t))}addLabelBboxes(e,t){const n=[Math.max(Math.floor((t[0]-this.anchor.x)/this.span),0),Math.max(Math.floor(-(t[1]-this.anchor.y)/this.span),0),Math.max(Math.floor((t[2]-this.anchor.x)/this.span),0),Math.max(Math.floor(-(t[3]-this.anchor.y)/this.span),0)];e.cells=[];for(let t=n[1];t<=n[3];t++){this.cells[t]=this.cells[t]||{};for(let r=n[0];r<=n[2];r++)this.cells[t][r]=this.cells[t][r]||{aabb:[],obb:[]},e.cells.push(this.cells[t][r])}}}const $t={tiles:{},grid:null,initGrid(e){this.grid=null==e?null:new Gt(e.anchor,e.span)},startTile(e,{apply_repeat_groups:t=!0,return_hidden:n=!1}={}){let r=this.tiles[e]={bboxes:{aabb:[],obb:[]},objects:{},labels:{},styles:{},repeat:t,return_hidden:n};null==r.complete&&(r.complete=new Promise((e,t)=>{r.resolve=e,r.reject=t}))},resetTile(e){delete this.tiles[e]},abortTile(e){this.tiles[e]&&this.tiles[e].resolve&&this.tiles[e].resolve([]),this.resetTile(e)},addStyle(e,t){this.tiles[t].styles[e]=!0},collide(e,t,n){let r=this.tiles[n];if(!r)return m("trace","Collision.collide() called with null tile",n,this.tiles,t,e),Promise.resolve([]);let i=r.objects;for(let n=0;n<e.length;n++){let r=e[n],s=r.label.layout.priority;i[s]=i[s]||{},i[s][t]=i[s][t]||[],i[s][t].push(r)}return delete r.styles[t],0===Object.keys(r.styles).length&&this.endTile(n),r.complete.then(()=>(r.resolve=null,r.labels[t]||[]))},endTile(e){let t=this.tiles[e],n=t.labels;this.grid&&this.addLabelsToGrid(e),t.repeat&&Bt.clear(e);let r=Object.keys(t.objects).sort((e,t)=>e-t);for(let i=0;i<r.length;i++){let s=t.objects[r[i]];if(s)for(let r in s){let i=s[r];n[r]=n[r]||[];for(let s=0;s<i.length;s++){let o=i[s];this.canBePlaced(o,e,o.linked,t)?o.linked?this.canBePlaced(o.linked,e,o,t)?(o.show=!0,(o.label.breach||o.linked.label.breach)&&(o.label.breach=!0,o.linked.label.breach=!0),(o.label.may_repeat_across_tiles||o.linked.label.may_repeat_across_tiles)&&(o.label.may_repeat_across_tiles=!0,o.linked.label.may_repeat_across_tiles=!0),n[r].push(o),this.place(o,e,t),this.place(o.linked,e,t)):t.return_hidden&&(o.show=!1,n[r].push(o)):(o.show=!0,n[r].push(o),this.place(o,e,t)):t.return_hidden&&(o.show=!1,n[r].push(o))}}}delete this.tiles[e],t.resolve()},addLabelsToGrid(e){const t=this.tiles[e];for(const e in t.objects){const n=t.objects[e];if(n)for(const e in n)n[e].forEach(e=>this.grid.addLabel(e.label))}},canBePlaced(e,t,n=null,{repeat:r=!0}={}){let i=e.label,s=e.label.layout;if(null!=i.placed)return i.placed;let o=!s.collide;if(o||(o=this.grid&&i.cells?i.cells.reduce((e,t)=>(e&&i.discard(t,n&&n.label)&&(e=!1),e),!0):!i.discard(this.tiles[t].bboxes,n&&n.label)),o){if(!r||!Bt.check(i,s,t))return!0;i.placed=!1}else s.collide&&(i.placed=!1);return i.placed},place({label:e},t,{repeat:n=!0}){null==e.placed&&(n&&Bt.add(e,e.layout,t),this.grid&&e.cells?e.cells.forEach(t=>Vt.add(e,t)):Vt.add(e,this.tiles[t].bboxes))}};class qt extends Vt{constructor(e,t,n,r=0){super(t,n),this.type="point",this.position=[e[0],e[1]],this.angle=r,this.parent=this.layout.parent,this.update(),this.start_anchor_index=1,this.degenerate=!(this.size[0]||this.size[1]||this.layout.buffer[0]||this.layout.buffer[1]),this.throw_away=!1}update(){super.update(),this.computeOffset(),this.updateBBoxes()}computeOffset(){if(this.offset=[this.layout.offset[0],this.layout.offset[1]],this.parent){let e=this.parent;this.offset=Ct.computeOffset(this.offset,e.size,e.anchor,Ct.zero_buffer),this.offset=Ct.computeOffset(this.offset,e.size,this.anchor,Ct.zero_buffer),e.offset!==J.zeroPair&&(this.offset===J.zeroPair?this.offset=e.offset:(this.offset[0]+=e.offset[0],this.offset[1]+=e.offset[1]))}this.offset=Ct.computeOffset(this.offset,this.size,this.anchor)}updateBBoxes(){let e=(this.size[0]+2*this.layout.buffer[0])*this.unit_scale*Vt.epsilon,t=(this.size[1]+2*this.layout.buffer[1])*this.unit_scale*Vt.epsilon;this.layout.italic&&(e+=5*this.unit_scale),this.obb=new jt(this.position[0]+this.offset[0]*this.unit_scale,this.position[1]-this.offset[1]*this.unit_scale,-this.angle,e,t),this.aabb=this.obb.getExtent(),this.inTileBounds&&(this.breach=!this.inTileBounds()),this.mayRepeatAcrossTiles&&(this.may_repeat_across_tiles=this.mayRepeatAcrossTiles())}discard(e,t=null){if(this.degenerate)return!1;if(super.discard(e,t)){if(Array.isArray(this.layout.anchor))for(let n=this.start_anchor_index;n<this.layout.anchor.length;n++)if(this.anchor=this.layout.anchor[n],this.update(),!super.discard(e,t))return!1;return!0}return!1}}qt.PLACEMENT={VERTEX:0,MIDPOINT:1,SPACED:2,CENTROID:3};const Ht=qt.PLACEMENT;function Wt(e,t,n){const r=[],i=n.placement,s=Math.max(t[0],t[1])*n.placement_min_length_ratio*n.units_per_pixel;if(i===Ht.SPACED){let i=function(e,t,n){let r=n.units_per_pixel,i=(n.placement_spacing||80)*r,s=function(e){let t=0;for(let n=0;n<e.length-1;n++)t+=Kt(e[n],e[n+1]);return t}(e);if(s<=t)return!1;let o=Math.max(Math.floor(s/i),1),a=[],l=[],u=.5*(s-(o-1)*i);for(let r=0;r<o;r++){let{position:r,angle:s}=Xt(e,u,t,n);null!=r&&null!=s&&(a.push(r),l.push(s)),u+=i}return{positions:a,angles:l}}(e,s,n);if(!i)return[];let o=i.positions,a=i.angles;for(let e=0;e<o.length;e++){let i=o[e],s=a[e];!0!==n.tile_edges&&Be(i)||r.push(new qt(i,t,n,s))}}else if(i===Ht.VERTEX){let i,s;for(let o=0;o<e.length-1;o++)if(i=e[o],s=e[o+1],!0===n.tile_edges||!Be(i)){const e=Zt(i,s,n.angle);r.push(new qt(i,t,n,e))}const o=Zt(i,s,n.angle);r.push(new qt(s,t,n,o))}else if(i===Ht.MIDPOINT)for(let i=0;i<e.length-1;i++){let o=e[i],a=e[i+1],l=[.5*(o[0]+a[0]),.5*(o[1]+a[1])];if((!0===n.tile_edges||!Be(l))&&(!s||Kt(o,a)>s)){const e=Zt(o,a,n.angle);r.push(new qt(l,t,n,e))}}return r}function Zt(e,t,n=0){return"auto"===n?Math.atan2(t[0]-e[0],t[1]-e[1]):n}function Kt(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2))}function Xt(e,t,n,r){let i,s,o=0;for(let a=0;a<e.length-1;a++){let l=e[a],u=e[a+1];const c=Kt(l,u);if(!(c<=n)&&(o+=c,o>t)){i=Yt(l,u,o-t),s=Zt(l,u,r.angle);break}}return{position:i,angle:s}}function Yt(e,t,n){let r=n/Kt(e,t);return[r*e[0]+(1-r)*t[0],r*e[1]+(1-r)*t[1]]}const Qt={key:e=>[e.style,e.weight,e.family,e.px_size,e.fill,e.stroke,e.stroke_width,e.underline_width,e.background_color,e.background_width,e.background_stroke_color,e.background_stroke_width,e.transform,e.text_wrap,e.max_lines,e.supersample,_.device_pixel_ratio].join("/"),defaults:{style:"normal",weight:"normal",size:"12px",px_size:12,family:"Helvetica",fill:[1,1,1,1],text_wrap:15,max_lines:5,align:"center"},compute(e,t){const n={};e.font=e.font||this.defaults,n.supersample=e.supersample_text?1.5:1,n.can_articulate=e.can_articulate,n.fill=J.evalCachedColorPropertyWithAlpha(e.font.fill,e.font.alpha,t),n.fill=_.toCSSColor(n.fill),e.font.stroke&&e.font.stroke.color&&(n.stroke=J.evalCachedColorPropertyWithAlpha(e.font.stroke.color,e.font.stroke.alpha,t),n.stroke=_.toCSSColor(n.stroke),n.stroke_width=J.evalCachedProperty(e.font.stroke.width,t)),!0!==e.font.underline||n.can_articulate||(n.underline_width=1.5*n.supersample),e.font.background&&!n.can_articulate&&(n.background_color=J.evalCachedColorPropertyWithAlpha(e.font.background.color,e.font.background.alpha,t),n.background_color=_.toCSSColor(n.background_color),n.background_color&&(n.background_width=J.evalCachedProperty(e.font.background.width,t)),n.background_stroke_color=e.font.background.stroke&&e.font.background.stroke.color&&J.evalCachedColorPropertyWithAlpha(e.font.background.stroke.color,e.font.background.stroke.alpha,t),n.background_stroke_color&&(n.background_stroke_color=_.toCSSColor(n.background_stroke_color),n.background_stroke_width=null!=e.font.background.stroke.width?J.evalCachedProperty(e.font.background.stroke.width,t):1)),n.weight=J.evalCachedProperty(e.font.weight,t)||this.defaults.weight,"number"==typeof n.weight&&(n.weight=Math.min(Math.max(n.weight,1),1e3)),e.font.family?(n.family=e.font.family,n.family!==this.defaults.family&&(n.family+=", "+this.defaults.family)):n.family=this.defaults.family,n.style=e.font.style||this.defaults.style,n.transform=e.font.transform,n.px_size=J.evalCachedProperty(e.font.px_size,t)*n.supersample,n.font_css=this.fontCSS(n);let r=e.text_wrap;return null!=r||n.can_articulate||(r=!0),!0===r&&(r=this.defaults.text_wrap),n.text_wrap=r,n.max_lines=e.max_lines||this.defaults.max_lines,n},fontCSS:({style:e,weight:t,px_size:n,family:r})=>[e,t,n+"px",r].filter(e=>e).join(" ")};var Jt,en,tn={exports:{}},nn=M((Jt||(Jt=1,en=tn,function(){function e(e,t){document.addEventListener?e.addEventListener("scroll",t,!1):e.attachEvent("scroll",t)}function t(e){this.a=document.createElement("div"),this.a.setAttribute("aria-hidden","true"),this.a.appendChild(document.createTextNode(e)),this.b=document.createElement("span"),this.c=document.createElement("span"),this.h=document.createElement("span"),this.f=document.createElement("span"),this.g=-1,this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.b.appendChild(this.h),this.c.appendChild(this.f),this.a.appendChild(this.b),this.a.appendChild(this.c)}function n(e,t){e.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;left:-999px;white-space:nowrap;font:"+t+";"}function r(e){var t=e.a.offsetWidth,n=t+100;return e.f.style.width=n+"px",e.c.scrollLeft=n,e.b.scrollLeft=e.b.scrollWidth+100,e.g!==t&&(e.g=t,!0)}function i(t,n){function i(){var e=s;r(e)&&e.a.parentNode&&n(e.g)}var s=t;e(t.b,i),e(t.c,i),r(t)}function s(e,t){var n=t||{};this.family=e,this.style=n.style||"normal",this.weight=n.weight||"normal",this.stretch=n.stretch||"normal"}var o=null,a=null,l=null,u=null;function c(){if(null===l){var e=document.createElement("div");try{e.style.font="condensed 100px sans-serif"}catch(e){}l=""!==e.style.font}return l}function h(e,t){return[e.style,e.weight,c()?e.stretch:"","100px",t].join(" ")}s.prototype.load=function(e,r){var s=this,l=e||"BESbswy",c=0,d=r||3e3,f=(new Date).getTime();return new Promise(function(e,r){var p;if(null===u&&(u=!!document.fonts),(p=u)&&(null===a&&(a=/OS X.*Version\/10\..*Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),p=!a),p){p=new Promise(function(e,t){!function n(){(new Date).getTime()-f>=d?t():document.fonts.load(h(s,'"'+s.family+'"'),l).then(function(t){1<=t.length?e():setTimeout(n,25)},function(){t()})}()});var g=new Promise(function(e,t){c=setTimeout(t,d)});Promise.race([g,p]).then(function(){clearTimeout(c),e(s)},function(){r(s)})}else!function(e){document.body?e():document.addEventListener?document.addEventListener("DOMContentLoaded",function t(){document.removeEventListener("DOMContentLoaded",t),e()}):document.attachEvent("onreadystatechange",function t(){"interactive"!=document.readyState&&"complete"!=document.readyState||(document.detachEvent("onreadystatechange",t),e())})}(function(){function a(){var t;(t=-1!=m&&-1!=_||-1!=m&&-1!=y||-1!=_&&-1!=y)&&((t=m!=_&&m!=y&&_!=y)||(null===o&&(t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),o=!!t&&(536>parseInt(t[1],10)||536===parseInt(t[1],10)&&11>=parseInt(t[2],10))),t=o&&(m==v&&_==v&&y==v||m==b&&_==b&&y==b||m==x&&_==x&&y==x)),t=!t),t&&(w.parentNode&&w.parentNode.removeChild(w),clearTimeout(c),e(s))}var u=new t(l),p=new t(l),g=new t(l),m=-1,_=-1,y=-1,v=-1,b=-1,x=-1,w=document.createElement("div");w.dir="ltr",n(u,h(s,"sans-serif")),n(p,h(s,"serif")),n(g,h(s,"monospace")),w.appendChild(u.a),w.appendChild(p.a),w.appendChild(g.a),document.body.appendChild(w),v=u.a.offsetWidth,b=p.a.offsetWidth,x=g.a.offsetWidth,function e(){if((new Date).getTime()-f>=d)w.parentNode&&w.parentNode.removeChild(w),r(s);else{var t=document.hidden;!0!==t&&void 0!==t||(m=u.a.offsetWidth,_=p.a.offsetWidth,y=g.a.offsetWidth,a()),c=setTimeout(e,50)}}(),i(u,function(e){m=e,a()}),n(u,h(s,'"'+s.family+'",sans-serif')),i(p,function(e){_=e,a()}),n(p,h(s,'"'+s.family+'",serif')),i(g,function(e){y=e,a()}),n(g,h(s,'"'+s.family+'",monospace'))})})},en.exports=s}()),tn.exports));const rn={fonts_loaded:Promise.resolve(),last_loaded:null,loadFonts(e){const t=JSON.stringify(e)===this.last_loaded;if(e&&!t){const t=[];for(const n in e)Array.isArray(e[n])?e[n].forEach(e=>t.push(this.loadFontFace(n,e))):t.push(this.loadFontFace(n,e[n]));this.last_loaded=JSON.stringify(e),this.fonts_loaded=Promise.all(t.filter(e=>e))}return this.fonts_loaded},async loadFontFace(e,t){if(null==t||"object"!=typeof t&&"external"!==t)return;const n={family:e};"object"==typeof t&&(Object.assign(n,t),"string"==typeof t.url&&await this.injectFontFace(n));try{n.weight="string"==typeof n.weight?n.weight.split(" ")[0]:n.weight;const t=new nn(e,n);await t.load(),m("debug",`Font face '${e}' is available`,n)}catch(t){m("warn",`Font face '${e}' is NOT available`,n,t)}},async injectFontFace({family:e,url:t,weight:n,style:r}){void 0===this.supports_native_font_loading&&(this.supports_native_font_loading=void 0!==window.FontFace);let i=t;if("blob:"===t.slice(0,5)){i=(await _.io(t,6e4,"arraybuffer")).body;let e=new Uint8Array(i);if(this.supports_native_font_loading)i=e;else{let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i="data:font/opentype;base64,"+btoa(t)}}if(this.supports_native_font_loading){let t;"string"==typeof i?t=new FontFace(e,`url(${encodeURI(i)})`,{weight:n,style:r}):i instanceof Uint8Array&&(t=new FontFace(e,i,{weight:n,style:r})),document.fonts.add(t),m("trace","Adding FontFace to document.fonts:",t)}else{let t=`\n @font-face {\n font-family: '${e}';\n font-weight: ${n||"normal"};\n font-style: ${r||"normal"};\n src: url(${encodeURI(i)});\n }`,s=document.createElement("style");s.appendChild(document.createTextNode("")),document.head.appendChild(s),s.sheet.insertRule(t,0),m("trace","Injecting CSS font face:",t)}}},sn=new RegExp("[֑-߿יִ-﷽ﹰ-ﻼ]");function on(e){return sn.test(e)}const an="\0-/:-@[-`{-¿×÷ʹ-˿ -⯿‐-\u2029 -⯿",ln=new RegExp("["+an+"]+");function un(e){return ln.test(e)}const cn=new RegExp("^["+an+"-ۿ]+"),hn=new RegExp("["+an+"آ-إاد-زوٱ-ٷڈ-ڙۄ-ۋۏےۓۮۯ]"),dn=new RegExp("^[ؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ۭ]+"),fn="[̀-֑ͯ-ׇֽֿׁׂׅׄަ-ްऀ-ःऺ-ौॎॏ॑-ॗॢॣঁ-ঃ়া-ৌৗৢৣਁ-ਃ਼-ੌੑઁ-ઃ઼ા-ૌૢૣଁ-ଃ଼ା-ୌୖୗୢୣஂா-்ௗఀ-ఃా-ౌౕౖౢౣಁ-ಃ಼ಾ-ೌೕೖೢೣഁ-ഃാ-ൌൎൗൢൣංඃ්-ෟෲෳัิ-ฺ็-๎ັິ-ຼ່-ໍ༹༘༙༵༷༾༿ཱ-ྃ྆྇ྍ-ྼ࿆ါ-း်-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ឴-៑៓ᩕ-ᩞᩡ-᩼᷀-᷿⃐-]",pn=new RegExp(`^.(?:${fn}+)?([्্੍્୍్್്྄္្᩠᩿]\\W(?:${fn}+)?)*`),gn={Mongolian:"᠀-"},mn=Object.keys(gn).map(e=>gn[e]).join(""),_n=new RegExp("["+mn+"]");function yn(e,t,n){const r=t?1:2;if(e.length<r)return[e];let i=e;if(n.segment[i])return n.stats.segment_hits++,n.segment[i];let s=[];if(cn.exec(e)){s=e.split(hn);let t=-1;for(var o=0;o<s.length-1;o++){if(o>0){let e=dn.exec(s[o]);e&&(s[o]=s[o].substring(e[0].length),s[o-1]+=e[0],t+=e[0].length)}t+=1+s[o].length,s[o]+=e.slice(t,t+1)}e=""}for(;e.length;){let t="",n=e,i=0;for(;i<r&&n.length;i++){let e=(pn.exec(n)||n)[0];t+=e,n=n.substring(e.length)}s.push(t),e=e.substring(t.length)}return t&&s.reverse(),n.stats.segment_misses++,n.segment[i]=s,s}class vn{constructor(e,t=1/0,n=1/0){this.width=0,this.height=0,this.lines=[],this.max_lines=t,this.text_wrap=n,this.context=e}createLine(e){return this.lines.length<this.max_lines&&new bn(e,this.text_wrap)}push(e){if(this.lines.length<this.max_lines){let t=this.context.measureText(e.text).width;return e.width=t,t>this.width&&(this.width=Math.ceil(t)),this.lines.push(e),this.height+=e.height,!0}return this.addEllipsis(),!1}advance(e,t){return!!this.push(e)&&this.createLine(t)}addEllipsis(){let e=this.lines[this.lines.length-1],t=Math.ceil(this.context.measureText(vn.ellipsis).width);e.append(vn.ellipsis),e.width+=t,e.width>this.width&&(this.width=e.width)}finish(e){e?this.push(e):this.addEllipsis()}static parse(e,t,n,r,i){let s;s="number"==typeof t?e.split(" "):[e];let o=new vn(i,n,t),a=o.createLine(r);for(let e=0;e<s.length;e++){let n=s[e].split("\n"),i=0===e;for(let s=0;s<n.length&&a;s++){let l=n[s];on(l)&&un(l[l.length-1])&&(l+="");let u=i?l:" "+l;if(t&&e>0&&a.exceedsTextwrap(u)){if(a=o.advance(a,r),!a)break;a.append(l),i=!0}else a.append(u);s<n.length-1&&(a=o.advance(a,r),i=!0)}e===s.length-1&&o.finish(a)}return o}}vn.ellipsis="...";class bn{constructor(e=0,t=0){this.chars=0,this.text="",this.height=Math.ceil(e),this.text_wrap=t}append(e){this.chars+=e.length,this.text+=e}exceedsTextwrap(e){return e.length+this.chars>this.text_wrap}}function xn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xn(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}class An{constructor(){this.createCanvas(),this.vertical_text_buffer=8,this.horizontal_text_buffer=4,this.background_size=4}createCanvas(){this.canvas=document.createElement("canvas"),this.canvas.style.backgroundColor="transparent",this.context=this.canvas.getContext("2d")}resize(e,t){this.canvas.width=e,this.canvas.height=t,this.context.clearRect(0,0,e,t)}setFont({font_css:e,fill:t,stroke:n,stroke_width:r,px_size:i,supersample:s}){this.px_size=i;let o=this.context,a=_.device_pixel_ratio*s;n&&r>0&&(o.strokeStyle=n,o.lineWidth=r*a),o.fillStyle=t,o.font=e,o.miterLimit=2}async textSizes(e,t){return await rn.loadFonts(),E.add({type:"textSizes",run:this.processTextSizesTask.bind(this),texts:t,tile_id:e,cursor:{styles:Object.keys(t),texts:null,style_idx:null,text_idx:null}})}processTextSizesTask(e){let{cursor:t,texts:n}=e;for(t.style_idx=t.style_idx||0;t.style_idx<t.styles.length;){let i=t.styles[t.style_idx];null==t.text_idx&&(t.text_idx=0,t.texts=Object.keys(n[i]));let s=n[i],o=!0;for(;t.text_idx<t.texts.length;){let n=t.texts[t.text_idx],a=s[n],l=a.text_settings;if(o&&(this.setFont(l),o=!1),a.size=this.textSize(i,n,l).size,l.can_articulate){let e=!1,t=!1;if(on(n)&&(un(n)?e=!0:t=!0),a.isRTL=e,a.no_curving=t||(r=n,_n.test(r)),a.vertical_buffer=this.vertical_text_buffer,a.segment_sizes=[],!a.no_curving){let t=yn(n,e,An.cache);a.segments=t;for(let e=0;e<t.length;e++)a.segment_sizes.push(this.textSize(i,t[e],l).size)}}if(t.text_idx++,!E.shouldContinue(e))return!1}t.text_idx=null,t.style_idx++}var r;return E.finish(e,n),!0}textSize(e,t,{transform:n,text_wrap:r,max_lines:i,stroke_width:s=0,background_color:o,background_stroke_width:a=0,background_width:l,underline_width:u=0,supersample:c}){if(An.cache.text[e]=An.cache.text[e]||{},An.cache.text[e][t])return An.cache.stats.text_hits++,An.cache.text[e][t];An.cache.stats.text_misses++,An.cache.text_count++;const h=_.device_pixel_ratio*c,d=this.applyTextTransform(t,n),f=this.context,p=this.vertical_text_buffer*h,g=(s+this.horizontal_text_buffer)*h;l=null!=l?l:this.background_size;const m=o||a?(l+a)*h:0,y=(2+u+(u?s+1:0))*h,v=this.px_size+y;let{width:b,height:x,lines:w}=vn.parse(d,r,i,v,f);b+=2*m,x+=2*m;let A=[b/h,x/h],E=[b+2*g,x+2*p],S=[E[0]/h,E[1]/h];return An.cache.text[e][t]={lines:w,size:{collision_size:A,texture_size:E,logical_size:S,horizontal_buffer:g,vertical_buffer:p,dpr:h,line_height:v,background_size:m}},An.cache.text[e][t]}drawTextMultiLine(e,[t,n],r,i,s){const{dpr:o,collision_size:a,texture_size:l,line_height:u,horizontal_buffer:c,vertical_buffer:h}=r;if(i.background_color||i.background_stroke_color){const e=i.background_stroke_color,r=(i.background_stroke_width||0)*o;this.context.save(),i.background_color&&(this.context.fillStyle=i.background_color,this.context.fillRect(t+c+("curved"===s?l[0]:0)+r,n+h+r,o*a[0]-2*r,o*a[1]-2*r)),e&&r&&(this.context.strokeStyle=e,this.context.lineWidth=r,this.context.strokeRect(t+c+("curved"===s?l[0]:0)+.5*r,n+h+.5*r,o*a[0]-r,o*a[1]-r)),this.context.restore()}const d=i.underline_width||0,f=i.stroke_width||0;let p=n-(d?.5*(d+f+1)*o:0);for(let n=0;n<e.length;n++){let o=e[n];this.drawTextLine(o,[t,p],r,i,s),p+=u}this.drawTextDebug([t,n],r,s)}drawTextLine(e,[t,n],r,i,s){const{stroke:o,stroke_width:a,transform:l,align:u="center"}=i,{horizontal_buffer:c,vertical_buffer:h,texture_size:d,background_size:f,line_height:p,dpr:g}=r,m=(i.underline_width||0)*g,_=this.applyTextTransform(e.text,l);let y;"left"===u?y=t+c+f:"center"===u?y=t+d[0]/2-e.width/2:"right"===u&&(y=t+d[0]-e.width-c-f);const v=n+.75*h+p+f-.5*m,b=o&&a>0&&"curved"===s?d[0]:0;if(m){this.context.save(),this.context.strokeStyle=this.context.fillStyle,this.context.lineWidth=m;const t=v+(.5*a+2)*g+.5*this.context.lineWidth;this.context.beginPath(),this.context.moveTo(y+b,t),this.context.lineTo(y+b+e.width,t),this.context.stroke(),this.context.restore()}o&&a>0&&this.context.strokeText(_,y+b,v),this.context.fillText(_,y,v)}drawTextDebug([e,t],n,r){const{dpr:i,horizontal_buffer:s,vertical_buffer:o,texture_size:a,collision_size:l}=n;v.draw_label_collision_boxes&&(this.context.save(),this.context.strokeStyle="blue",this.context.lineWidth=2,this.context.strokeRect(e+s,t+o,i*l[0],i*l[1]),"curved"===r&&this.context.strokeRect(e+a[0]+s,t+o,i*l[0],i*l[1]),this.context.restore()),v.draw_label_texture_boxes&&(this.context.save(),this.context.strokeStyle="green",this.context.lineWidth=2,this.context.strokeRect(e+2,t+2,a[0]-4,a[1]-4),"curved"===r&&this.context.strokeRect(e+2+a[0],t+2,a[0]-4,a[1]-4),this.context.restore())}rasterize(e,t,n,r,i){return E.add({type:"rasterizeLabels",run:this.processRasterizeTask.bind(this),cancel:this.cancelRasterizeTask.bind(this),pause_factor:2,user_moving_view:!1,texts:e,textures:t,texture_prefix:r,gl:i,tile_id:n,cursor:{styles:Object.keys(e),texts:null,style_idx:0,text_idx:null,texture_idx:0,texture_resize:!0,texture_names:[]}})}processRasterizeTask(e){let t,{cursor:n,texts:r,textures:i}=e;for(;n.texture_idx<e.textures.length;){for(t=i[n.texture_idx],n.texture_resize&&(n.texture_resize=!1,this.resize(...t.texture_size));n.style_idx<n.styles.length;){let i=n.styles[n.style_idx];null==n.text_idx&&(n.text_idx=0,n.texts=Object.keys(r[i]));let s=r[i],o=!0;for(;n.text_idx<n.texts.length;){let r=n.texts[n.text_idx],a=s[r],l=a.text_settings;if(o&&(this.setFont(l),o=!1),l.can_articulate){a.texcoords=a.texcoords||{};for(let e=0;e<a.type.length;e++){let s=a.type[e];if("straight"===s){if(a.textures[e]!==n.texture_idx)continue;let o,u=a.isRTL?r.split().reverse().join():r,c=t.texcoord_cache[i][u];if(c.texcoord)o=c.texcoord;else{let e=c.texture_position,{size:n,lines:r}=this.textSize(i,u,l);this.drawTextMultiLine(r,e,n,l,s),o=k.getTexcoordsForSprite(e,n.texture_size,t.texture_size),c.texcoord=o}a.texcoords[s]={texcoord:o,texture_id:c.texture_id}}else if("curved"===s){let r=a.segments;a.texcoords.curved=a.texcoords.curved||[],a.texcoords_stroke=a.texcoords_stroke||[];for(let o=0;o<r.length;o++){if(a.textures[e][o]!==n.texture_idx)continue;let u,c,h=r[o],d=t.texcoord_cache[i][h];if(d.texcoord)u=d.texcoord,c=d.texcoord_stroke,a.texcoords_stroke.push(c);else{let e=d.texture_position,{size:n,lines:r}=this.textSize(i,h,l);this.drawTextMultiLine(r,e,n,l,s),u=k.getTexcoordsForSprite(e,n.texture_size,t.texture_size);let o=[e[0]+n.texture_size[0],e[1]];c=k.getTexcoordsForSprite(o,n.texture_size,t.texture_size),d.texcoord=u,d.texcoord_stroke=c,a.texcoords_stroke.push(c)}a.texcoords.curved.push({texcoord:u,texture_id:d.texture_id})}}}}else{let e=this.textSize(i,r,l).lines;const s=wn({},l);for(let r in a.align)a.align[r].texture_id===n.texture_idx&&(s.align=r,this.drawTextMultiLine(e,a.align[r].texture_position,a.size,s),a.align[r].texcoords=k.getTexcoordsForSprite(a.align[r].texture_position,a.size.texture_size,t.texture_size))}if(n.text_idx++,!E.shouldContinue(e))return!1}n.text_idx=null,n.style_idx++}let s=e.texture_prefix+n.texture_idx;k.create(e.gl,s,{element:this.canvas,filtering:"linear",UNPACK_PREMULTIPLY_ALPHA_WEBGL:!0}),k.retain(s),n.texture_names.push(s),n.texture_idx++,n.texture_resize=!0,n.style_idx=0}return E.finish(e,n.texture_names),!0}cancelRasterizeTask(e){m("trace",`RasterizeTask: release textures [${e.cursor.texture_names.join(", ")}]`),e.cursor.texture_names.forEach(e=>k.release(e))}setTextureTextPositions(e,t){let n={cx:0,cy:0,width:0,height:0,column_width:0,texture_id:0,texcoord_cache:{}},r=[];for(let i in e){let s=e[i];for(let e in s){let o,a=s[e];if(a.text_settings.can_articulate){a.textures=[],n.texcoord_cache[i]=n.texcoord_cache[i]||{};for(let s=0;s<a.type.length;s++){let l=a.type[s];if("straight"===l){let l=a.isRTL?e.split().reverse().join():e;if(!n.texcoord_cache[i][l]){let e=a.size.texture_size;o=this.placeText(e[0],e[1],i,n,r,t),n.texcoord_cache[i][l]={texture_id:n.texture_id,texture_position:o}}a.textures[s]=n.texture_id}else if("curved"===l){a.textures[s]=[];for(let e=0;e<a.segment_sizes.length;e++){let l=a.segments[e];if(!n.texcoord_cache[i][l]){let s=a.segment_sizes[e].texture_size,u=2*s[0];o=this.placeText(u,s[1],i,n,r,t),n.texcoord_cache[i][l]={texture_id:n.texture_id,texture_position:o}}a.textures[s].push(n.texture_id)}}}}else{let e=a.size.texture_size;for(let s in a.align)o=this.placeText(e[0],e[1],i,n,r,t),a.align[s].texture_id=n.texture_id,a.align[s].texture_position=o}}}return n.column_width>0&&n.height>0&&(r[n.texture_id]={texture_size:[n.width,n.height],texcoord_cache:n.texcoord_cache}),r}placeText(e,t,n,r,i,s){let o;return r.cy+t>s?(r.cx+=r.column_width,r.cy=0,r.column_width=e):r.column_width=Math.max(r.column_width,e),r.cx+r.column_width<=s?(o=[r.cx,r.cy],r.cy+=t,r.height=Math.max(r.height,r.cy),r.width=Math.max(r.width,r.cx+r.column_width)):(i[r.texture_id]={texture_size:[r.width,r.height],texcoord_cache:r.texcoord_cache},r.texcoord_cache={},r.texcoord_cache[n]={},r.texture_id++,r.cx=0,r.cy=t,r.column_width=e,r.width=e,r.height=t,o=[0,0]),o}applyTextTransform(e,t){return"capitalize"===t?e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1)}):"uppercase"===t?e.toUpperCase():"lowercase"===t?e.toLowerCase():e}static fontPixelSize(e){if(null==e)return;e="string"==typeof e?e:String(e);let[,t,n]=e.match(An.font_size_re)||[];return n=n||"px","em"===n?t*=16:"pt"===n?t/=.75:"%"===n&&(t/=6.25),t=J.parsePositiveNumber(t),t*=_.device_pixel_ratio,t}static pruneTextCache(){An.cache.text_count>An.cache.text_count_max&&(An.cache.text={},An.cache.text_count=0,m("debug","TextCanvas: pruning text cache")),Object.keys(An.cache.segment).length>An.cache.segment_count_max&&(An.cache.segment={},m("debug","TextCanvas: pruning segment cache"))}}function En(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}An.font_size_re=/((?:[0-9]*\.)?[0-9]+)\s*(px|pt|em|%)?/,An.cache={text:{},text_count:0,text_count_max:2e3,segment:{},segment_count_max:2e3,stats:{text_hits:0,text_misses:0,segment_hits:0,segment_misses:0}};let Sn=0;const Tn={resetText(){t.is_main?this.canvas=new An:t.is_worker&&(this.texts={})},freeText(e){delete this.texts[e.id]},parseTextFeature(e,t,n,r){let i=this.parseTextSource(e,t,n);if(null==i||""===i)return;let s=Qt.compute(t,n),o=Qt.key(s);this.texts[r.id]=this.texts[r.id]||{};let a=this.texts[r.id][o]=this.texts[r.id][o]||{};if(i instanceof Object){let l=[],u=i.left+"-"+i.right;for(let c in i){let h=i[c];if(!h)continue;let d=this.computeTextLayout({},e,t,n,r,h,s,u,c);a[h]||(a[h]={text_settings:s,ref:0}),l.push({draw:t,text:h,text_settings_key:o,layout:d})}return l.length>0&&l}{let l=this.computeTextLayout({},e,t,n,r,i,s);return a[i]||(a[i]={text_settings:s,ref:0}),{draw:t,text:i,text_settings_key:o,layout:l}}},parseTextSource(e,t,n){let r,i=t.text_source||"name";if(null==i||Array.isArray(i)||"object"!=typeof i)r=this.parseTextSourceValue(i,e,n);else{r={};for(let t in i)r[t]=this.parseTextSourceValue(i[t],e,n)}return r},parseTextSourceValue(e,t,n){let r;if(Array.isArray(e)){for(let i=0;i<e.length;i++)if("string"==typeof e[i]?r=t.properties[e[i]]:"function"==typeof e[i]&&(r=e[i](n)),r)return r}else"string"==typeof e?r=t.properties[e]:e instanceof Function&&(r=e(n));return r},async prepareTextLabels(e,t){if(0===Object.keys(this.texts[e.id]||{}).length)return[];try{const n=await a.postMessage(this.main_thread_target+".calcTextSizes",e.id,this.texts[e.id]);return e.canceled?(m("trace",`Style ${this.name}: stop tile build because tile was canceled: ${e.key}, post-calcTextSizes()`),[]):(this.texts[e.id]=n||[],n?this.buildTextLabels(e,t):($t.abortTile(e.id),[]))}catch(t){return $t.abortTile(e.id),[]}},async collideAndRenderTextLabels(e,t,n){let r=await this.prepareTextLabels(e,n);if(0===r.length)return $t.collide([],t,e.id),{};if(r=await $t.collide(r,t,e.id),e.canceled)return m("trace",`stop tile build because tile was canceled: ${e.key}, post-collide()`),{};let s=this.texts[e.id];if(null==s||0===r.length)return{};this.cullTextStyles(s,r),r.forEach(e=>{let t=e.text_settings_key,n=s[t]&&s[t][e.text];n.text_settings.can_articulate?(n.type||(n.type=[]),-1===n.type.indexOf(e.label.type)&&n.type.push(e.label.type)):(n.align=n.align||{},n.align[e.label.align]={})});try{const t=await a.postMessage(this.main_thread_target+".rasterizeTexts",e.id,e.key,s);return e.canceled?(m("trace",`stop tile build because tile was canceled: ${e.key}, post-rasterizeTexts()`),{}):function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?En(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):En(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({labels:r},t)}catch(e){return{}}},cullTextStyles(e,t){for(let n=0;n<t.length;n++){let r=t[n];e[r.text_settings_key][r.text].ref++}for(let t in e)for(let n in e[t])e[t][n].ref<1&&delete e[t][n];for(let t in e)0===Object.keys(e[t]).length&&delete e[t]},calcTextSizes(e,t){return this.canvas.textSizes(e,t)},async rasterizeTexts(e,t,n){let r=new An,i=Math.min(this.max_texture_size,2048),s=r.setTextureTextPositions(n,i),o=["labels",this.name,t,e,Sn,""].join("-");return Sn++,s=await r.rasterize(n,s,e,o,this.gl),s?{texts:n,textures:s}:{}},preprocessText(e){if(e&&e.font&&"object"==typeof e.font)return e.font.weight=J.createPropertyCache(e.font.weight),e.font.fill=J.createPropertyCache(e.font.fill||Qt.defaults.fill),e.font.alpha=J.createPropertyCache(e.font.alpha),e.font.stroke&&(e.font.stroke.color=J.createPropertyCache(e.font.stroke.color),e.font.stroke.alpha=J.createPropertyCache(e.font.stroke.alpha)),e.font.background&&(e.font.background.color=J.createPropertyCache(e.font.background.color),e.font.background.alpha=J.createPropertyCache(e.font.background.alpha),e.font.background.width=J.createPropertyCache(e.font.background.width,J.parsePositiveNumber),e.font.background.stroke&&(e.font.background.stroke.color=J.createPropertyCache(e.font.background.stroke.color),e.font.background.stroke.alpha=J.createPropertyCache(e.font.background.stroke.alpha))),e.font.px_size=J.createPropertyCache(e.font.size||Qt.defaults.size,An.fontPixelSize,An.fontPixelSize),e.font.stroke&&null!=e.font.stroke.width&&(e.font.stroke.width=J.createPropertyCache(e.font.stroke.width,J.parsePositiveNumber)),e.font.background&&e.font.background.stroke&&null!=e.font.background.stroke.width&&(e.font.background.stroke.width=J.createPropertyCache(e.font.background.stroke.width,J.parsePositiveNumber)),e.offset=J.createPropertyCache(e.offset,e=>Array.isArray(e)&&e.map(J.parseNumber)),e.buffer=J.createPropertyCache(e.buffer,e=>(Array.isArray(e)?e:[e,e]).map(J.parsePositiveNumber)),e.repeat_distance=J.createPropertyCache(e.repeat_distance,J.parsePositiveNumber),e},computeTextLayout(e,t,n,r,i,s,o,a,l){let u=e||{};return u=this.computeLayout(u,t,n,r,i),null==n.repeat_distance&&(u.repeat_distance="point"===r.geometry?0:G.tile_size,u.repeat_distance&&(u.repeat_distance*=u.units_per_pixel,u.repeat_scale=1,"function"==typeof n.repeat_group?u.repeat_group=n.repeat_group(r):u.repeat_group=n.repeat_group)),u.repeat_distance&&(a&&(u.repeat_group+="/"+a),u.repeat_group+="/"+s),u.subdiv=i.overzoom2,u.align=n.align,u.italic="normal"!==o.style,"right"===l?u.orientation=1:"left"===l&&(u.orientation=-1),u}};var kn,On,Rn,Cn,Pn,Mn,Nn,In,Dn,Fn,zn,Ln,jn,Vn,Un,Bn,Gn=M(On?kn:(On=1,kn=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],m=t[14],_=t[15],y=n*a-r*o,v=n*l-i*o,b=n*u-s*o,x=r*l-i*a,w=r*u-s*a,A=i*u-s*l,E=c*g-h*p,S=c*m-d*p,T=c*_-f*p,k=h*m-d*g,O=h*_-f*g,R=d*_-f*m,C=y*R-v*O+b*k+x*T-w*S+A*E;return C?(C=1/C,e[0]=(a*R-l*O+u*k)*C,e[1]=(l*T-o*R-u*S)*C,e[2]=(o*O-a*T+u*E)*C,e[3]=(i*O-r*R-s*k)*C,e[4]=(n*R-i*T+s*S)*C,e[5]=(r*T-n*O-s*E)*C,e[6]=(g*A-m*w+_*x)*C,e[7]=(m*b-p*A-_*v)*C,e[8]=(p*w-g*b+_*y)*C,e):null})),$n=M(Cn?Rn:(Cn=1,Rn=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=c*o-a*u,d=-c*s+a*l,f=u*s-o*l,p=n*h+r*d+i*f;return p?(p=1/p,e[0]=h*p,e[1]=(-c*r+i*u)*p,e[2]=(a*r-i*o)*p,e[3]=d*p,e[4]=(c*n-i*l)*p,e[5]=(-a*n+i*s)*p,e[6]=f*p,e[7]=(-u*n+r*l)*p,e[8]=(o*n-r*s)*p,e):null})),qn=M(Mn?Pn:(Mn=1,Pn=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],g=t[12],m=t[13],_=t[14],y=t[15],v=n[0],b=n[1],x=n[2],w=n[3];return e[0]=v*r+b*a+x*h+w*g,e[1]=v*i+b*l+x*d+w*m,e[2]=v*s+b*u+x*f+w*_,e[3]=v*o+b*c+x*p+w*y,v=n[4],b=n[5],x=n[6],w=n[7],e[4]=v*r+b*a+x*h+w*g,e[5]=v*i+b*l+x*d+w*m,e[6]=v*s+b*u+x*f+w*_,e[7]=v*o+b*c+x*p+w*y,v=n[8],b=n[9],x=n[10],w=n[11],e[8]=v*r+b*a+x*h+w*g,e[9]=v*i+b*l+x*d+w*m,e[10]=v*s+b*u+x*f+w*_,e[11]=v*o+b*c+x*p+w*y,v=n[12],b=n[13],x=n[14],w=n[15],e[12]=v*r+b*a+x*h+w*g,e[13]=v*i+b*l+x*d+w*m,e[14]=v*s+b*u+x*f+w*_,e[15]=v*o+b*c+x*p+w*y,e})),Hn=M(In?Nn:(In=1,Nn=function(e,t,n){var r,i,s,o,a,l,u,c,h,d,f,p,g=n[0],m=n[1],_=n[2];return t===e?(e[12]=t[0]*g+t[4]*m+t[8]*_+t[12],e[13]=t[1]*g+t[5]*m+t[9]*_+t[13],e[14]=t[2]*g+t[6]*m+t[10]*_+t[14],e[15]=t[3]*g+t[7]*m+t[11]*_+t[15]):(r=t[0],i=t[1],s=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],e[0]=r,e[1]=i,e[2]=s,e[3]=o,e[4]=a,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=f,e[11]=p,e[12]=r*g+a*m+h*_+t[12],e[13]=i*g+l*m+d*_+t[13],e[14]=s*g+u*m+f*_+t[14],e[15]=o*g+c*m+p*_+t[15]),e})),Wn=M(Fn?Dn:(Fn=1,Dn=function(e,t,n){var r=n[0],i=n[1],s=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e})),Zn=M(Ln?zn:(Ln=1,zn=function(e,t,n,r,i){var s=1/Math.tan(t/2),o=1/(r-i);return e[0]=s/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+r)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*r*o,e[15]=0,e}));function Kn(){return Vn?jn:(Vn=1,jn=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e})}var Xn,Yn,Qn=function(){if(Bn)return Un;Bn=1;var e=Kn();return Un=function(t,n,r,i){var s,o,a,l,u,c,h,d,f,p,g=n[0],m=n[1],_=n[2],y=i[0],v=i[1],b=i[2],x=r[0],w=r[1],A=r[2];return Math.abs(g-x)<1e-6&&Math.abs(m-w)<1e-6&&Math.abs(_-A)<1e-6?e(t):(h=g-x,d=m-w,f=_-A,s=v*(f*=p=1/Math.sqrt(h*h+d*d+f*f))-b*(d*=p),o=b*(h*=p)-y*f,a=y*d-v*h,(p=Math.sqrt(s*s+o*o+a*a))?(s*=p=1/p,o*=p,a*=p):(s=0,o=0,a=0),l=d*a-f*o,u=f*s-h*a,c=h*o-d*s,(p=Math.sqrt(l*l+u*u+c*c))?(l*=p=1/p,u*=p,c*=p):(l=0,u=0,c=0),t[0]=s,t[1]=l,t[2]=h,t[3]=0,t[4]=o,t[5]=u,t[6]=d,t[7]=0,t[8]=a,t[9]=c,t[10]=f,t[11]=0,t[12]=-(s*g+o*m+a*_),t[13]=-(l*g+u*m+c*_),t[14]=-(h*g+d*m+f*_),t[15]=1,t)}}(),Jn=M(Qn),er=M(Kn()),tr=M(Yn?Xn:(Yn=1,Xn=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}));const nr={fromValues(e,t,n){var r=new Float64Array(3);return r[0]=e,r[1]=t,r[2]=n,r}},rr={normalFromMat4:Gn,invert:$n},ir={multiply:qn,translate:Hn,scale:Wn,perspective:Zn,lookAt:Jn,identity:er,copy:tr};class sr{constructor(e,t,n={}){this.view=t,this.position=n.position,this.zoom=n.zoom}static create(e,t,n){switch(n.type){case"isometric":return new ar(e,t,n);case"flat":return new lr(e,t,n);default:return new or(e,t,n)}}update(){}setupProgram(){}updateView(){if(this.position||this.zoom){var e={};this.position&&(e={lng:this.position[0],lat:this.position[1],zoom:this.position[2]}),this.zoom&&(e.zoom=this.zoom),this.view.setView(e)}}setupMatrices(e,t){ir.multiply(e.model_view32,this.view_matrix,e.model),t.uniform("Matrix4fv","u_modelView",e.model_view32),rr.normalFromMat4(e.normal32,e.model_view32),rr.invert(e.inverse_normal32,e.normal32),t.uniform("Matrix3fv","u_normalMatrix",e.normal32),t.uniform("Matrix3fv","u_inverseNormalMatrix",e.inverse_normal32)}}class or extends sr{constructor(e,t,n={}){super(e,t,n),this.type="perspective",this.focal_length=n.focal_length,this.fov=n.fov,this.focal_length||this.fov||(this.focal_length=[[16,2],[17,2.5],[18,3],[19,4],[20,6]]),this.vanishing_point=n.vanishing_point||[0,0],this.vanishing_point=this.vanishing_point.map(parseFloat),this.vanishing_point_skew=[],this.position_meters=null,this.view_matrix=new Float64Array(16),this.projection_matrix=new Float32Array(16),j.replaceBlock("camera","\n uniform mat4 u_projection;\n uniform vec3 u_eye;\n uniform vec2 u_vanishing_point;\n\n void cameraProjection (inout vec4 position) {\n position = u_projection * position;\n }")}constrainCamera({view_height:e,height:t,focal_length:n,fov:r}){return t?(n=2*t/e,r=2*Math.atan(1/n)):(n?r=2*Math.atan(1/n):r&&(r=r*Math.PI/180,n=1/Math.tan(r/2)),t=e/2*n),{view_height:e,height:t,focal_length:n,fov:r}}updateMatrices(){var e=this.view.size.css.height*this.view.meters_per_pixel,{height:t,fov:n}=this.constrainCamera({view_height:e,focal_length:_.interpolate(this.view.zoom,this.focal_length),fov:_.interpolate(this.view.zoom,this.fov)}),r=[this.view.center.meters.x,this.view.center.meters.y,t];this.position_meters=r,ir.lookAt(this.view_matrix,nr.fromValues(r[0],r[1],0),nr.fromValues(r[0],r[1],-1),nr.fromValues(0,1,0)),ir.perspective(this.projection_matrix,n,this.view.aspect,1,2*t),this.vanishing_point_skew[0]=this.vanishing_point[0]/this.view.size.css.width,this.vanishing_point_skew[1]=this.vanishing_point[1]/this.view.size.css.height,this.projection_matrix[8]=2*-this.vanishing_point_skew[0],this.projection_matrix[9]=2*-this.vanishing_point_skew[1],ir.translate(this.projection_matrix,this.projection_matrix,nr.fromValues(e/2*this.view.aspect*(2*-this.vanishing_point_skew[0]),e/2*(2*-this.vanishing_point_skew[1]),0)),ir.translate(this.projection_matrix,this.projection_matrix,nr.fromValues(0,0,-t))}update(){super.update(),this.updateMatrices()}setupProgram(e){e.uniform("Matrix4fv","u_projection",this.projection_matrix),e.uniform("3f","u_eye",[0,0,this.position_meters[2]]),e.uniform("2fv","u_vanishing_point",this.vanishing_point_skew)}}class ar extends sr{constructor(e,t,n={}){super(e,t,n),this.type="isometric",this.axis=n.axis||{x:0,y:1},2===this.axis.length&&(this.axis={x:this.axis[0],y:this.axis[1]}),this.position_meters=null,this.viewport_height=null,this.view_matrix=new Float64Array(16),this.projection_matrix=new Float32Array(16),j.replaceBlock("camera","\n uniform mat4 u_projection;\n uniform vec3 u_eye;\n uniform vec2 u_vanishing_point;\n\n void cameraProjection (inout vec4 position) {\n position = u_projection * position;\n // position.xy += position.z * u_isometric_axis;\n\n // Reverse z for depth buffer so up is negative,\n // and scale down values so objects higher than one screen height will not get clipped\n // pull forward slightly to avoid going past far clipping plane\n position.z = -position.z / 100. + 1. - 0.001;\n }")}update(){super.update(),this.viewport_height=this.view.size.css.height*this.view.meters_per_pixel;var e=[this.view.center.meters.x,this.view.center.meters.y,this.viewport_height];this.position_meters=e,ir.identity(this.view_matrix),ir.translate(this.view_matrix,this.view_matrix,nr.fromValues(-e[0],-e[1],0)),ir.identity(this.projection_matrix),this.projection_matrix[8]=this.axis.x/this.view.aspect,this.projection_matrix[9]=this.axis.y,ir.scale(this.projection_matrix,this.projection_matrix,nr.fromValues(2/this.view.size.meters.x,2/this.view.size.meters.y,2/this.view.size.meters.y))}setupProgram(e){e.uniform("Matrix4fv","u_projection",this.projection_matrix),e.uniform("3fv","u_eye",[0,0,this.viewport_height]),e.uniform("2fv","u_vanishing_point",[0,0])}}class lr extends ar{constructor(e,t,n={}){super(e,t,n),this.type="flat"}update(){this.axis.x=0,this.axis.y=0,super.update()}}const ur=qt.PLACEMENT,cr=Object.create(Pe),hr="__shader_point";Object.assign(cr,Tn),Object.assign(cr,{name:"points",built_in:!0,vertex_shader_src:"uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_tile_proxy_order_offset;\nuniform bool u_tile_fade_in;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\nuniform float u_visible_time;\nuniform bool u_view_panning;\nuniform float u_view_pan_snap_timer;\n\nuniform mat4 u_model;\nuniform mat4 u_modelView;\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nattribute vec4 a_position;\nattribute vec4 a_shape;\nattribute vec4 a_color;\nattribute vec2 a_texcoord;\nattribute vec2 a_offset;\n\nuniform float u_point_type;\n\n#ifdef TANGRAM_CURVED_LABEL\n attribute vec4 a_offsets;\n attribute vec4 a_pre_angles;\n attribute vec4 a_angles;\n#endif\n\nvarying vec4 v_color;\nvarying vec2 v_texcoord;\nvarying vec4 v_world_position;\nvarying float v_alpha_factor;\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n attribute float a_outline_edge;\n attribute vec4 a_outline_color;\n\n varying float v_outline_edge;\n varying vec4 v_outline_color;\n varying float v_aa_offset;\n#endif\n\n#ifdef TANGRAM_SHOW_HIDDEN_LABELS\n varying float v_label_hidden;\n#endif\n\n#define TANGRAM_PI 3.14159265359\n#define TANGRAM_NORMAL vec3(0., 0., 1.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvec2 rotate2D(vec2 _st, float _angle) {\n return mat2(cos(_angle),-sin(_angle),\n sin(_angle),cos(_angle)) * _st;\n}\n\n#ifdef TANGRAM_CURVED_LABEL\n // Assumes stops are [0, 0.33, 0.66, 0.99];\n float mix4linear(vec4 v, float x) {\n x = clamp(x, 0., 1.);\n return mix(mix(v[0], v[1], 3. * x),\n mix(v[1],\n mix(v[2], v[3], 3. * (max(x, .66) - .66)),\n 3. * (clamp(x, .33, .66) - .33)),\n step(0.33, x)\n );\n }\n#endif\n\nvoid main() {\n // Initialize globals\n #pragma tangram: setup\n\n // discard hidden labels by collapsing into degenerate triangle\n #ifndef TANGRAM_SHOW_HIDDEN_LABELS\n if (a_shape.w == 0.) {\n gl_Position = vec4(0., 0., 0., 1.);\n return;\n }\n #else\n // highlight hidden label in fragment shader for debugging\n if (a_shape.w == 0.) {\n v_label_hidden = 1.; // label debug testing\n }\n else {\n v_label_hidden = 0.;\n }\n #endif\n\n v_alpha_factor = 1.0;\n v_color = a_color;\n v_texcoord = a_texcoord; // UV from vertex attribute\n\n #ifdef TANGRAM_HAS_SHADER_POINTS\n v_outline_color = a_outline_color;\n v_outline_edge = a_outline_edge;\n\n if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n // use point dimensions for UVs instead (ignore attribute), add antialiasing info for fragment shader\n float _size = abs(a_shape.x / 128.); // radius in pixels\n v_texcoord = sign(a_shape.xy) * (_size + 1.) / _size;\n _size += 2.;\n v_aa_offset = 2. / _size;\n }\n #endif\n\n // Position\n vec4 position = u_modelView * vec4(a_position.xyz, 1.);\n\n // Apply positioning and scaling in screen space\n vec2 _shape = a_shape.xy / 256.; // values have an 8-bit fraction\n vec2 _offset = vec2(a_offset.x, -a_offset.y); // flip y to make it point down\n float _theta = a_shape.z / 4096.;\n\n #ifdef TANGRAM_CURVED_LABEL\n //TODO: potential bug? null is passed in for non-curved labels, otherwise the first offset will be 0\n if (a_offsets[0] != 0.){\n vec4 _angles_scaled = (TANGRAM_PI / 16384.) * a_angles;\n vec4 _pre_angles_scaled = (TANGRAM_PI / 128.) * a_pre_angles;\n vec4 _offsets_scaled = (1. / 64.) * a_offsets;\n\n float _zoom = clamp(u_map_position.z - u_tile_origin.z, 0., 1.); //fract(u_map_position.z);\n float _pre_angle = mix4linear(_pre_angles_scaled, _zoom);\n float _angle = mix4linear(_angles_scaled, _zoom);\n float _offset_curve = mix4linear(_offsets_scaled, _zoom);\n\n _shape = rotate2D(_shape, _pre_angle); // rotate in place\n _shape.x += _offset_curve; // offset for curved label segment\n _shape = rotate2D(_shape, _angle); // rotate relative to curved label anchor\n _shape += rotate2D(_offset, _theta); // offset if specified in the scene file\n }\n else {\n _shape = rotate2D(_shape + _offset, _theta);\n }\n #else\n _shape = rotate2D(_shape + _offset, _theta);\n #endif\n\n // Fade in (if requested) based on time mesh has been visible.\n // Value passed to fragment shader in the v_alpha_factor varying\n #ifdef TANGRAM_FADE_IN_RATE\n if (u_tile_fade_in) {\n v_alpha_factor *= clamp(u_visible_time * TANGRAM_FADE_IN_RATE, 0., 1.);\n }\n #endif\n\n // World coordinates for 3d procedural textures\n v_world_position = u_model * position;\n v_world_position.xy += _shape * u_meters_per_pixel;\n v_world_position = wrapWorldPosition(v_world_position);\n\n // Modify position before camera projection\n #pragma tangram: position\n\n cameraProjection(position);\n\n #ifdef TANGRAM_LAYER_ORDER\n // +1 is to keep all layers including proxies > 0\n applyLayerOrder(a_position.w + u_tile_proxy_order_offset + 1., position);\n #endif\n\n // Apply pixel offset in screen-space\n // Multiply by 2 is because screen is 2 units wide Normalized Device Coords (and u_resolution device pixels wide)\n // Device pixel ratio adjustment is because shape is in logical pixels\n position.xy += _shape * position.w * 2. * u_device_pixel_ratio / u_resolution;\n #ifdef TANGRAM_HAS_SHADER_POINTS\n if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n // enlarge by 1px to catch missed MSAA fragments\n position.xy += sign(_shape) * position.w * u_device_pixel_ratio / u_resolution;\n }\n #endif\n\n // Snap to pixel grid\n // Only applied to fully upright sprites/labels (not shader-drawn points), while panning is not active\n #ifdef TANGRAM_HAS_SHADER_POINTS\n if (!u_view_panning && (abs(_theta) < TANGRAM_EPSILON) && u_point_type != TANGRAM_POINT_TYPE_SHADER) {\n #else\n if (!u_view_panning && (abs(_theta) < TANGRAM_EPSILON)) {\n #endif\n vec2 _position_fract = fract((((position.xy / position.w) + 1.) * .5) * u_resolution);\n vec2 _position_snap = position.xy + ((step(0.5, _position_fract) - _position_fract) * position.w * 2. / u_resolution);\n\n // Animate the snapping to smooth the transition and make it less noticeable\n #ifdef TANGRAM_VIEW_PAN_SNAP_RATE\n position.xy = mix(position.xy, _position_snap, clamp(u_view_pan_snap_timer * TANGRAM_VIEW_PAN_SNAP_RATE, 0., 1.));\n #else\n position.xy = _position_snap;\n #endif\n }\n\n gl_Position = position;\n}\n",fragment_shader_src:"uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\nuniform float u_visible_time;\n\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nuniform sampler2D u_texture;\nuniform float u_point_type;\nuniform bool u_apply_color_blocks;\n\nvarying vec4 v_color;\nvarying vec2 v_texcoord;\nvarying vec4 v_world_position;\nvarying float v_alpha_factor;\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n varying vec4 v_outline_color;\n varying float v_outline_edge;\n varying float v_aa_offset;\n#endif\n\n#ifdef TANGRAM_SHOW_HIDDEN_LABELS\n varying float v_label_hidden;\n#endif\n\n#define TANGRAM_NORMAL vec3(0., 0., 1.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n //l is the distance from the center to the fragment, R is the radius of the drawn point\n float _tangram_antialias(float l, float R){\n float low = R - v_aa_offset;\n float high = R + v_aa_offset;\n return 1. - smoothstep(low, high, l);\n }\n#endif\n\nvoid main (void) {\n // Initialize globals\n #pragma tangram: setup\n\n vec4 color = v_color;\n\n #ifdef TANGRAM_HAS_SHADER_POINTS\n // Only apply shader blocks to point, not to attached text (N.B.: for compatibility with ES)\n if (u_point_type == TANGRAM_POINT_TYPE_TEXTURE) { // sprite texture\n color *= texture2D(u_texture, v_texcoord);\n }\n else if (u_point_type == TANGRAM_POINT_TYPE_LABEL) { // label texture\n color = texture2D(u_texture, v_texcoord);\n color.rgb /= max(color.a, 0.001); // un-multiply canvas texture\n }\n else if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n // Mask of outermost circle, either outline or point boundary\n float _d = length(v_texcoord); // distance to this fragment from the point center\n float _outer_alpha = _tangram_antialias(_d, 1.);\n float _fill_alpha = _tangram_antialias(_d, 1. - (v_outline_edge * 0.5)) * color.a;\n float _stroke_alpha = (_outer_alpha - _tangram_antialias(_d, 1. - v_outline_edge)) * v_outline_color.a;\n\n // Apply alpha compositing with stroke 'over' fill.\n #ifdef TANGRAM_BLEND_ADD\n color.a = _stroke_alpha + _fill_alpha;\n color.rgb = color.rgb * _fill_alpha + v_outline_color.rgb * _stroke_alpha;\n #else // TANGRAM_BLEND_OVERLAY (and fallback for not implemented blending modes)\n color.a = _stroke_alpha + _fill_alpha * (1. - _stroke_alpha);\n color.rgb = mix(color.rgb * _fill_alpha, v_outline_color.rgb, _stroke_alpha) / max(color.a, 0.001); // avoid divide by zero\n #endif\n }\n #else\n // If shader points not supported, assume label texture\n color = texture2D(u_texture, v_texcoord);\n color.rgb /= max(color.a, 0.001); // un-multiply canvas texture\n #endif\n\n // Shader blocks for color/filter are only applied for sprites, shader points, and standalone text,\n // NOT for text attached to a point (N.B.: for compatibility with ES)\n if (u_apply_color_blocks) {\n #pragma tangram: color\n #pragma tangram: filter\n }\n\n color.a *= v_alpha_factor;\n\n // highlight hidden label in fragment shader for debugging\n #ifdef TANGRAM_SHOW_HIDDEN_LABELS\n if (v_label_hidden > 0.) {\n color.a *= 0.5;\n color.rgb = vec3(1., 0., 0.);\n }\n #endif\n\n // Use alpha test as a lower-quality substitute\n // For opaque and translucent: avoid transparent pixels writing to depth buffer, obscuring geometry underneath\n // For multiply: avoid transparent pixels multiplying geometry underneath to zero/full black\n #if defined(TANGRAM_BLEND_OPAQUE) || defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n if (color.a < TANGRAM_ALPHA_TEST) {\n discard;\n }\n #endif\n\n // Make points more visible in wireframe debug mode\n #ifdef TANGRAM_WIREFRAME\n color = vec4(vec3(0.5), 1.); // use gray outline for textured points\n #ifdef TANGRAM_HAS_SHADER_POINTS\n if (u_point_type == TANGRAM_POINT_TYPE_SHADER) {\n color = vec4(v_color.rgb, 1.); // use original vertex color outline for shader points\n }\n #endif\n #endif\n\n gl_FragColor = color;\n}\n",selection:!0,collision:!0,blend:"overlay",init(e={}){Pe.init.call(this,e),this.setupDefines(),this.defines.TANGRAM_HAS_SHADER_POINTS=!0,this.defines.TANGRAM_POINT_TYPE_TEXTURE=1,this.defines.TANGRAM_POINT_TYPE_LABEL=2,this.defines.TANGRAM_POINT_TYPE_SHADER=3,this.collision_group_points=this.name+"-points",this.collision_group_text=this.name+"-text",this.stencil_proxy_tiles=!1,this.reset()},setupDefines(){"overlay"!==this.blend&&(this.defines.TANGRAM_LAYER_ORDER=!0),!0===v.suppress_label_fade_in?(this.fade_in_time=0,this.defines.TANGRAM_FADE_IN_RATE=null):(this.fade_in_time=.15,this.defines.TANGRAM_FADE_IN_RATE=1/this.fade_in_time),!0!==v.suppress_label_snap_animation&&(this.defines.TANGRAM_VIEW_PAN_SNAP_RATE=2),!0===v.show_hidden_labels&&(this.defines.TANGRAM_SHOW_HIDDEN_LABELS=!0),!0===v.wireframe&&(this.defines.TANGRAM_WIREFRAME=!0)},reset(){this.queues={},this.resetText(),this.texture_missing_sprites={}},addFeature(e,t,n){let r=n.tile;if(r.generation!==this.generation)return;let i,s={};if(s.color=this.parseColor(t.color,n),s.texture=t.texture,s.label_texture=null,s.blend_order=t.blend_order,!s.color&&!s.texture)return;if(s.alpha=J.evalCachedProperty(t.alpha,n),this.hasSprites(s)){if(i=this.parseSprite(s,t,n),!i)return void m({level:"debug",once:!0},`Layer group '${t.layers.join(", ")}' uses a texture '${s.texture}', but doesn't specify which sprite to draw. Features that match this layer group won't be drawn without specifying the sprite with the 'sprite' or 'sprite_default' properties. The merged draw parameters for this layer group are:`,t).then(n=>{n&&m("debug",`Example feature for layer group '${t.layers.join(", ")}'`,e)});s.texcoords=i.texcoords}else if(t.sprite)return void m({level:"warn",once:!0},`Layer group '${t.layers.join(", ")}' specifies sprite '${t.sprite}', but the texture '${t.texture}' doesn't define any sprites. Features that match this layer group won't be drawn. The merged draw parameters for this layer group are:`,t);if(this.calcSize(t,s,i,n),t.outline&&(s.outline_width=J.evalCachedProperty(t.outline.width,n)||J.defaults.outline.width,s.outline_color=this.parseColor(t.outline.color,n)),s.outline_edge_pct=0,s.outline_width&&s.outline_color){let e=s.outline_width;s.size[0]+=e,s.size[1]+=e,s.outline_edge_pct=e/Math.min(s.size[0],s.size[1])*2,s.outline_alpha=J.evalCachedProperty(t.outline.alpha,n)}s.size[0]=Math.min(s.size[0],256),s.size[1]=Math.min(s.size[1],256),s.placement=t.placement,s.placement_min_length_ratio=J.evalCachedProperty(t.placement_min_length_ratio,n),s.placement===ur.SPACED&&t.placement_spacing&&(s.placement_spacing=J.evalCachedProperty(t.placement_spacing,n)),s.angle=J.evalProperty(t.angle,n)||0,s.z=J.evalCachedDistanceProperty(t.z,n)||J.defaults.z,s.tile_edges=t.tile_edges,this.computeLayout(s,e,t,n,r);let o=t.text&&!1!==t.text.visible&&this.parseTextFeature(e,t.text,n,r);Array.isArray(o)&&(o=null,m({level:"warn",once:!0},`Layer group '${t.layers.join(", ")}': cannot use boundary labels (e.g. 'text_source: { left: ..., right: ... }') for 'text' labels attached to 'points'; provided 'text_source' value was ${JSON.stringify(t.text.text_source)}`)),o&&(o.layout.parent=s,o.layout.priority=t.text.priority?Math.max(o.layout.priority,s.priority+.5):s.priority+.5,$t.addStyle(this.collision_group_text,r.id)),this.queueFeature({feature:e,draw:t,context:n,style:s,text_feature:o},r),$t.addStyle(this.collision_group_points,r.id)},calcSize(e,t,n,r){if(t.size=e.size,t.size){if(t.size=J.evalCachedPointSizeProperty(e.size,n,k.textures[t.texture],r),null==t.size)return void m({level:"warn",once:!0},`Layer group '${e.layers.join(", ")}': 'size' (${JSON.stringify(e.size.value)}) couldn't be interpreted, features that match this layer group won't be drawn`);"number"==typeof t.size&&(t.size=[t.size,t.size])}else t.size=n&&n.css_size||[16,16]},hasSprites:e=>e.texture&&k.textures[e.texture]&&k.textures[e.texture].sprites,getSpriteInfo(e,t){let n=k.textures[e.texture].sprites[t]&&k.getSpriteInfo(e.texture,t);return t&&!n?(this.texture_missing_sprites[e.texture]=this.texture_missing_sprites[e.texture]||{},this.texture_missing_sprites[e.texture][t]||(m("debug",`Style: in style '${this.name}', could not find sprite '${t}' for texture '${e.texture}'`),this.texture_missing_sprites[e.texture][t]=!0)):n&&(n.sprite=t),n},parseSprite(e,t,n){let r=J.evalProperty(t.sprite,n);return this.getSpriteInfo(e,r)||this.getSpriteInfo(e,t.sprite_default)},queueFeature(e,t){this.tile_data[t.id]&&this.queues[t.id]||this.startData(t),this.queues[t.id]=this.queues[t.id]||[],this.queues[t.id].push(e)},async endData(e){if(e.canceled)return m("trace",`Style ${this.name}: stop tile build because tile was canceled: ${e.key}`),null;let t=this.queues[e.id];delete this.queues[e.id];let n=[],r=[];t.forEach(e=>{let t=e.style,i=e.feature,s=i.geometry,o=this.buildLabels(t.size,s,t);for(let s=0;s<o.length;s++){let a=o[s],l={feature:i,draw:e.draw,context:e.context,style:t,label:a};if(r.push(l),e.text_feature){let t={feature:i,draw:e.text_feature.draw,context:e.context,text:e.text_feature.text,text_settings_key:e.text_feature.text_settings_key,layout:e.text_feature.layout,point_label:a,linked:l};n.push(t),e.draw.text.optional||(l.linked=t)}}});const[,{labels:i,texts:s,textures:o}]=await Promise.all([$t.collide(r,this.collision_group_points,e.id).then(e=>{e.forEach(e=>{this.feature_style=e.style,this.feature_style.label=e.label,this.feature_style.linked=e.linked,Pe.addFeature.call(this,e.feature,e.draw,e.context)})}),this.collideAndRenderTextLabels(e,this.collision_group_text,n)]);i&&s&&i.forEach(e=>{let t=e.text_settings_key,n=s[t]&&s[t][e.text],r=this.feature_style;r.label=e.label,r.linked=e.linked,r.size=n.size.logical_size,r.texcoords=n.align[e.label.align].texcoords,r.label_texture=o[n.align[e.label.align].texture_id],r.blend_order=e.draw.blend_order,Pe.addFeature.call(this,e.feature,e.draw,e.context)}),this.freeText(e);const a=await Pe.endData.call(this,e);return a&&o&&o.length&&(a.textures=a.textures||[],a.textures.push(...o)),a},_preprocess(e){e.color=J.createColorPropertyCache(e.color),e.alpha=J.createPropertyCache(e.alpha),e.texture=void 0!==e.texture?e.texture:this.texture,e.blend_order=this.getBlendOrderForDraw(e),e.outline&&(e.outline.color=J.createColorPropertyCache(e.outline.color),e.outline.alpha=J.createPropertyCache(e.outline.alpha),e.outline.width=J.createPropertyCache(e.outline.width,J.parsePositiveNumber)),e.z=J.createPropertyCache(e.z,J.parseUnits);try{e.size=J.createPointSizePropertyCache(e.size,e.texture)}catch(t){return m({level:"warn",once:!0},`Layer group '${e.layers.join(", ")}': ${t} (${JSON.stringify(e.size)}), features that match this layer group won't be drawn.`),null}if(e.offset=J.createPropertyCache(e.offset,e=>Array.isArray(e)&&e.map(J.parseNumber)),e.buffer=J.createPropertyCache(e.buffer,e=>(Array.isArray(e)?e:[e,e]).map(J.parsePositiveNumber)),e.repeat_distance=J.createPropertyCache(e.repeat_distance,J.parseNumber),e.placement=ur[e.placement&&e.placement.toUpperCase()],null==e.placement&&(e.placement=ur.VERTEX),e.placement_spacing=null!=e.placement_spacing?e.placement_spacing:80,e.placement_spacing=J.createPropertyCache(e.placement_spacing,J.parsePositiveNumber),e.placement_min_length_ratio=null!=e.placement_min_length_ratio?e.placement_min_length_ratio:1,e.placement_min_length_ratio=J.createPropertyCache(e.placement_min_length_ratio,J.parsePositiveNumber),"number"==typeof e.angle)e.angle=e.angle*Math.PI/180;else if("function"==typeof e.angle){const t=e.angle;e.angle=e=>t(e)*Math.PI/180}else e.angle=e.angle||0;return e.text=this.preprocessText(e.text),e.text&&(e.text.key=e.key,e.text.group=e.group,e.text.layers=e.layers,e.text.order=e.order,e.text.blend_order=e.blend_order,e.text.repeat_group=null!=e.text.repeat_group?e.text.repeat_group:e.repeat_group,e.text.anchor=e.text.anchor||this.default_anchor,e.text.optional="boolean"==typeof e.text.optional&&e.text.optional,e.text.interactive=e.text.interactive||e.interactive),e},default_anchor:["bottom","top","right","left"],computeLayout(e,t,n,r,i){let s=e||{};s.id=t,s.units_per_pixel=i.units_per_pixel||1,s.collide=!1!==n.collide,s.anchor=n.anchor,s.offset=J.evalCachedProperty(n.offset,r)||J.zeroPair,s.buffer=J.evalCachedProperty(n.buffer,r)||J.zeroPair,s.repeat_distance=J.evalCachedProperty(n.repeat_distance,r),s.repeat_distance&&(s.repeat_distance*=s.units_per_pixel,s.repeat_scale=1,"function"==typeof n.repeat_group?s.repeat_group=n.repeat_group(r):s.repeat_group=n.repeat_group||r.layer);let o=n.priority;return null!=o?"function"==typeof o&&(o=o(r)):o=-1>>>0,s.priority=o,s},buildTextLabels(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],s=this.texts[e.id][i.text_settings_key][i.text].size.collision_size;i.label=new qt(i.point_label.position,s,i.layout),n.push(i)}return n},buildLabels(e,t,n){let r=[];if("Point"===t.type)r.push(new qt(t.coordinates,e,n,n.angle));else if("MultiPoint"===t.type){let i=t.coordinates;for(let t=0;t<i.length;++t){let s=i[t];r.push(new qt(s,e,n,n.angle))}}else if("LineString"===t.type){let i=Wt(t.coordinates,e,n);for(let e=0;e<i.length;++e)r.push(i[e])}else if("MultiLineString"===t.type){let i=t.coordinates;for(let t=0;t<i.length;t++){let s=Wt(i[t],e,n);for(let e=0;e<s.length;++e)r.push(s[e])}}else if("Polygon"===t.type)if(n.placement===ur.CENTROID){let i=G.centroid(t.coordinates);i&&r.push(new qt(i,e,n,n.angle))}else{let i=t.coordinates;for(let t=0;t<i.length;t++){let s=Wt(i[t],e,n);for(let e=0;e<s.length;++e)r.push(s[e])}}else if("MultiPolygon"===t.type)if(n.placement===ur.CENTROID){let i=G.multiCentroid(t.coordinates);i&&r.push(new qt(i,e,n,n.angle))}else{let i=t.coordinates;for(let t=0;t<i.length;t++){let s=i[t];for(let t=0;t<s.length;t++){let i=Wt(s[t],e,n);for(let e=0;e<i.length;++e)r.push(i[e])}}}return r},makeVertexTemplate(e,t,n=!0){let r=0;this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=e.z||0,this.vertex_template[r++]=this.scaleOrder(e.order),this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=e.label.layout.collide?0:1,t.variant.shader_point||(this.vertex_template[r++]=0,this.vertex_template[r++]=0),this.vertex_template[r++]=0,this.vertex_template[r++]=0;const i=e.color||J.defaults.color;if(this.vertex_template[r++]=255*i[0],this.vertex_template[r++]=255*i[1],this.vertex_template[r++]=255*i[2],this.vertex_template[r++]=255*(null!=e.alpha?e.alpha:i[3]),t.variant.selection&&(this.vertex_template[r++]=255*e.selection_color[0],this.vertex_template[r++]=255*e.selection_color[1],this.vertex_template[r++]=255*e.selection_color[2],this.vertex_template[r++]=255*e.selection_color[3]),t.variant.shader_point){const t=e.outline_color||J.defaults.outline.color;this.vertex_template[r++]=255*t[0],this.vertex_template[r++]=255*t[1],this.vertex_template[r++]=255*t[2],this.vertex_template[r++]=255*(null!=e.outline_alpha?e.outline_alpha:t[3]),this.vertex_template[r++]=e.outline_edge_pct||J.defaults.outline.width}return n&&this.addCustomAttributesToVertexTemplate(e,r),this.vertex_template},buildQuad:(e,t,n,r,i,s,o,a,l,u,c)=>t[0]<=0||t[1]<=0?0:function(e,t,n,r,i,s,o,a,l,u,c,h){const d=128*i[0],f=128*i[1];St[0]=-d,St[1]=-f,St[2]=d,St[3]=f;const p=c||Ve,g=t.vertex_elements;let m=t.vertex_count;for(let i=0;i<4;i++)n[r.a_position+0]=e[0],n[r.a_position+1]=e[1],n[r.a_shape+0]=St[At[i]],n[r.a_shape+1]=St[Et[i]],n[r.a_shape+2]=l,n[r.a_offset+0]=s[0],n[r.a_offset+1]=s[1],r.a_texcoord&&(n[r.a_texcoord+0]=65535*p[At[i]],n[r.a_texcoord+1]=65535*p[Et[i]]),h&&(n[r.a_pre_angles+0]=xt*a[0],n[r.a_pre_angles+1]=xt*a[1],n[r.a_pre_angles+2]=xt*a[2],n[r.a_pre_angles+3]=xt*a[3],n[r.a_angles+0]=wt*u[0],n[r.a_angles+1]=wt*u[1],n[r.a_angles+2]=wt*u[2],n[r.a_angles+3]=wt*u[3],n[r.a_offsets+0]=64*o[0],n[r.a_offsets+1]=64*o[1],n[r.a_offsets+2]=64*o[2],n[r.a_offsets+3]=64*o[3]),t.addVertex(n);return g.push(m+0),g.push(m+1),g.push(m+2),g.push(m+2),g.push(m+3),g.push(m+0),2}(e,u,c,u.vertex_layout.index,t,s,o,i,4096*n,r,a,l),build(e,t){let n=e.label;return"curved"===n.type?this.buildCurvedLabel(n,e,t):this.buildStraightLabel(n,e,t)},buildStraightLabel(e,t,n){let r,i,s=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),o=this.makeVertexTemplate(t,s);"point"!==e.type?(r=t.size[e.type],i=t.texcoords[e.type].texcoord):(r=t.size,i=t.texcoords),s.uniforms=s.uniforms||{},t.label_texture?(s.uniforms.u_texture=t.label_texture,s.uniforms.u_point_type=2,s.uniforms.u_apply_color_blocks=!1):t.texture?(s.uniforms.u_texture=t.texture,s.uniforms.u_point_type=1,s.uniforms.u_apply_color_blocks=!0):(s.uniforms.u_texture=k.default,s.uniforms.u_point_type=3,s.uniforms.u_apply_color_blocks=!0);let a=e.offset,l=this.buildQuad(e.position,r,e.angle,null,null,a,null,i,!1,s.vertex_data,o);const u=t.linked&&t.linked.label.id;return this.trackLabel(e,u,s,l,n),l},buildCurvedLabel(e,t,n){let r,i,s=0;for(let o=0;o<e.num_segments;o++){let a=t.size[e.type][o],l=t.texcoords_stroke[o];t.label_texture=t.label_textures[o],r=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),i=this.makeVertexTemplate(t,r),r.uniforms=r.uniforms||{},r.uniforms.u_texture=t.label_texture,r.uniforms.u_point_type=2,r.uniforms.u_apply_color_blocks=!1;let u=e.offset||[0,0],c=e.position,h=e.angles[o],d=e.offsets[o],f=e.pre_angles[o],p=this.buildQuad(c,a,e.angle,h,f,u,d,l,!0,r.vertex_data,i);s+=p;const g=t.linked&&t.linked.label.id;this.trackLabel(e,g,r,p,n)}for(let o=0;o<e.num_segments;o++){let a=t.size[e.type][o],l=t.texcoords[e.type][o].texcoord;t.label_texture=t.label_textures[o],r=this.getTileMesh(n.tile,this.meshVariantTypeForDraw(t)),i=this.makeVertexTemplate(t,r),r.uniforms=r.uniforms||{},r.uniforms.u_texture=t.label_texture,r.uniforms.u_point_type=2,r.uniforms.u_apply_color_blocks=!1;let u=e.offset||[0,0],c=e.position,h=e.angles[o],d=e.offsets[o],f=e.pre_angles[o],p=this.buildQuad(c,a,e.angle,h,f,u,d,l,!0,r.vertex_data,i);s+=p;const g=t.linked&&t.linked.label.id;this.trackLabel(e,g,r,p,n)}return s},trackLabel(e,t,n,r){if(e.layout.collide||e.may_repeat_across_tiles){n.labels=n.labels||{},n.labels[e.id]=n.labels[e.id]||{container:{label:e.toJSON(),linked:t},ranges:[]};const i=2*r,s=n.vertex_data.offset-n.vertex_data.stride*i;n.labels[e.id].ranges.push([s,i])}},buildLines(e,t,n){return this.build(t,n)},buildPoints(e,t,n){return this.build(t,n)},buildPolygons(e,t,n){return this.build(t,n)},vertexLayoutForMeshVariant(e){if(null==this.vertex_layouts[e.shader_point]){const t=[{name:"a_position",size:4,type:fe.SHORT,normalized:!1},{name:"a_shape",size:4,type:fe.SHORT,normalized:!1},{name:"a_texcoord",size:2,type:fe.UNSIGNED_SHORT,normalized:!0,static:e.shader_point?[0,0]:null},{name:"a_offset",size:2,type:fe.SHORT,normalized:!1},{name:"a_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_outline_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.shader_point?null:[0,0,0,0]},{name:"a_outline_edge",size:1,type:fe.FLOAT,normalized:!1,static:e.shader_point?null:0}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.shader_point]=new Le(t)}return this.vertex_layouts[e.shader_point]},meshVariantTypeForDraw(e){const t=e.label_texture||e.texture||hr,n=t+"/"+e.blend_order;return null==this.variants[n]&&(this.variants[n]={key:n,selection:1,shader_point:t===hr,blend_order:e.blend_order,mesh_order:e.label_texture?1:0}),this.variants[n]},makeMesh(e,t,n={}){return n=Object.assign({},n,{fade_in_time:this.fade_in_time}),Pe.makeMesh.call(this,e,t,n)}});const dr=[0,.33,.66,.99];let fr=function(e,t,n,r){const i=[{type:"straight",tolerance:r.no_curving?1.8:1.5},{type:"curved"},{type:"straight",tolerance:2.3}];for(let s=0;s<i.length;s++){let o,a=i[s];if("straight"===a.type?o=new gr(t,n,r,a.tolerance):"curved"===a.type&&!r.no_curving&&n.length>2&&(o=new mr(e,n,r)),o&&!o.throw_away)return o}return!1};class pr{constructor(e){this.id=Vt.nextLabelId(),this.layout=e,this.position=[],this.angle=0,this.offset=e.offset.slice(),this.unit_scale=this.layout.units_per_pixel,this.obbs=[],this.aabbs=[],this.type="",this.throw_away=!1}toJSON(){return{id:this.id,type:this.type,position:this.position,size:this.size,offset:this.offset,angle:this.angle,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:Ut(this.layout)}}static splitLineByOrientation(e){let t=[e[0]],n=0,r=0,i=0,s=t,o=!1;for(let a=1;a<e.length;a++){let l=e[a],u=e[a-1],c=ye.length(ye.sub(l,u));l[0]>u[0]?1===i?(t.push(l),n+=c,n>r&&(s=t,r=n,o=!1)):(t=[u,l],n=c,n>r&&(s=t,r=n,o=!1),i=1):l[0]<u[0]?-1===i?(t.unshift(l),n+=c,n>r&&(s=t,r=n,o=!0)):(t=[l,u],n=c,n>r&&(s=t,r=n,o=!0),i=-1):(-1===i?t.unshift(l):(t.push(l),i=1),n+=c,n>r&&(s=t,r=n,o=-1===i))}return[s,o]}discard(e,t=null){if(this.throw_away)return!0;for(let n=0;n<this.obbs.length;n++){let r={aabb:this.aabbs[n],obb:this.obbs[n]};if(Vt.prototype.occluded.call(r,e,t))return!0}return!1}inTileBounds(){for(let e=0;e<this.aabbs.length;e++){let t={aabb:this.aabbs[e]};if(!Vt.prototype.inTileBounds.call(t))return!1}return!0}static createOBB(e,t,n,r,i,s,o){let a=e[0],l=e[1];return!s||0===s[0]&&0===s[1]||(a+=(s=ye.rot(s,i))[0]*o,l-=s[1]*o),new jt(a,l,-r,t,n)}}class gr extends pr{constructor(e,t,n,r){super(n),this.type="straight",this.size=e,this.throw_away=!this.fit(e,t,n,r)}fit(e,t,n,r){let i,s=this.unit_scale;[t,i]=pr.splitLineByOrientation(t),"number"==typeof n.orientation&&(this.offset[1]+=1.2*(e[1]-n.vertical_buffer),i&&(this.offset[1]*=-1),-1===n.orientation&&(this.offset[1]*=-1));let o=vr(t),a=e[0]*s;for(let i=0;i<t.length-1;i++){let s,l=t[i],u=0,c=0,h=i+1;for(;h<t.length;){let d=t[h-1],f=t[h],p=yr(d,f);if(h!==i+1&&(u+=br(p,s)),Math.abs(u)>.1)break;if(c+=o[h-1],_r(c,a)<r){let t=ye.mult(ye.add(l,f),.5);return this.angle=-p,Math.abs(this.angle-Math.PI/2)<.01&&(this.angle=-Math.PI/2,"number"==typeof n.orientation&&(this.offset[1]*=-1)),this.position=t,this.updateBBoxes(this.position,e,this.angle,this.angle,this.offset),!0}s=p,h++}}return!1}updateBBoxes(e,t,n,r,i){let s=this.unit_scale;this.obbs=[],this.aabbs=[];let o=(t[0]+2*this.layout.buffer[0])*s*Vt.epsilon,a=(t[1]+2*this.layout.buffer[1])*s*Vt.epsilon,l=pr.createOBB(e,o,a,n,r,i,s),u=l.getExtent();this.obbs.push(l),this.aabbs.push(u),this.inTileBounds&&(this.breach=!this.inTileBounds()),this.mayRepeatAcrossTiles&&(this.may_repeat_across_tiles=this.mayRepeatAcrossTiles())}}class mr extends pr{constructor(e,t,n){super(n),this.type="curved",this.angles=[],this.pre_angles=[],this.offsets=[],this.num_segments=e.length,this.sizes=e,this.throw_away=!this.fit(this.sizes,t,n)}toJSON(){return{id:this.id,type:this.type,obbs:this.obbs.map(e=>e.toJSON()),position:this.position,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:Ut(this.layout)}}fit(e,t,n){let r,i=this.unit_scale,s=Math.max(...e.map(e=>e[1])),o=s*i;[t,r]=pr.splitLineByOrientation(t),"number"==typeof n.orientation&&(this.offset[1]+=1.2*(s-n.vertical_buffer),r&&(this.offset[1]*=-1),-1===n.orientation&&(this.offset[1]*=-1));let a=vr(t),l=e.map(e=>e[0]*i),u=a.reduce((e,t)=>e+t,0),c=l.reduce((e,t)=>e+t,0);if(c>u)return!1;let h=t.length-1;if(h-0<2)return!1;let d=mr.curvaturePlacement(t,u,a,c,0,h),f=t[d];if(-1===d||h-d<2)return!1;this.position=f;for(var p=0;p<l.length;p++){this.offsets[p]=[],this.angles[p]=[],this.pre_angles[p]=[];for(var g=0;g<dr.length;g++){let e=dr[g],[n,r]=mr.scaleLine(e,t);f=n[d];let{positions:s,offsets:a,angles:u,pre_angles:c}=mr.placeAtIndex(d,n,r,l),h=a.map(e=>Math.sqrt(e[0]*e[0]+e[1]*e[1])/i);if(0===e){this.angle=1/u.length*u.reduce((e,t)=>e+t);for(let e=0;e<s.length;e++){let t=s[e],n=c[e],r=l[e],a=n+u[e],h=this.angle,d=pr.createOBB(t,r,o,a,h,this.offset,i),f=d.getExtent();this.obbs.push(d),this.aabbs.push(f)}}this.offsets[p].push(h[p]),this.angles[p].push(u[p]),this.pre_angles[p].push(c[p])}}return!0}static curvaturePlacement(e,t,n,r,i,s){i=i||0,s=s||e.length-1;var o=[];for(let t=i+1;t<s;t++){var a=e[t-1],l=e[t],u=e[t+1],c=ye.perp(l,a),h=ye.perp(u,l),d=ye.angleBetween(c,h);d>1&&(d=1/0),o.push(d)}o.push(1/0);var f=[],p=[],g=i,m=0;for(let e=0;e<i;e++)m+=n[e];for(;m+r<t;){for(var _=m+r,y=m,v=g,b=0;v<s&&y+n[v]<_&&(b+=o[v])!==1/0;)y+=n[v],v++;if(0===b)return g;var x=b/(v-g);f.push(b),p.push(x),m+=n[g],g++}if(0===f.length)return-1;var w=Math.min.apply(null,f),A=p[f.indexOf(w)];return w<1.3&&A<.4?f.indexOf(w):-1}static scaleLine(e,t){var n=[t[0]],r=[];return t.forEach((i,s)=>{if(s!==t.length-1){var o=ye.sub(t[s+1],t[s]),a=ye.mult(o,1+e);n.push(ye.add(n[s],a)),r.push(ye.length(a))}}),[n,r]}static placeAtIndex(e,t,n,r){let i=t[e],[s,o]=mr.getIndicesAndOffsets(e,n,r),a=mr.getPositionsFromIndicesAndOffsets(t,s,o),[l,u,c]=mr.getAnglesFromIndicesAndOffsets(i,s,t,a);return{positions:a,offsets:l,angles:u,pre_angles:c}}static getIndicesAndOffsets(e,t,n){let r=n.length,i=[],s=[],o=0,a=0,l=0;for(;o<r;){let u=n[o];for(;o<r&&a+.5*u<=l+t[e];){let t=a-l+.5*u;s.push(t),i.push(e),a+=u,o++,u=n[o]}l+=t[e],e++}return[i,s]}static getPositionsFromIndicesAndOffsets(e,t,n){let r=[];for(let i=0;i<t.length;i++){let s=t[i],o=n[i],a=yr(e[s],e[s+1]),l=ye.rot([o,0],a),u=ye.add(e[s],l);r.push(u)}return r}static getAnglesFromIndicesAndOffsets(e,t,n,r){let i=[],s=[],o=[];for(let a=0;a<r.length;a++){let l=r[a],u=t[a],c=ye.sub(l,e),h=-ye.angle(c),d=-yr(n[u],n[u+1])-h;if(a>0){let e=i[a-1],t=s[a-1];Math.abs(h-e)>Math.PI&&(h+=h>e?-2*Math.PI:2*Math.PI),Math.abs(t-d)>Math.PI&&(d+=d>t?-2*Math.PI:2*Math.PI)}i.push(h),s.push(d),o.push(c)}return[o,i,s]}}function _r(e,t){return t/e}function yr(e,t){let n=ye.sub(t,e);return ye.angle(n)}function vr(e){let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1],s=Math.hypot(r[0]-i[0],r[1]-i[1]);t.push(s)}return t}function br(e,t){let n,r;for(e>t?(n=t,r=e):(n=e,r=t);r-n>Math.PI;)n+=2*Math.PI;return Math.abs(r-n)}let xr=Object.create(cr);Object.assign(xr,{name:"text",super:cr,built_in:!0,init(e={}){Pe.init.call(this,e),this.setupDefines(),this.defines.TANGRAM_HAS_SHADER_POINTS=!1,this.defines.TANGRAM_CURVED_LABEL=!0,this.reset()},makeVertexTemplate(e,t){this.super.makeVertexTemplate.call(this,e,t,!1);let n=t.vertex_data.vertex_layout.index.a_pre_angles;for(let e=0;e<12;e++)this.vertex_template[n++]=0;return this.addCustomAttributesToVertexTemplate(e,n),this.vertex_template},reset(){this.queues={},this.resetText()},addFeature(e,t,n){let r=n.tile;if(r.generation!==this.generation)return;let i=e.geometry.type;t.can_articulate="LineString"===i||"MultiLineString"===i,t.supersample_text="LineString"===i||"MultiLineString"===i;let s=this.parseTextFeature(e,t,n,r);s&&(s instanceof Array?s.forEach(t=>{t.feature=e,t.context=n,t.layout.vertex=!1,this.queueFeature(t,r)}):(s.feature=e,s.context=n,s.layout.vertex=!1,this.queueFeature(s,r)),$t.addStyle(this.name,r.id))},async endData(e){let t=this.queues[e.id];delete this.queues[e.id];const{labels:n,texts:r,textures:i}=await this.collideAndRenderTextLabels(e,this.name,t);n&&r&&(this.texts[e.id]=r,n.forEach(t=>{let n=t.text_settings_key,r=this.texts[e.id][n]&&this.texts[e.id][n][t.text],s=this.feature_style;s.label=t.label,r.text_settings.can_articulate?(s.size={},s.texcoords={},"straight"===t.label.type?(s.size.straight=r.size.logical_size,s.texcoords.straight=r.texcoords.straight,s.label_texture=i[r.texcoords.straight.texture_id]):(s.size.curved=r.segment_sizes.map(function(e){return e.logical_size}),s.texcoords_stroke=r.texcoords_stroke,s.texcoords.curved=r.texcoords.curved,s.label_textures=r.texcoords.curved.map(e=>i[e.texture_id]))):(s.size=r.size.logical_size,s.texcoords=r.align[t.label.align].texcoords,s.label_texture=i[r.align[t.label.align].texture_id]),s.blend_order=t.draw.blend_order,Pe.addFeature.call(this,t.feature,t.draw,t.context)})),this.freeText(e);const s=await Pe.endData.call(this,e);if(s){i&&i.length&&s.textures.push(...i);for(let e in s.meshes)s.meshes[e].uniforms.u_apply_color_blocks=!0}return s},_preprocess(e){return e.blend_order=this.getBlendOrderForDraw(e),this.preprocessText(e)},buildTextLabels(e,t){let n=[];for(let i=0;i<t.length;i++){let s,o=t[i],a=this.texts[e.id][o.text_settings_key][o.text];if(o.layout.vertical_buffer=a.vertical_buffer,a.text_settings.can_articulate){var r=a.segment_sizes.map(e=>e.collision_size);o.layout.no_curving=a.no_curving,s=this.buildLabels(r,o.feature.geometry,o.layout,a.size.collision_size)}else s=this.buildLabels(a.size.collision_size,o.feature.geometry,o.layout);for(let e=0;e<s.length;e++){let t=Object.create(o);t.label=s[e],n.push(t)}}return n},buildLabels(e,t,n,r){let i=[];if("LineString"===t.type)Array.prototype.push.apply(i,this.buildLineLabels(t.coordinates,e,n,r));else if("MultiLineString"===t.type){let s=t.coordinates;for(let t=0;t<s.length;++t)Array.prototype.push.apply(i,this.buildLineLabels(s[t],e,n,r))}else if("Point"===t.type)i.push(new qt(t.coordinates,e,n));else if("MultiPoint"===t.type){let r=t.coordinates;for(let t=0;t<r.length;++t)i.push(new qt(r[t],e,n))}else if("Polygon"===t.type){let r=G.centroid(t.coordinates);r&&i.push(new qt(r,e,n))}else if("MultiPolygon"===t.type){let r=G.multiCentroid(t.coordinates);r&&i.push(new qt(r,e,n))}return i},buildLineLabels(e,t,n,r){let i=[],s=Math.min(n.subdiv,e.length-1);if(s>1){let o=(e.length-1)/s;for(let a=0;a<s;a++){let s=Math.floor(a*o),l=Math.floor((a+1)*o)+1,u=e.slice(s,l),c=fr(t,r,u,n);c&&i.push(c)}}if(i.length<s){let s=fr(t,r,e,n);s&&i.push(s)}return i},vertexLayoutForMeshVariant(e){if(null==this.vertex_layouts[e.shader_point]){const t=[{name:"a_position",size:4,type:fe.SHORT,normalized:!1},{name:"a_shape",size:4,type:fe.SHORT,normalized:!1},{name:"a_texcoord",size:2,type:fe.UNSIGNED_SHORT,normalized:!0},{name:"a_offset",size:2,type:fe.SHORT,normalized:!1},{name:"a_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:fe.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_pre_angles",size:4,type:fe.BYTE,normalized:!1},{name:"a_angles",size:4,type:fe.SHORT,normalized:!1},{name:"a_offsets",size:4,type:fe.UNSIGNED_SHORT,normalized:!1}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.shader_point]=new Le(t)}return this.vertex_layouts[e.shader_point]}}),xr.texture_id=0;let wr=Object.create(et);function Ar(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Er(e){return null!=e}function Sr(e){return"("+e+")"}function Tr(e){return"string"==typeof e?'"'+e+'"':e}function kr(e){return"$"===e[0]?"context['"+e.substring(1)+"']":e.indexOf(".")>-1?-1===e.indexOf("\\.")?`context.feature.properties${e.split(".").map(e=>"['"+e+"']").join("")}`:`context.feature.properties${e.replace(/\\\./g,"__TANGRAM_DELIMITER__").split(".").map(e=>e.replace(/__TANGRAM_DELIMITER__/g,".")).map(e=>"['"+e+"']").join("")}`:"context.feature.properties['"+e+"']"}function Or(e,t){return Sr(Tr(t)+" === "+kr(e))}function Rr(e,t){return Sr(`${"["+t.map(Tr).join(",")+"]"}.indexOf(${kr(e)}) > -1`)}function Cr(e,t){return Sr(e.filter(Er).map(function(e){return Sr(e.join(" && "))}).join(" "+t+" "))}function Pr(e,t,n){return t&&t.length>0?Cr(t.map(function(e){return Lr(e,n)}),"||"):"true"}function Mr(e,t,n){return t&&t.length>0?Cr(t.map(function(e){return Lr(e,n)}),"&&"):"true"}function Nr(e,t,n){return"!"+Sr(Lr(t,n).join(" && "))}function Ir(e,t,n){return"!"+Sr(Pr(0,t,n))}function Dr(e,t){return Sr(kr(e)+(t?" != ":" == ")+"null")}function Fr(e,t,n){var r=[],i=n&&"function"==typeof n.rangeTransform&&n.rangeTransform;if(t.max){var s=i?i(t.max):t.max;r.push(kr(e)+" < "+s)}if(t.min){var o=i?o=i(t.min):t.min;r.push(kr(e)+" >= "+o)}return Sr(r.join(" && "))}function zr(e,t){let n=[];if(t.includes_any){const r="["+(Array.isArray(t.includes_any)?t.includes_any:[t.includes_any]).map(Tr).join(",")+"]";n.push(`${kr(e)} != null && ${r}.some(function(v) { return ${kr(e)}.indexOf(v) > -1 })`)}if(t.includes_all){const r="["+(Array.isArray(t.includes_all)?t.includes_all:[t.includes_all]).map(Tr).join(",")+"]";n.push(`${kr(e)} != null && ${r}.every(function(v) { return ${kr(e)}.indexOf(v) > -1 })`)}return Sr(n.join(" && "))}function Lr(e,t){var n=[];if("function"==typeof e)return[Sr(e.toString()+"(context)")];if(Array.isArray(e))return[Pr(0,e,t)];if(null==e)return["true"];for(var r=Object.keys(e),i=0;i<r.length;i++){var s=r[i],o=e[s],a=typeof o;if("string"===a||"number"===a)n.push(Or(s,o));else if("boolean"===a)n.push(Dr(s,o));else if("not"===s)n.push(Nr(0,o,t));else if("any"===s)n.push(Pr(0,o,t));else if("all"===s)n.push(Mr(0,o,t));else if("none"===s)n.push(Ir(0,o,t));else if(Array.isArray(o))n.push(Rr(s,o));else if("object"===a&&null!=o)o.max||o.min?n.push(Fr(s,o,t)):(o.includes_any||o.includes_all)&&n.push(zr(s,o));else{if(null!=o)throw new Error("Unknown Query syntax: "+o);n.push(" true ")}}return 0===r.length?["true"]:n}function jr(e,t){return null==e?function(){return!0}:new Function("context","return "+Sr(Lr(e,t).join(" && "))+";")}Object.assign(wr,{name:"raster",super:et,built_in:!0,init(){this.raster=this.raster||"color",this.super.init.apply(this,arguments),this.selection=!1},_preprocess(e){return e.color=e.color||J.defaults.color,this.super._preprocess.apply(this,arguments)}});const Vr=["filter","draw","visible","enabled","data","exclusive","priority"];let Ur={};function Br(e,t){let n,r=0;for(let t=0;t<e.length;t++)e[t].length>r&&(r=e[t].length);if(0===r)return null;let i={visible:!0};for(let s=0;s<r;s++)n=[],e.forEach(e=>{e[s]&&e[s][t]&&-1===n.indexOf(e[s][t])&&n.push(e[s][t])}),0!==n.length&&B(i,...n);return!1===i.visible?null:i}const Gr=["any","all","not","none"];class $r{constructor({layer:e,name:t,parent:n,draw:r,visible:i,enabled:s,filter:o,exclusive:a,priority:l,styles:u}){if(this.id=$r.id++,this.config_data=e.data,this.parent=n,this.name=t,this.full_name=this.parent?this.parent.full_name+":"+this.name:this.name,this.draw=r,this.filter=o,this.exclusive=!0===a,this.priority=null!=l?l:Number.MAX_SAFE_INTEGER,this.styles=u,this.is_built=!1,s=void 0===s?i:s,this.enabled=!1!==s,this.draw)for(let e in this.draw)if(this.draw[e]=null==this.draw[e]?{}:this.draw[e],"object"!=typeof this.draw[e]){let t=`Draw group '${e}' for layer ${this.full_name} is invalid, must be an object, `;t+=`but was set to \`${e}: ${this.draw[e]}\` instead`,m("warn",t),delete this.draw[e]}}build(){m("trace",`Building layer '${this.full_name}'`),this.buildFilter(),this.buildDraw(),this.is_built=!0}buildDraw(){this.draw=Z(this.draw,J.wrapFunction),this.calculatedDraw=function(e){let t=[];if(e.parent){let n=e.parent.calculatedDraw||[];t.push(...n)}return t.push(e.draw),t}(this)}buildFilter(){this.filter_original=this.filter,this.filter=Z(this.filter,J.wrapFunction);let e=typeof this.filter;if(null!=this.filter&&"object"!==e&&"function"!==e){let e=`Filter for layer ${this.full_name} is invalid, filter value must be an object or function, `;return e+=`but was set to \`filter: ${this.filter}\` instead`,void m("warn",e)}try{this.buildZooms(),this.buildPropMatches(),null!=this.filter&&("function"==typeof this.filter||Object.keys(this.filter).length>0)?this.filter=jr(this.filter,Wr):this.filter=null}catch(e){let t=`Filter for layer ${this.full_name} is invalid, \`filter: ${JSON.stringify(this.filter)}\` `;t+=`failed with error '${e.message}', stack trace: ${e.stack}`,m("warn",t)}}buildZooms(){let e=this.filter&&this.filter.$zoom,t=typeof e;if(null!=e){if(this.zooms={},"number"===t)this.zooms[e]=!0;else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.zooms[e[t]]=!0;else if("object"===t&&(null!=e.min||null!=e.max)){let t=e.min||0,n=e.max||G.max_style_zoom;for(let e=t;e<n;e++)this.zooms[e]=!0}delete this.filter.$zoom}}buildPropMatches(){this.filter&&!Array.isArray(this.filter)&&"function"!=typeof this.filter&&Object.keys(this.filter).forEach(e=>{if(-1===Gr.indexOf(e)){let t=this.filter[e],n=typeof t,r=Array.isArray(t);if(!r&&"string"!==n&&"number"!==n)return;"$"===e[0]?(this.context_prop_matches=this.context_prop_matches||[],this.context_prop_matches.push([e.substring(1),r?t:[t]]),delete this.filter[e]):-1===e.indexOf(".")&&(this.feature_prop_matches=this.feature_prop_matches||[],this.feature_prop_matches.push([e,r?t:[t]]),delete this.filter[e])}})}doPropMatches(e){if(this.feature_prop_matches)for(let t=0;t<this.feature_prop_matches.length;t++){let n=this.feature_prop_matches[t],r=e.feature.properties[n[0]];if(null==r||-1===n[1].indexOf(r))return!1}if(this.context_prop_matches)for(let t=0;t<this.context_prop_matches.length;t++){let n=this.context_prop_matches[t],r=e[n[0]];if(null==r||-1===n[1].indexOf(r))return!1}return!0}doesMatch(e){if(!this.enabled)return!1;if(this.is_built||this.build(),null!=this.zooms&&!this.zooms[e.zoom])return!1;if(!this.doPropMatches(e))return!1;let t;if(this.filter instanceof Function)try{t=this.filter(e)}catch(t){let n=`Filter for this ${this.full_name}: \`filter: ${this.filter_original}\` `;n+=`failed with error '${t.message}', stack trace: ${t.stack}`,m("error",n,e.feature)}else t=null==this.filter;return!!t&&(this.children_to_parse&&(function(e,t,n){for(let r in t){let i=t[r];if("object"!=typeof i||Array.isArray(i)){let t=`Layer value must be an object: cannot create layer '${r}: ${JSON.stringify(i)}'`;t+=`, under parent layer '${e.full_name}'.`,n[e.name]&&(t+=` The parent name '${e.name}' is also the name of a style, did you mean to create a 'draw' group`,e.parent&&(t+=` under '${e.parent.name}'`),t+=" instead?"),m("warn",t)}else Kr(r,i,e,n)}e.layers.sort((e,t)=>{if(e.exclusive<t.exclusive)return 1;if(e.exclusive>t.exclusive)return-1;const n=e.exclusive?1:-1;return e.priority>t.priority?n:e.priority<t.priority?-n:e.full_name<t.full_name?n:e.full_name>t.full_name?-n:void 0})}(this,this.children_to_parse,this.styles),delete this.children_to_parse),!0)}}$r.id=0;class qr extends $r{constructor(e){super(e),this.is_leaf=!0}}class Hr extends $r{constructor(e){super(e),this.is_tree=!0,this.layers=e.layers||[]}addLayer(e){this.layers.push(e)}buildDrawGroups(e){let t=[],n=[];if(Xr(e,[this],t,n),t.length>0){let e=function(e){if(e.length>1){for(var t=e[0],n=1;n<e.length;n++)t+="/"+e[n];return t}return e[0]}(n);if(void 0===Ur[e]){let n=t.map(e=>e&&!1!==e.visible&&e.calculatedDraw),r={};for(let e=0;e<n.length;e++){let t=n[e];if(t)for(let e=0;e<t.length;e++){let n=t[e];for(let e in n)r[e]=!0}}for(let i in r)Ur[e]=Ur[e]||{},Ur[e][i]=Br(n,i),Ur[e][i]?(Ur[e][i].key=e+"/"+i,Ur[e][i].layers=t.map(e=>e&&e.full_name),Ur[e][i].group=i):delete Ur[e][i];Ur[e]&&0===Object.keys(Ur[e]).length&&(Ur[e]=null)}return Ur[e]}}}const Wr={rangeTransform:e=>"string"==typeof e&&"px2"===e.trim().slice(-3)?`${parseFloat(e)} * context.meters_per_pixel_sq`:e};function Zr(e){return Vr.indexOf(e)>-1}function Kr(e,t,n,r){let i={name:e,layer:t=null==t?{}:t,parent:n,styles:r},[s,o]=function(e){let t={},n={};for(let r in e)Zr(r)?t[r]=e[r]:n[r]=e[r];return[t,n]}(t),a=(l=o,0===Object.keys(l).length);var l;let u;u=a&&null!=n?qr:Hr;let c=new u(Object.assign(i,s));return c.enabled&&(n&&n.addLayer(c),c.children_to_parse=a?null:o),c}function Xr(e,t,n,r){let i=!1,s=!1;if(0!==t.length){for(let o=0;o<t.length;o++){let a=t[o];if(a.is_leaf){if(a.doesMatch(e)&&(i=!0,n.push(a),r.push(a.id),a.exclusive))break}else if(a.is_tree&&a.doesMatch(e)&&(i=!0,s=Xr(e,a.layers,n,r),s||(n.push(a),r.push(a.id)),a.exclusive))break}return i}}function Yr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yr(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}let Jr=0,ei=0;class ti{constructor({coords:e,style_z:t,source:n,workers:r,view:i}){this.id=Jr++,this.view=i,this.source=n,this.generation=null,this.valid=!0,this.visible=!1,this.proxy_for=null,this.proxied_as=null,this.proxy_level=0,this.proxy_order_offset=0,this.fade_in=!0,this.loading=!1,this.loaded=!1,this.built=!1,this.labeled=!1,this.error=null,this.debug={},this.style_z=t,this.coords=Te.normalizedCoord(e,this.source),this.key=Te.key(this.coords,this.source,this.style_z),this.overzoom=Math.max(this.style_z-this.coords.z,0),this.overzoom2=Math.pow(2,this.overzoom),this.min=G.metersForTile(this.coords),this.max=G.metersForTile({x:this.coords.x+1,y:this.coords.y+1,z:this.coords.z}),this.span={x:this.max.x-this.min.x,y:-(this.max.y-this.min.y)},this.bounds={sw:{x:this.min.x,y:this.max.y},ne:{x:this.max.x,y:this.min.y}},this.meters_per_pixel=G.metersPerPixel(this.style_z),this.meters_per_pixel_sq=this.meters_per_pixel*this.meters_per_pixel,this.units_per_pixel=G.units_per_pixel/this.overzoom2,this.units_per_meter_overzoom=G.unitsPerMeter(this.coords.z)*this.overzoom2,this.preserve_tiles_within_zoom=this.source.preserve_tiles_within_zoom,this.meshes={},this.new_mesh_styles=[],this.pending_label_meshes=null,this.setWorker(r)}freeResources(){for(let e in this.meshes)this.meshes[e].forEach(e=>e.destroy());if(this.meshes={},this.pending_label_meshes)for(let e in this.pending_label_meshes)this.pending_label_meshes[e].forEach(e=>e.destroy());this.pending_label_meshes=null}destroy(){E.removeForTile(this.id),this.workerMessage("self.removeTile",this.key),this.freeResources(),this.worker=null,this.valid=!1}buildAsMessage(){return{id:this.id,key:this.key,source:this.source.name,coords:this.coords,min:this.min,max:this.max,units_per_pixel:this.units_per_pixel,meters_per_pixel:this.meters_per_pixel,meters_per_pixel_sq:this.meters_per_pixel_sq,units_per_meter_overzoom:this.units_per_meter_overzoom,style_z:this.style_z,overzoom:this.overzoom,overzoom2:this.overzoom2,generation:this.generation,debug:this.debug}}setWorker(e){this.source.tiled?this.worker_id=Math.abs(this.coords.x+this.coords.y+this.coords.z)%e.length:this.worker_id=this.source.id%e.length,this.worker=e[this.worker_id]}workerMessage(...e){return a.postMessage(this.worker,...e)}build(e,{fade_in:t=!0}={}){return this.generation=e,this.fade_in=t,this.loaded||(this.loading=!0,this.built=!1,this.labeled=!1),this.workerMessage("self.buildTile",{tile:this.buildAsMessage()}).catch(e=>{throw e})}static cancel(e){e&&(e.canceled=!0,e.source_data&&e.source_data.request_id&&(_.cancelRequest(e.source_data.request_id),e.source_data.request_id=null),ti.abortBuild(e))}static buildGeometry(e,{scene_id:t,layers:n,styles:r,global:i}){let s=e.source_data;e.debug.building=+new Date,e.debug.feature_count=0,e.debug.layers=null,$t.startTile(e.id,{apply_repeat_groups:!0});for(let t in n){let o=n[t];if(!o||!o.config_data){m("warn",`Layer ${t} was defined without a geometry data source and will not be rendered.`);continue}if(o.config_data.source!==e.source)continue;let a=ti.getDataForSource(s,o.config_data,t);for(let n=0;n<a.length;n++){let s=a[n],l=s.geom;if(l)for(let n=0;n<l.features.length;n++){let a=l.features[n];if(null==a.geometry)continue;let u=J.getFeatureParseContext(a,e,i);u.winding=e.default_winding,u.source=e.source,u.layer=s.layer;let c=o.buildDrawGroups(u,!0);if(c){for(let e in c){let n=c[e],i=n.style||e,s=r[i];s?(n=s.preprocess(n),null!=n&&!1!==n.visible&&(u.layers=n.layers,s.addFeature(a,n,u))):m("warn",`Style '${i}' not found, skipping layer '${t}':`,n,a)}e.debug.feature_count++}}}}e.debug.building=+new Date-e.debug.building;let o=this.stylesForTile(e,r).map(e=>r[e]);ti.buildStyleGroups(e,o,t,e=>e.collision?"collision":"non-collision")}static stylesForTile(e,t){let n=[];for(let r in t)t[r].hasDataForTile(e)&&n.push(r);return n}static buildStyleGroups(e,t,n,r){const i=t.reduce((e,t)=>{const n=r(t);return e[n]=e[n]||[],e[n].push(t),e},{});if(0===Object.keys(i).length)return a.postMessage(`TileManager_${n}.buildTileStylesCompleted`,a.withTransferables({tile:ti.slice(e),progress:{start:!0,done:!0}})),void $t.resetTile(e.id);const s={};for(const t in i)ti.buildStyleGroup({group_name:t,groups:i,tile:e,progress:s,scene_id:n})}static async buildStyleGroup({group_name:e,groups:t,tile:n,progress:r,scene_id:i}){const s=t[e],o={};try{await Promise.all(s.map(async function(e){const t=await e.endData(n);t&&(o[e.name]=t)})),m("trace",`Finished style group '${e}' for tile ${n.key}`),t[e]=null,Object.keys(t).every(e=>null==t[e])&&(r.done=!0),a.postMessage(`TileManager_${i}.buildTileStylesCompleted`,a.withTransferables({tile:Qr(Qr({},ti.slice(n)),{},{mesh_data:o}),progress:r})),r.done&&$t.resetTile(n.id)}catch(t){m("error",`Error for style group '${e}' for tile ${n.key}`,t&&t.stack||t)}}static getDataForSource(e,t,n){var r=[];if(null!=t&&null!=e&&null!=e.layers)if(!0===t.all_layers){null!=t.layer&&m({level:"warn",once:!0},`Layer ${n} includes both 'all_layers: true' and an explicit 'layer' keyword in its 'data' block. 'all_layers: true' takes precedence, 'layer' will be ignored.`);for(const t in e.layers)r.push({layer:t,geom:e.layers[t]})}else!t.layer&&e.layers._default?r.push({geom:e.layers._default}):!t.layer&&n?r.push({layer:n,geom:e.layers[n]}):"string"==typeof t.layer?r.push({layer:t.layer,geom:e.layers[t.layer]}):Array.isArray(t.layer)&&t.layer.forEach(t=>{r.push({layer:t,geom:e.layers[t]})});return r}buildMeshes(e,t){if(this.error)return;this.build_id=ei++,t.start&&(this.debug.geometry_count=0,this.debug.buffer_size=0);let n={},r=this.mesh_data;if(r)for(let t in r){for(let i in r[t].meshes){let s=r[t].meshes[i];if(s.vertex_data){if(!e[t]){m("warn",`Could not create mesh because style '${t}' not found, for tile ${this.key}, aborting tile`);break}let i=Object.assign({},r[t]);i.uniforms=Object.assign({},i.uniforms,s.uniforms),i.variant=s.variant,s.labels&&(i.retain=!0);let o=e[t].makeMesh(s.vertex_data,s.vertex_elements,i);o.variant=i.variant,o.labels=s.labels,n[t]=n[t]||[],n[t].push(o),null==o.variant.mesh_order&&(o.variant.mesh_order=n[t].length-1),this.debug.buffer_size+=o.buffer_size,this.debug.geometry_count+=o.geometry_count}}n[t]&&n[t].sort((e,t)=>{let n=e.variant.mesh_order,r=t.variant.mesh_order;return null==n?1:null==r||n<r?-1:1})}delete this.mesh_data;for(let t in n)e[t].collision?(this.pending_label_meshes=this.pending_label_meshes||{},this.pending_label_meshes[t]=n[t]):(this.meshes[t]&&this.meshes[t].forEach(e=>e.destroy()),this.meshes[t]=n[t],this.new_mesh_styles.push(t));if(t.done){for(let e in this.meshes)-1!==this.new_mesh_styles.indexOf(e)||this.pending_label_meshes&&null!=this.pending_label_meshes[e]||(this.meshes[e].forEach(e=>e.destroy()),delete this.meshes[e]);this.new_mesh_styles=[],this.debug.geometry_ratio=(this.debug.geometry_count/this.debug.feature_count).toFixed(1)}this.printDebug(t)}pendingLabelStyleCount(){return this.pending_label_meshes?Object.keys(this.pending_label_meshes).length:0}swapPendingLabels(){if(this.labeled=!0,this.pending_label_meshes){for(let e in this.pending_label_meshes)this.meshes[e]&&this.meshes[e].forEach(e=>e.destroy()),this.meshes[e]=this.pending_label_meshes[e];this.pending_label_meshes=null}}static abortBuild(e){if(E.removeForTile(e.id),$t.abortTile(e.id),e.mesh_data)for(let t in e.mesh_data){let n=e.mesh_data[t].textures;n&&n.forEach(t=>{let n=k.textures[t];n&&(m("trace",`releasing texture ${t} for tile ${e.key}`),n.release())})}}setProxyFor(e){e?(this.visible=!0,this.proxy_for=this.proxy_for||[],this.proxy_for.push(e),this.proxy_order_offset=1,e.proxied_as=e.style_z>this.style_z?"child":"parent",this.proxy_level=Math.abs(e.style_z-this.style_z)):(this.proxy_for=null,this.proxy_order_offset=0,this.proxy_level=0)}isProxy(){return null!=this.proxy_for}shouldProxyForStyle(e){return!this.proxy_for||this.proxy_for.some(t=>null==t.meshes[e])}setupProgram({model:e,model32:t},n){n.uniform("4fv","u_tile_origin",[this.min.x,this.min.y,this.style_z,this.coords.z]),n.uniform("1f","u_tile_proxy_order_offset",this.proxy_order_offset),ir.identity(e),ir.translate(e,e,nr.fromValues(this.min.x,this.min.y,0)),ir.scale(e,e,nr.fromValues(this.span.x/G.tile_scale,this.span.y/G.tile_scale,1)),ir.copy(t,e),n.uniform("Matrix4fv","u_model",t),n.uniform("1i","u_tile_fade_in",this.fade_in&&"child"!==this.proxied_as)}static slice(e,t){let n=["id","key","loading","loaded","generation","error","debug"];Array.isArray(t)&&n.push(...t);var r={};for(let t=0;t<n.length;t++){const i=n[t];r[i]=e[i]}return r}merge(e){return this.loading=e.loading,this.loaded=e.loaded,this.generation=e.generation,this.error=e.error,this.mesh_data=e.mesh_data,this.debug=B(this.debug,e.debug),this}printDebug(e){const t=["layers"];let n={};for(let e in this.debug)-1===t.indexOf(e)&&(n[e]=this.debug[e]);m("debug",`Tile ${e.done?"(done)":""}: debug for ${this.key}: [ ${JSON.stringify(n)} ]`)}}function ni(e,t){for(let n in e){let r=e[n];Me(t,n,r.features,r.geoms,r.styles,r.base),r.layers&&(t[n].layers=t[n].layers||{},ni(r.layers,t[n].layers))}}ti.coord_children={};var ri,ii,si,oi={};var ai,li,ui,ci,hi,di,fi,pi,gi,mi=function(){if(si)return ii;si=1,ii=t;var e=(ri||(ri=1,oi.read=function(e,t,n,r,i){var s,o,a=8*i-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+e[t+h],h+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=256*o+e[t+h],h+=d,c-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),s-=u}return(f?-1:1)*o*Math.pow(2,s-r)},oi.write=function(e,t,n,r,i,s){var o,a,l,u=8*s-i-1,c=(1<<u)-1,h=c>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:s-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(t*l-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[n+f]=255&o,f+=p,o/=256,u-=8);e[n+f-p]|=128*g}),oi);function t(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}t.Varint=0,t.Fixed64=1,t.Bytes=2,t.Fixed32=5;var n=4294967296,r=1/n;function i(e){return e.type===t.Bytes?e.readVarint()+e.pos:e.pos+1}function s(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function o(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.ceil(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function a(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function l(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function u(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function c(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function h(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function d(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function f(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function p(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function g(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function m(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function _(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function y(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}return t.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,s=this.pos;this.type=7&r,e(i,t,this),this.pos===s&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=m(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=y(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=m(this.buf,this.pos)+m(this.buf,this.pos+4)*n;return this.pos+=8,e},readSFixed64:function(){var e=m(this.buf,this.pos)+y(this.buf,this.pos+4)*n;return this.pos+=8,e},readFloat:function(){var t=e.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=e.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(e){var t,n,r=this.buf;return t=127&(n=r[this.pos++]),n<128?t:(t|=(127&(n=r[this.pos++]))<<7,n<128?t:(t|=(127&(n=r[this.pos++]))<<14,n<128?t:(t|=(127&(n=r[this.pos++]))<<21,n<128?t:function(e,t,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return s(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return s(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return s(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return s(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return s(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return s(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=function(e,t,n){for(var r="",i=t;i<n;){var s,o,a,l=e[i],u=null,c=l>239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(s=e[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&((u=(15&l)<<12|(63&s)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&((u=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,this.pos,e);return this.pos=e,t},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){var n=i(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var n=7&e;if(n===t.Varint)for(;this.buf[this.pos++]>127;);else if(n===t.Bytes)this.pos=this.readVarint()+this.pos;else if(n===t.Fixed32)this.pos+=4;else{if(n!==t.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),_(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),_(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),_(this.buf,-1&e,this.pos),_(this.buf,Math.floor(e*r),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),_(this.buf,-1&e,this.pos),_(this.buf,Math.floor(e*r),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos]=127&e}(n,0,t),function(e,t){var n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var r,i,s=0;s<t.length;s++){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){r>56319||s+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&o(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),e.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),e.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var r=this.pos-n;r>=128&&o(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,n,r){this.writeTag(e,t.Bytes),this.writeRawMessage(n,r)},writePackedVarint:function(e,t){this.writeMessage(e,a,t)},writePackedSVarint:function(e,t){this.writeMessage(e,l,t)},writePackedBoolean:function(e,t){this.writeMessage(e,h,t)},writePackedFloat:function(e,t){this.writeMessage(e,u,t)},writePackedDouble:function(e,t){this.writeMessage(e,c,t)},writePackedFixed32:function(e,t){this.writeMessage(e,d,t)},writePackedSFixed32:function(e,t){this.writeMessage(e,f,t)},writePackedFixed64:function(e,t){this.writeMessage(e,p,t)},writePackedSFixed64:function(e,t){this.writeMessage(e,g,t)},writeBytesField:function(e,n){this.writeTag(e,t.Bytes),this.writeBytes(n)},writeFixed32Field:function(e,n){this.writeTag(e,t.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(e,n){this.writeTag(e,t.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(e,n){this.writeTag(e,t.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(e,n){this.writeTag(e,t.Fixed64),this.writeSFixed64(n)},writeVarintField:function(e,n){this.writeTag(e,t.Varint),this.writeVarint(n)},writeSVarintField:function(e,n){this.writeTag(e,t.Varint),this.writeSVarint(n)},writeStringField:function(e,n){this.writeTag(e,t.Bytes),this.writeString(n)},writeFloatField:function(e,n){this.writeTag(e,t.Fixed32),this.writeFloat(n)},writeDoubleField:function(e,n){this.writeTag(e,t.Fixed64),this.writeDouble(n)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}},ii}(),_i=M(mi),yi={};function vi(){if(ci)return ui;ci=1;var e=function(){if(li)return ai;function e(e,t){this.x=e,this.y=t}return li=1,ai=e,e.prototype={clone:function(){return new e(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[0]*this.x+e[1]*this.y,n=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=n,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),n=Math.sin(e),r=t*this.x-n*this.y,i=n*this.x+t*this.y;return this.x=r,this.y=i,this},_rotateAround:function(e,t){var n=Math.cos(e),r=Math.sin(e),i=t.x+n*(this.x-t.x)-r*(this.y-t.y),s=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=i,this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},e.convert=function(t){return t instanceof e?t:Array.isArray(t)?new e(t[0],t[1]):t},ai}();function t(e,t,r,i,s){this.properties={},this.extent=r,this.type=0,this._pbf=e,this._geometry=-1,this._keys=i,this._values=s,e.readFields(n,this,t)}function n(e,t,n){1==e?t.id=n.readVarint():2==e?function(e,t){for(var n=e.readVarint()+e.pos;e.pos<n;){var r=t._keys[e.readVarint()],i=t._values[e.readVarint()];t.properties[r]=i}}(n,t):3==e?t.type=n.readVarint():4==e&&(t._geometry=n.pos)}function r(e){for(var t,n,r=0,i=0,s=e.length,o=s-1;i<s;o=i++)t=e[i],r+=((n=e[o]).x-t.x)*(t.y+n.y);return r}return ui=t,t.types=["Unknown","Point","LineString","Polygon"],t.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var n,r=t.readVarint()+t.pos,i=1,s=0,o=0,a=0,l=[];t.pos<r;){if(!s){var u=t.readVarint();i=7&u,s=u>>3}if(s--,1===i||2===i)o+=t.readSVarint(),a+=t.readSVarint(),1===i&&(n&&l.push(n),n=[]),n.push(new e(o,a));else{if(7!==i)throw new Error("unknown command "+i);n&&n.push(n[0].clone())}}return n&&l.push(n),l},t.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,r=0,i=0,s=0,o=1/0,a=-1/0,l=1/0,u=-1/0;e.pos<t;){if(!r){var c=e.readVarint();n=7&c,r=c>>3}if(r--,1===n||2===n)(i+=e.readSVarint())<o&&(o=i),i>a&&(a=i),(s+=e.readSVarint())<l&&(l=s),s>u&&(u=s);else if(7!==n)throw new Error("unknown command "+n)}return[o,l,a,u]},t.prototype.toGeoJSON=function(e,n,i){var s,o,a=this.extent*Math.pow(2,i),l=this.extent*e,u=this.extent*n,c=this.loadGeometry(),h=t.types[this.type];function d(e){for(var t=0;t<e.length;t++){var n=e[t],r=180-360*(n.y+u)/a;e[t]=[360*(n.x+l)/a-180,360/Math.PI*Math.atan(Math.exp(r*Math.PI/180))-90]}}switch(this.type){case 1:var f=[];for(s=0;s<c.length;s++)f[s]=c[s][0];d(c=f);break;case 2:for(s=0;s<c.length;s++)d(c[s]);break;case 3:for(c=function(e){var t=e.length;if(t<=1)return[e];for(var n,i,s=[],o=0;o<t;o++){var a=r(e[o]);0!==a&&(void 0===i&&(i=a<0),i===a<0?(n&&s.push(n),n=[e[o]]):n.push(e[o]))}return n&&s.push(n),s}(c),s=0;s<c.length;s++)for(o=0;o<c[s].length;o++)d(c[s][o])}1===c.length?c=c[0]:h="Multi"+h;var p={type:"Feature",geometry:{type:h,coordinates:c},properties:this.properties};return"id"in this&&(p.id=this.id),p},ui}function bi(){if(di)return hi;di=1;var e=vi();function t(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(n,this,t),this.length=this._features.length}function n(e,t,n){15===e?t.version=n.readVarint():1===e?t.name=n.readString():5===e?t.extent=n.readVarint():2===e?t._features.push(n.pos):3===e?t._keys.push(n.readString()):4===e&&t._values.push(function(e){for(var t=null,n=e.readVarint()+e.pos;e.pos<n;){var r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(n))}return hi=t,t.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var n=this._pbf.readVarint()+this._pbf.pos;return new e(this._pbf,n,this.extent,this._keys,this._values)},hi}var xi=(gi||(gi=1,yi.VectorTile=function(){if(pi)return fi;pi=1;var e=bi();function t(t,n,r){if(3===t){var i=new e(r,r.readVarint()+r.pos);i.length&&(n[i.name]=i)}}return fi=function(e,n){this.layers=e.readFields(t,{},n)},fi}(),yi.VectorTileFeature=vi(),yi.VectorTileLayer=bi()),yi);const wi=["{","["];class Ai extends Se{constructor(e,t){super(e,t),this.response_type="arraybuffer",!0===e.parse_json?this.parse_json_type=1:Array.isArray(e.parse_json)?(this.parse_json_type=2,this.parse_json_prop_list=e.parse_json):(null!=e.parse_json&&m({level:"warn",once:!0},`Data source '${this.name}': 'parse_json' parameter should be 'true', or an array of property names (was '${JSON.stringify(e.parse_json)}')`),this.parse_json_type=0)}parseSourceData(e,t,n){var r=new Uint8Array(n),i=new _i(r);if(t.data=new xi.VectorTile(i),t.layers=this.toGeoJSON(t.data),"function"==typeof this.transform){const n={min:Object.assign({},e.min),max:Object.assign({},e.max),coords:Object.assign({},e.coords)};t.layers=this.transform(t.layers,this.extra_data,n)}delete t.data}toGeoJSON(e){var t={};for(var n in e.layers){for(var r=e.layers[n],i=G.tile_scale/r.extent,s={type:"FeatureCollection",features:[]},o=0;o<r.length;o++){var a=r.feature(o),l={type:"Feature",geometry:{},id:a.id,properties:a.properties};this.parseJSONProperties(l);for(var u=l.geometry,c=a.loadGeometry(),h=0;h<c.length;h++)for(var d=c[h],f=0;f<d.length;f++)d[f]=[d[f].x*i,d[f].y*i];u.coordinates=c,"Point"===xi.VectorTileFeature.types[a.type]?1===c.length?(u.type="Point",u.coordinates=u.coordinates[0][0]):(u.type="MultiPoint",u.coordinates=u.coordinates[0]):"LineString"===xi.VectorTileFeature.types[a.type]?1===c.length?(u.type="LineString",u.coordinates=u.coordinates[0]):u.type="MultiLineString":"Polygon"===xi.VectorTileFeature.types[a.type]&&(u=Ei(u)),s.features.push(l)}t[n]=s}return t}parseJSONProperties(e){if(0!==this.parse_json_type){const t=e.properties;if(2===this.parse_json_type)this.parse_json_prop_list.forEach(e=>{try{t[e]=JSON.parse(t[e])}catch(e){}});else for(const n in t)if(wi.indexOf(t[n][0])>-1)try{t[n]=JSON.parse(t[n])}catch(e){}}}}function Ei(e){let t,n=[],r=[];for(let i=0;i<e.coordinates.length;i++){let s=e.coordinates[i],o=G.ringWinding(s);null!=o&&(t=t||o,o===t&&r.length>0&&(n.push(r),r=[]),r.push(s))}return r.length>0&&n.push(r),1===n.length?(e.type="Polygon",e.coordinates=n[0]):n.length>1?(e.type="MultiPolygon",e.coordinates=n):e=null,e}function Si(e,t,n,r){for(var i,s=r,o=n-t>>1,a=n-t,l=e[t],u=e[t+1],c=e[n],h=e[n+1],d=t+3;d<n;d+=3){var f=Ti(e[d],e[d+1],l,u,c,h);if(f>s)i=d,s=f;else if(f===s){var p=Math.abs(d-o);p<a&&(i=d,a=p)}}s>r&&(i-t>3&&Si(e,t,i,r),e[i+2]=s,n-i>3&&Si(e,i,n,r))}function Ti(e,t,n,r,i,s){var o=i-n,a=s-r;if(0!==o||0!==a){var l=((e-n)*o+(t-r)*a)/(o*o+a*a);l>1?(n=i,r=s):l>0&&(n+=o*l,r+=a*l)}return(o=e-n)*o+(a=t-r)*a}function ki(e,t,n,r){var i={id:void 0===e?null:e,type:t,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,n=e.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)Oi(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r<t.length;r++)Oi(e,t[r]);else if("MultiPolygon"===n)for(r=0;r<t.length;r++)for(var i=0;i<t[r].length;i++)Oi(e,t[r][i])}(i),i}function Oi(e,t){for(var n=0;n<t.length;n+=3)e.minX=Math.min(e.minX,t[n]),e.minY=Math.min(e.minY,t[n+1]),e.maxX=Math.max(e.maxX,t[n]),e.maxY=Math.max(e.maxY,t[n+1])}function Ri(e,t,n,r){if(t.geometry){var i=t.geometry.coordinates,s=t.geometry.type,o=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2),a=[],l=t.id;if(n.promoteId?l=t.properties[n.promoteId]:n.generateId&&(l=r||0),"Point"===s)Ci(i,a);else if("MultiPoint"===s)for(var u=0;u<i.length;u++)Ci(i[u],a);else if("LineString"===s)Pi(i,a,o,!1);else if("MultiLineString"===s){if(n.lineMetrics){for(u=0;u<i.length;u++)a=[],Pi(i[u],a,o,!1),e.push(ki(l,"LineString",a,t.properties));return}Mi(i,a,o,!1)}else if("Polygon"===s)Mi(i,a,o,!0);else{if("MultiPolygon"!==s){if("GeometryCollection"===s){for(u=0;u<t.geometry.geometries.length;u++)Ri(e,{id:l,geometry:t.geometry.geometries[u],properties:t.properties},n,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(u=0;u<i.length;u++){var c=[];Mi(i[u],c,o,!0),a.push(c)}}e.push(ki(l,s,a,t.properties))}}function Ci(e,t){t.push(Ni(e[0])),t.push(Ii(e[1])),t.push(0)}function Pi(e,t,n,r){for(var i,s,o=0,a=0;a<e.length;a++){var l=Ni(e[a][0]),u=Ii(e[a][1]);t.push(l),t.push(u),t.push(0),a>0&&(o+=r?(i*u-l*s)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-s,2))),i=l,s=u}var c=t.length-3;t[2]=1,Si(t,0,c,n),t[c+2]=1,t.size=Math.abs(o),t.start=0,t.end=t.size}function Mi(e,t,n,r){for(var i=0;i<e.length;i++){var s=[];Pi(e[i],s,n,r),t.push(s)}}function Ni(e){return e/360+.5}function Ii(e){var t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function Di(e,t,n,r,i,s,o,a){if(r/=t,s>=(n/=t)&&o<r)return e;if(o<n||s>=r)return null;for(var l=[],u=0;u<e.length;u++){var c=e[u],h=c.geometry,d=c.type,f=0===i?c.minX:c.minY,p=0===i?c.maxX:c.maxY;if(f>=n&&p<r)l.push(c);else if(!(p<n||f>=r)){var g=[];if("Point"===d||"MultiPoint"===d)Fi(h,g,n,r,i);else if("LineString"===d)zi(h,g,n,r,i,!1,a.lineMetrics);else if("MultiLineString"===d)ji(h,g,n,r,i,!1);else if("Polygon"===d)ji(h,g,n,r,i,!0);else if("MultiPolygon"===d)for(var m=0;m<h.length;m++){var _=[];ji(h[m],_,n,r,i,!0),_.length&&g.push(_)}if(g.length){if(a.lineMetrics&&"LineString"===d){for(m=0;m<g.length;m++)l.push(ki(c.id,d,g[m],c.tags));continue}"LineString"!==d&&"MultiLineString"!==d||(1===g.length?(d="LineString",g=g[0]):d="MultiLineString"),"Point"!==d&&"MultiPoint"!==d||(d=3===g.length?"Point":"MultiPoint"),l.push(ki(c.id,d,g,c.tags))}}}return l.length?l:null}function Fi(e,t,n,r,i){for(var s=0;s<e.length;s+=3){var o=e[s+i];o>=n&&o<=r&&(t.push(e[s]),t.push(e[s+1]),t.push(e[s+2]))}}function zi(e,t,n,r,i,s,o){for(var a,l,u=Li(e),c=0===i?Ui:Bi,h=e.start,d=0;d<e.length-3;d+=3){var f=e[d],p=e[d+1],g=e[d+2],m=e[d+3],_=e[d+4],y=0===i?f:p,v=0===i?m:_,b=!1;o&&(a=Math.sqrt(Math.pow(f-m,2)+Math.pow(p-_,2))),y<n?v>n&&(l=c(u,f,p,m,_,n),o&&(u.start=h+a*l)):y>r?v<r&&(l=c(u,f,p,m,_,r),o&&(u.start=h+a*l)):Vi(u,f,p,g),v<n&&y>=n&&(l=c(u,f,p,m,_,n),b=!0),v>r&&y<=r&&(l=c(u,f,p,m,_,r),b=!0),!s&&b&&(o&&(u.end=h+a*l),t.push(u),u=Li(e)),o&&(h+=a)}var x=e.length-3;f=e[x],p=e[x+1],g=e[x+2],(y=0===i?f:p)>=n&&y<=r&&Vi(u,f,p,g),x=u.length-3,s&&x>=3&&(u[x]!==u[0]||u[x+1]!==u[1])&&Vi(u,u[0],u[1],u[2]),u.length&&t.push(u)}function Li(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ji(e,t,n,r,i,s){for(var o=0;o<e.length;o++)zi(e[o],t,n,r,i,s,!1)}function Vi(e,t,n,r){e.push(t),e.push(n),e.push(r)}function Ui(e,t,n,r,i,s){var o=(s-t)/(r-t);return e.push(s),e.push(n+(i-n)*o),e.push(1),o}function Bi(e,t,n,r,i,s){var o=(s-n)/(i-n);return e.push(t+(r-t)*o),e.push(s),e.push(1),o}function Gi(e,t){for(var n=[],r=0;r<e.length;r++){var i,s=e[r],o=s.type;if("Point"===o||"MultiPoint"===o||"LineString"===o)i=$i(s.geometry,t);else if("MultiLineString"===o||"Polygon"===o){i=[];for(var a=0;a<s.geometry.length;a++)i.push($i(s.geometry[a],t))}else if("MultiPolygon"===o)for(i=[],a=0;a<s.geometry.length;a++){for(var l=[],u=0;u<s.geometry[a].length;u++)l.push($i(s.geometry[a][u],t));i.push(l)}n.push(ki(s.id,o,i,s.tags))}return n}function $i(e,t){var n=[];n.size=e.size,void 0!==e.start&&(n.start=e.start,n.end=e.end);for(var r=0;r<e.length;r+=3)n.push(e[r]+t,e[r+1],e[r+2]);return n}function qi(e,t){if(e.transformed)return e;var n,r,i,s=1<<e.z,o=e.x,a=e.y;for(n=0;n<e.features.length;n++){var l=e.features[n],u=l.geometry,c=l.type;if(l.geometry=[],1===c)for(r=0;r<u.length;r+=2)l.geometry.push(Hi(u[r],u[r+1],t,s,o,a));else for(r=0;r<u.length;r++){var h=[];for(i=0;i<u[r].length;i+=2)h.push(Hi(u[r][i],u[r][i+1],t,s,o,a));l.geometry.push(h)}}return e.transformed=!0,e}function Hi(e,t,n,r,i,s){return[Math.round(n*(e*r-i)),Math.round(n*(t*r-s))]}function Wi(e,t,n,r,i){for(var s=t===i.maxZoom?0:i.tolerance/((1<<t)*i.extent),o={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:n,y:r,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){o.numFeatures++,Zi(o,e[a],s,i);var l=e[a].minX,u=e[a].minY,c=e[a].maxX,h=e[a].maxY;l<o.minX&&(o.minX=l),u<o.minY&&(o.minY=u),c>o.maxX&&(o.maxX=c),h>o.maxY&&(o.maxY=h)}return o}function Zi(e,t,n,r){var i=t.geometry,s=t.type,o=[];if("Point"===s||"MultiPoint"===s)for(var a=0;a<i.length;a+=3)o.push(i[a]),o.push(i[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===s)Ki(o,i,e,n,!1,!1);else if("MultiLineString"===s||"Polygon"===s)for(a=0;a<i.length;a++)Ki(o,i[a],e,n,"Polygon"===s,0===a);else if("MultiPolygon"===s)for(var l=0;l<i.length;l++){var u=i[l];for(a=0;a<u.length;a++)Ki(o,u[a],e,n,!0,0===a)}if(o.length){var c=t.tags||null;if("LineString"===s&&r.lineMetrics){for(var h in c={},t.tags)c[h]=t.tags[h];c.mapbox_clip_start=i.start/i.size,c.mapbox_clip_end=i.end/i.size}var d={geometry:o,type:"Polygon"===s||"MultiPolygon"===s?3:"LineString"===s||"MultiLineString"===s?2:1,tags:c};null!==t.id&&(d.id=t.id),e.features.push(d)}}function Ki(e,t,n,r,i,s){var o=r*r;if(r>0&&t.size<(i?o:r))n.numPoints+=t.length/3;else{for(var a=[],l=0;l<t.length;l+=3)(0===r||t[l+2]>o)&&(n.numSimplified++,a.push(t[l]),a.push(t[l+1])),n.numPoints++;i&&function(e,t){for(var n=0,r=0,i=e.length,s=i-2;r<i;s=r,r+=2)n+=(e[r]-e[s])*(e[r+1]+e[s+1]);if(n>0===t)for(r=0,i=e.length;r<i/2;r+=2){var o=e[r],a=e[r+1];e[r]=e[i-2-r],e[r+1]=e[i-1-r],e[i-2-r]=o,e[i-1-r]=a}}(a,s),e.push(a)}}function Xi(e,t){return new Yi(e,t)}function Yi(e,t){var n=(t=this.options=function(e,t){for(var n in t)e[n]=t[n];return e}(Object.create(this.options),t)).debug;if(n&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(e,t){var n=[];if("FeatureCollection"===e.type)for(var r=0;r<e.features.length;r++)Ri(n,e.features[r],t,r);else"Feature"===e.type?Ri(n,e,t):Ri(n,{geometry:e},t);return n}(e,t);this.tiles={},this.tileCoords=[],n&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=function(e,t){var n=t.buffer/t.extent,r=e,i=Di(e,1,-1-n,n,0,-1,2,t),s=Di(e,1,1-n,2+n,0,-1,2,t);return(i||s)&&(r=Di(e,1,-n,1+n,0,-1,2,t)||[],i&&(r=Gi(i,1).concat(r)),s&&(r=r.concat(Gi(s,-1)))),r}(r,t),r.length&&this.splitTile(r,0,0,0),n&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function Qi(e,t,n){return 32*((1<<e)*n+t)+e}we.register("MVT",()=>Ai),Yi.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Yi.prototype.splitTile=function(e,t,n,r,i,s,o){for(var a=[e,t,n,r],l=this.options,u=l.debug;a.length;){r=a.pop(),n=a.pop(),t=a.pop(),e=a.pop();var c=1<<t,h=Qi(t,n,r),d=this.tiles[h];if(!d&&(u>1&&console.time("creation"),d=this.tiles[h]=Wi(e,t,n,r,l),this.tileCoords.push({z:t,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,n,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(d.source=e,i){if(t===l.maxZoom||t===i)continue;var p=1<<i-t;if(n!==Math.floor(s/p)||r!==Math.floor(o/p))continue}else if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue;if(d.source=null,0!==e.length){u>1&&console.time("clipping");var g,m,_,y,v,b,x=.5*l.buffer/l.extent,w=.5-x,A=.5+x,E=1+x;g=m=_=y=null,v=Di(e,c,n-x,n+A,0,d.minX,d.maxX,l),b=Di(e,c,n+w,n+E,0,d.minX,d.maxX,l),e=null,v&&(g=Di(v,c,r-x,r+A,1,d.minY,d.maxY,l),m=Di(v,c,r+w,r+E,1,d.minY,d.maxY,l),v=null),b&&(_=Di(b,c,r-x,r+A,1,d.minY,d.maxY,l),y=Di(b,c,r+w,r+E,1,d.minY,d.maxY,l),b=null),u>1&&console.timeEnd("clipping"),a.push(g||[],t+1,2*n,2*r),a.push(m||[],t+1,2*n,2*r+1),a.push(_||[],t+1,2*n+1,2*r),a.push(y||[],t+1,2*n+1,2*r+1)}}},Yi.prototype.getTile=function(e,t,n){var r=this.options,i=r.extent,s=r.debug;if(e<0||e>24)return null;var o=1<<e,a=Qi(e,t=(t%o+o)%o,n);if(this.tiles[a])return qi(this.tiles[a],i);s>1&&console.log("drilling down to z%d-%d-%d",e,t,n);for(var l,u=e,c=t,h=n;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[Qi(u,c,h)];return l&&l.source?(s>1&&console.log("found parent tile z%d-%d-%d",u,c,h),s>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,e,t,n),s>1&&console.timeEnd("drilling down"),this.tiles[a]?qi(this.tiles[a],i):null):null};class Ji extends Ee{constructor(e,t){super(e,t),this.load_data=null,this.tile_indexes={},this.setTileSize(512),this.pad_scale=0}_load(e){return this.load_data||(this.load_data=super._load({source_data:{layers:{}}}).then(e=>{e.source_data.error&&m("warn",`data source load error(s) for source '${this.name}', URL '${this.url}': ${e.source_data.error}`);let t=e.source_data.layers;for(let e in t)this.tile_indexes[e]=Xi(t[e],{maxZoom:this.max_zoom,tolerance:1.5,extent:G.tile_scale,buffer:1e-4});return this.loaded=!0,e})),this.load_data.then(()=>{for(let t in this.tile_indexes)e.source_data.layers[t]=this.getTileFeatures(e,t);return e})}getTileFeatures(e,t){let n,r=G.wrapTile(e.coords,{x:!0}),i=this.tile_indexes[t].getTile(r.z,r.x,r.y);if(i&&i.features){n={type:"FeatureCollection",features:[]};for(let e=0;e<i.features.length;e++){const t=i.features[e];let r={type:"Feature",geometry:{},id:t.id,properties:t.tags};if(1===t.type)r.geometry.coordinates=t.geometry.map(e=>[e[0],e[1]]),r.geometry.type="MultiPoint";else{if(2!==t.type&&3!==t.type)continue;if(r.geometry.coordinates=t.geometry.map(e=>e.map(e=>[e[0],e[1]])),2===t.type)r.geometry.type="MultiLineString";else if(r.geometry=Ei(r.geometry),null==r.geometry)continue}n.features.push(r)}}return n}formatURL(){return this.url}parseSourceData(e,t,n){let r="string"==typeof n?JSON.parse(n):n,i=this.getLayers(r);t.layers=this.preprocessLayers(i,e)}preprocessLayers(e,t){for(let t in e){let n=e[t];n.features=this.preprocessFeatures(n.features)}if("function"==typeof this.transform){const n={min:Object.assign({},t.min),max:Object.assign({},t.max),coords:Object.assign({},t.coords)};1===Object.keys(e).length&&e._default?e._default=this.transform(e._default,this.extra_data,n):e=this.transform(e,this.extra_data,n)}return e}preprocessFeatures(e){if(e=e.filter(e=>null!=e.geometry),this.config.generate_label_centroids){let t=[],n={label_placement:!0};e.forEach(e=>{let r,i;if("Polygon"===e.geometry.type)r=e.geometry.coordinates,i=ts(r,e.id,e.properties,n),t.push(i);else if("MultiPolygon"===e.geometry.type){r=e.geometry.coordinates;let s=-1/0,o=0;for(let e=0;e<r.length;e++){let t=G.polygonArea(r[e]);t>s&&(s=t,o=e)}i=ts(r[o],e.id,e.properties,n),t.push(i)}}),t=t.filter(e=>e),Array.prototype.push.apply(e,t)}return e}getLayers(e){return"Feature"===e.type?{_default:{type:"FeatureCollection",features:[e]}}:"FeatureCollection"===e.type?{_default:e}:e}}class es extends Se{constructor(e,t){super(e,t)}parseSourceData(e,t,n){let r="string"==typeof n?JSON.parse(n):n;this.prepareGeoJSON(r,e,t)}prepareGeoJSON(e,t,n){if("function"==typeof this.transform){const n={min:Object.assign({},t.min),max:Object.assign({},t.max),coords:Object.assign({},t.coords)};e=this.transform(e,this.extra_data,n)}n.layers=Ji.prototype.getLayers(e);let r={coords:t.coords,min:G.metersForTile(G.wrapTile(t.coords,{x:!0}))};we.projectData(n),we.scaleData(n,r)}}function ts(e,t,n,r){let i=G.centroid(e);if(!i)return;let s={};return Object.assign(s,n,r),{type:"Feature",id:t,properties:s,geometry:{type:"Point",coordinates:i}}}function ns(e){return e}function rs(e,t){var n=t.id,r=t.bbox,i=null==t.properties?{}:t.properties,s=function(e,t){var n=function(e){if(null==(t=e.transform))return ns;var t,n,r,i=t.scale[0],s=t.scale[1],o=t.translate[0],a=t.translate[1];return function(e,t){return t||(n=r=0),e[0]=(n+=e[0])*i+o,e[1]=(r+=e[1])*s+a,e}}(e),r=e.arcs;function i(e,t){t.length&&t.pop();for(var i=r[e<0?~e:e],s=0,o=i.length;s<o;++s)t.push(n(i[s].slice(),s));e<0&&function(e,t){for(var n,r=e.length,i=r-t;i<--r;)n=e[i],e[i++]=e[r],e[r]=n}(t,o)}function s(e){return n(e.slice())}function o(e){for(var t=[],n=0,r=e.length;n<r;++n)i(e[n],t);return t.length<2&&t.push(t[0].slice()),t}function a(e){for(var t=o(e);t.length<4;)t.push(t[0].slice());return t}function l(e){return e.map(a)}return function e(t){var n,r=t.type;switch(r){case"GeometryCollection":return{type:r,geometries:t.geometries.map(e)};case"Point":n=s(t.coordinates);break;case"MultiPoint":n=t.coordinates.map(s);break;case"LineString":n=o(t.arcs);break;case"MultiLineString":n=t.arcs.map(o);break;case"Polygon":n=l(t.arcs);break;case"MultiPolygon":n=t.arcs.map(l);break;default:return null}return{type:r,coordinates:n}}(t)}(e,t);return null==n&&null==r?{type:"Feature",properties:i,geometry:s}:null==r?{type:"Feature",id:n,properties:i,geometry:s}:{type:"Feature",id:n,bbox:r,properties:i,geometry:s}}we.register("GeoJSON",e=>es.urlHasTilePattern(e.url)?es:Ji);class is extends Ji{parseSourceData(e,t,n){let r="string"==typeof n?JSON.parse(n):n;r=this.toGeoJSON(r);let i=this.getLayers(r);super.preprocessLayers(i,e),t.layers=i}toGeoJSON(e){if(e.objects&&1===Object.keys(e.objects).length){let t=Object.keys(e.objects)[0];e=ss(e,e.objects[t])}else{let t={};for(let n in e.objects)t[n]=ss(e,e.objects[n]);e=t}return e}}function ss(e,t){let n=function(e,t){return"GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map(function(t){return rs(e,t)})}:rs(e,t)}(e,t);return"Feature"===n.type&&(n={type:"FeatureCollection",features:[n]}),n}class os extends es{constructor(e,t){super(e,t)}parseSourceData(e,t,n){let r="string"==typeof n?JSON.parse(n):n;r=is.prototype.toGeoJSON(r),this.prepareGeoJSON(r,e,t)}}we.register("TopoJSON",e=>os.urlHasTilePattern(e.url)?os:is),e.Collision=$t,e.DataSource=we,e.FeatureSelection=he,e.FilterOptions=Wr,e.FontManager=rn,e.GLSL=O,e.Geo=G,e.Label=Vt,e.LabelLineStraight=gr,e.LabelPoint=qt,e.Light=ve,e.Material=me,e.OBB=jt,e.ShaderProgram=j,e.Style=Pe,e.StyleManager=class{constructor(){this.styles={},this.base_styles={},this.active_styles=[],this.active_blend_orders=[],this.register(Object.create(et)),this.register(Object.create(bt)),this.register(Object.create(cr)),this.register(Object.create(xr)),this.register(Object.create(wr))}init(){j.removeBlock("global"),j.removeBlock("setup"),j.addBlock("global","#ifdef TANGRAM_VERTEX_SHADER\n\n// Apply layer ordering to avoid z-fighting\nvoid applyLayerOrder (float layer, inout vec4 position) {\n position.z -= layer * TANGRAM_LAYER_DELTA * position.w;\n}\n\n// Vertex position in model space: [0, 1] range over the local tile\n// Note positions can be outside that range due to unclipped geometry, geometry higher than a unit cube, etc.\nvec4 modelPosition() {\n return\n vec4(\n a_position.xyz / TANGRAM_TILE_SCALE // scale coords to ~0-1 range\n * exp2(u_tile_origin.z - u_tile_origin.w), // adjust for tile overzooming\n 1.)\n + vec4(0., 1., 0., 0.);\n // NB: additional offset to account for unusual Tangram JS y coords,\n // should be refactored to remove\n}\n\n// Position in model space as above, but according to tile coordinate (as opposed to style) zoom\n// e.g. unadjusted for tile overzooming\nvec4 modelPositionBaseZoom() {\n return\n vec4(\n a_position.xyz / TANGRAM_TILE_SCALE, // scale coords to ~0-1 range\n 1.)\n + vec4(0., 1., 0., 0.); // see note on offset above\n}\n\n#endif\n\n// Vertex position in world coordinates, useful for 3d procedural textures, etc.\nvec4 worldPosition() {\n return v_world_position;\n}\n\n// Optionally wrap world coordinates (allows more precision at higher zooms)\n// e.g. at wrap 1000, the world space will wrap every 1000 meters\n#ifdef TANGRAM_VERTEX_SHADER\n\nvec4 wrapWorldPosition(vec4 world_position) {\n #if defined(TANGRAM_WORLD_POSITION_WRAP)\n vec2 anchor = u_tile_origin.xy - mod(u_tile_origin.xy, TANGRAM_WORLD_POSITION_WRAP);\n world_position.xy -= anchor;\n #endif\n return world_position;\n}\n\n#endif\n\n// Normal in world space\n#if defined(TANGRAM_VERTEX_SHADER)\n\nvec3 worldNormal() {\n return TANGRAM_NORMAL;\n}\n\n#elif defined(TANGRAM_FRAGMENT_SHADER)\n\nvec3 worldNormal() {\n return u_inverseNormalMatrix * TANGRAM_NORMAL;\n}\n\n#endif\n"),j.addBlock("global","// Vertex attribute + varying for feature selection\n#if defined(TANGRAM_FEATURE_SELECTION) && defined(TANGRAM_VERTEX_SHADER)\n attribute vec4 a_selection_color;\n varying vec4 v_selection_color;\n#endif\n"),j.replaceBlock("setup","// Selection pass-specific rendering\n#if defined(TANGRAM_FEATURE_SELECTION) && defined(TANGRAM_VERTEX_SHADER)\n if (a_selection_color.rgb == vec3(0.)) {\n // Discard by forcing invalid triangle if we're in the feature\n // selection pass but have no selection info\n // TODO: in some cases we may actually want non-selectable features to occlude selectable ones?\n gl_Position = vec4(0., 0., 0., 1.);\n return;\n }\n v_selection_color = a_selection_color;\n#endif\n"),j.defines.TANGRAM_EPSILON=1e-5,j.defines.TANGRAM_LAYER_DELTA=1/16384,j.defines.TANGRAM_TILE_SCALE=`vec3(${G.tile_scale}., ${G.tile_scale}., u_meters_per_pixel * ${G.tile_size}.)`,j.defines.TANGRAM_HEIGHT_SCALE=G.height_scale,j.defines.TANGRAM_ALPHA_TEST=.5}destroy(e){Object.keys(this.styles).forEach(t=>{let n=this.styles[t];n.gl===e&&(m("trace",`StyleManager.destroy: destroying render style ${n.name}`),n.base&&this.remove(n.name),n.destroy())})}register(e){this.styles[e.name]=e,this.base_styles[e.name]=e}remove(e){delete this.styles[e]}getActiveStyles(){return this.active_styles}updateActiveStyles(e){return this.active_styles=Object.keys(e.reduce((e,t)=>(Object.keys(t.meshes).forEach(t=>e[t]=!0),e),{})),this.active_styles}getActiveBlendOrders(){return this.active_blend_orders}updateActiveBlendOrders(e){const t=[];e.forEach(e=>{Object.entries(e.meshes).forEach(([e,n])=>{n.forEach(n=>{const r=n.variant.blend_order;let i=t.findIndex(e=>e.blend_order===r);i=i>-1?i:t.push({blend_order:r,styles:[]})-1,-1===t[i].styles.indexOf(e)&&t[i].styles.push(e)})})}),this.active_blend_orders=t.sort((e,t)=>e.blend_order-t.blend_order)}mix(e,t){if(e.mixed)return e;e.mixed={};let n=[];e.mix&&(Array.isArray(e.mix)?n.push(...e.mix):n.push(e.mix),n=n.map(e=>t[e]).filter(t=>t&&t!==e),n.forEach(t=>e.mixed[t.name]=!0)),n.push(e),e.animated=n.some(e=>e&&e.animated),e.texcoords=n.some(e=>e&&e.texcoords),e.base=n.map(e=>e.base).filter(e=>e).pop(),e.lighting=n.map(e=>e.lighting).filter(e=>null!=e).pop(),e.texture=n.map(e=>e.texture).filter(e=>e).pop(),e.raster=n.map(e=>e.raster).filter(e=>null!=e).pop(),e.dash=n.map(e=>e.dash).filter(e=>null!=e).pop(),e.dash_background_color=n.map(e=>e.dash_background_color).filter(e=>null!=e).pop(),n.some(e=>Object.prototype.hasOwnProperty.call(e,"blend")&&e.blend)&&(e.blend=n.map(e=>Object.prototype.hasOwnProperty.call(e,"blend")&&e.blend).filter(e=>e).pop()),e.blend_order=n.map(e=>e.blend_order).filter(e=>null!=e).pop(),e.defines=Object.assign({},...n.map(e=>e.defines).filter(e=>e)),e.material=Object.assign({},...n.map(e=>e.material).filter(e=>e));let r=n.map(e=>e.draw).filter(e=>e);return r.length>0&&(e.draw=B({},...r)),this.mixShaders(e,t,n),e}mixShaders(e,t,n){let r={},i=n.map(e=>e.shaders).filter(e=>e);if(r.defines=Object.assign({},...i.map(e=>e.defines).filter(e=>e)),r.attributes=Object.assign({},...i.map(e=>e.attributes).filter(e=>e)),r.uniforms={},r._uniforms=e.shaders&&e.shaders.uniforms||{},r._uniform_scopes={},n.filter(e=>e.shaders&&e.shaders.uniforms).forEach(e=>{for(let n in e.shaders.uniforms)r._uniform_scopes[n]=e.name,Object.defineProperty(r.uniforms,n,{enumerable:!0,configurable:!0,get:function(){return void 0!==r._uniforms[n]?r._uniforms[n]:t[r._uniform_scopes[n]].shaders.uniforms!==r.uniforms?t[r._uniform_scopes[n]].shaders.uniforms[n]:void 0},set:function(e){r._uniforms[n]=e}})}),r.extensions=Object.keys(i.map(e=>e.extensions).filter(e=>e).reduce((e,t)=>("string"==typeof t?e[t]=!0:t.forEach(t=>e[t]=!0),e),{})||{}),e.shaders&&e.shaders.blocks){e.shaders.block_scopes=e.shaders.block_scopes||{};for(let t in e.shaders.blocks){let n=e.shaders.blocks[t];e.shaders.block_scopes[t]=e.shaders.block_scopes[t]||[],Array.isArray(n)?e.shaders.block_scopes[t].push(...n.map(()=>e.name)):e.shaders.block_scopes[t].push(e.name)}}let s={};return i.forEach(e=>{if(!e.blocks)return;r.blocks=r.blocks||{},r.block_scopes=r.block_scopes||{};let t={};for(let n in e.blocks){let i=e.blocks[n],o=e.block_scopes[n];r.blocks[n]=r.blocks[n]||[],r.block_scopes[n]=r.block_scopes[n]||[],i=Array.isArray(i)?i:[i],o=Array.isArray(o)?o:[o];for(let e=0;e<i.length;e++)s[o[e]]||(t[o[e]]=!0,r.blocks[n].push(i[e]),r.block_scopes[n].push(o[e]))}Object.assign(s,t)}),Object.assign(e.mixed,s),e.shaders=r,e}create(e,t,n={}){let r=B({},t);return r.name=e,r=this.mix(r,n),r.base&&this.base_styles[r.base]?this.styles[e]=r=Object.assign(Object.create(this.base_styles[r.base]),r):r.base=null,r}build(e){const t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ar(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ar(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},e);this.styles&&Object.values(this.styles).forEach(e=>a.removeTarget(e.main_thread_target));const n=["opaque","add","multiply","overlay","inlay","translucent"],r=["polygons","lines","points","text","raster"];for(const e of n)for(const n of r){const r=e+"_"+n;null==t[r]&&(t[r]={base:n,blend:e})}let s=Object.keys(t).sort((e,n)=>this.inheritanceDepth(e,t)-this.inheritanceDepth(n,t));for(let e in this.styles)this.base_styles[e]?this.styles[e].reset():delete this.styles[e];let o={};return s.forEach(e=>{o[e]=this.create(e,t[e],o)}),this.styles}initStyles(e={}){for(let t in this.styles)this.styles[t].init(e)}inheritanceDepth(e,t){let n=0;for(;;){let r=t[e];if(!r)break;if(!r.mix)break;if(n++,Array.isArray(r.mix)){n+=Math.max(...r.mix.map(n=>{if(e!==n)return this.inheritanceDepth(n,t)}));break}if(e===r.mix)break;e=r.mix}return n}},e.StyleParser=J,e.Task=E,e.TextCanvas=An,e.Texture=k,e.Thread=t,e.Tile=ti,e.TileID=Te,e.Utils=_,e.Vector=ye,e.VertexArrayObject=U,e.VertexData=ze,e.VertexElements=De,e.View=class{constructor(e,t){S(this),this.scene=e,this.createMatrices(),this.zoom=null,this.center=null,this.bounds=null,this.meters_per_pixel=null,this.panning=!1,this.panning_stop_at=0,this.pan_snap_timer=0,this.zoom_direction=0,this.user_input_at=0,this.user_input_timeout=50,this.user_input_active=!1,this.size={css:{},device:{},meters:{}},this.aspect=null,this.buffer=0,this.continuous_zoom="boolean"!=typeof t.continuousZoom||t.continuousZoom,this.wrap=!1!==t.wrapView,this.preserve_tiles_within_zoom=1,this.reset()}reset(){this.createCamera()}createCamera(){let e=this.getActiveCamera();e&&(this.camera=sr.create(e,this,this.scene.config.cameras[e]),this.camera.updateView())}getActiveCamera(){if(this.scene.config&&this.scene.config.cameras){for(let e in this.scene.config.cameras)if(this.scene.config.cameras[e].active)return e;let e=Object.keys(this.scene.config.cameras);return e.length&&e[0]}}setActiveCamera(e){let t=this.getActiveCamera();return t===e?e:(this.scene.config.cameras[e]&&(this.scene.config.cameras[e].active=!0,t&&this.scene.config.cameras[t]&&delete this.scene.config.cameras[t].active),this.scene.updateConfig({rebuild:!1,normalize:!1}),this.getActiveCamera())}update(){null!=this.camera&&this.ready()&&this.camera.update(),this.pan_snap_timer=(+new Date-this.panning_stop_at)/1e3,this.user_input_active=+new Date-this.user_input_at<this.user_input_timeout}setViewportSize(e,t){this.size.css={width:e,height:t},this.size.device={width:Math.round(this.size.css.width*_.device_pixel_ratio),height:Math.round(this.size.css.height*_.device_pixel_ratio)},this.aspect=this.size.css.width/this.size.css.height,this.updateBounds()}setView({lng:e,lat:t,zoom:n}={}){var r=!1;return"number"==typeof e&&"number"==typeof t&&(this.center&&e===this.center.lng&&t===this.center.lat||(r=!0,this.center={lng:e,lat:t})),"number"==typeof n&&n!==this.zoom&&(r=!0,this.setZoom(n)),r&&this.updateBounds(),r}setZoom(e){let t=this.tile_zoom,n=this.baseZoom(e);this.continuous_zoom||(e=n),n!==t&&(this.zoom_direction=n>t?1:-1),this.zoom=e,this.tile_zoom=n,this.updateBounds(),this.scene.requestRedraw()}baseZoom(e){return Math.floor(e)}setPanning(e){this.panning=e,this.panning||(this.panning_stop_at=+new Date)}markUserInput(){this.user_input_at=+new Date}ready(){return"number"==typeof this.size.css.width&&"number"==typeof this.size.css.height&&null!=this.center&&"number"==typeof this.zoom}updateBounds(){if(!this.ready())return;this.meters_per_pixel=G.metersPerPixel(this.zoom),this.size.meters={x:this.size.css.width*this.meters_per_pixel,y:this.size.css.height*this.meters_per_pixel};const e=G.latLngToMeters([this.center.lng,this.center.lat]);this.center.meters={x:e[0],y:e[1]},this.center.tile=G.tileForMeters([this.center.meters.x,this.center.meters.y],this.tile_zoom),this.bounds={sw:{x:this.center.meters.x-this.size.meters.x/2,y:this.center.meters.y-this.size.meters.y/2},ne:{x:this.center.meters.x+this.size.meters.x/2,y:this.center.meters.y+this.size.meters.y/2}},this.scene.tile_manager.updateTilesForView(),this.trigger("move"),this.scene.requestRedraw()}findVisibleTileCoordinates(){if(!this.bounds)return[];let e=this.tile_zoom,t=G.tileForMeters([this.bounds.sw.x,this.bounds.sw.y],e),n=G.tileForMeters([this.bounds.ne.x,this.bounds.ne.y],e),r=[t.x-this.buffer,n.x+this.buffer,n.y-this.buffer,t.y+this.buffer];if(!1===this.wrap){let t=(1<<e)-1;r=r.map(e=>Math.min(Math.max(0,e),t))}let i=[];for(let t=r[0];t<=r[1];t++)for(let n=r[2];n<=r[3];n++)i.push(Te.coord({x:t,y:n,z:e}));return i}pruneTilesForView(){this.ready()&&this.scene.tile_manager.removeTiles(e=>{if(e.visible||e.isProxy())return!1;if(e.loading&&e.style_z!==this.tile_zoom)return!0;if(Math.abs(e.style_z-this.tile_zoom)>(null!=e.preserve_tiles_within_zoom?e.preserve_tiles_within_zoom:this.preserve_tiles_within_zoom))return!0;const t=this.meters_per_pixel*G.tile_size,n=Te.coordAtZoom(G.tileForMeters([this.center.meters.x-this.size.meters.x/2-t,this.center.meters.y+this.size.meters.y/2+t],this.tile_zoom),e.coords.z),r=Te.coordAtZoom(G.tileForMeters([this.center.meters.x+this.size.meters.x/2+t,this.center.meters.y-this.size.meters.y/2-t],this.tile_zoom),e.coords.z);return(e.coords.x<n.x||e.coords.x>r.x||e.coords.y<n.y||e.coords.y>r.y)&&(m("trace",`View: remove tile ${e.key} (as ${e.coords.key}) for being too far out of visible area (${n.key}, ${r.key})`),!0)})}createMatrices(){this.matrices={},this.matrices.model=new Float64Array(16),this.matrices.model32=new Float32Array(16),this.matrices.model_view=new Float64Array(16),this.matrices.model_view32=new Float32Array(16),this.matrices.normal=new Float64Array(9),this.matrices.normal32=new Float32Array(9),this.matrices.inverse_normal32=new Float32Array(9)}setupTile(e,t){e.setupProgram(this.matrices,t),this.camera.setupMatrices(this.matrices,t)}setupProgram(e){e.uniform("2fv","u_resolution",[this.size.device.width,this.size.device.height]),e.uniform("3fv","u_map_position",[this.center.meters.x,this.center.meters.y,this.zoom]),e.uniform("1f","u_meters_per_pixel",this.meters_per_pixel),e.uniform("1f","u_device_pixel_ratio",_.device_pixel_ratio),e.uniform("1f","u_view_pan_snap_timer",this.pan_snap_timer),e.uniform("1i","u_view_panning",this.panning),this.camera.setupProgram(e)}isAnimating(){return this.pan_snap_timer<=.5}},e.WorkerBroker=a,e._defineProperty=i,e.addBaseURL=function(e,t){if(!e||!x(e))return e;var n,r="/"!==e[0];if(t?(n=document.createElement("a")).href=t:n=window.location,r)e=b(n.href)+e;else{let t=n.origin;t||(t=n.protocol+"//"+n.host),e=t+e}return e},e.buildFilter=jr,e.cache=W,e.clearFunctionStringCache=function(){W.functions={},W.num_functions=0,W.num_cached=0},e.compileFunctionStrings=Z,e.createObjectURL=function(e){return void 0===w&&(w=window.URL&&window.URL.createObjectURL||window.webkitURL&&window.webkitURL.createObjectURL,"function"!=typeof w&&(w=null,m("warn","window.URL.createObjectURL (or vendor prefix) not found, unable to create local blob URLs"))),w?w(e):e},e.debugSettings=v,e.debugSumLayerStats=function(e){let t={},n={};return e.filter(e=>e.debug.layers).forEach(e=>{Object.keys(e.debug.layers.list).forEach(n=>{let r=e.debug.layers.list[n];Me(t,n,r.features,r.geoms,r.styles,r.base)}),ni(e.debug.layers.tree,n)}),{list:t,tree:n}},e.extensionForURL=function(e){let t=(e=e.split("/").pop()).lastIndexOf(".");if(t>-1)return e.substring(t+1)},e.flattenRelativeURL=function(e){let t=(e||"").split("/");for(let e=1;e<t.length;e++)"."===t[e]?(t.splice(e,1),e--):".."===t[e]&&(e+=0,t.splice(e-1,2),e--);return t.join("/")},e.getAugmentedNamespace=function(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n},e.getDefaultExportFromCjs=M,e.isLocalURL=function(e){if("string"==typeof e)return e.search(/^(data|blob):/)>-1},e.isRelativeURL=x,e.isReserved=Zr,e.layerCache=function(){return Ur},e.log=m,e.mergeDebugSettings=function(e){Object.assign(y,e)},e.mergeObjects=B,e.parseLayers=function(e,t){Ur={};let n={};for(let r in e){let i=e[r];i&&(n[r]=Kr(r,i,null,t))}return n},e.pathForURL=b,e.sliceObject=T,e.subscribeMixin=S,e.version=o}),gx(0,function(e){const t=Object.assign(self,{FeatureSelection:e.FeatureSelection,sources:{},styles:{},layers:{},tiles:{},init(t,n,r,i,s,o,a){return this.scene_id=t,this._worker_id=n,this.num_workers=r,e.log.setLevel(i),e.Utils.device_pixel_ratio=s,e.VertexElements.setElementIndexUint(o),e.FeatureSelection.setPrefix(this._worker_id),this.style_manager=new e.StyleManager,this.importExternalScripts(a),e.Label.id_prefix=n,e.Label.id_multiplier=r,n},importExternalScripts(t){if(0===t.length)return;e.log("debug","loading custom data source scripts in worker:",t);let n=Object.getOwnPropertyNames(window);importScripts(...t),Object.getOwnPropertyNames(window).forEach(e=>{-1===n.indexOf(e)&&(this[e]=window[e])})},updateConfig({config:t,generation:n,introspection:r},i){return t=JSON.parse(t),e.mergeDebugSettings(i),this.generation=n,this.introspection=r,this.global=e.compileFunctionStrings(t.global),this.createDataSources(t),t.styles=e.compileFunctionStrings(t.styles,e.StyleParser.wrapFunction),this.styles=this.style_manager.build(t.styles),this.style_manager.initStyles({generation:this.generation,styles:this.styles,sources:this.sources,introspection:this.introspection}),this.layers=e.parseLayers(t.layers,this.style_manager.styles),this.syncing_textures=this.syncTextures(t.textures),this.configuring=this.syncing_textures.then(()=>{e.log("debug","updated config")}),this.configuring},createDataSources(t){this.last_config_sources=this.config_sources||{},this.config_sources=e.mergeObjects({},t.sources);let n=this.sources,r=[];this.sources={};for(let i in t.sources){if(JSON.stringify(this.last_config_sources[i])===JSON.stringify(t.sources[i])){this.sources[i]=n[i];continue}let s;t.sources[i]=e.compileFunctionStrings(t.sources[i]);try{s=e.DataSource.create(Object.assign({},t.sources[i],{name:i}),this.sources)}catch(e){continue}s&&(this.sources[i]=s,r.push(i))}r.forEach(e=>{for(let t in this.tiles)this.tiles[t].source===e&&delete this.tiles[t]})},awaitConfiguration(){return this.configuring},buildTile({tile:t}){if(null==this.getTile(t.key)||!0!==this.getTile(t.key).loading)return t=this.tiles[t.key]=Object.assign(this.getTile(t.key)||{},t),this.awaitConfiguration().then(()=>{if(!0!==t.loaded)t.loading=!0,t.loaded=!1,t.error=null,this.loadTileSourceData(t).then(()=>{this.getTile(t.key)?(t.source_data.error&&e.log("warn",`tile load error(s) for ${t.key}: ${t.source_data.error}`),t.loading=!1,t.loaded=!0,e.Tile.buildGeometry(t,this)):e.log("trace",`stop tile build after data source load because tile was removed: ${t.key}`)}).catch(n=>{t.loading=!1,t.loaded=!1,t.error=n.stack,e.log("error",`tile load error for ${t.key}: ${t.error}`),e.WorkerBroker.postMessage(`TileManager_${this.scene_id}.buildTileError`,e.Tile.slice(t))});else{e.log("trace",`used worker cache for tile ${t.key}`);try{e.Tile.buildGeometry(t,this)}catch(n){t.error=n.toString(),e.WorkerBroker.postMessage(`TileManager_${this.scene_id}.buildTileError`,e.Tile.slice(t))}}})},loadTileSourceData(e){const t=this.sources[e.source];if(t){for(const n in this.tiles){const r=this.tiles[n];if(r.source===e.source&&r.coords.key===e.coords.key&&r.loaded)return Promise.resolve(t.copyTileData(r,e))}return t.load(e)}return e.source_data={},Promise.resolve(e)},getTile(e){return this.tiles[e]},removeTile(t){var n=this.tiles[t];null!=n&&(!0===n.loading&&(e.log("trace",`cancel tile load for ${t}`),n.loading=!1,e.Tile.cancel(n)),e.FeatureSelection.clearTile(t),delete this.tiles[t],e.log("trace",`remove tile from cache for ${t}`))},queryFeatures({filter:t,visible:n,geometry:r,tile_keys:i}){let s=[],o=i.map(e=>this.tiles[e]).filter(e=>e&&e.loaded);return null!=t&&(t=["{","["].indexOf(t[0])>-1?JSON.parse(t):t,t=e.compileFunctionStrings(t,e.StyleParser.wrapFunction)),t=e.buildFilter(t,e.FilterOptions),o.forEach(i=>{for(let o in i.source_data.layers){let a=i.source_data.layers[o];if(null==a)return;a.features.forEach(a=>{const l=a.generation===this.generation;if(!0===n&&!l||!1===n&&l)return;let u=e.StyleParser.getFeatureParseContext(a,i,this.global);if(u.source=i.source,u.layer=o,u.id=a.id,!t(u))return;let c={type:a.type,id:a.id,properties:Object.assign({},a.properties,{$source:u.source,$layer:u.layer,$geometry:u.geometry,$visible:l})};!0===r&&(c.geometry=e.Geo.copyGeometry(a.geometry),e.Geo.tileSpaceToLatlng(c.geometry,i.coords.z,i.min)),s.push(c)})}}),s},getFeatureSelection({id:t,key:n}={}){var r=e.FeatureSelection.map[n];return{id:t,feature:r&&r.feature}},resetFeatureSelection(t=null){e.FeatureSelection.reset(t)},getFeatureSelectionMapSize:()=>e.FeatureSelection.getMapSize(),syncTextures(t){let n=[];return t&&n.push(...Object.keys(t)),e.log("trace","sync textures to worker:",n),n.length>0?e.Texture.syncTexturesToWorker(n):Promise.resolve()},updateDevicePixelRatio(t){e.Utils.device_pixel_ratio=t},clearFunctionStringCache(){e.clearFunctionStringCache()},profile(e){console.profile(`worker ${this._worker_id}: ${e}`)},profileEnd(e){console.profileEnd(`worker ${this._worker_id}: ${e}`)},debug:{debugSettings:e.debugSettings,layerCache:e.layerCache,functionStringCache:e.cache}});e.WorkerBroker.addTarget("self",t)}),gx(0,function(e){var t,n=t={};let r=0;function i(e,t){var n;const r=t[t.length-1];return null===(n=o(e,t))||void 0===n?void 0:n[r]}function s(e,t,n){const r=t[t.length-1],i=o(e,t);i&&(i[r]=n)}function o(e,t){if(0===t.length)return;let n=e;for(let e=0;e<t.length-1;e++)if(n=n[t[e]],null==n)return;return n}t.getContext=function(e,n){var i=!1;null==e&&((e=document.createElement("canvas")).style.position="absolute",e.style.top=0,e.style.left=0,e.style.zIndex=-1,document.body.appendChild(e),i=!0),e.addEventListener("webglcontextlost",()=>{}),e.addEventListener("webglcontextrestored",()=>{});var s=e.getContext("webgl",n)||e.getContext("experimental-webgl",n);if(!s)throw new Error("Couldn't create WebGL context.");return s._tangram_id=r++,i?(t.resize(s,window.innerWidth,window.innerHeight,n.device_pixel_ratio),window.addEventListener("resize",function(){t.resize(s,window.innerWidth,window.innerHeight,n.device_pixel_ratio)})):t.resize(s,parseFloat(e.style.width),parseFloat(e.style.height),n.device_pixel_ratio),s},t.resize=function(e,t,n,r){r=r||window.devicePixelRatio||1,e.canvas.style.width=t+"px",e.canvas.style.height=n+"px",e.canvas.width=Math.round(t*r),e.canvas.height=Math.round(n*r),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,e.canvas.width,e.canvas.height)};const a="global.",l="__global_prop";function u(e){return(null==e?void 0:e.slice(0,7))===a}function c(e,t){var n;const r=Array.isArray(t)?t:[t],i=o(e,r),s=r[r.length-1];return void 0!==(null==i||null===(n=i[l])||void 0===n?void 0:n[s])}function h(e,t=null,n={}){t=t?t+".":a;for(const r in e){const i=t+r,s=e[r];n[i]=s,"object"!=typeof s||Array.isArray(s)||h(s,i,n)}return n}function d(t,n,r,i){var s;let o;if(null!=r&&null!==(s=r[l])&&void 0!==s&&s[i]?o=r[l][i]:"string"==typeof n&&n.slice(0,7)===a&&(o=n),o){null==r[l]&&Object.defineProperty(r,l,{value:{}}),r[l][i]=o;let n,s=t[o];for(;"string"==typeof s&&s.slice(0,7)===a;){if(n=n||[o],n.indexOf(s)>-1){e.log({level:"warn",once:!0},"Global properties: cyclical reference detected",n),s=null;break}n.push(s),s=t[s]}Object.defineProperty(r,i,{enumerable:!0,get:function(){return s},set:function(e){delete r[l][i],delete r[i],r[i]=e}})}else if(Array.isArray(n))for(let e=0;e<n.length;e++)d(t,n[e],n,e);else if("object"==typeof n)for(const e in n)d(t,n[e],n,e);return n}var f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},p=[],g=[],m="undefined"!=typeof Uint8Array?Uint8Array:Array,_=!1;function y(){_=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)p[t]=e[t],g[e.charCodeAt(t)]=t;g["-".charCodeAt(0)]=62,g["_".charCodeAt(0)]=63}function v(e,t,n){for(var r,i,s=[],o=t;o<n;o+=3)r=(e[o]<<16)+(e[o+1]<<8)+e[o+2],s.push(p[(i=r)>>18&63]+p[i>>12&63]+p[i>>6&63]+p[63&i]);return s.join("")}function b(e){var t;_||y();for(var n=e.length,r=n%3,i="",s=[],o=16383,a=0,l=n-r;a<l;a+=o)s.push(v(e,a,a+o>l?l:a+o));return 1===r?(t=e[n-1],i+=p[t>>2],i+=p[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=p[t>>10],i+=p[t>>4&63],i+=p[t<<2&63],i+="="),s.push(i),s.join("")}function x(e,t,n,r,i){var s,o,a=8*i-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+e[t+h],h+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=256*o+e[t+h],h+=d,c-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),s-=u}return(f?-1:1)*o*Math.pow(2,s-r)}function w(e,t,n,r,i,s){var o,a,l,u=8*s-i-1,c=(1<<u)-1,h=c>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:s-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(t*l-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[n+f]=255&o,f+=p,o/=256,u-=8);e[n+f-p]|=128*g}var A={}.toString,E=Array.isArray||function(e){return"[object Array]"==A.call(e)};O.TYPED_ARRAY_SUPPORT=void 0===f.TYPED_ARRAY_SUPPORT||f.TYPED_ARRAY_SUPPORT;var S=T();function T(){return O.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function k(e,t){if(T()<t)throw new RangeError("Invalid typed array length");return O.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=O.prototype:(null===e&&(e=new O(t)),e.length=t),e}function O(e,t,n){if(!(O.TYPED_ARRAY_SUPPORT||this instanceof O))return new O(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return P(this,e)}return R(this,e,t,n)}function R(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),O.TYPED_ARRAY_SUPPORT?(e=t).__proto__=O.prototype:e=M(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!O.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|D(t,n),i=(e=k(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(I(t)){var n=0|N(t.length);return 0===(e=k(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?k(e,0):M(e,t);if("Buffer"===t.type&&E(t.data))return M(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function C(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function P(e,t){if(C(t),e=k(e,t<0?0:0|N(t)),!O.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function M(e,t){var n=t.length<0?0:0|N(t.length);e=k(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function N(e){if(e>=T())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+T().toString(16)+" bytes");return 0|e}function I(e){return!(null==e||!e._isBuffer)}function D(e,t){if(I(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return le(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return ue(e).length;default:if(r)return le(e).length;t=(""+t).toLowerCase(),r=!0}}function F(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Y(this,t,n);case"utf8":case"utf-8":return W(this,t,n);case"ascii":return K(this,t,n);case"latin1":case"binary":return X(this,t,n);case"base64":return H(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function z(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function L(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=O.from(t,r)),I(t))return 0===t.length?-1:j(e,t,n,r,i);if("number"==typeof t)return t&=255,O.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):j(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function j(e,t,n,r,i){var s,o=1,a=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var c=-1;for(s=n;s<a;s++)if(u(e,s)===u(t,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===l)return c*o}else-1!==c&&(s-=s-c),c=-1}else for(n+l>a&&(n=a-l),s=n;s>=0;s--){for(var h=!0,d=0;d<l;d++)if(u(e,s+d)!==u(t,d)){h=!1;break}if(h)return s}return-1}function V(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[n+o]=a}return o}function U(e,t,n,r){return ce(le(t,e.length-n),e,n,r)}function B(e,t,n,r){return ce(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function G(e,t,n,r){return B(e,t,n,r)}function $(e,t,n,r){return ce(ue(t),e,n,r)}function q(e,t,n,r){return ce(function(e,t){for(var n,r,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(n=e.charCodeAt(o))>>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function H(e,t,n){return 0===t&&n===e.length?b(e):b(e.slice(t,n))}function W(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,l,u=e[i],c=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(c=u);break;case 2:128==(192&(s=e[i+1]))&&(l=(31&u)<<6|63&s)>127&&(c=l);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(l=(15&u)<<12|(63&s)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=h}return function(e){var t=e.length;if(t<=Z)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Z));return n}(r)}O.poolSize=8192,O._augment=function(e){return e.__proto__=O.prototype,e},O.from=function(e,t,n){return R(null,e,t,n)},O.TYPED_ARRAY_SUPPORT&&(O.prototype.__proto__=Uint8Array.prototype,O.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&O[Symbol.species]),O.alloc=function(e,t,n){return function(e,t,n,r){return C(t),t<=0?k(e,t):void 0!==n?"string"==typeof r?k(e,t).fill(n,r):k(e,t).fill(n):k(e,t)}(null,e,t,n)},O.allocUnsafe=function(e){return P(null,e)},O.allocUnsafeSlow=function(e){return P(null,e)},O.isBuffer=he,O.compare=function(e,t){if(!I(e)||!I(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},O.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},O.concat=function(e,t){if(!E(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return O.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=O.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!I(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},O.byteLength=D,O.prototype._isBuffer=!0,O.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)z(this,t,t+1);return this},O.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)z(this,t,t+3),z(this,t+1,t+2);return this},O.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)z(this,t,t+7),z(this,t+1,t+6),z(this,t+2,t+5),z(this,t+3,t+4);return this},O.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?W(this,0,e):F.apply(this,arguments)},O.prototype.equals=function(e){if(!I(e))throw new TypeError("Argument must be a Buffer");return this===e||0===O.compare(this,e)},O.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},O.prototype.compare=function(e,t,n,r,i){if(!I(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(s,o),l=this.slice(r,i),u=e.slice(t,n),c=0;c<a;++c)if(l[c]!==u[c]){s=l[c],o=u[c];break}return s<o?-1:o<s?1:0},O.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},O.prototype.indexOf=function(e,t,n){return L(this,e,t,n,!0)},O.prototype.lastIndexOf=function(e,t,n){return L(this,e,t,n,!1)},O.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return V(this,e,t,n);case"utf8":case"utf-8":return U(this,e,t,n);case"ascii":return B(this,e,t,n);case"latin1":case"binary":return G(this,e,t,n);case"base64":return $(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},O.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;function K(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function X(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function Y(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=t;s<n;++s)i+=ae(e[s]);return i}function Q(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function J(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function ee(e,t,n,r,i,s){if(!I(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function te(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function ne(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function re(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ie(e,t,n,r,i){return i||re(e,0,n,4),w(e,t,n,r,23,4),n+4}function se(e,t,n,r,i){return i||re(e,0,n,8),w(e,t,n,r,52,8),n+8}O.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),O.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=O.prototype;else{var i=t-e;n=new O(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+e]}return n},O.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||J(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},O.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||J(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},O.prototype.readUInt8=function(e,t){return t||J(e,1,this.length),this[e]},O.prototype.readUInt16LE=function(e,t){return t||J(e,2,this.length),this[e]|this[e+1]<<8},O.prototype.readUInt16BE=function(e,t){return t||J(e,2,this.length),this[e]<<8|this[e+1]},O.prototype.readUInt32LE=function(e,t){return t||J(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},O.prototype.readUInt32BE=function(e,t){return t||J(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},O.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||J(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},O.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||J(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},O.prototype.readInt8=function(e,t){return t||J(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},O.prototype.readInt16LE=function(e,t){t||J(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},O.prototype.readInt16BE=function(e,t){t||J(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},O.prototype.readInt32LE=function(e,t){return t||J(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},O.prototype.readInt32BE=function(e,t){return t||J(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},O.prototype.readFloatLE=function(e,t){return t||J(e,4,this.length),x(this,e,!0,23,4)},O.prototype.readFloatBE=function(e,t){return t||J(e,4,this.length),x(this,e,!1,23,4)},O.prototype.readDoubleLE=function(e,t){return t||J(e,8,this.length),x(this,e,!0,52,8)},O.prototype.readDoubleBE=function(e,t){return t||J(e,8,this.length),x(this,e,!1,52,8)},O.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||ee(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s<n&&(i*=256);)this[t+s]=e/i&255;return t+n},O.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||ee(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},O.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,1,255,0),O.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},O.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,65535,0),O.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):te(this,e,t,!0),t+2},O.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,65535,0),O.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):te(this,e,t,!1),t+2},O.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,4294967295,0),O.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ne(this,e,t,!0),t+4},O.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,4294967295,0),O.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},O.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);ee(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o|0)-a&255;return t+n},O.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);ee(this,e,t,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o|0)-a&255;return t+n},O.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,1,127,-128),O.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},O.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,32767,-32768),O.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):te(this,e,t,!0),t+2},O.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,32767,-32768),O.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):te(this,e,t,!1),t+2},O.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,2147483647,-2147483648),O.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ne(this,e,t,!0),t+4},O.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),O.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},O.prototype.writeFloatLE=function(e,t,n){return ie(this,e,t,!0,n)},O.prototype.writeFloatBE=function(e,t,n){return ie(this,e,t,!1,n)},O.prototype.writeDoubleLE=function(e,t,n){return se(this,e,t,!0,n)},O.prototype.writeDoubleBE=function(e,t,n){return se(this,e,t,!1,n)},O.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,s=r-n;if(this===e&&n<t&&t<r)for(i=s-1;i>=0;--i)e[i+t]=this[i+n];else if(s<1e3||!O.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},O.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!O.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var o=I(e)?e:le(new O(e,r).toString()),a=o.length;for(s=0;s<n-t;++s)this[s+t]=o[s%a]}return this};var oe=/[^+\/0-9A-Za-z-_]/g;function ae(e){return e<16?"0"+e.toString(16):e.toString(16)}function le(e,t){var n;t=t||1/0;for(var r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function ue(e){return function(e){var t,n,r,i,s,o;_||y();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===e[a-2]?2:"="===e[a-1]?1:0,o=new m(3*a/4-s),r=s>0?a-4:a;var l=0;for(t=0,n=0;t<r;t+=4,n+=3)i=g[e.charCodeAt(t)]<<18|g[e.charCodeAt(t+1)]<<12|g[e.charCodeAt(t+2)]<<6|g[e.charCodeAt(t+3)],o[l++]=i>>16&255,o[l++]=i>>8&255,o[l++]=255&i;return 2===s?(i=g[e.charCodeAt(t)]<<2|g[e.charCodeAt(t+1)]>>4,o[l++]=255&i):1===s&&(i=g[e.charCodeAt(t)]<<10|g[e.charCodeAt(t+1)]<<4|g[e.charCodeAt(t+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(oe,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function ce(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function he(e){return null!=e&&(!!e._isBuffer||de(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&de(e.slice(0,0))}(e))}function de(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var fe=Object.freeze({__proto__:null,Buffer:O,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),O.alloc(+e)},isBuffer:he,kMaxLength:S});function pe(){throw new Error("setTimeout has not been defined")}function ge(){throw new Error("clearTimeout has not been defined")}var me=pe,_e=ge;function ye(e){if(me===setTimeout)return setTimeout(e,0);if((me===pe||!me)&&setTimeout)return me=setTimeout,setTimeout(e,0);try{return me(e,0)}catch(t){try{return me.call(null,e,0)}catch(t){return me.call(this,e,0)}}}"function"==typeof f.setTimeout&&(me=setTimeout),"function"==typeof f.clearTimeout&&(_e=clearTimeout);var ve,be=[],xe=!1,we=-1;function Ae(){xe&&ve&&(xe=!1,ve.length?be=ve.concat(be):we=-1,be.length&&Ee())}function Ee(){if(!xe){var e=ye(Ae);xe=!0;for(var t=be.length;t;){for(ve=be,be=[];++we<t;)ve&&ve[we].run();we=-1,t=be.length}ve=null,xe=!1,function(e){if(_e===clearTimeout)return clearTimeout(e);if((_e===ge||!_e)&&clearTimeout)return _e=clearTimeout,clearTimeout(e);try{return _e(e)}catch(t){try{return _e.call(null,e)}catch(t){return _e.call(this,e)}}}(e)}}function Se(e,t){this.fun=e,this.array=t}Se.prototype.run=function(){this.fun.apply(null,this.array)};var Te=f.performance||{};function ke(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}Te.now||Te.mozNow||Te.msNow||Te.oNow||Te.webkitNow;var Oe,Re,Ce,Pe,Me,Ne,Ie,De,Fe,ze,Le,je,Ve,Ue,Be,Ge,$e,qe,He,We,Ze,Ke,Xe,Ye,Qe,Je,et,tt,nt,rt,it,st,ot,at,lt={exports:{}},ut=(Oe||(Oe=1,lt.exports=function e(t,n,r){function i(o,a){if(!n[o]){if(!t[o]){if(!a&&ke)return ke(o);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var s=ke,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){var r=e("./utils"),i=e("./support"),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(e){for(var t,n,i,o,a,l,u,c=[],h=0,d=e.length,f=d,p="string"!==r.getTypeOf(e);h<e.length;)f=d-h,i=p?(t=e[h++],n=h<d?e[h++]:0,h<d?e[h++]:0):(t=e.charCodeAt(h++),n=h<d?e.charCodeAt(h++):0,h<d?e.charCodeAt(h++):0),o=t>>2,a=(3&t)<<4|n>>4,l=1<f?(15&n)<<2|i>>6:64,u=2<f?63&i:64,c.push(s.charAt(o)+s.charAt(a)+s.charAt(l)+s.charAt(u));return c.join("")},n.decode=function(e){var t,n,r,o,a,l,u=0,c=0,h="data:";if(e.substr(0,5)===h)throw new Error("Invalid base64 input, it looks like a data url.");var d,f=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===s.charAt(64)&&f--,e.charAt(e.length-2)===s.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=i.uint8array?new Uint8Array(0|f):new Array(0|f);u<e.length;)t=s.indexOf(e.charAt(u++))<<2|(o=s.indexOf(e.charAt(u++)))>>4,n=(15&o)<<4|(a=s.indexOf(e.charAt(u++)))>>2,r=(3&a)<<6|(l=s.indexOf(e.charAt(u++))),d[c++]=t,64!==a&&(d[c++]=n),64!==l&&(d[c++]=r);return d}},{"./support":30,"./utils":32}],2:[function(e,t,n){var r=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");function a(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}a.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,n){return e.pipe(new s).pipe(new o("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){var r=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,n){var r=i,s=0+n;e^=-1;for(var o=0;o<s;o++)e=e>>>8^r[255&(e^t[o])];return~e}(0|t,e,e.length):function(e,t,n){var r=i,s=0+n;e^=-1;for(var o=0;o<s;o++)e=e>>>8^r[255&(e^t.charCodeAt(o))];return~e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),o=e("./stream/GenericWorker"),a=r?"uint8array":"array";function l(e,t){o.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",s.inherits(l,o),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(a,e.data),!1)},l.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){function r(e,t){var n,r="";for(n=0;n<t;n++)r+=String.fromCharCode(255&e),e>>>=8;return r}function i(e,t,n,i,o,c){var h,d,f=e.file,p=e.compression,g=c!==a.utf8encode,m=s.transformTo("string",c(f.name)),_=s.transformTo("string",a.utf8encode(f.name)),y=f.comment,v=s.transformTo("string",c(y)),b=s.transformTo("string",a.utf8encode(y)),x=_.length!==f.name.length,w=b.length!==y.length,A="",E="",S="",T=f.dir,k=f.date,O={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(O.crc32=e.crc32,O.compressedSize=e.compressedSize,O.uncompressedSize=e.uncompressedSize);var R=0;t&&(R|=8),g||!x&&!w||(R|=2048);var C=0,P=0;T&&(C|=16),"UNIX"===o?(P=798,C|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(f.unixPermissions,T)):(P=20,C|=function(e){return 63&(e||0)}(f.dosPermissions)),h=k.getUTCHours(),h<<=6,h|=k.getUTCMinutes(),h<<=5,h|=k.getUTCSeconds()/2,d=k.getUTCFullYear()-1980,d<<=4,d|=k.getUTCMonth()+1,d<<=5,d|=k.getUTCDate(),x&&(E=r(1,1)+r(l(m),4)+_,A+="up"+r(E.length,2)+E),w&&(S=r(1,1)+r(l(v),4)+b,A+="uc"+r(S.length,2)+S);var M="";return M+="\n\0",M+=r(R,2),M+=p.magic,M+=r(h,2),M+=r(d,2),M+=r(O.crc32,4),M+=r(O.compressedSize,4),M+=r(O.uncompressedSize,4),M+=r(m.length,2),M+=r(A.length,2),{fileRecord:u.LOCAL_FILE_HEADER+M+m+A,dirRecord:u.CENTRAL_FILE_HEADER+r(P,2)+M+r(v.length,2)+"\0\0\0\0"+r(C,4)+r(i,4)+m+A+v}}var s=e("../utils"),o=e("../stream/GenericWorker"),a=e("../utf8"),l=e("../crc32"),u=e("../signature");function c(e,t,n,r){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(c,o),c.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},c.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},c.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return u.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},c.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var n=this.bytesWritten-e,i=function(e,t,n,i,o){var a=s.transformTo("string",o(i));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(e,2)+r(e,2)+r(t,4)+r(n,4)+r(a.length,2)+a}(this.dirRecords.length,n,e,this.zipComment,this.encodeFileName);this.push({data:i,meta:{percent:100}})},c.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},c.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(e){t.error(e)}),this},c.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},c.prototype.error=function(e){var t=this._sources;if(!o.prototype.error.call(this,e))return!1;for(var n=0;n<t.length;n++)try{t[n].error(e)}catch(e){}return!0},c.prototype.lock=function(){o.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=c},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,n){var r=e("../compressions"),i=e("./ZipFileWorker");n.generateWorker=function(e,t,n){var s=new i(t.streamFiles,n,t.platform,t.encodeFileName),o=0;try{e.forEach(function(e,n){o++;var i=function(e,t){var n=e||t,i=r[n];if(!i)throw new Error(n+" is not a valid compression method !");return i}(n.options.compression,t.compression),a=n.options.compressionOptions||t.compressionOptions||{},l=n.dir,u=n.date;n._compressWorker(i,a).withStreamInfo("file",{name:e,dir:l,date:u,comment:n.comment||"",unixPermissions:n.unixPermissions,dosPermissions:n.dosPermissions}).pipe(s)}),s.entriesCount=o}catch(e){s.error(e)}return s}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,n){function r(){if(!(this instanceof r))return new r;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new r;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(r.prototype=e("./object")).loadAsync=e("./load"),r.support=e("./support"),r.defaults=e("./defaults"),r.version="3.10.1",r.loadAsync=function(e,t){return(new r).loadAsync(e,t)},r.external=e("./external"),t.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,n){var r=e("./utils"),i=e("./external"),s=e("./utf8"),o=e("./zipEntries"),a=e("./stream/Crc32Probe"),l=e("./nodejsUtils");function u(e){return new i.Promise(function(t,n){var r=e.decompressed.getContentWorker().pipe(new a);r.on("error",function(e){n(e)}).on("end",function(){r.streamInfo.crc32!==e.decompressed.crc32?n(new Error("Corrupted zip : CRC32 mismatch")):t()}).resume()})}t.exports=function(e,t){var n=this;return t=r.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:s.utf8decode}),l.isNode&&l.isStream(e)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then(function(e){var n=new o(t);return n.load(e),n}).then(function(e){var n=[i.Promise.resolve(e)],r=e.files;if(t.checkCRC32)for(var s=0;s<r.length;s++)n.push(u(r[s]));return i.Promise.all(n)}).then(function(e){for(var i=e.shift(),s=i.files,o=0;o<s.length;o++){var a=s[o],l=a.fileNameStr,u=r.resolve(a.fileNameStr);n.file(u,a.decompressed,{binary:!0,optimizedBinaryString:!0,date:a.date,dir:a.dir,comment:a.fileCommentStr.length?a.fileCommentStr:null,unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions,createFolders:t.createFolders}),a.dir||(n.file(u).unsafeOriginalName=l)}return i.zipComment.length&&(n.comment=i.zipComment),n})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,n){var r=e("../utils"),i=e("../stream/GenericWorker");function s(e,t){i.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}r.inherits(s,i),s.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",function(e){t.push({data:e,meta:{percent:0}})}).on("error",function(e){t.isPaused?this.generatedError=e:t.error(e)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})},s.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,n){var r=e("readable-stream").Readable;function i(e,t,n){r.call(this,t),this._helper=e;var i=this;e.on("data",function(e,t){i.push(e)||i._helper.pause(),n&&n(t)}).on("error",function(e){i.emit("error",e)}).on("end",function(){i.push(null)})}e("../utils").inherits(i,r),i.prototype._read=function(){this._helper.resume()},t.exports=i},{"../utils":32,"readable-stream":16}],14:[function(e,t,n){t.exports={isNode:void 0!==O,newBufferFrom:function(e,t){if(O.from&&O.from!==Uint8Array.from)return O.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new O(e,t)},allocBuffer:function(e){if(O.alloc)return O.alloc(e);var t=new O(e);return t.fill(0),t},isBuffer:function(e){return he(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,n){function r(e,t,n){var r,i=s.getTypeOf(t),a=s.extend(n||{},l);a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),"string"==typeof a.unixPermissions&&(a.unixPermissions=parseInt(a.unixPermissions,8)),a.unixPermissions&&16384&a.unixPermissions&&(a.dir=!0),a.dosPermissions&&16&a.dosPermissions&&(a.dir=!0),a.dir&&(e=g(e)),a.createFolders&&(r=p(e))&&m.call(this,r,!0);var h="string"===i&&!1===a.binary&&!1===a.base64;n&&void 0!==n.binary||(a.binary=!h),(t instanceof u&&0===t.uncompressedSize||a.dir||!t||0===t.length)&&(a.base64=!1,a.binary=!0,t="",a.compression="STORE",i="string");var _;_=t instanceof u||t instanceof o?t:d.isNode&&d.isStream(t)?new f(e,t):s.prepareContent(e,t,a.binary,a.optimizedBinaryString,a.base64);var y=new c(e,_,a);this.files[e]=y}var i=e("./utf8"),s=e("./utils"),o=e("./stream/GenericWorker"),a=e("./stream/StreamHelper"),l=e("./defaults"),u=e("./compressedObject"),c=e("./zipObject"),h=e("./generate"),d=e("./nodejsUtils"),f=e("./nodejs/NodejsStreamInputAdapter"),p=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},g=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},m=function(e,t){return t=void 0!==t?t:l.createFolders,e=g(e),this.files[e]||r.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function _(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,n,r;for(t in this.files)r=this.files[t],(n=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(n,r)},filter:function(e){var t=[];return this.forEach(function(n,r){e(n,r)&&t.push(r)}),t},file:function(e,t,n){if(1!==arguments.length)return e=this.root+e,r.call(this,e,t,n),this;if(_(e)){var i=e;return this.filter(function(e,t){return!t.dir&&i.test(e)})}var s=this.files[this.root+e];return s&&!s.dir?s:null},folder:function(e){if(!e)return this;if(_(e))return this.filter(function(t,n){return n.dir&&e.test(t)});var t=this.root+e,n=m.call(this,t),r=this.clone();return r.root=n.name,r},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!==e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var n=this.filter(function(t,n){return n.name.slice(0,e.length)===e}),r=0;r<n.length;r++)delete this.files[n[r].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,n={};try{if((n=s.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=n.type.toLowerCase(),n.compression=n.compression.toUpperCase(),"binarystring"===n.type&&(n.type="string"),!n.type)throw new Error("No output type specified.");s.checkSupport(n.type),"darwin"!==n.platform&&"freebsd"!==n.platform&&"linux"!==n.platform&&"sunos"!==n.platform||(n.platform="UNIX"),"win32"===n.platform&&(n.platform="DOS");var r=n.comment||this.comment||"";t=h.generateWorker(this,n,r)}catch(e){(t=new o("error")).error(e)}return new a(t,n.type||"string",n.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,n){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,n){var r=e("./DataReader");function i(e){r.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data[this.zero+e]},i.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),n=e.charCodeAt(1),r=e.charCodeAt(2),i=e.charCodeAt(3),s=this.length-4;0<=s;--s)if(this.data[s]===t&&this.data[s+1]===n&&this.data[s+2]===r&&this.data[s+3]===i)return s-this.zero;return-1},i.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1),r=e.charCodeAt(2),i=e.charCodeAt(3),s=this.readData(4);return t===s[0]&&n===s[1]&&r===s[2]&&i===s[3]},i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],18:[function(e,t,n){var r=e("../utils");function i(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,n=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){var r=e("./Uint8ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){var r=e("./DataReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){var r=e("./ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){var r=e("../utils"),i=e("../support"),s=e("./ArrayReader"),o=e("./StringReader"),a=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new a(e):i.uint8array?new l(r.transformTo("uint8array",e)):new s(r.transformTo("array",e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){var r=e("./GenericWorker"),i=e("../utils");function s(e){r.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,r),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){var r=e("./GenericWorker"),i=e("../crc32");function s(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,r),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){var r=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){var r=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}r.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n<this._listeners[e].length;n++)this._listeners[e][n].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.end()}),e.on("error",function(e){t.error(e)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=r},{}],29:[function(e,t,n){var r=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),o=e("../base64"),a=e("../support"),l=e("../external"),u=null;if(a.nodestream)try{u=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function c(e,t,n){var o=t;switch(t){case"blob":case"arraybuffer":o="uint8array";break;case"base64":o="string"}try{this._internalType=o,this._outputType=t,this._mimeType=n,r.checkSupport(o),this._worker=e.pipe(new i(o)),e.lock()}catch(e){this._worker=new s("error"),this._worker.error(e)}}c.prototype={accumulate:function(e){return function(e,t){return new l.Promise(function(n,i){var s=[],a=e._internalType,l=e._outputType,u=e._mimeType;e.on("data",function(e,n){s.push(e),t&&t(n)}).on("error",function(e){s=[],i(e)}).on("end",function(){try{var e=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return o.encode(t);default:return r.transformTo(e,t)}}(l,function(e,t){var n,r=0,i=null,s=0;for(n=0;n<t.length;n++)s+=t[n].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(s),n=0;n<t.length;n++)i.set(t[n],r),r+=t[n].length;return i;case"nodebuffer":return O.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(a,s),u);n(e)}catch(e){i(e)}s=[]}).resume()})}(this,e)},on:function(e,t){var n=this;return"data"===e?this._worker.on(e,function(e){t.call(n,e.data,e.meta)}):this._worker.on(e,function(){r.delay(t,arguments,n)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(r.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=c},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,n.nodebuffer=void 0!==O,n.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=0===new Blob([r],{type:"application/zip"}).size}catch(e){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(r),n.blob=0===i.getBlob("application/zip").size}catch(e){n.blob=!1}}}try{n.nodestream=!!e("readable-stream").Readable}catch(e){n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,n){for(var r=e("./utils"),i=e("./support"),s=e("./nodejsUtils"),o=e("./stream/GenericWorker"),a=new Array(256),l=0;l<256;l++)a[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function u(){o.call(this,"utf-8 decode"),this.leftOver=null}function c(){o.call(this,"utf-8 encode")}a[254]=a[254]=1,n.utf8encode=function(e){return i.nodebuffer?s.newBufferFrom(e,"utf-8"):function(e){var t,n,r,s,o,a=e.length,l=0;for(s=0;s<a;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(r=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(r-56320),s++),l+=n<128?1:n<2048?2:n<65536?3:4;for(t=i.uint8array?new Uint8Array(l):new Array(l),s=o=0;o<l;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(r=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(r-56320),s++),n<128?t[o++]=n:(n<2048?t[o++]=192|n>>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,s,o=e.length,l=new Array(2*o);for(t=n=0;t<o;)if((i=e[t++])<128)l[n++]=i;else if(4<(s=a[i]))l[n++]=65533,t+=s-1;else{for(i&=2===s?31:3===s?15:7;1<s&&t<o;)i=i<<6|63&e[t++],s--;1<s?l[n++]=65533:i<65536?l[n++]=i:(i-=65536,l[n++]=55296|i>>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),r.applyFromCharCode(l)}(e=r.transformTo(i.uint8array?"uint8array":"array",e))},r.inherits(u,o),u.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var s=t;(t=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),t.set(s,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}(t),l=t;o!==t.length&&(i.uint8array?(l=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(l=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=u,r.inherits(c,o),c.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=c},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){var r=e("./support"),i=e("./base64"),s=e("./nodejsUtils"),o=e("./external");function a(e){return e}function l(e,t){for(var n=0;n<e.length;++n)t[n]=255&e.charCodeAt(n);return t}e("setimmediate"),n.newBlob=function(e,t){n.checkSupport("blob");try{return new Blob([e],{type:t})}catch(n){try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return r.append(e),r.getBlob(t)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(e,t,n){var r=[],i=0,s=e.length;if(s<=n)return String.fromCharCode.apply(null,e);for(;i<s;)"array"===t||"nodebuffer"===t?r.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+n,s)))):r.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+n,s)))),i+=n;return r.join("")},stringifyByChar:function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},applyCanBeUsed:{uint8array:function(){try{return r.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return r.nodebuffer&&1===String.fromCharCode.apply(null,s.allocBuffer(1)).length}catch(e){return!1}}()}};function c(e){var t=65536,r=n.getTypeOf(e),i=!0;if("uint8array"===r?i=u.applyCanBeUsed.uint8array:"nodebuffer"===r&&(i=u.applyCanBeUsed.nodebuffer),i)for(;1<t;)try{return u.stringifyByChunk(e,r,t)}catch(e){t=Math.floor(t/2)}return u.stringifyByChar(e)}function h(e,t){for(var n=0;n<e.length;n++)t[n]=e[n];return t}n.applyFromCharCode=c;var d={};d.string={string:a,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return d.string.uint8array(e).buffer},uint8array:function(e){return l(e,new Uint8Array(e.length))},nodebuffer:function(e){return l(e,s.allocBuffer(e.length))}},d.array={string:c,array:a,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return s.newBufferFrom(e)}},d.arraybuffer={string:function(e){return c(new Uint8Array(e))},array:function(e){return h(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:a,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return s.newBufferFrom(new Uint8Array(e))}},d.uint8array={string:c,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:a,nodebuffer:function(e){return s.newBufferFrom(e)}},d.nodebuffer={string:c,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return d.nodebuffer.uint8array(e).buffer},uint8array:function(e){return h(e,new Uint8Array(e.length))},nodebuffer:a},n.transformTo=function(e,t){if(t=t||"",!e)return t;n.checkSupport(e);var r=n.getTypeOf(t);return d[r][e](t)},n.resolve=function(e){for(var t=e.split("/"),n=[],r=0;r<t.length;r++){var i=t[r];"."===i||""===i&&0!==r&&r!==t.length-1||(".."===i?n.pop():n.push(i))}return n.join("/")},n.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":r.nodebuffer&&s.isBuffer(e)?"nodebuffer":r.uint8array&&e instanceof Uint8Array?"uint8array":r.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(e){if(!r[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(e){var t,n,r="";for(n=0;n<(e||"").length;n++)r+="\\x"+((t=e.charCodeAt(n))<16?"0":"")+t.toString(16).toUpperCase();return r},n.delay=function(e,t,n){setImmediate(function(){e.apply(n||null,t||[])})},n.inherits=function(e,t){function n(){}n.prototype=t.prototype,e.prototype=new n},n.extend=function(){var e,t,n={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===n[t]&&(n[t]=arguments[e][t]);return n},n.prepareContent=function(e,t,s,a,u){return o.Promise.resolve(t).then(function(e){return r.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new o.Promise(function(t,n){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=function(e){n(e.target.error)},r.readAsArrayBuffer(e)}):e}).then(function(t){var c=n.getTypeOf(t);return c?("arraybuffer"===c?t=n.transformTo("uint8array",t):"string"===c&&(u?t=i.decode(t):s&&!0!==a&&(t=function(e){return l(e,r.uint8array?new Uint8Array(e.length):new Array(e.length))}(t))),t):o.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,n){var r=e("./reader/readerFor"),i=e("./utils"),s=e("./signature"),o=e("./zipEntry"),a=e("./support");function l(e){this.files=[],this.loadOptions=e}l.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(t)+", expected "+i.pretty(e)+")")}},isSignature:function(e,t){var n=this.reader.index;this.reader.setIndex(e);var r=this.reader.readString(4)===t;return this.reader.setIndex(n),r},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=a.uint8array?"uint8array":"array",n=i.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(n)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,n,r=this.zip64EndOfCentralSize-44;0<r;)e=this.reader.readInt(2),t=this.reader.readInt(4),n=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:n}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(e=new o({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(e);var t=e;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var n=this.centralDirOffset+this.centralDirSize;this.zip64&&(n+=20,n+=12+this.zip64EndOfCentralSize);var r=t-n;if(0<r)this.isSignature(t,s.CENTRAL_FILE_HEADER)||(this.reader.zero=r);else if(r<0)throw new Error("Corrupted zip: missing "+Math.abs(r)+" bytes.")},prepareReader:function(e){this.reader=r(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=l},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,n){var r=e("./reader/readerFor"),i=e("./utils"),s=e("./compressedObject"),o=e("./crc32"),a=e("./utf8"),l=e("./compressions"),u=e("./support");function c(e,t){this.options=e,this.loadOptions=t}c.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(e){var t,n;if(e.skip(22),this.fileNameLength=e.readInt(2),n=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(n),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in l)if(Object.prototype.hasOwnProperty.call(l,t)&&l[t].magic===e)return l[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new s(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),n=e.readInt(2),r=e.readData(n),this.extraFields[t]={id:t,length:n,value:r};e.setIndex(i)},handleUTF8:function(){var e=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=a.utf8decode(this.fileName),this.fileCommentStr=a.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var n=i.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(n)}var r=this.findExtraFieldUnicodeComment();if(null!==r)this.fileCommentStr=r;else{var s=i.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(s)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=r(e.value);return 1!==t.readInt(1)||o(this.fileName)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=r(e.value);return 1!==t.readInt(1)||o(this.fileComment)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null}},t.exports=c},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,n){function r(e,t,n){this.name=e,this.dir=n.dir,this.date=n.date,this.comment=n.comment,this.unixPermissions=n.unixPermissions,this.dosPermissions=n.dosPermissions,this._data=t,this._dataBinary=n.binary,this.options={compression:n.compression,compressionOptions:n.compressionOptions}}var i=e("./stream/StreamHelper"),s=e("./stream/DataWorker"),o=e("./utf8"),a=e("./compressedObject"),l=e("./stream/GenericWorker");r.prototype={internalStream:function(e){var t=null,n="string";try{if(!e)throw new Error("No output type specified.");var r="string"===(n=e.toLowerCase())||"text"===n;"binarystring"!==n&&"text"!==n||(n="string"),t=this._decompressWorker();var s=!this._dataBinary;s&&!r&&(t=t.pipe(new o.Utf8EncodeWorker)),!s&&r&&(t=t.pipe(new o.Utf8DecodeWorker))}catch(e){(t=new l("error")).error(e)}return new i(t,n,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof a&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var n=this._decompressWorker();return this._dataBinary||(n=n.pipe(new o.Utf8EncodeWorker)),a.createWorkerFrom(n,e,t)},_decompressWorker:function(){return this._data instanceof a?this._data.getContentWorker():this._data instanceof l?this._data:new s(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],c=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<u.length;h++)r.prototype[u[h]]=c;t.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,n){(function(e){var n,r,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var s=0,o=new i(c),a=e.document.createTextNode("");o.observe(a,{characterData:!0}),n=function(){a.data=s=++s%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){c(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(c,0)};else{var l=new e.MessageChannel;l.port1.onmessage=c,n=function(){l.port2.postMessage(0)}}var u=[];function c(){var e,t;r=!0;for(var n=u.length;n;){for(t=u,u=[],e=-1;++e<n;)t[e]();n=u.length}r=!1}t.exports=function(e){1!==u.push(e)||r||n()}}).call(this,void 0!==f?f:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,n){var r=e("immediate");function i(){}var s={},o=["REJECTED"],a=["FULFILLED"],l=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==i&&f(this,e)}function c(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function h(e,t,n){r(function(){var r;try{r=t(n)}catch(r){return s.reject(e,r)}r===e?s.reject(e,new TypeError("Cannot resolve promise with itself")):s.resolve(e,r)})}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function f(e,t){var n=!1;function r(t){n||(n=!0,s.reject(e,t))}function i(t){n||(n=!0,s.resolve(e,t))}var o=p(function(){t(i,r)});"error"===o.status&&r(o.value)}function p(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}(t.exports=u).prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})},u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===o)return this;var n=new this.constructor(i);return this.state!==l?h(n,this.state===a?e:t,this.outcome):this.queue.push(new c(n,e,t)),n},c.prototype.callFulfilled=function(e){s.resolve(this.promise,e)},c.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},c.prototype.callRejected=function(e){s.reject(this.promise,e)},c.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},s.resolve=function(e,t){var n=p(d,t);if("error"===n.status)return s.reject(e,n.value);var r=n.value;if(r)f(e,r);else{e.state=a,e.outcome=t;for(var i=-1,o=e.queue.length;++i<o;)e.queue[i].callFulfilled(t)}return e},s.reject=function(e,t){e.state=o,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},u.resolve=function(e){return e instanceof this?e:s.resolve(new this(i),e)},u.reject=function(e){var t=new this(i);return s.reject(t,e)},u.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var o=new Array(n),a=0,l=-1,u=new this(i);++l<n;)c(e[l],l);return u;function c(e,i){t.resolve(e).then(function(e){o[i]=e,++a!==n||r||(r=!0,s.resolve(u,o))},function(e){r||(r=!0,s.reject(u,e))})}},u.race=function(e){if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var t=e.length,n=!1;if(!t)return this.resolve([]);for(var r,o=-1,a=new this(i);++o<t;)r=e[o],this.resolve(r).then(function(e){n||(n=!0,s.resolve(a,e))},function(e){n||(n=!0,s.reject(a,e))});return a}},{immediate:36}],38:[function(e,t,n){var r={};(0,e("./lib/utils/common").assign)(r,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,n){var r=e("./zlib/deflate"),i=e("./utils/common"),s=e("./utils/strings"),o=e("./zlib/messages"),a=e("./zlib/zstream"),l=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=i.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var n=r.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==n)throw new Error(o[n]);if(t.header&&r.deflateSetHeader(this.strm,t.header),t.dictionary){var c;if(c="string"==typeof t.dictionary?s.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(n=r.deflateSetDictionary(this.strm,c)))throw new Error(o[n]);this._dict_set=!0}}function c(e,t){var n=new u(t);if(n.push(e,!0),n.err)throw n.msg||o[n.err];return n.result}u.prototype.push=function(e,t){var n,o,a=this.strm,u=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=s.string2buf(e):"[object ArrayBuffer]"===l.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(u),a.next_out=0,a.avail_out=u),1!==(n=r.deflate(a,o))&&0!==n)return this.onEnd(n),!(this.ended=!0);0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(s.buf2binstring(i.shrinkBuf(a.output,a.next_out))):this.onData(i.shrinkBuf(a.output,a.next_out)))}while((0<a.avail_in||0===a.avail_out)&&1!==n);return 4===o?(n=r.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==o||(this.onEnd(0),!(a.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=u,n.deflate=c,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,c(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,n){var r=e("./zlib/inflate"),i=e("./utils/common"),s=e("./utils/strings"),o=e("./zlib/constants"),a=e("./zlib/messages"),l=e("./zlib/zstream"),u=e("./zlib/gzheader"),c=Object.prototype.toString;function h(e){if(!(this instanceof h))return new h(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var n=r.inflateInit2(this.strm,t.windowBits);if(n!==o.Z_OK)throw new Error(a[n]);this.header=new u,r.inflateGetHeader(this.strm,this.header)}function d(e,t){var n=new h(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}h.prototype.push=function(e,t){var n,a,l,u,h,d,f=this.strm,p=this.options.chunkSize,g=this.options.dictionary,m=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof e?f.input=s.binstring2buf(e):"[object ArrayBuffer]"===c.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new i.Buf8(p),f.next_out=0,f.avail_out=p),(n=r.inflate(f,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&g&&(d="string"==typeof g?s.string2buf(g):"[object ArrayBuffer]"===c.call(g)?new Uint8Array(g):g,n=r.inflateSetDictionary(this.strm,d)),n===o.Z_BUF_ERROR&&!0===m&&(n=o.Z_OK,m=!1),n!==o.Z_STREAM_END&&n!==o.Z_OK)return this.onEnd(n),!(this.ended=!0);f.next_out&&(0!==f.avail_out&&n!==o.Z_STREAM_END&&(0!==f.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(l=s.utf8border(f.output,f.next_out),u=f.next_out-l,h=s.buf2string(f.output,l),f.next_out=u,f.avail_out=p-u,u&&i.arraySet(f.output,f.output,l,u,0),this.onData(h)):this.onData(i.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(m=!0)}while((0<f.avail_in||0===f.avail_out)&&n!==o.Z_STREAM_END);return n===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(n=r.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),!(f.avail_out=0))},h.prototype.onData=function(e){this.chunks.push(e)},h.prototype.onEnd=function(e){e===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=h,n.inflate=d,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,d(e,t)},n.ungzip=d},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,n){var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var s=0;s<r;s++)e[i+s]=t[n+s]},flattenChunks:function(e){var t,n,r,i,s,o;for(t=r=0,n=e.length;t<n;t++)r+=e[t].length;for(o=new Uint8Array(r),t=i=0,n=e.length;t<n;t++)s=e[t],o.set(s,i),i+=s.length;return o}},s={arraySet:function(e,t,n,r,i){for(var s=0;s<r;s++)e[i+s]=t[n+s]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,i)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(r)},{}],42:[function(e,t,n){var r=e("./common"),i=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var o=new r.Buf8(256),a=0;a<256;a++)o[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function l(e,t){if(t<65537&&(e.subarray&&s||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",o=0;o<t;o++)n+=String.fromCharCode(e[o]);return n}o[254]=o[254]=1,n.string2buf=function(e){var t,n,i,s,o,a=e.length,l=0;for(s=0;s<a;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),l+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(l),s=o=0;o<l;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),n<128?t[o++]=n:(n<2048?t[o++]=192|n>>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,s,a=t||e.length,u=new Array(2*a);for(n=r=0;n<a;)if((i=e[n++])<128)u[r++]=i;else if(4<(s=o[i]))u[r++]=65533,n+=s-1;else{for(i&=2===s?31:3===s?15:7;1<s&&n<a;)i=i<<6|63&e[n++],s--;1<s?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return l(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+o[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){t.exports=function(e,t,n,r){for(var i=65535&e,s=e>>>16&65535,o=0;0!==n;){for(n-=o=2e3<n?2e3:n;s=s+(i=i+t[r++]|0)|0,--o;);i%=65521,s%=65521}return i|s<<16}},{}],44:[function(e,t,n){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,n){var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var s=r,o=i+n;e^=-1;for(var a=i;a<o;a++)e=e>>>8^s[255&(e^t[a])];return~e}},{}],46:[function(e,t,n){var r,i=e("../utils/common"),s=e("./trees"),o=e("./adler32"),a=e("./crc32"),l=e("./messages"),u=-2,c=258,h=262,d=113;function f(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4<e?9:0)}function g(e){for(var t=e.length;0<=--t;)e[t]=0}function m(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function _(e,t){s._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,m(e.strm)}function y(e,t){e.pending_buf[e.pending++]=t}function v(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function b(e,t){var n,r,i=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-h?e.strstart-(e.w_size-h):0,u=e.window,d=e.w_mask,f=e.prev,p=e.strstart+c,g=u[s+o-1],m=u[s+o];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(n=t)+o]===m&&u[n+o-1]===g&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&s<p);if(r=c-(p-s),s=p-c,o<r){if(e.match_start=t,a<=(o=r))break;g=u[s+o-1],m=u[s+o]}}}while((t=f[t&d])>l&&0!=--i);return o<=e.lookahead?o:e.lookahead}function x(e){var t,n,r,s,l,u,c,d,f,p,g=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=g+(g-h)){for(i.arraySet(e.window,e.window,g,g,0),e.match_start-=g,e.strstart-=g,e.block_start-=g,t=n=e.hash_size;r=e.head[--t],e.head[t]=g<=r?r-g:0,--n;);for(t=n=g;r=e.prev[--t],e.prev[t]=g<=r?r-g:0,--n;);s+=g}if(0===e.strm.avail_in)break;if(u=e.strm,c=e.window,d=e.strstart+e.lookahead,p=void 0,(f=s)<(p=u.avail_in)&&(p=f),n=0===p?0:(u.avail_in-=p,i.arraySet(c,u.input,u.next_in,p,d),1===u.state.wrap?u.adler=o(u.adler,c,p,d):2===u.state.wrap&&(u.adler=a(u.adler,c,p,d)),u.next_in+=p,u.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+3-1])&e.hash_mask,e.prev[l&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=l,l++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<h&&0!==e.strm.avail_in)}function w(e,t){for(var n,r;;){if(e.lookahead<h){if(x(e),e.lookahead<h&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-h&&(e.match_length=b(e,n)),e.match_length>=3)if(r=s._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}function A(e,t){for(var n,r,i;;){if(e.lookahead<h){if(x(e),e.lookahead<h&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-h&&(e.match_length=b(e,n),e.match_length<=5&&(1===e.strategy||3===e.match_length&&4096<e.strstart-e.match_start)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-3,r=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(_(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=s._tr_tally(e,0,e.window[e.strstart-1]))&&_(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=s._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}function E(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}function S(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),g(this.dyn_ltree),g(this.dyn_dtree),g(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),g(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),g(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function T(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:d,e.adler=2===t.wrap?0:1,t.last_flush=0,s._tr_init(t),0):f(e,u)}function k(e){var t=T(e);return 0===t&&function(e){e.window_size=2*e.w_size,g(e.head),e.max_lazy_match=r[e.level].max_lazy,e.good_match=r[e.level].good_length,e.nice_match=r[e.level].nice_length,e.max_chain_length=r[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0}(e.state),t}function O(e,t,n,r,s,o){if(!e)return u;var a=1;if(-1===t&&(t=6),r<0?(a=0,r=-r):15<r&&(a=2,r-=16),s<1||9<s||8!==n||r<8||15<r||t<0||9<t||o<0||4<o)return f(e,u);8===r&&(r=9);var l=new S;return(e.state=l).strm=e,l.wrap=a,l.gzhead=null,l.w_bits=r,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=s+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+3-1)/3),l.window=new i.Buf8(2*l.w_size),l.head=new i.Buf16(l.hash_size),l.prev=new i.Buf16(l.w_size),l.lit_bufsize=1<<s+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new i.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=t,l.strategy=o,l.method=n,k(e)}r=[new E(0,0,0,0,function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(x(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,_(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-h&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(_(e,!1),e.strm.avail_out),1)}),new E(4,4,8,4,w),new E(4,5,16,8,w),new E(4,6,32,32,w),new E(4,4,16,16,A),new E(8,16,32,32,A),new E(8,16,128,128,A),new E(8,32,128,256,A),new E(32,128,258,1024,A),new E(32,258,258,4096,A)],n.deflateInit=function(e,t){return O(e,t,8,15,8,0)},n.deflateInit2=O,n.deflateReset=k,n.deflateResetKeep=T,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?u:(e.state.gzhead=t,0):u},n.deflate=function(e,t){var n,i,o,l;if(!e||!e.state||5<t||t<0)return e?f(e,u):u;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return f(e,0===e.avail_out?-5:u);if(i.strm=e,n=i.last_flush,i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,y(i,31),y(i,139),y(i,8),i.gzhead?(y(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),y(i,255&i.gzhead.time),y(i,i.gzhead.time>>8&255),y(i,i.gzhead.time>>16&255),y(i,i.gzhead.time>>24&255),y(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),y(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(y(i,255&i.gzhead.extra.length),y(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(y(i,0),y(i,0),y(i,0),y(i,0),y(i,0),y(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),y(i,3),i.status=d);else{var h=8+(i.w_bits-8<<4)<<8;h|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(h|=32),h+=31-h%31,i.status=d,v(i,h),0!==i.strstart&&(v(i,e.adler>>>16),v(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),m(e),o=i.pending,i.pending!==i.pending_buf_size));)y(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),m(e),o=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,y(i,l)}while(0!==l);i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),m(e),o=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,y(i,l)}while(0!==l);i.gzhead.hcrc&&i.pending>o&&(e.adler=a(e.adler,i.pending_buf,i.pending-o,o)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&m(e),i.pending+2<=i.pending_buf_size&&(y(i,255&e.adler),y(i,e.adler>>8&255),e.adler=0,i.status=d)):i.status=d),0!==i.pending){if(m(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return f(e,-5);if(666===i.status&&0!==e.avail_in)return f(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var b=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(x(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,o,a=e.window;;){if(e.lookahead<=c){if(x(e),e.lookahead<=c&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0<e.strstart&&(r=a[i=e.strstart-1])===a[++i]&&r===a[++i]&&r===a[++i]){o=e.strstart+c;do{}while(r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&i<o);e.match_length=c-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=s._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==b&&4!==b||(i.status=666),1===b||3===b)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===b&&(1===t?s._tr_align(i):5!==t&&(s._tr_stored_block(i,0,0,!1),3===t&&(g(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),m(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(y(i,255&e.adler),y(i,e.adler>>8&255),y(i,e.adler>>16&255),y(i,e.adler>>24&255),y(i,255&e.total_in),y(i,e.total_in>>8&255),y(i,e.total_in>>16&255),y(i,e.total_in>>24&255)):(v(i,e.adler>>>16),v(i,65535&e.adler)),m(e),0<i.wrap&&(i.wrap=-i.wrap),0!==i.pending?0:1)},n.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&103!==t&&t!==d&&666!==t?f(e,u):(e.state=null,t===d?f(e,-3):0):u},n.deflateSetDictionary=function(e,t){var n,r,s,a,l,c,h,d,f=t.length;if(!e||!e.state)return u;if(2===(a=(n=e.state).wrap)||1===a&&42!==n.status||n.lookahead)return u;for(1===a&&(e.adler=o(e.adler,t,f,0)),n.wrap=0,f>=n.w_size&&(0===a&&(g(n.head),n.strstart=0,n.block_start=0,n.insert=0),d=new i.Buf8(n.w_size),i.arraySet(d,t,f-n.w_size,n.w_size,0),t=d,f=n.w_size),l=e.avail_in,c=e.next_in,h=e.input,e.avail_in=f,e.next_in=0,e.input=t,x(n);n.lookahead>=3;){for(r=n.strstart,s=n.lookahead-2;n.ins_h=(n.ins_h<<n.hash_shift^n.window[r+3-1])&n.hash_mask,n.prev[r&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=r,r++,--s;);n.strstart=r,n.lookahead=2,x(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=c,e.input=h,e.avail_in=l,n.wrap=a,0},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,n){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,n){t.exports=function(e,t){var n,r,i,s,o,a,l,u,c,h,d,f,p,g,m,_,y,v,b,x,w,A,E,S,T;n=e.state,r=e.next_in,S=e.input,i=r+(e.avail_in-5),s=e.next_out,T=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),l=n.dmax,u=n.wsize,c=n.whave,h=n.wnext,d=n.window,f=n.hold,p=n.bits,g=n.lencode,m=n.distcode,_=(1<<n.lenbits)-1,y=(1<<n.distbits)-1;e:do{p<15&&(f+=S[r++]<<p,p+=8,f+=S[r++]<<p,p+=8),v=g[f&_];t:for(;;){if(f>>>=b=v>>>24,p-=b,0==(b=v>>>16&255))T[s++]=65535&v;else{if(!(16&b)){if(!(64&b)){v=g[(65535&v)+(f&(1<<b)-1)];continue t}if(32&b){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}x=65535&v,(b&=15)&&(p<b&&(f+=S[r++]<<p,p+=8),x+=f&(1<<b)-1,f>>>=b,p-=b),p<15&&(f+=S[r++]<<p,p+=8,f+=S[r++]<<p,p+=8),v=m[f&y];n:for(;;){if(f>>>=b=v>>>24,p-=b,!(16&(b=v>>>16&255))){if(!(64&b)){v=m[(65535&v)+(f&(1<<b)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(w=65535&v,p<(b&=15)&&(f+=S[r++]<<p,(p+=8)<b&&(f+=S[r++]<<p,p+=8)),l<(w+=f&(1<<b)-1)){e.msg="invalid distance too far back",n.mode=30;break e}if(f>>>=b,p-=b,(b=s-o)<w){if(c<(b=w-b)&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(E=d,(A=0)===h){if(A+=u-b,b<x){for(x-=b;T[s++]=d[A++],--b;);A=s-w,E=T}}else if(h<b){if(A+=u+h-b,(b-=h)<x){for(x-=b;T[s++]=d[A++],--b;);if(A=0,h<x){for(x-=b=h;T[s++]=d[A++],--b;);A=s-w,E=T}}}else if(A+=h-b,b<x){for(x-=b;T[s++]=d[A++],--b;);A=s-w,E=T}for(;2<x;)T[s++]=E[A++],T[s++]=E[A++],T[s++]=E[A++],x-=3;x&&(T[s++]=E[A++],1<x&&(T[s++]=E[A++]))}else{for(A=s-w;T[s++]=T[A++],T[s++]=T[A++],T[s++]=T[A++],2<(x-=3););x&&(T[s++]=T[A++],1<x&&(T[s++]=T[A++]))}break}}break}}while(r<i&&s<a);r-=x=p>>3,f&=(1<<(p-=x<<3))-1,e.next_in=r,e.next_out=s,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=s<a?a-s+257:257-(s-a),n.hold=f,n.bits=p}},{}],49:[function(e,t,n){var r=e("../utils/common"),i=e("./adler32"),s=e("./crc32"),o=e("./inffast"),a=e("./inftrees"),l=-2;function u(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function c(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function h(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):l}function d(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,h(e)):l}function f(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?l:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,d(e))):l}function p(e,t){var n,r;return e?(r=new c,(e.state=r).window=null,0!==(n=f(e,t))&&(e.state=null),n):l}var g,m,_=!0;function y(e){if(_){var t;for(g=new r.Buf32(512),m=new r.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,g,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,m,0,e.work,{bits:5}),_=!1}e.lencode=g,e.lenbits=9,e.distcode=m,e.distbits=5}function v(e,t,n,i){var s,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new r.Buf8(o.wsize)),i>=o.wsize?(r.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i<(s=o.wsize-o.wnext)&&(s=i),r.arraySet(o.window,t,n-i,s,o.wnext),(i-=s)?(r.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=s))),0}n.inflateReset=d,n.inflateReset2=f,n.inflateResetKeep=h,n.inflateInit=function(e){return p(e,15)},n.inflateInit2=p,n.inflate=function(e,t){var n,c,h,d,f,p,g,m,_,b,x,w,A,E,S,T,k,O,R,C,P,M,N,I,D=0,F=new r.Buf8(4),z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return l;12===(n=e.state).mode&&(n.mode=13),f=e.next_out,h=e.output,g=e.avail_out,d=e.next_in,c=e.input,p=e.avail_in,m=n.hold,_=n.bits,b=p,x=g,M=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(2&n.wrap&&35615===m){F[n.check=0]=255&m,F[1]=m>>>8&255,n.check=s(n.check,F,2,0),_=m=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&m)<<8)+(m>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&m)){e.msg="unknown compression method",n.mode=30;break}if(_-=4,P=8+(15&(m>>>=4)),0===n.wbits)n.wbits=P;else if(P>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<P,e.adler=n.check=1,n.mode=512&m?10:12,_=m=0;break;case 2:for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(n.flags=m,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=m>>8&1),512&n.flags&&(F[0]=255&m,F[1]=m>>>8&255,n.check=s(n.check,F,2,0)),_=m=0,n.mode=3;case 3:for(;_<32;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.head&&(n.head.time=m),512&n.flags&&(F[0]=255&m,F[1]=m>>>8&255,F[2]=m>>>16&255,F[3]=m>>>24&255,n.check=s(n.check,F,4,0)),_=m=0,n.mode=4;case 4:for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.head&&(n.head.xflags=255&m,n.head.os=m>>8),512&n.flags&&(F[0]=255&m,F[1]=m>>>8&255,n.check=s(n.check,F,2,0)),_=m=0,n.mode=5;case 5:if(1024&n.flags){for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.length=m,n.head&&(n.head.extra_len=m),512&n.flags&&(F[0]=255&m,F[1]=m>>>8&255,n.check=s(n.check,F,2,0)),_=m=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(w=n.length)&&(w=p),w&&(n.head&&(P=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,c,d,w,P)),512&n.flags&&(n.check=s(n.check,c,w,d)),p-=w,d+=w,n.length-=w),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(w=0;P=c[d+w++],n.head&&P&&n.length<65536&&(n.head.name+=String.fromCharCode(P)),P&&w<p;);if(512&n.flags&&(n.check=s(n.check,c,w,d)),p-=w,d+=w,P)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===p)break e;for(w=0;P=c[d+w++],n.head&&P&&n.length<65536&&(n.head.comment+=String.fromCharCode(P)),P&&w<p;);if(512&n.flags&&(n.check=s(n.check,c,w,d)),p-=w,d+=w,P)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;_<16;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(m!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}_=m=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;_<32;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}e.adler=n.check=u(m),_=m=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=f,e.avail_out=g,e.next_in=d,e.avail_in=p,n.hold=m,n.bits=_,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last){m>>>=7&_,_-=7&_,n.mode=27;break}for(;_<3;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}switch(n.last=1&m,_-=1,3&(m>>>=1)){case 0:n.mode=14;break;case 1:if(y(n),n.mode=20,6!==t)break;m>>>=2,_-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}m>>>=2,_-=2;break;case 14:for(m>>>=7&_,_-=7&_;_<32;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if((65535&m)!=(m>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&m,_=m=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(w=n.length){if(p<w&&(w=p),g<w&&(w=g),0===w)break e;r.arraySet(h,c,d,w,f),p-=w,d+=w,g-=w,f+=w,n.length-=w;break}n.mode=12;break;case 17:for(;_<14;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(n.nlen=257+(31&m),m>>>=5,_-=5,n.ndist=1+(31&m),m>>>=5,_-=5,n.ncode=4+(15&m),m>>>=4,_-=4,286<n.nlen||30<n.ndist){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;_<3;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.lens[z[n.have++]]=7&m,m>>>=3,_-=3}for(;n.have<19;)n.lens[z[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,N={bits:n.lenbits},M=a(0,n.lens,0,19,n.lencode,0,n.work,N),n.lenbits=N.bits,M){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;T=(D=n.lencode[m&(1<<n.lenbits)-1])>>>16&255,k=65535&D,!((S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(k<16)m>>>=S,_-=S,n.lens[n.have++]=k;else{if(16===k){for(I=S+2;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(m>>>=S,_-=S,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}P=n.lens[n.have-1],w=3+(3&m),m>>>=2,_-=2}else if(17===k){for(I=S+3;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}_-=S,P=0,w=3+(7&(m>>>=S)),m>>>=3,_-=3}else{for(I=S+7;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}_-=S,P=0,w=11+(127&(m>>>=S)),m>>>=7,_-=7}if(n.have+w>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;w--;)n.lens[n.have++]=P}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,N={bits:n.lenbits},M=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,N),n.lenbits=N.bits,M){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,N={bits:n.distbits},M=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,N),n.distbits=N.bits,M){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=g){e.next_out=f,e.avail_out=g,e.next_in=d,e.avail_in=p,n.hold=m,n.bits=_,o(e,x),f=e.next_out,h=e.output,g=e.avail_out,d=e.next_in,c=e.input,p=e.avail_in,m=n.hold,_=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;T=(D=n.lencode[m&(1<<n.lenbits)-1])>>>16&255,k=65535&D,!((S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(T&&!(240&T)){for(O=S,R=T,C=k;T=(D=n.lencode[C+((m&(1<<O+R)-1)>>O)])>>>16&255,k=65535&D,!(O+(S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}m>>>=O,_-=O,n.back+=O}if(m>>>=S,_-=S,n.back+=S,n.length=k,0===T){n.mode=26;break}if(32&T){n.back=-1,n.mode=12;break}if(64&T){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&T,n.mode=22;case 22:if(n.extra){for(I=n.extra;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.length+=m&(1<<n.extra)-1,m>>>=n.extra,_-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;T=(D=n.distcode[m&(1<<n.distbits)-1])>>>16&255,k=65535&D,!((S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(!(240&T)){for(O=S,R=T,C=k;T=(D=n.distcode[C+((m&(1<<O+R)-1)>>O)])>>>16&255,k=65535&D,!(O+(S=D>>>24)<=_);){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}m>>>=O,_-=O,n.back+=O}if(m>>>=S,_-=S,n.back+=S,64&T){e.msg="invalid distance code",n.mode=30;break}n.offset=k,n.extra=15&T,n.mode=24;case 24:if(n.extra){for(I=n.extra;_<I;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}n.offset+=m&(1<<n.extra)-1,m>>>=n.extra,_-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===g)break e;if(w=x-g,n.offset>w){if((w=n.offset-w)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}A=w>n.wnext?(w-=n.wnext,n.wsize-w):n.wnext-w,w>n.length&&(w=n.length),E=n.window}else E=h,A=f-n.offset,w=n.length;for(g<w&&(w=g),g-=w,n.length-=w;h[f++]=E[A++],--w;);0===n.length&&(n.mode=21);break;case 26:if(0===g)break e;h[f++]=n.length,g--,n.mode=21;break;case 27:if(n.wrap){for(;_<32;){if(0===p)break e;p--,m|=c[d++]<<_,_+=8}if(x-=g,e.total_out+=x,n.total+=x,x&&(e.adler=n.check=n.flags?s(n.check,h,x,f-x):i(n.check,h,x,f-x)),x=g,(n.flags?m:u(m))!==n.check){e.msg="incorrect data check",n.mode=30;break}_=m=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;_<32;){if(0===p)break e;p--,m+=c[d++]<<_,_+=8}if(m!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}_=m=0}n.mode=29;case 29:M=1;break e;case 30:M=-3;break e;case 31:return-4;default:return l}return e.next_out=f,e.avail_out=g,e.next_in=d,e.avail_in=p,n.hold=m,n.bits=_,(n.wsize||x!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&v(e,e.output,e.next_out,x-e.avail_out)?(n.mode=31,-4):(b-=e.avail_in,x-=e.avail_out,e.total_in+=b,e.total_out+=x,n.total+=x,n.wrap&&x&&(e.adler=n.check=n.flags?s(n.check,h,x,e.next_out-x):i(n.check,h,x,e.next_out-x)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0==b&&0===x||4===t)&&0===M&&(M=-5),M)},n.inflateEnd=function(e){if(!e||!e.state)return l;var t=e.state;return t.window&&(t.window=null),e.state=null,0},n.inflateGetHeader=function(e,t){var n;return e&&e.state&&2&(n=e.state).wrap?((n.head=t).done=!1,0):l},n.inflateSetDictionary=function(e,t){var n,r=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?l:11===n.mode&&i(1,t,r,0)!==n.check?-3:v(e,t,r,r)?(n.mode=31,-4):(n.havedict=1,0):l},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,n){var r=e("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,l,u,c,h,d){var f,p,g,m,_,y,v,b,x,w=d.bits,A=0,E=0,S=0,T=0,k=0,O=0,R=0,C=0,P=0,M=0,N=null,I=0,D=new r.Buf16(16),F=new r.Buf16(16),z=null,L=0;for(A=0;A<=15;A++)D[A]=0;for(E=0;E<l;E++)D[t[n+E]]++;for(k=w,T=15;1<=T&&0===D[T];T--);if(T<k&&(k=T),0===T)return u[c++]=20971520,u[c++]=20971520,d.bits=1,0;for(S=1;S<T&&0===D[S];S++);for(k<S&&(k=S),A=C=1;A<=15;A++)if(C<<=1,(C-=D[A])<0)return-1;if(0<C&&(0===e||1!==T))return-1;for(F[1]=0,A=1;A<15;A++)F[A+1]=F[A]+D[A];for(E=0;E<l;E++)0!==t[n+E]&&(h[F[t[n+E]]++]=E);if(y=0===e?(N=z=h,19):1===e?(N=i,I-=257,z=s,L-=257,256):(N=o,z=a,-1),A=S,_=c,R=E=M=0,g=-1,m=(P=1<<(O=k))-1,1===e&&852<P||2===e&&592<P)return 1;for(;;){for(v=A-R,x=h[E]<y?(b=0,h[E]):h[E]>y?(b=z[L+h[E]],N[I+h[E]]):(b=96,0),f=1<<A-R,S=p=1<<O;u[_+(M>>R)+(p-=f)]=v<<24|b<<16|x,0!==p;);for(f=1<<A-1;M&f;)f>>=1;if(0!==f?(M&=f-1,M+=f):M=0,E++,0==--D[A]){if(A===T)break;A=t[n+h[E]]}if(k<A&&(M&m)!==g){for(0===R&&(R=k),_+=S,C=1<<(O=A-R);O+R<T&&!((C-=D[O+R])<=0);)O++,C<<=1;if(P+=1<<O,1===e&&852<P||2===e&&592<P)return 1;u[g=M&m]=k<<24|O<<16|_-c}}return 0!==M&&(u[_+M]=A-R<<24|64<<16),d.bits=k,0}},{"../utils/common":41}],51:[function(e,t,n){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,n){var r=e("../utils/common");function i(e){for(var t=e.length;0<=--t;)e[t]=0}var s=256,o=286,a=30,l=15,u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],c=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],d=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],f=new Array(576);i(f);var p=new Array(60);i(p);var g=new Array(512);i(g);var m=new Array(256);i(m);var _=new Array(29);i(_);var y,v,b,x=new Array(a);function w(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}function A(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function E(e){return e<256?g[e]:g[256+(e>>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function T(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,S(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function k(e,t,n){T(e,n[2*t],n[2*t+1])}function O(e,t){for(var n=0;n|=1&e,e>>>=1,n<<=1,0<--t;);return n>>>1}function R(e,t,n){var r,i,s=new Array(16),o=0;for(r=1;r<=l;r++)s[r]=o=o+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=O(s[a]++,a))}}function C(e){var t;for(t=0;t<o;t++)e.dyn_ltree[2*t]=0;for(t=0;t<a;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function P(e){8<e.bi_valid?S(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function M(e,t,n,r){var i=2*t,s=2*n;return e[i]<e[s]||e[i]===e[s]&&r[t]<=r[n]}function N(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&M(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!M(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function I(e,t,n){var r,i,o,a,l=0;if(0!==e.last_lit)for(;r=e.pending_buf[e.d_buf+2*l]<<8|e.pending_buf[e.d_buf+2*l+1],i=e.pending_buf[e.l_buf+l],l++,0===r?k(e,i,t):(k(e,(o=m[i])+s+1,t),0!==(a=u[o])&&T(e,i-=_[o],a),k(e,o=E(--r),n),0!==(a=c[o])&&T(e,r-=x[o],a)),l<e.last_lit;);k(e,256,t)}function D(e,t){var n,r,i,s=t.dyn_tree,o=t.stat_desc.static_tree,a=t.stat_desc.has_stree,u=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=573,n=0;n<u;n++)0!==s[2*n]?(e.heap[++e.heap_len]=c=n,e.depth[n]=0):s[2*n+1]=0;for(;e.heap_len<2;)s[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,a&&(e.static_len-=o[2*i+1]);for(t.max_code=c,n=e.heap_len>>1;1<=n;n--)N(e,s,n);for(i=u;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],N(e,s,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,s[2*i]=s[2*n]+s[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,s[2*n+1]=s[2*r+1]=i,e.heap[1]=i++,N(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,s,o,a,u=t.dyn_tree,c=t.max_code,h=t.stat_desc.static_tree,d=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,g=t.stat_desc.max_length,m=0;for(s=0;s<=l;s++)e.bl_count[s]=0;for(u[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)g<(s=u[2*u[2*(r=e.heap[n])+1]+1]+1)&&(s=g,m++),u[2*r+1]=s,c<r||(e.bl_count[s]++,o=0,p<=r&&(o=f[r-p]),a=u[2*r],e.opt_len+=a*(s+o),d&&(e.static_len+=a*(h[2*r+1]+o)));if(0!==m){do{for(s=g-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[g]--,m-=2}while(0<m);for(s=g;0!==s;s--)for(r=e.bl_count[s];0!==r;)c<(i=e.heap[--n])||(u[2*i+1]!==s&&(e.opt_len+=(s-u[2*i+1])*u[2*i],u[2*i+1]=s),r--)}}(e,t),R(s,c,e.bl_count)}function F(e,t,n){var r,i,s=-1,o=t[1],a=0,l=7,u=4;for(0===o&&(l=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=o,o=t[2*(r+1)+1],++a<l&&i===o||(a<u?e.bl_tree[2*i]+=a:0!==i?(i!==s&&e.bl_tree[2*i]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=i,u=(a=0)===o?(l=138,3):i===o?(l=6,3):(l=7,4))}function z(e,t,n){var r,i,s=-1,o=t[1],a=0,l=7,u=4;for(0===o&&(l=138,u=3),r=0;r<=n;r++)if(i=o,o=t[2*(r+1)+1],!(++a<l&&i===o)){if(a<u)for(;k(e,i,e.bl_tree),0!=--a;);else 0!==i?(i!==s&&(k(e,i,e.bl_tree),a--),k(e,16,e.bl_tree),T(e,a-3,2)):a<=10?(k(e,17,e.bl_tree),T(e,a-3,3)):(k(e,18,e.bl_tree),T(e,a-11,7));s=i,u=(a=0)===o?(l=138,3):i===o?(l=6,3):(l=7,4)}}i(x);var L=!1;function j(e,t,n,i){T(e,0+(i?1:0),3),function(e,t,n){P(e),S(e,n),S(e,~n),r.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}(e,t,n)}n._tr_init=function(e){L||(function(){var e,t,n,r,i,s=new Array(16);for(r=n=0;r<28;r++)for(_[r]=n,e=0;e<1<<u[r];e++)m[n++]=r;for(m[n-1]=r,r=i=0;r<16;r++)for(x[r]=i,e=0;e<1<<c[r];e++)g[i++]=r;for(i>>=7;r<a;r++)for(x[r]=i<<7,e=0;e<1<<c[r]-7;e++)g[256+i++]=r;for(t=0;t<=l;t++)s[t]=0;for(e=0;e<=143;)f[2*e+1]=8,e++,s[8]++;for(;e<=255;)f[2*e+1]=9,e++,s[9]++;for(;e<=279;)f[2*e+1]=7,e++,s[7]++;for(;e<=287;)f[2*e+1]=8,e++,s[8]++;for(R(f,287,s),e=0;e<a;e++)p[2*e+1]=5,p[2*e]=O(e,5);y=new w(f,u,257,o,l),v=new w(p,c,0,a,l),b=new w(new Array(0),h,0,19,7)}(),L=!0),e.l_desc=new A(e.dyn_ltree,y),e.d_desc=new A(e.dyn_dtree,v),e.bl_desc=new A(e.bl_tree,b),e.bi_buf=0,e.bi_valid=0,C(e)},n._tr_stored_block=j,n._tr_flush_block=function(e,t,n,r){var i,o,a=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<s;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),D(e,e.l_desc),D(e,e.d_desc),a=function(e){var t;for(F(e,e.dyn_ltree,e.l_desc.max_code),F(e,e.dyn_dtree,e.d_desc.max_code),D(e,e.bl_desc),t=18;3<=t&&0===e.bl_tree[2*d[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?j(e,t,n,r):4===e.strategy||o===i?(T(e,2+(r?1:0),3),I(e,f,p)):(T(e,4+(r?1:0),3),function(e,t,n,r){var i;for(T(e,t-257,5),T(e,n-1,5),T(e,r-4,4),i=0;i<r;i++)T(e,e.bl_tree[2*d[i]+1],3);z(e,e.dyn_ltree,t-1),z(e,e.dyn_dtree,n-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),I(e,e.dyn_ltree,e.dyn_dtree)),C(e),r&&P(e)},n._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(m[n]+s+1)]++,e.dyn_dtree[2*E(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){T(e,2,3),k(e,256,f),function(e){16===e.bi_valid?(S(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(e){!function(e){if(!e.setImmediate){var t,n,r,i,s=1,o={},a=!1,l=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,t="[object process]"==={}.toString.call(e.process)?function(e){!function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];be.push(new Se(e,t)),1!==be.length||xe||ye(Ee)}(function(){h(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(i="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",d,!1):e.attachEvent("onmessage",d),function(t){e.postMessage(i+t,"*")}):e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){h(e.data)},function(e){r.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(n=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,n.removeChild(t),t=null},n.appendChild(t)}):function(e){setTimeout(h,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var n=new Array(arguments.length-1),r=0;r<n.length;r++)n[r]=arguments[r+1];var i={callback:e,args:n};return o[s]=i,t(s),s++},u.clearImmediate=c}function c(e){delete o[e]}function h(e){if(a)setTimeout(h,0,e);else{var t=o[e];if(t){a=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(undefined,n)}}(t)}finally{c(e),a=!1}}}}function d(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(i)&&h(+t.data.slice(i.length))}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,void 0!==f?f:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10)),lt.exports),ct=e.getDefaultExportFromCjs(ut),ht={},dt={},ft={};function pt(){if(Re)return ft;function e(e){return null==e}return Re=1,ft.isNothing=e,ft.isObject=function(e){return"object"==typeof e&&null!==e},ft.toArray=function(t){return Array.isArray(t)?t:e(t)?[]:[t]},ft.repeat=function(e,t){var n,r="";for(n=0;n<t;n+=1)r+=e;return r},ft.isNegativeZero=function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},ft.extend=function(e,t){var n,r,i,s;if(t)for(n=0,r=(s=Object.keys(t)).length;n<r;n+=1)e[i=s[n]]=t[i];return e},ft}function gt(){if(Pe)return Ce;function e(e,t){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||"",this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():"")}return Pe=1,e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(e){var t=this.name+": ";return t+=this.reason||"(unknown reason)",!e&&this.mark&&(t+=" "+this.mark.toString()),t},Ce=e}function mt(){if(De)return Ie;De=1;var e=gt(),t=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];return Ie=function(r,i){if(i=i||{},Object.keys(i).forEach(function(n){if(-1===t.indexOf(n))throw new e('Unknown option "'+n+'" is met in definition of "'+r+'" YAML type.')}),this.tag=r,this.kind=i.kind||null,this.resolve=i.resolve||function(){return!0},this.construct=i.construct||function(e){return e},this.instanceOf=i.instanceOf||null,this.predicate=i.predicate||null,this.represent=i.represent||null,this.defaultStyle=i.defaultStyle||null,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}(i.styleAliases||null),-1===n.indexOf(this.kind))throw new e('Unknown kind "'+this.kind+'" is specified for "'+r+'" YAML type.')},Ie}function _t(){if(ze)return Fe;ze=1;var e=pt(),t=gt(),n=mt();function r(e,t,n){var i=[];return e.include.forEach(function(e){n=r(e,t,n)}),e[t].forEach(function(e){n.forEach(function(t,n){t.tag===e.tag&&i.push(n)}),n.push(e)}),n.filter(function(e,t){return-1===i.indexOf(t)})}function i(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new t("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=r(this,"implicit",[]),this.compiledExplicit=r(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,n={};function r(e){n[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(r);return n}(this.compiledImplicit,this.compiledExplicit)}return i.DEFAULT=null,i.create=function(){var r,s;switch(arguments.length){case 1:r=i.DEFAULT,s=arguments[0];break;case 2:r=arguments[0],s=arguments[1];break;default:throw new t("Wrong number of arguments for Schema.create function")}if(r=e.toArray(r),s=e.toArray(s),!r.every(function(e){return e instanceof i}))throw new t("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!s.every(function(e){return e instanceof n}))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new i({include:r,explicit:s})},Fe=i}function yt(){if(je)return Le;je=1;var e=mt();return Le=new e("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}})}function vt(){if(Ue)return Ve;Ue=1;var e=mt();return Ve=new e("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}})}function bt(){if(Ge)return Be;Ge=1;var e=mt();return Be=new e("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})}function xt(){if(qe)return $e;qe=1;var e=_t();return $e=new e({explicit:[yt(),vt(),bt()]})}function wt(){if(We)return He;We=1;var e=mt();return He=new e("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})}function At(){if(Ke)return Ze;Ke=1;var e=mt();return Ze=new e("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})}function Et(){if(Ye)return Xe;Ye=1;var e=pt(),t=mt();function n(e){return 48<=e&&e<=55}function r(e){return 48<=e&&e<=57}return Xe=new t("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,i,s=e.length,o=0,a=!1;if(!s)return!1;if("-"!==(t=e[o])&&"+"!==t||(t=e[++o]),"0"===t){if(o+1===s)return!0;if("b"===(t=e[++o])){for(o++;o<s;o++)if("_"!==(t=e[o])){if("0"!==t&&"1"!==t)return!1;a=!0}return a}if("x"===t){for(o++;o<s;o++)if("_"!==(t=e[o])){if(!(48<=(i=e.charCodeAt(o))&&i<=57||65<=i&&i<=70||97<=i&&i<=102))return!1;a=!0}return a}for(;o<s;o++)if("_"!==(t=e[o])){if(!n(e.charCodeAt(o)))return!1;a=!0}return a}for(;o<s;o++)if("_"!==(t=e[o])){if(":"===t)break;if(!r(e.charCodeAt(o)))return!1;a=!0}return!!a&&(":"!==t||/^(:[0-5]?[0-9])+$/.test(e.slice(o)))},construct:function(e){var t,n,r=e,i=1,s=[];return-1!==r.indexOf("_")&&(r=r.replace(/_/g,"")),"-"!==(t=r[0])&&"+"!==t||("-"===t&&(i=-1),t=(r=r.slice(1))[0]),"0"===r?0:"0"===t?"b"===r[1]?i*parseInt(r.slice(2),2):"x"===r[1]?i*parseInt(r,16):i*parseInt(r,8):-1!==r.indexOf(":")?(r.split(":").forEach(function(e){s.unshift(parseInt(e,10))}),r=0,n=1,s.forEach(function(e){r+=e*n,n*=60}),i*r):i*parseInt(r,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&t%1==0&&!e.isNegativeZero(t)},represent:{binary:function(e){return"0b"+e.toString(2)},octal:function(e){return"0"+e.toString(8)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return"0x"+e.toString(16).toUpperCase()}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Xe}function St(){if(Je)return Qe;Je=1;var e=pt(),t=mt(),n=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?|\\.[0-9_]+(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=/^[-+]?[0-9]+e/;return Qe=new t("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!!n.test(e)},construct:function(e){var t,n,r,i;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,i=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:t.indexOf(":")>=0?(t.split(":").forEach(function(e){i.unshift(parseFloat(e,10))}),t=0,r=1,i.forEach(function(e){t+=e*r,r*=60}),n*t):n*parseFloat(t,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||e.isNegativeZero(t))},represent:function(t,n){var i;if(isNaN(t))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(e.isNegativeZero(t))return"-0.0";return i=t.toString(10),r.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"})}function Tt(){if(tt)return et;tt=1;var e=_t();return et=new e({include:[xt()],implicit:[wt(),At(),Et(),St()]})}function kt(){if(rt)return nt;rt=1;var e=_t();return nt=new e({include:[Tt()]})}function Ot(){if(st)return it;st=1;var e=mt(),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$");return it=new e("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&null!==t.exec(e)},construct:function(e){var n,r,i,s,o,a,l,u,c=0,h=null;if(null===(n=t.exec(e)))throw new Error("Date resolve error");if(r=+n[1],i=+n[2]-1,s=+n[3],!n[4])return new Date(Date.UTC(r,i,s));if(o=+n[4],a=+n[5],l=+n[6],n[7]){for(c=n[7].slice(0,3);c.length<3;)c+="0";c=+c}return n[9]&&(h=6e4*(60*+n[10]+ +(n[11]||0)),"-"===n[9]&&(h=-h)),u=new Date(Date.UTC(r,i,s,o,a,l,c)),h&&u.setTime(u.getTime()-h),u},instanceOf:Date,represent:function(e){return e.toISOString()}})}function Rt(){if(at)return ot;at=1;var e=mt();return ot=new e("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}})}var Ct,Pt,Mt,Nt,It,Dt,Ft,zt,Lt,jt,Vt,Ut,Bt,Gt,$t,qt,Ht,Wt,Zt,Kt,Xt,Yt,Qt=e.getAugmentedNamespace(fe);function Jt(){if(Pt)return Ct;Pt=1;var e=Qt.Buffer,t=mt(),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";return Ct=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,r,i=0,s=e.length,o=n;for(r=0;r<s;r++)if(!((t=o.indexOf(e.charAt(r)))>64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(t){var r,i,s=t.replace(/[\r\n=]/g,""),o=s.length,a=n,l=0,u=[];for(r=0;r<o;r++)r%4==0&&r&&(u.push(l>>16&255),u.push(l>>8&255),u.push(255&l)),l=l<<6|a.indexOf(s.charAt(r));return 0==(i=o%4*6)?(u.push(l>>16&255),u.push(l>>8&255),u.push(255&l)):18===i?(u.push(l>>10&255),u.push(l>>2&255)):12===i&&u.push(l>>4&255),e?new e(u):u},predicate:function(t){return e&&e.isBuffer(t)},represent:function(e){var t,r,i="",s=0,o=e.length,a=n;for(t=0;t<o;t++)t%3==0&&t&&(i+=a[s>>18&63],i+=a[s>>12&63],i+=a[s>>6&63],i+=a[63&s]),s=(s<<8)+e[t];return 0==(r=o%3)?(i+=a[s>>18&63],i+=a[s>>12&63],i+=a[s>>6&63],i+=a[63&s]):2===r?(i+=a[s>>10&63],i+=a[s>>4&63],i+=a[s<<2&63],i+=a[64]):1===r&&(i+=a[s>>2&63],i+=a[s<<4&63],i+=a[64],i+=a[64]),i}}),Ct}function en(){if(Nt)return Mt;Nt=1;var e=mt(),t=Object.prototype.hasOwnProperty,n=Object.prototype.toString;return Mt=new e("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var r,i,s,o,a,l=[],u=e;for(r=0,i=u.length;r<i;r+=1){if(s=u[r],a=!1,"[object Object]"!==n.call(s))return!1;for(o in s)if(t.call(s,o)){if(a)return!1;a=!0}if(!a)return!1;if(-1!==l.indexOf(o))return!1;l.push(o)}return!0},construct:function(e){return null!==e?e:[]}}),Mt}function tn(){if(Dt)return It;Dt=1;var e=mt(),t=Object.prototype.toString;return It=new e("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;var n,r,i,s,o,a=e;for(o=new Array(a.length),n=0,r=a.length;n<r;n+=1){if(i=a[n],"[object Object]"!==t.call(i))return!1;if(1!==(s=Object.keys(i)).length)return!1;o[n]=[s[0],i[s[0]]]}return!0},construct:function(e){if(null===e)return[];var t,n,r,i,s,o=e;for(s=new Array(o.length),t=0,n=o.length;t<n;t+=1)r=o[t],i=Object.keys(r),s[t]=[i[0],r[i[0]]];return s}}),It}function nn(){if(zt)return Ft;zt=1;var e=mt(),t=Object.prototype.hasOwnProperty;return Ft=new e("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;var n,r=e;for(n in r)if(t.call(r,n)&&null!==r[n])return!1;return!0},construct:function(e){return null!==e?e:{}}})}function rn(){if(jt)return Lt;jt=1;var e=_t();return Lt=new e({include:[kt()],implicit:[Ot(),Rt()],explicit:[Jt(),en(),tn(),nn()]})}function sn(){if(Ut)return Vt;Ut=1;var e=mt();return Vt=new e("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:function(){return!0},construct:function(){},predicate:function(e){return void 0===e},represent:function(){return""}})}function on(){if(Gt)return Bt;Gt=1;var e=mt();return Bt=new e("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:function(e){if(null===e)return!1;if(0===e.length)return!1;var t=e,n=/\/([gim]*)$/.exec(e),r="";if("/"===t[0]){if(n&&(r=n[1]),r.length>3)return!1;if("/"!==t[t.length-r.length-1])return!1}return!0},construct:function(e){var t=e,n=/\/([gim]*)$/.exec(e),r="";return"/"===t[0]&&(n&&(r=n[1]),t=t.slice(1,t.length-r.length-1)),new RegExp(t,r)},predicate:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},represent:function(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}})}function an(){if(qt)return $t;var e;qt=1;try{e=ke("esprima")}catch(t){"undefined"!=typeof window&&(e=window.esprima)}var t=mt();return $t=new t("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:function(t){if(null===t)return!1;try{var n="("+t+")",r=e.parse(n,{range:!0});return"Program"===r.type&&1===r.body.length&&"ExpressionStatement"===r.body[0].type&&"FunctionExpression"===r.body[0].expression.type}catch(e){return!1}},construct:function(t){var n,r="("+t+")",i=e.parse(r,{range:!0}),s=[];if("Program"!==i.type||1!==i.body.length||"ExpressionStatement"!==i.body[0].type||"FunctionExpression"!==i.body[0].expression.type)throw new Error("Failed to resolve function");return i.body[0].expression.params.forEach(function(e){s.push(e.name)}),n=i.body[0].expression.body.range,new Function(s,r.slice(n[0]+1,n[1]-1))},predicate:function(e){return"[object Function]"===Object.prototype.toString.call(e)},represent:function(e){return e.toString()}})}function ln(){if(Wt)return Ht;Wt=1;var e=_t();return Ht=e.DEFAULT=new e({include:[rn()],explicit:[sn(),on(),an()]})}var un=function(){if(Yt)return Xt;Yt=1;var e=function(){if(Kt)return ht;Kt=1;var e=function(){if(Zt)return dt;Zt=1;var e=pt(),t=gt(),n=function(){if(Ne)return Me;Ne=1;var e=pt();function t(e,t,n,r,i){this.name=e,this.buffer=t,this.position=n,this.line=r,this.column=i}return t.prototype.getSnippet=function(t,n){var r,i,s,o,a;if(!this.buffer)return null;for(t=t||4,n=n||75,r="",i=this.position;i>0&&-1==="\0\r\n
\u2028\u2029".indexOf(this.buffer.charAt(i-1));)if(i-=1,this.position-i>n/2-1){r=" ... ",i+=5;break}for(s="",o=this.position;o<this.buffer.length&&-1==="\0\r\n
\u2028\u2029".indexOf(this.buffer.charAt(o));)if((o+=1)-this.position>n/2-1){s=" ... ",o-=5;break}return a=this.buffer.slice(i,o),e.repeat(" ",t)+r+a+s+"\n"+e.repeat(" ",t+this.position-i+r.length)+"^"},t.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},Me=t}(),r=rn(),i=ln(),s=Object.prototype.hasOwnProperty,o=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,a=/[\x85\u2028\u2029]/,l=/[,\[\]\{\}]/,u=/^(?:!|!!|![a-z\-]+!)$/i,c=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function h(e){return 10===e||13===e}function d(e){return 9===e||32===e}function f(e){return 9===e||32===e||10===e||13===e}function p(e){return 44===e||91===e||93===e||123===e||125===e}function g(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function m(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"
":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function _(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var y=new Array(256),v=new Array(256),b=0;b<256;b++)y[b]=m(b)?1:0,v[b]=m(b);function x(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||i,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function w(e,r){return new t(r,new n(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function A(e,t){throw w(e,t)}function E(e,t){e.onWarning&&e.onWarning.call(null,w(e,t))}var S={YAML:function(e,t,n){var r,i,s;null!==e.version&&A(e,"duplication of %YAML directive"),1!==n.length&&A(e,"YAML directive accepts exactly one argument"),null===(r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&A(e,"ill-formed argument of the YAML directive"),i=parseInt(r[1],10),s=parseInt(r[2],10),1!==i&&A(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=s<2,1!==s&&2!==s&&E(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var r,i;2!==n.length&&A(e,"TAG directive accepts exactly two arguments"),r=n[0],i=n[1],u.test(r)||A(e,"ill-formed tag handle (first argument) of the TAG directive"),s.call(e.tagMap,r)&&A(e,'there is a previously declared suffix for "'+r+'" tag handle'),c.test(i)||A(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagMap[r]=i}};function T(e,t,n,r){var i,s,a,l;if(t<n){if(l=e.input.slice(t,n),r)for(i=0,s=l.length;i<s;i+=1)9===(a=l.charCodeAt(i))||32<=a&&a<=1114111||A(e,"expected valid JSON character");else o.test(l)&&A(e,"the stream contains non-printable characters");e.result+=l}}function k(t,n,r,i){var o,a,l,u;for(e.isObject(r)||A(t,"cannot merge mappings; the provided source object is unacceptable"),l=0,u=(o=Object.keys(r)).length;l<u;l+=1)a=o[l],s.call(n,a)||(n[a]=r[a],i[a]=!0)}function O(e,t,n,r,i,o){var a,l;if(i=String(i),null===t&&(t={}),"tag:yaml.org,2002:merge"===r)if(Array.isArray(o))for(a=0,l=o.length;a<l;a+=1)k(e,t,o[a],n);else k(e,t,o,n);else e.json||s.call(n,i)||!s.call(t,i)||A(e,"duplicated mapping key"),t[i]=o,delete n[i];return t}function R(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):A(e,"a line break is expected"),e.line+=1,e.lineStart=e.position}function C(e,t,n){for(var r=0,i=e.input.charCodeAt(e.position);0!==i;){for(;d(i);)i=e.input.charCodeAt(++e.position);if(t&&35===i)do{i=e.input.charCodeAt(++e.position)}while(10!==i&&13!==i&&0!==i);if(!h(i))break;for(R(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;32===i;)e.lineIndent++,i=e.input.charCodeAt(++e.position)}return-1!==n&&0!==r&&e.lineIndent<n&&E(e,"deficient indentation"),r}function P(e){var t,n=e.position;return!(45!==(t=e.input.charCodeAt(n))&&46!==t||t!==e.input.charCodeAt(n+1)||t!==e.input.charCodeAt(n+2)||(n+=3,0!==(t=e.input.charCodeAt(n))&&!f(t)))}function M(t,n){1===n?t.result+=" ":n>1&&(t.result+=e.repeat("\n",n-1))}function N(e,t){var n,r,i=e.tag,s=e.anchor,o=[],a=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=o),r=e.input.charCodeAt(e.position);0!==r&&45===r&&f(e.input.charCodeAt(e.position+1));)if(a=!0,e.position++,C(e,!0,-1)&&e.lineIndent<=t)o.push(null),r=e.input.charCodeAt(e.position);else if(n=e.line,F(e,t,3,!1,!0),o.push(e.result),C(e,!0,-1),r=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==r)A(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return!!a&&(e.tag=i,e.anchor=s,e.kind="sequence",e.result=o,!0)}function I(e){var t,n,r,i,o=!1,a=!1;if(33!==(i=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&A(e,"duplication of a tag property"),60===(i=e.input.charCodeAt(++e.position))?(o=!0,i=e.input.charCodeAt(++e.position)):33===i?(a=!0,n="!!",i=e.input.charCodeAt(++e.position)):n="!",t=e.position,o){do{i=e.input.charCodeAt(++e.position)}while(0!==i&&62!==i);e.position<e.length?(r=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):A(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==i&&!f(i);)33===i&&(a?A(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),u.test(n)||A(e,"named tag handle cannot contain such characters"),a=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);r=e.input.slice(t,e.position),l.test(r)&&A(e,"tag suffix cannot contain flow indicator characters")}return r&&!c.test(r)&&A(e,"tag name cannot contain such characters: "+r),o?e.tag=r:s.call(e.tagMap,n)?e.tag=e.tagMap[n]+r:"!"===n?e.tag="!"+r:"!!"===n?e.tag="tag:yaml.org,2002:"+r:A(e,'undeclared tag handle "'+n+'"'),!0}function D(e){var t,n;if(38!==(n=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&A(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!f(n)&&!p(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&A(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function F(t,n,r,i,o){var a,l,u,c,m,b,x,w,E=1,S=!1,k=!1;if(null!==t.listener&&t.listener("open",t),t.tag=null,t.anchor=null,t.kind=null,t.result=null,a=l=u=4===r||3===r,i&&C(t,!0,-1)&&(S=!0,t.lineIndent>n?E=1:t.lineIndent===n?E=0:t.lineIndent<n&&(E=-1)),1===E)for(;I(t)||D(t);)C(t,!0,-1)?(S=!0,u=a,t.lineIndent>n?E=1:t.lineIndent===n?E=0:t.lineIndent<n&&(E=-1)):u=!1;if(u&&(u=S||o),1!==E&&4!==r||(x=1===r||2===r?n:n+1,w=t.position-t.lineStart,1===E?u&&(N(t,w)||function(e,t,n){var r,i,s,o,a=e.tag,l=e.anchor,u={},c={},h=null,p=null,g=null,m=!1,_=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=u),o=e.input.charCodeAt(e.position);0!==o;){if(r=e.input.charCodeAt(e.position+1),s=e.line,63!==o&&58!==o||!f(r)){if(!F(e,n,2,!1,!0))break;if(e.line===s){for(o=e.input.charCodeAt(e.position);d(o);)o=e.input.charCodeAt(++e.position);if(58===o)f(o=e.input.charCodeAt(++e.position))||A(e,"a whitespace character is expected after the key-value separator within a block mapping"),m&&(O(e,u,c,h,p,null),h=p=g=null),_=!0,m=!1,i=!1,h=e.tag,p=e.result;else{if(!_)return e.tag=a,e.anchor=l,!0;A(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!_)return e.tag=a,e.anchor=l,!0;A(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===o?(m&&(O(e,u,c,h,p,null),h=p=g=null),_=!0,m=!0,i=!0):m?(m=!1,i=!0):A(e,"incomplete explicit mapping pair; a key node is missed"),e.position+=1,o=r;if((e.line===s||e.lineIndent>t)&&(F(e,t,4,!0,i)&&(m?p=e.result:g=e.result),m||(O(e,u,c,h,p,g),h=p=g=null),C(e,!0,-1),o=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==o)A(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return m&&O(e,u,c,h,p,null),_&&(e.tag=a,e.anchor=l,e.kind="mapping",e.result=u),_}(t,w,x))||function(e,t){var n,r,i,s,o,a,l,u,c,h,d=!0,p=e.tag,g=e.anchor,m={};if(91===(h=e.input.charCodeAt(e.position)))i=93,a=!1,r=[];else{if(123!==h)return!1;i=125,a=!0,r={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=r),h=e.input.charCodeAt(++e.position);0!==h;){if(C(e,!0,t),(h=e.input.charCodeAt(e.position))===i)return e.position++,e.tag=p,e.anchor=g,e.kind=a?"mapping":"sequence",e.result=r,!0;d||A(e,"missed comma between flow collection entries"),c=null,s=o=!1,63===h&&f(e.input.charCodeAt(e.position+1))&&(s=o=!0,e.position++,C(e,!0,t)),n=e.line,F(e,t,1,!1,!0),u=e.tag,l=e.result,C(e,!0,t),h=e.input.charCodeAt(e.position),!o&&e.line!==n||58!==h||(s=!0,h=e.input.charCodeAt(++e.position),C(e,!0,t),F(e,t,1,!1,!0),c=e.result),a?O(e,r,m,u,l,c):s?r.push(O(e,null,m,u,l,c)):r.push(l),C(e,!0,t),44===(h=e.input.charCodeAt(e.position))?(d=!0,h=e.input.charCodeAt(++e.position)):d=!1}A(e,"unexpected end of the stream within a flow collection")}(t,x)?k=!0:(l&&function(t,n){var r,i,s,o,a,l=1,u=!1,c=n,f=0,p=!1;if(124===(o=t.input.charCodeAt(t.position)))i=!1;else{if(62!==o)return!1;i=!0}for(t.kind="scalar",t.result="";0!==o;)if(43===(o=t.input.charCodeAt(++t.position))||45===o)1===l?l=43===o?3:2:A(t,"repeat of a chomping mode identifier");else{if(!((s=48<=(a=o)&&a<=57?a-48:-1)>=0))break;0===s?A(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):u?A(t,"repeat of an indentation width identifier"):(c=n+s-1,u=!0)}if(d(o)){do{o=t.input.charCodeAt(++t.position)}while(d(o));if(35===o)do{o=t.input.charCodeAt(++t.position)}while(!h(o)&&0!==o)}for(;0!==o;){for(R(t),t.lineIndent=0,o=t.input.charCodeAt(t.position);(!u||t.lineIndent<c)&&32===o;)t.lineIndent++,o=t.input.charCodeAt(++t.position);if(!u&&t.lineIndent>c&&(c=t.lineIndent),h(o))f++;else{if(t.lineIndent<c){3===l?t.result+=e.repeat("\n",f):1===l&&u&&(t.result+="\n");break}for(i?d(o)?(p=!0,t.result+=e.repeat("\n",f+1)):p?(p=!1,t.result+=e.repeat("\n",f+1)):0===f?u&&(t.result+=" "):t.result+=e.repeat("\n",f):t.result+=u?e.repeat("\n",f+1):e.repeat("\n",f),u=!0,f=0,r=t.position;!h(o)&&0!==o;)o=t.input.charCodeAt(++t.position);T(t,r,t.position,!1)}}return!0}(t,x)||function(e,t){var n,r,i;if(39!==(n=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(T(e,r,e.position,!0),39!==(n=e.input.charCodeAt(++e.position)))return!0;r=i=e.position,e.position++}else h(n)?(T(e,r,i,!0),M(e,C(e,!1,t)),r=i=e.position):e.position===e.lineStart&&P(e)?A(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);A(e,"unexpected end of the stream within a single quoted scalar")}(t,x)||function(e,t){var n,r,i,s,o,a,l;if(34!==(a=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;0!==(a=e.input.charCodeAt(e.position));){if(34===a)return T(e,n,e.position,!0),e.position++,!0;if(92===a){if(T(e,n,e.position,!0),h(a=e.input.charCodeAt(++e.position)))C(e,!1,t);else if(a<256&&y[a])e.result+=v[a],e.position++;else if((o=120===(l=a)?2:117===l?4:85===l?8:0)>0){for(i=o,s=0;i>0;i--)(o=g(a=e.input.charCodeAt(++e.position)))>=0?s=(s<<4)+o:A(e,"expected hexadecimal character");e.result+=_(s),e.position++}else A(e,"unknown escape sequence");n=r=e.position}else h(a)?(T(e,n,r,!0),M(e,C(e,!1,t)),n=r=e.position):e.position===e.lineStart&&P(e)?A(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}A(e,"unexpected end of the stream within a double quoted scalar")}(t,x)?k=!0:function(e){var t,n,r;if(42!==(r=e.input.charCodeAt(e.position)))return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!f(r)&&!p(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&A(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),e.anchorMap.hasOwnProperty(n)||A(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],C(e,!0,-1),!0}(t)?(k=!0,null===t.tag&&null===t.anchor||A(t,"alias node should not have any properties")):function(e,t,n){var r,i,s,o,a,l,u,c,g=e.kind,m=e.result;if(f(c=e.input.charCodeAt(e.position))||p(c)||35===c||38===c||42===c||33===c||124===c||62===c||39===c||34===c||37===c||64===c||96===c)return!1;if((63===c||45===c)&&(f(r=e.input.charCodeAt(e.position+1))||n&&p(r)))return!1;for(e.kind="scalar",e.result="",i=s=e.position,o=!1;0!==c;){if(58===c){if(f(r=e.input.charCodeAt(e.position+1))||n&&p(r))break}else if(35===c){if(f(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&P(e)||n&&p(c))break;if(h(c)){if(a=e.line,l=e.lineStart,u=e.lineIndent,C(e,!1,-1),e.lineIndent>=t){o=!0,c=e.input.charCodeAt(e.position);continue}e.position=s,e.line=a,e.lineStart=l,e.lineIndent=u;break}}o&&(T(e,i,s,!1),M(e,e.line-a),i=s=e.position,o=!1),d(c)||(s=e.position+1),c=e.input.charCodeAt(++e.position)}return T(e,i,s,!1),!!e.result||(e.kind=g,e.result=m,!1)}(t,x,1===r)&&(k=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===E&&(k=u&&N(t,w))),null!==t.tag&&"!"!==t.tag)if("?"===t.tag){for(c=0,m=t.implicitTypes.length;c<m;c+=1)if((b=t.implicitTypes[c]).resolve(t.result)){t.result=b.construct(t.result),t.tag=b.tag,null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);break}}else s.call(t.typeMap,t.tag)?(b=t.typeMap[t.tag],null!==t.result&&b.kind!==t.kind&&A(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+b.kind+'", not "'+t.kind+'"'),b.resolve(t.result)?(t.result=b.construct(t.result),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):A(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")):A(t,"unknown tag !<"+t.tag+">");return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||k}function z(e){var t,n,r,i,o=e.position,l=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(i=e.input.charCodeAt(e.position))&&(C(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==i));){for(l=!0,i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!f(i);)i=e.input.charCodeAt(++e.position);for(r=[],(n=e.input.slice(t,e.position)).length<1&&A(e,"directive name must not be less than one character in length");0!==i;){for(;d(i);)i=e.input.charCodeAt(++e.position);if(35===i){do{i=e.input.charCodeAt(++e.position)}while(0!==i&&!h(i));break}if(h(i))break;for(t=e.position;0!==i&&!f(i);)i=e.input.charCodeAt(++e.position);r.push(e.input.slice(t,e.position))}0!==i&&R(e),s.call(S,n)?S[n](e,n,r):E(e,'unknown document directive "'+n+'"')}C(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,C(e,!0,-1)):l&&A(e,"directives end mark is expected"),F(e,e.lineIndent-1,4,!1,!0),C(e,!0,-1),e.checkLineBreaks&&a.test(e.input.slice(o,e.position))&&E(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&P(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,C(e,!0,-1)):e.position<e.length-1&&A(e,"end of the stream or a document separator is expected")}function L(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new x(e,t);for(n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)z(n);return n.documents}function j(e,t,n){var r,i,s=L(e,n);for(r=0,i=s.length;r<i;r+=1)t(s[r])}function V(e,n){var r=L(e,n);if(0!==r.length){if(1===r.length)return r[0];throw new t("expected a single document in the stream, but found more")}}return dt.loadAll=j,dt.load=V,dt.safeLoadAll=function(t,n,i){j(t,n,e.extend({schema:r},i))},dt.safeLoad=function(t,n){return V(t,e.extend({schema:r},n))},dt}();function t(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}return ht.Type=mt(),ht.Schema=_t(),ht.FAILSAFE_SCHEMA=xt(),ht.JSON_SCHEMA=Tt(),ht.CORE_SCHEMA=kt(),ht.DEFAULT_SAFE_SCHEMA=rn(),ht.DEFAULT_FULL_SCHEMA=ln(),ht.load=e.load,ht.loadAll=e.loadAll,ht.safeLoad=e.safeLoad,ht.safeLoadAll=e.safeLoadAll,ht.YAMLException=gt(),ht.MINIMAL_SCHEMA=xt(),ht.SAFE_SCHEMA=rn(),ht.DEFAULT_SCHEMA=ln(),ht.scan=t("scan"),ht.parse=t("parse"),ht.compose=t("compose"),ht.addConstructor=t("addConstructor"),ht}();return Xt=e}(),cn=e.getDefaultExportFromCjs(un);class hn{constructor(t,n,r=null){this.url=t,!n||e.isRelativeURL(n)&&!e.isRelativeURL(this.url)?this.path=e.pathForURL(this.url):this.path=n,this.path_for_parent=n||this.path,this.parent=r,this.container=null,this.parent&&(this.parent.container?this.container=this.parent.container:this.parent.isContainer()&&(this.container=this.parent))}load(){return fn(this.url)}resourceFor(e){return{url:this.urlFor(e),path:this.pathFor(e),type:this.typeFor(e)}}urlFor(t){return u(t)?t:e.isRelativeURL(t)&&this.container?this.parent.urlFor(this.path_for_parent+t):e.addBaseURL(t,this.path)}pathFor(t){return e.pathForURL(t)}typeFor(t){return e.extensionForURL(t)}isContainer(){return!1}}class dn extends hn{constructor(e,t,n){super(e,t,n),this.zip=null,this.files={},this.root=null,this.path=""}isContainer(){return!0}async load(){if(this.zip=new ct,"string"==typeof this.url){const{body:t}=await e.Utils.io(this.url,6e4,"arraybuffer");return await this.zip.loadAsync(t),await this.parseZipFiles(),this.loadRoot()}return this}urlFor(t){return u(t)?t:e.isRelativeURL(t)?this.urlForZipFile(e.flattenRelativeURL(t)):super.urlFor(t)}typeFor(t){return e.isRelativeURL(t)?this.typeForZipFile(t):super.typeFor(t)}loadRoot(){return this.findRoot(),fn(this.urlForZipFile(this.root))}findRoot(){const t=Object.keys(this.files).filter(e=>0===this.files[e].depth).filter(t=>"yaml"===e.extensionForURL(t));if(1===t.length&&(this.root=t[0]),!this.root){let e=`Could not find root scene for bundle '${this.url}': `;throw e+="The zip archive's root level must contain a single scene file with the '.yaml' extension. ",t.length>0?e+=`Found multiple YAML files at the root level: ${t.map(e=>"'"+e+"'").join(", ")}.`:e+="Found NO YAML files at the root level.",Error(e)}}async parseZipFiles(){let t=[],n=[];this.zip.forEach((e,r)=>{r.dir||(t.push(e),n.push(r.async("arraybuffer")))});const r=await Promise.all(n);for(let n=0;n<r.length;n++){let i=t[n],s=i.split("/").length-1;this.files[i]={data:r[n],type:e.extensionForURL(i),depth:s}}}urlForZipFile(t){if(this.files[t])return this.files[t].url||(this.files[t].url=e.createObjectURL(new Blob([this.files[t].data]))),this.files[t].url}typeForZipFile(e){return this.files[e]&&this.files[e].type}}function fn(t){return new Promise((n,r)=>{"string"==typeof t?e.Utils.io(t).then(({body:e})=>{try{n(function(e){return cn.safeLoad(e,{json:!0})}(e))}catch(e){r(e)}},r):(t=Object.assign({},t),n(t))})}const pn={async loadScene(t,{path:n,type:r}={}){const i=[],s={},o=await this.loadSceneRecursive({url:t,path:n,type:r},null,s,i),{config:a,bundle:l}=this.finalize(o);if(!a)throw i[0];return i.length>0&&i.forEach(t=>{const n=`Failed to import scene: ${t.url}`;e.log("error",n,t),this.trigger("error",{type:"scene_import",message:n,error:t,url:t.url})}),{config:a,bundle:l,texture_nodes:s}},async loadSceneRecursive({url:t,path:n,type:r},i,s={},o=[]){if(!t)return{};const a=function(t,n,r,i=null){return null!=i&&"zip"===i||"string"==typeof t&&!e.isLocalURL(t)&&"zip"===e.extensionForURL(t)?new dn(t,n,r):new hn(t,n,r)}(t,n,i,r);try{let t=await a.load();if(null==t.import)return this.normalize(t,a,s),{config:t,bundle:a};Array.isArray(t.import)||(t.import=[t.import]);const n=[];t.import.forEach(t=>{"object"==typeof t&&(t=e.createObjectURL(new Blob([JSON.stringify(t)]))),n.push(a.resourceFor(t))}),delete t.import;const r=n.map(e=>this.loadSceneRecursive(e,a,s,o)),i=(await Promise.all(r)).map(e=>this.normalize(e.config,e.bundle,s)).map(e=>e.config);return this.normalize(t,a,s),t=e.mergeObjects(...i,t),{config:t,bundle:a,texture_nodes:s}}catch(e){return e.url=t,o.push(e),{}}},normalize(e,t,n={}){return this.normalizeDataSources(e,t),this.normalizeFonts(e,t),this.normalizeTextures(e,t),this.collectTextures(e,t,n),{config:e,bundle:t,texture_nodes:n}},normalizeDataSources(e,t){e.sources=e.sources||{};for(const n in e.sources)this.normalizeDataSource(e.sources[n],t);return e},normalizeDataSource(e,t){if(e.url=t.urlFor(e.url),Array.isArray(e.composite)&&e.composite.forEach(e=>e.url=t.urlFor(e.url)),e.scripts){Array.isArray(e.scripts)&&(e.scripts=e.scripts.reduce((e,t)=>(e[t]=t,e),{}));for(const n in e.scripts)e.scripts[n]=t.urlFor(e.scripts[n])}return e},normalizeFonts(e,t){e.fonts=e.fonts||{};const n=Object.values(e.fonts).filter(e=>"external"!==e);for(const e of n)(Array.isArray(e)?e:[e]).forEach(e=>e.url=t.urlFor(e.url));return e},normalizeTextures(e,t){if(e.textures=e.textures||{},e.textures)for(const n in e.textures){const r=e.textures[n];r.url&&(r.url=t.urlFor(r.url))}},collectTextures(t,n,r){if(t.styles)for(const e in t.styles){const i=t.styles[e],s=i.texture;if("string"==typeof s&&!t.textures[s]){const t=["styles",e,"texture"];this.addTextureNode(t,n,r)}i.material&&["emission","ambient","diffuse","specular","normal"].forEach(s=>{const o=null!=i.material[s]&&i.material[s].texture;if("string"==typeof o&&!t.textures[o]){const t=["styles",e,"material",s,"texture"];this.addTextureNode(t,n,r)}})}if(t.styles)for(const i in t.styles){const s=t.styles[i];s.shaders&&s.shaders.uniforms&&e.GLSL.parseUniforms(s.shaders.uniforms).forEach(({type:e,value:s,path:o})=>{if("sampler2D"===e&&"string"==typeof s&&!t.textures[s]){const e=["styles",i,"shaders","uniforms",...o];this.addTextureNode(e,n,r)}})}if(t.layers){const i=[t.layers],s=[["layers"]];for(;i.length>0;){const o=i.pop(),a=s.pop();if("object"==typeof o&&!Array.isArray(o))for(const l in o)if("draw"===l){const e=o[l];for(const i in e){if(e[i].texture){const s=e[i].texture;if("string"==typeof s&&!t.textures[s]){const e=[...a,l,"draw",i,"texture"];this.addTextureNode(e,n,r)}}if(e[i].outline&&e[i].outline.texture){const s=e[i].outline.texture;if("string"==typeof s&&!t.textures[s]){const e=[...a,l,"draw",i,"outline","texture"];this.addTextureNode(e,n,r)}}}}else{if(e.isReserved(l))continue;i.push(o[l]),s.push([...a,l])}}}},addTextureNode(e,t,n){n[JSON.stringify(e)]={path:e,bundle:t}},hoistTextureNodes(e,t,n={}){for(const{path:r,bundle:o}of Object.values(n)){const n=i(e,r);if("string"==typeof n&&null==e.textures[n])if(c(e,r)){const r=t.urlFor(n);e.textures[n]={url:r}}else{const t=o.urlFor(n);e.textures[t]={url:t},s(e,r,t)}}},applyGlobalProperties:e=>e.global&&0!==Object.keys(e.global).length?d(h(e.global),e):e,finalize:({config:e,bundle:t})=>e?(e.global=e.global||{},e.scene=e.scene||{},e.cameras=e.cameras||{},e.lights=e.lights||{},e.styles=e.styles||{},e.layers=e.layers||{},e.camera&&(e.cameras.default=e.camera),0===Object.keys(e.cameras).length&&(e.cameras.default={}),(0===Object.keys(e.lights).length||Object.keys(e.lights).every(t=>!1===e.lights[t].visible))&&(e.lights.default_light={type:"directional"}),{config:e,bundle:t}):{}};e.subscribeMixin(pn);class gn{constructor(){this.tiles={},this.max_proxy_descendant_depth=6,this.max_proxy_ancestor_depth=7,this.children_cache={}}addTile(t){for(this.tiles[t.key]=this.tiles[t.key]||{descendants:0},this.tiles[t.key].tile=t;t.style_z>=0;){if(!(t=e.TileID.parent(t)))return;this.tiles[t.key]||(this.tiles[t.key]={descendants:0}),this.tiles[t.key].descendants++}}removeTile(t){for(this.tiles[t.key]&&(delete this.tiles[t.key].tile,0===this.tiles[t.key].descendants&&delete this.tiles[t.key]);t.style_z>=0;){if(!(t=e.TileID.parent(t)))return;this.tiles[t.key]&&this.tiles[t.key].descendants>0&&(this.tiles[t.key].descendants--,0!==this.tiles[t.key].descendants||this.tiles[t.key].tile||delete this.tiles[t.key])}}getAncestor(t){let n=0;for(;n<this.max_proxy_ancestor_depth;){if(!(t=e.TileID.parent(t)))return;if(this.tiles[t.key]&&this.tiles[t.key].tile&&this.tiles[t.key].tile.loaded)return this.tiles[t.key].tile;n++}}getDescendants(t,n=0){let r=[];if(n<this.max_proxy_descendant_depth){let i=e.TileID.children(t,this.children_cache);if(!i)return;i.forEach(e=>{this.tiles[e.key]&&(this.tiles[e.key].tile&&this.tiles[e.key].tile.loaded?r.push(this.tiles[e.key].tile):this.tiles[e.key].descendants>0&&r.push(...this.getDescendants(e,n+1)))})}return r}}let mn={},_n={};function yn(t,n=null){if(this.obb)return e.Label.prototype.occluded.call(this,t,n);if(this.obbs)for(let r=0;r<this.obbs.length;r++){let i={aabb:this.aabbs[r],obb:this.obbs[r]};if(e.Label.prototype.occluded.call(i,t,n))return!0}return!1}class vn{constructor({scene:t}){this.scene=t,this.tiles={},this.pyramid=new gn,this.visible_coords={},this.queued_coords=[],this.building_tiles=null,this.renderable_tiles=[],this.collision={tile_keys:null,mesh_set:null,zoom:null,zoom_steps:3},this.main_thread_target=["TileManager",this.scene.id].join("_"),e.WorkerBroker.addTarget(this.main_thread_target,this)}destroy(){this.forEachTile(e=>e.destroy()),this.tiles={},this.pyramid=null,this.visible_coords={},this.queued_coords=[],this.scene=null,e.WorkerBroker.removeTarget(this.main_thread_target)}get view(){return this.scene.view}get style_manager(){return this.scene.style_manager}keepTile(e){this.tiles[e.key]=e,this.pyramid.addTile(e)}hasTile(e){return void 0!==this.tiles[e]}forgetTile(e){if(this.hasTile(e)){let t=this.tiles[e];this.pyramid.removeTile(t)}delete this.tiles[e],this.tileBuildStop(e)}removeTile(t){e.log("trace",`tile unload for ${t}`);var n=this.tiles[t];null!=n&&n.destroy(),this.forgetTile(n.key),this.scene.requestRedraw()}forEachTile(e){for(let t in this.tiles)e(this.tiles[t])}removeTiles(e){let t=[];for(let n in this.tiles)e(this.tiles[n])&&t.push(n);for(let e=0;e<t.length;e++){let n=t[e];this.removeTile(n)}}updateTilesForView(){this.visible_coords={};let e=this.view.findVisibleTileCoordinates();for(let t=0;t<e.length;t++){const n=e[t];this.queueCoordinate(n),this.visible_coords[n.key]=n}this.updateTileStates()}updateTileStates(){return this.forEachTile(e=>{this.updateVisibility(e)}),this.loadQueuedCoordinates(),this.updateProxyTiles(),this.view.pruneTilesForView(),this.updateRenderableTiles(),this.style_manager.updateActiveStyles(this.renderable_tiles),this.style_manager.updateActiveBlendOrders(this.renderable_tiles),this.updateLabels()}updateLabels(){var t=this;if(this.scene.building&&!this.scene.building.initial)return Promise.resolve({});const n=this.renderable_tiles.filter(e=>e.valid).filter(e=>e.built);return 0===n.length?Promise.resolve({}):(n.sort((e,t)=>e.build_id<t.build_id?-1:e.build_id>t.build_id?1:0),this.collision.zoom===bn(this.view.zoom,this.collision.zoom_steps)&&this.collision.tile_keys===JSON.stringify(n.map(e=>e.key))&&this.collision.mesh_set===xn(n)?Promise.resolve({}):(this.collision.task||(this.collision.zoom=bn(this.view.zoom,this.collision.zoom_steps),this.collision.tile_keys=JSON.stringify(n.map(e=>e.key)),this.collision.mesh_set=xn(n),this.collision.task={type:"tileManagerUpdateLabels",run:async function(r){const i=await async function(t,n,r=!1){_n=mn,mn={};let i=function(t,n){let r={};t.forEach(t=>{const i=e.Geo.unitsPerMeter(t.coords.z),s=Math.pow(2,n-t.style_z),o=i*s,a=e.Geo.metersPerPixel(n),l=Object.assign({},t.meshes,t.pending_label_meshes);for(let n in l)l[n].forEach(n=>{if(n.labels)for(let s in n.labels){if(t.isProxy()&&!_n[s])continue;const l=n.labels[s].container.label,u=n.labels[s].container.linked,c=n.labels[s].ranges;let h={};if(h.discard=yn.bind(h),h.build_id=t.build_id,Object.assign(h,l),h.layout=Object.assign({},l.layout),h.layout.repeat_scale=.75,h.layout.repeat_distance=h.layout.repeat_distance||0,h.layout.repeat_distance/=o,h.position=[h.position[0]/i+t.min.x,h.position[1]/i+t.min.y],h.unit_scale=a,"point"===h.type)e.LabelPoint.prototype.updateBBoxes.call(h);else if("straight"===h.type)e.LabelLineStraight.prototype.updateBBoxes.call(h,h.position,h.size,h.angle,h.angle,h.offset);else if(l.obbs){const n=l.obbs.map(n=>{let{x:r,y:s,a:a,w:l,h:u}=n;return r=r/i+t.min.x,s=s/i+t.min.y,l/=o,u/=o,new e.OBB(r,s,a,l,u)});h.obbs=n,h.aabbs=n.map(e=>e.getExtent())}r[s]={label:h,linked:u,ranges:c,mesh:n}}})});for(let e in r){const t=r[e];t.linked&&(t.linked=r[t.linked])}return r=Object.keys(r).map(e=>r[e]),r}(t,n);e.Collision.startTile("main",{apply_repeat_groups:!0,return_hidden:!0}),e.Collision.addStyle("main","main");const s=Math.max(0,...Object.values(t).map(e=>Object.values(e.meshes)).flat().map(e=>Math.max(0,...e.map(e=>e.labels?Object.keys(e.labels).length:0)))),o=Math.floor(s/e.Geo.tile_size);o>0?e.Collision.initGrid({anchor:{x:Math.min(...t.map(e=>e.min.x)),y:Math.min(...t.map(e=>e.min.y))},span:t[0].span.x/o}):e.Collision.initGrid();const a=await e.Collision.collide(i,"main","main");let l=[];return a.forEach(e=>{let t=0;!0!==e.show||r&&e.label.breach&&!_n[e.label.id]||(t=1),t&&(mn[e.label.id]=!0);let n=!0;e.ranges.forEach(r=>{if(!n)return;let i=e.mesh;if(!i.valid)return;let s=i.vertex_layout.offset.a_shape,o=i.vertex_layout.stride;for(let e=0;e<r[1];e++){if(i.vertex_data[r[0]+e*o+s+6]===t)return void(n=!1);i.vertex_data[r[0]+e*o+s+6]=t}-1===l.indexOf(i)&&l.push(i)})}),l.forEach(e=>e.upload()),t.forEach(e=>e.swapPendingLabels()),{labels:a,containers:i}}(n,t.collision.zoom,t.isLoadingVisibleTiles());t.scene.requestRedraw(),t.collision.task=null,e.Task.finish(r,i),t.updateTileStates()},immediate:!0},e.Task.add(this.collision.task)),this.collision.task.promise))}updateProxyTiles(){if(0===this.view.zoom_direction)return;this.forEachTile(e=>e.setProxyFor(null));let e=!1;this.forEachTile(t=>{if(t.visible&&!t.labeled){const n=this.pyramid.getAncestor(t);if(n)n.setProxyFor(t),e=!0;else{const n=this.pyramid.getDescendants(t);for(let r=0;r<n.length;r++)n[r].setProxyFor(t),e=!0}}}),e||(this.view.zoom_direction=0)}updateVisibility(t){if(t.visible=!1,t.style_z===this.view.tile_zoom)if(this.visible_coords[t.coords.key])t.visible=!0;else for(let n in this.visible_coords)if(e.TileID.isDescendant(t.coords,this.visible_coords[n])){t.visible=!0;break}}pruneToVisibleTiles(){this.removeTiles(e=>!e.visible)}getRenderableTiles(){return this.renderable_tiles}updateRenderableTiles(){this.renderable_tiles=[];for(let e in this.tiles){let t=this.tiles[e];t.visible&&t.loaded&&this.renderable_tiles.push(t)}return this.renderable_tiles}isLoadingVisibleTiles(){return Object.keys(this.tiles).some(e=>this.tiles[e].visible&&!this.tiles[e].built)}allVisibleTilesLabeled(){return this.renderable_tiles.every(e=>e.labeled)}queueCoordinate(e){this.queued_coords[this.queued_coords.length]=e}loadQueuedCoordinates(){0!==this.queued_coords.length&&(this.queued_coords.sort((t,n)=>{let r=this.view.center.meters,i=e.Geo.metersPerTile(t.z)/2,s=e.Geo.metersForTile(t);s.x+=i,s.y-=i;let o=e.Geo.metersForTile(n);o.x+=i,o.y-=i;let a=Math.abs(r.x-s.x)+Math.abs(r.y-s.y),l=Math.abs(r.x-o.x)+Math.abs(r.y-o.y);return t.center_dist=a,n.center_dist=l,l>a?-1:l===a?0:1}),this.queued_coords.forEach(e=>this.loadCoordinate(e)),this.queued_coords=[])}loadCoordinate(t){if(t.z===this.view.center.tile.z)for(let n in this.scene.sources){let r=this.scene.sources[n];if(!r.builds_geometry_tiles||!r.includesTile(t,this.view.tile_zoom))continue;let i=e.TileID.normalizedKey(t,r,this.view.tile_zoom);if(i&&!this.hasTile(i)){e.log("trace",`load tile ${i}, distance from view center: ${t.center_dist}`);let n=new e.Tile({source:r,coords:t,workers:this.scene.workers,style_z:this.view.baseZoom(t.z),view:this.view});this.keepTile(n),this.buildTile(n)}}}buildTile(e,t){this.tileBuildStart(e.key),this.updateVisibility(e),e.build(this.scene.generation,t)}buildTileStylesCompleted({tile:t,progress:n}){if(null==this.tiles[t.key])e.log("trace",`discarded tile ${t.key} in TileManager.buildTileStylesCompleted because previously removed`),e.Tile.abortBuild(t),this.updateTileStates();else if(t.generation!==this.scene.generation)e.log("trace",`discarded tile ${t.key} in TileManager.buildTileStylesCompleted because built with scene config gen ${t.generation}, current ${this.scene.generation}`),e.Tile.abortBuild(t),this.updateTileStates();else{if(this.tiles[t.key]){if(t.id<this.tiles[t.key].id)return e.log("trace",`discarded tile ${t.key} for id ${t.id} in TileManager.buildTileStylesCompleted because built for discarded tile id`),void e.Tile.abortBuild(t);t=this.tiles[t.key].merge(t)}n.done&&(t.built=!0),t.buildMeshes(this.scene.styles,n),this.updateTileStates(),this.scene.requestRedraw()}n.done&&this.tileBuildStop(t.key)}buildTileError(t){e.log("error",`Error building tile ${t.key}:`,t.error),this.forgetTile(t.key),e.Tile.abortBuild(t)}tileBuildStart(t){this.building_tiles=this.building_tiles||{},this.building_tiles[t]=!0,e.log("trace",`tileBuildStart for ${t}: ${Object.keys(this.building_tiles).length}`)}tileBuildStop(t){this.building_tiles&&(e.log("trace",`tileBuildStop for ${t}: ${Object.keys(this.building_tiles).length}`),delete this.building_tiles[t],this.checkBuildQueue())}checkBuildQueue(){this.building_tiles&&0!==Object.keys(this.building_tiles).length||(this.building_tiles=null,this.scene.tileManagerBuildDone())}getDebugProp(e,t){var n=[];for(var r in this.tiles)null==this.tiles[r].debug[e]||"function"==typeof t&&!0!==t(this.tiles[r])||n.push(this.tiles[r].debug[e]);return n}getDebugSum(e,t){var n=0;for(var r in this.tiles)null==this.tiles[r].debug[e]||"function"==typeof t&&!0!==t(this.tiles[r])||(n+=this.tiles[r].debug[e]);return n}getDebugAverage(e,t){return this.getDebugSum(e,t)/Object.keys(this.tiles).length}}function bn(e,t,n=2){return(Math.floor(e*t)/t).toFixed(n)}function xn(e){return JSON.stringify(Object.entries(e).map(([,e])=>Object.entries(e.meshes).map(([,e])=>e.map(e=>e.created_at))))}class wn{constructor(e,t){t(e),this.value=e,this.setup=t}set(e){JSON.stringify(this.value)!==JSON.stringify(e)&&(this.setup(e),this.value=e)}}class An{constructor(e){this.defaults={},this.defaults.culling=!0,this.defaults.culling_face=e.BACK,this.defaults.blending=!1,this.defaults.blending_src=e.ONE_MINUS_SRC_ALPHA,this.defaults.blending_dst=e.ONE_MINUS_SRC_ALPHA,this.defaults.blending_src_alpha=e.ONE,this.defaults.blending_dst_alpha=e.ONE_MINUS_SRC_ALPHA,this.defaults.depth_write=!0,this.defaults.depth_test=!0,e.depthFunc(e.LESS),this.culling=new wn({cull:this.defaults.culling,face:this.defaults.culling_face},t=>{t.cull?(e.enable(e.CULL_FACE),e.cullFace(t.face)):e.disable(e.CULL_FACE)}),this.blending=new wn({blend:this.defaults.blending,src:this.defaults.blending_src,dst:this.defaults.blending_dst,src_alpha:this.defaults.blending_src_alpha,dst_alpha:this.defaults.blending_dst_alpha},t=>{t.blend?(e.enable(e.BLEND),t.src_alpha&&t.dst_alpha?e.blendFuncSeparate(t.src,t.dst,t.src_alpha,t.dst_alpha):e.blendFunc(t.src,t.dst)):e.disable(e.BLEND)}),this.depth_write=new wn({depth_write:this.defaults.depth_write},t=>{e.depthMask(t.depth_write)}),this.depth_test=new wn({depth_test:this.defaults.depth_test},t=>{t.depth_test?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST)})}}class En{constructor(){this.canvas=null,this.gl=null,this.screenshot_canvas=null,this.screenshot_context=null,this.queue_screenshot=null,this.video_capture=null}setCanvas(e,t){this.canvas=e,this.gl=t}screenshot({background:e}={}){return null!=this.queue_screenshot||(this.queue_screenshot={background:e},this.queue_screenshot.promise=new Promise((e,t)=>{this.queue_screenshot.resolve=e,this.queue_screenshot.reject=t})),this.queue_screenshot.promise}completeScreenshot(){if(null!=this.queue_screenshot){let t=this.canvas.width,n=this.canvas.height,r=new Uint8Array(t*n*4);this.gl.readPixels(0,0,t,n,this.gl.RGBA,this.gl.UNSIGNED_BYTE,r);let i=this.queue_screenshot.background;i=i&&"transparent"!==i?e.StyleParser.parseColor(i).slice(0,3).map(e=>255*e):null;let s=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let o=0;o<t;o++){let a=4*((n-e-1)*t+o),l=4*(e*t+o),u=r[a+3];s[l+0]=255*r[a+0]/u,s[l+1]=255*r[a+1]/u,s[l+2]=255*r[a+2]/u,s[l+3]=u,i&&(u/=255,s[l+0]=s[l+0]*u+i[0]*(1-u),s[l+1]=s[l+1]*u+i[1]*(1-u),s[l+2]=s[l+2]*u+i[2]*(1-u),s[l+3]=255)}this.screenshot_canvas=this.screenshot_canvas||document.createElement("canvas");let o=this.screenshot_canvas;o.width=t,o.height=n,this.screenshot_context=this.screenshot_context||o.getContext("2d");let a=this.screenshot_context,l=new ImageData(s,t,n);a.putImageData(l,0,0);const u=o.toDataURL("image/png"),c=atob(u.slice(22)),h=new Uint8Array(c.length);for(let e=0;e<c.length;++e)h[e]=c.charCodeAt(e);const d=new Blob([h],{type:"image/png"});this.queue_screenshot.resolve({url:u,blob:d,type:"png"}),this.queue_screenshot=null}}startVideoCapture(){if("function"!=typeof window.MediaRecorder||!this.canvas||"function"!=typeof this.canvas.captureStream)return e.log("warn","Video capture (Canvas.captureStream and/or MediaRecorder APIs) not supported by browser"),!1;if(this.video_capture)return e.log("warn","Video capture already in progress, call Scene.stopVideoCapture() first"),!1;try{let t=this.video_capture={};t.chunks=[],t.stream=this.canvas.captureStream(),t.options={mimeType:"video/webm"},t.media_recorder=new MediaRecorder(t.stream,t.options),t.media_recorder.ondataavailable=n=>{if(n.data.size>0&&t.chunks.push(n.data),t.resolve){let n=new Blob(t.chunks,{type:t.options.mimeType}),r=e.createObjectURL(n);t.stream&&(t.stream.getTracks()||[]).forEach(e=>{e.stop(),t.stream.removeTrack(e)}),t.stream=null,t.media_recorder=null,this.video_capture=null,t.resolve({url:r,blob:n,type:"webm"})}},t.media_recorder.start()}catch(t){return this.video_capture=null,e.log("error","Scene video capture failed",t),!1}return!0}stopVideoCapture(){return this.video_capture?(this.video_capture.promise=new Promise((e,t)=>{this.video_capture.resolve=e,this.video_capture.reject=t}),this.video_capture.media_recorder.stop(),this.video_capture.promise):(e.log("warn","No scene video capture in progress, call Scene.startVideoCapture() first"),Promise.resolve({}))}}function Sn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tn(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?Sn(Object(r),!0).forEach(function(n){e._defineProperty(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Sn(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}class kn{constructor(t,n){var r;n=n||{},e.subscribeMixin(this),this.id=kn.id++,this.initialized=!1,this.initializing=null,this.sources={},this.view=new e.View(this,n),this.tile_manager=new vn({scene:this}),this.num_workers=n.numWorkers||2,!0===n.disableVertexArrayObjects&&(e.VertexArrayObject.disabled=!0),e.Utils.use_high_density_display=void 0===n.highDensityDisplay||n.highDensityDisplay,e.Utils.updateDevicePixelRatio(),this.config=null,this.config_source=t,this.config_bundle=null,this.last_valid_config_source=null,this.styles=null,this.style_manager=new e.StyleManager,this.building=null,this.dirty=!0,n.preUpdate&&this.subscribe({pre_update:n.preUpdate}),n.postUpdate&&this.subscribe({post_update:n.postUpdate}),this.render_loop=!n.disableRenderLoop,this.render_loop_active=!1,this.render_loop_stop=!1,this.render_count=0,this.last_render_count=0,this.render_count_changed=!1,this.frame=0,this.last_main_render=-1,this.last_selection_render=-1,this.media_capture=new En,this.selection=null,this.selection_feature_count=0,this.fetching_selection_map=null,this.prev_textures=null,this.introspection=!0===n.introspection,this.times={},this.resetTime(),this.container=n.container,this.canvas=null,this.contextOptions=n.webGLContextOptions,this.lights=null,this.background=null,this.createListeners(),this.updating=0,this.generation=kn.generation,this.last_complete_generation=kn.generation,(r=this).debug={profile(t){console.profile(`main thread: ${t}`),e.WorkerBroker.postMessage(r.workers,"self.profile",t)},profileEnd(t){console.profileEnd(`main thread: ${t}`),e.WorkerBroker.postMessage(r.workers,"self.profileEnd",t)},timeRebuild(t=1,n={}){let i=[],s=()=>{let o=+new Date;r.rebuild(n).then(()=>{if(i.push(+new Date-o),i.length<t)s();else{let n=~~(i.reduce((e,t)=>e+t)/i.length);e.log("info",`Profiled rebuild ${t} times: ${n} avg (${Math.min(...i)} min, ${Math.max(...i)} max)`)}})};s()},geometryCountByStyle(){let e={};return r.tile_manager.getRenderableTiles().forEach(t=>{for(let n in t.meshes)e[n]=e[n]||0,t.meshes[n].forEach(t=>{e[n]+=t.geometry_count})}),e},geometryCountByBaseStyle(){let e=r.debug.geometryCountByStyle(),t={};for(let n in e){let i=r.styles[n].baseStyle();t[i]=t[i]||0,t[i]+=e[n]}return t},geometryCountTotal(){const e=r.debug.geometryCountByStyle();return Object.keys(e).reduce((t,n)=>e[n]+t,0)},geometrySizeByStyle(){let e={};return r.tile_manager.getRenderableTiles().forEach(t=>{for(let n in t.meshes)e[n]=e[n]||0,t.meshes[n].forEach(t=>{e[n]+=t.buffer_size})}),e},geometrySizeByBaseStyle(){let e=r.debug.geometrySizeByStyle(),t={};for(let n in e){let i=r.styles[n].baseStyle();t[i]=t[i]||0,t[i]+=e[n]}return t},geometrySizeTotal(){const e=r.debug.geometrySizeByStyle();return Object.keys(e).reduce((t,n)=>e[n]+t,0)},textureSizeTotal:()=>Object.values(e.Texture.textures).map(e=>e.byteSize()).reduce((e,t)=>e+t),layerStats:()=>e.debugSettings.layer_stats?e.debugSumLayerStats(r.tile_manager.getRenderableTiles()):(e.log("warn","Enable the 'layer_stats' debug setting to collect layer stats"),{}),renderableTilesCount:()=>r.tile_manager.getRenderableTiles().length},this.log_level=n.logLevel||"warn",e.log.setLevel(this.log_level),e.log.reset()}static create(e,t={}){return new kn(e,t)}load(t=null,n={}){var r=this;return this.initializing||(e.log.reset(),this.updating++,this.initialized=!1,this.view_complete=!1,this.times.frame=null,this.times.build=null,(n="string"==typeof n?{base_path:n}:n).blocking=void 0===n.blocking||n.blocking,!1!==this.render_loop&&this.setupRenderLoop(),this.createCanvas(),this.prev_textures=this.config&&Object.keys(this.config.textures),this.initializing=this.loadScene(t,n).then(async function({texture_nodes:t}){await r.createWorkers(),r.destroyFeatureSelection(),e.WorkerBroker.postMessage(r.workers,"self.clearFunctionStringCache");const i="object"==typeof r.config_source||r.hasSubscribersFor("load"),s=r.updateConfig({texture_nodes:t,serialize_funcs:i,normalize:!1,loading:!0,fade_in:!0});!0===n.blocking&&await s,r.freePreviousTextures(),r.updating--,r.initializing=null,r.initialized=!0,r.last_valid_config_source=r.config_source,r.last_valid_options={base_path:n.base_path,file_type:n.file_type},r.requestRedraw()}).catch(t=>{let n,r;if(this.initializing=null,this.updating=0,"YAMLException"===t.name?(n="yaml",r="Error parsing scene YAML"):r="Error initializing scene",this.trigger("error",{type:n,message:r,error:t,url:this.config_source}),r=`Scene.load() failed to load ${JSON.stringify(this.config_source)}: ${t.message}`,this.last_valid_config_source)return e.log("warn",r,t),e.log("info","Scene.load() reverting to last valid configuration"),this.load(this.last_valid_config_source,this.last_valid_base_path);throw e.log("error",r,t),t})),this.initializing}destroy(){if(this.initialized=!1,this.render_loop_stop=!0,this.destroyListeners(),this.destroyFeatureSelection(),this.canvas&&this.canvas.parentNode&&(this.canvas.parentNode.removeChild(this.canvas),this.canvas=null),this.container=null,this.gl){e.Texture.destroy(this.gl),this.style_manager.destroy(this.gl),this.styles={},e.ShaderProgram.reset();let t=this.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this.gl=null}this.sources={},this.destroyWorkers(),this.tile_manager.destroy(),this.tile_manager=null,e.log.reset()}createCanvas(){if(!this.canvas){this.container=this.container||document.body,this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.top=0,this.canvas.style.left=0,this.container.style.backgroundColor="transparent",this.container.appendChild(this.canvas);try{this.gl=n.getContext(this.canvas,Object.assign({alpha:!0,premultipliedAlpha:!0,stencil:!0,device_pixel_ratio:e.Utils.device_pixel_ratio,powerPreference:"high-performance"},this.contextOptions))}catch(e){throw new Error("Couldn't create WebGL context. Your browser may not support WebGL, or it's turned off? Visit http://webglreport.com/ for more info.")}this.resizeMap(this.container.clientWidth,this.container.clientHeight),e.VertexArrayObject.init(this.gl),this.render_states=new An(this.gl),this.media_capture.setCanvas(this.canvas,this.gl)}}updateExternalScripts(){let e=[...this.external_scripts||[]],t=[];if(this.config.scene.scripts)for(let e in this.config.scene.scripts)-1===t.indexOf(this.config.scene.scripts[e])&&t.push(this.config.scene.scripts[e]);for(let e in this.config.sources){let n=this.config.sources[e];if(n.scripts)for(let e in n.scripts)-1===t.indexOf(n.scripts[e])&&t.push(n.scripts[e])}return this.external_scripts=t,!(this.external_scripts.length===e.length&&this.external_scripts.every((t,n)=>t===e[n]))}createWorkers(){return this.updateExternalScripts()&&this.destroyWorkers(),this.workers?Promise.resolve():this.makeWorkers()}makeWorkers(){let t=!!this.gl.getExtension("OES_element_index_uint"),n=[];this.workers=[];for(let r=0;r<this.num_workers;r++){let i=new Worker(px.workerURL);this.workers[r]=i,e.WorkerBroker.addWorker(i),e.log("debug",`Scene.makeWorkers: initializing worker ${r}`);let s=r;n.push(e.WorkerBroker.postMessage(i,"self.init",this.id,r,this.num_workers,this.log_level,e.Utils.device_pixel_ratio,t,this.external_scripts).then(t=>(e.log("debug",`Scene.makeWorkers: initialized worker ${t}`),t),t=>(e.log("error",`Scene.makeWorkers: failed to initialize worker ${s}:`,t),Promise.reject(t))))}return this.next_worker=0,Promise.all(n).then(()=>{e.log.setWorkers(this.workers)})}destroyWorkers(){this.selection=null,Array.isArray(this.workers)&&(e.log.setWorkers(null),this.workers.forEach(e=>{e.terminate()}),this.workers=null)}ready(){return!(!this.view.ready()||0===Object.keys(this.sources).length)}updateDevicePixelRatio(){e.Utils.updateDevicePixelRatio()&&e.WorkerBroker.postMessage(this.workers,"self.updateDevicePixelRatio",e.Utils.device_pixel_ratio).then(()=>this.rebuild()).then(()=>this.resizeMap(this.view.size.css.width,this.view.size.css.height))}resizeMap(t,r){0===t&&0===r||(this.dirty=!0,this.view.setViewportSize(t,r),this.gl&&n.resize(this.gl,t,r,e.Utils.device_pixel_ratio))}requestRedraw(){this.dirty=!0}immediateRedraw(){this.dirty=!0,this.update()}renderLoop(){this.render_loop_active=!0,this.update(),e.Task.setState({user_moving_view:this.view.user_input_active}),e.Task.processAll(),this.render_loop_stop?(this.render_loop_stop=!1,this.render_loop_active=!1):window.requestAnimationFrame(this.renderLoop.bind(this))}setupRenderLoop(){this.render_loop_active||setTimeout(()=>{this.renderLoop()},0)}update(){let t=this.dirty,n=!!this.selection&&this.selection.hasPendingRequests();var r=!(!1===t&&!1===n||!1===this.initialized||this.updating>0||!1===this.ready());return this.trigger("pre_update",r),this.view.update(),!!r&&(this.dirty=!1,this.updateDevicePixelRatio(),this.render({main:t,selection:n}),this.updateViewComplete(),this.media_capture.completeScreenshot(),this.trigger("post_update",r),(!0===this.animated||this.view.isAnimating())&&(this.dirty=!0),this.frame++,e.log("trace","Scene.render()"),!0)}render({main:t,selection:n}){var r=this.gl;if(this.updateBackground(),Object.keys(this.lights).forEach(e=>this.lights[e].update()),this.render_count_changed=!1,t&&(this.render_count=this.renderPass(),this.last_main_render=this.frame,this.render_count!==this.last_render_count&&(this.render_count_changed=!0,this.logFirstFrame(),this.getFeatureSelectionMapSize().then(t=>{this.selection_feature_count=t,e.log("info",`Scene: rendered ${this.render_count} primitives (${t} features in selection map)`)})),this.last_render_count=this.render_count),n){if(this.view.panning||this.view.user_input_active)return void this.selection.clearPendingRequests();!this.selection.locked&&this.last_selection_render<this.last_main_render&&(this.selection.bind(),this.renderPass("selection_program",{allow_blend:!1}),r.bindFramebuffer(r.FRAMEBUFFER,null),r.viewport(0,0,this.canvas.width,this.canvas.height),r.clearColor(...this.background.computed_color),this.last_selection_render=this.frame),this.selection.read()}return!0}renderPass(t="program",{allow_blend:n}={}){n=null==n||n,this.clearFrame();let r,i=0;const s=this.style_manager.getActiveBlendOrders();for(const{blend_order:o,styles:a}of s)for(let s=0;s<a.length;s++){let l=this.styles[a[s]];if(null==l)continue;if(l.blend!==r){let t=Object.assign({},e.Style.render_states[l.blend],{blend:n&&l.blend});this.setRenderState(t)}const u=n&&l.blend;if("translucent"===u)this.gl.colorMask(!1,!1,!1,!1),this.renderStyle(l.name,t,o),this.gl.colorMask(!0,!0,!0,!0),this.gl.depthFunc(this.gl.EQUAL),this.gl.enable(this.gl.STENCIL_TEST),this.gl.clearStencil(0),this.gl.clear(this.gl.STENCIL_BUFFER_BIT),this.gl.stencilFunc(this.gl.EQUAL,this.gl.ZERO,255),this.gl.stencilOp(this.gl.KEEP,this.gl.KEEP,this.gl.INCR),i+=this.renderStyle(l.name,t,o),this.gl.disable(this.gl.STENCIL_TEST),this.gl.depthFunc(this.gl.LESS);else if("opaque"!==u&&!0===l.stencil_proxy_tiles){const e=this.tile_manager.getRenderableTiles().filter(e=>e.meshes[l.name]).map(e=>e.proxy_level).reduce((e,t)=>(e.indexOf(t)>-1||e.push(t),e),[]).sort();if(e.length>1){this.gl.enable(this.gl.STENCIL_TEST),this.gl.clearStencil(0),this.gl.clear(this.gl.STENCIL_BUFFER_BIT),this.gl.stencilOp(this.gl.KEEP,this.gl.KEEP,this.gl.REPLACE);for(let n=0;n<e.length;n++)this.gl.stencilFunc(this.gl.GEQUAL,e.length-n,255),i+=this.renderStyle(l.name,t,o,e[n]);this.gl.disable(this.gl.STENCIL_TEST)}else i+=this.renderStyle(l.name,t,o)}else i+=this.renderStyle(l.name,t,o);r=l.blend}return i}renderStyle(e,t,n,r=null){let i,s=this.styles[e],o=!0,a=0,l=this.tile_manager.getRenderableTiles().filter(e=>"number"!=typeof r||e.proxy_level===r).map(t=>{if(t.meshes[e])return[t,t.meshes[e].filter(e=>e.variant.blend_order===n)]}).filter(e=>e),u=Math.max(...l.map(([,e])=>Math.max(...e.map(e=>e.variant.mesh_order))));for(let n=0;n<u+1;n++)for(let[r,u]of l){let l=!0;if(!r.shouldProxyForStyle(e))continue;const c=u.filter(e=>e.variant.mesh_order===n);if(0!==c.length){if(!0===o&&(o=!1,i=this.setupStyle(s,t),!i))return 0;c.forEach(e=>{!0===l&&(l=!1,this.view.setupTile(r,i)),s.render(e)&&this.requestRedraw(),a+=e.geometry_count})}}return a}setupStyle(e,t){let n;try{if(n=e.getProgram(t),!n)return}catch(t){return void this.trigger("warning",{type:"styles",message:`Error compiling style ${e.name}`,style:e,shader_errors:e.program&&e.program.shader_errors})}n.use(),e.setup(),n.uniform("1f","u_time",this.animated?(+new Date-this.start_time)/1e3:0),this.view.setupProgram(n);for(let e in this.lights)this.lights[e].setupProgram(n);return n}clearFrame(){this.initialized&&(this.render_states.depth_write.set({depth_write:!0}),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT|this.gl.STENCIL_BUFFER_BIT))}setRenderState({depth_test:e,depth_write:t,cull_face:n,blend:r}={}){if(!this.initialized)return;let i=this.render_states;e=!1!==e&&i.defaults.depth_test,t=!1!==t&&i.defaults.depth_write,n=!1!==n&&i.defaults.culling,r=null!=r?r:i.defaults.blending;let s=this.gl;i.depth_test.set({depth_test:e}),i.depth_write.set({depth_write:t}),i.culling.set({cull:n,face:i.defaults.culling_face}),r?"opaque"===r?i.blending.set({blend:!1}):"overlay"===r||"inlay"===r||"translucent"===r?i.blending.set({blend:!0,src:s.SRC_ALPHA,dst:s.ONE_MINUS_SRC_ALPHA,src_alpha:s.ONE,dst_alpha:s.ONE_MINUS_SRC_ALPHA}):"add"===r?i.blending.set({blend:!0,src:s.ONE,dst:s.ONE}):"multiply"===r&&i.blending.set({blend:!0,src:s.ZERO,dst:s.SRC_COLOR}):i.blending.set({blend:!1})}getFeatureAt(t,{radius:n}={}){if(!this.initialized)return e.log("debug","Scene.getFeatureAt() called before scene was initialized"),Promise.resolve();if(0===this.selection_feature_count)return Promise.resolve();this.selection||this.resetFeatureSelection();let r={x:t.x/this.view.size.css.width,y:t.y/this.view.size.css.height};return n=n>0?{x:n/this.view.size.css.width,y:n/this.view.size.css.height}:null,this.selection.getFeatureAt(r,{radius:n}).then(e=>Object.assign(e,{pixel:t})).catch(e=>Promise.resolve({error:e}))}async queryFeatures({filter:t,unique:n=!0,group_by:r=null,visible:i=null,geometry:s=!1}={}){if(!this.initialized)return[];t=e.Utils.serializeWithFunctions(t);const o=!0===(n="string"==typeof n?[n]:n)||Array.isArray(n)&&n.indexOf("$id")>-1,a=n&&(t=>{const r=Array.isArray(n)?e.sliceObject(t.properties,n):t.properties,i=o?t.id:null;return s?JSON.stringify({geometry:t.geometry,properties:r,id:i}):JSON.stringify({properties:r,id:i})}),l=(r=("string"==typeof r||Array.isArray(r))&&r)&&(t=>Array.isArray(r)?JSON.stringify(e.sliceObject(t,r)):t[r]),u=this.tile_manager.getRenderableTiles().map(e=>e.key),c=await e.WorkerBroker.postMessage(this.workers,"self.queryFeatures",{filter:t,visible:i,geometry:s,tile_keys:u}),h=[],d={},f={};return c.forEach(e=>e.forEach(e=>{if(a){const t=a(e);if(d[t])return;d[t]=!0}if(l){const t=l(e.properties);f[t]=f[t]||[],f[t].push(e)}else h.push(e)})),l?f:h}rebuild({initial:t=!1,new_generation:n=!0,sources:r=null,serialize_funcs:i,profile:s=!1,fade_in:o=!1}={}){return new Promise((a,l)=>{if(this.building){this.building.queued&&this.building.queued.reject&&(e.log("debug","Scene.rebuild: request superceded by a newer call"),this.building.queued.resolve(!1));let u={initial:t,new_generation:n,sources:r,serialize_funcs:i,profile:s,fade_in:o};return this.building.queued={resolve:a,reject:l,options:u},void e.log("trace","Scene.rebuild(): queuing request")}if(this.building={resolve:a,reject:l,initial:t},s&&this.debug.profile("Scene.rebuild"),n){this.generation=++kn.generation;for(let e in this.styles)this.styles[e].setGeneration(this.generation)}this.syncConfigToWorker({serialize_funcs:i}),this.resetWorkerFeatureSelection(r),this.resetTime(),this.tile_manager.pruneToVisibleTiles(),this.tile_manager.forEachTile(e=>{(!r||r.indexOf(e.source.name)>-1)&&this.tile_manager.buildTile(e,{fade_in:o})}),this.tile_manager.updateTilesForView(),this.tile_manager.checkBuildQueue()}).then(()=>{s&&this.debug.profileEnd("Scene.rebuild")})}tileManagerBuildDone(){if(e.TextCanvas.pruneTextCache(),this.building){e.log("info","Scene: build geometry finished"),this.building.resolve&&(this.logFirstBuild(),this.building.resolve(!0));var t=this.building.queued;this.building=null,t?(e.log("debug","Scene: starting queued rebuild() request"),this.rebuild(t.options).then(t.resolve,t.reject)):this.tile_manager.updateLabels()}}async loadScene(t=null,{base_path:n,file_type:r}={}){this.config_source=t||this.config_source,"string"==typeof this.config_source?this.base_path=e.pathForURL(n||this.config_source):this.base_path=e.pathForURL(n),this.config_path=this.base_path;const{config:i,bundle:s,texture_nodes:o}=await pn.loadScene(this.config_source,{path:this.base_path,type:r});return this.config=i,this.config_bundle=s,{texture_nodes:o}}setDataSource(t,n){if(!t||!n||!n.type||!n.url&&!n.data)return void e.log("error","No name provided or not a valid config:",t,n);let r=null==this.config.sources[t],i=this.config.sources[t]=Object.assign({},n);return i.data&&"object"==typeof i.data&&(i.url=e.createObjectURL(new Blob([JSON.stringify(i.data)],{type:"application/json"})),delete i.data),r?this.updateConfig({rebuild:{sources:[t]}}):this.rebuild({sources:[t]})}createDataSources(t=!1){const n=[],r=Object.keys(this.sources);let i=0;for(var s in this.config.sources){const r=this.config.sources[s],o=this.sources[s];try{const t=Tn(Tn({},r),{},{name:s,id:i++});if(this.sources[s]=e.DataSource.create(t,this.sources),!this.sources[s])throw{}}catch(t){delete this.sources[s];const n=`Could not create data source: ${t.message}`;e.log("warn",`Scene: ${n}`,r),this.trigger("warning",{type:"sources",source:r,message:n})}(t||e.DataSource.tileLayoutChanged(this.sources[s],o))&&n.push(s)}r.forEach(e=>{this.config.sources[e]||(delete this.sources[e],n.push(e))}),n.length>0&&this.tile_manager.removeTiles(e=>n.indexOf(e.source.name)>-1);for(let e in this.config.layers){let t=this.config.layers[e];!1!==t.enabled&&t.data&&this.sources[t.data.source]&&(this.sources[t.data.source].builds_geometry_tiles=!0)}}loadTextures(){return e.Texture.createFromObject(this.gl,this.config.textures).then(()=>e.Texture.createDefault(this.gl))}freePreviousTextures(){this.prev_textures&&(this.prev_textures.forEach(t=>{!this.config.textures[t]&&e.Texture.textures[t]&&e.Texture.textures[t].destroy()}),this.prev_textures=null)}updateStyles(){if(!this.initialized&&!this.initializing)throw new Error("Scene.updateStyles() called before scene was initialized");this.styles=this.style_manager.build(this.config.styles),this.style_manager.initStyles(this);for(let e in this.styles)this.styles[e].setGL(this.gl);this.dirty=!0}get animated(){return!1!==this.config.scene.animated&&this.style_manager.getActiveStyles().some(e=>this.styles[e].animated)}getActiveCamera(){return this.view.getActiveCamera()}setActiveCamera(e){return this.view.setActiveCamera(e)}createLights(){this.lights={},e.debugSettings.wireframe&&(e.Light.enabled=!1);for(let t in this.config.lights){if(!this.config.lights[t]||"object"!=typeof this.config.lights[t])continue;let n=this.config.lights[t];n.name=t.replace("-","_"),n.visible=!1!==n.visible,n.visible&&(this.lights[n.name]=e.Light.create(this.view,n))}e.Light.inject(this.lights)}setBackground(){const t=this.config.scene.background;this.background={},t&&t.color&&(this.background.color=e.StyleParser.createColorPropertyCache(t.color)),this.background.color||(this.background.color=e.StyleParser.createColorPropertyCache([0,0,0,0]))}updateBackground(){const t=this.background.computed_color,n=this.background.computed_color=e.StyleParser.evalCachedColorProperty(this.background.color,{zoom:this.view.tile_zoom});t&&!n.some((e,n)=>t[n]!==e)||(1===n[3]?this.canvas.style.backgroundColor=`rgba(${n.map(e=>Math.floor(255*e)).join(", ")})`:this.canvas.style.backgroundColor="transparent",this.gl.clearColor(...n))}setIntrospection(e){return e!==this.introspection?(this.introspection=null!=e&&e,this.updating++,this.updateConfig({normalize:!1}).then(()=>this.updating--)):Promise.resolve()}updateConfig({loading:t=!1,rebuild:n=!0,serialize_funcs:r,texture_nodes:i={},normalize:s=!0,fade_in:o=!1}={}){this.generation=++kn.generation,this.updating++,this.config=pn.applyGlobalProperties(this.config),s&&pn.normalize(this.config,this.config_bundle,i),pn.hoistTextureNodes(this.config,this.config_bundle,i),this.trigger(t?"load":"update",{config:this.config}),this.style_manager.init(),this.view.reset(),this.createLights(),this.createDataSources(t),this.loadTextures(),this.setBackground(),e.FontManager.loadFonts(this.config.fonts),this.updateStyles();let a=n?this.rebuild(Object.assign({initial:t,new_generation:!1,serialize_funcs:r,fade_in:o},"object"==typeof n&&n)):this.syncConfigToWorker({serialize_funcs:r});return this.updating--,this.view.updateBounds(),this.requestRedraw(),a.then(()=>{this.last_render_count=0,this.requestRedraw()})}syncConfigToWorker({serialize_funcs:t=!0}={}){let n=t?e.Utils.serializeWithFunctions(this.config):JSON.stringify(this.config);return e.WorkerBroker.postMessage(this.workers,"self.updateConfig",{config:n,generation:this.generation,introspection:this.introspection},e.debugSettings)}createListeners(){this.listeners={},this.listeners.view={move:()=>this.trigger("move")},this.view.subscribe(this.listeners.view),this.listeners.texture={update:()=>this.dirty=!0,warning:e=>this.trigger("warning",Object.assign({type:"textures"},e))},e.Texture.subscribe(this.listeners.texture),this.listeners.scene_loader={error:e=>this.trigger("error",Object.assign({type:"scene"},e))},pn.subscribe(this.listeners.scene_loader)}destroyListeners(){this.unsubscribeAll(),this.view.unsubscribe(this.listeners.view),e.Texture.unsubscribe(this.listeners.texture),pn.unsubscribe(this.listeners.scene_loader),this.listeners=null}destroyFeatureSelection(){this.selection&&(this.selection.destroy(),this.selection=null)}resetFeatureSelection(){this.selection=new e.FeatureSelection(this.gl,this.workers,()=>this.building),this.last_render_count=0}resetWorkerFeatureSelection(t=null){this.workers&&e.WorkerBroker.postMessage(this.workers,"self.resetFeatureSelection",t)}getFeatureSelectionMapSize(){return null==this.fetching_selection_map&&(this.fetching_selection_map=e.WorkerBroker.postMessage(this.workers,"self.getFeatureSelectionMapSize").then(e=>(this.fetching_selection_map=null,e.reduce((e,t)=>e+t)))),this.fetching_selection_map}resetTime(){this.start_time=+new Date}updateViewComplete(){!this.render_count_changed&&this.generation===this.last_complete_generation||this.building||this.tile_manager.isLoadingVisibleTiles()||!this.tile_manager.allVisibleTilesLabeled()||(this.tile_manager.updateLabels(),this.last_complete_generation=this.generation,this.trigger("view_complete",{first:!0!==this.view_complete}),this.view_complete=!0)}resetViewComplete(){this.last_complete_generation=null}screenshot({background:e="white"}={}){return this.requestRedraw(),this.media_capture.screenshot({background:e})}startVideoCapture(){return this.requestRedraw(),this.media_capture.startVideoCapture()}stopVideoCapture(){return this.media_capture.stopVideoCapture()}logFirstFrame(){0!==this.last_render_count||this.times.first_frame||(this.times.first_frame=+new Date-this.start_time,e.log("debug",`Scene: initial frame time: ${this.times.first_frame}`))}logFirstBuild(){null==this.times.first_build&&(this.times.first_build=+new Date-this.start_time,e.log("debug",`Scene: initial build time: ${this.times.first_build}`))}}var On;kn.id=0,kn.generation=0;const Rn={map:{},scrollWheelZoom:{},doubleClickZoom:{}};var Cn={leafletLayer:function(t){return function(t){if(void 0!==On)return new On(t);if(e.Thread.is_main){let n,r=t.leaflet||window.L,i=r.GridLayer?r.GridLayer:r.TileLayer,s=i===r.GridLayer?"1.x":"0.7.x",o={};return i===r.TileLayer&&(o._addTile=function(){},o._removeTile=function(){},o._reset=function(){i.prototype._reset.apply(this,arguments),this.scene&&this.scene.container&&this.scene.canvas&&this.scene.container.appendChild(this.scene.canvas)}),Object.assign(o,{initialize(e){e.showDebug=!!e.showDebug,r.setOptions(this,e),this.updateTangramDebugSettings(),this.createScene(),this.hooks={},this._updating_tangram=!1},createScene(){this.scene=kn.create(this.options.scene,{numWorkers:this.options.numWorkers,preUpdate:this.options.preUpdate,postUpdate:this.options.postUpdate,continuousZoom:"1.x"===On.leafletVersion,wrapView:!0!==this.options.noWrap,highDensityDisplay:this.options.highDensityDisplay,logLevel:this.options.logLevel,introspection:this.options.introspection,webGLContextOptions:this.options.webGLContextOptions,disableRenderLoop:this.options.disableRenderLoop})},onAdd(t){this.scene||this.createScene(),i.prototype.onAdd.apply(this,arguments),this.hooks.resize=()=>{this._updating_tangram=!0,this.updateSize(),this._updating_tangram=!1},t.on("resize",this.hooks.resize),this.hooks.move=()=>{if(!this._updating_tangram){this._updating_tangram=!0,this.scene.view.setPanning(!0);var n=t.getCenter();n.zoom=Math.max(Math.min(t.getZoom(),t.getMaxZoom()||e.Geo.default_view_max_zoom),t.getMinZoom()),this.scene.view.setView(n),this._mapLayerCount>1&&this.scene.immediateRedraw(),this._updating_tangram=!1}},t.on("move",this.hooks.move),this.hooks.moveend=()=>{this.scene.view.setPanning(!1),this.scene.requestRedraw()},t.on("moveend",this.hooks.moveend),this.hooks.drag=()=>{this.scene.view.markUserInput()},t.on("drag",this.hooks.drag),this._map_pane_observer=new MutationObserver(e=>{e.forEach(()=>this.reverseTransform())}),this._map_pane_observer.observe(t.getPanes().mapPane,{attributes:!0}),this.modifyScrollWheelBehavior(t),this.modifyZoomBehavior(t),this.trackMapLayerCounts(t),this.setupSelectionEventHandlers(t),this.setSelectionEvents(this.options.events,{radius:this.options.selectionRadius}),this.scene.container=this.getContainer(),this.updateSize(),this.updateView(),this.resizeOnFirstVisible(),this.scene.subscribe({move:this.onTangramViewUpdate.bind(this)}),this.scene.load(this.options.scene,{base_path:this.options.sceneBasePath,file_type:this.options.sceneFileType,blocking:!1}).then(()=>{if(!this.options.attribution)for(const[,e]of Object.entries(this.scene.config.sources))e.attribution&&t.attributionControl.addAttribution(e.attribution);this._updating_tangram=!0,this.updateSize(),this.updateView(),this.reverseTransform(),this._updating_tangram=!1,this.fire("init")}).catch(e=>{this.fire("error",e)})},onRemove(e){i.prototype.onRemove.apply(this,arguments),e.off("layeradd layerremove overlayadd overlayremove",this._updateMapLayerCount),e.off("resize",this.hooks.resize),e.off("move",this.hooks.move),e.off("moveend",this.hooks.moveend),e.off("drag",this.hooks.drag),e.off("click",this.hooks.click),e.off("mousemove",this.hooks.mousemove),e.off("mouseout",this.hooks.mouseout),document.removeEventListener("visibilitychange",this.hooks.visibilitychange),this.hooks={},this._map_pane_observer.disconnect(),this.scene&&(this.scene.destroy(),this.scene=null)},createTile(e){var t=e.x+"/"+e.y+"/"+e.z,n=document.createElement("div");if(n.setAttribute("data-tile-key",t),n.style.width="256px",n.style.height="256px",this.options.showDebug){var r=document.createElement("div");r.textContent=t,r.style.position="absolute",r.style.left=0,r.style.top=0,r.style.color="white",r.style.fontSize="16px",r.style.textOutline="1px #000000",r.style.padding="8px",n.appendChild(r),n.style.borderStyle="solid",n.style.borderColor="white",n.style.borderWidth="1px"}return n},modifyScrollWheelBehavior(e){if(this.scene.view.continuous_zoom&&e.scrollWheelZoom&&!1!==this.options.modifyScrollWheel){e.options.zoomSnap=0;const a=e.scrollWheelZoom.enabled();e.scrollWheelZoom.disable(),r.Browser.chrome||r.Browser.safari?e.scrollWheelZoom._onWheelScroll=function(e){var t=r.DomEvent.getWheelDelta(e);this._delta+=t,this._lastMousePos=this._map.mouseEventToContainerPoint(e),this._performZoom(),r.DomEvent.stop(e)}:e.options.wheelDebounceTime=20;const l=(i=function(e){e._moveEnd(!0),e.fire("viewreset")},s=2*e.options.wheelDebounceTime,function(){var e=this,t=arguments;clearTimeout(o),o=setTimeout(function(){o=null,i.apply(e,t)},s)});Rn.scrollWheelZoom._performZoom||(Rn.scrollWheelZoom._performZoom=e.scrollWheelZoom._performZoom);var t=this;e.scrollWheelZoom._performZoom=function(){if(this._map===t._map){var e=this._map,r=e.getZoom();e._stop();var i=this._delta/(4*this._map.options.wheelPxPerZoomLevel);this._delta=0,r+i>=this._map.getMaxZoom()?i=this._map.getMaxZoom()-r:r+i<=this._map.getMinZoom()&&(i=this._map.getMinZoom()-r),i&&("center"===e.options.scrollWheelZoom?n(t,e.getCenter(),r+i):n(t,this._lastMousePos,r+i),l(e))}else Rn.scrollWheelZoom._performZoom.call(this)},a&&e.scrollWheelZoom.enable()}var i,s,o},modifyZoomBehavior(e){if(this.scene.view.continuous_zoom&&!1!==this.options.modifyZoomBehavior){var t=this;const i=function(t,i,s){e._stop();var o=e._zoom;i=r.latLng(i),s=void 0===s?o:s,s=Math.min(s,e.getMaxZoom());var a=Date.now();return e._moveStart(!0),function l(){var u=(Date.now()-a)/75;u<=1?(e._flyToFrame=r.Util.requestAnimFrame(l,e),n(t,i,o+(s-o)*u)):n(t,i,s)._moveEnd(!0)}.call(e),e};if(e.doubleClickZoom){const n=e.doubleClickZoom.enabled();e.doubleClickZoom.disable(),Rn.doubleClickZoom._onDoubleClick||(Rn.doubleClickZoom._onDoubleClick=e.doubleClickZoom._onDoubleClick),e.doubleClickZoom._onDoubleClick=function(e){if(this._map===t._map){var n=this._map,r=n.getZoom(),s=n.options.zoomDelta,o=e.originalEvent.shiftKey?r-s:r+s;"center"===n.options.doubleClickZoom?i(t,n.getCenter(),o):i(t,n.containerPointToLatLng(e.containerPoint),o)}else Rn.doubleClickZoom._onDoubleClick.call(this,e)},n&&e.doubleClickZoom.enable()}e._zoomAnimated&&(Rn.map._animateZoom||(Rn.map._animateZoom=e._animateZoom),e._animateZoom=function(e,n,s,o){this===t._map?(s&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=n,i(t,e,n)),setTimeout(r.Util.bind(this._onZoomTransitionEnd,this),250)):Rn.map._animateZoom.call(this,e,n,s,o)})}},updateView(){var t=this._map.getCenter();t.zoom=Math.max(Math.min(this._map.getZoom(),this._map.getMaxZoom()||e.Geo.default_view_max_zoom),this._map.getMinZoom()),this.scene.view.setView(t)},updateSize(){var e=this._map.getSize();this.scene.resizeMap(e.x,e.y)},resizeOnFirstVisible(){let e=!0;this.hooks.visibilitychange=()=>{e&&(e=!1,this.updateSize())},document.addEventListener("visibilitychange",this.hooks.visibilitychange)},onTangramViewUpdate(){if(!this._map||this._updating_tangram)return;let e=this._map.getCenter(),t=this.scene.view.center;e.lng===t.lng&&e.lat===t.lat&&this._map.getZoom()===this.scene.view.zoom||(this._updating_tangram=!0,this._map.setView([this.scene.view.center.lat,this.scene.view.center.lng],this.scene.view.zoom,{animate:!1}),this._updating_tangram=!1)},render(){this.scene&&this.scene.update()},reverseTransform(){if(this._map&&this.scene&&this.scene.container){var e=this._map.containerPointToLayerPoint([0,0]);r.DomUtil.setPosition(this.scene.container,e)}},setupSelectionEventHandlers(e){this._selection_events={},this._selection_radius=null,this.hooks.click=e=>{"function"==typeof this._selection_events.click&&this.scene.getFeatureAt(e.containerPoint,{radius:this._selection_radius}).then(t=>{let n=Object.assign({},t,{leaflet_event:e});this._selection_events.click(n)})},e.on("click",this.hooks.click),this.hooks.mousemove=e=>{"function"==typeof this._selection_events.hover&&this.scene.getFeatureAt(e.containerPoint,{radius:this._selection_radius}).then(t=>{let n=Object.assign({},t,{leaflet_event:e});this._selection_events.hover(n)})},e.on("mousemove",this.hooks.mousemove),this.hooks.mouseout=e=>{"function"==typeof this._selection_events.hover&&this._selection_events.hover({changed:!0,leaflet_event:e})},e.on("mouseout",this.hooks.mouseout)},setSelectionEvents(e,{radius:t}={}){this._selection_events=Object.assign(this._selection_events,e),this._selection_radius=void 0!==t?t:this._selection_radius},trackMapLayerCounts(e){this._updateMapLayerCount=()=>{let t=e.getPanes().mapPane.childNodes;this._mapLayerCount=0;for(let e=0;e<t.length;e++)this._mapLayerCount+=t[e].childNodes.length},e.on("layeradd layerremove overlayadd overlayremove",this._updateMapLayerCount),this._updateMapLayerCount()},updateTangramDebugSettings(){e.mergeDebugSettings(this.options.debug||{})}}),n=function(e,t,n){var i=e._map,s=e.scene,o=i.getZoomScale(n),a=i.getSize().divideBy(2),l=(t instanceof r.Point?t:i.latLngToContainerPoint(t)).subtract(a).multiplyBy(1-1/o),u=i.containerPointToLatLng(a.add(l));return s&&s.view.markUserInput(),i._move(u,n,{flyTo:!0})},"function"!=typeof(On=i.extend(o)).remove&&(On.prototype.remove=function(){this._map&&this._map.removeLayer(this),this.fire("remove")}),On.layerBaseClass=i,On.leafletVersion=s,new On(t)}}(t)},debug:{log:e.log,yaml:cn,Utils:e.Utils,Geo:e.Geo,Vector:e.Vector,DataSource:e.DataSource,GLSL:e.GLSL,ShaderProgram:e.ShaderProgram,VertexData:e.VertexData,Texture:e.Texture,Material:e.Material,Light:e.Light,Scene:kn,WorkerBroker:e.WorkerBroker,Task:e.Task,StyleManager:e.StyleManager,StyleParser:e.StyleParser,TileID:e.TileID,Collision:e.Collision,FeatureSelection:e.FeatureSelection,TextCanvas:e.TextCanvas,debugSettings:e.debugSettings},version:e.version};return Cn});try{px.debug.ESM=!0,px.debug.SHA="d0b887d09a3645aad91a18bd3bd0362d74627da3","object"==typeof window&&(window.Tangram=px)}catch(My){}var mx=Object.freeze({__proto__:null});export{yf as API_METHODS,Ll as Accordion,jo as ApiService,hx as AuthPage,No as AuthStore,jl as Button,Fy as CSVUploader,Dg as CameraCreateForm,zg as CameraUpdateForm,Hl as Card,Pc as Checkbox,_l as DartcomAuthProvider,Lo as DartcomMobxProvider,ix as DartcomProviders,zc as DateField,Ul as DeleteButton,lf as DragList,ff as ErrorBoundary,Jb as ExcelUploader,Ic as Form,Nc as FormErrorMessage,Uo as GlobalConfig,Gl as IconButton,pf as Input,dg as LayerButtonsContainer,hg as LayerDatesContainer,Sy as LeafletLayer,jc as List,Ty as Loader,zl as LocalizationProvider,Ry as Modal,Po as ModalStore,Lc as NoData,vf as PanelsNames,Rc as Paragraph,om as PillarCreateForm,ny as PillarUpdateForm,nx as QueryProvider,Do as RootStore,Ag as Select,gf as SourceLayers,zo as StoreContext,km as Tabs,mf as TangramSourceNames,Tm as TrafficSignAddDopButton,B_ as TrafficSignCreateForm,Rm as TrafficSignDopCreateForm,Pm as TrafficSignDopUpdateForm,C_ as TrafficSignPreviewImage,Mm as TrafficSignPreviewTitle,N_ as TrafficSignTable,$_ as TrafficSignUpdateForm,Q_ as TrafficSignalCreateForm,ey as TrafficSignalUpdateForm,Mf as TrafficStatus,ql as UploadButton,bf as _backendUrl,de as _testApiKeys,um as allTrafficSigns,Io as authStore,_g as cameraConfig,yg as cameraMainFields,iy as catIds,rn as copyInformation,Vo as createApiService,vg as defaultCamera,tm as defaultPillar,mm as defaultTrafficSign,_m as defaultTrafficSignDop,pm as defaultTrafficSignDopIds,fm as defaultTrafficSignIds,W_ as defaultTrafficSignal,en as encodeString,mg as getAdminAreaLayers,yy as getAllLayers,_y as getAllPointLayers,gy as getAllPolygonLayers,my as getAllPolylineLayers,vy as getBackendDate,wg as getBackendFixingType,pg as getBuildingLayers,gg as getBuiltupAreaLayers,bg as getCameraLayers,Lg as getCityPOILayers,Vg as getConditionLayers,on as getCoordinateByLatLng,sy as getDefaultPOI,Ug as getFacilityAreaLayers,xg as getFrontendFixingType,Bg as getLanduseAreaLayers,Tf as getLaneMarkingLineLayers,Sf as getLaneMarkingPolyLayers,xy as getLayerBackendDates,by as getLayerFrontendDates,fy as getLayerName,Wg as getLinkLayers,Zg as getNatureFieldLayers,Kg as getNatureForestLayers,Xg as getOceanAreaLayers,Yg as getOneWayLayers,ly as getPOILayers,oy as getPOITypeLayer,kf as getParkingLineLayers,nm as getPillarLayers,uy as getPointAddressLayers,cy as getRailroadLayers,Ef as getRoadPolyLayers,wm as getTrafficSignImgSrc,xm as getTrafficSignLayers,Sm as getTrafficSignTitleByNumber,Am as getTrafficSignTitlesOptions,Z_ as getTrafficSignalLayers,sn as getUniqueKey,tn as getUrlencodedBody,py as getValidLayer,hy as getWaterAreaLayers,dy as getWaterLinkLayers,wf as imagesPath,ug as layerCoordinateSchema,Df as layerDateFormat,Rf as layerDatesFields,lg as layerDatesFieldsSchema,Pf as layerDefaultBackendDates,Cf as layerDefaultFrontendDates,Of as layerServiceIds,cg as layerServiceIdsSchema,_f as loggerService,Mo as modalStore,ky as modalStyle,Em as parseTrafficSignCSVFile,Qg as pillarConfig,em as pillarConnectionFields,Jg as pillarMainFields,tx as queryClient,Fo as rootStore,nn as showSnackbar,Af as sourceUrl,ry as text_source,xf as tile_size,ym as trafficSignConfig,gm as trafficSignDopMainFields,bm as trafficSignDopWords,dm as trafficSignMainFields,vm as trafficSignWords,q_ as trafficSignalConfig,H_ as trafficSignalMainFields,am as trafficSigns,lm as trafficSignsDop,Nf as trafficStatusOptions,If as trafficTitles,Dc as useFormContext,wy as useGetLeafletLayer,Ka as useGetUser,ax as useLogout,ox as useShowErrorSnackbar,sx as useShowSnackbar,lx as useSignIn};
|
|
32
32
|
//# sourceMappingURL=index.esm.js.map
|