@overmap-ai/core 1.0.51 → 1.0.52

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 (45) hide show
  1. package/dist/forms/builder/constants.d.ts +1 -0
  2. package/dist/forms/builder/utils.d.ts +1 -1
  3. package/dist/forms/fields/QrField/QrField.d.ts +21 -0
  4. package/dist/forms/fields/QrField/QrInput.d.ts +10 -0
  5. package/dist/forms/fields/QrField/index.d.ts +2 -0
  6. package/dist/forms/fields/constants.d.ts +8 -0
  7. package/dist/forms/fields/index.d.ts +1 -0
  8. package/dist/forms/renderer/FormSubmissionBrowser/FormSubmissionBrowser.d.ts +5 -5
  9. package/dist/forms/renderer/FormSubmissionViewer/FormSubmissionViewer.d.ts +3 -3
  10. package/dist/forms/typings.d.ts +5 -2
  11. package/dist/overmap-core.js +1172 -473
  12. package/dist/overmap-core.js.map +1 -1
  13. package/dist/overmap-core.umd.cjs +1174 -476
  14. package/dist/overmap-core.umd.cjs.map +1 -1
  15. package/dist/sdk/sdk.d.ts +2 -1
  16. package/dist/sdk/services/AttachmentService.d.ts +2 -2
  17. package/dist/sdk/services/DocumentService.d.ts +5 -5
  18. package/dist/sdk/services/TeamService.d.ts +12 -0
  19. package/dist/sdk/services/UserFormSubmissionService.d.ts +9 -2
  20. package/dist/sdk/services/index.d.ts +1 -0
  21. package/dist/store/slices/categorySlice.d.ts +5 -1
  22. package/dist/store/slices/documentSlice.d.ts +352 -13
  23. package/dist/store/slices/formRevisionSlice.d.ts +66 -0
  24. package/dist/store/slices/formSlice.d.ts +110 -0
  25. package/dist/store/slices/formSubmissionSlice.d.ts +47 -0
  26. package/dist/store/slices/index.d.ts +4 -1
  27. package/dist/store/slices/issueSlice.d.ts +4 -1
  28. package/dist/store/slices/projectFileSlice.d.ts +4 -1
  29. package/dist/store/slices/teamSlice.d.ts +19 -0
  30. package/dist/store/slices/utils.d.ts +1 -0
  31. package/dist/store/slices/workspaceSlice.d.ts +4 -1
  32. package/dist/store/store.d.ts +13 -4
  33. package/dist/style.css +5 -0
  34. package/dist/typings/files.d.ts +11 -1
  35. package/dist/typings/models/attachments.d.ts +10 -13
  36. package/dist/typings/models/base.d.ts +10 -0
  37. package/dist/typings/models/documents.d.ts +19 -5
  38. package/dist/typings/models/forms.d.ts +8 -12
  39. package/dist/typings/models/index.d.ts +1 -0
  40. package/dist/typings/models/issues.d.ts +3 -2
  41. package/dist/typings/models/teams.d.ts +10 -0
  42. package/dist/utils/file.d.ts +2 -0
  43. package/dist/utils/forms.d.ts +2 -0
  44. package/package.json +2 -1
  45. package/dist/store/slices/userFormSlice.d.ts +0 -145
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  (function(global2, factory) {
8
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("dependency-graph"), require("@redux-offline/redux-offline"), require("@redux-offline/redux-offline/lib/defaults"), require("localforage"), require("redux-persist-migrate"), require("@reduxjs/toolkit"), require("superagent"), require("react-redux"), require("file-saver"), require("uuid"), require("color"), require("jwt-decode"), require("@redux-offline/redux-offline/lib/constants"), require("idb"), require("formik"), require("lodash.get"), require("linkify-react"), require("@hello-pangea/dnd"), require("xlsx"), require("react-pdf"), require("react-pdf/dist/Page/AnnotationLayer.css"), require("react-pdf/dist/Page/TextLayer.css"), require("react-dom"), require("react-sketch-canvas"), require("lodash.set"), require("lodash.clonedeep")) : typeof define === "function" && define.amd ? define(["exports", "react", "react/jsx-runtime", "@overmap-ai/blocks", "dependency-graph", "@redux-offline/redux-offline", "@redux-offline/redux-offline/lib/defaults", "localforage", "redux-persist-migrate", "@reduxjs/toolkit", "superagent", "react-redux", "file-saver", "uuid", "color", "jwt-decode", "@redux-offline/redux-offline/lib/constants", "idb", "formik", "lodash.get", "linkify-react", "@hello-pangea/dnd", "xlsx", "react-pdf", "react-pdf/dist/Page/AnnotationLayer.css", "react-pdf/dist/Page/TextLayer.css", "react-dom", "react-sketch-canvas", "lodash.set", "lodash.clonedeep"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["overmap-core"] = {}, global2.React, global2.jsxRuntime, global2.blocks, global2.dependencyGraph, global2.reduxOffline, global2.offlineConfig, global2.localforage, global2.createMigration, global2.toolkit, global2.request, global2.reactRedux, global2.saveAs, global2.uuid, global2.ColorCls, global2.jwtDecode, global2.constants, global2.idb, global2.formik, global2.get, global2.Linkify, global2.dnd, global2.xlsx, global2.reactPdf, null, null, global2.ReactDOM, global2.reactSketchCanvas, global2.set, global2.cloneDeep));
9
- })(this, function(exports2, React, jsxRuntime, blocks, dependencyGraph, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, reactRedux, saveAs, uuid, ColorCls, jwtDecode, constants, idb, formik, get, Linkify, dnd, xlsx, reactPdf, AnnotationLayer_css, TextLayer_css, ReactDOM, reactSketchCanvas, set, cloneDeep) {
8
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("dependency-graph"), require("@redux-offline/redux-offline"), require("@redux-offline/redux-offline/lib/defaults"), require("localforage"), require("redux-persist-migrate"), require("@reduxjs/toolkit"), require("superagent"), require("react-redux"), require("file-saver"), require("uuid"), require("color"), require("jwt-decode"), require("@redux-offline/redux-offline/lib/constants"), require("idb"), require("formik"), require("lodash.get"), require("linkify-react"), require("@hello-pangea/dnd"), require("qr-scanner"), require("xlsx"), require("react-pdf"), require("react-pdf/dist/Page/AnnotationLayer.css"), require("react-pdf/dist/Page/TextLayer.css"), require("react-dom"), require("react-sketch-canvas"), require("lodash.set"), require("lodash.clonedeep")) : typeof define === "function" && define.amd ? define(["exports", "react", "react/jsx-runtime", "@overmap-ai/blocks", "dependency-graph", "@redux-offline/redux-offline", "@redux-offline/redux-offline/lib/defaults", "localforage", "redux-persist-migrate", "@reduxjs/toolkit", "superagent", "react-redux", "file-saver", "uuid", "color", "jwt-decode", "@redux-offline/redux-offline/lib/constants", "idb", "formik", "lodash.get", "linkify-react", "@hello-pangea/dnd", "qr-scanner", "xlsx", "react-pdf", "react-pdf/dist/Page/AnnotationLayer.css", "react-pdf/dist/Page/TextLayer.css", "react-dom", "react-sketch-canvas", "lodash.set", "lodash.clonedeep"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["overmap-core"] = {}, global2.React, global2.jsxRuntime, global2.blocks, global2.dependencyGraph, global2.reduxOffline, global2.offlineConfig, global2.localforage, global2.createMigration, global2.toolkit, global2.request, global2.reactRedux, global2.saveAs, global2.uuid, global2.ColorCls, global2.jwtDecode, global2.constants, global2.idb, global2.formik, global2.get, global2.Linkify, global2.dnd, global2.QrScannerAPI, global2.xlsx, global2.reactPdf, null, null, global2.ReactDOM, global2.reactSketchCanvas, global2.set, global2.cloneDeep));
9
+ })(this, function(exports2, React, jsxRuntime, blocks, dependencyGraph, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, reactRedux, saveAs, uuid, ColorCls, jwtDecode, constants, idb, formik, get, Linkify, dnd, QrScannerAPI, xlsx, reactPdf, AnnotationLayer_css, TextLayer_css, ReactDOM, reactSketchCanvas, set, cloneDeep) {
10
10
  var _a;
11
11
  "use strict";
12
12
  function _interopNamespaceDefault(e) {
@@ -668,15 +668,15 @@ var __publicField = (obj, key, value) => {
668
668
  };
669
669
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
670
670
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
671
- const initialState$n = {
671
+ const initialState$q = {
672
672
  accessToken: "",
673
673
  refreshToken: "",
674
674
  isLoggedIn: false
675
675
  };
676
676
  const authSlice = toolkit.createSlice({
677
677
  name: "auth",
678
- initialState: initialState$n,
679
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
678
+ initialState: initialState$q,
679
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
680
680
  reducers: {
681
681
  setTokens: (state, action) => {
682
682
  state.accessToken = action.payload.accessToken;
@@ -841,6 +841,19 @@ var __publicField = (obj, key, value) => {
841
841
  element.click();
842
842
  document.body.removeChild(element);
843
843
  }
844
+ const constructUploadedFilePayloads = async (files) => {
845
+ const filePayloads = {};
846
+ for (const file of files) {
847
+ const sha1 = await hashFile(file);
848
+ filePayloads[sha1] = {
849
+ sha1,
850
+ extension: file.name.split(".").pop() || "",
851
+ file_type: file.type,
852
+ size: file.size
853
+ };
854
+ }
855
+ return Object.values(filePayloads);
856
+ };
844
857
  const fileToBlob = async (dataUrl) => {
845
858
  return (await fetch(dataUrl)).blob();
846
859
  };
@@ -1407,7 +1420,7 @@ var __publicField = (obj, key, value) => {
1407
1420
  return getLocalDateString(date);
1408
1421
  return relative.format(days, "days");
1409
1422
  });
1410
- const initialState$m = {
1423
+ const initialState$p = {
1411
1424
  categories: {},
1412
1425
  usedCategoryColors: [],
1413
1426
  categoryVisibility: {
@@ -1417,8 +1430,8 @@ var __publicField = (obj, key, value) => {
1417
1430
  };
1418
1431
  const categorySlice = toolkit.createSlice({
1419
1432
  name: "categories",
1420
- initialState: initialState$m,
1421
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1433
+ initialState: initialState$p,
1434
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1422
1435
  reducers: {
1423
1436
  setCategories: (state, action) => {
1424
1437
  if (!Array.isArray(action.payload))
@@ -1550,6 +1563,9 @@ var __publicField = (obj, key, value) => {
1550
1563
  hiddenCategoryCount++;
1551
1564
  return hiddenCategoryCount;
1552
1565
  };
1566
+ const selectIssueCountOfCategory = (categoryId) => (state) => {
1567
+ return Object.values(state.issueReducer.issues).filter((issue) => issue.category === categoryId).length;
1568
+ };
1553
1569
  const categoryReducer = categorySlice.reducer;
1554
1570
  function setAttachments(state, action) {
1555
1571
  state.attachments = {};
@@ -1587,14 +1603,14 @@ var __publicField = (obj, key, value) => {
1587
1603
  delete state.attachments[attachmentId];
1588
1604
  }
1589
1605
  }
1590
- const initialState$l = {
1606
+ const initialState$o = {
1591
1607
  components: {},
1592
1608
  attachments: {}
1593
1609
  };
1594
1610
  const componentSlice = toolkit.createSlice({
1595
1611
  name: "components",
1596
- initialState: initialState$l,
1597
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1612
+ initialState: initialState$o,
1613
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1598
1614
  reducers: {
1599
1615
  addComponent: (state, action) => {
1600
1616
  state.components[action.payload.offline_id] = action.payload;
@@ -1750,13 +1766,13 @@ var __publicField = (obj, key, value) => {
1750
1766
  removeAllComponentsOfType
1751
1767
  } = componentSlice.actions;
1752
1768
  const componentReducer = componentSlice.reducer;
1753
- const initialState$k = {
1769
+ const initialState$n = {
1754
1770
  completionsByComponentId: {}
1755
1771
  };
1756
1772
  const componentStageCompletionSlice = toolkit.createSlice({
1757
1773
  name: "componentStageCompletions",
1758
- initialState: initialState$k,
1759
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1774
+ initialState: initialState$n,
1775
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1760
1776
  reducers: {
1761
1777
  addStageCompletion: (state, action) => {
1762
1778
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1807,13 +1823,13 @@ var __publicField = (obj, key, value) => {
1807
1823
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1808
1824
  };
1809
1825
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1810
- const initialState$j = {
1826
+ const initialState$m = {
1811
1827
  stages: {}
1812
1828
  };
1813
1829
  const componentStageSlice = toolkit.createSlice({
1814
1830
  name: "componentStages",
1815
- initialState: initialState$j,
1816
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1831
+ initialState: initialState$m,
1832
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1817
1833
  reducers: {
1818
1834
  addStages: (state, action) => {
1819
1835
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1923,15 +1939,15 @@ var __publicField = (obj, key, value) => {
1923
1939
  );
1924
1940
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1925
1941
  const componentStageReducer = componentStageSlice.reducer;
1926
- const initialState$i = {
1942
+ const initialState$l = {
1927
1943
  componentTypes: {},
1928
1944
  hiddenComponentTypeIds: {},
1929
1945
  attachments: {}
1930
1946
  };
1931
1947
  const componentTypeSlice = toolkit.createSlice({
1932
1948
  name: "componentTypes",
1933
- initialState: initialState$i,
1934
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1949
+ initialState: initialState$l,
1950
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1935
1951
  reducers: {
1936
1952
  addComponentType: (state, action) => {
1937
1953
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -2042,13 +2058,13 @@ var __publicField = (obj, key, value) => {
2042
2058
  deleteComponentType
2043
2059
  } = componentTypeSlice.actions;
2044
2060
  const componentTypeReducer = componentTypeSlice.reducer;
2045
- const initialState$h = {
2061
+ const initialState$k = {
2046
2062
  workspaces: {},
2047
2063
  activeWorkspaceId: null
2048
2064
  };
2049
2065
  const workspaceSlice = toolkit.createSlice({
2050
2066
  name: "workspace",
2051
- initialState: initialState$h,
2067
+ initialState: initialState$k,
2052
2068
  // The `reducers` field lets us define reducers and generate associated actions
2053
2069
  reducers: {
2054
2070
  setWorkspaces: (state, action) => {
@@ -2105,7 +2121,7 @@ var __publicField = (obj, key, value) => {
2105
2121
  );
2106
2122
  const workspaceReducer = workspaceSlice.reducer;
2107
2123
  const maxRecentIssues = 10;
2108
- const initialState$g = {
2124
+ const initialState$j = {
2109
2125
  issues: {},
2110
2126
  attachments: {},
2111
2127
  comments: {},
@@ -2117,9 +2133,9 @@ var __publicField = (obj, key, value) => {
2117
2133
  };
2118
2134
  const issueSlice = toolkit.createSlice({
2119
2135
  name: "issues",
2120
- initialState: initialState$g,
2136
+ initialState: initialState$j,
2121
2137
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2122
- Object.assign(state, initialState$g);
2138
+ Object.assign(state, initialState$j);
2123
2139
  }),
2124
2140
  reducers: {
2125
2141
  setIssues: (state, action) => {
@@ -2527,15 +2543,15 @@ var __publicField = (obj, key, value) => {
2527
2543
  }
2528
2544
  );
2529
2545
  const issueReducer = issueSlice.reducer;
2530
- const initialState$f = {
2546
+ const initialState$i = {
2531
2547
  s3Urls: {}
2532
2548
  };
2533
2549
  const msPerHour = 1e3 * 60 * 60;
2534
2550
  const msPerWeek = msPerHour * 24 * 7;
2535
2551
  const fileSlice = toolkit.createSlice({
2536
2552
  name: "file",
2537
- initialState: initialState$f,
2538
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2553
+ initialState: initialState$i,
2554
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2539
2555
  reducers: {
2540
2556
  setUploadUrl: (state, action) => {
2541
2557
  const { url, fields, sha1 } = action.payload;
@@ -2562,7 +2578,7 @@ var __publicField = (obj, key, value) => {
2562
2578
  return url;
2563
2579
  };
2564
2580
  const fileReducer = fileSlice.reducer;
2565
- const initialState$e = {
2581
+ const initialState$h = {
2566
2582
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2567
2583
  mapStyle: MapStyle.SATELLITE,
2568
2584
  showTooltips: false,
@@ -2570,8 +2586,8 @@ var __publicField = (obj, key, value) => {
2570
2586
  };
2571
2587
  const mapSlice = toolkit.createSlice({
2572
2588
  name: "map",
2573
- initialState: initialState$e,
2574
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2589
+ initialState: initialState$h,
2590
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2575
2591
  reducers: {
2576
2592
  setMapStyle: (state, action) => {
2577
2593
  state.mapStyle = action.payload;
@@ -2640,7 +2656,7 @@ var __publicField = (obj, key, value) => {
2640
2656
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2641
2657
  return LicenseStatus2;
2642
2658
  })(LicenseStatus || {});
2643
- const initialState$d = {
2659
+ const initialState$g = {
2644
2660
  users: {},
2645
2661
  currentUser: {
2646
2662
  id: 0,
@@ -2651,8 +2667,8 @@ var __publicField = (obj, key, value) => {
2651
2667
  };
2652
2668
  const userSlice = toolkit.createSlice({
2653
2669
  name: "users",
2654
- initialState: initialState$d,
2655
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2670
+ initialState: initialState$g,
2671
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2656
2672
  reducers: {
2657
2673
  setUsers: (state, action) => {
2658
2674
  const usersMapping = {};
@@ -2714,13 +2730,13 @@ var __publicField = (obj, key, value) => {
2714
2730
  const selectUsersAsMapping = (state) => state.userReducer.users;
2715
2731
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2716
2732
  const userReducer = userSlice.reducer;
2717
- const initialState$c = {
2733
+ const initialState$f = {
2718
2734
  organizationAccesses: {}
2719
2735
  };
2720
2736
  const organizationAccessSlice = toolkit.createSlice({
2721
2737
  name: "organizationAccess",
2722
- initialState: initialState$c,
2723
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2738
+ initialState: initialState$f,
2739
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2724
2740
  reducers: {
2725
2741
  setOrganizationAccesses: (state, action) => {
2726
2742
  if (!Array.isArray(action.payload))
@@ -2783,13 +2799,13 @@ var __publicField = (obj, key, value) => {
2783
2799
  return organizationAccesses;
2784
2800
  };
2785
2801
  const organizationAccessReducer = organizationAccessSlice.reducer;
2786
- const initialState$b = {
2802
+ const initialState$e = {
2787
2803
  licenses: {}
2788
2804
  };
2789
2805
  const licenseSlice = toolkit.createSlice({
2790
2806
  name: "license",
2791
- initialState: initialState$b,
2792
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2807
+ initialState: initialState$e,
2808
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2793
2809
  reducers: {
2794
2810
  setLicenses: (state, action) => {
2795
2811
  if (!Array.isArray(action.payload))
@@ -2834,13 +2850,13 @@ var __publicField = (obj, key, value) => {
2834
2850
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2835
2851
  );
2836
2852
  const licenseReducer = licenseSlice.reducer;
2837
- const initialState$a = {
2853
+ const initialState$d = {
2838
2854
  projectAccesses: {}
2839
2855
  };
2840
2856
  const projectAccessSlice = toolkit.createSlice({
2841
2857
  name: "projectAccess",
2842
- initialState: initialState$a,
2843
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2858
+ initialState: initialState$d,
2859
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2844
2860
  reducers: {
2845
2861
  setProjectAccesses: (state, action) => {
2846
2862
  if (!Array.isArray(action.payload))
@@ -2908,7 +2924,7 @@ var __publicField = (obj, key, value) => {
2908
2924
  return projectAccesses;
2909
2925
  };
2910
2926
  const projectAccessReducer = projectAccessSlice.reducer;
2911
- const initialState$9 = {
2927
+ const initialState$c = {
2912
2928
  projects: {},
2913
2929
  activeProjectId: null,
2914
2930
  recentProjectIds: [],
@@ -2918,7 +2934,7 @@ var __publicField = (obj, key, value) => {
2918
2934
  };
2919
2935
  const projectSlice = toolkit.createSlice({
2920
2936
  name: "projects",
2921
- initialState: initialState$9,
2937
+ initialState: initialState$c,
2922
2938
  reducers: {
2923
2939
  setProjects: (state, action) => {
2924
2940
  const projectsMap = {};
@@ -3105,14 +3121,14 @@ var __publicField = (obj, key, value) => {
3105
3121
  }
3106
3122
  )
3107
3123
  );
3108
- const initialState$8 = {
3124
+ const initialState$b = {
3109
3125
  organizations: {},
3110
3126
  activeOrganizationId: null
3111
3127
  };
3112
3128
  const organizationSlice = toolkit.createSlice({
3113
3129
  name: "organizations",
3114
- initialState: initialState$8,
3115
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3130
+ initialState: initialState$b,
3131
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
3116
3132
  reducers: {
3117
3133
  setOrganizations: (state, action) => {
3118
3134
  for (const org of action.payload) {
@@ -3231,14 +3247,14 @@ var __publicField = (obj, key, value) => {
3231
3247
  }
3232
3248
  };
3233
3249
  };
3234
- const initialState$7 = {
3250
+ const initialState$a = {
3235
3251
  deletedRequests: [],
3236
3252
  latestRetryTime: 0
3237
3253
  };
3238
3254
  const outboxSlice = toolkit.createSlice({
3239
3255
  name: "outbox",
3240
- initialState: initialState$7,
3241
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3256
+ initialState: initialState$a,
3257
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3242
3258
  reducers: {
3243
3259
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3244
3260
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3270,7 +3286,7 @@ var __publicField = (obj, key, value) => {
3270
3286
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3271
3287
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3272
3288
  const outboxReducer = outboxSlice.reducer;
3273
- const initialState$6 = {
3289
+ const initialState$9 = {
3274
3290
  projectFiles: {},
3275
3291
  activeProjectFileId: null,
3276
3292
  isImportingProjectFile: false,
@@ -3278,8 +3294,8 @@ var __publicField = (obj, key, value) => {
3278
3294
  };
3279
3295
  const projectFileSlice = toolkit.createSlice({
3280
3296
  name: "projectFiles",
3281
- initialState: initialState$6,
3282
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3297
+ initialState: initialState$9,
3298
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3283
3299
  reducers: {
3284
3300
  addOrReplaceProjectFiles: (state, action) => {
3285
3301
  for (let fileObj of action.payload) {
@@ -3380,12 +3396,12 @@ var __publicField = (obj, key, value) => {
3380
3396
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3381
3397
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3382
3398
  const projectFileReducer = projectFileSlice.reducer;
3383
- const initialState$5 = {
3399
+ const initialState$8 = {
3384
3400
  isRehydrated: false
3385
3401
  };
3386
3402
  const rehydratedSlice = toolkit.createSlice({
3387
3403
  name: "rehydrated",
3388
- initialState: initialState$5,
3404
+ initialState: initialState$8,
3389
3405
  // The `reducers` field lets us define reducers and generate associated actions
3390
3406
  reducers: {
3391
3407
  setRehydrated: (state, action) => {
@@ -3395,7 +3411,7 @@ var __publicField = (obj, key, value) => {
3395
3411
  });
3396
3412
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3397
3413
  const rehydratedReducer = rehydratedSlice.reducer;
3398
- const initialState$4 = {
3414
+ const initialState$7 = {
3399
3415
  useIssueTemplate: false,
3400
3416
  placementMode: false,
3401
3417
  enableClustering: false,
@@ -3412,8 +3428,8 @@ var __publicField = (obj, key, value) => {
3412
3428
  };
3413
3429
  const settingSlice = toolkit.createSlice({
3414
3430
  name: "settings",
3415
- initialState: initialState$4,
3416
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3431
+ initialState: initialState$7,
3432
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3417
3433
  reducers: {
3418
3434
  setEnableDuplicateIssues: (state, action) => {
3419
3435
  state.useIssueTemplate = action.payload;
@@ -3459,146 +3475,231 @@ var __publicField = (obj, key, value) => {
3459
3475
  const settingReducer = settingSlice.reducer;
3460
3476
  const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
3461
3477
  const selectIsLoading = (state) => state.settingReducer.isLoading;
3462
- const LATEST_REVISION_CACHE = {};
3463
- function considerCachingRevision(revision, formId2, preferPending = false) {
3464
- var _a2;
3465
- if (!revision) {
3466
- if (!formId2) {
3467
- throw new Error("If revision is null, formId is required.");
3468
- }
3469
- const currentLatestRevision = getLatestRevisionFromCache(formId2);
3470
- if (currentLatestRevision)
3471
- return;
3472
- LATEST_REVISION_CACHE[formId2] = null;
3473
- return;
3474
- }
3475
- if (revision.revision === "Pending") {
3476
- if (preferPending) {
3477
- LATEST_REVISION_CACHE[revision.form] = revision;
3478
- }
3479
- return;
3480
- }
3481
- const cachedRevision = (_a2 = LATEST_REVISION_CACHE[revision.form]) == null ? void 0 : _a2.revision;
3482
- if (revision.revision > (typeof cachedRevision === "number" ? cachedRevision : -1)) {
3483
- LATEST_REVISION_CACHE[revision.form] = revision;
3478
+ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
3479
+ const revisionA = formRevisionA.revision;
3480
+ const revisionB = formRevisionB.revision;
3481
+ if (revisionA === "Pending" && revisionB === "Pending") {
3482
+ return formRevisionA.submitted_at < formRevisionB.submitted_at ? -1 : 1;
3483
+ } else if (revisionA === "Pending") {
3484
+ return 1;
3485
+ } else if (revisionB === "Pending") {
3486
+ return -1;
3487
+ } else {
3488
+ return revisionA < revisionB ? -1 : 1;
3484
3489
  }
3485
- }
3486
- function getLatestRevisionFromCache(formId2) {
3487
- return LATEST_REVISION_CACHE[formId2];
3488
- }
3489
- const initialState$3 = {
3490
- userForms: {},
3491
- revisions: {},
3492
- submissions: {},
3493
- submissionAttachments: {},
3494
- revisionAttachments: {}
3495
- };
3496
- const userFormSlice = toolkit.createSlice({
3497
- name: "userForms",
3498
- initialState: initialState$3,
3499
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3490
+ };
3491
+ const initialState$6 = {
3492
+ formRevisions: {},
3493
+ attachments: {}
3494
+ };
3495
+ const formRevisionsSlice = toolkit.createSlice({
3496
+ name: "formRevisions",
3497
+ initialState: initialState$6,
3498
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3500
3499
  reducers: {
3501
- setUserForms: (state, action) => {
3502
- state.userForms = {};
3503
- action.payload.forEach((userForm) => {
3504
- state.userForms[userForm.offline_id] = userForm;
3505
- });
3506
- },
3507
- addUserForm: (state, action) => {
3508
- state.userForms[action.payload.offline_id] = action.payload;
3500
+ // revision related actions
3501
+ setFormRevision: (state, action) => {
3502
+ state.formRevisions[action.payload.offline_id] = action.payload;
3509
3503
  },
3510
- addUserForms: (state, action) => {
3511
- action.payload.forEach((userForm) => {
3512
- state.userForms[userForm.offline_id] = userForm;
3513
- });
3514
- },
3515
- addUserFormRevisions: (state, action) => {
3516
- action.payload.forEach((userFormRevision) => {
3517
- state.revisions[userFormRevision.offline_id] = userFormRevision;
3518
- considerCachingRevision(userFormRevision);
3519
- });
3520
- },
3521
- addUserFormRevision: (state, action) => {
3522
- state.revisions[action.payload.offline_id] = action.payload;
3523
- considerCachingRevision(action.payload);
3504
+ setFormRevisions: (state, action) => {
3505
+ state.formRevisions = {};
3506
+ for (const revision of action.payload) {
3507
+ state.formRevisions[revision.offline_id] = revision;
3508
+ }
3524
3509
  },
3525
- deleteUserFormRevision: (state, action) => {
3526
- delete state.revisions[action.payload];
3527
- delete LATEST_REVISION_CACHE[action.payload];
3510
+ addFormRevision: (state, action) => {
3511
+ if (state.formRevisions[action.payload.offline_id] !== void 0) {
3512
+ throw new Error(`Revision with offline_id ${action.payload.offline_id} already exists`);
3513
+ }
3514
+ state.formRevisions[action.payload.offline_id] = action.payload;
3528
3515
  },
3529
- deleteUserFormRevisions: (state, action) => {
3516
+ addFormRevisions: (state, action) => {
3530
3517
  for (const userFormRevision of action.payload) {
3531
- delete state.revisions[userFormRevision.offline_id];
3532
- delete LATEST_REVISION_CACHE[userFormRevision.offline_id];
3518
+ if (state.formRevisions[userFormRevision.offline_id] !== void 0) {
3519
+ throw new Error(`Revision with offline_id ${userFormRevision.offline_id} already exists`);
3520
+ }
3533
3521
  }
3534
- },
3535
- updateOrCreateUserFormSubmission: (state, action) => {
3536
- state.submissions[action.payload.offline_id] = action.payload;
3537
- },
3538
- addUserFormSubmissionAttachment: (state, action) => {
3539
- const submissionId = action.payload.submission;
3540
- const submissionAttachments = state.submissionAttachments[submissionId];
3541
- if (submissionAttachments) {
3542
- submissionAttachments.push(action.payload);
3543
- } else {
3544
- state.submissionAttachments[submissionId] = [action.payload];
3522
+ for (const userFormRevision of action.payload) {
3523
+ state.formRevisions[userFormRevision.offline_id] = userFormRevision;
3545
3524
  }
3546
3525
  },
3547
- addUserFormRevisionAttachment: (state, action) => {
3548
- const revisionId = action.payload.revision;
3549
- const revisionAttachments = state.revisionAttachments[revisionId];
3550
- if (revisionAttachments) {
3551
- revisionAttachments.push(action.payload);
3552
- } else {
3553
- state.revisionAttachments[revisionId] = [action.payload];
3526
+ // UserFormRevisions do not get updated
3527
+ deleteFormRevision: (state, action) => {
3528
+ if (state.formRevisions[action.payload] === void 0) {
3529
+ throw new Error(`Revision with offline_id ${action.payload} does not exist`);
3554
3530
  }
3531
+ delete state.formRevisions[action.payload];
3555
3532
  },
3556
- setUserFormSubmissionAttachments: (state, action) => {
3557
- state.submissionAttachments = {};
3558
- for (const attachment of action.payload) {
3559
- const submissionId = attachment.submission;
3560
- const submissionAttachments = state.submissionAttachments[submissionId];
3561
- if (submissionAttachments) {
3562
- submissionAttachments.push(attachment);
3563
- } else {
3564
- state.submissionAttachments[submissionId] = [attachment];
3533
+ deleteFormRevisions: (state, action) => {
3534
+ for (const offlineId of action.payload) {
3535
+ if (state.formRevisions[offlineId] === void 0) {
3536
+ throw new Error(`Revision with offline_id ${offlineId} does not exist`);
3565
3537
  }
3566
3538
  }
3539
+ for (const offlineId of action.payload) {
3540
+ delete state.formRevisions[offlineId];
3541
+ }
3567
3542
  },
3568
- setUserFormRevisionAttachments: (state, action) => {
3569
- state.revisionAttachments = {};
3543
+ // attachment related actions
3544
+ setFormRevisionAttachments: (state, action) => {
3545
+ state.attachments = {};
3570
3546
  for (const attachment of action.payload) {
3571
- const revisionId = attachment.revision;
3572
- const revisionAttachments = state.revisionAttachments[revisionId];
3573
- if (revisionAttachments) {
3574
- revisionAttachments.push(attachment);
3575
- } else {
3576
- state.revisionAttachments[revisionId] = [attachment];
3577
- }
3547
+ state.attachments[attachment.offline_id] = attachment;
3578
3548
  }
3579
3549
  },
3580
- deleteUserFormSubmission: (state, action) => {
3581
- delete state.submissions[action.payload];
3550
+ addFormRevisionAttachment: (state, action) => {
3551
+ if (state.attachments[action.payload.offline_id] !== void 0) {
3552
+ throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3553
+ }
3554
+ state.attachments[action.payload.offline_id] = action.payload;
3582
3555
  },
3583
- deleteUserFormSubmissions: (state, action) => {
3584
- for (const userFormSubmission of action.payload) {
3585
- delete state.submissions[userFormSubmission.offline_id];
3556
+ addFormRevisionAttachments: (state, action) => {
3557
+ for (const attachment of action.payload) {
3558
+ if (state.attachments[attachment.offline_id] !== void 0) {
3559
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3560
+ }
3561
+ }
3562
+ for (const attachment of action.payload) {
3563
+ state.attachments[attachment.offline_id] = attachment;
3586
3564
  }
3587
3565
  },
3588
- addUserFormSubmissions: (state, action) => {
3589
- for (const submission of action.payload) {
3590
- state.submissions[submission.offline_id] = submission;
3566
+ deleteFormRevisionAttachment: (state, action) => {
3567
+ if (state.attachments[action.payload] === void 0) {
3568
+ throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3591
3569
  }
3570
+ delete state.attachments[action.payload];
3592
3571
  },
3593
- setUserFormSubmissions: (state, action) => {
3594
- state.submissions = {};
3595
- action.payload.forEach((submission) => {
3596
- state.submissions[submission.offline_id] = submission;
3572
+ deleteFormRevisionAttachments: (state, action) => {
3573
+ for (const offlineId of action.payload) {
3574
+ if (state.attachments[offlineId] === void 0) {
3575
+ throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3576
+ }
3577
+ }
3578
+ for (const offlineId of action.payload) {
3579
+ delete state.attachments[offlineId];
3580
+ }
3581
+ }
3582
+ }
3583
+ });
3584
+ const {
3585
+ setFormRevision,
3586
+ setFormRevisions,
3587
+ addFormRevision,
3588
+ addFormRevisions,
3589
+ deleteFormRevision,
3590
+ deleteFormRevisions,
3591
+ setFormRevisionAttachments,
3592
+ addFormRevisionAttachment,
3593
+ addFormRevisionAttachments,
3594
+ deleteFormRevisionAttachment,
3595
+ deleteFormRevisionAttachments
3596
+ } = formRevisionsSlice.actions;
3597
+ const selectFormRevisionMapping = (state) => state.formRevisionReducer.formRevisions;
3598
+ const selectFormRevisions = toolkit.createSelector(
3599
+ [selectFormRevisionMapping],
3600
+ (formRevisions) => Object.values(formRevisions)
3601
+ );
3602
+ const selectFormRevision = (formRevisionId) => (state) => {
3603
+ return state.formRevisionReducer.formRevisions[formRevisionId];
3604
+ };
3605
+ const _selectLatestFormRevision = (formRevisions, formId2) => {
3606
+ let ret = null;
3607
+ for (const candidate of Object.values(formRevisions)) {
3608
+ if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3609
+ ret = candidate;
3610
+ }
3611
+ }
3612
+ if (!ret) {
3613
+ throw new Error("No form revision found for form " + formId2);
3614
+ }
3615
+ return ret;
3616
+ };
3617
+ const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
3618
+ toolkit.createSelector([selectFormRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3619
+ return revisions.filter((revision) => revision.form === formId2).sort(formRevisionSortFn).pop();
3620
+ })
3621
+ );
3622
+ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
3623
+ toolkit.createSelector([selectFormRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3624
+ return revisions.filter((revision) => {
3625
+ return revision.form === formId2;
3626
+ });
3627
+ })
3628
+ );
3629
+ const selectLatestFormRevisionsOfComponentTypes = restructureCreateSelectorWithArgs(
3630
+ toolkit.createSelector(
3631
+ [
3632
+ (state) => state.formReducer.forms,
3633
+ selectFormRevisionMapping,
3634
+ (_state, componentTypeIds) => componentTypeIds
3635
+ ],
3636
+ (userForms, revisions, componentTypeIds) => {
3637
+ const componentTypeIdsSet = new Set(componentTypeIds);
3638
+ const formsOfComponentTypes = {};
3639
+ const ret = {};
3640
+ for (const form of Object.values(userForms)) {
3641
+ if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3642
+ formsOfComponentTypes[form.offline_id] = form;
3643
+ }
3644
+ }
3645
+ for (const revision of Object.values(revisions)) {
3646
+ const form = formsOfComponentTypes[revision.form];
3647
+ if (!form || !form.component_type || ret[form.component_type] && formRevisionSortFn(ret[form.component_type], revision) > 0)
3648
+ continue;
3649
+ ret[form.component_type] = revision;
3650
+ }
3651
+ return ret;
3652
+ }
3653
+ )
3654
+ );
3655
+ const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
3656
+ const latestRevisions = {};
3657
+ for (const revision of Object.values(revisions)) {
3658
+ const formId2 = revision.form;
3659
+ const currentLatestRevision = latestRevisions[formId2];
3660
+ if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3661
+ latestRevisions[formId2] = revision;
3662
+ }
3663
+ }
3664
+ return latestRevisions;
3665
+ });
3666
+ const selectUserFormRevisionAttachmentsMapping = (state) => {
3667
+ return state.formRevisionReducer.attachments;
3668
+ };
3669
+ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
3670
+ toolkit.createSelector(
3671
+ [selectUserFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
3672
+ (attachments, revisionId) => {
3673
+ return Object.values(attachments).filter((attachment) => attachment.revision === revisionId);
3674
+ }
3675
+ )
3676
+ );
3677
+ const formRevisionReducer = formRevisionsSlice.reducer;
3678
+ const initialState$5 = {
3679
+ forms: {}
3680
+ };
3681
+ const formSlice = toolkit.createSlice({
3682
+ name: "forms",
3683
+ initialState: initialState$5,
3684
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3685
+ reducers: {
3686
+ setForms: (state, action) => {
3687
+ state.forms = {};
3688
+ action.payload.forEach((userForm) => {
3689
+ state.forms[userForm.offline_id] = userForm;
3597
3690
  });
3598
3691
  },
3692
+ addForm: (state, action) => {
3693
+ state.forms[action.payload.offline_id] = action.payload;
3694
+ },
3695
+ addForms: (state, action) => {
3696
+ for (const userForm of action.payload) {
3697
+ state.forms[userForm.offline_id] = userForm;
3698
+ }
3699
+ },
3599
3700
  favoriteForm: (state, action) => {
3600
3701
  const { formId: formId2 } = action.payload;
3601
- const form = state.userForms[formId2];
3702
+ const form = state.forms[formId2];
3602
3703
  if (!form) {
3603
3704
  throw new Error("No form exists with the id " + formId2);
3604
3705
  }
@@ -3606,48 +3707,23 @@ var __publicField = (obj, key, value) => {
3606
3707
  },
3607
3708
  unfavoriteForm: (state, action) => {
3608
3709
  const { formId: formId2 } = action.payload;
3609
- const form = state.userForms[formId2];
3710
+ const form = state.forms[formId2];
3610
3711
  if (!form) {
3611
3712
  throw new Error("No form exists with the id " + formId2);
3612
3713
  }
3613
3714
  form.favorite = false;
3614
3715
  },
3615
- deleteUserForm: (state, action) => {
3616
- delete state.userForms[action.payload];
3716
+ deleteForm: (state, action) => {
3717
+ delete state.forms[action.payload];
3617
3718
  }
3618
3719
  }
3619
3720
  });
3620
- const {
3621
- addUserForm,
3622
- addUserForms,
3623
- addUserFormRevisions,
3624
- updateOrCreateUserFormSubmission,
3625
- addUserFormSubmissions,
3626
- deleteUserFormSubmission,
3627
- deleteUserFormSubmissions,
3628
- favoriteForm,
3629
- unfavoriteForm,
3630
- deleteUserForm,
3631
- deleteUserFormRevision,
3632
- deleteUserFormRevisions,
3633
- setUserFormSubmissions,
3634
- addUserFormRevision,
3635
- addUserFormSubmissionAttachment,
3636
- addUserFormRevisionAttachment,
3637
- setUserFormSubmissionAttachments,
3638
- setUserFormRevisionAttachments
3639
- } = userFormSlice.actions;
3640
- const selectSubmissionAttachments = (submissionId) => (state) => {
3641
- return state.userFormReducer.submissionAttachments[submissionId] || [];
3642
- };
3643
- const selectRevisionAttachments = (revisionId) => (state) => {
3644
- return state.userFormReducer.revisionAttachments[revisionId] || [];
3645
- };
3646
- const selectFilteredUserForms = restructureCreateSelectorWithArgs(
3721
+ const { setForms, addForm, addForms, favoriteForm, unfavoriteForm, deleteForm } = formSlice.actions;
3722
+ const selectFilteredForms = restructureCreateSelectorWithArgs(
3647
3723
  toolkit.createSelector(
3648
3724
  [
3649
- (state) => state.userFormReducer.userForms,
3650
- (state) => state.userFormReducer.revisions,
3725
+ (state) => state.formReducer.forms,
3726
+ (state) => state.formRevisionReducer.formRevisions,
3651
3727
  (_state, search) => search
3652
3728
  ],
3653
3729
  (userForms, revisions, search) => {
@@ -3681,63 +3757,188 @@ var __publicField = (obj, key, value) => {
3681
3757
  { memoizeOptions: { equalityCheck: reactRedux.shallowEqual } }
3682
3758
  )
3683
3759
  );
3684
- const selectFormRevision = (revisionId) => (state) => {
3685
- return state.userFormReducer.revisions[revisionId];
3760
+ const selectForm = (formId2) => (state) => {
3761
+ return state.formReducer.forms[formId2];
3686
3762
  };
3687
- const _selectLatestFormRevision = (revisions, formId2) => {
3688
- let ret = null;
3689
- for (const candidate of Object.values(revisions)) {
3690
- if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3691
- ret = candidate;
3692
- }
3693
- }
3694
- if (!ret) {
3695
- throw new Error("No revision found for form " + formId2);
3696
- }
3697
- return ret;
3763
+ const selectFormMapping = (state) => {
3764
+ return state.formReducer.forms;
3698
3765
  };
3699
- const selectLatestFormRevision = restructureCreateSelectorWithArgs(
3766
+ const selectFormOfComponentType = restructureCreateSelectorWithArgs(
3700
3767
  toolkit.createSelector(
3701
- [(state) => state.userFormReducer.revisions, (_state, formId2) => formId2],
3702
- (revisions, formId2) => {
3703
- if (!formId2) {
3704
- throw new Error("formId is required");
3705
- }
3706
- return _selectLatestFormRevision(revisions, formId2);
3768
+ [selectFormMapping, (_state, componentTypeId) => componentTypeId],
3769
+ (userForms, componentTypeId) => {
3770
+ return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3707
3771
  }
3708
3772
  )
3709
3773
  );
3710
- const selectUserForm = (formId2) => (state) => {
3711
- return state.userFormReducer.userForms[formId2];
3712
- };
3713
- const selectSubmissionMapping = (state) => state.userFormReducer.submissions;
3714
- const selectUserFormSubmission = (submissionId) => (state) => {
3715
- return state.userFormReducer.submissions[submissionId];
3716
- };
3717
- const selectSubmissions = toolkit.createSelector([selectSubmissionMapping], (submissions) => Object.values(submissions));
3718
- const selectRevisionMapping = (state) => state.userFormReducer.revisions;
3719
- const selectRevisions = toolkit.createSelector([selectRevisionMapping], (revisions) => Object.values(revisions));
3720
- const selectRevisionsForForm = restructureCreateSelectorWithArgs(
3721
- toolkit.createSelector([selectRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3722
- return revisions.filter((revision) => {
3723
- return revision.form === formId2;
3724
- });
3725
- })
3774
+ const selectFormsCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3775
+ return Object.keys(userForms).length;
3776
+ });
3777
+ const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3778
+ return Object.values(userForms).filter((form) => !form.component_type).length;
3779
+ });
3780
+ const formReducer = formSlice.reducer;
3781
+ const initialState$4 = {
3782
+ formSubmissions: {},
3783
+ attachments: {}
3784
+ };
3785
+ const formSubmissionSlice = toolkit.createSlice({
3786
+ name: "formSubmissions",
3787
+ initialState: initialState$4,
3788
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3789
+ reducers: {
3790
+ setFormSubmission: (state, action) => {
3791
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3792
+ },
3793
+ setFormSubmissions: (state, action) => {
3794
+ state.formSubmissions = {};
3795
+ for (const submission of action.payload) {
3796
+ state.formSubmissions[submission.offline_id] = submission;
3797
+ }
3798
+ },
3799
+ addFormSubmission: (state, action) => {
3800
+ if (action.payload.offline_id in state.formSubmissions) {
3801
+ throw new Error(`Submission with offline_id ${action.payload.offline_id} already exists`);
3802
+ }
3803
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3804
+ },
3805
+ addFormSubmissions: (state, action) => {
3806
+ for (const submission of action.payload) {
3807
+ if (state.formSubmissions[submission.offline_id] !== void 0) {
3808
+ throw new Error(`Submission with offline_id ${submission.offline_id} already exists`);
3809
+ }
3810
+ }
3811
+ for (const submission of action.payload) {
3812
+ state.formSubmissions[submission.offline_id] = submission;
3813
+ }
3814
+ },
3815
+ updateFormSubmission: (state, action) => {
3816
+ if (state.formSubmissions[action.payload.offline_id] === void 0) {
3817
+ throw new Error(`Submission with offline_id ${action.payload.offline_id} does not exist`);
3818
+ }
3819
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3820
+ },
3821
+ updateFormSubmissions: (state, action) => {
3822
+ for (const submission of action.payload) {
3823
+ if (state.formSubmissions[submission.offline_id] === void 0) {
3824
+ throw new Error(`Submission with offline_id ${submission.offline_id} does not exist`);
3825
+ }
3826
+ }
3827
+ for (const submission of action.payload) {
3828
+ state.formSubmissions[submission.offline_id] = submission;
3829
+ }
3830
+ },
3831
+ deleteFormSubmission: (state, action) => {
3832
+ if (state.formSubmissions[action.payload] === void 0) {
3833
+ throw new Error(`Submission with offline_id ${action.payload} does not exist`);
3834
+ }
3835
+ delete state.formSubmissions[action.payload];
3836
+ },
3837
+ deleteFormSubmissions: (state, action) => {
3838
+ for (const offlineId of action.payload) {
3839
+ if (state.formSubmissions[offlineId] === void 0) {
3840
+ throw new Error(`Submission with offline_id ${offlineId} does not exist`);
3841
+ }
3842
+ delete state.formSubmissions[offlineId];
3843
+ }
3844
+ for (const offlineId of action.payload) {
3845
+ delete state.formSubmissions[offlineId];
3846
+ }
3847
+ },
3848
+ // Attachments
3849
+ addFormSubmissionAttachment: (state, action) => {
3850
+ if (state.attachments[action.payload.offline_id] !== void 0) {
3851
+ throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3852
+ }
3853
+ state.attachments[action.payload.offline_id] = action.payload;
3854
+ },
3855
+ addFormSubmissionAttachments: (state, action) => {
3856
+ for (const attachment of action.payload) {
3857
+ if (state.attachments[attachment.offline_id] !== void 0) {
3858
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3859
+ }
3860
+ }
3861
+ for (const attachment of action.payload) {
3862
+ state.attachments[attachment.offline_id] = attachment;
3863
+ }
3864
+ },
3865
+ // We only need a multi set for attachments because they are not updated, only added and deleted
3866
+ setFormSubmissionAttachments: (state, action) => {
3867
+ state.attachments = {};
3868
+ for (const attachment of action.payload) {
3869
+ state.attachments[attachment.offline_id] = attachment;
3870
+ }
3871
+ },
3872
+ updateFormSubmissionAttachments: (state, action) => {
3873
+ for (const attachment of action.payload) {
3874
+ if (state.attachments[attachment.offline_id] === void 0) {
3875
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} does not exist`);
3876
+ }
3877
+ }
3878
+ for (const attachment of action.payload) {
3879
+ state.attachments[attachment.offline_id] = attachment;
3880
+ }
3881
+ },
3882
+ // The delete actions for UserFormSubmissionAttachments are not used in the app, but are included for completeness
3883
+ // Could be used if editing a submission is ever supported, will be applicable for supporting tip tap content in submissions
3884
+ deleteFormSubmissionAttachment: (state, action) => {
3885
+ if (state.attachments[action.payload] === void 0) {
3886
+ throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3887
+ }
3888
+ delete state.attachments[action.payload];
3889
+ },
3890
+ deleteFormSubmissionAttachments: (state, action) => {
3891
+ for (const offlineId of action.payload) {
3892
+ if (state.attachments[offlineId] === void 0) {
3893
+ throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3894
+ }
3895
+ delete state.attachments[offlineId];
3896
+ }
3897
+ }
3898
+ }
3899
+ });
3900
+ const {
3901
+ setFormSubmission,
3902
+ setFormSubmissions,
3903
+ addFormSubmission,
3904
+ addFormSubmissions,
3905
+ updateFormSubmission,
3906
+ updateFormSubmissions,
3907
+ deleteFormSubmission,
3908
+ deleteFormSubmissions,
3909
+ addFormSubmissionAttachment,
3910
+ addFormSubmissionAttachments,
3911
+ setFormSubmissionAttachments,
3912
+ updateFormSubmissionAttachments,
3913
+ deleteFormSubmissionAttachment,
3914
+ deleteFormSubmissionAttachments
3915
+ } = formSubmissionSlice.actions;
3916
+ const selectFormSubmissionsMapping = (state) => {
3917
+ return state.formSubmissionReducer.formSubmissions;
3918
+ };
3919
+ const selectFormSubmissions = toolkit.createSelector(
3920
+ [selectFormSubmissionsMapping],
3921
+ (submissions) => {
3922
+ return Object.values(submissions);
3923
+ }
3726
3924
  );
3727
- const selectSubmissionsForForm = restructureCreateSelectorWithArgs(
3925
+ const selectFormSubmission = (submissionId) => (state) => {
3926
+ return state.formSubmissionReducer.formSubmissions[submissionId];
3927
+ };
3928
+ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
3728
3929
  toolkit.createSelector(
3729
- [selectSubmissions, selectRevisionMapping, (_state, formId2) => formId2],
3930
+ [selectFormSubmissions, selectFormRevisionMapping, (_state, formId2) => formId2],
3730
3931
  (submissions, revisionMapping, formId2) => {
3731
- return Object.values(submissions).filter((submission) => {
3932
+ return submissions.filter((submission) => {
3732
3933
  const revision = revisionMapping[submission.form_revision];
3733
3934
  return (revision == null ? void 0 : revision.form) === formId2;
3734
3935
  });
3735
3936
  }
3736
3937
  )
3737
3938
  );
3738
- const selectSubmissionsForIssue = restructureCreateSelectorWithArgs(
3939
+ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
3739
3940
  toolkit.createSelector(
3740
- [(state) => state.userFormReducer.submissions, (_state, issueId) => issueId],
3941
+ [selectFormSubmissions, (_state, issueId) => issueId],
3741
3942
  (submissions, issueId) => {
3742
3943
  return Object.values(submissions).filter((submission) => {
3743
3944
  return submission.issue === issueId;
@@ -3745,9 +3946,9 @@ var __publicField = (obj, key, value) => {
3745
3946
  }
3746
3947
  )
3747
3948
  );
3748
- const selectSubmissionsForComponent = restructureCreateSelectorWithArgs(
3949
+ const selectFormSubmissionsOfComponent = restructureCreateSelectorWithArgs(
3749
3950
  toolkit.createSelector(
3750
- [selectSubmissions, (_state, componentId) => componentId],
3951
+ [selectFormSubmissions, (_state, componentId) => componentId],
3751
3952
  (submissions, componentId) => {
3752
3953
  return submissions.filter((submission) => {
3753
3954
  return submission.component === componentId;
@@ -3755,8 +3956,8 @@ var __publicField = (obj, key, value) => {
3755
3956
  }
3756
3957
  )
3757
3958
  );
3758
- const selectComponentSubmissionMapping = toolkit.createSelector(
3759
- [selectSubmissionMapping, selectComponentsMapping],
3959
+ const selectFormSubmissionsByComponents = toolkit.createSelector(
3960
+ [selectFormSubmissionsMapping, selectComponentsMapping],
3760
3961
  (submissions, components) => {
3761
3962
  var _a2;
3762
3963
  const componentSubmissionMapping = {};
@@ -3771,61 +3972,25 @@ var __publicField = (obj, key, value) => {
3771
3972
  }
3772
3973
  return componentSubmissionMapping;
3773
3974
  }
3774
- );
3775
- const selectUserFormMapping = (state) => {
3776
- return state.userFormReducer.userForms;
3777
- };
3778
- const selectComponentTypeForm = restructureCreateSelectorWithArgs(
3779
- toolkit.createSelector(
3780
- [selectUserFormMapping, (_state, componentTypeId) => componentTypeId],
3781
- (userForms, componentTypeId) => {
3782
- return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3783
- }
3784
- )
3785
- );
3786
- const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithArgs(
3787
- toolkit.createSelector(
3788
- [
3789
- selectUserFormMapping,
3790
- selectRevisionMapping,
3791
- (_state, componentTypeIds) => componentTypeIds
3792
- ],
3793
- (userForms, revisions, componentTypeIds) => {
3794
- const componentTypeIdsSet = new Set(componentTypeIds);
3795
- const ret = {};
3796
- for (const form of Object.values(userForms)) {
3797
- if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3798
- ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3799
- }
3800
- }
3801
- return ret;
3802
- }
3803
- )
3804
- );
3805
- const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
3806
- const latestRevisions = {};
3807
- for (const revision of Object.values(revisions)) {
3808
- const formId2 = revision.form;
3809
- const currentLatestRevision = latestRevisions[formId2];
3810
- if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3811
- latestRevisions[formId2] = revision;
3812
- }
3813
- }
3814
- return latestRevisions;
3815
- });
3816
- const selectNumberOfUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3817
- return Object.keys(userForms).length;
3818
- });
3819
- const selectNumberOfGeneralUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3820
- return Object.values(userForms).filter((form) => !form.component_type).length;
3821
- });
3822
- const userFormReducer = userFormSlice.reducer;
3823
- const initialState$2 = {
3975
+ );
3976
+ const selectFormSubmissionAttachmentsMapping = (state) => {
3977
+ return state.formSubmissionReducer.attachments;
3978
+ };
3979
+ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
3980
+ toolkit.createSelector(
3981
+ [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
3982
+ (attachmentsMapping, submissionId) => {
3983
+ return Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId);
3984
+ }
3985
+ )
3986
+ );
3987
+ const formSubmissionReducer = formSubmissionSlice.reducer;
3988
+ const initialState$3 = {
3824
3989
  emailDomains: {}
3825
3990
  };
3826
3991
  const emailDomainsSlice = toolkit.createSlice({
3827
3992
  name: "emailDomains",
3828
- initialState: initialState$2,
3993
+ initialState: initialState$3,
3829
3994
  reducers: {
3830
3995
  setEmailDomains: (state, action) => {
3831
3996
  const emailDomains = {};
@@ -3852,15 +4017,15 @@ var __publicField = (obj, key, value) => {
3852
4017
  (ed1, ed2) => ed1.domain.localeCompare(ed2.domain)
3853
4018
  );
3854
4019
  const emailDomainsReducer = emailDomainsSlice.reducer;
3855
- const initialState$1 = {
4020
+ const initialState$2 = {
3856
4021
  documents: {},
3857
4022
  attachments: {}
3858
4023
  };
3859
4024
  const documentSlice = toolkit.createSlice({
3860
4025
  name: "documents",
3861
- initialState: initialState$1,
4026
+ initialState: initialState$2,
3862
4027
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
3863
- Object.assign(state, initialState$1);
4028
+ Object.assign(state, initialState$2);
3864
4029
  }),
3865
4030
  reducers: {
3866
4031
  setDocuments: (state, action) => {
@@ -3897,9 +4062,18 @@ var __publicField = (obj, key, value) => {
3897
4062
  }
3898
4063
  }
3899
4064
  for (const document2 of action.payload) {
4065
+ const existingDocument = state.documents[document2.offline_id];
4066
+ if (document2.organization !== void 0 && document2.organization !== existingDocument.organization) {
4067
+ throw new Error("organization cannot be updated");
4068
+ }
4069
+ if (document2.project !== void 0 && document2.project !== existingDocument.project) {
4070
+ throw new Error("project cannot be updated");
4071
+ }
3900
4072
  state.documents[document2.offline_id] = {
3901
- ...state.documents[document2.offline_id],
4073
+ ...existingDocument,
3902
4074
  ...document2
4075
+ // Without the cast, TypeScript doesn't realize that we have guaranteed that the document doesn't
4076
+ // have both a project and an organization.
3903
4077
  };
3904
4078
  }
3905
4079
  },
@@ -4076,6 +4250,62 @@ var __publicField = (obj, key, value) => {
4076
4250
  )
4077
4251
  );
4078
4252
  const documentsReducer = documentSlice.reducer;
4253
+ const initialState$1 = {
4254
+ teams: {}
4255
+ };
4256
+ const teamSlice = toolkit.createSlice({
4257
+ name: "teams",
4258
+ initialState: initialState$1,
4259
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
4260
+ reducers: {
4261
+ setTeam: (state, action) => {
4262
+ state.teams[action.payload.offline_id] = action.payload;
4263
+ },
4264
+ setTeams: (state, action) => {
4265
+ state.teams = {};
4266
+ for (const team of action.payload) {
4267
+ state.teams[team.offline_id] = team;
4268
+ }
4269
+ },
4270
+ addTeam: (state, action) => {
4271
+ if (state.teams[action.payload.offline_id]) {
4272
+ throw new Error(`Team with offline_id ${action.payload.offline_id} already exists`);
4273
+ }
4274
+ state.teams[action.payload.offline_id] = action.payload;
4275
+ },
4276
+ updateTeam: (state, action) => {
4277
+ if (!state.teams[action.payload.offline_id]) {
4278
+ throw new Error(`Team with offline_id ${action.payload.offline_id} does not exist`);
4279
+ }
4280
+ state.teams[action.payload.offline_id] = action.payload;
4281
+ },
4282
+ deleteTeam: (state, action) => {
4283
+ delete state.teams[action.payload];
4284
+ }
4285
+ }
4286
+ });
4287
+ const { setTeam, setTeams, addTeam, updateTeam, deleteTeam } = teamSlice.actions;
4288
+ const selectTeamsMapping = (state) => state.teamReducer.teams;
4289
+ const selectTeams = toolkit.createSelector([selectTeamsMapping], (teams) => {
4290
+ return Object.values(teams);
4291
+ });
4292
+ const selectTeam = (teamId) => (state) => {
4293
+ return state.teamReducer.teams[teamId];
4294
+ };
4295
+ const selectTeamsOfOrganization = restructureCreateSelectorWithArgs(
4296
+ toolkit.createSelector(
4297
+ [selectTeams, (_state, organizationId) => organizationId],
4298
+ (teams, organizationId) => {
4299
+ return teams.filter((team) => team.organization === organizationId);
4300
+ }
4301
+ )
4302
+ );
4303
+ const selectTeamsOfUser = restructureCreateSelectorWithArgs(
4304
+ toolkit.createSelector([selectTeams, (_state, userId) => userId], (teams, userId) => {
4305
+ return teams.filter((team) => team.members.includes(userId));
4306
+ })
4307
+ );
4308
+ const teamReducer = teamSlice.reducer;
4079
4309
  const initialState = {
4080
4310
  version: 0
4081
4311
  };
@@ -4117,12 +4347,15 @@ var __publicField = (obj, key, value) => {
4117
4347
  projectFileReducer,
4118
4348
  rehydratedReducer,
4119
4349
  settingReducer,
4120
- userFormReducer,
4350
+ formReducer,
4351
+ formRevisionReducer,
4352
+ formSubmissionReducer,
4121
4353
  userReducer,
4122
4354
  workspaceReducer,
4123
4355
  emailDomainsReducer,
4124
4356
  licenseReducer,
4125
- documentsReducer
4357
+ documentsReducer,
4358
+ teamReducer
4126
4359
  };
4127
4360
  const overmapReducer = toolkit.combineReducers(overmapReducers);
4128
4361
  const resetStore = "RESET";
@@ -4170,9 +4403,7 @@ var __publicField = (obj, key, value) => {
4170
4403
  throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
4171
4404
  }
4172
4405
  }
4173
- const indexedForms = Object.values(draft.userFormReducer.userForms).filter(
4174
- (form) => form.index_workspace === workspaceId
4175
- );
4406
+ const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
4176
4407
  for (const form of indexedForms) {
4177
4408
  form.index_workspace = mainWorkspace.offline_id;
4178
4409
  }
@@ -6363,6 +6594,7 @@ var __publicField = (obj, key, value) => {
6363
6594
  }
6364
6595
  if (currentOrgId) {
6365
6596
  await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
6597
+ void this.client.teams.refreshStore();
6366
6598
  }
6367
6599
  if (!isProjectIdValid) {
6368
6600
  if (validProjects.length !== 0) {
@@ -6800,7 +7032,7 @@ var __publicField = (obj, key, value) => {
6800
7032
  ...revisionAttachmentPayload,
6801
7033
  file: URL.createObjectURL(image)
6802
7034
  };
6803
- store.dispatch(addUserFormRevisionAttachment(offlinePayload));
7035
+ store.dispatch(addFormRevisionAttachment(offlinePayload));
6804
7036
  return attach;
6805
7037
  });
6806
7038
  });
@@ -6815,13 +7047,14 @@ var __publicField = (obj, key, value) => {
6815
7047
  };
6816
7048
  const currentUser = state.userReducer.currentUser;
6817
7049
  const activeWorkspaceId = state.workspaceReducer.activeWorkspaceId;
7050
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6818
7051
  const offlineFormPayload = offline({});
6819
- const offlineRevisionPayload = offline(initialRevision);
7052
+ const offlineRevisionPayload = offline({ ...initialRevision, submitted_at: submittedAt });
6820
7053
  const retForm = {
6821
7054
  ...offlineFormPayload,
6822
7055
  index_workspace: activeWorkspaceId,
6823
7056
  favorite: true,
6824
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
7057
+ submitted_at: submittedAt,
6825
7058
  created_by: currentUser.id,
6826
7059
  ...componentTypeId && { component_type: componentTypeId },
6827
7060
  ...ownerAttrs
@@ -6831,11 +7064,12 @@ var __publicField = (obj, key, value) => {
6831
7064
  ...payloadWithoutImage,
6832
7065
  created_by: currentUser.id,
6833
7066
  form: retForm.offline_id,
6834
- revision: 0
7067
+ revision: 0,
7068
+ submitted_at: submittedAt
6835
7069
  };
6836
7070
  const { store } = this.client;
6837
- store.dispatch(addUserForm(retForm));
6838
- store.dispatch(addUserFormRevision(retRevision));
7071
+ store.dispatch(addForm(retForm));
7072
+ store.dispatch(addFormRevision(retRevision));
6839
7073
  const formPromise = this.enqueueRequest({
6840
7074
  description: "Create form",
6841
7075
  method: HttpMethod.POST,
@@ -6853,8 +7087,8 @@ var __publicField = (obj, key, value) => {
6853
7087
  });
6854
7088
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
6855
7089
  void formPromise.catch((e) => {
6856
- store.dispatch(deleteUserForm(retForm.offline_id));
6857
- store.dispatch(deleteUserFormRevision(retRevision.offline_id));
7090
+ store.dispatch(deleteForm(retForm.offline_id));
7091
+ store.dispatch(deleteFormRevision(retRevision.offline_id));
6858
7092
  throw e;
6859
7093
  });
6860
7094
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
@@ -6894,9 +7128,10 @@ var __publicField = (obj, key, value) => {
6894
7128
  ...payloadWithoutImage,
6895
7129
  created_by: currentUserId,
6896
7130
  revision: "Pending",
6897
- form: formId2
7131
+ form: formId2,
7132
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
6898
7133
  };
6899
- store.dispatch(addUserFormRevision(fullRevision));
7134
+ store.dispatch(addFormRevision(fullRevision));
6900
7135
  const promise = this.enqueueRequest({
6901
7136
  description: "Create form revision",
6902
7137
  method: HttpMethod.PATCH,
@@ -6910,9 +7145,9 @@ var __publicField = (obj, key, value) => {
6910
7145
  });
6911
7146
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevision.offline_id);
6912
7147
  void promise.then((result) => {
6913
- store.dispatch(addUserFormRevision(result));
7148
+ store.dispatch(setFormRevision(result));
6914
7149
  }).catch(() => {
6915
- store.dispatch(deleteUserFormRevision(fullRevision.offline_id));
7150
+ store.dispatch(deleteFormRevision(fullRevision.offline_id));
6916
7151
  });
6917
7152
  const settledPromise = Promise.all([promise, ...attachImagesPromises]).then(() => promise);
6918
7153
  return [fullRevision, settledPromise];
@@ -6954,19 +7189,19 @@ var __publicField = (obj, key, value) => {
6954
7189
  async delete(formId2) {
6955
7190
  const { store } = this.client;
6956
7191
  const state = store.getState();
6957
- const userForm = selectUserForm(formId2)(state);
7192
+ const userForm = selectForm(formId2)(state);
6958
7193
  if (!userForm) {
6959
7194
  throw new Error("Expected userForm to exist");
6960
7195
  }
6961
- const userFormSubmissions = selectSubmissionsForForm(formId2)(state);
7196
+ const userFormSubmissions = selectFormSubmissionsOfForm(formId2)(state);
6962
7197
  if (userFormSubmissions && userFormSubmissions.length > 0) {
6963
- store.dispatch(deleteUserFormSubmissions(userFormSubmissions));
7198
+ store.dispatch(deleteFormSubmissions(userFormSubmissions.map(({ offline_id }) => offline_id)));
6964
7199
  }
6965
- const userFormRevisions = selectRevisionsForForm(formId2)(state);
7200
+ const userFormRevisions = selectFormRevisionsOfForm(formId2)(state);
6966
7201
  if (userFormRevisions && userFormRevisions.length > 0) {
6967
- store.dispatch(deleteUserFormRevisions(userFormRevisions));
7202
+ store.dispatch(deleteFormRevisions(userFormRevisions.map(({ offline_id }) => offline_id)));
6968
7203
  }
6969
- store.dispatch(deleteUserForm(formId2));
7204
+ store.dispatch(deleteForm(formId2));
6970
7205
  try {
6971
7206
  return await this.enqueueRequest({
6972
7207
  description: "Delete form",
@@ -6976,12 +7211,12 @@ var __publicField = (obj, key, value) => {
6976
7211
  blocks: []
6977
7212
  });
6978
7213
  } catch (e) {
6979
- store.dispatch(addUserForm(userForm));
7214
+ store.dispatch(addForm(userForm));
6980
7215
  if (userFormRevisions && userFormRevisions.length > 0) {
6981
- store.dispatch(addUserFormRevisions(userFormRevisions));
7216
+ store.dispatch(addFormRevisions(userFormRevisions));
6982
7217
  }
6983
7218
  if (userFormSubmissions && userFormSubmissions.length > 0) {
6984
- store.dispatch(addUserFormSubmissions(userFormSubmissions));
7219
+ store.dispatch(addFormSubmissions(userFormSubmissions));
6985
7220
  }
6986
7221
  throw e;
6987
7222
  }
@@ -6995,16 +7230,15 @@ var __publicField = (obj, key, value) => {
6995
7230
  blockers: [],
6996
7231
  blocks: []
6997
7232
  });
6998
- store.dispatch(addUserForms(Object.values(result.forms)));
6999
- store.dispatch(addUserFormRevisions(Object.values(result.revisions)));
7000
- store.dispatch(setUserFormRevisionAttachments(Object.values(result.attachments)));
7233
+ store.dispatch(setForms(Object.values(result.forms)));
7234
+ store.dispatch(setFormRevisions(Object.values(result.revisions)));
7235
+ store.dispatch(setFormRevisionAttachments(Object.values(result.attachments)));
7001
7236
  }
7002
7237
  }
7003
7238
  const isArrayOfFiles = (value) => {
7004
7239
  return Array.isArray(value) && value[0] instanceof File;
7005
7240
  };
7006
- const separateFilesFromValues = (payload) => {
7007
- const { values } = payload;
7241
+ const separateFilesFromValues = (values) => {
7008
7242
  const files = {};
7009
7243
  const newValues = {};
7010
7244
  for (const key in values) {
@@ -7019,17 +7253,13 @@ var __publicField = (obj, key, value) => {
7019
7253
  newValues[key] = value;
7020
7254
  }
7021
7255
  }
7022
- const payloadWithoutFiles = {
7023
- ...payload,
7024
- values: newValues
7025
- };
7026
- return { payloadWithoutFiles, files };
7256
+ return { values: newValues, files };
7027
7257
  };
7028
7258
  class UserFormSubmissionService extends BaseApiService {
7029
7259
  constructor() {
7030
7260
  super(...arguments);
7031
7261
  // Attach files to submission, after uploading them to S3
7032
- __publicField(this, "getAttachFilesPromises", (files, payload) => {
7262
+ __publicField(this, "getAttachFilesPromises", (files, submission) => {
7033
7263
  const { store } = this.client;
7034
7264
  return Object.entries(files).map(async ([key, fileArray]) => {
7035
7265
  const attachResults = [];
@@ -7039,24 +7269,27 @@ var __publicField = (obj, key, value) => {
7039
7269
  const [fileProps] = await this.client.files.uploadFileToS3(sha1);
7040
7270
  const submissionAttachmentPayload = offline({
7041
7271
  ...fileProps,
7042
- submission: payload.offline_id,
7272
+ submission: submission.offline_id,
7043
7273
  field_identifier: key
7044
7274
  });
7045
7275
  const attach = await this.enqueueRequest({
7046
7276
  description: "Attach file to form submission",
7047
7277
  method: HttpMethod.POST,
7048
- url: `/forms/submission/${payload.offline_id}/attachments/`,
7278
+ url: `/forms/submission/${submission.offline_id}/attachments/`,
7049
7279
  payload: submissionAttachmentPayload,
7050
- blockers: [payload.component, payload.component_stage, payload.issue, payload.form_revision].filter(
7051
- (x) => x !== void 0
7052
- ),
7280
+ blockers: [
7281
+ submission.component,
7282
+ submission.component_stage,
7283
+ submission.issue,
7284
+ submission.form_revision
7285
+ ].filter((x) => x !== void 0),
7053
7286
  blocks: [submissionAttachmentPayload.offline_id]
7054
7287
  });
7055
7288
  const offlinePayload = {
7056
7289
  ...submissionAttachmentPayload,
7057
7290
  file: URL.createObjectURL(file)
7058
7291
  };
7059
- store.dispatch(addUserFormSubmissionAttachment(offlinePayload));
7292
+ store.dispatch(addFormSubmissionAttachment(offlinePayload));
7060
7293
  attachResults.push(attach);
7061
7294
  }
7062
7295
  return attachResults;
@@ -7070,71 +7303,168 @@ var __publicField = (obj, key, value) => {
7070
7303
  if (!activeProjectId) {
7071
7304
  throw new Error("Expected an active project");
7072
7305
  }
7073
- const { payloadWithoutFiles, files } = separateFilesFromValues(payload);
7306
+ const { values, files } = separateFilesFromValues(payload.values);
7307
+ const offlineSubmission = {
7308
+ ...payload,
7309
+ values,
7310
+ created_by: state.userReducer.currentUser.id,
7311
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7312
+ };
7074
7313
  const promise = this.enqueueRequest({
7075
7314
  description: "Respond to form",
7076
7315
  method: HttpMethod.POST,
7077
7316
  url: `/forms/revisions/${payload.form_revision}/respond/`,
7078
- payload: { ...payloadWithoutFiles, project: activeProjectId },
7317
+ payload: { ...offlineSubmission, project: activeProjectId },
7079
7318
  blockers: [payload.issue, payload.component, payload.component_stage, "add-form-entry"].filter(
7080
7319
  (x) => x !== void 0
7081
7320
  ),
7082
7321
  blocks: [payload.offline_id]
7083
7322
  });
7084
- const attachFilesPromises = this.getAttachFilesPromises(files, payload);
7085
- const now = (/* @__PURE__ */ new Date()).toISOString();
7086
- const fullOfflineResult = {
7087
- ...payload,
7088
- created_by: state.userReducer.currentUser.id,
7089
- created_at: now,
7090
- updated_at: now
7091
- };
7092
- const offlineResultWithoutFiles = {
7093
- ...fullOfflineResult,
7094
- ...payloadWithoutFiles
7095
- };
7096
- store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
7323
+ const attachFilesPromises = this.getAttachFilesPromises(files, offlineSubmission);
7324
+ store.dispatch(addFormSubmission(offlineSubmission));
7097
7325
  void promise.then((result) => {
7098
7326
  store.dispatch(addActiveProjectFormSubmissionsCount(1));
7099
- store.dispatch(updateOrCreateUserFormSubmission(result));
7327
+ store.dispatch(setFormSubmission(result));
7100
7328
  return result;
7101
7329
  }).catch(() => {
7102
- store.dispatch(deleteUserFormSubmission(payload.offline_id));
7330
+ store.dispatch(deleteFormSubmission(payload.offline_id));
7103
7331
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7104
7332
  });
7105
7333
  const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7106
- return [fullOfflineResult, settledPromise];
7334
+ return [offlineSubmission, settledPromise];
7107
7335
  }
7108
- update(submission) {
7336
+ // Note currently the bulkAdd method is specific to form submissions for components
7337
+ // TODO: adapt the support bulk adding to any model type
7338
+ async bulkAdd(args) {
7339
+ const { formRevision, values: argsValues, componentOfflineIds } = args;
7109
7340
  const { store } = this.client;
7110
- const { payloadWithoutFiles, files } = separateFilesFromValues(submission);
7111
- if (!("created_by" in payloadWithoutFiles) || !("created_at" in payloadWithoutFiles)) {
7112
- throw new Error("Expected payloadWithoutFiles to have created_by and created_at fields.");
7341
+ const offlineSubmissions = [];
7342
+ const offlineAttachments = [];
7343
+ const submissionOfflineIds = [];
7344
+ const submissionsPayload = [];
7345
+ const attachmentsPayload = [];
7346
+ const { values, files } = separateFilesFromValues(argsValues);
7347
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7348
+ const createdBy = store.getState().userReducer.currentUser.id;
7349
+ for (const component_id of componentOfflineIds) {
7350
+ const submission = offline({
7351
+ form_revision: formRevision,
7352
+ values,
7353
+ created_by: createdBy,
7354
+ submitted_at: submittedAt,
7355
+ component: component_id
7356
+ });
7357
+ submissionOfflineIds.push(submission.offline_id);
7358
+ submissionsPayload.push({ offline_id: submission.offline_id, component_id });
7359
+ offlineSubmissions.push(submission);
7360
+ for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
7361
+ for (const file of fileArray) {
7362
+ const sha1 = await hashFile(file);
7363
+ await this.client.files.addCache(file, sha1);
7364
+ const offlineAttachment = offline({
7365
+ file_name: file.name,
7366
+ file_sha1: sha1,
7367
+ file: URL.createObjectURL(file),
7368
+ submission: submission.offline_id,
7369
+ field_identifier: fieldIdentifier
7370
+ });
7371
+ offlineAttachments.push(offlineAttachment);
7372
+ attachmentsPayload.push({
7373
+ offline_id: offlineAttachment.offline_id,
7374
+ submission_id: submission.offline_id,
7375
+ sha1,
7376
+ name: file.name,
7377
+ field_identifier: fieldIdentifier
7378
+ });
7379
+ }
7380
+ }
7113
7381
  }
7382
+ const filesRecord = {};
7383
+ for (const file of Object.values(files).flat()) {
7384
+ const sha1 = await hashFile(file);
7385
+ filesRecord[sha1] = {
7386
+ sha1,
7387
+ extension: file.name.split(".").pop() || "",
7388
+ file_type: file.type,
7389
+ size: file.size
7390
+ };
7391
+ }
7392
+ store.dispatch(addFormSubmissions(offlineSubmissions));
7393
+ store.dispatch(addFormSubmissionAttachments(offlineAttachments));
7394
+ const promise = this.enqueueRequest({
7395
+ description: "Bulk add form submissions",
7396
+ method: HttpMethod.POST,
7397
+ url: `/forms/revisions/${formRevision}/bulk-respond/`,
7398
+ payload: {
7399
+ form_data: values,
7400
+ submitted_at: submittedAt,
7401
+ submissions: submissionsPayload,
7402
+ attachments: attachmentsPayload,
7403
+ files: Object.values(filesRecord)
7404
+ },
7405
+ blockers: componentOfflineIds,
7406
+ blocks: submissionOfflineIds
7407
+ });
7408
+ promise.then(({ submissions, attachments, presigned_urls }) => {
7409
+ store.dispatch(updateFormSubmissions(submissions));
7410
+ store.dispatch(updateFormSubmissionAttachments(attachments));
7411
+ for (const [sha1, presigned_url] of Object.entries(presigned_urls)) {
7412
+ const file = filesRecord[sha1];
7413
+ if (!file)
7414
+ continue;
7415
+ void this.enqueueRequest({
7416
+ url: presigned_url.url,
7417
+ description: "Upload file",
7418
+ method: HttpMethod.POST,
7419
+ isExternalUrl: true,
7420
+ isAuthNeeded: false,
7421
+ attachmentHash: sha1,
7422
+ blockers: [`s3-${file.sha1}.${file.extension}`],
7423
+ blocks: [sha1],
7424
+ s3url: presigned_url
7425
+ });
7426
+ }
7427
+ }).catch(() => {
7428
+ store.dispatch(deleteFormSubmissions(submissionOfflineIds));
7429
+ store.dispatch(deleteFormSubmissionAttachments(offlineAttachments.map((x) => x.offline_id)));
7430
+ });
7431
+ return [offlineSubmissions, promise.then(({ submissions }) => submissions)];
7432
+ }
7433
+ update(submission) {
7434
+ const { store } = this.client;
7435
+ const { values, files } = separateFilesFromValues(submission.values);
7114
7436
  const attachFilesPromises = this.getAttachFilesPromises(files, submission);
7115
- const fullResult = {
7116
- ...payloadWithoutFiles,
7117
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
7437
+ const offlineSubmission = {
7438
+ ...submission,
7439
+ values
7118
7440
  };
7119
- store.dispatch(updateOrCreateUserFormSubmission(fullResult));
7441
+ const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
7442
+ store.dispatch(updateFormSubmission(offlineSubmission));
7120
7443
  const promise = this.enqueueRequest({
7121
7444
  description: "Patch form submission",
7122
7445
  method: HttpMethod.PATCH,
7123
7446
  url: `/forms/submissions/${submission.offline_id}/`,
7124
- payload: fullResult,
7125
- blockers: [fullResult.issue, fullResult.component, fullResult.component_stage].filter(
7447
+ payload: offlineSubmission,
7448
+ blockers: [offlineSubmission.issue, offlineSubmission.component, offlineSubmission.component_stage].filter(
7126
7449
  (x) => x !== void 0
7127
7450
  ),
7128
- blocks: [fullResult.offline_id]
7451
+ blocks: [offlineSubmission.offline_id]
7129
7452
  });
7130
- return Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7453
+ promise.then((createdSubmission) => {
7454
+ store.dispatch(setFormSubmission(createdSubmission));
7455
+ }).catch(() => {
7456
+ store.dispatch(setFormSubmission(submissionToBeUpdated));
7457
+ });
7458
+ return [offlineSubmission, Promise.all([promise, ...attachFilesPromises]).then(() => promise)];
7131
7459
  }
7132
7460
  async delete(submissionId) {
7133
7461
  const { store } = this.client;
7134
7462
  const state = store.getState();
7135
- const submission = state.userFormReducer.submissions[submissionId];
7136
- store.dispatch(deleteUserFormSubmission(submissionId));
7463
+ const submission = state.formSubmissionReducer.formSubmissions[submissionId];
7464
+ const submissionAttachments = selectAttachmentsOfFormSubmission(submissionId)(state);
7465
+ store.dispatch(deleteFormSubmission(submissionId));
7137
7466
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7467
+ store.dispatch(deleteFormSubmissionAttachments(submissionAttachments.map((x) => x.offline_id)));
7138
7468
  try {
7139
7469
  return await this.enqueueRequest({
7140
7470
  description: "Delete user form submissions",
@@ -7144,10 +7474,9 @@ var __publicField = (obj, key, value) => {
7144
7474
  blocks: []
7145
7475
  });
7146
7476
  } catch (e) {
7147
- if (submission) {
7148
- store.dispatch(addActiveProjectFormSubmissionsCount(1));
7149
- store.dispatch(updateOrCreateUserFormSubmission(submission));
7150
- }
7477
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
7478
+ store.dispatch(addFormSubmission(submission));
7479
+ store.dispatch(addFormSubmissionAttachments(submissionAttachments));
7151
7480
  throw e;
7152
7481
  }
7153
7482
  }
@@ -7161,7 +7490,7 @@ var __publicField = (obj, key, value) => {
7161
7490
  blockers: [],
7162
7491
  blocks: []
7163
7492
  });
7164
- store.dispatch(setUserFormSubmissions(submissions));
7493
+ store.dispatch(setFormSubmissions(submissions));
7165
7494
  const attachments = await this.enqueueRequest({
7166
7495
  description: "Fetch form attachments",
7167
7496
  method: HttpMethod.GET,
@@ -7169,7 +7498,7 @@ var __publicField = (obj, key, value) => {
7169
7498
  blockers: [],
7170
7499
  blocks: []
7171
7500
  });
7172
- store.dispatch(setUserFormSubmissionAttachments(attachments));
7501
+ store.dispatch(setFormSubmissionAttachments(attachments));
7173
7502
  }
7174
7503
  }
7175
7504
  class WorkspaceService extends BaseApiService {
@@ -7729,17 +8058,28 @@ var __publicField = (obj, key, value) => {
7729
8058
  }
7730
8059
  }
7731
8060
  class DocumentService extends BaseApiService {
8061
+ // TODO: Support adding for project or organization
7732
8062
  add(document2) {
7733
8063
  const { store } = this.client;
7734
8064
  const currentUserId = store.getState().userReducer.currentUser.id;
7735
8065
  const activeProjectId = store.getState().projectReducer.activeProjectId;
7736
- const offlineDocument = offline({ ...document2, created_by: currentUserId });
7737
- store.dispatch(addDocuments([offlineDocument]));
8066
+ if (!activeProjectId) {
8067
+ throw new Error("No active project ID while creating document.");
8068
+ }
8069
+ const offlineDocument = offline(document2);
8070
+ const submittedDocument = {
8071
+ ...offlineDocument,
8072
+ created_by: currentUserId,
8073
+ project: activeProjectId,
8074
+ organization: null,
8075
+ children_documents: []
8076
+ };
8077
+ store.dispatch(addDocuments([submittedDocument]));
7738
8078
  const promise = this.enqueueRequest({
7739
8079
  description: "Create Document",
7740
8080
  method: HttpMethod.POST,
7741
- url: `/projects/${activeProjectId}/create-document/`,
7742
- payload: { ...offlineDocument },
8081
+ url: `/projects/${activeProjectId}/documents/`,
8082
+ payload: offlineDocument,
7743
8083
  queryParams: {
7744
8084
  parent_document: offlineDocument.parent_document ?? void 0
7745
8085
  },
@@ -7750,7 +8090,7 @@ var __publicField = (obj, key, value) => {
7750
8090
  promise.catch(() => {
7751
8091
  store.dispatch(removeDocuments([offlineDocument.offline_id]));
7752
8092
  });
7753
- return [offlineDocument, promise];
8093
+ return [submittedDocument, promise];
7754
8094
  }
7755
8095
  update(document2) {
7756
8096
  const { store } = this.client;
@@ -7850,15 +8190,25 @@ var __publicField = (obj, key, value) => {
7850
8190
  }
7851
8191
  async refreshStore() {
7852
8192
  const { store } = this.client;
7853
- const activeProjectId = store.getState().projectReducer.activeProjectId;
7854
- const result = await this.enqueueRequest({
8193
+ const state = store.getState();
8194
+ const activeProjectId = state.projectReducer.activeProjectId;
8195
+ const projectDocumentsPromise = this.enqueueRequest({
7855
8196
  description: "Get project documents",
7856
8197
  method: HttpMethod.GET,
7857
- url: `/documents/projects/${activeProjectId}/`,
8198
+ url: `/projects/${activeProjectId}/documents/`,
8199
+ blockers: [],
8200
+ blocks: []
8201
+ });
8202
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8203
+ const organizationDocumentsPromise = this.enqueueRequest({
8204
+ description: "Get organization documents",
8205
+ method: HttpMethod.GET,
8206
+ url: `/organizations/${activeOrganizationId}/documents/`,
7858
8207
  blockers: [],
7859
8208
  blocks: []
7860
8209
  });
7861
- store.dispatch(setDocuments(result));
8210
+ store.dispatch(setDocuments(await projectDocumentsPromise));
8211
+ store.dispatch(addDocuments(await organizationDocumentsPromise));
7862
8212
  }
7863
8213
  }
7864
8214
  class AgentService extends BaseApiService {
@@ -7893,6 +8243,142 @@ var __publicField = (obj, key, value) => {
7893
8243
  });
7894
8244
  }
7895
8245
  }
8246
+ class TeamService extends BaseApiService {
8247
+ add(teamPayload) {
8248
+ const { store } = this.client;
8249
+ const state = store.getState();
8250
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8251
+ if (!activeOrganizationId) {
8252
+ throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
8253
+ }
8254
+ const offlineTeam = offline({
8255
+ ...teamPayload,
8256
+ organization: activeOrganizationId,
8257
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
8258
+ // TODO: uncomment once supported
8259
+ // created_by: state.userReducer.currentUser.id,
8260
+ });
8261
+ store.dispatch(addTeam(offlineTeam));
8262
+ const promise = this.enqueueRequest({
8263
+ description: "Create team",
8264
+ method: HttpMethod.POST,
8265
+ url: `/organizations/${activeOrganizationId}/teams/`,
8266
+ payload: offlineTeam,
8267
+ // No blocks since users and organizations are not offline
8268
+ blockers: [],
8269
+ blocks: [offlineTeam.offline_id]
8270
+ });
8271
+ promise.then((createdTeam) => {
8272
+ store.dispatch(setTeam(createdTeam));
8273
+ }).catch(() => {
8274
+ store.dispatch(deleteTeam(offlineTeam.offline_id));
8275
+ });
8276
+ return [offlineTeam, promise];
8277
+ }
8278
+ // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
8279
+ update(team) {
8280
+ const { store } = this.client;
8281
+ const teamToBeUpdated = store.getState().teamReducer.teams[team.offline_id];
8282
+ const offlineUpdatedTeam = {
8283
+ ...teamToBeUpdated,
8284
+ ...team
8285
+ };
8286
+ store.dispatch(updateTeam(offlineUpdatedTeam));
8287
+ const promise = this.enqueueRequest({
8288
+ description: "Update team",
8289
+ method: HttpMethod.PATCH,
8290
+ url: `/organizations/teams/${team.offline_id}/`,
8291
+ payload: offlineUpdatedTeam,
8292
+ blockers: [team.offline_id],
8293
+ blocks: [team.offline_id]
8294
+ });
8295
+ promise.then((updatedTeam) => {
8296
+ store.dispatch(setTeam(updatedTeam));
8297
+ }).catch(() => {
8298
+ store.dispatch(setTeam(teamToBeUpdated));
8299
+ });
8300
+ return [offlineUpdatedTeam, promise];
8301
+ }
8302
+ async delete(teamId) {
8303
+ const { store } = this.client;
8304
+ const state = store.getState();
8305
+ const team = state.teamReducer.teams[teamId];
8306
+ if (!team) {
8307
+ throw new Error(`Expected team with id ${teamId} to exist`);
8308
+ }
8309
+ store.dispatch(deleteTeam(teamId));
8310
+ try {
8311
+ return await this.enqueueRequest({
8312
+ description: "Delete team",
8313
+ method: HttpMethod.DELETE,
8314
+ url: `/organizations/teams/${teamId}/`,
8315
+ blockers: [teamId],
8316
+ blocks: [teamId]
8317
+ });
8318
+ } catch (e) {
8319
+ store.dispatch(setTeam(team));
8320
+ throw e;
8321
+ }
8322
+ }
8323
+ async setMembers(teamId, members) {
8324
+ const { store } = this.client;
8325
+ const team = store.getState().teamReducer.teams[teamId];
8326
+ if (!team) {
8327
+ throw new Error(`Expected team with id ${teamId} to exist`);
8328
+ }
8329
+ if (members.length !== new Set(members).size) {
8330
+ throw new Error("Duplicate members found in the list");
8331
+ }
8332
+ store.dispatch(updateTeam({ ...team, members }));
8333
+ const promise = this.enqueueRequest({
8334
+ description: "Set team members",
8335
+ method: HttpMethod.PUT,
8336
+ url: `/organizations/teams/${teamId}/set-members/`,
8337
+ payload: {
8338
+ users: members
8339
+ },
8340
+ blockers: [teamId],
8341
+ blocks: [teamId]
8342
+ });
8343
+ promise.catch(() => {
8344
+ store.dispatch(setTeam(team));
8345
+ });
8346
+ return promise;
8347
+ }
8348
+ async addMembers(teamId, members) {
8349
+ const { store } = this.client;
8350
+ const team = store.getState().teamReducer.teams[teamId];
8351
+ if (!team) {
8352
+ throw new Error(`Expected team with id ${teamId} to exist`);
8353
+ }
8354
+ const newMembers = [...team.members, ...members];
8355
+ return this.setMembers(teamId, newMembers);
8356
+ }
8357
+ async removeMembers(teamId, members) {
8358
+ const { store } = this.client;
8359
+ const team = store.getState().teamReducer.teams[teamId];
8360
+ if (!team) {
8361
+ throw new Error(`Expected team with id ${teamId} to exist`);
8362
+ }
8363
+ const newMembers = team.members.filter((member) => !members.includes(member));
8364
+ return this.setMembers(teamId, newMembers);
8365
+ }
8366
+ async refreshStore() {
8367
+ const { store } = this.client;
8368
+ const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
8369
+ if (!activeOrganizationId) {
8370
+ throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
8371
+ }
8372
+ const result = await this.enqueueRequest({
8373
+ description: "Fetch teams",
8374
+ method: HttpMethod.GET,
8375
+ url: `/organizations/${activeOrganizationId}/teams/`,
8376
+ blockers: [],
8377
+ blocks: []
8378
+ });
8379
+ store.dispatch(setTeams(result));
8380
+ }
8381
+ }
7896
8382
  class OvermapSDK {
7897
8383
  constructor(apiUrl, store) {
7898
8384
  __publicField(this, "API_URL");
@@ -7922,6 +8408,7 @@ var __publicField = (obj, key, value) => {
7922
8408
  __publicField(this, "emailDomains", new EmailDomainsService(this));
7923
8409
  __publicField(this, "licenses", new LicenseService(this));
7924
8410
  __publicField(this, "documents", new DocumentService(this));
8411
+ __publicField(this, "teams", new TeamService(this));
7925
8412
  this.API_URL = apiUrl;
7926
8413
  this.store = store;
7927
8414
  }
@@ -7963,7 +8450,7 @@ var __publicField = (obj, key, value) => {
7963
8450
  const patchfieldBorder = "_patchfieldBorder_1w0fq_73";
7964
8451
  const title = "_title_1w0fq_73";
7965
8452
  const error = "_error_1w0fq_89";
7966
- const styles$c = {
8453
+ const styles$d = {
7967
8454
  description: description$2,
7968
8455
  floatingButtonContainer: floatingButtonContainer$2,
7969
8456
  FullScreenImageContainer: FullScreenImageContainer$2,
@@ -8084,7 +8571,7 @@ var __publicField = (obj, key, value) => {
8084
8571
  const longIconButton$1 = "_longIconButton_10o76_36";
8085
8572
  const previewImage$1 = "_previewImage_10o76_42";
8086
8573
  const FullScreenImage$1 = "_FullScreenImage_10o76_12";
8087
- const styles$b = {
8574
+ const styles$c = {
8088
8575
  description: description$1,
8089
8576
  floatingButtonContainer: floatingButtonContainer$1,
8090
8577
  FullScreenImageContainer: FullScreenImageContainer$1,
@@ -8108,7 +8595,7 @@ var __publicField = (obj, key, value) => {
8108
8595
  /* @__PURE__ */ jsxRuntime.jsx(
8109
8596
  "button",
8110
8597
  {
8111
- className: styles$b.FullScreenImageContainer,
8598
+ className: styles$c.FullScreenImageContainer,
8112
8599
  type: "button",
8113
8600
  onClick: () => {
8114
8601
  setShowPreview(false);
@@ -8116,7 +8603,7 @@ var __publicField = (obj, key, value) => {
8116
8603
  children: /* @__PURE__ */ jsxRuntime.jsx(
8117
8604
  "img",
8118
8605
  {
8119
- className: styles$b.FullScreenImage,
8606
+ className: styles$c.FullScreenImage,
8120
8607
  src: url,
8121
8608
  alt: name,
8122
8609
  onClick: (e) => {
@@ -8126,11 +8613,11 @@ var __publicField = (obj, key, value) => {
8126
8613
  )
8127
8614
  }
8128
8615
  ),
8129
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$b.TopBarContainer, align: "center", children: [
8616
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.TopBarContainer, align: "center", children: [
8130
8617
  /* @__PURE__ */ jsxRuntime.jsx(
8131
8618
  blocks.IconButton,
8132
8619
  {
8133
- className: styles$b.longIconButton,
8620
+ className: styles$c.longIconButton,
8134
8621
  variant: "soft",
8135
8622
  "aria-label": "Exit preview",
8136
8623
  onClick: () => {
@@ -8139,11 +8626,11 @@ var __publicField = (obj, key, value) => {
8139
8626
  children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiArrowLeftLine" })
8140
8627
  }
8141
8628
  ),
8142
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.fileName, children: name }),
8629
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.fileName, children: name }),
8143
8630
  /* @__PURE__ */ jsxRuntime.jsx(
8144
8631
  blocks.IconButton,
8145
8632
  {
8146
- className: styles$b.longIconButton,
8633
+ className: styles$c.longIconButton,
8147
8634
  variant: "soft",
8148
8635
  "aria-label": `Download ${name}`,
8149
8636
  onClick: handleDownload,
@@ -8171,7 +8658,7 @@ var __publicField = (obj, key, value) => {
8171
8658
  /* @__PURE__ */ jsxRuntime.jsx(
8172
8659
  "img",
8173
8660
  {
8174
- className: styles$b.previewImage,
8661
+ className: styles$c.previewImage,
8175
8662
  src: resolvedImageURL,
8176
8663
  alt: resolvedImage.name,
8177
8664
  onClick: () => {
@@ -8199,7 +8686,7 @@ var __publicField = (obj, key, value) => {
8199
8686
  const { helpText, children, severity } = props;
8200
8687
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
8201
8688
  children,
8202
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$b.description, children: helpText }) })
8689
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$c.description, children: helpText }) })
8203
8690
  ] });
8204
8691
  };
8205
8692
  const InputWithLabelAndHelpText = (props) => {
@@ -8433,6 +8920,9 @@ var __publicField = (obj, key, value) => {
8433
8920
  function RiCalendarLine(props) {
8434
8921
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M9 1V3H15V1H17V3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H7V1H9ZM20 11H4V19H20V11ZM7 5H4V9H20V5H17V7H15V5H9V7H7V5Z" }, "child": [] }] })(props);
8435
8922
  }
8923
+ function RiQrCodeLine(props) {
8924
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M16 17V16H13V13H16V15H18V17H17V19H15V21H13V18H15V17H16ZM21 21H17V19H19V17H21V21ZM3 3H11V11H3V3ZM5 5V9H9V5H5ZM13 3H21V11H13V3ZM15 5V9H19V5H15ZM3 13H11V21H3V13ZM5 15V19H9V15H5ZM18 13H21V15H18V13ZM6 6H8V8H6V6ZM6 16H8V18H6V16ZM16 6H18V8H16V6Z" }, "child": [] }] })(props);
8925
+ }
8436
8926
  function RiFileCopyLine(props) {
8437
8927
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z" }, "child": [] }] })(props);
8438
8928
  }
@@ -9336,9 +9826,9 @@ var __publicField = (obj, key, value) => {
9336
9826
  return React__namespace.createElement("div", { ...insetProps, ref: forwardedRef, className: classNames("rt-Inset", className, withBreakpoints(side, "rt-r-side"), withBreakpoints(clip, "rt-r-clip"), withBreakpoints(p, "rt-r-p"), withBreakpoints(px, "rt-r-px"), withBreakpoints(py, "rt-r-py"), withBreakpoints(pt, "rt-r-pt"), withBreakpoints(pr, "rt-r-pr"), withBreakpoints(pb, "rt-r-pb"), withBreakpoints(pl, "rt-r-pl"), withMarginProps(marginProps)) });
9337
9827
  });
9338
9828
  Inset.displayName = "Inset";
9339
- const sizes$7 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9829
+ const sizes$8 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9340
9830
  const headingPropDefs = {
9341
- size: { type: "enum", values: sizes$7, default: "6", responsive: true },
9831
+ size: { type: "enum", values: sizes$8, default: "6", responsive: true },
9342
9832
  weight: { ...weightProp, default: "bold" },
9343
9833
  align: alignProp,
9344
9834
  trim: trimProp,
@@ -9351,9 +9841,9 @@ var __publicField = (obj, key, value) => {
9351
9841
  return React__namespace.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, { "data-accent-color": color, ...headingProps, ref: forwardedRef, className: classNames("rt-Heading", className, withBreakpoints(size, "rt-r-size"), withBreakpoints(weight, "rt-r-weight"), withBreakpoints(align, "rt-r-ta"), withBreakpoints(trim, "rt-r-lt"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) }, asChild ? children : React__namespace.createElement(Tag, null, children));
9352
9842
  });
9353
9843
  Heading.displayName = "Heading";
9354
- const sizes$6 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9844
+ const sizes$7 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9355
9845
  const textPropDefs = {
9356
- size: { type: "enum", values: sizes$6, default: void 0, responsive: true },
9846
+ size: { type: "enum", values: sizes$7, default: void 0, responsive: true },
9357
9847
  weight: weightProp,
9358
9848
  align: alignProp,
9359
9849
  trim: trimProp,
@@ -9366,6 +9856,21 @@ var __publicField = (obj, key, value) => {
9366
9856
  return React__namespace.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, { "data-accent-color": color, ...textProps, ref: forwardedRef, className: classNames("rt-Text", className, withBreakpoints(size, "rt-r-size"), withBreakpoints(weight, "rt-r-weight"), withBreakpoints(align, "rt-r-ta"), withBreakpoints(trim, "rt-r-lt"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) }, asChild ? children : React__namespace.createElement(Tag, null, children));
9367
9857
  });
9368
9858
  Text.displayName = "Text";
9859
+ const sizes$6 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9860
+ const variants$4 = ["solid", "soft", "outline", "ghost"];
9861
+ const codePropDefs = {
9862
+ size: { type: "enum", values: sizes$6, default: void 0, responsive: true },
9863
+ variant: { type: "enum", values: variants$4, default: "soft" },
9864
+ weight: weightProp,
9865
+ color: colorProp,
9866
+ highContrast: highContrastProp
9867
+ };
9868
+ const Code = React__namespace.forwardRef((props, forwardedRef) => {
9869
+ const { rest: marginRest, ...marginProps } = extractMarginProps(props);
9870
+ const { className, size = codePropDefs.size.default, variant = codePropDefs.variant.default, weight = codePropDefs.weight.default, color = codePropDefs.color.default, highContrast = codePropDefs.highContrast.default, ...codeProps } = marginRest;
9871
+ return React__namespace.createElement("code", { "data-accent-color": color, ...codeProps, ref: forwardedRef, className: classNames("rt-Code", className, withBreakpoints(size, "rt-r-size"), `rt-variant-${variant}`, withBreakpoints(weight, "rt-r-weight"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) });
9872
+ });
9873
+ Code.displayName = "Code";
9369
9874
  const Em = React__namespace.forwardRef((props, forwardedRef) => React__namespace.createElement("em", { ...props, ref: forwardedRef, className: classNames("rt-Em", props.className) }));
9370
9875
  Em.displayName = "Em";
9371
9876
  const Strong = React__namespace.forwardRef((props, forwardedRef) => React__namespace.createElement("strong", { ...props, ref: forwardedRef, className: classNames("rt-Strong", props.className) }));
@@ -11756,7 +12261,7 @@ var __publicField = (obj, key, value) => {
11756
12261
  });
11757
12262
  const clickableLinkContainer = "_clickableLinkContainer_1ace7_1";
11758
12263
  const TextFieldInputCopy = "_TextFieldInputCopy_1ace7_5";
11759
- const styles$a = {
12264
+ const styles$b = {
11760
12265
  clickableLinkContainer,
11761
12266
  TextFieldInputCopy
11762
12267
  };
@@ -11785,13 +12290,13 @@ var __publicField = (obj, key, value) => {
11785
12290
  placeholder: field.placeholder,
11786
12291
  color
11787
12292
  }
11788
- ) : /* @__PURE__ */ jsxRuntime.jsxs(TextField$1.Root, { className: styles$a.clickableLinkContainer, children: [
12293
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(TextField$1.Root, { className: styles$b.clickableLinkContainer, children: [
11789
12294
  /* @__PURE__ */ jsxRuntime.jsx(
11790
12295
  "div",
11791
12296
  {
11792
12297
  className: classNames$1(
11793
12298
  "rt-TextFieldInput rt-r-size-2 rt-variant-surface",
11794
- styles$a.TextFieldInputCopy
12299
+ styles$b.TextFieldInputCopy
11795
12300
  ),
11796
12301
  children: /* @__PURE__ */ jsxRuntime.jsx(
11797
12302
  Linkify,
@@ -12363,8 +12868,7 @@ var __publicField = (obj, key, value) => {
12363
12868
  description: "List possible options for the user to select from.",
12364
12869
  required: true,
12365
12870
  identifier: `${path}options`,
12366
- minimum_length: 2,
12367
- maximum_length: 20
12871
+ minimum_length: 2
12368
12872
  }),
12369
12873
  showDirectly: true
12370
12874
  }
@@ -12483,6 +12987,158 @@ var __publicField = (obj, key, value) => {
12483
12987
  __publicField(_MultiSelectField, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options.");
12484
12988
  __publicField(_MultiSelectField, "Icon", RiCheckboxLine);
12485
12989
  let MultiSelectField = _MultiSelectField;
12990
+ const QrScannerWrapper = "_QrScannerWrapper_1puz3_1";
12991
+ const styles$a = {
12992
+ QrScannerWrapper
12993
+ };
12994
+ const QrInput = React.memo((props) => {
12995
+ const [{ inputId, labelId, label, helpText, size, severity, showInputOnly, field, fieldProps }, rest] = useFormikInput(props);
12996
+ const [showQrScanner, setShowQrScanner] = React.useState(false);
12997
+ const value = fieldProps.value;
12998
+ const handleQrScan = React.useCallback(
12999
+ (data) => {
13000
+ fieldProps.onChange({ target: { value: data } });
13001
+ setShowQrScanner(false);
13002
+ },
13003
+ [fieldProps]
13004
+ );
13005
+ const handleClearScanResult = React.useCallback(() => {
13006
+ fieldProps.onChange({ target: { value: "" } });
13007
+ }, [fieldProps]);
13008
+ const handleScanButtonClicked = React.useCallback(() => {
13009
+ setShowQrScanner(true);
13010
+ }, []);
13011
+ const handleQrScannerClose = React.useCallback(() => {
13012
+ setShowQrScanner(false);
13013
+ }, []);
13014
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsxs(
13015
+ InputWithLabel,
13016
+ {
13017
+ size,
13018
+ severity,
13019
+ inputId,
13020
+ labelId,
13021
+ label: showInputOnly ? label : "",
13022
+ image: showInputOnly ? void 0 : field.image,
13023
+ flexProps: { direction: "column", justify: "start", align: "start", gap: "1" },
13024
+ children: [
13025
+ /* @__PURE__ */ jsxRuntime.jsx(
13026
+ blocks.Overlay,
13027
+ {
13028
+ open: showQrScanner,
13029
+ content: () => /* @__PURE__ */ jsxRuntime.jsx(QrScanner, { onQrScan: handleQrScan, onClose: handleQrScannerClose }),
13030
+ onOpenChange: setShowQrScanner
13031
+ }
13032
+ ),
13033
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex, { width: "max-content", gap: "1", align: "center", children: [
13034
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { ...rest, variant: "soft", onClick: handleScanButtonClicked, children: [
13035
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiQrCodeLine" }),
13036
+ "Scan"
13037
+ ] }),
13038
+ value && /* @__PURE__ */ jsxRuntime.jsx(Text, { color: "jade", size: "1", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCheckLine", style: { verticalAlign: "bottom" } }) })
13039
+ ] }),
13040
+ value && /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { width: "max-content", gap: "2", align: "center", children: [
13041
+ /* @__PURE__ */ jsxRuntime.jsx(Code, { color: "gray", highContrast: true, children: value }),
13042
+ /* @__PURE__ */ jsxRuntime.jsx(
13043
+ blocks.IconButton,
13044
+ {
13045
+ severity: "info",
13046
+ variant: "ghost",
13047
+ "aria-label": "delete",
13048
+ size: "small",
13049
+ onClick: handleClearScanResult,
13050
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCloseLine" })
13051
+ }
13052
+ )
13053
+ ] }) })
13054
+ ]
13055
+ }
13056
+ ) });
13057
+ });
13058
+ QrInput.displayName = "QrInput";
13059
+ const QrScanner = React.memo((props) => {
13060
+ const { onQrScan, onClose } = props;
13061
+ const videoRef = React.useRef(null);
13062
+ const [isScannerLoading, setIsScannerLoading] = React.useState(false);
13063
+ React.useEffect(() => {
13064
+ if (!videoRef.current)
13065
+ return;
13066
+ const qrScanner = new QrScannerAPI(
13067
+ videoRef.current,
13068
+ (result) => {
13069
+ const data = result.data;
13070
+ onQrScan(data);
13071
+ qrScanner.destroy();
13072
+ },
13073
+ {
13074
+ highlightCodeOutline: true,
13075
+ highlightScanRegion: true,
13076
+ maxScansPerSecond: 1
13077
+ }
13078
+ );
13079
+ setIsScannerLoading(true);
13080
+ qrScanner.start().then(() => {
13081
+ setIsScannerLoading(false);
13082
+ }).catch(() => {
13083
+ setIsScannerLoading(false);
13084
+ });
13085
+ }, [onQrScan]);
13086
+ return /* @__PURE__ */ jsxRuntime.jsxs(
13087
+ Flex,
13088
+ {
13089
+ className: styles$a.QrScannerWrapper,
13090
+ width: "100%",
13091
+ height: "100%",
13092
+ direction: "column",
13093
+ gap: "2",
13094
+ justify: "center",
13095
+ position: "relative",
13096
+ children: [
13097
+ /* @__PURE__ */ jsxRuntime.jsx(Flex, { width: "100%", position: "absolute", top: "0", p: "2", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { "aria-label": "close", variant: "soft", severity: "info", highContrast: true, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCloseLine" }) }) }),
13098
+ /* @__PURE__ */ jsxRuntime.jsxs(Box, { style: { maxWidth: "100%", maxHeight: "100%" }, position: "relative", children: [
13099
+ /* @__PURE__ */ jsxRuntime.jsx("video", { ref: videoRef, style: { width: "100%", height: "100%" } }),
13100
+ isScannerLoading && /* @__PURE__ */ jsxRuntime.jsx(
13101
+ Flex,
13102
+ {
13103
+ position: "absolute",
13104
+ inset: "0",
13105
+ style: { background: "var(--color-background)" },
13106
+ justify: "center",
13107
+ align: "center",
13108
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Spinner, {})
13109
+ }
13110
+ )
13111
+ ] })
13112
+ ]
13113
+ }
13114
+ );
13115
+ });
13116
+ QrScanner.displayName = "QrScanner";
13117
+ const emptyQrField = {
13118
+ ...emptyBaseField,
13119
+ type: "qr"
13120
+ };
13121
+ const _QrField = class _QrField extends BaseField {
13122
+ constructor(options) {
13123
+ super({ ...options, type: "qr" });
13124
+ __publicField(this, "onlyValidateAfterTouched", false);
13125
+ }
13126
+ serialize() {
13127
+ return super._serialize();
13128
+ }
13129
+ static deserialize(data) {
13130
+ if (data.type !== "qr")
13131
+ throw new Error("Type mismatch.");
13132
+ return new _QrField(data);
13133
+ }
13134
+ getInput(props) {
13135
+ return /* @__PURE__ */ jsxRuntime.jsx(QrInput, { ...props, field: this });
13136
+ }
13137
+ };
13138
+ __publicField(_QrField, "fieldTypeName", "QR");
13139
+ __publicField(_QrField, "fieldTypeDescription", "Used for scanning/reading QR codes.");
13140
+ __publicField(_QrField, "Icon", RiQrCodeLine);
13141
+ let QrField = _QrField;
12486
13142
  const FieldInputCloner = React.memo((props) => {
12487
13143
  const { field, ...rest } = props;
12488
13144
  const [{ value: identifier }] = formik.useField(field.options.clonedFieldIdentifier);
@@ -13740,6 +14396,7 @@ var __publicField = (obj, key, value) => {
13740
14396
  text: TextField,
13741
14397
  custom: CustomField,
13742
14398
  upload: UploadField,
14399
+ qr: QrField,
13743
14400
  // TODO: Underscore
13744
14401
  "multi-string": MultiStringField,
13745
14402
  "multi-select": MultiSelectField
@@ -13753,6 +14410,7 @@ var __publicField = (obj, key, value) => {
13753
14410
  text: emptyTextField,
13754
14411
  custom: emptyCustomField,
13755
14412
  upload: emptyUploadField,
14413
+ qr: emptyQrField,
13756
14414
  // TODO: Underscore
13757
14415
  "multi-string": emptyMultiStringField,
13758
14416
  "multi-select": emptyMultiSelectField
@@ -13840,7 +14498,7 @@ var __publicField = (obj, key, value) => {
13840
14498
  return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "3", children: [
13841
14499
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
13842
14500
  /* @__PURE__ */ jsxRuntime.jsx(Heading, { as: "h3", size: "3", children: label }),
13843
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.description, children: description2 })
14501
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.description, children: description2 })
13844
14502
  ] }),
13845
14503
  inputs
13846
14504
  ] }) });
@@ -14027,7 +14685,7 @@ var __publicField = (obj, key, value) => {
14027
14685
  };
14028
14686
  const useAttachImagesToFormRevisionFields = (revision) => {
14029
14687
  const { sdk } = useSDK();
14030
- const attachments = useAppSelector(selectRevisionAttachments((revision == null ? void 0 : revision.offline_id) ?? ""));
14688
+ const attachments = useAppSelector(selectAttachmentsOfFormRevision((revision == null ? void 0 : revision.offline_id) ?? ""));
14031
14689
  return React.useMemo(() => {
14032
14690
  if (!revision || !attachments)
14033
14691
  return revision;
@@ -14083,7 +14741,7 @@ var __publicField = (obj, key, value) => {
14083
14741
  [schema.title]
14084
14742
  );
14085
14743
  const Description = React.useMemo(
14086
- () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.description, children: schema.description }) : schema.description,
14744
+ () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.description, children: schema.description }) : schema.description,
14087
14745
  [schema.description]
14088
14746
  );
14089
14747
  const inputs = useFieldInputs(schema.fields, { formId: formId2, disabled: readonly });
@@ -14099,7 +14757,7 @@ var __publicField = (obj, key, value) => {
14099
14757
  !hideDescription && Description
14100
14758
  ] }) }),
14101
14759
  inputs,
14102
- !readonly && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$b.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
14760
+ !readonly && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
14103
14761
  cancelText && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { severity: "info", ...buttonProps, type: "button", onClick: onCancel, children: cancelText }),
14104
14762
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { ...buttonProps, type: "submit", disabled: !formik$1.isValid, children: submitText })
14105
14763
  ] })
@@ -14124,7 +14782,7 @@ var __publicField = (obj, key, value) => {
14124
14782
  return formRevisionToSchema(revisionWithImages, { readonly: true });
14125
14783
  }, [revisionWithImages]);
14126
14784
  const submissionValuesWithAttachments = React.useMemo(() => {
14127
- const attachments = selectSubmissionAttachments(submission.offline_id)(sdk.store.getState()) ?? [];
14785
+ const attachments = selectAttachmentsOfFormSubmission(submission.offline_id)(sdk.store.getState()) ?? [];
14128
14786
  const downloadedAttachments = {};
14129
14787
  for (const attachment of attachments) {
14130
14788
  const promise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
@@ -14174,8 +14832,8 @@ var __publicField = (obj, key, value) => {
14174
14832
  }
14175
14833
  return ret;
14176
14834
  }, [filter, maxResults, ownerFilter]);
14177
- const userForms = useAppSelector(selectFilteredUserForms(ownerFilterOptions)) ?? [];
14178
- const userFormMapping = useAppSelector(selectUserFormMapping);
14835
+ const userForms = useAppSelector(selectFilteredForms(ownerFilterOptions)) ?? [];
14836
+ const userFormMapping = useAppSelector(selectFormMapping);
14179
14837
  const attachableUserForms = userForms.filter((form) => !form.component_type);
14180
14838
  const attachableUserFormMapping = Object.values(userFormMapping).filter(
14181
14839
  (form) => !form.component_type
@@ -14208,7 +14866,7 @@ var __publicField = (obj, key, value) => {
14208
14866
  const handleChange = React.useCallback((e) => {
14209
14867
  setFilter(e.currentTarget.value);
14210
14868
  }, []);
14211
- const numberOfForms = useAppSelector(selectNumberOfGeneralUserForms) || 0;
14869
+ const numberOfForms = useAppSelector(selectGeneralFormCount) || 0;
14212
14870
  const numberOfHiddenForms = numberOfForms - attachableUserForms.length;
14213
14871
  const overflowMessage = attachableUserForms.length == maxResults && numberOfHiddenForms > 0 ? `Only the first ${maxResults} results are shown (${numberOfHiddenForms} hidden)` : numberOfHiddenForms > 0 && `${numberOfHiddenForms} hidden forms`;
14214
14872
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { ref, direction: "column", gap: "2", children: [
@@ -14302,16 +14960,13 @@ var __publicField = (obj, key, value) => {
14302
14960
  const { submission, onSubmissionClick, compact, labelType, rowDecorator } = props;
14303
14961
  const currentUser = useAppSelector(selectCurrentUser);
14304
14962
  const createdBy = useAppSelector(selectUser("created_by" in submission ? submission.created_by : currentUser.id));
14305
- const dateToUse = getCreatedAtOrSubmittedAtDate(submission);
14306
- const formattedDateTime = isToday(dateToUse) ? dateToUse.toLocaleTimeString([], {
14307
- hour: "2-digit",
14308
- minute: "2-digit"
14309
- }) : getLocalDateString(dateToUse);
14963
+ const dateToUse = submission.submitted_at;
14964
+ const formattedDateTime = getLocalDateString(dateToUse);
14310
14965
  const revision = useAppSelector(selectFormRevision(submission.form_revision));
14311
14966
  if (!revision) {
14312
14967
  throw new Error(`Could not find revision ${submission.form_revision} for submission ${submission.offline_id}.`);
14313
14968
  }
14314
- const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevision(revision.form))) == null ? void 0 : _a2.revision;
14969
+ const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevisionOfForm(revision.form))) == null ? void 0 : _a2.revision;
14315
14970
  const creatorProfileSrc = useFileSrc({
14316
14971
  file: (createdBy == null ? void 0 : createdBy.profile.file) ?? null,
14317
14972
  fileSha1: (createdBy == null ? void 0 : createdBy.profile.file_sha1) ?? null
@@ -14342,10 +14997,6 @@ var __publicField = (obj, key, value) => {
14342
14997
  return row;
14343
14998
  });
14344
14999
  FormSubmissionBrowserEntry.displayName = "FormSubmissionBrowserEntry";
14345
- const getCreatedAtOrSubmittedAtDate = (submission) => {
14346
- const date = "created_at" in submission ? submission.created_at : submission.submitted_at;
14347
- return new Date(date);
14348
- };
14349
15000
  const FormSubmissionBrowser = React.memo((props) => {
14350
15001
  const {
14351
15002
  formId: formId2,
@@ -14359,10 +15010,10 @@ var __publicField = (obj, key, value) => {
14359
15010
  if (!!formId2 === !!propSubmissions) {
14360
15011
  throw new Error("Either formId or submissions must be provided, but not both.");
14361
15012
  }
14362
- const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectSubmissionsForForm(formId2));
15013
+ const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectFormSubmissionsOfForm(formId2));
14363
15014
  const sortedSubmissions = React.useMemo(
14364
15015
  () => submissions == null ? void 0 : submissions.sort((a, b) => {
14365
- return getCreatedAtOrSubmittedAtDate(b).getTime() - getCreatedAtOrSubmittedAtDate(a).getTime();
15016
+ return a.submitted_at.localeCompare(b.submitted_at);
14366
15017
  }),
14367
15018
  [submissions]
14368
15019
  );
@@ -15454,12 +16105,12 @@ var __publicField = (obj, key, value) => {
15454
16105
  });
15455
16106
  const previewSchema = React.useMemo(() => formRevisionToSchema(formik$1.values), [formik$1.values]);
15456
16107
  return /* @__PURE__ */ jsxRuntime.jsx(Tabs.Root, { ref, defaultValue: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
15457
- showTabs && /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: classNames$1(styles$c.tabsList, tabsListClassName), children: [
15458
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$c.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
16108
+ showTabs && /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: classNames$1(styles$d.tabsList, tabsListClassName), children: [
16109
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$d.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
15459
16110
  /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiPencilLine" }),
15460
16111
  "Edit"
15461
16112
  ] }) }),
15462
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$c.tabTrigger, value: "preview", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
16113
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$d.tabTrigger, value: "preview", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
15463
16114
  /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiEyeLine" }),
15464
16115
  "Preview"
15465
16116
  ] }) })
@@ -15483,8 +16134,8 @@ var __publicField = (obj, key, value) => {
15483
16134
  render: ({ setValue, value, meta }) => /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: meta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
15484
16135
  blocks.Input,
15485
16136
  {
15486
- className: classNames$1(styles$c.title, {
15487
- [styles$c.error]: meta.error
16137
+ className: classNames$1(styles$d.title, {
16138
+ [styles$d.error]: meta.error
15488
16139
  }),
15489
16140
  placeholder: "Form title",
15490
16141
  value,
@@ -15506,7 +16157,7 @@ var __publicField = (obj, key, value) => {
15506
16157
  render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
15507
16158
  blocks.TextArea,
15508
16159
  {
15509
- className: styles$c.description,
16160
+ className: styles$d.description,
15510
16161
  placeholder: "Explain the purpose of this form",
15511
16162
  value,
15512
16163
  onChange: (event) => {
@@ -15524,7 +16175,7 @@ var __publicField = (obj, key, value) => {
15524
16175
  /* @__PURE__ */ jsxRuntime.jsx(FieldsEditor, { fieldsOnly }),
15525
16176
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity: "danger", size: "1", children: typeof formik$1.errors.fields === "string" && formik$1.errors.fields })
15526
16177
  ] }),
15527
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
16178
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$d.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
15528
16179
  onCancel && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "solid", severity: "info", onClick: onCancel, children: "Cancel" }),
15529
16180
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", children: "Save form" })
15530
16181
  ] })
@@ -15559,6 +16210,9 @@ var __publicField = (obj, key, value) => {
15559
16210
  NumberInput,
15560
16211
  PatchField,
15561
16212
  PatchFormProvider,
16213
+ QrField,
16214
+ QrInput,
16215
+ QrScanner,
15562
16216
  SelectField,
15563
16217
  SelectInput,
15564
16218
  StringField,
@@ -15573,6 +16227,7 @@ var __publicField = (obj, key, value) => {
15573
16227
  emptyMultiSelectField,
15574
16228
  emptyMultiStringField,
15575
16229
  emptyNumberField,
16230
+ emptyQrField,
15576
16231
  emptySelectField,
15577
16232
  emptyStringField,
15578
16233
  emptyTextField,
@@ -15662,6 +16317,9 @@ var __publicField = (obj, key, value) => {
15662
16317
  exports2.ProjectFileService = ProjectFileService;
15663
16318
  exports2.ProjectService = ProjectService;
15664
16319
  exports2.ProjectType = ProjectType;
16320
+ exports2.QrField = QrField;
16321
+ exports2.QrInput = QrInput;
16322
+ exports2.QrScanner = QrScanner;
15665
16323
  exports2.SDKContext = SDKContext;
15666
16324
  exports2.SDKProvider = SDKProvider;
15667
16325
  exports2.SUPPORTED_IMAGE_FILE_TYPES = SUPPORTED_IMAGE_FILE_TYPES;
@@ -15672,6 +16330,7 @@ var __publicField = (obj, key, value) => {
15672
16330
  exports2.SpreadsheetViewer = SpreadsheetViewer;
15673
16331
  exports2.StringField = StringField;
15674
16332
  exports2.StringInput = StringInput;
16333
+ exports2.TeamService = TeamService;
15675
16334
  exports2.TextField = TextField;
15676
16335
  exports2.TextInput = TextInput;
15677
16336
  exports2.UserFormService = UserFormService;
@@ -15679,6 +16338,7 @@ var __publicField = (obj, key, value) => {
15679
16338
  exports2.VerificationCodeType = VerificationCodeType;
15680
16339
  exports2.WorkspaceService = WorkspaceService;
15681
16340
  exports2.YELLOW = YELLOW;
16341
+ exports2._selectLatestFormRevision = _selectLatestFormRevision;
15682
16342
  exports2._setLatestRetryTime = _setLatestRetryTime;
15683
16343
  exports2.acceptProjectInvite = acceptProjectInvite;
15684
16344
  exports2.addActiveProjectFormSubmissionsCount = addActiveProjectFormSubmissionsCount;
@@ -15696,6 +16356,16 @@ var __publicField = (obj, key, value) => {
15696
16356
  exports2.addDocuments = addDocuments;
15697
16357
  exports2.addEmailDomain = addEmailDomain;
15698
16358
  exports2.addFavouriteProjectId = addFavouriteProjectId;
16359
+ exports2.addForm = addForm;
16360
+ exports2.addFormRevision = addFormRevision;
16361
+ exports2.addFormRevisionAttachment = addFormRevisionAttachment;
16362
+ exports2.addFormRevisionAttachments = addFormRevisionAttachments;
16363
+ exports2.addFormRevisions = addFormRevisions;
16364
+ exports2.addFormSubmission = addFormSubmission;
16365
+ exports2.addFormSubmissionAttachment = addFormSubmissionAttachment;
16366
+ exports2.addFormSubmissionAttachments = addFormSubmissionAttachments;
16367
+ exports2.addFormSubmissions = addFormSubmissions;
16368
+ exports2.addForms = addForms;
15699
16369
  exports2.addIssue = addIssue;
15700
16370
  exports2.addIssueAttachment = addIssueAttachment;
15701
16371
  exports2.addIssueAttachments = addIssueAttachments;
@@ -15715,14 +16385,8 @@ var __publicField = (obj, key, value) => {
15715
16385
  exports2.addStageCompletion = addStageCompletion;
15716
16386
  exports2.addStageCompletions = addStageCompletions;
15717
16387
  exports2.addStages = addStages;
16388
+ exports2.addTeam = addTeam;
15718
16389
  exports2.addToRecentIssues = addToRecentIssues;
15719
- exports2.addUserForm = addUserForm;
15720
- exports2.addUserFormRevision = addUserFormRevision;
15721
- exports2.addUserFormRevisionAttachment = addUserFormRevisionAttachment;
15722
- exports2.addUserFormRevisions = addUserFormRevisions;
15723
- exports2.addUserFormSubmissionAttachment = addUserFormSubmissionAttachment;
15724
- exports2.addUserFormSubmissions = addUserFormSubmissions;
15725
- exports2.addUserForms = addUserForms;
15726
16390
  exports2.addUsers = addUsers;
15727
16391
  exports2.addWorkspace = addWorkspace;
15728
16392
  exports2.areArraysEqual = areArraysEqual;
@@ -15743,6 +16407,7 @@ var __publicField = (obj, key, value) => {
15743
16407
  exports2.componentStageSlice = componentStageSlice;
15744
16408
  exports2.componentTypeReducer = componentTypeReducer;
15745
16409
  exports2.componentTypeSlice = componentTypeSlice;
16410
+ exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
15746
16411
  exports2.coordinatesAreEqual = coordinatesAreEqual;
15747
16412
  exports2.coordinatesToLiteral = coordinatesToLiteral;
15748
16413
  exports2.coordinatesToPointGeometry = coordinatesToPointGeometry;
@@ -15753,12 +16418,17 @@ var __publicField = (obj, key, value) => {
15753
16418
  exports2.defaultBadgeColor = defaultBadgeColor;
15754
16419
  exports2.defaultStore = defaultStore;
15755
16420
  exports2.deleteComponentType = deleteComponentType;
16421
+ exports2.deleteForm = deleteForm;
16422
+ exports2.deleteFormRevision = deleteFormRevision;
16423
+ exports2.deleteFormRevisionAttachment = deleteFormRevisionAttachment;
16424
+ exports2.deleteFormRevisionAttachments = deleteFormRevisionAttachments;
16425
+ exports2.deleteFormRevisions = deleteFormRevisions;
16426
+ exports2.deleteFormSubmission = deleteFormSubmission;
16427
+ exports2.deleteFormSubmissionAttachment = deleteFormSubmissionAttachment;
16428
+ exports2.deleteFormSubmissionAttachments = deleteFormSubmissionAttachments;
16429
+ exports2.deleteFormSubmissions = deleteFormSubmissions;
15756
16430
  exports2.deleteProject = deleteProject;
15757
- exports2.deleteUserForm = deleteUserForm;
15758
- exports2.deleteUserFormRevision = deleteUserFormRevision;
15759
- exports2.deleteUserFormRevisions = deleteUserFormRevisions;
15760
- exports2.deleteUserFormSubmission = deleteUserFormSubmission;
15761
- exports2.deleteUserFormSubmissions = deleteUserFormSubmissions;
16431
+ exports2.deleteTeam = deleteTeam;
15762
16432
  exports2.dequeue = dequeue;
15763
16433
  exports2.deserialize = deserialize;
15764
16434
  exports2.deserializeField = deserializeField;
@@ -15776,6 +16446,7 @@ var __publicField = (obj, key, value) => {
15776
16446
  exports2.emptyMultiSelectField = emptyMultiSelectField;
15777
16447
  exports2.emptyMultiStringField = emptyMultiStringField;
15778
16448
  exports2.emptyNumberField = emptyNumberField;
16449
+ exports2.emptyQrField = emptyQrField;
15779
16450
  exports2.emptySelectField = emptySelectField;
15780
16451
  exports2.emptyStringField = emptyStringField;
15781
16452
  exports2.emptyTextField = emptyTextField;
@@ -15787,7 +16458,13 @@ var __publicField = (obj, key, value) => {
15787
16458
  exports2.fileSlice = fileSlice;
15788
16459
  exports2.fileToBlob = fileToBlob;
15789
16460
  exports2.flipCoordinates = flipCoordinates;
16461
+ exports2.formReducer = formReducer;
16462
+ exports2.formRevisionReducer = formRevisionReducer;
15790
16463
  exports2.formRevisionToSchema = formRevisionToSchema;
16464
+ exports2.formRevisionsSlice = formRevisionsSlice;
16465
+ exports2.formSlice = formSlice;
16466
+ exports2.formSubmissionReducer = formSubmissionReducer;
16467
+ exports2.formSubmissionSlice = formSubmissionSlice;
15791
16468
  exports2.forms = index;
15792
16469
  exports2.fullComponentMarkerSize = fullComponentMarkerSize;
15793
16470
  exports2.generateBadgeColors = generateBadgeColors;
@@ -15915,6 +16592,8 @@ var __publicField = (obj, key, value) => {
15915
16592
  exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
15916
16593
  exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
15917
16594
  exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
16595
+ exports2.selectAttachmentsOfFormRevision = selectAttachmentsOfFormRevision;
16596
+ exports2.selectAttachmentsOfFormSubmission = selectAttachmentsOfFormSubmission;
15918
16597
  exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
15919
16598
  exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
15920
16599
  exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
@@ -15932,11 +16611,9 @@ var __publicField = (obj, key, value) => {
15932
16611
  exports2.selectComponent = selectComponent;
15933
16612
  exports2.selectComponentAttachment = selectComponentAttachment;
15934
16613
  exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
15935
- exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
15936
16614
  exports2.selectComponentType = selectComponentType;
15937
16615
  exports2.selectComponentTypeAttachment = selectComponentTypeAttachment;
15938
16616
  exports2.selectComponentTypeAttachmentMapping = selectComponentTypeAttachmentMapping;
15939
- exports2.selectComponentTypeForm = selectComponentTypeForm;
15940
16617
  exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
15941
16618
  exports2.selectComponentTypeFromComponents = selectComponentTypeFromComponents;
15942
16619
  exports2.selectComponentTypeStagesMapping = selectComponentTypeStagesMapping;
@@ -15966,8 +16643,24 @@ var __publicField = (obj, key, value) => {
15966
16643
  exports2.selectExpandedSections = selectExpandedSections;
15967
16644
  exports2.selectFavouriteProjects = selectFavouriteProjects;
15968
16645
  exports2.selectFileAttachmentsOfIssue = selectFileAttachmentsOfIssue;
15969
- exports2.selectFilteredUserForms = selectFilteredUserForms;
16646
+ exports2.selectFilteredForms = selectFilteredForms;
16647
+ exports2.selectForm = selectForm;
16648
+ exports2.selectFormMapping = selectFormMapping;
16649
+ exports2.selectFormOfComponentType = selectFormOfComponentType;
15970
16650
  exports2.selectFormRevision = selectFormRevision;
16651
+ exports2.selectFormRevisionMapping = selectFormRevisionMapping;
16652
+ exports2.selectFormRevisions = selectFormRevisions;
16653
+ exports2.selectFormRevisionsOfForm = selectFormRevisionsOfForm;
16654
+ exports2.selectFormSubmission = selectFormSubmission;
16655
+ exports2.selectFormSubmissionAttachmentsMapping = selectFormSubmissionAttachmentsMapping;
16656
+ exports2.selectFormSubmissions = selectFormSubmissions;
16657
+ exports2.selectFormSubmissionsByComponents = selectFormSubmissionsByComponents;
16658
+ exports2.selectFormSubmissionsMapping = selectFormSubmissionsMapping;
16659
+ exports2.selectFormSubmissionsOfComponent = selectFormSubmissionsOfComponent;
16660
+ exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
16661
+ exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
16662
+ exports2.selectFormsCount = selectFormsCount;
16663
+ exports2.selectGeneralFormCount = selectGeneralFormCount;
15971
16664
  exports2.selectHiddenCategoryCount = selectHiddenCategoryCount;
15972
16665
  exports2.selectHiddenComponentTypeIds = selectHiddenComponentTypeIds;
15973
16666
  exports2.selectIsFetchingInitialData = selectIsFetchingInitialData;
@@ -15978,14 +16671,15 @@ var __publicField = (obj, key, value) => {
15978
16671
  exports2.selectIssueAttachment = selectIssueAttachment;
15979
16672
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
15980
16673
  exports2.selectIssueAttachments = selectIssueAttachments;
16674
+ exports2.selectIssueCountOfCategory = selectIssueCountOfCategory;
15981
16675
  exports2.selectIssueMapping = selectIssueMapping;
15982
16676
  exports2.selectIssueUpdateMapping = selectIssueUpdateMapping;
15983
16677
  exports2.selectIssueUpdatesOfIssue = selectIssueUpdatesOfIssue;
15984
16678
  exports2.selectIssues = selectIssues;
15985
- exports2.selectLatestFormRevision = selectLatestFormRevision;
16679
+ exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
16680
+ exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
16681
+ exports2.selectLatestFormRevisionsOfComponentTypes = selectLatestFormRevisionsOfComponentTypes;
15986
16682
  exports2.selectLatestRetryTime = selectLatestRetryTime;
15987
- exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
15988
- exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
15989
16683
  exports2.selectLicense = selectLicense;
15990
16684
  exports2.selectLicenseForProject = selectLicenseForProject;
15991
16685
  exports2.selectLicenses = selectLicenses;
@@ -15994,8 +16688,6 @@ var __publicField = (obj, key, value) => {
15994
16688
  exports2.selectMapStyle = selectMapStyle;
15995
16689
  exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
15996
16690
  exports2.selectNumberOfComponentsOfComponentType = selectNumberOfComponentsOfComponentType;
15997
- exports2.selectNumberOfGeneralUserForms = selectNumberOfGeneralUserForms;
15998
- exports2.selectNumberOfUserForms = selectNumberOfUserForms;
15999
16691
  exports2.selectOrganization = selectOrganization;
16000
16692
  exports2.selectOrganizationAccess = selectOrganizationAccess;
16001
16693
  exports2.selectOrganizationAccessForUser = selectOrganizationAccessForUser;
@@ -16023,8 +16715,6 @@ var __publicField = (obj, key, value) => {
16023
16715
  exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
16024
16716
  exports2.selectRecentProjects = selectRecentProjects;
16025
16717
  exports2.selectRehydrated = selectRehydrated;
16026
- exports2.selectRevisionAttachments = selectRevisionAttachments;
16027
- exports2.selectRevisionsForForm = selectRevisionsForForm;
16028
16718
  exports2.selectRootDocuments = selectRootDocuments;
16029
16719
  exports2.selectShowTooltips = selectShowTooltips;
16030
16720
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
@@ -16039,16 +16729,15 @@ var __publicField = (obj, key, value) => {
16039
16729
  exports2.selectStagesFromComponentType = selectStagesFromComponentType;
16040
16730
  exports2.selectStagesFromComponentTypeIds = selectStagesFromComponentTypeIds;
16041
16731
  exports2.selectStagesFromStageIds = selectStagesFromStageIds;
16042
- exports2.selectSubmissionAttachments = selectSubmissionAttachments;
16043
- exports2.selectSubmissionsForComponent = selectSubmissionsForComponent;
16044
- exports2.selectSubmissionsForForm = selectSubmissionsForForm;
16045
- exports2.selectSubmissionsForIssue = selectSubmissionsForIssue;
16732
+ exports2.selectTeam = selectTeam;
16733
+ exports2.selectTeams = selectTeams;
16734
+ exports2.selectTeamsMapping = selectTeamsMapping;
16735
+ exports2.selectTeamsOfOrganization = selectTeamsOfOrganization;
16736
+ exports2.selectTeamsOfUser = selectTeamsOfUser;
16046
16737
  exports2.selectUploadUrl = selectUploadUrl;
16047
16738
  exports2.selectUsedColors = selectUsedColors;
16048
16739
  exports2.selectUser = selectUser;
16049
- exports2.selectUserForm = selectUserForm;
16050
- exports2.selectUserFormMapping = selectUserFormMapping;
16051
- exports2.selectUserFormSubmission = selectUserFormSubmission;
16740
+ exports2.selectUserFormRevisionAttachmentsMapping = selectUserFormRevisionAttachmentsMapping;
16052
16741
  exports2.selectUsersAsMapping = selectUsersAsMapping;
16053
16742
  exports2.selectVisibleStatuses = selectVisibleStatuses;
16054
16743
  exports2.selectVisibleUserIds = selectVisibleUserIds;
@@ -16075,6 +16764,13 @@ var __publicField = (obj, key, value) => {
16075
16764
  exports2.setEnableClustering = setEnableClustering;
16076
16765
  exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
16077
16766
  exports2.setEnablePlacementMode = setEnablePlacementMode;
16767
+ exports2.setFormRevision = setFormRevision;
16768
+ exports2.setFormRevisionAttachments = setFormRevisionAttachments;
16769
+ exports2.setFormRevisions = setFormRevisions;
16770
+ exports2.setFormSubmission = setFormSubmission;
16771
+ exports2.setFormSubmissionAttachments = setFormSubmissionAttachments;
16772
+ exports2.setFormSubmissions = setFormSubmissions;
16773
+ exports2.setForms = setForms;
16078
16774
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
16079
16775
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
16080
16776
  exports2.setIsLoading = setIsLoading;
@@ -16096,12 +16792,11 @@ var __publicField = (obj, key, value) => {
16096
16792
  exports2.setSectionExpanded = setSectionExpanded;
16097
16793
  exports2.setShowTooltips = setShowTooltips;
16098
16794
  exports2.setStageCompletions = setStageCompletions;
16795
+ exports2.setTeam = setTeam;
16796
+ exports2.setTeams = setTeams;
16099
16797
  exports2.setTokens = setTokens;
16100
16798
  exports2.setTourStep = setTourStep;
16101
16799
  exports2.setUploadUrl = setUploadUrl;
16102
- exports2.setUserFormRevisionAttachments = setUserFormRevisionAttachments;
16103
- exports2.setUserFormSubmissionAttachments = setUserFormSubmissionAttachments;
16104
- exports2.setUserFormSubmissions = setUserFormSubmissions;
16105
16800
  exports2.setUsers = setUsers;
16106
16801
  exports2.setVisibleStatuses = setVisibleStatuses;
16107
16802
  exports2.setVisibleUserIds = setVisibleUserIds;
@@ -16112,6 +16807,8 @@ var __publicField = (obj, key, value) => {
16112
16807
  exports2.slugify = slugify;
16113
16808
  exports2.spacesToDashesLower = spacesToDashesLower;
16114
16809
  exports2.successColor = successColor;
16810
+ exports2.teamReducer = teamReducer;
16811
+ exports2.teamSlice = teamSlice;
16115
16812
  exports2.toFileNameSafeString = toFileNameSafeString;
16116
16813
  exports2.toOfflineIdRecord = toOfflineIdRecord;
16117
16814
  exports2.toggleComponentTypeVisibility = toggleComponentTypeVisibility;
@@ -16126,15 +16823,18 @@ var __publicField = (obj, key, value) => {
16126
16823
  exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
16127
16824
  exports2.updateDocumentAttachment = updateDocumentAttachment;
16128
16825
  exports2.updateDocuments = updateDocuments;
16826
+ exports2.updateFormSubmission = updateFormSubmission;
16827
+ exports2.updateFormSubmissionAttachments = updateFormSubmissionAttachments;
16828
+ exports2.updateFormSubmissions = updateFormSubmissions;
16129
16829
  exports2.updateIssue = updateIssue;
16130
16830
  exports2.updateIssueAttachment = updateIssueAttachment;
16131
16831
  exports2.updateLicense = updateLicense;
16132
16832
  exports2.updateOrCreateProject = updateOrCreateProject;
16133
- exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
16134
16833
  exports2.updateOrganizationAccess = updateOrganizationAccess;
16135
16834
  exports2.updateProjectAccess = updateProjectAccess;
16136
16835
  exports2.updateProjectAttachment = updateProjectAttachment;
16137
16836
  exports2.updateStages = updateStages;
16837
+ exports2.updateTeam = updateTeam;
16138
16838
  exports2.useAppDispatch = useAppDispatch;
16139
16839
  exports2.useAppSelector = useAppSelector;
16140
16840
  exports2.useFieldInput = useFieldInput;
@@ -16144,8 +16844,6 @@ var __publicField = (obj, key, value) => {
16144
16844
  exports2.useFormikInput = useFormikInput;
16145
16845
  exports2.useMemoCompare = useMemoCompare;
16146
16846
  exports2.useSDK = useSDK;
16147
- exports2.userFormReducer = userFormReducer;
16148
- exports2.userFormSlice = userFormSlice;
16149
16847
  exports2.userReducer = userReducer;
16150
16848
  exports2.userSlice = userSlice;
16151
16849
  exports2.valueIsFile = valueIsFile;