inplan 0.1.11 → 0.1.13

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.
@@ -15,7 +15,7 @@ var react_production_min = {};
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
17
  */
18
- var l$1 = Symbol.for("react.element"), n$1 = Symbol.for("react.portal"), p$2 = Symbol.for("react.fragment"), q$1 = Symbol.for("react.strict_mode"), r = Symbol.for("react.profiler"), t$1 = Symbol.for("react.provider"), u = Symbol.for("react.context"), v$1 = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), x = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), z$1 = Symbol.iterator;
18
+ var l$1 = Symbol.for("react.element"), n$1 = Symbol.for("react.portal"), p$2 = Symbol.for("react.fragment"), q$1 = Symbol.for("react.strict_mode"), r = Symbol.for("react.profiler"), t$1 = Symbol.for("react.provider"), u = Symbol.for("react.context"), v$1 = Symbol.for("react.forward_ref"), w$1 = Symbol.for("react.suspense"), x = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), z$1 = Symbol.iterator;
19
19
  function A$1(a) {
20
20
  if (null === a || "object" !== typeof a) return null;
21
21
  a = z$1 && a[z$1] || a["@@iterator"];
@@ -163,7 +163,7 @@ react_production_min.Fragment = p$2;
163
163
  react_production_min.Profiler = r;
164
164
  react_production_min.PureComponent = G$1;
165
165
  react_production_min.StrictMode = q$1;
166
- react_production_min.Suspense = w;
166
+ react_production_min.Suspense = w$1;
167
167
  react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = W$1;
168
168
  react_production_min.act = X$1;
169
169
  react_production_min.cloneElement = function(a, b, e) {
@@ -8074,7 +8074,7 @@ const HTML_REPLACEMENTS = {
8074
8074
  function replaceUnsafeChar(ch2) {
8075
8075
  return HTML_REPLACEMENTS[ch2];
8076
8076
  }
8077
- function escapeHtml(str) {
8077
+ function escapeHtml$1(str) {
8078
8078
  if (HTML_ESCAPE_TEST_RE.test(str)) {
8079
8079
  return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
8080
8080
  }
@@ -8188,7 +8188,7 @@ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
8188
8188
  arrayReplaceAt,
8189
8189
  asciiTrim,
8190
8190
  assign: assign$1,
8191
- escapeHtml,
8191
+ escapeHtml: escapeHtml$1,
8192
8192
  escapeRE: escapeRE$1,
8193
8193
  fromCodePoint: fromCodePoint$1,
8194
8194
  has,
@@ -8370,11 +8370,11 @@ const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
8370
8370
  const default_rules = {};
8371
8371
  default_rules.code_inline = function(tokens, idx, options, env, slf) {
8372
8372
  const token = tokens[idx];
8373
- return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
8373
+ return "<code" + slf.renderAttrs(token) + ">" + escapeHtml$1(token.content) + "</code>";
8374
8374
  };
8375
8375
  default_rules.code_block = function(tokens, idx, options, env, slf) {
8376
8376
  const token = tokens[idx];
8377
- return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml(tokens[idx].content) + "</code></pre>\n";
8377
+ return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml$1(tokens[idx].content) + "</code></pre>\n";
8378
8378
  };
8379
8379
  default_rules.fence = function(tokens, idx, options, env, slf) {
8380
8380
  const token = tokens[idx];
@@ -8388,9 +8388,9 @@ default_rules.fence = function(tokens, idx, options, env, slf) {
8388
8388
  }
8389
8389
  let highlighted;
8390
8390
  if (options.highlight) {
8391
- highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
8391
+ highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml$1(token.content);
8392
8392
  } else {
8393
- highlighted = escapeHtml(token.content);
8393
+ highlighted = escapeHtml$1(token.content);
8394
8394
  }
8395
8395
  if (highlighted.indexOf("<pre") === 0) {
8396
8396
  return highlighted + "\n";
@@ -8425,7 +8425,7 @@ default_rules.softbreak = function(tokens, idx, options) {
8425
8425
  return options.breaks ? options.xhtmlOut ? "<br />\n" : "<br>\n" : "\n";
8426
8426
  };
8427
8427
  default_rules.text = function(tokens, idx) {
8428
- return escapeHtml(tokens[idx].content);
8428
+ return escapeHtml$1(tokens[idx].content);
8429
8429
  };
8430
8430
  default_rules.html_block = function(tokens, idx) {
8431
8431
  return tokens[idx].content;
@@ -8443,7 +8443,7 @@ Renderer.prototype.renderAttrs = function renderAttrs(token) {
8443
8443
  }
8444
8444
  result = "";
8445
8445
  for (i = 0, l2 = token.attrs.length; i < l2; i++) {
8446
- result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
8446
+ result += " " + escapeHtml$1(token.attrs[i][0]) + '="' + escapeHtml$1(token.attrs[i][1]) + '"';
8447
8447
  }
8448
8448
  return result;
8449
8449
  };
@@ -12416,9 +12416,9 @@ MarkdownIt.prototype.disable = function(list2, ignoreInvalid) {
12416
12416
  }
12417
12417
  return this;
12418
12418
  };
12419
- MarkdownIt.prototype.use = function(plugin) {
12419
+ MarkdownIt.prototype.use = function(plugin2) {
12420
12420
  const args = [this].concat(Array.prototype.slice.call(arguments, 1));
12421
- plugin.apply(plugin, args);
12421
+ plugin2.apply(plugin2, args);
12422
12422
  return this;
12423
12423
  };
12424
12424
  MarkdownIt.prototype.parse = function(src, env) {
@@ -15865,6 +15865,42 @@ function findColumn(string2, col, tabSize, strict) {
15865
15865
  }
15866
15866
  return strict === true ? -1 : string2.length;
15867
15867
  }
15868
+ const cmState = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
15869
+ __proto__: null,
15870
+ Annotation,
15871
+ AnnotationType,
15872
+ ChangeDesc,
15873
+ ChangeSet,
15874
+ get CharCategory() {
15875
+ return CharCategory;
15876
+ },
15877
+ Compartment,
15878
+ EditorSelection,
15879
+ EditorState,
15880
+ Facet,
15881
+ Line: Line$1,
15882
+ get MapMode() {
15883
+ return MapMode;
15884
+ },
15885
+ Prec,
15886
+ Range: Range$1,
15887
+ RangeSet,
15888
+ RangeSetBuilder,
15889
+ RangeValue,
15890
+ SelectionRange,
15891
+ StateEffect,
15892
+ StateEffectType,
15893
+ StateField,
15894
+ Text,
15895
+ Transaction,
15896
+ codePointAt,
15897
+ codePointSize,
15898
+ combineConfig,
15899
+ countColumn,
15900
+ findClusterBreak,
15901
+ findColumn,
15902
+ fromCodePoint
15903
+ }, Symbol.toStringTag, { value: "Module" }));
15868
15904
  const C = "ͼ";
15869
15905
  const COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C);
15870
15906
  const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
@@ -17297,15 +17333,15 @@ class ViewPlugin {
17297
17333
  */
17298
17334
  static define(create, spec) {
17299
17335
  const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};
17300
- return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, (plugin) => {
17336
+ return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, (plugin2) => {
17301
17337
  let ext = [];
17302
17338
  if (deco)
17303
17339
  ext.push(decorations.of((view) => {
17304
- let pluginInst = view.plugin(plugin);
17340
+ let pluginInst = view.plugin(plugin2);
17305
17341
  return pluginInst ? deco(pluginInst) : Decoration.none;
17306
17342
  }));
17307
17343
  if (provide)
17308
- ext.push(provide(plugin));
17344
+ ext.push(provide(plugin2));
17309
17345
  return ext;
17310
17346
  });
17311
17347
  }
@@ -20331,10 +20367,10 @@ class InputState {
20331
20367
  this.mouseSelection.destroy();
20332
20368
  }
20333
20369
  }
20334
- function bindHandler(plugin, handler) {
20370
+ function bindHandler(plugin2, handler) {
20335
20371
  return (view, event) => {
20336
20372
  try {
20337
- return handler.call(plugin, event, view);
20373
+ return handler.call(plugin2, event, view);
20338
20374
  } catch (e) {
20339
20375
  logException(view.state, e);
20340
20376
  }
@@ -20345,19 +20381,19 @@ function computeHandlers(plugins) {
20345
20381
  function record(type) {
20346
20382
  return result[type] || (result[type] = { observers: [], handlers: [] });
20347
20383
  }
20348
- for (let plugin of plugins) {
20349
- let spec = plugin.spec, handlers2 = spec && spec.plugin.domEventHandlers, observers2 = spec && spec.plugin.domEventObservers;
20384
+ for (let plugin2 of plugins) {
20385
+ let spec = plugin2.spec, handlers2 = spec && spec.plugin.domEventHandlers, observers2 = spec && spec.plugin.domEventObservers;
20350
20386
  if (handlers2)
20351
20387
  for (let type in handlers2) {
20352
20388
  let f2 = handlers2[type];
20353
20389
  if (f2)
20354
- record(type).handlers.push(bindHandler(plugin.value, f2));
20390
+ record(type).handlers.push(bindHandler(plugin2.value, f2));
20355
20391
  }
20356
20392
  if (observers2)
20357
20393
  for (let type in observers2) {
20358
20394
  let f2 = observers2[type];
20359
20395
  if (f2)
20360
- record(type).observers.push(bindHandler(plugin.value, f2));
20396
+ record(type).observers.push(bindHandler(plugin2.value, f2));
20361
20397
  }
20362
20398
  }
20363
20399
  for (let type in handlers)
@@ -23344,8 +23380,8 @@ class EditorView {
23344
23380
  if (config2.scrollTo && config2.scrollTo.is(scrollIntoView$1))
23345
23381
  this.viewState.scrollTarget = config2.scrollTo.value.clip(this.viewState.state);
23346
23382
  this.plugins = this.state.facet(viewPlugin).map((spec) => new PluginInstance(spec));
23347
- for (let plugin of this.plugins)
23348
- plugin.update(this);
23383
+ for (let plugin2 of this.plugins)
23384
+ plugin2.update(this);
23349
23385
  this.observer = new DOMObserver(this);
23350
23386
  this.inputState = new InputState(this);
23351
23387
  this.inputState.ensureHandlers(this.plugins);
@@ -23480,13 +23516,13 @@ class EditorView {
23480
23516
  this.updateState = 2;
23481
23517
  let hadFocus = this.hasFocus;
23482
23518
  try {
23483
- for (let plugin of this.plugins)
23484
- plugin.destroy(this);
23519
+ for (let plugin2 of this.plugins)
23520
+ plugin2.destroy(this);
23485
23521
  this.viewState = new ViewState(this, newState);
23486
23522
  this.plugins = newState.facet(viewPlugin).map((spec) => new PluginInstance(spec));
23487
23523
  this.pluginMap.clear();
23488
- for (let plugin of this.plugins)
23489
- plugin.update(this);
23524
+ for (let plugin2 of this.plugins)
23525
+ plugin2.update(this);
23490
23526
  this.docView.destroy();
23491
23527
  this.docView = new DocView(this);
23492
23528
  this.inputState.ensureHandlers(this.plugins);
@@ -23509,14 +23545,14 @@ class EditorView {
23509
23545
  if (found < 0) {
23510
23546
  newPlugins.push(new PluginInstance(spec));
23511
23547
  } else {
23512
- let plugin = this.plugins[found];
23513
- plugin.mustUpdate = update;
23514
- newPlugins.push(plugin);
23548
+ let plugin2 = this.plugins[found];
23549
+ plugin2.mustUpdate = update;
23550
+ newPlugins.push(plugin2);
23515
23551
  }
23516
23552
  }
23517
- for (let plugin of this.plugins)
23518
- if (plugin.mustUpdate != update)
23519
- plugin.destroy(this);
23553
+ for (let plugin2 of this.plugins)
23554
+ if (plugin2.mustUpdate != update)
23555
+ plugin2.destroy(this);
23520
23556
  this.plugins = newPlugins;
23521
23557
  this.pluginMap.clear();
23522
23558
  } else {
@@ -23529,8 +23565,8 @@ class EditorView {
23529
23565
  this.inputState.ensureHandlers(this.plugins);
23530
23566
  }
23531
23567
  docViewUpdate() {
23532
- for (let plugin of this.plugins) {
23533
- let val = plugin.value;
23568
+ for (let plugin2 of this.plugins) {
23569
+ let val = plugin2.value;
23534
23570
  if (val && val.docViewUpdate) {
23535
23571
  try {
23536
23572
  val.docViewUpdate(this);
@@ -23739,10 +23775,10 @@ class EditorView {
23739
23775
  know you registered a given plugin, it is recommended to check
23740
23776
  the return value of this method.
23741
23777
  */
23742
- plugin(plugin) {
23743
- let known = this.pluginMap.get(plugin);
23744
- if (known === void 0 || known && known.plugin != plugin)
23745
- this.pluginMap.set(plugin, known = this.plugins.find((p2) => p2.plugin == plugin) || null);
23778
+ plugin(plugin2) {
23779
+ let known = this.pluginMap.get(plugin2);
23780
+ if (known === void 0 || known && known.plugin != plugin2)
23781
+ this.pluginMap.set(plugin2, known = this.plugins.find((p2) => p2.plugin == plugin2) || null);
23746
23782
  return known && known.update(this).value;
23747
23783
  }
23748
23784
  /**
@@ -24045,8 +24081,8 @@ class EditorView {
24045
24081
  destroy() {
24046
24082
  if (this.root.activeElement == this.contentDOM)
24047
24083
  this.contentDOM.blur();
24048
- for (let plugin of this.plugins)
24049
- plugin.destroy(this);
24084
+ for (let plugin2 of this.plugins)
24085
+ plugin2.destroy(this);
24050
24086
  this.plugins = [];
24051
24087
  this.inputState.destroy();
24052
24088
  this.docView.destroy();
@@ -24686,6 +24722,9 @@ function drawSelection(config2 = {}) {
24686
24722
  nativeSelectionHidden.of(true)
24687
24723
  ];
24688
24724
  }
24725
+ function getDrawSelectionConfig(state) {
24726
+ return state.facet(selectionConfig);
24727
+ }
24689
24728
  function configChanged(update) {
24690
24729
  return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
24691
24730
  }
@@ -25106,6 +25145,26 @@ class TabWidget extends WidgetType {
25106
25145
  return false;
25107
25146
  }
25108
25147
  }
25148
+ const plugin = /* @__PURE__ */ ViewPlugin.fromClass(class {
25149
+ constructor() {
25150
+ this.height = 1e3;
25151
+ this.attrs = { style: "padding-bottom: 1000px" };
25152
+ }
25153
+ update(update) {
25154
+ let { view } = update;
25155
+ let height = view.viewState.editorHeight - view.defaultLineHeight - view.documentPadding.top - 0.5;
25156
+ if (height >= 0 && height != this.height) {
25157
+ this.height = height;
25158
+ this.attrs = { style: `padding-bottom: ${height}px` };
25159
+ }
25160
+ }
25161
+ });
25162
+ function scrollPastEnd() {
25163
+ return [plugin, contentAttributes.of((view) => {
25164
+ var _a2;
25165
+ return ((_a2 = view.plugin(plugin)) === null || _a2 === void 0 ? void 0 : _a2.attrs) || null;
25166
+ })];
25167
+ }
25109
25168
  function highlightActiveLine() {
25110
25169
  return activeLineHighlighter;
25111
25170
  }
@@ -25132,6 +25191,49 @@ const activeLineHighlighter = /* @__PURE__ */ ViewPlugin.fromClass(class {
25132
25191
  }, {
25133
25192
  decorations: (v2) => v2.decorations
25134
25193
  });
25194
+ class Placeholder extends WidgetType {
25195
+ constructor(content2) {
25196
+ super();
25197
+ this.content = content2;
25198
+ }
25199
+ toDOM(view) {
25200
+ let wrap = document.createElement("span");
25201
+ wrap.className = "cm-placeholder";
25202
+ wrap.style.pointerEvents = "none";
25203
+ wrap.appendChild(typeof this.content == "string" ? document.createTextNode(this.content) : typeof this.content == "function" ? this.content(view) : this.content.cloneNode(true));
25204
+ wrap.setAttribute("aria-hidden", "true");
25205
+ return wrap;
25206
+ }
25207
+ coordsAt(dom) {
25208
+ let rects = dom.firstChild ? clientRectsFor(dom.firstChild) : [];
25209
+ if (!rects.length)
25210
+ return null;
25211
+ let style = window.getComputedStyle(dom.parentNode);
25212
+ let rect = flattenRect(rects[0], style.direction != "rtl");
25213
+ let lineHeight = parseInt(style.lineHeight);
25214
+ if (rect.bottom - rect.top > lineHeight * 1.5)
25215
+ return { left: rect.left, right: rect.right, top: rect.top, bottom: rect.top + lineHeight };
25216
+ return rect;
25217
+ }
25218
+ ignoreEvent() {
25219
+ return false;
25220
+ }
25221
+ }
25222
+ function placeholder(content2) {
25223
+ let plugin2 = ViewPlugin.fromClass(class {
25224
+ constructor(view) {
25225
+ this.view = view;
25226
+ this.placeholder = content2 ? Decoration.set([Decoration.widget({ widget: new Placeholder(content2), side: 1 }).range(0)]) : Decoration.none;
25227
+ }
25228
+ get decorations() {
25229
+ return this.view.state.doc.length ? Decoration.none : this.placeholder;
25230
+ }
25231
+ }, { decorations: (v2) => v2.decorations });
25232
+ return typeof content2 == "string" ? [
25233
+ plugin2,
25234
+ EditorView.contentAttributes.of({ "aria-placeholder": content2 })
25235
+ ] : plugin2;
25236
+ }
25135
25237
  const MaxOff = 2e3;
25136
25238
  function rectangleFor(state, a, b) {
25137
25239
  let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);
@@ -25196,7 +25298,7 @@ function rectangleSelectionStyle(view, event) {
25196
25298
  };
25197
25299
  }
25198
25300
  function rectangularSelection(options) {
25199
- let filter = (e) => e.altKey && e.button == 0;
25301
+ let filter = (options === null || options === void 0 ? void 0 : options.eventFilter) || ((e) => e.altKey && e.button == 0);
25200
25302
  return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);
25201
25303
  }
25202
25304
  const keys = {
@@ -25208,7 +25310,7 @@ const keys = {
25208
25310
  const showCrosshair = { style: "cursor: crosshair" };
25209
25311
  function crosshairCursor(options = {}) {
25210
25312
  let [code, getter] = keys[options.key || "Alt"];
25211
- let plugin = ViewPlugin.fromClass(class {
25313
+ let plugin2 = ViewPlugin.fromClass(class {
25212
25314
  constructor(view) {
25213
25315
  this.view = view;
25214
25316
  this.isDown = false;
@@ -25234,10 +25336,10 @@ function crosshairCursor(options = {}) {
25234
25336
  }
25235
25337
  });
25236
25338
  return [
25237
- plugin,
25339
+ plugin2,
25238
25340
  EditorView.contentAttributes.of((view) => {
25239
25341
  var _a2;
25240
- return ((_a2 = view.plugin(plugin)) === null || _a2 === void 0 ? void 0 : _a2.isDown) ? showCrosshair : null;
25342
+ return ((_a2 = view.plugin(plugin2)) === null || _a2 === void 0 ? void 0 : _a2.isDown) ? showCrosshair : null;
25241
25343
  })
25242
25344
  ];
25243
25345
  }
@@ -25255,7 +25357,7 @@ class TooltipViewManager {
25255
25357
  update(update, above) {
25256
25358
  var _a2;
25257
25359
  let input = update.state.facet(this.facet);
25258
- let tooltips = input.filter((x2) => x2);
25360
+ let tooltips2 = input.filter((x2) => x2);
25259
25361
  if (input === this.input) {
25260
25362
  for (let t2 of this.tooltipViews)
25261
25363
  if (t2.update)
@@ -25263,8 +25365,8 @@ class TooltipViewManager {
25263
25365
  return false;
25264
25366
  }
25265
25367
  let tooltipViews = [], newAbove = above ? [] : null;
25266
- for (let i = 0; i < tooltips.length; i++) {
25267
- let tip = tooltips[i], known = -1;
25368
+ for (let i = 0; i < tooltips2.length; i++) {
25369
+ let tip = tooltips2[i], known = -1;
25268
25370
  if (!tip)
25269
25371
  continue;
25270
25372
  for (let i2 = 0; i2 < this.tooltips.length; i2++) {
@@ -25294,11 +25396,14 @@ class TooltipViewManager {
25294
25396
  above.length = newAbove.length;
25295
25397
  }
25296
25398
  this.input = input;
25297
- this.tooltips = tooltips;
25399
+ this.tooltips = tooltips2;
25298
25400
  this.tooltipViews = tooltipViews;
25299
25401
  return true;
25300
25402
  }
25301
25403
  }
25404
+ function tooltips(config2 = {}) {
25405
+ return tooltipConfig.of(config2);
25406
+ }
25302
25407
  function windowSpace(view) {
25303
25408
  let docElt = view.dom.ownerDocument.documentElement;
25304
25409
  return { top: 0, left: 0, bottom: docElt.clientHeight, right: docElt.clientWidth };
@@ -25692,18 +25797,18 @@ class HoverTooltipHost {
25692
25797
  }
25693
25798
  }
25694
25799
  const showHoverTooltipHost = /* @__PURE__ */ showTooltip.compute([showHoverTooltip], (state) => {
25695
- let tooltips = state.facet(showHoverTooltip);
25696
- if (tooltips.length === 0)
25800
+ let tooltips2 = state.facet(showHoverTooltip);
25801
+ if (tooltips2.length === 0)
25697
25802
  return null;
25698
25803
  return {
25699
- pos: Math.min(...tooltips.map((t2) => t2.pos)),
25700
- end: Math.max(...tooltips.map((t2) => {
25804
+ pos: Math.min(...tooltips2.map((t2) => t2.pos)),
25805
+ end: Math.max(...tooltips2.map((t2) => {
25701
25806
  var _a2;
25702
25807
  return (_a2 = t2.end) !== null && _a2 !== void 0 ? _a2 : t2.pos;
25703
25808
  })),
25704
25809
  create: HoverTooltipHost.create,
25705
- above: tooltips[0].above,
25706
- arrow: tooltips.some((t2) => t2.arrow)
25810
+ above: tooltips2[0].above,
25811
+ arrow: tooltips2.some((t2) => t2.arrow)
25707
25812
  };
25708
25813
  });
25709
25814
  const hoverPlugin = /* @__PURE__ */ Facet.define();
@@ -25769,10 +25874,10 @@ class HoverPlugin {
25769
25874
  let open = this.source(view, pos, side);
25770
25875
  let done = (value) => {
25771
25876
  if (value && !(Array.isArray(value) && !value.length)) {
25772
- let tooltips = Array.isArray(value) ? value : [value];
25877
+ let tooltips2 = Array.isArray(value) ? value : [value];
25773
25878
  if (locked)
25774
- this.locked.set(tooltips, locked);
25775
- view.dispatch({ effects: this.setHover.of(tooltips) });
25879
+ this.locked.set(tooltips2, locked);
25880
+ view.dispatch({ effects: this.setHover.of(tooltips2) });
25776
25881
  }
25777
25882
  };
25778
25883
  if (open && "then" in open) {
@@ -25788,9 +25893,9 @@ class HoverPlugin {
25788
25893
  }
25789
25894
  }
25790
25895
  get tooltip() {
25791
- let plugin = this.view.plugin(tooltipPlugin);
25792
- let index = plugin ? plugin.manager.tooltips.findIndex((t2) => t2.create == HoverTooltipHost.create) : -1;
25793
- return index > -1 ? plugin.manager.tooltipViews[index] : null;
25896
+ let plugin2 = this.view.plugin(tooltipPlugin);
25897
+ let index = plugin2 ? plugin2.manager.tooltips.findIndex((t2) => t2.create == HoverTooltipHost.create) : -1;
25898
+ return index > -1 ? plugin2.manager.tooltipViews[index] : null;
25794
25899
  }
25795
25900
  mousemove(event) {
25796
25901
  var _a2, _b;
@@ -25898,7 +26003,7 @@ function hoverTooltip(source, options = {}) {
25898
26003
  },
25899
26004
  provide: (f2) => showHoverTooltip.from(f2)
25900
26005
  });
25901
- const plugin = ViewPlugin.define((view) => new HoverPlugin(
26006
+ const plugin2 = ViewPlugin.define((view) => new HoverPlugin(
25902
26007
  view,
25903
26008
  source,
25904
26009
  hoverState,
@@ -25911,8 +26016,8 @@ function hoverTooltip(source, options = {}) {
25911
26016
  active: hoverState,
25912
26017
  extension: [
25913
26018
  hoverState,
25914
- plugin,
25915
- hoverPlugin.of(plugin),
26019
+ plugin2,
26020
+ hoverPlugin.of(plugin2),
25916
26021
  showHoverTooltipHost
25917
26022
  ]
25918
26023
  };
@@ -25925,17 +26030,29 @@ function activateHover(view, pos, side, options = {}) {
25925
26030
  if (found)
25926
26031
  plugins = [found];
25927
26032
  }
25928
- for (let plugin of plugins)
25929
- plugin.activateHover(view, pos, side, (_a2 = options.until) !== null && _a2 !== void 0 ? _a2 : () => false);
26033
+ for (let plugin2 of plugins)
26034
+ plugin2.activateHover(view, pos, side, (_a2 = options.until) !== null && _a2 !== void 0 ? _a2 : () => false);
25930
26035
  }
25931
26036
  function getTooltip(view, tooltip) {
25932
- let plugin = view.plugin(tooltipPlugin);
25933
- if (!plugin)
26037
+ let plugin2 = view.plugin(tooltipPlugin);
26038
+ if (!plugin2)
25934
26039
  return null;
25935
- let found = plugin.manager.tooltips.indexOf(tooltip);
25936
- return found < 0 ? null : plugin.manager.tooltipViews[found];
26040
+ let found = plugin2.manager.tooltips.indexOf(tooltip);
26041
+ return found < 0 ? null : plugin2.manager.tooltipViews[found];
26042
+ }
26043
+ function hasHoverTooltips(state) {
26044
+ return state.facet(showHoverTooltip).some((x2) => x2);
25937
26045
  }
25938
26046
  const closeHoverTooltipEffect = /* @__PURE__ */ StateEffect.define();
26047
+ const closeHoverTooltips = /* @__PURE__ */ closeHoverTooltipEffect.of(null);
26048
+ function closeHoverTooltip(tooltip) {
26049
+ return closeHoverTooltipEffect.of(tooltip.active);
26050
+ }
26051
+ function repositionTooltips(view) {
26052
+ let plugin2 = view.plugin(tooltipPlugin);
26053
+ if (plugin2)
26054
+ plugin2.maybeMeasure();
26055
+ }
25939
26056
  const panelConfig = /* @__PURE__ */ Facet.define({
25940
26057
  combine(configs) {
25941
26058
  let topContainer, bottomContainer;
@@ -25946,10 +26063,13 @@ const panelConfig = /* @__PURE__ */ Facet.define({
25946
26063
  return { topContainer, bottomContainer };
25947
26064
  }
25948
26065
  });
26066
+ function panels(config2) {
26067
+ return config2 ? [panelConfig.of(config2)] : [];
26068
+ }
25949
26069
  function getPanel(view, panel) {
25950
- let plugin = view.plugin(panelPlugin);
25951
- let index = plugin ? plugin.specs.indexOf(panel) : -1;
25952
- return index > -1 ? plugin.panels[index] : null;
26070
+ let plugin2 = view.plugin(panelPlugin);
26071
+ let index = plugin2 ? plugin2.specs.indexOf(panel) : -1;
26072
+ return index > -1 ? plugin2.panels[index] : null;
25953
26073
  }
25954
26074
  const panelPlugin = /* @__PURE__ */ ViewPlugin.fromClass(class {
25955
26075
  constructor(view) {
@@ -25982,7 +26102,7 @@ const panelPlugin = /* @__PURE__ */ ViewPlugin.fromClass(class {
25982
26102
  let input = update.state.facet(showPanel);
25983
26103
  if (input != this.input) {
25984
26104
  let specs = input.filter((x2) => x2);
25985
- let panels = [], top2 = [], bottom = [], mount = [];
26105
+ let panels2 = [], top2 = [], bottom = [], mount = [];
25986
26106
  for (let spec of specs) {
25987
26107
  let known = this.specs.indexOf(spec), panel;
25988
26108
  if (known < 0) {
@@ -25993,11 +26113,11 @@ const panelPlugin = /* @__PURE__ */ ViewPlugin.fromClass(class {
25993
26113
  if (panel.update)
25994
26114
  panel.update(update);
25995
26115
  }
25996
- panels.push(panel);
26116
+ panels2.push(panel);
25997
26117
  (panel.top ? top2 : bottom).push(panel);
25998
26118
  }
25999
26119
  this.specs = specs;
26000
- this.panels = panels;
26120
+ this.panels = panels2;
26001
26121
  this.top.sync(top2);
26002
26122
  this.bottom.sync(bottom);
26003
26123
  for (let p2 of mount) {
@@ -26016,8 +26136,8 @@ const panelPlugin = /* @__PURE__ */ ViewPlugin.fromClass(class {
26016
26136
  this.bottom.sync([]);
26017
26137
  }
26018
26138
  }, {
26019
- provide: (plugin) => EditorView.scrollMargins.of((view) => {
26020
- let value = view.plugin(plugin);
26139
+ provide: (plugin2) => EditorView.scrollMargins.of((view) => {
26140
+ let value = view.plugin(plugin2);
26021
26141
  return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
26022
26142
  })
26023
26143
  });
@@ -26031,11 +26151,11 @@ class PanelGroup {
26031
26151
  this.panels = [];
26032
26152
  this.syncClasses();
26033
26153
  }
26034
- sync(panels) {
26154
+ sync(panels2) {
26035
26155
  for (let p2 of this.panels)
26036
- if (p2.destroy && panels.indexOf(p2) < 0)
26156
+ if (p2.destroy && panels2.indexOf(p2) < 0)
26037
26157
  p2.destroy();
26038
- this.panels = panels;
26158
+ this.panels = panels2;
26039
26159
  this.syncDOM();
26040
26160
  }
26041
26161
  syncDOM() {
@@ -26107,6 +26227,15 @@ function showDialog(view, config2) {
26107
26227
  return form;
26108
26228
  }) };
26109
26229
  }
26230
+ function getDialog(view, className) {
26231
+ let dialogs = view.state.field(dialogField, false) || [];
26232
+ for (let open of dialogs) {
26233
+ let panel = getPanel(view, open);
26234
+ if (panel && panel.dom.classList.contains(className))
26235
+ return panel;
26236
+ }
26237
+ return null;
26238
+ }
26110
26239
  const dialogField = /* @__PURE__ */ StateField.define({
26111
26240
  create() {
26112
26241
  return [];
@@ -26241,6 +26370,8 @@ function gutters(config2) {
26241
26370
  let result = [
26242
26371
  gutterView
26243
26372
  ];
26373
+ if (config2 && config2.fixed === false)
26374
+ result.push(unfixGutters.of(true));
26244
26375
  return result;
26245
26376
  }
26246
26377
  const gutterView = /* @__PURE__ */ ViewPlugin.fromClass(class {
@@ -26382,8 +26513,8 @@ const gutterView = /* @__PURE__ */ ViewPlugin.fromClass(class {
26382
26513
  this.domAfter.remove();
26383
26514
  }
26384
26515
  }, {
26385
- provide: (plugin) => EditorView.scrollMargins.of((view) => {
26386
- let value = view.plugin(plugin);
26516
+ provide: (plugin2) => EditorView.scrollMargins.of((view) => {
26517
+ let value = view.plugin(plugin2);
26387
26518
  if (!value || value.gutters.length == 0 || !value.fixed)
26388
26519
  return null;
26389
26520
  let before = value.dom.offsetWidth * view.scaleX, after = value.domAfter ? value.domAfter.offsetWidth * view.scaleX : 0;
@@ -26663,6 +26794,102 @@ const activeLineGutterHighlighter = /* @__PURE__ */ gutterLineClass.compute(["se
26663
26794
  function highlightActiveLineGutter() {
26664
26795
  return activeLineGutterHighlighter;
26665
26796
  }
26797
+ function matcher(decorator) {
26798
+ return ViewPlugin.define((view) => ({
26799
+ decorations: decorator.createDeco(view),
26800
+ update(u2) {
26801
+ this.decorations = decorator.updateDeco(u2, this.decorations);
26802
+ }
26803
+ }), {
26804
+ decorations: (v2) => v2.decorations
26805
+ });
26806
+ }
26807
+ const tabDeco = /* @__PURE__ */ Decoration.mark({ class: "cm-highlightTab" });
26808
+ const spaceDeco = /* @__PURE__ */ Decoration.mark({ class: "cm-highlightSpace" });
26809
+ const whitespaceHighlighter = /* @__PURE__ */ matcher(/* @__PURE__ */ new MatchDecorator({
26810
+ regexp: /\t| /g,
26811
+ decoration: (match2) => match2[0] == " " ? tabDeco : spaceDeco,
26812
+ boundary: /\S/
26813
+ }));
26814
+ function highlightWhitespace() {
26815
+ return whitespaceHighlighter;
26816
+ }
26817
+ const trailingHighlighter = /* @__PURE__ */ matcher(/* @__PURE__ */ new MatchDecorator({
26818
+ regexp: /\s+$/g,
26819
+ decoration: /* @__PURE__ */ Decoration.mark({ class: "cm-trailingSpace" })
26820
+ }));
26821
+ function highlightTrailingWhitespace() {
26822
+ return trailingHighlighter;
26823
+ }
26824
+ const __test = {
26825
+ HeightMap,
26826
+ HeightOracle,
26827
+ MeasuredHeights,
26828
+ QueryType: QueryType$1,
26829
+ ChangedRange,
26830
+ computeOrder,
26831
+ moveVisually,
26832
+ clearHeightChangeFlag,
26833
+ getHeightChangeFlag: () => heightChangeFlag
26834
+ };
26835
+ const cmView = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26836
+ __proto__: null,
26837
+ BidiSpan,
26838
+ BlockInfo,
26839
+ get BlockType() {
26840
+ return BlockType;
26841
+ },
26842
+ BlockWrapper,
26843
+ Decoration,
26844
+ get Direction() {
26845
+ return Direction;
26846
+ },
26847
+ EditorView,
26848
+ GutterMarker,
26849
+ MatchDecorator,
26850
+ RectangleMarker,
26851
+ ViewPlugin,
26852
+ ViewUpdate,
26853
+ WidgetType,
26854
+ __test,
26855
+ activateHover,
26856
+ closeHoverTooltip,
26857
+ closeHoverTooltips,
26858
+ crosshairCursor,
26859
+ drawSelection,
26860
+ dropCursor,
26861
+ getDialog,
26862
+ getDrawSelectionConfig,
26863
+ getPanel,
26864
+ getTooltip,
26865
+ gutter,
26866
+ gutterLineClass,
26867
+ gutterWidgetClass,
26868
+ gutters,
26869
+ hasHoverTooltips,
26870
+ highlightActiveLine,
26871
+ highlightActiveLineGutter,
26872
+ highlightSpecialChars,
26873
+ highlightTrailingWhitespace,
26874
+ highlightWhitespace,
26875
+ hoverTooltip,
26876
+ keymap,
26877
+ layer,
26878
+ lineNumberMarkers,
26879
+ lineNumberWidgetMarker,
26880
+ lineNumbers,
26881
+ logException,
26882
+ panels,
26883
+ placeholder,
26884
+ rectangularSelection,
26885
+ repositionTooltips,
26886
+ runScopeHandlers,
26887
+ scrollPastEnd,
26888
+ showDialog,
26889
+ showPanel,
26890
+ showTooltip,
26891
+ tooltips
26892
+ }, Symbol.toStringTag, { value: "Module" }));
26666
26893
  const DefaultBufferLength = 1024;
26667
26894
  let nextPropID = 0;
26668
26895
  class Range2 {
@@ -31743,9 +31970,9 @@ function sortOptions(active, state) {
31743
31970
  }
31744
31971
  } else {
31745
31972
  let pattern = state.sliceDoc(a.from, a.to), match2;
31746
- let matcher = conf.filterStrict ? new StrictMatcher(pattern) : new FuzzyMatcher(pattern);
31973
+ let matcher2 = conf.filterStrict ? new StrictMatcher(pattern) : new FuzzyMatcher(pattern);
31747
31974
  for (let option of a.result.options)
31748
- if (match2 = matcher.match(option.label)) {
31975
+ if (match2 = matcher2.match(option.label)) {
31749
31976
  let matched = !option.displayLabel ? match2.matched : getMatch ? getMatch(option, match2.matched) : [];
31750
31977
  let score2 = match2.score + (option.boost || 0);
31751
31978
  addOption(new Option(option, a.source, matched, score2));
@@ -43110,6 +43337,80 @@ function diffComment(prev, next) {
43110
43337
  }
43111
43338
  return patch;
43112
43339
  }
43340
+ var CLIP_ATTR = "data-inplan-clip";
43341
+ var CLIP_ATTR_RE = new RegExp(`${CLIP_ATTR}="([^"]*)"`);
43342
+ var FULL_ANCHOR = /\[[^\]]*\]\(#(cmt-[0-9a-z]+)\)/gi;
43343
+ var ANCHOR_HREF = /\]\(#(cmt-[0-9a-z]+)\)/gi;
43344
+ function anchorIdsIn(fragment) {
43345
+ const ids = [];
43346
+ for (const m2 of fragment.matchAll(FULL_ANCHOR)) ids.push(m2[1]);
43347
+ return ids;
43348
+ }
43349
+ function threadsFor(ids, all) {
43350
+ const keep = new Set(ids);
43351
+ let changed = true;
43352
+ while (changed) {
43353
+ changed = false;
43354
+ for (const c of all) {
43355
+ if (c.parentId && keep.has(c.parentId) && !keep.has(c.id)) {
43356
+ keep.add(c.id);
43357
+ changed = true;
43358
+ }
43359
+ }
43360
+ }
43361
+ return all.filter((c) => keep.has(c.id));
43362
+ }
43363
+ function remapComments(comments, taken) {
43364
+ const used = new Set(taken);
43365
+ const idMap = /* @__PURE__ */ new Map();
43366
+ for (const c of comments) {
43367
+ const id2 = genId(used);
43368
+ used.add(id2);
43369
+ idMap.set(c.id, id2);
43370
+ }
43371
+ const remapped = comments.map((c) => ({
43372
+ ...c,
43373
+ id: idMap.get(c.id),
43374
+ ...c.parentId !== void 0 ? { parentId: idMap.get(c.parentId) ?? c.parentId } : {}
43375
+ }));
43376
+ return { comments: remapped, idMap };
43377
+ }
43378
+ function rewriteAnchors(fragment, idMap) {
43379
+ return fragment.replace(ANCHOR_HREF, (whole, id2) => {
43380
+ const next = idMap.get(id2);
43381
+ return next ? `](#${next})` : whole;
43382
+ });
43383
+ }
43384
+ function escapeHtml(s) {
43385
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
43386
+ }
43387
+ function toBase64(s) {
43388
+ const bytes = new TextEncoder().encode(s);
43389
+ let bin = "";
43390
+ for (const b of bytes) bin += String.fromCharCode(b);
43391
+ return btoa(bin);
43392
+ }
43393
+ function fromBase64(b64) {
43394
+ const bin = atob(b64);
43395
+ const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
43396
+ return new TextDecoder().decode(bytes);
43397
+ }
43398
+ function buildClipHtml(text2, comments) {
43399
+ const payload = { v: 1, comments };
43400
+ return `<span ${CLIP_ATTR}="${toBase64(JSON.stringify(payload))}">${escapeHtml(text2)}</span>`;
43401
+ }
43402
+ function readClipHtml(html2) {
43403
+ const m2 = CLIP_ATTR_RE.exec(html2);
43404
+ if (!m2) return null;
43405
+ try {
43406
+ const payload = JSON.parse(fromBase64(m2[1]));
43407
+ if (payload && typeof payload === "object" && payload.v === 1 && Array.isArray(payload.comments)) {
43408
+ return payload;
43409
+ }
43410
+ } catch {
43411
+ }
43412
+ return null;
43413
+ }
43113
43414
  function slugifyFilename(text2) {
43114
43415
  const base2 = text2.trim().toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_-]+/g, "").replace(/_{2,}/g, "_").replace(/^[_-]+|[_-]+$/g, "");
43115
43416
  return `${base2 || "untitled"}.md`;
@@ -43233,6 +43534,7 @@ var EN = {
43233
43534
  "msg.autosaving": "auto-saving…",
43234
43535
  "msg.autosaved": "autosaved (backup)",
43235
43536
  "msg.turnFinished": "turn finished — waiting for agent",
43537
+ "msg.unsavedAnswer": "You have an unsaved answer — click “Answer” to save it, or Send again to skip.",
43236
43538
  "msg.cantAnchor": "Comments can't be anchored to this selection",
43237
43539
  // status bar
43238
43540
  "status.ready": "ready",
@@ -43267,6 +43569,10 @@ var EN = {
43267
43569
  "agent.overIncluded": "— over included",
43268
43570
  "agent.over": "(over)",
43269
43571
  "agent.connection": "Agent connection",
43572
+ "agent.localCmdHint": "Paste this to your coding agent:",
43573
+ "agent.localCmdBody": "Collaborate with me on my inplan plan. Check the CLI with `inplan --version` (if missing, install it: `npm i -g inplan`), sign in with `inplan login`, then run `{cmd}` and work with me through the comments.",
43574
+ "agent.copy": "Copy",
43575
+ "agent.copied": "Copied",
43270
43576
  // comment rail
43271
43577
  "rail.comments": "Comments",
43272
43578
  "rail.emptyHint": "No comments. Select text and use “+ {action}”.",
@@ -43379,6 +43685,7 @@ function NewDocModal({
43379
43685
  initialPath,
43380
43686
  exists,
43381
43687
  onPick,
43688
+ draftOption,
43382
43689
  onSubmit,
43383
43690
  onCancel
43384
43691
  }) {
@@ -43386,7 +43693,9 @@ function NewDocModal({
43386
43693
  const [title, setTitle] = reactExports.useState(initialTitle);
43387
43694
  const [path, setPath] = reactExports.useState(initialPath);
43388
43695
  const [append, setAppend] = reactExports.useState(true);
43696
+ const [prompt, setPrompt] = reactExports.useState("");
43389
43697
  const ref = reactExports.useRef(null);
43698
+ const showDraft = mode === "create" && !!draftOption;
43390
43699
  reactExports.useEffect(() => ref.current?.querySelector("input")?.focus(), []);
43391
43700
  reactExports.useEffect(() => {
43392
43701
  const onKey = (e) => {
@@ -43396,7 +43705,7 @@ function NewDocModal({
43396
43705
  return () => document.removeEventListener("keydown", onKey);
43397
43706
  }, [onCancel]);
43398
43707
  const ok2 = title.trim().length > 0 && path.trim().length > 0;
43399
- const submit = () => ok2 && onSubmit(title.trim(), path.trim(), { append });
43708
+ const submit = () => ok2 && onSubmit(title.trim(), path.trim(), { append, ...showDraft && prompt.trim() ? { draftPrompt: prompt.trim() } : {} });
43400
43709
  const onEnter = (e) => {
43401
43710
  if (e.key === "Enter") submit();
43402
43711
  };
@@ -43417,6 +43726,10 @@ function NewDocModal({
43417
43726
  }, children: t2("newdoc.browse") })
43418
43727
  ] })
43419
43728
  ] }),
43729
+ showDraft && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "ap-newdoc-field ap-newdoc-draft", children: [
43730
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: draftOption.label }),
43731
+ /* @__PURE__ */ jsxRuntimeExports.jsx("textarea", { className: "ap-newdoc-prompt", rows: 3, placeholder: draftOption.placeholder, value: prompt, onChange: (e) => setPrompt(e.target.value) })
43732
+ ] }),
43420
43733
  exists && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-newdoc-exists", role: "alert", children: [
43421
43734
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-newdoc-warn", children: t2("newdoc.exists") }),
43422
43735
  mode === "move" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "ap-newdoc-append", children: [
@@ -43635,7 +43948,8 @@ function QuestionChips({
43635
43948
  question: question2,
43636
43949
  disabled,
43637
43950
  answered = null,
43638
- onAnswer
43951
+ onAnswer,
43952
+ onPending
43639
43953
  }) {
43640
43954
  const t2 = useT();
43641
43955
  const isAnswered = answered != null;
@@ -43646,6 +43960,14 @@ function QuestionChips({
43646
43960
  const picking = !isAnswered || editing;
43647
43961
  const settled = answered ?? [];
43648
43962
  const hiddenCount = picking ? 0 : question2.choices.filter((c) => !settled.includes(c.label)).length;
43963
+ const sameAsSaved = selected.length === settled.length && selected.every((x2) => settled.includes(x2)) && !other.trim();
43964
+ const dirty = picking && (selected.length > 0 || other.trim().length > 0) && !sameAsSaved;
43965
+ const onPendingRef = reactExports.useRef(onPending);
43966
+ onPendingRef.current = onPending;
43967
+ reactExports.useEffect(() => {
43968
+ onPendingRef.current?.(dirty);
43969
+ }, [dirty]);
43970
+ reactExports.useEffect(() => () => onPendingRef.current?.(false), []);
43649
43971
  const toggle = (label) => {
43650
43972
  if (question2.multiSelect) {
43651
43973
  setSelected((s) => s.includes(label) ? s.filter((x2) => x2 !== label) : [...s, label]);
@@ -43746,7 +44068,7 @@ var findField = StateField.define({
43746
44068
  },
43747
44069
  provide: (f2) => EditorView.decorations.from(f2, (v2) => v2.deco)
43748
44070
  });
43749
- var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, editable: editable2, onChange, onCursorLine, onFind, find: find2, binding }, ref) {
44071
+ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, editable: editable2, onChange, onCursorLine, onFind, find: find2, binding, commentsForCopy, onCutComments, onPasteComments }, ref) {
43750
44072
  const host = reactExports.useRef(null);
43751
44073
  const view = reactExports.useRef(null);
43752
44074
  const editableComp = reactExports.useRef(new Compartment());
@@ -43758,6 +44080,12 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
43758
44080
  onFindRef.current = onFind;
43759
44081
  const bindingRef = reactExports.useRef(binding);
43760
44082
  bindingRef.current = binding;
44083
+ const commentsForCopyRef = reactExports.useRef(commentsForCopy);
44084
+ commentsForCopyRef.current = commentsForCopy;
44085
+ const onCutCommentsRef = reactExports.useRef(onCutComments);
44086
+ onCutCommentsRef.current = onCutComments;
44087
+ const onPasteCommentsRef = reactExports.useRef(onPasteComments);
44088
+ onPasteCommentsRef.current = onPasteComments;
43761
44089
  reactExports.useImperativeHandle(ref, () => ({
43762
44090
  scrollToLine(line) {
43763
44091
  const v2 = view.current;
@@ -43777,6 +44105,19 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
43777
44105
  }));
43778
44106
  reactExports.useEffect(() => {
43779
44107
  if (!host.current) return;
44108
+ const handleCopyCut = (e, v22, cut) => {
44109
+ const sel = v22.state.selection.main;
44110
+ if (sel.empty) return false;
44111
+ if (cut && !onCutCommentsRef.current) return false;
44112
+ const text2 = v22.state.sliceDoc(sel.from, sel.to);
44113
+ const comments = commentsForCopyRef.current?.(text2) ?? [];
44114
+ if (comments.length === 0) return false;
44115
+ e.preventDefault();
44116
+ e.clipboardData?.setData("text/plain", text2);
44117
+ e.clipboardData?.setData("text/html", buildClipHtml(text2, comments));
44118
+ if (cut) onCutCommentsRef.current(text2, sel.from, sel.to);
44119
+ return true;
44120
+ };
43780
44121
  const v2 = new EditorView({
43781
44122
  parent: host.current,
43782
44123
  state: EditorState.create({
@@ -43806,6 +44147,24 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
43806
44147
  onCursorLineRef.current(u2.state.doc.lineAt(u2.state.selection.main.head).number - 1);
43807
44148
  }
43808
44149
  }),
44150
+ // Copy/cut/paste that carries span-comment threads (see clipboard.ts). Each returns
44151
+ // false to fall through to CodeMirror's native handling whenever there's nothing
44152
+ // inplan-specific to do — so plain copy/paste, multi-cursor, etc. are untouched.
44153
+ EditorView.domEventHandlers({
44154
+ copy: (e, v22) => handleCopyCut(e, v22, false),
44155
+ cut: (e, v22) => handleCopyCut(e, v22, true),
44156
+ paste: (e, v22) => {
44157
+ if (!onPasteCommentsRef.current) return false;
44158
+ const html2 = e.clipboardData?.getData("text/html") ?? "";
44159
+ const payload = html2 ? readClipHtml(html2) : null;
44160
+ if (!payload) return false;
44161
+ const text2 = e.clipboardData?.getData("text/plain") ?? "";
44162
+ const sel = v22.state.selection.main;
44163
+ e.preventDefault();
44164
+ onPasteCommentsRef.current(text2, payload, sel.from, sel.to);
44165
+ return true;
44166
+ }
44167
+ }),
43809
44168
  // Plugin-injected binding extensions (e.g. remote cursors).
43810
44169
  ...binding ? binding.extensions : []
43811
44170
  ]
@@ -44008,7 +44367,6 @@ function ProfileMenu({
44008
44367
  setEditing(false);
44009
44368
  setOpen(false);
44010
44369
  };
44011
- const accountLabel = user ? user.name : t2("profile.notSignedIn");
44012
44370
  const note = sourceNote(identitySource);
44013
44371
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-profile", ref, children: [
44014
44372
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -44017,7 +44375,7 @@ function ProfileMenu({
44017
44375
  className: "ap-avatar",
44018
44376
  "data-onboard": "settings",
44019
44377
  title: user ? `${user.name}${user.email ? ` <${user.email}>` : ""}` : t2("profile.account"),
44020
- "aria-label": `${t2("profile.account")} — ${accountLabel}`,
44378
+ "aria-label": user ? `${t2("profile.account")} — ${user.name}` : t2("profile.account"),
44021
44379
  "aria-haspopup": "menu",
44022
44380
  "aria-expanded": isOpen,
44023
44381
  onClick: () => setOpen((v2) => !v2),
@@ -44025,9 +44383,9 @@ function ProfileMenu({
44025
44383
  }
44026
44384
  ),
44027
44385
  isOpen && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-profile-menu", role: "menu", children: [
44028
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-profile-id", children: [
44029
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-profile-name", children: accountLabel }),
44030
- user?.email && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-profile-email", children: user.email }),
44386
+ user && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-profile-id", children: [
44387
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-profile-name", children: user.name }),
44388
+ user.email && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-profile-email", children: user.email }),
44031
44389
  note && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-profile-source", children: note })
44032
44390
  ] }),
44033
44391
  editing ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -44150,11 +44508,28 @@ function AgentIndicator({
44150
44508
  quota,
44151
44509
  byoKey,
44152
44510
  policy,
44153
- onSetPolicy
44511
+ onSetPolicy,
44512
+ localCommand
44154
44513
  }) {
44155
44514
  const t2 = useT();
44156
44515
  const [open, setOpen] = reactExports.useState(false);
44516
+ const [copied, setCopied] = reactExports.useState(false);
44157
44517
  const ref = reactExports.useRef(null);
44518
+ const agentMessage = localCommand ? t2("agent.localCmdBody", { cmd: localCommand }) : "";
44519
+ const preview = agentMessage.length > 84 ? `${agentMessage.slice(0, 52)} … ${agentMessage.slice(-26)}` : agentMessage;
44520
+ const copy = () => {
44521
+ if (!agentMessage) return;
44522
+ const write = navigator.clipboard?.writeText(agentMessage);
44523
+ if (!write) return;
44524
+ void write.then(
44525
+ () => {
44526
+ setCopied(true);
44527
+ setTimeout(() => setCopied(false), 1500);
44528
+ },
44529
+ () => {
44530
+ }
44531
+ );
44532
+ };
44158
44533
  const POLICY_OPTIONS = [
44159
44534
  { value: "auto", label: t2("agent.connectCloud") },
44160
44535
  { value: "local", label: t2("agent.waitLocal") },
@@ -44206,7 +44581,14 @@ function AgentIndicator({
44206
44581
  ]
44207
44582
  },
44208
44583
  o.value
44209
- )) })
44584
+ )) }),
44585
+ policy === "local" && agentMessage && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-agent-localcmd", children: [
44586
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-agent-localcmd-hint", children: t2("agent.localCmdHint") }),
44587
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-agent-localcmd-row", children: [
44588
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-agent-localcmd-msg", title: agentMessage, children: preview }),
44589
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-agent-localcmd-copy", onClick: copy, "aria-label": t2("agent.copy"), children: copied ? t2("agent.copied") : t2("agent.copy") })
44590
+ ] })
44591
+ ] })
44210
44592
  ] })
44211
44593
  ] });
44212
44594
  }
@@ -44251,6 +44633,10 @@ var IconRevealArchive = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { ch
44251
44633
  /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "5", y: "13", width: "14", height: "7", rx: "1" }),
44252
44634
  /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "5", y1: "16", x2: "19", y2: "16" })
44253
44635
  ] });
44636
+ var IconPencil = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44637
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 20h9" }),
44638
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })
44639
+ ] });
44254
44640
  function parseAuthor(author) {
44255
44641
  const m2 = author.match(/^(.*?)\s*<([^>]+)>\s*$/);
44256
44642
  const email = m2 ? m2[2].trim() : "";
@@ -44353,6 +44739,27 @@ function QuitDialog({
44353
44739
  ] })
44354
44740
  ] }) });
44355
44741
  }
44742
+ var EditorErrorBoundary = class extends reactExports.Component {
44743
+ state = { error: null };
44744
+ static getDerivedStateFromError(error2) {
44745
+ return { error: error2 };
44746
+ }
44747
+ componentDidCatch(error2, info) {
44748
+ console.error(`[inplan] ${this.props.label ?? "editor"} crashed — contained by the error boundary`, error2, info.componentStack);
44749
+ }
44750
+ render() {
44751
+ const { error: error2 } = this.state;
44752
+ if (!error2) return this.props.children;
44753
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-editor-error", role: "alert", children: [
44754
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "ap-editor-error-title", children: [
44755
+ this.props.label ?? "This view",
44756
+ " couldn't load."
44757
+ ] }),
44758
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "ap-editor-error-msg", children: error2.message }),
44759
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-editor-error-retry", onClick: () => this.setState({ error: null }), children: "Try again" })
44760
+ ] });
44761
+ }
44762
+ };
44356
44763
  var STEPS = [
44357
44764
  { id: "welcome", target: null, gate: null },
44358
44765
  { id: "settings", target: '[data-onboard="settings"]', gate: null },
@@ -44738,6 +45145,16 @@ function commentBlockReason(raw, body, range, root) {
44738
45145
  if (b === "not-found") return anchorFailureReason(range);
44739
45146
  return null;
44740
45147
  }
45148
+ function CloudSignInOverlay({ url, onDismiss }) {
45149
+ reactExports.useEffect(() => {
45150
+ const onKey = (e) => {
45151
+ if (e.key === "Escape") onDismiss();
45152
+ };
45153
+ document.addEventListener("keydown", onKey);
45154
+ return () => document.removeEventListener("keydown", onKey);
45155
+ }, [onDismiss]);
45156
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-signin-backdrop", onMouseDown: onDismiss, role: "presentation", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-signin-panel", onMouseDown: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntimeExports.jsx("iframe", { className: "ap-signin-frame", src: url, title: "Sign in to inplan.ai" }) }) });
45157
+ }
44741
45158
  function App(props = {}) {
44742
45159
  const t2 = useT();
44743
45160
  const [loaded, setLoaded] = reactExports.useState(false);
@@ -44763,6 +45180,7 @@ function App(props = {}) {
44763
45180
  const [reloadReady, setReloadReady] = reactExports.useState(false);
44764
45181
  const [reloadIn, setReloadIn] = reactExports.useState(null);
44765
45182
  const [update, setUpdate] = reactExports.useState(null);
45183
+ const [signInUrl, setSignInUrl] = reactExports.useState(null);
44766
45184
  const profile = useProfile();
44767
45185
  const userAuthor = profile?.user ? profile.user.email ? `${profile.user.name} <${profile.user.email}>` : profile.user.name : USER_AUTHOR;
44768
45186
  const userAuthorRef = reactExports.useRef(userAuthor);
@@ -44780,6 +45198,10 @@ function App(props = {}) {
44780
45198
  const [reviewOpen, setReviewOpen] = reactExports.useState(false);
44781
45199
  const [findOpen, setFindOpen] = reactExports.useState(false);
44782
45200
  const [findOpts, setFindOpts] = reactExports.useState({ query: "", ci: false, inPreview: true, inEditor: false, inComments: false });
45201
+ const [openPanel, setOpenPanel] = reactExports.useState(null);
45202
+ const panelHideTimer = reactExports.useRef(null);
45203
+ const [closingPanel, setClosingPanel] = reactExports.useState(null);
45204
+ const lastOpenPanelRef = reactExports.useRef(null);
44783
45205
  const docRef = reactExports.useRef(doc2);
44784
45206
  docRef.current = doc2;
44785
45207
  const previewRef = reactExports.useRef(null);
@@ -44890,6 +45312,9 @@ function App(props = {}) {
44890
45312
  hostApi().onNavState?.((s) => setNavState(s)),
44891
45313
  // Desktop only: a newer npm version is available.
44892
45314
  hostApi().onUpdateAvailable?.((info) => setUpdate(info)),
45315
+ // Desktop only: show / tear down the cloud sign-in modal overlay on the host's request.
45316
+ hostApi().cloudSignIn?.onOpen((url) => setSignInUrl(url)),
45317
+ hostApi().cloudSignIn?.onClose(() => setSignInUrl(null)),
44893
45318
  // Comment store (plugin): adopt the external store's comments whenever it (or this editor)
44894
45319
  // changes them. Body stays driven by the editor/binding; only `comments` is synced.
44895
45320
  commentStore?.observe(() => setDoc((d) => ({ ...d, comments: commentStore.list() })))
@@ -44910,34 +45335,62 @@ function App(props = {}) {
44910
45335
  const timer = setTimeout(() => setReloadIn((s) => s === null ? null : s - 1), 1e3);
44911
45336
  return () => clearTimeout(timer);
44912
45337
  }, [reloadIn]);
45338
+ const syncExternalDoc = reactExports.useCallback((d, prevComments, prevBody) => {
45339
+ const store = hostApi().commentStore;
45340
+ const binding = hostApi().binding;
45341
+ if (!store && !binding) return false;
45342
+ const bodyChanged = d.body !== prevBody;
45343
+ if (store) {
45344
+ reconcileComments(store, prevComments, d.comments);
45345
+ if (!bodyChanged) return true;
45346
+ if (!binding?.setText) return false;
45347
+ binding.setText(d.body);
45348
+ return true;
45349
+ }
45350
+ if (!binding?.setText) return false;
45351
+ binding.setText(serialize(d));
45352
+ return true;
45353
+ }, []);
44913
45354
  const undo2 = reactExports.useCallback(() => {
44914
45355
  const prev = history2.current.pop();
44915
45356
  if (!prev) {
44916
45357
  setStatus(t2("msg.nothingUndo"));
44917
45358
  return;
44918
45359
  }
44919
- future.current.push(docRef.current);
45360
+ const cur2 = docRef.current;
45361
+ future.current.push(cur2);
44920
45362
  setDoc(prev);
44921
- setDirty(serialize(prev) !== savedRef.current);
45363
+ if (syncExternalDoc(prev, cur2.comments, cur2.body)) setDirty(false);
45364
+ else setDirty(serialize(prev) !== savedRef.current);
44922
45365
  setStatus(t2("msg.undid"));
44923
- }, []);
45366
+ }, [syncExternalDoc]);
44924
45367
  const redo2 = reactExports.useCallback(() => {
44925
45368
  const next = future.current.pop();
44926
45369
  if (!next) {
44927
45370
  setStatus(t2("msg.nothingRedo"));
44928
45371
  return;
44929
45372
  }
44930
- history2.current.push(docRef.current);
45373
+ const cur2 = docRef.current;
45374
+ history2.current.push(cur2);
44931
45375
  setDoc(next);
44932
- setDirty(serialize(next) !== savedRef.current);
45376
+ if (syncExternalDoc(next, cur2.comments, cur2.body)) setDirty(false);
45377
+ else setDirty(serialize(next) !== savedRef.current);
44933
45378
  setStatus(t2("msg.redid"));
44934
- }, []);
45379
+ }, [syncExternalDoc]);
45380
+ const reviewUndoRef = reactExports.useRef(() => {
45381
+ });
45382
+ const reviewRedoRef = reactExports.useRef(() => {
45383
+ });
44935
45384
  reactExports.useEffect(() => {
44936
45385
  const onKey = (e) => {
44937
45386
  if ((e.metaKey || e.ctrlKey) && (e.key === "z" || e.key === "Z")) {
44938
- if (document.activeElement?.closest(".ap-source")) return;
45387
+ const active = document.activeElement;
45388
+ if (active?.closest(".ap-source") || active?.closest(".ap-ihunk-edit-ta")) return;
44939
45389
  e.preventDefault();
44940
- if (e.shiftKey) redo2();
45390
+ if (proposal && reviewOpen) {
45391
+ if (e.shiftKey) reviewRedoRef.current();
45392
+ else reviewUndoRef.current();
45393
+ } else if (e.shiftKey) redo2();
44941
45394
  else undo2();
44942
45395
  } else if ((e.metaKey || e.ctrlKey) && !e.altKey && (e.key === "f" || e.key === "F")) {
44943
45396
  e.preventDefault();
@@ -45023,25 +45476,46 @@ function App(props = {}) {
45023
45476
  history2.current.push(docRef.current);
45024
45477
  if (history2.current.length > 200) history2.current.shift();
45025
45478
  future.current = [];
45026
- const commentOnly = next.body === docRef.current.body;
45479
+ const prevDoc = docRef.current;
45480
+ const commentOnly = next.body === prevDoc.body;
45481
+ const prevComments = prevDoc.comments;
45027
45482
  setDoc(next);
45028
45483
  if (action) void hostApi().logAction(action.type, action.payload);
45029
- if (commentOnly) {
45030
- const store = hostApi().commentStore;
45031
- if (store) {
45032
- reconcileComments(store, docRef.current.comments, next.comments);
45033
- setDirty(false);
45034
- } else {
45035
- const s = serialize(next);
45036
- savedRef.current = s;
45037
- setDirty(false);
45038
- void hostApi().save(s, { kind: mode.applyKind, cadence }).then(() => setCheckpoint(s));
45039
- }
45484
+ if (syncExternalDoc(next, prevComments, prevDoc.body)) {
45485
+ setDirty(false);
45486
+ } else if (commentOnly) {
45487
+ const s = serialize(next);
45488
+ savedRef.current = s;
45489
+ setDirty(false);
45490
+ void hostApi().save(s, { kind: mode.applyKind, cadence }).then(() => setCheckpoint(s));
45040
45491
  } else {
45041
45492
  setDirty(serialize(next) !== savedRef.current);
45042
45493
  }
45043
45494
  },
45044
- [cadence]
45495
+ [cadence, syncExternalDoc]
45496
+ );
45497
+ const commentsForCopy = reactExports.useCallback((text2) => {
45498
+ const ids = anchorIdsIn(text2);
45499
+ return ids.length ? threadsFor(ids, docRef.current.comments) : [];
45500
+ }, []);
45501
+ const onCutComments = reactExports.useCallback(
45502
+ (_text, from, to) => {
45503
+ const cur2 = docRef.current;
45504
+ const carried = new Set(threadsFor(anchorIdsIn(cur2.body.slice(from, to)), cur2.comments).map((c) => c.id));
45505
+ const body = cur2.body.slice(0, from) + cur2.body.slice(to);
45506
+ apply({ body, comments: cur2.comments.filter((c) => !carried.has(c.id)) }, { type: "comment_deleted", payload: { count: carried.size } });
45507
+ },
45508
+ [apply]
45509
+ );
45510
+ const onPasteComments = reactExports.useCallback(
45511
+ (text2, payload, from, to) => {
45512
+ const cur2 = docRef.current;
45513
+ const taken = new Set(cur2.comments.map((c) => c.id));
45514
+ const { comments: pasted, idMap } = remapComments(payload.comments, taken);
45515
+ const body = cur2.body.slice(0, from) + rewriteAnchors(text2, idMap) + cur2.body.slice(to);
45516
+ apply({ body, comments: [...cur2.comments, ...pasted] }, { type: "comment_created", payload: { count: pasted.length } });
45517
+ },
45518
+ [apply]
45045
45519
  );
45046
45520
  reactExports.useEffect(() => {
45047
45521
  if (!autoResolve || !loaded) return;
@@ -45093,7 +45567,24 @@ function App(props = {}) {
45093
45567
  setStatus(kind === "canonical" ? "saved" : "checkpoint saved");
45094
45568
  }, [cadence, mode]);
45095
45569
  saveNowRef.current = saveNow;
45570
+ const pendingAnswersRef = reactExports.useRef(/* @__PURE__ */ new Set());
45571
+ const nudgedAnswersRef = reactExports.useRef(/* @__PURE__ */ new Set());
45572
+ const setQuestionPending = reactExports.useCallback((id2, pending) => {
45573
+ if (pending) pendingAnswersRef.current.add(id2);
45574
+ else pendingAnswersRef.current.delete(id2);
45575
+ }, []);
45096
45576
  const finishTurn = reactExports.useCallback(() => {
45577
+ const next = [...pendingAnswersRef.current].find((id2) => !nudgedAnswersRef.current.has(id2));
45578
+ if (next) {
45579
+ nudgedAnswersRef.current.add(next);
45580
+ const card = railRef.current?.querySelector(`[data-cmt-card="${next}"]`);
45581
+ card?.scrollIntoView({ block: "center" });
45582
+ card?.querySelector(".ap-chip input, .ap-other")?.focus();
45583
+ setFocused(next);
45584
+ setStatus(t2("msg.unsavedAnswer"));
45585
+ return;
45586
+ }
45587
+ nudgedAnswersRef.current.clear();
45097
45588
  const content2 = serialize(docRef.current);
45098
45589
  void hostApi().save(content2, { kind: "canonical", cadence: "turn" }).then(() => setCheckpoint(content2));
45099
45590
  savedRef.current = content2;
@@ -45101,7 +45592,7 @@ function App(props = {}) {
45101
45592
  setAgentThinking(true);
45102
45593
  hostApi().telemetry?.("turn_finished");
45103
45594
  setStatus(t2("msg.turnFinished"));
45104
- }, []);
45595
+ }, [setQuestionPending]);
45105
45596
  const [quitOpen, setQuitOpen] = reactExports.useState(false);
45106
45597
  const [forceSettingsOpen, setForceSettingsOpen] = reactExports.useState(false);
45107
45598
  const confirmQuit = reactExports.useCallback((opts) => {
@@ -45218,7 +45709,8 @@ function App(props = {}) {
45218
45709
  content2 = `# ${title}
45219
45710
  `;
45220
45711
  }
45221
- const res = await api.newDoc.create(path, content2);
45712
+ const draftOpts = req.mode === "create" && opts.draftPrompt ? { draftPrompt: opts.draftPrompt } : null;
45713
+ const res = draftOpts ? await api.newDoc.create(path, content2, draftOpts) : await api.newDoc.create(path, content2);
45222
45714
  if (!res) {
45223
45715
  setStatus(t2("newdoc.failed"));
45224
45716
  return;
@@ -45295,6 +45787,23 @@ function App(props = {}) {
45295
45787
  setActivePreviewLine(line);
45296
45788
  editorRef.current?.scrollToLine(line);
45297
45789
  }, []);
45790
+ const scrollBothToLine = reactExports.useCallback((line) => {
45791
+ skipPreviewScroll.current = false;
45792
+ setActivePreviewLine(line);
45793
+ editorRef.current?.scrollToLine(line);
45794
+ }, []);
45795
+ reactExports.useEffect(() => {
45796
+ if (openPanel) {
45797
+ lastOpenPanelRef.current = (hostApi().sidePanels ?? []).find((p2) => p2.id === openPanel) ?? null;
45798
+ setClosingPanel(null);
45799
+ return;
45800
+ }
45801
+ if (!lastOpenPanelRef.current) return;
45802
+ setClosingPanel(lastOpenPanelRef.current);
45803
+ lastOpenPanelRef.current = null;
45804
+ const t22 = setTimeout(() => setClosingPanel(null), 540);
45805
+ return () => clearTimeout(t22);
45806
+ }, [openPanel]);
45298
45807
  const focusComment = reactExports.useCallback(
45299
45808
  (id2, fromPreview = false, fromRail = false) => {
45300
45809
  setFocused(id2);
@@ -45370,9 +45879,73 @@ function App(props = {}) {
45370
45879
  const reviewSegs = reactExports.useMemo(() => proposal ? lineSegments(proposal.baseBody, proposal.next.body) : [], [proposal]);
45371
45880
  const changeCount = reactExports.useMemo(() => reviewSegs.filter(isChange).length, [reviewSegs]);
45372
45881
  const [accepted, setAccepted] = reactExports.useState([]);
45373
- reactExports.useEffect(() => setAccepted(new Array(changeCount).fill(true)), [changeCount, proposal]);
45374
- const toggleHunk = reactExports.useCallback((idx, val) => setAccepted((a) => a.map((v2, k2) => k2 === idx ? val : v2)), []);
45375
- const applyReview = reactExports.useCallback(() => applyProposal(reviewSegs, accepted), [applyProposal, reviewSegs, accepted]);
45882
+ const [edits, setEdits] = reactExports.useState({});
45883
+ const editedSegs = reactExports.useMemo(() => {
45884
+ let ci2 = -1;
45885
+ return reviewSegs.map((s) => {
45886
+ if (!isChange(s)) return s;
45887
+ ci2++;
45888
+ return edits[ci2] ? { ...s, added: edits[ci2] } : s;
45889
+ });
45890
+ }, [reviewSegs, edits]);
45891
+ const reviewHist = reactExports.useRef([]);
45892
+ const reviewFuture = reactExports.useRef([]);
45893
+ const [editingHunk, setEditingHunk] = reactExports.useState(null);
45894
+ const [editDraft, setEditDraft] = reactExports.useState("");
45895
+ reactExports.useEffect(() => {
45896
+ setAccepted(new Array(changeCount).fill(true));
45897
+ setEdits({});
45898
+ reviewHist.current = [];
45899
+ reviewFuture.current = [];
45900
+ setEditingHunk(null);
45901
+ }, [changeCount, proposal]);
45902
+ const commitReview = reactExports.useCallback(
45903
+ (nextAccepted, nextEdits) => {
45904
+ reviewHist.current.push({ accepted, edits });
45905
+ if (reviewHist.current.length > 200) reviewHist.current.shift();
45906
+ reviewFuture.current = [];
45907
+ setAccepted(nextAccepted);
45908
+ setEdits(nextEdits);
45909
+ },
45910
+ [accepted, edits]
45911
+ );
45912
+ const toggleHunk = reactExports.useCallback((idx, val) => commitReview(accepted.map((v2, k2) => k2 === idx ? val : v2), edits), [commitReview, accepted, edits]);
45913
+ const setAllAccepted = reactExports.useCallback((val) => commitReview(new Array(changeCount).fill(val), edits), [commitReview, changeCount, edits]);
45914
+ const reviewUndo = reactExports.useCallback(() => {
45915
+ const prev = reviewHist.current.pop();
45916
+ if (!prev) return;
45917
+ reviewFuture.current.push({ accepted, edits });
45918
+ setEditingHunk(null);
45919
+ setAccepted(prev.accepted);
45920
+ setEdits(prev.edits);
45921
+ setStatus(t2("msg.undid"));
45922
+ }, [accepted, edits]);
45923
+ const reviewRedo = reactExports.useCallback(() => {
45924
+ const next = reviewFuture.current.pop();
45925
+ if (!next) return;
45926
+ reviewHist.current.push({ accepted, edits });
45927
+ setEditingHunk(null);
45928
+ setAccepted(next.accepted);
45929
+ setEdits(next.edits);
45930
+ setStatus(t2("msg.redid"));
45931
+ }, [accepted, edits]);
45932
+ reviewUndoRef.current = reviewUndo;
45933
+ reviewRedoRef.current = reviewRedo;
45934
+ const startEditHunk = reactExports.useCallback(
45935
+ (idx) => {
45936
+ const blocks = editedSegs.filter(isChange);
45937
+ setEditDraft((blocks[idx]?.added ?? []).join("\n"));
45938
+ setEditingHunk(idx);
45939
+ },
45940
+ [editedSegs]
45941
+ );
45942
+ const saveEditHunk = reactExports.useCallback(() => {
45943
+ if (editingHunk == null) return;
45944
+ commitReview(accepted, { ...edits, [editingHunk]: editDraft.split("\n") });
45945
+ setEditingHunk(null);
45946
+ }, [editingHunk, editDraft, commitReview, accepted, edits]);
45947
+ const cancelEditHunk = reactExports.useCallback(() => setEditingHunk(null), []);
45948
+ const applyReview = reactExports.useCallback(() => applyProposal(editedSegs, accepted), [applyProposal, editedSegs, accepted]);
45376
45949
  const [reviewCursor, setReviewCursor] = reactExports.useState(-1);
45377
45950
  reactExports.useEffect(() => setReviewCursor(-1), [proposal]);
45378
45951
  const reviewNext = reactExports.useCallback(() => {
@@ -45496,6 +46069,8 @@ function App(props = {}) {
45496
46069
  const ni2 = (focusedIdx < 0 ? dir === 1 ? -1 : visible.length : focusedIdx) + dir;
45497
46070
  if (ni2 >= 0 && ni2 < visible.length) focusComment(visible[ni2].thread.root.id);
45498
46071
  };
46072
+ const sidePanels = hostApi().sidePanels ?? [];
46073
+ const activePanel = sidePanels.find((p2) => p2.id === openPanel) ?? null;
45499
46074
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-app", children: [
45500
46075
  /* @__PURE__ */ jsxRuntimeExports.jsx(
45501
46076
  TopBar,
@@ -45633,8 +46208,15 @@ function App(props = {}) {
45633
46208
  t2("banner.reviewNext"),
45634
46209
  reviewCursor >= 0 ? ` (${reviewCursor + 1}/${changeCount})` : ""
45635
46210
  ] }),
45636
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled: editingLocked, onClick: () => setAccepted(new Array(changeCount).fill(true)), children: t2("banner.acceptAll") }),
45637
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled: editingLocked, onClick: () => setAccepted(new Array(changeCount).fill(false)), children: t2("banner.rejectAll") }),
46211
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
46212
+ TriSwitch,
46213
+ {
46214
+ state: changeCount > 0 && accepted.slice(0, changeCount).every(Boolean) ? "accept" : changeCount > 0 && accepted.slice(0, changeCount).every((v2) => !v2) ? "reject" : "mixed",
46215
+ onAccept: () => setAllAccepted(true),
46216
+ onReject: () => setAllAccepted(false),
46217
+ disabled: editingLocked || !changeCount
46218
+ }
46219
+ ),
45638
46220
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-primary", disabled: editingLocked, onClick: applyReview, children: t2("banner.apply") }),
45639
46221
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: () => setReviewOpen(false), children: t2("banner.laterLower") }),
45640
46222
  editingLocked && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-muted", children: t2("banner.locked") })
@@ -45669,11 +46251,22 @@ function App(props = {}) {
45669
46251
  initialPath: slugifyFilename(newDocReq.mode === "move" ? moveDocTitle(newDocReq.selected) : newDocReq.selected),
45670
46252
  exists: !!newDocReq.existing,
45671
46253
  onPick: hostApi().newDoc?.pickPath ? (name2) => hostApi().newDoc.pickPath(name2) : null,
46254
+ draftOption: hostApi().newDoc?.draftOption ?? null,
45672
46255
  onSubmit: createNewDoc,
45673
46256
  onCancel: () => setNewDocReq(null)
45674
46257
  }
45675
46258
  ),
45676
46259
  props.onboarding && props.onFinishOnboarding && /* @__PURE__ */ jsxRuntimeExports.jsx(Onboarding, { signals: onboardingSignals, onFinish: props.onFinishOnboarding, onActiveStep: (id2) => setForceSettingsOpen(id2 === "settings") }),
46260
+ signInUrl && /* @__PURE__ */ jsxRuntimeExports.jsx(
46261
+ CloudSignInOverlay,
46262
+ {
46263
+ url: signInUrl,
46264
+ onDismiss: () => {
46265
+ setSignInUrl(null);
46266
+ hostApi().cloudSignIn?.cancel();
46267
+ }
46268
+ }
46269
+ ),
45677
46270
  ctxMenu && /* @__PURE__ */ jsxRuntimeExports.jsx(
45678
46271
  ContextMenu,
45679
46272
  {
@@ -45722,6 +46315,34 @@ function App(props = {}) {
45722
46315
  }
45723
46316
  ),
45724
46317
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-main", style: { zoom }, children: [
46318
+ sidePanels.length > 0 && !activePanel && !closingPanel && /* @__PURE__ */ jsxRuntimeExports.jsx(
46319
+ "button",
46320
+ {
46321
+ className: "ap-sidepanel-bump",
46322
+ title: sidePanels[0].title,
46323
+ "aria-label": sidePanels[0].title,
46324
+ onClick: () => setOpenPanel(sidePanels[0].id),
46325
+ children: sidePanels[0].icon ?? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-iconbtn-fallback", children: sidePanels[0].title.slice(0, 1) })
46326
+ }
46327
+ ),
46328
+ (activePanel || closingPanel) && /* @__PURE__ */ jsxRuntimeExports.jsx(
46329
+ "aside",
46330
+ {
46331
+ className: `ap-sidepanel${!activePanel && closingPanel ? " ap-sidepanel--closing" : ""}`,
46332
+ "data-panel": (activePanel ?? closingPanel).id,
46333
+ onMouseEnter: activePanel ? () => {
46334
+ if (panelHideTimer.current) {
46335
+ clearTimeout(panelHideTimer.current);
46336
+ panelHideTimer.current = null;
46337
+ }
46338
+ } : void 0,
46339
+ onMouseLeave: activePanel ? () => {
46340
+ if (panelHideTimer.current) clearTimeout(panelHideTimer.current);
46341
+ panelHideTimer.current = setTimeout(() => setOpenPanel(null), 500);
46342
+ } : void 0,
46343
+ children: (activePanel ?? closingPanel).render({ body: doc2.body, activeLine: activePreviewLine, scrollToLine: scrollBothToLine, close: () => setOpenPanel(null) })
46344
+ }
46345
+ ),
45725
46346
  /* @__PURE__ */ jsxRuntimeExports.jsx(
45726
46347
  "section",
45727
46348
  {
@@ -45741,7 +46362,7 @@ function App(props = {}) {
45741
46362
  const block2 = commentBlockReason(raw, docRef.current.body, range, previewRef.current);
45742
46363
  setCtxMenu({ x: Math.max(8, Math.min(e.clientX, window.innerWidth - 200)), y: Math.max(8, Math.min(e.clientY, window.innerHeight - 220)), hasSel: trimmed.length > 0, hasRawSel: raw.length > 0, block: block2 });
45743
46364
  },
45744
- children: proposal && reviewOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(DiffPreview, { segs: reviewSegs, accepted, focused: reviewCursor, onToggle: toggleHunk }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
46365
+ children: proposal && reviewOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(DiffPreview, { segs: editedSegs, accepted, focused: reviewCursor, onToggle: toggleHunk, onEdit: startEditHunk, editingHunk, editDraft, onEditDraft: setEditDraft, onEditSave: saveEditHunk, onEditCancel: cancelEditHunk }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
45745
46366
  "div",
45746
46367
  {
45747
46368
  className: "ap-rendered",
@@ -45775,7 +46396,7 @@ function App(props = {}) {
45775
46396
  /* @__PURE__ */ jsxRuntimeExports.jsx(VSplitter, { width: srcW, setWidth: setSrcW }),
45776
46397
  /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "ap-pane", style: { width: srcW }, children: [
45777
46398
  panes === 2 && /* @__PURE__ */ jsxRuntimeExports.jsx(PaneTabs, { tab: rightTab, onTab: setRightTab }),
45778
- proposal && reviewOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(DiffSource, { segs: reviewSegs, accepted, focused: reviewCursor, onToggle: toggleHunk }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
46399
+ proposal && reviewOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(DiffSource, { segs: editedSegs, accepted, focused: reviewCursor, onToggle: toggleHunk }) : /* @__PURE__ */ jsxRuntimeExports.jsx(EditorErrorBoundary, { label: "The source editor", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
45779
46400
  SourceEditor,
45780
46401
  {
45781
46402
  ref: editorRef,
@@ -45783,15 +46404,17 @@ function App(props = {}) {
45783
46404
  value: doc2.body,
45784
46405
  editable: !editingLocked,
45785
46406
  onChange: (body) => {
45786
- const nd2 = { ...docRef.current, body };
45787
- setDoc(nd2);
45788
- setDirty(serialize(nd2) !== savedRef.current);
46407
+ setDoc((d) => ({ ...d, body }));
46408
+ if (!hostApi().binding?.setText) setDirty(serialize({ ...docRef.current, body }) !== savedRef.current);
45789
46409
  },
45790
46410
  onCursorLine: (line) => setActivePreviewLine(line),
45791
46411
  onFind: () => setFindOpen(true),
45792
- find: findOpen && findOpts.inEditor && findOpts.query ? { query: findOpts.query, ci: findOpts.ci } : null
46412
+ find: findOpen && findOpts.inEditor && findOpts.query ? { query: findOpts.query, ci: findOpts.ci } : null,
46413
+ commentsForCopy,
46414
+ onCutComments: editingLocked ? void 0 : onCutComments,
46415
+ onPasteComments: editingLocked ? void 0 : onPasteComments
45793
46416
  }
45794
- )
46417
+ ) })
45795
46418
  ] })
45796
46419
  ] }),
45797
46420
  showComments && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
@@ -45835,6 +46458,7 @@ function App(props = {}) {
45835
46458
  onFocus: () => focusComment(o.thread.root.id, false, true),
45836
46459
  onReply: (text2) => apply(addReply(docRef.current, o.thread.root.id, text2, userAuthorRef.current).doc, { type: "comment_created", payload: { parentId: o.thread.root.id } }),
45837
46460
  onAnswer: (selected, text2) => apply(setAnswer(docRef.current, o.thread.root.id, selected, text2, userAuthorRef.current).doc, { type: "comment_answered", payload: { parentId: o.thread.root.id, selected } }),
46461
+ onAnswerPending: (p2) => setQuestionPending(o.thread.root.id, p2),
45838
46462
  onResolve: (r2) => apply(setResolved(docRef.current, o.thread.root.id, r2), { type: "comment_resolved", payload: { id: o.thread.root.id, resolved: r2 } }),
45839
46463
  onEdit: (id2, text2) => apply(editCommentText(docRef.current, id2, text2), { type: "comment_modified", payload: { id: id2 } }),
45840
46464
  onDelete: (id2) => apply(deleteComment(docRef.current, id2), { type: "comment_deleted", payload: { id: id2 } })
@@ -45875,7 +46499,9 @@ function AppRoot() {
45875
46499
  const [apiReady, setApiReady] = reactExports.useState(phase === "real");
45876
46500
  const installSample = reactExports.useCallback(() => {
45877
46501
  const sample = createMemoryApi({ content: ONBOARDING_SAMPLE, settings: { autoResolve: false } }).api;
45878
- sample.i18n = window.api?.i18n;
46502
+ const real = window.api;
46503
+ sample.i18n = real?.i18n;
46504
+ sample.extraModes = real?.extraModes;
45879
46505
  setApiOverride(sample);
45880
46506
  }, []);
45881
46507
  reactExports.useEffect(() => {
@@ -46029,7 +46655,8 @@ function TopBar(props) {
46029
46655
  quota: profile.agentQuota,
46030
46656
  byoKey: profile.agentByoKey,
46031
46657
  policy: profile.agentPolicy,
46032
- onSetPolicy: profile.onSetAgentPolicy
46658
+ onSetPolicy: profile.onSetAgentPolicy,
46659
+ localCommand: hostApi().localAgentCommand
46033
46660
  }
46034
46661
  ),
46035
46662
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -46200,7 +46827,37 @@ function FindReplaceBar({
46200
46827
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: onClose, children: t2("find.close") })
46201
46828
  ] });
46202
46829
  }
46203
- function DiffPreview({ segs, accepted, focused, onToggle }) {
46830
+ function TriSwitch({ state, onAccept, onReject, disabled }) {
46831
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `ap-tri ap-tri--${state}${disabled ? " disabled" : ""}`, role: "group", "aria-label": "accept or reject all changes", children: [
46832
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "ap-tri-end ap-tri-accept", "aria-pressed": state === "accept", disabled, onClick: onAccept, children: "Accept all" }),
46833
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-tri-track", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-tri-thumb" }) }),
46834
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "ap-tri-end ap-tri-reject", "aria-pressed": state === "reject", disabled, onClick: onReject, children: "Reject all" })
46835
+ ] });
46836
+ }
46837
+ function HunkBar({ idx, on, onToggle, onEdit, editing }) {
46838
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-hunk-bar", children: [
46839
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ap-hunk-n", children: [
46840
+ "change ",
46841
+ idx + 1
46842
+ ] }),
46843
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
46844
+ on && onEdit && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: `ap-hunk-edit${editing ? " active" : ""}`, "aria-label": `edit change ${idx + 1}`, title: "Edit this change", onClick: () => onEdit(idx), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconPencil, {}) }),
46845
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-willbe", children: on ? "will be accepted" : "will be rejected" }),
46846
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { checked: on, onChange: (v2) => onToggle(idx, v2), ariaLabel: `accept change ${idx + 1}` })
46847
+ ] });
46848
+ }
46849
+ function DiffPreview({
46850
+ segs,
46851
+ accepted,
46852
+ focused,
46853
+ onToggle,
46854
+ onEdit,
46855
+ editingHunk,
46856
+ editDraft,
46857
+ onEditDraft,
46858
+ onEditSave,
46859
+ onEditCancel
46860
+ }) {
46204
46861
  let ci2 = -1;
46205
46862
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-rendered ap-diffview", children: segs.map((s, i) => {
46206
46863
  if (s.same) {
@@ -46209,17 +46866,36 @@ function DiffPreview({ segs, accepted, focused, onToggle }) {
46209
46866
  ci2++;
46210
46867
  const idx = ci2;
46211
46868
  const on = accepted[idx] ?? true;
46869
+ const editing = editingHunk === idx;
46212
46870
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-hunk": idx, className: `ap-ihunk${on ? " accepted" : " rejected"}${focused === idx ? " focused" : ""}`, children: [
46213
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-ihunk-bar", children: [
46214
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
46215
- "change ",
46216
- idx + 1
46217
- ] }),
46218
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
46219
- /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { checked: on, onChange: (v2) => onToggle(idx, v2), ariaLabel: `accept change ${idx + 1}` })
46220
- ] }),
46871
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HunkBar, { idx, on, onToggle, onEdit, editing }),
46221
46872
  s.removed && s.removed.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-ihunk-del", dangerouslySetInnerHTML: { __html: renderMarkdown(s.removed.join("\n"), () => false) } }),
46222
- s.added && s.added.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-ihunk-add", dangerouslySetInnerHTML: { __html: renderMarkdown(s.added.join("\n"), () => false) } })
46873
+ editing ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-ihunk-edit", children: [
46874
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
46875
+ "textarea",
46876
+ {
46877
+ className: "ap-ihunk-edit-ta",
46878
+ value: editDraft,
46879
+ autoFocus: true,
46880
+ rows: Math.min(12, Math.max(2, editDraft.split("\n").length)),
46881
+ "aria-label": `edit change ${idx + 1}`,
46882
+ onChange: (e) => onEditDraft(e.target.value),
46883
+ onKeyDown: (e) => {
46884
+ if (e.key === "Escape") {
46885
+ e.preventDefault();
46886
+ onEditCancel();
46887
+ } else if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
46888
+ e.preventDefault();
46889
+ onEditSave();
46890
+ }
46891
+ }
46892
+ }
46893
+ ),
46894
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-ihunk-edit-actions", children: [
46895
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", "aria-label": `cancel edit of change ${idx + 1}`, onClick: onEditCancel, children: "Cancel" }),
46896
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-primary", "aria-label": `save edit of change ${idx + 1}`, onClick: onEditSave, children: "Save" })
46897
+ ] })
46898
+ ] }) : s.added && s.added.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-ihunk-add", dangerouslySetInnerHTML: { __html: renderMarkdown(s.added.join("\n"), () => false) } })
46223
46899
  ] }, i);
46224
46900
  }) });
46225
46901
  }
@@ -46233,7 +46909,7 @@ function DiffSource({ segs, accepted, focused, onToggle }) {
46233
46909
  const idx = ci2;
46234
46910
  const on = accepted[idx] ?? true;
46235
46911
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-hunk": idx, className: `ap-hunk${on ? " accepted" : " rejected"}${focused === idx ? " focused" : ""}`, children: [
46236
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-hunk-toggle", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { label: `change ${idx + 1}`, checked: on, onChange: (v2) => onToggle(idx, v2) }) }),
46912
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HunkBar, { idx, on, onToggle }),
46237
46913
  /* @__PURE__ */ jsxRuntimeExports.jsx(HunkLines, { removed: s.removed ?? [], added: s.added ?? [] })
46238
46914
  ] }, i);
46239
46915
  }) });
@@ -46409,7 +47085,7 @@ function ThreadCard(props) {
46409
47085
  t2("rail.agentSuggestedResolve")
46410
47086
  ] }),
46411
47087
  renderComment(root, false),
46412
- root.question && /* @__PURE__ */ jsxRuntimeExports.jsx(QuestionChips, { question: root.question, disabled, answered: answeredSelection, onAnswer: props.onAnswer }),
47088
+ root.question && /* @__PURE__ */ jsxRuntimeExports.jsx(QuestionChips, { question: root.question, disabled, answered: answeredSelection, onAnswer: props.onAnswer, onPending: props.onAnswerPending }),
46413
47089
  thread.replies.map((r2) => renderComment(r2, true)),
46414
47090
  !replying && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-row ap-thread-actions", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", disabled, onClick: () => setReplying(true), children: t2("rail.reply") }) }),
46415
47091
  replying && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-reply-box", children: [
@@ -46461,33 +47137,60 @@ function ThreadCard(props) {
46461
47137
  }
46462
47138
  );
46463
47139
  }
46464
- async function bootstrap() {
46465
- const w2 = window;
47140
+ globalThis.__inplanCM = { state: cmState, view: cmView };
47141
+ const w = window;
47142
+ let pluginMod = null;
47143
+ let currentExt = null;
47144
+ async function activatePlugin() {
46466
47145
  try {
46467
- const info = w2.__inplanPlugin ? await w2.__inplanPlugin() : null;
46468
- if (info && w2.api) {
46469
- const mod = await import(
46470
- /* @vite-ignore */
46471
- info.rendererUrl
46472
- );
46473
- const ext = mod.activate(info.session);
46474
- if (ext && w2.api) {
46475
- setHostApi({ ...w2.api, binding: ext.binding, commentStore: ext.commentStore, extraModes: ext.extraModes });
46476
- window.addEventListener("beforeunload", () => {
46477
- try {
46478
- ext.dispose();
46479
- } catch {
46480
- }
46481
- });
46482
- }
47146
+ const info = w.__inplanPlugin ? await w.__inplanPlugin() : null;
47147
+ if (!info || !w.api) {
47148
+ currentExt = null;
47149
+ return;
47150
+ }
47151
+ if (!pluginMod) pluginMod = await import(
47152
+ /* @vite-ignore */
47153
+ info.rendererUrl
47154
+ );
47155
+ try {
47156
+ currentExt?.dispose();
47157
+ } catch {
47158
+ }
47159
+ currentExt = pluginMod.activate(info.session);
47160
+ if (currentExt) {
47161
+ setHostApi({ ...w.api, binding: currentExt.binding, commentStore: currentExt.commentStore, extraModes: currentExt.extraModes, sidePanels: currentExt.sidePanels });
46483
47162
  }
46484
47163
  } catch (err) {
46485
47164
  console.error("[inplan] plugin unavailable; using the file-backed editor", err);
47165
+ currentExt = null;
46486
47166
  }
47167
+ }
47168
+ function Shell() {
47169
+ const [epoch, setEpoch] = React.useState(0);
47170
+ React.useEffect(() => {
47171
+ const off = w.__inplanOnReactivate?.(() => {
47172
+ void activatePlugin().then(() => setEpoch((e) => e + 1));
47173
+ });
47174
+ const onUnload = () => {
47175
+ try {
47176
+ currentExt?.dispose();
47177
+ } catch {
47178
+ }
47179
+ };
47180
+ window.addEventListener("beforeunload", onUnload);
47181
+ return () => {
47182
+ off?.();
47183
+ window.removeEventListener("beforeunload", onUnload);
47184
+ };
47185
+ }, []);
47186
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(AppRoot, {}, epoch);
47187
+ }
47188
+ async function bootstrap() {
47189
+ await activatePlugin();
46487
47190
  const root = document.getElementById("root");
46488
47191
  if (root) {
46489
47192
  createRoot(root).render(
46490
- /* @__PURE__ */ jsxRuntimeExports.jsx(React.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(AppRoot, {}) })
47193
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Shell, {}) })
46491
47194
  );
46492
47195
  }
46493
47196
  }