{"version":3,"file":"MatterParamCommon.cjs","sources":["../../../../../src/services/ESPRMMatterHelpers/TransformMatterNodeDetails/MatterParamCommon.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD\n *\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n  ClusterParamResolver,\n  XyColorComponent,\n} from \"../../../config/cluster.types\";\nimport {\n  type MatterClusterSide as MatterClusterSideType,\n} from \"../../../utils/constants\";\nimport { MatterClusterSide } from \"./types\";\n\n/** Matter cluster fields on {@link ESPRMMatterDeviceParam}. */\ninterface MatterDeviceParamFields {\n  clusterId?: number;\n  clusterType?: MatterClusterSideType;\n  endpointId?: number;\n  matterAttributeId?: number;\n  writeAsCommand?: boolean;\n  matterCommandId?: number;\n  /** Snapshot from cluster registry at transform time; used by {@link ESPRMMatterDeviceParam.setValue}. */\n  resolver?: ClusterParamResolver;\n  /**\n   * XY-compound color backing: the param has no attribute of its own — its\n   * value derives from the endpoint's (CurrentX, CurrentY) pair and writes\n   * invoke `MoveToColor`. `matterAttributeId`/`resolver` are unset.\n   */\n  xyColorComponent?: XyColorComponent;\n}\n\n/** Compiled or raw Matter cluster param produced during node transform. */\ninterface MatterMappedParamFields extends MatterDeviceParamFields {\n  clusterSide: MatterClusterSideType;\n  deviceName: string;\n}\n\nfunction parseHexId(value: string): number | undefined {\n  const id = parseInt(value, 16);\n  return Number.isNaN(id) ? undefined : id;\n}\n\nfunction formatHexId(id: number): string {\n  return `0x${id.toString(16)}`;\n}\n\nfunction parseAttributeIds(attributes?: string[] | null): number[] {\n  if (!attributes?.length) {\n    return [];\n  }\n\n  return attributes\n    .map((key) => parseHexId(key))\n    .filter((id): id is number => id !== undefined);\n}\n\nfunction clusterType(clusterId: number, side: MatterClusterSide): string {\n  return `${side}:${formatHexId(clusterId)}`;\n}\n\nexport {\n  parseAttributeIds,\n  clusterType,\n  formatHexId,\n  parseHexId,\n};\n\nexport type {\n  MatterDeviceParamFields,\n  MatterMappedParamFields,\n};\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AAmCH,SAAS,UAAU,CAAC,KAAa,EAAA;IAC/B,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;AAC9B,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,EAAE;AAC1C;AAEA,SAAS,WAAW,CAAC,EAAU,EAAA;IAC7B,OAAO,CAAA,EAAA,EAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;AAC/B;AAEA,SAAS,iBAAiB,CAAC,UAA4B,EAAA;AACrD,IAAA,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE;AACvB,QAAA,OAAO,EAAE;IACX;AAEA,IAAA,OAAO;SACJ,GAAG,CAAC,CAAC,GAAG,KAAK,UAAU,CAAC,GAAG,CAAC;SAC5B,MAAM,CAAC,CAAC,EAAE,KAAmB,EAAE,KAAK,SAAS,CAAC;AACnD;AAEA,SAAS,WAAW,CAAC,SAAiB,EAAE,IAAuB,EAAA;IAC7D,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,WAAW,CAAC,SAAS,CAAC,EAAE;AAC5C;;;;;;;"}