@lv-x-software-house/x_view 1.2.8-dev.7 → 1.2.9-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +437 -417
  2. package/dist/index.mjs +475 -455
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -322,7 +322,12 @@ var updateExistingNodeVisuals = (state, updatedNode) => {
322
322
  if (oldLabelObject.material) oldLabelObject.material.dispose();
323
323
  }
324
324
  }
325
- const newMesh = createNodeMesh(updatedNode, position, state.glowTexture, hadQuestDateLabel);
325
+ const newMesh = createNodeMesh(
326
+ updatedNode,
327
+ position,
328
+ state.glowTexture,
329
+ hadQuestDateLabel
330
+ );
326
331
  if (oldTimelineBar) {
327
332
  newMesh.userData.timelineIntervalBar = oldTimelineBar;
328
333
  }
@@ -874,7 +879,12 @@ var removeNodeFromScene = (state, nodeId) => {
874
879
  var addStandaloneNodeToScene = (state, nodeData, position, forceShowQuestDate = false) => {
875
880
  const { graphGroup, nodeObjects, clickableNodes, glowTexture } = state;
876
881
  if (!graphGroup) return;
877
- const mesh = createNodeMesh(nodeData, position, glowTexture, forceShowQuestDate);
882
+ const mesh = createNodeMesh(
883
+ nodeData,
884
+ position,
885
+ glowTexture,
886
+ forceShowQuestDate
887
+ );
878
888
  mesh.scale.set(0.01, 0.01, 0.01);
879
889
  graphGroup.add(mesh);
880
890
  if (mesh.userData.labelObject) {
@@ -1092,7 +1102,9 @@ var userActionHandlers = {
1092
1102
  if (isCrossDataset) {
1093
1103
  graphDataRef.current[finalTargetDatasetId] = targetDataToUpdate;
1094
1104
  }
1095
- if (sceneDataRef.current.parent_dbs.some((db) => String(db.db_id) === String(sourceParentInfo.parentFileId))) {
1105
+ if (sceneDataRef.current.parent_dbs.some(
1106
+ (db) => String(db.db_id) === String(sourceParentInfo.parentFileId)
1107
+ )) {
1096
1108
  }
1097
1109
  const finalPosition = stateRef.current.ghostElements.node.position.clone();
1098
1110
  addNewNodeToScene(stateRef.current, newNode, newLink, finalPosition);
@@ -1287,7 +1299,10 @@ var userActionHandlers = {
1287
1299
  context.sceneSaveUrl,
1288
1300
  viewFilePayload
1289
1301
  );
1290
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
1302
+ const questSaveUrl = context.sceneSaveUrl.replace(
1303
+ "x_view_scenes",
1304
+ "x_view_quests"
1305
+ );
1291
1306
  await context.actions.save_view_data(questSaveUrl, questFilePayload);
1292
1307
  } else {
1293
1308
  const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
@@ -1363,7 +1378,12 @@ var userActionHandlers = {
1363
1378
  )
1364
1379
  );
1365
1380
  targetFinalPositions.push(endPosition);
1366
- const targetMesh = createNodeMesh(nodeData, startPosition, glowTexture);
1381
+ const targetMesh = createNodeMesh(
1382
+ nodeData,
1383
+ startPosition,
1384
+ glowTexture,
1385
+ !!nodeData.is_quest
1386
+ );
1367
1387
  targetMesh.scale.set(0.01, 0.01, 0.01);
1368
1388
  graphGroup.add(targetMesh);
1369
1389
  if (targetMesh.userData.labelObject) {
@@ -1515,10 +1535,16 @@ var userActionHandlers = {
1515
1535
  context.sceneConfigId,
1516
1536
  context.ownerId
1517
1537
  );
1518
- if (!sourceParentInfo || !sourceParentInfo.ownerId) {
1538
+ const targetParentInfo = getParentFileInfoForNode(
1539
+ graphDataRef.current,
1540
+ sceneDataRef.current,
1541
+ targetNodeData.id,
1542
+ context.sceneConfigId,
1543
+ context.ownerId
1544
+ );
1545
+ if (!sourceParentInfo || !sourceParentInfo.ownerId || !targetParentInfo) {
1519
1546
  console.error(
1520
- "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para o Node de origem:",
1521
- sourceNodeData.id
1547
+ "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para os Nodes da conex\xE3o."
1522
1548
  );
1523
1549
  alert(
1524
1550
  "Ocorreu um erro ao identificar o arquivo pai ou seu propriet\xE1rio."
@@ -1526,9 +1552,13 @@ var userActionHandlers = {
1526
1552
  userActionHandlers.handleCancelConnection(context);
1527
1553
  return;
1528
1554
  }
1529
- const { parentFileId: sourceParentFileId, ownerId: sourceOwnerId } = sourceParentInfo;
1530
- const parentFileIdToSave = sourceParentFileId;
1531
- const ownerIdToSave = sourceOwnerId;
1555
+ let parentInfoToSave = sourceParentInfo;
1556
+ const isSourceQuest = sourceParentInfo.parentFileId === context.sceneConfigId;
1557
+ const isTargetQuest = targetParentInfo.parentFileId === context.sceneConfigId;
1558
+ if (isSourceQuest || isTargetQuest) {
1559
+ parentInfoToSave = { parentFileId: context.sceneConfigId, ownerId: context.ownerId };
1560
+ }
1561
+ const { parentFileId: parentFileIdToSave, ownerId: ownerIdToSave } = parentInfoToSave;
1532
1562
  const newLink = {
1533
1563
  id: `link_${import_short_uuid.default.generate()}`,
1534
1564
  source: sourceNodeData.id,
@@ -1542,14 +1572,19 @@ var userActionHandlers = {
1542
1572
  const viewFilePayload = {
1543
1573
  parent_dbs: sceneDataRef.current.parent_dbs,
1544
1574
  nodes: sceneDataRef.current.nodes,
1545
- links: sceneDataRef.current.links,
1546
- quest_counter: sceneDataRef.current.quest_counter || 1
1575
+ links: sceneDataRef.current.links
1547
1576
  };
1548
1577
  await context.actions.save_view_data(
1549
1578
  context.sceneSaveUrl,
1550
1579
  viewFilePayload
1551
1580
  );
1552
- await context.actions.save_quest_link(context.ownerId, context.sceneConfigId, newLink);
1581
+ if (context.actions.upsert_quest_link_firestore) {
1582
+ await context.actions.upsert_quest_link_firestore(
1583
+ context.ownerId,
1584
+ context.sceneConfigId,
1585
+ newLink
1586
+ );
1587
+ }
1553
1588
  } else {
1554
1589
  const specificParentData = JSON.parse(
1555
1590
  JSON.stringify(graphDataRef.current[parentFileIdToSave])
@@ -1698,18 +1733,12 @@ var userActionHandlers = {
1698
1733
  const viewFilePayload = {
1699
1734
  parent_dbs: sceneDataRef.current.parent_dbs,
1700
1735
  nodes: sceneDataRef.current.nodes,
1701
- links: sceneDataRef.current.links,
1702
- quest_counter: sceneDataRef.current.quest_counter || 1
1736
+ links: sceneDataRef.current.links
1703
1737
  };
1704
- const questFilePayload = {
1705
- nodes: data.nodes,
1706
- links: data.links,
1707
- milestones: sceneDataRef.current.milestones || []
1708
- };
1709
- const p1 = context.actions.save_view_data(context.sceneSaveUrl, viewFilePayload);
1710
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
1711
- const p2 = context.actions.save_view_data(questSaveUrl, questFilePayload);
1712
- return Promise.all([p1, p2]);
1738
+ return context.actions.save_view_data(
1739
+ context.sceneSaveUrl,
1740
+ viewFilePayload
1741
+ );
1713
1742
  } else {
1714
1743
  return context.actions.save_view_data(
1715
1744
  `x_view_dbs/${fileOwnerId}/${fileId}`,
@@ -1734,6 +1763,15 @@ var userActionHandlers = {
1734
1763
  updatedOriginalParentData
1735
1764
  )
1736
1765
  );
1766
+ if (oldGoverningFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
1767
+ savePromises.push(
1768
+ context.actions.delete_quest_link_firestore(
1769
+ context.ownerId,
1770
+ context.sceneConfigId,
1771
+ linkId
1772
+ )
1773
+ );
1774
+ }
1737
1775
  const updatedNewParentData = JSON.parse(
1738
1776
  JSON.stringify(graphDataRef.current[newGoverningFileId])
1739
1777
  );
@@ -1747,6 +1785,15 @@ var userActionHandlers = {
1747
1785
  updatedNewParentData
1748
1786
  )
1749
1787
  );
1788
+ if (newGoverningFileId === context.sceneConfigId && context.actions.upsert_quest_link_firestore) {
1789
+ savePromises.push(
1790
+ context.actions.upsert_quest_link_firestore(
1791
+ context.ownerId,
1792
+ context.sceneConfigId,
1793
+ newLinkData
1794
+ )
1795
+ );
1796
+ }
1750
1797
  } else {
1751
1798
  const updatedParentData = JSON.parse(
1752
1799
  JSON.stringify(graphDataRef.current[oldGoverningFileId])
@@ -1763,6 +1810,15 @@ var userActionHandlers = {
1763
1810
  updatedParentData
1764
1811
  )
1765
1812
  );
1813
+ if (oldGoverningFileId === context.sceneConfigId && context.actions.upsert_quest_link_firestore) {
1814
+ savePromises.push(
1815
+ context.actions.upsert_quest_link_firestore(
1816
+ context.ownerId,
1817
+ context.sceneConfigId,
1818
+ newLinkData
1819
+ )
1820
+ );
1821
+ }
1766
1822
  }
1767
1823
  try {
1768
1824
  await Promise.all(savePromises);
@@ -1793,14 +1849,21 @@ var userActionHandlers = {
1793
1849
  );
1794
1850
  return;
1795
1851
  }
1796
- const parentInfo = getParentFileInfoForNode(
1852
+ const sourceParentInfo = getParentFileInfoForNode(
1797
1853
  graphDataRef.current,
1798
1854
  sceneDataRef.current,
1799
1855
  linkObject.userData.source,
1800
1856
  context.sceneConfigId,
1801
1857
  context.ownerId
1802
1858
  );
1803
- if (!parentInfo || !parentInfo.ownerId) {
1859
+ const targetParentInfo = getParentFileInfoForNode(
1860
+ graphDataRef.current,
1861
+ sceneDataRef.current,
1862
+ linkObject.userData.target,
1863
+ context.sceneConfigId,
1864
+ context.ownerId
1865
+ );
1866
+ if (!sourceParentInfo || !sourceParentInfo.ownerId) {
1804
1867
  console.error(
1805
1868
  "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para o link:",
1806
1869
  linkIdToDelete
@@ -1810,6 +1873,12 @@ var userActionHandlers = {
1810
1873
  );
1811
1874
  return;
1812
1875
  }
1876
+ let parentInfo = sourceParentInfo;
1877
+ const isSourceQuest = sourceParentInfo.parentFileId === context.sceneConfigId;
1878
+ const isTargetQuest = (targetParentInfo == null ? void 0 : targetParentInfo.parentFileId) === context.sceneConfigId;
1879
+ if (isSourceQuest || isTargetQuest) {
1880
+ parentInfo = { parentFileId: context.sceneConfigId, ownerId: context.ownerId };
1881
+ }
1813
1882
  const { parentFileId, ownerId } = parentInfo;
1814
1883
  const srcName = ((_c = (_b = (_a = linkObject.userData) == null ? void 0 : _a.sourceNode) == null ? void 0 : _b.userData) == null ? void 0 : _c.name) ?? linkObject.userData.source;
1815
1884
  const tgtName = ((_f = (_e = (_d = linkObject.userData) == null ? void 0 : _d.targetNode) == null ? void 0 : _e.userData) == null ? void 0 : _f.name) ?? linkObject.userData.target;
@@ -1822,8 +1891,6 @@ var userActionHandlers = {
1822
1891
  specificParentData.links = newLinks;
1823
1892
  let filenameToSave;
1824
1893
  let payloadToSave;
1825
- let questSaveUrl;
1826
- let questFilePayload;
1827
1894
  const isView = ((_g = context.viewType) == null ? void 0 : _g.toLowerCase()) === "view";
1828
1895
  if (isView && parentFileId === context.sceneConfigId) {
1829
1896
  filenameToSave = context.sceneSaveUrl;
@@ -1833,8 +1900,7 @@ var userActionHandlers = {
1833
1900
  payloadToSave = {
1834
1901
  parent_dbs: sceneDataRef.current.parent_dbs,
1835
1902
  nodes: sceneDataRef.current.nodes,
1836
- links: sceneDataRef.current.links,
1837
- quest_counter: sceneDataRef.current.quest_counter || 1
1903
+ links: sceneDataRef.current.links
1838
1904
  };
1839
1905
  } else {
1840
1906
  filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
@@ -1842,8 +1908,12 @@ var userActionHandlers = {
1842
1908
  }
1843
1909
  try {
1844
1910
  await context.actions.save_view_data(filenameToSave, payloadToSave);
1845
- if (isView && parentFileId === context.sceneConfigId && context.actions.delete_quest_link) {
1846
- await context.actions.delete_quest_link(ownerId, context.sceneConfigId, linkIdToDelete);
1911
+ if (isView && parentFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
1912
+ await context.actions.delete_quest_link_firestore(
1913
+ context.ownerId,
1914
+ context.sceneConfigId,
1915
+ linkIdToDelete
1916
+ );
1847
1917
  }
1848
1918
  graphDataRef.current[parentFileId] = specificParentData;
1849
1919
  setters.setDetailsLink(
@@ -2072,18 +2142,30 @@ var userActionHandlers = {
2072
2142
  payloadToSave = {
2073
2143
  parent_dbs: sceneDataRef.current.parent_dbs,
2074
2144
  nodes: sceneDataRef.current.nodes,
2075
- links: sceneDataRef.current.links,
2076
- quest_counter: sceneDataRef.current.quest_counter || 1
2145
+ links: sceneDataRef.current.links
2077
2146
  };
2078
- for (const nodeId of nodesToDelete) {
2079
- const questNode = (originalData.nodes || []).find((n) => String(n.id) === String(nodeId));
2080
- if (questNode && questNode.is_quest) {
2081
- await context.actions.delete_quest(ownerId, context.sceneConfigId, nodeId);
2147
+ if (context.actions.delete_quest_firestore) {
2148
+ nodesToDelete.forEach((nodeIdToDelete) => {
2149
+ savePromises.push(
2150
+ context.actions.delete_quest_firestore(
2151
+ context.ownerId,
2152
+ context.sceneConfigId,
2153
+ nodeIdToDelete
2154
+ )
2155
+ );
2156
+ });
2157
+ if (context.actions.delete_quest_link_firestore) {
2158
+ linksToDelete.forEach((linkIdToDelete) => {
2159
+ savePromises.push(
2160
+ context.actions.delete_quest_link_firestore(
2161
+ context.ownerId,
2162
+ context.sceneConfigId,
2163
+ linkIdToDelete
2164
+ )
2165
+ );
2166
+ });
2082
2167
  }
2083
2168
  }
2084
- for (const linkId of linksToDelete) {
2085
- await context.actions.delete_quest_link(ownerId, context.sceneConfigId, linkId);
2086
- }
2087
2169
  } else {
2088
2170
  filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
2089
2171
  payloadToSave = originalData;
@@ -2154,6 +2236,9 @@ var userActionHandlers = {
2154
2236
  const newLinks = (specificParentData.links || []).filter(
2155
2237
  (l) => String(l.source) !== strNodeId && String(l.target) !== strNodeId
2156
2238
  );
2239
+ const linksToDelete = (specificParentData.links || []).filter(
2240
+ (l) => String(l.source) === strNodeId || String(l.target) === strNodeId
2241
+ );
2157
2242
  specificParentData.nodes = newNodes;
2158
2243
  specificParentData.links = newLinks;
2159
2244
  let filenameToSave;
@@ -2172,12 +2257,27 @@ var userActionHandlers = {
2172
2257
  payloadToSave = {
2173
2258
  parent_dbs: sceneDataRef.current.parent_dbs,
2174
2259
  nodes: newVisualNodes,
2175
- links: newVisualLinks,
2176
- quest_counter: sceneDataRef.current.quest_counter || 1
2260
+ links: newVisualLinks
2177
2261
  };
2178
2262
  try {
2179
2263
  await context.actions.save_view_data(filenameToSave, payloadToSave);
2180
- await context.actions.delete_quest(ownerId, context.sceneConfigId, nodeIdToDelete);
2264
+ if (context.actions.delete_quest_firestore) {
2265
+ await context.actions.delete_quest_firestore(
2266
+ context.ownerId,
2267
+ context.sceneConfigId,
2268
+ nodeIdToDelete
2269
+ );
2270
+ if (context.actions.delete_quest_link_firestore && linksToDelete.length > 0) {
2271
+ const linkDeletePromises = linksToDelete.map(
2272
+ (link) => context.actions.delete_quest_link_firestore(
2273
+ context.ownerId,
2274
+ context.sceneConfigId,
2275
+ link.id
2276
+ )
2277
+ );
2278
+ await Promise.all(linkDeletePromises);
2279
+ }
2280
+ }
2181
2281
  graphDataRef.current[parentFileId] = specificParentData;
2182
2282
  setters.setDetailsNode(
2183
2283
  (prev) => String(prev == null ? void 0 : prev.id) === String(nodeIdToDelete) ? null : prev
@@ -2207,9 +2307,10 @@ var userActionHandlers = {
2207
2307
  }
2208
2308
  },
2209
2309
  handleSaveNodeDetails: async (context, updatedNode, keepOpen = false) => {
2210
- var _a, _b, _c;
2310
+ var _a, _b, _c, _d;
2211
2311
  const { graphDataRef, sceneDataRef, stateRef, setters } = context;
2212
2312
  if (!graphDataRef.current || !sceneDataRef.current) return;
2313
+ const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2213
2314
  const {
2214
2315
  _baseEmissiveIntensity,
2215
2316
  _baseScale,
@@ -2254,7 +2355,7 @@ var userActionHandlers = {
2254
2355
  const oldNode = specificParentData.nodes[nodeIndex];
2255
2356
  const isNewDone = oldNode.status !== "Done" && nodeToSave.status === "Done";
2256
2357
  specificParentData.nodes[nodeIndex] = { ...nodeToSave };
2257
- if (isNewDone && nodeToSave.is_quest && ((_a = nodeToSave.recurrence_config) == null ? void 0 : _a.enabled)) {
2358
+ if (isNewDone && nodeToSave.is_quest && ((_b = nodeToSave.recurrence_config) == null ? void 0 : _b.enabled)) {
2258
2359
  const nextDateObj = calculateNextRecurrenceDate(
2259
2360
  nodeToSave.recurrence_config
2260
2361
  );
@@ -2279,12 +2380,10 @@ var userActionHandlers = {
2279
2380
  }
2280
2381
  const nextQuestNode = {
2281
2382
  ...JSON.parse(JSON.stringify(nodeToSave)),
2282
- // Deep copy properties
2283
2383
  id: import_short_uuid.default.generate(),
2284
2384
  name: nextName,
2285
2385
  status: "Backlog",
2286
2386
  color: "#64748b",
2287
- // QUEST_STATUS_COLORS["Backlog"]
2288
2387
  assignee_id: nodeToSave.recurrence_config.next_assignee_id || "",
2289
2388
  Date: nextDateObj,
2290
2389
  timeline: [
@@ -2301,7 +2400,7 @@ var userActionHandlers = {
2301
2400
  ],
2302
2401
  version_node: {
2303
2402
  is_version: true,
2304
- parent_node: ((_b = nodeToSave.version_node) == null ? void 0 : _b.parent_node) || nodeToSave.id
2403
+ parent_node: ((_c = nodeToSave.version_node) == null ? void 0 : _c.parent_node) || nodeToSave.id
2305
2404
  },
2306
2405
  reviewStack: (nodeToSave.reviewStack || []).map((r) => ({
2307
2406
  ...r,
@@ -2309,21 +2408,56 @@ var userActionHandlers = {
2309
2408
  })),
2310
2409
  recurrence_config: nextRecurrenceConfig
2311
2410
  };
2312
- specificParentData.nodes.push(nextQuestNode);
2411
+ const rootId = ((_d = nodeToSave.version_node) == null ? void 0 : _d.parent_node) || nodeToSave.id;
2412
+ const nextQuestLink = {
2413
+ id: `link_${import_short_uuid.default.generate()}`,
2414
+ source: rootId,
2415
+ target: nextQuestNode.id
2416
+ };
2417
+ await context.actions.upsert_quest_firestore(
2418
+ context.ownerId,
2419
+ context.sceneConfigId,
2420
+ nextQuestNode
2421
+ );
2422
+ await context.actions.upsert_quest_link_firestore(
2423
+ context.ownerId,
2424
+ context.sceneConfigId,
2425
+ nextQuestLink
2426
+ );
2427
+ await context.actions.update_view_counter(
2428
+ context.ownerId,
2429
+ context.sceneConfigId,
2430
+ nextCounter
2431
+ );
2432
+ if (specificParentData.links) {
2433
+ specificParentData.links.push(nextQuestLink);
2434
+ }
2435
+ if (specificParentData.nodes) {
2436
+ specificParentData.nodes.push(nextQuestNode);
2437
+ }
2438
+ if (isView && parentFileId === context.sceneConfigId) {
2439
+ if (!sceneDataRef.current.links) sceneDataRef.current.links = [];
2440
+ sceneDataRef.current.links.push(nextQuestLink);
2441
+ sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
2442
+ }
2313
2443
  if (stateRef.current.nodeObjects[String(nodeToSave.id)]) {
2314
2444
  const oldMeshPosition = stateRef.current.nodeObjects[String(nodeToSave.id)].position.clone();
2315
2445
  setTimeout(() => {
2316
2446
  if (stateRef.current && stateRef.current.graphGroup) {
2317
2447
  const pos = oldMeshPosition.clone();
2318
2448
  pos.x += 12;
2319
- addStandaloneNodeToScene(stateRef.current, nextQuestNode, pos, true);
2449
+ addStandaloneNodeToScene(
2450
+ stateRef.current,
2451
+ nextQuestNode,
2452
+ pos,
2453
+ true
2454
+ );
2320
2455
  }
2321
2456
  }, 2e3);
2322
2457
  }
2323
2458
  }
2324
2459
  }
2325
2460
  try {
2326
- const isView = ((_c = context.viewType) == null ? void 0 : _c.toLowerCase()) === "view";
2327
2461
  if (isView && parentFileId === context.sceneConfigId) {
2328
2462
  const visualNodeIndex = sceneDataRef.current.nodes.findIndex(
2329
2463
  (n) => String(n.id) === String(nodeToSave.id)
@@ -2337,14 +2471,24 @@ var userActionHandlers = {
2337
2471
  const viewFilePayload = {
2338
2472
  parent_dbs: sceneDataRef.current.parent_dbs,
2339
2473
  nodes: sceneDataRef.current.nodes,
2340
- links: sceneDataRef.current.links,
2341
- quest_counter: sceneDataRef.current.quest_counter || 1
2474
+ links: sceneDataRef.current.links
2475
+ };
2476
+ const questFilePayload = {
2477
+ nodes: specificParentData.nodes,
2478
+ links: specificParentData.links,
2479
+ milestones: sceneDataRef.current.milestones || []
2342
2480
  };
2343
2481
  await context.actions.save_view_data(
2344
2482
  context.sceneSaveUrl,
2345
2483
  viewFilePayload
2346
2484
  );
2347
- await context.actions.save_quest(ownerId, context.sceneConfigId, nodeToSave);
2485
+ if (context.actions.upsert_quest_firestore) {
2486
+ await context.actions.upsert_quest_firestore(
2487
+ context.ownerId,
2488
+ context.sceneConfigId,
2489
+ nodeToSave
2490
+ );
2491
+ }
2348
2492
  } else {
2349
2493
  const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
2350
2494
  await context.actions.save_view_data(
@@ -2355,7 +2499,6 @@ var userActionHandlers = {
2355
2499
  graphDataRef.current[parentFileId] = specificParentData;
2356
2500
  if (isView && parentFileId === context.sceneConfigId) {
2357
2501
  sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
2358
- sceneDataRef.current.quest_counter = specificParentData.quest_counter || sceneDataRef.current.quest_counter;
2359
2502
  }
2360
2503
  updateExistingNodeVisuals(stateRef.current, nodeToSave);
2361
2504
  setters.setSceneVersion((v) => v + 1);
@@ -2412,8 +2555,7 @@ var userActionHandlers = {
2412
2555
  const viewFilePayload = {
2413
2556
  parent_dbs: sceneDataRef.current.parent_dbs,
2414
2557
  nodes: sceneDataRef.current.nodes,
2415
- links: sceneDataRef.current.links,
2416
- quest_counter: sceneDataRef.current.quest_counter || 1
2558
+ links: sceneDataRef.current.links
2417
2559
  };
2418
2560
  const questFilePayload = {
2419
2561
  nodes: specificParentData.nodes,
@@ -2424,8 +2566,13 @@ var userActionHandlers = {
2424
2566
  context.sceneSaveUrl,
2425
2567
  viewFilePayload
2426
2568
  );
2427
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
2428
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
2569
+ if (context.actions.upsert_quest_link_firestore) {
2570
+ await context.actions.upsert_quest_link_firestore(
2571
+ context.ownerId,
2572
+ context.sceneConfigId,
2573
+ linkToSave
2574
+ );
2575
+ }
2429
2576
  } else {
2430
2577
  const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
2431
2578
  await context.actions.save_view_data(
@@ -2520,7 +2667,7 @@ function createNewCustomProperty(existingProps = []) {
2520
2667
  nextValue = [{ id: (0, import_uuid.v4)(), name: "1", value: "" }];
2521
2668
  break;
2522
2669
  case "date":
2523
- nextKey = "Date";
2670
+ nextKey = "Data";
2524
2671
  nextValue = { type: "Data", value: "" };
2525
2672
  break;
2526
2673
  case "number":
@@ -2774,7 +2921,7 @@ var IGNORED_KEYS = [
2774
2921
  ];
2775
2922
  function extractCustomPropsFromNode(node) {
2776
2923
  const customPropTypes = node._customPropTypes || {};
2777
- return Object.keys(node).filter((k) => !IGNORED_KEYS.includes(k)).map((key) => {
2924
+ return Object.keys(node).filter((k) => !IGNORED_KEYS.includes(k) || customPropTypes[k]).map((key) => {
2778
2925
  const val = node[key];
2779
2926
  const t = customPropTypes[key] || inferPropType(val);
2780
2927
  if (t === "date") {
@@ -3290,6 +3437,17 @@ var parseDate = (str) => {
3290
3437
  }
3291
3438
  return null;
3292
3439
  };
3440
+ function extractDatePropFromNode(node) {
3441
+ if (!node) return null;
3442
+ if (node.Date) return node.Date;
3443
+ if (node._customPropTypes) {
3444
+ const dateKey = Object.keys(node._customPropTypes).find(
3445
+ (k) => node._customPropTypes[k] === "date"
3446
+ );
3447
+ if (dateKey && node[dateKey]) return node[dateKey];
3448
+ }
3449
+ return null;
3450
+ }
3293
3451
  var parseDateProp = (dateProp) => {
3294
3452
  let info = { isUndated: true, label: "", type: "point" };
3295
3453
  if (!dateProp) return info;
@@ -4963,7 +5121,7 @@ function CustomPropertyDisplay({
4963
5121
  links: "Links",
4964
5122
  images: "Images",
4965
5123
  documents: "Documents",
4966
- date: "Date"
5124
+ date: "Data"
4967
5125
  };
4968
5126
  const oldKeyIsFixed = Object.values(fixedKeyMap).includes(tempProp.key);
4969
5127
  if (fixedKeyMap[value]) {
@@ -8908,6 +9066,7 @@ function CreateQuestTreePanel({
8908
9066
  const [isSaving, setIsSaving] = (0, import_react12.useState)(false);
8909
9067
  const [hasUnsavedChanges, setHasUnsavedChanges] = (0, import_react12.useState)(false);
8910
9068
  const [activeTab, setActiveTab] = (0, import_react12.useState)("tree");
9069
+ const isInitialLoad = (0, import_react12.useRef)(true);
8911
9070
  const maxPanelW = typeof window !== "undefined" ? window.innerWidth * 0.92 : 1200;
8912
9071
  const { width: panelWidth, isResizing, handlePointerDown: handleResize } = useResizablePanel({
8913
9072
  initialWidth: 440,
@@ -8941,10 +9100,11 @@ function CreateQuestTreePanel({
8941
9100
  const indexToRemove = pathToRemove[pathToRemove.length - 1];
8942
9101
  if (currentParent.children && currentParent.children.length > indexToRemove) {
8943
9102
  currentParent.children.splice(indexToRemove, 1);
8944
- setHasUnsavedChanges(true);
9103
+ return { ...prev, [treeKey]: newTree };
8945
9104
  }
8946
- return { ...prev, [treeKey]: newTree };
9105
+ return prev;
8947
9106
  });
9107
+ setHasUnsavedChanges(true);
8948
9108
  }, [setQuestTreeMode, activeTab]);
8949
9109
  const handleMoveNode = (sourceId, targetId) => {
8950
9110
  const isAbstraction = activeTab === "abstraction";
@@ -9021,6 +9181,15 @@ function CreateQuestTreePanel({
9021
9181
  }));
9022
9182
  }
9023
9183
  }, [tree, abstraction_tree, questTreeMode.questNodeId, setQuestTreeMode]);
9184
+ (0, import_react12.useEffect)(() => {
9185
+ if (tree || abstraction_tree) {
9186
+ if (isInitialLoad.current) {
9187
+ isInitialLoad.current = false;
9188
+ return;
9189
+ }
9190
+ setHasUnsavedChanges(true);
9191
+ }
9192
+ }, [tree, abstraction_tree]);
9024
9193
  return /* @__PURE__ */ import_react12.default.createElement(
9025
9194
  "div",
9026
9195
  {
@@ -12331,7 +12500,6 @@ function QuestDetailsPanel({
12331
12500
  setIsSaving(false);
12332
12501
  }
12333
12502
  };
12334
- const filteredCustomProps = customProps.filter((p) => p.key !== "Date" && p.key !== "Data");
12335
12503
  const handleAddTimelineNote = async () => {
12336
12504
  if (!noteText.trim() && noteLinks.length === 0 && noteImages.length === 0 || isSaving) return;
12337
12505
  setIsSaving(true);
@@ -15456,12 +15624,12 @@ function XViewScene({
15456
15624
  get_view_members,
15457
15625
  create_google_doc_action,
15458
15626
  open_google_picker_action,
15459
- save_quest_action,
15460
- delete_quest_action,
15461
- save_quest_link_action,
15462
- delete_quest_link_action,
15463
- get_view_quests_and_links_action,
15464
- migrate_legacy_quests_action
15627
+ upsert_quest_firestore,
15628
+ delete_quest_firestore,
15629
+ upsert_quest_link_firestore,
15630
+ delete_quest_link_firestore,
15631
+ upsert_milestone_firestore,
15632
+ update_view_counter
15465
15633
  }) {
15466
15634
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
15467
15635
  const { data: session, status } = (0, import_react34.useSession)();
@@ -16020,12 +16188,20 @@ function XViewScene({
16020
16188
  obj.material.dispose();
16021
16189
  }
16022
16190
  }
16023
- Object.values(nodeObjects || {}).forEach((mesh) => {
16024
- const oldLabel = mesh.getObjectByName("timelineLabel");
16025
- if (oldLabel) {
16026
- mesh.remove(oldLabel);
16027
- if (oldLabel.material.map) oldLabel.material.map.dispose();
16028
- oldLabel.material.dispose();
16191
+ Object.values(nodeObjects).forEach((mesh) => {
16192
+ const oldTimelineLabel = mesh.getObjectByName("timelineLabel");
16193
+ if (oldTimelineLabel) {
16194
+ mesh.remove(oldTimelineLabel);
16195
+ if (oldTimelineLabel.material.map)
16196
+ oldTimelineLabel.material.map.dispose();
16197
+ oldTimelineLabel.material.dispose();
16198
+ }
16199
+ const oldQuestDateLabel = mesh.getObjectByName("questDateLabel");
16200
+ if (oldQuestDateLabel) {
16201
+ mesh.remove(oldQuestDateLabel);
16202
+ if (oldQuestDateLabel.material.map)
16203
+ oldQuestDateLabel.material.map.dispose();
16204
+ oldQuestDateLabel.material.dispose();
16029
16205
  }
16030
16206
  delete mesh.userData.timelineIntervalBar;
16031
16207
  delete mesh.userData.timelineEndLabel;
@@ -16044,43 +16220,19 @@ function XViewScene({
16044
16220
  }
16045
16221
  return null;
16046
16222
  };
16047
- Object.values(nodeObjects || {}).forEach((mesh) => {
16048
- const dateProp = mesh.userData.Date;
16223
+ Object.values(nodeObjects).forEach((mesh) => {
16224
+ const dateProp = extractDatePropFromNode(mesh.userData);
16049
16225
  let nodeInfo = { mesh, type: "point", label: "", isUndated: true };
16050
16226
  if (dateProp) {
16051
- if (dateProp.date) {
16052
- const date = parseDate2(dateProp.date);
16053
- if (date) {
16054
- nodeInfo.startDate = date;
16055
- nodeInfo.endDate = date;
16056
- nodeInfo.label = dateProp.date;
16057
- nodeInfo.isUndated = false;
16058
- allTimePoints.add(date.getTime());
16059
- }
16060
- } else if (dateProp.year) {
16061
- const year = parseInt(dateProp.year, 10);
16062
- if (!isNaN(year)) {
16063
- const date = new Date(year, 0, 1);
16064
- nodeInfo.startDate = date;
16065
- nodeInfo.endDate = date;
16066
- nodeInfo.label = String(year);
16067
- nodeInfo.isUndated = false;
16068
- allTimePoints.add(date.getTime());
16069
- }
16070
- } else if (dateProp.date_interval && dateProp.date_interval.start) {
16071
- const startYear = parseInt(dateProp.date_interval.start, 10);
16072
- const endYear = parseInt(dateProp.date_interval.end, 10) || startYear;
16073
- if (!isNaN(startYear)) {
16074
- const startDate = new Date(startYear, 0, 1);
16075
- const endDate = new Date(endYear, 11, 31);
16076
- nodeInfo.type = "interval";
16077
- nodeInfo.startDate = startDate;
16078
- nodeInfo.endDate = endDate;
16079
- nodeInfo.label = `${startYear} - ${endYear}`;
16080
- nodeInfo.isUndated = false;
16081
- allTimePoints.add(startDate.getTime());
16082
- allTimePoints.add(endDate.getTime());
16083
- }
16227
+ const info = parseDateProp(dateProp);
16228
+ if (!info.isUndated) {
16229
+ nodeInfo.startDate = info.startDate;
16230
+ nodeInfo.endDate = info.endDate;
16231
+ nodeInfo.label = info.label;
16232
+ nodeInfo.type = info.type;
16233
+ nodeInfo.isUndated = false;
16234
+ allTimePoints.add(info.startDate.getTime());
16235
+ if (info.endDate) allTimePoints.add(info.endDate.getTime());
16084
16236
  }
16085
16237
  }
16086
16238
  timelineNodes.push(nodeInfo);
@@ -16208,50 +16360,29 @@ function XViewScene({
16208
16360
  return null;
16209
16361
  };
16210
16362
  versionMeshes.forEach((mesh) => {
16211
- const dateProp = mesh.userData.Date;
16363
+ const dateProp = extractDatePropFromNode(mesh.userData);
16212
16364
  if (!dateProp) return;
16213
- let nodeInfo = { mesh, type: "point", label: "" };
16214
- if (dateProp.date) {
16215
- const date = parseDate2(dateProp.date);
16216
- if (date) {
16217
- nodeInfo.startDate = date;
16218
- nodeInfo.endDate = date;
16219
- nodeInfo.label = dateProp.date;
16220
- allTimePoints.add(date.getTime());
16221
- timelineNodes.push(nodeInfo);
16222
- }
16223
- } else if (dateProp.year) {
16224
- const year = parseInt(dateProp.year, 10);
16225
- if (!isNaN(year)) {
16226
- const date = new Date(year, 0, 1);
16227
- nodeInfo.startDate = date;
16228
- nodeInfo.endDate = date;
16229
- nodeInfo.label = String(year);
16230
- allTimePoints.add(date.getTime());
16231
- timelineNodes.push(nodeInfo);
16232
- }
16233
- } else if (dateProp.date_interval && dateProp.date_interval.start) {
16234
- const startYear = parseInt(dateProp.date_interval.start, 10);
16235
- const endYear = parseInt(dateProp.date_interval.end, 10) || startYear;
16236
- if (!isNaN(startYear)) {
16237
- const startDate = new Date(startYear, 0, 1);
16238
- const endDate = new Date(endYear, 11, 31);
16239
- nodeInfo.type = "interval";
16240
- nodeInfo.startDate = startDate;
16241
- nodeInfo.endDate = endDate;
16242
- nodeInfo.label = `${startYear} - ${endYear}`;
16243
- allTimePoints.add(startDate.getTime());
16244
- allTimePoints.add(endDate.getTime());
16245
- timelineNodes.push(nodeInfo);
16246
- }
16365
+ const info = parseDateProp(dateProp);
16366
+ if (!info.isUndated) {
16367
+ const nodeInfo = {
16368
+ mesh,
16369
+ type: info.type,
16370
+ startDate: info.startDate,
16371
+ endDate: info.endDate,
16372
+ label: info.label
16373
+ };
16374
+ allTimePoints.add(info.startDate.getTime());
16375
+ if (info.endDate) allTimePoints.add(info.endDate.getTime());
16376
+ timelineNodes.push(nodeInfo);
16247
16377
  }
16248
16378
  });
16249
16379
  if (timelineNodes.length === 0) return;
16250
16380
  const sortedTimePoints = Array.from(allTimePoints).sort((a, b) => a - b);
16381
+ const maxTimeIndex = sortedTimePoints.length - 1;
16251
16382
  const timeToYMap = new Map(
16252
16383
  sortedTimePoints.map((time, index) => [
16253
16384
  time,
16254
- index * TIMELINE_LAYER_SPACING_Y
16385
+ (index - maxTimeIndex) * TIMELINE_LAYER_SPACING_Y
16255
16386
  ])
16256
16387
  );
16257
16388
  timelineNodes.sort(
@@ -16259,18 +16390,38 @@ function XViewScene({
16259
16390
  );
16260
16391
  const baseX = sourceMesh.position.x + TIMELINE_NODE_SPACING_X;
16261
16392
  const baseY = sourceMesh.position.y;
16262
- const maxNodeIndex = timelineNodes.length - 1;
16263
- timelineNodes.forEach((node, index) => {
16393
+ const columns = [];
16394
+ const allFinalPoints = [sourceMesh.position.clone()];
16395
+ timelineNodes.forEach((node) => {
16264
16396
  const { mesh, type, startDate, endDate, label } = node;
16265
- const y = baseY + (index - maxNodeIndex) * TIMELINE_LAYER_SPACING_Y;
16266
- const versionTween = new import_tween2.Tween(mesh.position).to({ x: baseX, y, z: 0 }, 1500).easing(import_tween2.Easing.Cubic.InOut);
16397
+ const startY = timeToYMap.get(startDate.getTime());
16398
+ const endY = timeToYMap.get(endDate.getTime()) || startY;
16399
+ let foundColumn = false;
16400
+ for (let i = 0; i < columns.length; i++) {
16401
+ if (columns[i].endY < startY) {
16402
+ node.columnIndex = i;
16403
+ columns[i].endY = endY;
16404
+ foundColumn = true;
16405
+ break;
16406
+ }
16407
+ }
16408
+ if (!foundColumn) {
16409
+ node.columnIndex = columns.length;
16410
+ columns.push({ endY });
16411
+ }
16412
+ const x = baseX + node.columnIndex * TIMELINE_NODE_SPACING_X;
16413
+ const y = baseY + startY;
16414
+ allFinalPoints.push(new THREE3.Vector3(x, y, 0));
16415
+ const versionTween = new import_tween2.Tween(mesh.position).to({ x, y, z: 0 }, 1500).easing(import_tween2.Easing.Cubic.InOut);
16267
16416
  tweenGroup.add(versionTween);
16268
16417
  versionTween.start();
16269
- const startLabelText = type === "interval" ? startDate.getFullYear().toString() : label;
16270
- const startLabel = createTextSprite(startLabelText, 48);
16271
- startLabel.name = "timelineLabel";
16272
- startLabel.position.set(0, -2.5, 0);
16273
- mesh.add(startLabel);
16418
+ if (!mesh.getObjectByName("questDateLabel")) {
16419
+ const startLabelText = type === "interval" ? startDate.getFullYear().toString() : label;
16420
+ const startLabel = createTextSprite(startLabelText, 48);
16421
+ startLabel.name = "timelineLabel";
16422
+ startLabel.position.set(0, -2.5, 0);
16423
+ mesh.add(startLabel);
16424
+ }
16274
16425
  if (type === "interval") {
16275
16426
  const relativeEndY = timeToYMap.get(endDate.getTime()) - timeToYMap.get(startDate.getTime());
16276
16427
  if (relativeEndY > 0) {
@@ -16304,7 +16455,21 @@ function XViewScene({
16304
16455
  }
16305
16456
  }
16306
16457
  });
16307
- }, []);
16458
+ if (allFinalPoints.length > 0) {
16459
+ const boundingBox = new THREE3.Box3().setFromPoints(allFinalPoints);
16460
+ const center = new THREE3.Vector3();
16461
+ boundingBox.getCenter(center);
16462
+ const size = new THREE3.Vector3();
16463
+ boundingBox.getSize(size);
16464
+ const spread = Math.max(size.x, size.y, size.z, 1);
16465
+ const desiredDistance = Math.max(
16466
+ x_view_config.CAMERA_ZOOM_DISTANCE,
16467
+ spread * 1.5
16468
+ );
16469
+ const zoomFactor = x_view_config.CAMERA_ZOOM_DISTANCE / desiredDistance;
16470
+ tweenToTarget(center, zoomFactor);
16471
+ }
16472
+ }, [tweenToTarget]);
16308
16473
  (0, import_react33.useEffect)(() => {
16309
16474
  async function fetchAllData(configPath, ownerId2) {
16310
16475
  var _a2, _b2;
@@ -16325,40 +16490,19 @@ function XViewScene({
16325
16490
  focusAncestryId
16326
16491
  );
16327
16492
  const boardPromise = get_boards_action && session ? get_boards_action(configPath, sceneType, session, ownerId2) : Promise.resolve({ success: false, data: [] });
16328
- const questPromise = get_view_quests_and_links_action && session ? get_view_quests_and_links_action(ownerId2, sceneConfigId) : Promise.resolve({ success: false, quests: [], links: [] });
16329
- const [sceneResponse, boardResponse, questResponse] = await Promise.all([
16493
+ const [sceneResponse, boardResponse] = await Promise.all([
16330
16494
  scenePromise,
16331
- boardPromise,
16332
- questPromise
16495
+ boardPromise
16333
16496
  ]);
16334
16497
  if ((sceneResponse == null ? void 0 : sceneResponse.success) && ((_a2 = sceneResponse.data) == null ? void 0 : _a2.scene) && ((_b2 = sceneResponse.data) == null ? void 0 : _b2.parent)) {
16335
- const sceneData = sceneResponse.data.scene;
16336
- let firestoreQuests = (questResponse == null ? void 0 : questResponse.success) && Array.isArray(questResponse.quests) ? questResponse.quests : [];
16337
- let firestoreLinks = (questResponse == null ? void 0 : questResponse.success) && Array.isArray(questResponse.links) ? questResponse.links : [];
16338
- if (!sceneData.quests_migrated && firestoreQuests.length === 0) {
16339
- const legacyQuests = sceneData.quest_nodes || [];
16340
- const legacyLinks = sceneData.quest_links || [];
16341
- if ((legacyQuests.length > 0 || legacyLinks.length > 0) && migrate_legacy_quests_action) {
16342
- console.log(
16343
- "X-View: Iniciando Lazy Migration de Quests para Firestore..."
16344
- );
16345
- await migrate_legacy_quests_action(ownerId2, sceneConfigId, {
16346
- nodes: legacyQuests,
16347
- links: legacyLinks
16348
- });
16349
- firestoreQuests = legacyQuests;
16350
- firestoreLinks = legacyLinks;
16351
- sceneData.quests_migrated = true;
16352
- }
16353
- }
16354
16498
  if (focusNodeId) {
16355
16499
  let targetNode = sceneResponse.data.scene.nodes.find(
16356
16500
  (n) => String(n.id) === String(focusNodeId)
16357
16501
  );
16358
16502
  if (!targetNode) {
16359
16503
  const allParentNodes = Object.values(
16360
- sceneResponse.data.parent || {}
16361
- ).flatMap((f) => (f == null ? void 0 : f.nodes) || []);
16504
+ sceneResponse.data.parent
16505
+ ).flatMap((f) => f.nodes || []);
16362
16506
  targetNode = allParentNodes.find(
16363
16507
  (n) => String(n.id) === String(focusNodeId)
16364
16508
  );
@@ -16372,29 +16516,10 @@ function XViewScene({
16372
16516
  sceneResponse.data.scene.links = [];
16373
16517
  }
16374
16518
  sceneDataRef.current = {
16375
- ...sceneData,
16376
- quests_migrated: sceneData.quests_migrated || false,
16377
- milestones: sceneData.milestones || []
16519
+ ...sceneResponse.data.scene,
16520
+ milestones: sceneResponse.data.scene.milestones || []
16378
16521
  };
16379
- const currentParentData = sceneResponse.data.parent;
16380
- if (currentParentData && currentParentData[sceneConfigId]) {
16381
- const existingNodes = currentParentData[sceneConfigId].nodes || [];
16382
- const firestoreQuestIds = new Set(firestoreQuests.map((q) => String(q.id)));
16383
- const filteredExisting = existingNodes.filter(
16384
- (n) => !firestoreQuestIds.has(String(n.id))
16385
- );
16386
- currentParentData[sceneConfigId].nodes = [
16387
- ...filteredExisting,
16388
- ...firestoreQuests
16389
- ];
16390
- if (firestoreLinks && firestoreLinks.length > 0) {
16391
- currentParentData[sceneConfigId].links = [
16392
- ...currentParentData[sceneConfigId].links || [],
16393
- ...firestoreLinks
16394
- ];
16395
- }
16396
- }
16397
- parentDataRef.current = currentParentData;
16522
+ parentDataRef.current = sceneResponse.data.parent;
16398
16523
  ancestryDataRef.current = sceneResponse.data.ancestry;
16399
16524
  console.log(
16400
16525
  "Console de sceneResponse.data.scene:",
@@ -16700,7 +16825,7 @@ function XViewScene({
16700
16825
  positionGroups.get(posKey).push(String(q.id));
16701
16826
  });
16702
16827
  });
16703
- Object.values(nodeObjects || {}).forEach((mesh) => {
16828
+ Object.values(nodeObjects).forEach((mesh) => {
16704
16829
  const oldLabel = mesh.getObjectByName("questDateLabel") || mesh.getObjectByName("timelineLabel");
16705
16830
  if (oldLabel) {
16706
16831
  mesh.remove(oldLabel);
@@ -18009,12 +18134,13 @@ function XViewScene({
18009
18134
  get_scene_view_data,
18010
18135
  upload_file: upload_file_action,
18011
18136
  delete_file: delete_file_action,
18012
- save_quest: save_quest_action,
18013
- delete_quest: delete_quest_action,
18014
- save_quest_link: save_quest_link_action,
18015
- delete_quest_link: delete_quest_link_action,
18016
- get_view_quests_and_links: get_view_quests_and_links_action,
18017
- migrate_legacy_quests: migrate_legacy_quests_action
18137
+ // Adicionado novas importações aqui
18138
+ upsert_quest_firestore,
18139
+ delete_quest_firestore,
18140
+ upsert_quest_link_firestore,
18141
+ delete_quest_link_firestore,
18142
+ upsert_milestone_firestore,
18143
+ update_view_counter
18018
18144
  }
18019
18145
  };
18020
18146
  },
@@ -18034,12 +18160,12 @@ function XViewScene({
18034
18160
  get_scene_view_data,
18035
18161
  upload_file_action,
18036
18162
  delete_file_action,
18037
- save_quest_action,
18038
- delete_quest_action,
18039
- save_quest_link_action,
18040
- delete_quest_link_action,
18041
- get_view_quests_and_links_action,
18042
- migrate_legacy_quests_action
18163
+ upsert_quest_firestore,
18164
+ delete_quest_firestore,
18165
+ upsert_quest_link_firestore,
18166
+ delete_quest_link_firestore,
18167
+ upsert_milestone_firestore,
18168
+ update_view_counter
18043
18169
  ]
18044
18170
  );
18045
18171
  const handleStartVersioning = (nodeData) => {
@@ -18049,7 +18175,7 @@ function XViewScene({
18049
18175
  (questNode) => {
18050
18176
  var _a2, _b2, _c2;
18051
18177
  if (!questNode || !actionHandlerContext) return;
18052
- const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
18178
+ const allParentNodes = Object.values(parentDataRef.current).flatMap(
18053
18179
  (fileData) => fileData.nodes || []
18054
18180
  );
18055
18181
  const blockCheck = isQuestBlocked(questNode, allParentNodes);
@@ -18245,36 +18371,30 @@ function XViewScene({
18245
18371
  parentDataRef.current[sceneConfigId].nodes[parentIndex].quest_abstraction_tree = formattedAbstractionTree;
18246
18372
  }
18247
18373
  }
18248
- const sceneFileData = {
18249
- ...sceneData,
18250
- nodes: sceneData.nodes || [],
18251
- links: sceneData.links || [],
18252
- quest_counter: sceneData.quest_counter || 1
18253
- };
18254
- const questFileData = {
18255
- nodes: sceneData.quest_nodes || [],
18256
- links: sceneData.quest_links || [],
18257
- milestones: sceneData.milestones || []
18258
- };
18259
- await save_view_data(sceneSaveUrl, sceneFileData);
18260
- await save_quest_action(ownerId, sceneConfigId, updatedNodeData);
18261
- }
18262
- const updatedNodeData = sceneData.quest_nodes[questIndex];
18263
- const nodeMesh = (_a2 = stateRef.current.nodeObjects) == null ? void 0 : _a2[String(questNodeId)];
18264
- if (nodeMesh) {
18265
- nodeMesh.userData = {
18266
- ...nodeMesh.userData,
18267
- ...updatedNodeData
18268
- };
18269
- }
18270
- if (detailsNode && String(detailsNode.id) === String(questNodeId)) {
18271
- setDetailsNode((prev) => ({
18272
- ...prev,
18273
- quest_tree: formattedTree,
18274
- quest_abstraction_tree: formattedAbstractionTree
18275
- }));
18374
+ const updatedNodeData = sceneData.quest_nodes[questIndex];
18375
+ if (upsert_quest_firestore) {
18376
+ await upsert_quest_firestore(
18377
+ ownerId,
18378
+ sceneConfigId,
18379
+ updatedNodeData
18380
+ );
18381
+ }
18382
+ const nodeMesh = (_a2 = stateRef.current.nodeObjects) == null ? void 0 : _a2[String(questNodeId)];
18383
+ if (nodeMesh) {
18384
+ nodeMesh.userData = {
18385
+ ...nodeMesh.userData,
18386
+ ...updatedNodeData
18387
+ };
18388
+ }
18389
+ if (detailsNode && String(detailsNode.id) === String(questNodeId)) {
18390
+ setDetailsNode((prev) => ({
18391
+ ...prev,
18392
+ quest_tree: formattedTree,
18393
+ quest_abstraction_tree: formattedAbstractionTree
18394
+ }));
18395
+ }
18396
+ setSceneVersion((v) => v + 1);
18276
18397
  }
18277
- setSceneVersion((v) => v + 1);
18278
18398
  }
18279
18399
  }
18280
18400
  };
@@ -18323,7 +18443,6 @@ function XViewScene({
18323
18443
  ownerId: ownerId2
18324
18444
  } = context;
18325
18445
  if (!graphDataRef2.current || (viewType == null ? void 0 : viewType.toLowerCase()) !== "view") return;
18326
- const currentCounter = sceneDataRef2.current.quest_counter || 1;
18327
18446
  const newNode = {
18328
18447
  id: import_short_uuid2.default.generate(),
18329
18448
  ...newQuestData,
@@ -18334,19 +18453,16 @@ function XViewScene({
18334
18453
  graphDataRef2.current[sceneConfigId2] = { nodes: [], links: [] };
18335
18454
  }
18336
18455
  graphDataRef2.current[sceneConfigId2].nodes.push(newNode);
18337
- const sceneFileData = {
18338
- ...sceneDataRef2.current,
18339
- quest_counter: currentCounter + 1
18340
- };
18341
- const questFileData = {
18342
- nodes: graphDataRef2.current[sceneConfigId2].nodes,
18343
- links: graphDataRef2.current[sceneConfigId2].links,
18344
- milestones: sceneDataRef2.current.milestones || []
18345
- };
18456
+ const currentCounter = sceneDataRef2.current.quest_counter || 1;
18457
+ const nextCounter = currentCounter + 1;
18346
18458
  try {
18347
- await actions.save_view_data(sceneSaveUrl2, sceneFileData);
18348
- await actions.save_quest(ownerId2, sceneConfigId2, newNode);
18349
- sceneDataRef2.current.quest_counter = currentCounter + 1;
18459
+ if (actions.upsert_quest_firestore) {
18460
+ await actions.upsert_quest_firestore(ownerId2, sceneConfigId2, newNode);
18461
+ }
18462
+ if (actions.update_view_counter) {
18463
+ await actions.update_view_counter(ownerId2, sceneConfigId2, nextCounter);
18464
+ }
18465
+ sceneDataRef2.current.quest_counter = nextCounter;
18350
18466
  stateRef2.current.nodeIdToParentFileMap.set(String(newNode.id), {
18351
18467
  parentFileId: sceneConfigId2,
18352
18468
  ownerId: ownerId2,
@@ -18377,84 +18493,6 @@ function XViewScene({
18377
18493
  alert("Ocorreu um erro ao criar a Quest.");
18378
18494
  }
18379
18495
  };
18380
- userActionHandlers.handleCompleteConnection = async (context, targetNodeData) => {
18381
- const {
18382
- stateRef: stateRef2,
18383
- graphDataRef: graphDataRef2,
18384
- sceneDataRef: sceneDataRef2,
18385
- sceneConfigId: sceneConfigId2,
18386
- sceneSaveUrl: sceneSaveUrl2,
18387
- ownerId: ownerId2
18388
- } = context;
18389
- const { sourceNodeData } = stateRef2.current.connection;
18390
- if (!graphDataRef2.current || !sceneDataRef2.current || !sourceNodeData || !targetNodeData) {
18391
- userActionHandlers.handleCancelConnection(context);
18392
- return;
18393
- }
18394
- const sourceParentInfo = getParentFileInfoForNode(
18395
- graphDataRef2.current,
18396
- sceneDataRef2.current,
18397
- sourceNodeData.id,
18398
- sceneConfigId2,
18399
- ownerId2
18400
- );
18401
- const targetParentInfo = getParentFileInfoForNode(
18402
- graphDataRef2.current,
18403
- sceneDataRef2.current,
18404
- targetNodeData.id,
18405
- sceneConfigId2,
18406
- ownerId2
18407
- );
18408
- let parentInfoToSave = sourceParentInfo;
18409
- const isSourceQuest = sourceParentInfo.parentFileId === sceneConfigId2;
18410
- const isTargetQuest = targetParentInfo.parentFileId === sceneConfigId2;
18411
- if (isSourceQuest || isTargetQuest) {
18412
- parentInfoToSave = { parentFileId: sceneConfigId2, ownerId: ownerId2 };
18413
- }
18414
- const { parentFileId: parentFileIdToSave, ownerId: ownerIdToSave } = parentInfoToSave;
18415
- const newLink = {
18416
- id: `link_${import_short_uuid2.default.generate()}`,
18417
- source: sourceNodeData.id,
18418
- target: targetNodeData.id
18419
- };
18420
- try {
18421
- if (parentFileIdToSave === sceneConfigId2) {
18422
- const specificParentData = graphDataRef2.current[sceneConfigId2];
18423
- specificParentData.links.push(newLink);
18424
- const viewFilePayload = {
18425
- ...sceneDataRef2.current,
18426
- quest_counter: sceneDataRef2.current.quest_counter || 1
18427
- };
18428
- const questFilePayload = {
18429
- nodes: specificParentData.nodes,
18430
- links: specificParentData.links,
18431
- milestones: sceneDataRef2.current.milestones || []
18432
- };
18433
- await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
18434
- const questSaveUrl = sceneSaveUrl2.replace(
18435
- "x_view_scenes",
18436
- "x_view_quests"
18437
- );
18438
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
18439
- } else {
18440
- const specificParentData = JSON.parse(
18441
- JSON.stringify(graphDataRef2.current[parentFileIdToSave])
18442
- );
18443
- specificParentData.links.push(newLink);
18444
- const filenameForSpecificParent = `x_view_dbs/${ownerIdToSave}/${parentFileIdToSave}`;
18445
- await context.actions.save_view_data(
18446
- filenameForSpecificParent,
18447
- specificParentData
18448
- );
18449
- graphDataRef2.current[parentFileIdToSave] = specificParentData;
18450
- }
18451
- addNewLinkToScene(stateRef2.current, newLink);
18452
- } catch (error) {
18453
- console.error("Falha ao salvar a nova conex\xE3o:", error);
18454
- alert("Ocorreu um erro ao salvar a nova conex\xE3o.");
18455
- }
18456
- userActionHandlers.handleCancelConnection(context);
18457
- };
18458
18496
  const handleClearAncestryVisuals = (0, import_react33.useCallback)((ancestryId) => {
18459
18497
  const { renderedAncestries, ancestryGroup } = stateRef.current;
18460
18498
  const renderIndex = renderedAncestries.findIndex(
@@ -18586,7 +18624,7 @@ function XViewScene({
18586
18624
  if (line.material) line.material.dispose();
18587
18625
  });
18588
18626
  }
18589
- const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
18627
+ const allParentNodes = Object.values(parentDataRef.current).flatMap(
18590
18628
  (fileData) => fileData.nodes
18591
18629
  );
18592
18630
  const allAncestries = ancestryDataRef.current || [];
@@ -18974,7 +19012,7 @@ function XViewScene({
18974
19012
  );
18975
19013
  if (!ancestryObject || !ancestryObject.abstraction_tree) return;
18976
19014
  const { ancestryGroup, nodeObjects, renderer, renderedAncestries } = stateRef.current;
18977
- const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
19015
+ const allParentNodes = Object.values(parentDataRef.current).flatMap(
18978
19016
  (f) => f.nodes
18979
19017
  );
18980
19018
  let fullTree = buildFullAncestryTree(
@@ -19062,7 +19100,7 @@ function XViewScene({
19062
19100
  const allAncestries = ancestryDataRef.current || [];
19063
19101
  const fullTree = buildFullAncestryTree(
19064
19102
  ancestry.tree,
19065
- Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
19103
+ Object.values(parentDataRef.current).flatMap((f) => f.nodes),
19066
19104
  allAncestries
19067
19105
  );
19068
19106
  if (action === "open") {
@@ -19244,7 +19282,7 @@ function XViewScene({
19244
19282
  return null;
19245
19283
  const fullTree = buildFullAncestryTree(
19246
19284
  readingMode.ancestry.tree,
19247
- Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
19285
+ Object.values(parentDataRef.current).flatMap((f) => f.nodes),
19248
19286
  ancestryDataRef.current
19249
19287
  );
19250
19288
  const findNodeInTree = (tree, targetId) => {
@@ -19309,7 +19347,7 @@ function XViewScene({
19309
19347
  }
19310
19348
  const fullTree = buildFullAncestryTree(
19311
19349
  readingMode.ancestry.tree,
19312
- Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
19350
+ Object.values(parentDataRef.current).flatMap((f) => f.nodes),
19313
19351
  ancestryDataRef.current
19314
19352
  );
19315
19353
  let currentPtr = fullTree;
@@ -19406,7 +19444,7 @@ function XViewScene({
19406
19444
  let targetObj = ancestry;
19407
19445
  let targetTree = ancestry.tree;
19408
19446
  if (branchStack.length > 0) {
19409
- const allNodes = Object.values(parentDataRef.current || {}).flatMap(
19447
+ const allNodes = Object.values(parentDataRef.current).flatMap(
19410
19448
  (f) => f.nodes
19411
19449
  );
19412
19450
  const fullTree = buildFullAncestryTree(
@@ -19563,7 +19601,7 @@ function XViewScene({
19563
19601
  stateRef.current.maxAncestryRenderIndex = 0;
19564
19602
  const initialSections = /* @__PURE__ */ new Set(["preamble", 0]);
19565
19603
  await handleRenderAncestry(ancestryObject, initialSections);
19566
- const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
19604
+ const allParentNodes = Object.values(parentDataRef.current).flatMap(
19567
19605
  (fileData) => fileData.nodes
19568
19606
  );
19569
19607
  const allAncestries = ancestryDataRef.current || [];
@@ -20028,7 +20066,7 @@ function XViewScene({
20028
20066
  }, []);
20029
20067
  const allAvailableNodes = (0, import_react33.useMemo)(() => {
20030
20068
  if (!parentDataRef.current) return [];
20031
- return Object.values(parentDataRef.current || {}).flatMap(
20069
+ return Object.values(parentDataRef.current).flatMap(
20032
20070
  (fileData) => fileData.nodes || []
20033
20071
  );
20034
20072
  }, [sceneVersion, isInitialized]);
@@ -20117,7 +20155,7 @@ function XViewScene({
20117
20155
  if (!parentDataRef.current) {
20118
20156
  return [];
20119
20157
  }
20120
- const allTypes = Object.values(parentDataRef.current || {}).flatMap(
20158
+ const allTypes = Object.values(parentDataRef.current).flatMap(
20121
20159
  (fileData) => fileData.nodes.flatMap((node) => {
20122
20160
  if (Array.isArray(node.type)) return node.type;
20123
20161
  return [node.type];
@@ -20157,24 +20195,19 @@ function XViewScene({
20157
20195
  setSceneVersion((v) => v + 1);
20158
20196
  const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20159
20197
  if (!isView || !save_view_data || !sceneSaveUrl) return;
20160
- const sceneFileData = {
20161
- ...sceneDataRef.current,
20162
- nodes: sceneDataRef.current.nodes || [],
20163
- links: sceneDataRef.current.links || [],
20164
- quest_counter: sceneDataRef.current.quest_counter || 1
20165
- };
20166
20198
  const questFileData = {
20167
20199
  nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
20168
20200
  links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
20169
20201
  milestones: newMilestones
20170
20202
  };
20171
20203
  try {
20172
- await save_view_data(sceneSaveUrl, sceneFileData);
20173
- const questSaveUrl = sceneSaveUrl.replace(
20174
- "x_view_scenes",
20175
- "x_view_quests"
20176
- );
20177
- await save_view_data(questSaveUrl, questFileData);
20204
+ if (upsert_milestone_firestore) {
20205
+ await upsert_milestone_firestore(
20206
+ ownerId,
20207
+ sceneConfigId,
20208
+ newMilestones
20209
+ );
20210
+ }
20178
20211
  } catch (error) {
20179
20212
  console.error("Erro ao salvar milestones:", error);
20180
20213
  }
@@ -20182,7 +20215,7 @@ function XViewScene({
20182
20215
  [sceneConfigId, sceneSaveUrl, save_view_data, viewParams == null ? void 0 : viewParams.type]
20183
20216
  );
20184
20217
  const handleSaveCurrentView = (0, import_react33.useCallback)(async () => {
20185
- var _a2, _b2, _c2;
20218
+ var _a2;
20186
20219
  const { nodeObjects, allLinks } = stateRef.current;
20187
20220
  if (!nodeObjects || !allLinks || !sceneSaveUrl || !parentDataRef.current) {
20188
20221
  console.warn(
@@ -20191,7 +20224,7 @@ function XViewScene({
20191
20224
  return;
20192
20225
  }
20193
20226
  if (!save_view_data) return;
20194
- const currentNodes = Object.values(nodeObjects || {}).map((mesh) => {
20227
+ const currentNodes = Object.values(nodeObjects).map((mesh) => {
20195
20228
  const {
20196
20229
  _baseEmissiveIntensity,
20197
20230
  labelObject,
@@ -20212,23 +20245,10 @@ function XViewScene({
20212
20245
  const sceneFileData = {
20213
20246
  ...sceneDataRef.current,
20214
20247
  nodes: currentNodes,
20215
- links: currentLinks,
20216
- quest_counter: sceneDataRef.current.quest_counter || 1
20217
- };
20218
- const questFileData = {
20219
- nodes: isView ? ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || [] : sceneDataRef.current.quest_nodes || [],
20220
- links: isView ? ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || [] : sceneDataRef.current.quest_links || [],
20221
- milestones: sceneDataRef.current.milestones || []
20248
+ links: currentLinks
20222
20249
  };
20223
20250
  try {
20224
20251
  await save_view_data(sceneSaveUrl, sceneFileData);
20225
- if (isView) {
20226
- const questSaveUrl = sceneSaveUrl.replace(
20227
- "x_view_scenes",
20228
- "x_view_quests"
20229
- );
20230
- await save_view_data(questSaveUrl, questFileData);
20231
- }
20232
20252
  } catch (error) {
20233
20253
  console.error("Erro na chamada de save_view_data:", error);
20234
20254
  }
@@ -20353,7 +20373,7 @@ function XViewScene({
20353
20373
  } = stateRef.current;
20354
20374
  if (graphGroup) {
20355
20375
  let ghostPosition = sceneControls.target.clone();
20356
- const existingNodes = Object.values(nodeObjects || {});
20376
+ const existingNodes = Object.values(nodeObjects);
20357
20377
  let isOccupied = true;
20358
20378
  let radius = 18;
20359
20379
  let angle = 0;
@@ -21091,7 +21111,7 @@ async function save_view_data_logic(db_services, filename, data) {
21091
21111
  }
21092
21112
  }
21093
21113
  async function get_scene_view_data_logic(db_services, scene_config, owner_id, type, session, focusNodeId = null, focusAncestryId = null) {
21094
- var _a, _b;
21114
+ var _a, _b, _c;
21095
21115
  try {
21096
21116
  if (!session || !session.user) {
21097
21117
  return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
@@ -21133,54 +21153,56 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21133
21153
  const parentResponsesPromises = parentDbObjects.map(
21134
21154
  (db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
21135
21155
  );
21136
- const parentResponsesResults = await Promise.allSettled(
21137
- parentResponsesPromises
21138
- );
21139
- const parentData = {};
21140
- let currentQuestNodes = [];
21141
- let currentQuestLinks = [];
21142
- let currentMilestones = [];
21143
21156
  if (isView) {
21144
- const firestoreQuestsRes = await db_services.get_view_quests_and_links(
21145
- owner_id,
21146
- scene_config
21147
- );
21148
- const isMigrated = sceneData.quests_migrated === true;
21149
- if (firestoreQuestsRes.success && (firestoreQuestsRes.data.nodes.length > 0 || isMigrated)) {
21150
- currentQuestNodes = firestoreQuestsRes.data.nodes;
21151
- currentQuestLinks = firestoreQuestsRes.data.links;
21152
- currentMilestones = sceneData.milestones || [];
21153
- } else {
21154
- console.log(`Iniciando Lazy Migration para View ${scene_config}...`);
21155
- const legacyQuestsRes = await db_services.get_file(
21156
- `x_view_quests/${owner_id}/${scene_config}`
21157
- );
21158
- if (legacyQuestsRes.success && legacyQuestsRes.data) {
21159
- const legacyData = legacyQuestsRes.data;
21160
- currentQuestNodes = legacyData.nodes || [];
21161
- currentQuestLinks = legacyData.links || [];
21162
- currentMilestones = legacyData.milestones || [];
21163
- sceneData.milestones = currentMilestones;
21164
- await db_services.migrate_legacy_quests(
21157
+ const questFetchPromise = (async () => {
21158
+ try {
21159
+ const questsResponse = await db_services.get_view_quests_firestore(
21165
21160
  owner_id,
21166
- scene_config,
21167
- legacyData
21161
+ scene_config
21168
21162
  );
21163
+ if (questsResponse.success) {
21164
+ return {
21165
+ success: true,
21166
+ data: questsResponse.data || { nodes: [], links: [], milestones: [] },
21167
+ quest_counter: questsResponse.quest_counter
21168
+ };
21169
+ }
21170
+ return { success: false, error: "Falha ao carregar quests" };
21171
+ } catch (err) {
21172
+ return { success: false, error: err.message };
21169
21173
  }
21170
- }
21174
+ })();
21175
+ parentResponsesPromises.push(questFetchPromise);
21171
21176
  }
21177
+ const parentResponsesResults = await Promise.allSettled(
21178
+ parentResponsesPromises
21179
+ );
21180
+ const parentData = {};
21181
+ let questDataObj = null;
21172
21182
  for (let i = 0; i < parentResponsesResults.length; i++) {
21173
21183
  const result = parentResponsesResults[i];
21184
+ if (isView && i === parentResponsesResults.length - 1) {
21185
+ if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
21186
+ questDataObj = result.value.data;
21187
+ if (result.value.quest_counter !== void 0) {
21188
+ sceneData.quest_counter = result.value.quest_counter;
21189
+ }
21190
+ }
21191
+ continue;
21192
+ }
21174
21193
  const db_info = parentDbObjects[i];
21175
- if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
21194
+ if (result.status === "fulfilled" && ((_b = result.value) == null ? void 0 : _b.success)) {
21176
21195
  parentData[db_info.db_id] = result.value.data;
21177
21196
  } else {
21178
21197
  console.warn(
21179
21198
  `Arquivo pai n\xE3o carregado: ${db_info.db_id}. Pode ter sido deletado.`,
21180
- result.status === "rejected" ? result.reason : (_b = result.value) == null ? void 0 : _b.error
21199
+ result.status === "rejected" ? result.reason : (_c = result.value) == null ? void 0 : _c.error
21181
21200
  );
21182
21201
  }
21183
21202
  }
21203
+ const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
21204
+ const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
21205
+ const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
21184
21206
  if (isView) {
21185
21207
  parentData[scene_config] = {
21186
21208
  dataset_name: "Quests Internas (View)",
@@ -21188,8 +21210,8 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21188
21210
  links: currentQuestLinks
21189
21211
  };
21190
21212
  }
21191
- const allNodes = Object.values(parentData).flatMap((db) => (db == null ? void 0 : db.nodes) || []);
21192
- const allLinks = Object.values(parentData).flatMap((db) => (db == null ? void 0 : db.links) || []);
21213
+ const allNodes = Object.values(parentData).flatMap((db) => db.nodes || []);
21214
+ const allLinks = Object.values(parentData).flatMap((db) => db.links || []);
21193
21215
  const parentNodeMap = new Map(
21194
21216
  allNodes.map((node) => [String(node.id), node])
21195
21217
  );
@@ -21230,8 +21252,6 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21230
21252
  ...sceneData,
21231
21253
  nodes: validatedNodes,
21232
21254
  links: validatedLinks,
21233
- // Re-injetando no validated para que o restante do sistema (e.g. XViewScene local state)
21234
- // continue acessando as quests sem perceber a separação física
21235
21255
  quest_nodes: currentQuestNodes,
21236
21256
  quest_links: currentQuestLinks,
21237
21257
  milestones: currentMilestones