{"version":3,"file":"hslayers-ng-services-styler.mjs","sources":["../../../projects/hslayers/services/styler/default-style.ts","../../../projects/hslayers/services/styler/styler.service.ts","../../../projects/hslayers/services/styler/style-part-base.component.ts","../../../projects/hslayers/services/styler/hslayers-ng-services-styler.ts"],"sourcesContent":["export const defaultStyle = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<StyledLayerDescriptor version=\"1.0.0\" xsi:schemaLocation=\"http://www.opengis.net/sld StyledLayerDescriptor.xsd\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n  <NamedLayer>\n    <Name/>\n    <UserStyle>\n      <Title/>\n      <FeatureTypeStyle>\n        <Rule>\n          <Name/>\n          <PointSymbolizer>\n            <Graphic>\n              <Mark>\n                <WellKnownName>circle</WellKnownName>\n                <Fill>\n                  <CssParameter name=\"fill\">#FFFFFF</CssParameter>\n                  <CssParameter name=\"fill-opacity\">0.41</CssParameter>\n                </Fill>\n                <Stroke>\n                  <CssParameter name=\"stroke\">#0099ff</CssParameter>\n                  <CssParameter name=\"stroke-width\">1.25</CssParameter>\n                </Stroke>\n              </Mark>\n              <Size>10</Size>\n            </Graphic>\n          </PointSymbolizer>\n          <PolygonSymbolizer>\n            <Fill>\n              <CssParameter name=\"fill-opacity\">0.45</CssParameter>\n            </Fill>\n            <Stroke>\n              <CssParameter name=\"stroke\">#0099ff</CssParameter>\n              <CssParameter name=\"stroke-width\">1.25</CssParameter>\n              <CssParameter name=\"stroke-opacity\">0.3</CssParameter>\n            </Stroke>\n          </PolygonSymbolizer>\n          <LineSymbolizer>\n            <Stroke>\n              <CssParameter name=\"stroke\">#0099ff</CssParameter>\n              <CssParameter name=\"stroke-width\">1.25</CssParameter>\n            </Stroke>\n          </LineSymbolizer>\n        </Rule>\n      </FeatureTypeStyle>\n    </UserStyle>\n  </NamedLayer>\n</StyledLayerDescriptor>`;\n","import colormap from 'colormap';\n\nimport {DomSanitizer} from '@angular/platform-browser';\nimport {\n  computed,\n  Injectable,\n  signal,\n  WritableSignal,\n  inject,\n} from '@angular/core';\nimport {Subject} from 'rxjs';\n\nimport {Cluster, Vector as VectorSource} from 'ol/source';\nimport {\n  ConstructorParams,\n  SldStyleParser as SLDParser,\n  SldVersion,\n} from 'geostyler-sld-parser';\nimport {Feature, getUid} from 'ol';\nimport {\n  Filter,\n  Style as GeoStylerStyle,\n  Rule,\n  WellKnownName,\n} from 'geostyler-style';\nimport {Geometry} from 'ol/geom';\nimport {Icon, Style} from 'ol/style';\nimport {Layer, Vector as VectorLayer} from 'ol/layer';\nimport {OlStyleParser as OpenLayersParser} from 'geostyler-openlayers-parser';\nimport {StyleFunction, StyleLike, createDefaultStyle} from 'ol/style/Style';\n\nimport {\n  HsCommonLaymanService,\n  parseBase64Style,\n  awaitLayerSync,\n  getLaymanFriendlyLayerName,\n  isLayerSynchronizable,\n} from 'hslayers-ng/common/layman';\nimport {HsConfig} from 'hslayers-ng/config';\nimport {HsConfirmDialogComponent} from 'hslayers-ng/common/confirm';\nimport {HsDialogContainerService} from 'hslayers-ng/common/dialogs';\nimport {HsEventBusService} from 'hslayers-ng/services/event-bus';\nimport {HsLayerSynchronizerService} from 'hslayers-ng/services/save-map';\nimport {\n  instOf,\n  isFunction,\n  isLayerVectorLayer,\n} from 'hslayers-ng/services/utils';\nimport {HsLogService} from 'hslayers-ng/services/log';\nimport {HsMapService} from 'hslayers-ng/services/map';\nimport {HsQueryVectorService} from 'hslayers-ng/services/query';\nimport {HsToastService} from 'hslayers-ng/common/toast';\nimport {defaultStyle} from './default-style';\nimport {\n  getCluster,\n  getQml,\n  getSld,\n  getTitle,\n  setQml,\n  setSld,\n  getHighlighted,\n  getHsLaymanSynchronizingSignal,\n  setHsLaymanSynchronizing,\n} from 'hslayers-ng/common/extensions';\n\n@Injectable({\n  providedIn: 'root',\n})\nexport class HsStylerService {\n  hsQueryVectorService = inject(HsQueryVectorService);\n  private hsEventBusService = inject(HsEventBusService);\n  private hsLogService = inject(HsLogService);\n  sanitizer = inject(DomSanitizer);\n  private hsMapService = inject(HsMapService);\n  private hsConfig = inject(HsConfig);\n  private hsCommonLaymanService = inject(HsCommonLaymanService);\n  private hsLayerSynchronizerService = inject(HsLayerSynchronizerService);\n  private hsDialogContainerService = inject(HsDialogContainerService);\n  private hsToastService = inject(HsToastService);\n\n  layer: WritableSignal<VectorLayer<VectorSource<Feature>>> = signal(null);\n  layerBeingMonitored: boolean;\n  onSet: Subject<VectorLayer<VectorSource<Feature>>> = new Subject();\n  layerTitle: string;\n  styleObject: GeoStylerStyle;\n\n  sld: WritableSignal<string> = signal('');\n  qml: string;\n  isAuthenticated = this.hsCommonLaymanService.isAuthenticated;\n\n  pin_white_blue;\n  pin_white_blue_highlight;\n  colorMapDialogVisible = false;\n  unsavedChange = false;\n  changesStore = new Map<string, {sld: string; qml: string}>();\n\n  syncing = computed(() => {\n    const layer = this.layer();\n    if (!layer) {\n      return false;\n    }\n    const layerSyncing = getHsLaymanSynchronizingSignal(layer)();\n    if (!layerSyncing) {\n      this.unsavedChange = this.changesStore.has(getUid(layer));\n    }\n    return layerSyncing;\n  });\n\n  sldVersion: SldVersion = '1.0.0';\n\n  //Cumbersome as we need to toggle it but needed to track parsing errors\n  //in order to be able to sync layer style and sld prop\n  sldParsingError = false;\n\n  constructor() {\n    this.pin_white_blue = new Style({\n      image: new Icon({\n        src: this.hsConfig.assetsPath + 'img/pin_white_blue32.png',\n        crossOrigin: 'anonymous',\n        anchor: [0.5, 1],\n      }),\n    });\n    this.pin_white_blue_highlight = (\n      feature: Feature<Geometry>,\n      resolution,\n    ): Array<Style> => {\n      return [\n        new Style({\n          image: new Icon({\n            src:\n              this.hsConfig.assetsPath + getHighlighted(feature)\n                ? 'img/pin_white_red32.png'\n                : 'img/pin_white_blue32.png',\n            crossOrigin: 'anonymous',\n            anchor: [0.5, 1],\n          }),\n        }),\n      ];\n    };\n\n    this.hsMapService.loaded().then((map) => {\n      for (const layer of this.hsMapService\n        .getLayersArray()\n        .filter((layer) => isLayerVectorLayer(layer))) {\n        this.initLayerStyle(layer as VectorLayer<VectorSource<Feature>>);\n      }\n      this.hsEventBusService.layerAdditions.subscribe((layerDescriptor) => {\n        if (isLayerVectorLayer(layerDescriptor.layer)) {\n          this.initLayerStyle(\n            layerDescriptor.layer as VectorLayer<VectorSource<Feature>>,\n          );\n        }\n      });\n    });\n  }\n\n  isVectorLayer(layer: any): boolean {\n    if (instOf(layer, VectorLayer)) {\n      return true;\n    }\n    return false;\n  }\n\n  /**\n   * Get a Source for any vector layer. Both clustered and un-clustered.\n   * @param layer - Any vector layer\n   * @returns Source of the input layer or source of its cluster's source\n   */\n  getLayerSource(\n    layer: VectorLayer<VectorSource<Feature>>,\n    isClustered: boolean,\n  ): VectorSource {\n    if (!layer) {\n      return;\n    }\n    let src: VectorSource;\n    if (isClustered) {\n      src = (layer.getSource() as Cluster<Feature>).getSource();\n    } else {\n      src = layer.getSource();\n    }\n    return src;\n  }\n\n  /**\n   * Style clustered layer features using cluster style or individual feature style.\n   * @param layer - Any vector layer\n   */\n  async styleClusteredLayer(\n    layer: VectorLayer<VectorSource<Feature>>,\n  ): Promise<void> {\n    await this.fill(layer);\n    //Check if layer already has SLD style for clusters\n    if (\n      !this.styleObject.rules.find((r) => {\n        try {\n          /* \n          For clusters SLD styles created by Hslayers have 'AND' rule where the \n          first condition checks if 'features' attribute of a feature is set. \n          See addRule function \n          */\n          return r.filter[1][1] == 'features';\n        } catch (ex) {\n          return false;\n        }\n      })\n    ) {\n      // Remember to clone singleFeatureFilter on usage so the filters\n      // don't share the same reference\n      const singleFeatureFilter: string | Filter = [\n        '||',\n        ['==', 'features', 'undefined'],\n        ['==', 'features', '[object Object]'],\n      ];\n      for (const rule of this.styleObject.rules) {\n        // Set filter so the original style is applied to features which are not clusters\n        rule.filter =\n          Array.isArray(rule.filter) && rule.filter.length > 0\n            ? ['&&', [...singleFeatureFilter], rule.filter]\n            : [...singleFeatureFilter];\n      }\n      await this.addRule('Cluster');\n    }\n    let style = layer.getStyle();\n    if (instOf(layer.getSource(), Cluster) && isFunction(style)) {\n      style = this.wrapStyleForClusters(style as StyleFunction);\n      layer.setStyle(style);\n    }\n  }\n\n  /**\n   * Upload style created by createDefaultStyle method to layman thus syncing style of\n   * vector layer added without SLD by rewriting its default value\n   */\n  private trySyncingStyleToLayman(layer: VectorLayer<VectorSource<Feature>>) {\n    try {\n      if (this.hsLayerSynchronizerService.syncedLayers.includes(layer)) {\n        awaitLayerSync(layer).then(() => {\n          const sld = getSld(layer);\n          if (sld) {\n            setSld(\n              layer,\n              sld.replace(\n                '<NamedLayer>',\n                '<NamedLayer>' + '<!-- This will be removed by parser -->',\n              ),\n            );\n          }\n        });\n      }\n    } catch (error) {\n      this.hsLogService.error(error);\n    }\n  }\n\n  /**\n   * Parse style from 'sld' attribute defined in SLD format and convert to OL\n   * style which is set on the layer. Also do the opposite if no SLD is defined,\n   * because SLD is used in the styler panel.\n   *\n   * @param layer - OL layer to fill the missing style info\n   */\n  async initLayerStyle(\n    layer: VectorLayer<VectorSource<Feature>>,\n  ): Promise<void> {\n    if (!this.isVectorLayer(layer)) {\n      return;\n    }\n    let sld = getSld(layer);\n    const qml = getQml(layer);\n    const style = layer.getStyle();\n    /*\n     * No style has been detected (no SLD, QML nor OL style obj<StyleLike>)\n     */\n    if ((!style || style == createDefaultStyle) && !sld && !qml) {\n      sld = defaultStyle;\n      setSld(layer, defaultStyle);\n    }\n    /*\n     * SLD or QML style definition AND style def is undefined or default (eg. no custom StyleLike definition)\n     */\n    if ((sld || qml) && (!style || style == createDefaultStyle)) {\n      const dstyle = style == createDefaultStyle;\n      const parsedStyle = await this.parseStyle(sld ?? qml);\n      if (parsedStyle.sld !== sld) {\n        sld = parsedStyle.sld;\n        setSld(layer, sld);\n        this.sldParsingError = false;\n      }\n      if (parsedStyle.style) {\n        layer.setStyle(parsedStyle.style);\n      }\n      if (getCluster(layer)) {\n        if (!instOf(layer.getSource(), Cluster)) {\n          this.hsLogService.warn(\n            `Layer ${getTitle(\n              layer,\n            )} is meant to be clustered but not an instance of Cluster source! Waiting for a change:source event...`,\n          );\n          await new Promise((resolve) => {\n            layer.once('change:source', (evt) => resolve(evt.target));\n          });\n        }\n        //await is necessary because of consecutive code (this.fill())\n        await this.styleClusteredLayer(layer);\n      }\n      if (dstyle) {\n        this.trySyncingStyleToLayman(layer);\n      }\n    } else if (style && !sld && !qml) {\n      /*\n       * OL StyleLike definition\n       */\n      sld = await this.olStyleToSld(style as StyleLike);\n      setSld(layer, sld);\n    } else {\n      this.hsLogService.warn(\n        `Unexpected style definition for layer ${getTitle(layer)}`,\n      );\n    }\n    this.sld.set(sld);\n    this.qml = qml;\n  }\n\n  /**\n   * Parse style encoded as SLD or QML and return OL style object.\n   * This function is used to support backwards compatibility with custom format.\n   * @returns OL style object\n   */\n  async parseStyle(\n    style: any,\n  ): Promise<{sld?: string; qml?: string; style: StyleLike}> {\n    if (!style) {\n      return {\n        sld: defaultStyle,\n        style: createDefaultStyle,\n      };\n    }\n    const styleType = this.guessStyleFormat(style);\n    if (styleType == 'sld') {\n      const olStyle = await this.sldToOlStyle(style);\n      const sld = this.sldParsingError ? defaultStyle : style;\n      return {sld: sld, style: olStyle};\n    }\n    if (styleType == 'qml') {\n      return {qml: style, style: await this.qmlToOlStyle(style)};\n    }\n    return {style};\n  }\n\n  guessStyleFormat(style: any): 'qml' | 'sld' | undefined {\n    if (typeof style == 'string') {\n      if ((style as string).includes('StyledLayerDescriptor')) {\n        return 'sld';\n      }\n      if ((style as string).includes('<qgis')) {\n        return 'qml';\n      }\n    }\n    return undefined;\n  }\n\n  /**\n   * Prepare current layers style for editing by converting\n   * SLD attribute string to JSON and reading layers title\n   * @param styleWithPriority Used to prioritize certain style type. For example when\n   * loading style from a file\n   */\n  async fill(\n    layer: VectorLayer<VectorSource<Feature>>,\n    styleWithPriority?: 'sld' | 'qml',\n  ): Promise<void> {\n    const blankStyleObj = {name: 'untitled style', rules: []};\n    try {\n      if (!layer) {\n        return;\n      }\n      this.layer.set(layer);\n      this.layerBeingMonitored =\n        !!this.hsLayerSynchronizerService.syncedLayers.find((l) => l == layer);\n      this.unsavedChange = this.changesStore.has(getUid(layer));\n      this.layerTitle = getTitle(layer);\n      const {sld, qml} = this.unsavedChange\n        ? this.changesStore.get(getUid(layer))\n        : {\n            sld: getSld(layer),\n            qml: getQml(layer),\n          };\n      //If SLD available and QML is not prioritised, use it\n      if (sld != undefined && styleWithPriority !== 'qml') {\n        this.styleObject = await this.sldToJson(sld);\n        this.sldVersion = this.guessSldVersion(sld);\n      } else if (qml != undefined && styleWithPriority !== 'sld') {\n        this.styleObject = await this.qmlToJson(qml);\n        //Note: https://github.com/hslayers/hslayers-ng/issues/3431\n      } else {\n        if (styleWithPriority) {\n          console.warn(\n            'Prioritised style not parsed, unexpected blank style usage!',\n          );\n        }\n        this.styleObject = blankStyleObj;\n      }\n      await this.fixSymbolizerBugs(this.styleObject);\n      /**\n       * Save (update OL style) layer style\n       * unsavedChange - synced layman layer with changes\n       * layerBeingMonitored - other vector layers\n       */\n      if (this.unsavedChange || !this.layerBeingMonitored) {\n        //Update this.sld string in case styler for layer with unsaved changes was opened.\n        //Could have been changed by styling other layer in the meantime\n        this.save();\n      }\n    } catch (ex) {\n      this.styleObject = blankStyleObj;\n      this.hsLogService.error(ex.message);\n    }\n  }\n\n  /**\n   * Create serialized canvas element with SVG icon drawn on it.\n   *\n   * Used for perf optimization instead of expensive SVG icons while icon.color is not\n   * supported on Geostyler or we implement better VectorImage layer type support.\n   *\n   * NOTE: It's not possible to use HTMLCanvasElement directly, even though OL icon accepts it\n   * as Geostyler uses structuredCopy before processing.\n   */\n  private base64SvgToCanvas(base64Svg): Promise<string> {\n    return new Promise((resolve, reject) => {\n      const img = new Image();\n      img.src = base64Svg;\n      img.onload = () => {\n        const canvas = document.createElement('canvas');\n        canvas.width = img.width;\n        canvas.height = img.height;\n        const context = canvas.getContext('2d');\n        context.drawImage(img, 0, 0);\n        const dataUrl = canvas.toDataURL();\n        resolve(dataUrl);\n      };\n      img.onerror = (error) => {\n        console.error('Error loading SVG:', error);\n        reject(error);\n      };\n    });\n  }\n\n  private async fixSymbolizerBugs(styleObject: GeoStylerStyle): Promise<void> {\n    if (styleObject.rules) {\n      for (const rule of styleObject.rules) {\n        if (rule?.symbolizers) {\n          for (const symb of rule.symbolizers) {\n            if (symb.kind == 'Mark' && symb.wellKnownName !== undefined) {\n              symb.wellKnownName =\n                symb.wellKnownName.toLowerCase() as WellKnownName;\n            }\n            if (\n              symb.kind == 'Icon' &&\n              typeof symb.image === 'string' &&\n              symb.image.includes('base64')\n            ) {\n              const canvasIcon = await this.base64SvgToCanvas(symb.image);\n              symb.image = canvasIcon ? canvasIcon : symb.image;\n            }\n          }\n        }\n      }\n    }\n  }\n\n  /**\n   * Converts OL style into SLD\n   */\n  async olStyleToSld(style: StyleLike): Promise<string> {\n    try {\n      const {OlStyleParser} = await import('geostyler-openlayers-parser');\n      const parser = new OlStyleParser();\n\n      const {output: geoStylerStyle} = await parser.readStyle(style);\n      const sldParser = new SLDParser({sldVersion: '1.0.0'});\n      const {output: sld} = await sldParser.writeStyle(geoStylerStyle);\n      return sld;\n    } catch (error) {\n      this.hsLogService.error(\n        'There was an error converting OL style to SLD',\n        error,\n      );\n      return defaultStyle;\n    }\n  }\n\n  /**\n   * Convert SLD to OL style object\n   */\n  async sldToOlStyle(sld: string): Promise<StyleLike> {\n    try {\n      const sldObject = await this.sldToJson(sld);\n      await this.fixSymbolizerBugs(sldObject);\n      return await this.geoStylerStyleToOlStyle(sldObject);\n    } catch (ex) {\n      this.hsLogService.error(ex);\n    }\n  }\n\n  /**\n   * Convert QML to OL style object\n   */\n  async qmlToOlStyle(qml: string): Promise<StyleLike> {\n    try {\n      const styleObject = await this.qmlToJson(qml);\n      await this.fixSymbolizerBugs(styleObject);\n      return await this.geoStylerStyleToOlStyle(styleObject);\n    } catch (ex) {\n      this.hsLogService.error(ex);\n    }\n  }\n\n  public async geoStylerStyleToOlStyle(\n    sldObject: GeoStylerStyle,\n  ): Promise<StyleLike> {\n    const olConverter = new OpenLayersParser();\n    const {output: style} = await olConverter.writeStyle(sldObject);\n    return style;\n  }\n\n  guessSldVersion(sld: string): SldVersion {\n    try {\n      const parser = new DOMParser();\n      const xmlDoc = parser.parseFromString(sld, 'text/xml');\n      if (\n        xmlDoc.documentElement.attributes.getNamedItem('version')?.value ==\n        '1.1.0'\n      ) {\n        return '1.1.0';\n      }\n      return '1.0.0';\n    } catch (ex) {\n      return '1.0.0';\n    }\n  }\n\n  /**\n   * Convert SLD text to JSON which is easier to edit in Angular.\n   */\n  async sldToJson(sld: string): Promise<GeoStylerStyle> {\n    const options: ConstructorParams = {};\n    options.sldVersion = this.guessSldVersion(sld);\n    const sldParser = new SLDParser(options);\n    const sldObject = await sldParser.readStyle(sld);\n    if (!sldObject || sldObject.errors) {\n      this.sldParsingError = true;\n      const defaultSldObject = await sldParser.readStyle(defaultStyle);\n\n      /**\n       * NOTE: Not ideal as there is no information about which layer is affected\n       */\n      this.hsToastService.createToastPopupMessage(\n        'STYLER.sldParsingError',\n        'STYLER.sldParsingErrorMessage',\n        {\n          serviceCalledFrom: 'HsStylerService',\n        },\n      );\n      return {...defaultSldObject.output, name: 'HSLayers default style'};\n    }\n    const result = this.adjustForUndefinedValues({\n      styleObject: sldObject.output,\n      toSld: false,\n    });\n    return result;\n  }\n\n  /**\n   * Convert QML text to JSON which is easier to edit in Angular.\n   */\n  async qmlToJson(qml: string): Promise<GeoStylerStyle> {\n    const {QGISStyleParser} = await import('geostyler-qgis-parser');\n    const qmlParser = new QGISStyleParser();\n\n    const result = await qmlParser.readStyle(qml);\n    if (result.output) {\n      return result.output;\n    }\n    this.hsLogService.error(result.errors);\n  }\n\n  /**\n   * Recursively replaces all \"NULL\" values with undefined in an object\n   */\n  private replaceNullValues(obj: any): any {\n    if (Array.isArray(obj)) {\n      return obj.map((item) => this.replaceNullValues(item));\n    }\n    if (obj && typeof obj === 'object') {\n      const newObj = {};\n      for (const key in obj) {\n        newObj[key] = this.replaceNullValues(obj[key]);\n      }\n      return newObj;\n    }\n    if (obj === 'NULL') {\n      return undefined;\n    }\n    return obj;\n  }\n\n  /**\n   * Adjusts for undefined values in filter expressions.\n   * Replacing undefined (which works with OpenLayers) with 'NULL' (which works with Geostyler)\n   */\n  adjustForUndefinedValues(options: {\n    styleObject: GeoStylerStyle;\n    toSld: boolean;\n  }): GeoStylerStyle {\n    if (options.toSld) {\n      return JSON.parse(\n        JSON.stringify(options.styleObject).replaceAll('null]', '\"NULL\"]'),\n      );\n    }\n    const withNullValues = this.replaceNullValues(options.styleObject);\n    return this.laymanFiltersFix(withNullValues);\n  }\n\n  /**\n   * Remove dimension filters in case style is Layman's default style\n   */\n  private laymanFiltersFix(styleObject: GeoStylerStyle): GeoStylerStyle {\n    if (styleObject.name === 'generic' && styleObject.rules.length === 4) {\n      styleObject.rules = styleObject.rules.map((rule) => {\n        const {filter, ...rest} = rule;\n        return rest;\n      });\n    }\n    return styleObject;\n  }\n\n  private async jsonToSld(styleObject: GeoStylerStyle): Promise<string> {\n    const sldParser = new SLDParser({sldVersion: this.sldVersion});\n    const {output: sld} = await sldParser.writeStyle(\n      this.adjustForUndefinedValues({styleObject, toSld: true}),\n    );\n    return sld;\n  }\n\n  async addRule(\n    kind:\n      | 'Simple'\n      | 'ByScale'\n      | 'ByFilter'\n      | 'ByFilterAndScale'\n      | 'Cluster'\n      | 'ColorMap',\n    options?: {\n      min?: number;\n      max?: number;\n      categories?: number;\n      colorMapName?: string;\n      attribute?: string;\n    },\n  ): Promise<void> {\n    try {\n      switch (kind) {\n        case 'ColorMap':\n          const colors = colormap({\n            colormap: options.colorMapName,\n            nshades: options.categories,\n            format: 'hex',\n            alpha: 1,\n          });\n          const step = (options.max - options.min) / (options.categories - 1);\n          this.styleObject.rules = colors.map((color) => {\n            const ix = colors.indexOf(color);\n            const from = options.min + ix * step;\n            const till = options.min + (ix + 1) * step;\n            return {\n              name: `${from.toFixed(2)} - ${till.toFixed(2)} ${\n                options.attribute\n              }`,\n              filter: [\n                '&&',\n                ['>=', options.attribute, from],\n                ['<', options.attribute, till],\n              ],\n              symbolizers: [\n                {\n                  kind: 'Mark',\n                  color: color,\n                  strokeOpacity: 0.41,\n                  strokeColor: 'white',\n                  strokeWidth: 0.3,\n                  wellKnownName: 'circle',\n                  radius: 5,\n                },\n                {\n                  kind: 'Fill',\n                  color: color,\n                  strokeOpacity: 0.2,\n                },\n              ],\n            };\n          });\n          break;\n        case 'Cluster':\n          this.styleObject.rules.push({\n            name: 'Cluster rule',\n            filter: [\n              '&&',\n              ['!=', 'features', 'undefined'],\n              ['!=', 'features', '[object Object]'],\n            ],\n            symbolizers: [\n              {\n                kind: 'Mark',\n                color: '#FFFFFF',\n                strokeOpacity: 0.41,\n                strokeColor: '#0099ff',\n                strokeWidth: 2,\n                wellKnownName: 'circle',\n                radius: 10,\n              },\n              {\n                kind: 'Text',\n                label: '{{features}}',\n                size: 12,\n                haloColor: '#fff',\n                color: '#000',\n                offset: [0, 0],\n              },\n            ],\n          });\n          break;\n        case 'Simple':\n        default:\n          this.styleObject.rules.push({\n            name: 'Untitled rule',\n            symbolizers: [],\n          });\n      }\n      await this.save();\n    } catch (error) {\n      if (error.message?.includes('nshades')) {\n        const min = error.message.match(/\\d+/)[0];\n        this.hsToastService.createToastPopupMessage(\n          'STYLER.colorMap',\n          'STYLER.tooFewCategories',\n          {\n            type: 'warning',\n            serviceCalledFrom: 'HsStylerService',\n            details: [`Min = ${min}`],\n          },\n        );\n        return;\n      }\n      console.error(error);\n    }\n  }\n\n  async removeRule(rule: Rule): Promise<void> {\n    this.styleObject.rules.splice(this.styleObject.rules.indexOf(rule), 1);\n    await this.save();\n  }\n\n  //Unused?\n  encodeTob64(str: string): string {\n    return btoa(\n      encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => {\n        return String.fromCharCode(parseInt(p1, 16));\n      }),\n    );\n  }\n\n  //Unused?\n  decodeToUnicode(str: string): string {\n    return decodeURIComponent(\n      Array.prototype.map\n        .call(atob(str), (c) => {\n          return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n        })\n        .join(''),\n    );\n  }\n\n  /**\n   * Checks whether SLD/QML should be indicated or saved right away.\n   * Indicate only when user is logged in Layman and layer is being monitored otherwise save\n   */\n  resolveSldChange() {\n    if (this.isAuthenticated() && this.layerBeingMonitored) {\n      this.changesStore.set(getUid(this.layer()), {\n        sld: this.sld(),\n        qml: this.qml,\n      });\n      this.unsavedChange = true;\n    } else {\n      this.setSldQml();\n    }\n  }\n\n  /**Set SLD/QML parameter of layer*/\n  setSldQml() {\n    const layer = this.layer();\n    if (!layer) {\n      return;\n    }\n    if (isLayerSynchronizable(layer, instOf)) {\n      setHsLaymanSynchronizing(layer, true);\n    }\n    setSld(layer, this.sld());\n    setQml(layer, this.qml);\n    this.changesStore.delete(getUid(layer));\n  }\n\n  async save(): Promise<void> {\n    try {\n      let style: Style | Style[] | StyleFunction =\n        await this.geoStylerStyleToOlStyle(this.styleObject);\n      if (this.styleObject.rules.length == 0) {\n        this.hsLogService.warn('Missing style rules for layer', this.layer());\n        style = createDefaultStyle;\n      }\n      /* style is a function when text symbolizer is used. We need some hacking \n      for cluster layer in that case to have the correct number of features in \n      cluster display over the label */\n      if (instOf(this.layer().getSource(), Cluster) && isFunction(style)) {\n        style = this.wrapStyleForClusters(style as StyleFunction);\n      }\n      this.layer().setStyle(style);\n      const sld = await this.jsonToSld(this.styleObject);\n      this.sld.set(sld);\n      this.resolveSldChange();\n      this.onSet.next(this.layer());\n    } catch (ex) {\n      this.hsLogService.error(ex);\n    }\n  }\n\n  /**\n   * HACK is needed to style cluster layers. It wraps existing OL style function\n   * in a function which searches for Text styles and in them for serialized\n   * feature arrays and instead sets the length of this array as the label.\n   * If the geostyler text symbolizer had \\{\\{features\\}\\} as the text label template\n   * (which returns the \"features\" attribute of the parent/cluster feature) and returned\n   * '[object Object], [object Object]' the result would become \"2\".\n   * See https://github.com/geostyler/geostyler-openlayers-parser/issues/227\n   */\n  wrapStyleForClusters(style: StyleFunction): StyleFunction {\n    return (feature, resolution) => {\n      const tmp = style(feature, resolution);\n      if (!tmp) {\n        return;\n      }\n      if (Array.isArray(tmp)) {\n        for (const evaluatedStyle of tmp as Style[]) {\n          if (\n            evaluatedStyle.getText &&\n            evaluatedStyle.getText()?.getText()?.includes('[object Object]')\n          ) {\n            const featureListSerialized = evaluatedStyle.getText().getText();\n            const fCount = (featureListSerialized as string)\n              .split(',')\n              .length.toString();\n            evaluatedStyle.getText().setText(fCount);\n          }\n        }\n      }\n      return tmp;\n    };\n  }\n\n  async reset(): Promise<void> {\n    const dialog = this.hsDialogContainerService.create(\n      HsConfirmDialogComponent,\n      {\n        message: 'STYLER.reallyResetStyleToDefault',\n        title: 'COMMON.confirmReset',\n      },\n    );\n    const confirmed = await dialog.waitResult();\n    if (confirmed == 'yes') {\n      this.sld.set(defaultStyle);\n      const style = (await this.parseStyle(defaultStyle)).style;\n      if (style) {\n        this.layer().setStyle(style);\n      }\n      this.resolveSldChange();\n      this.fill(this.layer());\n    }\n  }\n\n  /**\n   * Load style in SLD/QML and set it to current layer\n   */\n  async loadStyle(styleString: string): Promise<void> {\n    try {\n      this.changesStore.delete(getUid(this.layer));\n      const styleFmt = this.guessStyleFormat(styleString);\n      if (styleFmt == 'sld') {\n        const sldParser = new SLDParser({\n          sldVersion: this.guessSldVersion(styleString),\n        });\n        await sldParser.readStyle(styleString);\n        this.sld.set(styleString);\n      } else if (styleFmt == 'qml') {\n        const {QGISStyleParser} = await import('geostyler-qgis-parser');\n        const qmlParser = new QGISStyleParser();\n        await qmlParser.readStyle(styleString);\n\n        this.qml = parseBase64Style(styleString);\n      }\n      this.resolveSldChange();\n      this.fill(this.layer(), styleFmt);\n    } catch (err) {\n      this.hsLogService.warn('SLD could not be parsed', err);\n    }\n  }\n\n  /**\n   * Calculate a stop-color value for gradient. Offset depend on number of colors (length)\n   * and current index.\n   * @param color - RGB(A) color definition\n   * @param linearGradient - SVG Linear Gradient element\n   * @param length - Offset calculation - length of an array (number of colors)\n   * @param index - Index of color\n   */\n  private appendColorToGradient(\n    color: number[],\n    linearGradient: SVGLinearGradientElement,\n    length: number,\n    index: number,\n  ): void {\n    const stop = document.createElementNS('http://www.w3.org/2000/svg', 'stop');\n    const step = 100 / length;\n    const offset = index * step;\n    stop.setAttribute('offset', `${100 - offset}%`);\n    const rgb = `rgb(${color[0]},${color[1]},${color[2]})`;\n    stop.setAttribute('stop-color', rgb);\n\n    linearGradient.appendChild(stop);\n  }\n\n  /**\n   * Generate SVG gradient for selected color map. Used by either\n   * - interpolated layer legend or\n   * - color map select options\n   */\n  generateSVGGradientForColorMap(input: Layer<any> | number[][]) {\n    const forLayer = input instanceof Layer;\n    const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n    svg.setAttribute('width', forLayer ? '75%' : '100%');\n    svg.setAttribute('height', '100%');\n\n    const defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');\n    const linearGradient = document.createElementNS(\n      'http://www.w3.org/2000/svg',\n      'linearGradient',\n    );\n\n    const differentiator = Math.floor(Math.random() * 1000000000);\n    const id = `idwGradient-${differentiator}${\n      forLayer ? '-' + getLaymanFriendlyLayerName(input.get('name')) : ''\n    }`;\n\n    linearGradient.setAttribute('id', id);\n    linearGradient.setAttribute(\n      'gradientTransform',\n      `rotate(${input instanceof Layer ? 90 : 0})`,\n    );\n\n    const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n    rect.setAttribute('width', forLayer ? '50%' : '100%');\n    rect.setAttribute('height', '100%');\n    rect.setAttribute('fill', `url('#${id}')`);\n\n    //Gradient def generation\n    if (input instanceof Layer) {\n      const source = input.getSource();\n      const arr = Array.from(Array(100).keys());\n      for (const i of arr.filter((e, idx) => idx % 5 === 4).reverse()) {\n        const color = source.getColor(i);\n        this.appendColorToGradient(color, linearGradient, 100, i);\n      }\n    } else {\n      for (const [i, color] of input.entries()) {\n        this.appendColorToGradient(\n          color,\n          linearGradient,\n          input.length + 1,\n          input.length - i,\n        );\n      }\n    }\n\n    defs.appendChild(linearGradient);\n\n    //Layout finishes. No need for labels for select option\n    svg.appendChild(defs);\n    svg.appendChild(rect);\n    if (input instanceof Layer) {\n      const max = document.createElementNS(\n        'http://www.w3.org/2000/svg',\n        'text',\n      );\n      max.setAttribute('x', '50%');\n      max.setAttribute('y', '10%');\n      max.innerHTML = 'High';\n\n      const min = document.createElementNS(\n        'http://www.w3.org/2000/svg',\n        'text',\n      );\n      min.setAttribute('x', '50%');\n      min.setAttribute('y', '95%');\n      min.innerHTML = 'Low';\n\n      svg.appendChild(max);\n      svg.appendChild(min);\n      svg.setAttribute('style', 'max-width: 7em');\n    }\n\n    return this.sanitizer.bypassSecurityTrustHtml(svg.outerHTML);\n  }\n}\n","import {Component, EventEmitter, Input, Output} from '@angular/core';\n\n@Component({\n  template: '<div></div>',\n  standalone: true,\n})\nexport class HsStylerPartBaseComponent {\n  @Output() changes = new EventEmitter<void>();\n  @Output() deleteFilter = new EventEmitter<void>();\n\n  @Input() warning: string;\n\n  emitChange(): void {\n    this.changes.emit();\n  }\n\n  deleteRuleFilter(): void {\n    this.deleteFilter.emit();\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["VectorLayer","SLDParser","OpenLayersParser"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MCoEf,eAAe,CAAA;AA8C1B,IAAA,WAAA,GAAA;AA7CA,QAAA,IAAA,CAAA,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC;AAC3C,QAAA,IAAA,CAAA,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC7C,QAAA,IAAA,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