"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "useMergedTabsterAttributes_unstable", { enumerable: true, get: function() { return useMergedTabsterAttributes_unstable; } }); const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard"); const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react")); const _tabster = require("tabster"); const useMergedTabsterAttributes_unstable = (...attributes)=>{ 'use no memo'; const stringAttributes = attributes.map((attribute)=>attribute[_tabster.TABSTER_ATTRIBUTE_NAME]).filter(Boolean); return _react.useMemo(()=>{ let attribute = stringAttributes[0]; attributes.shift(); for (const attr of stringAttributes){ attribute = mergeAttributes(attribute, attr); } return { [_tabster.TABSTER_ATTRIBUTE_NAME]: attribute }; // eslint-disable-next-line react-hooks/exhaustive-deps }, stringAttributes); }; function mergeAttributes(a, b) { if (!b) { return a; } let aParsed = {}; let bParsed = {}; if (a) { try { aParsed = JSON.parse(a); // eslint-disable-next-line no-empty } catch {} } if (b) { try { bParsed = JSON.parse(b); // eslint-disable-next-line no-empty } catch {} } return JSON.stringify({ ...aParsed, ...bParsed }); }