@macrostrat/feedback-components 1.1.2 → 1.1.4

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 (76) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/esm/{feedback-components.95dbe7d7.js → feedback-components.00434ff7.js} +10 -1
  3. package/dist/esm/feedback-components.00434ff7.js.map +1 -0
  4. package/dist/esm/{feedback-components.46a7a347.js → feedback-components.1c15f37f.js} +101 -12
  5. package/dist/esm/feedback-components.1c15f37f.js.map +1 -0
  6. package/dist/esm/{feedback-components.586103e8.js → feedback-components.204f7d2b.js} +27 -276
  7. package/dist/esm/feedback-components.204f7d2b.js.map +1 -0
  8. package/dist/esm/{feedback-components.3b3a5357.js → feedback-components.28ba71be.js} +19 -8
  9. package/dist/esm/feedback-components.28ba71be.js.map +1 -0
  10. package/dist/esm/{feedback-components.5df2a926.js → feedback-components.707e3490.js} +5 -7
  11. package/dist/esm/feedback-components.707e3490.js.map +1 -0
  12. package/dist/esm/feedback-components.7e879290.js +286 -0
  13. package/dist/esm/feedback-components.7e879290.js.map +1 -0
  14. package/dist/esm/{feedback-components.5509fab3.js → feedback-components.d55a1d18.js} +6 -6
  15. package/dist/esm/{feedback-components.5509fab3.js.map → feedback-components.d55a1d18.js.map} +1 -1
  16. package/dist/esm/{feedback-components.fb60c70d.css → feedback-components.d591ffec.css} +20 -1
  17. package/dist/esm/feedback-components.d591ffec.css.map +1 -0
  18. package/dist/esm/{feedback-components.fa1d3641.js → feedback-components.f6605b83.js} +49 -7
  19. package/dist/esm/feedback-components.f6605b83.js.map +1 -0
  20. package/dist/esm/feedback-components.fd8ac9ca.js +230 -0
  21. package/dist/esm/feedback-components.fd8ac9ca.js.map +1 -0
  22. package/dist/esm/index.d.ts +5 -2
  23. package/dist/esm/index.d.ts.map +1 -1
  24. package/dist/esm/index.js +2 -2
  25. package/dist/node/feedback-components.0eef8d0c.js +2 -0
  26. package/dist/node/feedback-components.0eef8d0c.js.map +1 -0
  27. package/dist/node/{feedback-components.a39f7653.js → feedback-components.2f740fc7.js} +2 -2
  28. package/dist/node/{feedback-components.a39f7653.js.map → feedback-components.2f740fc7.js.map} +1 -1
  29. package/dist/node/feedback-components.41db283a.js +2 -0
  30. package/dist/node/feedback-components.41db283a.js.map +1 -0
  31. package/dist/node/feedback-components.69d0ccd0.js +2 -0
  32. package/dist/node/feedback-components.69d0ccd0.js.map +1 -0
  33. package/dist/node/feedback-components.a7b43cfa.js +2 -0
  34. package/dist/node/feedback-components.a7b43cfa.js.map +1 -0
  35. package/dist/node/feedback-components.b22d37d1.js +2 -0
  36. package/dist/node/feedback-components.b22d37d1.js.map +1 -0
  37. package/dist/node/feedback-components.b9317f9c.js +2 -0
  38. package/dist/node/feedback-components.b9317f9c.js.map +1 -0
  39. package/dist/node/{feedback-components.c88cb37f.css → feedback-components.e096504e.css} +2 -2
  40. package/dist/node/feedback-components.e096504e.css.map +1 -0
  41. package/dist/node/feedback-components.e140ac86.js +2 -0
  42. package/dist/node/feedback-components.e140ac86.js.map +1 -0
  43. package/dist/node/feedback-components.f8373b58.js +2 -0
  44. package/dist/node/feedback-components.f8373b58.js.map +1 -0
  45. package/dist/node/index.js +1 -1
  46. package/dist/node/index.js.map +1 -1
  47. package/package.json +3 -2
  48. package/src/extractions/index.ts +7 -2
  49. package/src/extractions/types.ts +1 -0
  50. package/src/feedback/edit-state.ts +52 -3
  51. package/src/feedback/feedback.module.sass +17 -1
  52. package/src/feedback/graph.ts +17 -4
  53. package/src/feedback/index.ts +14 -309
  54. package/src/feedback/matches.ts +241 -0
  55. package/src/feedback/text-visualizer.ts +114 -4
  56. package/src/feedback/typelist.ts +312 -0
  57. package/dist/esm/feedback-components.3b3a5357.js.map +0 -1
  58. package/dist/esm/feedback-components.46a7a347.js.map +0 -1
  59. package/dist/esm/feedback-components.586103e8.js.map +0 -1
  60. package/dist/esm/feedback-components.5df2a926.js.map +0 -1
  61. package/dist/esm/feedback-components.95dbe7d7.js.map +0 -1
  62. package/dist/esm/feedback-components.fa1d3641.js.map +0 -1
  63. package/dist/esm/feedback-components.fb60c70d.css.map +0 -1
  64. package/dist/node/feedback-components.561466ac.js +0 -2
  65. package/dist/node/feedback-components.561466ac.js.map +0 -1
  66. package/dist/node/feedback-components.571ee23c.js +0 -2
  67. package/dist/node/feedback-components.571ee23c.js.map +0 -1
  68. package/dist/node/feedback-components.8b03e8be.js +0 -2
  69. package/dist/node/feedback-components.8b03e8be.js.map +0 -1
  70. package/dist/node/feedback-components.b7946db4.js +0 -2
  71. package/dist/node/feedback-components.b7946db4.js.map +0 -1
  72. package/dist/node/feedback-components.c459cc27.js +0 -2
  73. package/dist/node/feedback-components.c459cc27.js.map +0 -1
  74. package/dist/node/feedback-components.c88cb37f.css.map +0 -1
  75. package/dist/node/feedback-components.ec54a1e7.js +0 -2
  76. package/dist/node/feedback-components.ec54a1e7.js.map +0 -1
@@ -0,0 +1 @@
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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AS,GAAI,CAC9C,EACF,EACA,SA9CiB,AAAA,EACnB,AAAC,IACC,GAAI,CAAC,EAAW,OAAO,CAAE,MACzB,CAAA,EAAW,OAAO,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 +1,2 @@
1
- import"./feedback-components.8b03e8be.js";import"./feedback-components.b7946db4.js";import"./feedback-components.c459cc27.js";import e from"@macrostrat/hyper";var t=globalThis,r={},a={},o=t.parcelRequirea149;null==o&&((o=function(e){if(e in r)return r[e].exports;if(e in a){var t=a[e];delete a[e];var o={id:e,exports:{}};return r[e]=o,t.call(o.exports,o,o.exports),o.exports}var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(e,t){a[e]=t},t.parcelRequirea149=o),o.register;var n=o("edvRb"),d=o("eedTh"),i=o("9wFEx");let l=e.styled(i&&i.__esModule?i.default:i);var c=function({node:e,style:t,dragHandle:r,tree:a,matchComponent:o}){let i=function e(t,r){if(0==r.selectedNodes.length)return!0;for(let e of r.selectedNodes){var a,o;if(a=t.data,o=e.data,a.id==o.id)return!0}return!!(null!=t.parent&&e(t.parent,r))}(e,a),c=function(e,t){for(let o of t.selectedNodes){var r,a;if(r=e.data,a=o.data,r.id==a.id)return!0}return!1}(e,a),s=(0,d.useTreeDispatch)();return e.data?.type||(e.data.type={name:"lith",color:"rgb(107, 255, 91)"}),l("div.node",{style:t,ref:r},l(n.EntityTag,{data:e.data,active:c,highlighted:i,matchComponent:o,onClickType(){s({type:"toggle-entity-type-selector"})}}))};export{c as default};
2
- //# sourceMappingURL=feedback-components.a39f7653.js.map
1
+ import"./feedback-components.b22d37d1.js";import"./feedback-components.a7b43cfa.js";import"./feedback-components.b9317f9c.js";import e from"@macrostrat/hyper";var t=globalThis,r={},a={},o=t.parcelRequirea149;null==o&&((o=function(e){if(e in r)return r[e].exports;if(e in a){var t=a[e];delete a[e];var o={id:e,exports:{}};return r[e]=o,t.call(o.exports,o,o.exports),o.exports}var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(e,t){a[e]=t},t.parcelRequirea149=o),o.register;var n=o("edvRb"),d=o("eedTh"),i=o("9wFEx");let l=e.styled(i&&i.__esModule?i.default:i);var c=function({node:e,style:t,dragHandle:r,tree:a,matchComponent:o}){let i=function e(t,r){if(0==r.selectedNodes.length)return!0;for(let e of r.selectedNodes){var a,o;if(a=t.data,o=e.data,a.id==o.id)return!0}return!!(null!=t.parent&&e(t.parent,r))}(e,a),c=function(e,t){for(let o of t.selectedNodes){var r,a;if(r=e.data,a=o.data,r.id==a.id)return!0}return!1}(e,a),s=(0,d.useTreeDispatch)();return e.data?.type||(e.data.type={name:"lith",color:"rgb(107, 255, 91)"}),l("div.node",{style:t,ref:r},l(n.EntityTag,{data:e.data,active:c,highlighted:i,matchComponent:o,onClickType(){s({type:"toggle-entity-type-selector"})}}))};export{c as default};
2
+ //# sourceMappingURL=feedback-components.2f740fc7.js.map
@@ -1 +1 @@
1
- {"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,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,SCOA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GA+DvB,IAAA,EA3BA,SAAc,CAAA,KAAE,CAAI,CAAA,MAAE,CAAK,CAAA,WAAE,CAAU,CAAA,KAAE,CAAI,CAAA,eAAE,CAAc,CAAO,EAClE,IAAI,EAAuB,AA9B7B,SAAS,EAAkB,CAAuB,CAAE,CAAuB,EAEzE,GAAI,AAA6B,GAA7B,EAAK,aAAa,CAAC,MAAM,CAC3B,MAAO,CAAA,EAGT,IAAK,IAAM,KAAgB,EAAK,aAAa,CAC3C,KAZgB,EAAsB,EAYtC,GAZgB,EAYD,EAAK,IAAI,CAZc,EAYZ,EAAa,IAAI,CAXtC,EAAW,EAAE,EAAI,EAAS,EAAE,CAY/B,MAAO,CAAA,CADT,SAME,CAAA,AAAe,MAAf,EAAK,MAAM,EAAY,EAAkB,EAAK,MAAM,CAAE,EAAA,CAK5D,EAY+C,EAAM,GAC/C,EAAkB,AAXxB,SAAsB,CAAuB,CAAE,CAAuB,EACpE,IAAK,IAAM,KAAgB,EAAK,aAAa,CAC3C,KA3BgB,EAAsB,EA2BtC,GA3BgB,EA2BD,EAAK,IAAI,CA3Bc,EA2BZ,EAAa,IAAI,CA1BtC,EAAW,EAAE,EAAI,EAAS,EAAE,CA2B/B,MAAO,CAAA,CADT,CAIF,MAAO,CAAA,CACT,EAIqC,EAAM,GAEnC,EAAW,AAAA,CAAA,EAAA,EAAA,eAAc,AAAd,IAQjB,OAJI,AAAC,EAAK,IAAI,EAAE,MACd,CAAA,EAAK,IAAI,CAAC,IAAI,CAAG,CAAE,KAAM,OAAQ,MAAO,mBAAoB,CAAA,EAGvD,EACL,WACA,CAAE,MAAA,EAAO,IAAK,CAAW,EACzB,EAAE,EAAA,SAAQ,CAAG,CACX,KAAM,EAAK,IAAI,CACf,OAAA,EACA,YAAA,EACA,eAAA,EACA,cACE,EAAS,CAAE,KAAM,6BAA8B,EACjD,CACF,GAEJ,S,K,O","sources":["<anon>","packages/feedback-components/src/feedback/node.ts"],"sourcesContent":["import \"./feedback-components.8b03e8be.js\";\nimport \"./feedback-components.b7946db4.js\";\nimport \"./feedback-components.c459cc27.js\";\nimport $hPIF3$macrostrathyper from \"@macrostrat/hyper\";\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 $edvRb = parcelRequire(\"edvRb\");\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\nconst $2e9ede27ff2a3eea$var$h = (0, $hPIF3$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $2e9ede27ff2a3eea$var$isSelected(searchNode, treeNode) {\n return searchNode.id == treeNode.id;\n// We could also select children of the search node here if we wanted to\n}\nfunction $2e9ede27ff2a3eea$var$isNodeHighlighted(node, tree) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) return true;\n for (const selectedNode of tree.selectedNodes){\n if ($2e9ede27ff2a3eea$var$isSelected(node.data, selectedNode.data)) return true;\n }\n // Check if the parent node is highlighted\n if (node.parent != null && $2e9ede27ff2a3eea$var$isNodeHighlighted(node.parent, tree)) return true;\n return false;\n}\nfunction $2e9ede27ff2a3eea$var$isNodeActive(node, tree) {\n for (const selectedNode of tree.selectedNodes){\n if ($2e9ede27ff2a3eea$var$isSelected(node.data, selectedNode.data)) return true;\n }\n return false;\n}\nfunction $2e9ede27ff2a3eea$var$Node({ node: node, style: style, dragHandle: dragHandle, tree: tree, matchComponent: matchComponent }) {\n let highlighted = $2e9ede27ff2a3eea$var$isNodeHighlighted(node, tree);\n let active = $2e9ede27ff2a3eea$var$isNodeActive(node, tree);\n const dispatch = (0, $eedTh.useTreeDispatch)();\n // console.log(\"Node render\", node.data, highlighted, active);\n if (!node.data?.type) node.data.type = {\n name: \"lith\",\n color: \"rgb(107, 255, 91)\"\n };\n return $2e9ede27ff2a3eea$var$h(\"div.node\", {\n style: style,\n ref: dragHandle\n }, $2e9ede27ff2a3eea$var$h((0, $edvRb.EntityTag), {\n data: node.data,\n active: active,\n highlighted: highlighted,\n matchComponent: matchComponent,\n onClickType () {\n dispatch({\n type: \"toggle-entity-type-selector\"\n });\n }\n }));\n}\nvar $2e9ede27ff2a3eea$export$2e2bcd8739ae039 = $2e9ede27ff2a3eea$var$Node;\n\n\nexport {$2e9ede27ff2a3eea$export$2e2bcd8739ae039 as default};\n//# sourceMappingURL=feedback-components.a39f7653.js.map\n","import { NodeApi, TreeApi } from \"react-arborist\";\nimport { TreeData } from \"./types\";\nimport { EntityTag } from \"../extractions\";\nimport { useTreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nconst h = hyper.styled(styles);\n\nfunction isSelected(searchNode: TreeData, treeNode: TreeData) {\n return searchNode.id == treeNode.id;\n // We could also select children of the search node here if we wanted to\n}\n\nfunction isNodeHighlighted(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) {\n return true;\n }\n\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n\n // Check if the parent node is highlighted\n if (node.parent != null && isNodeHighlighted(node.parent, tree)) {\n return true;\n }\n\n return false;\n}\n\nfunction isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n return false;\n}\n\nfunction Node({ node, style, dragHandle, tree, matchComponent }: any) {\n let highlighted: boolean = isNodeHighlighted(node, tree);\n let active: boolean = isNodeActive(node, tree);\n\n const dispatch = useTreeDispatch();\n\n // console.log(\"Node render\", node.data, highlighted, active);\n\n if (!node.data?.type) {\n node.data.type = { name: \"lith\", color: \"rgb(107, 255, 91)\" };\n }\n\n return h(\n \"div.node\",\n { style, ref: dragHandle },\n h(EntityTag, {\n data: node.data,\n active,\n highlighted,\n matchComponent,\n onClickType() {\n dispatch({ type: \"toggle-entity-type-selector\" });\n },\n }),\n );\n}\n\nexport default Node;\n"],"names":["$hPIF3$macrostrathyper","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$edvRb","$eedTh","$9wFEx","$2e9ede27ff2a3eea$var$h","styled","a","__esModule","default","$2e9ede27ff2a3eea$export$2e2bcd8739ae039","node","style","dragHandle","tree","matchComponent","highlighted","$2e9ede27ff2a3eea$var$isNodeHighlighted","selectedNodes","length","selectedNode","searchNode","treeNode","data","parent","active","$2e9ede27ff2a3eea$var$isNodeActive","dispatch","useTreeDispatch","type","name","color","ref","EntityTag","onClickType"],"version":3,"file":"feedback-components.a39f7653.js.map","sourceRoot":"../../../../"}
1
+ {"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,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,SCOA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GA+DvB,IAAA,EA3BA,SAAc,CAAA,KAAE,CAAI,CAAA,MAAE,CAAK,CAAA,WAAE,CAAU,CAAA,KAAE,CAAI,CAAA,eAAE,CAAc,CAAO,EAClE,IAAI,EAAuB,AA9B7B,SAAS,EAAkB,CAAuB,CAAE,CAAuB,EAEzE,GAAI,AAA6B,GAA7B,EAAK,aAAa,CAAC,MAAM,CAC3B,MAAO,CAAA,EAGT,IAAK,IAAM,KAAgB,EAAK,aAAa,CAC3C,KAZgB,EAAsB,EAYtC,GAZgB,EAYD,EAAK,IAAI,CAZc,EAYZ,EAAa,IAAI,CAXtC,EAAW,EAAE,EAAI,EAAS,EAAE,CAY/B,MAAO,CAAA,CADT,SAME,CAAA,AAAe,MAAf,EAAK,MAAM,EAAY,EAAkB,EAAK,MAAM,CAAE,EAAA,CAK5D,EAY+C,EAAM,GAC/C,EAAkB,AAXxB,SAAsB,CAAuB,CAAE,CAAuB,EACpE,IAAK,IAAM,KAAgB,EAAK,aAAa,CAC3C,KA3BgB,EAAsB,EA2BtC,GA3BgB,EA2BD,EAAK,IAAI,CA3Bc,EA2BZ,EAAa,IAAI,CA1BtC,EAAW,EAAE,EAAI,EAAS,EAAE,CA2B/B,MAAO,CAAA,CADT,CAIF,MAAO,CAAA,CACT,EAIqC,EAAM,GAEnC,EAAW,AAAA,CAAA,EAAA,EAAA,eAAc,AAAd,IAQjB,OAJI,AAAC,EAAK,IAAI,EAAE,MACd,CAAA,EAAK,IAAI,CAAC,IAAI,CAAG,CAAE,KAAM,OAAQ,MAAO,mBAAoB,CAAA,EAGvD,EACL,WACA,CAAE,MAAA,EAAO,IAAK,CAAW,EACzB,EAAE,EAAA,SAAQ,CAAG,CACX,KAAM,EAAK,IAAI,CACf,OAAA,EACA,YAAA,EACA,eAAA,EACA,cACE,EAAS,CAAE,KAAM,6BAA8B,EACjD,CACF,GAEJ,S,K,O","sources":["<anon>","packages/feedback-components/src/feedback/node.ts"],"sourcesContent":["import \"./feedback-components.b22d37d1.js\";\nimport \"./feedback-components.a7b43cfa.js\";\nimport \"./feedback-components.b9317f9c.js\";\nimport $hPIF3$macrostrathyper from \"@macrostrat/hyper\";\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 $edvRb = parcelRequire(\"edvRb\");\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\nconst $2e9ede27ff2a3eea$var$h = (0, $hPIF3$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $2e9ede27ff2a3eea$var$isSelected(searchNode, treeNode) {\n return searchNode.id == treeNode.id;\n// We could also select children of the search node here if we wanted to\n}\nfunction $2e9ede27ff2a3eea$var$isNodeHighlighted(node, tree) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) return true;\n for (const selectedNode of tree.selectedNodes){\n if ($2e9ede27ff2a3eea$var$isSelected(node.data, selectedNode.data)) return true;\n }\n // Check if the parent node is highlighted\n if (node.parent != null && $2e9ede27ff2a3eea$var$isNodeHighlighted(node.parent, tree)) return true;\n return false;\n}\nfunction $2e9ede27ff2a3eea$var$isNodeActive(node, tree) {\n for (const selectedNode of tree.selectedNodes){\n if ($2e9ede27ff2a3eea$var$isSelected(node.data, selectedNode.data)) return true;\n }\n return false;\n}\nfunction $2e9ede27ff2a3eea$var$Node({ node: node, style: style, dragHandle: dragHandle, tree: tree, matchComponent: matchComponent }) {\n let highlighted = $2e9ede27ff2a3eea$var$isNodeHighlighted(node, tree);\n let active = $2e9ede27ff2a3eea$var$isNodeActive(node, tree);\n const dispatch = (0, $eedTh.useTreeDispatch)();\n // console.log(\"Node render\", node.data, highlighted, active);\n if (!node.data?.type) node.data.type = {\n name: \"lith\",\n color: \"rgb(107, 255, 91)\"\n };\n return $2e9ede27ff2a3eea$var$h(\"div.node\", {\n style: style,\n ref: dragHandle\n }, $2e9ede27ff2a3eea$var$h((0, $edvRb.EntityTag), {\n data: node.data,\n active: active,\n highlighted: highlighted,\n matchComponent: matchComponent,\n onClickType () {\n dispatch({\n type: \"toggle-entity-type-selector\"\n });\n }\n }));\n}\nvar $2e9ede27ff2a3eea$export$2e2bcd8739ae039 = $2e9ede27ff2a3eea$var$Node;\n\n\nexport {$2e9ede27ff2a3eea$export$2e2bcd8739ae039 as default};\n//# sourceMappingURL=feedback-components.2f740fc7.js.map\n","import { NodeApi, TreeApi } from \"react-arborist\";\nimport { TreeData } from \"./types\";\nimport { EntityTag } from \"../extractions\";\nimport { useTreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nconst h = hyper.styled(styles);\n\nfunction isSelected(searchNode: TreeData, treeNode: TreeData) {\n return searchNode.id == treeNode.id;\n // We could also select children of the search node here if we wanted to\n}\n\nfunction isNodeHighlighted(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) {\n return true;\n }\n\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n\n // Check if the parent node is highlighted\n if (node.parent != null && isNodeHighlighted(node.parent, tree)) {\n return true;\n }\n\n return false;\n}\n\nfunction isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n return false;\n}\n\nfunction Node({ node, style, dragHandle, tree, matchComponent }: any) {\n let highlighted: boolean = isNodeHighlighted(node, tree);\n let active: boolean = isNodeActive(node, tree);\n\n const dispatch = useTreeDispatch();\n\n // console.log(\"Node render\", node.data, highlighted, active);\n\n if (!node.data?.type) {\n node.data.type = { name: \"lith\", color: \"rgb(107, 255, 91)\" };\n }\n\n return h(\n \"div.node\",\n { style, ref: dragHandle },\n h(EntityTag, {\n data: node.data,\n active,\n highlighted,\n matchComponent,\n onClickType() {\n dispatch({ type: \"toggle-entity-type-selector\" });\n },\n }),\n );\n}\n\nexport default Node;\n"],"names":["$hPIF3$macrostrathyper","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$edvRb","$eedTh","$9wFEx","$2e9ede27ff2a3eea$var$h","styled","a","__esModule","default","$2e9ede27ff2a3eea$export$2e2bcd8739ae039","node","style","dragHandle","tree","matchComponent","highlighted","$2e9ede27ff2a3eea$var$isNodeHighlighted","selectedNodes","length","selectedNode","searchNode","treeNode","data","parent","active","$2e9ede27ff2a3eea$var$isNodeActive","dispatch","useTreeDispatch","type","name","color","ref","EntityTag","onClickType"],"version":3,"file":"feedback-components.2f740fc7.js.map","sourceRoot":"../../../../"}
@@ -0,0 +1,2 @@
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||`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DjE,AAA6B,IAAzB,EAAc,MAAM,EAEtB,EAAc,QAAQ,CAAC,IACvB,EAAM,IAAI,CACR,AAAC,GACC,EAAc,QAAQ,CAAC,EAAK,EAAE,GAC9B,EAAK,QAAQ,CAAC,IAAI,CAAC,AAAC,GAAU,EAAM,EAAE,GAAK,KAzDjC,EAAQ,AAAA,CAAA,EAAA,EAAA,WAAU,AAAV,EAAY,EAAE,KAAK,CAAE,CAAE,YAAA,EAAa,OAAA,CAAO,GAEzD,OAAO,EAAE,IAAK,CACZ,EAAE,SAAU,CACV,GAAI,EAAE,CAAC,CACP,GAAI,EAAE,CAAC,CACP,EAAG,EACH,KAAM,EAAM,eAAe,EAAI,OAC/B,QAAS,AAAC,IACR,EAAE,eAAe,GAEf,EAAE,OAAO,EACT,EAAE,OAAO,EACR,CAAa,CAAC,EAAE,GAAK,EAAE,EAAE,EAAI,AAAyB,IAAzB,EAAc,MAAM,EAGlD,EAAE,eAAe,GACjB,EAAS,CACP,KAAM,uBACN,QAAS,CAAE,IAAK,CAAC,EAAE,EAAE,CAAC,AAAC,CACzB,IAEA,EAAS,CACP,KAAM,cACN,QAAS,CAAE,IAAK,CAAC,EAAE,EAAE,CAAC,AAAC,CACzB,EAEJ,EACA,UAAW,EAAS,WAAa,GACjC,OA/BW,EAAS,QAAU,QAgC9B,YAAa,CACf,GACA,EAAE,EAAE,CAAC,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":"../../../../"}
@@ -0,0 +1,2 @@
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
@@ -0,0 +1 @@
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,CAAI,CAAA,cAAE,CAAa,CAAA,MAAE,CAAK,CAAA,SAAE,CAAQ,CAAA,aAAE,CAAY,CAAA,WAAE,CAAU,CAAE,CACtE,EAMF,OAAO,EACL,4BACA,CACE,SAAU,EACV,UAAW,AAAC,IACN,AAAU,cAAV,EAAE,GAAG,EACP,EAAS,CACP,KAAM,cACN,QAAS,CAAE,IAAK,CAAc,CAChC,EAEJ,CACF,EACA,EAAE,EAAiB,CACjB,KAAA,EACA,QApBgC,AAxDtC,SACE,CAAuB,CACvB,CAAuB,EAEvB,IAAI,EAA2B,EAAE,CAE3B,EAAW,IA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F,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":"../../../../"}
@@ -0,0 +1,2 @@
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
@@ -0,0 +1 @@
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,CAAG,EAC/B,EAAsB,CAC1B,GAAI,EACJ,KAAA,EACA,YAAa,AAAgB,KAAhB,EAAqB,KAAO,EACzC,MAAA,CACF,EAEM,EAAoB,IAAI,IAAI,EAAM,cAAc,EAGtD,OAFA,EAAkB,GAAG,CAAC,EAAO,GAEtB,CACL,GAAG,CAAK,CACR,eAAgB,EAChB,mBAAoB,EACpB,eAAgB,CAClB,CACF,CACA,IAAK,qBAAsB,CAEzB,GAAM,CAAA,GAAE,CAAE,CAAA,KAAE,CAAI,CAAA,YAAE,CAAW,CAAA,MAAE,CAAK,CAAE,CAAG,EAAO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AgB,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":"../../../../"}
@@ -0,0 +1,2 @@
1
+ import"./feedback-components.794f429b.js";import t from"classnames";import{Tag as e}from"@blueprintjs/core";import{asChromaColor as n}from"@macrostrat/color-utils";import a from"@macrostrat/hyper";import{useDarkMode as r}from"@macrostrat/ui-components";function o(t,e,n,a){Object.defineProperty(t,e,{get:n,set:a,enumerable:!0,configurable:!0})}var i=globalThis,l={},c={},s=i.parcelRequirea149;null==s&&((s=function(t){if(t in l)return l[t].exports;if(t in c){var e=c[t];delete c[t];var n={id:t,exports:{}};return l[t]=n,e.call(n.exports,n,n.exports),n.exports}var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}).register=function(t,e){c[t]=e},i.parcelRequirea149=s),s.register;var p={};o(p,"buildHighlights",()=>u),o(p,"enhanceData",()=>f),o(p,"getTagStyle",()=>m),o(p,"ExtractionContext",()=>g),o(p,"ModelInfo",()=>b),o(p,"EntityTag",()=>x);var d=s("2ptYq");let h=a.styled(d&&d.__esModule?d.default:d);function u(t,e){let n=[],a=[];for(let r of(null!=e&&(a=[e.id,...e.parents??[]]),t))n.push({start:r.indices[0],end:r.indices[1],text:r.name,backgroundColor:r.type?.color,tag:r.type?.name??"lith",id:r.id,parents:a,match:r.match}),n.push(...u(r.children??[],r));return n}function f(t,e,a){return{...t,model:e.get(t.model_id),entities:t.entities?.map(t=>(function t(e,a){return{...e,type:function(t,e=!1){let a=n(t.color??"#fff").brighten(e?1:2);return{...t,color:a.css()}}(a.get(e.type),null!=e.match),children:e.children?.map(e=>t(e,a))}})(t,a))}}function m(t,e={}){let a=n(t??"#fff"),{highlighted:o=!0,inDarkMode:i=r().isEnabled,active:l=!1}=e,c=o?.8:.5,s=o?.8:.2;l&&(c=1,s=1);let p="black",d=l?"#000":a.mix(p,c).hex(),h=o?a.mix(p,c/1.1).hex():"transparent",u=l?a.alpha(s).hex():function(t){let e=r().isEnabled?"#000000":"#ffffff",n=parseInt(t.slice(1,3),16),a=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16),i=parseInt(t.slice(7,9),16)/255,l=parseInt(e.slice(1,3),16),c=parseInt(e.slice(3,5),16),s=parseInt(e.slice(5,7),16),p=(t,e)=>Math.round((1-i)*e+i*t),d=p(n,l),h=p(a,c),u=p(o,s);return"#"+d.toString(16).padStart(2,"0")+h.toString(16).padStart(2,"0")+u.toString(16).padStart(2,"0")}(a.alpha(s).hex());return i||"#ffffff"!==u||(u="#f0f0f0"),{color:d,backgroundColor:u,boxSizing:"border-box",borderStyle:"solid",borderColor:h,borderWidth:"1.5px",fontWeight:l?"bold":"normal",fontSize:"0.9em"}}function g({data:t,entityTypes:e,matchComponent:n}){let a=u(t.entities,null);return h("div",[h("p",h($,{text:t.paragraph_text,highlights:a})),h(b,{data:t.model}),h("ul.entities",t.entities.map(t=>h(y,{data:t,matchComponent:n})))])}function b({data:t}){return h("p.model-name",["Model: ",h("code.bp5-code",t.name)])}function x({data:n,highlighted:a=!0,active:r=!1,onClickType:o,matchComponent:i=null}){let{name:l,type:c,match:s}=n,p=t({matched:null!=s,type:n.type?.name??"lith"},"entity"),d=m(c?.color,{highlighted:a,active:r}),u=null;return null!=s&&null!=i&&(u=h(i,{data:s})),h(e,{style:d,className:p},[h("span.entity-name",l)," ",h("code.entity-type.bp5-code",{onClick(t){r&&null!=o&&(o(c),t.stopPropagation())}},[c?.name,u])])}function y({data:t,matchComponent:e=null}){let n=t.children??[];return h("li.entity-row",[h(x,{data:t,matchComponent:e}),h.if(n.length>0)([h("ul.children",n.map(t=>h(y,{data:t,matchComponent:e})))])])}function $(t){let{text:e,highlights:n=[]}=t,a=[],r=0,o=n.sort((t,e)=>t.start-e.start);for(let t of o.map((t,e)=>{if(0===e)return t;let n=o[e-1];return t.start<n.end&&(t.start=n.end),t})){let{start:n,end:o,...i}=t;a.push(e.slice(r,n)),a.push(h("span.highlight",{style:i},e.slice(n,o))),r=o}return a.push(e.slice(r)),h("span",a)}export{u as buildHighlights,f as enhanceData,m as getTagStyle,g as ExtractionContext,b as ModelInfo,x as EntityTag};
2
+ //# sourceMappingURL=feedback-components.b22d37d1.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"A,M,oD,A,Q,M,Y,A,Q,O,C,K,mB,A,Q,iB,C,K,yB,A,Q,M,mB,A,Q,e,C,K,2B,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,kB,I,G,E,E,c,I,G,E,E,c,I,G,E,E,oB,I,G,E,E,Y,I,G,E,E,Y,I,G,I,E,E,SCWA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EACd,CAAqB,CACrB,CAAwB,EAExB,IAAI,EAAa,EAAE,CACf,EAAU,EAAE,CAKhB,IAAK,IAAM,KAJP,AAAU,MAAV,GACF,CAAA,EAAU,CAAC,EAAO,EAAE,IAAM,EAAO,OAAO,EAAI,EAAE,CAAE,AAAA,EAG7B,GACnB,EAAW,IAAI,CAAC,CACd,MAAO,EAAO,OAAO,CAAC,EAAE,CACxB,IAAK,EAAO,OAAO,CAAC,EAAE,CACtB,KAAM,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A,CAAe,GACpC,EAAE,EAAE,CAAC,EAAS,MAAM,CAAG,GAAG,CACxB,EACE,cACA,EAAS,GAAG,CAAC,AAAC,GAAM,EAAE,EAAgB,CAAE,KAAM,EAAG,eAAA,CAAe,KAEnE,EACF,CACH,CAEA,SAAS,EAAgB,CAAgD,EACvE,GAAM,CAAA,KAAE,CAAI,CAAA,WAAE,EAAa,EAAE,CAAE,CAAG,EAC5B,EAAQ,EAAE,CACZ,EAAQ,EAEN,EAAmB,EAAW,IAAI,CAAC,CAAC,EAAG,IAAM,EAAE,KAAK,CAAG,EAAE,KAAK,EAUpE,IAAK,IAAM,KAToB,EAAiB,GAAG,CAAC,CAAC,EAAW,KAC9D,GAAI,AAAM,IAAN,EAAS,OAAO,EACpB,IAAM,EAAO,CAAgB,CAAC,EAAI,EAAE,CAIpC,OAHI,EAAU,KAAK,CAAG,EAAK,GAAG,EAC5B,CAAA,EAAU,KAAK,CAAG,EAAK,GAAG,AAAH,EAElB,CACT,GAEgD,CAC9C,GAAM,CAAE,MAAO,CAAC,CAAA,IAAE,CAAG,CAAE,GAAG,EAAM,CAAG,EACnC,EAAM,IAAI,CAAC,EAAK,KAAK,CAAC,EAAO,IAC7B,EAAM,IAAI,CAAC,EAAE,iBAAkB,CAAE,MAAO,CAAK,EAAG,EAAK,KAAK,CAAC,EAAG,KAC9D,EAAQ,CACV,CAEA,OADA,EAAM,IAAI,CAAC,EAAK,KAAK,CAAC,IACf,EAAE,OAAQ,EACnB,Q,K,e,C,K,W,C,K,W,C,K,iB,C,K,S,C,K,S","sources":["<anon>","packages/feedback-components/src/extractions/index.ts"],"sourcesContent":["import \"./feedback-components.794f429b.js\";\nimport $78C1X$classnames from \"classnames\";\nimport {Tag as $78C1X$Tag} from \"@blueprintjs/core\";\nimport {asChromaColor as $78C1X$asChromaColor} from \"@macrostrat/color-utils\";\nimport $78C1X$macrostrathyper from \"@macrostrat/hyper\";\nimport {useDarkMode as $78C1X$useDarkMode} from \"@macrostrat/ui-components\";\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 $8c534c0378e15a46$exports = {};\n\n$parcel$export($8c534c0378e15a46$exports, \"buildHighlights\", () => $8c534c0378e15a46$export$c4b91360064ad200);\n$parcel$export($8c534c0378e15a46$exports, \"enhanceData\", () => $8c534c0378e15a46$export$d60b563f571177d);\n$parcel$export($8c534c0378e15a46$exports, \"getTagStyle\", () => $8c534c0378e15a46$export$35baa338324d8550);\n$parcel$export($8c534c0378e15a46$exports, \"ExtractionContext\", () => $8c534c0378e15a46$export$2b07158757c249e0);\n$parcel$export($8c534c0378e15a46$exports, \"ModelInfo\", () => $8c534c0378e15a46$export$4eb2a0ce903ce967);\n$parcel$export($8c534c0378e15a46$exports, \"EntityTag\", () => $8c534c0378e15a46$export$117e56c71b172cde);\n\nvar $2ptYq = parcelRequire(\"2ptYq\");\n\n\n\n\n\nconst $8c534c0378e15a46$var$h = (0, $78C1X$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($2ptYq))));\nfunction $8c534c0378e15a46$export$c4b91360064ad200(entities, parent) {\n let highlights = [];\n let parents = [];\n if (parent != null) parents = [\n parent.id,\n ...parent.parents ?? []\n ];\n for (const entity of entities){\n highlights.push({\n start: entity.indices[0],\n end: entity.indices[1],\n text: entity.name,\n backgroundColor: entity.type?.color,\n tag: entity.type?.name ?? \"lith\",\n id: entity.id,\n parents: parents,\n match: entity.match\n });\n highlights.push(...$8c534c0378e15a46$export$c4b91360064ad200(entity.children ?? [], entity));\n }\n return highlights;\n}\nfunction $8c534c0378e15a46$export$d60b563f571177d(extractionData, models, entityTypes) {\n return {\n ...extractionData,\n model: models.get(extractionData.model_id),\n entities: extractionData.entities?.map((d)=>$8c534c0378e15a46$var$enhanceEntity(d, entityTypes))\n };\n}\nfunction $8c534c0378e15a46$export$35baa338324d8550(baseColor, options = {}) {\n const _baseColor = (0, $78C1X$asChromaColor)(baseColor ?? \"#fff\");\n const { highlighted: highlighted = true, inDarkMode: inDarkMode = (0, $78C1X$useDarkMode)().isEnabled, active: active = false } = options;\n let mixAmount = highlighted ? 0.8 : 0.5;\n let backgroundAlpha = highlighted ? 0.8 : 0.2;\n if (active) {\n mixAmount = 1;\n backgroundAlpha = 1;\n }\n const mixTarget = \"black\";\n const color = active ? \"#000\" : _baseColor.mix(mixTarget, mixAmount).hex();\n const borderColor = highlighted ? _baseColor.mix(mixTarget, mixAmount / 1.1).hex() : \"transparent\";\n let backgroundColor = active ? _baseColor.alpha(backgroundAlpha).hex() : $8c534c0378e15a46$var$normalizeColor(_baseColor.alpha(backgroundAlpha).hex());\n // handle white backgrounds in light mode\n if (!inDarkMode && backgroundColor === \"#ffffff\") backgroundColor = \"#f0f0f0\";\n return {\n color: color,\n backgroundColor: backgroundColor,\n boxSizing: \"border-box\",\n borderStyle: \"solid\",\n borderColor: borderColor,\n borderWidth: \"1.5px\",\n fontWeight: active ? \"bold\" : \"normal\",\n fontSize: \"0.9em\"\n };\n}\nfunction $8c534c0378e15a46$var$enhanceEntity(entity, entityTypes) {\n return {\n ...entity,\n type: $8c534c0378e15a46$var$addColor(entityTypes.get(entity.type), entity.match != null),\n children: entity.children?.map((d)=>$8c534c0378e15a46$var$enhanceEntity(d, entityTypes))\n };\n}\nfunction $8c534c0378e15a46$var$addColor(entityType, match = false) {\n const color = (0, $78C1X$asChromaColor)(entityType.color ?? \"#fff\").brighten(match ? 1 : 2);\n return {\n ...entityType,\n color: color.css()\n };\n}\nfunction $8c534c0378e15a46$export$2b07158757c249e0({ data: data, entityTypes: entityTypes, matchComponent: matchComponent }) {\n const highlights = $8c534c0378e15a46$export$c4b91360064ad200(data.entities, null);\n return $8c534c0378e15a46$var$h(\"div\", [\n $8c534c0378e15a46$var$h(\"p\", $8c534c0378e15a46$var$h($8c534c0378e15a46$var$HighlightedText, {\n text: data.paragraph_text,\n highlights: highlights\n })),\n $8c534c0378e15a46$var$h($8c534c0378e15a46$export$4eb2a0ce903ce967, {\n data: data.model\n }),\n $8c534c0378e15a46$var$h(\"ul.entities\", data.entities.map((d)=>$8c534c0378e15a46$var$h($8c534c0378e15a46$var$ExtractionInfo, {\n data: d,\n matchComponent: matchComponent\n })))\n ]);\n}\nfunction $8c534c0378e15a46$export$4eb2a0ce903ce967({ data: data }) {\n return $8c534c0378e15a46$var$h(\"p.model-name\", [\n \"Model: \",\n $8c534c0378e15a46$var$h(\"code.bp5-code\", data.name)\n ]);\n}\nfunction $8c534c0378e15a46$export$117e56c71b172cde({ data: data, highlighted: highlighted = true, active: active = false, onClickType: onClickType, matchComponent: matchComponent = null }) {\n const { name: name, type: type, match: match } = data;\n const className = (0, $78C1X$classnames)({\n matched: match != null,\n type: data.type?.name ?? \"lith\"\n }, \"entity\");\n const style = $8c534c0378e15a46$export$35baa338324d8550(type?.color, {\n highlighted: highlighted,\n active: active\n });\n let _matchLink = null;\n if (match != null && matchComponent != null) _matchLink = $8c534c0378e15a46$var$h(matchComponent, {\n data: match\n });\n return $8c534c0378e15a46$var$h((0, $78C1X$Tag), {\n style: style,\n className: className\n }, [\n $8c534c0378e15a46$var$h(\"span.entity-name\", name),\n \" \",\n $8c534c0378e15a46$var$h(\"code.entity-type.bp5-code\", {\n onClick (evt) {\n if (active && onClickType != null) {\n onClickType(type);\n evt.stopPropagation();\n }\n }\n }, [\n type?.name,\n _matchLink\n ])\n ]);\n}\nfunction $8c534c0378e15a46$var$ExtractionInfo({ data: data, matchComponent: matchComponent = null }) {\n const children = data.children ?? [];\n return $8c534c0378e15a46$var$h(\"li.entity-row\", [\n $8c534c0378e15a46$var$h($8c534c0378e15a46$export$117e56c71b172cde, {\n data: data,\n matchComponent: matchComponent\n }),\n $8c534c0378e15a46$var$h.if(children.length > 0)([\n $8c534c0378e15a46$var$h(\"ul.children\", children.map((d)=>$8c534c0378e15a46$var$h($8c534c0378e15a46$var$ExtractionInfo, {\n data: d,\n matchComponent: matchComponent\n })))\n ])\n ]);\n}\nfunction $8c534c0378e15a46$var$HighlightedText(props) {\n const { text: text, highlights: highlights = [] } = props;\n const parts = [];\n let start = 0;\n const sortedHighlights = highlights.sort((a, b)=>a.start - b.start);\n const deconflictedHighlights = sortedHighlights.map((highlight, i)=>{\n if (i === 0) return highlight;\n const prev = sortedHighlights[i - 1];\n if (highlight.start < prev.end) highlight.start = prev.end;\n return highlight;\n });\n for (const highlight of deconflictedHighlights){\n const { start: s, end: end, ...rest } = highlight;\n parts.push(text.slice(start, s));\n parts.push($8c534c0378e15a46$var$h(\"span.highlight\", {\n style: rest\n }, text.slice(s, end)));\n start = end;\n }\n parts.push(text.slice(start));\n return $8c534c0378e15a46$var$h(\"span\", parts);\n}\nfunction $8c534c0378e15a46$var$normalizeColor(hex8) {\n const background = (0, $78C1X$useDarkMode)().isEnabled ? \"#000000\" : \"#ffffff\";\n const r = parseInt(hex8.slice(1, 3), 16);\n const g = parseInt(hex8.slice(3, 5), 16);\n const b = parseInt(hex8.slice(5, 7), 16);\n const a = parseInt(hex8.slice(7, 9), 16) / 255;\n const bgR = parseInt(background.slice(1, 3), 16);\n const bgG = parseInt(background.slice(3, 5), 16);\n const bgB = parseInt(background.slice(5, 7), 16);\n const blend = (fg, bg)=>Math.round((1 - a) * bg + a * fg);\n const blendedR = blend(r, bgR);\n const blendedG = blend(g, bgG);\n const blendedB = blend(b, bgB);\n return \"#\" + blendedR.toString(16).padStart(2, \"0\") + blendedG.toString(16).padStart(2, \"0\") + blendedB.toString(16).padStart(2, \"0\");\n}\nfunction $8c534c0378e15a46$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 {$8c534c0378e15a46$export$c4b91360064ad200 as buildHighlights, $8c534c0378e15a46$export$d60b563f571177d as enhanceData, $8c534c0378e15a46$export$35baa338324d8550 as getTagStyle, $8c534c0378e15a46$export$2b07158757c249e0 as ExtractionContext, $8c534c0378e15a46$export$4eb2a0ce903ce967 as ModelInfo, $8c534c0378e15a46$export$117e56c71b172cde as EntityTag};\n//# sourceMappingURL=feedback-components.b22d37d1.js.map\n","import styles from \"./main.module.sass\";\nimport classNames from \"classnames\";\nimport { Tag } from \"@blueprintjs/core\";\nimport type { Entity, EntityExt, Highlight, EntityType } from \"./types\";\nimport { CSSProperties } from \"react\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport hyper from \"@macrostrat/hyper\";\nimport { useDarkMode } from \"@macrostrat/ui-components\";\n\nexport type { Entity, EntityExt };\n\nconst h = hyper.styled(styles);\n\nexport function buildHighlights(\n entities: EntityExt[],\n parent: EntityExt | null,\n): Highlight[] {\n let highlights = [];\n let parents = [];\n if (parent != null) {\n parents = [parent.id, ...(parent.parents ?? [])];\n }\n\n for (const entity of entities) {\n highlights.push({\n start: entity.indices[0],\n end: entity.indices[1],\n text: entity.name,\n backgroundColor: entity.type?.color,\n tag: entity.type?.name ?? \"lith\",\n id: entity.id,\n parents,\n match: entity.match,\n });\n highlights.push(...buildHighlights(entity.children ?? [], entity));\n }\n return highlights;\n}\n\nexport function enhanceData(extractionData, models, entityTypes) {\n return {\n ...extractionData,\n model: models.get(extractionData.model_id),\n entities: extractionData.entities?.map((d) =>\n enhanceEntity(d, entityTypes),\n ),\n };\n}\n\nexport function getTagStyle(\n baseColor: string,\n options: {\n highlighted?: boolean;\n inDarkMode?: boolean;\n active?: boolean;\n showMatches?: boolean;\n } = {},\n): CSSProperties {\n const _baseColor = asChromaColor(baseColor ?? \"#fff\");\n const {\n highlighted = true,\n inDarkMode = useDarkMode().isEnabled,\n active = false,\n } = options;\n\n let mixAmount = highlighted ? 0.8 : 0.5;\n let backgroundAlpha = highlighted ? 0.8 : 0.2;\n\n if (active) {\n mixAmount = 1;\n backgroundAlpha = 1;\n }\n\n const mixTarget = \"black\";\n\n const color = active ? \"#000\" : _baseColor.mix(mixTarget, mixAmount).hex();\n const borderColor = highlighted\n ? _baseColor.mix(mixTarget, mixAmount / 1.1).hex()\n : \"transparent\";\n\n let backgroundColor = active\n ? _baseColor.alpha(backgroundAlpha).hex()\n : normalizeColor(_baseColor.alpha(backgroundAlpha).hex());\n\n // handle white backgrounds in light mode\n if (!inDarkMode && backgroundColor === \"#ffffff\") {\n backgroundColor = \"#f0f0f0\";\n }\n\n return {\n color,\n backgroundColor,\n boxSizing: \"border-box\",\n borderStyle: \"solid\",\n borderColor,\n borderWidth: \"1.5px\",\n fontWeight: active ? \"bold\" : \"normal\",\n fontSize: \"0.9em\",\n };\n}\n\nfunction enhanceEntity(\n entity: Entity,\n entityTypes: Map<number, EntityType>,\n): EntityExt {\n return {\n ...entity,\n type: addColor(entityTypes.get(entity.type), entity.match != null),\n children: entity.children?.map((d) => enhanceEntity(d, entityTypes)),\n };\n}\n\nfunction addColor(entityType: EntityType, match = false) {\n const color = asChromaColor(entityType.color ?? \"#fff\").brighten(\n match ? 1 : 2,\n );\n\n return { ...entityType, color: color.css() };\n}\n\nexport function ExtractionContext({\n data,\n entityTypes,\n matchComponent,\n}: {\n data: any;\n entityTypes: Map<number, EntityType>;\n matchComponent: MatchComponent;\n}) {\n const highlights = buildHighlights(data.entities, null);\n\n return h(\"div\", [\n h(\"p\", h(HighlightedText, { text: data.paragraph_text, highlights })),\n h(ModelInfo, { data: data.model }),\n h(\n \"ul.entities\",\n data.entities.map((d) => h(ExtractionInfo, { data: d, matchComponent })),\n ),\n ]);\n}\n\nexport function ModelInfo({ data }) {\n return h(\"p.model-name\", [\"Model: \", h(\"code.bp5-code\", data.name)]);\n}\n\nexport type MatchComponent = (props: { data: any }) => any;\n\ntype EntityTagProps = {\n data: EntityExt;\n highlighted?: boolean;\n active?: boolean;\n onClickType?: (type: EntityType) => void;\n matchComponent?: MatchComponent;\n};\n\nexport function EntityTag({\n data,\n highlighted = true,\n active = false,\n onClickType,\n matchComponent = null,\n}: EntityTagProps) {\n const { name, type, match } = data;\n\n const className = classNames(\n {\n matched: match != null,\n type: data.type?.name ?? \"lith\",\n },\n \"entity\",\n );\n\n const style = getTagStyle(type?.color, { highlighted, active });\n\n let _matchLink = null;\n if (match != null && matchComponent != null) {\n _matchLink = h(matchComponent, { data: match });\n }\n\n return h(Tag, { style, className }, [\n h(\"span.entity-name\", name),\n \" \",\n h(\n \"code.entity-type.bp5-code\",\n {\n onClick(evt) {\n if (active && onClickType != null) {\n onClickType(type);\n evt.stopPropagation();\n }\n },\n },\n [type?.name, _matchLink],\n ),\n ]);\n}\n\nfunction ExtractionInfo({\n data,\n matchComponent = null,\n}: {\n data: EntityExt;\n matchComponent: MatchComponent;\n}) {\n const children = data.children ?? [];\n\n return h(\"li.entity-row\", [\n h(EntityTag, { data, matchComponent }),\n h.if(children.length > 0)([\n h(\n \"ul.children\",\n children.map((d) => h(ExtractionInfo, { data: d, matchComponent })),\n ),\n ]),\n ]);\n}\n\nfunction HighlightedText(props: { text: string; highlights: Highlight[] }) {\n const { text, highlights = [] } = props;\n const parts = [];\n let start = 0;\n\n const sortedHighlights = highlights.sort((a, b) => a.start - b.start);\n const deconflictedHighlights = sortedHighlights.map((highlight, i) => {\n if (i === 0) return highlight;\n const prev = sortedHighlights[i - 1];\n if (highlight.start < prev.end) {\n highlight.start = prev.end;\n }\n return highlight;\n });\n\n for (const highlight of deconflictedHighlights) {\n const { start: s, end, ...rest } = highlight;\n parts.push(text.slice(start, s));\n parts.push(h(\"span.highlight\", { style: rest }, text.slice(s, end)));\n start = end;\n }\n parts.push(text.slice(start));\n return h(\"span\", parts);\n}\n\nfunction normalizeColor(hex8) {\n const background = useDarkMode().isEnabled ? \"#000000\" : \"#ffffff\";\n\n const r = parseInt(hex8.slice(1, 3), 16);\n const g = parseInt(hex8.slice(3, 5), 16);\n const b = parseInt(hex8.slice(5, 7), 16);\n const a = parseInt(hex8.slice(7, 9), 16) / 255;\n\n const bgR = parseInt(background.slice(1, 3), 16);\n const bgG = parseInt(background.slice(3, 5), 16);\n const bgB = parseInt(background.slice(5, 7), 16);\n\n const blend = (fg, bg) => Math.round((1 - a) * bg + a * fg);\n\n const blendedR = blend(r, bgR);\n const blendedG = blend(g, bgG);\n const blendedB = blend(b, bgB);\n\n return (\n \"#\" +\n blendedR.toString(16).padStart(2, \"0\") +\n blendedG.toString(16).padStart(2, \"0\") +\n blendedB.toString(16).padStart(2, \"0\")\n );\n}\n\nfunction isHighlighted(id: number, selectedNodes: number[], nodes: any[]) {\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":["$78C1X$classnames","Tag","$78C1X$Tag","asChromaColor","$78C1X$asChromaColor","$78C1X$macrostrathyper","useDarkMode","$78C1X$useDarkMode","$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","$8c534c0378e15a46$exports","$8c534c0378e15a46$export$c4b91360064ad200","$8c534c0378e15a46$export$d60b563f571177d","$8c534c0378e15a46$export$35baa338324d8550","$8c534c0378e15a46$export$2b07158757c249e0","$8c534c0378e15a46$export$4eb2a0ce903ce967","$8c534c0378e15a46$export$117e56c71b172cde","$2ptYq","$8c534c0378e15a46$var$h","styled","a","__esModule","default","entities","parent","highlights","parents","entity","push","start","indices","end","text","name","backgroundColor","type","color","tag","match","children","extractionData","models","entityTypes","model","model_id","map","d","$8c534c0378e15a46$var$enhanceEntity","$8c534c0378e15a46$var$addColor","entityType","brighten","css","baseColor","options","_baseColor","highlighted","inDarkMode","isEnabled","active","mixAmount","backgroundAlpha","mixTarget","mix","hex","borderColor","alpha","$8c534c0378e15a46$var$normalizeColor","hex8","background","r","parseInt","slice","g","b","bgR","bgG","bgB","blend","fg","bg","Math","round","blendedR","blendedG","blendedB","toString","padStart","boxSizing","borderStyle","borderWidth","fontWeight","fontSize","data","matchComponent","$8c534c0378e15a46$var$HighlightedText","paragraph_text","$8c534c0378e15a46$var$ExtractionInfo","onClickType","className","matched","style","_matchLink","onClick","evt","stopPropagation","if","length","props","parts","sortedHighlights","sort","highlight","i","prev","rest","buildHighlights","enhanceData","getTagStyle","ExtractionContext","ModelInfo","EntityTag"],"version":3,"file":"feedback-components.b22d37d1.js.map","sourceRoot":"../../../../"}
@@ -0,0 +1,2 @@
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
@@ -0,0 +1 @@
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 +1,2 @@
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}
2
- /*# sourceMappingURL=feedback-components.c88cb37f.css.map */
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 */
@@ -0,0 +1 @@
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":"../../../../"}