'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');

const DEFAULT_SIZE = { width: 0, height: 0, left: 0, top: 0 };
function useOffsets(tabs, tabSizes) {
  const offsetMap = vue.ref(/* @__PURE__ */ new Map());
  vue.watchEffect(() => {
    var _a, _b;
    const map = /* @__PURE__ */ new Map();
    const tabsValue = tabs.value;
    const lastOffset = tabSizes.value.get((_a = tabsValue[0]) == null ? void 0 : _a.key) || DEFAULT_SIZE;
    const rightOffset = lastOffset.left + lastOffset.width;
    for (let i = 0; i < tabsValue.length; i += 1) {
      const { key } = tabsValue[i];
      let data = tabSizes.value.get(key);
      if (!data)
        data = tabSizes.value.get((_b = tabsValue[i - 1]) == null ? void 0 : _b.key) || DEFAULT_SIZE;
      const entity = map.get(key) || { ...data };
      entity.right = rightOffset - entity.left - entity.width;
      map.set(key, entity);
    }
    offsetMap.value = new Map(map);
  });
  return offsetMap;
}

exports.default = useOffsets;
//# sourceMappingURL=useOffsets.cjs.map
