@salesforce/metadata-plugins 1.11.0 → 1.13.0

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.
Files changed (41) hide show
  1. package/dist/plugins/agent/ui/assets/VibeEditComposer-BQeSigSs.css +1 -0
  2. package/dist/plugins/agent/ui/assets/VibeEditComposer-D5GykTkw.js +1 -0
  3. package/dist/plugins/agent/ui/assets/index-CFqH429G.css +1 -0
  4. package/dist/plugins/agent/ui/assets/index-nYWtX5pm.js +72 -0
  5. package/dist/plugins/agent/ui/index.html +2 -2
  6. package/dist/plugins/flexipage/ui/assets/VibeEditComposer-BQeSigSs.css +1 -0
  7. package/dist/plugins/flexipage/ui/assets/VibeEditComposer-CwNZdtC5.js +1 -0
  8. package/dist/plugins/flexipage/ui/assets/index-C2upgZns.css +1 -0
  9. package/dist/plugins/flexipage/ui/assets/index-hFZPLB6p.js +49 -0
  10. package/dist/plugins/flexipage/ui/index.html +2 -2
  11. package/dist/plugins/flow/parser/edges.d.ts +1 -1
  12. package/dist/plugins/flow/parser/edges.d.ts.map +1 -1
  13. package/dist/plugins/flow/parser/edges.js +170 -2
  14. package/dist/plugins/flow/ui/assets/VibeEditComposer-BQeSigSs.css +1 -0
  15. package/dist/plugins/flow/ui/assets/VibeEditComposer-C36-RsSl.js +1 -0
  16. package/dist/plugins/flow/ui/assets/index-CdpIq7gH.js +49 -0
  17. package/dist/plugins/flow/ui/assets/index-Ckw5Ej7p.css +1 -0
  18. package/dist/plugins/flow/ui/index.html +2 -2
  19. package/dist/plugins/flowintent/ui/assets/{index-BkuUZejF.js → index-CzlE9StJ.js} +10 -10
  20. package/dist/plugins/flowintent/ui/index.html +1 -1
  21. package/dist/plugins/permissionset/ui/assets/VibeEditComposer-BQeSigSs.css +1 -0
  22. package/dist/plugins/permissionset/ui/assets/VibeEditComposer-HYu9RPHQ.js +1 -0
  23. package/dist/plugins/permissionset/ui/assets/index-DWBjNYzW.css +1 -0
  24. package/dist/plugins/permissionset/ui/assets/index-DilBd-cG.js +49 -0
  25. package/dist/plugins/permissionset/ui/index.html +2 -2
  26. package/dist/plugins/schema/ui/assets/VibeEditComposer-BQeSigSs.css +1 -0
  27. package/dist/plugins/schema/ui/assets/VibeEditComposer-Ce9dBbb3.js +1 -0
  28. package/dist/plugins/schema/ui/assets/index-DSSQ6K8b.js +71 -0
  29. package/dist/plugins/schema/ui/assets/index-Dsaw92BM.css +1 -0
  30. package/dist/plugins/schema/ui/index.html +2 -2
  31. package/package.json +12 -11
  32. package/dist/plugins/agent/ui/assets/index-BpnirPMA.js +0 -71
  33. package/dist/plugins/agent/ui/assets/index-DX8JtDoL.css +0 -1
  34. package/dist/plugins/flexipage/ui/assets/index-DBy19jKB.css +0 -1
  35. package/dist/plugins/flexipage/ui/assets/index-DJj6fJsw.js +0 -48
  36. package/dist/plugins/flow/ui/assets/index-B-Cn56iR.js +0 -48
  37. package/dist/plugins/flow/ui/assets/index-H7g-xvR-.css +0 -1
  38. package/dist/plugins/permissionset/ui/assets/index-BCcTde0G.js +0 -48
  39. package/dist/plugins/permissionset/ui/assets/index-DqEUhEQc.css +0 -1
  40. package/dist/plugins/schema/ui/assets/index-BBcLTTbn.js +0 -70
  41. package/dist/plugins/schema/ui/assets/index-EHPZb2E3.css +0 -1
@@ -51,8 +51,167 @@ export class EdgeBuilder {
51
51
  return id;
52
52
  }
53
53
  }
54
+ /**
55
+ * Collect every node id that has a structural home on the main spine — i.e., it
56
+ * is reachable from Start by following only non-fault, non-GoTo connectors that
57
+ * resolve to a known element. Used to detect when a `<faultConnector>` points
58
+ * at such a node so we can promote it to a GoTo chip instead of drawing a fault
59
+ * line back onto the spine.
60
+ *
61
+ * This covers two shapes:
62
+ * 1. A `<faultConnector>` pointing at the same node as its own element's
63
+ * `<connector>` (fault "falls through" to the success path).
64
+ * 2. Multiple elements sharing an error-handler screen that ALSO sits on the
65
+ * main spine (e.g., reached via a decision's default outcome) — the fault
66
+ * edges would otherwise all bend back onto the spine and overlap the
67
+ * shared handler and each other.
68
+ *
69
+ * The reachability restriction matters: raw references (authored `<isGoTo>`
70
+ * connectors, unresolved target names, or edges from a disconnected subgraph
71
+ * that never lands on the spine) would falsely promote a fault whose target
72
+ * has no structural placement, so the target and its downstream subtree would
73
+ * disappear from the canvas instead of rendering in the fault lane.
74
+ */
75
+ function collectStructuralSpineTargets(flow, knownIds) {
76
+ // Build a resolved, non-fault, non-GoTo adjacency map: source id → target ids.
77
+ const outgoing = new Map();
78
+ // Track every element that is the target of ANY connector (fault included) so
79
+ // the fallback root selection below matches `wireStartEdges` — which counts
80
+ // materialized fault edges when deciding indegree-0 entry points. Without
81
+ // this, a fault-only target looks like a spine root here (its fault-incoming
82
+ // is invisible in the non-fault adjacency map) and any fault edge landing on
83
+ // it gets promoted to GoTo; `wireStartEdges` then declines to connect Start
84
+ // to it, orphaning the target and its downstream subtree.
85
+ const anyIncoming = new Set();
86
+ const push = (from, connector) => {
87
+ if (!connector || typeof connector !== 'object') {
88
+ return;
89
+ }
90
+ if (connectorIsGoTo(connector)) {
91
+ return;
92
+ }
93
+ const target = connectorTarget(connector);
94
+ if (!target || !knownIds.has(target)) {
95
+ return;
96
+ }
97
+ const list = outgoing.get(from);
98
+ if (list) {
99
+ list.push(target);
100
+ }
101
+ else {
102
+ outgoing.set(from, [target]);
103
+ }
104
+ };
105
+ const markIncoming = (connector) => {
106
+ if (!connector || typeof connector !== 'object') {
107
+ return;
108
+ }
109
+ if (connectorIsGoTo(connector)) {
110
+ return;
111
+ }
112
+ const target = connectorTarget(connector);
113
+ if (target && knownIds.has(target)) {
114
+ anyIncoming.add(target);
115
+ }
116
+ };
117
+ // Synthetic Start's outgoing (declared connector, scheduledPaths, or legacy
118
+ // startElementReference) — the entry points to the spine.
119
+ const startId = '__START__';
120
+ const startEl = flow.start;
121
+ const declaredStart = [];
122
+ if (startEl) {
123
+ const main = connectorTarget(startEl.connector);
124
+ if (main && knownIds.has(main)) {
125
+ declaredStart.push(main);
126
+ }
127
+ for (const p of arr(startEl.scheduledPaths)) {
128
+ const t = connectorTarget(p.connector);
129
+ if (t && knownIds.has(t)) {
130
+ declaredStart.push(t);
131
+ }
132
+ }
133
+ }
134
+ const legacyStart = str(flow.startElementReference);
135
+ if (legacyStart && knownIds.has(legacyStart)) {
136
+ declaredStart.push(legacyStart);
137
+ }
138
+ if (declaredStart.length) {
139
+ outgoing.set(startId, declaredStart);
140
+ }
141
+ const elementIds = [];
142
+ for (const { tag, kind } of ELEMENT_TYPES) {
143
+ for (const el of arr(flow[tag])) {
144
+ if (!el || typeof el !== 'object') {
145
+ continue;
146
+ }
147
+ const record = el;
148
+ const from = str(record.name);
149
+ if (!from) {
150
+ continue;
151
+ }
152
+ elementIds.push(from);
153
+ if (kind === 'decision') {
154
+ for (const rule of arr(record.rules)) {
155
+ push(from, unwrapRule(rule).connector);
156
+ }
157
+ push(from, record.defaultConnector);
158
+ }
159
+ else if (kind === 'loop') {
160
+ push(from, record.nextValueConnector);
161
+ push(from, record.noMoreValuesConnector);
162
+ }
163
+ else if (kind === 'wait') {
164
+ for (const evt of arr(record.waitEvents)) {
165
+ push(from, evt.connector);
166
+ }
167
+ push(from, record.defaultConnector);
168
+ }
169
+ else {
170
+ push(from, record.connector);
171
+ }
172
+ // Fault connectors don't feed the spine adjacency (they aren't structural
173
+ // successors), but they DO count as incoming when picking fallback roots —
174
+ // `wireStartEdges` sees the materialized fault edge and won't seed Start
175
+ // to a fault-only target. Mirror that here.
176
+ markIncoming(record.faultConnector);
177
+ }
178
+ }
179
+ // Seed the BFS. Prefer the authored Start fan-out; when Start declares no
180
+ // outgoing (common in autolaunched flows), mirror `wireStartEdges` and treat
181
+ // every indegree-0 element as an entry point. Indegree here MUST include
182
+ // fault-incoming edges — the runtime graph that `wireStartEdges` sees does,
183
+ // and disagreement between the two paths caused fault-only targets to be
184
+ // treated as spine roots here (promoting their fault to GoTo) while
185
+ // `wireStartEdges` refused to seed Start to them, orphaning the target.
186
+ if (!outgoing.has(startId)) {
187
+ for (const targets of outgoing.values()) {
188
+ for (const t of targets) {
189
+ anyIncoming.add(t);
190
+ }
191
+ }
192
+ const entries = elementIds.filter((id) => !anyIncoming.has(id));
193
+ const seeds = entries.length > 0 ? entries : elementIds.slice(0, 1);
194
+ if (seeds.length) {
195
+ outgoing.set(startId, seeds);
196
+ }
197
+ }
198
+ const reachable = new Set();
199
+ const queue = [startId];
200
+ while (queue.length > 0) {
201
+ const cur = queue.shift();
202
+ for (const next of outgoing.get(cur) ?? []) {
203
+ if (reachable.has(next)) {
204
+ continue;
205
+ }
206
+ reachable.add(next);
207
+ queue.push(next);
208
+ }
209
+ }
210
+ return reachable;
211
+ }
54
212
  /** Second pass: branch-aware connectors per element kind. */
55
213
  export function wireElementEdges(flow, builder) {
214
+ const structuralTargets = collectStructuralSpineTargets(flow, builder.knownIds);
56
215
  for (const { tag, kind } of ELEMENT_TYPES) {
57
216
  for (const el of arr(flow[tag])) {
58
217
  if (!el || typeof el !== 'object') {
@@ -73,10 +232,19 @@ export function wireElementEdges(flow, builder) {
73
232
  // may itself carry `<isGoTo>true</isGoTo>` — the target already lives
74
233
  // elsewhere on the canvas (e.g., a decision's default outcome), so the
75
234
  // fault path renders as a `→ Target` chip on the source rather than
76
- // dragging the target into the fault lane.
235
+ // dragging the target into the fault lane. Flow Builder ALSO renders the
236
+ // fault as a `→ Target` chip whenever the fault target already sits on
237
+ // the main spine (Start-reachable via non-fault, non-GoTo connectors) —
238
+ // either the source element's own success path (fault "falls through"),
239
+ // or a shared error handler also reached from e.g. a decision's default
240
+ // outcome. Without auto-promotion those fault edges bend back onto the
241
+ // spine and stack on top of the shared target. Auto-promote them to GoTo
242
+ // so each one renders as a chip on its own source card. The reachability
243
+ // gate matters — promoting on a raw name match would drop targets that
244
+ // computeLayout never places on the spine.
77
245
  const faultTarget = connectorTarget(record.faultConnector);
78
246
  if (faultTarget) {
79
- const faultIsGoTo = connectorIsGoTo(record.faultConnector);
247
+ const faultIsGoTo = connectorIsGoTo(record.faultConnector) || structuralTargets.has(faultTarget);
80
248
  builder.addEdge(id, faultTarget, {
81
249
  label: CONNECTOR_LABELS.fault,
82
250
  isFault: true,
@@ -0,0 +1 @@
1
+ .vibe-edit-composer{--vec-canvas: var(--vscode-editor-background, light-dark(#ffffff, #181818));--vec-elevated: light-dark( color-mix(in srgb, var(--vec-canvas), var(--vec-text) 12%), color-mix(in srgb, var(--vec-canvas), var(--vec-text) 7%) );--vec-hover: var(--vscode-list-hoverBackground, light-dark(#e5e5e5, #2e2e2e));--vec-text: var(--vscode-editor-foreground, light-dark(#2e2e2e, #c9c9c9));--vec-text-secondary: var(--vscode-descriptionForeground, light-dark(#5c5c5c, #939393));--vec-text-tertiary: var(--vscode-descriptionForeground, light-dark(#696969, #848484));--vec-border: var(--vscode-panel-border, light-dark(#e5e5e5, #2e2e2e));--vec-interactive: var(--vscode-textLink-foreground, light-dark(#0250d9, #7cb1fe));--vec-info: var(--vscode-problemsInfoIcon-foreground, light-dark(#0b5cab, #78b0fd));--vec-danger: var(--vscode-list-errorForeground, light-dark(#a00449, #fe8aa7));--vec-primary: var(--vscode-button-background, light-dark(#0176d3, #0176d3));--vec-primary-fg: var(--vscode-button-foreground, light-dark(#ffffff, #ffffff));--vec-radius: .625rem;--vec-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .06);position:fixed;z-index:50;bottom:16px;left:50%;transform:translate(-50%);box-sizing:border-box;width:min(520px,calc(100% - 24px));min-width:min(280px,calc(100% - 24px));font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Arial,sans-serif;font-size:.8125rem;line-height:1.45;color:var(--vec-text)}.vibe-edit-composer--positioned{bottom:auto;transform:none}.vibe-edit-composer *,.vibe-edit-composer *:before,.vibe-edit-composer *:after{box-sizing:border-box}.vibe-edit-composer__card{display:flex;flex-direction:column;gap:8px;padding-top:8px;background:var(--vec-canvas);border:1px solid var(--vec-border);border-radius:calc(var(--vec-radius) + 4px);box-shadow:var(--vec-shadow-xl)}.vibe-edit-composer__header{display:flex;align-items:center;justify-content:space-between;padding:2px 16px;color:var(--vec-text-secondary)}.vibe-edit-composer__header-actions{display:inline-flex;align-items:center;gap:2px}.vibe-edit-composer__move-handle{cursor:grab;touch-action:none}.vibe-edit-composer__move-handle:active{cursor:grabbing}.vibe-edit-composer__move-controls{display:flex;gap:4px;padding:0 16px 4px}.vibe-edit-composer__move-controls button{padding:2px 6px;color:var(--vec-text-secondary);background:transparent;border:1px solid var(--vec-border);border-radius:calc(var(--vec-radius) - 4px);cursor:pointer}.vibe-edit-composer__move-controls button:hover{background:var(--vec-hover);color:var(--vec-text)}.vibe-edit-composer__move-controls button:focus-visible{outline:1px solid var(--vscode-focusBorder, var(--vec-interactive));outline-offset:2px}.vibe-edit-composer__title{display:inline-flex;align-items:center;gap:8px}.vibe-edit-composer__title-icon{display:inline-flex;flex-shrink:0}.vibe-edit-composer__title-text{font-size:13px;font-weight:500}.vibe-edit-composer__icon-button{display:inline-flex;align-items:center;justify-content:center;padding:4px;border:none;border-radius:calc(var(--vec-radius) - 2px);background:transparent;color:var(--vec-text-tertiary);cursor:pointer;transition:background-color .15s,color .15s}.vibe-edit-composer__icon-button--sm{width:24px;height:24px}.vibe-edit-composer__icon-button:hover:not(:disabled){background:var(--vec-hover);color:var(--vec-text)}.vibe-edit-composer__icon-button:disabled{opacity:.5;cursor:not-allowed}.vibe-edit-composer__send{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:6px 14px;font-family:inherit;font-size:.8125rem;font-weight:500;line-height:1.45;color:var(--vec-primary-fg);background:var(--vec-primary);border:none;border-radius:var(--vec-radius);cursor:pointer;transition:background-color .15s,color .15s,opacity .15s}.vibe-edit-composer__send:hover:not(:disabled){opacity:.9}.vibe-edit-composer__send:disabled{opacity:.5;cursor:not-allowed}.vibe-edit-composer__send-icon{display:flex;flex-shrink:0;align-items:center}.vibe-edit-composer__send-icon svg{display:block;width:16px;height:16px}.vibe-edit-composer__icon-button:focus,.vibe-edit-composer__send:focus{outline:none}.vibe-edit-composer__icon-button:focus-visible,.vibe-edit-composer__send:focus-visible{box-shadow:0 0 0 2px var(--vec-interactive)}@media (forced-colors: active){.vibe-edit-composer__icon-button:focus-visible,.vibe-edit-composer__send:focus-visible,.vibe-edit-composer__chip-icon-wrap:focus-visible{outline:2px solid Highlight;outline-offset:2px}.vibe-edit-composer__input-container:focus-within{outline:2px solid Highlight}.vibe-edit-composer__send{border:1px solid ButtonText}}.vibe-edit-composer__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.vibe-edit-composer__error{padding:0 16px;font-size:13px;color:var(--vec-danger)}.vibe-edit-composer__panel{position:relative}.vibe-edit-composer__input-container{position:relative;display:flex;flex-direction:column;background:var(--vec-elevated);border:1px solid var(--vec-border);border-width:1px 0 0;border-radius:calc(var(--vec-radius) + 4px);transition:border-color .15s}.vibe-edit-composer__input-container:focus-within{border-top-color:var(--vec-border);box-shadow:none}.vibe-edit-composer__editable{width:100%;min-height:64px;max-height:78px;padding:12px 16px 0;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable;font-size:.8125rem;font-weight:400;line-height:22px;color:var(--vec-text);white-space:pre-wrap;overflow-wrap:break-word;cursor:text}.vibe-edit-composer__text{display:inline-block;min-width:1px;min-height:22px;margin-left:6px;vertical-align:top;outline:none;caret-color:var(--vec-text)}.vibe-edit-composer__text:first-child{margin-left:0}.vibe-edit-composer__placeholder{color:var(--vec-text-secondary);pointer-events:none;-webkit-user-select:none;user-select:none}.vibe-edit-composer__text[contenteditable=false]{cursor:not-allowed}.vibe-edit-composer__chip{position:relative;top:-1px;display:inline-flex;align-items:center;gap:3px;max-width:100%;margin:0 2px;padding:2px 8px 2px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.75rem;font-weight:500;line-height:16px;color:var(--vec-text-secondary);white-space:nowrap;vertical-align:middle;-webkit-user-select:none;user-select:none;background:var(--vec-canvas);border:1px solid var(--vec-border);border-radius:calc(var(--vec-radius) - 4px)}.vibe-edit-composer__chip-icon-wrap{position:relative;display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;width:16px;height:16px;padding:0;color:inherit;background:transparent;border:none}.vibe-edit-composer__chip-icon,.vibe-edit-composer__chip-x{position:absolute;top:50%;left:50%;width:12px;height:12px;transform:translate(-50%,-50%)}.vibe-edit-composer__chip-icon{color:var(--vec-info);opacity:.7}.vibe-edit-composer__chip-x{cursor:pointer;opacity:0}.vibe-edit-composer__chip:hover .vibe-edit-composer__chip-icon,.vibe-edit-composer__chip-icon-wrap:focus-visible .vibe-edit-composer__chip-icon{opacity:0}.vibe-edit-composer__chip:hover .vibe-edit-composer__chip-x,.vibe-edit-composer__chip-icon-wrap:focus-visible .vibe-edit-composer__chip-x{opacity:.7}.vibe-edit-composer__chip-icon-wrap:disabled{cursor:not-allowed}.vibe-edit-composer__chip-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vibe-edit-composer__footer{display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;padding:4px 12px 12px}.vibe-edit-composer__controls{position:relative;display:flex;flex-shrink:0;align-items:center;gap:6px}.vibe-edit-composer__pulse-layer{position:fixed;top:0;right:0;bottom:0;left:0;z-index:30;pointer-events:none}.vibe-edit-composer__pulse{position:fixed;box-sizing:border-box;border:2px solid var(--vscode-button-background, #0176d3);border-radius:6px;box-shadow:0 0 0 4px color-mix(in srgb,var(--vscode-button-background, #0176d3) 25%,transparent);animation:vibe-edit-composer-pulse 1.1s ease-in-out infinite}@keyframes vibe-edit-composer-pulse{0%,to{opacity:1}50%{opacity:.45}}@media (prefers-reduced-motion: reduce){.vibe-edit-composer__pulse{animation:none}}
@@ -0,0 +1 @@
1
+ import{r,R as t,S as he,A as be}from"./index-CdpIq7gH.js";const k=12,re=12;function ce(o,u,c){const b=Math.max(c.left+k,c.left+c.width-u.width-k),a=Math.max(c.top+k,c.top+c.height-u.height-k);return{left:Math.min(Math.max(o.left,c.left+k),b),top:Math.min(Math.max(o.top,c.top+k),a)}}function ve(o,u,c){const b=o.left+o.width+re,a=o.left-u.width-re,m=b+u.width<=c.left+c.width-k;return ce({left:m?b:a,top:o.top},u,c)}function Ee(){return t.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"},he.map(o=>t.createElement("path",{key:o,d:o,fill:"currentColor"})))}function ge(){return t.createElement("svg",{width:"40",height:"48",viewBox:"0 0 40 48.3291",preserveAspectRatio:"xMidYMid meet",overflow:"visible",fill:"none","aria-hidden":"true"},be.map(o=>t.createElement("path",{key:o,d:o,fill:"currentColor"})))}function O({size:o,className:u,children:c}){return t.createElement("svg",{className:u,width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},c)}const oe=t.createElement(t.Fragment,null,t.createElement("path",{d:"M18 6 6 18"}),t.createElement("path",{d:"m6 6 12 12"})),_e=t.createElement(t.Fragment,null,t.createElement("circle",{cx:"8",cy:"6",r:"1",fill:"currentColor",stroke:"none"}),t.createElement("circle",{cx:"16",cy:"6",r:"1",fill:"currentColor",stroke:"none"}),t.createElement("circle",{cx:"8",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.createElement("circle",{cx:"16",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.createElement("circle",{cx:"8",cy:"18",r:"1",fill:"currentColor",stroke:"none"}),t.createElement("circle",{cx:"16",cy:"18",r:"1",fill:"currentColor",stroke:"none"}));function X(o){return{left:o.left,top:o.top,width:o.width,height:o.height}}function ie(){return{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}function we({ids:o,nodeFor:u}){const[c,b]=r.useState([]);return r.useEffect(()=>{let a=0;const m=()=>{const f=[];for(const p of o){const h=u(p);if(!h)continue;const s=h.getBoundingClientRect();f.push({id:p,x:s.x,y:s.y,width:s.width,height:s.height})}b(p=>p.length===f.length&&p.every((h,s)=>h.id===f[s].id&&h.x===f[s].x&&h.y===f[s].y&&h.width===f[s].width&&h.height===f[s].height)?p:f),a=requestAnimationFrame(m)};return a=requestAnimationFrame(m),()=>cancelAnimationFrame(a)},[o,u]),c.length===0?null:t.createElement("div",{className:"vibe-edit-composer__pulse-layer","aria-hidden":"true"},c.map(a=>t.createElement("div",{key:a.id,className:"vibe-edit-composer__pulse",style:{left:a.x,top:a.y,width:a.width,height:a.height}})))}function ke({elements:o,nodeFor:u,onEdit:c,onDeselect:b,onSent:a,onClose:m,onDraftChange:f}){const[p,h]=r.useState(""),[s,I]=r.useState("idle"),[ae,z]=r.useState(""),[A,Y]=r.useState([]),[F,G]=r.useState(""),C=r.useRef(null),T=r.useRef(null),[L,P]=r.useState(null),v=r.useRef(null),[H,K]=r.useState(!1),W=r.useId(),g=r.useRef(!1),V=r.useRef(null),_=r.useRef(null),U=r.useRef(!1),M=r.useRef(null),$=r.useRef(!1),S=r.useRef(!0);r.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]);const x=o.length,y=x>0,R=s==="applying",q=y&&p.trim().length>0&&!R,j=y&&p.trim().length>0;r.useEffect(()=>{f==null||f(j)},[j,f]);const w=r.useCallback(e=>{const n=T.current;if(!n)return;const l=ce(e,X(n.getBoundingClientRect()),ie());v.current=l,P(i=>i&&i.left===l.left&&i.top===l.top?i:l)},[]);r.useLayoutEffect(()=>{if(!y){g.current=!1,v.current=null,P(null),K(!1);return}const e=T.current;if(!e)return;const n=o[0].id;V.current!==n&&(V.current=n,g.current=!1);const l=()=>{if(g.current){v.current&&w(v.current);return}const ne=u(o[0].id);if(!ne)return;const D=ve(X(ne.getBoundingClientRect()),X(e.getBoundingClientRect()),ie());v.current=D,P(B=>B&&B.left===D.left&&B.top===D.top?B:D)};l();let i=0;const d=()=>{i===0&&(i=requestAnimationFrame(()=>{i=0,l()}))};window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),window.addEventListener("pointermove",d,!0),window.addEventListener("wheel",d,!0);const E=typeof ResizeObserver>"u"?null:new ResizeObserver(l);return E==null||E.observe(e),E==null||E.observe(u(o[0].id)??e),()=>{cancelAnimationFrame(i),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0),window.removeEventListener("pointermove",d,!0),window.removeEventListener("wheel",d,!0),E==null||E.disconnect()}},[o,y,u,w]);const N=r.useCallback((e,n)=>{g.current=!0;const l=v.current??{left:12,top:12};w({left:l.left+e,top:l.top+n})},[w]),se=r.useCallback(e=>{if(e.button!==0)return;const n=T.current;if(!n)return;const l=X(n.getBoundingClientRect()),i=g.current,d=v.current??{left:l.left,top:l.top};w(d),_.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,position:d,wasManuallyPositioned:i,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),e.currentTarget.focus(),e.preventDefault(),e.stopPropagation()},[w]),le=r.useCallback(e=>{const n=_.current;!n||n.pointerId!==e.pointerId||(!n.moved&&Math.hypot(e.clientX-n.startX,e.clientY-n.startY)>3&&(g.current=!0,n.moved=!0),w({left:n.position.left+e.clientX-n.startX,top:n.position.top+e.clientY-n.startY}),e.preventDefault(),e.stopPropagation())},[w]),ue=r.useCallback(e=>{const n=_.current;!n||n.pointerId!==e.pointerId||(_.current=null,U.current=n.moved,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),J=r.useCallback(e=>{const n=_.current;!n||n.pointerId!==e.pointerId||(_.current=null,g.current=n.wasManuallyPositioned,v.current=n.position,P(n.position),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),de=r.useCallback(e=>{const n=e.shiftKey?32:16,i={ArrowLeft:{left:-n,top:0},ArrowRight:{left:n,top:0},ArrowUp:{left:0,top:-n},ArrowDown:{left:0,top:n}}[e.key];if(i)e.preventDefault(),N(i.left,i.top);else if(e.key==="Escape"){e.preventDefault(),e.stopPropagation();const d=_.current;d&&(g.current=d.wasManuallyPositioned,v.current=d.position,P(d.position),_.current=null),K(!1)}},[N]);r.useEffect(()=>{var e;y&&((e=C.current)==null||e.focus())},[y]);const Q=r.useCallback(()=>{h(""),C.current&&(C.current.textContent="")},[]),Z=r.useCallback(async()=>{if(!q||$.current)return;$.current=!0;const e=p.trim(),n=o.map(i=>i.id),l=M.current?{kind:"existing",id:M.current.id,label:M.current.label}:{kind:"new"};I("applying"),Y(n);try{const i=await c(n,e,l);i&&i.chatId&&(M.current={id:i.chatId,label:i.chatLabel??"Edits"}),S.current&&(Q(),I("idle"),z(""),G("Sent to Agentforce Vibes"),a==null||a())}catch(i){S.current&&(Y([]),z(i instanceof Error&&i.message.length>0?i.message:"That edit couldn’t be sent. Try again."),I("error"))}finally{$.current=!1}},[q,Q,p,o,c,a]);r.useEffect(()=>{var e;s==="error"&&((e=C.current)==null||e.focus())},[s]),r.useEffect(()=>{if(!F)return;const e=setTimeout(()=>G(""),4e3);return()=>clearTimeout(e)},[F]),r.useEffect(()=>{if(s!=="idle"||A.length===0)return;const e=setTimeout(()=>Y([]),1200);return()=>clearTimeout(e)},[s,A]);const ee=()=>{o.forEach(e=>b(e.id)),m==null||m()},te=e=>{b(e.id),G(`Removed ${e.label}, ${x-1} selected`),x===1&&(m==null||m())},fe=e=>{h(e.currentTarget.textContent??""),s==="error"&&(z(""),I("idle"))},pe=e=>{e.key==="Enter"&&!e.shiftKey&&!e.nativeEvent.isComposing?(e.preventDefault(),Z()):e.key==="Escape"?(e.preventDefault(),ee()):e.key==="Backspace"&&p.length===0&&x>0&&(e.preventDefault(),te(o[x-1]))},me=e=>{var n;e.target===e.currentTarget&&((n=C.current)==null||n.focus())};return t.createElement(t.Fragment,null,t.createElement("span",{className:"vibe-edit-composer__sr-only",role:"status","aria-live":"polite"},F),A.length>0&&t.createElement(we,{ids:A,nodeFor:u}),y&&t.createElement("div",{className:`vibe-edit-composer${L?" vibe-edit-composer--positioned":""}`,role:"dialog","aria-label":"Edit selected metadata with the agent",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),style:L?{left:L.left,top:L.top}:void 0},t.createElement("div",{ref:T,className:"vibe-edit-composer__card"},t.createElement("div",{className:"vibe-edit-composer__header"},t.createElement("span",{className:"vibe-edit-composer__title"},t.createElement("span",{className:"vibe-edit-composer__title-icon"},t.createElement(Ee,null)),t.createElement("span",{className:"vibe-edit-composer__title-text"},x," selected")),t.createElement("span",{className:"vibe-edit-composer__header-actions"},t.createElement("button",{type:"button",className:"vibe-edit-composer__icon-button vibe-edit-composer__icon-button--sm vibe-edit-composer__move-handle","aria-label":"Move composer","aria-expanded":H,"aria-controls":H?W:void 0,title:"Drag to move composer. Arrow keys move it when focused.",onClick:()=>{if(U.current){U.current=!1;return}K(e=>!e)},onPointerDown:se,onPointerMove:le,onPointerUp:ue,onPointerCancel:J,onLostPointerCapture:J,onKeyDown:de,disabled:R},t.createElement(O,{size:16},_e)),t.createElement("button",{type:"button",className:"vibe-edit-composer__icon-button vibe-edit-composer__icon-button--sm","aria-label":"Exit select to edit",title:"Exit",onClick:ee,disabled:R},t.createElement(O,{size:16},oe)))),H&&t.createElement("div",{id:W,className:"vibe-edit-composer__move-controls",role:"group","aria-label":"Move composer controls"},t.createElement("button",{type:"button",onClick:()=>N(0,-16),"aria-label":"Move composer up"},"Up"),t.createElement("button",{type:"button",onClick:()=>N(-16,0),"aria-label":"Move composer left"},"Left"),t.createElement("button",{type:"button",onClick:()=>N(16,0),"aria-label":"Move composer right"},"Right"),t.createElement("button",{type:"button",onClick:()=>N(0,16),"aria-label":"Move composer down"},"Down")),s==="error"&&t.createElement("div",{className:"vibe-edit-composer__error",role:"alert"},ae),t.createElement("div",{className:"vibe-edit-composer__panel"},t.createElement("div",{className:"vibe-edit-composer__input-container"},t.createElement("div",{className:"vibe-edit-composer__editable",onClick:me},o.map(e=>t.createElement("span",{key:e.id,className:"vibe-edit-composer__chip",role:"group","aria-label":e.label,title:e.label},t.createElement("button",{type:"button",className:"vibe-edit-composer__chip-icon-wrap","aria-label":`Remove ${e.label} from selection`,onClick:()=>te(e),disabled:R},t.createElement(O,{size:12,className:"vibe-edit-composer__chip-icon"},t.createElement("path",{d:"M16 18l6-6-6-6"}),t.createElement("path",{d:"M8 6l-6 6 6 6"})),t.createElement(O,{size:12,className:"vibe-edit-composer__chip-x"},oe)),t.createElement("span",{className:"vibe-edit-composer__chip-label"},e.label))),t.createElement("span",{ref:C,className:"vibe-edit-composer__text",contentEditable:R?!1:"plaintext-only",suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","aria-label":"Describe your edits…","aria-busy":R||void 0,onInput:fe,onKeyDown:pe}),p.length===0&&t.createElement("span",{className:"vibe-edit-composer__placeholder","aria-hidden":"true"},"Describe your edits…")),t.createElement("div",{className:"vibe-edit-composer__footer"},t.createElement("div",{className:"vibe-edit-composer__controls"},t.createElement("button",{type:"button",className:"vibe-edit-composer__send",disabled:!q,onClick:()=>void Z(),"aria-label":"Send to Agent",title:M.current?"Adds to the edits chat":"Opens in a new chat"},t.createElement("span",{className:"vibe-edit-composer__send-icon"},t.createElement(ge,null)),"Send to Agent"))))))))}export{ke as default};