+/**
+ * Gets the connector cloned charging profiles applying a power limitation
+ * and sorted by connector id descending then stack level descending
+ *
+ * @param chargingStation -
+ * @param connectorId -
+ * @returns connector charging profiles array
+ */
+export const getConnectorChargingProfiles = (
+ chargingStation: ChargingStation,
+ connectorId: number,
+) => {
+ return cloneObject<ChargingProfile[]>(
+ (chargingStation.getConnectorStatus(connectorId)?.chargingProfiles ?? [])
+ .sort((a, b) => b.stackLevel - a.stackLevel)
+ .concat(
+ (chargingStation.getConnectorStatus(0)?.chargingProfiles ?? []).sort(
+ (a, b) => b.stackLevel - a.stackLevel,
+ ),
+ ),
+ );
+};
+