import { createContext } from 'react';

const dataKey = new TextEncoder().encode("1234567890123456");
const iv = new TextEncoder().encode("1234567890123456");
const encrypt = async ({ data }) => {
  const encoder = new TextEncoder();
  const encodedData = encoder.encode(data);
  const cryptoKey = await crypto?.subtle?.importKey?.(
    "raw",
    dataKey,
    { name: "AES-CBC" },
    false,
    ["encrypt"]
  );
  const encrypted = await crypto?.subtle?.encrypt?.(
    { name: "AES-CBC", iv },
    cryptoKey,
    encodedData
  );
  return btoa(String.fromCharCode(...new Uint8Array(encrypted))).substring(0, 20).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
};
const getTrackingIdHelper = async (data, component, scope) => {
  const encryption = await encrypt({ data });
  return `_${scope}_${component}_${encryption ?? ""}`;
};
const defaultContext = {
  scope: "ST",
  getTrackingId: (data, component) => getTrackingIdHelper(data, component, "ST"),
  optOut: false
};
const TrackingContext = createContext(defaultContext);

export { TrackingContext as T, getTrackingIdHelper as g };
//# sourceMappingURL=TrackingProviderContext-CrVA7KHv.js.map
