@ohhwells/bridge 0.1.164 → 0.1.165

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
  "use client";
2
2
 
3
3
  // src/OhhwellsBridge.tsx
4
- import React12, { useCallback as useCallback12, useEffect as useEffect19, useLayoutEffect as useLayoutEffect6, useRef as useRef14, useState as useState18 } from "react";
4
+ import React12, { useCallback as useCallback12, useEffect as useEffect20, useLayoutEffect as useLayoutEffect6, useRef as useRef14, useState as useState18 } from "react";
5
5
  import { createRoot as createRoot3 } from "react-dom/client";
6
6
  import { flushSync as flushSync3 } from "react-dom";
7
7
 
@@ -840,6 +840,10 @@ function useOhwCarousel(key, initial) {
840
840
  if (Array.isArray(detail?.images)) setImages(detail.images);
841
841
  };
842
842
  el.addEventListener(CAROUSEL_EVENT, onChange);
843
+ const pending = parseSlides(el.getAttribute(CAROUSEL_VALUE_ATTR));
844
+ if (pending.length > 0) {
845
+ setImages((prev) => JSON.stringify(prev) === JSON.stringify(pending) ? prev : pending);
846
+ }
843
847
  return () => el.removeEventListener(CAROUSEL_EVENT, onChange);
844
848
  }, [key]);
845
849
  const bind = {
@@ -2524,6 +2528,14 @@ function socialHrefKey(item) {
2524
2528
  function socialIconKey(item) {
2525
2529
  return item.querySelector(ICON_SELECTOR)?.dataset.ohwKey ?? null;
2526
2530
  }
2531
+ function pendingIconKey(item) {
2532
+ const existing = socialIconKey(item);
2533
+ if (existing) return existing;
2534
+ const base = socialHrefKey(item)?.replace(/-href$/, "");
2535
+ if (!base) return null;
2536
+ const taken = item.ownerDocument.querySelector(`[data-ohw-key="${base}"]`);
2537
+ return taken && taken !== item ? `${base}-icon` : base;
2538
+ }
2527
2539
  var SOCIAL_PLATFORM_LABELS = {
2528
2540
  instagram: "Instagram",
2529
2541
  facebook: "Facebook",
@@ -2721,9 +2733,9 @@ function reconcileSocialsFromContent(content, root = document) {
2721
2733
  listSocialsRows(root).forEach((row) => {
2722
2734
  const rowDisplay = socialsDisplayFor(row, content);
2723
2735
  listSocialItems(row).forEach((item) => {
2724
- const key = socialIconKey(item) ?? socialHrefKey(item)?.replace(/-href$/, "");
2736
+ const key = pendingIconKey(item);
2725
2737
  const stored2 = key ? content[key] : void 0;
2726
- if (!stored2?.trim()) return;
2738
+ if (!stored2?.trim().startsWith("<")) return;
2727
2739
  const existing = item.querySelector(ICON_SELECTOR);
2728
2740
  if (existing && existing.innerHTML.trim() && !existing.hasAttribute(SOCIALS_ICON_PLACEHOLDER_ATTR)) return;
2729
2741
  ensureIconSlot(item);
@@ -2983,8 +2995,7 @@ function ensureIconSlot(item) {
2983
2995
  const adopted = adoptAsIconSlot(drawn, base);
2984
2996
  if (adopted) return adopted;
2985
2997
  }
2986
- const taken = document.querySelector(`[data-ohw-key="${base}"]`);
2987
- const iconKey = taken && taken !== item ? `${base}-icon` : base;
2998
+ const iconKey = pendingIconKey(item) ?? base;
2988
2999
  const slot = document.createElement("span");
2989
3000
  slot.setAttribute("data-ohw-key", iconKey);
2990
3001
  slot.setAttribute("data-ohw-editable", "icon");
@@ -3496,11 +3507,11 @@ function insertFooterColumnDom(colIndex, heading, items) {
3496
3507
  container.appendChild(column);
3497
3508
  return { column, firstLink };
3498
3509
  }
3499
- function insertFooterColumn(heading = DEFAULT_FOOTER_COLUMN_HEADING, linkLabel = DEFAULT_FOOTER_COLUMN_LINK_LABEL, linkHref = DEFAULT_FOOTER_COLUMN_LINK_HREF) {
3510
+ function insertFooterColumn(heading = DEFAULT_FOOTER_COLUMN_HEADING, linkLabel = DEFAULT_FOOTER_COLUMN_LINK_LABEL, linkHref2 = DEFAULT_FOOTER_COLUMN_LINK_HREF) {
3500
3511
  if (!canAddFooterColumn()) {
3501
3512
  throw new Error(`Footer column limit reached (${MAX_FOOTER_COLUMNS})`);
3502
3513
  }
3503
- const resolvedHref = linkHref || (document.querySelector("[data-ai-footer], [data-ohw-ai-footer]") ? "/" : DEFAULT_FOOTER_COLUMN_LINK_HREF);
3514
+ const resolvedHref = linkHref2 || (document.querySelector("[data-ai-footer], [data-ohw-ai-footer]") ? "/" : DEFAULT_FOOTER_COLUMN_LINK_HREF);
3504
3515
  const colIndex = getNextFooterColumnIndex();
3505
3516
  const inserted = insertFooterColumnDom(colIndex, heading, [{ href: resolvedHref, label: linkLabel }]);
3506
3517
  if (!inserted?.firstLink) throw new Error("Failed to insert footer column");
@@ -3879,8 +3890,8 @@ function duplicateFooterItem(sourceAnchor) {
3879
3890
  const column = findFooterColumnForLink(sourceAnchor);
3880
3891
  if (!column) return null;
3881
3892
  const href = getLinkHref(sourceAnchor);
3882
- const labelEl = sourceAnchor.querySelector('[data-ohw-editable="text"]');
3883
- const label = (labelEl?.textContent ?? "").trim() || "Untitled";
3893
+ const labelEl2 = sourceAnchor.querySelector('[data-ohw-editable="text"]');
3894
+ const label = (labelEl2?.textContent ?? "").trim() || "Untitled";
3884
3895
  return insertFooterItem(column, href || "/", label, sourceAnchor);
3885
3896
  }
3886
3897
  function footerLabelKeyFromHrefKey(hrefKey) {
@@ -3890,8 +3901,8 @@ function deleteFooterItem(sourceAnchor) {
3890
3901
  if (!isFooterLinkAnchor(sourceAnchor)) return null;
3891
3902
  const hrefKey = sourceAnchor.getAttribute("data-ohw-href-key");
3892
3903
  if (!hrefKey || !isFooterHrefKey(hrefKey)) return null;
3893
- const labelEl = sourceAnchor.querySelector('[data-ohw-editable="text"]');
3894
- const label = (labelEl?.textContent ?? "").trim() || "Untitled";
3904
+ const labelEl2 = sourceAnchor.querySelector('[data-ohw-editable="text"]');
3905
+ const label = (labelEl2?.textContent ?? "").trim() || "Untitled";
3895
3906
  const labelKey = footerLabelKeyFromHrefKey(hrefKey);
3896
3907
  const previousOrder = getFooterOrderFromDom();
3897
3908
  const previousOrderJson = JSON.stringify(previousOrder);
@@ -4859,8 +4870,8 @@ function remapNavKeysInSubtree(root, keyMap) {
4859
4870
  const mapped = keyMap.get(oldHrefKey);
4860
4871
  if (!mapped) return;
4861
4872
  el.setAttribute("data-ohw-href-key", mapped.hrefKey);
4862
- const labelEl = el.querySelector(':scope > [data-ohw-editable="text"][data-ohw-key]') ?? el.querySelector('[data-ohw-editable="text"][data-ohw-key]');
4863
- if (labelEl) labelEl.setAttribute("data-ohw-key", mapped.labelKey);
4873
+ const labelEl2 = el.querySelector(':scope > [data-ohw-editable="text"][data-ohw-key]') ?? el.querySelector('[data-ohw-editable="text"][data-ohw-key]');
4874
+ if (labelEl2) labelEl2.setAttribute("data-ohw-key", mapped.labelKey);
4864
4875
  };
4865
4876
  if (root.matches("[data-ohw-href-key]")) remapAnchor(root);
4866
4877
  root.querySelectorAll("[data-ohw-href-key]").forEach(remapAnchor);
@@ -4868,10 +4879,10 @@ function remapNavKeysInSubtree(root, keyMap) {
4868
4879
  function readNavLinkSnapshot(hrefKey) {
4869
4880
  const el = findCounterpartByHrefKey(hrefKey, document) ?? document.querySelector(`[data-ohw-href-key="${CSS.escape(hrefKey)}"]`);
4870
4881
  if (!el) return { href: "/", label: "Untitled" };
4871
- const labelEl = el.querySelector('[data-ohw-editable="text"]');
4882
+ const labelEl2 = el.querySelector('[data-ohw-editable="text"]');
4872
4883
  return {
4873
4884
  href: getLinkHref2(el),
4874
- label: (labelEl?.textContent ?? "").trim() || "Untitled"
4885
+ label: (labelEl2?.textContent ?? "").trim() || "Untitled"
4875
4886
  };
4876
4887
  }
4877
4888
  function findClonedNavAnchor(unit, hrefKey) {
@@ -5045,8 +5056,8 @@ function deleteNavbarItem(sourceAnchor) {
5045
5056
  if (!isNavbarLinkItem(sourceAnchor)) return null;
5046
5057
  const sourceHrefKey = sourceAnchor.getAttribute("data-ohw-href-key");
5047
5058
  if (!sourceHrefKey || !isNavbarHrefKey(sourceHrefKey)) return null;
5048
- const labelEl = sourceAnchor.querySelector('[data-ohw-editable="text"]');
5049
- const label = (labelEl?.textContent ?? "").trim() || "Untitled";
5059
+ const labelEl2 = sourceAnchor.querySelector('[data-ohw-editable="text"]');
5060
+ const label = (labelEl2?.textContent ?? "").trim() || "Untitled";
5050
5061
  const previousForest = getNavForestFromDom();
5051
5062
  const previousOrderJson = serializeNavOrder(previousForest);
5052
5063
  const parentHrefKey = previousForest.find((n) => n.children.some((c) => c.id === sourceHrefKey))?.id ?? null;
@@ -11653,8 +11664,8 @@ function syncFooterTreeLinksFromDom(tree) {
11653
11664
  const heading = getFooterColumnHeadingEl(col);
11654
11665
  const title = heading ? textOf2(heading) : void 0;
11655
11666
  const items = listFooterLinksInColumn(col).map((anchor) => {
11656
- const labelEl = anchor.querySelector('[data-ohw-editable="text"]');
11657
- const label = textOf2(labelEl) || textOf2(anchor);
11667
+ const labelEl2 = anchor.querySelector('[data-ohw-editable="text"]');
11668
+ const label = textOf2(labelEl2) || textOf2(anchor);
11658
11669
  const href = hrefToFooterTreeRef(anchor.getAttribute("href"));
11659
11670
  return label ? { label, href: href || "home" } : null;
11660
11671
  }).filter((x) => Boolean(x));
@@ -17353,7 +17364,7 @@ function apiBase() {
17353
17364
  function bridgeVersion() {
17354
17365
  try {
17355
17366
  if (true) {
17356
- return "0.1.164";
17367
+ return "0.1.165";
17357
17368
  }
17358
17369
  } catch {
17359
17370
  }
@@ -17367,7 +17378,7 @@ function stampBridgeVersionOnDocument() {
17367
17378
  return;
17368
17379
  }
17369
17380
  try {
17370
- const v = true ? "0.1.164" : "";
17381
+ const v = true ? "0.1.165" : "";
17371
17382
  if (v) {
17372
17383
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17373
17384
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -24093,6 +24104,138 @@ function deleteSelectedNavFooterItem(deps) {
24093
24104
  return false;
24094
24105
  }
24095
24106
 
24107
+ // src/lib/build-page-sync.ts
24108
+ import { useEffect as useEffect19 } from "react";
24109
+ var CHROME_KEY_RE = /^(nav|footer|header|navbar)[-_]/u;
24110
+ function normalisePath(path) {
24111
+ const trimmed = path.trim().replace(/[?#].*$/u, "");
24112
+ if (!trimmed || trimmed === "/") return "/";
24113
+ return `/${trimmed.replace(/^\/+|\/+$/gu, "")}`;
24114
+ }
24115
+ function isDeadPageHref(href, livePaths) {
24116
+ const value = href.trim();
24117
+ if (!value.startsWith("/") || value.startsWith("//")) return false;
24118
+ const path = normalisePath(value);
24119
+ if (path === "/") return false;
24120
+ return !livePaths.some((live) => {
24121
+ const p = normalisePath(live);
24122
+ return p === path || p !== "/" && path.startsWith(`${p}/`);
24123
+ });
24124
+ }
24125
+ var sameWords = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
24126
+ function planBuildPageSync(links, msg) {
24127
+ const live = Array.isArray(msg.livePaths) ? msg.livePaths : [];
24128
+ const removed = new Set((msg.removed ?? []).map(normalisePath));
24129
+ const remove = [];
24130
+ const relabel = [];
24131
+ const retarget = [];
24132
+ const fallback = live.some((p) => normalisePath(p) === "/contact") ? "/contact" : "/";
24133
+ for (const link of links) {
24134
+ const href = link.href.trim();
24135
+ const isPage = href.startsWith("/") && !href.startsWith("//");
24136
+ if (isPage && (removed.has(normalisePath(href)) || live.length > 0 && isDeadPageHref(href, live))) {
24137
+ if (link.area === "chrome") retarget.push({ hrefKey: link.hrefKey, href: fallback });
24138
+ else remove.push(link.hrefKey);
24139
+ continue;
24140
+ }
24141
+ if (isPage) {
24142
+ const path = normalisePath(href);
24143
+ const rename = (msg.relabel ?? []).find((r2) => normalisePath(r2.path) === path);
24144
+ if (rename && sameWords(link.label, rename.oldTitle) && !sameWords(link.label, rename.label)) {
24145
+ relabel.push({ hrefKey: link.hrefKey, label: rename.label });
24146
+ }
24147
+ continue;
24148
+ }
24149
+ if (href.startsWith("#") || href.startsWith("/#")) {
24150
+ const anchor = href.replace(/^\/?#/u, "").toLowerCase();
24151
+ const target = (msg.anchorLabels ?? []).find((a) => a.anchors.some((id) => id.toLowerCase() === anchor));
24152
+ if (target && sameWords(link.label.replace(/\s+/gu, "-"), anchor) && !sameWords(link.label, target.label)) {
24153
+ relabel.push({ hrefKey: link.hrefKey, label: target.label });
24154
+ }
24155
+ }
24156
+ }
24157
+ return { remove, relabel, retarget };
24158
+ }
24159
+ function linkHref(el) {
24160
+ const key = el.getAttribute("data-ohw-href-key");
24161
+ const stored = key ? getStoredLinkHref(key) : void 0;
24162
+ return stored ?? el.getAttribute("href") ?? "";
24163
+ }
24164
+ function labelEl(anchor) {
24165
+ return anchor.querySelector('[data-ohw-editable="text"]');
24166
+ }
24167
+ function collectLinks() {
24168
+ const seen = /* @__PURE__ */ new Set();
24169
+ const links = [];
24170
+ document.querySelectorAll("[data-ohw-href-key]").forEach((el) => {
24171
+ const hrefKey = el.getAttribute("data-ohw-href-key") ?? "";
24172
+ if (seen.has(hrefKey)) return;
24173
+ const area = isNavbarHrefKey(hrefKey) ? "nav" : isFooterHrefKey(hrefKey) ? "footer" : CHROME_KEY_RE.test(hrefKey) ? "chrome" : null;
24174
+ if (!area) return;
24175
+ const label = labelEl(el);
24176
+ if (!label && area !== "chrome") return;
24177
+ seen.add(hrefKey);
24178
+ links.push({ hrefKey, href: linkHref(el), label: label?.textContent ?? el.textContent ?? "", area });
24179
+ });
24180
+ return links;
24181
+ }
24182
+ function applyBuildPageSync(msg, deps) {
24183
+ const plan = planBuildPageSync(collectLinks(), msg);
24184
+ const nodes = /* @__PURE__ */ new Map();
24185
+ for (const hrefKey of plan.remove) {
24186
+ const anchor = document.querySelector(`[data-ohw-href-key="${CSS.escape(hrefKey)}"]`);
24187
+ if (!anchor) continue;
24188
+ const nav = isNavbarHrefKey(hrefKey);
24189
+ const result = nav ? deleteNavbarItem(anchor) : deleteFooterItem(anchor);
24190
+ if (!result) continue;
24191
+ for (const key of result.removedKeys) {
24192
+ nodes.set(key, "");
24193
+ clearStoredLinkHref(key);
24194
+ }
24195
+ nodes.set(nav ? NAV_ORDER_KEY : FOOTER_ORDER_KEY, result.orderJson);
24196
+ }
24197
+ for (const { hrefKey, label } of plan.relabel) {
24198
+ const labelKey = hrefKey.replace(/-href$/u, "-label");
24199
+ document.querySelectorAll(`[data-ohw-href-key="${CSS.escape(hrefKey)}"]`).forEach((anchor) => {
24200
+ const el = labelEl(anchor);
24201
+ if (el) el.textContent = label;
24202
+ });
24203
+ nodes.set(labelKey, label);
24204
+ }
24205
+ for (const { hrefKey, href } of plan.retarget) {
24206
+ setStoredLinkHref(hrefKey, href);
24207
+ document.querySelectorAll(`[data-ohw-href-key="${CSS.escape(hrefKey)}"]`).forEach((anchor) => {
24208
+ if (anchor instanceof HTMLAnchorElement) anchor.setAttribute("href", href);
24209
+ });
24210
+ nodes.set(hrefKey, href);
24211
+ }
24212
+ if (nodes.size === 0) return 0;
24213
+ deps.setEditContent({ ...deps.getEditContent(), ...Object.fromEntries(nodes) });
24214
+ deps.postToParent({
24215
+ type: "ow:change",
24216
+ nodes: [...nodes].map(([key, text]) => ({ key, text }))
24217
+ });
24218
+ return plan.remove.length + plan.relabel.length + plan.retarget.length;
24219
+ }
24220
+ function useBuildPageSync(isEditMode, editContentRef, postToParent2) {
24221
+ useEffect19(() => {
24222
+ if (!isEditMode) return;
24223
+ const onMessage = (e) => {
24224
+ if (e.source !== window.parent || e.data?.type !== "ow:pages-sync") return;
24225
+ const changed = applyBuildPageSync(e.data, {
24226
+ getEditContent: () => editContentRef.current,
24227
+ setEditContent: (next) => {
24228
+ editContentRef.current = next;
24229
+ },
24230
+ postToParent: postToParent2
24231
+ });
24232
+ postToParent2({ type: "ow:pages-synced", changed });
24233
+ };
24234
+ window.addEventListener("message", onMessage);
24235
+ return () => window.removeEventListener("message", onMessage);
24236
+ }, [isEditMode, editContentRef, postToParent2]);
24237
+ }
24238
+
24096
24239
  // src/lib/nav-page-sync.ts
24097
24240
  function labelKeyFor(hrefKey) {
24098
24241
  return hrefKey.replace(/-href$/, "-label");
@@ -25798,7 +25941,7 @@ function OhhwellsBridge() {
25798
25941
  const searchParams = useSearchParams();
25799
25942
  const isEditMode = isEditSessionActive();
25800
25943
  const [bridgeRoot, setBridgeRoot] = useState18(null);
25801
- useEffect19(() => {
25944
+ useEffect20(() => {
25802
25945
  const figtreeFontId = "ohw-figtree-font";
25803
25946
  if (!document.getElementById(figtreeFontId)) {
25804
25947
  const preconnect1 = Object.assign(document.createElement("link"), { rel: "preconnect", href: "https://fonts.googleapis.com" });
@@ -25837,7 +25980,7 @@ function OhhwellsBridge() {
25837
25980
  }, 0);
25838
25981
  return () => window.clearTimeout(t);
25839
25982
  }, [subdomainFromQuery, subdomain]);
25840
- useEffect19(() => {
25983
+ useEffect20(() => {
25841
25984
  if (!subdomainFromQuery || typeof window === "undefined") return;
25842
25985
  const url = new URL(window.location.href);
25843
25986
  if (!url.searchParams.has("subdomain")) return;
@@ -25857,14 +26000,14 @@ function OhhwellsBridge() {
25857
26000
  const [fetchState, setFetchState] = useState18("idle");
25858
26001
  const [showBranding, setShowBranding] = useState18(false);
25859
26002
  const autoSaveTimers = useRef14(/* @__PURE__ */ new Map());
25860
- useEffect19(() => {
26003
+ useEffect20(() => {
25861
26004
  stampBridgeVersionOnDocument();
25862
26005
  }, []);
25863
- useEffect19(() => {
26006
+ useEffect20(() => {
25864
26007
  if (isEditMode) return;
25865
26008
  return armLoaderHangBeacon(subdomain, fetchState);
25866
26009
  }, [isEditMode, subdomain, fetchState]);
25867
- useEffect19(() => {
26010
+ useEffect20(() => {
25868
26011
  if (isEditMode || !subdomain) return;
25869
26012
  const onError = (event) => {
25870
26013
  reportOutageBeacon({
@@ -26005,7 +26148,7 @@ function OhhwellsBridge() {
26005
26148
  }, []);
26006
26149
  const selectMediaElementRef = useRef14(selectMediaElement);
26007
26150
  selectMediaElementRef.current = selectMediaElement;
26008
- useEffect19(() => {
26151
+ useEffect20(() => {
26009
26152
  if (!selectedMedia) return;
26010
26153
  const update = () => {
26011
26154
  const el = selectedMediaElRef.current;
@@ -26220,7 +26363,7 @@ function OhhwellsBridge() {
26220
26363
  const [fieldDragging, setFieldDragging] = useState18(false);
26221
26364
  const clearFormPickRef = useRef14(clearFormPick);
26222
26365
  clearFormPickRef.current = clearFormPick;
26223
- useEffect19(() => {
26366
+ useEffect20(() => {
26224
26367
  const el = fieldPickElRef.current;
26225
26368
  if (!el || fieldPickRect === null) return;
26226
26369
  const observer = new ResizeObserver(() => {
@@ -26229,7 +26372,7 @@ function OhhwellsBridge() {
26229
26372
  observer.observe(el);
26230
26373
  return () => observer.disconnect();
26231
26374
  }, [fieldPickRect !== null, fieldPickState]);
26232
- useEffect19(() => {
26375
+ useEffect20(() => {
26233
26376
  const el = formPickElRef.current;
26234
26377
  if (!el || formPickRect === null) return;
26235
26378
  const observer = new ResizeObserver(() => {
@@ -26256,7 +26399,7 @@ function OhhwellsBridge() {
26256
26399
  const hoveredItemElRef = useRef14(null);
26257
26400
  const [hoveredItemRect, setHoveredItemRect] = useState18(null);
26258
26401
  const [hoveredTextRect, setHoveredTextRect] = useState18(null);
26259
- useEffect19(() => {
26402
+ useEffect20(() => {
26260
26403
  const sync = () => {
26261
26404
  const el = document.querySelector(
26262
26405
  '[data-ohw-hovered]:not([contenteditable]):not([data-ohw-href-key]):not([data-ohw-editable="form"] *)'
@@ -26334,6 +26477,7 @@ function OhhwellsBridge() {
26334
26477
  const linkPopoverSessionRef = useRef14(null);
26335
26478
  const addNavAfterAnchorRef = useRef14(null);
26336
26479
  const editContentRef = useRef14({});
26480
+ useBuildPageSync(isEditMode, editContentRef, postToParent2);
26337
26481
  const aiSectionsRef = useRef14("");
26338
26482
  const aiFooterRef = useRef14("");
26339
26483
  const applyTreeLocalRef = useRef14(
@@ -26356,7 +26500,7 @@ function OhhwellsBridge() {
26356
26500
  const linkPopoverGraceUntilRef = useRef14(0);
26357
26501
  setLinkPopoverRef.current = setLinkPopover;
26358
26502
  linkPopoverSessionRef.current = linkPopover;
26359
- useEffect19(() => {
26503
+ useEffect20(() => {
26360
26504
  setSectionOrderPersistHandler((entries) => {
26361
26505
  const currentPath = window.location.pathname;
26362
26506
  const merged = mergePageSectionOrder(editContentRef.current[SECTION_ORDER_KEY], currentPath, entries);
@@ -26366,7 +26510,7 @@ function OhhwellsBridge() {
26366
26510
  });
26367
26511
  return () => setSectionOrderPersistHandler(null);
26368
26512
  }, []);
26369
- useEffect19(() => {
26513
+ useEffect20(() => {
26370
26514
  setAiFooterMountOptions({
26371
26515
  resolvePageHref: (pageOrAnchorId) => {
26372
26516
  const [pageId, anchor] = pageOrAnchorId.split("#");
@@ -26450,7 +26594,7 @@ function OhhwellsBridge() {
26450
26594
  }, [isEditMode, pathname]);
26451
26595
  const runSectionsPrefetchRef = useRef14(runSectionsPrefetch);
26452
26596
  runSectionsPrefetchRef.current = runSectionsPrefetch;
26453
- useEffect19(() => {
26597
+ useEffect20(() => {
26454
26598
  if (!linkPopover) {
26455
26599
  document.documentElement.removeAttribute("data-ohw-link-popover-open");
26456
26600
  return;
@@ -26478,7 +26622,7 @@ function OhhwellsBridge() {
26478
26622
  document.documentElement.removeAttribute("data-ohw-link-popover-open");
26479
26623
  };
26480
26624
  }, [linkPopover, postToParent2]);
26481
- useEffect19(() => {
26625
+ useEffect20(() => {
26482
26626
  if (!isEditMode) return;
26483
26627
  const useFixtures = shouldUseDevFixtures();
26484
26628
  if (useFixtures) {
@@ -26504,7 +26648,7 @@ function OhhwellsBridge() {
26504
26648
  if (!useFixtures) postToParent2({ type: "ow:request-site-pages" });
26505
26649
  return () => window.removeEventListener("message", onSitePages);
26506
26650
  }, [isEditMode, postToParent2]);
26507
- useEffect19(() => {
26651
+ useEffect20(() => {
26508
26652
  if (!isEditMode) return;
26509
26653
  const deps = {
26510
26654
  getEditContent: () => editContentRef.current,
@@ -26541,14 +26685,14 @@ function OhhwellsBridge() {
26541
26685
  window.addEventListener("message", onPageMessage);
26542
26686
  return () => window.removeEventListener("message", onPageMessage);
26543
26687
  }, [isEditMode, postToParent2]);
26544
- useEffect19(() => {
26688
+ useEffect20(() => {
26545
26689
  if (!isEditMode || shouldUseDevFixtures()) return;
26546
26690
  void loadAllSectionsManifest().then((manifest) => {
26547
26691
  if (Object.keys(manifest).length === 0) return;
26548
26692
  setSectionsByPath((prev) => ({ ...manifest, ...prev }));
26549
26693
  });
26550
26694
  }, [isEditMode]);
26551
- useEffect19(() => {
26695
+ useEffect20(() => {
26552
26696
  const update = () => {
26553
26697
  const el = activeElRef.current ?? selectedElRef.current;
26554
26698
  if (el) setToolbarRect(getEditMeasureEl(el).getBoundingClientRect());
@@ -27807,7 +27951,7 @@ function OhhwellsBridge() {
27807
27951
  },
27808
27952
  [postToParent2]
27809
27953
  );
27810
- useEffect19(() => {
27954
+ useEffect20(() => {
27811
27955
  const onDragOver = (e) => {
27812
27956
  const dragged = buttonCollectionDragRef.current;
27813
27957
  if (!dragged) return;
@@ -27878,7 +28022,7 @@ function OhhwellsBridge() {
27878
28022
  setLogoSizeDraft(null);
27879
28023
  deselectRef.current();
27880
28024
  }, []);
27881
- useEffect19(() => {
28025
+ useEffect20(() => {
27882
28026
  const session = floatingPanel && floatingPanel.kind === "logo-size" ? floatingPanel : null;
27883
28027
  if (!session || !logoSizeDraft) {
27884
28028
  postToParentRef.current({ type: "ow:logo-size-panel", open: false });
@@ -28036,7 +28180,7 @@ function OhhwellsBridge() {
28036
28180
  deselectRef.current = deselect;
28037
28181
  closeFloatingPanelOnlyRef.current = closeFloatingPanelOnly;
28038
28182
  const lastSiteWideScopeRef = useRef14(null);
28039
- useEffect19(() => {
28183
+ useEffect20(() => {
28040
28184
  if (!isEditMode) {
28041
28185
  if (lastSiteWideScopeRef.current !== false) {
28042
28186
  lastSiteWideScopeRef.current = false;
@@ -28213,7 +28357,7 @@ function OhhwellsBridge() {
28213
28357
  cancelled = true;
28214
28358
  };
28215
28359
  }, [subdomain, isEditMode]);
28216
- useEffect19(() => {
28360
+ useEffect20(() => {
28217
28361
  if (!isEditMode) return;
28218
28362
  const resolveIndex = (form, clientY) => {
28219
28363
  const wrappers = listFieldWrappers(form).filter((el) => fieldKeyOf(el) !== fieldDragRef.current?.key);
@@ -28254,7 +28398,7 @@ function OhhwellsBridge() {
28254
28398
  window.removeEventListener("drop", onDrop, true);
28255
28399
  };
28256
28400
  }, [buildFieldDropSlots, isEditMode, persistFields, selectField]);
28257
- useEffect19(() => {
28401
+ useEffect20(() => {
28258
28402
  if (!isEditMode) return;
28259
28403
  const mark = () => document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
28260
28404
  markFormFields(form);
@@ -28266,7 +28410,7 @@ function OhhwellsBridge() {
28266
28410
  });
28267
28411
  return () => observer.disconnect();
28268
28412
  }, [isEditMode, fetchState, pathname]);
28269
- useEffect19(() => {
28413
+ useEffect20(() => {
28270
28414
  if (!isEditMode) return;
28271
28415
  let saveTimer = null;
28272
28416
  const onInput = (e) => {
@@ -28288,14 +28432,14 @@ function OhhwellsBridge() {
28288
28432
  document.addEventListener("input", onInput, true);
28289
28433
  return () => document.removeEventListener("input", onInput, true);
28290
28434
  }, [isEditMode, persistFields]);
28291
- useEffect19(() => {
28435
+ useEffect20(() => {
28292
28436
  if (isEditMode || fetchState !== "done") return;
28293
28437
  const content = contentCache.get(subdomain) ?? {};
28294
28438
  document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
28295
28439
  reconcileFieldsFromContent(form, content);
28296
28440
  });
28297
28441
  }, [isEditMode, fetchState, subdomain]);
28298
- useEffect19(() => {
28442
+ useEffect20(() => {
28299
28443
  if (!isEditMode) return;
28300
28444
  const swallow = (e) => {
28301
28445
  const target = e.target;
@@ -28304,14 +28448,14 @@ function OhhwellsBridge() {
28304
28448
  document.addEventListener("submit", swallow, true);
28305
28449
  return () => document.removeEventListener("submit", swallow, true);
28306
28450
  }, [isEditMode]);
28307
- useEffect19(() => {
28451
+ useEffect20(() => {
28308
28452
  if (isEditMode || fetchState !== "done") return;
28309
28453
  console.log("env", process.env.NEXT_PUBLIC_FLOWOPS_API_URL);
28310
28454
  const apiUrl = process.env.NEXT_PUBLIC_FLOWOPS_API_URL ?? "https://flowops-backend-staging-2yfdh7pwpq-as.a.run.app";
28311
28455
  console.log({ apiUrl, subdomain });
28312
28456
  bindPublishedForms(apiUrl, subdomain, contentCache.get(subdomain) ?? {});
28313
28457
  }, [isEditMode, fetchState, subdomain]);
28314
- useEffect19(() => {
28458
+ useEffect20(() => {
28315
28459
  if (!subdomain || isEditMode) return;
28316
28460
  let debounceTimer = null;
28317
28461
  let observer = null;
@@ -28434,10 +28578,10 @@ function OhhwellsBridge() {
28434
28578
  const visible = Boolean(subdomain) && fetchState !== "done";
28435
28579
  el.style.display = visible ? "flex" : "none";
28436
28580
  }, [subdomain, fetchState]);
28437
- useEffect19(() => {
28581
+ useEffect20(() => {
28438
28582
  postToParent2({ type: "ow:navigation", path: pathname });
28439
28583
  }, [pathname, postToParent2]);
28440
- useEffect19(() => {
28584
+ useEffect20(() => {
28441
28585
  if (!subdomain || isEditMode) return;
28442
28586
  const content = contentCache.get(subdomain);
28443
28587
  if (!content) return;
@@ -28455,7 +28599,7 @@ function OhhwellsBridge() {
28455
28599
  }
28456
28600
  applyAiFooterFromContent(content);
28457
28601
  }, [pathname, subdomain, isEditMode]);
28458
- useEffect19(() => {
28602
+ useEffect20(() => {
28459
28603
  if (!isEditMode) return;
28460
28604
  if (linkPopoverSessionRef.current?.intent === "add-nav") return;
28461
28605
  if (document.querySelector("[data-ohw-section-picker]")) return;
@@ -28463,12 +28607,12 @@ function OhhwellsBridge() {
28463
28607
  deselectRef.current();
28464
28608
  deactivateRef.current();
28465
28609
  }, [pathname, isEditMode]);
28466
- useEffect19(() => {
28610
+ useEffect20(() => {
28467
28611
  if (!isEditMode) return;
28468
28612
  initSectionInstancesFromContent(editContentRef.current, pathname);
28469
28613
  initItemInstancesFromContent(editContentRef.current);
28470
28614
  }, [pathname, isEditMode]);
28471
- useEffect19(() => {
28615
+ useEffect20(() => {
28472
28616
  if (!isEditMode) return;
28473
28617
  const observer = new MutationObserver(() => {
28474
28618
  const drawer = document.querySelector("[data-ohw-nav-drawer]");
@@ -28479,7 +28623,7 @@ function OhhwellsBridge() {
28479
28623
  observer.observe(document.body, { childList: true, subtree: true });
28480
28624
  return () => observer.disconnect();
28481
28625
  }, [isEditMode, pathname]);
28482
- useEffect19(() => {
28626
+ useEffect20(() => {
28483
28627
  const contentForNav = () => {
28484
28628
  if (isEditMode) return editContentRef.current;
28485
28629
  if (!subdomain) return {};
@@ -28552,7 +28696,7 @@ function OhhwellsBridge() {
28552
28696
  observer?.disconnect();
28553
28697
  };
28554
28698
  }, [isEditMode, pathname, subdomain, fetchState, resyncSelectedNavigationItem]);
28555
- useEffect19(() => {
28699
+ useEffect20(() => {
28556
28700
  if (!isEditMode) return;
28557
28701
  let applying = false;
28558
28702
  let rafId = null;
@@ -28590,7 +28734,7 @@ function OhhwellsBridge() {
28590
28734
  observer.disconnect();
28591
28735
  };
28592
28736
  }, [isEditMode, pathname]);
28593
- useEffect19(() => {
28737
+ useEffect20(() => {
28594
28738
  if (!isEditMode) return;
28595
28739
  let lastPosted = 0;
28596
28740
  const measure = () => {
@@ -28634,7 +28778,7 @@ function OhhwellsBridge() {
28634
28778
  window.removeEventListener("resize", handleResize);
28635
28779
  };
28636
28780
  }, [pathname, isEditMode, postToParent2]);
28637
- useEffect19(() => {
28781
+ useEffect20(() => {
28638
28782
  if (isEditMode) return;
28639
28783
  const handleClick = (e) => {
28640
28784
  if (!isPlainLeftClick(e)) return;
@@ -28648,7 +28792,7 @@ function OhhwellsBridge() {
28648
28792
  document.addEventListener("click", handleClick, true);
28649
28793
  return () => document.removeEventListener("click", handleClick, true);
28650
28794
  }, [isEditMode, router, pathname]);
28651
- useEffect19(() => {
28795
+ useEffect20(() => {
28652
28796
  if (!isEditMode) {
28653
28797
  editStylesRef.current?.base.remove();
28654
28798
  editStylesRef.current?.forceHover.remove();
@@ -32103,7 +32247,7 @@ function OhhwellsBridge() {
32103
32247
  if (imageShowTimerRef.current) clearTimeout(imageShowTimerRef.current);
32104
32248
  };
32105
32249
  }, [isEditMode, refreshStateRules]);
32106
- useEffect19(() => {
32250
+ useEffect20(() => {
32107
32251
  if (!isEditMode) return;
32108
32252
  const THRESHOLD = 10;
32109
32253
  const resolveWasSelected = (el) => {
@@ -32259,7 +32403,7 @@ function OhhwellsBridge() {
32259
32403
  unlockFooterDragInteraction();
32260
32404
  };
32261
32405
  }, [isEditMode]);
32262
- useEffect19(() => {
32406
+ useEffect20(() => {
32263
32407
  if (!isEditMode) return;
32264
32408
  const THRESHOLD = 10;
32265
32409
  const onPointerDown = (e) => {
@@ -32350,7 +32494,7 @@ function OhhwellsBridge() {
32350
32494
  document.removeEventListener("selectstart", blockSelectStart, true);
32351
32495
  };
32352
32496
  }, [isEditMode, persistButtonCollectionDrag, refreshButtonDragVisuals]);
32353
- useEffect19(() => {
32497
+ useEffect20(() => {
32354
32498
  const handler = (e) => {
32355
32499
  if (e.data?.type !== "ow:request-schedule-config") return;
32356
32500
  const insertAfterVal = e.data.insertAfter;
@@ -32366,7 +32510,7 @@ function OhhwellsBridge() {
32366
32510
  window.addEventListener("message", handler);
32367
32511
  return () => window.removeEventListener("message", handler);
32368
32512
  }, [processConfigRequest]);
32369
- useEffect19(() => {
32513
+ useEffect20(() => {
32370
32514
  if (!isEditMode) return;
32371
32515
  document.querySelectorAll("[data-ohw-active-state]").forEach((el) => {
32372
32516
  el.removeAttribute("data-ohw-active-state");
@@ -32390,7 +32534,7 @@ function OhhwellsBridge() {
32390
32534
  postToParent2({
32391
32535
  type: "ow:ready",
32392
32536
  version: "1",
32393
- bridgeVersion: "0.1.164",
32537
+ bridgeVersion: "0.1.165",
32394
32538
  path: pathname,
32395
32539
  nodes: collectEditableNodes(editContentRef.current),
32396
32540
  sections
@@ -32402,7 +32546,7 @@ function OhhwellsBridge() {
32402
32546
  clearTimeout(timer);
32403
32547
  };
32404
32548
  }, [pathname, isEditMode, refreshStateRules, postToParent2]);
32405
- useEffect19(() => {
32549
+ useEffect20(() => {
32406
32550
  scrollToHashSectionWhenReady();
32407
32551
  const onHashChange = () => scrollToHashSectionWhenReady();
32408
32552
  window.addEventListener("hashchange", onHashChange);
@@ -32444,7 +32588,7 @@ function OhhwellsBridge() {
32444
32588
  if (el) setToolbarRect(getEditMeasureEl(el).getBoundingClientRect());
32445
32589
  refreshActiveCommandsRef.current();
32446
32590
  }, []);
32447
- useEffect19(() => {
32591
+ useEffect20(() => {
32448
32592
  const session = floatingPanel && floatingPanel.kind === "logo-size" ? floatingPanel : null;
32449
32593
  if (!session || !logoSizeDraft) return;
32450
32594
  const onPanelAction = (e) => {
@@ -33618,6 +33762,7 @@ export {
33618
33762
  hasMountedContentNodes,
33619
33763
  indexCollectionItems,
33620
33764
  insertFooterHours,
33765
+ isDeadPageHref,
33621
33766
  isEditSessionActive,
33622
33767
  isPlainLeftClick,
33623
33768
  isRenderableFooterTree,
@@ -33629,6 +33774,7 @@ export {
33629
33774
  parseAiFooterState,
33630
33775
  parseAiSectionsState,
33631
33776
  parseTarget,
33777
+ planBuildPageSync,
33632
33778
  recordOverriddenPaths,
33633
33779
  releaseTemplateLogoIfReplaced,
33634
33780
  removeFooterBlock,