@hestia-earth/ui-components 0.0.3 → 0.0.6

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 (39) hide show
  1. package/bundles/hestia-earth-ui-components.umd.js +1703 -1772
  2. package/bundles/hestia-earth-ui-components.umd.js.map +1 -1
  3. package/common/blank-node-state/blank-node-state.component.d.ts +1 -1
  4. package/common/common.service.d.ts +1 -2
  5. package/common/public-api.d.ts +1 -0
  6. package/common/toast/toast.component.d.ts +2 -2
  7. package/common/toast.service.d.ts +3 -3
  8. package/common/utils.d.ts +3 -11
  9. package/cycles/public-api.d.ts +1 -0
  10. package/engine/aggregation-engine.service.d.ts +13 -25
  11. package/engine/engine.service.d.ts +2 -6
  12. package/engine/public-api.d.ts +2 -2
  13. package/esm2015/common/common.service.js +1 -7
  14. package/esm2015/common/public-api.js +2 -1
  15. package/esm2015/common/toast/toast.component.js +3 -3
  16. package/esm2015/common/toast.service.js +5 -5
  17. package/esm2015/common/utils.js +3 -61
  18. package/esm2015/cycles/public-api.js +2 -1
  19. package/esm2015/engine/aggregation-engine.service.js +11 -47
  20. package/esm2015/engine/engine.service.js +9 -15
  21. package/esm2015/engine/public-api.js +3 -3
  22. package/esm2015/files/public-api.js +3 -1
  23. package/esm2015/impact-assessments/impact-assessments-products/impact-assessments-products.component.js +3 -3
  24. package/esm2015/mendeley/mendeley.service.js +1 -1
  25. package/esm2015/node/node-csv.service.js +1 -1
  26. package/esm2015/node/node.service.js +26 -16
  27. package/esm2015/schema/schema.service.js +1 -1
  28. package/esm2015/search/search.service.js +1 -1
  29. package/fesm2015/hestia-earth-ui-components.js +972 -1063
  30. package/fesm2015/hestia-earth-ui-components.js.map +1 -1
  31. package/files/public-api.d.ts +2 -0
  32. package/impact-assessments/impact-assessments-products/impact-assessments-products.component.d.ts +2 -2
  33. package/mendeley/mendeley.service.d.ts +2 -2
  34. package/node/node-csv.service.d.ts +1 -1
  35. package/node/node.service.d.ts +16 -7
  36. package/package.json +1 -1
  37. package/schema/schema.service.d.ts +1 -1
  38. package/search/search.service.d.ts +2 -2
  39. package/styles.scss +1 -0
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@ng-bootstrap/ng-bootstrap'), require('@angular/google-maps'), require('@fortawesome/angular-fontawesome'), require('@fortawesome/free-regular-svg-icons'), require('@fortawesome/free-solid-svg-icons'), require('@hestia-earth/utils'), require('random-material-color'), require('@hestia-earth/schema'), require('@hestia-earth/api'), require('rxjs'), require('rxjs/operators'), require('csvtojson'), require('@angular/common/http'), require('@angular/platform-browser'), require('pluralize'), require('@hestia-earth/bulma-tagsinput'), require('json-2-csv'), require('@angular/cdk/drag-drop'), require('@hestia-earth/schema-convert'), require('@hestia-earth/json-schema/schema-utils'), require('jsondiffpatch'), require('chart.js'), require('@google/markerclustererplus'), require('moment'), require('moment/locale/en-gb'), require('uuid'), require('chartjs-plugin-datalabels')) :
3
- typeof define === 'function' && define.amd ? define('@hestia-earth/ui-components', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/router', '@ng-bootstrap/ng-bootstrap', '@angular/google-maps', '@fortawesome/angular-fontawesome', '@fortawesome/free-regular-svg-icons', '@fortawesome/free-solid-svg-icons', '@hestia-earth/utils', 'random-material-color', '@hestia-earth/schema', '@hestia-earth/api', 'rxjs', 'rxjs/operators', 'csvtojson', '@angular/common/http', '@angular/platform-browser', 'pluralize', '@hestia-earth/bulma-tagsinput', 'json-2-csv', '@angular/cdk/drag-drop', '@hestia-earth/schema-convert', '@hestia-earth/json-schema/schema-utils', 'jsondiffpatch', 'chart.js', '@google/markerclustererplus', 'moment', 'moment/locale/en-gb', 'uuid', 'chartjs-plugin-datalabels'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["hestia-earth"] = global["hestia-earth"] || {}, global["hestia-earth"]["ui-components"] = {}), global.ng.core, global.ng.common, global.ng.forms, global.ng.router, global.i10, global.ng.googleMaps, global.i1, global.freeRegularSvgIcons, global.freeSolidSvgIcons, global.utils, global.randomMaterialColor, global.schema, global.api, global.rxjs, global.rxjs.operators, global.csvtojson, global.ng.common.http, global.ng.platformBrowser, global.pluralize, global.BulmaTagsInput, global.json2Csv, global.ng.cdk.dragDrop, global.schemaConvert, global.schemaUtils, global.jsondiffpatch, global.chart_js, global.MarkerClusterer, global.moment, null, global.uuid, global.ChartDataLabels));
5
- })(this, (function (exports, i0, i3, i1$4, i4, i10, i1$2, i1, freeRegularSvgIcons, freeSolidSvgIcons, utils, randomMaterialColor, schema, api, rxjs, operators, csvtojson, i1$1, i1$3, pluralize, BulmaTagsInput, json2Csv, i6, schemaConvert, schemaUtils, jsondiffpatch, chart_js, MarkerClusterer, moment, enGb, uuid, ChartDataLabels) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@ng-bootstrap/ng-bootstrap'), require('@angular/google-maps'), require('@fortawesome/angular-fontawesome'), require('@fortawesome/free-regular-svg-icons'), require('@fortawesome/free-solid-svg-icons'), require('@hestia-earth/utils'), require('random-material-color'), require('@hestia-earth/schema'), require('@hestia-earth/api'), require('rxjs'), require('rxjs/operators'), require('csvtojson'), require('@angular/common/http'), require('@angular/platform-browser'), require('pluralize'), require('@hestia-earth/bulma-tagsinput'), require('json-2-csv'), require('@angular/cdk/drag-drop'), require('@hestia-earth/schema-convert'), require('@hestia-earth/json-schema/schema-utils'), require('jsondiffpatch'), require('chart.js'), require('moment'), require('moment/locale/en-gb'), require('uuid'), require('@google/markerclustererplus'), require('chartjs-plugin-datalabels')) :
3
+ typeof define === 'function' && define.amd ? define('@hestia-earth/ui-components', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/router', '@ng-bootstrap/ng-bootstrap', '@angular/google-maps', '@fortawesome/angular-fontawesome', '@fortawesome/free-regular-svg-icons', '@fortawesome/free-solid-svg-icons', '@hestia-earth/utils', 'random-material-color', '@hestia-earth/schema', '@hestia-earth/api', 'rxjs', 'rxjs/operators', 'csvtojson', '@angular/common/http', '@angular/platform-browser', 'pluralize', '@hestia-earth/bulma-tagsinput', 'json-2-csv', '@angular/cdk/drag-drop', '@hestia-earth/schema-convert', '@hestia-earth/json-schema/schema-utils', 'jsondiffpatch', 'chart.js', 'moment', 'moment/locale/en-gb', 'uuid', '@google/markerclustererplus', 'chartjs-plugin-datalabels'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["hestia-earth"] = global["hestia-earth"] || {}, global["hestia-earth"]["ui-components"] = {}), global.ng.core, global.ng.common, global.ng.forms, global.ng.router, global.i10, global.ng.googleMaps, global.i1, global.freeRegularSvgIcons, global.freeSolidSvgIcons, global.utils, global.randomMaterialColor, global.schema, global.api, global.rxjs, global.rxjs.operators, global.csvtojson, global.ng.common.http, global.ng.platformBrowser, global.pluralize, global.BulmaTagsInput, global.json2Csv, global.ng.cdk.dragDrop, global.schemaConvert, global.schemaUtils, global.jsondiffpatch, global.chart_js, global.moment, null, global.uuid, global.MarkerClusterer, global.ChartDataLabels));
5
+ })(this, (function (exports, i0, i3, i1$4, i4, i10, i1$2, i1, freeRegularSvgIcons, freeSolidSvgIcons, utils, randomMaterialColor, schema, api, rxjs, operators, csvtojson, i1$1, i1$3, pluralize, BulmaTagsInput, json2Csv, i6, schemaConvert, schemaUtils, jsondiffpatch, chart_js, moment, enGb, uuid, MarkerClusterer, ChartDataLabels) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -37,8 +37,8 @@
37
37
  var pluralize__namespace = /*#__PURE__*/_interopNamespace(pluralize);
38
38
  var BulmaTagsInput__default = /*#__PURE__*/_interopDefaultLegacy(BulmaTagsInput);
39
39
  var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
40
- var MarkerClusterer__default = /*#__PURE__*/_interopDefaultLegacy(MarkerClusterer);
41
40
  var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
41
+ var MarkerClusterer__default = /*#__PURE__*/_interopDefaultLegacy(MarkerClusterer);
42
42
  var ChartDataLabels__default = /*#__PURE__*/_interopDefaultLegacy(ChartDataLabels);
43
43
 
44
44
  var HeAuthService = /** @class */ (function () {
@@ -418,9 +418,10 @@
418
418
  }], ctorParameters: function () { return [{ type: i1__namespace.FaIconLibrary }]; } });
419
419
 
420
420
  var _a$6, _b$3;
421
- var get$5 = require('lodash.get');
421
+ var get$4 = require('lodash.get');
422
422
  var gitHome = 'https://gitlab.com/hestia-earth';
423
423
  var gitRawBaseUrl = 'https://glcdn.githack.com/hestia-earth';
424
+ var gitBranch = function () { return ['dev', 'staging'].some(function (env) { return baseUrl().includes(env); }) ? 'develop' : 'master'; };
424
425
  var isChrome = function () { return window.navigator.userAgent.includes('Chrome'); };
425
426
  var baseUrl = function () { return window.location.origin.includes('localhost') ?
426
427
  'https://www-dev.hestia.earth' :
@@ -429,18 +430,8 @@
429
430
  'https://www.hestia.earth'; };
430
431
  var isExternal = function () { return baseUrl() !== window.location.origin; };
431
432
  ;
432
- var loadScript = function (src) { return new Promise(function (resolve, reject) {
433
- if (!src || document.body.querySelectorAll('script[src="' + src + '"]').length > 0) {
434
- return resolve({});
435
- }
436
- var script = document.createElement('script');
437
- script.onload = resolve;
438
- script.onerror = reject;
439
- script.src = src;
440
- document.body.appendChild(script);
441
- }); };
442
433
  var parseErrorStatus = function (error) { return ((error === null || error === void 0 ? void 0 : error.statusText) || '').toLowerCase().replace(/\s/g, '-'); };
443
- var parseErrorMessage = function (error) { return get$5(error, 'error.error', get$5(error, 'error.message', get$5(error, 'error', get$5(error, 'message', error)))); };
434
+ var parseErrorMessage = function (error) { return get$4(error, 'error.error', get$4(error, 'error.message', get$4(error, 'error', get$4(error, 'message', error)))); };
444
435
  var handleAPIError = function (error) {
445
436
  try {
446
437
  error = parseErrorMessage(error);
@@ -455,21 +446,6 @@
455
446
  var err = parseErrorMessage(error);
456
447
  return parseErrorStatus(err) || err;
457
448
  };
458
- var toFormData = function (data, formData) {
459
- if (formData === void 0) { formData = new FormData(); }
460
- for (var key in data) {
461
- if (data.hasOwnProperty(key)) {
462
- var value = data[key];
463
- if (typeof value === 'object') {
464
- formData.append(key, JSON.stringify(value));
465
- }
466
- else {
467
- formData.append(key, value);
468
- }
469
- }
470
- }
471
- return formData;
472
- };
473
449
  var filterParams = function (obj) {
474
450
  var res = {};
475
451
  Object.keys(obj).sort().forEach(function (key) {
@@ -480,14 +456,6 @@
480
456
  });
481
457
  return res;
482
458
  };
483
- var toSearchParams = function (params) {
484
- if (params === void 0) { params = {}; }
485
- var searchParams = new URLSearchParams();
486
- Object.keys(params)
487
- .filter(function (key) { return typeof params[key] !== 'undefined'; })
488
- .forEach(function (key) { return searchParams.append(key, "" + params[key]); });
489
- return searchParams;
490
- };
491
459
  var waitFor = function (variable, callback) {
492
460
  if (variable in window) {
493
461
  return callback();
@@ -502,23 +470,6 @@
502
470
  setTimeout(function () { return el ? el.scrollIntoView() : (retries < 10 ? scrollToEl(id, retries + 1) : null); }, 100);
503
471
  };
504
472
  var scrollTop = function () { return window.scrollTo(0, 0); };
505
- var animateCounter = function (total, callback) {
506
- var animationDuration = 10;
507
- var step = Math.pow(10, ("" + total).length - 1);
508
- var maxSteps = parseInt("" + total / step, 10);
509
- var current = 0;
510
- var interval = setInterval(function () {
511
- callback(current);
512
- current += (step / animationDuration);
513
- if (current > maxSteps * step) {
514
- animationDuration = 100;
515
- }
516
- if (current > total) {
517
- callback(total);
518
- clearInterval(interval);
519
- }
520
- }, animationDuration);
521
- };
522
473
  var safeJSONParse = function (value, defaultValue) {
523
474
  try {
524
475
  return typeof value === 'string' ? JSON.parse(value) : value;
@@ -582,7 +533,7 @@
582
533
  group[termId].values[nodeId].nodes.push(blankNode);
583
534
  group[termId].values[nodeId].value = concatBlankNodeValue(group[termId].values[nodeId].value, blankNode.value);
584
535
  grouppedValueKeys.forEach(function (arrayKey) {
585
- var newValue = get$5(blankNode, arrayKey, []);
536
+ var newValue = get$4(blankNode, arrayKey, []);
586
537
  group[termId].values[nodeId][arrayKey] = __spreadArray(__spreadArray([], __read((group[termId].values[nodeId][arrayKey] || []))), __read((Array.isArray(newValue) ? newValue : [newValue])));
587
538
  });
588
539
  return group;
@@ -592,7 +543,7 @@
592
543
  Object.keys(group.values).map(function (nodeId) {
593
544
  var index = group.values[nodeId].index;
594
545
  var termId = group.term['@id'];
595
- var originalValue = get$5(originalValues, "[" + index + "]." + key, []).filter(function (val) { return val.term['@id'] === termId; });
546
+ var originalValue = get$4(originalValues, "[" + index + "]." + key, []).filter(function (val) { return val.term['@id'] === termId; });
596
547
  if (originalValue.length > 0) {
597
548
  var value = originalValue.reduce(function (array, curr) { return concatBlankNodeValue(array, curr.value); }, []);
598
549
  group.originalValues[nodeId] = { value: propertyValue$1(value) };
@@ -601,7 +552,6 @@
601
552
  });
602
553
  return groups;
603
554
  };
604
- var sortByFn = function (key, asc) { return function (a, b) { return asc ? get$5(a, key, '').localeCompare(get$5(b, key, '')) : get$5(b, key, '').localeCompare(get$5(a, key, '')); }; };
605
555
  var ellipsis = function (text, maxlength) {
606
556
  if (text === void 0) { text = ''; }
607
557
  if (maxlength === void 0) { maxlength = 20; }
@@ -625,8 +575,6 @@
625
575
  // handle years
626
576
  .replace(/([0-9]{4})/g, function (g) { return "-" + g; }) :
627
577
  null; };
628
- var nodeTypeToString = function (type) { return "" + type.charAt(0).toLowerCase() + type.substring(1); };
629
- var parseNodeType = function (type) { return Object.values(schema.NodeType).find(function (v) { return v.toString().toLowerCase() === (type || '').toLowerCase(); }); };
630
578
  var nodeDefaultLabel = (_a$6 = {},
631
579
  _a$6[schema.NodeType.ImpactAssessment] = function (_a) {
632
580
  var name = _a.name, country = _a.country, endDate = _a.endDate, product = _a.product;
@@ -644,20 +592,6 @@
644
592
  var defaultLabel = function (node) { return node ? (node['@type'] in nodeDefaultLabel ? nodeDefaultLabel[node['@type']](node) : node.name) || node['@id'] || node.id : ''; };
645
593
  var itemColor = function (index) { return randomMaterialColor.getColor({ text: "" + index }); };
646
594
  var listColor = function (_v, index) { return itemColor(index); };
647
- var minutesBefore = function (date, minutes) {
648
- if (minutes === void 0) { minutes = 1; }
649
- date.setMinutes(date.getMinutes() - minutes);
650
- return date;
651
- };
652
- var hoursBefore = function (date, hours) {
653
- if (hours === void 0) { hours = 1; }
654
- date.setHours(date.getHours() - hours);
655
- return date;
656
- };
657
- var repeat = function (times) {
658
- if (times === void 0) { times = 0; }
659
- return (Array.from(Array(times), Math.random));
660
- };
661
595
  exports.DeltaDisplayType = void 0;
662
596
  (function (DeltaDisplayType) {
663
597
  DeltaDisplayType["absolute"] = "absolute";
@@ -683,6 +617,10 @@
683
617
  DeltaColour["Danger"] = "danger";
684
618
  })(exports.DeltaColour || (exports.DeltaColour = {}));
685
619
  var emptyValue = function (value) { return utils.isEmpty(value) || isNaN(propertyValue$1(value)); };
620
+ var repeat = function (times) {
621
+ if (times === void 0) { times = 0; }
622
+ return (Array.from(Array(times), Math.random));
623
+ };
686
624
  var filenameWithoutExt = function (filename) {
687
625
  if (filename === void 0) { filename = ''; }
688
626
  var file = api.fileToExt(filename, '');
@@ -855,261 +793,211 @@
855
793
  type: i0.Input
856
794
  }] } });
857
795
 
858
- var _a$4, _b$1, _c$1, _d$1, _e;
859
- var searchableTypes = [
860
- schema.NodeType.Cycle,
861
- schema.NodeType.Source
862
- ];
863
- var serializeSearchFilters = function (filters) { return Object.keys(filters || {})
864
- .filter(function (key) { return filters[key].length; })
865
- .map(function (key) { return key + "=" + filters[key].filter(Boolean).join('|'); })
866
- .join(';'); };
867
- var deserializeSearchFilters = function (filters) { return (filters || '').split(';').reduce(function (prev, curr) {
868
- var _a = __read(curr.split('='), 2), key = _a[0], values = _a[1];
869
- prev[key] = (values || '').split('|').filter(Boolean);
870
- return prev;
871
- }, {}); };
872
- var matchType = function (type) { return Object.freeze({
873
- match: { '@type': type }
874
- }); };
875
- var matchTermType = function (termType) { return Object.freeze({
876
- match: { termType: termType }
877
- }); };
878
- var matchRegex = function (key, value) {
879
- var _a;
880
- return Object.freeze({
881
- regexp: (_a = {}, _a[key] = { value: value.toString() }, _a)
882
- });
883
- };
884
- var matchQuery = function (key, value, boost) {
885
- var _a;
886
- return Object.freeze({
887
- match: (_a = {},
888
- _a[key] = Object.assign({ query: value }, (boost ? { boost: boost } : {})),
889
- _a)
796
+ var _a$4, _b$1, _c$1;
797
+ var termProperties = function (term) { return Object.keys(term).filter(function (key) { return !schema.isExpandable(term[key]) && ![
798
+ 'pinned', 'expanded', 'extended', 'selected', 'loading',
799
+ '_score', '@type', '@id', '@context', 'createdAt',
800
+ 'name', 'synonyms', 'termType', 'location', 'properties', 'schemaVersion'
801
+ ].includes(key); }); };
802
+ var findPropertyById = function (_a, key) {
803
+ var defaultProperties = _a.defaultProperties;
804
+ return (defaultProperties || []).find(function (_a) {
805
+ var term = _a.term;
806
+ return term['@id'] === key;
890
807
  });
891
808
  };
892
- var matchExactQuery = function (key, value, boost) { return matchQuery(key + ".keyword", value, boost); };
893
- var matchNameNormalized = function (query, boost) {
894
- if (boost === void 0) { boost = 20; }
895
- return Object.freeze({
896
- match: { nameNormalized: { query: query, boost: boost } }
809
+ var termLocationName = function (_a) {
810
+ var gadmFullName = _a.gadmFullName;
811
+ return ({
812
+ name: gadmFullName || ''
897
813
  });
898
814
  };
899
- var numberGte = function (key, value) {
900
- var _a;
901
- return Object.freeze({
902
- range: (_a = {}, _a[key] = { gte: value }, _a)
815
+ var termLocation = function (_a) {
816
+ var latitude = _a.latitude, longitude = _a.longitude;
817
+ return ({
818
+ lat: latitude,
819
+ lng: longitude
903
820
  });
904
821
  };
905
- var multiMatchQuery = function (query, fields, type, boost, analyzer) {
906
- if (type === void 0) { type = 'best_fields'; }
907
- return Object.freeze({
908
- multi_match: Object.assign(Object.assign({ query: query, fields: fields, type: type }, (boost ? { boost: boost } : {})), (analyzer ? { analyzer: analyzer } : {}))
909
- });
822
+ var termTypeToLabel = (_a$4 = {},
823
+ _a$4[schema.TermTermType.methodEmissionResourceUse] = 'Method (Emissions)',
824
+ _a$4[schema.TermTermType.methodMeasurement] = 'Method (Measurement)',
825
+ _a$4[schema.TermTermType.pesticideAI] = 'Pesticide Active Ingredient',
826
+ _a$4[schema.TermTermType.standardsLabels] = 'Standards & Labels',
827
+ _a$4[schema.TermTermType.usdaSoilType] = 'USDA Soil Type',
828
+ _a$4);
829
+ var termTypeLabel = function (type) {
830
+ if (type === void 0) { type = 'N/A'; }
831
+ return type in termTypeToLabel ? termTypeToLabel[type] : keyToLabel(type);
910
832
  };
911
- var matchPhraseQuery = function (query, boost) {
912
- var fields = [];
913
- for (var _i = 2; _i < arguments.length; _i++) {
914
- fields[_i - 2] = arguments[_i];
915
- }
916
- return fields.length ? multiMatchQuery(query, fields, 'phrase', boost) : matchExactQuery('name', query, boost);
917
- };
918
- var matchPhrasePrefixQuery = function (query, boost) {
919
- if (boost === void 0) { boost = 2; }
920
- var fields = [];
921
- for (var _i = 2; _i < arguments.length; _i++) {
922
- fields[_i - 2] = arguments[_i];
923
- }
924
- return fields.length ?
925
- multiMatchQuery(query, fields, 'phrase_prefix', boost) :
926
- Object.freeze({
927
- match_phrase_prefix: {
928
- nameSearchAsYouType: {
929
- query: query,
930
- boost: boost
931
- }
932
- }
933
- });
934
- };
935
- var matchBoolPrefixQuery = function (query, boost) {
936
- if (boost === void 0) { boost = 1; }
937
- var fields = [];
938
- for (var _i = 2; _i < arguments.length; _i++) {
939
- fields[_i - 2] = arguments[_i];
940
- }
941
- return fields.length ?
942
- multiMatchQuery(query, fields, 'bool_prefix', boost) :
943
- Object.freeze({
944
- match_bool_prefix: {
945
- name: {
946
- query: query,
947
- boost: boost
948
- }
949
- }
950
- });
951
- };
952
- var wildcardQuery = function (query, boost) {
953
- if (boost === void 0) { boost = 3; }
954
- var fields = [];
955
- for (var _i = 2; _i < arguments.length; _i++) {
956
- fields[_i - 2] = arguments[_i];
957
- }
958
- return Object.freeze({
959
- simple_query_string: {
960
- query: "*" + query + "*",
961
- fields: fields,
962
- analyze_wildcard: true,
963
- boost: boost
964
- }
965
- });
966
- };
967
- var matchCountryLevel = { match: { gadmLevel: 0 } };
968
- var matchGlobalRegion = { regexp: { '@id': 'region-*' } };
969
- var matchCountry = Object.freeze({
970
- bool: {
971
- should: [
972
- matchCountryLevel,
973
- matchGlobalRegion
974
- ],
975
- minimum_should_match: 1
976
- }
977
- });
978
- var countriesQuery = Object.freeze({
979
- bool: {
980
- must: [
981
- matchType(schema.NodeType.Term),
982
- matchTermType(schema.TermTermType.region),
983
- matchCountryLevel
984
- ]
985
- }
986
- });
987
- var allCountriesQuery = Object.freeze({
988
- bool: Object.assign({ must: [
989
- matchType(schema.NodeType.Term),
990
- matchTermType(schema.TermTermType.region)
991
- ] }, matchCountry.bool)
992
- });
993
- var matchRegion = numberGte('gadmLevel', 1);
994
- var regionsQuery = Object.freeze({
995
- bool: {
996
- must: [
997
- matchType(schema.NodeType.Term),
998
- matchTermType(schema.TermTermType.region),
999
- matchRegion
1000
- ]
1001
- }
1002
- });
1003
- var worldRegion = Object.freeze({
1004
- '@id': 'region-world',
1005
- name: 'World'
1006
- });
1007
- var cropsQuery = Object.freeze({
1008
- bool: {
1009
- must: [
1010
- matchType(schema.NodeType.Term),
1011
- matchTermType(schema.TermTermType.crop)
1012
- ]
1013
- }
1014
- });
1015
- var matchAggregatedQuery = matchQuery('aggregated', true);
1016
- var isNestedKey = function (key) { return schema.nestedSearchableKeys.includes(key.split('.')[0]); };
1017
- var matchNestedKey = function (key, query) { return isNestedKey(key) ? {
1018
- nested: { path: key.split('.')[0], query: query }
1019
- } : query; };
1020
- /**
1021
- * List of fields to return in the search results.
1022
- */
1023
- var searchResultsFields = Object.freeze((_a$4 = {},
1024
- _a$4[schema.NodeType.Cycle] = [
1025
- 'description', 'dataDescription', 'endDate',
1026
- 'emissionsCount', 'inputsCount', 'productsCount',
1027
- 'site.location', 'site.country.name', 'site.region.name'
1028
- ],
1029
- _a$4[schema.NodeType.Source] = ['bibliography.title', 'bibliography.documentDOI'],
1030
- _a$4[schema.NodeType.ImpactAssessment] = ['emissionsResourceUseCount', 'impactsCount', 'country.name'],
1031
- _a$4));
1032
- /**
1033
- * List of fields to search in.
1034
- */
1035
- var searchFields = Object.freeze((_b$1 = {},
1036
- _b$1[schema.NodeType.Cycle] = ['name', 'description', 'dataDescription'],
1037
- _b$1[schema.NodeType.Source] = ['name', 'bibliography.title'],
1038
- _b$1[schema.NodeType.ImpactAssessment] = ['name', 'product.name', 'country.name'],
1039
- _b$1));
1040
- var searchFieldsNested = Object.freeze((_c$1 = {},
1041
- _c$1[schema.NodeType.Cycle] = [
1042
- 'inputs.term.name',
1043
- 'emissions.term.name',
1044
- 'practices.term.name'
1045
- ],
1046
- _c$1[schema.NodeType.Source] = [],
1047
- _c$1[schema.NodeType.ImpactAssessment] = [
1048
- 'emissionsResourceUse.term.name',
1049
- 'impacts.term.name'
1050
- ],
1051
- _c$1));
1052
- /**
1053
- * Specific strict queries per type.
1054
- */
1055
- var searchQueries = (_d$1 = {},
1056
- _d$1[schema.NodeType.Cycle] = { must: [], must_not: [matchAggregatedQuery] },
1057
- _d$1[schema.NodeType.Source] = { must: [], must_not: [matchAggregatedQuery] },
1058
- _d$1);
1059
- var searchFiltersKeys = (_e = {},
1060
- _e[schema.NodeType.Cycle] = function (key) { return key; },
1061
- _e[schema.NodeType.Source] = function (key) { return key; },
1062
- _e);
1063
- /* eslint-disable complexity */
1064
- var searchQuery = function (type, query, filters, aggregated) {
1065
- var boolQuery = (Object.assign(Object.assign({ must: [
1066
- matchType(type),
1067
- aggregated ? matchAggregatedQuery : null
1068
- ].filter(Boolean) }, (query ? {
1069
- should: __spreadArray([
1070
- matchPhraseQuery.apply(void 0, __spreadArray([query, 100], __read(searchFields[type]))),
1071
- matchPhrasePrefixQuery.apply(void 0, __spreadArray([query, 20], __read(searchFields[type]))),
1072
- matchBoolPrefixQuery.apply(void 0, __spreadArray([query, 10], __read(searchFields[type])))
1073
- ], __read(searchFieldsNested[type].map(function (field) { return matchNestedKey(field, matchBoolPrefixQuery(query, 1, field)); }))),
1074
- minimum_should_match: 1
1075
- } : {})), { must_not: [
1076
- aggregated ? null : matchAggregatedQuery
1077
- ].filter(Boolean) }));
1078
- var keys = Object.keys(filters || {}).filter(function (key) { return filters[key].length; });
1079
- return {
1080
- bool: keys.length ? {
1081
- must: keys.map(function (key) {
1082
- var filterKey = searchFiltersKeys[type](key);
1083
- return {
1084
- bool: {
1085
- should: filters[key]
1086
- .map(function (value) { return matchNestedKey(filterKey, matchExactQuery(filterKey, value)); })
1087
- .map(function (must) {
1088
- var localQuery = JSON.parse(JSON.stringify(boolQuery));
1089
- localQuery.must.push(must);
1090
- return { bool: localQuery };
1091
- }),
1092
- minimum_should_match: 1
1093
- }
1094
- };
1095
- })
1096
- } : boolQuery
1097
- };
1098
- };
1099
- /* eslint-enable complexity */
1100
-
1101
- var primaryProduct = function (_a) {
1102
- var products = _a.products;
1103
- return (products || []).find(function (_a) {
1104
- var primary = _a.primary;
1105
- return primary;
1106
- });
1107
- };
1108
-
1109
- var HE_API_BASE_URL = new i0.InjectionToken('HE_API_BASE_URL');
1110
- var HeCommonService = /** @class */ (function () {
1111
- function HeCommonService(_apiBaseUrl) {
1112
- this._apiBaseUrl = _apiBaseUrl;
833
+ var termTypesToChildren = function (termTypes) { return termTypes.map(function (termType) { return ({ label: termTypeLabel(termType), termType: termType }); }); };
834
+ var groups = Object.freeze((_b$1 = {},
835
+ _b$1[schema.TermTermType.emission] = {
836
+ label: 'Emissions & Resource Use',
837
+ termType: 'Emissions & Resource Use',
838
+ children: termTypesToChildren([
839
+ schema.TermTermType.emission,
840
+ schema.TermTermType.resourceUse,
841
+ schema.TermTermType.model,
842
+ schema.TermTermType.characterisedIndicator,
843
+ schema.TermTermType.endpointIndicator,
844
+ schema.TermTermType.methodEmissionResourceUse
845
+ ])
846
+ },
847
+ _b$1[schema.TermTermType.region] = {
848
+ label: termTypeLabel(schema.TermTermType.region),
849
+ termType: schema.TermTermType.region,
850
+ children: []
851
+ },
852
+ _b$1.infrastructure = {
853
+ label: 'Infrastructure & Equipment',
854
+ termType: 'Infrastructure & Equipment',
855
+ children: termTypesToChildren([
856
+ schema.TermTermType.building,
857
+ schema.TermTermType.cropProtection,
858
+ schema.TermTermType.cropSupport,
859
+ schema.TermTermType.irrigation,
860
+ schema.TermTermType.machinery
861
+ ])
862
+ },
863
+ _b$1.input = {
864
+ label: 'Inputs',
865
+ termType: 'Inputs',
866
+ children: termTypesToChildren([
867
+ schema.TermTermType.antibiotic,
868
+ schema.TermTermType.electricity,
869
+ schema.TermTermType.fuel,
870
+ schema.TermTermType.material,
871
+ schema.TermTermType.inorganicFertilizer,
872
+ schema.TermTermType.organicFertilizer,
873
+ schema.TermTermType.other,
874
+ schema.TermTermType.pesticideAI,
875
+ schema.TermTermType.pesticideBrandName,
876
+ schema.TermTermType.soilAmendment,
877
+ schema.TermTermType.transport,
878
+ schema.TermTermType.water
879
+ ])
880
+ },
881
+ _b$1[schema.TermTermType.measurement] = {
882
+ label: 'Measurements',
883
+ termType: 'Measurements',
884
+ children: termTypesToChildren([
885
+ schema.TermTermType.measurement,
886
+ schema.TermTermType.soilTexture,
887
+ schema.TermTermType.soilType,
888
+ schema.TermTermType.usdaSoilType,
889
+ schema.TermTermType.methodMeasurement
890
+ ])
891
+ },
892
+ _b$1.practice = {
893
+ label: 'Practices',
894
+ termType: 'Production Practices',
895
+ children: termTypesToChildren([
896
+ schema.TermTermType.animalManagement,
897
+ schema.TermTermType.aquacultureManagement,
898
+ schema.TermTermType.biodiversity,
899
+ schema.TermTermType.cropEstablishment,
900
+ schema.TermTermType.cropResidueManagement,
901
+ schema.TermTermType.excretaManagement,
902
+ schema.TermTermType.landUseManagement,
903
+ schema.TermTermType.operation,
904
+ schema.TermTermType.standardsLabels,
905
+ schema.TermTermType.system,
906
+ schema.TermTermType.tillage,
907
+ schema.TermTermType.waterRegime,
908
+ ])
909
+ },
910
+ _b$1.product = {
911
+ label: 'Products',
912
+ termType: 'Products',
913
+ children: termTypesToChildren([
914
+ schema.TermTermType.crop,
915
+ schema.TermTermType.cropResidue,
916
+ schema.TermTermType.excreta,
917
+ schema.TermTermType.liveAnimal,
918
+ schema.TermTermType.liveAquaticSpecies,
919
+ schema.TermTermType.animalProduct,
920
+ schema.TermTermType.processedFood
921
+ ])
922
+ },
923
+ _b$1[schema.TermTermType.property] = {
924
+ label: termTypeLabel(schema.TermTermType.property),
925
+ termType: schema.TermTermType.property,
926
+ children: []
927
+ },
928
+ _b$1));
929
+ var termTypeGroups = [
930
+ groups.property,
931
+ groups.region,
932
+ groups.input,
933
+ groups.emission,
934
+ groups.product,
935
+ groups.practice,
936
+ groups.measurement,
937
+ groups.infrastructure
938
+ ];
939
+ var termToParent = (_c$1 = {},
940
+ _c$1[schema.TermTermType.property] = 'Properties',
941
+ _c$1[schema.TermTermType.region] = 'Geographies',
942
+ _c$1);
943
+ var termChildToParent = function (termType) { return termTypeGroups.find(function (_a) {
944
+ var children = _a.children;
945
+ return (children || []).some(function (child) { return child.termType === termType; });
946
+ }) ||
947
+ { termType: termToParent[termType] }; };
948
+ var sortOrder = [
949
+ schema.TermTermType.property,
950
+ schema.TermTermType.crop,
951
+ schema.TermTermType.cropResidue,
952
+ schema.TermTermType.animalProduct,
953
+ schema.TermTermType.liveAnimal,
954
+ schema.TermTermType.liveAquaticSpecies,
955
+ schema.TermTermType.processedFood,
956
+ schema.TermTermType.emission,
957
+ schema.TermTermType.resourceUse,
958
+ schema.TermTermType.inorganicFertilizer,
959
+ schema.TermTermType.organicFertilizer,
960
+ schema.TermTermType.soilAmendment,
961
+ schema.TermTermType.soilTexture,
962
+ schema.TermTermType.water,
963
+ schema.TermTermType.material,
964
+ schema.TermTermType.antibiotic,
965
+ schema.TermTermType.electricity,
966
+ schema.TermTermType.fuel,
967
+ schema.TermTermType.aquacultureManagement,
968
+ schema.TermTermType.biodiversity,
969
+ schema.TermTermType.cropResidueManagement,
970
+ schema.TermTermType.animalManagement,
971
+ schema.TermTermType.waterRegime,
972
+ schema.TermTermType.system,
973
+ schema.TermTermType.tillage,
974
+ schema.TermTermType.landUseManagement,
975
+ schema.TermTermType.operation,
976
+ schema.TermTermType.cropEstablishment,
977
+ schema.TermTermType.measurement,
978
+ schema.TermTermType.soilType,
979
+ schema.TermTermType.usdaSoilType,
980
+ schema.TermTermType.methodMeasurement,
981
+ schema.TermTermType.building,
982
+ schema.TermTermType.cropProtection,
983
+ schema.TermTermType.cropSupport,
984
+ schema.TermTermType.irrigation,
985
+ schema.TermTermType.machinery,
986
+ schema.TermTermType.model,
987
+ schema.TermTermType.characterisedIndicator,
988
+ schema.TermTermType.endpointIndicator,
989
+ schema.TermTermType.methodEmissionResourceUse,
990
+ schema.TermTermType.other,
991
+ schema.TermTermType.region,
992
+ schema.TermTermType.pesticideAI,
993
+ schema.TermTermType.pesticideBrandName,
994
+ schema.TermTermType.standardsLabels
995
+ ];
996
+
997
+ var HE_API_BASE_URL = new i0.InjectionToken('HE_API_BASE_URL');
998
+ var HeCommonService = /** @class */ (function () {
999
+ function HeCommonService(_apiBaseUrl) {
1000
+ this._apiBaseUrl = _apiBaseUrl;
1113
1001
  }
1114
1002
  Object.defineProperty(HeCommonService.prototype, "apiBaseUrl", {
1115
1003
  get: function () {
@@ -1118,15 +1006,6 @@
1118
1006
  enumerable: false,
1119
1007
  configurable: true
1120
1008
  });
1121
- Object.defineProperty(HeCommonService.prototype, "gitBranch", {
1122
- get: function () {
1123
- return ['dev', 'staging'].some(function (env) { return baseUrl().includes(env); })
1124
- ? 'develop'
1125
- : 'master';
1126
- },
1127
- enumerable: false,
1128
- configurable: true
1129
- });
1130
1009
  return HeCommonService;
1131
1010
  }());
1132
1011
  HeCommonService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeCommonService, deps: [{ token: HE_API_BASE_URL }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -1143,207 +1022,24 @@
1143
1022
  }] }];
1144
1023
  } });
1145
1024
 
1146
- var _a$3, _b, _c;
1147
- var termProperties = function (term) { return Object.keys(term).filter(function (key) { return !schema.isExpandable(term[key]) && ![
1148
- 'pinned', 'expanded', 'extended', 'selected', 'loading',
1149
- '_score', '@type', '@id', '@context', 'createdAt',
1150
- 'name', 'synonyms', 'termType', 'location', 'properties', 'schemaVersion'
1151
- ].includes(key); }); };
1152
- var findPropertyById = function (_a, key) {
1153
- var defaultProperties = _a.defaultProperties;
1154
- return (defaultProperties || []).find(function (_a) {
1155
- var term = _a.term;
1156
- return term['@id'] === key;
1157
- });
1158
- };
1159
- var termLocationName = function (_a) {
1160
- var gadmFullName = _a.gadmFullName;
1161
- return ({
1162
- name: gadmFullName || ''
1163
- });
1164
- };
1165
- var termLocation = function (_a) {
1166
- var latitude = _a.latitude, longitude = _a.longitude;
1167
- return ({
1168
- lat: latitude,
1169
- lng: longitude
1170
- });
1025
+ var nodeTypeUrl = function (apiBaseUrl, type) { return type ? apiBaseUrl + "/" + api.nodeTypeToParam(type) : ''; };
1026
+ /**
1027
+ * Get the full url to fetch the node data.
1028
+ *
1029
+ * @param apiBaseUrl The url of the API hosting the data.
1030
+ * @param node The node with a type, id and optionally a dataState
1031
+ * @returns The full url.
1032
+ */
1033
+ var nodeUrl = function (apiBaseUrl, _a) {
1034
+ var dataState = _a.dataState, node = __rest(_a, ["dataState"]);
1035
+ return nodeTypeUrl(apiBaseUrl, node['@type'] || node.type) + "/" + (node['@id'] || node.id) + (dataState ? "?dataState=" + dataState : '');
1171
1036
  };
1172
- var termTypeToLabel = (_a$3 = {},
1173
- _a$3[schema.TermTermType.methodEmissionResourceUse] = 'Method (Emissions)',
1174
- _a$3[schema.TermTermType.methodMeasurement] = 'Method (Measurement)',
1175
- _a$3[schema.TermTermType.pesticideAI] = 'Pesticide Active Ingredient',
1176
- _a$3[schema.TermTermType.standardsLabels] = 'Standards & Labels',
1177
- _a$3[schema.TermTermType.usdaSoilType] = 'USDA Soil Type',
1178
- _a$3);
1179
- var termTypeLabel = function (type) {
1180
- if (type === void 0) { type = 'N/A'; }
1181
- return type in termTypeToLabel ? termTypeToLabel[type] : keyToLabel(type);
1037
+ var nodeLogsUrl = function (apiBaseUrl, _a) {
1038
+ var dataState = _a.dataState, node = __rest(_a, ["dataState"]);
1039
+ return nodeUrl(apiBaseUrl, node) + "/log" + (dataState ? "?dataState=" + dataState : '');
1182
1040
  };
1183
- var termTypesToChildren = function (termTypes) { return termTypes.map(function (termType) { return ({ label: termTypeLabel(termType), termType: termType }); }); };
1184
- var groups = Object.freeze((_b = {},
1185
- _b[schema.TermTermType.emission] = {
1186
- label: 'Emissions & Resource Use',
1187
- termType: 'Emissions & Resource Use',
1188
- children: termTypesToChildren([
1189
- schema.TermTermType.emission,
1190
- schema.TermTermType.resourceUse,
1191
- schema.TermTermType.model,
1192
- schema.TermTermType.characterisedIndicator,
1193
- schema.TermTermType.endpointIndicator,
1194
- schema.TermTermType.methodEmissionResourceUse
1195
- ])
1196
- },
1197
- _b[schema.TermTermType.region] = {
1198
- label: termTypeLabel(schema.TermTermType.region),
1199
- termType: schema.TermTermType.region,
1200
- children: []
1201
- },
1202
- _b.infrastructure = {
1203
- label: 'Infrastructure & Equipment',
1204
- termType: 'Infrastructure & Equipment',
1205
- children: termTypesToChildren([
1206
- schema.TermTermType.building,
1207
- schema.TermTermType.cropProtection,
1208
- schema.TermTermType.cropSupport,
1209
- schema.TermTermType.irrigation,
1210
- schema.TermTermType.machinery
1211
- ])
1212
- },
1213
- _b.input = {
1214
- label: 'Inputs',
1215
- termType: 'Inputs',
1216
- children: termTypesToChildren([
1217
- schema.TermTermType.antibiotic,
1218
- schema.TermTermType.electricity,
1219
- schema.TermTermType.fuel,
1220
- schema.TermTermType.material,
1221
- schema.TermTermType.inorganicFertilizer,
1222
- schema.TermTermType.organicFertilizer,
1223
- schema.TermTermType.other,
1224
- schema.TermTermType.pesticideAI,
1225
- schema.TermTermType.pesticideBrandName,
1226
- schema.TermTermType.soilAmendment,
1227
- schema.TermTermType.transport,
1228
- schema.TermTermType.water
1229
- ])
1230
- },
1231
- _b[schema.TermTermType.measurement] = {
1232
- label: 'Measurements',
1233
- termType: 'Measurements',
1234
- children: termTypesToChildren([
1235
- schema.TermTermType.measurement,
1236
- schema.TermTermType.soilTexture,
1237
- schema.TermTermType.soilType,
1238
- schema.TermTermType.usdaSoilType,
1239
- schema.TermTermType.methodMeasurement
1240
- ])
1241
- },
1242
- _b.practice = {
1243
- label: 'Practices',
1244
- termType: 'Production Practices',
1245
- children: termTypesToChildren([
1246
- schema.TermTermType.animalManagement,
1247
- schema.TermTermType.aquacultureManagement,
1248
- schema.TermTermType.biodiversity,
1249
- schema.TermTermType.cropEstablishment,
1250
- schema.TermTermType.cropResidueManagement,
1251
- schema.TermTermType.excretaManagement,
1252
- schema.TermTermType.landUseManagement,
1253
- schema.TermTermType.operation,
1254
- schema.TermTermType.standardsLabels,
1255
- schema.TermTermType.system,
1256
- schema.TermTermType.tillage,
1257
- schema.TermTermType.waterRegime,
1258
- ])
1259
- },
1260
- _b.product = {
1261
- label: 'Products',
1262
- termType: 'Products',
1263
- children: termTypesToChildren([
1264
- schema.TermTermType.crop,
1265
- schema.TermTermType.cropResidue,
1266
- schema.TermTermType.excreta,
1267
- schema.TermTermType.liveAnimal,
1268
- schema.TermTermType.liveAquaticSpecies,
1269
- schema.TermTermType.animalProduct,
1270
- schema.TermTermType.processedFood
1271
- ])
1272
- },
1273
- _b[schema.TermTermType.property] = {
1274
- label: termTypeLabel(schema.TermTermType.property),
1275
- termType: schema.TermTermType.property,
1276
- children: []
1277
- },
1278
- _b));
1279
- var termTypeGroups = [
1280
- groups.property,
1281
- groups.region,
1282
- groups.input,
1283
- groups.emission,
1284
- groups.product,
1285
- groups.practice,
1286
- groups.measurement,
1287
- groups.infrastructure
1288
- ];
1289
- var termToParent = (_c = {},
1290
- _c[schema.TermTermType.property] = 'Properties',
1291
- _c[schema.TermTermType.region] = 'Geographies',
1292
- _c);
1293
- var termChildToParent = function (termType) { return termTypeGroups.find(function (_a) {
1294
- var children = _a.children;
1295
- return (children || []).some(function (child) { return child.termType === termType; });
1296
- }) ||
1297
- { termType: termToParent[termType] }; };
1298
- var sortOrder = [
1299
- schema.TermTermType.property,
1300
- schema.TermTermType.crop,
1301
- schema.TermTermType.cropResidue,
1302
- schema.TermTermType.animalProduct,
1303
- schema.TermTermType.liveAnimal,
1304
- schema.TermTermType.liveAquaticSpecies,
1305
- schema.TermTermType.processedFood,
1306
- schema.TermTermType.emission,
1307
- schema.TermTermType.resourceUse,
1308
- schema.TermTermType.inorganicFertilizer,
1309
- schema.TermTermType.organicFertilizer,
1310
- schema.TermTermType.soilAmendment,
1311
- schema.TermTermType.soilTexture,
1312
- schema.TermTermType.water,
1313
- schema.TermTermType.material,
1314
- schema.TermTermType.antibiotic,
1315
- schema.TermTermType.electricity,
1316
- schema.TermTermType.fuel,
1317
- schema.TermTermType.aquacultureManagement,
1318
- schema.TermTermType.biodiversity,
1319
- schema.TermTermType.cropResidueManagement,
1320
- schema.TermTermType.animalManagement,
1321
- schema.TermTermType.waterRegime,
1322
- schema.TermTermType.system,
1323
- schema.TermTermType.tillage,
1324
- schema.TermTermType.landUseManagement,
1325
- schema.TermTermType.operation,
1326
- schema.TermTermType.cropEstablishment,
1327
- schema.TermTermType.measurement,
1328
- schema.TermTermType.soilType,
1329
- schema.TermTermType.usdaSoilType,
1330
- schema.TermTermType.methodMeasurement,
1331
- schema.TermTermType.building,
1332
- schema.TermTermType.cropProtection,
1333
- schema.TermTermType.cropSupport,
1334
- schema.TermTermType.irrigation,
1335
- schema.TermTermType.machinery,
1336
- schema.TermTermType.model,
1337
- schema.TermTermType.characterisedIndicator,
1338
- schema.TermTermType.endpointIndicator,
1339
- schema.TermTermType.methodEmissionResourceUse,
1340
- schema.TermTermType.other,
1341
- schema.TermTermType.region,
1342
- schema.TermTermType.pesticideAI,
1343
- schema.TermTermType.pesticideBrandName,
1344
- schema.TermTermType.standardsLabels
1345
- ];
1346
-
1041
+ var lookupUrl = function (filename) { return filename.startsWith('http') ? filename : baseUrl() + "/glossary/lookups/" + filename + ".csv"; };
1042
+ var termTypeLookupUrl = function (termType) { return baseUrl() + "/glossary/" + termChildToParent(termType).termType + "/" + termType + ".csv"; };
1347
1043
  var HeNodeService = /** @class */ (function () {
1348
1044
  function HeNodeService(http, authService, commonService) {
1349
1045
  this.http = http;
@@ -1398,28 +1094,20 @@
1398
1094
  .catch(function () { return (responseType === 'json' ? ({}) : ''); });
1399
1095
  };
1400
1096
  HeNodeService.prototype.nodeTypeUrl = function (type) {
1401
- return this.commonService.apiBaseUrl + "/" + api.nodeTypeToParam(type);
1402
- };
1403
- HeNodeService.prototype.nodeUrl = function (_a) {
1404
- var dataState = _a.dataState, node = __rest(_a, ["dataState"]);
1405
- return this.nodeTypeUrl(node['@type'] || node.type) + "/" + (node['@id'] || node.id) + (dataState ? "?dataState=" + dataState : '');
1406
- };
1407
- HeNodeService.prototype.nodeLogsUrl = function (_a) {
1408
- var dataState = _a.dataState, node = __rest(_a, ["dataState"]);
1409
- return this.nodeUrl(node) + "/log" + (dataState ? "?dataState=" + dataState : '');
1097
+ return nodeTypeUrl(this.commonService.apiBaseUrl, type);
1410
1098
  };
1411
- HeNodeService.prototype.lookupUrl = function (filename) {
1412
- return filename.startsWith('http') ? filename : baseUrl() + "/glossary/lookups/" + filename + ".csv";
1099
+ HeNodeService.prototype.nodeUrl = function (node) {
1100
+ return nodeUrl(this.commonService.apiBaseUrl, node);
1413
1101
  };
1414
- HeNodeService.prototype.termTypeLookupUrl = function (termType) {
1415
- return baseUrl() + "/glossary/" + termChildToParent(termType).termType + "/" + termType + ".csv";
1102
+ HeNodeService.prototype.nodeLogsUrl = function (node) {
1103
+ return nodeLogsUrl(this.commonService.apiBaseUrl, node);
1416
1104
  };
1417
1105
  HeNodeService.prototype.downloadLookup = function (filename) {
1418
1106
  return __awaiter(this, void 0, void 0, function () {
1419
1107
  var url;
1420
1108
  return __generator(this, function (_b) {
1421
1109
  try {
1422
- url = this.lookupUrl(filename);
1110
+ url = lookupUrl(filename);
1423
1111
  return [2 /*return*/, this.downloadRaw(url, 'text')];
1424
1112
  }
1425
1113
  catch (_err) {
@@ -1439,7 +1127,7 @@
1439
1127
  return [4 /*yield*/, this.downloadLookup(termType)];
1440
1128
  case 1:
1441
1129
  data = _b.sent();
1442
- return [2 /*return*/, (data === null || data === void 0 ? void 0 : data.startsWith('term.id')) ? this.lookupUrl(termType) : null];
1130
+ return [2 /*return*/, (data === null || data === void 0 ? void 0 : data.startsWith('term.id')) ? lookupUrl(termType) : null];
1443
1131
  case 2:
1444
1132
  _err_1 = _b.sent();
1445
1133
  return [2 /*return*/, null];
@@ -1459,54 +1147,15 @@
1459
1147
  }]
1460
1148
  }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeAuthService }, { type: HeCommonService }]; } });
1461
1149
 
1462
- var get$4 = require('lodash.get');
1150
+ var gitUrl$1 = function () { return gitHome + "/hestia-aggregation-engine/-/blob/" + gitBranch(); };
1151
+ var rawUrl$1 = function () { return gitRawBaseUrl + "/hestia-aggregation-engine/-/raw/" + gitBranch(); };
1463
1152
  var lookups = Object.freeze({
1464
1153
  cropYield: 'region-crop-cropGroupingFaostatProduction-yield',
1465
1154
  cropGroupingColumn: 'cropGroupingFaostatProduction'
1466
1155
  });
1467
- var extractGroupedDataClosesDate = function (data, year) {
1468
- var dataByDate = (data || '').split(';').reduce(function (prev, curr) {
1469
- var _d;
1470
- return (Object.assign(Object.assign({}, prev), (curr.length > 0 && curr.split(':')[1] !== '-' ? (_d = {}, _d[curr.split(':')[0]] = curr.split(':')[1], _d) : {})));
1471
- }, {});
1472
- var years = Object.keys(dataByDate).map(function (v) { return +v; });
1473
- var closestYear = years.reduce(function (prev, curr) { return Math.abs(curr - year) < Math.abs(prev - year) ? curr : prev; }, 0);
1474
- return closestYear ? +dataByDate[closestYear] / 10 : null;
1475
- };
1476
- var cropGrouping = function (lookup, product) { return (lookup.find(function (_d) {
1477
- var term = _d.term;
1478
- return term.id === (product === null || product === void 0 ? void 0 : product.term['@id']);
1479
- }) || {})[lookups.cropGroupingColumn]; };
1480
- var cropYieldCountry = function (cropYield, cycle) { return cropYield.find(function (_d) {
1481
- var term = _d.term;
1482
- return term.id === get$4(cycle, 'site.country.@id', worldRegion['@id']);
1483
- }) || {}; };
1484
- var extendCycle = function (_d) {
1485
- var crop = _d.crop, cropYield = _d.cropYield;
1486
- return function (cycle) {
1487
- var _a, _b, _c;
1488
- var product = primaryProduct(cycle);
1489
- var grouping = cropGrouping(crop, product);
1490
- var countryData = cropYieldCountry(cropYield, cycle)[grouping];
1491
- var countryValue = extractGroupedDataClosesDate(countryData, +(cycle.endDate || ''));
1492
- var productValue = propertyValue$1(product === null || product === void 0 ? void 0 : product.value);
1493
- return {
1494
- cycle: cycle,
1495
- name: (_a = product === null || product === void 0 ? void 0 : product.term) === null || _a === void 0 ? void 0 : _a.name,
1496
- startDate: cycle.startDate,
1497
- endDate: cycle.endDate,
1498
- country: ((_c = (_b = cycle.site) === null || _b === void 0 ? void 0 : _b.country) === null || _c === void 0 ? void 0 : _c.name) || worldRegion.name,
1499
- observations: propertyValue$1(product === null || product === void 0 ? void 0 : product.observations) || 0,
1500
- yield: productValue,
1501
- faoYield: countryValue || undefined,
1502
- diff: delta(productValue, countryValue)
1503
- };
1504
- };
1505
- };
1506
1156
  var HeAggregationEngineService = /** @class */ (function () {
1507
- function HeAggregationEngineService(http, commonService, nodeService) {
1157
+ function HeAggregationEngineService(http, nodeService) {
1508
1158
  this.http = http;
1509
- this.commonService = commonService;
1510
1159
  this.nodeService = nodeService;
1511
1160
  this.modelsLoading = false;
1512
1161
  this.modelsLoaded = false;
@@ -1518,38 +1167,24 @@
1518
1167
  }
1519
1168
  HeAggregationEngineService.prototype.init = function () {
1520
1169
  return __awaiter(this, void 0, void 0, function () {
1521
- return __generator(this, function (_d) {
1522
- switch (_d.label) {
1170
+ return __generator(this, function (_b) {
1171
+ switch (_b.label) {
1523
1172
  case 0: return [4 /*yield*/, this.loadModels().toPromise()];
1524
1173
  case 1:
1525
- _d.sent();
1174
+ _b.sent();
1526
1175
  return [2 /*return*/];
1527
1176
  }
1528
1177
  });
1529
1178
  });
1530
1179
  };
1531
- Object.defineProperty(HeAggregationEngineService.prototype, "gitUrl", {
1532
- get: function () {
1533
- return gitHome + "/hestia-aggregation-engine/-/blob/" + this.commonService.gitBranch;
1534
- },
1535
- enumerable: false,
1536
- configurable: true
1537
- });
1538
- Object.defineProperty(HeAggregationEngineService.prototype, "rawUrl", {
1539
- get: function () {
1540
- return gitRawBaseUrl + "/hestia-aggregation-engine/-/raw/" + this.commonService.gitBranch;
1541
- },
1542
- enumerable: false,
1543
- configurable: true
1544
- });
1545
1180
  HeAggregationEngineService.prototype.loadModels = function () {
1546
1181
  var _this = this;
1547
1182
  this.modelsLoading = true;
1548
- return this.http.get(this.rawUrl + "/model-links.json").pipe(operators.catchError(function () { return rxjs.of({ links: [] }); }), operators.map(function (_d) {
1549
- var links = _d.links;
1183
+ return this.http.get(rawUrl$1() + "/model-links.json").pipe(operators.catchError(function () { return rxjs.of({ links: [] }); }), operators.map(function (_b) {
1184
+ var links = _b.links;
1550
1185
  _this._models.next(links.map(function (_a) {
1551
1186
  var modelPath = _a.path, docPath = _a.docPath, link = __rest(_a, ["path", "docPath"]);
1552
- return (Object.assign(Object.assign({}, link), { path: _this.gitUrl + "/" + modelPath, docPath: _this.gitUrl + "/" + docPath }));
1187
+ return (Object.assign(Object.assign({}, link), { path: gitUrl$1() + "/" + modelPath, docPath: gitUrl$1() + "/" + docPath }));
1553
1188
  }));
1554
1189
  _this.modelsLoading = false;
1555
1190
  _this.modelsLoaded = true;
@@ -1575,11 +1210,11 @@
1575
1210
  HeAggregationEngineService.prototype.loadLookup = function (filename) {
1576
1211
  return __awaiter(this, void 0, void 0, function () {
1577
1212
  var data;
1578
- return __generator(this, function (_d) {
1579
- switch (_d.label) {
1213
+ return __generator(this, function (_b) {
1214
+ switch (_b.label) {
1580
1215
  case 0: return [4 /*yield*/, this.nodeService.downloadLookup(filename)];
1581
1216
  case 1:
1582
- data = _d.sent();
1217
+ data = _b.sent();
1583
1218
  return [2 /*return*/, csvtojson__namespace({ delimiter: 'auto' }).fromString(data)];
1584
1219
  }
1585
1220
  });
@@ -1609,16 +1244,18 @@
1609
1244
  };
1610
1245
  return HeAggregationEngineService;
1611
1246
  }());
1612
- HeAggregationEngineService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeAggregationEngineService, deps: [{ token: i1__namespace$1.HttpClient }, { token: HeCommonService }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1247
+ HeAggregationEngineService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeAggregationEngineService, deps: [{ token: i1__namespace$1.HttpClient }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1613
1248
  HeAggregationEngineService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeAggregationEngineService, providedIn: 'root' });
1614
1249
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeAggregationEngineService, decorators: [{
1615
1250
  type: i0.Injectable,
1616
1251
  args: [{
1617
1252
  providedIn: 'root'
1618
1253
  }]
1619
- }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeCommonService }, { type: HeNodeService }]; } });
1254
+ }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeNodeService }]; } });
1620
1255
 
1621
1256
  var HE_ORCHESTRATOR_BASE_URL = new i0.InjectionToken('HE_ORCHESTRATOR_BASE_URL');
1257
+ var gitUrl = function () { return gitHome + "/hestia-engine-models/-/blob/" + gitBranch(); };
1258
+ var rawUrl = function () { return gitRawBaseUrl + "/hestia-engine-models/-/raw/" + gitBranch(); };
1622
1259
  var findConfigModels = function (_b, modelId, modelKey) {
1623
1260
  var models = _b.models;
1624
1261
  return models.flat().filter(function (_b) {
@@ -1636,9 +1273,8 @@
1636
1273
  ].filter(Boolean).join('-')
1637
1274
  ].join('/'); };
1638
1275
  var HeEngineService = /** @class */ (function () {
1639
- function HeEngineService(http, commonService) {
1276
+ function HeEngineService(http) {
1640
1277
  this.http = http;
1641
- this.commonService = commonService;
1642
1278
  this.modelsLoading = false;
1643
1279
  this.modelsLoaded = false;
1644
1280
  this._models = new rxjs.ReplaySubject(1);
@@ -1656,28 +1292,14 @@
1656
1292
  });
1657
1293
  });
1658
1294
  };
1659
- Object.defineProperty(HeEngineService.prototype, "gitUrl", {
1660
- get: function () {
1661
- return gitHome + "/hestia-engine-models/-/blob/" + this.commonService.gitBranch;
1662
- },
1663
- enumerable: false,
1664
- configurable: true
1665
- });
1666
- Object.defineProperty(HeEngineService.prototype, "rawUrl", {
1667
- get: function () {
1668
- return gitRawBaseUrl + "/hestia-engine-models/-/raw/" + this.commonService.gitBranch;
1669
- },
1670
- enumerable: false,
1671
- configurable: true
1672
- });
1673
1295
  HeEngineService.prototype.loadModels = function () {
1674
1296
  var _this = this;
1675
1297
  this.modelsLoading = true;
1676
- return this.http.get(this.rawUrl + "/model-links.json").pipe(operators.catchError(function () { return rxjs.of({ links: [] }); }), operators.map(function (_b) {
1298
+ return this.http.get(rawUrl() + "/model-links.json").pipe(operators.catchError(function () { return rxjs.of({ links: [] }); }), operators.map(function (_b) {
1677
1299
  var links = _b.links;
1678
1300
  _this._models.next(links.map(function (_a) {
1679
1301
  var path = _a.path, docPath = _a.docPath, link = __rest(_a, ["path", "docPath"]);
1680
- return (Object.assign(Object.assign({}, link), { path: _this.gitUrl + "/" + path, docPath: _this.gitUrl + "/" + docPath, apiDocsPath: pathToApiDocsPath(link.model, link.term || link.modelKey) }));
1302
+ return (Object.assign(Object.assign({}, link), { path: gitUrl() + "/" + path, docPath: gitUrl() + "/" + docPath, apiDocsPath: pathToApiDocsPath(link.model, link.term || link.modelKey) }));
1681
1303
  }));
1682
1304
  _this.modelsLoading = false;
1683
1305
  _this.modelsLoaded = true;
@@ -1707,14 +1329,14 @@
1707
1329
  };
1708
1330
  return HeEngineService;
1709
1331
  }());
1710
- HeEngineService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeEngineService, deps: [{ token: i1__namespace$1.HttpClient }, { token: HeCommonService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1332
+ HeEngineService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeEngineService, deps: [{ token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1711
1333
  HeEngineService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeEngineService, providedIn: 'root' });
1712
1334
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeEngineService, decorators: [{
1713
1335
  type: i0.Injectable,
1714
1336
  args: [{
1715
1337
  providedIn: 'root'
1716
1338
  }]
1717
- }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeCommonService }]; } });
1339
+ }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }]; } });
1718
1340
 
1719
1341
  var NodeKeyState;
1720
1342
  (function (NodeKeyState) {
@@ -2390,11 +2012,11 @@
2390
2012
  }] } });
2391
2013
 
2392
2014
  var toastId = 0;
2393
- var ToastService = /** @class */ (function () {
2394
- function ToastService() {
2015
+ var HeToastService = /** @class */ (function () {
2016
+ function HeToastService() {
2395
2017
  this.toasts = new rxjs.ReplaySubject(1);
2396
2018
  }
2397
- ToastService.prototype.success = function (message, duration) {
2019
+ HeToastService.prototype.success = function (message, duration) {
2398
2020
  if (duration === void 0) { duration = 3000; }
2399
2021
  this.toasts.next({
2400
2022
  id: ++toastId,
@@ -2404,7 +2026,7 @@
2404
2026
  showRawMessage: true
2405
2027
  });
2406
2028
  };
2407
- ToastService.prototype.error = function (message, showRawMessage, duration) {
2029
+ HeToastService.prototype.error = function (message, showRawMessage, duration) {
2408
2030
  if (showRawMessage === void 0) { showRawMessage = true; }
2409
2031
  if (duration === void 0) { duration = 3000; }
2410
2032
  this.toasts.next({
@@ -2415,11 +2037,11 @@
2415
2037
  showRawMessage: showRawMessage
2416
2038
  });
2417
2039
  };
2418
- return ToastService;
2040
+ return HeToastService;
2419
2041
  }());
2420
- ToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2421
- ToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastService, providedIn: 'root' });
2422
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastService, decorators: [{
2042
+ HeToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2043
+ HeToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeToastService, providedIn: 'root' });
2044
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeToastService, decorators: [{
2423
2045
  type: i0.Injectable,
2424
2046
  args: [{
2425
2047
  providedIn: 'root'
@@ -2451,7 +2073,7 @@
2451
2073
  };
2452
2074
  return ToastComponent;
2453
2075
  }());
2454
- ToastComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastComponent, deps: [{ token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Component });
2076
+ ToastComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastComponent, deps: [{ token: HeToastService }], target: i0__namespace.ɵɵFactoryTarget.Component });
2455
2077
  ToastComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ToastComponent, selector: "he-toast", ngImport: i0__namespace, template: "<div class=\"mb-3 columns is-centered is-vcentered\">\n <div class=\"notification is-{{toast.color}}\" role=\"alert\" *ngFor=\"let toast of toasts\">\n <button class=\"delete\" aria-label=\"delete\" (click)=\"dismiss(toast)\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n <strong [ngSwitch]=\"toast.color\">\n <ng-container *ngSwitchCase=\"'danger'\">\n <ng-container [ngSwitch]=\"toast.message\">\n <span *ngSwitchCase=\"'Unauthorized'\">You are not allowed to perform this action.</span>\n <span *ngSwitchCase=\"'form-invalid'\">Please fix all the errors on this page.</span>\n <span *ngSwitchCase=\"'users-email-already-taken'\">Email already taken.</span>\n <span *ngSwitchCase=\"'users-auth-already-taken'\">Account already connected.</span>\n <span *ngSwitchDefault>\n <span *ngIf=\"toast.showRawMessage\">{{toast.message}}</span>\n <span [class.is-hidden]=\"toast.showRawMessage\">An unknown error occurred. Please try again later.</span>\n </span>\n </ng-container>\n </ng-container>\n <ng-container *ngSwitchDefault>\n <span *ngIf=\"toast.showRawMessage\">{{toast.message}}</span>\n <span [class.is-hidden]=\"toast.showRawMessage\">An unknown error occurred. Please try again later.</span>\n </ng-container>\n </strong>\n </div>\n</div>\n", styles: [":host{bottom:0;position:fixed;width:100%}\n"], directives: [{ type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i3__namespace.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2456
2078
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastComponent, decorators: [{
2457
2079
  type: i0.Component,
@@ -2460,7 +2082,7 @@
2460
2082
  templateUrl: './toast.component.html',
2461
2083
  styleUrls: ['./toast.component.scss']
2462
2084
  }]
2463
- }], ctorParameters: function () { return [{ type: ToastService }]; } });
2085
+ }], ctorParameters: function () { return [{ type: HeToastService }]; } });
2464
2086
 
2465
2087
  var KeysPipe = /** @class */ (function () {
2466
2088
  function KeysPipe() {
@@ -2944,50 +2566,293 @@
2944
2566
  }]
2945
2567
  }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeCommonService }]; } });
2946
2568
 
2947
- var emptySearchResult = function () { return ({
2948
- time: 0,
2949
- count: 0,
2950
- results: []
2569
+ var _a$3, _b, _c, _d$1, _e;
2570
+ var searchableTypes = [
2571
+ schema.NodeType.Cycle,
2572
+ schema.NodeType.Source
2573
+ ];
2574
+ var serializeSearchFilters = function (filters) { return Object.keys(filters || {})
2575
+ .filter(function (key) { return filters[key].length; })
2576
+ .map(function (key) { return key + "=" + filters[key].filter(Boolean).join('|'); })
2577
+ .join(';'); };
2578
+ var deserializeSearchFilters = function (filters) { return (filters || '').split(';').reduce(function (prev, curr) {
2579
+ var _a = __read(curr.split('='), 2), key = _a[0], values = _a[1];
2580
+ prev[key] = (values || '').split('|').filter(Boolean);
2581
+ return prev;
2582
+ }, {}); };
2583
+ var matchType = function (type) { return Object.freeze({
2584
+ match: { '@type': type }
2951
2585
  }); };
2952
- var MAX_RESULTS = 10000;
2953
- var suggestMatchQuery = function (query) { return [
2954
- matchPhraseQuery(query, 10),
2955
- matchQuery('nameNormalized', query, 8),
2956
- matchPhrasePrefixQuery(query, 2)
2957
- ]; };
2958
- var suggestQuery = function (query, type, extraQueries) {
2959
- if (extraQueries === void 0) { extraQueries = []; }
2960
- return ({
2961
- bool: {
2962
- must: extraQueries,
2963
- should: (type ? [type] : searchableTypes).map(function (v) { return ({
2964
- bool: {
2965
- must: [matchType(v)],
2966
- should: suggestMatchQuery(query),
2967
- minimum_should_match: 1
2968
- }
2969
- }); }),
2970
- minimum_should_match: 1
2971
- }
2586
+ var matchTermType = function (termType) { return Object.freeze({
2587
+ match: { termType: termType }
2588
+ }); };
2589
+ var matchRegex = function (key, value) {
2590
+ var _a;
2591
+ return Object.freeze({
2592
+ regexp: (_a = {}, _a[key] = { value: value.toString() }, _a)
2972
2593
  });
2973
2594
  };
2974
- var suggestSourceQuery = function (query, fields) { return ({
2975
- bool: {
2976
- must: [matchType(schema.NodeType.Source)],
2977
- should: [
2978
- matchPhraseQuery.apply(void 0, __spreadArray([query, 100], __read(fields))),
2979
- matchPhrasePrefixQuery.apply(void 0, __spreadArray([query, 20], __read(fields))),
2980
- matchBoolPrefixQuery.apply(void 0, __spreadArray([query, 10], __read(fields)))
2981
- ],
2982
- minimum_should_match: 1
2595
+ var matchQuery = function (key, value, boost) {
2596
+ var _a;
2597
+ return Object.freeze({
2598
+ match: (_a = {},
2599
+ _a[key] = Object.assign({ query: value }, (boost ? { boost: boost } : {})),
2600
+ _a)
2601
+ });
2602
+ };
2603
+ var matchExactQuery = function (key, value, boost) { return matchQuery(key + ".keyword", value, boost); };
2604
+ var matchNameNormalized = function (query, boost) {
2605
+ if (boost === void 0) { boost = 20; }
2606
+ return Object.freeze({
2607
+ match: { nameNormalized: { query: query, boost: boost } }
2608
+ });
2609
+ };
2610
+ var numberGte = function (key, value) {
2611
+ var _a;
2612
+ return Object.freeze({
2613
+ range: (_a = {}, _a[key] = { gte: value }, _a)
2614
+ });
2615
+ };
2616
+ var multiMatchQuery = function (query, fields, type, boost, analyzer) {
2617
+ if (type === void 0) { type = 'best_fields'; }
2618
+ return Object.freeze({
2619
+ multi_match: Object.assign(Object.assign({ query: query, fields: fields, type: type }, (boost ? { boost: boost } : {})), (analyzer ? { analyzer: analyzer } : {}))
2620
+ });
2621
+ };
2622
+ var matchPhraseQuery = function (query, boost) {
2623
+ var fields = [];
2624
+ for (var _i = 2; _i < arguments.length; _i++) {
2625
+ fields[_i - 2] = arguments[_i];
2983
2626
  }
2984
- }); };
2985
- var HeSearchService = /** @class */ (function () {
2986
- function HeSearchService(http, commonService) {
2987
- this.http = http;
2988
- this.commonService = commonService;
2627
+ return fields.length ? multiMatchQuery(query, fields, 'phrase', boost) : matchExactQuery('name', query, boost);
2628
+ };
2629
+ var matchPhrasePrefixQuery = function (query, boost) {
2630
+ if (boost === void 0) { boost = 2; }
2631
+ var fields = [];
2632
+ for (var _i = 2; _i < arguments.length; _i++) {
2633
+ fields[_i - 2] = arguments[_i];
2989
2634
  }
2990
- HeSearchService.prototype.search = function (params) {
2635
+ return fields.length ?
2636
+ multiMatchQuery(query, fields, 'phrase_prefix', boost) :
2637
+ Object.freeze({
2638
+ match_phrase_prefix: {
2639
+ nameSearchAsYouType: {
2640
+ query: query,
2641
+ boost: boost
2642
+ }
2643
+ }
2644
+ });
2645
+ };
2646
+ var matchBoolPrefixQuery = function (query, boost) {
2647
+ if (boost === void 0) { boost = 1; }
2648
+ var fields = [];
2649
+ for (var _i = 2; _i < arguments.length; _i++) {
2650
+ fields[_i - 2] = arguments[_i];
2651
+ }
2652
+ return fields.length ?
2653
+ multiMatchQuery(query, fields, 'bool_prefix', boost) :
2654
+ Object.freeze({
2655
+ match_bool_prefix: {
2656
+ name: {
2657
+ query: query,
2658
+ boost: boost
2659
+ }
2660
+ }
2661
+ });
2662
+ };
2663
+ var wildcardQuery = function (query, boost) {
2664
+ if (boost === void 0) { boost = 3; }
2665
+ var fields = [];
2666
+ for (var _i = 2; _i < arguments.length; _i++) {
2667
+ fields[_i - 2] = arguments[_i];
2668
+ }
2669
+ return Object.freeze({
2670
+ simple_query_string: {
2671
+ query: "*" + query + "*",
2672
+ fields: fields,
2673
+ analyze_wildcard: true,
2674
+ boost: boost
2675
+ }
2676
+ });
2677
+ };
2678
+ var matchCountryLevel = { match: { gadmLevel: 0 } };
2679
+ var matchGlobalRegion = { regexp: { '@id': 'region-*' } };
2680
+ var matchCountry = Object.freeze({
2681
+ bool: {
2682
+ should: [
2683
+ matchCountryLevel,
2684
+ matchGlobalRegion
2685
+ ],
2686
+ minimum_should_match: 1
2687
+ }
2688
+ });
2689
+ var countriesQuery = Object.freeze({
2690
+ bool: {
2691
+ must: [
2692
+ matchType(schema.NodeType.Term),
2693
+ matchTermType(schema.TermTermType.region),
2694
+ matchCountryLevel
2695
+ ]
2696
+ }
2697
+ });
2698
+ var allCountriesQuery = Object.freeze({
2699
+ bool: Object.assign({ must: [
2700
+ matchType(schema.NodeType.Term),
2701
+ matchTermType(schema.TermTermType.region)
2702
+ ] }, matchCountry.bool)
2703
+ });
2704
+ var matchRegion = numberGte('gadmLevel', 1);
2705
+ var regionsQuery = Object.freeze({
2706
+ bool: {
2707
+ must: [
2708
+ matchType(schema.NodeType.Term),
2709
+ matchTermType(schema.TermTermType.region),
2710
+ matchRegion
2711
+ ]
2712
+ }
2713
+ });
2714
+ var worldRegion = Object.freeze({
2715
+ '@id': 'region-world',
2716
+ name: 'World'
2717
+ });
2718
+ var cropsQuery = Object.freeze({
2719
+ bool: {
2720
+ must: [
2721
+ matchType(schema.NodeType.Term),
2722
+ matchTermType(schema.TermTermType.crop)
2723
+ ]
2724
+ }
2725
+ });
2726
+ var matchAggregatedQuery = matchQuery('aggregated', true);
2727
+ var isNestedKey = function (key) { return schema.nestedSearchableKeys.includes(key.split('.')[0]); };
2728
+ var matchNestedKey = function (key, query) { return isNestedKey(key) ? {
2729
+ nested: { path: key.split('.')[0], query: query }
2730
+ } : query; };
2731
+ /**
2732
+ * List of fields to return in the search results.
2733
+ */
2734
+ var searchResultsFields = Object.freeze((_a$3 = {},
2735
+ _a$3[schema.NodeType.Cycle] = [
2736
+ 'description', 'dataDescription', 'endDate',
2737
+ 'emissionsCount', 'inputsCount', 'productsCount',
2738
+ 'site.location', 'site.country.name', 'site.region.name'
2739
+ ],
2740
+ _a$3[schema.NodeType.Source] = ['bibliography.title', 'bibliography.documentDOI'],
2741
+ _a$3[schema.NodeType.ImpactAssessment] = ['emissionsResourceUseCount', 'impactsCount', 'country.name'],
2742
+ _a$3));
2743
+ /**
2744
+ * List of fields to search in.
2745
+ */
2746
+ var searchFields = Object.freeze((_b = {},
2747
+ _b[schema.NodeType.Cycle] = ['name', 'description', 'dataDescription'],
2748
+ _b[schema.NodeType.Source] = ['name', 'bibliography.title'],
2749
+ _b[schema.NodeType.ImpactAssessment] = ['name', 'product.name', 'country.name'],
2750
+ _b));
2751
+ var searchFieldsNested = Object.freeze((_c = {},
2752
+ _c[schema.NodeType.Cycle] = [
2753
+ 'inputs.term.name',
2754
+ 'emissions.term.name',
2755
+ 'practices.term.name'
2756
+ ],
2757
+ _c[schema.NodeType.Source] = [],
2758
+ _c[schema.NodeType.ImpactAssessment] = [
2759
+ 'emissionsResourceUse.term.name',
2760
+ 'impacts.term.name'
2761
+ ],
2762
+ _c));
2763
+ /**
2764
+ * Specific strict queries per type.
2765
+ */
2766
+ var searchQueries = (_d$1 = {},
2767
+ _d$1[schema.NodeType.Cycle] = { must: [], must_not: [matchAggregatedQuery] },
2768
+ _d$1[schema.NodeType.Source] = { must: [], must_not: [matchAggregatedQuery] },
2769
+ _d$1);
2770
+ var searchFiltersKeys = (_e = {},
2771
+ _e[schema.NodeType.Cycle] = function (key) { return key; },
2772
+ _e[schema.NodeType.Source] = function (key) { return key; },
2773
+ _e);
2774
+ /* eslint-disable complexity */
2775
+ var searchQuery = function (type, query, filters, aggregated) {
2776
+ var boolQuery = (Object.assign(Object.assign({ must: [
2777
+ matchType(type),
2778
+ aggregated ? matchAggregatedQuery : null
2779
+ ].filter(Boolean) }, (query ? {
2780
+ should: __spreadArray([
2781
+ matchPhraseQuery.apply(void 0, __spreadArray([query, 100], __read(searchFields[type]))),
2782
+ matchPhrasePrefixQuery.apply(void 0, __spreadArray([query, 20], __read(searchFields[type]))),
2783
+ matchBoolPrefixQuery.apply(void 0, __spreadArray([query, 10], __read(searchFields[type])))
2784
+ ], __read(searchFieldsNested[type].map(function (field) { return matchNestedKey(field, matchBoolPrefixQuery(query, 1, field)); }))),
2785
+ minimum_should_match: 1
2786
+ } : {})), { must_not: [
2787
+ aggregated ? null : matchAggregatedQuery
2788
+ ].filter(Boolean) }));
2789
+ var keys = Object.keys(filters || {}).filter(function (key) { return filters[key].length; });
2790
+ return {
2791
+ bool: keys.length ? {
2792
+ must: keys.map(function (key) {
2793
+ var filterKey = searchFiltersKeys[type](key);
2794
+ return {
2795
+ bool: {
2796
+ should: filters[key]
2797
+ .map(function (value) { return matchNestedKey(filterKey, matchExactQuery(filterKey, value)); })
2798
+ .map(function (must) {
2799
+ var localQuery = JSON.parse(JSON.stringify(boolQuery));
2800
+ localQuery.must.push(must);
2801
+ return { bool: localQuery };
2802
+ }),
2803
+ minimum_should_match: 1
2804
+ }
2805
+ };
2806
+ })
2807
+ } : boolQuery
2808
+ };
2809
+ };
2810
+ /* eslint-enable complexity */
2811
+
2812
+ var emptySearchResult = function () { return ({
2813
+ time: 0,
2814
+ count: 0,
2815
+ results: []
2816
+ }); };
2817
+ var MAX_RESULTS = 10000;
2818
+ var suggestMatchQuery = function (query) { return [
2819
+ matchPhraseQuery(query, 10),
2820
+ matchQuery('nameNormalized', query, 8),
2821
+ matchPhrasePrefixQuery(query, 2)
2822
+ ]; };
2823
+ var suggestQuery = function (query, type, extraQueries) {
2824
+ if (extraQueries === void 0) { extraQueries = []; }
2825
+ return ({
2826
+ bool: {
2827
+ must: extraQueries,
2828
+ should: (type ? [type] : searchableTypes).map(function (v) { return ({
2829
+ bool: {
2830
+ must: [matchType(v)],
2831
+ should: suggestMatchQuery(query),
2832
+ minimum_should_match: 1
2833
+ }
2834
+ }); }),
2835
+ minimum_should_match: 1
2836
+ }
2837
+ });
2838
+ };
2839
+ var suggestSourceQuery = function (query, fields) { return ({
2840
+ bool: {
2841
+ must: [matchType(schema.NodeType.Source)],
2842
+ should: [
2843
+ matchPhraseQuery.apply(void 0, __spreadArray([query, 100], __read(fields))),
2844
+ matchPhrasePrefixQuery.apply(void 0, __spreadArray([query, 20], __read(fields))),
2845
+ matchBoolPrefixQuery.apply(void 0, __spreadArray([query, 10], __read(fields)))
2846
+ ],
2847
+ minimum_should_match: 1
2848
+ }
2849
+ }); };
2850
+ var HeSearchService = /** @class */ (function () {
2851
+ function HeSearchService(http, commonService) {
2852
+ this.http = http;
2853
+ this.commonService = commonService;
2854
+ }
2855
+ HeSearchService.prototype.search = function (params) {
2991
2856
  return this.http.post(this.commonService.apiBaseUrl + "/search", params)
2992
2857
  .pipe(operators.catchError(function () { return rxjs.of(emptySearchResult()); }))
2993
2858
  .toPromise();
@@ -3234,6 +3099,14 @@
3234
3099
  emptyFieldValue: ''
3235
3100
  }); };
3236
3101
 
3102
+ var primaryProduct = function (_a) {
3103
+ var products = _a.products;
3104
+ return (products || []).find(function (_a) {
3105
+ var primary = _a.primary;
3106
+ return primary;
3107
+ });
3108
+ };
3109
+
3237
3110
  var _a$1;
3238
3111
  var linkTypeEnabled = function (type) { return [
3239
3112
  schema.NodeType.Cycle,
@@ -4909,459 +4782,27 @@
4909
4782
  }]
4910
4783
  }] });
4911
4784
 
4912
- var isSite = function (_a) {
4913
- var type = _a["@type"], id = _a["@id"];
4914
- return type === schema.NodeType.Site && !!id;
4785
+ var _f;
4786
+ var mapErrorMessage = 'does not contain latitude and longitude';
4787
+ var parseDataPath = function (dataPath) {
4788
+ var _f = __read(dataPath.split('.')), _ = _f[0], paths = _f.slice(1);
4789
+ return paths.map(function (path) { return ({ path: path, label: keyToLabel(path.replace(/\[\d+\]/g, '')) }); });
4915
4790
  };
4916
- var siteLocation = function (_a) {
4917
- var latitude = _a.latitude, longitude = _a.longitude;
4918
- return latitude && longitude ? ({
4919
- lat: latitude,
4920
- lng: longitude
4921
- }) : undefined;
4791
+ var contactUsEmail = 'community@hestia.earth';
4792
+ var externalLink = function (href, text) { return "<a href=\"" + href + "\" target=\"_blank\">" + text + "</a>"; };
4793
+ var glossaryLink = function (text) { return externalLink(baseUrl() + "/glossary", text); };
4794
+ var glossaryTypeLink = function (type) { return externalLink(baseUrl() + "/glossary?termType=" + type, termTypeLabel(type)); };
4795
+ var termLink = function (_f) {
4796
+ var id = _f.id, name = _f.name;
4797
+ return externalLink(baseUrl() + "/term/" + id, name);
4922
4798
  };
4923
- var siteDefaultLocation = function (_a) {
4924
- var region = _a.region, country = _a.country;
4925
- var markers = [
4926
- region ? createMarker(termLocation(region), termLocationName(region).name, undefined, 20) : undefined,
4927
- country ? createMarker(termLocation(country), termLocationName(country).name, undefined, 40) : undefined
4928
- ].filter(Boolean);
4929
- return (markers.length ? markers[0] : undefined);
4799
+ var nodeLink = function (_f) {
4800
+ var type = _f["@type"], id = _f["@id"], name = _f.name;
4801
+ return type && id ? "<a href=\"/" + type.toLowerCase() + "/" + id + "\" target=\"_blank\">" + (name || id) + "</a>" : null;
4930
4802
  };
4931
- var siteMarker = function (site) { return createMarker(site ? siteLocation(site) : undefined, site.name); };
4932
- var sitePolygon = function (_a) {
4933
- var boundary = _a.boundary;
4934
- return (boundary ? polygonsFromFeature(boundary) : undefined);
4935
- };
4936
- var regions = function (sites) { return utils.unique(sites.map(function (_a) {
4937
- var country = _a.country, region = _a.region;
4938
- return region ? region['@id'] : (country ? country['@id'] : null);
4939
- }).filter(Boolean)); };
4940
- var defaultCenter = { lat: 0, lng: 0 };
4941
- var SitesMapsComponent = /** @class */ (function () {
4942
- function SitesMapsComponent(nodeService) {
4943
- this.nodeService = nodeService;
4944
- this.loaded = false;
4945
- this.loadPolygons = true;
4946
- this.sites = [];
4947
- this.nodes = [];
4948
- this.center = defaultCenter;
4949
- this.zoom = 2;
4950
- this.showNotice = true;
4951
- this.googleLoaded = false;
4952
- this.showNoLocation = false;
4953
- }
4954
- SitesMapsComponent.prototype.ngOnInit = function () {
4955
- var _this = this;
4956
- waitFor('google', function () {
4957
- _this.googleLoaded = true;
4958
- setTimeout(function () { return !_this.loaded && _this.loadData(); });
4959
- });
4960
- };
4961
- SitesMapsComponent.prototype.ngAfterViewInit = function () {
4962
- return this.googleLoaded && this.loadData();
4963
- };
4964
- SitesMapsComponent.prototype.loadData = function () {
4965
- return __awaiter(this, void 0, void 0, function () {
4966
- var sites, markers, polygons, termPolygons;
4967
- var _this = this;
4968
- return __generator(this, function (_a) {
4969
- switch (_a.label) {
4970
- case 0:
4971
- // loaded data as geojson
4972
- this.map.googleMap.data.setStyle(function () { return (Object.assign(Object.assign({}, strokeStyle), { strokeOpacity: 0.1 })); });
4973
- return [4 /*yield*/, this.getSites()];
4974
- case 1:
4975
- sites = _a.sent();
4976
- markers = this.addSiteMarkers(sites);
4977
- polygons = sites.flatMap(sitePolygon).filter(Boolean);
4978
- polygons.map(function (polygon) { return polygon === null || polygon === void 0 ? void 0 : polygon.setMap(_this.map.googleMap); });
4979
- this.loaded = true;
4980
- return [4 /*yield*/, Promise.all(regions(sites).map(function (v) { return _this.addTermsPolygons(v); }))];
4981
- case 2:
4982
- termPolygons = (_a.sent()).flat();
4983
- this.showNoLocation = markers.length === 0 && polygons.length === 0 && termPolygons.length === 0;
4984
- return [2 /*return*/, markers.length ?
4985
- this.centerMarker(markers[0]) :
4986
- this.centerPolygons(polygons.length ? polygons : termPolygons)];
4987
- }
4988
- });
4989
- });
4990
- };
4991
- SitesMapsComponent.prototype.addMarkers = function (markers, cluster) {
4992
- var _this = this;
4993
- if (cluster === void 0) { cluster = false; }
4994
- return cluster ?
4995
- new MarkerClusterer__default["default"](this.map.googleMap, markers, { imagePath: clustererImage }) :
4996
- markers.map(function (marker) { return marker.setMap(_this.map.googleMap); });
4997
- };
4998
- SitesMapsComponent.prototype.addTermsPolygons = function (id) {
4999
- return __awaiter(this, void 0, void 0, function () {
5000
- var _a;
5001
- return __generator(this, function (_b) {
5002
- switch (_b.label) {
5003
- case 0:
5004
- if (!this.loadPolygons) return [3 /*break*/, 2];
5005
- return [4 /*yield*/, this.termPolygons(id)];
5006
- case 1:
5007
- _a = _b.sent();
5008
- return [3 /*break*/, 3];
5009
- case 2:
5010
- _a = [];
5011
- _b.label = 3;
5012
- case 3: return [2 /*return*/, _a];
5013
- }
5014
- });
5015
- });
5016
- };
5017
- SitesMapsComponent.prototype.centerMarker = function (marker) {
5018
- var center = marker.getPosition();
5019
- this.center = center ? { lat: center.lat(), lng: center.lng() } : defaultCenter;
5020
- };
5021
- SitesMapsComponent.prototype.centerPolygons = function (polygons) {
5022
- try {
5023
- return polygons.length ? this.map.googleMap.fitBounds(polygonBounds(polygons)) : null;
5024
- }
5025
- catch (err) {
5026
- if (polygons.length) {
5027
- this.map.googleMap.fitBounds(polygonBounds(polygons[0]));
5028
- this.zoom = 3;
5029
- }
5030
- }
5031
- };
5032
- SitesMapsComponent.prototype.addSiteMarkers = function (sites) {
5033
- var siteMarkers = sites.map(siteMarker).filter(Boolean);
5034
- var markers = siteMarkers.length ? siteMarkers : sites.map(siteDefaultLocation).filter(Boolean);
5035
- this.addMarkers(markers, !!siteMarkers.length);
5036
- return markers;
5037
- };
5038
- SitesMapsComponent.prototype.loadSite = function (node) {
5039
- return __awaiter(this, void 0, void 0, function () {
5040
- var _a;
5041
- return __generator(this, function (_b) {
5042
- switch (_b.label) {
5043
- case 0:
5044
- if (!('schemaVersion' in node)) return [3 /*break*/, 1];
5045
- _a = node;
5046
- return [3 /*break*/, 3];
5047
- case 1: return [4 /*yield*/, this.nodeService.get(node)];
5048
- case 2:
5049
- _a = _b.sent();
5050
- _b.label = 3;
5051
- case 3:
5052
- // means the site was already downloaded
5053
- return [2 /*return*/, _a];
5054
- }
5055
- });
5056
- });
5057
- };
5058
- SitesMapsComponent.prototype.siteData = function (node) {
5059
- return __awaiter(this, void 0, void 0, function () {
5060
- var _a, _b, _c, _d;
5061
- return __generator(this, function (_e) {
5062
- switch (_e.label) {
5063
- case 0:
5064
- if (![
5065
- schema.NodeType.Site,
5066
- schema.NodeType.Organisation
5067
- ].includes(node.type)) return [3 /*break*/, 1];
5068
- _a = node;
5069
- return [3 /*break*/, 7];
5070
- case 1:
5071
- if (!isSite(node)) return [3 /*break*/, 2];
5072
- _b = this.loadSite(node);
5073
- return [3 /*break*/, 6];
5074
- case 2:
5075
- if (!('site' in node && isSite(node.site))) return [3 /*break*/, 3];
5076
- _c = this.loadSite(node.site);
5077
- return [3 /*break*/, 5];
5078
- case 3:
5079
- _d = this.siteData;
5080
- return [4 /*yield*/, this.loadSite(node)];
5081
- case 4:
5082
- _c = _d.apply(this, [_e.sent()]);
5083
- _e.label = 5;
5084
- case 5:
5085
- _b = (_c);
5086
- _e.label = 6;
5087
- case 6:
5088
- _a = (_b);
5089
- _e.label = 7;
5090
- case 7: return [2 /*return*/, _a];
5091
- }
5092
- });
5093
- });
5094
- };
5095
- SitesMapsComponent.prototype.getSites = function () {
5096
- var _this = this;
5097
- var nodes = this.sites && this.sites.length ? this.sites : this.nodes;
5098
- return Promise.all(nodes.map(function (node) { return _this.siteData(node); }));
5099
- };
5100
- SitesMapsComponent.prototype.termPolygons = function (id) {
5101
- return __awaiter(this, void 0, void 0, function () {
5102
- var data, polygons, _err_1;
5103
- var _this = this;
5104
- return __generator(this, function (_a) {
5105
- switch (_a.label) {
5106
- case 0:
5107
- _a.trys.push([0, 2, , 3]);
5108
- return [4 /*yield*/, this.nodeService.downloadRaw(baseUrl() + "/gadm/" + id + ".geojson")];
5109
- case 1:
5110
- data = _a.sent();
5111
- polygons = polygonsFromFeature(data);
5112
- polygons.map(function (polygon) { return polygon.setMap(_this.map.googleMap); });
5113
- return [2 /*return*/, polygons];
5114
- case 2:
5115
- _err_1 = _a.sent();
5116
- // ignore error if the file does not exist
5117
- return [2 /*return*/, []];
5118
- case 3: return [2 /*return*/];
5119
- }
5120
- });
5121
- });
5122
- };
5123
- return SitesMapsComponent;
5124
- }());
5125
- SitesMapsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMapsComponent, deps: [{ token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
5126
- SitesMapsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMapsComponent, selector: "he-sites-maps", inputs: { loadPolygons: "loadPolygons", sites: "sites", nodes: "nodes", center: "center", zoom: "zoom", showNotice: "showNotice" }, viewQueries: [{ propertyName: "map", first: true, predicate: i1$2.GoogleMap, descendants: true }], ngImport: i0__namespace, template: "<google-map *ngIf=\"googleLoaded\"\n height=\"100%\"\n width=\"100%\"\n [zoom]=\"zoom\"\n [center]=\"center\"\n></google-map>\n\n<p *ngIf=\"showNotice\" class=\"mt-2 is-italic is-size-7\">The information provided might not be complete</p>\n\n<div class=\"no-location has-text-center has-text-light\" *ngIf=\"showNoLocation\">\n <span>No precise location data</span>\n</div>\n", styles: [":host{display:block;height:100%;position:relative;width:100%}.no-location{background-color:#0000004d;left:0;height:100%;position:absolute;top:0;width:100%;z-index:9}.no-location>span{display:inline-block;margin-top:12%}\n"], components: [{ type: i1__namespace$2.GoogleMap, selector: "google-map", inputs: ["height", "width", "center", "zoom", "options", "mapTypeId"], outputs: ["authFailure", "boundsChanged", "centerChanged", "mapClick", "mapDblclick", "mapDrag", "mapDragend", "mapDragstart", "headingChanged", "idle", "maptypeidChanged", "mapMousemove", "mapMouseout", "mapMouseover", "projectionChanged", "mapRightclick", "tilesloaded", "tiltChanged", "zoomChanged"], exportAs: ["googleMap"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
5127
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMapsComponent, decorators: [{
5128
- type: i0.Component,
5129
- args: [{
5130
- selector: 'he-sites-maps',
5131
- templateUrl: './sites-maps.component.html',
5132
- styleUrls: ['./sites-maps.component.scss']
5133
- }]
5134
- }], ctorParameters: function () { return [{ type: HeNodeService }]; }, propDecorators: { map: [{
5135
- type: i0.ViewChild,
5136
- args: [i1$2.GoogleMap]
5137
- }], loadPolygons: [{
5138
- type: i0.Input
5139
- }], sites: [{
5140
- type: i0.Input
5141
- }], nodes: [{
5142
- type: i0.Input
5143
- }], center: [{
5144
- type: i0.Input
5145
- }], zoom: [{
5146
- type: i0.Input
5147
- }], showNotice: [{
5148
- type: i0.Input
5149
- }] } });
5150
-
5151
- var maxAreaSize = 5000;
5152
- var siteTooBig = function (_a) {
5153
- var area = _a.area;
5154
- return area && area / 100 > maxAreaSize;
5155
- };
5156
- var hasMultipleValues = function (values) { return (values || []).length > 1; };
5157
- var weighedAverage = function (_a) {
5158
- var value = _a.value, depthLower = _a.depthLower, depthUpper = _a.depthUpper;
5159
- return value.reduce(function (prev, curr, index) { return prev + (curr * (depthLower[index] - depthUpper[index])); }, 0) /
5160
- value.reduce(function (prev, _curr, index) { return prev + (depthLower[index] - depthUpper[index]); }, 0);
5161
- };
5162
- var measurementValue = function (_a) {
5163
- var value = _a.value, depthLower = _a.depthLower, depthUpper = _a.depthUpper;
5164
- return hasMultipleValues(value) && hasMultipleValues(depthLower) && hasMultipleValues(depthUpper) ?
5165
- weighedAverage({ value: value, depthLower: depthLower, depthUpper: depthUpper }) :
5166
- propertyValue$1(value);
5167
- };
5168
-
5169
- var SitesMeasurementsLogsComponent = /** @class */ (function () {
5170
- function SitesMeasurementsLogsComponent(searchService, nodeService) {
5171
- this.searchService = searchService;
5172
- this.nodeService = nodeService;
5173
- this.originalValues = [];
5174
- this.recalculatedValues = [];
5175
- this.loading = true;
5176
- this.NodeType = schema.NodeType;
5177
- this.models = [];
5178
- this.measurements = [];
5179
- }
5180
- SitesMeasurementsLogsComponent.prototype.ngOnInit = function () {
5181
- return __awaiter(this, void 0, void 0, function () {
5182
- var _a, measurements;
5183
- return __generator(this, function (_b) {
5184
- switch (_b.label) {
5185
- case 0:
5186
- this.logsUrl = this.nodeService.nodeLogsUrl(this.node);
5187
- _a = this;
5188
- return [4 /*yield*/, this.nodeService.getModelsLog(this.node)];
5189
- case 1:
5190
- _a.logs = _b.sent();
5191
- return [4 /*yield*/, this.searchService.search({
5192
- fields: ['@type', '@id', 'name'],
5193
- limit: 1000,
5194
- query: {
5195
- bool: {
5196
- must: [
5197
- matchType(schema.NodeType.Term),
5198
- matchTermType(schema.TermTermType.measurement)
5199
- ]
5200
- }
5201
- }
5202
- })];
5203
- case 2:
5204
- measurements = (_b.sent()).results;
5205
- this.measurements = measurements;
5206
- this.loading = false;
5207
- return [2 /*return*/];
5208
- }
5209
- });
5210
- });
5211
- };
5212
- Object.defineProperty(SitesMeasurementsLogsComponent.prototype, "node", {
5213
- get: function () {
5214
- return Object.assign(Object.assign({}, this.site), { dataState: api.DataState.recalculated });
5215
- },
5216
- enumerable: false,
5217
- configurable: true
5218
- });
5219
- return SitesMeasurementsLogsComponent;
5220
- }());
5221
- SitesMeasurementsLogsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsLogsComponent, deps: [{ token: HeSearchService }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
5222
- SitesMeasurementsLogsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMeasurementsLogsComponent, selector: "he-sites-measurements-logs", inputs: { site: "site", originalValues: "originalValues", recalculatedValues: "recalculatedValues" }, ngImport: i0__namespace, template: "<he-node-logs-models *ngIf=\"!loading; else loader\"\n [logsUrl]=\"logsUrl\"\n [nodeType]=\"NodeType.Site\"\n [originalValues]=\"originalValues\"\n [recalculatedValues]=\"recalculatedValues\"\n [terms]=\"measurements\"\n [logs]=\"logs\"\n filteredType=\"Measurement\"\n></he-node-logs-models>\n\n<ng-template #loader>\n <div class=\"has-text-center py-3\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"lg\"></fa-icon>\n </div>\n</ng-template>\n", styles: [""], components: [{ type: NodeLogsModelsComponent, selector: "he-node-logs-models", inputs: ["nodeType", "nodeKey", "logsUrl", "originalValues", "recalculatedValues", "terms", "logs", "filteredType"] }, { type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
5223
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsLogsComponent, decorators: [{
5224
- type: i0.Component,
5225
- args: [{
5226
- selector: 'he-sites-measurements-logs',
5227
- templateUrl: './sites-measurements-logs.component.html',
5228
- styleUrls: ['./sites-measurements-logs.component.scss']
5229
- }]
5230
- }], ctorParameters: function () { return [{ type: HeSearchService }, { type: HeNodeService }]; }, propDecorators: { site: [{
5231
- type: i0.Input
5232
- }], originalValues: [{
5233
- type: i0.Input
5234
- }], recalculatedValues: [{
5235
- type: i0.Input
5236
- }] } });
5237
-
5238
- var orderBy$1 = require('lodash.orderby');
5239
- var View$1;
5240
- (function (View) {
5241
- View["table"] = "table";
5242
- View["logs"] = "logs";
5243
- })(View$1 || (View$1 = {}));
5244
- var SitesMeasurementsComponent = /** @class */ (function () {
5245
- function SitesMeasurementsComponent() {
5246
- this.originalValues = [];
5247
- this.sites = [];
5248
- this.showDownload = false;
5249
- this.View = View$1;
5250
- this.selectedView = View$1.table;
5251
- this.maxAreaSize = maxAreaSize;
5252
- this.siteTooBig = siteTooBig;
5253
- this.defaultLabel = defaultLabel;
5254
- this.measurementValue = measurementValue;
5255
- this.measurements = [];
5256
- }
5257
- SitesMeasurementsComponent.prototype.ngOnChanges = function (changes) {
5258
- if ('sites' in changes) {
5259
- return this.update();
5260
- }
5261
- if ('dataState' in changes) {
5262
- this.selectedView = View$1.table;
5263
- }
5264
- };
5265
- SitesMeasurementsComponent.prototype.trackById = function (_index, item) {
5266
- return item['@id'];
5267
- };
5268
- Object.defineProperty(SitesMeasurementsComponent.prototype, "isOriginal", {
5269
- get: function () {
5270
- return this.dataState === api.DataState.original;
5271
- },
5272
- enumerable: false,
5273
- configurable: true
5274
- });
5275
- SitesMeasurementsComponent.prototype.update = function () {
5276
- var measurementsPerSite = groupNodesByTerm(this.sites, 'measurements', this.originalValues);
5277
- this.measurements = orderBy$1(grouppedKeys(measurementsPerSite), ['key'], ['asc']);
5278
- };
5279
- SitesMeasurementsComponent.prototype.togglePopover = function (popover, context) {
5280
- return popover.isOpen() ? popover.close() : popover.open(context);
5281
- };
5282
- Object.defineProperty(SitesMeasurementsComponent.prototype, "showAreaTooBig", {
5283
- get: function () {
5284
- return this.dataState === api.DataState.recalculated && (this.sites || []).some(siteTooBig);
5285
- },
5286
- enumerable: false,
5287
- configurable: true
5288
- });
5289
- return SitesMeasurementsComponent;
5290
- }());
5291
- SitesMeasurementsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
5292
- SitesMeasurementsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMeasurementsComponent, selector: "he-sites-measurements", inputs: { originalValues: "originalValues", sites: "sites", dataState: "dataState" }, usesOnChanges: true, ngImport: i0__namespace, template: "<ng-container *ngIf=\"measurements.length; else emptyTable\">\n <div class=\"columns is-variable is-2 m-0\">\n <div class=\"column is-hidden-mobile\"></div>\n <div class=\"column is-narrow\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.table\" (click)=\"selectedView = View.table\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"list\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Table view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"!isOriginal && sites.length === 1\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.logs\" (click)=\"selectedView = View.logs\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"calculator\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Recalculations logs</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"px-3 pb-3\" [class.is-hidden]=\"selectedView !== View.table\">\n <div class=\"has-text-right mb-2\">\n <button class=\"button is-dark is-outlined is-small\" (click)=\"showDownload = true\">\n <fa-icon icon=\"download\"></fa-icon>\n <span class=\"pl-2\">Download (CSV)</span>\n </button>\n </div>\n\n <div class=\"table-container data-table-container mb-1\">\n <table class=\"table is-narrow data-table has-children-{{measurements.length}}\">\n <thead>\n <tr>\n <th class=\"width-auto\"></th>\n <th *ngFor=\"let measurement of measurements\"\n [attr.title]=\"measurement.value.term.name\"\n >\n <he-node-link [node]=\"measurement.value.term\">\n <span>{{measurement.value.term.name | ellipsis:30}}</span>\n </he-node-link>\n </th>\n </tr>\n <tr>\n <th class=\"width-auto\"></th>\n <th *ngFor=\"let measurement of measurements\"\n [attr.title]=\"measurement.value.term.units\"\n >{{measurement.value.term.units}}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let site of sites; trackBy: trackById; let i = index\">\n <td class=\"width-auto\" [attr.title]=\"defaultLabel(site)\">\n <he-node-link [node]=\"site\">\n <span class=\"is-nowrap has-text-ellipsis\">{{i + 1}}. {{defaultLabel(site)}}</span>\n </he-node-link>\n </td>\n <td class=\"is-nowrap\" *ngFor=\"let measurement of measurements\">\n <span *ngIf=\"measurement.value.values[site['@id']]\"\n class=\"trigger-popover\"\n [ngbPopover]=\"details\" [autoClose]=\"'outside'\"\n triggers=\"manual\" #p=\"ngbPopover\" placement=\"left\" container=\"body\"\n (click)=\"togglePopover(p, { data: measurement.value.values[site['@id']], site: site, key: 'measurements' })\"\n >\n <span pointer>{{measurementValue(measurement.value.values[site['@id']]) | precision:3 | default:'-'}}</span>\n <he-blank-node-state class=\"ml-1\"\n [node]=\"measurement.value.values[site['@id']].nodes[0]\"\n key=\"value\"\n ></he-blank-node-state>\n </span>\n <span *ngIf=\"!measurement.value.values[site['@id']]\">\n <span>-</span>\n <sup class=\"pl-1\" *ngIf=\"siteTooBig(site)\">(1)</sup>\n </span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n\n <he-blank-node-state-notice [dataState]=\"dataState\"></he-blank-node-state-notice>\n\n <p class=\"is-size-7 is-italic\" *ngIf=\"showAreaTooBig\">\n (1) This region is >{{maxAreaSize}}km2 and is too large to reliably gap fill Measurements.\n </p>\n </div>\n\n <he-sites-measurements-logs *ngIf=\"selectedView === View.logs && !isOriginal\"\n [site]=\"sites[0]\"\n [originalValues]=\"originalValues[0].measurements\"\n [recalculatedValues]=\"sites[0].measurements\"\n ></he-sites-measurements-logs>\n</ng-container>\n\n<he-node-csv-export-confirm *ngIf=\"showDownload\"\n [nodes]=\"sites\" filename=\"site-measurements.csv\" [isUpload]=\"false\"\n [headerKeys]=\"['site.id', 'site.@id', 'site.measurements.']\"\n (closed)=\"showDownload = false\"\n></he-node-csv-export-confirm>\n\n<ng-template #emptyTable>\n <div class=\"panel-block\">\n <span>No data</span>\n </div>\n</ng-template>\n\n<ng-template #emptyValue>\n <span>-</span>\n</ng-template>\n\n<ng-template #details let-node=\"site\" let-data=\"data\" let-key=\"key\">\n <p><b>{{node.name}}</b></p>\n <he-node-value-details\n [data]=\"data\" [nodeType]=\"node['@type']\" [dataKey]=\"key\"\n ></he-node-value-details>\n</ng-template>\n", styles: ["fa-icon{display:inline-block;width:10px}\n"], components: [{ type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }, { type: NodeLinkComponent, selector: "he-node-link", inputs: ["node", "showExternalLink"] }, { type: BlankNodeStateComponent, selector: "he-blank-node-state", inputs: ["nodeType", "dataKey", "key", "node", "state"] }, { type: BlankNodeStateNoticeComponent, selector: "he-blank-node-state-notice", inputs: ["dataState", "showDeleted"] }, { type: SitesMeasurementsLogsComponent, selector: "he-sites-measurements-logs", inputs: ["site", "originalValues", "recalculatedValues"] }, { type: NodeCsvExportConfirmComponent, selector: "he-node-csv-export-confirm", inputs: ["nodes", "filename", "headerKeys", "extension", "isUpload"], outputs: ["closed"] }, { type: NodeValueDetailsComponent, selector: "he-node-value-details", inputs: ["data", "nodeType", "dataKey"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgbPopover, selector: "[ngbPopover]", inputs: ["animation", "autoClose", "placement", "triggers", "container", "disablePopover", "popoverClass", "openDelay", "closeDelay", "ngbPopover", "popoverTitle"], outputs: ["shown", "hidden"], exportAs: ["ngbPopover"] }], pipes: { "ellipsis": EllipsisPipe, "default": DefaultPipe, "precision": PrecisionPipe } });
5293
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsComponent, decorators: [{
5294
- type: i0.Component,
5295
- args: [{
5296
- selector: 'he-sites-measurements',
5297
- templateUrl: './sites-measurements.component.html',
5298
- styleUrls: ['./sites-measurements.component.scss']
5299
- }]
5300
- }], propDecorators: { originalValues: [{
5301
- type: i0.Input
5302
- }], sites: [{
5303
- type: i0.Input
5304
- }], dataState: [{
5305
- type: i0.Input
5306
- }] } });
5307
-
5308
- var components$2 = [
5309
- SitesMapsComponent,
5310
- SitesMeasurementsComponent,
5311
- SitesMeasurementsLogsComponent
5312
- ];
5313
- var HeSitesModule = /** @class */ (function () {
5314
- function HeSitesModule() {
5315
- }
5316
- return HeSitesModule;
5317
- }());
5318
- HeSitesModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
5319
- HeSitesModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, declarations: [SitesMapsComponent,
5320
- SitesMeasurementsComponent,
5321
- SitesMeasurementsLogsComponent], imports: [i3.CommonModule, i1$4.ReactiveFormsModule,
5322
- HeCommonModule,
5323
- HeNodeModule], exports: [SitesMapsComponent,
5324
- SitesMeasurementsComponent,
5325
- SitesMeasurementsLogsComponent] });
5326
- HeSitesModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, imports: [[
5327
- i3.CommonModule, i1$4.ReactiveFormsModule,
5328
- HeCommonModule,
5329
- HeNodeModule
5330
- ]] });
5331
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, decorators: [{
5332
- type: i0.NgModule,
5333
- args: [{
5334
- declarations: components$2,
5335
- exports: components$2,
5336
- imports: [
5337
- i3.CommonModule, i1$4.ReactiveFormsModule,
5338
- HeCommonModule,
5339
- HeNodeModule
5340
- ]
5341
- }]
5342
- }] });
5343
-
5344
- var _f;
5345
- var mapErrorMessage = 'does not contain latitude and longitude';
5346
- var parseDataPath = function (dataPath) {
5347
- var _f = __read(dataPath.split('.')), _ = _f[0], paths = _f.slice(1);
5348
- return paths.map(function (path) { return ({ path: path, label: keyToLabel(path.replace(/\[\d+\]/g, '')) }); });
5349
- };
5350
- var contactUsEmail = 'community@hestia.earth';
5351
- var externalLink = function (href, text) { return "<a href=\"" + href + "\" target=\"_blank\">" + text + "</a>"; };
5352
- var glossaryLink = function (text) { return externalLink(baseUrl() + "/glossary", text); };
5353
- var glossaryTypeLink = function (type) { return externalLink(baseUrl() + "/glossary?termType=" + type, termTypeLabel(type)); };
5354
- var termLink = function (_f) {
5355
- var id = _f.id, name = _f.name;
5356
- return externalLink(baseUrl() + "/term/" + id, name);
5357
- };
5358
- var nodeLink = function (_f) {
5359
- var type = _f["@type"], id = _f["@id"], name = _f.name;
5360
- return type && id ? "<a href=\"/" + type.toLowerCase() + "/" + id + "\" target=\"_blank\">" + (name || id) + "</a>" : null;
5361
- };
5362
- var schemaLink = function (type, title) {
5363
- if (title === void 0) { title = type; }
5364
- return "<a href=\"" + baseUrl() + "/schema/" + type + "\" target=\"_blank\">" + title + "</a>";
4803
+ var schemaLink = function (type, title) {
4804
+ if (title === void 0) { title = type; }
4805
+ return "<a href=\"" + baseUrl() + "/schema/" + type + "\" target=\"_blank\">" + title + "</a>";
5365
4806
  };
5366
4807
  var code = function (text) { return "<code>" + text + "</code>"; };
5367
4808
  var dateFormatMessage = "should follow the ISO 8601 date format, e.g. " + code(2000) + ", or " + code('2000-12') + ", or " + code('2000-12-30');
@@ -5474,671 +4915,1103 @@
5474
4915
  var _a, _b, _c, _d, _e;
5475
4916
  return "You have the following Product " + code((_a = params === null || params === void 0 ? void 0 : params.product) === null || _a === void 0 ? void 0 : _a.name) + " however,\n you have used a generic " + glossaryTypeLink((_b = params === null || params === void 0 ? void 0 : params.term) === null || _b === void 0 ? void 0 : _b.termType) + " term " + code((_c = params === null || params === void 0 ? void 0 : params.term) === null || _c === void 0 ? void 0 : _c.name) + ".\n Use a more specific term for the " + glossaryTypeLink((_d = params === null || params === void 0 ? void 0 : params.term) === null || _d === void 0 ? void 0 : _d.termType) + " which reflects the specific " + glossaryTypeLink((_e = params === null || params === void 0 ? void 0 : params.product) === null || _e === void 0 ? void 0 : _e.termType) + ".";
5476
4917
  },
5477
- _f['is missing required bibliographic information'] = function () { return "The automatic bibliography search failed for this Bibliography. Either:\n 1) manually fill-in the <b>required</b> bibliographic information as per\n " + schemaLink(schema.SchemaType.Bibliography, 'our schema') + ".\n 2) provide the " + code('documentDOI') + " as well as the " + code('title') + "\n 3) check the " + code('documentDOI') + " and " + code('title') + " for typos against the\n " + externalLink('https://www.mendeley.com', 'Mendeley catalogue'); },
5478
- _f['should be lower than max size'] = function (_f) {
5479
- var params = _f.params;
5480
- return "The boundary or region is >" + (params === null || params === void 0 ? void 0 : params.expected) + "km2 and is too large to reliably gap fill Measurements.";
4918
+ _f['is missing required bibliographic information'] = function () { return "The automatic bibliography search failed for this Bibliography. Either:\n 1) manually fill-in the <b>required</b> bibliographic information as per\n " + schemaLink(schema.SchemaType.Bibliography, 'our schema') + ".\n 2) provide the " + code('documentDOI') + " as well as the " + code('title') + "\n 3) check the " + code('documentDOI') + " and " + code('title') + " for typos against the\n " + externalLink('https://www.mendeley.com', 'Mendeley catalogue'); },
4919
+ _f['should be lower than max size'] = function (_f) {
4920
+ var params = _f.params;
4921
+ return "The boundary or region is >" + (params === null || params === void 0 ? void 0 : params.expected) + "km2 and is too large to reliably gap fill Measurements.";
4922
+ },
4923
+ _f['an excreta input is required when using an excretaManagement practice'] = function (_f) {
4924
+ var dataPath = _f.dataPath;
4925
+ var paths = parseDataPath(dataPath);
4926
+ return "Excreta management is the conversion of excreta to another type of excreta.\n You have added an excretaManagement Practice to this " + paths[0].label + " but there is no excreta Input.\n To represent excreta management, use a " + paths[0].label + " with excreta as an Input and excretaManagement as a Practice.";
4927
+ },
4928
+ _f['only 1 primary product allowed'] = function () { return 'There can only be one primary product in each Cycle.'; },
4929
+ _f['is not allowed in combination with noTillage'] = function () { return "This operation involves tillage, yet you have specified the Practice " + termLink(noTillage) + ".\n Either change this operation or the Practice."; },
4930
+ _f['should contain a tillage practice'] = function () { return "We recommend specifying the type of tillage used for this Cycle.\n Please see the " + glossaryTypeLink(schema.TermTermType.tillage) + " glossary."; },
4931
+ _f['must set value for every tillage practice'] = function () { return "Either specify a single " + glossaryTypeLink(schema.TermTermType.tillage) + " practice or add a value to all practices."; },
4932
+ _f['sum not equal to 100% for tillage practices'] = function () { return "The sum of " + glossaryTypeLink(schema.TermTermType.tillage) + " practices must equal 100%."; },
4933
+ _f['can only have 1 tillage practice without a value'] = function (_f) {
4934
+ var params = _f.params;
4935
+ var _a;
4936
+ return "It is not possible for a Cycle to have the following tillage Practices:\n " + ((_a = params === null || params === void 0 ? void 0 : params.current) !== null && _a !== void 0 ? _a : []).map(function (_f) {
4937
+ var name = _f.name;
4938
+ return name;
4939
+ }).join(' and ') + " at the same time.\n If multiple tillage practices did occur, please specify the percentage of area they occurred on.";
4940
+ },
4941
+ _f['can not be linked to the same Cycle'] = function () { return 'You can not link an Input to the Impact Assessment of the same Cycle.'; },
4942
+ _f['must be 0 for product value 0'] = function (_f, errorCount) {
4943
+ var dataPath = _f.dataPath, params = _f.params;
4944
+ return "If the amount produced is zero, the " + code(dataPath === null || dataPath === void 0 ? void 0 : dataPath.split('.').pop()) + " of " + (errorCount === 1 ? code(params === null || params === void 0 ? void 0 : params.term.name) : 'that product') + " must also be zero.";
4945
+ },
4946
+ _f);
4947
+ var formatCustomErrorMessage = function (message, error, errorCount) {
4948
+ if (errorCount === void 0) { errorCount = 1; }
4949
+ var formattedMessage = message && message in customErrorMessage ?
4950
+ customErrorMessage[message](error, errorCount) :
4951
+ message;
4952
+ return formattedMessage ? "<p class=\"is-normal\">" + formattedMessage + "</p>" : '';
4953
+ };
4954
+ var formatError = function (error, errorCount) {
4955
+ if (errorCount === void 0) { errorCount = 1; }
4956
+ return error ? (Object.assign(Object.assign({ level: 'error' }, error), { mapError: error.message === mapErrorMessage, message: formatCustomErrorMessage(error.message, error, errorCount) })) : undefined;
4957
+ };
4958
+ var errorHasError = function (error) { return error && (error.level === 'error' || !error.level); };
4959
+ var errorHasWarning = function (error) { return error && error.level === 'warning'; };
4960
+ var isMissingPropertyError = function (_f) {
4961
+ var params = _f.params;
4962
+ return !!params && 'missingProperty' in params;
4963
+ };
4964
+ var isMissingOneOfError = function (_f) {
4965
+ var keyword = _f.keyword, schemaPath = _f.schemaPath;
4966
+ return keyword === 'required' && (schemaPath || '').includes('oneOf');
4967
+ };
4968
+ var isFailingKeywordError = function (_f) {
4969
+ var params = _f.params;
4970
+ return !!params && 'failingKeyword' in params;
4971
+ };
4972
+ var filterError = function (error) { return [
4973
+ isFailingKeywordError
4974
+ ].every(function (func) { return !func(error); }); };
4975
+ var missingNodeErrors = function (errors) { return errors.filter(function (_f) {
4976
+ var keyword = _f.keyword, params = _f.params;
4977
+ return keyword === 'required' && ((params === null || params === void 0 ? void 0 : params.missingProperty) === '@type' || (params === null || params === void 0 ? void 0 : params.missingProperty) === '@id');
4978
+ }); };
4979
+
4980
+ var _d;
4981
+ /* eslint-disable complexity */
4982
+ var get$1 = require('lodash.get');
4983
+ var ARRAY_DELIMITER = ';';
4984
+ var privateKeys = [
4985
+ 'filepath'
4986
+ ];
4987
+ var defaultSuggestionType = 'default';
4988
+ var stringValue = function (value) { return (typeof value === 'undefined' || value === null ? '' : value).toString(); };
4989
+ var nonExpandableArrayDataPath = function (key) { return key.replace(/\[\d+\]$/, ''); };
4990
+ var keyToDataPath = function (key) { return (key === null || key === void 0 ? void 0 : key.length) ? "." + key : ''; };
4991
+ var dataPathToKey = function (dataPath, trimArray) {
4992
+ if (trimArray === void 0) { trimArray = false; }
4993
+ return trimArray ? nonExpandableArrayDataPath(dataPath.substring(1)) : dataPath.substring(1);
4994
+ };
4995
+ var parentKey = function (key) {
4996
+ var keys = (key.startsWith('.') ? key.substring(1) : key).split('.');
4997
+ keys.pop();
4998
+ return keys.join('.');
4999
+ };
5000
+ /**
5001
+ * Sort properties having errors, type, id, ...properties (simple), and finally the groups
5002
+ *
5003
+ * @param a {INodeProperty}
5004
+ * @param b {INodeProperty}
5005
+ */
5006
+ var sortProperties = function (a, b) {
5007
+ if (utils.isNumber(a.key) && utils.isNumber(b.key)) {
5008
+ return +a.key - +b.key;
5009
+ }
5010
+ if (a.isExpandable) {
5011
+ return b.isExpandable ? a.key.localeCompare(b.key) : 1;
5012
+ }
5013
+ if (b.isExpandable) {
5014
+ return -1;
5015
+ }
5016
+ if (!a.key) {
5017
+ return -1;
5018
+ }
5019
+ var aKey = a.key.replace('@', '');
5020
+ var bKey = b.key.replace('@', '');
5021
+ if (aKey === 'type') {
5022
+ return -1;
5023
+ }
5024
+ if (bKey === 'type') {
5025
+ return 1;
5026
+ }
5027
+ if (aKey === 'id' && bKey !== 'type') {
5028
+ return -1;
5029
+ }
5030
+ if (a.hasError || a.hasWarning) {
5031
+ return -1;
5032
+ }
5033
+ return a.key.localeCompare(b.key);
5034
+ };
5035
+ var defaultPropertyError = {
5036
+ max: function (_d) {
5037
+ var max = _d.max;
5038
+ return "should be <= " + max;
5039
+ },
5040
+ min: function (_d) {
5041
+ var min = _d.min;
5042
+ return "should be >= " + min;
5043
+ },
5044
+ pattern: function (_d) {
5045
+ var requiredPattern = _d.requiredPattern;
5046
+ return "should match pattern \"" + requiredPattern + "\"";
5047
+ },
5048
+ required: function (_e, _d) {
5049
+ var schemaType = _d.schemaType;
5050
+ return schemaType ? "should be set or linked to another " + schemaType : undefined;
5051
+ }
5052
+ };
5053
+ var formatPropertyError = function (errors, property) {
5054
+ var key = Object.keys(errors)[0];
5055
+ return key in defaultPropertyError ? formatCustomErrorMessage(defaultPropertyError[key](errors[key], property)) : '';
5056
+ };
5057
+ var hasError = function (value) { return Array.isArray(value) ? value.some(hasError) : value.hasError; };
5058
+ var hasWarning = function (value) { return Array.isArray(value) ? value.some(hasWarning) : value.hasWarning; };
5059
+ var compileSuggestionQueries = function (key, allOf) {
5060
+ var conditions = (allOf || [])
5061
+ .filter(function (v) { var _c; return (((_c = v.if) === null || _c === void 0 ? void 0 : _c.required) || []).includes(key); })
5062
+ .map(function (v) { var _c; return (_c = v.then) === null || _c === void 0 ? void 0 : _c.properties[key]; })
5063
+ .map(function (v) { var _c; return ((_c = v === null || v === void 0 ? void 0 : v.items) === null || _c === void 0 ? void 0 : _c.properties) || (v === null || v === void 0 ? void 0 : v.properties); })
5064
+ .filter(Boolean);
5065
+ return conditions.length ? [{
5066
+ bool: {
5067
+ should: conditions.flatMap(function (cond) { return Object.keys(cond).flatMap(function (k) { return (cond[k].enum || []).map(function (v) {
5068
+ var _d;
5069
+ return ({
5070
+ match: (_d = {}, _d[k] = v, _d)
5071
+ });
5072
+ }); }); }),
5073
+ minimum_should_match: 1
5074
+ }
5075
+ }] : [];
5076
+ };
5077
+ // default suggest for linking nodes together using the `id` field
5078
+ var suggestLinkNodes = function (type, fullKey) {
5079
+ var keys = fullKey.split('.');
5080
+ var key = keys.pop();
5081
+ return key === 'id' && keys.length >= 1 ? { type: type, isLinkNode: true } : undefined;
5082
+ };
5083
+ var suggestExistingNode = function (type, fullKey) {
5084
+ var keys = fullKey.split('.');
5085
+ var key = keys.pop();
5086
+ return keys.length >= 1 && ['@id', 'openLCAId'].includes(key) ? { type: type, isUniqueKey: '@id' } : undefined;
5087
+ };
5088
+ var defaultNodeTypeSuggestion = function (type) { return function (fullKey) { return suggestLinkNodes(type, fullKey) || suggestExistingNode(type, fullKey); }; };
5089
+ var termSuggestions = function (parent, _d) {
5090
+ var allOf = _d.allOf;
5091
+ return ({
5092
+ type: schema.NodeType.Term,
5093
+ queries: __spreadArray(__spreadArray([], __read(compileSuggestionQueries(nonExpandableArrayDataPath(parent), allOf))), __read((['country'].includes(parent) ? [matchCountry] : [])))
5094
+ });
5095
+ };
5096
+ var formatLinkNodesSuggestions = function (nodeMap, type) { return (nodeMap[type] || []).map(function (id) { return ({ type: type, id: id, name: "Link with " + type + ": " + id }); }); };
5097
+ var typeToSuggestion = (_d = {},
5098
+ _d[schema.NodeType.Actor] = defaultNodeTypeSuggestion(schema.NodeType.Actor),
5099
+ _d[schema.NodeType.Cycle] = defaultNodeTypeSuggestion(schema.NodeType.Cycle),
5100
+ _d[schema.NodeType.ImpactAssessment] = defaultNodeTypeSuggestion(schema.NodeType.ImpactAssessment),
5101
+ _d[schema.NodeType.Organisation] = defaultNodeTypeSuggestion(schema.NodeType.Organisation),
5102
+ _d[schema.NodeType.Site] = defaultNodeTypeSuggestion(schema.NodeType.Site),
5103
+ _d[schema.NodeType.Source] = defaultNodeTypeSuggestion(schema.NodeType.Source),
5104
+ _d[schema.NodeType.Term] = function (fullKey, parentSchema) {
5105
+ var keys = fullKey.split('.');
5106
+ var key = keys.pop();
5107
+ return ['name'].includes(key) && keys.length >= 1 ?
5108
+ termSuggestions(keys.pop(), parentSchema) :
5109
+ defaultNodeTypeSuggestion(schema.NodeType.Term)(fullKey);
5110
+ },
5111
+ _d[schema.SchemaType.Bibliography] = function (fullKey) {
5112
+ var keys = fullKey.split('.');
5113
+ var key = keys.pop();
5114
+ var parent = keys.pop();
5115
+ // prevent replacing a top-level source
5116
+ return ['title', 'documentDOI', 'scopus'].includes(key) && parent === 'bibliography' && keys.length >= 1 ? {
5117
+ type: schema.NodeType.Source,
5118
+ parentLevel: 1
5119
+ } : null;
5481
5120
  },
5482
- _f['an excreta input is required when using an excretaManagement practice'] = function (_f) {
5483
- var dataPath = _f.dataPath;
5484
- var paths = parseDataPath(dataPath);
5485
- return "Excreta management is the conversion of excreta to another type of excreta.\n You have added an excretaManagement Practice to this " + paths[0].label + " but there is no excreta Input.\n To represent excreta management, use a " + paths[0].label + " with excreta as an Input and excretaManagement as a Practice.";
5121
+ _d.number = function (_a, _b, schema) {
5122
+ var values = schema.const ? [schema.const] : [];
5123
+ return {
5124
+ type: values.length > 0 ? 'select' : defaultSuggestionType,
5125
+ // exclude suggesting SchemaType
5126
+ values: values
5127
+ };
5486
5128
  },
5487
- _f['only 1 primary product allowed'] = function () { return 'There can only be one primary product in each Cycle.'; },
5488
- _f['is not allowed in combination with noTillage'] = function () { return "This operation involves tillage, yet you have specified the Practice " + termLink(noTillage) + ".\n Either change this operation or the Practice."; },
5489
- _f['should contain a tillage practice'] = function () { return "We recommend specifying the type of tillage used for this Cycle.\n Please see the " + glossaryTypeLink(schema.TermTermType.tillage) + " glossary."; },
5490
- _f['must set value for every tillage practice'] = function () { return "Either specify a single " + glossaryTypeLink(schema.TermTermType.tillage) + " practice or add a value to all practices."; },
5491
- _f['sum not equal to 100% for tillage practices'] = function () { return "The sum of " + glossaryTypeLink(schema.TermTermType.tillage) + " practices must equal 100%."; },
5492
- _f['can only have 1 tillage practice without a value'] = function (_f) {
5493
- var params = _f.params;
5494
- var _a;
5495
- return "It is not possible for a Cycle to have the following tillage Practices:\n " + ((_a = params === null || params === void 0 ? void 0 : params.current) !== null && _a !== void 0 ? _a : []).map(function (_f) {
5496
- var name = _f.name;
5497
- return name;
5498
- }).join(' and ') + " at the same time.\n If multiple tillage practices did occur, please specify the percentage of area they occurred on.";
5129
+ _d.integer = function (_a, _b, schema) {
5130
+ var values = schema.const ? [schema.const] : [];
5131
+ return {
5132
+ type: values.length > 0 ? 'select' : defaultSuggestionType,
5133
+ // exclude suggesting SchemaType
5134
+ values: values
5135
+ };
5499
5136
  },
5500
- _f['can not be linked to the same Cycle'] = function () { return 'You can not link an Input to the Impact Assessment of the same Cycle.'; },
5501
- _f['must be 0 for product value 0'] = function (_f, errorCount) {
5502
- var dataPath = _f.dataPath, params = _f.params;
5503
- return "If the amount produced is zero, the " + code(dataPath === null || dataPath === void 0 ? void 0 : dataPath.split('.').pop()) + " of " + (errorCount === 1 ? code(params === null || params === void 0 ? void 0 : params.term.name) : 'that product') + " must also be zero.";
5137
+ _d.string = function (fullKey, _b, schema$1) {
5138
+ // exclude suggesting SchemaType
5139
+ var values = schema$1.const ?
5140
+ [schema$1.const] :
5141
+ (schema$1.enum || []).filter(function (val) { return !Object.values(schema.SchemaType).includes(val); });
5142
+ var key = fullKey.split('.').pop();
5143
+ return {
5144
+ type: values.length > 0 && key !== 'type' ? 'select' : defaultSuggestionType,
5145
+ values: values
5146
+ };
5504
5147
  },
5505
- _f);
5506
- var formatCustomErrorMessage = function (message, error, errorCount) {
5507
- if (errorCount === void 0) { errorCount = 1; }
5508
- var formattedMessage = message && message in customErrorMessage ?
5509
- customErrorMessage[message](error, errorCount) :
5510
- message;
5511
- return formattedMessage ? "<p class=\"is-normal\">" + formattedMessage + "</p>" : '';
5148
+ _d.boolean = function (_a) { return ({
5149
+ type: 'select',
5150
+ values: ['true', 'false']
5151
+ }); },
5152
+ _d);
5153
+ var enableSuggestions = function (parentSchema, type, fullKey, schema) {
5154
+ var suggestion = type in typeToSuggestion ? typeToSuggestion[type](fullKey, parentSchema) : null;
5155
+ return suggestion !== null ? suggestion : (schema && schema.type in typeToSuggestion ?
5156
+ typeToSuggestion[schema.type](fullKey, parentSchema, schema) :
5157
+ null);
5512
5158
  };
5513
- var formatError = function (error, errorCount) {
5514
- if (errorCount === void 0) { errorCount = 1; }
5515
- return error ? (Object.assign(Object.assign({ level: 'error' }, error), { mapError: error.message === mapErrorMessage, message: formatCustomErrorMessage(error.message, error, errorCount) })) : undefined;
5159
+ var formatProperty = function (prop) { return (Object.assign(Object.assign({ '@type': schema.SchemaType.Property }, prop), { term: Object.assign({ '@type': schema.NodeType.Term }, prop.term) })); };
5160
+ var formatSuggestion = function (_c) {
5161
+ var defaultProperties = _c.defaultProperties, node = __rest(_c, ["defaultProperties"]);
5162
+ return (Object.assign(Object.assign({}, node), (defaultProperties ? { defaultProperties: defaultProperties.map(formatProperty) } : {})));
5516
5163
  };
5517
- var errorHasError = function (error) { return error && (error.level === 'error' || !error.level); };
5518
- var errorHasWarning = function (error) { return error && error.level === 'warning'; };
5519
- var isMissingPropertyError = function (_f) {
5520
- var params = _f.params;
5521
- return !!params && 'missingProperty' in params;
5164
+ var nodeAvailableProperties = function (node, _d) {
5165
+ var fullKey = _d.fullKey, schema = _d.schema, schemaType = _d.schemaType;
5166
+ return availableProperties(schema, schemaType, fullKey ? get$1(node, fullKey, {}) : node, fullKey.length > 0);
5522
5167
  };
5523
- var isMissingOneOfError = function (_f) {
5524
- var keyword = _f.keyword, schemaPath = _f.schemaPath;
5525
- return keyword === 'required' && (schemaPath || '').includes('oneOf');
5168
+ var isAddPropertyEnabled = function (node, schemaType, schema, fullKey) {
5169
+ if (fullKey === void 0) { fullKey = ''; }
5170
+ return !!schema &&
5171
+ !!Object.keys(nodeAvailableProperties(node, { fullKey: fullKey, schema: schema })).length &&
5172
+ (!fullKey || nestingTypeEnabled(schemaType));
5526
5173
  };
5527
- var isFailingKeywordError = function (_f) {
5528
- var params = _f.params;
5529
- return !!params && 'failingKeyword' in params;
5174
+ var editableKey = function (key) { return !['type', '@type', 'termType'].includes(key); };
5175
+ var propertyId = function () { return uuid.v4(); };
5176
+ var propertyUrl = function (node, key) { return ['@id', 'name'].includes(key) && linkTypeEnabled(node['@type']) ?
5177
+ {
5178
+ url: baseUrl() + "/" + node['@type'].toLowerCase() + "/" + node['@id'],
5179
+ title: 'Open'
5180
+ } :
5181
+ (node.type === schema.SchemaType.Term && ['name'].includes(key) ? {
5182
+ url: baseUrl() + "/glossary?query=",
5183
+ urlParamValue: true,
5184
+ title: 'Search in Glossary'
5185
+ } : undefined); };
5186
+ var propertyMapsUrl = function (node, key, value) { return ['type'].includes(key) && [
5187
+ schema.SchemaType.Site.toString(),
5188
+ schema.SchemaType.Organisation.toString()
5189
+ ].includes(stringValue(value) || node.type) ?
5190
+ {
5191
+ url: mapsUrl({ lat: node.latitude, lng: node.longitude }),
5192
+ title: 'View on maps',
5193
+ icon: 'map'
5194
+ } :
5195
+ undefined; };
5196
+ var propertyExternalUrl = function (node, key, value) { return propertyUrl(node, key) ||
5197
+ propertyMapsUrl(node, key, value); };
5198
+ var arrayPlaceholder = function (valueType) { return "Type a " + valueType + " then press Enter"; };
5199
+ var defaultPlaceholder = function (_d, valueType) {
5200
+ var type = _d.type, examples = _d.examples;
5201
+ return (examples === null || examples === void 0 ? void 0 : examples.length) ? (Array.isArray(examples[0]) ? arrayPlaceholder(valueType) : examples[0]) : "Must be of type " + (type || valueType);
5202
+ };
5203
+ var schemaPlacholder = function (schema, fullKey) {
5204
+ var _d = __read(fullKey.split('.')), parent = _d[0], keys = _d.slice(1);
5205
+ var properties = schema.properties || {};
5206
+ var examples = (parent in properties ? properties[parent] : { examples: [] }).examples;
5207
+ return (examples === null || examples === void 0 ? void 0 : examples.length) && typeof examples[0] === 'object' ? get$1(examples[0], keys.join('.'), null) : null;
5208
+ };
5209
+ var propertyPlaceholder = function (schema, valueType, fullKey, parentSchema) {
5210
+ if (fullKey === void 0) { fullKey = ''; }
5211
+ return schema.type === 'array' ?
5212
+ arrayPlaceholder(valueType) : (parentSchema && (fullKey === null || fullKey === void 0 ? void 0 : fullKey.length) ? schemaPlacholder(parentSchema, fullKey) : null) || defaultPlaceholder(schema, valueType);
5213
+ };
5214
+ var propertyTypeValue = {
5215
+ object: function (val) { return safeJSONStringify(val); },
5216
+ array: function (val, schema) {
5217
+ var items = schema.items;
5218
+ return '$ref' in items ? val : (Array.isArray(val) ?
5219
+ val.map(function (value) { return propertyValue(items, value); }).join(ARRAY_DELIMITER) :
5220
+ val);
5221
+ },
5222
+ json: function (val) { return val || ''; },
5223
+ string: function (val) { return ("" + val || '').trim(); },
5224
+ number: function (val) { return +("" + val || '0'); },
5225
+ integer: function (val) { return +("" + val || '0'); },
5226
+ boolean: function (val) { return ("" + val || '').toLowerCase() === 'true'; }
5227
+ };
5228
+ var propertyValue = function (schema, value) { return schema.type ? (Array.isArray(schema.type) ?
5229
+ propertyTypeValue[typeof value](value, schema) :
5230
+ propertyTypeValue[schema.type](value, schema)) :
5231
+ safeJSONStringify(value); };
5232
+ var propertyValueType = function (schema, value) { return (schema.type ? (Array.isArray(schema.type) ?
5233
+ schema.type[0] :
5234
+ schema.type === 'array' ?
5235
+ propertyValueType(Object.assign(Object.assign({}, schema), { type: [schema.items.type] })) :
5236
+ schema.type) : typeof value); };
5237
+ var propertyTypeParseValue = {
5238
+ object: function (val) { return safeJSONParse(val); },
5239
+ array: function (val, schema) {
5240
+ var items = schema.items;
5241
+ return '$ref' in items ? val : (!val || Array.isArray(val) ? val : val.split(ARRAY_DELIMITER).map(function (value) { return parseNewValue(items, value); }));
5242
+ },
5243
+ json: function (val) { return val || ''; },
5244
+ string: function (val) { return ("" + val || '').trim(); },
5245
+ number: function (val) { return +("" + val || '0'); },
5246
+ integer: function (val) { return +("" + val || '0'); },
5247
+ boolean: function (val) { return ("" + val || '').toLowerCase() === 'true'; }
5248
+ };
5249
+ /**
5250
+ * Convert value to the final type in the schema.
5251
+ *
5252
+ * @param schema Definition of the value.
5253
+ * @param value
5254
+ * @returns Value in the correct format.
5255
+ */
5256
+ var parseNewValue = function (schema, value) { return schema.type ? (Array.isArray(schema.type) ?
5257
+ propertyTypeParseValue[typeof value](value, schema) :
5258
+ propertyTypeParseValue[schema.type](value, schema)) : value; };
5259
+ var isOpenDefault = function (schemaType) { return [
5260
+ schema.SchemaType.Term
5261
+ ].includes(schemaType); };
5262
+ // can the property be seen when the group is closed
5263
+ var isKeyClosedVisible = function (key) { return ['type', 'id', '@type', '@id'].includes(key); };
5264
+ var isKeyHidden = function (key) { return ['type', '@type'].includes(key); };
5265
+ var isKeyRequired = function (key, def) { return ['type', 'id'].includes(key) || ((def === null || def === void 0 ? void 0 : def.required) || []).includes(key); };
5266
+ var propertyError = function (errors) { return function (dataPath, nonExpandableArray) {
5267
+ if (nonExpandableArray === void 0) { nonExpandableArray = false; }
5268
+ return errors.find(function (error) { return (error.dataPath === dataPath || (nonExpandableArray && nonExpandableArrayDataPath(error.dataPath) === nonExpandableArrayDataPath(dataPath))) && (dataPath.length > 0 || !isMissingPropertyError(error)); });
5269
+ }; };
5270
+ var missingPropertyErrors = function (node, errors, parent) {
5271
+ if (parent === void 0) { parent = ''; }
5272
+ var allErrors = errors.filter(function (error) { return error.dataPath === keyToDataPath(parent) && isMissingPropertyError(error); });
5273
+ // check for node not found errors
5274
+ var missingNode = missingNodeErrors(allErrors);
5275
+ return missingNode.length === 2 ? [{
5276
+ id: propertyId(),
5277
+ schemaType: node.type,
5278
+ suggestions: { type: defaultSuggestionType },
5279
+ key: '',
5280
+ fullKey: parent,
5281
+ value: '',
5282
+ error: {
5283
+ level: 'error',
5284
+ message: missingNodeErrorMessage(node)
5285
+ },
5286
+ hasError: true,
5287
+ properties: [],
5288
+ addPropertyEnabled: false
5289
+ }] : allErrors.map(function (error) {
5290
+ var missingProperty = error.params.missingProperty;
5291
+ var fullKey = parent ? parent + "." + missingProperty : missingProperty;
5292
+ var missingOneOf = isMissingOneOfError(error);
5293
+ return {
5294
+ id: propertyId(),
5295
+ schemaType: node.type,
5296
+ suggestions: { type: defaultSuggestionType },
5297
+ key: missingProperty,
5298
+ fullKey: fullKey,
5299
+ value: 'Add field to fix',
5300
+ editable: false,
5301
+ error: formatError(error),
5302
+ hasError: missingOneOf ? false : errorHasError(error),
5303
+ hasWarning: missingOneOf || errorHasWarning(error),
5304
+ properties: [],
5305
+ addPropertyEnabled: true
5306
+ };
5307
+ });
5530
5308
  };
5531
- var filterError = function (error) { return [
5532
- isFailingKeywordError
5533
- ].every(function (func) { return !func(error); }); };
5534
- var missingNodeErrors = function (errors) { return errors.filter(function (_f) {
5535
- var keyword = _f.keyword, params = _f.params;
5536
- return keyword === 'required' && ((params === null || params === void 0 ? void 0 : params.missingProperty) === '@type' || (params === null || params === void 0 ? void 0 : params.missingProperty) === '@id');
5537
- }); };
5538
-
5539
- var _d;
5540
- /* eslint-disable complexity */
5541
- var get$1 = require('lodash.get');
5542
- var ARRAY_DELIMITER = ';';
5543
- var privateKeys = [
5544
- 'filepath'
5545
- ];
5546
- var defaultSuggestionType = 'default';
5547
- var stringValue = function (value) { return (typeof value === 'undefined' || value === null ? '' : value).toString(); };
5548
- var nonExpandableArrayDataPath = function (key) { return key.replace(/\[\d+\]$/, ''); };
5549
- var keyToDataPath = function (key) { return (key === null || key === void 0 ? void 0 : key.length) ? "." + key : ''; };
5550
- var dataPathToKey = function (dataPath, trimArray) {
5551
- if (trimArray === void 0) { trimArray = false; }
5552
- return trimArray ? nonExpandableArrayDataPath(dataPath.substring(1)) : dataPath.substring(1);
5309
+ var propertyFromNode = function (schemas, errors, nodeSchema, deepEditable, parent, node) {
5310
+ if (parent === void 0) { parent = ''; }
5311
+ return function (key) {
5312
+ var value = node[key];
5313
+ var expandable = schema.isExpandable(value);
5314
+ var isArray = Array.isArray(value);
5315
+ var nonExpandableArray = isArray && !expandable;
5316
+ var fullKey = Array.isArray(node) ? parent + "[" + key + "]" : [
5317
+ parent,
5318
+ key
5319
+ ].filter(Boolean).join('.');
5320
+ var nodeType = node.type || node['@type'];
5321
+ var schemaType = expandable ? (isArray && value.length ? value[0].type || value[0]['@type'] : value.type || value['@type']) : nodeType;
5322
+ var schema$1 = (schemas && schema.isTypeValid({ type: schemaType }) ? (expandable ? schemas[schemaType] : schemas[schemaType].properties[key]) : null) || {};
5323
+ var isIri = isSchemaIri(schema$1);
5324
+ var error = propertyError(errors)(keyToDataPath(fullKey), nonExpandableArray);
5325
+ var parentSchema = expandable ? (
5326
+ // TODO: for non-array, should be schema unless last recursion
5327
+ isArray ? schema$1 : nodeSchema) : nodeSchema;
5328
+ var properties = expandable || isIri ?
5329
+ recursiveProperties(schemas, errors, parentSchema, deepEditable, fullKey)(value) : [];
5330
+ var inError = errorHasError(error) || hasError(properties);
5331
+ var inWarning = errorHasWarning(error) || hasWarning(properties);
5332
+ var editable = schema.isTypeNode(node['@type']) || (expandable && schema.isTypeNode(value['@type'])) ?
5333
+ false :
5334
+ (
5335
+ // prevent editing/adding new properties on existing sub-nodes
5336
+ !deepEditable && schema.isTypeNode(schemaType) && (expandable ? value.type !== schema.NodeType.Term : parent && node.type !== schema.NodeType.Term) ?
5337
+ false :
5338
+ // handle IRI
5339
+ (!schemaType && key === '@id') || editableKey(key));
5340
+ var valueType = propertyValueType(schema$1, value);
5341
+ return {
5342
+ id: propertyId(),
5343
+ schemaType: isIri ? null : schemaType,
5344
+ schema: schema$1,
5345
+ key: key,
5346
+ fullKey: fullKey,
5347
+ value: propertyValue(schema$1, value),
5348
+ editable: inError || editable,
5349
+ suggestions: enableSuggestions(nodeSchema, node.type, fullKey, schema$1),
5350
+ addPropertyEnabled: isAddPropertyEnabled(node, schemaType, schema$1, fullKey),
5351
+ newProperty: {},
5352
+ newError: { level: 'warning' },
5353
+ error: formatError(error),
5354
+ isHidden: parent && isKeyHidden(key),
5355
+ closedVisible: isKeyClosedVisible(key),
5356
+ hasError: inError,
5357
+ hasWarning: inWarning,
5358
+ isRequired: isKeyRequired(key, schemas[nodeType]),
5359
+ isArray: isArray,
5360
+ isExpandable: expandable,
5361
+ isOpen: isOpenDefault(schemaType),
5362
+ properties: properties,
5363
+ placeholder: propertyPlaceholder(schema$1, valueType, fullKey, parentSchema),
5364
+ externalUrl: propertyExternalUrl(node, key, value)
5365
+ };
5366
+ };
5553
5367
  };
5554
- var parentKey = function (key) {
5555
- var keys = (key.startsWith('.') ? key.substring(1) : key).split('.');
5556
- keys.pop();
5557
- return keys.join('.');
5368
+ var singleProperty = function (schemas, errors, node, fullKey) {
5369
+ var _d = __read(fullKey.split('.')), _t = _d[0], keys = _d.slice(1);
5370
+ var key = keys.pop();
5371
+ var parent = keys.join('.');
5372
+ var parentNode = parent.length ? get$1(node, parent) : node;
5373
+ var schemaType = schema.typeToSchemaType(parentNode.type || parentNode['@type']);
5374
+ var parentSchema = schemas[schemaType];
5375
+ return propertyFromNode(schemas, errors, parentSchema, true, parent, parentNode)(key);
5558
5376
  };
5559
- /**
5560
- * Sort properties having errors, type, id, ...properties (simple), and finally the groups
5561
- *
5562
- * @param a {INodeProperty}
5563
- * @param b {INodeProperty}
5564
- */
5565
- var sortProperties = function (a, b) {
5566
- if (utils.isNumber(a.key) && utils.isNumber(b.key)) {
5567
- return +a.key - +b.key;
5568
- }
5569
- if (a.isExpandable) {
5570
- return b.isExpandable ? a.key.localeCompare(b.key) : 1;
5571
- }
5572
- if (b.isExpandable) {
5573
- return -1;
5574
- }
5575
- if (!a.key) {
5576
- return -1;
5577
- }
5578
- var aKey = a.key.replace('@', '');
5579
- var bKey = b.key.replace('@', '');
5580
- if (aKey === 'type') {
5581
- return -1;
5582
- }
5583
- if (bKey === 'type') {
5584
- return 1;
5585
- }
5586
- if (aKey === 'id' && bKey !== 'type') {
5587
- return -1;
5588
- }
5589
- if (a.hasError || a.hasWarning) {
5590
- return -1;
5591
- }
5592
- return a.key.localeCompare(b.key);
5377
+ var recursiveProperties = function (schemas, errors, nodeSchema, deepEditable, parent) {
5378
+ if (parent === void 0) { parent = ''; }
5379
+ return function (node) {
5380
+ var _d;
5381
+ return (_d = Object.keys(node)
5382
+ .filter(function (key) { return !privateKeys.includes(key); })
5383
+ .map(propertyFromNode(schemas, errors, nodeSchema, deepEditable, parent, node)))
5384
+ .concat.apply(_d, __spreadArray([], __read(missingPropertyErrors(node, errors, parent)))).sort(sortProperties);
5385
+ };
5593
5386
  };
5594
- var defaultPropertyError = {
5595
- max: function (_d) {
5596
- var max = _d.max;
5597
- return "should be <= " + max;
5598
- },
5599
- min: function (_d) {
5600
- var min = _d.min;
5601
- return "should be >= " + min;
5602
- },
5603
- pattern: function (_d) {
5604
- var requiredPattern = _d.requiredPattern;
5605
- return "should match pattern \"" + requiredPattern + "\"";
5606
- },
5607
- required: function (_e, _d) {
5608
- var schemaType = _d.schemaType;
5609
- return schemaType ? "should be set or linked to another " + schemaType : undefined;
5387
+ var fullKeyParts = function (fullKey) { return fullKey.split('.').flatMap(function (val) {
5388
+ if (val.endsWith(']')) {
5389
+ var _d = __read(val.split('['), 2), key = _d[0], index = _d[1];
5390
+ return [key, index.replace(']', '')];
5610
5391
  }
5392
+ return val;
5393
+ }); };
5394
+ var updateProperties = function (_d, updater) {
5395
+ var properties = _d.properties;
5396
+ return (properties || []).map(function (prop) { return updateProperties(updater(prop), updater); });
5611
5397
  };
5612
- var formatPropertyError = function (errors, property) {
5613
- var key = Object.keys(errors)[0];
5614
- return key in defaultPropertyError ? formatCustomErrorMessage(defaultPropertyError[key](errors[key], property)) : '';
5398
+ var typeToNewProperty = function (schemas, schema, nodeSchema, node, fullKey) {
5399
+ var key = fullKeyParts(fullKey).pop();
5400
+ var mappings = {
5401
+ object: function () {
5402
+ var _d = schemaRequiredProperties(schemas, schema), schemaType = _d.schemaType, properties = _d.properties;
5403
+ node[key] = node[key] || {};
5404
+ node[key].type = schemaType;
5405
+ // TODO: handle load schemas from http source
5406
+ if (schemaType.startsWith('http')) {
5407
+ return typeToNewProperty(schemas, { type: 'json' }, nodeSchema, node, fullKey);
5408
+ }
5409
+ // TODO: handle nodeSchema should be schema unless last recursion
5410
+ var props = properties
5411
+ .filter(function (prop) { return nestingEnabled(schemaType, prop.key) && !!prop.value; })
5412
+ .map(function (v) { return (Object.assign(Object.assign({}, typeToNewProperty(schemas, v.value, nodeSchema, node[key], fullKey + "." + v.key)), { isRequired: true })); });
5413
+ var value = props.reduce(function (prev, curr) {
5414
+ var _d;
5415
+ return (Object.assign(Object.assign({}, prev), (_d = {}, _d[curr.key] = curr.value, _d)));
5416
+ }, {});
5417
+ return {
5418
+ id: propertyId(),
5419
+ isAdded: true,
5420
+ schema: schemas[schemaType],
5421
+ schemaType: schemaType,
5422
+ key: key,
5423
+ fullKey: fullKey,
5424
+ value: value,
5425
+ editable: editableKey(key),
5426
+ isHidden: isKeyHidden(key),
5427
+ closedVisible: isKeyClosedVisible(key),
5428
+ suggestions: enableSuggestions(nodeSchema, schemaType, fullKey),
5429
+ properties: props.sort(sortProperties),
5430
+ addPropertyEnabled: isAddPropertyEnabled(node, schemaType, schemas[schemaType], key),
5431
+ newProperty: {},
5432
+ newError: { level: 'warning' },
5433
+ isRequired: isKeyRequired(key, schema),
5434
+ isArray: false,
5435
+ isExpandable: true,
5436
+ isOpen: isOpenDefault(schemaType)
5437
+ };
5438
+ },
5439
+ array: function () {
5440
+ var items = schema.items;
5441
+ // array of string, number and boolean
5442
+ if (items.type) {
5443
+ return mappings.default();
5444
+ }
5445
+ var schemaType = definitionToSchemaType(items);
5446
+ node[key] = node[key] || [];
5447
+ node[key].push({});
5448
+ var property = typeToNewProperty(schemas, items, schemas[schemaType], node[key][0], fullKey + "[0]");
5449
+ return {
5450
+ id: propertyId(),
5451
+ isAdded: true,
5452
+ schema: schema,
5453
+ schemaType: schemaType,
5454
+ key: key,
5455
+ fullKey: fullKey,
5456
+ value: [property.value],
5457
+ editable: editableKey(key),
5458
+ isHidden: isKeyHidden(key),
5459
+ closedVisible: isKeyClosedVisible(key),
5460
+ suggestions: undefined,
5461
+ properties: [property],
5462
+ newProperty: {},
5463
+ newError: { level: 'warning' },
5464
+ isArray: true,
5465
+ isExpandable: true,
5466
+ addPropertyEnabled: false
5467
+ };
5468
+ },
5469
+ default: function () {
5470
+ var valueType = propertyValueType(schema);
5471
+ var value = schema.default || schema.const || valueTypeToDefault[valueType];
5472
+ node[key] = value;
5473
+ return {
5474
+ id: propertyId(),
5475
+ isAdded: true,
5476
+ schema: schema,
5477
+ schemaType: node.type,
5478
+ key: key,
5479
+ fullKey: fullKey,
5480
+ value: propertyValue(schema, value),
5481
+ editable: editableKey(key),
5482
+ isHidden: isKeyHidden(key),
5483
+ closedVisible: isKeyClosedVisible(key),
5484
+ suggestions: enableSuggestions(nodeSchema, node.type, fullKey, schema),
5485
+ placeholder: propertyPlaceholder(schema, valueType, fullKey, nodeSchema),
5486
+ externalUrl: propertyExternalUrl(node, key, value),
5487
+ properties: [],
5488
+ addPropertyEnabled: false
5489
+ };
5490
+ }
5491
+ };
5492
+ var mapped = !schema.type ? mappings.object : (schema.type in mappings ? mappings[schema.type] : mappings.default);
5493
+ return mapped();
5615
5494
  };
5616
- var hasError = function (value) { return Array.isArray(value) ? value.some(hasError) : value.hasError; };
5617
- var hasWarning = function (value) { return Array.isArray(value) ? value.some(hasWarning) : value.hasWarning; };
5618
- var compileSuggestionQueries = function (key, allOf) {
5619
- var conditions = (allOf || [])
5620
- .filter(function (v) { var _c; return (((_c = v.if) === null || _c === void 0 ? void 0 : _c.required) || []).includes(key); })
5621
- .map(function (v) { var _c; return (_c = v.then) === null || _c === void 0 ? void 0 : _c.properties[key]; })
5622
- .map(function (v) { var _c; return ((_c = v === null || v === void 0 ? void 0 : v.items) === null || _c === void 0 ? void 0 : _c.properties) || (v === null || v === void 0 ? void 0 : v.properties); })
5623
- .filter(Boolean);
5624
- return conditions.length ? [{
5625
- bool: {
5626
- should: conditions.flatMap(function (cond) { return Object.keys(cond).flatMap(function (k) { return (cond[k].enum || []).map(function (v) {
5627
- var _d;
5628
- return ({
5629
- match: (_d = {}, _d[k] = v, _d)
5630
- });
5631
- }); }); }),
5632
- minimum_should_match: 1
5495
+ var findProperty = function (properties, fullKey) {
5496
+ var e_1, _d;
5497
+ try {
5498
+ for (var properties_1 = __values(properties), properties_1_1 = properties_1.next(); !properties_1_1.done; properties_1_1 = properties_1.next()) {
5499
+ var p = properties_1_1.value;
5500
+ if (p.fullKey === fullKey) {
5501
+ return p;
5633
5502
  }
5634
- }] : [];
5635
- };
5636
- // default suggest for linking nodes together using the `id` field
5637
- var suggestLinkNodes = function (type, fullKey) {
5638
- var keys = fullKey.split('.');
5639
- var key = keys.pop();
5640
- return key === 'id' && keys.length >= 1 ? { type: type, isLinkNode: true } : undefined;
5503
+ var childP = findProperty(p.properties, fullKey);
5504
+ if (childP) {
5505
+ return childP;
5506
+ }
5507
+ }
5508
+ }
5509
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
5510
+ finally {
5511
+ try {
5512
+ if (properties_1_1 && !properties_1_1.done && (_d = properties_1.return)) _d.call(properties_1);
5513
+ }
5514
+ finally { if (e_1) throw e_1.error; }
5515
+ }
5516
+ return null;
5641
5517
  };
5642
- var suggestExistingNode = function (type, fullKey) {
5643
- var keys = fullKey.split('.');
5644
- var key = keys.pop();
5645
- return keys.length >= 1 && ['@id', 'openLCAId'].includes(key) ? { type: type, isUniqueKey: '@id' } : undefined;
5518
+ var parentProperty = function (properties, property) {
5519
+ var _c;
5520
+ var allKeys = property.fullKey.split('.');
5521
+ __spreadArray([], __read(new Array(((_c = property.suggestions) === null || _c === void 0 ? void 0 : _c.parentLevel) || 0))).map(function () { return allKeys.pop(); });
5522
+ var parentKeys = fullKeyParts(allKeys.join('.'));
5523
+ parentKeys.pop();
5524
+ var parent = parentKeys.reduce(function (prev, curr, currIndex) {
5525
+ var prop = prev.find(function (v) { return v.key === curr; });
5526
+ return currIndex === parentKeys.length - 1 ? (prop || {}) : (prop.properties || []);
5527
+ }, properties);
5528
+ return Array.isArray(parent) ? property : parent;
5646
5529
  };
5647
- var defaultNodeTypeSuggestion = function (type) { return function (fullKey) { return suggestLinkNodes(type, fullKey) || suggestExistingNode(type, fullKey); }; };
5648
- var termSuggestions = function (parent, _d) {
5649
- var allOf = _d.allOf;
5650
- return ({
5651
- type: schema.NodeType.Term,
5652
- queries: __spreadArray(__spreadArray([], __read(compileSuggestionQueries(nonExpandableArrayDataPath(parent), allOf))), __read((['country'].includes(parent) ? [matchCountry] : [])))
5530
+ var nestedProperty = function (_d, nestedKey) {
5531
+ var properties = _d.properties;
5532
+ return properties.find(function (_d) {
5533
+ var key = _d.key;
5534
+ return key === nestedKey;
5653
5535
  });
5654
5536
  };
5655
- var formatLinkNodesSuggestions = function (nodeMap, type) { return (nodeMap[type] || []).map(function (id) { return ({ type: type, id: id, name: "Link with " + type + ": " + id }); }); };
5656
- var typeToSuggestion = (_d = {},
5657
- _d[schema.NodeType.Actor] = defaultNodeTypeSuggestion(schema.NodeType.Actor),
5658
- _d[schema.NodeType.Cycle] = defaultNodeTypeSuggestion(schema.NodeType.Cycle),
5659
- _d[schema.NodeType.ImpactAssessment] = defaultNodeTypeSuggestion(schema.NodeType.ImpactAssessment),
5660
- _d[schema.NodeType.Organisation] = defaultNodeTypeSuggestion(schema.NodeType.Organisation),
5661
- _d[schema.NodeType.Site] = defaultNodeTypeSuggestion(schema.NodeType.Site),
5662
- _d[schema.NodeType.Source] = defaultNodeTypeSuggestion(schema.NodeType.Source),
5663
- _d[schema.NodeType.Term] = function (fullKey, parentSchema) {
5664
- var keys = fullKey.split('.');
5665
- var key = keys.pop();
5666
- return ['name'].includes(key) && keys.length >= 1 ?
5667
- termSuggestions(keys.pop(), parentSchema) :
5668
- defaultNodeTypeSuggestion(schema.NodeType.Term)(fullKey);
5669
- },
5670
- _d[schema.SchemaType.Bibliography] = function (fullKey) {
5671
- var keys = fullKey.split('.');
5672
- var key = keys.pop();
5673
- var parent = keys.pop();
5674
- // prevent replacing a top-level source
5675
- return ['title', 'documentDOI', 'scopus'].includes(key) && parent === 'bibliography' && keys.length >= 1 ? {
5676
- type: schema.NodeType.Source,
5677
- parentLevel: 1
5678
- } : null;
5679
- },
5680
- _d.number = function (_a, _b, schema) {
5681
- var values = schema.const ? [schema.const] : [];
5682
- return {
5683
- type: values.length > 0 ? 'select' : defaultSuggestionType,
5684
- // exclude suggesting SchemaType
5685
- values: values
5686
- };
5687
- },
5688
- _d.integer = function (_a, _b, schema) {
5689
- var values = schema.const ? [schema.const] : [];
5690
- return {
5691
- type: values.length > 0 ? 'select' : defaultSuggestionType,
5692
- // exclude suggesting SchemaType
5693
- values: values
5694
- };
5695
- },
5696
- _d.string = function (fullKey, _b, schema$1) {
5697
- // exclude suggesting SchemaType
5698
- var values = schema$1.const ?
5699
- [schema$1.const] :
5700
- (schema$1.enum || []).filter(function (val) { return !Object.values(schema.SchemaType).includes(val); });
5701
- var key = fullKey.split('.').pop();
5702
- return {
5703
- type: values.length > 0 && key !== 'type' ? 'select' : defaultSuggestionType,
5704
- values: values
5705
- };
5706
- },
5707
- _d.boolean = function (_a) { return ({
5708
- type: 'select',
5709
- values: ['true', 'false']
5710
- }); },
5711
- _d);
5712
- var enableSuggestions = function (parentSchema, type, fullKey, schema) {
5713
- var suggestion = type in typeToSuggestion ? typeToSuggestion[type](fullKey, parentSchema) : null;
5714
- return suggestion !== null ? suggestion : (schema && schema.type in typeToSuggestion ?
5715
- typeToSuggestion[schema.type](fullKey, parentSchema, schema) :
5716
- null);
5717
- };
5718
- var formatProperty = function (prop) { return (Object.assign(Object.assign({ '@type': schema.SchemaType.Property }, prop), { term: Object.assign({ '@type': schema.NodeType.Term }, prop.term) })); };
5719
- var formatSuggestion = function (_c) {
5720
- var defaultProperties = _c.defaultProperties, node = __rest(_c, ["defaultProperties"]);
5721
- return (Object.assign(Object.assign({}, node), (defaultProperties ? { defaultProperties: defaultProperties.map(formatProperty) } : {})));
5722
- };
5723
- var nodeAvailableProperties = function (node, _d) {
5724
- var fullKey = _d.fullKey, schema = _d.schema, schemaType = _d.schemaType;
5725
- return availableProperties(schema, schemaType, fullKey ? get$1(node, fullKey, {}) : node, fullKey.length > 0);
5726
- };
5727
- var isAddPropertyEnabled = function (node, schemaType, schema, fullKey) {
5728
- if (fullKey === void 0) { fullKey = ''; }
5729
- return !!schema &&
5730
- !!Object.keys(nodeAvailableProperties(node, { fullKey: fullKey, schema: schema })).length &&
5731
- (!fullKey || nestingTypeEnabled(schemaType));
5537
+ var siblingProperty = function (properties, property, siblingKey) {
5538
+ var parent = parentProperty(properties, property);
5539
+ var parentProperties = parent === property ? properties : parent.properties;
5540
+ return parentProperties.find(function (prop) { return prop.key === siblingKey; });
5732
5541
  };
5733
- var editableKey = function (key) { return !['type', '@type', 'termType'].includes(key); };
5734
- var propertyId = function () { return uuid.v4(); };
5735
- var propertyUrl = function (node, key) { return ['@id', 'name'].includes(key) && linkTypeEnabled(node['@type']) ?
5736
- {
5737
- url: baseUrl() + "/" + node['@type'].toLowerCase() + "/" + node['@id'],
5738
- title: 'Open'
5739
- } :
5740
- (node.type === schema.SchemaType.Term && ['name'].includes(key) ? {
5741
- url: baseUrl() + "/glossary?query=",
5742
- urlParamValue: true,
5743
- title: 'Search in Glossary'
5744
- } : undefined); };
5745
- var propertyMapsUrl = function (node, key, value) { return ['type'].includes(key) && [
5746
- schema.SchemaType.Site.toString(),
5747
- schema.SchemaType.Organisation.toString()
5748
- ].includes(stringValue(value) || node.type) ?
5749
- {
5750
- url: mapsUrl({ lat: node.latitude, lng: node.longitude }),
5751
- title: 'View on maps',
5752
- icon: 'map'
5753
- } :
5754
- undefined; };
5755
- var propertyExternalUrl = function (node, key, value) { return propertyUrl(node, key) ||
5756
- propertyMapsUrl(node, key, value); };
5757
- var arrayPlaceholder = function (valueType) { return "Type a " + valueType + " then press Enter"; };
5758
- var defaultPlaceholder = function (_d, valueType) {
5759
- var type = _d.type, examples = _d.examples;
5760
- return (examples === null || examples === void 0 ? void 0 : examples.length) ? (Array.isArray(examples[0]) ? arrayPlaceholder(valueType) : examples[0]) : "Must be of type " + (type || valueType);
5542
+ var groupChanged = function (properties, key, value) {
5543
+ try {
5544
+ var parentKeys_1 = fullKeyParts(key);
5545
+ parentKeys_1.reduce(function (prev, curr, currIndex) {
5546
+ if (currIndex === parentKeys_1.length - 1 && value === null) {
5547
+ return prev.splice(prev.findIndex(function (v) { return v.key === curr; }), 1);
5548
+ }
5549
+ else {
5550
+ var prop = prev.find(function (v) { return v.key === curr; });
5551
+ prop.changed = true;
5552
+ return prop.properties;
5553
+ }
5554
+ }, properties);
5555
+ }
5556
+ catch (_err) { }
5761
5557
  };
5762
- var schemaPlacholder = function (schema, fullKey) {
5763
- var _d = __read(fullKey.split('.')), parent = _d[0], keys = _d.slice(1);
5764
- var properties = schema.properties || {};
5765
- var examples = (parent in properties ? properties[parent] : { examples: [] }).examples;
5766
- return (examples === null || examples === void 0 ? void 0 : examples.length) && typeof examples[0] === 'object' ? get$1(examples[0], keys.join('.'), null) : null;
5558
+ var refreshPropertyKeys = function (property) { return property.properties.map(function (prop, i) {
5559
+ prop.fullKey = "" + property.fullKey + (property.isArray ? "[" + i + "]" : "." + prop.key);
5560
+ prop.key = property.isArray ? "" + i : prop.key;
5561
+ return refreshPropertyKeys(prop);
5562
+ }); };
5563
+ var calculateCycleDurationEnabled = function (properties, property) {
5564
+ var startDate = siblingProperty(properties, property, 'startDate');
5565
+ var endDate = siblingProperty(properties, property, 'endDate');
5566
+ return !!(startDate === null || startDate === void 0 ? void 0 : startDate.value) && !!(endDate === null || endDate === void 0 ? void 0 : endDate.value);
5767
5567
  };
5768
- var propertyPlaceholder = function (schema, valueType, fullKey, parentSchema) {
5769
- if (fullKey === void 0) { fullKey = ''; }
5770
- return schema.type === 'array' ?
5771
- arrayPlaceholder(valueType) : (parentSchema && (fullKey === null || fullKey === void 0 ? void 0 : fullKey.length) ? schemaPlacholder(parentSchema, fullKey) : null) || defaultPlaceholder(schema, valueType);
5568
+ var calculateCycleDuration = function (properties, property) {
5569
+ var startDate = siblingProperty(properties, property, 'startDate');
5570
+ var endDate = siblingProperty(properties, property, 'endDate');
5571
+ return utils.diffInDays(startDate.value, endDate.value);
5772
5572
  };
5773
- var propertyTypeValue = {
5774
- object: function (val) { return safeJSONStringify(val); },
5775
- array: function (val, schema) {
5776
- var items = schema.items;
5777
- return '$ref' in items ? val : (Array.isArray(val) ?
5778
- val.map(function (value) { return propertyValue(items, value); }).join(ARRAY_DELIMITER) :
5779
- val);
5780
- },
5781
- json: function (val) { return val || ''; },
5782
- string: function (val) { return ("" + val || '').trim(); },
5783
- number: function (val) { return +("" + val || '0'); },
5784
- integer: function (val) { return +("" + val || '0'); },
5785
- boolean: function (val) { return ("" + val || '').toLowerCase() === 'true'; }
5573
+ var calculateCycleStartDateEnabled = function (properties, property) {
5574
+ var cycleDuration = siblingProperty(properties, property, 'cycleDuration');
5575
+ var endDate = siblingProperty(properties, property, 'endDate');
5576
+ return !!(cycleDuration === null || cycleDuration === void 0 ? void 0 : cycleDuration.value) && !!(endDate === null || endDate === void 0 ? void 0 : endDate.value);
5786
5577
  };
5787
- var propertyValue = function (schema, value) { return schema.type ? (Array.isArray(schema.type) ?
5788
- propertyTypeValue[typeof value](value, schema) :
5789
- propertyTypeValue[schema.type](value, schema)) :
5790
- safeJSONStringify(value); };
5791
- var propertyValueType = function (schema, value) { return (schema.type ? (Array.isArray(schema.type) ?
5792
- schema.type[0] :
5793
- schema.type === 'array' ?
5794
- propertyValueType(Object.assign(Object.assign({}, schema), { type: [schema.items.type] })) :
5795
- schema.type) : typeof value); };
5796
- var propertyTypeParseValue = {
5797
- object: function (val) { return safeJSONParse(val); },
5798
- array: function (val, schema) {
5799
- var items = schema.items;
5800
- return '$ref' in items ? val : (!val || Array.isArray(val) ? val : val.split(ARRAY_DELIMITER).map(function (value) { return parseNewValue(items, value); }));
5801
- },
5802
- json: function (val) { return val || ''; },
5803
- string: function (val) { return ("" + val || '').trim(); },
5804
- number: function (val) { return +("" + val || '0'); },
5805
- integer: function (val) { return +("" + val || '0'); },
5806
- boolean: function (val) { return ("" + val || '').toLowerCase() === 'true'; }
5578
+ var calculateCycleStartDate = function (properties, property) {
5579
+ var cycleDuration = siblingProperty(properties, property, 'cycleDuration');
5580
+ var endDate = siblingProperty(properties, property, 'endDate');
5581
+ return moment__namespace(endDate.value).locale('en-gb').subtract(cycleDuration.value, 'days').format('YYYY-MM-DD');
5807
5582
  };
5808
- /**
5809
- * Convert value to the final type in the schema.
5810
- *
5811
- * @param schema Definition of the value.
5812
- * @param value
5813
- * @returns Value in the correct format.
5814
- */
5815
- var parseNewValue = function (schema, value) { return schema.type ? (Array.isArray(schema.type) ?
5816
- propertyTypeParseValue[typeof value](value, schema) :
5817
- propertyTypeParseValue[schema.type](value, schema)) : value; };
5818
- var isOpenDefault = function (schemaType) { return [
5819
- schema.SchemaType.Term
5820
- ].includes(schemaType); };
5821
- // can the property be seen when the group is closed
5822
- var isKeyClosedVisible = function (key) { return ['type', 'id', '@type', '@id'].includes(key); };
5823
- var isKeyHidden = function (key) { return ['type', '@type'].includes(key); };
5824
- var isKeyRequired = function (key, def) { return ['type', 'id'].includes(key) || ((def === null || def === void 0 ? void 0 : def.required) || []).includes(key); };
5825
- var propertyError = function (errors) { return function (dataPath, nonExpandableArray) {
5826
- if (nonExpandableArray === void 0) { nonExpandableArray = false; }
5827
- return errors.find(function (error) { return (error.dataPath === dataPath || (nonExpandableArray && nonExpandableArrayDataPath(error.dataPath) === nonExpandableArrayDataPath(dataPath))) && (dataPath.length > 0 || !isMissingPropertyError(error)); });
5828
- }; };
5829
- var missingPropertyErrors = function (node, errors, parent) {
5830
- if (parent === void 0) { parent = ''; }
5831
- var allErrors = errors.filter(function (error) { return error.dataPath === keyToDataPath(parent) && isMissingPropertyError(error); });
5832
- // check for node not found errors
5833
- var missingNode = missingNodeErrors(allErrors);
5834
- return missingNode.length === 2 ? [{
5835
- id: propertyId(),
5836
- schemaType: node.type,
5837
- suggestions: { type: defaultSuggestionType },
5838
- key: '',
5839
- fullKey: parent,
5840
- value: '',
5841
- error: {
5842
- level: 'error',
5843
- message: missingNodeErrorMessage(node)
5844
- },
5845
- hasError: true,
5846
- properties: [],
5847
- addPropertyEnabled: false
5848
- }] : allErrors.map(function (error) {
5849
- var missingProperty = error.params.missingProperty;
5850
- var fullKey = parent ? parent + "." + missingProperty : missingProperty;
5851
- var missingOneOf = isMissingOneOfError(error);
5852
- return {
5853
- id: propertyId(),
5854
- schemaType: node.type,
5855
- suggestions: { type: defaultSuggestionType },
5856
- key: missingProperty,
5857
- fullKey: fullKey,
5858
- value: 'Add field to fix',
5859
- editable: false,
5860
- error: formatError(error),
5861
- hasError: missingOneOf ? false : errorHasError(error),
5862
- hasWarning: missingOneOf || errorHasWarning(error),
5863
- properties: [],
5864
- addPropertyEnabled: true
5865
- };
5866
- });
5583
+
5584
+ var isSite = function (_a) {
5585
+ var type = _a["@type"], id = _a["@id"];
5586
+ return type === schema.NodeType.Site && !!id;
5867
5587
  };
5868
- var propertyFromNode = function (schemas, errors, nodeSchema, deepEditable, parent, node) {
5869
- if (parent === void 0) { parent = ''; }
5870
- return function (key) {
5871
- var value = node[key];
5872
- var expandable = schema.isExpandable(value);
5873
- var isArray = Array.isArray(value);
5874
- var nonExpandableArray = isArray && !expandable;
5875
- var fullKey = Array.isArray(node) ? parent + "[" + key + "]" : [
5876
- parent,
5877
- key
5878
- ].filter(Boolean).join('.');
5879
- var nodeType = node.type || node['@type'];
5880
- var schemaType = expandable ? (isArray && value.length ? value[0].type || value[0]['@type'] : value.type || value['@type']) : nodeType;
5881
- var schema$1 = (schemas && schema.isTypeValid({ type: schemaType }) ? (expandable ? schemas[schemaType] : schemas[schemaType].properties[key]) : null) || {};
5882
- var isIri = isSchemaIri(schema$1);
5883
- var error = propertyError(errors)(keyToDataPath(fullKey), nonExpandableArray);
5884
- var parentSchema = expandable ? (
5885
- // TODO: for non-array, should be schema unless last recursion
5886
- isArray ? schema$1 : nodeSchema) : nodeSchema;
5887
- var properties = expandable || isIri ?
5888
- recursiveProperties(schemas, errors, parentSchema, deepEditable, fullKey)(value) : [];
5889
- var inError = errorHasError(error) || hasError(properties);
5890
- var inWarning = errorHasWarning(error) || hasWarning(properties);
5891
- var editable = schema.isTypeNode(node['@type']) || (expandable && schema.isTypeNode(value['@type'])) ?
5892
- false :
5893
- (
5894
- // prevent editing/adding new properties on existing sub-nodes
5895
- !deepEditable && schema.isTypeNode(schemaType) && (expandable ? value.type !== schema.NodeType.Term : parent && node.type !== schema.NodeType.Term) ?
5896
- false :
5897
- // handle IRI
5898
- (!schemaType && key === '@id') || editableKey(key));
5899
- var valueType = propertyValueType(schema$1, value);
5900
- return {
5901
- id: propertyId(),
5902
- schemaType: isIri ? null : schemaType,
5903
- schema: schema$1,
5904
- key: key,
5905
- fullKey: fullKey,
5906
- value: propertyValue(schema$1, value),
5907
- editable: inError || editable,
5908
- suggestions: enableSuggestions(nodeSchema, node.type, fullKey, schema$1),
5909
- addPropertyEnabled: isAddPropertyEnabled(node, schemaType, schema$1, fullKey),
5910
- newProperty: {},
5911
- newError: { level: 'warning' },
5912
- error: formatError(error),
5913
- isHidden: parent && isKeyHidden(key),
5914
- closedVisible: isKeyClosedVisible(key),
5915
- hasError: inError,
5916
- hasWarning: inWarning,
5917
- isRequired: isKeyRequired(key, schemas[nodeType]),
5918
- isArray: isArray,
5919
- isExpandable: expandable,
5920
- isOpen: isOpenDefault(schemaType),
5921
- properties: properties,
5922
- placeholder: propertyPlaceholder(schema$1, valueType, fullKey, parentSchema),
5923
- externalUrl: propertyExternalUrl(node, key, value)
5924
- };
5925
- };
5588
+ var siteLocation = function (_a) {
5589
+ var latitude = _a.latitude, longitude = _a.longitude;
5590
+ return latitude && longitude ? ({
5591
+ lat: latitude,
5592
+ lng: longitude
5593
+ }) : undefined;
5926
5594
  };
5927
- var singleProperty = function (schemas, errors, node, fullKey) {
5928
- var _d = __read(fullKey.split('.')), _t = _d[0], keys = _d.slice(1);
5929
- var key = keys.pop();
5930
- var parent = keys.join('.');
5931
- var parentNode = parent.length ? get$1(node, parent) : node;
5932
- var schemaType = schema.typeToSchemaType(parentNode.type || parentNode['@type']);
5933
- var parentSchema = schemas[schemaType];
5934
- return propertyFromNode(schemas, errors, parentSchema, true, parent, parentNode)(key);
5595
+ var siteDefaultLocation = function (_a) {
5596
+ var region = _a.region, country = _a.country;
5597
+ var markers = [
5598
+ region ? createMarker(termLocation(region), termLocationName(region).name, undefined, 20) : undefined,
5599
+ country ? createMarker(termLocation(country), termLocationName(country).name, undefined, 40) : undefined
5600
+ ].filter(Boolean);
5601
+ return (markers.length ? markers[0] : undefined);
5935
5602
  };
5936
- var recursiveProperties = function (schemas, errors, nodeSchema, deepEditable, parent) {
5937
- if (parent === void 0) { parent = ''; }
5938
- return function (node) {
5939
- var _d;
5940
- return (_d = Object.keys(node)
5941
- .filter(function (key) { return !privateKeys.includes(key); })
5942
- .map(propertyFromNode(schemas, errors, nodeSchema, deepEditable, parent, node)))
5943
- .concat.apply(_d, __spreadArray([], __read(missingPropertyErrors(node, errors, parent)))).sort(sortProperties);
5603
+ var siteMarker = function (site) { return createMarker(site ? siteLocation(site) : undefined, site.name); };
5604
+ var sitePolygon = function (_a) {
5605
+ var boundary = _a.boundary;
5606
+ return (boundary ? polygonsFromFeature(boundary) : undefined);
5607
+ };
5608
+ var regions = function (sites) { return utils.unique(sites.map(function (_a) {
5609
+ var country = _a.country, region = _a.region;
5610
+ return region ? region['@id'] : (country ? country['@id'] : null);
5611
+ }).filter(Boolean)); };
5612
+ var defaultCenter = { lat: 0, lng: 0 };
5613
+ var SitesMapsComponent = /** @class */ (function () {
5614
+ function SitesMapsComponent(nodeService) {
5615
+ this.nodeService = nodeService;
5616
+ this.loaded = false;
5617
+ this.loadPolygons = true;
5618
+ this.sites = [];
5619
+ this.nodes = [];
5620
+ this.center = defaultCenter;
5621
+ this.zoom = 2;
5622
+ this.showNotice = true;
5623
+ this.googleLoaded = false;
5624
+ this.showNoLocation = false;
5625
+ }
5626
+ SitesMapsComponent.prototype.ngOnInit = function () {
5627
+ var _this = this;
5628
+ waitFor('google', function () {
5629
+ _this.googleLoaded = true;
5630
+ setTimeout(function () { return !_this.loaded && _this.loadData(); });
5631
+ });
5632
+ };
5633
+ SitesMapsComponent.prototype.ngAfterViewInit = function () {
5634
+ return this.googleLoaded && this.loadData();
5635
+ };
5636
+ SitesMapsComponent.prototype.loadData = function () {
5637
+ return __awaiter(this, void 0, void 0, function () {
5638
+ var sites, markers, polygons, termPolygons;
5639
+ var _this = this;
5640
+ return __generator(this, function (_a) {
5641
+ switch (_a.label) {
5642
+ case 0:
5643
+ // loaded data as geojson
5644
+ this.map.googleMap.data.setStyle(function () { return (Object.assign(Object.assign({}, strokeStyle), { strokeOpacity: 0.1 })); });
5645
+ return [4 /*yield*/, this.getSites()];
5646
+ case 1:
5647
+ sites = _a.sent();
5648
+ markers = this.addSiteMarkers(sites);
5649
+ polygons = sites.flatMap(sitePolygon).filter(Boolean);
5650
+ polygons.map(function (polygon) { return polygon === null || polygon === void 0 ? void 0 : polygon.setMap(_this.map.googleMap); });
5651
+ this.loaded = true;
5652
+ return [4 /*yield*/, Promise.all(regions(sites).map(function (v) { return _this.addTermsPolygons(v); }))];
5653
+ case 2:
5654
+ termPolygons = (_a.sent()).flat();
5655
+ this.showNoLocation = markers.length === 0 && polygons.length === 0 && termPolygons.length === 0;
5656
+ return [2 /*return*/, markers.length ?
5657
+ this.centerMarker(markers[0]) :
5658
+ this.centerPolygons(polygons.length ? polygons : termPolygons)];
5659
+ }
5660
+ });
5661
+ });
5662
+ };
5663
+ SitesMapsComponent.prototype.addMarkers = function (markers, cluster) {
5664
+ var _this = this;
5665
+ if (cluster === void 0) { cluster = false; }
5666
+ return cluster ?
5667
+ new MarkerClusterer__default["default"](this.map.googleMap, markers, { imagePath: clustererImage }) :
5668
+ markers.map(function (marker) { return marker.setMap(_this.map.googleMap); });
5669
+ };
5670
+ SitesMapsComponent.prototype.addTermsPolygons = function (id) {
5671
+ return __awaiter(this, void 0, void 0, function () {
5672
+ var _a;
5673
+ return __generator(this, function (_b) {
5674
+ switch (_b.label) {
5675
+ case 0:
5676
+ if (!this.loadPolygons) return [3 /*break*/, 2];
5677
+ return [4 /*yield*/, this.termPolygons(id)];
5678
+ case 1:
5679
+ _a = _b.sent();
5680
+ return [3 /*break*/, 3];
5681
+ case 2:
5682
+ _a = [];
5683
+ _b.label = 3;
5684
+ case 3: return [2 /*return*/, _a];
5685
+ }
5686
+ });
5687
+ });
5944
5688
  };
5945
- };
5946
- var fullKeyParts = function (fullKey) { return fullKey.split('.').flatMap(function (val) {
5947
- if (val.endsWith(']')) {
5948
- var _d = __read(val.split('['), 2), key = _d[0], index = _d[1];
5949
- return [key, index.replace(']', '')];
5950
- }
5951
- return val;
5952
- }); };
5953
- var updateProperties = function (_d, updater) {
5954
- var properties = _d.properties;
5955
- return (properties || []).map(function (prop) { return updateProperties(updater(prop), updater); });
5956
- };
5957
- var typeToNewProperty = function (schemas, schema, nodeSchema, node, fullKey) {
5958
- var key = fullKeyParts(fullKey).pop();
5959
- var mappings = {
5960
- object: function () {
5961
- var _d = schemaRequiredProperties(schemas, schema), schemaType = _d.schemaType, properties = _d.properties;
5962
- node[key] = node[key] || {};
5963
- node[key].type = schemaType;
5964
- // TODO: handle load schemas from http source
5965
- if (schemaType.startsWith('http')) {
5966
- return typeToNewProperty(schemas, { type: 'json' }, nodeSchema, node, fullKey);
5967
- }
5968
- // TODO: handle nodeSchema should be schema unless last recursion
5969
- var props = properties
5970
- .filter(function (prop) { return nestingEnabled(schemaType, prop.key) && !!prop.value; })
5971
- .map(function (v) { return (Object.assign(Object.assign({}, typeToNewProperty(schemas, v.value, nodeSchema, node[key], fullKey + "." + v.key)), { isRequired: true })); });
5972
- var value = props.reduce(function (prev, curr) {
5973
- var _d;
5974
- return (Object.assign(Object.assign({}, prev), (_d = {}, _d[curr.key] = curr.value, _d)));
5975
- }, {});
5976
- return {
5977
- id: propertyId(),
5978
- isAdded: true,
5979
- schema: schemas[schemaType],
5980
- schemaType: schemaType,
5981
- key: key,
5982
- fullKey: fullKey,
5983
- value: value,
5984
- editable: editableKey(key),
5985
- isHidden: isKeyHidden(key),
5986
- closedVisible: isKeyClosedVisible(key),
5987
- suggestions: enableSuggestions(nodeSchema, schemaType, fullKey),
5988
- properties: props.sort(sortProperties),
5989
- addPropertyEnabled: isAddPropertyEnabled(node, schemaType, schemas[schemaType], key),
5990
- newProperty: {},
5991
- newError: { level: 'warning' },
5992
- isRequired: isKeyRequired(key, schema),
5993
- isArray: false,
5994
- isExpandable: true,
5995
- isOpen: isOpenDefault(schemaType)
5996
- };
5997
- },
5998
- array: function () {
5999
- var items = schema.items;
6000
- // array of string, number and boolean
6001
- if (items.type) {
6002
- return mappings.default();
5689
+ SitesMapsComponent.prototype.centerMarker = function (marker) {
5690
+ var center = marker.getPosition();
5691
+ this.center = center ? { lat: center.lat(), lng: center.lng() } : defaultCenter;
5692
+ };
5693
+ SitesMapsComponent.prototype.centerPolygons = function (polygons) {
5694
+ try {
5695
+ return polygons.length ? this.map.googleMap.fitBounds(polygonBounds(polygons)) : null;
5696
+ }
5697
+ catch (err) {
5698
+ if (polygons.length) {
5699
+ this.map.googleMap.fitBounds(polygonBounds(polygons[0]));
5700
+ this.zoom = 3;
6003
5701
  }
6004
- var schemaType = definitionToSchemaType(items);
6005
- node[key] = node[key] || [];
6006
- node[key].push({});
6007
- var property = typeToNewProperty(schemas, items, schemas[schemaType], node[key][0], fullKey + "[0]");
6008
- return {
6009
- id: propertyId(),
6010
- isAdded: true,
6011
- schema: schema,
6012
- schemaType: schemaType,
6013
- key: key,
6014
- fullKey: fullKey,
6015
- value: [property.value],
6016
- editable: editableKey(key),
6017
- isHidden: isKeyHidden(key),
6018
- closedVisible: isKeyClosedVisible(key),
6019
- suggestions: undefined,
6020
- properties: [property],
6021
- newProperty: {},
6022
- newError: { level: 'warning' },
6023
- isArray: true,
6024
- isExpandable: true,
6025
- addPropertyEnabled: false
6026
- };
6027
- },
6028
- default: function () {
6029
- var valueType = propertyValueType(schema);
6030
- var value = schema.default || schema.const || valueTypeToDefault[valueType];
6031
- node[key] = value;
6032
- return {
6033
- id: propertyId(),
6034
- isAdded: true,
6035
- schema: schema,
6036
- schemaType: node.type,
6037
- key: key,
6038
- fullKey: fullKey,
6039
- value: propertyValue(schema, value),
6040
- editable: editableKey(key),
6041
- isHidden: isKeyHidden(key),
6042
- closedVisible: isKeyClosedVisible(key),
6043
- suggestions: enableSuggestions(nodeSchema, node.type, fullKey, schema),
6044
- placeholder: propertyPlaceholder(schema, valueType, fullKey, nodeSchema),
6045
- externalUrl: propertyExternalUrl(node, key, value),
6046
- properties: [],
6047
- addPropertyEnabled: false
6048
- };
6049
5702
  }
6050
5703
  };
6051
- var mapped = !schema.type ? mappings.object : (schema.type in mappings ? mappings[schema.type] : mappings.default);
6052
- return mapped();
5704
+ SitesMapsComponent.prototype.addSiteMarkers = function (sites) {
5705
+ var siteMarkers = sites.map(siteMarker).filter(Boolean);
5706
+ var markers = siteMarkers.length ? siteMarkers : sites.map(siteDefaultLocation).filter(Boolean);
5707
+ this.addMarkers(markers, !!siteMarkers.length);
5708
+ return markers;
5709
+ };
5710
+ SitesMapsComponent.prototype.loadSite = function (node) {
5711
+ return __awaiter(this, void 0, void 0, function () {
5712
+ var _a;
5713
+ return __generator(this, function (_b) {
5714
+ switch (_b.label) {
5715
+ case 0:
5716
+ if (!('schemaVersion' in node)) return [3 /*break*/, 1];
5717
+ _a = node;
5718
+ return [3 /*break*/, 3];
5719
+ case 1: return [4 /*yield*/, this.nodeService.get(node)];
5720
+ case 2:
5721
+ _a = _b.sent();
5722
+ _b.label = 3;
5723
+ case 3:
5724
+ // means the site was already downloaded
5725
+ return [2 /*return*/, _a];
5726
+ }
5727
+ });
5728
+ });
5729
+ };
5730
+ SitesMapsComponent.prototype.siteData = function (node) {
5731
+ return __awaiter(this, void 0, void 0, function () {
5732
+ var _a, _b, _c, _d;
5733
+ return __generator(this, function (_e) {
5734
+ switch (_e.label) {
5735
+ case 0:
5736
+ if (![
5737
+ schema.NodeType.Site,
5738
+ schema.NodeType.Organisation
5739
+ ].includes(node.type)) return [3 /*break*/, 1];
5740
+ _a = node;
5741
+ return [3 /*break*/, 7];
5742
+ case 1:
5743
+ if (!isSite(node)) return [3 /*break*/, 2];
5744
+ _b = this.loadSite(node);
5745
+ return [3 /*break*/, 6];
5746
+ case 2:
5747
+ if (!('site' in node && isSite(node.site))) return [3 /*break*/, 3];
5748
+ _c = this.loadSite(node.site);
5749
+ return [3 /*break*/, 5];
5750
+ case 3:
5751
+ _d = this.siteData;
5752
+ return [4 /*yield*/, this.loadSite(node)];
5753
+ case 4:
5754
+ _c = _d.apply(this, [_e.sent()]);
5755
+ _e.label = 5;
5756
+ case 5:
5757
+ _b = (_c);
5758
+ _e.label = 6;
5759
+ case 6:
5760
+ _a = (_b);
5761
+ _e.label = 7;
5762
+ case 7: return [2 /*return*/, _a];
5763
+ }
5764
+ });
5765
+ });
5766
+ };
5767
+ SitesMapsComponent.prototype.getSites = function () {
5768
+ var _this = this;
5769
+ var nodes = this.sites && this.sites.length ? this.sites : this.nodes;
5770
+ return Promise.all(nodes.map(function (node) { return _this.siteData(node); }));
5771
+ };
5772
+ SitesMapsComponent.prototype.termPolygons = function (id) {
5773
+ return __awaiter(this, void 0, void 0, function () {
5774
+ var data, polygons, _err_1;
5775
+ var _this = this;
5776
+ return __generator(this, function (_a) {
5777
+ switch (_a.label) {
5778
+ case 0:
5779
+ _a.trys.push([0, 2, , 3]);
5780
+ return [4 /*yield*/, this.nodeService.downloadRaw(baseUrl() + "/gadm/" + id + ".geojson")];
5781
+ case 1:
5782
+ data = _a.sent();
5783
+ polygons = polygonsFromFeature(data);
5784
+ polygons.map(function (polygon) { return polygon.setMap(_this.map.googleMap); });
5785
+ return [2 /*return*/, polygons];
5786
+ case 2:
5787
+ _err_1 = _a.sent();
5788
+ // ignore error if the file does not exist
5789
+ return [2 /*return*/, []];
5790
+ case 3: return [2 /*return*/];
5791
+ }
5792
+ });
5793
+ });
5794
+ };
5795
+ return SitesMapsComponent;
5796
+ }());
5797
+ SitesMapsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMapsComponent, deps: [{ token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
5798
+ SitesMapsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMapsComponent, selector: "he-sites-maps", inputs: { loadPolygons: "loadPolygons", sites: "sites", nodes: "nodes", center: "center", zoom: "zoom", showNotice: "showNotice" }, viewQueries: [{ propertyName: "map", first: true, predicate: i1$2.GoogleMap, descendants: true }], ngImport: i0__namespace, template: "<google-map *ngIf=\"googleLoaded\"\n height=\"100%\"\n width=\"100%\"\n [zoom]=\"zoom\"\n [center]=\"center\"\n></google-map>\n\n<p *ngIf=\"showNotice\" class=\"mt-2 is-italic is-size-7\">The information provided might not be complete</p>\n\n<div class=\"no-location has-text-center has-text-light\" *ngIf=\"showNoLocation\">\n <span>No precise location data</span>\n</div>\n", styles: [":host{display:block;height:100%;position:relative;width:100%}.no-location{background-color:#0000004d;left:0;height:100%;position:absolute;top:0;width:100%;z-index:9}.no-location>span{display:inline-block;margin-top:12%}\n"], components: [{ type: i1__namespace$2.GoogleMap, selector: "google-map", inputs: ["height", "width", "center", "zoom", "options", "mapTypeId"], outputs: ["authFailure", "boundsChanged", "centerChanged", "mapClick", "mapDblclick", "mapDrag", "mapDragend", "mapDragstart", "headingChanged", "idle", "maptypeidChanged", "mapMousemove", "mapMouseout", "mapMouseover", "projectionChanged", "mapRightclick", "tilesloaded", "tiltChanged", "zoomChanged"], exportAs: ["googleMap"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
5799
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMapsComponent, decorators: [{
5800
+ type: i0.Component,
5801
+ args: [{
5802
+ selector: 'he-sites-maps',
5803
+ templateUrl: './sites-maps.component.html',
5804
+ styleUrls: ['./sites-maps.component.scss']
5805
+ }]
5806
+ }], ctorParameters: function () { return [{ type: HeNodeService }]; }, propDecorators: { map: [{
5807
+ type: i0.ViewChild,
5808
+ args: [i1$2.GoogleMap]
5809
+ }], loadPolygons: [{
5810
+ type: i0.Input
5811
+ }], sites: [{
5812
+ type: i0.Input
5813
+ }], nodes: [{
5814
+ type: i0.Input
5815
+ }], center: [{
5816
+ type: i0.Input
5817
+ }], zoom: [{
5818
+ type: i0.Input
5819
+ }], showNotice: [{
5820
+ type: i0.Input
5821
+ }] } });
5822
+
5823
+ var maxAreaSize = 5000;
5824
+ var siteTooBig = function (_a) {
5825
+ var area = _a.area;
5826
+ return area && area / 100 > maxAreaSize;
5827
+ };
5828
+ var hasMultipleValues = function (values) { return (values || []).length > 1; };
5829
+ var weighedAverage = function (_a) {
5830
+ var value = _a.value, depthLower = _a.depthLower, depthUpper = _a.depthUpper;
5831
+ return value.reduce(function (prev, curr, index) { return prev + (curr * (depthLower[index] - depthUpper[index])); }, 0) /
5832
+ value.reduce(function (prev, _curr, index) { return prev + (depthLower[index] - depthUpper[index]); }, 0);
5833
+ };
5834
+ var measurementValue = function (_a) {
5835
+ var value = _a.value, depthLower = _a.depthLower, depthUpper = _a.depthUpper;
5836
+ return hasMultipleValues(value) && hasMultipleValues(depthLower) && hasMultipleValues(depthUpper) ?
5837
+ weighedAverage({ value: value, depthLower: depthLower, depthUpper: depthUpper }) :
5838
+ propertyValue$1(value);
6053
5839
  };
6054
- var findProperty = function (properties, fullKey) {
6055
- var e_1, _d;
6056
- try {
6057
- for (var properties_1 = __values(properties), properties_1_1 = properties_1.next(); !properties_1_1.done; properties_1_1 = properties_1.next()) {
6058
- var p = properties_1_1.value;
6059
- if (p.fullKey === fullKey) {
6060
- return p;
6061
- }
6062
- var childP = findProperty(p.properties, fullKey);
6063
- if (childP) {
6064
- return childP;
6065
- }
6066
- }
5840
+
5841
+ var SitesMeasurementsLogsComponent = /** @class */ (function () {
5842
+ function SitesMeasurementsLogsComponent(searchService, nodeService) {
5843
+ this.searchService = searchService;
5844
+ this.nodeService = nodeService;
5845
+ this.originalValues = [];
5846
+ this.recalculatedValues = [];
5847
+ this.loading = true;
5848
+ this.NodeType = schema.NodeType;
5849
+ this.models = [];
5850
+ this.measurements = [];
6067
5851
  }
6068
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6069
- finally {
6070
- try {
6071
- if (properties_1_1 && !properties_1_1.done && (_d = properties_1.return)) _d.call(properties_1);
6072
- }
6073
- finally { if (e_1) throw e_1.error; }
5852
+ SitesMeasurementsLogsComponent.prototype.ngOnInit = function () {
5853
+ return __awaiter(this, void 0, void 0, function () {
5854
+ var _a, measurements;
5855
+ return __generator(this, function (_b) {
5856
+ switch (_b.label) {
5857
+ case 0:
5858
+ this.logsUrl = this.nodeService.nodeLogsUrl(this.node);
5859
+ _a = this;
5860
+ return [4 /*yield*/, this.nodeService.getModelsLog(this.node)];
5861
+ case 1:
5862
+ _a.logs = _b.sent();
5863
+ return [4 /*yield*/, this.searchService.search({
5864
+ fields: ['@type', '@id', 'name'],
5865
+ limit: 1000,
5866
+ query: {
5867
+ bool: {
5868
+ must: [
5869
+ matchType(schema.NodeType.Term),
5870
+ matchTermType(schema.TermTermType.measurement)
5871
+ ]
5872
+ }
5873
+ }
5874
+ })];
5875
+ case 2:
5876
+ measurements = (_b.sent()).results;
5877
+ this.measurements = measurements;
5878
+ this.loading = false;
5879
+ return [2 /*return*/];
5880
+ }
5881
+ });
5882
+ });
5883
+ };
5884
+ Object.defineProperty(SitesMeasurementsLogsComponent.prototype, "node", {
5885
+ get: function () {
5886
+ return Object.assign(Object.assign({}, this.site), { dataState: api.DataState.recalculated });
5887
+ },
5888
+ enumerable: false,
5889
+ configurable: true
5890
+ });
5891
+ return SitesMeasurementsLogsComponent;
5892
+ }());
5893
+ SitesMeasurementsLogsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsLogsComponent, deps: [{ token: HeSearchService }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
5894
+ SitesMeasurementsLogsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMeasurementsLogsComponent, selector: "he-sites-measurements-logs", inputs: { site: "site", originalValues: "originalValues", recalculatedValues: "recalculatedValues" }, ngImport: i0__namespace, template: "<he-node-logs-models *ngIf=\"!loading; else loader\"\n [logsUrl]=\"logsUrl\"\n [nodeType]=\"NodeType.Site\"\n [originalValues]=\"originalValues\"\n [recalculatedValues]=\"recalculatedValues\"\n [terms]=\"measurements\"\n [logs]=\"logs\"\n filteredType=\"Measurement\"\n></he-node-logs-models>\n\n<ng-template #loader>\n <div class=\"has-text-center py-3\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"lg\"></fa-icon>\n </div>\n</ng-template>\n", styles: [""], components: [{ type: NodeLogsModelsComponent, selector: "he-node-logs-models", inputs: ["nodeType", "nodeKey", "logsUrl", "originalValues", "recalculatedValues", "terms", "logs", "filteredType"] }, { type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
5895
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsLogsComponent, decorators: [{
5896
+ type: i0.Component,
5897
+ args: [{
5898
+ selector: 'he-sites-measurements-logs',
5899
+ templateUrl: './sites-measurements-logs.component.html',
5900
+ styleUrls: ['./sites-measurements-logs.component.scss']
5901
+ }]
5902
+ }], ctorParameters: function () { return [{ type: HeSearchService }, { type: HeNodeService }]; }, propDecorators: { site: [{
5903
+ type: i0.Input
5904
+ }], originalValues: [{
5905
+ type: i0.Input
5906
+ }], recalculatedValues: [{
5907
+ type: i0.Input
5908
+ }] } });
5909
+
5910
+ var orderBy$1 = require('lodash.orderby');
5911
+ var View$1;
5912
+ (function (View) {
5913
+ View["table"] = "table";
5914
+ View["logs"] = "logs";
5915
+ })(View$1 || (View$1 = {}));
5916
+ var SitesMeasurementsComponent = /** @class */ (function () {
5917
+ function SitesMeasurementsComponent() {
5918
+ this.originalValues = [];
5919
+ this.sites = [];
5920
+ this.showDownload = false;
5921
+ this.View = View$1;
5922
+ this.selectedView = View$1.table;
5923
+ this.maxAreaSize = maxAreaSize;
5924
+ this.siteTooBig = siteTooBig;
5925
+ this.defaultLabel = defaultLabel;
5926
+ this.measurementValue = measurementValue;
5927
+ this.measurements = [];
6074
5928
  }
6075
- return null;
6076
- };
6077
- var parentProperty = function (properties, property) {
6078
- var _c;
6079
- var allKeys = property.fullKey.split('.');
6080
- __spreadArray([], __read(new Array(((_c = property.suggestions) === null || _c === void 0 ? void 0 : _c.parentLevel) || 0))).map(function () { return allKeys.pop(); });
6081
- var parentKeys = fullKeyParts(allKeys.join('.'));
6082
- parentKeys.pop();
6083
- var parent = parentKeys.reduce(function (prev, curr, currIndex) {
6084
- var prop = prev.find(function (v) { return v.key === curr; });
6085
- return currIndex === parentKeys.length - 1 ? (prop || {}) : (prop.properties || []);
6086
- }, properties);
6087
- return Array.isArray(parent) ? property : parent;
6088
- };
6089
- var nestedProperty = function (_d, nestedKey) {
6090
- var properties = _d.properties;
6091
- return properties.find(function (_d) {
6092
- var key = _d.key;
6093
- return key === nestedKey;
5929
+ SitesMeasurementsComponent.prototype.ngOnChanges = function (changes) {
5930
+ if ('sites' in changes) {
5931
+ return this.update();
5932
+ }
5933
+ if ('dataState' in changes) {
5934
+ this.selectedView = View$1.table;
5935
+ }
5936
+ };
5937
+ SitesMeasurementsComponent.prototype.trackById = function (_index, item) {
5938
+ return item['@id'];
5939
+ };
5940
+ Object.defineProperty(SitesMeasurementsComponent.prototype, "isOriginal", {
5941
+ get: function () {
5942
+ return this.dataState === api.DataState.original;
5943
+ },
5944
+ enumerable: false,
5945
+ configurable: true
6094
5946
  });
6095
- };
6096
- var siblingProperty = function (properties, property, siblingKey) {
6097
- var parent = parentProperty(properties, property);
6098
- var parentProperties = parent === property ? properties : parent.properties;
6099
- return parentProperties.find(function (prop) { return prop.key === siblingKey; });
6100
- };
6101
- var groupChanged = function (properties, key, value) {
6102
- try {
6103
- var parentKeys_1 = fullKeyParts(key);
6104
- parentKeys_1.reduce(function (prev, curr, currIndex) {
6105
- if (currIndex === parentKeys_1.length - 1 && value === null) {
6106
- return prev.splice(prev.findIndex(function (v) { return v.key === curr; }), 1);
6107
- }
6108
- else {
6109
- var prop = prev.find(function (v) { return v.key === curr; });
6110
- prop.changed = true;
6111
- return prop.properties;
6112
- }
6113
- }, properties);
5947
+ SitesMeasurementsComponent.prototype.update = function () {
5948
+ var measurementsPerSite = groupNodesByTerm(this.sites, 'measurements', this.originalValues);
5949
+ this.measurements = orderBy$1(grouppedKeys(measurementsPerSite), ['key'], ['asc']);
5950
+ };
5951
+ SitesMeasurementsComponent.prototype.togglePopover = function (popover, context) {
5952
+ return popover.isOpen() ? popover.close() : popover.open(context);
5953
+ };
5954
+ Object.defineProperty(SitesMeasurementsComponent.prototype, "showAreaTooBig", {
5955
+ get: function () {
5956
+ return this.dataState === api.DataState.recalculated && (this.sites || []).some(siteTooBig);
5957
+ },
5958
+ enumerable: false,
5959
+ configurable: true
5960
+ });
5961
+ return SitesMeasurementsComponent;
5962
+ }());
5963
+ SitesMeasurementsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
5964
+ SitesMeasurementsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMeasurementsComponent, selector: "he-sites-measurements", inputs: { originalValues: "originalValues", sites: "sites", dataState: "dataState" }, usesOnChanges: true, ngImport: i0__namespace, template: "<ng-container *ngIf=\"measurements.length; else emptyTable\">\n <div class=\"columns is-variable is-2 m-0\">\n <div class=\"column is-hidden-mobile\"></div>\n <div class=\"column is-narrow\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.table\" (click)=\"selectedView = View.table\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"list\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Table view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"!isOriginal && sites.length === 1\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.logs\" (click)=\"selectedView = View.logs\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"calculator\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Recalculations logs</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"px-3 pb-3\" [class.is-hidden]=\"selectedView !== View.table\">\n <div class=\"has-text-right mb-2\">\n <button class=\"button is-dark is-outlined is-small\" (click)=\"showDownload = true\">\n <fa-icon icon=\"download\"></fa-icon>\n <span class=\"pl-2\">Download (CSV)</span>\n </button>\n </div>\n\n <div class=\"table-container data-table-container mb-1\">\n <table class=\"table is-narrow data-table has-children-{{measurements.length}}\">\n <thead>\n <tr>\n <th class=\"width-auto\"></th>\n <th *ngFor=\"let measurement of measurements\"\n [attr.title]=\"measurement.value.term.name\"\n >\n <he-node-link [node]=\"measurement.value.term\">\n <span>{{measurement.value.term.name | ellipsis:30}}</span>\n </he-node-link>\n </th>\n </tr>\n <tr>\n <th class=\"width-auto\"></th>\n <th *ngFor=\"let measurement of measurements\"\n [attr.title]=\"measurement.value.term.units\"\n >{{measurement.value.term.units}}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let site of sites; trackBy: trackById; let i = index\">\n <td class=\"width-auto\" [attr.title]=\"defaultLabel(site)\">\n <he-node-link [node]=\"site\">\n <span class=\"is-nowrap has-text-ellipsis\">{{i + 1}}. {{defaultLabel(site)}}</span>\n </he-node-link>\n </td>\n <td class=\"is-nowrap\" *ngFor=\"let measurement of measurements\">\n <span *ngIf=\"measurement.value.values[site['@id']]\"\n class=\"trigger-popover\"\n [ngbPopover]=\"details\" [autoClose]=\"'outside'\"\n triggers=\"manual\" #p=\"ngbPopover\" placement=\"left\" container=\"body\"\n (click)=\"togglePopover(p, { data: measurement.value.values[site['@id']], site: site, key: 'measurements' })\"\n >\n <span pointer>{{measurementValue(measurement.value.values[site['@id']]) | precision:3 | default:'-'}}</span>\n <he-blank-node-state class=\"ml-1\"\n [node]=\"measurement.value.values[site['@id']].nodes[0]\"\n key=\"value\"\n ></he-blank-node-state>\n </span>\n <span *ngIf=\"!measurement.value.values[site['@id']]\">\n <span>-</span>\n <sup class=\"pl-1\" *ngIf=\"siteTooBig(site)\">(1)</sup>\n </span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n\n <he-blank-node-state-notice [dataState]=\"dataState\"></he-blank-node-state-notice>\n\n <p class=\"is-size-7 is-italic\" *ngIf=\"showAreaTooBig\">\n (1) This region is >{{maxAreaSize}}km2 and is too large to reliably gap fill Measurements.\n </p>\n </div>\n\n <he-sites-measurements-logs *ngIf=\"selectedView === View.logs && !isOriginal\"\n [site]=\"sites[0]\"\n [originalValues]=\"originalValues[0].measurements\"\n [recalculatedValues]=\"sites[0].measurements\"\n ></he-sites-measurements-logs>\n</ng-container>\n\n<he-node-csv-export-confirm *ngIf=\"showDownload\"\n [nodes]=\"sites\" filename=\"site-measurements.csv\" [isUpload]=\"false\"\n [headerKeys]=\"['site.id', 'site.@id', 'site.measurements.']\"\n (closed)=\"showDownload = false\"\n></he-node-csv-export-confirm>\n\n<ng-template #emptyTable>\n <div class=\"panel-block\">\n <span>No data</span>\n </div>\n</ng-template>\n\n<ng-template #emptyValue>\n <span>-</span>\n</ng-template>\n\n<ng-template #details let-node=\"site\" let-data=\"data\" let-key=\"key\">\n <p><b>{{node.name}}</b></p>\n <he-node-value-details\n [data]=\"data\" [nodeType]=\"node['@type']\" [dataKey]=\"key\"\n ></he-node-value-details>\n</ng-template>\n", styles: ["fa-icon{display:inline-block;width:10px}\n"], components: [{ type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }, { type: NodeLinkComponent, selector: "he-node-link", inputs: ["node", "showExternalLink"] }, { type: BlankNodeStateComponent, selector: "he-blank-node-state", inputs: ["nodeType", "dataKey", "key", "node", "state"] }, { type: BlankNodeStateNoticeComponent, selector: "he-blank-node-state-notice", inputs: ["dataState", "showDeleted"] }, { type: SitesMeasurementsLogsComponent, selector: "he-sites-measurements-logs", inputs: ["site", "originalValues", "recalculatedValues"] }, { type: NodeCsvExportConfirmComponent, selector: "he-node-csv-export-confirm", inputs: ["nodes", "filename", "headerKeys", "extension", "isUpload"], outputs: ["closed"] }, { type: NodeValueDetailsComponent, selector: "he-node-value-details", inputs: ["data", "nodeType", "dataKey"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgbPopover, selector: "[ngbPopover]", inputs: ["animation", "autoClose", "placement", "triggers", "container", "disablePopover", "popoverClass", "openDelay", "closeDelay", "ngbPopover", "popoverTitle"], outputs: ["shown", "hidden"], exportAs: ["ngbPopover"] }], pipes: { "ellipsis": EllipsisPipe, "default": DefaultPipe, "precision": PrecisionPipe } });
5965
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsComponent, decorators: [{
5966
+ type: i0.Component,
5967
+ args: [{
5968
+ selector: 'he-sites-measurements',
5969
+ templateUrl: './sites-measurements.component.html',
5970
+ styleUrls: ['./sites-measurements.component.scss']
5971
+ }]
5972
+ }], propDecorators: { originalValues: [{
5973
+ type: i0.Input
5974
+ }], sites: [{
5975
+ type: i0.Input
5976
+ }], dataState: [{
5977
+ type: i0.Input
5978
+ }] } });
5979
+
5980
+ var components$2 = [
5981
+ SitesMapsComponent,
5982
+ SitesMeasurementsComponent,
5983
+ SitesMeasurementsLogsComponent
5984
+ ];
5985
+ var HeSitesModule = /** @class */ (function () {
5986
+ function HeSitesModule() {
6114
5987
  }
6115
- catch (_err) { }
6116
- };
6117
- var refreshPropertyKeys = function (property) { return property.properties.map(function (prop, i) {
6118
- prop.fullKey = "" + property.fullKey + (property.isArray ? "[" + i + "]" : "." + prop.key);
6119
- prop.key = property.isArray ? "" + i : prop.key;
6120
- return refreshPropertyKeys(prop);
6121
- }); };
6122
- var calculateCycleDurationEnabled = function (properties, property) {
6123
- var startDate = siblingProperty(properties, property, 'startDate');
6124
- var endDate = siblingProperty(properties, property, 'endDate');
6125
- return !!(startDate === null || startDate === void 0 ? void 0 : startDate.value) && !!(endDate === null || endDate === void 0 ? void 0 : endDate.value);
6126
- };
6127
- var calculateCycleDuration = function (properties, property) {
6128
- var startDate = siblingProperty(properties, property, 'startDate');
6129
- var endDate = siblingProperty(properties, property, 'endDate');
6130
- return utils.diffInDays(startDate.value, endDate.value);
6131
- };
6132
- var calculateCycleStartDateEnabled = function (properties, property) {
6133
- var cycleDuration = siblingProperty(properties, property, 'cycleDuration');
6134
- var endDate = siblingProperty(properties, property, 'endDate');
6135
- return !!(cycleDuration === null || cycleDuration === void 0 ? void 0 : cycleDuration.value) && !!(endDate === null || endDate === void 0 ? void 0 : endDate.value);
6136
- };
6137
- var calculateCycleStartDate = function (properties, property) {
6138
- var cycleDuration = siblingProperty(properties, property, 'cycleDuration');
6139
- var endDate = siblingProperty(properties, property, 'endDate');
6140
- return moment__namespace(endDate.value).locale('en-gb').subtract(cycleDuration.value, 'days').format('YYYY-MM-DD');
6141
- };
5988
+ return HeSitesModule;
5989
+ }());
5990
+ HeSitesModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
5991
+ HeSitesModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, declarations: [SitesMapsComponent,
5992
+ SitesMeasurementsComponent,
5993
+ SitesMeasurementsLogsComponent], imports: [i3.CommonModule, i1$4.ReactiveFormsModule,
5994
+ HeCommonModule,
5995
+ HeNodeModule], exports: [SitesMapsComponent,
5996
+ SitesMeasurementsComponent,
5997
+ SitesMeasurementsLogsComponent] });
5998
+ HeSitesModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, imports: [[
5999
+ i3.CommonModule, i1$4.ReactiveFormsModule,
6000
+ HeCommonModule,
6001
+ HeNodeModule
6002
+ ]] });
6003
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, decorators: [{
6004
+ type: i0.NgModule,
6005
+ args: [{
6006
+ declarations: components$2,
6007
+ exports: components$2,
6008
+ imports: [
6009
+ i3.CommonModule, i1$4.ReactiveFormsModule,
6010
+ HeCommonModule,
6011
+ HeNodeModule
6012
+ ]
6013
+ }]
6014
+ }] });
6142
6015
 
6143
6016
  var user = {};
6144
6017
  var HeUsersService = /** @class */ (function () {
@@ -7327,7 +7200,7 @@
7327
7200
  };
7328
7201
  return ImpactAssessmentsProductsComponent;
7329
7202
  }());
7330
- ImpactAssessmentsProductsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ImpactAssessmentsProductsComponent, deps: [{ token: i1__namespace$4.FormBuilder }, { token: HeNodeService }, { token: HeSearchService }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Component });
7203
+ ImpactAssessmentsProductsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ImpactAssessmentsProductsComponent, deps: [{ token: i1__namespace$4.FormBuilder }, { token: HeNodeService }, { token: HeSearchService }, { token: HeToastService }], target: i0__namespace.ɵɵFactoryTarget.Component });
7331
7204
  ImpactAssessmentsProductsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ImpactAssessmentsProductsComponent, selector: "he-impact-assessments-products", inputs: { cycles: "cycles", impactAssessments: "impactAssessments", key: "key", dataState: "dataState", enableCompare: "enableCompare", filterTermTypes: "filterTermTypes", enableFilterMethodModel: "enableFilterMethodModel" }, usesOnChanges: true, ngImport: i0__namespace, template: "<ng-container *ngIf=\"indicators.length; else emptyTable\">\n <div class=\"columns is-variable is-2 m-0\">\n <div class=\"column is-hidden-mobile\"></div>\n <div class=\"column is-narrow\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.table\" (click)=\"selectedView = View.table\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"list\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Table view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"impactAssessments.length > 1\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.chart\" (click)=\"selectedView = View.chart\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"chart-bar\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Chart view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"enableBreakdown\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.breakdown\" (click)=\"selectedView = View.breakdown\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"chart-bar\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Breakdown view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"!isOriginal && impactAssessments.length === 1\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.logs\" (click)=\"showRecalculationLogs()\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"calculator\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Recalculations logs</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"px-3 pb-3\" [class.is-hidden]=\"selectedView !== View.table\">\n <div class=\"has-text-right mb-2\">\n <button class=\"button is-dark is-outlined is-small\" (click)=\"showDownload = true\">\n <fa-icon icon=\"download\"></fa-icon>\n <span class=\"pl-2\">Download (CSV)</span>\n </button>\n </div>\n\n <div class=\"table-container data-table-container mb-1\" *bindOnce=\"indicators\">\n <table class=\"table is-narrow data-table has-children-{{indicators.length + 1}}\">\n <thead>\n <tr>\n <th class=\"width-auto\">\n <div class=\"select is-small\" *ngIf=\"enableFilterMethodModel\">\n <select name=\"selectedMethodModel\"\n (change)=\"updateImpacts()\" [(ngModel)]=\"selectedMethodModel\"\n >\n <option [ngValue]=\"undefined\">Filter Model</option>\n <option *ngFor=\"let term of methodModels\" [ngValue]=\"term\">{{term.name}}</option>\n </select>\n </div>\n </th>\n <th></th>\n <th *ngFor=\"let indicator of indicators\"\n [attr.title]=\"indicator.value.term.name\"\n >\n <he-node-link [node]=\"indicator.value.term\">\n <span>{{indicator.value.term.name | ellipsis:30}}</span>\n </he-node-link>\n </th>\n </tr>\n <tr>\n <th class=\"width-auto\">\n <a [href]=\"baseUrl + '/schema/ImpactAssessment#functionalUnit'\" target=\"_blank\">Functional unit:</a>\n <span class=\"pl-1\">1 kg</span>\n </th>\n <th>Product</th>\n <th *ngFor=\"let indicator of indicators\"\n [attr.title]=\"indicator.value.term.units\"\n >{{indicator.value.term.units}}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let impactAssessment of impactAssessments; trackBy: trackById; let i = index\">\n <td class=\"width-auto\" [attr.title]=\"impactName(impactAssessment)\" [style.border-left-color]=\"itemColor(i)\">\n <label *ngIf=\"enableCompare\" class=\"is-inline-block checkbox\">\n <input type=\"checkbox\" class=\"selector\"\n (change)=\"toggleImpact(impactAssessment)\"\n [checked]=\"isSelected(impactAssessment)\"\n >\n </label>\n <he-node-link class=\"is-inline-block\" [node]=\"impactAssessment\">\n <span class=\"is-nowrap has-text-ellipsis\">{{i + 1}}. {{impactName(impactAssessment)}}</span>\n </he-node-link>\n </td>\n <td [attr.title]=\"impactAssessment.product?.name\">\n <he-node-link *ngIf=\"impactAssessment.product\" [node]=\"impactAssessment.product\">\n <span>{{impactAssessment.product.name | ellipsis:30}}</span>\n </he-node-link>\n </td>\n <td class=\"is-nowrap\" *ngFor=\"let indicator of indicators\">\n <span *ngIf=\"indicator.value.values[impactAssessment['@id']]; else emptyValue\"\n class=\"trigger-popover\"\n [ngbPopover]=\"details\" [autoClose]=\"'outside'\"\n triggers=\"manual\" #p=\"ngbPopover\" placement=\"left\" container=\"body\"\n (click)=\"togglePopover(p, { data: indicator.value.values[impactAssessment['@id']], impactAssessment: impactAssessment, key: key })\"\n >\n <span pointer>{{propertyValue(indicator.value.values[impactAssessment['@id']].value, key === 'impacts') | precision:3 | default:'-'}}</span>\n <he-blank-node-state class=\"ml-1\"\n [node]=\"indicator.value.values[impactAssessment['@id']].nodes[0]\"\n key=\"value\"\n [state]=\"impactAssessment.aggregated ? 'aggregated' : null\"\n ></he-blank-node-state>\n </span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n\n <he-blank-node-state-notice [dataState]=\"dataState\"></he-blank-node-state-notice>\n\n <form *ngIf=\"enableCompare\" class=\"mt-2\" [formGroup]=\"form\" (submit)=\"form.valid && addImpact()\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <span class=\"button is-small is-static\">Compare with Aggregated Impact Assessment</span>\n </div>\n <div class=\"control is-expanded\" [class.has-icons-right]=\"suggesting || loading\">\n <input class=\"input is-small\"\n placeholder=\"Search by name or id\"\n formControlName=\"search\" name=\"search\"\n\n [ngbTypeahead]=\"suggestImpactAssessment\"\n [inputFormatter]=\"formatter\"\n [resultTemplate]=\"suggestion\"\n [focusFirst]=\"true\"\n >\n <span class=\"icon is-small is-right has-text-grey-dark\" [class.is-hidden]=\"!(suggesting || loading)\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"sm\"></fa-icon>\n </span>\n </div>\n <div class=\"control\">\n <button class=\"button is-small\" type=\"submit\" [disabled]=\"suggesting || loading\">\n <fa-icon icon=\"plus\"></fa-icon>\n </button>\n </div>\n </div>\n </form>\n </div>\n\n <he-impact-assessments-indicator-breakdown-chart *ngIf=\"selectedView === View.breakdown\"\n [impactAssessment]=\"impactAssessments[0]\"\n [indicators]=\"impactAssessments[0][key]\"\n ></he-impact-assessments-indicator-breakdown-chart>\n\n <he-impact-assessments-indicators-chart *ngIf=\"impactAssessments.length > 1\" [class.is-hidden]=\"selectedView !== View.chart\"\n [key]=\"key\"\n [impactAssessments]=\"selectedImpactAssessments\"\n [filterTermTypes]=\"filterTermTypes\"\n ></he-impact-assessments-indicators-chart>\n\n <he-impact-assessments-products-logs *ngIf=\"selectedView === View.logs && !isOriginal\"\n [key]=\"key\"\n [impactAssessment]=\"impactAssessments[0]\"\n [filterTermTypes]=\"filterTermTypes\"\n [originalValues]=\"originalValues[0][key]\"\n [recalculatedValues]=\"impactAssessments[0][key]\"\n ></he-impact-assessments-products-logs>\n</ng-container>\n\n<he-node-csv-export-confirm *ngIf=\"showDownload\"\n [nodes]=\"impactAssessments\" [filename]=\"'impact-' + key + '.csv'\" [isUpload]=\"false\"\n [headerKeys]=\"['impactAssessment.id', 'impactAssessment.@id', 'impactAssessment.' + key + '.']\"\n (closed)=\"showDownload = false\"\n></he-node-csv-export-confirm>\n\n<ng-template #emptyTable>\n <div class=\"panel-block\">\n <span>No data</span>\n </div>\n</ng-template>\n\n<ng-template #emptyValue>\n <span>-</span>\n</ng-template>\n\n<ng-template #details let-node=\"impactAssessment\" let-data=\"data\" let-key=\"key\">\n <p *bindOnce=\"node\">\n <b>\n <span *ngIf=\"data.cycle\">{{cycleLabel(node.cycle)}}</span>\n <span *ngIf=\"!data.cycle\">{{data.name}}</span>\n </b>\n </p>\n <he-node-value-details\n [data]=\"data\" [nodeType]=\"node['@type']\" [dataKey]=\"key\"\n ></he-node-value-details>\n</ng-template>\n\n<ng-template #suggestion let-impact=\"result\" let-t=\"term\">\n <div class=\"is-block\">\n <ngb-highlight [result]=\"impact.name || impact.cycle.name\" [term]=\"t\"></ngb-highlight>\n </div>\n <div class=\"columns is-flex\">\n <div class=\"column\" *ngIf=\"impact.country\">\n <span class=\"pr-1 has-text-underline\">Country:</span>\n <span class=\"is-inline-flex\"><ngb-highlight [result]=\"impact.country.name\" [term]=\"t\"></ngb-highlight></span>\n </div>\n <div class=\"column\" *ngIf=\"impact.product\">\n <span class=\"pr-1 has-text-underline\">Product:</span>\n <span class=\"is-inline-flex\"><ngb-highlight [result]=\"impact.product.name\" [term]=\"t\"></ngb-highlight></span>\n </div>\n <div class=\"column\" *ngIf=\"impact.endDate\">\n <span class=\"pr-1 has-text-underline\">Date:</span>\n <span class=\"is-inline-flex\"><ngb-highlight [result]=\"impact.endDate\" [term]=\"t\"></ngb-highlight></span>\n </div>\n </div>\n</ng-template>\n", styles: ["label.checkbox{width:20px}td he-node-link{width:160px}table.data-table td:first-child{border-left-width:8px}\n"], components: [{ type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }, { type: NodeLinkComponent, selector: "he-node-link", inputs: ["node", "showExternalLink"] }, { type: BlankNodeStateComponent, selector: "he-blank-node-state", inputs: ["nodeType", "dataKey", "key", "node", "state"] }, { type: BlankNodeStateNoticeComponent, selector: "he-blank-node-state-notice", inputs: ["dataState", "showDeleted"] }, { type: ImpactAssessmentsIndicatorBreakdownChartComponent, selector: "he-impact-assessments-indicator-breakdown-chart", inputs: ["impactAssessment", "indicators"] }, { type: ImpactAssessmentsIndicatorsChartComponent, selector: "he-impact-assessments-indicators-chart", inputs: ["impactAssessments", "key", "filterTermTypes"] }, { type: ImpactAssessmentsProductsLogsComponent, selector: "he-impact-assessments-products-logs", inputs: ["impactAssessment", "key", "filterTermTypes", "originalValues", "recalculatedValues"] }, { type: NodeCsvExportConfirmComponent, selector: "he-node-csv-export-confirm", inputs: ["nodes", "filename", "headerKeys", "extension", "isUpload"], outputs: ["closed"] }, { type: NodeValueDetailsComponent, selector: "he-node-value-details", inputs: ["data", "nodeType", "dataKey"] }, { type: i10__namespace.NgbHighlight, selector: "ngb-highlight", inputs: ["highlightClass", "result", "term"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: BindOnceDirective, selector: "[bindOnce]", inputs: ["bindOnce"] }, { type: i1__namespace$4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i1__namespace$4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1__namespace$4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i1__namespace$4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1__namespace$4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgbPopover, selector: "[ngbPopover]", inputs: ["animation", "autoClose", "placement", "triggers", "container", "disablePopover", "popoverClass", "openDelay", "closeDelay", "ngbPopover", "popoverTitle"], outputs: ["shown", "hidden"], exportAs: ["ngbPopover"] }, { type: i1__namespace$4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1__namespace$4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1__namespace$4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1__namespace$4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i10__namespace.NgbTypeahead, selector: "input[ngbTypeahead]", inputs: ["autocomplete", "placement", "container", "editable", "focusFirst", "showHint", "inputFormatter", "ngbTypeahead", "resultFormatter", "resultTemplate"], outputs: ["selectItem"], exportAs: ["ngbTypeahead"] }, { type: i1__namespace$4.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }], pipes: { "ellipsis": EllipsisPipe, "default": DefaultPipe, "precision": PrecisionPipe } });
7332
7205
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ImpactAssessmentsProductsComponent, decorators: [{
7333
7206
  type: i0.Component,
@@ -7336,7 +7209,7 @@
7336
7209
  templateUrl: './impact-assessments-products.component.html',
7337
7210
  styleUrls: ['./impact-assessments-products.component.scss']
7338
7211
  }]
7339
- }], ctorParameters: function () { return [{ type: i1__namespace$4.FormBuilder }, { type: HeNodeService }, { type: HeSearchService }, { type: ToastService }]; }, propDecorators: { cycles: [{
7212
+ }], ctorParameters: function () { return [{ type: i1__namespace$4.FormBuilder }, { type: HeNodeService }, { type: HeSearchService }, { type: HeToastService }]; }, propDecorators: { cycles: [{
7340
7213
  type: i0.Input
7341
7214
  }], impactAssessments: [{
7342
7215
  type: i0.Input
@@ -7436,6 +7309,7 @@
7436
7309
  * Generated bundle index. Do not edit.
7437
7310
  */
7438
7311
 
7312
+ exports.ARRAY_DELIMITER = ARRAY_DELIMITER;
7439
7313
  exports.BibliographiesSearchConfirmComponent = BibliographiesSearchConfirmComponent;
7440
7314
  exports.BindOnceDirective = BindOnceDirective;
7441
7315
  exports.BlankNodeDiffsComponent = BlankNodeDiffsComponent;
@@ -7477,6 +7351,7 @@
7477
7351
  exports.HeSearchModule = HeSearchModule;
7478
7352
  exports.HeSearchService = HeSearchService;
7479
7353
  exports.HeSitesModule = HeSitesModule;
7354
+ exports.HeToastService = HeToastService;
7480
7355
  exports.HeUsersService = HeUsersService;
7481
7356
  exports.ImpactAssessmentsIndicatorBreakdownChartComponent = ImpactAssessmentsIndicatorBreakdownChartComponent;
7482
7357
  exports.ImpactAssessmentsIndicatorsChartComponent = ImpactAssessmentsIndicatorsChartComponent;
@@ -7510,45 +7385,78 @@
7510
7385
  exports.TagsInputDirective = TagsInputDirective;
7511
7386
  exports.TimesPipe = TimesPipe;
7512
7387
  exports.ToastComponent = ToastComponent;
7513
- exports.ToastService = ToastService;
7514
7388
  exports.UnitConverterComponent = UnitConverterComponent;
7389
+ exports.addPolygonToFeature = addPolygonToFeature;
7515
7390
  exports.allCountriesQuery = allCountriesQuery;
7516
- exports.animateCounter = animateCounter;
7517
7391
  exports.arrayValue = arrayValue;
7518
7392
  exports.availableProperties = availableProperties;
7519
7393
  exports.baseUrl = baseUrl;
7520
7394
  exports.bottom = bottom;
7395
+ exports.calculateCycleDuration = calculateCycleDuration;
7396
+ exports.calculateCycleDurationEnabled = calculateCycleDurationEnabled;
7397
+ exports.calculateCycleStartDate = calculateCycleStartDate;
7398
+ exports.calculateCycleStartDateEnabled = calculateCycleStartDateEnabled;
7399
+ exports.clustererImage = clustererImage;
7400
+ exports.code = code;
7401
+ exports.coordinatesToPoint = coordinatesToPoint;
7521
7402
  exports.countriesQuery = countriesQuery;
7403
+ exports.createMarker = createMarker;
7522
7404
  exports.cropsQuery = cropsQuery;
7405
+ exports.dataPathToKey = dataPathToKey;
7523
7406
  exports.dataValue = dataValue;
7407
+ exports.defaultFeature = defaultFeature;
7524
7408
  exports.defaultLabel = defaultLabel;
7409
+ exports.defaultSuggestionType = defaultSuggestionType;
7525
7410
  exports.definitionToSchemaType = definitionToSchemaType;
7526
7411
  exports.delta = delta;
7527
7412
  exports.deserializeSearchFilters = deserializeSearchFilters;
7528
7413
  exports.ellipsis = ellipsis;
7529
7414
  exports.emptyValue = emptyValue;
7415
+ exports.errorHasError = errorHasError;
7416
+ exports.errorHasWarning = errorHasWarning;
7530
7417
  exports.errorText = errorText;
7531
7418
  exports.filenameWithoutExt = filenameWithoutExt;
7419
+ exports.fillColor = fillColor;
7420
+ exports.fillStyle = fillStyle;
7421
+ exports.filterError = filterError;
7532
7422
  exports.filterParams = filterParams;
7423
+ exports.findConfigModels = findConfigModels;
7424
+ exports.findProperty = findProperty;
7533
7425
  exports.findPropertyById = findPropertyById;
7426
+ exports.formatCustomErrorMessage = formatCustomErrorMessage;
7427
+ exports.formatError = formatError;
7428
+ exports.formatLinkNodesSuggestions = formatLinkNodesSuggestions;
7429
+ exports.formatPropertyError = formatPropertyError;
7430
+ exports.formatSuggestion = formatSuggestion;
7431
+ exports.gitBranch = gitBranch;
7534
7432
  exports.gitHome = gitHome;
7535
7433
  exports.gitRawBaseUrl = gitRawBaseUrl;
7434
+ exports.groupChanged = groupChanged;
7536
7435
  exports.groupNodesByTerm = groupNodesByTerm;
7537
7436
  exports.grouppedKeys = grouppedKeys;
7538
7437
  exports.grouppedValueKeys = grouppedValueKeys;
7539
7438
  exports.handleAPIError = handleAPIError;
7540
- exports.hoursBefore = hoursBefore;
7439
+ exports.hasError = hasError;
7440
+ exports.hasWarning = hasWarning;
7441
+ exports.isAddPropertyEnabled = isAddPropertyEnabled;
7541
7442
  exports.isChrome = isChrome;
7542
7443
  exports.isExternal = isExternal;
7444
+ exports.isMissingOneOfError = isMissingOneOfError;
7445
+ exports.isMissingPropertyError = isMissingPropertyError;
7543
7446
  exports.isSchemaIri = isSchemaIri;
7544
7447
  exports.isScrolledBelow = isScrolledBelow;
7545
7448
  exports.itemColor = itemColor;
7449
+ exports.keyToDataPath = keyToDataPath;
7546
7450
  exports.keyToLabel = keyToLabel;
7547
7451
  exports.levels = levels;
7548
7452
  exports.linkTypeEnabled = linkTypeEnabled;
7549
7453
  exports.listColor = listColor;
7550
- exports.loadScript = loadScript;
7454
+ exports.locationQuery = locationQuery;
7455
+ exports.lookupUrl = lookupUrl;
7456
+ exports.lookups = lookups;
7551
7457
  exports.mapsUrl = mapsUrl;
7458
+ exports.markerIcon = markerIcon;
7459
+ exports.markerPie = markerPie;
7552
7460
  exports.matchAggregatedQuery = matchAggregatedQuery;
7553
7461
  exports.matchBoolPrefixQuery = matchBoolPrefixQuery;
7554
7462
  exports.matchCountry = matchCountry;
@@ -7565,18 +7473,36 @@
7565
7473
  exports.matchType = matchType;
7566
7474
  exports.maxAreaSize = maxAreaSize;
7567
7475
  exports.measurementValue = measurementValue;
7568
- exports.minutesBefore = minutesBefore;
7476
+ exports.missingNodeErrorMessage = missingNodeErrorMessage;
7477
+ exports.missingNodeErrors = missingNodeErrors;
7569
7478
  exports.multiMatchQuery = multiMatchQuery;
7479
+ exports.nestedProperty = nestedProperty;
7570
7480
  exports.nestingEnabled = nestingEnabled;
7571
7481
  exports.nestingTypeEnabled = nestingTypeEnabled;
7572
- exports.nodeTypeToString = nodeTypeToString;
7482
+ exports.nodeAvailableProperties = nodeAvailableProperties;
7483
+ exports.nodeLink = nodeLink;
7484
+ exports.nodeLogsUrl = nodeLogsUrl;
7485
+ exports.nodeUrl = nodeUrl;
7573
7486
  exports.numberGte = numberGte;
7487
+ exports.parentKey = parentKey;
7488
+ exports.parentProperty = parentProperty;
7574
7489
  exports.parseData = parseData;
7490
+ exports.parseDataPath = parseDataPath;
7575
7491
  exports.parseLines = parseLines;
7576
7492
  exports.parseMessage = parseMessage;
7577
- exports.parseNodeType = parseNodeType;
7493
+ exports.parseNewValue = parseNewValue;
7494
+ exports.pathToApiDocsPath = pathToApiDocsPath;
7495
+ exports.pointToCoordinates = pointToCoordinates;
7496
+ exports.polygonBounds = polygonBounds;
7497
+ exports.polygonToCoordinates = polygonToCoordinates;
7498
+ exports.polygonsFromFeature = polygonsFromFeature;
7499
+ exports.primaryProduct = primaryProduct;
7500
+ exports.propertyError = propertyError;
7501
+ exports.propertyId = propertyId;
7578
7502
  exports.propertyValue = propertyValue$1;
7503
+ exports.recursiveProperties = recursiveProperties;
7579
7504
  exports.refToSchemaType = refToSchemaType;
7505
+ exports.refreshPropertyKeys = refreshPropertyKeys;
7580
7506
  exports.regionsQuery = regionsQuery;
7581
7507
  exports.repeat = repeat;
7582
7508
  exports.roundValue = roundValue;
@@ -7590,9 +7516,13 @@
7590
7516
  exports.searchResultsFields = searchResultsFields;
7591
7517
  exports.searchableTypes = searchableTypes;
7592
7518
  exports.serializeSearchFilters = serializeSearchFilters;
7519
+ exports.siblingProperty = siblingProperty;
7520
+ exports.singleProperty = singleProperty;
7593
7521
  exports.siteTooBig = siteTooBig;
7594
- exports.sortByFn = sortByFn;
7595
7522
  exports.sortOrder = sortOrder;
7523
+ exports.sortProperties = sortProperties;
7524
+ exports.strokeColor = strokeColor;
7525
+ exports.strokeStyle = strokeStyle;
7596
7526
  exports.suggestMatchQuery = suggestMatchQuery;
7597
7527
  exports.suggestQuery = suggestQuery;
7598
7528
  exports.termChildToParent = termChildToParent;
@@ -7601,10 +7531,11 @@
7601
7531
  exports.termProperties = termProperties;
7602
7532
  exports.termTypeGroups = termTypeGroups;
7603
7533
  exports.termTypeLabel = termTypeLabel;
7534
+ exports.termTypeLookupUrl = termTypeLookupUrl;
7604
7535
  exports.toCsv = toCsv$1;
7605
7536
  exports.toDashCase = toDashCase;
7606
- exports.toFormData = toFormData;
7607
- exports.toSearchParams = toSearchParams;
7537
+ exports.typeToNewProperty = typeToNewProperty;
7538
+ exports.updateProperties = updateProperties;
7608
7539
  exports.valueTypeToDefault = valueTypeToDefault;
7609
7540
  exports.waitFor = waitFor;
7610
7541
  exports.wildcardQuery = wildcardQuery;