claudekit-cli 3.41.4-dev.50 → 3.41.4-dev.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli-manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "3.41.4-dev.50",
3
- "generatedAt": "2026-04-24T15:26:38.683Z",
2
+ "version": "3.41.4-dev.51",
3
+ "generatedAt": "2026-04-24T21:03:36.506Z",
4
4
  "commands": {
5
5
  "agents": {
6
6
  "name": "agents",
package/dist/index.js CHANGED
@@ -53811,7 +53811,7 @@ var init_gemini_hook_event_map = __esm(() => {
53811
53811
  import { existsSync as existsSync25 } from "node:fs";
53812
53812
  import { mkdir as mkdir11, readFile as readFile21, rename as rename7, rm as rm5, writeFile as writeFile12 } from "node:fs/promises";
53813
53813
  import { homedir as homedir27 } from "node:os";
53814
- import { basename as basename11, dirname as dirname12, join as join39, resolve as resolve15 } from "node:path";
53814
+ import { basename as basename11, dirname as dirname12, isAbsolute as isAbsolute5, join as join39, resolve as resolve15 } from "node:path";
53815
53815
  function validateHooksSectionShape(value) {
53816
53816
  if (!value || typeof value !== "object" || Array.isArray(value)) {
53817
53817
  return "hooks must be a non-null object";
@@ -53959,7 +53959,8 @@ async function mergeHooksIntoSettings(targetSettingsPath, newHooks) {
53959
53959
  }
53960
53960
  }
53961
53961
  const existingHooks = existingSettings.hooks ?? {};
53962
- const merged = deduplicateMerge(existingHooks, newHooks);
53962
+ const pruned = pruneStaleFileHooks(existingHooks);
53963
+ const merged = deduplicateMerge(pruned, newHooks);
53963
53964
  existingSettings.hooks = merged;
53964
53965
  const dir = dirname12(targetSettingsPath);
53965
53966
  await mkdir11(dir, { recursive: true });
@@ -53973,6 +53974,44 @@ async function mergeHooksIntoSettings(targetSettingsPath, newHooks) {
53973
53974
  }
53974
53975
  return { backupPath };
53975
53976
  }
53977
+ function extractLeadingAbsolutePath(command) {
53978
+ const trimmed = command.trim();
53979
+ if (trimmed.length === 0)
53980
+ return null;
53981
+ const firstToken = trimmed.split(/\s+/)[0];
53982
+ if (!firstToken)
53983
+ return null;
53984
+ if (!isAbsolute5(firstToken))
53985
+ return null;
53986
+ return firstToken;
53987
+ }
53988
+ function isCkManagedHookPath(absPath) {
53989
+ const normalized = absPath.replace(/\\/g, "/");
53990
+ return normalized.includes("/.claude/hooks/") || normalized.includes("/.codex/hooks/") || normalized.includes("/.gemini/hooks/");
53991
+ }
53992
+ function pruneStaleFileHooks(existing) {
53993
+ const result = {};
53994
+ for (const [event, groups] of Object.entries(existing)) {
53995
+ const prunedGroups = [];
53996
+ for (const group of groups) {
53997
+ const survivingHooks = group.hooks.filter((h2) => {
53998
+ const path3 = extractLeadingAbsolutePath(h2.command);
53999
+ if (path3 === null)
54000
+ return true;
54001
+ if (!isCkManagedHookPath(path3))
54002
+ return true;
54003
+ return existsSync25(path3);
54004
+ });
54005
+ if (survivingHooks.length > 0) {
54006
+ prunedGroups.push({ ...group, hooks: survivingHooks });
54007
+ }
54008
+ }
54009
+ if (prunedGroups.length > 0) {
54010
+ result[event] = prunedGroups;
54011
+ }
54012
+ }
54013
+ return result;
54014
+ }
53976
54015
  function deduplicateMerge(existing, incoming) {
53977
54016
  const merged = {};
53978
54017
  for (const [event, groups] of Object.entries(existing)) {
@@ -56636,6 +56675,7 @@ function registerMigrationRoutes(app) {
56636
56675
  }
56637
56676
  const plan = parity.value;
56638
56677
  const resolutionsObj = payloadParsed.data.resolutions;
56678
+ const executionMode = payloadParsed.data.mode ?? "reconcile";
56639
56679
  const resolutionsMap = new Map(Object.entries(resolutionsObj));
56640
56680
  for (const action of plan.actions) {
56641
56681
  if (action.action === "conflict") {
@@ -56767,7 +56807,7 @@ function registerMigrationRoutes(app) {
56767
56807
  const plannedSkillActions = execActions.filter((a3) => a3.type === "skill").length;
56768
56808
  if (includeFromPlan.skills && discovered2.skills.length > 0 && plannedSkillActions === 0) {
56769
56809
  const allowedSkillNames = getPlanItemsByType(plan, "skills");
56770
- const plannedSkills = allowedSkillNames.length > 0 ? discovered2.skills.filter((skill) => allowedSkillNames.includes(skill.name)) : discovered2.skills;
56810
+ const plannedSkills = allowedSkillNames.length > 0 ? discovered2.skills.filter((skill) => allowedSkillNames.includes(skill.name)) : executionMode === "install" ? [] : discovered2.skills;
56771
56811
  const skillProviders = allPlanProviders.filter((provider) => providerSupportsType(provider, "skill"));
56772
56812
  if (skillProviders.length > 0) {
56773
56813
  const globalFromPlan = plan.actions[0]?.global ?? false;
@@ -57737,13 +57777,13 @@ var init_plan_scanner = () => {};
57737
57777
 
57738
57778
  // src/domains/plan-parser/plan-scope.ts
57739
57779
  import { homedir as homedir30 } from "node:os";
57740
- import { isAbsolute as isAbsolute5, join as join44, relative as relative9, resolve as resolve18 } from "node:path";
57780
+ import { isAbsolute as isAbsolute6, join as join44, relative as relative9, resolve as resolve18 } from "node:path";
57741
57781
  function resolveConfiguredDir(configuredPath, baseDir) {
57742
57782
  const trimmed = configuredPath?.trim();
57743
57783
  if (!trimmed) {
57744
57784
  return join44(baseDir, DEFAULT_PLANS_DIRNAME);
57745
57785
  }
57746
- return isAbsolute5(trimmed) ? resolve18(trimmed) : resolve18(baseDir, trimmed);
57786
+ return isAbsolute6(trimmed) ? resolve18(trimmed) : resolve18(baseDir, trimmed);
57747
57787
  }
57748
57788
  function resolveProjectPlansDir(projectRoot, config) {
57749
57789
  return resolveConfiguredDir(config?.paths?.plans, projectRoot);
@@ -57758,7 +57798,7 @@ function isWithinDir(targetPath, baseDir) {
57758
57798
  const resolvedTarget = resolve18(targetPath);
57759
57799
  const resolvedBase = resolve18(baseDir);
57760
57800
  const relativePath = relative9(resolvedBase, resolvedTarget);
57761
- return relativePath === "" || !relativePath.startsWith("..") && relativePath !== ".." && !isAbsolute5(relativePath);
57801
+ return relativePath === "" || !relativePath.startsWith("..") && relativePath !== ".." && !isAbsolute6(relativePath);
57762
57802
  }
57763
57803
  function inferPlanScopeForDir(planDir, config) {
57764
57804
  return isWithinDir(planDir, resolveGlobalPlansDir(config)) ? "global" : "project";
@@ -57767,7 +57807,7 @@ function parsePlanReference(reference, defaultScope) {
57767
57807
  const trimmed = reference.trim();
57768
57808
  const normalizePlanId = (rawPlanId) => {
57769
57809
  const planId = rawPlanId.trim();
57770
- const valid = planId.length > 0 && !isAbsolute5(planId) && !planId.includes("/") && !planId.includes("\\") && PLAN_ID_PATTERN.test(planId);
57810
+ const valid = planId.length > 0 && !isAbsolute6(planId) && !planId.includes("/") && !planId.includes("\\") && PLAN_ID_PATTERN.test(planId);
57771
57811
  return { planId, valid };
57772
57812
  };
57773
57813
  if (trimmed.startsWith(GLOBAL_PLAN_PREFIX)) {
@@ -58548,7 +58588,7 @@ import {
58548
58588
  unlinkSync,
58549
58589
  writeFileSync as writeFileSync4
58550
58590
  } from "node:fs";
58551
- import { dirname as dirname18, isAbsolute as isAbsolute6, join as join47, parse as parse2, relative as relative10, resolve as resolve19 } from "node:path";
58591
+ import { dirname as dirname18, isAbsolute as isAbsolute7, join as join47, parse as parse2, relative as relative10, resolve as resolve19 } from "node:path";
58552
58592
  function createEmptyRegistry() {
58553
58593
  return {
58554
58594
  version: 1,
@@ -58603,7 +58643,7 @@ function migrateFromProjectLocal(cwd2, globalPath) {
58603
58643
  }
58604
58644
  }
58605
58645
  function normalizeRegistryDir(cwd2, dir) {
58606
- const absoluteDir = isAbsolute6(dir) ? dir : resolve19(cwd2, dir);
58646
+ const absoluteDir = isAbsolute7(dir) ? dir : resolve19(cwd2, dir);
58607
58647
  const relativeDir = relative10(cwd2, absoluteDir) || dir;
58608
58648
  return relativeDir.replace(/\\/g, "/");
58609
58649
  }
@@ -62163,7 +62203,7 @@ var package_default;
62163
62203
  var init_package = __esm(() => {
62164
62204
  package_default = {
62165
62205
  name: "claudekit-cli",
62166
- version: "3.41.4-dev.50",
62206
+ version: "3.41.4-dev.51",
62167
62207
  description: "CLI tool for bootstrapping and updating ClaudeKit projects",
62168
62208
  type: "module",
62169
62209
  repository: {
@@ -82391,11 +82431,11 @@ init_path_resolver();
82391
82431
  init_zod();
82392
82432
  var import_fs_extra9 = __toESM(require_lib3(), 1);
82393
82433
  import { mkdir as mkdir19, readdir as readdir17, readlink, rename as rename10, symlink } from "node:fs/promises";
82394
- import { basename as basename21, dirname as dirname28, isAbsolute as isAbsolute7, join as join71, normalize as normalize4, resolve as resolve27, sep as sep8 } from "node:path";
82434
+ import { basename as basename21, dirname as dirname28, isAbsolute as isAbsolute8, join as join71, normalize as normalize4, resolve as resolve27, sep as sep8 } from "node:path";
82395
82435
  var SNAPSHOT_DIR = "snapshot";
82396
82436
  var MANIFEST_FILE = "manifest.json";
82397
82437
  function normalizeRelativePath(rootDir, inputPath) {
82398
- if (!inputPath || isAbsolute7(inputPath)) {
82438
+ if (!inputPath || isAbsolute8(inputPath)) {
82399
82439
  throw new Error(`Unsafe backup path: ${inputPath}`);
82400
82440
  }
82401
82441
  const normalized = normalize4(inputPath).replaceAll("\\", "/");
@@ -82655,7 +82695,7 @@ async function loadDestructiveOperationBackup(backupDir) {
82655
82695
  const resolvedBackupDir = await assertManagedBackupDir(backupDir);
82656
82696
  const manifestPath = join71(resolvedBackupDir, MANIFEST_FILE);
82657
82697
  const manifest = destructiveOperationBackupManifestSchema.parse(await import_fs_extra9.readJson(manifestPath));
82658
- if (!isAbsolute7(manifest.sourceRoot)) {
82698
+ if (!isAbsolute8(manifest.sourceRoot)) {
82659
82699
  throw new Error(`Backup manifest source root must be absolute: ${manifest.sourceRoot}`);
82660
82700
  }
82661
82701
  const resolvedSourceRoot = resolve27(manifest.sourceRoot);
@@ -88511,7 +88551,7 @@ init_config_version_checker();
88511
88551
 
88512
88552
  // src/domains/sync/sync-engine.ts
88513
88553
  import { lstat as lstat4, readFile as readFile43, readlink as readlink2, realpath as realpath6, stat as stat15 } from "node:fs/promises";
88514
- import { isAbsolute as isAbsolute8, join as join91, normalize as normalize8, relative as relative15 } from "node:path";
88554
+ import { isAbsolute as isAbsolute9, join as join91, normalize as normalize8, relative as relative15 } from "node:path";
88515
88555
 
88516
88556
  // src/services/file-operations/ownership-checker.ts
88517
88557
  init_metadata_migration();
@@ -89733,10 +89773,10 @@ async function validateSymlinkChain(path7, basePath, maxDepth = MAX_SYMLINK_DEPT
89733
89773
  if (!stats.isSymbolicLink())
89734
89774
  break;
89735
89775
  const target = await readlink2(current);
89736
- const resolvedTarget = isAbsolute8(target) ? target : join91(current, "..", target);
89776
+ const resolvedTarget = isAbsolute9(target) ? target : join91(current, "..", target);
89737
89777
  const normalizedTarget = normalize8(resolvedTarget);
89738
89778
  const rel = relative15(basePath, normalizedTarget);
89739
- if (rel.startsWith("..") || isAbsolute8(rel)) {
89779
+ if (rel.startsWith("..") || isAbsolute9(rel)) {
89740
89780
  throw new Error(`Symlink chain escapes base directory at depth ${depth}: ${path7}`);
89741
89781
  }
89742
89782
  current = normalizedTarget;
@@ -89763,7 +89803,7 @@ async function validateSyncPath(basePath, filePath) {
89763
89803
  throw new Error(`Path too long: ${filePath.slice(0, 50)}...`);
89764
89804
  }
89765
89805
  const normalized = normalize8(filePath);
89766
- if (isAbsolute8(normalized)) {
89806
+ if (isAbsolute9(normalized)) {
89767
89807
  throw new Error(`Absolute paths not allowed: ${filePath}`);
89768
89808
  }
89769
89809
  if (normalized.startsWith("..") || normalized.includes("/../")) {
@@ -89771,7 +89811,7 @@ async function validateSyncPath(basePath, filePath) {
89771
89811
  }
89772
89812
  const fullPath = join91(basePath, normalized);
89773
89813
  const rel = relative15(basePath, fullPath);
89774
- if (rel.startsWith("..") || isAbsolute8(rel)) {
89814
+ if (rel.startsWith("..") || isAbsolute9(rel)) {
89775
89815
  throw new Error(`Path escapes base directory: ${filePath}`);
89776
89816
  }
89777
89817
  await validateSymlinkChain(fullPath, basePath);
@@ -89779,7 +89819,7 @@ async function validateSyncPath(basePath, filePath) {
89779
89819
  const resolvedBase = await realpath6(basePath);
89780
89820
  const resolvedFull = await realpath6(fullPath);
89781
89821
  const resolvedRel = relative15(resolvedBase, resolvedFull);
89782
- if (resolvedRel.startsWith("..") || isAbsolute8(resolvedRel)) {
89822
+ if (resolvedRel.startsWith("..") || isAbsolute9(resolvedRel)) {
89783
89823
  throw new Error(`Symlink escapes base directory: ${filePath}`);
89784
89824
  }
89785
89825
  } catch (error) {
@@ -89789,7 +89829,7 @@ async function validateSyncPath(basePath, filePath) {
89789
89829
  const resolvedBase = await realpath6(basePath);
89790
89830
  const resolvedParent = await realpath6(parentPath);
89791
89831
  const resolvedRel = relative15(resolvedBase, resolvedParent);
89792
- if (resolvedRel.startsWith("..") || isAbsolute8(resolvedRel)) {
89832
+ if (resolvedRel.startsWith("..") || isAbsolute9(resolvedRel)) {
89793
89833
  throw new Error(`Parent symlink escapes base directory: ${filePath}`);
89794
89834
  }
89795
89835
  } catch (parentError) {
@@ -95237,11 +95277,11 @@ var modeFix = (mode, isDir, portable) => {
95237
95277
 
95238
95278
  // node_modules/tar/dist/esm/strip-absolute-path.js
95239
95279
  import { win32 as win322 } from "node:path";
95240
- var { isAbsolute: isAbsolute9, parse: parse5 } = win322;
95280
+ var { isAbsolute: isAbsolute10, parse: parse5 } = win322;
95241
95281
  var stripAbsolutePath = (path7) => {
95242
95282
  let r2 = "";
95243
95283
  let parsed = parse5(path7);
95244
- while (isAbsolute9(path7) || parsed.root) {
95284
+ while (isAbsolute10(path7) || parsed.root) {
95245
95285
  const root = path7.charAt(0) === "/" && path7.slice(0, 4) !== "//?/" ? "/" : parsed.root;
95246
95286
  path7 = path7.slice(root.length);
95247
95287
  r2 += root;
@@ -108882,7 +108922,7 @@ Please use only one download method.`);
108882
108922
  // src/commands/plan/plan-command.ts
108883
108923
  init_output_manager();
108884
108924
  import { existsSync as existsSync67, statSync as statSync12 } from "node:fs";
108885
- import { dirname as dirname46, isAbsolute as isAbsolute11, join as join147, parse as parse7, resolve as resolve46 } from "node:path";
108925
+ import { dirname as dirname46, isAbsolute as isAbsolute12, join as join147, parse as parse7, resolve as resolve46 } from "node:path";
108886
108926
 
108887
108927
  // src/commands/plan/plan-read-handlers.ts
108888
108928
  init_config();
@@ -108950,14 +108990,14 @@ init_config();
108950
108990
  init_plan_parser();
108951
108991
  init_plan_scope();
108952
108992
  init_plans_registry();
108953
- import { isAbsolute as isAbsolute10, resolve as resolve43 } from "node:path";
108993
+ import { isAbsolute as isAbsolute11, resolve as resolve43 } from "node:path";
108954
108994
  async function getGlobalPlansDirFromCwd() {
108955
108995
  const projectRoot = findProjectRoot(process.cwd());
108956
108996
  const { config } = await CkConfigManager.loadFull(projectRoot);
108957
108997
  return resolveGlobalPlansDir(config);
108958
108998
  }
108959
108999
  function resolveTargetFromBase(target, baseDir) {
108960
- const resolvedTarget = isAbsolute10(target) ? resolve43(target) : resolve43(baseDir, target);
109000
+ const resolvedTarget = isAbsolute11(target) ? resolve43(target) : resolve43(baseDir, target);
108961
109001
  return isWithinDir(resolvedTarget, baseDir) ? resolvedTarget : null;
108962
109002
  }
108963
109003
 
@@ -109461,7 +109501,7 @@ function resolveTargetPath(target, baseDir) {
109461
109501
  if (!baseDir) {
109462
109502
  return resolve46(target);
109463
109503
  }
109464
- if (isAbsolute11(target)) {
109504
+ if (isAbsolute12(target)) {
109465
109505
  return resolve46(target);
109466
109506
  }
109467
109507
  const cwdCandidate = resolve46(target);
@@ -268,7 +268,7 @@ Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}
268
268
  `))};if((fe.mac||fe.android)&&h.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(h={from:a,to:l,insert:Ge.of([r.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let f=this.to-this.from+(h.to-h.from+h.insert.length);cg(e,h,q.single(this.toEditorPos(r.selectionStart,f),this.toEditorPos(r.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],i=null;for(let o=this.toEditorPos(r.rangeStart),a=this.toEditorPos(r.rangeEnd);o<a;o++){let l=e.coordsForChar(o);i=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||i||new DOMRect,s.push(i)}n.updateCharacterBounds(r.rangeStart,s)},this.handlers.textformatupdate=r=>{let s=[];for(let i of r.getTextFormats()){let o=i.underlineStyle,a=i.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let l=this.toEditorPos(i.rangeStart),d=this.toEditorPos(i.rangeEnd);if(l<d){let u=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;s.push(je.mark({attributes:{style:u}}).range(l,d))}}}e.dispatch({effects:Xk.of(je.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let s=Da(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((i,o,a,l,d)=>{if(r)return;let u=d.length-(o-i);if(s&&o>=s.to)if(s.from==i&&s.to==o&&s.insert.eq(d)){s=this.pendingContextChange=null,n+=u,this.to+=u;return}else s=null,this.revertPending(e.state);if(i+=n,o+=n,o<=this.from)this.from+=u,this.to+=u;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+d.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),d.toString()),this.to+=u}n+=u}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class ae{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(i=>r(i,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||fM(e.parent)||document,this.viewState=new rb(e.state||Fe.create(e)),e.scrollTo&&e.scrollTo.is(Pc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Oi).map(s=>new Ih(s));for(let s of this.plugins)s.update(this);this.observer=new RA(this),this.inputState=new sA(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Hx(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let n=e.length==1&&e[0]instanceof jt?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,i=this.state;for(let f of e){if(f.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=f.state}if(this.destroyed){this.viewState.state=i;return}let o=this.hasFocus,a=0,l=null;e.some(f=>f.annotation(p2))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=m2(i,o),l||(a=1));let d=this.observer.delayedAndroidKey,u=null;if(d?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(u=null)):this.observer.clear(),i.facet(Fe.phrases)!=this.state.facet(Fe.phrases))return this.setState(i);s=Wd.create(this,i,e),s.flags|=a;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;h=new zi(p.empty?p:q.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is(Pc)&&(h=p.value.clip(this.state))}this.viewState.update(s,h),this.bidiCache=qd.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Qo)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Tc)!=s.state.facet(Tc)&&(this.viewState.mustMeasureContent=!0),(n||r||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let f of this.state.facet(_p))try{f(s)}catch(p){dn(this.state,p,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!a2(this,u)&&d.force&&Fi(this.contentDOM,d.key,d.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new rb(e),this.plugins=e.facet(Oi).map(r=>new Ih(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Hx(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Oi),r=e.state.facet(Oi);if(n!=r){let s=[];for(let i of r){let o=n.indexOf(i);if(o<0)s.push(new Ih(i));else{let a=this.plugins[o];a.mustUpdate=e,s.push(a)}}for(let i of this.plugins)i.mustUpdate!=e&&i.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){dn(this.state,r,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.scrollDOM,s=r.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(Tk(r))i=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(s);i=p.from,o=p.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let d=[];l&4||([this.measureRequests,d]=[d,this.measureRequests]);let u=d.map(p=>{try{return p.read(this)}catch(m){return dn(this.state,m),ab}}),h=Wd.create(this,this.state,[]),f=!1;h.flags|=l,n?n.flags|=l:n=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h),f&&this.docViewUpdate());for(let p=0;p<d.length;p++)if(u[p]!=ab)try{let m=d[p];m.write&&m.write(u[p],this)}catch(m){dn(this.state,m)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let m=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-o;if(m>1||m<-1){s=s+m,r.scrollTop=s/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let a of this.state.facet(_p))a(n)}get themeClasses(){return Vp+" "+(this.state.facet(zp)?y2:b2)+" "+this.state.facet(Tc)}updateAttrs(){let e=lb(this,Zk,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Fr)?"true":"false",class:"cm-content",style:`${fe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),lb(this,ag,n);let r=this.observer.ignore(()=>{let s=Ix(this.contentDOM,this.contentAttrs,n),i=Ix(this.dom,this.editorAttrs,e);return s||i});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(ae.announce)){n&&(this.announceDOM.textContent=""),n=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Qo);let e=this.state.facet(ae.cspNonce);Ss.mount(this.root,this.styleModules.concat(TA).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(r=>r.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return zh(this,e,Wx(this,e,n,r))}moveByGroup(e,n){return zh(this,e,Wx(this,e,n,r=>YM(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),i=r[n?r.length-1:0];return q.cursor(i.side(n,s)+e.from,i.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return qM(this,e,n,r)}moveVertically(e,n,r){return zh(this,e,XM(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=Bp(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),Bp(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.docView.coordsAt(e,n);if(!r||r.left==r.right)return r;let s=this.state.doc.lineAt(e),i=this.bidiSpans(s),o=i[Vr.find(i,e-s.from,-1,n)];return Ma(r,o.dir==Je.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Gk)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>$A)return Bk(e.length);let n=this.textDirectionAt(e.from),r;for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||$k(i.isolates,r=Fx(this,e))))return i.order;r||(r=Fx(this,e));let s=wM(e.text,n,r);return this.bidiCache.push(new qd(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||fe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ak(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return Pc.of(new zi(typeof e=="number"?q.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return Pc.of(new zi(q.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return pt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return pt.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=Ss.newName(),s=[Tc.of(r),Qo.of(Hp(`.${r}`,e))];return n&&n.dark&&s.push(zp.of(!0)),s}static baseTheme(e){return hi.lowest(Qo.of(Hp("."+Vp,e,v2)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&yt.get(r)||yt.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}ae.styleModule=Qo;ae.inputHandler=Uk;ae.clipboardInputFilter=ig;ae.clipboardOutputFilter=og;ae.scrollHandler=Yk;ae.focusChangeEffect=Kk;ae.perLineTextDirection=Gk;ae.exceptionSink=Wk;ae.updateListener=_p;ae.editable=Fr;ae.mouseSelectionStyle=Hk;ae.dragMovesSelection=Vk;ae.clickAddsSelectionRange=zk;ae.decorations=Ta;ae.blockWrappers=Qk;ae.outerDecorations=Jk;ae.atomicRanges=Gl;ae.bidiIsolatedRanges=e2;ae.scrollMargins=t2;ae.darkTheme=zp;ae.cspNonce=pe.define({combine:t=>t.length?t[0]:""});ae.contentAttributes=ag;ae.editorAttributes=Zk;ae.lineWrapping=ae.contentAttributes.of({class:"cm-lineWrapping"});ae.announce=Me.define();const $A=4096,ab={};class qd{constructor(e,n,r,s,i,o){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=i,this.order=o}static update(e,n){if(n.empty&&!e.some(i=>i.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Je.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let o=e[i];o.dir==s&&!n.touchesRange(o.from,o.to)&&r.push(new qd(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function lb(t,e,n){for(let r=t.state.facet(e),s=r.length-1;s>=0;s--){let i=r[s],o=typeof i=="function"?i(t):i;o&&ng(o,n)}return n}const BA=fe.mac?"mac":fe.windows?"win":fe.linux?"linux":"key";function FA(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,i,o,a;for(let l=0;l<n.length-1;++l){const d=n[l];if(/^(cmd|meta|m)$/i.test(d))a=!0;else if(/^a(lt)?$/i.test(d))s=!0;else if(/^(c|ctrl|control)$/i.test(d))i=!0;else if(/^s(hift)?$/i.test(d))o=!0;else if(/^mod$/i.test(d))e=="mac"?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+d)}return s&&(r="Alt-"+r),i&&(r="Ctrl-"+r),a&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function Lc(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const zA=hi.default(ae.domEventHandlers({keydown(t,e){return k2(w2(e.state),t,e,"editor")}})),Hu=pe.define({enables:zA}),cb=new WeakMap;function w2(t){let e=t.facet(Hu),n=cb.get(e);return n||cb.set(e,n=WA(e.reduce((r,s)=>r.concat(s),[]))),n}function VA(t,e,n){return k2(w2(t.state),e,t,n)}let ds=null;const HA=4e3;function WA(t,e=BA){let n=Object.create(null),r=Object.create(null),s=(o,a)=>{let l=r[o];if(l==null)r[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},i=(o,a,l,d,u)=>{var h,f;let p=n[o]||(n[o]=Object.create(null)),m=a.split(/ (?!$)/).map(y=>FA(y,e));for(let y=1;y<m.length;y++){let k=m.slice(0,y).join(" ");s(k,!0),p[k]||(p[k]={preventDefault:!0,stopPropagation:!1,run:[v=>{let w=ds={view:v,prefix:k,scope:o};return setTimeout(()=>{ds==w&&(ds=null)},HA),!0}]})}let x=m.join(" ");s(x,!1);let b=p[x]||(p[x]={preventDefault:!1,stopPropagation:!1,run:((f=(h=p._any)===null||h===void 0?void 0:h.run)===null||f===void 0?void 0:f.slice())||[]});l&&b.run.push(l),d&&(b.preventDefault=!0),u&&(b.stopPropagation=!0)};for(let o of t){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let d of a){let u=n[d]||(n[d]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:h}=o;for(let f in u)u[f].run.push(p=>h(p,Wp))}let l=o[e]||o.key;if(l)for(let d of a)i(d,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&i(d,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}let Wp=null;function k2(t,e,n,r){Wp=e;let s=sM(e),i=an(s,0),o=xr(i)==s.length&&s!=" ",a="",l=!1,d=!1,u=!1;ds&&ds.view==n&&ds.scope==r&&(a=ds.prefix+" ",d2.indexOf(e.keyCode)<0&&(d=!0,ds=null));let h=new Set,f=b=>{if(b){for(let y of b.run)if(!h.has(y)&&(h.add(y),y(n)))return b.stopPropagation&&(u=!0),!0;b.preventDefault&&(b.stopPropagation&&(u=!0),d=!0)}return!1},p=t[r],m,x;return p&&(f(p[a+Lc(s,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(fe.windows&&e.ctrlKey&&e.altKey)&&!(fe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(m=Cs[e.keyCode])&&m!=s?(f(p[a+Lc(m,e,!0)])||e.shiftKey&&(x=Oa[e.keyCode])!=s&&x!=m&&f(p[a+Lc(x,e,!1)]))&&(l=!0):o&&e.shiftKey&&f(p[a+Lc(s,e,!0)])&&(l=!0),!l&&f(p._any)&&(l=!0)),d&&(l=!0),l&&u&&e.stopPropagation(),Wp=null,l}class ql{constructor(e,n,r,s,i){this.className=e,this.left=n,this.top=r,this.width=s,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let i=S2(e);return[new ql(n,s.left-i.left,s.top-i.top,null,s.bottom-s.top)]}else return UA(e,n,r)}}function S2(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Je.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function db(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let i=t.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,a=t.posAtCoords({x:i.left+1,y:o}),l=t.posAtCoords({x:i.right-1,y:o});return a==null||l==null?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}function UA(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),i=t.textDirection==Je.LTR,o=t.contentDOM,a=o.getBoundingClientRect(),l=S2(t),d=o.querySelector(".cm-line"),u=d&&window.getComputedStyle(d),h=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=a.right-(u?parseInt(u.paddingRight):0),p=$p(t,r,1),m=$p(t,s,-1),x=p.type==Bt.Text?p:null,b=m.type==Bt.Text?m:null;if(x&&(t.lineWrapping||p.widgetLineBreaks)&&(x=db(t,r,1,x)),b&&(t.lineWrapping||m.widgetLineBreaks)&&(b=db(t,s,-1,b)),x&&b&&x.from==b.from&&x.to==b.to)return k(v(n.from,n.to,x));{let C=x?v(n.from,null,x):w(p,!1),j=b?v(null,n.to,b):w(m,!0),S=[];return(x||p).to<(b||m).from-(x&&b?1:0)||p.widgetLineBreaks>1&&C.bottom+t.defaultLineHeight/2<j.top?S.push(y(h,C.bottom,f,j.top)):C.bottom<j.top&&t.elementAtHeight((C.bottom+j.top)/2).type==Bt.Text&&(C.bottom=j.top=(C.bottom+j.top)/2),k(C).concat(S).concat(k(j))}function y(C,j,S,P){return new ql(e,C-l.left,j-l.top,S-C,P-j)}function k({top:C,bottom:j,horizontal:S}){let P=[];for(let D=0;D<S.length;D+=2)P.push(y(S[D],C,S[D+1],j));return P}function v(C,j,S){let P=1e9,D=-1e9,A=[];function N(O,E,M,R,_){let $=t.coordsAtPos(O,O==S.to?-2:2),F=t.coordsAtPos(M,M==S.from?2:-2);!$||!F||(P=Math.min($.top,F.top,P),D=Math.max($.bottom,F.bottom,D),_==Je.LTR?A.push(i&&E?h:$.left,i&&R?f:F.right):A.push(!i&&R?h:F.left,!i&&E?f:$.right))}let T=C??S.from,I=j??S.to;for(let O of t.visibleRanges)if(O.to>T&&O.from<I)for(let E=Math.max(O.from,T),M=Math.min(O.to,I);;){let R=t.state.doc.lineAt(E);for(let _ of t.bidiSpans(R)){let $=_.from+R.from,F=_.to+R.from;if($>=M)break;F>E&&N(Math.max($,E),C==null&&$<=T,Math.min(F,M),j==null&&F>=I,_.dir)}if(E=R.to+1,E>=M)break}return A.length==0&&N(T,C==null,I,j==null,t.textDirection),{top:P,bottom:D,horizontal:A}}function w(C,j){let S=a.top+(j?C.top:C.bottom);return{top:S,bottom:S,horizontal:[]}}}function KA(t,e){return t.constructor==e.constructor&&t.eq(e)}class GA{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(md)!=e.state.facet(md)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(md);for(;n<r.length&&r[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:n}=this.view;(e!=this.scaleX||n!=this.scaleY)&&(this.scaleX=e,this.scaleY=n,this.dom.style.transform=`scale(${1/e}, ${1/n})`)}draw(e){if(e.length!=this.drawn.length||e.some((n,r)=>!KA(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,fe.safari&&fe.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const md=pe.define();function C2(t){return[pt.define(e=>new GA(e,t)),md.of(t)]}const La=pe.define({combine(t){return Er(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function qA(t={}){return[La.of(t),YA,XA,ZA,qk.of(!0)]}function j2(t){return t.startState.facet(La)!=t.state.facet(La)}const YA=C2({above:!0,markers(t){let{state:e}=t,n=e.facet(La),r=[];for(let s of e.selection.ranges){let i=s==e.selection.main;if(s.empty||n.drawRangeCursor){let o=i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=s.empty?s:q.cursor(s.head,s.head>s.anchor?-1:1);for(let l of ql.forRange(t,o,a))r.push(l)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=j2(t);return n&&ub(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){ub(e.state,t)},class:"cm-cursorLayer"});function ub(t,e){e.style.animationDuration=t.facet(La).cursorBlinkRate+"ms"}const XA=C2({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:ql.forRange(t,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||j2(t)},class:"cm-selectionLayer"}),ZA=hi.highest(ae.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),N2=Me.define({map(t,e){return t==null?null:e.mapPos(t)}}),ta=zt.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((n,r)=>r.is(N2)?r.value:n,t)}}),QA=pt.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let n=t.state.field(ta);n==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(ta)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(ta),n=e!=null&&t.coordsAtPos(e);if(!n)return null;let r=t.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+t.scrollDOM.scrollLeft*t.scaleX,top:n.top-r.top+t.scrollDOM.scrollTop*t.scaleY,height:n.bottom-n.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/n+"px",this.cursor.style.height=t.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(ta)!=t&&this.view.dispatch({effects:N2.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function JA(){return[ta,QA]}function hb(t,e,n,r,s){e.lastIndex=0;for(let i=t.iterRange(n,r),o=n,a;!i.next().done;o+=i.value.length)if(!i.lineBreak)for(;a=e.exec(i.value);)s(o+a.index,a)}function eT(t,e){let n=t.visibleRanges;if(n.length==1&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;let r=[];for(let{from:s,to:i}of n)s=Math.max(t.state.doc.lineAt(s).from,s-e),i=Math.min(t.state.doc.lineAt(i).to,i+e),r.length&&r[r.length-1].to>=s?r[r.length-1].to=i:r.push({from:s,to:i});return r}class tT{constructor(e){const{regexp:n,decoration:r,decorate:s,boundary:i,maxLength:o=1e3}=e;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,s)this.addMatch=(a,l,d,u)=>s(u,d,d+a[0].length,a,l);else if(typeof r=="function")this.addMatch=(a,l,d,u)=>{let h=r(a,l,d);h&&u(d,d+a[0].length,h)};else if(r)this.addMatch=(a,l,d,u)=>u(d,d+a[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=i,this.maxLength=o}createDeco(e){let n=new Ur,r=n.add.bind(n);for(let{from:s,to:i}of eT(e,this.maxLength))hb(e.state.doc,this.regexp,s,i,(o,a)=>this.addMatch(a,e,o,r));return n.finish()}updateDeco(e,n){let r=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((i,o,a,l)=>{l>=e.view.viewport.from&&a<=e.view.viewport.to&&(r=Math.min(a,r),s=Math.max(l,s))}),e.viewportMoved||s-r>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,n.map(e.changes),r,s):n}updateRange(e,n,r,s){for(let i of e.visibleRanges){let o=Math.max(i.from,r),a=Math.min(i.to,s);if(a>=o){let l=e.state.doc.lineAt(o),d=l.to<a?e.state.doc.lineAt(a):l,u=Math.max(i.from,l.from),h=Math.min(i.to,d.to);if(this.boundary){for(;o>l.from;o--)if(this.boundary.test(l.text[o-1-l.from])){u=o;break}for(;a<d.to;a++)if(this.boundary.test(d.text[a-d.from])){h=a;break}}let f=[],p,m=(x,b,y)=>f.push(y.range(x,b));if(l==d)for(this.regexp.lastIndex=u-l.from;(p=this.regexp.exec(l.text))&&p.index<h-l.from;)this.addMatch(p,e,p.index+l.from,m);else hb(e.state.doc,this.regexp,u,h,(x,b)=>this.addMatch(b,e,x,m));n=n.update({filterFrom:u,filterTo:h,filter:(x,b)=>x<u||b>h,add:f})}}return n}}const Up=/x/.unicode!=null?"gu":"g",nT=new RegExp(`[\0-\b
269
269
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Up),rT={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Wh=null;function sT(){var t;if(Wh==null&&typeof document<"u"&&document.body){let e=document.body.style;Wh=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return Wh||!1}const gd=pe.define({combine(t){let e=Er(t,{render:null,specialChars:nT,addSpecialChars:null});return(e.replaceTabs=!sT())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Up)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Up)),e}});function iT(t={}){return[gd.of(t),oT()]}let fb=null;function oT(){return fb||(fb=pt.fromClass(class{constructor(t){this.view=t,this.decorations=je.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(gd)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new tT({regexp:t.specialChars,decoration:(e,n,r)=>{let{doc:s}=n.state,i=an(e[0],0);if(i==9){let o=s.lineAt(r),a=n.state.tabSize,l=vo(o.text,a,r-o.from);return je.replace({widget:new dT((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[i]||(this.decorationCache[i]=je.replace({widget:new cT(t,i)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(gd);t.startState.facet(gd)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const aT="•";function lT(t){return t>=32?aT:t==10?"␤":String.fromCharCode(9216+t)}class cT extends Dr{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=lT(this.code),r=e.state.phrase("Control character")+" "+(rT[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,r,n);if(s)return s;let i=document.createElement("span");return i.textContent=n,i.title=r,i.setAttribute("aria-label",r),i.className="cm-specialChar",i}ignoreEvent(){return!1}}class dT extends Dr{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function uT(){return fT}const hT=je.line({class:"cm-activeLine"}),fT=pt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push(hT.range(s.from)),e=s.from)}return je.set(n)}},{decorations:t=>t.decorations});class pT extends Dr{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?la(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),s=Ma(n[0],r.direction!="rtl"),i=parseInt(r.lineHeight);return s.bottom-s.top>i*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+i}:s}ignoreEvent(){return!1}}function mT(t){let e=pt.fromClass(class{constructor(n){this.view=n,this.placeholder=t?je.set([je.widget({widget:new pT(t),side:1}).range(0)]):je.none}get decorations(){return this.view.state.doc.length?je.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,ae.contentAttributes.of({"aria-placeholder":t})]:e}const Kp=2e3;function gT(t,e,n){let r=Math.min(e.line,n.line),s=Math.max(e.line,n.line),i=[];if(e.off>Kp||n.off>Kp||e.col<0||n.col<0){let o=Math.min(e.off,n.off),a=Math.max(e.off,n.off);for(let l=r;l<=s;l++){let d=t.doc.line(l);d.length<=a&&i.push(q.range(d.from+o,d.to+a))}}else{let o=Math.min(e.col,n.col),a=Math.max(e.col,n.col);for(let l=r;l<=s;l++){let d=t.doc.line(l),u=jp(d.text,o,t.tabSize,!0);if(u<0)i.push(q.cursor(d.to));else{let h=jp(d.text,a,t.tabSize);i.push(q.range(d.from+u,d.from+h))}}}return i}function xT(t,e){let n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}function pb(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),r=t.state.doc.lineAt(n),s=n-r.from,i=s>Kp?-1:s==r.length?xT(t,e.clientX):vo(r.text,t.state.tabSize,n-r.from);return{line:r.number,col:i,off:s}}function bT(t,e){let n=pb(t,e),r=t.state.selection;return n?{update(s){if(s.docChanged){let i=s.changes.mapPos(s.startState.doc.line(n.line).from),o=s.state.doc.lineAt(i);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},r=r.map(s.changes)}},get(s,i,o){let a=pb(t,s);if(!a)return r;let l=gT(t.state,n,a);return l.length?o?q.create(l.concat(r.ranges)):q.create(l):r}}:null}function yT(t){let e=n=>n.altKey&&n.button==0;return ae.mouseSelectionStyle.of((n,r)=>e(r)?bT(n,r):null)}const vT={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},wT={style:"cursor: crosshair"};function kT(t={}){let[e,n]=vT[t.key||"Alt"],r=pt.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||n(s))},keyup(s){(s.keyCode==e||!n(s))&&this.set(!1)},mousemove(s){this.set(n(s))}}});return[r,ae.contentAttributes.of(s=>{var i;return!((i=s.plugin(r))===null||i===void 0)&&i.isDown?wT:null})]}const Rc="-10000px";class P2{constructor(e,n,r,s){this.facet=n,this.createTooltipView=r,this.removeTooltipView=s,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let i=null;this.tooltipViews=this.tooltips.map(o=>i=r(o,i))}update(e,n){var r;let s=e.state.facet(this.facet),i=s.filter(l=>l);if(s===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=n?[]:null;for(let l=0;l<i.length;l++){let d=i[l],u=-1;if(d){for(let h=0;h<this.tooltips.length;h++){let f=this.tooltips[h];f&&f.create==d.create&&(u=h)}if(u<0)o[l]=this.createTooltipView(d,l?o[l-1]:null),a&&(a[l]=!!d.above);else{let h=o[l]=this.tooltipViews[u];a&&(a[l]=n[u]),h.update&&h.update(e)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(a.forEach((l,d)=>n[d]=l),n.length=a.length),this.input=s,this.tooltips=i,this.tooltipViews=o,!0}}function ST(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Uh=pe.define({combine:t=>{var e,n,r;return{position:fe.ios?"absolute":((e=t.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(s=>s.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(s=>s.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||ST}}}),mb=new WeakMap,hg=pt.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Uh);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new P2(t,fg,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(Uh);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",n.dom.appendChild(s)}return n.dom.style.position=this.position,n.dom.style.top=Rc,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:i}=this.manager.tooltipViews[0];if(fe.safari){let o=i.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!i.offsetParent&&i.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(t=i.width/this.parent.offsetWidth,e=i.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),s=lg(this.view);return{visible:{left:r.left+s.left,top:r.top+s.top,right:r.right-s.right,bottom:r.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((i,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(i.pos):this.view.coordsAtPos(i.pos)}),size:this.manager.tooltipViews.map(({dom:i})=>i.getBoundingClientRect()),space:this.view.state.facet(Uh).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:n,space:r,scaleX:s,scaleY:i}=t,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],d=this.manager.tooltipViews[a],{dom:u}=d,h=t.pos[a],f=t.size[a];if(!h||l.clip!==!1&&(h.bottom<=Math.max(n.top,r.top)||h.top>=Math.min(n.bottom,r.bottom)||h.right<Math.max(n.left,r.left)-.1||h.left>Math.min(n.right,r.right)+.1)){u.style.top=Rc;continue}let p=l.arrow?d.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,x=f.right-f.left,b=(e=mb.get(d))!==null&&e!==void 0?e:f.bottom-f.top,y=d.offset||jT,k=this.view.textDirection==Je.LTR,v=f.width>r.right-r.left?k?r.left:r.right-f.width:k?Math.max(r.left,Math.min(h.left-(p?14:0)+y.x,r.right-x)):Math.min(Math.max(r.left,h.left-x+(p?14:0)-y.x),r.right-x),w=this.above[a];!l.strictSide&&(w?h.top-b-m-y.y<r.top:h.bottom+b+m+y.y>r.bottom)&&w==r.bottom-h.bottom>h.top-r.top&&(w=this.above[a]=!w);let C=(w?h.top-r.top:r.bottom-h.bottom)-m;if(C<b&&d.resize!==!1){if(C<this.view.defaultLineHeight){u.style.top=Rc;continue}mb.set(d,b),u.style.height=(b=C)/i+"px"}else u.style.height&&(u.style.height="");let j=w?h.top-b-m-y.y:h.bottom+m+y.y,S=v+x;if(d.overlap!==!0)for(let P of o)P.left<S&&P.right>v&&P.top<j+b&&P.bottom>j&&(j=w?P.top-b-2-m:P.bottom+m+2);if(this.position=="absolute"?(u.style.top=(j-t.parent.top)/i+"px",gb(u,(v-t.parent.left)/s)):(u.style.top=j/i+"px",gb(u,v/s)),p){let P=h.left+(k?y.x:-y.x)-(v+14-7);p.style.left=P/s+"px"}d.overlap!==!0&&o.push({left:v,top:j,right:S,bottom:j+b}),u.classList.toggle("cm-tooltip-above",w),u.classList.toggle("cm-tooltip-below",!w),d.positioned&&d.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Rc}},{eventObservers:{scroll(){this.maybeMeasure()}}});function gb(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const CT=ae.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),jT={x:0,y:0},fg=pe.define({enables:[hg,CT]}),Yd=pe.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Wu{static create(e){return new Wu(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new P2(e,Yd,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let s=r[e];if(s!==void 0){if(n===void 0)n=s;else if(n!==s)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const NT=fg.compute([Yd],t=>{let e=t.facet(Yd);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Wu.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class PT{constructor(e,n,r,s,i){this.view=e,this.source=n,this.field=r,this.setHover=s,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:n}=this,r=e.docView.tile.nearest(n.target);if(!r)return;let s,i=1;if(r.isWidget())s=r.posAtStart;else{if(s=e.posAtCoords(n),s==null)return;let a=e.coordsAtPos(s);if(!a||n.y<a.top||n.y>a.bottom||n.x<a.left-e.defaultCharacterWidth||n.x>a.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(s)).find(u=>u.from<=s&&u.to>=s),d=l&&l.dir==Je.RTL?-1:1;i=n.x<a.left?-d:d}let o=this.source(e,s,i);if(o?.then){let a=this.pending={pos:s};o.then(l=>{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>dn(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(hg),n=e?e.manager.tooltips.findIndex(r=>r.create==Wu.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:i}=this;if(s.length&&i&&!OT(i.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,a=(r=(n=s[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!ET(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const _c=4;function OT(t,e){let{left:n,right:r,top:s,bottom:i}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();s=Math.min(a.top,s),i=Math.max(a.bottom,i)}return e.clientX>=n-_c&&e.clientX<=r+_c&&e.clientY>=s-_c&&e.clientY<=i+_c}function ET(t,e,n,r,s,i){let o=t.scrollDOM.getBoundingClientRect(),a=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.right<r||o.top>s||Math.min(o.bottom,a)<s)return!1;let l=t.posAtCoords({x:r,y:s},!1);return l>=e&&l<=n}function DT(t,e={}){let n=Me.define(),r=zt.define({create(){return[]},update(s,i){if(s.length&&(e.hideOnChange&&(i.docChanged||i.selection)?s=[]:e.hideOn&&(s=s.filter(o=>!e.hideOn(i,o))),i.docChanged)){let o=[];for(let a of s){let l=i.changes.mapPos(a.pos,-1,Zt.TrackDel);if(l!=null){let d=Object.assign(Object.create(null),a);d.pos=l,d.end!=null&&(d.end=i.changes.mapPos(d.end)),o.push(d)}}s=o}for(let o of i.effects)o.is(n)&&(s=o.value),o.is(MT)&&(s=[]);return s},provide:s=>Yd.from(s)});return{active:r,extension:[r,pt.define(s=>new PT(s,t,r,n,e.hoverTime||300)),NT]}}function O2(t,e){let n=t.plugin(hg);if(!n)return null;let r=n.manager.tooltips.indexOf(e);return r<0?null:n.manager.tooltipViews[r]}const MT=Me.define(),xb=pe.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}});function Ra(t,e){let n=t.plugin(E2),r=n?n.specs.indexOf(e):-1;return r>-1?n.panels[r]:null}const E2=pt.fromClass(class{constructor(t){this.input=t.state.facet(_a),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(xb);this.top=new Ic(t,!0,e.topContainer),this.bottom=new Ic(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(xb);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ic(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ic(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(_a);if(n!=this.input){let r=n.filter(l=>l),s=[],i=[],o=[],a=[];for(let l of r){let d=this.specs.indexOf(l),u;d<0?(u=l(t.view),a.push(u)):(u=this.panels[d],u.update&&u.update(t)),s.push(u),(u.top?i:o).push(u)}this.specs=r,this.panels=s,this.top.sync(i),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>ae.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Ic{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=bb(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=bb(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function bb(t){let e=t.nextSibling;return t.remove(),e}const _a=pe.define({enables:E2});class Gr extends ks{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Gr.prototype.elementClass="";Gr.prototype.toDOM=void 0;Gr.prototype.mapMode=Zt.TrackBefore;Gr.prototype.startSide=Gr.prototype.endSide=-1;Gr.prototype.point=!0;const xd=pe.define(),AT=pe.define(),TT={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},ua=pe.define();function LT(t){return[D2(),ua.of({...TT,...t})]}const yb=pe.define({combine:t=>t.some(e=>e)});function D2(t){return[RT]}const RT=pt.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(ua).map(e=>new wb(t,e)),this.fixed=!t.state.facet(yb);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(yb)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=Ie.iter(this.view.state.facet(xd),this.view.viewport.from),r=[],s=this.gutters.map(i=>new _T(i,this.view.viewport,-this.view.documentPadding.top));for(let i of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(i.type)){let o=!0;for(let a of i.type)if(a.type==Bt.Text&&o){Gp(n,r,a.from);for(let l of s)l.line(this.view,a,r);o=!1}else if(a.widget)for(let l of s)l.widget(this.view,a)}else if(i.type==Bt.Text){Gp(n,r,i.from);for(let o of s)o.line(this.view,i,r)}else if(i.widget)for(let o of s)o.widget(this.view,i);for(let i of s)i.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(ua),n=t.state.facet(ua),r=t.docChanged||t.heightChanged||t.viewportChanged||!Ie.eq(t.startState.facet(xd),t.state.facet(xd),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let i of n){let o=e.indexOf(i);o<0?s.push(new wb(this.view,i)):(this.gutters[o].update(t),s.push(this.gutters[o]))}for(let i of this.gutters)i.dom.remove(),s.indexOf(i)<0&&i.destroy();for(let i of s)i.config.side=="after"?this.getDOMAfter().appendChild(i.dom):this.dom.appendChild(i.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>ae.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Je.LTR?{left:r,right:s}:{right:r,left:s}})});function vb(t){return Array.isArray(t)?t:[t]}function Gp(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class _T{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=Ie.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,i=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==s.elements.length){let a=new M2(e,o,i,r);s.elements.push(a),s.dom.appendChild(a.dom)}else s.elements[this.i].update(e,o,i,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Gp(this.cursor,s,n.from),r.length&&(s=s.concat(r));let i=this.gutter.config.lineMarker(e,n,s);i&&s.unshift(i);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let i of e.state.facet(AT)){let o=i(e,n.widget,n);o&&(s||(s=[])).push(o)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class wb{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let i=s.target,o;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let l=i.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=s.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[r](e,a,s)&&s.preventDefault()});this.markers=vb(n.markers(e)),n.initialSpacer&&(this.spacer=new M2(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=vb(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!Ie.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class M2{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),IT(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let i=0,o=0;;){let a=o,l=i<n.length?n[i++]:null,d=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let h=o;h<this.markers.length;h++)if(this.markers[h].compare(l)){a=h,d=!0;break}}else a=this.markers.length;for(;o<a;){let u=this.markers[o++];if(u.toDOM){u.destroy(s);let h=s.nextSibling;s.remove(),s=h}}if(!l)break;l.toDOM&&(d?s=s.nextSibling:this.dom.insertBefore(l.toDOM(e),s)),d&&o++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function IT(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}const $T=pe.define(),BT=pe.define(),Ei=pe.define({combine(t){return Er(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,n){let r=Object.assign({},e);for(let s in n){let i=r[s],o=n[s];r[s]=i?(a,l,d)=>i(a,l,d)||o(a,l,d):o}return r}})}});class Kh extends Gr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Gh(t,e){return t.state.facet(Ei).formatNumber(e,t.state)}const FT=ua.compute([Ei],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet($T)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Kh(Gh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(BT)){let i=s(e,n,r);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Ei)!=e.state.facet(Ei),initialSpacer(e){return new Kh(Gh(e,kb(e.state.doc.lines)))},updateSpacer(e,n){let r=Gh(n.view,kb(n.view.state.doc.lines));return r==e.number?e:new Kh(r)},domEventHandlers:t.facet(Ei).domEventHandlers,side:"before"}));function zT(t={}){return[Ei.of(t),D2(),FT]}function kb(t){let e=9;for(;e<t;)e=e*10+9;return e}const VT=new class extends Gr{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},HT=xd.compute(["selection"],t=>{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(VT.range(s)))}return Ie.of(e)});function WT(){return HT}var qh;const Di=new _e;function UT(t){return pe.define({combine:t?e=>e.concat(t):void 0})}const KT=new _e;class Zn{constructor(e,n,r=[],s=""){this.data=e,this.name=s,Fe.prototype.hasOwnProperty("tree")||Object.defineProperty(Fe.prototype,"tree",{get(){return Kt(this)}}),this.parser=n,this.extension=[Ns.of(this),Fe.languageData.of((i,o,a)=>{let l=Sb(i,o,a),d=l.type.prop(Di);if(!d)return[];let u=i.facet(d),h=l.type.prop(KT);if(h){let f=l.resolve(o-l.from,a);for(let p of h)if(p.test(f,i)){let m=i.facet(p.facet);return p.type=="replace"?m:m.concat(u)}}return u})].concat(r)}isActiveAt(e,n,r=-1){return Sb(e,n,r).type.prop(Di)==this.data}findRegions(e){let n=e.facet(Ns);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(i,o)=>{if(i.prop(Di)==this.data){r.push({from:o,to:o+i.length});return}let a=i.prop(_e.mounted);if(a){if(a.tree.prop(Di)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+i.length});return}else if(a.overlay){let l=r.length;if(s(a.tree,a.overlay[0].from+o),r.length>l)return}}for(let l=0;l<i.children.length;l++){let d=i.children[l];d instanceof ft&&s(d,i.positions[l]+o)}};return s(Kt(e),0),r}get allowsNesting(){return!0}}Zn.setState=Me.define();function Sb(t,e,n){let r=t.facet(Ns),s=Kt(t).topNode;if(!r||r.allowsNesting)for(let i=s;i;i=i.enter(e,n,dt.ExcludeBuffers|dt.EnterBracketed))i.type.isTop&&(s=i);return s}class Xd extends Zn{constructor(e,n,r){super(e,n,[],r),this.parser=n}static define(e){let n=UT(e.languageData);return new Xd(n,e.parser.configure({props:[Di.add(r=>r.isTop?n:void 0)]}),e.name)}configure(e,n){return new Xd(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Kt(t){let e=t.field(Zn.state,!1);return e?e.tree:ft.empty}class GT{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e<r||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Vo=null;class Zd{constructor(e,n,r=[],s,i,o,a,l){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=i,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Zd(e,n,[],ft.empty,0,r,[],null)}startParse(){return this.parser.startParse(new GT(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=ft.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(Zs.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Zs.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Vo;Vo=this;try{return e()}finally{Vo=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Cb(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:i,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((d,u,h,f)=>l.push({fromA:d,toA:u,fromB:h,toB:f})),r=Zs.applyChanges(r,l),s=ft.empty,i=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let d of this.skipped){let u=e.mapPos(d.from,1),h=e.mapPos(d.to,-1);u<h&&a.push({from:u,to:h})}}}return new Zd(this.parser,n,r,s,i,o,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:s,to:i}=this.skipped[r];s<e.to&&i>e.from&&(this.fragments=Cb(this.fragments,s,i),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends ok{createParse(n,r,s){let i=s[0].from,o=s[s.length-1].to;return{parsedPos:i,advance(){let l=Vo;if(l){for(let d of s)l.tempSkipped.push(d);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new ft(fn.none,[],[],o-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Vo}}function Cb(t,e,n){return Zs.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class io{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new io(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Zd.create(e.facet(Ns).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new io(r)}}Zn.state=zt.define({create:io.init,update(t,e){for(let n of e.effects)if(n.is(Zn.setState))return n.value;return e.startState.facet(Ns)!=e.state.facet(Ns)?io.init(e.state):t.apply(e)}});let A2=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(A2=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Yh=typeof navigator<"u"&&(!((qh=navigator.scheduling)===null||qh===void 0)&&qh.isInputPending)?()=>navigator.scheduling.isInputPending():null,qT=pt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Zn.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Zn.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=A2(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:s}}=this.view,i=r.field(Zn.state);if(i.tree==i.context.tree&&i.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Yh?Math.max(25,e.timeRemaining()-5):1e9),a=i.context.treeLen<s&&r.doc.length>s+1e3,l=i.context.work(()=>Yh&&Yh()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Zn.setState.of(new io(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>dn(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ns=pe.define({combine(t){return t.length?t[0]:null},enables:t=>[Zn.state,qT,ae.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class YT{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const XT=pe.define(),Uu=pe.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Qd(t){let e=t.facet(Uu);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Ia(t,e){let n="",r=t.tabSize,s=t.facet(Uu)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let i=0;i<e;i++)n+=s;return n}function pg(t,e){t instanceof Fe&&(t=new Ku(t));for(let r of t.state.facet(XT)){let s=r(t,e);if(s!==void 0)return s}let n=Kt(t.state);return n.length>=e?ZT(t,n,e):null}class Ku{constructor(e,n={}){this.state=e,this.options=n,this.unit=Qd(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:i}=this.options;return s!=null&&s>=r.from&&s<=r.to?i&&s==e?{text:"",from:e}:(n<0?s<e:s<=e)?{text:r.text.slice(s-r.from),from:s}:{text:r.text.slice(0,s-r.from),from:r.from}:r}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:s}=this.lineAt(e,n);return r.slice(e-s,Math.min(r.length,e+100-s))}column(e,n=1){let{text:r,from:s}=this.lineAt(e,n),i=this.countColumn(r,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(i+=o-this.countColumn(r,r.search(/\S|$/))),i}countColumn(e,n=e.length){return vo(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),i=this.options.overrideIndentation;if(i){let o=i(s);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const T2=new _e;function ZT(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let i=[];for(let o=s;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)i.push(o);for(let o=i.length-1;o>=0;o--)r={node:i[o],next:r}}return L2(r,t,n)}function L2(t,e,n){for(let r=t;r;r=r.next){let s=JT(r.node);if(s)return s(mg.create(e,n,r))}return 0}function QT(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function JT(t){let e=t.type.prop(T2);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(_e.closedBy))){let s=t.lastChild,i=s&&r.indexOf(s.name)>-1;return o=>r6(o,!0,1,void 0,i&&!QT(o)?s.from:void 0)}return t.parent==null?e6:null}function e6(){return 0}class mg extends Ku{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new mg(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(t6(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return L2(this.context.next,this.base,this.pos)}}function t6(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function n6(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,i=t.state.doc.lineAt(n.from),o=s==null||s<=i.from?i.to:Math.min(i.to,s);for(let a=n.to;;){let l=e.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let d=/^ */.exec(i.text.slice(n.to-i.from))[0].length;return{from:n.from,to:n.to+d}}a=l.to}}function r6(t,e,n,r,s){let i=t.textAfter,o=i.match(/^\s*/)[0].length,a=r&&i.slice(o,o+r.length)==r||s==t.pos+o,l=n6(t);return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*n)}function jb({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const s6=200;function i6(){return Fe.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:r}=t.newSelection.main,s=n.lineAt(r);if(r>s.from+s6)return t;let i=n.sliceString(s.from,r);if(!e.some(d=>d.test(i)))return t;let{state:o}=t,a=-1,l=[];for(let{head:d}of o.selection.ranges){let u=o.doc.lineAt(d);if(u.from==a)continue;a=u.from;let h=pg(o,u.from);if(h==null)continue;let f=/^\s*/.exec(u.text)[0],p=Ia(o,h);f!=p&&l.push({from:u.from,to:u.from+f.length,insert:p})}return l.length?[t,{changes:l,sequential:!0}]:t})}const o6=pe.define(),R2=new _e;function a6(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function l6(t,e,n){let r=Kt(t);if(r.length<n)return null;let s=r.resolveStack(n,1),i=null;for(let o=s;o;o=o.next){let a=o.node;if(a.to<=n||a.from>n)continue;if(i&&a.from<e)break;let l=a.type.prop(R2);if(l&&(a.to<r.length-50||r.length==t.doc.length||!c6(a))){let d=l(a,t);d&&d.from<=n&&d.from>=e&&d.to>n&&(i=d)}}return i}function c6(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Jd(t,e,n){for(let r of t.facet(o6)){let s=r(t,e,n);if(s)return s}return l6(t,e,n)}function _2(t,e){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);return n>=r?void 0:{from:n,to:r}}const Gu=Me.define({map:_2}),Yl=Me.define({map:_2});function I2(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(r=>r.from<=n&&r.to>=n)||e.push(t.lineBlockAt(n));return e}const si=zt.define({create(){return je.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,r)=>t=Nb(t,n,r)),t=t.map(e.changes);for(let n of e.effects)if(n.is(Gu)&&!d6(t,n.value.from,n.value.to)){let{preparePlaceholder:r}=e.state.facet(F2),s=r?je.replace({widget:new x6(r(e.state,n.value))}):Pb;t=t.update({add:[s.range(n.value.from,n.value.to)]})}else n.is(Yl)&&(t=t.update({filter:(r,s)=>n.value.from!=r||n.value.to!=s,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=Nb(t,e.selection.main.head)),t},provide:t=>ae.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(r,s)=>{n.push(r,s)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let r=t[n++],s=t[n++];if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(Pb.range(r,s))}return je.set(e,!0)}});function Nb(t,e,n=e){let r=!1;return t.between(e,n,(s,i)=>{s<n&&i>e&&(r=!0)}),r?t.update({filterFrom:e,filterTo:n,filter:(s,i)=>s>=n||i<=e}):t}function eu(t,e,n){var r;let s=null;return(r=t.field(si,!1))===null||r===void 0||r.between(e,n,(i,o)=>{(!s||s.from>i)&&(s={from:i,to:o})}),s}function d6(t,e,n){let r=!1;return t.between(e,e,(s,i)=>{s==e&&i==n&&(r=!0)}),r}function $2(t,e){return t.field(si,!1)?e:e.concat(Me.appendConfig.of(z2()))}const u6=t=>{for(let e of I2(t)){let n=Jd(t.state,e.from,e.to);if(n)return t.dispatch({effects:$2(t.state,[Gu.of(n),B2(t,n)])}),!0}return!1},h6=t=>{if(!t.state.field(si,!1))return!1;let e=[];for(let n of I2(t)){let r=eu(t.state,n.from,n.to);r&&e.push(Yl.of(r),B2(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function B2(t,e,n=!0){let r=t.state.doc.lineAt(e.from).number,s=t.state.doc.lineAt(e.to).number;return ae.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${t.state.phrase("to")} ${s}.`)}const f6=t=>{let{state:e}=t,n=[];for(let r=0;r<e.doc.length;){let s=t.lineBlockAt(r),i=Jd(e,s.from,s.to);i&&n.push(Gu.of(i)),r=(i?t.lineBlockAt(i.to):s).to+1}return n.length&&t.dispatch({effects:$2(t.state,n)}),!!n.length},p6=t=>{let e=t.state.field(si,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(r,s)=>{n.push(Yl.of({from:r,to:s}))}),t.dispatch({effects:n}),!0},m6=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:u6},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:h6},{key:"Ctrl-Alt-[",run:f6},{key:"Ctrl-Alt-]",run:p6}],g6={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},F2=pe.define({combine(t){return Er(t,g6)}});function z2(t){return[si,v6]}function V2(t,e){let{state:n}=t,r=n.facet(F2),s=o=>{let a=t.lineBlockAt(t.posAtDOM(o.target)),l=eu(t.state,a.from,a.to);l&&t.dispatch({effects:Yl.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,s,e);let i=document.createElement("span");return i.textContent=r.placeholderText,i.setAttribute("aria-label",n.phrase("folded code")),i.title=n.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=s,i}const Pb=je.replace({widget:new class extends Dr{toDOM(t){return V2(t,null)}}});class x6 extends Dr{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return V2(e,this.value)}}const b6={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Xh extends Gr{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function y6(t={}){let e={...b6,...t},n=new Xh(e,!0),r=new Xh(e,!1),s=pt.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Ns)!=o.state.facet(Ns)||o.startState.field(si,!1)!=o.state.field(si,!1)||Kt(o.startState)!=Kt(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new Ur;for(let l of o.viewportLineBlocks){let d=eu(o.state,l.from,l.to)?r:Jd(o.state,l.from,l.to)?n:null;d&&a.add(l.from,l.from,d)}return a.finish()}}),{domEventHandlers:i}=e;return[s,LT({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(s))===null||a===void 0?void 0:a.markers)||Ie.empty},initialSpacer(){return new Xh(e,!1)},domEventHandlers:{...i,click:(o,a,l)=>{if(i.click&&i.click(o,a,l))return!0;let d=eu(o.state,a.from,a.to);if(d)return o.dispatch({effects:Yl.of(d)}),!0;let u=Jd(o.state,a.from,a.to);return u?(o.dispatch({effects:Gu.of(u)}),!0):!1}}}),z2()]}const v6=ae.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class wo{constructor(e,n){this.specs=e;let r;function s(a){let l=Ss.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const i=typeof n.all=="string"?n.all:n.all?s(n.all):void 0,o=n.scope;this.scope=o instanceof Zn?a=>a.prop(Di)==o.data:o?a=>a==o:void 0,this.style=ck(e.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=r?new Ss(r):null,this.themeType=n.themeType}static define(e,n){return new wo(e,n||{})}}const qp=pe.define(),H2=pe.define({combine(t){return t.length?[t[0]]:null}});function Zh(t){let e=t.facet(qp);return e.length?e:t.facet(H2)}function gg(t,e){let n=[k6],r;return t instanceof wo&&(t.module&&n.push(ae.styleModule.of(t.module)),r=t.themeType),e?.fallback?n.push(H2.of(t)):r?n.push(qp.computeN([ae.darkTheme],s=>s.facet(ae.darkTheme)==(r=="dark")?[t]:[])):n.push(qp.of(t)),n}class w6{constructor(e){this.markCache=Object.create(null),this.tree=Kt(e.state),this.decorations=this.buildDeco(e,Zh(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=Kt(e.state),r=Zh(e.state),s=r!=Zh(e.startState),{viewport:i}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<i.to&&!s&&n.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||s)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=i.to)}buildDeco(e,n){if(!n||!this.tree.length)return je.none;let r=new Ur;for(let{from:s,to:i}of e.visibleRanges)MD(this.tree,n,(o,a,l)=>{r.add(o,a,this.markCache[l]||(this.markCache[l]=je.mark({class:l})))},s,i);return r.finish()}}const k6=hi.high(pt.fromClass(w6,{decorations:t=>t.decorations})),S6=wo.define([{tag:W.meta,color:"#404740"},{tag:W.link,textDecoration:"underline"},{tag:W.heading,textDecoration:"underline",fontWeight:"bold"},{tag:W.emphasis,fontStyle:"italic"},{tag:W.strong,fontWeight:"bold"},{tag:W.strikethrough,textDecoration:"line-through"},{tag:W.keyword,color:"#708"},{tag:[W.atom,W.bool,W.url,W.contentSeparator,W.labelName],color:"#219"},{tag:[W.literal,W.inserted],color:"#164"},{tag:[W.string,W.deleted],color:"#a11"},{tag:[W.regexp,W.escape,W.special(W.string)],color:"#e40"},{tag:W.definition(W.variableName),color:"#00f"},{tag:W.local(W.variableName),color:"#30a"},{tag:[W.typeName,W.namespace],color:"#085"},{tag:W.className,color:"#167"},{tag:[W.special(W.variableName),W.macroName],color:"#256"},{tag:W.definition(W.propertyName),color:"#00c"},{tag:W.comment,color:"#940"},{tag:W.invalid,color:"#f00"}]),C6=ae.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),W2=1e4,U2="()[]{}",K2=pe.define({combine(t){return Er(t,{afterCursor:!0,brackets:U2,maxScanDistance:W2,renderMatch:P6})}}),j6=je.mark({class:"cm-matchingBracket"}),N6=je.mark({class:"cm-nonmatchingBracket"});function P6(t){let e=[],n=t.matched?j6:N6;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}const O6=zt.define({create(){return je.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],r=e.state.facet(K2);for(let s of e.state.selection.ranges){if(!s.empty)continue;let i=yr(e.state,s.head,-1,r)||s.head>0&&yr(e.state,s.head-1,1,r)||r.afterCursor&&(yr(e.state,s.head,1,r)||s.head<e.state.doc.length&&yr(e.state,s.head+1,-1,r));i&&(n=n.concat(r.renderMatch(i,e.state)))}return je.set(n,!0)},provide:t=>ae.decorations.from(t)}),E6=[O6,C6];function D6(t={}){return[K2.of(t),E6]}const M6=new _e;function Yp(t,e,n){let r=t.prop(e<0?_e.openedBy:_e.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function Xp(t){let e=t.type.prop(M6);return e?e(t.node):t}function yr(t,e,n,r={}){let s=r.maxScanDistance||W2,i=r.brackets||U2,o=Kt(t),a=o.resolveInner(e,n);for(let l=a;l;l=l.parent){let d=Yp(l.type,n,i);if(d&&l.from<l.to){let u=Xp(l);if(u&&(n>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return A6(t,e,n,l,u,d,i)}}return T6(t,e,n,o,a.type,s,i)}function A6(t,e,n,r,s,i,o){let a=r.parent,l={from:s.from,to:s.to},d=0,u=a?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(d==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let h=Xp(u);return{start:l,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Yp(u.type,n,o))d++;else if(Yp(u.type,-n,o)){if(d==0){let h=Xp(u);return{start:l,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}d--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function T6(t,e,n,r,s,i,o){let a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(a);if(l<0||l%2==0!=n>0)return null;let d={from:n<0?e-1:e,to:n>0?e+1:e},u=t.doc.iterRange(e,n>0?t.doc.length:0),h=0;for(let f=0;!u.next().done&&f<=i;){let p=u.value;n<0&&(f+=p.length);let m=e+f*n;for(let x=n>0?0:p.length-1,b=n>0?p.length:-1;x!=b;x+=n){let y=o.indexOf(p[x]);if(!(y<0||r.resolveInner(m+x,1).type!=s))if(y%2==0==n>0)h++;else{if(h==1)return{start:d,end:{from:m+x,to:m+x+1},matched:y>>1==l>>1};h--}}n>0&&(f+=p.length)}return u.done?{start:d,matched:!1}:null}const L6=Object.create(null),Ob=[fn.none],Eb=[],Db=Object.create(null),R6=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])R6[t]=_6(L6,e);function Qh(t,e){Eb.indexOf(t)>-1||(Eb.push(t),console.warn(e))}function _6(t,e){let n=[];for(let a of e.split(" ")){let l=[];for(let d of a.split(".")){let u=t[d]||W[d];u?typeof u=="function"?l.length?l=l.map(u):Qh(d,`Modifier ${d} used at start of tag`):l.length?Qh(d,`Tag ${d} used as modifier`):l=Array.isArray(u)?u:[u]:Qh(d,`Unknown highlighting tag ${d}`)}for(let d of l)n.push(d)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(a=>a.id),i=Db[s];if(i)return i.id;let o=Db[s]=fn.define({id:Ob.length,name:r,props:[ak({[r]:n})]});return Ob.push(o),o.id}Je.RTL,Je.LTR;const I6=Xd.define({name:"json",parser:RD.configure({props:[T2.add({Object:jb({except:/^\s*\}/}),Array:jb({except:/^\s*\]/})}),R2.add({"Object Array":a6})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function $6(){return new YT(I6)}function Zp(){return Zp=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Zp.apply(null,arguments)}function B6(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}const F6=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=bg(t.state,n.from);return r.line?z6(t):r.block?H6(t):!1};function xg(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const z6=xg(K6,0),V6=xg(G2,0),H6=xg((t,e)=>G2(t,e,U6(e)),0);function bg(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Ho=50;function W6(t,{open:e,close:n},r,s){let i=t.sliceDoc(r-Ho,r),o=t.sliceDoc(s,s+Ho),a=/\s*$/.exec(i)[0].length,l=/^\s*/.exec(o)[0].length,d=i.length-a;if(i.slice(d-e.length,d)==e&&o.slice(l,l+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:s+l,margin:l&&1}};let u,h;s-r<=2*Ho?u=h=t.sliceDoc(r,s):(u=t.sliceDoc(r,r+Ho),h=t.sliceDoc(s-Ho,s));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(h)[0].length,m=h.length-p-n.length;return u.slice(f,f+e.length)==e&&h.slice(m,m+n.length)==n?{open:{pos:r+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:s-p-n.length,margin:/\s/.test(h.charAt(m-1))?1:0}}:null}function U6(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let i=e.length-1;i>=0&&e[i].to>r.from?e[i].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function G2(t,e,n=e.selection.ranges){let r=n.map(i=>bg(e,i.from).block);if(!r.every(i=>i))return null;let s=n.map((i,o)=>W6(e,r[o],i.from,i.to));if(t!=2&&!s.every(i=>i))return{changes:e.changes(n.map((i,o)=>s[o]?[]:[{from:i.from,insert:r[o].open+" "},{from:i.to,insert:" "+r[o].close}]))};if(t!=1&&s.some(i=>i)){let i=[];for(let o=0,a;o<s.length;o++)if(a=s[o]){let l=r[o],{open:d,close:u}=a;i.push({from:d.pos-l.open.length,to:d.pos+d.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:i}}return null}function K6(t,e,n=e.selection.ranges){let r=[],s=-1;for(let{from:i,to:o}of n){let a=r.length,l=1e9,d=bg(e,i).line;if(d){for(let u=i;u<=o;){let h=e.doc.lineAt(u);if(h.from>s&&(i==o||o>h.from)){s=h.from;let f=/^\s*/.exec(h.text)[0].length,p=f==h.length,m=h.text.slice(f,f+d.length)==d?f:-1;f<h.text.length&&f<l&&(l=f),r.push({line:h,comment:m,token:d,indent:f,empty:p,single:!1})}u=h.to+1}if(l<1e9)for(let u=a;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=l);r.length==a+1&&(r[a].single=!0)}}if(t!=2&&r.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:a,token:l,indent:d,empty:u,single:h}of r)(h||!u)&&i.push({from:a.from+d,insert:l+" "});let o=e.changes(i);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(i=>i.comment>=0)){let i=[];for(let{line:o,comment:a,token:l}of r)if(a>=0){let d=o.from+a,u=d+l.length;o.text[u-o.from]==" "&&u++,i.push({from:d,to:u})}return{changes:i}}return null}const Qp=Or.define(),G6=Or.define(),q6=pe.define(),q2=pe.define({combine(t){return Er(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Y2=zt.define({create(){return vr.empty},update(t,e){let n=e.state.facet(q2),r=e.annotation(Qp);if(r){let l=un.fromTransaction(e,r.selection),d=r.side,u=d==0?t.undone:t.done;return l?u=tu(u,u.length,n.minDepth,l):u=Q2(u,e.startState.selection),new vr(d==0?r.rest:u,d==0?u:r.rest)}let s=e.annotation(G6);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(jt.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let i=un.fromTransaction(e),o=e.annotation(jt.time),a=e.annotation(jt.userEvent);return i?t=t.addChanges(i,o,a,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new vr(t.done.map(un.fromJSON),t.undone.map(un.fromJSON))}});function Y6(t={}){return[Y2,q2.of(t),ae.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?X2:e.inputType=="historyRedo"?Jp:null;return r?(e.preventDefault(),r(n)):!1}})]}function qu(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Y2,!1);if(!s)return!1;let i=s.pop(t,n,e);return i?(r(i),!0):!1}}const X2=qu(0,!1),Jp=qu(1,!1),X6=qu(0,!0),Z6=qu(1,!0);class un{constructor(e,n,r,s,i){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=i}setSelAfter(e){return new un(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new un(e.changes&&kt.fromJSON(e.changes),[],e.mapped&&Sr.fromJSON(e.mapped),e.startSelection&&q.fromJSON(e.startSelection),e.selectionsAfter.map(q.fromJSON))}static fromTransaction(e,n){let r=Ln;for(let s of e.startState.facet(q6)){let i=s(e);i.length&&(r=r.concat(i))}return!r.length&&e.changes.empty?null:new un(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,Ln)}static selection(e){return new un(void 0,Ln,void 0,void 0,e)}}function tu(t,e,n,r){let s=e+1>n+20?e-n-1:0,i=t.slice(s,e);return i.push(r),i}function Q6(t,e){let n=[],r=!1;return t.iterChangedRanges((s,i)=>n.push(s,i)),e.iterChangedRanges((s,i,o,a)=>{for(let l=0;l<n.length;){let d=n[l++],u=n[l++];a>=d&&o<=u&&(r=!0)}}),r}function J6(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function Z2(t,e){return t.length?e.length?t.concat(e):t:e}const Ln=[],eL=200;function Q2(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-eL));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),tu(t,t.length-1,1e9,n.setSelAfter(r)))}else return[un.selection([e])]}function tL(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Jh(t,e){if(!t.length)return t;let n=t.length,r=Ln;for(;n;){let s=nL(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let i=t.slice(0,n);return i[n-1]=s,i}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[un.selection(r)]:Ln}function nL(t,e,n){let r=Z2(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Ln,n);if(!t.changes)return un.selection(r);let s=t.changes.map(e),i=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(i):i;return new un(s,Me.mapEffects(t.effects,e),o,t.startSelection.map(i),r)}const rL=/^(input\.type|delete)($|\.)/;class vr{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new vr(this.done,this.undone):this}addChanges(e,n,r,s,i){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||rL.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<s.newGroupDelay&&s.joinToEvent(i,Q6(a.changes,e.changes))||r=="input.type.compose")?o=tu(o,o.length-1,s.minDepth,new un(e.changes.compose(a.changes),Z2(Me.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Ln)):o=tu(o,o.length,s.minDepth,e),new vr(o,Ln,n,r)}addSelection(e,n,r,s){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:Ln;return i.length>0&&n-this.prevTime<s&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&J6(i[i.length-1],e)?this:new vr(Q2(this.done,e),this.undone,n,r)}addMapping(e){return new vr(Jh(this.done,e),Jh(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,r){let s=e==0?this.done:this.undone;if(s.length==0)return null;let i=s[s.length-1],o=i.selectionsAfter[0]||n.selection;if(r&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Qp.of({side:e,rest:tL(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let a=s.length==1?Ln:s.slice(0,s.length-1);return i.mapped&&(a=Jh(a,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Qp.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}vr.empty=new vr(Ln,Ln);const sL=[{key:"Mod-z",run:X2,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Jp,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Jp,preventDefault:!0},{key:"Mod-u",run:X6,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Z6,preventDefault:!0}];function ko(t,e){return q.create(t.ranges.map(e),t.mainIndex)}function ir(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function or({state:t,dispatch:e},n){let r=ko(t.selection,n);return r.eq(t.selection,!0)?!1:(e(ir(t,r)),!0)}function Yu(t,e){return q.cursor(e?t.to:t.from)}function J2(t,e){return or(t,n=>n.empty?t.moveByChar(n,e):Yu(n,e))}function Gt(t){return t.textDirectionAt(t.state.selection.main.head)==Je.LTR}const eS=t=>J2(t,!Gt(t)),tS=t=>J2(t,Gt(t));function nS(t,e){return or(t,n=>n.empty?t.moveByGroup(n,e):Yu(n,e))}const iL=t=>nS(t,!Gt(t)),oL=t=>nS(t,Gt(t));function aL(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Xu(t,e,n){let r=Kt(t).resolveInner(e.head),s=n?_e.closedBy:_e.openedBy;for(let l=e.head;;){let d=n?r.childAfter(l):r.childBefore(l);if(!d)break;aL(t,d,s)?r=d:l=n?d.to:d.from}let i=r.type.prop(s),o,a;return i&&(o=n?yr(t,r.from,1):yr(t,r.to,-1))&&o.matched?a=n?o.end.to:o.end.from:a=n?r.to:r.from,q.cursor(a,n?-1:1)}const lL=t=>or(t,e=>Xu(t.state,e,!Gt(t))),cL=t=>or(t,e=>Xu(t.state,e,Gt(t)));function rS(t,e){return or(t,n=>{if(!n.empty)return Yu(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const sS=t=>rS(t,!1),iS=t=>rS(t,!0);function oS(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0,s;if(e){for(let i of t.state.facet(ae.scrollMargins)){let o=i(t);o?.top&&(n=Math.max(o?.top,n)),o?.bottom&&(r=Math.max(o?.bottom,r))}s=t.scrollDOM.clientHeight-n-r}else s=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,s-5)}}function aS(t,e){let n=oS(t),{state:r}=t,s=ko(r.selection,o=>o.empty?t.moveVertically(o,e,n.height):Yu(o,e));if(s.eq(r.selection))return!1;let i;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,d=a.bottom-n.marginBottom;o&&o.top>l&&o.bottom<d&&(i=ae.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-l}))}return t.dispatch(ir(r,s),{effects:i}),!0}const Mb=t=>aS(t,!1),em=t=>aS(t,!0);function Ds(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let i=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;i&&e.head!=r.from+i&&(s=q.cursor(r.from+i))}return s}const dL=t=>or(t,e=>Ds(t,e,!0)),uL=t=>or(t,e=>Ds(t,e,!1)),hL=t=>or(t,e=>Ds(t,e,!Gt(t))),fL=t=>or(t,e=>Ds(t,e,Gt(t))),pL=t=>or(t,e=>q.cursor(t.lineBlockAt(e.head).from,1)),mL=t=>or(t,e=>q.cursor(t.lineBlockAt(e.head).to,-1));function gL(t,e,n){let r=!1,s=ko(t.selection,i=>{let o=yr(t,i.head,-1)||yr(t,i.head,1)||i.head>0&&yr(t,i.head-1,1)||i.head<t.doc.length&&yr(t,i.head+1,-1);if(!o||!o.end)return i;r=!0;let a=o.start.from==i.head?o.end.to:o.end.from;return q.cursor(a)});return r?(e(ir(t,s)),!0):!1}const xL=({state:t,dispatch:e})=>gL(t,e);function Hn(t,e){let n=ko(t.state.selection,r=>{let s=e(r);return q.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return n.eq(t.state.selection)?!1:(t.dispatch(ir(t.state,n)),!0)}function lS(t,e){return Hn(t,n=>t.moveByChar(n,e))}const cS=t=>lS(t,!Gt(t)),dS=t=>lS(t,Gt(t));function uS(t,e){return Hn(t,n=>t.moveByGroup(n,e))}const bL=t=>uS(t,!Gt(t)),yL=t=>uS(t,Gt(t)),vL=t=>Hn(t,e=>Xu(t.state,e,!Gt(t))),wL=t=>Hn(t,e=>Xu(t.state,e,Gt(t)));function hS(t,e){return Hn(t,n=>t.moveVertically(n,e))}const fS=t=>hS(t,!1),pS=t=>hS(t,!0);function mS(t,e){return Hn(t,n=>t.moveVertically(n,e,oS(t).height))}const Ab=t=>mS(t,!1),Tb=t=>mS(t,!0),kL=t=>Hn(t,e=>Ds(t,e,!0)),SL=t=>Hn(t,e=>Ds(t,e,!1)),CL=t=>Hn(t,e=>Ds(t,e,!Gt(t))),jL=t=>Hn(t,e=>Ds(t,e,Gt(t))),NL=t=>Hn(t,e=>q.cursor(t.lineBlockAt(e.head).from)),PL=t=>Hn(t,e=>q.cursor(t.lineBlockAt(e.head).to)),Lb=({state:t,dispatch:e})=>(e(ir(t,{anchor:0})),!0),Rb=({state:t,dispatch:e})=>(e(ir(t,{anchor:t.doc.length})),!0),_b=({state:t,dispatch:e})=>(e(ir(t,{anchor:t.selection.main.anchor,head:0})),!0),Ib=({state:t,dispatch:e})=>(e(ir(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),OL=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),EL=({state:t,dispatch:e})=>{let n=Zu(t).map(({from:r,to:s})=>q.range(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:q.create(n),userEvent:"select"})),!0},DL=({state:t,dispatch:e})=>{let n=ko(t.selection,r=>{let s=Kt(t),i=s.resolveStack(r.from,1);if(r.empty){let o=s.resolveStack(r.from,-1);o.node.from>=i.node.from&&o.node.to<=i.node.to&&(i=o)}for(let o=i;o;o=o.next){let{node:a}=o;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&o.next)return q.range(a.to,a.from)}return r});return n.eq(t.selection)?!1:(e(ir(t,n)),!0)};function gS(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let i of n.selection.ranges){let o=n.doc.lineAt(i.head);if(e?o.to<t.state.doc.length:o.from>0)for(let a=i;;){let l=t.moveVertically(a,e);if(l.head<o.from||l.head>o.to){s.some(d=>d.head==l.head)||s.push(l);break}else{if(l.head==a.head)break;a=l}}}return s.length==r.ranges.length?!1:(t.dispatch(ir(n,q.create(s,s.length-1))),!0)}const ML=t=>gS(t,!1),AL=t=>gS(t,!0),TL=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=q.create([n.main]):n.main.empty||(r=q.create([q.cursor(n.main.head)])),r?(e(ir(t,r)),!0):!1};function Xl(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(i=>{let{from:o,to:a}=i;if(o==a){let l=e(i);l<o?(n="delete.backward",l=$c(t,l,!1)):l>o&&(n="delete.forward",l=$c(t,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=$c(t,o,!1),a=$c(t,a,!0);return o==a?{range:i}:{changes:{from:o,to:a},range:q.cursor(o,o<i.head?-1:1)}});return s.changes.empty?!1:(t.dispatch(r.update(s,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?ae.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function $c(t,e,n){if(t instanceof ae)for(let r of t.state.facet(ae.atomicRanges).map(s=>s(t)))r.between(e,e,(s,i)=>{s<e&&i>e&&(e=n?i:s)});return e}const xS=(t,e,n)=>Xl(t,r=>{let s=r.from,{state:i}=t,o=i.doc.lineAt(s),a,l;if(n&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,s-o.from))){if(a[a.length-1]==" ")return s-1;let d=vo(a,i.tabSize),u=d%Qd(i)||Qd(i);for(let h=0;h<u&&a[a.length-1-h]==" ";h++)s--;l=s}else l=Ct(o.text,s-o.from,e,e)+o.from,l==s&&o.number!=(e?i.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,s-o.from))&&(l=Ct(o.text,l-o.from,!1,!1)+o.from);return l}),tm=t=>xS(t,!1,!0),bS=t=>xS(t,!0,!1),yS=(t,e)=>Xl(t,n=>{let r=n.head,{state:s}=t,i=s.doc.lineAt(r),o=s.charCategorizer(r);for(let a=null;;){if(r==(e?i.to:i.from)){r==n.head&&i.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let l=Ct(i.text,r-i.from,e)+i.from,d=i.text.slice(Math.min(r,l)-i.from,Math.max(r,l)-i.from),u=o(d);if(a!=null&&u!=a)break;(d!=" "||r!=n.head)&&(a=u),r=l}return r}),vS=t=>yS(t,!1),LL=t=>yS(t,!0),RL=t=>Xl(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),_L=t=>Xl(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),IL=t=>Xl(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),$L=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Ge.of(["",""])},range:q.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},BL=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,i=t.doc.lineAt(s),o=s==i.from?s-1:Ct(i.text,s-i.from,!1)+i.from,a=s==i.to?s+1:Ct(i.text,s-i.from,!0)+i.from;return{changes:{from:o,to:a,insert:t.doc.slice(s,a).append(t.doc.slice(o,s))},range:q.cursor(a)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Zu(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),i=t.doc.lineAt(r.to);if(!r.empty&&r.to==i.from&&(i=t.doc.lineAt(r.to-1)),n>=s.number){let o=e[e.length-1];o.to=i.to,o.ranges.push(r)}else e.push({from:s.from,to:i.to,ranges:[r]});n=i.number+1}return e}function wS(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let i of Zu(t)){if(n?i.to==t.doc.length:i.from==0)continue;let o=t.doc.lineAt(n?i.to+1:i.from-1),a=o.length+1;if(n){r.push({from:i.to,to:o.to},{from:i.from,insert:o.text+t.lineBreak});for(let l of i.ranges)s.push(q.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{r.push({from:o.from,to:i.from},{from:i.to,insert:t.lineBreak+o.text});for(let l of i.ranges)s.push(q.range(l.anchor-a,l.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:q.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const FL=({state:t,dispatch:e})=>wS(t,e,!1),zL=({state:t,dispatch:e})=>wS(t,e,!0);function kS(t,e,n){if(t.readOnly)return!1;let r=[];for(let i of Zu(t))n?r.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):r.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const VL=({state:t,dispatch:e})=>kS(t,e,!1),HL=({state:t,dispatch:e})=>kS(t,e,!0),WL=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Zu(e).map(({from:s,to:i})=>(s>0?s--:i<e.doc.length&&i++,{from:s,to:i}))),r=ko(e.selection,s=>{let i;if(t.lineWrapping){let o=t.lineBlockAt(s.head),a=t.coordsAtPos(s.head,s.assoc||1);a&&(i=o.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,i)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function UL(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Kt(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),i;return r&&s&&r.to<=e&&s.from>=e&&(i=r.type.prop(_e.closedBy))&&i.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const $b=SS(!1),KL=SS(!0);function SS(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:i,to:o}=s,a=e.doc.lineAt(i),l=!t&&i==o&&UL(e,i);t&&(i=o=(o<=a.to?a:e.doc.lineAt(o)).to);let d=new Ku(e,{simulateBreak:i,simulateDoubleBreak:!!l}),u=pg(d,i);for(u==null&&(u=vo(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:i,to:o}=l:i>a.from&&i<a.from+100&&!/\S/.test(a.text.slice(0,i))&&(i=a.from);let h=["",Ia(e,u)];return l&&h.push(Ia(e,d.lineIndent(a.from,-1))),{changes:{from:i,to:o,insert:Ge.of(h)},range:q.cursor(i+1+h[1].length)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function yg(t,e){let n=-1;return t.changeByRange(r=>{let s=[];for(let o=r.from;o<=r.to;){let a=t.doc.lineAt(o);a.number>n&&(r.empty||r.to>a.from)&&(e(a,s,r),n=a.number),o=a.to+1}let i=t.changes(s);return{changes:s,range:q.range(i.mapPos(r.anchor,1),i.mapPos(r.head,1))}})}const GL=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Ku(t,{overrideIndentation:i=>{let o=n[i];return o??-1}}),s=yg(t,(i,o,a)=>{let l=pg(r,i.from);if(l==null)return;/\S/.test(i.text)||(l=0);let d=/^\s*/.exec(i.text)[0],u=Ia(t,l);(d!=u||a.from<i.from+d.length)&&(n[i.from]=l,o.push({from:i.from,to:i.from+d.length,insert:u}))});return s.changes.empty||e(t.update(s,{userEvent:"indent"})),!0},CS=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(yg(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Uu)})}),{userEvent:"input.indent"})),!0),jS=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(yg(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let i=vo(s,t.tabSize),o=0,a=Ia(t,Math.max(0,i-Qd(t)));for(;o<s.length&&o<a.length&&s.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:n.from+o,to:n.from+s.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),qL=t=>(t.setTabFocusMode(),!0),YL=[{key:"Ctrl-b",run:eS,shift:cS,preventDefault:!0},{key:"Ctrl-f",run:tS,shift:dS},{key:"Ctrl-p",run:sS,shift:fS},{key:"Ctrl-n",run:iS,shift:pS},{key:"Ctrl-a",run:pL,shift:NL},{key:"Ctrl-e",run:mL,shift:PL},{key:"Ctrl-d",run:bS},{key:"Ctrl-h",run:tm},{key:"Ctrl-k",run:RL},{key:"Ctrl-Alt-h",run:vS},{key:"Ctrl-o",run:$L},{key:"Ctrl-t",run:BL},{key:"Ctrl-v",run:em}],XL=[{key:"ArrowLeft",run:eS,shift:cS,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:iL,shift:bL,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:hL,shift:CL,preventDefault:!0},{key:"ArrowRight",run:tS,shift:dS,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:oL,shift:yL,preventDefault:!0},{mac:"Cmd-ArrowRight",run:fL,shift:jL,preventDefault:!0},{key:"ArrowUp",run:sS,shift:fS,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Lb,shift:_b},{mac:"Ctrl-ArrowUp",run:Mb,shift:Ab},{key:"ArrowDown",run:iS,shift:pS,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Rb,shift:Ib},{mac:"Ctrl-ArrowDown",run:em,shift:Tb},{key:"PageUp",run:Mb,shift:Ab},{key:"PageDown",run:em,shift:Tb},{key:"Home",run:uL,shift:SL,preventDefault:!0},{key:"Mod-Home",run:Lb,shift:_b},{key:"End",run:dL,shift:kL,preventDefault:!0},{key:"Mod-End",run:Rb,shift:Ib},{key:"Enter",run:$b,shift:$b},{key:"Mod-a",run:OL},{key:"Backspace",run:tm,shift:tm,preventDefault:!0},{key:"Delete",run:bS,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:vS,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:LL,preventDefault:!0},{mac:"Mod-Backspace",run:_L,preventDefault:!0},{mac:"Mod-Delete",run:IL,preventDefault:!0}].concat(YL.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),ZL=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:lL,shift:vL},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:cL,shift:wL},{key:"Alt-ArrowUp",run:FL},{key:"Shift-Alt-ArrowUp",run:VL},{key:"Alt-ArrowDown",run:zL},{key:"Shift-Alt-ArrowDown",run:HL},{key:"Mod-Alt-ArrowUp",run:ML},{key:"Mod-Alt-ArrowDown",run:AL},{key:"Escape",run:TL},{key:"Mod-Enter",run:KL},{key:"Alt-l",mac:"Ctrl-l",run:EL},{key:"Mod-i",run:DL,preventDefault:!0},{key:"Mod-[",run:jS},{key:"Mod-]",run:CS},{key:"Mod-Alt-\\",run:GL},{key:"Shift-Mod-k",run:WL},{key:"Shift-Mod-\\",run:xL},{key:"Mod-/",run:F6},{key:"Alt-A",run:V6},{key:"Ctrl-m",mac:"Shift-Alt-m",run:qL}].concat(XL),QL={key:"Tab",run:CS,shift:jS},Bb=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class oo{constructor(e,n,r=0,s=e.length,i,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,s),this.bufferStart=r,this.normalize=i?a=>i(Bb(a)):Bb,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return an(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=Zm(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=xr(e);let s=this.normalize(n);if(s.length)for(let i=0,o=r;;i++){let a=s.charCodeAt(i),l=this.match(a,o,this.bufferPos+this.bufferStart);if(i==s.length-1){if(l)return this.value=l,this;break}o==r&&i<n.length&&n.charCodeAt(i)==a&&o++}}}match(e,n,r){let s=null;for(let i=0;i<this.matches.length;i+=2){let o=this.matches[i],a=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[i+1],to:r}:(this.matches[i]++,a=!0)),a||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:n,to:r}:this.matches.push(1,n)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(oo.prototype[Symbol.iterator]=function(){return this});const NS={from:-1,to:-1,match:/.*/.exec("")},vg="gm"+(/x/.unicode==null?"":"u");class PS{constructor(e,n,r,s=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=NS,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new OS(e,n,r,s,i);this.re=new RegExp(n,vg+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=nu(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,s=r+n[0].length;if(this.matchPos=nu(this.text,s+(r==s?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<s||r>this.value.to)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const ef=new WeakMap;class Vi{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let s=ef.get(e);if(!s||s.from>=r||s.to<=n){let a=new Vi(n,e.sliceString(n,r));return ef.set(e,a),a}if(s.from==n&&s.to==r)return s;let{text:i,from:o}=s;return o>n&&(i=e.sliceString(n,o)+i,o=n),s.to<r&&(i+=e.sliceString(s.to,r)),ef.set(e,new Vi(o,i)),new Vi(n,i.slice(n-o,r-o))}}class OS{constructor(e,n,r,s,i){this.text=e,this.to=i,this.done=!1,this.value=NS,this.matchPos=nu(e,s),this.re=new RegExp(n,vg+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=Vi.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,s=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,match:n},this.matchPos=nu(this.text,s+(r==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Vi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(PS.prototype[Symbol.iterator]=OS.prototype[Symbol.iterator]=function(){return this});function JL(t){try{return new RegExp(t,vg),!0}catch{return!1}}function nu(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}function nm(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),n=Xe("input",{class:"cm-textfield",name:"line",value:e}),r=Xe("form",{class:"cm-gotoLine",onkeydown:i=>{i.keyCode==27?(i.preventDefault(),t.dispatch({effects:ha.of(!1)}),t.focus()):i.keyCode==13&&(i.preventDefault(),s())},onsubmit:i=>{i.preventDefault(),s()}},Xe("label",t.state.phrase("Go to line"),": ",n)," ",Xe("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),Xe("button",{name:"close",onclick:()=>{t.dispatch({effects:ha.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["×"]));function s(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!i)return;let{state:o}=t,a=o.doc.lineAt(o.selection.main.head),[,l,d,u,h]=i,f=u?+u.slice(1):0,p=d?+d:a.number;if(d&&h){let b=p/100;l&&(b=b*(l=="-"?-1:1)+a.number/o.doc.lines),p=Math.round(o.doc.lines*b)}else d&&l&&(p=p*(l=="-"?-1:1)+a.number);let m=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),x=q.cursor(m.from+Math.max(0,Math.min(f,m.length)));t.dispatch({effects:[ha.of(!1),ae.scrollIntoView(x.from,{y:"center"})],selection:x}),t.focus()}return{dom:r}}const ha=Me.define(),Fb=zt.define({create(){return!0},update(t,e){for(let n of e.effects)n.is(ha)&&(t=n.value);return t},provide:t=>_a.from(t,e=>e?nm:null)}),eR=t=>{let e=Ra(t,nm);if(!e){let n=[ha.of(!0)];t.state.field(Fb,!1)==null&&n.push(Me.appendConfig.of([Fb,tR])),t.dispatch({effects:n}),e=Ra(t,nm)}return e&&e.dom.querySelector("input").select(),!0},tR=ae.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),nR={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},rR=pe.define({combine(t){return Er(t,nR,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function sR(t){return[cR,lR]}const iR=je.mark({class:"cm-selectionMatch"}),oR=je.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function zb(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=st.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=st.Word)}function aR(t,e,n,r){return t(e.sliceDoc(n,n+1))==st.Word&&t(e.sliceDoc(r-1,r))==st.Word}const lR=pt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(rR),{state:n}=t,r=n.selection;if(r.ranges.length>1)return je.none;let s=r.main,i,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return je.none;let l=n.wordAt(s.head);if(!l)return je.none;o=n.charCategorizer(s.head),i=n.sliceDoc(l.from,l.to)}else{let l=s.to-s.from;if(l<e.minSelectionLength||l>200)return je.none;if(e.wholeWords){if(i=n.sliceDoc(s.from,s.to),o=n.charCategorizer(s.head),!(zb(o,n,s.from,s.to)&&aR(o,n,s.from,s.to)))return je.none}else if(i=n.sliceDoc(s.from,s.to),!i)return je.none}let a=[];for(let l of t.visibleRanges){let d=new oo(n.doc,i,l.from,l.to);for(;!d.next().done;){let{from:u,to:h}=d.value;if((!o||zb(o,n,u,h))&&(s.empty&&u<=s.from&&h>=s.to?a.push(oR.range(u,h)):(u>=s.to||h<=s.from)&&a.push(iR.range(u,h)),a.length>e.maxMatches))return je.none}}return je.set(a)}},{decorations:t=>t.decorations}),cR=ae.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),dR=({state:t,dispatch:e})=>{let{selection:n}=t,r=q.create(n.ranges.map(s=>t.wordAt(s.head)||q.cursor(s.head)),n.mainIndex);return r.eq(n)?!1:(e(t.update({selection:r})),!0)};function uR(t,e){let{main:n,ranges:r}=t.selection,s=t.wordAt(n.head),i=s&&s.from==n.from&&s.to==n.to;for(let o=!1,a=new oo(t.doc,e,r[r.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new oo(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),o=!0}else{if(o&&r.some(l=>l.from==a.value.from))continue;if(i){let l=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const hR=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(i=>i.from===i.to))return dR({state:t,dispatch:e});let r=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(i=>t.sliceDoc(i.from,i.to)!=r))return!1;let s=uR(t,r);return s?(e(t.update({selection:t.selection.addRange(q.range(s.from,s.to),!1),effects:ae.scrollIntoView(s.to)})),!0):!1},So=pe.define({combine(t){return Er(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new CR(e),scrollToMatch:e=>ae.scrollIntoView(e)})}});class ES{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||JL(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
270
270
  `:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new gR(this):new pR(this)}getCursor(e,n=0,r){let s=e.doc?e:Fe.create({doc:e});return r==null&&(r=s.doc.length),this.regexp?Ni(this,s,n,r):ji(this,s,n,r)}}class DS{constructor(e){this.spec=e}}function ji(t,e,n,r){return new oo(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:s=>s.toLowerCase(),t.wholeWord?fR(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function fR(t,e){return(n,r,s,i)=>((i>n||i+s.length<r)&&(i=Math.max(0,n-2),s=t.sliceString(i,Math.min(t.length,r+2))),(e(ru(s,n-i))!=st.Word||e(su(s,n-i))!=st.Word)&&(e(su(s,r-i))!=st.Word||e(ru(s,r-i))!=st.Word))}class pR extends DS{constructor(e){super(e)}nextMatch(e,n,r){let s=ji(this.spec,e,r,e.doc.length).nextOverlapping();if(s.done){let i=Math.min(e.doc.length,n+this.spec.unquoted.length);s=ji(this.spec,e,0,i).nextOverlapping()}return s.done||s.value.from==n&&s.value.to==r?null:s.value}prevMatchInRange(e,n,r){for(let s=r;;){let i=Math.max(n,s-1e4-this.spec.unquoted.length),o=ji(this.spec,e,i,s),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(i==n)return null;s-=1e4}}prevMatch(e,n,r){let s=this.prevMatchInRange(e,0,n);return s||(s=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=n||s.to!=r)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=ji(this.spec,e,0,e.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(e,n,r,s){let i=ji(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)s(i.value.from,i.value.to)}}function Ni(t,e,n,r){return new PS(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?mR(e.charCategorizer(e.selection.main.head)):void 0},n,r)}function ru(t,e){return t.slice(Ct(t,e,!1),e)}function su(t,e){return t.slice(e,Ct(t,e))}function mR(t){return(e,n,r)=>!r[0].length||(t(ru(r.input,r.index))!=st.Word||t(su(r.input,r.index))!=st.Word)&&(t(su(r.input,r.index+r[0].length))!=st.Word||t(ru(r.input,r.index+r[0].length))!=st.Word)}class gR extends DS{nextMatch(e,n,r){let s=Ni(this.spec,e,r,e.doc.length).next();return s.done&&(s=Ni(this.spec,e,0,n).next()),s.done?null:s.value}prevMatchInRange(e,n,r){for(let s=1;;s++){let i=Math.max(n,r-s*1e4),o=Ni(this.spec,e,i,r),a=null;for(;!o.next().done;)a=o.value;if(a&&(i==n||a.from>i+10))return a;if(i==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let s=r.length;s>0;s--){let i=+r.slice(0,s);if(i>0&&i<e.match.length)return e.match[i]+r.slice(s)}return n})}matchAll(e,n){let r=Ni(this.spec,e,0,e.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(e,n,r,s){let i=Ni(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!i.next().done;)s(i.value.from,i.value.to)}}const $a=Me.define(),wg=Me.define(),xs=zt.define({create(t){return new tf(rm(t).create(),null)},update(t,e){for(let n of e.effects)n.is($a)?t=new tf(n.value.create(),t.panel):n.is(wg)&&(t=new tf(t.query,n.value?kg:null));return t},provide:t=>_a.from(t,e=>e.panel)});class tf{constructor(e,n){this.query=e,this.panel=n}}const xR=je.mark({class:"cm-searchMatch"}),bR=je.mark({class:"cm-searchMatch cm-searchMatch-selected"}),yR=pt.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(xs))}update(t){let e=t.state.field(xs);(e!=t.startState.field(xs)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return je.none;let{view:n}=this,r=new Ur;for(let s=0,i=n.visibleRanges,o=i.length;s<o;s++){let{from:a,to:l}=i[s];for(;s<o-1&&l>i[s+1].from-2*250;)l=i[++s].to;t.highlight(n.state,a,l,(d,u)=>{let h=n.state.selection.ranges.some(f=>f.from==d&&f.to==u);r.add(d,u,h?bR:xR)})}return r.finish()}},{decorations:t=>t.decorations});function Zl(t){return e=>{let n=e.state.field(xs,!1);return n&&n.query.spec.valid?t(e,n):TS(e)}}const iu=Zl((t,{query:e})=>{let{to:n}=t.state.selection.main,r=e.nextMatch(t.state,n,n);if(!r)return!1;let s=q.single(r.from,r.to),i=t.state.facet(So);return t.dispatch({selection:s,effects:[Sg(t,r),i.scrollToMatch(s.main,t)],userEvent:"select.search"}),AS(t),!0}),ou=Zl((t,{query:e})=>{let{state:n}=t,{from:r}=n.selection.main,s=e.prevMatch(n,r,r);if(!s)return!1;let i=q.single(s.from,s.to),o=t.state.facet(So);return t.dispatch({selection:i,effects:[Sg(t,s),o.scrollToMatch(i.main,t)],userEvent:"select.search"}),AS(t),!0}),vR=Zl((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:q.create(n.map(r=>q.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),wR=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:s}=n.main,i=[],o=0;for(let a=new oo(t.doc,t.sliceDoc(r,s));!a.next().done;){if(i.length>1e3)return!1;a.value.from==r&&(o=i.length),i.push(q.range(a.value.from,a.value.to))}return e(t.update({selection:q.create(i,o),userEvent:"select.search.matches"})),!0},Vb=Zl((t,{query:e})=>{let{state:n}=t,{from:r,to:s}=n.selection.main;if(n.readOnly)return!1;let i=e.nextMatch(n,r,r);if(!i)return!1;let o=i,a=[],l,d,u=[];o.from==r&&o.to==s&&(d=n.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:d}),o=e.nextMatch(n,o.from,o.to),u.push(ae.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let h=t.state.changes(a);return o&&(l=q.single(o.from,o.to).map(h),u.push(Sg(t,o)),u.push(n.facet(So).scrollToMatch(l.main,t))),t.dispatch({changes:h,selection:l,effects:u,userEvent:"input.replace"}),!0}),kR=Zl((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(s=>{let{from:i,to:o}=s;return{from:i,to:o,insert:e.getReplacement(s)}});if(!n.length)return!1;let r=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:ae.announce.of(r),userEvent:"input.replace.all"}),!0});function kg(t){return t.state.facet(So).createPanel(t)}function rm(t,e){var n,r,s,i,o;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let d=t.facet(So);return new ES({search:((n=e?.literal)!==null&&n!==void 0?n:d.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e?.caseSensitive)!==null&&r!==void 0?r:d.caseSensitive,literal:(s=e?.literal)!==null&&s!==void 0?s:d.literal,regexp:(i=e?.regexp)!==null&&i!==void 0?i:d.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:d.wholeWord})}function MS(t){let e=Ra(t,kg);return e&&e.dom.querySelector("[main-field]")}function AS(t){let e=MS(t);e&&e==t.root.activeElement&&e.select()}const TS=t=>{let e=t.state.field(xs,!1);if(e&&e.panel){let n=MS(t);if(n&&n!=t.root.activeElement){let r=rm(t.state,e.query.spec);r.valid&&t.dispatch({effects:$a.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[wg.of(!0),e?$a.of(rm(t.state,e.query.spec)):Me.appendConfig.of(NR)]});return!0},LS=t=>{let e=t.state.field(xs,!1);if(!e||!e.panel)return!1;let n=Ra(t,kg);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:wg.of(!1)}),!0},SR=[{key:"Mod-f",run:TS,scope:"editor search-panel"},{key:"F3",run:iu,shift:ou,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:iu,shift:ou,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:LS,scope:"editor search-panel"},{key:"Mod-Shift-l",run:wR},{key:"Mod-Alt-g",run:eR},{key:"Mod-d",run:hR,preventDefault:!0}];class CR{constructor(e){this.view=e;let n=this.query=e.state.field(xs).query.spec;this.commit=this.commit.bind(this),this.searchField=Xe("input",{value:n.search,placeholder:gn(e,"Find"),"aria-label":gn(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Xe("input",{value:n.replace,placeholder:gn(e,"Replace"),"aria-label":gn(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Xe("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=Xe("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=Xe("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,i,o){return Xe("button",{class:"cm-button",name:s,onclick:i,type:"button"},o)}this.dom=Xe("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>iu(e),[gn(e,"next")]),r("prev",()=>ou(e),[gn(e,"previous")]),r("select",()=>vR(e),[gn(e,"all")]),Xe("label",null,[this.caseField,gn(e,"match case")]),Xe("label",null,[this.reField,gn(e,"regexp")]),Xe("label",null,[this.wordField,gn(e,"by word")]),...e.state.readOnly?[]:[Xe("br"),this.replaceField,r("replace",()=>Vb(e),[gn(e,"replace")]),r("replaceAll",()=>kR(e),[gn(e,"replace all")])],Xe("button",{name:"close",onclick:()=>LS(e),"aria-label":gn(e,"close"),type:"button"},["×"])])}commit(){let e=new ES({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:$a.of(e)}))}keydown(e){VA(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ou:iu)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Vb(this.view))}update(e){for(let n of e.transactions)for(let r of n.effects)r.is($a)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(So).top}}function gn(t,e){return t.state.phrase(e)}const Bc=30,Fc=/[\s\.,:;?!]/;function Sg(t,{from:e,to:n}){let r=t.state.doc.lineAt(e),s=t.state.doc.lineAt(n).to,i=Math.max(r.from,e-Bc),o=Math.min(s,n+Bc),a=t.state.sliceDoc(i,o);if(i!=r.from){for(let l=0;l<Bc;l++)if(!Fc.test(a[l+1])&&Fc.test(a[l])){a=a.slice(l);break}}if(o!=s){for(let l=a.length-1;l>a.length-Bc;l--)if(!Fc.test(a[l-1])&&Fc.test(a[l])){a=a.slice(0,l);break}}return ae.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${r.number}.`)}const jR=ae.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),NR=[xs,hi.low(yR),jR];class RS{constructor(e,n,r,s){this.state=e,this.pos=n,this.explicit=r,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=Kt(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),s=n.text.slice(r-n.from,this.pos-n.from),i=s.search(_S(e,!1));return i<0?null:{from:r+i,to:this.pos,text:s.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function Hb(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function PR(t){let e=Object.create(null),n=Object.create(null);for(let{label:s}of t){e[s[0]]=!0;for(let i=1;i<s.length;i++)n[s[i]]=!0}let r=Hb(e)+Hb(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function OR(t){let e=t.map(s=>typeof s=="string"?{label:s}:s),[n,r]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:PR(e);return s=>{let i=s.matchBefore(r);return i||s.explicit?{from:i?i.from:s.pos,options:e,validFor:n}:null}}class Wb{constructor(e,n,r,s){this.completion=e,this.source=n,this.match=r,this.score=s}}function Qs(t){return t.selection.main.from}function _S(t,e){var n;let{source:r}=t,s=e&&r[0]!="^",i=r[r.length-1]!="$";return!s&&!i?t:new RegExp(`${s?"^":""}(?:${r})${i?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const IS=Or.define();function ER(t,e,n,r){let{main:s}=t.selection,i=n-s.from,o=r-s.from;return{...t.changeByRange(a=>{if(a!=s&&n!=r&&t.sliceDoc(a.from+i,a.from+o)!=t.sliceDoc(n,r))return{range:a};let l=t.toText(e);return{changes:{from:a.from+i,to:r==s.from?a.to:a.from+o,insert:l},range:q.cursor(a.from+i+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Ub=new WeakMap;function DR(t){if(!Array.isArray(t))return t;let e=Ub.get(t);return e||Ub.set(t,e=OR(t)),e}const au=Me.define(),Ba=Me.define();class MR{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let r=an(e,n),s=xr(r);this.chars.push(r);let i=e.slice(n,n+s),o=i.toUpperCase();this.folded.push(an(o==i?i.toLowerCase():o,0)),n+=s}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:r,any:s,precise:i,byWord:o}=this;if(n.length==1){let k=an(e,0),v=xr(k),w=v==e.length?0:-100;if(k!=n[0])if(k==r[0])w+=-200;else return null;return this.ret(w,[0,v])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,d=0;if(a<0){for(let k=0,v=Math.min(e.length,200);k<v&&d<l;){let w=an(e,k);(w==n[d]||w==r[d])&&(s[d++]=k),k+=xr(w)}if(d<l)return null}let u=0,h=0,f=!1,p=0,m=-1,x=-1,b=/[a-z]/.test(e),y=!0;for(let k=0,v=Math.min(e.length,200),w=0;k<v&&h<l;){let C=an(e,k);a<0&&(u<l&&C==n[u]&&(i[u++]=k),p<l&&(C==n[p]||C==r[p]?(p==0&&(m=k),x=k+1,p++):p=0));let j,S=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(j=Zm(C))!=j.toLowerCase()?1:j!=j.toUpperCase()?2:0;(!k||S==1&&b||w==0&&S!=0)&&(n[h]==C||r[h]==C&&(f=!0)?o[h++]=k:o.length&&(y=!1)),w=S,k+=xr(C)}return h==l&&o[0]==0&&y?this.result(-100+(f?-200:0),o,e):p==l&&m==0?this.ret(-200-e.length+(x==e.length?0:-100),[0,x]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):p==l?this.ret(-900-e.length,[m,x]):h==l?this.result(-100+(f?-200:0)+-700+(y?0:-1100),o,e):n.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,n,r){let s=[],i=0;for(let o of n){let a=o+(this.astral?xr(an(r,o)):1);i&&s[i-1]==o?s[i-1]=a:(s[i++]=o,s[i++]=a)}return this.ret(e-r.length,s)}}class AR{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const Dt=pe.define({combine(t){return Er(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:TR,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>r=>Kb(e(r),n(r)),optionClass:(e,n)=>r=>Kb(e(r),n(r)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function Kb(t,e){return t?e?t+" "+e:t:e}function TR(t,e,n,r,s,i){let o=t.textDirection==Je.RTL,a=o,l=!1,d="top",u,h,f=e.left-s.left,p=s.right-e.right,m=r.right-r.left,x=r.bottom-r.top;if(a&&f<Math.min(m,p)?a=!1:!a&&p<Math.min(m,f)&&(a=!0),m<=(a?f:p))u=Math.max(s.top,Math.min(n.top,s.bottom-x))-e.top,h=Math.min(400,a?f:p);else{l=!0,h=Math.min(400,(o?e.right:s.right-e.left)-30);let k=s.bottom-e.bottom;k>=x||k>e.top?u=n.bottom-e.top:(d="bottom",u=e.bottom-n.top)}let b=(e.bottom-e.top)/i.offsetHeight,y=(e.right-e.left)/i.offsetWidth;return{style:`${d}: ${u/b}px; max-width: ${h/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}function LR(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(n,r,s,i){let o=document.createElement("span");o.className="cm-completionLabel";let a=n.displayLabel||n.label,l=0;for(let d=0;d<i.length;){let u=i[d++],h=i[d++];u>l&&o.appendChild(document.createTextNode(a.slice(l,u)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(a.slice(u,h))),f.className="cm-completionMatchedText",l=h}return l<a.length&&o.appendChild(document.createTextNode(a.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),e.sort((n,r)=>n.position-r.position).map(n=>n.render)}function nf(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let s=Math.floor(e/n);return{from:s*n,to:(s+1)*n}}let r=Math.floor((t-e)/n);return{from:t-(r+1)*n,to:t-r*n}}class RR{constructor(e,n,r){this.view=e,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let s=e.state.field(n),{options:i,selected:o}=s.open,a=e.state.facet(Dt);this.optionContent=LR(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=nf(i.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:d}=e.state.field(n).open;for(let u=l.target,h;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(h=/-(\d+)$/.exec(u.id))&&+h[1]<d.length){this.applyCompletion(e,d[+h[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let d=e.state.field(this.stateField,!1);d&&d.tooltip&&e.state.facet(Dt).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Ba.of(null)})}),this.showOptions(i,s.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let r=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=s){let{options:i,selected:o,disabled:a}=r.open;(!s.open||s.open.options!=i)&&(this.range=nf(i.length,o,e.state.facet(Dt).maxRenderedOptions),this.showOptions(i,r.id)),this.updateSel(),a!=((n=s.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=nf(n.options.length,n.selected,this.view.state.facet(Dt).maxRenderedOptions),this.showOptions(n.options,e.id));let r=this.updateSelectedOption(n.selected);if(r){this.destroyInfo();let{completion:s}=n.options[n.selected],{info:i}=s;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(s);if(!o)return;"then"in o?o.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,s)}).catch(a=>dn(this.view.state,a,"completion info")):(this.addInfoPane(o,s),r.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",r.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:i}=e;r.appendChild(s),this.infoDestroy=i||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let r=this.list.firstChild,s=this.range.from;r;r=r.nextSibling,s++)r.nodeName!="LI"||!r.id?s--:s==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&(r.removeAttribute("aria-selected"),r.removeAttribute("aria-describedby"));return n&&IR(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),i=this.space;if(!i){let o=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(i.bottom,n.bottom)-10||s.bottom<Math.max(i.top,n.top)+10?null:this.view.state.facet(Dt).positionInfo(this.view,n,s,r,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,r){const s=document.createElement("ul");s.id=n,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let i=null;for(let o=r.from;o<r.to;o++){let{completion:a,match:l}=e[o],{section:d}=a;if(d){let f=typeof d=="string"?d:d.name;if(f!=i&&(o>r.from||r.from==0))if(i=f,typeof d!="string"&&d.header)s.appendChild(d.header(d));else{let p=s.appendChild(document.createElement("completion-section"));p.textContent=f}}const u=s.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let h=this.optionClass(a);h&&(u.className=h);for(let f of this.optionContent){let p=f(a,this.view.state,this.view,l);p&&u.appendChild(p)}}return r.from&&s.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function _R(t,e){return n=>new RR(n,t,e)}function IR(t,e){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),s=n.height/t.offsetHeight;r.top<n.top?t.scrollTop-=(n.top-r.top)/s:r.bottom>n.bottom&&(t.scrollTop+=(r.bottom-n.bottom)/s)}function Gb(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function $R(t,e){let n=[],r=null,s=null,i=u=>{n.push(u);let{section:h}=u.completion;if(h){r||(r=[]);let f=typeof h=="string"?h:h.name;r.some(p=>p.name==f)||r.push(typeof h=="string"?{name:f}:h)}},o=e.facet(Dt);for(let u of t)if(u.hasResult()){let h=u.result.getMatch;if(u.result.filter===!1)for(let f of u.result.options)i(new Wb(f,u.source,h?h(f):[],1e9-n.length));else{let f=e.sliceDoc(u.from,u.to),p,m=o.filterStrict?new AR(f):new MR(f);for(let x of u.result.options)if(p=m.match(x.label)){let b=x.displayLabel?h?h(x,p.matched):[]:p.matched,y=p.score+(x.boost||0);if(i(new Wb(x,u.source,b,y)),typeof x.section=="object"&&x.section.rank==="dynamic"){let{name:k}=x.section;s||(s=Object.create(null)),s[k]=Math.max(y,s[k]||-1e9)}}}}if(r){let u=Object.create(null),h=0,f=(p,m)=>(p.rank==="dynamic"&&m.rank==="dynamic"?s[m.name]-s[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof m.rank=="number"?m.rank:1e9)||(p.name<m.name?-1:1);for(let p of r.sort(f))h-=1e5,u[p.name]=h;for(let p of n){let{section:m}=p.completion;m&&(p.score+=u[typeof m=="string"?m:m.name])}}let a=[],l=null,d=o.compareCompletions;for(let u of n.sort((h,f)=>f.score-h.score||d(h.completion,f.completion))){let h=u.completion;!l||l.label!=h.label||l.detail!=h.detail||l.type!=null&&h.type!=null&&l.type!=h.type||l.apply!=h.apply||l.boost!=h.boost?a.push(u):Gb(u.completion)>Gb(l)&&(a[a.length-1]=u),l=u.completion}return a}class Mi{constructor(e,n,r,s,i,o){this.options=e,this.attrs=n,this.tooltip=r,this.timestamp=s,this.selected=i,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new Mi(this.options,qb(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,r,s,i,o){if(s&&!o&&e.some(d=>d.isPending))return s.setDisabled();let a=$R(e,n);if(!a.length)return s&&e.some(d=>d.isPending)?s.setDisabled():null;let l=n.facet(Dt).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let d=s.options[s.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==d){l=u;break}}return new Mi(a,qb(r,l),{pos:e.reduce((d,u)=>u.hasResult()?Math.min(d,u.from):d,1e8),create:WR,above:i.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Mi(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Mi(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class lu{constructor(e,n,r){this.active=e,this.id=n,this.open=r}static start(){return new lu(VR,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,r=n.facet(Dt),i=(r.override||n.languageDataAt("autocomplete",Qs(n)).map(DR)).map(l=>(this.active.find(u=>u.source==l)||new Rn(l,this.active.some(u=>u.state!=0)?1:0)).update(e,r));i.length==this.active.length&&i.every((l,d)=>l==this.active[d])&&(i=this.active);let o=this.open,a=e.effects.some(l=>l.is(Cg));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||i.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!BR(i,this.active)||a?o=Mi.build(i,n,this.id,o,r,a):o&&o.disabled&&!i.some(l=>l.isPending)&&(o=null),!o&&i.every(l=>!l.isPending)&&i.some(l=>l.hasResult())&&(i=i.map(l=>l.hasResult()?new Rn(l.source,0):l));for(let l of e.effects)l.is(BS)&&(o=o&&o.setSelected(l.value,this.id));return i==this.active&&o==this.open?this:new lu(i,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?FR:zR}}function BR(t,e){if(t==e)return!0;for(let n=0,r=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;r<e.length&&!e[r].hasResult();)r++;let s=n==t.length,i=r==e.length;if(s||i)return s==i;if(t[n++].result!=e[r++].result)return!1}}const FR={"aria-autocomplete":"list"},zR={};function qb(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const VR=[];function $S(t,e){if(t.isUserEvent("input.complete")){let r=t.annotation(IS);if(r&&e.activateOnCompletion(r))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Rn{constructor(e,n,r=!1){this.source=e,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let r=$S(e,n),s=this;(r&8||r&16&&this.touches(e))&&(s=new Rn(s.source,0)),r&4&&s.state==0&&(s=new Rn(this.source,1)),s=s.updateFor(e,r);for(let i of e.effects)if(i.is(au))s=new Rn(s.source,1,i.value);else if(i.is(Ba))s=new Rn(s.source,0);else if(i.is(Cg))for(let o of i.value)o.source==s.source&&(s=o);return s}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Qs(e.state))}}class Hi extends Rn{constructor(e,n,r,s,i,o){super(e,3,n),this.limit=r,this.result=s,this.from=i,this.to=o}hasResult(){return!0}updateFor(e,n){var r;if(!(n&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=Qs(e.state);if(a>o||!s||n&2&&(Qs(e.startState)==this.from||a<this.limit))return new Rn(this.source,n&4?1:0);let l=e.changes.mapPos(this.limit);return HR(s.validFor,e.state,i,o)?new Hi(this.source,this.explicit,l,s,i,o):s.update&&(s=s.update(s,i,o,new RS(e.state,a,!1)))?new Hi(this.source,this.explicit,l,s,s.from,(r=s.to)!==null&&r!==void 0?r:Qs(e.state)):new Rn(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Hi(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Rn(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function HR(t,e,n,r){if(!t)return!1;let s=e.sliceDoc(n,r);return typeof t=="function"?t(s,n,r,e):_S(t,!0).test(s)}const Cg=Me.define({map(t,e){return t.map(n=>n.map(e))}}),BS=Me.define(),ln=zt.define({create(){return lu.start()},update(t,e){return t.update(e)},provide:t=>[fg.from(t,e=>e.tooltip),ae.contentAttributes.from(t,e=>e.attrs)]});function jg(t,e){const n=e.completion.apply||e.completion.label;let r=t.state.field(ln).active.find(s=>s.source==e.source);return r instanceof Hi?(typeof n=="string"?t.dispatch({...ER(t.state,n,r.from,r.to),annotations:IS.of(e.completion)}):n(t,e.completion,r.from,r.to),!0):!1}const WR=_R(ln,jg);function zc(t,e="option"){return n=>{let r=n.state.field(ln,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Dt).interactionDelay)return!1;let s=1,i;e=="page"&&(i=O2(n,r.open.tooltip))&&(s=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,a=r.open.selected>-1?r.open.selected+s*(t?1:-1):t?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),n.dispatch({effects:BS.of(a)}),!0}}const UR=t=>{let e=t.state.field(ln,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Dt).interactionDelay?!1:jg(t,e.open.options[e.open.selected])},rf=t=>t.state.field(ln,!1)?(t.dispatch({effects:au.of(!0)}),!0):!1,KR=t=>{let e=t.state.field(ln,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Ba.of(null)}),!0)};class GR{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const qR=50,YR=1e3,XR=pt.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(ln).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(ln),n=t.state.facet(Dt);if(!t.selectionSet&&!t.docChanged&&t.startState.field(ln)==e)return;let r=t.transactions.some(i=>{let o=$S(i,n);return o&8||(i.selection||i.docChanged)&&!(o&3)});for(let i=0;i<this.running.length;i++){let o=this.running[i];if(r||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>qR&&Date.now()-o.time>YR){for(let a of o.context.abortListeners)try{a()}catch(l){dn(this.view.state,l)}o.context.abortListeners=null,this.running.splice(i--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(i=>i.effects.some(o=>o.is(au)))&&(this.pendingStart=!0);let s=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(i=>i.isPending&&!this.running.some(o=>o.active.source==i.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let i of t.transactions)i.isUserEvent("input.type")?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(ln);for(let n of e.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Dt).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=Qs(e),r=new RS(e,n,t.explicit,this.view),s=new GR(t,r);this.running.push(s),Promise.resolve(t.source(r)).then(i=>{s.context.aborted||(s.done=i||null,this.scheduleAccept())},i=>{this.view.dispatch({effects:Ba.of(null)}),dn(this.view.state,i)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Dt).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(Dt),r=this.view.state.field(ln);for(let s=0;s<this.running.length;s++){let i=this.running[s];if(i.done===void 0)continue;if(this.running.splice(s--,1),i.done){let a=Qs(i.updates.length?i.updates[0].startState:this.view.state),l=Math.min(a,i.done.from+(i.active.explicit?0:1)),d=new Hi(i.active.source,i.active.explicit,l,i.done,i.done.from,(t=i.done.to)!==null&&t!==void 0?t:a);for(let u of i.updates)d=d.update(u,n);if(d.hasResult()){e.push(d);continue}}let o=r.active.find(a=>a.source==i.active.source);if(o&&o.isPending)if(i.done==null){let a=new Rn(i.active.source,0);for(let l of i.updates)a=a.update(l,n);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:Cg.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(ln,!1);if(e&&e.tooltip&&this.view.state.facet(Dt).closeOnBlur){let n=e.open&&O2(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Ba.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:au.of(!1)}),20),this.composing=0}}}),ZR=typeof navigator=="object"&&/Win/.test(navigator.platform),QR=hi.highest(ae.domEventHandlers({keydown(t,e){let n=e.state.field(ln,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(ZR&&t.altKey)||t.metaKey)return!1;let r=n.open.options[n.open.selected],s=n.active.find(o=>o.source==r.source),i=r.completion.commitCharacters||s.result.commitCharacters;return i&&i.indexOf(t.key)>-1&&jg(e,r),!1}})),JR=ae.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Fa={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ys=Me.define({map(t,e){let n=e.mapPos(t,-1,Zt.TrackAfter);return n??void 0}}),Ng=new class extends ks{};Ng.startSide=1;Ng.endSide=-1;const FS=zt.define({create(){return Ie.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of e.effects)n.is(Ys)&&(t=t.update({add:[Ng.range(n.value,n.value+1)]}));return t}});function e7(){return[n7,FS]}const sf="()[]{}<>«»»«[]{}";function zS(t){for(let e=0;e<sf.length;e+=2)if(sf.charCodeAt(e)==t)return sf.charAt(e+1);return Zm(t<128?t:t+1)}function VS(t,e){return t.languageDataAt("closeBrackets",e)[0]||Fa}const t7=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),n7=ae.inputHandler.of((t,e,n,r)=>{if((t7?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let s=t.state.selection.main;if(r.length>2||r.length==2&&xr(an(r,0))==1||e!=s.from||n!=s.to)return!1;let i=i7(t.state,r);return i?(t.dispatch(i),!0):!1}),r7=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=VS(t,t.selection.main.head).brackets||Fa.brackets,s=null,i=t.changeByRange(o=>{if(o.empty){let a=o7(t.doc,o.head);for(let l of r)if(l==a&&Qu(t.doc,o.head)==zS(an(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:q.cursor(o.head-l.length)}}return{range:s=o}});return s||e(t.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},s7=[{key:"Backspace",run:r7}];function i7(t,e){let n=VS(t,t.selection.main.head),r=n.brackets||Fa.brackets;for(let s of r){let i=zS(an(s,0));if(e==s)return i==s?c7(t,s,r.indexOf(s+s+s)>-1,n):a7(t,s,i,n.before||Fa.before);if(e==i&&HS(t,t.selection.main.from))return l7(t,s,i)}return null}function HS(t,e){let n=!1;return t.field(FS).between(0,t.doc.length,r=>{r==e&&(n=!0)}),n}function Qu(t,e){let n=t.sliceString(e,e+2);return n.slice(0,xr(an(n,0)))}function o7(t,e){let n=t.sliceString(e-2,e);return xr(an(n,0))==n.length?n:n.slice(1)}function a7(t,e,n,r){let s=null,i=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:Ys.of(o.to+e.length),range:q.range(o.anchor+e.length,o.head+e.length)};let a=Qu(t.doc,o.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+n,from:o.head},effects:Ys.of(o.head+e.length),range:q.cursor(o.head+e.length)}:{range:s=o}});return s?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function l7(t,e,n){let r=null,s=t.changeByRange(i=>i.empty&&Qu(t.doc,i.head)==n?{changes:{from:i.head,to:i.head+n.length,insert:n},range:q.cursor(i.head+n.length)}:r={range:i});return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function c7(t,e,n,r){let s=r.stringPrefixes||Fa.stringPrefixes,i=null,o=t.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Ys.of(a.to+e.length),range:q.range(a.anchor+e.length,a.head+e.length)};let l=a.head,d=Qu(t.doc,l),u;if(d==e){if(Yb(t,l))return{changes:{insert:e+e,from:l},effects:Ys.of(l+e.length),range:q.cursor(l+e.length)};if(HS(t,l)){let f=n&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+f.length,insert:f},range:q.cursor(l+f.length)}}}else{if(n&&t.sliceDoc(l-2*e.length,l)==e+e&&(u=Xb(t,l-2*e.length,s))>-1&&Yb(t,u))return{changes:{insert:e+e+e+e,from:l},effects:Ys.of(l+e.length),range:q.cursor(l+e.length)};if(t.charCategorizer(l)(d)!=st.Word&&Xb(t,l,s)>-1&&!d7(t,l,e,s))return{changes:{insert:e+e,from:l},effects:Ys.of(l+e.length),range:q.cursor(l+e.length)}}return{range:i=a}});return i?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Yb(t,e){let n=Kt(t).resolveInner(e+1);return n.parent&&n.from==e}function d7(t,e,n,r){let s=Kt(t).resolveInner(e,-1),i=r.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=t.sliceDoc(s.from,Math.min(s.to,s.from+n.length+i)),l=a.indexOf(n);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let u=s.firstChild;for(;u&&u.from==s.from&&u.to-u.from>n.length+l;){if(t.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let d=s.to==e&&s.parent;if(!d)break;s=d}return!1}function Xb(t,e,n){let r=t.charCategorizer(e);if(r(t.sliceDoc(e-1,e))!=st.Word)return e;for(let s of n){let i=e-s.length;if(t.sliceDoc(i,e)==s&&r(t.sliceDoc(i-1,i))!=st.Word)return i}return-1}function u7(t={}){return[QR,ln,Dt.of(t),XR,h7,JR]}const WS=[{key:"Ctrl-Space",run:rf},{mac:"Alt-`",run:rf},{mac:"Alt-i",run:rf},{key:"Escape",run:KR},{key:"ArrowDown",run:zc(!0)},{key:"ArrowUp",run:zc(!1)},{key:"PageDown",run:zc(!0,"page")},{key:"PageUp",run:zc(!1,"page")},{key:"Enter",run:UR}],h7=hi.highest(Hu.computeN([Dt],t=>t.facet(Dt).defaultKeymap?[WS]:[]));class Zb{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Vs{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let s=r.facet(za).markerFilter;s&&(e=s(e,r));let i=e.slice().sort((p,m)=>p.from-m.from||p.to-m.to),o=new Ur,a=[],l=0,d=r.doc.iter(),u=0,h=r.doc.length;for(let p=0;;){let m=p==i.length?null:i[p];if(!m&&!a.length)break;let x,b;if(a.length)x=l,b=a.reduce((v,w)=>Math.min(v,w.to),m&&m.from>x?m.from:1e8);else{if(x=m.from,x>h)break;b=m.to,a.push(m),p++}for(;p<i.length;){let v=i[p];if(v.from==x&&(v.to>v.from||v.to==x))a.push(v),p++,b=Math.min(v.to,b);else{b=Math.min(v.from,b);break}}b=Math.min(b,h);let y=!1;if(a.some(v=>v.from==x&&(v.to==b||b==h))&&(y=x==b,!y&&b-x<10)){let v=x-(u+d.value.length);v>0&&(d.next(v),u=x);for(let w=x;;){if(w>=b){y=!0;break}if(!d.lineBreak&&u+d.value.length>w)break;w=u+d.value.length,u+=d.value.length,d.next()}}let k=j7(a);if(y)o.add(x,x,je.widget({widget:new w7(k),diagnostics:a.slice()}));else{let v=a.reduce((w,C)=>C.markClass?w+" "+C.markClass:w,"");o.add(x,b,je.mark({class:"cm-lintRange cm-lintRange-"+k+v,diagnostics:a.slice(),inclusiveEnd:a.some(w=>w.to>b)}))}if(l=b,l==h)break;for(let v=0;v<a.length;v++)a[v].to<=l&&a.splice(v--,1)}let f=o.finish();return new Vs(f,n,ao(f))}}function ao(t,e=null,n=0){let r=null;return t.between(n,1e9,(s,i,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new Zb(s,i,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new Zb(r.from,i,r.diagnostic)}}),r}function f7(t,e){let n=e.pos,r=e.end||n,s=t.state.facet(za).hideOn(t,n,r);if(s!=null)return s;let i=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(US))||t.changes.touchesRange(i.from,Math.max(i.to,r)))}function p7(t,e){return t.field(wn,!1)?e:e.concat(Me.appendConfig.of(N7))}const US=Me.define(),Pg=Me.define(),KS=Me.define(),wn=zt.define({create(){return new Vs(je.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,s=t.panel;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);r=ao(n,t.selected.diagnostic,i)||ao(n,null,i)}!n.size&&s&&e.state.facet(za).autoPanel&&(s=null),t=new Vs(n,s,r)}for(let n of e.effects)if(n.is(US)){let r=e.state.facet(za).autoPanel?n.value.length?Va.open:null:t.panel;t=Vs.init(n.value,r,e.state)}else n.is(Pg)?t=new Vs(t.diagnostics,n.value?Va.open:null,t.selected):n.is(KS)&&(t=new Vs(t.diagnostics,t.panel,n.value));return t},provide:t=>[_a.from(t,e=>e.panel),ae.decorations.from(t,e=>e.diagnostics)]}),m7=je.mark({class:"cm-lintRange cm-lintRange-active"});function g7(t,e,n){let{diagnostics:r}=t.state.field(wn),s,i=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(l,d,{spec:u})=>{if(e>=l&&e<=d&&(l==d||(e>l||n>0)&&(e<d||n<0)))return s=u.diagnostics,i=l,o=d,!1});let a=t.state.facet(za).tooltipFilter;return s&&a&&(s=a(s,t.state)),s?{pos:i,end:o,above:t.state.doc.lineAt(i).to<o,create(){return{dom:x7(t,s)}}}:null}function x7(t,e){return Xe("ul",{class:"cm-tooltip-lint"},e.map(n=>qS(t,n,!1)))}const b7=t=>{let e=t.state.field(wn,!1);(!e||!e.panel)&&t.dispatch({effects:p7(t.state,[Pg.of(!0)])});let n=Ra(t,Va.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},Qb=t=>{let e=t.state.field(wn,!1);return!e||!e.panel?!1:(t.dispatch({effects:Pg.of(!1)}),!0)},y7=t=>{let e=t.state.field(wn,!1);if(!e)return!1;let n=t.state.selection.main,r=e.diagnostics.iter(n.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},v7=[{key:"Mod-Shift-m",run:b7,preventDefault:!0},{key:"F8",run:y7}],za=pe.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...Er(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Jb,tooltipFilter:Jb,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,s,i)=>e(r,s,i)||n(r,s,i):e:n,autoPanel:(e,n)=>e||n})}}});function Jb(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function GS(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let s=n[r];if(/[a-zA-Z]/.test(s)&&!e.some(i=>i.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function qS(t,e,n){var r;let s=n?GS(e.actions):[];return Xe("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Xe("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((i,o)=>{let a=!1,l=p=>{if(p.preventDefault(),a)return;a=!0;let m=ao(t.state.field(wn).diagnostics,e);m&&i.apply(t,m.from,m.to)},{name:d}=i,u=s[o]?d.indexOf(s[o]):-1,h=u<0?d:[d.slice(0,u),Xe("u",d.slice(u,u+1)),d.slice(u+1)],f=i.markClass?" "+i.markClass:"";return Xe("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:l,onmousedown:l,"aria-label":` Action: ${d}${u<0?"":` (access key "${s[o]})"`}.`},h)}),e.source&&Xe("div",{class:"cm-diagnosticSource"},e.source))}class w7 extends Dr{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Xe("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ey{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=qS(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Va{constructor(e){this.view=e,this.items=[];let n=s=>{if(s.keyCode==27)Qb(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:i}=this.items[this.selectedIndex],o=GS(i.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==s.keyCode){let l=ao(this.view.state.field(wn).diagnostics,i);l&&i.actions[a].apply(e,l.from,l.to)}}else return;s.preventDefault()},r=s=>{for(let i=0;i<this.items.length;i++)this.items[i].dom.contains(s.target)&&this.moveSelection(i)};this.list=Xe("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=Xe("div",{class:"cm-panel-lint"},this.list,Xe("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Qb(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(wn).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(wn),r=0,s=!1,i=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:d})=>{for(let u of d.diagnostics){if(o.has(u))continue;o.add(u);let h=-1,f;for(let p=r;p<this.items.length;p++)if(this.items[p].diagnostic==u){h=p;break}h<0?(f=new ey(this.view,u),this.items.splice(r,0,f),s=!0):(f=this.items[h],h>r&&(this.items.splice(r,h-r),s=!0)),n&&f.diagnostic==n.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),i=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new ey(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let d=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/d:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/d)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(wn),r=ao(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:KS.of(r)})}static open(e){return new Va(e)}}function k7(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Vc(t){return k7(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const S7=ae.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Vc("#d11")},".cm-lintRange-warning":{backgroundImage:Vc("orange")},".cm-lintRange-info":{backgroundImage:Vc("#999")},".cm-lintRange-hint":{backgroundImage:Vc("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function C7(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function j7(t){let e="hint",n=1;for(let r of t){let s=C7(r.severity);s>n&&(n=s,e=r.severity)}return e}const N7=[wn,ae.decorations.compute([wn],t=>{let{selected:e,panel:n}=t.field(wn);return!e||!n||e.from==e.to?je.none:je.set([m7.range(e.from,e.to)])}),DT(g7,{hideOn:f7}),S7];var ty=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,r=[];e.closeBracketsKeymap!==!1&&(r=r.concat(s7)),e.defaultKeymap!==!1&&(r=r.concat(ZL)),e.searchKeymap!==!1&&(r=r.concat(SR)),e.historyKeymap!==!1&&(r=r.concat(sL)),e.foldKeymap!==!1&&(r=r.concat(m6)),e.completionKeymap!==!1&&(r=r.concat(WS)),e.lintKeymap!==!1&&(r=r.concat(v7));var s=[];return e.lineNumbers!==!1&&s.push(zT()),e.highlightActiveLineGutter!==!1&&s.push(WT()),e.highlightSpecialChars!==!1&&s.push(iT()),e.history!==!1&&s.push(Y6()),e.foldGutter!==!1&&s.push(y6()),e.drawSelection!==!1&&s.push(qA()),e.dropCursor!==!1&&s.push(JA()),e.allowMultipleSelections!==!1&&s.push(Fe.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(i6()),e.syntaxHighlighting!==!1&&s.push(gg(S6,{fallback:!0})),e.bracketMatching!==!1&&s.push(D6()),e.closeBrackets!==!1&&s.push(e7()),e.autocompletion!==!1&&s.push(u7()),e.rectangularSelection!==!1&&s.push(yT()),n!==!1&&s.push(kT()),e.highlightActiveLine!==!1&&s.push(uT()),e.highlightSelectionMatches!==!1&&s.push(sR()),e.tabSize&&typeof e.tabSize=="number"&&s.push(Uu.of(" ".repeat(e.tabSize))),s.concat([Hu.of(r.flat())]).filter(Boolean)};const P7="#e5c07b",ny="#e06c75",O7="#56b6c2",E7="#ffffff",bd="#abb2bf",sm="#7d8799",D7="#61afef",M7="#98c379",ry="#d19a66",A7="#c678dd",T7="#21252b",sy="#2c313a",iy="#282c34",of="#353a42",L7="#3E4451",oy="#528bff",R7=ae.theme({"&":{color:bd,backgroundColor:iy},".cm-content":{caretColor:oy},".cm-cursor, .cm-dropCursor":{borderLeftColor:oy},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:L7},".cm-panels":{backgroundColor:T7,color:bd},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:iy,color:sm,border:"none"},".cm-activeLineGutter":{backgroundColor:sy},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:of},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:of,borderBottomColor:of},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:sy,color:bd}}},{dark:!0}),_7=wo.define([{tag:W.keyword,color:A7},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:ny},{tag:[W.function(W.variableName),W.labelName],color:D7},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:ry},{tag:[W.definition(W.name),W.separator],color:bd},{tag:[W.typeName,W.className,W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:P7},{tag:[W.operator,W.operatorKeyword,W.url,W.escape,W.regexp,W.link,W.special(W.string)],color:O7},{tag:[W.meta,W.comment],color:sm},{tag:W.strong,fontWeight:"bold"},{tag:W.emphasis,fontStyle:"italic"},{tag:W.strikethrough,textDecoration:"line-through"},{tag:W.link,color:sm,textDecoration:"underline"},{tag:W.heading,fontWeight:"bold",color:ny},{tag:[W.atom,W.bool,W.special(W.variableName)],color:ry},{tag:[W.processingInstruction,W.string,W.inserted],color:M7},{tag:W.invalid,color:E7}]),I7=[R7,gg(_7)];var $7=ae.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),B7=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:r=!0,readOnly:s=!1,theme:i="light",placeholder:o="",basicSetup:a=!0}=e,l=[];switch(n&&l.unshift(Hu.of([QL])),a&&(typeof a=="boolean"?l.unshift(ty()):l.unshift(ty(a))),o&&l.unshift(mT(o)),i){case"light":l.push($7);break;case"dark":l.push(I7);break;case"none":break;default:l.push(i);break}return r===!1&&l.push(ae.editable.of(!1)),s&&l.push(Fe.readOnly.of(!0)),[...l]},F7=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class z7{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(n=>{try{n()}catch(r){console.error("TimeoutLatch callback error:",r)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class ay{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var af=null,V7=()=>typeof window>"u"?new ay:(af||(af=new ay),af),ly=Or.define(),H7=200,W7=[];function U7(t){var{value:e,selection:n,onChange:r,onStatistics:s,onCreateEditor:i,onUpdate:o,extensions:a=W7,autoFocus:l,theme:d="light",height:u=null,minHeight:h=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:x=null,placeholder:b="",editable:y=!0,readOnly:k=!1,indentWithTab:v=!0,basicSetup:w=!0,root:C,initialState:j}=t,[S,P]=g.useState(),[D,A]=g.useState(),[N,T]=g.useState(),I=g.useState(()=>({current:null}))[0],O=g.useState(()=>({current:null}))[0],E=ae.theme({"&":{height:u,minHeight:h,maxHeight:f,width:p,minWidth:m,maxWidth:x},"& .cm-scroller":{height:"100% !important"}}),M=ae.updateListener.of($=>{if($.docChanged&&typeof r=="function"&&!$.transactions.some(V=>V.annotation(ly))){I.current?I.current.reset():(I.current=new z7(()=>{if(O.current){var V=O.current;O.current=null,V()}I.current=null},H7),V7().add(I.current));var F=$.state.doc,z=F.toString();r(z,$)}s&&s(F7($))}),R=B7({theme:d,editable:y,readOnly:k,placeholder:b,indentWithTab:v,basicSetup:w}),_=[M,E,...R];return o&&typeof o=="function"&&_.push(ae.updateListener.of(o)),_=_.concat(a),g.useLayoutEffect(()=>{if(S&&!N){var $={doc:e,selection:n,extensions:_},F=j?Fe.fromJSON(j.json,$,j.fields):Fe.create($);if(T(F),!D){var z=new ae({state:F,parent:S,root:C});A(z),i&&i(z,F)}}return()=>{D&&(T(void 0),A(void 0))}},[S,N]),g.useEffect(()=>{t.container&&P(t.container)},[t.container]),g.useEffect(()=>()=>{D&&(D.destroy(),A(void 0)),I.current&&(I.current.cancel(),I.current=null)},[D]),g.useEffect(()=>{l&&D&&D.focus()},[l,D]),g.useEffect(()=>{D&&D.dispatch({effects:Me.reconfigure.of(_)})},[d,a,u,h,f,p,m,x,b,y,k,v,w,r,o]),g.useEffect(()=>{if(e!==void 0){var $=D?D.state.doc.toString():"";if(D&&e!==$){var F=I.current&&!I.current.isDone,z=()=>{D&&e!==D.state.doc.toString()&&D.dispatch({changes:{from:0,to:D.state.doc.toString().length,insert:e||""},annotations:[ly.of(!0)]})};F?O.current=z:z()}}},[e,D]),{state:N,setState:T,view:D,setView:A,container:S,setContainer:P}}var K7=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],YS=g.forwardRef((t,e)=>{var{className:n,value:r="",selection:s,extensions:i=[],onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:d,autoFocus:u,theme:h="light",height:f,minHeight:p,maxHeight:m,width:x,minWidth:b,maxWidth:y,basicSetup:k,placeholder:v,indentWithTab:w,editable:C,readOnly:j,root:S,initialState:P}=t,D=B6(t,K7),A=g.useRef(null),{state:N,view:T,container:I,setContainer:O}=U7({root:S,value:r,autoFocus:u,theme:h,height:f,minHeight:p,maxHeight:m,width:x,minWidth:b,maxWidth:y,basicSetup:k,placeholder:v,indentWithTab:w,editable:C,readOnly:j,selection:s,onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:d,extensions:i,initialState:P});g.useImperativeHandle(e,()=>({editor:A.current,state:N,view:T}),[A,I,N,T]);var E=g.useCallback(R=>{A.current=R,O(R)},[O]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var M=typeof h=="string"?"cm-theme-"+h:"cm-theme";return c.jsx("div",Zp({ref:E,className:""+M+(n?" "+n:"")},D))});YS.displayName="CodeMirror";const G7=()=>{const t=ae.theme({"&":{backgroundColor:"var(--dash-surface)",color:"var(--dash-text)",height:"100%"},".cm-editor":{height:"100% !important"},".cm-content":{color:"var(--dash-text)",caretColor:"var(--dash-accent)",fontFamily:"'JetBrains Mono', Menlo, monospace",padding:"1rem"},".cm-line":{color:"var(--dash-text)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--dash-accent)"},"& ::selection":{backgroundColor:"var(--dash-accent-selection) !important",color:"inherit !important"},".cm-gutters":{backgroundColor:"var(--dash-surface)",color:"var(--dash-text-muted)",border:"none",borderRight:"1px solid var(--dash-border)",paddingRight:"0.5rem"},".cm-lineNumbers .cm-gutterElement":{padding:"0 0.5rem 0 1rem",minWidth:"3rem"},".cm-activeLineGutter":{backgroundColor:"var(--dash-accent-subtle)",color:"var(--dash-accent)",fontWeight:"600"},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--dash-accent) 8%, transparent)"},".cm-matchingBracket":{backgroundColor:"var(--dash-accent-subtle)",outline:"1px solid var(--dash-accent)"},".cm-scroller":{overflow:"auto !important",height:"100%",maxHeight:"100%"}}),e=wo.define([{tag:W.propertyName,color:"var(--dash-accent)"},{tag:W.string,color:"color-mix(in srgb, var(--dash-accent) 70%, var(--dash-text))"},{tag:W.number,color:"var(--dash-accent-hover)"},{tag:W.bool,color:"var(--dash-accent-hover)"},{tag:W.null,color:"var(--dash-text-muted)"},{tag:W.punctuation,color:"var(--dash-text-secondary)"},{tag:W.brace,color:"var(--dash-text-secondary)"},{tag:W.bracket,color:"var(--dash-text-secondary)"}]);return[t,gg(e)]},q7=({value:t,onChange:e,onCursorLineChange:n,onEditorFocus:r,height:s="100%",readOnly:i=!1,className:o})=>{const a=g.useMemo(()=>[$6(),ae.lineWrapping,...G7()],[]),l=g.useMemo(()=>{if(n)return d=>{const u=d.state.selection.main.head,h=d.view.state.doc.lineAt(u).number-1;n(h)}},[n]);return c.jsx("div",{className:`h-full [&_.cm-editor]:h-full [&_.cm-editor]:outline-none [&_.cm-focused]:outline-none ${o??""}`.trim(),children:c.jsx(YS,{value:t,height:s,extensions:a,onChange:e,onFocus:r,onUpdate:l,theme:"none",readOnly:i,basicSetup:{lineNumbers:!0,highlightActiveLineGutter:!0,highlightActiveLine:!0,foldGutter:!1,dropCursor:!0,drawSelection:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!1,rectangularSelection:!1,crosshairCursor:!1,highlightSelectionMatches:!0}})})},Og=({width:t,isLoading:e,jsonText:n,cursorLine:r,syntaxError:s,onChange:i,onEditorFocus:o,onCursorLineChange:a,readOnly:l=!1,headerTitle:d,headerPath:u,headerActions:h})=>{const{t:f}=ee(),p=m=>{if(l||!m.target.closest(".cm-editor"))return;const b=m.currentTarget;b.scrollHeight<=b.clientHeight||(b.scrollTop+=m.deltaY)};return c.jsxs("div",{style:{width:`${t}%`},className:"bg-dash-surface border border-dash-border rounded-xl overflow-hidden flex flex-col shadow-sm min-w-0 h-full",children:[c.jsx("div",{className:"p-3 border-b border-dash-border bg-dash-surface-hover/50 shrink-0",children:c.jsxs("div",{className:"flex items-end justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("h3",{className:"text-xs font-bold text-dash-text-secondary uppercase tracking-widest",children:d??f("jsonTab")}),u&&c.jsx("p",{className:"mt-1 mono text-[11px] text-dash-text-muted truncate",children:u})]}),h&&c.jsx("div",{className:"flex items-center gap-2 shrink-0",children:h})]})}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",onWheelCapture:p,children:e?c.jsx("div",{className:"h-full flex items-center justify-center",children:c.jsx("div",{className:"animate-pulse text-dash-text-muted text-sm",children:f("loading")})}):l?c.jsx("pre",{className:"h-full overflow-auto p-4 font-mono text-xs leading-4 text-dash-text whitespace-pre m-0",children:n}):c.jsx(q7,{value:n,onChange:i,onEditorFocus:o,onCursorLineChange:a,readOnly:l,className:"[&_.cm-content]:text-xs [&_.cm-content]:leading-4 [&_.cm-gutters]:text-xs [&_.cm-gutters]:leading-4"})}),c.jsxs("div",{className:"px-4 py-2 bg-dash-surface-hover/30 border-t border-dash-border text-[10px] text-dash-text-muted flex justify-between uppercase tracking-widest font-bold",children:[c.jsxs("div",{className:"flex gap-4",children:[c.jsx("span",{children:"UTF-8"}),c.jsx("span",{children:"JSON"}),c.jsxs("span",{children:["L:",r+1]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[l&&c.jsx("span",{children:f("readOnly")}),s?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),c.jsx("span",{className:"text-red-500 normal-case",children:s})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-dash-accent"}),f("syntaxValid")]})]})]})]})},cy=({label:t,value:e})=>c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-dash-bg border border-dash-border rounded-md",children:[c.jsxs("span",{className:"text-[9px] font-bold text-dash-text-muted uppercase",children:[t,":"]}),c.jsx("span",{className:"text-[10px] mono font-bold text-dash-text-secondary",children:e})]}),XS=({width:t,fieldDoc:e,activeFieldPath:n,extraContent:r,overrideBadge:s})=>{const{t:i,lang:o}=ee(),a=e??(n?Fw[n]??{path:n,type:"unknown",default:"n/a",description:"Help is being resolved for this field. Try editing the value or switching to the JSON view for schema-based details.",descriptionVi:"Đang tải trợ giúp cho trường này. Hãy thử chỉnh sửa giá trị hoặc chuyển sang chế độ JSON để xem mô tả suy ra từ schema."}:null);return c.jsxs("div",{style:{width:`${t}%`},className:"bg-dash-surface border border-dash-border rounded-xl flex flex-col shadow-sm overflow-hidden min-w-0",children:[c.jsx("div",{className:"p-3 border-b border-dash-border bg-dash-surface-hover/50 shrink-0",children:c.jsx("h3",{className:"text-xs font-bold text-dash-text-secondary uppercase tracking-widest",children:i("configurationHelp")})}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:a?c.jsxs("div",{className:"space-y-5 animate-in fade-in duration-500",children:[c.jsxs("header",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[c.jsx("span",{className:"text-[10px] bg-dash-accent-subtle text-dash-accent px-1.5 py-0.5 rounded font-mono uppercase font-bold",children:i("field")}),c.jsx("h2",{className:"text-base font-bold text-dash-text mono break-all",children:a.path}),s]}),c.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[c.jsx(cy,{label:i("type"),value:a.type}),c.jsx(cy,{label:i("default"),value:a.default})]})]}),c.jsxs("section",{children:[c.jsx("h4",{className:"text-[10px] font-bold text-dash-text-muted uppercase tracking-widest mb-2",children:i("description")}),c.jsx("p",{className:"text-sm text-dash-text-secondary leading-relaxed italic",children:o==="vi"?a.descriptionVi:a.description})]}),a.validValues&&c.jsxs("section",{children:[c.jsx("h4",{className:"text-[10px] font-bold text-dash-text-muted uppercase tracking-widest mb-2",children:i("validValues")}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.validValues.map(l=>c.jsx("span",{className:"px-2 py-0.5 bg-dash-bg border border-dash-border rounded text-[11px] mono text-dash-text",children:l},l))})]}),a.effect&&c.jsxs("section",{className:"bg-dash-accent-subtle/30 p-3 rounded-lg border border-dash-accent/10",children:[c.jsx("h4",{className:"text-[10px] font-bold text-dash-accent uppercase tracking-widest mb-1",children:i("systemEffect")}),c.jsx("p",{className:"text-[12px] text-dash-text-secondary leading-normal",children:o==="vi"&&a.effectVi?a.effectVi:a.effect})]}),a.example&&c.jsxs("section",{children:[c.jsx("h4",{className:"text-[10px] font-bold text-dash-text-muted uppercase tracking-widest mb-2",children:i("exampleUsage")}),c.jsx("div",{className:"bg-dash-bg p-3 rounded-lg border border-dash-border overflow-hidden",children:c.jsx("pre",{className:"text-[11px] mono text-dash-text-secondary whitespace-pre overflow-x-auto",children:a.example})})]}),r]}):c.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center opacity-40 space-y-4",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-dash-bg border border-dash-border flex items-center justify-center text-lg",children:"?"}),c.jsxs("div",{className:"max-w-[180px]",children:[c.jsx("p",{className:"text-sm font-bold text-dash-text mb-1 italic",children:i("knowledgeBase")}),c.jsx("p",{className:"text-xs text-dash-text-secondary",children:i("clickToSeeHelp")})]})]})}),a&&c.jsx("div",{className:"p-3 bg-dash-surface-hover/20 border-t border-dash-border shrink-0",children:c.jsxs("p",{className:"text-[10px] text-dash-text-muted font-medium flex items-center gap-1.5 italic",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),i("extractedFrom")]})})]})},Y7=({variant:t="development"})=>{const{t:e}=ee(),n={development:e("developmentFeature"),beta:e("betaFeature"),experimental:e("experimentalFeature")};return c.jsx("span",{className:"text-[9px] bg-orange-500/10 text-orange-500 px-2 py-0.5 rounded-full font-bold border border-orange-500/30 uppercase tracking-wider",children:n[t]})},dy={codex:{heavy:{model:"gpt-5.4",effort:"xhigh"},balanced:{model:"gpt-5.4",effort:"high"},light:{model:"gpt-5.4-mini",effort:"medium"}},"gemini-cli":{heavy:{model:"gemini-3.1-pro-preview"},balanced:{model:"gemini-3.1-pro-preview"},light:{model:"gemini-3-flash-preview"}}},X7={codex:"Codex","gemini-cli":"Gemini CLI"},uy=["heavy","balanced","light"];function hy(t,e){return e.split(".").reduce((n,r)=>{if(n!=null&&typeof n=="object"&&r in n)return n[r]},t)}const fy="bg-transparent border border-dash-border rounded px-2 py-1 text-sm text-dash-text placeholder:text-dash-text-muted focus:border-dash-accent focus:outline-none w-full",Z7=({config:t,onChange:e})=>{const{t:n}=ee(),[r,s]=g.useState(!1),i=(l,d,u,h)=>{const f=`modelTaxonomy.${l}.${d}.${u}`;e(f,h===""?void 0:h)},o=l=>{for(const d of uy)e(`modelTaxonomy.${l}.${d}.model`,void 0),dy[l]?.[d]?.effort!==void 0&&e(`modelTaxonomy.${l}.${d}.effort`,void 0)},a=l=>n(l==="heavy"?"taxonomyTierHeavy":l==="balanced"?"taxonomyTierBalanced":"taxonomyTierLight");return c.jsxs("div",{className:"bg-dash-surface border border-dash-border rounded-lg overflow-hidden flex flex-col h-full",children:[c.jsxs("button",{type:"button",onClick:()=>s(!r),className:"w-full flex items-center justify-between px-4 py-3 bg-dash-surface-hover/30 hover:bg-dash-surface-hover/50 transition-colors","aria-expanded":!r,"aria-controls":"section-model-taxonomy",children:[c.jsx("h3",{className:"text-sm font-bold text-dash-text uppercase tracking-wider",children:n("sectionModelTaxonomy")}),c.jsx("svg",{className:`w-4 h-4 text-dash-text-muted transition-transform duration-200 ${r?"":"rotate-180"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),!r&&c.jsx("div",{id:"section-model-taxonomy",className:"flex-1 overflow-y-auto min-h-0",children:c.jsxs("div",{className:"px-4 py-3 space-y-4",children:[c.jsx("p",{className:"text-xs text-dash-text-secondary",children:n("taxonomyDescription")}),Object.entries(dy).map(([l,d])=>{const u=Object.values(d).some(h=>h.effort!==void 0);return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-xs font-semibold text-dash-text uppercase tracking-wider",children:X7[l]??l}),c.jsx("button",{type:"button",onClick:()=>o(l),className:"text-xs text-dash-text-muted hover:text-dash-text px-2 py-0.5 rounded border border-dash-border hover:border-dash-accent transition-colors",children:n("taxonomyResetProvider")})]}),c.jsx("div",{className:"overflow-hidden rounded border border-dash-border",children:c.jsxs("table",{className:"w-full text-xs",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"bg-dash-surface-hover/40 border-b border-dash-border",children:[c.jsx("th",{className:"text-left px-3 py-2 text-dash-text-secondary font-medium w-1/4",children:n("taxonomyTier")}),c.jsx("th",{className:"text-left px-3 py-2 text-dash-text-secondary font-medium",children:n("taxonomyModel")}),u&&c.jsx("th",{className:"text-left px-3 py-2 text-dash-text-secondary font-medium w-1/4",children:n("taxonomyEffort")})]})}),c.jsx("tbody",{children:uy.map(h=>{const f=d[h],p=hy(t,`modelTaxonomy.${l}.${h}.model`),m=hy(t,`modelTaxonomy.${l}.${h}.effort`);return c.jsxs("tr",{className:"border-b border-dash-border last:border-0",children:[c.jsx("td",{className:"px-3 py-2 text-dash-text-secondary",children:a(h)}),c.jsx("td",{className:"px-3 py-2",children:c.jsx("input",{type:"text",className:fy,placeholder:f?.model??"",value:p??"",onChange:x=>i(l,h,"model",x.target.value)})}),u&&c.jsx("td",{className:"px-3 py-2",children:f?.effort!==void 0?c.jsx("input",{type:"text",className:fy,placeholder:f.effort,value:m??"",onChange:x=>i(l,h,"effort",x.target.value)}):null})]},h)})})]})})]},l)})]})})]})},Q7=(t,e)=>{const[n,r]=g.useState(null);return g.useEffect(()=>{const s=t.split(`
271
- `),i=[];let o=null;for(let a=0;a<=Math.min(e,s.length-1);a++){const l=s[a].trim(),d=l.match(/"([^"]+)"\s*:\s*{/);if(d){i.push(d[1]),a===e&&(o=i.join("."));continue}if(l==="}"||l==="},"){i.pop();continue}const u=l.match(/"([^"]+)"\s*:/);if(u){const h=u[1];if(a===e){o=i.length>0?`${i.join(".")}.${h}`:h;break}}}r(o)},[t,e]),n};function ZS(t){const{scope:e,fetchConfig:n,fetchSchema:r,saveConfig:s,onReset:i}=t,[o,a]=g.useState("{}"),[l,d]=g.useState(0),[u,h]=g.useState(null),[f,p]=g.useState(null),[m,x]=g.useState({}),[b,y]=g.useState({}),[k,v]=g.useState({}),[w,C]=g.useState(!0),[j,S]=g.useState(null),[P,D]=g.useState("idle"),[A,N]=g.useState(!1),[T,I]=g.useState(null),[O,E]=g.useState(null),M=Q7(o,l),R=fE(O,M),_=g.useMemo(()=>hE(R,f),[R,f]);g.useEffect(()=>{(async()=>{S(null);try{const[Q,se]=await Promise.all([n(),r()]),ce=Q.local??Q.config;x(ce),y(Q.global??{}),v(Q.sources),p(se),a(JSON.stringify(ce,null,2))}catch(Q){const se=Q instanceof Error?Q.message:String(Q);console.error("Failed to load config data:",Q),S(se)}finally{C(!1)}})()},[n,r]),g.useEffect(()=>{try{JSON.parse(o),h(null)}catch(U){h(U instanceof Error?U.message:"Invalid JSON")}},[o]),g.useEffect(()=>{if(T==="json")try{const U=JSON.parse(o);x(U)}catch{}},[o,T]);const $=g.useCallback(U=>{E(null),I("json"),a(U)},[]),F=g.useCallback(()=>{E(null)},[]),z=g.useCallback((U,Q)=>{E(U),I("form"),x(se=>{const ce=zw(se,U,Q);return a(JSON.stringify(ce,null,2)),ce}),v(se=>({...se,[U]:e}))},[e]),V=g.useCallback(async()=>{if(!u){D("saving");try{const U=JSON.parse(o),se=await s(U)??U;x(se),a(JSON.stringify(se,null,2)),D("saved"),setTimeout(()=>D("idle"),2e3)}catch{D("error"),setTimeout(()=>D("idle"),3e3)}}},[o,u,s]),Z=g.useCallback(async()=>{if(N(!1),i){C(!0);try{const U=await i(),Q=U.local??U.config;x(Q),v(U.sources),a(JSON.stringify(Q,null,2))}catch(U){console.error("Failed to reset:",U)}finally{C(!1)}}else{const U={};x(U),a(JSON.stringify(U,null,2))}},[i]);return{jsonText:o,config:m,globalConfig:b,sources:k,schema:f,isLoading:w,loadError:j,saveStatus:P,syntaxError:u,cursorLine:l,showResetConfirm:A,activeFieldPath:R,fieldDoc:_,handleJsonChange:$,handleJsonEditorFocus:F,handleFormChange:z,handleSave:V,handleReset:Z,setCursorLine:d,setFocusedFieldPath:E,setShowResetConfirm:N}}function Eg({storageKey:t,defaultSizes:e,minSizes:n}){const[r,s]=g.useState(()=>{if(typeof window>"u")return e;const d=localStorage.getItem(t);if(d)try{const u=JSON.parse(d);if(Array.isArray(u)&&u.length===e.length){const h=u.reduce((f,p)=>f+p,0);if(Math.abs(h-100)<1)return u}}catch{}return e}),[i,o]=g.useState(!1);g.useEffect(()=>{localStorage.setItem(t,JSON.stringify(r))},[r,t]);const a=g.useCallback((d,u)=>{u.preventDefault(),o(!0);let h=u.currentTarget.parentElement;for(;h&&getComputedStyle(h).display!=="flex";)h=h.parentElement;if(!h)return;const p=h.getBoundingClientRect().width,m=u.clientX,x=[...r],b=k=>{const w=(k.clientX-m)/p*100,C=[...x],j=d,S=d+1;let P=x[j]+w,D=x[S]-w;P<n[j]&&(P=n[j],D=x[j]+x[S]-P),D<n[S]&&(D=n[S],P=x[j]+x[S]-D),C[j]=P,C[S]=D,s(C)},y=()=>{o(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",b),document.addEventListener("mouseup",y),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[r,n]),l=g.useCallback(()=>{s(e)},[e]);return{sizes:r,isDragging:i,startDrag:a,reset:l}}function J7(t,e,n,r){const[s,i]=g.useState(()=>{if(typeof window>"u")return e;const d=localStorage.getItem(t);if(d){const u=Number.parseFloat(d);if(!Number.isNaN(u)&&u>=n&&u<=100-r)return u}return e}),[o,a]=g.useState(!1),l=g.useCallback(d=>{d.preventDefault(),a(!0);const u=d.target.closest("[data-vresize-container]");if(!u)return;const h=p=>{const m=u.getBoundingClientRect(),x=(p.clientY-m.top)/m.height*100;i(Math.max(n,Math.min(100-r,x)))},f=()=>{a(!1),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",f),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",h),document.addEventListener("mouseup",f),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[n,r]);return g.useEffect(()=>{localStorage.setItem(t,String(s))},[t,s]),{topPct:s,isDragging:o,startDrag:l}}const e8=()=>{const{t}=ee(),e=Ft(),{sizes:n,isDragging:r,startDrag:s}=Eg({storageKey:"claudekit-global-config-panels",defaultSizes:[35,40,25],minSizes:[20,25,15]}),i=J7("claudekit-form-taxonomy-split",70,25,15),o=g.useCallback(async()=>await ux(),[]),a=g.useCallback(async f=>{await Ww({scope:"global",config:f})},[]),l=g.useCallback(async()=>await ux(),[]),d=ZS({scope:"global",fetchConfig:o,fetchSchema:Uw,saveConfig:a,onReset:l}),u=g.useMemo(()=>[{id:"general",title:t("sectionGeneral"),fields:[{path:"codingLevel",label:t("fieldCodingLevel"),description:t("fieldCodingLevelDesc")},{path:"statusline",label:t("fieldStatusline"),description:t("fieldStatuslineDesc")},{path:"statuslineColors",label:t("fieldStatuslineColors"),description:t("fieldStatuslineColorsDesc")},{path:"locale.thinkingLanguage",label:t("fieldThinkingLanguage"),description:t("fieldThinkingLanguageDesc")},{path:"locale.responseLanguage",label:t("fieldResponseLanguage"),description:t("fieldResponseLanguageDesc")}]},{id:"paths",title:t("sectionPaths"),fields:[{path:"paths.docs",label:t("fieldDocsPath"),description:t("fieldDocsPathDesc")},{path:"paths.plans",label:t("fieldPlansPath"),description:t("fieldPlansPathDesc")},{path:"paths.globalPlans",label:t("fieldGlobalPlansPath"),description:t("fieldGlobalPlansPathDesc")}]},{id:"privacy",title:t("sectionPrivacy"),defaultCollapsed:!0,fields:[{path:"privacyBlock",label:t("fieldPrivacyBlock"),description:t("fieldPrivacyBlockDesc")},{path:"trust.enabled",label:t("fieldTrustEnabled"),description:t("fieldTrustEnabledDesc")},{path:"trust.passphrase",label:t("fieldTrustPassphrase"),description:t("fieldTrustPassphraseDesc")}]},{id:"project",title:t("sectionProject"),defaultCollapsed:!0,fields:[{path:"project.type",label:t("fieldProjectType"),description:t("fieldProjectTypeDesc")},{path:"project.packageManager",label:t("fieldPackageManager"),description:t("fieldPackageManagerDesc")},{path:"project.framework",label:t("fieldFramework"),description:t("fieldFrameworkDesc")}]},{id:"integrations",title:t("sectionIntegrations"),defaultCollapsed:!0,fields:[{path:"gemini.model",label:t("fieldGeminiModel"),description:t("fieldGeminiModelDesc")},{path:"skills.research.useGemini",label:t("fieldResearchUseGemini"),description:t("fieldResearchUseGeminiDesc")}]},{id:"hooks",title:t("sectionHooks"),defaultCollapsed:!0,fields:[{path:"hooks.session-init",label:t("fieldHookSessionInit"),description:t("fieldHookSessionInitDesc")},{path:"hooks.subagent-init",label:t("fieldHookSubagentInit"),description:t("fieldHookSubagentInitDesc")},{path:"hooks.descriptive-name",label:t("fieldHookDescriptiveName"),description:t("fieldHookDescriptiveNameDesc")},{path:"hooks.dev-rules-reminder",label:t("fieldHookDevRulesReminder"),description:t("fieldHookDevRulesReminderDesc")},{path:"hooks.usage-context-awareness",label:t("fieldHookUsageContextAwareness"),description:t("fieldHookUsageContextAwarenessDesc")},{path:"hooks.context-tracking",label:t("fieldHookContextTracking"),description:t("fieldHookContextTrackingDesc")},{path:"hooks.scout-block",label:t("fieldHookScoutBlock"),description:t("fieldHookScoutBlockDesc")},{path:"hooks.privacy-block",label:t("fieldHookPrivacyBlock"),description:t("fieldHookPrivacyBlockDesc")},{path:"hooks.simplify-gate",label:t("fieldHookSimplifyGate"),description:t("fieldHookSimplifyGateDesc")}]},{id:"simplify",title:t("sectionSimplify"),defaultCollapsed:!0,fields:[{path:"simplify.threshold.locDelta",label:t("fieldSimplifyThresholdLocDelta"),description:t("fieldSimplifyThresholdLocDeltaDesc")},{path:"simplify.threshold.fileCount",label:t("fieldSimplifyThresholdFileCount"),description:t("fieldSimplifyThresholdFileCountDesc")},{path:"simplify.threshold.singleFileLoc",label:t("fieldSimplifyThresholdSingleFileLoc"),description:t("fieldSimplifyThresholdSingleFileLocDesc")},{path:"simplify.gate.enabled",label:t("fieldSimplifyGateEnabled"),description:t("fieldSimplifyGateEnabledDesc")},{path:"simplify.gate.hardVerbs",label:t("fieldSimplifyGateHardVerbs"),description:t("fieldSimplifyGateHardVerbsDesc")},{path:"simplify.gate.softVerbs",label:t("fieldSimplifyGateSoftVerbs"),description:t("fieldSimplifyGateSoftVerbsDesc")}]},{id:"advanced",title:t("sectionAdvanced"),defaultCollapsed:!0,fields:[{path:"docs.maxLoc",label:t("fieldDocsMaxLoc"),description:t("fieldDocsMaxLocDesc")},{path:"plan.namingFormat",label:t("fieldPlanNamingFormat"),description:t("fieldPlanNamingFormatDesc")},{path:"plan.dateFormat",label:t("fieldPlanDateFormat"),description:t("fieldPlanDateFormatDesc")},{path:"plan.validation.mode",label:t("fieldPlanValidationMode"),description:t("fieldPlanValidationModeDesc")},{path:"plan.validation.minQuestions",label:t("fieldPlanMinQuestions"),description:t("fieldPlanMinQuestionsDesc")},{path:"plan.validation.maxQuestions",label:t("fieldPlanMaxQuestions"),description:t("fieldPlanMaxQuestionsDesc")},{path:"assertions",label:t("fieldAssertions"),description:t("fieldAssertionsDesc")}]}],[t]),h=d.showResetConfirm?c.jsxs("div",{className:"flex items-center gap-2 bg-red-500/10 border border-red-500/30 rounded-lg px-2 py-1 animate-in fade-in duration-200",children:[c.jsx("span",{className:"text-xs text-red-500 font-medium",children:t("confirmReset")}),c.jsx("button",{type:"button",onClick:d.handleReset,className:"px-2 py-0.5 rounded bg-red-500 text-white text-xs font-bold hover:bg-red-600 transition-colors",children:t("confirm")}),c.jsx("button",{type:"button",onClick:()=>d.setShowResetConfirm(!1),className:"px-2 py-0.5 rounded bg-dash-surface text-dash-text-secondary text-xs font-bold hover:bg-dash-surface-hover transition-colors border border-dash-border",children:t("cancel")})]}):c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",onClick:()=>d.setShowResetConfirm(!0),className:"px-3 py-1.5 rounded-lg bg-dash-surface text-xs font-bold text-dash-text-secondary hover:bg-dash-surface-hover transition-colors border border-dash-border",children:t("resetToDefault")}),c.jsx("button",{type:"button",onClick:d.handleSave,disabled:!!d.syntaxError||d.saveStatus==="saving",className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all tracking-widest uppercase ${d.syntaxError?"bg-dash-surface text-dash-text-muted cursor-not-allowed border border-dash-border":d.saveStatus==="saved"?"bg-green-500 text-white shadow-lg shadow-green-500/20":d.saveStatus==="error"?"bg-red-500 text-white":"bg-dash-accent text-dash-bg hover:bg-dash-accent-hover shadow-lg shadow-dash-accent/20"}`,children:d.saveStatus==="saving"?t("saving"):d.saveStatus==="saved"?t("saved"):d.saveStatus==="error"?t("saveFailed"):t("saveChanges")})]});return c.jsxs("div",{className:"animate-in fade-in duration-300 w-full h-full flex flex-col transition-colors",children:[c.jsx(ek,{title:t("globalConfig"),filePath:"~/.claude/.ck.json",onBack:()=>e(-1),onSave:d.handleSave,onReset:d.handleReset,saveStatus:d.saveStatus,syntaxError:d.syntaxError,showResetConfirm:d.showResetConfirm,setShowResetConfirm:d.setShowResetConfirm,showActions:!1,showFilePath:!1}),!d.isLoading&&d.loadError&&c.jsxs("div",{className:"mx-4 mt-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30 text-xs text-red-500",children:[c.jsx("p",{className:"font-medium",children:t("configLoadFailed")}),c.jsxs("p",{className:"mt-1 break-words",children:[t("configLoadFailedDetail")," ",d.loadError]})]}),c.jsx("div",{className:"flex-1 flex min-h-0",children:c.jsxs(c.Fragment,{children:[c.jsxs("div",{"data-vresize-container":!0,style:{width:`${n[0]}%`},className:"flex flex-col min-w-0 min-h-0",children:[c.jsx("div",{style:{height:`${d.isLoading?100:i.topPct}%`},className:"min-h-0",children:c.jsx(tk,{width:100,isLoading:d.isLoading,schema:d.schema,config:d.config,sources:d.sources,sections:u,onChange:d.handleFormChange})}),!d.isLoading&&c.jsxs(c.Fragment,{children:[c.jsx(_n,{direction:"vertical",isDragging:i.isDragging,onMouseDown:i.startDrag}),c.jsx("div",{style:{height:`${100-i.topPct}%`},className:"min-h-0",children:c.jsx(Z7,{config:d.config,onChange:d.handleFormChange})})]})]}),c.jsx(_n,{direction:"horizontal",isDragging:r,onMouseDown:f=>s(0,f)}),c.jsx(Og,{width:n[1],isLoading:d.isLoading,jsonText:d.jsonText,cursorLine:d.cursorLine,syntaxError:d.syntaxError,onChange:d.handleJsonChange,onCursorLineChange:d.setCursorLine,headerPath:"~/.claude/.ck.json",headerActions:h}),c.jsx(_n,{direction:"horizontal",isDragging:r,onMouseDown:f=>s(1,f)}),c.jsx(XS,{width:n[2],fieldDoc:d.fieldDoc,activeFieldPath:d.activeFieldPath})]})})]})};function t8(t){const e=t.replace(/\\/g,"/"),n=e.split("/").filter(Boolean);return n.length<3?null:`${e.startsWith("/")?"/":""}${n.slice(0,-2).join("/")}`}function n8(){const[t]=Hl(),e=t.get("projectId"),n=t.get("file"),r=n?t8(n):null,s=new URLSearchParams;return r&&(s.set("dir",r),s.set("view","kanban"),e&&s.set("projectId",e)),c.jsx(gw,{replace:!0,to:r?`/plans?${s.toString()}`:"/plans"})}function r8(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[s,i]=g.useState(null),o=g.useCallback(async()=>{try{if(r(!0),i(null),nt()){const d=await gP();e(d.map(u=>({name:u.name,command:u.command,args:u.args,source:u.source,sourceLabel:u.sourceLabel})));return}const a=await fetch("/api/mcp-servers");if(!a.ok)throw new Error(`Failed to fetch MCP servers: ${a.status}`);const l=await a.json();e(l.servers??[])}catch(a){i(a instanceof Error?a.message:"Failed to load MCP servers"),e([])}finally{r(!1)}},[]);return g.useEffect(()=>{o()},[o]),{servers:t,loading:n,error:s,reload:o}}function s8(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-3.5 h-3.5 shrink-0 text-dash-accent",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h14M12 5l7 7-7 7"})})}function i8({label:t,count:e}){return c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[c.jsx("span",{className:"text-xs font-bold text-dash-text-muted uppercase tracking-wider flex-1",children:t}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold",children:e})]})}function o8({server:t,selected:e,onClick:n}){return c.jsxs("button",{type:"button",onClick:n,className:["w-full flex items-start gap-2 px-3 py-2 rounded-md transition-colors text-left group",e?"bg-dash-accent/10 border border-dash-accent/30":"hover:bg-dash-surface-hover border border-transparent"].join(" "),children:[c.jsx(s8,{}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"text-sm font-semibold text-dash-accent font-mono",children:t.name}),c.jsx("p",{className:"text-xs text-dash-text-muted mt-0.5 truncate font-mono",children:t.command})]})]})}function a8({server:t}){const{t:e}=ee();return c.jsxs("div",{className:"flex flex-col gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("h2",{className:"text-base font-semibold text-dash-text font-mono truncate flex-1",children:t.name}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold shrink-0",children:e("sessionReadOnly")})]}),c.jsx("div",{className:"flex items-center gap-2 text-xs text-dash-text-muted",children:c.jsx("span",{className:"font-mono px-2 py-0.5 rounded bg-dash-surface border border-dash-border text-dash-accent",children:t.sourceLabel})}),c.jsx("div",{className:"rounded-lg border border-dash-border bg-dash-surface p-5 overflow-x-auto",children:c.jsx("table",{className:"w-full text-sm",children:c.jsxs("tbody",{children:[c.jsxs("tr",{className:"border-b border-dash-border",children:[c.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-dash-text-muted w-28 shrink-0 align-top",children:e("mcpCommand")}),c.jsx("td",{className:"py-2 font-mono text-xs text-dash-text break-all",children:t.command})]}),t.args.length>0&&c.jsxs("tr",{className:"border-b border-dash-border",children:[c.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-dash-text-muted w-28 align-top",children:e("mcpArgs")}),c.jsx("td",{className:"py-2 text-xs text-dash-text",children:c.jsx("div",{className:"flex flex-col gap-1",children:t.args.map((n,r)=>c.jsx("code",{className:"font-mono bg-dash-surface border border-dash-border rounded px-1.5 py-0.5 text-[11px] break-all",children:n},r))})})]}),t.env&&Object.keys(t.env).length>0&&c.jsxs("tr",{className:"border-b border-dash-border",children:[c.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-dash-text-muted w-28 align-top",children:"env"}),c.jsx("td",{className:"py-2 text-xs text-dash-text",children:c.jsx("div",{className:"flex flex-col gap-1",children:Object.keys(t.env).map(n=>c.jsxs("code",{className:"font-mono bg-dash-surface border border-dash-border rounded px-1.5 py-0.5 text-[11px]",children:[n,"=",c.jsx("span",{className:"text-dash-text-muted",children:"***"})]},n))})})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-dash-text-muted w-28 align-top",children:e("mcpSource")}),c.jsx("td",{className:"py-2 text-xs text-dash-text font-mono",children:t.sourceLabel})]})]})})})]})}const l8=({message:t})=>c.jsx("div",{className:"flex items-center justify-center h-full text-sm text-dash-text-muted",children:t}),c8=()=>{const{t}=ee(),{servers:e,loading:n,error:r}=r8(),[s,i]=g.useState(""),[o,a]=g.useState(null),{size:l,isDragging:d,startDrag:u}=yo({storageKey:"ck-mcp-panel-width",defaultSize:380,minSize:260,maxSize:650}),h=x=>`${x.source}-${x.name}`,f=e.find(x=>h(x)===o)??null,p=g.useMemo(()=>{if(!s.trim())return e;const x=s.toLowerCase();return e.filter(b=>b.name.toLowerCase().includes(x)||b.command.toLowerCase().includes(x)||b.sourceLabel.toLowerCase().includes(x))},[e,s]),m=g.useMemo(()=>{const x=new Map;for(const b of p){const y=x.get(b.sourceLabel)??[];y.push(b),x.set(b.sourceLabel,y)}return x},[p]);return c.jsxs("div",{className:"flex h-full overflow-hidden",children:[c.jsxs("div",{style:{width:`${l}px`},className:"shrink-0 flex flex-col overflow-hidden border-r border-dash-border",children:[c.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-3 border-b border-dash-border",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-base font-bold text-dash-text",children:t("mcpTitle")}),!n&&!r&&c.jsx("p",{className:"text-xs text-dash-text-muted mt-0.5",children:e.length===0?t("mcpNoServers"):`${e.length} ${e.length===1?"server":"servers"} configured`}),c.jsx("p",{className:"text-[11px] text-dash-text-muted font-mono mt-0.5",children:"~/.claude.json + settings.json + .mcp.json"})]}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold shrink-0",children:t("sessionReadOnly")})]}),c.jsxs("div",{className:"relative",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-dash-text-muted pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),c.jsx("input",{type:"text",value:s,onChange:x=>i(x.target.value),placeholder:t("mcpServerName"),className:"w-full pl-9 pr-4 py-2 text-sm bg-dash-surface border border-dash-border rounded-lg text-dash-text placeholder:text-dash-text-muted focus:outline-none focus:border-dash-accent/50 transition-colors"}),s&&c.jsx("button",{type:"button",onClick:()=>i(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-dash-text-muted hover:text-dash-text transition-colors",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[n&&c.jsx("div",{className:"flex flex-1 items-center justify-center text-dash-text-muted text-sm p-8",children:t("loading")}),!n&&r&&c.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 dark:bg-red-900/20 p-4 text-red-600 dark:text-red-400 text-sm m-2",children:r}),!n&&!r&&m.size===0&&c.jsx("div",{className:"flex items-center justify-center p-8 text-dash-text-muted text-sm",children:t("mcpNoServers")}),!n&&!r&&m.size>0&&c.jsx("div",{className:"flex flex-col gap-2 pb-4",children:Array.from(m.entries()).map(([x,b])=>c.jsxs("div",{children:[m.size>1&&c.jsx(i8,{label:x,count:b.length}),c.jsx("div",{className:"space-y-0.5",children:b.map(y=>{const k=h(y);return c.jsx(o8,{server:y,selected:o===k,onClick:()=>a(k)},k)})})]},x))})]})]}),c.jsx(_n,{onMouseDown:u,isDragging:d,direction:"horizontal"}),c.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:f?c.jsx(a8,{server:f}):c.jsx(l8,{message:t("selectToView")})})]})},Ju=({titleKey:t,descriptionKey:e,commandHintKey:n})=>{const{t:r}=ee();return c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsxs("div",{className:"max-w-xl rounded-2xl border border-dash-border bg-dash-surface p-8 text-center shadow-sm",children:[c.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] text-dash-accent",children:r("desktopModeLabel")}),c.jsx("h2",{className:"mt-3 text-xl font-semibold text-dash-text",children:r(t)}),c.jsx("p",{className:"mt-3 text-sm leading-relaxed text-dash-text-muted",children:r(e)}),n&&c.jsx("p",{className:"mt-4 rounded-lg border border-dash-border bg-dash-bg px-4 py-3 text-xs font-medium text-dash-text",children:r(n)})]})})};function Ha(t){return`${t.provider}::${t.type}::${t.item}::${String(t.global)}`}const d8=["agent","command","skill","config","rules","hooks"],u8={agent:"migrateTypeAgents",command:"migrateTypeCommands",skill:"migrateTypeSkills",config:"migrateTypeConfig",rules:"migrateTypeRules",hooks:"migrateTypeHooks"},h8={agent:"border-dash-accent/30 text-dash-accent",command:"border-yellow-500/30 text-yellow-400",skill:"border-purple-500/30 text-purple-400",config:"border-teal-500/30 text-teal-400",rules:"border-rose-500/30 text-rose-400",hooks:"border-cyan-500/30 text-cyan-400"},f8=({type:t,candidates:e,selected:n,onToggleItem:r,onSelectAll:s,onDeselectAll:i})=>{const{t:o}=ee(),a=g.useMemo(()=>e.map(Ha),[e]),l=a.filter(f=>n.has(f)).length,d=l===a.length,u=h8[t],h=o(u8[t]);return c.jsxs("div",{className:"border border-dash-border rounded-lg bg-dash-surface overflow-hidden",children:[c.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between border-b border-dash-border bg-dash-bg",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h4",{className:"text-sm font-semibold text-dash-text",children:h}),c.jsxs("span",{className:`px-2 py-0.5 text-xs rounded-md border ${u}`,children:[l,"/",e.length]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",onClick:()=>s(a),disabled:d,className:"dash-focus-ring px-2.5 py-1 text-[11px] rounded border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover disabled:opacity-40",children:o("migrateInstallSelectAll")}),c.jsx("button",{type:"button",onClick:()=>i(a),disabled:l===0,className:"dash-focus-ring px-2.5 py-1 text-[11px] rounded border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover disabled:opacity-40",children:o("migrateInstallDeselectAll")})]})]}),c.jsx("div",{className:"divide-y divide-dash-border/50",children:e.map(f=>{const p=Ha(f),m=n.has(p);return c.jsxs("label",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-dash-surface-hover cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:m,onChange:()=>r(p),className:"h-4 w-4 rounded border-dash-border accent-dash-accent","aria-label":`${f.item} from ${f.provider}`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsx("span",{className:"text-sm font-mono text-dash-text truncate",children:f.item}),f.isDirectoryItem&&c.jsx("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded border border-purple-500/30 text-purple-400",children:o("migrateInstallDirItem")}),f.alreadyInstalled&&c.jsx("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded border border-dash-border text-dash-text-muted",children:o("migrateInstallAlreadyInstalled")})]}),c.jsx("div",{className:"text-[11px] text-dash-text-muted mt-0.5",children:f.provider})]}),f.description&&c.jsx("p",{className:"hidden md:block text-xs text-dash-text-secondary max-w-[200px] truncate shrink-0",children:f.description})]},p)})})]})},p8=({candidates:t,selected:e,onSelectionChange:n,onInstall:r,isInstalling:s=!1})=>{const{t:i}=ee(),o=g.useMemo(()=>{const p=new Map;for(const m of t){const x=p.get(m.type)??[];x.push(m),p.set(m.type,x)}return d8.filter(m=>(p.get(m)?.length??0)>0).map(m=>({type:m,candidates:p.get(m)??[]}))},[t]),a=g.useMemo(()=>t.map(Ha),[t]),l=g.useCallback(p=>{const m=new Set(e);m.has(p)?m.delete(p):m.add(p),n(m)},[e,n]),d=g.useCallback(p=>{const m=new Set(e);for(const x of p)m.add(x);n(m)},[e,n]),u=g.useCallback(p=>{const m=new Set(e);for(const x of p)m.delete(x);n(m)},[e,n]),h=g.useCallback(()=>{n(new Set(a))},[a,n]),f=g.useCallback(()=>{n(new Set)},[n]);return t.length===0?c.jsx("div",{className:"dash-panel p-8 text-center",children:c.jsx("p",{className:"text-dash-text-muted text-sm",children:i("migrateInstallNoCandidates")})}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[c.jsx("p",{className:"text-sm text-dash-text-secondary",children:i("migrateInstallSelectedCount").replace("{count}",String(e.size)).replace("{total}",String(t.length))}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",onClick:h,disabled:e.size===t.length,className:"dash-focus-ring px-3 py-1.5 text-xs rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover disabled:opacity-40",children:i("migrateInstallSelectAll")}),c.jsx("button",{type:"button",onClick:f,disabled:e.size===0,className:"dash-focus-ring px-3 py-1.5 text-xs rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover disabled:opacity-40",children:i("migrateInstallDeselectAll")})]})]}),o.map(({type:p,candidates:m})=>c.jsx(f8,{type:p,candidates:m,selected:e,onToggleItem:l,onSelectAll:d,onDeselectAll:u},p)),c.jsx("div",{className:"flex items-center justify-end pt-2",children:c.jsx("button",{type:"button",disabled:e.size===0||s,onClick:()=>r(e),className:"dash-focus-ring px-6 py-2.5 bg-dash-accent text-white rounded-md text-sm font-semibold hover:bg-dash-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:s?i("migrateInstallInstalling"):i("migrateInstallCta").replace("{count}",String(e.size))})})]})};function m8(t){return new Set(t.map(Ha))}function g8(t,e){const r=t.filter(s=>e.has(Ha(s))).map(s=>({action:"install",item:s.item,type:s.type,provider:s.provider,global:s.global,targetPath:s.registryPath??s.sourcePath,reason:"User-selected install",reasonCode:"new-item",isDirectoryItem:s.isDirectoryItem}));return{actions:r,summary:{install:r.length,update:0,skip:0,conflict:0,delete:0},hasConflicts:!1,banners:[]}}const py=[{key:"agent",labelKey:"migrateTypeAgents",badgeClass:"border-dash-accent/30 text-dash-accent"},{key:"command",labelKey:"migrateTypeCommands",badgeClass:"border-yellow-500/30 text-yellow-400"},{key:"skill",labelKey:"migrateTypeSkills",badgeClass:"border-purple-500/30 text-purple-400"},{key:"config",labelKey:"migrateTypeConfig",badgeClass:"border-teal-500/30 text-teal-400"},{key:"rules",labelKey:"migrateTypeRules",badgeClass:"border-rose-500/30 text-rose-400"},{key:"hooks",labelKey:"migrateTypeHooks",badgeClass:"border-cyan-500/30 text-cyan-400"}],x8=new Set([8203,8204,8205,8288,65279,8232,8233,8234,8235,8236,8237,8238,8294,8295,8296,8297]);function b8(t){return t===9||t===10||t===13?!0:t>=0&&t<=8||t>=11&&t<=31||t>=127&&t<=159||x8.has(t)}function Hs(t){let e="";for(const n of t){const r=n.codePointAt(0);r!==void 0&&(b8(r)||(e+=n))}return e}function my(t){if(!t)return"-";const e=t.replace(/\\/g,"/"),n=e.match(/.*\/(\.[^/]+\/)/);if(n?.[1]){const s=(n.index??0)+n[0].length-n[1].length;return e.slice(s)}const r=e.split("/");return r.length>3?`.../${r.slice(-3).join("/")}`:e}function Ai(t){return t.success?t.skipped?"skipped":"installed":"failed"}function y8(t){const e={installed:0,skipped:0,failed:0};for(const n of t){const r=Ai(n);r==="installed"?e.installed+=1:r==="skipped"?e.skipped+=1:e.failed+=1}return e}function QS(t){switch(t){case"agent":case"command":case"skill":case"config":case"rules":case"hooks":case"unknown":return t;default:return"unknown"}}function v8(t,e){switch(t){case"failed":return{label:e("migrateStatusFailed"),className:"border-red-500/30 bg-red-500/10 text-red-400"};case"skipped":return{label:e("migrateStatusSkipped"),className:"border-yellow-500/30 bg-yellow-500/10 text-yellow-400"};default:return{label:e("migrateStatusInstalled"),className:"border-green-500/30 bg-green-500/10 text-green-400"}}}function w8(t){const e=new Map;for(const n of t){const r=QS(n.portableType),s=e.get(r)||[];s.push(n),e.set(r,s)}return e}function k8(t){return[QS(t.portableType),t.provider,t.providerDisplayName,t.itemName,t.path,t.success,t.skipped,t.overwritten,t.error,t.skipReason].map(n=>n===void 0?"":String(n)).join("|")}function S8(t){if(t.length===0)return!0;const e=t[0].provider;return t.every(n=>n.provider===e)}const Wi=({label:t,count:e,className:n})=>e<=0?null:c.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-2.5 py-1 text-xs ${n}`,children:[c.jsx("span",{className:"font-semibold",children:e}),c.jsx("span",{children:t})]}),gy=({labelKey:t,badgeClass:e,items:n,isExpanded:r,onToggle:s,singleProvider:i})=>{const{t:o}=ee(),a=n.filter(f=>Ai(f)==="installed").length,l=n.filter(f=>Ai(f)==="skipped").length,d=n.filter(f=>Ai(f)==="failed").length,u=i?"md:grid-cols-[minmax(0,1.5fr)_minmax(0,1.35fr)_auto_minmax(0,1fr)]":"md:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)_minmax(0,1.2fr)_auto_minmax(0,1fr)]",h=new Map;return c.jsxs("div",{className:"rounded-xl border border-dash-border bg-dash-surface overflow-hidden",children:[c.jsxs("button",{type:"button",onClick:s,className:"w-full flex flex-wrap items-center gap-2 px-4 py-3 text-left hover:bg-dash-surface-hover transition-colors",children:[c.jsx("svg",{className:`w-3.5 h-3.5 text-dash-text-muted transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c.jsx("path",{d:"M9 5l7 7-7 7"})}),c.jsx("p",{className:"text-sm font-semibold text-dash-text",children:o(t)}),c.jsx("span",{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-semibold ${e}`,children:n.length}),c.jsx("span",{className:"hidden sm:block flex-1"}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px]",children:[c.jsx(Wi,{label:o("migrateStatusInstalled"),count:a,className:"border-green-500/30 bg-green-500/10 text-green-400"}),c.jsx(Wi,{label:o("migrateStatusSkipped"),count:l,className:"border-yellow-500/30 bg-yellow-500/10 text-yellow-400"}),c.jsx(Wi,{label:o("migrateStatusFailed"),count:d,className:"border-red-500/30 bg-red-500/10 text-red-400"})]})]}),r&&c.jsxs("div",{className:"border-t border-dash-border/80",children:[c.jsxs("div",{className:`hidden md:grid ${u} items-center gap-3 px-4 py-2 border-b border-dash-border/70 text-[10px] font-semibold uppercase tracking-wide text-dash-text-muted`,children:[c.jsx("p",{children:o("migrateItem")}),!i&&c.jsx("p",{children:o("migrateProvider")}),c.jsx("p",{children:o("migratePath")}),c.jsx("p",{children:o("migrateStatus")}),c.jsx("p",{children:o("migrateError")})]}),c.jsx("div",{className:"divide-y divide-dash-border/70",children:n.map(f=>{const p=k8(f),m=h.get(p)??0;h.set(p,m+1);const x=m===0?p:`${p}#${m}`,b=Ai(f),y=v8(b,o),k=Hs(f.itemName||my(f.path)),v=Hs(f.providerDisplayName||f.provider||""),w=Hs(f.path||""),C=Hs(my(f.path)),j=Hs(f.error||f.skipReason||"");return c.jsxs("div",{className:`grid gap-1.5 ${u} items-start px-4 py-2.5 hover:bg-dash-bg/60 transition-colors`,children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("p",{className:"text-xs font-semibold text-dash-text truncate",title:k,children:k}),c.jsxs("div",{className:"mt-0.5 space-y-0.5 md:hidden",children:[!i&&c.jsx("p",{className:"text-[11px] text-dash-text-secondary truncate",children:v}),c.jsx("p",{className:"font-mono text-[11px] text-dash-text-muted truncate",title:w,children:C}),j&&c.jsx("p",{className:"text-[11px] text-red-400/80 line-clamp-2",title:j,children:j})]})]}),!i&&c.jsx("p",{className:"hidden md:block text-[11px] text-dash-text-secondary truncate",children:v}),c.jsx("p",{className:"hidden md:block font-mono text-[11px] text-dash-text-muted truncate",title:w,children:C}),c.jsx("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-[11px] font-medium ${y.className}`,children:y.label}),c.jsx("p",{className:`hidden md:block text-[11px] truncate ${j?"text-red-400/80":"text-dash-text-muted"}`,title:j,children:j||"-"})]},x)})})]})]})},C8=({results:t,onReset:e})=>{const{t:n}=ee(),[r,s]=g.useState(""),i=g.useDeferredValue(r),[o,a]=g.useState("all"),[l,d]=g.useState(()=>new Set(py.map(w=>w.key))),u=g.useMemo(()=>{const w=i.trim().toLowerCase();return t.results.filter(C=>{if(o!=="all"&&Ai(C)!==o)return!1;if(!w)return!0;const j=(C.itemName||"").toLowerCase(),S=(C.path||"").toLowerCase(),P=(C.providerDisplayName||C.provider||"").toLowerCase();return j.includes(w)||S.includes(w)||P.includes(w)})},[t.results,i,o]),h=g.useMemo(()=>S8(u),[u]),f=g.useMemo(()=>{if(!h||u.length===0)return"";const w=Array.from(new Set(u.map(C=>C.providerDisplayName?.trim()||"").filter(C=>C.length>0)));return w.length===1?w[0]:u[0]?.provider||""},[u,h]),p=g.useMemo(()=>w8(u),[u]),m=g.useMemo(()=>y8(t.results),[t.results]),x=g.useMemo(()=>[...p.keys()],[p]),b=m.installed+m.skipped+m.failed,y=x.length>0&&x.every(w=>l.has(w)),k=w=>{d(C=>{const j=new Set(C);return j.has(w)?j.delete(w):j.add(w),j})},v=()=>{if(y){d(new Set);return}d(new Set(x))};return c.jsxs("div",{className:"dash-panel p-4 md:p-5 space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"text-base font-semibold text-dash-text",children:[n("migrateSummaryTitle"),h&&f&&c.jsxs("span",{className:"text-dash-text-muted font-normal",children:[" ","· ",Hs(f)]})]}),c.jsxs("p",{className:"text-xs text-dash-text-muted mt-1",children:[b," ",n("migrateSummarySubtitle")]})]}),c.jsx("button",{type:"button",onClick:e,className:"dash-focus-ring px-4 py-2 text-sm font-semibold rounded-md bg-dash-bg border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover",children:n("migrateSummaryNewMigration")})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[c.jsx(Wi,{label:n("migrateStatusInstalled"),count:m.installed,className:"border-green-500/30 bg-green-500/10 text-green-400"}),c.jsx(Wi,{label:n("migrateStatusSkipped"),count:m.skipped,className:"border-yellow-500/30 bg-yellow-500/10 text-yellow-400"}),c.jsx(Wi,{label:n("migrateStatusFailed"),count:m.failed,className:"border-red-500/30 bg-red-500/10 text-red-400"})]}),t.warnings.length>0&&c.jsx("div",{className:"space-y-2",children:t.warnings.map((w,C)=>c.jsx("div",{className:"px-3 py-2 border border-yellow-500/30 bg-yellow-500/10 rounded-md text-xs text-yellow-400",children:Hs(w)},C))}),c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("div",{className:"relative",children:[c.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 stroke-dash-text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"11",cy:"11",r:"8"}),c.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),c.jsx("input",{type:"text",value:r,onChange:w=>s(w.target.value),placeholder:n("migrateSummarySearchPlaceholder"),className:"dash-focus-ring w-full pl-9 pr-3 py-2 bg-dash-bg border border-dash-border rounded-lg text-dash-text text-sm focus:border-dash-accent transition-colors"})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[["all","installed","skipped","failed"].map(w=>{const C=w==="all"?"migrateSummaryFilterAll":w==="installed"?"migrateStatusInstalled":w==="skipped"?"migrateStatusSkipped":"migrateStatusFailed";return c.jsx("button",{type:"button",onClick:()=>a(w),className:`dash-focus-ring px-3 py-1 text-xs font-medium rounded-full border transition-colors ${o===w?"bg-dash-accent/10 border-dash-accent text-dash-accent":"border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover hover:text-dash-text"}`,children:n(C)},w)}),c.jsx("button",{type:"button",onClick:v,className:"dash-focus-ring ml-1 px-3 py-1 text-xs font-medium rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover",children:n(y?"migrateSummaryCollapseAll":"migrateSummaryExpandAll")})]})]}),u.length===0?c.jsx("div",{className:"text-center py-8 text-sm text-dash-text-muted",children:n("migrateSummaryNoResults")}):c.jsxs("div",{className:"space-y-2.5",children:[py.map(w=>{const C=p.get(w.key);return!C||C.length===0?null:c.jsx(gy,{labelKey:w.labelKey,badgeClass:w.badgeClass,items:C,isExpanded:l.has(w.key),onToggle:()=>k(w.key),singleProvider:h},w.key)}),(()=>{const w=p.get("unknown");return!w||w.length===0?null:c.jsx(gy,{labelKey:"migrateTypeUnknown",badgeClass:"border-dash-border text-dash-text-muted",items:w,isExpanded:l.has("unknown"),onToggle:()=>k("unknown"),singleProvider:h})})()]})]})},j8=({pendingCount:t,nextMode:e,onConfirm:n,onCancel:r})=>{const{t:s}=ee(),i=g.useRef(null);g.useEffect(()=>{const a=i.current;if(!a)return;a.open||a.showModal();const l=d=>{d.preventDefault(),r()};return a.addEventListener("cancel",l),()=>{a.removeEventListener("cancel",l),a.open&&a.close()}},[r]);const o=s(e==="install"?"migrateModeInstall":"migrateModeReconcile");return c.jsxs("dialog",{ref:i,"aria-labelledby":"mode-confirm-title","aria-describedby":"mode-confirm-body",onClick:a=>{a.target===a.currentTarget&&r()},className:"fixed inset-0 z-50 m-auto h-auto max-w-sm rounded-xl border border-dash-border bg-dash-surface p-6 shadow-2xl backdrop:bg-black/50",children:[c.jsx("h2",{id:"mode-confirm-title",className:"mb-2 text-base font-semibold text-dash-text",children:s("migrateModeConfirmTitle")}),c.jsx("p",{id:"mode-confirm-body",className:"mb-5 text-sm text-dash-text-secondary",children:s("migrateModeConfirmBody").replace("{count}",String(t)).replace("{mode}",o)}),c.jsxs("div",{className:"flex justify-end gap-3",children:[c.jsx("button",{type:"button",onClick:r,className:"dash-focus-ring px-4 py-2 text-sm font-medium rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover",children:s("cancel")}),c.jsx("button",{type:"button",autoFocus:!0,onClick:n,className:"dash-focus-ring px-4 py-2 text-sm font-semibold rounded-md bg-dash-accent text-white hover:bg-dash-accent/90",children:s("migrateModeConfirmSwitch")})]})]})},N8=({mode:t,pendingCount:e,disabled:n=!1,onModeChange:r})=>{const{t:s}=ee(),[i,o]=g.useState(null),a=g.useCallback(u=>{u===t||n||(e>0?o(u):r(u))},[t,n,e,r]),l=g.useCallback(()=>{i&&(r(i),o(null))},[i,r]),d=g.useCallback(()=>{o(null)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{role:"tablist","aria-label":s("migrateModeLabel"),className:"inline-flex rounded-lg border border-dash-border bg-dash-bg overflow-hidden",children:["reconcile","install"].map(u=>{const h=t===u,f=u==="reconcile"?"migrateModeReconcile":"migrateModeInstall",p=u==="reconcile"?"migrateModeReconcileDesc":"migrateModeInstallDesc";return c.jsxs("button",{type:"button",role:"tab","aria-selected":h,"aria-controls":`migrate-${u}-panel`,id:`migrate-${u}-tab`,disabled:n,onClick:()=>a(u),className:`px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-dash-accent disabled:opacity-50 disabled:cursor-not-allowed ${h?"bg-dash-accent-subtle text-dash-accent":"text-dash-text-secondary hover:bg-dash-surface-hover hover:text-dash-text"}`,children:[c.jsx("span",{className:"block",children:s(f)}),c.jsx("span",{className:"block text-[10px] font-normal opacity-70",children:s(p)})]},u)})}),i&&c.jsx(j8,{pendingCount:e,nextMode:i,onConfirm:l,onCancel:d})]})},P8=500;function O8(t){return t>=0&&t<=8||t>=11&&t<=31||t>=127&&t<=159}function E8(t){let e="";for(const n of t){const r=n.codePointAt(0);r!==void 0&&(O8(r)||(e+=n))}return e}const D8=({diff:t,className:e=""})=>{const n=t.split(`
271
+ `),i=[];let o=null;for(let a=0;a<=Math.min(e,s.length-1);a++){const l=s[a].trim(),d=l.match(/"([^"]+)"\s*:\s*{/);if(d){i.push(d[1]),a===e&&(o=i.join("."));continue}if(l==="}"||l==="},"){i.pop();continue}const u=l.match(/"([^"]+)"\s*:/);if(u){const h=u[1];if(a===e){o=i.length>0?`${i.join(".")}.${h}`:h;break}}}r(o)},[t,e]),n};function ZS(t){const{scope:e,fetchConfig:n,fetchSchema:r,saveConfig:s,onReset:i}=t,[o,a]=g.useState("{}"),[l,d]=g.useState(0),[u,h]=g.useState(null),[f,p]=g.useState(null),[m,x]=g.useState({}),[b,y]=g.useState({}),[k,v]=g.useState({}),[w,C]=g.useState(!0),[j,S]=g.useState(null),[P,D]=g.useState("idle"),[A,N]=g.useState(!1),[T,I]=g.useState(null),[O,E]=g.useState(null),M=Q7(o,l),R=fE(O,M),_=g.useMemo(()=>hE(R,f),[R,f]);g.useEffect(()=>{(async()=>{S(null);try{const[Q,se]=await Promise.all([n(),r()]),ce=Q.local??Q.config;x(ce),y(Q.global??{}),v(Q.sources),p(se),a(JSON.stringify(ce,null,2))}catch(Q){const se=Q instanceof Error?Q.message:String(Q);console.error("Failed to load config data:",Q),S(se)}finally{C(!1)}})()},[n,r]),g.useEffect(()=>{try{JSON.parse(o),h(null)}catch(U){h(U instanceof Error?U.message:"Invalid JSON")}},[o]),g.useEffect(()=>{if(T==="json")try{const U=JSON.parse(o);x(U)}catch{}},[o,T]);const $=g.useCallback(U=>{E(null),I("json"),a(U)},[]),F=g.useCallback(()=>{E(null)},[]),z=g.useCallback((U,Q)=>{E(U),I("form"),x(se=>{const ce=zw(se,U,Q);return a(JSON.stringify(ce,null,2)),ce}),v(se=>({...se,[U]:e}))},[e]),V=g.useCallback(async()=>{if(!u){D("saving");try{const U=JSON.parse(o),se=await s(U)??U;x(se),a(JSON.stringify(se,null,2)),D("saved"),setTimeout(()=>D("idle"),2e3)}catch{D("error"),setTimeout(()=>D("idle"),3e3)}}},[o,u,s]),Z=g.useCallback(async()=>{if(N(!1),i){C(!0);try{const U=await i(),Q=U.local??U.config;x(Q),v(U.sources),a(JSON.stringify(Q,null,2))}catch(U){console.error("Failed to reset:",U)}finally{C(!1)}}else{const U={};x(U),a(JSON.stringify(U,null,2))}},[i]);return{jsonText:o,config:m,globalConfig:b,sources:k,schema:f,isLoading:w,loadError:j,saveStatus:P,syntaxError:u,cursorLine:l,showResetConfirm:A,activeFieldPath:R,fieldDoc:_,handleJsonChange:$,handleJsonEditorFocus:F,handleFormChange:z,handleSave:V,handleReset:Z,setCursorLine:d,setFocusedFieldPath:E,setShowResetConfirm:N}}function Eg({storageKey:t,defaultSizes:e,minSizes:n}){const[r,s]=g.useState(()=>{if(typeof window>"u")return e;const d=localStorage.getItem(t);if(d)try{const u=JSON.parse(d);if(Array.isArray(u)&&u.length===e.length){const h=u.reduce((f,p)=>f+p,0);if(Math.abs(h-100)<1)return u}}catch{}return e}),[i,o]=g.useState(!1);g.useEffect(()=>{localStorage.setItem(t,JSON.stringify(r))},[r,t]);const a=g.useCallback((d,u)=>{u.preventDefault(),o(!0);let h=u.currentTarget.parentElement;for(;h&&getComputedStyle(h).display!=="flex";)h=h.parentElement;if(!h)return;const p=h.getBoundingClientRect().width,m=u.clientX,x=[...r],b=k=>{const w=(k.clientX-m)/p*100,C=[...x],j=d,S=d+1;let P=x[j]+w,D=x[S]-w;P<n[j]&&(P=n[j],D=x[j]+x[S]-P),D<n[S]&&(D=n[S],P=x[j]+x[S]-D),C[j]=P,C[S]=D,s(C)},y=()=>{o(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",b),document.addEventListener("mouseup",y),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[r,n]),l=g.useCallback(()=>{s(e)},[e]);return{sizes:r,isDragging:i,startDrag:a,reset:l}}function J7(t,e,n,r){const[s,i]=g.useState(()=>{if(typeof window>"u")return e;const d=localStorage.getItem(t);if(d){const u=Number.parseFloat(d);if(!Number.isNaN(u)&&u>=n&&u<=100-r)return u}return e}),[o,a]=g.useState(!1),l=g.useCallback(d=>{d.preventDefault(),a(!0);const u=d.target.closest("[data-vresize-container]");if(!u)return;const h=p=>{const m=u.getBoundingClientRect(),x=(p.clientY-m.top)/m.height*100;i(Math.max(n,Math.min(100-r,x)))},f=()=>{a(!1),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",f),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",h),document.addEventListener("mouseup",f),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[n,r]);return g.useEffect(()=>{localStorage.setItem(t,String(s))},[t,s]),{topPct:s,isDragging:o,startDrag:l}}const e8=()=>{const{t}=ee(),e=Ft(),{sizes:n,isDragging:r,startDrag:s}=Eg({storageKey:"claudekit-global-config-panels",defaultSizes:[35,40,25],minSizes:[20,25,15]}),i=J7("claudekit-form-taxonomy-split",70,25,15),o=g.useCallback(async()=>await ux(),[]),a=g.useCallback(async f=>{await Ww({scope:"global",config:f})},[]),l=g.useCallback(async()=>await ux(),[]),d=ZS({scope:"global",fetchConfig:o,fetchSchema:Uw,saveConfig:a,onReset:l}),u=g.useMemo(()=>[{id:"general",title:t("sectionGeneral"),fields:[{path:"codingLevel",label:t("fieldCodingLevel"),description:t("fieldCodingLevelDesc")},{path:"statusline",label:t("fieldStatusline"),description:t("fieldStatuslineDesc")},{path:"statuslineColors",label:t("fieldStatuslineColors"),description:t("fieldStatuslineColorsDesc")},{path:"locale.thinkingLanguage",label:t("fieldThinkingLanguage"),description:t("fieldThinkingLanguageDesc")},{path:"locale.responseLanguage",label:t("fieldResponseLanguage"),description:t("fieldResponseLanguageDesc")}]},{id:"paths",title:t("sectionPaths"),fields:[{path:"paths.docs",label:t("fieldDocsPath"),description:t("fieldDocsPathDesc")},{path:"paths.plans",label:t("fieldPlansPath"),description:t("fieldPlansPathDesc")},{path:"paths.globalPlans",label:t("fieldGlobalPlansPath"),description:t("fieldGlobalPlansPathDesc")}]},{id:"privacy",title:t("sectionPrivacy"),defaultCollapsed:!0,fields:[{path:"privacyBlock",label:t("fieldPrivacyBlock"),description:t("fieldPrivacyBlockDesc")},{path:"trust.enabled",label:t("fieldTrustEnabled"),description:t("fieldTrustEnabledDesc")},{path:"trust.passphrase",label:t("fieldTrustPassphrase"),description:t("fieldTrustPassphraseDesc")}]},{id:"project",title:t("sectionProject"),defaultCollapsed:!0,fields:[{path:"project.type",label:t("fieldProjectType"),description:t("fieldProjectTypeDesc")},{path:"project.packageManager",label:t("fieldPackageManager"),description:t("fieldPackageManagerDesc")},{path:"project.framework",label:t("fieldFramework"),description:t("fieldFrameworkDesc")}]},{id:"integrations",title:t("sectionIntegrations"),defaultCollapsed:!0,fields:[{path:"gemini.model",label:t("fieldGeminiModel"),description:t("fieldGeminiModelDesc")},{path:"skills.research.useGemini",label:t("fieldResearchUseGemini"),description:t("fieldResearchUseGeminiDesc")}]},{id:"hooks",title:t("sectionHooks"),defaultCollapsed:!0,fields:[{path:"hooks.session-init",label:t("fieldHookSessionInit"),description:t("fieldHookSessionInitDesc")},{path:"hooks.subagent-init",label:t("fieldHookSubagentInit"),description:t("fieldHookSubagentInitDesc")},{path:"hooks.descriptive-name",label:t("fieldHookDescriptiveName"),description:t("fieldHookDescriptiveNameDesc")},{path:"hooks.dev-rules-reminder",label:t("fieldHookDevRulesReminder"),description:t("fieldHookDevRulesReminderDesc")},{path:"hooks.usage-context-awareness",label:t("fieldHookUsageContextAwareness"),description:t("fieldHookUsageContextAwarenessDesc")},{path:"hooks.context-tracking",label:t("fieldHookContextTracking"),description:t("fieldHookContextTrackingDesc")},{path:"hooks.scout-block",label:t("fieldHookScoutBlock"),description:t("fieldHookScoutBlockDesc")},{path:"hooks.privacy-block",label:t("fieldHookPrivacyBlock"),description:t("fieldHookPrivacyBlockDesc")},{path:"hooks.simplify-gate",label:t("fieldHookSimplifyGate"),description:t("fieldHookSimplifyGateDesc")}]},{id:"simplify",title:t("sectionSimplify"),defaultCollapsed:!0,fields:[{path:"simplify.threshold.locDelta",label:t("fieldSimplifyThresholdLocDelta"),description:t("fieldSimplifyThresholdLocDeltaDesc")},{path:"simplify.threshold.fileCount",label:t("fieldSimplifyThresholdFileCount"),description:t("fieldSimplifyThresholdFileCountDesc")},{path:"simplify.threshold.singleFileLoc",label:t("fieldSimplifyThresholdSingleFileLoc"),description:t("fieldSimplifyThresholdSingleFileLocDesc")},{path:"simplify.gate.enabled",label:t("fieldSimplifyGateEnabled"),description:t("fieldSimplifyGateEnabledDesc")},{path:"simplify.gate.hardVerbs",label:t("fieldSimplifyGateHardVerbs"),description:t("fieldSimplifyGateHardVerbsDesc")},{path:"simplify.gate.softVerbs",label:t("fieldSimplifyGateSoftVerbs"),description:t("fieldSimplifyGateSoftVerbsDesc")}]},{id:"advanced",title:t("sectionAdvanced"),defaultCollapsed:!0,fields:[{path:"docs.maxLoc",label:t("fieldDocsMaxLoc"),description:t("fieldDocsMaxLocDesc")},{path:"plan.namingFormat",label:t("fieldPlanNamingFormat"),description:t("fieldPlanNamingFormatDesc")},{path:"plan.dateFormat",label:t("fieldPlanDateFormat"),description:t("fieldPlanDateFormatDesc")},{path:"plan.validation.mode",label:t("fieldPlanValidationMode"),description:t("fieldPlanValidationModeDesc")},{path:"plan.validation.minQuestions",label:t("fieldPlanMinQuestions"),description:t("fieldPlanMinQuestionsDesc")},{path:"plan.validation.maxQuestions",label:t("fieldPlanMaxQuestions"),description:t("fieldPlanMaxQuestionsDesc")},{path:"assertions",label:t("fieldAssertions"),description:t("fieldAssertionsDesc")}]}],[t]),h=d.showResetConfirm?c.jsxs("div",{className:"flex items-center gap-2 bg-red-500/10 border border-red-500/30 rounded-lg px-2 py-1 animate-in fade-in duration-200",children:[c.jsx("span",{className:"text-xs text-red-500 font-medium",children:t("confirmReset")}),c.jsx("button",{type:"button",onClick:d.handleReset,className:"px-2 py-0.5 rounded bg-red-500 text-white text-xs font-bold hover:bg-red-600 transition-colors",children:t("confirm")}),c.jsx("button",{type:"button",onClick:()=>d.setShowResetConfirm(!1),className:"px-2 py-0.5 rounded bg-dash-surface text-dash-text-secondary text-xs font-bold hover:bg-dash-surface-hover transition-colors border border-dash-border",children:t("cancel")})]}):c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",onClick:()=>d.setShowResetConfirm(!0),className:"px-3 py-1.5 rounded-lg bg-dash-surface text-xs font-bold text-dash-text-secondary hover:bg-dash-surface-hover transition-colors border border-dash-border",children:t("resetToDefault")}),c.jsx("button",{type:"button",onClick:d.handleSave,disabled:!!d.syntaxError||d.saveStatus==="saving",className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all tracking-widest uppercase ${d.syntaxError?"bg-dash-surface text-dash-text-muted cursor-not-allowed border border-dash-border":d.saveStatus==="saved"?"bg-green-500 text-white shadow-lg shadow-green-500/20":d.saveStatus==="error"?"bg-red-500 text-white":"bg-dash-accent text-dash-bg hover:bg-dash-accent-hover shadow-lg shadow-dash-accent/20"}`,children:d.saveStatus==="saving"?t("saving"):d.saveStatus==="saved"?t("saved"):d.saveStatus==="error"?t("saveFailed"):t("saveChanges")})]});return c.jsxs("div",{className:"animate-in fade-in duration-300 w-full h-full flex flex-col transition-colors",children:[c.jsx(ek,{title:t("globalConfig"),filePath:"~/.claude/.ck.json",onBack:()=>e(-1),onSave:d.handleSave,onReset:d.handleReset,saveStatus:d.saveStatus,syntaxError:d.syntaxError,showResetConfirm:d.showResetConfirm,setShowResetConfirm:d.setShowResetConfirm,showActions:!1,showFilePath:!1}),!d.isLoading&&d.loadError&&c.jsxs("div",{className:"mx-4 mt-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30 text-xs text-red-500",children:[c.jsx("p",{className:"font-medium",children:t("configLoadFailed")}),c.jsxs("p",{className:"mt-1 break-words",children:[t("configLoadFailedDetail")," ",d.loadError]})]}),c.jsx("div",{className:"flex-1 flex min-h-0",children:c.jsxs(c.Fragment,{children:[c.jsxs("div",{"data-vresize-container":!0,style:{width:`${n[0]}%`},className:"flex flex-col min-w-0 min-h-0",children:[c.jsx("div",{style:{height:`${d.isLoading?100:i.topPct}%`},className:"min-h-0",children:c.jsx(tk,{width:100,isLoading:d.isLoading,schema:d.schema,config:d.config,sources:d.sources,sections:u,onChange:d.handleFormChange})}),!d.isLoading&&c.jsxs(c.Fragment,{children:[c.jsx(_n,{direction:"vertical",isDragging:i.isDragging,onMouseDown:i.startDrag}),c.jsx("div",{style:{height:`${100-i.topPct}%`},className:"min-h-0",children:c.jsx(Z7,{config:d.config,onChange:d.handleFormChange})})]})]}),c.jsx(_n,{direction:"horizontal",isDragging:r,onMouseDown:f=>s(0,f)}),c.jsx(Og,{width:n[1],isLoading:d.isLoading,jsonText:d.jsonText,cursorLine:d.cursorLine,syntaxError:d.syntaxError,onChange:d.handleJsonChange,onCursorLineChange:d.setCursorLine,headerPath:"~/.claude/.ck.json",headerActions:h}),c.jsx(_n,{direction:"horizontal",isDragging:r,onMouseDown:f=>s(1,f)}),c.jsx(XS,{width:n[2],fieldDoc:d.fieldDoc,activeFieldPath:d.activeFieldPath})]})})]})};function t8(t){const e=t.replace(/\\/g,"/"),n=e.split("/").filter(Boolean);return n.length<3?null:`${e.startsWith("/")?"/":""}${n.slice(0,-2).join("/")}`}function n8(){const[t]=Hl(),e=t.get("projectId"),n=t.get("file"),r=n?t8(n):null,s=new URLSearchParams;return r&&(s.set("dir",r),s.set("view","kanban"),e&&s.set("projectId",e)),c.jsx(gw,{replace:!0,to:r?`/plans?${s.toString()}`:"/plans"})}function r8(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[s,i]=g.useState(null),o=g.useCallback(async()=>{try{if(r(!0),i(null),nt()){const d=await gP();e(d.map(u=>({name:u.name,command:u.command,args:u.args,source:u.source,sourceLabel:u.sourceLabel})));return}const a=await fetch("/api/mcp-servers");if(!a.ok)throw new Error(`Failed to fetch MCP servers: ${a.status}`);const l=await a.json();e(l.servers??[])}catch(a){i(a instanceof Error?a.message:"Failed to load MCP servers"),e([])}finally{r(!1)}},[]);return g.useEffect(()=>{o()},[o]),{servers:t,loading:n,error:s,reload:o}}function s8(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-3.5 h-3.5 shrink-0 text-dash-accent",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h14M12 5l7 7-7 7"})})}function i8({label:t,count:e}){return c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[c.jsx("span",{className:"text-xs font-bold text-dash-text-muted uppercase tracking-wider flex-1",children:t}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold",children:e})]})}function o8({server:t,selected:e,onClick:n}){return c.jsxs("button",{type:"button",onClick:n,className:["w-full flex items-start gap-2 px-3 py-2 rounded-md transition-colors text-left group",e?"bg-dash-accent/10 border border-dash-accent/30":"hover:bg-dash-surface-hover border border-transparent"].join(" "),children:[c.jsx(s8,{}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"text-sm font-semibold text-dash-accent font-mono",children:t.name}),c.jsx("p",{className:"text-xs text-dash-text-muted mt-0.5 truncate font-mono",children:t.command})]})]})}function a8({server:t}){const{t:e}=ee();return c.jsxs("div",{className:"flex flex-col gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("h2",{className:"text-base font-semibold text-dash-text font-mono truncate flex-1",children:t.name}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold shrink-0",children:e("sessionReadOnly")})]}),c.jsx("div",{className:"flex items-center gap-2 text-xs text-dash-text-muted",children:c.jsx("span",{className:"font-mono px-2 py-0.5 rounded bg-dash-surface border border-dash-border text-dash-accent",children:t.sourceLabel})}),c.jsx("div",{className:"rounded-lg border border-dash-border bg-dash-surface p-5 overflow-x-auto",children:c.jsx("table",{className:"w-full text-sm",children:c.jsxs("tbody",{children:[c.jsxs("tr",{className:"border-b border-dash-border",children:[c.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-dash-text-muted w-28 shrink-0 align-top",children:e("mcpCommand")}),c.jsx("td",{className:"py-2 font-mono text-xs text-dash-text break-all",children:t.command})]}),t.args.length>0&&c.jsxs("tr",{className:"border-b border-dash-border",children:[c.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-dash-text-muted w-28 align-top",children:e("mcpArgs")}),c.jsx("td",{className:"py-2 text-xs text-dash-text",children:c.jsx("div",{className:"flex flex-col gap-1",children:t.args.map((n,r)=>c.jsx("code",{className:"font-mono bg-dash-surface border border-dash-border rounded px-1.5 py-0.5 text-[11px] break-all",children:n},r))})})]}),t.env&&Object.keys(t.env).length>0&&c.jsxs("tr",{className:"border-b border-dash-border",children:[c.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-dash-text-muted w-28 align-top",children:"env"}),c.jsx("td",{className:"py-2 text-xs text-dash-text",children:c.jsx("div",{className:"flex flex-col gap-1",children:Object.keys(t.env).map(n=>c.jsxs("code",{className:"font-mono bg-dash-surface border border-dash-border rounded px-1.5 py-0.5 text-[11px]",children:[n,"=",c.jsx("span",{className:"text-dash-text-muted",children:"***"})]},n))})})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"py-2 pr-4 font-mono text-xs text-dash-text-muted w-28 align-top",children:e("mcpSource")}),c.jsx("td",{className:"py-2 text-xs text-dash-text font-mono",children:t.sourceLabel})]})]})})})]})}const l8=({message:t})=>c.jsx("div",{className:"flex items-center justify-center h-full text-sm text-dash-text-muted",children:t}),c8=()=>{const{t}=ee(),{servers:e,loading:n,error:r}=r8(),[s,i]=g.useState(""),[o,a]=g.useState(null),{size:l,isDragging:d,startDrag:u}=yo({storageKey:"ck-mcp-panel-width",defaultSize:380,minSize:260,maxSize:650}),h=x=>`${x.source}-${x.name}`,f=e.find(x=>h(x)===o)??null,p=g.useMemo(()=>{if(!s.trim())return e;const x=s.toLowerCase();return e.filter(b=>b.name.toLowerCase().includes(x)||b.command.toLowerCase().includes(x)||b.sourceLabel.toLowerCase().includes(x))},[e,s]),m=g.useMemo(()=>{const x=new Map;for(const b of p){const y=x.get(b.sourceLabel)??[];y.push(b),x.set(b.sourceLabel,y)}return x},[p]);return c.jsxs("div",{className:"flex h-full overflow-hidden",children:[c.jsxs("div",{style:{width:`${l}px`},className:"shrink-0 flex flex-col overflow-hidden border-r border-dash-border",children:[c.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-3 border-b border-dash-border",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-base font-bold text-dash-text",children:t("mcpTitle")}),!n&&!r&&c.jsx("p",{className:"text-xs text-dash-text-muted mt-0.5",children:e.length===0?t("mcpNoServers"):`${e.length} ${e.length===1?"server":"servers"} configured`}),c.jsx("p",{className:"text-[11px] text-dash-text-muted font-mono mt-0.5",children:"~/.claude.json + settings.json + .mcp.json"})]}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold shrink-0",children:t("sessionReadOnly")})]}),c.jsxs("div",{className:"relative",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-dash-text-muted pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),c.jsx("input",{type:"text",value:s,onChange:x=>i(x.target.value),placeholder:t("mcpServerName"),className:"w-full pl-9 pr-4 py-2 text-sm bg-dash-surface border border-dash-border rounded-lg text-dash-text placeholder:text-dash-text-muted focus:outline-none focus:border-dash-accent/50 transition-colors"}),s&&c.jsx("button",{type:"button",onClick:()=>i(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-dash-text-muted hover:text-dash-text transition-colors",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[n&&c.jsx("div",{className:"flex flex-1 items-center justify-center text-dash-text-muted text-sm p-8",children:t("loading")}),!n&&r&&c.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 dark:bg-red-900/20 p-4 text-red-600 dark:text-red-400 text-sm m-2",children:r}),!n&&!r&&m.size===0&&c.jsx("div",{className:"flex items-center justify-center p-8 text-dash-text-muted text-sm",children:t("mcpNoServers")}),!n&&!r&&m.size>0&&c.jsx("div",{className:"flex flex-col gap-2 pb-4",children:Array.from(m.entries()).map(([x,b])=>c.jsxs("div",{children:[m.size>1&&c.jsx(i8,{label:x,count:b.length}),c.jsx("div",{className:"space-y-0.5",children:b.map(y=>{const k=h(y);return c.jsx(o8,{server:y,selected:o===k,onClick:()=>a(k)},k)})})]},x))})]})]}),c.jsx(_n,{onMouseDown:u,isDragging:d,direction:"horizontal"}),c.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:f?c.jsx(a8,{server:f}):c.jsx(l8,{message:t("selectToView")})})]})},Ju=({titleKey:t,descriptionKey:e,commandHintKey:n})=>{const{t:r}=ee();return c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsxs("div",{className:"max-w-xl rounded-2xl border border-dash-border bg-dash-surface p-8 text-center shadow-sm",children:[c.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] text-dash-accent",children:r("desktopModeLabel")}),c.jsx("h2",{className:"mt-3 text-xl font-semibold text-dash-text",children:r(t)}),c.jsx("p",{className:"mt-3 text-sm leading-relaxed text-dash-text-muted",children:r(e)}),n&&c.jsx("p",{className:"mt-4 rounded-lg border border-dash-border bg-dash-bg px-4 py-3 text-xs font-medium text-dash-text",children:r(n)})]})})};function Ha(t){return`${t.provider}::${t.type}::${t.item}::${String(t.global)}`}const d8=["agent","command","skill","config","rules","hooks"],u8={agent:"migrateTypeAgents",command:"migrateTypeCommands",skill:"migrateTypeSkills",config:"migrateTypeConfig",rules:"migrateTypeRules",hooks:"migrateTypeHooks"},h8={agent:"border-dash-accent/30 text-dash-accent",command:"border-yellow-500/30 text-yellow-400",skill:"border-purple-500/30 text-purple-400",config:"border-teal-500/30 text-teal-400",rules:"border-rose-500/30 text-rose-400",hooks:"border-cyan-500/30 text-cyan-400"},f8=({type:t,candidates:e,selected:n,onToggleItem:r,onSelectAll:s,onDeselectAll:i})=>{const{t:o}=ee(),a=g.useMemo(()=>e.map(Ha),[e]),l=a.filter(f=>n.has(f)).length,d=l===a.length,u=h8[t],h=o(u8[t]);return c.jsxs("div",{className:"border border-dash-border rounded-lg bg-dash-surface overflow-hidden",children:[c.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between border-b border-dash-border bg-dash-bg",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h4",{className:"text-sm font-semibold text-dash-text",children:h}),c.jsxs("span",{className:`px-2 py-0.5 text-xs rounded-md border ${u}`,children:[l,"/",e.length]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",onClick:()=>s(a),disabled:d,className:"dash-focus-ring px-2.5 py-1 text-[11px] rounded border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover disabled:opacity-40",children:o("migrateInstallSelectAll")}),c.jsx("button",{type:"button",onClick:()=>i(a),disabled:l===0,className:"dash-focus-ring px-2.5 py-1 text-[11px] rounded border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover disabled:opacity-40",children:o("migrateInstallDeselectAll")})]})]}),c.jsx("div",{className:"divide-y divide-dash-border/50",children:e.map(f=>{const p=Ha(f),m=n.has(p);return c.jsxs("label",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-dash-surface-hover cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:m,onChange:()=>r(p),className:"h-4 w-4 rounded border-dash-border accent-dash-accent","aria-label":`${f.item} from ${f.provider}`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsx("span",{className:"text-sm font-mono text-dash-text truncate",children:f.item}),f.isDirectoryItem&&c.jsx("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded border border-purple-500/30 text-purple-400",children:o("migrateInstallDirItem")}),f.alreadyInstalled&&c.jsx("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded border border-dash-border text-dash-text-muted",children:o("migrateInstallAlreadyInstalled")})]}),c.jsx("div",{className:"text-[11px] text-dash-text-muted mt-0.5",children:f.provider})]}),f.description&&c.jsx("p",{className:"hidden md:block text-xs text-dash-text-secondary max-w-[200px] truncate shrink-0",children:f.description})]},p)})})]})},p8=({candidates:t,selected:e,onSelectionChange:n,onInstall:r,isInstalling:s=!1})=>{const{t:i}=ee(),o=g.useMemo(()=>{const p=new Map;for(const m of t){const x=p.get(m.type)??[];x.push(m),p.set(m.type,x)}return d8.filter(m=>(p.get(m)?.length??0)>0).map(m=>({type:m,candidates:p.get(m)??[]}))},[t]),a=g.useMemo(()=>t.map(Ha),[t]),l=g.useCallback(p=>{const m=new Set(e);m.has(p)?m.delete(p):m.add(p),n(m)},[e,n]),d=g.useCallback(p=>{const m=new Set(e);for(const x of p)m.add(x);n(m)},[e,n]),u=g.useCallback(p=>{const m=new Set(e);for(const x of p)m.delete(x);n(m)},[e,n]),h=g.useCallback(()=>{n(new Set(a))},[a,n]),f=g.useCallback(()=>{n(new Set)},[n]);return t.length===0?c.jsx("div",{className:"dash-panel p-8 text-center",children:c.jsx("p",{className:"text-dash-text-muted text-sm",children:i("migrateInstallNoCandidates")})}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[c.jsx("p",{className:"text-sm text-dash-text-secondary",children:i("migrateInstallSelectedCount").replace("{count}",String(e.size)).replace("{total}",String(t.length))}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",onClick:h,disabled:e.size===t.length,className:"dash-focus-ring px-3 py-1.5 text-xs rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover disabled:opacity-40",children:i("migrateInstallSelectAll")}),c.jsx("button",{type:"button",onClick:f,disabled:e.size===0,className:"dash-focus-ring px-3 py-1.5 text-xs rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover disabled:opacity-40",children:i("migrateInstallDeselectAll")})]})]}),o.map(({type:p,candidates:m})=>c.jsx(f8,{type:p,candidates:m,selected:e,onToggleItem:l,onSelectAll:d,onDeselectAll:u},p)),c.jsx("div",{className:"flex items-center justify-end pt-2",children:c.jsx("button",{type:"button",disabled:e.size===0||s,onClick:()=>r(e),className:"dash-focus-ring px-6 py-2.5 bg-dash-accent text-white rounded-md text-sm font-semibold hover:bg-dash-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:s?i("migrateInstallInstalling"):i("migrateInstallCta").replace("{count}",String(e.size))})})]})};function m8(t){return new Set(t.map(Ha))}function g8(t,e){const n=t.filter(l=>e.has(Ha(l))),r=n.map(l=>({action:"install",item:l.item,type:l.type,provider:l.provider,global:l.global,targetPath:l.registryPath??l.sourcePath,reason:"User-selected install",reasonCode:"new-item",isDirectoryItem:l.isDirectoryItem})),s=l=>({agent:"agents",command:"commands",skill:"skills",config:"config",rules:"rules",hooks:"hooks"})[l],i={agents:!1,commands:!1,skills:!1,config:!1,rules:!1,hooks:!1},o={agents:[],commands:[],skills:[],config:[],rules:[],hooks:[]},a=new Set;for(const l of n){const d=s(l.type);i[d]=!0,o[d].push(l.item),a.add(l.provider)}return{actions:r,summary:{install:r.length,update:0,skip:0,conflict:0,delete:0},hasConflicts:!1,banners:[],meta:{include:i,providers:Array.from(a),items:o,mode:"install"}}}const py=[{key:"agent",labelKey:"migrateTypeAgents",badgeClass:"border-dash-accent/30 text-dash-accent"},{key:"command",labelKey:"migrateTypeCommands",badgeClass:"border-yellow-500/30 text-yellow-400"},{key:"skill",labelKey:"migrateTypeSkills",badgeClass:"border-purple-500/30 text-purple-400"},{key:"config",labelKey:"migrateTypeConfig",badgeClass:"border-teal-500/30 text-teal-400"},{key:"rules",labelKey:"migrateTypeRules",badgeClass:"border-rose-500/30 text-rose-400"},{key:"hooks",labelKey:"migrateTypeHooks",badgeClass:"border-cyan-500/30 text-cyan-400"}],x8=new Set([8203,8204,8205,8288,65279,8232,8233,8234,8235,8236,8237,8238,8294,8295,8296,8297]);function b8(t){return t===9||t===10||t===13?!0:t>=0&&t<=8||t>=11&&t<=31||t>=127&&t<=159||x8.has(t)}function Hs(t){let e="";for(const n of t){const r=n.codePointAt(0);r!==void 0&&(b8(r)||(e+=n))}return e}function my(t){if(!t)return"-";const e=t.replace(/\\/g,"/"),n=e.match(/.*\/(\.[^/]+\/)/);if(n?.[1]){const s=(n.index??0)+n[0].length-n[1].length;return e.slice(s)}const r=e.split("/");return r.length>3?`.../${r.slice(-3).join("/")}`:e}function Ai(t){return t.success?t.skipped?"skipped":"installed":"failed"}function y8(t){const e={installed:0,skipped:0,failed:0};for(const n of t){const r=Ai(n);r==="installed"?e.installed+=1:r==="skipped"?e.skipped+=1:e.failed+=1}return e}function QS(t){switch(t){case"agent":case"command":case"skill":case"config":case"rules":case"hooks":case"unknown":return t;default:return"unknown"}}function v8(t,e){switch(t){case"failed":return{label:e("migrateStatusFailed"),className:"border-red-500/30 bg-red-500/10 text-red-400"};case"skipped":return{label:e("migrateStatusSkipped"),className:"border-yellow-500/30 bg-yellow-500/10 text-yellow-400"};default:return{label:e("migrateStatusInstalled"),className:"border-green-500/30 bg-green-500/10 text-green-400"}}}function w8(t){const e=new Map;for(const n of t){const r=QS(n.portableType),s=e.get(r)||[];s.push(n),e.set(r,s)}return e}function k8(t){return[QS(t.portableType),t.provider,t.providerDisplayName,t.itemName,t.path,t.success,t.skipped,t.overwritten,t.error,t.skipReason].map(n=>n===void 0?"":String(n)).join("|")}function S8(t){if(t.length===0)return!0;const e=t[0].provider;return t.every(n=>n.provider===e)}const Wi=({label:t,count:e,className:n})=>e<=0?null:c.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-2.5 py-1 text-xs ${n}`,children:[c.jsx("span",{className:"font-semibold",children:e}),c.jsx("span",{children:t})]}),gy=({labelKey:t,badgeClass:e,items:n,isExpanded:r,onToggle:s,singleProvider:i})=>{const{t:o}=ee(),a=n.filter(f=>Ai(f)==="installed").length,l=n.filter(f=>Ai(f)==="skipped").length,d=n.filter(f=>Ai(f)==="failed").length,u=i?"md:grid-cols-[minmax(0,1.5fr)_minmax(0,1.35fr)_auto_minmax(0,1fr)]":"md:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)_minmax(0,1.2fr)_auto_minmax(0,1fr)]",h=new Map;return c.jsxs("div",{className:"rounded-xl border border-dash-border bg-dash-surface overflow-hidden",children:[c.jsxs("button",{type:"button",onClick:s,className:"w-full flex flex-wrap items-center gap-2 px-4 py-3 text-left hover:bg-dash-surface-hover transition-colors",children:[c.jsx("svg",{className:`w-3.5 h-3.5 text-dash-text-muted transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c.jsx("path",{d:"M9 5l7 7-7 7"})}),c.jsx("p",{className:"text-sm font-semibold text-dash-text",children:o(t)}),c.jsx("span",{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-semibold ${e}`,children:n.length}),c.jsx("span",{className:"hidden sm:block flex-1"}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px]",children:[c.jsx(Wi,{label:o("migrateStatusInstalled"),count:a,className:"border-green-500/30 bg-green-500/10 text-green-400"}),c.jsx(Wi,{label:o("migrateStatusSkipped"),count:l,className:"border-yellow-500/30 bg-yellow-500/10 text-yellow-400"}),c.jsx(Wi,{label:o("migrateStatusFailed"),count:d,className:"border-red-500/30 bg-red-500/10 text-red-400"})]})]}),r&&c.jsxs("div",{className:"border-t border-dash-border/80",children:[c.jsxs("div",{className:`hidden md:grid ${u} items-center gap-3 px-4 py-2 border-b border-dash-border/70 text-[10px] font-semibold uppercase tracking-wide text-dash-text-muted`,children:[c.jsx("p",{children:o("migrateItem")}),!i&&c.jsx("p",{children:o("migrateProvider")}),c.jsx("p",{children:o("migratePath")}),c.jsx("p",{children:o("migrateStatus")}),c.jsx("p",{children:o("migrateError")})]}),c.jsx("div",{className:"divide-y divide-dash-border/70",children:n.map(f=>{const p=k8(f),m=h.get(p)??0;h.set(p,m+1);const x=m===0?p:`${p}#${m}`,b=Ai(f),y=v8(b,o),k=Hs(f.itemName||my(f.path)),v=Hs(f.providerDisplayName||f.provider||""),w=Hs(f.path||""),C=Hs(my(f.path)),j=Hs(f.error||f.skipReason||"");return c.jsxs("div",{className:`grid gap-1.5 ${u} items-start px-4 py-2.5 hover:bg-dash-bg/60 transition-colors`,children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("p",{className:"text-xs font-semibold text-dash-text truncate",title:k,children:k}),c.jsxs("div",{className:"mt-0.5 space-y-0.5 md:hidden",children:[!i&&c.jsx("p",{className:"text-[11px] text-dash-text-secondary truncate",children:v}),c.jsx("p",{className:"font-mono text-[11px] text-dash-text-muted truncate",title:w,children:C}),j&&c.jsx("p",{className:"text-[11px] text-red-400/80 line-clamp-2",title:j,children:j})]})]}),!i&&c.jsx("p",{className:"hidden md:block text-[11px] text-dash-text-secondary truncate",children:v}),c.jsx("p",{className:"hidden md:block font-mono text-[11px] text-dash-text-muted truncate",title:w,children:C}),c.jsx("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-[11px] font-medium ${y.className}`,children:y.label}),c.jsx("p",{className:`hidden md:block text-[11px] truncate ${j?"text-red-400/80":"text-dash-text-muted"}`,title:j,children:j||"-"})]},x)})})]})]})},C8=({results:t,onReset:e})=>{const{t:n}=ee(),[r,s]=g.useState(""),i=g.useDeferredValue(r),[o,a]=g.useState("all"),[l,d]=g.useState(()=>new Set(py.map(w=>w.key))),u=g.useMemo(()=>{const w=i.trim().toLowerCase();return t.results.filter(C=>{if(o!=="all"&&Ai(C)!==o)return!1;if(!w)return!0;const j=(C.itemName||"").toLowerCase(),S=(C.path||"").toLowerCase(),P=(C.providerDisplayName||C.provider||"").toLowerCase();return j.includes(w)||S.includes(w)||P.includes(w)})},[t.results,i,o]),h=g.useMemo(()=>S8(u),[u]),f=g.useMemo(()=>{if(!h||u.length===0)return"";const w=Array.from(new Set(u.map(C=>C.providerDisplayName?.trim()||"").filter(C=>C.length>0)));return w.length===1?w[0]:u[0]?.provider||""},[u,h]),p=g.useMemo(()=>w8(u),[u]),m=g.useMemo(()=>y8(t.results),[t.results]),x=g.useMemo(()=>[...p.keys()],[p]),b=m.installed+m.skipped+m.failed,y=x.length>0&&x.every(w=>l.has(w)),k=w=>{d(C=>{const j=new Set(C);return j.has(w)?j.delete(w):j.add(w),j})},v=()=>{if(y){d(new Set);return}d(new Set(x))};return c.jsxs("div",{className:"dash-panel p-4 md:p-5 space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"text-base font-semibold text-dash-text",children:[n("migrateSummaryTitle"),h&&f&&c.jsxs("span",{className:"text-dash-text-muted font-normal",children:[" ","· ",Hs(f)]})]}),c.jsxs("p",{className:"text-xs text-dash-text-muted mt-1",children:[b," ",n("migrateSummarySubtitle")]})]}),c.jsx("button",{type:"button",onClick:e,className:"dash-focus-ring px-4 py-2 text-sm font-semibold rounded-md bg-dash-bg border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover",children:n("migrateSummaryNewMigration")})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[c.jsx(Wi,{label:n("migrateStatusInstalled"),count:m.installed,className:"border-green-500/30 bg-green-500/10 text-green-400"}),c.jsx(Wi,{label:n("migrateStatusSkipped"),count:m.skipped,className:"border-yellow-500/30 bg-yellow-500/10 text-yellow-400"}),c.jsx(Wi,{label:n("migrateStatusFailed"),count:m.failed,className:"border-red-500/30 bg-red-500/10 text-red-400"})]}),t.warnings.length>0&&c.jsx("div",{className:"space-y-2",children:t.warnings.map((w,C)=>c.jsx("div",{className:"px-3 py-2 border border-yellow-500/30 bg-yellow-500/10 rounded-md text-xs text-yellow-400",children:Hs(w)},C))}),c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("div",{className:"relative",children:[c.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 stroke-dash-text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"11",cy:"11",r:"8"}),c.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),c.jsx("input",{type:"text",value:r,onChange:w=>s(w.target.value),placeholder:n("migrateSummarySearchPlaceholder"),className:"dash-focus-ring w-full pl-9 pr-3 py-2 bg-dash-bg border border-dash-border rounded-lg text-dash-text text-sm focus:border-dash-accent transition-colors"})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[["all","installed","skipped","failed"].map(w=>{const C=w==="all"?"migrateSummaryFilterAll":w==="installed"?"migrateStatusInstalled":w==="skipped"?"migrateStatusSkipped":"migrateStatusFailed";return c.jsx("button",{type:"button",onClick:()=>a(w),className:`dash-focus-ring px-3 py-1 text-xs font-medium rounded-full border transition-colors ${o===w?"bg-dash-accent/10 border-dash-accent text-dash-accent":"border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover hover:text-dash-text"}`,children:n(C)},w)}),c.jsx("button",{type:"button",onClick:v,className:"dash-focus-ring ml-1 px-3 py-1 text-xs font-medium rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover",children:n(y?"migrateSummaryCollapseAll":"migrateSummaryExpandAll")})]})]}),u.length===0?c.jsx("div",{className:"text-center py-8 text-sm text-dash-text-muted",children:n("migrateSummaryNoResults")}):c.jsxs("div",{className:"space-y-2.5",children:[py.map(w=>{const C=p.get(w.key);return!C||C.length===0?null:c.jsx(gy,{labelKey:w.labelKey,badgeClass:w.badgeClass,items:C,isExpanded:l.has(w.key),onToggle:()=>k(w.key),singleProvider:h},w.key)}),(()=>{const w=p.get("unknown");return!w||w.length===0?null:c.jsx(gy,{labelKey:"migrateTypeUnknown",badgeClass:"border-dash-border text-dash-text-muted",items:w,isExpanded:l.has("unknown"),onToggle:()=>k("unknown"),singleProvider:h})})()]})]})},j8=({pendingCount:t,nextMode:e,onConfirm:n,onCancel:r})=>{const{t:s}=ee(),i=g.useRef(null);g.useEffect(()=>{const a=i.current;if(!a)return;a.open||a.showModal();const l=d=>{d.preventDefault(),r()};return a.addEventListener("cancel",l),()=>{a.removeEventListener("cancel",l),a.open&&a.close()}},[r]);const o=s(e==="install"?"migrateModeInstall":"migrateModeReconcile");return c.jsxs("dialog",{ref:i,"aria-labelledby":"mode-confirm-title","aria-describedby":"mode-confirm-body",onClick:a=>{a.target===a.currentTarget&&r()},className:"fixed inset-0 z-50 m-auto h-auto max-w-sm rounded-xl border border-dash-border bg-dash-surface p-6 shadow-2xl backdrop:bg-black/50",children:[c.jsx("h2",{id:"mode-confirm-title",className:"mb-2 text-base font-semibold text-dash-text",children:s("migrateModeConfirmTitle")}),c.jsx("p",{id:"mode-confirm-body",className:"mb-5 text-sm text-dash-text-secondary",children:s("migrateModeConfirmBody").replace("{count}",String(t)).replace("{mode}",o)}),c.jsxs("div",{className:"flex justify-end gap-3",children:[c.jsx("button",{type:"button",onClick:r,className:"dash-focus-ring px-4 py-2 text-sm font-medium rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover",children:s("cancel")}),c.jsx("button",{type:"button",autoFocus:!0,onClick:n,className:"dash-focus-ring px-4 py-2 text-sm font-semibold rounded-md bg-dash-accent text-white hover:bg-dash-accent/90",children:s("migrateModeConfirmSwitch")})]})]})},N8=({mode:t,pendingCount:e,disabled:n=!1,onModeChange:r})=>{const{t:s}=ee(),[i,o]=g.useState(null),a=g.useCallback(u=>{u===t||n||(e>0?o(u):r(u))},[t,n,e,r]),l=g.useCallback(()=>{i&&(r(i),o(null))},[i,r]),d=g.useCallback(()=>{o(null)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{role:"tablist","aria-label":s("migrateModeLabel"),className:"inline-flex rounded-lg border border-dash-border bg-dash-bg overflow-hidden",children:["reconcile","install"].map(u=>{const h=t===u,f=u==="reconcile"?"migrateModeReconcile":"migrateModeInstall",p=u==="reconcile"?"migrateModeReconcileDesc":"migrateModeInstallDesc";return c.jsxs("button",{type:"button",role:"tab","aria-selected":h,"aria-controls":`migrate-${u}-panel`,id:`migrate-${u}-tab`,disabled:n,onClick:()=>a(u),className:`px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-dash-accent disabled:opacity-50 disabled:cursor-not-allowed ${h?"bg-dash-accent-subtle text-dash-accent":"text-dash-text-secondary hover:bg-dash-surface-hover hover:text-dash-text"}`,children:[c.jsx("span",{className:"block",children:s(f)}),c.jsx("span",{className:"block text-[10px] font-normal opacity-70",children:s(p)})]},u)})}),i&&c.jsx(j8,{pendingCount:e,nextMode:i,onConfirm:l,onCancel:d})]})},P8=500;function O8(t){return t>=0&&t<=8||t>=11&&t<=31||t>=127&&t<=159}function E8(t){let e="";for(const n of t){const r=n.codePointAt(0);r!==void 0&&(O8(r)||(e+=n))}return e}const D8=({diff:t,className:e=""})=>{const n=t.split(`
272
272
  `),r=n.slice(0,P8),s=n.length-r.length;return c.jsxs("pre",{className:`text-xs font-mono overflow-x-auto p-3 rounded bg-dash-bg border border-dash-border ${e}`,children:[r.map((i,o)=>{const a=E8(i);let l="text-dash-text";return a.startsWith("+")?l="text-green-400 bg-green-500/10":a.startsWith("-")?l="text-red-400 bg-red-500/10":a.startsWith("@@")&&(l="text-blue-400"),c.jsx("div",{className:l,children:a},`${o}:${a.slice(0,24)}`)}),s>0&&c.jsxs("div",{className:"text-dash-text-muted",children:["... truncated ",s," additional line(s)"]})]})};function M8(t){return t>=0&&t<=8||t>=11&&t<=31||t>=127&&t<=159}function Wo(t){let e="";for(const n of t){const r=n.codePointAt(0);r!==void 0&&(M8(r)||(e+=n))}return e}const JS=({action:t,resolution:e,onResolve:n})=>{const{t:r}=ee(),[s,i]=g.useState(!1),o=t.ownedSections&&t.ownedSections.length>0;return c.jsxs("div",{className:"border border-dash-border rounded-lg p-4 mb-3 bg-dash-surface",children:[c.jsxs("div",{className:"flex justify-between items-start gap-4",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"font-mono text-sm text-dash-text truncate",children:[Wo(t.provider),"/",Wo(t.type),"/",Wo(t.item)]}),c.jsx("p",{className:"text-xs text-dash-text-muted mt-1",children:Wo(t.reason)}),t.targetPath&&c.jsx("p",{className:"text-xs text-dash-text-secondary mt-1 font-mono truncate",children:Wo(t.targetPath)})]}),c.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[c.jsx("button",{type:"button",onClick:()=>n({type:"overwrite"}),className:`dash-focus-ring px-3 py-1.5 text-xs font-semibold rounded-md transition-colors ${e?.type==="overwrite"?"bg-dash-accent text-white":"bg-dash-bg border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover"}`,children:r("migrateConflictUseCK")}),c.jsx("button",{type:"button",onClick:()=>n({type:"keep"}),className:`dash-focus-ring px-3 py-1.5 text-xs font-semibold rounded-md transition-colors ${e?.type==="keep"?"bg-dash-accent text-white":"bg-dash-bg border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover"}`,children:r("migrateConflictKeepMine")}),o&&c.jsx("button",{type:"button",onClick:()=>n({type:"smart-merge"}),className:`dash-focus-ring px-3 py-1.5 text-xs font-semibold rounded-md transition-colors ${e?.type==="smart-merge"?"bg-dash-accent text-white":"bg-dash-bg border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover"}`,children:r("migrateConflictSmartMerge")}),t.diff&&c.jsx("button",{type:"button",onClick:()=>i(!s),className:"dash-focus-ring px-3 py-1.5 text-xs font-medium rounded-md border border-dash-border text-dash-text-secondary hover:bg-dash-surface-hover",children:r(s?"migrateConflictHideDiff":"migrateConflictShowDiff")})]})]}),s&&t.diff&&c.jsx(D8,{diff:t.diff,className:"mt-3"}),e&&c.jsxs("div",{className:"mt-2 text-xs text-green-400 flex items-center gap-1.5",children:[c.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:c.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),c.jsxs("span",{children:[r("migrateConflictResolved"),": ",A8(e.type,r)]})]})]})};function A8(t,e){switch(t){case"overwrite":return e("migrateConflictUseCK");case"keep":return e("migrateConflictKeepMine");case"smart-merge":return e("migrateConflictSmartMerge");case"resolved":return e("migrateConflictManual");default:return String(t)}}const T8=({banner:t,onRespectDeletionsOverride:e})=>{const{t:n}=ee(),r=t.kind==="empty-dir-respected";return c.jsxs("output",{"aria-live":"polite",className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${r?"bg-dash-surface border-dash-border text-dash-text-secondary":"bg-blue-500/5 border-blue-500/20 text-blue-300"}`,children:[c.jsx("svg",{className:`w-4 h-4 mt-0.5 shrink-0 ${r?"text-dash-text-muted":"text-blue-400"}`,fill:"currentColor",viewBox:"0 0 20 20","aria-hidden":"true",children:c.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})}),c.jsx("div",{className:"flex-1 min-w-0",children:r?c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:"text-xs font-medium",children:[n("migrateBanner_emptyDirRespected_title")," —"," ",c.jsx("span",{className:"font-mono",children:t.path})," ",n("migrateBanner_emptyDirRespected_body")]}),e&&c.jsxs("button",{type:"button",onClick:e,className:"dash-focus-ring mt-1.5 text-xs font-medium text-dash-accent hover:underline",children:[n("migrateBanner_reinstallCta")," →"]})]}):c.jsxs("p",{className:"text-xs font-medium",children:[n("migrateBanner_emptyDir_title")," — ",c.jsx("span",{className:"font-mono",children:t.path}),":"," ",c.jsx("span",{className:"font-semibold",children:t.itemCount})," ",n("migrateBanner_emptyDir_body")]})})]})},xy=[{key:"install",labelKey:"migrateActionInstall",activeClass:"border-green-400 text-green-400",badgeClass:"bg-green-500/10 border-green-500/30 text-green-400"},{key:"update",labelKey:"migrateActionUpdate",activeClass:"border-yellow-400 text-yellow-400",badgeClass:"bg-yellow-500/10 border-yellow-500/30 text-yellow-400"},{key:"delete",labelKey:"migrateActionDelete",activeClass:"border-dash-text-secondary text-dash-text-secondary",badgeClass:"bg-dash-bg border-dash-border text-dash-text-secondary"},{key:"skip",labelKey:"migrateActionSkip",activeClass:"border-dash-text-muted text-dash-text-muted",badgeClass:"bg-dash-bg border-dash-border text-dash-text-muted"}],eC=["agent","command","skill","config","rules","hooks"],L8={agent:"migrateTypeAgents",command:"migrateTypeCommands",skill:"migrateTypeSkills",config:"migrateTypeConfig",rules:"migrateTypeRules",hooks:"migrateTypeHooks"},R8={agent:"border-dash-accent/30 text-dash-accent",command:"border-yellow-500/30 text-yellow-400",skill:"border-purple-500/30 text-purple-400",config:"border-teal-500/30 text-teal-400",rules:"border-rose-500/30 text-rose-400",hooks:"border-cyan-500/30 text-cyan-400"},Ui=200,_8={install:["skip"],update:["skip"],delete:["skip"],skip:["install"]},I8=new Set(["user-deleted-respected","user-edits-preserved","target-state-unknown"]);function $8(t){return t>=0&&t<=8||t>=11&&t<=31||t>=127&&t<=159}function Hc(t){let e="";for(const n of t){const r=n.codePointAt(0);r!==void 0&&($8(r)||(e+=n))}return e}function B8(t){return{"new-item":"migrateReason_newItem","new-provider-for-item":"migrateReason_newProviderForItem","target-deleted-source-changed":"migrateReason_targetDeletedSourceChanged","target-dir-empty-reinstall":"migrateReason_targetDirEmptyReinstall","force-reinstall":"migrateReason_forceReinstall","force-overwrite":"migrateReason_forceOverwrite","registry-upgrade-reinstall":"migrateReason_registryUpgradeReinstall","source-changed":"migrateReason_sourceChanged","registry-upgrade-heal":"migrateReason_registryUpgradeHeal","no-changes":"migrateReason_noChanges","user-edits-preserved":"migrateReason_userEditsPreserved","user-deleted-respected":"migrateReason_userDeletedRespected","target-up-to-date-backfill":"migrateReason_targetUpToDateBackfill","provider-checksum-unavailable":"migrateReason_providerChecksumUnavailable","target-state-unknown":"migrateReason_targetStateUnknown","source-removed-orphan":"migrateReason_sourceRemovedOrphan","renamed-cleanup":"migrateReason_renamedCleanup","path-migrated-cleanup":"migrateReason_pathMigratedCleanup","both-changed":"migrateReason_bothChanged","target-state-unknown-source-changed":"migrateReason_targetStateUnknownSourceChanged"}[t]??"migrateReason_targetStateUnknown"}function F8(t){const e={install:[],update:[],delete:[],skip:[],conflict:[]};for(const n of t)n.action==="conflict"?(e.install.push(n),e.conflict.push(n)):(n.action==="install"||n.action==="update"||n.action==="delete"||n.action==="skip")&&e[n.action].push(n);return e}function z8(t){const e=new Map;for(const n of t){const r=e.get(n.type)??[];r.push(n),e.set(n.type,r)}return e}function V8(t,e,n){return[...t].sort((r,s)=>{const i=e.get(n(r))==="skip"?1:0,o=e.get(n(s))==="skip"?1:0;return i-o})}const H8=({plan:t,resolutions:e,onResolve:n,actionKey:r,flips:s,onFlip:i,onRespectDeletionsOverride:o})=>{const{t:a}=ee(),l=g.useMemo(()=>F8(t.actions),[t.actions]),d=g.useMemo(()=>xy.filter(v=>l[v.key].length>0),[l]),[u,h]=g.useState(()=>{for(const v of xy)if(l[v.key].length>0)return v.key;return"install"});g.useEffect(()=>{l[u]?.length===0&&d.length>0&&h(d[0].key)},[l,u,d]);const[f,p]=g.useState(!1),m=g.useMemo(()=>V8(l[u]??[],s,r),[l,u,s,r]),x=g.useMemo(()=>z8(m),[m]),b=u==="skip",y=u==="update"&&(l.update.length??0)>10,k=!b&&!y;return c.jsxs("div",{className:"space-y-4",children:[t.banners.length>0&&c.jsx("div",{className:"space-y-2",children:t.banners.map((v,w)=>c.jsx(T8,{banner:v,onRespectDeletionsOverride:o},`banner-${w}`))}),l.conflict.length>0&&c.jsx(U8,{conflicts:l.conflict,resolutions:e,onResolve:n,actionKey:r,open:f,onToggle:()=>p(v=>!v)}),c.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[t.summary.install>0&&c.jsxs("div",{className:"px-2.5 py-1 rounded-md bg-green-500/10 border border-green-500/30 text-green-400",children:[t.summary.install," ",a("migrateActionInstall")]}),t.summary.update>0&&c.jsxs("div",{className:"px-2.5 py-1 rounded-md bg-yellow-500/10 border border-yellow-500/30 text-yellow-400",children:[t.summary.update," ",a("migrateActionUpdate")]}),t.summary.skip>0&&c.jsxs("div",{className:"px-2.5 py-1 rounded-md bg-dash-bg border border-dash-border text-dash-text-muted",children:[t.summary.skip," ",a("migrateActionSkip")]}),t.summary.conflict>0&&c.jsxs("div",{className:"px-2.5 py-1 rounded-md bg-red-500/10 border border-red-500/30 text-red-400",children:[t.summary.conflict," ",a("migrateActionConflict")]}),t.summary.delete>0&&c.jsxs("div",{className:"px-2.5 py-1 rounded-md bg-dash-bg border border-dash-border text-dash-text-secondary",children:[t.summary.delete," ",a("migrateActionDelete")]})]}),d.length>1&&c.jsx("div",{className:"flex gap-1 border-b border-dash-border",role:"tablist",children:d.map(v=>{const w=u===v.key,C=l[v.key].length;return c.jsxs("button",{type:"button",role:"tab","aria-selected":w,onClick:()=>h(v.key),className:`px-3 py-2 text-xs font-medium border-b-2 transition-colors ${w?v.activeClass:"border-transparent text-dash-text-muted hover:text-dash-text-secondary"}`,children:[a(v.labelKey)," ",c.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-[10px] border ${v.badgeClass}`,"aria-label":`${C} items`,children:C})]},v.key)})}),b?c.jsx(W8,{typeGroups:x,activeTab:u,flips:s,onFlip:i,actionKey:r}):c.jsx("div",{className:"space-y-3",children:eC.map(v=>{const w=x.get(v);return!w||w.length===0?null:c.jsxs(tC,{type:v,count:w.length,defaultExpanded:k,children:[w.slice(0,Ui).map(C=>c.jsx(nC,{action:C,sourceTab:u,isFlippedToSkip:s.get(r(C))==="skip",onFlip:j=>i(C,j),hasConflict:C.action==="conflict",resolutions:e,onResolve:n,actionKey:r},r(C))),w.length>Ui&&c.jsxs("div",{className:"text-xs text-dash-text-muted px-1",children:["... ",w.length-Ui," more"]})]},`${u}:${v}`)})})]})},W8=({typeGroups:t,activeTab:e,flips:n,onFlip:r,actionKey:s})=>{const{t:i}=ee(),[o,a]=g.useState(!1),l=g.useMemo(()=>{let d=0;for(const u of t.values())d+=u.length;return d},[t]);return c.jsxs("div",{className:"border border-dash-border rounded-lg bg-dash-surface",children:[c.jsxs("button",{type:"button","aria-expanded":o,onClick:()=>a(d=>!d),className:"w-full px-4 py-3 flex items-center justify-between text-left hover:bg-dash-surface-hover transition-colors",children:[c.jsxs("span",{className:"text-sm text-dash-text-muted",children:[i(o?"migrateHideSkippedItems":"migrateShowSkippedItems"),c.jsxs("span",{className:"ml-2 text-xs text-dash-text-muted opacity-70",children:["(",l,")"]})]}),c.jsx("svg",{"aria-hidden":"true",className:`w-4 h-4 text-dash-text-muted transition-transform ${o?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),o&&c.jsx("div",{className:"px-4 pb-4 space-y-3",children:eC.map(d=>{const u=t.get(d);return!u||u.length===0?null:c.jsxs(tC,{type:d,count:u.length,defaultExpanded:!1,children:[u.slice(0,Ui).map(h=>c.jsx(nC,{action:h,sourceTab:e,isFlippedToSkip:n.get(s(h))==="skip",onFlip:f=>r(h,f),hasConflict:!1,resolutions:new Map,onResolve:()=>{},actionKey:s},s(h))),u.length>Ui&&c.jsxs("div",{className:"text-xs text-dash-text-muted px-1",children:["... ",u.length-Ui," more"]})]},`${e}:${d}`)})})]})},U8=({conflicts:t,resolutions:e,onResolve:n,actionKey:r,open:s,onToggle:i})=>{const{t:o}=ee(),a=g.useMemo(()=>t.filter(l=>e.has(r(l))).length,[t,e,r]);return c.jsxs("div",{className:"border border-red-500/30 rounded-lg bg-red-500/5",children:[c.jsxs("div",{className:"px-4 py-3 flex items-center justify-between gap-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("svg",{className:"w-4 h-4 text-red-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),c.jsxs("span",{className:"text-sm font-medium text-red-400",children:[o("migrateConflictBanner_title")," (",t.length,")"]}),a>0&&c.jsxs("span",{className:"text-xs text-green-400",children:[a,"/",t.length," resolved"]})]}),c.jsx("button",{type:"button",onClick:i,"aria-expanded":s,className:"dash-focus-ring px-3 py-1 text-xs font-medium rounded-md bg-red-500/10 border border-red-500/30 text-red-400 hover:bg-red-500/20 transition-colors",children:o(s?"migrateConflictBanner_hide":"migrateConflictBanner_cta")})]}),s&&c.jsx("div",{className:"px-4 pb-4 space-y-3",children:t.map(l=>c.jsx(JS,{action:l,resolution:e.get(r(l))??null,onResolve:d=>n(l,d)},r(l)))})]})},tC=({type:t,count:e,defaultExpanded:n=!0,children:r})=>{const{t:s}=ee(),[i,o]=g.useState(n),a=R8[t],l=s(L8[t]);return c.jsxs("div",{className:"border border-dash-border rounded-lg bg-dash-surface",children:[c.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>o(d=>!d),className:"w-full px-4 py-2.5 flex items-center justify-between text-left hover:bg-dash-surface-hover transition-colors",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h4",{className:"text-sm font-semibold text-dash-text",children:l}),c.jsx("span",{className:`px-2 py-0.5 text-xs rounded-md border ${a}`,children:e})]}),c.jsx("svg",{"aria-hidden":"true",className:`w-4 h-4 text-dash-text-muted transition-transform ${i?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),i&&c.jsx("div",{className:"px-4 pt-1 pb-4 space-y-2",children:r})]})},nC=({action:t,sourceTab:e,isFlippedToSkip:n,onFlip:r,hasConflict:s,resolutions:i,onResolve:o,actionKey:a})=>{const{t:l}=ee(),[d,u]=g.useState(!1),h=!n,f=`${Hc(t.provider)}/${Hc(t.item)}`,p=t.reasonCopy??(t.reasonCode?l(B8(t.reasonCode)):Hc(t.reason)),m=x=>{r(x.target.checked?"execute":"skip")};return c.jsx("div",{className:`px-3 py-2 bg-dash-bg rounded-md border border-dash-border transition-opacity ${n?"opacity-50":"opacity-100"}`,children:c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx("input",{type:"checkbox",checked:h,onChange:m,"aria-label":`${l("migrateFlip_toggleItem")}: ${f}`,className:"mt-0.5 shrink-0 accent-dash-accent cursor-pointer"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[c.jsx("span",{className:"font-mono text-xs text-dash-text truncate",children:f}),s&&c.jsx("button",{type:"button",onClick:()=>u(x=>!x),className:"dash-focus-ring shrink-0 px-1.5 py-0.5 text-[10px] font-medium rounded border border-red-500/40 bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors",children:l("migrateConflictBadge")})]}),c.jsx("div",{className:"text-xs text-dash-text-muted mt-0.5",children:p}),t.targetPath&&c.jsx("div",{className:"text-xs text-dash-text-secondary mt-0.5 font-mono truncate",children:Hc(t.targetPath)}),s&&d&&c.jsx("div",{className:"mt-2",children:c.jsx(JS,{action:t,resolution:i.get(a(t))??null,onResolve:x=>o(t,x)})})]}),c.jsx(K8,{sourceTab:e,action:t,isFlippedToSkip:n,onFlip:r})]})})},K8=({sourceTab:t,action:e,isFlippedToSkip:n,onFlip:r})=>{const{t:s}=ee(),[i,o]=g.useState(!1),a=g.useRef(null);g.useEffect(()=>{if(!i)return;const h=f=>{a.current&&!a.current.contains(f.target)&&o(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]);const l=_8[t],d=t==="skip"&&l.includes("install")&&e.reasonCode!==void 0&&I8.has(e.reasonCode);return(n?d||t!=="skip":l.length>0)?c.jsxs("div",{ref:a,className:"relative shrink-0",children:[c.jsx("button",{type:"button",onClick:()=>o(h=>!h),"aria-label":"More actions","aria-haspopup":"true","aria-expanded":i,className:"dash-focus-ring p-1 rounded text-dash-text-muted hover:text-dash-text hover:bg-dash-surface-hover transition-colors",children:c.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:c.jsx("path",{d:"M10 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4z"})})}),i&&c.jsxs("div",{className:"absolute right-0 top-6 z-10 min-w-[140px] bg-dash-surface border border-dash-border rounded-lg shadow-lg py-1",children:[n&&(d||t!=="skip")&&c.jsx("button",{type:"button",onClick:()=>{r("execute"),o(!1)},className:"w-full px-3 py-1.5 text-xs text-left text-dash-text hover:bg-dash-surface-hover",children:s("migrateFlip_moveToInstall")}),!n&&c.jsx("button",{type:"button",onClick:()=>{r("skip"),o(!1)},className:"w-full px-3 py-1.5 text-xs text-left text-dash-text hover:bg-dash-surface-hover",children:s("migrateFlip_moveToSkip")}),!n&&t==="skip"&&d&&c.jsx("button",{type:"button",onClick:()=>{r("execute"),o(!1)},className:"w-full px-3 py-1.5 text-xs text-left text-dash-text hover:bg-dash-surface-hover",children:s("migrateFlip_moveToInstall")})]})]}):null};var G8=function(e){return typeof window<"u"?matchMedia&&matchMedia("(prefers-color-scheme: ".concat(e,")")):{matches:!1}},lf,q8=g.createContext({appearance:"light",setAppearance:function(){},isDarkMode:!1,themeMode:"light",setThemeMode:function(){},browserPrefers:(lf=G8("dark"))!==null&&lf!==void 0&&lf.matches?"dark":"light"}),Y8=function(){return g.useContext(q8)};const rC=(t,e)=>{if(e)return"row";switch(t){case"horizontal":return"row";case"horizontal-reverse":return"row-reverse";case"vertical":default:return"column";case"vertical-reverse":return"column-reverse"}},X8=t=>{if(t)return["space-between","space-around","space-evenly"].includes(t)},Z8=(t,e)=>rC(t,e)==="row",wi=t=>typeof t=="number"?`${t}px`:t,Q8=({visible:t,flex:e,gap:n,direction:r,horizontal:s,align:i,justify:o,distribution:a,height:l,width:d,padding:u,paddingInline:h,paddingBlock:f,prefixCls:p,as:m="div",className:x,style:b,children:y,wrap:k,ref:v,...w})=>{const C=o||a,S=Z8(r,s)&&!d&&X8(C)?"100%":wi(d),P={...e!==void 0?{"--lobe-flex":String(e)}:{},...r||s?{"--lobe-flex-direction":rC(r,s)}:{},...k!==void 0?{"--lobe-flex-wrap":k}:{},...C!==void 0?{"--lobe-flex-justify":C}:{},...i!==void 0?{"--lobe-flex-align":i}:{},...S!==void 0?{"--lobe-flex-width":S}:{},...l!==void 0?{"--lobe-flex-height":wi(l)}:{},...u!==void 0?{"--lobe-flex-padding":wi(u)}:{},...h!==void 0?{"--lobe-flex-padding-inline":wi(h)}:{},...f!==void 0?{"--lobe-flex-padding-block":wi(f)}:{},...n!==void 0?{"--lobe-flex-gap":wi(n)}:{},...b},D="lobe-flex",A=[D,t===!1?`${D}--hidden`:void 0,p?`${p}-flex`:void 0,x].filter(Boolean).join(" ");return c.jsx(m,{ref:v,...w,className:A,style:P,children:y})};var sC=g.memo(Q8);const J8=({children:t,ref:e,...n})=>c.jsx(sC,{...n,align:"center",justify:"center",ref:e,children:t});var e_=J8;const t_=/\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;function n_(t){return Array.from(t.match(t_)??[])}function r_(t){return n_(t).map(n=>n.toLowerCase()).join("-")}var iC={exports:{}},oC={};/**
273
273
  * @license React
274
274
  * use-sync-external-store-shim.production.js
@@ -71,7 +71,7 @@
71
71
  background: var(--dash-text-muted);
72
72
  }
73
73
  </style>
74
- <script type="module" crossorigin src="/assets/index-DyvVqUTe.js"></script>
74
+ <script type="module" crossorigin src="/assets/index-CBunI942.js"></script>
75
75
  <link rel="modulepreload" crossorigin href="/assets/vendor-BkC4CYzM.js">
76
76
  <link rel="stylesheet" crossorigin href="/assets/index-CRtJwrzd.css">
77
77
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudekit-cli",
3
- "version": "3.41.4-dev.50",
3
+ "version": "3.41.4-dev.51",
4
4
  "description": "CLI tool for bootstrapping and updating ClaudeKit projects",
5
5
  "type": "module",
6
6
  "repository": {