@macrostrat/feedback-components 1.1.3 → 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 (62) hide show
  1. package/CHANGELOG.md +5 -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.f577ebea.js → feedback-components.1c15f37f.js} +32 -24
  5. package/dist/esm/feedback-components.1c15f37f.js.map +1 -0
  6. package/dist/esm/{feedback-components.1e7da538.js → feedback-components.204f7d2b.js} +23 -281
  7. package/dist/esm/feedback-components.204f7d2b.js.map +1 -0
  8. package/dist/esm/{feedback-components.832b2eae.js → feedback-components.28ba71be.js} +5 -5
  9. package/dist/esm/{feedback-components.832b2eae.js.map → feedback-components.28ba71be.js.map} +1 -1
  10. package/dist/esm/feedback-components.7e879290.js +286 -0
  11. package/dist/esm/feedback-components.7e879290.js.map +1 -0
  12. package/dist/esm/{feedback-components.45d25912.js → feedback-components.d55a1d18.js} +5 -5
  13. package/dist/esm/{feedback-components.45d25912.js.map → feedback-components.d55a1d18.js.map} +1 -1
  14. package/dist/esm/{feedback-components.fb60c70d.css → feedback-components.d591ffec.css} +20 -1
  15. package/dist/esm/feedback-components.d591ffec.css.map +1 -0
  16. package/dist/esm/{feedback-components.fa1d3641.js → feedback-components.f6605b83.js} +49 -7
  17. package/dist/esm/feedback-components.f6605b83.js.map +1 -0
  18. package/dist/esm/feedback-components.fd8ac9ca.js +230 -0
  19. package/dist/esm/feedback-components.fd8ac9ca.js.map +1 -0
  20. package/dist/esm/index.d.ts.map +1 -1
  21. package/dist/esm/index.js +1 -1
  22. package/dist/node/feedback-components.0eef8d0c.js +2 -0
  23. package/dist/node/feedback-components.0eef8d0c.js.map +1 -0
  24. package/dist/node/{feedback-components.f9abf0d6.js → feedback-components.2f740fc7.js} +2 -2
  25. package/dist/node/{feedback-components.f9abf0d6.js.map → feedback-components.2f740fc7.js.map} +1 -1
  26. package/dist/node/{feedback-components.4cd6b208.js → feedback-components.41db283a.js} +2 -2
  27. package/dist/node/{feedback-components.4cd6b208.js.map → feedback-components.41db283a.js.map} +1 -1
  28. package/dist/node/feedback-components.69d0ccd0.js +2 -0
  29. package/dist/node/feedback-components.69d0ccd0.js.map +1 -0
  30. package/dist/node/feedback-components.a7b43cfa.js +2 -0
  31. package/dist/node/feedback-components.a7b43cfa.js.map +1 -0
  32. package/dist/node/feedback-components.b9317f9c.js +2 -0
  33. package/dist/node/feedback-components.b9317f9c.js.map +1 -0
  34. package/dist/node/{feedback-components.c88cb37f.css → feedback-components.e096504e.css} +2 -2
  35. package/dist/node/feedback-components.e096504e.css.map +1 -0
  36. package/dist/node/feedback-components.e140ac86.js +2 -0
  37. package/dist/node/feedback-components.e140ac86.js.map +1 -0
  38. package/dist/node/feedback-components.f8373b58.js +2 -0
  39. package/dist/node/feedback-components.f8373b58.js.map +1 -0
  40. package/dist/node/index.js +1 -1
  41. package/dist/node/index.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/feedback/edit-state.ts +52 -3
  44. package/src/feedback/feedback.module.sass +17 -1
  45. package/src/feedback/index.ts +11 -317
  46. package/src/feedback/matches.ts +241 -0
  47. package/src/feedback/text-visualizer.ts +21 -21
  48. package/src/feedback/typelist.ts +312 -0
  49. package/dist/esm/feedback-components.1e7da538.js.map +0 -1
  50. package/dist/esm/feedback-components.95dbe7d7.js.map +0 -1
  51. package/dist/esm/feedback-components.f577ebea.js.map +0 -1
  52. package/dist/esm/feedback-components.fa1d3641.js.map +0 -1
  53. package/dist/esm/feedback-components.fb60c70d.css.map +0 -1
  54. package/dist/node/feedback-components.25f1909a.js +0 -2
  55. package/dist/node/feedback-components.25f1909a.js.map +0 -1
  56. package/dist/node/feedback-components.9328e8ba.js +0 -2
  57. package/dist/node/feedback-components.9328e8ba.js.map +0 -1
  58. package/dist/node/feedback-components.b7946db4.js +0 -2
  59. package/dist/node/feedback-components.b7946db4.js.map +0 -1
  60. package/dist/node/feedback-components.c459cc27.js +0 -2
  61. package/dist/node/feedback-components.c459cc27.js.map +0 -1
  62. package/dist/node/feedback-components.c88cb37f.css.map +0 -1
@@ -1 +1 @@
1
- {"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,mB,C,C,a,C,C,iB,C,C,e,C,C,gB,C,K,U,A,Q,Y,C,C,a,C,K,O,A,Q,W,C,C,U,C,K,mB,A,Q,iB,C,K,2B,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,E,S,E,E,S,E,E,SCkBA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAU,CAMzB,EAGC,GAAM,CAAA,KAAE,CAAI,CAAA,MAAE,CAAK,CAAA,OAAE,CAAM,CAAA,SAAE,CAAQ,CAAA,cAAE,CAAa,CAAE,CAAG,EAEnD,CAAC,EAAO,EAAS,CAAG,AAAA,EAAgC,MACpD,CAAC,EAAO,EAAS,CAAG,AAAA,EAAgC,MACpD,CAAC,EAAY,EAAc,CAAG,AAAA,EAAS,CAAA,SAsC7C,CApCA,AAAA,EAAU,KACR,GAAM,CAAA,MAAE,CAAK,CAAA,MAAE,CAAK,CAAE,CAAG,AAAA,CAAA,EAAA,EAAA,WAAU,AAAV,EAAY,GAE/B,EAAW,IAAI,IACnB,EAAM,GAAG,CAAC,AAAC,GAAM,CAAC,EAAE,EAAE,CAAE,EAAE,GAGtB,EAAQ,EAAM,GAAG,CAAC,AAAC,GAChB,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./feedback-components.b7946db4.js\";\nimport \"./feedback-components.c459cc27.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.4cd6b208.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.4cd6b208.js.map","sourceRoot":"../../../../"}
1
+ {"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,mB,C,C,a,C,C,iB,C,C,e,C,C,gB,C,K,U,A,Q,Y,C,C,a,C,K,O,A,Q,W,C,C,U,C,K,mB,A,Q,iB,C,K,2B,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,E,S,E,E,S,E,E,SCkBA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAU,CAMzB,EAGC,GAAM,CAAA,KAAE,CAAI,CAAA,MAAE,CAAK,CAAA,OAAE,CAAM,CAAA,SAAE,CAAQ,CAAA,cAAE,CAAa,CAAE,CAAG,EAEnD,CAAC,EAAO,EAAS,CAAG,AAA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,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,E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e,GACb,EAAW,OAAO,EACpB,OAAO,IAAI,CAAC,EAAW,OAAO,CAAG,IAAM,EAAK,UAAU,CAAE,SAE5D,CACF,EACF,GACD,CAAA,EAGC,EAAK,WAAW,EAClB,CAAA,EAAM,EAAE,EAAW,CACjB,MAAO,sBACP,MAAO,EAAE,EAAc,CACrB,KAAM,CAAE,KAAM,EAAK,IAAI,CAAE,GAAI,EAAK,WAAW,AAAC,EAC9C,QAAS,AAAC,IACR,EAAE,eAAe,GACb,EAAW,QAAQ,EACrB,OAAO,IAAI,CAAC,EAAW,QAAQ,CAAG,IAAM,EAAK,WAAW,CAAE,SAE9D,CACF,EACF,EAAA,EAGK,EAAE,sBAAuB,CAC9B,EACA,EAAE,EAAM,CACN,KAAM,QACN,MAAO,MACP,UAAW,YACX,QAAS,KACP,EAAS,CAAE,KAAM,eAAgB,QAAS,CAAE,GAAI,CAAO,CAAE,EAC3D,CACF,GACD,CACH,Q,K,Y,C,K,e,C,K,K","sources":["<anon>","packages/feedback-components/src/feedback/text-visualizer.ts"],"sourcesContent":["import \"./feedback-components.b9317f9c.js\";\nimport \"./feedback-components.b22d37d1.js\";\nimport $h8ona$macrostrathyper from \"@macrostrat/hyper\";\nimport {useRef as $h8ona$useRef, useEffect as $h8ona$useEffect} from \"react\";\nimport {Icon as $h8ona$Icon} from \"@blueprintjs/core\";\nimport {JSONView as $h8ona$JSONView, DataField as $h8ona$DataField} from \"@macrostrat/ui-components\";\nimport {LithologyTag as $h8ona$LithologyTag} from \"@macrostrat/data-components\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\n\n\n\nconst $d6cf457c7790c03a$var$h = (0, $h8ona$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $d6cf457c7790c03a$var$buildTags(highlights, selectedNodes) {\n let tags = [];\n // If entity ID has already been seen, don't add it again\n const entities = new Set();\n for (const highlight of highlights){\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n const highlighted = $d6cf457c7790c03a$var$isHighlighted(highlight, selectedNodes);\n const active = $d6cf457c7790c03a$var$isActive(highlight, selectedNodes);\n const tagStyle = (0, $edvRb.getTagStyle)(highlight.backgroundColor, {\n highlighted: highlighted,\n active: active\n });\n const tag = {\n color: tagStyle.color,\n tagStyle: {\n display: \"none\"\n },\n markStyle: {\n backgroundColor: tagStyle.backgroundColor\n },\n ...highlight,\n backgroundColor: tagStyle.backgroundColor\n };\n tags.push(tag);\n entities.add(highlight.id);\n }\n return tags;\n}\nfunction $d6cf457c7790c03a$var$isActive(tag, selectedNodes) {\n return selectedNodes.includes(tag.id);\n}\nfunction $d6cf457c7790c03a$var$isHighlighted(tag, selectedNodes) {\n if (selectedNodes.length === 0) return true;\n return (selectedNodes.includes(tag.id) || tag.parents?.some((d)=>selectedNodes.includes(d))) ?? false;\n}\nfunction $d6cf457c7790c03a$export$6e107db9091b8219(props) {\n // Convert input to tags\n const { text: text, selectedNodes: selectedNodes, nodes: nodes, dispatch: dispatch, allowOverlap: allowOverlap, matchLinks: matchLinks } = props;\n const allTags = $d6cf457c7790c03a$var$buildTags((0, $edvRb.buildHighlights)(nodes, null), selectedNodes);\n return $d6cf457c7790c03a$var$h(\"div.feedback-text-wrapper\", {\n tabIndex: 0,\n onKeyDown: (e)=>{\n if (e.key === \"Backspace\") dispatch({\n type: \"delete-node\",\n payload: {\n ids: selectedNodes\n }\n });\n }\n }, $d6cf457c7790c03a$var$h($d6cf457c7790c03a$export$190465bec6b893be, {\n text: text,\n allTags: allTags,\n allowOverlap: allowOverlap,\n dispatch: dispatch,\n selectedNodes: selectedNodes,\n matchLinks: matchLinks\n }));\n}\nfunction $d6cf457c7790c03a$var$createTagFromSelection({ container: container }) {\n const selection = window.getSelection();\n if (!selection || selection.isCollapsed || selection.rangeCount === 0 || !container) return null;\n const range = selection.getRangeAt(0);\n if (!container.contains(range.startContainer) || !container.contains(range.endContainer)) return null;\n const preRange = document.createRange();\n preRange.setStart(container, 0);\n preRange.setEnd(range.startContainer, range.startOffset);\n const start = preRange.toString().length;\n const selectedText = range.toString();\n const end = start + selectedText.length;\n return {\n start: start,\n end: end,\n text: selectedText\n };\n}\nfunction $d6cf457c7790c03a$var$addTag({ tag: tag, dispatch: dispatch, text: text, allTags: allTags, allowOverlap: allowOverlap }) {\n let { start: start, end: end } = tag;\n // snap to text\n if (text[end - 1] != \" \") {\n // double clicking word overselects by one, shouldn't increase to next word\n while(start > 0 && /\\w/.test(text[start - 1]))start--;\n while(end < text.length && /\\w/.test(text[end]))end++;\n }\n let payload = {\n start: start,\n end: end,\n text: text.slice(start, end)\n };\n if (payload.text.trim() === \"\") {\n console.log(\"Blank tag found, ignoring\");\n return;\n }\n const duplicate = allTags.find((t)=>t.start === payload.start && (t.end === payload.end || t.end === payload.end - 1));\n if (duplicate) {\n console.log(\"Duplicate tag found, ignoring\");\n return;\n }\n if (payload.text.endsWith(\" \")) {\n payload.text = payload.text.slice(0, -1);\n payload.end -= 1;\n }\n const inside = allTags.some((t)=>t.start <= payload.start && t.end >= payload.end);\n const overlap = allTags.some((t)=>t.start < payload.end && t.end > payload.start);\n if ((inside || overlap) && !allowOverlap) {\n console.log(\"Tag is inside another tag, ignoring\");\n return;\n }\n dispatch({\n type: \"create-node\",\n payload: payload\n });\n}\nfunction $d6cf457c7790c03a$var$nestHighlights(text, tags) {\n const events = [];\n for (const tag of tags){\n events.push({\n pos: tag.start,\n type: \"start\",\n tag: tag\n });\n events.push({\n pos: tag.end,\n type: \"end\",\n tag: tag\n });\n }\n events.sort((a, b)=>{\n if (a.pos !== b.pos) return a.pos - b.pos;\n if (a.type === \"end\" && b.type === \"start\") return -1;\n if (a.type === \"start\" && b.type === \"end\") return 1;\n return 0;\n });\n const root = {\n children: [],\n textStart: 0\n };\n const stack = [\n root\n ];\n let lastPos = 0;\n for (const { pos: pos, type: type, tag: tag } of events){\n const parent = stack[stack.length - 1];\n if (pos > lastPos) {\n const slice = text.slice(lastPos, pos);\n parent.children.push(slice);\n }\n if (type === \"start\") {\n const newNode = {\n tag: tag,\n children: [],\n textStart: pos\n };\n parent.children.push(newNode);\n stack.push(newNode);\n } else stack.pop();\n lastPos = pos;\n }\n if (lastPos < text.length) stack[stack.length - 1].children.push(text.slice(lastPos));\n return root;\n}\nfunction $d6cf457c7790c03a$var$renderNode(node, dispatch, selectedNodes, parentSelected, matchLinks) {\n if (typeof node === \"string\") return node;\n const { tag: tag, children: children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n const showBorder = selectedNodes.length === 0 || isSelected;\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1,\n border: \"1px solid \" + (showBorder ? tag.color : \"transparent\"),\n margin: \"-1px\"\n };\n let moveText = [];\n if (isSelected) {\n for(const key in children)if (Object.prototype.hasOwnProperty.call(children, key)) {\n const child = children[key];\n if (child?.tag) moveText.push(child.children[0]);\n else moveText.push(child);\n }\n }\n return $d6cf457c7790c03a$var$h(\"span\", {\n onMouseEnter: (e)=>{\n e.stopPropagation();\n },\n className: \"highlight\",\n style: style,\n onClick: (e)=>{\n e.stopPropagation();\n if (e.ctrlKey || e.metaKey || selectedNodes[0] === tag.id && selectedNodes.length === 1) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: [\n tag.id\n ]\n }\n });\n } else if (e.shiftKey && selectedNodes.length > 0) {\n // Select range from last selected node to this one\n const lastSelected = selectedNodes[selectedNodes.length - 1];\n dispatch({\n type: \"select-range\",\n payload: {\n ids: [\n lastSelected,\n tag.id\n ]\n }\n });\n } else dispatch({\n type: \"select-node\",\n payload: {\n ids: [\n tag.id\n ]\n }\n });\n }\n }, isSelected ? moveText.flat() : children.map((child, i)=>$d6cf457c7790c03a$var$renderNode(child, dispatch, selectedNodes, isSelected, matchLinks)));\n}\nfunction $d6cf457c7790c03a$export$190465bec6b893be(props) {\n const { text: text, allTags: allTags = [], dispatch: dispatch, selectedNodes: selectedNodes, allowOverlap: allowOverlap, matchLinks: matchLinks } = props;\n const tree = $d6cf457c7790c03a$var$nestHighlights(text, allTags);\n const spanRef = (0, $h8ona$useRef)(null);\n (0, $h8ona$useEffect)(()=>{\n const handleMouseUp = ()=>{\n const tag = $d6cf457c7790c03a$var$createTagFromSelection({\n container: spanRef.current\n });\n if (!tag) return;\n $d6cf457c7790c03a$var$addTag({\n tag: tag,\n dispatch: dispatch,\n text: text,\n allTags: allTags,\n allowOverlap: allowOverlap\n });\n };\n document.addEventListener(\"mouseup\", handleMouseUp);\n return ()=>{\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [\n text,\n allTags,\n dispatch,\n allowOverlap\n ]);\n return $d6cf457c7790c03a$var$h(\"span\", {\n ref: spanRef\n }, tree.children.map((child, i)=>$d6cf457c7790c03a$var$renderNode(child, dispatch, selectedNodes, false, matchLinks)));\n}\nfunction $d6cf457c7790c03a$export$f421feb8fad20413({ data: data, matchLinks: matchLinks, dispatch: dispatch, nodeId: nodeId }) {\n if (!data || Object.keys(data).length === 0) return;\n let tag = $d6cf457c7790c03a$var$h((0, $h8ona$JSONView), {\n data: data\n });\n if (data.lith_id) tag = $d6cf457c7790c03a$var$h((0, $h8ona$DataField), {\n label: \"Lithology\",\n value: $d6cf457c7790c03a$var$h((0, $h8ona$LithologyTag), {\n data: {\n name: data.name,\n id: data.lith_id,\n color: data.color\n },\n onClick: (e)=>{\n e.stopPropagation();\n if (matchLinks.lithology) window.open(matchLinks.lithology + \"/\" + data.lith_id, \"_blank\");\n }\n })\n });\n if (data.strat_name_id) tag = $d6cf457c7790c03a$var$h(\"div\", [\n $d6cf457c7790c03a$var$h((0, $h8ona$DataField), {\n label: \"Stratigraphic name\",\n value: $d6cf457c7790c03a$var$h((0, $h8ona$LithologyTag), {\n data: {\n name: data.name,\n id: data.strat_name_id,\n color: data.color\n },\n onClick: (e)=>{\n e.stopPropagation();\n if (matchLinks.strat_name) window.open(matchLinks.strat_name + \"/\" + data.strat_name_id, \"_blank\");\n }\n })\n }),\n $d6cf457c7790c03a$var$h.if(data.concept_id)((0, $h8ona$DataField), {\n label: \"Stratigraphic concept\",\n value: $d6cf457c7790c03a$var$h((0, $h8ona$LithologyTag), {\n data: {\n name: data.name,\n id: data.concept_id,\n color: data.color\n },\n onClick: (e)=>{\n e.stopPropagation();\n if (matchLinks.concept) window.open(matchLinks.concept + \"/\" + data.concept_id, \"_blank\");\n }\n })\n })\n ]);\n if (data.lith_att_id) tag = $d6cf457c7790c03a$var$h((0, $h8ona$DataField), {\n label: \"Lithology attribute\",\n value: $d6cf457c7790c03a$var$h((0, $h8ona$LithologyTag), {\n data: {\n name: data.name,\n id: data.lith_att_id\n },\n onClick: (e)=>{\n e.stopPropagation();\n if (matchLinks.lith_att) window.open(matchLinks.lith_att + \"/\" + data.lith_att_id, \"_blank\");\n }\n })\n });\n return $d6cf457c7790c03a$var$h(\"div.match-container\", [\n tag,\n $d6cf457c7790c03a$var$h((0, $h8ona$Icon), {\n icon: \"cross\",\n color: \"red\",\n className: \"close-btn\",\n onClick: ()=>{\n dispatch({\n type: \"remove-match\",\n payload: {\n id: nodeId\n }\n });\n }\n })\n ]);\n}\n\n\nexport {$d6cf457c7790c03a$export$6e107db9091b8219 as FeedbackText, $d6cf457c7790c03a$export$190465bec6b893be as HighlightedText, $d6cf457c7790c03a$export$f421feb8fad20413 as Match};\n//# sourceMappingURL=feedback-components.69d0ccd0.js.map\n","import { AnnotateBlendTag } from \"react-text-annotate-blend\";\nimport { InternalEntity } from \"./types\";\nimport { TreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { buildHighlights, getTagStyle } from \"../extractions\";\nimport { Highlight } from \"../extractions/types\";\nimport { useEffect, useRef } from \"react\";\nimport { Icon } from \"@blueprintjs/core\";\nimport { DataField, JSONView } from \"@macrostrat/ui-components\";\nimport { LithologyList, LithologyTag } from \"@macrostrat/data-components\";\n\nconst h = hyper.styled(styles);\n\nexport interface FeedbackTextProps {\n text: string;\n selectedNodes: number[];\n nodes: InternalEntity[];\n updateNodes: (nodes: string[]) => void;\n dispatch: TreeDispatch;\n lineHeight: string;\n allowOverlap?: boolean;\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n };\n}\n\nfunction buildTags(\n highlights: Highlight[],\n selectedNodes: number[],\n): AnnotateBlendTag[] {\n let tags: AnnotateBlendTag[] = [];\n // If entity ID has already been seen, don't add it again\n const entities = new Set<number>();\n\n for (const highlight of highlights) {\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n\n const highlighted = isHighlighted(highlight, selectedNodes);\n const active = isActive(highlight, selectedNodes);\n const tagStyle = getTagStyle(highlight.backgroundColor, {\n highlighted,\n active,\n });\n\n const tag = {\n color: tagStyle.color,\n tagStyle: {\n display: \"none\",\n },\n markStyle: {\n backgroundColor: tagStyle.backgroundColor,\n },\n ...highlight,\n backgroundColor: tagStyle.backgroundColor,\n };\n\n tags.push(tag);\n\n entities.add(highlight.id);\n }\n\n return tags;\n}\n\nfunction isActive(tag: Highlight, selectedNodes: number[]) {\n return selectedNodes.includes(tag.id);\n}\n\nfunction isHighlighted(tag: Highlight, selectedNodes: number[]) {\n if (selectedNodes.length === 0) return true;\n return (\n (selectedNodes.includes(tag.id) ||\n tag.parents?.some((d) => selectedNodes.includes(d))) ??\n false\n );\n}\n\nexport function FeedbackText(props: FeedbackTextProps) {\n // Convert input to tags\n const { text, selectedNodes, nodes, dispatch, allowOverlap, matchLinks } =\n props;\n const allTags: AnnotateBlendTag[] = buildTags(\n buildHighlights(nodes, null),\n selectedNodes,\n );\n\n return h(\n \"div.feedback-text-wrapper\",\n {\n tabIndex: 0,\n onKeyDown: (e) => {\n if (e.key === \"Backspace\") {\n dispatch({\n type: \"delete-node\",\n payload: { ids: selectedNodes },\n });\n }\n },\n },\n h(HighlightedText, {\n text,\n allTags,\n allowOverlap,\n dispatch,\n selectedNodes,\n matchLinks,\n }),\n );\n}\n\nfunction createTagFromSelection({\n container,\n}: {\n container: HTMLElement | null;\n}) {\n const selection = window.getSelection();\n if (\n !selection ||\n selection.isCollapsed ||\n selection.rangeCount === 0 ||\n !container\n )\n return null;\n\n const range = selection.getRangeAt(0);\n\n if (\n !container.contains(range.startContainer) ||\n !container.contains(range.endContainer)\n ) {\n return null;\n }\n\n const preRange = document.createRange();\n preRange.setStart(container, 0);\n preRange.setEnd(range.startContainer, range.startOffset);\n const start = preRange.toString().length;\n\n const selectedText = range.toString();\n const end = start + selectedText.length;\n\n return {\n start,\n end,\n text: selectedText,\n };\n}\n\nfunction addTag({ tag, dispatch, text, allTags, allowOverlap }) {\n let { start, end } = tag;\n // snap to text\n if (text[end - 1] != \" \") {\n // double clicking word overselects by one, shouldn't increase to next word\n while (start > 0 && /\\w/.test(text[start - 1])) {\n start--;\n }\n while (end < text.length && /\\w/.test(text[end])) {\n end++;\n }\n }\n\n let payload = { start, end, text: text.slice(start, end) };\n\n if (payload.text.trim() === \"\") {\n console.log(\"Blank tag found, ignoring\");\n return;\n }\n\n const duplicate = allTags.find(\n (t) =>\n t.start === payload.start &&\n (t.end === payload.end || t.end === payload.end - 1),\n );\n\n if (duplicate) {\n console.log(\"Duplicate tag found, ignoring\");\n return;\n }\n\n if (payload.text.endsWith(\" \")) {\n payload.text = payload.text.slice(0, -1);\n payload.end -= 1;\n }\n\n const inside = allTags.some(\n (t) => t.start <= payload.start && t.end >= payload.end,\n );\n\n const overlap = allTags.some(\n (t) => t.start < payload.end && t.end > payload.start,\n );\n\n if ((inside || overlap) && !allowOverlap) {\n console.log(\"Tag is inside another tag, ignoring\");\n return;\n }\n\n dispatch({ type: \"create-node\", payload });\n}\n\nfunction nestHighlights(text: string, tags: AnnotateBlendTag[]) {\n const events: Array<{\n pos: number;\n type: \"start\" | \"end\";\n tag: AnnotateBlendTag;\n }> = [];\n\n for (const tag of tags) {\n events.push({ pos: tag.start, type: \"start\", tag });\n events.push({ pos: tag.end, type: \"end\", tag });\n }\n\n events.sort((a, b) => {\n if (a.pos !== b.pos) return a.pos - b.pos;\n if (a.type === \"end\" && b.type === \"start\") return -1;\n if (a.type === \"start\" && b.type === \"end\") return 1;\n return 0;\n });\n\n const root = { children: [], textStart: 0 };\n const stack = [root];\n let lastPos = 0;\n\n for (const { pos, type, tag } of events) {\n const parent = stack[stack.length - 1];\n\n if (pos > lastPos) {\n const slice = text.slice(lastPos, pos);\n parent.children.push(slice);\n }\n\n if (type === \"start\") {\n const newNode = { tag, children: [], textStart: pos };\n parent.children.push(newNode);\n stack.push(newNode);\n } else {\n stack.pop();\n }\n\n lastPos = pos;\n }\n\n if (lastPos < text.length) {\n stack[stack.length - 1].children.push(text.slice(lastPos));\n }\n\n return root;\n}\n\nfunction renderNode(\n node: any,\n dispatch: TreeDispatch,\n selectedNodes: number[],\n parentSelected: boolean,\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n },\n): any {\n if (typeof node === \"string\") return node;\n\n const { tag, children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n const showBorder = selectedNodes.length === 0 || isSelected;\n\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1,\n border: \"1px solid \" + (showBorder ? tag.color : \"transparent\"),\n margin: \"-1px\",\n };\n\n let moveText = [];\n if (isSelected) {\n for (const key in children) {\n if (Object.prototype.hasOwnProperty.call(children, key)) {\n const child = children[key];\n if (child?.tag) {\n moveText.push(child.children[0]);\n } else {\n moveText.push(child);\n }\n }\n }\n }\n\n return h(\n \"span\",\n {\n onMouseEnter: (e: MouseEvent) => {\n e.stopPropagation();\n },\n className: \"highlight\",\n style,\n onClick: (e: MouseEvent) => {\n e.stopPropagation();\n if (\n e.ctrlKey ||\n e.metaKey ||\n (selectedNodes[0] === tag.id && selectedNodes.length === 1)\n ) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [tag.id] },\n });\n } else if (e.shiftKey && selectedNodes.length > 0) {\n // Select range from last selected node to this one\n const lastSelected = selectedNodes[selectedNodes.length - 1];\n\n dispatch({\n type: \"select-range\",\n payload: { ids: [lastSelected, tag.id] },\n });\n } else {\n dispatch({\n type: \"select-node\",\n payload: { ids: [tag.id] },\n });\n }\n },\n },\n isSelected\n ? moveText.flat()\n : children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, isSelected, matchLinks),\n ),\n );\n}\n\nexport function HighlightedText(props: {\n text: string;\n allTags: AnnotateBlendTag[];\n lineHeight: string;\n allowOverlap?: boolean;\n dispatch: TreeDispatch;\n selectedNodes: number[];\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n };\n}) {\n const {\n text,\n allTags = [],\n dispatch,\n selectedNodes,\n allowOverlap,\n matchLinks,\n } = props;\n\n const tree = nestHighlights(text, allTags);\n\n const spanRef = useRef<HTMLSpanElement>(null);\n\n useEffect(() => {\n const handleMouseUp = () => {\n const tag = createTagFromSelection({ container: spanRef.current });\n if (!tag) return;\n addTag({ tag, dispatch, text, allTags, allowOverlap });\n };\n\n document.addEventListener(\"mouseup\", handleMouseUp);\n return () => {\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [text, allTags, dispatch, allowOverlap]);\n\n return h(\n \"span\",\n { ref: spanRef },\n tree.children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, false, matchLinks),\n ),\n );\n}\n\nexport function Match({ data, matchLinks, dispatch, nodeId }) {\n if (!data || Object.keys(data).length === 0) return;\n\n let tag = h(JSONView, { data });\n\n if (data.lith_id) {\n tag = h(DataField, {\n label: \"Lithology\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.lithology) {\n window.open(matchLinks.lithology + \"/\" + data.lith_id, \"_blank\");\n }\n },\n }),\n });\n }\n\n if (data.strat_name_id) {\n tag = h(\"div\", [\n h(DataField, {\n label: \"Stratigraphic name\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.strat_name_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.strat_name) {\n window.open(\n matchLinks.strat_name + \"/\" + data.strat_name_id,\n \"_blank\",\n );\n }\n },\n }),\n }),\n h.if(data.concept_id)(DataField, {\n label: \"Stratigraphic concept\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.concept_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.concept) {\n window.open(matchLinks.concept + \"/\" + data.concept_id, \"_blank\");\n }\n },\n }),\n }),\n ]);\n }\n\n if (data.lith_att_id) {\n tag = h(DataField, {\n label: \"Lithology attribute\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_att_id },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.lith_att) {\n window.open(matchLinks.lith_att + \"/\" + data.lith_att_id, \"_blank\");\n }\n },\n }),\n });\n }\n\n return h(\"div.match-container\", [\n tag,\n h(Icon, {\n icon: \"cross\",\n color: \"red\",\n className: \"close-btn\",\n onClick: () => {\n dispatch({ type: \"remove-match\", payload: { id: nodeId } });\n },\n }),\n ]);\n}\n"],"names":["$h8ona$macrostrathyper","useRef","$h8ona$useRef","useEffect","$h8ona$useEffect","Icon","$h8ona$Icon","JSONView","$h8ona$JSONView","DataField","$h8ona$DataField","LithologyTag","$h8ona$LithologyTag","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$9wFEx","$edvRb","$d6cf457c7790c03a$var$h","styled","a","__esModule","default","$d6cf457c7790c03a$export$6e107db9091b8219","props","text","selectedNodes","nodes","dispatch","allowOverlap","matchLinks","tabIndex","onKeyDown","e","key","type","payload","ids","$d6cf457c7790c03a$export$190465bec6b893be","allTags","$d6cf457c7790c03a$var$buildTags","highlights","tags","entities","Set","highlight","tag","has","highlighted","$d6cf457c7790c03a$var$isHighlighted","length","includes","parents","some","d","active","tagStyle","getTagStyle","backgroundColor","color","display","markStyle","push","add","buildHighlights","tree","$d6cf457c7790c03a$var$nestHighlights","events","pos","start","end","sort","b","root","children","textStart","stack","lastPos","parent","slice","newNode","pop","spanRef","handleMouseUp","$d6cf457c7790c03a$var$createTagFromSelection","container","selection","window","getSelection","isCollapsed","rangeCount","range","getRangeAt","contains","startContainer","endContainer","preRange","document","createRange","setStart","setEnd","startOffset","toString","selectedText","current","$d6cf457c7790c03a$var$addTag","test","trim","console","log","find","t","endsWith","inside","overlap","addEventListener","removeEventListener","ref","map","child","i","$d6cf457c7790c03a$var$renderNode","node","parentSelected","isSelected","showBorder","style","zIndex","border","margin","moveText","Object","prototype","hasOwnProperty","onMouseEnter","stopPropagation","className","onClick","ctrlKey","metaKey","shiftKey","flat","$d6cf457c7790c03a$export$f421feb8fad20413","data","nodeId","keys","lith_id","label","value","name","lithology","open","strat_name_id","strat_name","if","concept_id","concept","lith_att_id","lith_att","icon","FeedbackText","HighlightedText","Match"],"version":3,"file":"feedback-components.69d0ccd0.js.map","sourceRoot":"../../../../"}
@@ -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,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AE,CACjB,IAAM,EAAQ,EAAa,EAAK,QAAQ,CAAE,GAC1C,GAAI,EAAO,OAAO,CACpB,CACF,CACA,OAAO,IACT,CAEA,SAAS,EAAgB,CAAI,CAAE,CAAO,CAAE,CAAW,EACjD,OAAO,EAAK,GAAG,CAAC,AAAC,GAAS,AAG5B,CAAA,SAAwB,CAAI,CAAE,CAAO,CAAE,CAAW,EAChD,IAAM,EAAO,EAAK,IAAI,CAAC,EAAE,GAAK,EAAQ,EAAE,CAAG,EAAc,EAAK,IAAI,CAElE,MAAO,CACL,GAAG,CAAI,CACP,KAAA,EACA,SAAU,EAAK,QAAQ,CACnB,EAAgB,EAAK,QAAQ,CAAE,EAAS,GACxC,EAAE,AACR,CACF,CAAA,EAb2C,EAAM,EAAS,GAC1D,Q,K,Q,C,K,gB,C,K,mB,C,K,e,C,K,Y,C,K,W","sources":["<anon>","packages/feedback-components/src/feedback/edit-state.ts"],"sourcesContent":["import {useReducer as $eGztG$useReducer, createContext as $eGztG$createContext, useContext as $eGztG$useContext} from \"react\";\nimport $eGztG$immutabilityhelper from \"immutability-helper\";\n\n\n\nvar $330ae695507d96f5$export$53ec42062883b2d4 = /*#__PURE__*/ function(ViewMode) {\n ViewMode[\"Tree\"] = \"tree\";\n ViewMode[\"Graph\"] = \"graph\";\n return ViewMode;\n}({});\nfunction $330ae695507d96f5$export$911bb4b9c8065d3d(initialTree, entityTypes) {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n return (0, $eGztG$useReducer)($330ae695507d96f5$var$treeReducer, {\n initialTree: initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: \"tree\"\n });\n}\nconst $330ae695507d96f5$export$e5ce04c5b3f58533 = (0, $eGztG$createContext)(null);\nfunction $330ae695507d96f5$export$e1068f2d1c68f87e() {\n const dispatch = (0, $eGztG$useContext)($330ae695507d96f5$export$e5ce04c5b3f58533);\n if (dispatch == null) throw new Error(\"No dispatch context available\");\n return dispatch;\n}\nfunction $330ae695507d96f5$var$treeReducer(state, action) {\n switch(action.type){\n case \"add-entity-type\":\n {\n // Add a new entity type to the map\n const { name: name, description: description, color: color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType = {\n id: newId,\n name: name,\n description: description === \"\" ? null : description,\n color: color\n };\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId\n };\n }\n case \"update-entity-type\":\n {\n // Update an existing entity type in the map\n const { id: id, name: name, description: description, color: color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n const updatedType = {\n ...oldType,\n name: name,\n description: description === \"\" ? null : description,\n color: color\n };\n newEntityTypesMap.set(id, updatedType);\n // Update the tree to reflect the new type\n const newTree = $330ae695507d96f5$var$updateTreeTypes(state.tree, oldType, updatedType);\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n // make list of nodes in order\n const allNodes = $330ae695507d96f5$var$flattenAndSort(state.tree);\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node)=>node.id === node1);\n const endIndex = allNodes.findIndex((node)=>node.id === node2);\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node)=>node.id)\n };\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.dragIds);\n let keyPath = [];\n if (action.payload.parentId) {\n keyPath = $330ae695507d96f5$var$findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n // Add removed nodes to the new tree at the correct location\n let updateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n $splice: [\n [\n action.payload.index,\n 0,\n ...removedNodes\n ]\n ]\n });\n return {\n ...state,\n tree: (0, $eGztG$immutabilityhelper)(newTree, updateSpec)\n };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.ids);\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n const children = _removedNodes.flatMap((node)=>node.children ?? []).filter((child)=>!$330ae695507d96f5$var$nodeIsInTree(newTree2, child.id));\n // Reset the selection\n return {\n ...state,\n tree: [\n ...newTree2,\n ...children\n ],\n selectedNodes: state.selectedNodes.filter((id)=>!action.payload.ids.includes(id))\n };\n case \"select-node\":\n const { ids: ids } = action.payload;\n const type = action.payload.ids.length > 0 ? $330ae695507d96f5$export$e64eb58334357825(state.tree, ids[0])?.type : null;\n return {\n ...state,\n selectedNodes: ids,\n selectedEntityType: type\n };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter((id)=>!state.selectedNodes.includes(id));\n const nodesToKeep = state.selectedNodes.filter((id)=>!action.payload.ids.includes(id));\n const newType = action.payload.ids.length > 0 ? $330ae695507d96f5$export$e64eb58334357825(state.tree, action.payload.ids[0])?.type : null;\n return {\n ...state,\n selectedNodes: [\n ...nodesToKeep,\n ...nodesToAdd\n ],\n selectedEntityType: newType\n };\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text: text, start: start, end: end } = action.payload;\n const node = {\n id: newId,\n name: text,\n children: [],\n indices: [\n start,\n end\n ],\n type: state.selectedEntityType\n };\n return {\n ...state,\n tree: [\n ...state.tree,\n node\n ],\n selectedNodes: [\n newId\n ],\n lastInternalId: newId\n };\n case \"delete-entity-type\":\n {\n // Remove the entity type from the map\n const { id: id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = $330ae695507d96f5$var$updateTreeTypes(state.tree, oldType, defaultType);\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: []\n };\n }\n case \"add-match\":\n {\n const { id: id } = action.payload;\n // Find the node path\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n // Build update spec to set the `match` property\n const matchUpdateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n match: {\n $set: action.payload.payload\n }\n });\n const updatedTree = (0, $eGztG$immutabilityhelper)(state.tree, matchUpdateSpec);\n return {\n ...state,\n tree: updatedTree\n };\n }\n case \"remove-match\":\n {\n const { id: id } = action.payload;\n console.log(\"Removing match for node with id:\", id);\n // Find the node path\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n // Build update spec to unset the `match` property\n const matchUpdateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n match: {\n $set: null\n }\n });\n const updatedTree = (0, $eGztG$immutabilityhelper)(state.tree, matchUpdateSpec);\n return {\n ...state,\n tree: updatedTree\n };\n }\n /** Entity type selection */ case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType\n };\n case \"select-entity-type\":\n {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes){\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n const nestedSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n type: {\n $set: action.payload\n }\n });\n newTree2 = (0, $eGztG$immutabilityhelper)(newTree2, nestedSpec);\n }\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload\n };\n }\n case \"deselect\":\n return {\n ...state,\n selectedNodes: []\n };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: []\n };\n case \"set-view-mode\":\n return {\n ...state,\n viewMode: action.payload\n };\n }\n}\nfunction $330ae695507d96f5$var$nodeIsInTree(tree, id) {\n for (let node of tree){\n if (node.id == id) return true;\n else if (node.children) {\n if ($330ae695507d96f5$var$nodeIsInTree(node.children, id)) return true;\n }\n }\n return false;\n}\nfunction $330ae695507d96f5$var$buildNestedSpec(keyPath, innerSpec) {\n // Build a nested object from a key path\n let spec = innerSpec;\n for(let i = keyPath.length - 1; i >= 0; i--)spec = {\n [keyPath[i]]: spec\n };\n return spec;\n// Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\nfunction $330ae695507d96f5$var$findNode(tree, id) {\n // Find the index of the node with the given id in the tree, returning the key path\n for(let i = 0; i < tree.length; i++){\n if (tree[i].id == id) return [\n i\n ];\n else if (tree[i].children) {\n let path = $330ae695507d96f5$var$findNode(tree[i].children, id);\n if (path != null) return [\n i,\n \"children\",\n ...path\n ];\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$removeNodes(tree, ids) {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */ let newTree = [];\n let removedNodes = [];\n for (let node of tree)if (ids.includes(node.id)) removedNodes.push(node);\n else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = $330ae695507d96f5$var$removeNodes(node.children, ids);\n node = {\n ...node,\n children: newChildren\n };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n return [\n newTree,\n removedNodes\n ];\n}\nfunction $330ae695507d96f5$export$8d9dbb7a64bf2a5e(tree) {\n // Convert the tree to a graph\n let nodes = [];\n let edges = [];\n const nodeMap = new Map();\n for (let node of tree){\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) continue;\n const { indices: indices, id: id, name: name, type: type, children: children } = node;\n const nodeData = {\n id: id,\n type: type.id,\n color: type.color,\n name: name,\n txt_range: [\n indices\n ],\n reasoning: null,\n match: node.match,\n children: children\n };\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n if (node.children) {\n for (let child of node.children)edges.push({\n source: node.id,\n dest: child.id\n });\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = $330ae695507d96f5$export$8d9dbb7a64bf2a5e(node.children);\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n return {\n nodes: nodes,\n edges: edges\n };\n}\nfunction $330ae695507d96f5$export$e64eb58334357825(tree, id) {\n for (const node of tree){\n if (node.id === id) return node;\n if (node.children) {\n const found = $330ae695507d96f5$export$e64eb58334357825(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node)=>$330ae695507d96f5$var$updateNodeType(node, oldType, defaultType));\n}\nfunction $330ae695507d96f5$var$updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n return {\n ...node,\n type: type,\n children: node.children ? $330ae695507d96f5$var$updateTreeTypes(node.children, oldType, defaultType) : []\n };\n}\nfunction $330ae695507d96f5$var$flattenAndSort(nodes) {\n const result = [];\n function traverse(nodeList) {\n for (const node of nodeList){\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) traverse(node.children);\n }\n }\n traverse(nodes);\n // sort by start\n return result.sort((a, b)=>a.indices[0] - b.indices[0]);\n}\n\n\nexport {$330ae695507d96f5$export$53ec42062883b2d4 as ViewMode, $330ae695507d96f5$export$911bb4b9c8065d3d as useUpdatableTree, $330ae695507d96f5$export$e5ce04c5b3f58533 as TreeDispatchContext, $330ae695507d96f5$export$e1068f2d1c68f87e as useTreeDispatch, $330ae695507d96f5$export$e64eb58334357825 as findNodeById, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=feedback-components.a7b43cfa.js.map\n","import { TreeData } from \"./types\";\nimport { createContext, Dispatch, useContext, useReducer } from \"react\";\nimport update, { Spec } from \"immutability-helper\";\nimport { EntityType } from \"../extractions/types\";\n\nexport enum ViewMode {\n Tree = \"tree\",\n Graph = \"graph\",\n}\n\ninterface TreeState {\n initialTree: TreeData[];\n tree: TreeData[];\n selectedNodes: number[];\n entityTypesMap: Map<number, EntityType>;\n selectedEntityType: EntityType;\n lastInternalId: number;\n isSelectingEntityType: boolean;\n viewMode: ViewMode;\n}\n\ntype TextRange = {\n start: number;\n end: number;\n text: string;\n};\n\ntype TreeAction =\n | {\n type: \"move-node\";\n payload: { dragIds: number[]; parentId: number; index: number };\n }\n | { type: \"delete-node\"; payload: { ids: number[] } }\n | { type: \"select-node\"; payload: { ids: number[] } }\n | { type: \"toggle-node-selected\"; payload: { ids: number[] } }\n | { type: \"set-view-mode\"; payload: ViewMode }\n | { type: \"create-node\"; payload: TextRange }\n | { type: \"select-entity-type\"; payload: EntityType }\n | { type: \"toggle-entity-type-selector\"; payload?: boolean | null }\n | { type: \"deselect\" }\n | { type: \"reset\" }\n | { type: \"delete-entity-type\"; payload: { id: number } }\n | {\n type: \"add-entity-type\";\n payload: { name: string; description: string; color: string };\n }\n | {\n type: \"update-entity-type\";\n payload: { id: number; name: string; description: string; color: string };\n }\n | { type: \"select-range\"; payload: { ids: number[] } }\n | { type: \"add-match\"; payload: { id: number; payload: any } }\n | { type: \"remove-match\"; payload: { id: number } };\n\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>,\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n\n return useReducer(treeReducer, {\n initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: ViewMode.Tree,\n });\n}\n\nexport const TreeDispatchContext = createContext<TreeDispatch | null>(null);\n\nexport function useTreeDispatch() {\n const dispatch = useContext(TreeDispatchContext);\n if (dispatch == null) {\n throw new Error(\"No dispatch context available\");\n }\n return dispatch;\n}\n\nfunction treeReducer(state: TreeState, action: TreeAction) {\n switch (action.type) {\n case \"add-entity-type\": {\n // Add a new entity type to the map\n const { name, description, color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType: EntityType = {\n id: newId,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId,\n };\n }\n case \"update-entity-type\": {\n // Update an existing entity type in the map\n const { id, name, description, color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n\n const updatedType: EntityType = {\n ...oldType,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n newEntityTypesMap.set(id, updatedType);\n\n // Update the tree to reflect the new type\n const newTree = updateTreeTypes(state.tree, oldType, updatedType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType,\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n\n // make list of nodes in order\n const allNodes = flattenAndSort(state.tree);\n\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node) => node.id === node1);\n const endIndex = allNodes.findIndex((node) => node.id === node2);\n\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node) => node.id),\n };\n\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = removeNodes(\n state.tree,\n action.payload.dragIds,\n );\n\n let keyPath: (number | \"children\")[] = [];\n if (action.payload.parentId) {\n keyPath = findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n\n // Add removed nodes to the new tree at the correct location\n let updateSpec = buildNestedSpec(keyPath, {\n $splice: [[action.payload.index, 0, ...removedNodes]],\n });\n\n return { ...state, tree: update(newTree, updateSpec) };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = removeNodes(\n state.tree,\n action.payload.ids,\n );\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n\n const children = _removedNodes\n .flatMap((node) => node.children ?? [])\n .filter((child) => !nodeIsInTree(newTree2, child.id));\n\n // Reset the selection\n\n return {\n ...state,\n tree: [...newTree2, ...children],\n selectedNodes: state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n ),\n };\n case \"select-node\":\n const { ids } = action.payload;\n\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter(\n (id) => !state.selectedNodes.includes(id),\n );\n const nodesToKeep = state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n );\n\n const newType =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, action.payload.ids[0])?.type\n : null;\n\n return {\n ...state,\n selectedNodes: [...nodesToKeep, ...nodesToAdd],\n selectedEntityType: newType,\n };\n\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text, start, end } = action.payload;\n const node: TreeData = {\n id: newId,\n name: text,\n children: [],\n indices: [start, end],\n type: state.selectedEntityType,\n };\n\n return {\n ...state,\n tree: [...state.tree, node],\n selectedNodes: [newId],\n lastInternalId: newId,\n };\n\n case \"delete-entity-type\": {\n // Remove the entity type from the map\n const { id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = updateTreeTypes(state.tree, oldType, defaultType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: [],\n };\n }\n\n case \"add-match\": {\n const { id } = action.payload;\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to set the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: action.payload.payload },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n case \"remove-match\": {\n const { id } = action.payload;\n\n console.log(\"Removing match for node with id:\", id);\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to unset the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: null },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n /** Entity type selection */\n case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType,\n };\n case \"select-entity-type\": {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes) {\n const keyPath = findNode(state.tree, id);\n const nestedSpec = buildNestedSpec(keyPath, {\n type: { $set: action.payload },\n });\n newTree2 = update(newTree2, nestedSpec);\n }\n\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload,\n };\n }\n case \"deselect\":\n return { ...state, selectedNodes: [] };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: [],\n };\n case \"set-view-mode\":\n return { ...state, viewMode: action.payload };\n }\n}\n\nfunction nodeIsInTree(tree: TreeData[], id: number): boolean {\n for (let node of tree) {\n if (node.id == id) {\n return true;\n } else if (node.children) {\n if (nodeIsInTree(node.children, id)) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction buildNestedSpec(\n keyPath: (number | \"children\")[],\n innerSpec: Spec<any>,\n): Spec<TreeData[]> {\n // Build a nested object from a key path\n\n let spec = innerSpec;\n for (let i = keyPath.length - 1; i >= 0; i--) {\n spec = { [keyPath[i]]: spec };\n }\n return spec as any;\n // Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\n\nfunction findNode(\n tree: TreeData[],\n id: number,\n): (number | \"children\")[] | null {\n // Find the index of the node with the given id in the tree, returning the key path\n for (let i = 0; i < tree.length; i++) {\n if (tree[i].id == id) {\n return [i];\n } else if (tree[i].children) {\n let path = findNode(tree[i].children, id);\n if (path != null) {\n return [i, \"children\", ...path];\n }\n }\n }\n return null;\n}\n\nfunction removeNodes(\n tree: TreeData[],\n ids: number[],\n): [TreeData[], TreeData[]] {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */\n let newTree: TreeData[] = [];\n let removedNodes: TreeData[] = [];\n\n for (let node of tree) {\n if (ids.includes(node.id)) {\n removedNodes.push(node);\n } else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = removeNodes(node.children, ids);\n node = { ...node, children: newChildren };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n }\n\n return [newTree, removedNodes];\n}\n\nexport interface EntityOutput {\n id: number;\n type: number | null;\n txt_range: number[][];\n name: string;\n match: any | null;\n reasoning: string | null;\n color: string | null;\n children: any[] | null;\n}\n\nexport interface GraphData {\n nodes: EntityOutput[];\n edges: { source: number; dest: number }[];\n}\n\nexport function treeToGraph(tree: TreeData[]): GraphData {\n // Convert the tree to a graph\n let nodes: EntityOutput[] = [];\n let edges: { source: number; dest: number }[] = [];\n const nodeMap = new Map<number, TreeData>();\n\n for (let node of tree) {\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) {\n continue;\n }\n\n const { indices, id, name, type, children } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: type.id,\n color: type.color,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\n children,\n };\n\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n\n if (node.children) {\n for (let child of node.children) {\n edges.push({ source: node.id, dest: child.id });\n }\n\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = treeToGraph(\n node.children,\n );\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n\n return { nodes, edges };\n}\n\nexport function findNodeById(tree, id) {\n for (const node of tree) {\n if (node.id === id) {\n return node;\n }\n if (node.children) {\n const found = findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\n\nfunction updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node) => updateNodeType(node, oldType, defaultType));\n}\n\nfunction updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n\n return {\n ...node,\n type,\n children: node.children\n ? updateTreeTypes(node.children, oldType, defaultType)\n : [],\n };\n}\n\nfunction flattenAndSort(nodes) {\n const result = [];\n\n function traverse(nodeList) {\n for (const node of nodeList) {\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) {\n traverse(node.children);\n }\n }\n }\n\n traverse(nodes);\n\n // sort by start\n return result.sort((a, b) => a.indices[0] - b.indices[0]);\n}\n"],"names":["useReducer","$eGztG$useReducer","createContext","$eGztG$createContext","useContext","$eGztG$useContext","$eGztG$immutabilityhelper","ViewMode","$330ae695507d96f5$export$53ec42062883b2d4","$330ae695507d96f5$export$911bb4b9c8065d3d","initialTree","entityTypes","type","values","next","value","$330ae695507d96f5$var$treeReducer","tree","selectedNodes","entityTypesMap","selectedEntityType","lastInternalId","isSelectingEntityType","viewMode","$330ae695507d96f5$export$e5ce04c5b3f58533","$330ae695507d96f5$export$e1068f2d1c68f87e","dispatch","Error","state","action","name","description","color","payload","newId","newType","id","newEntityTypesMap","Map","set","oldType","get","console","warn","updatedType","newTree","$330ae695507d96f5$var$updateTreeTypes","payloadIds","ids","node1","node2","allNodes","$330ae695507d96f5$var$flattenAndSort","nodes","result","traverse","nodeList","node","push","Array","isArray","children","length","sort","a","b","indices","startIndex","findIndex","endIndex","slice","log","map","removedNodes","$330ae695507d96f5$var$removeNodes","dragIds","keyPath","parentId","$330ae695507d96f5$var$findNode","updateSpec","$330ae695507d96f5$var$buildNestedSpec","$splice","index","newTree2","_removedNodes","flatMap","filter","child","$330ae695507d96f5$var$nodeIsInTree","includes","$330ae695507d96f5$export$e64eb58334357825","nodesToAdd","nodesToKeep","text","start","end","delete","defaultType","matchUpdateSpec","match","$set","updatedTree","innerSpec","spec","i","path","newChildren","removedChildren","$330ae695507d96f5$export$8d9dbb7a64bf2a5e","edges","nodeMap","has","nodeData","txt_range","reasoning","source","dest","childNodes","childEdges","found","$330ae695507d96f5$var$updateNodeType","useUpdatableTree","TreeDispatchContext","useTreeDispatch","findNodeById","treeToGraph"],"version":3,"file":"feedback-components.a7b43cfa.js.map","sourceRoot":"../../../../"}
@@ -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":"../../../../"}
@@ -0,0 +1,2 @@
1
+ import"./feedback-components.b9317f9c.js";import"./feedback-components.b22d37d1.js";import e from"@macrostrat/hyper";import{useState as t}from"react";import{Icon as o,Overlay2 as d,Popover as i}from"@blueprintjs/core";import{useInDarkMode as l,SaveButton as a}from"@macrostrat/ui-components";import{ColorPicker as r}from"@macrostrat/data-sheet";var n=globalThis,s={},p={},c=n.parcelRequirea149;null==c&&((c=function(e){if(e in s)return s[e].exports;if(e in p){var t=p[e];delete p[e];var o={id:e,exports:{}};return s[e]=o,t.call(o.exports,o,o.exports),o.exports}var d=Error("Cannot find module '"+e+"'");throw d.code="MODULE_NOT_FOUND",d}).register=function(e,t){p[e]=t},n.parcelRequirea149=c),c.register;var y=c("9wFEx"),u=c("edvRb");let v=e.styled(y&&y.__esModule?y.default:y);function m({types:e,selected:o,dispatch:d,selectedNodes:i,tree:a}){let[r,n]=t(null),s=i.length>0,p=l()?.9:.4;return v("div.type-list-container",[v("div.type-list-header",s&&!r?"Change selected nodes to:":"Entity Types"),v("div.type-list",Array.from(e.values()).map(e=>v(x,{type:e,luminance:p,selectedType:r,setSelectedType:n,dispatch:d,tree:a,selectedNodes:i,selected:o,isSelectedNodes:s}))),v(f,{dispatch:d})])}function g(e,t){let o=[];return e.forEach(function e(d){d.type.id===t&&o.push(d.id),Array.isArray(d.children)&&d.children.forEach(e)}),o}function f({dispatch:e}){let[d,i]=t(!1);return v("div.add-type-container",[v("div.add-type",{onClick:()=>i(!0)},[v("p.add-type-text","Add new type"),v(o,{icon:"plus"})]),v(b,{setOverlayOpen:i,overlayOpen:d,title:"Add New Type",saveHandler:t=>{e({type:"add-entity-type",payload:t}),i(!1)}})])}function h({dispatch:e,type:d}){let[i,l]=t(!1);return v("div.edit-type",[v(o,{icon:"edit",className:"edit-icon",onClick:e=>{e.stopPropagation(),l(!0)}}),v(b,{setOverlayOpen:l,overlayOpen:i,originalType:d,title:"Edit Type",saveHandler:t=>{e({type:"update-entity-type",payload:t}),l(!1)}})])}function b({setOverlayOpen:e,overlayOpen:i,originalType:l,title:n,saveHandler:s}){let{name:p,description:c,color:y,id:u}=l||{},[m,g]=t(p||""),[f,h]=t(c||""),[b,x]=t(y||"#fff");return v(d,{isOpen:i},v("div.overlay-container",v("div.add-type-overlay",[v("h2.title",[n,v(o,{icon:"cross",className:"close-icon",onClick:()=>{e(!1)},style:{cursor:"pointer",color:"red"}})]),v("div.form-group",[v("div.text-inputs",[v("div.form-field.name",[v("p.label","Name"),v("input",{type:"text",placeholder:"Enter type name",onChange:e=>g(e.target.value),value:m})]),v("div.form-field.form-description",[v("p.label","Description"),v("input",{type:"text",placeholder:"Enter type description",onChange:e=>h(e.target.value),value:f})])]),v("div.form-field.color",[v("p.label","Color"),v(r,{value:b,onChange:e=>x(e),style:{width:"100%"}})])]),v(a,{className:"save-btn",small:!0,onClick:()=>s({name:m,description:f,color:b,id:u})},"Save changes")])))}function x({type:e,luminance:t,selectedType:d,setSelectedType:a,dispatch:r,tree:n,selectedNodes:s,selected:p,isSelectedNodes:c}){let{color:y,name:m,id:f,description:b}=e;l();let x=f===p?.id&&s.length>0,N=(0,u.getTagStyle)(y,{active:x,highlighted:0===s.length}),T={id:f,name:m,color:y,description:b},k=g(n,f);return v(i,{autoFocus:!1,content:v("div.description",b||"No description available"),interactionKind:"hover"},v("div.type-tag",{onClick:()=>{c||null!==d?c&&null===d?f===p?.id&&s.length>0?r({type:"toggle-node-selected",payload:{ids:s}}):r({type:"select-entity-type",payload:T}):c&&d.id===f?(a(null),r({type:"toggle-node-selected",payload:{ids:k}})):c&&d.id!==f?k.length>0&&(a(e),r({type:"toggle-node-selected",payload:{ids:g(n,d.id)}}),r({type:"toggle-node-selected",payload:{ids:k}})):console.warn("Unexpected state in TypeTag click handler",{isSelectedNodes:c,selectedType:d,selectedNodes:s,ids:k,id:f,selected:p}):k.length>0&&(a(e),r({type:"toggle-node-selected",payload:{ids:k}}))},style:{cursor:k.length>0||c&&!d?"pointer":"",color:"black",backgroundColor:N.backgroundColor,border:x?"1px solid var(--text-emphasized-color)":"1px solid var(--background-color)"}},v("div.type-container",[v("div.type-name",m),v("div.icons",[v(h,{dispatch:r,type:e}),v(o,{icon:"cross",className:"delete-type-icon",style:{color:"red",cursor:"pointer"},onClick:e=>{e.stopPropagation(),r({type:"delete-entity-type",payload:{id:f}})}})])])))}export{m as TypeList};
2
+ //# sourceMappingURL=feedback-components.e140ac86.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"A,M,oD,A,O,oD,A,Q,M,mB,A,Q,Y,C,K,O,A,Q,Q,C,C,Y,C,C,W,C,K,mB,A,Q,iB,C,C,c,C,K,2B,A,Q,e,C,K,wB,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,SCUA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAS,CAAA,MAAE,CAAK,CAAA,SAAE,CAAQ,CAAA,SAAE,CAAQ,CAAA,cAAE,CAAa,CAAA,KAAE,CAAI,CAAE,EACzE,GAAM,CAAC,EAAc,EAAgB,CAAG,AAAA,EAAS,MAC3C,EAAkB,EAAc,MAAM,CAAG,EAEzC,EAAY,AADD,AAAA,IACY,GAAM,GAEnC,OAAO,EAAE,0BAA2B,CAClC,EACE,uBACA,GAAmB,CAAC,EAChB,4BACA,gBAEN,EACE,gBACA,MAAM,IAAI,CAAC,EAAM,MAAM,IAAI,GAAG,CAAC,AAAC,GAC9B,EAAE,EAAS,CACT,KAAA,EACA,UAAA,EACA,aAAA,EACA,gBAAA,EACA,SAAA,EACA,KAAA,EACA,cAAA,EACA,SAAA,EACA,gBAAA,CACF,KAGJ,EAAE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AS,CAAE,KAAM,uBAAwB,QAAS,CAAE,IAAA,CAAI,CAAE,GAgChE,EAaM,MAAO,CACL,OACE,EAAI,MAAM,CAAG,GAAM,GAAmB,CAAC,EACnC,UACA,GACN,MAAO,QACP,gBAAiB,EAAM,eAAe,CACtC,OAAQ,EACJ,yCACA,mCACN,CACF,EACA,EAAE,qBAAsB,CACtB,EAAE,gBAAiB,GACnB,EAAE,YAAa,CACb,EAAE,EAAU,CACV,SAAA,EACA,KAAA,CACF,GACA,EAAE,EAAM,CACN,KAAM,QACN,UAAW,mBACX,MAAO,CAAE,MAAO,MAAO,OAAQ,SAAU,EACzC,QAAS,AAAC,IACR,EAAE,eAAe,GACjB,EAAS,CACP,KAAM,qBACN,QAAS,CAAE,GAAA,CAAG,CAChB,EACF,CACF,GACD,EACF,GAGP,Q,K,Q","sources":["<anon>","packages/feedback-components/src/feedback/typelist.ts"],"sourcesContent":["import \"./feedback-components.b9317f9c.js\";\nimport \"./feedback-components.b22d37d1.js\";\nimport $a9pfJ$macrostrathyper from \"@macrostrat/hyper\";\nimport {useState as $a9pfJ$useState} from \"react\";\nimport {Icon as $a9pfJ$Icon, Overlay2 as $a9pfJ$Overlay2, Popover as $a9pfJ$Popover} from \"@blueprintjs/core\";\nimport {useInDarkMode as $a9pfJ$useInDarkMode, SaveButton as $a9pfJ$SaveButton} from \"@macrostrat/ui-components\";\nimport {ColorPicker as $a9pfJ$ColorPicker} from \"@macrostrat/data-sheet\";\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 $7f564edd0e07f138$var$h = (0, $a9pfJ$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $7f564edd0e07f138$export$9ebd91d75ddb6a8b({ types: types, selected: selected, dispatch: dispatch, selectedNodes: selectedNodes, tree: tree }) {\n const [selectedType, setSelectedType] = (0, $a9pfJ$useState)(null);\n const isSelectedNodes = selectedNodes.length > 0;\n const darkMode = (0, $a9pfJ$useInDarkMode)();\n const luminance = darkMode ? 0.9 : 0.4;\n return $7f564edd0e07f138$var$h(\"div.type-list-container\", [\n $7f564edd0e07f138$var$h(\"div.type-list-header\", isSelectedNodes && !selectedType ? \"Change selected nodes to:\" : \"Entity Types\"),\n $7f564edd0e07f138$var$h(\"div.type-list\", Array.from(types.values()).map((type)=>$7f564edd0e07f138$var$h($7f564edd0e07f138$var$TypeTag, {\n type: type,\n luminance: luminance,\n selectedType: selectedType,\n setSelectedType: setSelectedType,\n dispatch: dispatch,\n tree: tree,\n selectedNodes: selectedNodes,\n selected: selected,\n isSelectedNodes: isSelectedNodes\n }))),\n $7f564edd0e07f138$var$h($7f564edd0e07f138$var$AddType, {\n dispatch: dispatch\n })\n ]);\n}\nfunction $7f564edd0e07f138$var$collectMatchingIds(tree, id) {\n const ids = [];\n function traverse(node) {\n if (node.type.id === id) ids.push(node.id);\n if (Array.isArray(node.children)) node.children.forEach(traverse);\n }\n tree.forEach(traverse);\n return ids;\n}\nfunction $7f564edd0e07f138$var$AddType({ dispatch: dispatch }) {\n const [overlayOpen, setOverlayOpen] = (0, $a9pfJ$useState)(false);\n const saveHandler = (payload)=>{\n dispatch({\n type: \"add-entity-type\",\n payload: payload\n });\n setOverlayOpen(false);\n };\n return $7f564edd0e07f138$var$h(\"div.add-type-container\", [\n $7f564edd0e07f138$var$h(\"div.add-type\", {\n onClick: ()=>setOverlayOpen(true)\n }, [\n $7f564edd0e07f138$var$h(\"p.add-type-text\", \"Add new type\"),\n $7f564edd0e07f138$var$h((0, $a9pfJ$Icon), {\n icon: \"plus\"\n })\n ]),\n $7f564edd0e07f138$var$h($7f564edd0e07f138$var$TypeOverlay, {\n setOverlayOpen: setOverlayOpen,\n overlayOpen: overlayOpen,\n title: \"Add New Type\",\n saveHandler: saveHandler\n })\n ]);\n}\nfunction $7f564edd0e07f138$var$EditType({ dispatch: dispatch, type: type }) {\n const [editorOpen, setEditorOpen] = (0, $a9pfJ$useState)(false);\n const saveHandler = (payload)=>{\n dispatch({\n type: \"update-entity-type\",\n payload: payload\n });\n setEditorOpen(false);\n };\n return $7f564edd0e07f138$var$h(\"div.edit-type\", [\n $7f564edd0e07f138$var$h((0, $a9pfJ$Icon), {\n icon: \"edit\",\n className: \"edit-icon\",\n onClick: (e)=>{\n e.stopPropagation();\n setEditorOpen(true);\n }\n }),\n $7f564edd0e07f138$var$h($7f564edd0e07f138$var$TypeOverlay, {\n setOverlayOpen: setEditorOpen,\n overlayOpen: editorOpen,\n originalType: type,\n title: \"Edit Type\",\n saveHandler: saveHandler\n })\n ]);\n}\nfunction $7f564edd0e07f138$var$TypeOverlay({ setOverlayOpen: setOverlayOpen, overlayOpen: overlayOpen, originalType: originalType, title: title, saveHandler: saveHandler }) {\n const { name: name, description: description, color: color, id: id } = originalType || {};\n const [nameInput, setNameInput] = (0, $a9pfJ$useState)(name || \"\");\n const [descriptionInput, setDescriptionInput] = (0, $a9pfJ$useState)(description || \"\");\n const [colorInput, setColorInput] = (0, $a9pfJ$useState)(color || \"#fff\");\n return $7f564edd0e07f138$var$h((0, $a9pfJ$Overlay2), {\n isOpen: overlayOpen\n }, $7f564edd0e07f138$var$h(\"div.overlay-container\", $7f564edd0e07f138$var$h(\"div.add-type-overlay\", [\n $7f564edd0e07f138$var$h(\"h2.title\", [\n title,\n $7f564edd0e07f138$var$h((0, $a9pfJ$Icon), {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: ()=>{\n setOverlayOpen(false);\n },\n style: {\n cursor: \"pointer\",\n color: \"red\"\n }\n })\n ]),\n $7f564edd0e07f138$var$h(\"div.form-group\", [\n $7f564edd0e07f138$var$h(\"div.text-inputs\", [\n $7f564edd0e07f138$var$h(\"div.form-field.name\", [\n $7f564edd0e07f138$var$h(\"p.label\", \"Name\"),\n $7f564edd0e07f138$var$h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type name\",\n onChange: (e)=>setNameInput(e.target.value),\n value: nameInput\n })\n ]),\n $7f564edd0e07f138$var$h(\"div.form-field.form-description\", [\n $7f564edd0e07f138$var$h(\"p.label\", \"Description\"),\n $7f564edd0e07f138$var$h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type description\",\n onChange: (e)=>setDescriptionInput(e.target.value),\n value: descriptionInput\n })\n ])\n ]),\n $7f564edd0e07f138$var$h(\"div.form-field.color\", [\n $7f564edd0e07f138$var$h(\"p.label\", \"Color\"),\n $7f564edd0e07f138$var$h((0, $a9pfJ$ColorPicker), {\n value: colorInput,\n onChange: (color)=>setColorInput(color),\n style: {\n width: \"100%\"\n }\n })\n ])\n ]),\n $7f564edd0e07f138$var$h((0, $a9pfJ$SaveButton), {\n className: \"save-btn\",\n small: true,\n onClick: ()=>saveHandler({\n name: nameInput,\n description: descriptionInput,\n color: colorInput,\n id: id\n })\n }, \"Save changes\")\n ])));\n}\nfunction $7f564edd0e07f138$var$TypeTag({ type: type, luminance: luminance, selectedType: selectedType, setSelectedType: setSelectedType, dispatch: dispatch, tree: tree, selectedNodes: selectedNodes, selected: selected, isSelectedNodes: isSelectedNodes }) {\n const { color: color, name: name, id: id, description: description } = type;\n const darkMode = (0, $a9pfJ$useInDarkMode)();\n const isSelected = id === selected?.id && selectedNodes.length > 0;\n const style = (0, $edvRb.getTagStyle)(color, {\n active: isSelected,\n highlighted: selectedNodes.length === 0\n });\n const payload = {\n id: id,\n name: name,\n color: color,\n description: description\n };\n const ids = $7f564edd0e07f138$var$collectMatchingIds(tree, id);\n const handleTagClick = ()=>{\n if (!isSelectedNodes && selectedType === null) {\n if (ids.length > 0) {\n setSelectedType(type);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n }\n } else if (isSelectedNodes && selectedType === null) {\n if (id === selected?.id && selectedNodes.length > 0) dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: selectedNodes\n }\n });\n else dispatch({\n type: \"select-entity-type\",\n payload: payload\n });\n } else if (isSelectedNodes && selectedType.id === id) {\n setSelectedType(null);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n } else if (isSelectedNodes && selectedType.id !== id) {\n if (ids.length > 0) {\n setSelectedType(type);\n const oldIds = $7f564edd0e07f138$var$collectMatchingIds(tree, selectedType.id);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: oldIds\n }\n });\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n }\n } else console.warn(\"Unexpected state in TypeTag click handler\", {\n isSelectedNodes: isSelectedNodes,\n selectedType: selectedType,\n selectedNodes: selectedNodes,\n ids: ids,\n id: id,\n selected: selected\n });\n };\n return $7f564edd0e07f138$var$h((0, $a9pfJ$Popover), {\n autoFocus: false,\n content: $7f564edd0e07f138$var$h(\"div.description\", description || \"No description available\"),\n interactionKind: \"hover\"\n }, $7f564edd0e07f138$var$h(\"div.type-tag\", {\n onClick: handleTagClick,\n style: {\n cursor: ids.length > 0 || isSelectedNodes && !selectedType ? \"pointer\" : \"\",\n color: \"black\",\n backgroundColor: style.backgroundColor,\n border: isSelected ? `1px solid var(--text-emphasized-color)` : `1px solid var(--background-color)`\n }\n }, $7f564edd0e07f138$var$h(\"div.type-container\", [\n $7f564edd0e07f138$var$h(\"div.type-name\", name),\n $7f564edd0e07f138$var$h(\"div.icons\", [\n $7f564edd0e07f138$var$h($7f564edd0e07f138$var$EditType, {\n dispatch: dispatch,\n type: type\n }),\n $7f564edd0e07f138$var$h((0, $a9pfJ$Icon), {\n icon: \"cross\",\n className: \"delete-type-icon\",\n style: {\n color: \"red\",\n cursor: \"pointer\"\n },\n onClick: (e)=>{\n e.stopPropagation();\n dispatch({\n type: \"delete-entity-type\",\n payload: {\n id: id\n }\n });\n }\n })\n ])\n ])));\n}\n\n\nexport {$7f564edd0e07f138$export$9ebd91d75ddb6a8b as TypeList};\n//# sourceMappingURL=feedback-components.e140ac86.js.map\n","import styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport { getTagStyle } from \"../extractions\";\nimport { useState } from \"react\";\nimport { Icon, Popover, Overlay2 } from \"@blueprintjs/core\";\nimport { SaveButton } from \"@macrostrat/ui-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { ColorPicker } from \"@macrostrat/data-sheet\";\n\nconst h = hyper.styled(styles);\n\nexport function TypeList({ types, selected, dispatch, selectedNodes, tree }) {\n const [selectedType, setSelectedType] = useState(null);\n const isSelectedNodes = selectedNodes.length > 0;\n const darkMode = useInDarkMode();\n const luminance = darkMode ? 0.9 : 0.4;\n\n return h(\"div.type-list-container\", [\n h(\n \"div.type-list-header\",\n isSelectedNodes && !selectedType\n ? \"Change selected nodes to:\"\n : \"Entity Types\",\n ),\n h(\n \"div.type-list\",\n Array.from(types.values()).map((type) =>\n h(TypeTag, {\n type,\n luminance,\n selectedType,\n setSelectedType,\n dispatch,\n tree,\n selectedNodes,\n selected,\n isSelectedNodes,\n }),\n ),\n ),\n h(AddType, { dispatch }),\n ]);\n}\n\nfunction collectMatchingIds(tree, id) {\n const ids = [];\n\n function traverse(node) {\n if (node.type.id === id) {\n ids.push(node.id);\n }\n if (Array.isArray(node.children)) {\n node.children.forEach(traverse);\n }\n }\n\n tree.forEach(traverse);\n return ids;\n}\n\nfunction AddType({ dispatch }) {\n const [overlayOpen, setOverlayOpen] = useState(false);\n\n const saveHandler = (payload) => {\n dispatch({\n type: \"add-entity-type\",\n payload,\n });\n setOverlayOpen(false);\n };\n\n return h(\"div.add-type-container\", [\n h(\"div.add-type\", { onClick: () => setOverlayOpen(true) }, [\n h(\"p.add-type-text\", \"Add new type\"),\n h(Icon, { icon: \"plus\" }),\n ]),\n h(TypeOverlay, {\n setOverlayOpen,\n overlayOpen,\n title: \"Add New Type\",\n saveHandler,\n }),\n ]);\n}\n\nfunction EditType({ dispatch, type }) {\n const [editorOpen, setEditorOpen] = useState(false);\n\n const saveHandler = (payload) => {\n dispatch({\n type: \"update-entity-type\",\n payload,\n });\n setEditorOpen(false);\n };\n\n return h(\"div.edit-type\", [\n h(Icon, {\n icon: \"edit\",\n className: \"edit-icon\",\n onClick: (e) => {\n e.stopPropagation();\n setEditorOpen(true);\n },\n }),\n h(TypeOverlay, {\n setOverlayOpen: setEditorOpen,\n overlayOpen: editorOpen,\n originalType: type,\n title: \"Edit Type\",\n saveHandler,\n }),\n ]);\n}\n\nfunction TypeOverlay({\n setOverlayOpen,\n overlayOpen,\n originalType,\n title,\n saveHandler,\n}) {\n const { name, description, color, id } = originalType || {};\n\n const [nameInput, setNameInput] = useState(name || \"\");\n const [descriptionInput, setDescriptionInput] = useState(description || \"\");\n const [colorInput, setColorInput] = useState(color || \"#fff\");\n\n return h(\n Overlay2,\n {\n isOpen: overlayOpen,\n },\n h(\n \"div.overlay-container\",\n h(\"div.add-type-overlay\", [\n h(\"h2.title\", [\n title,\n h(Icon, {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: () => {\n setOverlayOpen(false);\n },\n style: { cursor: \"pointer\", color: \"red\" },\n }),\n ]),\n h(\"div.form-group\", [\n h(\"div.text-inputs\", [\n h(\"div.form-field.name\", [\n h(\"p.label\", \"Name\"),\n h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type name\",\n onChange: (e) => setNameInput(e.target.value),\n value: nameInput,\n }),\n ]),\n h(\"div.form-field.form-description\", [\n h(\"p.label\", \"Description\"),\n h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type description\",\n onChange: (e) => setDescriptionInput(e.target.value),\n value: descriptionInput,\n }),\n ]),\n ]),\n h(\"div.form-field.color\", [\n h(\"p.label\", \"Color\"),\n h(ColorPicker, {\n value: colorInput,\n onChange: (color) => setColorInput(color),\n style: { width: \"100%\" },\n }),\n ]),\n ]),\n h(\n SaveButton,\n {\n className: \"save-btn\",\n small: true,\n onClick: () =>\n saveHandler({\n name: nameInput,\n description: descriptionInput,\n color: colorInput,\n id,\n }),\n },\n \"Save changes\",\n ),\n ]),\n ),\n );\n}\n\nfunction TypeTag({\n type,\n luminance,\n selectedType,\n setSelectedType,\n dispatch,\n tree,\n selectedNodes,\n selected,\n isSelectedNodes,\n}) {\n const { color, name, id, description } = type;\n const darkMode = useInDarkMode();\n const isSelected = id === selected?.id && selectedNodes.length > 0;\n\n const style = getTagStyle(color, {\n active: isSelected,\n highlighted: selectedNodes.length === 0,\n });\n\n const payload = {\n id,\n name,\n color,\n description,\n };\n\n const ids = collectMatchingIds(tree, id);\n\n const handleTagClick = () => {\n if (!isSelectedNodes && selectedType === null) {\n if (ids.length > 0) {\n setSelectedType(type);\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n }\n } else if (isSelectedNodes && selectedType === null) {\n if (id === selected?.id && selectedNodes.length > 0) {\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: selectedNodes },\n });\n } else {\n dispatch({ type: \"select-entity-type\", payload });\n }\n } else if (isSelectedNodes && selectedType.id === id) {\n setSelectedType(null);\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n } else if (isSelectedNodes && selectedType.id !== id) {\n if (ids.length > 0) {\n setSelectedType(type);\n const oldIds = collectMatchingIds(tree, selectedType.id);\n\n dispatch({ type: \"toggle-node-selected\", payload: { ids: oldIds } });\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n }\n } else {\n console.warn(\"Unexpected state in TypeTag click handler\", {\n isSelectedNodes,\n selectedType,\n selectedNodes,\n ids,\n id,\n selected,\n });\n }\n };\n\n return h(\n Popover,\n {\n autoFocus: false,\n content: h(\"div.description\", description || \"No description available\"),\n interactionKind: \"hover\",\n },\n h(\n \"div.type-tag\",\n {\n onClick: handleTagClick,\n style: {\n cursor:\n ids.length > 0 || (isSelectedNodes && !selectedType)\n ? \"pointer\"\n : \"\",\n color: \"black\",\n backgroundColor: style.backgroundColor,\n border: isSelected\n ? `1px solid var(--text-emphasized-color)`\n : `1px solid var(--background-color)`,\n },\n },\n h(\"div.type-container\", [\n h(\"div.type-name\", name),\n h(\"div.icons\", [\n h(EditType, {\n dispatch,\n type,\n }),\n h(Icon, {\n icon: \"cross\",\n className: \"delete-type-icon\",\n style: { color: \"red\", cursor: \"pointer\" },\n onClick: (e) => {\n e.stopPropagation();\n dispatch({\n type: \"delete-entity-type\",\n payload: { id },\n });\n },\n }),\n ]),\n ]),\n ),\n );\n}\n"],"names":["$a9pfJ$macrostrathyper","useState","$a9pfJ$useState","Icon","$a9pfJ$Icon","Overlay2","$a9pfJ$Overlay2","Popover","$a9pfJ$Popover","useInDarkMode","$a9pfJ$useInDarkMode","SaveButton","$a9pfJ$SaveButton","ColorPicker","$a9pfJ$ColorPicker","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$9wFEx","$edvRb","$7f564edd0e07f138$var$h","styled","a","__esModule","default","$7f564edd0e07f138$export$9ebd91d75ddb6a8b","types","selected","dispatch","selectedNodes","tree","selectedType","setSelectedType","isSelectedNodes","length","luminance","darkMode","Array","from","values","map","type","$7f564edd0e07f138$var$TypeTag","$7f564edd0e07f138$var$AddType","$7f564edd0e07f138$var$collectMatchingIds","ids","forEach","traverse","node","push","isArray","children","overlayOpen","setOverlayOpen","onClick","icon","$7f564edd0e07f138$var$TypeOverlay","title","saveHandler","payload","$7f564edd0e07f138$var$EditType","editorOpen","setEditorOpen","className","e","stopPropagation","originalType","name","description","color","nameInput","setNameInput","descriptionInput","setDescriptionInput","colorInput","setColorInput","isOpen","style","cursor","placeholder","onChange","target","value","width","small","isSelected","getTagStyle","active","highlighted","autoFocus","content","interactionKind","console","warn","backgroundColor","border","TypeList"],"version":3,"file":"feedback-components.e140ac86.js.map","sourceRoot":"../../../../"}
@@ -0,0 +1,2 @@
1
+ import"./feedback-components.69d0ccd0.js";import"./feedback-components.b9317f9c.js";import{Divider as e,Switch as a,Icon as t,Overlay2 as i}from"@blueprintjs/core";import{Select as n}from"@blueprintjs/select";import r from"@macrostrat/hyper";import{useState as l}from"react";import{useAPIResult as o,DataField as c,JSONView as d,SaveButton as m}from"@macrostrat/ui-components";import{LithologyTag as s}from"@macrostrat/data-components";var h=globalThis,p={},u={},v=h.parcelRequirea149;null==v&&((v=function(e){if(e in p)return p[e].exports;if(e in u){var a=u[e];delete u[e];var t={id:e,exports:{}};return p[e]=t,a.call(t.exports,t,t.exports),t.exports}var i=Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(e,a){u[e]=a},h.parcelRequirea149=v),v.register;var f=v("3OP12"),_=v("9wFEx");let y=r.styled(_&&_.__esModule?_.default:_);function k({match:i,setMatchLinks:n,matchLinks:r,selectedNodes:o,tree:c,dispatch:d}){var m,s;let h,[p,u]=l(!1),v=null;return 1===o.length&&(m=c,s=o[0],h=null,m.forEach(function e(a){if(a.id===s)return h=a,!0;if(Array.isArray(a.children)){for(let t of a.children)if(e(t))return!0}return!1}),v=h),y.if(r)("div",[y(e),y(a,{label:"Show matches",checked:null!==i,onChange:e=>{n(null===i?r||{}:null)}}),y.if(v&&i)(f.Match,{data:v?.match,matchLinks:r,dispatch:d,nodeId:v?.id}),y.if(1==o.length&&!v?.match&&i)("div.add-match-container",[y("div.add-type",{onClick:()=>{u(!0)}},[y("p.add-match-text","Add match"),y(t,{icon:"plus"})]),y(b,{isOpen:p,setOverlayOpen:u,nodeMatch:v,dispatch:d})])])}function b({isOpen:e,setOverlayOpen:a,nodeMatch:r,dispatch:h}){let[p,u]=l(r?.name||""),[v,f]=l(y("div","Select a match")),[_,k]=l(!0),[b,g]=l({}),C=o("https://dev.macrostrat.org/api/pg/type_lookup?name=ilike.*"+p+"*"),O=C?.map(e=>{let a=e.type||"";return"lith"===a?y("div",{onClick:()=>{g({lith_id:e.id,name:e.name})}},y(c,{className:"match-item",label:"Lithology",value:y(s,{data:{name:e.name,id:e.lith_id,color:e.color}})})):"strat_name"===a?y("div",{onClick:()=>{g({strat_name_id:e.id,name:e.name})}},y(c,{className:"match-item",label:"Stratigraphic name",value:y(s,{data:{name:e.name,id:e.id,color:e.color}})})):"lith_att"===a?y("div",{onClick:()=>{g({lith_att_id:e.lith_att_id,name:e.name})}},y(c,{className:"match-item",label:"Lithology attribute",value:y(s,{data:{name:e.name,id:e.lith_att_id}}),onClick:()=>{g({lith_att_id:e.lith_att_id,name:e.name})}})):("interval"===a&&y("div",{onClick:()=>{g({int_id:e.id,name:e.name})}},y(c,{label:"Interval",className:"match-item",value:y(s,{data:{name:e.name,id:e.id}}),onClick:()=>{g({int_id:e.id,name:e.name})}})),y(d,{data:e}))});return y(i,{isOpen:e},y("div.overlay-container",y("div.add-type-overlay",[y("h2.title",["Add match with "+r.name,y(t,{icon:"cross",className:"close-icon",onClick:()=>{a(!1)},style:{cursor:"pointer",color:"red"}})]),y("div.form-group",[y(n,{items:O||[],itemRenderer:(e,{handleClick:a})=>y("div.match-item",{onClick:a},e),onItemSelect:e=>{k(!1),f(e)},onQueryChange:e=>u(e),popoverProps:{minimal:!0},query:p,placeholder:"Enter match name"},v)]),y(m,{className:"save-btn",small:!0,onClick:()=>{h({type:"add-match",payload:{id:r.id,payload:b}}),a(!1)},disabled:_},"Save changes")])))}export{k as Matches};
2
+ //# sourceMappingURL=feedback-components.f8373b58.js.map
@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C,GACD,EACD,EAAE,iBAAkB,CAClB,EACE,EACA,CACE,MAAO,GAAS,EAAE,CAClB,aAAc,CAAC,EAAM,CAAA,YAAE,CAAW,CAAE,GAC3B,EAAE,iBAAkB,CAAE,QAAS,CAAY,EAAG,GAEvD,aAAc,AAAC,IACb,EAAY,CAAA,GACZ,EAAgB,EAClB,EACA,cAAe,AAAC,GAAU,EAAc,GACxC,aAAc,CAAE,QAAS,CAAA,CAAK,EAC9B,MAAO,EACP,YAAa,kBACf,EACA,GAEH,EACD,EACE,EACA,CACE,UAAW,WACX,MAAO,CAAA,EACP,QAAS,KAEP,EAAS,CACP,KAAM,YACN,QAAS,CAAE,GAAI,EAAU,EAAE,CAAE,QAAA,CAAQ,CACvC,GACA,EAAe,CAAA,EACjB,EACA,SAAA,CACF,EACA,gBAEH,GAGP,Q,K,O","sources":["<anon>","packages/feedback-components/src/feedback/matches.ts"],"sourcesContent":["import \"./feedback-components.69d0ccd0.js\";\nimport \"./feedback-components.b9317f9c.js\";\nimport {Divider as $locXJ$Divider, Switch as $locXJ$Switch, Icon as $locXJ$Icon, Overlay2 as $locXJ$Overlay2} from \"@blueprintjs/core\";\nimport {Select as $locXJ$Select} from \"@blueprintjs/select\";\nimport $locXJ$macrostrathyper from \"@macrostrat/hyper\";\nimport {useState as $locXJ$useState} from \"react\";\nimport {useAPIResult as $locXJ$useAPIResult, DataField as $locXJ$DataField, JSONView as $locXJ$JSONView, SaveButton as $locXJ$SaveButton} from \"@macrostrat/ui-components\";\nimport {LithologyTag as $locXJ$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\n\nvar $3OP12 = parcelRequire(\"3OP12\");\n\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\n\nconst $7accc8160d3205c1$var$h = (0, $locXJ$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $7accc8160d3205c1$export$6479cfcac2b87c0({ match: match, setMatchLinks: setMatchLinks, matchLinks: matchLinks, selectedNodes: selectedNodes, tree: tree, dispatch: dispatch }) {\n const [overlayOpen, setOverlayOpen] = (0, $locXJ$useState)(false);\n let nodeMatch = null;\n if (selectedNodes.length === 1) nodeMatch = $7accc8160d3205c1$var$findMatchingNode(tree, selectedNodes[0]);\n return $7accc8160d3205c1$var$h.if(matchLinks)(\"div\", [\n $7accc8160d3205c1$var$h((0, $locXJ$Divider)),\n $7accc8160d3205c1$var$h((0, $locXJ$Switch), {\n label: \"Show matches\",\n checked: match !== null,\n onChange: (e)=>{\n setMatchLinks(match === null ? matchLinks || {} : null);\n }\n }),\n $7accc8160d3205c1$var$h.if(nodeMatch && match)((0, $3OP12.Match), {\n data: nodeMatch?.match,\n matchLinks: matchLinks,\n dispatch: dispatch,\n nodeId: nodeMatch?.id\n }),\n $7accc8160d3205c1$var$h.if(selectedNodes.length == 1 && !nodeMatch?.match && match)(\"div.add-match-container\", [\n $7accc8160d3205c1$var$h(\"div.add-type\", {\n onClick: ()=>{\n setOverlayOpen(true);\n }\n }, [\n $7accc8160d3205c1$var$h(\"p.add-match-text\", \"Add match\"),\n $7accc8160d3205c1$var$h((0, $locXJ$Icon), {\n icon: \"plus\"\n })\n ]),\n $7accc8160d3205c1$var$h($7accc8160d3205c1$var$MatchOverlay, {\n isOpen: overlayOpen,\n setOverlayOpen: setOverlayOpen,\n nodeMatch: nodeMatch,\n dispatch: dispatch\n })\n ])\n ]);\n}\nfunction $7accc8160d3205c1$var$findMatchingNode(tree, nodeId) {\n let match = null;\n function traverse(node) {\n if (node.id === nodeId) {\n match = node;\n return true;\n }\n if (Array.isArray(node.children)) for (const child of node.children){\n if (traverse(child)) return true;\n }\n return false;\n }\n tree.forEach(traverse);\n return match;\n}\nfunction $7accc8160d3205c1$var$MatchOverlay({ isOpen: isOpen, setOverlayOpen: setOverlayOpen, nodeMatch: nodeMatch, dispatch: dispatch }) {\n const [inputValue, setInputValue] = (0, $locXJ$useState)(nodeMatch?.name || \"\");\n const [selectedItem, setSelectedItem] = (0, $locXJ$useState)($7accc8160d3205c1$var$h(\"div\", \"Select a match\"));\n const [disabled, setDisabled] = (0, $locXJ$useState)(true);\n const [payload, setPayload] = (0, $locXJ$useState)({});\n const data = (0, $locXJ$useAPIResult)(\"https://dev.macrostrat.org/api/pg/type_lookup?name=ilike.*\" + inputValue + \"*\");\n const items = data?.map((data)=>{\n const type = data.type || \"\";\n if (type === \"lith\") return $7accc8160d3205c1$var$h(\"div\", {\n onClick: ()=>{\n setPayload({\n lith_id: data.id,\n name: data.name\n });\n }\n }, $7accc8160d3205c1$var$h((0, $locXJ$DataField), {\n className: \"match-item\",\n label: \"Lithology\",\n value: $7accc8160d3205c1$var$h((0, $locXJ$LithologyTag), {\n data: {\n name: data.name,\n id: data.lith_id,\n color: data.color\n }\n })\n }));\n if (type === \"strat_name\") return $7accc8160d3205c1$var$h(\"div\", {\n onClick: ()=>{\n setPayload({\n strat_name_id: data.id,\n name: data.name\n });\n }\n }, $7accc8160d3205c1$var$h((0, $locXJ$DataField), {\n className: \"match-item\",\n label: \"Stratigraphic name\",\n value: $7accc8160d3205c1$var$h((0, $locXJ$LithologyTag), {\n data: {\n name: data.name,\n id: data.id,\n color: data.color\n }\n })\n }));\n if (type === \"lith_att\") return $7accc8160d3205c1$var$h(\"div\", {\n onClick: ()=>{\n setPayload({\n lith_att_id: data.lith_att_id,\n name: data.name\n });\n }\n }, $7accc8160d3205c1$var$h((0, $locXJ$DataField), {\n className: \"match-item\",\n label: \"Lithology attribute\",\n value: $7accc8160d3205c1$var$h((0, $locXJ$LithologyTag), {\n data: {\n name: data.name,\n id: data.lith_att_id\n }\n }),\n onClick: ()=>{\n setPayload({\n lith_att_id: data.lith_att_id,\n name: data.name\n });\n }\n }));\n if (type === \"interval\") $7accc8160d3205c1$var$h(\"div\", {\n onClick: ()=>{\n setPayload({\n int_id: data.id,\n name: data.name\n });\n }\n }, $7accc8160d3205c1$var$h((0, $locXJ$DataField), {\n label: \"Interval\",\n className: \"match-item\",\n value: $7accc8160d3205c1$var$h((0, $locXJ$LithologyTag), {\n data: {\n name: data.name,\n id: data.id\n }\n }),\n onClick: ()=>{\n setPayload({\n int_id: data.id,\n name: data.name\n });\n }\n }));\n return $7accc8160d3205c1$var$h((0, $locXJ$JSONView), {\n data: data\n });\n });\n return $7accc8160d3205c1$var$h((0, $locXJ$Overlay2), {\n isOpen: isOpen\n }, $7accc8160d3205c1$var$h(\"div.overlay-container\", $7accc8160d3205c1$var$h(\"div.add-type-overlay\", [\n $7accc8160d3205c1$var$h(\"h2.title\", [\n \"Add match with \" + nodeMatch.name,\n $7accc8160d3205c1$var$h((0, $locXJ$Icon), {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: ()=>{\n setOverlayOpen(false);\n },\n style: {\n cursor: \"pointer\",\n color: \"red\"\n }\n })\n ]),\n $7accc8160d3205c1$var$h(\"div.form-group\", [\n $7accc8160d3205c1$var$h((0, $locXJ$Select), {\n items: items || [],\n itemRenderer: (item, { handleClick: handleClick })=>{\n return $7accc8160d3205c1$var$h(\"div.match-item\", {\n onClick: handleClick\n }, item);\n },\n onItemSelect: (item)=>{\n setDisabled(false);\n setSelectedItem(item);\n },\n onQueryChange: (query)=>setInputValue(query),\n popoverProps: {\n minimal: true\n },\n query: inputValue,\n placeholder: \"Enter match name\"\n }, selectedItem)\n ]),\n $7accc8160d3205c1$var$h((0, $locXJ$SaveButton), {\n className: \"save-btn\",\n small: true,\n onClick: ()=>{\n // Handle save changes\n dispatch({\n type: \"add-match\",\n payload: {\n id: nodeMatch.id,\n payload: payload\n }\n });\n setOverlayOpen(false);\n },\n disabled: disabled\n }, \"Save changes\")\n ])));\n}\n\n\nexport {$7accc8160d3205c1$export$6479cfcac2b87c0 as Matches};\n//# sourceMappingURL=feedback-components.f8373b58.js.map\n","import { Switch } from \"@blueprintjs/core\";\nimport { Match } from \"./text-visualizer\";\nimport { Select } from \"@blueprintjs/select\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { useState } from \"react\";\nimport { Icon, Divider, Overlay2 } from \"@blueprintjs/core\";\nimport { JSONView, SaveButton } from \"@macrostrat/ui-components\";\nimport { useAPIResult, DataField } from \"@macrostrat/ui-components\";\nimport { LithologyTag } from \"@macrostrat/data-components\";\n\nconst h = hyper.styled(styles);\n\nexport function Matches({\n match,\n setMatchLinks,\n matchLinks,\n selectedNodes,\n tree,\n dispatch,\n}) {\n const [overlayOpen, setOverlayOpen] = useState(false);\n\n let nodeMatch = null;\n if (selectedNodes.length === 1) {\n nodeMatch = findMatchingNode(tree, selectedNodes[0]);\n }\n\n return h.if(matchLinks)(\"div\", [\n h(Divider),\n h(Switch, {\n label: \"Show matches\",\n checked: match !== null,\n onChange: (e) => {\n setMatchLinks(match === null ? matchLinks || {} : null);\n },\n }),\n h.if(nodeMatch && match)(Match, {\n data: nodeMatch?.match,\n matchLinks: matchLinks,\n dispatch,\n nodeId: nodeMatch?.id,\n }),\n h.if(selectedNodes.length == 1 && !nodeMatch?.match && match)(\n \"div.add-match-container\",\n [\n h(\n \"div.add-type\",\n {\n onClick: () => {\n setOverlayOpen(true);\n },\n },\n [h(\"p.add-match-text\", \"Add match\"), h(Icon, { icon: \"plus\" })],\n ),\n h(MatchOverlay, {\n isOpen: overlayOpen,\n setOverlayOpen,\n nodeMatch,\n dispatch,\n }),\n ],\n ),\n ]);\n}\n\nfunction findMatchingNode(tree, nodeId) {\n let match = null;\n\n function traverse(node) {\n if (node.id === nodeId) {\n match = node;\n return true;\n }\n if (Array.isArray(node.children)) {\n for (const child of node.children) {\n if (traverse(child)) return true;\n }\n }\n return false;\n }\n\n tree.forEach(traverse);\n return match;\n}\n\nfunction MatchOverlay({ isOpen, setOverlayOpen, nodeMatch, dispatch }) {\n const [inputValue, setInputValue] = useState(nodeMatch?.name || \"\");\n const [selectedItem, setSelectedItem] = useState(h(\"div\", \"Select a match\"));\n const [disabled, setDisabled] = useState(true);\n const [payload, setPayload] = useState({});\n\n const data = useAPIResult(\n \"https://dev.macrostrat.org/api/pg/type_lookup?name=ilike.*\" +\n inputValue +\n \"*\",\n );\n const items = data?.map((data) => {\n const type = data.type || \"\";\n\n if (type === \"lith\") {\n return h(\n \"div\",\n {\n onClick: () => {\n setPayload({ lith_id: data.id, name: data.name });\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Lithology\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_id, color: data.color },\n }),\n }),\n );\n }\n\n if (type === \"strat_name\") {\n return h(\n \"div\",\n {\n onClick: () => {\n setPayload({ strat_name_id: data.id, name: data.name });\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Stratigraphic name\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.id, color: data.color },\n }),\n }),\n );\n }\n\n if (type === \"lith_att\") {\n return h(\n \"div\",\n {\n onClick: () => {\n setPayload({ lith_att_id: data.lith_att_id, name: data.name });\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Lithology attribute\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_att_id },\n }),\n onClick: () => {\n setPayload({ lith_att_id: data.lith_att_id, name: data.name });\n },\n }),\n );\n }\n\n if (type === \"interval\") {\n h(\n \"div\",\n {\n onClick: () => {\n setPayload({ int_id: data.id, name: data.name });\n },\n },\n h(DataField, {\n label: \"Interval\",\n className: \"match-item\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.id },\n }),\n onClick: () => {\n setPayload({ int_id: data.id, name: data.name });\n },\n }),\n );\n }\n\n return h(JSONView, { data });\n });\n\n return h(\n Overlay2,\n {\n isOpen,\n },\n h(\n \"div.overlay-container\",\n h(\"div.add-type-overlay\", [\n h(\"h2.title\", [\n \"Add match with \" + nodeMatch.name,\n h(Icon, {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: () => {\n setOverlayOpen(false);\n },\n style: { cursor: \"pointer\", color: \"red\" },\n }),\n ]),\n h(\"div.form-group\", [\n h(\n Select,\n {\n items: items || [],\n itemRenderer: (item, { handleClick }) => {\n return h(\"div.match-item\", { onClick: handleClick }, item);\n },\n onItemSelect: (item) => {\n setDisabled(false);\n setSelectedItem(item);\n },\n onQueryChange: (query) => setInputValue(query),\n popoverProps: { minimal: true },\n query: inputValue,\n placeholder: \"Enter match name\",\n },\n selectedItem,\n ),\n ]),\n h(\n SaveButton,\n {\n className: \"save-btn\",\n small: true,\n onClick: () => {\n // Handle save changes\n dispatch({\n type: \"add-match\",\n payload: { id: nodeMatch.id, payload },\n });\n setOverlayOpen(false);\n },\n disabled,\n },\n \"Save changes\",\n ),\n ]),\n ),\n );\n}\n"],"names":["Divider","$locXJ$Divider","Switch","$locXJ$Switch","Icon","$locXJ$Icon","Overlay2","$locXJ$Overlay2","Select","$locXJ$Select","$locXJ$macrostrathyper","useState","$locXJ$useState","useAPIResult","$locXJ$useAPIResult","DataField","$locXJ$DataField","JSONView","$locXJ$JSONView","SaveButton","$locXJ$SaveButton","LithologyTag","$locXJ$LithologyTag","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$3OP12","$9wFEx","$7accc8160d3205c1$var$h","styled","a","__esModule","default","$7accc8160d3205c1$export$6479cfcac2b87c0","match","setMatchLinks","matchLinks","selectedNodes","tree","dispatch","nodeId","overlayOpen","setOverlayOpen","nodeMatch","length","forEach","traverse","node","Array","isArray","children","child","if","label","checked","onChange","e","Match","data","onClick","icon","$7accc8160d3205c1$var$MatchOverlay","isOpen","inputValue","setInputValue","name","selectedItem","setSelectedItem","disabled","setDisabled","payload","setPayload","items","map","type","lith_id","className","value","color","strat_name_id","lith_att_id","int_id","style","cursor","itemRenderer","item","handleClick","onItemSelect","onQueryChange","query","popoverProps","minimal","placeholder","small","Matches"],"version":3,"file":"feedback-components.f8373b58.js.map","sourceRoot":"../../../../"}
@@ -1,2 +1,2 @@
1
- import"./feedback-components.b22d37d1.js";import"./feedback-components.9328e8ba.js";function e(e,a){return Object.keys(a).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})}),e}var a=globalThis,t={},r={},c=a.parcelRequirea149;null==c&&((c=function(e){if(e in t)return t[e].exports;if(e in r){var a=r[e];delete r[e];var c={id:e,exports:{}};return t[e]=c,a.call(c.exports,c,c.exports),c.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,a){r[e]=a},a.parcelRequirea149=c),c.register;var o={},n=c("edvRb"),d=c("aZPCw");e(o,n),e(o,d);export{$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,$2c86488f2f3c1edd$export$a90600c9da52b40c as FeedbackComponent,$330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};
1
+ import"./feedback-components.b22d37d1.js";import"./feedback-components.0eef8d0c.js";function e(e,a){return Object.keys(a).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})}),e}var a=globalThis,t={},r={},c=a.parcelRequirea149;null==c&&((c=function(e){if(e in t)return t[e].exports;if(e in r){var a=r[e];delete r[e];var c={id:e,exports:{}};return t[e]=c,a.call(c.exports,c,c.exports),c.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,a){r[e]=a},a.parcelRequirea149=c),c.register;var o={},n=c("edvRb"),d=c("aZPCw");e(o,n),e(o,d);export{$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,$2c86488f2f3c1edd$export$a90600c9da52b40c as FeedbackComponent,$330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};
2
2
  //# sourceMappingURL=index.js.map