mapicgc-gl-js 0.0.80 → 0.0.81

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.
@@ -58725,7 +58725,7 @@ function(n) {
58725
58725
  */
58726
58726
  function(n) {
58727
58727
  function e() {
58728
- return (On.canvg ? Promise.resolve(On.canvg) : import("./index.es-BWyxJuJN-BMkqIbwq.mjs")).catch(function(t) {
58728
+ return (On.canvg ? Promise.resolve(On.canvg) : import("./index.es-BWyxJuJN-CymjIt7T.mjs")).catch(function(t) {
58729
58729
  return Promise.reject(new Error("Could not load canvg: " + t));
58730
58730
  }).then(function(t) {
58731
58731
  return t.default ? t.default : t;
@@ -63947,9 +63947,9 @@ let yh, qf, Ci, _r, nW = class {
63947
63947
  type: "Point",
63948
63948
  coordinates: C
63949
63949
  },
63950
- place_name: A.properties.label,
63950
+ place_name: A.properties.etiqueta,
63951
63951
  properties: A.properties,
63952
- text: A.properties.label,
63952
+ text: A.properties.etiqueta,
63953
63953
  place_type: ["place"],
63954
63954
  center: C
63955
63955
  };
@@ -1,4 +1,4 @@
1
- import { p as Ui } from "./index-58U3KmRv.mjs";
1
+ import { p as Ui } from "./index-Bq_bNMRX.mjs";
2
2
  var Zt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3
3
  function No(i) {
4
4
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
@@ -2579,7 +2579,7 @@ end`};t.events.push(["putFont",function(s){(function(a){var o=a.font,h=a.out,f=a
2579
2579
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t){const e=new this(t);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return i.forEach(a=>e.set(a)),e}static accessor(t){const n=(this[p4]=this[p4]={accessors:{}}).accessors,i=this.prototype;function s(a){const o=Gg(a);n[o]||(jit(i,a),n[o]=!0)}return Se.isArray(t)?t.forEach(s):s(t),this}}bc.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Se.reduceDescriptors(bc.prototype,(r,t)=>{let{value:e}=r,n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[n]=i}}}),Se.freezeMethods(bc);function ox(r,t){const e=this||Vg,n=t||e,i=bc.from(n.headers);let s=n.data;return Se.forEach(r,function(o){s=o.call(e,s,i.normalize(),t?t.status:void 0)}),i.normalize(),s}function g4(r){return!!(r&&r.__CANCEL__)}function jg(r,t,e){En.call(this,r??"canceled",En.ERR_CANCELED,t,e),this.name="CanceledError"}Se.inherits(jg,En,{__CANCEL__:!0});function qit(r,t,e){const n=e.config.validateStatus;!e.status||!n||n(e.status)?r(e):t(new En("Request failed with status code "+e.status,[En.ERR_BAD_REQUEST,En.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}const Kit=Kl.hasStandardBrowserEnv?{write(r,t,e,n,i,s){const a=[r+"="+encodeURIComponent(t)];Se.isNumber(e)&&a.push("expires="+new Date(e).toGMTString()),Se.isString(n)&&a.push("path="+n),Se.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(r){const t=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function $it(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Wit(r,t){return t?r.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):r}function m4(r,t){return r&&!$it(t)?Wit(r,t):t}const Xit=Kl.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let n;function i(s){let a=s;return t&&(e.setAttribute("href",a),a=e.href),e.setAttribute("href",a),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:e.pathname.charAt(0)==="/"?e.pathname:"/"+e.pathname}}return n=i(window.location.href),function(a){const o=Se.isString(a)?i(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}();function Jit(r){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return t&&t[1]||""}function Yit(r,t){r=r||10;const e=new Array(r),n=new Array(r);let i=0,s=0,a;return t=t!==void 0?t:1e3,function(h){const f=Date.now(),m=n[s];a||(a=f),e[i]=h,n[i]=f;let v=s,x=0;for(;v!==i;)x+=e[v++],v=v%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),f-a<t)return;const C=m&&f-m;return C?Math.round(x*1e3/C):void 0}}function y4(r,t){let e=0;const n=Yit(50,250);return i=>{const s=i.loaded,a=i.lengthComputable?i.total:void 0,o=s-e,h=n(o),f=s<=a;e=s;const m={loaded:s,total:a,progress:a?s/a:void 0,bytes:o,rate:h||void 0,estimated:h&&a&&f?(a-s)/h:void 0,event:i};m[t?"download":"upload"]=!0,r(m)}}const ax={http:Iit,xhr:typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(e,n){let i=r.data;const s=bc.from(r.headers).normalize();let{responseType:a,withXSRFToken:o}=r,h;function f(){r.cancelToken&&r.cancelToken.unsubscribe(h),r.signal&&r.signal.removeEventListener("abort",h)}let m;if(Se.isFormData(i)){if(Kl.hasStandardBrowserEnv||Kl.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if((m=s.getContentType())!==!1){const[M,...k]=m?m.split(";").map(Q=>Q.trim()).filter(Boolean):[];s.setContentType([M||"multipart/form-data",...k].join("; "))}}let v=new XMLHttpRequest;if(r.auth){const M=r.auth.username||"",k=r.auth.password?unescape(encodeURIComponent(r.auth.password)):"";s.set("Authorization","Basic "+btoa(M+":"+k))}const x=m4(r.baseURL,r.url);v.open(r.method.toUpperCase(),u4(x,r.params,r.paramsSerializer),!0),v.timeout=r.timeout;function C(){if(!v)return;const M=bc.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),Q={data:!a||a==="text"||a==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:M,config:r,request:v};qit(function(J){e(J),f()},function(J){n(J),f()},Q),v=null}if("onloadend"in v?v.onloadend=C:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(C)},v.onabort=function(){v&&(n(new En("Request aborted",En.ECONNABORTED,r,v)),v=null)},v.onerror=function(){n(new En("Network Error",En.ERR_NETWORK,r,v)),v=null},v.ontimeout=function(){let k=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const Q=r.transitional||h4;r.timeoutErrorMessage&&(k=r.timeoutErrorMessage),n(new En(k,Q.clarifyTimeoutError?En.ETIMEDOUT:En.ECONNABORTED,r,v)),v=null},Kl.hasStandardBrowserEnv&&(o&&Se.isFunction(o)&&(o=o(r)),o||o!==!1&&Xit(x))){const M=r.xsrfHeaderName&&r.xsrfCookieName&&Kit.read(r.xsrfCookieName);M&&s.set(r.xsrfHeaderName,M)}i===void 0&&s.setContentType(null),"setRequestHeader"in v&&Se.forEach(s.toJSON(),function(k,Q){v.setRequestHeader(Q,k)}),Se.isUndefined(r.withCredentials)||(v.withCredentials=!!r.withCredentials),a&&a!=="json"&&(v.responseType=r.responseType),typeof r.onDownloadProgress=="function"&&v.addEventListener("progress",y4(r.onDownloadProgress,!0)),typeof r.onUploadProgress=="function"&&v.upload&&v.upload.addEventListener("progress",y4(r.onUploadProgress)),(r.cancelToken||r.signal)&&(h=M=>{v&&(n(!M||M.type?new jg(null,r,v):M),v.abort(),v=null)},r.cancelToken&&r.cancelToken.subscribe(h),r.signal&&(r.signal.aborted?h():r.signal.addEventListener("abort",h)));const P=Jit(x);if(P&&Kl.protocols.indexOf(P)===-1){n(new En("Unsupported protocol "+P+":",En.ERR_BAD_REQUEST,r));return}v.send(i||null)})}};Se.forEach(ax,(r,t)=>{if(r){try{Object.defineProperty(r,"name",{value:t})}catch{}Object.defineProperty(r,"adapterName",{value:t})}});const _4=r=>`- ${r}`,Zit=r=>Se.isFunction(r)||r===null||r===!1,v4={getAdapter:r=>{r=Se.isArray(r)?r:[r];const{length:t}=r;let e,n;const i={};for(let s=0;s<t;s++){e=r[s];let a;if(n=e,!Zit(e)&&(n=ax[(a=String(e)).toLowerCase()],n===void 0))throw new En(`Unknown adapter '${a}'`);if(n)break;i[a||"#"+s]=n}if(!n){const s=Object.entries(i).map(o=>{let[h,f]=o;return`adapter ${h} `+(f===!1?"is not supported by the environment":"is not available in the build")});let a=t?s.length>1?`since :
2580
2580
  `+s.map(_4).join(`
2581
2581
  `):" "+_4(s[0]):"as no adapter specified";throw new En("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return n},adapters:ax};function cx(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new jg(null,r)}function b4(r){return cx(r),r.headers=bc.from(r.headers),r.data=ox.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),v4.getAdapter(r.adapter||Vg.adapter)(r).then(function(n){return cx(r),n.data=ox.call(r,r.transformResponse,n),n.headers=bc.from(n.headers),n},function(n){return g4(n)||(cx(r),n&&n.response&&(n.response.data=ox.call(r,r.transformResponse,n.response),n.response.headers=bc.from(n.response.headers))),Promise.reject(n)})}const w4=r=>r instanceof bc?{...r}:r;function Df(r,t){t=t||{};const e={};function n(f,m,v){return Se.isPlainObject(f)&&Se.isPlainObject(m)?Se.merge.call({caseless:v},f,m):Se.isPlainObject(m)?Se.merge({},m):Se.isArray(m)?m.slice():m}function i(f,m,v){if(Se.isUndefined(m)){if(!Se.isUndefined(f))return n(void 0,f,v)}else return n(f,m,v)}function s(f,m){if(!Se.isUndefined(m))return n(void 0,m)}function a(f,m){if(Se.isUndefined(m)){if(!Se.isUndefined(f))return n(void 0,f)}else return n(void 0,m)}function o(f,m,v){if(v in t)return n(f,m);if(v in r)return n(void 0,f)}const h={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(f,m)=>i(w4(f),w4(m),!0)};return Se.forEach(Object.keys(Object.assign({},r,t)),function(m){const v=h[m]||i,x=v(r[m],t[m],m);Se.isUndefined(x)&&v!==o||(e[m]=x)}),e}const x4="1.6.8",lx={};["object","boolean","number","function","string","symbol"].forEach((r,t)=>{lx[r]=function(n){return typeof n===r||"a"+(t<1?"n ":" ")+r}});const B4={};lx.transitional=function(t,e,n){function i(s,a){return"[Axios v"+x4+"] Transitional option '"+s+"'"+a+(n?". "+n:"")}return(s,a,o)=>{if(t===!1)throw new En(i(a," has been removed"+(e?" in "+e:"")),En.ERR_DEPRECATED);return e&&!B4[a]&&(B4[a]=!0,console.warn(i(a," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(s,a,o):!0}};function tst(r,t,e){if(typeof r!="object")throw new En("options must be an object",En.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const s=n[i],a=t[s];if(a){const o=r[s],h=o===void 0||a(o,s,r);if(h!==!0)throw new En("option "+s+" must be "+h,En.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new En("Unknown option "+s,En.ERR_BAD_OPTION)}}const ux={assertOptions:tst,validators:lx},HA=ux.validators;class nd{constructor(t){this.defaults=t,this.interceptors={request:new A4,response:new A4}}async request(t,e){try{return await this._request(t,e)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
2582
- `+s):n.stack=s}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Df(this.defaults,e);const{transitional:n,paramsSerializer:i,headers:s}=e;n!==void 0&&ux.assertOptions(n,{silentJSONParsing:HA.transitional(HA.boolean),forcedJSONParsing:HA.transitional(HA.boolean),clarifyTimeoutError:HA.transitional(HA.boolean)},!1),i!=null&&(Se.isFunction(i)?e.paramsSerializer={serialize:i}:ux.assertOptions(i,{encode:HA.function,serialize:HA.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&Se.merge(s.common,s[e.method]);s&&Se.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),e.headers=bc.concat(a,s);const o=[];let h=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(e)===!1||(h=h&&M.synchronous,o.unshift(M.fulfilled,M.rejected))});const f=[];this.interceptors.response.forEach(function(M){f.push(M.fulfilled,M.rejected)});let m,v=0,x;if(!h){const P=[b4.bind(this),void 0];for(P.unshift.apply(P,o),P.push.apply(P,f),x=P.length,m=Promise.resolve(e);v<x;)m=m.then(P[v++],P[v++]);return m}x=o.length;let C=e;for(v=0;v<x;){const P=o[v++],M=o[v++];try{C=P(C)}catch(k){M.call(this,k);break}}try{m=b4.call(this,C)}catch(P){return Promise.reject(P)}for(v=0,x=f.length;v<x;)m=m.then(f[v++],f[v++]);return m}getUri(t){t=Df(this.defaults,t);const e=m4(t.baseURL,t.url);return u4(e,t.params,t.paramsSerializer)}}Se.forEach(["delete","get","head","options"],function(t){nd.prototype[t]=function(e,n){return this.request(Df(n||{},{method:t,url:e,data:(n||{}).data}))}}),Se.forEach(["post","put","patch"],function(t){function e(n){return function(s,a,o){return this.request(Df(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}nd.prototype[t]=e(),nd.prototype[t+"Form"]=e(!0)});class Ax{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(s){e=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(i);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new jg(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new Ax(function(i){t=i}),cancel:t}}}function est(r){return function(e){return r.apply(null,e)}}function rst(r){return Se.isObject(r)&&r.isAxiosError===!0}const hx={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(hx).forEach(r=>{let[t,e]=r;hx[e]=t});function C4(r){const t=new nd(r),e=$P(nd.prototype.request,t);return Se.extend(e,nd.prototype,t,{allOwnKeys:!0}),Se.extend(e,t,null,{allOwnKeys:!0}),e.create=function(i){return C4(Df(r,i))},e}const ds=C4(Vg);ds.Axios=nd,ds.CanceledError=jg,ds.CancelToken=Ax,ds.isCancel=g4,ds.VERSION=x4,ds.toFormData=jy,ds.AxiosError=En,ds.Cancel=ds.CanceledError,ds.all=function(t){return Promise.all(t)},ds.spread=est,ds.isAxiosError=rst,ds.mergeConfig=Df,ds.AxiosHeaders=bc,ds.formToJSON=r=>f4(Se.isHTMLForm(r)?new FormData(r):r),ds.getAdapter=v4.getAdapter,ds.HttpStatusCode=hx,ds.default=ds;const nst="https://tilemaps.icgc.cat/cdn/configs/mapicgc-config.json",ist=5e3;class E4{static async getConfigICGC(){try{const t=await ds.get(nst,{timeout:ist});return t.data?t.data:(console.log("Resposta sense dades:",t),rd)}catch(t){return t.response?(console.error("Error de resposta:",t.response.data),console.error("Codi d'estat:",t.response.status)):t.request?console.error("No s'ha rebut resposta del servidor:",t.request):console.error("Error:",t.message),rd}}}const sst={cobertesSol:{"fill-opacity":["interpolate",["exponential",.5],["zoom"],13.5,1,18,.4],"fill-outline-color":"rgba(0,0, 0, 0)","fill-color":["interpolate",["cubic-bezier",.5,1,1,1],["get","nivell_2"],0,"#ffffff",111,"#ffff00",112,"#ccff33",113,"#af5b15",114,"#808000",115,"#cdcd00",116,"#ffffcc",221,"#33cc33",222,"#66ff33",223,"#689018",224,"#967d5f",225,"#19e61e",226,"#b4ff9b",227,"#aaa500",228,"#c3c3a0",229,"#00ff9b",230,"#ff9632",231,"#282828",232,"#79797a",233,"#f5df78",234,"#3296ff",341,"#ff007d",342,"#ff53cd",343,"#ffa4e2",344,"#ffc8e2",345,"#ffb4b4",346,"#0f3700",347,"#730055",348,"#6200c4",349,"#4a9595",350,"#ff00f0",351,"#adaaca",352,"#ffe6e6",353,"#67629a",354,"#4a466e",355,"#2f2d46",461,"#6f6fff",462,"#0000dc",463,"#000064",464,"#185f94",465,"#12466d",466,"#000080"]}},ost="lines",Ky="labels";let id,qg,ki,Pn,ast=class{constructor(t){E4.getConfigICGC().then(e=>{id={...e.Styles},ki={...e.Layers},qg={...e.Terrains},Pn={...e.defaultOptions},this.initTheMap(t)}).catch(e=>{console.info("Configuracio per defecte",e),id={...rd.Styles},ki={...rd.Layers},qg={...rd.Terrains},Pn={...rd.defaultOptions},this.initTheMap(t)})}initTheMap(t){if(!t)t=Pn.mapOptions;else for(const e in Pn.mapOptions){let n=[Pn.mapOptions.center[0],Pn.mapOptions.center[1]];Pn.mapOptions.center=n,t.hasOwnProperty(e)||(t[e]=Pn.mapOptions[e])}t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new Hs.Map(t),this.map.options=t,this.map.addControl(new Hs.AttributionControl({compact:!0})),this.map.on("load",async()=>{const e=this.map.getStyle().name,n=this.map.options.style;if(window.document.querySelector(".maplibregl-compact-show")){var i=window.document.querySelector(".maplibregl-compact-show");i.classList.remove("maplibregl-compact-show")}this.map.addControl(new jnt({color:n.indexOf("orto")===-1,defaultOptions:Pn}),"bottom-left"),this._dealOrto3dStyle(e)})}addGeocoderICGC(t){try{t===void 0&&(t="top-right");let e={collapsed:!0,marker:!0,popup:!0,showResultMarkers:!0,maplibregl:Hs,showResultsWhileTyping:!0,minLength:2};const n={forwardGeocode:async s=>{const a=[];try{const o=Pn.geocoder.peliasUrl1+encodeURIComponent(s.query)+Pn.geocoder.peliasUrl2,f=await(await fetch(o)).json();for(const m of f.features){const v=m.geometry.coordinates,x={type:"Feature",geometry:{type:"Point",coordinates:v},place_name:m.properties.label,properties:m.properties,text:m.properties.label,place_type:["place"],center:v};a.push(x)}}catch(o){console.error(`Failed to forwardGeocode with error: ${o}`)}return{features:a}}};this.map.addControl(new Gnt(n,e),t);let i=document.getElementsByClassName("maplibregl-ctrl-geocoder--input");i[0].attributes[2].nodeValue="Cerca...",i[0].addEventListener("input",function(s){s.target.value.length>3})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}getStyle(){try{return this.map.getStyle()}catch(t){console.error(`Error getting style: ${t.message}`)}}async loadImage(t){try{return this.map.loadImage(t)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}addImage(t,e){try{return this.map.addImage(t,e)}catch(n){console.error(`Error getting addImage: ${n.message}`)}}getConfigStyles(){try{let t=[];for(const e of id)t.push(e.name);return t}catch(t){console.error(`Error retrieving base styles: ${t.message}`)}}getConfigWMSLayers(){try{let t=[];for(const e in ki.WMS)ki.WMS.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving WMS layers: ${t.message}`)}}getConfigOrtoLayers(){try{let t=[];for(const e in ki.Orto)ki.Orto.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving orto image layers: ${t.message}`)}}getConfigVectorLayers(){try{let t=[];for(const e in ki.Vector)ki.Vector.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vector layers: ${t.message}`)}}getConfigVectorAdminLayers(){try{let t=[];for(const e in ki.VectorAdmin)ki.VectorAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vectorAdmin layers: ${t.message}`)}}getConfigFGBAdminLayers(){try{let t=[];for(const e in ki.FGBAdmin)ki.FGBAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving FGBAdmin layers: ${t.message}`)}}async fetchData(t,e,n){try{(!n||n===void 0)&&(n={type:"line",layout:{visibility:"visible"},paint:{"line-color":"grey","line-width":2},layerPosition:"top"});let i=n.layerPosition;if(t.includes(".fgb"))this.addFGBLayerICGC(t,e,n);else{const a=await(await fetch(t)).json();let o=e,h=this._dealOrderLayer(i),f=a.features[0].geometry.type;f.includes("ine")&&(n!==void 0?this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:n.layout||{},paint:n.paint||{}},h):this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},h)),f.includes("olygon")&&(n!==void 0?this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},h):this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"fill-color":"blue","fill-opacity":.6}},h)),f.includes("oint")&&(n!==void 0?this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},h):this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},h))}}catch(i){console.error(`Error fetching data: ${i.message}`)}}async fetchDataAndMenu(t,e,n,i){try{let s;i!==null?s=i.layerPosition:s=Ky;let a,o=document.getElementById("map");if(document.getElementById("menu-group")?a=document.getElementById("menu-group"):(a=document.createElement("nav"),a.id="menu-group",a.classList.add="filter-group",o.appendChild(a)),a!==null){let h="visible",f=this._dealOrderLayer(s),m;if(t.includes(".fgb")){let x=this._getKeyByUrlFGB(t);x===null&&(x="userFGB");const C=await fetch(t),P={type:"FeatureCollection",features:[]};for await(const k of RS(C.body))P.features.push(k);m=P;let M=e;if(this.map.addSource(M,{type:"geojson",data:P}),t.includes("text"))i!==void 0?this.map.addLayer({id:e,type:"symbol",source:M,layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:h,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f);else{let k=e+"Text";this.map.addLayer({id:k,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:h,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f)}}else m=await(await fetch(t)).json();if(n!=="all"){const x=document.createElement("div");x.id="titleDivMenu",x.textContent=e,a.appendChild(x);const C=document.createElement("div");C.id="titleDivMenuSub",C.textContent=`📂 ${n}`,a.appendChild(C)}let v;if(i.type?v=i.type:v=m.features[0].geometry.type,n==="all")v.includes("ine")&&(i!==void 0?this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},f)),v.includes("olygon")&&(i!==void 0?this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"fill-color":"#0000FF","fill-opacity":0}},f)),v.includes("oint")&&(i!==void 0?this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},f)),v.includes("ymbol")&&(i!==void 0?this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f)),this.addMenuItem(e);else{let x=n;const C={};m.features.forEach(P=>{const M=P.properties[x],k=M+"-userFieldFilter-"+e;M!==null&&(C[k]||(v.includes("ine")&&(i!==void 0?this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint,filter:["==",`${x}`,M]},f):this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"line-color":"black","line-width":2,"line-opacity":1}},f)),v.includes("olygon")&&(i!==void 0?this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:m},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},f):this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"fill-color":"blue","fill-opacity":.6}},f)),v.includes("oint")&&(i!==void 0?this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:m},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},f):this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"circle-color":"red","circle-opacity":.85}},f)),C[k]=!0,this.addMenuItem(k)))})}}}catch(s){console.error(`Error fetching data: ${s.message}`)}}on(t,e){setTimeout(()=>{try{this.map.on(t,e)}catch(n){console.error(`Error adding event ON listener: ${n.message}`)}},500)}getSource(t){try{return this.map.getSource(t)}catch(e){console.error(`Error getting source: ${e.message}`)}}addSource(t,e){try{this.map.addSource(t,e)}catch(n){console.error(`Error adding source: ${n.message}`)}}setStyle(t,e){try{e!==void 0?this.map.setStyle(t,e):this.map.setStyle(t),this.map.on("styledata",()=>{if(window.document.querySelector(".maplibregl-compact-show")){var n=window.document.querySelector(".maplibregl-compact-show");n.classList.remove("maplibregl-compact-show")}this._dealOrto3dStyle(this.map.getStyle().name)})}catch(n){console.error(`Error setting style: ${n.message}`)}}getLayer(t){try{return this.map.getLayer(t)}catch(e){console.error(`Error getting layer: ${e.message}`)}}setFilter(t,e,n){try{return this.map.setFilter(t,e,n)}catch(i){console.error(`Error setting filter: ${i.message}`)}}jumpTo(t){try{this.map.jumpTo(t)}catch(e){console.error(`Error jumping to ${t}: ${e.message}`)}}setLayoutProperty(t,e,n){try{this.map.setLayoutProperty(t,e,n)}catch(i){console.error(`Error setting layout property: ${i.message}`)}}setPaintProperty(t,e,n){try{this.map.setPaintProperty(t,e,n)}catch(i){console.error(`Error setting paint property: ${i.message}`)}}addControl(t,e){try{e===void 0&&(e="top-right"),this.map.addControl(t,e)}catch(n){console.error(`Error adding control: ${n.message}`)}}getZoom(){try{return this.map.getZoom()}catch(t){console.error(`Error getting zoom level: ${t.message}`)}}addMouseCoordControl(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"bottom-left";try{this.map.addControl(new Wnt(t),e)}catch(n){console.error(`Error adding mouse coordinate control: ${n.message}`)}}addGeolocateControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Hs.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),e):this.map.addControl(new Hs.GeolocateControl(t),e)}catch(n){console.error(`Error adding geolocate control: ${n.message}`)}}addFullscreenControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Hs.FullscreenControl({container:HTMLElement}),e):this.map.addControl(new Hs.FullscreenControl(t),e)}catch(n){console.error(`Error adding fullscreen control: ${n.message}`)}}getBounds(){try{return this.map.getBounds()}catch(t){console.error(`Error getting bounds: ${t.message}`)}}getCenter(){try{return this.map.getCenter()}catch(t){console.error(`Error getting center: ${t.message}`)}}setTerrain(t){try{return this.map.setTerrain(t)}catch(e){console.error(`Error setting terrain: ${e.message}`)}}setLayerZoomRange(t,e,n){try{return this.map.setLayerZoomRange(t,e,n)}catch(i){console.error(`Error setting terrain: ${i.message}`)}}getCanvas(){try{return this.map.getCanvas()}catch(t){console.error(`Error getting canvas: ${t.message}`)}}setCenter(t){try{return this.map.setCenter(t)}catch(e){console.error(`Error setting center: ${e.message}`)}}addLayer(t,e){try{this.map.addLayer(t,e)}catch(n){console.error(`Error adding layer: ${n.message}`)}}addLayerGeoJSON(t,e){try{let n=this._dealOrderLayer(e);this.map.addSource(`${t.id}`,{type:"geojson",data:t.data}),this.map.addLayer({id:`${t.id}-layerIcgcMap`,type:t.layerType,source:`${t.id}`,layout:t.layout,paint:t.paint},n)}catch(n){console.error(`Error adding GeoJSON layer: ${n.message}`)}}addLayerWMS(t,e,n){try{let i=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,layout:n.layout,paint:n.paint},i)):(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,paint:{}},i))}catch(i){console.error(`Error adding WMS layer: ${i.message}`)}}removeControl(t){try{this.map.removeControl(t)}catch(e){console.error(`Error removing control: ${e.message}`)}}removeLayer(t){try{this.map.removeLayer(t)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(t){try{this.map.removeSource(t)}catch(e){console.error(`Error removing source: ${e.message}`)}}addLogo(t){try{let e=document.getElementById("map"),n;n=document.createElement("div"),n.id="logos",e.appendChild(n);const i=document.createElement("img");i.src=t.url,i.style.height=t.height;const s=document.getElementById("logos"),a=document.createElement("a");a.id=t.id,a.href=t.href,a.target="_blank",a.style.position="relative",a.style.bottom="1px",a.appendChild(i),s.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(t){try{const e=a=>{this.map.setStyle(a)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="filter-group",n.appendChild(i);const s=document.getElementById("basemap-group");for(const a of t)for(const o of Object.keys(Pn.baseStyles)){const h=Pn.baseStyles[o];if(a===h.url){const f=document.createElement("div");f.className="basemap-item",f.title=h.key,f.style.backgroundImage=`url('${h.image}')`,s.appendChild(f),f.addEventListener("click",()=>e(h.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(t){try{const e=a=>{map.setStyle(a.url)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="basemap-group",n.appendChild(i);const s=document.getElementById("basemap-group");t.forEach(a=>{const o=document.createElement("div");o.className="basemap-item",o.title=a.label,o.style.backgroundImage=`url('${a.image}')`,s.appendChild(o),o.addEventListener("click",()=>e(a))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(t,e,n){try{let i;this.map.on("mouseenter",t,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",t,()=>{this.map.getCanvas().style.cursor=""}),this.map.on("click",s=>{let a=this.map.queryRenderedFeatures(s.point);if(a&&a[0].source.includes(t)){let o=[s.lngLat.lng,s.lngLat.lat];if(e!==void 0&&e.length>0&&e!=="all"){if(e!==null){let h="";e.forEach(f=>{let m=a[0].properties[f];h=h+`<h4>${m}</h4>`}),i=h,this.addPopup(o,i,n)}}else{let h="";for(const f in a[0].properties)h+="<b>"+f+"</b>:"+a[0].properties[f]+"<br>";i=h,this.addPopup(o,i,n)}}})}catch(i){console.error(`Error adding feature query: ${i.message}`)}}addScaleControl(t,e){try{var n=new Hs.ScaleControl(t);this.map.addControl(n,e)}catch(i){console.error(`Error adding scale: ${i.message}`)}}addExportControl(t,e){try{typeof t=="string"&&(e=t,t=void 0),t===void 0&&(t={PageSize:Jh.A4,PageOrientation:Rg.Landscape,Format:ku.PNG,DPI:C2[300],Crosshair:!0,PrintableArea:!0,Local:"ca"},e="top-right"),this.map.addControl(new tnt(t),e)}catch(n){console.error(`Error adding export control: ${n.message}`)}}addMarker(t){try{let e,n;return t.text===void 0?e=new Hs.Marker(t.options).setLngLat(t.coord).addTo(this.map):(n=new Hs.Popup({offset:t.textOffset}).setHTML(t.text),e=new Hs.Marker().setLngLat(t.coord).setPopup(n).addTo(this.map)),e}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(t,e,n){try{return n.image===void 0?new Hs.Popup().setLngLat(t).setHTML(`
2582
+ `+s):n.stack=s}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Df(this.defaults,e);const{transitional:n,paramsSerializer:i,headers:s}=e;n!==void 0&&ux.assertOptions(n,{silentJSONParsing:HA.transitional(HA.boolean),forcedJSONParsing:HA.transitional(HA.boolean),clarifyTimeoutError:HA.transitional(HA.boolean)},!1),i!=null&&(Se.isFunction(i)?e.paramsSerializer={serialize:i}:ux.assertOptions(i,{encode:HA.function,serialize:HA.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&Se.merge(s.common,s[e.method]);s&&Se.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),e.headers=bc.concat(a,s);const o=[];let h=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(e)===!1||(h=h&&M.synchronous,o.unshift(M.fulfilled,M.rejected))});const f=[];this.interceptors.response.forEach(function(M){f.push(M.fulfilled,M.rejected)});let m,v=0,x;if(!h){const P=[b4.bind(this),void 0];for(P.unshift.apply(P,o),P.push.apply(P,f),x=P.length,m=Promise.resolve(e);v<x;)m=m.then(P[v++],P[v++]);return m}x=o.length;let C=e;for(v=0;v<x;){const P=o[v++],M=o[v++];try{C=P(C)}catch(k){M.call(this,k);break}}try{m=b4.call(this,C)}catch(P){return Promise.reject(P)}for(v=0,x=f.length;v<x;)m=m.then(f[v++],f[v++]);return m}getUri(t){t=Df(this.defaults,t);const e=m4(t.baseURL,t.url);return u4(e,t.params,t.paramsSerializer)}}Se.forEach(["delete","get","head","options"],function(t){nd.prototype[t]=function(e,n){return this.request(Df(n||{},{method:t,url:e,data:(n||{}).data}))}}),Se.forEach(["post","put","patch"],function(t){function e(n){return function(s,a,o){return this.request(Df(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}nd.prototype[t]=e(),nd.prototype[t+"Form"]=e(!0)});class Ax{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(s){e=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(i);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new jg(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new Ax(function(i){t=i}),cancel:t}}}function est(r){return function(e){return r.apply(null,e)}}function rst(r){return Se.isObject(r)&&r.isAxiosError===!0}const hx={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(hx).forEach(r=>{let[t,e]=r;hx[e]=t});function C4(r){const t=new nd(r),e=$P(nd.prototype.request,t);return Se.extend(e,nd.prototype,t,{allOwnKeys:!0}),Se.extend(e,t,null,{allOwnKeys:!0}),e.create=function(i){return C4(Df(r,i))},e}const ds=C4(Vg);ds.Axios=nd,ds.CanceledError=jg,ds.CancelToken=Ax,ds.isCancel=g4,ds.VERSION=x4,ds.toFormData=jy,ds.AxiosError=En,ds.Cancel=ds.CanceledError,ds.all=function(t){return Promise.all(t)},ds.spread=est,ds.isAxiosError=rst,ds.mergeConfig=Df,ds.AxiosHeaders=bc,ds.formToJSON=r=>f4(Se.isHTMLForm(r)?new FormData(r):r),ds.getAdapter=v4.getAdapter,ds.HttpStatusCode=hx,ds.default=ds;const nst="https://tilemaps.icgc.cat/cdn/configs/mapicgc-config.json",ist=5e3;class E4{static async getConfigICGC(){try{const t=await ds.get(nst,{timeout:ist});return t.data?t.data:(console.log("Resposta sense dades:",t),rd)}catch(t){return t.response?(console.error("Error de resposta:",t.response.data),console.error("Codi d'estat:",t.response.status)):t.request?console.error("No s'ha rebut resposta del servidor:",t.request):console.error("Error:",t.message),rd}}}const sst={cobertesSol:{"fill-opacity":["interpolate",["exponential",.5],["zoom"],13.5,1,18,.4],"fill-outline-color":"rgba(0,0, 0, 0)","fill-color":["interpolate",["cubic-bezier",.5,1,1,1],["get","nivell_2"],0,"#ffffff",111,"#ffff00",112,"#ccff33",113,"#af5b15",114,"#808000",115,"#cdcd00",116,"#ffffcc",221,"#33cc33",222,"#66ff33",223,"#689018",224,"#967d5f",225,"#19e61e",226,"#b4ff9b",227,"#aaa500",228,"#c3c3a0",229,"#00ff9b",230,"#ff9632",231,"#282828",232,"#79797a",233,"#f5df78",234,"#3296ff",341,"#ff007d",342,"#ff53cd",343,"#ffa4e2",344,"#ffc8e2",345,"#ffb4b4",346,"#0f3700",347,"#730055",348,"#6200c4",349,"#4a9595",350,"#ff00f0",351,"#adaaca",352,"#ffe6e6",353,"#67629a",354,"#4a466e",355,"#2f2d46",461,"#6f6fff",462,"#0000dc",463,"#000064",464,"#185f94",465,"#12466d",466,"#000080"]}},ost="lines",Ky="labels";let id,qg,ki,Pn,ast=class{constructor(t){E4.getConfigICGC().then(e=>{id={...e.Styles},ki={...e.Layers},qg={...e.Terrains},Pn={...e.defaultOptions},this.initTheMap(t)}).catch(e=>{console.info("Configuracio per defecte",e),id={...rd.Styles},ki={...rd.Layers},qg={...rd.Terrains},Pn={...rd.defaultOptions},this.initTheMap(t)})}initTheMap(t){if(!t)t=Pn.mapOptions;else for(const e in Pn.mapOptions){let n=[Pn.mapOptions.center[0],Pn.mapOptions.center[1]];Pn.mapOptions.center=n,t.hasOwnProperty(e)||(t[e]=Pn.mapOptions[e])}t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new Hs.Map(t),this.map.options=t,this.map.addControl(new Hs.AttributionControl({compact:!0})),this.map.on("load",async()=>{const e=this.map.getStyle().name,n=this.map.options.style;if(window.document.querySelector(".maplibregl-compact-show")){var i=window.document.querySelector(".maplibregl-compact-show");i.classList.remove("maplibregl-compact-show")}this.map.addControl(new jnt({color:n.indexOf("orto")===-1,defaultOptions:Pn}),"bottom-left"),this._dealOrto3dStyle(e)})}addGeocoderICGC(t){try{t===void 0&&(t="top-right");let e={collapsed:!0,marker:!0,popup:!0,showResultMarkers:!0,maplibregl:Hs,showResultsWhileTyping:!0,minLength:2};const n={forwardGeocode:async s=>{const a=[];try{const o=Pn.geocoder.peliasUrl1+encodeURIComponent(s.query)+Pn.geocoder.peliasUrl2,f=await(await fetch(o)).json();for(const m of f.features){const v=m.geometry.coordinates,x={type:"Feature",geometry:{type:"Point",coordinates:v},place_name:m.properties.etiqueta,properties:m.properties,text:m.properties.etiqueta,place_type:["place"],center:v};a.push(x)}}catch(o){console.error(`Failed to forwardGeocode with error: ${o}`)}return{features:a}}};this.map.addControl(new Gnt(n,e),t);let i=document.getElementsByClassName("maplibregl-ctrl-geocoder--input");i[0].attributes[2].nodeValue="Cerca...",i[0].addEventListener("input",function(s){s.target.value.length>3})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}getStyle(){try{return this.map.getStyle()}catch(t){console.error(`Error getting style: ${t.message}`)}}async loadImage(t){try{return this.map.loadImage(t)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}addImage(t,e){try{return this.map.addImage(t,e)}catch(n){console.error(`Error getting addImage: ${n.message}`)}}getConfigStyles(){try{let t=[];for(const e of id)t.push(e.name);return t}catch(t){console.error(`Error retrieving base styles: ${t.message}`)}}getConfigWMSLayers(){try{let t=[];for(const e in ki.WMS)ki.WMS.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving WMS layers: ${t.message}`)}}getConfigOrtoLayers(){try{let t=[];for(const e in ki.Orto)ki.Orto.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving orto image layers: ${t.message}`)}}getConfigVectorLayers(){try{let t=[];for(const e in ki.Vector)ki.Vector.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vector layers: ${t.message}`)}}getConfigVectorAdminLayers(){try{let t=[];for(const e in ki.VectorAdmin)ki.VectorAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vectorAdmin layers: ${t.message}`)}}getConfigFGBAdminLayers(){try{let t=[];for(const e in ki.FGBAdmin)ki.FGBAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving FGBAdmin layers: ${t.message}`)}}async fetchData(t,e,n){try{(!n||n===void 0)&&(n={type:"line",layout:{visibility:"visible"},paint:{"line-color":"grey","line-width":2},layerPosition:"top"});let i=n.layerPosition;if(t.includes(".fgb"))this.addFGBLayerICGC(t,e,n);else{const a=await(await fetch(t)).json();let o=e,h=this._dealOrderLayer(i),f=a.features[0].geometry.type;f.includes("ine")&&(n!==void 0?this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:n.layout||{},paint:n.paint||{}},h):this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},h)),f.includes("olygon")&&(n!==void 0?this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},h):this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"fill-color":"blue","fill-opacity":.6}},h)),f.includes("oint")&&(n!==void 0?this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},h):this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},h))}}catch(i){console.error(`Error fetching data: ${i.message}`)}}async fetchDataAndMenu(t,e,n,i){try{let s;i!==null?s=i.layerPosition:s=Ky;let a,o=document.getElementById("map");if(document.getElementById("menu-group")?a=document.getElementById("menu-group"):(a=document.createElement("nav"),a.id="menu-group",a.classList.add="filter-group",o.appendChild(a)),a!==null){let h="visible",f=this._dealOrderLayer(s),m;if(t.includes(".fgb")){let x=this._getKeyByUrlFGB(t);x===null&&(x="userFGB");const C=await fetch(t),P={type:"FeatureCollection",features:[]};for await(const k of RS(C.body))P.features.push(k);m=P;let M=e;if(this.map.addSource(M,{type:"geojson",data:P}),t.includes("text"))i!==void 0?this.map.addLayer({id:e,type:"symbol",source:M,layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:h,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f);else{let k=e+"Text";this.map.addLayer({id:k,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:h,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f)}}else m=await(await fetch(t)).json();if(n!=="all"){const x=document.createElement("div");x.id="titleDivMenu",x.textContent=e,a.appendChild(x);const C=document.createElement("div");C.id="titleDivMenuSub",C.textContent=`📂 ${n}`,a.appendChild(C)}let v;if(i.type?v=i.type:v=m.features[0].geometry.type,n==="all")v.includes("ine")&&(i!==void 0?this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},f)),v.includes("olygon")&&(i!==void 0?this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"fill-color":"#0000FF","fill-opacity":0}},f)),v.includes("oint")&&(i!==void 0?this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},f)),v.includes("ymbol")&&(i!==void 0?this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f)),this.addMenuItem(e);else{let x=n;const C={};m.features.forEach(P=>{const M=P.properties[x],k=M+"-userFieldFilter-"+e;M!==null&&(C[k]||(v.includes("ine")&&(i!==void 0?this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint,filter:["==",`${x}`,M]},f):this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"line-color":"black","line-width":2,"line-opacity":1}},f)),v.includes("olygon")&&(i!==void 0?this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:m},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},f):this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"fill-color":"blue","fill-opacity":.6}},f)),v.includes("oint")&&(i!==void 0?this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:m},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},f):this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"circle-color":"red","circle-opacity":.85}},f)),C[k]=!0,this.addMenuItem(k)))})}}}catch(s){console.error(`Error fetching data: ${s.message}`)}}on(t,e){setTimeout(()=>{try{this.map.on(t,e)}catch(n){console.error(`Error adding event ON listener: ${n.message}`)}},500)}getSource(t){try{return this.map.getSource(t)}catch(e){console.error(`Error getting source: ${e.message}`)}}addSource(t,e){try{this.map.addSource(t,e)}catch(n){console.error(`Error adding source: ${n.message}`)}}setStyle(t,e){try{e!==void 0?this.map.setStyle(t,e):this.map.setStyle(t),this.map.on("styledata",()=>{if(window.document.querySelector(".maplibregl-compact-show")){var n=window.document.querySelector(".maplibregl-compact-show");n.classList.remove("maplibregl-compact-show")}this._dealOrto3dStyle(this.map.getStyle().name)})}catch(n){console.error(`Error setting style: ${n.message}`)}}getLayer(t){try{return this.map.getLayer(t)}catch(e){console.error(`Error getting layer: ${e.message}`)}}setFilter(t,e,n){try{return this.map.setFilter(t,e,n)}catch(i){console.error(`Error setting filter: ${i.message}`)}}jumpTo(t){try{this.map.jumpTo(t)}catch(e){console.error(`Error jumping to ${t}: ${e.message}`)}}setLayoutProperty(t,e,n){try{this.map.setLayoutProperty(t,e,n)}catch(i){console.error(`Error setting layout property: ${i.message}`)}}setPaintProperty(t,e,n){try{this.map.setPaintProperty(t,e,n)}catch(i){console.error(`Error setting paint property: ${i.message}`)}}addControl(t,e){try{e===void 0&&(e="top-right"),this.map.addControl(t,e)}catch(n){console.error(`Error adding control: ${n.message}`)}}getZoom(){try{return this.map.getZoom()}catch(t){console.error(`Error getting zoom level: ${t.message}`)}}addMouseCoordControl(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"bottom-left";try{this.map.addControl(new Wnt(t),e)}catch(n){console.error(`Error adding mouse coordinate control: ${n.message}`)}}addGeolocateControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Hs.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),e):this.map.addControl(new Hs.GeolocateControl(t),e)}catch(n){console.error(`Error adding geolocate control: ${n.message}`)}}addFullscreenControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Hs.FullscreenControl({container:HTMLElement}),e):this.map.addControl(new Hs.FullscreenControl(t),e)}catch(n){console.error(`Error adding fullscreen control: ${n.message}`)}}getBounds(){try{return this.map.getBounds()}catch(t){console.error(`Error getting bounds: ${t.message}`)}}getCenter(){try{return this.map.getCenter()}catch(t){console.error(`Error getting center: ${t.message}`)}}setTerrain(t){try{return this.map.setTerrain(t)}catch(e){console.error(`Error setting terrain: ${e.message}`)}}setLayerZoomRange(t,e,n){try{return this.map.setLayerZoomRange(t,e,n)}catch(i){console.error(`Error setting terrain: ${i.message}`)}}getCanvas(){try{return this.map.getCanvas()}catch(t){console.error(`Error getting canvas: ${t.message}`)}}setCenter(t){try{return this.map.setCenter(t)}catch(e){console.error(`Error setting center: ${e.message}`)}}addLayer(t,e){try{this.map.addLayer(t,e)}catch(n){console.error(`Error adding layer: ${n.message}`)}}addLayerGeoJSON(t,e){try{let n=this._dealOrderLayer(e);this.map.addSource(`${t.id}`,{type:"geojson",data:t.data}),this.map.addLayer({id:`${t.id}-layerIcgcMap`,type:t.layerType,source:`${t.id}`,layout:t.layout,paint:t.paint},n)}catch(n){console.error(`Error adding GeoJSON layer: ${n.message}`)}}addLayerWMS(t,e,n){try{let i=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,layout:n.layout,paint:n.paint},i)):(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,paint:{}},i))}catch(i){console.error(`Error adding WMS layer: ${i.message}`)}}removeControl(t){try{this.map.removeControl(t)}catch(e){console.error(`Error removing control: ${e.message}`)}}removeLayer(t){try{this.map.removeLayer(t)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(t){try{this.map.removeSource(t)}catch(e){console.error(`Error removing source: ${e.message}`)}}addLogo(t){try{let e=document.getElementById("map"),n;n=document.createElement("div"),n.id="logos",e.appendChild(n);const i=document.createElement("img");i.src=t.url,i.style.height=t.height;const s=document.getElementById("logos"),a=document.createElement("a");a.id=t.id,a.href=t.href,a.target="_blank",a.style.position="relative",a.style.bottom="1px",a.appendChild(i),s.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(t){try{const e=a=>{this.map.setStyle(a)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="filter-group",n.appendChild(i);const s=document.getElementById("basemap-group");for(const a of t)for(const o of Object.keys(Pn.baseStyles)){const h=Pn.baseStyles[o];if(a===h.url){const f=document.createElement("div");f.className="basemap-item",f.title=h.key,f.style.backgroundImage=`url('${h.image}')`,s.appendChild(f),f.addEventListener("click",()=>e(h.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(t){try{const e=a=>{map.setStyle(a.url)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="basemap-group",n.appendChild(i);const s=document.getElementById("basemap-group");t.forEach(a=>{const o=document.createElement("div");o.className="basemap-item",o.title=a.label,o.style.backgroundImage=`url('${a.image}')`,s.appendChild(o),o.addEventListener("click",()=>e(a))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(t,e,n){try{let i;this.map.on("mouseenter",t,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",t,()=>{this.map.getCanvas().style.cursor=""}),this.map.on("click",s=>{let a=this.map.queryRenderedFeatures(s.point);if(a&&a[0].source.includes(t)){let o=[s.lngLat.lng,s.lngLat.lat];if(e!==void 0&&e.length>0&&e!=="all"){if(e!==null){let h="";e.forEach(f=>{let m=a[0].properties[f];h=h+`<h4>${m}</h4>`}),i=h,this.addPopup(o,i,n)}}else{let h="";for(const f in a[0].properties)h+="<b>"+f+"</b>:"+a[0].properties[f]+"<br>";i=h,this.addPopup(o,i,n)}}})}catch(i){console.error(`Error adding feature query: ${i.message}`)}}addScaleControl(t,e){try{var n=new Hs.ScaleControl(t);this.map.addControl(n,e)}catch(i){console.error(`Error adding scale: ${i.message}`)}}addExportControl(t,e){try{typeof t=="string"&&(e=t,t=void 0),t===void 0&&(t={PageSize:Jh.A4,PageOrientation:Rg.Landscape,Format:ku.PNG,DPI:C2[300],Crosshair:!0,PrintableArea:!0,Local:"ca"},e="top-right"),this.map.addControl(new tnt(t),e)}catch(n){console.error(`Error adding export control: ${n.message}`)}}addMarker(t){try{let e,n;return t.text===void 0?e=new Hs.Marker(t.options).setLngLat(t.coord).addTo(this.map):(n=new Hs.Popup({offset:t.textOffset}).setHTML(t.text),e=new Hs.Marker().setLngLat(t.coord).setPopup(n).addTo(this.map)),e}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(t,e,n){try{return n.image===void 0?new Hs.Popup().setLngLat(t).setHTML(`
2583
2583
  <div class="popupBody">
2584
2584
  <div class="popupTop">
2585
2585
  ${n.title}
@@ -1,4 +1,4 @@
1
- import { C as p, a as s, M as r } from "./index-58U3KmRv.mjs";
1
+ import { C as p, a as s, M as r } from "./index-Bq_bNMRX.mjs";
2
2
  export {
3
3
  p as CompareMaps,
4
4
  s as Config,
@@ -2579,7 +2579,7 @@ end`};t.events.push(["putFont",function(s){(function(a){var o=a.font,h=a.out,f=a
2579
2579
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t){const e=new this(t);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return i.forEach(a=>e.set(a)),e}static accessor(t){const n=(this[p4]=this[p4]={accessors:{}}).accessors,i=this.prototype;function s(a){const o=Gg(a);n[o]||(jit(i,a),n[o]=!0)}return Se.isArray(t)?t.forEach(s):s(t),this}}bc.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Se.reduceDescriptors(bc.prototype,(r,t)=>{let{value:e}=r,n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[n]=i}}}),Se.freezeMethods(bc);function ox(r,t){const e=this||Vg,n=t||e,i=bc.from(n.headers);let s=n.data;return Se.forEach(r,function(o){s=o.call(e,s,i.normalize(),t?t.status:void 0)}),i.normalize(),s}function g4(r){return!!(r&&r.__CANCEL__)}function jg(r,t,e){En.call(this,r??"canceled",En.ERR_CANCELED,t,e),this.name="CanceledError"}Se.inherits(jg,En,{__CANCEL__:!0});function qit(r,t,e){const n=e.config.validateStatus;!e.status||!n||n(e.status)?r(e):t(new En("Request failed with status code "+e.status,[En.ERR_BAD_REQUEST,En.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}const Kit=Kl.hasStandardBrowserEnv?{write(r,t,e,n,i,s){const a=[r+"="+encodeURIComponent(t)];Se.isNumber(e)&&a.push("expires="+new Date(e).toGMTString()),Se.isString(n)&&a.push("path="+n),Se.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(r){const t=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function $it(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Wit(r,t){return t?r.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):r}function m4(r,t){return r&&!$it(t)?Wit(r,t):t}const Xit=Kl.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let n;function i(s){let a=s;return t&&(e.setAttribute("href",a),a=e.href),e.setAttribute("href",a),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:e.pathname.charAt(0)==="/"?e.pathname:"/"+e.pathname}}return n=i(window.location.href),function(a){const o=Se.isString(a)?i(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}();function Jit(r){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return t&&t[1]||""}function Yit(r,t){r=r||10;const e=new Array(r),n=new Array(r);let i=0,s=0,a;return t=t!==void 0?t:1e3,function(h){const f=Date.now(),m=n[s];a||(a=f),e[i]=h,n[i]=f;let v=s,x=0;for(;v!==i;)x+=e[v++],v=v%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),f-a<t)return;const C=m&&f-m;return C?Math.round(x*1e3/C):void 0}}function y4(r,t){let e=0;const n=Yit(50,250);return i=>{const s=i.loaded,a=i.lengthComputable?i.total:void 0,o=s-e,h=n(o),f=s<=a;e=s;const m={loaded:s,total:a,progress:a?s/a:void 0,bytes:o,rate:h||void 0,estimated:h&&a&&f?(a-s)/h:void 0,event:i};m[t?"download":"upload"]=!0,r(m)}}const ax={http:Iit,xhr:typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(e,n){let i=r.data;const s=bc.from(r.headers).normalize();let{responseType:a,withXSRFToken:o}=r,h;function f(){r.cancelToken&&r.cancelToken.unsubscribe(h),r.signal&&r.signal.removeEventListener("abort",h)}let m;if(Se.isFormData(i)){if(Kl.hasStandardBrowserEnv||Kl.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if((m=s.getContentType())!==!1){const[M,...k]=m?m.split(";").map(Q=>Q.trim()).filter(Boolean):[];s.setContentType([M||"multipart/form-data",...k].join("; "))}}let v=new XMLHttpRequest;if(r.auth){const M=r.auth.username||"",k=r.auth.password?unescape(encodeURIComponent(r.auth.password)):"";s.set("Authorization","Basic "+btoa(M+":"+k))}const x=m4(r.baseURL,r.url);v.open(r.method.toUpperCase(),u4(x,r.params,r.paramsSerializer),!0),v.timeout=r.timeout;function C(){if(!v)return;const M=bc.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),Q={data:!a||a==="text"||a==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:M,config:r,request:v};qit(function(J){e(J),f()},function(J){n(J),f()},Q),v=null}if("onloadend"in v?v.onloadend=C:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(C)},v.onabort=function(){v&&(n(new En("Request aborted",En.ECONNABORTED,r,v)),v=null)},v.onerror=function(){n(new En("Network Error",En.ERR_NETWORK,r,v)),v=null},v.ontimeout=function(){let k=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const Q=r.transitional||h4;r.timeoutErrorMessage&&(k=r.timeoutErrorMessage),n(new En(k,Q.clarifyTimeoutError?En.ETIMEDOUT:En.ECONNABORTED,r,v)),v=null},Kl.hasStandardBrowserEnv&&(o&&Se.isFunction(o)&&(o=o(r)),o||o!==!1&&Xit(x))){const M=r.xsrfHeaderName&&r.xsrfCookieName&&Kit.read(r.xsrfCookieName);M&&s.set(r.xsrfHeaderName,M)}i===void 0&&s.setContentType(null),"setRequestHeader"in v&&Se.forEach(s.toJSON(),function(k,Q){v.setRequestHeader(Q,k)}),Se.isUndefined(r.withCredentials)||(v.withCredentials=!!r.withCredentials),a&&a!=="json"&&(v.responseType=r.responseType),typeof r.onDownloadProgress=="function"&&v.addEventListener("progress",y4(r.onDownloadProgress,!0)),typeof r.onUploadProgress=="function"&&v.upload&&v.upload.addEventListener("progress",y4(r.onUploadProgress)),(r.cancelToken||r.signal)&&(h=M=>{v&&(n(!M||M.type?new jg(null,r,v):M),v.abort(),v=null)},r.cancelToken&&r.cancelToken.subscribe(h),r.signal&&(r.signal.aborted?h():r.signal.addEventListener("abort",h)));const P=Jit(x);if(P&&Kl.protocols.indexOf(P)===-1){n(new En("Unsupported protocol "+P+":",En.ERR_BAD_REQUEST,r));return}v.send(i||null)})}};Se.forEach(ax,(r,t)=>{if(r){try{Object.defineProperty(r,"name",{value:t})}catch{}Object.defineProperty(r,"adapterName",{value:t})}});const _4=r=>`- ${r}`,Zit=r=>Se.isFunction(r)||r===null||r===!1,v4={getAdapter:r=>{r=Se.isArray(r)?r:[r];const{length:t}=r;let e,n;const i={};for(let s=0;s<t;s++){e=r[s];let a;if(n=e,!Zit(e)&&(n=ax[(a=String(e)).toLowerCase()],n===void 0))throw new En(`Unknown adapter '${a}'`);if(n)break;i[a||"#"+s]=n}if(!n){const s=Object.entries(i).map(o=>{let[h,f]=o;return`adapter ${h} `+(f===!1?"is not supported by the environment":"is not available in the build")});let a=t?s.length>1?`since :
2580
2580
  `+s.map(_4).join(`
2581
2581
  `):" "+_4(s[0]):"as no adapter specified";throw new En("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return n},adapters:ax};function cx(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new jg(null,r)}function b4(r){return cx(r),r.headers=bc.from(r.headers),r.data=ox.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),v4.getAdapter(r.adapter||Vg.adapter)(r).then(function(n){return cx(r),n.data=ox.call(r,r.transformResponse,n),n.headers=bc.from(n.headers),n},function(n){return g4(n)||(cx(r),n&&n.response&&(n.response.data=ox.call(r,r.transformResponse,n.response),n.response.headers=bc.from(n.response.headers))),Promise.reject(n)})}const w4=r=>r instanceof bc?{...r}:r;function Df(r,t){t=t||{};const e={};function n(f,m,v){return Se.isPlainObject(f)&&Se.isPlainObject(m)?Se.merge.call({caseless:v},f,m):Se.isPlainObject(m)?Se.merge({},m):Se.isArray(m)?m.slice():m}function i(f,m,v){if(Se.isUndefined(m)){if(!Se.isUndefined(f))return n(void 0,f,v)}else return n(f,m,v)}function s(f,m){if(!Se.isUndefined(m))return n(void 0,m)}function a(f,m){if(Se.isUndefined(m)){if(!Se.isUndefined(f))return n(void 0,f)}else return n(void 0,m)}function o(f,m,v){if(v in t)return n(f,m);if(v in r)return n(void 0,f)}const h={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(f,m)=>i(w4(f),w4(m),!0)};return Se.forEach(Object.keys(Object.assign({},r,t)),function(m){const v=h[m]||i,x=v(r[m],t[m],m);Se.isUndefined(x)&&v!==o||(e[m]=x)}),e}const x4="1.6.8",lx={};["object","boolean","number","function","string","symbol"].forEach((r,t)=>{lx[r]=function(n){return typeof n===r||"a"+(t<1?"n ":" ")+r}});const B4={};lx.transitional=function(t,e,n){function i(s,a){return"[Axios v"+x4+"] Transitional option '"+s+"'"+a+(n?". "+n:"")}return(s,a,o)=>{if(t===!1)throw new En(i(a," has been removed"+(e?" in "+e:"")),En.ERR_DEPRECATED);return e&&!B4[a]&&(B4[a]=!0,console.warn(i(a," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(s,a,o):!0}};function tst(r,t,e){if(typeof r!="object")throw new En("options must be an object",En.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const s=n[i],a=t[s];if(a){const o=r[s],h=o===void 0||a(o,s,r);if(h!==!0)throw new En("option "+s+" must be "+h,En.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new En("Unknown option "+s,En.ERR_BAD_OPTION)}}const ux={assertOptions:tst,validators:lx},HA=ux.validators;class nd{constructor(t){this.defaults=t,this.interceptors={request:new A4,response:new A4}}async request(t,e){try{return await this._request(t,e)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
2582
- `+s):n.stack=s}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Df(this.defaults,e);const{transitional:n,paramsSerializer:i,headers:s}=e;n!==void 0&&ux.assertOptions(n,{silentJSONParsing:HA.transitional(HA.boolean),forcedJSONParsing:HA.transitional(HA.boolean),clarifyTimeoutError:HA.transitional(HA.boolean)},!1),i!=null&&(Se.isFunction(i)?e.paramsSerializer={serialize:i}:ux.assertOptions(i,{encode:HA.function,serialize:HA.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&Se.merge(s.common,s[e.method]);s&&Se.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),e.headers=bc.concat(a,s);const o=[];let h=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(e)===!1||(h=h&&M.synchronous,o.unshift(M.fulfilled,M.rejected))});const f=[];this.interceptors.response.forEach(function(M){f.push(M.fulfilled,M.rejected)});let m,v=0,x;if(!h){const P=[b4.bind(this),void 0];for(P.unshift.apply(P,o),P.push.apply(P,f),x=P.length,m=Promise.resolve(e);v<x;)m=m.then(P[v++],P[v++]);return m}x=o.length;let C=e;for(v=0;v<x;){const P=o[v++],M=o[v++];try{C=P(C)}catch(k){M.call(this,k);break}}try{m=b4.call(this,C)}catch(P){return Promise.reject(P)}for(v=0,x=f.length;v<x;)m=m.then(f[v++],f[v++]);return m}getUri(t){t=Df(this.defaults,t);const e=m4(t.baseURL,t.url);return u4(e,t.params,t.paramsSerializer)}}Se.forEach(["delete","get","head","options"],function(t){nd.prototype[t]=function(e,n){return this.request(Df(n||{},{method:t,url:e,data:(n||{}).data}))}}),Se.forEach(["post","put","patch"],function(t){function e(n){return function(s,a,o){return this.request(Df(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}nd.prototype[t]=e(),nd.prototype[t+"Form"]=e(!0)});class Ax{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(s){e=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(i);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new jg(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new Ax(function(i){t=i}),cancel:t}}}function est(r){return function(e){return r.apply(null,e)}}function rst(r){return Se.isObject(r)&&r.isAxiosError===!0}const hx={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(hx).forEach(r=>{let[t,e]=r;hx[e]=t});function C4(r){const t=new nd(r),e=$P(nd.prototype.request,t);return Se.extend(e,nd.prototype,t,{allOwnKeys:!0}),Se.extend(e,t,null,{allOwnKeys:!0}),e.create=function(i){return C4(Df(r,i))},e}const ds=C4(Vg);ds.Axios=nd,ds.CanceledError=jg,ds.CancelToken=Ax,ds.isCancel=g4,ds.VERSION=x4,ds.toFormData=jy,ds.AxiosError=En,ds.Cancel=ds.CanceledError,ds.all=function(t){return Promise.all(t)},ds.spread=est,ds.isAxiosError=rst,ds.mergeConfig=Df,ds.AxiosHeaders=bc,ds.formToJSON=r=>f4(Se.isHTMLForm(r)?new FormData(r):r),ds.getAdapter=v4.getAdapter,ds.HttpStatusCode=hx,ds.default=ds;const nst="https://tilemaps.icgc.cat/cdn/configs/mapicgc-config.json",ist=5e3;class E4{static async getConfigICGC(){try{const t=await ds.get(nst,{timeout:ist});return t.data?t.data:(console.log("Resposta sense dades:",t),rd)}catch(t){return t.response?(console.error("Error de resposta:",t.response.data),console.error("Codi d'estat:",t.response.status)):t.request?console.error("No s'ha rebut resposta del servidor:",t.request):console.error("Error:",t.message),rd}}}const sst={cobertesSol:{"fill-opacity":["interpolate",["exponential",.5],["zoom"],13.5,1,18,.4],"fill-outline-color":"rgba(0,0, 0, 0)","fill-color":["interpolate",["cubic-bezier",.5,1,1,1],["get","nivell_2"],0,"#ffffff",111,"#ffff00",112,"#ccff33",113,"#af5b15",114,"#808000",115,"#cdcd00",116,"#ffffcc",221,"#33cc33",222,"#66ff33",223,"#689018",224,"#967d5f",225,"#19e61e",226,"#b4ff9b",227,"#aaa500",228,"#c3c3a0",229,"#00ff9b",230,"#ff9632",231,"#282828",232,"#79797a",233,"#f5df78",234,"#3296ff",341,"#ff007d",342,"#ff53cd",343,"#ffa4e2",344,"#ffc8e2",345,"#ffb4b4",346,"#0f3700",347,"#730055",348,"#6200c4",349,"#4a9595",350,"#ff00f0",351,"#adaaca",352,"#ffe6e6",353,"#67629a",354,"#4a466e",355,"#2f2d46",461,"#6f6fff",462,"#0000dc",463,"#000064",464,"#185f94",465,"#12466d",466,"#000080"]}},ost="lines",Ky="labels";let id,qg,ki,Pn,ast=class{constructor(t){E4.getConfigICGC().then(e=>{id={...e.Styles},ki={...e.Layers},qg={...e.Terrains},Pn={...e.defaultOptions},this.initTheMap(t)}).catch(e=>{console.info("Configuracio per defecte",e),id={...rd.Styles},ki={...rd.Layers},qg={...rd.Terrains},Pn={...rd.defaultOptions},this.initTheMap(t)})}initTheMap(t){if(!t)t=Pn.mapOptions;else for(const e in Pn.mapOptions){let n=[Pn.mapOptions.center[0],Pn.mapOptions.center[1]];Pn.mapOptions.center=n,t.hasOwnProperty(e)||(t[e]=Pn.mapOptions[e])}t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new Hs.Map(t),this.map.options=t,this.map.addControl(new Hs.AttributionControl({compact:!0})),this.map.on("load",async()=>{const e=this.map.getStyle().name,n=this.map.options.style;if(window.document.querySelector(".maplibregl-compact-show")){var i=window.document.querySelector(".maplibregl-compact-show");i.classList.remove("maplibregl-compact-show")}this.map.addControl(new jnt({color:n.indexOf("orto")===-1,defaultOptions:Pn}),"bottom-left"),this._dealOrto3dStyle(e)})}addGeocoderICGC(t){try{t===void 0&&(t="top-right");let e={collapsed:!0,marker:!0,popup:!0,showResultMarkers:!0,maplibregl:Hs,showResultsWhileTyping:!0,minLength:2};const n={forwardGeocode:async s=>{const a=[];try{const o=Pn.geocoder.peliasUrl1+encodeURIComponent(s.query)+Pn.geocoder.peliasUrl2,f=await(await fetch(o)).json();for(const m of f.features){const v=m.geometry.coordinates,x={type:"Feature",geometry:{type:"Point",coordinates:v},place_name:m.properties.label,properties:m.properties,text:m.properties.label,place_type:["place"],center:v};a.push(x)}}catch(o){console.error(`Failed to forwardGeocode with error: ${o}`)}return{features:a}}};this.map.addControl(new Gnt(n,e),t);let i=document.getElementsByClassName("maplibregl-ctrl-geocoder--input");i[0].attributes[2].nodeValue="Cerca...",i[0].addEventListener("input",function(s){s.target.value.length>3})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}getStyle(){try{return this.map.getStyle()}catch(t){console.error(`Error getting style: ${t.message}`)}}async loadImage(t){try{return this.map.loadImage(t)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}addImage(t,e){try{return this.map.addImage(t,e)}catch(n){console.error(`Error getting addImage: ${n.message}`)}}getConfigStyles(){try{let t=[];for(const e of id)t.push(e.name);return t}catch(t){console.error(`Error retrieving base styles: ${t.message}`)}}getConfigWMSLayers(){try{let t=[];for(const e in ki.WMS)ki.WMS.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving WMS layers: ${t.message}`)}}getConfigOrtoLayers(){try{let t=[];for(const e in ki.Orto)ki.Orto.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving orto image layers: ${t.message}`)}}getConfigVectorLayers(){try{let t=[];for(const e in ki.Vector)ki.Vector.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vector layers: ${t.message}`)}}getConfigVectorAdminLayers(){try{let t=[];for(const e in ki.VectorAdmin)ki.VectorAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vectorAdmin layers: ${t.message}`)}}getConfigFGBAdminLayers(){try{let t=[];for(const e in ki.FGBAdmin)ki.FGBAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving FGBAdmin layers: ${t.message}`)}}async fetchData(t,e,n){try{(!n||n===void 0)&&(n={type:"line",layout:{visibility:"visible"},paint:{"line-color":"grey","line-width":2},layerPosition:"top"});let i=n.layerPosition;if(t.includes(".fgb"))this.addFGBLayerICGC(t,e,n);else{const a=await(await fetch(t)).json();let o=e,h=this._dealOrderLayer(i),f=a.features[0].geometry.type;f.includes("ine")&&(n!==void 0?this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:n.layout||{},paint:n.paint||{}},h):this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},h)),f.includes("olygon")&&(n!==void 0?this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},h):this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"fill-color":"blue","fill-opacity":.6}},h)),f.includes("oint")&&(n!==void 0?this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},h):this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},h))}}catch(i){console.error(`Error fetching data: ${i.message}`)}}async fetchDataAndMenu(t,e,n,i){try{let s;i!==null?s=i.layerPosition:s=Ky;let a,o=document.getElementById("map");if(document.getElementById("menu-group")?a=document.getElementById("menu-group"):(a=document.createElement("nav"),a.id="menu-group",a.classList.add="filter-group",o.appendChild(a)),a!==null){let h="visible",f=this._dealOrderLayer(s),m;if(t.includes(".fgb")){let x=this._getKeyByUrlFGB(t);x===null&&(x="userFGB");const C=await fetch(t),P={type:"FeatureCollection",features:[]};for await(const k of RS(C.body))P.features.push(k);m=P;let M=e;if(this.map.addSource(M,{type:"geojson",data:P}),t.includes("text"))i!==void 0?this.map.addLayer({id:e,type:"symbol",source:M,layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:h,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f);else{let k=e+"Text";this.map.addLayer({id:k,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:h,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f)}}else m=await(await fetch(t)).json();if(n!=="all"){const x=document.createElement("div");x.id="titleDivMenu",x.textContent=e,a.appendChild(x);const C=document.createElement("div");C.id="titleDivMenuSub",C.textContent=`📂 ${n}`,a.appendChild(C)}let v;if(i.type?v=i.type:v=m.features[0].geometry.type,n==="all")v.includes("ine")&&(i!==void 0?this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},f)),v.includes("olygon")&&(i!==void 0?this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"fill-color":"#0000FF","fill-opacity":0}},f)),v.includes("oint")&&(i!==void 0?this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},f)),v.includes("ymbol")&&(i!==void 0?this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f)),this.addMenuItem(e);else{let x=n;const C={};m.features.forEach(P=>{const M=P.properties[x],k=M+"-userFieldFilter-"+e;M!==null&&(C[k]||(v.includes("ine")&&(i!==void 0?this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint,filter:["==",`${x}`,M]},f):this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"line-color":"black","line-width":2,"line-opacity":1}},f)),v.includes("olygon")&&(i!==void 0?this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:m},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},f):this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"fill-color":"blue","fill-opacity":.6}},f)),v.includes("oint")&&(i!==void 0?this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:m},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},f):this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"circle-color":"red","circle-opacity":.85}},f)),C[k]=!0,this.addMenuItem(k)))})}}}catch(s){console.error(`Error fetching data: ${s.message}`)}}on(t,e){setTimeout(()=>{try{this.map.on(t,e)}catch(n){console.error(`Error adding event ON listener: ${n.message}`)}},500)}getSource(t){try{return this.map.getSource(t)}catch(e){console.error(`Error getting source: ${e.message}`)}}addSource(t,e){try{this.map.addSource(t,e)}catch(n){console.error(`Error adding source: ${n.message}`)}}setStyle(t,e){try{e!==void 0?this.map.setStyle(t,e):this.map.setStyle(t),this.map.on("styledata",()=>{if(window.document.querySelector(".maplibregl-compact-show")){var n=window.document.querySelector(".maplibregl-compact-show");n.classList.remove("maplibregl-compact-show")}this._dealOrto3dStyle(this.map.getStyle().name)})}catch(n){console.error(`Error setting style: ${n.message}`)}}getLayer(t){try{return this.map.getLayer(t)}catch(e){console.error(`Error getting layer: ${e.message}`)}}setFilter(t,e,n){try{return this.map.setFilter(t,e,n)}catch(i){console.error(`Error setting filter: ${i.message}`)}}jumpTo(t){try{this.map.jumpTo(t)}catch(e){console.error(`Error jumping to ${t}: ${e.message}`)}}setLayoutProperty(t,e,n){try{this.map.setLayoutProperty(t,e,n)}catch(i){console.error(`Error setting layout property: ${i.message}`)}}setPaintProperty(t,e,n){try{this.map.setPaintProperty(t,e,n)}catch(i){console.error(`Error setting paint property: ${i.message}`)}}addControl(t,e){try{e===void 0&&(e="top-right"),this.map.addControl(t,e)}catch(n){console.error(`Error adding control: ${n.message}`)}}getZoom(){try{return this.map.getZoom()}catch(t){console.error(`Error getting zoom level: ${t.message}`)}}addMouseCoordControl(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"bottom-left";try{this.map.addControl(new Wnt(t),e)}catch(n){console.error(`Error adding mouse coordinate control: ${n.message}`)}}addGeolocateControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Hs.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),e):this.map.addControl(new Hs.GeolocateControl(t),e)}catch(n){console.error(`Error adding geolocate control: ${n.message}`)}}addFullscreenControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Hs.FullscreenControl({container:HTMLElement}),e):this.map.addControl(new Hs.FullscreenControl(t),e)}catch(n){console.error(`Error adding fullscreen control: ${n.message}`)}}getBounds(){try{return this.map.getBounds()}catch(t){console.error(`Error getting bounds: ${t.message}`)}}getCenter(){try{return this.map.getCenter()}catch(t){console.error(`Error getting center: ${t.message}`)}}setTerrain(t){try{return this.map.setTerrain(t)}catch(e){console.error(`Error setting terrain: ${e.message}`)}}setLayerZoomRange(t,e,n){try{return this.map.setLayerZoomRange(t,e,n)}catch(i){console.error(`Error setting terrain: ${i.message}`)}}getCanvas(){try{return this.map.getCanvas()}catch(t){console.error(`Error getting canvas: ${t.message}`)}}setCenter(t){try{return this.map.setCenter(t)}catch(e){console.error(`Error setting center: ${e.message}`)}}addLayer(t,e){try{this.map.addLayer(t,e)}catch(n){console.error(`Error adding layer: ${n.message}`)}}addLayerGeoJSON(t,e){try{let n=this._dealOrderLayer(e);this.map.addSource(`${t.id}`,{type:"geojson",data:t.data}),this.map.addLayer({id:`${t.id}-layerIcgcMap`,type:t.layerType,source:`${t.id}`,layout:t.layout,paint:t.paint},n)}catch(n){console.error(`Error adding GeoJSON layer: ${n.message}`)}}addLayerWMS(t,e,n){try{let i=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,layout:n.layout,paint:n.paint},i)):(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,paint:{}},i))}catch(i){console.error(`Error adding WMS layer: ${i.message}`)}}removeControl(t){try{this.map.removeControl(t)}catch(e){console.error(`Error removing control: ${e.message}`)}}removeLayer(t){try{this.map.removeLayer(t)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(t){try{this.map.removeSource(t)}catch(e){console.error(`Error removing source: ${e.message}`)}}addLogo(t){try{let e=document.getElementById("map"),n;n=document.createElement("div"),n.id="logos",e.appendChild(n);const i=document.createElement("img");i.src=t.url,i.style.height=t.height;const s=document.getElementById("logos"),a=document.createElement("a");a.id=t.id,a.href=t.href,a.target="_blank",a.style.position="relative",a.style.bottom="1px",a.appendChild(i),s.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(t){try{const e=a=>{this.map.setStyle(a)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="filter-group",n.appendChild(i);const s=document.getElementById("basemap-group");for(const a of t)for(const o of Object.keys(Pn.baseStyles)){const h=Pn.baseStyles[o];if(a===h.url){const f=document.createElement("div");f.className="basemap-item",f.title=h.key,f.style.backgroundImage=`url('${h.image}')`,s.appendChild(f),f.addEventListener("click",()=>e(h.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(t){try{const e=a=>{map.setStyle(a.url)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="basemap-group",n.appendChild(i);const s=document.getElementById("basemap-group");t.forEach(a=>{const o=document.createElement("div");o.className="basemap-item",o.title=a.label,o.style.backgroundImage=`url('${a.image}')`,s.appendChild(o),o.addEventListener("click",()=>e(a))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(t,e,n){try{let i;this.map.on("mouseenter",t,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",t,()=>{this.map.getCanvas().style.cursor=""}),this.map.on("click",s=>{let a=this.map.queryRenderedFeatures(s.point);if(a&&a[0].source.includes(t)){let o=[s.lngLat.lng,s.lngLat.lat];if(e!==void 0&&e.length>0&&e!=="all"){if(e!==null){let h="";e.forEach(f=>{let m=a[0].properties[f];h=h+`<h4>${m}</h4>`}),i=h,this.addPopup(o,i,n)}}else{let h="";for(const f in a[0].properties)h+="<b>"+f+"</b>:"+a[0].properties[f]+"<br>";i=h,this.addPopup(o,i,n)}}})}catch(i){console.error(`Error adding feature query: ${i.message}`)}}addScaleControl(t,e){try{var n=new Hs.ScaleControl(t);this.map.addControl(n,e)}catch(i){console.error(`Error adding scale: ${i.message}`)}}addExportControl(t,e){try{typeof t=="string"&&(e=t,t=void 0),t===void 0&&(t={PageSize:Jh.A4,PageOrientation:Rg.Landscape,Format:ku.PNG,DPI:C2[300],Crosshair:!0,PrintableArea:!0,Local:"ca"},e="top-right"),this.map.addControl(new tnt(t),e)}catch(n){console.error(`Error adding export control: ${n.message}`)}}addMarker(t){try{let e,n;return t.text===void 0?e=new Hs.Marker(t.options).setLngLat(t.coord).addTo(this.map):(n=new Hs.Popup({offset:t.textOffset}).setHTML(t.text),e=new Hs.Marker().setLngLat(t.coord).setPopup(n).addTo(this.map)),e}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(t,e,n){try{return n.image===void 0?new Hs.Popup().setLngLat(t).setHTML(`
2582
+ `+s):n.stack=s}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Df(this.defaults,e);const{transitional:n,paramsSerializer:i,headers:s}=e;n!==void 0&&ux.assertOptions(n,{silentJSONParsing:HA.transitional(HA.boolean),forcedJSONParsing:HA.transitional(HA.boolean),clarifyTimeoutError:HA.transitional(HA.boolean)},!1),i!=null&&(Se.isFunction(i)?e.paramsSerializer={serialize:i}:ux.assertOptions(i,{encode:HA.function,serialize:HA.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&Se.merge(s.common,s[e.method]);s&&Se.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),e.headers=bc.concat(a,s);const o=[];let h=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(e)===!1||(h=h&&M.synchronous,o.unshift(M.fulfilled,M.rejected))});const f=[];this.interceptors.response.forEach(function(M){f.push(M.fulfilled,M.rejected)});let m,v=0,x;if(!h){const P=[b4.bind(this),void 0];for(P.unshift.apply(P,o),P.push.apply(P,f),x=P.length,m=Promise.resolve(e);v<x;)m=m.then(P[v++],P[v++]);return m}x=o.length;let C=e;for(v=0;v<x;){const P=o[v++],M=o[v++];try{C=P(C)}catch(k){M.call(this,k);break}}try{m=b4.call(this,C)}catch(P){return Promise.reject(P)}for(v=0,x=f.length;v<x;)m=m.then(f[v++],f[v++]);return m}getUri(t){t=Df(this.defaults,t);const e=m4(t.baseURL,t.url);return u4(e,t.params,t.paramsSerializer)}}Se.forEach(["delete","get","head","options"],function(t){nd.prototype[t]=function(e,n){return this.request(Df(n||{},{method:t,url:e,data:(n||{}).data}))}}),Se.forEach(["post","put","patch"],function(t){function e(n){return function(s,a,o){return this.request(Df(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}nd.prototype[t]=e(),nd.prototype[t+"Form"]=e(!0)});class Ax{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(s){e=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(i);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new jg(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new Ax(function(i){t=i}),cancel:t}}}function est(r){return function(e){return r.apply(null,e)}}function rst(r){return Se.isObject(r)&&r.isAxiosError===!0}const hx={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(hx).forEach(r=>{let[t,e]=r;hx[e]=t});function C4(r){const t=new nd(r),e=$P(nd.prototype.request,t);return Se.extend(e,nd.prototype,t,{allOwnKeys:!0}),Se.extend(e,t,null,{allOwnKeys:!0}),e.create=function(i){return C4(Df(r,i))},e}const ds=C4(Vg);ds.Axios=nd,ds.CanceledError=jg,ds.CancelToken=Ax,ds.isCancel=g4,ds.VERSION=x4,ds.toFormData=jy,ds.AxiosError=En,ds.Cancel=ds.CanceledError,ds.all=function(t){return Promise.all(t)},ds.spread=est,ds.isAxiosError=rst,ds.mergeConfig=Df,ds.AxiosHeaders=bc,ds.formToJSON=r=>f4(Se.isHTMLForm(r)?new FormData(r):r),ds.getAdapter=v4.getAdapter,ds.HttpStatusCode=hx,ds.default=ds;const nst="https://tilemaps.icgc.cat/cdn/configs/mapicgc-config.json",ist=5e3;class E4{static async getConfigICGC(){try{const t=await ds.get(nst,{timeout:ist});return t.data?t.data:(console.log("Resposta sense dades:",t),rd)}catch(t){return t.response?(console.error("Error de resposta:",t.response.data),console.error("Codi d'estat:",t.response.status)):t.request?console.error("No s'ha rebut resposta del servidor:",t.request):console.error("Error:",t.message),rd}}}const sst={cobertesSol:{"fill-opacity":["interpolate",["exponential",.5],["zoom"],13.5,1,18,.4],"fill-outline-color":"rgba(0,0, 0, 0)","fill-color":["interpolate",["cubic-bezier",.5,1,1,1],["get","nivell_2"],0,"#ffffff",111,"#ffff00",112,"#ccff33",113,"#af5b15",114,"#808000",115,"#cdcd00",116,"#ffffcc",221,"#33cc33",222,"#66ff33",223,"#689018",224,"#967d5f",225,"#19e61e",226,"#b4ff9b",227,"#aaa500",228,"#c3c3a0",229,"#00ff9b",230,"#ff9632",231,"#282828",232,"#79797a",233,"#f5df78",234,"#3296ff",341,"#ff007d",342,"#ff53cd",343,"#ffa4e2",344,"#ffc8e2",345,"#ffb4b4",346,"#0f3700",347,"#730055",348,"#6200c4",349,"#4a9595",350,"#ff00f0",351,"#adaaca",352,"#ffe6e6",353,"#67629a",354,"#4a466e",355,"#2f2d46",461,"#6f6fff",462,"#0000dc",463,"#000064",464,"#185f94",465,"#12466d",466,"#000080"]}},ost="lines",Ky="labels";let id,qg,ki,Pn,ast=class{constructor(t){E4.getConfigICGC().then(e=>{id={...e.Styles},ki={...e.Layers},qg={...e.Terrains},Pn={...e.defaultOptions},this.initTheMap(t)}).catch(e=>{console.info("Configuracio per defecte",e),id={...rd.Styles},ki={...rd.Layers},qg={...rd.Terrains},Pn={...rd.defaultOptions},this.initTheMap(t)})}initTheMap(t){if(!t)t=Pn.mapOptions;else for(const e in Pn.mapOptions){let n=[Pn.mapOptions.center[0],Pn.mapOptions.center[1]];Pn.mapOptions.center=n,t.hasOwnProperty(e)||(t[e]=Pn.mapOptions[e])}t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new Hs.Map(t),this.map.options=t,this.map.addControl(new Hs.AttributionControl({compact:!0})),this.map.on("load",async()=>{const e=this.map.getStyle().name,n=this.map.options.style;if(window.document.querySelector(".maplibregl-compact-show")){var i=window.document.querySelector(".maplibregl-compact-show");i.classList.remove("maplibregl-compact-show")}this.map.addControl(new jnt({color:n.indexOf("orto")===-1,defaultOptions:Pn}),"bottom-left"),this._dealOrto3dStyle(e)})}addGeocoderICGC(t){try{t===void 0&&(t="top-right");let e={collapsed:!0,marker:!0,popup:!0,showResultMarkers:!0,maplibregl:Hs,showResultsWhileTyping:!0,minLength:2};const n={forwardGeocode:async s=>{const a=[];try{const o=Pn.geocoder.peliasUrl1+encodeURIComponent(s.query)+Pn.geocoder.peliasUrl2,f=await(await fetch(o)).json();for(const m of f.features){const v=m.geometry.coordinates,x={type:"Feature",geometry:{type:"Point",coordinates:v},place_name:m.properties.etiqueta,properties:m.properties,text:m.properties.etiqueta,place_type:["place"],center:v};a.push(x)}}catch(o){console.error(`Failed to forwardGeocode with error: ${o}`)}return{features:a}}};this.map.addControl(new Gnt(n,e),t);let i=document.getElementsByClassName("maplibregl-ctrl-geocoder--input");i[0].attributes[2].nodeValue="Cerca...",i[0].addEventListener("input",function(s){s.target.value.length>3})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}getStyle(){try{return this.map.getStyle()}catch(t){console.error(`Error getting style: ${t.message}`)}}async loadImage(t){try{return this.map.loadImage(t)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}addImage(t,e){try{return this.map.addImage(t,e)}catch(n){console.error(`Error getting addImage: ${n.message}`)}}getConfigStyles(){try{let t=[];for(const e of id)t.push(e.name);return t}catch(t){console.error(`Error retrieving base styles: ${t.message}`)}}getConfigWMSLayers(){try{let t=[];for(const e in ki.WMS)ki.WMS.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving WMS layers: ${t.message}`)}}getConfigOrtoLayers(){try{let t=[];for(const e in ki.Orto)ki.Orto.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving orto image layers: ${t.message}`)}}getConfigVectorLayers(){try{let t=[];for(const e in ki.Vector)ki.Vector.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vector layers: ${t.message}`)}}getConfigVectorAdminLayers(){try{let t=[];for(const e in ki.VectorAdmin)ki.VectorAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vectorAdmin layers: ${t.message}`)}}getConfigFGBAdminLayers(){try{let t=[];for(const e in ki.FGBAdmin)ki.FGBAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving FGBAdmin layers: ${t.message}`)}}async fetchData(t,e,n){try{(!n||n===void 0)&&(n={type:"line",layout:{visibility:"visible"},paint:{"line-color":"grey","line-width":2},layerPosition:"top"});let i=n.layerPosition;if(t.includes(".fgb"))this.addFGBLayerICGC(t,e,n);else{const a=await(await fetch(t)).json();let o=e,h=this._dealOrderLayer(i),f=a.features[0].geometry.type;f.includes("ine")&&(n!==void 0?this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:n.layout||{},paint:n.paint||{}},h):this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},h)),f.includes("olygon")&&(n!==void 0?this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},h):this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"fill-color":"blue","fill-opacity":.6}},h)),f.includes("oint")&&(n!==void 0?this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},h):this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},h))}}catch(i){console.error(`Error fetching data: ${i.message}`)}}async fetchDataAndMenu(t,e,n,i){try{let s;i!==null?s=i.layerPosition:s=Ky;let a,o=document.getElementById("map");if(document.getElementById("menu-group")?a=document.getElementById("menu-group"):(a=document.createElement("nav"),a.id="menu-group",a.classList.add="filter-group",o.appendChild(a)),a!==null){let h="visible",f=this._dealOrderLayer(s),m;if(t.includes(".fgb")){let x=this._getKeyByUrlFGB(t);x===null&&(x="userFGB");const C=await fetch(t),P={type:"FeatureCollection",features:[]};for await(const k of RS(C.body))P.features.push(k);m=P;let M=e;if(this.map.addSource(M,{type:"geojson",data:P}),t.includes("text"))i!==void 0?this.map.addLayer({id:e,type:"symbol",source:M,layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:h,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f);else{let k=e+"Text";this.map.addLayer({id:k,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:h,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f)}}else m=await(await fetch(t)).json();if(n!=="all"){const x=document.createElement("div");x.id="titleDivMenu",x.textContent=e,a.appendChild(x);const C=document.createElement("div");C.id="titleDivMenuSub",C.textContent=`📂 ${n}`,a.appendChild(C)}let v;if(i.type?v=i.type:v=m.features[0].geometry.type,n==="all")v.includes("ine")&&(i!==void 0?this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},f)),v.includes("olygon")&&(i!==void 0?this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"fill-color":"#0000FF","fill-opacity":0}},f)),v.includes("oint")&&(i!==void 0?this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},f)),v.includes("ymbol")&&(i!==void 0?this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint},f):this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:m},layout:{visibility:"visible"},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},f)),this.addMenuItem(e);else{let x=n;const C={};m.features.forEach(P=>{const M=P.properties[x],k=M+"-userFieldFilter-"+e;M!==null&&(C[k]||(v.includes("ine")&&(i!==void 0?this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:m},layout:i.layout,paint:i.paint,filter:["==",`${x}`,M]},f):this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"line-color":"black","line-width":2,"line-opacity":1}},f)),v.includes("olygon")&&(i!==void 0?this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:m},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},f):this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"fill-color":"blue","fill-opacity":.6}},f)),v.includes("oint")&&(i!==void 0?this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:m},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},f):this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:m},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"circle-color":"red","circle-opacity":.85}},f)),C[k]=!0,this.addMenuItem(k)))})}}}catch(s){console.error(`Error fetching data: ${s.message}`)}}on(t,e){setTimeout(()=>{try{this.map.on(t,e)}catch(n){console.error(`Error adding event ON listener: ${n.message}`)}},500)}getSource(t){try{return this.map.getSource(t)}catch(e){console.error(`Error getting source: ${e.message}`)}}addSource(t,e){try{this.map.addSource(t,e)}catch(n){console.error(`Error adding source: ${n.message}`)}}setStyle(t,e){try{e!==void 0?this.map.setStyle(t,e):this.map.setStyle(t),this.map.on("styledata",()=>{if(window.document.querySelector(".maplibregl-compact-show")){var n=window.document.querySelector(".maplibregl-compact-show");n.classList.remove("maplibregl-compact-show")}this._dealOrto3dStyle(this.map.getStyle().name)})}catch(n){console.error(`Error setting style: ${n.message}`)}}getLayer(t){try{return this.map.getLayer(t)}catch(e){console.error(`Error getting layer: ${e.message}`)}}setFilter(t,e,n){try{return this.map.setFilter(t,e,n)}catch(i){console.error(`Error setting filter: ${i.message}`)}}jumpTo(t){try{this.map.jumpTo(t)}catch(e){console.error(`Error jumping to ${t}: ${e.message}`)}}setLayoutProperty(t,e,n){try{this.map.setLayoutProperty(t,e,n)}catch(i){console.error(`Error setting layout property: ${i.message}`)}}setPaintProperty(t,e,n){try{this.map.setPaintProperty(t,e,n)}catch(i){console.error(`Error setting paint property: ${i.message}`)}}addControl(t,e){try{e===void 0&&(e="top-right"),this.map.addControl(t,e)}catch(n){console.error(`Error adding control: ${n.message}`)}}getZoom(){try{return this.map.getZoom()}catch(t){console.error(`Error getting zoom level: ${t.message}`)}}addMouseCoordControl(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"bottom-left";try{this.map.addControl(new Wnt(t),e)}catch(n){console.error(`Error adding mouse coordinate control: ${n.message}`)}}addGeolocateControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Hs.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),e):this.map.addControl(new Hs.GeolocateControl(t),e)}catch(n){console.error(`Error adding geolocate control: ${n.message}`)}}addFullscreenControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Hs.FullscreenControl({container:HTMLElement}),e):this.map.addControl(new Hs.FullscreenControl(t),e)}catch(n){console.error(`Error adding fullscreen control: ${n.message}`)}}getBounds(){try{return this.map.getBounds()}catch(t){console.error(`Error getting bounds: ${t.message}`)}}getCenter(){try{return this.map.getCenter()}catch(t){console.error(`Error getting center: ${t.message}`)}}setTerrain(t){try{return this.map.setTerrain(t)}catch(e){console.error(`Error setting terrain: ${e.message}`)}}setLayerZoomRange(t,e,n){try{return this.map.setLayerZoomRange(t,e,n)}catch(i){console.error(`Error setting terrain: ${i.message}`)}}getCanvas(){try{return this.map.getCanvas()}catch(t){console.error(`Error getting canvas: ${t.message}`)}}setCenter(t){try{return this.map.setCenter(t)}catch(e){console.error(`Error setting center: ${e.message}`)}}addLayer(t,e){try{this.map.addLayer(t,e)}catch(n){console.error(`Error adding layer: ${n.message}`)}}addLayerGeoJSON(t,e){try{let n=this._dealOrderLayer(e);this.map.addSource(`${t.id}`,{type:"geojson",data:t.data}),this.map.addLayer({id:`${t.id}-layerIcgcMap`,type:t.layerType,source:`${t.id}`,layout:t.layout,paint:t.paint},n)}catch(n){console.error(`Error adding GeoJSON layer: ${n.message}`)}}addLayerWMS(t,e,n){try{let i=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,layout:n.layout,paint:n.paint},i)):(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,paint:{}},i))}catch(i){console.error(`Error adding WMS layer: ${i.message}`)}}removeControl(t){try{this.map.removeControl(t)}catch(e){console.error(`Error removing control: ${e.message}`)}}removeLayer(t){try{this.map.removeLayer(t)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(t){try{this.map.removeSource(t)}catch(e){console.error(`Error removing source: ${e.message}`)}}addLogo(t){try{let e=document.getElementById("map"),n;n=document.createElement("div"),n.id="logos",e.appendChild(n);const i=document.createElement("img");i.src=t.url,i.style.height=t.height;const s=document.getElementById("logos"),a=document.createElement("a");a.id=t.id,a.href=t.href,a.target="_blank",a.style.position="relative",a.style.bottom="1px",a.appendChild(i),s.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(t){try{const e=a=>{this.map.setStyle(a)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="filter-group",n.appendChild(i);const s=document.getElementById("basemap-group");for(const a of t)for(const o of Object.keys(Pn.baseStyles)){const h=Pn.baseStyles[o];if(a===h.url){const f=document.createElement("div");f.className="basemap-item",f.title=h.key,f.style.backgroundImage=`url('${h.image}')`,s.appendChild(f),f.addEventListener("click",()=>e(h.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(t){try{const e=a=>{map.setStyle(a.url)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="basemap-group",n.appendChild(i);const s=document.getElementById("basemap-group");t.forEach(a=>{const o=document.createElement("div");o.className="basemap-item",o.title=a.label,o.style.backgroundImage=`url('${a.image}')`,s.appendChild(o),o.addEventListener("click",()=>e(a))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(t,e,n){try{let i;this.map.on("mouseenter",t,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",t,()=>{this.map.getCanvas().style.cursor=""}),this.map.on("click",s=>{let a=this.map.queryRenderedFeatures(s.point);if(a&&a[0].source.includes(t)){let o=[s.lngLat.lng,s.lngLat.lat];if(e!==void 0&&e.length>0&&e!=="all"){if(e!==null){let h="";e.forEach(f=>{let m=a[0].properties[f];h=h+`<h4>${m}</h4>`}),i=h,this.addPopup(o,i,n)}}else{let h="";for(const f in a[0].properties)h+="<b>"+f+"</b>:"+a[0].properties[f]+"<br>";i=h,this.addPopup(o,i,n)}}})}catch(i){console.error(`Error adding feature query: ${i.message}`)}}addScaleControl(t,e){try{var n=new Hs.ScaleControl(t);this.map.addControl(n,e)}catch(i){console.error(`Error adding scale: ${i.message}`)}}addExportControl(t,e){try{typeof t=="string"&&(e=t,t=void 0),t===void 0&&(t={PageSize:Jh.A4,PageOrientation:Rg.Landscape,Format:ku.PNG,DPI:C2[300],Crosshair:!0,PrintableArea:!0,Local:"ca"},e="top-right"),this.map.addControl(new tnt(t),e)}catch(n){console.error(`Error adding export control: ${n.message}`)}}addMarker(t){try{let e,n;return t.text===void 0?e=new Hs.Marker(t.options).setLngLat(t.coord).addTo(this.map):(n=new Hs.Popup({offset:t.textOffset}).setHTML(t.text),e=new Hs.Marker().setLngLat(t.coord).setPopup(n).addTo(this.map)),e}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(t,e,n){try{return n.image===void 0?new Hs.Popup().setLngLat(t).setHTML(`
2583
2583
  <div class="popupBody">
2584
2584
  <div class="popupTop">
2585
2585
  ${n.title}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mapicgc-gl-js",
3
3
  "homepage": "https://openicgc.github.io/mapicgc-doc/",
4
- "version": "0.0.80",
4
+ "version": "0.0.81",
5
5
  "description": "mapicgc-gl-js library",
6
6
  "author": "Institut Cartogràfic i Geològic de Catalunya",
7
7
  "license": "BSD-3-Clause",
package/src/map/Map.js CHANGED
@@ -128,9 +128,9 @@ export default class Map {
128
128
  type: "Point",
129
129
  coordinates: center,
130
130
  },
131
- place_name: feature.properties.label,
131
+ place_name: feature.properties.etiqueta,
132
132
  properties: feature.properties,
133
- text: feature.properties.label,
133
+ text: feature.properties.etiqueta,
134
134
  place_type: ["place"],
135
135
  center,
136
136
  };