@ohhwells/bridge 0.1.169 → 0.1.170-next.454

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 useEffect21, useLayoutEffect as useLayoutEffect6, useRef as useRef14, useState as useState18 } from "react";
4
+ import React12, { useCallback as useCallback12, useEffect as useEffect21, useLayoutEffect as useLayoutEffect7, 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
 
@@ -189,9 +189,23 @@ function parseSectionsFromHtml(html) {
189
189
  return parseSectionsFromRoot(doc);
190
190
  }
191
191
 
192
+ // src/lib/soft-hide.ts
193
+ var PREV_DISPLAY_ATTR = "data-ohw-prev-display";
194
+ function softHide(el) {
195
+ if (!el.hasAttribute(PREV_DISPLAY_ATTR)) el.setAttribute(PREV_DISPLAY_ATTR, el.style.display);
196
+ el.style.display = "none";
197
+ }
198
+ function softUnhide(el) {
199
+ const prev = el.getAttribute(PREV_DISPLAY_ATTR);
200
+ el.removeAttribute(PREV_DISPLAY_ATTR);
201
+ if (prev) el.style.display = prev;
202
+ else el.style.removeProperty("display");
203
+ }
204
+
192
205
  // src/lib/section-instances.ts
193
206
  var SECTION_ORDER_KEY = "__ohw_section_order";
194
207
  var REMOVED_ATTR = "data-ohw-section-removed";
208
+ var CLONE_ATTR = "data-ohw-section-clone";
195
209
  function isRemovedSection(el) {
196
210
  return el.hasAttribute(REMOVED_ATTR);
197
211
  }
@@ -260,14 +274,14 @@ function syncRemovedFlags(entries) {
260
274
  const removedIds = new Set(entries.filter((e) => e.removed).map((e) => e.instanceId));
261
275
  document.querySelectorAll(`[${REMOVED_ATTR}]`).forEach((el) => {
262
276
  if (!removedIds.has(instanceIdOf(el))) {
263
- el.style.removeProperty("display");
277
+ softUnhide(el);
264
278
  el.removeAttribute(REMOVED_ATTR);
265
279
  }
266
280
  });
267
281
  for (const id of removedIds) {
268
282
  const el = findByInstanceId(id);
269
283
  if (el) {
270
- el.style.display = "none";
284
+ softHide(el);
271
285
  el.setAttribute(REMOVED_ATTR, "");
272
286
  }
273
287
  }
@@ -320,6 +334,7 @@ function duplicateSectionInstance(instanceId, newId, currentPath, existingEntrie
320
334
  if (!original) return null;
321
335
  const clone = original.cloneNode(true);
322
336
  clone.setAttribute("data-ohw-instance", newId);
337
+ clone.setAttribute(CLONE_ATTR, "");
323
338
  const keyRekeys = rekeySectionSubtree(clone, newId);
324
339
  original.insertAdjacentElement("afterend", clone);
325
340
  const byId = new Map(existingEntries.map((e) => [e.instanceId, e]));
@@ -339,6 +354,15 @@ function duplicateSectionInstance(instanceId, newId, currentPath, existingEntrie
339
354
  function newInstanceId() {
340
355
  return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `instance-${Date.now()}-${Math.random().toString(36).slice(2)}`;
341
356
  }
357
+ function orderBeforeMove(raw, currentPath) {
358
+ const entries = topLevelSections().map((el, order) => ({
359
+ instanceId: instanceIdOf(el),
360
+ type: sectionTypeOf(el),
361
+ order,
362
+ pagePath: currentPath
363
+ }));
364
+ return JSON.stringify(mergePageSectionOrder(raw, currentPath, entries));
365
+ }
342
366
  function getPageSectionOrderEntries(raw, currentPath) {
343
367
  if (!raw) return [];
344
368
  try {
@@ -390,6 +414,10 @@ function initSectionInstancesFromContent(content, currentPath) {
390
414
  if (type) el.setAttribute("data-ohw-instance", type);
391
415
  });
392
416
  const entries = getPageSectionOrderEntries(content[SECTION_ORDER_KEY], currentPath);
417
+ const listed = new Set(entries.map((entry) => entry.instanceId));
418
+ document.querySelectorAll(`[${CLONE_ATTR}]`).forEach((clone) => {
419
+ if (!listed.has(instanceIdOf(clone))) clone.remove();
420
+ });
393
421
  for (const entry of entries) {
394
422
  if (entry.instanceId === entry.type) continue;
395
423
  if (document.querySelector(`[data-ohw-instance="${CSS.escape(entry.instanceId)}"]`)) continue;
@@ -399,6 +427,7 @@ function initSectionInstancesFromContent(content, currentPath) {
399
427
  if (!original) continue;
400
428
  const clone = original.cloneNode(true);
401
429
  clone.setAttribute("data-ohw-instance", entry.instanceId);
430
+ clone.setAttribute(CLONE_ATTR, "");
402
431
  rekeySectionSubtree(clone, entry.instanceId);
403
432
  original.insertAdjacentElement("afterend", clone);
404
433
  }
@@ -1098,21 +1127,21 @@ function chromeFrom(sample) {
1098
1127
  };
1099
1128
  }
1100
1129
  function filledPrimary(seed) {
1101
- const paint = parseColor(paintColor(seed)) ?? { r: 15, g: 15, b: 15, a: 1 };
1102
- const luminance = relativeLuminance(paint);
1130
+ const paint2 = parseColor(paintColor(seed)) ?? { r: 15, g: 15, b: 15, a: 1 };
1131
+ const luminance = relativeLuminance(paint2);
1103
1132
  return {
1104
- background: toCss({ ...paint, a: 1 }),
1133
+ background: toCss({ ...paint2, a: 1 }),
1105
1134
  color: luminance > 0.55 ? "rgb(15, 15, 15)" : "rgb(255, 255, 255)",
1106
1135
  borderColor: TRANSPARENT,
1107
1136
  borderWidth: "0px"
1108
1137
  };
1109
1138
  }
1110
1139
  function generatedSecondary(primary) {
1111
- const paint = accentColor(primary);
1140
+ const paint2 = accentColor(primary);
1112
1141
  return {
1113
1142
  background: TRANSPARENT,
1114
- color: paint,
1115
- borderColor: paint,
1143
+ color: paint2,
1144
+ borderColor: paint2,
1116
1145
  borderWidth: "1px"
1117
1146
  };
1118
1147
  }
@@ -1125,9 +1154,9 @@ function generatedGhost(primary) {
1125
1154
  };
1126
1155
  }
1127
1156
  function normalizeOutlineChrome(outline, primary) {
1128
- const paint = accentColor(primary);
1157
+ const paint2 = accentColor(primary);
1129
1158
  const text = parseColor(outline.color);
1130
- const paintRgb = parseColor(paint);
1159
+ const paintRgb = parseColor(paint2);
1131
1160
  const primaryLabel = parseColor(primary.color);
1132
1161
  const matchesOnPrimary = Boolean(text && primaryLabel) && colorKey(outline.color) === colorKey(primary.color);
1133
1162
  const textTooLight = text ? relativeLuminance(text) > 0.7 : false;
@@ -1136,8 +1165,8 @@ function normalizeOutlineChrome(outline, primary) {
1136
1165
  const hasBorder = parseFloat(outline.borderWidth) > 0;
1137
1166
  return {
1138
1167
  ...outline,
1139
- color: paint,
1140
- borderColor: hasBorder ? paint : outline.borderColor
1168
+ color: paint2,
1169
+ borderColor: hasBorder ? paint2 : outline.borderColor
1141
1170
  };
1142
1171
  }
1143
1172
  function generateButtonVariants(samples) {
@@ -1556,6 +1585,8 @@ function brandTrackedFontFamily(doc, stack) {
1556
1585
  }
1557
1586
  var paintLockByEl = /* @__PURE__ */ new WeakMap();
1558
1587
  var paintObserverByEl = /* @__PURE__ */ new WeakMap();
1588
+ var prePaintByEl = /* @__PURE__ */ new WeakMap();
1589
+ var paintedEls = /* @__PURE__ */ new Set();
1559
1590
  var PAINT_GUARD_ATTRS = {
1560
1591
  attributes: true,
1561
1592
  attributeFilter: ["style", "class"]
@@ -1619,6 +1650,18 @@ function paintedTokensOf(el) {
1619
1650
  }
1620
1651
  function applyButtonStyle(el, assignment, tokens) {
1621
1652
  const doc = el.ownerDocument;
1653
+ if (!prePaintByEl.has(el)) {
1654
+ const label = labelElement(el);
1655
+ const ownLabel = label && label !== el ? label : null;
1656
+ prePaintByEl.set(el, {
1657
+ style: el.getAttribute("style"),
1658
+ variant: el.getAttribute("data-ohw-btn-variant"),
1659
+ size: el.getAttribute("data-ohw-btn-size"),
1660
+ label: ownLabel,
1661
+ labelStyle: ownLabel?.getAttribute("style") ?? null
1662
+ });
1663
+ }
1664
+ paintedEls.add(el);
1622
1665
  const tracked = {
1623
1666
  ...tokens,
1624
1667
  variants: {
@@ -1638,6 +1681,31 @@ function applyButtonStylesFromContent(doc, content) {
1638
1681
  if (!el) continue;
1639
1682
  applyButtonStyle(el, assignment, tokensFromButton(el));
1640
1683
  }
1684
+ for (const el of paintedEls) {
1685
+ if (!el.isConnected) {
1686
+ paintedEls.delete(el);
1687
+ continue;
1688
+ }
1689
+ const id = buttonId(el);
1690
+ if (el.ownerDocument === doc && (!id || !assignments[id])) unpaintButton(el);
1691
+ }
1692
+ }
1693
+ function unpaintButton(el) {
1694
+ paintObserverByEl.get(el)?.disconnect();
1695
+ paintObserverByEl.delete(el);
1696
+ paintLockByEl.delete(el);
1697
+ paintedEls.delete(el);
1698
+ const before = prePaintByEl.get(el);
1699
+ prePaintByEl.delete(el);
1700
+ if (!before) return;
1701
+ const restore = (target, name, value) => {
1702
+ if (value === null) target.removeAttribute(name);
1703
+ else target.setAttribute(name, value);
1704
+ };
1705
+ restore(el, "style", before.style);
1706
+ restore(el, "data-ohw-btn-variant", before.variant);
1707
+ restore(el, "data-ohw-btn-size", before.size);
1708
+ if (before.label?.isConnected) restore(before.label, "style", before.labelStyle);
1641
1709
  }
1642
1710
  function withAssignment(content, id, assignment) {
1643
1711
  return { ...readAssignments(content), [id]: assignment };
@@ -2188,6 +2256,7 @@ function reconcileButtonCollections(doc, content) {
2188
2256
  }
2189
2257
  const snapshots = readSnapshots(content);
2190
2258
  const collections = readCollections(content);
2259
+ dropUnsavedCopies(doc, snapshots, collections);
2191
2260
  for (const collectionState of Object.values(collections)) {
2192
2261
  const live = collectionState.members.map((id) => findButton(doc, id) ?? restoreSnapshot(doc, snapshots[id], content)).filter((el) => Boolean(el && !hidden.has(buttonId(el) ?? "")));
2193
2262
  if (live.length === 0) continue;
@@ -2212,6 +2281,18 @@ function reconcileButtonCollections(doc, content) {
2212
2281
  for (const member of live) setButtonDragAttr(member);
2213
2282
  }
2214
2283
  }
2284
+ function dropUnsavedCopies(doc, snapshots, collections) {
2285
+ const stale = Array.from(doc.querySelectorAll('[data-ohw-href-key*="-copy-"]')).filter((el) => {
2286
+ const id = buttonId(el);
2287
+ return Boolean(id && /-copy-\d+-href$/.test(id) && !snapshots[id]);
2288
+ });
2289
+ for (const el of stale) {
2290
+ const collection = buttonCollectionOf(el);
2291
+ el.remove();
2292
+ const id = collection?.getAttribute(COLLECTION_ATTR) ?? "";
2293
+ if (collection && !collections[id] && listCollectionMembers(collection).length <= 1) unwrapCollection(collection);
2294
+ }
2295
+ }
2215
2296
  function restoreSnapshot(doc, snapshot, content) {
2216
2297
  if (!snapshot) return null;
2217
2298
  const existing = findButton(doc, snapshot.id);
@@ -4746,6 +4827,9 @@ function reconcileNavbarItemsFromContent(content) {
4746
4827
  }
4747
4828
  }
4748
4829
  pruneNavbarItemsNotInOrder(allowed);
4830
+ for (const node of orderForest) {
4831
+ if (node.children.length === 0) collapseEmptyNavDropdownForParent(node.id);
4832
+ }
4749
4833
  applyNavForest(orderForest);
4750
4834
  for (const parentKey of openParentKeys) {
4751
4835
  const trigger = document.querySelector(
@@ -5115,6 +5199,118 @@ function deleteNavbarItem(sourceAnchor) {
5115
5199
  };
5116
5200
  }
5117
5201
 
5202
+ // src/lib/hidden-editables.ts
5203
+ var HIDDEN_EDITABLES_KEY = "__ohw_hidden_editables";
5204
+ var HIDDEN_ATTR = "data-ohw-editable-hidden";
5205
+ var FORM_SELECTOR = '[data-ohw-editable="form"]';
5206
+ function parseJson3(raw) {
5207
+ if (!raw) return null;
5208
+ try {
5209
+ return JSON.parse(raw);
5210
+ } catch {
5211
+ return null;
5212
+ }
5213
+ }
5214
+ function readHiddenEditables(content) {
5215
+ const parsed = parseJson3(content?.[HIDDEN_EDITABLES_KEY]);
5216
+ if (!Array.isArray(parsed)) return [];
5217
+ return [...new Set(parsed.filter((key) => typeof key === "string" && key.length > 0))];
5218
+ }
5219
+ function isEditableKeyHidden(content, key) {
5220
+ if (!key) return false;
5221
+ return readHiddenEditables(content).includes(key);
5222
+ }
5223
+ function resolveSoftHideTarget(el) {
5224
+ const cta = el.closest(CTA_BUTTON_SELECTOR);
5225
+ if (cta) return cta;
5226
+ const form = el.closest(FORM_SELECTOR);
5227
+ if (form) return form;
5228
+ return el;
5229
+ }
5230
+ function canSoftHideEditable(el, opts) {
5231
+ if (!el) return false;
5232
+ const target = resolveSoftHideTarget(el);
5233
+ const key = target.dataset.ohwKey ?? el.dataset.ohwKey;
5234
+ if (!key) return false;
5235
+ if (key.startsWith("ai.")) return false;
5236
+ if (key.startsWith("__ohw_")) return false;
5237
+ if (el.hasAttribute("data-ohw-section") || target.hasAttribute("data-ohw-section")) return false;
5238
+ if (el.closest("[data-ohw-social-item]")) return false;
5239
+ if (target.matches(FORM_SELECTOR) || el.dataset.ohwEditable === "form") return true;
5240
+ const cta = el.closest(CTA_BUTTON_SELECTOR);
5241
+ if (cta) return !isLastNavbarButton(cta);
5242
+ if (opts?.isNavFooterItem) return false;
5243
+ if (el.closest("[data-ohw-nav-container], [data-ohw-nav-drawer], [data-ohw-nav-root], nav")) {
5244
+ if (el.closest("[data-ohw-href-key], [data-ohw-nav-item], [data-ohw-nav-group]")) return false;
5245
+ }
5246
+ if (el.closest("footer, [data-ai-footer]")) {
5247
+ if (el.closest("[data-ohw-href-key], [data-ohw-footer-item], [data-ohw-social-item]")) return false;
5248
+ }
5249
+ const kind = el.dataset.ohwEditable;
5250
+ return kind === "text" || kind === "plain" || kind === "image" || kind === "bg-image" || kind === "video" || kind === "icon" || kind === "link" || kind === "map";
5251
+ }
5252
+ function withHiddenEditable(content, key) {
5253
+ const hidden = readHiddenEditables(content);
5254
+ if (hidden.includes(key)) {
5255
+ return {
5256
+ content,
5257
+ nodes: [{ key: HIDDEN_EDITABLES_KEY, text: content[HIDDEN_EDITABLES_KEY] ?? "[]" }],
5258
+ added: false
5259
+ };
5260
+ }
5261
+ const nextHidden = [...hidden, key];
5262
+ const text = JSON.stringify(nextHidden);
5263
+ return {
5264
+ content: { ...content, [HIDDEN_EDITABLES_KEY]: text },
5265
+ nodes: [{ key: HIDDEN_EDITABLES_KEY, text }],
5266
+ added: true
5267
+ };
5268
+ }
5269
+ function withoutHiddenEditable(content, key) {
5270
+ const nextHidden = readHiddenEditables(content).filter((entry) => entry !== key);
5271
+ const text = JSON.stringify(nextHidden);
5272
+ return {
5273
+ content: { ...content, [HIDDEN_EDITABLES_KEY]: text },
5274
+ nodes: [{ key: HIDDEN_EDITABLES_KEY, text }]
5275
+ };
5276
+ }
5277
+ function escapeAttrValue(value) {
5278
+ return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
5279
+ }
5280
+ function markHidden(el) {
5281
+ softHide(el);
5282
+ el.setAttribute(HIDDEN_ATTR, "");
5283
+ }
5284
+ function markVisible(el) {
5285
+ softUnhide(el);
5286
+ el.removeAttribute(HIDDEN_ATTR);
5287
+ }
5288
+ function applyHiddenEditablesToDom(content, root = document) {
5289
+ const hidden = readHiddenEditables(content);
5290
+ root.querySelectorAll(`[${HIDDEN_ATTR}]`).forEach((el) => markVisible(el));
5291
+ for (const key of hidden) {
5292
+ root.querySelectorAll(`[data-ohw-key="${escapeAttrValue(key)}"]`).forEach((el) => {
5293
+ markHidden(resolveSoftHideTarget(el));
5294
+ });
5295
+ }
5296
+ }
5297
+ function softHideEditableInDom(el, content) {
5298
+ if (!canSoftHideEditable(el)) return null;
5299
+ const target = resolveSoftHideTarget(el);
5300
+ const key = target.dataset.ohwKey ?? el.dataset.ohwKey;
5301
+ if (!key) return null;
5302
+ const next = withHiddenEditable(content, key);
5303
+ markHidden(target);
5304
+ return { content: next.content, nodes: next.nodes, key, target };
5305
+ }
5306
+ function softUnhideEditableInDom(key, content, root = document) {
5307
+ const next = withoutHiddenEditable(content, key);
5308
+ root.querySelectorAll(`[data-ohw-key="${escapeAttrValue(key)}"]`).forEach((el) => {
5309
+ markVisible(resolveSoftHideTarget(el));
5310
+ });
5311
+ return next;
5312
+ }
5313
+
5118
5314
  // src/lib/collect-editable-nodes.ts
5119
5315
  var VIDEO_AUTOPLAY_SUFFIX = "__ohw_autoplay";
5120
5316
  var VIDEO_MUTED_SUFFIX = "__ohw_muted";
@@ -5193,7 +5389,9 @@ function collectEditableNodes(extraContent, root = document) {
5193
5389
  BUTTON_ASSIGNMENTS_KEY,
5194
5390
  BUTTON_COLLECTIONS_KEY,
5195
5391
  BUTTON_SNAPSHOTS_KEY,
5196
- BUTTON_HIDDEN_KEY
5392
+ BUTTON_HIDDEN_KEY,
5393
+ // Soft-hidden template slots (non-AI Delete) — no DOM marker when hidden.
5394
+ HIDDEN_EDITABLES_KEY
5197
5395
  ]) {
5198
5396
  const text = extraContent[key];
5199
5397
  if (typeof text === "string" && text.length > 0) {
@@ -5665,10 +5863,10 @@ function rekeyItemClone(clone, source, sibling, group, newIndex) {
5665
5863
  function setRemoved(el, removed) {
5666
5864
  if (removed) {
5667
5865
  el.setAttribute(ITEM_REMOVED_ATTR, "");
5668
- el.style.display = "none";
5866
+ softHide(el);
5669
5867
  } else if (el.hasAttribute(ITEM_REMOVED_ATTR)) {
5670
5868
  el.removeAttribute(ITEM_REMOVED_ATTR);
5671
- el.style.removeProperty("display");
5869
+ softUnhide(el);
5672
5870
  }
5673
5871
  }
5674
5872
  function seedState(group) {
@@ -6678,6 +6876,21 @@ function pricingCardFeatureCount(tree, index) {
6678
6876
  const target = findPricingCollection(tree)?.children?.[index];
6679
6877
  return target ? pricingFeatureList(target).length : 0;
6680
6878
  }
6879
+ function prevailingFeatureIcon(features) {
6880
+ const counts = /* @__PURE__ */ new Map();
6881
+ for (const row of features) {
6882
+ const key = `${row.icon ?? ""}|${row.iconColor ?? ""}`;
6883
+ const entry = counts.get(key) ?? { count: 0, ...row.icon ? { icon: row.icon } : {}, ...row.iconColor ? { iconColor: row.iconColor } : {} };
6884
+ entry.count += 1;
6885
+ counts.set(key, entry);
6886
+ }
6887
+ let best = null;
6888
+ for (const entry of counts.values()) {
6889
+ if (!best || entry.count > best.count) best = entry;
6890
+ }
6891
+ if (!best) return {};
6892
+ return { ...best.icon ? { icon: best.icon } : {}, ...best.iconColor ? { iconColor: best.iconColor } : {} };
6893
+ }
6681
6894
  function addPricingCardFeature(tree, index, text) {
6682
6895
  return withPricingCollection(tree, (collection) => {
6683
6896
  const children = collection.children;
@@ -6686,7 +6899,7 @@ function addPricingCardFeature(tree, index, text) {
6686
6899
  const features = pricingFeatureList(target);
6687
6900
  if (features.length >= PRICING_FEATURES_MAX) return false;
6688
6901
  target.slots = target.slots ?? {};
6689
- target.slots.features = [...features, { text }];
6902
+ target.slots.features = [...features, { text, ...prevailingFeatureIcon(features) }];
6690
6903
  return true;
6691
6904
  });
6692
6905
  }
@@ -6753,6 +6966,127 @@ function rewriteIconSlot(tree, path, ref) {
6753
6966
  return next;
6754
6967
  }
6755
6968
 
6969
+ // src/lib/ai-remove-block.ts
6970
+ function blockPathFromEditKey(sectionId, key) {
6971
+ const prefix = aiSlotKeyPrefixFor(sectionId);
6972
+ if (!key.startsWith(prefix)) return void 0;
6973
+ const path = [];
6974
+ for (const part of key.slice(prefix.length).split(".")) {
6975
+ if (/^[rbc]\d+$/.test(part)) path.push(part);
6976
+ else break;
6977
+ }
6978
+ if (path.length < 2 || !/^r\d+$/.test(path[0]) || !/^b\d+$/.test(path[1])) return void 0;
6979
+ return path.join(".");
6980
+ }
6981
+ function parseBlockPath(path) {
6982
+ const segs = [];
6983
+ for (const part of path.split(".")) {
6984
+ const match = part.match(/^([rbc])(\d+)$/);
6985
+ if (!match) return void 0;
6986
+ segs.push({ kind: match[1], index: Number(match[2]) });
6987
+ }
6988
+ if (segs.length < 2 || segs[0].kind !== "r" || segs[1].kind !== "b") return void 0;
6989
+ return segs;
6990
+ }
6991
+ function cloneTree(tree) {
6992
+ return JSON.parse(JSON.stringify(tree));
6993
+ }
6994
+ function nodeAtPath2(tree, segs) {
6995
+ let node = tree.rows?.[segs[0].index]?.blocks?.[segs[1].index];
6996
+ for (let i = 2; i < segs.length; i += 1) {
6997
+ if (segs[i].kind !== "c") return null;
6998
+ node = node?.children?.[segs[i].index];
6999
+ }
7000
+ return node ?? null;
7001
+ }
7002
+ function unwrapPromoted(node) {
7003
+ if (node.promoted === true && node.slots?.layout === "stack" && (node.children?.length ?? 0) === 1) {
7004
+ const only = { ...node.children[0] };
7005
+ if (node.slot) only.slot = node.slot;
7006
+ only.span = node.span;
7007
+ return only;
7008
+ }
7009
+ return node;
7010
+ }
7011
+ function removeBlockAtPath(tree, path) {
7012
+ const segs = parseBlockPath(path);
7013
+ if (!segs) return { ok: false, reasons: [`invalid block path "${path}"`] };
7014
+ const next = cloneTree(tree);
7015
+ const rowIndex = segs[0].index;
7016
+ const row = next.rows[rowIndex];
7017
+ if (!row) return { ok: false, reasons: [`row ${rowIndex} not found`] };
7018
+ if (segs.length === 2) {
7019
+ const blockIndex = segs[1].index;
7020
+ if (!row.blocks[blockIndex]) return { ok: false, reasons: [`block ${path} not found`] };
7021
+ row.blocks.splice(blockIndex, 1);
7022
+ if (row.blocks.length === 0) {
7023
+ next.rows.splice(rowIndex, 1);
7024
+ } else if (row.blocks.length === 1) {
7025
+ row.blocks[0] = { ...row.blocks[0], span: 12 };
7026
+ delete row.blocks[0].slot;
7027
+ }
7028
+ } else {
7029
+ let parent = row.blocks[segs[1].index];
7030
+ for (let i = 2; i < segs.length - 1; i += 1) {
7031
+ if (!parent?.children || segs[i].kind !== "c") {
7032
+ return { ok: false, reasons: [`block ${path} not found`] };
7033
+ }
7034
+ parent = parent.children[segs[i].index];
7035
+ }
7036
+ const childIndex = segs[segs.length - 1].index;
7037
+ if (!parent?.children || segs[segs.length - 1].kind !== "c" || !parent.children[childIndex]) {
7038
+ return { ok: false, reasons: [`block ${path} not found`] };
7039
+ }
7040
+ parent.children.splice(childIndex, 1);
7041
+ if (segs.length === 3) {
7042
+ row.blocks[segs[1].index] = unwrapPromoted(parent);
7043
+ if (row.blocks[segs[1].index].type === "group" && (row.blocks[segs[1].index].children?.length ?? 0) === 0) {
7044
+ row.blocks.splice(segs[1].index, 1);
7045
+ if (row.blocks.length === 0) next.rows.splice(rowIndex, 1);
7046
+ }
7047
+ if (next.rows[rowIndex]?.blocks.length === 1) {
7048
+ next.rows[rowIndex].blocks[0] = { ...next.rows[rowIndex].blocks[0], span: 12 };
7049
+ delete next.rows[rowIndex].blocks[0].slot;
7050
+ }
7051
+ } else {
7052
+ const grand = row.blocks[segs[1].index];
7053
+ let cursor = grand;
7054
+ for (let i = 2; i < segs.length - 2; i += 1) {
7055
+ cursor = cursor?.children?.[segs[i].index];
7056
+ }
7057
+ const containerIndex = segs[segs.length - 2].index;
7058
+ if (cursor?.children?.[containerIndex]) {
7059
+ cursor.children[containerIndex] = unwrapPromoted(parent);
7060
+ }
7061
+ }
7062
+ }
7063
+ if (next.rows.length === 0) {
7064
+ return { ok: false, reasons: ["a section must keep at least one block"] };
7065
+ }
7066
+ return { ok: true, tree: next };
7067
+ }
7068
+ function planAiBlockRemoval(aiSectionsRaw, editKey) {
7069
+ if (!editKey || !editKey.startsWith("ai.")) return null;
7070
+ const state = parseAiSectionsState(aiSectionsRaw);
7071
+ const entry = state.sections.find((s) => editKey.startsWith(aiSlotKeyPrefixFor(s.id)));
7072
+ if (!entry) return null;
7073
+ const path = blockPathFromEditKey(entry.id, editKey);
7074
+ if (!path) return null;
7075
+ const segs = parseBlockPath(path);
7076
+ if (!segs) return null;
7077
+ const node = nodeAtPath2(entry.tree, segs);
7078
+ if (!node) return null;
7079
+ const removed = removeBlockAtPath(entry.tree, path);
7080
+ if (!removed.ok) return removed;
7081
+ return { ok: true, tree: removed.tree, path, entry };
7082
+ }
7083
+ var planAiTextBlockRemoval = planAiBlockRemoval;
7084
+ function canRemoveAiBlock(aiSectionsRaw, editKey) {
7085
+ const plan = planAiBlockRemoval(aiSectionsRaw, editKey);
7086
+ return plan?.ok === true;
7087
+ }
7088
+ var canRemoveAiTextBlock = canRemoveAiBlock;
7089
+
6756
7090
  // src/lib/ai-footer-tree.ts
6757
7091
  var FOOTER_COLUMN_SPANS = [12, 6, 4, 3];
6758
7092
  var FOOTER_COLUMN_BLOCKS = [
@@ -7330,6 +7664,120 @@ function findSelectableNavContainer(doc = document) {
7330
7664
  );
7331
7665
  }
7332
7666
 
7667
+ // src/lib/youtube.ts
7668
+ var YOUTUBE_ID_PATTERN = /^[A-Za-z0-9_-]{11}$/;
7669
+ function extractYouTubeId(input) {
7670
+ const trimmed = input.trim();
7671
+ if (!trimmed) return null;
7672
+ if (YOUTUBE_ID_PATTERN.test(trimmed)) return trimmed;
7673
+ let url;
7674
+ try {
7675
+ url = new URL(trimmed);
7676
+ } catch {
7677
+ return null;
7678
+ }
7679
+ const host = url.hostname.replace(/^www\./, "");
7680
+ if (host !== "youtube.com" && host !== "m.youtube.com" && host !== "youtu.be" && host !== "youtube-nocookie.com") {
7681
+ return null;
7682
+ }
7683
+ let candidate = null;
7684
+ if (host === "youtu.be") {
7685
+ candidate = url.pathname.slice(1).split("/")[0] ?? null;
7686
+ } else if (url.pathname === "/watch") {
7687
+ candidate = url.searchParams.get("v");
7688
+ } else {
7689
+ const match = url.pathname.match(/^\/(?:embed|shorts)\/([^/]+)/);
7690
+ candidate = match ? match[1] : null;
7691
+ }
7692
+ return candidate && YOUTUBE_ID_PATTERN.test(candidate) ? candidate : null;
7693
+ }
7694
+
7695
+ // src/lib/section-embed.ts
7696
+ var SECTION_EMBED_SUFFIX = "__ohw_embed";
7697
+ function readStoredEmbed(value) {
7698
+ if (value.startsWith("start\n")) {
7699
+ return { raw: value.slice("start\n".length), at: "start" };
7700
+ }
7701
+ return { raw: value, at: "end" };
7702
+ }
7703
+ function embedFrameSrc(value) {
7704
+ const videoId = extractYouTubeId(value);
7705
+ if (videoId) {
7706
+ return { src: `https://www.youtube-nocookie.com/embed/${videoId}?rel=0`, title: "YouTube video" };
7707
+ }
7708
+ let url;
7709
+ try {
7710
+ url = new URL(value);
7711
+ } catch {
7712
+ return null;
7713
+ }
7714
+ const host = url.hostname.replace(/^www\./, "").toLowerCase();
7715
+ if (host === "google.com" && url.pathname.startsWith("/maps") || host === "maps.google.com") {
7716
+ const query = url.searchParams.get("q") || url.searchParams.get("query") || "";
7717
+ const src = query ? `https://maps.google.com/maps?q=${encodeURIComponent(query)}&output=embed` : `https://maps.google.com/maps?output=embed`;
7718
+ return { src, title: "Map" };
7719
+ }
7720
+ if (host === "maps.app.goo.gl") {
7721
+ return { src: value, title: "Map" };
7722
+ }
7723
+ if (host === "calendly.com" || host.endsWith(".calendly.com") || host === "calendar.google.com") {
7724
+ return { src: value, title: "Calendar" };
7725
+ }
7726
+ if (host === "docs.google.com" && url.pathname.includes("/forms/")) {
7727
+ return { src: value.replace(/\/edit(?:\?.*)?$/i, "/viewform"), title: "Form" };
7728
+ }
7729
+ if (host === "forms.gle") {
7730
+ return { src: value, title: "Form" };
7731
+ }
7732
+ return null;
7733
+ }
7734
+ function place(section, box, at) {
7735
+ if (at === "start") {
7736
+ section.insertBefore(box, section.firstChild);
7737
+ return;
7738
+ }
7739
+ section.appendChild(box);
7740
+ }
7741
+ function paint(section, key, src, title, at) {
7742
+ const existing = section.querySelector(`[data-ohw-section-embed="${CSS.escape(key)}"]`);
7743
+ const frame = existing?.querySelector("iframe");
7744
+ if (existing && frame) {
7745
+ if (frame.getAttribute("src") !== src) frame.setAttribute("src", src);
7746
+ frame.title = title;
7747
+ place(section, existing, at);
7748
+ return;
7749
+ }
7750
+ existing?.remove();
7751
+ const box = document.createElement("div");
7752
+ box.setAttribute("data-ohw-section-embed", key);
7753
+ box.style.cssText = at === "start" ? "width:100%;max-width:960px;margin:0 auto 32px;padding:32px 24px 0;box-sizing:border-box;" : "width:100%;max-width:960px;margin:32px auto 0;padding:0 24px 32px;box-sizing:border-box;";
7754
+ const frameWrap = document.createElement("div");
7755
+ frameWrap.style.cssText = "position:relative;width:100%;aspect-ratio:16/9;min-height:250px;border-radius:12px;overflow:hidden;background:#0f172a;";
7756
+ const iframe = document.createElement("iframe");
7757
+ iframe.src = src;
7758
+ iframe.title = title;
7759
+ iframe.style.cssText = "position:absolute;inset:0;width:100%;height:100%;border:0;";
7760
+ iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture";
7761
+ iframe.setAttribute("allowfullscreen", "");
7762
+ frameWrap.appendChild(iframe);
7763
+ box.appendChild(frameWrap);
7764
+ place(section, box, at);
7765
+ }
7766
+ function applySectionEmbeds(content) {
7767
+ for (const [key, val] of Object.entries(content)) {
7768
+ if (!key.endsWith(SECTION_EMBED_SUFFIX)) continue;
7769
+ const sectionId = key.slice(0, -SECTION_EMBED_SUFFIX.length);
7770
+ const section = document.querySelector(`[data-ohw-section="${CSS.escape(sectionId)}"]`);
7771
+ const stored = typeof val === "string" ? readStoredEmbed(val) : null;
7772
+ const frame = stored ? embedFrameSrc(stored.raw) : null;
7773
+ if (!section || !stored || !frame) {
7774
+ section?.querySelector(`[data-ohw-section-embed="${CSS.escape(key)}"]`)?.remove();
7775
+ continue;
7776
+ }
7777
+ paint(section, key, frame.src, frame.title, stored.at);
7778
+ }
7779
+ }
7780
+
7333
7781
  // src/ui/ai-tree/aiSectionsManager.tsx
7334
7782
  import { flushSync } from "react-dom";
7335
7783
  import { createRoot } from "react-dom/client";
@@ -7852,12 +8300,19 @@ function footerBodyStyle(fallbackFont, color, weight = 500) {
7852
8300
  }
7853
8301
  var str = (value) => typeof value === "string" ? value : "";
7854
8302
  var cardRadius = (slots) => slots.cornerStyle === "sharp" ? 0 : AI_TREE_TOKENS.radiusCard;
7855
- var blockAlignStyle = (blockAlign) => blockAlign ? {
7856
- display: "flex",
7857
- flexDirection: "column",
7858
- alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
7859
- textAlign: blockAlign
7860
- } : {};
8303
+ var HUG_ALIGN_TYPES = /* @__PURE__ */ new Set(["button", "button-row", "rating"]);
8304
+ var blockAlignStyle = (blockAlign, blockType) => {
8305
+ if (!blockAlign) return {};
8306
+ if (blockType && HUG_ALIGN_TYPES.has(blockType)) {
8307
+ return {
8308
+ display: "flex",
8309
+ flexDirection: "column",
8310
+ alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
8311
+ textAlign: blockAlign
8312
+ };
8313
+ }
8314
+ return { width: "100%", textAlign: blockAlign, boxSizing: "border-box" };
8315
+ };
7861
8316
  var fullBleedBlock = (block) => block.type === "carousel" || block.type === "group" && str(block.slots?.layout) === "overlap";
7862
8317
  var featureLines = (value) => value.split(/\n|<br\s*\/?>/i).map((line) => line.trim()).filter(Boolean);
7863
8318
  var AI_MOBILE_CSS = [
@@ -7903,7 +8358,7 @@ var AI_MOBILE_CSS = [
7903
8358
  // page's first section. Top only (bottom needs no nav clearance); ~96px approximates the
7904
8359
  // template nav's own height (measured ~94px) — there's no shared `--ohw-header-h` var to read
7905
8360
  // an exact figure from (no live measurement exists), so this is a safe approximation, not a
7906
- // pixel-exact fit. Horizontal spacing already comes from `data-ai-container`.
8361
+ // pixel-exact fit. Horizontal spacing already comes from `data-ai-section-inner`.
7907
8362
  '[data-ai-overlay-clearance] [data-ai-overlap-layer="overlay"]{padding-top:96px}',
7908
8363
  // A full-bleed carousel's height is pure arithmetic: it spans the whole window, so 16/9 turns
7909
8364
  // window width straight into height. Measured at 16/9 it came out ~90% of the viewport at EVERY
@@ -7919,8 +8374,10 @@ var AI_MOBILE_CSS = [
7919
8374
  "[data-ai-section]{overflow-x:hidden}",
7920
8375
  // `:not([data-ai-full-bleed])`: this `!important` gutter beat the inline `padding: 0` that a
7921
8376
  // full-bleed section's container sets, so a carousel/media hero that is edge-to-edge on desktop
7922
- // still got a 20px band of section background down both sides on a phone.
7923
- "[data-ai-container]:not([data-ai-full-bleed]){padding:0 20px !important}",
8377
+ // still got a 20px band of section background down both sides on a phone. The footer's own
8378
+ // container keeps the unguarded rule below — `data-ai-full-bleed` can never appear on it.
8379
+ "[data-ai-section-inner]:not([data-ai-full-bleed]){padding:0 20px !important}",
8380
+ "[data-ai-container]{padding:0 20px !important}",
7924
8381
  "[data-ai-row]{display:flex !important;flex-direction:column !important;align-items:stretch !important}",
7925
8382
  "[data-ai-cell]{width:100%;min-width:0}",
7926
8383
  // The rule above turns every row into a COLUMN flex container on phones, which silently breaks
@@ -8125,6 +8582,31 @@ function pricingCardEmphasis(featured, ctx, hasBg) {
8125
8582
  function textAttrs(ctx, path) {
8126
8583
  return ctx.keyFor ? { "data-ohw-key": ctx.keyFor(path), "data-ohw-editable": "text" } : {};
8127
8584
  }
8585
+ var AI_RESPONSIVE_CSS = [
8586
+ "@media (max-width: 960px) {",
8587
+ " [data-ai-responsive] [data-ai-grid] { grid-template-columns: repeat(2, 1fr) !important; }",
8588
+ ' [data-ai-responsive] [data-ai-grid="1"] { grid-template-columns: 1fr !important; }',
8589
+ "}",
8590
+ "@media (max-width: 640px) {",
8591
+ " [data-ai-responsive] [data-ai-grid] { grid-template-columns: 1fr !important; }",
8592
+ " [data-ai-responsive] [data-ai-columns] > * { grid-column: 1 / -1 !important; }",
8593
+ // Group containers flatten to a column on phones; span placements come along for free.
8594
+ // `:not([data-ai-group="overlap"])` for the same reason as the twin pair in AI_MOBILE_CSS — see
8595
+ // the comment there. This sheet's copy is the narrower selector, so without the exemption it
8596
+ // flattens an `overlap` hero below 640px even though the other rule stands down: measured a 390px
8597
+ // viewport with the heading/CTA in flow *under* the image, 219px of section background where the
8598
+ // layered text used to be.
8599
+ ' [data-ai-responsive] [data-ai-group]:not([data-ai-group="overlap"]) { display: flex !important; flex-direction: column !important; }',
8600
+ ' [data-ai-responsive] [data-ai-group]:not([data-ai-group="overlap"]) > * { grid-column: auto !important; }',
8601
+ // `:not([data-ai-full-bleed])` for the same reason as the twin rule in AI_MOBILE_CSS: this one
8602
+ // is narrower (0,2,0 vs 0,1,0) and also `!important`, so without the guard it wins outright and
8603
+ // a full-bleed hero gets its 20px side band back below 640px only — the one width where the
8604
+ // other rule had already been taught to stand down.
8605
+ " [data-ai-responsive] [data-ai-section-inner]:not([data-ai-full-bleed]) { padding-left: 20px !important; padding-right: 20px !important; }",
8606
+ " [data-ai-responsive] { overflow-x: hidden; }",
8607
+ " [data-ai-responsive] img { max-width: 100%; }",
8608
+ "}"
8609
+ ].join("\n");
8128
8610
  var TRANSPARENT_PX = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
8129
8611
  function MediaBox({
8130
8612
  refValue,
@@ -8179,7 +8661,7 @@ function MediaBox({
8179
8661
  position: fill ? "absolute" : void 0,
8180
8662
  inset: fill ? 0 : void 0,
8181
8663
  width: fill ? "100%" : fixedSize ? "auto" : "100%",
8182
- height: fill ? "100%" : void 0,
8664
+ height: fill ? "100%" : fixedSize ? height : void 0,
8183
8665
  aspectRatio: fill ? void 0 : aspectRatio,
8184
8666
  minHeight: fill || fixedSize ? void 0 : height ?? (aspectRatio ? void 0 : 180),
8185
8667
  borderRadius: radius,
@@ -8380,7 +8862,13 @@ function TextBlock({
8380
8862
  "div",
8381
8863
  {
8382
8864
  ...textAttrs(ctx, `${path}.content`),
8383
- style: { ...typeStyle(spec, font), color: ctx.brand.palette.dark, textAlign: align },
8865
+ style: {
8866
+ ...typeStyle(spec, font),
8867
+ color: ctx.brand.palette.dark,
8868
+ textAlign: align,
8869
+ width: "100%",
8870
+ boxSizing: "border-box"
8871
+ },
8384
8872
  dangerouslySetInnerHTML: { __html: str(slots.content) }
8385
8873
  }
8386
8874
  );
@@ -8391,7 +8879,7 @@ function SectionHeaderBlock({ node, ctx, path }) {
8391
8879
  const children = node.children ?? [];
8392
8880
  const buttonRowIdx = children.findIndex((c) => c.type === "button-row");
8393
8881
  const buttonRow = buttonRowIdx >= 0 ? children[buttonRowIdx] : void 0;
8394
- return /* @__PURE__ */ jsxs("div", { style: { textAlign: align }, children: [
8882
+ return /* @__PURE__ */ jsxs("div", { style: { textAlign: align, width: "100%", boxSizing: "border-box" }, children: [
8395
8883
  str(slots.tagline) && /* @__PURE__ */ jsx(
8396
8884
  "div",
8397
8885
  {
@@ -9675,7 +10163,7 @@ function CollectionBlock({ node, ctx, path }) {
9675
10163
  return /* @__PURE__ */ jsx(
9676
10164
  "div",
9677
10165
  {
9678
- "data-ai-grid": "",
10166
+ "data-ai-grid": String(itemsPerRow),
9679
10167
  "data-ohw-pricing-collection": isPricing ? "" : void 0,
9680
10168
  style: {
9681
10169
  display: "grid",
@@ -9977,7 +10465,7 @@ function renderNode(node, ctx, path, ambientAlign) {
9977
10465
  },
9978
10466
  children: [
9979
10467
  i > 0 && ctx.heroOverlapFullBleed ? (
9980
- // The section's `data-ai-container` gave up its max-width/gutter so the base
10468
+ // The section's `data-ai-section-inner` gave up its max-width/gutter so the base
9981
10469
  // layer (this group's i===0 sibling) can span edge-to-edge — reintroduced here,
9982
10470
  // scoped to just the overlay text, so a heading/copy/CTA stack doesn't stretch
9983
10471
  // the full section width instead of reading at the usual content width.
@@ -10010,10 +10498,10 @@ function renderNode(node, ctx, path, ambientAlign) {
10010
10498
  gridColumn: `span ${typeof child.span === "number" ? Math.min(12, Math.max(1, child.span)) : 12}`,
10011
10499
  minWidth: 0
10012
10500
  } : { minWidth: 0 },
10013
- // A child's own `align` (or the group's inherited `ambientAlign`, e.g. from an
10014
- // `overlap` overlay layer — see renderNode) positions it within this column; a stack
10015
- // child otherwise stretches full-width (unchanged pre-existing behaviour).
10016
- ...blockAlignStyle(child.align ?? ambientAlign)
10501
+ // Same ambient as renderNode below: child's own align, else the group's, else the
10502
+ // inherited ambient (overlap overlay / section). Copy fills the column; button-row
10503
+ // etc. still hug via flex alignItems.
10504
+ ...blockAlignStyle(child.align ?? node.align ?? ambientAlign, child.type)
10017
10505
  },
10018
10506
  children: renderNode(child, ctx, `${path}.c${i}`, node.align ?? ambientAlign)
10019
10507
  },
@@ -10382,12 +10870,7 @@ function AiTreeRenderer({
10382
10870
  if (fillHeight) return "stretch";
10383
10871
  return (distributed ?? settings.verticalPosition) === "top" ? "start" : "center";
10384
10872
  };
10385
- const cellAlignStyle = (blockAlign) => blockAlign ? {
10386
- display: "flex",
10387
- flexDirection: "column",
10388
- alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
10389
- textAlign: blockAlign
10390
- } : {};
10873
+ const cellAlignStyle = (blockAlign, blockType) => blockAlignStyle(blockAlign, blockType);
10391
10874
  const needsOverlayClearance = fillHeight && pad === 0;
10392
10875
  return /* @__PURE__ */ jsxs(
10393
10876
  "section",
@@ -10396,6 +10879,7 @@ function AiTreeRenderer({
10396
10879
  ...fillHeight ? { "data-ai-fill-height": "" } : {},
10397
10880
  ...needsOverlayClearance ? { "data-ai-overlay-clearance": "" } : {},
10398
10881
  ...bgAttrs,
10882
+ "data-ai-responsive": "",
10399
10883
  style: {
10400
10884
  position: "relative",
10401
10885
  padding: `${padCss} 0`,
@@ -10409,12 +10893,13 @@ function AiTreeRenderer({
10409
10893
  ...fillHeight ? { display: "grid" } : {}
10410
10894
  },
10411
10895
  children: [
10412
- isOverlay && backgroundUrl && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, background: `rgba(255,255,255,${overlayAlpha})` } }),
10896
+ /* @__PURE__ */ jsx("style", { children: AI_RESPONSIVE_CSS }),
10413
10897
  /* @__PURE__ */ jsx("style", { children: AI_MOBILE_CSS }),
10898
+ isOverlay && backgroundUrl && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, background: `rgba(255,255,255,${overlayAlpha})` } }),
10414
10899
  /* @__PURE__ */ jsx(
10415
10900
  "div",
10416
10901
  {
10417
- "data-ai-container": "",
10902
+ "data-ai-section-inner": "",
10418
10903
  ...fullBleedMedia ? { "data-ai-full-bleed": "" } : {},
10419
10904
  style: {
10420
10905
  position: "relative",
@@ -10431,7 +10916,7 @@ function AiTreeRenderer({
10431
10916
  children: tree.rows.map((row, r2) => /* @__PURE__ */ jsx(
10432
10917
  "div",
10433
10918
  {
10434
- "data-ai-row": "",
10919
+ "data-ai-columns": "",
10435
10920
  style: {
10436
10921
  display: "grid",
10437
10922
  gridTemplateColumns: "repeat(12, 1fr)",
@@ -10447,11 +10932,11 @@ function AiTreeRenderer({
10447
10932
  gridColumn: `span ${Math.min(12, Math.max(1, block.span))}`,
10448
10933
  minWidth: 0,
10449
10934
  // Cascades the section's min-height stretch (see `fillHeight` above) down to
10450
- // this cell; `cellAlignStyle` below overrides to `flex` when the block also has
10451
- // its own horizontal `align`, which takes priority for that block.
10935
+ // this cell; `cellAlignStyle` below overrides when the block also has its own
10936
+ // horizontal `align` (flex hug for buttons; width 100% for text).
10452
10937
  ...fillHeight ? { display: "grid" } : {},
10453
10938
  // Horizontal placement of the block's content within its column.
10454
- ...fullBleedBlock(block) ? {} : cellAlignStyle(block.align),
10939
+ ...fullBleedBlock(block) ? {} : cellAlignStyle(block.align, block.type),
10455
10940
  // space-between: each column becomes a flex column whose content spreads over
10456
10941
  // the full row height instead of clumping at the top.
10457
10942
  ...distributed === "space-between" ? { display: "flex", flexDirection: "column", justifyContent: "space-between" } : {}
@@ -11093,9 +11578,10 @@ function applyAiSectionsToDom(state, options) {
11093
11578
  if (existing && existing.serialized === serialized && existing.container.isConnected) {
11094
11579
  continue;
11095
11580
  }
11096
- const isNewMount = !existing || !existing.container.isConnected;
11097
11581
  let container = existing?.container;
11582
+ let isNewMount = false;
11098
11583
  if (!container || !container.isConnected) {
11584
+ isNewMount = true;
11099
11585
  existing?.root.unmount();
11100
11586
  container?.remove();
11101
11587
  container = document.createElement("div");
@@ -11175,7 +11661,7 @@ import { createRoot as createRoot2 } from "react-dom/client";
11175
11661
  import { flushSync as flushSync2 } from "react-dom";
11176
11662
  import { jsx as jsx3 } from "react/jsx-runtime";
11177
11663
  var CONTAINER_ATTR2 = "data-ohw-ai-footer";
11178
- var HIDDEN_ATTR = "data-ohw-ai-footer-replaced";
11664
+ var HIDDEN_ATTR2 = "data-ohw-ai-footer-replaced";
11179
11665
  var mounted2 = null;
11180
11666
  var mountOptions = {};
11181
11667
  var capturedSurface;
@@ -11205,12 +11691,12 @@ function findTemplateFooter() {
11205
11691
  function hideTemplateFooter(footer) {
11206
11692
  if (!footer) return;
11207
11693
  footer.style.display = "none";
11208
- footer.setAttribute(HIDDEN_ATTR, "");
11694
+ footer.setAttribute(HIDDEN_ATTR2, "");
11209
11695
  }
11210
11696
  function showTemplateFooter() {
11211
- for (const el of document.querySelectorAll(`[${HIDDEN_ATTR}]`)) {
11697
+ for (const el of document.querySelectorAll(`[${HIDDEN_ATTR2}]`)) {
11212
11698
  el.style.removeProperty("display");
11213
- el.removeAttribute(HIDDEN_ATTR);
11699
+ el.removeAttribute(HIDDEN_ATTR2);
11214
11700
  }
11215
11701
  }
11216
11702
  function unmountAiFooter() {
@@ -11405,7 +11891,7 @@ function pickFooterColumnIndex(columnBlockCounts) {
11405
11891
  }
11406
11892
 
11407
11893
  // src/lib/ai-footer-edits.ts
11408
- function cloneTree(tree) {
11894
+ function cloneTree2(tree) {
11409
11895
  return JSON.parse(JSON.stringify(tree));
11410
11896
  }
11411
11897
  function rebalanceFooterColumnSpans(columns) {
@@ -11433,6 +11919,34 @@ function minSpanForFooterBlock(type) {
11433
11919
  return 3;
11434
11920
  }
11435
11921
  }
11922
+ function readLiveSocialItems() {
11923
+ const root = getFooterRoot();
11924
+ const row = root?.querySelector("[data-ohw-socials-row]");
11925
+ if (!row) return [];
11926
+ const items = [];
11927
+ for (const anchor of Array.from(row.querySelectorAll("a[href]"))) {
11928
+ const href = anchor.getAttribute("href")?.trim() ?? "";
11929
+ const aria = anchor.getAttribute("aria-label")?.trim().toLowerCase() ?? "";
11930
+ const platform = FOOTER_SOCIAL_PLATFORMS.find((name) => aria === name) ?? FOOTER_SOCIAL_PLATFORMS.find((name) => href.toLowerCase().includes(name));
11931
+ if (!platform || !/^https?:\/\//i.test(href)) continue;
11932
+ items.push({ platform, href });
11933
+ }
11934
+ return items;
11935
+ }
11936
+ function syncSocialRowsFromDom(tree) {
11937
+ const root = getFooterRoot();
11938
+ if (!root) return;
11939
+ const row = root.querySelector("[data-ohw-socials-row]");
11940
+ const live = readLiveSocialItems();
11941
+ if (row && live.length === 0) return;
11942
+ for (const col of tree.columns) {
11943
+ col.blocks = col.blocks.flatMap((block) => {
11944
+ if (block.type !== "social-row") return [block];
11945
+ if (!row) return [];
11946
+ return [{ ...block, items: live.map((item) => ({ platform: item.platform, href: item.href })) }];
11947
+ });
11948
+ }
11949
+ }
11436
11950
  function collectBrandBlocks(tree) {
11437
11951
  const brand = [];
11438
11952
  for (const col of tree.columns) {
@@ -11455,7 +11969,7 @@ function countFooterLinkLists(tree) {
11455
11969
  return collectLinkListBlocks(tree).length;
11456
11970
  }
11457
11971
  function packFooterTreeBrand(tree) {
11458
- const next = cloneTree(tree);
11972
+ const next = cloneTree2(tree);
11459
11973
  const brand = collectBrandBlocks(next);
11460
11974
  const lists = collectLinkListBlocks(next);
11461
11975
  if (lists.length === 0) {
@@ -11540,7 +12054,7 @@ function ensureFooterTree(tree, opts) {
11540
12054
  return tree ?? buildDefaultFooterTree(opts);
11541
12055
  }
11542
12056
  function appendFooterSocial(tree, entry) {
11543
- const next = cloneTree(tree);
12057
+ const next = cloneTree2(tree);
11544
12058
  const platform = entry.platform.trim().toLowerCase();
11545
12059
  const href = entry.href.trim();
11546
12060
  for (const col2 of next.columns) {
@@ -11569,7 +12083,7 @@ function appendFooterSocial(tree, entry) {
11569
12083
  return next;
11570
12084
  }
11571
12085
  function insertFooterHours(tree, hours, title = "Hours") {
11572
- const next = cloneTree(tree);
12086
+ const next = cloneTree2(tree);
11573
12087
  const idx = pickFooterColumnIndex(next.columns.map((c) => c.blocks.length));
11574
12088
  const col = next.columns[idx] ?? next.columns[0];
11575
12089
  if (!col) return next;
@@ -11596,7 +12110,7 @@ function addFooterLinkColumn(tree, column) {
11596
12110
  return next;
11597
12111
  }
11598
12112
  function removeFooterBlock(tree, predicate) {
11599
- const next = cloneTree(tree);
12113
+ const next = cloneTree2(tree);
11600
12114
  for (let c = 0; c < next.columns.length; c++) {
11601
12115
  const col = next.columns[c];
11602
12116
  if (!col) continue;
@@ -11632,7 +12146,7 @@ function foldAiFooterSlotOverride(tree, key, value) {
11632
12146
  const path = key.slice(prefix.length);
11633
12147
  const brandMatch = path.match(/^brand\.b(\d+)\.(.+)$/);
11634
12148
  if (!brandMatch) return null;
11635
- const next = cloneTree(tree);
12149
+ const next = cloneTree2(tree);
11636
12150
  const brands = [];
11637
12151
  for (const col of next.columns) {
11638
12152
  for (const block2 of col.blocks) {
@@ -11677,7 +12191,8 @@ function textOf2(el) {
11677
12191
  return (el?.textContent ?? "").replace(/\s+/g, " ").trim();
11678
12192
  }
11679
12193
  function syncFooterTreeLinksFromDom(tree) {
11680
- const next = cloneTree(tree);
12194
+ const next = cloneTree2(tree);
12195
+ syncSocialRowsFromDom(next);
11681
12196
  const domCols = listFooterColumns().map((col) => {
11682
12197
  const heading = getFooterColumnHeadingEl(col);
11683
12198
  const title = heading ? textOf2(heading) : void 0;
@@ -12158,7 +12673,7 @@ var PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]-?/g;
12158
12673
  var HAS_PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]/;
12159
12674
  var SKIPPED_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "NOSCRIPT", "TEXTAREA", "CODE", "PRE"]);
12160
12675
  var TEXT_ATTRS = ["alt", "title", "aria-label", "placeholder"];
12161
- var HIDDEN_ATTR2 = "data-ohw-placeholder-hidden";
12676
+ var HIDDEN_ATTR3 = "data-ohw-placeholder-hidden";
12162
12677
  function hasPlaceholder(text) {
12163
12678
  return HAS_PLACEHOLDER_RE.test(text);
12164
12679
  }
@@ -12177,10 +12692,10 @@ function skipped(el) {
12177
12692
  }
12178
12693
  function hideIfEmptied(el) {
12179
12694
  const control = el?.closest("a, button");
12180
- if (!control || control.hasAttribute(HIDDEN_ATTR2)) return;
12695
+ if (!control || control.hasAttribute(HIDDEN_ATTR3)) return;
12181
12696
  if ((control.textContent ?? "").trim()) return;
12182
12697
  if (control.querySelector("img, svg, picture, video")) return;
12183
- control.setAttribute(HIDDEN_ATTR2, "");
12698
+ control.setAttribute(HIDDEN_ATTR3, "");
12184
12699
  control.style.display = "none";
12185
12700
  }
12186
12701
  function stripElementAttrs(el) {
@@ -17329,10 +17844,10 @@ function ItemInteractionLayer({
17329
17844
  }
17330
17845
 
17331
17846
  // src/lib/forms.ts
17332
- var FORM_SELECTOR = '[data-ohw-editable="form"]';
17847
+ var FORM_SELECTOR2 = '[data-ohw-editable="form"]';
17333
17848
  function getFormElement(el) {
17334
17849
  if (!el) return null;
17335
- return el.closest(FORM_SELECTOR);
17850
+ return el.closest(FORM_SELECTOR2);
17336
17851
  }
17337
17852
  function formKeyOf(form) {
17338
17853
  return form.getAttribute("data-ohw-key");
@@ -17393,7 +17908,7 @@ function clearSubmitError(form) {
17393
17908
  if (note) note.style.display = "none";
17394
17909
  }
17395
17910
  var SUCCESS_TEXT_ATTR = "data-ohw-form-success-text";
17396
- var HIDDEN_ATTR3 = "data-ohw-form-hidden";
17911
+ var HIDDEN_ATTR4 = "data-ohw-form-hidden";
17397
17912
  var DEFAULT_SUCCESS_TEXT = "Thanks! We'll be in touch.";
17398
17913
  function formSuccessKey(formKey) {
17399
17914
  return `${formKey}-success`;
@@ -17419,13 +17934,13 @@ function setFormViewState(form, formKey, state, initialText) {
17419
17934
  Array.from(form.children).forEach((child) => {
17420
17935
  if (!(child instanceof HTMLElement) || child === success) return;
17421
17936
  if (state === "success") {
17422
- if (!child.hasAttribute(HIDDEN_ATTR3)) {
17423
- child.setAttribute(HIDDEN_ATTR3, child.style.display);
17937
+ if (!child.hasAttribute(HIDDEN_ATTR4)) {
17938
+ child.setAttribute(HIDDEN_ATTR4, child.style.display);
17424
17939
  child.style.display = "none";
17425
17940
  }
17426
- } else if (child.hasAttribute(HIDDEN_ATTR3)) {
17427
- child.style.display = child.getAttribute(HIDDEN_ATTR3) ?? "";
17428
- child.removeAttribute(HIDDEN_ATTR3);
17941
+ } else if (child.hasAttribute(HIDDEN_ATTR4)) {
17942
+ child.style.display = child.getAttribute(HIDDEN_ATTR4) ?? "";
17943
+ child.removeAttribute(HIDDEN_ATTR4);
17429
17944
  }
17430
17945
  });
17431
17946
  success.style.display = state === "success" ? "" : "none";
@@ -17444,7 +17959,7 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
17444
17959
  "submit",
17445
17960
  async (e) => {
17446
17961
  const target = e.target;
17447
- const form = target?.closest(FORM_SELECTOR);
17962
+ const form = target?.closest(FORM_SELECTOR2);
17448
17963
  if (!form || !(form instanceof HTMLFormElement)) return;
17449
17964
  const formKey = formKeyOf(form);
17450
17965
  if (!formKey) return;
@@ -17490,7 +18005,7 @@ function apiBase() {
17490
18005
  function bridgeVersion() {
17491
18006
  try {
17492
18007
  if (true) {
17493
- return "0.1.169";
18008
+ return "0.1.170-next.454";
17494
18009
  }
17495
18010
  } catch {
17496
18011
  }
@@ -17504,7 +18019,7 @@ function stampBridgeVersionOnDocument() {
17504
18019
  return;
17505
18020
  }
17506
18021
  try {
17507
- const v = true ? "0.1.169" : "";
18022
+ const v = true ? "0.1.170-next.454" : "";
17508
18023
  if (v) {
17509
18024
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17510
18025
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -17665,7 +18180,9 @@ function isFieldRequired(wrapper) {
17665
18180
  function markFormFields(form) {
17666
18181
  form.querySelectorAll("input, textarea").forEach((input) => {
17667
18182
  const type = input.type;
17668
- if (type === "submit" || type === "button" || type === "reset" || type === "hidden") return;
18183
+ if (type === "submit" || type === "button" || type === "reset" || type === "hidden" || type === "checkbox" || type === "radio") {
18184
+ return;
18185
+ }
17669
18186
  if (getFieldWrapper(input)) return;
17670
18187
  let wrapper = input;
17671
18188
  while (wrapper.parentElement && wrapper.parentElement !== form && wrapper.parentElement.querySelectorAll("input, textarea").length === 1) {
@@ -18073,7 +18590,7 @@ function FieldTypePicker({ onPick }) {
18073
18590
 
18074
18591
  // src/ui/MediaOverlay.tsx
18075
18592
  import * as React8 from "react";
18076
- import { Film, ImageIcon, Pause, Play as Play2, Volume2, VolumeX } from "lucide-react";
18593
+ import { Film, ImageIcon, Pause, Play as Play2, Trash2 as Trash23, Volume2, VolumeX } from "lucide-react";
18077
18594
 
18078
18595
  // src/ui/button.tsx
18079
18596
  import * as React7 from "react";
@@ -18163,6 +18680,7 @@ function MediaOverlay({
18163
18680
  onFadeOutComplete,
18164
18681
  onReplace,
18165
18682
  onSelect,
18683
+ onDelete,
18166
18684
  onVideoSettingsChange
18167
18685
  }) {
18168
18686
  const { rect } = hover;
@@ -18182,6 +18700,7 @@ function MediaOverlay({
18182
18700
  (prev) => prev && prev.fullWidth === width && prev.height === height ? prev : { fullWidth: width, height }
18183
18701
  );
18184
18702
  }, [isVideo]);
18703
+ const replaceLabel = isVideo ? "Replace video" : hover.elementType === "bg-image" ? "Replace background" : "Replace image";
18185
18704
  const replaceMode = buttonSize ? replaceButtonMode({ width: rect.width, height: rect.height }, buttonSize) : "none";
18186
18705
  const box = {
18187
18706
  position: "fixed",
@@ -18280,11 +18799,10 @@ function MediaOverlay({
18280
18799
  className: "flex items-center justify-center cursor-pointer",
18281
18800
  style: {
18282
18801
  ...box,
18283
- // When text overlays this media, let clicks fall THROUGH to the text underneath. In the
18284
- // parent this needed a whole `ow:click-at` round-trip to re-hit-test inside the iframe;
18285
- // in-document, pointer-events does it natively. The button below opts back in, so
18286
- // Replace still works.
18287
- pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto",
18802
+ // Visual only. `pointer-events: auto` on this full-bleed rect covered the navbar
18803
+ // (hero bg includes the absolute TopNav) and swallowed CTA press-drag. Text overlay
18804
+ // and cueOnly also need clicks to fall through — Replace / video controls opt back in.
18805
+ pointerEvents: "none",
18288
18806
  // Selected: a firm component ring with no wash, so the image reads as chosen rather
18289
18807
  // than hovered. Hover keeps the existing tinted preview.
18290
18808
  boxShadow: selected ? "inset 0 0 0 2px var(--color-bridge-primary)" : "inset 0 0 0 1.5px var(--color-bridge-primary)",
@@ -18311,40 +18829,74 @@ function MediaOverlay({
18311
18829
  },
18312
18830
  children: [
18313
18831
  isVideo ? /* @__PURE__ */ jsx17(Film, { size: 14 }) : /* @__PURE__ */ jsx17(ImageIcon, { size: 14 }),
18314
- isVideo ? "Replace video" : "Replace image"
18832
+ replaceLabel
18315
18833
  ]
18316
18834
  }
18317
18835
  ),
18318
- replaceMode === "none" || cueOnly ? null : /* @__PURE__ */ jsxs8(
18319
- Button,
18836
+ showChrome && replaceMode !== "none" && /* @__PURE__ */ jsxs8(
18837
+ "div",
18320
18838
  {
18321
- "data-ohw-media-overlay": "",
18322
- variant: "outline",
18323
- size: "sm",
18324
- "aria-label": isVideo ? "Replace video" : "Replace image",
18325
- className: "gap-1.5 cursor-pointer hover:bg-background",
18839
+ className: "flex items-center gap-1.5",
18326
18840
  style: {
18327
- ...OVERLAY_BUTTON_STYLE,
18328
- // Icon-only is a square of the same height, so the pair can never differ vertically.
18329
- // `minWidth` has to go too: the button's own size carries `min-w-[64px]`, and a
18330
- // minimum beats a width — the square came out wider than the avatar it sat on.
18331
- ...replaceMode === "icon" && buttonSize ? {
18332
- width: buttonSize.height,
18333
- minWidth: buttonSize.height,
18334
- padding: 0,
18335
- justifyContent: "center"
18336
- } : null,
18337
- // Don't let Replace steal clicks when text (e.g. nav) sits on top of this media.
18841
+ // Parent overlay is pointer-events:none; controls opt back in (unless text sits on top).
18338
18842
  pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto"
18339
18843
  },
18340
- onMouseDown: (e) => e.preventDefault(),
18341
- onClick: (e) => {
18342
- e.stopPropagation();
18343
- onReplace(hover.key);
18344
- },
18844
+ onClick: (e) => e.stopPropagation(),
18345
18845
  children: [
18346
- isVideo ? /* @__PURE__ */ jsx17(Film, { size: 14 }) : /* @__PURE__ */ jsx17(ImageIcon, { size: 14 }),
18347
- replaceMode === "full" ? isVideo ? "Replace video" : hover.elementType === "bg-image" ? "Replace background" : "Replace image" : null
18846
+ /* @__PURE__ */ jsxs8(
18847
+ Button,
18848
+ {
18849
+ "data-ohw-media-overlay": "",
18850
+ variant: "outline",
18851
+ size: "sm",
18852
+ "aria-label": replaceLabel,
18853
+ className: "gap-1.5 cursor-pointer hover:bg-background",
18854
+ style: {
18855
+ ...OVERLAY_BUTTON_STYLE,
18856
+ // Icon-only is a square of the same height, so the pair can never differ vertically.
18857
+ // `minWidth` has to go too: the button's own size carries `min-w-[64px]`, and a
18858
+ // minimum beats a width — the square came out wider than the avatar it sat on.
18859
+ ...replaceMode === "icon" && buttonSize ? {
18860
+ width: buttonSize.height,
18861
+ minWidth: buttonSize.height,
18862
+ padding: 0,
18863
+ justifyContent: "center"
18864
+ } : null
18865
+ },
18866
+ onMouseDown: (e) => e.preventDefault(),
18867
+ onClick: (e) => {
18868
+ e.stopPropagation();
18869
+ onReplace(hover.key);
18870
+ },
18871
+ children: [
18872
+ isVideo ? /* @__PURE__ */ jsx17(Film, { size: 14 }) : /* @__PURE__ */ jsx17(ImageIcon, { size: 14 }),
18873
+ replaceMode === "full" ? replaceLabel : null
18874
+ ]
18875
+ }
18876
+ ),
18877
+ selected && onDelete ? /* @__PURE__ */ jsx17(
18878
+ Button,
18879
+ {
18880
+ "data-ohw-media-overlay": "",
18881
+ variant: "outline",
18882
+ size: "sm",
18883
+ "aria-label": "Delete",
18884
+ title: "Delete",
18885
+ className: "cursor-pointer hover:bg-background",
18886
+ style: {
18887
+ ...OVERLAY_BUTTON_STYLE,
18888
+ minWidth: 0,
18889
+ padding: buttonSize ? `0 ${(buttonSize.height - 14) / 2}px` : "0 8px",
18890
+ height: buttonSize?.height
18891
+ },
18892
+ onMouseDown: (e) => e.preventDefault(),
18893
+ onClick: (e) => {
18894
+ e.stopPropagation();
18895
+ onDelete(hover.key);
18896
+ },
18897
+ children: /* @__PURE__ */ jsx17(Trash23, { size: 14 })
18898
+ }
18899
+ ) : null
18348
18900
  ]
18349
18901
  }
18350
18902
  )
@@ -18492,7 +19044,7 @@ function highlightedRect() {
18492
19044
  const rect = first.getBoundingClientRect();
18493
19045
  return { top: rect.top + window.scrollY, bottom: rect.bottom + window.scrollY };
18494
19046
  }
18495
- function installAiChangeHighlight() {
19047
+ function installAiChangeHighlight(select) {
18496
19048
  const onMessage = (e) => {
18497
19049
  const data = e.data;
18498
19050
  if (data?.type !== "ow:ai-highlight") return;
@@ -18501,6 +19053,8 @@ function installAiChangeHighlight() {
18501
19053
  const item = raw && typeof raw.sectionId === "string" && typeof raw.group === "string" && typeof raw.index === "number" ? { sectionId: raw.sectionId, group: raw.group, index: raw.index } : void 0;
18502
19054
  const sectionId = typeof data.sectionId === "string" ? data.sectionId : void 0;
18503
19055
  const found = highlightChangedElements(keys, item, sectionId);
19056
+ const first = data.select === true ? document.querySelector(`[${MARK_ATTR}]`) : null;
19057
+ if (first) select?.(first);
18504
19058
  const rect = data.reveal === true && found > 0 ? highlightedRect() : null;
18505
19059
  window.parent?.postMessage({ type: "ow:ai-highlight-done", found, ...rect ? { rect } : {} }, "*");
18506
19060
  };
@@ -18508,6 +19062,28 @@ function installAiChangeHighlight() {
18508
19062
  return () => window.removeEventListener("message", onMessage);
18509
19063
  }
18510
19064
 
19065
+ // src/lib/history-key-relay.ts
19066
+ var isMac = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/i.test(navigator.platform || navigator.userAgent);
19067
+ function historyActionFor(e, mac = isMac()) {
19068
+ const mod = mac ? e.metaKey : e.ctrlKey;
19069
+ if (!mod || e.altKey) return null;
19070
+ const key = e.key.toLowerCase();
19071
+ if (key === "z") return e.shiftKey ? "redo" : "undo";
19072
+ if (key === "y" && !mac) return "redo";
19073
+ return null;
19074
+ }
19075
+ var isEditingText = (el) => !!el && (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLElement && el.isContentEditable);
19076
+ function installHistoryKeyRelay() {
19077
+ const onKeyDown = (e) => {
19078
+ const action = historyActionFor(e);
19079
+ if (!action || isEditingText(document.activeElement)) return;
19080
+ e.preventDefault();
19081
+ window.parent?.postMessage({ type: "ow:history-key", action }, "*");
19082
+ };
19083
+ window.addEventListener("keydown", onKeyDown);
19084
+ return () => window.removeEventListener("keydown", onKeyDown);
19085
+ }
19086
+
18511
19087
  // src/ui/ai-section/AiSectionOverlay.tsx
18512
19088
  import { Fragment as Fragment6, jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
18513
19089
  var findSectionElement = findByInstanceId;
@@ -18760,7 +19336,8 @@ function AiSectionOverlay({
18760
19336
  window.addEventListener("message", onMessage);
18761
19337
  return () => window.removeEventListener("message", onMessage);
18762
19338
  }, [postToParent2]);
18763
- useEffect8(() => installAiChangeHighlight(), []);
19339
+ useEffect8(() => installAiChangeHighlight((el) => selectFromElement(el)), [selectFromElement]);
19340
+ useEffect8(() => installHistoryKeyRelay(), []);
18764
19341
  const [hoveredId, setHoveredId] = useState7(null);
18765
19342
  useEffect8(() => {
18766
19343
  const onMove = (e) => {
@@ -18950,8 +19527,24 @@ function AiSectionOverlay({
18950
19527
  }
18951
19528
 
18952
19529
  // src/ui/ai-section/AiMediaStripOverlay.tsx
18953
- import { useCallback as useCallback3, useEffect as useEffect9, useRef as useRef5, useState as useState8 } from "react";
18954
- import { Star } from "lucide-react";
19530
+ import { useCallback as useCallback3, useEffect as useEffect9, useLayoutEffect as useLayoutEffect4, useRef as useRef5, useState as useState8 } from "react";
19531
+ import {
19532
+ AlignCenter,
19533
+ AlignLeft,
19534
+ AlignRight,
19535
+ ArrowLeft as ArrowLeft2,
19536
+ ArrowRight as ArrowRight2,
19537
+ Check as Check2,
19538
+ ChevronDown as ChevronDown3,
19539
+ Image as ImageIcon2,
19540
+ ImageMinus,
19541
+ ImagePlus,
19542
+ Link as LinkIcon,
19543
+ Minus,
19544
+ Palette,
19545
+ Plus as Plus2,
19546
+ Star
19547
+ } from "lucide-react";
18955
19548
 
18956
19549
  // src/lib/ai-media-strip-tree.ts
18957
19550
  var MEDIA_STRIP_ITEM_MIN = 1;
@@ -19065,14 +19658,6 @@ function setMediaStripItemAsset(tree, index, assetId) {
19065
19658
  return true;
19066
19659
  });
19067
19660
  }
19068
- function setMediaStripItemAlt(tree, index, alt) {
19069
- return withMediaStrip(tree, (block) => {
19070
- const items = block.items;
19071
- if (index < 0 || index >= items.length) return false;
19072
- items[index] = { ...items[index], alt };
19073
- return true;
19074
- });
19075
- }
19076
19661
  function setMediaStripItemLink(tree, index, link) {
19077
19662
  return withMediaStrip(tree, (block) => {
19078
19663
  const items = block.items;
@@ -19090,11 +19675,117 @@ function setMediaStripItemLink(tree, index, link) {
19090
19675
  });
19091
19676
  }
19092
19677
 
19678
+ // src/ui/dialog.tsx
19679
+ import * as React9 from "react";
19680
+ import { Dialog as DialogPrimitive } from "radix-ui";
19681
+ import { X as X2 } from "lucide-react";
19682
+ import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
19683
+ function Dialog2({
19684
+ ...props
19685
+ }) {
19686
+ return /* @__PURE__ */ jsx20(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
19687
+ }
19688
+ function DialogPortal({
19689
+ ...props
19690
+ }) {
19691
+ return /* @__PURE__ */ jsx20(DialogPrimitive.Portal, { ...props });
19692
+ }
19693
+ function DialogOverlay({
19694
+ className,
19695
+ ...props
19696
+ }) {
19697
+ return /* @__PURE__ */ jsx20(
19698
+ DialogPrimitive.Overlay,
19699
+ {
19700
+ "data-slot": "dialog-overlay",
19701
+ "data-ohw-link-modal-root": "",
19702
+ className: cn("fixed inset-0 z-[2147483646] bg-black/50", className),
19703
+ ...props
19704
+ }
19705
+ );
19706
+ }
19707
+ var DialogContent = React9.forwardRef(
19708
+ ({ className, children, showCloseButton = true, container, ...props }, ref) => {
19709
+ const positionMode = container ? "absolute" : "fixed";
19710
+ return /* @__PURE__ */ jsxs11(DialogPortal, { container: container ?? void 0, children: [
19711
+ /* @__PURE__ */ jsx20(DialogOverlay, { className: cn(positionMode, "inset-0") }),
19712
+ /* @__PURE__ */ jsxs11(
19713
+ DialogPrimitive.Content,
19714
+ {
19715
+ ref,
19716
+ "data-slot": "dialog-content",
19717
+ className: cn(
19718
+ positionMode,
19719
+ "left-1/2 top-1/2 z-[2147483647] flex w-full max-w-[448px] -translate-x-1/2 -translate-y-1/2 flex-col overflow-visible",
19720
+ "rounded-xl border border-border bg-background font-sans shadow-lg outline-none",
19721
+ container ? "max-h-[calc(100%-32px)]" : "max-h-[calc(100vh-32px)]",
19722
+ className
19723
+ ),
19724
+ onMouseDown: (e) => e.stopPropagation(),
19725
+ ...props,
19726
+ children: [
19727
+ children,
19728
+ showCloseButton ? /* @__PURE__ */ jsx20(
19729
+ DialogPrimitive.Close,
19730
+ {
19731
+ type: "button",
19732
+ className: "absolute right-[9px] top-[9px] rounded-sm p-1.5 text-foreground hover:bg-muted/50",
19733
+ "aria-label": "Close",
19734
+ children: /* @__PURE__ */ jsx20(X2, { size: 16, "aria-hidden": true })
19735
+ }
19736
+ ) : null
19737
+ ]
19738
+ }
19739
+ )
19740
+ ] });
19741
+ }
19742
+ );
19743
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
19744
+ function DialogHeader({
19745
+ className,
19746
+ ...props
19747
+ }) {
19748
+ return /* @__PURE__ */ jsx20("div", { className: cn("flex flex-col gap-1.5", className), ...props });
19749
+ }
19750
+ function DialogFooter({
19751
+ className,
19752
+ ...props
19753
+ }) {
19754
+ return /* @__PURE__ */ jsx20(
19755
+ "div",
19756
+ {
19757
+ className: cn("flex items-center justify-end gap-2", className),
19758
+ ...props
19759
+ }
19760
+ );
19761
+ }
19762
+ var DialogTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx20(
19763
+ DialogPrimitive.Title,
19764
+ {
19765
+ ref,
19766
+ className: cn(
19767
+ "text-lg font-semibold leading-none tracking-tight text-card-foreground",
19768
+ className
19769
+ ),
19770
+ ...props
19771
+ }
19772
+ ));
19773
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
19774
+ var DialogDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx20(
19775
+ DialogPrimitive.Description,
19776
+ {
19777
+ ref,
19778
+ className: cn("text-sm text-muted-foreground", className),
19779
+ ...props
19780
+ }
19781
+ ));
19782
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
19783
+ var DialogClose = DialogPrimitive.Close;
19784
+
19093
19785
  // src/ui/ai-section/AiMediaStripOverlay.tsx
19094
- import { Fragment as Fragment7, jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
19095
- var PRIMARY3 = "#0885FE";
19096
- var OHW_BLUE = `var(--ohw-primary, ${PRIMARY3})`;
19097
- var OHW_BLUE_DARK = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY3}) 60%, #000000)`;
19786
+ import { Fragment as Fragment7, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
19787
+ var PRIMARY3 = "var(--ohw-primary, #0885FE)";
19788
+ var CHROME_SELECTOR = "[data-ohw-toolbar], [data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-link-modal-root], [data-ohw-section-picker], [data-ohw-ai-review], [data-ohw-more-menu]";
19098
19789
  function findMediaStripItemElement(sectionId, index) {
19099
19790
  const sectionEl2 = findByInstanceId(sectionId);
19100
19791
  if (!sectionEl2) return null;
@@ -19104,14 +19795,35 @@ function findMediaStripItemElement(sectionId, index) {
19104
19795
  }
19105
19796
  return null;
19106
19797
  }
19107
- function readRect2(ref) {
19108
- const el = ref && findMediaStripItemElement(ref.sectionId, ref.index);
19798
+ function itemRefFromTarget(target) {
19799
+ if (!(target instanceof Element)) return null;
19800
+ if (target.closest(CHROME_SELECTOR)) return null;
19801
+ const itemEl = target.closest("[data-ohw-media-strip-item]");
19802
+ if (!itemEl) return null;
19803
+ const sectionEl2 = itemEl.closest("[data-ohw-section]");
19804
+ const unit = sectionEl2 ? movableUnit(sectionEl2) : null;
19805
+ const sectionId = unit ? instanceIdOf(unit) || null : null;
19806
+ const index = Number(itemEl.dataset.ohwMediaStripIndex);
19807
+ if (!sectionId || Number.isNaN(index)) return null;
19808
+ return { sectionId, index };
19809
+ }
19810
+ function sameRef(a, b) {
19811
+ return a?.sectionId === b?.sectionId && a?.index === b?.index;
19812
+ }
19813
+ function rectOf(el) {
19109
19814
  if (!el) return null;
19110
19815
  const r2 = el.getBoundingClientRect();
19111
19816
  if (r2.width <= 0 || r2.height <= 0) return null;
19112
19817
  return { top: r2.top, left: r2.left, width: r2.width, height: r2.height };
19113
19818
  }
19114
- function useLiveItemRect(ref) {
19819
+ function readRect2(ref) {
19820
+ return rectOf(ref && findMediaStripItemElement(ref.sectionId, ref.index));
19821
+ }
19822
+ function readStripRect(ref) {
19823
+ const item = ref && findMediaStripItemElement(ref.sectionId, ref.index);
19824
+ return rectOf(item?.closest("[data-ohw-media-strip]") ?? item);
19825
+ }
19826
+ function useLiveItemRect(ref, strip = false) {
19115
19827
  const [rect, setRect] = useState8(null);
19116
19828
  useEffect9(() => {
19117
19829
  if (!ref) {
@@ -19119,7 +19831,7 @@ function useLiveItemRect(ref) {
19119
19831
  return;
19120
19832
  }
19121
19833
  const update = () => {
19122
- const next = readRect2(ref);
19834
+ const next = strip ? readStripRect(ref) : readRect2(ref);
19123
19835
  setRect(
19124
19836
  (prev) => prev && next && prev.top === next.top && prev.left === next.left && prev.width === next.width && prev.height === next.height ? prev : next
19125
19837
  );
@@ -19134,9 +19846,49 @@ function useLiveItemRect(ref) {
19134
19846
  window.removeEventListener("resize", update);
19135
19847
  clearInterval(interval);
19136
19848
  };
19137
- }, [ref?.sectionId, ref?.index]);
19849
+ }, [ref?.sectionId, ref?.index, strip]);
19138
19850
  return rect;
19139
19851
  }
19852
+ var TOOLBAR_STRIP_GAP = 52;
19853
+ var TOOLBAR_STRIP_GAP_MOBILE = 42;
19854
+ var TOOLBAR_EDGE_MARGIN2 = 4;
19855
+ function StripToolbarSlot({ stripRect, children }) {
19856
+ const slotRef = useRef5(null);
19857
+ const [shift, setShift] = useState8(0);
19858
+ const centerX = stripRect.left + stripRect.width / 2;
19859
+ useLayoutEffect4(() => {
19860
+ const slot = slotRef.current;
19861
+ if (!slot) return;
19862
+ const clamp = () => {
19863
+ const w = slot.offsetWidth;
19864
+ if (w <= 0) return;
19865
+ const half = w / 2;
19866
+ const clamped = Math.max(TOOLBAR_EDGE_MARGIN2 + half, Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN2 - half));
19867
+ setShift((prev) => Math.abs(prev - (clamped - centerX)) < 0.5 ? prev : clamped - centerX);
19868
+ };
19869
+ clamp();
19870
+ const ro = new ResizeObserver(clamp);
19871
+ ro.observe(slot);
19872
+ return () => ro.disconnect();
19873
+ }, [centerX, children]);
19874
+ const mobile = window.innerWidth <= 480;
19875
+ return /* @__PURE__ */ jsx21(
19876
+ "div",
19877
+ {
19878
+ ref: slotRef,
19879
+ "data-ohw-bridge": "",
19880
+ "data-ohw-item-interaction": "",
19881
+ className: "pointer-events-auto fixed",
19882
+ style: {
19883
+ top: stripRect.top - (mobile ? TOOLBAR_STRIP_GAP_MOBILE : TOOLBAR_STRIP_GAP),
19884
+ left: centerX + shift,
19885
+ transform: "translate(-50%, -100%)",
19886
+ zIndex: 2147483645
19887
+ },
19888
+ children
19889
+ }
19890
+ );
19891
+ }
19140
19892
  function requestValidateTree(postToParent2, tree) {
19141
19893
  return new Promise((resolve) => {
19142
19894
  const id = `ai-validate-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
@@ -19173,116 +19925,72 @@ function requestAssetPick(postToParent2) {
19173
19925
  postToParent2({ type: "ow:asset-pick", id });
19174
19926
  });
19175
19927
  }
19176
- function Pill({
19928
+ function ToolbarAction({
19177
19929
  label,
19178
19930
  onClick,
19179
- disabled,
19180
- active
19931
+ disabled = false,
19932
+ active = false,
19933
+ children
19181
19934
  }) {
19182
- return /* @__PURE__ */ jsx20(
19183
- "button",
19184
- {
19185
- type: "button",
19186
- onClick,
19187
- disabled,
19188
- style: {
19189
- height: 28,
19190
- padding: "0 10px",
19191
- display: "inline-flex",
19192
- alignItems: "center",
19193
- gap: 4,
19194
- borderRadius: 999,
19195
- border: "none",
19196
- cursor: disabled ? "default" : "pointer",
19197
- background: active ? OHW_BLUE_DARK : "#ffffff",
19198
- color: active ? "#ffffff" : OHW_BLUE_DARK,
19199
- opacity: disabled ? 0.4 : 1,
19200
- fontSize: 12,
19201
- lineHeight: "16px",
19202
- fontFamily: "Figtree, ui-sans-serif, system-ui, sans-serif",
19203
- whiteSpace: "nowrap",
19204
- flex: "0 0 auto"
19205
- },
19206
- children: label
19207
- }
19208
- );
19935
+ const button = /* @__PURE__ */ jsx21(CustomToolbarButton, { type: "button", "aria-label": label, disabled, active, onClick, className: "size-8", children });
19936
+ return /* @__PURE__ */ jsxs12(Tooltip, { children: [
19937
+ /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: disabled ? /* @__PURE__ */ jsx21("span", { className: "inline-flex", children: button }) : button }),
19938
+ /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: label })
19939
+ ] });
19209
19940
  }
19210
- function AltInput({ value, onCommit }) {
19211
- const [draft, setDraft] = useState8(value);
19212
- useEffect9(() => setDraft(value), [value]);
19213
- return /* @__PURE__ */ jsxs11(
19214
- "div",
19215
- {
19216
- style: {
19217
- display: "flex",
19218
- alignItems: "center",
19219
- gap: 6,
19220
- height: 28,
19221
- padding: "0 12px",
19222
- borderRadius: 999,
19223
- background: "#ffffff",
19224
- width: "100%",
19225
- maxWidth: 260,
19226
- boxSizing: "border-box"
19227
- },
19228
- children: [
19229
- /* @__PURE__ */ jsx20(
19230
- "span",
19231
- {
19232
- style: {
19233
- flex: "0 0 auto",
19234
- color: OHW_BLUE_DARK,
19235
- fontSize: 10,
19236
- fontWeight: 700,
19237
- textTransform: "uppercase",
19238
- letterSpacing: 0.4
19239
- },
19240
- children: "Alt"
19241
- }
19242
- ),
19243
- /* @__PURE__ */ jsx20(
19244
- "input",
19941
+ function ToolbarSeparator() {
19942
+ return /* @__PURE__ */ jsx21("span", { "aria-hidden": true, className: "mx-0.5 block h-6 w-px shrink-0 bg-border" });
19943
+ }
19944
+ function OptionMenu({
19945
+ label,
19946
+ value,
19947
+ options,
19948
+ onChange
19949
+ }) {
19950
+ const current = options.find((o) => o.value === value) ?? options[0];
19951
+ return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
19952
+ /* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground", children: label }),
19953
+ /* @__PURE__ */ jsxs12(DropdownMenu, { modal: false, children: [
19954
+ /* @__PURE__ */ jsx21(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs12(
19955
+ "button",
19956
+ {
19957
+ type: "button",
19958
+ "aria-label": label,
19959
+ className: "inline-flex h-8 min-w-[76px] items-center gap-[7px] rounded-[6px] bg-transparent px-2 text-[13px] font-medium text-foreground transition-colors hover:bg-muted data-[state=open]:bg-muted",
19960
+ children: [
19961
+ /* @__PURE__ */ jsx21("span", { className: "flex-1 text-left", children: current.label }),
19962
+ /* @__PURE__ */ jsx21(ChevronDown3, { size: 16, style: { pointerEvents: "none" } })
19963
+ ]
19964
+ }
19965
+ ) }),
19966
+ /* @__PURE__ */ jsx21(DropdownMenuContent, { align: "end", sideOffset: 8, className: "w-[132px] min-w-[132px] p-1", children: options.map((option) => {
19967
+ const selected = option.value === value;
19968
+ return /* @__PURE__ */ jsxs12(
19969
+ DropdownMenuItem,
19245
19970
  {
19246
- type: "text",
19247
- value: draft,
19248
- onChange: (e) => setDraft(e.target.value),
19249
- onBlur: () => {
19250
- if (draft !== value) onCommit(draft);
19251
- },
19252
- onKeyDown: (e) => {
19253
- if (e.key === "Enter") e.currentTarget.blur();
19254
- if (e.key === "Escape") {
19255
- setDraft(value);
19256
- e.currentTarget.blur();
19257
- }
19258
- },
19259
- placeholder: "Describe this image",
19260
- "aria-label": "Image alt text",
19261
- style: {
19262
- flex: 1,
19263
- minWidth: 0,
19264
- border: "none",
19265
- outline: "none",
19266
- background: "transparent",
19267
- fontSize: 12,
19268
- lineHeight: "16px",
19269
- fontFamily: "Figtree, ui-sans-serif, system-ui, sans-serif",
19270
- color: "#1f2937"
19271
- }
19272
- }
19273
- )
19274
- ]
19275
- }
19276
- );
19971
+ role: "menuitemradio",
19972
+ "aria-checked": selected,
19973
+ onSelect: () => onChange(option.value),
19974
+ className: cn("grid grid-cols-[1fr_16px] gap-2 py-2 pl-2 pr-2 text-[13px]", selected && "bg-muted"),
19975
+ children: [
19976
+ /* @__PURE__ */ jsx21("span", { children: option.label }),
19977
+ selected && /* @__PURE__ */ jsx21(Check2, { size: 16, className: "text-bridge-primary" })
19978
+ ]
19979
+ },
19980
+ option.value
19981
+ );
19982
+ }) })
19983
+ ] })
19984
+ ] });
19277
19985
  }
19278
19986
  var VARIANTS = [
19279
19987
  { value: "logos", label: "Logos" },
19280
19988
  { value: "reel", label: "Reel" }
19281
19989
  ];
19282
19990
  var ALIGNS = [
19283
- { value: "left", label: "Left" },
19284
- { value: "center", label: "Center" },
19285
- { value: "right", label: "Right" }
19991
+ { value: "left", label: "Align left", Icon: AlignLeft },
19992
+ { value: "center", label: "Align center", Icon: AlignCenter },
19993
+ { value: "right", label: "Align right", Icon: AlignRight }
19286
19994
  ];
19287
19995
  var HOVERS = [
19288
19996
  { value: "none", label: "None" },
@@ -19290,104 +19998,104 @@ var HOVERS = [
19290
19998
  { value: "zoom", label: "Zoom" },
19291
19999
  { value: "fade", label: "Fade" }
19292
20000
  ];
19293
- var TREATMENTS = [
19294
- { value: "color", label: "Color" },
19295
- { value: "grayscale", label: "Grayscale" }
19296
- ];
19297
20001
  var HTTP_URL_RE = /^https?:\/\/\S+$/i;
19298
- function LinkInput({ value, onCommit }) {
19299
- const [draft, setDraft] = useState8(value);
20002
+ function LinkModal({
20003
+ href,
20004
+ linkTarget,
20005
+ onClose,
20006
+ onSave
20007
+ }) {
20008
+ const [draft, setDraft] = useState8(href);
20009
+ const [newTab, setNewTab] = useState8(linkTarget !== "same-tab");
19300
20010
  const [invalid, setInvalid] = useState8(false);
19301
- useEffect9(() => {
19302
- setDraft(value);
19303
- setInvalid(false);
19304
- }, [value]);
19305
- const commit2 = () => {
20011
+ const save = () => {
19306
20012
  const next = draft.trim();
19307
- if (next === value) return setInvalid(false);
19308
- if (next && !HTTP_URL_RE.test(next)) return setInvalid(true);
19309
- setInvalid(false);
19310
- onCommit(next);
19311
- };
19312
- return /* @__PURE__ */ jsxs11(
19313
- "div",
19314
- {
19315
- style: {
19316
- display: "flex",
19317
- alignItems: "center",
19318
- gap: 6,
19319
- height: 28,
19320
- padding: "0 12px",
19321
- borderRadius: 999,
19322
- background: "#ffffff",
19323
- width: "100%",
19324
- maxWidth: 260,
19325
- boxSizing: "border-box",
19326
- boxShadow: invalid ? "inset 0 0 0 1.5px #EF4444" : "none"
19327
- },
19328
- children: [
19329
- /* @__PURE__ */ jsx20(
19330
- "span",
19331
- {
19332
- style: {
19333
- flex: "0 0 auto",
19334
- color: OHW_BLUE_DARK,
19335
- fontSize: 10,
19336
- fontWeight: 700,
19337
- textTransform: "uppercase",
19338
- letterSpacing: 0.4
19339
- },
19340
- children: "Link"
19341
- }
19342
- ),
19343
- /* @__PURE__ */ jsx20(
19344
- "input",
19345
- {
19346
- type: "text",
19347
- inputMode: "url",
19348
- value: draft,
19349
- onChange: (e) => setDraft(e.target.value),
19350
- onBlur: commit2,
19351
- onKeyDown: (e) => {
19352
- if (e.key === "Enter") e.currentTarget.blur();
19353
- if (e.key === "Escape") {
19354
- setDraft(value);
19355
- setInvalid(false);
19356
- e.currentTarget.blur();
19357
- }
19358
- },
19359
- placeholder: "https://example.com",
19360
- "aria-label": "Image link URL",
19361
- "aria-invalid": invalid,
19362
- style: {
19363
- flex: 1,
19364
- minWidth: 0,
19365
- border: "none",
19366
- outline: "none",
19367
- background: "transparent",
19368
- fontSize: 12,
19369
- lineHeight: "16px",
19370
- fontFamily: "Figtree, ui-sans-serif, system-ui, sans-serif",
19371
- color: "#1f2937"
19372
- }
19373
- }
19374
- )
19375
- ]
20013
+ if (next && !HTTP_URL_RE.test(next)) {
20014
+ setInvalid(true);
20015
+ return;
19376
20016
  }
19377
- );
20017
+ onSave(next, newTab ? "new-tab" : "same-tab");
20018
+ onClose();
20019
+ };
20020
+ return /* @__PURE__ */ jsx21(Dialog2, { open: true, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs12(DialogContent, { "data-ohw-link-modal-root": "", className: "max-w-[400px] gap-4 p-5", children: [
20021
+ /* @__PURE__ */ jsx21(DialogHeader, { children: /* @__PURE__ */ jsx21(DialogTitle, { className: "text-base", children: "Image link" }) }),
20022
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-3", children: [
20023
+ /* @__PURE__ */ jsx21(
20024
+ "input",
20025
+ {
20026
+ autoFocus: true,
20027
+ type: "text",
20028
+ inputMode: "url",
20029
+ value: draft,
20030
+ onChange: (e) => {
20031
+ setDraft(e.target.value);
20032
+ setInvalid(false);
20033
+ },
20034
+ onKeyDown: (e) => {
20035
+ if (e.key === "Enter") save();
20036
+ },
20037
+ placeholder: "https://example.com",
20038
+ "aria-label": "Image link URL",
20039
+ "aria-invalid": invalid,
20040
+ className: cn(
20041
+ "h-9 w-full rounded-[6px] border border-border bg-background px-3 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/70 focus:border-bridge-primary",
20042
+ invalid && "border-destructive focus:border-destructive"
20043
+ )
20044
+ }
20045
+ ),
20046
+ invalid && /* @__PURE__ */ jsx21("p", { className: "text-xs text-destructive", children: "Enter a full URL starting with http:// or https://" }),
20047
+ /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-2 text-[13px] text-foreground", children: [
20048
+ /* @__PURE__ */ jsx21("input", { type: "checkbox", checked: newTab, onChange: (e) => setNewTab(e.target.checked) }),
20049
+ "Open in new tab"
20050
+ ] })
20051
+ ] }),
20052
+ /* @__PURE__ */ jsxs12(DialogFooter, { children: [
20053
+ href && /* @__PURE__ */ jsx21(
20054
+ "button",
20055
+ {
20056
+ type: "button",
20057
+ onClick: () => {
20058
+ onSave("", "new-tab");
20059
+ onClose();
20060
+ },
20061
+ className: "mr-auto rounded-[6px] px-3 py-2 text-[13px] font-medium text-destructive transition-colors hover:bg-muted",
20062
+ children: "Remove link"
20063
+ }
20064
+ ),
20065
+ /* @__PURE__ */ jsx21(
20066
+ "button",
20067
+ {
20068
+ type: "button",
20069
+ onClick: onClose,
20070
+ className: "rounded-[6px] px-3 py-2 text-[13px] font-medium text-foreground transition-colors hover:bg-muted",
20071
+ children: "Cancel"
20072
+ }
20073
+ ),
20074
+ /* @__PURE__ */ jsx21(
20075
+ "button",
20076
+ {
20077
+ type: "button",
20078
+ onClick: save,
20079
+ className: "rounded-[6px] bg-bridge-primary px-3 py-2 text-[13px] font-medium text-primary-foreground transition-opacity hover:opacity-90",
20080
+ children: "Save"
20081
+ }
20082
+ )
20083
+ ] })
20084
+ ] }) });
19378
20085
  }
19379
20086
  function MediaStripToolbar({
19380
20087
  entry,
19381
20088
  index,
19382
20089
  pending,
19383
20090
  error,
20091
+ itemEditOn,
20092
+ onToggleItemEdit,
19384
20093
  onSetVariant,
19385
20094
  onSetAlign,
19386
20095
  onSetHover,
19387
20096
  onSetTreatment,
19388
20097
  onResize,
19389
- onSetAlt,
19390
- onSetLink,
20098
+ onOpenLink,
19391
20099
  onAddItem,
19392
20100
  onRemoveItem,
19393
20101
  onChangeImage,
@@ -19396,81 +20104,102 @@ function MediaStripToolbar({
19396
20104
  }) {
19397
20105
  const items = mediaStripItems(entry.tree);
19398
20106
  const itemCount = items.length;
19399
- const currentAlt = items[index]?.alt ?? "";
19400
- const currentHref2 = items[index]?.href ?? "";
19401
- const currentTarget = items[index]?.linkTarget === "same-tab" ? "same-tab" : "new-tab";
19402
20107
  const slots = findMediaStripSlots(entry.tree);
19403
20108
  const variant = slots?.variant === "reel" ? "reel" : "logos";
19404
20109
  const align = slots?.align === "left" || slots?.align === "right" ? slots.align : "center";
19405
20110
  const hover = slots?.hover === "none" || slots?.hover === "lift" || slots?.hover === "zoom" || slots?.hover === "fade" ? slots.hover : "lift";
19406
20111
  const treatment = slots?.treatment === "color" || slots?.treatment === "grayscale" ? slots.treatment : variant === "logos" ? "grayscale" : "color";
19407
20112
  const sizeValue = variant === "logos" ? typeof slots?.logoMaxHeight === "number" ? slots.logoMaxHeight : 48 : typeof slots?.cardWidth === "number" ? slots.cardWidth : 240;
19408
- const isMobile = window.innerWidth <= 480;
19409
- const rowStyle = isMobile ? {
19410
- display: "flex",
19411
- gap: 6,
19412
- flexWrap: "nowrap",
19413
- justifyContent: "center",
19414
- overflowX: "auto",
19415
- WebkitOverflowScrolling: "touch",
19416
- width: "100%",
19417
- scrollbarWidth: "none"
19418
- } : { display: "flex", gap: 6, flexWrap: "nowrap", justifyContent: "center" };
19419
- return /* @__PURE__ */ jsxs11(
20113
+ const mobile = window.innerWidth <= 480;
20114
+ const gatedLabel = (label) => itemEditOn ? label : "Turn on the star to edit this image";
20115
+ return /* @__PURE__ */ jsx21(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs12(
19420
20116
  "div",
19421
20117
  {
19422
20118
  "data-ohw-bridge": "",
19423
20119
  "data-ohw-toolbar": "",
19424
20120
  onMouseDown: (e) => e.stopPropagation(),
19425
- style: {
19426
- display: "flex",
19427
- flexDirection: "column",
19428
- gap: 6,
19429
- alignItems: "center",
19430
- background: OHW_BLUE,
19431
- padding: 8,
19432
- borderRadius: 12,
19433
- boxShadow: "0 8px 24px rgba(0,0,0,0.25)",
19434
- pointerEvents: pending ? "none" : "auto",
19435
- opacity: pending ? 0.6 : 1,
19436
- maxWidth: isMobile ? "calc(100vw - 24px)" : "none"
19437
- },
20121
+ className: cn("flex flex-col items-center gap-1.5 font-sans", pending && "pointer-events-none opacity-60"),
20122
+ style: { maxWidth: mobile ? "calc(100vw - 24px)" : void 0 },
19438
20123
  children: [
19439
- /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
19440
- VARIANTS.map((v) => /* @__PURE__ */ jsx20(Pill, { label: v.label, active: variant === v.value, onClick: () => onSetVariant(v.value) }, v.value)),
19441
- ALIGNS.map((a) => /* @__PURE__ */ jsx20(Pill, { label: a.label, active: align === a.value, onClick: () => onSetAlign(a.value) }, a.value))
19442
- ] }),
19443
- /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
19444
- HOVERS.map((h) => /* @__PURE__ */ jsx20(Pill, { label: h.label, active: hover === h.value, onClick: () => onSetHover(h.value) }, h.value)),
19445
- TREATMENTS.map((t) => /* @__PURE__ */ jsx20(Pill, { label: t.label, active: treatment === t.value, onClick: () => onSetTreatment(t.value) }, t.value))
19446
- ] }),
19447
- /* @__PURE__ */ jsxs11("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
19448
- /* @__PURE__ */ jsx20(Pill, { label: "\u2212", onClick: () => onResize(-8) }),
19449
- /* @__PURE__ */ jsxs11("span", { style: { color: "#ffffff", fontSize: 12, minWidth: 34, textAlign: "center" }, children: [
19450
- sizeValue,
19451
- "px"
19452
- ] }),
19453
- /* @__PURE__ */ jsx20(Pill, { label: "+", onClick: () => onResize(8) })
19454
- ] }),
19455
- /* @__PURE__ */ jsx20("div", { style: { display: "flex", justifyContent: "center", width: "100%" }, children: /* @__PURE__ */ jsx20(AltInput, { value: currentAlt, onCommit: onSetAlt }) }),
19456
- /* @__PURE__ */ jsx20("div", { style: { display: "flex", justifyContent: "center", width: "100%" }, children: /* @__PURE__ */ jsx20(LinkInput, { value: currentHref2, onCommit: (href) => onSetLink(href, currentTarget) }) }),
19457
- currentHref2 && /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
19458
- /* @__PURE__ */ jsx20(Pill, { label: "New tab", active: currentTarget === "new-tab", onClick: () => onSetLink(currentHref2, "new-tab") }),
19459
- /* @__PURE__ */ jsx20(Pill, { label: "Same tab", active: currentTarget === "same-tab", onClick: () => onSetLink(currentHref2, "same-tab") })
19460
- ] }),
19461
- /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
19462
- /* @__PURE__ */ jsx20(Pill, { label: "Change Image", onClick: onChangeImage }),
19463
- /* @__PURE__ */ jsx20(Pill, { label: "+ Item", onClick: onAddItem }),
19464
- /* @__PURE__ */ jsx20(Pill, { label: "\u2212 Item", onClick: onRemoveItem, disabled: itemCount <= 1 })
19465
- ] }),
19466
- /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
19467
- /* @__PURE__ */ jsx20(Pill, { label: "\u2190 Move", onClick: onMoveLeft, disabled: index <= 0 }),
19468
- /* @__PURE__ */ jsx20(Pill, { label: "\u2192 Move", onClick: onMoveRight, disabled: index >= itemCount - 1 })
19469
- ] }),
19470
- error && /* @__PURE__ */ jsx20("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
20124
+ /* @__PURE__ */ jsxs12(
20125
+ "div",
20126
+ {
20127
+ className: cn(
20128
+ "flex items-center gap-1 rounded-[10px] border border-border bg-background p-1 whitespace-nowrap",
20129
+ "shadow-[0px_10px_15px_-3px_rgba(0,0,0,0.1),0px_4px_6px_-4px_rgba(0,0,0,0.1)]",
20130
+ mobile ? "flex-wrap justify-center" : "flex-nowrap"
20131
+ ),
20132
+ children: [
20133
+ /* @__PURE__ */ jsxs12(Tooltip, { children: [
20134
+ /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(
20135
+ CustomToolbarButton,
20136
+ {
20137
+ type: "button",
20138
+ "aria-label": itemEditOn ? "Done editing this image" : "Edit this image",
20139
+ "aria-pressed": itemEditOn,
20140
+ onClick: onToggleItemEdit,
20141
+ className: "group size-8",
20142
+ children: /* @__PURE__ */ jsx21(
20143
+ Star,
20144
+ {
20145
+ size: 16,
20146
+ fill: "currentColor",
20147
+ strokeWidth: 0,
20148
+ className: cn(
20149
+ "transition-colors",
20150
+ itemEditOn ? "text-[#f59e0b] group-hover:text-[#d97706]" : "text-[#d6d3d1] group-hover:text-[#fbbf24]"
20151
+ ),
20152
+ style: { pointerEvents: "none" }
20153
+ }
20154
+ )
20155
+ }
20156
+ ) }),
20157
+ /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: itemEditOn ? "Done editing this image" : "Edit this image" })
20158
+ ] }),
20159
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20160
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: gatedLabel("Change image"), onClick: onChangeImage, disabled: !itemEditOn, children: /* @__PURE__ */ jsx21(ImageIcon2, { size: 16, style: { pointerEvents: "none" } }) }),
20161
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: gatedLabel("Link"), onClick: onOpenLink, disabled: !itemEditOn, children: /* @__PURE__ */ jsx21(LinkIcon, { size: 16, style: { pointerEvents: "none" } }) }),
20162
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: gatedLabel("Move left"), onClick: onMoveLeft, disabled: !itemEditOn || index <= 0, children: /* @__PURE__ */ jsx21(ArrowLeft2, { size: 16, style: { pointerEvents: "none" } }) }),
20163
+ /* @__PURE__ */ jsx21(
20164
+ ToolbarAction,
20165
+ {
20166
+ label: gatedLabel("Move right"),
20167
+ onClick: onMoveRight,
20168
+ disabled: !itemEditOn || index >= itemCount - 1,
20169
+ children: /* @__PURE__ */ jsx21(ArrowRight2, { size: 16, style: { pointerEvents: "none" } })
20170
+ }
20171
+ ),
20172
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: gatedLabel("Remove image"), onClick: onRemoveItem, disabled: !itemEditOn || itemCount <= 1, children: /* @__PURE__ */ jsx21(ImageMinus, { size: 16, style: { pointerEvents: "none" } }) }),
20173
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20174
+ /* @__PURE__ */ jsx21(OptionMenu, { label: "Layout", value: variant, options: VARIANTS, onChange: onSetVariant }),
20175
+ /* @__PURE__ */ jsx21(OptionMenu, { label: "Hover", value: hover, options: HOVERS, onChange: onSetHover }),
20176
+ /* @__PURE__ */ jsx21(
20177
+ ToolbarAction,
20178
+ {
20179
+ label: treatment === "grayscale" ? "Show in color" : "Show grayscale",
20180
+ active: treatment === "grayscale",
20181
+ onClick: () => onSetTreatment(treatment === "grayscale" ? "color" : "grayscale"),
20182
+ children: /* @__PURE__ */ jsx21(Palette, { size: 16, style: { pointerEvents: "none" } })
20183
+ }
20184
+ ),
20185
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20186
+ ALIGNS.map(({ value, label, Icon }) => /* @__PURE__ */ jsx21(ToolbarAction, { label, active: align === value, onClick: () => onSetAlign(value), children: /* @__PURE__ */ jsx21(Icon, { size: 16, style: { pointerEvents: "none" } }) }, value)),
20187
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20188
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: "Smaller", onClick: () => onResize(-8), children: /* @__PURE__ */ jsx21(Minus, { size: 16, style: { pointerEvents: "none" } }) }),
20189
+ /* @__PURE__ */ jsxs12("span", { className: "min-w-[40px] text-center text-xs tabular-nums text-muted-foreground", children: [
20190
+ sizeValue,
20191
+ "px"
20192
+ ] }),
20193
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: "Larger", onClick: () => onResize(8), children: /* @__PURE__ */ jsx21(Plus2, { size: 16, style: { pointerEvents: "none" } }) }),
20194
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20195
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: "Add image", onClick: onAddItem, children: /* @__PURE__ */ jsx21(ImagePlus, { size: 16, style: { pointerEvents: "none" } }) })
20196
+ ]
20197
+ }
20198
+ ),
20199
+ error && /* @__PURE__ */ jsx21("div", { className: "max-w-[260px] rounded-md bg-background px-2 py-1 text-center text-[11px] text-destructive shadow-sm", children: error })
19471
20200
  ]
19472
20201
  }
19473
- );
20202
+ ) });
19474
20203
  }
19475
20204
  function findMediaStripSlots(tree) {
19476
20205
  const stack = tree.rows.flatMap((row) => row.blocks);
@@ -19489,31 +20218,23 @@ function AiMediaStripOverlay({
19489
20218
  }) {
19490
20219
  const [hover, setHover] = useState8(null);
19491
20220
  const [active, setActive] = useState8(null);
20221
+ const [itemEditOn, setItemEditOn] = useState8(false);
20222
+ const [linkOpen, setLinkOpen] = useState8(false);
19492
20223
  const [pending, setPending] = useState8(false);
19493
20224
  const [error, setError] = useState8(null);
19494
20225
  const activeRef = useRef5(null);
19495
20226
  activeRef.current = active;
20227
+ const linkOpenRef = useRef5(false);
20228
+ linkOpenRef.current = linkOpen;
19496
20229
  useEffect9(() => {
19497
20230
  const onMove = (e) => {
20231
+ const ref = itemRefFromTarget(e.target);
19498
20232
  const t = e.target;
19499
- if (!(t instanceof HTMLElement)) return;
19500
- if (t.closest("[data-ohw-toolbar], [data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-link-modal-root], [data-ohw-section-picker], [data-ohw-ai-review]")) {
19501
- return;
19502
- }
19503
- const itemEl = t.closest("[data-ohw-media-strip-item]");
19504
- if (!itemEl) {
19505
- setHover(null);
19506
- return;
19507
- }
19508
- const sectionEl2 = itemEl.closest("[data-ohw-section]");
19509
- const unit = sectionEl2 ? movableUnit(sectionEl2) : null;
19510
- const sectionId = unit ? instanceIdOf(unit) || null : null;
19511
- const index = Number(itemEl.dataset.ohwMediaStripIndex);
19512
- if (!sectionId || Number.isNaN(index)) {
19513
- setHover(null);
19514
- return;
19515
- }
19516
- setHover({ sectionId, index });
20233
+ const overEditable = Boolean(t?.closest?.("[data-ohw-editable]"));
20234
+ setHover((prev) => {
20235
+ const next = ref && !overEditable ? ref : null;
20236
+ return sameRef(prev, next) ? prev : next;
20237
+ });
19517
20238
  };
19518
20239
  const onLeave = () => setHover(null);
19519
20240
  document.addEventListener("mousemove", onMove, { passive: true });
@@ -19525,23 +20246,25 @@ function AiMediaStripOverlay({
19525
20246
  }, []);
19526
20247
  useEffect9(() => {
19527
20248
  const onClick = (e) => {
19528
- const current = activeRef.current;
19529
- if (!current) return;
19530
20249
  const t = e.target;
19531
- if (!(t instanceof HTMLElement)) return;
19532
- if (t.closest("[data-ohw-item-interaction]")) return;
19533
- const itemEl = findMediaStripItemElement(current.sectionId, current.index);
19534
- if (itemEl && itemEl.contains(t)) return;
19535
- setActive(null);
20250
+ if (!(t instanceof Element)) return;
20251
+ if (t.closest(CHROME_SELECTOR)) return;
20252
+ const ref = itemRefFromTarget(t);
20253
+ if (sameRef(activeRef.current, ref)) return;
20254
+ if (ref) clearInteractionChromeRef.current();
20255
+ setItemEditOn(false);
19536
20256
  setError(null);
20257
+ setActive(ref);
19537
20258
  };
19538
20259
  document.addEventListener("click", onClick, true);
19539
20260
  return () => document.removeEventListener("click", onClick, true);
19540
- }, []);
20261
+ }, [clearInteractionChromeRef]);
19541
20262
  useEffect9(() => {
19542
20263
  const onBlur = () => {
19543
20264
  if (!activeRef.current) return;
19544
20265
  setActive(null);
20266
+ setItemEditOn(false);
20267
+ setLinkOpen(false);
19545
20268
  setError(null);
19546
20269
  };
19547
20270
  window.addEventListener("blur", onBlur);
@@ -19551,7 +20274,10 @@ function AiMediaStripOverlay({
19551
20274
  const onKeyDown = (e) => {
19552
20275
  if (e.key !== "Escape") return;
19553
20276
  if (!activeRef.current) return;
20277
+ if (linkOpenRef.current) return;
20278
+ if (document.querySelector('[data-ohw-more-menu][data-state="open"]')) return;
19554
20279
  setActive(null);
20280
+ setItemEditOn(false);
19555
20281
  setError(null);
19556
20282
  };
19557
20283
  document.addEventListener("keydown", onKeyDown);
@@ -19585,137 +20311,133 @@ function AiMediaStripOverlay({
19585
20311
  tree: nextTree,
19586
20312
  label: entry.label,
19587
20313
  media: extraMedia ? { ...entry.media, ...extraMedia } : entry.media,
19588
- ...entry.brand ? { brand: entry.brand } : {}
20314
+ ...entry.brand ? { brand: entry.brand } : {},
20315
+ // The user is already looking at the strip they just edited — recentering the viewport
20316
+ // on every edit reads as the section jumping around.
20317
+ skipScrollIntoView: true
19589
20318
  });
19590
20319
  return true;
19591
20320
  },
19592
20321
  [findEntry, postToParent2, applyTreeLocalRef]
19593
20322
  );
19594
20323
  const activeEntry = active ? findEntry(active.sectionId) : null;
19595
- const hoverHandleRect = useLiveItemRect(!active && hover ? hover : null);
19596
20324
  const activeItemRect = useLiveItemRect(active);
19597
- const TOOLBAR_APPROX_H = 170;
19598
- const toolbarState = activeItemRect && activeItemRect.top < TOOLBAR_APPROX_H ? "active-bottom" : "active-top";
19599
- return /* @__PURE__ */ jsxs11(Fragment7, { children: [
19600
- hoverHandleRect && hover && /* @__PURE__ */ jsx20(
19601
- "button",
19602
- {
19603
- type: "button",
19604
- "data-ohw-toolbar": "",
19605
- onClick: () => {
19606
- clearInteractionChromeRef.current();
19607
- setActive(hover);
19608
- },
19609
- "aria-label": "Configure media item",
19610
- style: {
19611
- position: "fixed",
19612
- top: hoverHandleRect.top + 8,
19613
- left: hoverHandleRect.left + hoverHandleRect.width - 36,
19614
- width: 28,
19615
- height: 28,
19616
- borderRadius: 8,
19617
- border: `1.5px dashed ${PRIMARY3}`,
19618
- background: "#ffffff",
19619
- color: PRIMARY3,
19620
- display: "flex",
19621
- alignItems: "center",
19622
- justifyContent: "center",
19623
- cursor: "pointer",
19624
- zIndex: 2147483643,
19625
- fontSize: 14,
19626
- fontWeight: 700
19627
- },
19628
- children: /* @__PURE__ */ jsx20(Star, { size: 14, style: { pointerEvents: "none" } })
19629
- }
19630
- ),
19631
- activeItemRect && active && activeEntry && /* @__PURE__ */ jsx20(
19632
- ItemInteractionLayer,
19633
- {
19634
- rect: activeItemRect,
19635
- state: toolbarState,
19636
- toolbar: /* @__PURE__ */ jsx20(
19637
- MediaStripToolbar,
19638
- {
19639
- entry: activeEntry,
19640
- index: active.index,
19641
- pending,
19642
- error,
19643
- onSetVariant: (variant) => runMutation(active.sectionId, (tree) => setMediaStripVariant(tree, variant)),
19644
- onSetAlign: (align) => runMutation(active.sectionId, (tree) => setMediaStripAlign(tree, align)),
19645
- onSetHover: (hoverPreset) => runMutation(active.sectionId, (tree) => setMediaStripHover(tree, hoverPreset)),
19646
- onSetTreatment: (treatment) => runMutation(active.sectionId, (tree) => setMediaStripTreatment(tree, treatment)),
19647
- onResize: (delta) => {
19648
- const slots = findMediaStripSlots(activeEntry.tree);
19649
- const variant = slots?.variant === "reel" ? "reel" : "logos";
19650
- const current = variant === "logos" ? typeof slots?.logoMaxHeight === "number" ? slots.logoMaxHeight : 48 : typeof slots?.cardWidth === "number" ? slots.cardWidth : 240;
19651
- void runMutation(active.sectionId, (tree) => setMediaStripSizing(tree, current + delta));
19652
- },
19653
- onSetAlt: (alt) => {
19654
- void runMutation(active.sectionId, (tree) => setMediaStripItemAlt(tree, active.index, alt));
19655
- },
19656
- onSetLink: (href, linkTarget) => {
20325
+ const activeStripRect = useLiveItemRect(active, true);
20326
+ const hoverRect = useLiveItemRect(hover && !sameRef(hover, active) ? hover : null);
20327
+ const activeItems = activeEntry ? mediaStripItems(activeEntry.tree) : [];
20328
+ const activeItem = active ? activeItems[active.index] : void 0;
20329
+ const activeHref = activeItem?.href ?? "";
20330
+ const activeTarget = activeItem?.linkTarget === "same-tab" ? "same-tab" : "new-tab";
20331
+ return /* @__PURE__ */ jsxs12(Fragment7, { children: [
20332
+ hoverRect && /* @__PURE__ */ jsx21(ItemInteractionLayer, { rect: hoverRect, state: "hover" }),
20333
+ activeItemRect && activeStripRect && active && activeEntry && /* @__PURE__ */ jsxs12(Fragment7, { children: [
20334
+ /* @__PURE__ */ jsx21(ItemInteractionLayer, { rect: activeItemRect, state: "active-top" }),
20335
+ /* @__PURE__ */ jsx21(StripToolbarSlot, { stripRect: activeStripRect, children: /* @__PURE__ */ jsx21(
20336
+ MediaStripToolbar,
20337
+ {
20338
+ entry: activeEntry,
20339
+ index: active.index,
20340
+ pending,
20341
+ error,
20342
+ itemEditOn,
20343
+ onToggleItemEdit: () => setItemEditOn((on) => !on),
20344
+ onSetVariant: (variant) => runMutation(active.sectionId, (tree) => setMediaStripVariant(tree, variant)),
20345
+ onSetAlign: (align) => runMutation(active.sectionId, (tree) => setMediaStripAlign(tree, align)),
20346
+ onSetHover: (hoverPreset) => runMutation(active.sectionId, (tree) => setMediaStripHover(tree, hoverPreset)),
20347
+ onSetTreatment: (treatment) => runMutation(active.sectionId, (tree) => setMediaStripTreatment(tree, treatment)),
20348
+ onResize: (delta) => {
20349
+ const slots = findMediaStripSlots(activeEntry.tree);
20350
+ const variant = slots?.variant === "reel" ? "reel" : "logos";
20351
+ const current = variant === "logos" ? typeof slots?.logoMaxHeight === "number" ? slots.logoMaxHeight : 48 : typeof slots?.cardWidth === "number" ? slots.cardWidth : 240;
20352
+ void runMutation(active.sectionId, (tree) => setMediaStripSizing(tree, current + delta));
20353
+ },
20354
+ onOpenLink: () => setLinkOpen(true),
20355
+ onAddItem: () => {
20356
+ void requestAssetPick(postToParent2).then((picked) => {
20357
+ if (!picked) return;
20358
+ const item = { assetId: picked.assetId, alt: "Logo" };
19657
20359
  void runMutation(
19658
20360
  active.sectionId,
19659
- (tree) => setMediaStripItemLink(tree, active.index, href ? { href, linkTarget } : {})
19660
- );
19661
- },
19662
- onAddItem: () => {
19663
- void requestAssetPick(postToParent2).then((picked) => {
19664
- if (!picked) return;
19665
- const item = { assetId: picked.assetId, alt: "Logo" };
19666
- void runMutation(
19667
- active.sectionId,
19668
- (tree) => addMediaStripItem(tree, item, active.index),
19669
- { [picked.assetId]: picked.url }
19670
- ).then((applied) => {
19671
- if (applied) setActive({ sectionId: active.sectionId, index: active.index + 1 });
19672
- });
20361
+ (tree) => addMediaStripItem(tree, item, active.index),
20362
+ { [picked.assetId]: picked.url }
20363
+ ).then((applied) => {
20364
+ if (applied) setActive({ sectionId: active.sectionId, index: active.index + 1 });
19673
20365
  });
19674
- },
19675
- onChangeImage: () => {
19676
- void requestAssetPick(postToParent2).then((picked) => {
19677
- if (!picked) return;
19678
- void runMutation(
19679
- active.sectionId,
19680
- (tree) => setMediaStripItemAsset(tree, active.index, picked.assetId),
19681
- { [picked.assetId]: picked.url }
19682
- );
19683
- });
19684
- },
19685
- onRemoveItem: () => {
19686
- void runMutation(active.sectionId, (tree) => removeMediaStripItem(tree, active.index)).then(
19687
- (applied) => {
19688
- if (applied) setActive(null);
19689
- }
19690
- );
19691
- },
19692
- onMoveLeft: () => {
19693
- void runMutation(active.sectionId, (tree) => reorderMediaStripItem(tree, active.index, -1)).then(
19694
- (applied) => {
19695
- if (applied) setActive({ sectionId: active.sectionId, index: active.index - 1 });
19696
- }
19697
- );
19698
- },
19699
- onMoveRight: () => {
19700
- void runMutation(active.sectionId, (tree) => reorderMediaStripItem(tree, active.index, 1)).then(
19701
- (applied) => {
19702
- if (applied) setActive({ sectionId: active.sectionId, index: active.index + 1 });
19703
- }
20366
+ });
20367
+ },
20368
+ onChangeImage: () => {
20369
+ void requestAssetPick(postToParent2).then((picked) => {
20370
+ if (!picked) return;
20371
+ void runMutation(
20372
+ active.sectionId,
20373
+ (tree) => setMediaStripItemAsset(tree, active.index, picked.assetId),
20374
+ { [picked.assetId]: picked.url }
19704
20375
  );
19705
- }
20376
+ });
20377
+ },
20378
+ onRemoveItem: () => {
20379
+ void runMutation(active.sectionId, (tree) => removeMediaStripItem(tree, active.index)).then(
20380
+ (applied) => {
20381
+ if (applied) setActive(null);
20382
+ }
20383
+ );
20384
+ },
20385
+ onMoveLeft: () => {
20386
+ void runMutation(active.sectionId, (tree) => reorderMediaStripItem(tree, active.index, -1)).then(
20387
+ (applied) => {
20388
+ if (applied) setActive({ sectionId: active.sectionId, index: active.index - 1 });
20389
+ }
20390
+ );
20391
+ },
20392
+ onMoveRight: () => {
20393
+ void runMutation(active.sectionId, (tree) => reorderMediaStripItem(tree, active.index, 1)).then(
20394
+ (applied) => {
20395
+ if (applied) setActive({ sectionId: active.sectionId, index: active.index + 1 });
20396
+ }
20397
+ );
19706
20398
  }
19707
- )
19708
- }
19709
- )
20399
+ }
20400
+ ) }),
20401
+ /* @__PURE__ */ jsx21(
20402
+ "div",
20403
+ {
20404
+ "data-ohw-bridge": "",
20405
+ "data-ohw-item-interaction": "",
20406
+ "aria-hidden": true,
20407
+ className: "pointer-events-none fixed rounded-[4px] px-[7px] py-[3px] font-sans text-[11px] font-medium leading-none text-primary-foreground whitespace-nowrap",
20408
+ style: {
20409
+ top: activeItemRect.top + activeItemRect.height + 10,
20410
+ left: activeItemRect.left - 5,
20411
+ background: PRIMARY3,
20412
+ zIndex: 2147483644
20413
+ },
20414
+ children: "Media item"
20415
+ }
20416
+ ),
20417
+ linkOpen && /* @__PURE__ */ jsx21(
20418
+ LinkModal,
20419
+ {
20420
+ href: activeHref,
20421
+ linkTarget: activeTarget,
20422
+ onClose: () => setLinkOpen(false),
20423
+ onSave: (href, linkTarget) => {
20424
+ void runMutation(
20425
+ active.sectionId,
20426
+ (tree) => setMediaStripItemLink(tree, active.index, href ? { href, linkTarget } : {})
20427
+ );
20428
+ }
20429
+ }
20430
+ )
20431
+ ] })
19710
20432
  ] });
19711
20433
  }
19712
20434
 
19713
20435
  // src/ui/ai-section/AiPricingCardOverlay.tsx
19714
- import { useCallback as useCallback4, useEffect as useEffect10, useLayoutEffect as useLayoutEffect4, useRef as useRef6, useState as useState9 } from "react";
19715
- import { Check as Check2, ChevronDown as ChevronDown3, Minus, Plus as Plus2, Star as Star2 } from "lucide-react";
19716
- import { Fragment as Fragment8, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
20436
+ import { useCallback as useCallback4, useEffect as useEffect10, useLayoutEffect as useLayoutEffect5, useRef as useRef6, useState as useState9 } from "react";
20437
+ import { Check as Check3, ChevronDown as ChevronDown4, Minus as Minus2, Plus as Plus3, Star as Star2 } from "lucide-react";
20438
+ import { Fragment as Fragment8, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
19717
20439
  var PRIMARY4 = "var(--ohw-primary, #0885FE)";
19718
- var CHROME_SELECTOR = "[data-ohw-toolbar], [data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-link-modal-root], [data-ohw-section-picker], [data-ohw-ai-review], [data-ohw-more-menu]";
20440
+ var CHROME_SELECTOR2 = "[data-ohw-toolbar], [data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-link-modal-root], [data-ohw-section-picker], [data-ohw-ai-review], [data-ohw-more-menu]";
19719
20441
  function findPricingCardElement(sectionId, index) {
19720
20442
  const sectionEl2 = findByInstanceId(sectionId);
19721
20443
  if (!sectionEl2) return null;
@@ -19727,7 +20449,7 @@ function findPricingCardElement(sectionId, index) {
19727
20449
  }
19728
20450
  function cardRefFromTarget(target) {
19729
20451
  if (!(target instanceof Element)) return null;
19730
- if (target.closest(CHROME_SELECTOR)) return null;
20452
+ if (target.closest(CHROME_SELECTOR2)) return null;
19731
20453
  const cardEl = target.closest("[data-ohw-pricing-card]");
19732
20454
  if (!cardEl) return null;
19733
20455
  const sectionEl2 = cardEl.closest("[data-ohw-section]");
@@ -19737,21 +20459,21 @@ function cardRefFromTarget(target) {
19737
20459
  if (!sectionId || Number.isNaN(index)) return null;
19738
20460
  return { sectionId, index };
19739
20461
  }
19740
- function sameRef(a, b) {
20462
+ function sameRef2(a, b) {
19741
20463
  return a?.sectionId === b?.sectionId && a?.index === b?.index;
19742
20464
  }
19743
- function rectOf(el) {
20465
+ function rectOf2(el) {
19744
20466
  if (!el) return null;
19745
20467
  const r2 = el.getBoundingClientRect();
19746
20468
  if (r2.width <= 0 || r2.height <= 0) return null;
19747
20469
  return { top: r2.top, left: r2.left, width: r2.width, height: r2.height };
19748
20470
  }
19749
20471
  function readRect3(ref) {
19750
- return rectOf(ref && findPricingCardElement(ref.sectionId, ref.index));
20472
+ return rectOf2(ref && findPricingCardElement(ref.sectionId, ref.index));
19751
20473
  }
19752
20474
  function readGridRect(ref) {
19753
20475
  const card = ref && findPricingCardElement(ref.sectionId, ref.index);
19754
- return rectOf(card?.closest("[data-ohw-pricing-collection]") ?? card);
20476
+ return rectOf2(card?.closest("[data-ohw-pricing-collection]") ?? card);
19755
20477
  }
19756
20478
  function useLiveCardRect(ref, grid = false) {
19757
20479
  const [rect, setRect] = useState9(null);
@@ -19781,19 +20503,19 @@ function useLiveCardRect(ref, grid = false) {
19781
20503
  }
19782
20504
  var TOOLBAR_GRID_GAP = 52;
19783
20505
  var TOOLBAR_GRID_GAP_MOBILE = 42;
19784
- var TOOLBAR_EDGE_MARGIN2 = 4;
20506
+ var TOOLBAR_EDGE_MARGIN3 = 4;
19785
20507
  function GridToolbarSlot({ gridRect, children }) {
19786
20508
  const slotRef = useRef6(null);
19787
20509
  const [shift, setShift] = useState9(0);
19788
20510
  const centerX = gridRect.left + gridRect.width / 2;
19789
- useLayoutEffect4(() => {
20511
+ useLayoutEffect5(() => {
19790
20512
  const slot = slotRef.current;
19791
20513
  if (!slot) return;
19792
20514
  const clamp = () => {
19793
20515
  const w = slot.offsetWidth;
19794
20516
  if (w <= 0) return;
19795
20517
  const half = w / 2;
19796
- const clamped = Math.max(TOOLBAR_EDGE_MARGIN2 + half, Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN2 - half));
20518
+ const clamped = Math.max(TOOLBAR_EDGE_MARGIN3 + half, Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN3 - half));
19797
20519
  setShift((prev) => Math.abs(prev - (clamped - centerX)) < 0.5 ? prev : clamped - centerX);
19798
20520
  };
19799
20521
  clamp();
@@ -19802,7 +20524,7 @@ function GridToolbarSlot({ gridRect, children }) {
19802
20524
  return () => ro.disconnect();
19803
20525
  }, [centerX, children]);
19804
20526
  const mobile = window.innerWidth <= 480;
19805
- return /* @__PURE__ */ jsx21(
20527
+ return /* @__PURE__ */ jsx22(
19806
20528
  "div",
19807
20529
  {
19808
20530
  ref: slotRef,
@@ -19837,7 +20559,7 @@ function requestValidateTree2(postToParent2, tree) {
19837
20559
  });
19838
20560
  }
19839
20561
  function StyleSwatch({ style }) {
19840
- return /* @__PURE__ */ jsx21(
20562
+ return /* @__PURE__ */ jsx22(
19841
20563
  "span",
19842
20564
  {
19843
20565
  "aria-hidden": true,
@@ -19851,35 +20573,35 @@ function StyleSwatch({ style }) {
19851
20573
  );
19852
20574
  }
19853
20575
  function ButtonGlyph() {
19854
- return /* @__PURE__ */ jsxs12("svg", { width: "18", height: "12", viewBox: "0 0 18 12", fill: "none", "aria-hidden": true, style: { pointerEvents: "none" }, children: [
19855
- /* @__PURE__ */ jsx21("rect", { x: "0.75", y: "0.75", width: "16.5", height: "10.5", rx: "3", stroke: "currentColor", strokeWidth: "1.5" }),
19856
- /* @__PURE__ */ jsx21("path", { d: "M5.5 6H12.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
20576
+ return /* @__PURE__ */ jsxs13("svg", { width: "18", height: "12", viewBox: "0 0 18 12", fill: "none", "aria-hidden": true, style: { pointerEvents: "none" }, children: [
20577
+ /* @__PURE__ */ jsx22("rect", { x: "0.75", y: "0.75", width: "16.5", height: "10.5", rx: "3", stroke: "currentColor", strokeWidth: "1.5" }),
20578
+ /* @__PURE__ */ jsx22("path", { d: "M5.5 6H12.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
19857
20579
  ] });
19858
20580
  }
19859
20581
  function FeatureGlyph({ mode }) {
19860
- return /* @__PURE__ */ jsxs12("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", "aria-hidden": true, style: { pointerEvents: "none" }, children: [
19861
- /* @__PURE__ */ jsx21("circle", { cx: "8", cy: "8", r: "7.25", stroke: "currentColor", strokeWidth: "1.5" }),
19862
- /* @__PURE__ */ jsx21("path", { d: "M5 8.2L7.2 10.3L11 6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
19863
- /* @__PURE__ */ jsx21("circle", { cx: "13.5", cy: "13.5", r: "4.25", fill: "var(--ohw-background, #ffffff)", stroke: "var(--ohw-background, #ffffff)", strokeWidth: "1" }),
19864
- /* @__PURE__ */ jsx21("circle", { cx: "13.5", cy: "13.5", r: "3.75", fill: "var(--ohw-background, #ffffff)", stroke: PRIMARY4, strokeWidth: "1" }),
19865
- /* @__PURE__ */ jsx21("path", { d: "M11.5 13.5H15.5", stroke: PRIMARY4, strokeWidth: "1.5", strokeLinecap: "round" }),
19866
- mode === "add" && /* @__PURE__ */ jsx21("path", { d: "M13.5 11.5V15.5", stroke: PRIMARY4, strokeWidth: "1.5", strokeLinecap: "round" })
20582
+ return /* @__PURE__ */ jsxs13("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", "aria-hidden": true, style: { pointerEvents: "none" }, children: [
20583
+ /* @__PURE__ */ jsx22("circle", { cx: "8", cy: "8", r: "7.25", stroke: "currentColor", strokeWidth: "1.5" }),
20584
+ /* @__PURE__ */ jsx22("path", { d: "M5 8.2L7.2 10.3L11 6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
20585
+ /* @__PURE__ */ jsx22("circle", { cx: "13.5", cy: "13.5", r: "4.25", fill: "var(--ohw-background, #ffffff)", stroke: "var(--ohw-background, #ffffff)", strokeWidth: "1" }),
20586
+ /* @__PURE__ */ jsx22("circle", { cx: "13.5", cy: "13.5", r: "3.75", fill: "var(--ohw-background, #ffffff)", stroke: PRIMARY4, strokeWidth: "1" }),
20587
+ /* @__PURE__ */ jsx22("path", { d: "M11.5 13.5H15.5", stroke: PRIMARY4, strokeWidth: "1.5", strokeLinecap: "round" }),
20588
+ mode === "add" && /* @__PURE__ */ jsx22("path", { d: "M13.5 11.5V15.5", stroke: PRIMARY4, strokeWidth: "1.5", strokeLinecap: "round" })
19867
20589
  ] });
19868
20590
  }
19869
- function ToolbarAction({
20591
+ function ToolbarAction2({
19870
20592
  label,
19871
20593
  onClick,
19872
20594
  disabled = false,
19873
20595
  children
19874
20596
  }) {
19875
- const button = /* @__PURE__ */ jsx21(CustomToolbarButton, { type: "button", "aria-label": label, disabled, onClick, className: "size-8", children });
19876
- return /* @__PURE__ */ jsxs12(Tooltip, { children: [
19877
- /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: disabled ? /* @__PURE__ */ jsx21("span", { className: "inline-flex", children: button }) : button }),
19878
- /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: label })
20597
+ const button = /* @__PURE__ */ jsx22(CustomToolbarButton, { type: "button", "aria-label": label, disabled, onClick, className: "size-8", children });
20598
+ return /* @__PURE__ */ jsxs13(Tooltip, { children: [
20599
+ /* @__PURE__ */ jsx22(TooltipTrigger, { asChild: true, children: disabled ? /* @__PURE__ */ jsx22("span", { className: "inline-flex", children: button }) : button }),
20600
+ /* @__PURE__ */ jsx22(TooltipContent, { side: "bottom", sideOffset: 8, children: label })
19879
20601
  ] });
19880
20602
  }
19881
- function ToolbarSeparator() {
19882
- return /* @__PURE__ */ jsx21("span", { "aria-hidden": true, className: "mx-0.5 block h-6 w-px shrink-0 bg-border" });
20603
+ function ToolbarSeparator2() {
20604
+ return /* @__PURE__ */ jsx22("span", { "aria-hidden": true, className: "mx-0.5 block h-6 w-px shrink-0 bg-border" });
19883
20605
  }
19884
20606
  function CardStyleMenu({
19885
20607
  value,
@@ -19887,7 +20609,7 @@ function CardStyleMenu({
19887
20609
  disabled = false
19888
20610
  }) {
19889
20611
  const current = PRICING_CARD_STYLES.find((s) => s.value === value) ?? PRICING_CARD_STYLES[0];
19890
- const trigger = /* @__PURE__ */ jsxs12(
20612
+ const trigger = /* @__PURE__ */ jsxs13(
19891
20613
  "button",
19892
20614
  {
19893
20615
  type: "button",
@@ -19898,28 +20620,28 @@ function CardStyleMenu({
19898
20620
  disabled && "cursor-not-allowed opacity-40 hover:bg-transparent"
19899
20621
  ),
19900
20622
  children: [
19901
- /* @__PURE__ */ jsx21(StyleSwatch, { style: current.value }),
19902
- /* @__PURE__ */ jsx21("span", { className: "flex-1 text-left", children: current.label }),
19903
- /* @__PURE__ */ jsx21(ChevronDown3, { size: 16, style: { pointerEvents: "none" } })
20623
+ /* @__PURE__ */ jsx22(StyleSwatch, { style: current.value }),
20624
+ /* @__PURE__ */ jsx22("span", { className: "flex-1 text-left", children: current.label }),
20625
+ /* @__PURE__ */ jsx22(ChevronDown4, { size: 16, style: { pointerEvents: "none" } })
19904
20626
  ]
19905
20627
  }
19906
20628
  );
19907
20629
  if (disabled) {
19908
- return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
19909
- /* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground opacity-50", children: "Card style" }),
19910
- /* @__PURE__ */ jsxs12(Tooltip, { children: [
19911
- /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21("span", { className: "inline-flex", children: trigger }) }),
19912
- /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: "Mark as featured to edit card style" })
20630
+ return /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
20631
+ /* @__PURE__ */ jsx22("span", { className: "text-xs text-muted-foreground opacity-50", children: "Card style" }),
20632
+ /* @__PURE__ */ jsxs13(Tooltip, { children: [
20633
+ /* @__PURE__ */ jsx22(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx22("span", { className: "inline-flex", children: trigger }) }),
20634
+ /* @__PURE__ */ jsx22(TooltipContent, { side: "bottom", sideOffset: 8, children: "Mark as featured to edit card style" })
19913
20635
  ] })
19914
20636
  ] });
19915
20637
  }
19916
- return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
19917
- /* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground", children: "Card style" }),
19918
- /* @__PURE__ */ jsxs12(DropdownMenu, { modal: false, children: [
19919
- /* @__PURE__ */ jsx21(DropdownMenuTrigger, { asChild: true, children: trigger }),
19920
- /* @__PURE__ */ jsx21(DropdownMenuContent, { align: "end", sideOffset: 8, className: "w-[152px] min-w-[152px] p-1", children: PRICING_CARD_STYLES.map((style) => {
20638
+ return /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
20639
+ /* @__PURE__ */ jsx22("span", { className: "text-xs text-muted-foreground", children: "Card style" }),
20640
+ /* @__PURE__ */ jsxs13(DropdownMenu, { modal: false, children: [
20641
+ /* @__PURE__ */ jsx22(DropdownMenuTrigger, { asChild: true, children: trigger }),
20642
+ /* @__PURE__ */ jsx22(DropdownMenuContent, { align: "end", sideOffset: 8, className: "w-[152px] min-w-[152px] p-1", children: PRICING_CARD_STYLES.map((style) => {
19921
20643
  const selected = style.value === value;
19922
- return /* @__PURE__ */ jsxs12(
20644
+ return /* @__PURE__ */ jsxs13(
19923
20645
  DropdownMenuItem,
19924
20646
  {
19925
20647
  role: "menuitemradio",
@@ -19927,9 +20649,9 @@ function CardStyleMenu({
19927
20649
  onSelect: () => onChange(style.value),
19928
20650
  className: cn("grid grid-cols-[18px_1fr_16px] gap-2 py-2 pl-2 pr-2 text-[13px]", selected && "bg-muted"),
19929
20651
  children: [
19930
- /* @__PURE__ */ jsx21(StyleSwatch, { style: style.value }),
19931
- /* @__PURE__ */ jsx21("span", { children: style.label }),
19932
- selected && /* @__PURE__ */ jsx21(Check2, { size: 16, className: "text-bridge-primary" })
20652
+ /* @__PURE__ */ jsx22(StyleSwatch, { style: style.value }),
20653
+ /* @__PURE__ */ jsx22("span", { children: style.label }),
20654
+ selected && /* @__PURE__ */ jsx22(Check3, { size: 16, className: "text-bridge-primary" })
19933
20655
  ]
19934
20656
  },
19935
20657
  style.value
@@ -19959,7 +20681,7 @@ function PricingCardToolbar({
19959
20681
  const style = pricingCardStyle(entry.tree, index);
19960
20682
  const featuredTag = pricingCardFeaturedTag(entry.tree, index);
19961
20683
  const mobile = window.innerWidth <= 480;
19962
- return /* @__PURE__ */ jsx21(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs12(
20684
+ return /* @__PURE__ */ jsx22(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs13(
19963
20685
  "div",
19964
20686
  {
19965
20687
  "data-ohw-bridge": "",
@@ -19971,7 +20693,7 @@ function PricingCardToolbar({
19971
20693
  ),
19972
20694
  style: { maxWidth: mobile ? "calc(100vw - 24px)" : void 0 },
19973
20695
  children: [
19974
- /* @__PURE__ */ jsxs12(
20696
+ /* @__PURE__ */ jsxs13(
19975
20697
  "div",
19976
20698
  {
19977
20699
  className: cn(
@@ -19980,8 +20702,8 @@ function PricingCardToolbar({
19980
20702
  mobile ? "flex-wrap justify-center" : "flex-nowrap"
19981
20703
  ),
19982
20704
  children: [
19983
- /* @__PURE__ */ jsxs12(Tooltip, { children: [
19984
- /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(
20705
+ /* @__PURE__ */ jsxs13(Tooltip, { children: [
20706
+ /* @__PURE__ */ jsx22(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx22(
19985
20707
  CustomToolbarButton,
19986
20708
  {
19987
20709
  type: "button",
@@ -19989,7 +20711,7 @@ function PricingCardToolbar({
19989
20711
  "aria-pressed": featuredTag,
19990
20712
  onClick: () => onSetFeaturedTag(!featuredTag),
19991
20713
  className: "group size-8",
19992
- children: /* @__PURE__ */ jsx21(
20714
+ children: /* @__PURE__ */ jsx22(
19993
20715
  Star2,
19994
20716
  {
19995
20717
  size: 16,
@@ -20004,25 +20726,25 @@ function PricingCardToolbar({
20004
20726
  )
20005
20727
  }
20006
20728
  ) }),
20007
- /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: featuredTag ? "Unmark featured" : "Mark as featured" })
20729
+ /* @__PURE__ */ jsx22(TooltipContent, { side: "bottom", sideOffset: 8, children: featuredTag ? "Unmark featured" : "Mark as featured" })
20008
20730
  ] }),
20009
- /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20010
- /* @__PURE__ */ jsx21(CardStyleMenu, { value: style, onChange: onSetStyle, disabled: !featuredTag }),
20011
- /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20012
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Add button", onClick: onAddButton, disabled: buttonCount >= 2, children: /* @__PURE__ */ jsx21(ButtonGlyph, {}) }),
20013
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Remove button", onClick: onRemoveButton, disabled: buttonCount === 0, children: /* @__PURE__ */ jsxs12("span", { className: "relative inline-flex", children: [
20014
- /* @__PURE__ */ jsx21(ButtonGlyph, {}),
20015
- /* @__PURE__ */ jsx21(Minus, { size: 10, strokeWidth: 2.5, className: "absolute -right-1.5 -top-1.5 rounded-full bg-background text-bridge-primary" })
20731
+ /* @__PURE__ */ jsx22(ToolbarSeparator2, {}),
20732
+ /* @__PURE__ */ jsx22(CardStyleMenu, { value: style, onChange: onSetStyle, disabled: !featuredTag }),
20733
+ /* @__PURE__ */ jsx22(ToolbarSeparator2, {}),
20734
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Add button", onClick: onAddButton, disabled: buttonCount >= 2, children: /* @__PURE__ */ jsx22(ButtonGlyph, {}) }),
20735
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Remove button", onClick: onRemoveButton, disabled: buttonCount === 0, children: /* @__PURE__ */ jsxs13("span", { className: "relative inline-flex", children: [
20736
+ /* @__PURE__ */ jsx22(ButtonGlyph, {}),
20737
+ /* @__PURE__ */ jsx22(Minus2, { size: 10, strokeWidth: 2.5, className: "absolute -right-1.5 -top-1.5 rounded-full bg-background text-bridge-primary" })
20016
20738
  ] }) }),
20017
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Add feature", onClick: onAddFeature, disabled: featureCount >= 10, children: /* @__PURE__ */ jsx21(FeatureGlyph, { mode: "add" }) }),
20018
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Remove feature", onClick: onRemoveFeature, disabled: featureCount <= 1, children: /* @__PURE__ */ jsx21(FeatureGlyph, { mode: "remove" }) }),
20019
- /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20020
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Add tier", onClick: onAddTier, disabled: collectionCount >= 4, children: /* @__PURE__ */ jsx21(Plus2, { size: 16, style: { pointerEvents: "none" } }) }),
20021
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Remove tier", onClick: onRemoveTier, disabled: collectionCount <= 1, children: /* @__PURE__ */ jsx21(Minus, { size: 16, style: { pointerEvents: "none" } }) })
20739
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Add feature", onClick: onAddFeature, disabled: featureCount >= 10, children: /* @__PURE__ */ jsx22(FeatureGlyph, { mode: "add" }) }),
20740
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Remove feature", onClick: onRemoveFeature, disabled: featureCount <= 1, children: /* @__PURE__ */ jsx22(FeatureGlyph, { mode: "remove" }) }),
20741
+ /* @__PURE__ */ jsx22(ToolbarSeparator2, {}),
20742
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Add tier", onClick: onAddTier, disabled: collectionCount >= 4, children: /* @__PURE__ */ jsx22(Plus3, { size: 16, style: { pointerEvents: "none" } }) }),
20743
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Remove tier", onClick: onRemoveTier, disabled: collectionCount <= 1, children: /* @__PURE__ */ jsx22(Minus2, { size: 16, style: { pointerEvents: "none" } }) })
20022
20744
  ]
20023
20745
  }
20024
20746
  ),
20025
- error && /* @__PURE__ */ jsx21("div", { className: "max-w-[260px] rounded-md bg-background px-2 py-1 text-center text-[11px] text-destructive shadow-sm", children: error })
20747
+ error && /* @__PURE__ */ jsx22("div", { className: "max-w-[260px] rounded-md bg-background px-2 py-1 text-center text-[11px] text-destructive shadow-sm", children: error })
20026
20748
  ]
20027
20749
  }
20028
20750
  ) });
@@ -20056,7 +20778,7 @@ function AiPricingCardOverlay({
20056
20778
  const overEditable = Boolean(t?.closest?.("[data-ohw-editable], [data-ohw-role], a, button"));
20057
20779
  setHover((prev) => {
20058
20780
  const next = ref && !overEditable ? ref : null;
20059
- return sameRef(prev, next) ? prev : next;
20781
+ return sameRef2(prev, next) ? prev : next;
20060
20782
  });
20061
20783
  };
20062
20784
  const onLeave = () => setHover(null);
@@ -20071,10 +20793,10 @@ function AiPricingCardOverlay({
20071
20793
  const onClick = (e) => {
20072
20794
  const t = e.target;
20073
20795
  if (!(t instanceof Element)) return;
20074
- if (t.closest(CHROME_SELECTOR)) return;
20796
+ if (t.closest(CHROME_SELECTOR2)) return;
20075
20797
  const ref = cardRefFromTarget(t);
20076
- setActive((prev) => sameRef(prev, ref) ? prev : ref);
20077
- if (!ref || !sameRef(activeRef.current, ref)) setError(null);
20798
+ setActive((prev) => sameRef2(prev, ref) ? prev : ref);
20799
+ if (!ref || !sameRef2(activeRef.current, ref)) setError(null);
20078
20800
  };
20079
20801
  document.addEventListener("click", onClick, true);
20080
20802
  return () => document.removeEventListener("click", onClick, true);
@@ -20139,12 +20861,12 @@ function AiPricingCardOverlay({
20139
20861
  const activeEntry = active ? findEntry(active.sectionId) : null;
20140
20862
  const activeCardRect = useLiveCardRect(active);
20141
20863
  const activeGridRect = useLiveCardRect(active, true);
20142
- const hoverRect = useLiveCardRect(hover && !sameRef(hover, active) ? hover : null);
20143
- return /* @__PURE__ */ jsxs12(Fragment8, { children: [
20144
- hoverRect && /* @__PURE__ */ jsx21(ItemInteractionLayer, { rect: hoverRect, state: "hover" }),
20145
- activeCardRect && activeGridRect && active && activeEntry && /* @__PURE__ */ jsxs12(Fragment8, { children: [
20146
- /* @__PURE__ */ jsx21(ItemInteractionLayer, { rect: activeCardRect, state: "active-top" }),
20147
- /* @__PURE__ */ jsx21(GridToolbarSlot, { gridRect: activeGridRect, children: /* @__PURE__ */ jsx21(
20864
+ const hoverRect = useLiveCardRect(hover && !sameRef2(hover, active) ? hover : null);
20865
+ return /* @__PURE__ */ jsxs13(Fragment8, { children: [
20866
+ hoverRect && /* @__PURE__ */ jsx22(ItemInteractionLayer, { rect: hoverRect, state: "hover" }),
20867
+ activeCardRect && activeGridRect && active && activeEntry && /* @__PURE__ */ jsxs13(Fragment8, { children: [
20868
+ /* @__PURE__ */ jsx22(ItemInteractionLayer, { rect: activeCardRect, state: "active-top" }),
20869
+ /* @__PURE__ */ jsx22(GridToolbarSlot, { gridRect: activeGridRect, children: /* @__PURE__ */ jsx22(
20148
20870
  PricingCardToolbar,
20149
20871
  {
20150
20872
  entry: activeEntry,
@@ -20172,7 +20894,7 @@ function AiPricingCardOverlay({
20172
20894
  onRemoveFeature: () => runMutation(active.sectionId, (tree) => removePricingCardFeature(tree, active.index))
20173
20895
  }
20174
20896
  ) }),
20175
- /* @__PURE__ */ jsx21(
20897
+ /* @__PURE__ */ jsx22(
20176
20898
  "div",
20177
20899
  {
20178
20900
  "data-ohw-bridge": "",
@@ -20236,39 +20958,11 @@ function clearVideo(tree, path) {
20236
20958
  });
20237
20959
  }
20238
20960
 
20239
- // src/lib/youtube.ts
20240
- var YOUTUBE_ID_PATTERN = /^[A-Za-z0-9_-]{11}$/;
20241
- function extractYouTubeId(input) {
20242
- const trimmed = input.trim();
20243
- if (!trimmed) return null;
20244
- if (YOUTUBE_ID_PATTERN.test(trimmed)) return trimmed;
20245
- let url;
20246
- try {
20247
- url = new URL(trimmed);
20248
- } catch {
20249
- return null;
20250
- }
20251
- const host = url.hostname.replace(/^www\./, "");
20252
- if (host !== "youtube.com" && host !== "m.youtube.com" && host !== "youtu.be" && host !== "youtube-nocookie.com") {
20253
- return null;
20254
- }
20255
- let candidate = null;
20256
- if (host === "youtu.be") {
20257
- candidate = url.pathname.slice(1).split("/")[0] ?? null;
20258
- } else if (url.pathname === "/watch") {
20259
- candidate = url.searchParams.get("v");
20260
- } else {
20261
- const match = url.pathname.match(/^\/(?:embed|shorts)\/([^/]+)/);
20262
- candidate = match ? match[1] : null;
20263
- }
20264
- return candidate && YOUTUBE_ID_PATTERN.test(candidate) ? candidate : null;
20265
- }
20266
-
20267
20961
  // src/ui/ai-section/AiVideoOverlay.tsx
20268
- import { Fragment as Fragment9, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
20962
+ import { Fragment as Fragment9, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
20269
20963
  var PRIMARY5 = "#0885FE";
20270
- var OHW_BLUE2 = `var(--ohw-primary, ${PRIMARY5})`;
20271
- var OHW_BLUE_DARK2 = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY5}) 60%, #000000)`;
20964
+ var OHW_BLUE = `var(--ohw-primary, ${PRIMARY5})`;
20965
+ var OHW_BLUE_DARK = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY5}) 60%, #000000)`;
20272
20966
  function findVideoBlockElement(sectionId, path) {
20273
20967
  const sectionEl2 = findByInstanceId(sectionId);
20274
20968
  if (!sectionEl2) return null;
@@ -20328,12 +21022,12 @@ function requestValidateTree3(postToParent2, tree) {
20328
21022
  postToParent2({ type: "ow:ai-validate-tree-request", id, tree });
20329
21023
  });
20330
21024
  }
20331
- function Pill2({
21025
+ function Pill({
20332
21026
  label,
20333
21027
  onClick,
20334
21028
  disabled
20335
21029
  }) {
20336
- return /* @__PURE__ */ jsx22(
21030
+ return /* @__PURE__ */ jsx23(
20337
21031
  "button",
20338
21032
  {
20339
21033
  type: "button",
@@ -20349,7 +21043,7 @@ function Pill2({
20349
21043
  border: "none",
20350
21044
  cursor: disabled ? "default" : "pointer",
20351
21045
  background: "#ffffff",
20352
- color: OHW_BLUE_DARK2,
21046
+ color: OHW_BLUE_DARK,
20353
21047
  opacity: disabled ? 0.4 : 1,
20354
21048
  fontSize: 12,
20355
21049
  lineHeight: "16px",
@@ -20392,8 +21086,8 @@ function VideoUrlInput({ value, onCommit }) {
20392
21086
  onCommit(id);
20393
21087
  }
20394
21088
  };
20395
- return /* @__PURE__ */ jsxs13("div", { style: { display: "flex", flexDirection: "column", gap: 4, width: "100%", maxWidth: 280 }, children: [
20396
- /* @__PURE__ */ jsxs13(
21089
+ return /* @__PURE__ */ jsxs14("div", { style: { display: "flex", flexDirection: "column", gap: 4, width: "100%", maxWidth: 280 }, children: [
21090
+ /* @__PURE__ */ jsxs14(
20397
21091
  "div",
20398
21092
  {
20399
21093
  style: {
@@ -20409,12 +21103,12 @@ function VideoUrlInput({ value, onCommit }) {
20409
21103
  boxShadow: invalid ? "inset 0 0 0 1.5px #EF4444" : "none"
20410
21104
  },
20411
21105
  children: [
20412
- /* @__PURE__ */ jsx22(
21106
+ /* @__PURE__ */ jsx23(
20413
21107
  "span",
20414
21108
  {
20415
21109
  style: {
20416
21110
  flex: "0 0 auto",
20417
- color: OHW_BLUE_DARK2,
21111
+ color: OHW_BLUE_DARK,
20418
21112
  fontSize: 10,
20419
21113
  lineHeight: "16px",
20420
21114
  fontWeight: 700,
@@ -20424,7 +21118,7 @@ function VideoUrlInput({ value, onCommit }) {
20424
21118
  children: "Video"
20425
21119
  }
20426
21120
  ),
20427
- /* @__PURE__ */ jsx22(
21121
+ /* @__PURE__ */ jsx23(
20428
21122
  "input",
20429
21123
  {
20430
21124
  type: "text",
@@ -20461,7 +21155,7 @@ function VideoUrlInput({ value, onCommit }) {
20461
21155
  ]
20462
21156
  }
20463
21157
  ),
20464
- invalid && /* @__PURE__ */ jsx22("div", { style: { color: "#FCA5A5", fontSize: 11, textAlign: "center" }, children: "That doesn't look like a YouTube link \u2014 try pasting the video URL again." })
21158
+ invalid && /* @__PURE__ */ jsx23("div", { style: { color: "#FCA5A5", fontSize: 11, textAlign: "center" }, children: "That doesn't look like a YouTube link \u2014 try pasting the video URL again." })
20465
21159
  ] });
20466
21160
  }
20467
21161
  function VideoToolbar({
@@ -20471,7 +21165,7 @@ function VideoToolbar({
20471
21165
  onSetVideoId,
20472
21166
  onRemove
20473
21167
  }) {
20474
- return /* @__PURE__ */ jsxs13(
21168
+ return /* @__PURE__ */ jsxs14(
20475
21169
  "div",
20476
21170
  {
20477
21171
  "data-ohw-bridge": "",
@@ -20483,7 +21177,7 @@ function VideoToolbar({
20483
21177
  gap: 6,
20484
21178
  alignItems: "center",
20485
21179
  width: 280,
20486
- background: OHW_BLUE2,
21180
+ background: OHW_BLUE,
20487
21181
  padding: 8,
20488
21182
  borderRadius: 12,
20489
21183
  boxShadow: "0 8px 24px rgba(0,0,0,0.25)",
@@ -20491,9 +21185,9 @@ function VideoToolbar({
20491
21185
  opacity: pending ? 0.6 : 1
20492
21186
  },
20493
21187
  children: [
20494
- /* @__PURE__ */ jsx22(VideoUrlInput, { value: videoId, onCommit: onSetVideoId }),
20495
- /* @__PURE__ */ jsx22(Pill2, { label: "Remove video", onClick: onRemove, disabled: !videoId }),
20496
- error && /* @__PURE__ */ jsx22("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
21188
+ /* @__PURE__ */ jsx23(VideoUrlInput, { value: videoId, onCommit: onSetVideoId }),
21189
+ /* @__PURE__ */ jsx23(Pill, { label: "Remove video", onClick: onRemove, disabled: !videoId }),
21190
+ error && /* @__PURE__ */ jsx23("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
20497
21191
  ]
20498
21192
  }
20499
21193
  );
@@ -20613,8 +21307,8 @@ function AiVideoOverlay({
20613
21307
  const activeBlockRect = useLiveBlockRect(active);
20614
21308
  const TOOLBAR_APPROX_H = 90;
20615
21309
  const toolbarState = activeBlockRect && activeBlockRect.top < TOOLBAR_APPROX_H ? "active-bottom" : "active-top";
20616
- return /* @__PURE__ */ jsxs13(Fragment9, { children: [
20617
- hoverHandleRect && hover && /* @__PURE__ */ jsx22(
21310
+ return /* @__PURE__ */ jsxs14(Fragment9, { children: [
21311
+ hoverHandleRect && hover && /* @__PURE__ */ jsx23(
20618
21312
  "button",
20619
21313
  {
20620
21314
  type: "button",
@@ -20642,15 +21336,15 @@ function AiVideoOverlay({
20642
21336
  fontSize: 14,
20643
21337
  fontWeight: 700
20644
21338
  },
20645
- children: /* @__PURE__ */ jsx22(Star3, { size: 14, style: { pointerEvents: "none" } })
21339
+ children: /* @__PURE__ */ jsx23(Star3, { size: 14, style: { pointerEvents: "none" } })
20646
21340
  }
20647
21341
  ),
20648
- activeBlockRect && active && activeEntry && /* @__PURE__ */ jsx22(
21342
+ activeBlockRect && active && activeEntry && /* @__PURE__ */ jsx23(
20649
21343
  ItemInteractionLayer,
20650
21344
  {
20651
21345
  rect: activeBlockRect,
20652
21346
  state: toolbarState,
20653
- toolbar: /* @__PURE__ */ jsx22(
21347
+ toolbar: /* @__PURE__ */ jsx23(
20654
21348
  VideoToolbar,
20655
21349
  {
20656
21350
  videoId: videoIdAt(activeEntry.tree, active.path),
@@ -20725,10 +21419,10 @@ function setCarouselAutoplay(tree, on) {
20725
21419
  }
20726
21420
 
20727
21421
  // src/ui/ai-section/AiFadeCarouselOverlay.tsx
20728
- import { Fragment as Fragment10, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
21422
+ import { Fragment as Fragment10, jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
20729
21423
  var PRIMARY6 = "#0885FE";
20730
- var OHW_BLUE3 = `var(--ohw-primary, ${PRIMARY6})`;
20731
- var OHW_BLUE_DARK3 = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY6}) 60%, #000000)`;
21424
+ var OHW_BLUE2 = `var(--ohw-primary, ${PRIMARY6})`;
21425
+ var OHW_BLUE_DARK2 = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY6}) 60%, #000000)`;
20732
21426
  function findCarouselItemElement(sectionId, index) {
20733
21427
  const sectionEl2 = findByInstanceId(sectionId);
20734
21428
  if (!sectionEl2) return null;
@@ -20807,8 +21501,8 @@ function requestAssetPick2(postToParent2) {
20807
21501
  postToParent2({ type: "ow:asset-pick", id });
20808
21502
  });
20809
21503
  }
20810
- function Pill3({ label, onClick, disabled }) {
20811
- return /* @__PURE__ */ jsx23(
21504
+ function Pill2({ label, onClick, disabled }) {
21505
+ return /* @__PURE__ */ jsx24(
20812
21506
  "button",
20813
21507
  {
20814
21508
  type: "button",
@@ -20824,7 +21518,7 @@ function Pill3({ label, onClick, disabled }) {
20824
21518
  border: "none",
20825
21519
  cursor: disabled ? "default" : "pointer",
20826
21520
  background: "#ffffff",
20827
- color: OHW_BLUE_DARK3,
21521
+ color: OHW_BLUE_DARK2,
20828
21522
  opacity: disabled ? 0.4 : 1,
20829
21523
  fontSize: 12,
20830
21524
  lineHeight: "16px",
@@ -20842,7 +21536,7 @@ function TogglePill({
20842
21536
  onToggle,
20843
21537
  disabled
20844
21538
  }) {
20845
- return /* @__PURE__ */ jsxs14(
21539
+ return /* @__PURE__ */ jsxs15(
20846
21540
  "button",
20847
21541
  {
20848
21542
  type: "button",
@@ -20861,7 +21555,7 @@ function TogglePill({
20861
21555
  border: "none",
20862
21556
  cursor: disabled ? "default" : "pointer",
20863
21557
  background: "#ffffff",
20864
- color: OHW_BLUE_DARK3,
21558
+ color: OHW_BLUE_DARK2,
20865
21559
  opacity: disabled ? 0.4 : 1,
20866
21560
  fontSize: 12,
20867
21561
  lineHeight: "16px",
@@ -20871,7 +21565,7 @@ function TogglePill({
20871
21565
  },
20872
21566
  children: [
20873
21567
  label,
20874
- /* @__PURE__ */ jsx23(
21568
+ /* @__PURE__ */ jsx24(
20875
21569
  "span",
20876
21570
  {
20877
21571
  "aria-hidden": true,
@@ -20884,10 +21578,10 @@ function TogglePill({
20884
21578
  // Off is a grey track, not a washed-out blue: the pill's own white background already
20885
21579
  // carries the brand colour in the text, and a pale blue track next to it read as
20886
21580
  // "disabled control" rather than "switch that is off".
20887
- background: on ? OHW_BLUE_DARK3 : "#CBD5E1",
21581
+ background: on ? OHW_BLUE_DARK2 : "#CBD5E1",
20888
21582
  transition: "background 120ms ease"
20889
21583
  },
20890
- children: /* @__PURE__ */ jsx23(
21584
+ children: /* @__PURE__ */ jsx24(
20891
21585
  "span",
20892
21586
  {
20893
21587
  style: {
@@ -20916,7 +21610,7 @@ function CarouselSlideToolbar({
20916
21610
  onChangeImage,
20917
21611
  onToggleAutoplay
20918
21612
  }) {
20919
- return /* @__PURE__ */ jsxs14(
21613
+ return /* @__PURE__ */ jsxs15(
20920
21614
  "div",
20921
21615
  {
20922
21616
  "data-ohw-bridge": "",
@@ -20927,7 +21621,7 @@ function CarouselSlideToolbar({
20927
21621
  flexDirection: "column",
20928
21622
  gap: 6,
20929
21623
  alignItems: "center",
20930
- background: OHW_BLUE3,
21624
+ background: OHW_BLUE2,
20931
21625
  padding: 8,
20932
21626
  borderRadius: 12,
20933
21627
  boxShadow: "0 8px 24px rgba(0,0,0,0.25)",
@@ -20939,11 +21633,11 @@ function CarouselSlideToolbar({
20939
21633
  pointerEvents: pending ? "none" : "auto"
20940
21634
  },
20941
21635
  children: [
20942
- /* @__PURE__ */ jsxs14("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
20943
- /* @__PURE__ */ jsx23(Pill3, { label: "Change Image", onClick: onChangeImage }),
20944
- /* @__PURE__ */ jsx23(TogglePill, { label: "Autoplay", on: autoplay, onToggle: onToggleAutoplay })
21636
+ /* @__PURE__ */ jsxs15("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
21637
+ /* @__PURE__ */ jsx24(Pill2, { label: "Change Image", onClick: onChangeImage }),
21638
+ /* @__PURE__ */ jsx24(TogglePill, { label: "Autoplay", on: autoplay, onToggle: onToggleAutoplay })
20945
21639
  ] }),
20946
- error && /* @__PURE__ */ jsx23("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
21640
+ error && /* @__PURE__ */ jsx24("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
20947
21641
  ]
20948
21642
  }
20949
21643
  );
@@ -21083,8 +21777,8 @@ function AiFadeCarouselOverlay({
21083
21777
  const activeItemRect = useLiveItemRect2(active);
21084
21778
  const TOOLBAR_APPROX_H = 90;
21085
21779
  const toolbarState = activeItemRect && activeItemRect.top < TOOLBAR_APPROX_H ? "active-bottom" : "active-top";
21086
- return /* @__PURE__ */ jsxs14(Fragment10, { children: [
21087
- hoverHandleRect && hover && /* @__PURE__ */ jsx23(
21780
+ return /* @__PURE__ */ jsxs15(Fragment10, { children: [
21781
+ hoverHandleRect && hover && /* @__PURE__ */ jsx24(
21088
21782
  "button",
21089
21783
  {
21090
21784
  type: "button",
@@ -21113,10 +21807,10 @@ function AiFadeCarouselOverlay({
21113
21807
  fontSize: 14,
21114
21808
  fontWeight: 700
21115
21809
  },
21116
- children: /* @__PURE__ */ jsx23(Star4, { size: 14, style: { pointerEvents: "none" } })
21810
+ children: /* @__PURE__ */ jsx24(Star4, { size: 14, style: { pointerEvents: "none" } })
21117
21811
  }
21118
21812
  ),
21119
- swapping && /* @__PURE__ */ jsx23(
21813
+ swapping && /* @__PURE__ */ jsx24(
21120
21814
  "div",
21121
21815
  {
21122
21816
  ref: skeletonRef,
@@ -21134,15 +21828,15 @@ function AiFadeCarouselOverlay({
21134
21828
  zIndex: 2147483646,
21135
21829
  pointerEvents: "none"
21136
21830
  },
21137
- children: /* @__PURE__ */ jsx23("style", { children: MEDIA_SKELETON_CSS })
21831
+ children: /* @__PURE__ */ jsx24("style", { children: MEDIA_SKELETON_CSS })
21138
21832
  }
21139
21833
  ),
21140
- activeItemRect && active && activeEntry && /* @__PURE__ */ jsx23(
21834
+ activeItemRect && active && activeEntry && /* @__PURE__ */ jsx24(
21141
21835
  ItemInteractionLayer,
21142
21836
  {
21143
21837
  rect: activeItemRect,
21144
21838
  state: toolbarState,
21145
- toolbar: /* @__PURE__ */ jsx23(
21839
+ toolbar: /* @__PURE__ */ jsx24(
21146
21840
  CarouselSlideToolbar,
21147
21841
  {
21148
21842
  pending,
@@ -21333,118 +22027,11 @@ function mergePrefetchedSections(prev, fetched, livePath, liveSections) {
21333
22027
  // src/ui/link-modal/LinkPopover.tsx
21334
22028
  import { useEffect as useEffect16 } from "react";
21335
22029
 
21336
- // src/ui/dialog.tsx
21337
- import * as React9 from "react";
21338
- import { Dialog as DialogPrimitive } from "radix-ui";
21339
- import { X as X2 } from "lucide-react";
21340
- import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
21341
- function Dialog2({
21342
- ...props
21343
- }) {
21344
- return /* @__PURE__ */ jsx24(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
21345
- }
21346
- function DialogPortal({
21347
- ...props
21348
- }) {
21349
- return /* @__PURE__ */ jsx24(DialogPrimitive.Portal, { ...props });
21350
- }
21351
- function DialogOverlay({
21352
- className,
21353
- ...props
21354
- }) {
21355
- return /* @__PURE__ */ jsx24(
21356
- DialogPrimitive.Overlay,
21357
- {
21358
- "data-slot": "dialog-overlay",
21359
- "data-ohw-link-modal-root": "",
21360
- className: cn("fixed inset-0 z-[2147483646] bg-black/50", className),
21361
- ...props
21362
- }
21363
- );
21364
- }
21365
- var DialogContent = React9.forwardRef(
21366
- ({ className, children, showCloseButton = true, container, ...props }, ref) => {
21367
- const positionMode = container ? "absolute" : "fixed";
21368
- return /* @__PURE__ */ jsxs15(DialogPortal, { container: container ?? void 0, children: [
21369
- /* @__PURE__ */ jsx24(DialogOverlay, { className: cn(positionMode, "inset-0") }),
21370
- /* @__PURE__ */ jsxs15(
21371
- DialogPrimitive.Content,
21372
- {
21373
- ref,
21374
- "data-slot": "dialog-content",
21375
- className: cn(
21376
- positionMode,
21377
- "left-1/2 top-1/2 z-[2147483647] flex w-full max-w-[448px] -translate-x-1/2 -translate-y-1/2 flex-col overflow-visible",
21378
- "rounded-xl border border-border bg-background font-sans shadow-lg outline-none",
21379
- container ? "max-h-[calc(100%-32px)]" : "max-h-[calc(100vh-32px)]",
21380
- className
21381
- ),
21382
- onMouseDown: (e) => e.stopPropagation(),
21383
- ...props,
21384
- children: [
21385
- children,
21386
- showCloseButton ? /* @__PURE__ */ jsx24(
21387
- DialogPrimitive.Close,
21388
- {
21389
- type: "button",
21390
- className: "absolute right-[9px] top-[9px] rounded-sm p-1.5 text-foreground hover:bg-muted/50",
21391
- "aria-label": "Close",
21392
- children: /* @__PURE__ */ jsx24(X2, { size: 16, "aria-hidden": true })
21393
- }
21394
- ) : null
21395
- ]
21396
- }
21397
- )
21398
- ] });
21399
- }
21400
- );
21401
- DialogContent.displayName = DialogPrimitive.Content.displayName;
21402
- function DialogHeader({
21403
- className,
21404
- ...props
21405
- }) {
21406
- return /* @__PURE__ */ jsx24("div", { className: cn("flex flex-col gap-1.5", className), ...props });
21407
- }
21408
- function DialogFooter({
21409
- className,
21410
- ...props
21411
- }) {
21412
- return /* @__PURE__ */ jsx24(
21413
- "div",
21414
- {
21415
- className: cn("flex items-center justify-end gap-2", className),
21416
- ...props
21417
- }
21418
- );
21419
- }
21420
- var DialogTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx24(
21421
- DialogPrimitive.Title,
21422
- {
21423
- ref,
21424
- className: cn(
21425
- "text-lg font-semibold leading-none tracking-tight text-card-foreground",
21426
- className
21427
- ),
21428
- ...props
21429
- }
21430
- ));
21431
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
21432
- var DialogDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx24(
21433
- DialogPrimitive.Description,
21434
- {
21435
- ref,
21436
- className: cn("text-sm text-muted-foreground", className),
21437
- ...props
21438
- }
21439
- ));
21440
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
21441
- var DialogClose = DialogPrimitive.Close;
21442
-
21443
22030
  // src/ui/link-modal/LinkEditorPanel.tsx
21444
22031
  import { Info, X as X4 } from "lucide-react";
21445
22032
 
21446
22033
  // src/ui/link-modal/DestinationBreadcrumb.tsx
21447
- import { ArrowRight as ArrowRight2, File, GalleryVertical } from "lucide-react";
22034
+ import { ArrowRight as ArrowRight3, File, GalleryVertical } from "lucide-react";
21448
22035
  import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
21449
22036
  function DestinationBreadcrumb({
21450
22037
  pageTitle,
@@ -21458,7 +22045,7 @@ function DestinationBreadcrumb({
21458
22045
  /* @__PURE__ */ jsx25("span", { className: "text-sm font-medium leading-none text-foreground!", children: pageTitle })
21459
22046
  ] }),
21460
22047
  /* @__PURE__ */ jsx25(
21461
- ArrowRight2,
22048
+ ArrowRight3,
21462
22049
  {
21463
22050
  size: 16,
21464
22051
  className: "shrink-0 text-muted-foreground",
@@ -21570,7 +22157,7 @@ function Label({ className, ...props }) {
21570
22157
  }
21571
22158
 
21572
22159
  // src/ui/link-modal/UrlOrPageInput.tsx
21573
- import { ChevronDown as ChevronDown4, File as File2, X as X3 } from "lucide-react";
22160
+ import { ChevronDown as ChevronDown5, File as File2, X as X3 } from "lucide-react";
21574
22161
  import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
21575
22162
  function FieldChevron({
21576
22163
  onClick
@@ -21583,7 +22170,7 @@ function FieldChevron({
21583
22170
  onClick,
21584
22171
  "aria-label": "Open page list",
21585
22172
  tabIndex: -1,
21586
- children: /* @__PURE__ */ jsx29(ChevronDown4, { size: 16 })
22173
+ children: /* @__PURE__ */ jsx29(ChevronDown5, { size: 16 })
21587
22174
  }
21588
22175
  );
21589
22176
  }
@@ -21813,7 +22400,7 @@ function LinkEditorPanel({ state, onClose }) {
21813
22400
  // src/ui/link-modal/SectionPickerOverlay.tsx
21814
22401
  import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo2, useRef as useRef10, useState as useState13 } from "react";
21815
22402
  import { createPortal as createPortal2 } from "react-dom";
21816
- import { ArrowLeft as ArrowLeft2, Check as Check3 } from "lucide-react";
22403
+ import { ArrowLeft as ArrowLeft3, Check as Check4 } from "lucide-react";
21817
22404
  import { usePathname as usePathname2, useRouter as useRouter2 } from "next/navigation";
21818
22405
 
21819
22406
  // src/lib/parent-scroll.ts
@@ -22090,7 +22677,7 @@ function SectionPickerOverlay({
22090
22677
  className: "h-8 min-w-0 gap-1 border-border bg-background px-2 py-1.5 shadow-sm hover:bg-muted cursor-pointer",
22091
22678
  onClick: onBack,
22092
22679
  children: [
22093
- /* @__PURE__ */ jsx31(ArrowLeft2, { className: "size-4 shrink-0", "aria-hidden": true }),
22680
+ /* @__PURE__ */ jsx31(ArrowLeft3, { className: "size-4 shrink-0", "aria-hidden": true }),
22094
22681
  "Back"
22095
22682
  ]
22096
22683
  }
@@ -22159,7 +22746,7 @@ function SectionPickerOverlay({
22159
22746
  className: "absolute right-3 top-3 flex size-8 items-center justify-center rounded-full text-white",
22160
22747
  style: { backgroundColor: "var(--ohw-primary, #0885fe)" },
22161
22748
  "aria-hidden": true,
22162
- children: /* @__PURE__ */ jsx31(Check3, { className: "size-5" })
22749
+ children: /* @__PURE__ */ jsx31(Check4, { className: "size-5" })
22163
22750
  }
22164
22751
  ) : null
22165
22752
  ]
@@ -22543,6 +23130,7 @@ function shouldUseDevFixtures() {
22543
23130
  function getLogoElement(el) {
22544
23131
  const marked = el.closest('[data-ohw-role="logo"], [data-ohw-logo]');
22545
23132
  if (marked) return marked;
23133
+ if (el.closest('[data-ohw-editable="icon"]')) return null;
22546
23134
  const root = el.closest("nav, [data-ohw-nav-root], footer");
22547
23135
  if (!root) return null;
22548
23136
  const anchor = el.closest("a");
@@ -22612,7 +23200,7 @@ function addFooterColumnWithPersist({
22612
23200
  import {
22613
23201
  useCallback as useCallback9,
22614
23202
  useEffect as useEffect17,
22615
- useLayoutEffect as useLayoutEffect5,
23203
+ useLayoutEffect as useLayoutEffect6,
22616
23204
  useRef as useRef11,
22617
23205
  useState as useState15
22618
23206
  } from "react";
@@ -22709,7 +23297,7 @@ function FloatingPanel({
22709
23297
  return () => window.removeEventListener("message", onParentScroll);
22710
23298
  }, [open]);
22711
23299
  const positionRef = useRef11(position);
22712
- useLayoutEffect5(() => {
23300
+ useLayoutEffect6(() => {
22713
23301
  if (!open) {
22714
23302
  positionRef.current = position;
22715
23303
  return;
@@ -22719,7 +23307,7 @@ function FloatingPanel({
22719
23307
  }
22720
23308
  positionRef.current = position;
22721
23309
  }, [open, position, liveScroll, parentScroll]);
22722
- useLayoutEffect5(() => {
23310
+ useLayoutEffect6(() => {
22723
23311
  if (!open || !panelRef.current) return;
22724
23312
  const el = panelRef.current;
22725
23313
  const header = el.querySelector("[data-ohw-floating-panel-header]");
@@ -22928,7 +23516,7 @@ function SocialsDisplayPanel({ display, onChange, className }) {
22928
23516
  }
22929
23517
 
22930
23518
  // src/ui/button-style-panel.tsx
22931
- import { Check as Check4 } from "lucide-react";
23519
+ import { Check as Check5 } from "lucide-react";
22932
23520
  import { jsx as jsx35, jsxs as jsxs24 } from "react/jsx-runtime";
22933
23521
  var SIZE_LABEL = { s: "S", m: "M", l: "L" };
22934
23522
  function ButtonStylePanel({
@@ -22999,7 +23587,7 @@ function ButtonStylePanel({
22999
23587
  {
23000
23588
  className: "absolute right-0.5 top-0.5 flex size-5 items-center justify-center rounded-full bg-primary text-primary-foreground",
23001
23589
  "aria-hidden": true,
23002
- children: /* @__PURE__ */ jsx35(Check4, { className: "size-3", strokeWidth: 3 })
23590
+ children: /* @__PURE__ */ jsx35(Check5, { className: "size-3", strokeWidth: 3 })
23003
23591
  }
23004
23592
  ) : null
23005
23593
  ]
@@ -23885,12 +24473,19 @@ function useSectionDrag({
23885
24473
  clearSectionDragVisuals();
23886
24474
  return;
23887
24475
  }
24476
+ const previous = orderBeforeMove(editContentRef.current[SECTION_ORDER_KEY], window.location.pathname);
23888
24477
  const orderJson = JSON.stringify(
23889
24478
  mergePageSectionOrder(editContentRef.current[SECTION_ORDER_KEY], window.location.pathname, entries)
23890
24479
  );
23891
24480
  editContentRef.current = { ...editContentRef.current, [SECTION_ORDER_KEY]: orderJson };
23892
24481
  setAiSectionOrder(orderJson, window.location.pathname);
23893
- postToParentRef.current({ type: "ow:change", nodes: [{ key: SECTION_ORDER_KEY, text: orderJson }] });
24482
+ postToParentRef.current({
24483
+ type: "ow:change",
24484
+ nodes: [{ key: SECTION_ORDER_KEY, text: orderJson }],
24485
+ previous: { [SECTION_ORDER_KEY]: previous },
24486
+ // Undo scrolls to this section; a one-place move swaps two, so the order alone can't say which.
24487
+ moved: session.instanceId
24488
+ });
23894
24489
  applyPersistedOrder(getPageSectionOrderEntries(orderJson, window.location.pathname));
23895
24490
  clearSectionDragVisuals();
23896
24491
  requestAnimationFrame(() => {
@@ -24024,7 +24619,7 @@ function useSectionDrag({
24024
24619
  }
24025
24620
 
24026
24621
  // src/ui/footer-container-chrome.tsx
24027
- import { Plus as Plus3 } from "lucide-react";
24622
+ import { Plus as Plus4 } from "lucide-react";
24028
24623
  import { jsx as jsx36, jsxs as jsxs25 } from "react/jsx-runtime";
24029
24624
  function FooterContainerChrome({
24030
24625
  rect,
@@ -24065,7 +24660,7 @@ function FooterContainerChrome({
24065
24660
  if (addDisabled) return;
24066
24661
  onAdd();
24067
24662
  },
24068
- children: /* @__PURE__ */ jsx36(Plus3, { className: "size-4 shrink-0 text-foreground", "aria-hidden": true })
24663
+ children: /* @__PURE__ */ jsx36(Plus4, { className: "size-4 shrink-0 text-foreground", "aria-hidden": true })
24069
24664
  }
24070
24665
  ) }),
24071
24666
  /* @__PURE__ */ jsx36(TooltipContent, { side: "bottom", sideOffset: 9, children: addDisabled ? "Maximum columns reached" : "Add item" })
@@ -24472,7 +25067,7 @@ function retargetPageLinks(change, deps) {
24472
25067
  }
24473
25068
 
24474
25069
  // src/ui/navbar-container-chrome.tsx
24475
- import { Plus as Plus4 } from "lucide-react";
25070
+ import { Plus as Plus5 } from "lucide-react";
24476
25071
  import { jsx as jsx37 } from "react/jsx-runtime";
24477
25072
  function NavbarContainerChrome({
24478
25073
  rect,
@@ -24508,7 +25103,7 @@ function NavbarContainerChrome({
24508
25103
  e.stopPropagation();
24509
25104
  onAdd();
24510
25105
  },
24511
- children: /* @__PURE__ */ jsx37(Plus4, { className: "size-4 shrink-0 text-foreground", "aria-hidden": true })
25106
+ children: /* @__PURE__ */ jsx37(Plus5, { className: "size-4 shrink-0 text-foreground", "aria-hidden": true })
24512
25107
  }
24513
25108
  )
24514
25109
  }
@@ -24580,7 +25175,7 @@ function Badge({ className, variant, ...props }) {
24580
25175
  }
24581
25176
 
24582
25177
  // src/OhhwellsBridge.tsx
24583
- import { Brush as Brush2, Link as Link2, Plus as Plus5, Settings } from "lucide-react";
25178
+ import { Brush as Brush2, Link as Link2, Plus as Plus6, Settings, Trash2 as Trash24 } from "lucide-react";
24584
25179
  import { Fragment as Fragment13, jsx as jsx40, jsxs as jsxs26 } from "react/jsx-runtime";
24585
25180
  var PRIMARY7 = "#0885FE";
24586
25181
  var IMAGE_FADE_MS = 300;
@@ -25358,7 +25953,7 @@ function getNavigationSelectionParent(el) {
25358
25953
  if (!isFooterLinksContainer(el) && (el.hasAttribute("data-ohw-footer-col") || el.hasAttribute("data-ohw-footer-column") || isInferredFooterGroup2(el))) {
25359
25954
  return resolveFooterLinksContainerFrom(el);
25360
25955
  }
25361
- if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-nav-drawer") || isFooterLinksContainer(el)) {
25956
+ if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-nav-drawer") || el.hasAttribute("data-ohw-footer-col") || el.hasAttribute("data-ohw-footer-column") || isFooterLinksContainer(el) || isInferredFooterGroup2(el)) {
25362
25957
  return getNavigationRoot(el);
25363
25958
  }
25364
25959
  return null;
@@ -25580,7 +26175,6 @@ var ICONS = {
25580
26175
  insertUnorderedList: '<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',
25581
26176
  insertOrderedList: '<line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/>'
25582
26177
  };
25583
- var HEIGHT_SETTLE_DELAYS = [150, 400, 800];
25584
26178
  var SELECTION_CHROME_GAP2 = 4;
25585
26179
  var TOOLBAR_STROKE_GAP2 = 4;
25586
26180
  var TOOLBAR_OFFSET_FROM_ELEMENT = SELECTION_CHROME_GAP2 + TOOLBAR_STROKE_GAP2;
@@ -25678,7 +26272,7 @@ function applyVisibleViewport(el, parentScroll) {
25678
26272
  el.style.top = `${top}px`;
25679
26273
  el.style.height = `${height}px`;
25680
26274
  }
25681
- var TOOLBAR_EDGE_MARGIN3 = 4;
26275
+ var TOOLBAR_EDGE_MARGIN4 = 4;
25682
26276
  function clampToolbarToClip(top, transform, rect, clip, approxH, gap) {
25683
26277
  const isAbove = transform.includes("translateY(-100%)");
25684
26278
  let visualTop = isAbove ? top - approxH : top;
@@ -25705,8 +26299,8 @@ function clampToolbarToClip(top, transform, rect, clip, approxH, gap) {
25705
26299
  function clampToolbarLeft(centerX, toolbarWidth) {
25706
26300
  const half = toolbarWidth / 2;
25707
26301
  return Math.max(
25708
- TOOLBAR_EDGE_MARGIN3 + half,
25709
- Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN3 - half)
26302
+ TOOLBAR_EDGE_MARGIN4 + half,
26303
+ Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN4 - half)
25710
26304
  );
25711
26305
  }
25712
26306
  function calcToolbarPos(rect, parentScroll, toolbarW = 306) {
@@ -25828,7 +26422,10 @@ function FloatingToolbar({
25828
26422
  onCommand,
25829
26423
  activeCommands,
25830
26424
  showEditLink,
25831
- onEditLink
26425
+ onEditLink,
26426
+ showDelete,
26427
+ onDelete,
26428
+ deleteDisabled
25832
26429
  }) {
25833
26430
  const localRef = React12.useRef(null);
25834
26431
  const [measuredW, setMeasuredW] = React12.useState(330);
@@ -25855,7 +26452,7 @@ function FloatingToolbar({
25855
26452
  const ro = new ResizeObserver(update);
25856
26453
  ro.observe(node);
25857
26454
  return () => ro.disconnect();
25858
- }, [showEditLink, activeCommands]);
26455
+ }, [showEditLink, showDelete, activeCommands]);
25859
26456
  const { top, left, transform } = calcToolbarPos(rect, parentScroll, measuredW);
25860
26457
  return /* @__PURE__ */ jsx40(
25861
26458
  "div",
@@ -25920,7 +26517,28 @@ function FloatingToolbar({
25920
26517
  },
25921
26518
  children: /* @__PURE__ */ jsx40(Link2, { className: "size-4 shrink-0", "aria-hidden": true })
25922
26519
  }
25923
- ) : null
26520
+ ) : null,
26521
+ showDelete ? /* @__PURE__ */ jsxs26(Fragment13, { children: [
26522
+ /* @__PURE__ */ jsx40(CustomToolbarDivider, {}),
26523
+ /* @__PURE__ */ jsx40(
26524
+ CustomToolbarButton,
26525
+ {
26526
+ type: "button",
26527
+ title: "Delete",
26528
+ disabled: deleteDisabled,
26529
+ onMouseDown: (e) => {
26530
+ e.preventDefault();
26531
+ e.stopPropagation();
26532
+ if (!deleteDisabled) onDelete?.();
26533
+ },
26534
+ onClick: (e) => {
26535
+ e.preventDefault();
26536
+ e.stopPropagation();
26537
+ },
26538
+ children: /* @__PURE__ */ jsx40(Trash24, { className: "size-4 shrink-0", "aria-hidden": true })
26539
+ }
26540
+ )
26541
+ ] }) : null
25924
26542
  ] })
25925
26543
  }
25926
26544
  );
@@ -26107,7 +26725,7 @@ function OhhwellsBridge() {
26107
26725
  }, []);
26108
26726
  const subdomainFromQuery = searchParams.get("subdomain");
26109
26727
  const [subdomain, setSubdomain] = useState18(() => resolveSubdomain(subdomainFromQuery));
26110
- useLayoutEffect6(() => {
26728
+ useLayoutEffect7(() => {
26111
26729
  const next = resolveSubdomain(subdomainFromQuery);
26112
26730
  if (next !== subdomain) setSubdomain(next);
26113
26731
  if (next) return;
@@ -26534,6 +27152,8 @@ function OhhwellsBridge() {
26534
27152
  const [activeCommands, setActiveCommands] = useState18(/* @__PURE__ */ new Set());
26535
27153
  const [sectionGap, setSectionGap] = useState18(null);
26536
27154
  const [toolbarShowEditLink, setToolbarShowEditLink] = useState18(false);
27155
+ const [toolbarShowAiBlockDelete, setToolbarShowAiBlockDelete] = useState18(false);
27156
+ const deletingAiBlockRef = useRef14(false);
26537
27157
  const hoveredNavContainerRef = useRef14(null);
26538
27158
  const [hoveredNavContainerRect, setHoveredNavContainerRect] = useState18(null);
26539
27159
  const hoveredItemElRef = useRef14(null);
@@ -26589,21 +27209,6 @@ function OhhwellsBridge() {
26589
27209
  const [isItemDragging, setIsItemDragging] = useState18(false);
26590
27210
  const [isFooterFrameSelection, setIsFooterFrameSelection] = useState18(false);
26591
27211
  isFooterFrameSelectionRef.current = isFooterFrameSelection;
26592
- const [floatingPanel, setFloatingPanel] = useState18(null);
26593
- const floatingPanelOpenRef = useRef14(false);
26594
- floatingPanelOpenRef.current = floatingPanel !== null;
26595
- const floatingPanelRef = useRef14(null);
26596
- floatingPanelRef.current = floatingPanel;
26597
- const [floatingPanelPos, setFloatingPanelPos] = useState18(null);
26598
- const buttonCollectionDragRef = useRef14(null);
26599
- const buttonDropInsertIndexRef = useRef14(null);
26600
- const [buttonDropSlots, setButtonDropSlots] = useState18([]);
26601
- const [activeButtonDropIndex, setActiveButtonDropIndex] = useState18(null);
26602
- const buttonPointerDragRef = useRef14(null);
26603
- const [buttonStyleTick, setButtonStyleTick] = useState18(0);
26604
- const [logoSizeDraft, setLogoSizeDraft] = useState18(null);
26605
- const [editorViewport, setEditorViewport] = useState18("desktop");
26606
- const [parentScrollSnap, setParentScrollSnap] = useState18(null);
26607
27212
  const [navDropdownPreviewOpen, setNavDropdownPreviewOpen] = useState18(null);
26608
27213
  const [footerHeadingVisible, setFooterHeadingVisible] = useState18(null);
26609
27214
  const footerDragRef = useRef14(null);
@@ -26630,6 +27235,21 @@ function OhhwellsBridge() {
26630
27235
  const stylesRef = useRef14("");
26631
27236
  const appliedDrawerRef = useRef14(null);
26632
27237
  const pendingDeleteUndoRef = useRef14(null);
27238
+ const [floatingPanel, setFloatingPanel] = useState18(null);
27239
+ const floatingPanelOpenRef = useRef14(false);
27240
+ const floatingPanelRef = useRef14(null);
27241
+ floatingPanelRef.current = floatingPanel;
27242
+ const setFloatingPanelRef = useRef14(setFloatingPanel);
27243
+ const [floatingPanelPos, setFloatingPanelPos] = useState18(null);
27244
+ const buttonCollectionDragRef = useRef14(null);
27245
+ const buttonDropInsertIndexRef = useRef14(null);
27246
+ const [buttonDropSlots, setButtonDropSlots] = useState18([]);
27247
+ const [activeButtonDropIndex, setActiveButtonDropIndex] = useState18(null);
27248
+ const buttonPointerDragRef = useRef14(null);
27249
+ const [buttonStyleTick, setButtonStyleTick] = useState18(0);
27250
+ const [logoSizeDraft, setLogoSizeDraft] = useState18(null);
27251
+ const [editorViewport, setEditorViewport] = useState18("desktop");
27252
+ const [parentScrollSnap, setParentScrollSnap] = useState18(null);
26633
27253
  const [sitePages, setSitePages] = useState18([]);
26634
27254
  const collectionItemsRef = useRef14(/* @__PURE__ */ new Map());
26635
27255
  const [sectionsByPath, setSectionsByPath] = useState18({});
@@ -26639,7 +27259,18 @@ function OhhwellsBridge() {
26639
27259
  const linkPopoverOpenRef = useRef14(false);
26640
27260
  const linkPopoverGraceUntilRef = useRef14(0);
26641
27261
  setLinkPopoverRef.current = setLinkPopover;
27262
+ setFloatingPanelRef.current = setFloatingPanel;
26642
27263
  linkPopoverSessionRef.current = linkPopover;
27264
+ floatingPanelOpenRef.current = Boolean(floatingPanel);
27265
+ useEffect21(() => {
27266
+ const syncViewport = () => {
27267
+ const next = window.innerWidth <= 480 ? "mobile" : "desktop";
27268
+ setEditorViewport((prev) => prev === next ? prev : next);
27269
+ };
27270
+ syncViewport();
27271
+ window.addEventListener("resize", syncViewport);
27272
+ return () => window.removeEventListener("resize", syncViewport);
27273
+ }, []);
26643
27274
  useEffect21(() => {
26644
27275
  setSectionOrderPersistHandler((entries) => {
26645
27276
  const currentPath = window.location.pathname;
@@ -26946,6 +27577,7 @@ function OhhwellsBridge() {
26946
27577
  setMaxBadge(null);
26947
27578
  setActiveCommands(/* @__PURE__ */ new Set());
26948
27579
  setToolbarShowEditLink(false);
27580
+ setToolbarShowAiBlockDelete(false);
26949
27581
  postToParent2({ type: "ow:exit-edit" });
26950
27582
  }, [postToParent2]);
26951
27583
  const clearSelectedAttr = useCallback12(() => {
@@ -27116,6 +27748,7 @@ function OhhwellsBridge() {
27116
27748
  setMaxBadge(null);
27117
27749
  setActiveCommands(/* @__PURE__ */ new Set());
27118
27750
  setToolbarShowEditLink(false);
27751
+ setToolbarShowAiBlockDelete(false);
27119
27752
  postToParent2({ type: "ow:exit-edit" });
27120
27753
  reselectNavigationItem(navAnchor);
27121
27754
  }, [postToParent2, reselectNavigationItem]);
@@ -28286,6 +28919,13 @@ function OhhwellsBridge() {
28286
28919
  }
28287
28920
  }
28288
28921
  setToolbarShowEditLink(Boolean(getHrefKeyFromElement(el)));
28922
+ setToolbarShowAiBlockDelete(
28923
+ canRemoveAiBlock(aiSectionsRef.current, el.dataset.ohwKey ?? null) || canSoftHideEditable(el, {
28924
+ isNavFooterItem: Boolean(
28925
+ getNavigationItemAnchor(el) && isNavFooterScopedNavigationItem(el) && !isCtaButton(el)
28926
+ )
28927
+ })
28928
+ );
28289
28929
  const navAnchor = getNavigationItemAnchor(el);
28290
28930
  if (navAnchor) {
28291
28931
  if (isNestedNavChild(navAnchor)) {
@@ -28346,7 +28986,7 @@ function OhhwellsBridge() {
28346
28986
  isFooterFrameSelection,
28347
28987
  postToParent2
28348
28988
  ]);
28349
- useLayoutEffect6(() => {
28989
+ useLayoutEffect7(() => {
28350
28990
  if (!subdomain || isEditMode) {
28351
28991
  setFetchState("done");
28352
28992
  return;
@@ -28373,6 +29013,7 @@ function OhhwellsBridge() {
28373
29013
  applyAiFooterFromContent(content);
28374
29014
  if (typeof content[STYLE_STORE_KEY] === "string") {
28375
29015
  stylesRef.current = content[STYLE_STORE_KEY];
29016
+ document.querySelectorAll('[data-ohw-editable="form"]').forEach((f) => markFormFields(f));
28376
29017
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
28377
29018
  }
28378
29019
  applyBrandChrome(content);
@@ -28383,15 +29024,16 @@ function OhhwellsBridge() {
28383
29024
  if (key === "__ohw_sections") continue;
28384
29025
  if (key === AI_SECTIONS_KEY) continue;
28385
29026
  if (key === AI_FOOTER_KEY) continue;
29027
+ if (key === LOGO_PLACEHOLDER_KEY) continue;
29028
+ if (LOGO_IMAGE_KEYS.includes(key)) continue;
28386
29029
  if (key === BRAND_KIT_KEY) continue;
28387
29030
  if (key === STYLE_STORE_KEY) continue;
28388
29031
  if (BRAND_CHROME_KEYS.has(key)) continue;
28389
- if (key === LOGO_PLACEHOLDER_KEY) continue;
28390
29032
  if (key === CUSTOM_CODE_AFTER_HEAD_KEY || key === CUSTOM_CODE_BEFORE_HEAD_KEY) continue;
28391
- if (LOGO_IMAGE_KEYS.includes(key)) continue;
28392
29033
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
28393
29034
  continue;
28394
29035
  }
29036
+ if (key.endsWith(SECTION_EMBED_SUFFIX)) continue;
28395
29037
  if (applyVideoSettingNode(key, val)) continue;
28396
29038
  if (applyCarouselNode(key, val)) continue;
28397
29039
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -28431,6 +29073,7 @@ function OhhwellsBridge() {
28431
29073
  });
28432
29074
  applyLinkByKey(key, val);
28433
29075
  }
29076
+ applySectionEmbeds(content);
28434
29077
  applyLogoFromContent(content);
28435
29078
  applyLogoSizes(content);
28436
29079
  reconcileNavbarItemsFromContent(content);
@@ -28439,6 +29082,7 @@ function OhhwellsBridge() {
28439
29082
  applySocialsDisplayFromContent(content);
28440
29083
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28441
29084
  syncButtonsFromContent(document, content);
29085
+ applyHiddenEditablesToDom(content);
28442
29086
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28443
29087
  if (typeof content[STYLE_STORE_KEY] === "string") {
28444
29088
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -28619,20 +29263,22 @@ function OhhwellsBridge() {
28619
29263
  }
28620
29264
  applyAiFooterFromContent(content);
28621
29265
  if (typeof content[STYLE_STORE_KEY] === "string") {
29266
+ document.querySelectorAll('[data-ohw-editable="form"]').forEach((f) => markFormFields(f));
28622
29267
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
28623
29268
  }
28624
29269
  for (const [key, val] of Object.entries(content)) {
28625
29270
  if (key === "__ohw_sections") continue;
28626
29271
  if (key === AI_SECTIONS_KEY) continue;
28627
29272
  if (key === AI_FOOTER_KEY) continue;
29273
+ if (key === LOGO_PLACEHOLDER_KEY) continue;
29274
+ if (LOGO_IMAGE_KEYS.includes(key)) continue;
28628
29275
  if (key === BRAND_KIT_KEY) continue;
28629
29276
  if (key === STYLE_STORE_KEY) continue;
28630
29277
  if (BRAND_CHROME_KEYS.has(key)) continue;
28631
- if (key === LOGO_PLACEHOLDER_KEY) continue;
28632
- if (LOGO_IMAGE_KEYS.includes(key)) continue;
28633
29278
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
28634
29279
  continue;
28635
29280
  }
29281
+ if (key.endsWith(SECTION_EMBED_SUFFIX)) continue;
28636
29282
  if (applyVideoSettingNode(key, val)) continue;
28637
29283
  if (applyCarouselNode(key, val)) continue;
28638
29284
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -28657,6 +29303,7 @@ function OhhwellsBridge() {
28657
29303
  });
28658
29304
  applyLinkByKey(key, val);
28659
29305
  }
29306
+ applySectionEmbeds(content);
28660
29307
  applyLogoFromContent(content);
28661
29308
  reconcileNavbarItemsFromContent(content);
28662
29309
  reconcileFooterOrderFromContent(content);
@@ -28664,6 +29311,7 @@ function OhhwellsBridge() {
28664
29311
  applySocialsDisplayFromContent(content);
28665
29312
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28666
29313
  syncButtonsFromContent(document, content);
29314
+ applyHiddenEditablesToDom(content);
28667
29315
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28668
29316
  if (typeof content[STYLE_STORE_KEY] === "string") {
28669
29317
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -28712,7 +29360,7 @@ function OhhwellsBridge() {
28712
29360
  if (debounceTimer) clearTimeout(debounceTimer);
28713
29361
  };
28714
29362
  }, [subdomain, isEditMode, pathname]);
28715
- useLayoutEffect6(() => {
29363
+ useLayoutEffect7(() => {
28716
29364
  const el = document.getElementById("ohw-loader");
28717
29365
  if (!el) return;
28718
29366
  const visible = Boolean(subdomain) && fetchState !== "done";
@@ -28802,6 +29450,7 @@ function OhhwellsBridge() {
28802
29450
  applySocialsDisplayFromContent(content);
28803
29451
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28804
29452
  syncButtonsFromContent(document, content);
29453
+ applyHiddenEditablesToDom(content);
28805
29454
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28806
29455
  document.querySelectorAll("footer [data-ohw-href-key]").forEach((el) => {
28807
29456
  if (isFooterHrefKey(el.getAttribute("data-ohw-href-key")) || getSocialItem(el)) {
@@ -28896,26 +29545,11 @@ function OhhwellsBridge() {
28896
29545
  const t2 = setTimeout(measure, 500);
28897
29546
  const ro = new ResizeObserver(schedule);
28898
29547
  ro.observe(document.body);
28899
- let lastWidth = window.innerWidth;
28900
- let resizeTimers = [];
28901
- const clearResizeTimers = () => {
28902
- resizeTimers.forEach(clearTimeout);
28903
- resizeTimers = [];
28904
- };
28905
- const handleResize = () => {
28906
- if (window.innerWidth === lastWidth) return;
28907
- lastWidth = window.innerWidth;
28908
- clearResizeTimers();
28909
- resizeTimers = HEIGHT_SETTLE_DELAYS.map((delay) => setTimeout(measure, delay));
28910
- };
28911
- window.addEventListener("resize", handleResize);
28912
29548
  return () => {
28913
29549
  clearTimeout(t1);
28914
29550
  clearTimeout(t2);
28915
29551
  if (raf != null) cancelAnimationFrame(raf);
28916
29552
  ro.disconnect();
28917
- clearResizeTimers();
28918
- window.removeEventListener("resize", handleResize);
28919
29553
  };
28920
29554
  }, [pathname, isEditMode, postToParent2]);
28921
29555
  useEffect21(() => {
@@ -29212,6 +29846,13 @@ function OhhwellsBridge() {
29212
29846
  if (target.closest("[data-ohw-state-toggle]")) return;
29213
29847
  if (target.closest("[data-ohw-max-badge]")) return;
29214
29848
  if (isInsideLinkEditor(target)) return;
29849
+ if (isInsideFloatingPanel(target)) return;
29850
+ if (target.closest("[data-ohw-form-toolbar]")) return;
29851
+ if (target.closest(
29852
+ '[data-ohw-field-toolbar], [data-ohw-field-type-picker], [data-radix-popper-content-wrapper], [role="menu"], [data-slot="dropdown-menu-content"]'
29853
+ )) {
29854
+ return;
29855
+ }
29215
29856
  if (selectedMediaElRef.current && !selectedMediaElRef.current.contains(target) && !target.closest("[data-ohw-media-overlay], [data-ohw-edit-chrome], [data-ohw-item-interaction]")) {
29216
29857
  clearMediaSelectionRef.current();
29217
29858
  }
@@ -29235,8 +29876,6 @@ function OhhwellsBridge() {
29235
29876
  return;
29236
29877
  }
29237
29878
  }
29238
- if (isInsideFloatingPanel(target)) return;
29239
- if (target.closest("[data-ohw-form-toolbar]")) return;
29240
29879
  const collectionItem = matchCollectionItemClick(target, collectionItemsRef.current);
29241
29880
  if (collectionItem) {
29242
29881
  e.preventDefault();
@@ -29248,11 +29887,6 @@ function OhhwellsBridge() {
29248
29887
  });
29249
29888
  return;
29250
29889
  }
29251
- if (target.closest(
29252
- '[data-ohw-field-toolbar], [data-ohw-field-type-picker], [data-radix-popper-content-wrapper], [role="menu"], [data-slot="dropdown-menu-content"]'
29253
- )) {
29254
- return;
29255
- }
29256
29890
  {
29257
29891
  const formEl = getFormElement(target);
29258
29892
  const onSuccessText = target.closest(`[${SUCCESS_TEXT_ATTR}]`);
@@ -29406,9 +30040,13 @@ function OhhwellsBridge() {
29406
30040
  if (isIconEditable(editable) && !getSocialItem(editable)) {
29407
30041
  e.preventDefault();
29408
30042
  e.stopPropagation();
29409
- selectIconElementRef.current(editable);
29410
30043
  const aiIcon = editable.hasAttribute("data-ai-icon");
29411
30044
  const featureIcon = aiIcon && /\.features\.\d+\.icon$/.test(editable.dataset.ohwKey ?? "");
30045
+ if (aiIcon) {
30046
+ aiSectionApiRef.current?.selectFromElement(editable);
30047
+ } else {
30048
+ selectIconElementRef.current(editable);
30049
+ }
29412
30050
  postToParentRef.current({
29413
30051
  type: "ow:icon-pick",
29414
30052
  key: editable.dataset.ohwKey ?? "",
@@ -29636,6 +30274,9 @@ function OhhwellsBridge() {
29636
30274
  setHoveredItemRect(null);
29637
30275
  hoveredNavContainerRef.current = null;
29638
30276
  setHoveredNavContainerRect(null);
30277
+ siblingHintElRef.current = null;
30278
+ setSiblingHintRect(null);
30279
+ setSiblingHintRects([]);
29639
30280
  return;
29640
30281
  }
29641
30282
  {
@@ -29756,7 +30397,6 @@ function OhhwellsBridge() {
29756
30397
  hoveredNavContainerRef.current = null;
29757
30398
  setHoveredNavContainerRect(null);
29758
30399
  hoveredItemElRef.current = editable;
29759
- setHoveredItemRect(isSelectedForHoverRef.current(editable) ? null : editable.getBoundingClientRect());
29760
30400
  }
29761
30401
  }
29762
30402
  }
@@ -30466,7 +31106,11 @@ function OhhwellsBridge() {
30466
31106
  };
30467
31107
  const handleMouseMove = (e) => {
30468
31108
  const { clientX, clientY } = e;
30469
- if (pointOwnedByFloatingPanel(clientX, clientY)) return;
31109
+ if (pointOwnedByFloatingPanel(clientX, clientY)) {
31110
+ dismissImageHover();
31111
+ clearImageHover();
31112
+ return;
31113
+ }
30470
31114
  if (isNavDrawerOpen() && isPointOutsideOpenDrawer(clientX, clientY)) {
30471
31115
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
30472
31116
  formHoverElRef.current = null;
@@ -30495,7 +31139,12 @@ function OhhwellsBridge() {
30495
31139
  setHoveredItemRect(null);
30496
31140
  hoveredNavContainerRef.current = null;
30497
31141
  setHoveredNavContainerRect(null);
31142
+ siblingHintElRef.current = null;
31143
+ setSiblingHintRect(null);
31144
+ setSiblingHintRects([]);
30498
31145
  dismissImageHover();
31146
+ clearImageHover();
31147
+ setSectionGap(null);
30499
31148
  return;
30500
31149
  }
30501
31150
  if (probeSocialsRowAt(clientX, clientY)) return;
@@ -30507,7 +31156,11 @@ function OhhwellsBridge() {
30507
31156
  if (e.data?.type !== "ow:pointer-sync") return;
30508
31157
  const { clientX, clientY } = e.data;
30509
31158
  if (typeof clientX !== "number" || typeof clientY !== "number") return;
30510
- if (pointOwnedByFloatingPanel(clientX, clientY)) return;
31159
+ if (pointOwnedByFloatingPanel(clientX, clientY)) {
31160
+ dismissImageHover();
31161
+ clearImageHover();
31162
+ return;
31163
+ }
30511
31164
  if (isNavDrawerOpen() && isPointOutsideOpenDrawer(clientX, clientY)) return;
30512
31165
  if (probeSocialsRowAt(clientX, clientY)) return;
30513
31166
  probeSectionGapAt(clientX, clientY);
@@ -30887,6 +31540,7 @@ function OhhwellsBridge() {
30887
31540
  applyAiFooterFromContent(content);
30888
31541
  if (typeof content[STYLE_STORE_KEY] === "string") {
30889
31542
  stylesRef.current = content[STYLE_STORE_KEY];
31543
+ document.querySelectorAll('[data-ohw-editable="form"]').forEach((f) => markFormFields(f));
30890
31544
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
30891
31545
  }
30892
31546
  applyBrandChrome(content);
@@ -30901,15 +31555,16 @@ function OhhwellsBridge() {
30901
31555
  }
30902
31556
  if (key === AI_SECTIONS_KEY) continue;
30903
31557
  if (key === AI_FOOTER_KEY) continue;
31558
+ if (key === LOGO_PLACEHOLDER_KEY) continue;
31559
+ if (LOGO_IMAGE_KEYS.includes(key) && !String(val ?? "").trim()) continue;
30904
31560
  if (key === BRAND_KIT_KEY) continue;
30905
31561
  if (key === STYLE_STORE_KEY) continue;
30906
31562
  if (BRAND_CHROME_KEYS.has(key)) continue;
30907
- if (key === LOGO_PLACEHOLDER_KEY) continue;
30908
31563
  if (key === CUSTOM_CODE_AFTER_HEAD_KEY || key === CUSTOM_CODE_BEFORE_HEAD_KEY) continue;
30909
- if (LOGO_IMAGE_KEYS.includes(key) && !String(val ?? "").trim()) continue;
30910
31564
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
30911
31565
  continue;
30912
31566
  }
31567
+ if (key.endsWith(SECTION_EMBED_SUFFIX)) continue;
30913
31568
  if (applyVideoSettingNode(key, val)) continue;
30914
31569
  if (applyCarouselNode(key, val)) continue;
30915
31570
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -30935,6 +31590,7 @@ function OhhwellsBridge() {
30935
31590
  });
30936
31591
  applyLinkByKey(key, val);
30937
31592
  }
31593
+ applySectionEmbeds(content);
30938
31594
  applyLogoFromContent(content);
30939
31595
  applyLogoSizes(content);
30940
31596
  document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
@@ -30949,6 +31605,8 @@ function OhhwellsBridge() {
30949
31605
  reconcileNavbarItemsFromContent(editContentRef.current);
30950
31606
  reconcileFooterOrderFromContent(editContentRef.current);
30951
31607
  syncButtonsFromContent(document, editContentRef.current);
31608
+ applyHiddenEditablesToDom(editContentRef.current);
31609
+ if (selectedElRef.current && !selectedElRef.current.isConnected) deselectRef.current();
30952
31610
  syncNavigationDragCursorAttrs();
30953
31611
  if (typeof content[STYLE_STORE_KEY] === "string") {
30954
31612
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -31380,6 +32038,7 @@ function OhhwellsBridge() {
31380
32038
  const instanceId = typeof e.data.instanceId === "string" ? e.data.instanceId : "";
31381
32039
  const direction = e.data.direction === "up" || e.data.direction === "down" ? e.data.direction : null;
31382
32040
  if (!instanceId || !direction) return;
32041
+ const previous = orderBeforeMove(editContentRef.current[SECTION_ORDER_KEY], window.location.pathname);
31383
32042
  const entries = moveSectionInstance(instanceId, direction, window.location.pathname);
31384
32043
  if (!entries) return;
31385
32044
  const orderJson = JSON.stringify(
@@ -31388,7 +32047,12 @@ function OhhwellsBridge() {
31388
32047
  editContentRef.current = { ...editContentRef.current, [SECTION_ORDER_KEY]: orderJson };
31389
32048
  applyPersistedOrder(getPageSectionOrderEntries(orderJson, window.location.pathname));
31390
32049
  setAiSectionOrder(orderJson, window.location.pathname);
31391
- postToParentRef.current({ type: "ow:change", nodes: [{ key: SECTION_ORDER_KEY, text: orderJson }] });
32050
+ postToParentRef.current({
32051
+ type: "ow:change",
32052
+ nodes: [{ key: SECTION_ORDER_KEY, text: orderJson }],
32053
+ previous: { [SECTION_ORDER_KEY]: previous },
32054
+ moved: instanceId
32055
+ });
31392
32056
  window.dispatchEvent(new Event("resize"));
31393
32057
  };
31394
32058
  window.addEventListener("message", handleMoveSection);
@@ -31567,6 +32231,12 @@ function OhhwellsBridge() {
31567
32231
  closeLinkPopoverRef.current();
31568
32232
  return;
31569
32233
  }
32234
+ if (floatingPanelOpenRef.current) {
32235
+ setFloatingPanelRef.current(null);
32236
+ deselectRef.current();
32237
+ deactivateRef.current();
32238
+ return;
32239
+ }
31570
32240
  deselectRef.current();
31571
32241
  deactivateRef.current();
31572
32242
  clearMediaSelectionRef.current();
@@ -31745,18 +32415,12 @@ function OhhwellsBridge() {
31745
32415
  return;
31746
32416
  }
31747
32417
  }
31748
- if ((e.key === "Delete" || e.key === "Backspace") && selectedElRef.current && !activeElRef.current && !linkPopoverOpenRef.current) {
32418
+ if ((e.key === "Delete" || e.key === "Backspace") && !activeElRef.current && !linkPopoverOpenRef.current && (selectedElRef.current || selectedMediaElRef.current || selectedIconElRef.current)) {
31749
32419
  if (handleDeleteSelectedRef.current()) {
31750
32420
  e.preventDefault();
31751
32421
  return;
31752
32422
  }
31753
32423
  }
31754
- if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z" && !activeElRef.current) {
31755
- if (runPendingDeleteUndoRef.current()) {
31756
- e.preventDefault();
31757
- return;
31758
- }
31759
- }
31760
32424
  if (e.key !== "Escape") return;
31761
32425
  const el = activeElRef.current;
31762
32426
  if (el && originalContentRef.current !== null) {
@@ -32403,10 +33067,10 @@ function OhhwellsBridge() {
32403
33067
  window.removeEventListener("message", handleDuplicateSection);
32404
33068
  window.removeEventListener("message", handleDeactivate);
32405
33069
  window.removeEventListener("message", handleSelectNav);
32406
- document.documentElement.removeAttribute("data-ohw-panel-dragging");
32407
33070
  window.removeEventListener("message", handleToastAction);
32408
33071
  window.removeEventListener("message", handleFormCount);
32409
33072
  window.removeEventListener("message", handleUiEscape);
33073
+ document.documentElement.removeAttribute("data-ohw-panel-dragging");
32410
33074
  autoSaveTimers.current.forEach(clearTimeout);
32411
33075
  autoSaveTimers.current.clear();
32412
33076
  if (imageUnhoverTimerRef.current) clearTimeout(imageUnhoverTimerRef.current);
@@ -32700,7 +33364,7 @@ function OhhwellsBridge() {
32700
33364
  postToParent2({
32701
33365
  type: "ow:ready",
32702
33366
  version: "1",
32703
- bridgeVersion: "0.1.169",
33367
+ bridgeVersion: "0.1.170-next.454",
32704
33368
  path: pathname,
32705
33369
  nodes: collectEditableNodes(editContentRef.current),
32706
33370
  sections
@@ -32901,7 +33565,7 @@ function OhhwellsBridge() {
32901
33565
  const copyHref = result.copy.getAttribute("data-ohw-href-key");
32902
33566
  const copyHrefVal = copyHref ? result.content[copyHref] : void 0;
32903
33567
  if (copyHref && copyHrefVal !== void 0) applyLinkByKey(copyHref, copyHrefVal);
32904
- postToParent2({ type: "ow:change", nodes: result.nodes });
33568
+ postToParent2({ type: "ow:change", nodes: result.nodes, label: "Button duplicated" });
32905
33569
  enforceLinkHrefs();
32906
33570
  requestAnimationFrame(() => {
32907
33571
  selectRef.current(result.copy);
@@ -32950,7 +33614,7 @@ function OhhwellsBridge() {
32950
33614
  ...editContentRef.current,
32951
33615
  ...Object.fromEntries(nodes.map((node) => [node.key, node.text]))
32952
33616
  };
32953
- postToParent2({ type: "ow:change", nodes });
33617
+ postToParent2({ type: "ow:change", nodes, label: "Social icon duplicated" });
32954
33618
  enforceLinkHrefs();
32955
33619
  const copyRow = findSocialsRow(result.item);
32956
33620
  if (copyRow) applySocialsDisplayToRow(copyRow, socialsDisplayFor(copyRow, editContentRef.current));
@@ -33000,7 +33664,7 @@ function OhhwellsBridge() {
33000
33664
  [NAV_COUNT_KEY]: navCount,
33001
33665
  [NAV_ORDER_KEY]: result.orderJson
33002
33666
  };
33003
- postToParent2({ type: "ow:change", nodes });
33667
+ postToParent2({ type: "ow:change", nodes, label: "Link duplicated" });
33004
33668
  enforceLinkHrefs();
33005
33669
  if (isNestedNavChild(selected) || navItemOwnsDropdownPanel(selected)) {
33006
33670
  setNavGroupForceOpen(selected, true);
@@ -33040,7 +33704,8 @@ function OhhwellsBridge() {
33040
33704
  { key: result.hrefKey, text: result.href },
33041
33705
  { key: result.labelKey, text: result.label },
33042
33706
  { key: FOOTER_ORDER_KEY, text: orderJson }
33043
- ]
33707
+ ],
33708
+ label: "Link duplicated"
33044
33709
  });
33045
33710
  enforceLinkHrefs();
33046
33711
  requestAnimationFrame(() => {
@@ -33056,7 +33721,154 @@ function OhhwellsBridge() {
33056
33721
  enforceLinkHrefs();
33057
33722
  return true;
33058
33723
  }, []);
33724
+ const deleteAiBlock = useCallback12(
33725
+ (editKey, opts) => {
33726
+ if (!opts?.fromToolbar && activeElRef.current) return false;
33727
+ if (deletingAiBlockRef.current) return false;
33728
+ const plan = planAiBlockRemoval(aiSectionsRef.current, editKey);
33729
+ if (!plan) return false;
33730
+ if (!plan.ok) {
33731
+ postToParent2({
33732
+ type: "ow:toast",
33733
+ title: plan.reasons[0] ?? "That block cannot be deleted",
33734
+ toastType: "error"
33735
+ });
33736
+ return true;
33737
+ }
33738
+ const { tree: nextTree, entry } = plan;
33739
+ const previous = aiSectionsRef.current;
33740
+ deletingAiBlockRef.current = true;
33741
+ void requestValidateTree5(postToParent2, nextTree).then(({ ok, reasons }) => {
33742
+ deletingAiBlockRef.current = false;
33743
+ if (!ok) {
33744
+ postToParent2({
33745
+ type: "ow:toast",
33746
+ title: reasons[0] ?? "That change is not allowed.",
33747
+ toastType: "error"
33748
+ });
33749
+ return;
33750
+ }
33751
+ clearMediaSelectionRef.current();
33752
+ clearIconSelectionRef.current();
33753
+ applyTreeLocalRef.current?.({
33754
+ id: entry.id,
33755
+ mode: "replace",
33756
+ targetSectionId: entry.id,
33757
+ tree: nextTree,
33758
+ label: entry.label,
33759
+ media: entry.media,
33760
+ ...entry.brand ? { brand: entry.brand } : {},
33761
+ skipScrollIntoView: true
33762
+ });
33763
+ const actionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `delete-block-${Date.now()}`;
33764
+ pendingDeleteUndoRef.current = {
33765
+ actionId,
33766
+ restore: () => {
33767
+ clearInteractionChromeRef.current();
33768
+ aiSectionsRef.current = previous;
33769
+ applyAiSectionsToDom(parseAiSectionsState(previous));
33770
+ const restoreHeight = document.body.scrollHeight;
33771
+ if (restoreHeight > 50) postToParent2({ type: "ow:height", height: restoreHeight });
33772
+ postToParent2({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: previous }] });
33773
+ postToParent2({
33774
+ type: "ow:ai-sections-changed",
33775
+ sections: collectSections(),
33776
+ nodes: collectEditableNodes(editContentRef.current)
33777
+ });
33778
+ }
33779
+ };
33780
+ postToParent2({
33781
+ type: "ow:toast",
33782
+ title: "Block deleted",
33783
+ toastType: "success",
33784
+ actionLabel: "Undo",
33785
+ actionId,
33786
+ duration: 6e3
33787
+ });
33788
+ });
33789
+ return true;
33790
+ },
33791
+ [postToParent2]
33792
+ );
33793
+ const softHideTemplateEditable = useCallback12(
33794
+ (el, opts) => {
33795
+ if (!opts?.fromToolbar && activeElRef.current) return false;
33796
+ if (!canSoftHideEditable(el, {
33797
+ isNavFooterItem: Boolean(
33798
+ getNavigationItemAnchor(el) && isNavFooterScopedNavigationItem(el) && !isCtaButton(el)
33799
+ )
33800
+ })) {
33801
+ return false;
33802
+ }
33803
+ const previousContent = editContentRef.current;
33804
+ const result = softHideEditableInDom(el, previousContent);
33805
+ if (!result) return false;
33806
+ editContentRef.current = result.content;
33807
+ postToParent2({ type: "ow:change", nodes: result.nodes });
33808
+ clearMediaSelectionRef.current();
33809
+ clearIconSelectionRef.current();
33810
+ clearInteractionChromeRef.current();
33811
+ clearFormPickRef.current?.();
33812
+ deselectRef.current();
33813
+ const actionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `hide-editable-${Date.now()}`;
33814
+ const hiddenKey = result.key;
33815
+ pendingDeleteUndoRef.current = {
33816
+ actionId,
33817
+ restore: () => {
33818
+ clearInteractionChromeRef.current();
33819
+ const restored = softUnhideEditableInDom(hiddenKey, editContentRef.current);
33820
+ editContentRef.current = restored.content;
33821
+ postToParent2({ type: "ow:change", nodes: restored.nodes });
33822
+ const restoreHeight = document.body.scrollHeight;
33823
+ if (restoreHeight > 50) postToParent2({ type: "ow:height", height: restoreHeight });
33824
+ }
33825
+ };
33826
+ postToParent2({
33827
+ type: "ow:toast",
33828
+ title: "Block deleted",
33829
+ toastType: "success",
33830
+ actionLabel: "Undo",
33831
+ actionId,
33832
+ duration: 6e3
33833
+ });
33834
+ return true;
33835
+ },
33836
+ [postToParent2]
33837
+ );
33838
+ const deleteFromToolbar = useCallback12(
33839
+ (editKey, el) => {
33840
+ if (!editKey && !el) return false;
33841
+ if (editKey && canRemoveAiBlock(aiSectionsRef.current, editKey)) {
33842
+ return deleteAiBlock(editKey, { fromToolbar: true });
33843
+ }
33844
+ const target = el ?? (editKey ? document.querySelector(`[data-ohw-key="${editKey.replace(/"/g, '\\"')}"]`) : null);
33845
+ if (target) return softHideTemplateEditable(target, { fromToolbar: true });
33846
+ return false;
33847
+ },
33848
+ [deleteAiBlock, softHideTemplateEditable]
33849
+ );
33850
+ const resolveSelectedAiBlockKey = useCallback12(() => {
33851
+ const candidates = [
33852
+ activeElRef.current?.dataset.ohwKey,
33853
+ selectedMediaElRef.current?.dataset.ohwKey,
33854
+ selectedMedia?.key,
33855
+ selectedIconElRef.current?.dataset.ohwKey,
33856
+ selectedElRef.current?.getAttribute("data-ohw-href-key"),
33857
+ selectedElRef.current?.dataset.ohwKey,
33858
+ selectedElRef.current?.querySelector("[data-ohw-key]")?.dataset.ohwKey
33859
+ ];
33860
+ for (const key of candidates) {
33861
+ if (key && canRemoveAiBlock(aiSectionsRef.current, key)) return key;
33862
+ }
33863
+ return null;
33864
+ }, [selectedMedia]);
33059
33865
  const handleDeleteSelected = useCallback12(() => {
33866
+ if (!activeElRef.current) {
33867
+ const aiKey = resolveSelectedAiBlockKey();
33868
+ if (aiKey && deleteAiBlock(aiKey)) return true;
33869
+ const mediaEl = selectedMediaElRef.current;
33870
+ if (mediaEl && softHideTemplateEditable(mediaEl, { fromToolbar: true })) return true;
33871
+ }
33060
33872
  const selected = selectedElRef.current;
33061
33873
  if (!selected) return false;
33062
33874
  if (isCtaButton(selected)) {
@@ -33115,7 +33927,7 @@ function OhhwellsBridge() {
33115
33927
  }
33116
33928
  }
33117
33929
  return deleted;
33118
- }, [postToParent2]);
33930
+ }, [postToParent2, deleteAiBlock, softHideTemplateEditable, resolveSelectedAiBlockKey]);
33119
33931
  handleDeleteSelectedRef.current = handleDeleteSelected;
33120
33932
  runPendingDeleteUndoRef.current = runPendingDeleteUndo;
33121
33933
  const handleLinkPopoverSubmit = useCallback12(
@@ -33333,6 +34145,13 @@ function OhhwellsBridge() {
33333
34145
  isUploading: false,
33334
34146
  onReplace: handleMediaReplace,
33335
34147
  onSelect: handleMediaSelect,
34148
+ onDelete: canRemoveAiBlock(aiSectionsRef.current, selectedMedia.key) || selectedMediaElRef.current != null && canSoftHideEditable(selectedMediaElRef.current, {
34149
+ isNavFooterItem: Boolean(
34150
+ getNavigationItemAnchor(selectedMediaElRef.current) && isNavFooterScopedNavigationItem(selectedMediaElRef.current) && !isCtaButton(selectedMediaElRef.current)
34151
+ )
34152
+ }) ? (key) => {
34153
+ deleteFromToolbar(key, selectedMediaElRef.current);
34154
+ } : void 0,
33336
34155
  onVideoSettingsChange: handleVideoSettingsChange
33337
34156
  }
33338
34157
  ),
@@ -33435,7 +34254,7 @@ function OhhwellsBridge() {
33435
34254
  className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/80",
33436
34255
  onClick: () => setFieldTypePickerOpen((open) => !open),
33437
34256
  "data-ohw-add-field": "",
33438
- children: /* @__PURE__ */ jsx40(Plus5, { size: 15, "aria-hidden": true })
34257
+ children: /* @__PURE__ */ jsx40(Plus6, { size: 15, "aria-hidden": true })
33439
34258
  }
33440
34259
  ),
33441
34260
  /* @__PURE__ */ jsx40("div", { className: "mx-0.5 h-5 w-px bg-border" }),
@@ -33497,7 +34316,24 @@ function OhhwellsBridge() {
33497
34316
  children: state
33498
34317
  },
33499
34318
  state
33500
- )) })
34319
+ )) }),
34320
+ /* @__PURE__ */ jsx40("div", { className: "mx-0.5 h-5 w-px bg-border" }),
34321
+ /* @__PURE__ */ jsx40(
34322
+ "button",
34323
+ {
34324
+ type: "button",
34325
+ "aria-label": "Delete form",
34326
+ title: "Delete",
34327
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/80",
34328
+ onClick: () => {
34329
+ setFieldTypePickerOpen(false);
34330
+ const form = formPickElRef.current;
34331
+ if (!form) return;
34332
+ softHideTemplateEditable(form, { fromToolbar: true });
34333
+ },
34334
+ children: /* @__PURE__ */ jsx40(Trash24, { size: 15, "aria-hidden": true })
34335
+ }
34336
+ )
33501
34337
  ]
33502
34338
  }
33503
34339
  )
@@ -33666,7 +34502,15 @@ function OhhwellsBridge() {
33666
34502
  onCommand: handleCommand,
33667
34503
  activeCommands,
33668
34504
  showEditLink,
33669
- onEditLink: openLinkPopoverForActive
34505
+ onEditLink: openLinkPopoverForActive,
34506
+ showDelete: toolbarShowAiBlockDelete,
34507
+ deleteDisabled: deletingAiBlockRef.current,
34508
+ onDelete: () => {
34509
+ const el = activeElRef.current;
34510
+ const key = el?.dataset.ohwKey;
34511
+ if (!key) return;
34512
+ deleteFromToolbar(key, el);
34513
+ }
33670
34514
  }
33671
34515
  )
33672
34516
  ] }),
@@ -33895,6 +34739,7 @@ export {
33895
34739
  FOOTER_COLUMN_BLOCKS,
33896
34740
  FOOTER_COLUMN_SPANS,
33897
34741
  FOOTER_SOCIAL_PLATFORMS,
34742
+ HIDDEN_EDITABLES_KEY,
33898
34743
  ItemActionToolbar,
33899
34744
  ItemInteractionLayer,
33900
34745
  LinkEditorPanel,
@@ -33917,9 +34762,14 @@ export {
33917
34762
  addFooterLinkColumn,
33918
34763
  appendFooterSocial,
33919
34764
  applyBrandChrome,
34765
+ applyHiddenEditablesToDom,
33920
34766
  applyStickySearchParams,
34767
+ blockPathFromEditKey,
33921
34768
  buildDefaultFooterTree,
33922
34769
  buildTarget,
34770
+ canRemoveAiBlock,
34771
+ canRemoveAiTextBlock,
34772
+ canSoftHideEditable,
33923
34773
  dropIndicatorVariants,
33924
34774
  ensureFooterTree,
33925
34775
  filterAvailablePages,
@@ -33930,6 +34780,7 @@ export {
33930
34780
  insertFooterHours,
33931
34781
  isDeadPageHref,
33932
34782
  isEditSessionActive,
34783
+ isEditableKeyHidden,
33933
34784
  isPlainLeftClick,
33934
34785
  isRenderableFooterTree,
33935
34786
  isRenderableTree,
@@ -33940,15 +34791,22 @@ export {
33940
34791
  parseAiFooterState,
33941
34792
  parseAiSectionsState,
33942
34793
  parseTarget,
34794
+ planAiBlockRemoval,
34795
+ planAiTextBlockRemoval,
33943
34796
  planBuildPageSync,
34797
+ readHiddenEditables,
33944
34798
  recordOverriddenPaths,
33945
34799
  releaseTemplateLogoIfReplaced,
34800
+ removeBlockAtPath,
33946
34801
  removeFooterBlock,
33947
34802
  resetOverriddenPathsCache,
33948
34803
  resolveFooterCopyright,
34804
+ resolveSoftHideTarget,
33949
34805
  resolveStickyNavigation,
33950
34806
  serializeAiFooterState,
33951
34807
  shouldFetchContentForPath,
34808
+ softHideEditableInDom,
34809
+ softUnhideEditableInDom,
33952
34810
  stepViableSlide,
33953
34811
  stripPlaceholderText,
33954
34812
  stripPlaceholders,
@@ -33956,6 +34814,8 @@ export {
33956
34814
  toggleVariants,
33957
34815
  useOhwCarousel,
33958
34816
  validateUrlInput,
33959
- viableSlides
34817
+ viableSlides,
34818
+ withHiddenEditable,
34819
+ withoutHiddenEditable
33960
34820
  };
33961
34821
  //# sourceMappingURL=index.js.map