@ohhwells/bridge 0.1.171 → 0.1.172

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
@@ -5199,6 +5199,118 @@ function deleteNavbarItem(sourceAnchor) {
5199
5199
  };
5200
5200
  }
5201
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
+
5202
5314
  // src/lib/collect-editable-nodes.ts
5203
5315
  var VIDEO_AUTOPLAY_SUFFIX = "__ohw_autoplay";
5204
5316
  var VIDEO_MUTED_SUFFIX = "__ohw_muted";
@@ -5277,7 +5389,9 @@ function collectEditableNodes(extraContent, root = document) {
5277
5389
  BUTTON_ASSIGNMENTS_KEY,
5278
5390
  BUTTON_COLLECTIONS_KEY,
5279
5391
  BUTTON_SNAPSHOTS_KEY,
5280
- BUTTON_HIDDEN_KEY
5392
+ BUTTON_HIDDEN_KEY,
5393
+ // Soft-hidden template slots (non-AI Delete) — no DOM marker when hidden.
5394
+ HIDDEN_EDITABLES_KEY
5281
5395
  ]) {
5282
5396
  const text = extraContent[key];
5283
5397
  if (typeof text === "string" && text.length > 0) {
@@ -6837,6 +6951,127 @@ function rewriteIconSlot(tree, path, ref) {
6837
6951
  return next;
6838
6952
  }
6839
6953
 
6954
+ // src/lib/ai-remove-block.ts
6955
+ function blockPathFromEditKey(sectionId, key) {
6956
+ const prefix = aiSlotKeyPrefixFor(sectionId);
6957
+ if (!key.startsWith(prefix)) return void 0;
6958
+ const path = [];
6959
+ for (const part of key.slice(prefix.length).split(".")) {
6960
+ if (/^[rbc]\d+$/.test(part)) path.push(part);
6961
+ else break;
6962
+ }
6963
+ if (path.length < 2 || !/^r\d+$/.test(path[0]) || !/^b\d+$/.test(path[1])) return void 0;
6964
+ return path.join(".");
6965
+ }
6966
+ function parseBlockPath(path) {
6967
+ const segs = [];
6968
+ for (const part of path.split(".")) {
6969
+ const match = part.match(/^([rbc])(\d+)$/);
6970
+ if (!match) return void 0;
6971
+ segs.push({ kind: match[1], index: Number(match[2]) });
6972
+ }
6973
+ if (segs.length < 2 || segs[0].kind !== "r" || segs[1].kind !== "b") return void 0;
6974
+ return segs;
6975
+ }
6976
+ function cloneTree(tree) {
6977
+ return JSON.parse(JSON.stringify(tree));
6978
+ }
6979
+ function nodeAtPath2(tree, segs) {
6980
+ let node = tree.rows?.[segs[0].index]?.blocks?.[segs[1].index];
6981
+ for (let i = 2; i < segs.length; i += 1) {
6982
+ if (segs[i].kind !== "c") return null;
6983
+ node = node?.children?.[segs[i].index];
6984
+ }
6985
+ return node ?? null;
6986
+ }
6987
+ function unwrapPromoted(node) {
6988
+ if (node.promoted === true && node.slots?.layout === "stack" && (node.children?.length ?? 0) === 1) {
6989
+ const only = { ...node.children[0] };
6990
+ if (node.slot) only.slot = node.slot;
6991
+ only.span = node.span;
6992
+ return only;
6993
+ }
6994
+ return node;
6995
+ }
6996
+ function removeBlockAtPath(tree, path) {
6997
+ const segs = parseBlockPath(path);
6998
+ if (!segs) return { ok: false, reasons: [`invalid block path "${path}"`] };
6999
+ const next = cloneTree(tree);
7000
+ const rowIndex = segs[0].index;
7001
+ const row = next.rows[rowIndex];
7002
+ if (!row) return { ok: false, reasons: [`row ${rowIndex} not found`] };
7003
+ if (segs.length === 2) {
7004
+ const blockIndex = segs[1].index;
7005
+ if (!row.blocks[blockIndex]) return { ok: false, reasons: [`block ${path} not found`] };
7006
+ row.blocks.splice(blockIndex, 1);
7007
+ if (row.blocks.length === 0) {
7008
+ next.rows.splice(rowIndex, 1);
7009
+ } else if (row.blocks.length === 1) {
7010
+ row.blocks[0] = { ...row.blocks[0], span: 12 };
7011
+ delete row.blocks[0].slot;
7012
+ }
7013
+ } else {
7014
+ let parent = row.blocks[segs[1].index];
7015
+ for (let i = 2; i < segs.length - 1; i += 1) {
7016
+ if (!parent?.children || segs[i].kind !== "c") {
7017
+ return { ok: false, reasons: [`block ${path} not found`] };
7018
+ }
7019
+ parent = parent.children[segs[i].index];
7020
+ }
7021
+ const childIndex = segs[segs.length - 1].index;
7022
+ if (!parent?.children || segs[segs.length - 1].kind !== "c" || !parent.children[childIndex]) {
7023
+ return { ok: false, reasons: [`block ${path} not found`] };
7024
+ }
7025
+ parent.children.splice(childIndex, 1);
7026
+ if (segs.length === 3) {
7027
+ row.blocks[segs[1].index] = unwrapPromoted(parent);
7028
+ if (row.blocks[segs[1].index].type === "group" && (row.blocks[segs[1].index].children?.length ?? 0) === 0) {
7029
+ row.blocks.splice(segs[1].index, 1);
7030
+ if (row.blocks.length === 0) next.rows.splice(rowIndex, 1);
7031
+ }
7032
+ if (next.rows[rowIndex]?.blocks.length === 1) {
7033
+ next.rows[rowIndex].blocks[0] = { ...next.rows[rowIndex].blocks[0], span: 12 };
7034
+ delete next.rows[rowIndex].blocks[0].slot;
7035
+ }
7036
+ } else {
7037
+ const grand = row.blocks[segs[1].index];
7038
+ let cursor = grand;
7039
+ for (let i = 2; i < segs.length - 2; i += 1) {
7040
+ cursor = cursor?.children?.[segs[i].index];
7041
+ }
7042
+ const containerIndex = segs[segs.length - 2].index;
7043
+ if (cursor?.children?.[containerIndex]) {
7044
+ cursor.children[containerIndex] = unwrapPromoted(parent);
7045
+ }
7046
+ }
7047
+ }
7048
+ if (next.rows.length === 0) {
7049
+ return { ok: false, reasons: ["a section must keep at least one block"] };
7050
+ }
7051
+ return { ok: true, tree: next };
7052
+ }
7053
+ function planAiBlockRemoval(aiSectionsRaw, editKey) {
7054
+ if (!editKey || !editKey.startsWith("ai.")) return null;
7055
+ const state = parseAiSectionsState(aiSectionsRaw);
7056
+ const entry = state.sections.find((s) => editKey.startsWith(aiSlotKeyPrefixFor(s.id)));
7057
+ if (!entry) return null;
7058
+ const path = blockPathFromEditKey(entry.id, editKey);
7059
+ if (!path) return null;
7060
+ const segs = parseBlockPath(path);
7061
+ if (!segs) return null;
7062
+ const node = nodeAtPath2(entry.tree, segs);
7063
+ if (!node) return null;
7064
+ const removed = removeBlockAtPath(entry.tree, path);
7065
+ if (!removed.ok) return removed;
7066
+ return { ok: true, tree: removed.tree, path, entry };
7067
+ }
7068
+ var planAiTextBlockRemoval = planAiBlockRemoval;
7069
+ function canRemoveAiBlock(aiSectionsRaw, editKey) {
7070
+ const plan = planAiBlockRemoval(aiSectionsRaw, editKey);
7071
+ return plan?.ok === true;
7072
+ }
7073
+ var canRemoveAiTextBlock = canRemoveAiBlock;
7074
+
6840
7075
  // src/lib/ai-footer-tree.ts
6841
7076
  var FOOTER_COLUMN_SPANS = [12, 6, 4, 3];
6842
7077
  var FOOTER_COLUMN_BLOCKS = [
@@ -7936,12 +8171,19 @@ function footerBodyStyle(fallbackFont, color, weight = 500) {
7936
8171
  }
7937
8172
  var str = (value) => typeof value === "string" ? value : "";
7938
8173
  var cardRadius = (slots) => slots.cornerStyle === "sharp" ? 0 : AI_TREE_TOKENS.radiusCard;
7939
- var blockAlignStyle = (blockAlign) => blockAlign ? {
7940
- display: "flex",
7941
- flexDirection: "column",
7942
- alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
7943
- textAlign: blockAlign
7944
- } : {};
8174
+ var HUG_ALIGN_TYPES = /* @__PURE__ */ new Set(["button", "button-row", "rating"]);
8175
+ var blockAlignStyle = (blockAlign, blockType) => {
8176
+ if (!blockAlign) return {};
8177
+ if (blockType && HUG_ALIGN_TYPES.has(blockType)) {
8178
+ return {
8179
+ display: "flex",
8180
+ flexDirection: "column",
8181
+ alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
8182
+ textAlign: blockAlign
8183
+ };
8184
+ }
8185
+ return { width: "100%", textAlign: blockAlign, boxSizing: "border-box" };
8186
+ };
7945
8187
  var fullBleedBlock = (block) => block.type === "carousel" || block.type === "group" && str(block.slots?.layout) === "overlap";
7946
8188
  var featureLines = (value) => value.split(/\n|<br\s*\/?>/i).map((line) => line.trim()).filter(Boolean);
7947
8189
  var AI_MOBILE_CSS = [
@@ -8464,7 +8706,13 @@ function TextBlock({
8464
8706
  "div",
8465
8707
  {
8466
8708
  ...textAttrs(ctx, `${path}.content`),
8467
- style: { ...typeStyle(spec, font), color: ctx.brand.palette.dark, textAlign: align },
8709
+ style: {
8710
+ ...typeStyle(spec, font),
8711
+ color: ctx.brand.palette.dark,
8712
+ textAlign: align,
8713
+ width: "100%",
8714
+ boxSizing: "border-box"
8715
+ },
8468
8716
  dangerouslySetInnerHTML: { __html: str(slots.content) }
8469
8717
  }
8470
8718
  );
@@ -8475,7 +8723,7 @@ function SectionHeaderBlock({ node, ctx, path }) {
8475
8723
  const children = node.children ?? [];
8476
8724
  const buttonRowIdx = children.findIndex((c) => c.type === "button-row");
8477
8725
  const buttonRow = buttonRowIdx >= 0 ? children[buttonRowIdx] : void 0;
8478
- return /* @__PURE__ */ jsxs("div", { style: { textAlign: align }, children: [
8726
+ return /* @__PURE__ */ jsxs("div", { style: { textAlign: align, width: "100%", boxSizing: "border-box" }, children: [
8479
8727
  str(slots.tagline) && /* @__PURE__ */ jsx(
8480
8728
  "div",
8481
8729
  {
@@ -10094,10 +10342,10 @@ function renderNode(node, ctx, path, ambientAlign) {
10094
10342
  gridColumn: `span ${typeof child.span === "number" ? Math.min(12, Math.max(1, child.span)) : 12}`,
10095
10343
  minWidth: 0
10096
10344
  } : { minWidth: 0 },
10097
- // A child's own `align` (or the group's inherited `ambientAlign`, e.g. from an
10098
- // `overlap` overlay layer — see renderNode) positions it within this column; a stack
10099
- // child otherwise stretches full-width (unchanged pre-existing behaviour).
10100
- ...blockAlignStyle(child.align ?? ambientAlign)
10345
+ // Same ambient as renderNode below: child's own align, else the group's, else the
10346
+ // inherited ambient (overlap overlay / section). Copy fills the column; button-row
10347
+ // etc. still hug via flex alignItems.
10348
+ ...blockAlignStyle(child.align ?? node.align ?? ambientAlign, child.type)
10101
10349
  },
10102
10350
  children: renderNode(child, ctx, `${path}.c${i}`, node.align ?? ambientAlign)
10103
10351
  },
@@ -10466,12 +10714,7 @@ function AiTreeRenderer({
10466
10714
  if (fillHeight) return "stretch";
10467
10715
  return (distributed ?? settings.verticalPosition) === "top" ? "start" : "center";
10468
10716
  };
10469
- const cellAlignStyle = (blockAlign) => blockAlign ? {
10470
- display: "flex",
10471
- flexDirection: "column",
10472
- alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
10473
- textAlign: blockAlign
10474
- } : {};
10717
+ const cellAlignStyle = (blockAlign, blockType) => blockAlignStyle(blockAlign, blockType);
10475
10718
  const needsOverlayClearance = fillHeight && pad === 0;
10476
10719
  return /* @__PURE__ */ jsxs(
10477
10720
  "section",
@@ -10531,11 +10774,11 @@ function AiTreeRenderer({
10531
10774
  gridColumn: `span ${Math.min(12, Math.max(1, block.span))}`,
10532
10775
  minWidth: 0,
10533
10776
  // Cascades the section's min-height stretch (see `fillHeight` above) down to
10534
- // this cell; `cellAlignStyle` below overrides to `flex` when the block also has
10535
- // its own horizontal `align`, which takes priority for that block.
10777
+ // this cell; `cellAlignStyle` below overrides when the block also has its own
10778
+ // horizontal `align` (flex hug for buttons; width 100% for text).
10536
10779
  ...fillHeight ? { display: "grid" } : {},
10537
10780
  // Horizontal placement of the block's content within its column.
10538
- ...fullBleedBlock(block) ? {} : cellAlignStyle(block.align),
10781
+ ...fullBleedBlock(block) ? {} : cellAlignStyle(block.align, block.type),
10539
10782
  // space-between: each column becomes a flex column whose content spreads over
10540
10783
  // the full row height instead of clumping at the top.
10541
10784
  ...distributed === "space-between" ? { display: "flex", flexDirection: "column", justifyContent: "space-between" } : {}
@@ -11259,7 +11502,7 @@ import { createRoot as createRoot2 } from "react-dom/client";
11259
11502
  import { flushSync as flushSync2 } from "react-dom";
11260
11503
  import { jsx as jsx3 } from "react/jsx-runtime";
11261
11504
  var CONTAINER_ATTR2 = "data-ohw-ai-footer";
11262
- var HIDDEN_ATTR = "data-ohw-ai-footer-replaced";
11505
+ var HIDDEN_ATTR2 = "data-ohw-ai-footer-replaced";
11263
11506
  var mounted2 = null;
11264
11507
  var mountOptions = {};
11265
11508
  var capturedSurface;
@@ -11289,12 +11532,12 @@ function findTemplateFooter() {
11289
11532
  function hideTemplateFooter(footer) {
11290
11533
  if (!footer) return;
11291
11534
  footer.style.display = "none";
11292
- footer.setAttribute(HIDDEN_ATTR, "");
11535
+ footer.setAttribute(HIDDEN_ATTR2, "");
11293
11536
  }
11294
11537
  function showTemplateFooter() {
11295
- for (const el of document.querySelectorAll(`[${HIDDEN_ATTR}]`)) {
11538
+ for (const el of document.querySelectorAll(`[${HIDDEN_ATTR2}]`)) {
11296
11539
  el.style.removeProperty("display");
11297
- el.removeAttribute(HIDDEN_ATTR);
11540
+ el.removeAttribute(HIDDEN_ATTR2);
11298
11541
  }
11299
11542
  }
11300
11543
  function unmountAiFooter() {
@@ -11489,7 +11732,7 @@ function pickFooterColumnIndex(columnBlockCounts) {
11489
11732
  }
11490
11733
 
11491
11734
  // src/lib/ai-footer-edits.ts
11492
- function cloneTree(tree) {
11735
+ function cloneTree2(tree) {
11493
11736
  return JSON.parse(JSON.stringify(tree));
11494
11737
  }
11495
11738
  function rebalanceFooterColumnSpans(columns) {
@@ -11539,7 +11782,7 @@ function countFooterLinkLists(tree) {
11539
11782
  return collectLinkListBlocks(tree).length;
11540
11783
  }
11541
11784
  function packFooterTreeBrand(tree) {
11542
- const next = cloneTree(tree);
11785
+ const next = cloneTree2(tree);
11543
11786
  const brand = collectBrandBlocks(next);
11544
11787
  const lists = collectLinkListBlocks(next);
11545
11788
  if (lists.length === 0) {
@@ -11624,7 +11867,7 @@ function ensureFooterTree(tree, opts) {
11624
11867
  return tree ?? buildDefaultFooterTree(opts);
11625
11868
  }
11626
11869
  function appendFooterSocial(tree, entry) {
11627
- const next = cloneTree(tree);
11870
+ const next = cloneTree2(tree);
11628
11871
  const platform = entry.platform.trim().toLowerCase();
11629
11872
  const href = entry.href.trim();
11630
11873
  for (const col2 of next.columns) {
@@ -11653,7 +11896,7 @@ function appendFooterSocial(tree, entry) {
11653
11896
  return next;
11654
11897
  }
11655
11898
  function insertFooterHours(tree, hours, title = "Hours") {
11656
- const next = cloneTree(tree);
11899
+ const next = cloneTree2(tree);
11657
11900
  const idx = pickFooterColumnIndex(next.columns.map((c) => c.blocks.length));
11658
11901
  const col = next.columns[idx] ?? next.columns[0];
11659
11902
  if (!col) return next;
@@ -11680,7 +11923,7 @@ function addFooterLinkColumn(tree, column) {
11680
11923
  return next;
11681
11924
  }
11682
11925
  function removeFooterBlock(tree, predicate) {
11683
- const next = cloneTree(tree);
11926
+ const next = cloneTree2(tree);
11684
11927
  for (let c = 0; c < next.columns.length; c++) {
11685
11928
  const col = next.columns[c];
11686
11929
  if (!col) continue;
@@ -11716,7 +11959,7 @@ function foldAiFooterSlotOverride(tree, key, value) {
11716
11959
  const path = key.slice(prefix.length);
11717
11960
  const brandMatch = path.match(/^brand\.b(\d+)\.(.+)$/);
11718
11961
  if (!brandMatch) return null;
11719
- const next = cloneTree(tree);
11962
+ const next = cloneTree2(tree);
11720
11963
  const brands = [];
11721
11964
  for (const col of next.columns) {
11722
11965
  for (const block2 of col.blocks) {
@@ -11761,7 +12004,7 @@ function textOf2(el) {
11761
12004
  return (el?.textContent ?? "").replace(/\s+/g, " ").trim();
11762
12005
  }
11763
12006
  function syncFooterTreeLinksFromDom(tree) {
11764
- const next = cloneTree(tree);
12007
+ const next = cloneTree2(tree);
11765
12008
  const domCols = listFooterColumns().map((col) => {
11766
12009
  const heading = getFooterColumnHeadingEl(col);
11767
12010
  const title = heading ? textOf2(heading) : void 0;
@@ -12242,7 +12485,7 @@ var PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]-?/g;
12242
12485
  var HAS_PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]/;
12243
12486
  var SKIPPED_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "NOSCRIPT", "TEXTAREA", "CODE", "PRE"]);
12244
12487
  var TEXT_ATTRS = ["alt", "title", "aria-label", "placeholder"];
12245
- var HIDDEN_ATTR2 = "data-ohw-placeholder-hidden";
12488
+ var HIDDEN_ATTR3 = "data-ohw-placeholder-hidden";
12246
12489
  function hasPlaceholder(text) {
12247
12490
  return HAS_PLACEHOLDER_RE.test(text);
12248
12491
  }
@@ -12261,10 +12504,10 @@ function skipped(el) {
12261
12504
  }
12262
12505
  function hideIfEmptied(el) {
12263
12506
  const control = el?.closest("a, button");
12264
- if (!control || control.hasAttribute(HIDDEN_ATTR2)) return;
12507
+ if (!control || control.hasAttribute(HIDDEN_ATTR3)) return;
12265
12508
  if ((control.textContent ?? "").trim()) return;
12266
12509
  if (control.querySelector("img, svg, picture, video")) return;
12267
- control.setAttribute(HIDDEN_ATTR2, "");
12510
+ control.setAttribute(HIDDEN_ATTR3, "");
12268
12511
  control.style.display = "none";
12269
12512
  }
12270
12513
  function stripElementAttrs(el) {
@@ -17413,10 +17656,10 @@ function ItemInteractionLayer({
17413
17656
  }
17414
17657
 
17415
17658
  // src/lib/forms.ts
17416
- var FORM_SELECTOR = '[data-ohw-editable="form"]';
17659
+ var FORM_SELECTOR2 = '[data-ohw-editable="form"]';
17417
17660
  function getFormElement(el) {
17418
17661
  if (!el) return null;
17419
- return el.closest(FORM_SELECTOR);
17662
+ return el.closest(FORM_SELECTOR2);
17420
17663
  }
17421
17664
  function formKeyOf(form) {
17422
17665
  return form.getAttribute("data-ohw-key");
@@ -17477,7 +17720,7 @@ function clearSubmitError(form) {
17477
17720
  if (note) note.style.display = "none";
17478
17721
  }
17479
17722
  var SUCCESS_TEXT_ATTR = "data-ohw-form-success-text";
17480
- var HIDDEN_ATTR3 = "data-ohw-form-hidden";
17723
+ var HIDDEN_ATTR4 = "data-ohw-form-hidden";
17481
17724
  var DEFAULT_SUCCESS_TEXT = "Thanks! We'll be in touch.";
17482
17725
  function formSuccessKey(formKey) {
17483
17726
  return `${formKey}-success`;
@@ -17503,13 +17746,13 @@ function setFormViewState(form, formKey, state, initialText) {
17503
17746
  Array.from(form.children).forEach((child) => {
17504
17747
  if (!(child instanceof HTMLElement) || child === success) return;
17505
17748
  if (state === "success") {
17506
- if (!child.hasAttribute(HIDDEN_ATTR3)) {
17507
- child.setAttribute(HIDDEN_ATTR3, child.style.display);
17749
+ if (!child.hasAttribute(HIDDEN_ATTR4)) {
17750
+ child.setAttribute(HIDDEN_ATTR4, child.style.display);
17508
17751
  child.style.display = "none";
17509
17752
  }
17510
- } else if (child.hasAttribute(HIDDEN_ATTR3)) {
17511
- child.style.display = child.getAttribute(HIDDEN_ATTR3) ?? "";
17512
- child.removeAttribute(HIDDEN_ATTR3);
17753
+ } else if (child.hasAttribute(HIDDEN_ATTR4)) {
17754
+ child.style.display = child.getAttribute(HIDDEN_ATTR4) ?? "";
17755
+ child.removeAttribute(HIDDEN_ATTR4);
17513
17756
  }
17514
17757
  });
17515
17758
  success.style.display = state === "success" ? "" : "none";
@@ -17528,7 +17771,7 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
17528
17771
  "submit",
17529
17772
  async (e) => {
17530
17773
  const target = e.target;
17531
- const form = target?.closest(FORM_SELECTOR);
17774
+ const form = target?.closest(FORM_SELECTOR2);
17532
17775
  if (!form || !(form instanceof HTMLFormElement)) return;
17533
17776
  const formKey = formKeyOf(form);
17534
17777
  if (!formKey) return;
@@ -17574,7 +17817,7 @@ function apiBase() {
17574
17817
  function bridgeVersion() {
17575
17818
  try {
17576
17819
  if (true) {
17577
- return "0.1.171";
17820
+ return "0.1.172";
17578
17821
  }
17579
17822
  } catch {
17580
17823
  }
@@ -17588,7 +17831,7 @@ function stampBridgeVersionOnDocument() {
17588
17831
  return;
17589
17832
  }
17590
17833
  try {
17591
- const v = true ? "0.1.171" : "";
17834
+ const v = true ? "0.1.172" : "";
17592
17835
  if (v) {
17593
17836
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17594
17837
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -18159,7 +18402,7 @@ function FieldTypePicker({ onPick }) {
18159
18402
 
18160
18403
  // src/ui/MediaOverlay.tsx
18161
18404
  import * as React8 from "react";
18162
- import { Film, ImageIcon, Pause, Play as Play2, Volume2, VolumeX } from "lucide-react";
18405
+ import { Film, ImageIcon, Pause, Play as Play2, Trash2 as Trash23, Volume2, VolumeX } from "lucide-react";
18163
18406
 
18164
18407
  // src/ui/button.tsx
18165
18408
  import * as React7 from "react";
@@ -18249,6 +18492,7 @@ function MediaOverlay({
18249
18492
  onFadeOutComplete,
18250
18493
  onReplace,
18251
18494
  onSelect,
18495
+ onDelete,
18252
18496
  onVideoSettingsChange
18253
18497
  }) {
18254
18498
  const { rect } = hover;
@@ -18402,35 +18646,66 @@ function MediaOverlay({
18402
18646
  }
18403
18647
  ),
18404
18648
  replaceMode === "none" || cueOnly ? null : /* @__PURE__ */ jsxs8(
18405
- Button,
18649
+ "div",
18406
18650
  {
18407
- "data-ohw-media-overlay": "",
18408
- variant: "outline",
18409
- size: "sm",
18410
- "aria-label": isVideo ? "Replace video" : "Replace image",
18411
- className: "gap-1.5 cursor-pointer hover:bg-background",
18412
- style: {
18413
- ...OVERLAY_BUTTON_STYLE,
18414
- // Icon-only is a square of the same height, so the pair can never differ vertically.
18415
- // `minWidth` has to go too: the button's own size carries `min-w-[64px]`, and a
18416
- // minimum beats a width — the square came out wider than the avatar it sat on.
18417
- ...replaceMode === "icon" && buttonSize ? {
18418
- width: buttonSize.height,
18419
- minWidth: buttonSize.height,
18420
- padding: 0,
18421
- justifyContent: "center"
18422
- } : null,
18423
- // Don't let Replace steal clicks when text (e.g. nav) sits on top of this media.
18424
- pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto"
18425
- },
18426
- onMouseDown: (e) => e.preventDefault(),
18427
- onClick: (e) => {
18428
- e.stopPropagation();
18429
- onReplace(hover.key);
18430
- },
18651
+ className: "flex items-center gap-1.5",
18652
+ style: { pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto" },
18653
+ onClick: (e) => e.stopPropagation(),
18431
18654
  children: [
18432
- isVideo ? /* @__PURE__ */ jsx17(Film, { size: 14 }) : /* @__PURE__ */ jsx17(ImageIcon, { size: 14 }),
18433
- replaceMode === "full" ? isVideo ? "Replace video" : hover.elementType === "bg-image" ? "Replace background" : "Replace image" : null
18655
+ /* @__PURE__ */ jsxs8(
18656
+ Button,
18657
+ {
18658
+ "data-ohw-media-overlay": "",
18659
+ variant: "outline",
18660
+ size: "sm",
18661
+ "aria-label": isVideo ? "Replace video" : "Replace image",
18662
+ className: "gap-1.5 cursor-pointer hover:bg-background",
18663
+ style: {
18664
+ ...OVERLAY_BUTTON_STYLE,
18665
+ // Icon-only is a square of the same height, so the pair can never differ vertically.
18666
+ // `minWidth` has to go too: the button's own size carries `min-w-[64px]`, and a
18667
+ // minimum beats a width — the square came out wider than the avatar it sat on.
18668
+ ...replaceMode === "icon" && buttonSize ? {
18669
+ width: buttonSize.height,
18670
+ minWidth: buttonSize.height,
18671
+ padding: 0,
18672
+ justifyContent: "center"
18673
+ } : null
18674
+ },
18675
+ onMouseDown: (e) => e.preventDefault(),
18676
+ onClick: (e) => {
18677
+ e.stopPropagation();
18678
+ onReplace(hover.key);
18679
+ },
18680
+ children: [
18681
+ isVideo ? /* @__PURE__ */ jsx17(Film, { size: 14 }) : /* @__PURE__ */ jsx17(ImageIcon, { size: 14 }),
18682
+ replaceMode === "full" ? isVideo ? "Replace video" : hover.elementType === "bg-image" ? "Replace background" : "Replace image" : null
18683
+ ]
18684
+ }
18685
+ ),
18686
+ selected && onDelete ? /* @__PURE__ */ jsx17(
18687
+ Button,
18688
+ {
18689
+ "data-ohw-media-overlay": "",
18690
+ variant: "outline",
18691
+ size: "sm",
18692
+ "aria-label": "Delete",
18693
+ title: "Delete",
18694
+ className: "cursor-pointer hover:bg-background",
18695
+ style: {
18696
+ ...OVERLAY_BUTTON_STYLE,
18697
+ minWidth: 0,
18698
+ padding: buttonSize ? `0 ${(buttonSize.height - 14) / 2}px` : "0 8px",
18699
+ height: buttonSize?.height
18700
+ },
18701
+ onMouseDown: (e) => e.preventDefault(),
18702
+ onClick: (e) => {
18703
+ e.stopPropagation();
18704
+ onDelete(hover.key);
18705
+ },
18706
+ children: /* @__PURE__ */ jsx17(Trash23, { size: 14 })
18707
+ }
18708
+ ) : null
18434
18709
  ]
18435
18710
  }
18436
18711
  )
@@ -24698,7 +24973,7 @@ function Badge({ className, variant, ...props }) {
24698
24973
  }
24699
24974
 
24700
24975
  // src/OhhwellsBridge.tsx
24701
- import { Brush as Brush2, Link as Link2, Plus as Plus5, Settings } from "lucide-react";
24976
+ import { Brush as Brush2, Link as Link2, Plus as Plus5, Settings, Trash2 as Trash24 } from "lucide-react";
24702
24977
  import { Fragment as Fragment13, jsx as jsx40, jsxs as jsxs26 } from "react/jsx-runtime";
24703
24978
  var PRIMARY7 = "#0885FE";
24704
24979
  var IMAGE_FADE_MS = 300;
@@ -25946,7 +26221,10 @@ function FloatingToolbar({
25946
26221
  onCommand,
25947
26222
  activeCommands,
25948
26223
  showEditLink,
25949
- onEditLink
26224
+ onEditLink,
26225
+ showDelete,
26226
+ onDelete,
26227
+ deleteDisabled
25950
26228
  }) {
25951
26229
  const localRef = React12.useRef(null);
25952
26230
  const [measuredW, setMeasuredW] = React12.useState(330);
@@ -25973,7 +26251,7 @@ function FloatingToolbar({
25973
26251
  const ro = new ResizeObserver(update);
25974
26252
  ro.observe(node);
25975
26253
  return () => ro.disconnect();
25976
- }, [showEditLink, activeCommands]);
26254
+ }, [showEditLink, showDelete, activeCommands]);
25977
26255
  const { top, left, transform } = calcToolbarPos(rect, parentScroll, measuredW);
25978
26256
  return /* @__PURE__ */ jsx40(
25979
26257
  "div",
@@ -26038,7 +26316,28 @@ function FloatingToolbar({
26038
26316
  },
26039
26317
  children: /* @__PURE__ */ jsx40(Link2, { className: "size-4 shrink-0", "aria-hidden": true })
26040
26318
  }
26041
- ) : null
26319
+ ) : null,
26320
+ showDelete ? /* @__PURE__ */ jsxs26(Fragment13, { children: [
26321
+ /* @__PURE__ */ jsx40(CustomToolbarDivider, {}),
26322
+ /* @__PURE__ */ jsx40(
26323
+ CustomToolbarButton,
26324
+ {
26325
+ type: "button",
26326
+ title: "Delete",
26327
+ disabled: deleteDisabled,
26328
+ onMouseDown: (e) => {
26329
+ e.preventDefault();
26330
+ e.stopPropagation();
26331
+ if (!deleteDisabled) onDelete?.();
26332
+ },
26333
+ onClick: (e) => {
26334
+ e.preventDefault();
26335
+ e.stopPropagation();
26336
+ },
26337
+ children: /* @__PURE__ */ jsx40(Trash24, { className: "size-4 shrink-0", "aria-hidden": true })
26338
+ }
26339
+ )
26340
+ ] }) : null
26042
26341
  ] })
26043
26342
  }
26044
26343
  );
@@ -26652,6 +26951,8 @@ function OhhwellsBridge() {
26652
26951
  const [activeCommands, setActiveCommands] = useState18(/* @__PURE__ */ new Set());
26653
26952
  const [sectionGap, setSectionGap] = useState18(null);
26654
26953
  const [toolbarShowEditLink, setToolbarShowEditLink] = useState18(false);
26954
+ const [toolbarShowAiBlockDelete, setToolbarShowAiBlockDelete] = useState18(false);
26955
+ const deletingAiBlockRef = useRef14(false);
26655
26956
  const hoveredNavContainerRef = useRef14(null);
26656
26957
  const [hoveredNavContainerRect, setHoveredNavContainerRect] = useState18(null);
26657
26958
  const hoveredItemElRef = useRef14(null);
@@ -27064,6 +27365,7 @@ function OhhwellsBridge() {
27064
27365
  setMaxBadge(null);
27065
27366
  setActiveCommands(/* @__PURE__ */ new Set());
27066
27367
  setToolbarShowEditLink(false);
27368
+ setToolbarShowAiBlockDelete(false);
27067
27369
  postToParent2({ type: "ow:exit-edit" });
27068
27370
  }, [postToParent2]);
27069
27371
  const clearSelectedAttr = useCallback12(() => {
@@ -27234,6 +27536,7 @@ function OhhwellsBridge() {
27234
27536
  setMaxBadge(null);
27235
27537
  setActiveCommands(/* @__PURE__ */ new Set());
27236
27538
  setToolbarShowEditLink(false);
27539
+ setToolbarShowAiBlockDelete(false);
27237
27540
  postToParent2({ type: "ow:exit-edit" });
27238
27541
  reselectNavigationItem(navAnchor);
27239
27542
  }, [postToParent2, reselectNavigationItem]);
@@ -28404,6 +28707,13 @@ function OhhwellsBridge() {
28404
28707
  }
28405
28708
  }
28406
28709
  setToolbarShowEditLink(Boolean(getHrefKeyFromElement(el)));
28710
+ setToolbarShowAiBlockDelete(
28711
+ canRemoveAiBlock(aiSectionsRef.current, el.dataset.ohwKey ?? null) || canSoftHideEditable(el, {
28712
+ isNavFooterItem: Boolean(
28713
+ getNavigationItemAnchor(el) && isNavFooterScopedNavigationItem(el) && !isCtaButton(el)
28714
+ )
28715
+ })
28716
+ );
28407
28717
  const navAnchor = getNavigationItemAnchor(el);
28408
28718
  if (navAnchor) {
28409
28719
  if (isNestedNavChild(navAnchor)) {
@@ -28557,6 +28867,7 @@ function OhhwellsBridge() {
28557
28867
  applySocialsDisplayFromContent(content);
28558
28868
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28559
28869
  syncButtonsFromContent(document, content);
28870
+ applyHiddenEditablesToDom(content);
28560
28871
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28561
28872
  if (typeof content[STYLE_STORE_KEY] === "string") {
28562
28873
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -28782,6 +29093,7 @@ function OhhwellsBridge() {
28782
29093
  applySocialsDisplayFromContent(content);
28783
29094
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28784
29095
  syncButtonsFromContent(document, content);
29096
+ applyHiddenEditablesToDom(content);
28785
29097
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28786
29098
  if (typeof content[STYLE_STORE_KEY] === "string") {
28787
29099
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -28920,6 +29232,7 @@ function OhhwellsBridge() {
28920
29232
  applySocialsDisplayFromContent(content);
28921
29233
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28922
29234
  syncButtonsFromContent(document, content);
29235
+ applyHiddenEditablesToDom(content);
28923
29236
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28924
29237
  document.querySelectorAll("footer [data-ohw-href-key]").forEach((el) => {
28925
29238
  if (isFooterHrefKey(el.getAttribute("data-ohw-href-key")) || getSocialItem(el)) {
@@ -31067,6 +31380,7 @@ function OhhwellsBridge() {
31067
31380
  reconcileNavbarItemsFromContent(editContentRef.current);
31068
31381
  reconcileFooterOrderFromContent(editContentRef.current);
31069
31382
  syncButtonsFromContent(document, editContentRef.current);
31383
+ applyHiddenEditablesToDom(editContentRef.current);
31070
31384
  if (selectedElRef.current && !selectedElRef.current.isConnected) deselectRef.current();
31071
31385
  syncNavigationDragCursorAttrs();
31072
31386
  if (typeof content[STYLE_STORE_KEY] === "string") {
@@ -31870,7 +32184,7 @@ function OhhwellsBridge() {
31870
32184
  return;
31871
32185
  }
31872
32186
  }
31873
- if ((e.key === "Delete" || e.key === "Backspace") && selectedElRef.current && !activeElRef.current && !linkPopoverOpenRef.current) {
32187
+ if ((e.key === "Delete" || e.key === "Backspace") && !activeElRef.current && !linkPopoverOpenRef.current && (selectedElRef.current || selectedMediaElRef.current || selectedIconElRef.current)) {
31874
32188
  if (handleDeleteSelectedRef.current()) {
31875
32189
  e.preventDefault();
31876
32190
  return;
@@ -32819,7 +33133,7 @@ function OhhwellsBridge() {
32819
33133
  postToParent2({
32820
33134
  type: "ow:ready",
32821
33135
  version: "1",
32822
- bridgeVersion: "0.1.171",
33136
+ bridgeVersion: "0.1.172",
32823
33137
  path: pathname,
32824
33138
  nodes: collectEditableNodes(editContentRef.current),
32825
33139
  sections
@@ -33176,7 +33490,154 @@ function OhhwellsBridge() {
33176
33490
  enforceLinkHrefs();
33177
33491
  return true;
33178
33492
  }, []);
33493
+ const deleteAiBlock = useCallback12(
33494
+ (editKey, opts) => {
33495
+ if (!opts?.fromToolbar && activeElRef.current) return false;
33496
+ if (deletingAiBlockRef.current) return false;
33497
+ const plan = planAiBlockRemoval(aiSectionsRef.current, editKey);
33498
+ if (!plan) return false;
33499
+ if (!plan.ok) {
33500
+ postToParent2({
33501
+ type: "ow:toast",
33502
+ title: plan.reasons[0] ?? "That block cannot be deleted",
33503
+ toastType: "error"
33504
+ });
33505
+ return true;
33506
+ }
33507
+ const { tree: nextTree, entry } = plan;
33508
+ const previous = aiSectionsRef.current;
33509
+ deletingAiBlockRef.current = true;
33510
+ void requestValidateTree5(postToParent2, nextTree).then(({ ok, reasons }) => {
33511
+ deletingAiBlockRef.current = false;
33512
+ if (!ok) {
33513
+ postToParent2({
33514
+ type: "ow:toast",
33515
+ title: reasons[0] ?? "That change is not allowed.",
33516
+ toastType: "error"
33517
+ });
33518
+ return;
33519
+ }
33520
+ clearMediaSelectionRef.current();
33521
+ clearIconSelectionRef.current();
33522
+ applyTreeLocalRef.current?.({
33523
+ id: entry.id,
33524
+ mode: "replace",
33525
+ targetSectionId: entry.id,
33526
+ tree: nextTree,
33527
+ label: entry.label,
33528
+ media: entry.media,
33529
+ ...entry.brand ? { brand: entry.brand } : {},
33530
+ skipScrollIntoView: true
33531
+ });
33532
+ const actionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `delete-block-${Date.now()}`;
33533
+ pendingDeleteUndoRef.current = {
33534
+ actionId,
33535
+ restore: () => {
33536
+ clearInteractionChromeRef.current();
33537
+ aiSectionsRef.current = previous;
33538
+ applyAiSectionsToDom(parseAiSectionsState(previous));
33539
+ const restoreHeight = document.body.scrollHeight;
33540
+ if (restoreHeight > 50) postToParent2({ type: "ow:height", height: restoreHeight });
33541
+ postToParent2({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: previous }] });
33542
+ postToParent2({
33543
+ type: "ow:ai-sections-changed",
33544
+ sections: collectSections(),
33545
+ nodes: collectEditableNodes(editContentRef.current)
33546
+ });
33547
+ }
33548
+ };
33549
+ postToParent2({
33550
+ type: "ow:toast",
33551
+ title: "Block deleted",
33552
+ toastType: "success",
33553
+ actionLabel: "Undo",
33554
+ actionId,
33555
+ duration: 6e3
33556
+ });
33557
+ });
33558
+ return true;
33559
+ },
33560
+ [postToParent2]
33561
+ );
33562
+ const softHideTemplateEditable = useCallback12(
33563
+ (el, opts) => {
33564
+ if (!opts?.fromToolbar && activeElRef.current) return false;
33565
+ if (!canSoftHideEditable(el, {
33566
+ isNavFooterItem: Boolean(
33567
+ getNavigationItemAnchor(el) && isNavFooterScopedNavigationItem(el) && !isCtaButton(el)
33568
+ )
33569
+ })) {
33570
+ return false;
33571
+ }
33572
+ const previousContent = editContentRef.current;
33573
+ const result = softHideEditableInDom(el, previousContent);
33574
+ if (!result) return false;
33575
+ editContentRef.current = result.content;
33576
+ postToParent2({ type: "ow:change", nodes: result.nodes });
33577
+ clearMediaSelectionRef.current();
33578
+ clearIconSelectionRef.current();
33579
+ clearInteractionChromeRef.current();
33580
+ clearFormPickRef.current?.();
33581
+ deselectRef.current();
33582
+ const actionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `hide-editable-${Date.now()}`;
33583
+ const hiddenKey = result.key;
33584
+ pendingDeleteUndoRef.current = {
33585
+ actionId,
33586
+ restore: () => {
33587
+ clearInteractionChromeRef.current();
33588
+ const restored = softUnhideEditableInDom(hiddenKey, editContentRef.current);
33589
+ editContentRef.current = restored.content;
33590
+ postToParent2({ type: "ow:change", nodes: restored.nodes });
33591
+ const restoreHeight = document.body.scrollHeight;
33592
+ if (restoreHeight > 50) postToParent2({ type: "ow:height", height: restoreHeight });
33593
+ }
33594
+ };
33595
+ postToParent2({
33596
+ type: "ow:toast",
33597
+ title: "Block deleted",
33598
+ toastType: "success",
33599
+ actionLabel: "Undo",
33600
+ actionId,
33601
+ duration: 6e3
33602
+ });
33603
+ return true;
33604
+ },
33605
+ [postToParent2]
33606
+ );
33607
+ const deleteFromToolbar = useCallback12(
33608
+ (editKey, el) => {
33609
+ if (!editKey && !el) return false;
33610
+ if (editKey && canRemoveAiBlock(aiSectionsRef.current, editKey)) {
33611
+ return deleteAiBlock(editKey, { fromToolbar: true });
33612
+ }
33613
+ const target = el ?? (editKey ? document.querySelector(`[data-ohw-key="${editKey.replace(/"/g, '\\"')}"]`) : null);
33614
+ if (target) return softHideTemplateEditable(target, { fromToolbar: true });
33615
+ return false;
33616
+ },
33617
+ [deleteAiBlock, softHideTemplateEditable]
33618
+ );
33619
+ const resolveSelectedAiBlockKey = useCallback12(() => {
33620
+ const candidates = [
33621
+ activeElRef.current?.dataset.ohwKey,
33622
+ selectedMediaElRef.current?.dataset.ohwKey,
33623
+ selectedMedia?.key,
33624
+ selectedIconElRef.current?.dataset.ohwKey,
33625
+ selectedElRef.current?.getAttribute("data-ohw-href-key"),
33626
+ selectedElRef.current?.dataset.ohwKey,
33627
+ selectedElRef.current?.querySelector("[data-ohw-key]")?.dataset.ohwKey
33628
+ ];
33629
+ for (const key of candidates) {
33630
+ if (key && canRemoveAiBlock(aiSectionsRef.current, key)) return key;
33631
+ }
33632
+ return null;
33633
+ }, [selectedMedia]);
33179
33634
  const handleDeleteSelected = useCallback12(() => {
33635
+ if (!activeElRef.current) {
33636
+ const aiKey = resolveSelectedAiBlockKey();
33637
+ if (aiKey && deleteAiBlock(aiKey)) return true;
33638
+ const mediaEl = selectedMediaElRef.current;
33639
+ if (mediaEl && softHideTemplateEditable(mediaEl, { fromToolbar: true })) return true;
33640
+ }
33180
33641
  const selected = selectedElRef.current;
33181
33642
  if (!selected) return false;
33182
33643
  if (isCtaButton(selected)) {
@@ -33235,7 +33696,7 @@ function OhhwellsBridge() {
33235
33696
  }
33236
33697
  }
33237
33698
  return deleted;
33238
- }, [postToParent2]);
33699
+ }, [postToParent2, deleteAiBlock, softHideTemplateEditable, resolveSelectedAiBlockKey]);
33239
33700
  handleDeleteSelectedRef.current = handleDeleteSelected;
33240
33701
  runPendingDeleteUndoRef.current = runPendingDeleteUndo;
33241
33702
  const handleLinkPopoverSubmit = useCallback12(
@@ -33453,6 +33914,13 @@ function OhhwellsBridge() {
33453
33914
  isUploading: false,
33454
33915
  onReplace: handleMediaReplace,
33455
33916
  onSelect: handleMediaSelect,
33917
+ onDelete: canRemoveAiBlock(aiSectionsRef.current, selectedMedia.key) || selectedMediaElRef.current != null && canSoftHideEditable(selectedMediaElRef.current, {
33918
+ isNavFooterItem: Boolean(
33919
+ getNavigationItemAnchor(selectedMediaElRef.current) && isNavFooterScopedNavigationItem(selectedMediaElRef.current) && !isCtaButton(selectedMediaElRef.current)
33920
+ )
33921
+ }) ? (key) => {
33922
+ deleteFromToolbar(key, selectedMediaElRef.current);
33923
+ } : void 0,
33456
33924
  onVideoSettingsChange: handleVideoSettingsChange
33457
33925
  }
33458
33926
  ),
@@ -33617,7 +34085,24 @@ function OhhwellsBridge() {
33617
34085
  children: state
33618
34086
  },
33619
34087
  state
33620
- )) })
34088
+ )) }),
34089
+ /* @__PURE__ */ jsx40("div", { className: "mx-0.5 h-5 w-px bg-border" }),
34090
+ /* @__PURE__ */ jsx40(
34091
+ "button",
34092
+ {
34093
+ type: "button",
34094
+ "aria-label": "Delete form",
34095
+ title: "Delete",
34096
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/80",
34097
+ onClick: () => {
34098
+ setFieldTypePickerOpen(false);
34099
+ const form = formPickElRef.current;
34100
+ if (!form) return;
34101
+ softHideTemplateEditable(form, { fromToolbar: true });
34102
+ },
34103
+ children: /* @__PURE__ */ jsx40(Trash24, { size: 15, "aria-hidden": true })
34104
+ }
34105
+ )
33621
34106
  ]
33622
34107
  }
33623
34108
  )
@@ -33786,7 +34271,15 @@ function OhhwellsBridge() {
33786
34271
  onCommand: handleCommand,
33787
34272
  activeCommands,
33788
34273
  showEditLink,
33789
- onEditLink: openLinkPopoverForActive
34274
+ onEditLink: openLinkPopoverForActive,
34275
+ showDelete: toolbarShowAiBlockDelete,
34276
+ deleteDisabled: deletingAiBlockRef.current,
34277
+ onDelete: () => {
34278
+ const el = activeElRef.current;
34279
+ const key = el?.dataset.ohwKey;
34280
+ if (!key) return;
34281
+ deleteFromToolbar(key, el);
34282
+ }
33790
34283
  }
33791
34284
  )
33792
34285
  ] }),
@@ -34015,6 +34508,7 @@ export {
34015
34508
  FOOTER_COLUMN_BLOCKS,
34016
34509
  FOOTER_COLUMN_SPANS,
34017
34510
  FOOTER_SOCIAL_PLATFORMS,
34511
+ HIDDEN_EDITABLES_KEY,
34018
34512
  ItemActionToolbar,
34019
34513
  ItemInteractionLayer,
34020
34514
  LinkEditorPanel,
@@ -34037,9 +34531,14 @@ export {
34037
34531
  addFooterLinkColumn,
34038
34532
  appendFooterSocial,
34039
34533
  applyBrandChrome,
34534
+ applyHiddenEditablesToDom,
34040
34535
  applyStickySearchParams,
34536
+ blockPathFromEditKey,
34041
34537
  buildDefaultFooterTree,
34042
34538
  buildTarget,
34539
+ canRemoveAiBlock,
34540
+ canRemoveAiTextBlock,
34541
+ canSoftHideEditable,
34043
34542
  dropIndicatorVariants,
34044
34543
  ensureFooterTree,
34045
34544
  filterAvailablePages,
@@ -34050,6 +34549,7 @@ export {
34050
34549
  insertFooterHours,
34051
34550
  isDeadPageHref,
34052
34551
  isEditSessionActive,
34552
+ isEditableKeyHidden,
34053
34553
  isPlainLeftClick,
34054
34554
  isRenderableFooterTree,
34055
34555
  isRenderableTree,
@@ -34060,15 +34560,22 @@ export {
34060
34560
  parseAiFooterState,
34061
34561
  parseAiSectionsState,
34062
34562
  parseTarget,
34563
+ planAiBlockRemoval,
34564
+ planAiTextBlockRemoval,
34063
34565
  planBuildPageSync,
34566
+ readHiddenEditables,
34064
34567
  recordOverriddenPaths,
34065
34568
  releaseTemplateLogoIfReplaced,
34569
+ removeBlockAtPath,
34066
34570
  removeFooterBlock,
34067
34571
  resetOverriddenPathsCache,
34068
34572
  resolveFooterCopyright,
34573
+ resolveSoftHideTarget,
34069
34574
  resolveStickyNavigation,
34070
34575
  serializeAiFooterState,
34071
34576
  shouldFetchContentForPath,
34577
+ softHideEditableInDom,
34578
+ softUnhideEditableInDom,
34072
34579
  stepViableSlide,
34073
34580
  stripPlaceholderText,
34074
34581
  stripPlaceholders,
@@ -34076,6 +34583,8 @@ export {
34076
34583
  toggleVariants,
34077
34584
  useOhwCarousel,
34078
34585
  validateUrlInput,
34079
- viableSlides
34586
+ viableSlides,
34587
+ withHiddenEditable,
34588
+ withoutHiddenEditable
34080
34589
  };
34081
34590
  //# sourceMappingURL=index.js.map