@macrostrat/feedback-components 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/esm/{feedback-components.7e879290.js → feedback-components.03f08dc7.js} +10 -9
  3. package/dist/esm/feedback-components.03f08dc7.js.map +1 -0
  4. package/dist/esm/{feedback-components.204f7d2b.js → feedback-components.06a79c6a.js} +46 -21
  5. package/dist/esm/feedback-components.06a79c6a.js.map +1 -0
  6. package/dist/esm/{feedback-components.1c15f37f.js → feedback-components.3f59f2a5.js} +14 -97
  7. package/dist/esm/feedback-components.3f59f2a5.js.map +1 -0
  8. package/dist/esm/{feedback-components.d55a1d18.js → feedback-components.4cbd249a.js} +5 -5
  9. package/dist/esm/{feedback-components.d55a1d18.js.map → feedback-components.4cbd249a.js.map} +1 -1
  10. package/dist/esm/{feedback-components.d591ffec.css → feedback-components.5a8f0185.css} +11 -5
  11. package/dist/esm/feedback-components.5a8f0185.css.map +1 -0
  12. package/dist/esm/{feedback-components.f6605b83.js → feedback-components.6cec1102.js} +79 -46
  13. package/dist/esm/feedback-components.6cec1102.js.map +1 -0
  14. package/dist/esm/{feedback-components.00434ff7.js → feedback-components.7c2fe400.js} +7 -1
  15. package/dist/esm/feedback-components.7c2fe400.js.map +1 -0
  16. package/dist/esm/{feedback-components.28ba71be.js → feedback-components.939a3a9f.js} +7 -7
  17. package/dist/esm/feedback-components.939a3a9f.js.map +1 -0
  18. package/dist/esm/{feedback-components.fd8ac9ca.js → feedback-components.e53837d9.js} +114 -96
  19. package/dist/esm/feedback-components.e53837d9.js.map +1 -0
  20. package/dist/esm/index.d.ts +2 -1
  21. package/dist/esm/index.d.ts.map +1 -1
  22. package/dist/esm/index.js +1 -1
  23. package/dist/node/{feedback-components.2f740fc7.js → feedback-components.3888aa2a.js} +2 -2
  24. package/dist/node/{feedback-components.2f740fc7.js.map → feedback-components.3888aa2a.js.map} +1 -1
  25. package/dist/node/feedback-components.388de4ac.js +2 -0
  26. package/dist/node/feedback-components.388de4ac.js.map +1 -0
  27. package/dist/node/feedback-components.827f8d80.js +2 -0
  28. package/dist/node/feedback-components.827f8d80.js.map +1 -0
  29. package/dist/node/feedback-components.9e1d4e4c.js +2 -0
  30. package/dist/node/feedback-components.9e1d4e4c.js.map +1 -0
  31. package/dist/node/feedback-components.b8da3bce.js +2 -0
  32. package/dist/node/feedback-components.b8da3bce.js.map +1 -0
  33. package/dist/node/feedback-components.c31cf831.js +2 -0
  34. package/dist/node/feedback-components.c31cf831.js.map +1 -0
  35. package/dist/node/feedback-components.db4d0a14.css +2 -0
  36. package/dist/node/feedback-components.db4d0a14.css.map +1 -0
  37. package/dist/node/feedback-components.f91331e9.js +2 -0
  38. package/dist/node/feedback-components.f91331e9.js.map +1 -0
  39. package/dist/node/feedback-components.fc0395df.js +2 -0
  40. package/dist/node/feedback-components.fc0395df.js.map +1 -0
  41. package/dist/node/index.js +1 -1
  42. package/dist/node/index.js.map +1 -1
  43. package/package.json +2 -2
  44. package/src/feedback/edit-state.ts +96 -49
  45. package/src/feedback/feedback.module.sass +9 -5
  46. package/src/feedback/graph.ts +5 -2
  47. package/src/feedback/index.ts +29 -4
  48. package/src/feedback/matches.ts +123 -85
  49. package/src/feedback/text-visualizer.ts +32 -86
  50. package/src/feedback/typelist.ts +13 -4
  51. package/dist/esm/feedback-components.00434ff7.js.map +0 -1
  52. package/dist/esm/feedback-components.1c15f37f.js.map +0 -1
  53. package/dist/esm/feedback-components.204f7d2b.js.map +0 -1
  54. package/dist/esm/feedback-components.28ba71be.js.map +0 -1
  55. package/dist/esm/feedback-components.7e879290.js.map +0 -1
  56. package/dist/esm/feedback-components.d591ffec.css.map +0 -1
  57. package/dist/esm/feedback-components.f6605b83.js.map +0 -1
  58. package/dist/esm/feedback-components.fd8ac9ca.js.map +0 -1
  59. package/dist/node/feedback-components.0eef8d0c.js +0 -2
  60. package/dist/node/feedback-components.0eef8d0c.js.map +0 -1
  61. package/dist/node/feedback-components.41db283a.js +0 -2
  62. package/dist/node/feedback-components.41db283a.js.map +0 -1
  63. package/dist/node/feedback-components.69d0ccd0.js +0 -2
  64. package/dist/node/feedback-components.69d0ccd0.js.map +0 -1
  65. package/dist/node/feedback-components.a7b43cfa.js +0 -2
  66. package/dist/node/feedback-components.a7b43cfa.js.map +0 -1
  67. package/dist/node/feedback-components.b9317f9c.js +0 -2
  68. package/dist/node/feedback-components.b9317f9c.js.map +0 -1
  69. package/dist/node/feedback-components.e096504e.css +0 -2
  70. package/dist/node/feedback-components.e096504e.css.map +0 -1
  71. package/dist/node/feedback-components.e140ac86.js +0 -2
  72. package/dist/node/feedback-components.e140ac86.js.map +0 -1
  73. package/dist/node/feedback-components.f8373b58.js +0 -2
  74. package/dist/node/feedback-components.f8373b58.js.map +0 -1
@@ -1 +0,0 @@
1
- {"mappings":";;;;;AAKO,IAAA,AAAK,mEAAA;;;WAAA;;AAmDL,SAAS,0CACd,WAAuB,EACvB,WAAoC;IAEpC,4BAA4B;IAC5B,qDAAqD;IACrD,MAAM,OAAO,YAAY,MAAM,GAAG,IAAI,GAAG,KAAK;IAE9C,OAAO,CAAA,GAAA,iBAAS,EAAE,mCAAa;qBAC7B;QACA,MAAM;QACN,eAAe,EAAE;QACjB,gBAAgB;QAChB,oBAAoB;QACpB,gBAAgB;QAChB,uBAAuB;QACvB,QAAQ;IACV;AACF;AAEO,MAAM,4CAAsB,CAAA,GAAA,oBAAY,EAAuB;AAE/D,SAAS;IACd,MAAM,WAAW,CAAA,GAAA,iBAAS,EAAE;IAC5B,IAAI,YAAY,MACd,MAAM,IAAI,MAAM;IAElB,OAAO;AACT;AAEA,SAAS,kCAAY,KAAgB,EAAE,MAAkB;IACvD,OAAQ,OAAO,IAAI;QACjB,KAAK;YAAmB;gBACtB,mCAAmC;gBACnC,MAAM,QAAE,IAAI,eAAE,WAAW,SAAE,KAAK,EAAE,GAAG,OAAO,OAAO;gBACnD,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AC,CAAC,GAAG,IAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;AAC1D","sources":["packages/feedback-components/src/feedback/edit-state.ts"],"sourcesContent":["import { TreeData } from \"./types\";\nimport { createContext, Dispatch, useContext, useReducer } from \"react\";\nimport update, { Spec } from \"immutability-helper\";\nimport { EntityType } from \"../extractions/types\";\n\nexport enum ViewMode {\n Tree = \"tree\",\n Graph = \"graph\",\n}\n\ninterface TreeState {\n initialTree: TreeData[];\n tree: TreeData[];\n selectedNodes: number[];\n entityTypesMap: Map<number, EntityType>;\n selectedEntityType: EntityType;\n lastInternalId: number;\n isSelectingEntityType: boolean;\n viewMode: ViewMode;\n}\n\ntype TextRange = {\n start: number;\n end: number;\n text: string;\n};\n\ntype TreeAction =\n | {\n type: \"move-node\";\n payload: { dragIds: number[]; parentId: number; index: number };\n }\n | { type: \"delete-node\"; payload: { ids: number[] } }\n | { type: \"select-node\"; payload: { ids: number[] } }\n | { type: \"toggle-node-selected\"; payload: { ids: number[] } }\n | { type: \"set-view-mode\"; payload: ViewMode }\n | { type: \"create-node\"; payload: TextRange }\n | { type: \"select-entity-type\"; payload: EntityType }\n | { type: \"toggle-entity-type-selector\"; payload?: boolean | null }\n | { type: \"deselect\" }\n | { type: \"reset\" }\n | { type: \"delete-entity-type\"; payload: { id: number } }\n | {\n type: \"add-entity-type\";\n payload: { name: string; description: string; color: string };\n }\n | {\n type: \"update-entity-type\";\n payload: { id: number; name: string; description: string; color: string };\n }\n | { type: \"select-range\"; payload: { ids: number[] } }\n | { type: \"add-match\"; payload: { id: number; payload: any } }\n | { type: \"remove-match\"; payload: { id: number } };\n\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>,\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n\n return useReducer(treeReducer, {\n initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: ViewMode.Tree,\n });\n}\n\nexport const TreeDispatchContext = createContext<TreeDispatch | null>(null);\n\nexport function useTreeDispatch() {\n const dispatch = useContext(TreeDispatchContext);\n if (dispatch == null) {\n throw new Error(\"No dispatch context available\");\n }\n return dispatch;\n}\n\nfunction treeReducer(state: TreeState, action: TreeAction) {\n switch (action.type) {\n case \"add-entity-type\": {\n // Add a new entity type to the map\n const { name, description, color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType: EntityType = {\n id: newId,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId,\n };\n }\n case \"update-entity-type\": {\n // Update an existing entity type in the map\n const { id, name, description, color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n\n const updatedType: EntityType = {\n ...oldType,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n newEntityTypesMap.set(id, updatedType);\n\n // Update the tree to reflect the new type\n const newTree = updateTreeTypes(state.tree, oldType, updatedType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType,\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n\n // make list of nodes in order\n const allNodes = flattenAndSort(state.tree);\n\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node) => node.id === node1);\n const endIndex = allNodes.findIndex((node) => node.id === node2);\n\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node) => node.id),\n };\n\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = removeNodes(\n state.tree,\n action.payload.dragIds,\n );\n\n let keyPath: (number | \"children\")[] = [];\n if (action.payload.parentId) {\n keyPath = findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n\n // Add removed nodes to the new tree at the correct location\n let updateSpec = buildNestedSpec(keyPath, {\n $splice: [[action.payload.index, 0, ...removedNodes]],\n });\n\n return { ...state, tree: update(newTree, updateSpec) };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = removeNodes(\n state.tree,\n action.payload.ids,\n );\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n\n const children = _removedNodes\n .flatMap((node) => node.children ?? [])\n .filter((child) => !nodeIsInTree(newTree2, child.id));\n\n // Reset the selection\n\n return {\n ...state,\n tree: [...newTree2, ...children],\n selectedNodes: state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n ),\n };\n case \"select-node\":\n const { ids } = action.payload;\n\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter(\n (id) => !state.selectedNodes.includes(id),\n );\n const nodesToKeep = state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n );\n\n const newType =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, action.payload.ids[0])?.type\n : null;\n\n return {\n ...state,\n selectedNodes: [...nodesToKeep, ...nodesToAdd],\n selectedEntityType: newType,\n };\n\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text, start, end } = action.payload;\n const node: TreeData = {\n id: newId,\n name: text,\n children: [],\n indices: [start, end],\n type: state.selectedEntityType,\n };\n\n return {\n ...state,\n tree: [...state.tree, node],\n selectedNodes: [newId],\n lastInternalId: newId,\n };\n\n case \"delete-entity-type\": {\n // Remove the entity type from the map\n const { id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = updateTreeTypes(state.tree, oldType, defaultType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: [],\n };\n }\n\n case \"add-match\": {\n const { id } = action.payload;\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to set the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: action.payload.payload },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n case \"remove-match\": {\n const { id } = action.payload;\n\n console.log(\"Removing match for node with id:\", id);\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to unset the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: null },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n /** Entity type selection */\n case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType,\n };\n case \"select-entity-type\": {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes) {\n const keyPath = findNode(state.tree, id);\n const nestedSpec = buildNestedSpec(keyPath, {\n type: { $set: action.payload },\n });\n newTree2 = update(newTree2, nestedSpec);\n }\n\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload,\n };\n }\n case \"deselect\":\n return { ...state, selectedNodes: [] };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: [],\n };\n case \"set-view-mode\":\n return { ...state, viewMode: action.payload };\n }\n}\n\nfunction nodeIsInTree(tree: TreeData[], id: number): boolean {\n for (let node of tree) {\n if (node.id == id) {\n return true;\n } else if (node.children) {\n if (nodeIsInTree(node.children, id)) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction buildNestedSpec(\n keyPath: (number | \"children\")[],\n innerSpec: Spec<any>,\n): Spec<TreeData[]> {\n // Build a nested object from a key path\n\n let spec = innerSpec;\n for (let i = keyPath.length - 1; i >= 0; i--) {\n spec = { [keyPath[i]]: spec };\n }\n return spec as any;\n // Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\n\nfunction findNode(\n tree: TreeData[],\n id: number,\n): (number | \"children\")[] | null {\n // Find the index of the node with the given id in the tree, returning the key path\n for (let i = 0; i < tree.length; i++) {\n if (tree[i].id == id) {\n return [i];\n } else if (tree[i].children) {\n let path = findNode(tree[i].children, id);\n if (path != null) {\n return [i, \"children\", ...path];\n }\n }\n }\n return null;\n}\n\nfunction removeNodes(\n tree: TreeData[],\n ids: number[],\n): [TreeData[], TreeData[]] {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */\n let newTree: TreeData[] = [];\n let removedNodes: TreeData[] = [];\n\n for (let node of tree) {\n if (ids.includes(node.id)) {\n removedNodes.push(node);\n } else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = removeNodes(node.children, ids);\n node = { ...node, children: newChildren };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n }\n\n return [newTree, removedNodes];\n}\n\nexport interface EntityOutput {\n id: number;\n type: number | null;\n txt_range: number[][];\n name: string;\n match: any | null;\n reasoning: string | null;\n color: string | null;\n children: any[] | null;\n}\n\nexport interface GraphData {\n nodes: EntityOutput[];\n edges: { source: number; dest: number }[];\n}\n\nexport function treeToGraph(tree: TreeData[]): GraphData {\n // Convert the tree to a graph\n let nodes: EntityOutput[] = [];\n let edges: { source: number; dest: number }[] = [];\n const nodeMap = new Map<number, TreeData>();\n\n for (let node of tree) {\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) {\n continue;\n }\n\n const { indices, id, name, type, children } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: type.id,\n color: type.color,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\n children,\n };\n\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n\n if (node.children) {\n for (let child of node.children) {\n edges.push({ source: node.id, dest: child.id });\n }\n\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = treeToGraph(\n node.children,\n );\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n\n return { nodes, edges };\n}\n\nexport function findNodeById(tree, id) {\n for (const node of tree) {\n if (node.id === id) {\n return node;\n }\n if (node.children) {\n const found = findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\n\nfunction updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node) => updateNodeType(node, oldType, defaultType));\n}\n\nfunction updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n\n return {\n ...node,\n type,\n children: node.children\n ? updateTreeTypes(node.children, oldType, defaultType)\n : [],\n };\n}\n\nfunction flattenAndSort(nodes) {\n const result = [];\n\n function traverse(nodeList) {\n for (const node of nodeList) {\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) {\n traverse(node.children);\n }\n }\n }\n\n traverse(nodes);\n\n // sort by start\n return result.sort((a, b) => a.indices[0] - b.indices[0]);\n}\n"],"names":[],"version":3,"file":"feedback-components.f6605b83.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;AAWA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,8EAAK;AAErB,SAAS,yCAAQ,SACtB,KAAK,iBACL,aAAa,cACb,UAAU,iBACV,aAAa,QACb,IAAI,YACJ,QAAQ,EACT;IACC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AAU,cAAc;gBACxC,cAAc;oBAAE,SAAS;gBAAK;gBAC9B,OAAO;gBACP,aAAa;YACf,GACA;SAEH;QACD,wBACE,CAAA,GAAA,iBAAS,GACT;YACE,WAAW;YACX,OAAO;YACP,SAAS;gBACP,sBAAsB;gBACtB,SAAS;oBACP,MAAM;oBACN,SAAS;wBAAE,IAAI,UAAU,EAAE;iCAAE;oBAAQ;gBACvC;gBACA,eAAe;YACjB;sBACA;QACF,GACA;KAEH;AAGP","sources":["packages/feedback-components/src/feedback/matches.ts"],"sourcesContent":["import { Switch } from \"@blueprintjs/core\";\nimport { Match } from \"./text-visualizer\";\nimport { Select } from \"@blueprintjs/select\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { useState } from \"react\";\nimport { Icon, Divider, Overlay2 } from \"@blueprintjs/core\";\nimport { JSONView, SaveButton } from \"@macrostrat/ui-components\";\nimport { useAPIResult, DataField } from \"@macrostrat/ui-components\";\nimport { LithologyTag } from \"@macrostrat/data-components\";\n\nconst h = hyper.styled(styles);\n\nexport function Matches({\n match,\n setMatchLinks,\n matchLinks,\n selectedNodes,\n tree,\n dispatch,\n}) {\n const [overlayOpen, setOverlayOpen] = useState(false);\n\n let nodeMatch = null;\n if (selectedNodes.length === 1) {\n nodeMatch = findMatchingNode(tree, selectedNodes[0]);\n }\n\n return h.if(matchLinks)(\"div\", [\n h(Divider),\n h(Switch, {\n label: \"Show matches\",\n checked: match !== null,\n onChange: (e) => {\n setMatchLinks(match === null ? matchLinks || {} : null);\n },\n }),\n h.if(nodeMatch && match)(Match, {\n data: nodeMatch?.match,\n matchLinks: matchLinks,\n dispatch,\n nodeId: nodeMatch?.id,\n }),\n h.if(selectedNodes.length == 1 && !nodeMatch?.match && match)(\n \"div.add-match-container\",\n [\n h(\n \"div.add-type\",\n {\n onClick: () => {\n setOverlayOpen(true);\n },\n },\n [h(\"p.add-match-text\", \"Add match\"), h(Icon, { icon: \"plus\" })],\n ),\n h(MatchOverlay, {\n isOpen: overlayOpen,\n setOverlayOpen,\n nodeMatch,\n dispatch,\n }),\n ],\n ),\n ]);\n}\n\nfunction findMatchingNode(tree, nodeId) {\n let match = null;\n\n function traverse(node) {\n if (node.id === nodeId) {\n match = node;\n return true;\n }\n if (Array.isArray(node.children)) {\n for (const child of node.children) {\n if (traverse(child)) return true;\n }\n }\n return false;\n }\n\n tree.forEach(traverse);\n return match;\n}\n\nfunction MatchOverlay({ isOpen, setOverlayOpen, nodeMatch, dispatch }) {\n const [inputValue, setInputValue] = useState(nodeMatch?.name || \"\");\n const [selectedItem, setSelectedItem] = useState(h(\"div\", \"Select a match\"));\n const [disabled, setDisabled] = useState(true);\n const [payload, setPayload] = useState({});\n\n const data = useAPIResult(\n \"https://dev.macrostrat.org/api/pg/type_lookup?name=ilike.*\" +\n inputValue +\n \"*\",\n );\n const items = data?.map((data) => {\n const type = data.type || \"\";\n\n if (type === \"lith\") {\n return h(\n \"div\",\n {\n onClick: () => {\n setPayload({ lith_id: data.id, name: data.name });\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Lithology\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_id, color: data.color },\n }),\n }),\n );\n }\n\n if (type === \"strat_name\") {\n return h(\n \"div\",\n {\n onClick: () => {\n setPayload({ strat_name_id: data.id, name: data.name });\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Stratigraphic name\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.id, color: data.color },\n }),\n }),\n );\n }\n\n if (type === \"lith_att\") {\n return h(\n \"div\",\n {\n onClick: () => {\n setPayload({ lith_att_id: data.lith_att_id, name: data.name });\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Lithology attribute\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_att_id },\n }),\n onClick: () => {\n setPayload({ lith_att_id: data.lith_att_id, name: data.name });\n },\n }),\n );\n }\n\n if (type === \"interval\") {\n h(\n \"div\",\n {\n onClick: () => {\n setPayload({ int_id: data.id, name: data.name });\n },\n },\n h(DataField, {\n label: \"Interval\",\n className: \"match-item\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.id },\n }),\n onClick: () => {\n setPayload({ int_id: data.id, name: data.name });\n },\n }),\n );\n }\n\n return h(JSONView, { data });\n });\n\n return h(\n Overlay2,\n {\n isOpen,\n },\n h(\n \"div.overlay-container\",\n h(\"div.add-type-overlay\", [\n h(\"h2.title\", [\n \"Add match with \" + nodeMatch.name,\n h(Icon, {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: () => {\n setOverlayOpen(false);\n },\n style: { cursor: \"pointer\", color: \"red\" },\n }),\n ]),\n h(\"div.form-group\", [\n h(\n Select,\n {\n items: items || [],\n itemRenderer: (item, { handleClick }) => {\n return h(\"div.match-item\", { onClick: handleClick }, item);\n },\n onItemSelect: (item) => {\n setDisabled(false);\n setSelectedItem(item);\n },\n onQueryChange: (query) => setInputValue(query),\n popoverProps: { minimal: true },\n query: inputValue,\n placeholder: \"Enter match name\",\n },\n selectedItem,\n ),\n ]),\n h(\n SaveButton,\n {\n className: \"save-btn\",\n small: true,\n onClick: () => {\n // Handle save changes\n dispatch({\n type: \"add-match\",\n payload: { id: nodeMatch.id, payload },\n });\n setOverlayOpen(false);\n },\n disabled,\n },\n \"Save changes\",\n ),\n ]),\n ),\n );\n}\n"],"names":[],"version":3,"file":"feedback-components.fd8ac9ca.js.map"}
@@ -1,2 +0,0 @@
1
- import"./feedback-components.b9317f9c.js";import"./feedback-components.2f740fc7.js";import"./feedback-components.69d0ccd0.js";import"./feedback-components.b22d37d1.js";import"./feedback-components.a7b43cfa.js";import"./feedback-components.acac789b.js";import"./feedback-components.41db283a.js";import"./feedback-components.f8373b58.js";import"./feedback-components.e140ac86.js";import e from"@macrostrat/hyper";import{Tree as t}from"react-arborist";import{useState as n,useRef as r,useCallback as o,useEffect as a}from"react";import{SegmentedControl as i,Card as s,ButtonGroup as d,Divider as c}from"@blueprintjs/core";import{ErrorBoundary as l,FlexRow as p,CancelButton as m,SaveButton as u}from"@macrostrat/ui-components";import f from"use-element-dimensions";function h(e,t,n,r){Object.defineProperty(e,t,{get:n,set:r,enumerable:!0,configurable:!0})}var y=globalThis,b={},v={},g=y.parcelRequirea149;null==g&&((g=function(e){if(e in b)return b[e].exports;if(e in v){var t=v[e];delete v[e];var n={id:e,exports:{}};return b[e]=n,t.call(n.exports,n,n.exports),n.exports}var r=Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}).register=function(e,t){v[e]=t},y.parcelRequirea149=g),g.register;var w={};h(w,"FeedbackComponent",()=>j),h(w,"treeToGraph",()=>g("eedTh").treeToGraph);var k=g("9wFEx"),S=g("bQY4Q"),_=g("3OP12"),C=g("edvRb"),T=g("eedTh"),x=g("iKZjQ"),E=g("bK9Of"),H=g("jlqgz"),R=g("aWecs");let F=e.styled(k&&k.__esModule?k.default:k);function j({entities:e=[],text:t,model:r,entityTypes:o,matchComponent:a,onSave:h,allowOverlap:y,matchLinks:b}){let[v,g]=(0,T.useUpdatableTree)(e.map(O),o),[w,k]=n(b||{}),{selectedNodes:S,tree:x,selectedEntityType:R,isSelectingEntityType:j,entityTypesMap:A}=v,[{width:L,height:M},D]=f();return F("div.page-wrapper",[F("div.feedback-container",F(T.TreeDispatchContext.Provider,{value:g},[F(l,{description:"An error occurred while rendering the feedback text component."},F(_.FeedbackText,{text:t,dispatch:g,nodes:x,selectedNodes:S,allowOverlap:y,matchLinks:w})),F(p,{alignItems:"baseline",justifyContent:"space-between"},[F(C.ModelInfo,{data:r}),F(i,{options:[{label:"Tree",value:"tree"},{label:"Graph",value:"graph"}],value:v.viewMode,small:!0,onValueChange(e){console.log("Setting view mode",e),g({type:"set-view-mode",payload:e})}})]),F("div.entity-panel",{ref:D},[F.if("tree"==v.viewMode)(N,{selectedNodes:S,dispatch:g,tree:x,width:L,height:M,matchComponent:a}),F.if("graph"==v.viewMode)(E.GraphView,{tree:x,width:L,height:M,dispatch:g,selectedNodes:S})])])),F(s,{className:"control-panel"},[F("div.control-content",[F(d,{vertical:!0,fill:!0,minimal:!0,alignText:"left"},[F(m,{icon:"trash",disabled:v.initialTree==v.tree,onClick(){g({type:"reset"})}},"Reset"),F(u,{onClick(){h(v.tree)},disabled:v.initialTree==v.tree},"Save")]),F(H.Matches,{match:w,setMatchLinks:k,matchLinks:b,selectedNodes:S,tree:x,dispatch:g}),F(c),F(I,{entityTypes:A,selected:R,onChange(e){g({type:"select-entity-type",payload:e})},dispatch:g,tree:x,selectedNodes:S,isOpen:j,setOpen:e=>g({type:"toggle-entity-type-selector",payload:e})})])])])}function O(e){return{...e,term_type:e.type.name,txt_range:[e.indices],children:e.children?.map(O)??[]}}function I({entityTypes:e,selected:t,isOpen:r,setOpen:o,onChange:a,tree:i,dispatch:s,selectedNodes:d=[]}){let c=null!=t?t:void 0,[l,p]=n(""),m=Array.from(e.values()),u=""!==l?m.filter(e=>e.name.toLowerCase().includes(l.toLowerCase())):m;return F("div.entity-type-selector",[F(R.TypeList,{types:e,selected:c,dispatch:s,selectedNodes:d,tree:i}),F(x.OmniboxSelector,{isOpen:r,items:u,selectedItem:c,onSelectItem(e){o(!1),a(e)},onQueryChange(e){p(e)},onClose(){o(!1)}})])}function N(e){let{selectedNodes:n,dispatch:i,tree:s,height:d,width:c,matchComponent:l}=e,p=r(),m=r(!1),u=o(e=>F(S.default,{...e,matchComponent:l}),[l]);a(()=>{if(null!=p.current)!function(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}(new Set(n.map(e=>e.toString())),p.current.selectedIds)&&p.current.setSelection({ids:n.map(e=>e.toString()),anchor:null,mostRecent:null})},[n]);let f=r(!1);return a(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(f.current=!0)},t=()=>f.current=!1;return window.addEventListener("keydown",e),window.addEventListener("keyup",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t)}},[]),F("div.selection-tree-wrapper",{onPointerDown:function(){m.current=!0}},F(t,{className:"selection-tree",height:d,width:c,ref:p,data:s,onMove({dragIds:e,parentId:t,index:n}){i({type:"move-node",payload:{dragIds:e.map(e=>parseInt(e)),parentId:t?parseInt(t):null,index:n}})},onDelete({ids:e}){i({type:"delete-node",payload:{ids:e.map(e=>parseInt(e))}})},onSelect:o(e=>{if(!m.current)return;m.current=!1;let t=f.current,r=e.map(e=>parseInt(e.id));t?i({type:"toggle-node-selected",payload:{ids:r}}):(1===r.length&&r[0]===n[0]&&(r=[]),i({type:"select-node",payload:{ids:r}}))},[n,i]),children:u,idAccessor:e=>e.id.toString()}))}export{j as FeedbackComponent,$330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};
2
- //# sourceMappingURL=feedback-components.0eef8d0c.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,Q,C,K,gB,A,Q,Y,C,C,U,C,C,e,C,C,a,C,K,O,A,Q,oB,C,C,Q,C,C,e,C,C,W,C,K,mB,A,Q,iB,C,C,W,C,C,gB,C,C,c,C,K,2B,A,Q,M,wB,C,S,E,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,C,E,E,E,oB,I,G,E,E,c,I,A,E,S,W,E,I,E,E,S,E,E,S,E,E,S,E,E,S,E,E,S,E,E,S,E,E,S,E,E,S,E,E,SCuCA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,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AAO,CAAG,CAAA,EACrB,IAAM,EAAgB,EAAe,OAAO,CAExC,EAAM,EAAM,GAAG,CAAC,AAAC,GAAM,SAAS,EAAE,EAAE,GAEpC,EACF,EAAS,CAAE,KAAM,uBAAwB,QAAS,CAAE,IAAA,CAAI,CAAE,IAEtD,AAAe,IAAf,EAAI,MAAM,EAAU,CAAG,CAAC,EAAE,GAAK,CAAa,CAAC,EAAE,EACjD,CAAA,EAAM,EAAE,AAAF,EAGR,EAAS,CAAE,KAAM,cAAe,QAAS,CAAE,IAAA,CAAI,CAAE,GAErD,EACA,CAAC,EAAe,EAAS,EA6BvB,SAAU,EACV,WAAA,AAAW,GACF,EAAE,EAAE,CAAC,QAAQ,EAExB,GAEJ,Q,K,iB,C,6C,W","sources":["<anon>","packages/feedback-components/src/feedback/index.ts"],"sourcesContent":["import \"./feedback-components.b9317f9c.js\";\nimport \"./feedback-components.2f740fc7.js\";\nimport \"./feedback-components.69d0ccd0.js\";\nimport \"./feedback-components.b22d37d1.js\";\nimport \"./feedback-components.a7b43cfa.js\";\nimport \"./feedback-components.acac789b.js\";\nimport \"./feedback-components.41db283a.js\";\nimport \"./feedback-components.f8373b58.js\";\nimport \"./feedback-components.e140ac86.js\";\nimport $ajJMX$macrostrathyper from \"@macrostrat/hyper\";\nimport {Tree as $ajJMX$Tree} from \"react-arborist\";\nimport {useState as $ajJMX$useState, useRef as $ajJMX$useRef, useCallback as $ajJMX$useCallback, useEffect as $ajJMX$useEffect} from \"react\";\nimport {SegmentedControl as $ajJMX$SegmentedControl, Card as $ajJMX$Card, ButtonGroup as $ajJMX$ButtonGroup, Divider as $ajJMX$Divider} from \"@blueprintjs/core\";\nimport {ErrorBoundary as $ajJMX$ErrorBoundary, FlexRow as $ajJMX$FlexRow, CancelButton as $ajJMX$CancelButton, SaveButton as $ajJMX$SaveButton} from \"@macrostrat/ui-components\";\nimport $ajJMX$useelementdimensions from \"use-element-dimensions\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nvar $2c86488f2f3c1edd$exports = {};\n\n$parcel$export($2c86488f2f3c1edd$exports, \"FeedbackComponent\", () => $2c86488f2f3c1edd$export$a90600c9da52b40c);\n$parcel$export($2c86488f2f3c1edd$exports, \"treeToGraph\", () => (parcelRequire(\"eedTh\")).treeToGraph);\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\nvar $bQY4Q = parcelRequire(\"bQY4Q\");\n\nvar $3OP12 = parcelRequire(\"3OP12\");\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\n\n\nvar $iKZjQ = parcelRequire(\"iKZjQ\");\n\n\n\nvar $bK9Of = parcelRequire(\"bK9Of\");\n\nvar $jlqgz = parcelRequire(\"jlqgz\");\n\nvar $aWecs = parcelRequire(\"aWecs\");\nconst $2c86488f2f3c1edd$var$h = (0, $ajJMX$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $2c86488f2f3c1edd$var$setsAreTheSame(a, b) {\n if (a.size !== b.size) return false;\n for (const item of a){\n if (!b.has(item)) return false;\n }\n return true;\n}\nfunction $2c86488f2f3c1edd$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave, allowOverlap: allowOverlap, matchLinks: matchLinks }) {\n // Get the input arguments\n const [state, dispatch] = (0, $eedTh.useUpdatableTree)(entities.map($2c86488f2f3c1edd$var$processEntity), entityTypes);\n const [match, setMatchLinks] = (0, $ajJMX$useState)(matchLinks || {});\n const { selectedNodes: selectedNodes, tree: tree, selectedEntityType: selectedEntityType, isSelectingEntityType: isSelectingEntityType, entityTypesMap: entityTypesMap } = state;\n const [{ width: width, height: height }, ref] = (0, $ajJMX$useelementdimensions)();\n return $2c86488f2f3c1edd$var$h(\"div.page-wrapper\", [\n $2c86488f2f3c1edd$var$h(\"div.feedback-container\", $2c86488f2f3c1edd$var$h((0, $eedTh.TreeDispatchContext).Provider, {\n value: dispatch\n }, [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$ErrorBoundary), {\n description: \"An error occurred while rendering the feedback text component.\"\n }, $2c86488f2f3c1edd$var$h((0, $3OP12.FeedbackText), {\n text: text,\n dispatch: dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes: selectedNodes,\n allowOverlap: allowOverlap,\n matchLinks: match\n })),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$FlexRow), {\n alignItems: \"baseline\",\n justifyContent: \"space-between\"\n }, [\n $2c86488f2f3c1edd$var$h((0, $edvRb.ModelInfo), {\n data: model\n }),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$SegmentedControl), {\n options: [\n {\n label: \"Tree\",\n value: \"tree\"\n },\n {\n label: \"Graph\",\n value: \"graph\"\n }\n ],\n value: state.viewMode,\n small: true,\n onValueChange (value) {\n console.log(\"Setting view mode\", value);\n dispatch({\n type: \"set-view-mode\",\n payload: value\n });\n }\n })\n ]),\n $2c86488f2f3c1edd$var$h(\"div.entity-panel\", {\n ref: ref\n }, [\n $2c86488f2f3c1edd$var$h.if(state.viewMode == \"tree\")($2c86488f2f3c1edd$var$ManagedSelectionTree, {\n selectedNodes: selectedNodes,\n dispatch: dispatch,\n tree: tree,\n width: width,\n height: height,\n matchComponent: matchComponent\n }),\n $2c86488f2f3c1edd$var$h.if(state.viewMode == \"graph\")((0, $bK9Of.GraphView), {\n tree: tree,\n width: width,\n height: height,\n dispatch: dispatch,\n selectedNodes: selectedNodes\n })\n ])\n ])),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Card), {\n className: \"control-panel\"\n }, [\n $2c86488f2f3c1edd$var$h(\"div.control-content\", [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$ButtonGroup), {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\"\n }, [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$CancelButton), {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick () {\n dispatch({\n type: \"reset\"\n });\n }\n }, \"Reset\"),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$SaveButton), {\n onClick () {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree\n }, \"Save\")\n ]),\n $2c86488f2f3c1edd$var$h((0, $jlqgz.Matches), {\n match: match,\n setMatchLinks: setMatchLinks,\n matchLinks: matchLinks,\n selectedNodes: selectedNodes,\n tree: tree,\n dispatch: dispatch\n }),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Divider)),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$EntityTypeSelector, {\n entityTypes: entityTypesMap,\n selected: selectedEntityType,\n onChange (payload) {\n dispatch({\n type: \"select-entity-type\",\n payload: payload\n });\n },\n dispatch: dispatch,\n tree: tree,\n selectedNodes: selectedNodes,\n isOpen: isSelectingEntityType,\n setOpen: (isOpen)=>dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen\n })\n })\n ])\n ])\n ]);\n}\nfunction $2c86488f2f3c1edd$var$processEntity(entity) {\n // @ts-ignore\n return {\n ...entity,\n // @ts-ignore\n term_type: entity.type.name,\n txt_range: [\n entity.indices\n ],\n children: entity.children?.map($2c86488f2f3c1edd$var$processEntity) ?? []\n };\n}\nfunction $2c86488f2f3c1edd$var$EntityTypeSelector({ entityTypes: entityTypes, selected: selected, isOpen: isOpen, setOpen: setOpen, onChange: onChange, tree: tree, dispatch: dispatch, selectedNodes: selectedNodes = [] }) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n const [inputValue, setInputValue] = (0, $ajJMX$useState)(\"\");\n const types = Array.from(entityTypes.values());\n const items = inputValue !== \"\" ? types.filter((d)=>d.name.toLowerCase().includes(inputValue.toLowerCase())) : types;\n return $2c86488f2f3c1edd$var$h(\"div.entity-type-selector\", [\n $2c86488f2f3c1edd$var$h((0, $aWecs.TypeList), {\n types: entityTypes,\n selected: _selected,\n dispatch: dispatch,\n selectedNodes: selectedNodes,\n tree: tree\n }),\n $2c86488f2f3c1edd$var$h((0, $iKZjQ.OmniboxSelector), {\n isOpen: isOpen,\n items: items,\n selectedItem: _selected,\n onSelectItem (item) {\n setOpen(false);\n onChange(item);\n },\n onQueryChange (query) {\n setInputValue(query);\n },\n onClose () {\n setOpen(false);\n }\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$countNodes(tree) {\n if (!tree) return 0;\n let count = 0;\n function recurse(nodes) {\n for (const node of nodes){\n count++;\n if (node.children && Array.isArray(node.children)) recurse(node.children);\n }\n }\n recurse(tree);\n return count;\n}\nfunction $2c86488f2f3c1edd$var$ManagedSelectionTree(props) {\n const { selectedNodes: selectedNodes, dispatch: dispatch, tree: tree, height: height, width: width, matchComponent: matchComponent } = props;\n const ref = (0, $ajJMX$useRef)();\n // Use a ref to track clicks (won't cause rerender)\n const clickedRef = (0, $ajJMX$useRef)(false);\n const _Node = (0, $ajJMX$useCallback)((props)=>$2c86488f2f3c1edd$var$h((0, $bQY4Q.default), {\n ...props,\n matchComponent: matchComponent\n }), [\n matchComponent\n ]);\n // Update Tree selection when selectedNodes change\n (0, $ajJMX$useEffect)(()=>{\n if (ref.current == null) return;\n const selection = new Set(selectedNodes.map((d)=>d.toString()));\n const currentSelection = ref.current.selectedIds;\n if ($2c86488f2f3c1edd$var$setsAreTheSame(selection, currentSelection)) return;\n ref.current.setSelection({\n ids: selectedNodes.map((d)=>d.toString()),\n anchor: null,\n mostRecent: null\n });\n }, [\n selectedNodes\n ]);\n // Mark clicked when user clicks inside the tree container\n function handleClick() {\n clickedRef.current = true;\n }\n const ctrlPressedRef = (0, $ajJMX$useRef)(false);\n (0, $ajJMX$useEffect)(()=>{\n const down = (e)=>{\n if (e.ctrlKey || e.metaKey) ctrlPressedRef.current = true;\n };\n const up = ()=>ctrlPressedRef.current = false;\n window.addEventListener(\"keydown\", down);\n window.addEventListener(\"keyup\", up);\n return ()=>{\n window.removeEventListener(\"keydown\", down);\n window.removeEventListener(\"keyup\", up);\n };\n }, []);\n const handleSelect = (0, $ajJMX$useCallback)((nodes)=>{\n if (!clickedRef.current) return;\n clickedRef.current = false;\n const isMultiSelect = ctrlPressedRef.current;\n let ids = nodes.map((d)=>parseInt(d.id));\n if (isMultiSelect) dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n else {\n if (ids.length === 1 && ids[0] === selectedNodes[0]) ids = [];\n dispatch({\n type: \"select-node\",\n payload: {\n ids: ids\n }\n });\n }\n }, [\n selectedNodes,\n dispatch\n ]);\n return $2c86488f2f3c1edd$var$h(\"div.selection-tree-wrapper\", {\n onPointerDown: handleClick\n }, $2c86488f2f3c1edd$var$h((0, $ajJMX$Tree), {\n className: \"selection-tree\",\n height: height,\n width: width,\n ref: ref,\n data: tree,\n onMove ({ dragIds: dragIds, parentId: parentId, index: index }) {\n dispatch({\n type: \"move-node\",\n payload: {\n dragIds: dragIds.map((d)=>parseInt(d)),\n parentId: parentId ? parseInt(parentId) : null,\n index: index\n }\n });\n },\n onDelete ({ ids: ids }) {\n dispatch({\n type: \"delete-node\",\n payload: {\n ids: ids.map((d)=>parseInt(d))\n }\n });\n },\n onSelect: handleSelect,\n children: _Node,\n idAccessor (d) {\n return d.id.toString();\n }\n }));\n}\n\n\nexport {$2c86488f2f3c1edd$export$a90600c9da52b40c as FeedbackComponent, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=feedback-components.0eef8d0c.js.map\n","import styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport { Tree, TreeApi } from \"react-arborist\";\nimport Node from \"./node\";\nimport { FeedbackText } from \"./text-visualizer\";\nimport type { InternalEntity, TreeData } from \"./types\";\nimport type { Entity } from \"../extractions\";\nimport { getTagStyle, ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n ButtonGroup,\n Card,\n SegmentedControl,\n Divider,\n} from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n ErrorBoundary,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\n\nimport { Matches } from \"./matches\";\nimport { TypeList } from \"./typelist\";\n\nexport type { GraphData } from \"./edit-state\";\nexport { treeToGraph } from \"./edit-state\";\nexport type { TreeData } from \"./types\";\n\nconst h = hyper.styled(styles);\n\nfunction setsAreTheSame<T>(a: Set<T>, b: Set<T>) {\n if (a.size !== b.size) return false;\n for (const item of a) {\n if (!b.has(item)) return false;\n }\n return true;\n}\n\nexport function FeedbackComponent({\n entities = [],\n text,\n model,\n entityTypes,\n matchComponent,\n onSave,\n allowOverlap,\n matchLinks,\n}) {\n // Get the input arguments\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes,\n );\n const [match, setMatchLinks] = useState(matchLinks || {});\n\n const {\n selectedNodes,\n tree,\n selectedEntityType,\n isSelectingEntityType,\n entityTypesMap,\n } = state;\n\n const [{ width, height }, ref] = useElementDimensions();\n\n return h(\"div.page-wrapper\", [\n h(\n \"div.feedback-container\",\n h(TreeDispatchContext.Provider, { value: dispatch }, [\n h(\n ErrorBoundary,\n {\n description:\n \"An error occurred while rendering the feedback text component.\",\n },\n h(FeedbackText, {\n text,\n dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes,\n allowOverlap,\n matchLinks: match,\n }),\n ),\n h(\n FlexRow,\n { alignItems: \"baseline\", justifyContent: \"space-between\" },\n [\n h(ModelInfo, { data: model }),\n h(SegmentedControl, {\n options: [\n { label: \"Tree\", value: \"tree\" },\n { label: \"Graph\", value: \"graph\" },\n ],\n value: state.viewMode,\n small: true,\n onValueChange(value: ViewMode) {\n console.log(\"Setting view mode\", value);\n dispatch({ type: \"set-view-mode\", payload: value });\n },\n }),\n ],\n ),\n h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h.if(state.viewMode == \"tree\")(ManagedSelectionTree, {\n selectedNodes,\n dispatch,\n tree,\n width,\n height,\n matchComponent,\n }),\n h.if(state.viewMode == \"graph\")(GraphView, {\n tree,\n width,\n height,\n dispatch,\n selectedNodes,\n }),\n ],\n ),\n ]),\n ),\n h(Card, { className: \"control-panel\" }, [\n h(\"div.control-content\", [\n h(\n ButtonGroup,\n {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\",\n },\n [\n h(\n CancelButton,\n {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick() {\n dispatch({ type: \"reset\" });\n },\n },\n \"Reset\",\n ),\n h(\n SaveButton,\n {\n onClick() {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree,\n },\n \"Save\",\n ),\n ],\n ),\n h(Matches, {\n match,\n setMatchLinks,\n matchLinks,\n selectedNodes,\n tree,\n dispatch,\n }),\n h(Divider),\n h(EntityTypeSelector, {\n entityTypes: entityTypesMap,\n selected: selectedEntityType,\n onChange(payload) {\n dispatch({ type: \"select-entity-type\", payload });\n },\n dispatch,\n tree,\n selectedNodes,\n isOpen: isSelectingEntityType,\n setOpen: (isOpen: boolean) =>\n dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen,\n }),\n }),\n ]),\n ]),\n ]);\n}\n\nfunction processEntity(entity: Entity): InternalEntity {\n // @ts-ignore\n return {\n ...entity,\n // @ts-ignore\n term_type: entity.type.name,\n txt_range: [entity.indices],\n children: entity.children?.map(processEntity) ?? [],\n };\n}\n\nfunction EntityTypeSelector({\n entityTypes,\n selected,\n isOpen,\n setOpen,\n onChange,\n tree,\n dispatch,\n selectedNodes = [],\n}) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n const [inputValue, setInputValue] = useState(\"\");\n const types = Array.from(entityTypes.values());\n\n const items =\n inputValue !== \"\"\n ? types.filter((d) =>\n d.name.toLowerCase().includes(inputValue.toLowerCase()),\n )\n : types;\n\n return h(\"div.entity-type-selector\", [\n h(TypeList, {\n types: entityTypes,\n selected: _selected,\n dispatch,\n selectedNodes,\n tree,\n }),\n h(OmniboxSelector, {\n isOpen,\n items,\n selectedItem: _selected,\n onSelectItem(item) {\n setOpen(false);\n onChange(item);\n },\n onQueryChange(query) {\n setInputValue(query);\n },\n onClose() {\n setOpen(false);\n },\n }),\n ]);\n}\n\nfunction countNodes(tree) {\n if (!tree) return 0;\n let count = 0;\n\n function recurse(nodes) {\n for (const node of nodes) {\n count++;\n if (node.children && Array.isArray(node.children)) {\n recurse(node.children);\n }\n }\n }\n\n recurse(tree);\n return count;\n}\n\nfunction ManagedSelectionTree(props) {\n const { selectedNodes, dispatch, tree, height, width, matchComponent } =\n props;\n\n const ref = useRef<TreeApi<TreeData>>();\n // Use a ref to track clicks (won't cause rerender)\n const clickedRef = useRef(false);\n\n const _Node = useCallback(\n (props) => h(Node, { ...props, matchComponent }),\n [matchComponent],\n );\n\n // Update Tree selection when selectedNodes change\n useEffect(() => {\n if (ref.current == null) return;\n\n const selection = new Set(selectedNodes.map((d) => d.toString()));\n const currentSelection = ref.current.selectedIds;\n if (setsAreTheSame(selection, currentSelection)) return;\n\n ref.current.setSelection({\n ids: selectedNodes.map((d) => d.toString()),\n anchor: null,\n mostRecent: null,\n });\n }, [selectedNodes]);\n\n // Mark clicked when user clicks inside the tree container\n function handleClick() {\n clickedRef.current = true;\n }\n\n const ctrlPressedRef = useRef(false);\n\n useEffect(() => {\n const down = (e) => {\n if (e.ctrlKey || e.metaKey) ctrlPressedRef.current = true;\n };\n const up = () => (ctrlPressedRef.current = false);\n\n window.addEventListener(\"keydown\", down);\n window.addEventListener(\"keyup\", up);\n return () => {\n window.removeEventListener(\"keydown\", down);\n window.removeEventListener(\"keyup\", up);\n };\n }, []);\n\n const handleSelect = useCallback(\n (nodes) => {\n if (!clickedRef.current) return;\n clickedRef.current = false;\n const isMultiSelect = ctrlPressedRef.current;\n\n let ids = nodes.map((d) => parseInt(d.id));\n\n if (isMultiSelect) {\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n } else {\n if (ids.length === 1 && ids[0] === selectedNodes[0]) {\n ids = [];\n }\n\n dispatch({ type: \"select-node\", payload: { ids } });\n }\n },\n [selectedNodes, dispatch],\n );\n\n return h(\n \"div.selection-tree-wrapper\",\n { onPointerDown: handleClick },\n h(Tree, {\n className: \"selection-tree\",\n height,\n width,\n ref,\n data: tree,\n onMove({ dragIds, parentId, index }) {\n dispatch({\n type: \"move-node\",\n payload: {\n dragIds: dragIds.map((d) => parseInt(d)),\n parentId: parentId ? parseInt(parentId) : null,\n index,\n },\n });\n },\n onDelete({ ids }) {\n dispatch({\n type: \"delete-node\",\n payload: { ids: ids.map((d) => parseInt(d)) },\n });\n },\n onSelect: handleSelect,\n children: _Node,\n idAccessor(d) {\n return d.id.toString();\n },\n }),\n );\n}\n"],"names":["$ajJMX$macrostrathyper","Tree","$ajJMX$Tree","useState","$ajJMX$useState","useRef","$ajJMX$useRef","useCallback","$ajJMX$useCallback","useEffect","$ajJMX$useEffect","SegmentedControl","$ajJMX$SegmentedControl","Card","$ajJMX$Card","ButtonGroup","$ajJMX$ButtonGroup","Divider","$ajJMX$Divider","ErrorBoundary","$ajJMX$ErrorBoundary","FlexRow","$ajJMX$FlexRow","CancelButton","$ajJMX$CancelButton","SaveButton","$ajJMX$SaveButton","$ajJMX$useelementdimensions","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$2c86488f2f3c1edd$exports","$2c86488f2f3c1edd$export$a90600c9da52b40c","treeToGraph","$9wFEx","$bQY4Q","$3OP12","$edvRb","$eedTh","$iKZjQ","$bK9Of","$jlqgz","$aWecs","$2c86488f2f3c1edd$var$h","styled","a","__esModule","default","entities","text","model","entityTypes","matchComponent","onSave","allowOverlap","matchLinks","state","dispatch","useUpdatableTree","map","$2c86488f2f3c1edd$var$processEntity","match","setMatchLinks","selectedNodes","tree","selectedEntityType","isSelectingEntityType","entityTypesMap","width","height","ref","TreeDispatchContext","Provider","value","description","FeedbackText","nodes","alignItems","justifyContent","ModelInfo","data","options","label","viewMode","small","onValueChange","console","log","type","payload","if","$2c86488f2f3c1edd$var$ManagedSelectionTree","GraphView","className","vertical","fill","minimal","alignText","icon","disabled","initialTree","onClick","Matches","$2c86488f2f3c1edd$var$EntityTypeSelector","selected","onChange","isOpen","setOpen","entity","term_type","name","txt_range","indices","children","_selected","undefined","inputValue","setInputValue","types","Array","from","values","items","filter","d","toLowerCase","includes","TypeList","OmniboxSelector","selectedItem","onSelectItem","item","onQueryChange","query","onClose","props","clickedRef","_Node","current","$2c86488f2f3c1edd$var$setsAreTheSame","b","size","has","Set","toString","selectedIds","setSelection","ids","anchor","mostRecent","ctrlPressedRef","down","ctrlKey","metaKey","up","window","addEventListener","removeEventListener","onPointerDown","onMove","dragIds","parentId","index","parseInt","onDelete","onSelect","isMultiSelect","length","idAccessor","FeedbackComponent","$330ae695507d96f5$export$8d9dbb7a64bf2a5e"],"version":3,"file":"feedback-components.0eef8d0c.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"./feedback-components.a7b43cfa.js";import"./feedback-components.b9317f9c.js";import"./feedback-components.b22d37d1.js";import e from"@macrostrat/hyper";import{forceSimulation as r,forceLink as t,forceManyBody as o,forceCenter as a,forceCollide as i}from"d3-force";import{useState as s,useEffect as l}from"react";import{Spinner as c,Switch as n}from"@blueprintjs/core";import{ErrorBoundary as d}from"@macrostrat/ui-components";var p=globalThis,h={},g={},f=p.parcelRequirea149;null==f&&((f=function(e){if(e in h)return h[e].exports;if(e in g){var r=g[e];delete g[e];var t={id:e,exports:{}};return h[e]=t,r.call(t.exports,t,t.exports),t.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,r){g[e]=r},p.parcelRequirea149=f),f.register;var u=f("eedTh"),m=f("9wFEx"),y=f("edvRb");let b=e.styled(m&&m.__esModule?m.default:m);function k(e){let{tree:p,width:h,height:g,dispatch:f,selectedNodes:m}=e,[k,x]=s(null),[w,v]=s(null),[S,_]=s(!1);return(l(()=>{let{nodes:e,edges:s}=(0,u.treeToGraph)(p),l=new Map(e.map(e=>[e.id,e])),c=s.map(e=>({source:l.get(e.source),target:l.get(e.dest),strength:1})),n=r(e).force("link",t(c)).force("charge",o().strength(-50)).force("center",a(h/2,g/2)).force("collide",i().radius(20)).on("tick",()=>{console.log("Simulation tick")}).on("end",()=>{x(e),v(c)});return()=>{n.stop()}},[p,h,g]),null==k||null==w)?b(c):(console.log("Graph",k,w,m),b(d,{description:"An error occurred while rendering the graph view."},b("div.graph-view",{style:{width:h,height:g}},[b(n,{className:"show-labels-switch",label:"Show Labels",checked:S,onChange:e=>_(e.target.checked)}),b("svg",{width:h,height:g},[b("g.links",w.map(e=>b("line",{x1:e.source.x,y1:e.source.y,x2:e.target.x,y2:e.target.y,stroke:"black"}))),b("g.nodes",k.map(e=>{var r,t,o;let a=m.includes(e.id),i=(r=e.id,t=m,o=k,0===t.length||t.includes(r)||o.some(e=>t.includes(e.id)&&e.children.some(e=>e.id===r))),s=(0,y.getTagStyle)(e.color,{highlighted:i,active:a});return b("g",[b("circle",{cx:e.x,cy:e.y,r:8,fill:s.backgroundColor||"blue",onClick:r=>{r.stopPropagation(),r.ctrlKey||r.metaKey||m[0]===e.id&&1===m.length?(r.stopPropagation(),f({type:"toggle-node-selected",payload:{ids:[e.id]}})):f({type:"select-node",payload:{ids:[e.id]}})},className:a?"selected":"",stroke:a?"white":"black",strokeWidth:2}),b.if(S)("text",{x:e.x+10,y:e.y+4,className:"node-label"},e.name||`Node ${e.id}`),b.if(!S)("title",e.name||`Node ${e.id}`)])}))])])))}export{k as GraphView};
2
- //# sourceMappingURL=feedback-components.41db283a.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,mB,C,C,a,C,C,iB,C,C,e,C,C,gB,C,K,U,A,Q,Y,C,C,a,C,K,O,A,Q,W,C,C,U,C,K,mB,A,Q,iB,C,K,2B,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,E,S,E,E,S,E,E,SCkBA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAU,CAMzB,EAGC,GAAM,CAAA,KAAE,CAAI,CAAA,MAAE,CAAK,CAAA,OAAE,CAAM,CAAA,SAAE,CAAQ,CAAA,cAAE,CAAa,CAAE,CAAG,EAEnD,CAAC,EAAO,EAAS,CAAG,AAAA,EAAgC,MACpD,CAA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GACH,OACA,CACE,EAAG,EAAE,CAAC,CAAG,GACT,EAAG,EAAE,CAAC,CAAG,EACT,UAAW,YACb,EACA,EAAE,IAAI,EAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAA,CAAE,EAE1B,EAAE,EAAE,CAAC,CAAC,GAAY,QAAS,EAAE,IAAI,EAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAA,CAAE,EACpD,CACH,IAEH,EACF,GAEL,Q,K,S","sources":["<anon>","packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import \"./feedback-components.a7b43cfa.js\";\nimport \"./feedback-components.b9317f9c.js\";\nimport \"./feedback-components.b22d37d1.js\";\nimport $9bqpz$macrostrathyper from \"@macrostrat/hyper\";\nimport {forceSimulation as $9bqpz$forceSimulation, forceLink as $9bqpz$forceLink, forceManyBody as $9bqpz$forceManyBody, forceCenter as $9bqpz$forceCenter, forceCollide as $9bqpz$forceCollide} from \"d3-force\";\nimport {useState as $9bqpz$useState, useEffect as $9bqpz$useEffect} from \"react\";\nimport {Spinner as $9bqpz$Spinner, Switch as $9bqpz$Switch} from \"@blueprintjs/core\";\nimport {ErrorBoundary as $9bqpz$ErrorBoundary} from \"@macrostrat/ui-components\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\n\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\nconst $8732cb0ae0ae3dfd$var$h = (0, $9bqpz$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566(props) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree: tree, width: width, height: height, dispatch: dispatch, selectedNodes: selectedNodes } = props;\n const [nodes, setNodes] = (0, $9bqpz$useState)(null);\n const [links, setLinks] = (0, $9bqpz$useState)(null);\n const [showLabels, setShowLabels] = (0, $9bqpz$useState)(false);\n (0, $9bqpz$useEffect)(()=>{\n const { nodes: nodes, edges: edges } = (0, $eedTh.treeToGraph)(tree);\n const nodesMap = new Map(nodes.map((d)=>[\n d.id,\n d\n ]));\n const links = edges.map((d)=>{\n return {\n source: nodesMap.get(d.source),\n target: nodesMap.get(d.dest),\n strength: 1\n };\n });\n const simulation = (0, $9bqpz$forceSimulation)(nodes).force(\"link\", (0, $9bqpz$forceLink)(links)).force(\"charge\", (0, $9bqpz$forceManyBody)().strength(-50)).force(\"center\", (0, $9bqpz$forceCenter)(width / 2, height / 2)).force(\"collide\", (0, $9bqpz$forceCollide)().radius(20)).on(\"tick\", ()=>{\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n }).on(\"end\", ()=>{\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n return ()=>{\n simulation.stop();\n };\n }, [\n tree,\n width,\n height\n ]);\n if (nodes == null || links == null) return $8732cb0ae0ae3dfd$var$h((0, $9bqpz$Spinner));\n console.log(\"Graph\", nodes, links, selectedNodes);\n return $8732cb0ae0ae3dfd$var$h((0, $9bqpz$ErrorBoundary), {\n description: \"An error occurred while rendering the graph view.\"\n }, $8732cb0ae0ae3dfd$var$h(\"div.graph-view\", {\n style: {\n width: width,\n height: height\n }\n }, [\n $8732cb0ae0ae3dfd$var$h((0, $9bqpz$Switch), {\n className: \"show-labels-switch\",\n label: \"Show Labels\",\n checked: showLabels,\n onChange: (e)=>setShowLabels(e.target.checked)\n }),\n $8732cb0ae0ae3dfd$var$h(\"svg\", {\n width: width,\n height: height\n }, [\n $8732cb0ae0ae3dfd$var$h(\"g.links\", links.map((d)=>{\n return $8732cb0ae0ae3dfd$var$h(\"line\", {\n x1: d.source.x,\n y1: d.source.y,\n x2: d.target.x,\n y2: d.target.y,\n stroke: \"black\"\n });\n })),\n $8732cb0ae0ae3dfd$var$h(\"g.nodes\", nodes.map((d)=>{\n const active = selectedNodes.includes(d.id);\n const stroke = active ? \"white\" : \"black\";\n const highlighted = $8732cb0ae0ae3dfd$var$isHighlighted(d.id, selectedNodes, nodes);\n const style = (0, $edvRb.getTagStyle)(d.color, {\n highlighted: highlighted,\n active: active\n });\n return $8732cb0ae0ae3dfd$var$h(\"g\", [\n $8732cb0ae0ae3dfd$var$h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 8,\n fill: style.backgroundColor || \"blue\",\n onClick: (e)=>{\n e.stopPropagation();\n if (e.ctrlKey || e.metaKey || selectedNodes[0] === d.id && selectedNodes.length === 1) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: [\n d.id\n ]\n }\n });\n } else dispatch({\n type: \"select-node\",\n payload: {\n ids: [\n d.id\n ]\n }\n });\n },\n className: active ? \"selected\" : \"\",\n stroke: stroke,\n strokeWidth: 2\n }),\n $8732cb0ae0ae3dfd$var$h.if(showLabels)(\"text\", {\n x: d.x + 10,\n y: d.y + 4,\n className: \"node-label\"\n }, d.name || `Node ${d.id}`),\n $8732cb0ae0ae3dfd$var$h.if(!showLabels)(\"title\", d.name || `Node ${d.id}`)\n ]);\n }))\n ])\n ]));\n}\nfunction $8732cb0ae0ae3dfd$var$isHighlighted(id, selectedNodes, nodes) {\n if (selectedNodes.length === 0) return true;\n return selectedNodes.includes(id) || nodes.some((node)=>selectedNodes.includes(node.id) && node.children.some((child)=>child.id === id));\n}\n\n\nexport {$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566 as GraphView};\n//# sourceMappingURL=feedback-components.41db283a.js.map\n","import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport {\n forceSimulation,\n SimulationNodeDatum,\n SimulationLinkDatum,\n forceCenter,\n forceLink,\n forceManyBody,\n forceCollide,\n} from \"d3-force\";\nimport { useEffect, useState } from \"react\";\nimport { Spinner, Switch } from \"@blueprintjs/core\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { getTagStyle } from \"../extractions\";\n\nconst h = hyper.styled(styles);\n\nexport function GraphView(props: {\n tree: TreeData[];\n width: number;\n height: number;\n dispatch: (action: any) => void;\n selectedNodes: number[];\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height, dispatch, selectedNodes } = props;\n\n const [nodes, setNodes] = useState<SimulationNodeDatum[]>(null);\n const [links, setLinks] = useState<SimulationLinkDatum[]>(null);\n const [showLabels, setShowLabels] = useState(false);\n\n useEffect(() => {\n const { nodes, edges } = treeToGraph(tree);\n\n const nodesMap = new Map<number, SimulationNodeDatum>(\n nodes.map((d) => [d.id, d]),\n );\n\n const links = edges.map((d) => {\n return {\n source: nodesMap.get(d.source),\n target: nodesMap.get(d.dest),\n strength: 1,\n };\n });\n\n const simulation = forceSimulation(nodes)\n .force(\"link\", forceLink(links))\n .force(\"charge\", forceManyBody().strength(-50))\n .force(\"center\", forceCenter(width / 2, height / 2))\n .force(\"collide\", forceCollide().radius(20))\n .on(\"tick\", () => {\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n })\n .on(\"end\", () => {\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n\n return () => {\n simulation.stop();\n };\n }, [tree, width, height]);\n\n if (nodes == null || links == null) {\n return h(Spinner);\n }\n\n console.log(\"Graph\", nodes, links, selectedNodes);\n\n return h(\n ErrorBoundary,\n {\n description: \"An error occurred while rendering the graph view.\",\n },\n h(\"div.graph-view\", { style: { width, height } }, [\n h(Switch, {\n className: \"show-labels-switch\",\n label: \"Show Labels\",\n checked: showLabels,\n onChange: (e) => setShowLabels(e.target.checked),\n }),\n h(\"svg\", { width, height }, [\n h(\n \"g.links\",\n links.map((d) => {\n return h(\"line\", {\n x1: d.source.x,\n y1: d.source.y,\n x2: d.target.x,\n y2: d.target.y,\n stroke: \"black\",\n });\n }),\n ),\n h(\n \"g.nodes\",\n nodes.map((d) => {\n const active = selectedNodes.includes(d.id);\n const stroke = active ? \"white\" : \"black\";\n const highlighted = isHighlighted(d.id, selectedNodes, nodes);\n const style = getTagStyle(d.color, { highlighted, active });\n\n return h(\"g\", [\n h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 8,\n fill: style.backgroundColor || \"blue\",\n onClick: (e) => {\n e.stopPropagation();\n if (\n e.ctrlKey ||\n e.metaKey ||\n (selectedNodes[0] === d.id && selectedNodes.length === 1)\n ) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [d.id] },\n });\n } else {\n dispatch({\n type: \"select-node\",\n payload: { ids: [d.id] },\n });\n }\n },\n className: active ? \"selected\" : \"\",\n stroke,\n strokeWidth: 2,\n }),\n h.if(showLabels)(\n \"text\",\n {\n x: d.x + 10,\n y: d.y + 4,\n className: \"node-label\",\n },\n d.name || `Node ${d.id}`,\n ),\n h.if(!showLabels)(\"title\", d.name || `Node ${d.id}`),\n ]);\n }),\n ),\n ]),\n ]),\n );\n}\n\nfunction isHighlighted(id: number, selectedNodes: number[], nodes: TreeData[]) {\n if (selectedNodes.length === 0) return true;\n return (\n selectedNodes.includes(id) ||\n nodes.some(\n (node) =>\n selectedNodes.includes(node.id) &&\n node.children.some((child) => child.id === id),\n )\n );\n}\n"],"names":["$9bqpz$macrostrathyper","forceSimulation","$9bqpz$forceSimulation","forceLink","$9bqpz$forceLink","forceManyBody","$9bqpz$forceManyBody","forceCenter","$9bqpz$forceCenter","forceCollide","$9bqpz$forceCollide","useState","$9bqpz$useState","useEffect","$9bqpz$useEffect","Spinner","$9bqpz$Spinner","Switch","$9bqpz$Switch","ErrorBoundary","$9bqpz$ErrorBoundary","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$eedTh","$9wFEx","$edvRb","$8732cb0ae0ae3dfd$var$h","styled","a","__esModule","default","$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566","props","tree","width","height","dispatch","selectedNodes","nodes","setNodes","links","setLinks","showLabels","setShowLabels","edges","treeToGraph","nodesMap","Map","map","d","source","get","target","dest","strength","simulation","force","radius","on","console","log","stop","description","style","className","label","checked","onChange","e","x1","x","y1","y","x2","y2","stroke","active","includes","highlighted","length","some","node","children","child","getTagStyle","color","cx","cy","r","fill","backgroundColor","onClick","stopPropagation","ctrlKey","metaKey","type","payload","ids","strokeWidth","if","name","GraphView"],"version":3,"file":"feedback-components.41db283a.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"./feedback-components.b9317f9c.js";import"./feedback-components.b22d37d1.js";import t from"@macrostrat/hyper";import{useRef as e,useEffect as a}from"react";import{Icon as n}from"@blueprintjs/core";import{JSONView as o,DataField as r}from"@macrostrat/ui-components";import{LithologyTag as l}from"@macrostrat/data-components";var i=globalThis,s={},d={},c=i.parcelRequirea149;null==c&&((c=function(t){if(t in s)return s[t].exports;if(t in d){var e=d[t];delete d[t];var a={id:t,exports:{}};return s[t]=a,e.call(a.exports,a,a.exports),a.exports}var n=Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(t,e){d[t]=e},i.parcelRequirea149=c),c.register;var p=c("9wFEx"),g=c("edvRb");let u=t.styled(p&&p.__esModule?p.default:p);function h(t){let{text:e,selectedNodes:a,nodes:n,dispatch:o,allowOverlap:r,matchLinks:l}=t;return u("div.feedback-text-wrapper",{tabIndex:0,onKeyDown:t=>{"Backspace"===t.key&&o({type:"delete-node",payload:{ids:a}})}},u(f,{text:e,allTags:function(t,e){let a=[],n=new Set;for(let r of t){var o;if(n.has(r.id))continue;let t=function(t,e){return 0===e.length||((e.includes(t.id)||t.parents?.some(t=>e.includes(t)))??!1)}(r,e),l=(o=r,e.includes(o.id)),i=(0,g.getTagStyle)(r.backgroundColor,{highlighted:t,active:l}),s={color:i.color,tagStyle:{display:"none"},markStyle:{backgroundColor:i.backgroundColor},...r,backgroundColor:i.backgroundColor};a.push(s),n.add(r.id)}return a}((0,g.buildHighlights)(n,null),a),allowOverlap:r,dispatch:o,selectedNodes:a,matchLinks:l}))}function f(t){let{text:n,allTags:o=[],dispatch:r,selectedNodes:l,allowOverlap:i,matchLinks:s}=t,d=function(t,e){let a=[];for(let t of e)a.push({pos:t.start,type:"start",tag:t}),a.push({pos:t.end,type:"end",tag:t});a.sort((t,e)=>t.pos!==e.pos?t.pos-e.pos:"end"===t.type&&"start"===e.type?-1:+("start"===t.type&&"end"===e.type));let n={children:[],textStart:0},o=[n],r=0;for(let{pos:e,type:n,tag:l}of a){let a=o[o.length-1];if(e>r){let n=t.slice(r,e);a.children.push(n)}if("start"===n){let t={tag:l,children:[],textStart:e};a.children.push(t),o.push(t)}else o.pop();r=e}return r<t.length&&o[o.length-1].children.push(t.slice(r)),n}(n,o),c=e(null);return a(()=>{let t=()=>{let t=function({container:t}){let e=window.getSelection();if(!e||e.isCollapsed||0===e.rangeCount||!t)return null;let a=e.getRangeAt(0);if(!t.contains(a.startContainer)||!t.contains(a.endContainer))return null;let n=document.createRange();n.setStart(t,0),n.setEnd(a.startContainer,a.startOffset);let o=n.toString().length,r=a.toString(),l=o+r.length;return{start:o,end:l,text:r}}({container:c.current});t&&function({tag:t,dispatch:e,text:a,allTags:n,allowOverlap:o}){let{start:r,end:l}=t;if(" "!=a[l-1]){for(;r>0&&/\w/.test(a[r-1]);)r--;for(;l<a.length&&/\w/.test(a[l]);)l++}let i={start:r,end:l,text:a.slice(r,l)};if(""===i.text.trim())return console.log("Blank tag found, ignoring");if(n.find(t=>t.start===i.start&&(t.end===i.end||t.end===i.end-1)))return console.log("Duplicate tag found, ignoring");i.text.endsWith(" ")&&(i.text=i.text.slice(0,-1),i.end-=1);let s=n.some(t=>t.start<=i.start&&t.end>=i.end),d=n.some(t=>t.start<i.end&&t.end>i.start);if((s||d)&&!o)return console.log("Tag is inside another tag, ignoring");e({type:"create-node",payload:i})}({tag:t,dispatch:r,text:n,allTags:o,allowOverlap:i})};return document.addEventListener("mouseup",t),()=>{document.removeEventListener("mouseup",t)}},[n,o,r,i]),u("span",{ref:c},d.children.map((t,e)=>(function t(e,a,n,o,r){if("string"==typeof e)return e;let{tag:l,children:i}=e,s=n?.includes(l.id),d=0===n.length||s,c={...l,zIndex:o?-1:1,border:"1px solid "+(d?l.color:"transparent"),margin:"-1px"},p=[];if(s){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)){let e=i[t];e?.tag?p.push(e.children[0]):p.push(e)}}return u("span",{onMouseEnter:t=>{t.stopPropagation()},className:"highlight",style:c,onClick:t=>{t.stopPropagation(),t.ctrlKey||t.metaKey||n[0]===l.id&&1===n.length?(t.stopPropagation(),a({type:"toggle-node-selected",payload:{ids:[l.id]}})):t.shiftKey&&n.length>0?a({type:"select-range",payload:{ids:[n[n.length-1],l.id]}}):a({type:"select-node",payload:{ids:[l.id]}})}},s?p.flat():i.map((e,o)=>t(e,a,n,s,r)))})(t,r,l,!1,s)))}function m({data:t,matchLinks:e,dispatch:a,nodeId:i}){if(!t||0===Object.keys(t).length)return;let s=u(o,{data:t});return t.lith_id&&(s=u(r,{label:"Lithology",value:u(l,{data:{name:t.name,id:t.lith_id,color:t.color},onClick:a=>{a.stopPropagation(),e.lithology&&window.open(e.lithology+"/"+t.lith_id,"_blank")}})})),t.strat_name_id&&(s=u("div",[u(r,{label:"Stratigraphic name",value:u(l,{data:{name:t.name,id:t.strat_name_id,color:t.color},onClick:a=>{a.stopPropagation(),e.strat_name&&window.open(e.strat_name+"/"+t.strat_name_id,"_blank")}})}),u.if(t.concept_id)(r,{label:"Stratigraphic concept",value:u(l,{data:{name:t.name,id:t.concept_id,color:t.color},onClick:a=>{a.stopPropagation(),e.concept&&window.open(e.concept+"/"+t.concept_id,"_blank")}})})])),t.lith_att_id&&(s=u(r,{label:"Lithology attribute",value:u(l,{data:{name:t.name,id:t.lith_att_id},onClick:a=>{a.stopPropagation(),e.lith_att&&window.open(e.lith_att+"/"+t.lith_att_id,"_blank")}})})),u("div.match-container",[s,u(n,{icon:"cross",color:"red",className:"close-btn",onClick:()=>{a({type:"remove-match",payload:{id:i}})}})])}export{h as FeedbackText,f as HighlightedText,m as Match};
2
- //# sourceMappingURL=feedback-components.69d0ccd0.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,oD,A,O,oD,A,Q,M,mB,A,Q,U,C,C,a,C,K,O,A,Q,Q,C,K,mB,A,Q,Y,C,C,a,C,K,2B,A,Q,gB,C,K,6B,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,E,S,E,E,SCYA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAqEhB,SAAS,EAAa,CAAwB,EAEnD,GAAM,CAAA,KAAE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B,OAAO,IAAI,CAAC,EAAW,OAAO,CAAG,IAAM,EAAK,UAAU,CAAE,SAE5D,CACF,EACF,GACD,CAAA,EAGC,EAAK,WAAW,EAClB,CAAA,EAAM,EAAE,EAAW,CACjB,MAAO,sBACP,MAAO,EAAE,EAAc,CACrB,KAAM,CAAE,KAAM,EAAK,IAAI,CAAE,GAAI,EAAK,WAAW,AAAC,EAC9C,QAAS,AAAC,IACR,EAAE,eAAe,GACb,EAAW,QAAQ,EACrB,OAAO,IAAI,CAAC,EAAW,QAAQ,CAAG,IAAM,EAAK,WAAW,CAAE,SAE9D,CACF,EACF,EAAA,EAGK,EAAE,sBAAuB,CAC9B,EACA,EAAE,EAAM,CACN,KAAM,QACN,MAAO,MACP,UAAW,YACX,QAAS,KACP,EAAS,CAAE,KAAM,eAAgB,QAAS,CAAE,GAAI,CAAO,CAAE,EAC3D,CACF,GACD,CACH,Q,K,Y,C,K,e,C,K,K","sources":["<anon>","packages/feedback-components/src/feedback/text-visualizer.ts"],"sourcesContent":["import \"./feedback-components.b9317f9c.js\";\nimport \"./feedback-components.b22d37d1.js\";\nimport $h8ona$macrostrathyper from \"@macrostrat/hyper\";\nimport {useRef as $h8ona$useRef, useEffect as $h8ona$useEffect} from \"react\";\nimport {Icon as $h8ona$Icon} from \"@blueprintjs/core\";\nimport {JSONView as $h8ona$JSONView, DataField as $h8ona$DataField} from \"@macrostrat/ui-components\";\nimport {LithologyTag as $h8ona$LithologyTag} from \"@macrostrat/data-components\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\n\n\n\nconst $d6cf457c7790c03a$var$h = (0, $h8ona$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $d6cf457c7790c03a$var$buildTags(highlights, selectedNodes) {\n let tags = [];\n // If entity ID has already been seen, don't add it again\n const entities = new Set();\n for (const highlight of highlights){\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n const highlighted = $d6cf457c7790c03a$var$isHighlighted(highlight, selectedNodes);\n const active = $d6cf457c7790c03a$var$isActive(highlight, selectedNodes);\n const tagStyle = (0, $edvRb.getTagStyle)(highlight.backgroundColor, {\n highlighted: highlighted,\n active: active\n });\n const tag = {\n color: tagStyle.color,\n tagStyle: {\n display: \"none\"\n },\n markStyle: {\n backgroundColor: tagStyle.backgroundColor\n },\n ...highlight,\n backgroundColor: tagStyle.backgroundColor\n };\n tags.push(tag);\n entities.add(highlight.id);\n }\n return tags;\n}\nfunction $d6cf457c7790c03a$var$isActive(tag, selectedNodes) {\n return selectedNodes.includes(tag.id);\n}\nfunction $d6cf457c7790c03a$var$isHighlighted(tag, selectedNodes) {\n if (selectedNodes.length === 0) return true;\n return (selectedNodes.includes(tag.id) || tag.parents?.some((d)=>selectedNodes.includes(d))) ?? false;\n}\nfunction $d6cf457c7790c03a$export$6e107db9091b8219(props) {\n // Convert input to tags\n const { text: text, selectedNodes: selectedNodes, nodes: nodes, dispatch: dispatch, allowOverlap: allowOverlap, matchLinks: matchLinks } = props;\n const allTags = $d6cf457c7790c03a$var$buildTags((0, $edvRb.buildHighlights)(nodes, null), selectedNodes);\n return $d6cf457c7790c03a$var$h(\"div.feedback-text-wrapper\", {\n tabIndex: 0,\n onKeyDown: (e)=>{\n if (e.key === \"Backspace\") dispatch({\n type: \"delete-node\",\n payload: {\n ids: selectedNodes\n }\n });\n }\n }, $d6cf457c7790c03a$var$h($d6cf457c7790c03a$export$190465bec6b893be, {\n text: text,\n allTags: allTags,\n allowOverlap: allowOverlap,\n dispatch: dispatch,\n selectedNodes: selectedNodes,\n matchLinks: matchLinks\n }));\n}\nfunction $d6cf457c7790c03a$var$createTagFromSelection({ container: container }) {\n const selection = window.getSelection();\n if (!selection || selection.isCollapsed || selection.rangeCount === 0 || !container) return null;\n const range = selection.getRangeAt(0);\n if (!container.contains(range.startContainer) || !container.contains(range.endContainer)) return null;\n const preRange = document.createRange();\n preRange.setStart(container, 0);\n preRange.setEnd(range.startContainer, range.startOffset);\n const start = preRange.toString().length;\n const selectedText = range.toString();\n const end = start + selectedText.length;\n return {\n start: start,\n end: end,\n text: selectedText\n };\n}\nfunction $d6cf457c7790c03a$var$addTag({ tag: tag, dispatch: dispatch, text: text, allTags: allTags, allowOverlap: allowOverlap }) {\n let { start: start, end: end } = tag;\n // snap to text\n if (text[end - 1] != \" \") {\n // double clicking word overselects by one, shouldn't increase to next word\n while(start > 0 && /\\w/.test(text[start - 1]))start--;\n while(end < text.length && /\\w/.test(text[end]))end++;\n }\n let payload = {\n start: start,\n end: end,\n text: text.slice(start, end)\n };\n if (payload.text.trim() === \"\") {\n console.log(\"Blank tag found, ignoring\");\n return;\n }\n const duplicate = allTags.find((t)=>t.start === payload.start && (t.end === payload.end || t.end === payload.end - 1));\n if (duplicate) {\n console.log(\"Duplicate tag found, ignoring\");\n return;\n }\n if (payload.text.endsWith(\" \")) {\n payload.text = payload.text.slice(0, -1);\n payload.end -= 1;\n }\n const inside = allTags.some((t)=>t.start <= payload.start && t.end >= payload.end);\n const overlap = allTags.some((t)=>t.start < payload.end && t.end > payload.start);\n if ((inside || overlap) && !allowOverlap) {\n console.log(\"Tag is inside another tag, ignoring\");\n return;\n }\n dispatch({\n type: \"create-node\",\n payload: payload\n });\n}\nfunction $d6cf457c7790c03a$var$nestHighlights(text, tags) {\n const events = [];\n for (const tag of tags){\n events.push({\n pos: tag.start,\n type: \"start\",\n tag: tag\n });\n events.push({\n pos: tag.end,\n type: \"end\",\n tag: tag\n });\n }\n events.sort((a, b)=>{\n if (a.pos !== b.pos) return a.pos - b.pos;\n if (a.type === \"end\" && b.type === \"start\") return -1;\n if (a.type === \"start\" && b.type === \"end\") return 1;\n return 0;\n });\n const root = {\n children: [],\n textStart: 0\n };\n const stack = [\n root\n ];\n let lastPos = 0;\n for (const { pos: pos, type: type, tag: tag } of events){\n const parent = stack[stack.length - 1];\n if (pos > lastPos) {\n const slice = text.slice(lastPos, pos);\n parent.children.push(slice);\n }\n if (type === \"start\") {\n const newNode = {\n tag: tag,\n children: [],\n textStart: pos\n };\n parent.children.push(newNode);\n stack.push(newNode);\n } else stack.pop();\n lastPos = pos;\n }\n if (lastPos < text.length) stack[stack.length - 1].children.push(text.slice(lastPos));\n return root;\n}\nfunction $d6cf457c7790c03a$var$renderNode(node, dispatch, selectedNodes, parentSelected, matchLinks) {\n if (typeof node === \"string\") return node;\n const { tag: tag, children: children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n const showBorder = selectedNodes.length === 0 || isSelected;\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1,\n border: \"1px solid \" + (showBorder ? tag.color : \"transparent\"),\n margin: \"-1px\"\n };\n let moveText = [];\n if (isSelected) {\n for(const key in children)if (Object.prototype.hasOwnProperty.call(children, key)) {\n const child = children[key];\n if (child?.tag) moveText.push(child.children[0]);\n else moveText.push(child);\n }\n }\n return $d6cf457c7790c03a$var$h(\"span\", {\n onMouseEnter: (e)=>{\n e.stopPropagation();\n },\n className: \"highlight\",\n style: style,\n onClick: (e)=>{\n e.stopPropagation();\n if (e.ctrlKey || e.metaKey || selectedNodes[0] === tag.id && selectedNodes.length === 1) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: [\n tag.id\n ]\n }\n });\n } else if (e.shiftKey && selectedNodes.length > 0) {\n // Select range from last selected node to this one\n const lastSelected = selectedNodes[selectedNodes.length - 1];\n dispatch({\n type: \"select-range\",\n payload: {\n ids: [\n lastSelected,\n tag.id\n ]\n }\n });\n } else dispatch({\n type: \"select-node\",\n payload: {\n ids: [\n tag.id\n ]\n }\n });\n }\n }, isSelected ? moveText.flat() : children.map((child, i)=>$d6cf457c7790c03a$var$renderNode(child, dispatch, selectedNodes, isSelected, matchLinks)));\n}\nfunction $d6cf457c7790c03a$export$190465bec6b893be(props) {\n const { text: text, allTags: allTags = [], dispatch: dispatch, selectedNodes: selectedNodes, allowOverlap: allowOverlap, matchLinks: matchLinks } = props;\n const tree = $d6cf457c7790c03a$var$nestHighlights(text, allTags);\n const spanRef = (0, $h8ona$useRef)(null);\n (0, $h8ona$useEffect)(()=>{\n const handleMouseUp = ()=>{\n const tag = $d6cf457c7790c03a$var$createTagFromSelection({\n container: spanRef.current\n });\n if (!tag) return;\n $d6cf457c7790c03a$var$addTag({\n tag: tag,\n dispatch: dispatch,\n text: text,\n allTags: allTags,\n allowOverlap: allowOverlap\n });\n };\n document.addEventListener(\"mouseup\", handleMouseUp);\n return ()=>{\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [\n text,\n allTags,\n dispatch,\n allowOverlap\n ]);\n return $d6cf457c7790c03a$var$h(\"span\", {\n ref: spanRef\n }, tree.children.map((child, i)=>$d6cf457c7790c03a$var$renderNode(child, dispatch, selectedNodes, false, matchLinks)));\n}\nfunction $d6cf457c7790c03a$export$f421feb8fad20413({ data: data, matchLinks: matchLinks, dispatch: dispatch, nodeId: nodeId }) {\n if (!data || Object.keys(data).length === 0) return;\n let tag = $d6cf457c7790c03a$var$h((0, $h8ona$JSONView), {\n data: data\n });\n if (data.lith_id) tag = $d6cf457c7790c03a$var$h((0, $h8ona$DataField), {\n label: \"Lithology\",\n value: $d6cf457c7790c03a$var$h((0, $h8ona$LithologyTag), {\n data: {\n name: data.name,\n id: data.lith_id,\n color: data.color\n },\n onClick: (e)=>{\n e.stopPropagation();\n if (matchLinks.lithology) window.open(matchLinks.lithology + \"/\" + data.lith_id, \"_blank\");\n }\n })\n });\n if (data.strat_name_id) tag = $d6cf457c7790c03a$var$h(\"div\", [\n $d6cf457c7790c03a$var$h((0, $h8ona$DataField), {\n label: \"Stratigraphic name\",\n value: $d6cf457c7790c03a$var$h((0, $h8ona$LithologyTag), {\n data: {\n name: data.name,\n id: data.strat_name_id,\n color: data.color\n },\n onClick: (e)=>{\n e.stopPropagation();\n if (matchLinks.strat_name) window.open(matchLinks.strat_name + \"/\" + data.strat_name_id, \"_blank\");\n }\n })\n }),\n $d6cf457c7790c03a$var$h.if(data.concept_id)((0, $h8ona$DataField), {\n label: \"Stratigraphic concept\",\n value: $d6cf457c7790c03a$var$h((0, $h8ona$LithologyTag), {\n data: {\n name: data.name,\n id: data.concept_id,\n color: data.color\n },\n onClick: (e)=>{\n e.stopPropagation();\n if (matchLinks.concept) window.open(matchLinks.concept + \"/\" + data.concept_id, \"_blank\");\n }\n })\n })\n ]);\n if (data.lith_att_id) tag = $d6cf457c7790c03a$var$h((0, $h8ona$DataField), {\n label: \"Lithology attribute\",\n value: $d6cf457c7790c03a$var$h((0, $h8ona$LithologyTag), {\n data: {\n name: data.name,\n id: data.lith_att_id\n },\n onClick: (e)=>{\n e.stopPropagation();\n if (matchLinks.lith_att) window.open(matchLinks.lith_att + \"/\" + data.lith_att_id, \"_blank\");\n }\n })\n });\n return $d6cf457c7790c03a$var$h(\"div.match-container\", [\n tag,\n $d6cf457c7790c03a$var$h((0, $h8ona$Icon), {\n icon: \"cross\",\n color: \"red\",\n className: \"close-btn\",\n onClick: ()=>{\n dispatch({\n type: \"remove-match\",\n payload: {\n id: nodeId\n }\n });\n }\n })\n ]);\n}\n\n\nexport {$d6cf457c7790c03a$export$6e107db9091b8219 as FeedbackText, $d6cf457c7790c03a$export$190465bec6b893be as HighlightedText, $d6cf457c7790c03a$export$f421feb8fad20413 as Match};\n//# sourceMappingURL=feedback-components.69d0ccd0.js.map\n","import { AnnotateBlendTag } from \"react-text-annotate-blend\";\nimport { InternalEntity } from \"./types\";\nimport { TreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { buildHighlights, getTagStyle } from \"../extractions\";\nimport { Highlight } from \"../extractions/types\";\nimport { useEffect, useRef } from \"react\";\nimport { Icon } from \"@blueprintjs/core\";\nimport { DataField, JSONView } from \"@macrostrat/ui-components\";\nimport { LithologyList, LithologyTag } from \"@macrostrat/data-components\";\n\nconst h = hyper.styled(styles);\n\nexport interface FeedbackTextProps {\n text: string;\n selectedNodes: number[];\n nodes: InternalEntity[];\n updateNodes: (nodes: string[]) => void;\n dispatch: TreeDispatch;\n lineHeight: string;\n allowOverlap?: boolean;\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n };\n}\n\nfunction buildTags(\n highlights: Highlight[],\n selectedNodes: number[],\n): AnnotateBlendTag[] {\n let tags: AnnotateBlendTag[] = [];\n // If entity ID has already been seen, don't add it again\n const entities = new Set<number>();\n\n for (const highlight of highlights) {\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n\n const highlighted = isHighlighted(highlight, selectedNodes);\n const active = isActive(highlight, selectedNodes);\n const tagStyle = getTagStyle(highlight.backgroundColor, {\n highlighted,\n active,\n });\n\n const tag = {\n color: tagStyle.color,\n tagStyle: {\n display: \"none\",\n },\n markStyle: {\n backgroundColor: tagStyle.backgroundColor,\n },\n ...highlight,\n backgroundColor: tagStyle.backgroundColor,\n };\n\n tags.push(tag);\n\n entities.add(highlight.id);\n }\n\n return tags;\n}\n\nfunction isActive(tag: Highlight, selectedNodes: number[]) {\n return selectedNodes.includes(tag.id);\n}\n\nfunction isHighlighted(tag: Highlight, selectedNodes: number[]) {\n if (selectedNodes.length === 0) return true;\n return (\n (selectedNodes.includes(tag.id) ||\n tag.parents?.some((d) => selectedNodes.includes(d))) ??\n false\n );\n}\n\nexport function FeedbackText(props: FeedbackTextProps) {\n // Convert input to tags\n const { text, selectedNodes, nodes, dispatch, allowOverlap, matchLinks } =\n props;\n const allTags: AnnotateBlendTag[] = buildTags(\n buildHighlights(nodes, null),\n selectedNodes,\n );\n\n return h(\n \"div.feedback-text-wrapper\",\n {\n tabIndex: 0,\n onKeyDown: (e) => {\n if (e.key === \"Backspace\") {\n dispatch({\n type: \"delete-node\",\n payload: { ids: selectedNodes },\n });\n }\n },\n },\n h(HighlightedText, {\n text,\n allTags,\n allowOverlap,\n dispatch,\n selectedNodes,\n matchLinks,\n }),\n );\n}\n\nfunction createTagFromSelection({\n container,\n}: {\n container: HTMLElement | null;\n}) {\n const selection = window.getSelection();\n if (\n !selection ||\n selection.isCollapsed ||\n selection.rangeCount === 0 ||\n !container\n )\n return null;\n\n const range = selection.getRangeAt(0);\n\n if (\n !container.contains(range.startContainer) ||\n !container.contains(range.endContainer)\n ) {\n return null;\n }\n\n const preRange = document.createRange();\n preRange.setStart(container, 0);\n preRange.setEnd(range.startContainer, range.startOffset);\n const start = preRange.toString().length;\n\n const selectedText = range.toString();\n const end = start + selectedText.length;\n\n return {\n start,\n end,\n text: selectedText,\n };\n}\n\nfunction addTag({ tag, dispatch, text, allTags, allowOverlap }) {\n let { start, end } = tag;\n // snap to text\n if (text[end - 1] != \" \") {\n // double clicking word overselects by one, shouldn't increase to next word\n while (start > 0 && /\\w/.test(text[start - 1])) {\n start--;\n }\n while (end < text.length && /\\w/.test(text[end])) {\n end++;\n }\n }\n\n let payload = { start, end, text: text.slice(start, end) };\n\n if (payload.text.trim() === \"\") {\n console.log(\"Blank tag found, ignoring\");\n return;\n }\n\n const duplicate = allTags.find(\n (t) =>\n t.start === payload.start &&\n (t.end === payload.end || t.end === payload.end - 1),\n );\n\n if (duplicate) {\n console.log(\"Duplicate tag found, ignoring\");\n return;\n }\n\n if (payload.text.endsWith(\" \")) {\n payload.text = payload.text.slice(0, -1);\n payload.end -= 1;\n }\n\n const inside = allTags.some(\n (t) => t.start <= payload.start && t.end >= payload.end,\n );\n\n const overlap = allTags.some(\n (t) => t.start < payload.end && t.end > payload.start,\n );\n\n if ((inside || overlap) && !allowOverlap) {\n console.log(\"Tag is inside another tag, ignoring\");\n return;\n }\n\n dispatch({ type: \"create-node\", payload });\n}\n\nfunction nestHighlights(text: string, tags: AnnotateBlendTag[]) {\n const events: Array<{\n pos: number;\n type: \"start\" | \"end\";\n tag: AnnotateBlendTag;\n }> = [];\n\n for (const tag of tags) {\n events.push({ pos: tag.start, type: \"start\", tag });\n events.push({ pos: tag.end, type: \"end\", tag });\n }\n\n events.sort((a, b) => {\n if (a.pos !== b.pos) return a.pos - b.pos;\n if (a.type === \"end\" && b.type === \"start\") return -1;\n if (a.type === \"start\" && b.type === \"end\") return 1;\n return 0;\n });\n\n const root = { children: [], textStart: 0 };\n const stack = [root];\n let lastPos = 0;\n\n for (const { pos, type, tag } of events) {\n const parent = stack[stack.length - 1];\n\n if (pos > lastPos) {\n const slice = text.slice(lastPos, pos);\n parent.children.push(slice);\n }\n\n if (type === \"start\") {\n const newNode = { tag, children: [], textStart: pos };\n parent.children.push(newNode);\n stack.push(newNode);\n } else {\n stack.pop();\n }\n\n lastPos = pos;\n }\n\n if (lastPos < text.length) {\n stack[stack.length - 1].children.push(text.slice(lastPos));\n }\n\n return root;\n}\n\nfunction renderNode(\n node: any,\n dispatch: TreeDispatch,\n selectedNodes: number[],\n parentSelected: boolean,\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n },\n): any {\n if (typeof node === \"string\") return node;\n\n const { tag, children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n const showBorder = selectedNodes.length === 0 || isSelected;\n\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1,\n border: \"1px solid \" + (showBorder ? tag.color : \"transparent\"),\n margin: \"-1px\",\n };\n\n let moveText = [];\n if (isSelected) {\n for (const key in children) {\n if (Object.prototype.hasOwnProperty.call(children, key)) {\n const child = children[key];\n if (child?.tag) {\n moveText.push(child.children[0]);\n } else {\n moveText.push(child);\n }\n }\n }\n }\n\n return h(\n \"span\",\n {\n onMouseEnter: (e: MouseEvent) => {\n e.stopPropagation();\n },\n className: \"highlight\",\n style,\n onClick: (e: MouseEvent) => {\n e.stopPropagation();\n if (\n e.ctrlKey ||\n e.metaKey ||\n (selectedNodes[0] === tag.id && selectedNodes.length === 1)\n ) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [tag.id] },\n });\n } else if (e.shiftKey && selectedNodes.length > 0) {\n // Select range from last selected node to this one\n const lastSelected = selectedNodes[selectedNodes.length - 1];\n\n dispatch({\n type: \"select-range\",\n payload: { ids: [lastSelected, tag.id] },\n });\n } else {\n dispatch({\n type: \"select-node\",\n payload: { ids: [tag.id] },\n });\n }\n },\n },\n isSelected\n ? moveText.flat()\n : children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, isSelected, matchLinks),\n ),\n );\n}\n\nexport function HighlightedText(props: {\n text: string;\n allTags: AnnotateBlendTag[];\n lineHeight: string;\n allowOverlap?: boolean;\n dispatch: TreeDispatch;\n selectedNodes: number[];\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n };\n}) {\n const {\n text,\n allTags = [],\n dispatch,\n selectedNodes,\n allowOverlap,\n matchLinks,\n } = props;\n\n const tree = nestHighlights(text, allTags);\n\n const spanRef = useRef<HTMLSpanElement>(null);\n\n useEffect(() => {\n const handleMouseUp = () => {\n const tag = createTagFromSelection({ container: spanRef.current });\n if (!tag) return;\n addTag({ tag, dispatch, text, allTags, allowOverlap });\n };\n\n document.addEventListener(\"mouseup\", handleMouseUp);\n return () => {\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [text, allTags, dispatch, allowOverlap]);\n\n return h(\n \"span\",\n { ref: spanRef },\n tree.children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, false, matchLinks),\n ),\n );\n}\n\nexport function Match({ data, matchLinks, dispatch, nodeId }) {\n if (!data || Object.keys(data).length === 0) return;\n\n let tag = h(JSONView, { data });\n\n if (data.lith_id) {\n tag = h(DataField, {\n label: \"Lithology\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.lithology) {\n window.open(matchLinks.lithology + \"/\" + data.lith_id, \"_blank\");\n }\n },\n }),\n });\n }\n\n if (data.strat_name_id) {\n tag = h(\"div\", [\n h(DataField, {\n label: \"Stratigraphic name\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.strat_name_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.strat_name) {\n window.open(\n matchLinks.strat_name + \"/\" + data.strat_name_id,\n \"_blank\",\n );\n }\n },\n }),\n }),\n h.if(data.concept_id)(DataField, {\n label: \"Stratigraphic concept\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.concept_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.concept) {\n window.open(matchLinks.concept + \"/\" + data.concept_id, \"_blank\");\n }\n },\n }),\n }),\n ]);\n }\n\n if (data.lith_att_id) {\n tag = h(DataField, {\n label: \"Lithology attribute\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_att_id },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.lith_att) {\n window.open(matchLinks.lith_att + \"/\" + data.lith_att_id, \"_blank\");\n }\n },\n }),\n });\n }\n\n return h(\"div.match-container\", [\n tag,\n h(Icon, {\n icon: \"cross\",\n color: \"red\",\n className: \"close-btn\",\n onClick: () => {\n dispatch({ type: \"remove-match\", payload: { id: nodeId } });\n },\n }),\n ]);\n}\n"],"names":["$h8ona$macrostrathyper","useRef","$h8ona$useRef","useEffect","$h8ona$useEffect","Icon","$h8ona$Icon","JSONView","$h8ona$JSONView","DataField","$h8ona$DataField","LithologyTag","$h8ona$LithologyTag","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$9wFEx","$edvRb","$d6cf457c7790c03a$var$h","styled","a","__esModule","default","$d6cf457c7790c03a$export$6e107db9091b8219","props","text","selectedNodes","nodes","dispatch","allowOverlap","matchLinks","tabIndex","onKeyDown","e","key","type","payload","ids","$d6cf457c7790c03a$export$190465bec6b893be","allTags","$d6cf457c7790c03a$var$buildTags","highlights","tags","entities","Set","highlight","tag","has","highlighted","$d6cf457c7790c03a$var$isHighlighted","length","includes","parents","some","d","active","tagStyle","getTagStyle","backgroundColor","color","display","markStyle","push","add","buildHighlights","tree","$d6cf457c7790c03a$var$nestHighlights","events","pos","start","end","sort","b","root","children","textStart","stack","lastPos","parent","slice","newNode","pop","spanRef","handleMouseUp","$d6cf457c7790c03a$var$createTagFromSelection","container","selection","window","getSelection","isCollapsed","rangeCount","range","getRangeAt","contains","startContainer","endContainer","preRange","document","createRange","setStart","setEnd","startOffset","toString","selectedText","current","$d6cf457c7790c03a$var$addTag","test","trim","console","log","find","t","endsWith","inside","overlap","addEventListener","removeEventListener","ref","map","child","i","$d6cf457c7790c03a$var$renderNode","node","parentSelected","isSelected","showBorder","style","zIndex","border","margin","moveText","Object","prototype","hasOwnProperty","onMouseEnter","stopPropagation","className","onClick","ctrlKey","metaKey","shiftKey","flat","$d6cf457c7790c03a$export$f421feb8fad20413","data","nodeId","keys","lith_id","label","value","name","lithology","open","strat_name_id","strat_name","if","concept_id","concept","lith_att_id","lith_att","icon","FeedbackText","HighlightedText","Match"],"version":3,"file":"feedback-components.69d0ccd0.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import{useReducer as e,createContext as t,useContext as n}from"react";import r from"immutability-helper";var l,d=((l={}).Tree="tree",l.Graph="graph",l);function i(t,n){let r=n.values().next().value;return e(o,{initialTree:t,tree:t,selectedNodes:[],entityTypesMap:n,selectedEntityType:r,lastInternalId:0,isSelectingEntityType:!1,viewMode:"tree"})}let a=t(null);function s(){let e=n(a);if(null==e)throw Error("No dispatch context available");return e}function o(e,t){switch(t.type){case"add-entity-type":{let{name:n,description:r,color:l}=t.payload,d=e.lastInternalId-1,i={id:d,name:n,description:""===r?null:r,color:l},a=new Map(e.entityTypesMap);return a.set(d,i),{...e,entityTypesMap:a,selectedEntityType:i,lastInternalId:d}}case"update-entity-type":{let{id:n,name:r,description:l,color:d}=t.payload,i=new Map(e.entityTypesMap),a=i.get(n);if(!a)return console.warn(`Entity type with id ${n} not found`),e;let s={...a,name:r,description:""===l?null:l,color:d};i.set(n,s);let o=h(e.tree,a,s);return{...e,tree:o,entityTypesMap:i,selectedEntityType:s}}case"select-range":let n=t.payload.ids,l=n[0],d=n[1],i=function(e){let t=[];return!function e(n){for(let r of n)t.push(r),Array.isArray(r.children)&&r.children.length>0&&e(r.children)}(e),t.sort((e,t)=>e.indices[0]-t.indices[0])}(e.tree),a=i.findIndex(e=>e.id===l),s=i.findIndex(e=>e.id===d),o=i.slice(a,s+1);return console.log("Selecting range:",o),{...e,selectedNodes:o.map(e=>e.id)};case"move-node":let[y,g]=u(e.tree,t.payload.dragIds),m=[];t.payload.parentId&&(m=p(y,t.payload.parentId)).push("children");let $=c(m,{$splice:[[t.payload.index,0,...g]]});return{...e,tree:r(y,$)};case"delete-node":let[T,x]=u(e.tree,t.payload.ids),w=x.flatMap(e=>e.children??[]).filter(e=>!function e(t,n){for(let r of t)if(r.id==n)return!0;else if(r.children&&e(r.children,n))return!0;return!1}(T,e.id));return{...e,tree:[...T,...w],selectedNodes:e.selectedNodes.filter(e=>!t.payload.ids.includes(e))};case"select-node":let{ids:N}=t.payload,I=t.payload.ids.length>0?f(e.tree,N[0])?.type:null;return{...e,selectedNodes:N,selectedEntityType:I};case"toggle-node-selected":let M=t.payload.ids.filter(t=>!e.selectedNodes.includes(t)),b=e.selectedNodes.filter(e=>!t.payload.ids.includes(e)),v=t.payload.ids.length>0?f(e.tree,t.payload.ids[0])?.type:null;return{...e,selectedNodes:[...b,...M],selectedEntityType:v};case"create-node":let E=e.lastInternalId-1,{text:S,start:C,end:A}=t.payload,D={id:E,name:S,children:[],indices:[C,A],type:e.selectedEntityType};return{...e,tree:[...e.tree,D],selectedNodes:[E],lastInternalId:E};case"delete-entity-type":{let{id:n}=t.payload,r=new Map(e.entityTypesMap),l=r.get(n);r.delete(n);let d=r.values().next().value,i=h(e.tree,l,d);return{...e,tree:i,entityTypesMap:r,selectedNodes:[]}}case"add-match":{let{id:n}=t.payload,l=p(e.tree,n);if(!l)return console.warn(`Node with id ${n} not found`),e;let d=c(l,{match:{$set:t.payload.payload}}),i=r(e.tree,d);return{...e,tree:i}}case"remove-match":{let{id:n}=t.payload;console.log("Removing match for node with id:",n);let l=p(e.tree,n);if(!l)return console.warn(`Node with id ${n} not found`),e;let d=c(l,{match:{$set:null}}),i=r(e.tree,d);return{...e,tree:i}}case"toggle-entity-type-selector":return{...e,isSelectingEntityType:t.payload??!e.isSelectingEntityType};case"select-entity-type":{let n=e.tree;for(let l of e.selectedNodes)n=r(n,c(p(e.tree,l),{type:{$set:t.payload}}));return{...e,tree:n,selectedEntityType:t.payload}}case"deselect":return{...e,selectedNodes:[]};case"reset":return{...e,tree:e.initialTree,selectedNodes:[]};case"set-view-mode":return{...e,viewMode:t.payload}}}function c(e,t){let n=t;for(let t=e.length-1;t>=0;t--)n={[e[t]]:n};return n}function p(e,t){for(let n=0;n<e.length;n++)if(e[n].id==t)return[n];else if(e[n].children){let r=p(e[n].children,t);if(null!=r)return[n,"children",...r]}return null}function u(e,t){let n=[],r=[];for(let l of e)if(t.includes(l.id))r.push(l);else{if(l.children){let[e,n]=u(l.children,t);l={...l,children:e},r.push(...n)}n.push(l)}return[n,r]}function y(e){let t=[],n=[],r=new Map;for(let l of e){if(r.has(l.id))continue;let{indices:e,id:d,name:i,type:a,children:s}=l,o={id:d,type:a.id,color:a.color,name:i,txt_range:[e],reasoning:null,match:l.match,children:s};if(r.set(l.id,l),t.push(o),l.children){for(let e of l.children)n.push({source:l.id,dest:e.id});let{nodes:e,edges:r}=y(l.children);t.push(...e),n.push(...r)}}return{nodes:t,edges:n}}function f(e,t){for(let n of e){if(n.id===t)return n;if(n.children){let e=f(n.children,t);if(e)return e}}return null}function h(e,t,n){return e.map(e=>(function(e,t,n){let r=e.type.id===t.id?n:e.type;return{...e,type:r,children:e.children?h(e.children,t,n):[]}})(e,t,n))}export{d as ViewMode,i as useUpdatableTree,a as TreeDispatchContext,s as useTreeDispatch,f as findNodeById,y as treeToGraph};
2
- //# sourceMappingURL=feedback-components.a7b43cfa.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,O,c,C,C,iB,C,C,c,C,K,O,A,Q,M,qB,CCKO,IAAK,EAAA,G,CAAA,E,C,G,I,C,O,E,K,C,QAAA,GAmDL,SAAS,EACd,CAAuB,CACvB,CAAoC,EAIpC,IAAM,EAAO,EAAY,MAAM,GAAG,IAAI,GAAG,KAAK,CAE9C,OAAO,AAAA,EAAW,EAAa,CAC7B,YAAA,EACA,KAAM,EACN,cAAe,EAAE,CACjB,eAAgB,EAChB,mBAAoB,EACpB,eAAgB,EAChB,sBAAuB,CAAA,EACvB,SAAA,MACF,EACF,CAEO,IAAM,EAAsB,AAAA,EAAmC,MAE/D,SAAS,IACd,IAAM,EAAW,AAAA,EAAW,GAC5B,GAAI,AAAY,MAAZ,EACF,MAAM,AAAI,MAAM,iCAElB,OAAO,CACT,CAEA,SAAS,EAAY,CAAgB,CAAE,CAAkB,EACvD,OAAQ,EAAO,IAAI,EACjB,IAAK,kBAAmB,CAEtB,GAAM,CAAA,KAAE,CAAI,CAAA,YAAE,CAAW,CAAA,MAAE,CAAK,CAAE,CAAG,EAAO,OAAO,CAC7C,EAAQ,EAAM,cAAc,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a,EAAK,QAAQ,CAAE,GAC1C,GAAI,EAAO,OAAO,CACpB,CACF,CACA,OAAO,IACT,CAEA,SAAS,EAAgB,CAAI,CAAE,CAAO,CAAE,CAAW,EACjD,OAAO,EAAK,GAAG,CAAC,AAAC,GAAS,AAG5B,CAAA,SAAwB,CAAI,CAAE,CAAO,CAAE,CAAW,EAChD,IAAM,EAAO,EAAK,IAAI,CAAC,EAAE,GAAK,EAAQ,EAAE,CAAG,EAAc,EAAK,IAAI,CAElE,MAAO,CACL,GAAG,CAAI,CACP,KAAA,EACA,SAAU,EAAK,QAAQ,CACnB,EAAgB,EAAK,QAAQ,CAAE,EAAS,GACxC,EAAE,AACR,CACF,CAAA,EAb2C,EAAM,EAAS,GAC1D,Q,K,Q,C,K,gB,C,K,mB,C,K,e,C,K,Y,C,K,W","sources":["<anon>","packages/feedback-components/src/feedback/edit-state.ts"],"sourcesContent":["import {useReducer as $eGztG$useReducer, createContext as $eGztG$createContext, useContext as $eGztG$useContext} from \"react\";\nimport $eGztG$immutabilityhelper from \"immutability-helper\";\n\n\n\nvar $330ae695507d96f5$export$53ec42062883b2d4 = /*#__PURE__*/ function(ViewMode) {\n ViewMode[\"Tree\"] = \"tree\";\n ViewMode[\"Graph\"] = \"graph\";\n return ViewMode;\n}({});\nfunction $330ae695507d96f5$export$911bb4b9c8065d3d(initialTree, entityTypes) {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n return (0, $eGztG$useReducer)($330ae695507d96f5$var$treeReducer, {\n initialTree: initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: \"tree\"\n });\n}\nconst $330ae695507d96f5$export$e5ce04c5b3f58533 = (0, $eGztG$createContext)(null);\nfunction $330ae695507d96f5$export$e1068f2d1c68f87e() {\n const dispatch = (0, $eGztG$useContext)($330ae695507d96f5$export$e5ce04c5b3f58533);\n if (dispatch == null) throw new Error(\"No dispatch context available\");\n return dispatch;\n}\nfunction $330ae695507d96f5$var$treeReducer(state, action) {\n switch(action.type){\n case \"add-entity-type\":\n {\n // Add a new entity type to the map\n const { name: name, description: description, color: color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType = {\n id: newId,\n name: name,\n description: description === \"\" ? null : description,\n color: color\n };\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId\n };\n }\n case \"update-entity-type\":\n {\n // Update an existing entity type in the map\n const { id: id, name: name, description: description, color: color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n const updatedType = {\n ...oldType,\n name: name,\n description: description === \"\" ? null : description,\n color: color\n };\n newEntityTypesMap.set(id, updatedType);\n // Update the tree to reflect the new type\n const newTree = $330ae695507d96f5$var$updateTreeTypes(state.tree, oldType, updatedType);\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n // make list of nodes in order\n const allNodes = $330ae695507d96f5$var$flattenAndSort(state.tree);\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node)=>node.id === node1);\n const endIndex = allNodes.findIndex((node)=>node.id === node2);\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node)=>node.id)\n };\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.dragIds);\n let keyPath = [];\n if (action.payload.parentId) {\n keyPath = $330ae695507d96f5$var$findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n // Add removed nodes to the new tree at the correct location\n let updateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n $splice: [\n [\n action.payload.index,\n 0,\n ...removedNodes\n ]\n ]\n });\n return {\n ...state,\n tree: (0, $eGztG$immutabilityhelper)(newTree, updateSpec)\n };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.ids);\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n const children = _removedNodes.flatMap((node)=>node.children ?? []).filter((child)=>!$330ae695507d96f5$var$nodeIsInTree(newTree2, child.id));\n // Reset the selection\n return {\n ...state,\n tree: [\n ...newTree2,\n ...children\n ],\n selectedNodes: state.selectedNodes.filter((id)=>!action.payload.ids.includes(id))\n };\n case \"select-node\":\n const { ids: ids } = action.payload;\n const type = action.payload.ids.length > 0 ? $330ae695507d96f5$export$e64eb58334357825(state.tree, ids[0])?.type : null;\n return {\n ...state,\n selectedNodes: ids,\n selectedEntityType: type\n };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter((id)=>!state.selectedNodes.includes(id));\n const nodesToKeep = state.selectedNodes.filter((id)=>!action.payload.ids.includes(id));\n const newType = action.payload.ids.length > 0 ? $330ae695507d96f5$export$e64eb58334357825(state.tree, action.payload.ids[0])?.type : null;\n return {\n ...state,\n selectedNodes: [\n ...nodesToKeep,\n ...nodesToAdd\n ],\n selectedEntityType: newType\n };\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text: text, start: start, end: end } = action.payload;\n const node = {\n id: newId,\n name: text,\n children: [],\n indices: [\n start,\n end\n ],\n type: state.selectedEntityType\n };\n return {\n ...state,\n tree: [\n ...state.tree,\n node\n ],\n selectedNodes: [\n newId\n ],\n lastInternalId: newId\n };\n case \"delete-entity-type\":\n {\n // Remove the entity type from the map\n const { id: id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = $330ae695507d96f5$var$updateTreeTypes(state.tree, oldType, defaultType);\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: []\n };\n }\n case \"add-match\":\n {\n const { id: id } = action.payload;\n // Find the node path\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n // Build update spec to set the `match` property\n const matchUpdateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n match: {\n $set: action.payload.payload\n }\n });\n const updatedTree = (0, $eGztG$immutabilityhelper)(state.tree, matchUpdateSpec);\n return {\n ...state,\n tree: updatedTree\n };\n }\n case \"remove-match\":\n {\n const { id: id } = action.payload;\n console.log(\"Removing match for node with id:\", id);\n // Find the node path\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n // Build update spec to unset the `match` property\n const matchUpdateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n match: {\n $set: null\n }\n });\n const updatedTree = (0, $eGztG$immutabilityhelper)(state.tree, matchUpdateSpec);\n return {\n ...state,\n tree: updatedTree\n };\n }\n /** Entity type selection */ case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType\n };\n case \"select-entity-type\":\n {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes){\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n const nestedSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n type: {\n $set: action.payload\n }\n });\n newTree2 = (0, $eGztG$immutabilityhelper)(newTree2, nestedSpec);\n }\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload\n };\n }\n case \"deselect\":\n return {\n ...state,\n selectedNodes: []\n };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: []\n };\n case \"set-view-mode\":\n return {\n ...state,\n viewMode: action.payload\n };\n }\n}\nfunction $330ae695507d96f5$var$nodeIsInTree(tree, id) {\n for (let node of tree){\n if (node.id == id) return true;\n else if (node.children) {\n if ($330ae695507d96f5$var$nodeIsInTree(node.children, id)) return true;\n }\n }\n return false;\n}\nfunction $330ae695507d96f5$var$buildNestedSpec(keyPath, innerSpec) {\n // Build a nested object from a key path\n let spec = innerSpec;\n for(let i = keyPath.length - 1; i >= 0; i--)spec = {\n [keyPath[i]]: spec\n };\n return spec;\n// Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\nfunction $330ae695507d96f5$var$findNode(tree, id) {\n // Find the index of the node with the given id in the tree, returning the key path\n for(let i = 0; i < tree.length; i++){\n if (tree[i].id == id) return [\n i\n ];\n else if (tree[i].children) {\n let path = $330ae695507d96f5$var$findNode(tree[i].children, id);\n if (path != null) return [\n i,\n \"children\",\n ...path\n ];\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$removeNodes(tree, ids) {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */ let newTree = [];\n let removedNodes = [];\n for (let node of tree)if (ids.includes(node.id)) removedNodes.push(node);\n else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = $330ae695507d96f5$var$removeNodes(node.children, ids);\n node = {\n ...node,\n children: newChildren\n };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n return [\n newTree,\n removedNodes\n ];\n}\nfunction $330ae695507d96f5$export$8d9dbb7a64bf2a5e(tree) {\n // Convert the tree to a graph\n let nodes = [];\n let edges = [];\n const nodeMap = new Map();\n for (let node of tree){\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) continue;\n const { indices: indices, id: id, name: name, type: type, children: children } = node;\n const nodeData = {\n id: id,\n type: type.id,\n color: type.color,\n name: name,\n txt_range: [\n indices\n ],\n reasoning: null,\n match: node.match,\n children: children\n };\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n if (node.children) {\n for (let child of node.children)edges.push({\n source: node.id,\n dest: child.id\n });\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = $330ae695507d96f5$export$8d9dbb7a64bf2a5e(node.children);\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n return {\n nodes: nodes,\n edges: edges\n };\n}\nfunction $330ae695507d96f5$export$e64eb58334357825(tree, id) {\n for (const node of tree){\n if (node.id === id) return node;\n if (node.children) {\n const found = $330ae695507d96f5$export$e64eb58334357825(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node)=>$330ae695507d96f5$var$updateNodeType(node, oldType, defaultType));\n}\nfunction $330ae695507d96f5$var$updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n return {\n ...node,\n type: type,\n children: node.children ? $330ae695507d96f5$var$updateTreeTypes(node.children, oldType, defaultType) : []\n };\n}\nfunction $330ae695507d96f5$var$flattenAndSort(nodes) {\n const result = [];\n function traverse(nodeList) {\n for (const node of nodeList){\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) traverse(node.children);\n }\n }\n traverse(nodes);\n // sort by start\n return result.sort((a, b)=>a.indices[0] - b.indices[0]);\n}\n\n\nexport {$330ae695507d96f5$export$53ec42062883b2d4 as ViewMode, $330ae695507d96f5$export$911bb4b9c8065d3d as useUpdatableTree, $330ae695507d96f5$export$e5ce04c5b3f58533 as TreeDispatchContext, $330ae695507d96f5$export$e1068f2d1c68f87e as useTreeDispatch, $330ae695507d96f5$export$e64eb58334357825 as findNodeById, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=feedback-components.a7b43cfa.js.map\n","import { TreeData } from \"./types\";\nimport { createContext, Dispatch, useContext, useReducer } from \"react\";\nimport update, { Spec } from \"immutability-helper\";\nimport { EntityType } from \"../extractions/types\";\n\nexport enum ViewMode {\n Tree = \"tree\",\n Graph = \"graph\",\n}\n\ninterface TreeState {\n initialTree: TreeData[];\n tree: TreeData[];\n selectedNodes: number[];\n entityTypesMap: Map<number, EntityType>;\n selectedEntityType: EntityType;\n lastInternalId: number;\n isSelectingEntityType: boolean;\n viewMode: ViewMode;\n}\n\ntype TextRange = {\n start: number;\n end: number;\n text: string;\n};\n\ntype TreeAction =\n | {\n type: \"move-node\";\n payload: { dragIds: number[]; parentId: number; index: number };\n }\n | { type: \"delete-node\"; payload: { ids: number[] } }\n | { type: \"select-node\"; payload: { ids: number[] } }\n | { type: \"toggle-node-selected\"; payload: { ids: number[] } }\n | { type: \"set-view-mode\"; payload: ViewMode }\n | { type: \"create-node\"; payload: TextRange }\n | { type: \"select-entity-type\"; payload: EntityType }\n | { type: \"toggle-entity-type-selector\"; payload?: boolean | null }\n | { type: \"deselect\" }\n | { type: \"reset\" }\n | { type: \"delete-entity-type\"; payload: { id: number } }\n | {\n type: \"add-entity-type\";\n payload: { name: string; description: string; color: string };\n }\n | {\n type: \"update-entity-type\";\n payload: { id: number; name: string; description: string; color: string };\n }\n | { type: \"select-range\"; payload: { ids: number[] } }\n | { type: \"add-match\"; payload: { id: number; payload: any } }\n | { type: \"remove-match\"; payload: { id: number } };\n\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>,\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n\n return useReducer(treeReducer, {\n initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: ViewMode.Tree,\n });\n}\n\nexport const TreeDispatchContext = createContext<TreeDispatch | null>(null);\n\nexport function useTreeDispatch() {\n const dispatch = useContext(TreeDispatchContext);\n if (dispatch == null) {\n throw new Error(\"No dispatch context available\");\n }\n return dispatch;\n}\n\nfunction treeReducer(state: TreeState, action: TreeAction) {\n switch (action.type) {\n case \"add-entity-type\": {\n // Add a new entity type to the map\n const { name, description, color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType: EntityType = {\n id: newId,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId,\n };\n }\n case \"update-entity-type\": {\n // Update an existing entity type in the map\n const { id, name, description, color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n\n const updatedType: EntityType = {\n ...oldType,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n newEntityTypesMap.set(id, updatedType);\n\n // Update the tree to reflect the new type\n const newTree = updateTreeTypes(state.tree, oldType, updatedType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType,\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n\n // make list of nodes in order\n const allNodes = flattenAndSort(state.tree);\n\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node) => node.id === node1);\n const endIndex = allNodes.findIndex((node) => node.id === node2);\n\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node) => node.id),\n };\n\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = removeNodes(\n state.tree,\n action.payload.dragIds,\n );\n\n let keyPath: (number | \"children\")[] = [];\n if (action.payload.parentId) {\n keyPath = findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n\n // Add removed nodes to the new tree at the correct location\n let updateSpec = buildNestedSpec(keyPath, {\n $splice: [[action.payload.index, 0, ...removedNodes]],\n });\n\n return { ...state, tree: update(newTree, updateSpec) };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = removeNodes(\n state.tree,\n action.payload.ids,\n );\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n\n const children = _removedNodes\n .flatMap((node) => node.children ?? [])\n .filter((child) => !nodeIsInTree(newTree2, child.id));\n\n // Reset the selection\n\n return {\n ...state,\n tree: [...newTree2, ...children],\n selectedNodes: state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n ),\n };\n case \"select-node\":\n const { ids } = action.payload;\n\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter(\n (id) => !state.selectedNodes.includes(id),\n );\n const nodesToKeep = state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n );\n\n const newType =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, action.payload.ids[0])?.type\n : null;\n\n return {\n ...state,\n selectedNodes: [...nodesToKeep, ...nodesToAdd],\n selectedEntityType: newType,\n };\n\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text, start, end } = action.payload;\n const node: TreeData = {\n id: newId,\n name: text,\n children: [],\n indices: [start, end],\n type: state.selectedEntityType,\n };\n\n return {\n ...state,\n tree: [...state.tree, node],\n selectedNodes: [newId],\n lastInternalId: newId,\n };\n\n case \"delete-entity-type\": {\n // Remove the entity type from the map\n const { id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = updateTreeTypes(state.tree, oldType, defaultType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: [],\n };\n }\n\n case \"add-match\": {\n const { id } = action.payload;\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to set the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: action.payload.payload },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n case \"remove-match\": {\n const { id } = action.payload;\n\n console.log(\"Removing match for node with id:\", id);\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to unset the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: null },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n /** Entity type selection */\n case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType,\n };\n case \"select-entity-type\": {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes) {\n const keyPath = findNode(state.tree, id);\n const nestedSpec = buildNestedSpec(keyPath, {\n type: { $set: action.payload },\n });\n newTree2 = update(newTree2, nestedSpec);\n }\n\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload,\n };\n }\n case \"deselect\":\n return { ...state, selectedNodes: [] };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: [],\n };\n case \"set-view-mode\":\n return { ...state, viewMode: action.payload };\n }\n}\n\nfunction nodeIsInTree(tree: TreeData[], id: number): boolean {\n for (let node of tree) {\n if (node.id == id) {\n return true;\n } else if (node.children) {\n if (nodeIsInTree(node.children, id)) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction buildNestedSpec(\n keyPath: (number | \"children\")[],\n innerSpec: Spec<any>,\n): Spec<TreeData[]> {\n // Build a nested object from a key path\n\n let spec = innerSpec;\n for (let i = keyPath.length - 1; i >= 0; i--) {\n spec = { [keyPath[i]]: spec };\n }\n return spec as any;\n // Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\n\nfunction findNode(\n tree: TreeData[],\n id: number,\n): (number | \"children\")[] | null {\n // Find the index of the node with the given id in the tree, returning the key path\n for (let i = 0; i < tree.length; i++) {\n if (tree[i].id == id) {\n return [i];\n } else if (tree[i].children) {\n let path = findNode(tree[i].children, id);\n if (path != null) {\n return [i, \"children\", ...path];\n }\n }\n }\n return null;\n}\n\nfunction removeNodes(\n tree: TreeData[],\n ids: number[],\n): [TreeData[], TreeData[]] {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */\n let newTree: TreeData[] = [];\n let removedNodes: TreeData[] = [];\n\n for (let node of tree) {\n if (ids.includes(node.id)) {\n removedNodes.push(node);\n } else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = removeNodes(node.children, ids);\n node = { ...node, children: newChildren };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n }\n\n return [newTree, removedNodes];\n}\n\nexport interface EntityOutput {\n id: number;\n type: number | null;\n txt_range: number[][];\n name: string;\n match: any | null;\n reasoning: string | null;\n color: string | null;\n children: any[] | null;\n}\n\nexport interface GraphData {\n nodes: EntityOutput[];\n edges: { source: number; dest: number }[];\n}\n\nexport function treeToGraph(tree: TreeData[]): GraphData {\n // Convert the tree to a graph\n let nodes: EntityOutput[] = [];\n let edges: { source: number; dest: number }[] = [];\n const nodeMap = new Map<number, TreeData>();\n\n for (let node of tree) {\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) {\n continue;\n }\n\n const { indices, id, name, type, children } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: type.id,\n color: type.color,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\n children,\n };\n\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n\n if (node.children) {\n for (let child of node.children) {\n edges.push({ source: node.id, dest: child.id });\n }\n\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = treeToGraph(\n node.children,\n );\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n\n return { nodes, edges };\n}\n\nexport function findNodeById(tree, id) {\n for (const node of tree) {\n if (node.id === id) {\n return node;\n }\n if (node.children) {\n const found = findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\n\nfunction updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node) => updateNodeType(node, oldType, defaultType));\n}\n\nfunction updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n\n return {\n ...node,\n type,\n children: node.children\n ? updateTreeTypes(node.children, oldType, defaultType)\n : [],\n };\n}\n\nfunction flattenAndSort(nodes) {\n const result = [];\n\n function traverse(nodeList) {\n for (const node of nodeList) {\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) {\n traverse(node.children);\n }\n }\n }\n\n traverse(nodes);\n\n // sort by start\n return result.sort((a, b) => a.indices[0] - b.indices[0]);\n}\n"],"names":["useReducer","$eGztG$useReducer","createContext","$eGztG$createContext","useContext","$eGztG$useContext","$eGztG$immutabilityhelper","ViewMode","$330ae695507d96f5$export$53ec42062883b2d4","$330ae695507d96f5$export$911bb4b9c8065d3d","initialTree","entityTypes","type","values","next","value","$330ae695507d96f5$var$treeReducer","tree","selectedNodes","entityTypesMap","selectedEntityType","lastInternalId","isSelectingEntityType","viewMode","$330ae695507d96f5$export$e5ce04c5b3f58533","$330ae695507d96f5$export$e1068f2d1c68f87e","dispatch","Error","state","action","name","description","color","payload","newId","newType","id","newEntityTypesMap","Map","set","oldType","get","console","warn","updatedType","newTree","$330ae695507d96f5$var$updateTreeTypes","payloadIds","ids","node1","node2","allNodes","$330ae695507d96f5$var$flattenAndSort","nodes","result","traverse","nodeList","node","push","Array","isArray","children","length","sort","a","b","indices","startIndex","findIndex","endIndex","slice","log","map","removedNodes","$330ae695507d96f5$var$removeNodes","dragIds","keyPath","parentId","$330ae695507d96f5$var$findNode","updateSpec","$330ae695507d96f5$var$buildNestedSpec","$splice","index","newTree2","_removedNodes","flatMap","filter","child","$330ae695507d96f5$var$nodeIsInTree","includes","$330ae695507d96f5$export$e64eb58334357825","nodesToAdd","nodesToKeep","text","start","end","delete","defaultType","matchUpdateSpec","match","$set","updatedTree","innerSpec","spec","i","path","newChildren","removedChildren","$330ae695507d96f5$export$8d9dbb7a64bf2a5e","edges","nodeMap","has","nodeData","txt_range","reasoning","source","dest","childNodes","childEdges","found","$330ae695507d96f5$var$updateNodeType","useUpdatableTree","TreeDispatchContext","useTreeDispatch","findNodeById","treeToGraph"],"version":3,"file":"feedback-components.a7b43cfa.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- function e(e,t,o,n){Object.defineProperty(e,t,{get:o,set:n,enumerable:!0,configurable:!0})}var t,o,n,a,c,r,p,i,l,Q,W,X,_,d,s,y,f,b,g,m,h,k,u,x,v,w,$,j={};e(j,"add-type",()=>t,e=>t=e),e(j,"add-type-overlay",()=>o,e=>o=e),e(j,"close-btn",()=>n,e=>n=e),e(j,"control-content",()=>a,e=>a=e),e(j,"control-panel",()=>c,e=>c=e),e(j,"description",()=>r,e=>r=e),e(j,"entity-panel",()=>p,e=>p=e),e(j,"feedback-component",()=>i,e=>i=e),e(j,"feedback-container",()=>l,e=>l=e),e(j,"feedback-text",()=>Q,e=>Q=e),e(j,"feedback-text-wrapper",()=>W,e=>W=e),e(j,"form-group",()=>X,e=>X=e),e(j,"highlight",()=>_,e=>_=e),e(j,"icons",()=>d,e=>d=e),e(j,"match-container",()=>s,e=>s=e),e(j,"match-item",()=>y,e=>y=e),e(j,"node",()=>f,e=>f=e),e(j,"node-label",()=>b,e=>b=e),e(j,"overlay-container",()=>g,e=>g=e),e(j,"page-wrapper",()=>m,e=>m=e),e(j,"selected",()=>h,e=>h=e),e(j,"selection-tree",()=>k,e=>k=e),e(j,"text-inputs",()=>u,e=>u=e),e(j,"title",()=>x,e=>x=e),e(j,"type-container",()=>v,e=>v=e),e(j,"type-list",()=>w,e=>w=e),e(j,"type-tag",()=>$,e=>$=e),t="QoX8-W_add-type",o="QoX8-W_add-type-overlay",n="QoX8-W_close-btn",a="QoX8-W_control-content",c="QoX8-W_control-panel",r="QoX8-W_description",p="QoX8-W_entity-panel",i="QoX8-W_feedback-component",l="QoX8-W_feedback-container",Q="QoX8-W_feedback-text",W="QoX8-W_feedback-text-wrapper",X="QoX8-W_form-group",_="QoX8-W_highlight",d="QoX8-W_icons",s="QoX8-W_match-container",y="QoX8-W_match-item",f="QoX8-W_node",b="QoX8-W_node-label",g="QoX8-W_overlay-container",m="QoX8-W_page-wrapper",h="QoX8-W_selected",k="QoX8-W_selection-tree",u="QoX8-W_text-inputs",x="QoX8-W_title",v="QoX8-W_type-container",w="QoX8-W_type-list",$="QoX8-W_type-tag";export{j as default};
2
- //# sourceMappingURL=feedback-components.b9317f9c.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,S,E,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,ICAA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,E,E,C,E,E,E,W,I,E,A,G,E,G,E,E,mB,I,E,A,G,E,G,E,E,Y,I,E,A,G,E,G,E,E,kB,I,E,A,G,E,G,E,E,gB,I,E,A,G,E,G,E,E,c,I,E,A,G,E,G,E,E,e,I,E,A,G,E,G,E,E,qB,I,E,A,G,E,G,E,E,qB,I,E,A,G,E,G,E,E,gB,I,E,A,G,E,G,E,E,wB,I,E,A,G,E,G,E,E,a,I,E,A,G,E,G,E,E,Y,I,E,A,G,E,G,E,E,Q,I,E,A,G,E,G,E,E,kB,I,E,A,G,E,G,E,E,a,I,E,A,G,E,G,E,E,O,I,E,A,G,E,G,E,E,a,I,E,A,G,E,G,E,E,oB,I,E,A,G,E,G,E,E,e,I,E,A,G,E,G,E,E,W,I,E,A,G,E,G,E,E,iB,I,E,A,G,E,G,E,E,c,I,E,A,G,E,G,E,E,Q,I,E,A,G,E,G,E,E,iB,I,E,A,G,E,G,E,E,Y,I,E,A,G,E,G,E,E,W,I,E,A,G,E,GA1BA,EAA6B,kBAC7B,EAAqC,0BACrC,EAA8B,mBAC9B,EAAoC,yBACpC,EAAkC,uBAClC,EAAgC,qBAChC,EAAiC,sBACjC,EAAuC,4BACvC,EAAuC,4BACvC,EAAkC,uBAClC,EAA0C,+BAC1C,EAA+B,oBAC/B,EAA8B,mBAC9B,EAA0B,eAC1B,EAAoC,yBACpC,EAA+B,oBAC/B,EAAyB,cACzB,EAA+B,oBAC/B,EAAsC,2BACtC,EAAiC,sBACjC,EAA6B,kBAC7B,EAAmC,wBACnC,EAAgC,qBAChC,EAA0B,eAC1B,EAAmC,wBACnC,EAA8B,mBAC9B,EAA6B,yB,K,O","sources":["<anon>","packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":["\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\nvar $01ca2f1f49a3a114$exports = {};\n\n$parcel$export($01ca2f1f49a3a114$exports, \"add-type\", () => $01ca2f1f49a3a114$export$cb889aaddfa2926c, (v) => $01ca2f1f49a3a114$export$cb889aaddfa2926c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"add-type-overlay\", () => $01ca2f1f49a3a114$export$5f8f750fd71deeed, (v) => $01ca2f1f49a3a114$export$5f8f750fd71deeed = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"close-btn\", () => $01ca2f1f49a3a114$export$f5032a039312e50b, (v) => $01ca2f1f49a3a114$export$f5032a039312e50b = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"control-content\", () => $01ca2f1f49a3a114$export$42e8b5293e69631e, (v) => $01ca2f1f49a3a114$export$42e8b5293e69631e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"control-panel\", () => $01ca2f1f49a3a114$export$a0a23f31d5562853, (v) => $01ca2f1f49a3a114$export$a0a23f31d5562853 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"description\", () => $01ca2f1f49a3a114$export$6d59db4903f20f7d, (v) => $01ca2f1f49a3a114$export$6d59db4903f20f7d = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"entity-panel\", () => $01ca2f1f49a3a114$export$38f2cd12e45697e, (v) => $01ca2f1f49a3a114$export$38f2cd12e45697e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-component\", () => $01ca2f1f49a3a114$export$579bd45c78bf5510, (v) => $01ca2f1f49a3a114$export$579bd45c78bf5510 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-container\", () => $01ca2f1f49a3a114$export$23889d205b405f6e, (v) => $01ca2f1f49a3a114$export$23889d205b405f6e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-text\", () => $01ca2f1f49a3a114$export$890489be1870bed5, (v) => $01ca2f1f49a3a114$export$890489be1870bed5 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-text-wrapper\", () => $01ca2f1f49a3a114$export$6bd0fd0a746c88f, (v) => $01ca2f1f49a3a114$export$6bd0fd0a746c88f = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"form-group\", () => $01ca2f1f49a3a114$export$55a1f87a143fb302, (v) => $01ca2f1f49a3a114$export$55a1f87a143fb302 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"highlight\", () => $01ca2f1f49a3a114$export$e4043f67d36cbb26, (v) => $01ca2f1f49a3a114$export$e4043f67d36cbb26 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"icons\", () => $01ca2f1f49a3a114$export$df03f54e09e486fa, (v) => $01ca2f1f49a3a114$export$df03f54e09e486fa = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"match-container\", () => $01ca2f1f49a3a114$export$864d1dadc1dd3f57, (v) => $01ca2f1f49a3a114$export$864d1dadc1dd3f57 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"match-item\", () => $01ca2f1f49a3a114$export$a7bcc8ced81f8d07, (v) => $01ca2f1f49a3a114$export$a7bcc8ced81f8d07 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"node\", () => $01ca2f1f49a3a114$export$35059013cd4a06db, (v) => $01ca2f1f49a3a114$export$35059013cd4a06db = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"node-label\", () => $01ca2f1f49a3a114$export$75d14899fb692bb6, (v) => $01ca2f1f49a3a114$export$75d14899fb692bb6 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"overlay-container\", () => $01ca2f1f49a3a114$export$6a1093e41947f68e, (v) => $01ca2f1f49a3a114$export$6a1093e41947f68e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"page-wrapper\", () => $01ca2f1f49a3a114$export$7c414e944018fb15, (v) => $01ca2f1f49a3a114$export$7c414e944018fb15 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"selected\", () => $01ca2f1f49a3a114$export$d90250155de6d7e7, (v) => $01ca2f1f49a3a114$export$d90250155de6d7e7 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"selection-tree\", () => $01ca2f1f49a3a114$export$3ae1b51693c80a9c, (v) => $01ca2f1f49a3a114$export$3ae1b51693c80a9c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"text-inputs\", () => $01ca2f1f49a3a114$export$bc7581b048bdc9d, (v) => $01ca2f1f49a3a114$export$bc7581b048bdc9d = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"title\", () => $01ca2f1f49a3a114$export$fb184b623420d9be, (v) => $01ca2f1f49a3a114$export$fb184b623420d9be = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-container\", () => $01ca2f1f49a3a114$export$b2d17fca990bb66c, (v) => $01ca2f1f49a3a114$export$b2d17fca990bb66c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-list\", () => $01ca2f1f49a3a114$export$915fe2ca68846e4c, (v) => $01ca2f1f49a3a114$export$915fe2ca68846e4c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-tag\", () => $01ca2f1f49a3a114$export$5e5acbc770fb0e4, (v) => $01ca2f1f49a3a114$export$5e5acbc770fb0e4 = v);\nvar $01ca2f1f49a3a114$export$cb889aaddfa2926c;\nvar $01ca2f1f49a3a114$export$5f8f750fd71deeed;\nvar $01ca2f1f49a3a114$export$f5032a039312e50b;\nvar $01ca2f1f49a3a114$export$42e8b5293e69631e;\nvar $01ca2f1f49a3a114$export$a0a23f31d5562853;\nvar $01ca2f1f49a3a114$export$6d59db4903f20f7d;\nvar $01ca2f1f49a3a114$export$38f2cd12e45697e;\nvar $01ca2f1f49a3a114$export$579bd45c78bf5510;\nvar $01ca2f1f49a3a114$export$23889d205b405f6e;\nvar $01ca2f1f49a3a114$export$890489be1870bed5;\nvar $01ca2f1f49a3a114$export$6bd0fd0a746c88f;\nvar $01ca2f1f49a3a114$export$55a1f87a143fb302;\nvar $01ca2f1f49a3a114$export$e4043f67d36cbb26;\nvar $01ca2f1f49a3a114$export$df03f54e09e486fa;\nvar $01ca2f1f49a3a114$export$864d1dadc1dd3f57;\nvar $01ca2f1f49a3a114$export$a7bcc8ced81f8d07;\nvar $01ca2f1f49a3a114$export$35059013cd4a06db;\nvar $01ca2f1f49a3a114$export$75d14899fb692bb6;\nvar $01ca2f1f49a3a114$export$6a1093e41947f68e;\nvar $01ca2f1f49a3a114$export$7c414e944018fb15;\nvar $01ca2f1f49a3a114$export$d90250155de6d7e7;\nvar $01ca2f1f49a3a114$export$3ae1b51693c80a9c;\nvar $01ca2f1f49a3a114$export$bc7581b048bdc9d;\nvar $01ca2f1f49a3a114$export$fb184b623420d9be;\nvar $01ca2f1f49a3a114$export$b2d17fca990bb66c;\nvar $01ca2f1f49a3a114$export$915fe2ca68846e4c;\nvar $01ca2f1f49a3a114$export$5e5acbc770fb0e4;\n$01ca2f1f49a3a114$export$cb889aaddfa2926c = `QoX8-W_add-type`;\n$01ca2f1f49a3a114$export$5f8f750fd71deeed = `QoX8-W_add-type-overlay`;\n$01ca2f1f49a3a114$export$f5032a039312e50b = `QoX8-W_close-btn`;\n$01ca2f1f49a3a114$export$42e8b5293e69631e = `QoX8-W_control-content`;\n$01ca2f1f49a3a114$export$a0a23f31d5562853 = `QoX8-W_control-panel`;\n$01ca2f1f49a3a114$export$6d59db4903f20f7d = `QoX8-W_description`;\n$01ca2f1f49a3a114$export$38f2cd12e45697e = `QoX8-W_entity-panel`;\n$01ca2f1f49a3a114$export$579bd45c78bf5510 = `QoX8-W_feedback-component`;\n$01ca2f1f49a3a114$export$23889d205b405f6e = `QoX8-W_feedback-container`;\n$01ca2f1f49a3a114$export$890489be1870bed5 = `QoX8-W_feedback-text`;\n$01ca2f1f49a3a114$export$6bd0fd0a746c88f = `QoX8-W_feedback-text-wrapper`;\n$01ca2f1f49a3a114$export$55a1f87a143fb302 = `QoX8-W_form-group`;\n$01ca2f1f49a3a114$export$e4043f67d36cbb26 = `QoX8-W_highlight`;\n$01ca2f1f49a3a114$export$df03f54e09e486fa = `QoX8-W_icons`;\n$01ca2f1f49a3a114$export$864d1dadc1dd3f57 = `QoX8-W_match-container`;\n$01ca2f1f49a3a114$export$a7bcc8ced81f8d07 = `QoX8-W_match-item`;\n$01ca2f1f49a3a114$export$35059013cd4a06db = `QoX8-W_node`;\n$01ca2f1f49a3a114$export$75d14899fb692bb6 = `QoX8-W_node-label`;\n$01ca2f1f49a3a114$export$6a1093e41947f68e = `QoX8-W_overlay-container`;\n$01ca2f1f49a3a114$export$7c414e944018fb15 = `QoX8-W_page-wrapper`;\n$01ca2f1f49a3a114$export$d90250155de6d7e7 = `QoX8-W_selected`;\n$01ca2f1f49a3a114$export$3ae1b51693c80a9c = `QoX8-W_selection-tree`;\n$01ca2f1f49a3a114$export$bc7581b048bdc9d = `QoX8-W_text-inputs`;\n$01ca2f1f49a3a114$export$fb184b623420d9be = `QoX8-W_title`;\n$01ca2f1f49a3a114$export$b2d17fca990bb66c = `QoX8-W_type-container`;\n$01ca2f1f49a3a114$export$915fe2ca68846e4c = `QoX8-W_type-list`;\n$01ca2f1f49a3a114$export$5e5acbc770fb0e4 = `QoX8-W_type-tag`;\n\n\nexport {$01ca2f1f49a3a114$exports as default};\n//# sourceMappingURL=feedback-components.b9317f9c.js.map\n",null],"names":["$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$01ca2f1f49a3a114$export$cb889aaddfa2926c","$01ca2f1f49a3a114$export$5f8f750fd71deeed","$01ca2f1f49a3a114$export$f5032a039312e50b","$01ca2f1f49a3a114$export$42e8b5293e69631e","$01ca2f1f49a3a114$export$a0a23f31d5562853","$01ca2f1f49a3a114$export$6d59db4903f20f7d","$01ca2f1f49a3a114$export$38f2cd12e45697e","$01ca2f1f49a3a114$export$579bd45c78bf5510","$01ca2f1f49a3a114$export$23889d205b405f6e","$01ca2f1f49a3a114$export$890489be1870bed5","$01ca2f1f49a3a114$export$6bd0fd0a746c88f","$01ca2f1f49a3a114$export$55a1f87a143fb302","$01ca2f1f49a3a114$export$e4043f67d36cbb26","$01ca2f1f49a3a114$export$df03f54e09e486fa","$01ca2f1f49a3a114$export$864d1dadc1dd3f57","$01ca2f1f49a3a114$export$a7bcc8ced81f8d07","$01ca2f1f49a3a114$export$35059013cd4a06db","$01ca2f1f49a3a114$export$75d14899fb692bb6","$01ca2f1f49a3a114$export$6a1093e41947f68e","$01ca2f1f49a3a114$export$7c414e944018fb15","$01ca2f1f49a3a114$export$d90250155de6d7e7","$01ca2f1f49a3a114$export$3ae1b51693c80a9c","$01ca2f1f49a3a114$export$bc7581b048bdc9d","$01ca2f1f49a3a114$export$fb184b623420d9be","$01ca2f1f49a3a114$export$b2d17fca990bb66c","$01ca2f1f49a3a114$export$915fe2ca68846e4c","$01ca2f1f49a3a114$export$5e5acbc770fb0e4","$01ca2f1f49a3a114$exports","default"],"version":3,"file":"feedback-components.b9317f9c.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- :root{--text-line-height:3em;--main-extra-width:200px}.QoX8-W_page-wrapper{flex-direction:row;align-items:flex-start;gap:2em;display:flex;position:relative}.QoX8-W_feedback-container{flex:4}.QoX8-W_control-panel{flex:1;height:auto}.QoX8-W_control-content{position:sticky;top:0}.QoX8-W_feedback-component{width:800px;position:relative}.QoX8-W_feedback-component>svg{width:800px}.QoX8-W_node{cursor:pointer}circle{cursor:pointer;border:1px solid #000}.QoX8-W_selected{border:1px solid #fff}.QoX8-W_feedback-text{margin-bottom:2em}.QoX8-W_entity-panel{background:var(--panel-secondary-background-color);width:calc(100% - 2em);min-height:100px;max-height:600px;box-shadow:0 0 0 1px var(--panel-border-color)inset;border-radius:4px;flex:1;padding:1em;position:relative}.QoX8-W_selection-tree{margin:-1em 0;padding:1em 0}.QoX8-W_type-list{grid-template-rows:repeat(10,auto);grid-auto-flow:column;gap:.2em;display:grid}.QoX8-W_type-list .QoX8-W_type-tag{border-radius:.2em;padding:.2em .5em}.QoX8-W_description{max-width:300px;padding:.5em}mark{cursor:pointer;border-radius:.2em;color:#000!important}[role=treeitem]{width:auto!important}.QoX8-W_highlight{cursor:pointer;zIndex:10;border-radius:.2em;padding:.2em 0;position:relative}.QoX8-W_feedback-text-wrapper{z-index:0;line-height:var(--text-line-height);position:relative;overflow:visible}.QoX8-W_type-container{justify-content:space-between;align-items:center;column-gap:1em;display:flex}.QoX8-W_add-type{cursor:pointer;justify-content:space-between;align-items:center;padding:0 .5em;display:flex}.QoX8-W_add-type p{margin:0}.QoX8-W_overlay-container{justify-content:center;align-items:center;width:100vw;height:80vh;display:flex}.QoX8-W_overlay-container .QoX8-W_add-type-overlay{background-color:var(--secondary-color);border-radius:.2em;flex-direction:column;gap:1em;padding:.5em 1em;display:flex}.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_title{justify-content:space-between;align-items:center;display:flex}.QoX8-W_overlay-container .QoX8-W_add-type-overlay h2{margin:0}.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group{gap:3em;display:flex}.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group .QoX8-W_text-inputs{flex-direction:column;gap:1em;display:flex}.QoX8-W_icons{gap:.25em;display:flex}.QoX8-W_node-label{fill:var(--text-emphasized-color);fontSize:10px;pointerEvents:none}.QoX8-W_match-item{background-color:var(--background-color);color:var(--text-emphasized-color);cursor:pointer;border-radius:.2em;margin-bottom:4px;padding:.1em .2em}.QoX8-W_match-container{justify-content:space-between;align-items:center;display:flex}.QoX8-W_match-container .QoX8-W_close-btn{cursor:pointer}
2
- /*# sourceMappingURL=feedback-components.e096504e.css.map */
@@ -1 +0,0 @@
1
- {"mappings":"ACAA,sDAIA,sGAOA,kCAGA,yCAIA,8CAIA,yDAIE,2CAGF,4BAGA,4CAIA,uCAGA,wCAGA,4OAYA,mDAIA,iGAME,wEAIF,iDAIA,4DAKA,qCAGA,+FAOA,+GAMA,oGAMA,6GAOE,4BAGF,yGAOE,0KAQE,+HAKA,+DAGA,2FAIE,qIAKN,qCAIA,sFAKA,qKAQA,sFAKE","sources":["feedback-components.e096504e.css","packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[":root {\n --text-line-height: 3em;\n --main-extra-width: 200px;\n}\n\n.QoX8-W_page-wrapper {\n flex-direction: row;\n align-items: flex-start;\n gap: 2em;\n display: flex;\n position: relative;\n}\n\n.QoX8-W_feedback-container {\n flex: 4;\n}\n\n.QoX8-W_control-panel {\n flex: 1;\n height: auto;\n}\n\n.QoX8-W_control-content {\n position: sticky;\n top: 0;\n}\n\n.QoX8-W_feedback-component {\n width: 800px;\n position: relative;\n}\n\n.QoX8-W_feedback-component > svg {\n width: 800px;\n}\n\n.QoX8-W_node {\n cursor: pointer;\n}\n\ncircle {\n cursor: pointer;\n border: 1px solid #000;\n}\n\n.QoX8-W_selected {\n border: 1px solid #fff;\n}\n\n.QoX8-W_feedback-text {\n margin-bottom: 2em;\n}\n\n.QoX8-W_entity-panel {\n background: var(--panel-secondary-background-color);\n width: calc(100% - 2em);\n min-height: 100px;\n max-height: 600px;\n box-shadow: 0 0 0 1px var(--panel-border-color) inset;\n border-radius: 4px;\n flex: 1;\n padding: 1em;\n position: relative;\n}\n\n.QoX8-W_selection-tree {\n margin: -1em 0;\n padding: 1em 0;\n}\n\n.QoX8-W_type-list {\n grid-template-rows: repeat(10, auto);\n grid-auto-flow: column;\n gap: .2em;\n display: grid;\n}\n\n.QoX8-W_type-list .QoX8-W_type-tag {\n border-radius: .2em;\n padding: .2em .5em;\n}\n\n.QoX8-W_description {\n max-width: 300px;\n padding: .5em;\n}\n\nmark {\n cursor: pointer;\n border-radius: .2em;\n color: #000 !important;\n}\n\n[role=\"treeitem\"] {\n width: auto !important;\n}\n\n.QoX8-W_highlight {\n cursor: pointer;\n zIndex: 10;\n border-radius: .2em;\n padding: .2em 0;\n position: relative;\n}\n\n.QoX8-W_feedback-text-wrapper {\n z-index: 0;\n line-height: var(--text-line-height);\n position: relative;\n overflow: visible;\n}\n\n.QoX8-W_type-container {\n justify-content: space-between;\n align-items: center;\n column-gap: 1em;\n display: flex;\n}\n\n.QoX8-W_add-type {\n cursor: pointer;\n justify-content: space-between;\n align-items: center;\n padding: 0 .5em;\n display: flex;\n}\n\n.QoX8-W_add-type p {\n margin: 0;\n}\n\n.QoX8-W_overlay-container {\n justify-content: center;\n align-items: center;\n width: 100vw;\n height: 80vh;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay {\n background-color: var(--secondary-color);\n border-radius: .2em;\n flex-direction: column;\n gap: 1em;\n padding: .5em 1em;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_title {\n justify-content: space-between;\n align-items: center;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay h2 {\n margin: 0;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group {\n gap: 3em;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group .QoX8-W_text-inputs {\n flex-direction: column;\n gap: 1em;\n display: flex;\n}\n\n.QoX8-W_icons {\n gap: .25em;\n display: flex;\n}\n\n.QoX8-W_node-label {\n fill: var(--text-emphasized-color);\n fontSize: 10px;\n pointerEvents: none;\n}\n\n.QoX8-W_match-item {\n background-color: var(--background-color);\n color: var(--text-emphasized-color);\n cursor: pointer;\n border-radius: .2em;\n margin-bottom: 4px;\n padding: .1em .2em;\n}\n\n.QoX8-W_match-container {\n justify-content: space-between;\n align-items: center;\n display: flex;\n}\n\n.QoX8-W_match-container .QoX8-W_close-btn {\n cursor: pointer;\n}\n/*# sourceMappingURL=feedback-components.e096504e.css.map */\n",":root\n --text-line-height: 3em\n --main-extra-width: 200px\n\n.page-wrapper\n display: flex\n flex-direction: row\n position: relative\n gap: 2em\n align-items: flex-start // makes control-content lose stick\n\n.feedback-container\n flex: 4\n\n.control-panel\n flex: 1\n height: auto\n\n.control-content\n position: sticky\n top: 0\n\n.feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\ncircle\n cursor: pointer\n border: 1px solid black\n\n.selected\n border: 1px solid white\n \n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n width: calc(100% - 2em)\n flex: 1\n min-height: 100px\n padding: 1em\n background: var(--panel-secondary-background-color)\n border-radius: 4px\n // Inset box shadow\n box-shadow: 0 0 0 1px var(--panel-border-color) inset\n\n.selection-tree\n margin: -1em 0\n padding: 1em 0\n \n.type-list\n display: grid\n grid-auto-flow: column\n grid-template-rows: repeat(10, auto)\n gap: 0.2em\n\n .type-tag\n padding: .2em .5em\n border-radius: .2em\n\n.description\n max-width: 300px\n padding: .5em\n\nmark\n border-radius: .2em\n cursor: pointer\n color: black !important\n\n[role=\"treeitem\"]\n width: auto !important\n\n.highlight\n cursor: pointer\n padding: .2em 0\n border-radius: .2em\n position: relative\n zIndex: 10\n\n.feedback-text-wrapper \n position: relative\n z-index: 0\n overflow: visible\n line-height: var(--text-line-height)\n\n.type-container\n display: flex\n justify-content: space-between\n align-items: center\n column-gap: 1em\n\n.add-type\n cursor: pointer\n display: flex\n justify-content: space-between\n padding: 0 .5em\n align-items: center\n\n p\n margin: 0\n\n.overlay-container\n height: 80vh\n width: 100vw\n display: flex\n justify-content: center\n align-items: center\n\n .add-type-overlay\n background-color: var(--secondary-color)\n padding: .5em 1em\n display: flex\n flex-direction: column\n gap: 1em\n border-radius: .2em\n\n .title\n display: flex\n justify-content: space-between\n align-items: center\n\n h2\n margin: 0\n\n .form-group\n display: flex\n gap: 3em\n\n .text-inputs\n display: flex\n flex-direction: column\n gap: 1em\n\n.icons\n display: flex\n gap: .25em\n\n.node-label\n fill: var(--text-emphasized-color)\n fontSize: 10px\n pointerEvents: none\n\n.match-item\n background-color: var(--background-color)\n color: var(--text-emphasized-color)\n padding: .1em .2em\n border-radius: .2em\n margin-bottom: 4px\n cursor: pointer\n\n.match-container\n display: flex\n justify-content: space-between\n align-items: center\n\n .close-btn\n cursor: pointer"],"names":[],"version":3,"file":"feedback-components.e096504e.css.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"./feedback-components.b9317f9c.js";import"./feedback-components.b22d37d1.js";import e from"@macrostrat/hyper";import{useState as t}from"react";import{Icon as o,Overlay2 as d,Popover as i}from"@blueprintjs/core";import{useInDarkMode as l,SaveButton as a}from"@macrostrat/ui-components";import{ColorPicker as r}from"@macrostrat/data-sheet";var n=globalThis,s={},p={},c=n.parcelRequirea149;null==c&&((c=function(e){if(e in s)return s[e].exports;if(e in p){var t=p[e];delete p[e];var o={id:e,exports:{}};return s[e]=o,t.call(o.exports,o,o.exports),o.exports}var d=Error("Cannot find module '"+e+"'");throw d.code="MODULE_NOT_FOUND",d}).register=function(e,t){p[e]=t},n.parcelRequirea149=c),c.register;var y=c("9wFEx"),u=c("edvRb");let v=e.styled(y&&y.__esModule?y.default:y);function m({types:e,selected:o,dispatch:d,selectedNodes:i,tree:a}){let[r,n]=t(null),s=i.length>0,p=l()?.9:.4;return v("div.type-list-container",[v("div.type-list-header",s&&!r?"Change selected nodes to:":"Entity Types"),v("div.type-list",Array.from(e.values()).map(e=>v(x,{type:e,luminance:p,selectedType:r,setSelectedType:n,dispatch:d,tree:a,selectedNodes:i,selected:o,isSelectedNodes:s}))),v(f,{dispatch:d})])}function g(e,t){let o=[];return e.forEach(function e(d){d.type.id===t&&o.push(d.id),Array.isArray(d.children)&&d.children.forEach(e)}),o}function f({dispatch:e}){let[d,i]=t(!1);return v("div.add-type-container",[v("div.add-type",{onClick:()=>i(!0)},[v("p.add-type-text","Add new type"),v(o,{icon:"plus"})]),v(b,{setOverlayOpen:i,overlayOpen:d,title:"Add New Type",saveHandler:t=>{e({type:"add-entity-type",payload:t}),i(!1)}})])}function h({dispatch:e,type:d}){let[i,l]=t(!1);return v("div.edit-type",[v(o,{icon:"edit",className:"edit-icon",onClick:e=>{e.stopPropagation(),l(!0)}}),v(b,{setOverlayOpen:l,overlayOpen:i,originalType:d,title:"Edit Type",saveHandler:t=>{e({type:"update-entity-type",payload:t}),l(!1)}})])}function b({setOverlayOpen:e,overlayOpen:i,originalType:l,title:n,saveHandler:s}){let{name:p,description:c,color:y,id:u}=l||{},[m,g]=t(p||""),[f,h]=t(c||""),[b,x]=t(y||"#fff");return v(d,{isOpen:i},v("div.overlay-container",v("div.add-type-overlay",[v("h2.title",[n,v(o,{icon:"cross",className:"close-icon",onClick:()=>{e(!1)},style:{cursor:"pointer",color:"red"}})]),v("div.form-group",[v("div.text-inputs",[v("div.form-field.name",[v("p.label","Name"),v("input",{type:"text",placeholder:"Enter type name",onChange:e=>g(e.target.value),value:m})]),v("div.form-field.form-description",[v("p.label","Description"),v("input",{type:"text",placeholder:"Enter type description",onChange:e=>h(e.target.value),value:f})])]),v("div.form-field.color",[v("p.label","Color"),v(r,{value:b,onChange:e=>x(e),style:{width:"100%"}})])]),v(a,{className:"save-btn",small:!0,onClick:()=>s({name:m,description:f,color:b,id:u})},"Save changes")])))}function x({type:e,luminance:t,selectedType:d,setSelectedType:a,dispatch:r,tree:n,selectedNodes:s,selected:p,isSelectedNodes:c}){let{color:y,name:m,id:f,description:b}=e;l();let x=f===p?.id&&s.length>0,N=(0,u.getTagStyle)(y,{active:x,highlighted:0===s.length}),T={id:f,name:m,color:y,description:b},k=g(n,f);return v(i,{autoFocus:!1,content:v("div.description",b||"No description available"),interactionKind:"hover"},v("div.type-tag",{onClick:()=>{c||null!==d?c&&null===d?f===p?.id&&s.length>0?r({type:"toggle-node-selected",payload:{ids:s}}):r({type:"select-entity-type",payload:T}):c&&d.id===f?(a(null),r({type:"toggle-node-selected",payload:{ids:k}})):c&&d.id!==f?k.length>0&&(a(e),r({type:"toggle-node-selected",payload:{ids:g(n,d.id)}}),r({type:"toggle-node-selected",payload:{ids:k}})):console.warn("Unexpected state in TypeTag click handler",{isSelectedNodes:c,selectedType:d,selectedNodes:s,ids:k,id:f,selected:p}):k.length>0&&(a(e),r({type:"toggle-node-selected",payload:{ids:k}}))},style:{cursor:k.length>0||c&&!d?"pointer":"",color:"black",backgroundColor:N.backgroundColor,border:x?"1px solid var(--text-emphasized-color)":"1px solid var(--background-color)"}},v("div.type-container",[v("div.type-name",m),v("div.icons",[v(h,{dispatch:r,type:e}),v(o,{icon:"cross",className:"delete-type-icon",style:{color:"red",cursor:"pointer"},onClick:e=>{e.stopPropagation(),r({type:"delete-entity-type",payload:{id:f}})}})])])))}export{m as TypeList};
2
- //# sourceMappingURL=feedback-components.e140ac86.js.map