@ailaw/venus 0.3.14 → 0.3.18

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 (2) hide show
  1. package/dist/venus.es.js +259 -3833
  2. package/package.json +1 -1
package/dist/venus.es.js CHANGED
@@ -17,13 +17,12 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { defineComponent, ref as ref$1, watch, computed, toRefs as toRefs$1, shallowRef, onMounted } from "vue-demi";
20
+ import { defineComponent, ref as ref$1, watch, computed, toRefs as toRefs$1, shallowRef } from "vue-demi";
21
21
  import { Select, Modal, Form, Input, Checkbox, Divider, Button, Tag, Tooltip, Upload, Row, Col, Radio, Table, Badge, Card, message } from "ant-design-vue";
22
- import { useQuery, useResult, useMutation } from "@vue/apollo-composable";
22
+ import { useQuery, useResult, useMutation, useApolloClient } from "@vue/apollo-composable";
23
23
  import gql from "graphql-tag";
24
24
  import { path, uniqBy, prop } from "ramda";
25
25
  import "vue";
26
- import { Source, visit } from "graphql";
27
26
  var index$4 = "";
28
27
  function __variableDynamicImportRuntime0__$1(path2) {
29
28
  switch (path2) {
@@ -221,10 +220,10 @@ function useCreateProfile() {
221
220
  const me = useMe();
222
221
  const { mutate, loading } = useMutation(addProfileUserMutation);
223
222
  const createProfile = async (profile) => {
224
- var _a2;
223
+ var _a;
225
224
  const variables = {
226
225
  email: profile.email,
227
- lawFirmId: (_a2 = me.value) == null ? void 0 : _a2.lawFirmId
226
+ lawFirmId: (_a = me.value) == null ? void 0 : _a.lawFirmId
228
227
  };
229
228
  if (profile.profileType === "USERPROFILE") {
230
229
  variables.name = profile.profileName;
@@ -374,8 +373,8 @@ var __vue2_script$d = defineComponent({
374
373
  },
375
374
  setup(props, { emit }) {
376
375
  const selectedId = computed(() => {
377
- var _a2;
378
- return (_a2 = props.value) == null ? void 0 : _a2.id;
376
+ var _a;
377
+ return (_a = props.value) == null ? void 0 : _a.id;
379
378
  });
380
379
  const handleSelect = (value) => emit("input", props.source.find((v) => String(v.id) == value));
381
380
  const handleProfileCreate = () => emit("create-profile");
@@ -411,9 +410,9 @@ var ProfileSelector = /* @__PURE__ */ function() {
411
410
  function useProfiles(keywords, onlyRole, profileIds) {
412
411
  const me = useMe();
413
412
  const { result, loading } = useQuery(profilesQuery, () => {
414
- var _a2;
413
+ var _a;
415
414
  return {
416
- lawFirmId: (_a2 = me.value) == null ? void 0 : _a2.lawFirmId,
415
+ lawFirmId: (_a = me.value) == null ? void 0 : _a.lawFirmId,
417
416
  keywords: keywords.value,
418
417
  profileType: onlyRole.value,
419
418
  profileIds: profileIds.value
@@ -843,7 +842,7 @@ var __vue2_script$9 = defineComponent({
843
842
  [k]: v
844
843
  }));
845
844
  };
846
- const remove2 = (id) => {
845
+ const remove = (id) => {
847
846
  emit("change", props.value.filter((v) => v.id !== id));
848
847
  };
849
848
  const beforeUpload = (file) => {
@@ -874,7 +873,7 @@ var __vue2_script$9 = defineComponent({
874
873
  };
875
874
  return {
876
875
  changeVal,
877
- remove: remove2,
876
+ remove,
878
877
  beforeUpload,
879
878
  loading,
880
879
  allowFiles: [
@@ -913,10 +912,10 @@ var AFileUploader = /* @__PURE__ */ function() {
913
912
  return __component__$9.exports;
914
913
  }();
915
914
  var refactorParams = (record) => {
916
- var _a2;
915
+ var _a;
917
916
  return {
918
917
  id: record.id,
919
- sampleDocList: ((_a2 = record.sampleDocs) == null ? void 0 : _a2.map(({ id }) => id)) || [],
918
+ sampleDocList: ((_a = record.sampleDocs) == null ? void 0 : _a.map(({ id }) => id)) || [],
920
919
  taskName: record.taskName,
921
920
  isEmployee: record.isEmployee || AssigneeTypes[AssigneeTypes.EMPTY_DEFAULT],
922
921
  generalTaskType: record.generalTaskType,
@@ -1219,7 +1218,7 @@ function __vue2_injectStyles$6(context) {
1219
1218
  var TaskTemplateFilter = /* @__PURE__ */ function() {
1220
1219
  return __component__$6.exports;
1221
1220
  }();
1222
- var toString$2 = function(x) {
1221
+ var toString = function(x) {
1223
1222
  return Object.prototype.toString.call(x);
1224
1223
  };
1225
1224
  function isNative(Ctor) {
@@ -1229,8 +1228,8 @@ var hasSymbol = typeof Symbol !== "undefined" && isNative(Symbol) && typeof Refl
1229
1228
  var noopFn = function(_) {
1230
1229
  return _;
1231
1230
  };
1232
- function proxy(target, key, _a2) {
1233
- var get2 = _a2.get, set2 = _a2.set;
1231
+ function proxy(target, key, _a) {
1232
+ var get2 = _a.get, set2 = _a.set;
1234
1233
  Object.defineProperty(target, key, {
1235
1234
  enumerable: true,
1236
1235
  configurable: true,
@@ -1246,7 +1245,7 @@ function def(obj, key, val, enumerable) {
1246
1245
  configurable: true
1247
1246
  });
1248
1247
  }
1249
- function hasOwn$1(obj, key) {
1248
+ function hasOwn(obj, key) {
1250
1249
  return Object.hasOwnProperty.call(obj, key);
1251
1250
  }
1252
1251
  function isArray(x) {
@@ -1261,7 +1260,7 @@ function isObject(val) {
1261
1260
  return val !== null && typeof val === "object";
1262
1261
  }
1263
1262
  function isPlainObject(x) {
1264
- return toString$2(x) === "[object Object]";
1263
+ return toString(x) === "[object Object]";
1265
1264
  }
1266
1265
  function isFunction(x) {
1267
1266
  return typeof x === "function";
@@ -1280,24 +1279,24 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1280
1279
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1281
1280
  PERFORMANCE OF THIS SOFTWARE.
1282
1281
  ***************************************************************************** */
1283
- var extendStatics$1 = function(d, b) {
1284
- extendStatics$1 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
1282
+ var extendStatics = function(d, b) {
1283
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
1285
1284
  d2.__proto__ = b2;
1286
1285
  } || function(d2, b2) {
1287
1286
  for (var p in b2)
1288
1287
  if (Object.prototype.hasOwnProperty.call(b2, p))
1289
1288
  d2[p] = b2[p];
1290
1289
  };
1291
- return extendStatics$1(d, b);
1290
+ return extendStatics(d, b);
1292
1291
  };
1293
- function __extends$1(d, b) {
1292
+ function __extends(d, b) {
1294
1293
  if (typeof b !== "function" && b !== null)
1295
1294
  throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1296
- extendStatics$1(d, b);
1297
- function __2() {
1295
+ extendStatics(d, b);
1296
+ function __() {
1298
1297
  this.constructor = d;
1299
1298
  }
1300
- d.prototype = b === null ? Object.create(b) : (__2.prototype = b.prototype, new __2());
1299
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1301
1300
  }
1302
1301
  function __values(o) {
1303
1302
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
@@ -1360,7 +1359,7 @@ var EffectScopeImpl = function() {
1360
1359
  return EffectScopeImpl2;
1361
1360
  }();
1362
1361
  (function(_super) {
1363
- __extends$1(EffectScope, _super);
1362
+ __extends(EffectScope, _super);
1364
1363
  function EffectScope(detached) {
1365
1364
  if (detached === void 0) {
1366
1365
  detached = false;
@@ -1379,13 +1378,13 @@ var EffectScopeImpl = function() {
1379
1378
  return EffectScope;
1380
1379
  })(EffectScopeImpl);
1381
1380
  function recordEffectScope(effect, scope) {
1382
- var _a2;
1381
+ var _a;
1383
1382
  scope = scope || activeEffectScope;
1384
1383
  if (scope && scope.active) {
1385
1384
  scope.effects.push(effect);
1386
1385
  return;
1387
1386
  }
1388
- var vm = (_a2 = getCurrentInstance()) === null || _a2 === void 0 ? void 0 : _a2.proxy;
1387
+ var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy;
1389
1388
  vm && vm.$on("hook:destroyed", function() {
1390
1389
  return effect.stop();
1391
1390
  });
@@ -1411,7 +1410,7 @@ try {
1411
1410
  } else if (requiredVue && "default" in requiredVue && isVue(requiredVue.default)) {
1412
1411
  vueDependency = requiredVue.default;
1413
1412
  }
1414
- } catch (_a2) {
1413
+ } catch (_a) {
1415
1414
  }
1416
1415
  var vueConstructor = null;
1417
1416
  var currentInstance = null;
@@ -1421,7 +1420,7 @@ function isVue(obj) {
1421
1420
  return obj && isFunction(obj) && obj.name === "Vue";
1422
1421
  }
1423
1422
  function isVueRegistered(Vue) {
1424
- return vueConstructor && hasOwn$1(Vue, PluginInstalledFlag);
1423
+ return vueConstructor && hasOwn(Vue, PluginInstalledFlag);
1425
1424
  }
1426
1425
  function getVueConstructor() {
1427
1426
  return vueConstructor;
@@ -1569,12 +1568,12 @@ var accessModifiedSet = new WeakMap();
1569
1568
  var readonlySet = new WeakMap();
1570
1569
  function set$1(target, key, val) {
1571
1570
  var Vue = getVueConstructor();
1572
- var _a2 = Vue.util;
1573
- _a2.warn;
1574
- var defineReactive = _a2.defineReactive;
1571
+ var _a = Vue.util;
1572
+ _a.warn;
1573
+ var defineReactive = _a.defineReactive;
1575
1574
  var ob = target.__ob__;
1576
1575
  function ssrMockReactivity() {
1577
- if (ob && isObject(val) && !hasOwn$1(val, "__ob__")) {
1576
+ if (ob && isObject(val) && !hasOwn(val, "__ob__")) {
1578
1577
  mockReactivityDeep(val);
1579
1578
  }
1580
1579
  }
@@ -1609,8 +1608,8 @@ function set$1(target, key, val) {
1609
1608
  return val;
1610
1609
  }
1611
1610
  var RefImpl = function() {
1612
- function RefImpl2(_a2) {
1613
- var get2 = _a2.get, set2 = _a2.set;
1611
+ function RefImpl2(_a) {
1612
+ var get2 = _a.get, set2 = _a.set;
1614
1613
  proxy(this, "value", {
1615
1614
  get: get2,
1616
1615
  set: set2
@@ -1634,11 +1633,11 @@ function createRef(options, isReadonly, isComputed) {
1634
1633
  return sealed;
1635
1634
  }
1636
1635
  function ref(raw) {
1637
- var _a2;
1636
+ var _a;
1638
1637
  if (isRef(raw)) {
1639
1638
  return raw;
1640
1639
  }
1641
- var value = reactive((_a2 = {}, _a2[RefKey] = raw, _a2));
1640
+ var value = reactive((_a = {}, _a[RefKey] = raw, _a));
1642
1641
  return createRef({
1643
1642
  get: function() {
1644
1643
  return value[RefKey];
@@ -1676,12 +1675,12 @@ function toRef(object, key) {
1676
1675
  });
1677
1676
  }
1678
1677
  function isRaw(obj) {
1679
- var _a2;
1680
- return Boolean(obj && hasOwn$1(obj, "__ob__") && typeof obj.__ob__ === "object" && ((_a2 = obj.__ob__) === null || _a2 === void 0 ? void 0 : _a2.__raw__));
1678
+ var _a;
1679
+ return Boolean(obj && hasOwn(obj, "__ob__") && typeof obj.__ob__ === "object" && ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a.__raw__));
1681
1680
  }
1682
1681
  function isReactive(obj) {
1683
- var _a2;
1684
- return Boolean(obj && hasOwn$1(obj, "__ob__") && typeof obj.__ob__ === "object" && !((_a2 = obj.__ob__) === null || _a2 === void 0 ? void 0 : _a2.__raw__));
1682
+ var _a;
1683
+ return Boolean(obj && hasOwn(obj, "__ob__") && typeof obj.__ob__ === "object" && !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a.__raw__));
1685
1684
  }
1686
1685
  function setupAccessControl(target) {
1687
1686
  if (!isPlainObject(target) || isRaw(target) || isArray(target) || isRef(target) || isComponentInstance(target) || accessModifiedSet.has(target))
@@ -1748,17 +1747,17 @@ function observe(obj) {
1748
1747
  });
1749
1748
  observed = vm._data.$$state;
1750
1749
  }
1751
- if (!hasOwn$1(observed, "__ob__")) {
1750
+ if (!hasOwn(observed, "__ob__")) {
1752
1751
  mockReactivityDeep(observed);
1753
1752
  }
1754
1753
  return observed;
1755
1754
  }
1756
1755
  function mockReactivityDeep(obj, seen) {
1757
- var e_1, _a2;
1756
+ var e_1, _a;
1758
1757
  if (seen === void 0) {
1759
1758
  seen = new Set();
1760
1759
  }
1761
- if (seen.has(obj) || hasOwn$1(obj, "__ob__") || !Object.isExtensible(obj))
1760
+ if (seen.has(obj) || hasOwn(obj, "__ob__") || !Object.isExtensible(obj))
1762
1761
  return;
1763
1762
  def(obj, "__ob__", mockObserver(obj));
1764
1763
  seen.add(obj);
@@ -1775,8 +1774,8 @@ function mockReactivityDeep(obj, seen) {
1775
1774
  e_1 = { error: e_1_1 };
1776
1775
  } finally {
1777
1776
  try {
1778
- if (_c && !_c.done && (_a2 = _b.return))
1779
- _a2.call(_b);
1777
+ if (_c && !_c.done && (_a = _b.return))
1778
+ _a.call(_b);
1780
1779
  } finally {
1781
1780
  if (e_1)
1782
1781
  throw e_1.error;
@@ -1824,7 +1823,7 @@ var vmStateManager = {
1824
1823
  };
1825
1824
  function asVmProperty(vm, propName, propValue) {
1826
1825
  var props = vm.$options.props;
1827
- if (!(propName in vm) && !(props && hasOwn$1(props, propName))) {
1826
+ if (!(propName in vm) && !(props && hasOwn(props, propName))) {
1828
1827
  if (isRef(propValue)) {
1829
1828
  proxy(vm, propName, {
1830
1829
  get: function() {
@@ -1875,7 +1874,7 @@ function updateTemplateRef(vm) {
1875
1874
  vmStateManager.set(vm, "refs", validNewKeys);
1876
1875
  }
1877
1876
  function updateVmAttrs(vm, ctx) {
1878
- var e_1, _a2;
1877
+ var e_1, _a;
1879
1878
  if (!vm) {
1880
1879
  return;
1881
1880
  }
@@ -1897,7 +1896,7 @@ function updateVmAttrs(vm, ctx) {
1897
1896
  }
1898
1897
  var source = vm.$attrs;
1899
1898
  var _loop_1 = function(attr2) {
1900
- if (!hasOwn$1(attrBindings.data, attr2)) {
1899
+ if (!hasOwn(attrBindings.data, attr2)) {
1901
1900
  proxy(attrBindings.data, attr2, {
1902
1901
  get: function() {
1903
1902
  return vm.$attrs[attr2];
@@ -1914,8 +1913,8 @@ function updateVmAttrs(vm, ctx) {
1914
1913
  e_1 = { error: e_1_1 };
1915
1914
  } finally {
1916
1915
  try {
1917
- if (_c && !_c.done && (_a2 = _b.return))
1918
- _a2.call(_b);
1916
+ if (_c && !_c.done && (_a = _b.return))
1917
+ _a.call(_b);
1919
1918
  } finally {
1920
1919
  if (e_1)
1921
1920
  throw e_1.error;
@@ -1968,9 +1967,9 @@ function mixin(Vue) {
1968
1967
  updateVmAttrs(this);
1969
1968
  },
1970
1969
  updated: function() {
1971
- var _a2;
1970
+ var _a;
1972
1971
  updateTemplateRef(this);
1973
- if ((_a2 = this.$vnode) === null || _a2 === void 0 ? void 0 : _a2.context) {
1972
+ if ((_a = this.$vnode) === null || _a === void 0 ? void 0 : _a.context) {
1974
1973
  updateTemplateRef(this.$vnode.context);
1975
1974
  }
1976
1975
  }
@@ -2152,7 +2151,7 @@ function mergeData(from, to) {
2152
2151
  continue;
2153
2152
  toVal = to[key];
2154
2153
  fromVal = from[key];
2155
- if (!hasOwn$1(to, key)) {
2154
+ if (!hasOwn(to, key)) {
2156
2155
  to[key] = fromVal;
2157
2156
  } else if (toVal !== fromVal && isPlainObject(toVal) && !isRef(toVal) && isPlainObject(fromVal) && !isRef(fromVal)) {
2158
2157
  mergeData(fromVal, toVal);
@@ -2160,7 +2159,7 @@ function mergeData(from, to) {
2160
2159
  }
2161
2160
  return to;
2162
2161
  }
2163
- function install$1(Vue) {
2162
+ function install(Vue) {
2164
2163
  if (isVueRegistered(Vue)) {
2165
2164
  return;
2166
2165
  }
@@ -2174,7 +2173,7 @@ function install$1(Vue) {
2174
2173
  }
2175
2174
  var Plugin = {
2176
2175
  install: function(Vue) {
2177
- return install$1(Vue);
2176
+ return install(Vue);
2178
2177
  }
2179
2178
  };
2180
2179
  if (typeof window !== "undefined" && window.Vue) {
@@ -2207,12 +2206,7 @@ var __vue2_script$5 = defineComponent({
2207
2206
  },
2208
2207
  pagination: {
2209
2208
  type: Object,
2210
- required: true,
2211
- default: {
2212
- current: 0,
2213
- pageSize: 6,
2214
- total: 0
2215
- }
2209
+ required: true
2216
2210
  },
2217
2211
  noEdit: {
2218
2212
  type: Boolean,
@@ -2233,18 +2227,25 @@ var __vue2_script$5 = defineComponent({
2233
2227
  key: "taskName",
2234
2228
  scopedSlots: { customRender: "taskName" }
2235
2229
  },
2230
+ {
2231
+ title: t("message.assignee"),
2232
+ dataIndex: "isEmployee",
2233
+ key: "isEmployee",
2234
+ width: 120,
2235
+ scopedSlots: { customRender: "isEmployee" }
2236
+ },
2236
2237
  {
2237
2238
  title: t("message.tag"),
2238
2239
  dataIndex: "tagList",
2239
2240
  key: "tagList",
2240
- width: 250,
2241
+ width: 120,
2241
2242
  scopedSlots: { customRender: "tagList" }
2242
2243
  },
2243
2244
  {
2244
2245
  title: "Operation",
2245
2246
  dataIndex: "id",
2246
2247
  key: "id",
2247
- width: 225,
2248
+ width: 210,
2248
2249
  scopedSlots: { customRender: "operation" }
2249
2250
  }
2250
2251
  ];
@@ -2262,7 +2263,9 @@ var render$5 = function() {
2262
2263
  return _c("div", [_c("ant-table", { attrs: { "dataSource": _vm.dataSource, "rowKey": "id", "columns": _vm.columns, "pagination": _vm.pagination, "loading": _vm.loading }, on: { "change": function($event) {
2263
2264
  return _vm.$emit("changePagination", $event);
2264
2265
  } }, scopedSlots: _vm._u([{ key: "taskName", fn: function(text, record) {
2265
- return _c("span", {}, [_c("span", { staticStyle: { "display": "inline-block", "width": "250px" } }, [_vm._v(_vm._s(text))]), _c("assignee-tag", { attrs: { "assignee-type": record.isEmployee } })], 1);
2266
+ return _c("span", {}, [_c("span", { staticStyle: { "display": "inline-block", "width": "250px" } }, [_vm._v(_vm._s(text))])]);
2267
+ } }, { key: "isEmployee", fn: function(isEmployee) {
2268
+ return _c("span", {}, [_c("assignee-tag", { attrs: { "assignee-type": isEmployee } })], 1);
2266
2269
  } }, { key: "tagList", fn: function(tags) {
2267
2270
  return [_c("tags-with-tooltip", { attrs: { "tags": tags } })];
2268
2271
  } }, { key: "operation", fn: function(_, record) {
@@ -2278,7 +2281,7 @@ var render$5 = function() {
2278
2281
  var staticRenderFns$5 = [];
2279
2282
  var TaskTablePure_vue_vue_type_style_index_0_scoped_true_lang = "";
2280
2283
  const __cssModules$5 = {};
2281
- var __component__$5 = /* @__PURE__ */ normalizeComponent(__vue2_script$5, render$5, staticRenderFns$5, false, __vue2_injectStyles$5, "278e8b7a", null, null);
2284
+ var __component__$5 = /* @__PURE__ */ normalizeComponent(__vue2_script$5, render$5, staticRenderFns$5, false, __vue2_injectStyles$5, "cbdc9a40", null, null);
2282
2285
  function __vue2_injectStyles$5(context) {
2283
2286
  for (let o in __cssModules$5) {
2284
2287
  this[o] = __cssModules$5[o];
@@ -2290,12 +2293,18 @@ var TaskTablePure = /* @__PURE__ */ function() {
2290
2293
  var useSearchTaskTemplates = (pagination, conditions = ref$1({}), lawFirmId) => {
2291
2294
  const startIndex = computed(() => (pagination.value.current - 1) * pagination.value.pageSize);
2292
2295
  const endIndex = computed(() => startIndex.value + pagination.value.pageSize);
2296
+ watch(() => conditions.value, () => {
2297
+ pagination.value.current = 1;
2298
+ pagination.value.total = 0;
2299
+ });
2293
2300
  return useQuery(SearchTaskTemplatesQuery, () => ({
2294
2301
  query: {
2295
2302
  includeGallery: true,
2296
2303
  keywords: conditions.value.keywords || "",
2297
2304
  isEmployee: conditions.value.isEmployee,
2298
- taskTemplateId: conditions.value.taskTemplateId
2305
+ taskTemplateId: conditions.value.taskTemplateId,
2306
+ sortBy: TaskTemplateSortBy.name,
2307
+ sortOrder: SortOrder.asc
2299
2308
  },
2300
2309
  startIndex: startIndex.value,
2301
2310
  endIndex: endIndex.value,
@@ -2345,8 +2354,7 @@ var useTaskActions = (addedTasks, emit) => {
2345
2354
  const taskToAdd = {
2346
2355
  taskTemplateObj: record
2347
2356
  };
2348
- emit("update:tempTask", taskToAdd);
2349
- emit("update:newTaskVisible", true);
2357
+ emit("editTask", taskToAdd);
2350
2358
  };
2351
2359
  const removeTask = (record) => emit("update:addedTasks", addedTasks.value.filter(({ id }) => id !== record.id));
2352
2360
  return {
@@ -2366,18 +2374,18 @@ var useSearchTaskConditions = () => ref$1({
2366
2374
  var useTaskTemplateTableData = (props, emit) => {
2367
2375
  const initialPagination = ref$1({
2368
2376
  current: 1,
2369
- pageSize: 6,
2377
+ pageSize: props.pageSize || 10,
2370
2378
  total: 0
2371
2379
  });
2372
2380
  const { conditions = useSearchTaskConditions(), addedTasks = ref$1([]) } = toRefs$1(props);
2373
- const { result, loading, refetch } = useSearchTaskTemplates(initialPagination, conditions, props.lawFirmId);
2381
+ const { result, loading, variables } = useSearchTaskTemplates(initialPagination, conditions, props.lawFirmId);
2374
2382
  const dataSource = computed(() => {
2375
- var _a2;
2376
- return ((_a2 = result.value) == null ? void 0 : _a2.taskTemplateSearch.taskTemplateList) || [];
2383
+ var _a;
2384
+ return ((_a = result.value) == null ? void 0 : _a.taskTemplateSearch.taskTemplateList) || [];
2377
2385
  });
2378
2386
  const total = computed(() => {
2379
- var _a2;
2380
- return ((_a2 = result.value) == null ? void 0 : _a2.taskTemplateSearch.numResult) || 0;
2387
+ var _a;
2388
+ return ((_a = result.value) == null ? void 0 : _a.taskTemplateSearch.numResult) || 0;
2381
2389
  });
2382
2390
  const pagination = computed(() => __spreadProps(__spreadValues({}, initialPagination.value), {
2383
2391
  total: total.value
@@ -2395,9 +2403,9 @@ var useTaskTemplateTableData = (props, emit) => {
2395
2403
  dataSource,
2396
2404
  result,
2397
2405
  loading,
2398
- refetch,
2399
2406
  conditions,
2400
- addedTasks
2407
+ addedTasks,
2408
+ variables
2401
2409
  };
2402
2410
  };
2403
2411
  var __vue2_script$4 = defineComponent({
@@ -2417,14 +2425,17 @@ var __vue2_script$4 = defineComponent({
2417
2425
  lawFirmId: {
2418
2426
  type: Number,
2419
2427
  required: true
2428
+ },
2429
+ pageSize: {
2430
+ type: Number
2420
2431
  }
2421
2432
  },
2422
2433
  setup(props, { emit }) {
2423
2434
  const {
2424
2435
  loading,
2425
- refetch,
2426
2436
  dataSource,
2427
2437
  pagination,
2438
+ variables,
2428
2439
  changePagination,
2429
2440
  addTask,
2430
2441
  editTask,
@@ -2432,14 +2443,14 @@ var __vue2_script$4 = defineComponent({
2432
2443
  } = useTaskTemplateTableData(props, emit);
2433
2444
  return {
2434
2445
  loading,
2435
- refetch,
2436
2446
  dataSource,
2437
2447
  pagination,
2438
2448
  AssigneeTypesText,
2439
2449
  changePagination,
2440
2450
  addTask,
2441
2451
  editTask,
2442
- removeTask
2452
+ removeTask,
2453
+ variables
2443
2454
  };
2444
2455
  }
2445
2456
  });
@@ -2454,7 +2465,7 @@ var render$4 = function() {
2454
2465
  var staticRenderFns$4 = [];
2455
2466
  var TaskTable_vue_vue_type_style_index_0_scoped_true_lang = "";
2456
2467
  const __cssModules$4 = {};
2457
- var __component__$4 = /* @__PURE__ */ normalizeComponent(__vue2_script$4, render$4, staticRenderFns$4, false, __vue2_injectStyles$4, "5c367cce", null, null);
2468
+ var __component__$4 = /* @__PURE__ */ normalizeComponent(__vue2_script$4, render$4, staticRenderFns$4, false, __vue2_injectStyles$4, "7b828978", null, null);
2458
2469
  function __vue2_injectStyles$4(context) {
2459
2470
  for (let o in __cssModules$4) {
2460
2471
  this[o] = __cssModules$4[o];
@@ -2477,31 +2488,38 @@ var __vue2_script$3 = defineComponent({
2477
2488
  default: false
2478
2489
  },
2479
2490
  addedTasks: {
2480
- type: Array,
2481
- required: true
2491
+ type: Array
2482
2492
  },
2483
2493
  lawFirmId: {
2484
2494
  type: Number,
2485
2495
  required: true
2486
2496
  },
2487
2497
  taskSettingPageUrl: {
2488
- type: String,
2489
- required: true
2498
+ type: String
2490
2499
  },
2491
2500
  showPage: {
2492
2501
  type: Boolean,
2493
2502
  default: false
2503
+ },
2504
+ pageSize: {
2505
+ type: Number
2506
+ },
2507
+ openReviewButtonText: {
2508
+ type: String,
2509
+ default: "Review and add to template"
2494
2510
  }
2495
2511
  },
2496
2512
  setup(props, { emit }) {
2497
- const taskTable = ref$1(null);
2513
+ const taskTable = ref$1();
2498
2514
  const conditions = useSearchTaskConditions();
2499
2515
  const currentComponent = shallowRef(props.showPage ? Card : Modal);
2500
2516
  const editAction = (record) => {
2501
- emit("edit", record);
2517
+ emit("editTask", record);
2502
2518
  };
2519
+ const getVariables = () => taskTable.value.variables;
2503
2520
  return {
2504
2521
  editAction,
2522
+ getVariables,
2505
2523
  taskTable,
2506
2524
  conditions,
2507
2525
  AssigneeTypes,
@@ -2520,17 +2538,15 @@ var render$3 = function() {
2520
2538
  return _vm.$emit("update:visible", false);
2521
2539
  } } }, [_vm._v("Cancel ")]), _c("ant-badge", { attrs: { "count": _vm.addedTasks.length } }, [_c("ant-button", { attrs: { "disabled": _vm.addedTasks.length === 0, "type": "primary" }, on: { "click": function($event) {
2522
2540
  return _vm.$emit("update:reviewModalVisible", true);
2523
- } } }, [_vm._v(" " + _vm._s(_vm.$t("message.reviewTasks")) + " ")])], 1)];
2541
+ } } }, [_vm._v(" " + _vm._s(_vm.openReviewButtonText) + " ")])], 1)];
2524
2542
  }, proxy: true }]) }, [_c("task-template-filter", { attrs: { "show-task-home-page-link": true, "task-setting-page-url": _vm.taskSettingPageUrl, "conditions": _vm.conditions, "inline": !!_vm.showPage }, on: { "update:conditions": function($event) {
2525
2543
  _vm.conditions = $event;
2526
2544
  }, "update:newTaskVisible": function($event) {
2527
2545
  return _vm.$emit("update:newTaskVisible", true);
2528
- } } }), _c("task-table", { ref: "taskTable", attrs: { "conditions": _vm.conditions, "added-tasks": _vm.addedTasks, "law-firm-id": _vm.lawFirmId }, on: { "update:addedTasks": function($event) {
2546
+ } } }), _c("task-table", { ref: "taskTable", attrs: { "conditions": _vm.conditions, "added-tasks": _vm.addedTasks, "law-firm-id": _vm.lawFirmId, "page-size": _vm.pageSize }, on: { "update:addedTasks": function($event) {
2529
2547
  return _vm.$emit("update:addedTasks", $event);
2530
- }, "update:tempTask": function($event) {
2531
- return _vm.$emit("update:tempTask", $event);
2532
- }, "update:newTaskVisible": function($event) {
2533
- return _vm.$emit("update:newTaskVisible", $event);
2548
+ }, "editTask": function($event) {
2549
+ return _vm.$emit("editTask", $event);
2534
2550
  } }, scopedSlots: _vm._u([{ key: "default", fn: function(ref2) {
2535
2551
  var loading = ref2.loading;
2536
2552
  var dataSource = ref2.dataSource;
@@ -2542,7 +2558,7 @@ var render$3 = function() {
2542
2558
  var staticRenderFns$3 = [];
2543
2559
  var MainModal_vue_vue_type_style_index_0_scoped_true_lang = "";
2544
2560
  const __cssModules$3 = {};
2545
- var __component__$3 = /* @__PURE__ */ normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "23ce399e", null, null);
2561
+ var __component__$3 = /* @__PURE__ */ normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "b2f78f98", null, null);
2546
2562
  function __vue2_injectStyles$3(context) {
2547
2563
  for (let o in __cssModules$3) {
2548
2564
  this[o] = __cssModules$3[o];
@@ -2594,7 +2610,7 @@ var __vue2_script$2 = defineComponent({
2594
2610
  const pagination = ref$1({
2595
2611
  total: addedTasks.value.length,
2596
2612
  current: 1,
2597
- pageSize: 6
2613
+ pageSize: 10
2598
2614
  });
2599
2615
  const changePagination = (newPagination) => {
2600
2616
  pagination.value = newPagination;
@@ -2633,7 +2649,7 @@ var render$2 = function() {
2633
2649
  var staticRenderFns$2 = [];
2634
2650
  var ReviewModal_vue_vue_type_style_index_0_scoped_true_lang = "";
2635
2651
  const __cssModules$2 = {};
2636
- var __component__$2 = /* @__PURE__ */ normalizeComponent(__vue2_script$2, render$2, staticRenderFns$2, false, __vue2_injectStyles$2, "3f8e3a92", null, null);
2652
+ var __component__$2 = /* @__PURE__ */ normalizeComponent(__vue2_script$2, render$2, staticRenderFns$2, false, __vue2_injectStyles$2, "09e3f3ca", null, null);
2637
2653
  function __vue2_injectStyles$2(context) {
2638
2654
  for (let o in __cssModules$2) {
2639
2655
  this[o] = __cssModules$2[o];
@@ -2645,14 +2661,14 @@ var ReviewModal = /* @__PURE__ */ function() {
2645
2661
  const useMutateTaskTemplate = () => useMutation(UpdateTaskTemplateMutation);
2646
2662
  const useCreateTaskTemplate = () => useMutation(CreateTaskTemplateMutation);
2647
2663
  const submit = async (record, updateTemplate, createTemplate) => {
2648
- var _a2, _b, _c, _d;
2664
+ var _a, _b, _c, _d;
2649
2665
  let newRecord = {};
2650
2666
  let res;
2651
2667
  let success;
2652
2668
  const isUpdate = !!record.taskTemplateId;
2653
2669
  if (isUpdate) {
2654
2670
  res = await updateTemplate.mutate(record);
2655
- newRecord = ((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.updateTaskTemplate.updatedTaskTemplate) || {};
2671
+ newRecord = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.updateTaskTemplate.updatedTaskTemplate) || {};
2656
2672
  success = ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.updateTaskTemplate.code) === ResponseCode.success;
2657
2673
  } else {
2658
2674
  res = await createTemplate.mutate(record);
@@ -2712,3743 +2728,157 @@ const CreateTaskTemplateMutation = gql`
2712
2728
  }
2713
2729
  ${taskTemplateFragment}
2714
2730
  `;
2715
- /*! *****************************************************************************
2716
- Copyright (c) Microsoft Corporation.
2717
-
2718
- Permission to use, copy, modify, and/or distribute this software for any
2719
- purpose with or without fee is hereby granted.
2720
-
2721
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2722
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2723
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2724
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2725
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2726
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2727
- PERFORMANCE OF THIS SOFTWARE.
2728
- ***************************************************************************** */
2729
- var extendStatics = function(d, b) {
2730
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2731
- d2.__proto__ = b2;
2732
- } || function(d2, b2) {
2733
- for (var p in b2)
2734
- if (Object.prototype.hasOwnProperty.call(b2, p))
2735
- d2[p] = b2[p];
2736
- };
2737
- return extendStatics(d, b);
2738
- };
2739
- function __extends(d, b) {
2740
- if (typeof b !== "function" && b !== null)
2741
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2742
- extendStatics(d, b);
2743
- function __2() {
2744
- this.constructor = d;
2745
- }
2746
- d.prototype = b === null ? Object.create(b) : (__2.prototype = b.prototype, new __2());
2747
- }
2748
- var __assign = function() {
2749
- __assign = Object.assign || function __assign2(t) {
2750
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2751
- s = arguments[i];
2752
- for (var p in s)
2753
- if (Object.prototype.hasOwnProperty.call(s, p))
2754
- t[p] = s[p];
2755
- }
2756
- return t;
2757
- };
2758
- return __assign.apply(this, arguments);
2731
+ const defaultTaskTemplate = {
2732
+ taskTemplateObj: {},
2733
+ isAddedToTask: false,
2734
+ isNotified: false
2759
2735
  };
2760
- function __rest(s, e) {
2761
- var t = {};
2762
- for (var p in s)
2763
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2764
- t[p] = s[p];
2765
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
2766
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2767
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2768
- t[p[i]] = s[p[i]];
2736
+ var __vue2_script$1 = defineComponent({
2737
+ name: "index",
2738
+ components: {
2739
+ NewTask,
2740
+ MainModal,
2741
+ ReviewModal
2742
+ },
2743
+ props: {
2744
+ uploadFilesFunc: {
2745
+ type: Function,
2746
+ required: true
2747
+ },
2748
+ visible: {
2749
+ type: Boolean,
2750
+ default: false
2751
+ },
2752
+ userId: {
2753
+ type: String,
2754
+ required: true
2755
+ },
2756
+ lawFirmId: {
2757
+ type: Number,
2758
+ required: true
2759
+ },
2760
+ value: {
2761
+ type: Array,
2762
+ default: () => []
2763
+ },
2764
+ reviewText: {
2765
+ type: String,
2766
+ default: "Add"
2767
+ },
2768
+ openReviewButtonText: {
2769
+ type: String,
2770
+ default: "Review and add to template"
2771
+ },
2772
+ showSendEmail: {
2773
+ type: Boolean,
2774
+ default: false
2775
+ },
2776
+ sendEmail: {
2777
+ type: Boolean,
2778
+ default: false
2779
+ },
2780
+ taskSettingPageUrl: {
2781
+ type: String
2782
+ },
2783
+ allowClear: {
2784
+ type: Boolean,
2785
+ default: false
2786
+ },
2787
+ pageMode: {
2788
+ type: Boolean,
2789
+ default: false
2790
+ },
2791
+ pageSize: {
2792
+ type: Number
2769
2793
  }
2770
- return t;
2771
- }
2772
- function __spreadArray(to, from, pack) {
2773
- if (pack || arguments.length === 2)
2774
- for (var i = 0, l = from.length, ar; i < l; i++) {
2775
- if (ar || !(i in from)) {
2776
- if (!ar)
2777
- ar = Array.prototype.slice.call(from, 0, i);
2778
- ar[i] = from[i];
2794
+ },
2795
+ setup(props, { emit }) {
2796
+ const { client } = useApolloClient();
2797
+ const mainModal = ref$1();
2798
+ const reviewModal = ref$1();
2799
+ const newTaskVisible = ref$1(false);
2800
+ const reviewModalVisible = ref$1(false);
2801
+ const tempTask = ref$1(defaultTaskTemplate);
2802
+ const updateTemplate = useMutateTaskTemplate();
2803
+ const createTemplate = useCreateTaskTemplate();
2804
+ const addedTasks = ref$1([]);
2805
+ watch(() => newTaskVisible.value, (visible) => {
2806
+ if (!visible) {
2807
+ tempTask.value = defaultTaskTemplate;
2779
2808
  }
2780
- }
2781
- return to.concat(ar || Array.prototype.slice.call(from));
2782
- }
2783
- var genericMessage = "Invariant Violation";
2784
- var _a$3 = Object.setPrototypeOf, setPrototypeOf = _a$3 === void 0 ? function(obj, proto) {
2785
- obj.__proto__ = proto;
2786
- return obj;
2787
- } : _a$3;
2788
- var InvariantError = function(_super) {
2789
- __extends(InvariantError2, _super);
2790
- function InvariantError2(message2) {
2791
- if (message2 === void 0) {
2792
- message2 = genericMessage;
2793
- }
2794
- var _this = _super.call(this, typeof message2 === "number" ? genericMessage + ": " + message2 + " (see https://github.com/apollographql/invariant-packages)" : message2) || this;
2795
- _this.framesToPop = 1;
2796
- _this.name = genericMessage;
2797
- setPrototypeOf(_this, InvariantError2.prototype);
2798
- return _this;
2799
- }
2800
- return InvariantError2;
2801
- }(Error);
2802
- function invariant(condition, message2) {
2803
- if (!condition) {
2804
- throw new InvariantError(message2);
2805
- }
2806
- }
2807
- var verbosityLevels = ["debug", "log", "warn", "error", "silent"];
2808
- var verbosityLevel = verbosityLevels.indexOf("log");
2809
- function wrapConsoleMethod(name) {
2810
- return function() {
2811
- if (verbosityLevels.indexOf(name) >= verbosityLevel) {
2812
- var method = console[name] || console.log;
2813
- return method.apply(console, arguments);
2814
- }
2815
- };
2816
- }
2817
- (function(invariant2) {
2818
- invariant2.debug = wrapConsoleMethod("debug");
2819
- invariant2.log = wrapConsoleMethod("log");
2820
- invariant2.warn = wrapConsoleMethod("warn");
2821
- invariant2.error = wrapConsoleMethod("error");
2822
- })(invariant || (invariant = {}));
2823
- function maybe$1(thunk) {
2824
- try {
2825
- return thunk();
2826
- } catch (_a2) {
2827
- }
2828
- }
2829
- var global$1 = maybe$1(function() {
2830
- return globalThis;
2831
- }) || maybe$1(function() {
2832
- return window;
2833
- }) || maybe$1(function() {
2834
- return self;
2835
- }) || maybe$1(function() {
2836
- return global;
2837
- }) || maybe$1(function() {
2838
- return maybe$1.constructor("return this")();
2839
- });
2840
- var __ = "__";
2841
- var GLOBAL_KEY = [__, __].join("DEV");
2842
- function getDEV() {
2843
- try {
2844
- return Boolean(__DEV__);
2845
- } catch (_a2) {
2846
- Object.defineProperty(global$1, GLOBAL_KEY, {
2847
- value: maybe$1(function() {
2848
- return "production";
2849
- }) !== "production",
2850
- enumerable: false,
2851
- configurable: true,
2852
- writable: true
2853
- });
2854
- return global$1[GLOBAL_KEY];
2855
- }
2856
- }
2857
- var DEV = getDEV();
2858
- function maybe(thunk) {
2859
- try {
2860
- return thunk();
2861
- } catch (_) {
2862
- }
2863
- }
2864
- var safeGlobal = maybe(function() {
2865
- return globalThis;
2866
- }) || maybe(function() {
2867
- return window;
2868
- }) || maybe(function() {
2869
- return self;
2870
- }) || maybe(function() {
2871
- return global;
2872
- }) || maybe(function() {
2873
- return maybe.constructor("return this")();
2874
- });
2875
- var needToRemove = false;
2876
- function install() {
2877
- if (safeGlobal && !maybe(function() {
2878
- return "production";
2879
- }) && !maybe(function() {
2880
- return process;
2881
- })) {
2882
- Object.defineProperty(safeGlobal, "process", {
2883
- value: {
2884
- env: {
2885
- NODE_ENV: "production"
2886
- }
2887
- },
2888
- configurable: true,
2889
- enumerable: false,
2890
- writable: true
2891
- });
2892
- needToRemove = true;
2893
- }
2894
- }
2895
- install();
2896
- function remove() {
2897
- if (needToRemove) {
2898
- delete safeGlobal.process;
2899
- needToRemove = false;
2900
- }
2901
- }
2902
- function removeTemporaryGlobals() {
2903
- return typeof Source === "function" ? remove() : remove();
2904
- }
2905
- function checkDEV() {
2906
- __DEV__ ? invariant(typeof DEV === "boolean", DEV) : invariant(typeof DEV === "boolean", 36);
2907
- }
2908
- removeTemporaryGlobals();
2909
- checkDEV();
2910
- function shouldInclude(_a2, variables) {
2911
- var directives = _a2.directives;
2912
- if (!directives || !directives.length) {
2913
- return true;
2914
- }
2915
- return getInclusionDirectives(directives).every(function(_a3) {
2916
- var directive = _a3.directive, ifArgument = _a3.ifArgument;
2917
- var evaledValue = false;
2918
- if (ifArgument.value.kind === "Variable") {
2919
- evaledValue = variables && variables[ifArgument.value.name.value];
2920
- __DEV__ ? invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : invariant(evaledValue !== void 0, 37);
2921
- } else {
2922
- evaledValue = ifArgument.value.value;
2923
- }
2924
- return directive.name.value === "skip" ? !evaledValue : evaledValue;
2925
- });
2926
- }
2927
- function isInclusionDirective(_a2) {
2928
- var value = _a2.name.value;
2929
- return value === "skip" || value === "include";
2930
- }
2931
- function getInclusionDirectives(directives) {
2932
- var result = [];
2933
- if (directives && directives.length) {
2934
- directives.forEach(function(directive) {
2935
- if (!isInclusionDirective(directive))
2936
- return;
2937
- var directiveArguments = directive.arguments;
2938
- var directiveName = directive.name.value;
2939
- __DEV__ ? invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : invariant(directiveArguments && directiveArguments.length === 1, 38);
2940
- var ifArgument = directiveArguments[0];
2941
- __DEV__ ? invariant(ifArgument.name && ifArgument.name.value === "if", "Invalid argument for the @".concat(directiveName, " directive.")) : invariant(ifArgument.name && ifArgument.name.value === "if", 39);
2942
- var ifValue = ifArgument.value;
2943
- __DEV__ ? invariant(ifValue && (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : invariant(ifValue && (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 40);
2944
- result.push({ directive, ifArgument });
2945
2809
  });
2946
- }
2947
- return result;
2948
- }
2949
- function getFragmentQueryDocument(document, fragmentName) {
2950
- var actualFragmentName = fragmentName;
2951
- var fragments = [];
2952
- document.definitions.forEach(function(definition) {
2953
- if (definition.kind === "OperationDefinition") {
2954
- throw __DEV__ ? new InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : "", ". ") + "No operations are allowed when using a fragment as a query. Only fragments are allowed.") : new InvariantError(41);
2955
- }
2956
- if (definition.kind === "FragmentDefinition") {
2957
- fragments.push(definition);
2958
- }
2959
- });
2960
- if (typeof actualFragmentName === "undefined") {
2961
- __DEV__ ? invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : invariant(fragments.length === 1, 42);
2962
- actualFragmentName = fragments[0].name.value;
2963
- }
2964
- var query = __assign(__assign({}, document), { definitions: __spreadArray([
2965
- {
2966
- kind: "OperationDefinition",
2967
- operation: "query",
2968
- selectionSet: {
2969
- kind: "SelectionSet",
2970
- selections: [
2971
- {
2972
- kind: "FragmentSpread",
2973
- name: {
2974
- kind: "Name",
2975
- value: actualFragmentName
2976
- }
2810
+ const updateReviewModalContent = (record, newRecord) => {
2811
+ if (reviewModalVisible.value) {
2812
+ const newValue = addedTasks.value.map((originTask) => {
2813
+ if (originTask.id === record.taskTemplateId) {
2814
+ return newRecord;
2977
2815
  }
2978
- ]
2979
- }
2980
- }
2981
- ], document.definitions, true) });
2982
- return query;
2983
- }
2984
- function createFragmentMap(fragments) {
2985
- if (fragments === void 0) {
2986
- fragments = [];
2987
- }
2988
- var symTable = {};
2989
- fragments.forEach(function(fragment) {
2990
- symTable[fragment.name.value] = fragment;
2991
- });
2992
- return symTable;
2993
- }
2994
- function getFragmentFromSelection(selection, fragmentMap) {
2995
- switch (selection.kind) {
2996
- case "InlineFragment":
2997
- return selection;
2998
- case "FragmentSpread": {
2999
- var fragment = fragmentMap && fragmentMap[selection.name.value];
3000
- __DEV__ ? invariant(fragment, "No fragment named ".concat(selection.name.value, ".")) : invariant(fragment, 43);
3001
- return fragment;
3002
- }
3003
- default:
3004
- return null;
3005
- }
3006
- }
3007
- function isNonNullObject(obj) {
3008
- return obj !== null && typeof obj === "object";
3009
- }
3010
- function makeReference(id) {
3011
- return { __ref: String(id) };
3012
- }
3013
- function isReference(obj) {
3014
- return Boolean(obj && typeof obj === "object" && typeof obj.__ref === "string");
3015
- }
3016
- function isStringValue(value) {
3017
- return value.kind === "StringValue";
3018
- }
3019
- function isBooleanValue(value) {
3020
- return value.kind === "BooleanValue";
3021
- }
3022
- function isIntValue(value) {
3023
- return value.kind === "IntValue";
3024
- }
3025
- function isFloatValue(value) {
3026
- return value.kind === "FloatValue";
3027
- }
3028
- function isVariable(value) {
3029
- return value.kind === "Variable";
3030
- }
3031
- function isObjectValue(value) {
3032
- return value.kind === "ObjectValue";
3033
- }
3034
- function isListValue(value) {
3035
- return value.kind === "ListValue";
3036
- }
3037
- function isEnumValue(value) {
3038
- return value.kind === "EnumValue";
3039
- }
3040
- function isNullValue(value) {
3041
- return value.kind === "NullValue";
3042
- }
3043
- function valueToObjectRepresentation(argObj, name, value, variables) {
3044
- if (isIntValue(value) || isFloatValue(value)) {
3045
- argObj[name.value] = Number(value.value);
3046
- } else if (isBooleanValue(value) || isStringValue(value)) {
3047
- argObj[name.value] = value.value;
3048
- } else if (isObjectValue(value)) {
3049
- var nestedArgObj_1 = {};
3050
- value.fields.map(function(obj) {
3051
- return valueToObjectRepresentation(nestedArgObj_1, obj.name, obj.value, variables);
3052
- });
3053
- argObj[name.value] = nestedArgObj_1;
3054
- } else if (isVariable(value)) {
3055
- var variableValue = (variables || {})[value.name.value];
3056
- argObj[name.value] = variableValue;
3057
- } else if (isListValue(value)) {
3058
- argObj[name.value] = value.values.map(function(listValue) {
3059
- var nestedArgArrayObj = {};
3060
- valueToObjectRepresentation(nestedArgArrayObj, name, listValue, variables);
3061
- return nestedArgArrayObj[name.value];
3062
- });
3063
- } else if (isEnumValue(value)) {
3064
- argObj[name.value] = value.value;
3065
- } else if (isNullValue(value)) {
3066
- argObj[name.value] = null;
3067
- } else {
3068
- throw __DEV__ ? new InvariantError('The inline argument "'.concat(name.value, '" of kind "').concat(value.kind, '"') + "is not supported. Use variables instead of inline arguments to overcome this limitation.") : new InvariantError(52);
3069
- }
3070
- }
3071
- function storeKeyNameFromField(field, variables) {
3072
- var directivesObj = null;
3073
- if (field.directives) {
3074
- directivesObj = {};
3075
- field.directives.forEach(function(directive) {
3076
- directivesObj[directive.name.value] = {};
3077
- if (directive.arguments) {
3078
- directive.arguments.forEach(function(_a2) {
3079
- var name = _a2.name, value = _a2.value;
3080
- return valueToObjectRepresentation(directivesObj[directive.name.value], name, value, variables);
2816
+ return originTask;
3081
2817
  });
2818
+ emit("update:value", newValue.map(({ id }) => id));
3082
2819
  }
3083
- });
3084
- }
3085
- var argObj = null;
3086
- if (field.arguments && field.arguments.length) {
3087
- argObj = {};
3088
- field.arguments.forEach(function(_a2) {
3089
- var name = _a2.name, value = _a2.value;
3090
- return valueToObjectRepresentation(argObj, name, value, variables);
3091
- });
3092
- }
3093
- return getStoreKeyName(field.name.value, argObj, directivesObj);
3094
- }
3095
- var KNOWN_DIRECTIVES = [
3096
- "connection",
3097
- "include",
3098
- "skip",
3099
- "client",
3100
- "rest",
3101
- "export"
3102
- ];
3103
- var getStoreKeyName = Object.assign(function(fieldName, args, directives) {
3104
- if (args && directives && directives["connection"] && directives["connection"]["key"]) {
3105
- if (directives["connection"]["filter"] && directives["connection"]["filter"].length > 0) {
3106
- var filterKeys = directives["connection"]["filter"] ? directives["connection"]["filter"] : [];
3107
- filterKeys.sort();
3108
- var filteredArgs_1 = {};
3109
- filterKeys.forEach(function(key) {
3110
- filteredArgs_1[key] = args[key];
2820
+ };
2821
+ const _submit = async (record) => {
2822
+ const variables = mainModal.value.getVariables();
2823
+ const existed = client.readQuery({
2824
+ query: SearchTaskTemplatesQuery,
2825
+ variables
3111
2826
  });
3112
- return "".concat(directives["connection"]["key"], "(").concat(stringify(filteredArgs_1), ")");
3113
- } else {
3114
- return directives["connection"]["key"];
3115
- }
3116
- }
3117
- var completeFieldName = fieldName;
3118
- if (args) {
3119
- var stringifiedArgs = stringify(args);
3120
- completeFieldName += "(".concat(stringifiedArgs, ")");
3121
- }
3122
- if (directives) {
3123
- Object.keys(directives).forEach(function(key) {
3124
- if (KNOWN_DIRECTIVES.indexOf(key) !== -1)
3125
- return;
3126
- if (directives[key] && Object.keys(directives[key]).length) {
3127
- completeFieldName += "@".concat(key, "(").concat(stringify(directives[key]), ")");
3128
- } else {
3129
- completeFieldName += "@".concat(key);
2827
+ const {
2828
+ newRecord,
2829
+ success
2830
+ } = await submit(record, updateTemplate, createTemplate);
2831
+ if (success) {
2832
+ client.writeQuery({
2833
+ query: SearchTaskTemplatesQuery,
2834
+ data: {
2835
+ taskTemplateSearch: __spreadProps(__spreadValues({}, existed.taskTemplateSearch), {
2836
+ taskTemplateList: existed.taskTemplateSearch.taskTemplateList.map((record2) => {
2837
+ if (record2.id === newRecord.id) {
2838
+ return __spreadProps(__spreadValues({}, newRecord), {
2839
+ isGallery: record2.isGallery
2840
+ });
2841
+ }
2842
+ return record2;
2843
+ })
2844
+ })
2845
+ },
2846
+ variables
2847
+ });
2848
+ newTaskVisible.value = false;
2849
+ updateReviewModalContent(record, newRecord);
3130
2850
  }
3131
- });
3132
- }
3133
- return completeFieldName;
3134
- }, {
3135
- setStringify: function(s) {
3136
- var previous = stringify;
3137
- stringify = s;
3138
- return previous;
3139
- }
3140
- });
3141
- var stringify = function defaultStringify(value) {
3142
- return JSON.stringify(value, stringifyReplacer);
3143
- };
3144
- function stringifyReplacer(_key, value) {
3145
- if (isNonNullObject(value) && !Array.isArray(value)) {
3146
- value = Object.keys(value).sort().reduce(function(copy, key) {
3147
- copy[key] = value[key];
3148
- return copy;
3149
- }, {});
3150
- }
3151
- return value;
3152
- }
3153
- function argumentsObjectFromField(field, variables) {
3154
- if (field.arguments && field.arguments.length) {
3155
- var argObj_1 = {};
3156
- field.arguments.forEach(function(_a2) {
3157
- var name = _a2.name, value = _a2.value;
3158
- return valueToObjectRepresentation(argObj_1, name, value, variables);
3159
- });
3160
- return argObj_1;
3161
- }
3162
- return null;
3163
- }
3164
- function resultKeyNameFromField(field) {
3165
- return field.alias ? field.alias.value : field.name.value;
3166
- }
3167
- function getTypenameFromResult(result, selectionSet, fragmentMap) {
3168
- if (typeof result.__typename === "string") {
3169
- return result.__typename;
3170
- }
3171
- for (var _i = 0, _a2 = selectionSet.selections; _i < _a2.length; _i++) {
3172
- var selection = _a2[_i];
3173
- if (isField(selection)) {
3174
- if (selection.name.value === "__typename") {
3175
- return result[resultKeyNameFromField(selection)];
3176
- }
3177
- } else {
3178
- var typename = getTypenameFromResult(result, getFragmentFromSelection(selection, fragmentMap).selectionSet, fragmentMap);
3179
- if (typeof typename === "string") {
3180
- return typename;
3181
- }
3182
- }
3183
- }
3184
- }
3185
- function isField(selection) {
3186
- return selection.kind === "Field";
3187
- }
3188
- function checkDocument(doc) {
3189
- __DEV__ ? invariant(doc && doc.kind === "Document", 'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql') : invariant(doc && doc.kind === "Document", 44);
3190
- var operations = doc.definitions.filter(function(d) {
3191
- return d.kind !== "FragmentDefinition";
3192
- }).map(function(definition) {
3193
- if (definition.kind !== "OperationDefinition") {
3194
- throw __DEV__ ? new InvariantError('Schema type definitions not allowed in queries. Found: "'.concat(definition.kind, '"')) : new InvariantError(45);
3195
- }
3196
- return definition;
3197
- });
3198
- __DEV__ ? invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : invariant(operations.length <= 1, 46);
3199
- return doc;
3200
- }
3201
- function getOperationDefinition(doc) {
3202
- checkDocument(doc);
3203
- return doc.definitions.filter(function(definition) {
3204
- return definition.kind === "OperationDefinition";
3205
- })[0];
3206
- }
3207
- function getFragmentDefinitions(doc) {
3208
- return doc.definitions.filter(function(definition) {
3209
- return definition.kind === "FragmentDefinition";
3210
- });
3211
- }
3212
- function getQueryDefinition(doc) {
3213
- var queryDef = getOperationDefinition(doc);
3214
- __DEV__ ? invariant(queryDef && queryDef.operation === "query", "Must contain a query definition.") : invariant(queryDef && queryDef.operation === "query", 47);
3215
- return queryDef;
3216
- }
3217
- function getMainDefinition(queryDoc) {
3218
- checkDocument(queryDoc);
3219
- var fragmentDefinition;
3220
- for (var _i = 0, _a2 = queryDoc.definitions; _i < _a2.length; _i++) {
3221
- var definition = _a2[_i];
3222
- if (definition.kind === "OperationDefinition") {
3223
- var operation = definition.operation;
3224
- if (operation === "query" || operation === "mutation" || operation === "subscription") {
3225
- return definition;
3226
- }
3227
- }
3228
- if (definition.kind === "FragmentDefinition" && !fragmentDefinition) {
3229
- fragmentDefinition = definition;
3230
- }
3231
- }
3232
- if (fragmentDefinition) {
3233
- return fragmentDefinition;
3234
- }
3235
- throw __DEV__ ? new InvariantError("Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.") : new InvariantError(51);
3236
- }
3237
- function getDefaultValues(definition) {
3238
- var defaultValues = Object.create(null);
3239
- var defs = definition && definition.variableDefinitions;
3240
- if (defs && defs.length) {
3241
- defs.forEach(function(def2) {
3242
- if (def2.defaultValue) {
3243
- valueToObjectRepresentation(defaultValues, def2.variable.name, def2.defaultValue);
3244
- }
3245
- });
3246
- }
3247
- return defaultValues;
3248
- }
3249
- var TYPENAME_FIELD = {
3250
- kind: "Field",
3251
- name: {
3252
- kind: "Name",
3253
- value: "__typename"
3254
- }
3255
- };
3256
- var addTypenameToDocument = Object.assign(function(doc) {
3257
- return visit(checkDocument(doc), {
3258
- SelectionSet: {
3259
- enter: function(node, _key, parent) {
3260
- if (parent && parent.kind === "OperationDefinition") {
3261
- return;
3262
- }
3263
- var selections = node.selections;
3264
- if (!selections) {
3265
- return;
3266
- }
3267
- var skip = selections.some(function(selection) {
3268
- return isField(selection) && (selection.name.value === "__typename" || selection.name.value.lastIndexOf("__", 0) === 0);
3269
- });
3270
- if (skip) {
3271
- return;
3272
- }
3273
- var field = parent;
3274
- if (isField(field) && field.directives && field.directives.some(function(d) {
3275
- return d.name.value === "export";
3276
- })) {
3277
- return;
3278
- }
3279
- return __assign(__assign({}, node), { selections: __spreadArray(__spreadArray([], selections, true), [TYPENAME_FIELD], false) });
3280
- }
3281
- }
3282
- });
3283
- }, {
3284
- added: function(field) {
3285
- return field === TYPENAME_FIELD;
3286
- }
3287
- });
3288
- var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
3289
- var defaultReconciler = function(target, source, property) {
3290
- return this.merge(target[property], source[property]);
3291
- };
3292
- var DeepMerger = function() {
3293
- function DeepMerger2(reconciler) {
3294
- if (reconciler === void 0) {
3295
- reconciler = defaultReconciler;
3296
- }
3297
- this.reconciler = reconciler;
3298
- this.isObject = isNonNullObject;
3299
- this.pastCopies = new Set();
3300
- }
3301
- DeepMerger2.prototype.merge = function(target, source) {
3302
- var _this = this;
3303
- var context = [];
3304
- for (var _i = 2; _i < arguments.length; _i++) {
3305
- context[_i - 2] = arguments[_i];
3306
- }
3307
- if (isNonNullObject(source) && isNonNullObject(target)) {
3308
- Object.keys(source).forEach(function(sourceKey) {
3309
- if (hasOwnProperty$2.call(target, sourceKey)) {
3310
- var targetValue = target[sourceKey];
3311
- if (source[sourceKey] !== targetValue) {
3312
- var result = _this.reconciler.apply(_this, __spreadArray([target, source, sourceKey], context, false));
3313
- if (result !== targetValue) {
3314
- target = _this.shallowCopyForMerge(target);
3315
- target[sourceKey] = result;
3316
- }
3317
- }
3318
- } else {
3319
- target = _this.shallowCopyForMerge(target);
3320
- target[sourceKey] = source[sourceKey];
3321
- }
3322
- });
3323
- return target;
3324
- }
3325
- return source;
3326
- };
3327
- DeepMerger2.prototype.shallowCopyForMerge = function(value) {
3328
- if (isNonNullObject(value)) {
3329
- if (this.pastCopies.has(value)) {
3330
- if (!Object.isFrozen(value))
3331
- return value;
3332
- this.pastCopies.delete(value);
3333
- }
3334
- if (Array.isArray(value)) {
3335
- value = value.slice(0);
3336
- } else {
3337
- value = __assign({ __proto__: Object.getPrototypeOf(value) }, value);
3338
- }
3339
- this.pastCopies.add(value);
3340
- }
3341
- return value;
3342
- };
3343
- return DeepMerger2;
3344
- }();
3345
- var toString$1 = Object.prototype.toString;
3346
- function cloneDeep(value) {
3347
- return cloneDeepHelper(value);
3348
- }
3349
- function cloneDeepHelper(val, seen) {
3350
- switch (toString$1.call(val)) {
3351
- case "[object Array]": {
3352
- seen = seen || new Map();
3353
- if (seen.has(val))
3354
- return seen.get(val);
3355
- var copy_1 = val.slice(0);
3356
- seen.set(val, copy_1);
3357
- copy_1.forEach(function(child, i) {
3358
- copy_1[i] = cloneDeepHelper(child, seen);
3359
- });
3360
- return copy_1;
3361
- }
3362
- case "[object Object]": {
3363
- seen = seen || new Map();
3364
- if (seen.has(val))
3365
- return seen.get(val);
3366
- var copy_2 = Object.create(Object.getPrototypeOf(val));
3367
- seen.set(val, copy_2);
3368
- Object.keys(val).forEach(function(key) {
3369
- copy_2[key] = cloneDeepHelper(val[key], seen);
3370
- });
3371
- return copy_2;
3372
- }
3373
- default:
3374
- return val;
3375
- }
3376
- }
3377
- function deepFreeze(value) {
3378
- var workSet = new Set([value]);
3379
- workSet.forEach(function(obj) {
3380
- if (isNonNullObject(obj) && shallowFreeze(obj) === obj) {
3381
- Object.getOwnPropertyNames(obj).forEach(function(name) {
3382
- if (isNonNullObject(obj[name]))
3383
- workSet.add(obj[name]);
3384
- });
3385
- }
3386
- });
3387
- return value;
3388
- }
3389
- function shallowFreeze(obj) {
3390
- if (__DEV__ && !Object.isFrozen(obj)) {
3391
- try {
3392
- Object.freeze(obj);
3393
- } catch (e) {
3394
- if (e instanceof TypeError)
3395
- return null;
3396
- throw e;
3397
- }
3398
- }
3399
- return obj;
3400
- }
3401
- function maybeDeepFreeze(obj) {
3402
- if (__DEV__) {
3403
- deepFreeze(obj);
3404
- }
3405
- return obj;
3406
- }
3407
- var canUseWeakMap = typeof WeakMap === "function" && !(typeof navigator === "object" && navigator.product === "ReactNative");
3408
- var canUseWeakSet = typeof WeakSet === "function";
3409
- function isNonEmptyArray(value) {
3410
- return Array.isArray(value) && value.length > 0;
3411
- }
3412
- function compact() {
3413
- var objects = [];
3414
- for (var _i = 0; _i < arguments.length; _i++) {
3415
- objects[_i] = arguments[_i];
3416
- }
3417
- var result = Object.create(null);
3418
- objects.forEach(function(obj) {
3419
- if (!obj)
3420
- return;
3421
- Object.keys(obj).forEach(function(key) {
3422
- var value = obj[key];
3423
- if (value !== void 0) {
3424
- result[key] = value;
3425
- }
3426
- });
3427
- });
3428
- return result;
3429
- }
3430
- var prefixCounts = new Map();
3431
- function makeUniqueId(prefix) {
3432
- var count = prefixCounts.get(prefix) || 1;
3433
- prefixCounts.set(prefix, count + 1);
3434
- return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
3435
- }
3436
- function stringifyForDisplay(value) {
3437
- var undefId = makeUniqueId("stringifyForDisplay");
3438
- return JSON.stringify(value, function(key, value2) {
3439
- return value2 === void 0 ? undefId : value2;
3440
- }).split(JSON.stringify(undefId)).join("<undefined>");
3441
- }
3442
- var _a$2 = Object.prototype, toString = _a$2.toString, hasOwnProperty$1 = _a$2.hasOwnProperty;
3443
- var fnToStr = Function.prototype.toString;
3444
- var previousComparisons = new Map();
3445
- function equal(a, b) {
3446
- try {
3447
- return check(a, b);
3448
- } finally {
3449
- previousComparisons.clear();
3450
- }
3451
- }
3452
- function check(a, b) {
3453
- if (a === b) {
3454
- return true;
3455
- }
3456
- var aTag = toString.call(a);
3457
- var bTag = toString.call(b);
3458
- if (aTag !== bTag) {
3459
- return false;
3460
- }
3461
- switch (aTag) {
3462
- case "[object Array]":
3463
- if (a.length !== b.length)
3464
- return false;
3465
- case "[object Object]": {
3466
- if (previouslyCompared(a, b))
3467
- return true;
3468
- var aKeys = definedKeys(a);
3469
- var bKeys = definedKeys(b);
3470
- var keyCount = aKeys.length;
3471
- if (keyCount !== bKeys.length)
3472
- return false;
3473
- for (var k = 0; k < keyCount; ++k) {
3474
- if (!hasOwnProperty$1.call(b, aKeys[k])) {
3475
- return false;
3476
- }
3477
- }
3478
- for (var k = 0; k < keyCount; ++k) {
3479
- var key = aKeys[k];
3480
- if (!check(a[key], b[key])) {
3481
- return false;
3482
- }
3483
- }
3484
- return true;
3485
- }
3486
- case "[object Error]":
3487
- return a.name === b.name && a.message === b.message;
3488
- case "[object Number]":
3489
- if (a !== a)
3490
- return b !== b;
3491
- case "[object Boolean]":
3492
- case "[object Date]":
3493
- return +a === +b;
3494
- case "[object RegExp]":
3495
- case "[object String]":
3496
- return a == "" + b;
3497
- case "[object Map]":
3498
- case "[object Set]": {
3499
- if (a.size !== b.size)
3500
- return false;
3501
- if (previouslyCompared(a, b))
3502
- return true;
3503
- var aIterator = a.entries();
3504
- var isMap = aTag === "[object Map]";
3505
- while (true) {
3506
- var info = aIterator.next();
3507
- if (info.done)
3508
- break;
3509
- var _a2 = info.value, aKey = _a2[0], aValue = _a2[1];
3510
- if (!b.has(aKey)) {
3511
- return false;
3512
- }
3513
- if (isMap && !check(aValue, b.get(aKey))) {
3514
- return false;
3515
- }
3516
- }
3517
- return true;
3518
- }
3519
- case "[object Uint16Array]":
3520
- case "[object Uint8Array]":
3521
- case "[object Uint32Array]":
3522
- case "[object Int32Array]":
3523
- case "[object Int8Array]":
3524
- case "[object Int16Array]":
3525
- case "[object ArrayBuffer]":
3526
- a = new Uint8Array(a);
3527
- b = new Uint8Array(b);
3528
- case "[object DataView]": {
3529
- var len = a.byteLength;
3530
- if (len === b.byteLength) {
3531
- while (len-- && a[len] === b[len]) {
3532
- }
3533
- }
3534
- return len === -1;
3535
- }
3536
- case "[object AsyncFunction]":
3537
- case "[object GeneratorFunction]":
3538
- case "[object AsyncGeneratorFunction]":
3539
- case "[object Function]": {
3540
- var aCode = fnToStr.call(a);
3541
- if (aCode !== fnToStr.call(b)) {
3542
- return false;
3543
- }
3544
- return !endsWith(aCode, nativeCodeSuffix);
3545
- }
3546
- }
3547
- return false;
3548
- }
3549
- function definedKeys(obj) {
3550
- return Object.keys(obj).filter(isDefinedKey, obj);
3551
- }
3552
- function isDefinedKey(key) {
3553
- return this[key] !== void 0;
3554
- }
3555
- var nativeCodeSuffix = "{ [native code] }";
3556
- function endsWith(full, suffix) {
3557
- var fromIndex = full.length - suffix.length;
3558
- return fromIndex >= 0 && full.indexOf(suffix, fromIndex) === fromIndex;
3559
- }
3560
- function previouslyCompared(a, b) {
3561
- var bSet = previousComparisons.get(a);
3562
- if (bSet) {
3563
- if (bSet.has(b))
3564
- return true;
3565
- } else {
3566
- previousComparisons.set(a, bSet = new Set());
3567
- }
3568
- bSet.add(b);
3569
- return false;
3570
- }
3571
- var defaultMakeData = function() {
3572
- return Object.create(null);
3573
- };
3574
- var _a$1 = Array.prototype, forEach = _a$1.forEach, slice = _a$1.slice;
3575
- var Trie = function() {
3576
- function Trie2(weakness, makeData) {
3577
- if (weakness === void 0) {
3578
- weakness = true;
3579
- }
3580
- if (makeData === void 0) {
3581
- makeData = defaultMakeData;
3582
- }
3583
- this.weakness = weakness;
3584
- this.makeData = makeData;
3585
- }
3586
- Trie2.prototype.lookup = function() {
3587
- var array = [];
3588
- for (var _i = 0; _i < arguments.length; _i++) {
3589
- array[_i] = arguments[_i];
3590
- }
3591
- return this.lookupArray(array);
3592
- };
3593
- Trie2.prototype.lookupArray = function(array) {
3594
- var node = this;
3595
- forEach.call(array, function(key) {
3596
- return node = node.getChildTrie(key);
3597
- });
3598
- return node.data || (node.data = this.makeData(slice.call(array)));
3599
- };
3600
- Trie2.prototype.getChildTrie = function(key) {
3601
- var map = this.weakness && isObjRef(key) ? this.weak || (this.weak = new WeakMap()) : this.strong || (this.strong = new Map());
3602
- var child = map.get(key);
3603
- if (!child)
3604
- map.set(key, child = new Trie2(this.weakness, this.makeData));
3605
- return child;
3606
- };
3607
- return Trie2;
3608
- }();
3609
- function isObjRef(value) {
3610
- switch (typeof value) {
3611
- case "object":
3612
- if (value === null)
3613
- break;
3614
- case "function":
3615
- return true;
3616
- }
3617
- return false;
3618
- }
3619
- var currentContext = null;
3620
- var MISSING_VALUE = {};
3621
- var idCounter = 1;
3622
- var makeSlotClass = function() {
3623
- return function() {
3624
- function Slot2() {
3625
- this.id = [
3626
- "slot",
3627
- idCounter++,
3628
- Date.now(),
3629
- Math.random().toString(36).slice(2)
3630
- ].join(":");
3631
- }
3632
- Slot2.prototype.hasValue = function() {
3633
- for (var context_1 = currentContext; context_1; context_1 = context_1.parent) {
3634
- if (this.id in context_1.slots) {
3635
- var value = context_1.slots[this.id];
3636
- if (value === MISSING_VALUE)
3637
- break;
3638
- if (context_1 !== currentContext) {
3639
- currentContext.slots[this.id] = value;
3640
- }
3641
- return true;
3642
- }
3643
- }
3644
- if (currentContext) {
3645
- currentContext.slots[this.id] = MISSING_VALUE;
3646
- }
3647
- return false;
3648
- };
3649
- Slot2.prototype.getValue = function() {
3650
- if (this.hasValue()) {
3651
- return currentContext.slots[this.id];
3652
- }
3653
- };
3654
- Slot2.prototype.withValue = function(value, callback, args, thisArg) {
3655
- var _a2;
3656
- var slots = (_a2 = {
3657
- __proto__: null
3658
- }, _a2[this.id] = value, _a2);
3659
- var parent = currentContext;
3660
- currentContext = { parent, slots };
3661
- try {
3662
- return callback.apply(thisArg, args);
3663
- } finally {
3664
- currentContext = parent;
3665
- }
3666
- };
3667
- Slot2.bind = function(callback) {
3668
- var context = currentContext;
3669
- return function() {
3670
- var saved = currentContext;
3671
- try {
3672
- currentContext = context;
3673
- return callback.apply(this, arguments);
3674
- } finally {
3675
- currentContext = saved;
3676
- }
3677
- };
3678
- };
3679
- Slot2.noContext = function(callback, args, thisArg) {
3680
- if (currentContext) {
3681
- var saved = currentContext;
3682
- try {
3683
- currentContext = null;
3684
- return callback.apply(thisArg, args);
3685
- } finally {
3686
- currentContext = saved;
3687
- }
3688
- } else {
3689
- return callback.apply(thisArg, args);
3690
- }
3691
- };
3692
- return Slot2;
3693
- }();
3694
- };
3695
- var globalKey = "@wry/context:Slot";
3696
- var host = Array;
3697
- var Slot = host[globalKey] || function() {
3698
- var Slot2 = makeSlotClass();
3699
- try {
3700
- Object.defineProperty(host, globalKey, {
3701
- value: host[globalKey] = Slot2,
3702
- enumerable: false,
3703
- writable: false,
3704
- configurable: false
3705
- });
3706
- } finally {
3707
- return Slot2;
3708
- }
3709
- }();
3710
- Slot.bind;
3711
- Slot.noContext;
3712
- function defaultDispose() {
3713
- }
3714
- var Cache = function() {
3715
- function Cache2(max, dispose) {
3716
- if (max === void 0) {
3717
- max = Infinity;
3718
- }
3719
- if (dispose === void 0) {
3720
- dispose = defaultDispose;
3721
- }
3722
- this.max = max;
3723
- this.dispose = dispose;
3724
- this.map = new Map();
3725
- this.newest = null;
3726
- this.oldest = null;
3727
- }
3728
- Cache2.prototype.has = function(key) {
3729
- return this.map.has(key);
3730
- };
3731
- Cache2.prototype.get = function(key) {
3732
- var node = this.getNode(key);
3733
- return node && node.value;
3734
- };
3735
- Cache2.prototype.getNode = function(key) {
3736
- var node = this.map.get(key);
3737
- if (node && node !== this.newest) {
3738
- var older = node.older, newer = node.newer;
3739
- if (newer) {
3740
- newer.older = older;
3741
- }
3742
- if (older) {
3743
- older.newer = newer;
3744
- }
3745
- node.older = this.newest;
3746
- node.older.newer = node;
3747
- node.newer = null;
3748
- this.newest = node;
3749
- if (node === this.oldest) {
3750
- this.oldest = newer;
3751
- }
3752
- }
3753
- return node;
3754
- };
3755
- Cache2.prototype.set = function(key, value) {
3756
- var node = this.getNode(key);
3757
- if (node) {
3758
- return node.value = value;
3759
- }
3760
- node = {
3761
- key,
3762
- value,
3763
- newer: null,
3764
- older: this.newest
3765
- };
3766
- if (this.newest) {
3767
- this.newest.newer = node;
3768
- }
3769
- this.newest = node;
3770
- this.oldest = this.oldest || node;
3771
- this.map.set(key, node);
3772
- return node.value;
3773
- };
3774
- Cache2.prototype.clean = function() {
3775
- while (this.oldest && this.map.size > this.max) {
3776
- this.delete(this.oldest.key);
3777
- }
3778
- };
3779
- Cache2.prototype.delete = function(key) {
3780
- var node = this.map.get(key);
3781
- if (node) {
3782
- if (node === this.newest) {
3783
- this.newest = node.older;
3784
- }
3785
- if (node === this.oldest) {
3786
- this.oldest = node.newer;
3787
- }
3788
- if (node.newer) {
3789
- node.newer.older = node.older;
3790
- }
3791
- if (node.older) {
3792
- node.older.newer = node.newer;
3793
- }
3794
- this.map.delete(key);
3795
- this.dispose(node.value, key);
3796
- return true;
3797
- }
3798
- return false;
3799
- };
3800
- return Cache2;
3801
- }();
3802
- var parentEntrySlot = new Slot();
3803
- var _a;
3804
- var hasOwnProperty = Object.prototype.hasOwnProperty;
3805
- var toArray = (_a = Array.from, _a === void 0 ? function(collection) {
3806
- var array = [];
3807
- collection.forEach(function(item) {
3808
- return array.push(item);
3809
- });
3810
- return array;
3811
- } : _a);
3812
- function maybeUnsubscribe(entryOrDep) {
3813
- var unsubscribe = entryOrDep.unsubscribe;
3814
- if (typeof unsubscribe === "function") {
3815
- entryOrDep.unsubscribe = void 0;
3816
- unsubscribe();
3817
- }
3818
- }
3819
- var emptySetPool = [];
3820
- var POOL_TARGET_SIZE = 100;
3821
- function assert(condition, optionalMessage) {
3822
- if (!condition) {
3823
- throw new Error(optionalMessage || "assertion failure");
3824
- }
3825
- }
3826
- function valueIs(a, b) {
3827
- var len = a.length;
3828
- return len > 0 && len === b.length && a[len - 1] === b[len - 1];
3829
- }
3830
- function valueGet(value) {
3831
- switch (value.length) {
3832
- case 0:
3833
- throw new Error("unknown value");
3834
- case 1:
3835
- return value[0];
3836
- case 2:
3837
- throw value[1];
3838
- }
3839
- }
3840
- function valueCopy(value) {
3841
- return value.slice(0);
3842
- }
3843
- var Entry = function() {
3844
- function Entry2(fn) {
3845
- this.fn = fn;
3846
- this.parents = new Set();
3847
- this.childValues = new Map();
3848
- this.dirtyChildren = null;
3849
- this.dirty = true;
3850
- this.recomputing = false;
3851
- this.value = [];
3852
- this.deps = null;
3853
- ++Entry2.count;
3854
- }
3855
- Entry2.prototype.peek = function() {
3856
- if (this.value.length === 1 && !mightBeDirty(this)) {
3857
- rememberParent(this);
3858
- return this.value[0];
3859
- }
3860
- };
3861
- Entry2.prototype.recompute = function(args) {
3862
- assert(!this.recomputing, "already recomputing");
3863
- rememberParent(this);
3864
- return mightBeDirty(this) ? reallyRecompute(this, args) : valueGet(this.value);
3865
- };
3866
- Entry2.prototype.setDirty = function() {
3867
- if (this.dirty)
3868
- return;
3869
- this.dirty = true;
3870
- this.value.length = 0;
3871
- reportDirty(this);
3872
- maybeUnsubscribe(this);
3873
- };
3874
- Entry2.prototype.dispose = function() {
3875
- var _this = this;
3876
- this.setDirty();
3877
- forgetChildren(this);
3878
- eachParent(this, function(parent, child) {
3879
- parent.setDirty();
3880
- forgetChild(parent, _this);
3881
- });
3882
- };
3883
- Entry2.prototype.forget = function() {
3884
- this.dispose();
3885
- };
3886
- Entry2.prototype.dependOn = function(dep2) {
3887
- dep2.add(this);
3888
- if (!this.deps) {
3889
- this.deps = emptySetPool.pop() || new Set();
3890
- }
3891
- this.deps.add(dep2);
3892
- };
3893
- Entry2.prototype.forgetDeps = function() {
3894
- var _this = this;
3895
- if (this.deps) {
3896
- toArray(this.deps).forEach(function(dep2) {
3897
- return dep2.delete(_this);
3898
- });
3899
- this.deps.clear();
3900
- emptySetPool.push(this.deps);
3901
- this.deps = null;
3902
- }
3903
- };
3904
- Entry2.count = 0;
3905
- return Entry2;
3906
- }();
3907
- function rememberParent(child) {
3908
- var parent = parentEntrySlot.getValue();
3909
- if (parent) {
3910
- child.parents.add(parent);
3911
- if (!parent.childValues.has(child)) {
3912
- parent.childValues.set(child, []);
3913
- }
3914
- if (mightBeDirty(child)) {
3915
- reportDirtyChild(parent, child);
3916
- } else {
3917
- reportCleanChild(parent, child);
3918
- }
3919
- return parent;
3920
- }
3921
- }
3922
- function reallyRecompute(entry, args) {
3923
- forgetChildren(entry);
3924
- parentEntrySlot.withValue(entry, recomputeNewValue, [entry, args]);
3925
- if (maybeSubscribe(entry, args)) {
3926
- setClean(entry);
3927
- }
3928
- return valueGet(entry.value);
3929
- }
3930
- function recomputeNewValue(entry, args) {
3931
- entry.recomputing = true;
3932
- entry.value.length = 0;
3933
- try {
3934
- entry.value[0] = entry.fn.apply(null, args);
3935
- } catch (e) {
3936
- entry.value[1] = e;
3937
- }
3938
- entry.recomputing = false;
3939
- }
3940
- function mightBeDirty(entry) {
3941
- return entry.dirty || !!(entry.dirtyChildren && entry.dirtyChildren.size);
3942
- }
3943
- function setClean(entry) {
3944
- entry.dirty = false;
3945
- if (mightBeDirty(entry)) {
3946
- return;
3947
- }
3948
- reportClean(entry);
3949
- }
3950
- function reportDirty(child) {
3951
- eachParent(child, reportDirtyChild);
3952
- }
3953
- function reportClean(child) {
3954
- eachParent(child, reportCleanChild);
3955
- }
3956
- function eachParent(child, callback) {
3957
- var parentCount = child.parents.size;
3958
- if (parentCount) {
3959
- var parents = toArray(child.parents);
3960
- for (var i = 0; i < parentCount; ++i) {
3961
- callback(parents[i], child);
3962
- }
3963
- }
3964
- }
3965
- function reportDirtyChild(parent, child) {
3966
- assert(parent.childValues.has(child));
3967
- assert(mightBeDirty(child));
3968
- var parentWasClean = !mightBeDirty(parent);
3969
- if (!parent.dirtyChildren) {
3970
- parent.dirtyChildren = emptySetPool.pop() || new Set();
3971
- } else if (parent.dirtyChildren.has(child)) {
3972
- return;
3973
- }
3974
- parent.dirtyChildren.add(child);
3975
- if (parentWasClean) {
3976
- reportDirty(parent);
3977
- }
3978
- }
3979
- function reportCleanChild(parent, child) {
3980
- assert(parent.childValues.has(child));
3981
- assert(!mightBeDirty(child));
3982
- var childValue = parent.childValues.get(child);
3983
- if (childValue.length === 0) {
3984
- parent.childValues.set(child, valueCopy(child.value));
3985
- } else if (!valueIs(childValue, child.value)) {
3986
- parent.setDirty();
3987
- }
3988
- removeDirtyChild(parent, child);
3989
- if (mightBeDirty(parent)) {
3990
- return;
3991
- }
3992
- reportClean(parent);
3993
- }
3994
- function removeDirtyChild(parent, child) {
3995
- var dc = parent.dirtyChildren;
3996
- if (dc) {
3997
- dc.delete(child);
3998
- if (dc.size === 0) {
3999
- if (emptySetPool.length < POOL_TARGET_SIZE) {
4000
- emptySetPool.push(dc);
4001
- }
4002
- parent.dirtyChildren = null;
4003
- }
4004
- }
4005
- }
4006
- function forgetChildren(parent) {
4007
- if (parent.childValues.size > 0) {
4008
- parent.childValues.forEach(function(_value, child) {
4009
- forgetChild(parent, child);
4010
- });
4011
- }
4012
- parent.forgetDeps();
4013
- assert(parent.dirtyChildren === null);
4014
- }
4015
- function forgetChild(parent, child) {
4016
- child.parents.delete(parent);
4017
- parent.childValues.delete(child);
4018
- removeDirtyChild(parent, child);
4019
- }
4020
- function maybeSubscribe(entry, args) {
4021
- if (typeof entry.subscribe === "function") {
4022
- try {
4023
- maybeUnsubscribe(entry);
4024
- entry.unsubscribe = entry.subscribe.apply(null, args);
4025
- } catch (e) {
4026
- entry.setDirty();
4027
- return false;
4028
- }
4029
- }
4030
- return true;
4031
- }
4032
- var EntryMethods = {
4033
- setDirty: true,
4034
- dispose: true,
4035
- forget: true
4036
- };
4037
- function dep(options) {
4038
- var depsByKey = new Map();
4039
- var subscribe = options && options.subscribe;
4040
- function depend(key) {
4041
- var parent = parentEntrySlot.getValue();
4042
- if (parent) {
4043
- var dep_1 = depsByKey.get(key);
4044
- if (!dep_1) {
4045
- depsByKey.set(key, dep_1 = new Set());
4046
- }
4047
- parent.dependOn(dep_1);
4048
- if (typeof subscribe === "function") {
4049
- maybeUnsubscribe(dep_1);
4050
- dep_1.unsubscribe = subscribe(key);
4051
- }
4052
- }
4053
- }
4054
- depend.dirty = function dirty(key, entryMethodName) {
4055
- var dep2 = depsByKey.get(key);
4056
- if (dep2) {
4057
- var m_1 = entryMethodName && hasOwnProperty.call(EntryMethods, entryMethodName) ? entryMethodName : "setDirty";
4058
- toArray(dep2).forEach(function(entry) {
4059
- return entry[m_1]();
4060
- });
4061
- depsByKey.delete(key);
4062
- maybeUnsubscribe(dep2);
4063
- }
4064
- };
4065
- return depend;
4066
- }
4067
- function makeDefaultMakeCacheKeyFunction() {
4068
- var keyTrie = new Trie(typeof WeakMap === "function");
4069
- return function() {
4070
- return keyTrie.lookupArray(arguments);
4071
- };
4072
- }
4073
- makeDefaultMakeCacheKeyFunction();
4074
- var caches = new Set();
4075
- function wrap(originalFunction, options) {
4076
- if (options === void 0) {
4077
- options = Object.create(null);
4078
- }
4079
- var cache = new Cache(options.max || Math.pow(2, 16), function(entry) {
4080
- return entry.dispose();
4081
- });
4082
- var keyArgs = options.keyArgs;
4083
- var makeCacheKey = options.makeCacheKey || makeDefaultMakeCacheKeyFunction();
4084
- var optimistic = function() {
4085
- var key = makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments);
4086
- if (key === void 0) {
4087
- return originalFunction.apply(null, arguments);
4088
- }
4089
- var entry = cache.get(key);
4090
- if (!entry) {
4091
- cache.set(key, entry = new Entry(originalFunction));
4092
- entry.subscribe = options.subscribe;
4093
- entry.forget = function() {
4094
- return cache.delete(key);
4095
- };
4096
- }
4097
- var value = entry.recompute(Array.prototype.slice.call(arguments));
4098
- cache.set(key, entry);
4099
- caches.add(cache);
4100
- if (!parentEntrySlot.hasValue()) {
4101
- caches.forEach(function(cache2) {
4102
- return cache2.clean();
4103
- });
4104
- caches.clear();
4105
- }
4106
- return value;
4107
- };
4108
- Object.defineProperty(optimistic, "size", {
4109
- get: function() {
4110
- return cache["map"].size;
4111
- },
4112
- configurable: false,
4113
- enumerable: false
4114
- });
4115
- function dirtyKey(key) {
4116
- var entry = cache.get(key);
4117
- if (entry) {
4118
- entry.setDirty();
4119
- }
4120
- }
4121
- optimistic.dirtyKey = dirtyKey;
4122
- optimistic.dirty = function dirty() {
4123
- dirtyKey(makeCacheKey.apply(null, arguments));
4124
- };
4125
- function peekKey(key) {
4126
- var entry = cache.get(key);
4127
- if (entry) {
4128
- return entry.peek();
4129
- }
4130
- }
4131
- optimistic.peekKey = peekKey;
4132
- optimistic.peek = function peek() {
4133
- return peekKey(makeCacheKey.apply(null, arguments));
4134
- };
4135
- function forgetKey(key) {
4136
- return cache.delete(key);
4137
- }
4138
- optimistic.forgetKey = forgetKey;
4139
- optimistic.forget = function forget() {
4140
- return forgetKey(makeCacheKey.apply(null, arguments));
4141
- };
4142
- optimistic.makeCacheKey = makeCacheKey;
4143
- optimistic.getKey = keyArgs ? function getKey() {
4144
- return makeCacheKey.apply(null, keyArgs.apply(null, arguments));
4145
- } : makeCacheKey;
4146
- return Object.freeze(optimistic);
4147
- }
4148
- var ApolloCache = function() {
4149
- function ApolloCache2() {
4150
- this.getFragmentDoc = wrap(getFragmentQueryDocument);
4151
- }
4152
- ApolloCache2.prototype.batch = function(options) {
4153
- var _this = this;
4154
- var optimisticId = typeof options.optimistic === "string" ? options.optimistic : options.optimistic === false ? null : void 0;
4155
- var updateResult;
4156
- this.performTransaction(function() {
4157
- return updateResult = options.update(_this);
4158
- }, optimisticId);
4159
- return updateResult;
4160
- };
4161
- ApolloCache2.prototype.recordOptimisticTransaction = function(transaction, optimisticId) {
4162
- this.performTransaction(transaction, optimisticId);
4163
- };
4164
- ApolloCache2.prototype.transformDocument = function(document) {
4165
- return document;
4166
- };
4167
- ApolloCache2.prototype.identify = function(object) {
4168
- return;
4169
- };
4170
- ApolloCache2.prototype.gc = function() {
4171
- return [];
4172
- };
4173
- ApolloCache2.prototype.modify = function(options) {
4174
- return false;
4175
- };
4176
- ApolloCache2.prototype.transformForLink = function(document) {
4177
- return document;
4178
- };
4179
- ApolloCache2.prototype.readQuery = function(options, optimistic) {
4180
- if (optimistic === void 0) {
4181
- optimistic = !!options.optimistic;
4182
- }
4183
- return this.read(__assign(__assign({}, options), { rootId: options.id || "ROOT_QUERY", optimistic }));
4184
- };
4185
- ApolloCache2.prototype.readFragment = function(options, optimistic) {
4186
- if (optimistic === void 0) {
4187
- optimistic = !!options.optimistic;
4188
- }
4189
- return this.read(__assign(__assign({}, options), { query: this.getFragmentDoc(options.fragment, options.fragmentName), rootId: options.id, optimistic }));
4190
- };
4191
- ApolloCache2.prototype.writeQuery = function(_a2) {
4192
- var id = _a2.id, data = _a2.data, options = __rest(_a2, ["id", "data"]);
4193
- return this.write(Object.assign(options, {
4194
- dataId: id || "ROOT_QUERY",
4195
- result: data
4196
- }));
4197
- };
4198
- ApolloCache2.prototype.writeFragment = function(_a2) {
4199
- var id = _a2.id, data = _a2.data, fragment = _a2.fragment, fragmentName = _a2.fragmentName, options = __rest(_a2, ["id", "data", "fragment", "fragmentName"]);
4200
- return this.write(Object.assign(options, {
4201
- query: this.getFragmentDoc(fragment, fragmentName),
4202
- dataId: id,
4203
- result: data
4204
- }));
4205
- };
4206
- ApolloCache2.prototype.updateQuery = function(options, update) {
4207
- return this.batch({
4208
- update: function(cache) {
4209
- var value = cache.readQuery(options);
4210
- var data = update(value);
4211
- if (data === void 0 || data === null)
4212
- return value;
4213
- cache.writeQuery(__assign(__assign({}, options), { data }));
4214
- return data;
4215
- }
4216
- });
4217
- };
4218
- ApolloCache2.prototype.updateFragment = function(options, update) {
4219
- return this.batch({
4220
- update: function(cache) {
4221
- var value = cache.readFragment(options);
4222
- var data = update(value);
4223
- if (data === void 0 || data === null)
4224
- return value;
4225
- cache.writeFragment(__assign(__assign({}, options), { data }));
4226
- return data;
4227
- }
4228
- });
4229
- };
4230
- return ApolloCache2;
4231
- }();
4232
- var MissingFieldError = function() {
4233
- function MissingFieldError2(message2, path2, query, variables) {
4234
- this.message = message2;
4235
- this.path = path2;
4236
- this.query = query;
4237
- this.variables = variables;
4238
- }
4239
- return MissingFieldError2;
4240
- }();
4241
- var hasOwn = Object.prototype.hasOwnProperty;
4242
- function defaultDataIdFromObject(_a2, context) {
4243
- var __typename = _a2.__typename, id = _a2.id, _id = _a2._id;
4244
- if (typeof __typename === "string") {
4245
- if (context) {
4246
- context.keyObject = id !== void 0 ? { id } : _id !== void 0 ? { _id } : void 0;
4247
- }
4248
- if (id === void 0)
4249
- id = _id;
4250
- if (id !== void 0) {
4251
- return "".concat(__typename, ":").concat(typeof id === "number" || typeof id === "string" ? id : JSON.stringify(id));
4252
- }
4253
- }
4254
- }
4255
- var defaultConfig = {
4256
- dataIdFromObject: defaultDataIdFromObject,
4257
- addTypename: true,
4258
- resultCaching: true,
4259
- canonizeResults: false
4260
- };
4261
- function normalizeConfig(config) {
4262
- return compact(defaultConfig, config);
4263
- }
4264
- function shouldCanonizeResults(config) {
4265
- var value = config.canonizeResults;
4266
- return value === void 0 ? defaultConfig.canonizeResults : value;
4267
- }
4268
- function getTypenameFromStoreObject(store, objectOrReference) {
4269
- return isReference(objectOrReference) ? store.get(objectOrReference.__ref, "__typename") : objectOrReference && objectOrReference.__typename;
4270
- }
4271
- var TypeOrFieldNameRegExp = /^[_a-z][_0-9a-z]*/i;
4272
- function fieldNameFromStoreName(storeFieldName) {
4273
- var match = storeFieldName.match(TypeOrFieldNameRegExp);
4274
- return match ? match[0] : storeFieldName;
4275
- }
4276
- function selectionSetMatchesResult(selectionSet, result, variables) {
4277
- if (isNonNullObject(result)) {
4278
- return Array.isArray(result) ? result.every(function(item) {
4279
- return selectionSetMatchesResult(selectionSet, item, variables);
4280
- }) : selectionSet.selections.every(function(field) {
4281
- if (isField(field) && shouldInclude(field, variables)) {
4282
- var key = resultKeyNameFromField(field);
4283
- return hasOwn.call(result, key) && (!field.selectionSet || selectionSetMatchesResult(field.selectionSet, result[key], variables));
4284
- }
4285
- return true;
4286
- });
4287
- }
4288
- return false;
4289
- }
4290
- function storeValueIsStoreObject(value) {
4291
- return isNonNullObject(value) && !isReference(value) && !Array.isArray(value);
4292
- }
4293
- function makeProcessedFieldsMerger() {
4294
- return new DeepMerger();
4295
- }
4296
- var DELETE = Object.create(null);
4297
- var delModifier = function() {
4298
- return DELETE;
4299
- };
4300
- var INVALIDATE = Object.create(null);
4301
- var EntityStore = function() {
4302
- function EntityStore2(policies, group) {
4303
- var _this = this;
4304
- this.policies = policies;
4305
- this.group = group;
4306
- this.data = Object.create(null);
4307
- this.rootIds = Object.create(null);
4308
- this.refs = Object.create(null);
4309
- this.getFieldValue = function(objectOrReference, storeFieldName) {
4310
- return maybeDeepFreeze(isReference(objectOrReference) ? _this.get(objectOrReference.__ref, storeFieldName) : objectOrReference && objectOrReference[storeFieldName]);
4311
- };
4312
- this.canRead = function(objOrRef) {
4313
- return isReference(objOrRef) ? _this.has(objOrRef.__ref) : typeof objOrRef === "object";
4314
- };
4315
- this.toReference = function(objOrIdOrRef, mergeIntoStore) {
4316
- if (typeof objOrIdOrRef === "string") {
4317
- return makeReference(objOrIdOrRef);
4318
- }
4319
- if (isReference(objOrIdOrRef)) {
4320
- return objOrIdOrRef;
4321
- }
4322
- var id = _this.policies.identify(objOrIdOrRef)[0];
4323
- if (id) {
4324
- var ref2 = makeReference(id);
4325
- if (mergeIntoStore) {
4326
- _this.merge(id, objOrIdOrRef);
4327
- }
4328
- return ref2;
4329
- }
4330
- };
4331
- }
4332
- EntityStore2.prototype.toObject = function() {
4333
- return __assign({}, this.data);
4334
- };
4335
- EntityStore2.prototype.has = function(dataId) {
4336
- return this.lookup(dataId, true) !== void 0;
4337
- };
4338
- EntityStore2.prototype.get = function(dataId, fieldName) {
4339
- this.group.depend(dataId, fieldName);
4340
- if (hasOwn.call(this.data, dataId)) {
4341
- var storeObject = this.data[dataId];
4342
- if (storeObject && hasOwn.call(storeObject, fieldName)) {
4343
- return storeObject[fieldName];
4344
- }
4345
- }
4346
- if (fieldName === "__typename" && hasOwn.call(this.policies.rootTypenamesById, dataId)) {
4347
- return this.policies.rootTypenamesById[dataId];
4348
- }
4349
- if (this instanceof Layer) {
4350
- return this.parent.get(dataId, fieldName);
4351
- }
4352
- };
4353
- EntityStore2.prototype.lookup = function(dataId, dependOnExistence) {
4354
- if (dependOnExistence)
4355
- this.group.depend(dataId, "__exists");
4356
- if (hasOwn.call(this.data, dataId)) {
4357
- return this.data[dataId];
4358
- }
4359
- if (this instanceof Layer) {
4360
- return this.parent.lookup(dataId, dependOnExistence);
4361
- }
4362
- if (this.policies.rootTypenamesById[dataId]) {
4363
- return Object.create(null);
4364
- }
4365
- };
4366
- EntityStore2.prototype.merge = function(older, newer) {
4367
- var _this = this;
4368
- var dataId;
4369
- if (isReference(older))
4370
- older = older.__ref;
4371
- if (isReference(newer))
4372
- newer = newer.__ref;
4373
- var existing = typeof older === "string" ? this.lookup(dataId = older) : older;
4374
- var incoming = typeof newer === "string" ? this.lookup(dataId = newer) : newer;
4375
- if (!incoming)
4376
- return;
4377
- __DEV__ ? invariant(typeof dataId === "string", "store.merge expects a string ID") : invariant(typeof dataId === "string", 1);
4378
- var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
4379
- this.data[dataId] = merged;
4380
- if (merged !== existing) {
4381
- delete this.refs[dataId];
4382
- if (this.group.caching) {
4383
- var fieldsToDirty_1 = Object.create(null);
4384
- if (!existing)
4385
- fieldsToDirty_1.__exists = 1;
4386
- Object.keys(incoming).forEach(function(storeFieldName) {
4387
- if (!existing || existing[storeFieldName] !== merged[storeFieldName]) {
4388
- fieldsToDirty_1[storeFieldName] = 1;
4389
- var fieldName = fieldNameFromStoreName(storeFieldName);
4390
- if (fieldName !== storeFieldName && !_this.policies.hasKeyArgs(merged.__typename, fieldName)) {
4391
- fieldsToDirty_1[fieldName] = 1;
4392
- }
4393
- if (merged[storeFieldName] === void 0 && !(_this instanceof Layer)) {
4394
- delete merged[storeFieldName];
4395
- }
4396
- }
4397
- });
4398
- if (fieldsToDirty_1.__typename && !(existing && existing.__typename) && this.policies.rootTypenamesById[dataId] === merged.__typename) {
4399
- delete fieldsToDirty_1.__typename;
4400
- }
4401
- Object.keys(fieldsToDirty_1).forEach(function(fieldName) {
4402
- return _this.group.dirty(dataId, fieldName);
4403
- });
4404
- }
4405
- }
4406
- };
4407
- EntityStore2.prototype.modify = function(dataId, fields) {
4408
- var _this = this;
4409
- var storeObject = this.lookup(dataId);
4410
- if (storeObject) {
4411
- var changedFields_1 = Object.create(null);
4412
- var needToMerge_1 = false;
4413
- var allDeleted_1 = true;
4414
- var sharedDetails_1 = {
4415
- DELETE,
4416
- INVALIDATE,
4417
- isReference,
4418
- toReference: this.toReference,
4419
- canRead: this.canRead,
4420
- readField: function(fieldNameOrOptions, from) {
4421
- return _this.policies.readField(typeof fieldNameOrOptions === "string" ? {
4422
- fieldName: fieldNameOrOptions,
4423
- from: from || makeReference(dataId)
4424
- } : fieldNameOrOptions, { store: _this });
4425
- }
4426
- };
4427
- Object.keys(storeObject).forEach(function(storeFieldName) {
4428
- var fieldName = fieldNameFromStoreName(storeFieldName);
4429
- var fieldValue = storeObject[storeFieldName];
4430
- if (fieldValue === void 0)
4431
- return;
4432
- var modify = typeof fields === "function" ? fields : fields[storeFieldName] || fields[fieldName];
4433
- if (modify) {
4434
- var newValue = modify === delModifier ? DELETE : modify(maybeDeepFreeze(fieldValue), __assign(__assign({}, sharedDetails_1), { fieldName, storeFieldName, storage: _this.getStorage(dataId, storeFieldName) }));
4435
- if (newValue === INVALIDATE) {
4436
- _this.group.dirty(dataId, storeFieldName);
4437
- } else {
4438
- if (newValue === DELETE)
4439
- newValue = void 0;
4440
- if (newValue !== fieldValue) {
4441
- changedFields_1[storeFieldName] = newValue;
4442
- needToMerge_1 = true;
4443
- fieldValue = newValue;
4444
- }
4445
- }
4446
- }
4447
- if (fieldValue !== void 0) {
4448
- allDeleted_1 = false;
4449
- }
4450
- });
4451
- if (needToMerge_1) {
4452
- this.merge(dataId, changedFields_1);
4453
- if (allDeleted_1) {
4454
- if (this instanceof Layer) {
4455
- this.data[dataId] = void 0;
4456
- } else {
4457
- delete this.data[dataId];
4458
- }
4459
- this.group.dirty(dataId, "__exists");
4460
- }
4461
- return true;
4462
- }
4463
- }
4464
- return false;
4465
- };
4466
- EntityStore2.prototype.delete = function(dataId, fieldName, args) {
4467
- var _a2;
4468
- var storeObject = this.lookup(dataId);
4469
- if (storeObject) {
4470
- var typename = this.getFieldValue(storeObject, "__typename");
4471
- var storeFieldName = fieldName && args ? this.policies.getStoreFieldName({ typename, fieldName, args }) : fieldName;
4472
- return this.modify(dataId, storeFieldName ? (_a2 = {}, _a2[storeFieldName] = delModifier, _a2) : delModifier);
4473
- }
4474
- return false;
4475
- };
4476
- EntityStore2.prototype.evict = function(options, limit) {
4477
- var evicted = false;
4478
- if (options.id) {
4479
- if (hasOwn.call(this.data, options.id)) {
4480
- evicted = this.delete(options.id, options.fieldName, options.args);
4481
- }
4482
- if (this instanceof Layer && this !== limit) {
4483
- evicted = this.parent.evict(options, limit) || evicted;
4484
- }
4485
- if (options.fieldName || evicted) {
4486
- this.group.dirty(options.id, options.fieldName || "__exists");
4487
- }
4488
- }
4489
- return evicted;
4490
- };
4491
- EntityStore2.prototype.clear = function() {
4492
- this.replace(null);
4493
- };
4494
- EntityStore2.prototype.extract = function() {
4495
- var _this = this;
4496
- var obj = this.toObject();
4497
- var extraRootIds = [];
4498
- this.getRootIdSet().forEach(function(id) {
4499
- if (!hasOwn.call(_this.policies.rootTypenamesById, id)) {
4500
- extraRootIds.push(id);
4501
- }
4502
- });
4503
- if (extraRootIds.length) {
4504
- obj.__META = { extraRootIds: extraRootIds.sort() };
4505
- }
4506
- return obj;
4507
- };
4508
- EntityStore2.prototype.replace = function(newData) {
4509
- var _this = this;
4510
- Object.keys(this.data).forEach(function(dataId) {
4511
- if (!(newData && hasOwn.call(newData, dataId))) {
4512
- _this.delete(dataId);
4513
- }
4514
- });
4515
- if (newData) {
4516
- var __META = newData.__META, rest_1 = __rest(newData, ["__META"]);
4517
- Object.keys(rest_1).forEach(function(dataId) {
4518
- _this.merge(dataId, rest_1[dataId]);
4519
- });
4520
- if (__META) {
4521
- __META.extraRootIds.forEach(this.retain, this);
4522
- }
4523
- }
4524
- };
4525
- EntityStore2.prototype.retain = function(rootId) {
4526
- return this.rootIds[rootId] = (this.rootIds[rootId] || 0) + 1;
4527
- };
4528
- EntityStore2.prototype.release = function(rootId) {
4529
- if (this.rootIds[rootId] > 0) {
4530
- var count = --this.rootIds[rootId];
4531
- if (!count)
4532
- delete this.rootIds[rootId];
4533
- return count;
4534
- }
4535
- return 0;
4536
- };
4537
- EntityStore2.prototype.getRootIdSet = function(ids) {
4538
- if (ids === void 0) {
4539
- ids = new Set();
4540
- }
4541
- Object.keys(this.rootIds).forEach(ids.add, ids);
4542
- if (this instanceof Layer) {
4543
- this.parent.getRootIdSet(ids);
4544
- } else {
4545
- Object.keys(this.policies.rootTypenamesById).forEach(ids.add, ids);
4546
- }
4547
- return ids;
4548
- };
4549
- EntityStore2.prototype.gc = function() {
4550
- var _this = this;
4551
- var ids = this.getRootIdSet();
4552
- var snapshot = this.toObject();
4553
- ids.forEach(function(id) {
4554
- if (hasOwn.call(snapshot, id)) {
4555
- Object.keys(_this.findChildRefIds(id)).forEach(ids.add, ids);
4556
- delete snapshot[id];
4557
- }
4558
- });
4559
- var idsToRemove = Object.keys(snapshot);
4560
- if (idsToRemove.length) {
4561
- var root_1 = this;
4562
- while (root_1 instanceof Layer)
4563
- root_1 = root_1.parent;
4564
- idsToRemove.forEach(function(id) {
4565
- return root_1.delete(id);
4566
- });
4567
- }
4568
- return idsToRemove;
4569
- };
4570
- EntityStore2.prototype.findChildRefIds = function(dataId) {
4571
- if (!hasOwn.call(this.refs, dataId)) {
4572
- var found_1 = this.refs[dataId] = Object.create(null);
4573
- var root = this.data[dataId];
4574
- if (!root)
4575
- return found_1;
4576
- var workSet_1 = new Set([root]);
4577
- workSet_1.forEach(function(obj) {
4578
- if (isReference(obj)) {
4579
- found_1[obj.__ref] = true;
4580
- }
4581
- if (isNonNullObject(obj)) {
4582
- Object.keys(obj).forEach(function(key) {
4583
- var child = obj[key];
4584
- if (isNonNullObject(child)) {
4585
- workSet_1.add(child);
4586
- }
4587
- });
4588
- }
4589
- });
4590
- }
4591
- return this.refs[dataId];
4592
- };
4593
- EntityStore2.prototype.makeCacheKey = function() {
4594
- return this.group.keyMaker.lookupArray(arguments);
4595
- };
4596
- return EntityStore2;
4597
- }();
4598
- var CacheGroup = function() {
4599
- function CacheGroup2(caching, parent) {
4600
- if (parent === void 0) {
4601
- parent = null;
4602
- }
4603
- this.caching = caching;
4604
- this.parent = parent;
4605
- this.d = null;
4606
- this.resetCaching();
4607
- }
4608
- CacheGroup2.prototype.resetCaching = function() {
4609
- this.d = this.caching ? dep() : null;
4610
- this.keyMaker = new Trie(canUseWeakMap);
4611
- };
4612
- CacheGroup2.prototype.depend = function(dataId, storeFieldName) {
4613
- if (this.d) {
4614
- this.d(makeDepKey(dataId, storeFieldName));
4615
- var fieldName = fieldNameFromStoreName(storeFieldName);
4616
- if (fieldName !== storeFieldName) {
4617
- this.d(makeDepKey(dataId, fieldName));
4618
- }
4619
- if (this.parent) {
4620
- this.parent.depend(dataId, storeFieldName);
4621
- }
4622
- }
4623
- };
4624
- CacheGroup2.prototype.dirty = function(dataId, storeFieldName) {
4625
- if (this.d) {
4626
- this.d.dirty(makeDepKey(dataId, storeFieldName), storeFieldName === "__exists" ? "forget" : "setDirty");
4627
- }
4628
- };
4629
- return CacheGroup2;
4630
- }();
4631
- function makeDepKey(dataId, storeFieldName) {
4632
- return storeFieldName + "#" + dataId;
4633
- }
4634
- function maybeDependOnExistenceOfEntity(store, entityId) {
4635
- if (supportsResultCaching(store)) {
4636
- store.group.depend(entityId, "__exists");
4637
- }
4638
- }
4639
- (function(EntityStore2) {
4640
- var Root = function(_super) {
4641
- __extends(Root2, _super);
4642
- function Root2(_a2) {
4643
- var policies = _a2.policies, _b = _a2.resultCaching, resultCaching = _b === void 0 ? true : _b, seed = _a2.seed;
4644
- var _this = _super.call(this, policies, new CacheGroup(resultCaching)) || this;
4645
- _this.stump = new Stump(_this);
4646
- _this.storageTrie = new Trie(canUseWeakMap);
4647
- if (seed)
4648
- _this.replace(seed);
4649
- return _this;
4650
- }
4651
- Root2.prototype.addLayer = function(layerId, replay) {
4652
- return this.stump.addLayer(layerId, replay);
4653
- };
4654
- Root2.prototype.removeLayer = function() {
4655
- return this;
4656
- };
4657
- Root2.prototype.getStorage = function() {
4658
- return this.storageTrie.lookupArray(arguments);
4659
- };
4660
- return Root2;
4661
- }(EntityStore2);
4662
- EntityStore2.Root = Root;
4663
- })(EntityStore || (EntityStore = {}));
4664
- var Layer = function(_super) {
4665
- __extends(Layer2, _super);
4666
- function Layer2(id, parent, replay, group) {
4667
- var _this = _super.call(this, parent.policies, group) || this;
4668
- _this.id = id;
4669
- _this.parent = parent;
4670
- _this.replay = replay;
4671
- _this.group = group;
4672
- replay(_this);
4673
- return _this;
4674
- }
4675
- Layer2.prototype.addLayer = function(layerId, replay) {
4676
- return new Layer2(layerId, this, replay, this.group);
4677
- };
4678
- Layer2.prototype.removeLayer = function(layerId) {
4679
- var _this = this;
4680
- var parent = this.parent.removeLayer(layerId);
4681
- if (layerId === this.id) {
4682
- if (this.group.caching) {
4683
- Object.keys(this.data).forEach(function(dataId) {
4684
- var ownStoreObject = _this.data[dataId];
4685
- var parentStoreObject = parent["lookup"](dataId);
4686
- if (!parentStoreObject) {
4687
- _this.delete(dataId);
4688
- } else if (!ownStoreObject) {
4689
- _this.group.dirty(dataId, "__exists");
4690
- Object.keys(parentStoreObject).forEach(function(storeFieldName) {
4691
- _this.group.dirty(dataId, storeFieldName);
4692
- });
4693
- } else if (ownStoreObject !== parentStoreObject) {
4694
- Object.keys(ownStoreObject).forEach(function(storeFieldName) {
4695
- if (!equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
4696
- _this.group.dirty(dataId, storeFieldName);
4697
- }
4698
- });
4699
- }
4700
- });
4701
- }
4702
- return parent;
4703
- }
4704
- if (parent === this.parent)
4705
- return this;
4706
- return parent.addLayer(this.id, this.replay);
4707
- };
4708
- Layer2.prototype.toObject = function() {
4709
- return __assign(__assign({}, this.parent.toObject()), this.data);
4710
- };
4711
- Layer2.prototype.findChildRefIds = function(dataId) {
4712
- var fromParent = this.parent.findChildRefIds(dataId);
4713
- return hasOwn.call(this.data, dataId) ? __assign(__assign({}, fromParent), _super.prototype.findChildRefIds.call(this, dataId)) : fromParent;
4714
- };
4715
- Layer2.prototype.getStorage = function() {
4716
- var p = this.parent;
4717
- while (p.parent)
4718
- p = p.parent;
4719
- return p.getStorage.apply(p, arguments);
4720
- };
4721
- return Layer2;
4722
- }(EntityStore);
4723
- var Stump = function(_super) {
4724
- __extends(Stump2, _super);
4725
- function Stump2(root) {
4726
- return _super.call(this, "EntityStore.Stump", root, function() {
4727
- }, new CacheGroup(root.group.caching, root.group)) || this;
4728
- }
4729
- Stump2.prototype.removeLayer = function() {
4730
- return this;
4731
- };
4732
- Stump2.prototype.merge = function() {
4733
- return this.parent.merge.apply(this.parent, arguments);
4734
- };
4735
- return Stump2;
4736
- }(Layer);
4737
- function storeObjectReconciler(existingObject, incomingObject, property) {
4738
- var existingValue = existingObject[property];
4739
- var incomingValue = incomingObject[property];
4740
- return equal(existingValue, incomingValue) ? existingValue : incomingValue;
4741
- }
4742
- function supportsResultCaching(store) {
4743
- return !!(store instanceof EntityStore && store.group.caching);
4744
- }
4745
- function shallowCopy(value) {
4746
- if (isNonNullObject(value)) {
4747
- return Array.isArray(value) ? value.slice(0) : __assign({ __proto__: Object.getPrototypeOf(value) }, value);
4748
- }
4749
- return value;
4750
- }
4751
- var ObjectCanon = function() {
4752
- function ObjectCanon2() {
4753
- this.known = new (canUseWeakSet ? WeakSet : Set)();
4754
- this.pool = new Trie(canUseWeakMap);
4755
- this.passes = new WeakMap();
4756
- this.keysByJSON = new Map();
4757
- this.empty = this.admit({});
4758
- }
4759
- ObjectCanon2.prototype.isKnown = function(value) {
4760
- return isNonNullObject(value) && this.known.has(value);
4761
- };
4762
- ObjectCanon2.prototype.pass = function(value) {
4763
- if (isNonNullObject(value)) {
4764
- var copy = shallowCopy(value);
4765
- this.passes.set(copy, value);
4766
- return copy;
4767
- }
4768
- return value;
4769
- };
4770
- ObjectCanon2.prototype.admit = function(value) {
4771
- var _this = this;
4772
- if (isNonNullObject(value)) {
4773
- var original = this.passes.get(value);
4774
- if (original)
4775
- return original;
4776
- var proto = Object.getPrototypeOf(value);
4777
- switch (proto) {
4778
- case Array.prototype: {
4779
- if (this.known.has(value))
4780
- return value;
4781
- var array = value.map(this.admit, this);
4782
- var node = this.pool.lookupArray(array);
4783
- if (!node.array) {
4784
- this.known.add(node.array = array);
4785
- if (__DEV__) {
4786
- Object.freeze(array);
4787
- }
4788
- }
4789
- return node.array;
4790
- }
4791
- case null:
4792
- case Object.prototype: {
4793
- if (this.known.has(value))
4794
- return value;
4795
- var proto_1 = Object.getPrototypeOf(value);
4796
- var array_1 = [proto_1];
4797
- var keys = this.sortedKeys(value);
4798
- array_1.push(keys.json);
4799
- var firstValueIndex_1 = array_1.length;
4800
- keys.sorted.forEach(function(key) {
4801
- array_1.push(_this.admit(value[key]));
4802
- });
4803
- var node = this.pool.lookupArray(array_1);
4804
- if (!node.object) {
4805
- var obj_1 = node.object = Object.create(proto_1);
4806
- this.known.add(obj_1);
4807
- keys.sorted.forEach(function(key, i) {
4808
- obj_1[key] = array_1[firstValueIndex_1 + i];
4809
- });
4810
- if (__DEV__) {
4811
- Object.freeze(obj_1);
4812
- }
4813
- }
4814
- return node.object;
4815
- }
4816
- }
4817
- }
4818
- return value;
4819
- };
4820
- ObjectCanon2.prototype.sortedKeys = function(obj) {
4821
- var keys = Object.keys(obj);
4822
- var node = this.pool.lookupArray(keys);
4823
- if (!node.keys) {
4824
- keys.sort();
4825
- var json = JSON.stringify(keys);
4826
- if (!(node.keys = this.keysByJSON.get(json))) {
4827
- this.keysByJSON.set(json, node.keys = { sorted: keys, json });
4828
- }
4829
- }
4830
- return node.keys;
4831
- };
4832
- return ObjectCanon2;
4833
- }();
4834
- var canonicalStringify = Object.assign(function(value) {
4835
- if (isNonNullObject(value)) {
4836
- if (stringifyCanon === void 0) {
4837
- resetCanonicalStringify();
4838
- }
4839
- var canonical = stringifyCanon.admit(value);
4840
- var json = stringifyCache.get(canonical);
4841
- if (json === void 0) {
4842
- stringifyCache.set(canonical, json = JSON.stringify(canonical));
4843
- }
4844
- return json;
4845
- }
4846
- return JSON.stringify(value);
4847
- }, {
4848
- reset: resetCanonicalStringify
4849
- });
4850
- var stringifyCanon;
4851
- var stringifyCache;
4852
- function resetCanonicalStringify() {
4853
- stringifyCanon = new ObjectCanon();
4854
- stringifyCache = new (canUseWeakMap ? WeakMap : Map)();
4855
- }
4856
- function execSelectionSetKeyArgs(options) {
4857
- return [
4858
- options.selectionSet,
4859
- options.objectOrReference,
4860
- options.context,
4861
- options.context.canonizeResults
4862
- ];
4863
- }
4864
- var StoreReader = function() {
4865
- function StoreReader2(config) {
4866
- var _this = this;
4867
- this.knownResults = new (canUseWeakMap ? WeakMap : Map)();
4868
- this.config = compact(config, {
4869
- addTypename: config.addTypename !== false,
4870
- canonizeResults: shouldCanonizeResults(config)
4871
- });
4872
- this.canon = config.canon || new ObjectCanon();
4873
- this.executeSelectionSet = wrap(function(options) {
4874
- var _a2;
4875
- var canonizeResults = options.context.canonizeResults;
4876
- var peekArgs = execSelectionSetKeyArgs(options);
4877
- peekArgs[3] = !canonizeResults;
4878
- var other = (_a2 = _this.executeSelectionSet).peek.apply(_a2, peekArgs);
4879
- if (other) {
4880
- if (canonizeResults) {
4881
- return __assign(__assign({}, other), { result: _this.canon.admit(other.result) });
4882
- }
4883
- return other;
4884
- }
4885
- maybeDependOnExistenceOfEntity(options.context.store, options.enclosingRef.__ref);
4886
- return _this.execSelectionSetImpl(options);
4887
- }, {
4888
- max: this.config.resultCacheMaxSize,
4889
- keyArgs: execSelectionSetKeyArgs,
4890
- makeCacheKey: function(selectionSet, parent, context, canonizeResults) {
4891
- if (supportsResultCaching(context.store)) {
4892
- return context.store.makeCacheKey(selectionSet, isReference(parent) ? parent.__ref : parent, context.varString, canonizeResults);
4893
- }
4894
- }
4895
- });
4896
- this.executeSubSelectedArray = wrap(function(options) {
4897
- maybeDependOnExistenceOfEntity(options.context.store, options.enclosingRef.__ref);
4898
- return _this.execSubSelectedArrayImpl(options);
4899
- }, {
4900
- max: this.config.resultCacheMaxSize,
4901
- makeCacheKey: function(_a2) {
4902
- var field = _a2.field, array = _a2.array, context = _a2.context;
4903
- if (supportsResultCaching(context.store)) {
4904
- return context.store.makeCacheKey(field, array, context.varString);
4905
- }
4906
- }
4907
- });
4908
- }
4909
- StoreReader2.prototype.resetCanon = function() {
4910
- this.canon = new ObjectCanon();
4911
- };
4912
- StoreReader2.prototype.diffQueryAgainstStore = function(_a2) {
4913
- var store = _a2.store, query = _a2.query, _b = _a2.rootId, rootId = _b === void 0 ? "ROOT_QUERY" : _b, variables = _a2.variables, _c = _a2.returnPartialData, returnPartialData = _c === void 0 ? true : _c, _d = _a2.canonizeResults, canonizeResults = _d === void 0 ? this.config.canonizeResults : _d;
4914
- var policies = this.config.cache.policies;
4915
- variables = __assign(__assign({}, getDefaultValues(getQueryDefinition(query))), variables);
4916
- var rootRef = makeReference(rootId);
4917
- var merger = new DeepMerger();
4918
- var execResult = this.executeSelectionSet({
4919
- selectionSet: getMainDefinition(query).selectionSet,
4920
- objectOrReference: rootRef,
4921
- enclosingRef: rootRef,
4922
- context: {
4923
- store,
4924
- query,
4925
- policies,
4926
- variables,
4927
- varString: canonicalStringify(variables),
4928
- canonizeResults,
4929
- fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
4930
- merge: function(a, b) {
4931
- return merger.merge(a, b);
4932
- }
4933
- }
4934
- });
4935
- var missing;
4936
- if (execResult.missing) {
4937
- missing = [new MissingFieldError(firstMissing(execResult.missing), execResult.missing, query, variables)];
4938
- if (!returnPartialData) {
4939
- throw missing[0];
4940
- }
4941
- }
4942
- return {
4943
- result: execResult.result,
4944
- complete: !missing,
4945
- missing
4946
- };
4947
- };
4948
- StoreReader2.prototype.isFresh = function(result, parent, selectionSet, context) {
4949
- if (supportsResultCaching(context.store) && this.knownResults.get(result) === selectionSet) {
4950
- var latest = this.executeSelectionSet.peek(selectionSet, parent, context, this.canon.isKnown(result));
4951
- if (latest && result === latest.result) {
4952
- return true;
4953
- }
4954
- }
4955
- return false;
4956
- };
4957
- StoreReader2.prototype.execSelectionSetImpl = function(_a2) {
4958
- var _this = this;
4959
- var selectionSet = _a2.selectionSet, objectOrReference = _a2.objectOrReference, enclosingRef = _a2.enclosingRef, context = _a2.context;
4960
- if (isReference(objectOrReference) && !context.policies.rootTypenamesById[objectOrReference.__ref] && !context.store.has(objectOrReference.__ref)) {
4961
- return {
4962
- result: this.canon.empty,
4963
- missing: "Dangling reference to missing ".concat(objectOrReference.__ref, " object")
4964
- };
4965
- }
4966
- var variables = context.variables, policies = context.policies, store = context.store;
4967
- var typename = store.getFieldValue(objectOrReference, "__typename");
4968
- var result = {};
4969
- var missing;
4970
- if (this.config.addTypename && typeof typename === "string" && !policies.rootIdsByTypename[typename]) {
4971
- result = { __typename: typename };
4972
- }
4973
- function handleMissing(result2, resultName) {
4974
- var _a3;
4975
- if (result2.missing) {
4976
- missing = context.merge(missing, (_a3 = {}, _a3[resultName] = result2.missing, _a3));
4977
- }
4978
- return result2.result;
4979
- }
4980
- var workSet = new Set(selectionSet.selections);
4981
- workSet.forEach(function(selection) {
4982
- var _a3, _b;
4983
- if (!shouldInclude(selection, variables))
4984
- return;
4985
- if (isField(selection)) {
4986
- var fieldValue = policies.readField({
4987
- fieldName: selection.name.value,
4988
- field: selection,
4989
- variables: context.variables,
4990
- from: objectOrReference
4991
- }, context);
4992
- var resultName = resultKeyNameFromField(selection);
4993
- if (fieldValue === void 0) {
4994
- if (!addTypenameToDocument.added(selection)) {
4995
- missing = context.merge(missing, (_a3 = {}, _a3[resultName] = "Can't find field '".concat(selection.name.value, "' on ").concat(isReference(objectOrReference) ? objectOrReference.__ref + " object" : "object " + JSON.stringify(objectOrReference, null, 2)), _a3));
4996
- }
4997
- } else if (Array.isArray(fieldValue)) {
4998
- fieldValue = handleMissing(_this.executeSubSelectedArray({
4999
- field: selection,
5000
- array: fieldValue,
5001
- enclosingRef,
5002
- context
5003
- }), resultName);
5004
- } else if (!selection.selectionSet) {
5005
- if (context.canonizeResults) {
5006
- fieldValue = _this.canon.pass(fieldValue);
5007
- }
5008
- } else if (fieldValue != null) {
5009
- fieldValue = handleMissing(_this.executeSelectionSet({
5010
- selectionSet: selection.selectionSet,
5011
- objectOrReference: fieldValue,
5012
- enclosingRef: isReference(fieldValue) ? fieldValue : enclosingRef,
5013
- context
5014
- }), resultName);
5015
- }
5016
- if (fieldValue !== void 0) {
5017
- result = context.merge(result, (_b = {}, _b[resultName] = fieldValue, _b));
5018
- }
5019
- } else {
5020
- var fragment = getFragmentFromSelection(selection, context.fragmentMap);
5021
- if (fragment && policies.fragmentMatches(fragment, typename)) {
5022
- fragment.selectionSet.selections.forEach(workSet.add, workSet);
5023
- }
5024
- }
5025
- });
5026
- var finalResult = { result, missing };
5027
- var frozen = context.canonizeResults ? this.canon.admit(finalResult) : maybeDeepFreeze(finalResult);
5028
- if (frozen.result) {
5029
- this.knownResults.set(frozen.result, selectionSet);
5030
- }
5031
- return frozen;
5032
- };
5033
- StoreReader2.prototype.execSubSelectedArrayImpl = function(_a2) {
5034
- var _this = this;
5035
- var field = _a2.field, array = _a2.array, enclosingRef = _a2.enclosingRef, context = _a2.context;
5036
- var missing;
5037
- function handleMissing(childResult, i) {
5038
- var _a3;
5039
- if (childResult.missing) {
5040
- missing = context.merge(missing, (_a3 = {}, _a3[i] = childResult.missing, _a3));
5041
- }
5042
- return childResult.result;
5043
- }
5044
- if (field.selectionSet) {
5045
- array = array.filter(context.store.canRead);
5046
- }
5047
- array = array.map(function(item, i) {
5048
- if (item === null) {
5049
- return null;
5050
- }
5051
- if (Array.isArray(item)) {
5052
- return handleMissing(_this.executeSubSelectedArray({
5053
- field,
5054
- array: item,
5055
- enclosingRef,
5056
- context
5057
- }), i);
5058
- }
5059
- if (field.selectionSet) {
5060
- return handleMissing(_this.executeSelectionSet({
5061
- selectionSet: field.selectionSet,
5062
- objectOrReference: item,
5063
- enclosingRef: isReference(item) ? item : enclosingRef,
5064
- context
5065
- }), i);
5066
- }
5067
- if (__DEV__) {
5068
- assertSelectionSetForIdValue(context.store, field, item);
5069
- }
5070
- return item;
5071
- });
5072
- return {
5073
- result: context.canonizeResults ? this.canon.admit(array) : array,
5074
- missing
5075
- };
5076
- };
5077
- return StoreReader2;
5078
- }();
5079
- function firstMissing(tree) {
5080
- try {
5081
- JSON.stringify(tree, function(_, value) {
5082
- if (typeof value === "string")
5083
- throw value;
5084
- return value;
5085
- });
5086
- } catch (result) {
5087
- return result;
5088
- }
5089
- }
5090
- function assertSelectionSetForIdValue(store, field, fieldValue) {
5091
- if (!field.selectionSet) {
5092
- var workSet_1 = new Set([fieldValue]);
5093
- workSet_1.forEach(function(value) {
5094
- if (isNonNullObject(value)) {
5095
- __DEV__ ? invariant(!isReference(value), "Missing selection set for object of type ".concat(getTypenameFromStoreObject(store, value), " returned for query field ").concat(field.name.value)) : invariant(!isReference(value), 5);
5096
- Object.values(value).forEach(workSet_1.add, workSet_1);
5097
- }
5098
- });
5099
- }
5100
- }
5101
- var cacheSlot = new Slot();
5102
- var cacheInfoMap = new WeakMap();
5103
- function getCacheInfo(cache) {
5104
- var info = cacheInfoMap.get(cache);
5105
- if (!info) {
5106
- cacheInfoMap.set(cache, info = {
5107
- vars: new Set(),
5108
- dep: dep()
5109
- });
5110
- }
5111
- return info;
5112
- }
5113
- function forgetCache(cache) {
5114
- getCacheInfo(cache).vars.forEach(function(rv) {
5115
- return rv.forgetCache(cache);
5116
- });
5117
- }
5118
- function recallCache(cache) {
5119
- getCacheInfo(cache).vars.forEach(function(rv) {
5120
- return rv.attachCache(cache);
5121
- });
5122
- }
5123
- function makeVar(value) {
5124
- var caches2 = new Set();
5125
- var listeners = new Set();
5126
- var rv = function(newValue) {
5127
- if (arguments.length > 0) {
5128
- if (value !== newValue) {
5129
- value = newValue;
5130
- caches2.forEach(function(cache2) {
5131
- getCacheInfo(cache2).dep.dirty(rv);
5132
- broadcast(cache2);
5133
- });
5134
- var oldListeners = Array.from(listeners);
5135
- listeners.clear();
5136
- oldListeners.forEach(function(listener) {
5137
- return listener(value);
5138
- });
5139
- }
5140
- } else {
5141
- var cache = cacheSlot.getValue();
5142
- if (cache) {
5143
- attach(cache);
5144
- getCacheInfo(cache).dep(rv);
5145
- }
5146
- }
5147
- return value;
5148
- };
5149
- rv.onNextChange = function(listener) {
5150
- listeners.add(listener);
5151
- return function() {
5152
- listeners.delete(listener);
5153
- };
5154
- };
5155
- var attach = rv.attachCache = function(cache) {
5156
- caches2.add(cache);
5157
- getCacheInfo(cache).vars.add(rv);
5158
- return rv;
5159
- };
5160
- rv.forgetCache = function(cache) {
5161
- return caches2.delete(cache);
5162
- };
5163
- return rv;
5164
- }
5165
- function broadcast(cache) {
5166
- if (cache.broadcastWatches) {
5167
- cache.broadcastWatches();
5168
- }
5169
- }
5170
- var specifierInfoCache = Object.create(null);
5171
- function lookupSpecifierInfo(spec) {
5172
- var cacheKey = JSON.stringify(spec);
5173
- return specifierInfoCache[cacheKey] || (specifierInfoCache[cacheKey] = Object.create(null));
5174
- }
5175
- function keyFieldsFnFromSpecifier(specifier) {
5176
- var info = lookupSpecifierInfo(specifier);
5177
- return info.keyFieldsFn || (info.keyFieldsFn = function(object, context) {
5178
- var extract = function(from, key) {
5179
- return context.readField(key, from);
5180
- };
5181
- var keyObject = context.keyObject = collectSpecifierPaths(specifier, function(schemaKeyPath) {
5182
- var extracted = extractKeyPath(context.storeObject, schemaKeyPath, extract);
5183
- if (extracted === void 0 && object !== context.storeObject && hasOwn.call(object, schemaKeyPath[0])) {
5184
- extracted = extractKeyPath(object, schemaKeyPath, extractKey);
5185
- }
5186
- __DEV__ ? invariant(extracted !== void 0, "Missing field '".concat(schemaKeyPath.join("."), "' while extracting keyFields from ").concat(JSON.stringify(object))) : invariant(extracted !== void 0, 2);
5187
- return extracted;
5188
- });
5189
- return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
5190
- });
5191
- }
5192
- function keyArgsFnFromSpecifier(specifier) {
5193
- var info = lookupSpecifierInfo(specifier);
5194
- return info.keyArgsFn || (info.keyArgsFn = function(args, _a2) {
5195
- var field = _a2.field, variables = _a2.variables, fieldName = _a2.fieldName;
5196
- var collected = collectSpecifierPaths(specifier, function(keyPath) {
5197
- var firstKey = keyPath[0];
5198
- var firstChar = firstKey.charAt(0);
5199
- if (firstChar === "@") {
5200
- if (field && isNonEmptyArray(field.directives)) {
5201
- var directiveName_1 = firstKey.slice(1);
5202
- var d = field.directives.find(function(d2) {
5203
- return d2.name.value === directiveName_1;
5204
- });
5205
- var directiveArgs = d && argumentsObjectFromField(d, variables);
5206
- return directiveArgs && extractKeyPath(directiveArgs, keyPath.slice(1));
5207
- }
5208
- return;
5209
- }
5210
- if (firstChar === "$") {
5211
- var variableName = firstKey.slice(1);
5212
- if (variables && hasOwn.call(variables, variableName)) {
5213
- var varKeyPath = keyPath.slice(0);
5214
- varKeyPath[0] = variableName;
5215
- return extractKeyPath(variables, varKeyPath);
5216
- }
5217
- return;
5218
- }
5219
- if (args) {
5220
- return extractKeyPath(args, keyPath);
5221
- }
5222
- });
5223
- var suffix = JSON.stringify(collected);
5224
- if (args || suffix !== "{}") {
5225
- fieldName += ":" + suffix;
5226
- }
5227
- return fieldName;
5228
- });
5229
- }
5230
- function collectSpecifierPaths(specifier, extractor) {
5231
- var merger = new DeepMerger();
5232
- return getSpecifierPaths(specifier).reduce(function(collected, path2) {
5233
- var _a2;
5234
- var toMerge = extractor(path2);
5235
- if (toMerge !== void 0) {
5236
- for (var i = path2.length - 1; i >= 0; --i) {
5237
- toMerge = (_a2 = {}, _a2[path2[i]] = toMerge, _a2);
5238
- }
5239
- collected = merger.merge(collected, toMerge);
5240
- }
5241
- return collected;
5242
- }, Object.create(null));
5243
- }
5244
- function getSpecifierPaths(spec) {
5245
- var info = lookupSpecifierInfo(spec);
5246
- if (!info.paths) {
5247
- var paths_1 = info.paths = [];
5248
- var currentPath_1 = [];
5249
- spec.forEach(function(s, i) {
5250
- if (Array.isArray(s)) {
5251
- getSpecifierPaths(s).forEach(function(p) {
5252
- return paths_1.push(currentPath_1.concat(p));
5253
- });
5254
- currentPath_1.length = 0;
5255
- } else {
5256
- currentPath_1.push(s);
5257
- if (!Array.isArray(spec[i + 1])) {
5258
- paths_1.push(currentPath_1.slice(0));
5259
- currentPath_1.length = 0;
5260
- }
5261
- }
5262
- });
5263
- }
5264
- return info.paths;
5265
- }
5266
- function extractKey(object, key) {
5267
- return object[key];
5268
- }
5269
- function extractKeyPath(object, path2, extract) {
5270
- extract = extract || extractKey;
5271
- return normalize(path2.reduce(function reducer(obj, key) {
5272
- return Array.isArray(obj) ? obj.map(function(child) {
5273
- return reducer(child, key);
5274
- }) : obj && extract(obj, key);
5275
- }, object));
5276
- }
5277
- function normalize(value) {
5278
- if (isNonNullObject(value)) {
5279
- if (Array.isArray(value)) {
5280
- return value.map(normalize);
5281
- }
5282
- return collectSpecifierPaths(Object.keys(value).sort(), function(path2) {
5283
- return extractKeyPath(value, path2);
5284
- });
5285
- }
5286
- return value;
5287
- }
5288
- getStoreKeyName.setStringify(canonicalStringify);
5289
- function argsFromFieldSpecifier(spec) {
5290
- return spec.args !== void 0 ? spec.args : spec.field ? argumentsObjectFromField(spec.field, spec.variables) : null;
5291
- }
5292
- var nullKeyFieldsFn = function() {
5293
- return void 0;
5294
- };
5295
- var simpleKeyArgsFn = function(_args, context) {
5296
- return context.fieldName;
5297
- };
5298
- var mergeTrueFn = function(existing, incoming, _a2) {
5299
- var mergeObjects = _a2.mergeObjects;
5300
- return mergeObjects(existing, incoming);
5301
- };
5302
- var mergeFalseFn = function(_, incoming) {
5303
- return incoming;
5304
- };
5305
- var Policies = function() {
5306
- function Policies2(config) {
5307
- this.config = config;
5308
- this.typePolicies = Object.create(null);
5309
- this.toBeAdded = Object.create(null);
5310
- this.supertypeMap = new Map();
5311
- this.fuzzySubtypes = new Map();
5312
- this.rootIdsByTypename = Object.create(null);
5313
- this.rootTypenamesById = Object.create(null);
5314
- this.usingPossibleTypes = false;
5315
- this.config = __assign({ dataIdFromObject: defaultDataIdFromObject }, config);
5316
- this.cache = this.config.cache;
5317
- this.setRootTypename("Query");
5318
- this.setRootTypename("Mutation");
5319
- this.setRootTypename("Subscription");
5320
- if (config.possibleTypes) {
5321
- this.addPossibleTypes(config.possibleTypes);
5322
- }
5323
- if (config.typePolicies) {
5324
- this.addTypePolicies(config.typePolicies);
5325
- }
5326
- }
5327
- Policies2.prototype.identify = function(object, partialContext) {
5328
- var _a2;
5329
- var policies = this;
5330
- var typename = partialContext && (partialContext.typename || ((_a2 = partialContext.storeObject) === null || _a2 === void 0 ? void 0 : _a2.__typename)) || object.__typename;
5331
- if (typename === this.rootTypenamesById.ROOT_QUERY) {
5332
- return ["ROOT_QUERY"];
5333
- }
5334
- var storeObject = partialContext && partialContext.storeObject || object;
5335
- var context = __assign(__assign({}, partialContext), { typename, storeObject, readField: partialContext && partialContext.readField || function() {
5336
- var options = normalizeReadFieldOptions(arguments, storeObject);
5337
- return policies.readField(options, {
5338
- store: policies.cache["data"],
5339
- variables: options.variables
5340
- });
5341
- } });
5342
- var id;
5343
- var policy = typename && this.getTypePolicy(typename);
5344
- var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
5345
- while (keyFn) {
5346
- var specifierOrId = keyFn(object, context);
5347
- if (Array.isArray(specifierOrId)) {
5348
- keyFn = keyFieldsFnFromSpecifier(specifierOrId);
5349
- } else {
5350
- id = specifierOrId;
5351
- break;
5352
- }
5353
- }
5354
- id = id ? String(id) : void 0;
5355
- return context.keyObject ? [id, context.keyObject] : [id];
5356
- };
5357
- Policies2.prototype.addTypePolicies = function(typePolicies) {
5358
- var _this = this;
5359
- Object.keys(typePolicies).forEach(function(typename) {
5360
- var _a2 = typePolicies[typename], queryType = _a2.queryType, mutationType = _a2.mutationType, subscriptionType = _a2.subscriptionType, incoming = __rest(_a2, ["queryType", "mutationType", "subscriptionType"]);
5361
- if (queryType)
5362
- _this.setRootTypename("Query", typename);
5363
- if (mutationType)
5364
- _this.setRootTypename("Mutation", typename);
5365
- if (subscriptionType)
5366
- _this.setRootTypename("Subscription", typename);
5367
- if (hasOwn.call(_this.toBeAdded, typename)) {
5368
- _this.toBeAdded[typename].push(incoming);
5369
- } else {
5370
- _this.toBeAdded[typename] = [incoming];
5371
- }
5372
- });
5373
- };
5374
- Policies2.prototype.updateTypePolicy = function(typename, incoming) {
5375
- var _this = this;
5376
- var existing = this.getTypePolicy(typename);
5377
- var keyFields = incoming.keyFields, fields = incoming.fields;
5378
- function setMerge(existing2, merge) {
5379
- existing2.merge = typeof merge === "function" ? merge : merge === true ? mergeTrueFn : merge === false ? mergeFalseFn : existing2.merge;
5380
- }
5381
- setMerge(existing, incoming.merge);
5382
- existing.keyFn = keyFields === false ? nullKeyFieldsFn : Array.isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields) : typeof keyFields === "function" ? keyFields : existing.keyFn;
5383
- if (fields) {
5384
- Object.keys(fields).forEach(function(fieldName) {
5385
- var existing2 = _this.getFieldPolicy(typename, fieldName, true);
5386
- var incoming2 = fields[fieldName];
5387
- if (typeof incoming2 === "function") {
5388
- existing2.read = incoming2;
5389
- } else {
5390
- var keyArgs = incoming2.keyArgs, read = incoming2.read, merge = incoming2.merge;
5391
- existing2.keyFn = keyArgs === false ? simpleKeyArgsFn : Array.isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) : typeof keyArgs === "function" ? keyArgs : existing2.keyFn;
5392
- if (typeof read === "function") {
5393
- existing2.read = read;
5394
- }
5395
- setMerge(existing2, merge);
5396
- }
5397
- if (existing2.read && existing2.merge) {
5398
- existing2.keyFn = existing2.keyFn || simpleKeyArgsFn;
5399
- }
5400
- });
5401
- }
5402
- };
5403
- Policies2.prototype.setRootTypename = function(which, typename) {
5404
- if (typename === void 0) {
5405
- typename = which;
5406
- }
5407
- var rootId = "ROOT_" + which.toUpperCase();
5408
- var old = this.rootTypenamesById[rootId];
5409
- if (typename !== old) {
5410
- __DEV__ ? invariant(!old || old === which, "Cannot change root ".concat(which, " __typename more than once")) : invariant(!old || old === which, 3);
5411
- if (old)
5412
- delete this.rootIdsByTypename[old];
5413
- this.rootIdsByTypename[typename] = rootId;
5414
- this.rootTypenamesById[rootId] = typename;
5415
- }
5416
- };
5417
- Policies2.prototype.addPossibleTypes = function(possibleTypes) {
5418
- var _this = this;
5419
- this.usingPossibleTypes = true;
5420
- Object.keys(possibleTypes).forEach(function(supertype) {
5421
- _this.getSupertypeSet(supertype, true);
5422
- possibleTypes[supertype].forEach(function(subtype) {
5423
- _this.getSupertypeSet(subtype, true).add(supertype);
5424
- var match = subtype.match(TypeOrFieldNameRegExp);
5425
- if (!match || match[0] !== subtype) {
5426
- _this.fuzzySubtypes.set(subtype, new RegExp(subtype));
5427
- }
5428
- });
5429
- });
5430
- };
5431
- Policies2.prototype.getTypePolicy = function(typename) {
5432
- var _this = this;
5433
- if (!hasOwn.call(this.typePolicies, typename)) {
5434
- var policy_1 = this.typePolicies[typename] = Object.create(null);
5435
- policy_1.fields = Object.create(null);
5436
- var supertypes = this.supertypeMap.get(typename);
5437
- if (supertypes && supertypes.size) {
5438
- supertypes.forEach(function(supertype) {
5439
- var _a2 = _this.getTypePolicy(supertype), fields = _a2.fields, rest = __rest(_a2, ["fields"]);
5440
- Object.assign(policy_1, rest);
5441
- Object.assign(policy_1.fields, fields);
5442
- });
5443
- }
5444
- }
5445
- var inbox = this.toBeAdded[typename];
5446
- if (inbox && inbox.length) {
5447
- inbox.splice(0).forEach(function(policy) {
5448
- _this.updateTypePolicy(typename, policy);
5449
- });
5450
- }
5451
- return this.typePolicies[typename];
5452
- };
5453
- Policies2.prototype.getFieldPolicy = function(typename, fieldName, createIfMissing) {
5454
- if (typename) {
5455
- var fieldPolicies = this.getTypePolicy(typename).fields;
5456
- return fieldPolicies[fieldName] || createIfMissing && (fieldPolicies[fieldName] = Object.create(null));
5457
- }
5458
- };
5459
- Policies2.prototype.getSupertypeSet = function(subtype, createIfMissing) {
5460
- var supertypeSet = this.supertypeMap.get(subtype);
5461
- if (!supertypeSet && createIfMissing) {
5462
- this.supertypeMap.set(subtype, supertypeSet = new Set());
5463
- }
5464
- return supertypeSet;
5465
- };
5466
- Policies2.prototype.fragmentMatches = function(fragment, typename, result, variables) {
5467
- var _this = this;
5468
- if (!fragment.typeCondition)
5469
- return true;
5470
- if (!typename)
5471
- return false;
5472
- var supertype = fragment.typeCondition.name.value;
5473
- if (typename === supertype)
5474
- return true;
5475
- if (this.usingPossibleTypes && this.supertypeMap.has(supertype)) {
5476
- var typenameSupertypeSet = this.getSupertypeSet(typename, true);
5477
- var workQueue_1 = [typenameSupertypeSet];
5478
- var maybeEnqueue_1 = function(subtype) {
5479
- var supertypeSet2 = _this.getSupertypeSet(subtype, false);
5480
- if (supertypeSet2 && supertypeSet2.size && workQueue_1.indexOf(supertypeSet2) < 0) {
5481
- workQueue_1.push(supertypeSet2);
5482
- }
5483
- };
5484
- var needToCheckFuzzySubtypes = !!(result && this.fuzzySubtypes.size);
5485
- var checkingFuzzySubtypes = false;
5486
- for (var i = 0; i < workQueue_1.length; ++i) {
5487
- var supertypeSet = workQueue_1[i];
5488
- if (supertypeSet.has(supertype)) {
5489
- if (!typenameSupertypeSet.has(supertype)) {
5490
- if (checkingFuzzySubtypes) {
5491
- __DEV__ && invariant.warn("Inferring subtype ".concat(typename, " of supertype ").concat(supertype));
5492
- }
5493
- typenameSupertypeSet.add(supertype);
5494
- }
5495
- return true;
5496
- }
5497
- supertypeSet.forEach(maybeEnqueue_1);
5498
- if (needToCheckFuzzySubtypes && i === workQueue_1.length - 1 && selectionSetMatchesResult(fragment.selectionSet, result, variables)) {
5499
- needToCheckFuzzySubtypes = false;
5500
- checkingFuzzySubtypes = true;
5501
- this.fuzzySubtypes.forEach(function(regExp, fuzzyString) {
5502
- var match = typename.match(regExp);
5503
- if (match && match[0] === typename) {
5504
- maybeEnqueue_1(fuzzyString);
5505
- }
5506
- });
5507
- }
5508
- }
5509
- }
5510
- return false;
5511
- };
5512
- Policies2.prototype.hasKeyArgs = function(typename, fieldName) {
5513
- var policy = this.getFieldPolicy(typename, fieldName, false);
5514
- return !!(policy && policy.keyFn);
5515
- };
5516
- Policies2.prototype.getStoreFieldName = function(fieldSpec) {
5517
- var typename = fieldSpec.typename, fieldName = fieldSpec.fieldName;
5518
- var policy = this.getFieldPolicy(typename, fieldName, false);
5519
- var storeFieldName;
5520
- var keyFn = policy && policy.keyFn;
5521
- if (keyFn && typename) {
5522
- var context = {
5523
- typename,
5524
- fieldName,
5525
- field: fieldSpec.field || null,
5526
- variables: fieldSpec.variables
5527
- };
5528
- var args = argsFromFieldSpecifier(fieldSpec);
5529
- while (keyFn) {
5530
- var specifierOrString = keyFn(args, context);
5531
- if (Array.isArray(specifierOrString)) {
5532
- keyFn = keyArgsFnFromSpecifier(specifierOrString);
5533
- } else {
5534
- storeFieldName = specifierOrString || fieldName;
5535
- break;
5536
- }
5537
- }
5538
- }
5539
- if (storeFieldName === void 0) {
5540
- storeFieldName = fieldSpec.field ? storeKeyNameFromField(fieldSpec.field, fieldSpec.variables) : getStoreKeyName(fieldName, argsFromFieldSpecifier(fieldSpec));
5541
- }
5542
- if (storeFieldName === false) {
5543
- return fieldName;
5544
- }
5545
- return fieldName === fieldNameFromStoreName(storeFieldName) ? storeFieldName : fieldName + ":" + storeFieldName;
5546
- };
5547
- Policies2.prototype.readField = function(options, context) {
5548
- var objectOrReference = options.from;
5549
- if (!objectOrReference)
5550
- return;
5551
- var nameOrField = options.field || options.fieldName;
5552
- if (!nameOrField)
5553
- return;
5554
- if (options.typename === void 0) {
5555
- var typename = context.store.getFieldValue(objectOrReference, "__typename");
5556
- if (typename)
5557
- options.typename = typename;
5558
- }
5559
- var storeFieldName = this.getStoreFieldName(options);
5560
- var fieldName = fieldNameFromStoreName(storeFieldName);
5561
- var existing = context.store.getFieldValue(objectOrReference, storeFieldName);
5562
- var policy = this.getFieldPolicy(options.typename, fieldName, false);
5563
- var read = policy && policy.read;
5564
- if (read) {
5565
- var readOptions = makeFieldFunctionOptions(this, objectOrReference, options, context, context.store.getStorage(isReference(objectOrReference) ? objectOrReference.__ref : objectOrReference, storeFieldName));
5566
- return cacheSlot.withValue(this.cache, read, [existing, readOptions]);
5567
- }
5568
- return existing;
5569
- };
5570
- Policies2.prototype.getReadFunction = function(typename, fieldName) {
5571
- var policy = this.getFieldPolicy(typename, fieldName, false);
5572
- return policy && policy.read;
5573
- };
5574
- Policies2.prototype.getMergeFunction = function(parentTypename, fieldName, childTypename) {
5575
- var policy = this.getFieldPolicy(parentTypename, fieldName, false);
5576
- var merge = policy && policy.merge;
5577
- if (!merge && childTypename) {
5578
- policy = this.getTypePolicy(childTypename);
5579
- merge = policy && policy.merge;
5580
- }
5581
- return merge;
5582
- };
5583
- Policies2.prototype.runMergeFunction = function(existing, incoming, _a2, context, storage) {
5584
- var field = _a2.field, typename = _a2.typename, merge = _a2.merge;
5585
- if (merge === mergeTrueFn) {
5586
- return makeMergeObjectsFunction(context.store)(existing, incoming);
5587
- }
5588
- if (merge === mergeFalseFn) {
5589
- return incoming;
5590
- }
5591
- if (context.overwrite) {
5592
- existing = void 0;
5593
- }
5594
- return merge(existing, incoming, makeFieldFunctionOptions(this, void 0, { typename, fieldName: field.name.value, field, variables: context.variables }, context, storage || Object.create(null)));
5595
- };
5596
- return Policies2;
5597
- }();
5598
- function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, context, storage) {
5599
- var storeFieldName = policies.getStoreFieldName(fieldSpec);
5600
- var fieldName = fieldNameFromStoreName(storeFieldName);
5601
- var variables = fieldSpec.variables || context.variables;
5602
- var _a2 = context.store, toReference = _a2.toReference, canRead = _a2.canRead;
5603
- return {
5604
- args: argsFromFieldSpecifier(fieldSpec),
5605
- field: fieldSpec.field || null,
5606
- fieldName,
5607
- storeFieldName,
5608
- variables,
5609
- isReference,
5610
- toReference,
5611
- storage,
5612
- cache: policies.cache,
5613
- canRead,
5614
- readField: function() {
5615
- return policies.readField(normalizeReadFieldOptions(arguments, objectOrReference, context), context);
5616
- },
5617
- mergeObjects: makeMergeObjectsFunction(context.store)
5618
- };
5619
- }
5620
- function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables) {
5621
- var fieldNameOrOptions = readFieldArgs[0], from = readFieldArgs[1], argc = readFieldArgs.length;
5622
- var options;
5623
- if (typeof fieldNameOrOptions === "string") {
5624
- options = {
5625
- fieldName: fieldNameOrOptions,
5626
- from: argc > 1 ? from : objectOrReference
5627
- };
5628
- } else {
5629
- options = __assign({}, fieldNameOrOptions);
5630
- if (!hasOwn.call(options, "from")) {
5631
- options.from = objectOrReference;
5632
- }
5633
- }
5634
- if (__DEV__ && options.from === void 0) {
5635
- __DEV__ && invariant.warn("Undefined 'from' passed to readField with arguments ".concat(stringifyForDisplay(Array.from(readFieldArgs))));
5636
- }
5637
- if (options.variables === void 0) {
5638
- options.variables = variables;
5639
- }
5640
- return options;
5641
- }
5642
- function makeMergeObjectsFunction(store) {
5643
- return function mergeObjects(existing, incoming) {
5644
- if (Array.isArray(existing) || Array.isArray(incoming)) {
5645
- throw __DEV__ ? new InvariantError("Cannot automatically merge arrays") : new InvariantError(4);
5646
- }
5647
- if (isNonNullObject(existing) && isNonNullObject(incoming)) {
5648
- var eType = store.getFieldValue(existing, "__typename");
5649
- var iType = store.getFieldValue(incoming, "__typename");
5650
- var typesDiffer = eType && iType && eType !== iType;
5651
- if (typesDiffer) {
5652
- return incoming;
5653
- }
5654
- if (isReference(existing) && storeValueIsStoreObject(incoming)) {
5655
- store.merge(existing.__ref, incoming);
5656
- return existing;
5657
- }
5658
- if (storeValueIsStoreObject(existing) && isReference(incoming)) {
5659
- store.merge(existing, incoming.__ref);
5660
- return incoming;
5661
- }
5662
- if (storeValueIsStoreObject(existing) && storeValueIsStoreObject(incoming)) {
5663
- return __assign(__assign({}, existing), incoming);
5664
- }
5665
- }
5666
- return incoming;
5667
- };
5668
- }
5669
- function getContextFlavor(context, clientOnly, deferred) {
5670
- var key = "".concat(clientOnly).concat(deferred);
5671
- var flavored = context.flavors.get(key);
5672
- if (!flavored) {
5673
- context.flavors.set(key, flavored = context.clientOnly === clientOnly && context.deferred === deferred ? context : __assign(__assign({}, context), { clientOnly, deferred }));
5674
- }
5675
- return flavored;
5676
- }
5677
- var StoreWriter = function() {
5678
- function StoreWriter2(cache, reader) {
5679
- this.cache = cache;
5680
- this.reader = reader;
5681
- }
5682
- StoreWriter2.prototype.writeToStore = function(store, _a2) {
5683
- var _this = this;
5684
- var query = _a2.query, result = _a2.result, dataId = _a2.dataId, variables = _a2.variables, overwrite = _a2.overwrite;
5685
- var operationDefinition = getOperationDefinition(query);
5686
- var merger = makeProcessedFieldsMerger();
5687
- variables = __assign(__assign({}, getDefaultValues(operationDefinition)), variables);
5688
- var context = {
5689
- store,
5690
- written: Object.create(null),
5691
- merge: function(existing, incoming) {
5692
- return merger.merge(existing, incoming);
5693
- },
5694
- variables,
5695
- varString: canonicalStringify(variables),
5696
- fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
5697
- overwrite: !!overwrite,
5698
- incomingById: new Map(),
5699
- clientOnly: false,
5700
- deferred: false,
5701
- flavors: new Map()
5702
- };
5703
- var ref2 = this.processSelectionSet({
5704
- result: result || Object.create(null),
5705
- dataId,
5706
- selectionSet: operationDefinition.selectionSet,
5707
- mergeTree: { map: new Map() },
5708
- context
5709
- });
5710
- if (!isReference(ref2)) {
5711
- throw __DEV__ ? new InvariantError("Could not identify object ".concat(JSON.stringify(result))) : new InvariantError(6);
5712
- }
5713
- context.incomingById.forEach(function(_a3, dataId2) {
5714
- var storeObject = _a3.storeObject, mergeTree = _a3.mergeTree, fieldNodeSet = _a3.fieldNodeSet;
5715
- var entityRef = makeReference(dataId2);
5716
- if (mergeTree && mergeTree.map.size) {
5717
- var applied = _this.applyMerges(mergeTree, entityRef, storeObject, context);
5718
- if (isReference(applied)) {
5719
- return;
5720
- }
5721
- storeObject = applied;
5722
- }
5723
- if (__DEV__ && !context.overwrite) {
5724
- var fieldsWithSelectionSets_1 = Object.create(null);
5725
- fieldNodeSet.forEach(function(field) {
5726
- if (field.selectionSet) {
5727
- fieldsWithSelectionSets_1[field.name.value] = true;
5728
- }
5729
- });
5730
- var hasSelectionSet_1 = function(storeFieldName) {
5731
- return fieldsWithSelectionSets_1[fieldNameFromStoreName(storeFieldName)] === true;
5732
- };
5733
- var hasMergeFunction_1 = function(storeFieldName) {
5734
- var childTree = mergeTree && mergeTree.map.get(storeFieldName);
5735
- return Boolean(childTree && childTree.info && childTree.info.merge);
5736
- };
5737
- Object.keys(storeObject).forEach(function(storeFieldName) {
5738
- if (hasSelectionSet_1(storeFieldName) && !hasMergeFunction_1(storeFieldName)) {
5739
- warnAboutDataLoss(entityRef, storeObject, storeFieldName, context.store);
5740
- }
5741
- });
5742
- }
5743
- store.merge(dataId2, storeObject);
5744
- });
5745
- store.retain(ref2.__ref);
5746
- return ref2;
5747
- };
5748
- StoreWriter2.prototype.processSelectionSet = function(_a2) {
5749
- var _this = this;
5750
- var dataId = _a2.dataId, result = _a2.result, selectionSet = _a2.selectionSet, context = _a2.context, mergeTree = _a2.mergeTree;
5751
- var policies = this.cache.policies;
5752
- var incoming = Object.create(null);
5753
- var typename = dataId && policies.rootTypenamesById[dataId] || getTypenameFromResult(result, selectionSet, context.fragmentMap) || dataId && context.store.get(dataId, "__typename");
5754
- if (typeof typename === "string") {
5755
- incoming.__typename = typename;
5756
- }
5757
- var readField = function() {
5758
- var options = normalizeReadFieldOptions(arguments, incoming, context.variables);
5759
- if (isReference(options.from)) {
5760
- var info = context.incomingById.get(options.from.__ref);
5761
- if (info) {
5762
- var result_1 = policies.readField(__assign(__assign({}, options), { from: info.storeObject }), context);
5763
- if (result_1 !== void 0) {
5764
- return result_1;
5765
- }
5766
- }
5767
- }
5768
- return policies.readField(options, context);
5769
- };
5770
- var fieldNodeSet = new Set();
5771
- this.flattenFields(selectionSet, result, context, typename).forEach(function(context2, field) {
5772
- var _a3;
5773
- var resultFieldKey = resultKeyNameFromField(field);
5774
- var value = result[resultFieldKey];
5775
- fieldNodeSet.add(field);
5776
- if (value !== void 0) {
5777
- var storeFieldName = policies.getStoreFieldName({
5778
- typename,
5779
- fieldName: field.name.value,
5780
- field,
5781
- variables: context2.variables
5782
- });
5783
- var childTree = getChildMergeTree(mergeTree, storeFieldName);
5784
- var incomingValue = _this.processFieldValue(value, field, field.selectionSet ? getContextFlavor(context2, false, false) : context2, childTree);
5785
- var childTypename = void 0;
5786
- if (field.selectionSet && (isReference(incomingValue) || storeValueIsStoreObject(incomingValue))) {
5787
- childTypename = readField("__typename", incomingValue);
5788
- }
5789
- var merge = policies.getMergeFunction(typename, field.name.value, childTypename);
5790
- if (merge) {
5791
- childTree.info = {
5792
- field,
5793
- typename,
5794
- merge
5795
- };
5796
- } else {
5797
- maybeRecycleChildMergeTree(mergeTree, storeFieldName);
5798
- }
5799
- incoming = context2.merge(incoming, (_a3 = {}, _a3[storeFieldName] = incomingValue, _a3));
5800
- } else if (__DEV__ && !context2.clientOnly && !context2.deferred && !addTypenameToDocument.added(field) && !policies.getReadFunction(typename, field.name.value)) {
5801
- __DEV__ && invariant.error("Missing field '".concat(resultKeyNameFromField(field), "' while writing result ").concat(JSON.stringify(result, null, 2)).substring(0, 1e3));
5802
- }
5803
- });
5804
- try {
5805
- var _b = policies.identify(result, {
5806
- typename,
5807
- selectionSet,
5808
- fragmentMap: context.fragmentMap,
5809
- storeObject: incoming,
5810
- readField
5811
- }), id = _b[0], keyObject = _b[1];
5812
- dataId = dataId || id;
5813
- if (keyObject) {
5814
- incoming = context.merge(incoming, keyObject);
5815
- }
5816
- } catch (e) {
5817
- if (!dataId)
5818
- throw e;
5819
- }
5820
- if (typeof dataId === "string") {
5821
- var dataRef = makeReference(dataId);
5822
- var sets = context.written[dataId] || (context.written[dataId] = []);
5823
- if (sets.indexOf(selectionSet) >= 0)
5824
- return dataRef;
5825
- sets.push(selectionSet);
5826
- if (this.reader && this.reader.isFresh(result, dataRef, selectionSet, context)) {
5827
- return dataRef;
5828
- }
5829
- var previous_1 = context.incomingById.get(dataId);
5830
- if (previous_1) {
5831
- previous_1.storeObject = context.merge(previous_1.storeObject, incoming);
5832
- previous_1.mergeTree = mergeMergeTrees(previous_1.mergeTree, mergeTree);
5833
- fieldNodeSet.forEach(function(field) {
5834
- return previous_1.fieldNodeSet.add(field);
5835
- });
5836
- } else {
5837
- context.incomingById.set(dataId, {
5838
- storeObject: incoming,
5839
- mergeTree: mergeTreeIsEmpty(mergeTree) ? void 0 : mergeTree,
5840
- fieldNodeSet
5841
- });
5842
- }
5843
- return dataRef;
5844
- }
5845
- return incoming;
5846
- };
5847
- StoreWriter2.prototype.processFieldValue = function(value, field, context, mergeTree) {
5848
- var _this = this;
5849
- if (!field.selectionSet || value === null) {
5850
- return __DEV__ ? cloneDeep(value) : value;
5851
- }
5852
- if (Array.isArray(value)) {
5853
- return value.map(function(item, i) {
5854
- var value2 = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
5855
- maybeRecycleChildMergeTree(mergeTree, i);
5856
- return value2;
5857
- });
5858
- }
5859
- return this.processSelectionSet({
5860
- result: value,
5861
- selectionSet: field.selectionSet,
5862
- context,
5863
- mergeTree
5864
- });
5865
- };
5866
- StoreWriter2.prototype.flattenFields = function(selectionSet, result, context, typename) {
5867
- if (typename === void 0) {
5868
- typename = getTypenameFromResult(result, selectionSet, context.fragmentMap);
5869
- }
5870
- var fieldMap = new Map();
5871
- var policies = this.cache.policies;
5872
- var limitingTrie = new Trie(false);
5873
- (function flatten(selectionSet2, inheritedContext) {
5874
- var visitedNode = limitingTrie.lookup(selectionSet2, inheritedContext.clientOnly, inheritedContext.deferred);
5875
- if (visitedNode.visited)
5876
- return;
5877
- visitedNode.visited = true;
5878
- selectionSet2.selections.forEach(function(selection) {
5879
- if (!shouldInclude(selection, context.variables))
5880
- return;
5881
- var clientOnly = inheritedContext.clientOnly, deferred = inheritedContext.deferred;
5882
- if (!(clientOnly && deferred) && isNonEmptyArray(selection.directives)) {
5883
- selection.directives.forEach(function(dir) {
5884
- var name = dir.name.value;
5885
- if (name === "client")
5886
- clientOnly = true;
5887
- if (name === "defer") {
5888
- var args = argumentsObjectFromField(dir, context.variables);
5889
- if (!args || args.if !== false) {
5890
- deferred = true;
5891
- }
5892
- }
5893
- });
5894
- }
5895
- if (isField(selection)) {
5896
- var existing = fieldMap.get(selection);
5897
- if (existing) {
5898
- clientOnly = clientOnly && existing.clientOnly;
5899
- deferred = deferred && existing.deferred;
5900
- }
5901
- fieldMap.set(selection, getContextFlavor(context, clientOnly, deferred));
5902
- } else {
5903
- var fragment = getFragmentFromSelection(selection, context.fragmentMap);
5904
- if (fragment && policies.fragmentMatches(fragment, typename, result, context.variables)) {
5905
- flatten(fragment.selectionSet, getContextFlavor(context, clientOnly, deferred));
5906
- }
5907
- }
5908
- });
5909
- })(selectionSet, context);
5910
- return fieldMap;
5911
- };
5912
- StoreWriter2.prototype.applyMerges = function(mergeTree, existing, incoming, context, getStorageArgs) {
5913
- var _a2;
5914
- var _this = this;
5915
- if (mergeTree.map.size && !isReference(incoming)) {
5916
- var e_1 = !Array.isArray(incoming) && (isReference(existing) || storeValueIsStoreObject(existing)) ? existing : void 0;
5917
- var i_1 = incoming;
5918
- if (e_1 && !getStorageArgs) {
5919
- getStorageArgs = [isReference(e_1) ? e_1.__ref : e_1];
5920
- }
5921
- var changedFields_1;
5922
- var getValue_1 = function(from, name) {
5923
- return Array.isArray(from) ? typeof name === "number" ? from[name] : void 0 : context.store.getFieldValue(from, String(name));
5924
- };
5925
- mergeTree.map.forEach(function(childTree, storeFieldName) {
5926
- var eVal = getValue_1(e_1, storeFieldName);
5927
- var iVal = getValue_1(i_1, storeFieldName);
5928
- if (iVal === void 0)
5929
- return;
5930
- if (getStorageArgs) {
5931
- getStorageArgs.push(storeFieldName);
5932
- }
5933
- var aVal = _this.applyMerges(childTree, eVal, iVal, context, getStorageArgs);
5934
- if (aVal !== iVal) {
5935
- changedFields_1 = changedFields_1 || new Map();
5936
- changedFields_1.set(storeFieldName, aVal);
5937
- }
5938
- if (getStorageArgs) {
5939
- invariant(getStorageArgs.pop() === storeFieldName);
5940
- }
5941
- });
5942
- if (changedFields_1) {
5943
- incoming = Array.isArray(i_1) ? i_1.slice(0) : __assign({}, i_1);
5944
- changedFields_1.forEach(function(value, name) {
5945
- incoming[name] = value;
5946
- });
5947
- }
5948
- }
5949
- if (mergeTree.info) {
5950
- return this.cache.policies.runMergeFunction(existing, incoming, mergeTree.info, context, getStorageArgs && (_a2 = context.store).getStorage.apply(_a2, getStorageArgs));
5951
- }
5952
- return incoming;
5953
- };
5954
- return StoreWriter2;
5955
- }();
5956
- var emptyMergeTreePool = [];
5957
- function getChildMergeTree(_a2, name) {
5958
- var map = _a2.map;
5959
- if (!map.has(name)) {
5960
- map.set(name, emptyMergeTreePool.pop() || { map: new Map() });
5961
- }
5962
- return map.get(name);
5963
- }
5964
- function mergeMergeTrees(left, right) {
5965
- if (left === right || !right || mergeTreeIsEmpty(right))
5966
- return left;
5967
- if (!left || mergeTreeIsEmpty(left))
5968
- return right;
5969
- var info = left.info && right.info ? __assign(__assign({}, left.info), right.info) : left.info || right.info;
5970
- var needToMergeMaps = left.map.size && right.map.size;
5971
- var map = needToMergeMaps ? new Map() : left.map.size ? left.map : right.map;
5972
- var merged = { info, map };
5973
- if (needToMergeMaps) {
5974
- var remainingRightKeys_1 = new Set(right.map.keys());
5975
- left.map.forEach(function(leftTree, key) {
5976
- merged.map.set(key, mergeMergeTrees(leftTree, right.map.get(key)));
5977
- remainingRightKeys_1.delete(key);
5978
- });
5979
- remainingRightKeys_1.forEach(function(key) {
5980
- merged.map.set(key, mergeMergeTrees(right.map.get(key), left.map.get(key)));
5981
- });
5982
- }
5983
- return merged;
5984
- }
5985
- function mergeTreeIsEmpty(tree) {
5986
- return !tree || !(tree.info || tree.map.size);
5987
- }
5988
- function maybeRecycleChildMergeTree(_a2, name) {
5989
- var map = _a2.map;
5990
- var childTree = map.get(name);
5991
- if (childTree && mergeTreeIsEmpty(childTree)) {
5992
- emptyMergeTreePool.push(childTree);
5993
- map.delete(name);
5994
- }
5995
- }
5996
- var warnings = new Set();
5997
- function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
5998
- var getChild = function(objOrRef) {
5999
- var child = store.getFieldValue(objOrRef, storeFieldName);
6000
- return typeof child === "object" && child;
6001
- };
6002
- var existing = getChild(existingRef);
6003
- if (!existing)
6004
- return;
6005
- var incoming = getChild(incomingObj);
6006
- if (!incoming)
6007
- return;
6008
- if (isReference(existing))
6009
- return;
6010
- if (equal(existing, incoming))
6011
- return;
6012
- if (Object.keys(existing).every(function(key) {
6013
- return store.getFieldValue(incoming, key) !== void 0;
6014
- })) {
6015
- return;
6016
- }
6017
- var parentType = store.getFieldValue(existingRef, "__typename") || store.getFieldValue(incomingObj, "__typename");
6018
- var fieldName = fieldNameFromStoreName(storeFieldName);
6019
- var typeDotName = "".concat(parentType, ".").concat(fieldName);
6020
- if (warnings.has(typeDotName))
6021
- return;
6022
- warnings.add(typeDotName);
6023
- var childTypenames = [];
6024
- if (!Array.isArray(existing) && !Array.isArray(incoming)) {
6025
- [existing, incoming].forEach(function(child) {
6026
- var typename = store.getFieldValue(child, "__typename");
6027
- if (typeof typename === "string" && !childTypenames.includes(typename)) {
6028
- childTypenames.push(typename);
6029
- }
6030
- });
6031
- }
6032
- __DEV__ && invariant.warn("Cache data may be lost when replacing the ".concat(fieldName, " field of a ").concat(parentType, " object.\n\nTo address this problem (which is not a bug in Apollo Client), ").concat(childTypenames.length ? "either ensure all objects of type " + childTypenames.join(" and ") + " have an ID or a custom merge function, or " : "", "define a custom merge function for the ").concat(typeDotName, " field, so InMemoryCache can safely merge these objects:\n\n existing: ").concat(JSON.stringify(existing).slice(0, 1e3), "\n incoming: ").concat(JSON.stringify(incoming).slice(0, 1e3), "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n"));
6033
- }
6034
- var InMemoryCache = function(_super) {
6035
- __extends(InMemoryCache2, _super);
6036
- function InMemoryCache2(config) {
6037
- if (config === void 0) {
6038
- config = {};
6039
- }
6040
- var _this = _super.call(this) || this;
6041
- _this.watches = new Set();
6042
- _this.typenameDocumentCache = new Map();
6043
- _this.makeVar = makeVar;
6044
- _this.txCount = 0;
6045
- _this.config = normalizeConfig(config);
6046
- _this.addTypename = !!_this.config.addTypename;
6047
- _this.policies = new Policies({
6048
- cache: _this,
6049
- dataIdFromObject: _this.config.dataIdFromObject,
6050
- possibleTypes: _this.config.possibleTypes,
6051
- typePolicies: _this.config.typePolicies
6052
- });
6053
- _this.init();
6054
- return _this;
6055
- }
6056
- InMemoryCache2.prototype.init = function() {
6057
- var rootStore = this.data = new EntityStore.Root({
6058
- policies: this.policies,
6059
- resultCaching: this.config.resultCaching
6060
- });
6061
- this.optimisticData = rootStore.stump;
6062
- this.resetResultCache();
6063
- };
6064
- InMemoryCache2.prototype.resetResultCache = function(resetResultIdentities) {
6065
- var _this = this;
6066
- var previousReader = this.storeReader;
6067
- this.storeWriter = new StoreWriter(this, this.storeReader = new StoreReader({
6068
- cache: this,
6069
- addTypename: this.addTypename,
6070
- resultCacheMaxSize: this.config.resultCacheMaxSize,
6071
- canonizeResults: shouldCanonizeResults(this.config),
6072
- canon: resetResultIdentities ? void 0 : previousReader && previousReader.canon
6073
- }));
6074
- this.maybeBroadcastWatch = wrap(function(c, options) {
6075
- return _this.broadcastWatch(c, options);
6076
- }, {
6077
- max: this.config.resultCacheMaxSize,
6078
- makeCacheKey: function(c) {
6079
- var store = c.optimistic ? _this.optimisticData : _this.data;
6080
- if (supportsResultCaching(store)) {
6081
- var optimistic = c.optimistic, rootId = c.rootId, variables = c.variables;
6082
- return store.makeCacheKey(c.query, c.callback, canonicalStringify({ optimistic, rootId, variables }));
6083
- }
6084
- }
6085
- });
6086
- new Set([
6087
- this.data.group,
6088
- this.optimisticData.group
6089
- ]).forEach(function(group) {
6090
- return group.resetCaching();
6091
- });
6092
- };
6093
- InMemoryCache2.prototype.restore = function(data) {
6094
- this.init();
6095
- if (data)
6096
- this.data.replace(data);
6097
- return this;
6098
- };
6099
- InMemoryCache2.prototype.extract = function(optimistic) {
6100
- if (optimistic === void 0) {
6101
- optimistic = false;
6102
- }
6103
- return (optimistic ? this.optimisticData : this.data).extract();
6104
- };
6105
- InMemoryCache2.prototype.read = function(options) {
6106
- var _a2 = options.returnPartialData, returnPartialData = _a2 === void 0 ? false : _a2;
6107
- try {
6108
- return this.storeReader.diffQueryAgainstStore(__assign(__assign({}, options), { store: options.optimistic ? this.optimisticData : this.data, config: this.config, returnPartialData })).result || null;
6109
- } catch (e) {
6110
- if (e instanceof MissingFieldError) {
6111
- return null;
6112
- }
6113
- throw e;
6114
- }
6115
- };
6116
- InMemoryCache2.prototype.write = function(options) {
6117
- try {
6118
- ++this.txCount;
6119
- return this.storeWriter.writeToStore(this.data, options);
6120
- } finally {
6121
- if (!--this.txCount && options.broadcast !== false) {
6122
- this.broadcastWatches();
6123
- }
6124
- }
6125
- };
6126
- InMemoryCache2.prototype.modify = function(options) {
6127
- if (hasOwn.call(options, "id") && !options.id) {
6128
- return false;
6129
- }
6130
- var store = options.optimistic ? this.optimisticData : this.data;
6131
- try {
6132
- ++this.txCount;
6133
- return store.modify(options.id || "ROOT_QUERY", options.fields);
6134
- } finally {
6135
- if (!--this.txCount && options.broadcast !== false) {
6136
- this.broadcastWatches();
6137
- }
6138
- }
6139
- };
6140
- InMemoryCache2.prototype.diff = function(options) {
6141
- return this.storeReader.diffQueryAgainstStore(__assign(__assign({}, options), { store: options.optimistic ? this.optimisticData : this.data, rootId: options.id || "ROOT_QUERY", config: this.config }));
6142
- };
6143
- InMemoryCache2.prototype.watch = function(watch2) {
6144
- var _this = this;
6145
- if (!this.watches.size) {
6146
- recallCache(this);
6147
- }
6148
- this.watches.add(watch2);
6149
- if (watch2.immediate) {
6150
- this.maybeBroadcastWatch(watch2);
6151
- }
6152
- return function() {
6153
- if (_this.watches.delete(watch2) && !_this.watches.size) {
6154
- forgetCache(_this);
6155
- }
6156
- _this.maybeBroadcastWatch.forget(watch2);
6157
- };
6158
- };
6159
- InMemoryCache2.prototype.gc = function(options) {
6160
- canonicalStringify.reset();
6161
- var ids = this.optimisticData.gc();
6162
- if (options && !this.txCount) {
6163
- if (options.resetResultCache) {
6164
- this.resetResultCache(options.resetResultIdentities);
6165
- } else if (options.resetResultIdentities) {
6166
- this.storeReader.resetCanon();
6167
- }
6168
- }
6169
- return ids;
6170
- };
6171
- InMemoryCache2.prototype.retain = function(rootId, optimistic) {
6172
- return (optimistic ? this.optimisticData : this.data).retain(rootId);
6173
- };
6174
- InMemoryCache2.prototype.release = function(rootId, optimistic) {
6175
- return (optimistic ? this.optimisticData : this.data).release(rootId);
6176
- };
6177
- InMemoryCache2.prototype.identify = function(object) {
6178
- if (isReference(object))
6179
- return object.__ref;
6180
- try {
6181
- return this.policies.identify(object)[0];
6182
- } catch (e) {
6183
- __DEV__ && invariant.warn(e);
6184
- }
6185
- };
6186
- InMemoryCache2.prototype.evict = function(options) {
6187
- if (!options.id) {
6188
- if (hasOwn.call(options, "id")) {
6189
- return false;
6190
- }
6191
- options = __assign(__assign({}, options), { id: "ROOT_QUERY" });
6192
- }
6193
- try {
6194
- ++this.txCount;
6195
- return this.optimisticData.evict(options, this.data);
6196
- } finally {
6197
- if (!--this.txCount && options.broadcast !== false) {
6198
- this.broadcastWatches();
6199
- }
6200
- }
6201
- };
6202
- InMemoryCache2.prototype.reset = function(options) {
6203
- var _this = this;
6204
- this.init();
6205
- canonicalStringify.reset();
6206
- if (options && options.discardWatches) {
6207
- this.watches.forEach(function(watch2) {
6208
- return _this.maybeBroadcastWatch.forget(watch2);
6209
- });
6210
- this.watches.clear();
6211
- forgetCache(this);
6212
- } else {
6213
- this.broadcastWatches();
6214
- }
6215
- return Promise.resolve();
6216
- };
6217
- InMemoryCache2.prototype.removeOptimistic = function(idToRemove) {
6218
- var newOptimisticData = this.optimisticData.removeLayer(idToRemove);
6219
- if (newOptimisticData !== this.optimisticData) {
6220
- this.optimisticData = newOptimisticData;
6221
- this.broadcastWatches();
6222
- }
6223
- };
6224
- InMemoryCache2.prototype.batch = function(options) {
6225
- var _this = this;
6226
- var update = options.update, _a2 = options.optimistic, optimistic = _a2 === void 0 ? true : _a2, removeOptimistic = options.removeOptimistic, onWatchUpdated = options.onWatchUpdated;
6227
- var updateResult;
6228
- var perform = function(layer) {
6229
- var _a3 = _this, data = _a3.data, optimisticData = _a3.optimisticData;
6230
- ++_this.txCount;
6231
- if (layer) {
6232
- _this.data = _this.optimisticData = layer;
6233
- }
6234
- try {
6235
- return updateResult = update(_this);
6236
- } finally {
6237
- --_this.txCount;
6238
- _this.data = data;
6239
- _this.optimisticData = optimisticData;
6240
- }
6241
- };
6242
- var alreadyDirty = new Set();
6243
- if (onWatchUpdated && !this.txCount) {
6244
- this.broadcastWatches(__assign(__assign({}, options), { onWatchUpdated: function(watch2) {
6245
- alreadyDirty.add(watch2);
6246
- return false;
6247
- } }));
6248
- }
6249
- if (typeof optimistic === "string") {
6250
- this.optimisticData = this.optimisticData.addLayer(optimistic, perform);
6251
- } else if (optimistic === false) {
6252
- perform(this.data);
6253
- } else {
6254
- perform();
6255
- }
6256
- if (typeof removeOptimistic === "string") {
6257
- this.optimisticData = this.optimisticData.removeLayer(removeOptimistic);
6258
- }
6259
- if (onWatchUpdated && alreadyDirty.size) {
6260
- this.broadcastWatches(__assign(__assign({}, options), { onWatchUpdated: function(watch2, diff) {
6261
- var result = onWatchUpdated.call(this, watch2, diff);
6262
- if (result !== false) {
6263
- alreadyDirty.delete(watch2);
6264
- }
6265
- return result;
6266
- } }));
6267
- if (alreadyDirty.size) {
6268
- alreadyDirty.forEach(function(watch2) {
6269
- return _this.maybeBroadcastWatch.dirty(watch2);
6270
- });
6271
- }
6272
- } else {
6273
- this.broadcastWatches(options);
6274
- }
6275
- return updateResult;
6276
- };
6277
- InMemoryCache2.prototype.performTransaction = function(update, optimisticId) {
6278
- return this.batch({
6279
- update,
6280
- optimistic: optimisticId || optimisticId !== null
6281
- });
6282
- };
6283
- InMemoryCache2.prototype.transformDocument = function(document) {
6284
- if (this.addTypename) {
6285
- var result = this.typenameDocumentCache.get(document);
6286
- if (!result) {
6287
- result = addTypenameToDocument(document);
6288
- this.typenameDocumentCache.set(document, result);
6289
- this.typenameDocumentCache.set(result, result);
6290
- }
6291
- return result;
6292
- }
6293
- return document;
6294
- };
6295
- InMemoryCache2.prototype.broadcastWatches = function(options) {
6296
- var _this = this;
6297
- if (!this.txCount) {
6298
- this.watches.forEach(function(c) {
6299
- return _this.maybeBroadcastWatch(c, options);
6300
- });
6301
- }
6302
- };
6303
- InMemoryCache2.prototype.broadcastWatch = function(c, options) {
6304
- var lastDiff = c.lastDiff;
6305
- var diff = this.diff(c);
6306
- if (options) {
6307
- if (c.optimistic && typeof options.optimistic === "string") {
6308
- diff.fromOptimisticTransaction = true;
6309
- }
6310
- if (options.onWatchUpdated && options.onWatchUpdated.call(this, c, diff, lastDiff) === false) {
6311
- return;
6312
- }
6313
- }
6314
- if (!lastDiff || !equal(lastDiff.result, diff.result)) {
6315
- c.callback(c.lastDiff = diff, lastDiff);
6316
- }
6317
- };
6318
- return InMemoryCache2;
6319
- }(ApolloCache);
6320
- const defaultTaskTemplate = {
6321
- taskTemplateObj: {},
6322
- isAddedToTask: false,
6323
- isNotified: false
6324
- };
6325
- var __vue2_script$1 = defineComponent({
6326
- name: "index",
6327
- components: {
6328
- NewTask,
6329
- MainModal,
6330
- ReviewModal
6331
- },
6332
- props: {
6333
- uploadFilesFunc: {
6334
- type: Function,
6335
- required: true
6336
- },
6337
- visible: {
6338
- type: Boolean,
6339
- default: false
6340
- },
6341
- userId: {
6342
- type: String,
6343
- required: true
6344
- },
6345
- lawFirmId: {
6346
- type: Number,
6347
- required: true
6348
- },
6349
- value: {
6350
- type: Array,
6351
- default: () => []
6352
- },
6353
- reviewText: {
6354
- type: String,
6355
- default: "Add"
6356
- },
6357
- showSendEmail: {
6358
- type: Boolean,
6359
- default: false
6360
- },
6361
- sendEmail: {
6362
- type: Boolean,
6363
- default: false
6364
- },
6365
- taskSettingPageUrl: {
6366
- type: String
6367
- },
6368
- allowClear: {
6369
- type: Boolean,
6370
- default: false
6371
- },
6372
- pageMode: {
6373
- type: Boolean,
6374
- default: false
6375
- }
6376
- },
6377
- setup(props, { emit }) {
6378
- const mainModal = ref$1();
6379
- const reviewModal = ref$1();
6380
- const newTaskVisible = ref$1(false);
6381
- const reviewModalVisible = ref$1(false);
6382
- const tempTask = ref$1(defaultTaskTemplate);
6383
- const updateTemplate = useMutateTaskTemplate();
6384
- const createTemplate = useCreateTaskTemplate();
6385
- const addedTasks = ref$1([]);
6386
- new InMemoryCache();
6387
- onMounted(() => {
6388
- const { value, lawFirmId } = props;
6389
- if (!value.length)
6390
- return;
6391
- const conditions = ref$1({
6392
- taskTemplateId: value
6393
- });
6394
- const { result } = useSearchTaskTemplates(ref$1({ current: 1, pageSize: 1e3, total: 0 }), conditions, lawFirmId);
6395
- watch(() => result.value, () => {
6396
- var _a2, _b;
6397
- addedTasks.value = ((_b = (_a2 = result.value) == null ? void 0 : _a2.taskTemplateSearch) == null ? void 0 : _b.taskTemplateList) || [];
6398
- });
6399
- });
6400
- watch(() => newTaskVisible.value, (visible) => {
6401
- if (!visible) {
6402
- tempTask.value = defaultTaskTemplate;
6403
- }
6404
- });
6405
- const _submit = async (record) => {
6406
- const {
6407
- newRecord,
6408
- success
6409
- } = await submit(record, updateTemplate, createTemplate);
6410
- if (success) {
6411
- newTaskVisible.value = false;
6412
- mainModal.value.taskTable.refetch();
6413
- if (reviewModalVisible.value) {
6414
- const newValue = addedTasks.value.map((originTask) => {
6415
- if (originTask.id === record.taskTemplateId) {
6416
- return newRecord;
6417
- }
6418
- return originTask;
6419
- });
6420
- emit("update:value", newValue.map(({ id }) => id));
6421
- }
6422
- }
6423
- };
6424
- const submitting = computed(() => updateTemplate.loading.value || createTemplate.loading.value);
6425
- const showEdit = (record) => {
6426
- newTaskVisible.value = true;
6427
- tempTask.value = {
6428
- taskTemplateObj: __spreadValues({}, record)
6429
- };
6430
- };
6431
- return {
6432
- showEdit,
6433
- mainModal,
6434
- reviewModal,
6435
- _submit,
6436
- newTaskVisible,
6437
- tempTask,
6438
- reviewModalVisible,
6439
- submitting,
6440
- addedTasks
6441
- };
2851
+ };
2852
+ const submitting = computed(() => updateTemplate.loading.value || createTemplate.loading.value);
2853
+ const editTask = (record) => {
2854
+ newTaskVisible.value = true;
2855
+ tempTask.value = __spreadValues({}, record);
2856
+ };
2857
+ return {
2858
+ editTask,
2859
+ mainModal,
2860
+ reviewModal,
2861
+ _submit,
2862
+ newTaskVisible,
2863
+ tempTask,
2864
+ reviewModalVisible,
2865
+ submitting,
2866
+ addedTasks
2867
+ };
6442
2868
  }
6443
2869
  });
6444
2870
  var render$1 = function() {
6445
2871
  var _vm = this;
6446
2872
  var _h = _vm.$createElement;
6447
2873
  var _c = _vm._self._c || _h;
6448
- return _c("div", { attrs: { "id": "venus-component-task-cart" } }, [_c("main-modal", { ref: "mainModal", attrs: { "task-setting-page-url": _vm.taskSettingPageUrl, "tempTask": _vm.tempTask, "newTaskVisible": _vm.newTaskVisible, "reviewModalVisible": _vm.reviewModalVisible, "added-tasks": _vm.addedTasks, "law-firm-id": _vm.lawFirmId, "visible": _vm.visible, "show-page": _vm.pageMode }, on: { "update:tempTask": function($event) {
2874
+ return _c("div", { attrs: { "id": "venus-component-task-cart" } }, [_c("main-modal", { ref: "mainModal", attrs: { "visible": _vm.visible, "show-page": _vm.pageMode, "page-size": _vm.pageSize, "law-firm-id": _vm.lawFirmId, "tempTask": _vm.tempTask, "added-tasks": _vm.addedTasks, "newTaskVisible": _vm.newTaskVisible, "task-setting-page-url": _vm.taskSettingPageUrl, "reviewModalVisible": _vm.reviewModalVisible, "open-review-button-text": _vm.openReviewButtonText }, on: { "update:tempTask": function($event) {
6449
2875
  _vm.tempTask = $event;
6450
2876
  }, "update:temp-task": function($event) {
6451
2877
  _vm.tempTask = $event;
2878
+ }, "update:addedTasks": function($event) {
2879
+ _vm.addedTasks = $event;
2880
+ }, "update:added-tasks": function($event) {
2881
+ _vm.addedTasks = $event;
6452
2882
  }, "update:newTaskVisible": function($event) {
6453
2883
  _vm.newTaskVisible = $event;
6454
2884
  }, "update:new-task-visible": function($event) {
@@ -6457,37 +2887,33 @@ var render$1 = function() {
6457
2887
  _vm.reviewModalVisible = $event;
6458
2888
  }, "update:review-modal-visible": function($event) {
6459
2889
  _vm.reviewModalVisible = $event;
6460
- }, "update:addedTasks": function($event) {
6461
- _vm.addedTasks = $event;
6462
- }, "update:added-tasks": function($event) {
6463
- _vm.addedTasks = $event;
6464
- }, "update:visible": function($event) {
2890
+ }, "editTask": _vm.editTask, "update:visible": function($event) {
6465
2891
  return _vm.$emit("update:visible", $event);
6466
- }, "edit": _vm.showEdit }, scopedSlots: _vm._u([{ key: "default", fn: function(ref2) {
2892
+ } }, scopedSlots: _vm._u([{ key: "default", fn: function(ref2) {
6467
2893
  var loading = ref2.loading;
6468
2894
  var dataSource = ref2.dataSource;
6469
2895
  var pagination = ref2.pagination;
6470
2896
  var changePagination = ref2.changePagination;
6471
2897
  return [_vm._t("table", null, { "loading": loading, "dataSource": dataSource, "pagination": pagination, "changePagination": changePagination })];
6472
- } }], null, true) }), _c("review-modal", { ref: "reviewModal", attrs: { "tempTask": _vm.tempTask, "visible": _vm.reviewModalVisible, "newTaskVisible": _vm.newTaskVisible, "added-tasks": _vm.addedTasks, "review-text": _vm.reviewText, "showSendEmail": _vm.showSendEmail, "sendEmail": _vm.sendEmail, "allow-clear": _vm.allowClear }, on: { "update:tempTask": function($event) {
2898
+ } }], null, true) }), _c("review-modal", { ref: "reviewModal", attrs: { "sendEmail": _vm.sendEmail, "allow-clear": _vm.allowClear, "tempTask": _vm.tempTask, "review-text": _vm.reviewText, "added-tasks": _vm.addedTasks, "showSendEmail": _vm.showSendEmail, "visible": _vm.reviewModalVisible, "newTaskVisible": _vm.newTaskVisible }, on: { "update:tempTask": function($event) {
6473
2899
  _vm.tempTask = $event;
6474
2900
  }, "update:temp-task": function($event) {
6475
2901
  _vm.tempTask = $event;
2902
+ }, "update:addedTasks": function($event) {
2903
+ _vm.addedTasks = $event;
2904
+ }, "update:added-tasks": function($event) {
2905
+ _vm.addedTasks = $event;
6476
2906
  }, "update:visible": function($event) {
6477
2907
  _vm.reviewModalVisible = $event;
6478
2908
  }, "update:newTaskVisible": function($event) {
6479
2909
  _vm.newTaskVisible = $event;
6480
2910
  }, "update:new-task-visible": function($event) {
6481
2911
  _vm.newTaskVisible = $event;
6482
- }, "update:addedTasks": function($event) {
6483
- _vm.addedTasks = $event;
6484
- }, "update:added-tasks": function($event) {
6485
- _vm.addedTasks = $event;
6486
- }, "update:sendEmail": function($event) {
6487
- return _vm.$emit("update:sendEmail", $event);
6488
2912
  }, "submit": function($event) {
6489
2913
  return _vm.$emit("submit", $event);
6490
- } } }), _c("new-task", { attrs: { "value": _vm.tempTask, "visible": _vm.newTaskVisible, "upload-files-func": _vm.uploadFilesFunc, "law-firm-id": _vm.lawFirmId, "user-id": _vm.userId, "loading": _vm.submitting }, on: { "update:value": function($event) {
2914
+ }, "update:sendEmail": function($event) {
2915
+ return _vm.$emit("update:sendEmail", $event);
2916
+ } } }), _c("new-task", { attrs: { "user-id": _vm.userId, "loading": _vm.submitting, "value": _vm.tempTask, "law-firm-id": _vm.lawFirmId, "visible": _vm.newTaskVisible, "upload-files-func": _vm.uploadFilesFunc }, on: { "update:value": function($event) {
6491
2917
  _vm.tempTask = $event;
6492
2918
  }, "update:visible": function($event) {
6493
2919
  _vm.newTaskVisible = $event;
@@ -6496,7 +2922,7 @@ var render$1 = function() {
6496
2922
  var staticRenderFns$1 = [];
6497
2923
  var index_vue_vue_type_style_index_0_scoped_true_lang = "";
6498
2924
  const __cssModules$1 = {};
6499
- var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1, "2b41ba2b", null, null);
2925
+ var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1, "57002a5a", null, null);
6500
2926
  function __vue2_injectStyles$1(context) {
6501
2927
  for (let o in __cssModules$1) {
6502
2928
  this[o] = __cssModules$1[o];