var _a, _b, _c, _d, _e, _f;
import { createStore } from "@stencil/store";
import env from "./helpers/env";
import getHandlebarsHelpers from "./helpers/getHandlebarsHelpers";
import setCache from "./helpers/setCache";
const { state, onChange } = createStore({
  colors: {
    primary: "#2473bb",
    "primary-rgb": "36, 115, 187",
    "primary-contrast": "#ffffff",
    "primary-contrast-rgb": "255, 255, 255",
    "primary-shade": "#2065a5",
    "primary-tint": "#3a81c2",
    secondary: "#1e3955",
    "secondary-rgb": "30, 57, 85",
    "secondary-contrast": "#ffffff",
    "secondary-contrast-rgb": "255, 255, 255",
    "secondary-shade": "#1a324b",
    "secondary-tint": "#354d66",
    tertiary: "#54b6e7",
    "tertiary-rgb": "84, 182, 231",
    "tertiary-contrast": "#ffffff",
    "tertiary-contrast-rgb": "0, 0, 0",
    "tertiary-shade": "#4aa0cb",
    "tertiary-tint": "#65bde9",
    success: "#79c79d",
    "success-rgb": "121, 199, 157",
    "success-contrast": "#000000",
    "success-contrast-rgb": "0, 0, 0",
    "success-shade": "#6aaf8a",
    "success-tint": "#86cda7",
    warning: "#ffc723",
    "warning-rgb": "255, 199, 35",
    "warning-contrast": "#000000",
    "warning-contrast-rgb": "0, 0, 0",
    "warning-shade": "#e0af1f",
    "warning-tint": "#ffcd39",
    danger: "#db3a5e",
    "danger-rgb": "219, 58, 94",
    "danger-contrast": "#ffffff",
    "danger-contrast-rgb": "255, 255, 255",
    "danger-shade": "#c13353",
    "danger-tint": "#df4e6e",
    dark: "#08141c",
    "dark-rgb": "8, 20, 28",
    "dark-contrast": "#ffffff",
    "dark-contrast-rgb": "255, 255, 255",
    "dark-shade": "#071219",
    "dark-tint": "#212c33",
    medium: "#d8d8d8",
    "medium-rgb": "190, 190, 190",
    "medium-contrast": "#000000",
    "medium-contrast-rgb": "0, 0, 0",
    "medium-shade": "#bebebe",
    "medium-tint": "#dcdcdc",
    light: "#F6F6F6",
    "light-rgb": "248, 248, 248",
    "light-contrast": "#000000",
    "light-contrast-rgb": "0, 0, 0",
    "light-shade": "#d8d8d8",
    "light-tint": "#f7f7f7",
  },
  darkMode: (((_a = localStorage === null || localStorage === void 0 ? void 0 : localStorage.getItem) === null || _a === void 0 ? void 0 : _a.call(localStorage, "floodteam:darkMode")) &&
    JSON.parse(localStorage.getItem("floodteam:darkMode"))) ||
    !!((_c = (_b = window === null || window === void 0 ? void 0 : window.matchMedia) === null || _b === void 0 ? void 0 : _b.call(window, "(prefers-color-scheme: dark)")) === null || _c === void 0 ? void 0 : _c.matches),
  manifest: {},
  config: env(),
  version: "1.2.0",
  locations: [],
  profile: {},
  session: (((_d = localStorage === null || localStorage === void 0 ? void 0 : localStorage.getItem) === null || _d === void 0 ? void 0 : _d.call(localStorage, "floodteam:session")) &&
    JSON.parse(localStorage.getItem("floodteam:session"))) ||
    null,
  services: [],
  templates: [],
  isOnline: false,
  claims: {},
  job: null,
  site: null,
  jobs: {},
  users: {},
  pins: [],
  filters: {},
  editorSizes: [50, 50],
  isPreviewing: false,
  navigationView: ((_e = localStorage === null || localStorage === void 0 ? void 0 : localStorage.getItem) === null || _e === void 0 ? void 0 : _e.call(localStorage, "floodteam:navigationView")) || "menu",
  helpers: getHandlebarsHelpers(),
  paymentMethods: [],
  roles: [
    "homeowner",
    "franchisee",
    "mitigation",
    "vision",
    "design",
    "tech",
    "finance",
    "operations",
    "success",
    "marketing",
    "agent",
    "adjuster",
    "referral",
    "vendor",
    "business",
  ],
  feedFetchData: {},
  draftNote: (((_f = localStorage === null || localStorage === void 0 ? void 0 : localStorage.getItem) === null || _f === void 0 ? void 0 : _f.call(localStorage, "floodteam:draftNote")) &&
    JSON.parse(localStorage.getItem("floodteam:draftNote"))) ||
    {},
});
onChange("darkMode", async (value) => {
  localStorage.setItem("floodteam:darkMode", JSON.stringify(value));
  if (value) {
    document.body.classList.remove("light");
    document.body.classList.add("dark");
  }
  else {
    document.body.classList.remove("dark");
    document.body.classList.add("light");
  }
});
onChange("editorSizes", async (value) => {
  await setCache("floodteam:editorSizes", value);
});
onChange("isPreviewing", async (value) => {
  await setCache("floodteam:isPreviewing", value);
});
onChange("filters", async (value) => {
  await setCache("floodteam:filters", value);
});
onChange("pins", async (value) => {
  await setCache("floodteam:pins", value);
});
onChange("jobs", async (value) => {
  if (!value)
    return;
  await setCache("floodteam:jobs", value);
});
onChange("users", async (value) => {
  if (!value)
    return;
  await setCache("floodteam:users", value);
});
onChange("claims", async (value) => {
  await setCache("floodteam:claims", value);
});
onChange("navigationView", async (value) => {
  localStorage.setItem("floodteam:navigationView", value);
});
onChange("profile", async (value) => {
  await setCache("floodteam:profile", value);
});
onChange("services", async (value) => {
  await setCache("floodteam:services", value);
});
onChange("locations", async (value) => {
  await setCache("floodteam:locations", value);
});
onChange("session", async (value) => {
  localStorage.setItem("floodteam:session", JSON.stringify(value));
});
onChange("draftNote", async (value) => {
  localStorage.setItem("floodteam:draftNote", JSON.stringify(value));
});
export default state;
