import { createLocalStore } from './local';
const store = createLocalStore('surecart-local-storage', () => ({
  live: {},
  test: {},
}), true);
export default store;
/** Get the order. */
export const getOrder = (formId, mode) => {
  var _a;
  return (_a = store.state[mode]) === null || _a === void 0 ? void 0 : _a[formId];
};
/** Set the order. */
export const setOrder = (data, formId) => {
  const mode = (data === null || data === void 0 ? void 0 : data.live_mode) ? 'live' : 'test';
  store.set(mode, { ...store.state[mode], [formId]: data });
};
/** Update the order in the store. */
export const updateOrder = (data, formId, mode) => {
  var _a;
  return store.set(mode, {
    ...store.state[mode],
    [formId]: {
      ...(((_a = store.state[mode]) === null || _a === void 0 ? void 0 : _a[formId]) || {}),
      ...data,
    },
  });
};
/** Clear the order from the store. */
export const clearOrder = (formId, mode) => {
  const { [formId]: remove, ...checkouts } = store.state[mode];
  return store.set(mode, checkouts);
};
