| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |   import EditLayerState from "./EditLayerState" | 
					
						
							|  |  |  |   import { UIEventSource } from "../../Logic/UIEventSource" | 
					
						
							|  |  |  |   import type { TagConfigJson } from "../../Models/ThemeConfig/Json/TagConfigJson" | 
					
						
							|  |  |  |   import { TagUtils } from "../../Logic/Tags/TagUtils" | 
					
						
							|  |  |  |   import FromHtml from "../Base/FromHtml.svelte" | 
					
						
							|  |  |  |   import { PencilIcon } from "@rgossiaux/svelte-heroicons/outline" | 
					
						
							|  |  |  |   import Region from "./Region.svelte" | 
					
						
							|  |  |  |   import type { ConfigMeta } from "./configMeta" | 
					
						
							|  |  |  |   import configs from "../../assets/schemas/questionabletagrenderingconfigmeta.json" | 
					
						
							|  |  |  |   import { Utils } from "../../Utils" | 
					
						
							|  |  |  |   import ToSvelte from "../Base/ToSvelte.svelte" | 
					
						
							|  |  |  |   import { VariableUiElement } from "../Base/VariableUIElement" | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |   export let state: EditLayerState | 
					
						
							|  |  |  |   export let path: (string | number)[] | 
					
						
							|  |  |  |   let tag: UIEventSource<TagConfigJson> = state.getStoreFor([...path, "if"]) | 
					
						
							|  |  |  |   let parsedTag = tag.map((t) => (t ? TagUtils.Tag(t) : undefined)) | 
					
						
							|  |  |  |   let exampleTags = parsedTag.map((pt) => { | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |     if (!pt) { | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |       return {} | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |     const keys = pt.usedKeys() | 
					
						
							|  |  |  |     const o = {} | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |     for (const key of keys) { | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |       o[key] = "value" | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |     return o | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  |   let uploadableOnly: boolean = true | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-05 12:05:00 +01:00
										 |  |  |   let thenText: UIEventSource<Record<string, string>> = state.getStoreFor([...path, "then"]) | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |   let thenTextEn = thenText.mapD((translation) => | 
					
						
							|  |  |  |     typeof translation === "string" ? translation : translation["en"] | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  |   let editMode = Object.keys($thenText ?? {})?.length === 0 | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |   let mappingConfigs: ConfigMeta[] = configs | 
					
						
							|  |  |  |     .filter((c) => c.path[0] === "mappings") | 
					
						
							|  |  |  |     .map((c) => <ConfigMeta>Utils.Clone(c)) | 
					
						
							|  |  |  |     .map((c) => { | 
					
						
							|  |  |  |       c.path.splice(0, 1) | 
					
						
							|  |  |  |       return c | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |     .filter((c) => c.path.length == 1 && c.hints.group !== "hidden") | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  | <button | 
					
						
							|  |  |  |   on:click={() => { | 
					
						
							|  |  |  |     editMode = !editMode | 
					
						
							|  |  |  |   }} | 
					
						
							|  |  |  | > | 
					
						
							|  |  |  |   <PencilIcon class="h-6 w-6" /> | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  | </button> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | {#if editMode} | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |   <div class="flex w-full items-start justify-between"> | 
					
						
							|  |  |  |     <div class="flex w-full flex-col"> | 
					
						
							|  |  |  |       <Region {state} configs={mappingConfigs} {path} /> | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |     </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <slot name="delete" /> | 
					
						
							|  |  |  |   </div> | 
					
						
							|  |  |  | {:else} | 
					
						
							|  |  |  |   <div> | 
					
						
							| 
									
										
										
										
											2023-11-05 12:05:00 +01:00
										 |  |  |     {#if Object.keys($thenText).length > 0} | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |       <b> | 
					
						
							| 
									
										
										
										
											2023-11-05 12:05:00 +01:00
										 |  |  |         {$thenTextEn} | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |       </b> | 
					
						
							|  |  |  |     {:else} | 
					
						
							|  |  |  |       <i>No then is set</i> | 
					
						
							|  |  |  |     {/if} | 
					
						
							| 
									
										
										
										
											2023-11-09 16:30:26 +01:00
										 |  |  |     <FromHtml src={$parsedTag?.asHumanString(false, false, $exampleTags)} /> | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 |  |  |   </div> | 
					
						
							|  |  |  | {/if} |