var w=Object.defineProperty;var y=(l,e,i)=>e in l?w(l,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):l[e]=i;var t=(l,e,i)=>(y(l,typeof e!="symbol"?e+"":e,i),i);import{a as g,b as h,e as v}from"./SubtleButton-5269e23e.js";import{L as S,d as T,aU as f}from"./ChartJsUtils-4d4315f9.js";import{C as L}from"./Constants-78dfb500.js";import{U as x,L as I}from"./UIEventSource-92ac4fe9.js";class M{constructor(e,i){t(this,"icon");t(this,"text");t(this,"href");t(this,"newTab");t(this,"requirements");this.icon=e.icon,this.text=g.T(e.text,"themes:"+i+".text"),this.href=e.href,this.newTab=e.newTab,this.requirements=new Set(e.requirements);for(const a of e.requirements)if(this.requirements.has("no-"+a))throw"Conflicting requirements found for "+i+".extraLink: both '"+a+"' and 'no-"+a+"' found";if(this.icon===void 0&&this.text===void 0)throw"At "+i+".extraLink: define at least an icon or a text to show. Both are undefined, this is not allowed"}}const u=class u{constructor(e,i=!0,a){t(this,"id");t(this,"credits");t(this,"language");t(this,"title");t(this,"shortDescription");t(this,"description");t(this,"descriptionTail");t(this,"icon");t(this,"socialImage");t(this,"startZoom");t(this,"startLat");t(this,"startLon");t(this,"defaultBackgroundId");t(this,"layers");t(this,"tileLayerSources");t(this,"hideFromOverview");t(this,"lockLocation");t(this,"enableUserBadge");t(this,"enableShareScreen");t(this,"enableMoreQuests");t(this,"enableMultiSelect");t(this,"selectionMode");t(this,"enableAddNewPoints");t(this,"enableLayers");t(this,"enableSearch");t(this,"enableGeolocation");t(this,"enableBackgroundLayerSelection");t(this,"enableShowAllQuestions");t(this,"enableExportButton");t(this,"enablePdfDownload");t(this,"enableTerrain");t(this,"enableMorePrivacy");t(this,"customCss");t(this,"overpassUrl");t(this,"overpassTimeout");t(this,"overpassMaxZoom");t(this,"osmApiTileSize");t(this,"official");t(this,"usedImages");t(this,"extraLink");t(this,"definedAtUrl");t(this,"definitionRaw");t(this,"layersDict");t(this,"source");t(this,"enableCache");t(this,"popups");if(e===void 0)throw"Cannot construct a layout config, the parameter 'json' is undefined";if(this.source=e,this.official=i,this.id=e.id,this.definedAtUrl=a==null?void 0:a.definedAtUrl,this.definitionRaw=a==null?void 0:a.definitionRaw,this.enableCache=e.enableCache??!0,this.enableMultiSelect=e.enableMultiSelect,this.selectionMode=e.selectionMode,i){if(e.id.toLowerCase()!==e.id)throw"The id of a theme should be lowercase: "+e.id;if(e.id.match(/[a-z0-9-_]/)==null)throw"The id of a theme should match [a-z0-9-_]*: "+e.id}const r=this.id;this.credits=Array.isArray(e.credits)?e.credits.join("; "):e.credits,this.language=e.mustHaveLanguage??Object.keys(e.title);{if(typeof e.title=="string")throw`The title of a theme should always be a translation, as it sets the corresponding languages (${r}.title). The themenID is ${this.id}; the offending object is ${JSON.stringify(e.title)} which is a ${typeof e.title})`;if(this.language.length==0)throw"No languages defined. Define at least one language. You can do this by adding a title";if(e.title===void 0)throw"Title not defined in "+this.id;if(e.description===void 0)throw"Description not defined in "+this.id;if(e.hideInOverview)throw"The json for "+this.id+" contains a 'hideInOverview'. Did you mean hideFromOverview instead?";if(e.layers===void 0)throw"Got undefined layers for "+e.id+" at "+r}if(this.title=new h(e.title,"themes:"+r+".title"),this.description=new h(e.description,"themes:"+r+".description"),this.shortDescription=e.shortDescription===void 0?this.description.FirstSentence():new h(e.shortDescription,"themes:"+r+".shortdescription"),this.descriptionTail=e.descriptionTail===void 0?void 0:new h(e.descriptionTail,"themes:"+r+".descriptionTail"),this.icon=e.icon,this.socialImage=e.socialImage??u.defaultSocialImage,this.socialImage===""&&i)throw"Theme "+e.id+" has empty string as social image";this.startZoom=e.startZoom,this.startLat=e.startLat,this.startLon=e.startLon,this.defaultBackgroundId=e.defaultBackgroundId,this.tileLayerSources=e.tileLayerSources??[],this.layers=e.layers.map(s=>new S(s,e.id+".layers."+s.id,i,e.layers)),this.extraLink=new M(e.extraLink??{icon:"./assets/svg/pop-out.svg",href:"https://{basepath}/{theme}.html?lat={lat}&lon={lon}&z={zoom}&language={language}",newTab:!0,requirements:["iframe","no-welcome-message"]},r+".extraLink"),this.popups=(e.popup??[]).map((s,d)=>{const o=r+".popup."+d;if(!s.id)throw o+": an id is required";const b=Array.isArray(s.body)?s.body:[s.body];function c(n){return typeof n=="string"?{render:{"*":n}}:g.isProbablyATranslation(n)?{render:n}:n}return{id:s.id,dismissible:s.dismissible??!1,condition:T.Tag(s.condition,o+".condition"),title:new f(c(s.title),o+".title"),body:b.map((n,p)=>new f(c(n),o+".body."+p))}}),this.hideFromOverview=e.hideFromOverview??!1,this.lockLocation=e.lockLocation??void 0,this.enableUserBadge=e.enableUserBadge??!0,this.enableShareScreen=e.enableShareScreen??!0,this.enableMoreQuests=e.enableMoreQuests??!0,this.enableLayers=e.enableLayers??!0,this.enableSearch=e.enableSearch??!0,this.enableGeolocation=e.enableGeolocation??!0,this.enableAddNewPoints=e.enableAddNewPoints??!0,this.enableBackgroundLayerSelection=e.enableBackgroundLayerSelection??!0,this.enableShowAllQuestions=e.enableShowAllQuestions??!1,this.enableExportButton=e.enableDownload??!0,this.enablePdfDownload=e.enablePdfDownload??!0,this.enableTerrain=e.enableTerrain??!1,this.customCss=e.customCss,this.overpassUrl=e.overpassUrl??L.defaultOverpassUrls,this.overpassTimeout=e.overpassTimeout??30,this.overpassMaxZoom=e.overpassMaxZoom??16,this.osmApiTileSize=e.osmApiTileSize??this.overpassMaxZoom+1,this.enableMorePrivacy=e.enableMorePrivacy||e.layers.some(s=>s.enableMorePrivacy),this.layersDict=new Map;for(const s of this.layers)this.layersDict.set(s.id,s)}CustomCodeSnippets(){if(this.official)return[];const e="
This layout uses custom javascript, loaded for the wide internet. The code is printed below, please report suspicious code on the issue tracker of MapComplete:
",i=[];for(const a of this.layers)i.push(...a.CustomCodeSnippets().map(r=>r+"
"));return i.length===0||i.splice(0,0,e),i}getLayer(e){return this.layersDict.get(e)}isLeftRightSensitive(){return this.layers.some(e=>e.isLeftRightSensitive)}hasNoteLayer(){return this.layers.some(e=>e.id==="note")}hasPresets(){return this.layers.some(e=>{var i;return((i=e.presets)==null?void 0:i.length)>0})}missingTranslations(e){let i=0;const a=new Map;return x.WalkObject([this,e],r=>{const s=r;s.translations["*"]===void 0&&(s.context===void 0||s.context.indexOf(":"){const o=s.translations;o["*"]===void 0&&(s.context.indexOf(":")r==null?!1:r instanceof h),{untranslated:a,total:i}}getMatchingLayer(e,i){var a;if(e!==void 0){if(e.id.startsWith("current_view"))return this.getLayer("current_view");for(const r of this.layers)if(!(i!=null&&i.has(r.id))){if(!r.source){if((a=r.isShown)!=null&&a.matchesProperties(e))return r;continue}if(r.source.osmTags.matchesProperties(e)&&(!r.isShown||r.isShown.matchesProperties(e)))return r}}}getUsedImages(){if(this.usedImages)return this.usedImages;const e=this.source,a={...e,layers:e.layers.filter(r=>r.id!=="favourite")}._usedImages;return a.sort(),this.usedImages=I.dedup(a),this.usedImages}};t(u,"defaultSocialImage","assets/SocialImage.png");let m=u;export{m as T}; //# sourceMappingURL=ThemeConfig-b0b7784c.js.map