2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2022-03-07 09:51:47 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
import { CSSResult } from '@lit/reactive-element';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Conditionally maps cssInfos to an array ready for ShadowDom::styles
|
|
|
|
* usage.
|
|
|
|
*
|
|
|
|
* @typedef {([CSSResult, boolean] | [CSSResult])} cssInfo
|
|
|
|
* @param {(cssInfo | string)[]} entries - An array of 'entry-like' arrays of `cssInfo`s to map
|
|
|
|
*/
|
2022-09-15 08:43:17 +00:00
|
|
|
const cssMap = (entries) => {
|
2022-03-07 09:51:47 +00:00
|
|
|
return entries
|
2022-09-15 08:43:17 +00:00
|
|
|
.filter((entry) => (entry instanceof CSSResult ? true : entry[entry.length - 1]))
|
|
|
|
.map((entry) => (entry instanceof CSSResult ? entry : entry[0]));
|
2022-03-07 09:51:47 +00:00
|
|
|
};
|
|
|
|
export default helper(cssMap);
|