kakidash 0.1.0 → 0.1.1
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/README.ja.md +4 -1
- package/README.md +4 -1
- package/dist/index.d.ts +20 -2
- package/dist/kakidash.cjs +4 -4
- package/dist/kakidash.es.js +550 -260
- package/dist/kakidash.umd.js +4 -4
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -22,6 +22,7 @@ Kakidashのミッションは、**アウトプット速度の最大化**です
|
|
|
22
22
|
- フォントサイズ変更
|
|
23
23
|
- 太字 (Bold)、斜体 (Italic)
|
|
24
24
|
- カラーパレットによる色変更 (Style Editor)
|
|
25
|
+
- **アイコン設定**: コマンドパレットからのフラットアイコン追加・削除 (`m` key)
|
|
25
26
|
- **インタラクション**:
|
|
26
27
|
- ドラッグ&ドロップによるノード移動・並び替え
|
|
27
28
|
- キーボードショートカットによる高速操作
|
|
@@ -194,6 +195,7 @@ kakidash.setTheme('custom');
|
|
|
194
195
|
- **`kakidash.redo()`**: 元に戻した変更をやり直します。
|
|
195
196
|
- **`kakidash.toggleFold(nodeId)`**: ノードの折り畳み/展開を切り替えます。
|
|
196
197
|
- **`kakidash.getSelectedNodeId()`**: 現在選択されているノードのIDを取得します。
|
|
198
|
+
- **`kakidash.updateNode(nodeId, { topic?, style?, icon? })`**: ノードを更新します。`icon` にはアイコンID ('check', 'star' など) を指定します。
|
|
197
199
|
- **`kakidash.on(event, listener)`**: イベントリスナーを登録します。
|
|
198
200
|
- **`kakidash.off(event, listener)`**: イベントリスナーを削除します。
|
|
199
201
|
|
|
@@ -204,7 +206,7 @@ kakidash.setTheme('custom');
|
|
|
204
206
|
| `node:select` | `string \| null` | ノードが選択されたときに発火します。 |
|
|
205
207
|
| `node:add` | `{ id: string; topic: string }` | 新しいノードが追加されたときに発火します。 |
|
|
206
208
|
| `node:remove` | `string` | ノードが削除されたときに発火します。 |
|
|
207
|
-
| `node:update` | `{ id: string; topic
|
|
209
|
+
| `node:update` | `{ id: string; topic?: string; icon?: string }` | ノードが更新されたときに発火します。 |
|
|
208
210
|
| `node:move` | `{ nodeId: string; newParentId: string; position?: string }` | ノードが移動されたときに発火します。 |
|
|
209
211
|
| `model:load` | `MindMapData` | データがロードされたときに発火します。 |
|
|
210
212
|
| `model:change` | `void` | データモデルが変更されたときに発火します。 |
|
|
@@ -309,6 +311,7 @@ const kakidash = new Kakidash(container, {
|
|
|
309
311
|
### General
|
|
310
312
|
| Key | Description |
|
|
311
313
|
| --- | --- |
|
|
314
|
+
| `m` | コマンドパレット (検索 / アイコン) |
|
|
312
315
|
| `Arrow Keys` | ノード間の移動 |
|
|
313
316
|
| `h` / `j` / `k` / `l` | ノード間の移動 (Vim風) |
|
|
314
317
|
| `F2` / `DblClick` / `Space` | ノードの編集を開始 (画像の場合はズーム) |
|
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ Master the shortcuts and expand your mind map at the speed of thought.
|
|
|
20
20
|
- Font size adjustment.
|
|
21
21
|
- Bold (`Bold`), Italic (`Italic`).
|
|
22
22
|
- Color changes via palette (Style Editor).
|
|
23
|
+
- **Icon Settings**: Add/Remove flat icons via Command Palette (`m` key).
|
|
23
24
|
- **Interaction**:
|
|
24
25
|
- Drag and drop for node movement and reordering.
|
|
25
26
|
- Keyboard shortcuts for rapid operation.
|
|
@@ -188,6 +189,7 @@ All values accept standard CSS strings.
|
|
|
188
189
|
- **`kakidash.redo()`**: Redo the last undone change.
|
|
189
190
|
- **`kakidash.toggleFold(nodeId)`**: Toggle fold state of a node.
|
|
190
191
|
- **`kakidash.getSelectedNodeId()`**: Get the ID of the currently selected node.
|
|
192
|
+
- **`kakidash.updateNode(nodeId, { topic?, style?, icon? })`**: Updates a node property. `icon` accepts an icon ID (e.g., 'check').
|
|
191
193
|
- **`kakidash.on(event, listener)`**: Register an event listener.
|
|
192
194
|
- **`kakidash.off(event, listener)`**: Remove an event listener.
|
|
193
195
|
|
|
@@ -198,7 +200,7 @@ All values accept standard CSS strings.
|
|
|
198
200
|
| `node:select` | `string \| null` | Fired when a node is selected. |
|
|
199
201
|
| `node:add` | `{ id: string; topic: string }` | Fired when a new node is added. |
|
|
200
202
|
| `node:remove` | `string` | Fired when a node is removed. |
|
|
201
|
-
| `node:update` | `{ id: string; topic
|
|
203
|
+
| `node:update` | `{ id: string; topic?: string; icon?: string }` | Fired when a node is updated. |
|
|
202
204
|
| `node:move` | `{ nodeId: string; newParentId: string; position?: string }` | Fired when a node is moved. |
|
|
203
205
|
| `model:load` | `MindMapData` | Fired when data is loaded. |
|
|
204
206
|
| `model:change` | `void` | Fired when the data model changes. |
|
|
@@ -303,6 +305,7 @@ Here is the complete default configuration. You can partially override these key
|
|
|
303
305
|
### General
|
|
304
306
|
| Key | Description |
|
|
305
307
|
| --- | --- |
|
|
308
|
+
| `m` | Command Palette (Search / Icons) |
|
|
306
309
|
| `Arrow Keys` | Navigate between nodes |
|
|
307
310
|
| `h` / `j` / `k` / `l` | Navigate between nodes (Vim-style) |
|
|
308
311
|
| `F2` / `DblClick` / `Space` | Start editing node (Space triggers zoom if image) |
|
package/dist/index.d.ts
CHANGED
|
@@ -21,10 +21,26 @@ export declare class Kakidash extends TypedEventEmitter<KakidashEventMap> {
|
|
|
21
21
|
updateNode(nodeId: string, updates: {
|
|
22
22
|
topic?: string;
|
|
23
23
|
style?: Partial<NodeStyle>;
|
|
24
|
+
icon?: string;
|
|
24
25
|
}): void;
|
|
25
26
|
undo(): void;
|
|
26
27
|
redo(): void;
|
|
27
28
|
toggleFold(nodeId: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Toggles the visibility of the command palette.
|
|
31
|
+
*/
|
|
32
|
+
toggleCommandPalette(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Opens the command palette (alias for toggleCommandPalette).
|
|
35
|
+
*/
|
|
36
|
+
openCommandPalette(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Searches for nodes matching the query string.
|
|
39
|
+
* Performs a case-insensitive, partial match search.
|
|
40
|
+
* @param query The search string.
|
|
41
|
+
* @returns An array of matching Node objects.
|
|
42
|
+
*/
|
|
43
|
+
searchNodes(query: string): Node_2[];
|
|
28
44
|
getSelectedNodeId(): string | null;
|
|
29
45
|
updateNodeStyle(nodeId: string, style: Partial<NodeStyle>): void;
|
|
30
46
|
setTheme(theme: Theme): void;
|
|
@@ -139,6 +155,7 @@ declare interface MindMapNodeData {
|
|
|
139
155
|
parentId?: string;
|
|
140
156
|
image?: string;
|
|
141
157
|
layoutSide?: 'left' | 'right';
|
|
158
|
+
icon?: string;
|
|
142
159
|
}
|
|
143
160
|
|
|
144
161
|
declare interface MindMapStyles {
|
|
@@ -171,7 +188,8 @@ declare class Node_2 {
|
|
|
171
188
|
image?: string;
|
|
172
189
|
layoutSide?: 'left' | 'right';
|
|
173
190
|
isFolded: boolean;
|
|
174
|
-
|
|
191
|
+
icon?: string;
|
|
192
|
+
constructor(id: string, topic: string, parentId?: string | null, isRoot?: boolean, image?: string, layoutSide?: 'left' | 'right', isFolded?: boolean, icon?: string);
|
|
175
193
|
addChild(node: Node_2): void;
|
|
176
194
|
insertChild(node: Node_2, index: number): void;
|
|
177
195
|
removeChild(nodeId: string): void;
|
|
@@ -186,7 +204,7 @@ declare interface NodeStyle {
|
|
|
186
204
|
fontStyle?: string;
|
|
187
205
|
}
|
|
188
206
|
|
|
189
|
-
declare type ShortcutAction = 'navUp' | 'navDown' | 'navLeft' | 'navRight' | 'addChild' | 'insertParent' | 'addSibling' | 'addSiblingBefore' | 'deleteNode' | 'beginEdit' | 'copy' | 'paste' | 'cut' | 'undo' | 'redo' | 'bold' | 'italic' | 'zoomIn' | 'zoomOut' | 'scaleUp' | 'scaleDown' | 'resetZoom' | 'toggleFold' | 'centerMap' | 'selectColor1' | 'selectColor2' | 'selectColor3' | 'selectColor4' | 'selectColor5' | 'selectColor6' | 'selectColor7';
|
|
207
|
+
declare type ShortcutAction = 'navUp' | 'navDown' | 'navLeft' | 'navRight' | 'addChild' | 'insertParent' | 'addSibling' | 'addSiblingBefore' | 'deleteNode' | 'beginEdit' | 'copy' | 'paste' | 'cut' | 'undo' | 'redo' | 'bold' | 'italic' | 'zoomIn' | 'zoomOut' | 'scaleUp' | 'scaleDown' | 'resetZoom' | 'toggleFold' | 'centerMap' | 'selectColor1' | 'selectColor2' | 'selectColor3' | 'selectColor4' | 'selectColor5' | 'selectColor6' | 'selectColor7' | 'openCommandPalette';
|
|
190
208
|
|
|
191
209
|
export declare type ShortcutConfig = Partial<Record<ShortcutAction, KeyBinding[]>>;
|
|
192
210
|
|
package/dist/kakidash.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class E{root;theme="default";constructor(e){this.root=e}findNode(e){return this.findNodeRecursive(this.root,e)}findNodeRecursive(e,t){if(e.id===t)return e;for(const i of e.children){const o=this.findNodeRecursive(i,t);if(o)return o}return null}moveNode(e,t){const i=this.findNode(e),o=this.findNode(t);if(!i||!o||i.isRoot||i.parentId===t||this.isDescendant(i,t))return!1;if(i.parentId){const s=this.findNode(i.parentId);s&&s.removeChild(e)}return o.addChild(i),!0}addSibling(e,t,i){const o=this.findNode(e);if(!o||!o.parentId)return!1;const s=this.findNode(o.parentId);if(!s)return!1;const n=s.children.findIndex(l=>l.id===e);if(n===-1)return!1;const d=i==="before"?n:n+1;return s.insertChild(t,d),!0}insertParent(e,t){const i=this.findNode(e);if(!i||!i.parentId)return!1;const o=this.findNode(i.parentId);if(!o)return!1;const s=o.children.findIndex(n=>n.id===e);return s===-1?!1:(o.removeChild(e),o.insertChild(t,s),t.addChild(i),!0)}isDescendant(e,t){if(e.id===t)return!0;for(const i of e.children)if(this.isDescendant(i,t))return!0;return!1}}class b{id;topic;children;style;parentId;isRoot;image;layoutSide;isFolded;constructor(e,t,i=null,o=!1,s,n,d=!1){this.id=e,this.topic=t,this.children=[],this.style={fontSize:o?"24px":"16px"},this.parentId=i,this.isRoot=o,this.image=s,this.layoutSide=n,this.isFolded=d}addChild(e){e.parentId=this.id,this.children.push(e)}insertChild(e,t){e.parentId=this.id,t>=0&&t<=this.children.length?this.children.splice(t,0,e):this.children.push(e)}removeChild(e){this.children=this.children.filter(t=>t.id!==e)}updateTopic(e){this.topic=e}}class I{past=[];future=[];maxHistorySize;constructor(e=10){this.maxHistorySize=e}push(e){this.past.push(e),this.past.length>this.maxHistorySize&&this.past.shift(),this.future=[]}undo(e){if(this.past.length===0)return null;const t=this.past.pop();return t?(this.future.push(e),t):null}get canUndo(){return this.past.length>0}redo(e){if(this.future.length===0)return null;const t=this.future.pop();return t?(this.past.push(e),this.past.length>this.maxHistorySize&&this.past.shift(),t):null}get canRedo(){return this.future.length>0}clear(){this.past=[],this.future=[]}}class M{mindMap;historyManager;idGenerator;constructor(e,t){this.mindMap=e,this.historyManager=new I(10),this.idGenerator=t}saveState(){this.historyManager.push(this.exportData())}undo(){const e=this.historyManager.undo(this.exportData());return e?(this.importData(e),!0):!1}redo(){const e=this.historyManager.redo(this.exportData());return e?(this.importData(e),!0):!1}get canUndo(){return this.historyManager.canUndo}get canRedo(){return this.historyManager.canRedo}addNode(e,t="New topic",i){const o=this.mindMap.findNode(e);if(!o)return null;this.saveState();const s=this.idGenerator.generate(),n=new b(s,t,null,!1,void 0,i,!1);return o.addChild(n),n}addImageNode(e,t){const i=this.mindMap.findNode(e);if(!i)return null;this.saveState();const o=this.idGenerator.generate(),s=new b(o,"",e,!1,t,void 0,!1);return i.addChild(s),s}removeNode(e,t=!0){const i=this.mindMap.findNode(e);if(!i||i.isRoot||!i.parentId)return!1;const o=this.mindMap.findNode(i.parentId);return o?(t&&this.saveState(),o.removeChild(e),!0):!1}updateNodeTopic(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),i.updateTopic(t),!0):!1}updateNodeStyle(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),i.style={...i.style,...t},!0):!1}toggleNodeFold(e){const t=this.mindMap.findNode(e);return t?t.children.length===0&&!t.isFolded?!1:(this.saveState(),t.isFolded=!t.isFolded,!0):!1}setTheme(e){this.mindMap.theme!==e&&(this.saveState(),this.mindMap.theme=e)}moveNode(e,t,i){const o=this.mindMap.findNode(e);if(o&&o.parentId===t)return i&&o.layoutSide!==i?(this.saveState(),o.layoutSide=i,!0):!1;if(!o)return!1;if(this.saveState(),this.mindMap.moveNode(e,t)){if(i){const s=this.mindMap.findNode(e);s&&(s.layoutSide=i)}return!0}return!1}addSibling(e,t,i="New topic"){const o=this.mindMap.findNode(e);if(!o||!o.parentId)return null;this.saveState();const s=this.idGenerator.generate(),n=new b(s,i);return this.mindMap.addSibling(e,n,t)?n:null}reorderNode(e,t,i){const o=this.mindMap.findNode(e),s=this.mindMap.findNode(t);if(!o||!s||!s.parentId||o.id===s.id||o.isRoot)return!1;const n=this.mindMap.findNode(s.parentId);if(!n)return!1;if(this.saveState(),o.parentId!==n.id){let r=n;for(;r.parentId;){if(r.id===o.id)return!1;if(!r.parentId)break;const h=this.mindMap.findNode(r.parentId);if(!h)break;r=h}}if(o.parentId&&o.parentId!==n.id){const r=this.mindMap.findNode(o.parentId);r&&r.removeChild(o.id),o.parentId=n.id}else o.parentId===n.id&&n.removeChild(o.id);const d=n.children.findIndex(r=>r.id===t);if(d===-1)return n.addChild(o),!0;const l=i==="before"?d:d+1;return n.insertChild(o,l),n.isRoot&&s.layoutSide&&(o.layoutSide=s.layoutSide),!0}insertNodeAsParent(e,t){const i=this.mindMap.findNode(e),o=this.mindMap.findNode(t);if(!i||!o||!o.parentId||i.id===o.id)return!1;const s=this.mindMap.findNode(o.parentId);if(!s)return!1;let n=s;for(;n;){if(n.id===i.id)return!1;if(!n.parentId)break;n=this.mindMap.findNode(n.parentId)}if(this.saveState(),i.parentId){const l=this.mindMap.findNode(i.parentId);l&&l.removeChild(i.id)}const d=s.children.findIndex(l=>l.id===t);return d===-1?!1:(s.isRoot&&o.layoutSide&&(i.layoutSide=o.layoutSide),s.removeChild(t),s.insertChild(i,d),i.parentId=s.id,i.addChild(o),!0)}insertParent(e,t="New topic"){const i=this.mindMap.findNode(e);if(!i||!i.parentId)return null;this.saveState();const o=this.idGenerator.generate(),s=new b(o,t);return this.mindMap.insertParent(e,s)?s:null}clipboard=null;copyNode(e){const t=this.mindMap.findNode(e);t&&(this.clipboard=this.deepCloneNode(t),navigator.clipboard&&navigator.clipboard.writeText(t.topic).catch(i=>{console.error("Failed to write to clipboard",i)}))}cutNode(e){const t=this.mindMap.findNode(e);t&&!t.isRoot&&t.parentId&&(this.copyNode(e),this.removeNode(e))}pasteNode(e){if(!this.clipboard)return null;const t=this.mindMap.findNode(e);if(!t)return null;this.saveState();const i=this.deepCloneNode(this.clipboard);return this.regenerateIds(i),t.addChild(i),i}deepCloneNode(e){const t=new b(e.id,e.topic,null,!1,e.image,e.layoutSide,e.isFolded);return t.style={...e.style},t.children=e.children.map(i=>this.deepCloneNode(i)),t.children.forEach(i=>i.parentId=t.id),t}regenerateIds(e){e.id=this.idGenerator.generate(),e.children.forEach(t=>{t.parentId=e.id,this.regenerateIds(t)})}exportData(){const e=t=>({id:t.id,topic:t.topic,root:t.isRoot||void 0,children:t.children.length>0?t.children.map(e):void 0,style:Object.keys(t.style).length>0?t.style:void 0,image:t.image,layoutSide:t.layoutSide,isFolded:t.isFolded});return{nodeData:e(this.mindMap.root),theme:this.mindMap.theme}}importData(e){const t=(i,o=null)=>{const s=!!i.root,n=new b(i.id,i.topic,o,s,i.image,i.layoutSide,i.isFolded||!1);return i.style&&(n.style={...i.style}),i.children&&i.children.length>0&&i.children.forEach(d=>{const l=t(d,n.id);n.addChild(l)}),n};this.mindMap.root=t(e.nodeData),e.theme&&(this.mindMap.theme=e.theme)}}class w{container;svg;nodeContainer;options;maxWidth=-1;constructor(e,t={}){this.container=e,this.container.style.position="relative",this.container.style.width="100%",this.container.style.height="100%",this.container.style.overflow="hidden",this.container.style.backgroundColor="var(--vscode-editor-background, transparent)",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.position="absolute",this.svg.style.top="0",this.svg.style.left="0",this.svg.style.width="100%",this.svg.style.height="100%",this.svg.style.zIndex="0",this.svg.style.pointerEvents="none",this.svg.style.overflow="visible",this.svg.style.transformOrigin="0 0",this.container.appendChild(this.svg),this.nodeContainer=document.createElement("div"),this.nodeContainer.style.position="absolute",this.nodeContainer.style.top="0",this.nodeContainer.style.left="0",this.nodeContainer.style.width="100%",this.nodeContainer.style.height="100%",this.nodeContainer.style.zIndex="1",this.nodeContainer.style.transformOrigin="0 0",this.container.appendChild(this.nodeContainer),this.options=t}render(e,t=null,i="Right"){this.svg.innerHTML="",this.nodeContainer.innerHTML="",this.renderNode(e.root,0,this.container.clientHeight/2,t,i,!0,void 0,e)}updateTransform(e,t,i=1){const o=`translate(${e}px, ${t}px) scale(${i})`;this.svg.style.transform=o,this.nodeContainer.style.transform=o}static RAINBOW_PALETTE=["#E74C3C","#3498DB","#2ECC71","#F1C40F","#9B59B6","#E67E22","#1ABC9C"];getThemeColor(e,t){if(t.theme==="colorful"){if(e.isRoot)return"#333";let i=e;for(;i.parentId&&i.parentId!==t.root.id;){const n=t.findNode(i.parentId);if(!n)break;i=n}const s=t.root.children.findIndex(n=>n.id===i.id);if(s!==-1)return w.RAINBOW_PALETTE[s%w.RAINBOW_PALETTE.length]}return"#ccc"}renderNode(e,t,i,o,s,n,d="right",l){const r=document.createElement("div");if(r.dataset.id=e.id,r.style.position="absolute",r.style.left=`${t}px`,r.style.top=`${i}px`,e.image){const y=document.createElement("img");y.src=e.image,y.style.maxWidth="150px",y.style.maxHeight="150px",y.style.display="block",r.appendChild(y);const u=document.createElement("div");u.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--vscode-icon-foreground, #333)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><line x1="11" y1="8" x2="11" y2="14"></line><line x1="8" y1="11" x2="14" y2="11"></line></svg>',u.style.position="absolute",u.style.bottom="5px",u.style.right="5px",u.style.backgroundColor="var(--vscode-editor-background, rgba(255, 255, 255, 0.9))",u.style.borderRadius="50%",u.style.width="24px",u.style.height="24px",u.style.display="flex",u.style.justifyContent="center",u.style.alignItems="center",u.style.cursor="pointer",u.title="Zoom Image",u.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",r.appendChild(u),u.addEventListener("click",f=>{f.stopPropagation(),this.showImageModal(e.image)}),r.style.padding="5px"}else r.textContent=e.topic,this.maxWidth!==-1?(r.style.whiteSpace="pre-wrap",r.style.wordWrap="break-word",r.style.overflowWrap="anywhere",r.style.maxWidth=`${this.maxWidth}px`,r.style.width="max-content"):r.style.whiteSpace="pre";r.className="mindmap-node",e.isRoot||(r.draggable=!0),r.style.position="absolute",r.style.padding="8px 12px",e.image&&(r.style.padding="5px"),l?.theme==="custom"?e.isRoot?r.style.color="var(--mindmap-root-color, var(--vscode-editor-foreground, black))":r.style.color="var(--mindmap-child-color, var(--vscode-editor-foreground, black))":r.style.color="var(--vscode-editor-foreground, black)";const h=l?.theme||"default",a=l?this.getThemeColor(e,l):"#ccc";if(h==="simple"&&!e.isRoot)r.style.border="none";else if(h==="custom")if(e.isRoot){const y="2px solid var(--vscode-editor-foreground, #333)";r.style.border=`var(--mindmap-root-border, ${y})`}else r.style.border="var(--mindmap-child-border, 1px solid #ccc)";else h==="colorful"?r.style.border=`2px solid ${a}`:r.style.border="1px solid var(--vscode-editorGroup-border, #ccc)";r.style.borderRadius="4px",e.isRoot&&(r.style.fontSize="1.2em",r.style.fontWeight="bold",h!=="custom"&&(r.style.border="2px solid var(--vscode-editor-foreground, #333)")),e.style.color&&(r.style.color=e.style.color),e.style.fontSize&&(r.style.fontSize=e.style.fontSize),e.style.fontWeight&&(r.style.fontWeight=e.style.fontWeight),e.style.fontStyle&&(r.style.fontStyle=e.style.fontStyle),e.style.background?r.style.backgroundColor=e.style.background:h==="custom"?e.isRoot?r.style.backgroundColor="var(--mindmap-root-background, var(--vscode-editor-background, white))":r.style.backgroundColor="var(--mindmap-child-background, var(--vscode-editor-background, white))":r.style.backgroundColor="var(--vscode-editorWidget-background, var(--vscode-editor-background, white))";const{width:c}=this.measureNode(e);let p=t;if(d==="left"&&!n?p=t-c:n&&(p=t-c/2),r.style.left=`${p}px`,r.style.top=`${i}px`,r.style.transform="translate(0, -50%)",r.style.zIndex="10",r.style.cursor="default",r.style.userSelect="none",e.id===o&&(r.style.outline="2px solid var(--vscode-focusBorder, #007bff)",r.style.boxShadow="0 0 5px var(--vscode-focusBorder, rgba(0, 123, 255, 0.5))"),this.nodeContainer.appendChild(r),e.children.length===0)return;if(this.options.onToggleFold){const y=[];if(n&&s==="Both")y.push(p+c),y.push(p);else{let u=d==="right";n&&(s==="Left"?u=!1:u=!0),y.push(u?p+c:p)}y.forEach(u=>{const f=document.createElement("div");f.className="mindmap-toggle-btn",f.innerHTML=e.isFolded?"+":"-",f.style.position="absolute",f.style.width="16px",f.style.height="16px",f.style.fontSize="12px",f.style.lineHeight="14px",f.style.textAlign="center",f.style.borderRadius="50%",f.style.border="1px solid var(--vscode-widget-border, #999)",f.style.backgroundColor="var(--vscode-editor-background, #fff)",f.style.color="var(--vscode-editor-foreground, #000)",f.style.cursor="pointer",f.style.zIndex="11",f.style.userSelect="none";const v=0;f.style.left=`${u+v}px`,f.style.top=`${i}px`,f.style.transform="translate(-50%, -50%)",f.addEventListener("click",k=>{k.stopPropagation(),this.options.onToggleFold?.(e.id)}),this.nodeContainer.appendChild(f)})}if(e.isFolded)return;let g=[],m=[];n&&s==="Both"?e.children.forEach((y,u)=>{(y.layoutSide||(u%2===0?"right":"left"))==="right"?g.push(y):m.push(y)}):s==="Left"?m=e.children:s==="Right"?g=e.children:d==="left"?m=e.children:g=e.children,g.length>0&&this.renderChildrenStack(e,g,t,i,o,s,"right",c,l),m.length>0&&this.renderChildrenStack(e,m,t,i,o,s,"left",c,l)}renderChildrenStack(e,t,i,o,s,n,d,l,r){const h=t.reduce((g,m)=>g+this.getNodeHeight(m),0);let a=o-h/2;const c=80;let p=0;e.isRoot?p=d==="right"?i+l/2:i-l/2:d==="right"?p=i+l:(p=i,p=i-l),t.forEach(g=>{const m=this.getNodeHeight(g),y=a+m/2;let u=0;d==="right"?u=p+c:u=p-c,this.renderNode(g,u,y,s,n,!1,d,r);const f=r?this.getThemeColor(g,r):"#ccc";this.drawConnection(p,o,u,y,f,r?.theme),a+=m})}getChildrenHeight(e){return e.children.reduce((t,i)=>t+this.getNodeHeight(i),0)}getNodeHeight(e){const{height:t}=this.measureNode(e),i=20;if(e.children.length===0)return t+i;const o=this.getChildrenHeight(e);return Math.max(t+i,o)}measureNode(e){if(e.image)return{width:160,height:160};const t=document.createElement("div");t.textContent=e.topic,t.className="mindmap-node",t.style.visibility="hidden",t.style.position="absolute",this.maxWidth!==-1?(t.style.whiteSpace="pre-wrap",t.style.wordWrap="break-word",t.style.overflowWrap="anywhere",t.style.maxWidth=`${this.maxWidth}px`,t.style.width="max-content"):t.style.whiteSpace="pre",t.style.padding="8px 12px",t.style.border="1px solid var(--vscode-editorGroup-border, #ccc)",e.isRoot&&(t.style.fontSize="1.2em",t.style.fontWeight="bold",t.style.border="2px solid var(--vscode-editor-foreground, #333)"),e.style.color&&(t.style.color=e.style.color),e.style.fontSize&&(t.style.fontSize=e.style.fontSize),e.style.fontWeight&&(t.style.fontWeight=e.style.fontWeight),e.style.fontStyle&&(t.style.fontStyle=e.style.fontStyle),e.style.background&&(t.style.backgroundColor=e.style.background),this.nodeContainer.appendChild(t);const i=t.offsetWidth,o=t.offsetHeight;return this.nodeContainer.removeChild(t),{width:i||100,height:o||40}}drawConnection(e,t,i,o,s="#ccc",n="default"){const d=document.createElementNS("http://www.w3.org/2000/svg","path"),l=e+(i-e)/2,r=e+(i-e)/2,h=`M ${e} ${t} C ${l} ${t}, ${r} ${o}, ${i} ${o}`;d.setAttribute("d",h),n==="custom"?d.style.stroke=`var(--mindmap-connection-color, ${s})`:d.style.stroke=s,d.setAttribute("fill","none"),d.setAttribute("stroke-width","2"),this.svg.appendChild(d)}showImageModal(e){this.options.onImageZoom&&this.options.onImageZoom(!0);const t=document.createElement("div");t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100vw",t.style.height="100vh",t.style.backgroundColor="rgba(0,0,0,0.8)",t.style.zIndex="1000",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.cursor="zoom-out";const i=document.createElement("img");i.src=e,i.style.maxWidth="90%",i.style.maxHeight="90%",i.style.boxShadow="0 0 20px rgba(0,0,0,0.5)",t.appendChild(i),document.body.appendChild(t);let o;const s=()=>{document.body.contains(t)&&document.body.removeChild(t),o&&document.removeEventListener("keydown",o,!0),this.options.onImageZoom&&this.options.onImageZoom(!1),this.container.focus()};o=n=>{n.stopPropagation(),n.preventDefault(),s()},document.addEventListener("keydown",o,!0),t.addEventListener("click",()=>{s()})}}class C{container;editorEl;currentNodeId=null;onUpdate;static FONT_SIZES=[{label:"12px",value:"12px"},{label:"14px",value:"14px"},{label:"16px",value:"16px"},{label:"18px",value:"18px"},{label:"24px",value:"24px"},{label:"32px",value:"32px"},{label:"48px",value:"48px"}];static PALETTE=["#000000","#E74C3C","#E67E22","#F1C40F","#2ECC71","#3498DB","#9B59B6"];constructor(e){this.container=e,this.editorEl=this.createEditor(),this.container.appendChild(this.editorEl),this.editorEl.addEventListener("mousedown",t=>t.stopPropagation()),this.editorEl.addEventListener("click",t=>t.stopPropagation()),this.editorEl.addEventListener("dblclick",t=>t.stopPropagation())}createEditor(){const e=document.createElement("div");e.className="style-editor",e.style.position="absolute",e.style.top="20px",e.style.right="20px",e.style.display="none",e.style.backgroundColor="white",e.style.border="1px solid #eee",e.style.borderRadius="8px",e.style.padding="8px",e.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)",e.style.zIndex="2000",e.style.pointerEvents="auto",e.style.fontFamily="Arial, sans-serif",e.style.display="flex",e.style.flexDirection="column",e.style.gap="8px",e.style.margin="0",e.style.boxSizing="border-box",e.style.minWidth="220px";const t=document.createElement("div");t.style.display="flex",t.style.gap="8px",t.style.alignItems="center";const i=document.createElement("select");i.style.padding="4px 8px",i.style.borderRadius="4px",i.style.border="1px solid #ccc",i.style.fontSize="14px",i.style.flex="1",C.FONT_SIZES.forEach(h=>{const a=document.createElement("option");a.value=h.value,a.textContent=h.label,i.appendChild(a)}),i.onchange=h=>{this.currentNodeId&&this.onUpdate&&this.onUpdate(this.currentNodeId,{fontSize:h.target.value})},t.appendChild(i);const s=(h,a,c)=>{const p=document.createElement("button");return p.textContent=h,p.style.width="32px",p.style.height="32px",p.style.padding="0",p.style.display="flex",p.style.justifyContent="center",p.style.alignItems="center",p.style.border="1px solid #ddd",p.style.backgroundColor="#f5f5f5",p.style.borderRadius="4px",p.style.cursor="pointer",p.style.fontSize="14px",a&&(p.style[a]=a==="fontWeight"?"bold":"italic"),p.onclick=c,p},n=s("B","fontWeight",()=>{if(this.currentNodeId&&this.onUpdate){const h=n.classList.contains("active"),a=h?"normal":"bold";this.onUpdate(this.currentNodeId,{fontWeight:a}),this.updateButtonState(n,!h)}}),d=s("I","fontStyle",()=>{if(this.currentNodeId&&this.onUpdate){const h=d.classList.contains("active"),a=h?"normal":"italic";this.onUpdate(this.currentNodeId,{fontStyle:a}),this.updateButtonState(d,!h)}});t.appendChild(n),t.appendChild(d),e.appendChild(t);const l=document.createElement("div");l.style.display="flex",l.style.gap="4px",l.style.alignItems="center",l.style.justifyContent="space-between";const r=document.createElement("input");return r.type="color",r.style.width="24px",r.style.height="24px",r.style.border="1px solid #ccc",r.style.padding="0",r.style.backgroundColor="transparent",r.style.cursor="pointer",r.style.appearance="none",r.onchange=h=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:h.target.value}),this.updateActivePaletteItem(h.target.value))},C.PALETTE.forEach((h,a)=>{const c=document.createElement("div");c.className="color-swatch",c.dataset.color=h,c.textContent=(a+1).toString(),c.style.width="24px",c.style.height="24px",c.style.backgroundColor=h,c.style.borderRadius="4px",c.style.cursor="pointer",c.style.border="1px solid transparent",c.style.color=h==="#F1C40F"?"black":"white",c.style.fontSize="12px",c.style.fontWeight="bold",c.style.display="flex",c.style.justifyContent="center",c.style.alignItems="center",c.onclick=()=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:h}),r.value=h,this.updateActivePaletteItem(h))},l.appendChild(c)}),l.appendChild(r),e.appendChild(l),e}updateActivePaletteItem(e){this.editorEl.querySelectorAll(".color-swatch").forEach(i=>{const o=i;o.dataset.color?.toLowerCase()===e.toLowerCase()?(o.style.border="2px solid #ccc",o.style.transform="scale(1.1)"):(o.style.border="1px solid transparent",o.style.transform="scale(1)")})}updateButtonState(e,t){t?(e.classList.add("active"),e.style.backgroundColor="#e0e0e0",e.style.borderColor="#999"):(e.classList.remove("active"),e.style.backgroundColor="#f5f5f5",e.style.borderColor="#ddd")}show(e,t){this.currentNodeId=e,this.editorEl.style.display="flex";const i=this.editorEl.querySelector("select");i.value=t.fontSize||"";const o=this.editorEl.querySelector('input[type="color"]'),s=t.color||"#000000";o.value=s,this.updateActivePaletteItem(s);const n=this.editorEl.querySelectorAll("button")[0];this.updateButtonState(n,t.fontWeight==="bold");const d=this.editorEl.querySelectorAll("button")[1];this.updateButtonState(d,t.fontStyle==="italic")}hide(){this.editorEl.style.display="none",this.currentNodeId=null}}class B{container;element;options;currentMode="Right";currentTheme="default";layoutButtons=new Map;themeButtons=new Map;constructor(e,t){this.container=e,this.options=t,this.element=document.createElement("div"),this.render()}render(){this.element.style.position="absolute",this.element.style.top="20px",this.element.style.left="20px",this.element.style.display="flex",this.element.style.flexDirection="column",this.element.style.backgroundColor="white",this.element.style.borderRadius="8px",this.element.style.boxShadow="0 2px 10px rgba(0,0,0,0.1)",this.element.style.padding="5px",this.element.style.zIndex="2000",this.element.style.gap="5px",this.element.style.pointerEvents="auto",this.element.addEventListener("click",e=>e.stopPropagation()),this.element.addEventListener("mousedown",e=>e.stopPropagation()),this.createLayoutButton("Right",this.getRightIcon()),this.createLayoutButton("Left",this.getLeftIcon()),this.createLayoutButton("Both",this.getBothIcon()),this.addSeparator(),this.createThemeButton("default",this.getThemeDefaultIcon()),this.createThemeButton("simple",this.getThemeSimpleIcon()),this.createThemeButton("colorful",this.getThemeColorfulIcon()),this.createThemeButton("custom",this.getThemeCustomIcon()),this.addSeparator(),this.createIconActionButton("Reset Zoom",this.getZoomResetIcon(),()=>{this.options.onZoomReset&&this.options.onZoomReset()}),this.addSeparator(),this.createIconActionButton("Shortcuts Help",this.getHelpIcon(),()=>{this.options.onShowShortcuts&&this.options.onShowShortcuts()}),this.container.appendChild(this.element),this.updateActiveButtons()}addSeparator(){const e=document.createElement("div");e.style.height="1px",e.style.backgroundColor="#ccc",e.style.margin="5px 2px",this.element.appendChild(e)}createLayoutButton(e,t){const i=document.createElement("button");i.innerHTML=t,this.styleButton(i),i.title=`Layout: ${e}`,i.addEventListener("click",()=>{this.setMode(e)}),this.element.appendChild(i),this.layoutButtons.set(e,i)}createThemeButton(e,t){const i=document.createElement("button");i.innerHTML=t,this.styleButton(i),i.title=`Theme: ${e}`,i.addEventListener("click",()=>{this.setTheme(e)}),this.element.appendChild(i),this.themeButtons.set(e,i)}createIconActionButton(e,t,i){const o=document.createElement("button");o.innerHTML=t,this.styleButton(o),o.title=e,o.addEventListener("click",i),this.element.appendChild(o)}styleButton(e){e.style.width="32px",e.style.height="32px",e.style.border="none",e.style.background="transparent",e.style.cursor="pointer",e.style.borderRadius="4px",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.style.color="#555"}updateActiveButtons(){this.layoutButtons.forEach((e,t)=>{t===this.currentMode?(e.style.backgroundColor="#e6f7ff",e.style.color="#007bff"):(e.style.backgroundColor="transparent",e.style.color="#555")}),this.themeButtons.forEach((e,t)=>{t===this.currentTheme?(e.style.backgroundColor="#e6f7ff",e.style.color="#007bff"):(e.style.backgroundColor="transparent",e.style.color="#555")})}setMode(e){this.currentMode!==e&&(this.currentMode=e,this.updateActiveButtons(),this.options.onLayoutChange(e))}setTheme(e){this.currentTheme!==e&&(this.currentTheme=e,this.updateActiveButtons(),this.options.onThemeChange(e))}getRightIcon(){return`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class k{root;theme="default";constructor(e){this.root=e}findNode(e){return this.findNodeRecursive(this.root,e)}findNodeRecursive(e,t){if(e.id===t)return e;for(const i of e.children){const o=this.findNodeRecursive(i,t);if(o)return o}return null}moveNode(e,t){const i=this.findNode(e),o=this.findNode(t);if(!i||!o||i.isRoot||i.parentId===t||this.isDescendant(i,t))return!1;if(i.parentId){const s=this.findNode(i.parentId);s&&s.removeChild(e)}return o.addChild(i),!0}addSibling(e,t,i){const o=this.findNode(e);if(!o||!o.parentId)return!1;const s=this.findNode(o.parentId);if(!s)return!1;const n=s.children.findIndex(a=>a.id===e);if(n===-1)return!1;const r=i==="before"?n:n+1;return s.insertChild(t,r),!0}insertParent(e,t){const i=this.findNode(e);if(!i||!i.parentId)return!1;const o=this.findNode(i.parentId);if(!o)return!1;const s=o.children.findIndex(n=>n.id===e);return s===-1?!1:(o.removeChild(e),o.insertChild(t,s),t.addChild(i),!0)}isDescendant(e,t){if(e.id===t)return!0;for(const i of e.children)if(this.isDescendant(i,t))return!0;return!1}}class x{id;topic;children;style;parentId;isRoot;image;layoutSide;isFolded;icon;constructor(e,t,i=null,o=!1,s,n,r=!1,a){this.id=e,this.topic=t,this.children=[],this.style={fontSize:o?"24px":"16px"},this.parentId=i,this.isRoot=o,this.image=s,this.layoutSide=n,this.isFolded=r,this.icon=a}addChild(e){e.parentId=this.id,this.children.push(e)}insertChild(e,t){e.parentId=this.id,t>=0&&t<=this.children.length?this.children.splice(t,0,e):this.children.push(e)}removeChild(e){this.children=this.children.filter(t=>t.id!==e)}updateTopic(e){this.topic=e}}class M{past=[];future=[];maxHistorySize;constructor(e=10){this.maxHistorySize=e}push(e){this.past.push(e),this.past.length>this.maxHistorySize&&this.past.shift(),this.future=[]}undo(e){if(this.past.length===0)return null;const t=this.past.pop();return t?(this.future.push(e),t):null}get canUndo(){return this.past.length>0}redo(e){if(this.future.length===0)return null;const t=this.future.pop();return t?(this.past.push(e),this.past.length>this.maxHistorySize&&this.past.shift(),t):null}get canRedo(){return this.future.length>0}clear(){this.past=[],this.future=[]}}class B{mindMap;historyManager;idGenerator;constructor(e,t){this.mindMap=e,this.historyManager=new M(10),this.idGenerator=t}saveState(){this.historyManager.push(this.exportData())}undo(){const e=this.historyManager.undo(this.exportData());return e?(this.importData(e),!0):!1}redo(){const e=this.historyManager.redo(this.exportData());return e?(this.importData(e),!0):!1}get canUndo(){return this.historyManager.canUndo}get canRedo(){return this.historyManager.canRedo}addNode(e,t="New topic",i){const o=this.mindMap.findNode(e);if(!o)return null;this.saveState();const s=this.idGenerator.generate(),n=new x(s,t,null,!1,void 0,i,!1);return o.addChild(n),n}addImageNode(e,t){const i=this.mindMap.findNode(e);if(!i)return null;this.saveState();const o=this.idGenerator.generate(),s=new x(o,"",e,!1,t,void 0,!1);return i.addChild(s),s}removeNode(e,t=!0){const i=this.mindMap.findNode(e);if(!i||i.isRoot||!i.parentId)return!1;const o=this.mindMap.findNode(i.parentId);return o?(t&&this.saveState(),o.removeChild(e),!0):!1}updateNodeTopic(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),i.updateTopic(t),!0):!1}updateNodeStyle(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),i.style={...i.style,...t},!0):!1}toggleNodeFold(e){const t=this.mindMap.findNode(e);return t?t.children.length===0&&!t.isFolded?!1:(this.saveState(),t.isFolded=!t.isFolded,!0):!1}setTheme(e){this.mindMap.theme!==e&&(this.saveState(),this.mindMap.theme=e)}moveNode(e,t,i){const o=this.mindMap.findNode(e);if(o&&o.parentId===t)return i&&o.layoutSide!==i?(this.saveState(),o.layoutSide=i,!0):!1;if(!o)return!1;if(this.saveState(),this.mindMap.moveNode(e,t)){if(i){const s=this.mindMap.findNode(e);s&&(s.layoutSide=i)}return!0}return!1}addSibling(e,t,i="New topic"){const o=this.mindMap.findNode(e);if(!o||!o.parentId)return null;this.saveState();const s=this.idGenerator.generate(),n=new x(s,i);return this.mindMap.addSibling(e,n,t)?n:null}reorderNode(e,t,i){const o=this.mindMap.findNode(e),s=this.mindMap.findNode(t);if(!o||!s||!s.parentId||o.id===s.id||o.isRoot)return!1;const n=this.mindMap.findNode(s.parentId);if(!n)return!1;if(this.saveState(),o.parentId!==n.id){let l=n;for(;l.parentId;){if(l.id===o.id)return!1;if(!l.parentId)break;const h=this.mindMap.findNode(l.parentId);if(!h)break;l=h}}if(o.parentId&&o.parentId!==n.id){const l=this.mindMap.findNode(o.parentId);l&&l.removeChild(o.id),o.parentId=n.id}else o.parentId===n.id&&n.removeChild(o.id);const r=n.children.findIndex(l=>l.id===t);if(r===-1)return n.addChild(o),!0;const a=i==="before"?r:r+1;return n.insertChild(o,a),n.isRoot&&s.layoutSide&&(o.layoutSide=s.layoutSide),!0}insertNodeAsParent(e,t){const i=this.mindMap.findNode(e),o=this.mindMap.findNode(t);if(!i||!o||!o.parentId||i.id===o.id)return!1;const s=this.mindMap.findNode(o.parentId);if(!s)return!1;let n=s;for(;n;){if(n.id===i.id)return!1;if(!n.parentId)break;n=this.mindMap.findNode(n.parentId)}if(this.saveState(),i.parentId){const a=this.mindMap.findNode(i.parentId);a&&a.removeChild(i.id)}const r=s.children.findIndex(a=>a.id===t);return r===-1?!1:(s.isRoot&&o.layoutSide&&(i.layoutSide=o.layoutSide),s.removeChild(t),s.insertChild(i,r),i.parentId=s.id,i.addChild(o),!0)}insertParent(e,t="New topic"){const i=this.mindMap.findNode(e);if(!i||!i.parentId)return null;this.saveState();const o=this.idGenerator.generate(),s=new x(o,t);return this.mindMap.insertParent(e,s)?s:null}clipboard=null;copyNode(e){const t=this.mindMap.findNode(e);t&&(this.clipboard=this.deepCloneNode(t),navigator.clipboard&&navigator.clipboard.writeText(t.topic).catch(i=>{console.error("Failed to write to clipboard",i)}))}cutNode(e){const t=this.mindMap.findNode(e);t&&!t.isRoot&&t.parentId&&(this.copyNode(e),this.removeNode(e))}pasteNode(e){if(!this.clipboard)return null;const t=this.mindMap.findNode(e);if(!t)return null;this.saveState();const i=this.deepCloneNode(this.clipboard);return this.regenerateIds(i),t.addChild(i),i}deepCloneNode(e){const t=new x(e.id,e.topic,null,!1,e.image,e.layoutSide,e.isFolded,e.icon);return t.style={...e.style},t.children=e.children.map(i=>this.deepCloneNode(i)),t.children.forEach(i=>i.parentId=t.id),t}updateNodeIcon(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),t==="delete"?i.icon=void 0:i.icon=t,!0):!1}regenerateIds(e){e.id=this.idGenerator.generate(),e.children.forEach(t=>{t.parentId=e.id,this.regenerateIds(t)})}exportData(){const e=t=>({id:t.id,topic:t.topic,root:t.isRoot||void 0,children:t.children.length>0?t.children.map(e):void 0,style:Object.keys(t.style).length>0?t.style:void 0,image:t.image,layoutSide:t.layoutSide,isFolded:t.isFolded,icon:t.icon});return{nodeData:e(this.mindMap.root),theme:this.mindMap.theme}}searchNodes(e){if(!e)return[];const t=[],i=e.toLowerCase(),o=s=>{s.topic.toLowerCase().includes(i)&&t.push(s),s.children.forEach(o)};return o(this.mindMap.root),t}importData(e){const t=(i,o=null)=>{const s=!!i.root,n=new x(i.id,i.topic,o,s,i.image,i.layoutSide,i.isFolded||!1,i.icon);return i.style&&(n.style={...i.style}),i.children&&i.children.length>0&&i.children.forEach(r=>{const a=t(r,n.id);n.addChild(a)}),n};this.mindMap.root=t(e.nodeData),e.theme&&(this.mindMap.theme=e.theme)}}const I={blue_circle:{path:'<circle cx="12" cy="12" r="10" fill="#3498DB" />',color:"#3498DB",viewBox:"0 0 24 24"},red_circle:{path:'<circle cx="12" cy="12" r="10" fill="#E74C3C" />',color:"#E74C3C",viewBox:"0 0 24 24"},question:{path:'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z" fill="#95A5A6" />',color:"#95A5A6",viewBox:"0 0 24 24"},important:{path:'<path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z" fill="#F1C40F" />',color:"#F1C40F",viewBox:"0 0 24 24"},check:{path:'<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" fill="#2ECC71" />',color:"#2ECC71",viewBox:"0 0 24 24"},cross:{path:'<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" fill="#E74C3C" />',color:"#E74C3C",viewBox:"0 0 24 24"},flag:{path:'<path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z" fill="#E67E22" />',color:"#E67E22",viewBox:"0 0 24 24"},idea:{path:'<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" fill="#F39C12" />',color:"#F39C12",viewBox:"0 0 24 24"},warning:{path:'<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" fill="#E67E22" />',color:"#E67E22",viewBox:"0 0 24 24"},schedule:{path:'<path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z" fill="#3498DB" />',color:"#3498DB",viewBox:"0 0 24 24"}};class E{container;svg;nodeContainer;options;maxWidth=-1;constructor(e,t={}){this.container=e,this.container.style.position="relative",this.container.style.width="100%",this.container.style.height="100%",this.container.style.overflow="hidden",this.container.style.backgroundColor="var(--vscode-editor-background, transparent)",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.position="absolute",this.svg.style.top="0",this.svg.style.left="0",this.svg.style.width="100%",this.svg.style.height="100%",this.svg.style.zIndex="0",this.svg.style.pointerEvents="none",this.svg.style.overflow="visible",this.svg.style.transformOrigin="0 0",this.container.appendChild(this.svg),this.nodeContainer=document.createElement("div"),this.nodeContainer.style.position="absolute",this.nodeContainer.style.top="0",this.nodeContainer.style.left="0",this.nodeContainer.style.width="100%",this.nodeContainer.style.height="100%",this.nodeContainer.style.zIndex="1",this.nodeContainer.style.transformOrigin="0 0",this.container.appendChild(this.nodeContainer),this.options=t}render(e,t=null,i="Right"){this.svg.innerHTML="",this.nodeContainer.innerHTML="",this.renderNode(e.root,0,this.container.clientHeight/2,t,i,!0,void 0,e)}updateTransform(e,t,i=1){const o=`translate(${e}px, ${t}px) scale(${i})`;this.svg.style.transform=o,this.nodeContainer.style.transform=o}static RAINBOW_PALETTE=["#E74C3C","#3498DB","#2ECC71","#F1C40F","#9B59B6","#E67E22","#1ABC9C"];getThemeColor(e,t){if(t.theme==="colorful"){if(e.isRoot)return"#333";let i=e;for(;i.parentId&&i.parentId!==t.root.id;){const n=t.findNode(i.parentId);if(!n)break;i=n}const s=t.root.children.findIndex(n=>n.id===i.id);if(s!==-1)return E.RAINBOW_PALETTE[s%E.RAINBOW_PALETTE.length]}return"#ccc"}renderNode(e,t,i,o,s,n,r="right",a){const l=document.createElement("div");if(l.dataset.id=e.id,l.style.position="absolute",l.style.left=`${t}px`,l.style.top=`${i}px`,e.image){const y=document.createElement("img");y.src=e.image,y.style.maxWidth="150px",y.style.maxHeight="150px",y.style.display="block",l.appendChild(y);const u=document.createElement("div");u.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--vscode-icon-foreground, #333)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><line x1="11" y1="8" x2="11" y2="14"></line><line x1="8" y1="11" x2="14" y2="11"></line></svg>',u.style.position="absolute",u.style.bottom="5px",u.style.right="5px",u.style.backgroundColor="var(--vscode-editor-background, rgba(255, 255, 255, 0.9))",u.style.borderRadius="50%",u.style.width="24px",u.style.height="24px",u.style.display="flex",u.style.justifyContent="center",u.style.alignItems="center",u.style.cursor="pointer",u.title="Zoom Image",u.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",l.appendChild(u),u.addEventListener("click",p=>{p.stopPropagation(),this.showImageModal(e.image)}),l.style.padding="5px"}else{if(l.style.display="flex",l.style.alignItems="center",l.style.justifyContent=e.isRoot?"center":"flex-start",e.icon){const u=I[e.icon];if(u){const p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.setAttribute("viewBox",u.viewBox),p.setAttribute("width","20"),p.setAttribute("height","20"),p.style.marginRight="8px",p.style.flexShrink="0",p.innerHTML=u.path,l.appendChild(p)}else{const p=document.createElement("span");p.textContent=e.icon,p.style.marginRight="6px",p.style.fontSize="1.2em",l.appendChild(p)}}const y=document.createElement("span");y.textContent=e.topic,l.appendChild(y),this.maxWidth!==-1?(y.style.whiteSpace="pre-wrap",y.style.wordWrap="break-word",y.style.overflowWrap="anywhere",y.style.maxWidth=`${this.maxWidth}px`):y.style.whiteSpace="pre"}l.className="mindmap-node",e.isRoot||(l.draggable=!0),l.style.position="absolute",l.style.padding="8px 12px",e.image&&(l.style.padding="5px"),a?.theme==="custom"?e.isRoot?l.style.color="var(--mindmap-root-color, var(--vscode-editor-foreground, black))":l.style.color="var(--mindmap-child-color, var(--vscode-editor-foreground, black))":l.style.color="var(--vscode-editor-foreground, black)";const h=a?.theme||"default",f=a?this.getThemeColor(e,a):"#ccc";if(h==="simple"&&!e.isRoot)l.style.border="none";else if(h==="custom")if(e.isRoot){const y="2px solid var(--vscode-editor-foreground, #333)";l.style.border=`var(--mindmap-root-border, ${y})`}else l.style.border="var(--mindmap-child-border, 1px solid #ccc)";else h==="colorful"?l.style.border=`2px solid ${f}`:l.style.border="1px solid var(--vscode-editorGroup-border, #ccc)";l.style.borderRadius="4px",e.isRoot&&(l.style.fontSize="1.2em",l.style.fontWeight="bold",h!=="custom"&&(l.style.border="2px solid var(--vscode-editor-foreground, #333)")),e.style.color&&(l.style.color=e.style.color),e.style.fontSize&&(l.style.fontSize=e.style.fontSize),e.style.fontWeight&&(l.style.fontWeight=e.style.fontWeight),e.style.fontStyle&&(l.style.fontStyle=e.style.fontStyle),e.style.background?l.style.backgroundColor=e.style.background:h==="custom"?e.isRoot?l.style.backgroundColor="var(--mindmap-root-background, var(--vscode-editor-background, white))":l.style.backgroundColor="var(--mindmap-child-background, var(--vscode-editor-background, white))":l.style.backgroundColor="var(--vscode-editorWidget-background, var(--vscode-editor-background, white))";const{width:d}=this.measureNode(e);let c=t;if(r==="left"&&!n?c=t-d:n&&(c=t-d/2),l.style.left=`${c}px`,l.style.top=`${i}px`,l.style.transform="translate(0, -50%)",l.style.zIndex="10",l.style.cursor="default",l.style.userSelect="none",e.id===o&&(l.style.outline="2px solid var(--vscode-focusBorder, #007bff)",l.style.boxShadow="0 0 5px var(--vscode-focusBorder, rgba(0, 123, 255, 0.5))"),this.nodeContainer.appendChild(l),e.children.length===0)return;if(this.options.onToggleFold){const y=[];if(n&&s==="Both")y.push(c+d),y.push(c);else{let u=r==="right";n&&(s==="Left"?u=!1:u=!0),y.push(u?c+d:c)}y.forEach(u=>{const p=document.createElement("div");p.className="mindmap-toggle-btn",p.innerHTML=e.isFolded?"+":"-",p.style.position="absolute",p.style.width="16px",p.style.height="16px",p.style.fontSize="12px",p.style.lineHeight="14px",p.style.textAlign="center",p.style.borderRadius="50%",p.style.border="1px solid var(--vscode-widget-border, #999)",p.style.backgroundColor="var(--vscode-editor-background, #fff)",p.style.color="var(--vscode-editor-foreground, #000)",p.style.cursor="pointer",p.style.zIndex="11",p.style.userSelect="none";const N=0;p.style.left=`${u+N}px`,p.style.top=`${i}px`,p.style.transform="translate(-50%, -50%)",p.addEventListener("click",b=>{b.stopPropagation(),this.options.onToggleFold?.(e.id)}),this.nodeContainer.appendChild(p)})}if(e.isFolded)return;let g=[],m=[];n&&s==="Both"?e.children.forEach((y,u)=>{(y.layoutSide||(u%2===0?"right":"left"))==="right"?g.push(y):m.push(y)}):s==="Left"?m=e.children:s==="Right"?g=e.children:r==="left"?m=e.children:g=e.children,g.length>0&&this.renderChildrenStack(e,g,t,i,o,s,"right",d,a),m.length>0&&this.renderChildrenStack(e,m,t,i,o,s,"left",d,a)}renderChildrenStack(e,t,i,o,s,n,r,a,l){const h=t.reduce((g,m)=>g+this.getNodeHeight(m),0);let f=o-h/2;const d=80;let c=0;e.isRoot?c=r==="right"?i+a/2:i-a/2:r==="right"?c=i+a:(c=i,c=i-a),t.forEach(g=>{const m=this.getNodeHeight(g),y=f+m/2;let u=0;r==="right"?u=c+d:u=c-d,this.renderNode(g,u,y,s,n,!1,r,l);const p=l?this.getThemeColor(g,l):"#ccc";this.drawConnection(c,o,u,y,p,l?.theme),f+=m})}getChildrenHeight(e){return e.children.reduce((t,i)=>t+this.getNodeHeight(i),0)}getNodeHeight(e){const{height:t}=this.measureNode(e),i=20;if(e.children.length===0)return t+i;const o=this.getChildrenHeight(e);return Math.max(t+i,o)}measureNode(e){if(e.image)return{width:160,height:160};const t=document.createElement("div");if(t.className="mindmap-node",t.style.visibility="hidden",t.style.position="absolute",t.style.display="flex",t.style.alignItems="center",e.icon)if(I[e.icon]){const r=document.createElement("div");r.style.width="20px",r.style.height="20px",r.style.marginRight="8px",r.style.flexShrink="0",t.appendChild(r)}else{const r=document.createElement("span");r.textContent=e.icon,r.style.marginRight="6px",r.style.fontSize="1.2em",t.appendChild(r)}const i=document.createElement("span");i.textContent=e.topic,t.appendChild(i),this.maxWidth!==-1?(i.style.whiteSpace="pre-wrap",i.style.wordWrap="break-word",i.style.overflowWrap="anywhere",i.style.maxWidth=`${this.maxWidth}px`,i.style.width="max-content"):i.style.whiteSpace="pre",t.style.padding="8px 12px",t.style.border="1px solid var(--vscode-editorGroup-border, #ccc)",e.isRoot&&(t.style.fontSize="1.2em",t.style.fontWeight="bold",t.style.border="2px solid var(--vscode-editor-foreground, #333)"),e.style.color&&(t.style.color=e.style.color),e.style.fontSize&&(t.style.fontSize=e.style.fontSize),e.style.fontWeight&&(t.style.fontWeight=e.style.fontWeight),e.style.fontStyle&&(t.style.fontStyle=e.style.fontStyle),e.style.background&&(t.style.backgroundColor=e.style.background),this.nodeContainer.appendChild(t);const o=t.offsetWidth,s=t.offsetHeight;return this.nodeContainer.removeChild(t),{width:o||100,height:s||40}}drawConnection(e,t,i,o,s="#ccc",n="default"){const r=document.createElementNS("http://www.w3.org/2000/svg","path"),a=e+(i-e)/2,l=e+(i-e)/2,h=`M ${e} ${t} C ${a} ${t}, ${l} ${o}, ${i} ${o}`;r.setAttribute("d",h),n==="custom"?r.style.stroke=`var(--mindmap-connection-color, ${s})`:r.style.stroke=s,r.setAttribute("fill","none"),r.setAttribute("stroke-width","2"),this.svg.appendChild(r)}showImageModal(e){this.options.onImageZoom&&this.options.onImageZoom(!0);const t=document.createElement("div");t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100vw",t.style.height="100vh",t.style.backgroundColor="rgba(0,0,0,0.8)",t.style.zIndex="1000",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.cursor="zoom-out";const i=document.createElement("img");i.src=e,i.style.maxWidth="90%",i.style.maxHeight="90%",i.style.boxShadow="0 0 20px rgba(0,0,0,0.5)",t.appendChild(i),document.body.appendChild(t);let o;const s=()=>{document.body.contains(t)&&document.body.removeChild(t),o&&document.removeEventListener("keydown",o,!0),this.options.onImageZoom&&this.options.onImageZoom(!1),this.container.focus()};o=n=>{n.stopPropagation(),n.preventDefault(),s()},document.addEventListener("keydown",o,!0),t.addEventListener("click",()=>{s()})}}class C{container;editorEl;currentNodeId=null;onUpdate;static FONT_SIZES=[{label:"12px",value:"12px"},{label:"14px",value:"14px"},{label:"16px",value:"16px"},{label:"18px",value:"18px"},{label:"24px",value:"24px"},{label:"32px",value:"32px"},{label:"48px",value:"48px"}];static PALETTE=["#000000","#E74C3C","#E67E22","#F1C40F","#2ECC71","#3498DB","#9B59B6"];constructor(e){this.container=e,this.editorEl=this.createEditor(),this.container.appendChild(this.editorEl),this.editorEl.addEventListener("mousedown",t=>t.stopPropagation()),this.editorEl.addEventListener("click",t=>t.stopPropagation()),this.editorEl.addEventListener("dblclick",t=>t.stopPropagation())}createEditor(){const e=document.createElement("div");e.className="style-editor",e.style.position="absolute",e.style.top="20px",e.style.right="20px",e.style.display="none",e.style.backgroundColor="white",e.style.border="1px solid #eee",e.style.borderRadius="8px",e.style.padding="8px",e.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)",e.style.zIndex="2000",e.style.pointerEvents="auto",e.style.fontFamily="Arial, sans-serif",e.style.display="flex",e.style.flexDirection="column",e.style.gap="8px",e.style.margin="0",e.style.boxSizing="border-box",e.style.minWidth="220px";const t=document.createElement("div");t.style.display="flex",t.style.gap="8px",t.style.alignItems="center";const i=document.createElement("select");i.style.padding="4px 8px",i.style.borderRadius="4px",i.style.border="1px solid #ccc",i.style.fontSize="14px",i.style.flex="1",C.FONT_SIZES.forEach(h=>{const f=document.createElement("option");f.value=h.value,f.textContent=h.label,i.appendChild(f)}),i.onchange=h=>{this.currentNodeId&&this.onUpdate&&this.onUpdate(this.currentNodeId,{fontSize:h.target.value})},t.appendChild(i);const s=(h,f,d)=>{const c=document.createElement("button");return c.textContent=h,c.style.width="32px",c.style.height="32px",c.style.padding="0",c.style.display="flex",c.style.justifyContent="center",c.style.alignItems="center",c.style.border="1px solid #ddd",c.style.backgroundColor="#f5f5f5",c.style.borderRadius="4px",c.style.cursor="pointer",c.style.fontSize="14px",f&&(c.style[f]=f==="fontWeight"?"bold":"italic"),c.onclick=d,c},n=s("B","fontWeight",()=>{if(this.currentNodeId&&this.onUpdate){const h=n.classList.contains("active"),f=h?"normal":"bold";this.onUpdate(this.currentNodeId,{fontWeight:f}),this.updateButtonState(n,!h)}}),r=s("I","fontStyle",()=>{if(this.currentNodeId&&this.onUpdate){const h=r.classList.contains("active"),f=h?"normal":"italic";this.onUpdate(this.currentNodeId,{fontStyle:f}),this.updateButtonState(r,!h)}});t.appendChild(n),t.appendChild(r),e.appendChild(t);const a=document.createElement("div");a.style.display="flex",a.style.gap="4px",a.style.alignItems="center",a.style.justifyContent="space-between";const l=document.createElement("input");return l.type="color",l.style.width="24px",l.style.height="24px",l.style.border="1px solid #ccc",l.style.padding="0",l.style.backgroundColor="transparent",l.style.cursor="pointer",l.style.appearance="none",l.onchange=h=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:h.target.value}),this.updateActivePaletteItem(h.target.value))},C.PALETTE.forEach((h,f)=>{const d=document.createElement("div");d.className="color-swatch",d.dataset.color=h,d.textContent=(f+1).toString(),d.style.width="24px",d.style.height="24px",d.style.backgroundColor=h,d.style.borderRadius="4px",d.style.cursor="pointer",d.style.border="1px solid transparent",d.style.color=h==="#F1C40F"?"black":"white",d.style.fontSize="12px",d.style.fontWeight="bold",d.style.display="flex",d.style.justifyContent="center",d.style.alignItems="center",d.onclick=()=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:h}),l.value=h,this.updateActivePaletteItem(h))},a.appendChild(d)}),a.appendChild(l),e.appendChild(a),e}updateActivePaletteItem(e){this.editorEl.querySelectorAll(".color-swatch").forEach(i=>{const o=i;o.dataset.color?.toLowerCase()===e.toLowerCase()?(o.style.border="2px solid #ccc",o.style.transform="scale(1.1)"):(o.style.border="1px solid transparent",o.style.transform="scale(1)")})}updateButtonState(e,t){t?(e.classList.add("active"),e.style.backgroundColor="#e0e0e0",e.style.borderColor="#999"):(e.classList.remove("active"),e.style.backgroundColor="#f5f5f5",e.style.borderColor="#ddd")}show(e,t){this.currentNodeId=e,this.editorEl.style.display="flex";const i=this.editorEl.querySelector("select");i.value=t.fontSize||"";const o=this.editorEl.querySelector('input[type="color"]'),s=t.color||"#000000";o.value=s,this.updateActivePaletteItem(s);const n=this.editorEl.querySelectorAll("button")[0];this.updateButtonState(n,t.fontWeight==="bold");const r=this.editorEl.querySelectorAll("button")[1];this.updateButtonState(r,t.fontStyle==="italic")}hide(){this.editorEl.style.display="none",this.currentNodeId=null}}class L{container;element;options;currentMode="Right";currentTheme="default";layoutButtons=new Map;themeButtons=new Map;constructor(e,t){this.container=e,this.options=t,this.element=document.createElement("div"),this.render()}render(){this.element.style.position="absolute",this.element.style.top="20px",this.element.style.left="20px",this.element.style.display="flex",this.element.style.flexDirection="column",this.element.style.backgroundColor="white",this.element.style.borderRadius="8px",this.element.style.boxShadow="0 2px 10px rgba(0,0,0,0.1)",this.element.style.padding="5px",this.element.style.zIndex="2000",this.element.style.gap="5px",this.element.style.pointerEvents="auto",this.element.addEventListener("click",e=>e.stopPropagation()),this.element.addEventListener("mousedown",e=>e.stopPropagation()),this.createLayoutButton("Right",this.getRightIcon()),this.createLayoutButton("Left",this.getLeftIcon()),this.createLayoutButton("Both",this.getBothIcon()),this.addSeparator(),this.createThemeButton("default",this.getThemeDefaultIcon()),this.createThemeButton("simple",this.getThemeSimpleIcon()),this.createThemeButton("colorful",this.getThemeColorfulIcon()),this.createThemeButton("custom",this.getThemeCustomIcon()),this.addSeparator(),this.createIconActionButton("Reset Zoom",this.getZoomResetIcon(),()=>{this.options.onZoomReset&&this.options.onZoomReset()}),this.addSeparator(),this.createIconActionButton("Shortcuts Help",this.getHelpIcon(),()=>{this.options.onShowShortcuts&&this.options.onShowShortcuts()}),this.container.appendChild(this.element),this.updateActiveButtons()}addSeparator(){const e=document.createElement("div");e.style.height="1px",e.style.backgroundColor="#ccc",e.style.margin="5px 2px",this.element.appendChild(e)}createLayoutButton(e,t){const i=document.createElement("button");i.innerHTML=t,this.styleButton(i),i.title=`Layout: ${e}`,i.addEventListener("click",()=>{this.setMode(e)}),this.element.appendChild(i),this.layoutButtons.set(e,i)}createThemeButton(e,t){const i=document.createElement("button");i.innerHTML=t,this.styleButton(i),i.title=`Theme: ${e}`,i.addEventListener("click",()=>{this.setTheme(e)}),this.element.appendChild(i),this.themeButtons.set(e,i)}createIconActionButton(e,t,i){const o=document.createElement("button");o.innerHTML=t,this.styleButton(o),o.title=e,o.addEventListener("click",i),this.element.appendChild(o)}styleButton(e){e.style.width="32px",e.style.height="32px",e.style.border="none",e.style.background="transparent",e.style.cursor="pointer",e.style.borderRadius="4px",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.style.color="#555"}updateActiveButtons(){this.layoutButtons.forEach((e,t)=>{t===this.currentMode?(e.style.backgroundColor="#e6f7ff",e.style.color="#007bff"):(e.style.backgroundColor="transparent",e.style.color="#555")}),this.themeButtons.forEach((e,t)=>{t===this.currentTheme?(e.style.backgroundColor="#e6f7ff",e.style.color="#007bff"):(e.style.backgroundColor="transparent",e.style.color="#555")})}setMode(e){this.currentMode!==e&&(this.currentMode=e,this.updateActiveButtons(),this.options.onLayoutChange(e))}setTheme(e){this.currentTheme!==e&&(this.currentTheme=e,this.updateActiveButtons(),this.options.onThemeChange(e))}getRightIcon(){return`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
2
|
<circle cx="5" cy="12" r="3"></circle>
|
|
3
3
|
<path d="M8 12h8"></path>
|
|
4
4
|
<path d="M8 12 L16 5"></path>
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
<circle cx="12" cy="12" r="10"></circle>
|
|
38
38
|
<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path>
|
|
39
39
|
<line x1="12" y1="17" x2="12.01" y2="17"></line>
|
|
40
|
-
</svg>`}}const D={navUp:[{key:"ArrowUp"},{key:"k",ctrlKey:!1,metaKey:!1,altKey:!1}],navDown:[{key:"ArrowDown"},{key:"j",ctrlKey:!1,metaKey:!1,altKey:!1}],navLeft:[{key:"ArrowLeft"},{key:"h",ctrlKey:!1,metaKey:!1,altKey:!1}],navRight:[{key:"ArrowRight"},{key:"l",ctrlKey:!1,metaKey:!1,altKey:!1}],addChild:[{key:"Tab"},{key:"a"}],insertParent:[{key:"Tab",shiftKey:!0},{key:"a",shiftKey:!0}],addSibling:[{key:"Enter"}],addSiblingBefore:[{key:"Enter",shiftKey:!0}],deleteNode:[{key:"Delete"},{key:"Backspace"}],beginEdit:[{key:"F2"},{key:" "}],copy:[{key:"c",ctrlKey:!0},{key:"c",metaKey:!0}],paste:[{key:"v",ctrlKey:!0},{key:"v",metaKey:!0}],cut:[{key:"x",ctrlKey:!0},{key:"x",metaKey:!0}],undo:[{key:"z",ctrlKey:!0},{key:"z",metaKey:!0}],redo:[{key:"Z",ctrlKey:!0,shiftKey:!0},{key:"Z",metaKey:!0,shiftKey:!0},{key:"y",ctrlKey:!0},{key:"y",metaKey:!0}],bold:[{key:"b"}],italic:[{key:"i"}],zoomIn:[{key:">",shiftKey:!0},{key:"."}],zoomOut:[{key:"<",shiftKey:!0},{key:","}],scaleUp:[{key:"["}],scaleDown:[{key:"]"}],resetZoom:[{key:":"}],toggleFold:[{key:"f",ctrlKey:!1,metaKey:!1,altKey:!1}],selectColor1:[{key:"1"}],selectColor2:[{key:"2"}],selectColor3:[{key:"3"}],selectColor4:[{key:"4"}],selectColor5:[{key:"5"}],selectColor6:[{key:"6"}],selectColor7:[{key:"7"}]};class
|
|
41
|
-
`)||e.value==="")&&(s.textContent+=""),document.body.appendChild(s);const n=s.offsetWidth+20,
|
|
40
|
+
</svg>`}}const D={navUp:[{key:"ArrowUp"},{key:"k",ctrlKey:!1,metaKey:!1,altKey:!1}],navDown:[{key:"ArrowDown"},{key:"j",ctrlKey:!1,metaKey:!1,altKey:!1}],navLeft:[{key:"ArrowLeft"},{key:"h",ctrlKey:!1,metaKey:!1,altKey:!1}],navRight:[{key:"ArrowRight"},{key:"l",ctrlKey:!1,metaKey:!1,altKey:!1}],addChild:[{key:"Tab"},{key:"a"}],insertParent:[{key:"Tab",shiftKey:!0},{key:"a",shiftKey:!0}],addSibling:[{key:"Enter"}],addSiblingBefore:[{key:"Enter",shiftKey:!0}],deleteNode:[{key:"Delete"},{key:"Backspace"}],beginEdit:[{key:"F2"},{key:" "}],copy:[{key:"c",ctrlKey:!0},{key:"c",metaKey:!0}],paste:[{key:"v",ctrlKey:!0},{key:"v",metaKey:!0}],cut:[{key:"x",ctrlKey:!0},{key:"x",metaKey:!0}],undo:[{key:"z",ctrlKey:!0},{key:"z",metaKey:!0}],redo:[{key:"Z",ctrlKey:!0,shiftKey:!0},{key:"Z",metaKey:!0,shiftKey:!0},{key:"y",ctrlKey:!0},{key:"y",metaKey:!0}],bold:[{key:"b"}],italic:[{key:"i"}],zoomIn:[{key:">",shiftKey:!0},{key:"."}],zoomOut:[{key:"<",shiftKey:!0},{key:","}],scaleUp:[{key:"["}],scaleDown:[{key:"]"}],resetZoom:[{key:":"}],toggleFold:[{key:"f",ctrlKey:!1,metaKey:!1,altKey:!1}],selectColor1:[{key:"1"}],selectColor2:[{key:"2"}],selectColor3:[{key:"3"}],selectColor4:[{key:"4"}],selectColor5:[{key:"5"}],selectColor6:[{key:"6"}],selectColor7:[{key:"7"}],openCommandPalette:[{key:"m"}]};class T{container;maxWidth;options;constructor(e,t,i){this.container=e,this.maxWidth=t,this.options=i}setMaxWidth(e){this.maxWidth=e}startEditing(e,t){const i=e.textContent||"",o=this.createEditTextarea(e,i);this.applyTextareaStyles(o,e,this.maxWidth);const s=e.style.outline,n=e.style.boxShadow;e.style.outline="none",e.style.boxShadow="none";const r=this.createSizeUpdater(o,e,this.maxWidth);r(),o.addEventListener("input",r);const a=this.createCleanupFunction(o,e,s,n);this.setupEditEventHandlers(o,t,i,a),e.parentElement?e.parentElement.appendChild(o):this.container.appendChild(o),o.focus({preventScroll:!0}),o.select()}createEditTextarea(e,t){const i=document.createElement("textarea");return i.value=t,i.style.position="absolute",i.style.top=e.style.top,i.style.left=e.style.left,i.style.transform=e.style.transform,this.container.scrollTop=0,this.container.scrollLeft=0,i.style.overflow="hidden",i.style.resize="none",i.style.minHeight="1em",i}applyTextareaStyles(e,t,i){i!==-1?(e.style.whiteSpace="pre-wrap",e.style.wordWrap="break-word",e.style.overflowWrap="anywhere",e.style.maxWidth=`${i}px`,e.style.width="max-content"):e.style.whiteSpace="pre";const o=window.getComputedStyle(t);e.style.font=o.font,e.style.padding=o.padding,e.style.boxSizing="border-box",e.style.backgroundColor=o.backgroundColor,e.style.border="none",e.style.outline="none",e.style.boxShadow="none",e.style.borderTop=o.borderTop,e.style.borderRight=o.borderRight,e.style.borderBottom=o.borderBottom,e.style.borderLeft=o.borderLeft,e.style.borderRadius=o.borderRadius,e.style.zIndex="100"}createSizeUpdater(e,t,i){const o=window.getComputedStyle(t);return()=>{const s=document.createElement("span");s.style.font=o.font,s.style.padding=o.padding,i!==-1?(s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflowWrap="anywhere",s.style.maxWidth=`${i}px`,s.style.width="max-content"):s.style.whiteSpace="pre",s.style.visibility="hidden",s.style.position="absolute",s.textContent=e.value||"",(e.value.endsWith(`
|
|
41
|
+
`)||e.value==="")&&(s.textContent+=""),document.body.appendChild(s);const n=s.offsetWidth+20,r=s.offsetHeight+10;e.style.width=Math.max(n,t.offsetWidth)+"px",e.style.height=Math.max(r,t.offsetHeight)+"px",document.body.removeChild(s)}}createCleanupFunction(e,t,i,o){return()=>{e.parentNode&&e.parentNode.contains(e)&&e.parentNode.removeChild(e),t.style.outline=i,t.style.boxShadow=o}}setupEditEventHandlers(e,t,i,o){let s=!1;const n=()=>{if(s)return;s=!0;const a=e.value;a!==i&&this.options.onUpdateNode&&this.options.onUpdateNode(t,a),o(),this.options.onEditEnd&&this.options.onEditEnd(t)},r=()=>{s||(s=!0,o(),this.options.onEditEnd&&this.options.onEditEnd(t))};e.addEventListener("blur",()=>{s||n()}),e.addEventListener("keydown",a=>{if(a.stopPropagation(),!a.isComposing)if(a.key==="Enter"){if(a.shiftKey)return;a.preventDefault(),n()}else a.key==="Escape"&&(a.preventDefault(),r())})}}class R{container;options;draggedNodeId=null;isReadOnly=!1;constructor(e,t){this.container=e,this.options=t,this.injectDragStyles()}setReadOnly(e){this.isReadOnly=e}injectDragStyles(){const e=document.createElement("style");e.textContent=`
|
|
42
42
|
.mindmap-node.drag-over-top {
|
|
43
43
|
border-top: 4px solid #007bff !important;
|
|
44
44
|
}
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
.mindmap-node.drag-over-right {
|
|
52
52
|
border-right: 4px solid #007bff !important;
|
|
53
53
|
}
|
|
54
|
-
`,document.head.appendChild(e)}handleDragStart(e){const t=e;if(this.isReadOnly){t.preventDefault();return}const o=t.target.closest(".mindmap-node");o&&o.dataset.id&&(this.draggedNodeId=o.dataset.id,t.dataTransfer?.setData("text/plain",o.dataset.id),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}handleDragOver(e){const t=e;if(this.isReadOnly)return;t.preventDefault();const o=t.target.closest(".mindmap-node");if(o&&o.dataset.id&&this.draggedNodeId&&o.dataset.id!==this.draggedNodeId){const s=this.getDropPosition(t,o);o.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right"),o.classList.add(`drag-over-${s}`),t.dataTransfer&&(t.dataTransfer.dropEffect="move")}}handleDragLeave(e){const i=e.target.closest(".mindmap-node");i&&i.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}handleDrop(e){const t=e;t.preventDefault();const o=t.target.closest(".mindmap-node");if(this.container.querySelectorAll(".mindmap-node").forEach(s=>{s.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}),!this.isReadOnly){if(o&&o.dataset.id&&this.draggedNodeId){const s=o.dataset.id;if(this.draggedNodeId!==s){const n=this.getDropPosition(t,o);this.options.onDropNode(this.draggedNodeId,s,n)}}this.draggedNodeId=null}}handleDragEnd(){this.draggedNodeId=null,this.container.querySelectorAll(".mindmap-node").forEach(e=>{e.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")})}getDropPosition(e,t){const i=t.getBoundingClientRect(),o=e.clientX-i.left,s=e.clientY-i.top,n=i.width,d=i.height;return s<d*.25?"top":s>d*.75?"bottom":o<n*.25?"left":(o>n*.75,"right")}}class L{shortcuts;constructor(e){this.shortcuts=e}matches(e,t){const i=this.shortcuts[t];return i?i.some(o=>{const s=o.ctrlKey??!1,n=o.metaKey??!1,d=o.altKey??!1,l=o.shiftKey??!1;return e.ctrlKey!==s||e.metaKey!==n||e.altKey!==d||e.shiftKey!==l?!1:o.key.toLowerCase()===e.key.toLowerCase()}):!1}getAction(e){const t=Object.keys(this.shortcuts);for(const i of t)if(this.matches(e,i))return i}}class P{container;options;maxWidth=-1;selectedNodeId=null;isPanning=!1;lastMouseX=0;lastMouseY=0;isReadOnly=!1;shortcuts;nodeEditor;nodeDragger;shortcutManager;cleanupFns=[];constructor(e,t){this.container=e,this.container.tabIndex=0,this.container.style.outline="none",this.container.style.cursor="default",this.options=t,this.shortcuts={...D,...t.shortcuts},this.nodeEditor=new R(e,this.maxWidth,t),this.nodeDragger=new T(e,t),this.shortcutManager=new L(this.shortcuts),this.isReadOnly=!!t.allowReadOnly,this.nodeDragger.setReadOnly(this.isReadOnly),this.attachEvents()}getShortcuts(){return this.shortcuts}setReadOnly(e){this.isReadOnly=e,this.nodeDragger&&this.nodeDragger.setReadOnly(e),e&&this.nodeDragger&&this.nodeDragger.draggedNodeId&&(this.nodeDragger.draggedNodeId=null)}destroy(){this.cleanupFns.forEach(e=>e()),this.cleanupFns=[]}updateSelection(e){this.selectedNodeId=e}attachEvents(){const e=(o,s,n,d)=>{o.addEventListener(s,n,d),this.cleanupFns.push(()=>{typeof o.removeEventListener=="function"&&o.removeEventListener(s,n,d)})};e(this.container,"focus",()=>{}),e(this.container,"blur",()=>{}),e(this.container,"scroll",()=>{(this.container.scrollTop!==0||this.container.scrollLeft!==0)&&(this.container.scrollTop=0,this.container.scrollLeft=0)}),e(this.container,"click",o=>{const n=o.target.closest(".mindmap-node");n&&n.dataset.id?this.options.onNodeClick(n.dataset.id):this.options.onNodeClick(""),this.container.focus()}),e(this.container,"mousedown",o=>{const s=o,n=s.target;!n.closest(".mindmap-node")&&n.tagName!=="INPUT"&&(this.isPanning=!0,this.lastMouseX=s.clientX,this.lastMouseY=s.clientY,this.container.style.cursor="all-scroll")}),e(window,"mousemove",o=>{const s=o;if(this.isPanning){const n=s.clientX-this.lastMouseX,d=s.clientY-this.lastMouseY;this.lastMouseX=s.clientX,this.lastMouseY=s.clientY,this.options.onPan&&this.options.onPan(n,d)}});const t=()=>{this.isPanning&&(this.isPanning=!1,this.container.style.cursor="default")};e(window,"mouseup",t),e(window,"mouseleave",t),e(this.container,"wheel",o=>{const s=o;if(s.preventDefault(),s.ctrlKey||s.metaKey){this.options.onZoom&&this.options.onZoom(s.deltaY,s.clientX,s.clientY);return}let n=1;s.deltaMode===1?n=33:s.deltaMode===2&&(n=window.innerHeight);const d=-s.deltaX*n,l=-s.deltaY*n;this.options.onPan&&this.options.onPan(d,l)},{passive:!1}),e(document,"keydown",o=>{const s=o,n=s.target;if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable)return;if(this.shortcutManager.matches(s,"resetZoom")){s.preventDefault(),this.options.onZoomReset?.();return}if(!this.selectedNodeId){if(this.shortcutManager.matches(s,"navUp")||this.shortcutManager.matches(s,"navDown")||this.shortcutManager.matches(s,"navLeft")||this.shortcutManager.matches(s,"navRight")){s.preventDefault();let l=null,r=1/0;this.container.querySelectorAll(".mindmap-node").forEach(a=>{const c=a;if(!c.dataset.id)return;const p=c.getBoundingClientRect(),g=p.left+p.width/2,m=p.top+p.height/2,y=this.container.getBoundingClientRect(),u=y.left+y.width/2,f=y.top+y.height/2,v=Math.pow(g-u,2)+Math.pow(m-f,2);v<r&&(r=v,l=c.dataset.id)}),l&&this.options.onNodeClick(l)}return}const d=this.shortcutManager.getAction(s);d&&this.handleAction(d,s)}),e(document,"paste",o=>{const s=o;if(this.isReadOnly||!this.selectedNodeId)return;const n=s.clipboardData?.items;if(!n||n.length===0){this.options.onPasteNode?.(this.selectedNodeId);return}let d=!1;for(const l of n)if(l.type.startsWith("image/")){const r=l.getAsFile();if(r){const h=new FileReader;h.onload=a=>{a.target?.result&&this.options.onPasteImage&&this.selectedNodeId&&this.options.onPasteImage(this.selectedNodeId,a.target.result)},h.readAsDataURL(r)}s.preventDefault(),d=!0;break}d||this.options.onPasteNode?.(this.selectedNodeId)});const i=(o,s,n)=>e(o,s,n);i(this.container,"dragstart",this.nodeDragger.handleDragStart.bind(this.nodeDragger)),i(this.container,"dragover",this.nodeDragger.handleDragOver.bind(this.nodeDragger)),i(this.container,"dragleave",this.nodeDragger.handleDragLeave.bind(this.nodeDragger)),i(this.container,"drop",this.nodeDragger.handleDrop.bind(this.nodeDragger)),i(this.container,"dragend",this.nodeDragger.handleDragEnd.bind(this.nodeDragger)),e(this.container,"dblclick",o=>{if(this.isReadOnly)return;const n=o.target.closest(".mindmap-node");n&&n.dataset.id&&this.startEditing(n,n.dataset.id)})}editNode(e){const t=this.container.querySelector(`.mindmap-node[data-id="${e}"]`);t&&this.startEditing(t,e)}get draggedNodeId(){return this.nodeDragger?this.nodeDragger.draggedNodeId:null}set draggedNodeId(e){this.nodeDragger&&(this.nodeDragger.draggedNodeId=e)}startEditing(e,t){this.nodeEditor.setMaxWidth(this.maxWidth),this.nodeEditor.startEditing(e,t)}handleAction(e,t){if(this.selectedNodeId){switch(e){case"copy":t.preventDefault(),this.options.onCopyNode?.(this.selectedNodeId);return;case"navUp":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Up");return;case"navDown":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Down");return;case"navRight":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Right");return;case"navLeft":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Left");return}if(!this.isReadOnly)switch(e){case"addChild":t.preventDefault(),this.options.onAddChild(this.selectedNodeId);break;case"insertParent":t.preventDefault(),this.options.onInsertParent?.(this.selectedNodeId);break;case"addSibling":t.preventDefault(),this.options.onAddSibling(this.selectedNodeId,"after");break;case"addSiblingBefore":t.preventDefault(),this.options.onAddSibling(this.selectedNodeId,"before");break;case"deleteNode":t.preventDefault(),this.options.onDeleteNode(this.selectedNodeId);break;case"beginEdit":t.preventDefault(),this.handleBeginEdit();break;case"scaleUp":if(t.preventDefault(),this.options.onZoom){const i=this.container.getBoundingClientRect();this.options.onZoom(-100,i.left+i.width/2,i.top+i.height/2)}break;case"scaleDown":if(t.preventDefault(),this.options.onZoom){const i=this.container.getBoundingClientRect();this.options.onZoom(100,i.left+i.width/2,i.top+i.height/2)}break;case"cut":t.preventDefault(),this.options.onCutNode?.(this.selectedNodeId);break;case"undo":t.preventDefault(),this.options.onUndo?.();break;case"redo":t.preventDefault(),this.options.onRedo?.();break;case"bold":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"bold"});break;case"italic":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"italic"});break;case"zoomIn":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"increaseSize"});break;case"zoomOut":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"decreaseSize"});break;case"toggleFold":t.preventDefault(),this.options.onToggleFold?.(this.selectedNodeId);break;default:if(e.startsWith("selectColor")){const i=parseInt(e.replace("selectColor",""),10)-1;isNaN(i)||(t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"color",index:i}))}break}}}handleBeginEdit(){if(!this.selectedNodeId)return;const e=this.container.querySelector(`.mindmap-node[data-id="${this.selectedNodeId}"]`);if(e){const t=e.querySelector('[title="Zoom Image"]');if(t){t.click();return}if(e.querySelector("img"))return;this.startEditing(e,this.selectedNodeId)}}}class A{mindMap;service;renderer;eventBus;styleEditor;interactionHandler;layoutSwitcher;selectedNodeId=null;layoutMode="Right";panX=0;panY=0;targetPanX=0;targetPanY=0;scale=1;isBatching=!1;animationFrameId=null;maxWidth=-1;pendingNodeCreation=!1;savedCustomStyles={rootNode:{border:"2px solid #aeb6bf",background:"#ebf5fb",color:"#2e4053"},childNode:{border:"1px solid #d5d8dc",background:"#fdfefe",color:"#2c3e50"},connection:{color:"#abb2b9"}};constructor(e,t,i,o,s){this.mindMap=e,this.service=t,this.renderer=i,this.styleEditor=o,this.eventBus=s}setInteractionHandler(e){this.interactionHandler=e}setLayoutSwitcher(e){this.layoutSwitcher=e}init(e){this.panX=e*.2,this.targetPanX=this.panX,this.startAnimationLoop(),this.render()}destroy(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}getData(){const e=this.service.exportData();return e.selectedId=this.selectedNodeId||void 0,e}loadData(e){try{this.service.importData(e),e.selectedId?this.selectNode(e.selectedId):this.selectNode(null),this.render(),this.eventBus.emit("model:load",e),e.theme&&this.setTheme(e.theme),this.eventBus.emit("model:change",void 0)}catch(t){console.error("Failed to load data",t)}}batch(e){this.isBatching=!0;try{e()}finally{this.isBatching=!1,this.render()}}getSelectedNodeId(){return this.selectedNodeId}addNode(e,t,i,o={emitChange:!0}){const s=this.service.addNode(e,t,i);return s&&(this.render(),this.eventBus.emit("node:add",{id:s.id,topic:s.topic}),o.emitChange&&this.eventBus.emit("model:change",void 0)),s}addSibling(e,t="after",i="New topic",o={emitChange:!0}){const s=this.mindMap.findNode(e);if(!s||!s.parentId)return null;const n=this.mindMap.findNode(s.parentId);n&&n.isRoot&&this.layoutMode==="Both"&&this.ensureExplicitLayoutSides(n);const d=this.service.addSibling(e,t,i);if(d){if(n&&n.isRoot&&this.layoutMode==="Both"){const l=s.layoutSide||(n.children.indexOf(s)%2===0?"right":"left");d.layoutSide=l}this.render(),this.eventBus.emit("node:add",{id:d.id,topic:d.topic}),o.emitChange&&this.eventBus.emit("model:change",void 0)}return d}insertParent(e,t="New topic",i={emitChange:!0}){const o=this.service.insertParent(e,t);return o&&(this.render(),this.eventBus.emit("node:add",{id:o.id,topic:o.topic}),i.emitChange&&this.eventBus.emit("model:change",void 0)),o}deleteNode(e){this.service.removeNode(e)&&(this.render(),this.eventBus.emit("node:remove",e),this.eventBus.emit("model:change",void 0))}updateNode(e,t){let i=!1;this.interactionHandler&&this.interactionHandler.isReadOnly||(t.topic!==void 0&&this.service.updateNodeTopic(e,t.topic)&&(i=!0),t.style!==void 0&&this.service.updateNodeStyle(e,t.style)&&(i=!0),i&&(this.render(),t.topic!==void 0&&this.eventBus.emit("node:update",{id:e,topic:t.topic}),this.eventBus.emit("model:change",void 0),this.pendingNodeCreation&&(this.pendingNodeCreation=!1)))}addChildNode(e){const t=this.mindMap.findNode(e);t&&t.isRoot&&this.layoutMode==="Both"&&this.ensureExplicitLayoutSides(t);let i;if(this.layoutMode==="Both"&&t&&t.isRoot){let s=0,n=0;t.children.forEach((d,l)=>{(d.layoutSide||(l%2===0?"right":"left"))==="left"?s++:n++}),i=s<n?"left":"right"}this.pendingNodeCreation=!0;const o=this.addNode(e,"New topic",i,{emitChange:!1});o&&(this.selectNode(o.id),this.ensureNodeVisible(o.id,!1,!0),this.interactionHandler.editNode(o.id))}addSiblingNode(e,t="after"){this.pendingNodeCreation=!0;const i=this.addSibling(e,t,"New topic",{emitChange:!1});i&&(this.selectNode(i.id),this.ensureNodeVisible(i.id,!1,!0),this.interactionHandler.editNode(i.id))}insertParentNode(e){this.pendingNodeCreation=!0;const t=this.insertParent(e,"New topic",{emitChange:!1});t&&(this.selectNode(t.id),this.ensureNodeVisible(t.id,!1,!0),this.interactionHandler.editNode(t.id))}removeNode(e){const i=this.mindMap.findNode(e)?.parentId||null,o=this.selectedNodeId===e;this.deleteNode(e),o&&i&&this.selectNode(i)}selectNode(e){if(this.selectedNodeId!==e){if(this.selectedNodeId=e,this.interactionHandler&&this.interactionHandler.updateSelection(e),e){const t=this.mindMap.findNode(e);t&&(!t.image&&this.interactionHandler&&!this.interactionHandler.isReadOnly?this.styleEditor.show(e,t.style):this.styleEditor.hide())}else this.styleEditor.hide();this.render(),this.eventBus.emit("node:select",e)}}moveNode(e,t,i){const o=this.mindMap.findNode(t);if(o){if(i==="top"){if(o.isRoot)return;this.service.reorderNode(e,t,"before")}else if(i==="bottom"){if(o.isRoot)return;this.service.reorderNode(e,t,"after")}else if(o.isRoot){const s=i==="left"?"left":"right";this.service.moveNode(e,t,s)}else((this.getNodeDirection(o)==="right"?i==="right":i==="left")?"addChild":"insertParent")==="addChild"?this.service.moveNode(e,t):this.service.insertNodeAsParent(e,t);this.render(),this.eventBus.emit("node:move",{nodeId:e,newParentId:t,position:i}),this.eventBus.emit("model:change",void 0)}}updateNodeTopic(e,t){this.updateNode(e,{topic:t}),setTimeout(()=>this.ensureNodeVisible(e),0)}render(){this.isBatching||(this.renderer.render(this.mindMap,this.selectedNodeId,this.layoutMode),this.renderer.updateTransform(this.panX,this.panY,this.scale))}setLayoutMode(e){this.layoutMode=e,this.layoutSwitcher&&this.layoutSwitcher.setMode(e);const t=this.renderer.container.clientWidth;e==="Right"?this.panX=t*.2:e==="Left"?this.panX=t*.8:this.panX=t*.5,this.panY=0,this.targetPanX=this.panX,this.targetPanY=this.panY,this.render()}getLayoutMode(){return this.layoutMode}setMaxNodeWidth(e){this.maxWidth=e,this.renderer.maxWidth=e,this.interactionHandler&&(this.interactionHandler.maxWidth=e),this.render()}getMaxNodeWidth(){return this.maxWidth}updateGlobalStyles(e){e.rootNode&&(this.savedCustomStyles.rootNode={...this.savedCustomStyles.rootNode,...e.rootNode}),e.childNode&&(this.savedCustomStyles.childNode={...this.savedCustomStyles.childNode,...e.childNode}),e.connection&&(this.savedCustomStyles.connection={...this.savedCustomStyles.connection,...e.connection}),e.canvas&&(this.savedCustomStyles.canvas={...this.savedCustomStyles.canvas,...e.canvas}),this.mindMap.theme==="custom"&&this.applyCustomStylesToDOM(this.savedCustomStyles)}setTheme(e){if(this.service.setTheme(e),this.layoutSwitcher&&this.layoutSwitcher.setTheme(e),e==="custom")this.applyCustomStylesToDOM(this.savedCustomStyles);else{const t=this.renderer.container;["--mindmap-root-border","--mindmap-root-background","--mindmap-root-color","--mindmap-child-border","--mindmap-child-background","--mindmap-child-color","--mindmap-connection-color","--mindmap-canvas-background"].forEach(o=>t.style.removeProperty(o)),t.style.backgroundColor="var(--vscode-editor-background, transparent)"}this.render(),this.eventBus.emit("model:change",void 0)}resetZoom(){const e=this.renderer.container.clientWidth/2,t=this.renderer.container.clientHeight/2,i=1;this.panX=e-(e-this.panX)*(i/this.scale),this.panY=t-(t-this.panY)*(i/this.scale),this.scale=i,this.targetPanX=this.panX,this.targetPanY=this.panY,this.render()}panBoard(e,t){this.targetPanX+=e,this.targetPanY+=t}zoomBoard(e,t,i){const d=this.renderer.container.getBoundingClientRect(),l=t-d.left,r=i-d.top,h=Math.min(Math.max(this.scale*(1-e*.001),.1),5),a=l-(l-this.panX)*(h/this.scale),c=r-(r-this.panY)*(h/this.scale);this.panX=a,this.panY=c,this.targetPanX=a,this.targetPanY=c,this.scale=h,this.renderer.updateTransform(this.panX,this.panY,this.scale)}setReadOnly(e){this.interactionHandler&&this.interactionHandler.setReadOnly(e),e&&this.styleEditor.hide()}undo(){this.service.undo()&&(this.render(),this.eventBus.emit("model:change",void 0))}redo(){this.service.redo()&&(this.render(),this.eventBus.emit("model:change",void 0))}toggleFold(e){this.service.toggleNodeFold(e)&&(this.render(),this.eventBus.emit("model:change",void 0))}navigateNode(e,t){const i=this.mindMap.findNode(e);if(!i)return;let o;switch(t){case"Left":o=this.navigateLeft(i);break;case"Right":o=this.navigateRight(i);break;case"Up":o=this.navigateUp(i);break;case"Down":o=this.navigateDown(i);break}o&&this.selectNode(o),this.selectedNodeId&&this.selectedNodeId!==e&&setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0),0)}copyNode(e){this.service.copyNode(e)}pasteNode(e){const t=this.service.pasteNode(e);t&&(this.render(),this.selectNode(t.id),this.eventBus.emit("node:add",{id:t.id,topic:t.topic}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(t.id,!0),0))}cutNode(e){const t=this.mindMap.findNode(e);if(t){const i=t.parentId;this.service.cutNode(e),i&&this.selectNode(i),this.render(),this.eventBus.emit("node:remove",e),this.eventBus.emit("model:change",void 0)}}pasteImage(e,t){const i=this.service.addImageNode(e,t);i&&(this.render(),this.selectNode(i.id),this.eventBus.emit("node:add",{id:i.id,topic:""}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(i.id,!0),0))}onEditEnd(){this.pendingNodeCreation&&(this.pendingNodeCreation=!1,this.eventBus.emit("model:change",void 0))}onStyleAction(e,t){if(this.interactionHandler&&this.interactionHandler.isReadOnly)return;const i=this.mindMap.findNode(e);if(!i)return;const o=i.style||{};let s=null;if(t.type==="bold")s={fontWeight:o.fontWeight==="bold"?"normal":"bold"};else if(t.type==="italic")s={fontStyle:o.fontStyle==="italic"?"normal":"italic"};else if(t.type==="color")t.index>=0&&t.index<C.PALETTE.length&&(s={color:C.PALETTE[t.index]});else if(t.type==="increaseSize"||t.type==="decreaseSize"){const n=C.FONT_SIZES,d=o.fontSize||"";let l=n.findIndex(h=>h.value===d);l===-1&&(l=0);let r=l;t.type==="increaseSize"?r=Math.min(n.length-1,l+1):r=Math.max(0,l-1),r!==l&&(s={fontSize:n[r].value})}s&&this.service.updateNodeStyle(e,s)&&(this.render(),this.eventBus.emit("model:change",void 0),this.selectedNodeId===e&&this.styleEditor.show(e,{...o,...s}))}applyCustomStylesToDOM(e){const t={};e.rootNode?.border&&(t["--mindmap-root-border"]=e.rootNode.border),e.rootNode?.background&&(t["--mindmap-root-background"]=e.rootNode.background),e.rootNode?.color&&(t["--mindmap-root-color"]=e.rootNode.color),e.childNode?.border&&(t["--mindmap-child-border"]=e.childNode.border),e.childNode?.background&&(t["--mindmap-child-background"]=e.childNode.background),e.childNode?.color&&(t["--mindmap-child-color"]=e.childNode.color),e.connection?.color&&(t["--mindmap-connection-color"]=e.connection.color),e.canvas?.background&&(t["--mindmap-canvas-background"]=e.canvas.background);const i=this.renderer.container;Object.entries(t).forEach(([o,s])=>i.style.setProperty(o,s)),e.canvas?.background&&(i.style.backgroundColor="var(--mindmap-canvas-background, transparent)")}ensureExplicitLayoutSides(e){!e.isRoot||this.layoutMode!=="Both"||e.children.forEach((t,i)=>{t.layoutSide||(t.layoutSide=i%2===0?"right":"left")})}getNodeDirection(e){if(e.isRoot||this.layoutMode==="Right")return"right";if(this.layoutMode==="Left")return"left";let t=e;for(;t.parentId;){const i=this.mindMap.findNode(t.parentId);if(!i)break;if(i.isRoot)return t.layoutSide?t.layoutSide:i.children.findIndex(s=>s.id===t.id)%2===0?"right":"left";t=i}return"right"}startAnimationLoop(){let e=performance.now();const t=()=>{const i=performance.now(),o=(i-e)/1e3;e=i;const s=1-Math.exp(-8*o),n=this.targetPanX-this.panX,d=this.targetPanY-this.panY;Math.abs(n)>.1||Math.abs(d)>.1?(this.panX+=n*s,this.panY+=d*s,this.renderer.updateTransform(this.panX,this.panY,this.scale)):(this.panX!==this.targetPanX||this.panY!==this.targetPanY)&&(this.panX=this.targetPanX,this.panY=this.targetPanY,this.renderer.updateTransform(this.panX,this.panY,this.scale)),Number.isNaN(this.panX)&&(this.panX=0),Number.isNaN(this.panY)&&(this.panY=0),this.animationFrameId=requestAnimationFrame(t)};t()}ensureNodeVisible(e,t=!1,i=!1){const o=this.renderer.container.querySelector(`.mindmap-node[data-id="${e}"]`);if(!o)return;const s=o.getBoundingClientRect(),n=this.renderer.container.getBoundingClientRect(),d=50;let l=0,r=0;const h=s.left<n.left+d,a=s.right>n.right-d,c=s.top<n.top+d,p=s.bottom>n.bottom-d;if(t&&(h||a||c||p)){const g=s.left+s.width/2,m=s.top+s.height/2,y=n.left+n.width/2,u=n.top+n.height/2;l=y-g,r=u-m}else h?l=n.left+d-s.left:a&&(l=n.right-d-s.right),c?r=n.top+d-s.top:p&&(r=n.bottom-d-s.bottom);(l!==0||r!==0)&&(i?(this.panX+=l,this.panY+=r,this.targetPanX=this.panX,this.targetPanY=this.panY,this.renderer.updateTransform(this.panX,this.panY,this.scale)):this.panBoard(l,r))}navigateLeft(e){if(e.isRoot){if(this.layoutMode==="Left")return e.children.length>0?e.children[0].id:void 0;if(this.layoutMode==="Both"){const t=e.children.find((i,o)=>(i.layoutSide||(o%2!==0?"left":"right"))==="left");return t?t.id:void 0}}else if(e.parentId)return this.getNodeDirection(e)==="right"?e.parentId:e.children.length>0?e.children[0].id:void 0}navigateRight(e){if(e.isRoot){if(this.layoutMode==="Right")return e.children.length>0?e.children[0].id:void 0;if(this.layoutMode==="Both"){const t=e.children.find((i,o)=>(i.layoutSide||(o%2===0?"right":"left"))==="right");return t?t.id:void 0}}else if(e.parentId)return this.getNodeDirection(e)==="right"?e.children.length>0?e.children[0].id:void 0:e.parentId}navigateUp(e){if(e.parentId){const t=this.mindMap.findNode(e.parentId);if(t){const i=this.getNodeDirection(e),o=t.children.filter(n=>this.getNodeDirection(n)===i),s=o.findIndex(n=>n.id===e.id);if(s>0)return o[s-1].id}}}navigateDown(e){if(e.parentId){const t=this.mindMap.findNode(e.parentId);if(t){const i=this.getNodeDirection(e),o=t.children.filter(n=>this.getNodeDirection(n)===i),s=o.findIndex(n=>n.id===e.id);if(s!==-1&&s<o.length-1)return o[s+1].id}}}showShortcutModal(){if(!this.interactionHandler||typeof document>"u")return;const e=document.createElement("div");e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100vw",e.style.height="100vh",e.style.backgroundColor="rgba(0,0,0,0.5)",e.style.zIndex="3000",e.style.display="flex",e.style.justifyContent="center",e.style.alignItems="center",e.style.opacity="0",e.style.transition="opacity 0.2s";const t=document.createElement("div");t.style.backgroundColor="white",t.style.padding="20px",t.style.borderRadius="8px",t.style.boxShadow="0 4px 6px rgba(0,0,0,0.1)",t.style.maxWidth="600px",t.style.width="90%",t.style.maxHeight="90vh",t.style.overflowY="auto",t.style.position="relative";const i=document.createElement("h2");i.textContent="Keyboard Shortcuts",i.style.margin="0 0 15px 0",i.style.fontSize="1.5em",i.style.borderBottom="1px solid #eee",i.style.paddingBottom="10px",t.appendChild(i);const o=document.createElement("button");o.textContent="×",o.style.position="absolute",o.style.top="10px",o.style.right="15px",o.style.background="none",o.style.border="none",o.style.fontSize="24px",o.style.cursor="pointer",o.style.color="#999",o.addEventListener("click",()=>{d()}),t.appendChild(o);const s=this.interactionHandler.getShortcuts();[{title:"General",actions:[{action:"navUp",desc:"Move Selection Up",descJa:"ノード間の移動 (上)"},{action:"navDown",desc:"Move Selection Down",descJa:"ノード間の移動 (下)"},{action:"navLeft",desc:"Move Selection Left",descJa:"ノード間の移動 (左)"},{action:"navRight",desc:"Move Selection Right",descJa:"ノード間の移動 (右)"},{action:"beginEdit",desc:"Start Editing (Zoom if Image)",descJa:"ノードの編集を開始 (画像の場合はズーム)"},{action:"addSibling",desc:"Add Sibling (Below)",descJa:"兄弟ノードを追加 (下)"},{action:"addSiblingBefore",desc:"Add Sibling (Above)",descJa:"兄弟ノードを追加 (上)"},{action:"addChild",desc:"Add Child",descJa:"子ノードを追加"},{action:"insertParent",desc:"Insert Parent",descJa:"親ノードを挿入"},{action:"deleteNode",desc:"Delete Node",descJa:"ノードを削除"},{action:"undo",desc:"Undo",descJa:"元に戻す (Undo)"},{action:"redo",desc:"Redo",descJa:"やり直し (Redo)"},{action:"copy",desc:"Copy",descJa:"コピー"},{action:"cut",desc:"Cut",descJa:"切り取り"},{action:"paste",desc:"Paste",descJa:"貼り付け (画像も可)"},{action:"toggleFold",desc:"Toggle Fold",descJa:"ノードの展開/折り畳み"},{action:"scaleUp",desc:"Canvas Zoom In",descJa:"キャンバス拡大"},{action:"scaleDown",desc:"Canvas Zoom Out",descJa:"キャンバス縮小"},{action:"resetZoom",desc:"Reset Zoom",descJa:"ズームリセット"},{key:"Drag (Canvas)",desc:"Pan Board",descJa:"画面のパン (移動)"},{key:"Wheel",desc:"Vertical Scroll",descJa:"上下スクロール (パン)"},{key:"Shift + Wheel",desc:"Horizontal Scroll",descJa:"左右スクロール (パン)"},{key:"Ctrl/Cmd + Wheel",desc:"Zoom",descJa:"ズームイン/アウト"}]},{title:"Editing (Text Input)",actions:[{key:"Enter",desc:"Confirm Edit",descJa:"編集を確定"},{key:"Shift + Enter",desc:"New Line",descJa:"改行"},{key:"Esc",desc:"Cancel Edit",descJa:"編集をキャンセル"}]},{title:"Styling (Selection)",actions:[{action:"bold",desc:"Toggle Bold",descJa:"太字 (Bold) 切り替え"},{action:"italic",desc:"Toggle Italic",descJa:"斜体 (Italic) 切り替え"},{action:"selectColor1",desc:"Color 1",descJa:"ノードの色を変更 (1)"},{action:"selectColor2",desc:"Color 2",descJa:"ノードの色を変更 (2)"},{action:"selectColor3",desc:"Color 3",descJa:"ノードの色を変更 (3)"},{action:"selectColor4",desc:"Color 4",descJa:"ノードの色を変更 (4)"},{action:"selectColor5",desc:"Color 5",descJa:"ノードの色を変更 (5)"},{action:"selectColor6",desc:"Color 6",descJa:"ノードの色を変更 (6)"},{action:"selectColor7",desc:"Color 7",descJa:"ノードの色を変更 (7)"},{key:"Shift + . (>)",desc:"Increase Font Size",descJa:"フォントサイズ拡大"},{key:"Shift + , (<)",desc:"Decrease Font Size",descJa:"フォントサイズ縮小"}]}].forEach(r=>{const h=[];if(r.actions.forEach(y=>{let u="";const f=y;if(f.key)u=f.key;else if(f.action&&s[f.action]){const v=s[f.action];if(v&&v.length>0){const k=v.map(x=>{const S=[];return(x.ctrlKey||x.metaKey)&&S.push("Ctrl/Cmd"),x.altKey&&S.push("Alt"),x.shiftKey&&S.push("Shift"),x.key===" "?S.push("Space"):S.push(x.key),S.join(" + ")});u=[...new Set(k)].join(" / ")}}u&&h.push({key:u,desc:f.descJa||f.desc})}),h.length===0)return;const a=document.createElement("h3");a.textContent=r.title,a.style.marginTop="20px",a.style.marginBottom="10px",a.style.fontSize="1.2em",a.style.color="#333",a.style.borderBottom="1px solid #f0f0f0",t.appendChild(a);const c=document.createElement("table");c.style.width="100%",c.style.borderCollapse="collapse",c.style.fontSize="0.9em";const p=document.createElement("tr");p.style.borderBottom="2px solid #ddd";const g=document.createElement("th");g.textContent="Key",g.style.textAlign="center",g.style.padding="8px 0",g.style.width="40%",g.style.color="#666";const m=document.createElement("th");m.textContent="Description",m.style.textAlign="center",m.style.padding="8px 0",m.style.color="#666",p.appendChild(g),p.appendChild(m),c.appendChild(p),h.forEach(y=>{const u=document.createElement("tr");u.style.borderBottom="1px solid #f9f9f9";const f=document.createElement("td");f.textContent=y.key,f.style.padding="6px 0",f.style.fontWeight="bold",f.style.color="#555",f.style.minWidth="180px",f.style.textAlign="center";const v=document.createElement("td");v.textContent=y.desc,v.style.padding="6px 0",v.style.textAlign="left",v.style.color="#333",u.appendChild(f),u.appendChild(v),c.appendChild(u)}),t.appendChild(c)}),e.appendChild(t),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1"});const d=()=>{e.style.opacity="0",setTimeout(()=>{document.body.contains(e)&&document.body.removeChild(e)},200),document.removeEventListener("keydown",l)},l=r=>{r.key==="Escape"&&d()};document.addEventListener("keydown",l),e.addEventListener("click",r=>{r.target===e&&d()})}}class W{listeners={};on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e]?.push(t)}addListener(e,t){this.on(e,t)}off(e,t){const i=this.listeners[e];i&&(this.listeners[e]=i.filter(o=>o!==t))}removeListener(e,t){this.off(e,t)}emit(e,t){this.listeners[e]?.forEach(i=>i(t))}}class z{generate(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+Math.random().toString(36).substr(2)}}class H extends W{mindMap;controller;constructor(e,t={}){super();const i=new b("root","Root Topic",null,!0);this.mindMap=new E(i);const o=new z,s=new M(this.mindMap,o),n=document.createElement("div");n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",n.style.zIndex="2000",e.style.overscrollBehavior="none",e.style.touchAction="none",e.appendChild(n);const d=new C(n),l=new w(e,{onImageZoom:a=>this.controller.setReadOnly(a),onToggleFold:a=>this.controller.toggleFold(a)});this.controller=new A(this.mindMap,s,l,d,{emit:(a,c)=>this.emit(a,c)}),d.onUpdate=(a,c)=>{this.controller.updateNode(a,{style:c})};const r=new P(e,{onNodeClick:a=>this.controller.selectNode(a||null),onAddChild:a=>this.controller.addChildNode(a),onInsertParent:a=>this.controller.insertParentNode(a),onAddSibling:(a,c)=>this.controller.addSiblingNode(a,c),onDeleteNode:a=>this.controller.removeNode(a),onDropNode:(a,c,p)=>this.controller.moveNode(a,c,p),onUpdateNode:(a,c)=>this.controller.updateNodeTopic(a,c),onNavigate:(a,c)=>this.controller.navigateNode(a,c),onPan:(a,c)=>this.controller.panBoard(a,c),onCopyNode:a=>this.controller.copyNode(a),onPasteNode:a=>this.controller.pasteNode(a),onCutNode:a=>this.controller.cutNode(a),onPasteImage:(a,c)=>this.controller.pasteImage(a,c),onZoom:(a,c,p)=>this.controller.zoomBoard(a,c,p),onZoomReset:()=>this.controller.resetZoom(),onUndo:()=>this.controller.undo(),onRedo:()=>this.controller.redo(),onStyleAction:(a,c)=>this.controller.onStyleAction(a,c),onEditEnd:a=>this.controller.onEditEnd(),onToggleFold:a=>this.controller.toggleFold(a),shortcuts:t.shortcuts});this.controller.setInteractionHandler(r);const h=new B(n,{onLayoutChange:a=>this.controller.setLayoutMode(a),onThemeChange:a=>this.controller.setTheme(a),onZoomReset:()=>this.controller.resetZoom(),onShowShortcuts:()=>this.controller.showShortcutModal()});this.controller.setLayoutSwitcher(h),t.maxNodeWidth!==void 0&&this.controller.setMaxNodeWidth(t.maxNodeWidth),t.customStyles&&this.controller.updateGlobalStyles(t.customStyles),this.controller.init(e.clientWidth)}addNode(e,t,i,o={emitChange:!0}){return this.controller.addNode(e,t,i,o)}addSibling(e,t="after",i="New topic",o={emitChange:!0}){return this.controller.addSibling(e,t,i,o)}insertParent(e,t="New topic",i={emitChange:!0}){return this.controller.insertParent(e,t,i)}deleteNode(e){this.controller.deleteNode(e)}updateNode(e,t){this.controller.updateNode(e,t)}undo(){this.controller.undo()}redo(){this.controller.redo()}toggleFold(e){this.controller.toggleFold(e)}getSelectedNodeId(){return this.controller.selectedNodeId}updateNodeStyle(e,t){this.controller.updateNode(e,{style:t})}setTheme(e){this.controller.setTheme(e)}getMindMap(){return this.mindMap}getNode(e){return this.mindMap.findNode(e)||void 0}getRoot(){return this.mindMap.root}findNodes(e){const t=[],i=o=>{e(o)&&t.push(o),o.children.forEach(i)};return i(this.mindMap.root),t}setMaxNodeWidth(e){this.controller.setMaxNodeWidth(e)}getMaxNodeWidth(){return this.controller.getMaxNodeWidth()}updateGlobalStyles(e){this.controller.updateGlobalStyles(e)}setReadOnly(e){this.controller.setReadOnly(e)}destroy(){this.controller.destroy(),this.controller.interactionHandler?.destroy()}batch(e){this.controller.isBatching=!0;try{e()}finally{this.controller.isBatching=!1,this.controller.render()}}addChildNode(e){this.controller.addChildNode(e)}addSiblingNode(e,t="after"){this.controller.addSiblingNode(e,t)}insertParentNode(e){this.controller.insertParentNode(e)}removeNode(e){this.controller.removeNode(e)}moveNode(e,t,i){this.controller.moveNode(e,t,i)}updateNodeTopic(e,t){this.controller.updateNodeTopic(e,t)}selectNode(e){this.controller.selectNode(e)}panBoard(e,t){this.controller.panBoard(e,t)}zoomBoard(e,t,i){this.controller.zoomBoard(e,t,i)}resetZoom(){this.controller.resetZoom()}copyNode(e){this.controller.copyNode(e)}pasteNode(e){this.controller.pasteNode(e)}pasteImage(e,t){this.controller.pasteImage(e,t)}cutNode(e){this.controller.cutNode(e)}updateLayout(e){e==="Standard"?this.controller.setLayoutMode("Both"):this.controller.setLayoutMode(e)}setLayoutMode(e){this.controller.setLayoutMode(e)}getLayoutMode(){return this.controller.getLayoutMode()}navigateNode(e,t){this.controller.navigateNode(e,t)}getData(){return this.controller.getData()}loadData(e){this.controller.loadData(e)}getRootId(){return this.mindMap.root.id}}exports.Kakidash=H;
|
|
54
|
+
`,document.head.appendChild(e)}handleDragStart(e){const t=e;if(this.isReadOnly){t.preventDefault();return}const o=t.target.closest(".mindmap-node");o&&o.dataset.id&&(this.draggedNodeId=o.dataset.id,t.dataTransfer?.setData("text/plain",o.dataset.id),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}handleDragOver(e){const t=e;if(this.isReadOnly)return;t.preventDefault();const o=t.target.closest(".mindmap-node");if(o&&o.dataset.id&&this.draggedNodeId&&o.dataset.id!==this.draggedNodeId){const s=this.getDropPosition(t,o);o.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right"),o.classList.add(`drag-over-${s}`),t.dataTransfer&&(t.dataTransfer.dropEffect="move")}}handleDragLeave(e){const i=e.target.closest(".mindmap-node");i&&i.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}handleDrop(e){const t=e;t.preventDefault();const o=t.target.closest(".mindmap-node");if(this.container.querySelectorAll(".mindmap-node").forEach(s=>{s.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}),!this.isReadOnly){if(o&&o.dataset.id&&this.draggedNodeId){const s=o.dataset.id;if(this.draggedNodeId!==s){const n=this.getDropPosition(t,o);this.options.onDropNode(this.draggedNodeId,s,n)}}this.draggedNodeId=null}}handleDragEnd(){this.draggedNodeId=null,this.container.querySelectorAll(".mindmap-node").forEach(e=>{e.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")})}getDropPosition(e,t){const i=t.getBoundingClientRect(),o=e.clientX-i.left,s=e.clientY-i.top,n=i.width,r=i.height;return s<r*.25?"top":s>r*.75?"bottom":o<n*.25?"left":(o>n*.75,"right")}}class P{shortcuts;constructor(e){this.shortcuts=e}matches(e,t){const i=this.shortcuts[t];return i?i.some(o=>{const s=o.ctrlKey??!1,n=o.metaKey??!1,r=o.altKey??!1,a=o.shiftKey??!1;return e.ctrlKey!==s||e.metaKey!==n||e.altKey!==r||e.shiftKey!==a?!1:o.key.toLowerCase()===e.key.toLowerCase()}):!1}getAction(e){const t=Object.keys(this.shortcuts);for(const i of t)if(this.matches(e,i))return i}}class A{container;options;maxWidth=-1;selectedNodeId=null;isPanning=!1;lastMouseX=0;lastMouseY=0;isReadOnly=!1;shortcuts;nodeEditor;nodeDragger;shortcutManager;cleanupFns=[];constructor(e,t){this.container=e,this.container.tabIndex=0,this.container.style.outline="none",this.container.style.cursor="default",this.options=t,this.shortcuts={...D,...t.shortcuts},this.nodeEditor=new T(e,this.maxWidth,t),this.nodeDragger=new R(e,t),this.shortcutManager=new P(this.shortcuts),this.isReadOnly=!!t.allowReadOnly,this.nodeDragger.setReadOnly(this.isReadOnly),this.attachEvents()}getShortcuts(){return this.shortcuts}setReadOnly(e){this.isReadOnly=e,this.nodeDragger&&this.nodeDragger.setReadOnly(e),e&&this.nodeDragger&&this.nodeDragger.draggedNodeId&&(this.nodeDragger.draggedNodeId=null)}destroy(){this.cleanupFns.forEach(e=>e()),this.cleanupFns=[]}updateSelection(e){this.selectedNodeId=e}attachEvents(){const e=(o,s,n,r)=>{o.addEventListener(s,n,r),this.cleanupFns.push(()=>{typeof o.removeEventListener=="function"&&o.removeEventListener(s,n,r)})};e(this.container,"focus",()=>{}),e(this.container,"blur",()=>{}),e(this.container,"scroll",()=>{(this.container.scrollTop!==0||this.container.scrollLeft!==0)&&(this.container.scrollTop=0,this.container.scrollLeft=0)}),e(this.container,"click",o=>{const n=o.target.closest(".mindmap-node");n&&n.dataset.id?this.options.onNodeClick(n.dataset.id):this.options.onNodeClick(""),this.container.focus()}),e(this.container,"mousedown",o=>{const s=o,n=s.target;!n.closest(".mindmap-node")&&n.tagName!=="INPUT"&&(this.isPanning=!0,this.lastMouseX=s.clientX,this.lastMouseY=s.clientY,this.container.style.cursor="all-scroll")}),e(window,"mousemove",o=>{const s=o;if(this.isPanning){const n=s.clientX-this.lastMouseX,r=s.clientY-this.lastMouseY;this.lastMouseX=s.clientX,this.lastMouseY=s.clientY,this.options.onPan&&this.options.onPan(n,r)}});const t=()=>{this.isPanning&&(this.isPanning=!1,this.container.style.cursor="default")};e(window,"mouseup",t),e(window,"mouseleave",t),e(this.container,"wheel",o=>{const s=o;if(s.preventDefault(),s.ctrlKey||s.metaKey){this.options.onZoom&&this.options.onZoom(s.deltaY,s.clientX,s.clientY);return}let n=1;s.deltaMode===1?n=33:s.deltaMode===2&&(n=window.innerHeight);const r=-s.deltaX*n,a=-s.deltaY*n;this.options.onPan&&this.options.onPan(r,a)},{passive:!1}),e(document,"keydown",o=>{const s=o,n=s.target;if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable)return;if(this.shortcutManager.matches(s,"resetZoom")){s.preventDefault(),this.options.onZoomReset?.();return}if(this.shortcutManager.getAction(s)==="openCommandPalette"){s.preventDefault(),this.options.onToggleCommandPalette?.();return}if(!this.selectedNodeId){if(this.shortcutManager.matches(s,"navUp")||this.shortcutManager.matches(s,"navDown")||this.shortcutManager.matches(s,"navLeft")||this.shortcutManager.matches(s,"navRight")){s.preventDefault();let l=null,h=1/0;this.container.querySelectorAll(".mindmap-node").forEach(d=>{const c=d;if(!c.dataset.id)return;const g=c.getBoundingClientRect(),m=g.left+g.width/2,y=g.top+g.height/2,u=this.container.getBoundingClientRect(),p=u.left+u.width/2,N=u.top+u.height/2,b=Math.pow(m-p,2)+Math.pow(y-N,2);b<h&&(h=b,l=c.dataset.id)}),l&&this.options.onNodeClick(l)}return}const a=this.shortcutManager.getAction(s);a&&this.handleAction(a,s)}),e(document,"paste",o=>{const s=o;if(this.isReadOnly||!this.selectedNodeId)return;const n=s.clipboardData?.items;if(!n||n.length===0){this.options.onPasteNode?.(this.selectedNodeId);return}let r=!1;for(const a of n)if(a.type.startsWith("image/")){const l=a.getAsFile();if(l){const h=new FileReader;h.onload=f=>{f.target?.result&&this.options.onPasteImage&&this.selectedNodeId&&this.options.onPasteImage(this.selectedNodeId,f.target.result)},h.readAsDataURL(l)}s.preventDefault(),r=!0;break}r||this.options.onPasteNode?.(this.selectedNodeId)});const i=(o,s,n)=>e(o,s,n);i(this.container,"dragstart",this.nodeDragger.handleDragStart.bind(this.nodeDragger)),i(this.container,"dragover",this.nodeDragger.handleDragOver.bind(this.nodeDragger)),i(this.container,"dragleave",this.nodeDragger.handleDragLeave.bind(this.nodeDragger)),i(this.container,"drop",this.nodeDragger.handleDrop.bind(this.nodeDragger)),i(this.container,"dragend",this.nodeDragger.handleDragEnd.bind(this.nodeDragger)),e(this.container,"dblclick",o=>{if(this.isReadOnly)return;const n=o.target.closest(".mindmap-node");n&&n.dataset.id&&this.startEditing(n,n.dataset.id)})}editNode(e){const t=this.container.querySelector(`.mindmap-node[data-id="${e}"]`);t&&this.startEditing(t,e)}get draggedNodeId(){return this.nodeDragger?this.nodeDragger.draggedNodeId:null}set draggedNodeId(e){this.nodeDragger&&(this.nodeDragger.draggedNodeId=e)}startEditing(e,t){this.nodeEditor.setMaxWidth(this.maxWidth),this.nodeEditor.startEditing(e,t)}handleAction(e,t){if(this.selectedNodeId){switch(e){case"copy":t.preventDefault(),this.options.onCopyNode?.(this.selectedNodeId);return;case"navUp":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Up");return;case"navDown":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Down");return;case"navRight":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Right");return;case"navLeft":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Left");return}if(!this.isReadOnly)switch(e){case"addChild":t.preventDefault(),this.options.onAddChild(this.selectedNodeId);break;case"insertParent":t.preventDefault(),this.options.onInsertParent?.(this.selectedNodeId);break;case"addSibling":t.preventDefault(),this.options.onAddSibling(this.selectedNodeId,"after");break;case"addSiblingBefore":t.preventDefault(),this.options.onAddSibling(this.selectedNodeId,"before");break;case"deleteNode":t.preventDefault(),this.options.onDeleteNode(this.selectedNodeId);break;case"beginEdit":t.preventDefault(),this.handleBeginEdit();break;case"scaleUp":if(t.preventDefault(),this.options.onZoom){const i=this.container.getBoundingClientRect();this.options.onZoom(-100,i.left+i.width/2,i.top+i.height/2)}break;case"scaleDown":if(t.preventDefault(),this.options.onZoom){const i=this.container.getBoundingClientRect();this.options.onZoom(100,i.left+i.width/2,i.top+i.height/2)}break;case"cut":t.preventDefault(),this.options.onCutNode?.(this.selectedNodeId);break;case"undo":t.preventDefault(),this.options.onUndo?.();break;case"redo":t.preventDefault(),this.options.onRedo?.();break;case"bold":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"bold"});break;case"italic":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"italic"});break;case"zoomIn":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"increaseSize"});break;case"zoomOut":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"decreaseSize"});break;case"toggleFold":t.preventDefault(),this.options.onToggleFold?.(this.selectedNodeId);break;case"openCommandPalette":t.preventDefault(),this.options.onToggleCommandPalette?.();break;default:if(e.startsWith("selectColor")){const i=parseInt(e.replace("selectColor",""),10)-1;isNaN(i)||(t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"color",index:i}))}break}}}handleBeginEdit(){if(!this.selectedNodeId)return;const e=this.container.querySelector(`.mindmap-node[data-id="${this.selectedNodeId}"]`);if(e){const t=e.querySelector('[title="Zoom Image"]');if(t){t.click();return}if(e.querySelector("img"))return;this.startEditing(e,this.selectedNodeId)}}}class z{container;overlay;paletteEl;inputEl;resultListEl;options;results=[];selectedIndex=-1;mode="menu";MENU_COMMANDS=[{id:"search-nodes",topic:"> Search Nodes",type:"command"},{id:"icon",topic:"> Icon",type:"command"}];ICON_LIST=[{id:"delete",topic:"🗑️ 削除 (Delete)",type:"icon"},{id:"blue_circle",topic:"Good",type:"icon"},{id:"red_circle",topic:"Bad",type:"icon"},{id:"question",topic:"Question",type:"icon"},{id:"important",topic:"Important",type:"icon"},{id:"check",topic:"Check",type:"icon"},{id:"cross",topic:"Cross",type:"icon"},{id:"flag",topic:"Flag",type:"icon"},{id:"idea",topic:"Idea",type:"icon"},{id:"warning",topic:"Warning",type:"icon"},{id:"schedule",topic:"Schedule",type:"icon"}];constructor(e,t){this.container=e,this.options=t,this.overlay=this.createOverlay(),this.paletteEl=this.createPalette(),this.inputEl=this.paletteEl.querySelector("input"),this.resultListEl=this.paletteEl.querySelector("ul"),this.container.appendChild(this.overlay),this.container.appendChild(this.paletteEl)}createOverlay(){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.backgroundColor="rgba(0, 0, 0, 0.1)",e.style.zIndex="1999",e.style.display="none",e.addEventListener("click",()=>{this.close()}),e}createPalette(){const e=document.createElement("div");e.className="command-palette",e.style.position="absolute",e.style.top="20px",e.style.left="50%",e.style.transform="translateX(-50%)",e.style.width="400px",e.style.backgroundColor="white",e.style.borderRadius="8px",e.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)",e.style.border="1px solid #eee",e.style.zIndex="2000",e.style.display="none",e.style.flexDirection="column",e.style.overflow="hidden",e.style.padding="8px",e.style.boxSizing="border-box",e.style.fontFamily="Arial, sans-serif";const t=document.createElement("input");t.type="text",t.placeholder="Type > to search commands...",t.style.width="100%",t.style.boxSizing="border-box",t.style.padding="4px 8px",t.style.height="32px",t.style.border="1px solid #ccc",t.style.borderRadius="4px",t.style.fontSize="14px",t.style.outline="none",t.style.marginBottom="0",t.addEventListener("input",o=>{const s=o.target.value;if(this.mode==="menu"){const n=this.MENU_COMMANDS.filter(r=>r.topic.toLowerCase().includes(s.toLowerCase()));this.renderList(n)}else if(this.mode==="icon"){const n=this.ICON_LIST.filter(r=>r.topic.toLowerCase().includes(s.toLowerCase()));this.renderList(n)}else this.options.onInput(s)}),t.addEventListener("keydown",o=>{o.key==="ArrowDown"?(o.preventDefault(),this.moveSelection(1)):o.key==="ArrowUp"?(o.preventDefault(),this.moveSelection(-1)):o.key==="Enter"?(o.preventDefault(),this.confirmSelection()):o.key==="Escape"?(o.preventDefault(),this.close()):o.key==="Backspace"&&this.inputEl.value===""&&(this.mode==="search"||this.mode==="icon")&&(this.mode="menu",this.inputEl.placeholder="Type to filter commands...",this.renderList(this.MENU_COMMANDS))});const i=document.createElement("ul");return i.style.listStyle="none",i.style.margin="8px 0 0 0",i.style.padding="0",i.style.maxHeight="300px",i.style.overflowY="auto",i.style.display="none",i.style.borderTop="1px solid #eee",e.appendChild(t),e.appendChild(i),e}show(){this.mode="menu",this.overlay.style.display="block",this.paletteEl.style.display="flex",this.inputEl.value="",this.inputEl.placeholder="Type to filter commands...",this.inputEl.focus(),this.renderList(this.MENU_COMMANDS)}close(){this.overlay.style.display="none",this.paletteEl.style.display="none",this.options.onClose(),this.mode="menu"}toggle(){this.paletteEl.style.display==="none"?this.show():this.close()}setResults(e){this.mode==="search"&&this.renderList(e.map(t=>({...t,type:"node"})))}renderList(e){if(this.results=e,this.resultListEl.innerHTML="",this.selectedIndex=-1,e.length===0){if(this.inputEl.value.trim()!==""&&(this.mode==="search"||this.mode==="icon")){const t=document.createElement("li");t.textContent="No results found",t.style.padding="8px",t.style.color="#999",t.style.fontSize="12px",t.style.textAlign="center",this.resultListEl.appendChild(t),this.resultListEl.style.display="block"}else this.mode==="menu"&&e.length===0?this.resultListEl.style.display="none":this.resultListEl.style.display="none";return}this.resultListEl.style.display="block",e.forEach((t,i)=>{const o=document.createElement("li");if(o.style.borderBottom="1px solid #f9f9f9",t.type==="icon"&&t.id!=="delete"){o.style.display="flex",o.style.alignItems="center";const s=I[t.id];if(s){const r=document.createElement("div");r.style.width="20px",r.style.height="20px",r.style.marginRight="8px",r.style.flexShrink="0",r.innerHTML=`<svg viewBox="${s.viewBox}" width="20" height="20">${s.path}</svg>`,o.appendChild(r)}const n=document.createElement("span");n.textContent=t.topic,o.appendChild(n)}else o.textContent=t.topic;o.addEventListener("mouseenter",()=>{this.setSelectedIndex(i)}),o.addEventListener("click",()=>{this.selectItem(t)}),this.resultListEl.appendChild(o)}),e.length>0&&this.setSelectedIndex(0)}selectItem(e){e.type==="command"?e.id==="search-nodes"?this.switchToSearchMode():e.id==="icon"&&this.switchToIconMode():e.type==="icon"?(this.options.onIconSelect(e.id),this.close()):(this.options.onSelect(e.id),this.close())}switchToSearchMode(){this.mode="search",this.inputEl.value="",this.inputEl.placeholder="Search nodes...",this.renderList([]),this.resultListEl.style.display="none",this.inputEl.focus()}switchToIconMode(){this.mode="icon",this.inputEl.value="",this.inputEl.placeholder="Select icon...",this.renderList(this.ICON_LIST),this.inputEl.focus()}moveSelection(e){if(this.results.length===0)return;const t=Math.max(0,Math.min(this.results.length-1,this.selectedIndex+e));this.setSelectedIndex(t),this.scrollToSelected()}setSelectedIndex(e){this.selectedIndex=e;const t=this.resultListEl.children;for(let i=0;i<t.length;i++){const o=t[i];i===e?(o.style.backgroundColor="#007acc",o.style.color="white"):(o.style.backgroundColor="transparent",o.style.color="black")}}scrollToSelected(){const e=this.resultListEl.children;this.selectedIndex>=0&&this.selectedIndex<e.length&&e[this.selectedIndex].scrollIntoView({block:"nearest"})}confirmSelection(){this.selectedIndex>=0&&this.selectedIndex<this.results.length&&this.selectItem(this.results[this.selectedIndex])}}class H{mindMap;service;renderer;eventBus;styleEditor;commandPalette;interactionHandler;layoutSwitcher;selectedNodeId=null;layoutMode="Right";panX=0;panY=0;targetPanX=0;targetPanY=0;scale=1;isBatching=!1;animationFrameId=null;maxWidth=-1;pendingNodeCreation=!1;savedCustomStyles={rootNode:{border:"2px solid #aeb6bf",background:"#ebf5fb",color:"#2e4053"},childNode:{border:"1px solid #d5d8dc",background:"#fdfefe",color:"#2c3e50"},connection:{color:"#abb2b9"}};constructor(e,t,i,o,s){this.mindMap=e,this.service=t,this.renderer=i,this.styleEditor=o,this.eventBus=s,this.commandPalette=new z(this.renderer.container,{onInput:n=>this.handleSearchInput(n),onSelect:n=>this.handleSearchResultSelect(n),onIconSelect:n=>this.handleIconSelect(n),onClose:()=>{this.interactionHandler&&this.interactionHandler.container.focus()}})}setInteractionHandler(e){this.interactionHandler=e}setLayoutSwitcher(e){this.layoutSwitcher=e}init(e){this.panX=e*.2,this.targetPanX=this.panX,this.startAnimationLoop(),this.render()}destroy(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}getData(){const e=this.service.exportData();return e.selectedId=this.selectedNodeId||void 0,e}loadData(e){try{this.service.importData(e),e.selectedId?this.selectNode(e.selectedId):this.selectNode(null),this.render(),this.eventBus.emit("model:load",e),e.theme&&this.setTheme(e.theme),this.eventBus.emit("model:change",void 0)}catch(t){console.error("Failed to load data",t)}}batch(e){this.isBatching=!0;try{e()}finally{this.isBatching=!1,this.render()}}getSelectedNodeId(){return this.selectedNodeId}addNode(e,t,i,o={emitChange:!0}){const s=this.service.addNode(e,t,i);return s&&(this.render(),this.eventBus.emit("node:add",{id:s.id,topic:s.topic}),o.emitChange&&this.eventBus.emit("model:change",void 0)),s}addSibling(e,t="after",i="New topic",o={emitChange:!0}){const s=this.mindMap.findNode(e);if(!s||!s.parentId)return null;const n=this.mindMap.findNode(s.parentId);n&&n.isRoot&&this.layoutMode==="Both"&&this.ensureExplicitLayoutSides(n);const r=this.service.addSibling(e,t,i);if(r){if(n&&n.isRoot&&this.layoutMode==="Both"){const a=s.layoutSide||(n.children.indexOf(s)%2===0?"right":"left");r.layoutSide=a}this.render(),this.eventBus.emit("node:add",{id:r.id,topic:r.topic}),o.emitChange&&this.eventBus.emit("model:change",void 0)}return r}insertParent(e,t="New topic",i={emitChange:!0}){const o=this.service.insertParent(e,t);return o&&(this.render(),this.eventBus.emit("node:add",{id:o.id,topic:o.topic}),i.emitChange&&this.eventBus.emit("model:change",void 0)),o}deleteNode(e){this.service.removeNode(e)&&(this.render(),this.eventBus.emit("node:remove",e),this.eventBus.emit("model:change",void 0))}updateNode(e,t){let i=!1;this.interactionHandler&&this.interactionHandler.isReadOnly||(t.topic!==void 0&&this.service.updateNodeTopic(e,t.topic)&&(i=!0),t.style!==void 0&&this.service.updateNodeStyle(e,t.style)&&(i=!0),t.icon!==void 0&&this.service.updateNodeIcon(e,t.icon)&&(i=!0),i&&(this.render(),t.topic!==void 0&&this.eventBus.emit("node:update",{id:e,topic:t.topic}),this.eventBus.emit("model:change",void 0),this.pendingNodeCreation&&(this.pendingNodeCreation=!1)))}addChildNode(e){const t=this.mindMap.findNode(e);t&&t.isRoot&&this.layoutMode==="Both"&&this.ensureExplicitLayoutSides(t);let i;if(this.layoutMode==="Both"&&t&&t.isRoot){let s=0,n=0;t.children.forEach((r,a)=>{(r.layoutSide||(a%2===0?"right":"left"))==="left"?s++:n++}),i=s<n?"left":"right"}this.pendingNodeCreation=!0;const o=this.addNode(e,"New topic",i,{emitChange:!1});o&&(this.selectNode(o.id),this.ensureNodeVisible(o.id,!1,!0),this.interactionHandler.editNode(o.id))}addSiblingNode(e,t="after"){this.pendingNodeCreation=!0;const i=this.addSibling(e,t,"New topic",{emitChange:!1});i&&(this.selectNode(i.id),this.ensureNodeVisible(i.id,!1,!0),this.interactionHandler.editNode(i.id))}insertParentNode(e){this.pendingNodeCreation=!0;const t=this.insertParent(e,"New topic",{emitChange:!1});t&&(this.selectNode(t.id),this.ensureNodeVisible(t.id,!1,!0),this.interactionHandler.editNode(t.id))}removeNode(e){const i=this.mindMap.findNode(e)?.parentId||null,o=this.selectedNodeId===e;this.deleteNode(e),o&&i&&this.selectNode(i)}selectNode(e){if(this.selectedNodeId!==e){if(this.selectedNodeId=e,this.interactionHandler&&this.interactionHandler.updateSelection(e),e){const t=this.mindMap.findNode(e);t&&(!t.image&&this.interactionHandler&&!this.interactionHandler.isReadOnly?this.styleEditor.show(e,t.style):this.styleEditor.hide())}else this.styleEditor.hide();this.render(),this.eventBus.emit("node:select",e)}}moveNode(e,t,i){const o=this.mindMap.findNode(t);if(o){if(i==="top"){if(o.isRoot)return;this.service.reorderNode(e,t,"before")}else if(i==="bottom"){if(o.isRoot)return;this.service.reorderNode(e,t,"after")}else if(o.isRoot){const s=i==="left"?"left":"right";this.service.moveNode(e,t,s)}else((this.getNodeDirection(o)==="right"?i==="right":i==="left")?"addChild":"insertParent")==="addChild"?this.service.moveNode(e,t):this.service.insertNodeAsParent(e,t);this.render(),this.eventBus.emit("node:move",{nodeId:e,newParentId:t,position:i}),this.eventBus.emit("model:change",void 0)}}updateNodeTopic(e,t){this.updateNode(e,{topic:t}),setTimeout(()=>this.ensureNodeVisible(e),0)}render(){this.isBatching||(this.renderer.render(this.mindMap,this.selectedNodeId,this.layoutMode),this.renderer.updateTransform(this.panX,this.panY,this.scale))}setLayoutMode(e){this.layoutMode=e,this.layoutSwitcher&&this.layoutSwitcher.setMode(e);const t=this.renderer.container.clientWidth;e==="Right"?this.panX=t*.2:e==="Left"?this.panX=t*.8:this.panX=t*.5,this.panY=0,this.targetPanX=this.panX,this.targetPanY=this.panY,this.render()}getLayoutMode(){return this.layoutMode}setMaxNodeWidth(e){this.maxWidth=e,this.renderer.maxWidth=e,this.interactionHandler&&(this.interactionHandler.maxWidth=e),this.render()}getMaxNodeWidth(){return this.maxWidth}updateGlobalStyles(e){e.rootNode&&(this.savedCustomStyles.rootNode={...this.savedCustomStyles.rootNode,...e.rootNode}),e.childNode&&(this.savedCustomStyles.childNode={...this.savedCustomStyles.childNode,...e.childNode}),e.connection&&(this.savedCustomStyles.connection={...this.savedCustomStyles.connection,...e.connection}),e.canvas&&(this.savedCustomStyles.canvas={...this.savedCustomStyles.canvas,...e.canvas}),this.mindMap.theme==="custom"&&this.applyCustomStylesToDOM(this.savedCustomStyles)}setTheme(e){if(this.service.setTheme(e),this.layoutSwitcher&&this.layoutSwitcher.setTheme(e),e==="custom")this.applyCustomStylesToDOM(this.savedCustomStyles);else{const t=this.renderer.container;["--mindmap-root-border","--mindmap-root-background","--mindmap-root-color","--mindmap-child-border","--mindmap-child-background","--mindmap-child-color","--mindmap-connection-color","--mindmap-canvas-background"].forEach(o=>t.style.removeProperty(o)),t.style.backgroundColor="var(--vscode-editor-background, transparent)"}this.render(),this.eventBus.emit("model:change",void 0)}resetZoom(){const e=this.renderer.container.clientWidth/2,t=this.renderer.container.clientHeight/2,i=1;this.panX=e-(e-this.panX)*(i/this.scale),this.panY=t-(t-this.panY)*(i/this.scale),this.scale=i,this.targetPanX=this.panX,this.targetPanY=this.panY,this.render()}panBoard(e,t){this.targetPanX+=e,this.targetPanY+=t}zoomBoard(e,t,i){const r=this.renderer.container.getBoundingClientRect(),a=t-r.left,l=i-r.top,h=Math.min(Math.max(this.scale*(1-e*.001),.1),5),f=a-(a-this.panX)*(h/this.scale),d=l-(l-this.panY)*(h/this.scale);this.panX=f,this.panY=d,this.targetPanX=f,this.targetPanY=d,this.scale=h,this.renderer.updateTransform(this.panX,this.panY,this.scale)}setReadOnly(e){this.interactionHandler&&this.interactionHandler.setReadOnly(e),e&&this.styleEditor.hide()}undo(){this.service.undo()&&(this.render(),this.eventBus.emit("model:change",void 0))}redo(){this.service.redo()&&(this.render(),this.eventBus.emit("model:change",void 0))}toggleFold(e){this.service.toggleNodeFold(e)&&(this.render(),this.eventBus.emit("model:change",void 0))}navigateNode(e,t){const i=this.mindMap.findNode(e);if(!i)return;let o;switch(t){case"Left":o=this.navigateLeft(i);break;case"Right":o=this.navigateRight(i);break;case"Up":o=this.navigateUp(i);break;case"Down":o=this.navigateDown(i);break}o&&this.selectNode(o),this.selectedNodeId&&this.selectedNodeId!==e&&setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0),0)}copyNode(e){this.service.copyNode(e)}pasteNode(e){const t=this.service.pasteNode(e);t&&(this.render(),this.selectNode(t.id),this.eventBus.emit("node:add",{id:t.id,topic:t.topic}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(t.id,!0),0))}cutNode(e){const t=this.mindMap.findNode(e);if(t){const i=t.parentId;this.service.cutNode(e),i&&this.selectNode(i),this.render(),this.eventBus.emit("node:remove",e),this.eventBus.emit("model:change",void 0)}}pasteImage(e,t){const i=this.service.addImageNode(e,t);i&&(this.render(),this.selectNode(i.id),this.eventBus.emit("node:add",{id:i.id,topic:""}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(i.id,!0),0))}onEditEnd(){this.pendingNodeCreation&&(this.pendingNodeCreation=!1,this.eventBus.emit("model:change",void 0))}onStyleAction(e,t){if(this.interactionHandler&&this.interactionHandler.isReadOnly)return;const i=this.mindMap.findNode(e);if(!i)return;const o=i.style||{};let s=null;if(t.type==="bold")s={fontWeight:o.fontWeight==="bold"?"normal":"bold"};else if(t.type==="italic")s={fontStyle:o.fontStyle==="italic"?"normal":"italic"};else if(t.type==="color")t.index>=0&&t.index<C.PALETTE.length&&(s={color:C.PALETTE[t.index]});else if(t.type==="increaseSize"||t.type==="decreaseSize"){const n=C.FONT_SIZES,r=o.fontSize||"";let a=n.findIndex(h=>h.value===r);a===-1&&(a=0);let l=a;t.type==="increaseSize"?l=Math.min(n.length-1,a+1):l=Math.max(0,a-1),l!==a&&(s={fontSize:n[l].value})}s&&this.service.updateNodeStyle(e,s)&&(this.render(),this.eventBus.emit("model:change",void 0),this.selectedNodeId===e&&this.styleEditor.show(e,{...o,...s}))}toggleCommandPalette(){this.interactionHandler&&this.interactionHandler.isReadOnly||this.commandPalette.toggle()}searchNodes(e){return this.service.searchNodes(e)}handleSearchInput(e){const t=this.service.searchNodes(e);this.commandPalette.setResults(t.map(i=>({id:i.id,topic:i.topic})))}handleSearchResultSelect(e){this.selectNode(e),setTimeout(()=>this.ensureNodeVisible(e,!0,!0),0)}handleIconSelect(e){this.selectedNodeId&&(this.service.updateNodeIcon(this.selectedNodeId,e),this.render(),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0,!0),0))}applyCustomStylesToDOM(e){const t={};e.rootNode?.border&&(t["--mindmap-root-border"]=e.rootNode.border),e.rootNode?.background&&(t["--mindmap-root-background"]=e.rootNode.background),e.rootNode?.color&&(t["--mindmap-root-color"]=e.rootNode.color),e.childNode?.border&&(t["--mindmap-child-border"]=e.childNode.border),e.childNode?.background&&(t["--mindmap-child-background"]=e.childNode.background),e.childNode?.color&&(t["--mindmap-child-color"]=e.childNode.color),e.connection?.color&&(t["--mindmap-connection-color"]=e.connection.color),e.canvas?.background&&(t["--mindmap-canvas-background"]=e.canvas.background);const i=this.renderer.container;Object.entries(t).forEach(([o,s])=>i.style.setProperty(o,s)),e.canvas?.background&&(i.style.backgroundColor="var(--mindmap-canvas-background, transparent)")}ensureExplicitLayoutSides(e){!e.isRoot||this.layoutMode!=="Both"||e.children.forEach((t,i)=>{t.layoutSide||(t.layoutSide=i%2===0?"right":"left")})}getNodeDirection(e){if(e.isRoot||this.layoutMode==="Right")return"right";if(this.layoutMode==="Left")return"left";let t=e;for(;t.parentId;){const i=this.mindMap.findNode(t.parentId);if(!i)break;if(i.isRoot)return t.layoutSide?t.layoutSide:i.children.findIndex(s=>s.id===t.id)%2===0?"right":"left";t=i}return"right"}startAnimationLoop(){let e=performance.now();const t=()=>{const i=performance.now(),o=(i-e)/1e3;e=i;const s=1-Math.exp(-8*o),n=this.targetPanX-this.panX,r=this.targetPanY-this.panY;Math.abs(n)>.1||Math.abs(r)>.1?(this.panX+=n*s,this.panY+=r*s,this.renderer.updateTransform(this.panX,this.panY,this.scale)):(this.panX!==this.targetPanX||this.panY!==this.targetPanY)&&(this.panX=this.targetPanX,this.panY=this.targetPanY,this.renderer.updateTransform(this.panX,this.panY,this.scale)),Number.isNaN(this.panX)&&(this.panX=0),Number.isNaN(this.panY)&&(this.panY=0),this.animationFrameId=requestAnimationFrame(t)};t()}ensureNodeVisible(e,t=!1,i=!1){const o=this.renderer.container.querySelector(`.mindmap-node[data-id="${e}"]`);if(!o)return;const s=o.getBoundingClientRect(),n=this.renderer.container.getBoundingClientRect(),r=50;let a=0,l=0;const h=s.left<n.left+r,f=s.right>n.right-r,d=s.top<n.top+r,c=s.bottom>n.bottom-r;if(t&&(h||f||d||c)){const g=s.left+s.width/2,m=s.top+s.height/2,y=n.left+n.width/2,u=n.top+n.height/2;a=y-g,l=u-m}else h?a=n.left+r-s.left:f&&(a=n.right-r-s.right),d?l=n.top+r-s.top:c&&(l=n.bottom-r-s.bottom);(a!==0||l!==0)&&(i?(this.panX+=a,this.panY+=l,this.targetPanX=this.panX,this.targetPanY=this.panY,this.renderer.updateTransform(this.panX,this.panY,this.scale)):this.panBoard(a,l))}navigateLeft(e){if(e.isRoot){if(this.layoutMode==="Left")return e.children.length>0?e.children[0].id:void 0;if(this.layoutMode==="Both"){const t=e.children.find((i,o)=>(i.layoutSide||(o%2!==0?"left":"right"))==="left");return t?t.id:void 0}}else if(e.parentId)return this.getNodeDirection(e)==="right"?e.parentId:e.children.length>0?e.children[0].id:void 0}navigateRight(e){if(e.isRoot){if(this.layoutMode==="Right")return e.children.length>0?e.children[0].id:void 0;if(this.layoutMode==="Both"){const t=e.children.find((i,o)=>(i.layoutSide||(o%2===0?"right":"left"))==="right");return t?t.id:void 0}}else if(e.parentId)return this.getNodeDirection(e)==="right"?e.children.length>0?e.children[0].id:void 0:e.parentId}navigateUp(e){if(e.parentId){const t=this.mindMap.findNode(e.parentId);if(t){const i=this.getNodeDirection(e),o=t.children.filter(n=>this.getNodeDirection(n)===i),s=o.findIndex(n=>n.id===e.id);if(s>0)return o[s-1].id}}}navigateDown(e){if(e.parentId){const t=this.mindMap.findNode(e.parentId);if(t){const i=this.getNodeDirection(e),o=t.children.filter(n=>this.getNodeDirection(n)===i),s=o.findIndex(n=>n.id===e.id);if(s!==-1&&s<o.length-1)return o[s+1].id}}}showShortcutModal(){if(!this.interactionHandler||typeof document>"u")return;const e=document.createElement("div");e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100vw",e.style.height="100vh",e.style.backgroundColor="rgba(0,0,0,0.5)",e.style.zIndex="3000",e.style.display="flex",e.style.justifyContent="center",e.style.alignItems="center",e.style.opacity="0",e.style.transition="opacity 0.2s";const t=document.createElement("div");t.style.backgroundColor="white",t.style.padding="20px",t.style.borderRadius="8px",t.style.boxShadow="0 4px 6px rgba(0,0,0,0.1)",t.style.maxWidth="600px",t.style.width="90%",t.style.maxHeight="90vh",t.style.overflowY="auto",t.style.position="relative";const i=document.createElement("h2");i.textContent="Keyboard Shortcuts",i.style.margin="0 0 15px 0",i.style.fontSize="1.5em",i.style.borderBottom="1px solid #eee",i.style.paddingBottom="10px",t.appendChild(i);const o=document.createElement("button");o.textContent="×",o.style.position="absolute",o.style.top="10px",o.style.right="15px",o.style.background="none",o.style.border="none",o.style.fontSize="24px",o.style.cursor="pointer",o.style.color="#999",o.addEventListener("click",()=>{r()}),t.appendChild(o);const s=this.interactionHandler.getShortcuts();[{title:"General",actions:[{action:"openCommandPalette",desc:"Open Command Palette",descJa:"コマンドパレットを開く"},{action:"navUp",desc:"Move Selection Up",descJa:"ノード間の移動 (上)"},{action:"navDown",desc:"Move Selection Down",descJa:"ノード間の移動 (下)"},{action:"navLeft",desc:"Move Selection Left",descJa:"ノード間の移動 (左)"},{action:"navRight",desc:"Move Selection Right",descJa:"ノード間の移動 (右)"},{action:"beginEdit",desc:"Start Editing (Zoom if Image)",descJa:"ノードの編集を開始 (画像の場合はズーム)"},{action:"addSibling",desc:"Add Sibling (Below)",descJa:"兄弟ノードを追加 (下)"},{action:"addSiblingBefore",desc:"Add Sibling (Above)",descJa:"兄弟ノードを追加 (上)"},{action:"addChild",desc:"Add Child",descJa:"子ノードを追加"},{action:"insertParent",desc:"Insert Parent",descJa:"親ノードを挿入"},{action:"deleteNode",desc:"Delete Node",descJa:"ノードを削除"},{action:"undo",desc:"Undo",descJa:"元に戻す (Undo)"},{action:"redo",desc:"Redo",descJa:"やり直し (Redo)"},{action:"copy",desc:"Copy",descJa:"コピー"},{action:"cut",desc:"Cut",descJa:"切り取り"},{action:"paste",desc:"Paste",descJa:"貼り付け (画像も可)"},{action:"toggleFold",desc:"Toggle Fold",descJa:"ノードの展開/折り畳み"},{action:"scaleUp",desc:"Canvas Zoom In",descJa:"キャンバス拡大"},{action:"scaleDown",desc:"Canvas Zoom Out",descJa:"キャンバス縮小"},{action:"resetZoom",desc:"Reset Zoom",descJa:"ズームリセット"},{key:"Drag (Canvas)",desc:"Pan Board",descJa:"画面のパン (移動)"},{key:"Wheel",desc:"Vertical Scroll",descJa:"上下スクロール (パン)"},{key:"Shift + Wheel",desc:"Horizontal Scroll",descJa:"左右スクロール (パン)"},{key:"Ctrl/Cmd + Wheel",desc:"Zoom",descJa:"ズームイン/アウト"}]},{title:"Editing (Text Input)",actions:[{key:"Enter",desc:"Confirm Edit",descJa:"編集を確定"},{key:"Shift + Enter",desc:"New Line",descJa:"改行"},{key:"Esc",desc:"Cancel Edit",descJa:"編集をキャンセル"}]},{title:"Styling (Selection)",actions:[{action:"bold",desc:"Toggle Bold",descJa:"太字 (Bold) 切り替え"},{action:"italic",desc:"Toggle Italic",descJa:"斜体 (Italic) 切り替え"},{action:"selectColor1",desc:"Color 1",descJa:"ノードの色を変更 (1)"},{action:"selectColor2",desc:"Color 2",descJa:"ノードの色を変更 (2)"},{action:"selectColor3",desc:"Color 3",descJa:"ノードの色を変更 (3)"},{action:"selectColor4",desc:"Color 4",descJa:"ノードの色を変更 (4)"},{action:"selectColor5",desc:"Color 5",descJa:"ノードの色を変更 (5)"},{action:"selectColor6",desc:"Color 6",descJa:"ノードの色を変更 (6)"},{action:"selectColor7",desc:"Color 7",descJa:"ノードの色を変更 (7)"},{key:"Shift + . (>)",desc:"Increase Font Size",descJa:"フォントサイズ拡大"},{key:"Shift + , (<)",desc:"Decrease Font Size",descJa:"フォントサイズ縮小"}]}].forEach(l=>{const h=[];if(l.actions.forEach(y=>{let u="";const p=y;if(p.key)u=p.key;else if(p.action&&s[p.action]){const N=s[p.action];if(N&&N.length>0){const b=N.map(S=>{const w=[];return(S.ctrlKey||S.metaKey)&&w.push("Ctrl/Cmd"),S.altKey&&w.push("Alt"),S.shiftKey&&w.push("Shift"),S.key===" "?w.push("Space"):w.push(S.key),w.join(" + ")});u=[...new Set(b)].join(" / ")}}u&&h.push({key:u,desc:p.descJa||p.desc})}),h.length===0)return;const f=document.createElement("h3");f.textContent=l.title,f.style.marginTop="20px",f.style.marginBottom="10px",f.style.fontSize="1.2em",f.style.color="#333",f.style.borderBottom="1px solid #f0f0f0",t.appendChild(f);const d=document.createElement("table");d.style.width="100%",d.style.borderCollapse="collapse",d.style.fontSize="0.9em";const c=document.createElement("tr");c.style.borderBottom="2px solid #ddd";const g=document.createElement("th");g.textContent="Key",g.style.textAlign="center",g.style.padding="8px 0",g.style.width="40%",g.style.color="#666";const m=document.createElement("th");m.textContent="Description",m.style.textAlign="center",m.style.padding="8px 0",m.style.color="#666",c.appendChild(g),c.appendChild(m),d.appendChild(c),h.forEach(y=>{const u=document.createElement("tr");u.style.borderBottom="1px solid #f9f9f9";const p=document.createElement("td");p.textContent=y.key,p.style.padding="6px 0",p.style.fontWeight="bold",p.style.color="#555",p.style.minWidth="180px",p.style.textAlign="center";const N=document.createElement("td");N.textContent=y.desc,N.style.padding="6px 0",N.style.textAlign="left",N.style.color="#333",u.appendChild(p),u.appendChild(N),d.appendChild(u)}),t.appendChild(d)}),e.appendChild(t),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1"});const r=()=>{e.style.opacity="0",setTimeout(()=>{document.body.contains(e)&&document.body.removeChild(e)},200),document.removeEventListener("keydown",a)},a=l=>{l.key==="Escape"&&r()};document.addEventListener("keydown",a),e.addEventListener("click",l=>{l.target===e&&r()})}}class W{listeners={};on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e]?.push(t)}addListener(e,t){this.on(e,t)}off(e,t){const i=this.listeners[e];i&&(this.listeners[e]=i.filter(o=>o!==t))}removeListener(e,t){this.off(e,t)}emit(e,t){this.listeners[e]?.forEach(i=>i(t))}}class F{generate(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+Math.random().toString(36).substr(2)}}class O extends W{mindMap;controller;constructor(e,t={}){super();const i=new x("root","Root Topic",null,!0);this.mindMap=new k(i);const o=new F,s=new B(this.mindMap,o),n=document.createElement("div");n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",n.style.zIndex="2000",window.getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.style.overscrollBehavior="none",e.style.touchAction="none",e.appendChild(n);const a=new C(n),l=new E(e,{onImageZoom:d=>this.controller.setReadOnly(d),onToggleFold:d=>this.controller.toggleFold(d)});this.controller=new H(this.mindMap,s,l,a,{emit:(d,c)=>this.emit(d,c)}),a.onUpdate=(d,c)=>{this.controller.updateNode(d,{style:c})};const h=new A(e,{onNodeClick:d=>this.controller.selectNode(d||null),onAddChild:d=>this.controller.addChildNode(d),onInsertParent:d=>this.controller.insertParentNode(d),onAddSibling:(d,c)=>this.controller.addSiblingNode(d,c),onDeleteNode:d=>this.controller.removeNode(d),onDropNode:(d,c,g)=>this.controller.moveNode(d,c,g),onUpdateNode:(d,c)=>this.controller.updateNodeTopic(d,c),onNavigate:(d,c)=>this.controller.navigateNode(d,c),onPan:(d,c)=>this.controller.panBoard(d,c),onCopyNode:d=>this.controller.copyNode(d),onPasteNode:d=>this.controller.pasteNode(d),onCutNode:d=>this.controller.cutNode(d),onPasteImage:(d,c)=>this.controller.pasteImage(d,c),onZoom:(d,c,g)=>this.controller.zoomBoard(d,c,g),onZoomReset:()=>this.controller.resetZoom(),onUndo:()=>this.controller.undo(),onRedo:()=>this.controller.redo(),onStyleAction:(d,c)=>this.controller.onStyleAction(d,c),onEditEnd:d=>this.controller.onEditEnd(),onToggleFold:d=>this.controller.toggleFold(d),onToggleCommandPalette:()=>this.controller.toggleCommandPalette(),shortcuts:t.shortcuts});this.controller.setInteractionHandler(h);const f=new L(n,{onLayoutChange:d=>this.controller.setLayoutMode(d),onThemeChange:d=>this.controller.setTheme(d),onZoomReset:()=>this.controller.resetZoom(),onShowShortcuts:()=>this.controller.showShortcutModal()});this.controller.setLayoutSwitcher(f),t.maxNodeWidth!==void 0&&this.controller.setMaxNodeWidth(t.maxNodeWidth),t.customStyles&&this.controller.updateGlobalStyles(t.customStyles),this.controller.init(e.clientWidth)}addNode(e,t,i,o={emitChange:!0}){return this.controller.addNode(e,t,i,o)}addSibling(e,t="after",i="New topic",o={emitChange:!0}){return this.controller.addSibling(e,t,i,o)}insertParent(e,t="New topic",i={emitChange:!0}){return this.controller.insertParent(e,t,i)}deleteNode(e){this.controller.deleteNode(e)}updateNode(e,t){this.controller.updateNode(e,t)}undo(){this.controller.undo()}redo(){this.controller.redo()}toggleFold(e){this.controller.toggleFold(e)}toggleCommandPalette(){this.controller.toggleCommandPalette()}openCommandPalette(){this.controller.toggleCommandPalette()}searchNodes(e){return this.controller.searchNodes(e)}getSelectedNodeId(){return this.controller.selectedNodeId}updateNodeStyle(e,t){this.controller.updateNode(e,{style:t})}setTheme(e){this.controller.setTheme(e)}getMindMap(){return this.mindMap}getNode(e){return this.mindMap.findNode(e)||void 0}getRoot(){return this.mindMap.root}findNodes(e){const t=[],i=o=>{e(o)&&t.push(o),o.children.forEach(i)};return i(this.mindMap.root),t}setMaxNodeWidth(e){this.controller.setMaxNodeWidth(e)}getMaxNodeWidth(){return this.controller.getMaxNodeWidth()}updateGlobalStyles(e){this.controller.updateGlobalStyles(e)}setReadOnly(e){this.controller.setReadOnly(e)}destroy(){this.controller.destroy(),this.controller.interactionHandler?.destroy()}batch(e){this.controller.isBatching=!0;try{e()}finally{this.controller.isBatching=!1,this.controller.render()}}addChildNode(e){this.controller.addChildNode(e)}addSiblingNode(e,t="after"){this.controller.addSiblingNode(e,t)}insertParentNode(e){this.controller.insertParentNode(e)}removeNode(e){this.controller.removeNode(e)}moveNode(e,t,i){this.controller.moveNode(e,t,i)}updateNodeTopic(e,t){this.controller.updateNodeTopic(e,t)}selectNode(e){this.controller.selectNode(e)}panBoard(e,t){this.controller.panBoard(e,t)}zoomBoard(e,t,i){this.controller.zoomBoard(e,t,i)}resetZoom(){this.controller.resetZoom()}copyNode(e){this.controller.copyNode(e)}pasteNode(e){this.controller.pasteNode(e)}pasteImage(e,t){this.controller.pasteImage(e,t)}cutNode(e){this.controller.cutNode(e)}updateLayout(e){e==="Standard"?this.controller.setLayoutMode("Both"):this.controller.setLayoutMode(e)}setLayoutMode(e){this.controller.setLayoutMode(e)}getLayoutMode(){return this.controller.getLayoutMode()}navigateNode(e,t){this.controller.navigateNode(e,t)}getData(){return this.controller.getData()}loadData(e){this.controller.loadData(e)}getRootId(){return this.mindMap.root.id}}exports.Kakidash=O;
|