sanity-plugin-all-in-one-accessibility 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useColorSchemeValue, useColorSchemeSetValue, useCurrentUser, definePlugin } from "sanity";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import { forwardRef, createContext, useContext, useRef, useEffect, useState, useCallback, useMemo } from "react";
4
- const AIOA_API_BASE = "https://ada.skynettechnologies.us/api/", AIOA_UPDATE_API = `${AIOA_API_BASE}widget-setting-update-platform`, AIOA_PLATFORM = "sanity", AIOA_WIDGET_SETTINGS_API = "https://freeada.skynettechnologies.com/api/widget-settings", AIOA_CHECK_WEBSITE_API = "https://ada.skynettechnologies.us/check-website", AIOA_GEO_API = "https://ipapi.co/json", AIOA_UPGRADE_URL = "https://ada.skynettechnologies.us/trial-subscription", AIOA_HTTP_TIMEOUT = 30, AIOA_GEO_TIMEOUT = 8e3, AIOA_SCAN_API = "https://skynetaccessibilityscan.com/api/ada-scanner/domain/details", AIOA_SCAN_LANG = "en", AIOA_SCORE_LEVELS = [
4
+ const AIOA_API_BASE = "https://ada.skynettechnologies.us/api/", AIOA_UPDATE_API = `${AIOA_API_BASE}widget-setting-update-platform`, AIOA_PLATFORM = "sanity", AIOA_CHECK_WEBSITE_API = "https://ada.skynettechnologies.us/check-website", AIOA_GEO_API = "https://ipapi.co/json", AIOA_UPGRADE_URL = "https://ada.skynettechnologies.us/trial-subscription", AIOA_HTTP_TIMEOUT = 30, AIOA_GEO_TIMEOUT = 8e3, AIOA_SCAN_API = "https://skynetaccessibilityscan.com/api/ada-scanner/domain/details", AIOA_SCAN_LANG = "en", AIOA_SCORE_LEVELS = [
5
5
  [85, "compliant", "Compliant"],
6
6
  [50, "semi", "Semi Compliant"],
7
7
  [0, "not", "Not Compliant"]
@@ -16,11 +16,11 @@ const AIOA_API_BASE = "https://ada.skynettechnologies.us/api/", AIOA_UPDATE_API
16
16
  ["bottom_center", "Bottom center", 0.5, 1],
17
17
  ["bottom_right", "Bottom right", 1, 1]
18
18
  ], AIOA_ICON_SIZES = [
19
- ["aioa-big-icon", "Big", 84],
20
- ["aioa-medium-icon", "Medium", 74],
21
- ["aioa-default-icon", "Default", 64],
22
- ["aioa-small-icon", "Small", 54],
23
- ["aioa-extra-small-icon", "Extra small", 44]
19
+ ["aioa-big-icon", "Big", 75],
20
+ ["aioa-medium-icon", "Medium", 65],
21
+ ["aioa-default-icon", "Default", 55],
22
+ ["aioa-small-icon", "Small", 45],
23
+ ["aioa-extra-small-icon", "Extra small", 35]
24
24
  ], AIOA_PRESET_COLORS = [
25
25
  ["420083", "Purple (default)"],
26
26
  ["1D4ED8", "Blue"],
@@ -110,17 +110,7 @@ const storage = {
110
110
  class PendingError extends Error {
111
111
  pending = !0;
112
112
  }
113
- const MOBILE_FIELDS = [
114
- "is_mobile_position",
115
- "is_widget_custom_position_mobile",
116
- "widget_position_mobile",
117
- "widget_position_top_mobile",
118
- "widget_position_bottom_mobile",
119
- "widget_position_left_mobile",
120
- "widget_position_right_mobile",
121
- "widget_position_vertical_center_offset_mobile",
122
- "widget_position_horizontal_center_offset_mobile"
123
- ], INVALID_DOMAIN = "A valid domain is required, for example example.com or localhost.";
113
+ const INVALID_DOMAIN = "A valid domain is required, for example example.com or localhost.";
124
114
  async function fetchWidgetSettings(domain) {
125
115
  const url = normalizeDomain(domain);
126
116
  if (!isValidDomain(url))
@@ -145,8 +135,8 @@ async function getDashboardLink(domain) {
145
135
  const res = await post(AIOA_CHECK_WEBSITE_API, { domain: url });
146
136
  if (res === null)
147
137
  return { error: "Unable to load the dashboard link right now." };
148
- const link = toStr(res.manage_domain);
149
- return /^https:\/\//i.test(link) ? { link } : { error: `No dashboard link was found for ${url}.` };
138
+ const link = toStr(res.manage_domain).trim();
139
+ return /^https:\/\/\S+$/i.test(link) ? { link } : { error: `No dashboard link was found for ${url}.` };
150
140
  }
151
141
  async function getScanDetails(domain) {
152
142
  const url = normalizeDomain(domain);
@@ -218,18 +208,16 @@ async function getSettingsData(url) {
218
208
  if (res === null)
219
209
  return !1;
220
210
  const data = res.Data;
221
- return isEmpty(data) || !isObject(data) ? null : withMobileFields(url, data);
211
+ return isEmpty(data) || !isObject(data) ? null : withPlanStatus(url, data);
222
212
  }
223
- async function withMobileFields(url, data) {
213
+ async function withPlanStatus(url, data) {
224
214
  if (toInt(data.is_free_widget) === 1)
225
215
  return data;
226
- const res = await post(AIOA_WIDGET_SETTINGS_API, { website_url: url }), widget = res ? res.Data : null;
227
- if (!isObject(widget))
228
- return data;
229
- const merged = { ...data };
230
- for (const field of MOBILE_FIELDS)
231
- !Object.prototype.hasOwnProperty.call(merged, field) && field in widget && (merged[field] = widget[field]);
232
- return merged;
216
+ const res = await post(AIOA_CHECK_WEBSITE_API, { domain: url });
217
+ return {
218
+ ...data,
219
+ plan_expired: res !== null && (toStr(res.plan_status).trim().toLowerCase() === "expired" || toInt(res.status) === 3)
220
+ };
233
221
  }
234
222
  async function waitForSettings(url, attempts = 3) {
235
223
  for (let i = 0; i < attempts; i++) {
@@ -261,14 +249,14 @@ function scoreSummary(data, altCount) {
261
249
  alt_text: altText(altCount),
262
250
  pages: {
263
251
  scanned: toInt(data.total_scan_pages),
264
- total: toInt(data.total_selected_pages ?? data.total_pages ?? 0)
252
+ total: toInt(data.total_pages ?? data.total_selected_pages ?? 0)
265
253
  },
266
254
  last_scan: toStr(data.last_scan),
267
255
  report_url: /^https:\/\//i.test(reportUrl) ? reportUrl : ""
268
256
  };
269
257
  }
270
258
  function altText(altCount) {
271
- const count = isObject(altCount) ? altCount : {}, images = (key) => Math.max(0, toInt(count[key])), fixed = images("total_decorative_images") + images("total_update_alt_text") + images("total_other_images");
259
+ const count = isObject(altCount) ? altCount : {}, images = (key) => Math.max(0, toInt(count[key])), fixed = images("total_decorative_images") + images("total_update_alt_text");
272
260
  return ratio(fixed, fixed + images("total_missing_alt_tag"));
273
261
  }
274
262
  function ratio(fixed, total) {
@@ -902,6 +890,12 @@ function IconTypeSection({ state, update }) {
902
890
  ] })
903
891
  ] });
904
892
  }
893
+ function startSize(state) {
894
+ if (state.iconSizeCustom.trim() !== "")
895
+ return state.iconSizeCustom;
896
+ const preset = AIOA_ICON_SIZES.find(([value]) => value === state.iconSize);
897
+ return preset ? String(preset[2]) : "";
898
+ }
905
899
  function IconSizeSection({ state, update, refs }) {
906
900
  return /* @__PURE__ */ jsxs("section", { className: "aioa-card", "aria-labelledby": "aioa-icon-size-title", children: [
907
901
  /* @__PURE__ */ jsx("h2", { id: "aioa-icon-size-title", children: "Icon size for desktop" }),
@@ -913,7 +907,9 @@ function IconSizeSection({ state, update, refs }) {
913
907
  type: "checkbox",
914
908
  checked: state.customSize,
915
909
  "aria-controls": "aioa-custom-size aioa-icon-sizes",
916
- onChange: (e) => update(e.target.checked ? { customSize: !0 } : { customSize: !1, sizeCheck: !1 })
910
+ onChange: (e) => update(
911
+ e.target.checked ? { customSize: !0, iconSizeCustom: startSize(state) } : { customSize: !1, sizeCheck: !1 }
912
+ )
917
913
  }
918
914
  ),
919
915
  "Set an exact size in pixels"
@@ -926,7 +922,7 @@ function IconSizeSection({ state, update, refs }) {
926
922
  hidden: state.customSize,
927
923
  children: [
928
924
  /* @__PURE__ */ jsx("legend", { className: "visually-hidden", children: "Select icon size for desktop" }),
929
- /* @__PURE__ */ jsx("div", { className: "aioa-size-row", children: AIOA_ICON_SIZES.map(([value, label, diameter]) => {
925
+ /* @__PURE__ */ jsx("div", { className: "aioa-size-row", children: AIOA_ICON_SIZES.map(([value, label, px]) => {
930
926
  const id = `aioa-size-${aioaSlug(value)}`;
931
927
  return /* @__PURE__ */ jsxs("div", { className: "aioa-icon-option", children: [
932
928
  /* @__PURE__ */ jsx(
@@ -942,8 +938,15 @@ function IconSizeSection({ state, update, refs }) {
942
938
  }
943
939
  ),
944
940
  /* @__PURE__ */ jsxs("label", { htmlFor: id, className: "aioa-icon-label", children: [
945
- /* @__PURE__ */ jsx("span", { className: "aioa-icon", style: { "--d": `${Math.trunc(diameter)}px` }, children: /* @__PURE__ */ jsx("img", { src: iconUrl(state.iconType), alt: "" }) }),
946
- /* @__PURE__ */ jsx("span", { className: "aioa-icon-caption", children: label })
941
+ /* @__PURE__ */ jsx("span", { className: "aioa-icon", style: { "--d": `${Math.trunc(px)}px` }, children: /* @__PURE__ */ jsx("img", { src: iconUrl(state.iconType), alt: "" }) }),
942
+ /* @__PURE__ */ jsxs("span", { className: "aioa-icon-caption", children: [
943
+ label,
944
+ " ",
945
+ /* @__PURE__ */ jsxs("small", { children: [
946
+ px,
947
+ "px"
948
+ ] })
949
+ ] })
947
950
  ] })
948
951
  ] }, value);
949
952
  }) })
@@ -1050,7 +1053,29 @@ function ReportIcon() {
1050
1053
  /* @__PURE__ */ jsx("path", { d: "M12 10v4M12 17v.5" })
1051
1054
  ] });
1052
1055
  }
1053
- const UpgradeUrlContext = createContext(AIOA_UPGRADE_URL);
1056
+ const UpgradeUrlContext = createContext(AIOA_UPGRADE_URL), PlanExpiredContext = createContext(!1), DashboardContext = createContext({ busy: null, open: () => {
1057
+ } });
1058
+ function DashboardButton({
1059
+ id,
1060
+ className,
1061
+ children
1062
+ }) {
1063
+ const { busy, open } = useContext(DashboardContext), isBusy = busy === id;
1064
+ return /* @__PURE__ */ jsx(
1065
+ "button",
1066
+ {
1067
+ type: "button",
1068
+ className,
1069
+ disabled: isBusy,
1070
+ "aria-busy": isBusy || void 0,
1071
+ onClick: () => open(id),
1072
+ children: isBusy ? /* @__PURE__ */ jsxs(Fragment, { children: [
1073
+ /* @__PURE__ */ jsx("span", { className: "aioa-spinner", "aria-hidden": "true" }),
1074
+ /* @__PURE__ */ jsx("span", { children: "Opening\u2026" })
1075
+ ] }) : children
1076
+ }
1077
+ );
1078
+ }
1054
1079
  function Header({
1055
1080
  theme,
1056
1081
  onToggleTheme
@@ -1085,17 +1110,21 @@ function Header({
1085
1110
  ] });
1086
1111
  }
1087
1112
  function UpgradeBanner() {
1088
- const upgradeHref = useContext(UpgradeUrlContext);
1113
+ const upgradeHref = useContext(UpgradeUrlContext), expired = useContext(PlanExpiredContext);
1089
1114
  return /* @__PURE__ */ jsxs("section", { className: "aioa-upgrade", "aria-labelledby": "aioa-upgrade-title", children: [
1090
1115
  /* @__PURE__ */ jsx(WatermarkIcon, {}),
1091
1116
  /* @__PURE__ */ jsxs("div", { className: "aioa-upgrade-head", children: [
1092
1117
  /* @__PURE__ */ jsxs("div", { className: "aioa-upgrade-intro", children: [
1093
- /* @__PURE__ */ jsxs("p", { className: "aioa-upgrade-tag", children: [
1118
+ /* @__PURE__ */ jsxs("p", { className: `aioa-upgrade-tag${expired ? " is-expired" : ""}`, children: [
1094
1119
  /* @__PURE__ */ jsx("i", { "aria-hidden": "true" }),
1095
- "Free plan active"
1120
+ expired ? "Paid plan expired" : "Free plan active"
1096
1121
  ] }),
1097
- /* @__PURE__ */ jsx("h2", { id: "aioa-upgrade-title", children: "With 24 Features" }),
1098
- /* @__PURE__ */ jsxs("p", { children: [
1122
+ /* @__PURE__ */ jsx("h2", { id: "aioa-upgrade-title", children: expired ? "Your paid plan has expired" : "With 24 Features" }),
1123
+ expired ? /* @__PURE__ */ jsxs("p", { children: [
1124
+ "Renew your plan to unlock ",
1125
+ /* @__PURE__ */ jsx("strong", { children: "100+ Premium Accessibility Features" }),
1126
+ " again. Paid Features and Accessibility Score are locked until then."
1127
+ ] }) : /* @__PURE__ */ jsxs("p", { children: [
1099
1128
  "Upgrade to unlock ",
1100
1129
  /* @__PURE__ */ jsx("strong", { children: "90+ Premium Accessibility Features" }),
1101
1130
  " and make your website even more inclusive."
@@ -1106,7 +1135,11 @@ function UpgradeBanner() {
1106
1135
  ] })
1107
1136
  ] }),
1108
1137
  /* @__PURE__ */ jsxs("div", { className: "aioa-upgrade-cta", children: [
1109
- /* @__PURE__ */ jsxs(
1138
+ expired ? /* @__PURE__ */ jsxs(DashboardButton, { id: "renew-banner", className: "aioa-btn-white", children: [
1139
+ "Renew Plan",
1140
+ /* @__PURE__ */ jsx(ArrowIcon, {}),
1141
+ /* @__PURE__ */ jsx("span", { className: "visually-hidden", children: "(opens your dashboard in a new tab)" })
1142
+ ] }) : /* @__PURE__ */ jsxs(
1110
1143
  "a",
1111
1144
  {
1112
1145
  href: upgradeHref,
@@ -1120,7 +1153,7 @@ function UpgradeBanner() {
1120
1153
  ]
1121
1154
  }
1122
1155
  ),
1123
- /* @__PURE__ */ jsx("small", { children: "10-day free trial \xB7 Cancel anytime" })
1156
+ /* @__PURE__ */ jsx("small", { children: expired ? "Renew from your dashboard" : /* @__PURE__ */ jsx(Fragment, { children: "10-day free trial \xB7 Cancel anytime" }) })
1124
1157
  ] })
1125
1158
  ] }),
1126
1159
  /* @__PURE__ */ jsxs("p", { className: "aioa-upgrade-note", children: [
@@ -1129,33 +1162,17 @@ function UpgradeBanner() {
1129
1162
  ] })
1130
1163
  ] });
1131
1164
  }
1132
- function PaidBanner({
1133
- busy,
1134
- onDashboard
1135
- }) {
1165
+ function PaidBanner() {
1136
1166
  return /* @__PURE__ */ jsxs("section", { className: "aioa-notice", "aria-labelledby": "aioa-paid-title", children: [
1137
1167
  /* @__PURE__ */ jsxs("div", { className: "aioa-notice-body", children: [
1138
1168
  /* @__PURE__ */ jsx("p", { className: "aioa-tag is-success", children: "Paid plan active" }),
1139
1169
  /* @__PURE__ */ jsx("h2", { id: "aioa-paid-title", children: "All pro features are unlocked" }),
1140
1170
  /* @__PURE__ */ jsx("p", { children: "Manage features, accessibility reports and widget analytics from your dashboard." })
1141
1171
  ] }),
1142
- /* @__PURE__ */ jsx("div", { className: "aioa-notice-action", children: /* @__PURE__ */ jsx(
1143
- "button",
1144
- {
1145
- type: "button",
1146
- className: "aioa-btn aioa-btn-primary",
1147
- disabled: busy,
1148
- "aria-busy": busy || void 0,
1149
- onClick: (e) => onDashboard(e.currentTarget),
1150
- children: busy ? /* @__PURE__ */ jsxs(Fragment, { children: [
1151
- /* @__PURE__ */ jsx("span", { className: "aioa-spinner", "aria-hidden": "true" }),
1152
- /* @__PURE__ */ jsx("span", { children: "Opening\u2026" })
1153
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1154
- "Dashboard",
1155
- /* @__PURE__ */ jsx("span", { className: "visually-hidden", children: "(opens in a new tab)" })
1156
- ] })
1157
- }
1158
- ) })
1172
+ /* @__PURE__ */ jsx("div", { className: "aioa-notice-action", children: /* @__PURE__ */ jsxs(DashboardButton, { id: "dashboard", className: "aioa-btn aioa-btn-primary", children: [
1173
+ "Dashboard",
1174
+ /* @__PURE__ */ jsx("span", { className: "visually-hidden", children: "(opens in a new tab)" })
1175
+ ] }) })
1159
1176
  ] });
1160
1177
  }
1161
1178
  function SiteStrip({ domain }) {
@@ -1227,15 +1244,18 @@ function Lockable({
1227
1244
  children,
1228
1245
  contentClassName = ""
1229
1246
  }) {
1230
- const contentRef = useRef(null), upgradeHref = useContext(UpgradeUrlContext);
1247
+ const contentRef = useRef(null), upgradeHref = useContext(UpgradeUrlContext), expired = useContext(PlanExpiredContext);
1231
1248
  return useEffect(() => {
1232
1249
  contentRef.current && (contentRef.current.inert = locked);
1233
1250
  }, [locked]), /* @__PURE__ */ jsxs("div", { className: `aioa-lockable${locked ? " is-locked" : ""}`, children: [
1234
1251
  /* @__PURE__ */ jsx("div", { ref: contentRef, className: `aioa-lock-content ${contentClassName}`.trim(), children }),
1235
1252
  locked && /* @__PURE__ */ jsx("div", { className: `aioa-lock${center ? " is-center" : ""}`, children: /* @__PURE__ */ jsxs("div", { className: "aioa-lock-card", role: "group", "aria-labelledby": `${lockId}-text`, children: [
1236
1253
  /* @__PURE__ */ jsx("span", { className: "aioa-lock-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(LockIcon, {}) }),
1237
- /* @__PURE__ */ jsx("p", { className: "aioa-lock-text", id: `${lockId}-text`, children: "Try a 10-day free trial to view all 90+ features." }),
1238
- /* @__PURE__ */ jsxs(
1254
+ /* @__PURE__ */ jsx("p", { className: "aioa-lock-text", id: `${lockId}-text`, children: expired ? "Your paid plan has expired. Renew it to view all 100+ features again." : "Try a 10-day free trial to view all 90+ features." }),
1255
+ expired ? /* @__PURE__ */ jsxs(DashboardButton, { id: `renew-${lockId}`, className: "aioa-btn aioa-btn-primary", children: [
1256
+ "Renew Plan",
1257
+ /* @__PURE__ */ jsx("span", { className: "visually-hidden", children: "(opens your dashboard in a new tab)" })
1258
+ ] }) : /* @__PURE__ */ jsxs(
1239
1259
  "a",
1240
1260
  {
1241
1261
  href: upgradeHref,
@@ -1934,6 +1954,8 @@ const AIOA_CSS = `
1934
1954
  font-size: 12.5px; font-weight: 600; background: rgba(255, 255, 255, .14); color: #f0e8ff;
1935
1955
  }
1936
1956
  .aioa-upgrade-tag i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
1957
+ /* "Paid plan expired": amber dot */
1958
+ .aioa-upgrade-tag.is-expired i { background: #fbbf24; }
1937
1959
 
1938
1960
  /* 190+ languages / 12 profiles */
1939
1961
  .aioa-upgrade-points { display: flex; flex-wrap: wrap; gap: 5px 20px; margin: 12px 0 0; padding: 0; list-style: none; font-weight: 600; }
@@ -1950,6 +1972,8 @@ const AIOA_CSS = `
1950
1972
  border-radius: var(--radius-sm); background: #fff; color: #420083; font-weight: 700; text-decoration: none; white-space: nowrap;
1951
1973
  }
1952
1974
  .aioa-btn-white:hover { background: #f3eefa; }
1975
+ button.aioa-btn-white { border: 0; cursor: pointer; }
1976
+ button.aioa-btn-white[disabled] { opacity: .8; cursor: progress; }
1953
1977
  .aioa-btn-white svg { width: 17px; height: 17px; }
1954
1978
 
1955
1979
  .aioa-upgrade-note { margin-top: 16px; padding-top: 13px; border-top: 1px solid rgba(255, 255, 255, .16); font-size: 13.5px; color: #d3c1f3; }
@@ -2097,6 +2121,8 @@ const AIOA_CSS = `
2097
2121
  /* Icon size: each circle at its own diameter (--d, set in the icon-size partial), bottoms aligned */
2098
2122
  .aioa-size-row { --scale: 1; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 22px; }
2099
2123
  .aioa-size-row .aioa-icon { width: calc(var(--d) * var(--scale)); }
2124
+ .aioa-size-row .aioa-icon-caption { text-align: center; line-height: 1.35; }
2125
+ .aioa-icon-caption small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
2100
2126
 
2101
2127
  /* ---------- Save bar ---------- */
2102
2128
 
@@ -2358,7 +2384,7 @@ function SettingsPage({ tool }) {
2358
2384
  const upgradeHref = useMemo(
2359
2385
  () => upgradeUrl(activeDomain, adminName, adminEmail),
2360
2386
  [activeDomain, adminName, adminEmail]
2361
- ), { theme, toggleTheme } = useTheme(), { toasts, toast, dismiss } = useToasts(), [view, setView] = useState({ name: "load" }), [isPaid, setIsPaid] = useState(!1), [tab, setTab] = useState("appearance"), [appearance, setAppearance] = useState(emptyAppearance), [paid, setPaid] = useState(() => paidFrom({})), [dirty, setDirty] = useState(!1), [saving, setSaving] = useState(!1), [score, setScore] = useState({ status: "idle" }), [dashboardBusy, setDashboardBusy] = useState(!1), latest = useRef({ appearance, paid, isPaid });
2387
+ ), { theme, toggleTheme } = useTheme(), { toasts, toast, dismiss } = useToasts(), [view, setView] = useState({ name: "load" }), [isPaid, setIsPaid] = useState(!1), [planExpired, setPlanExpired] = useState(!1), [tab, setTab] = useState("appearance"), [appearance, setAppearance] = useState(emptyAppearance), [paid, setPaid] = useState(() => paidFrom({})), [dirty, setDirty] = useState(!1), [saving, setSaving] = useState(!1), [score, setScore] = useState({ status: "idle" }), [dashboardBusy, setDashboardBusy] = useState(null), latest = useRef({ appearance, paid, isPaid });
2362
2388
  latest.current = { appearance, paid, isPaid };
2363
2389
  const updateAppearance = useCallback((patch) => {
2364
2390
  setAppearance((state) => ({ ...state, ...patch })), setDirty(!0);
@@ -2388,53 +2414,33 @@ function SettingsPage({ tool }) {
2388
2414
  });
2389
2415
  const selectTab = useCallback((name) => {
2390
2416
  setTab(name), storage.set(STORAGE_TAB, name);
2391
- }, []), dashboard = useRef({
2392
- request: null,
2393
- link: "",
2394
- failure: null
2395
- }), loadDashboard = useCallback(() => {
2396
- if (dashboard.current.request)
2397
- return;
2398
- const request = getDashboardLink(activeDomain).then((result) => {
2399
- const value = "link" in result ? result.link : "";
2400
- if (!value || !/^https:\/\//i.test(value))
2401
- throw new Error("error" in result && result.error || "Unable to load the dashboard link.");
2402
- return dashboard.current.link = value, value;
2403
- });
2404
- dashboard.current.request = request, request.catch((err) => {
2405
- dashboard.current.failure = err;
2406
- });
2407
- }, [activeDomain]), openIn = (win, url) => {
2408
- win && !win.closed ? (win.opener = null, win.location.href = url) : toast("success", "Your dashboard link is ready", "Your browser blocked the new tab.", {
2417
+ }, []), openIn = (win, url) => {
2418
+ win && !win.closed ? (win.opener = null, win.location.href = url) : toast("success", "Your dashboard is ready to open", "Your browser blocked the new tab.", {
2409
2419
  href: url,
2410
2420
  label: "Open dashboard"
2411
2421
  });
2412
2422
  }, showDashboardError = (err) => {
2413
2423
  const reason = err instanceof TypeError ? "Please check your connection." : err instanceof Error && err.message || "";
2414
- toast(
2415
- "error",
2416
- "Could not open the dashboard",
2417
- `${reason ? `${reason} ` : ""}Reload the page to try again.`
2418
- );
2419
- }, openDashboard = () => {
2420
- const { link, failure, request } = dashboard.current;
2421
- if (link) {
2422
- openIn(window.open("", "_blank"), link);
2423
- return;
2424
- }
2425
- if (failure || !request) {
2426
- showDashboardError(failure);
2424
+ toast("error", "Could not open the dashboard", `${reason ? `${reason} ` : ""}Please try again.`);
2425
+ }, openDashboard = (id) => {
2426
+ if (dashboardBusy)
2427
2427
  return;
2428
- }
2429
2428
  const win = window.open("", "_blank");
2430
2429
  if (win)
2431
2430
  try {
2432
2431
  win.document.title = "Opening dashboard\u2026", win.document.body.style.cssText = "font-family:system-ui,sans-serif;display:grid;place-items:center;min-height:90vh;color:#420083", win.document.body.textContent = "Opening your All in One Accessibility dashboard\u2026";
2433
2432
  } catch {
2434
2433
  }
2435
- setDashboardBusy(!0), request.then((url) => openIn(win, url)).catch((err) => {
2434
+ setDashboardBusy(id), getDashboardLink(activeDomain).then((result) => {
2435
+ const link = "link" in result ? result.link : "";
2436
+ if (!link || !/^https:\/\//i.test(link))
2437
+ throw new Error(
2438
+ "error" in result && result.error || "Unable to load the dashboard link."
2439
+ );
2440
+ openIn(win, link);
2441
+ }).catch((err) => {
2436
2442
  win && !win.closed && win.close(), showDashboardError(err);
2437
- }).finally(() => setDashboardBusy(!1));
2443
+ }).finally(() => setDashboardBusy(null));
2438
2444
  }, register2 = useRef({
2439
2445
  promise: null,
2440
2446
  settled: !1
@@ -2471,10 +2477,10 @@ function SettingsPage({ tool }) {
2471
2477
  }, [activeDomain]), applyResult = useCallback(
2472
2478
  (result) => {
2473
2479
  storage.remove(STORAGE_REGISTERED + activeDomain);
2474
- const paidPlan = toInt(result.is_free_widget) !== 1, order = paidPlan ? TAB_ORDER.paid : TAB_ORDER.free, stored = storage.get(STORAGE_TAB);
2475
- setAppearance(appearanceFrom(result)), setPaid(paidFrom(result)), setIsPaid(paidPlan), setTab(TABS.includes(stored) ? stored : order[0]), setDirty(!1), setView({ name: "settings" }), paidPlan && loadDashboard();
2480
+ const flag = result.plan_expired, expired = flag === !0 || flag === 1 || flag === "1" || flag === "true", paidPlan = toInt(result.is_free_widget) !== 1 && !expired, order = paidPlan ? TAB_ORDER.paid : TAB_ORDER.free, stored = storage.get(STORAGE_TAB);
2481
+ setAppearance(appearanceFrom(result)), setPaid(paidFrom(result)), setIsPaid(paidPlan), setPlanExpired(expired), setTab(TABS.includes(stored) ? stored : order[0]), setDirty(!1), setView({ name: "settings" });
2476
2482
  },
2477
- [activeDomain, loadDashboard]
2483
+ [activeDomain]
2478
2484
  ), loadSettings = useCallback(() => {
2479
2485
  if (!activeDomain) {
2480
2486
  showError(
@@ -2555,8 +2561,8 @@ function SettingsPage({ tool }) {
2555
2561
  /* @__PURE__ */ jsx("p", { children: view.message }),
2556
2562
  view.retry && /* @__PURE__ */ jsx("button", { type: "button", className: "aioa-btn aioa-btn-primary", onClick: loadSettings, children: "Try again" })
2557
2563
  ] }),
2558
- view.name === "settings" && /* @__PURE__ */ jsxs(UpgradeUrlContext.Provider, { value: upgradeHref, children: [
2559
- isPaid ? /* @__PURE__ */ jsx(PaidBanner, { busy: dashboardBusy, onDashboard: openDashboard }) : /* @__PURE__ */ jsx(UpgradeBanner, {}),
2564
+ view.name === "settings" && /* @__PURE__ */ jsx(UpgradeUrlContext.Provider, { value: upgradeHref, children: /* @__PURE__ */ jsx(PlanExpiredContext.Provider, { value: planExpired, children: /* @__PURE__ */ jsxs(DashboardContext.Provider, { value: { busy: dashboardBusy, open: openDashboard }, children: [
2565
+ isPaid ? /* @__PURE__ */ jsx(PaidBanner, {}) : /* @__PURE__ */ jsx(UpgradeBanner, {}),
2560
2566
  /* @__PURE__ */ jsx(SiteStrip, { domain: activeDomain }),
2561
2567
  /* @__PURE__ */ jsx(
2562
2568
  Tabs,
@@ -2646,7 +2652,7 @@ function SettingsPage({ tool }) {
2646
2652
  /* @__PURE__ */ jsx("p", { className: "aioa-after-note", children: "It may take a few seconds for changes to appear on your website. If you don't see them, clear your browser cache or check in a private window." })
2647
2653
  ] })
2648
2654
  ] })
2649
- ] })
2655
+ ] }) }) })
2650
2656
  ] })
2651
2657
  ] }),
2652
2658
  /* @__PURE__ */ jsx(ToastRegion, { toasts, onDismiss: dismiss })