version: 3

env:
  figmaTokenVar: FIGMA_TOKEN

bridge:
  # Used by mode: mcp, motion export, and sourceExport.transport: plugin.
  # A static REST source uses it only for items routed through Plugin export.
  baseUrl: http://127.0.0.1:37830
  authTokenVar: BRIDGE_AUTH_TOKEN

state:
  file: .sxl/cache/icons-state.json

safety:
  allowOutsideWorkspace: false

sources:
  - id: ds-icons-monochrome
    mode: rest
    fileKeyVar: SXL_ICONS_FILE_KEY
    pageName: Monochrome
    downloadSpeed: 20
    # Optional description marker filter:
    # descriptionExportMarker:
    #   key: sxl-studio-export-icon
    #   includeWhenMissing: true
    selectors:
      includeComponentSetNames: []
      includeComponentNames: []

targets:
  - id: web-icons-svg
    mode: sync
    sourceIds: [ds-icons-monochrome]
    download:
      enabled: true
      pruneUntracked: false
    output:
      path: assets/icons/svg
      format: svg
      scale: 1
      quality: 100
      lossless: false
      unsafeSvgPolicy: fail # fail | embed-image-fills | embed-png
      qualitySize: null
      width: null
      height: null
      modeWH: null
    naming:
      case: kebab
      separator: "-"
      pattern: "{prefix}{variant.style}{sectionName}{baseName}{suffix}"
      prefix: null
      suffix: null
      includeSectionName: false
      collisionStrategy: add-nodeid
    font:
      enabled: true
      path: assets/icons/font
      formats: [woff2, woff, ttf, eot]
      fontName: icons
      engine: webfonts-generator
    sfSymbols:
      enabled: true
      path: assets/icons/ios
    overrides:
      # A square 24x24 vector is exported by Figma at WIDTH 128, then encoded
      # locally as a lossless 128x128 WebP without local upscaling.
      - name: illustrations-lossless-webp-128
        match:
          sectionName: Illustrations
        patch:
          output:
            format: webp
            width: 128
            height: 128
            quality: 100
            lossless: true
          sourceExport:
            transport: plugin
            format: png
            constraint:
              type: WIDTH
              value: 128

  # REST-only repair keeps the Figma REST SVG and embeds only omitted
  # IMAGE/STRETCH fills. Plugin, Bridge, and Remote Connect are not required.
  - id: media-rest-svg-repair
    mode: sync
    sourceIds: [ds-icons-monochrome]
    selectors:
      includeComponentNames: [media-preview]
    download:
      enabled: true
      pruneUntracked: false
    output:
      path: assets/icons/media-svg
      format: svg
      unsafeSvgPolicy: embed-image-fills
    naming:
      case: kebab
      separator: "-"
      prefix: null
      suffix: null
      includeSectionName: false
      collisionStrategy: add-nodeid
