2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  ThemeConfig  from  "../Models/ThemeConfig/ThemeConfig" 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 01:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  QueryParameters  }  from  "./Web/QueryParameters" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  AllKnownLayouts  }  from  "../Customizations/AllKnownLayouts" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  FixedUiElement  }  from  "../UI/Base/FixedUiElement" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  Utils  }  from  "../Utils" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  UIEventSource  }  from  "./UIEventSource" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  LocalStorageSource  }  from  "./Web/LocalStorageSource" 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  LZString  from  "lz-string" 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 01:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  FixLegacyTheme  }  from  "../Models/ThemeConfig/Conversion/LegacyJsonConvert" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  LayerConfigJson  }  from  "../Models/ThemeConfig/Json/LayerConfigJson" 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-08 01:14:21 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  known_layers  from  "../assets/generated/known_layers.json" 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 01:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  PrepareTheme  }  from  "../Models/ThemeConfig/Conversion/PrepareTheme" 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-08 01:14:21 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  licenses  from  "../assets/generated/license_info.json" 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  TagRenderingConfig  from  "../Models/ThemeConfig/TagRenderingConfig" 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 01:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  FixImages  }  from  "../Models/ThemeConfig/Conversion/FixImages" 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-15 18:04:30 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  questions  from  "../assets/generated/layers/questions.json" 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-11 12:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  DoesImageExist ,  PrevalidateTheme  }  from  "../Models/ThemeConfig/Conversion/Validation" 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 01:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  DesugaringContext  }  from  "../Models/ThemeConfig/Conversion/Conversion" 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-11 04:16:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  TagRenderingConfigJson  }  from  "../Models/ThemeConfig/Json/TagRenderingConfigJson" 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-08 02:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  Hash  from  "./Web/Hash" 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-11 04:16:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  QuestionableTagRenderingConfigJson  }  from  "../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson" 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  ThemeConfigJson  }  from  "../Models/ThemeConfig/Json/ThemeConfigJson" 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-11 12:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  ValidateThemeAndLayers  }  from  "../Models/ThemeConfig/Conversion/ValidateThemeAndLayers" 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 00:56:47 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								export  default  class  DetermineTheme  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  static  readonly  _knownImages  =  new  Set ( Array . from ( licenses ) . map ( ( l )  = >  l . path ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-08 02:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  static  readonly  loadCustomThemeParam  =  QueryParameters . GetQueryParameter ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "userlayout" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "false" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "If not 'false', a custom (non-official) theme is loaded. This custom layout can be done in multiple ways: \n\n- The hash of the URL contains a base64-encoded .json-file containing the theme definition\n- The hash of the URL contains a lz-compressed .json-file, as generated by the custom theme generator\n- The parameter itself is an URL, in which case that URL will be downloaded. It should point to a .json of a theme" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-23 15:35:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-08 02:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    public  static  getCustomDefinition ( ) :  string  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  layoutFromBase64  =  decodeURIComponent ( DetermineTheme . loadCustomThemeParam . data ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-08 02:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( layoutFromBase64 . startsWith ( "http" ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  layoutFromBase64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( layoutFromBase64  !==  "false" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            // We have to load something from the hash (or from disk)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  hash  =  Hash . hash . data 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                JSON . parse ( atob ( hash ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                return  atob ( hash ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            }  catch  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                // We try to decode with lz-string
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                JSON . parse ( Utils . UnMinify ( LZString . decompressFromBase64 ( hash ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                return  Utils . UnMinify ( LZString . decompressFromBase64 ( hash ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  undefined 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-16 16:06:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  static  async  expandRemoteLayers ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        layoutConfig : ThemeConfigJson 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ) :  Promise < ThemeConfigJson >  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-16 16:06:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( ! layoutConfig . layers )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-23 21:31:58 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            // This is probably a layer in 'layer-only-mode'
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  layoutConfig 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-23 15:35:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for  ( let  i  =  0 ;  i  <  layoutConfig . layers . length ;  i ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  l  =  layoutConfig . layers [ i ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( typeof  l  !==  "string" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                new  URL ( l ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                console . log ( "Downloading remote layer "  +  l ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                const  layerConfig  =  < LayerConfigJson > await  Utils . downloadJson ( l ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                layoutConfig . layers [ i ]  =  layerConfig 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            }  catch  ( _ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  layoutConfig 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     *  Gets  the  correct  layout  for  this  website 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     * / 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    public  static  async  getTheme ( ) :  Promise < ThemeConfig  |  undefined >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  layoutFromBase64  =  decodeURIComponent ( DetermineTheme . loadCustomThemeParam . data ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( layoutFromBase64 . startsWith ( "http" ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  await  DetermineTheme . LoadRemoteTheme ( layoutFromBase64 ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( layoutFromBase64  !==  "false" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            // We have to load something from the hash (or from disk)
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  await  DetermineTheme . LoadLayoutFromHash ( DetermineTheme . loadCustomThemeParam ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  layoutId : string  =  undefined 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  path  =  window . location . pathname . split ( "/" ) . slice ( - 1 ) [ 0 ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-21 18:35:31 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( path  !==  "theme.html"  &&  path  !==  "" )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            layoutId  =  path 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								            if  ( path . endsWith ( ".html" ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                layoutId  =  path . substr ( 0 ,  path . length  -  5 ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            console . log ( "Using layout" ,  layoutId ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        layoutId  =  QueryParameters . GetQueryParameter ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            "layout" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            layoutId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            "The layout to load into MapComplete" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ) . data 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-01 19:34:13 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  id  =  layoutId ? . toLowerCase ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  layouts  =  AllKnownLayouts . allKnownLayouts 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( layouts . size ( )  ==  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-12 23:49:46 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            throw  "Build failed or running, no layouts are known at all" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-01 19:34:13 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( layouts . getConfig ( id )  ===  undefined )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            const  alternatives  =  Utils . sortedByLevenshteinDistance ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                Array . from ( layouts . keys ( ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ( i )  = >  i 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ) . slice ( 0 ,  3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  msg  =  ` No builtin map theme with name  ${ layoutId }  exists. Perhaps you meant one of  ${ alternatives . join ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ", " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ) } ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-01 19:34:13 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            throw  msg 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-15 02:28:24 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-01 19:34:13 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  layouts . get ( id ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-16 16:06:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    public  static  async  LoadLayoutFromHash ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        userLayoutParam : UIEventSource < string > 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    ) :  Promise < ThemeConfig  |  null >  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  hash  =  location . hash . substr ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  json : any 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 02:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // layoutFromBase64 contains the name of the theme. This is partly to do tracking with goat counter
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 02:10:25 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  dedicatedHashFromLocalStorage  =  LocalStorageSource . get ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            "user-layout-"  +  userLayoutParam . data ? . replace ( " " ,  "_" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( dedicatedHashFromLocalStorage . data ? . length  <  10 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            dedicatedHashFromLocalStorage . setData ( undefined ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 02:10:25 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  hashFromLocalStorage  =  LocalStorageSource . get ( "last-loaded-user-layout" ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( hash . length  <  10 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            hash  =  dedicatedHashFromLocalStorage . data  ? ?  hashFromLocalStorage . data 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            console . log ( "Saving hash to local storage" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            hashFromLocalStorage . setData ( hash ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            dedicatedHashFromLocalStorage . setData ( hash ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            json  =  JSON . parse ( atob ( hash ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        }  catch  ( e )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            // We try to decode with lz-string
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            json  =  JSON . parse ( Utils . UnMinify ( LZString . decompressFromBase64 ( hash ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-23 15:35:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        json  =  await  this . expandRemoteLayers ( json ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  layoutToUse  =  DetermineTheme . prepCustomTheme ( json ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        userLayoutParam . setData ( layoutToUse . id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  layoutToUse 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 05:20:02 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-06 23:56:50 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  static  getSharedTagRenderings ( ) :  Map < string ,  QuestionableTagRenderingConfigJson >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  dict  =  new  Map < string ,  QuestionableTagRenderingConfigJson > ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 17:33:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-15 18:04:30 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for  ( const  tagRendering  of  questions . tagRenderings )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            dict . set ( tagRendering . id ,  < QuestionableTagRenderingConfigJson >  tagRendering ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 17:33:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  dict 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-01 19:34:13 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-19 01:56:19 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  static  getSharedTagRenderingOrder ( ) :  string [ ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 04:21:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  questions . tagRenderings . map ( ( tr )  = >  tr . id ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-19 01:56:19 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  static  prepCustomTheme ( json : any ,  sourceUrl? : string ,  forceId? : string ) :  ThemeConfig  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( json . layers  ===  undefined  &&  json . tagRenderings  !==  undefined )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-06 23:56:50 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            // We got fed a layer instead of a theme
 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-11 04:16:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            const  layerConfig  =  < LayerConfigJson > json 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 14:04:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            let  icon  =  Utils . NoNull ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 04:21:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                layerConfig . pointRendering 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    . flatMap ( ( pr )  = >  pr . marker ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    . map ( ( iconSpec )  = >  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-24 13:11:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                        if  ( ! iconSpec )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 14:04:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                            return  undefined 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 04:21:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                        const  icon  =  new  TagRenderingConfig ( < TagRenderingConfigJson > iconSpec . icon ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            . render . txt 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        if  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            iconSpec . color  ===  undefined  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            icon . startsWith ( "http:" )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            icon . startsWith ( "https:" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            return  icon 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        const  color  =  new  TagRenderingConfig ( < TagRenderingConfigJson > iconSpec . color ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            . render . txt 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        return  icon  +  ":"  +  color 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ) . join ( ";" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-19 01:56:19 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-24 13:11:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            if  ( ! icon )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 14:04:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                icon  =  "./assets/svg/bug.svg" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 00:56:47 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            json  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                id : json.id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                description : json.description , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                descriptionTail :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    en :  "<div class='alert'>Layer only mode.</div> The loaded custom theme actually isn't a custom theme, but only contains a layer." , 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 00:56:47 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                icon , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                title : json.name , 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                layers :  [ json ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 00:56:47 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  knownLayersDict  =  new  Map < string ,  LayerConfigJson > ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-12 03:46:51 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for  ( const  key  in  known_layers [ "layers" ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  layer  =  known_layers [ "layers" ] [ key ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            knownLayersDict . set ( layer . id ,  < LayerConfigJson > layer ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 17:33:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  convertState : DesugaringContext  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            tagRenderings : DetermineTheme.getSharedTagRenderings ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            tagRenderingOrder : DetermineTheme.getSharedTagRenderingOrder ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-13 03:13:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            sharedLayers : knownLayersDict , 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            publicLayers : new  Set < string > ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-11 04:16:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        json  =  new  FixLegacyTheme ( ) . convertStrict ( json ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  raw  =  json 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-18 02:39:30 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        json  =  new  FixImages ( DetermineTheme . _knownImages ) . convertStrict ( json ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        json . enableNoteImports  =  json . enableNoteImports  ? ?  false 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-11 04:16:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        json  =  new  PrepareTheme ( convertState ) . convertStrict ( json ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        console . log ( "The layoutconfig is " ,  json ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-21 16:47:54 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        json . id  =  forceId  ? ?  json . id 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-11 01:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-11 04:16:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            new  PrevalidateTheme ( ) . convertStrict ( json ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-11 01:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-11 04:16:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            new  ValidateThemeAndLayers ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-19 01:56:19 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                new  DoesImageExist ( new  Set < string > ( ) ,  ( )  = >  true ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-11 01:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                "" , 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-03 03:57:30 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                false 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-11 04:16:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            ) . convertStrict ( json ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-11 01:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  new  ThemeConfig ( json ,  false ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-18 02:39:30 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            definitionRaw : JSON.stringify ( raw ,  null ,  "  " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            definedAtUrl : sourceUrl , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-18 02:39:30 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  static  async  LoadRemoteTheme ( link : string ) :  Promise < ThemeConfig  |  null >  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        console . log ( "Downloading map theme from " ,  link ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 16:34:51 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        new  FixedUiElement ( ` Downloading the theme from the <a href=" ${ link } ">link</a>... ` ) . AttachTo ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 17:33:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            "maindiv" 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 16:34:51 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  parsed  =  < ThemeConfigJson > await  Utils . downloadJson ( link ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  forcedId  =  parsed . id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  url  =  new  URL ( link ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( ! ( url . hostname  ===  "localhost"  ||  url . hostname  ===  "127.0.0.1" ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            forcedId  =  link 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 16:34:51 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-26 11:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        console . log ( "Loaded remote link:" ,  link ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-23 15:35:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        parsed  =  await  this . expandRemoteLayers ( parsed ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  DetermineTheme . prepCustomTheme ( parsed ,  link ,  forcedId ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 16:34:51 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}