{"version":3,"file":"c8y-ngx-components-branding-shared-data.mjs","sources":["../../branding/shared/data/apply-branding-locally.service.ts","../../branding/shared/data/branding-shades.service.ts","../../branding/shared/data/branding-version.service.ts","../../branding/shared/data/branding.type.ts","../../branding/shared/data/branding-tracking.service.ts","../../branding/shared/data/store-branding.service.ts","../../branding/shared/data/c8y-ngx-components-branding-shared-data.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { OptionsService } from '@c8y/ngx-components';\nimport { BrandingOptionsJson } from './branding.type';\nimport { applyBrandingOptions, getOptionsToMerge, mergeOptions } from '@c8y/bootstrap';\n\n@Injectable({ providedIn: 'root' })\nexport class ApplyBrandingLocallyService {\n  private keysToRemove: Array<string> | null;\n\n  constructor(private options: OptionsService) {}\n\n  applyBranding(optionsJson?: BrandingOptionsJson) {\n    if (!this.keysToRemove) {\n      this.keysToRemove = Object.keys(this.combineOptions());\n    }\n    const combinedOptions = this.combineOptions(optionsJson);\n    const newKeysToRemove = Object.keys(combinedOptions);\n\n    // avoid to remove keys that would actually be set again afterwards\n    const keysToActuallyRemove = this.keysToRemove.filter(key => !newKeysToRemove.includes(key));\n    this.removeKeysFromOptions(keysToActuallyRemove);\n\n    this.keysToRemove = newKeysToRemove;\n\n    applyBrandingOptions(combinedOptions);\n    this.applyApplicationOptions(combinedOptions);\n  }\n\n  resetBranding() {\n    this.applyBranding();\n  }\n\n  private applyApplicationOptions(optionsJson: any) {\n    Object.entries(optionsJson).forEach(([key, value]) => {\n      this.options.set(key, value);\n    });\n  }\n\n  private removeKeysFromOptions(keys: string[]) {\n    for (const key of keys) {\n      this.options.delete(key);\n    }\n  }\n\n  private combineOptions(optionsJson?: BrandingOptionsJson) {\n    const optionsToMerge = getOptionsToMerge();\n    if (!optionsToMerge) {\n      // should never happen as the options should be set quite early in bootstrapping process.\n      throw Error(`Failed to retrieve options for merging`);\n    }\n    if (optionsJson) {\n      optionsToMerge.dynamicOptions = optionsJson;\n    }\n    return mergeOptions(optionsToMerge);\n  }\n}\n","import { Injectable } from '@angular/core';\nimport { default as chroma } from 'chroma-js';\n\n@Injectable({ providedIn: 'root' })\nexport class BrandingShadesService {\n  getShadeColorBrandingCssVars(newBrandPrimary: string) {\n    const shades = this.generateShades(newBrandPrimary);\n    return this.shadesToObject(shades);\n  }\n\n  isValidShadeColor(color: string): boolean {\n    try {\n      return chroma.valid(color);\n    } catch {\n      return false;\n    }\n  }\n\n  hasCustomShadesSet(\n    previousBrandPrimary: string,\n    otherVars: Record<string, string | number>\n  ): boolean {\n    if (previousBrandPrimary && otherVars) {\n      const oldShades = this.generateShades(previousBrandPrimary);\n      const oldShadesObj = this.shadesToObject(oldShades);\n      for (const shadeKey of Object.keys(oldShadesObj)) {\n        const fromVars = otherVars[shadeKey];\n        const generated = oldShadesObj[shadeKey];\n        if (fromVars === null || fromVars === undefined) {\n          continue;\n        }\n        if (fromVars !== generated) {\n          return true;\n        }\n      }\n    }\n    return false;\n  }\n\n  private shadesToObject(shades: string[]) {\n    const brandingCssVars: Record<`c8y-brand-${number}0`, string> = {};\n    let i = 1;\n    for (const shade of shades) {\n      const key = `c8y-brand-${i}0` as const;\n      brandingCssVars[key] = shade;\n      i++;\n    }\n\n    return brandingCssVars;\n  }\n\n  private generateShades(inputColor: string) {\n    const referenceShades = [\n      '#134158',\n      '#1C5569',\n      '#058192', // primary color\n      '#22A6AA',\n      '#3CC1B7',\n      '#8ADBD5',\n      '#C5EDEA',\n      '#EBF9F8'\n    ];\n    // Calculate the luminance of the reference shades\n    const referenceLuminances = referenceShades.map(color => chroma(color).luminance());\n    const inputColorAsHex = chroma(inputColor);\n    // Generate shades of the input color with the same luminance as the reference shades\n    const generatedShades = referenceLuminances.map(luminance =>\n      chroma(inputColor).luminance(luminance).hex('rgb')\n    );\n    // Calculate the distance between the input color and each color in the generatedShades array\n    const distances = generatedShades.map(color => chroma.deltaE(inputColorAsHex, color));\n    // Find the index of the color with the smallest distance\n    const index = distances.indexOf(Math.min(...distances));\n    generatedShades[index] = inputColorAsHex.hex('rgb');\n    return generatedShades;\n  }\n}\n","import { Injectable } from '@angular/core';\n\n/**\n * Service for creating and manipulating branding versions.\n */\n@Injectable({\n  providedIn: 'root'\n})\nexport class BrandingVersionService {\n  static readonly nameAndIterationSeparator = '-';\n\n  /**\n   * Creates the initial branding version for a given name.\n   * @param name The name of the branding.\n   * @returns The initial branding version.\n   */\n  createInitialBrandingVersion<T extends string>(name: T) {\n    return `${name}${BrandingVersionService.nameAndIterationSeparator}${1}` as const;\n  }\n\n  /**\n   * Splits a branding version into its name and iteration.\n   * @param version The branding version to split.\n   * @returns The name and iteration of the branding version.\n   *\n   * Errors are thrown if the version is not in the expected format.\n   */\n  splitBrandingIntoNameAndIteration(version: string): { name: string; iteration: number } {\n    const splitted = version.split(BrandingVersionService.nameAndIterationSeparator);\n    if (splitted.length < 2) {\n      throw Error(\n        `A valid version should at least conatin one '${BrandingVersionService.nameAndIterationSeparator}', this is not the case for '${version}'`\n      );\n    }\n\n    const lastValueOfSplittedArray = splitted[splitted.length - 1];\n    if (lastValueOfSplittedArray === '' || !/[0-9]+/.test(lastValueOfSplittedArray)) {\n      throw Error(\n        `The second part of the version should be a positive integer, this is not the case for '${lastValueOfSplittedArray}' from '${version}'`\n      );\n    }\n\n    const iteration = Number.parseInt(lastValueOfSplittedArray);\n    if (Number.isNaN(iteration) && iteration <= 0) {\n      throw Error(\n        `The second part of the version should be a positive integer, this is not the case for '${iteration}' from '${version}'`\n      );\n    }\n\n    const name = splitted.slice(0, -1).join(BrandingVersionService.nameAndIterationSeparator);\n    if (!name) {\n      throw Error(\n        `The first part of the version should not be empty, this is the case for '${name}' from '${version}'`\n      );\n    }\n\n    return { iteration, name };\n  }\n\n  /**\n   * Bumps the iteration of a branding version.\n   * @param version The branding version to bump.\n   * @returns The bumped branding version.\n   *\n   * Errors are thrown if the version is not in the expected format.\n   */\n  bumpBrandingIteration(version: string) {\n    const { name, iteration } = this.splitBrandingIntoNameAndIteration(version);\n    return `${name}${BrandingVersionService.nameAndIterationSeparator}${iteration + 1}` as const;\n  }\n}\n","import type { FormBuilder, FormControl } from '@angular/forms';\nimport { Alert, colorValidator, ApplicationOptions } from '@c8y/ngx-components';\n\nexport type BrandingFormValue = ReturnType<typeof createGenericBrandingForm>['value'];\nexport type BrandingFormKeys = keyof BrandingFormValue;\nexport type BrandingFormTopLevelKeys = (typeof brandingFormGroupTopLevelEntries)[number];\nexport type BrandingFormTopLevelKeysToUnpack =\n  (typeof brandingFormGroupTopLevelEntriesToUnpack)[number];\n\nexport type TopLevelFormKeysNotToUnpack = Exclude<\n  BrandingFormTopLevelKeys,\n  BrandingFormTopLevelKeysToUnpack\n>;\nexport type UnpackedTopLevelFormKeys = Pick<\n  BrandingFormValue,\n  BrandingFormTopLevelKeysToUnpack\n>[keyof Pick<BrandingFormValue, BrandingFormTopLevelKeysToUnpack>];\n\nexport type NotUnpackedTopLevelFormKeys = Pick<BrandingFormValue, TopLevelFormKeysNotToUnpack>;\nexport type TopLevelForm = NotUnpackedTopLevelFormKeys & UnpackedTopLevelFormKeys;\nexport type TopLevelValues = TopLevelForm;\n\nexport type BrandingCSSVarsForm = Omit<BrandingFormValue, BrandingFormTopLevelKeys>;\n\nexport type LightBrandingCSSVarsValues = ReturnType<typeof createBrandingForm>['value'] &\n  BrandingCSSVarsForm[keyof BrandingCSSVarsForm];\n\ntype addPrefixToObject<T, P extends string> = {\n  [K in keyof T as K extends string ? `${P}${K}` : never]: T[K];\n};\n\nexport type DarkBrandingCSSVarsValues = addPrefixToObject<LightBrandingCSSVarsValues, 'dark-'>;\n\nexport type BrandingCSSVarsValues = LightBrandingCSSVarsValues & DarkBrandingCSSVarsValues;\n\nexport type BrandingOptionsJson = TopLevelValues & {\n  brandingCssVars?: BrandingCSSVarsValues & { [key: string]: any };\n} & Omit<Partial<ApplicationOptions>, 'brandingCssVars'> & { [key: string]: any };\n\nexport const brandingFormGroupTopLevelEntries = [\n  'cookieBanner',\n  'genericApplicationOptions',\n  'darkThemeAvailable',\n  'messageBanner'\n] as const satisfies ReadonlyArray<BrandingFormKeys>;\nexport const brandingFormGroupTopLevelEntriesToUnpack = [\n  'genericApplicationOptions'\n] as const satisfies ReadonlyArray<(typeof brandingFormGroupTopLevelEntries)[number]>;\n\nexport const numberBrandingVars = ['brand-logo-img-height', 'btn-border-radius-base'] as const;\nexport const colorBrandingVars = [\n  'brand-dark',\n  'brand-light',\n  'brand-primary',\n  'c8y-brand-10',\n  'c8y-brand-20',\n  'c8y-brand-30',\n  'c8y-brand-40',\n  'c8y-brand-50',\n  'c8y-brand-60',\n  'c8y-brand-70',\n  'c8y-brand-80',\n  'palette-status-info',\n  'palette-status-warning',\n  'palette-status-success',\n  'palette-status-danger',\n  'palette-status-info-light',\n  'palette-status-warning-light',\n  'palette-status-success-light',\n  'palette-status-danger-light',\n  'palette-status-info-dark',\n  'palette-status-warning-dark',\n  'palette-status-success-dark',\n  'palette-status-danger-dark',\n  'body-background-color',\n  'text-color',\n  'text-muted',\n  'link-color',\n  'link-hover-color',\n  'action-bar-background-default',\n  'action-bar-color-actions-hover',\n  'action-bar-color-actions',\n  'action-bar-color-default',\n  'action-bar-icon-color',\n  'header-color',\n  'header-text-color',\n  'header-hover-color',\n  'navigator-bg-color',\n  'navigator-active-bg',\n  'navigator-border-active',\n  'navigator-header-bg',\n  'navigator-title-color',\n  'navigator-separator-color',\n  'navigator-text-color',\n  'navigator-color-active',\n  'right-drawer-background-default',\n  'right-drawer-text-color-default',\n  'right-drawer-separator-color',\n  'right-drawer-link-color',\n  'right-drawer-link-color-hover',\n  'right-drawer-text-color-muted'\n] as const;\nexport const stringBrandingVars = [\n  'brand-logo-img',\n  'navigator-platform-logo',\n  'login-platform-animation-img'\n] as const;\n\nexport const stringOrNumberBrandingVars = ['navigator-platform-logo-height'] as const;\n\nexport const allBrandingCSSVars = [\n  ...numberBrandingVars,\n  ...stringBrandingVars,\n  ...colorBrandingVars\n] as const;\n\nexport function createGenericBrandingForm(formBuilder: FormBuilder) {\n  const form = formBuilder.group({\n    darkThemeAvailable: formBuilder.control<boolean>(false),\n    cookieBanner: formBuilder.group({\n      cookieBannerTitle: formBuilder.control<string>(undefined),\n      cookieBannerText: formBuilder.control<string>(undefined),\n      cookieBannerDisabled: formBuilder.control(false),\n      policyUrl: formBuilder.control<string>(undefined),\n      policyVersion: formBuilder.control<string>(undefined)\n    }),\n    messageBanner: formBuilder.group({\n      messageBannerEnabled: formBuilder.control(false),\n      messageBannerContent: formBuilder.control<string>(''),\n      messageBannerType: formBuilder.control<Alert['type']>('info'),\n      messageBannerId: formBuilder.control<string>('')\n    }),\n    baseTypography: formBuilder.group({\n      'font-url': formBuilder.control<string>(undefined),\n      'font-family-base': formBuilder.control<string>(undefined)\n    }),\n    headingsAndNavigatorTypography: formBuilder.group({\n      'font-family-headings': formBuilder.control<string>(undefined),\n      'navigator-font-family': formBuilder.control<string>('var(--font-family-base)')\n    }),\n    genericApplicationOptions: formBuilder.group({\n      globalTitle: formBuilder.control<string>(undefined),\n      faviconUrl: formBuilder.control<string>(undefined)\n    })\n  });\n  return form;\n}\n\nexport function createBrandingForm(formBuilder: FormBuilder) {\n  const colorControls = colorBrandingVars.reduce(\n    (acc, key) => {\n      acc[key] = formBuilder.control<string>(undefined, { asyncValidators: [colorValidator()] });\n      return acc;\n    },\n    {} as { [key in (typeof colorBrandingVars)[number]]: FormControl<string> }\n  );\n  const stringControls = stringBrandingVars.reduce(\n    (acc, key) => {\n      acc[key] = formBuilder.control<string>(undefined);\n      return acc;\n    },\n    {} as { [key in (typeof stringBrandingVars)[number]]: FormControl<string> }\n  );\n  const numberControls = numberBrandingVars.reduce(\n    (acc, key) => {\n      acc[key] = formBuilder.control<number>(undefined);\n      return acc;\n    },\n    {} as { [key in (typeof numberBrandingVars)[number]]: FormControl<number> }\n  );\n  const stringOrNumberControls = stringOrNumberBrandingVars.reduce(\n    (acc, key) => {\n      acc[key] = formBuilder.control<number>(undefined);\n      return acc;\n    },\n    {} as {\n      [key in (typeof stringOrNumberBrandingVars)[number]]: FormControl<string | number>;\n    }\n  );\n  const form = formBuilder.group({\n    ...colorControls,\n    ...stringControls,\n    ...numberControls,\n    ...stringOrNumberControls\n  });\n\n  return form;\n}\n","import { Injectable, Optional } from '@angular/core';\nimport { GainsightService, PxEventData } from '@c8y/ngx-components';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class BrandingTrackingService {\n  readonly prefix = 'brandingManager';\n  constructor(@Optional() private gainsight: GainsightService) {}\n\n  getStartedUsingBranding() {\n    this.triggerEvent('getStartedUsingBranding');\n  }\n\n  deleteAllBrandings() {\n    this.triggerEvent('deleteAllBrandings');\n  }\n\n  exportBranding() {\n    this.triggerEvent('exportBranding');\n  }\n\n  addNewVersion() {\n    this.triggerEvent('addNewVersion');\n  }\n\n  duplicateVersion() {\n    this.triggerEvent('duplicateVersion');\n  }\n\n  applyToApps(apps: string[]) {\n    this.triggerEvent('applyToApps', { apps });\n  }\n\n  importBranding() {\n    this.triggerEvent('importBranding');\n  }\n\n  deleteBrandingVariant() {\n    this.triggerEvent('deleteBrandingVariant');\n  }\n\n  openPreviewForBranding() {\n    this.triggerEvent('openPreviewForBranding');\n  }\n\n  private triggerEvent(action: string, props?: PxEventData) {\n    if (!this.gainsight) {\n      return;\n    }\n\n    const finalProps = {\n      ...props,\n      action\n    };\n\n    return this.gainsight.triggerEvent(this.prefix, finalProps);\n  }\n}\n","import { Injectable } from '@angular/core';\nimport {\n  ApplicationAvailability,\n  ApplicationType,\n  FetchClient,\n  IApplication,\n  IApplicationBinary,\n  IManagedObject,\n  InventoryBinaryService,\n  InventoryService\n} from '@c8y/client';\nimport { ApplicationService } from '@c8y/client';\nimport { AppStateService, ThemeSwitcherService, ZipService } from '@c8y/ngx-components';\nimport { defer, BehaviorSubject, Observable } from 'rxjs';\nimport { map, switchMap } from 'rxjs/operators';\nimport { cloneDeep, uniq } from 'lodash-es';\nimport { BrandingVersionService } from './branding-version.service';\nimport { BrandingOptionsJson, allBrandingCSSVars, numberBrandingVars } from './branding.type';\nimport { StaticAsset, StaticAssetsService } from '@c8y/ngx-components/static-assets/data';\nimport { BrandingTrackingService } from './branding-tracking.service';\n\nexport interface BrandVersion {\n  name: string;\n  id: string;\n  revision: number;\n  version: string;\n  tags: string[];\n  owner?: string;\n  lastUpdated?: string;\n  publicOptionsApp?: IApplication;\n}\n\nexport interface BrandingFileDetails {\n  fileName: string;\n  blob: Blob;\n  jsonContent?: any;\n}\n\nexport interface BrandingFileDetailsLegacy {\n  path: string;\n  value: string;\n  blob?: Blob;\n  fileName: string;\n  urlWrapped: boolean;\n}\n\n/**\n * Service to load and store the branding of the tenant.\n */\n@Injectable({ providedIn: 'root' })\nexport class StoreBrandingService {\n  readonly fileNames = {\n    options: 'options.json',\n    manifest: 'cumulocity.json',\n    exportZipName: 'public-options.zip'\n  } as const;\n  readonly manifestValues = {\n    name: 'public-options',\n    contextPath: 'public-options',\n    key: 'public-options-key',\n    description: 'Application containing static assets used by e.g. branding.',\n    noAppSwitcher: true,\n    type: ApplicationType.HOSTED,\n    availability: ApplicationAvailability.SHARED\n  } as const satisfies IApplication;\n  refreshTriggerBrandingVariants = new BehaviorSubject<void>(null);\n  constructor(\n    private applicationService: ApplicationService,\n    private inventory: InventoryService,\n    private binary: InventoryBinaryService,\n    private zip: ZipService,\n    private fetch: FetchClient,\n    private brandingVersionService: BrandingVersionService,\n    private appState: AppStateService,\n    private staticAssets: StaticAssetsService,\n    private themeSwitcher: ThemeSwitcherService,\n    private brandingTracking: BrandingTrackingService\n  ) {}\n\n  /**\n   * Sets the `latest` tag on the provided branding version. Making it the global active branding.\n   */\n  async markAsActive(brandingVersion: BrandVersion, app?: IApplication): Promise<void> {\n    const publicOptions = app || (await this.getPublicOptionsApp());\n    const tags = brandingVersion.tags || [];\n    const version = brandingVersion.version;\n    await this.applicationService.setPackageVersionTag(publicOptions, version, [...tags, 'latest']);\n  }\n\n  /**\n   * Opens a new tab with to preview the branding. The branding must have been saved beforehand.\n   * @param brandingName the name of the branding to be previewed\n   */\n  openPreviewForBranding(brandingName: string) {\n    this.brandingTracking.openPreviewForBranding();\n    window.open(\n      `/apps/${\n        this.appState.currentApplication.value?.contextPath || 'cockpit'\n      }/index.html?brandingPreview=true&dynamicOptionsUrl=/apps/public/public-options@${brandingName}/options.json`,\n      '_blank',\n      'noopener,noreferrer'\n    );\n  }\n\n  /**\n   * Returns the brandings of the tenant.\n   * If no public options app is found, publicOptions will be undefined and variants an empty array.\n   * For old brandings (created without versioning) a default version is returned.\n   */\n  async loadBrandingVariants(\n    app?: IApplication\n  ): Promise<{ publicOptions: IApplication | undefined; variants: BrandVersion[] }> {\n    const publicOptions = app || (await this.getPublicOptionsApp());\n    if (!publicOptions) {\n      return { publicOptions: undefined, variants: [] };\n    }\n    const { data: versions } = await this.applicationService.listVersions(publicOptions);\n    let mappedVersions: BrandVersion[] =\n      versions\n        ?.map(tmp => {\n          try {\n            const { name, iteration } =\n              this.brandingVersionService.splitBrandingIntoNameAndIteration(tmp.version);\n            return {\n              revision: iteration,\n              name: name,\n              id: tmp.binaryId,\n              version: tmp.version,\n              tags: tmp.tags || [],\n              publicOptionsApp: publicOptions\n            };\n          } catch (e) {\n            console.warn('Failed to parse version', tmp, e);\n            return undefined;\n          }\n        })\n        ?.filter(Boolean) || [];\n    if (!versions && publicOptions.activeVersionId) {\n      mappedVersions = [\n        {\n          name: 'default',\n          id: publicOptions.activeVersionId,\n          version: 'default-1',\n          revision: 1,\n          tags: ['latest', 'default'],\n          publicOptionsApp: publicOptions\n        }\n      ];\n    }\n\n    const variants = await this.getMetadataOfBrandingBinaries(mappedVersions);\n    return { publicOptions, variants };\n  }\n\n  /**\n   * As the branding is not immediately available after creation, this method will wait for the branding to be present.\n   * @param version The version of the branding to be retrieved.\n   */\n  async waitForBrandingToBePresent(version: string): Promise<void> {\n    const numberOfAttempts = 120;\n    const sleepDurationInSeconds = 1;\n    for (let i = 0; i < numberOfAttempts; i++) {\n      try {\n        // do not sleep before the first attempt\n        if (i !== 0) {\n          await new Promise(resolve => setTimeout(resolve, sleepDurationInSeconds * 1_000));\n        }\n        await this.getBrandingOptionsForVersion(version);\n        console.info(`Branding \"${version}\" available now.`);\n        return;\n      } catch (e) {\n        console.warn(\n          `Branding \"${version}\" not yet present, retrying in ${sleepDurationInSeconds} seconds...`,\n          e\n        );\n      }\n    }\n    throw new Error(\n      `Branding \"${version}\" not available after ${numberOfAttempts * sleepDurationInSeconds} seconds, giving up.`\n    );\n  }\n\n  /**\n   * Will create a the initial branding based on the currently applied CSS variables.\n   */\n  async getStartedUsingBranding(): Promise<void> {\n    const allVariables: Record<string, string> = {};\n    const themeToRetrieveVars = ['light', 'dark'] as const;\n    const unretrievableVars = new Array<string>();\n    for (const theme of themeToRetrieveVars) {\n      this.themeSwitcher.temporaryChangeTheme(theme);\n      const styles = getComputedStyle(document.body);\n      const variablesToSkip = [\n        'navigator-platform-logo',\n        'brand-logo-img'\n      ] satisfies (typeof allBrandingCSSVars)[number][];\n      const values = allBrandingCSSVars\n        .filter(cssVar => !variablesToSkip.includes(cssVar as any))\n        .reduce((prev, key) => {\n          const directValue = styles.getPropertyValue(`--${key}`);\n          const c8yPrefixedValue = styles.getPropertyValue(`--c8y-${key}`);\n          const newKey = theme === 'light' ? key : `dark-${key}`;\n          if (!directValue && !c8yPrefixedValue) {\n            unretrievableVars.push(newKey);\n            return prev;\n          }\n          let value: string | number = directValue || c8yPrefixedValue;\n          if (numberBrandingVars.includes(key as any)) {\n            try {\n              value = Number.parseFloat(value.replace(/[A-Za-z]/g, '').trim());\n            } catch (e) {\n              console.warn(\n                `Failed to parse number for \"${key}\" value that failed to parse: \"${value}\"`,\n                e\n              );\n              return prev;\n            }\n          }\n          return Object.assign(prev, { [newKey]: value });\n        }, {});\n      Object.assign(allVariables, values);\n    }\n    this.themeSwitcher.resetTemporaryTheme();\n\n    try {\n      await this.createPublicOptionsAppFromInheritedOptions(allVariables);\n    } catch (e) {\n      console.warn(e);\n    }\n  }\n\n  getZipForBinary(\n    binaryId: string,\n    fileName: string = this.fileNames.exportZipName\n  ): Observable<File> {\n    return defer(() => this.binary.download(binaryId)).pipe(\n      switchMap(response => response.blob()),\n      map(blob => new File([blob], fileName))\n    );\n  }\n\n  /**\n   * Deletes the public options app and therefore all brandings.\n   * The public options app can be optionally provided to avoid another request for it.\n   */\n  async deleteAllBrandings(publicOptions?: IApplication): Promise<void> {\n    publicOptions = publicOptions || (await this.getPublicOptionsApp());\n    await this.applicationService.delete(publicOptions);\n  }\n\n  /**\n   * Enhances the provided branding versions with metadata from the linked binaries.\n   * It will add the owner and lastUpdated fields to the versions.\n   * The provided array is altered.\n   */\n  async getMetadataOfBrandingBinaries(versions: BrandVersion[]): Promise<BrandVersion[]> {\n    const binaryIds = uniq(versions.map(tmp => tmp.id));\n    if (!binaryIds.length) {\n      return versions;\n    }\n    const { data: metadata } = await this.inventory.list({\n      ids: binaryIds.join(','),\n      pageSize: 2000\n    });\n    return versions.map(version => {\n      const metadataForVersion =\n        metadata.find(tmp => tmp.id === version.id) || ({} as IManagedObject);\n      const { owner, lastUpdated } = metadataForVersion;\n      return Object.assign(version, { owner, lastUpdated });\n    });\n  }\n\n  /**\n   * Saves the provided branding as a new version for the public options app.\n   * The public options app can be optionally provided to avoid another request for it.\n   */\n  async saveBranding(\n    blob: Blob | File,\n    version: string,\n    tags: string[] = [],\n    publicOptionsApp?: IApplication\n  ): Promise<{\n    version: string;\n    binary: IApplicationBinary;\n    tags: string[];\n  }> {\n    const file = blob instanceof File ? blob : new File([blob], `public-options-${version}.zip`);\n    const publicOptions = publicOptionsApp || (await this.getPublicOptionsApp());\n\n    const { data: binary } = await this.applicationService\n      .binary(publicOptions)\n      .uploadApplicationVersion(file, version, tags);\n    if (!publicOptions.activeVersionId || tags.includes('latest')) {\n      await this.applicationService.update({\n        id: publicOptions.id,\n        activeVersionId: `${binary.binaryId}`\n      });\n    }\n    this.refreshTriggerBrandingVariants.next();\n    return { version, binary, tags };\n  }\n\n  /**\n   * Removes a branding version from the public options app.\n   * The public options app can be optionally provided to avoid another request for it.\n   */\n  async deleteBrandingVersion(version: string, publicOptions?: IApplication): Promise<void> {\n    publicOptions = publicOptions || (await this.getPublicOptionsApp());\n    await this.applicationService.deleteVersionPackage(publicOptions, { version });\n    this.refreshTriggerBrandingVariants.next();\n  }\n\n  /**\n   * Returns the blob of a zip file containing the provided branding options (options.json) and the manifest (cumulocity.json).\n   */\n  async getBrandingZip(content: Record<string, any> = {}): Promise<Blob> {\n    content.lastUpdated = new Date().toISOString();\n    const contentAsString = JSON.stringify(content);\n    const zip = await this.zip.createZip([\n      { fileName: this.fileNames.options, blob: new Blob([contentAsString]) },\n      { fileName: this.fileNames.manifest, blob: new Blob([JSON.stringify(this.manifestValues)]) }\n    ]);\n    return zip;\n  }\n\n  /**\n   * Adds a new branding version to the public options app.\n   * The public options app can be optionally provided to avoid another request for it.\n   */\n  async addBranding(\n    version: string,\n    content: BrandingOptionsJson = {},\n    tags: string[] = [],\n    publicOptionsApp?: IApplication\n  ): Promise<{\n    version: string;\n    binary: IApplicationBinary;\n    tags: string[];\n  }> {\n    const zip = await this.getBrandingZip(content);\n\n    return await this.saveBranding(zip, version, tags, publicOptionsApp);\n  }\n\n  /**\n   * Returns the branding options for the provided version.\n   * If no branding was found (e.g. status 404), an error is thrown.\n   */\n  async getBrandingOptionsForVersion(version?: string): Promise<BrandingOptionsJson> {\n    const url = `/apps/public/public-options${version ? `@${version}` : ''}/${this.fileNames.options}?nocache=${new Date().getTime()}`;\n    const response = await this.fetch.fetch(url);\n    if (response.status !== 200) {\n      throw Error(`Unexpected status code: ${response.status}`);\n    }\n\n    const content = await response.json();\n    return content as BrandingOptionsJson;\n  }\n\n  /**\n   * Saves a new iteration of an already existing branding.\n   */\n  async saveExistingBranding(\n    branding: Record<string, any>,\n    currentVersion: string,\n    tagsOfCurrentVersion: string[] = [],\n    newVersion?: string\n  ): Promise<string> {\n    const publicOptions = await this.getPublicOptionsApp();\n    const versionToBeSet = newVersion\n      ? this.brandingVersionService.createInitialBrandingVersion(newVersion)\n      : this.brandingVersionService.bumpBrandingIteration(currentVersion);\n\n    const finalTags = tagsOfCurrentVersion;\n    // only apply latest tag directly\n    // there seems to be some special handling for the latest tag in the backend, that allows to directly move it while uploading the new version.\n    // for all other tags this results in a 409 conflict. We therefore need to first delete the old version, before setting the other tags on the new version.\n    if (!newVersion) {\n      tagsOfCurrentVersion = tagsOfCurrentVersion.filter(tag => tag === 'latest');\n    }\n    await this.addBranding(versionToBeSet, branding, tagsOfCurrentVersion, publicOptions);\n    if (!newVersion) {\n      try {\n        await this.deleteBrandingVersion(currentVersion, publicOptions);\n      } catch (e) {\n        if (e.res.status !== 404) {\n          throw e;\n        }\n      }\n      await this.applicationService.setPackageVersionTag(publicOptions, versionToBeSet, finalTags);\n    }\n\n    return versionToBeSet;\n  }\n\n  /**\n   * Combines current branding options with the provided branding variables and creates a new public options app.\n   * Any assets in the branding will be cloned.\n   */\n  async createPublicOptionsAppFromInheritedOptions(brandingVars?: Record<string, string>): Promise<{\n    version: string;\n    binary: IApplicationBinary;\n    tags: string[];\n  }> {\n    let currentlyAppliedBranding: BrandingOptionsJson;\n    let fallBackBranding: BrandingOptionsJson = {};\n    try {\n      currentlyAppliedBranding = await this.getBrandingOptionsForVersion();\n      fallBackBranding = cloneDeep(currentlyAppliedBranding);\n    } catch (e) {\n      console.warn('Failed to get currently applied branding, proceeding with empty branding.', e);\n    }\n\n    if (brandingVars) {\n      currentlyAppliedBranding = currentlyAppliedBranding || {};\n      const brandingCssVars = currentlyAppliedBranding.brandingCssVars || {};\n      Object.assign(brandingCssVars, brandingVars);\n      currentlyAppliedBranding.brandingCssVars = brandingCssVars;\n    }\n\n    if (currentlyAppliedBranding) {\n      try {\n        const { oldAssets, newAssets } = await this.staticAssets.cloneAssetsIntoTenant('branding');\n        currentlyAppliedBranding = this.replaceBrandingAssetsInBrandingOptions(\n          currentlyAppliedBranding,\n          oldAssets,\n          newAssets\n        );\n      } catch (e) {\n        console.warn('Failed to relocate branding assets into current tenant.', e);\n      }\n    }\n\n    const publicOptionsApp = await this.createPublicOptionsApp();\n\n    const defaultBrandingName = `default`;\n    const result = await this.addBranding(\n      this.brandingVersionService.createInitialBrandingVersion(defaultBrandingName),\n      currentlyAppliedBranding || {},\n      ['latest', defaultBrandingName],\n      publicOptionsApp\n    );\n\n    const fallbackBrandingName = `fallback`;\n    await this.addBranding(\n      this.brandingVersionService.createInitialBrandingVersion(fallbackBrandingName),\n      fallBackBranding,\n      [fallbackBrandingName],\n      publicOptionsApp\n    );\n\n    return result;\n  }\n\n  /**\n   * Replaces the assets in the branding options with the new assets.\n   * Goes through the provided `oldAssets` and replaces their occurrences in the branding with the corresponding `newAssets` entry sharing the same fileName.\n   * Returns the updated branding options.\n   */\n  replaceBrandingAssetsInBrandingOptions(\n    branding: BrandingOptionsJson,\n    oldAssets: StaticAsset[],\n    newAssets: StaticAsset[]\n  ): BrandingOptionsJson {\n    let brandingAsJSONString = JSON.stringify(branding);\n    for (const oldAsset of oldAssets) {\n      const newLocatedAsset = newAssets.find(tmp => tmp.fileName === oldAsset.fileName);\n      if (!newLocatedAsset) {\n        continue;\n      }\n      // if the path is the same, we don't need to replace it.\n      if (oldAsset.path === newLocatedAsset.path) {\n        continue;\n      }\n\n      // TODO: use proper replaceAll once it's available with es2021\n      brandingAsJSONString = brandingAsJSONString.split(oldAsset.path).join(newLocatedAsset.path);\n    }\n    return JSON.parse(brandingAsJSONString);\n  }\n\n  private async getPublicOptionsApp() {\n    try {\n      const { data: manifest } = await this.applicationService.getManifestOfContextPath(\n        this.manifestValues.contextPath\n      );\n      const { data: app } = await this.applicationService.detail(manifest.id);\n      if (app.owner.tenant.id !== this.appState.currentTenant.value?.name) {\n        return undefined;\n      }\n      return app;\n    } catch (e) {\n      // e.g. reached when no app with the given context path exists\n      return undefined;\n    }\n  }\n\n  private async createPublicOptionsApp() {\n    const { data: app } = await this.applicationService.create(this.manifestValues);\n    return app;\n  }\n}\n","/**\n * Generated bundle index. Do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