diff --git a/all-chts-bundle.js b/all-chts-bundle.js
index 78e076b2..e8f4a1cd 100644
--- a/all-chts-bundle.js
+++ b/all-chts-bundle.js
@@ -27,4 +27,14 @@ module.exports = {
nootils: require('cht-core-3-11/shared-libs/rules-engine/node_modules/medic-nootils'),
Lineage: require('cht-core-3-11/shared-libs/lineage'),
},
+ '3.12': {
+ ddocs: require('./build/cht-core-3-12-ddocs.json'),
+ RegistrationUtils: require('cht-core-3-12/shared-libs/registration-utils'),
+ CalendarInterval: require('cht-core-3-12/shared-libs/calendar-interval'),
+ RulesEngineCore: require('cht-core-3-12/shared-libs/rules-engine'),
+ RulesEmitter: require('cht-core-3-12/shared-libs/rules-engine/src/rules-emitter'),
+ nootils: require('cht-core-3-12/shared-libs/rules-engine/node_modules/medic-nootils'),
+ Lineage: require('cht-core-3-12/shared-libs/lineage'),
+ ChtScriptApi: require('cht-core-3-12/shared-libs/cht-script-api'),
+ },
};
diff --git a/dist/all-chts-bundle.dev.js b/dist/all-chts-bundle.dev.js
index eaa054d0..59175887 100644
--- a/dist/all-chts-bundle.dev.js
+++ b/dist/all-chts-bundle.dev.js
@@ -36,6 +36,16 @@ module.exports = {
nootils: __webpack_require__(/*! cht-core-3-11/shared-libs/rules-engine/node_modules/medic-nootils */ "./node_modules/cht-core-3-11/shared-libs/rules-engine/node_modules/medic-nootils/src/nootils.js"),
Lineage: __webpack_require__(/*! cht-core-3-11/shared-libs/lineage */ "./node_modules/cht-core-3-11/shared-libs/lineage/src/index.js"),
},
+ '3.12': {
+ ddocs: __webpack_require__(/*! ./build/cht-core-3-12-ddocs.json */ "./build/cht-core-3-12-ddocs.json"),
+ RegistrationUtils: __webpack_require__(/*! cht-core-3-12/shared-libs/registration-utils */ "./node_modules/cht-core-3-12/shared-libs/registration-utils/src/index.js"),
+ CalendarInterval: __webpack_require__(/*! cht-core-3-12/shared-libs/calendar-interval */ "./node_modules/cht-core-3-12/shared-libs/calendar-interval/src/index.js"),
+ RulesEngineCore: __webpack_require__(/*! cht-core-3-12/shared-libs/rules-engine */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/src/index.js"),
+ RulesEmitter: __webpack_require__(/*! cht-core-3-12/shared-libs/rules-engine/src/rules-emitter */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/src/rules-emitter.js"),
+ nootils: __webpack_require__(/*! cht-core-3-12/shared-libs/rules-engine/node_modules/medic-nootils */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/medic-nootils/src/nootils.js"),
+ Lineage: __webpack_require__(/*! cht-core-3-12/shared-libs/lineage */ "./node_modules/cht-core-3-12/shared-libs/lineage/src/index.js"),
+ ChtScriptApi: __webpack_require__(/*! cht-core-3-12/shared-libs/cht-script-api */ "./node_modules/cht-core-3-12/shared-libs/cht-script-api/src/index.js"),
+ },
};
@@ -48,7 +58,7 @@ module.exports = {
/***/ ((module) => {
"use strict";
-module.exports = JSON.parse('[{"views":{"contacts_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_parent":{"map":"function(doc) {\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n var parentId = doc.parent && doc.parent._id;\\n var type = doc.type === \'contact\' ? doc.contact_type : doc.type;\\n if (parentId) {\\n emit([parentId, type]);\\n }\\n }\\n}"},"contacts_by_last_visited":{"reduce":"_stats","map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n if (typeof date !== \'number\' || isNaN(date)) {\\n date = 0;\\n }\\n // Is a visit report about a family\\n emit(doc.fields.visited_contact_uuid, date);\\n } else if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n // Is a contact type\\n emit(doc._id, 0);\\n }\\n}"},"contacts_by_type_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(type, key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([ type, key ], value);\\n }\\n };\\n\\n var emitField = function(type, key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(type, word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(type, key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(type, key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_place":{"map":"function(doc) {\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n if (idx !== -1) {\\n var place = doc.parent;\\n var order = idx + \' \' + (doc.name && doc.name.toLowerCase());\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], order);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"contacts_by_reference":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'national_office\' ||\\n doc.type === \'person\') {\\n\\n var emitReference = function(prefix, key) {\\n if (tombstone) {\\n prefix = \'tombstone-\' + prefix;\\n }\\n emit([ prefix, String(key) ], doc.reported_date);\\n };\\n\\n if (doc.place_id) {\\n emitReference(\'shortcode\', doc.place_id);\\n }\\n if (doc.patient_id) {\\n emitReference(\'shortcode\', doc.patient_id);\\n }\\n if (doc.simprints_id) {\\n emitReference(\'simprints\', doc.simprints_id);\\n }\\n if (doc.rc_code) {\\n // need String because rewriter wraps everything in quotes\\n // keep refid case-insenstive since data is usually coming from SMS\\n emitReference(\'external\', String(doc.rc_code).toUpperCase());\\n }\\n }\\n}"},"contacts_by_type":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (tombstone) {\\n type = \'tombstone-\' + type;\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n emit([ type ], order);\\n }\\n}"},"data_records_by_type":{"map":"function(doc) {\\n if (doc.type === \'data_record\') {\\n emit(doc.form ? \'report\' : \'message\');\\n }\\n}","reduce":"_count"},"doc_by_type":{"map":"function(doc) {\\n if (doc.type === \'translations\') {\\n emit([ \'translations\', doc.enabled ], {\\n code: doc.code,\\n name: doc.name\\n });\\n return;\\n }\\n emit([ doc.type ]);\\n}"},"messages_by_contact_date":{"map":"function(doc) {\\n\\n var emitMessage = function(doc, contact, phone) {\\n var id = (contact && contact._id) || phone || doc._id;\\n emit([ id, doc.reported_date ], {\\n id: doc._id,\\n date: doc.reported_date,\\n contact: contact && contact._id\\n });\\n };\\n\\n if (doc.type === \'data_record\' && !doc.form) {\\n if (doc.kujua_message && doc.tasks) {\\n // outgoing\\n doc.tasks.forEach(function(task) {\\n var message = task.messages && task.messages[0];\\n if(message) {\\n emitMessage(doc, message.contact, message.to);\\n }\\n });\\n } else if (doc.sms_message) {\\n // incoming\\n emitMessage(doc, doc.contact, doc.from);\\n }\\n }\\n}","reduce":"function(key, values) {\\n var latest = { date: 0 };\\n values.forEach(function(value) {\\n if (value.date > latest.date) {\\n latest = value;\\n }\\n });\\n return latest;\\n}"},"docs_by_id_lineage":{"map":"function(doc) {\\n\\n var emitLineage = function(contact, depth) {\\n while (contact && contact._id) {\\n emit([ doc._id, depth++ ], { _id: contact._id });\\n contact = contact.parent;\\n }\\n };\\n\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n\\n if (types.indexOf(doc.type) !== -1) {\\n // contact\\n emitLineage(doc, 0);\\n } else if (doc.type === \'data_record\' && doc.form) {\\n // report\\n emit([ doc._id, 0 ]);\\n emitLineage(doc.contact, 1);\\n }\\n}"},"registered_patients":{"map":"// NB: This returns *registrations* for patients. If patients are created by\\n// means other then sending in a registration report (eg created in the UI)\\n// they will not show up in this view.\\n//\\n// For a view with all patients by their shortcode, use:\\n// medic/patient_by_patient_shortcode_id\\nfunction(doc) {\\n var patientId = doc.patient_id || (doc.fields && doc.fields.patient_id);\\n if (doc.form &&\\n doc.type === \'data_record\' &&\\n (!doc.errors || doc.errors.length === 0) &&\\n patientId) {\\n emit(String(patientId));\\n }\\n}"},"reports_by_form_year_week_places":{"map":"// data record must adhere to property name of `week` or `week_number`\\nfunction(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.year &&\\n (doc.fields.week || doc.fields.week_number)) {\\n var year = parseInt(doc.fields.year, 10);\\n var week = parseInt(doc.fields.week || doc.fields.week_number, 10);\\n var clinic = doc.contact && doc.contact.parent;\\n var healthCenter = clinic && clinic.parent;\\n var district = healthCenter && healthCenter.parent;\\n emit(\\n [ doc.form, year, week ],\\n {\\n isValid: (doc.errors && doc.errors.length === 0),\\n clinicId: clinic && clinic._id,\\n healthCenterId: healthCenter && healthCenter._id,\\n districtId: district && district._id,\\n weekNumber: week\\n }\\n );\\n }\\n}"},"reports_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.reported_date], doc.reported_date);\\n }\\n}"},"reports_by_form_year_month_places":{"map":"// data record must adhere to property name of `month`\\nfunction(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.year &&\\n doc.fields.month) {\\n var year = parseInt(doc.fields.year, 10);\\n var month = parseInt(doc.fields.month, 10);\\n var clinic = doc.contact && doc.contact.parent;\\n var healthCenter = clinic && clinic.parent;\\n var district = healthCenter && healthCenter.parent;\\n emit(\\n [ doc.form, year, month ],\\n {\\n isValid: (doc.errors && doc.errors.length === 0),\\n clinicId: clinic && clinic._id,\\n healthCenterId: healthCenter && healthCenter._id,\\n districtId: district && district._id,\\n month: month\\n }\\n );\\n }\\n}"},"reports_by_form":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.form], doc.reported_date);\\n }\\n}","reduce":"function() {\\n return true;\\n}"},"reports_by_place":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var place = doc.contact && doc.contact.parent;\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], doc.reported_date);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"reports_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'content\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, reportedDate) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, reportedDate);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, reportedDate);\\n }\\n };\\n\\n if (doc.type === \'data_record\' && doc.form) {\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], doc.reported_date);\\n });\\n if (doc.fields) {\\n Object.keys(doc.fields).forEach(function(key) {\\n emitField(key, doc.fields[key], doc.reported_date);\\n });\\n }\\n if (doc.contact && doc.contact._id) {\\n emitMaybe(\'contact:\' + doc.contact._id.toLowerCase(), doc.reported_date);\\n }\\n }\\n}"},"reports_by_validity":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([!doc.errors || doc.errors.length === 0], doc.reported_date);\\n }\\n}"},"reports_by_verification":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.verified], doc.reported_date);\\n }\\n}"},"reports_by_subject":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var emitField = function(obj, field) {\\n if (obj[field]) {\\n emit(obj[field], doc.reported_date);\\n }\\n };\\n\\n emitField(doc, \'patient_id\');\\n emitField(doc, \'place_id\');\\n emitField(doc, \'case_id\');\\n\\n if (doc.fields) {\\n emitField(doc.fields, \'patient_id\');\\n emitField(doc.fields, \'place_id\');\\n emitField(doc.fields, \'case_id\');\\n emitField(doc.fields, \'patient_uuid\');\\n emitField(doc.fields, \'place_uuid\');\\n }\\n }\\n}"},"total_clinics_by_facility":{"map":"function(doc) {\\n var districtId = doc.parent && doc.parent.parent && doc.parent.parent._id;\\n if (doc.type === \'clinic\' || (doc.type === \'contact\' && districtId)) {\\n var healthCenterId = doc.parent && doc.parent._id;\\n emit([ districtId, healthCenterId, doc._id, 0 ]);\\n if (doc.contact && doc.contact._id) {\\n emit([ districtId, healthCenterId, doc._id, 1 ], { _id: doc.contact._id });\\n }\\n var index = 2;\\n var parent = doc.parent;\\n while(parent) {\\n if (parent._id) {\\n emit([ districtId, healthCenterId, doc._id, index++ ], { _id: parent._id });\\n }\\n parent = parent.parent;\\n }\\n }\\n}"},"tasks_by_contact":{"map":"function(doc) {\\n if (doc.type === \'task\') {\\n var isTerminalState = [\'Cancelled\', \'Completed\', \'Failed\'].indexOf(doc.state) >= 0;\\n if (!isTerminalState) {\\n emit(\'owner-\' + (doc.owner || \'_unassigned\'));\\n }\\n\\n if (doc.requester) {\\n emit(\'requester-\' + doc.requester);\\n }\\n }\\n}"},"visits_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var visited_date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n\\n // Is a visit report about a family\\n emit(visited_date, doc.fields.visited_contact_uuid);\\n }\\n}"},"contacts_by_phone":{"map":"function(doc) {\\n if (doc.phone) {\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n if (types.indexOf(doc.type) !== -1) {\\n emit(doc.phone);\\n }\\n }\\n}"}},"validate_doc_update":"function(newDoc, oldDoc, userCtx) {\\n /*\\n LOCAL DOCUMENT VALIDATION\\n\\n This is for validating document structure, irrespective of authority, so it\\n can be run both on couchdb and pouchdb (where you are technically admin).\\n\\n For validations around authority check lib/validate_doc_update.js, which is\\n only run on the server.\\n */\\n\\n var _err = function(msg) {\\n throw({ forbidden: msg });\\n };\\n\\n /**\\n * Ensure that type=\'form\' documents are created with correctly formatted _id\\n * property.\\n */\\n var validateForm = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var form_id = id_parts.slice(1).join(\':\');\\n if (prefix !== \'form\') {\\n _err(\'_id property must be prefixed with \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (!form_id) {\\n _err(\'_id property must define a value after \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id property must be lower case. e.g. \\"form:registration\\"\');\\n }\\n };\\n\\n var validateUserSettings = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var username = id_parts.slice(1).join(\':\');\\n var idExample = \' e.g. \\"org.couchdb.user:sally\\"\';\\n if (prefix !== \'org.couchdb.user\') {\\n _err(\'_id must be prefixed with \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (!username) {\\n _err(\'_id must define a value after \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id must be lower case.\' + idExample);\\n }\\n if (typeof newDoc.name === \'undefined\' || newDoc.name !== username) {\\n _err(\'name property must be equivalent to username.\' + idExample);\\n }\\n if (newDoc.name.toLowerCase() !== username.toLowerCase()) {\\n _err(\'name must be equivalent to username\');\\n }\\n if (typeof newDoc.known !== \'undefined\' && typeof newDoc.known !== \'boolean\') {\\n _err(\'known is not a boolean.\');\\n }\\n if (typeof newDoc.roles !== \'object\') {\\n _err(\'roles is a required array\');\\n }\\n };\\n\\n if (userCtx.facility_id === newDoc._id) {\\n _err(\'You are not authorized to edit your own place\');\\n }\\n if (newDoc.type === \'form\') {\\n validateForm(newDoc);\\n }\\n if (newDoc.type === \'user-settings\') {\\n validateUserSettings(newDoc);\\n }\\n\\n log(\\n \'medic-client validate_doc_update passed for User \\"\' + userCtx.name +\\n \'\\" changing document \\"\' + newDoc._id + \'\\"\'\\n );\\n}","_id":"_design/medic-client"}]');
+module.exports = JSON.parse('[{"_id":"_design/medic-client","validate_doc_update":"function(newDoc, oldDoc, userCtx) {\\n /*\\n LOCAL DOCUMENT VALIDATION\\n\\n This is for validating document structure, irrespective of authority, so it\\n can be run both on couchdb and pouchdb (where you are technically admin).\\n\\n For validations around authority check lib/validate_doc_update.js, which is\\n only run on the server.\\n */\\n\\n var _err = function(msg) {\\n throw({ forbidden: msg });\\n };\\n\\n /**\\n * Ensure that type=\'form\' documents are created with correctly formatted _id\\n * property.\\n */\\n var validateForm = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var form_id = id_parts.slice(1).join(\':\');\\n if (prefix !== \'form\') {\\n _err(\'_id property must be prefixed with \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (!form_id) {\\n _err(\'_id property must define a value after \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id property must be lower case. e.g. \\"form:registration\\"\');\\n }\\n };\\n\\n var validateUserSettings = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var username = id_parts.slice(1).join(\':\');\\n var idExample = \' e.g. \\"org.couchdb.user:sally\\"\';\\n if (prefix !== \'org.couchdb.user\') {\\n _err(\'_id must be prefixed with \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (!username) {\\n _err(\'_id must define a value after \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id must be lower case.\' + idExample);\\n }\\n if (typeof newDoc.name === \'undefined\' || newDoc.name !== username) {\\n _err(\'name property must be equivalent to username.\' + idExample);\\n }\\n if (newDoc.name.toLowerCase() !== username.toLowerCase()) {\\n _err(\'name must be equivalent to username\');\\n }\\n if (typeof newDoc.known !== \'undefined\' && typeof newDoc.known !== \'boolean\') {\\n _err(\'known is not a boolean.\');\\n }\\n if (typeof newDoc.roles !== \'object\') {\\n _err(\'roles is a required array\');\\n }\\n };\\n\\n if (userCtx.facility_id === newDoc._id) {\\n _err(\'You are not authorized to edit your own place\');\\n }\\n if (newDoc.type === \'form\') {\\n validateForm(newDoc);\\n }\\n if (newDoc.type === \'user-settings\') {\\n validateUserSettings(newDoc);\\n }\\n\\n log(\\n \'medic-client validate_doc_update passed for User \\"\' + userCtx.name +\\n \'\\" changing document \\"\' + newDoc._id + \'\\"\'\\n );\\n}","views":{"contacts_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_last_visited":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n if (typeof date !== \'number\' || isNaN(date)) {\\n date = 0;\\n }\\n // Is a visit report about a family\\n emit(doc.fields.visited_contact_uuid, date);\\n } else if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n // Is a contact type\\n emit(doc._id, 0);\\n }\\n}","reduce":"_stats"},"contacts_by_parent":{"map":"function(doc) {\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n var parentId = doc.parent && doc.parent._id;\\n var type = doc.type === \'contact\' ? doc.contact_type : doc.type;\\n if (parentId) {\\n emit([parentId, type]);\\n }\\n }\\n}"},"contacts_by_phone":{"map":"function(doc) {\\n if (doc.phone) {\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n if (types.indexOf(doc.type) !== -1) {\\n emit(doc.phone);\\n }\\n }\\n}"},"contacts_by_place":{"map":"function(doc) {\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n if (idx !== -1) {\\n var place = doc.parent;\\n var order = idx + \' \' + (doc.name && doc.name.toLowerCase());\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], order);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"contacts_by_reference":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'national_office\' ||\\n doc.type === \'person\') {\\n\\n var emitReference = function(prefix, key) {\\n if (tombstone) {\\n prefix = \'tombstone-\' + prefix;\\n }\\n emit([ prefix, String(key) ], doc.reported_date);\\n };\\n\\n if (doc.place_id) {\\n emitReference(\'shortcode\', doc.place_id);\\n }\\n if (doc.patient_id) {\\n emitReference(\'shortcode\', doc.patient_id);\\n }\\n if (doc.simprints_id) {\\n emitReference(\'simprints\', doc.simprints_id);\\n }\\n if (doc.rc_code) {\\n // need String because rewriter wraps everything in quotes\\n // keep refid case-insenstive since data is usually coming from SMS\\n emitReference(\'external\', String(doc.rc_code).toUpperCase());\\n }\\n }\\n}"},"contacts_by_type":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (tombstone) {\\n type = \'tombstone-\' + type;\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n emit([ type ], order);\\n }\\n}"},"contacts_by_type_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(type, key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([ type, key ], value);\\n }\\n };\\n\\n var emitField = function(type, key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(type, word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(type, key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(type, key, doc[key], order);\\n });\\n }\\n}"},"data_records_by_type":{"map":"function(doc) {\\n if (doc.type === \'data_record\') {\\n emit(doc.form ? \'report\' : \'message\');\\n }\\n}","reduce":"_count"},"doc_by_type":{"map":"function(doc) {\\n if (doc.type === \'translations\') {\\n emit([ \'translations\', doc.enabled ], {\\n code: doc.code,\\n name: doc.name\\n });\\n return;\\n }\\n emit([ doc.type ]);\\n}"},"docs_by_id_lineage":{"map":"function(doc) {\\n\\n var emitLineage = function(contact, depth) {\\n while (contact && contact._id) {\\n emit([ doc._id, depth++ ], { _id: contact._id });\\n contact = contact.parent;\\n }\\n };\\n\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n\\n if (types.indexOf(doc.type) !== -1) {\\n // contact\\n emitLineage(doc, 0);\\n } else if (doc.type === \'data_record\' && doc.form) {\\n // report\\n emit([ doc._id, 0 ]);\\n emitLineage(doc.contact, 1);\\n }\\n}"},"messages_by_contact_date":{"map":"function(doc) {\\n\\n var emitMessage = function(doc, contact, phone) {\\n var id = (contact && contact._id) || phone || doc._id;\\n emit([ id, doc.reported_date ], {\\n id: doc._id,\\n date: doc.reported_date,\\n contact: contact && contact._id\\n });\\n };\\n\\n if (doc.type === \'data_record\' && !doc.form) {\\n if (doc.kujua_message && doc.tasks) {\\n // outgoing\\n doc.tasks.forEach(function(task) {\\n var message = task.messages && task.messages[0];\\n if(message) {\\n emitMessage(doc, message.contact, message.to);\\n }\\n });\\n } else if (doc.sms_message) {\\n // incoming\\n emitMessage(doc, doc.contact, doc.from);\\n }\\n }\\n}","reduce":"function(key, values) {\\n var latest = { date: 0 };\\n values.forEach(function(value) {\\n if (value.date > latest.date) {\\n latest = value;\\n }\\n });\\n return latest;\\n}"},"registered_patients":{"map":"// NB: This returns *registrations* for patients. If patients are created by\\n// means other then sending in a registration report (eg created in the UI)\\n// they will not show up in this view.\\n//\\n// For a view with all patients by their shortcode, use:\\n// medic/patient_by_patient_shortcode_id\\nfunction(doc) {\\n var patientId = doc.patient_id || (doc.fields && doc.fields.patient_id);\\n if (doc.form &&\\n doc.type === \'data_record\' &&\\n (!doc.errors || doc.errors.length === 0) &&\\n patientId) {\\n emit(String(patientId));\\n }\\n}"},"reports_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.reported_date], doc.reported_date);\\n }\\n}"},"reports_by_form_year_month_places":{"map":"// data record must adhere to property name of `month`\\nfunction(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.year &&\\n doc.fields.month) {\\n var year = parseInt(doc.fields.year, 10);\\n var month = parseInt(doc.fields.month, 10);\\n var clinic = doc.contact && doc.contact.parent;\\n var healthCenter = clinic && clinic.parent;\\n var district = healthCenter && healthCenter.parent;\\n emit(\\n [ doc.form, year, month ],\\n {\\n isValid: (doc.errors && doc.errors.length === 0),\\n clinicId: clinic && clinic._id,\\n healthCenterId: healthCenter && healthCenter._id,\\n districtId: district && district._id,\\n month: month\\n }\\n );\\n }\\n}"},"reports_by_form_year_week_places":{"map":"// data record must adhere to property name of `week` or `week_number`\\nfunction(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.year &&\\n (doc.fields.week || doc.fields.week_number)) {\\n var year = parseInt(doc.fields.year, 10);\\n var week = parseInt(doc.fields.week || doc.fields.week_number, 10);\\n var clinic = doc.contact && doc.contact.parent;\\n var healthCenter = clinic && clinic.parent;\\n var district = healthCenter && healthCenter.parent;\\n emit(\\n [ doc.form, year, week ],\\n {\\n isValid: (doc.errors && doc.errors.length === 0),\\n clinicId: clinic && clinic._id,\\n healthCenterId: healthCenter && healthCenter._id,\\n districtId: district && district._id,\\n weekNumber: week\\n }\\n );\\n }\\n}"},"reports_by_form":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.form], doc.reported_date);\\n }\\n}","reduce":"function() {\\n return true;\\n}"},"reports_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'content\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, reportedDate) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, reportedDate);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, reportedDate);\\n }\\n };\\n\\n if (doc.type === \'data_record\' && doc.form) {\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], doc.reported_date);\\n });\\n if (doc.fields) {\\n Object.keys(doc.fields).forEach(function(key) {\\n emitField(key, doc.fields[key], doc.reported_date);\\n });\\n }\\n if (doc.contact && doc.contact._id) {\\n emitMaybe(\'contact:\' + doc.contact._id.toLowerCase(), doc.reported_date);\\n }\\n }\\n}"},"reports_by_place":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var place = doc.contact && doc.contact.parent;\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], doc.reported_date);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"reports_by_subject":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var emitField = function(obj, field) {\\n if (obj[field]) {\\n emit(obj[field], doc.reported_date);\\n }\\n };\\n\\n emitField(doc, \'patient_id\');\\n emitField(doc, \'place_id\');\\n emitField(doc, \'case_id\');\\n\\n if (doc.fields) {\\n emitField(doc.fields, \'patient_id\');\\n emitField(doc.fields, \'place_id\');\\n emitField(doc.fields, \'case_id\');\\n emitField(doc.fields, \'patient_uuid\');\\n emitField(doc.fields, \'place_uuid\');\\n }\\n }\\n}"},"reports_by_validity":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([!doc.errors || doc.errors.length === 0], doc.reported_date);\\n }\\n}"},"reports_by_verification":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.verified], doc.reported_date);\\n }\\n}"},"tasks_by_contact":{"map":"function(doc) {\\n if (doc.type === \'task\') {\\n var isTerminalState = [\'Cancelled\', \'Completed\', \'Failed\'].indexOf(doc.state) >= 0;\\n if (!isTerminalState) {\\n emit(\'owner-\' + (doc.owner || \'_unassigned\'));\\n }\\n\\n if (doc.requester) {\\n emit(\'requester-\' + doc.requester);\\n }\\n }\\n}"},"total_clinics_by_facility":{"map":"function(doc) {\\n var districtId = doc.parent && doc.parent.parent && doc.parent.parent._id;\\n if (doc.type === \'clinic\' || (doc.type === \'contact\' && districtId)) {\\n var healthCenterId = doc.parent && doc.parent._id;\\n emit([ districtId, healthCenterId, doc._id, 0 ]);\\n if (doc.contact && doc.contact._id) {\\n emit([ districtId, healthCenterId, doc._id, 1 ], { _id: doc.contact._id });\\n }\\n var index = 2;\\n var parent = doc.parent;\\n while(parent) {\\n if (parent._id) {\\n emit([ districtId, healthCenterId, doc._id, index++ ], { _id: parent._id });\\n }\\n parent = parent.parent;\\n }\\n }\\n}"},"visits_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var visited_date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n\\n // Is a visit report about a family\\n emit(visited_date, doc.fields.visited_contact_uuid);\\n }\\n}"}}}]');
/***/ }),
@@ -59,7 +69,18 @@ module.exports = JSON.parse('[{"views":{"contacts_by_freetext":{"map":"function(
/***/ ((module) => {
"use strict";
-module.exports = JSON.parse('[{"validate_doc_update":"function(newDoc, oldDoc, userCtx) {\\n /*\\n LOCAL DOCUMENT VALIDATION\\n\\n This is for validating document structure, irrespective of authority, so it\\n can be run both on couchdb and pouchdb (where you are technically admin).\\n\\n For validations around authority check lib/validate_doc_update.js, which is\\n only run on the server.\\n */\\n\\n var _err = function(msg) {\\n throw({ forbidden: msg });\\n };\\n\\n /**\\n * Ensure that type=\'form\' documents are created with correctly formatted _id\\n * property.\\n */\\n var validateForm = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var form_id = id_parts.slice(1).join(\':\');\\n if (prefix !== \'form\') {\\n _err(\'_id property must be prefixed with \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (!form_id) {\\n _err(\'_id property must define a value after \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id property must be lower case. e.g. \\"form:registration\\"\');\\n }\\n };\\n\\n var validateUserSettings = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var username = id_parts.slice(1).join(\':\');\\n var idExample = \' e.g. \\"org.couchdb.user:sally\\"\';\\n if (prefix !== \'org.couchdb.user\') {\\n _err(\'_id must be prefixed with \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (!username) {\\n _err(\'_id must define a value after \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id must be lower case.\' + idExample);\\n }\\n if (typeof newDoc.name === \'undefined\' || newDoc.name !== username) {\\n _err(\'name property must be equivalent to username.\' + idExample);\\n }\\n if (newDoc.name.toLowerCase() !== username.toLowerCase()) {\\n _err(\'name must be equivalent to username\');\\n }\\n if (typeof newDoc.known !== \'undefined\' && typeof newDoc.known !== \'boolean\') {\\n _err(\'known is not a boolean.\');\\n }\\n if (typeof newDoc.roles !== \'object\') {\\n _err(\'roles is a required array\');\\n }\\n };\\n\\n if (userCtx.facility_id === newDoc._id) {\\n _err(\'You are not authorized to edit your own place\');\\n }\\n if (newDoc.type === \'form\') {\\n validateForm(newDoc);\\n }\\n if (newDoc.type === \'user-settings\') {\\n validateUserSettings(newDoc);\\n }\\n\\n log(\\n \'medic-client validate_doc_update passed for User \\"\' + userCtx.name +\\n \'\\" changing document \\"\' + newDoc._id + \'\\"\'\\n );\\n}","_id":"_design/medic-client","views":{"contacts_by_last_visited":{"reduce":"_stats","map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n if (typeof date !== \'number\' || isNaN(date)) {\\n date = 0;\\n }\\n // Is a visit report about a family\\n emit(doc.fields.visited_contact_uuid, date);\\n } else if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n // Is a contact type\\n emit(doc._id, 0);\\n }\\n}"},"contacts_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_reference":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'national_office\' ||\\n doc.type === \'person\') {\\n\\n var emitReference = function(prefix, key) {\\n if (tombstone) {\\n prefix = \'tombstone-\' + prefix;\\n }\\n emit([ prefix, String(key) ], doc.reported_date);\\n };\\n\\n if (doc.place_id) {\\n emitReference(\'shortcode\', doc.place_id);\\n }\\n if (doc.patient_id) {\\n emitReference(\'shortcode\', doc.patient_id);\\n }\\n if (doc.simprints_id) {\\n emitReference(\'simprints\', doc.simprints_id);\\n }\\n if (doc.rc_code) {\\n // need String because rewriter wraps everything in quotes\\n // keep refid case-insenstive since data is usually coming from SMS\\n emitReference(\'external\', String(doc.rc_code).toUpperCase());\\n }\\n }\\n}"},"contacts_by_parent":{"map":"function(doc) {\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n var parentId = doc.parent && doc.parent._id;\\n var type = doc.type === \'contact\' ? doc.contact_type : doc.type;\\n if (parentId) {\\n emit([parentId, type]);\\n }\\n }\\n}"},"contacts_by_place":{"map":"function(doc) {\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n if (idx !== -1) {\\n var place = doc.parent;\\n var order = idx + \' \' + (doc.name && doc.name.toLowerCase());\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], order);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"contacts_by_phone":{"map":"function(doc) {\\n if (doc.phone) {\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n if (types.indexOf(doc.type) !== -1) {\\n emit(doc.phone);\\n }\\n }\\n}"},"contacts_by_type_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(type, key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([ type, key ], value);\\n }\\n };\\n\\n var emitField = function(type, key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(type, word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(type, key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(type, key, doc[key], order);\\n });\\n }\\n}"},"data_records_by_type":{"reduce":"_count","map":"function(doc) {\\n if (doc.type === \'data_record\') {\\n emit(doc.form ? \'report\' : \'message\');\\n }\\n}"},"contacts_by_type":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (tombstone) {\\n type = \'tombstone-\' + type;\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n emit([ type ], order);\\n }\\n}"},"docs_by_id_lineage":{"map":"function(doc) {\\n\\n var emitLineage = function(contact, depth) {\\n while (contact && contact._id) {\\n emit([ doc._id, depth++ ], { _id: contact._id });\\n contact = contact.parent;\\n }\\n };\\n\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n\\n if (types.indexOf(doc.type) !== -1) {\\n // contact\\n emitLineage(doc, 0);\\n } else if (doc.type === \'data_record\' && doc.form) {\\n // report\\n emit([ doc._id, 0 ]);\\n emitLineage(doc.contact, 1);\\n }\\n}"},"doc_by_type":{"map":"function(doc) {\\n if (doc.type === \'translations\') {\\n emit([ \'translations\', doc.enabled ], {\\n code: doc.code,\\n name: doc.name\\n });\\n return;\\n }\\n emit([ doc.type ]);\\n}"},"messages_by_contact_date":{"map":"function(doc) {\\n\\n var emitMessage = function(doc, contact, phone) {\\n var id = (contact && contact._id) || phone || doc._id;\\n emit([ id, doc.reported_date ], {\\n id: doc._id,\\n date: doc.reported_date,\\n contact: contact && contact._id\\n });\\n };\\n\\n if (doc.type === \'data_record\' && !doc.form) {\\n if (doc.kujua_message && doc.tasks) {\\n // outgoing\\n doc.tasks.forEach(function(task) {\\n var message = task.messages && task.messages[0];\\n if(message) {\\n emitMessage(doc, message.contact, message.to);\\n }\\n });\\n } else if (doc.sms_message) {\\n // incoming\\n emitMessage(doc, doc.contact, doc.from);\\n }\\n }\\n}","reduce":"function(key, values) {\\n var latest = { date: 0 };\\n values.forEach(function(value) {\\n if (value.date > latest.date) {\\n latest = value;\\n }\\n });\\n return latest;\\n}"},"registered_patients":{"map":"// NB: This returns *registrations* for contacts. If contacts are created by\\n// means other then sending in a registration report (eg created in the UI)\\n// they will not show up in this view.\\n//\\n// For a view with all patients by their shortcode, use:\\n// medic/docs_by_shortcode\\nfunction(doc) {\\n var patientId = doc.patient_id || (doc.fields && doc.fields.patient_id);\\n var placeId = doc.place_id || (doc.fields && doc.fields.place_id);\\n\\n if (!doc.form || doc.type !== \'data_record\' || (doc.errors && doc.errors.length)) {\\n return;\\n }\\n\\n if (patientId) {\\n emit(String(patientId));\\n }\\n\\n if (placeId) {\\n emit(String(placeId));\\n }\\n}"},"reports_by_form":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.form], doc.reported_date);\\n }\\n}","reduce":"function() {\\n return true;\\n}"},"reports_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.reported_date], doc.reported_date);\\n }\\n}"},"reports_by_place":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var place = doc.contact && doc.contact.parent;\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], doc.reported_date);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"reports_by_subject":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var emitField = function(obj, field) {\\n if (obj[field]) {\\n emit(obj[field], doc.reported_date);\\n }\\n };\\n\\n emitField(doc, \'patient_id\');\\n emitField(doc, \'place_id\');\\n emitField(doc, \'case_id\');\\n\\n if (doc.fields) {\\n emitField(doc.fields, \'patient_id\');\\n emitField(doc.fields, \'place_id\');\\n emitField(doc.fields, \'case_id\');\\n emitField(doc.fields, \'patient_uuid\');\\n emitField(doc.fields, \'place_uuid\');\\n }\\n }\\n}"},"reports_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'content\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, reportedDate) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, reportedDate);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, reportedDate);\\n }\\n };\\n\\n if (doc.type === \'data_record\' && doc.form) {\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], doc.reported_date);\\n });\\n if (doc.fields) {\\n Object.keys(doc.fields).forEach(function(key) {\\n emitField(key, doc.fields[key], doc.reported_date);\\n });\\n }\\n if (doc.contact && doc.contact._id) {\\n emitMaybe(\'contact:\' + doc.contact._id.toLowerCase(), doc.reported_date);\\n }\\n }\\n}"},"reports_by_validity":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([!doc.errors || doc.errors.length === 0], doc.reported_date);\\n }\\n}"},"visits_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var visited_date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n\\n // Is a visit report about a family\\n emit(visited_date, doc.fields.visited_contact_uuid);\\n }\\n}"},"tasks_by_contact":{"map":"function(doc) {\\n if (doc.type === \'task\') {\\n var isTerminalState = [\'Cancelled\', \'Completed\', \'Failed\'].indexOf(doc.state) >= 0;\\n if (!isTerminalState) {\\n emit(\'owner-\' + (doc.owner || \'_unassigned\'));\\n }\\n\\n if (doc.requester) {\\n emit(\'requester-\' + doc.requester);\\n }\\n }\\n}"},"reports_by_verification":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.verified], doc.reported_date);\\n }\\n}"},"total_clinics_by_facility":{"map":"function(doc) {\\n var districtId = doc.parent && doc.parent.parent && doc.parent.parent._id;\\n if (doc.type === \'clinic\' || (doc.type === \'contact\' && districtId)) {\\n var healthCenterId = doc.parent && doc.parent._id;\\n emit([ districtId, healthCenterId, doc._id, 0 ]);\\n if (doc.contact && doc.contact._id) {\\n emit([ districtId, healthCenterId, doc._id, 1 ], { _id: doc.contact._id });\\n }\\n var index = 2;\\n var parent = doc.parent;\\n while(parent) {\\n if (parent._id) {\\n emit([ districtId, healthCenterId, doc._id, index++ ], { _id: parent._id });\\n }\\n parent = parent.parent;\\n }\\n }\\n}"}}}]');
+module.exports = JSON.parse('[{"_id":"_design/medic-client","views":{"contacts_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_last_visited":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n if (typeof date !== \'number\' || isNaN(date)) {\\n date = 0;\\n }\\n // Is a visit report about a family\\n emit(doc.fields.visited_contact_uuid, date);\\n } else if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n // Is a contact type\\n emit(doc._id, 0);\\n }\\n}","reduce":"_stats"},"contacts_by_parent":{"map":"function(doc) {\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n var parentId = doc.parent && doc.parent._id;\\n var type = doc.type === \'contact\' ? doc.contact_type : doc.type;\\n if (parentId) {\\n emit([parentId, type]);\\n }\\n }\\n}"},"contacts_by_phone":{"map":"function(doc) {\\n if (doc.phone) {\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n if (types.indexOf(doc.type) !== -1) {\\n emit(doc.phone);\\n }\\n }\\n}"},"contacts_by_place":{"map":"function(doc) {\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n if (idx !== -1) {\\n var place = doc.parent;\\n var order = idx + \' \' + (doc.name && doc.name.toLowerCase());\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], order);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"contacts_by_reference":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'national_office\' ||\\n doc.type === \'person\') {\\n\\n var emitReference = function(prefix, key) {\\n if (tombstone) {\\n prefix = \'tombstone-\' + prefix;\\n }\\n emit([ prefix, String(key) ], doc.reported_date);\\n };\\n\\n if (doc.place_id) {\\n emitReference(\'shortcode\', doc.place_id);\\n }\\n if (doc.patient_id) {\\n emitReference(\'shortcode\', doc.patient_id);\\n }\\n if (doc.simprints_id) {\\n emitReference(\'simprints\', doc.simprints_id);\\n }\\n if (doc.rc_code) {\\n // need String because rewriter wraps everything in quotes\\n // keep refid case-insenstive since data is usually coming from SMS\\n emitReference(\'external\', String(doc.rc_code).toUpperCase());\\n }\\n }\\n}"},"contacts_by_type_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(type, key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([ type, key ], value);\\n }\\n };\\n\\n var emitField = function(type, key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(type, word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(type, key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(type, key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_type":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (tombstone) {\\n type = \'tombstone-\' + type;\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n emit([ type ], order);\\n }\\n}"},"data_records_by_type":{"map":"function(doc) {\\n if (doc.type === \'data_record\') {\\n emit(doc.form ? \'report\' : \'message\');\\n }\\n}","reduce":"_count"},"doc_by_type":{"map":"function(doc) {\\n if (doc.type === \'translations\') {\\n emit([ \'translations\', doc.enabled ], {\\n code: doc.code,\\n name: doc.name\\n });\\n return;\\n }\\n emit([ doc.type ]);\\n}"},"docs_by_id_lineage":{"map":"function(doc) {\\n\\n var emitLineage = function(contact, depth) {\\n while (contact && contact._id) {\\n emit([ doc._id, depth++ ], { _id: contact._id });\\n contact = contact.parent;\\n }\\n };\\n\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n\\n if (types.indexOf(doc.type) !== -1) {\\n // contact\\n emitLineage(doc, 0);\\n } else if (doc.type === \'data_record\' && doc.form) {\\n // report\\n emit([ doc._id, 0 ]);\\n emitLineage(doc.contact, 1);\\n }\\n}"},"messages_by_contact_date":{"map":"function(doc) {\\n\\n var emitMessage = function(doc, contact, phone) {\\n var id = (contact && contact._id) || phone || doc._id;\\n emit([ id, doc.reported_date ], {\\n id: doc._id,\\n date: doc.reported_date,\\n contact: contact && contact._id\\n });\\n };\\n\\n if (doc.type === \'data_record\' && !doc.form) {\\n if (doc.kujua_message && doc.tasks) {\\n // outgoing\\n doc.tasks.forEach(function(task) {\\n var message = task.messages && task.messages[0];\\n if(message) {\\n emitMessage(doc, message.contact, message.to);\\n }\\n });\\n } else if (doc.sms_message) {\\n // incoming\\n emitMessage(doc, doc.contact, doc.from);\\n }\\n }\\n}","reduce":"function(key, values) {\\n var latest = { date: 0 };\\n values.forEach(function(value) {\\n if (value.date > latest.date) {\\n latest = value;\\n }\\n });\\n return latest;\\n}"},"registered_patients":{"map":"// NB: This returns *registrations* for contacts. If contacts are created by\\n// means other then sending in a registration report (eg created in the UI)\\n// they will not show up in this view.\\n//\\n// For a view with all patients by their shortcode, use:\\n// medic/docs_by_shortcode\\nfunction(doc) {\\n var patientId = doc.patient_id || (doc.fields && doc.fields.patient_id);\\n var placeId = doc.place_id || (doc.fields && doc.fields.place_id);\\n\\n if (!doc.form || doc.type !== \'data_record\' || (doc.errors && doc.errors.length)) {\\n return;\\n }\\n\\n if (patientId) {\\n emit(String(patientId));\\n }\\n\\n if (placeId) {\\n emit(String(placeId));\\n }\\n}"},"reports_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.reported_date], doc.reported_date);\\n }\\n}"},"reports_by_form":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.form], doc.reported_date);\\n }\\n}","reduce":"function() {\\n return true;\\n}"},"reports_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'content\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, reportedDate) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, reportedDate);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, reportedDate);\\n }\\n };\\n\\n if (doc.type === \'data_record\' && doc.form) {\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], doc.reported_date);\\n });\\n if (doc.fields) {\\n Object.keys(doc.fields).forEach(function(key) {\\n emitField(key, doc.fields[key], doc.reported_date);\\n });\\n }\\n if (doc.contact && doc.contact._id) {\\n emitMaybe(\'contact:\' + doc.contact._id.toLowerCase(), doc.reported_date);\\n }\\n }\\n}"},"reports_by_place":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var place = doc.contact && doc.contact.parent;\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], doc.reported_date);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"reports_by_subject":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var emitField = function(obj, field) {\\n if (obj[field]) {\\n emit(obj[field], doc.reported_date);\\n }\\n };\\n\\n emitField(doc, \'patient_id\');\\n emitField(doc, \'place_id\');\\n emitField(doc, \'case_id\');\\n\\n if (doc.fields) {\\n emitField(doc.fields, \'patient_id\');\\n emitField(doc.fields, \'place_id\');\\n emitField(doc.fields, \'case_id\');\\n emitField(doc.fields, \'patient_uuid\');\\n emitField(doc.fields, \'place_uuid\');\\n }\\n }\\n}"},"reports_by_validity":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([!doc.errors || doc.errors.length === 0], doc.reported_date);\\n }\\n}"},"reports_by_verification":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.verified], doc.reported_date);\\n }\\n}"},"tasks_by_contact":{"map":"function(doc) {\\n if (doc.type === \'task\') {\\n var isTerminalState = [\'Cancelled\', \'Completed\', \'Failed\'].indexOf(doc.state) >= 0;\\n if (!isTerminalState) {\\n emit(\'owner-\' + (doc.owner || \'_unassigned\'));\\n }\\n\\n if (doc.requester) {\\n emit(\'requester-\' + doc.requester);\\n }\\n }\\n}"},"total_clinics_by_facility":{"map":"function(doc) {\\n var districtId = doc.parent && doc.parent.parent && doc.parent.parent._id;\\n if (doc.type === \'clinic\' || (doc.type === \'contact\' && districtId)) {\\n var healthCenterId = doc.parent && doc.parent._id;\\n emit([ districtId, healthCenterId, doc._id, 0 ]);\\n if (doc.contact && doc.contact._id) {\\n emit([ districtId, healthCenterId, doc._id, 1 ], { _id: doc.contact._id });\\n }\\n var index = 2;\\n var parent = doc.parent;\\n while(parent) {\\n if (parent._id) {\\n emit([ districtId, healthCenterId, doc._id, index++ ], { _id: parent._id });\\n }\\n parent = parent.parent;\\n }\\n }\\n}"},"visits_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var visited_date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n\\n // Is a visit report about a family\\n emit(visited_date, doc.fields.visited_contact_uuid);\\n }\\n}"}},"validate_doc_update":"function(newDoc, oldDoc, userCtx) {\\n /*\\n LOCAL DOCUMENT VALIDATION\\n\\n This is for validating document structure, irrespective of authority, so it\\n can be run both on couchdb and pouchdb (where you are technically admin).\\n\\n For validations around authority check lib/validate_doc_update.js, which is\\n only run on the server.\\n */\\n\\n var _err = function(msg) {\\n throw({ forbidden: msg });\\n };\\n\\n /**\\n * Ensure that type=\'form\' documents are created with correctly formatted _id\\n * property.\\n */\\n var validateForm = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var form_id = id_parts.slice(1).join(\':\');\\n if (prefix !== \'form\') {\\n _err(\'_id property must be prefixed with \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (!form_id) {\\n _err(\'_id property must define a value after \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id property must be lower case. e.g. \\"form:registration\\"\');\\n }\\n };\\n\\n var validateUserSettings = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var username = id_parts.slice(1).join(\':\');\\n var idExample = \' e.g. \\"org.couchdb.user:sally\\"\';\\n if (prefix !== \'org.couchdb.user\') {\\n _err(\'_id must be prefixed with \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (!username) {\\n _err(\'_id must define a value after \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id must be lower case.\' + idExample);\\n }\\n if (typeof newDoc.name === \'undefined\' || newDoc.name !== username) {\\n _err(\'name property must be equivalent to username.\' + idExample);\\n }\\n if (newDoc.name.toLowerCase() !== username.toLowerCase()) {\\n _err(\'name must be equivalent to username\');\\n }\\n if (typeof newDoc.known !== \'undefined\' && typeof newDoc.known !== \'boolean\') {\\n _err(\'known is not a boolean.\');\\n }\\n if (typeof newDoc.roles !== \'object\') {\\n _err(\'roles is a required array\');\\n }\\n };\\n\\n if (userCtx.facility_id === newDoc._id) {\\n _err(\'You are not authorized to edit your own place\');\\n }\\n if (newDoc.type === \'form\') {\\n validateForm(newDoc);\\n }\\n if (newDoc.type === \'user-settings\') {\\n validateUserSettings(newDoc);\\n }\\n\\n log(\\n \'medic-client validate_doc_update passed for User \\"\' + userCtx.name +\\n \'\\" changing document \\"\' + newDoc._id + \'\\"\'\\n );\\n}"}]');
+
+/***/ }),
+
+/***/ "./build/cht-core-3-12-ddocs.json":
+/*!****************************************!*\
+ !*** ./build/cht-core-3-12-ddocs.json ***!
+ \****************************************/
+/***/ ((module) => {
+
+"use strict";
+module.exports = JSON.parse('[{"_id":"_design/medic-client","validate_doc_update":"function(newDoc, oldDoc, userCtx) {\\n /*\\n LOCAL DOCUMENT VALIDATION\\n\\n This is for validating document structure, irrespective of authority, so it\\n can be run both on couchdb and pouchdb (where you are technically admin).\\n\\n For validations around authority check lib/validate_doc_update.js, which is\\n only run on the server.\\n */\\n\\n var _err = function(msg) {\\n throw({ forbidden: msg });\\n };\\n\\n /**\\n * Ensure that type=\'form\' documents are created with correctly formatted _id\\n * property.\\n */\\n var validateForm = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var form_id = id_parts.slice(1).join(\':\');\\n if (prefix !== \'form\') {\\n _err(\'_id property must be prefixed with \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (!form_id) {\\n _err(\'_id property must define a value after \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id property must be lower case. e.g. \\"form:registration\\"\');\\n }\\n };\\n\\n var validateUserSettings = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var username = id_parts.slice(1).join(\':\');\\n var idExample = \' e.g. \\"org.couchdb.user:sally\\"\';\\n if (prefix !== \'org.couchdb.user\') {\\n _err(\'_id must be prefixed with \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (!username) {\\n _err(\'_id must define a value after \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id must be lower case.\' + idExample);\\n }\\n if (typeof newDoc.name === \'undefined\' || newDoc.name !== username) {\\n _err(\'name property must be equivalent to username.\' + idExample);\\n }\\n if (newDoc.name.toLowerCase() !== username.toLowerCase()) {\\n _err(\'name must be equivalent to username\');\\n }\\n if (typeof newDoc.known !== \'undefined\' && typeof newDoc.known !== \'boolean\') {\\n _err(\'known is not a boolean.\');\\n }\\n if (typeof newDoc.roles !== \'object\') {\\n _err(\'roles is a required array\');\\n }\\n };\\n\\n if (userCtx.facility_id === newDoc._id) {\\n _err(\'You are not authorized to edit your own place\');\\n }\\n if (newDoc.type === \'form\') {\\n validateForm(newDoc);\\n }\\n if (newDoc.type === \'user-settings\') {\\n validateUserSettings(newDoc);\\n }\\n\\n log(\\n \'medic-client validate_doc_update passed for User \\"\' + userCtx.name +\\n \'\\" changing document \\"\' + newDoc._id + \'\\"\'\\n );\\n}","views":{"contacts_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_last_visited":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n if (typeof date !== \'number\' || isNaN(date)) {\\n date = 0;\\n }\\n // Is a visit report about a family\\n emit(doc.fields.visited_contact_uuid, date);\\n } else if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n // Is a contact type\\n emit(doc._id, 0);\\n }\\n}","reduce":"_stats"},"contacts_by_parent":{"map":"function(doc) {\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n var parentId = doc.parent && doc.parent._id;\\n var type = doc.type === \'contact\' ? doc.contact_type : doc.type;\\n if (parentId) {\\n emit([parentId, type]);\\n }\\n }\\n}"},"contacts_by_phone":{"map":"function(doc) {\\n if (doc.phone) {\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n if (types.indexOf(doc.type) !== -1) {\\n emit(doc.phone);\\n }\\n }\\n}"},"contacts_by_place":{"map":"function(doc) {\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n if (idx !== -1) {\\n var place = doc.parent;\\n var order = idx + \' \' + (doc.name && doc.name.toLowerCase());\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], order);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"contacts_by_reference":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'national_office\' ||\\n doc.type === \'person\') {\\n\\n var emitReference = function(prefix, key) {\\n if (tombstone) {\\n prefix = \'tombstone-\' + prefix;\\n }\\n emit([ prefix, String(key) ], doc.reported_date);\\n };\\n\\n if (doc.place_id) {\\n emitReference(\'shortcode\', doc.place_id);\\n }\\n if (doc.patient_id) {\\n emitReference(\'shortcode\', doc.patient_id);\\n }\\n if (doc.simprints_id) {\\n emitReference(\'simprints\', doc.simprints_id);\\n }\\n if (doc.rc_code) {\\n // need String because rewriter wraps everything in quotes\\n // keep refid case-insenstive since data is usually coming from SMS\\n emitReference(\'external\', String(doc.rc_code).toUpperCase());\\n }\\n }\\n}"},"contacts_by_type_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(type, key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([ type, key ], value);\\n }\\n };\\n\\n var emitField = function(type, key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(type, word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(type, key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(type, key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_type":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (tombstone) {\\n type = \'tombstone-\' + type;\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n emit([ type ], order);\\n }\\n}"},"data_records_by_type":{"reduce":"_count","map":"function(doc) {\\n if (doc.type === \'data_record\') {\\n emit(doc.form ? \'report\' : \'message\');\\n }\\n}"},"doc_by_type":{"map":"function(doc) {\\n if (doc.type === \'translations\') {\\n emit([ \'translations\', doc.enabled ], {\\n code: doc.code,\\n name: doc.name\\n });\\n return;\\n }\\n emit([ doc.type ]);\\n}"},"messages_by_contact_date":{"map":"function(doc) {\\n\\n var emitMessage = function(doc, contact, phone) {\\n var id = (contact && contact._id) || phone || doc._id;\\n emit([ id, doc.reported_date ], {\\n id: doc._id,\\n date: doc.reported_date,\\n contact: contact && contact._id\\n });\\n };\\n\\n if (doc.type === \'data_record\' && !doc.form) {\\n if (doc.kujua_message && doc.tasks) {\\n // outgoing\\n doc.tasks.forEach(function(task) {\\n var message = task.messages && task.messages[0];\\n if(message) {\\n emitMessage(doc, message.contact, message.to);\\n }\\n });\\n } else if (doc.sms_message) {\\n // incoming\\n emitMessage(doc, doc.contact, doc.from);\\n }\\n }\\n}","reduce":"function(key, values) {\\n var latest = { date: 0 };\\n values.forEach(function(value) {\\n if (value.date > latest.date) {\\n latest = value;\\n }\\n });\\n return latest;\\n}"},"docs_by_id_lineage":{"map":"function(doc) {\\n\\n var emitLineage = function(contact, depth) {\\n while (contact && contact._id) {\\n emit([ doc._id, depth++ ], { _id: contact._id });\\n contact = contact.parent;\\n }\\n };\\n\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n\\n if (types.indexOf(doc.type) !== -1) {\\n // contact\\n emitLineage(doc, 0);\\n } else if (doc.type === \'data_record\' && doc.form) {\\n // report\\n emit([ doc._id, 0 ]);\\n emitLineage(doc.contact, 1);\\n }\\n}"},"reports_by_form":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.form], doc.reported_date);\\n }\\n}","reduce":"function() {\\n return true;\\n}"},"registered_patients":{"map":"// NB: This returns *registrations* for contacts. If contacts are created by\\n// means other then sending in a registration report (eg created in the UI)\\n// they will not show up in this view.\\n//\\n// For a view with all patients by their shortcode, use:\\n// medic/docs_by_shortcode\\nfunction(doc) {\\n var patientId = doc.patient_id || (doc.fields && doc.fields.patient_id);\\n var placeId = doc.place_id || (doc.fields && doc.fields.place_id);\\n\\n if (!doc.form || doc.type !== \'data_record\' || (doc.errors && doc.errors.length)) {\\n return;\\n }\\n\\n if (patientId) {\\n emit(String(patientId));\\n }\\n\\n if (placeId) {\\n emit(String(placeId));\\n }\\n}"},"reports_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.reported_date], doc.reported_date);\\n }\\n}"},"reports_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'content\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, reportedDate) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, reportedDate);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, reportedDate);\\n }\\n };\\n\\n if (doc.type === \'data_record\' && doc.form) {\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], doc.reported_date);\\n });\\n if (doc.fields) {\\n Object.keys(doc.fields).forEach(function(key) {\\n emitField(key, doc.fields[key], doc.reported_date);\\n });\\n }\\n if (doc.contact && doc.contact._id) {\\n emitMaybe(\'contact:\' + doc.contact._id.toLowerCase(), doc.reported_date);\\n }\\n }\\n}"},"reports_by_place":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var place = doc.contact && doc.contact.parent;\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], doc.reported_date);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"reports_by_subject":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var emitField = function(obj, field) {\\n if (obj[field]) {\\n emit(obj[field], doc.reported_date);\\n }\\n };\\n\\n emitField(doc, \'patient_id\');\\n emitField(doc, \'place_id\');\\n emitField(doc, \'case_id\');\\n\\n if (doc.fields) {\\n emitField(doc.fields, \'patient_id\');\\n emitField(doc.fields, \'place_id\');\\n emitField(doc.fields, \'case_id\');\\n emitField(doc.fields, \'patient_uuid\');\\n emitField(doc.fields, \'place_uuid\');\\n }\\n }\\n}"},"reports_by_validity":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([!doc.errors || doc.errors.length === 0], doc.reported_date);\\n }\\n}"},"reports_by_verification":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.verified], doc.reported_date);\\n }\\n}"},"tasks_by_contact":{"map":"function(doc) {\\n if (doc.type === \'task\') {\\n var isTerminalState = [\'Cancelled\', \'Completed\', \'Failed\'].indexOf(doc.state) >= 0;\\n if (!isTerminalState) {\\n emit(\'owner-\' + (doc.owner || \'_unassigned\'));\\n }\\n\\n if (doc.requester) {\\n emit(\'requester-\' + doc.requester);\\n }\\n }\\n}"},"total_clinics_by_facility":{"map":"function(doc) {\\n var districtId = doc.parent && doc.parent.parent && doc.parent.parent._id;\\n if (doc.type === \'clinic\' || (doc.type === \'contact\' && districtId)) {\\n var healthCenterId = doc.parent && doc.parent._id;\\n emit([ districtId, healthCenterId, doc._id, 0 ]);\\n if (doc.contact && doc.contact._id) {\\n emit([ districtId, healthCenterId, doc._id, 1 ], { _id: doc.contact._id });\\n }\\n var index = 2;\\n var parent = doc.parent;\\n while(parent) {\\n if (parent._id) {\\n emit([ districtId, healthCenterId, doc._id, index++ ], { _id: parent._id });\\n }\\n parent = parent.parent;\\n }\\n }\\n}"},"visits_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var visited_date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n\\n // Is a visit report about a family\\n emit(visited_date, doc.fields.visited_contact_uuid);\\n emit([doc.fields.visited_contact_uuid, visited_date]);\\n }\\n}"}}}]');
/***/ }),
@@ -70,7 +91,7 @@ module.exports = JSON.parse('[{"validate_doc_update":"function(newDoc, oldDoc, u
/***/ ((module) => {
"use strict";
-module.exports = JSON.parse('[{"validate_doc_update":"function(newDoc, oldDoc, userCtx) {\\n /*\\n LOCAL DOCUMENT VALIDATION\\n\\n This is for validating document structure, irrespective of authority, so it\\n can be run both on couchdb and pouchdb (where you are technically admin).\\n\\n For validations around authority check lib/validate_doc_update.js, which is\\n only run on the server.\\n */\\n\\n var _err = function(msg) {\\n throw({ forbidden: msg });\\n };\\n\\n /**\\n * Ensure that type=\'form\' documents are created with correctly formatted _id\\n * property.\\n */\\n var validateForm = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var form_id = id_parts.slice(1).join(\':\');\\n if (prefix !== \'form\') {\\n _err(\'_id property must be prefixed with \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (!form_id) {\\n _err(\'_id property must define a value after \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id property must be lower case. e.g. \\"form:registration\\"\');\\n }\\n };\\n\\n var validateUserSettings = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var username = id_parts.slice(1).join(\':\');\\n var idExample = \' e.g. \\"org.couchdb.user:sally\\"\';\\n if (prefix !== \'org.couchdb.user\') {\\n _err(\'_id must be prefixed with \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (!username) {\\n _err(\'_id must define a value after \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id must be lower case.\' + idExample);\\n }\\n if (typeof newDoc.name === \'undefined\' || newDoc.name !== username) {\\n _err(\'name property must be equivalent to username.\' + idExample);\\n }\\n if (newDoc.name.toLowerCase() !== username.toLowerCase()) {\\n _err(\'name must be equivalent to username\');\\n }\\n if (typeof newDoc.known !== \'undefined\' && typeof newDoc.known !== \'boolean\') {\\n _err(\'known is not a boolean.\');\\n }\\n if (typeof newDoc.roles !== \'object\') {\\n _err(\'roles is a required array\');\\n }\\n };\\n\\n if (userCtx.facility_id === newDoc._id) {\\n _err(\'You are not authorized to edit your own place\');\\n }\\n if (newDoc.type === \'form\') {\\n validateForm(newDoc);\\n }\\n if (newDoc.type === \'user-settings\') {\\n validateUserSettings(newDoc);\\n }\\n\\n log(\\n \'medic-client validate_doc_update passed for User \\"\' + userCtx.name +\\n \'\\" changing document \\"\' + newDoc._id + \'\\"\'\\n );\\n}","_id":"_design/medic-client","views":{"contacts_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_last_visited":{"reduce":"_stats","map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n if (typeof date !== \'number\' || isNaN(date)) {\\n date = 0;\\n }\\n // Is a visit report about a family\\n emit(doc.fields.visited_contact_uuid, date);\\n } else if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n // Is a contact type\\n emit(doc._id, 0);\\n }\\n}"},"contacts_by_phone":{"map":"function(doc) {\\n if (doc.phone) {\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n if (types.indexOf(doc.type) !== -1) {\\n emit(doc.phone);\\n }\\n }\\n}"},"contacts_by_place":{"map":"function(doc) {\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n if (idx !== -1) {\\n var place = doc.parent;\\n var order = idx + \' \' + (doc.name && doc.name.toLowerCase());\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], order);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"contacts_by_reference":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'national_office\' ||\\n doc.type === \'person\') {\\n\\n var emitReference = function(prefix, key) {\\n if (tombstone) {\\n prefix = \'tombstone-\' + prefix;\\n }\\n emit([ prefix, String(key) ], doc.reported_date);\\n };\\n\\n if (doc.place_id) {\\n emitReference(\'shortcode\', doc.place_id);\\n }\\n if (doc.patient_id) {\\n emitReference(\'shortcode\', doc.patient_id);\\n }\\n if (doc.simprints_id) {\\n emitReference(\'simprints\', doc.simprints_id);\\n }\\n if (doc.rc_code) {\\n // need String because rewriter wraps everything in quotes\\n // keep refid case-insenstive since data is usually coming from SMS\\n emitReference(\'external\', String(doc.rc_code).toUpperCase());\\n }\\n }\\n}"},"contacts_by_parent":{"map":"function(doc) {\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n var parentId = doc.parent && doc.parent._id;\\n if (parentId) {\\n emit([parentId, doc.contact_type || doc.type]);\\n }\\n }\\n}"},"contacts_by_type_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(type, key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([ type, key ], value);\\n }\\n };\\n\\n var emitField = function(type, key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(type, word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(type, key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(type, key, doc[key], order);\\n });\\n }\\n}"},"data_records_by_type":{"reduce":"_count","map":"function(doc) {\\n if (doc.type === \'data_record\') {\\n emit(doc.form ? \'report\' : \'message\');\\n }\\n}"},"contacts_by_type":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (tombstone) {\\n type = \'tombstone-\' + type;\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n emit([ type ], order);\\n }\\n}"},"docs_by_id_lineage":{"map":"function(doc) {\\n\\n var emitLineage = function(contact, depth) {\\n while (contact && contact._id) {\\n emit([ doc._id, depth++ ], { _id: contact._id });\\n contact = contact.parent;\\n }\\n };\\n\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n\\n if (types.indexOf(doc.type) !== -1) {\\n // contact\\n emitLineage(doc, 0);\\n } else if (doc.type === \'data_record\' && doc.form) {\\n // report\\n emit([ doc._id, 0 ]);\\n emitLineage(doc.contact, 1);\\n }\\n}"},"messages_by_contact_date":{"map":"function(doc) {\\n\\n var emitMessage = function(doc, contact, phone) {\\n var id = (contact && contact._id) || phone || doc._id;\\n emit([ id, doc.reported_date ], {\\n id: doc._id,\\n date: doc.reported_date,\\n contact: contact && contact._id\\n });\\n };\\n\\n if (doc.type === \'data_record\' && !doc.form) {\\n if (doc.kujua_message && doc.tasks) {\\n // outgoing\\n doc.tasks.forEach(function(task) {\\n var message = task.messages && task.messages[0];\\n if(message) {\\n emitMessage(doc, message.contact, message.to);\\n }\\n });\\n } else if (doc.sms_message) {\\n // incoming\\n emitMessage(doc, doc.contact, doc.from);\\n }\\n }\\n}","reduce":"function(key, values) {\\n var latest = { date: 0 };\\n values.forEach(function(value) {\\n if (value.date > latest.date) {\\n latest = value;\\n }\\n });\\n return latest;\\n}"},"doc_by_type":{"map":"function(doc) {\\n if (doc.type === \'translations\') {\\n emit([ \'translations\', doc.enabled ], {\\n code: doc.code,\\n name: doc.name\\n });\\n return;\\n }\\n emit([ doc.type ]);\\n}"},"registered_patients":{"map":"// NB: This returns *registrations* for patients. If patients are created by\\n// means other then sending in a registration report (eg created in the UI)\\n// they will not show up in this view.\\n//\\n// For a view with all patients by their shortcode, use:\\n// medic/patient_by_patient_shortcode_id\\nfunction(doc) {\\n var patientId = doc.patient_id || (doc.fields && doc.fields.patient_id);\\n if (doc.form &&\\n doc.type === \'data_record\' &&\\n (!doc.errors || doc.errors.length === 0) &&\\n patientId) {\\n emit(String(patientId));\\n }\\n}"},"reports_by_form_year_month_places":{"map":"// data record must adhere to property name of `month`\\nfunction(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.year &&\\n doc.fields.month) {\\n var year = parseInt(doc.fields.year, 10);\\n var month = parseInt(doc.fields.month, 10);\\n var clinic = doc.contact && doc.contact.parent;\\n var healthCenter = clinic && clinic.parent;\\n var district = healthCenter && healthCenter.parent;\\n emit(\\n [ doc.form, year, month ],\\n {\\n isValid: (doc.errors && doc.errors.length === 0),\\n clinicId: clinic && clinic._id,\\n healthCenterId: healthCenter && healthCenter._id,\\n districtId: district && district._id,\\n month: month\\n }\\n );\\n }\\n}"},"reports_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.reported_date], doc.reported_date);\\n }\\n}"},"reports_by_form_year_week_places":{"map":"// data record must adhere to property name of `week` or `week_number`\\nfunction(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.year &&\\n (doc.fields.week || doc.fields.week_number)) {\\n var year = parseInt(doc.fields.year, 10);\\n var week = parseInt(doc.fields.week || doc.fields.week_number, 10);\\n var clinic = doc.contact && doc.contact.parent;\\n var healthCenter = clinic && clinic.parent;\\n var district = healthCenter && healthCenter.parent;\\n emit(\\n [ doc.form, year, week ],\\n {\\n isValid: (doc.errors && doc.errors.length === 0),\\n clinicId: clinic && clinic._id,\\n healthCenterId: healthCenter && healthCenter._id,\\n districtId: district && district._id,\\n weekNumber: week\\n }\\n );\\n }\\n}"},"reports_by_form":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.form], doc.reported_date);\\n }\\n}","reduce":"function() {\\n return true;\\n}"},"reports_by_subject":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var emitField = function(obj, field) {\\n if (obj[field]) {\\n emit(obj[field], doc.reported_date);\\n }\\n };\\n\\n emitField(doc, \'patient_id\');\\n emitField(doc, \'place_id\');\\n emitField(doc, \'case_id\');\\n\\n if (doc.fields) {\\n emitField(doc.fields, \'patient_id\');\\n emitField(doc.fields, \'place_id\');\\n emitField(doc.fields, \'case_id\');\\n emitField(doc.fields, \'patient_uuid\');\\n emitField(doc.fields, \'place_uuid\');\\n }\\n }\\n}"},"reports_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'content\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, reportedDate) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, reportedDate);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, reportedDate);\\n }\\n };\\n\\n if (doc.type === \'data_record\' && doc.form) {\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], doc.reported_date);\\n });\\n if (doc.fields) {\\n Object.keys(doc.fields).forEach(function(key) {\\n emitField(key, doc.fields[key], doc.reported_date);\\n });\\n }\\n if (doc.contact && doc.contact._id) {\\n emitMaybe(\'contact:\' + doc.contact._id.toLowerCase(), doc.reported_date);\\n }\\n }\\n}"},"reports_by_validity":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([!doc.errors || doc.errors.length === 0], doc.reported_date);\\n }\\n}"},"reports_by_verification":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.verified], doc.reported_date);\\n }\\n}"},"tasks_by_contact":{"map":"function(doc) {\\n if (doc.type === \'task\') {\\n var isTerminalState = [\'Cancelled\', \'Completed\', \'Failed\'].indexOf(doc.state) >= 0;\\n if (!isTerminalState) {\\n emit(\'owner-\' + (doc.owner || \'_unassigned\'));\\n }\\n\\n if (doc.requester) {\\n emit(\'requester-\' + doc.requester);\\n }\\n }\\n}"},"reports_by_place":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var place = doc.contact && doc.contact.parent;\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], doc.reported_date);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"total_clinics_by_facility":{"map":"function(doc) {\\n var districtId = doc.parent && doc.parent.parent && doc.parent.parent._id;\\n if (doc.type === \'clinic\' || (doc.type === \'contact\' && districtId)) {\\n var healthCenterId = doc.parent && doc.parent._id;\\n emit([ districtId, healthCenterId, doc._id, 0 ]);\\n if (doc.contact && doc.contact._id) {\\n emit([ districtId, healthCenterId, doc._id, 1 ], { _id: doc.contact._id });\\n }\\n var index = 2;\\n var parent = doc.parent;\\n while(parent) {\\n if (parent._id) {\\n emit([ districtId, healthCenterId, doc._id, index++ ], { _id: parent._id });\\n }\\n parent = parent.parent;\\n }\\n }\\n}"},"visits_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var visited_date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n\\n // Is a visit report about a family\\n emit(visited_date, doc.fields.visited_contact_uuid);\\n }\\n}"}}}]');
+module.exports = JSON.parse('[{"validate_doc_update":"function(newDoc, oldDoc, userCtx) {\\n /*\\n LOCAL DOCUMENT VALIDATION\\n\\n This is for validating document structure, irrespective of authority, so it\\n can be run both on couchdb and pouchdb (where you are technically admin).\\n\\n For validations around authority check lib/validate_doc_update.js, which is\\n only run on the server.\\n */\\n\\n var _err = function(msg) {\\n throw({ forbidden: msg });\\n };\\n\\n /**\\n * Ensure that type=\'form\' documents are created with correctly formatted _id\\n * property.\\n */\\n var validateForm = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var form_id = id_parts.slice(1).join(\':\');\\n if (prefix !== \'form\') {\\n _err(\'_id property must be prefixed with \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (!form_id) {\\n _err(\'_id property must define a value after \\"form:\\". e.g. \\"form:registration\\"\');\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id property must be lower case. e.g. \\"form:registration\\"\');\\n }\\n };\\n\\n var validateUserSettings = function(newDoc) {\\n var id_parts = newDoc._id.split(\':\');\\n var prefix = id_parts[0];\\n var username = id_parts.slice(1).join(\':\');\\n var idExample = \' e.g. \\"org.couchdb.user:sally\\"\';\\n if (prefix !== \'org.couchdb.user\') {\\n _err(\'_id must be prefixed with \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (!username) {\\n _err(\'_id must define a value after \\"org.couchdb.user:\\".\' + idExample);\\n }\\n if (newDoc._id !== newDoc._id.toLowerCase()) {\\n _err(\'_id must be lower case.\' + idExample);\\n }\\n if (typeof newDoc.name === \'undefined\' || newDoc.name !== username) {\\n _err(\'name property must be equivalent to username.\' + idExample);\\n }\\n if (newDoc.name.toLowerCase() !== username.toLowerCase()) {\\n _err(\'name must be equivalent to username\');\\n }\\n if (typeof newDoc.known !== \'undefined\' && typeof newDoc.known !== \'boolean\') {\\n _err(\'known is not a boolean.\');\\n }\\n if (typeof newDoc.roles !== \'object\') {\\n _err(\'roles is a required array\');\\n }\\n };\\n\\n if (userCtx.facility_id === newDoc._id) {\\n _err(\'You are not authorized to edit your own place\');\\n }\\n if (newDoc.type === \'form\') {\\n validateForm(newDoc);\\n }\\n if (newDoc.type === \'user-settings\') {\\n validateUserSettings(newDoc);\\n }\\n\\n log(\\n \'medic-client validate_doc_update passed for User \\"\' + userCtx.name +\\n \'\\" changing document \\"\' + newDoc._id + \'\\"\'\\n );\\n}","_id":"_design/medic-client","views":{"contacts_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_last_visited":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n if (typeof date !== \'number\' || isNaN(date)) {\\n date = 0;\\n }\\n // Is a visit report about a family\\n emit(doc.fields.visited_contact_uuid, date);\\n } else if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n // Is a contact type\\n emit(doc._id, 0);\\n }\\n}","reduce":"_stats"},"contacts_by_parent":{"map":"function(doc) {\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'person\') {\\n var parentId = doc.parent && doc.parent._id;\\n if (parentId) {\\n emit([parentId, doc.contact_type || doc.type]);\\n }\\n }\\n}"},"contacts_by_phone":{"map":"function(doc) {\\n if (doc.phone) {\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n if (types.indexOf(doc.type) !== -1) {\\n emit(doc.phone);\\n }\\n }\\n}"},"contacts_by_place":{"map":"function(doc) {\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n if (doc.type === \'contact\') {\\n idx = types.indexOf(doc.contact_type);\\n if (idx === -1) {\\n idx = doc.contact_type;\\n }\\n } else {\\n idx = types.indexOf(doc.type);\\n }\\n if (idx !== -1) {\\n var place = doc.parent;\\n var order = idx + \' \' + (doc.name && doc.name.toLowerCase());\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], order);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"contacts_by_reference":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n\\n if (doc.type === \'contact\' ||\\n doc.type === \'clinic\' ||\\n doc.type === \'health_center\' ||\\n doc.type === \'district_hospital\' ||\\n doc.type === \'national_office\' ||\\n doc.type === \'person\') {\\n\\n var emitReference = function(prefix, key) {\\n if (tombstone) {\\n prefix = \'tombstone-\' + prefix;\\n }\\n emit([ prefix, String(key) ], doc.reported_date);\\n };\\n\\n if (doc.place_id) {\\n emitReference(\'shortcode\', doc.place_id);\\n }\\n if (doc.patient_id) {\\n emitReference(\'shortcode\', doc.patient_id);\\n }\\n if (doc.simprints_id) {\\n emitReference(\'simprints\', doc.simprints_id);\\n }\\n if (doc.rc_code) {\\n // need String because rewriter wraps everything in quotes\\n // keep refid case-insenstive since data is usually coming from SMS\\n emitReference(\'external\', String(doc.rc_code).toUpperCase());\\n }\\n }\\n}"},"contacts_by_type_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'geolocation\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(type, key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([ type, key ], value);\\n }\\n };\\n\\n var emitField = function(type, key, value, order) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(type, word, order);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(type, key + \':\' + value, order);\\n }\\n };\\n\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n Object.keys(doc).forEach(function(key) {\\n emitField(type, key, doc[key], order);\\n });\\n }\\n}"},"contacts_by_type":{"map":"function(doc) {\\n var tombstone = false;\\n if (doc.type === \'tombstone\' && doc.tombstone) {\\n tombstone = true;\\n doc = doc.tombstone;\\n }\\n var types = [ \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n var idx;\\n var type;\\n if (doc.type === \'contact\') {\\n type = doc.contact_type;\\n idx = types.indexOf(type);\\n if (idx === -1) {\\n idx = type;\\n }\\n } else {\\n type = doc.type;\\n idx = types.indexOf(type);\\n }\\n if (tombstone) {\\n type = \'tombstone-\' + type;\\n }\\n if (idx !== -1) {\\n var dead = !!doc.date_of_death;\\n var muted = !!doc.muted;\\n var order = dead + \' \' + muted + \' \' + idx + \' \' + (doc.name && doc.name.toLowerCase());\\n emit([ type ], order);\\n }\\n}"},"data_records_by_type":{"map":"function(doc) {\\n if (doc.type === \'data_record\') {\\n emit(doc.form ? \'report\' : \'message\');\\n }\\n}","reduce":"_count"},"doc_by_type":{"map":"function(doc) {\\n if (doc.type === \'translations\') {\\n emit([ \'translations\', doc.enabled ], {\\n code: doc.code,\\n name: doc.name\\n });\\n return;\\n }\\n emit([ doc.type ]);\\n}"},"docs_by_id_lineage":{"map":"function(doc) {\\n\\n var emitLineage = function(contact, depth) {\\n while (contact && contact._id) {\\n emit([ doc._id, depth++ ], { _id: contact._id });\\n contact = contact.parent;\\n }\\n };\\n\\n var types = [ \'contact\', \'district_hospital\', \'health_center\', \'clinic\', \'person\' ];\\n\\n if (types.indexOf(doc.type) !== -1) {\\n // contact\\n emitLineage(doc, 0);\\n } else if (doc.type === \'data_record\' && doc.form) {\\n // report\\n emit([ doc._id, 0 ]);\\n emitLineage(doc.contact, 1);\\n }\\n}"},"messages_by_contact_date":{"map":"function(doc) {\\n\\n var emitMessage = function(doc, contact, phone) {\\n var id = (contact && contact._id) || phone || doc._id;\\n emit([ id, doc.reported_date ], {\\n id: doc._id,\\n date: doc.reported_date,\\n contact: contact && contact._id\\n });\\n };\\n\\n if (doc.type === \'data_record\' && !doc.form) {\\n if (doc.kujua_message && doc.tasks) {\\n // outgoing\\n doc.tasks.forEach(function(task) {\\n var message = task.messages && task.messages[0];\\n if(message) {\\n emitMessage(doc, message.contact, message.to);\\n }\\n });\\n } else if (doc.sms_message) {\\n // incoming\\n emitMessage(doc, doc.contact, doc.from);\\n }\\n }\\n}","reduce":"function(key, values) {\\n var latest = { date: 0 };\\n values.forEach(function(value) {\\n if (value.date > latest.date) {\\n latest = value;\\n }\\n });\\n return latest;\\n}"},"registered_patients":{"map":"// NB: This returns *registrations* for patients. If patients are created by\\n// means other then sending in a registration report (eg created in the UI)\\n// they will not show up in this view.\\n//\\n// For a view with all patients by their shortcode, use:\\n// medic/patient_by_patient_shortcode_id\\nfunction(doc) {\\n var patientId = doc.patient_id || (doc.fields && doc.fields.patient_id);\\n if (doc.form &&\\n doc.type === \'data_record\' &&\\n (!doc.errors || doc.errors.length === 0) &&\\n patientId) {\\n emit(String(patientId));\\n }\\n}"},"reports_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.reported_date], doc.reported_date);\\n }\\n}"},"reports_by_form_year_month_places":{"map":"// data record must adhere to property name of `month`\\nfunction(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.year &&\\n doc.fields.month) {\\n var year = parseInt(doc.fields.year, 10);\\n var month = parseInt(doc.fields.month, 10);\\n var clinic = doc.contact && doc.contact.parent;\\n var healthCenter = clinic && clinic.parent;\\n var district = healthCenter && healthCenter.parent;\\n emit(\\n [ doc.form, year, month ],\\n {\\n isValid: (doc.errors && doc.errors.length === 0),\\n clinicId: clinic && clinic._id,\\n healthCenterId: healthCenter && healthCenter._id,\\n districtId: district && district._id,\\n month: month\\n }\\n );\\n }\\n}"},"reports_by_form_year_week_places":{"map":"// data record must adhere to property name of `week` or `week_number`\\nfunction(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.year &&\\n (doc.fields.week || doc.fields.week_number)) {\\n var year = parseInt(doc.fields.year, 10);\\n var week = parseInt(doc.fields.week || doc.fields.week_number, 10);\\n var clinic = doc.contact && doc.contact.parent;\\n var healthCenter = clinic && clinic.parent;\\n var district = healthCenter && healthCenter.parent;\\n emit(\\n [ doc.form, year, week ],\\n {\\n isValid: (doc.errors && doc.errors.length === 0),\\n clinicId: clinic && clinic._id,\\n healthCenterId: healthCenter && healthCenter._id,\\n districtId: district && district._id,\\n weekNumber: week\\n }\\n );\\n }\\n}"},"reports_by_form":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.form], doc.reported_date);\\n }\\n}","reduce":"function() {\\n return true;\\n}"},"reports_by_freetext":{"map":"function(doc) {\\n var skip = [ \'_id\', \'_rev\', \'type\', \'refid\', \'content\' ];\\n\\n var usedKeys = [];\\n var emitMaybe = function(key, value) {\\n if (usedKeys.indexOf(key) === -1 && // Not already used\\n key.length > 2 // Not too short\\n ) {\\n usedKeys.push(key);\\n emit([key], value);\\n }\\n };\\n\\n var emitField = function(key, value, reportedDate) {\\n if (!key || !value) {\\n return;\\n }\\n key = key.toLowerCase();\\n if (skip.indexOf(key) !== -1 || /_date$/.test(key)) {\\n return;\\n }\\n if (typeof value === \'string\') {\\n value = value.toLowerCase();\\n value.split(/\\\\s+/).forEach(function(word) {\\n emitMaybe(word, reportedDate);\\n });\\n }\\n if (typeof value === \'number\' || typeof value === \'string\') {\\n emitMaybe(key + \':\' + value, reportedDate);\\n }\\n };\\n\\n if (doc.type === \'data_record\' && doc.form) {\\n Object.keys(doc).forEach(function(key) {\\n emitField(key, doc[key], doc.reported_date);\\n });\\n if (doc.fields) {\\n Object.keys(doc.fields).forEach(function(key) {\\n emitField(key, doc.fields[key], doc.reported_date);\\n });\\n }\\n if (doc.contact && doc.contact._id) {\\n emitMaybe(\'contact:\' + doc.contact._id.toLowerCase(), doc.reported_date);\\n }\\n }\\n}"},"reports_by_place":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var place = doc.contact && doc.contact.parent;\\n while (place) {\\n if (place._id) {\\n emit([ place._id ], doc.reported_date);\\n }\\n place = place.parent;\\n }\\n }\\n}"},"reports_by_subject":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n var emitField = function(obj, field) {\\n if (obj[field]) {\\n emit(obj[field], doc.reported_date);\\n }\\n };\\n\\n emitField(doc, \'patient_id\');\\n emitField(doc, \'place_id\');\\n emitField(doc, \'case_id\');\\n\\n if (doc.fields) {\\n emitField(doc.fields, \'patient_id\');\\n emitField(doc.fields, \'place_id\');\\n emitField(doc.fields, \'case_id\');\\n emitField(doc.fields, \'patient_uuid\');\\n emitField(doc.fields, \'place_uuid\');\\n }\\n }\\n}"},"reports_by_validity":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([!doc.errors || doc.errors.length === 0], doc.reported_date);\\n }\\n}"},"reports_by_verification":{"map":"function(doc) {\\n if (doc.type === \'data_record\' && doc.form) {\\n emit([doc.verified], doc.reported_date);\\n }\\n}"},"tasks_by_contact":{"map":"function(doc) {\\n if (doc.type === \'task\') {\\n var isTerminalState = [\'Cancelled\', \'Completed\', \'Failed\'].indexOf(doc.state) >= 0;\\n if (!isTerminalState) {\\n emit(\'owner-\' + (doc.owner || \'_unassigned\'));\\n }\\n\\n if (doc.requester) {\\n emit(\'requester-\' + doc.requester);\\n }\\n }\\n}"},"total_clinics_by_facility":{"map":"function(doc) {\\n var districtId = doc.parent && doc.parent.parent && doc.parent.parent._id;\\n if (doc.type === \'clinic\' || (doc.type === \'contact\' && districtId)) {\\n var healthCenterId = doc.parent && doc.parent._id;\\n emit([ districtId, healthCenterId, doc._id, 0 ]);\\n if (doc.contact && doc.contact._id) {\\n emit([ districtId, healthCenterId, doc._id, 1 ], { _id: doc.contact._id });\\n }\\n var index = 2;\\n var parent = doc.parent;\\n while(parent) {\\n if (parent._id) {\\n emit([ districtId, healthCenterId, doc._id, index++ ], { _id: parent._id });\\n }\\n parent = parent.parent;\\n }\\n }\\n}"},"visits_by_date":{"map":"function(doc) {\\n if (doc.type === \'data_record\' &&\\n doc.form &&\\n doc.fields &&\\n doc.fields.visited_contact_uuid) {\\n\\n var visited_date = doc.fields.visited_date ? Date.parse(doc.fields.visited_date) : doc.reported_date;\\n\\n // Is a visit report about a family\\n emit(visited_date, doc.fields.visited_contact_uuid);\\n }\\n}"}}}]');
/***/ }),
@@ -91530,6 +91551,23800 @@ module.exports = (taskDocs, timestamp = Date.now()) => {
};
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/calendar-interval/src/index.js":
+/*!*******************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/calendar-interval/src/index.js ***!
+ \*******************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+const moment = __webpack_require__(/*! moment */ "./node_modules/moment/moment.js");
+
+const normalizeStartDate = (intervalStartDate) => {
+ intervalStartDate = parseInt(intervalStartDate);
+
+ if (isNaN(intervalStartDate) || intervalStartDate <= 0 || intervalStartDate > 31) {
+ intervalStartDate = 1;
+ }
+
+ return intervalStartDate;
+};
+
+const getMinimumStartDate = (intervalStartDate, relativeDate) => {
+ return moment
+ .min(
+ relativeDate.clone().subtract(1, 'month').date(intervalStartDate).startOf('day'),
+ relativeDate.clone().startOf('month')
+ )
+ .valueOf();
+};
+
+const getMinimumEndDate = (intervalStartDate, nextMonth, relativeDate) => {
+ return moment
+ .min(
+ relativeDate.clone().add(nextMonth ? 1 : 0, 'month').date(intervalStartDate - 1).endOf('day'),
+ relativeDate.clone().add(nextMonth ? 1 : 0, 'month').endOf('month')
+ )
+ .valueOf();
+};
+
+const getInterval = (intervalStartDate, referenceDate = moment()) => {
+ intervalStartDate = normalizeStartDate(intervalStartDate);
+ if (intervalStartDate === 1) {
+ return {
+ start: referenceDate.startOf('month').valueOf(),
+ end: referenceDate.endOf('month').valueOf()
+ };
+ }
+
+ if (intervalStartDate <= referenceDate.date()) {
+ return {
+ start: referenceDate.date(intervalStartDate).startOf('day').valueOf(),
+ end: getMinimumEndDate(intervalStartDate, true, referenceDate)
+ };
+ }
+
+ return {
+ start: getMinimumStartDate(intervalStartDate, referenceDate),
+ end: getMinimumEndDate(intervalStartDate, false, referenceDate)
+ };
+};
+
+module.exports = {
+ // Returns the timestamps of the start and end of the current calendar interval
+ // @param {Number} [intervalStartDate=1] - day of month when interval starts (1 - 31)
+ //
+ // if `intervalStartDate` exceeds month's day count, the start/end of following/current month is returned
+ // f.e. `intervalStartDate` === 31 would generate next intervals :
+ // [12-31 -> 01-30], [01-31 -> 02-[28|29]], [03-01 -> 03-30], [03-31 -> 04-30], [05-01 -> 05-30], [05-31 - 06-30]
+ getCurrent: (intervalStartDate) => getInterval(intervalStartDate),
+
+ /**
+ * Returns the timestamps of the start and end of the a calendar interval that contains a reference date
+ * @param {Number} [intervalStartDate=1] - day of month when interval starts (1 - 31)
+ * @param {Number} timestamp - the reference date the interval should include
+ * @returns { start: number, end: number } - timestamps that define the calendar interval
+ */
+ getInterval: (intervalStartDate, timestamp) => getInterval(intervalStartDate, moment(timestamp)),
+};
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/cht-script-api/src/auth.js":
+/*!***************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/cht-script-api/src/auth.js ***!
+ \***************************************************************************/
+/***/ ((module) => {
+
+/**
+ * CHT Script API - Auth module
+ * Provides tools related to Authentication.
+ */
+
+const ADMIN_ROLE = '_admin';
+const NATIONAL_ADMIN_ROLE = 'national_admin'; // Deprecated: kept for backwards compatibility: #4525
+const DISALLOWED_PERMISSION_PREFIX = '!';
+
+const isAdmin = (userRoles) => {
+ if (!Array.isArray(userRoles)) {
+ return false;
+ }
+
+ return [ADMIN_ROLE, NATIONAL_ADMIN_ROLE].some(role => userRoles.includes(role));
+};
+
+const groupPermissions = (permissions) => {
+ const groups = { allowed: [], disallowed: [] };
+
+ permissions.forEach(permission => {
+ if (permission.indexOf(DISALLOWED_PERMISSION_PREFIX) === 0) {
+ // Removing the DISALLOWED_PERMISSION_PREFIX and keeping the permission name.
+ groups.disallowed.push(permission.substring(1));
+ } else {
+ groups.allowed.push(permission);
+ }
+ });
+
+ return groups;
+};
+
+const debug = (reason, permissions, roles) => {
+ // eslint-disable-next-line no-console
+ console.debug(`CHT Script API :: ${reason}. User roles: ${roles}. Wanted permissions: ${permissions}`);
+};
+
+const checkUserHasPermissions = (permissions, userRoles, chtPermissionsSettings, expectedToHave) => {
+ return permissions.every(permission => {
+ const roles = chtPermissionsSettings[permission];
+
+ if (!roles) {
+ return !expectedToHave;
+ }
+
+ return expectedToHave === userRoles.some(role => roles.includes(role));
+ });
+};
+
+const verifyParameters = (permissions, userRoles, chtPermissionsSettings) => {
+ if (!Array.isArray(permissions) || !permissions.length) {
+ debug('Permissions to verify are not provided or have invalid type');
+ return false;
+ }
+
+ if (!Array.isArray(userRoles)) {
+ debug('User roles are not provided or have invalid type');
+ return false;
+ }
+
+ if (!chtPermissionsSettings || !Object.keys(chtPermissionsSettings).length) {
+ debug('CHT-Core\'s configured permissions are not provided');
+ return false;
+ }
+
+ return true;
+};
+
+/**
+ * Verify if the user's role has the permission(s).
+ * @param permissions {string | string[]} Permission(s) to verify
+ * @param userRoles {string[]} Array of user roles.
+ * @param chtPermissionsSettings {object} Object of configured permissions in CHT-Core's settings.
+ * @return {boolean}
+ */
+const hasPermissions = (permissions, userRoles, chtPermissionsSettings) => {
+ if (permissions && typeof permissions === 'string') {
+ permissions = [ permissions ];
+ }
+
+ if (!verifyParameters(permissions, userRoles, chtPermissionsSettings)) {
+ return false;
+ }
+
+ const { allowed, disallowed } = groupPermissions(permissions);
+
+ if (isAdmin(userRoles)) {
+ if (disallowed.length) {
+ debug('Disallowed permission(s) found for admin', permissions, userRoles);
+ return false;
+ }
+ // Admin has the permissions automatically.
+ return true;
+ }
+
+ const hasDisallowed = !checkUserHasPermissions(disallowed, userRoles, chtPermissionsSettings, false);
+ const hasAllowed = checkUserHasPermissions(allowed, userRoles, chtPermissionsSettings, true);
+
+ if (hasDisallowed) {
+ debug('Found disallowed permission(s)', permissions, userRoles);
+ return false;
+ }
+
+ if (!hasAllowed) {
+ debug('Missing permission(s)', permissions, userRoles);
+ return false;
+ }
+
+ return true;
+};
+
+/**
+ * Verify if the user's role has all the permissions of any of the provided groups.
+ * @param permissionsGroupList {string[][]} Array of groups of permissions due to the complexity of permission grouping
+ * @param userRoles {string[]} Array of user roles.
+ * @param chtPermissionsSettings {object} Object of configured permissions in CHT-Core's settings.
+ * @return {boolean}
+ */
+const hasAnyPermission = (permissionsGroupList, userRoles, chtPermissionsSettings) => {
+ if (!verifyParameters(permissionsGroupList, userRoles, chtPermissionsSettings)) {
+ return false;
+ }
+
+ const validGroup = permissionsGroupList.every(permissions => Array.isArray(permissions));
+ if (!validGroup) {
+ debug('Permission groups to verify are invalid');
+ return false;
+ }
+
+ const allowedGroupList = [];
+ const disallowedGroupList = [];
+ permissionsGroupList.forEach(permissions => {
+ const { allowed, disallowed } = groupPermissions(permissions);
+ allowedGroupList.push(allowed);
+ disallowedGroupList.push(disallowed);
+ });
+
+ if (isAdmin(userRoles)) {
+ if (disallowedGroupList.every(permissions => permissions.length)) {
+ debug('Disallowed permission(s) found for admin', permissionsGroupList, userRoles);
+ return false;
+ }
+ // Admin has the permissions automatically.
+ return true;
+ }
+
+ const hasAnyPermissionGroup = permissionsGroupList.some((permissions, i) => {
+ const hasAnyAllowed = checkUserHasPermissions(allowedGroupList[i], userRoles, chtPermissionsSettings, true);
+ const hasAnyDisallowed = !checkUserHasPermissions(disallowedGroupList[i], userRoles, chtPermissionsSettings, false);
+ // Checking the 'permission group' is valid.
+ return hasAnyAllowed && !hasAnyDisallowed;
+ });
+
+ if (!hasAnyPermissionGroup) {
+ debug('No matching permissions', permissionsGroupList, userRoles);
+ return false;
+ }
+
+ return true;
+};
+
+module.exports = {
+ hasPermissions,
+ hasAnyPermission
+};
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/cht-script-api/src/index.js":
+/*!****************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/cht-script-api/src/index.js ***!
+ \****************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/**
+ * CHT Script API - Index
+ * Builds and exports a versioned API from feature modules.
+ * Whenever possible keep this file clean by defining new features in modules.
+ */
+const auth = __webpack_require__(/*! ./auth */ "./node_modules/cht-core-3-12/shared-libs/cht-script-api/src/auth.js");
+
+/**
+ * Verify if the user's role has the permission(s).
+ * @param permissions {string | string[]} Permission(s) to verify
+ * @param userRoles {string[]} Array of user roles.
+ * @param chtPermissionsSettings {object} Object of configured permissions in CHT-Core's settings.
+ * @return {boolean}
+ */
+const hasPermissions = (permissions, userRoles, chtPermissionsSettings) => {
+ return auth.hasPermissions(permissions, userRoles, chtPermissionsSettings);
+};
+
+/**
+ * Verify if the user's role has all the permissions of any of the provided groups.
+ * @param permissionsGroupList {string[][]} Array of groups of permissions due to the complexity of permission grouping
+ * @param userRoles {string[]} Array of user roles.
+ * @param chtPermissionsSettings {object} Object of configured permissions in CHT-Core's settings.
+ * @return {boolean}
+ */
+const hasAnyPermission = (permissionsGroupList, userRoles, chtPermissionsSettings) => {
+ return auth.hasAnyPermission(permissionsGroupList, userRoles, chtPermissionsSettings);
+};
+
+module.exports = {
+ v1: {
+ hasPermissions,
+ hasAnyPermission
+ }
+};
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/lineage/src/hydration.js":
+/*!*************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/lineage/src/hydration.js ***!
+ \*************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+const _ = __webpack_require__(/*! lodash/core */ "./node_modules/lodash/core.js");
+_.uniq = __webpack_require__(/*! lodash/uniq */ "./node_modules/lodash/uniq.js");
+const utils = __webpack_require__(/*! ./utils */ "./node_modules/cht-core-3-12/shared-libs/lineage/src/utils.js");
+
+const deepCopy = obj => JSON.parse(JSON.stringify(obj));
+
+const selfAndParents = function(self) {
+ const parents = [];
+ let current = self;
+ while (current) {
+ if (parents.includes(current)) {
+ return parents;
+ }
+
+ parents.push(current);
+ current = current.parent;
+ }
+ return parents;
+};
+
+const extractParentIds = current => selfAndParents(current)
+ .map(parent => parent._id)
+ .filter(id => id);
+
+const getContactById = (contacts, id) => id && contacts.find(contact => contact && contact._id === id);
+
+const getContactIds = (contacts) => {
+ const ids = [];
+ contacts.forEach(doc => {
+ if (!doc) {
+ return;
+ }
+
+ const id = utils.getId(doc.contact);
+ id && ids.push(id);
+
+ if (!utils.validLinkedDocs(doc)) {
+ return;
+ }
+ Object.keys(doc.linked_docs).forEach(key => {
+ const id = utils.getId(doc.linked_docs[key]);
+ id && ids.push(id);
+ });
+ });
+
+ return _.uniq(ids);
+};
+
+module.exports = function(Promise, DB) {
+ const fillParentsInDocs = function(doc, lineage) {
+ if (!doc || !lineage.length) {
+ return doc;
+ }
+
+ // Parent hierarchy starts at the contact for data_records
+ let currentParent;
+ if (utils.isReport(doc)) {
+ currentParent = doc.contact = lineage.shift() || doc.contact;
+ } else {
+ // It's a contact
+ currentParent = doc;
+ }
+
+ const parentIds = extractParentIds(currentParent.parent);
+ lineage.forEach(function(l, i) {
+ currentParent.parent = l ? deepCopy(l) : { _id: parentIds[i] };
+ currentParent = currentParent.parent;
+ });
+
+ return doc;
+ };
+
+ const fillContactsInDocs = function(docs, contacts) {
+ if (!contacts || !contacts.length) {
+ return;
+ }
+
+ docs.forEach(function(doc) {
+ if (!doc) {
+ return;
+ }
+ const id = utils.getId(doc.contact);
+ const contactDoc = getContactById(contacts, id);
+ if (contactDoc) {
+ doc.contact = deepCopy(contactDoc);
+ }
+
+ if (!utils.validLinkedDocs(doc)) {
+ return;
+ }
+
+ Object.keys(doc.linked_docs).forEach(key => {
+ const id = utils.getId(doc.linked_docs[key]);
+ const contactDoc = getContactById(contacts, id);
+ if (contactDoc) {
+ doc.linked_docs[key] = deepCopy(contactDoc);
+ }
+ });
+ });
+ };
+
+ const fetchContacts = function(lineage) {
+ const contactIds = getContactIds(lineage);
+
+ // Only fetch docs that are new to us
+ const lineageContacts = [];
+ const contactsToFetch = [];
+ contactIds.forEach(function(id) {
+ const contact = getContactById(lineage, id);
+ if (contact) {
+ lineageContacts.push(deepCopy(contact));
+ } else {
+ contactsToFetch.push(id);
+ }
+ });
+
+ return fetchDocs(contactsToFetch)
+ .then(function(fetchedContacts) {
+ return lineageContacts.concat(fetchedContacts);
+ });
+ };
+
+ const mergeLineagesIntoDoc = function(lineage, contacts, patientLineage, placeLineage) {
+ const doc = lineage.shift();
+ fillParentsInDocs(doc, lineage);
+
+ if (patientLineage && patientLineage.length) {
+ const patientDoc = patientLineage.shift();
+ fillParentsInDocs(patientDoc, patientLineage);
+ doc.patient = patientDoc;
+ }
+
+ if (placeLineage && placeLineage.length) {
+ const placeDoc = placeLineage.shift();
+ fillParentsInDocs(placeDoc, placeLineage);
+ doc.place = placeDoc;
+ }
+
+ return doc;
+ };
+
+ /*
+ * @returns {Object} subjectMaps
+ * @returns {Map} subjectMaps.patientUuids - map with [k, v] pairs of [recordUuid, patientUuid]
+ * @returns {Map} subjectMaps.placeUuids - map with [k, v] pairs of [recordUuid, placeUuid]
+ */
+ const fetchSubjectsUuids = (records) => {
+ const shortcodes = [];
+ const recordToPlaceUuidMap = new Map();
+ const recordToPatientUuidMap = new Map();
+
+ records.forEach(record => {
+ if (!utils.isReport(record)) {
+ return;
+ }
+
+ const patientId = utils.getPatientId(record);
+ const placeId = utils.getPlaceId(record);
+ recordToPatientUuidMap.set(record._id, patientId);
+ recordToPlaceUuidMap.set(record._id, placeId);
+
+ shortcodes.push(patientId, placeId);
+ });
+
+ if (!shortcodes.some(shortcode => shortcode)) {
+ return Promise.resolve({ patientUuids: recordToPatientUuidMap, placeUuids: recordToPlaceUuidMap });
+ }
+
+ return contactUuidByShortcode(shortcodes).then(shortcodeToUuidMap => {
+ records.forEach(record => {
+ const patientShortcode = recordToPatientUuidMap.get(record._id);
+ recordToPatientUuidMap.set(record._id, shortcodeToUuidMap.get(patientShortcode));
+
+ const placeShortcode = recordToPlaceUuidMap.get(record._id);
+ recordToPlaceUuidMap.set(record._id, shortcodeToUuidMap.get(placeShortcode));
+ });
+
+ return { patientUuids: recordToPatientUuidMap, placeUuids: recordToPlaceUuidMap };
+ });
+ };
+
+ /*
+ * @returns {Object} lineages
+ * @returns {Array} lineages.patientLineage
+ * @returns {Array} lineages.placeLineage
+ */
+ const fetchSubjectLineage = (record) => {
+ if (!utils.isReport(record)) {
+ return Promise.resolve({ patientLineage: [], placeLineage: [] });
+ }
+
+ const patientId = utils.getPatientId(record);
+ const placeId = utils.getPlaceId(record);
+
+ if (!patientId && !placeId) {
+ return Promise.resolve({ patientLineage: [], placeLineage: [] });
+ }
+
+ return contactUuidByShortcode([patientId, placeId]).then((shortcodeToUuidMap) => {
+ const patientUuid = shortcodeToUuidMap.get(patientId);
+ const placeUuid = shortcodeToUuidMap.get(placeId);
+
+ return fetchLineageByIds([patientUuid, placeUuid]).then((lineages) => {
+ const patientLineage = lineages.find(lineage => lineage[0]._id === patientUuid) || [];
+ const placeLineage = lineages.find(lineage => lineage[0]._id === placeUuid) || [];
+
+ return { patientLineage, placeLineage };
+ });
+ });
+ };
+
+ /*
+ * @returns {Map} map with [k, v] pairs of [shortcode, uuid]
+ */
+ const contactUuidByShortcode = function(shortcodes) {
+ const keys = shortcodes
+ .filter(shortcode => shortcode)
+ .map(shortcode => [ 'shortcode', shortcode ]);
+
+ return DB.query('medic-client/contacts_by_reference', { keys })
+ .then(function(results) {
+ const findIdWithKey = key => {
+ const matchingRow = results.rows.find(row => row.key[1] === key);
+ return matchingRow && matchingRow.id;
+ };
+
+ return new Map(shortcodes.map(shortcode => ([ shortcode, findIdWithKey(shortcode) || shortcode, ])));
+ });
+ };
+
+ const fetchLineageById = function(id) {
+ const options = {
+ startkey: [id],
+ endkey: [id, {}],
+ include_docs: true
+ };
+ return DB.query('medic-client/docs_by_id_lineage', options)
+ .then(function(result) {
+ return result.rows.map(function(row) {
+ return row.doc;
+ });
+ });
+ };
+
+ const fetchLineageByIds = function(ids) {
+ return fetchDocs(ids).then(function(docs) {
+ return hydrateDocs(docs).then(function(hydratedDocs) {
+ // Returning a list of docs just like fetchLineageById
+ const docsList = [];
+ hydratedDocs.forEach(function(hdoc) {
+ const docLineage = selfAndParents(hdoc);
+ docsList.push(docLineage);
+ });
+ return docsList;
+ });
+ });
+ };
+
+ const fetchDoc = function(id) {
+ return DB.get(id)
+ .catch(function(err) {
+ if (err.status === 404) {
+ err.statusCode = 404;
+ }
+ throw err;
+ });
+ };
+
+ const fetchHydratedDoc = function(id, options = {}, callback) {
+ let lineage;
+ let patientLineage;
+ let placeLineage;
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+
+ _.defaults(options, {
+ throwWhenMissingLineage: false,
+ });
+
+ return fetchLineageById(id)
+ .then(function(result) {
+ lineage = result;
+
+ if (lineage.length === 0) {
+ if (options.throwWhenMissingLineage) {
+ const err = new Error(`Document not found: ${id}`);
+ err.code = 404;
+ throw err;
+ } else {
+ // Not a doc that has lineage, just do a normal fetch.
+ return fetchDoc(id);
+ }
+ }
+
+ return fetchSubjectLineage(lineage[0])
+ .then((lineages = {}) => {
+ patientLineage = lineages.patientLineage;
+ placeLineage = lineages.placeLineage;
+
+ return fetchContacts(lineage.concat(patientLineage, placeLineage));
+ })
+ .then(function(contacts) {
+ fillContactsInDocs(lineage, contacts);
+ fillContactsInDocs(patientLineage, contacts);
+ fillContactsInDocs(placeLineage, contacts);
+ return mergeLineagesIntoDoc(lineage, contacts, patientLineage, placeLineage);
+ });
+ })
+ .then(function(result) {
+ if (callback) {
+ callback(null, result);
+ }
+ return result;
+ })
+ .catch(function(err) {
+ if (callback) {
+ callback(err);
+ } else {
+ throw err;
+ }
+ });
+ };
+
+ // for data_records, include the first-level contact.
+ const collectParentIds = function(docs) {
+ const ids = [];
+ docs.forEach(function(doc) {
+ let parent = doc.parent;
+ if (utils.isReport(doc)) {
+ const contactId = utils.getId(doc.contact);
+ if (!contactId) {
+ return;
+ }
+ ids.push(contactId);
+ parent = doc.contact;
+ }
+
+ ids.push(...extractParentIds(parent));
+ });
+ return _.uniq(ids);
+ };
+
+ // for data_records, doesn't include the first-level contact (it counts as a parent).
+ const collectLeafContactIds = function(partiallyHydratedDocs) {
+ const ids = [];
+ partiallyHydratedDocs.forEach(function(doc) {
+ const startLineageFrom = utils.isReport(doc) ? doc.contact : doc;
+ ids.push(...getContactIds(selfAndParents(startLineageFrom)));
+ });
+
+ return _.uniq(ids);
+ };
+
+ const fetchDocs = function(ids) {
+ if (!ids || !ids.length) {
+ return Promise.resolve([]);
+ }
+ const keys = _.uniq(ids.filter(id => id));
+ if (keys.length === 0) {
+ return Promise.resolve([]);
+ }
+
+ return DB.allDocs({ keys, include_docs: true })
+ .then(function(results) {
+ return results.rows
+ .map(function(row) {
+ return row.doc;
+ })
+ .filter(function(doc) {
+ return !!doc;
+ });
+ });
+ };
+
+ const hydrateDocs = function(docs) {
+ if (!docs.length) {
+ return Promise.resolve([]);
+ }
+
+ const hydratedDocs = deepCopy(docs); // a copy of the original docs which we will incrementally hydrate and return
+ const knownDocs = [...hydratedDocs]; // an array of all documents which we have fetched
+
+ let patientUuids; // a map of [k, v] pairs with [hydratedDocUuid, patientUuid]
+ let placeUuids; // a map of [k, v] pairs with [hydratedDocUuid, placeUuid]
+
+ return fetchSubjectsUuids(hydratedDocs)
+ .then((subjectMaps) => {
+ placeUuids = subjectMaps.placeUuids;
+ patientUuids = subjectMaps.patientUuids;
+
+ return fetchDocs([...placeUuids.values(), ...patientUuids.values()]);
+ })
+ .then(subjects => {
+ knownDocs.push(...subjects);
+
+ const firstRoundIdsToFetch = _.uniq([
+ ...collectParentIds(hydratedDocs),
+ ...collectLeafContactIds(hydratedDocs),
+
+ ...collectParentIds(subjects),
+ ...collectLeafContactIds(subjects),
+ ]);
+
+ return fetchDocs(firstRoundIdsToFetch);
+ })
+ .then(function(firstRoundFetched) {
+ knownDocs.push(...firstRoundFetched);
+ const secondRoundIdsToFetch = collectLeafContactIds(firstRoundFetched)
+ .filter(id => !knownDocs.some(doc => doc._id === id));
+ return fetchDocs(secondRoundIdsToFetch);
+ })
+ .then(function(secondRoundFetched) {
+ knownDocs.push(...secondRoundFetched);
+
+ fillContactsInDocs(knownDocs, knownDocs);
+ hydratedDocs.forEach((doc) => {
+ const reconstructLineage = (docWithLineage, parents) => {
+ const parentIds = extractParentIds(docWithLineage);
+ return parentIds.map(id => {
+ // how can we use hashmaps?
+ return getContactById(parents, id);
+ });
+ };
+
+ const isReport = utils.isReport(doc);
+ const findParentsFor = isReport ? doc.contact : doc;
+ const lineage = reconstructLineage(findParentsFor, knownDocs);
+
+ if (isReport) {
+ lineage.unshift(doc);
+ }
+
+ const patientDoc = getContactById(knownDocs, patientUuids.get(doc._id));
+ const patientLineage = reconstructLineage(patientDoc, knownDocs);
+
+ const placeDoc = getContactById(knownDocs, placeUuids.get(doc._id));
+ const placeLineage = reconstructLineage(placeDoc, knownDocs);
+
+ mergeLineagesIntoDoc(lineage, knownDocs, patientLineage, placeLineage);
+ });
+
+ return hydratedDocs;
+ });
+ };
+
+ const fetchHydratedDocs = docIds => {
+ if (!Array.isArray(docIds)) {
+ return Promise.reject(new Error('Invalid parameter: "docIds" must be an array'));
+ }
+
+ if (!docIds.length) {
+ return Promise.resolve([]);
+ }
+
+ if (docIds.length === 1) {
+ return fetchHydratedDoc(docIds[0])
+ .then(doc => [doc])
+ .catch(err => {
+ if (err.status === 404) {
+ return [];
+ }
+
+ throw err;
+ });
+ }
+
+ return DB
+ .allDocs({ keys: docIds, include_docs: true })
+ .then(result => {
+ const docs = result.rows.map(row => row.doc).filter(doc => doc);
+ return hydrateDocs(docs);
+ });
+ };
+
+ return {
+ /**
+ * Given a doc id get a doc and all parents, contact (and parents) and patient (and parents) and place (and parents)
+ * @param {String} id The id of the doc to fetch and hydrate
+ * @param {Object} [options] Options for the behavior of the hydration
+ * @param {Boolean} [options.throwWhenMissingLineage=false] When true, throw if the doc has nothing to hydrate.
+ * When false, does a best effort to return the document regardless of content.
+ * @returns {Promise} A promise to return the hydrated doc.
+ */
+ fetchHydratedDoc: (id, options, callback) => fetchHydratedDoc(id, options, callback),
+
+ /**
+ * Given an array of ids, returns hydrated versions of every requested doc (using hydrateDocs or fetchHydratedDoc)
+ * If a doc is not found, it's simply excluded from the results list
+ * @param {Object[]} docs The array of docs to hydrate
+ * @returns {Promise} A promise to return the hydrated docs
+ */
+ fetchHydratedDocs: docIds => fetchHydratedDocs(docIds),
+
+ /**
+ * Given an array of docs bind the parents, contact (and parents) and patient (and parents) and place (and parents)
+ * @param {Object[]} docs The array of docs to hydrate
+ * @returns {Promise}
+ */
+ hydrateDocs: docs => hydrateDocs(docs),
+
+ fetchLineageById,
+ fetchLineageByIds,
+ fillContactsInDocs,
+ fillParentsInDocs,
+ fetchContacts,
+ };
+};
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/lineage/src/index.js":
+/*!*********************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/lineage/src/index.js ***!
+ \*********************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/**
+ * @module lineage
+ */
+module.exports = (Promise, DB) => Object.assign(
+ {},
+ __webpack_require__(/*! ./hydration */ "./node_modules/cht-core-3-12/shared-libs/lineage/src/hydration.js")(Promise, DB),
+ __webpack_require__(/*! ./minify */ "./node_modules/cht-core-3-12/shared-libs/lineage/src/minify.js")
+);
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/lineage/src/minify.js":
+/*!**********************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/lineage/src/minify.js ***!
+ \**********************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+const utils = __webpack_require__(/*! ./utils */ "./node_modules/cht-core-3-12/shared-libs/lineage/src/utils.js");
+const RECURSION_LIMIT = 50;
+
+// Minifies things you would attach to another doc:
+// doc.parent = minify(doc.parent)
+// Not:
+// minify(doc)
+function minifyLineage(parent) {
+ if (!parent || !parent._id) {
+ return parent;
+ }
+
+ const docId = parent._id;
+ const result = { _id: parent._id };
+ let minified = result;
+ for (let guard = RECURSION_LIMIT; parent.parent && parent.parent._id; --guard) {
+ if (guard === 0) {
+ throw Error(`Could not minify ${docId}, possible parent recursion.`);
+ }
+
+ minified.parent = { _id: parent.parent._id };
+ minified = minified.parent;
+ parent = parent.parent;
+ }
+
+ return result;
+}
+
+/**
+ * Remove all hyrdrated items and leave just the ids
+ * @param {Object} doc The doc to minify
+ */
+function minify(doc) {
+ if (!doc) {
+ return;
+ }
+ if (doc.parent) {
+ doc.parent = minifyLineage(doc.parent);
+ }
+ if (doc.contact && doc.contact._id) {
+ const miniContact = { _id: doc.contact._id };
+ if (doc.contact.parent) {
+ miniContact.parent = minifyLineage(doc.contact.parent);
+ }
+ doc.contact = miniContact;
+ }
+ if (doc.type === 'data_record') {
+ delete doc.patient;
+ delete doc.place;
+ }
+
+ if (utils.validLinkedDocs(doc)) {
+ Object.keys(doc.linked_docs).forEach(key => {
+ doc.linked_docs[key] = utils.getId(doc.linked_docs[key]);
+ });
+ }
+}
+
+module.exports = {
+ minify,
+ minifyLineage,
+};
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/lineage/src/utils.js":
+/*!*********************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/lineage/src/utils.js ***!
+ \*********************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+const contactTypeUtils = __webpack_require__(/*! @medic/contact-types-utils */ "./node_modules/cht-core-3-11/shared-libs/contact-types-utils/src/index.js");
+const _ = __webpack_require__(/*! lodash/core */ "./node_modules/lodash/core.js");
+
+const isContact = doc => {
+ if (!doc) {
+ return;
+ }
+
+ return doc.type === 'contact' || contactTypeUtils.HARDCODED_TYPES.includes(doc.type);
+};
+
+const getId = (item) => item && (typeof item === 'string' ? item : item._id);
+
+// don't process linked docs for non-contact types
+// linked_docs property should be a key-value object
+const validLinkedDocs = doc => {
+ return isContact(doc) && _.isObject(doc.linked_docs) && !_.isArray(doc.linked_docs);
+};
+
+const isReport = (doc) => doc.type === 'data_record';
+const getPatientId = (doc) => (doc.fields && (doc.fields.patient_id || doc.fields.patient_uuid)) || doc.patient_id;
+const getPlaceId = (doc) => (doc.fields && doc.fields.place_id) || doc.place_id;
+
+
+module.exports = {
+ getId,
+ validLinkedDocs,
+ isReport,
+ getPatientId,
+ getPlaceId,
+};
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/registration-utils/src/index.js":
+/*!********************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/registration-utils/src/index.js ***!
+ \********************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+const uniq = __webpack_require__(/*! lodash/uniq */ "./node_modules/lodash/uniq.js");
+
+const formCodeMatches = (conf, form) => {
+ return (new RegExp('^[^a-z]*' + conf + '[^a-z]*$', 'i')).test(form);
+};
+
+// Returns whether `doc` is a valid registration against a configuration
+// This is done by checks roughly similar to the `registration` transition filter function
+// Serves as a replacement for checking for `transitions` metadata within the doc itself
+exports.isValidRegistration = (doc, settings) => {
+ if (!doc ||
+ (doc.errors && doc.errors.length) ||
+ !settings ||
+ !settings.registrations ||
+ doc.type !== 'data_record' ||
+ !doc.form) {
+ return false;
+ }
+
+ // Registration transition should be configured for this form
+ const registrationConfiguration = settings.registrations.find((conf) => {
+ return conf &&
+ conf.form &&
+ formCodeMatches(conf.form, doc.form);
+ });
+ if (!registrationConfiguration) {
+ return false;
+ }
+
+ if (doc.content_type === 'xml') {
+ return true;
+ }
+
+ // SMS forms need to be configured
+ const form = settings.forms && settings.forms[doc.form];
+ if (!form) {
+ return false;
+ }
+
+ // Require a known submitter or the form to be public.
+ return Boolean(form.public_form || doc.contact);
+};
+
+exports._formCodeMatches = formCodeMatches;
+
+const CONTACT_SUBJECT_PROPERTIES = ['_id', 'patient_id', 'place_id'];
+const REPORT_SUBJECT_PROPERTIES = ['patient_id', 'patient_uuid', 'place_id', 'place_uuid'];
+
+exports.getSubjectIds = (doc) => {
+ const subjectIds = [];
+
+ if (!doc) {
+ return subjectIds;
+ }
+
+ if (doc.type === 'data_record') {
+ REPORT_SUBJECT_PROPERTIES.forEach(prop => {
+ if (doc[prop]) {
+ subjectIds.push(doc[prop]);
+ }
+ if (doc.fields && doc.fields[prop]) {
+ subjectIds.push(doc.fields[prop]);
+ }
+ });
+ } else {
+ CONTACT_SUBJECT_PROPERTIES.forEach(prop => {
+ if (doc[prop]) {
+ subjectIds.push(doc[prop]);
+ }
+ });
+ }
+
+ return uniq(subjectIds);
+};
+
+exports.getSubjectId = report => {
+ if (!report) {
+ return false;
+ }
+ for (const prop of REPORT_SUBJECT_PROPERTIES) {
+ if (report[prop]) {
+ return report[prop];
+ }
+ if (report.fields && report.fields[prop]) {
+ return report.fields[prop];
+ }
+ }
+};
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/arguments-extended/index.js":
+/*!******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/arguments-extended/index.js ***!
+ \******************************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+
+ function defineArgumentsExtended(extended, is) {
+
+ var pSlice = Array.prototype.slice,
+ isArguments = is.isArguments;
+
+ function argsToArray(args, slice) {
+ var i = -1, j = 0, l = args.length, ret = [];
+ slice = slice || 0;
+ i += slice;
+ while (++i < l) {
+ ret[j++] = args[i];
+ }
+ return ret;
+ }
+
+
+ return extended
+ .define(isArguments, {
+ toArray: argsToArray
+ })
+ .expose({
+ argsToArray: argsToArray
+ });
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineArgumentsExtended(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js"), __webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"));
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js ***!
+ \**************************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+ /*global define*/
+
+ function defineArray(extended, is, args) {
+
+ var isString = is.isString,
+ isArray = Array.isArray || is.isArray,
+ isDate = is.isDate,
+ floor = Math.floor,
+ abs = Math.abs,
+ mathMax = Math.max,
+ mathMin = Math.min,
+ arrayProto = Array.prototype,
+ arrayIndexOf = arrayProto.indexOf,
+ arrayForEach = arrayProto.forEach,
+ arrayMap = arrayProto.map,
+ arrayReduce = arrayProto.reduce,
+ arrayReduceRight = arrayProto.reduceRight,
+ arrayFilter = arrayProto.filter,
+ arrayEvery = arrayProto.every,
+ arraySome = arrayProto.some,
+ argsToArray = args.argsToArray;
+
+
+ function cross(num, cros) {
+ return reduceRight(cros, function (a, b) {
+ if (!isArray(b)) {
+ b = [b];
+ }
+ b.unshift(num);
+ a.unshift(b);
+ return a;
+ }, []);
+ }
+
+ function permute(num, cross, length) {
+ var ret = [];
+ for (var i = 0; i < cross.length; i++) {
+ ret.push([num].concat(rotate(cross, i)).slice(0, length));
+ }
+ return ret;
+ }
+
+
+ function intersection(a, b) {
+ var ret = [], aOne, i = -1, l;
+ l = a.length;
+ while (++i < l) {
+ aOne = a[i];
+ if (indexOf(b, aOne) !== -1) {
+ ret.push(aOne);
+ }
+ }
+ return ret;
+ }
+
+
+ var _sort = (function () {
+
+ var isAll = function (arr, test) {
+ return every(arr, test);
+ };
+
+ var defaultCmp = function (a, b) {
+ return a - b;
+ };
+
+ var dateSort = function (a, b) {
+ return a.getTime() - b.getTime();
+ };
+
+ return function _sort(arr, property) {
+ var ret = [];
+ if (isArray(arr)) {
+ ret = arr.slice();
+ if (property) {
+ if (typeof property === "function") {
+ ret.sort(property);
+ } else {
+ ret.sort(function (a, b) {
+ var aProp = a[property], bProp = b[property];
+ if (isString(aProp) && isString(bProp)) {
+ return aProp > bProp ? 1 : aProp < bProp ? -1 : 0;
+ } else if (isDate(aProp) && isDate(bProp)) {
+ return aProp.getTime() - bProp.getTime();
+ } else {
+ return aProp - bProp;
+ }
+ });
+ }
+ } else {
+ if (isAll(ret, isString)) {
+ ret.sort();
+ } else if (isAll(ret, isDate)) {
+ ret.sort(dateSort);
+ } else {
+ ret.sort(defaultCmp);
+ }
+ }
+ }
+ return ret;
+ };
+
+ })();
+
+ function indexOf(arr, searchElement, from) {
+ var index = (from || 0) - 1,
+ length = arr.length;
+ while (++index < length) {
+ if (arr[index] === searchElement) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ function lastIndexOf(arr, searchElement, from) {
+ if (!isArray(arr)) {
+ throw new TypeError();
+ }
+
+ var t = Object(arr);
+ var len = t.length >>> 0;
+ if (len === 0) {
+ return -1;
+ }
+
+ var n = len;
+ if (arguments.length > 2) {
+ n = Number(arguments[2]);
+ if (n !== n) {
+ n = 0;
+ } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
+ n = (n > 0 || -1) * floor(abs(n));
+ }
+ }
+
+ var k = n >= 0 ? mathMin(n, len - 1) : len - abs(n);
+
+ for (; k >= 0; k--) {
+ if (k in t && t[k] === searchElement) {
+ return k;
+ }
+ }
+ return -1;
+ }
+
+ function filter(arr, iterator, scope) {
+ if (arr && arrayFilter && arrayFilter === arr.filter) {
+ return arr.filter(iterator, scope);
+ }
+ if (!isArray(arr) || typeof iterator !== "function") {
+ throw new TypeError();
+ }
+
+ var t = Object(arr);
+ var len = t.length >>> 0;
+ var res = [];
+ for (var i = 0; i < len; i++) {
+ if (i in t) {
+ var val = t[i]; // in case fun mutates this
+ if (iterator.call(scope, val, i, t)) {
+ res.push(val);
+ }
+ }
+ }
+ return res;
+ }
+
+ function forEach(arr, iterator, scope) {
+ if (!isArray(arr) || typeof iterator !== "function") {
+ throw new TypeError();
+ }
+ if (arr && arrayForEach && arrayForEach === arr.forEach) {
+ arr.forEach(iterator, scope);
+ return arr;
+ }
+ for (var i = 0, len = arr.length; i < len; ++i) {
+ iterator.call(scope || arr, arr[i], i, arr);
+ }
+
+ return arr;
+ }
+
+ function every(arr, iterator, scope) {
+ if (arr && arrayEvery && arrayEvery === arr.every) {
+ return arr.every(iterator, scope);
+ }
+ if (!isArray(arr) || typeof iterator !== "function") {
+ throw new TypeError();
+ }
+ var t = Object(arr);
+ var len = t.length >>> 0;
+ for (var i = 0; i < len; i++) {
+ if (i in t && !iterator.call(scope, t[i], i, t)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ function some(arr, iterator, scope) {
+ if (arr && arraySome && arraySome === arr.some) {
+ return arr.some(iterator, scope);
+ }
+ if (!isArray(arr) || typeof iterator !== "function") {
+ throw new TypeError();
+ }
+ var t = Object(arr);
+ var len = t.length >>> 0;
+ for (var i = 0; i < len; i++) {
+ if (i in t && iterator.call(scope, t[i], i, t)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function map(arr, iterator, scope) {
+ if (arr && arrayMap && arrayMap === arr.map) {
+ return arr.map(iterator, scope);
+ }
+ if (!isArray(arr) || typeof iterator !== "function") {
+ throw new TypeError();
+ }
+
+ var t = Object(arr);
+ var len = t.length >>> 0;
+ var res = [];
+ for (var i = 0; i < len; i++) {
+ if (i in t) {
+ res.push(iterator.call(scope, t[i], i, t));
+ }
+ }
+ return res;
+ }
+
+ function reduce(arr, accumulator, curr) {
+ var initial = arguments.length > 2;
+ if (arr && arrayReduce && arrayReduce === arr.reduce) {
+ return initial ? arr.reduce(accumulator, curr) : arr.reduce(accumulator);
+ }
+ if (!isArray(arr) || typeof accumulator !== "function") {
+ throw new TypeError();
+ }
+ var i = 0, l = arr.length >> 0;
+ if (arguments.length < 3) {
+ if (l === 0) {
+ throw new TypeError("Array length is 0 and no second argument");
+ }
+ curr = arr[0];
+ i = 1; // start accumulating at the second element
+ } else {
+ curr = arguments[2];
+ }
+ while (i < l) {
+ if (i in arr) {
+ curr = accumulator.call(undefined, curr, arr[i], i, arr);
+ }
+ ++i;
+ }
+ return curr;
+ }
+
+ function reduceRight(arr, accumulator, curr) {
+ var initial = arguments.length > 2;
+ if (arr && arrayReduceRight && arrayReduceRight === arr.reduceRight) {
+ return initial ? arr.reduceRight(accumulator, curr) : arr.reduceRight(accumulator);
+ }
+ if (!isArray(arr) || typeof accumulator !== "function") {
+ throw new TypeError();
+ }
+
+ var t = Object(arr);
+ var len = t.length >>> 0;
+
+ // no value to return if no initial value, empty array
+ if (len === 0 && arguments.length === 2) {
+ throw new TypeError();
+ }
+
+ var k = len - 1;
+ if (arguments.length >= 3) {
+ curr = arguments[2];
+ } else {
+ do {
+ if (k in arr) {
+ curr = arr[k--];
+ break;
+ }
+ }
+ while (true);
+ }
+ while (k >= 0) {
+ if (k in t) {
+ curr = accumulator.call(undefined, curr, t[k], k, t);
+ }
+ k--;
+ }
+ return curr;
+ }
+
+
+ function toArray(o) {
+ var ret = [];
+ if (o !== null) {
+ var args = argsToArray(arguments);
+ if (args.length === 1) {
+ if (isArray(o)) {
+ ret = o;
+ } else if (is.isHash(o)) {
+ for (var i in o) {
+ if (o.hasOwnProperty(i)) {
+ ret.push([i, o[i]]);
+ }
+ }
+ } else {
+ ret.push(o);
+ }
+ } else {
+ forEach(args, function (a) {
+ ret = ret.concat(toArray(a));
+ });
+ }
+ }
+ return ret;
+ }
+
+ function sum(array) {
+ array = array || [];
+ if (array.length) {
+ return reduce(array, function (a, b) {
+ return a + b;
+ });
+ } else {
+ return 0;
+ }
+ }
+
+ function avg(arr) {
+ arr = arr || [];
+ if (arr.length) {
+ var total = sum(arr);
+ if (is.isNumber(total)) {
+ return total / arr.length;
+ } else {
+ throw new Error("Cannot average an array of non numbers.");
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ function sort(arr, cmp) {
+ return _sort(arr, cmp);
+ }
+
+ function min(arr, cmp) {
+ return _sort(arr, cmp)[0];
+ }
+
+ function max(arr, cmp) {
+ return _sort(arr, cmp)[arr.length - 1];
+ }
+
+ function difference(arr1) {
+ var ret = arr1, args = flatten(argsToArray(arguments, 1));
+ if (isArray(arr1)) {
+ ret = filter(arr1, function (a) {
+ return indexOf(args, a) === -1;
+ });
+ }
+ return ret;
+ }
+
+ function removeDuplicates(arr) {
+ var ret = [], i = -1, l, retLength = 0;
+ if (arr) {
+ l = arr.length;
+ while (++i < l) {
+ var item = arr[i];
+ if (indexOf(ret, item) === -1) {
+ ret[retLength++] = item;
+ }
+ }
+ }
+ return ret;
+ }
+
+
+ function unique(arr) {
+ return removeDuplicates(arr);
+ }
+
+
+ function rotate(arr, numberOfTimes) {
+ var ret = arr.slice();
+ if (typeof numberOfTimes !== "number") {
+ numberOfTimes = 1;
+ }
+ if (numberOfTimes && isArray(arr)) {
+ if (numberOfTimes > 0) {
+ ret.push(ret.shift());
+ numberOfTimes--;
+ } else {
+ ret.unshift(ret.pop());
+ numberOfTimes++;
+ }
+ return rotate(ret, numberOfTimes);
+ } else {
+ return ret;
+ }
+ }
+
+ function permutations(arr, length) {
+ var ret = [];
+ if (isArray(arr)) {
+ var copy = arr.slice(0);
+ if (typeof length !== "number") {
+ length = arr.length;
+ }
+ if (!length) {
+ ret = [
+ []
+ ];
+ } else if (length <= arr.length) {
+ ret = reduce(arr, function (a, b, i) {
+ var ret;
+ if (length > 1) {
+ ret = permute(b, rotate(copy, i).slice(1), length);
+ } else {
+ ret = [
+ [b]
+ ];
+ }
+ return a.concat(ret);
+ }, []);
+ }
+ }
+ return ret;
+ }
+
+ function zip() {
+ var ret = [];
+ var arrs = argsToArray(arguments);
+ if (arrs.length > 1) {
+ var arr1 = arrs.shift();
+ if (isArray(arr1)) {
+ ret = reduce(arr1, function (a, b, i) {
+ var curr = [b];
+ for (var j = 0; j < arrs.length; j++) {
+ var currArr = arrs[j];
+ if (isArray(currArr) && !is.isUndefined(currArr[i])) {
+ curr.push(currArr[i]);
+ } else {
+ curr.push(null);
+ }
+ }
+ a.push(curr);
+ return a;
+ }, []);
+ }
+ }
+ return ret;
+ }
+
+ function transpose(arr) {
+ var ret = [];
+ if (isArray(arr) && arr.length) {
+ var last;
+ forEach(arr, function (a) {
+ if (isArray(a) && (!last || a.length === last.length)) {
+ forEach(a, function (b, i) {
+ if (!ret[i]) {
+ ret[i] = [];
+ }
+ ret[i].push(b);
+ });
+ last = a;
+ }
+ });
+ }
+ return ret;
+ }
+
+ function valuesAt(arr, indexes) {
+ var ret = [];
+ indexes = argsToArray(arguments);
+ arr = indexes.shift();
+ if (isArray(arr) && indexes.length) {
+ for (var i = 0, l = indexes.length; i < l; i++) {
+ ret.push(arr[indexes[i]] || null);
+ }
+ }
+ return ret;
+ }
+
+ function union() {
+ var ret = [];
+ var arrs = argsToArray(arguments);
+ if (arrs.length > 1) {
+ for (var i = 0, l = arrs.length; i < l; i++) {
+ ret = ret.concat(arrs[i]);
+ }
+ ret = removeDuplicates(ret);
+ }
+ return ret;
+ }
+
+ function intersect() {
+ var collect = [], sets, i = -1 , l;
+ if (arguments.length > 1) {
+ //assume we are intersections all the lists in the array
+ sets = argsToArray(arguments);
+ } else {
+ sets = arguments[0];
+ }
+ if (isArray(sets)) {
+ collect = sets[0];
+ i = 0;
+ l = sets.length;
+ while (++i < l) {
+ collect = intersection(collect, sets[i]);
+ }
+ }
+ return removeDuplicates(collect);
+ }
+
+ function powerSet(arr) {
+ var ret = [];
+ if (isArray(arr) && arr.length) {
+ ret = reduce(arr, function (a, b) {
+ var ret = map(a, function (c) {
+ return c.concat(b);
+ });
+ return a.concat(ret);
+ }, [
+ []
+ ]);
+ }
+ return ret;
+ }
+
+ function cartesian(a, b) {
+ var ret = [];
+ if (isArray(a) && isArray(b) && a.length && b.length) {
+ ret = cross(a[0], b).concat(cartesian(a.slice(1), b));
+ }
+ return ret;
+ }
+
+ function compact(arr) {
+ var ret = [];
+ if (isArray(arr) && arr.length) {
+ ret = filter(arr, function (item) {
+ return !is.isUndefinedOrNull(item);
+ });
+ }
+ return ret;
+ }
+
+ function multiply(arr, times) {
+ times = is.isNumber(times) ? times : 1;
+ if (!times) {
+ //make sure times is greater than zero if it is zero then dont multiply it
+ times = 1;
+ }
+ arr = toArray(arr || []);
+ var ret = [], i = 0;
+ while (++i <= times) {
+ ret = ret.concat(arr);
+ }
+ return ret;
+ }
+
+ function flatten(arr) {
+ var set;
+ var args = argsToArray(arguments);
+ if (args.length > 1) {
+ //assume we are intersections all the lists in the array
+ set = args;
+ } else {
+ set = toArray(arr);
+ }
+ return reduce(set, function (a, b) {
+ return a.concat(b);
+ }, []);
+ }
+
+ function pluck(arr, prop) {
+ prop = prop.split(".");
+ var result = arr.slice(0);
+ forEach(prop, function (prop) {
+ var exec = prop.match(/(\w+)\(\)$/);
+ result = map(result, function (item) {
+ return exec ? item[exec[1]]() : item[prop];
+ });
+ });
+ return result;
+ }
+
+ function invoke(arr, func, args) {
+ args = argsToArray(arguments, 2);
+ return map(arr, function (item) {
+ var exec = isString(func) ? item[func] : func;
+ return exec.apply(item, args);
+ });
+ }
+
+
+ var array = {
+ toArray: toArray,
+ sum: sum,
+ avg: avg,
+ sort: sort,
+ min: min,
+ max: max,
+ difference: difference,
+ removeDuplicates: removeDuplicates,
+ unique: unique,
+ rotate: rotate,
+ permutations: permutations,
+ zip: zip,
+ transpose: transpose,
+ valuesAt: valuesAt,
+ union: union,
+ intersect: intersect,
+ powerSet: powerSet,
+ cartesian: cartesian,
+ compact: compact,
+ multiply: multiply,
+ flatten: flatten,
+ pluck: pluck,
+ invoke: invoke,
+ forEach: forEach,
+ map: map,
+ filter: filter,
+ reduce: reduce,
+ reduceRight: reduceRight,
+ some: some,
+ every: every,
+ indexOf: indexOf,
+ lastIndexOf: lastIndexOf
+ };
+
+ return extended.define(isArray, array).expose(array);
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineArray(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js"), __webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"), __webpack_require__(/*! arguments-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/arguments-extended/index.js"));
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/charenc/charenc.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/charenc/charenc.js ***!
+ \*********************************************************************************************/
+/***/ ((module) => {
+
+var charenc = {
+ // UTF-8 encoding
+ utf8: {
+ // Convert a string to a byte array
+ stringToBytes: function(str) {
+ return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
+ },
+
+ // Convert a byte array to a string
+ bytesToString: function(bytes) {
+ return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
+ }
+ },
+
+ // Binary encoding
+ bin: {
+ // Convert a string to a byte array
+ stringToBytes: function(str) {
+ for (var bytes = [], i = 0; i < str.length; i++)
+ bytes.push(str.charCodeAt(i) & 0xFF);
+ return bytes;
+ },
+
+ // Convert a byte array to a string
+ bytesToString: function(bytes) {
+ for (var str = [], i = 0; i < bytes.length; i++)
+ str.push(String.fromCharCode(bytes[i]));
+ return str.join('');
+ }
+ }
+};
+
+module.exports = charenc;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/crypt/crypt.js":
+/*!*****************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/crypt/crypt.js ***!
+ \*****************************************************************************************/
+/***/ ((module) => {
+
+(function() {
+ var base64map
+ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
+
+ crypt = {
+ // Bit-wise rotation left
+ rotl: function(n, b) {
+ return (n << b) | (n >>> (32 - b));
+ },
+
+ // Bit-wise rotation right
+ rotr: function(n, b) {
+ return (n << (32 - b)) | (n >>> b);
+ },
+
+ // Swap big-endian to little-endian and vice versa
+ endian: function(n) {
+ // If number given, swap endian
+ if (n.constructor == Number) {
+ return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
+ }
+
+ // Else, assume array and swap all items
+ for (var i = 0; i < n.length; i++)
+ n[i] = crypt.endian(n[i]);
+ return n;
+ },
+
+ // Generate an array of any length of random bytes
+ randomBytes: function(n) {
+ for (var bytes = []; n > 0; n--)
+ bytes.push(Math.floor(Math.random() * 256));
+ return bytes;
+ },
+
+ // Convert a byte array to big-endian 32-bit words
+ bytesToWords: function(bytes) {
+ for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
+ words[b >>> 5] |= bytes[i] << (24 - b % 32);
+ return words;
+ },
+
+ // Convert big-endian 32-bit words to a byte array
+ wordsToBytes: function(words) {
+ for (var bytes = [], b = 0; b < words.length * 32; b += 8)
+ bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
+ return bytes;
+ },
+
+ // Convert a byte array to a hex string
+ bytesToHex: function(bytes) {
+ for (var hex = [], i = 0; i < bytes.length; i++) {
+ hex.push((bytes[i] >>> 4).toString(16));
+ hex.push((bytes[i] & 0xF).toString(16));
+ }
+ return hex.join('');
+ },
+
+ // Convert a hex string to a byte array
+ hexToBytes: function(hex) {
+ for (var bytes = [], c = 0; c < hex.length; c += 2)
+ bytes.push(parseInt(hex.substr(c, 2), 16));
+ return bytes;
+ },
+
+ // Convert a byte array to a base-64 string
+ bytesToBase64: function(bytes) {
+ for (var base64 = [], i = 0; i < bytes.length; i += 3) {
+ var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
+ for (var j = 0; j < 4; j++)
+ if (i * 8 + j * 6 <= bytes.length * 8)
+ base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
+ else
+ base64.push('=');
+ }
+ return base64.join('');
+ },
+
+ // Convert a base-64 string to a byte array
+ base64ToBytes: function(base64) {
+ // Remove non-base-64 characters
+ base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
+
+ for (var bytes = [], i = 0, imod4 = 0; i < base64.length;
+ imod4 = ++i % 4) {
+ if (imod4 == 0) continue;
+ bytes.push(((base64map.indexOf(base64.charAt(i - 1))
+ & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))
+ | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
+ }
+ return bytes;
+ }
+ };
+
+ module.exports = crypt;
+})();
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/date-extended/index.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/date-extended/index.js ***!
+ \*************************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+
+ function defineDate(extended, is, array) {
+
+ function _pad(string, length, ch, end) {
+ string = "" + string; //check for numbers
+ ch = ch || " ";
+ var strLen = string.length;
+ while (strLen < length) {
+ if (end) {
+ string += ch;
+ } else {
+ string = ch + string;
+ }
+ strLen++;
+ }
+ return string;
+ }
+
+ function _truncate(string, length, end) {
+ var ret = string;
+ if (is.isString(ret)) {
+ if (string.length > length) {
+ if (end) {
+ var l = string.length;
+ ret = string.substring(l - length, l);
+ } else {
+ ret = string.substring(0, length);
+ }
+ }
+ } else {
+ ret = _truncate("" + ret, length);
+ }
+ return ret;
+ }
+
+ function every(arr, iterator, scope) {
+ if (!is.isArray(arr) || typeof iterator !== "function") {
+ throw new TypeError();
+ }
+ var t = Object(arr);
+ var len = t.length >>> 0;
+ for (var i = 0; i < len; i++) {
+ if (i in t && !iterator.call(scope, t[i], i, t)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ var transforms = (function () {
+ var floor = Math.floor, round = Math.round;
+
+ var addMap = {
+ day: function addDay(date, amount) {
+ return [amount, "Date", false];
+ },
+ weekday: function addWeekday(date, amount) {
+ // Divide the increment time span into weekspans plus leftover days
+ // e.g., 8 days is one 5-day weekspan / and two leftover days
+ // Can't have zero leftover days, so numbers divisible by 5 get
+ // a days value of 5, and the remaining days make up the number of weeks
+ var days, weeks, mod = amount % 5, strt = date.getDay(), adj = 0;
+ if (!mod) {
+ days = (amount > 0) ? 5 : -5;
+ weeks = (amount > 0) ? ((amount - 5) / 5) : ((amount + 5) / 5);
+ } else {
+ days = mod;
+ weeks = parseInt(amount / 5, 10);
+ }
+ if (strt === 6 && amount > 0) {
+ adj = 1;
+ } else if (strt === 0 && amount < 0) {
+ // Orig date is Sun / negative increment
+ // Jump back over Sat
+ adj = -1;
+ }
+ // Get weekday val for the new date
+ var trgt = strt + days;
+ // New date is on Sat or Sun
+ if (trgt === 0 || trgt === 6) {
+ adj = (amount > 0) ? 2 : -2;
+ }
+ // Increment by number of weeks plus leftover days plus
+ // weekend adjustments
+ return [(7 * weeks) + days + adj, "Date", false];
+ },
+ year: function addYear(date, amount) {
+ return [amount, "FullYear", true];
+ },
+ week: function addWeek(date, amount) {
+ return [amount * 7, "Date", false];
+ },
+ quarter: function addYear(date, amount) {
+ return [amount * 3, "Month", true];
+ },
+ month: function addYear(date, amount) {
+ return [amount, "Month", true];
+ }
+ };
+
+ function addTransform(interval, date, amount) {
+ interval = interval.replace(/s$/, "");
+ if (addMap.hasOwnProperty(interval)) {
+ return addMap[interval](date, amount);
+ }
+ return [amount, "UTC" + interval.charAt(0).toUpperCase() + interval.substring(1) + "s", false];
+ }
+
+
+ var differenceMap = {
+ "quarter": function quarterDifference(date1, date2, utc) {
+ var yearDiff = date2.getFullYear() - date1.getFullYear();
+ var m1 = date1[utc ? "getUTCMonth" : "getMonth"]();
+ var m2 = date2[utc ? "getUTCMonth" : "getMonth"]();
+ // Figure out which quarter the months are in
+ var q1 = floor(m1 / 3) + 1;
+ var q2 = floor(m2 / 3) + 1;
+ // Add quarters for any year difference between the dates
+ q2 += (yearDiff * 4);
+ return q2 - q1;
+ },
+
+ "weekday": function weekdayDifference(date1, date2, utc) {
+ var days = differenceTransform("day", date1, date2, utc), weeks;
+ var mod = days % 7;
+ // Even number of weeks
+ if (mod === 0) {
+ days = differenceTransform("week", date1, date2, utc) * 5;
+ } else {
+ // Weeks plus spare change (< 7 days)
+ var adj = 0, aDay = date1[utc ? "getUTCDay" : "getDay"](), bDay = date2[utc ? "getUTCDay" : "getDay"]();
+ weeks = parseInt(days / 7, 10);
+ // Mark the date advanced by the number of
+ // round weeks (may be zero)
+ var dtMark = new Date(+date1);
+ dtMark.setDate(dtMark[utc ? "getUTCDate" : "getDate"]() + (weeks * 7));
+ var dayMark = dtMark[utc ? "getUTCDay" : "getDay"]();
+
+ // Spare change days -- 6 or less
+ if (days > 0) {
+ if (aDay === 6 || bDay === 6) {
+ adj = -1;
+ } else if (aDay === 0) {
+ adj = 0;
+ } else if (bDay === 0 || (dayMark + mod) > 5) {
+ adj = -2;
+ }
+ } else if (days < 0) {
+ if (aDay === 6) {
+ adj = 0;
+ } else if (aDay === 0 || bDay === 0) {
+ adj = 1;
+ } else if (bDay === 6 || (dayMark + mod) < 0) {
+ adj = 2;
+ }
+ }
+ days += adj;
+ days -= (weeks * 2);
+ }
+ return days;
+ },
+ year: function (date1, date2) {
+ return date2.getFullYear() - date1.getFullYear();
+ },
+ month: function (date1, date2, utc) {
+ var m1 = date1[utc ? "getUTCMonth" : "getMonth"]();
+ var m2 = date2[utc ? "getUTCMonth" : "getMonth"]();
+ return (m2 - m1) + ((date2.getFullYear() - date1.getFullYear()) * 12);
+ },
+ week: function (date1, date2, utc) {
+ return round(differenceTransform("day", date1, date2, utc) / 7);
+ },
+ day: function (date1, date2) {
+ return 1.1574074074074074e-8 * (date2.getTime() - date1.getTime());
+ },
+ hour: function (date1, date2) {
+ return 2.7777777777777776e-7 * (date2.getTime() - date1.getTime());
+ },
+ minute: function (date1, date2) {
+ return 0.000016666666666666667 * (date2.getTime() - date1.getTime());
+ },
+ second: function (date1, date2) {
+ return 0.001 * (date2.getTime() - date1.getTime());
+ },
+ millisecond: function (date1, date2) {
+ return date2.getTime() - date1.getTime();
+ }
+ };
+
+
+ function differenceTransform(interval, date1, date2, utc) {
+ interval = interval.replace(/s$/, "");
+ return round(differenceMap[interval](date1, date2, utc));
+ }
+
+
+ return {
+ addTransform: addTransform,
+ differenceTransform: differenceTransform
+ };
+ }()),
+ addTransform = transforms.addTransform,
+ differenceTransform = transforms.differenceTransform;
+
+
+ /**
+ * @ignore
+ * Based on DOJO Date Implementation
+ *
+ * Dojo is available under *either* the terms of the modified BSD license *or* the
+ * Academic Free License version 2.1. As a recipient of Dojo, you may choose which
+ * license to receive this code under (except as noted in per-module LICENSE
+ * files). Some modules may not be the copyright of the Dojo Foundation. These
+ * modules contain explicit declarations of copyright in both the LICENSE files in
+ * the directories in which they reside and in the code itself. No external
+ * contributions are allowed under licenses which are fundamentally incompatible
+ * with the AFL or BSD licenses that Dojo is distributed under.
+ *
+ */
+
+ var floor = Math.floor, round = Math.round, min = Math.min, pow = Math.pow, ceil = Math.ceil, abs = Math.abs;
+ var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+ var monthAbbr = ["Jan.", "Feb.", "Mar.", "Apr.", "May.", "Jun.", "Jul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."];
+ var dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
+ var dayAbbr = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+ var eraNames = ["Before Christ", "Anno Domini"];
+ var eraAbbr = ["BC", "AD"];
+
+
+ function getDayOfYear(/*Date*/dateObject, utc) {
+ // summary: gets the day of the year as represented by dateObject
+ return date.difference(new Date(dateObject.getFullYear(), 0, 1, dateObject.getHours()), dateObject, null, utc) + 1; // Number
+ }
+
+ function getWeekOfYear(/*Date*/dateObject, /*Number*/firstDayOfWeek, utc) {
+ firstDayOfWeek = firstDayOfWeek || 0;
+ var fullYear = dateObject[utc ? "getUTCFullYear" : "getFullYear"]();
+ var firstDayOfYear = new Date(fullYear, 0, 1).getDay(),
+ adj = (firstDayOfYear - firstDayOfWeek + 7) % 7,
+ week = floor((getDayOfYear(dateObject) + adj - 1) / 7);
+
+ // if year starts on the specified day, start counting weeks at 1
+ if (firstDayOfYear === firstDayOfWeek) {
+ week++;
+ }
+
+ return week; // Number
+ }
+
+ function getTimezoneName(/*Date*/dateObject) {
+ var str = dateObject.toString();
+ var tz = '';
+ var pos = str.indexOf('(');
+ if (pos > -1) {
+ tz = str.substring(++pos, str.indexOf(')'));
+ }
+ return tz; // String
+ }
+
+
+ function buildDateEXP(pattern, tokens) {
+ return pattern.replace(/([a-z])\1*/ig,function (match) {
+ // Build a simple regexp. Avoid captures, which would ruin the tokens list
+ var s,
+ c = match.charAt(0),
+ l = match.length,
+ p2 = '0?',
+ p3 = '0{0,2}';
+ if (c === 'y') {
+ s = '\\d{2,4}';
+ } else if (c === "M") {
+ s = (l > 2) ? '\\S+?' : '1[0-2]|' + p2 + '[1-9]';
+ } else if (c === "D") {
+ s = '[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|' + p3 + '[1-9][0-9]|' + p2 + '[1-9]';
+ } else if (c === "d") {
+ s = '3[01]|[12]\\d|' + p2 + '[1-9]';
+ } else if (c === "w") {
+ s = '[1-4][0-9]|5[0-3]|' + p2 + '[1-9]';
+ } else if (c === "E") {
+ s = '\\S+';
+ } else if (c === "h") {
+ s = '1[0-2]|' + p2 + '[1-9]';
+ } else if (c === "K") {
+ s = '1[01]|' + p2 + '\\d';
+ } else if (c === "H") {
+ s = '1\\d|2[0-3]|' + p2 + '\\d';
+ } else if (c === "k") {
+ s = '1\\d|2[0-4]|' + p2 + '[1-9]';
+ } else if (c === "m" || c === "s") {
+ s = '[0-5]\\d';
+ } else if (c === "S") {
+ s = '\\d{' + l + '}';
+ } else if (c === "a") {
+ var am = 'AM', pm = 'PM';
+ s = am + '|' + pm;
+ if (am !== am.toLowerCase()) {
+ s += '|' + am.toLowerCase();
+ }
+ if (pm !== pm.toLowerCase()) {
+ s += '|' + pm.toLowerCase();
+ }
+ s = s.replace(/\./g, "\\.");
+ } else if (c === 'v' || c === 'z' || c === 'Z' || c === 'G' || c === 'q' || c === 'Q') {
+ s = ".*";
+ } else {
+ s = c === " " ? "\\s*" : c + "*";
+ }
+ if (tokens) {
+ tokens.push(match);
+ }
+
+ return "(" + s + ")"; // add capture
+ }).replace(/[\xa0 ]/g, "[\\s\\xa0]"); // normalize whitespace. Need explicit handling of \xa0 for IE.
+ }
+
+
+ /**
+ * @namespace Utilities for Dates
+ */
+ var date = {
+
+ /**@lends date*/
+
+ /**
+ * Returns the number of days in the month of a date
+ *
+ * @example
+ *
+ * dateExtender.getDaysInMonth(new Date(2006, 1, 1)); //28
+ * dateExtender.getDaysInMonth(new Date(2004, 1, 1)); //29
+ * dateExtender.getDaysInMonth(new Date(2006, 2, 1)); //31
+ * dateExtender.getDaysInMonth(new Date(2006, 3, 1)); //30
+ * dateExtender.getDaysInMonth(new Date(2006, 4, 1)); //31
+ * dateExtender.getDaysInMonth(new Date(2006, 5, 1)); //30
+ * dateExtender.getDaysInMonth(new Date(2006, 6, 1)); //31
+ * @param {Date} dateObject the date containing the month
+ * @return {Number} the number of days in the month
+ */
+ getDaysInMonth: function (/*Date*/dateObject) {
+ // summary:
+ // Returns the number of days in the month used by dateObject
+ var month = dateObject.getMonth();
+ var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
+ if (month === 1 && date.isLeapYear(dateObject)) {
+ return 29;
+ } // Number
+ return days[month]; // Number
+ },
+
+ /**
+ * Determines if a date is a leap year
+ *
+ * @example
+ *
+ * dateExtender.isLeapYear(new Date(1600, 0, 1)); //true
+ * dateExtender.isLeapYear(new Date(2004, 0, 1)); //true
+ * dateExtender.isLeapYear(new Date(2000, 0, 1)); //true
+ * dateExtender.isLeapYear(new Date(2006, 0, 1)); //false
+ * dateExtender.isLeapYear(new Date(1900, 0, 1)); //false
+ * dateExtender.isLeapYear(new Date(1800, 0, 1)); //false
+ * dateExtender.isLeapYear(new Date(1700, 0, 1)); //false
+ *
+ * @param {Date} dateObject
+ * @returns {Boolean} true if it is a leap year false otherwise
+ */
+ isLeapYear: function (/*Date*/dateObject, utc) {
+ var year = dateObject[utc ? "getUTCFullYear" : "getFullYear"]();
+ return (year % 400 === 0) || (year % 4 === 0 && year % 100 !== 0);
+
+ },
+
+ /**
+ * Determines if a date is on a weekend
+ *
+ * @example
+ *
+ * var thursday = new Date(2006, 8, 21);
+ * var saturday = new Date(2006, 8, 23);
+ * var sunday = new Date(2006, 8, 24);
+ * var monday = new Date(2006, 8, 25);
+ * dateExtender.isWeekend(thursday)); //false
+ * dateExtender.isWeekend(saturday); //true
+ * dateExtender.isWeekend(sunday); //true
+ * dateExtender.isWeekend(monday)); //false
+ *
+ * @param {Date} dateObject the date to test
+ *
+ * @returns {Boolean} true if the date is a weekend
+ */
+ isWeekend: function (/*Date?*/dateObject, utc) {
+ // summary:
+ // Determines if the date falls on a weekend, according to local custom.
+ var day = (dateObject || new Date())[utc ? "getUTCDay" : "getDay"]();
+ return day === 0 || day === 6;
+ },
+
+ /**
+ * Get the timezone of a date
+ *
+ * @example
+ * //just setting the strLocal to simulate the toString() of a date
+ * dt.str = 'Sun Sep 17 2006 22:25:51 GMT-0500 (CDT)';
+ * //just setting the strLocal to simulate the locale
+ * dt.strLocale = 'Sun 17 Sep 2006 10:25:51 PM CDT';
+ * dateExtender.getTimezoneName(dt); //'CDT'
+ * dt.str = 'Sun Sep 17 2006 22:57:18 GMT-0500 (CDT)';
+ * dt.strLocale = 'Sun Sep 17 22:57:18 2006';
+ * dateExtender.getTimezoneName(dt); //'CDT'
+ * @param dateObject the date to get the timezone from
+ *
+ * @returns {String} the timezone of the date
+ */
+ getTimezoneName: getTimezoneName,
+
+ /**
+ * Compares two dates
+ *
+ * @example
+ *
+ * var d1 = new Date();
+ * d1.setHours(0);
+ * dateExtender.compare(d1, d1); // 0
+ *
+ * var d1 = new Date();
+ * d1.setHours(0);
+ * var d2 = new Date();
+ * d2.setFullYear(2005);
+ * d2.setHours(12);
+ * dateExtender.compare(d1, d2, "date"); // 1
+ * dateExtender.compare(d1, d2, "datetime"); // 1
+ *
+ * var d1 = new Date();
+ * d1.setHours(0);
+ * var d2 = new Date();
+ * d2.setFullYear(2005);
+ * d2.setHours(12);
+ * dateExtender.compare(d2, d1, "date"); // -1
+ * dateExtender.compare(d1, d2, "time"); //-1
+ *
+ * @param {Date|String} date1 the date to comapare
+ * @param {Date|String} [date2=new Date()] the date to compare date1 againse
+ * @param {"date"|"time"|"datetime"} portion compares the portion specified
+ *
+ * @returns -1 if date1 is < date2 0 if date1 === date2 1 if date1 > date2
+ */
+ compare: function (/*Date*/date1, /*Date*/date2, /*String*/portion) {
+ date1 = new Date(+date1);
+ date2 = new Date(+(date2 || new Date()));
+
+ if (portion === "date") {
+ // Ignore times and compare dates.
+ date1.setHours(0, 0, 0, 0);
+ date2.setHours(0, 0, 0, 0);
+ } else if (portion === "time") {
+ // Ignore dates and compare times.
+ date1.setFullYear(0, 0, 0);
+ date2.setFullYear(0, 0, 0);
+ }
+ return date1 > date2 ? 1 : date1 < date2 ? -1 : 0;
+ },
+
+
+ /**
+ * Adds a specified interval and amount to a date
+ *
+ * @example
+ * var dtA = new Date(2005, 11, 27);
+ * dateExtender.add(dtA, "year", 1); //new Date(2006, 11, 27);
+ * dateExtender.add(dtA, "years", 1); //new Date(2006, 11, 27);
+ *
+ * dtA = new Date(2000, 0, 1);
+ * dateExtender.add(dtA, "quarter", 1); //new Date(2000, 3, 1);
+ * dateExtender.add(dtA, "quarters", 1); //new Date(2000, 3, 1);
+ *
+ * dtA = new Date(2000, 0, 1);
+ * dateExtender.add(dtA, "month", 1); //new Date(2000, 1, 1);
+ * dateExtender.add(dtA, "months", 1); //new Date(2000, 1, 1);
+ *
+ * dtA = new Date(2000, 0, 31);
+ * dateExtender.add(dtA, "month", 1); //new Date(2000, 1, 29);
+ * dateExtender.add(dtA, "months", 1); //new Date(2000, 1, 29);
+ *
+ * dtA = new Date(2000, 0, 1);
+ * dateExtender.add(dtA, "week", 1); //new Date(2000, 0, 8);
+ * dateExtender.add(dtA, "weeks", 1); //new Date(2000, 0, 8);
+ *
+ * dtA = new Date(2000, 0, 1);
+ * dateExtender.add(dtA, "day", 1); //new Date(2000, 0, 2);
+ *
+ * dtA = new Date(2000, 0, 1);
+ * dateExtender.add(dtA, "weekday", 1); //new Date(2000, 0, 3);
+ *
+ * dtA = new Date(2000, 0, 1, 11);
+ * dateExtender.add(dtA, "hour", 1); //new Date(2000, 0, 1, 12);
+ *
+ * dtA = new Date(2000, 11, 31, 23, 59);
+ * dateExtender.add(dtA, "minute", 1); //new Date(2001, 0, 1, 0, 0);
+ *
+ * dtA = new Date(2000, 11, 31, 23, 59, 59);
+ * dateExtender.add(dtA, "second", 1); //new Date(2001, 0, 1, 0, 0, 0);
+ *
+ * dtA = new Date(2000, 11, 31, 23, 59, 59, 999);
+ * dateExtender.add(dtA, "millisecond", 1); //new Date(2001, 0, 1, 0, 0, 0, 0);
+ *
+ * @param {Date} date
+ * @param {String} interval the interval to add
+ *
+ * - day | days
+ * - weekday | weekdays
+ * - year | years
+ * - week | weeks
+ * - quarter | quarters
+ * - months | months
+ * - hour | hours
+ * - minute | minutes
+ * - second | seconds
+ * - millisecond | milliseconds
+ *
+ * @param {Number} [amount=0] the amount to add
+ */
+ add: function (/*Date*/date, /*String*/interval, /*int*/amount) {
+ var res = addTransform(interval, date, amount || 0);
+ amount = res[0];
+ var property = res[1];
+ var sum = new Date(+date);
+ var fixOvershoot = res[2];
+ if (property) {
+ sum["set" + property](sum["get" + property]() + amount);
+ }
+
+ if (fixOvershoot && (sum.getDate() < date.getDate())) {
+ sum.setDate(0);
+ }
+
+ return sum; // Date
+ },
+
+ /**
+ * Finds the difference between two dates based on the specified interval
+ *
+ * @example
+ *
+ * var dtA, dtB;
+ *
+ * dtA = new Date(2005, 11, 27);
+ * dtB = new Date(2006, 11, 27);
+ * dateExtender.difference(dtA, dtB, "year"); //1
+ *
+ * dtA = new Date(2000, 1, 29);
+ * dtB = new Date(2001, 2, 1);
+ * dateExtender.difference(dtA, dtB, "quarter"); //4
+ * dateExtender.difference(dtA, dtB, "month"); //13
+ *
+ * dtA = new Date(2000, 1, 1);
+ * dtB = new Date(2000, 1, 8);
+ * dateExtender.difference(dtA, dtB, "week"); //1
+ *
+ * dtA = new Date(2000, 1, 29);
+ * dtB = new Date(2000, 2, 1);
+ * dateExtender.difference(dtA, dtB, "day"); //1
+ *
+ * dtA = new Date(2006, 7, 3);
+ * dtB = new Date(2006, 7, 11);
+ * dateExtender.difference(dtA, dtB, "weekday"); //6
+ *
+ * dtA = new Date(2000, 11, 31, 23);
+ * dtB = new Date(2001, 0, 1, 0);
+ * dateExtender.difference(dtA, dtB, "hour"); //1
+ *
+ * dtA = new Date(2000, 11, 31, 23, 59);
+ * dtB = new Date(2001, 0, 1, 0, 0);
+ * dateExtender.difference(dtA, dtB, "minute"); //1
+ *
+ * dtA = new Date(2000, 11, 31, 23, 59, 59);
+ * dtB = new Date(2001, 0, 1, 0, 0, 0);
+ * dateExtender.difference(dtA, dtB, "second"); //1
+ *
+ * dtA = new Date(2000, 11, 31, 23, 59, 59, 999);
+ * dtB = new Date(2001, 0, 1, 0, 0, 0, 0);
+ * dateExtender.difference(dtA, dtB, "millisecond"); //1
+ *
+ *
+ * @param {Date} date1
+ * @param {Date} [date2 = new Date()]
+ * @param {String} [interval = "day"] the intercal to find the difference of.
+ *
+ * - day | days
+ * - weekday | weekdays
+ * - year | years
+ * - week | weeks
+ * - quarter | quarters
+ * - months | months
+ * - hour | hours
+ * - minute | minutes
+ * - second | seconds
+ * - millisecond | milliseconds
+ *
+ */
+ difference: function (/*Date*/date1, /*Date?*/date2, /*String*/interval, utc) {
+ date2 = date2 || new Date();
+ interval = interval || "day";
+ return differenceTransform(interval, date1, date2, utc);
+ },
+
+ /**
+ * Formats a date to the specidifed format string
+ *
+ * @example
+ *
+ * var date = new Date(2006, 7, 11, 0, 55, 12, 345);
+ * dateExtender.format(date, "EEEE, MMMM dd, yyyy"); //"Friday, August 11, 2006"
+ * dateExtender.format(date, "M/dd/yy"); //"8/11/06"
+ * dateExtender.format(date, "E"); //"6"
+ * dateExtender.format(date, "h:m a"); //"12:55 AM"
+ * dateExtender.format(date, 'h:m:s'); //"12:55:12"
+ * dateExtender.format(date, 'h:m:s.SS'); //"12:55:12.35"
+ * dateExtender.format(date, 'k:m:s.SS'); //"24:55:12.35"
+ * dateExtender.format(date, 'H:m:s.SS'); //"0:55:12.35"
+ * dateExtender.format(date, "ddMMyyyy"); //"11082006"
+ *
+ * @param date the date to format
+ * @param {String} format the format of the date composed of the following options
+ *
+ * - G Era designator Text AD
+ * - y Year Year 1996; 96
+ * - M Month in year Month July; Jul; 07
+ * - w Week in year Number 27
+ * - W Week in month Number 2
+ * - D Day in year Number 189
+ * - d Day in month Number 10
+ * - E Day in week Text Tuesday; Tue
+ * - a Am/pm marker Text PM
+ * - H Hour in day (0-23) Number 0
+ * - k Hour in day (1-24) Number 24
+ * - K Hour in am/pm (0-11) Number 0
+ * - h Hour in am/pm (1-12) Number 12
+ * - m Minute in hour Number 30
+ * - s Second in minute Number 55
+ * - S Millisecond Number 978
+ * - z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
+ * - Z Time zone RFC 822 time zone -0800
+ *
+ */
+ format: function (date, format, utc) {
+ utc = utc || false;
+ var fullYear, month, day, d, hour, minute, second, millisecond;
+ if (utc) {
+ fullYear = date.getUTCFullYear();
+ month = date.getUTCMonth();
+ day = date.getUTCDay();
+ d = date.getUTCDate();
+ hour = date.getUTCHours();
+ minute = date.getUTCMinutes();
+ second = date.getUTCSeconds();
+ millisecond = date.getUTCMilliseconds();
+ } else {
+ fullYear = date.getFullYear();
+ month = date.getMonth();
+ d = date.getDate();
+ day = date.getDay();
+ hour = date.getHours();
+ minute = date.getMinutes();
+ second = date.getSeconds();
+ millisecond = date.getMilliseconds();
+ }
+ return format.replace(/([A-Za-z])\1*/g, function (match) {
+ var s, pad,
+ c = match.charAt(0),
+ l = match.length;
+ if (c === 'd') {
+ s = "" + d;
+ pad = true;
+ } else if (c === "H" && !s) {
+ s = "" + hour;
+ pad = true;
+ } else if (c === 'm' && !s) {
+ s = "" + minute;
+ pad = true;
+ } else if (c === 's') {
+ if (!s) {
+ s = "" + second;
+ }
+ pad = true;
+ } else if (c === "G") {
+ s = ((l < 4) ? eraAbbr : eraNames)[fullYear < 0 ? 0 : 1];
+ } else if (c === "y") {
+ s = fullYear;
+ if (l > 1) {
+ if (l === 2) {
+ s = _truncate("" + s, 2, true);
+ } else {
+ pad = true;
+ }
+ }
+ } else if (c.toUpperCase() === "Q") {
+ s = ceil((month + 1) / 3);
+ pad = true;
+ } else if (c === "M") {
+ if (l < 3) {
+ s = month + 1;
+ pad = true;
+ } else {
+ s = (l === 3 ? monthAbbr : monthNames)[month];
+ }
+ } else if (c === "w") {
+ s = getWeekOfYear(date, 0, utc);
+ pad = true;
+ } else if (c === "D") {
+ s = getDayOfYear(date, utc);
+ pad = true;
+ } else if (c === "E") {
+ if (l < 3) {
+ s = day + 1;
+ pad = true;
+ } else {
+ s = (l === -3 ? dayAbbr : dayNames)[day];
+ }
+ } else if (c === 'a') {
+ s = (hour < 12) ? 'AM' : 'PM';
+ } else if (c === "h") {
+ s = (hour % 12) || 12;
+ pad = true;
+ } else if (c === "K") {
+ s = (hour % 12);
+ pad = true;
+ } else if (c === "k") {
+ s = hour || 24;
+ pad = true;
+ } else if (c === "S") {
+ s = round(millisecond * pow(10, l - 3));
+ pad = true;
+ } else if (c === "z" || c === "v" || c === "Z") {
+ s = getTimezoneName(date);
+ if ((c === "z" || c === "v") && !s) {
+ l = 4;
+ }
+ if (!s || c === "Z") {
+ var offset = date.getTimezoneOffset();
+ var tz = [
+ (offset >= 0 ? "-" : "+"),
+ _pad(floor(abs(offset) / 60), 2, "0"),
+ _pad(abs(offset) % 60, 2, "0")
+ ];
+ if (l === 4) {
+ tz.splice(0, 0, "GMT");
+ tz.splice(3, 0, ":");
+ }
+ s = tz.join("");
+ }
+ } else {
+ s = match;
+ }
+ if (pad) {
+ s = _pad(s, l, '0');
+ }
+ return s;
+ });
+ }
+
+ };
+
+ var numberDate = {};
+
+ function addInterval(interval) {
+ numberDate[interval + "sFromNow"] = function (val) {
+ return date.add(new Date(), interval, val);
+ };
+ numberDate[interval + "sAgo"] = function (val) {
+ return date.add(new Date(), interval, -val);
+ };
+ }
+
+ var intervals = ["year", "month", "day", "hour", "minute", "second"];
+ for (var i = 0, l = intervals.length; i < l; i++) {
+ addInterval(intervals[i]);
+ }
+
+ var stringDate = {
+
+ parseDate: function (dateStr, format) {
+ if (!format) {
+ throw new Error('format required when calling dateExtender.parse');
+ }
+ var tokens = [], regexp = buildDateEXP(format, tokens),
+ re = new RegExp("^" + regexp + "$", "i"),
+ match = re.exec(dateStr);
+ if (!match) {
+ return null;
+ } // null
+ var result = [1970, 0, 1, 0, 0, 0, 0], // will get converted to a Date at the end
+ amPm = "",
+ valid = every(match, function (v, i) {
+ if (i) {
+ var token = tokens[i - 1];
+ var l = token.length, type = token.charAt(0);
+ if (type === 'y') {
+ if (v < 100) {
+ v = parseInt(v, 10);
+ //choose century to apply, according to a sliding window
+ //of 80 years before and 20 years after present year
+ var year = '' + new Date().getFullYear(),
+ century = year.substring(0, 2) * 100,
+ cutoff = min(year.substring(2, 4) + 20, 99);
+ result[0] = (v < cutoff) ? century + v : century - 100 + v;
+ } else {
+ result[0] = v;
+ }
+ } else if (type === "M") {
+ if (l > 2) {
+ var months = monthNames, j, k;
+ if (l === 3) {
+ months = monthAbbr;
+ }
+ //Tolerate abbreviating period in month part
+ //Case-insensitive comparison
+ v = v.replace(".", "").toLowerCase();
+ var contains = false;
+ for (j = 0, k = months.length; j < k && !contains; j++) {
+ var s = months[j].replace(".", "").toLocaleLowerCase();
+ if (s === v) {
+ v = j;
+ contains = true;
+ }
+ }
+ if (!contains) {
+ return false;
+ }
+ } else {
+ v--;
+ }
+ result[1] = v;
+ } else if (type === "E" || type === "e") {
+ var days = dayNames;
+ if (l === 3) {
+ days = dayAbbr;
+ }
+ //Case-insensitive comparison
+ v = v.toLowerCase();
+ days = array.map(days, function (d) {
+ return d.toLowerCase();
+ });
+ var d = array.indexOf(days, v);
+ if (d === -1) {
+ v = parseInt(v, 10);
+ if (isNaN(v) || v > days.length) {
+ return false;
+ }
+ } else {
+ v = d;
+ }
+ } else if (type === 'D' || type === "d") {
+ if (type === "D") {
+ result[1] = 0;
+ }
+ result[2] = v;
+ } else if (type === "a") {
+ var am = "am";
+ var pm = "pm";
+ var period = /\./g;
+ v = v.replace(period, '').toLowerCase();
+ // we might not have seen the hours field yet, so store the state and apply hour change later
+ amPm = (v === pm) ? 'p' : (v === am) ? 'a' : '';
+ } else if (type === "k" || type === "h" || type === "H" || type === "K") {
+ if (type === "k" && (+v) === 24) {
+ v = 0;
+ }
+ result[3] = v;
+ } else if (type === "m") {
+ result[4] = v;
+ } else if (type === "s") {
+ result[5] = v;
+ } else if (type === "S") {
+ result[6] = v;
+ }
+ }
+ return true;
+ });
+ if (valid) {
+ var hours = +result[3];
+ //account for am/pm
+ if (amPm === 'p' && hours < 12) {
+ result[3] = hours + 12; //e.g., 3pm -> 15
+ } else if (amPm === 'a' && hours === 12) {
+ result[3] = 0; //12am -> 0
+ }
+ var dateObject = new Date(result[0], result[1], result[2], result[3], result[4], result[5], result[6]); // Date
+ var dateToken = (array.indexOf(tokens, 'd') !== -1),
+ monthToken = (array.indexOf(tokens, 'M') !== -1),
+ month = result[1],
+ day = result[2],
+ dateMonth = dateObject.getMonth(),
+ dateDay = dateObject.getDate();
+ if ((monthToken && dateMonth > month) || (dateToken && dateDay > day)) {
+ return null;
+ }
+ return dateObject; // Date
+ } else {
+ return null;
+ }
+ }
+ };
+
+
+ var ret = extended.define(is.isDate, date).define(is.isString, stringDate).define(is.isNumber, numberDate);
+ for (i in date) {
+ if (date.hasOwnProperty(i)) {
+ ret[i] = date[i];
+ }
+ }
+
+ for (i in stringDate) {
+ if (stringDate.hasOwnProperty(i)) {
+ ret[i] = stringDate[i];
+ }
+ }
+ for (i in numberDate) {
+ if (numberDate.hasOwnProperty(i)) {
+ ret[i] = numberDate[i];
+ }
+ }
+ return ret;
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineDate(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js"), __webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"), __webpack_require__(/*! array-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js"));
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/declare.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/declare.js ***!
+ \************************************************************************************************/
+/***/ ((module) => {
+
+(function () {
+
+ /**
+ * @projectName declare
+ * @github http://github.com/doug-martin/declare.js
+ * @header
+ *
+ * Declare is a library designed to allow writing object oriented code the same way in both the browser and node.js.
+ *
+ * ##Installation
+ *
+ * `npm install declare.js`
+ *
+ * Or [download the source](https://raw.github.com/doug-martin/declare.js/master/declare.js) ([minified](https://raw.github.com/doug-martin/declare.js/master/declare-min.js))
+ *
+ * ###Requirejs
+ *
+ * To use with requirejs place the `declare` source in the root scripts directory
+ *
+ * ```
+ *
+ * define(["declare"], function(declare){
+ * return declare({
+ * instance : {
+ * hello : function(){
+ * return "world";
+ * }
+ * }
+ * });
+ * });
+ *
+ * ```
+ *
+ *
+ * ##Usage
+ *
+ * declare.js provides
+ *
+ * Class methods
+ *
+ * * `as(module | object, name)` : exports the object to module or the object with the name
+ * * `mixin(mixin)` : mixes in an object but does not inherit directly from the object. **Note** this does not return a new class but changes the original class.
+ * * `extend(proto)` : extend a class with the given properties. A shortcut to `declare(Super, {})`;
+ *
+ * Instance methods
+ *
+ * * `_super(arguments)`: calls the super of the current method, you can pass in either the argments object or an array with arguments you want passed to super
+ * * `_getSuper()`: returns a this methods direct super.
+ * * `_static` : use to reference class properties and methods.
+ * * `get(prop)` : gets a property invoking the getter if it exists otherwise it just returns the named property on the object.
+ * * `set(prop, val)` : sets a property invoking the setter if it exists otherwise it just sets the named property on the object.
+ *
+ *
+ * ###Declaring a new Class
+ *
+ * Creating a new class with declare is easy!
+ *
+ * ```
+ *
+ * var Mammal = declare({
+ * //define your instance methods and properties
+ * instance : {
+ *
+ * //will be called whenever a new instance is created
+ * constructor: function(options) {
+ * options = options || {};
+ * this._super(arguments);
+ * this._type = options.type || "mammal";
+ * },
+ *
+ * speak : function() {
+ * return "A mammal of type " + this._type + " sounds like";
+ * },
+ *
+ * //Define your getters
+ * getters : {
+ *
+ * //can be accessed by using the get method. (mammal.get("type"))
+ * type : function() {
+ * return this._type;
+ * }
+ * },
+ *
+ * //Define your setters
+ * setters : {
+ *
+ * //can be accessed by using the set method. (mammal.set("type", "mammalType"))
+ * type : function(t) {
+ * this._type = t;
+ * }
+ * }
+ * },
+ *
+ * //Define your static methods
+ * static : {
+ *
+ * //Mammal.soundOff(); //"Im a mammal!!"
+ * soundOff : function() {
+ * return "Im a mammal!!";
+ * }
+ * }
+ * });
+ *
+ *
+ * ```
+ *
+ * You can use Mammal just like you would any other class.
+ *
+ * ```
+ * Mammal.soundOff("Im a mammal!!");
+ *
+ * var myMammal = new Mammal({type : "mymammal"});
+ * myMammal.speak(); // "A mammal of type mymammal sounds like"
+ * myMammal.get("type"); //"mymammal"
+ * myMammal.set("type", "mammal");
+ * myMammal.get("type"); //"mammal"
+ *
+ *
+ * ```
+ *
+ * ###Extending a class
+ *
+ * If you want to just extend a single class use the .extend method.
+ *
+ * ```
+ *
+ * var Wolf = Mammal.extend({
+ *
+ * //define your instance method
+ * instance: {
+ *
+ * //You can override super constructors just be sure to call `_super`
+ * constructor: function(options) {
+ * options = options || {};
+ * this._super(arguments); //call our super constructor.
+ * this._sound = "growl";
+ * this._color = options.color || "grey";
+ * },
+ *
+ * //override Mammals `speak` method by appending our own data to it.
+ * speak : function() {
+ * return this._super(arguments) + " a " + this._sound;
+ * },
+ *
+ * //add new getters for sound and color
+ * getters : {
+ *
+ * //new Wolf().get("type")
+ * //notice color is read only as we did not define a setter
+ * color : function() {
+ * return this._color;
+ * },
+ *
+ * //new Wolf().get("sound")
+ * sound : function() {
+ * return this._sound;
+ * }
+ * },
+ *
+ * setters : {
+ *
+ * //new Wolf().set("sound", "howl")
+ * sound : function(s) {
+ * this._sound = s;
+ * }
+ * }
+ *
+ * },
+ *
+ * static : {
+ *
+ * //You can override super static methods also! And you can still use _super
+ * soundOff : function() {
+ * //You can even call super in your statics!!!
+ * //should return "I'm a mammal!! that growls"
+ * return this._super(arguments) + " that growls";
+ * }
+ * }
+ * });
+ *
+ * Wolf.soundOff(); //Im a mammal!! that growls
+ *
+ * var myWolf = new Wolf();
+ * myWolf instanceof Mammal //true
+ * myWolf instanceof Wolf //true
+ *
+ * ```
+ *
+ * You can also extend a class by using the declare method and just pass in the super class.
+ *
+ * ```
+ * //Typical hierarchical inheritance
+ * // Mammal->Wolf->Dog
+ * var Dog = declare(Wolf, {
+ * instance: {
+ * constructor: function(options) {
+ * options = options || {};
+ * this._super(arguments);
+ * //override Wolfs initialization of sound to woof.
+ * this._sound = "woof";
+ *
+ * },
+ *
+ * speak : function() {
+ * //Should return "A mammal of type mammal sounds like a growl thats domesticated"
+ * return this._super(arguments) + " thats domesticated";
+ * }
+ * },
+ *
+ * static : {
+ * soundOff : function() {
+ * //should return "I'm a mammal!! that growls but now barks"
+ * return this._super(arguments) + " but now barks";
+ * }
+ * }
+ * });
+ *
+ * Dog.soundOff(); //Im a mammal!! that growls but now barks
+ *
+ * var myDog = new Dog();
+ * myDog instanceof Mammal //true
+ * myDog instanceof Wolf //true
+ * myDog instanceof Dog //true
+ *
+ *
+ * //Notice you still get the extend method.
+ *
+ * // Mammal->Wolf->Dog->Breed
+ * var Breed = Dog.extend({
+ * instance: {
+ *
+ * //initialize outside of constructor
+ * _pitch : "high",
+ *
+ * constructor: function(options) {
+ * options = options || {};
+ * this._super(arguments);
+ * this.breed = options.breed || "lab";
+ * },
+ *
+ * speak : function() {
+ * //Should return "A mammal of type mammal sounds like a
+ * //growl thats domesticated with a high pitch!"
+ * return this._super(arguments) + " with a " + this._pitch + " pitch!";
+ * },
+ *
+ * getters : {
+ * pitch : function() {
+ * return this._pitch;
+ * }
+ * }
+ * },
+ *
+ * static : {
+ * soundOff : function() {
+ * //should return "I'M A MAMMAL!! THAT GROWLS BUT NOW BARKS!"
+ * return this._super(arguments).toUpperCase() + "!";
+ * }
+ * }
+ * });
+ *
+ *
+ * Breed.soundOff()//"IM A MAMMAL!! THAT GROWLS BUT NOW BARKS!"
+ *
+ * var myBreed = new Breed({color : "gold", type : "lab"}),
+ * myBreed instanceof Dog //true
+ * myBreed instanceof Wolf //true
+ * myBreed instanceof Mammal //true
+ * myBreed.speak() //"A mammal of type lab sounds like a woof thats domesticated with a high pitch!"
+ * myBreed.get("type") //"lab"
+ * myBreed.get("color") //"gold"
+ * myBreed.get("sound")" //"woof"
+ * ```
+ *
+ * ###Multiple Inheritance / Mixins
+ *
+ * declare also allows the use of multiple super classes.
+ * This is useful if you have generic classes that provide functionality but shouldnt be used on their own.
+ *
+ * Lets declare a mixin that allows us to watch for property changes.
+ *
+ * ```
+ * //Notice that we set up the functions outside of declare because we can reuse them
+ *
+ * function _set(prop, val) {
+ * //get the old value
+ * var oldVal = this.get(prop);
+ * //call super to actually set the property
+ * var ret = this._super(arguments);
+ * //call our handlers
+ * this.__callHandlers(prop, oldVal, val);
+ * return ret;
+ * }
+ *
+ * function _callHandlers(prop, oldVal, newVal) {
+ * //get our handlers for the property
+ * var handlers = this.__watchers[prop], l;
+ * //if the handlers exist and their length does not equal 0 then we call loop through them
+ * if (handlers && (l = handlers.length) !== 0) {
+ * for (var i = 0; i < l; i++) {
+ * //call the handler
+ * handlers[i].call(null, prop, oldVal, newVal);
+ * }
+ * }
+ * }
+ *
+ *
+ * //the watch function
+ * function _watch(prop, handler) {
+ * if ("function" !== typeof handler) {
+ * //if its not a function then its an invalid handler
+ * throw new TypeError("Invalid handler.");
+ * }
+ * if (!this.__watchers[prop]) {
+ * //create the watchers if it doesnt exist
+ * this.__watchers[prop] = [handler];
+ * } else {
+ * //otherwise just add it to the handlers array
+ * this.__watchers[prop].push(handler);
+ * }
+ * }
+ *
+ * function _unwatch(prop, handler) {
+ * if ("function" !== typeof handler) {
+ * throw new TypeError("Invalid handler.");
+ * }
+ * var handlers = this.__watchers[prop], index;
+ * if (handlers && (index = handlers.indexOf(handler)) !== -1) {
+ * //remove the handler if it is found
+ * handlers.splice(index, 1);
+ * }
+ * }
+ *
+ * declare({
+ * instance:{
+ * constructor:function () {
+ * this._super(arguments);
+ * //set up our watchers
+ * this.__watchers = {};
+ * },
+ *
+ * //override the default set function so we can watch values
+ * "set":_set,
+ * //set up our callhandlers function
+ * __callHandlers:_callHandlers,
+ * //add the watch function
+ * watch:_watch,
+ * //add the unwatch function
+ * unwatch:_unwatch
+ * },
+ *
+ * "static":{
+ *
+ * init:function () {
+ * this._super(arguments);
+ * this.__watchers = {};
+ * },
+ * //override the default set function so we can watch values
+ * "set":_set,
+ * //set our callHandlers function
+ * __callHandlers:_callHandlers,
+ * //add the watch
+ * watch:_watch,
+ * //add the unwatch function
+ * unwatch:_unwatch
+ * }
+ * })
+ *
+ * ```
+ *
+ * Now lets use the mixin
+ *
+ * ```
+ * var WatchDog = declare([Dog, WatchMixin]);
+ *
+ * var watchDog = new WatchDog();
+ * //create our handler
+ * function watch(id, oldVal, newVal) {
+ * console.log("watchdog's %s was %s, now %s", id, oldVal, newVal);
+ * }
+ *
+ * //watch for property changes
+ * watchDog.watch("type", watch);
+ * watchDog.watch("color", watch);
+ * watchDog.watch("sound", watch);
+ *
+ * //now set the properties each handler will be called
+ * watchDog.set("type", "newDog");
+ * watchDog.set("color", "newColor");
+ * watchDog.set("sound", "newSound");
+ *
+ *
+ * //unwatch the property changes
+ * watchDog.unwatch("type", watch);
+ * watchDog.unwatch("color", watch);
+ * watchDog.unwatch("sound", watch);
+ *
+ * //no handlers will be called this time
+ * watchDog.set("type", "newDog");
+ * watchDog.set("color", "newColor");
+ * watchDog.set("sound", "newSound");
+ *
+ *
+ * ```
+ *
+ * ###Accessing static methods and properties witin an instance.
+ *
+ * To access static properties on an instance use the `_static` property which is a reference to your constructor.
+ *
+ * For example if your in your constructor and you want to have configurable default values.
+ *
+ * ```
+ * consturctor : function constructor(opts){
+ * this.opts = opts || {};
+ * this._type = opts.type || this._static.DEFAULT_TYPE;
+ * }
+ * ```
+ *
+ *
+ *
+ * ###Creating a new instance of within an instance.
+ *
+ * Often times you want to create a new instance of an object within an instance. If your subclassed however you cannot return a new instance of the parent class as it will not be the right sub class. `declare` provides a way around this by setting the `_static` property on each isntance of the class.
+ *
+ * Lets add a reproduce method `Mammal`
+ *
+ * ```
+ * reproduce : function(options){
+ * return new this._static(options);
+ * }
+ * ```
+ *
+ * Now in each subclass you can call reproduce and get the proper type.
+ *
+ * ```
+ * var myDog = new Dog();
+ * var myDogsChild = myDog.reproduce();
+ *
+ * myDogsChild instanceof Dog; //true
+ * ```
+ *
+ * ###Using the `as`
+ *
+ * `declare` also provides an `as` method which allows you to add your class to an object or if your using node.js you can pass in `module` and the class will be exported as the module.
+ *
+ * ```
+ * var animals = {};
+ *
+ * Mammal.as(animals, "Dog");
+ * Wolf.as(animals, "Wolf");
+ * Dog.as(animals, "Dog");
+ * Breed.as(animals, "Breed");
+ *
+ * var myDog = new animals.Dog();
+ *
+ * ```
+ *
+ * Or in node
+ *
+ * ```
+ * Mammal.as(exports, "Dog");
+ * Wolf.as(exports, "Wolf");
+ * Dog.as(exports, "Dog");
+ * Breed.as(exports, "Breed");
+ *
+ * ```
+ *
+ * To export a class as the `module` in node
+ *
+ * ```
+ * Mammal.as(module);
+ * ```
+ *
+ *
+ */
+ function createDeclared() {
+ var arraySlice = Array.prototype.slice, classCounter = 0, Base, forceNew = new Function();
+
+ var SUPER_REGEXP = /(super)/g;
+
+ function argsToArray(args, slice) {
+ slice = slice || 0;
+ return arraySlice.call(args, slice);
+ }
+
+ function isArray(obj) {
+ return Object.prototype.toString.call(obj) === "[object Array]";
+ }
+
+ function isObject(obj) {
+ var undef;
+ return obj !== null && obj !== undef && typeof obj === "object";
+ }
+
+ function isHash(obj) {
+ var ret = isObject(obj);
+ return ret && obj.constructor === Object;
+ }
+
+ var isArguments = function _isArguments(object) {
+ return Object.prototype.toString.call(object) === '[object Arguments]';
+ };
+
+ if (!isArguments(arguments)) {
+ isArguments = function _isArguments(obj) {
+ return !!(obj && obj.hasOwnProperty("callee"));
+ };
+ }
+
+ function indexOf(arr, item) {
+ if (arr && arr.length) {
+ for (var i = 0, l = arr.length; i < l; i++) {
+ if (arr[i] === item) {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ function merge(target, source, exclude) {
+ var name, s;
+ for (name in source) {
+ if (source.hasOwnProperty(name) && indexOf(exclude, name) === -1) {
+ s = source[name];
+ if (!(name in target) || (target[name] !== s)) {
+ target[name] = s;
+ }
+ }
+ }
+ return target;
+ }
+
+ function callSuper(args, a) {
+ var meta = this.__meta,
+ supers = meta.supers,
+ l = supers.length, superMeta = meta.superMeta, pos = superMeta.pos;
+ if (l > pos) {
+ args = !args ? [] : (!isArguments(args) && !isArray(args)) ? [args] : args;
+ var name = superMeta.name, f = superMeta.f, m;
+ do {
+ m = supers[pos][name];
+ if ("function" === typeof m && (m = m._f || m) !== f) {
+ superMeta.pos = 1 + pos;
+ return m.apply(this, args);
+ }
+ } while (l > ++pos);
+ }
+
+ return null;
+ }
+
+ function getSuper() {
+ var meta = this.__meta,
+ supers = meta.supers,
+ l = supers.length, superMeta = meta.superMeta, pos = superMeta.pos;
+ if (l > pos) {
+ var name = superMeta.name, f = superMeta.f, m;
+ do {
+ m = supers[pos][name];
+ if ("function" === typeof m && (m = m._f || m) !== f) {
+ superMeta.pos = 1 + pos;
+ return m.bind(this);
+ }
+ } while (l > ++pos);
+ }
+ return null;
+ }
+
+ function getter(name) {
+ var getters = this.__getters__;
+ if (getters.hasOwnProperty(name)) {
+ return getters[name].apply(this);
+ } else {
+ return this[name];
+ }
+ }
+
+ function setter(name, val) {
+ var setters = this.__setters__;
+ if (isHash(name)) {
+ for (var i in name) {
+ var prop = name[i];
+ if (setters.hasOwnProperty(i)) {
+ setters[name].call(this, prop);
+ } else {
+ this[i] = prop;
+ }
+ }
+ } else {
+ if (setters.hasOwnProperty(name)) {
+ return setters[name].apply(this, argsToArray(arguments, 1));
+ } else {
+ return this[name] = val;
+ }
+ }
+ }
+
+
+ function defaultFunction() {
+ var meta = this.__meta || {},
+ supers = meta.supers,
+ l = supers.length, superMeta = meta.superMeta, pos = superMeta.pos;
+ if (l > pos) {
+ var name = superMeta.name, f = superMeta.f, m;
+ do {
+ m = supers[pos][name];
+ if ("function" === typeof m && (m = m._f || m) !== f) {
+ superMeta.pos = 1 + pos;
+ return m.apply(this, arguments);
+ }
+ } while (l > ++pos);
+ }
+ return null;
+ }
+
+
+ function functionWrapper(f, name) {
+ if (f.toString().match(SUPER_REGEXP)) {
+ var wrapper = function wrapper() {
+ var ret, meta = this.__meta || {};
+ var orig = meta.superMeta;
+ meta.superMeta = {f: f, pos: 0, name: name};
+ switch (arguments.length) {
+ case 0:
+ ret = f.call(this);
+ break;
+ case 1:
+ ret = f.call(this, arguments[0]);
+ break;
+ case 2:
+ ret = f.call(this, arguments[0], arguments[1]);
+ break;
+
+ case 3:
+ ret = f.call(this, arguments[0], arguments[1], arguments[2]);
+ break;
+ default:
+ ret = f.apply(this, arguments);
+ }
+ meta.superMeta = orig;
+ return ret;
+ };
+ wrapper._f = f;
+ return wrapper;
+ } else {
+ f._f = f;
+ return f;
+ }
+ }
+
+ function defineMixinProps(child, proto) {
+
+ var operations = proto.setters || {}, __setters = child.__setters__, __getters = child.__getters__;
+ for (var i in operations) {
+ if (!__setters.hasOwnProperty(i)) { //make sure that the setter isnt already there
+ __setters[i] = operations[i];
+ }
+ }
+ operations = proto.getters || {};
+ for (i in operations) {
+ if (!__getters.hasOwnProperty(i)) { //make sure that the setter isnt already there
+ __getters[i] = operations[i];
+ }
+ }
+ for (var j in proto) {
+ if (j !== "getters" && j !== "setters") {
+ var p = proto[j];
+ if ("function" === typeof p) {
+ if (!child.hasOwnProperty(j)) {
+ child[j] = functionWrapper(defaultFunction, j);
+ }
+ } else {
+ child[j] = p;
+ }
+ }
+ }
+ }
+
+ function mixin() {
+ var args = argsToArray(arguments), l = args.length;
+ var child = this.prototype;
+ var childMeta = child.__meta, thisMeta = this.__meta, bases = child.__meta.bases, staticBases = bases.slice(),
+ staticSupers = thisMeta.supers || [], supers = childMeta.supers || [];
+ for (var i = 0; i < l; i++) {
+ var m = args[i], mProto = m.prototype;
+ var protoMeta = mProto.__meta, meta = m.__meta;
+ !protoMeta && (protoMeta = (mProto.__meta = {proto: mProto || {}}));
+ !meta && (meta = (m.__meta = {proto: m.__proto__ || {}}));
+ defineMixinProps(child, protoMeta.proto || {});
+ defineMixinProps(this, meta.proto || {});
+ //copy the bases for static,
+
+ mixinSupers(m.prototype, supers, bases);
+ mixinSupers(m, staticSupers, staticBases);
+ }
+ return this;
+ }
+
+ function mixinSupers(sup, arr, bases) {
+ var meta = sup.__meta;
+ !meta && (meta = (sup.__meta = {}));
+ var unique = sup.__meta.unique;
+ !unique && (meta.unique = "declare" + ++classCounter);
+ //check it we already have this super mixed into our prototype chain
+ //if true then we have already looped their supers!
+ if (indexOf(bases, unique) === -1) {
+ //add their id to our bases
+ bases.push(unique);
+ var supers = sup.__meta.supers || [], i = supers.length - 1 || 0;
+ while (i >= 0) {
+ mixinSupers(supers[i--], arr, bases);
+ }
+ arr.unshift(sup);
+ }
+ }
+
+ function defineProps(child, proto) {
+ var operations = proto.setters,
+ __setters = child.__setters__,
+ __getters = child.__getters__;
+ if (operations) {
+ for (var i in operations) {
+ __setters[i] = operations[i];
+ }
+ }
+ operations = proto.getters || {};
+ if (operations) {
+ for (i in operations) {
+ __getters[i] = operations[i];
+ }
+ }
+ for (i in proto) {
+ if (i != "getters" && i != "setters") {
+ var f = proto[i];
+ if ("function" === typeof f) {
+ var meta = f.__meta || {};
+ if (!meta.isConstructor) {
+ child[i] = functionWrapper(f, i);
+ } else {
+ child[i] = f;
+ }
+ } else {
+ child[i] = f;
+ }
+ }
+ }
+
+ }
+
+ function _export(obj, name) {
+ if (obj && name) {
+ obj[name] = this;
+ } else {
+ obj.exports = obj = this;
+ }
+ return this;
+ }
+
+ function extend(proto) {
+ return declare(this, proto);
+ }
+
+ function getNew(ctor) {
+ // create object with correct prototype using a do-nothing
+ // constructor
+ forceNew.prototype = ctor.prototype;
+ var t = new forceNew();
+ forceNew.prototype = null; // clean up
+ return t;
+ }
+
+
+ function __declare(child, sup, proto) {
+ var childProto = {}, supers = [];
+ var unique = "declare" + ++classCounter, bases = [], staticBases = [];
+ var instanceSupers = [], staticSupers = [];
+ var meta = {
+ supers: instanceSupers,
+ unique: unique,
+ bases: bases,
+ superMeta: {
+ f: null,
+ pos: 0,
+ name: null
+ }
+ };
+ var childMeta = {
+ supers: staticSupers,
+ unique: unique,
+ bases: staticBases,
+ isConstructor: true,
+ superMeta: {
+ f: null,
+ pos: 0,
+ name: null
+ }
+ };
+
+ if (isHash(sup) && !proto) {
+ proto = sup;
+ sup = Base;
+ }
+
+ if ("function" === typeof sup || isArray(sup)) {
+ supers = isArray(sup) ? sup : [sup];
+ sup = supers.shift();
+ child.__meta = childMeta;
+ childProto = getNew(sup);
+ childProto.__meta = meta;
+ childProto.__getters__ = merge({}, childProto.__getters__ || {});
+ childProto.__setters__ = merge({}, childProto.__setters__ || {});
+ child.__getters__ = merge({}, child.__getters__ || {});
+ child.__setters__ = merge({}, child.__setters__ || {});
+ mixinSupers(sup.prototype, instanceSupers, bases);
+ mixinSupers(sup, staticSupers, staticBases);
+ } else {
+ child.__meta = childMeta;
+ childProto.__meta = meta;
+ childProto.__getters__ = childProto.__getters__ || {};
+ childProto.__setters__ = childProto.__setters__ || {};
+ child.__getters__ = child.__getters__ || {};
+ child.__setters__ = child.__setters__ || {};
+ }
+ child.prototype = childProto;
+ if (proto) {
+ var instance = meta.proto = proto.instance || {};
+ var stat = childMeta.proto = proto.static || {};
+ stat.init = stat.init || defaultFunction;
+ defineProps(childProto, instance);
+ defineProps(child, stat);
+ if (!instance.hasOwnProperty("constructor")) {
+ childProto.constructor = instance.constructor = functionWrapper(defaultFunction, "constructor");
+ } else {
+ childProto.constructor = functionWrapper(instance.constructor, "constructor");
+ }
+ } else {
+ meta.proto = {};
+ childMeta.proto = {};
+ child.init = functionWrapper(defaultFunction, "init");
+ childProto.constructor = functionWrapper(defaultFunction, "constructor");
+ }
+ if (supers.length) {
+ mixin.apply(child, supers);
+ }
+ if (sup) {
+ //do this so we mixin our super methods directly but do not ov
+ merge(child, merge(merge({}, sup), child));
+ }
+ childProto._super = child._super = callSuper;
+ childProto._getSuper = child._getSuper = getSuper;
+ childProto._static = child;
+ }
+
+ function declare(sup, proto) {
+ function declared() {
+ switch (arguments.length) {
+ case 0:
+ this.constructor.call(this);
+ break;
+ case 1:
+ this.constructor.call(this, arguments[0]);
+ break;
+ case 2:
+ this.constructor.call(this, arguments[0], arguments[1]);
+ break;
+ case 3:
+ this.constructor.call(this, arguments[0], arguments[1], arguments[2]);
+ break;
+ default:
+ this.constructor.apply(this, arguments);
+ }
+ }
+
+ __declare(declared, sup, proto);
+ return declared.init() || declared;
+ }
+
+ function singleton(sup, proto) {
+ var retInstance;
+
+ function declaredSingleton() {
+ if (!retInstance) {
+ this.constructor.apply(this, arguments);
+ retInstance = this;
+ }
+ return retInstance;
+ }
+
+ __declare(declaredSingleton, sup, proto);
+ return declaredSingleton.init() || declaredSingleton;
+ }
+
+ Base = declare({
+ instance: {
+ "get": getter,
+ "set": setter
+ },
+
+ "static": {
+ "get": getter,
+ "set": setter,
+ mixin: mixin,
+ extend: extend,
+ as: _export
+ }
+ });
+
+ declare.singleton = singleton;
+ return declare;
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = createDeclared();
+ }
+ } else {}
+}());
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+module.exports = __webpack_require__(/*! ./declare.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/declare.js");
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js":
+/*!********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js ***!
+ \********************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+ /*global extender is, dateExtended*/
+
+ function defineExtended(extender) {
+
+
+ var merge = (function merger() {
+ function _merge(target, source) {
+ var name, s;
+ for (name in source) {
+ if (source.hasOwnProperty(name)) {
+ s = source[name];
+ if (!(name in target) || (target[name] !== s)) {
+ target[name] = s;
+ }
+ }
+ }
+ return target;
+ }
+
+ return function merge(obj) {
+ if (!obj) {
+ obj = {};
+ }
+ for (var i = 1, l = arguments.length; i < l; i++) {
+ _merge(obj, arguments[i]);
+ }
+ return obj; // Object
+ };
+ }());
+
+ function getExtended() {
+
+ var loaded = {};
+
+
+ //getInitial instance;
+ var extended = extender.define();
+ extended.expose({
+ register: function register(alias, extendWith) {
+ if (!extendWith) {
+ extendWith = alias;
+ alias = null;
+ }
+ var type = typeof extendWith;
+ if (alias) {
+ extended[alias] = extendWith;
+ } else if (extendWith && type === "function") {
+ extended.extend(extendWith);
+ } else if (type === "object") {
+ extended.expose(extendWith);
+ } else {
+ throw new TypeError("extended.register must be called with an extender function");
+ }
+ return extended;
+ },
+
+ define: function () {
+ return extender.define.apply(extender, arguments);
+ }
+ });
+
+ return extended;
+ }
+
+ function extended() {
+ return getExtended();
+ }
+
+ extended.define = function define() {
+ return extender.define.apply(extender, arguments);
+ };
+
+ return extended;
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineExtended(__webpack_require__(/*! extender */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extender/index.js"));
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extender/extender.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extender/extender.js ***!
+ \***********************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ /*jshint strict:false*/
+
+
+ /**
+ *
+ * @projectName extender
+ * @github http://github.com/doug-martin/extender
+ * @header
+ * [![build status](https://secure.travis-ci.org/doug-martin/extender.png)](http://travis-ci.org/doug-martin/extender)
+ * # Extender
+ *
+ * `extender` is a library that helps in making chainable APIs, by creating a function that accepts different values and returns an object decorated with functions based on the type.
+ *
+ * ## Why Is Extender Different?
+ *
+ * Extender is different than normal chaining because is does more than return `this`. It decorates your values in a type safe manner.
+ *
+ * For example if you return an array from a string based method then the returned value will be decorated with array methods and not the string methods. This allow you as the developer to focus on your API and not worrying about how to properly build and connect your API.
+ *
+ *
+ * ## Installation
+ *
+ * ```
+ * npm install extender
+ * ```
+ *
+ * Or [download the source](https://raw.github.com/doug-martin/extender/master/extender.js) ([minified](https://raw.github.com/doug-martin/extender/master/extender-min.js))
+ *
+ * **Note** `extender` depends on [`declare.js`](http://doug-martin.github.com/declare.js/).
+ *
+ * ### Requirejs
+ *
+ * To use with requirejs place the `extend` source in the root scripts directory
+ *
+ * ```javascript
+ *
+ * define(["extender"], function(extender){
+ * });
+ *
+ * ```
+ *
+ *
+ * ## Usage
+ *
+ * **`extender.define(tester, decorations)`**
+ *
+ * To create your own extender call the `extender.define` function.
+ *
+ * This function accepts an optional tester which is used to determine a value should be decorated with the specified `decorations`
+ *
+ * ```javascript
+ * function isString(obj) {
+ * return !isUndefinedOrNull(obj) && (typeof obj === "string" || obj instanceof String);
+ * }
+ *
+ *
+ * var myExtender = extender.define(isString, {
+ * multiply: function (str, times) {
+ * var ret = str;
+ * for (var i = 1; i < times; i++) {
+ * ret += str;
+ * }
+ * return ret;
+ * },
+ * toArray: function (str, delim) {
+ * delim = delim || "";
+ * return str.split(delim);
+ * }
+ * });
+ *
+ * myExtender("hello").multiply(2).value(); //hellohello
+ *
+ * ```
+ *
+ * If you do not specify a tester function and just pass in an object of `functions` then all values passed in will be decorated with methods.
+ *
+ * ```javascript
+ *
+ * function isUndefined(obj) {
+ * var undef;
+ * return obj === undef;
+ * }
+ *
+ * function isUndefinedOrNull(obj) {
+ * var undef;
+ * return obj === undef || obj === null;
+ * }
+ *
+ * function isArray(obj) {
+ * return Object.prototype.toString.call(obj) === "[object Array]";
+ * }
+ *
+ * function isBoolean(obj) {
+ * var undef, type = typeof obj;
+ * return !isUndefinedOrNull(obj) && type === "boolean" || type === "Boolean";
+ * }
+ *
+ * function isString(obj) {
+ * return !isUndefinedOrNull(obj) && (typeof obj === "string" || obj instanceof String);
+ * }
+ *
+ * var myExtender = extender.define({
+ * isUndefined : isUndefined,
+ * isUndefinedOrNull : isUndefinedOrNull,
+ * isArray : isArray,
+ * isBoolean : isBoolean,
+ * isString : isString
+ * });
+ *
+ * ```
+ *
+ * To use
+ *
+ * ```
+ * var undef;
+ * myExtender("hello").isUndefined().value(); //false
+ * myExtender(undef).isUndefined().value(); //true
+ * ```
+ *
+ * You can also chain extenders so that they accept multiple types and decorates accordingly.
+ *
+ * ```javascript
+ * myExtender
+ * .define(isArray, {
+ * pluck: function (arr, m) {
+ * var ret = [];
+ * for (var i = 0, l = arr.length; i < l; i++) {
+ * ret.push(arr[i][m]);
+ * }
+ * return ret;
+ * }
+ * })
+ * .define(isBoolean, {
+ * invert: function (val) {
+ * return !val;
+ * }
+ * });
+ *
+ * myExtender([{a: "a"},{a: "b"},{a: "c"}]).pluck("a").value(); //["a", "b", "c"]
+ * myExtender("I love javascript!").toArray(/\s+/).pluck("0"); //["I", "l", "j"]
+ *
+ * ```
+ *
+ * Notice that we reuse the same extender as defined above.
+ *
+ * **Return Values**
+ *
+ * When creating an extender if you return a value from one of the decoration functions then that value will also be decorated. If you do not return any values then the extender will be returned.
+ *
+ * **Default decoration methods**
+ *
+ * By default every value passed into an extender is decorated with the following methods.
+ *
+ * * `value` : The value this extender represents.
+ * * `eq(otherValue)` : Tests strict equality of the currently represented value to the `otherValue`
+ * * `neq(oterValue)` : Tests strict inequality of the currently represented value.
+ * * `print` : logs the current value to the console.
+ *
+ * **Extender initialization**
+ *
+ * When creating an extender you can also specify a constructor which will be invoked with the current value.
+ *
+ * ```javascript
+ * myExtender.define(isString, {
+ * constructor : function(val){
+ * //set our value to the string trimmed
+ * this._value = val.trimRight().trimLeft();
+ * }
+ * });
+ * ```
+ *
+ * **`noWrap`**
+ *
+ * `extender` also allows you to specify methods that should not have the value wrapped providing a cleaner exit function other than `value()`.
+ *
+ * For example suppose you have an API that allows you to build a validator, rather than forcing the user to invoke the `value` method you could add a method called `validator` which makes more syntactic sense.
+ *
+ * ```
+ *
+ * var myValidator = extender.define({
+ * //chainable validation methods
+ * //...
+ * //end chainable validation methods
+ *
+ * noWrap : {
+ * validator : function(){
+ * //return your validator
+ * }
+ * }
+ * });
+ *
+ * myValidator().isNotNull().isEmailAddress().validator(); //now you dont need to call .value()
+ *
+ *
+ * ```
+ * **`extender.extend(extendr)`**
+ *
+ * You may also compose extenders through the use of `extender.extend(extender)`, which will return an entirely new extender that is the composition of extenders.
+ *
+ * Suppose you have the following two extenders.
+ *
+ * ```javascript
+ * var myExtender = extender
+ * .define({
+ * isFunction: is.function,
+ * isNumber: is.number,
+ * isString: is.string,
+ * isDate: is.date,
+ * isArray: is.array,
+ * isBoolean: is.boolean,
+ * isUndefined: is.undefined,
+ * isDefined: is.defined,
+ * isUndefinedOrNull: is.undefinedOrNull,
+ * isNull: is.null,
+ * isArguments: is.arguments,
+ * isInstanceOf: is.instanceOf,
+ * isRegExp: is.regExp
+ * });
+ * var myExtender2 = extender.define(is.array, {
+ * pluck: function (arr, m) {
+ * var ret = [];
+ * for (var i = 0, l = arr.length; i < l; i++) {
+ * ret.push(arr[i][m]);
+ * }
+ * return ret;
+ * },
+ *
+ * noWrap: {
+ * pluckPlain: function (arr, m) {
+ * var ret = [];
+ * for (var i = 0, l = arr.length; i < l; i++) {
+ * ret.push(arr[i][m]);
+ * }
+ * return ret;
+ * }
+ * }
+ * });
+ *
+ *
+ * ```
+ *
+ * And you do not want to alter either of them but instead what to create a third that is the union of the two.
+ *
+ *
+ * ```javascript
+ * var composed = extender.extend(myExtender).extend(myExtender2);
+ * ```
+ * So now you can use the new extender with the joined functionality if `myExtender` and `myExtender2`.
+ *
+ * ```javascript
+ * var extended = composed([
+ * {a: "a"},
+ * {a: "b"},
+ * {a: "c"}
+ * ]);
+ * extended.isArray().value(); //true
+ * extended.pluck("a").value(); // ["a", "b", "c"]);
+ *
+ * ```
+ *
+ * **Note** `myExtender` and `myExtender2` will **NOT** be altered.
+ *
+ * **`extender.expose(methods)`**
+ *
+ * The `expose` method allows you to add methods to your extender that are not wrapped or automatically chained by exposing them on the extender directly.
+ *
+ * ```
+ * var isMethods = {
+ * isFunction: is.function,
+ * isNumber: is.number,
+ * isString: is.string,
+ * isDate: is.date,
+ * isArray: is.array,
+ * isBoolean: is.boolean,
+ * isUndefined: is.undefined,
+ * isDefined: is.defined,
+ * isUndefinedOrNull: is.undefinedOrNull,
+ * isNull: is.null,
+ * isArguments: is.arguments,
+ * isInstanceOf: is.instanceOf,
+ * isRegExp: is.regExp
+ * };
+ *
+ * var myExtender = extender.define(isMethods).expose(isMethods);
+ *
+ * myExtender.isArray([]); //true
+ * myExtender([]).isArray([]).value(); //true
+ *
+ * ```
+ *
+ *
+ * **Using `instanceof`**
+ *
+ * When using extenders you can test if a value is an `instanceof` of an extender by using the instanceof operator.
+ *
+ * ```javascript
+ * var str = myExtender("hello");
+ *
+ * str instanceof myExtender; //true
+ * ```
+ *
+ * ## Examples
+ *
+ * To see more examples click [here](https://github.com/doug-martin/extender/tree/master/examples)
+ */
+ function defineExtender(declare) {
+
+
+ var slice = Array.prototype.slice, undef;
+
+ function indexOf(arr, item) {
+ if (arr && arr.length) {
+ for (var i = 0, l = arr.length; i < l; i++) {
+ if (arr[i] === item) {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ function isArray(obj) {
+ return Object.prototype.toString.call(obj) === "[object Array]";
+ }
+
+ var merge = (function merger() {
+ function _merge(target, source, exclude) {
+ var name, s;
+ for (name in source) {
+ if (source.hasOwnProperty(name) && indexOf(exclude, name) === -1) {
+ s = source[name];
+ if (!(name in target) || (target[name] !== s)) {
+ target[name] = s;
+ }
+ }
+ }
+ return target;
+ }
+
+ return function merge(obj) {
+ if (!obj) {
+ obj = {};
+ }
+ var l = arguments.length;
+ var exclude = arguments[arguments.length - 1];
+ if (isArray(exclude)) {
+ l--;
+ } else {
+ exclude = [];
+ }
+ for (var i = 1; i < l; i++) {
+ _merge(obj, arguments[i], exclude);
+ }
+ return obj; // Object
+ };
+ }());
+
+
+ function extender(supers) {
+ supers = supers || [];
+ var Base = declare({
+ instance: {
+ constructor: function (value) {
+ this._value = value;
+ },
+
+ value: function () {
+ return this._value;
+ },
+
+ eq: function eq(val) {
+ return this["__extender__"](this._value === val);
+ },
+
+ neq: function neq(other) {
+ return this["__extender__"](this._value !== other);
+ },
+ print: function () {
+ console.log(this._value);
+ return this;
+ }
+ }
+ }), defined = [];
+
+ function addMethod(proto, name, func) {
+ if ("function" !== typeof func) {
+ throw new TypeError("when extending type you must provide a function");
+ }
+ var extendedMethod;
+ if (name === "constructor") {
+ extendedMethod = function () {
+ this._super(arguments);
+ func.apply(this, arguments);
+ };
+ } else {
+ extendedMethod = function extendedMethod() {
+ var args = slice.call(arguments);
+ args.unshift(this._value);
+ var ret = func.apply(this, args);
+ return ret !== undef ? this["__extender__"](ret) : this;
+ };
+ }
+ proto[name] = extendedMethod;
+ }
+
+ function addNoWrapMethod(proto, name, func) {
+ if ("function" !== typeof func) {
+ throw new TypeError("when extending type you must provide a function");
+ }
+ var extendedMethod;
+ if (name === "constructor") {
+ extendedMethod = function () {
+ this._super(arguments);
+ func.apply(this, arguments);
+ };
+ } else {
+ extendedMethod = function extendedMethod() {
+ var args = slice.call(arguments);
+ args.unshift(this._value);
+ return func.apply(this, args);
+ };
+ }
+ proto[name] = extendedMethod;
+ }
+
+ function decorateProto(proto, decoration, nowrap) {
+ for (var i in decoration) {
+ if (decoration.hasOwnProperty(i)) {
+ if (i !== "getters" && i !== "setters") {
+ if (i === "noWrap") {
+ decorateProto(proto, decoration[i], true);
+ } else if (nowrap) {
+ addNoWrapMethod(proto, i, decoration[i]);
+ } else {
+ addMethod(proto, i, decoration[i]);
+ }
+ } else {
+ proto[i] = decoration[i];
+ }
+ }
+ }
+ }
+
+ function _extender(obj) {
+ var ret = obj, i, l;
+ if (!(obj instanceof Base)) {
+ var OurBase = Base;
+ for (i = 0, l = defined.length; i < l; i++) {
+ var definer = defined[i];
+ if (definer[0](obj)) {
+ OurBase = OurBase.extend({instance: definer[1]});
+ }
+ }
+ ret = new OurBase(obj);
+ ret["__extender__"] = _extender;
+ }
+ return ret;
+ }
+
+ function always() {
+ return true;
+ }
+
+ function define(tester, decorate) {
+ if (arguments.length) {
+ if (typeof tester === "object") {
+ decorate = tester;
+ tester = always;
+ }
+ decorate = decorate || {};
+ var proto = {};
+ decorateProto(proto, decorate);
+ //handle browsers like which skip over the constructor while looping
+ if (!proto.hasOwnProperty("constructor")) {
+ if (decorate.hasOwnProperty("constructor")) {
+ addMethod(proto, "constructor", decorate.constructor);
+ } else {
+ proto.constructor = function () {
+ this._super(arguments);
+ };
+ }
+ }
+ defined.push([tester, proto]);
+ }
+ return _extender;
+ }
+
+ function extend(supr) {
+ if (supr && supr.hasOwnProperty("__defined__")) {
+ _extender["__defined__"] = defined = defined.concat(supr["__defined__"]);
+ }
+ merge(_extender, supr, ["define", "extend", "expose", "__defined__"]);
+ return _extender;
+ }
+
+ _extender.define = define;
+ _extender.extend = extend;
+ _extender.expose = function expose() {
+ var methods;
+ for (var i = 0, l = arguments.length; i < l; i++) {
+ methods = arguments[i];
+ if (typeof methods === "object") {
+ merge(_extender, methods, ["define", "extend", "expose", "__defined__"]);
+ }
+ }
+ return _extender;
+ };
+ _extender["__defined__"] = defined;
+
+
+ return _extender;
+ }
+
+ return {
+ define: function () {
+ return extender().define.apply(extender, arguments);
+ },
+
+ extend: function (supr) {
+ return extender().define().extend(supr);
+ }
+ };
+
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineExtender(__webpack_require__(/*! declare.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js"));
+
+ }
+ } else {}
+
+}).call(this);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extender/index.js":
+/*!********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extender/index.js ***!
+ \********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+module.exports = __webpack_require__(/*! ./extender.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extender/extender.js");
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/function-extended/index.js":
+/*!*****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/function-extended/index.js ***!
+ \*****************************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+
+ function defineFunction(extended, is, args) {
+
+ var isArray = is.isArray,
+ isObject = is.isObject,
+ isString = is.isString,
+ isFunction = is.isFunction,
+ argsToArray = args.argsToArray;
+
+ function spreadArgs(f, args, scope) {
+ var ret;
+ switch ((args || []).length) {
+ case 0:
+ ret = f.call(scope);
+ break;
+ case 1:
+ ret = f.call(scope, args[0]);
+ break;
+ case 2:
+ ret = f.call(scope, args[0], args[1]);
+ break;
+ case 3:
+ ret = f.call(scope, args[0], args[1], args[2]);
+ break;
+ default:
+ ret = f.apply(scope, args);
+ }
+ return ret;
+ }
+
+ function hitch(scope, method, args) {
+ args = argsToArray(arguments, 2);
+ if ((isString(method) && !(method in scope))) {
+ throw new Error(method + " property not defined in scope");
+ } else if (!isString(method) && !isFunction(method)) {
+ throw new Error(method + " is not a function");
+ }
+ if (isString(method)) {
+ return function () {
+ var func = scope[method];
+ if (isFunction(func)) {
+ return spreadArgs(func, args.concat(argsToArray(arguments)), scope);
+ } else {
+ return func;
+ }
+ };
+ } else {
+ if (args.length) {
+ return function () {
+ return spreadArgs(method, args.concat(argsToArray(arguments)), scope);
+ };
+ } else {
+
+ return function () {
+ return spreadArgs(method, arguments, scope);
+ };
+ }
+ }
+ }
+
+
+ function applyFirst(method, args) {
+ args = argsToArray(arguments, 1);
+ if (!isString(method) && !isFunction(method)) {
+ throw new Error(method + " must be the name of a property or function to execute");
+ }
+ if (isString(method)) {
+ return function () {
+ var scopeArgs = argsToArray(arguments), scope = scopeArgs.shift();
+ var func = scope[method];
+ if (isFunction(func)) {
+ scopeArgs = args.concat(scopeArgs);
+ return spreadArgs(func, scopeArgs, scope);
+ } else {
+ return func;
+ }
+ };
+ } else {
+ return function () {
+ var scopeArgs = argsToArray(arguments), scope = scopeArgs.shift();
+ scopeArgs = args.concat(scopeArgs);
+ return spreadArgs(method, scopeArgs, scope);
+ };
+ }
+ }
+
+
+ function hitchIgnore(scope, method, args) {
+ args = argsToArray(arguments, 2);
+ if ((isString(method) && !(method in scope))) {
+ throw new Error(method + " property not defined in scope");
+ } else if (!isString(method) && !isFunction(method)) {
+ throw new Error(method + " is not a function");
+ }
+ if (isString(method)) {
+ return function () {
+ var func = scope[method];
+ if (isFunction(func)) {
+ return spreadArgs(func, args, scope);
+ } else {
+ return func;
+ }
+ };
+ } else {
+ return function () {
+ return spreadArgs(method, args, scope);
+ };
+ }
+ }
+
+
+ function hitchAll(scope) {
+ var funcs = argsToArray(arguments, 1);
+ if (!isObject(scope) && !isFunction(scope)) {
+ throw new TypeError("scope must be an object");
+ }
+ if (funcs.length === 1 && isArray(funcs[0])) {
+ funcs = funcs[0];
+ }
+ if (!funcs.length) {
+ funcs = [];
+ for (var k in scope) {
+ if (scope.hasOwnProperty(k) && isFunction(scope[k])) {
+ funcs.push(k);
+ }
+ }
+ }
+ for (var i = 0, l = funcs.length; i < l; i++) {
+ scope[funcs[i]] = hitch(scope, scope[funcs[i]]);
+ }
+ return scope;
+ }
+
+
+ function partial(method, args) {
+ args = argsToArray(arguments, 1);
+ if (!isString(method) && !isFunction(method)) {
+ throw new Error(method + " must be the name of a property or function to execute");
+ }
+ if (isString(method)) {
+ return function () {
+ var func = this[method];
+ if (isFunction(func)) {
+ var scopeArgs = args.concat(argsToArray(arguments));
+ return spreadArgs(func, scopeArgs, this);
+ } else {
+ return func;
+ }
+ };
+ } else {
+ return function () {
+ var scopeArgs = args.concat(argsToArray(arguments));
+ return spreadArgs(method, scopeArgs, this);
+ };
+ }
+ }
+
+ function curryFunc(f, execute) {
+ return function () {
+ var args = argsToArray(arguments);
+ return execute ? spreadArgs(f, arguments, this) : function () {
+ return spreadArgs(f, args.concat(argsToArray(arguments)), this);
+ };
+ };
+ }
+
+
+ function curry(depth, cb, scope) {
+ var f;
+ if (scope) {
+ f = hitch(scope, cb);
+ } else {
+ f = cb;
+ }
+ if (depth) {
+ var len = depth - 1;
+ for (var i = len; i >= 0; i--) {
+ f = curryFunc(f, i === len);
+ }
+ }
+ return f;
+ }
+
+ return extended
+ .define(isObject, {
+ bind: hitch,
+ bindAll: hitchAll,
+ bindIgnore: hitchIgnore,
+ curry: function (scope, depth, fn) {
+ return curry(depth, fn, scope);
+ }
+ })
+ .define(isFunction, {
+ bind: function (fn, obj) {
+ return spreadArgs(hitch, [obj, fn].concat(argsToArray(arguments, 2)), this);
+ },
+ bindIgnore: function (fn, obj) {
+ return spreadArgs(hitchIgnore, [obj, fn].concat(argsToArray(arguments, 2)), this);
+ },
+ partial: partial,
+ applyFirst: applyFirst,
+ curry: function (fn, num, scope) {
+ return curry(num, fn, scope);
+ },
+ noWrap: {
+ f: function () {
+ return this.value();
+ }
+ }
+ })
+ .define(isString, {
+ bind: function (str, scope) {
+ return hitch(scope, str);
+ },
+ bindIgnore: function (str, scope) {
+ return hitchIgnore(scope, str);
+ },
+ partial: partial,
+ applyFirst: applyFirst,
+ curry: function (fn, depth, scope) {
+ return curry(depth, fn, scope);
+ }
+ })
+ .expose({
+ bind: hitch,
+ bindAll: hitchAll,
+ bindIgnore: hitchIgnore,
+ partial: partial,
+ applyFirst: applyFirst,
+ curry: curry
+ });
+
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineFunction(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js"), __webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"), __webpack_require__(/*! arguments-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/arguments-extended/index.js"));
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/ht/index.js":
+/*!**************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/ht/index.js ***!
+ \**************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+
+ function defineHt(_) {
+
+
+ var hashFunction = function (key) {
+ if (typeof key === "string") {
+ return key;
+ } else if (typeof key === "object") {
+ return key.hashCode ? key.hashCode() : "" + key;
+ } else {
+ return "" + key;
+ }
+ };
+
+ var Bucket = _.declare({
+
+ instance: {
+
+ constructor: function () {
+ this.__entries = [];
+ this.__keys = [];
+ this.__values = [];
+ },
+
+ pushValue: function (key, value) {
+ this.__keys.push(key);
+ this.__values.push(value);
+ this.__entries.push({key: key, value: value});
+ return value;
+ },
+
+ remove: function (key) {
+ var ret = null, map = this.__entries, val, keys = this.__keys, vals = this.__values;
+ var i = map.length - 1;
+ for (; i >= 0; i--) {
+ if (!!(val = map[i]) && val.key === key) {
+ map.splice(i, 1);
+ keys.splice(i, 1);
+ vals.splice(i, 1);
+ return val.value;
+ }
+ }
+ return ret;
+ },
+
+ "set": function (key, value) {
+ var ret = null, map = this.__entries, vals = this.__values;
+ var i = map.length - 1;
+ for (; i >= 0; i--) {
+ var val = map[i];
+ if (val && key === val.key) {
+ vals[i] = value;
+ val.value = value;
+ ret = value;
+ break;
+ }
+ }
+ if (!ret) {
+ map.push({key: key, value: value});
+ }
+ return ret;
+ },
+
+ find: function (key) {
+ var ret = null, map = this.__entries, val;
+ var i = map.length - 1;
+ for (; i >= 0; i--) {
+ val = map[i];
+ if (val && key === val.key) {
+ ret = val.value;
+ break;
+ }
+ }
+ return ret;
+ },
+
+ getEntrySet: function () {
+ return this.__entries;
+ },
+
+ getKeys: function () {
+ return this.__keys;
+ },
+
+ getValues: function (arr) {
+ return this.__values;
+ }
+ }
+ });
+
+ return _.declare({
+
+ instance: {
+
+ constructor: function () {
+ this.__map = {};
+ },
+
+ entrySet: function () {
+ var ret = [], map = this.__map;
+ for (var i in map) {
+ if (map.hasOwnProperty(i)) {
+ ret = ret.concat(map[i].getEntrySet());
+ }
+ }
+ return ret;
+ },
+
+ put: function (key, value) {
+ var hash = hashFunction(key);
+ var bucket = null;
+ if (!(bucket = this.__map[hash])) {
+ bucket = (this.__map[hash] = new Bucket());
+ }
+ bucket.pushValue(key, value);
+ return value;
+ },
+
+ remove: function (key) {
+ var hash = hashFunction(key), ret = null;
+ var bucket = this.__map[hash];
+ if (bucket) {
+ ret = bucket.remove(key);
+ }
+ return ret;
+ },
+
+ "get": function (key) {
+ var hash = hashFunction(key), ret = null, bucket;
+ if (!!(bucket = this.__map[hash])) {
+ ret = bucket.find(key);
+ }
+ return ret;
+ },
+
+ "set": function (key, value) {
+ var hash = hashFunction(key), ret = null, bucket = null, map = this.__map;
+ if (!!(bucket = map[hash])) {
+ ret = bucket.set(key, value);
+ } else {
+ ret = (map[hash] = new Bucket()).pushValue(key, value);
+ }
+ return ret;
+ },
+
+ contains: function (key) {
+ var hash = hashFunction(key), ret = false, bucket = null;
+ if (!!(bucket = this.__map[hash])) {
+ ret = !!(bucket.find(key));
+ }
+ return ret;
+ },
+
+ concat: function (hashTable) {
+ if (hashTable instanceof this._static) {
+ var ret = new this._static();
+ var otherEntrySet = hashTable.entrySet().concat(this.entrySet());
+ for (var i = otherEntrySet.length - 1; i >= 0; i--) {
+ var e = otherEntrySet[i];
+ ret.put(e.key, e.value);
+ }
+ return ret;
+ } else {
+ throw new TypeError("When joining hashtables the joining arg must be a HashTable");
+ }
+ },
+
+ filter: function (cb, scope) {
+ var es = this.entrySet(), ret = new this._static();
+ es = _.filter(es, cb, scope);
+ for (var i = es.length - 1; i >= 0; i--) {
+ var e = es[i];
+ ret.put(e.key, e.value);
+ }
+ return ret;
+ },
+
+ forEach: function (cb, scope) {
+ var es = this.entrySet();
+ _.forEach(es, cb, scope);
+ },
+
+ every: function (cb, scope) {
+ var es = this.entrySet();
+ return _.every(es, cb, scope);
+ },
+
+ map: function (cb, scope) {
+ var es = this.entrySet();
+ return _.map(es, cb, scope);
+ },
+
+ some: function (cb, scope) {
+ var es = this.entrySet();
+ return _.some(es, cb, scope);
+ },
+
+ reduce: function (cb, scope) {
+ var es = this.entrySet();
+ return _.reduce(es, cb, scope);
+ },
+
+ reduceRight: function (cb, scope) {
+ var es = this.entrySet();
+ return _.reduceRight(es, cb, scope);
+ },
+
+ clear: function () {
+ this.__map = {};
+ },
+
+ keys: function () {
+ var ret = [], map = this.__map;
+ for (var i in map) {
+ //if (map.hasOwnProperty(i)) {
+ ret = ret.concat(map[i].getKeys());
+ //}
+ }
+ return ret;
+ },
+
+ values: function () {
+ var ret = [], map = this.__map;
+ for (var i in map) {
+ //if (map.hasOwnProperty(i)) {
+ ret = ret.concat(map[i].getValues());
+ //}
+ }
+ return ret;
+ },
+
+ isEmpty: function () {
+ return this.keys().length === 0;
+ }
+ }
+
+ });
+
+
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineHt(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js")().register("declare", __webpack_require__(/*! declare.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js")).register(__webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js")).register(__webpack_require__(/*! array-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js")));
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-buffer/index.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-buffer/index.js ***!
+ \*********************************************************************************************/
+/***/ ((module) => {
+
+/*!
+ * Determine if an object is a Buffer
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+
+// The _isBuffer check is for Safari 5-7 support, because it's missing
+// Object.prototype.constructor. Remove this eventually
+module.exports = function (obj) {
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
+}
+
+function isBuffer (obj) {
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
+}
+
+// For Node v0.10 support. Remove this eventually.
+function isSlowBuffer (obj) {
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
+}
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js ***!
+ \***********************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+
+ function defineIsa(extended) {
+
+ var pSlice = Array.prototype.slice;
+
+ var hasOwn = Object.prototype.hasOwnProperty;
+ var toStr = Object.prototype.toString;
+
+ function argsToArray(args, slice) {
+ var i = -1, j = 0, l = args.length, ret = [];
+ slice = slice || 0;
+ i += slice;
+ while (++i < l) {
+ ret[j++] = args[i];
+ }
+ return ret;
+ }
+
+ function keys(obj) {
+ var ret = [];
+ for (var i in obj) {
+ if (hasOwn.call(obj, i)) {
+ ret.push(i);
+ }
+ }
+ return ret;
+ }
+
+ //taken from node js assert.js
+ //https://github.com/joyent/node/blob/master/lib/assert.js
+ function deepEqual(actual, expected) {
+ // 7.1. All identical values are equivalent, as determined by ===.
+ if (actual === expected) {
+ return true;
+
+ } else if (typeof Buffer !== "undefined" && Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
+ if (actual.length !== expected.length) {
+ return false;
+ }
+ for (var i = 0; i < actual.length; i++) {
+ if (actual[i] !== expected[i]) {
+ return false;
+ }
+ }
+ return true;
+
+ // 7.2. If the expected value is a Date object, the actual value is
+ // equivalent if it is also a Date object that refers to the same time.
+ } else if (isDate(actual) && isDate(expected)) {
+ return actual.getTime() === expected.getTime();
+
+ // 7.3 If the expected value is a RegExp object, the actual value is
+ // equivalent if it is also a RegExp object with the same source and
+ // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
+ } else if (isRegExp(actual) && isRegExp(expected)) {
+ return actual.source === expected.source &&
+ actual.global === expected.global &&
+ actual.multiline === expected.multiline &&
+ actual.lastIndex === expected.lastIndex &&
+ actual.ignoreCase === expected.ignoreCase;
+
+ // 7.4. Other pairs that do not both pass typeof value == 'object',
+ // equivalence is determined by ==.
+ } else if (isString(actual) && isString(expected) && actual !== expected) {
+ return false;
+ } else if (typeof actual !== 'object' && typeof expected !== 'object') {
+ return actual === expected;
+
+ // 7.5 For all other Object pairs, including Array objects, equivalence is
+ // determined by having the same number of owned properties (as verified
+ // with Object.prototype.hasOwnProperty.call), the same set of keys
+ // (although not necessarily the same order), equivalent values for every
+ // corresponding key, and an identical 'prototype' property. Note: this
+ // accounts for both named and indexed properties on Arrays.
+ } else {
+ return objEquiv(actual, expected);
+ }
+ }
+
+
+ function objEquiv(a, b) {
+ var key;
+ if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) {
+ return false;
+ }
+ // an identical 'prototype' property.
+ if (a.prototype !== b.prototype) {
+ return false;
+ }
+ //~~~I've managed to break Object.keys through screwy arguments passing.
+ // Converting to array solves the problem.
+ if (isArguments(a)) {
+ if (!isArguments(b)) {
+ return false;
+ }
+ a = pSlice.call(a);
+ b = pSlice.call(b);
+ return deepEqual(a, b);
+ }
+ try {
+ var ka = keys(a),
+ kb = keys(b),
+ i;
+ // having the same number of owned properties (keys incorporates
+ // hasOwnProperty)
+ if (ka.length !== kb.length) {
+ return false;
+ }
+ //the same set of keys (although not necessarily the same order),
+ ka.sort();
+ kb.sort();
+ //~~~cheap key test
+ for (i = ka.length - 1; i >= 0; i--) {
+ if (ka[i] !== kb[i]) {
+ return false;
+ }
+ }
+ //equivalent values for every corresponding key, and
+ //~~~possibly expensive deep test
+ for (i = ka.length - 1; i >= 0; i--) {
+ key = ka[i];
+ if (!deepEqual(a[key], b[key])) {
+ return false;
+ }
+ }
+ } catch (e) {//happens when one is a string literal and the other isn't
+ return false;
+ }
+ return true;
+ }
+
+
+ var isFunction = function (obj) {
+ return toStr.call(obj) === '[object Function]';
+ };
+
+ //ie hack
+ if ("undefined" !== typeof window && !isFunction(window.alert)) {
+ (function (alert) {
+ isFunction = function (obj) {
+ return toStr.call(obj) === '[object Function]' || obj === alert;
+ };
+ }(window.alert));
+ }
+
+ function isObject(obj) {
+ var undef;
+ return obj !== null && typeof obj === "object";
+ }
+
+ function isHash(obj) {
+ var ret = isObject(obj);
+ return ret && obj.constructor === Object && !obj.nodeType && !obj.setInterval;
+ }
+
+ function isEmpty(object) {
+ if (isArguments(object)) {
+ return object.length === 0;
+ } else if (isObject(object)) {
+ return keys(object).length === 0;
+ } else if (isString(object) || isArray(object)) {
+ return object.length === 0;
+ }
+ return true;
+ }
+
+ function isBoolean(obj) {
+ return obj === true || obj === false || toStr.call(obj) === "[object Boolean]";
+ }
+
+ function isUndefined(obj) {
+ return typeof obj === 'undefined';
+ }
+
+ function isDefined(obj) {
+ return !isUndefined(obj);
+ }
+
+ function isUndefinedOrNull(obj) {
+ return isUndefined(obj) || isNull(obj);
+ }
+
+ function isNull(obj) {
+ return obj === null;
+ }
+
+
+ var isArguments = function _isArguments(object) {
+ return toStr.call(object) === '[object Arguments]';
+ };
+
+ if (!isArguments(arguments)) {
+ isArguments = function _isArguments(obj) {
+ return !!(obj && hasOwn.call(obj, "callee"));
+ };
+ }
+
+
+ function isInstanceOf(obj, clazz) {
+ if (isFunction(clazz)) {
+ return obj instanceof clazz;
+ } else {
+ return false;
+ }
+ }
+
+ function isRegExp(obj) {
+ return toStr.call(obj) === '[object RegExp]';
+ }
+
+ var isArray = Array.isArray || function isArray(obj) {
+ return toStr.call(obj) === "[object Array]";
+ };
+
+ function isDate(obj) {
+ return toStr.call(obj) === '[object Date]';
+ }
+
+ function isString(obj) {
+ return toStr.call(obj) === '[object String]';
+ }
+
+ function isNumber(obj) {
+ return toStr.call(obj) === '[object Number]';
+ }
+
+ function isTrue(obj) {
+ return obj === true;
+ }
+
+ function isFalse(obj) {
+ return obj === false;
+ }
+
+ function isNotNull(obj) {
+ return !isNull(obj);
+ }
+
+ function isEq(obj, obj2) {
+ /*jshint eqeqeq:false*/
+ return obj == obj2;
+ }
+
+ function isNeq(obj, obj2) {
+ /*jshint eqeqeq:false*/
+ return obj != obj2;
+ }
+
+ function isSeq(obj, obj2) {
+ return obj === obj2;
+ }
+
+ function isSneq(obj, obj2) {
+ return obj !== obj2;
+ }
+
+ function isIn(obj, arr) {
+ if ((isArray(arr) && Array.prototype.indexOf) || isString(arr)) {
+ return arr.indexOf(obj) > -1;
+ } else if (isArray(arr)) {
+ for (var i = 0, l = arr.length; i < l; i++) {
+ if (isEq(obj, arr[i])) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ function isNotIn(obj, arr) {
+ return !isIn(obj, arr);
+ }
+
+ function isLt(obj, obj2) {
+ return obj < obj2;
+ }
+
+ function isLte(obj, obj2) {
+ return obj <= obj2;
+ }
+
+ function isGt(obj, obj2) {
+ return obj > obj2;
+ }
+
+ function isGte(obj, obj2) {
+ return obj >= obj2;
+ }
+
+ function isLike(obj, reg) {
+ if (isString(reg)) {
+ return ("" + obj).match(reg) !== null;
+ } else if (isRegExp(reg)) {
+ return reg.test(obj);
+ }
+ return false;
+ }
+
+ function isNotLike(obj, reg) {
+ return !isLike(obj, reg);
+ }
+
+ function contains(arr, obj) {
+ return isIn(obj, arr);
+ }
+
+ function notContains(arr, obj) {
+ return !isIn(obj, arr);
+ }
+
+ function containsAt(arr, obj, index) {
+ if (isArray(arr) && arr.length > index) {
+ return isEq(arr[index], obj);
+ }
+ return false;
+ }
+
+ function notContainsAt(arr, obj, index) {
+ if (isArray(arr)) {
+ return !isEq(arr[index], obj);
+ }
+ return false;
+ }
+
+ function has(obj, prop) {
+ return hasOwn.call(obj, prop);
+ }
+
+ function notHas(obj, prop) {
+ return !has(obj, prop);
+ }
+
+ function length(obj, l) {
+ if (has(obj, "length")) {
+ return obj.length === l;
+ }
+ return false;
+ }
+
+ function notLength(obj, l) {
+ if (has(obj, "length")) {
+ return obj.length !== l;
+ }
+ return false;
+ }
+
+ var isa = {
+ isFunction: isFunction,
+ isObject: isObject,
+ isEmpty: isEmpty,
+ isHash: isHash,
+ isNumber: isNumber,
+ isString: isString,
+ isDate: isDate,
+ isArray: isArray,
+ isBoolean: isBoolean,
+ isUndefined: isUndefined,
+ isDefined: isDefined,
+ isUndefinedOrNull: isUndefinedOrNull,
+ isNull: isNull,
+ isArguments: isArguments,
+ instanceOf: isInstanceOf,
+ isRegExp: isRegExp,
+ deepEqual: deepEqual,
+ isTrue: isTrue,
+ isFalse: isFalse,
+ isNotNull: isNotNull,
+ isEq: isEq,
+ isNeq: isNeq,
+ isSeq: isSeq,
+ isSneq: isSneq,
+ isIn: isIn,
+ isNotIn: isNotIn,
+ isLt: isLt,
+ isLte: isLte,
+ isGt: isGt,
+ isGte: isGte,
+ isLike: isLike,
+ isNotLike: isNotLike,
+ contains: contains,
+ notContains: notContains,
+ has: has,
+ notHas: notHas,
+ isLength: length,
+ isNotLength: notLength,
+ containsAt: containsAt,
+ notContainsAt: notContainsAt
+ };
+
+ var tester = {
+ constructor: function () {
+ this._testers = [];
+ },
+
+ noWrap: {
+ tester: function () {
+ var testers = this._testers;
+ return function tester(value) {
+ var isa = false;
+ for (var i = 0, l = testers.length; i < l && !isa; i++) {
+ isa = testers[i](value);
+ }
+ return isa;
+ };
+ }
+ }
+ };
+
+ var switcher = {
+ constructor: function () {
+ this._cases = [];
+ this.__default = null;
+ },
+
+ def: function (val, fn) {
+ this.__default = fn;
+ },
+
+ noWrap: {
+ switcher: function () {
+ var testers = this._cases, __default = this.__default;
+ return function tester() {
+ var handled = false, args = argsToArray(arguments), caseRet;
+ for (var i = 0, l = testers.length; i < l && !handled; i++) {
+ caseRet = testers[i](args);
+ if (caseRet.length > 1) {
+ if (caseRet[1] || caseRet[0]) {
+ return caseRet[1];
+ }
+ }
+ }
+ if (!handled && __default) {
+ return __default.apply(this, args);
+ }
+ };
+ }
+ }
+ };
+
+ function addToTester(func) {
+ tester[func] = function isaTester() {
+ this._testers.push(isa[func]);
+ };
+ }
+
+ function addToSwitcher(func) {
+ switcher[func] = function isaTester() {
+ var args = argsToArray(arguments, 1), isFunc = isa[func], handler, doBreak = true;
+ if (args.length <= isFunc.length - 1) {
+ throw new TypeError("A handler must be defined when calling using switch");
+ } else {
+ handler = args.pop();
+ if (isBoolean(handler)) {
+ doBreak = handler;
+ handler = args.pop();
+ }
+ }
+ if (!isFunction(handler)) {
+ throw new TypeError("handler must be defined");
+ }
+ this._cases.push(function (testArgs) {
+ if (isFunc.apply(isa, testArgs.concat(args))) {
+ return [doBreak, handler.apply(this, testArgs)];
+ }
+ return [false];
+ });
+ };
+ }
+
+ for (var i in isa) {
+ if (hasOwn.call(isa, i)) {
+ addToSwitcher(i);
+ addToTester(i);
+ }
+ }
+
+ var is = extended.define(isa).expose(isa);
+ is.tester = extended.define(tester);
+ is.switcher = extended.define(switcher);
+ return is;
+
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineIsa(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js"));
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/leafy/index.js":
+/*!*****************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/leafy/index.js ***!
+ \*****************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+
+ function defineLeafy(_) {
+
+ function compare(a, b) {
+ var ret = 0;
+ if (a > b) {
+ return 1;
+ } else if (a < b) {
+ return -1;
+ } else if (!b) {
+ return 1;
+ }
+ return ret;
+ }
+
+ var multiply = _.multiply;
+
+ var Tree = _.declare({
+
+ instance: {
+
+ /**
+ * Prints a node
+ * @param node node to print
+ * @param level the current level the node is at, Used for formatting
+ */
+ __printNode: function (node, level) {
+ //console.log(level);
+ var str = [];
+ if (_.isUndefinedOrNull(node)) {
+ str.push(multiply('\t', level));
+ str.push("~");
+ console.log(str.join(""));
+ } else {
+ this.__printNode(node.right, level + 1);
+ str.push(multiply('\t', level));
+ str.push(node.data + "\n");
+ console.log(str.join(""));
+ this.__printNode(node.left, level + 1);
+ }
+ },
+
+ constructor: function (options) {
+ options = options || {};
+ this.compare = options.compare || compare;
+ this.__root = null;
+ },
+
+ insert: function () {
+ throw new Error("Not Implemented");
+ },
+
+ remove: function () {
+ throw new Error("Not Implemented");
+ },
+
+ clear: function () {
+ this.__root = null;
+ },
+
+ isEmpty: function () {
+ return !(this.__root);
+ },
+
+ traverseWithCondition: function (node, order, callback) {
+ var cont = true;
+ if (node) {
+ order = order || Tree.PRE_ORDER;
+ if (order === Tree.PRE_ORDER) {
+ cont = callback(node.data);
+ if (cont) {
+ cont = this.traverseWithCondition(node.left, order, callback);
+ if (cont) {
+ cont = this.traverseWithCondition(node.right, order, callback);
+ }
+
+ }
+ } else if (order === Tree.IN_ORDER) {
+ cont = this.traverseWithCondition(node.left, order, callback);
+ if (cont) {
+ cont = callback(node.data);
+ if (cont) {
+ cont = this.traverseWithCondition(node.right, order, callback);
+ }
+ }
+ } else if (order === Tree.POST_ORDER) {
+ cont = this.traverseWithCondition(node.left, order, callback);
+ if (cont) {
+ if (cont) {
+ cont = this.traverseWithCondition(node.right, order, callback);
+ }
+ if (cont) {
+ cont = callback(node.data);
+ }
+ }
+ } else if (order === Tree.REVERSE_ORDER) {
+ cont = this.traverseWithCondition(node.right, order, callback);
+ if (cont) {
+ cont = callback(node.data);
+ if (cont) {
+ cont = this.traverseWithCondition(node.left, order, callback);
+ }
+ }
+ }
+ }
+ return cont;
+ },
+
+ traverse: function (node, order, callback) {
+ if (node) {
+ order = order || Tree.PRE_ORDER;
+ if (order === Tree.PRE_ORDER) {
+ callback(node.data);
+ this.traverse(node.left, order, callback);
+ this.traverse(node.right, order, callback);
+ } else if (order === Tree.IN_ORDER) {
+ this.traverse(node.left, order, callback);
+ callback(node.data);
+ this.traverse(node.right, order, callback);
+ } else if (order === Tree.POST_ORDER) {
+ this.traverse(node.left, order, callback);
+ this.traverse(node.right, order, callback);
+ callback(node.data);
+ } else if (order === Tree.REVERSE_ORDER) {
+ this.traverse(node.right, order, callback);
+ callback(node.data);
+ this.traverse(node.left, order, callback);
+
+ }
+ }
+ },
+
+ forEach: function (cb, scope, order) {
+ if (typeof cb !== "function") {
+ throw new TypeError();
+ }
+ order = order || Tree.IN_ORDER;
+ scope = scope || this;
+ this.traverse(this.__root, order, function (node) {
+ cb.call(scope, node, this);
+ });
+ },
+
+ map: function (cb, scope, order) {
+ if (typeof cb !== "function") {
+ throw new TypeError();
+ }
+
+ order = order || Tree.IN_ORDER;
+ scope = scope || this;
+ var ret = new this._static();
+ this.traverse(this.__root, order, function (node) {
+ ret.insert(cb.call(scope, node, this));
+ });
+ return ret;
+ },
+
+ filter: function (cb, scope, order) {
+ if (typeof cb !== "function") {
+ throw new TypeError();
+ }
+
+ order = order || Tree.IN_ORDER;
+ scope = scope || this;
+ var ret = new this._static();
+ this.traverse(this.__root, order, function (node) {
+ if (cb.call(scope, node, this)) {
+ ret.insert(node);
+ }
+ });
+ return ret;
+ },
+
+ reduce: function (fun, accumulator, order) {
+ var arr = this.toArray(order);
+ var args = [arr, fun];
+ if (!_.isUndefinedOrNull(accumulator)) {
+ args.push(accumulator);
+ }
+ return _.reduce.apply(_, args);
+ },
+
+ reduceRight: function (fun, accumulator, order) {
+ var arr = this.toArray(order);
+ var args = [arr, fun];
+ if (!_.isUndefinedOrNull(accumulator)) {
+ args.push(accumulator);
+ }
+ return _.reduceRight.apply(_, args);
+ },
+
+ every: function (cb, scope, order) {
+ if (typeof cb !== "function") {
+ throw new TypeError();
+ }
+ order = order || Tree.IN_ORDER;
+ scope = scope || this;
+ var ret = false;
+ this.traverseWithCondition(this.__root, order, function (node) {
+ ret = cb.call(scope, node, this);
+ return ret;
+ });
+ return ret;
+ },
+
+ some: function (cb, scope, order) {
+ if (typeof cb !== "function") {
+ throw new TypeError();
+ }
+
+ order = order || Tree.IN_ORDER;
+ scope = scope || this;
+ var ret;
+ this.traverseWithCondition(this.__root, order, function (node) {
+ ret = cb.call(scope, node, this);
+ return !ret;
+ });
+ return ret;
+ },
+
+ toArray: function (order) {
+ order = order || Tree.IN_ORDER;
+ var arr = [];
+ this.traverse(this.__root, order, function (node) {
+ arr.push(node);
+ });
+ return arr;
+ },
+
+ contains: function (value) {
+ var ret = false;
+ var root = this.__root;
+ while (root !== null) {
+ var cmp = this.compare(value, root.data);
+ if (cmp) {
+ root = root[(cmp === -1) ? "left" : "right"];
+ } else {
+ ret = true;
+ root = null;
+ }
+ }
+ return ret;
+ },
+
+ find: function (value) {
+ var ret;
+ var root = this.__root;
+ while (root) {
+ var cmp = this.compare(value, root.data);
+ if (cmp) {
+ root = root[(cmp === -1) ? "left" : "right"];
+ } else {
+ ret = root.data;
+ break;
+ }
+ }
+ return ret;
+ },
+
+ findLessThan: function (value, exclusive) {
+ //find a better way!!!!
+ var ret = [], compare = this.compare;
+ this.traverseWithCondition(this.__root, Tree.IN_ORDER, function (v) {
+ var cmp = compare(value, v);
+ if ((!exclusive && cmp === 0) || cmp === 1) {
+ ret.push(v);
+ return true;
+ } else {
+ return false;
+ }
+ });
+ return ret;
+ },
+
+ findGreaterThan: function (value, exclusive) {
+ //find a better way!!!!
+ var ret = [], compare = this.compare;
+ this.traverse(this.__root, Tree.REVERSE_ORDER, function (v) {
+ var cmp = compare(value, v);
+ if ((!exclusive && cmp === 0) || cmp === -1) {
+ ret.push(v);
+ return true;
+ } else {
+ return false;
+ }
+ });
+ return ret;
+ },
+
+ print: function () {
+ this.__printNode(this.__root, 0);
+ }
+ },
+
+ "static": {
+ PRE_ORDER: "pre_order",
+ IN_ORDER: "in_order",
+ POST_ORDER: "post_order",
+ REVERSE_ORDER: "reverse_order"
+ }
+ });
+
+ var AVLTree = (function () {
+ var abs = Math.abs;
+
+
+ var makeNode = function (data) {
+ return {
+ data: data,
+ balance: 0,
+ left: null,
+ right: null
+ };
+ };
+
+ var rotateSingle = function (root, dir, otherDir) {
+ var save = root[otherDir];
+ root[otherDir] = save[dir];
+ save[dir] = root;
+ return save;
+ };
+
+
+ var rotateDouble = function (root, dir, otherDir) {
+ root[otherDir] = rotateSingle(root[otherDir], otherDir, dir);
+ return rotateSingle(root, dir, otherDir);
+ };
+
+ var adjustBalance = function (root, dir, bal) {
+ var otherDir = dir === "left" ? "right" : "left";
+ var n = root[dir], nn = n[otherDir];
+ if (nn.balance === 0) {
+ root.balance = n.balance = 0;
+ } else if (nn.balance === bal) {
+ root.balance = -bal;
+ n.balance = 0;
+ } else { /* nn.balance == -bal */
+ root.balance = 0;
+ n.balance = bal;
+ }
+ nn.balance = 0;
+ };
+
+ var insertAdjustBalance = function (root, dir) {
+ var otherDir = dir === "left" ? "right" : "left";
+
+ var n = root[dir];
+ var bal = dir === "right" ? -1 : +1;
+
+ if (n.balance === bal) {
+ root.balance = n.balance = 0;
+ root = rotateSingle(root, otherDir, dir);
+ } else {
+ adjustBalance(root, dir, bal);
+ root = rotateDouble(root, otherDir, dir);
+ }
+
+ return root;
+
+ };
+
+ var removeAdjustBalance = function (root, dir, done) {
+ var otherDir = dir === "left" ? "right" : "left";
+ var n = root[otherDir];
+ var bal = dir === "right" ? -1 : 1;
+ if (n.balance === -bal) {
+ root.balance = n.balance = 0;
+ root = rotateSingle(root, dir, otherDir);
+ } else if (n.balance === bal) {
+ adjustBalance(root, otherDir, -bal);
+ root = rotateDouble(root, dir, otherDir);
+ } else { /* n.balance == 0 */
+ root.balance = -bal;
+ n.balance = bal;
+ root = rotateSingle(root, dir, otherDir);
+ done.done = true;
+ }
+ return root;
+ };
+
+ function insert(tree, data, cmp) {
+ /* Empty tree case */
+ var root = tree.__root;
+ if (root === null || root === undefined) {
+ tree.__root = makeNode(data);
+ } else {
+ var it = root, upd = [], up = [], top = 0, dir;
+ while (true) {
+ dir = upd[top] = cmp(data, it.data) === -1 ? "left" : "right";
+ up[top++] = it;
+ if (!it[dir]) {
+ it[dir] = makeNode(data);
+ break;
+ }
+ it = it[dir];
+ }
+ if (!it[dir]) {
+ return null;
+ }
+ while (--top >= 0) {
+ up[top].balance += upd[top] === "right" ? -1 : 1;
+ if (up[top].balance === 0) {
+ break;
+ } else if (abs(up[top].balance) > 1) {
+ up[top] = insertAdjustBalance(up[top], upd[top]);
+ if (top !== 0) {
+ up[top - 1][upd[top - 1]] = up[top];
+ } else {
+ tree.__root = up[0];
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ function remove(tree, data, cmp) {
+ var root = tree.__root;
+ if (root !== null && root !== undefined) {
+ var it = root, top = 0, up = [], upd = [], done = {done: false}, dir, compare;
+ while (true) {
+ if (!it) {
+ return;
+ } else if ((compare = cmp(data, it.data)) === 0) {
+ break;
+ }
+ dir = upd[top] = compare === -1 ? "left" : "right";
+ up[top++] = it;
+ it = it[dir];
+ }
+ var l = it.left, r = it.right;
+ if (!l || !r) {
+ dir = !l ? "right" : "left";
+ if (top !== 0) {
+ up[top - 1][upd[top - 1]] = it[dir];
+ } else {
+ tree.__root = it[dir];
+ }
+ } else {
+ var heir = l;
+ upd[top] = "left";
+ up[top++] = it;
+ while (heir.right) {
+ upd[top] = "right";
+ up[top++] = heir;
+ heir = heir.right;
+ }
+ it.data = heir.data;
+ up[top - 1][up[top - 1] === it ? "left" : "right"] = heir.left;
+ }
+ while (--top >= 0 && !done.done) {
+ up[top].balance += upd[top] === "left" ? -1 : +1;
+ if (abs(up[top].balance) === 1) {
+ break;
+ } else if (abs(up[top].balance) > 1) {
+ up[top] = removeAdjustBalance(up[top], upd[top], done);
+ if (top !== 0) {
+ up[top - 1][upd[top - 1]] = up[top];
+ } else {
+ tree.__root = up[0];
+ }
+ }
+ }
+ }
+ }
+
+
+ return Tree.extend({
+ instance: {
+
+ insert: function (data) {
+ insert(this, data, this.compare);
+ },
+
+
+ remove: function (data) {
+ remove(this, data, this.compare);
+ },
+
+ __printNode: function (node, level) {
+ var str = [];
+ if (!node) {
+ str.push(multiply('\t', level));
+ str.push("~");
+ console.log(str.join(""));
+ } else {
+ this.__printNode(node.right, level + 1);
+ str.push(multiply('\t', level));
+ str.push(node.data + ":" + node.balance + "\n");
+ console.log(str.join(""));
+ this.__printNode(node.left, level + 1);
+ }
+ }
+
+ }
+ });
+ }());
+
+ var AnderssonTree = (function () {
+
+ var nil = {level: 0, data: null};
+
+ function makeNode(data, level) {
+ return {
+ data: data,
+ level: level,
+ left: nil,
+ right: nil
+ };
+ }
+
+ function skew(root) {
+ if (root.level !== 0 && root.left.level === root.level) {
+ var save = root.left;
+ root.left = save.right;
+ save.right = root;
+ root = save;
+ }
+ return root;
+ }
+
+ function split(root) {
+ if (root.level !== 0 && root.right.right.level === root.level) {
+ var save = root.right;
+ root.right = save.left;
+ save.left = root;
+ root = save;
+ root.level++;
+ }
+ return root;
+ }
+
+ function insert(root, data, compare) {
+ if (root === nil) {
+ root = makeNode(data, 1);
+ }
+ else {
+ var dir = compare(data, root.data) === -1 ? "left" : "right";
+ root[dir] = insert(root[dir], data, compare);
+ root = skew(root);
+ root = split(root);
+ }
+ return root;
+ }
+
+ var remove = function (root, data, compare) {
+ var rLeft, rRight;
+ if (root !== nil) {
+ var cmp = compare(data, root.data);
+ if (cmp === 0) {
+ rLeft = root.left, rRight = root.right;
+ if (rLeft !== nil && rRight !== nil) {
+ var heir = rLeft;
+ while (heir.right !== nil) {
+ heir = heir.right;
+ }
+ root.data = heir.data;
+ root.left = remove(rLeft, heir.data, compare);
+ } else {
+ root = root[rLeft === nil ? "right" : "left"];
+ }
+ } else {
+ var dir = cmp === -1 ? "left" : "right";
+ root[dir] = remove(root[dir], data, compare);
+ }
+ }
+ if (root !== nil) {
+ var rLevel = root.level;
+ var rLeftLevel = root.left.level, rRightLevel = root.right.level;
+ if (rLeftLevel < rLevel - 1 || rRightLevel < rLevel - 1) {
+ if (rRightLevel > --root.level) {
+ root.right.level = root.level;
+ }
+ root = skew(root);
+ root = split(root);
+ }
+ }
+ return root;
+ };
+
+ return Tree.extend({
+
+ instance: {
+
+ isEmpty: function () {
+ return this.__root === nil || this._super(arguments);
+ },
+
+ insert: function (data) {
+ if (!this.__root) {
+ this.__root = nil;
+ }
+ this.__root = insert(this.__root, data, this.compare);
+ },
+
+ remove: function (data) {
+ this.__root = remove(this.__root, data, this.compare);
+ },
+
+
+ traverseWithCondition: function (node) {
+ var cont = true;
+ if (node !== nil) {
+ return this._super(arguments);
+ }
+ return cont;
+ },
+
+
+ traverse: function (node) {
+ if (node !== nil) {
+ this._super(arguments);
+ }
+ },
+
+ contains: function () {
+ if (this.__root !== nil) {
+ return this._super(arguments);
+ }
+ return false;
+ },
+
+ __printNode: function (node, level) {
+ var str = [];
+ if (!node || !node.data) {
+ str.push(multiply('\t', level));
+ str.push("~");
+ console.log(str.join(""));
+ } else {
+ this.__printNode(node.right, level + 1);
+ str.push(multiply('\t', level));
+ str.push(node.data + ":" + node.level + "\n");
+ console.log(str.join(""));
+ this.__printNode(node.left, level + 1);
+ }
+ }
+
+ }
+
+ });
+ }());
+
+ var BinaryTree = Tree.extend({
+ instance: {
+ insert: function (data) {
+ if (!this.__root) {
+ this.__root = {
+ data: data,
+ parent: null,
+ left: null,
+ right: null
+ };
+ return this.__root;
+ }
+ var compare = this.compare;
+ var root = this.__root;
+ while (root !== null) {
+ var cmp = compare(data, root.data);
+ if (cmp) {
+ var leaf = (cmp === -1) ? "left" : "right";
+ var next = root[leaf];
+ if (!next) {
+ return (root[leaf] = {data: data, parent: root, left: null, right: null});
+ } else {
+ root = next;
+ }
+ } else {
+ return;
+ }
+ }
+ },
+
+ remove: function (data) {
+ if (this.__root !== null) {
+ var head = {right: this.__root}, it = head;
+ var p, f = null;
+ var dir = "right";
+ while (it[dir] !== null) {
+ p = it;
+ it = it[dir];
+ var cmp = this.compare(data, it.data);
+ if (!cmp) {
+ f = it;
+ }
+ dir = (cmp === -1 ? "left" : "right");
+ }
+ if (f !== null) {
+ f.data = it.data;
+ p[p.right === it ? "right" : "left"] = it[it.left === null ? "right" : "left"];
+ }
+ this.__root = head.right;
+ }
+
+ }
+ }
+ });
+
+ var RedBlackTree = (function () {
+ var RED = "RED", BLACK = "BLACK";
+
+ var isRed = function (node) {
+ return node !== null && node.red;
+ };
+
+ var makeNode = function (data) {
+ return {
+ data: data,
+ red: true,
+ left: null,
+ right: null
+ };
+ };
+
+ var insert = function (root, data, compare) {
+ if (!root) {
+ return makeNode(data);
+
+ } else {
+ var cmp = compare(data, root.data);
+ if (cmp) {
+ var dir = cmp === -1 ? "left" : "right";
+ var otherDir = dir === "left" ? "right" : "left";
+ root[dir] = insert(root[dir], data, compare);
+ var node = root[dir];
+
+ if (isRed(node)) {
+
+ var sibling = root[otherDir];
+ if (isRed(sibling)) {
+ /* Case 1 */
+ root.red = true;
+ node.red = false;
+ sibling.red = false;
+ } else {
+
+ if (isRed(node[dir])) {
+
+ root = rotateSingle(root, otherDir);
+ } else if (isRed(node[otherDir])) {
+
+ root = rotateDouble(root, otherDir);
+ }
+ }
+
+ }
+ }
+ }
+ return root;
+ };
+
+ var rotateSingle = function (root, dir) {
+ var otherDir = dir === "left" ? "right" : "left";
+ var save = root[otherDir];
+ root[otherDir] = save[dir];
+ save[dir] = root;
+ root.red = true;
+ save.red = false;
+ return save;
+ };
+
+ var rotateDouble = function (root, dir) {
+ var otherDir = dir === "left" ? "right" : "left";
+ root[otherDir] = rotateSingle(root[otherDir], otherDir);
+ return rotateSingle(root, dir);
+ };
+
+
+ var remove = function (root, data, done, compare) {
+ if (!root) {
+ done.done = true;
+ } else {
+ var dir;
+ if (compare(data, root.data) === 0) {
+ if (!root.left || !root.right) {
+ var save = root[!root.left ? "right" : "left"];
+ /* Case 0 */
+ if (isRed(root)) {
+ done.done = true;
+ } else if (isRed(save)) {
+ save.red = false;
+ done.done = true;
+ }
+ return save;
+ }
+ else {
+ var heir = root.right, p;
+ while (heir.left !== null) {
+ p = heir;
+ heir = heir.left;
+ }
+ if (p) {
+ p.left = null;
+ }
+ root.data = heir.data;
+ data = heir.data;
+ }
+ }
+ dir = compare(data, root.data) === -1 ? "left" : "right";
+ root[dir] = remove(root[dir], data, done, compare);
+ if (!done.done) {
+ root = removeBalance(root, dir, done);
+ }
+ }
+ return root;
+ };
+
+ var removeBalance = function (root, dir, done) {
+ var notDir = dir === "left" ? "right" : "left";
+ var p = root, s = p[notDir];
+ if (isRed(s)) {
+ root = rotateSingle(root, dir);
+ s = p[notDir];
+ }
+ if (s !== null) {
+ if (!isRed(s.left) && !isRed(s.right)) {
+ if (isRed(p)) {
+ done.done = true;
+ }
+ p.red = 0;
+ s.red = 1;
+ } else {
+ var save = p.red, newRoot = ( root === p );
+ p = (isRed(s[notDir]) ? rotateSingle : rotateDouble)(p, dir);
+ p.red = save;
+ p.left.red = p.right.red = 0;
+ if (newRoot) {
+ root = p;
+ } else {
+ root[dir] = p;
+ }
+ done.done = true;
+ }
+ }
+ return root;
+ };
+
+ return Tree.extend({
+ instance: {
+ insert: function (data) {
+ this.__root = insert(this.__root, data, this.compare);
+ this.__root.red = false;
+ },
+
+ remove: function (data) {
+ var done = {done: false};
+ var root = remove(this.__root, data, done, this.compare);
+ if (root !== null) {
+ root.red = 0;
+ }
+ this.__root = root;
+ return data;
+ },
+
+
+ __printNode: function (node, level) {
+ var str = [];
+ if (!node) {
+ str.push(multiply('\t', level));
+ str.push("~");
+ console.log(str.join(""));
+ } else {
+ this.__printNode(node.right, level + 1);
+ str.push(multiply('\t', level));
+ str.push((node.red ? RED : BLACK) + ":" + node.data + "\n");
+ console.log(str.join(""));
+ this.__printNode(node.left, level + 1);
+ }
+ }
+
+ }
+ });
+
+ }());
+
+
+ return {
+ Tree: Tree,
+ AVLTree: AVLTree,
+ AnderssonTree: AnderssonTree,
+ BinaryTree: BinaryTree,
+ RedBlackTree: RedBlackTree,
+ IN_ORDER: Tree.IN_ORDER,
+ PRE_ORDER: Tree.PRE_ORDER,
+ POST_ORDER: Tree.POST_ORDER,
+ REVERSE_ORDER: Tree.REVERSE_ORDER
+
+ };
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineLeafy(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js")()
+ .register("declare", __webpack_require__(/*! declare.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js"))
+ .register(__webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"))
+ .register(__webpack_require__(/*! array-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js"))
+ .register(__webpack_require__(/*! string-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/string-extended/index.js"))
+ );
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_DataView.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_DataView.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getNative.js"),
+ root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js");
+
+/* Built-in method references that are verified to be native. */
+var DataView = getNative(root, 'DataView');
+
+module.exports = DataView;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Hash.js":
+/*!******************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Hash.js ***!
+ \******************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var hashClear = __webpack_require__(/*! ./_hashClear */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashClear.js"),
+ hashDelete = __webpack_require__(/*! ./_hashDelete */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashDelete.js"),
+ hashGet = __webpack_require__(/*! ./_hashGet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashGet.js"),
+ hashHas = __webpack_require__(/*! ./_hashHas */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashHas.js"),
+ hashSet = __webpack_require__(/*! ./_hashSet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashSet.js");
+
+/**
+ * Creates a hash object.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+function Hash(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+}
+
+// Add methods to `Hash`.
+Hash.prototype.clear = hashClear;
+Hash.prototype['delete'] = hashDelete;
+Hash.prototype.get = hashGet;
+Hash.prototype.has = hashHas;
+Hash.prototype.set = hashSet;
+
+module.exports = Hash;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_ListCache.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_ListCache.js ***!
+ \***********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheClear.js"),
+ listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheDelete.js"),
+ listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheGet.js"),
+ listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheHas.js"),
+ listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheSet.js");
+
+/**
+ * Creates an list cache object.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+function ListCache(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+}
+
+// Add methods to `ListCache`.
+ListCache.prototype.clear = listCacheClear;
+ListCache.prototype['delete'] = listCacheDelete;
+ListCache.prototype.get = listCacheGet;
+ListCache.prototype.has = listCacheHas;
+ListCache.prototype.set = listCacheSet;
+
+module.exports = ListCache;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Map.js":
+/*!*****************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Map.js ***!
+ \*****************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getNative.js"),
+ root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js");
+
+/* Built-in method references that are verified to be native. */
+var Map = getNative(root, 'Map');
+
+module.exports = Map;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_MapCache.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_MapCache.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var mapCacheClear = __webpack_require__(/*! ./_mapCacheClear */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheClear.js"),
+ mapCacheDelete = __webpack_require__(/*! ./_mapCacheDelete */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheDelete.js"),
+ mapCacheGet = __webpack_require__(/*! ./_mapCacheGet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheGet.js"),
+ mapCacheHas = __webpack_require__(/*! ./_mapCacheHas */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheHas.js"),
+ mapCacheSet = __webpack_require__(/*! ./_mapCacheSet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheSet.js");
+
+/**
+ * Creates a map cache object to store key-value pairs.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+function MapCache(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+}
+
+// Add methods to `MapCache`.
+MapCache.prototype.clear = mapCacheClear;
+MapCache.prototype['delete'] = mapCacheDelete;
+MapCache.prototype.get = mapCacheGet;
+MapCache.prototype.has = mapCacheHas;
+MapCache.prototype.set = mapCacheSet;
+
+module.exports = MapCache;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Promise.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Promise.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getNative.js"),
+ root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js");
+
+/* Built-in method references that are verified to be native. */
+var Promise = getNative(root, 'Promise');
+
+module.exports = Promise;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Set.js":
+/*!*****************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Set.js ***!
+ \*****************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getNative.js"),
+ root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js");
+
+/* Built-in method references that are verified to be native. */
+var Set = getNative(root, 'Set');
+
+module.exports = Set;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_SetCache.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_SetCache.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var MapCache = __webpack_require__(/*! ./_MapCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_MapCache.js"),
+ setCacheAdd = __webpack_require__(/*! ./_setCacheAdd */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setCacheAdd.js"),
+ setCacheHas = __webpack_require__(/*! ./_setCacheHas */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setCacheHas.js");
+
+/**
+ *
+ * Creates an array cache object to store unique values.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [values] The values to cache.
+ */
+function SetCache(values) {
+ var index = -1,
+ length = values == null ? 0 : values.length;
+
+ this.__data__ = new MapCache;
+ while (++index < length) {
+ this.add(values[index]);
+ }
+}
+
+// Add methods to `SetCache`.
+SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
+SetCache.prototype.has = setCacheHas;
+
+module.exports = SetCache;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Stack.js":
+/*!*******************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Stack.js ***!
+ \*******************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var ListCache = __webpack_require__(/*! ./_ListCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_ListCache.js"),
+ stackClear = __webpack_require__(/*! ./_stackClear */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackClear.js"),
+ stackDelete = __webpack_require__(/*! ./_stackDelete */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackDelete.js"),
+ stackGet = __webpack_require__(/*! ./_stackGet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackGet.js"),
+ stackHas = __webpack_require__(/*! ./_stackHas */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackHas.js"),
+ stackSet = __webpack_require__(/*! ./_stackSet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackSet.js");
+
+/**
+ * Creates a stack cache object to store key-value pairs.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+function Stack(entries) {
+ var data = this.__data__ = new ListCache(entries);
+ this.size = data.size;
+}
+
+// Add methods to `Stack`.
+Stack.prototype.clear = stackClear;
+Stack.prototype['delete'] = stackDelete;
+Stack.prototype.get = stackGet;
+Stack.prototype.has = stackHas;
+Stack.prototype.set = stackSet;
+
+module.exports = Stack;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Symbol.js":
+/*!********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Symbol.js ***!
+ \********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js");
+
+/** Built-in value references. */
+var Symbol = root.Symbol;
+
+module.exports = Symbol;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Uint8Array.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Uint8Array.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js");
+
+/** Built-in value references. */
+var Uint8Array = root.Uint8Array;
+
+module.exports = Uint8Array;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_WeakMap.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_WeakMap.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getNative.js"),
+ root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js");
+
+/* Built-in method references that are verified to be native. */
+var WeakMap = getNative(root, 'WeakMap');
+
+module.exports = WeakMap;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayFilter.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayFilter.js ***!
+ \*************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * A specialized version of `_.filter` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ */
+function arrayFilter(array, predicate) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index];
+ if (predicate(value, index, array)) {
+ result[resIndex++] = value;
+ }
+ }
+ return result;
+}
+
+module.exports = arrayFilter;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayIncludes.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayIncludes.js ***!
+ \***************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseIndexOf = __webpack_require__(/*! ./_baseIndexOf */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIndexOf.js");
+
+/**
+ * A specialized version of `_.includes` for arrays without support for
+ * specifying an index to search from.
+ *
+ * @private
+ * @param {Array} [array] The array to inspect.
+ * @param {*} target The value to search for.
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
+ */
+function arrayIncludes(array, value) {
+ var length = array == null ? 0 : array.length;
+ return !!length && baseIndexOf(array, value, 0) > -1;
+}
+
+module.exports = arrayIncludes;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayIncludesWith.js":
+/*!*******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayIncludesWith.js ***!
+ \*******************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * This function is like `arrayIncludes` except that it accepts a comparator.
+ *
+ * @private
+ * @param {Array} [array] The array to inspect.
+ * @param {*} target The value to search for.
+ * @param {Function} comparator The comparator invoked per element.
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
+ */
+function arrayIncludesWith(array, value, comparator) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (comparator(value, array[index])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+module.exports = arrayIncludesWith;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayLikeKeys.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayLikeKeys.js ***!
+ \***************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseTimes = __webpack_require__(/*! ./_baseTimes */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseTimes.js"),
+ isArguments = __webpack_require__(/*! ./isArguments */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArguments.js"),
+ isArray = __webpack_require__(/*! ./isArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js"),
+ isBuffer = __webpack_require__(/*! ./isBuffer */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isBuffer.js"),
+ isIndex = __webpack_require__(/*! ./_isIndex */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isIndex.js"),
+ isTypedArray = __webpack_require__(/*! ./isTypedArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isTypedArray.js");
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Creates an array of the enumerable property names of the array-like `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @param {boolean} inherited Specify returning inherited property names.
+ * @returns {Array} Returns the array of property names.
+ */
+function arrayLikeKeys(value, inherited) {
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
+
+ for (var key in value) {
+ if ((inherited || hasOwnProperty.call(value, key)) &&
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+module.exports = arrayLikeKeys;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayMap.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayMap.js ***!
+ \**********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * A specialized version of `_.map` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+function arrayMap(array, iteratee) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ result = Array(length);
+
+ while (++index < length) {
+ result[index] = iteratee(array[index], index, array);
+ }
+ return result;
+}
+
+module.exports = arrayMap;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayPush.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayPush.js ***!
+ \***********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Appends the elements of `values` to `array`.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to append.
+ * @returns {Array} Returns `array`.
+ */
+function arrayPush(array, values) {
+ var index = -1,
+ length = values.length,
+ offset = array.length;
+
+ while (++index < length) {
+ array[offset + index] = values[index];
+ }
+ return array;
+}
+
+module.exports = arrayPush;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arraySome.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arraySome.js ***!
+ \***********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * A specialized version of `_.some` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ */
+function arraySome(array, predicate) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (predicate(array[index], index, array)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+module.exports = arraySome;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_assocIndexOf.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_assocIndexOf.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var eq = __webpack_require__(/*! ./eq */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/eq.js");
+
+/**
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} key The key to search for.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function assocIndexOf(array, key) {
+ var length = array.length;
+ while (length--) {
+ if (eq(array[length][0], key)) {
+ return length;
+ }
+ }
+ return -1;
+}
+
+module.exports = assocIndexOf;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseFindIndex.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseFindIndex.js ***!
+ \***************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {number} fromIndex The index to search from.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseFindIndex(array, predicate, fromIndex, fromRight) {
+ var length = array.length,
+ index = fromIndex + (fromRight ? 1 : -1);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (predicate(array[index], index, array)) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+module.exports = baseFindIndex;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGet.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGet.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var castPath = __webpack_require__(/*! ./_castPath */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_castPath.js"),
+ toKey = __webpack_require__(/*! ./_toKey */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toKey.js");
+
+/**
+ * The base implementation of `_.get` without support for default values.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to get.
+ * @returns {*} Returns the resolved value.
+ */
+function baseGet(object, path) {
+ path = castPath(path, object);
+
+ var index = 0,
+ length = path.length;
+
+ while (object != null && index < length) {
+ object = object[toKey(path[index++])];
+ }
+ return (index && index == length) ? object : undefined;
+}
+
+module.exports = baseGet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetAllKeys.js":
+/*!****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetAllKeys.js ***!
+ \****************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var arrayPush = __webpack_require__(/*! ./_arrayPush */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayPush.js"),
+ isArray = __webpack_require__(/*! ./isArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js");
+
+/**
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
+ * symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
+ * @returns {Array} Returns the array of property names and symbols.
+ */
+function baseGetAllKeys(object, keysFunc, symbolsFunc) {
+ var result = keysFunc(object);
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
+}
+
+module.exports = baseGetAllKeys;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetTag.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetTag.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var Symbol = __webpack_require__(/*! ./_Symbol */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Symbol.js"),
+ getRawTag = __webpack_require__(/*! ./_getRawTag */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getRawTag.js"),
+ objectToString = __webpack_require__(/*! ./_objectToString */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_objectToString.js");
+
+/** `Object#toString` result references. */
+var nullTag = '[object Null]',
+ undefinedTag = '[object Undefined]';
+
+/** Built-in value references. */
+var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
+
+/**
+ * The base implementation of `getTag` without fallbacks for buggy environments.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+function baseGetTag(value) {
+ if (value == null) {
+ return value === undefined ? undefinedTag : nullTag;
+ }
+ return (symToStringTag && symToStringTag in Object(value))
+ ? getRawTag(value)
+ : objectToString(value);
+}
+
+module.exports = baseGetTag;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseHasIn.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseHasIn.js ***!
+ \***********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * The base implementation of `_.hasIn` without support for deep paths.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {Array|string} key The key to check.
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
+ */
+function baseHasIn(object, key) {
+ return object != null && key in Object(object);
+}
+
+module.exports = baseHasIn;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIndexOf.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIndexOf.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseFindIndex = __webpack_require__(/*! ./_baseFindIndex */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseFindIndex.js"),
+ baseIsNaN = __webpack_require__(/*! ./_baseIsNaN */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsNaN.js"),
+ strictIndexOf = __webpack_require__(/*! ./_strictIndexOf */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_strictIndexOf.js");
+
+/**
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseIndexOf(array, value, fromIndex) {
+ return value === value
+ ? strictIndexOf(array, value, fromIndex)
+ : baseFindIndex(array, baseIsNaN, fromIndex);
+}
+
+module.exports = baseIndexOf;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsArguments.js":
+/*!*****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsArguments.js ***!
+ \*****************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetTag.js"),
+ isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObjectLike.js");
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]';
+
+/**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+function baseIsArguments(value) {
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
+}
+
+module.exports = baseIsArguments;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsEqual.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsEqual.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseIsEqualDeep = __webpack_require__(/*! ./_baseIsEqualDeep */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsEqualDeep.js"),
+ isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObjectLike.js");
+
+/**
+ * The base implementation of `_.isEqual` which supports partial comparisons
+ * and tracks traversed objects.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @param {boolean} bitmask The bitmask flags.
+ * 1 - Unordered comparison
+ * 2 - Partial comparison
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ */
+function baseIsEqual(value, other, bitmask, customizer, stack) {
+ if (value === other) {
+ return true;
+ }
+ if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
+ return value !== value && other !== other;
+ }
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
+}
+
+module.exports = baseIsEqual;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsEqualDeep.js":
+/*!*****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsEqualDeep.js ***!
+ \*****************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var Stack = __webpack_require__(/*! ./_Stack */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Stack.js"),
+ equalArrays = __webpack_require__(/*! ./_equalArrays */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalArrays.js"),
+ equalByTag = __webpack_require__(/*! ./_equalByTag */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalByTag.js"),
+ equalObjects = __webpack_require__(/*! ./_equalObjects */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalObjects.js"),
+ getTag = __webpack_require__(/*! ./_getTag */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getTag.js"),
+ isArray = __webpack_require__(/*! ./isArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js"),
+ isBuffer = __webpack_require__(/*! ./isBuffer */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isBuffer.js"),
+ isTypedArray = __webpack_require__(/*! ./isTypedArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isTypedArray.js");
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1;
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]',
+ arrayTag = '[object Array]',
+ objectTag = '[object Object]';
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
+ * deep comparisons and tracks traversed objects enabling objects with circular
+ * references to be compared.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
+ var objIsArr = isArray(object),
+ othIsArr = isArray(other),
+ objTag = objIsArr ? arrayTag : getTag(object),
+ othTag = othIsArr ? arrayTag : getTag(other);
+
+ objTag = objTag == argsTag ? objectTag : objTag;
+ othTag = othTag == argsTag ? objectTag : othTag;
+
+ var objIsObj = objTag == objectTag,
+ othIsObj = othTag == objectTag,
+ isSameTag = objTag == othTag;
+
+ if (isSameTag && isBuffer(object)) {
+ if (!isBuffer(other)) {
+ return false;
+ }
+ objIsArr = true;
+ objIsObj = false;
+ }
+ if (isSameTag && !objIsObj) {
+ stack || (stack = new Stack);
+ return (objIsArr || isTypedArray(object))
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
+ }
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
+
+ if (objIsWrapped || othIsWrapped) {
+ var objUnwrapped = objIsWrapped ? object.value() : object,
+ othUnwrapped = othIsWrapped ? other.value() : other;
+
+ stack || (stack = new Stack);
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
+ }
+ }
+ if (!isSameTag) {
+ return false;
+ }
+ stack || (stack = new Stack);
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
+}
+
+module.exports = baseIsEqualDeep;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsMatch.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsMatch.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var Stack = __webpack_require__(/*! ./_Stack */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Stack.js"),
+ baseIsEqual = __webpack_require__(/*! ./_baseIsEqual */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsEqual.js");
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+/**
+ * The base implementation of `_.isMatch` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property values to match.
+ * @param {Array} matchData The property names, values, and compare flags to match.
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
+ */
+function baseIsMatch(object, source, matchData, customizer) {
+ var index = matchData.length,
+ length = index,
+ noCustomizer = !customizer;
+
+ if (object == null) {
+ return !length;
+ }
+ object = Object(object);
+ while (index--) {
+ var data = matchData[index];
+ if ((noCustomizer && data[2])
+ ? data[1] !== object[data[0]]
+ : !(data[0] in object)
+ ) {
+ return false;
+ }
+ }
+ while (++index < length) {
+ data = matchData[index];
+ var key = data[0],
+ objValue = object[key],
+ srcValue = data[1];
+
+ if (noCustomizer && data[2]) {
+ if (objValue === undefined && !(key in object)) {
+ return false;
+ }
+ } else {
+ var stack = new Stack;
+ if (customizer) {
+ var result = customizer(objValue, srcValue, key, object, source, stack);
+ }
+ if (!(result === undefined
+ ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
+ : result
+ )) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+module.exports = baseIsMatch;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsNaN.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsNaN.js ***!
+ \***********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * The base implementation of `_.isNaN` without support for number objects.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ */
+function baseIsNaN(value) {
+ return value !== value;
+}
+
+module.exports = baseIsNaN;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsNative.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsNative.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isFunction = __webpack_require__(/*! ./isFunction */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isFunction.js"),
+ isMasked = __webpack_require__(/*! ./_isMasked */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isMasked.js"),
+ isObject = __webpack_require__(/*! ./isObject */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObject.js"),
+ toSource = __webpack_require__(/*! ./_toSource */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toSource.js");
+
+/**
+ * Used to match `RegExp`
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
+ */
+var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
+
+/** Used to detect host constructors (Safari). */
+var reIsHostCtor = /^\[object .+?Constructor\]$/;
+
+/** Used for built-in method references. */
+var funcProto = Function.prototype,
+ objectProto = Object.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString = funcProto.toString;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/** Used to detect if a method is native. */
+var reIsNative = RegExp('^' +
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
+);
+
+/**
+ * The base implementation of `_.isNative` without bad shim checks.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a native function,
+ * else `false`.
+ */
+function baseIsNative(value) {
+ if (!isObject(value) || isMasked(value)) {
+ return false;
+ }
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
+ return pattern.test(toSource(value));
+}
+
+module.exports = baseIsNative;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsTypedArray.js":
+/*!******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsTypedArray.js ***!
+ \******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetTag.js"),
+ isLength = __webpack_require__(/*! ./isLength */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isLength.js"),
+ isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObjectLike.js");
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]',
+ arrayTag = '[object Array]',
+ boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ errorTag = '[object Error]',
+ funcTag = '[object Function]',
+ mapTag = '[object Map]',
+ numberTag = '[object Number]',
+ objectTag = '[object Object]',
+ regexpTag = '[object RegExp]',
+ setTag = '[object Set]',
+ stringTag = '[object String]',
+ weakMapTag = '[object WeakMap]';
+
+var arrayBufferTag = '[object ArrayBuffer]',
+ dataViewTag = '[object DataView]',
+ float32Tag = '[object Float32Array]',
+ float64Tag = '[object Float64Array]',
+ int8Tag = '[object Int8Array]',
+ int16Tag = '[object Int16Array]',
+ int32Tag = '[object Int32Array]',
+ uint8Tag = '[object Uint8Array]',
+ uint8ClampedTag = '[object Uint8ClampedArray]',
+ uint16Tag = '[object Uint16Array]',
+ uint32Tag = '[object Uint32Array]';
+
+/** Used to identify `toStringTag` values of typed arrays. */
+var typedArrayTags = {};
+typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
+typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
+typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
+typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
+typedArrayTags[uint32Tag] = true;
+typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
+typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
+typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
+typedArrayTags[errorTag] = typedArrayTags[funcTag] =
+typedArrayTags[mapTag] = typedArrayTags[numberTag] =
+typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
+typedArrayTags[setTag] = typedArrayTags[stringTag] =
+typedArrayTags[weakMapTag] = false;
+
+/**
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ */
+function baseIsTypedArray(value) {
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
+}
+
+module.exports = baseIsTypedArray;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIteratee.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIteratee.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseMatches = __webpack_require__(/*! ./_baseMatches */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseMatches.js"),
+ baseMatchesProperty = __webpack_require__(/*! ./_baseMatchesProperty */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseMatchesProperty.js"),
+ identity = __webpack_require__(/*! ./identity */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/identity.js"),
+ isArray = __webpack_require__(/*! ./isArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js"),
+ property = __webpack_require__(/*! ./property */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/property.js");
+
+/**
+ * The base implementation of `_.iteratee`.
+ *
+ * @private
+ * @param {*} [value=_.identity] The value to convert to an iteratee.
+ * @returns {Function} Returns the iteratee.
+ */
+function baseIteratee(value) {
+ // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
+ // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
+ if (typeof value == 'function') {
+ return value;
+ }
+ if (value == null) {
+ return identity;
+ }
+ if (typeof value == 'object') {
+ return isArray(value)
+ ? baseMatchesProperty(value[0], value[1])
+ : baseMatches(value);
+ }
+ return property(value);
+}
+
+module.exports = baseIteratee;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseKeys.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseKeys.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isPrototype = __webpack_require__(/*! ./_isPrototype */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isPrototype.js"),
+ nativeKeys = __webpack_require__(/*! ./_nativeKeys */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeKeys.js");
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+function baseKeys(object) {
+ if (!isPrototype(object)) {
+ return nativeKeys(object);
+ }
+ var result = [];
+ for (var key in Object(object)) {
+ if (hasOwnProperty.call(object, key) && key != 'constructor') {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+module.exports = baseKeys;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseMatches.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseMatches.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseIsMatch = __webpack_require__(/*! ./_baseIsMatch */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsMatch.js"),
+ getMatchData = __webpack_require__(/*! ./_getMatchData */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMatchData.js"),
+ matchesStrictComparable = __webpack_require__(/*! ./_matchesStrictComparable */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_matchesStrictComparable.js");
+
+/**
+ * The base implementation of `_.matches` which doesn't clone `source`.
+ *
+ * @private
+ * @param {Object} source The object of property values to match.
+ * @returns {Function} Returns the new spec function.
+ */
+function baseMatches(source) {
+ var matchData = getMatchData(source);
+ if (matchData.length == 1 && matchData[0][2]) {
+ return matchesStrictComparable(matchData[0][0], matchData[0][1]);
+ }
+ return function(object) {
+ return object === source || baseIsMatch(object, source, matchData);
+ };
+}
+
+module.exports = baseMatches;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseMatchesProperty.js":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseMatchesProperty.js ***!
+ \*********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseIsEqual = __webpack_require__(/*! ./_baseIsEqual */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsEqual.js"),
+ get = __webpack_require__(/*! ./get */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/get.js"),
+ hasIn = __webpack_require__(/*! ./hasIn */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/hasIn.js"),
+ isKey = __webpack_require__(/*! ./_isKey */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isKey.js"),
+ isStrictComparable = __webpack_require__(/*! ./_isStrictComparable */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isStrictComparable.js"),
+ matchesStrictComparable = __webpack_require__(/*! ./_matchesStrictComparable */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_matchesStrictComparable.js"),
+ toKey = __webpack_require__(/*! ./_toKey */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toKey.js");
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+/**
+ * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
+ *
+ * @private
+ * @param {string} path The path of the property to get.
+ * @param {*} srcValue The value to match.
+ * @returns {Function} Returns the new spec function.
+ */
+function baseMatchesProperty(path, srcValue) {
+ if (isKey(path) && isStrictComparable(srcValue)) {
+ return matchesStrictComparable(toKey(path), srcValue);
+ }
+ return function(object) {
+ var objValue = get(object, path);
+ return (objValue === undefined && objValue === srcValue)
+ ? hasIn(object, path)
+ : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
+ };
+}
+
+module.exports = baseMatchesProperty;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseProperty.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseProperty.js ***!
+ \**************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+}
+
+module.exports = baseProperty;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_basePropertyDeep.js":
+/*!******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_basePropertyDeep.js ***!
+ \******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseGet = __webpack_require__(/*! ./_baseGet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGet.js");
+
+/**
+ * A specialized version of `baseProperty` which supports deep paths.
+ *
+ * @private
+ * @param {Array|string} path The path of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+function basePropertyDeep(path) {
+ return function(object) {
+ return baseGet(object, path);
+ };
+}
+
+module.exports = basePropertyDeep;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseTimes.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseTimes.js ***!
+ \***********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * The base implementation of `_.times` without support for iteratee shorthands
+ * or max array length checks.
+ *
+ * @private
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ */
+function baseTimes(n, iteratee) {
+ var index = -1,
+ result = Array(n);
+
+ while (++index < n) {
+ result[index] = iteratee(index);
+ }
+ return result;
+}
+
+module.exports = baseTimes;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseToString.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseToString.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var Symbol = __webpack_require__(/*! ./_Symbol */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Symbol.js"),
+ arrayMap = __webpack_require__(/*! ./_arrayMap */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayMap.js"),
+ isArray = __webpack_require__(/*! ./isArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js"),
+ isSymbol = __webpack_require__(/*! ./isSymbol */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isSymbol.js");
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/** Used to convert symbols to primitives and strings. */
+var symbolProto = Symbol ? Symbol.prototype : undefined,
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
+
+/**
+ * The base implementation of `_.toString` which doesn't convert nullish
+ * values to empty strings.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {string} Returns the string.
+ */
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ if (isArray(value)) {
+ // Recursively convert values (susceptible to call stack limits).
+ return arrayMap(value, baseToString) + '';
+ }
+ if (isSymbol(value)) {
+ return symbolToString ? symbolToString.call(value) : '';
+ }
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+}
+
+module.exports = baseToString;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseUnary.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseUnary.js ***!
+ \***********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * The base implementation of `_.unary` without support for storing metadata.
+ *
+ * @private
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ */
+function baseUnary(func) {
+ return function(value) {
+ return func(value);
+ };
+}
+
+module.exports = baseUnary;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseUniq.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseUniq.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var SetCache = __webpack_require__(/*! ./_SetCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_SetCache.js"),
+ arrayIncludes = __webpack_require__(/*! ./_arrayIncludes */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayIncludes.js"),
+ arrayIncludesWith = __webpack_require__(/*! ./_arrayIncludesWith */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayIncludesWith.js"),
+ cacheHas = __webpack_require__(/*! ./_cacheHas */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_cacheHas.js"),
+ createSet = __webpack_require__(/*! ./_createSet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_createSet.js"),
+ setToArray = __webpack_require__(/*! ./_setToArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setToArray.js");
+
+/** Used as the size to enable large array optimizations. */
+var LARGE_ARRAY_SIZE = 200;
+
+/**
+ * The base implementation of `_.uniqBy` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ */
+function baseUniq(array, iteratee, comparator) {
+ var index = -1,
+ includes = arrayIncludes,
+ length = array.length,
+ isCommon = true,
+ result = [],
+ seen = result;
+
+ if (comparator) {
+ isCommon = false;
+ includes = arrayIncludesWith;
+ }
+ else if (length >= LARGE_ARRAY_SIZE) {
+ var set = iteratee ? null : createSet(array);
+ if (set) {
+ return setToArray(set);
+ }
+ isCommon = false;
+ includes = cacheHas;
+ seen = new SetCache;
+ }
+ else {
+ seen = iteratee ? [] : result;
+ }
+ outer:
+ while (++index < length) {
+ var value = array[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ value = (comparator || value !== 0) ? value : 0;
+ if (isCommon && computed === computed) {
+ var seenIndex = seen.length;
+ while (seenIndex--) {
+ if (seen[seenIndex] === computed) {
+ continue outer;
+ }
+ }
+ if (iteratee) {
+ seen.push(computed);
+ }
+ result.push(value);
+ }
+ else if (!includes(seen, computed, comparator)) {
+ if (seen !== result) {
+ seen.push(computed);
+ }
+ result.push(value);
+ }
+ }
+ return result;
+}
+
+module.exports = baseUniq;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_cacheHas.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_cacheHas.js ***!
+ \**********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Checks if a `cache` value for `key` exists.
+ *
+ * @private
+ * @param {Object} cache The cache to query.
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function cacheHas(cache, key) {
+ return cache.has(key);
+}
+
+module.exports = cacheHas;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_castPath.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_castPath.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isArray = __webpack_require__(/*! ./isArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js"),
+ isKey = __webpack_require__(/*! ./_isKey */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isKey.js"),
+ stringToPath = __webpack_require__(/*! ./_stringToPath */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stringToPath.js"),
+ toString = __webpack_require__(/*! ./toString */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/toString.js");
+
+/**
+ * Casts `value` to a path array if it's not one.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @param {Object} [object] The object to query keys on.
+ * @returns {Array} Returns the cast property path array.
+ */
+function castPath(value, object) {
+ if (isArray(value)) {
+ return value;
+ }
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
+}
+
+module.exports = castPath;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_coreJsData.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_coreJsData.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js");
+
+/** Used to detect overreaching core-js shims. */
+var coreJsData = root['__core-js_shared__'];
+
+module.exports = coreJsData;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_createSet.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_createSet.js ***!
+ \***********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var Set = __webpack_require__(/*! ./_Set */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Set.js"),
+ noop = __webpack_require__(/*! ./noop */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/noop.js"),
+ setToArray = __webpack_require__(/*! ./_setToArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setToArray.js");
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/**
+ * Creates a set object of `values`.
+ *
+ * @private
+ * @param {Array} values The values to add to the set.
+ * @returns {Object} Returns the new set.
+ */
+var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
+ return new Set(values);
+};
+
+module.exports = createSet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalArrays.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalArrays.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var SetCache = __webpack_require__(/*! ./_SetCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_SetCache.js"),
+ arraySome = __webpack_require__(/*! ./_arraySome */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arraySome.js"),
+ cacheHas = __webpack_require__(/*! ./_cacheHas */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_cacheHas.js");
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+/**
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
+ * partial deep comparisons.
+ *
+ * @private
+ * @param {Array} array The array to compare.
+ * @param {Array} other The other array to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
+ */
+function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ arrLength = array.length,
+ othLength = other.length;
+
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
+ return false;
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(array);
+ if (stacked && stack.get(other)) {
+ return stacked == other;
+ }
+ var index = -1,
+ result = true,
+ seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
+
+ stack.set(array, other);
+ stack.set(other, array);
+
+ // Ignore non-index properties.
+ while (++index < arrLength) {
+ var arrValue = array[index],
+ othValue = other[index];
+
+ if (customizer) {
+ var compared = isPartial
+ ? customizer(othValue, arrValue, index, other, array, stack)
+ : customizer(arrValue, othValue, index, array, other, stack);
+ }
+ if (compared !== undefined) {
+ if (compared) {
+ continue;
+ }
+ result = false;
+ break;
+ }
+ // Recursively compare arrays (susceptible to call stack limits).
+ if (seen) {
+ if (!arraySome(other, function(othValue, othIndex) {
+ if (!cacheHas(seen, othIndex) &&
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
+ return seen.push(othIndex);
+ }
+ })) {
+ result = false;
+ break;
+ }
+ } else if (!(
+ arrValue === othValue ||
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
+ )) {
+ result = false;
+ break;
+ }
+ }
+ stack['delete'](array);
+ stack['delete'](other);
+ return result;
+}
+
+module.exports = equalArrays;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalByTag.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalByTag.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var Symbol = __webpack_require__(/*! ./_Symbol */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Symbol.js"),
+ Uint8Array = __webpack_require__(/*! ./_Uint8Array */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Uint8Array.js"),
+ eq = __webpack_require__(/*! ./eq */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/eq.js"),
+ equalArrays = __webpack_require__(/*! ./_equalArrays */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalArrays.js"),
+ mapToArray = __webpack_require__(/*! ./_mapToArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapToArray.js"),
+ setToArray = __webpack_require__(/*! ./_setToArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setToArray.js");
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+/** `Object#toString` result references. */
+var boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ errorTag = '[object Error]',
+ mapTag = '[object Map]',
+ numberTag = '[object Number]',
+ regexpTag = '[object RegExp]',
+ setTag = '[object Set]',
+ stringTag = '[object String]',
+ symbolTag = '[object Symbol]';
+
+var arrayBufferTag = '[object ArrayBuffer]',
+ dataViewTag = '[object DataView]';
+
+/** Used to convert symbols to primitives and strings. */
+var symbolProto = Symbol ? Symbol.prototype : undefined,
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
+
+/**
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
+ * the same `toStringTag`.
+ *
+ * **Note:** This function only supports comparing values with tags of
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {string} tag The `toStringTag` of the objects to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
+ switch (tag) {
+ case dataViewTag:
+ if ((object.byteLength != other.byteLength) ||
+ (object.byteOffset != other.byteOffset)) {
+ return false;
+ }
+ object = object.buffer;
+ other = other.buffer;
+
+ case arrayBufferTag:
+ if ((object.byteLength != other.byteLength) ||
+ !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
+ return false;
+ }
+ return true;
+
+ case boolTag:
+ case dateTag:
+ case numberTag:
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
+ // Invalid dates are coerced to `NaN`.
+ return eq(+object, +other);
+
+ case errorTag:
+ return object.name == other.name && object.message == other.message;
+
+ case regexpTag:
+ case stringTag:
+ // Coerce regexes to strings and treat strings, primitives and objects,
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
+ // for more details.
+ return object == (other + '');
+
+ case mapTag:
+ var convert = mapToArray;
+
+ case setTag:
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
+ convert || (convert = setToArray);
+
+ if (object.size != other.size && !isPartial) {
+ return false;
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(object);
+ if (stacked) {
+ return stacked == other;
+ }
+ bitmask |= COMPARE_UNORDERED_FLAG;
+
+ // Recursively compare objects (susceptible to call stack limits).
+ stack.set(object, other);
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
+ stack['delete'](object);
+ return result;
+
+ case symbolTag:
+ if (symbolValueOf) {
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
+ }
+ }
+ return false;
+}
+
+module.exports = equalByTag;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalObjects.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_equalObjects.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getAllKeys = __webpack_require__(/*! ./_getAllKeys */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getAllKeys.js");
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1;
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * A specialized version of `baseIsEqualDeep` for objects with support for
+ * partial deep comparisons.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ objProps = getAllKeys(object),
+ objLength = objProps.length,
+ othProps = getAllKeys(other),
+ othLength = othProps.length;
+
+ if (objLength != othLength && !isPartial) {
+ return false;
+ }
+ var index = objLength;
+ while (index--) {
+ var key = objProps[index];
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
+ return false;
+ }
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(object);
+ if (stacked && stack.get(other)) {
+ return stacked == other;
+ }
+ var result = true;
+ stack.set(object, other);
+ stack.set(other, object);
+
+ var skipCtor = isPartial;
+ while (++index < objLength) {
+ key = objProps[index];
+ var objValue = object[key],
+ othValue = other[key];
+
+ if (customizer) {
+ var compared = isPartial
+ ? customizer(othValue, objValue, key, other, object, stack)
+ : customizer(objValue, othValue, key, object, other, stack);
+ }
+ // Recursively compare objects (susceptible to call stack limits).
+ if (!(compared === undefined
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
+ : compared
+ )) {
+ result = false;
+ break;
+ }
+ skipCtor || (skipCtor = key == 'constructor');
+ }
+ if (result && !skipCtor) {
+ var objCtor = object.constructor,
+ othCtor = other.constructor;
+
+ // Non `Object` object instances with different constructors are not equal.
+ if (objCtor != othCtor &&
+ ('constructor' in object && 'constructor' in other) &&
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
+ result = false;
+ }
+ }
+ stack['delete'](object);
+ stack['delete'](other);
+ return result;
+}
+
+module.exports = equalObjects;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_freeGlobal.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_freeGlobal.js ***!
+ \************************************************************************************************/
+/***/ ((module) => {
+
+/** Detect free variable `global` from Node.js. */
+var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+module.exports = freeGlobal;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getAllKeys.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getAllKeys.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseGetAllKeys = __webpack_require__(/*! ./_baseGetAllKeys */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetAllKeys.js"),
+ getSymbols = __webpack_require__(/*! ./_getSymbols */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getSymbols.js"),
+ keys = __webpack_require__(/*! ./keys */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/keys.js");
+
+/**
+ * Creates an array of own enumerable property names and symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names and symbols.
+ */
+function getAllKeys(object) {
+ return baseGetAllKeys(object, keys, getSymbols);
+}
+
+module.exports = getAllKeys;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMapData.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMapData.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isKeyable = __webpack_require__(/*! ./_isKeyable */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isKeyable.js");
+
+/**
+ * Gets the data for `map`.
+ *
+ * @private
+ * @param {Object} map The map to query.
+ * @param {string} key The reference key.
+ * @returns {*} Returns the map data.
+ */
+function getMapData(map, key) {
+ var data = map.__data__;
+ return isKeyable(key)
+ ? data[typeof key == 'string' ? 'string' : 'hash']
+ : data.map;
+}
+
+module.exports = getMapData;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMatchData.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMatchData.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isStrictComparable = __webpack_require__(/*! ./_isStrictComparable */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isStrictComparable.js"),
+ keys = __webpack_require__(/*! ./keys */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/keys.js");
+
+/**
+ * Gets the property names, values, and compare flags of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the match data of `object`.
+ */
+function getMatchData(object) {
+ var result = keys(object),
+ length = result.length;
+
+ while (length--) {
+ var key = result[length],
+ value = object[key];
+
+ result[length] = [key, value, isStrictComparable(value)];
+ }
+ return result;
+}
+
+module.exports = getMatchData;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getNative.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getNative.js ***!
+ \***********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseIsNative = __webpack_require__(/*! ./_baseIsNative */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsNative.js"),
+ getValue = __webpack_require__(/*! ./_getValue */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getValue.js");
+
+/**
+ * Gets the native function at `key` of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {string} key The key of the method to get.
+ * @returns {*} Returns the function if it's native, else `undefined`.
+ */
+function getNative(object, key) {
+ var value = getValue(object, key);
+ return baseIsNative(value) ? value : undefined;
+}
+
+module.exports = getNative;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getRawTag.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getRawTag.js ***!
+ \***********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var Symbol = __webpack_require__(/*! ./_Symbol */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Symbol.js");
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var nativeObjectToString = objectProto.toString;
+
+/** Built-in value references. */
+var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
+
+/**
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the raw `toStringTag`.
+ */
+function getRawTag(value) {
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
+ tag = value[symToStringTag];
+
+ try {
+ value[symToStringTag] = undefined;
+ var unmasked = true;
+ } catch (e) {}
+
+ var result = nativeObjectToString.call(value);
+ if (unmasked) {
+ if (isOwn) {
+ value[symToStringTag] = tag;
+ } else {
+ delete value[symToStringTag];
+ }
+ }
+ return result;
+}
+
+module.exports = getRawTag;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getSymbols.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getSymbols.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var arrayFilter = __webpack_require__(/*! ./_arrayFilter */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayFilter.js"),
+ stubArray = __webpack_require__(/*! ./stubArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/stubArray.js");
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Built-in value references. */
+var propertyIsEnumerable = objectProto.propertyIsEnumerable;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeGetSymbols = Object.getOwnPropertySymbols;
+
+/**
+ * Creates an array of the own enumerable symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of symbols.
+ */
+var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
+ if (object == null) {
+ return [];
+ }
+ object = Object(object);
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
+ return propertyIsEnumerable.call(object, symbol);
+ });
+};
+
+module.exports = getSymbols;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getTag.js":
+/*!********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getTag.js ***!
+ \********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var DataView = __webpack_require__(/*! ./_DataView */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_DataView.js"),
+ Map = __webpack_require__(/*! ./_Map */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Map.js"),
+ Promise = __webpack_require__(/*! ./_Promise */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Promise.js"),
+ Set = __webpack_require__(/*! ./_Set */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Set.js"),
+ WeakMap = __webpack_require__(/*! ./_WeakMap */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_WeakMap.js"),
+ baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetTag.js"),
+ toSource = __webpack_require__(/*! ./_toSource */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toSource.js");
+
+/** `Object#toString` result references. */
+var mapTag = '[object Map]',
+ objectTag = '[object Object]',
+ promiseTag = '[object Promise]',
+ setTag = '[object Set]',
+ weakMapTag = '[object WeakMap]';
+
+var dataViewTag = '[object DataView]';
+
+/** Used to detect maps, sets, and weakmaps. */
+var dataViewCtorString = toSource(DataView),
+ mapCtorString = toSource(Map),
+ promiseCtorString = toSource(Promise),
+ setCtorString = toSource(Set),
+ weakMapCtorString = toSource(WeakMap);
+
+/**
+ * Gets the `toStringTag` of `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+var getTag = baseGetTag;
+
+// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
+if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
+ (Map && getTag(new Map) != mapTag) ||
+ (Promise && getTag(Promise.resolve()) != promiseTag) ||
+ (Set && getTag(new Set) != setTag) ||
+ (WeakMap && getTag(new WeakMap) != weakMapTag)) {
+ getTag = function(value) {
+ var result = baseGetTag(value),
+ Ctor = result == objectTag ? value.constructor : undefined,
+ ctorString = Ctor ? toSource(Ctor) : '';
+
+ if (ctorString) {
+ switch (ctorString) {
+ case dataViewCtorString: return dataViewTag;
+ case mapCtorString: return mapTag;
+ case promiseCtorString: return promiseTag;
+ case setCtorString: return setTag;
+ case weakMapCtorString: return weakMapTag;
+ }
+ }
+ return result;
+ };
+}
+
+module.exports = getTag;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getValue.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getValue.js ***!
+ \**********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Gets the value at `key` of `object`.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {string} key The key of the property to get.
+ * @returns {*} Returns the property value.
+ */
+function getValue(object, key) {
+ return object == null ? undefined : object[key];
+}
+
+module.exports = getValue;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hasPath.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hasPath.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var castPath = __webpack_require__(/*! ./_castPath */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_castPath.js"),
+ isArguments = __webpack_require__(/*! ./isArguments */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArguments.js"),
+ isArray = __webpack_require__(/*! ./isArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js"),
+ isIndex = __webpack_require__(/*! ./_isIndex */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isIndex.js"),
+ isLength = __webpack_require__(/*! ./isLength */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isLength.js"),
+ toKey = __webpack_require__(/*! ./_toKey */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toKey.js");
+
+/**
+ * Checks if `path` exists on `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @param {Function} hasFunc The function to check properties.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ */
+function hasPath(object, path, hasFunc) {
+ path = castPath(path, object);
+
+ var index = -1,
+ length = path.length,
+ result = false;
+
+ while (++index < length) {
+ var key = toKey(path[index]);
+ if (!(result = object != null && hasFunc(object, key))) {
+ break;
+ }
+ object = object[key];
+ }
+ if (result || ++index != length) {
+ return result;
+ }
+ length = object == null ? 0 : object.length;
+ return !!length && isLength(length) && isIndex(key, length) &&
+ (isArray(object) || isArguments(object));
+}
+
+module.exports = hasPath;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashClear.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashClear.js ***!
+ \***********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeCreate.js");
+
+/**
+ * Removes all key-value entries from the hash.
+ *
+ * @private
+ * @name clear
+ * @memberOf Hash
+ */
+function hashClear() {
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
+ this.size = 0;
+}
+
+module.exports = hashClear;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashDelete.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashDelete.js ***!
+ \************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Removes `key` and its value from the hash.
+ *
+ * @private
+ * @name delete
+ * @memberOf Hash
+ * @param {Object} hash The hash to modify.
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+function hashDelete(key) {
+ var result = this.has(key) && delete this.__data__[key];
+ this.size -= result ? 1 : 0;
+ return result;
+}
+
+module.exports = hashDelete;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashGet.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashGet.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeCreate.js");
+
+/** Used to stand-in for `undefined` hash values. */
+var HASH_UNDEFINED = '__lodash_hash_undefined__';
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Gets the hash value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf Hash
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+function hashGet(key) {
+ var data = this.__data__;
+ if (nativeCreate) {
+ var result = data[key];
+ return result === HASH_UNDEFINED ? undefined : result;
+ }
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
+}
+
+module.exports = hashGet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashHas.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashHas.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeCreate.js");
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Checks if a hash value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf Hash
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function hashHas(key) {
+ var data = this.__data__;
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
+}
+
+module.exports = hashHas;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashSet.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hashSet.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeCreate.js");
+
+/** Used to stand-in for `undefined` hash values. */
+var HASH_UNDEFINED = '__lodash_hash_undefined__';
+
+/**
+ * Sets the hash `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf Hash
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the hash instance.
+ */
+function hashSet(key, value) {
+ var data = this.__data__;
+ this.size += this.has(key) ? 0 : 1;
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
+ return this;
+}
+
+module.exports = hashSet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isIndex.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isIndex.js ***!
+ \*********************************************************************************************/
+/***/ ((module) => {
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/** Used to detect unsigned integer values. */
+var reIsUint = /^(?:0|[1-9]\d*)$/;
+
+/**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+function isIndex(value, length) {
+ var type = typeof value;
+ length = length == null ? MAX_SAFE_INTEGER : length;
+
+ return !!length &&
+ (type == 'number' ||
+ (type != 'symbol' && reIsUint.test(value))) &&
+ (value > -1 && value % 1 == 0 && value < length);
+}
+
+module.exports = isIndex;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isKey.js":
+/*!*******************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isKey.js ***!
+ \*******************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isArray = __webpack_require__(/*! ./isArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js"),
+ isSymbol = __webpack_require__(/*! ./isSymbol */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isSymbol.js");
+
+/** Used to match property names within property paths. */
+var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
+ reIsPlainProp = /^\w*$/;
+
+/**
+ * Checks if `value` is a property name and not a property path.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {Object} [object] The object to query keys on.
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
+ */
+function isKey(value, object) {
+ if (isArray(value)) {
+ return false;
+ }
+ var type = typeof value;
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
+ value == null || isSymbol(value)) {
+ return true;
+ }
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
+ (object != null && value in Object(object));
+}
+
+module.exports = isKey;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isKeyable.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isKeyable.js ***!
+ \***********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Checks if `value` is suitable for use as unique object key.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
+ */
+function isKeyable(value) {
+ var type = typeof value;
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
+ ? (value !== '__proto__')
+ : (value === null);
+}
+
+module.exports = isKeyable;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isMasked.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isMasked.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var coreJsData = __webpack_require__(/*! ./_coreJsData */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_coreJsData.js");
+
+/** Used to detect methods masquerading as native. */
+var maskSrcKey = (function() {
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
+ return uid ? ('Symbol(src)_1.' + uid) : '';
+}());
+
+/**
+ * Checks if `func` has its source masked.
+ *
+ * @private
+ * @param {Function} func The function to check.
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
+ */
+function isMasked(func) {
+ return !!maskSrcKey && (maskSrcKey in func);
+}
+
+module.exports = isMasked;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isPrototype.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isPrototype.js ***!
+ \*************************************************************************************************/
+/***/ ((module) => {
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/**
+ * Checks if `value` is likely a prototype object.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
+ */
+function isPrototype(value) {
+ var Ctor = value && value.constructor,
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
+
+ return value === proto;
+}
+
+module.exports = isPrototype;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isStrictComparable.js":
+/*!********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isStrictComparable.js ***!
+ \********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isObject = __webpack_require__(/*! ./isObject */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObject.js");
+
+/**
+ * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` if suitable for strict
+ * equality comparisons, else `false`.
+ */
+function isStrictComparable(value) {
+ return value === value && !isObject(value);
+}
+
+module.exports = isStrictComparable;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheClear.js":
+/*!****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheClear.js ***!
+ \****************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Removes all key-value entries from the list cache.
+ *
+ * @private
+ * @name clear
+ * @memberOf ListCache
+ */
+function listCacheClear() {
+ this.__data__ = [];
+ this.size = 0;
+}
+
+module.exports = listCacheClear;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheDelete.js":
+/*!*****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheDelete.js ***!
+ \*****************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_assocIndexOf.js");
+
+/** Used for built-in method references. */
+var arrayProto = Array.prototype;
+
+/** Built-in value references. */
+var splice = arrayProto.splice;
+
+/**
+ * Removes `key` and its value from the list cache.
+ *
+ * @private
+ * @name delete
+ * @memberOf ListCache
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+function listCacheDelete(key) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ if (index < 0) {
+ return false;
+ }
+ var lastIndex = data.length - 1;
+ if (index == lastIndex) {
+ data.pop();
+ } else {
+ splice.call(data, index, 1);
+ }
+ --this.size;
+ return true;
+}
+
+module.exports = listCacheDelete;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheGet.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheGet.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_assocIndexOf.js");
+
+/**
+ * Gets the list cache value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf ListCache
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+function listCacheGet(key) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ return index < 0 ? undefined : data[index][1];
+}
+
+module.exports = listCacheGet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheHas.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheHas.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_assocIndexOf.js");
+
+/**
+ * Checks if a list cache value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf ListCache
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function listCacheHas(key) {
+ return assocIndexOf(this.__data__, key) > -1;
+}
+
+module.exports = listCacheHas;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheSet.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_listCacheSet.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_assocIndexOf.js");
+
+/**
+ * Sets the list cache `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf ListCache
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the list cache instance.
+ */
+function listCacheSet(key, value) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ if (index < 0) {
+ ++this.size;
+ data.push([key, value]);
+ } else {
+ data[index][1] = value;
+ }
+ return this;
+}
+
+module.exports = listCacheSet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheClear.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheClear.js ***!
+ \***************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var Hash = __webpack_require__(/*! ./_Hash */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Hash.js"),
+ ListCache = __webpack_require__(/*! ./_ListCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_ListCache.js"),
+ Map = __webpack_require__(/*! ./_Map */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Map.js");
+
+/**
+ * Removes all key-value entries from the map.
+ *
+ * @private
+ * @name clear
+ * @memberOf MapCache
+ */
+function mapCacheClear() {
+ this.size = 0;
+ this.__data__ = {
+ 'hash': new Hash,
+ 'map': new (Map || ListCache),
+ 'string': new Hash
+ };
+}
+
+module.exports = mapCacheClear;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheDelete.js":
+/*!****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheDelete.js ***!
+ \****************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getMapData = __webpack_require__(/*! ./_getMapData */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMapData.js");
+
+/**
+ * Removes `key` and its value from the map.
+ *
+ * @private
+ * @name delete
+ * @memberOf MapCache
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+function mapCacheDelete(key) {
+ var result = getMapData(this, key)['delete'](key);
+ this.size -= result ? 1 : 0;
+ return result;
+}
+
+module.exports = mapCacheDelete;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheGet.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheGet.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getMapData = __webpack_require__(/*! ./_getMapData */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMapData.js");
+
+/**
+ * Gets the map value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf MapCache
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+function mapCacheGet(key) {
+ return getMapData(this, key).get(key);
+}
+
+module.exports = mapCacheGet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheHas.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheHas.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getMapData = __webpack_require__(/*! ./_getMapData */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMapData.js");
+
+/**
+ * Checks if a map value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf MapCache
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function mapCacheHas(key) {
+ return getMapData(this, key).has(key);
+}
+
+module.exports = mapCacheHas;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheSet.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapCacheSet.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getMapData = __webpack_require__(/*! ./_getMapData */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getMapData.js");
+
+/**
+ * Sets the map `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf MapCache
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the map cache instance.
+ */
+function mapCacheSet(key, value) {
+ var data = getMapData(this, key),
+ size = data.size;
+
+ data.set(key, value);
+ this.size += data.size == size ? 0 : 1;
+ return this;
+}
+
+module.exports = mapCacheSet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapToArray.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_mapToArray.js ***!
+ \************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Converts `map` to its key-value pairs.
+ *
+ * @private
+ * @param {Object} map The map to convert.
+ * @returns {Array} Returns the key-value pairs.
+ */
+function mapToArray(map) {
+ var index = -1,
+ result = Array(map.size);
+
+ map.forEach(function(value, key) {
+ result[++index] = [key, value];
+ });
+ return result;
+}
+
+module.exports = mapToArray;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_matchesStrictComparable.js":
+/*!*************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_matchesStrictComparable.js ***!
+ \*************************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * A specialized version of `matchesProperty` for source values suitable
+ * for strict equality comparisons, i.e. `===`.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @param {*} srcValue The value to match.
+ * @returns {Function} Returns the new spec function.
+ */
+function matchesStrictComparable(key, srcValue) {
+ return function(object) {
+ if (object == null) {
+ return false;
+ }
+ return object[key] === srcValue &&
+ (srcValue !== undefined || (key in Object(object)));
+ };
+}
+
+module.exports = matchesStrictComparable;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_memoizeCapped.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_memoizeCapped.js ***!
+ \***************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var memoize = __webpack_require__(/*! ./memoize */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/memoize.js");
+
+/** Used as the maximum memoize cache size. */
+var MAX_MEMOIZE_SIZE = 500;
+
+/**
+ * A specialized version of `_.memoize` which clears the memoized function's
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
+ *
+ * @private
+ * @param {Function} func The function to have its output memoized.
+ * @returns {Function} Returns the new memoized function.
+ */
+function memoizeCapped(func) {
+ var result = memoize(func, function(key) {
+ if (cache.size === MAX_MEMOIZE_SIZE) {
+ cache.clear();
+ }
+ return key;
+ });
+
+ var cache = result.cache;
+ return result;
+}
+
+module.exports = memoizeCapped;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeCreate.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeCreate.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_getNative.js");
+
+/* Built-in method references that are verified to be native. */
+var nativeCreate = getNative(Object, 'create');
+
+module.exports = nativeCreate;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeKeys.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nativeKeys.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var overArg = __webpack_require__(/*! ./_overArg */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_overArg.js");
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeKeys = overArg(Object.keys, Object);
+
+module.exports = nativeKeys;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nodeUtil.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nodeUtil.js ***!
+ \**********************************************************************************************/
+/***/ ((module, exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var freeGlobal = __webpack_require__(/*! ./_freeGlobal */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_freeGlobal.js");
+
+/** Detect free variable `exports`. */
+var freeExports = true && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports = freeModule && freeModule.exports === freeExports;
+
+/** Detect free variable `process` from Node.js. */
+var freeProcess = moduleExports && freeGlobal.process;
+
+/** Used to access faster Node.js helpers. */
+var nodeUtil = (function() {
+ try {
+ // Use `util.types` for Node.js 10+.
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
+
+ if (types) {
+ return types;
+ }
+
+ // Legacy `process.binding('util')` for Node.js < 10.
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
+ } catch (e) {}
+}());
+
+module.exports = nodeUtil;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_objectToString.js":
+/*!****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_objectToString.js ***!
+ \****************************************************************************************************/
+/***/ ((module) => {
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var nativeObjectToString = objectProto.toString;
+
+/**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+function objectToString(value) {
+ return nativeObjectToString.call(value);
+}
+
+module.exports = objectToString;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_overArg.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_overArg.js ***!
+ \*********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+}
+
+module.exports = overArg;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js":
+/*!******************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js ***!
+ \******************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var freeGlobal = __webpack_require__(/*! ./_freeGlobal */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_freeGlobal.js");
+
+/** Detect free variable `self`. */
+var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+/** Used as a reference to the global object. */
+var root = freeGlobal || freeSelf || Function('return this')();
+
+module.exports = root;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setCacheAdd.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setCacheAdd.js ***!
+ \*************************************************************************************************/
+/***/ ((module) => {
+
+/** Used to stand-in for `undefined` hash values. */
+var HASH_UNDEFINED = '__lodash_hash_undefined__';
+
+/**
+ * Adds `value` to the array cache.
+ *
+ * @private
+ * @name add
+ * @memberOf SetCache
+ * @alias push
+ * @param {*} value The value to cache.
+ * @returns {Object} Returns the cache instance.
+ */
+function setCacheAdd(value) {
+ this.__data__.set(value, HASH_UNDEFINED);
+ return this;
+}
+
+module.exports = setCacheAdd;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setCacheHas.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setCacheHas.js ***!
+ \*************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Checks if `value` is in the array cache.
+ *
+ * @private
+ * @name has
+ * @memberOf SetCache
+ * @param {*} value The value to search for.
+ * @returns {number} Returns `true` if `value` is found, else `false`.
+ */
+function setCacheHas(value) {
+ return this.__data__.has(value);
+}
+
+module.exports = setCacheHas;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setToArray.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_setToArray.js ***!
+ \************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Converts `set` to an array of its values.
+ *
+ * @private
+ * @param {Object} set The set to convert.
+ * @returns {Array} Returns the values.
+ */
+function setToArray(set) {
+ var index = -1,
+ result = Array(set.size);
+
+ set.forEach(function(value) {
+ result[++index] = value;
+ });
+ return result;
+}
+
+module.exports = setToArray;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackClear.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackClear.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var ListCache = __webpack_require__(/*! ./_ListCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_ListCache.js");
+
+/**
+ * Removes all key-value entries from the stack.
+ *
+ * @private
+ * @name clear
+ * @memberOf Stack
+ */
+function stackClear() {
+ this.__data__ = new ListCache;
+ this.size = 0;
+}
+
+module.exports = stackClear;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackDelete.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackDelete.js ***!
+ \*************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Removes `key` and its value from the stack.
+ *
+ * @private
+ * @name delete
+ * @memberOf Stack
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+function stackDelete(key) {
+ var data = this.__data__,
+ result = data['delete'](key);
+
+ this.size = data.size;
+ return result;
+}
+
+module.exports = stackDelete;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackGet.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackGet.js ***!
+ \**********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Gets the stack value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf Stack
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+function stackGet(key) {
+ return this.__data__.get(key);
+}
+
+module.exports = stackGet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackHas.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackHas.js ***!
+ \**********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Checks if a stack value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf Stack
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function stackHas(key) {
+ return this.__data__.has(key);
+}
+
+module.exports = stackHas;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackSet.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stackSet.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var ListCache = __webpack_require__(/*! ./_ListCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_ListCache.js"),
+ Map = __webpack_require__(/*! ./_Map */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_Map.js"),
+ MapCache = __webpack_require__(/*! ./_MapCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_MapCache.js");
+
+/** Used as the size to enable large array optimizations. */
+var LARGE_ARRAY_SIZE = 200;
+
+/**
+ * Sets the stack `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf Stack
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the stack cache instance.
+ */
+function stackSet(key, value) {
+ var data = this.__data__;
+ if (data instanceof ListCache) {
+ var pairs = data.__data__;
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
+ pairs.push([key, value]);
+ this.size = ++data.size;
+ return this;
+ }
+ data = this.__data__ = new MapCache(pairs);
+ }
+ data.set(key, value);
+ this.size = data.size;
+ return this;
+}
+
+module.exports = stackSet;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_strictIndexOf.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_strictIndexOf.js ***!
+ \***************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * A specialized version of `_.indexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function strictIndexOf(array, value, fromIndex) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+module.exports = strictIndexOf;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stringToPath.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_stringToPath.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var memoizeCapped = __webpack_require__(/*! ./_memoizeCapped */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_memoizeCapped.js");
+
+/** Used to match property names within property paths. */
+var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
+
+/** Used to match backslashes in property paths. */
+var reEscapeChar = /\\(\\)?/g;
+
+/**
+ * Converts `string` to a property path array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the property path array.
+ */
+var stringToPath = memoizeCapped(function(string) {
+ var result = [];
+ if (string.charCodeAt(0) === 46 /* . */) {
+ result.push('');
+ }
+ string.replace(rePropName, function(match, number, quote, subString) {
+ result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
+ });
+ return result;
+});
+
+module.exports = stringToPath;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toKey.js":
+/*!*******************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toKey.js ***!
+ \*******************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isSymbol = __webpack_require__(/*! ./isSymbol */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isSymbol.js");
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/**
+ * Converts `value` to a string key if it's not a string or symbol.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {string|symbol} Returns the key.
+ */
+function toKey(value) {
+ if (typeof value == 'string' || isSymbol(value)) {
+ return value;
+ }
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+}
+
+module.exports = toKey;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toSource.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toSource.js ***!
+ \**********************************************************************************************/
+/***/ ((module) => {
+
+/** Used for built-in method references. */
+var funcProto = Function.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString = funcProto.toString;
+
+/**
+ * Converts `func` to its source code.
+ *
+ * @private
+ * @param {Function} func The function to convert.
+ * @returns {string} Returns the source code.
+ */
+function toSource(func) {
+ if (func != null) {
+ try {
+ return funcToString.call(func);
+ } catch (e) {}
+ try {
+ return (func + '');
+ } catch (e) {}
+ }
+ return '';
+}
+
+module.exports = toSource;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/eq.js":
+/*!***************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/eq.js ***!
+ \***************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Performs a
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * comparison between two values to determine if they are equivalent.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
+ *
+ * _.eq(object, object);
+ * // => true
+ *
+ * _.eq(object, other);
+ * // => false
+ *
+ * _.eq('a', 'a');
+ * // => true
+ *
+ * _.eq('a', Object('a'));
+ * // => false
+ *
+ * _.eq(NaN, NaN);
+ * // => true
+ */
+function eq(value, other) {
+ return value === other || (value !== value && other !== other);
+}
+
+module.exports = eq;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/get.js":
+/*!****************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/get.js ***!
+ \****************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseGet = __webpack_require__(/*! ./_baseGet */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGet.js");
+
+/**
+ * Gets the value at `path` of `object`. If the resolved value is
+ * `undefined`, the `defaultValue` is returned in its place.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to get.
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.get(object, 'a[0].b.c');
+ * // => 3
+ *
+ * _.get(object, ['a', '0', 'b', 'c']);
+ * // => 3
+ *
+ * _.get(object, 'a.b.c', 'default');
+ * // => 'default'
+ */
+function get(object, path, defaultValue) {
+ var result = object == null ? undefined : baseGet(object, path);
+ return result === undefined ? defaultValue : result;
+}
+
+module.exports = get;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/hasIn.js":
+/*!******************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/hasIn.js ***!
+ \******************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseHasIn = __webpack_require__(/*! ./_baseHasIn */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseHasIn.js"),
+ hasPath = __webpack_require__(/*! ./_hasPath */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_hasPath.js");
+
+/**
+ * Checks if `path` is a direct or inherited property of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ * @example
+ *
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
+ *
+ * _.hasIn(object, 'a');
+ * // => true
+ *
+ * _.hasIn(object, 'a.b');
+ * // => true
+ *
+ * _.hasIn(object, ['a', 'b']);
+ * // => true
+ *
+ * _.hasIn(object, 'b');
+ * // => false
+ */
+function hasIn(object, path) {
+ return object != null && hasPath(object, path, baseHasIn);
+}
+
+module.exports = hasIn;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/identity.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/identity.js ***!
+ \*********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * This method returns the first argument it receives.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ *
+ * console.log(_.identity(object) === object);
+ * // => true
+ */
+function identity(value) {
+ return value;
+}
+
+module.exports = identity;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArguments.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArguments.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseIsArguments = __webpack_require__(/*! ./_baseIsArguments */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsArguments.js"),
+ isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObjectLike.js");
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/** Built-in value references. */
+var propertyIsEnumerable = objectProto.propertyIsEnumerable;
+
+/**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */
+var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+};
+
+module.exports = isArguments;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js":
+/*!********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArray.js ***!
+ \********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+var isArray = Array.isArray;
+
+module.exports = isArray;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArrayLike.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArrayLike.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var isFunction = __webpack_require__(/*! ./isFunction */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isFunction.js"),
+ isLength = __webpack_require__(/*! ./isLength */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isLength.js");
+
+/**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */
+function isArrayLike(value) {
+ return value != null && isLength(value.length) && !isFunction(value);
+}
+
+module.exports = isArrayLike;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isBuffer.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isBuffer.js ***!
+ \*********************************************************************************************/
+/***/ ((module, exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var root = __webpack_require__(/*! ./_root */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_root.js"),
+ stubFalse = __webpack_require__(/*! ./stubFalse */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/stubFalse.js");
+
+/** Detect free variable `exports`. */
+var freeExports = true && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports = freeModule && freeModule.exports === freeExports;
+
+/** Built-in value references. */
+var Buffer = moduleExports ? root.Buffer : undefined;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
+
+/**
+ * Checks if `value` is a buffer.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
+ * @example
+ *
+ * _.isBuffer(new Buffer(2));
+ * // => true
+ *
+ * _.isBuffer(new Uint8Array(2));
+ * // => false
+ */
+var isBuffer = nativeIsBuffer || stubFalse;
+
+module.exports = isBuffer;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isFunction.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isFunction.js ***!
+ \***********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetTag.js"),
+ isObject = __webpack_require__(/*! ./isObject */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObject.js");
+
+/** `Object#toString` result references. */
+var asyncTag = '[object AsyncFunction]',
+ funcTag = '[object Function]',
+ genTag = '[object GeneratorFunction]',
+ proxyTag = '[object Proxy]';
+
+/**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */
+function isFunction(value) {
+ if (!isObject(value)) {
+ return false;
+ }
+ // The use of `Object#toString` avoids issues with the `typeof` operator
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
+ var tag = baseGetTag(value);
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
+}
+
+module.exports = isFunction;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isLength.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isLength.js ***!
+ \*********************************************************************************************/
+/***/ ((module) => {
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */
+function isLength(value) {
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+}
+
+module.exports = isLength;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObject.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObject.js ***!
+ \*********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == 'object' || type == 'function');
+}
+
+module.exports = isObject;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObjectLike.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObjectLike.js ***!
+ \*************************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+function isObjectLike(value) {
+ return value != null && typeof value == 'object';
+}
+
+module.exports = isObjectLike;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isSymbol.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isSymbol.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseGetTag.js"),
+ isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isObjectLike.js");
+
+/** `Object#toString` result references. */
+var symbolTag = '[object Symbol]';
+
+/**
+ * Checks if `value` is classified as a `Symbol` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @example
+ *
+ * _.isSymbol(Symbol.iterator);
+ * // => true
+ *
+ * _.isSymbol('abc');
+ * // => false
+ */
+function isSymbol(value) {
+ return typeof value == 'symbol' ||
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
+}
+
+module.exports = isSymbol;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isTypedArray.js":
+/*!*************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isTypedArray.js ***!
+ \*************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseIsTypedArray = __webpack_require__(/*! ./_baseIsTypedArray */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIsTypedArray.js"),
+ baseUnary = __webpack_require__(/*! ./_baseUnary */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseUnary.js"),
+ nodeUtil = __webpack_require__(/*! ./_nodeUtil */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_nodeUtil.js");
+
+/* Node.js helper references. */
+var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
+
+/**
+ * Checks if `value` is classified as a typed array.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ * @example
+ *
+ * _.isTypedArray(new Uint8Array);
+ * // => true
+ *
+ * _.isTypedArray([]);
+ * // => false
+ */
+var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
+
+module.exports = isTypedArray;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/keys.js":
+/*!*****************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/keys.js ***!
+ \*****************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var arrayLikeKeys = __webpack_require__(/*! ./_arrayLikeKeys */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_arrayLikeKeys.js"),
+ baseKeys = __webpack_require__(/*! ./_baseKeys */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseKeys.js"),
+ isArrayLike = __webpack_require__(/*! ./isArrayLike */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/isArrayLike.js");
+
+/**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+function keys(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
+}
+
+module.exports = keys;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/memoize.js":
+/*!********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/memoize.js ***!
+ \********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var MapCache = __webpack_require__(/*! ./_MapCache */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_MapCache.js");
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * Creates a function that memoizes the result of `func`. If `resolver` is
+ * provided, it determines the cache key for storing the result based on the
+ * arguments provided to the memoized function. By default, the first argument
+ * provided to the memoized function is used as the map cache key. The `func`
+ * is invoked with the `this` binding of the memoized function.
+ *
+ * **Note:** The cache is exposed as the `cache` property on the memoized
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
+ * constructor with one whose instances implement the
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to have its output memoized.
+ * @param {Function} [resolver] The function to resolve the cache key.
+ * @returns {Function} Returns the new memoized function.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ * var other = { 'c': 3, 'd': 4 };
+ *
+ * var values = _.memoize(_.values);
+ * values(object);
+ * // => [1, 2]
+ *
+ * values(other);
+ * // => [3, 4]
+ *
+ * object.a = 2;
+ * values(object);
+ * // => [1, 2]
+ *
+ * // Modify the result cache.
+ * values.cache.set(object, ['a', 'b']);
+ * values(object);
+ * // => ['a', 'b']
+ *
+ * // Replace `_.memoize.Cache`.
+ * _.memoize.Cache = WeakMap;
+ */
+function memoize(func, resolver) {
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ var memoized = function() {
+ var args = arguments,
+ key = resolver ? resolver.apply(this, args) : args[0],
+ cache = memoized.cache;
+
+ if (cache.has(key)) {
+ return cache.get(key);
+ }
+ var result = func.apply(this, args);
+ memoized.cache = cache.set(key, result) || cache;
+ return result;
+ };
+ memoized.cache = new (memoize.Cache || MapCache);
+ return memoized;
+}
+
+// Expose `MapCache`.
+memoize.Cache = MapCache;
+
+module.exports = memoize;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/noop.js":
+/*!*****************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/noop.js ***!
+ \*****************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * This method returns `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Util
+ * @example
+ *
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
+ */
+function noop() {
+ // No operation performed.
+}
+
+module.exports = noop;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/property.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/property.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseProperty = __webpack_require__(/*! ./_baseProperty */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseProperty.js"),
+ basePropertyDeep = __webpack_require__(/*! ./_basePropertyDeep */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_basePropertyDeep.js"),
+ isKey = __webpack_require__(/*! ./_isKey */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_isKey.js"),
+ toKey = __webpack_require__(/*! ./_toKey */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_toKey.js");
+
+/**
+ * Creates a function that returns the value at `path` of a given object.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {Array|string} path The path of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': { 'b': 2 } },
+ * { 'a': { 'b': 1 } }
+ * ];
+ *
+ * _.map(objects, _.property('a.b'));
+ * // => [2, 1]
+ *
+ * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
+ * // => [1, 2]
+ */
+function property(path) {
+ return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
+}
+
+module.exports = property;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/stubArray.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/stubArray.js ***!
+ \**********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * This method returns a new empty array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {Array} Returns the new empty array.
+ * @example
+ *
+ * var arrays = _.times(2, _.stubArray);
+ *
+ * console.log(arrays);
+ * // => [[], []]
+ *
+ * console.log(arrays[0] === arrays[1]);
+ * // => false
+ */
+function stubArray() {
+ return [];
+}
+
+module.exports = stubArray;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/stubFalse.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/stubFalse.js ***!
+ \**********************************************************************************************/
+/***/ ((module) => {
+
+/**
+ * This method returns `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `false`.
+ * @example
+ *
+ * _.times(2, _.stubFalse);
+ * // => [false, false]
+ */
+function stubFalse() {
+ return false;
+}
+
+module.exports = stubFalse;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/toString.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/toString.js ***!
+ \*********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseToString = __webpack_require__(/*! ./_baseToString */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseToString.js");
+
+/**
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.toString(null);
+ * // => ''
+ *
+ * _.toString(-0);
+ * // => '-0'
+ *
+ * _.toString([1, 2, 3]);
+ * // => '1,2,3'
+ */
+function toString(value) {
+ return value == null ? '' : baseToString(value);
+}
+
+module.exports = toString;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/uniqBy.js":
+/*!*******************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/uniqBy.js ***!
+ \*******************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var baseIteratee = __webpack_require__(/*! ./_baseIteratee */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseIteratee.js"),
+ baseUniq = __webpack_require__(/*! ./_baseUniq */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/lodash/_baseUniq.js");
+
+/**
+ * This method is like `_.uniq` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the criterion by which
+ * uniqueness is computed. The order of result values is determined by the
+ * order they occur in the array. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
+ * // => [2.1, 1.2]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 1 }, { 'x': 2 }]
+ */
+function uniqBy(array, iteratee) {
+ return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
+}
+
+module.exports = uniqBy;
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/md5/md5.js":
+/*!*************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/md5/md5.js ***!
+ \*************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+(function(){
+ var crypt = __webpack_require__(/*! crypt */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/crypt/crypt.js"),
+ utf8 = __webpack_require__(/*! charenc */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/charenc/charenc.js").utf8,
+ isBuffer = __webpack_require__(/*! is-buffer */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-buffer/index.js"),
+ bin = __webpack_require__(/*! charenc */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/charenc/charenc.js").bin,
+
+ // The core
+ md5 = function (message, options) {
+ // Convert to byte array
+ if (message.constructor == String)
+ if (options && options.encoding === 'binary')
+ message = bin.stringToBytes(message);
+ else
+ message = utf8.stringToBytes(message);
+ else if (isBuffer(message))
+ message = Array.prototype.slice.call(message, 0);
+ else if (!Array.isArray(message) && message.constructor !== Uint8Array)
+ message = message.toString();
+ // else, assume byte array already
+
+ var m = crypt.bytesToWords(message),
+ l = message.length * 8,
+ a = 1732584193,
+ b = -271733879,
+ c = -1732584194,
+ d = 271733878;
+
+ // Swap endian
+ for (var i = 0; i < m.length; i++) {
+ m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
+ ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
+ }
+
+ // Padding
+ m[l >>> 5] |= 0x80 << (l % 32);
+ m[(((l + 64) >>> 9) << 4) + 14] = l;
+
+ // Method shortcuts
+ var FF = md5._ff,
+ GG = md5._gg,
+ HH = md5._hh,
+ II = md5._ii;
+
+ for (var i = 0; i < m.length; i += 16) {
+
+ var aa = a,
+ bb = b,
+ cc = c,
+ dd = d;
+
+ a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
+ d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
+ c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
+ b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
+ a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
+ d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
+ c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
+ b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
+ a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
+ d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
+ c = FF(c, d, a, b, m[i+10], 17, -42063);
+ b = FF(b, c, d, a, m[i+11], 22, -1990404162);
+ a = FF(a, b, c, d, m[i+12], 7, 1804603682);
+ d = FF(d, a, b, c, m[i+13], 12, -40341101);
+ c = FF(c, d, a, b, m[i+14], 17, -1502002290);
+ b = FF(b, c, d, a, m[i+15], 22, 1236535329);
+
+ a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
+ d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
+ c = GG(c, d, a, b, m[i+11], 14, 643717713);
+ b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
+ a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
+ d = GG(d, a, b, c, m[i+10], 9, 38016083);
+ c = GG(c, d, a, b, m[i+15], 14, -660478335);
+ b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
+ a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
+ d = GG(d, a, b, c, m[i+14], 9, -1019803690);
+ c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
+ b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
+ a = GG(a, b, c, d, m[i+13], 5, -1444681467);
+ d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
+ c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
+ b = GG(b, c, d, a, m[i+12], 20, -1926607734);
+
+ a = HH(a, b, c, d, m[i+ 5], 4, -378558);
+ d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
+ c = HH(c, d, a, b, m[i+11], 16, 1839030562);
+ b = HH(b, c, d, a, m[i+14], 23, -35309556);
+ a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
+ d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
+ c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
+ b = HH(b, c, d, a, m[i+10], 23, -1094730640);
+ a = HH(a, b, c, d, m[i+13], 4, 681279174);
+ d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
+ c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
+ b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
+ a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
+ d = HH(d, a, b, c, m[i+12], 11, -421815835);
+ c = HH(c, d, a, b, m[i+15], 16, 530742520);
+ b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
+
+ a = II(a, b, c, d, m[i+ 0], 6, -198630844);
+ d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
+ c = II(c, d, a, b, m[i+14], 15, -1416354905);
+ b = II(b, c, d, a, m[i+ 5], 21, -57434055);
+ a = II(a, b, c, d, m[i+12], 6, 1700485571);
+ d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
+ c = II(c, d, a, b, m[i+10], 15, -1051523);
+ b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
+ a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
+ d = II(d, a, b, c, m[i+15], 10, -30611744);
+ c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
+ b = II(b, c, d, a, m[i+13], 21, 1309151649);
+ a = II(a, b, c, d, m[i+ 4], 6, -145523070);
+ d = II(d, a, b, c, m[i+11], 10, -1120210379);
+ c = II(c, d, a, b, m[i+ 2], 15, 718787259);
+ b = II(b, c, d, a, m[i+ 9], 21, -343485551);
+
+ a = (a + aa) >>> 0;
+ b = (b + bb) >>> 0;
+ c = (c + cc) >>> 0;
+ d = (d + dd) >>> 0;
+ }
+
+ return crypt.endian([a, b, c, d]);
+ };
+
+ // Auxiliary functions
+ md5._ff = function (a, b, c, d, x, s, t) {
+ var n = a + (b & c | ~b & d) + (x >>> 0) + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ };
+ md5._gg = function (a, b, c, d, x, s, t) {
+ var n = a + (b & d | c & ~d) + (x >>> 0) + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ };
+ md5._hh = function (a, b, c, d, x, s, t) {
+ var n = a + (b ^ c ^ d) + (x >>> 0) + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ };
+ md5._ii = function (a, b, c, d, x, s, t) {
+ var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ };
+
+ // Package private blocksize
+ md5._blocksize = 16;
+ md5._digestsize = 16;
+
+ module.exports = function (message, options) {
+ if (message === undefined || message === null)
+ throw new Error('Illegal argument ' + message);
+
+ var digestbytes = crypt.wordsToBytes(md5(message, options));
+ return options && options.asBytes ? digestbytes :
+ options && options.asString ? bin.bytesToString(digestbytes) :
+ crypt.bytesToHex(digestbytes);
+ };
+
+})();
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/medic-nootils/src/nootils.js":
+/*!*******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/medic-nootils/src/nootils.js ***!
+ \*******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+const _ = __webpack_require__(/*! underscore */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/underscore/underscore-node.cjs");
+
+const NO_LMP_DATE_MODIFIER = 4;
+
+module.exports = function(settings) {
+ const taskSchedules = settings && settings.tasks && settings.tasks.schedules;
+ const lib = {
+ /**
+ * @function
+ * In legacy versions, partner code is required to only emit tasks which are ready to be displayed to the user. Utils.isTimely is the mechanism used for this.
+ * With the rules-engine improvements in webapp 3.8, this responsibility shifts. Partner code should emit all tasks and the webapp's rules-engine decides what to display.
+ * To this end - Utils.isTimely becomes a pass-through in nootils@4.x
+ * @returns True
+ */
+ isTimely: () => true,
+
+ addDate: function(date, days) {
+ let result;
+ if (date) {
+ result = new Date(date.getTime());
+ } else {
+ result = lib.now();
+ }
+ result.setDate(result.getDate() + days);
+ result.setHours(0, 0, 0, 0);
+ return result;
+ },
+
+ getLmpDate: function(doc) {
+ const weeks = doc.fields.last_menstrual_period || NO_LMP_DATE_MODIFIER;
+ return lib.addDate(new Date(doc.reported_date), weeks * -7);
+ },
+
+ // TODO getSchedule() can be removed when tasks.json support is dropped
+ getSchedule: function(name) {
+ return _.findWhere(taskSchedules, { name: name });
+ },
+
+ getMostRecentTimestamp: function(reports, form, fields) {
+ const report = lib.getMostRecentReport(reports, form, fields);
+ return report && report.reported_date;
+ },
+
+ getMostRecentReport: function(reports, form, fields) {
+ let result = null;
+ reports.forEach(function(report) {
+ if (report.form === form &&
+ !report.deleted &&
+ (!result || (report.reported_date > result.reported_date)) &&
+ (!fields || (report.fields && lib.fieldsMatch(report, fields)))) {
+ result = report;
+ }
+ });
+ return result;
+ },
+
+ isFormSubmittedInWindow: function(reports, form, start, end, count) {
+ let result = false;
+ reports.forEach(function(report) {
+ if (!result && report.form === form) {
+ if (report.reported_date >= start && report.reported_date <= end) {
+ if (!count ||
+ (count && report.fields && report.fields.follow_up_count > count)) {
+ result = true;
+ }
+ }
+ }
+ });
+ return result;
+ },
+
+ isFirstReportNewer: function(firstReport, secondReport) {
+ if (firstReport && firstReport.reported_date) {
+ if (secondReport && secondReport.reported_date) {
+ return firstReport.reported_date > secondReport.reported_date;
+ }
+ return true;
+ }
+ return null;
+ },
+
+ isDateValid: function(date) {
+ return !isNaN(date.getTime());
+ },
+
+ /**
+ * @function
+ * @name getField
+ *
+ * Gets the value of specified field path.
+ * @param {Object} report - The report object.
+ * @param {string} field - Period separated json path assuming report.fields as
+ * the root node e.g 'dob' (equivalent to report.fields.dob)
+ * or 'screening.test_result' equivalent to report.fields.screening.test_result
+ */
+ getField: function(report, field) {
+ return _.propertyOf(report.fields)(field.split('.'));
+ },
+
+ fieldsMatch: function(report, fieldValues) {
+ return Object.keys(fieldValues).every(function(field) {
+ return lib.getField(report, field) === fieldValues[field];
+ });
+ },
+
+ MS_IN_DAY: 24*60*60*1000, // 1 day in ms
+
+ now: function() { return new Date(); },
+ };
+
+ return lib;
+};
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/index.js":
+/*!*****************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/index.js ***!
+ \*****************************************************************************************/
+/***/ ((module, exports, __webpack_require__) => {
+
+module.exports = exports = __webpack_require__(/*! ./lib */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/index.js");
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/agenda.js":
+/*!**********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/agenda.js ***!
+ \**********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+"use strict";
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ declare = extd.declare,
+ AVLTree = extd.AVLTree,
+ LinkedList = extd.LinkedList,
+ isPromise = extd.isPromiseLike,
+ EventEmitter = __webpack_require__(/*! events */ "events").EventEmitter;
+
+
+var FactHash = declare({
+ instance: {
+ constructor: function () {
+ this.memory = {};
+ this.memoryValues = new LinkedList();
+ },
+
+ clear: function () {
+ this.memoryValues.clear();
+ this.memory = {};
+ },
+
+
+ remove: function (v) {
+ var hashCode = v.hashCode,
+ memory = this.memory,
+ ret = memory[hashCode];
+ if (ret) {
+ this.memoryValues.remove(ret);
+ delete memory[hashCode];
+ }
+ return ret;
+ },
+
+ insert: function (insert) {
+ var hashCode = insert.hashCode;
+ if (hashCode in this.memory) {
+ throw new Error("Activation already in agenda " + insert.rule.name + " agenda");
+ }
+ this.memoryValues.push((this.memory[hashCode] = insert));
+ }
+ }
+});
+
+
+var DEFAULT_AGENDA_GROUP = "main";
+module.exports = declare(EventEmitter, {
+
+ instance: {
+ constructor: function (flow, conflictResolution) {
+ this.agendaGroups = {};
+ this.agendaGroupStack = [DEFAULT_AGENDA_GROUP];
+ this.rules = {};
+ this.flow = flow;
+ this.comparator = conflictResolution;
+ this.setFocus(DEFAULT_AGENDA_GROUP).addAgendaGroup(DEFAULT_AGENDA_GROUP);
+ },
+
+ addAgendaGroup: function (groupName) {
+ if (!extd.has(this.agendaGroups, groupName)) {
+ this.agendaGroups[groupName] = new AVLTree({compare: this.comparator});
+ }
+ },
+
+ getAgendaGroup: function (groupName) {
+ return this.agendaGroups[groupName || DEFAULT_AGENDA_GROUP];
+ },
+
+ setFocus: function (agendaGroup) {
+ if (agendaGroup !== this.getFocused() && this.agendaGroups[agendaGroup]) {
+ this.agendaGroupStack.push(agendaGroup);
+ this.emit("focused", agendaGroup);
+ }
+ return this;
+ },
+
+ getFocused: function () {
+ var ags = this.agendaGroupStack;
+ return ags[ags.length - 1];
+ },
+
+ getFocusedAgenda: function () {
+ return this.agendaGroups[this.getFocused()];
+ },
+
+ register: function (node) {
+ var agendaGroup = node.rule.agendaGroup;
+ this.rules[node.name] = {tree: new AVLTree({compare: this.comparator}), factTable: new FactHash()};
+ if (agendaGroup) {
+ this.addAgendaGroup(agendaGroup);
+ }
+ },
+
+ isEmpty: function () {
+ var agendaGroupStack = this.agendaGroupStack, changed = false;
+ while (this.getFocusedAgenda().isEmpty() && this.getFocused() !== DEFAULT_AGENDA_GROUP) {
+ agendaGroupStack.pop();
+ changed = true;
+ }
+ if (changed) {
+ this.emit("focused", this.getFocused());
+ }
+ return this.getFocusedAgenda().isEmpty();
+ },
+
+ fireNext: function () {
+ var agendaGroupStack = this.agendaGroupStack, ret = false;
+ while (this.getFocusedAgenda().isEmpty() && this.getFocused() !== DEFAULT_AGENDA_GROUP) {
+ agendaGroupStack.pop();
+ }
+ if (!this.getFocusedAgenda().isEmpty()) {
+ var activation = this.pop();
+ this.emit("fire", activation.rule.name, activation.match.factHash);
+ var fired = activation.rule.fire(this.flow, activation.match);
+ if (isPromise(fired)) {
+ ret = fired.then(function () {
+ //return true if an activation fired
+ return true;
+ });
+ } else {
+ ret = true;
+ }
+ }
+ //return false if activation not fired
+ return ret;
+ },
+
+ pop: function () {
+ var tree = this.getFocusedAgenda(), root = tree.__root;
+ while (root.right) {
+ root = root.right;
+ }
+ var v = root.data;
+ tree.remove(v);
+ var rule = this.rules[v.name];
+ rule.tree.remove(v);
+ rule.factTable.remove(v);
+ return v;
+ },
+
+ peek: function () {
+ var tree = this.getFocusedAgenda(), root = tree.__root;
+ while (root.right) {
+ root = root.right;
+ }
+ return root.data;
+ },
+
+ modify: function (node, context) {
+ this.retract(node, context);
+ this.insert(node, context);
+ },
+
+ retract: function (node, retract) {
+ var rule = this.rules[node.name];
+ retract.rule = node;
+ var activation = rule.factTable.remove(retract);
+ if (activation) {
+ this.getAgendaGroup(node.rule.agendaGroup).remove(activation);
+ rule.tree.remove(activation);
+ }
+ },
+
+ insert: function (node, insert) {
+ var rule = this.rules[node.name], nodeRule = node.rule, agendaGroup = nodeRule.agendaGroup;
+ rule.tree.insert(insert);
+ this.getAgendaGroup(agendaGroup).insert(insert);
+ if (nodeRule.autoFocus) {
+ this.setFocus(agendaGroup);
+ }
+
+ rule.factTable.insert(insert);
+ },
+
+ dispose: function () {
+ for (var i in this.agendaGroups) {
+ this.agendaGroups[i].clear();
+ }
+ var rules = this.rules;
+ for (i in rules) {
+ if (i in rules) {
+ rules[i].tree.clear();
+ rules[i].factTable.clear();
+
+ }
+ }
+ this.rules = {};
+ }
+ }
+
+});
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/common.js":
+/*!******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/common.js ***!
+ \******************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+/*jshint evil:true*/
+
+var extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ forEach = extd.forEach,
+ isString = extd.isString;
+
+exports.modifiers = ["assert", "modify", "retract", "emit", "halt", "focus", "getFacts"];
+
+var createFunction = function (body, defined, scope, scopeNames, definedNames) {
+ var declares = [];
+ forEach(definedNames, function (i) {
+ if (body.indexOf(i) !== -1) {
+ declares.push("var " + i + "= defined." + i + ";");
+ }
+ });
+
+ forEach(scopeNames, function (i) {
+ if (body.indexOf(i) !== -1) {
+ declares.push("var " + i + "= scope." + i + ";");
+ }
+ });
+ body = ["((function(){", declares.join(""), "\n\treturn ", body, "\n})())"].join("");
+ try {
+ return eval(body);
+ } catch (e) {
+ throw new Error("Invalid action : " + body + "\n" + e.message);
+ }
+};
+
+var createDefined = (function () {
+
+ var _createDefined = function (action, defined, scope) {
+ if (isString(action)) {
+ var declares = [];
+ extd(defined).keys().forEach(function (i) {
+ if (action.indexOf(i) !== -1) {
+ declares.push("var " + i + "= defined." + i + ";");
+ }
+ });
+
+ extd(scope).keys().forEach(function (i) {
+ if (action.indexOf(i) !== -1) {
+ declares.push("var " + i + "= function(){var prop = scope." + i + "; return __objToStr__.call(prop) === '[object Function]' ? prop.apply(void 0, arguments) : prop;};");
+ }
+ });
+ if (declares.length) {
+ declares.unshift("var __objToStr__ = Object.prototype.toString;");
+ }
+ action = [declares.join(""), "return ", action, ";"].join("");
+ action = new Function("defined", "scope", action)(defined, scope);
+ }
+ var ret = action.hasOwnProperty("constructor") && "function" === typeof action.constructor ? action.constructor : function (opts) {
+ opts = opts || {};
+ for (var i in opts) {
+ if (i in action) {
+ this[i] = opts[i];
+ }
+ }
+ };
+ var proto = ret.prototype;
+ for (var i in action) {
+ proto[i] = action[i];
+ }
+ return ret;
+
+ };
+
+ return function (options, defined, scope) {
+ return _createDefined(options.properties, defined, scope);
+ };
+})();
+
+exports.createFunction = createFunction;
+exports.createDefined = createDefined;
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/index.js":
+/*!*****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/index.js ***!
+ \*****************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+/*jshint evil:true*/
+
+var extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ parser = __webpack_require__(/*! ../parser */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/index.js"),
+ constraintMatcher = __webpack_require__(/*! ../constraintMatcher.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraintMatcher.js"),
+ indexOf = extd.indexOf,
+ forEach = extd.forEach,
+ removeDuplicates = extd.removeDuplicates,
+ map = extd.map,
+ obj = extd.hash,
+ keys = obj.keys,
+ merge = extd.merge,
+ rules = __webpack_require__(/*! ../rule */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/rule.js"),
+ common = __webpack_require__(/*! ./common */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/common.js"),
+ modifiers = common.modifiers,
+ createDefined = common.createDefined,
+ createFunction = common.createFunction;
+
+
+/**
+ * @private
+ * Parses an action from a rule definition
+ * @param {String} action the body of the action to execute
+ * @param {Array} identifiers array of identifiers collected
+ * @param {Object} defined an object of defined
+ * @param scope
+ * @return {Object}
+ */
+var parseAction = function (action, identifiers, defined, scope) {
+ var declares = [];
+ forEach(identifiers, function (i) {
+ if (action.indexOf(i) !== -1) {
+ declares.push("var " + i + "= facts." + i + ";");
+ }
+ });
+ extd(defined).keys().forEach(function (i) {
+ if (action.indexOf(i) !== -1) {
+ declares.push("var " + i + "= defined." + i + ";");
+ }
+ });
+
+ extd(scope).keys().forEach(function (i) {
+ if (action.indexOf(i) !== -1) {
+ declares.push("var " + i + "= scope." + i + ";");
+ }
+ });
+ extd(modifiers).forEach(function (i) {
+ if (action.indexOf(i) !== -1) {
+ declares.push("if(!" + i + "){ var " + i + "= flow." + i + ";}");
+ }
+ });
+ var params = ["facts", 'flow'];
+ if (/next\(.*\)/.test(action)) {
+ params.push("next");
+ }
+ action = declares.join("") + action;
+ try {
+ return new Function("defined, scope", "return " + new Function(params.join(","), action).toString())(defined, scope);
+ } catch (e) {
+ throw new Error("Invalid action : " + action + "\n" + e.message);
+ }
+};
+
+var createRuleFromObject = (function () {
+ var __resolveRule = function (rule, identifiers, conditions, defined, name) {
+ var condition = [], definedClass = rule[0], alias = rule[1], constraint = rule[2], refs = rule[3];
+ if (extd.isHash(constraint)) {
+ refs = constraint;
+ constraint = null;
+ }
+ if (definedClass && !!(definedClass = defined[definedClass])) {
+ condition.push(definedClass);
+ } else {
+ throw new Error("Invalid class " + rule[0] + " for rule " + name);
+ }
+ condition.push(alias, constraint, refs);
+ conditions.push(condition);
+ identifiers.push(alias);
+ if (constraint) {
+ forEach(constraintMatcher.getIdentifiers(parser.parseConstraint(constraint)), function (i) {
+ identifiers.push(i);
+ });
+ }
+ if (extd.isObject(refs)) {
+ for (var j in refs) {
+ var ident = refs[j];
+ if (indexOf(identifiers, ident) === -1) {
+ identifiers.push(ident);
+ }
+ }
+ }
+ };
+
+ function parseRule(rule, conditions, identifiers, defined, name) {
+ if (rule.length) {
+ var r0 = rule[0];
+ if (r0 === "not" || r0 === "exists") {
+ var temp = [];
+ rule.shift();
+ __resolveRule(rule, identifiers, temp, defined, name);
+ var cond = temp[0];
+ cond.unshift(r0);
+ conditions.push(cond);
+ } else if (r0 === "or") {
+ var conds = [r0];
+ rule.shift();
+ forEach(rule, function (cond) {
+ parseRule(cond, conds, identifiers, defined, name);
+ });
+ conditions.push(conds);
+ } else {
+ __resolveRule(rule, identifiers, conditions, defined, name);
+ identifiers = removeDuplicates(identifiers);
+ }
+ }
+
+ }
+
+ return function (obj, defined, scope) {
+ var name = obj.name;
+ if (extd.isEmpty(obj)) {
+ throw new Error("Rule is empty");
+ }
+ var options = obj.options || {};
+ options.scope = scope;
+ var constraints = obj.constraints || [], l = constraints.length;
+ if (!l) {
+ constraints = ["true"];
+ }
+ var action = obj.action;
+ if (extd.isUndefined(action)) {
+ throw new Error("No action was defined for rule " + name);
+ }
+ var conditions = [], identifiers = [];
+ forEach(constraints, function (rule) {
+ parseRule(rule, conditions, identifiers, defined, name);
+ });
+ return rules.createRule(name, options, conditions, parseAction(action, identifiers, defined, scope));
+ };
+})();
+
+exports.parse = function (src, file) {
+ //parse flow from file
+ return parser.parseRuleSet(src, file);
+
+};
+exports.compile = function (flowObj, options, cb, Container) {
+ if (extd.isFunction(options)) {
+ cb = options;
+ options = {};
+ } else {
+ options = options || {};
+ }
+ var name = flowObj.name || options.name;
+ //if !name throw an error
+ if (!name) {
+ throw new Error("Name must be present in JSON or options");
+ }
+ var flow = new Container(name);
+ var defined = merge({Array: Array, String: String, Number: Number, Boolean: Boolean, RegExp: RegExp, Date: Date, Object: Object}, options.define || {});
+ if (typeof Buffer !== "undefined") {
+ defined.Buffer = Buffer;
+ }
+ var scope = merge({console: console}, options.scope);
+ //add the anything added to the scope as a property
+ forEach(flowObj.scope, function (s) {
+ scope[s.name] = true;
+ });
+ //add any defined classes in the parsed flowObj to defined
+ forEach(flowObj.define, function (d) {
+ defined[d.name] = createDefined(d, defined, scope);
+ });
+
+ //expose any defined classes to the flow.
+ extd(defined).forEach(function (cls, name) {
+ flow.addDefined(name, cls);
+ });
+
+ var scopeNames = extd(flowObj.scope).pluck("name").union(extd(scope).keys().value()).value();
+ var definedNames = map(keys(defined), function (s) {
+ return s;
+ });
+ forEach(flowObj.scope, function (s) {
+ scope[s.name] = createFunction(s.body, defined, scope, scopeNames, definedNames);
+ });
+ var rules = flowObj.rules;
+ if (rules.length) {
+ forEach(rules, function (rule) {
+ flow.__rules = flow.__rules.concat(createRuleFromObject(rule, defined, scope));
+ });
+ }
+ if (cb) {
+ cb.call(flow, flow);
+ }
+ return flow;
+};
+
+exports.transpile = __webpack_require__(/*! ./transpile */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/transpile.js").transpile;
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/transpile.js":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/transpile.js ***!
+ \*********************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+var extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ forEach = extd.forEach,
+ indexOf = extd.indexOf,
+ merge = extd.merge,
+ isString = extd.isString,
+ modifiers = __webpack_require__(/*! ./common */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/common.js").modifiers,
+ constraintMatcher = __webpack_require__(/*! ../constraintMatcher */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraintMatcher.js"),
+ parser = __webpack_require__(/*! ../parser */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/index.js");
+
+function definedToJs(options) {
+ /*jshint evil:true*/
+ options = isString(options) ? new Function("return " + options + ";")() : options;
+ var ret = ["(function(){"], value;
+
+ if (options.hasOwnProperty("constructor") && "function" === typeof options.constructor) {
+ ret.push("var Defined = " + options.constructor.toString() + ";");
+ } else {
+ ret.push("var Defined = function(opts){ for(var i in opts){if(opts.hasOwnProperty(i)){this[i] = opts[i];}}};");
+ }
+ ret.push("var proto = Defined.prototype;");
+ for (var key in options) {
+ if (options.hasOwnProperty(key)) {
+ value = options[key];
+ ret.push("proto." + key + " = " + (extd.isFunction(value) ? value.toString() : extd.format("%j", value)) + ";");
+ }
+ }
+ ret.push("return Defined;");
+ ret.push("}())");
+ return ret.join("");
+
+}
+
+function actionToJs(action, identifiers, defined, scope) {
+ var declares = [], usedVars = {};
+ forEach(identifiers, function (i) {
+ if (action.indexOf(i) !== -1) {
+ usedVars[i] = true;
+ declares.push("var " + i + "= facts." + i + ";");
+ }
+ });
+ extd(defined).keys().forEach(function (i) {
+ if (action.indexOf(i) !== -1 && !usedVars[i]) {
+ usedVars[i] = true;
+ declares.push("var " + i + "= defined." + i + ";");
+ }
+ });
+
+ extd(scope).keys().forEach(function (i) {
+ if (action.indexOf(i) !== -1 && !usedVars[i]) {
+ usedVars[i] = true;
+ declares.push("var " + i + "= scope." + i + ";");
+ }
+ });
+ extd(modifiers).forEach(function (i) {
+ if (action.indexOf(i) !== -1 && !usedVars[i]) {
+ declares.push("var " + i + "= flow." + i + ";");
+ }
+ });
+ var params = ["facts", 'flow'];
+ if (/next\(.*\)/.test(action)) {
+ params.push("next");
+ }
+ action = declares.join("") + action;
+ try {
+ return ["function(", params.join(","), "){", action, "}"].join("");
+ } catch (e) {
+ throw new Error("Invalid action : " + action + "\n" + e.message);
+ }
+}
+
+function parseConstraintModifier(constraint, ret) {
+ if (constraint.length && extd.isString(constraint[0])) {
+ var modifier = constraint[0].match(" *(from)");
+ if (modifier) {
+ modifier = modifier[0];
+ switch (modifier) {
+ case "from":
+ ret.push(', "', constraint.shift(), '"');
+ break;
+ default:
+ throw new Error("Unrecognized modifier " + modifier);
+ }
+ }
+ }
+}
+
+function parseConstraintHash(constraint, ret, identifiers) {
+ if (constraint.length && extd.isHash(constraint[0])) {
+ //ret of options
+ var refs = constraint.shift();
+ extd(refs).values().forEach(function (ident) {
+ if (indexOf(identifiers, ident) === -1) {
+ identifiers.push(ident);
+ }
+ });
+ ret.push(',' + extd.format('%j', [refs]));
+ }
+}
+
+function constraintsToJs(constraint, identifiers) {
+ constraint = constraint.slice(0);
+ var ret = [];
+ if (constraint[0] === "or") {
+ ret.push('["' + constraint.shift() + '"');
+ ret.push(extd.map(constraint,function (c) {
+ return constraintsToJs(c, identifiers);
+ }).join(",") + "]");
+ return ret;
+ } else if (constraint[0] === "not" || constraint[0] === "exists") {
+ ret.push('"', constraint.shift(), '", ');
+ }
+ identifiers.push(constraint[1]);
+ ret.push(constraint[0], ', "' + constraint[1].replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + '"');
+ constraint.splice(0, 2);
+ if (constraint.length) {
+ //constraint
+ var c = constraint.shift();
+ if (extd.isString(c) && c) {
+ ret.push(',"' + c.replace(/\\/g, "\\\\").replace(/"/g, "\\\""), '"');
+ forEach(constraintMatcher.getIdentifiers(parser.parseConstraint(c)), function (i) {
+ identifiers.push(i);
+ });
+ } else {
+ ret.push(',"true"');
+ constraint.unshift(c);
+ }
+ }
+ parseConstraintModifier(constraint, ret);
+ parseConstraintHash(constraint, ret, identifiers);
+ return '[' + ret.join("") + ']';
+}
+
+exports.transpile = function (flowObj, options) {
+ options = options || {};
+ var ret = [];
+ ret.push("(function(){");
+ ret.push("return function(options){");
+ ret.push("options = options || {};");
+ ret.push("var bind = function(scope, fn){return function(){return fn.apply(scope, arguments);};}, defined = {Array: Array, String: String, Number: Number, Boolean: Boolean, RegExp: RegExp, Date: Date, Object: Object}, scope = options.scope || {};");
+ ret.push("var optDefined = options.defined || {}; for(var i in optDefined){defined[i] = optDefined[i];}");
+ var defined = merge({Array: Array, String: String, Number: Number, Boolean: Boolean, RegExp: RegExp, Date: Date, Object: Object}, options.define || {});
+ if (typeof Buffer !== "undefined") {
+ defined.Buffer = Buffer;
+ }
+ var scope = merge({console: console}, options.scope);
+ ret.push(["return nools.flow('", options.name, "', function(){"].join(""));
+ //add any defined classes in the parsed flowObj to defined
+ ret.push(extd(flowObj.define || []).map(function (defined) {
+ var name = defined.name;
+ defined[name] = {};
+ return ["var", name, "= defined." + name, "= this.addDefined('" + name + "',", definedToJs(defined.properties) + ");"].join(" ");
+ }).value().join("\n"));
+ ret.push(extd(flowObj.scope || []).map(function (s) {
+ var name = s.name;
+ scope[name] = {};
+ return ["var", name, "= scope." + name, "= ", s.body, ";"].join(" ");
+ }).value().join("\n"));
+ ret.push("scope.console = console;\n");
+
+
+ ret.push(extd(flowObj.rules || []).map(function (rule) {
+ var identifiers = [], ret = ["this.rule('", rule.name.replace(/'/g, "\\'"), "'"], options = extd.merge(rule.options || {}, {scope: "scope"});
+ ret.push(",", extd.format("%j", [options]).replace(/(:"scope")/, ":scope"));
+ if (rule.constraints && !extd.isEmpty(rule.constraints)) {
+ ret.push(", [");
+ ret.push(extd(rule.constraints).map(function (c) {
+ return constraintsToJs(c, identifiers);
+ }).value().join(","));
+ ret.push("]");
+ }
+ ret.push(",", actionToJs(rule.action, identifiers, defined, scope));
+ ret.push(");");
+ return ret.join("");
+ }).value().join(""));
+ ret.push("});");
+ ret.push("};");
+ ret.push("}());");
+ return ret.join("");
+};
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/conflict.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/conflict.js ***!
+ \************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+var map = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js").map;
+
+function salience(a, b) {
+ return a.rule.priority - b.rule.priority;
+}
+
+function bucketCounter(a, b) {
+ return a.counter - b.counter;
+}
+
+function factRecency(a, b) {
+ /*jshint noempty: false*/
+
+ var i = 0;
+ var aMatchRecency = a.match.recency,
+ bMatchRecency = b.match.recency, aLength = aMatchRecency.length - 1, bLength = bMatchRecency.length - 1;
+ while (aMatchRecency[i] === bMatchRecency[i] && i < aLength && i < bLength && i++) {
+ }
+ var ret = aMatchRecency[i] - bMatchRecency[i];
+ if (!ret) {
+ ret = aLength - bLength;
+ }
+ return ret;
+}
+
+function activationRecency(a, b) {
+ return a.recency - b.recency;
+}
+
+var strategies = {
+ salience: salience,
+ bucketCounter: bucketCounter,
+ factRecency: factRecency,
+ activationRecency: activationRecency
+};
+
+exports.strategies = strategies;
+exports.strategy = function (strats) {
+ strats = map(strats, function (s) {
+ return strategies[s];
+ });
+ var stratsLength = strats.length;
+
+ return function (a, b) {
+ var i = -1, ret = 0;
+ var equal = (a === b) || (a.name === b.name && a.hashCode === b.hashCode);
+ if (!equal) {
+ while (++i < stratsLength && !ret) {
+ ret = strats[i](a, b);
+ }
+ ret = ret > 0 ? 1 : -1;
+ }
+ return ret;
+ };
+};
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraint.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraint.js ***!
+ \**************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ deepEqual = extd.deepEqual,
+ merge = extd.merge,
+ instanceOf = extd.instanceOf,
+ filter = extd.filter,
+ declare = extd.declare,
+ constraintMatcher;
+
+var id = 0;
+var Constraint = declare({
+
+ type: null,
+
+ instance: {
+ constructor: function (constraint) {
+ if (!constraintMatcher) {
+ constraintMatcher = __webpack_require__(/*! ./constraintMatcher */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraintMatcher.js");
+ }
+ this.id = id++;
+ this.constraint = constraint;
+ extd.bindAll(this, ["assert"]);
+ },
+ "assert": function () {
+ throw new Error("not implemented");
+ },
+
+ getIndexableProperties: function () {
+ return [];
+ },
+
+ equal: function (constraint) {
+ return instanceOf(constraint, this._static) && this.get("alias") === constraint.get("alias") && extd.deepEqual(this.constraint, constraint.constraint);
+ },
+
+ getters: {
+ variables: function () {
+ return [this.get("alias")];
+ }
+ }
+
+
+ }
+});
+
+Constraint.extend({
+ instance: {
+
+ type: "object",
+
+ constructor: function (type) {
+ this._super([type]);
+ },
+
+ "assert": function (param) {
+ return param instanceof this.constraint || param.constructor === this.constraint;
+ },
+
+ equal: function (constraint) {
+ return instanceOf(constraint, this._static) && this.constraint === constraint.constraint;
+ }
+ }
+}).as(exports, "ObjectConstraint");
+
+var EqualityConstraint = Constraint.extend({
+
+ instance: {
+
+ type: "equality",
+
+ constructor: function (constraint, options) {
+ this._super([constraint]);
+ options = options || {};
+ this.pattern = options.pattern;
+ this._matcher = constraintMatcher.getMatcher(constraint, options, true);
+ },
+
+ "assert": function (values) {
+ return this._matcher(values);
+ }
+ }
+}).as(exports, "EqualityConstraint");
+
+EqualityConstraint.extend({instance: {type: "inequality"}}).as(exports, "InequalityConstraint");
+EqualityConstraint.extend({instance: {type: "comparison"}}).as(exports, "ComparisonConstraint");
+
+Constraint.extend({
+
+ instance: {
+
+ type: "equality",
+
+ constructor: function () {
+ this._super([
+ [true]
+ ]);
+ },
+
+ equal: function (constraint) {
+ return instanceOf(constraint, this._static) && this.get("alias") === constraint.get("alias");
+ },
+
+
+ "assert": function () {
+ return true;
+ }
+ }
+}).as(exports, "TrueConstraint");
+
+var ReferenceConstraint = Constraint.extend({
+
+ instance: {
+
+ type: "reference",
+
+ constructor: function (constraint, options) {
+ this.cache = {};
+ this._super([constraint]);
+ options = options || {};
+ this.values = [];
+ this.pattern = options.pattern;
+ this._options = options;
+ this._matcher = constraintMatcher.getMatcher(constraint, options, false);
+ },
+
+ "assert": function (fact, fh) {
+ try {
+ return this._matcher(fact, fh);
+ } catch (e) {
+ throw new Error("Error with evaluating pattern " + this.pattern + " " + e.message);
+ }
+
+ },
+
+ merge: function (that) {
+ var ret = this;
+ if (that instanceof ReferenceConstraint) {
+ ret = new this._static([this.constraint, that.constraint, "and"], merge({}, this._options, this._options));
+ ret._alias = this._alias || that._alias;
+ ret.vars = this.vars.concat(that.vars);
+ }
+ return ret;
+ },
+
+ equal: function (constraint) {
+ return instanceOf(constraint, this._static) && extd.deepEqual(this.constraint, constraint.constraint);
+ },
+
+
+ getters: {
+ variables: function () {
+ return this.vars;
+ },
+
+ alias: function () {
+ return this._alias;
+ }
+ },
+
+ setters: {
+ alias: function (alias) {
+ this._alias = alias;
+ this.vars = filter(constraintMatcher.getIdentifiers(this.constraint), function (v) {
+ return v !== alias;
+ });
+ }
+ }
+ }
+
+}).as(exports, "ReferenceConstraint");
+
+
+ReferenceConstraint.extend({
+ instance: {
+ type: "reference_equality",
+ op: "eq",
+ getIndexableProperties: function () {
+ return constraintMatcher.getIndexableProperties(this.constraint);
+ }
+ }
+}).as(exports, "ReferenceEqualityConstraint")
+ .extend({instance: {type: "reference_inequality", op: "neq"}}).as(exports, "ReferenceInequalityConstraint")
+ .extend({instance: {type: "reference_gt", op: "gt"}}).as(exports, "ReferenceGTConstraint")
+ .extend({instance: {type: "reference_gte", op: "gte"}}).as(exports, "ReferenceGTEConstraint")
+ .extend({instance: {type: "reference_lt", op: "lt"}}).as(exports, "ReferenceLTConstraint")
+ .extend({instance: {type: "reference_lte", op: "lte"}}).as(exports, "ReferenceLTEConstraint");
+
+
+Constraint.extend({
+ instance: {
+
+ type: "hash",
+
+ constructor: function (hash) {
+ this._super([hash]);
+ },
+
+ equal: function (constraint) {
+ return extd.instanceOf(constraint, this._static) && this.get("alias") === constraint.get("alias") && extd.deepEqual(this.constraint, constraint.constraint);
+ },
+
+ "assert": function () {
+ return true;
+ },
+
+ getters: {
+ variables: function () {
+ return this.constraint;
+ }
+ }
+
+ }
+}).as(exports, "HashConstraint");
+
+Constraint.extend({
+ instance: {
+ constructor: function (constraints, options) {
+ this.type = "from";
+ this.constraints = constraintMatcher.getSourceMatcher(constraints, (options || {}), true);
+ extd.bindAll(this, ["assert"]);
+ },
+
+ equal: function (constraint) {
+ return instanceOf(constraint, this._static) && this.get("alias") === constraint.get("alias") && deepEqual(this.constraints, constraint.constraints);
+ },
+
+ "assert": function (fact, fh) {
+ return this.constraints(fact, fh);
+ },
+
+ getters: {
+ variables: function () {
+ return this.constraint;
+ }
+ }
+
+ }
+}).as(exports, "FromConstraint");
+
+Constraint.extend({
+ instance: {
+ constructor: function (func, options) {
+ this.type = "custom";
+ this.fn = func;
+ this.options = options;
+ extd.bindAll(this, ["assert"]);
+ },
+
+ equal: function (constraint) {
+ return instanceOf(constraint, this._static) && this.fn === constraint.constraint;
+ },
+
+ "assert": function (fact, fh) {
+ return this.fn(fact, fh);
+ }
+ }
+}).as(exports, "CustomConstraint");
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraintMatcher.js":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraintMatcher.js ***!
+ \*********************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ isArray = extd.isArray,
+ forEach = extd.forEach,
+ some = extd.some,
+ indexOf = extd.indexOf,
+ isNumber = extd.isNumber,
+ removeDups = extd.removeDuplicates,
+ atoms = __webpack_require__(/*! ./constraint */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraint.js");
+
+function getProps(val) {
+ return extd(val).map(function mapper(val) {
+ return isArray(val) ? isArray(val[0]) ? getProps(val).value() : val.reverse().join(".") : val;
+ }).flatten().filter(function (v) {
+ return !!v;
+ });
+}
+
+var definedFuncs = {
+ indexOf: extd.indexOf,
+ now: function () {
+ return new Date();
+ },
+
+ Date: function (y, m, d, h, min, s, ms) {
+ var date = new Date();
+ if (isNumber(y)) {
+ date.setYear(y);
+ }
+ if (isNumber(m)) {
+ date.setMonth(m);
+ }
+ if (isNumber(d)) {
+ date.setDate(d);
+ }
+ if (isNumber(h)) {
+ date.setHours(h);
+ }
+ if (isNumber(min)) {
+ date.setMinutes(min);
+ }
+ if (isNumber(s)) {
+ date.setSeconds(s);
+ }
+ if (isNumber(ms)) {
+ date.setMilliseconds(ms);
+ }
+ return date;
+ },
+
+ lengthOf: function (arr, length) {
+ return arr.length === length;
+ },
+
+ isTrue: function (val) {
+ return val === true;
+ },
+
+ isFalse: function (val) {
+ return val === false;
+ },
+
+ isNotNull: function (actual) {
+ return actual !== null;
+ },
+
+ dateCmp: function (dt1, dt2) {
+ return extd.compare(dt1, dt2);
+ }
+
+};
+
+forEach(["years", "days", "months", "hours", "minutes", "seconds"], function (k) {
+ definedFuncs[k + "FromNow"] = extd[k + "FromNow"];
+ definedFuncs[k + "Ago"] = extd[k + "Ago"];
+});
+
+
+forEach(["isArray", "isNumber", "isHash", "isObject", "isDate", "isBoolean", "isString", "isRegExp", "isNull", "isEmpty",
+ "isUndefined", "isDefined", "isUndefinedOrNull", "isPromiseLike", "isFunction", "deepEqual"], function (k) {
+ var m = extd[k];
+ definedFuncs[k] = function () {
+ return m.apply(extd, arguments);
+ };
+});
+
+
+var lang = {
+
+ equal: function (c1, c2) {
+ var ret = false;
+ if (c1 === c2) {
+ ret = true;
+ } else {
+ if (c1[2] === c2[2]) {
+ if (indexOf(["string", "number", "boolean", "regexp", "identifier", "null"], c1[2]) !== -1) {
+ ret = c1[0] === c2[0];
+ } else if (c1[2] === "unary" || c1[2] === "logicalNot") {
+ ret = this.equal(c1[0], c2[0]);
+ } else {
+ ret = this.equal(c1[0], c2[0]) && this.equal(c1[1], c2[1]);
+ }
+ }
+ }
+ return ret;
+ },
+
+ __getProperties: function (rule) {
+ var ret = [];
+ if (rule) {
+ var rule2 = rule[2];
+ if (!rule2) {
+ return ret;
+ }
+ if (rule2 !== "prop" &&
+ rule2 !== "identifier" &&
+ rule2 !== "string" &&
+ rule2 !== "number" &&
+ rule2 !== "boolean" &&
+ rule2 !== "regexp" &&
+ rule2 !== "unary" &&
+ rule2 !== "unary") {
+ ret[0] = this.__getProperties(rule[0]);
+ ret[1] = this.__getProperties(rule[1]);
+ } else if (rule2 === "identifier") {
+ //at the bottom
+ ret = [rule[0]];
+ } else {
+ ret = lang.__getProperties(rule[1]).concat(lang.__getProperties(rule[0]));
+ }
+ }
+ return ret;
+ },
+
+ getIndexableProperties: function (rule) {
+ if (rule[2] === "composite") {
+ return this.getIndexableProperties(rule[0]);
+ } else if (/^(\w+(\['[^']*'])*) *([!=]==?|[<>]=?) (\w+(\['[^']*'])*)$/.test(this.parse(rule))) {
+ return getProps(this.__getProperties(rule)).flatten().value();
+ } else {
+ return [];
+ }
+ },
+
+ getIdentifiers: function (rule) {
+ var ret = [];
+ var rule2 = rule[2];
+
+ if (rule2 === "identifier") {
+ //its an identifier so stop
+ return [rule[0]];
+ } else if (rule2 === "function") {
+ ret = ret.concat(this.getIdentifiers(rule[0])).concat(this.getIdentifiers(rule[1]));
+ } else if (rule2 !== "string" &&
+ rule2 !== "number" &&
+ rule2 !== "boolean" &&
+ rule2 !== "regexp" &&
+ rule2 !== "unary" &&
+ rule2 !== "unary") {
+ //its an expression so keep going
+ if (rule2 === "prop") {
+ ret = ret.concat(this.getIdentifiers(rule[0]));
+ if (rule[1]) {
+ var propChain = rule[1];
+ //go through the member variables and collect any identifiers that may be in functions
+ while (isArray(propChain)) {
+ if (propChain[2] === "function") {
+ ret = ret.concat(this.getIdentifiers(propChain[1]));
+ break;
+ } else {
+ propChain = propChain[1];
+ }
+ }
+ }
+
+ } else {
+ if (rule[0]) {
+ ret = ret.concat(this.getIdentifiers(rule[0]));
+ }
+ if (rule[1]) {
+ ret = ret.concat(this.getIdentifiers(rule[1]));
+ }
+ }
+ }
+ //remove dups and return
+ return removeDups(ret);
+ },
+
+ toConstraints: function (rule, options) {
+ var ret = [],
+ alias = options.alias,
+ scope = options.scope || {};
+
+ var rule2 = rule[2];
+
+
+ if (rule2 === "and") {
+ ret = ret.concat(this.toConstraints(rule[0], options)).concat(this.toConstraints(rule[1], options));
+ } else if (
+ rule2 === "composite" ||
+ rule2 === "or" ||
+ rule2 === "lt" ||
+ rule2 === "gt" ||
+ rule2 === "lte" ||
+ rule2 === "gte" ||
+ rule2 === "like" ||
+ rule2 === "notLike" ||
+ rule2 === "eq" ||
+ rule2 === "neq" ||
+ rule2 === "seq" ||
+ rule2 === "sneq" ||
+ rule2 === "in" ||
+ rule2 === "notIn" ||
+ rule2 === "prop" ||
+ rule2 === "propLookup" ||
+ rule2 === "function" ||
+ rule2 === "logicalNot") {
+ var isReference = some(this.getIdentifiers(rule), function (i) {
+ return i !== alias && !(i in definedFuncs) && !(i in scope);
+ });
+ switch (rule2) {
+ case "eq":
+ ret.push(new atoms[isReference ? "ReferenceEqualityConstraint" : "EqualityConstraint"](rule, options));
+ break;
+ case "seq":
+ ret.push(new atoms[isReference ? "ReferenceEqualityConstraint" : "EqualityConstraint"](rule, options));
+ break;
+ case "neq":
+ ret.push(new atoms[isReference ? "ReferenceInequalityConstraint" : "InequalityConstraint"](rule, options));
+ break;
+ case "sneq":
+ ret.push(new atoms[isReference ? "ReferenceInequalityConstraint" : "InequalityConstraint"](rule, options));
+ break;
+ case "gt":
+ ret.push(new atoms[isReference ? "ReferenceGTConstraint" : "ComparisonConstraint"](rule, options));
+ break;
+ case "gte":
+ ret.push(new atoms[isReference ? "ReferenceGTEConstraint" : "ComparisonConstraint"](rule, options));
+ break;
+ case "lt":
+ ret.push(new atoms[isReference ? "ReferenceLTConstraint" : "ComparisonConstraint"](rule, options));
+ break;
+ case "lte":
+ ret.push(new atoms[isReference ? "ReferenceLTEConstraint" : "ComparisonConstraint"](rule, options));
+ break;
+ default:
+ ret.push(new atoms[isReference ? "ReferenceConstraint" : "ComparisonConstraint"](rule, options));
+ }
+
+ }
+ return ret;
+ },
+
+
+ parse: function (rule) {
+ return this[rule[2]](rule[0], rule[1]);
+ },
+
+ composite: function (lhs) {
+ return this.parse(lhs);
+ },
+
+ and: function (lhs, rhs) {
+ return ["(", this.parse(lhs), "&&", this.parse(rhs), ")"].join(" ");
+ },
+
+ or: function (lhs, rhs) {
+ return ["(", this.parse(lhs), "||", this.parse(rhs), ")"].join(" ");
+ },
+
+ prop: function (name, prop) {
+ if (prop[2] === "function") {
+ return [this.parse(name), this.parse(prop)].join(".");
+ } else {
+ return [this.parse(name), "['", this.parse(prop), "']"].join("");
+ }
+ },
+
+ propLookup: function (name, prop) {
+ if (prop[2] === "function") {
+ return [this.parse(name), this.parse(prop)].join(".");
+ } else {
+ return [this.parse(name), "[", this.parse(prop), "]"].join("");
+ }
+ },
+
+ unary: function (lhs) {
+ return -1 * this.parse(lhs);
+ },
+
+ plus: function (lhs, rhs) {
+ return [this.parse(lhs), "+", this.parse(rhs)].join(" ");
+ },
+ minus: function (lhs, rhs) {
+ return [this.parse(lhs), "-", this.parse(rhs)].join(" ");
+ },
+
+ mult: function (lhs, rhs) {
+ return [this.parse(lhs), "*", this.parse(rhs)].join(" ");
+ },
+
+ div: function (lhs, rhs) {
+ return [this.parse(lhs), "/", this.parse(rhs)].join(" ");
+ },
+
+ mod: function (lhs, rhs) {
+ return [this.parse(lhs), "%", this.parse(rhs)].join(" ");
+ },
+
+ lt: function (lhs, rhs) {
+ return [this.parse(lhs), "<", this.parse(rhs)].join(" ");
+ },
+ gt: function (lhs, rhs) {
+ return [this.parse(lhs), ">", this.parse(rhs)].join(" ");
+ },
+ lte: function (lhs, rhs) {
+ return [this.parse(lhs), "<=", this.parse(rhs)].join(" ");
+ },
+ gte: function (lhs, rhs) {
+ return [this.parse(lhs), ">=", this.parse(rhs)].join(" ");
+ },
+ like: function (lhs, rhs) {
+ return [this.parse(rhs), ".test(", this.parse(lhs), ")"].join("");
+ },
+ notLike: function (lhs, rhs) {
+ return ["!", this.parse(rhs), ".test(", this.parse(lhs), ")"].join("");
+ },
+ eq: function (lhs, rhs) {
+ return [this.parse(lhs), "==", this.parse(rhs)].join(" ");
+ },
+
+ seq: function (lhs, rhs) {
+ return [this.parse(lhs), "===", this.parse(rhs)].join(" ");
+ },
+
+ neq: function (lhs, rhs) {
+ return [this.parse(lhs), "!=", this.parse(rhs)].join(" ");
+ },
+
+ sneq: function (lhs, rhs) {
+ return [this.parse(lhs), "!==", this.parse(rhs)].join(" ");
+ },
+
+ "in": function (lhs, rhs) {
+ return ["(indexOf(", this.parse(rhs), ",", this.parse(lhs), ")) != -1"].join("");
+ },
+
+ "notIn": function (lhs, rhs) {
+ return ["(indexOf(", this.parse(rhs), ",", this.parse(lhs), ")) == -1"].join("");
+ },
+
+ "arguments": function (lhs, rhs) {
+ var ret = [];
+ if (lhs) {
+ ret.push(this.parse(lhs));
+ }
+ if (rhs) {
+ ret.push(this.parse(rhs));
+ }
+ return ret.join(",");
+ },
+
+ "array": function (lhs) {
+ var args = [];
+ if (lhs) {
+ args = this.parse(lhs);
+ if (isArray(args)) {
+ return args;
+ } else {
+ return ["[", args, "]"].join("");
+ }
+ }
+ return ["[", args.join(","), "]"].join("");
+ },
+
+ "function": function (lhs, rhs) {
+ var args = this.parse(rhs);
+ return [this.parse(lhs), "(", args, ")"].join("");
+ },
+
+ "string": function (lhs) {
+ return "'" + lhs + "'";
+ },
+
+ "number": function (lhs) {
+ return lhs;
+ },
+
+ "boolean": function (lhs) {
+ return lhs;
+ },
+
+ regexp: function (lhs) {
+ return lhs;
+ },
+
+ identifier: function (lhs) {
+ return lhs;
+ },
+
+ "null": function () {
+ return "null";
+ },
+
+ logicalNot: function (lhs) {
+ return ["!(", this.parse(lhs), ")"].join("");
+ }
+};
+
+var matcherCount = 0;
+var toJs = exports.toJs = function (rule, scope, alias, equality, wrap) {
+ /*jshint evil:true*/
+ var js = lang.parse(rule);
+ scope = scope || {};
+ var vars = lang.getIdentifiers(rule);
+ var closureVars = ["var indexOf = definedFuncs.indexOf; var hasOwnProperty = Object.prototype.hasOwnProperty;"], funcVars = [];
+ extd(vars).filter(function (v) {
+ var ret = ["var ", v, " = "];
+ if (definedFuncs.hasOwnProperty(v)) {
+ ret.push("definedFuncs['", v, "']");
+ } else if (scope.hasOwnProperty(v)) {
+ ret.push("scope['", v, "']");
+ } else {
+ return true;
+ }
+ ret.push(";");
+ closureVars.push(ret.join(""));
+ return false;
+ }).forEach(function (v) {
+ var ret = ["var ", v, " = "];
+ if (equality || v !== alias) {
+ ret.push("fact." + v);
+ } else if (v === alias) {
+ ret.push("hash.", v, "");
+ }
+ ret.push(";");
+ funcVars.push(ret.join(""));
+ });
+ var closureBody = closureVars.join("") + "return function matcher" + (matcherCount++) + (!equality ? "(fact, hash){" : "(fact){") + funcVars.join("") + " return " + (wrap ? wrap(js) : js) + ";}";
+ var f = new Function("definedFuncs, scope", closureBody)(definedFuncs, scope);
+ //console.log(f.toString());
+ return f;
+};
+
+exports.getMatcher = function (rule, options, equality) {
+ options = options || {};
+ return toJs(rule, options.scope, options.alias, equality, function (src) {
+ return "!!(" + src + ")";
+ });
+};
+
+exports.getSourceMatcher = function (rule, options, equality) {
+ options = options || {};
+ return toJs(rule, options.scope, options.alias, equality, function (src) {
+ return src;
+ });
+};
+
+exports.toConstraints = function (constraint, options) {
+ if (typeof constraint === 'function') {
+ return [new atoms.CustomConstraint(constraint, options)];
+ }
+ //constraint.split("&&")
+ return lang.toConstraints(constraint, options);
+};
+
+exports.equal = function (c1, c2) {
+ return lang.equal(c1, c2);
+};
+
+exports.getIdentifiers = function (constraint) {
+ return lang.getIdentifiers(constraint);
+};
+
+exports.getIndexableProperties = function (constraint) {
+ return lang.getIndexableProperties(constraint);
+};
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js ***!
+ \***********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+"use strict";
+/* module decorator */ module = __webpack_require__.nmd(module);
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ isBoolean = extd.isBoolean,
+ declare = extd.declare,
+ indexOf = extd.indexOf,
+ pPush = Array.prototype.push;
+
+function createContextHash(paths, hashCode) {
+ var ret = "",
+ i = -1,
+ l = paths.length;
+ while (++i < l) {
+ ret += paths[i].id + ":";
+ }
+ ret += hashCode;
+ return ret;
+}
+
+function merge(h1, h2, aliases) {
+ var i = -1, l = aliases.length, alias;
+ while (++i < l) {
+ alias = aliases[i];
+ h1[alias] = h2[alias];
+ }
+}
+
+function unionRecency(arr, arr1, arr2) {
+ pPush.apply(arr, arr1);
+ var i = -1, l = arr2.length, val, j = arr.length;
+ while (++i < l) {
+ val = arr2[i];
+ if (indexOf(arr, val) === -1) {
+ arr[j++] = val;
+ }
+ }
+}
+
+var Match = declare({
+ instance: {
+
+ isMatch: true,
+ hashCode: "",
+ facts: null,
+ factIds: null,
+ factHash: null,
+ recency: null,
+ aliases: null,
+
+ constructor: function () {
+ this.facts = [];
+ this.factIds = [];
+ this.factHash = {};
+ this.recency = [];
+ this.aliases = [];
+ },
+
+ addFact: function (assertable) {
+ pPush.call(this.facts, assertable);
+ pPush.call(this.recency, assertable.recency);
+ pPush.call(this.factIds, assertable.id);
+ this.hashCode = this.factIds.join(":");
+ return this;
+ },
+
+ merge: function (mr) {
+ var ret = new Match();
+ ret.isMatch = mr.isMatch;
+ pPush.apply(ret.facts, this.facts);
+ pPush.apply(ret.facts, mr.facts);
+ pPush.apply(ret.aliases, this.aliases);
+ pPush.apply(ret.aliases, mr.aliases);
+ ret.hashCode = this.hashCode + ":" + mr.hashCode;
+ merge(ret.factHash, this.factHash, this.aliases);
+ merge(ret.factHash, mr.factHash, mr.aliases);
+ unionRecency(ret.recency, this.recency, mr.recency);
+ return ret;
+ }
+ }
+});
+
+var Context = declare({
+ instance: {
+ match: null,
+ factHash: null,
+ aliases: null,
+ fact: null,
+ hashCode: null,
+ paths: null,
+ pathsHash: null,
+
+ constructor: function (fact, paths, mr) {
+ this.fact = fact;
+ if (mr) {
+ this.match = mr;
+ } else {
+ this.match = new Match().addFact(fact);
+ }
+ this.factHash = this.match.factHash;
+ this.aliases = this.match.aliases;
+ this.hashCode = this.match.hashCode;
+ if (paths) {
+ this.paths = paths;
+ this.pathsHash = createContextHash(paths, this.hashCode);
+ } else {
+ this.pathsHash = this.hashCode;
+ }
+ },
+
+ "set": function (key, value) {
+ this.factHash[key] = value;
+ this.aliases.push(key);
+ return this;
+ },
+
+ isMatch: function (isMatch) {
+ if (isBoolean(isMatch)) {
+ this.match.isMatch = isMatch;
+ } else {
+ return this.match.isMatch;
+ }
+ return this;
+ },
+
+ mergeMatch: function (merge) {
+ var match = this.match = this.match.merge(merge);
+ this.factHash = match.factHash;
+ this.hashCode = match.hashCode;
+ this.aliases = match.aliases;
+ return this;
+ },
+
+ clone: function (fact, paths, match) {
+ return new Context(fact || this.fact, paths || this.path, match || this.match);
+ }
+ }
+}).as(module);
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/executionStrategy.js":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/executionStrategy.js ***!
+ \*********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ Promise = extd.Promise,
+ nextTick = __webpack_require__(/*! ./nextTick */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nextTick.js"),
+ isPromiseLike = extd.isPromiseLike;
+
+Promise.extend({
+ instance: {
+
+ looping: false,
+
+ constructor: function (flow, matchUntilHalt) {
+ this._super([]);
+ this.flow = flow;
+ this.agenda = flow.agenda;
+ this.rootNode = flow.rootNode;
+ this.matchUntilHalt = !!(matchUntilHalt);
+ extd.bindAll(this, ["onAlter", "callNext"]);
+ },
+
+ halt: function () {
+ this.__halted = true;
+ if (!this.looping) {
+ this.callback();
+ }
+ },
+
+ onAlter: function () {
+ this.flowAltered = true;
+ if (!this.looping && this.matchUntilHalt && !this.__halted) {
+ this.callNext();
+ }
+ },
+
+ setup: function () {
+ var flow = this.flow;
+ this.rootNode.resetCounter();
+ flow.on("assert", this.onAlter);
+ flow.on("modify", this.onAlter);
+ flow.on("retract", this.onAlter);
+ },
+
+ tearDown: function () {
+ var flow = this.flow;
+ flow.removeListener("assert", this.onAlter);
+ flow.removeListener("modify", this.onAlter);
+ flow.removeListener("retract", this.onAlter);
+ },
+
+ __handleAsyncNext: function (next) {
+ var self = this, agenda = self.agenda;
+ return next.then(function () {
+ self.looping = false;
+ if (!agenda.isEmpty()) {
+ if (self.flowAltered) {
+ self.rootNode.incrementCounter();
+ self.flowAltered = false;
+ }
+ if (!self.__halted) {
+ self.callNext();
+ } else {
+ self.callback();
+ }
+ } else if (!self.matchUntilHalt || self.__halted) {
+ self.callback();
+ }
+ self = null;
+ }, this.errback);
+ },
+
+ __handleSyncNext: function (next) {
+ this.looping = false;
+ if (!this.agenda.isEmpty()) {
+ if (this.flowAltered) {
+ this.rootNode.incrementCounter();
+ this.flowAltered = false;
+ }
+ }
+ if (next && !this.__halted) {
+ nextTick(this.callNext);
+ } else if (!this.matchUntilHalt || this.__halted) {
+ this.callback();
+ }
+ return next;
+ },
+
+ callback: function () {
+ this.tearDown();
+ this._super(arguments);
+ },
+
+
+ callNext: function () {
+ this.looping = true;
+ var next = this.agenda.fireNext();
+ return isPromiseLike(next) ? this.__handleAsyncNext(next) : this.__handleSyncNext(next);
+ },
+
+ execute: function () {
+ this.setup();
+ this.callNext();
+ return this;
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+var arr = __webpack_require__(/*! array-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js"),
+ unique = arr.unique,
+ indexOf = arr.indexOf,
+ map = arr.map,
+ pSlice = Array.prototype.slice,
+ pSplice = Array.prototype.splice;
+
+function plucked(prop) {
+ var exec = prop.match(/(\w+)\(\)$/);
+ if (exec) {
+ prop = exec[1];
+ return function (item) {
+ return item[prop]();
+ };
+ } else {
+ return function (item) {
+ return item[prop];
+ };
+ }
+}
+
+function plucker(prop) {
+ prop = prop.split(".");
+ if (prop.length === 1) {
+ return plucked(prop[0]);
+ } else {
+ var pluckers = map(prop, function (prop) {
+ return plucked(prop);
+ });
+ var l = pluckers.length;
+ return function (item) {
+ var i = -1, res = item;
+ while (++i < l) {
+ res = pluckers[i](res);
+ }
+ return res;
+ };
+ }
+}
+
+function intersection(a, b) {
+ a = pSlice.call(a);
+ var aOne, i = -1, l;
+ l = a.length;
+ while (++i < l) {
+ aOne = a[i];
+ if (indexOf(b, aOne) === -1) {
+ pSplice.call(a, i--, 1);
+ l--;
+ }
+ }
+ return a;
+}
+
+function inPlaceIntersection(a, b) {
+ var aOne, i = -1, l;
+ l = a.length;
+ while (++i < l) {
+ aOne = a[i];
+ if (indexOf(b, aOne) === -1) {
+ pSplice.call(a, i--, 1);
+ l--;
+ }
+ }
+ return a;
+}
+
+function inPlaceDifference(a, b) {
+ var aOne, i = -1, l;
+ l = a.length;
+ while (++i < l) {
+ aOne = a[i];
+ if (indexOf(b, aOne) !== -1) {
+ pSplice.call(a, i--, 1);
+ l--;
+ }
+ }
+ return a;
+}
+
+function diffArr(arr1, arr2) {
+ var ret = [], i = -1, j, l2 = arr2.length, l1 = arr1.length, a, found;
+ if (l2 > l1) {
+ ret = arr1.slice();
+ while (++i < l2) {
+ a = arr2[i];
+ j = -1;
+ l1 = ret.length;
+ while (++j < l1) {
+ if (ret[j] === a) {
+ ret.splice(j, 1);
+ break;
+ }
+ }
+ }
+ } else {
+ while (++i < l1) {
+ a = arr1[i];
+ j = -1;
+ found = false;
+ while (++j < l2) {
+ if (arr2[j] === a) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ ret.push(a);
+ }
+ }
+ }
+ return ret;
+}
+
+function diffHash(h1, h2) {
+ var ret = {};
+ for (var i in h1) {
+ if (!hasOwnProperty.call(h2, i)) {
+ ret[i] = h1[i];
+ }
+ }
+ return ret;
+}
+
+
+function union(arr1, arr2) {
+ return unique(arr1.concat(arr2));
+}
+
+module.exports = __webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js")()
+ .register(__webpack_require__(/*! date-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/date-extended/index.js"))
+ .register(arr)
+ .register(__webpack_require__(/*! object-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/object-extended/index.js"))
+ .register(__webpack_require__(/*! string-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/string-extended/index.js"))
+ .register(__webpack_require__(/*! promise-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/promise-extended/index.js"))
+ .register(__webpack_require__(/*! function-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/function-extended/index.js"))
+ .register(__webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"))
+ .register("intersection", intersection)
+ .register("inPlaceIntersection", inPlaceIntersection)
+ .register("inPlaceDifference", inPlaceDifference)
+ .register("diffArr", diffArr)
+ .register("diffHash", diffHash)
+ .register("unionArr", union)
+ .register("plucker", plucker)
+ .register("HashTable", __webpack_require__(/*! ht */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/ht/index.js"))
+ .register("declare", __webpack_require__(/*! declare.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js"))
+ .register(__webpack_require__(/*! leafy */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/leafy/index.js"))
+ .register("LinkedList", __webpack_require__(/*! ./linkedList */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/linkedList.js"));
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/flow.js":
+/*!********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/flow.js ***!
+ \********************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+"use strict";
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ bind = extd.bind,
+ declare = extd.declare,
+ nodes = __webpack_require__(/*! ./nodes */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/index.js"),
+ EventEmitter = __webpack_require__(/*! events */ "events").EventEmitter,
+ wm = __webpack_require__(/*! ./workingMemory */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/workingMemory.js"),
+ WorkingMemory = wm.WorkingMemory,
+ ExecutionStragegy = __webpack_require__(/*! ./executionStrategy */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/executionStrategy.js"),
+ AgendaTree = __webpack_require__(/*! ./agenda */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/agenda.js");
+
+module.exports = declare(EventEmitter, {
+
+ instance: {
+
+ name: null,
+
+ executionStrategy: null,
+
+ constructor: function (name, conflictResolutionStrategy) {
+ this.env = null;
+ this.name = name;
+ this.__rules = {};
+ this.conflictResolutionStrategy = conflictResolutionStrategy;
+ this.workingMemory = new WorkingMemory();
+ this.agenda = new AgendaTree(this, conflictResolutionStrategy);
+ this.agenda.on("fire", bind(this, "emit", "fire"));
+ this.agenda.on("focused", bind(this, "emit", "focused"));
+ this.rootNode = new nodes.RootNode(this.workingMemory, this.agenda);
+ extd.bindAll(this, "halt", "assert", "retract", "modify", "focus",
+ "emit", "getFacts", "getFact");
+ },
+
+ getFacts: function (Type) {
+ var ret;
+ if (Type) {
+ ret = this.workingMemory.getFactsByType(Type);
+ } else {
+ ret = this.workingMemory.getFacts();
+ }
+ return ret;
+ },
+
+ getFact: function (Type) {
+ var ret;
+ if (Type) {
+ ret = this.workingMemory.getFactsByType(Type);
+ } else {
+ ret = this.workingMemory.getFacts();
+ }
+ return ret && ret[0];
+ },
+
+ focus: function (focused) {
+ this.agenda.setFocus(focused);
+ return this;
+ },
+
+ halt: function () {
+ this.executionStrategy.halt();
+ return this;
+ },
+
+ dispose: function () {
+ this.workingMemory.dispose();
+ this.agenda.dispose();
+ this.rootNode.dispose();
+ },
+
+ assert: function (fact) {
+ this.rootNode.assertFact(this.workingMemory.assertFact(fact));
+ this.emit("assert", fact);
+ return fact;
+ },
+
+ // This method is called to remove an existing fact from working memory
+ retract: function (fact) {
+ //fact = this.workingMemory.getFact(fact);
+ this.rootNode.retractFact(this.workingMemory.retractFact(fact));
+ this.emit("retract", fact);
+ return fact;
+ },
+
+ // This method is called to alter an existing fact. It is essentially a
+ // retract followed by an assert.
+ modify: function (fact, cb) {
+ //fact = this.workingMemory.getFact(fact);
+ if ("function" === typeof cb) {
+ cb.call(fact, fact);
+ }
+ this.rootNode.modifyFact(this.workingMemory.modifyFact(fact));
+ this.emit("modify", fact);
+ return fact;
+ },
+
+ print: function () {
+ this.rootNode.print();
+ },
+
+ containsRule: function (name) {
+ return this.rootNode.containsRule(name);
+ },
+
+ rule: function (rule) {
+ this.rootNode.assertRule(rule);
+ },
+
+ matchUntilHalt: function (cb) {
+ return (this.executionStrategy = new ExecutionStragegy(this, true)).execute().classic(cb).promise();
+ },
+
+ match: function (cb) {
+ return (this.executionStrategy = new ExecutionStragegy(this)).execute().classic(cb).promise();
+ }
+
+ }
+});
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/flowContainer.js":
+/*!*****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/flowContainer.js ***!
+ \*****************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+"use strict";
+/* module decorator */ module = __webpack_require__.nmd(module);
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ instanceOf = extd.instanceOf,
+ forEach = extd.forEach,
+ declare = extd.declare,
+ InitialFact = __webpack_require__(/*! ./pattern */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/pattern.js").InitialFact,
+ conflictStrategies = __webpack_require__(/*! ./conflict */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/conflict.js"),
+ conflictResolution = conflictStrategies.strategy(["salience", "activationRecency"]),
+ rule = __webpack_require__(/*! ./rule */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/rule.js"),
+ Flow = __webpack_require__(/*! ./flow */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/flow.js");
+
+var flows = {};
+var FlowContainer = declare({
+
+ instance: {
+
+ constructor: function (name, cb) {
+ this.name = name;
+ this.cb = cb;
+ this.__rules = [];
+ this.__defined = {};
+ this.conflictResolutionStrategy = conflictResolution;
+ if (cb) {
+ cb.call(this, this);
+ }
+ if (!flows.hasOwnProperty(name)) {
+ flows[name] = this;
+ } else {
+ throw new Error("Flow with " + name + " already defined");
+ }
+ },
+
+ conflictResolution: function (strategies) {
+ this.conflictResolutionStrategy = conflictStrategies.strategy(strategies);
+ return this;
+ },
+
+ getDefined: function (name) {
+ var ret = this.__defined[name.toLowerCase()];
+ if (!ret) {
+ throw new Error(name + " flow class is not defined");
+ }
+ return ret;
+ },
+
+ addDefined: function (name, cls) {
+ //normalize
+ this.__defined[name.toLowerCase()] = cls;
+ return cls;
+ },
+
+ rule: function () {
+ this.__rules = this.__rules.concat(rule.createRule.apply(rule, arguments));
+ return this;
+ },
+
+ getSession: function () {
+ var flow = new Flow(this.name, this.conflictResolutionStrategy);
+ forEach(this.__rules, function (rule) {
+ flow.rule(rule);
+ });
+ flow.assert(new InitialFact());
+ for (var i = 0, l = arguments.length; i < l; i++) {
+ flow.assert(arguments[i]);
+ }
+ return flow;
+ },
+
+ containsRule: function (name) {
+ return extd.some(this.__rules, function (rule) {
+ return rule.name === name;
+ });
+ }
+
+ },
+
+ "static": {
+ getFlow: function (name) {
+ return flows[name];
+ },
+
+ hasFlow: function (name) {
+ return extd.has(flows, name);
+ },
+
+ deleteFlow: function (name) {
+ if (instanceOf(name, FlowContainer)) {
+ name = name.name;
+ }
+ delete flows[name];
+ return FlowContainer;
+ },
+
+ deleteFlows: function () {
+ for (var name in flows) {
+ if (name in flows) {
+ delete flows[name];
+ }
+ }
+ return FlowContainer;
+ },
+
+ create: function (name, cb) {
+ return new FlowContainer(name, cb);
+ }
+ }
+
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/index.js":
+/*!*********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/index.js ***!
+ \*********************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+/**
+ *
+ * @projectName nools
+ * @github https://github.com/C2FO/nools
+ * @includeDoc [Examples] ../docs-md/examples.md
+ * @includeDoc [Change Log] ../history.md
+ * @header [../readme.md]
+ */
+
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ fs = __webpack_require__(/*! fs */ "fs"),
+ path = __webpack_require__(/*! path */ "path"),
+ compile = __webpack_require__(/*! ./compile */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/compile/index.js"),
+ FlowContainer = __webpack_require__(/*! ./flowContainer */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/flowContainer.js");
+
+function isNoolsFile(file) {
+ return (/\.nools$/).test(file);
+}
+
+function parse(source) {
+ var ret;
+ if (isNoolsFile(source)) {
+ ret = compile.parse(fs.readFileSync(source, "utf8"), source);
+ } else {
+ ret = compile.parse(source);
+ }
+ return ret;
+}
+
+exports.Flow = FlowContainer;
+
+exports.getFlow = FlowContainer.getFlow;
+exports.hasFlow = FlowContainer.hasFlow;
+
+exports.deleteFlow = function (name) {
+ FlowContainer.deleteFlow(name);
+ return this;
+};
+
+exports.deleteFlows = function () {
+ FlowContainer.deleteFlows();
+ return this;
+};
+
+exports.flow = FlowContainer.create;
+
+exports.compile = function (file, options, cb) {
+ if (extd.isFunction(options)) {
+ cb = options;
+ options = {};
+ } else {
+ options = options || {};
+ }
+ if (extd.isString(file)) {
+ options.name = options.name || (isNoolsFile(file) ? path.basename(file, path.extname(file)) : null);
+ file = parse(file);
+ }
+ if (!options.name) {
+ throw new Error("Name required when compiling nools source");
+ }
+ return compile.compile(file, options, cb, FlowContainer);
+};
+
+exports.transpile = function (file, options) {
+ options = options || {};
+ if (extd.isString(file)) {
+ options.name = options.name || (isNoolsFile(file) ? path.basename(file, path.extname(file)) : null);
+ file = parse(file);
+ }
+ return compile.transpile(file, options);
+};
+
+exports.parse = parse;
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/linkedList.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/linkedList.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var declare = __webpack_require__(/*! declare.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js");
+declare({
+
+ instance: {
+ constructor: function () {
+ this.head = null;
+ this.tail = null;
+ this.length = null;
+ },
+
+ push: function (data) {
+ var tail = this.tail, head = this.head, node = {data: data, prev: tail, next: null};
+ if (tail) {
+ this.tail.next = node;
+ }
+ this.tail = node;
+ if (!head) {
+ this.head = node;
+ }
+ this.length++;
+ return node;
+ },
+
+ remove: function (node) {
+ if (node.prev) {
+ node.prev.next = node.next;
+ } else {
+ this.head = node.next;
+ }
+ if (node.next) {
+ node.next.prev = node.prev;
+ } else {
+ this.tail = node.prev;
+ }
+ //node.data = node.prev = node.next = null;
+ this.length--;
+ },
+
+ forEach: function (cb) {
+ var head = {next: this.head};
+ while ((head = head.next)) {
+ cb(head.data);
+ }
+ },
+
+ toArray: function () {
+ var head = {next: this.head}, ret = [];
+ while ((head = head.next)) {
+ ret.push(head);
+ }
+ return ret;
+ },
+
+ removeByData: function (data) {
+ var head = {next: this.head};
+ while ((head = head.next)) {
+ if (head.data === data) {
+ this.remove(head);
+ break;
+ }
+ }
+ },
+
+ getByData: function (data) {
+ var head = {next: this.head};
+ while ((head = head.next)) {
+ if (head.data === data) {
+ return head;
+ }
+ }
+ },
+
+ clear: function () {
+ this.head = this.tail = null;
+ this.length = 0;
+ }
+
+ }
+
+}).as(module);
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nextTick.js":
+/*!************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nextTick.js ***!
+ \************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/*global setImmediate, window, MessageChannel*/
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js");
+var nextTick;
+if (typeof setImmediate === "function") {
+ // In IE10, or use https://github.com/NobleJS/setImmediate
+ if (typeof window !== "undefined") {
+ nextTick = extd.bind(window, setImmediate);
+ } else {
+ nextTick = setImmediate;
+ }
+} else if (typeof process !== "undefined") {
+ // node
+ nextTick = process.nextTick;
+} else if (typeof MessageChannel !== "undefined") {
+ // modern browsers
+ // http://www.nonblocking.io/2011/06/windownexttick.html
+ var channel = new MessageChannel();
+ // linked list of tasks (single, with head node)
+ var head = {}, tail = head;
+ channel.port1.onmessage = function () {
+ head = head.next;
+ var task = head.task;
+ delete head.task;
+ task();
+ };
+ nextTick = function (task) {
+ tail = tail.next = {task: task};
+ channel.port2.postMessage(0);
+ };
+} else {
+ // old browsers
+ nextTick = function (task) {
+ setTimeout(task, 0);
+ };
+}
+
+module.exports = nextTick;
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/adapterNode.js":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/adapterNode.js ***!
+ \*********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var Node = __webpack_require__(/*! ./node */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/node.js"),
+ intersection = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js").intersection;
+
+Node.extend({
+ instance: {
+
+ __propagatePaths: function (method, context) {
+ var entrySet = this.__entrySet, i = entrySet.length, entry, outNode, paths, continuingPaths;
+ while (--i > -1) {
+ entry = entrySet[i];
+ outNode = entry.key;
+ paths = entry.value;
+ if ((continuingPaths = intersection(paths, context.paths)).length) {
+ outNode[method](context.clone(null, continuingPaths, null));
+ }
+ }
+ },
+
+ __propagateNoPaths: function (method, context) {
+ var entrySet = this.__entrySet, i = entrySet.length;
+ while (--i > -1) {
+ entrySet[i].key[method](context);
+ }
+ },
+
+ __propagate: function (method, context) {
+ if (context.paths) {
+ this.__propagatePaths(method, context);
+ } else {
+ this.__propagateNoPaths(method, context);
+ }
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/aliasNode.js":
+/*!*******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/aliasNode.js ***!
+ \*******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var AlphaNode = __webpack_require__(/*! ./alphaNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/alphaNode.js");
+
+AlphaNode.extend({
+ instance: {
+
+ constructor: function () {
+ this._super(arguments);
+ this.alias = this.constraint.get("alias");
+ },
+
+ toString: function () {
+ return "AliasNode" + this.__count;
+ },
+
+ assert: function (context) {
+ return this.__propagate("assert", context.set(this.alias, context.fact.object));
+ },
+
+ modify: function (context) {
+ return this.__propagate("modify", context.set(this.alias, context.fact.object));
+ },
+
+ retract: function (context) {
+ return this.__propagate("retract", context.set(this.alias, context.fact.object));
+ },
+
+ equal: function (other) {
+ return other instanceof this._static && this.alias === other.alias;
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/alphaNode.js":
+/*!*******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/alphaNode.js ***!
+ \*******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+"use strict";
+/* module decorator */ module = __webpack_require__.nmd(module);
+
+var Node = __webpack_require__(/*! ./node */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/node.js");
+
+Node.extend({
+ instance: {
+ constructor: function (constraint) {
+ this._super([]);
+ this.constraint = constraint;
+ this.constraintAssert = this.constraint.assert;
+ },
+
+ toString: function () {
+ return "AlphaNode " + this.__count;
+ },
+
+ equal: function (constraint) {
+ return this.constraint.equal(constraint.constraint);
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/betaNode.js":
+/*!******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/betaNode.js ***!
+ \******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ keys = extd.hash.keys,
+ Node = __webpack_require__(/*! ./node */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/node.js"),
+ LeftMemory = __webpack_require__(/*! ./misc/leftMemory */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/leftMemory.js"), RightMemory = __webpack_require__(/*! ./misc/rightMemory */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/rightMemory.js");
+
+Node.extend({
+
+ instance: {
+
+ nodeType: "BetaNode",
+
+ constructor: function () {
+ this._super([]);
+ this.leftMemory = {};
+ this.rightMemory = {};
+ this.leftTuples = new LeftMemory();
+ this.rightTuples = new RightMemory();
+ },
+
+ __propagate: function (method, context) {
+ var entrySet = this.__entrySet, i = entrySet.length, entry, outNode;
+ while (--i > -1) {
+ entry = entrySet[i];
+ outNode = entry.key;
+ outNode[method](context);
+ }
+ },
+
+ dispose: function () {
+ this.leftMemory = {};
+ this.rightMemory = {};
+ this.leftTuples.clear();
+ this.rightTuples.clear();
+ },
+
+ disposeLeft: function (fact) {
+ this.leftMemory = {};
+ this.leftTuples.clear();
+ this.propagateDispose(fact);
+ },
+
+ disposeRight: function (fact) {
+ this.rightMemory = {};
+ this.rightTuples.clear();
+ this.propagateDispose(fact);
+ },
+
+ hashCode: function () {
+ return this.nodeType + " " + this.__count;
+ },
+
+ toString: function () {
+ return this.nodeType + " " + this.__count;
+ },
+
+ retractLeft: function (context) {
+ context = this.removeFromLeftMemory(context).data;
+ var rightMatches = context.rightMatches,
+ hashCodes = keys(rightMatches),
+ i = -1,
+ l = hashCodes.length;
+ while (++i < l) {
+ this.__propagate("retract", rightMatches[hashCodes[i]].clone());
+ }
+ },
+
+ retractRight: function (context) {
+ context = this.removeFromRightMemory(context).data;
+ var leftMatches = context.leftMatches,
+ hashCodes = keys(leftMatches),
+ i = -1,
+ l = hashCodes.length;
+ while (++i < l) {
+ this.__propagate("retract", leftMatches[hashCodes[i]].clone());
+ }
+ },
+
+ assertLeft: function (context) {
+ this.__addToLeftMemory(context);
+ var rm = this.rightTuples.getRightMemory(context), i = -1, l = rm.length;
+ while (++i < l) {
+ this.propagateFromLeft(context, rm[i].data);
+ }
+ },
+
+ assertRight: function (context) {
+ this.__addToRightMemory(context);
+ var lm = this.leftTuples.getLeftMemory(context), i = -1, l = lm.length;
+ while (++i < l) {
+ this.propagateFromRight(context, lm[i].data);
+ }
+ },
+
+ modifyLeft: function (context) {
+ var previousContext = this.removeFromLeftMemory(context).data;
+ this.__addToLeftMemory(context);
+ var rm = this.rightTuples.getRightMemory(context), l = rm.length, i = -1, rightMatches;
+ if (!l) {
+ this.propagateRetractModifyFromLeft(previousContext);
+ } else {
+ rightMatches = previousContext.rightMatches;
+ while (++i < l) {
+ this.propagateAssertModifyFromLeft(context, rightMatches, rm[i].data);
+ }
+
+ }
+ },
+
+ modifyRight: function (context) {
+ var previousContext = this.removeFromRightMemory(context).data;
+ this.__addToRightMemory(context);
+ var lm = this.leftTuples.getLeftMemory(context);
+ if (!lm.length) {
+ this.propagateRetractModifyFromRight(previousContext);
+ } else {
+ var leftMatches = previousContext.leftMatches, i = -1, l = lm.length;
+ while (++i < l) {
+ this.propagateAssertModifyFromRight(context, leftMatches, lm[i].data);
+ }
+ }
+ },
+
+ propagateFromLeft: function (context, rc) {
+ this.__propagate("assert", this.__addToMemoryMatches(rc, context, context.clone(null, null, context.match.merge(rc.match))));
+ },
+
+ propagateFromRight: function (context, lc) {
+ this.__propagate("assert", this.__addToMemoryMatches(context, lc, lc.clone(null, null, lc.match.merge(context.match))));
+ },
+
+ propagateRetractModifyFromLeft: function (context) {
+ var rightMatches = context.rightMatches,
+ hashCodes = keys(rightMatches),
+ l = hashCodes.length,
+ i = -1;
+ while (++i < l) {
+ this.__propagate("retract", rightMatches[hashCodes[i]].clone());
+ }
+ },
+
+ propagateRetractModifyFromRight: function (context) {
+ var leftMatches = context.leftMatches,
+ hashCodes = keys(leftMatches),
+ l = hashCodes.length,
+ i = -1;
+ while (++i < l) {
+ this.__propagate("retract", leftMatches[hashCodes[i]].clone());
+ }
+ },
+
+ propagateAssertModifyFromLeft: function (context, rightMatches, rm) {
+ var factId = rm.hashCode;
+ if (factId in rightMatches) {
+ this.__propagate("modify", this.__addToMemoryMatches(rm, context, context.clone(null, null, context.match.merge(rm.match))));
+ } else {
+ this.propagateFromLeft(context, rm);
+ }
+ },
+
+ propagateAssertModifyFromRight: function (context, leftMatches, lm) {
+ var factId = lm.hashCode;
+ if (factId in leftMatches) {
+ this.__propagate("modify", this.__addToMemoryMatches(context, lm, context.clone(null, null, lm.match.merge(context.match))));
+ } else {
+ this.propagateFromRight(context, lm);
+ }
+ },
+
+ removeFromRightMemory: function (context) {
+ var hashCode = context.hashCode, ret;
+ context = this.rightMemory[hashCode] || null;
+ var tuples = this.rightTuples;
+ if (context) {
+ var leftMemory = this.leftMemory;
+ ret = context.data;
+ var leftMatches = ret.leftMatches;
+ tuples.remove(context);
+ var hashCodes = keys(leftMatches), i = -1, l = hashCodes.length;
+ while (++i < l) {
+ delete leftMemory[hashCodes[i]].data.rightMatches[hashCode];
+ }
+ delete this.rightMemory[hashCode];
+ }
+ return context;
+ },
+
+ removeFromLeftMemory: function (context) {
+ var hashCode = context.hashCode;
+ context = this.leftMemory[hashCode] || null;
+ if (context) {
+ var rightMemory = this.rightMemory;
+ var rightMatches = context.data.rightMatches;
+ this.leftTuples.remove(context);
+ var hashCodes = keys(rightMatches), i = -1, l = hashCodes.length;
+ while (++i < l) {
+ delete rightMemory[hashCodes[i]].data.leftMatches[hashCode];
+ }
+ delete this.leftMemory[hashCode];
+ }
+ return context;
+ },
+
+ getRightMemoryMatches: function (context) {
+ var lm = this.leftMemory[context.hashCode], ret = {};
+ if (lm) {
+ ret = lm.rightMatches;
+ }
+ return ret;
+ },
+
+ __addToMemoryMatches: function (rightContext, leftContext, createdContext) {
+ var rightFactId = rightContext.hashCode,
+ rm = this.rightMemory[rightFactId],
+ lm, leftFactId = leftContext.hashCode;
+ if (rm) {
+ rm = rm.data;
+ if (leftFactId in rm.leftMatches) {
+ throw new Error("Duplicate left fact entry");
+ }
+ rm.leftMatches[leftFactId] = createdContext;
+ }
+ lm = this.leftMemory[leftFactId];
+ if (lm) {
+ lm = lm.data;
+ if (rightFactId in lm.rightMatches) {
+ throw new Error("Duplicate right fact entry");
+ }
+ lm.rightMatches[rightFactId] = createdContext;
+ }
+ return createdContext;
+ },
+
+ __addToRightMemory: function (context) {
+ var hashCode = context.hashCode, rm = this.rightMemory;
+ if (hashCode in rm) {
+ return false;
+ }
+ rm[hashCode] = this.rightTuples.push(context);
+ context.leftMatches = {};
+ return true;
+ },
+
+
+ __addToLeftMemory: function (context) {
+ var hashCode = context.hashCode, lm = this.leftMemory;
+ if (hashCode in lm) {
+ return false;
+ }
+ lm[hashCode] = this.leftTuples.push(context);
+ context.rightMatches = {};
+ return true;
+ }
+ }
+
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/equalityNode.js":
+/*!**********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/equalityNode.js ***!
+ \**********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var AlphaNode = __webpack_require__(/*! ./alphaNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/alphaNode.js");
+
+AlphaNode.extend({
+ instance: {
+
+ constructor: function () {
+ this.memory = {};
+ this._super(arguments);
+ this.constraintAssert = this.constraint.assert;
+ },
+
+ assert: function (context) {
+ if ((this.memory[context.pathsHash] = this.constraintAssert(context.factHash))) {
+ this.__propagate("assert", context);
+ }
+ },
+
+ modify: function (context) {
+ var memory = this.memory,
+ hashCode = context.pathsHash,
+ wasMatch = memory[hashCode];
+ if ((memory[hashCode] = this.constraintAssert(context.factHash))) {
+ this.__propagate(wasMatch ? "modify" : "assert", context);
+ } else if (wasMatch) {
+ this.__propagate("retract", context);
+ }
+ },
+
+ retract: function (context) {
+ var hashCode = context.pathsHash,
+ memory = this.memory;
+ if (memory[hashCode]) {
+ this.__propagate("retract", context);
+ }
+ delete memory[hashCode];
+ },
+
+ toString: function () {
+ return "EqualityNode" + this.__count;
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/existsFromNode.js":
+/*!************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/existsFromNode.js ***!
+ \************************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var FromNotNode = __webpack_require__(/*! ./fromNotNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/fromNotNode.js"),
+ extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ Context = __webpack_require__(/*! ../context */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js"),
+ isDefined = extd.isDefined,
+ isArray = extd.isArray;
+
+FromNotNode.extend({
+ instance: {
+
+ nodeType: "ExistsFromNode",
+
+ retractLeft: function (context) {
+ var ctx = this.removeFromLeftMemory(context);
+ if (ctx) {
+ ctx = ctx.data;
+ if (ctx.blocked) {
+ this.__propagate("retract", ctx.clone());
+ }
+ }
+ },
+
+ __modify: function (context, leftContext) {
+ var leftContextBlocked = leftContext.blocked;
+ var fh = context.factHash, o = this.from(fh);
+ if (isArray(o)) {
+ for (var i = 0, l = o.length; i < l; i++) {
+ if (this.__isMatch(context, o[i], true)) {
+ context.blocked = true;
+ break;
+ }
+ }
+ } else if (isDefined(o)) {
+ context.blocked = this.__isMatch(context, o, true);
+ }
+ var newContextBlocked = context.blocked;
+ if (newContextBlocked) {
+ if (leftContextBlocked) {
+ this.__propagate("modify", context.clone());
+ } else {
+ this.__propagate("assert", context.clone());
+ }
+ } else if (leftContextBlocked) {
+ this.__propagate("retract", context.clone());
+ }
+
+ },
+
+ __findMatches: function (context) {
+ var fh = context.factHash, o = this.from(fh), isMatch = false;
+ if (isArray(o)) {
+ for (var i = 0, l = o.length; i < l; i++) {
+ if (this.__isMatch(context, o[i], true)) {
+ context.blocked = true;
+ this.__propagate("assert", context.clone());
+ return;
+ }
+ }
+ } else if (isDefined(o) && (this.__isMatch(context, o, true))) {
+ context.blocked = true;
+ this.__propagate("assert", context.clone());
+ }
+ return isMatch;
+ },
+
+ __isMatch: function (oc, o, add) {
+ var ret = false;
+ if (this.type(o)) {
+ var createdFact = this.workingMemory.getFactHandle(o);
+ var context = new Context(createdFact, null, null)
+ .mergeMatch(oc.match)
+ .set(this.alias, o);
+ if (add) {
+ var fm = this.fromMemory[createdFact.id];
+ if (!fm) {
+ fm = this.fromMemory[createdFact.id] = {};
+ }
+ fm[oc.hashCode] = oc;
+ }
+ var fh = context.factHash;
+ var eqConstraints = this.__equalityConstraints;
+ for (var i = 0, l = eqConstraints.length; i < l; i++) {
+ if (eqConstraints[i](fh)) {
+ ret = true;
+ } else {
+ ret = false;
+ break;
+ }
+ }
+ }
+ return ret;
+ },
+
+ assertLeft: function (context) {
+ this.__addToLeftMemory(context);
+ this.__findMatches(context);
+ }
+
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/existsNode.js":
+/*!********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/existsNode.js ***!
+ \********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var NotNode = __webpack_require__(/*! ./notNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/notNode.js"),
+ LinkedList = __webpack_require__(/*! ../linkedList */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/linkedList.js");
+
+
+NotNode.extend({
+ instance: {
+
+ nodeType: "ExistsNode",
+
+ blockedContext: function (leftContext, rightContext) {
+ leftContext.blocker = rightContext;
+ this.removeFromLeftMemory(leftContext);
+ this.addToLeftBlockedMemory(rightContext.blocking.push(leftContext));
+ this.__propagate("assert", this.__cloneContext(leftContext));
+ },
+
+ notBlockedContext: function (leftContext, propagate) {
+ this.__addToLeftMemory(leftContext);
+ propagate && this.__propagate("retract", this.__cloneContext(leftContext));
+ },
+
+ propagateFromLeft: function (leftContext) {
+ this.notBlockedContext(leftContext, false);
+ },
+
+
+ retractLeft: function (context) {
+ var ctx;
+ if (!this.removeFromLeftMemory(context)) {
+ if ((ctx = this.removeFromLeftBlockedMemory(context))) {
+ this.__propagate("retract", this.__cloneContext(ctx.data));
+ } else {
+ throw new Error();
+ }
+ }
+ },
+
+ modifyLeft: function (context) {
+ var ctx = this.removeFromLeftMemory(context),
+ leftContext,
+ thisConstraint = this.constraint,
+ rightTuples = this.rightTuples,
+ l = rightTuples.length,
+ isBlocked = false,
+ node, rc, blocker;
+ if (!ctx) {
+ //blocked before
+ ctx = this.removeFromLeftBlockedMemory(context);
+ isBlocked = true;
+ }
+ if (ctx) {
+ leftContext = ctx.data;
+
+ if (leftContext && leftContext.blocker) {
+ //we were blocked before so only check nodes previous to our blocker
+ blocker = this.rightMemory[leftContext.blocker.hashCode];
+ }
+ if (blocker) {
+ if (thisConstraint.isMatch(context, rc = blocker.data)) {
+ //propogate as a modify or assert
+ this.__propagate(!isBlocked ? "assert" : "modify", this.__cloneContext(leftContext));
+ context.blocker = rc;
+ this.addToLeftBlockedMemory(rc.blocking.push(context));
+ context = null;
+ }
+ if (context) {
+ node = {next: blocker.next};
+ }
+ } else {
+ node = {next: rightTuples.head};
+ }
+ if (context && l) {
+ node = {next: rightTuples.head};
+ //we were propagated before
+ while ((node = node.next)) {
+ if (thisConstraint.isMatch(context, rc = node.data)) {
+ //we cant be proagated so retract previous
+
+ //we were asserted before so retract
+ this.__propagate(!isBlocked ? "assert" : "modify", this.__cloneContext(leftContext));
+
+ this.addToLeftBlockedMemory(rc.blocking.push(context));
+ context.blocker = rc;
+ context = null;
+ break;
+ }
+ }
+ }
+ if (context) {
+ //we can still be propogated
+ this.__addToLeftMemory(context);
+ if (isBlocked) {
+ //we were blocked so retract
+ this.__propagate("retract", this.__cloneContext(context));
+ }
+
+ }
+ } else {
+ throw new Error();
+ }
+
+ },
+
+ modifyRight: function (context) {
+ var ctx = this.removeFromRightMemory(context);
+ if (ctx) {
+ var rightContext = ctx.data,
+ leftTuples = this.leftTuples,
+ leftTuplesLength = leftTuples.length,
+ leftContext,
+ thisConstraint = this.constraint,
+ node,
+ blocking = rightContext.blocking;
+ this.__addToRightMemory(context);
+ context.blocking = new LinkedList();
+ if (leftTuplesLength || blocking.length) {
+ if (blocking.length) {
+ var rc;
+ //check old blocked contexts
+ //check if the same contexts blocked before are still blocked
+ var blockingNode = {next: blocking.head};
+ while ((blockingNode = blockingNode.next)) {
+ leftContext = blockingNode.data;
+ leftContext.blocker = null;
+ if (thisConstraint.isMatch(leftContext, context)) {
+ leftContext.blocker = context;
+ this.addToLeftBlockedMemory(context.blocking.push(leftContext));
+ this.__propagate("assert", this.__cloneContext(leftContext));
+ leftContext = null;
+ } else {
+ //we arent blocked anymore
+ leftContext.blocker = null;
+ node = ctx;
+ while ((node = node.next)) {
+ if (thisConstraint.isMatch(leftContext, rc = node.data)) {
+ leftContext.blocker = rc;
+ this.addToLeftBlockedMemory(rc.blocking.push(leftContext));
+ this.__propagate("assert", this.__cloneContext(leftContext));
+ leftContext = null;
+ break;
+ }
+ }
+ if (leftContext) {
+ this.__addToLeftMemory(leftContext);
+ }
+ }
+ }
+ }
+
+ if (leftTuplesLength) {
+ //check currently left tuples in memory
+ node = {next: leftTuples.head};
+ while ((node = node.next)) {
+ leftContext = node.data;
+ if (thisConstraint.isMatch(leftContext, context)) {
+ this.__propagate("assert", this.__cloneContext(leftContext));
+ this.removeFromLeftMemory(leftContext);
+ this.addToLeftBlockedMemory(context.blocking.push(leftContext));
+ leftContext.blocker = context;
+ }
+ }
+ }
+
+
+ }
+ } else {
+ throw new Error();
+ }
+
+
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/fromNode.js":
+/*!******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/fromNode.js ***!
+ \******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var JoinNode = __webpack_require__(/*! ./joinNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinNode.js"),
+ extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ constraint = __webpack_require__(/*! ../constraint */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraint.js"),
+ EqualityConstraint = constraint.EqualityConstraint,
+ HashConstraint = constraint.HashConstraint,
+ ReferenceConstraint = constraint.ReferenceConstraint,
+ Context = __webpack_require__(/*! ../context */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js"),
+ isDefined = extd.isDefined,
+ isEmpty = extd.isEmpty,
+ forEach = extd.forEach,
+ isArray = extd.isArray;
+
+var DEFAULT_MATCH = {
+ isMatch: function () {
+ return false;
+ }
+};
+
+JoinNode.extend({
+ instance: {
+
+ nodeType: "FromNode",
+
+ constructor: function (pattern, wm) {
+ this._super(arguments);
+ this.workingMemory = wm;
+ this.fromMemory = {};
+ this.pattern = pattern;
+ this.type = pattern.get("constraints")[0].assert;
+ this.alias = pattern.get("alias");
+ this.from = pattern.from.assert;
+ var eqConstraints = this.__equalityConstraints = [];
+ var vars = [];
+ forEach(this.constraints = this.pattern.get("constraints").slice(1), function (c) {
+ if (c instanceof EqualityConstraint || c instanceof ReferenceConstraint) {
+ eqConstraints.push(c.assert);
+ } else if (c instanceof HashConstraint) {
+ vars = vars.concat(c.get("variables"));
+ }
+ });
+ this.__variables = vars;
+ },
+
+ __createMatches: function (context) {
+ var fh = context.factHash, o = this.from(fh);
+ if (isArray(o)) {
+ for (var i = 0, l = o.length; i < l; i++) {
+ this.__checkMatch(context, o[i], true);
+ }
+ } else if (isDefined(o)) {
+ this.__checkMatch(context, o, true);
+ }
+ },
+
+ __checkMatch: function (context, o, propogate) {
+ var newContext;
+ if ((newContext = this.__createMatch(context, o)).isMatch() && propogate) {
+ this.__propagate("assert", newContext.clone());
+ }
+ return newContext;
+ },
+
+ __createMatch: function (lc, o) {
+ if (this.type(o)) {
+ var createdFact = this.workingMemory.getFactHandle(o, true),
+ createdContext,
+ rc = new Context(createdFact, null, null)
+ .set(this.alias, o),
+ createdFactId = createdFact.id;
+ var fh = rc.factHash, lcFh = lc.factHash;
+ for (var key in lcFh) {
+ fh[key] = lcFh[key];
+ }
+ var eqConstraints = this.__equalityConstraints, vars = this.__variables, i = -1, l = eqConstraints.length;
+ while (++i < l) {
+ if (!eqConstraints[i](fh, fh)) {
+ createdContext = DEFAULT_MATCH;
+ break;
+ }
+ }
+ var fm = this.fromMemory[createdFactId];
+ if (!fm) {
+ fm = this.fromMemory[createdFactId] = {};
+ }
+ if (!createdContext) {
+ var prop;
+ i = -1;
+ l = vars.length;
+ while (++i < l) {
+ prop = vars[i];
+ fh[prop] = o[prop];
+ }
+ lc.fromMatches[createdFact.id] = createdContext = rc.clone(createdFact, null, lc.match.merge(rc.match));
+ }
+ fm[lc.hashCode] = [lc, createdContext];
+ return createdContext;
+ }
+ return DEFAULT_MATCH;
+ },
+
+ retractRight: function () {
+ throw new Error("Shouldnt have gotten here");
+ },
+
+ removeFromFromMemory: function (context) {
+ var factId = context.fact.id;
+ var fm = this.fromMemory[factId];
+ if (fm) {
+ var entry;
+ for (var i in fm) {
+ entry = fm[i];
+ if (entry[1] === context) {
+ delete fm[i];
+ if (isEmpty(fm)) {
+ delete this.fromMemory[factId];
+ }
+ break;
+ }
+ }
+ }
+
+ },
+
+ retractLeft: function (context) {
+ var ctx = this.removeFromLeftMemory(context);
+ if (ctx) {
+ ctx = ctx.data;
+ var fromMatches = ctx.fromMatches;
+ for (var i in fromMatches) {
+ this.removeFromFromMemory(fromMatches[i]);
+ this.__propagate("retract", fromMatches[i].clone());
+ }
+ }
+ },
+
+ modifyLeft: function (context) {
+ var ctx = this.removeFromLeftMemory(context), newContext, i, l, factId, fact;
+ if (ctx) {
+ this.__addToLeftMemory(context);
+
+ var leftContext = ctx.data,
+ fromMatches = (context.fromMatches = {}),
+ rightMatches = leftContext.fromMatches,
+ o = this.from(context.factHash);
+
+ if (isArray(o)) {
+ for (i = 0, l = o.length; i < l; i++) {
+ newContext = this.__checkMatch(context, o[i], false);
+ if (newContext.isMatch()) {
+ factId = newContext.fact.id;
+ if (factId in rightMatches) {
+ this.__propagate("modify", newContext.clone());
+ } else {
+ this.__propagate("assert", newContext.clone());
+ }
+ }
+ }
+ } else if (isDefined(o)) {
+ newContext = this.__checkMatch(context, o, false);
+ if (newContext.isMatch()) {
+ factId = newContext.fact.id;
+ if (factId in rightMatches) {
+ this.__propagate("modify", newContext.clone());
+ } else {
+ this.__propagate("assert", newContext.clone());
+ }
+ }
+ }
+ for (i in rightMatches) {
+ if (!(i in fromMatches)) {
+ this.removeFromFromMemory(rightMatches[i]);
+ this.__propagate("retract", rightMatches[i].clone());
+ }
+ }
+ } else {
+ this.assertLeft(context);
+ }
+ fact = context.fact;
+ factId = fact.id;
+ var fm = this.fromMemory[factId];
+ this.fromMemory[factId] = {};
+ if (fm) {
+ var lc, entry, cc, createdIsMatch, factObject = fact.object;
+ for (i in fm) {
+ entry = fm[i];
+ lc = entry[0];
+ cc = entry[1];
+ createdIsMatch = cc.isMatch();
+ if (lc.hashCode !== context.hashCode) {
+ newContext = this.__createMatch(lc, factObject, false);
+ if (createdIsMatch) {
+ this.__propagate("retract", cc.clone());
+ }
+ if (newContext.isMatch()) {
+ this.__propagate(createdIsMatch ? "modify" : "assert", newContext.clone());
+ }
+
+ }
+ }
+ }
+ },
+
+ assertLeft: function (context) {
+ this.__addToLeftMemory(context);
+ context.fromMatches = {};
+ this.__createMatches(context);
+ },
+
+ assertRight: function () {
+ throw new Error("Shouldnt have gotten here");
+ }
+
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/fromNotNode.js":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/fromNotNode.js ***!
+ \*********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var JoinNode = __webpack_require__(/*! ./joinNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinNode.js"),
+ extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ constraint = __webpack_require__(/*! ../constraint */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraint.js"),
+ EqualityConstraint = constraint.EqualityConstraint,
+ HashConstraint = constraint.HashConstraint,
+ ReferenceConstraint = constraint.ReferenceConstraint,
+ Context = __webpack_require__(/*! ../context */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js"),
+ isDefined = extd.isDefined,
+ forEach = extd.forEach,
+ isArray = extd.isArray;
+
+JoinNode.extend({
+ instance: {
+
+ nodeType: "FromNotNode",
+
+ constructor: function (pattern, workingMemory) {
+ this._super(arguments);
+ this.workingMemory = workingMemory;
+ this.pattern = pattern;
+ this.type = pattern.get("constraints")[0].assert;
+ this.alias = pattern.get("alias");
+ this.from = pattern.from.assert;
+ this.fromMemory = {};
+ var eqConstraints = this.__equalityConstraints = [];
+ var vars = [];
+ forEach(this.constraints = this.pattern.get("constraints").slice(1), function (c) {
+ if (c instanceof EqualityConstraint || c instanceof ReferenceConstraint) {
+ eqConstraints.push(c.assert);
+ } else if (c instanceof HashConstraint) {
+ vars = vars.concat(c.get("variables"));
+ }
+ });
+ this.__variables = vars;
+
+ },
+
+ retractLeft: function (context) {
+ var ctx = this.removeFromLeftMemory(context);
+ if (ctx) {
+ ctx = ctx.data;
+ if (!ctx.blocked) {
+ this.__propagate("retract", ctx.clone());
+ }
+ }
+ },
+
+ __modify: function (context, leftContext) {
+ var leftContextBlocked = leftContext.blocked;
+ var fh = context.factHash, o = this.from(fh);
+ if (isArray(o)) {
+ for (var i = 0, l = o.length; i < l; i++) {
+ if (this.__isMatch(context, o[i], true)) {
+ context.blocked = true;
+ break;
+ }
+ }
+ } else if (isDefined(o)) {
+ context.blocked = this.__isMatch(context, o, true);
+ }
+ var newContextBlocked = context.blocked;
+ if (!newContextBlocked) {
+ if (leftContextBlocked) {
+ this.__propagate("assert", context.clone());
+ } else {
+ this.__propagate("modify", context.clone());
+ }
+ } else if (!leftContextBlocked) {
+ this.__propagate("retract", leftContext.clone());
+ }
+
+ },
+
+ modifyLeft: function (context) {
+ var ctx = this.removeFromLeftMemory(context);
+ if (ctx) {
+ this.__addToLeftMemory(context);
+ this.__modify(context, ctx.data);
+ } else {
+ throw new Error();
+ }
+ var fm = this.fromMemory[context.fact.id];
+ this.fromMemory[context.fact.id] = {};
+ if (fm) {
+ for (var i in fm) {
+ // update any contexts associated with this fact
+ if (i !== context.hashCode) {
+ var lc = fm[i];
+ ctx = this.removeFromLeftMemory(lc);
+ if (ctx) {
+ lc = lc.clone();
+ lc.blocked = false;
+ this.__addToLeftMemory(lc);
+ this.__modify(lc, ctx.data);
+ }
+ }
+ }
+ }
+ },
+
+ __findMatches: function (context) {
+ var fh = context.factHash, o = this.from(fh), isMatch = false;
+ if (isArray(o)) {
+ for (var i = 0, l = o.length; i < l; i++) {
+ if (this.__isMatch(context, o[i], true)) {
+ context.blocked = true;
+ return;
+ }
+ }
+ this.__propagate("assert", context.clone());
+ } else if (isDefined(o) && !(context.blocked = this.__isMatch(context, o, true))) {
+ this.__propagate("assert", context.clone());
+ }
+ return isMatch;
+ },
+
+ __isMatch: function (oc, o, add) {
+ var ret = false;
+ if (this.type(o)) {
+ var createdFact = this.workingMemory.getFactHandle(o);
+ var context = new Context(createdFact, null)
+ .mergeMatch(oc.match)
+ .set(this.alias, o);
+ if (add) {
+ var fm = this.fromMemory[createdFact.id];
+ if (!fm) {
+ fm = this.fromMemory[createdFact.id] = {};
+ }
+ fm[oc.hashCode] = oc;
+ }
+ var fh = context.factHash;
+ var eqConstraints = this.__equalityConstraints;
+ for (var i = 0, l = eqConstraints.length; i < l; i++) {
+ if (eqConstraints[i](fh, fh)) {
+ ret = true;
+ } else {
+ ret = false;
+ break;
+ }
+ }
+ }
+ return ret;
+ },
+
+ assertLeft: function (context) {
+ this.__addToLeftMemory(context);
+ this.__findMatches(context);
+ },
+
+ assertRight: function () {
+ throw new Error("Shouldnt have gotten here");
+ },
+
+ retractRight: function () {
+ throw new Error("Shouldnt have gotten here");
+ }
+
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/index.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/index.js ***!
+ \***************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+var extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ forEach = extd.forEach,
+ some = extd.some,
+ declare = extd.declare,
+ pattern = __webpack_require__(/*! ../pattern.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/pattern.js"),
+ ObjectPattern = pattern.ObjectPattern,
+ FromPattern = pattern.FromPattern,
+ FromNotPattern = pattern.FromNotPattern,
+ ExistsPattern = pattern.ExistsPattern,
+ FromExistsPattern = pattern.FromExistsPattern,
+ NotPattern = pattern.NotPattern,
+ CompositePattern = pattern.CompositePattern,
+ InitialFactPattern = pattern.InitialFactPattern,
+ constraints = __webpack_require__(/*! ../constraint */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraint.js"),
+ HashConstraint = constraints.HashConstraint,
+ ReferenceConstraint = constraints.ReferenceConstraint,
+ AliasNode = __webpack_require__(/*! ./aliasNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/aliasNode.js"),
+ EqualityNode = __webpack_require__(/*! ./equalityNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/equalityNode.js"),
+ JoinNode = __webpack_require__(/*! ./joinNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinNode.js"),
+ BetaNode = __webpack_require__(/*! ./betaNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/betaNode.js"),
+ NotNode = __webpack_require__(/*! ./notNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/notNode.js"),
+ FromNode = __webpack_require__(/*! ./fromNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/fromNode.js"),
+ FromNotNode = __webpack_require__(/*! ./fromNotNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/fromNotNode.js"),
+ ExistsNode = __webpack_require__(/*! ./existsNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/existsNode.js"),
+ ExistsFromNode = __webpack_require__(/*! ./existsFromNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/existsFromNode.js"),
+ LeftAdapterNode = __webpack_require__(/*! ./leftAdapterNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/leftAdapterNode.js"),
+ RightAdapterNode = __webpack_require__(/*! ./rightAdapterNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/rightAdapterNode.js"),
+ TypeNode = __webpack_require__(/*! ./typeNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/typeNode.js"),
+ TerminalNode = __webpack_require__(/*! ./terminalNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/terminalNode.js"),
+ PropertyNode = __webpack_require__(/*! ./propertyNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/propertyNode.js");
+
+function hasRefernceConstraints(pattern) {
+ return some(pattern.constraints || [], function (c) {
+ return c instanceof ReferenceConstraint;
+ });
+}
+
+declare({
+ instance: {
+ constructor: function (wm, agendaTree) {
+ this.terminalNodes = [];
+ this.joinNodes = [];
+ this.nodes = [];
+ this.constraints = [];
+ this.typeNodes = [];
+ this.__ruleCount = 0;
+ this.bucket = {
+ counter: 0,
+ recency: 0
+ };
+ this.agendaTree = agendaTree;
+ this.workingMemory = wm;
+ },
+
+ assertRule: function (rule) {
+ var terminalNode = new TerminalNode(this.bucket, this.__ruleCount++, rule, this.agendaTree);
+ this.__addToNetwork(rule, rule.pattern, terminalNode);
+ this.__mergeJoinNodes();
+ this.terminalNodes.push(terminalNode);
+ },
+
+ resetCounter: function () {
+ this.bucket.counter = 0;
+ },
+
+ incrementCounter: function () {
+ this.bucket.counter++;
+ },
+
+ assertFact: function (fact) {
+ var typeNodes = this.typeNodes, i = typeNodes.length - 1;
+ for (; i >= 0; i--) {
+ typeNodes[i].assert(fact);
+ }
+ },
+
+ retractFact: function (fact) {
+ var typeNodes = this.typeNodes, i = typeNodes.length - 1;
+ for (; i >= 0; i--) {
+ typeNodes[i].retract(fact);
+ }
+ },
+
+ modifyFact: function (fact) {
+ var typeNodes = this.typeNodes, i = typeNodes.length - 1;
+ for (; i >= 0; i--) {
+ typeNodes[i].modify(fact);
+ }
+ },
+
+
+ containsRule: function (name) {
+ return some(this.terminalNodes, function (n) {
+ return n.rule.name === name;
+ });
+ },
+
+ dispose: function () {
+ var typeNodes = this.typeNodes, i = typeNodes.length - 1;
+ for (; i >= 0; i--) {
+ typeNodes[i].dispose();
+ }
+ },
+
+ __mergeJoinNodes: function () {
+ var joinNodes = this.joinNodes;
+ for (var i = 0; i < joinNodes.length; i++) {
+ var j1 = joinNodes[i], j2 = joinNodes[i + 1];
+ if (j1 && j2 && (j1.constraint && j2.constraint && j1.constraint.equal(j2.constraint))) {
+ j1.merge(j2);
+ joinNodes.splice(i + 1, 1);
+ }
+ }
+ },
+
+ __checkEqual: function (node) {
+ var constraints = this.constraints, i = constraints.length - 1;
+ for (; i >= 0; i--) {
+ var n = constraints[i];
+ if (node.equal(n)) {
+ return n;
+ }
+ }
+ constraints.push(node);
+ return node;
+ },
+
+ __createTypeNode: function (rule, pattern) {
+ var ret = new TypeNode(pattern.get("constraints")[0]);
+ var constraints = this.typeNodes, i = constraints.length - 1;
+ for (; i >= 0; i--) {
+ var n = constraints[i];
+ if (ret.equal(n)) {
+ return n;
+ }
+ }
+ constraints.push(ret);
+ return ret;
+ },
+
+ __createEqualityNode: function (rule, constraint) {
+ return this.__checkEqual(new EqualityNode(constraint)).addRule(rule);
+ },
+
+ __createPropertyNode: function (rule, constraint) {
+ return this.__checkEqual(new PropertyNode(constraint)).addRule(rule);
+ },
+
+ __createAliasNode: function (rule, pattern) {
+ return this.__checkEqual(new AliasNode(pattern)).addRule(rule);
+ },
+
+ __createAdapterNode: function (rule, side) {
+ return (side === "left" ? new LeftAdapterNode() : new RightAdapterNode()).addRule(rule);
+ },
+
+ __createJoinNode: function (rule, pattern, outNode, side) {
+ var joinNode;
+ if (pattern.rightPattern instanceof NotPattern) {
+ joinNode = new NotNode();
+ } else if (pattern.rightPattern instanceof FromExistsPattern) {
+ joinNode = new ExistsFromNode(pattern.rightPattern, this.workingMemory);
+ } else if (pattern.rightPattern instanceof ExistsPattern) {
+ joinNode = new ExistsNode();
+ } else if (pattern.rightPattern instanceof FromNotPattern) {
+ joinNode = new FromNotNode(pattern.rightPattern, this.workingMemory);
+ } else if (pattern.rightPattern instanceof FromPattern) {
+ joinNode = new FromNode(pattern.rightPattern, this.workingMemory);
+ } else if (pattern instanceof CompositePattern && !hasRefernceConstraints(pattern.leftPattern) && !hasRefernceConstraints(pattern.rightPattern)) {
+ joinNode = new BetaNode();
+ this.joinNodes.push(joinNode);
+ } else {
+ joinNode = new JoinNode();
+ this.joinNodes.push(joinNode);
+ }
+ joinNode["__rule__"] = rule;
+ var parentNode = joinNode;
+ if (outNode instanceof BetaNode) {
+ var adapterNode = this.__createAdapterNode(rule, side);
+ parentNode.addOutNode(adapterNode, pattern);
+ parentNode = adapterNode;
+ }
+ parentNode.addOutNode(outNode, pattern);
+ return joinNode.addRule(rule);
+ },
+
+ __addToNetwork: function (rule, pattern, outNode, side) {
+ if (pattern instanceof ObjectPattern) {
+ if (!(pattern instanceof InitialFactPattern) && (!side || side === "left")) {
+ this.__createBetaNode(rule, new CompositePattern(new InitialFactPattern(), pattern), outNode, side);
+ } else {
+ this.__createAlphaNode(rule, pattern, outNode, side);
+ }
+ } else if (pattern instanceof CompositePattern) {
+ this.__createBetaNode(rule, pattern, outNode, side);
+ }
+ },
+
+ __createBetaNode: function (rule, pattern, outNode, side) {
+ var joinNode = this.__createJoinNode(rule, pattern, outNode, side);
+ this.__addToNetwork(rule, pattern.rightPattern, joinNode, "right");
+ this.__addToNetwork(rule, pattern.leftPattern, joinNode, "left");
+ outNode.addParentNode(joinNode);
+ return joinNode;
+ },
+
+
+ __createAlphaNode: function (rule, pattern, outNode, side) {
+ var typeNode, parentNode;
+ if (!(pattern instanceof FromPattern)) {
+
+ var constraints = pattern.get("constraints");
+ typeNode = this.__createTypeNode(rule, pattern);
+ var aliasNode = this.__createAliasNode(rule, pattern);
+ typeNode.addOutNode(aliasNode, pattern);
+ aliasNode.addParentNode(typeNode);
+ parentNode = aliasNode;
+ var i = constraints.length - 1;
+ for (; i > 0; i--) {
+ var constraint = constraints[i], node;
+ if (constraint instanceof HashConstraint) {
+ node = this.__createPropertyNode(rule, constraint);
+ } else if (constraint instanceof ReferenceConstraint) {
+ outNode.constraint.addConstraint(constraint);
+ continue;
+ } else {
+ node = this.__createEqualityNode(rule, constraint);
+ }
+ parentNode.addOutNode(node, pattern);
+ node.addParentNode(parentNode);
+ parentNode = node;
+ }
+
+ if (outNode instanceof BetaNode) {
+ var adapterNode = this.__createAdapterNode(rule, side);
+ adapterNode.addParentNode(parentNode);
+ parentNode.addOutNode(adapterNode, pattern);
+ parentNode = adapterNode;
+ }
+ outNode.addParentNode(parentNode);
+ parentNode.addOutNode(outNode, pattern);
+ return typeNode;
+ }
+ },
+
+ print: function () {
+ forEach(this.terminalNodes, function (t) {
+ t.print(" ");
+ });
+ }
+ }
+}).as(exports, "RootNode");
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinNode.js":
+/*!******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinNode.js ***!
+ \******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var BetaNode = __webpack_require__(/*! ./betaNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/betaNode.js"),
+ JoinReferenceNode = __webpack_require__(/*! ./joinReferenceNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinReferenceNode.js");
+
+BetaNode.extend({
+
+ instance: {
+ constructor: function () {
+ this._super(arguments);
+ this.constraint = new JoinReferenceNode(this.leftTuples, this.rightTuples);
+ },
+
+ nodeType: "JoinNode",
+
+ propagateFromLeft: function (context, rm) {
+ var mr;
+ if ((mr = this.constraint.match(context, rm)).isMatch) {
+ this.__propagate("assert", this.__addToMemoryMatches(rm, context, context.clone(null, null, mr)));
+ }
+ return this;
+ },
+
+ propagateFromRight: function (context, lm) {
+ var mr;
+ if ((mr = this.constraint.match(lm, context)).isMatch) {
+ this.__propagate("assert", this.__addToMemoryMatches(context, lm, context.clone(null, null, mr)));
+ }
+ return this;
+ },
+
+ propagateAssertModifyFromLeft: function (context, rightMatches, rm) {
+ var factId = rm.hashCode, mr;
+ if (factId in rightMatches) {
+ mr = this.constraint.match(context, rm);
+ var mrIsMatch = mr.isMatch;
+ if (!mrIsMatch) {
+ this.__propagate("retract", rightMatches[factId].clone());
+ } else {
+ this.__propagate("modify", this.__addToMemoryMatches(rm, context, context.clone(null, null, mr)));
+ }
+ } else {
+ this.propagateFromLeft(context, rm);
+ }
+ },
+
+ propagateAssertModifyFromRight: function (context, leftMatches, lm) {
+ var factId = lm.hashCode, mr;
+ if (factId in leftMatches) {
+ mr = this.constraint.match(lm, context);
+ var mrIsMatch = mr.isMatch;
+ if (!mrIsMatch) {
+ this.__propagate("retract", leftMatches[factId].clone());
+ } else {
+ this.__propagate("modify", this.__addToMemoryMatches(context, lm, context.clone(null, null, mr)));
+ }
+ } else {
+ this.propagateFromRight(context, lm);
+ }
+ }
+ }
+
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinReferenceNode.js":
+/*!***************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinReferenceNode.js ***!
+ \***************************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var Node = __webpack_require__(/*! ./node */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/node.js"),
+ constraints = __webpack_require__(/*! ../constraint */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraint.js"),
+ ReferenceEqualityConstraint = constraints.ReferenceEqualityConstraint;
+
+var DEFUALT_CONSTRAINT = {
+ isDefault: true,
+ assert: function () {
+ return true;
+ },
+
+ equal: function () {
+ return false;
+ }
+};
+
+var inversions = {
+ "gt": "lte",
+ "gte": "lte",
+ "lt": "gte",
+ "lte": "gte",
+ "eq": "eq",
+ "neq": "neq"
+};
+
+function normalizeRightIndexConstraint(rightIndex, indexes, op) {
+ if (rightIndex === indexes[1]) {
+ op = inversions[op];
+ }
+ return op;
+}
+
+function normalizeLeftIndexConstraint(leftIndex, indexes, op) {
+ if (leftIndex === indexes[1]) {
+ op = inversions[op];
+ }
+ return op;
+}
+
+Node.extend({
+
+ instance: {
+
+ constraint: DEFUALT_CONSTRAINT,
+
+ constructor: function (leftMemory, rightMemory) {
+ this._super(arguments);
+ this.constraint = DEFUALT_CONSTRAINT;
+ this.constraintAssert = DEFUALT_CONSTRAINT.assert;
+ this.rightIndexes = [];
+ this.leftIndexes = [];
+ this.constraintLength = 0;
+ this.leftMemory = leftMemory;
+ this.rightMemory = rightMemory;
+ },
+
+ addConstraint: function (constraint) {
+ if (constraint instanceof ReferenceEqualityConstraint) {
+ var identifiers = constraint.getIndexableProperties();
+ var alias = constraint.get("alias");
+ if (identifiers.length === 2 && alias) {
+ var leftIndex, rightIndex, i = -1, indexes = [];
+ while (++i < 2) {
+ var index = identifiers[i];
+ if (index.match(new RegExp("^" + alias + "(\\.?)")) === null) {
+ indexes.push(index);
+ leftIndex = index;
+ } else {
+ indexes.push(index);
+ rightIndex = index;
+ }
+ }
+ if (leftIndex && rightIndex) {
+ var leftOp = normalizeLeftIndexConstraint(leftIndex, indexes, constraint.op),
+ rightOp = normalizeRightIndexConstraint(rightIndex, indexes, constraint.op);
+ this.rightMemory.addIndex(rightIndex, leftIndex, rightOp);
+ this.leftMemory.addIndex(leftIndex, rightIndex, leftOp);
+ }
+ }
+ }
+ if (this.constraint.isDefault) {
+ this.constraint = constraint;
+ this.isDefault = false;
+ } else {
+ this.constraint = this.constraint.merge(constraint);
+ }
+ this.constraintAssert = this.constraint.assert;
+
+ },
+
+ equal: function (constraint) {
+ return this.constraint.equal(constraint.constraint);
+ },
+
+ isMatch: function (lc, rc) {
+ return this.constraintAssert(lc.factHash, rc.factHash);
+ },
+
+ match: function (lc, rc) {
+ var ret = {isMatch: false};
+ if (this.constraintAssert(lc.factHash, rc.factHash)) {
+ ret = lc.match.merge(rc.match);
+ }
+ return ret;
+ }
+
+ }
+
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/leftAdapterNode.js":
+/*!*************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/leftAdapterNode.js ***!
+ \*************************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var Node = __webpack_require__(/*! ./adapterNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/adapterNode.js");
+
+Node.extend({
+ instance: {
+ propagateAssert: function (context) {
+ this.__propagate("assertLeft", context);
+ },
+
+ propagateRetract: function (context) {
+ this.__propagate("retractLeft", context);
+ },
+
+ propagateResolve: function (context) {
+ this.__propagate("retractResolve", context);
+ },
+
+ propagateModify: function (context) {
+ this.__propagate("modifyLeft", context);
+ },
+
+ retractResolve: function (match) {
+ this.__propagate("retractResolve", match);
+ },
+
+ dispose: function (context) {
+ this.propagateDispose(context);
+ },
+
+ toString: function () {
+ return "LeftAdapterNode " + this.__count;
+ }
+ }
+
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/helpers.js":
+/*!**********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/helpers.js ***!
+ \**********************************************************************************************************/
+/***/ ((__unused_webpack_module, exports) => {
+
+exports.getMemory = (function () {
+
+ var pPush = Array.prototype.push, NPL = 0, EMPTY_ARRAY = [], NOT_POSSIBLES_HASH = {}, POSSIBLES_HASH = {}, PL = 0;
+
+ function mergePossibleTuples(ret, a, l) {
+ var val, j = 0, i = -1;
+ if (PL < l) {
+ while (PL && ++i < l) {
+ if (POSSIBLES_HASH[(val = a[i]).hashCode]) {
+ ret[j++] = val;
+ PL--;
+ }
+ }
+ } else {
+ pPush.apply(ret, a);
+ }
+ PL = 0;
+ POSSIBLES_HASH = {};
+ }
+
+
+ function mergeNotPossibleTuples(ret, a, l) {
+ var val, j = 0, i = -1;
+ if (NPL < l) {
+ while (++i < l) {
+ if (!NPL) {
+ ret[j++] = a[i];
+ } else if (!NOT_POSSIBLES_HASH[(val = a[i]).hashCode]) {
+ ret[j++] = val;
+ } else {
+ NPL--;
+ }
+ }
+ }
+ NPL = 0;
+ NOT_POSSIBLES_HASH = {};
+ }
+
+ function mergeBothTuples(ret, a, l) {
+ if (PL === l) {
+ mergeNotPossibles(ret, a, l);
+ } else if (NPL < l) {
+ var val, j = 0, i = -1, hashCode;
+ while (++i < l) {
+ if (!NOT_POSSIBLES_HASH[(hashCode = (val = a[i]).hashCode)] && POSSIBLES_HASH[hashCode]) {
+ ret[j++] = val;
+ }
+ }
+ }
+ NPL = 0;
+ NOT_POSSIBLES_HASH = {};
+ PL = 0;
+ POSSIBLES_HASH = {};
+ }
+
+ function mergePossiblesAndNotPossibles(a, l) {
+ var ret = EMPTY_ARRAY;
+ if (l) {
+ if (NPL || PL) {
+ ret = [];
+ if (!NPL) {
+ mergePossibleTuples(ret, a, l);
+ } else if (!PL) {
+ mergeNotPossibleTuples(ret, a, l);
+ } else {
+ mergeBothTuples(ret, a, l);
+ }
+ } else {
+ ret = a;
+ }
+ }
+ return ret;
+ }
+
+ function getRangeTuples(op, currEntry, val) {
+ var ret;
+ if (op === "gt") {
+ ret = currEntry.findGT(val);
+ } else if (op === "gte") {
+ ret = currEntry.findGTE(val);
+ } else if (op === "lt") {
+ ret = currEntry.findLT(val);
+ } else if (op === "lte") {
+ ret = currEntry.findLTE(val);
+ }
+ return ret;
+ }
+
+ function mergeNotPossibles(tuples, tl) {
+ if (tl) {
+ var j = -1, hashCode;
+ while (++j < tl) {
+ hashCode = tuples[j].hashCode;
+ if (!NOT_POSSIBLES_HASH[hashCode]) {
+ NOT_POSSIBLES_HASH[hashCode] = true;
+ NPL++;
+ }
+ }
+ }
+ }
+
+ function mergePossibles(tuples, tl) {
+ if (tl) {
+ var j = -1, hashCode;
+ while (++j < tl) {
+ hashCode = tuples[j].hashCode;
+ if (!POSSIBLES_HASH[hashCode]) {
+ POSSIBLES_HASH[hashCode] = true;
+ PL++;
+ }
+ }
+ }
+ }
+
+ return function _getMemory(entry, factHash, indexes) {
+ var i = -1, l = indexes.length,
+ ret = entry.tuples,
+ rl = ret.length,
+ intersected = false,
+ tables = entry.tables,
+ index, val, op, nextEntry, currEntry, tuples, tl;
+ while (++i < l && rl) {
+ index = indexes[i];
+ val = index[3](factHash);
+ op = index[4];
+ currEntry = tables[index[0]];
+ if (op === "eq" || op === "seq") {
+ if ((nextEntry = currEntry.get(val))) {
+ rl = (ret = (entry = nextEntry).tuples).length;
+ tables = nextEntry.tables;
+ } else {
+ rl = (ret = EMPTY_ARRAY).length;
+ }
+ } else if (op === "neq" || op === "sneq") {
+ if ((nextEntry = currEntry.get(val))) {
+ tl = (tuples = nextEntry.tuples).length;
+ mergeNotPossibles(tuples, tl);
+ }
+ } else if (!intersected) {
+ rl = (ret = getRangeTuples(op, currEntry, val)).length;
+ intersected = true;
+ } else if ((tl = (tuples = getRangeTuples(op, currEntry, val)).length)) {
+ mergePossibles(tuples, tl);
+ } else {
+ ret = tuples;
+ rl = tl;
+ }
+ }
+ return mergePossiblesAndNotPossibles(ret, rl);
+ };
+}());
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/leftMemory.js":
+/*!*************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/leftMemory.js ***!
+ \*************************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var Memory = __webpack_require__(/*! ./memory */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/memory.js");
+
+Memory.extend({
+
+ instance: {
+
+ getLeftMemory: function (tuple) {
+ return this.getMemory(tuple);
+ }
+ }
+
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/memory.js":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/memory.js ***!
+ \*********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var extd = __webpack_require__(/*! ../../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ plucker = extd.plucker,
+ declare = extd.declare,
+ getMemory = __webpack_require__(/*! ./helpers */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/helpers.js").getMemory,
+ Table = __webpack_require__(/*! ./table */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/table.js"),
+ TupleEntry = __webpack_require__(/*! ./tupleEntry */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/tupleEntry.js");
+
+
+var id = 0;
+declare({
+
+ instance: {
+ length: 0,
+
+ constructor: function () {
+ this.head = null;
+ this.tail = null;
+ this.indexes = [];
+ this.tables = new TupleEntry(null, new Table(), false);
+ },
+
+ push: function (data) {
+ var tail = this.tail, head = this.head, node = {data: data, tuples: [], hashCode: id++, prev: tail, next: null};
+ if (tail) {
+ this.tail.next = node;
+ }
+ this.tail = node;
+ if (!head) {
+ this.head = node;
+ }
+ this.length++;
+ this.__index(node);
+ this.tables.addNode(node);
+ return node;
+ },
+
+ remove: function (node) {
+ if (node.prev) {
+ node.prev.next = node.next;
+ } else {
+ this.head = node.next;
+ }
+ if (node.next) {
+ node.next.prev = node.prev;
+ } else {
+ this.tail = node.prev;
+ }
+ this.tables.removeNode(node);
+ this.__removeFromIndex(node);
+ this.length--;
+ },
+
+ forEach: function (cb) {
+ var head = {next: this.head};
+ while ((head = head.next)) {
+ cb(head.data);
+ }
+ },
+
+ toArray: function () {
+ return this.tables.tuples.slice();
+ },
+
+ clear: function () {
+ this.head = this.tail = null;
+ this.length = 0;
+ this.clearIndexes();
+ },
+
+ clearIndexes: function () {
+ this.tables = {};
+ this.indexes.length = 0;
+ },
+
+ __index: function (node) {
+ var data = node.data,
+ factHash = data.factHash,
+ indexes = this.indexes,
+ entry = this.tables,
+ i = -1, l = indexes.length,
+ tuples, index, val, path, tables, currEntry, prevLookup;
+ while (++i < l) {
+ index = indexes[i];
+ val = index[2](factHash);
+ path = index[0];
+ tables = entry.tables;
+ if (!(tuples = (currEntry = tables[path] || (tables[path] = new Table())).get(val))) {
+ tuples = new TupleEntry(val, currEntry, true);
+ currEntry.set(val, tuples);
+ }
+ if (currEntry !== prevLookup) {
+ node.tuples.push(tuples.addNode(node));
+ }
+ prevLookup = currEntry;
+ if (index[4] === "eq") {
+ entry = tuples;
+ }
+ }
+ },
+
+ __removeFromIndex: function (node) {
+ var tuples = node.tuples, i = tuples.length;
+ while (--i >= 0) {
+ tuples[i].removeNode(node);
+ }
+ node.tuples.length = 0;
+ },
+
+ getMemory: function (tuple) {
+ var ret;
+ if (!this.length) {
+ ret = [];
+ } else {
+ ret = getMemory(this.tables, tuple.factHash, this.indexes);
+ }
+ return ret;
+ },
+
+ __createIndexTree: function () {
+ var table = this.tables.tables = {};
+ var indexes = this.indexes;
+ table[indexes[0][0]] = new Table();
+ },
+
+
+ addIndex: function (primary, lookup, op) {
+ this.indexes.push([primary, lookup, plucker(primary), plucker(lookup), op || "eq"]);
+ this.indexes.sort(function (a, b) {
+ var aOp = a[4], bOp = b[4];
+ return aOp === bOp ? 0 : aOp > bOp ? 1 : aOp === bOp ? 0 : -1;
+ });
+ this.__createIndexTree();
+
+ }
+
+ }
+
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/rightMemory.js":
+/*!**************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/rightMemory.js ***!
+ \**************************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var Memory = __webpack_require__(/*! ./memory */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/memory.js");
+
+Memory.extend({
+
+ instance: {
+
+ getRightMemory: function (tuple) {
+ return this.getMemory(tuple);
+ }
+ }
+
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/table.js":
+/*!********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/table.js ***!
+ \********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var extd = __webpack_require__(/*! ../../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ pPush = Array.prototype.push,
+ HashTable = extd.HashTable,
+ AVLTree = extd.AVLTree;
+
+function compare(a, b) {
+ /*jshint eqeqeq: false*/
+ a = a.key;
+ b = b.key;
+ var ret;
+ if (a == b) {
+ ret = 0;
+ } else if (a > b) {
+ ret = 1;
+ } else if (a < b) {
+ ret = -1;
+ } else {
+ ret = 1;
+ }
+ return ret;
+}
+
+function compareGT(v1, v2) {
+ return compare(v1, v2) === 1;
+}
+function compareGTE(v1, v2) {
+ return compare(v1, v2) !== -1;
+}
+
+function compareLT(v1, v2) {
+ return compare(v1, v2) === -1;
+}
+function compareLTE(v1, v2) {
+ return compare(v1, v2) !== 1;
+}
+
+var STACK = [],
+ VALUE = {key: null};
+function traverseInOrder(tree, key, comparator) {
+ VALUE.key = key;
+ var ret = [];
+ var i = 0, current = tree.__root, v;
+ while (true) {
+ if (current) {
+ current = (STACK[i++] = current).left;
+ } else {
+ if (i > 0) {
+ v = (current = STACK[--i]).data;
+ if (comparator(v, VALUE)) {
+ pPush.apply(ret, v.value.tuples);
+ current = current.right;
+ } else {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ }
+ STACK.length = 0;
+ return ret;
+}
+
+function traverseReverseOrder(tree, key, comparator) {
+ VALUE.key = key;
+ var ret = [];
+ var i = 0, current = tree.__root, v;
+ while (true) {
+ if (current) {
+ current = (STACK[i++] = current).right;
+ } else {
+ if (i > 0) {
+ v = (current = STACK[--i]).data;
+ if (comparator(v, VALUE)) {
+ pPush.apply(ret, v.value.tuples);
+ current = current.left;
+ } else {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ }
+ STACK.length = 0;
+ return ret;
+}
+
+AVLTree.extend({
+ instance: {
+
+ constructor: function () {
+ this._super([
+ {
+ compare: compare
+ }
+ ]);
+ this.gtCache = new HashTable();
+ this.gteCache = new HashTable();
+ this.ltCache = new HashTable();
+ this.lteCache = new HashTable();
+ this.hasGTCache = false;
+ this.hasGTECache = false;
+ this.hasLTCache = false;
+ this.hasLTECache = false;
+ },
+
+ clearCache: function () {
+ this.hasGTCache && this.gtCache.clear() && (this.hasGTCache = false);
+ this.hasGTECache && this.gteCache.clear() && (this.hasGTECache = false);
+ this.hasLTCache && this.ltCache.clear() && (this.hasLTCache = false);
+ this.hasLTECache && this.lteCache.clear() && (this.hasLTECache = false);
+ },
+
+ contains: function (key) {
+ return this._super([
+ {key: key}
+ ]);
+ },
+
+ "set": function (key, value) {
+ this.insert({key: key, value: value});
+ this.clearCache();
+ },
+
+ "get": function (key) {
+ var ret = this.find({key: key});
+ return ret && ret.value;
+ },
+
+ "remove": function (key) {
+ this.clearCache();
+ return this._super([
+ {key: key}
+ ]);
+ },
+
+ findGT: function (key) {
+ var ret = this.gtCache.get(key);
+ if (!ret) {
+ this.hasGTCache = true;
+ this.gtCache.put(key, (ret = traverseReverseOrder(this, key, compareGT)));
+ }
+ return ret;
+ },
+
+ findGTE: function (key) {
+ var ret = this.gteCache.get(key);
+ if (!ret) {
+ this.hasGTECache = true;
+ this.gteCache.put(key, (ret = traverseReverseOrder(this, key, compareGTE)));
+ }
+ return ret;
+ },
+
+ findLT: function (key) {
+ var ret = this.ltCache.get(key);
+ if (!ret) {
+ this.hasLTCache = true;
+ this.ltCache.put(key, (ret = traverseInOrder(this, key, compareLT)));
+ }
+ return ret;
+ },
+
+ findLTE: function (key) {
+ var ret = this.lteCache.get(key);
+ if (!ret) {
+ this.hasLTECache = true;
+ this.lteCache.put(key, (ret = traverseInOrder(this, key, compareLTE)));
+ }
+ return ret;
+ }
+
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/tupleEntry.js":
+/*!*************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/misc/tupleEntry.js ***!
+ \*************************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var extd = __webpack_require__(/*! ../../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ indexOf = extd.indexOf;
+// HashSet = require("./hashSet");
+
+
+var TUPLE_ID = 0;
+extd.declare({
+
+ instance: {
+ tuples: null,
+ tupleMap: null,
+ hashCode: null,
+ tables: null,
+ entry: null,
+ constructor: function (val, entry, canRemove) {
+ this.val = val;
+ this.canRemove = canRemove;
+ this.tuples = [];
+ this.tupleMap = {};
+ this.hashCode = TUPLE_ID++;
+ this.tables = {};
+ this.length = 0;
+ this.entry = entry;
+ },
+
+ addNode: function (node) {
+ this.tuples[this.length++] = node;
+ if (this.length > 1) {
+ this.entry.clearCache();
+ }
+ return this;
+ },
+
+ removeNode: function (node) {
+ var tuples = this.tuples, index = indexOf(tuples, node);
+ if (index !== -1) {
+ tuples.splice(index, 1);
+ this.length--;
+ this.entry.clearCache();
+ }
+ if (this.canRemove && !this.length) {
+ this.entry.remove(this.val);
+ }
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/node.js":
+/*!**************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/node.js ***!
+ \**************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ forEach = extd.forEach,
+ indexOf = extd.indexOf,
+ intersection = extd.intersection,
+ declare = extd.declare,
+ HashTable = extd.HashTable,
+ Context = __webpack_require__(/*! ../context */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js");
+
+var count = 0;
+declare({
+ instance: {
+ constructor: function () {
+ this.nodes = new HashTable();
+ this.rules = [];
+ this.parentNodes = [];
+ this.__count = count++;
+ this.__entrySet = [];
+ },
+
+ addRule: function (rule) {
+ if (indexOf(this.rules, rule) === -1) {
+ this.rules.push(rule);
+ }
+ return this;
+ },
+
+ merge: function (that) {
+ that.nodes.forEach(function (entry) {
+ var patterns = entry.value, node = entry.key;
+ for (var i = 0, l = patterns.length; i < l; i++) {
+ this.addOutNode(node, patterns[i]);
+ }
+ that.nodes.remove(node);
+ }, this);
+ var thatParentNodes = that.parentNodes;
+ for (var i = 0, l = that.parentNodes.l; i < l; i++) {
+ var parentNode = thatParentNodes[i];
+ this.addParentNode(parentNode);
+ parentNode.nodes.remove(that);
+ }
+ return this;
+ },
+
+ resolve: function (mr1, mr2) {
+ return mr1.hashCode === mr2.hashCode;
+ },
+
+ print: function (tab) {
+ console.log(tab + this.toString());
+ forEach(this.parentNodes, function (n) {
+ n.print(" " + tab);
+ });
+ },
+
+ addOutNode: function (outNode, pattern) {
+ if (!this.nodes.contains(outNode)) {
+ this.nodes.put(outNode, []);
+ }
+ this.nodes.get(outNode).push(pattern);
+ this.__entrySet = this.nodes.entrySet();
+ },
+
+ addParentNode: function (n) {
+ if (indexOf(this.parentNodes, n) === -1) {
+ this.parentNodes.push(n);
+ }
+ },
+
+ shareable: function () {
+ return false;
+ },
+
+ __propagate: function (method, context) {
+ var entrySet = this.__entrySet, i = entrySet.length, entry, outNode, paths, continuingPaths;
+ while (--i > -1) {
+ entry = entrySet[i];
+ outNode = entry.key;
+ paths = entry.value;
+
+ if ((continuingPaths = intersection(paths, context.paths)).length) {
+ outNode[method](new Context(context.fact, continuingPaths, context.match));
+ }
+
+ }
+ },
+
+ dispose: function (assertable) {
+ this.propagateDispose(assertable);
+ },
+
+ retract: function (assertable) {
+ this.propagateRetract(assertable);
+ },
+
+ propagateDispose: function (assertable, outNodes) {
+ outNodes = outNodes || this.nodes;
+ var entrySet = this.__entrySet, i = entrySet.length - 1;
+ for (; i >= 0; i--) {
+ var entry = entrySet[i], outNode = entry.key;
+ outNode.dispose(assertable);
+ }
+ },
+
+ propagateAssert: function (assertable) {
+ this.__propagate("assert", assertable);
+ },
+
+ propagateRetract: function (assertable) {
+ this.__propagate("retract", assertable);
+ },
+
+ assert: function (assertable) {
+ this.propagateAssert(assertable);
+ },
+
+ modify: function (assertable) {
+ this.propagateModify(assertable);
+ },
+
+ propagateModify: function (assertable) {
+ this.__propagate("modify", assertable);
+ }
+ }
+
+}).as(module);
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/notNode.js":
+/*!*****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/notNode.js ***!
+ \*****************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var JoinNode = __webpack_require__(/*! ./joinNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/joinNode.js"),
+ LinkedList = __webpack_require__(/*! ../linkedList */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/linkedList.js"),
+ Context = __webpack_require__(/*! ../context */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js"),
+ InitialFact = __webpack_require__(/*! ../pattern */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/pattern.js").InitialFact;
+
+
+JoinNode.extend({
+ instance: {
+
+ nodeType: "NotNode",
+
+ constructor: function () {
+ this._super(arguments);
+ this.leftTupleMemory = {};
+ //use this ensure a unique match for and propagated context.
+ this.notMatch = new Context(new InitialFact()).match;
+ },
+
+ __cloneContext: function (context) {
+ return context.clone(null, null, context.match.merge(this.notMatch));
+ },
+
+
+ retractRight: function (context) {
+ var ctx = this.removeFromRightMemory(context),
+ rightContext = ctx.data,
+ blocking = rightContext.blocking;
+ if (blocking.length) {
+ //if we are blocking left contexts
+ var leftContext, thisConstraint = this.constraint, blockingNode = {next: blocking.head}, rc;
+ while ((blockingNode = blockingNode.next)) {
+ leftContext = blockingNode.data;
+ this.removeFromLeftBlockedMemory(leftContext);
+ var rm = this.rightTuples.getRightMemory(leftContext), l = rm.length, i;
+ i = -1;
+ while (++i < l) {
+ if (thisConstraint.isMatch(leftContext, rc = rm[i].data)) {
+ this.blockedContext(leftContext, rc);
+ leftContext = null;
+ break;
+ }
+ }
+ if (leftContext) {
+ this.notBlockedContext(leftContext, true);
+ }
+ }
+ blocking.clear();
+ }
+
+ },
+
+ blockedContext: function (leftContext, rightContext, propagate) {
+ leftContext.blocker = rightContext;
+ this.removeFromLeftMemory(leftContext);
+ this.addToLeftBlockedMemory(rightContext.blocking.push(leftContext));
+ propagate && this.__propagate("retract", this.__cloneContext(leftContext));
+ },
+
+ notBlockedContext: function (leftContext, propagate) {
+ this.__addToLeftMemory(leftContext);
+ propagate && this.__propagate("assert", this.__cloneContext(leftContext));
+ },
+
+ propagateFromLeft: function (leftContext) {
+ this.notBlockedContext(leftContext, true);
+ },
+
+ propagateFromRight: function (leftContext) {
+ this.notBlockedContext(leftContext, true);
+ },
+
+ blockFromAssertRight: function (leftContext, rightContext) {
+ this.blockedContext(leftContext, rightContext, true);
+ },
+
+ blockFromAssertLeft: function (leftContext, rightContext) {
+ this.blockedContext(leftContext, rightContext, false);
+ },
+
+
+ retractLeft: function (context) {
+ var ctx = this.removeFromLeftMemory(context);
+ if (ctx) {
+ ctx = ctx.data;
+ this.__propagate("retract", this.__cloneContext(ctx));
+ } else {
+ if (!this.removeFromLeftBlockedMemory(context)) {
+ throw new Error();
+ }
+ }
+ },
+
+ assertLeft: function (context) {
+ var values = this.rightTuples.getRightMemory(context),
+ thisConstraint = this.constraint, rc, i = -1, l = values.length;
+ while (++i < l) {
+ if (thisConstraint.isMatch(context, rc = values[i].data)) {
+ this.blockFromAssertLeft(context, rc);
+ context = null;
+ i = l;
+ }
+ }
+ if (context) {
+ this.propagateFromLeft(context);
+ }
+ },
+
+ assertRight: function (context) {
+ this.__addToRightMemory(context);
+ context.blocking = new LinkedList();
+ var fl = this.leftTuples.getLeftMemory(context).slice(),
+ i = -1, l = fl.length,
+ leftContext, thisConstraint = this.constraint;
+ while (++i < l) {
+ leftContext = fl[i].data;
+ if (thisConstraint.isMatch(leftContext, context)) {
+ this.blockFromAssertRight(leftContext, context);
+ }
+ }
+ },
+
+ addToLeftBlockedMemory: function (context) {
+ var data = context.data, hashCode = data.hashCode;
+ var ctx = this.leftMemory[hashCode];
+ this.leftTupleMemory[hashCode] = context;
+ if (ctx) {
+ this.leftTuples.remove(ctx);
+ }
+ return this;
+ },
+
+ removeFromLeftBlockedMemory: function (context) {
+ var ret = this.leftTupleMemory[context.hashCode] || null;
+ if (ret) {
+ delete this.leftTupleMemory[context.hashCode];
+ ret.data.blocker.blocking.remove(ret);
+ }
+ return ret;
+ },
+
+ modifyLeft: function (context) {
+ var ctx = this.removeFromLeftMemory(context),
+ leftContext,
+ thisConstraint = this.constraint,
+ rightTuples = this.rightTuples.getRightMemory(context),
+ l = rightTuples.length,
+ isBlocked = false,
+ i, rc, blocker;
+ if (!ctx) {
+ //blocked before
+ ctx = this.removeFromLeftBlockedMemory(context);
+ isBlocked = true;
+ }
+ if (ctx) {
+ leftContext = ctx.data;
+
+ if (leftContext && leftContext.blocker) {
+ //we were blocked before so only check nodes previous to our blocker
+ blocker = this.rightMemory[leftContext.blocker.hashCode];
+ leftContext.blocker = null;
+ }
+ if (blocker) {
+ if (thisConstraint.isMatch(context, rc = blocker.data)) {
+ //we cant be proagated so retract previous
+ if (!isBlocked) {
+ //we were asserted before so retract
+ this.__propagate("retract", this.__cloneContext(leftContext));
+ }
+ context.blocker = rc;
+ this.addToLeftBlockedMemory(rc.blocking.push(context));
+ context = null;
+ }
+ }
+ if (context && l) {
+ i = -1;
+ //we were propogated before
+ while (++i < l) {
+ if (thisConstraint.isMatch(context, rc = rightTuples[i].data)) {
+ //we cant be proagated so retract previous
+ if (!isBlocked) {
+ //we were asserted before so retract
+ this.__propagate("retract", this.__cloneContext(leftContext));
+ }
+ this.addToLeftBlockedMemory(rc.blocking.push(context));
+ context.blocker = rc;
+ context = null;
+ break;
+ }
+ }
+ }
+ if (context) {
+ //we can still be propogated
+ this.__addToLeftMemory(context);
+ if (!isBlocked) {
+ //we weren't blocked before so modify
+ this.__propagate("modify", this.__cloneContext(context));
+ } else {
+ //we were blocked before but aren't now
+ this.__propagate("assert", this.__cloneContext(context));
+ }
+
+ }
+ } else {
+ throw new Error();
+ }
+
+ },
+
+ modifyRight: function (context) {
+ var ctx = this.removeFromRightMemory(context);
+ if (ctx) {
+ var rightContext = ctx.data,
+ leftTuples = this.leftTuples.getLeftMemory(context).slice(),
+ leftTuplesLength = leftTuples.length,
+ leftContext,
+ thisConstraint = this.constraint,
+ i, node,
+ blocking = rightContext.blocking;
+ this.__addToRightMemory(context);
+ context.blocking = new LinkedList();
+
+ var rc;
+ //check old blocked contexts
+ //check if the same contexts blocked before are still blocked
+ var blockingNode = {next: blocking.head};
+ while ((blockingNode = blockingNode.next)) {
+ leftContext = blockingNode.data;
+ leftContext.blocker = null;
+ if (thisConstraint.isMatch(leftContext, context)) {
+ leftContext.blocker = context;
+ this.addToLeftBlockedMemory(context.blocking.push(leftContext));
+ leftContext = null;
+ } else {
+ //we arent blocked anymore
+ leftContext.blocker = null;
+ node = ctx;
+ while ((node = node.next)) {
+ if (thisConstraint.isMatch(leftContext, rc = node.data)) {
+ leftContext.blocker = rc;
+ this.addToLeftBlockedMemory(rc.blocking.push(leftContext));
+ leftContext = null;
+ break;
+ }
+ }
+ if (leftContext) {
+ this.__addToLeftMemory(leftContext);
+ this.__propagate("assert", this.__cloneContext(leftContext));
+ }
+ }
+ }
+ if (leftTuplesLength) {
+ //check currently left tuples in memory
+ i = -1;
+ while (++i < leftTuplesLength) {
+ leftContext = leftTuples[i].data;
+ if (thisConstraint.isMatch(leftContext, context)) {
+ this.__propagate("retract", this.__cloneContext(leftContext));
+ this.removeFromLeftMemory(leftContext);
+ this.addToLeftBlockedMemory(context.blocking.push(leftContext));
+ leftContext.blocker = context;
+ }
+ }
+ }
+ } else {
+ throw new Error();
+ }
+
+
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/propertyNode.js":
+/*!**********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/propertyNode.js ***!
+ \**********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var AlphaNode = __webpack_require__(/*! ./alphaNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/alphaNode.js"),
+ Context = __webpack_require__(/*! ../context */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js"),
+ extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js");
+
+AlphaNode.extend({
+ instance: {
+
+ constructor: function () {
+ this._super(arguments);
+ this.alias = this.constraint.get("alias");
+ this.varLength = (this.variables = extd(this.constraint.get("variables")).toArray().value()).length;
+ },
+
+ assert: function (context) {
+ var c = new Context(context.fact, context.paths);
+ var variables = this.variables, o = context.fact.object, item;
+ c.set(this.alias, o);
+ for (var i = 0, l = this.varLength; i < l; i++) {
+ item = variables[i];
+ c.set(item[1], o[item[0]]);
+ }
+
+ this.__propagate("assert", c);
+
+ },
+
+ retract: function (context) {
+ this.__propagate("retract", new Context(context.fact, context.paths));
+ },
+
+ modify: function (context) {
+ var c = new Context(context.fact, context.paths);
+ var variables = this.variables, o = context.fact.object, item;
+ c.set(this.alias, o);
+ for (var i = 0, l = this.varLength; i < l; i++) {
+ item = variables[i];
+ c.set(item[1], o[item[0]]);
+ }
+ this.__propagate("modify", c);
+ },
+
+
+ toString: function () {
+ return "PropertyNode" + this.__count;
+ }
+ }
+}).as(module);
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/rightAdapterNode.js":
+/*!**************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/rightAdapterNode.js ***!
+ \**************************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var Node = __webpack_require__(/*! ./adapterNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/adapterNode.js");
+
+Node.extend({
+ instance: {
+
+ retractResolve: function (match) {
+ this.__propagate("retractResolve", match);
+ },
+
+ dispose: function (context) {
+ this.propagateDispose(context);
+ },
+
+ propagateAssert: function (context) {
+ this.__propagate("assertRight", context);
+ },
+
+ propagateRetract: function (context) {
+ this.__propagate("retractRight", context);
+ },
+
+ propagateResolve: function (context) {
+ this.__propagate("retractResolve", context);
+ },
+
+ propagateModify: function (context) {
+ this.__propagate("modifyRight", context);
+ },
+
+ toString: function () {
+ return "RightAdapterNode " + this.__count;
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/terminalNode.js":
+/*!**********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/terminalNode.js ***!
+ \**********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var Node = __webpack_require__(/*! ./node */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/node.js"),
+ extd = __webpack_require__(/*! ../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ bind = extd.bind;
+
+Node.extend({
+ instance: {
+ constructor: function (bucket, index, rule, agenda) {
+ this._super([]);
+ this.resolve = bind(this, this.resolve);
+ this.rule = rule;
+ this.index = index;
+ this.name = this.rule.name;
+ this.agenda = agenda;
+ this.bucket = bucket;
+ agenda.register(this);
+ },
+
+ __assertModify: function (context) {
+ var match = context.match;
+ if (match.isMatch) {
+ var rule = this.rule, bucket = this.bucket;
+ this.agenda.insert(this, {
+ rule: rule,
+ hashCode: context.hashCode,
+ index: this.index,
+ name: rule.name,
+ recency: bucket.recency++,
+ match: match,
+ counter: bucket.counter
+ });
+ }
+ },
+
+ assert: function (context) {
+ this.__assertModify(context);
+ },
+
+ modify: function (context) {
+ this.agenda.retract(this, context);
+ this.__assertModify(context);
+ },
+
+ retract: function (context) {
+ this.agenda.retract(this, context);
+ },
+
+ retractRight: function (context) {
+ this.agenda.retract(this, context);
+ },
+
+ retractLeft: function (context) {
+ this.agenda.retract(this, context);
+ },
+
+ assertLeft: function (context) {
+ this.__assertModify(context);
+ },
+
+ assertRight: function (context) {
+ this.__assertModify(context);
+ },
+
+ toString: function () {
+ return "TerminalNode " + this.rule.name;
+ }
+ }
+}).as(module);
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/typeNode.js":
+/*!******************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/typeNode.js ***!
+ \******************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+var AlphaNode = __webpack_require__(/*! ./alphaNode */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/nodes/alphaNode.js"),
+ Context = __webpack_require__(/*! ../context */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/context.js");
+
+AlphaNode.extend({
+ instance: {
+
+ assert: function (fact) {
+ if (this.constraintAssert(fact.object)) {
+ this.__propagate("assert", fact);
+ }
+ },
+
+ modify: function (fact) {
+ if (this.constraintAssert(fact.object)) {
+ this.__propagate("modify", fact);
+ }
+ },
+
+ retract: function (fact) {
+ if (this.constraintAssert(fact.object)) {
+ this.__propagate("retract", fact);
+ }
+ },
+
+ toString: function () {
+ return "TypeNode" + this.__count;
+ },
+
+ dispose: function () {
+ var es = this.__entrySet, i = es.length - 1;
+ for (; i >= 0; i--) {
+ var e = es[i], outNode = e.key, paths = e.value;
+ outNode.dispose({paths: paths});
+ }
+ },
+
+ __propagate: function (method, fact) {
+ var es = this.__entrySet, i = -1, l = es.length;
+ while (++i < l) {
+ var e = es[i], outNode = e.key, paths = e.value;
+ outNode[method](new Context(fact, paths));
+ }
+ }
+ }
+}).as(module);
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/constraint/parser.js":
+/*!****************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/constraint/parser.js ***!
+ \****************************************************************************************************************/
+/***/ ((module, exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
+/* parser generated by jison 0.4.17 */
+/*
+ Returns a Parser object of the following structure:
+
+ Parser: {
+ yy: {}
+ }
+
+ Parser.prototype: {
+ yy: {},
+ trace: function(),
+ symbols_: {associative list: name ==> number},
+ terminals_: {associative list: number ==> name},
+ productions_: [...],
+ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
+ table: [...],
+ defaultActions: {...},
+ parseError: function(str, hash),
+ parse: function(input),
+
+ lexer: {
+ EOF: 1,
+ parseError: function(str, hash),
+ setInput: function(input),
+ input: function(),
+ unput: function(str),
+ more: function(),
+ less: function(n),
+ pastInput: function(),
+ upcomingInput: function(),
+ showPosition: function(),
+ test_match: function(regex_match_array, rule_index),
+ next: function(),
+ lex: function(),
+ begin: function(condition),
+ popState: function(),
+ _currentRules: function(),
+ topState: function(),
+ pushState: function(condition),
+
+ options: {
+ ranges: boolean (optional: true ==> token location info will include a .range[] member)
+ flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
+ backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
+ },
+
+ performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
+ rules: [...],
+ conditions: {associative list: name ==> set},
+ }
+ }
+
+
+ token location info (@$, _$, etc.): {
+ first_line: n,
+ last_line: n,
+ first_column: n,
+ last_column: n,
+ range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
+ }
+
+
+ the parseError function receives a 'hash' object with these members for lexer and parser errors: {
+ text: (matched text)
+ token: (the produced terminal token, if any)
+ line: (yylineno)
+ }
+ while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
+ loc: (yylloc)
+ expected: (string describing the set of expected tokens)
+ recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
+ }
+*/
+var parser = (function(){
+var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,29],$V1=[1,30],$V2=[1,26],$V3=[1,24],$V4=[1,16],$V5=[1,18],$V6=[1,19],$V7=[1,20],$V8=[1,21],$V9=[1,22],$Va=[5,38,49],$Vb=[1,33],$Vc=[5,36,38,49],$Vd=[5,8,11,12,13,15,17,19,20,21,22,24,25,26,27,28,29,36,38,49],$Ve=[2,2],$Vf=[5,24,25,26,27,28,29,36,38,49],$Vg=[1,42],$Vh=[1,43],$Vi=[1,44],$Vj=[1,45],$Vk=[5,8,11,12,13,15,17,19,20,21,22,24,25,26,27,28,29,31,33,36,38,40,46,49],$Vl=[1,46],$Vm=[1,47],$Vn=[1,48],$Vo=[5,19,20,21,22,24,25,26,27,28,29,36,38,49],$Vp=[1,50],$Vq=[5,8,11,12,13,15,17,19,20,21,22,24,25,26,27,28,29,31,33,36,38,40,43,44,46,48,49],$Vr=[5,17,19,20,21,22,24,25,26,27,28,29,36,38,49],$Vs=[1,55],$Vt=[1,54],$Vu=[5,8,15,17,19,20,21,22,24,25,26,27,28,29,36,38,49],$Vv=[1,56],$Vw=[1,57],$Vx=[1,58],$Vy=[1,87],$Vz=[40,46,49];
+var parser = {trace: function trace() { },
+yy: {},
+symbols_: {"error":2,"expressions":3,"EXPRESSION":4,"EOF":5,"UNARY_EXPRESSION":6,"LITERAL_EXPRESSION":7,"-":8,"!":9,"MULTIPLICATIVE_EXPRESSION":10,"*":11,"/":12,"%":13,"ADDITIVE_EXPRESSION":14,"+":15,"EXPONENT_EXPRESSION":16,"^":17,"RELATIONAL_EXPRESSION":18,"<":19,">":20,"<=":21,">=":22,"EQUALITY_EXPRESSION":23,"==":24,"===":25,"!=":26,"!==":27,"=~":28,"!=~":29,"IN_EXPRESSION":30,"in":31,"ARRAY_EXPRESSION":32,"notIn":33,"OBJECT_EXPRESSION":34,"AND_EXPRESSION":35,"&&":36,"OR_EXPRESSION":37,"||":38,"ARGUMENT_LIST":39,",":40,"IDENTIFIER_EXPRESSION":41,"IDENTIFIER":42,".":43,"[":44,"STRING_EXPRESSION":45,"]":46,"NUMBER_EXPRESSION":47,"(":48,")":49,"STRING":50,"NUMBER":51,"REGEXP_EXPRESSION":52,"REGEXP":53,"BOOLEAN_EXPRESSION":54,"BOOLEAN":55,"NULL_EXPRESSION":56,"NULL":57,"$accept":0,"$end":1},
+terminals_: {2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"===",26:"!=",27:"!==",28:"=~",29:"!=~",31:"in",33:"notIn",36:"&&",38:"||",40:",",42:"IDENTIFIER",43:".",44:"[",46:"]",48:"(",49:")",50:"STRING",51:"NUMBER",53:"REGEXP",55:"BOOLEAN",57:"NULL"},
+productions_: [0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[30,1],[30,3],[30,3],[30,3],[30,3],[35,1],[35,3],[37,1],[37,3],[39,1],[39,3],[41,1],[34,1],[34,3],[34,4],[34,4],[34,4],[34,3],[34,4],[45,1],[47,1],[52,1],[54,1],[56,1],[32,2],[32,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],
+performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
+/* this == yyval */
+
+var $0 = $$.length - 1;
+switch (yystate) {
+case 1:
+return $$[$0-1];
+break;
+case 3:
+this.$ = [$$[$0], null, 'unary'];
+break;
+case 4:
+this.$ = [$$[$0], null, 'logicalNot'];
+break;
+case 6:
+this.$ = [$$[$0-2], $$[$0], 'mult'];
+break;
+case 7:
+this.$ = [$$[$0-2], $$[$0], 'div'];
+break;
+case 8:
+this.$ = [$$[$0-2], $$[$0], 'mod'];
+break;
+case 10:
+this.$ = [$$[$0-2], $$[$0], 'plus'];
+break;
+case 11:
+this.$ = [$$[$0-2], $$[$0], 'minus'];
+break;
+case 13:
+this.$ = [$$[$0-2], $$[$0], 'pow'];
+break;
+case 15:
+this.$ = [$$[$0-2], $$[$0], 'lt'];
+break;
+case 16:
+this.$ = [$$[$0-2], $$[$0], 'gt'];
+break;
+case 17:
+this.$ = [$$[$0-2], $$[$0], 'lte'];
+break;
+case 18:
+this.$ = [$$[$0-2], $$[$0], 'gte'];
+break;
+case 20:
+this.$ = [$$[$0-2], $$[$0], 'eq'];
+break;
+case 21:
+this.$ = [$$[$0-2], $$[$0], 'seq'];
+break;
+case 22:
+this.$ = [$$[$0-2], $$[$0], 'neq'];
+break;
+case 23:
+this.$ = [$$[$0-2], $$[$0], 'sneq'];
+break;
+case 24:
+this.$ = [$$[$0-2], $$[$0], 'like'];
+break;
+case 25:
+this.$ = [$$[$0-2], $$[$0], 'notLike'];
+break;
+case 27: case 29:
+this.$ = [$$[$0-2], $$[$0], 'in'];
+break;
+case 28: case 30:
+this.$ = [$$[$0-2], $$[$0], 'notIn'];
+break;
+case 32:
+this.$ = [$$[$0-2], $$[$0], 'and'];
+break;
+case 34:
+this.$ = [$$[$0-2], $$[$0], 'or'];
+break;
+case 36:
+this.$ = [$$[$0-2], $$[$0], 'arguments']
+break;
+case 37:
+this.$ = [String(yytext), null, 'identifier'];
+break;
+case 39:
+this.$ = [$$[$0-2],$$[$0], 'prop'];
+break;
+case 40: case 41: case 42:
+this.$ = [$$[$0-3],$$[$0-1], 'propLookup'];
+break;
+case 43:
+this.$ = [$$[$0-2], [null, null, 'arguments'], 'function']
+break;
+case 44:
+this.$ = [$$[$0-3], $$[$0-1], 'function']
+break;
+case 45:
+this.$ = [String(yytext.replace(/^['|"]|['|"]$/g, '')), null, 'string'];
+break;
+case 46:
+this.$ = [Number(yytext), null, 'number'];
+break;
+case 47:
+this.$ = [yytext, null, 'regexp'];
+break;
+case 48:
+this.$ = [yytext.replace(/^\s+/, '') == 'true', null, 'boolean'];
+break;
+case 49:
+this.$ = [null, null, 'null'];
+break;
+case 50:
+this.$ = [null, null, 'array'];
+break;
+case 51:
+this.$ = [$$[$0-1], null, 'array'];
+break;
+case 59:
+this.$ = [$$[$0-1], null, 'composite']
+break;
+}
+},
+table: [{3:1,4:2,6:28,7:7,8:$V0,9:$V1,10:27,14:25,16:17,18:8,23:6,30:5,32:15,34:14,35:4,37:3,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{1:[3]},{5:[1,31]},o([5,49],[2,60],{38:[1,32]}),o($Va,[2,33],{36:$Vb}),o($Vc,[2,31]),o($Vc,[2,26],{24:[1,34],25:[1,35],26:[1,36],27:[1,37],28:[1,38],29:[1,39]}),o($Vd,$Ve,{31:[1,40],33:[1,41]}),o($Vf,[2,19],{19:$Vg,20:$Vh,21:$Vi,22:$Vj}),o($Vk,[2,52]),o($Vk,[2,53]),o($Vk,[2,54]),o($Vk,[2,55]),o($Vk,[2,56]),o($Vk,[2,57],{43:$Vl,44:$Vm,48:$Vn}),o($Vk,[2,58]),{4:49,6:28,7:7,8:$V0,9:$V1,10:27,14:25,16:17,18:8,23:6,30:5,32:15,34:14,35:4,37:3,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},o($Vo,[2,14],{17:$Vp}),o($Vk,[2,45]),o($Vk,[2,46]),o($Vk,[2,47]),o($Vk,[2,48]),o($Vk,[2,49]),o($Vq,[2,38]),{7:53,32:15,34:14,39:52,41:23,42:$V2,44:$V3,45:9,46:[1,51],47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},o($Vr,[2,12],{8:$Vs,15:$Vt}),o($Vq,[2,37]),o($Vu,[2,9],{11:$Vv,12:$Vw,13:$Vx}),o($Vd,[2,5]),{6:59,7:60,8:$V0,9:$V1,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:61,7:60,8:$V0,9:$V1,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{1:[2,1]},{6:28,7:7,8:$V0,9:$V1,10:27,14:25,16:17,18:8,23:6,30:5,32:15,34:14,35:62,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:7,8:$V0,9:$V1,10:27,14:25,16:17,18:8,23:6,30:63,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:17,18:64,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:17,18:65,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:17,18:66,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:17,18:67,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:17,18:68,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:17,18:69,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{32:70,34:71,41:23,42:$V2,44:$V3},{32:72,34:73,41:23,42:$V2,44:$V3},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:74,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:75,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:76,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:27,14:25,16:77,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{41:78,42:$V2},{34:81,41:23,42:$V2,45:79,47:80,50:$V5,51:$V6},{7:53,32:15,34:14,39:83,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,49:[1,82],50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{49:[1,84]},{6:28,7:60,8:$V0,9:$V1,10:27,14:85,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},o($Vk,[2,50]),{40:$Vy,46:[1,86]},o($Vz,[2,35]),{6:28,7:60,8:$V0,9:$V1,10:88,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:28,7:60,8:$V0,9:$V1,10:89,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:90,7:60,8:$V0,9:$V1,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:91,7:60,8:$V0,9:$V1,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},{6:92,7:60,8:$V0,9:$V1,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},o($Vd,[2,3]),o($Vd,$Ve),o($Vd,[2,4]),o($Va,[2,34],{36:$Vb}),o($Vc,[2,32]),o($Vf,[2,20],{19:$Vg,20:$Vh,21:$Vi,22:$Vj}),o($Vf,[2,21],{19:$Vg,20:$Vh,21:$Vi,22:$Vj}),o($Vf,[2,22],{19:$Vg,20:$Vh,21:$Vi,22:$Vj}),o($Vf,[2,23],{19:$Vg,20:$Vh,21:$Vi,22:$Vj}),o($Vf,[2,24],{19:$Vg,20:$Vh,21:$Vi,22:$Vj}),o($Vf,[2,25],{19:$Vg,20:$Vh,21:$Vi,22:$Vj}),o($Vc,[2,27]),o($Vc,[2,29],{43:$Vl,44:$Vm,48:$Vn}),o($Vc,[2,28]),o($Vc,[2,30],{43:$Vl,44:$Vm,48:$Vn}),o($Vo,[2,15],{17:$Vp}),o($Vo,[2,16],{17:$Vp}),o($Vo,[2,17],{17:$Vp}),o($Vo,[2,18],{17:$Vp}),o($Vq,[2,39]),{46:[1,93]},{46:[1,94]},{43:$Vl,44:$Vm,46:[1,95],48:$Vn},o($Vq,[2,43]),{40:$Vy,49:[1,96]},o($Vk,[2,59]),o($Vr,[2,13],{8:$Vs,15:$Vt}),o($Vk,[2,51]),{7:97,32:15,34:14,41:23,42:$V2,44:$V3,45:9,47:10,48:$V4,50:$V5,51:$V6,52:11,53:$V7,54:12,55:$V8,56:13,57:$V9},o($Vu,[2,10],{11:$Vv,12:$Vw,13:$Vx}),o($Vu,[2,11],{11:$Vv,12:$Vw,13:$Vx}),o($Vd,[2,6]),o($Vd,[2,7]),o($Vd,[2,8]),o($Vq,[2,40]),o($Vq,[2,41]),o($Vq,[2,42]),o($Vq,[2,44]),o($Vz,[2,36])],
+defaultActions: {31:[2,1]},
+parseError: function parseError(str, hash) {
+ if (hash.recoverable) {
+ this.trace(str);
+ } else {
+ function _parseError (msg, hash) {
+ this.message = msg;
+ this.hash = hash;
+ }
+ _parseError.prototype = Error;
+
+ throw new _parseError(str, hash);
+ }
+},
+parse: function parse(input) {
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
+ var args = lstack.slice.call(arguments, 1);
+ var lexer = Object.create(this.lexer);
+ var sharedState = { yy: {} };
+ for (var k in this.yy) {
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
+ sharedState.yy[k] = this.yy[k];
+ }
+ }
+ lexer.setInput(input, sharedState.yy);
+ sharedState.yy.lexer = lexer;
+ sharedState.yy.parser = this;
+ if (typeof lexer.yylloc == 'undefined') {
+ lexer.yylloc = {};
+ }
+ var yyloc = lexer.yylloc;
+ lstack.push(yyloc);
+ var ranges = lexer.options && lexer.options.ranges;
+ if (typeof sharedState.yy.parseError === 'function') {
+ this.parseError = sharedState.yy.parseError;
+ } else {
+ this.parseError = Object.getPrototypeOf(this).parseError;
+ }
+ function popStack(n) {
+ stack.length = stack.length - 2 * n;
+ vstack.length = vstack.length - n;
+ lstack.length = lstack.length - n;
+ }
+ _token_stack:
+ var lex = function () {
+ var token;
+ token = lexer.lex() || EOF;
+ if (typeof token !== 'number') {
+ token = self.symbols_[token] || token;
+ }
+ return token;
+ };
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
+ while (true) {
+ state = stack[stack.length - 1];
+ if (this.defaultActions[state]) {
+ action = this.defaultActions[state];
+ } else {
+ if (symbol === null || typeof symbol == 'undefined') {
+ symbol = lex();
+ }
+ action = table[state] && table[state][symbol];
+ }
+ if (typeof action === 'undefined' || !action.length || !action[0]) {
+ var errStr = '';
+ expected = [];
+ for (p in table[state]) {
+ if (this.terminals_[p] && p > TERROR) {
+ expected.push('\'' + this.terminals_[p] + '\'');
+ }
+ }
+ if (lexer.showPosition) {
+ errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
+ } else {
+ errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
+ }
+ this.parseError(errStr, {
+ text: lexer.match,
+ token: this.terminals_[symbol] || symbol,
+ line: lexer.yylineno,
+ loc: yyloc,
+ expected: expected
+ });
+ }
+ if (action[0] instanceof Array && action.length > 1) {
+ throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
+ }
+ switch (action[0]) {
+ case 1:
+ stack.push(symbol);
+ vstack.push(lexer.yytext);
+ lstack.push(lexer.yylloc);
+ stack.push(action[1]);
+ symbol = null;
+ if (!preErrorSymbol) {
+ yyleng = lexer.yyleng;
+ yytext = lexer.yytext;
+ yylineno = lexer.yylineno;
+ yyloc = lexer.yylloc;
+ if (recovering > 0) {
+ recovering--;
+ }
+ } else {
+ symbol = preErrorSymbol;
+ preErrorSymbol = null;
+ }
+ break;
+ case 2:
+ len = this.productions_[action[1]][1];
+ yyval.$ = vstack[vstack.length - len];
+ yyval._$ = {
+ first_line: lstack[lstack.length - (len || 1)].first_line,
+ last_line: lstack[lstack.length - 1].last_line,
+ first_column: lstack[lstack.length - (len || 1)].first_column,
+ last_column: lstack[lstack.length - 1].last_column
+ };
+ if (ranges) {
+ yyval._$.range = [
+ lstack[lstack.length - (len || 1)].range[0],
+ lstack[lstack.length - 1].range[1]
+ ];
+ }
+ r = this.performAction.apply(yyval, [
+ yytext,
+ yyleng,
+ yylineno,
+ sharedState.yy,
+ action[1],
+ vstack,
+ lstack
+ ].concat(args));
+ if (typeof r !== 'undefined') {
+ return r;
+ }
+ if (len) {
+ stack = stack.slice(0, -1 * len * 2);
+ vstack = vstack.slice(0, -1 * len);
+ lstack = lstack.slice(0, -1 * len);
+ }
+ stack.push(this.productions_[action[1]][0]);
+ vstack.push(yyval.$);
+ lstack.push(yyval._$);
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
+ stack.push(newState);
+ break;
+ case 3:
+ return true;
+ }
+ }
+ return true;
+}};
+/* generated by jison-lex 0.3.4 */
+var lexer = (function(){
+var lexer = ({
+
+EOF:1,
+
+parseError:function parseError(str, hash) {
+ if (this.yy.parser) {
+ this.yy.parser.parseError(str, hash);
+ } else {
+ throw new Error(str);
+ }
+ },
+
+// resets the lexer, sets new input
+setInput:function (input, yy) {
+ this.yy = yy || this.yy || {};
+ this._input = input;
+ this._more = this._backtrack = this.done = false;
+ this.yylineno = this.yyleng = 0;
+ this.yytext = this.matched = this.match = '';
+ this.conditionStack = ['INITIAL'];
+ this.yylloc = {
+ first_line: 1,
+ first_column: 0,
+ last_line: 1,
+ last_column: 0
+ };
+ if (this.options.ranges) {
+ this.yylloc.range = [0,0];
+ }
+ this.offset = 0;
+ return this;
+ },
+
+// consumes and returns one char from the input
+input:function () {
+ var ch = this._input[0];
+ this.yytext += ch;
+ this.yyleng++;
+ this.offset++;
+ this.match += ch;
+ this.matched += ch;
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
+ if (lines) {
+ this.yylineno++;
+ this.yylloc.last_line++;
+ } else {
+ this.yylloc.last_column++;
+ }
+ if (this.options.ranges) {
+ this.yylloc.range[1]++;
+ }
+
+ this._input = this._input.slice(1);
+ return ch;
+ },
+
+// unshifts one char (or a string) into the input
+unput:function (ch) {
+ var len = ch.length;
+ var lines = ch.split(/(?:\r\n?|\n)/g);
+
+ this._input = ch + this._input;
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
+ //this.yyleng -= len;
+ this.offset -= len;
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
+ this.match = this.match.substr(0, this.match.length - 1);
+ this.matched = this.matched.substr(0, this.matched.length - 1);
+
+ if (lines.length - 1) {
+ this.yylineno -= lines.length - 1;
+ }
+ var r = this.yylloc.range;
+
+ this.yylloc = {
+ first_line: this.yylloc.first_line,
+ last_line: this.yylineno + 1,
+ first_column: this.yylloc.first_column,
+ last_column: lines ?
+ (lines.length === oldLines.length ? this.yylloc.first_column : 0)
+ + oldLines[oldLines.length - lines.length].length - lines[0].length :
+ this.yylloc.first_column - len
+ };
+
+ if (this.options.ranges) {
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
+ }
+ this.yyleng = this.yytext.length;
+ return this;
+ },
+
+// When called from action, caches matched text and appends it on next action
+more:function () {
+ this._more = true;
+ return this;
+ },
+
+// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
+reject:function () {
+ if (this.options.backtrack_lexer) {
+ this._backtrack = true;
+ } else {
+ return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
+ text: "",
+ token: null,
+ line: this.yylineno
+ });
+
+ }
+ return this;
+ },
+
+// retain first n characters of the match
+less:function (n) {
+ this.unput(this.match.slice(n));
+ },
+
+// displays already matched input, i.e. for error messages
+pastInput:function () {
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
+ return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
+ },
+
+// displays upcoming input, i.e. for error messages
+upcomingInput:function () {
+ var next = this.match;
+ if (next.length < 20) {
+ next += this._input.substr(0, 20-next.length);
+ }
+ return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
+ },
+
+// displays the character position where the lexing error occurred, i.e. for error messages
+showPosition:function () {
+ var pre = this.pastInput();
+ var c = new Array(pre.length + 1).join("-");
+ return pre + this.upcomingInput() + "\n" + c + "^";
+ },
+
+// test the lexed token: return FALSE when not a match, otherwise return token
+test_match:function (match, indexed_rule) {
+ var token,
+ lines,
+ backup;
+
+ if (this.options.backtrack_lexer) {
+ // save context
+ backup = {
+ yylineno: this.yylineno,
+ yylloc: {
+ first_line: this.yylloc.first_line,
+ last_line: this.last_line,
+ first_column: this.yylloc.first_column,
+ last_column: this.yylloc.last_column
+ },
+ yytext: this.yytext,
+ match: this.match,
+ matches: this.matches,
+ matched: this.matched,
+ yyleng: this.yyleng,
+ offset: this.offset,
+ _more: this._more,
+ _input: this._input,
+ yy: this.yy,
+ conditionStack: this.conditionStack.slice(0),
+ done: this.done
+ };
+ if (this.options.ranges) {
+ backup.yylloc.range = this.yylloc.range.slice(0);
+ }
+ }
+
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
+ if (lines) {
+ this.yylineno += lines.length;
+ }
+ this.yylloc = {
+ first_line: this.yylloc.last_line,
+ last_line: this.yylineno + 1,
+ first_column: this.yylloc.last_column,
+ last_column: lines ?
+ lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
+ this.yylloc.last_column + match[0].length
+ };
+ this.yytext += match[0];
+ this.match += match[0];
+ this.matches = match;
+ this.yyleng = this.yytext.length;
+ if (this.options.ranges) {
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
+ }
+ this._more = false;
+ this._backtrack = false;
+ this._input = this._input.slice(match[0].length);
+ this.matched += match[0];
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
+ if (this.done && this._input) {
+ this.done = false;
+ }
+ if (token) {
+ return token;
+ } else if (this._backtrack) {
+ // recover context
+ for (var k in backup) {
+ this[k] = backup[k];
+ }
+ return false; // rule action called reject() implying the next rule should be tested instead.
+ }
+ return false;
+ },
+
+// return next match in input
+next:function () {
+ if (this.done) {
+ return this.EOF;
+ }
+ if (!this._input) {
+ this.done = true;
+ }
+
+ var token,
+ match,
+ tempMatch,
+ index;
+ if (!this._more) {
+ this.yytext = '';
+ this.match = '';
+ }
+ var rules = this._currentRules();
+ for (var i = 0; i < rules.length; i++) {
+ tempMatch = this._input.match(this.rules[rules[i]]);
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
+ match = tempMatch;
+ index = i;
+ if (this.options.backtrack_lexer) {
+ token = this.test_match(tempMatch, rules[i]);
+ if (token !== false) {
+ return token;
+ } else if (this._backtrack) {
+ match = false;
+ continue; // rule action called reject() implying a rule MISmatch.
+ } else {
+ // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
+ return false;
+ }
+ } else if (!this.options.flex) {
+ break;
+ }
+ }
+ }
+ if (match) {
+ token = this.test_match(match, rules[index]);
+ if (token !== false) {
+ return token;
+ }
+ // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
+ return false;
+ }
+ if (this._input === "") {
+ return this.EOF;
+ } else {
+ return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
+ text: "",
+ token: null,
+ line: this.yylineno
+ });
+ }
+ },
+
+// return next match that has a token
+lex:function lex() {
+ var r = this.next();
+ if (r) {
+ return r;
+ } else {
+ return this.lex();
+ }
+ },
+
+// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
+begin:function begin(condition) {
+ this.conditionStack.push(condition);
+ },
+
+// pop the previously active lexer condition state off the condition stack
+popState:function popState() {
+ var n = this.conditionStack.length - 1;
+ if (n > 0) {
+ return this.conditionStack.pop();
+ } else {
+ return this.conditionStack[0];
+ }
+ },
+
+// produce the lexer rule set which is active for the currently active lexer condition state
+_currentRules:function _currentRules() {
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
+ } else {
+ return this.conditions["INITIAL"].rules;
+ }
+ },
+
+// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
+topState:function topState(n) {
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
+ if (n >= 0) {
+ return this.conditionStack[n];
+ } else {
+ return "INITIAL";
+ }
+ },
+
+// alias for begin(condition)
+pushState:function pushState(condition) {
+ this.begin(condition);
+ },
+
+// return the number of states currently on the stack
+stateStackSize:function stateStackSize() {
+ return this.conditionStack.length;
+ },
+options: {},
+performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
+var YYSTATE=YY_START;
+switch($avoiding_name_collisions) {
+case 0:return 31;
+break;
+case 1:return 33;
+break;
+case 2:return 'from';
+break;
+case 3:return 24;
+break;
+case 4:return 25;
+break;
+case 5:return 26;
+break;
+case 6:return 27;
+break;
+case 7:return 21;
+break;
+case 8:return 19;
+break;
+case 9:return 22;
+break;
+case 10:return 20;
+break;
+case 11:return 28;
+break;
+case 12:return 29;
+break;
+case 13:return 36;
+break;
+case 14:return 38;
+break;
+case 15:return 57;
+break;
+case 16:return 55;
+break;
+case 17:/* skip whitespace */
+break;
+case 18:return 51;
+break;
+case 19:return 50;
+break;
+case 20:return 50;
+break;
+case 21:return 42;
+break;
+case 22:return 53;
+break;
+case 23:return 43;
+break;
+case 24:return 11;
+break;
+case 25:return 12;
+break;
+case 26:return 13;
+break;
+case 27:return 40;
+break;
+case 28:return 8;
+break;
+case 29:return 28;
+break;
+case 30:return 29;
+break;
+case 31:return 25;
+break;
+case 32:return 24;
+break;
+case 33:return 27;
+break;
+case 34:return 26;
+break;
+case 35:return 21;
+break;
+case 36:return 22;
+break;
+case 37:return 20;
+break;
+case 38:return 19;
+break;
+case 39:return 36;
+break;
+case 40:return 38;
+break;
+case 41:return 15;
+break;
+case 42:return 17;
+break;
+case 43:return 48;
+break;
+case 44:return 46;
+break;
+case 45:return 44;
+break;
+case 46:return 49;
+break;
+case 47:return 9;
+break;
+case 48:return 5;
+break;
+}
+},
+rules: [/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(seq|SEQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(sneq|SNEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s*(null)\b)/,/^(?:\s*(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:===)/,/^(?:==)/,/^(?:!==)/,/^(?:!=)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],
+conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"inclusive":true}}
+});
+return lexer;
+})();
+parser.lexer = lexer;
+function Parser () {
+ this.yy = {};
+}
+Parser.prototype = parser;parser.Parser = Parser;
+return new Parser;
+})();
+
+
+if (true) {
+exports.parser = parser;
+exports.Parser = parser.Parser;
+exports.parse = function () { return parser.parse.apply(parser, arguments); };
+exports.main = function commonjsMain(args) {
+ if (!args[1]) {
+ console.log('Usage: '+args[0]+' FILE');
+ process.exit(1);
+ }
+ var source = __webpack_require__(/*! fs */ "fs").readFileSync(__webpack_require__(/*! path */ "path").normalize(args[1]), "utf8");
+ return exports.parser.parse(source);
+};
+if ( true && __webpack_require__.c[__webpack_require__.s] === module) {
+ exports.main(process.argv.slice(1));
+}
+}
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/index.js":
+/*!****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/index.js ***!
+ \****************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+(function () {
+ "use strict";
+ var constraintParser = __webpack_require__(/*! ./constraint/parser */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/constraint/parser.js"),
+ noolParser = __webpack_require__(/*! ./nools/nool.parser */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/nool.parser.js");
+
+ exports.parseConstraint = function (expression) {
+ try {
+ return constraintParser.parse(expression);
+ } catch (e) {
+ throw new Error("Invalid expression '" + expression + "'");
+ }
+ };
+
+ exports.parseRuleSet = function (source, file) {
+ return noolParser.parse(source, file);
+ };
+})();
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/nool.parser.js":
+/*!****************************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/nool.parser.js ***!
+ \****************************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+
+var tokens = __webpack_require__(/*! ./tokens.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/tokens.js"),
+ extd = __webpack_require__(/*! ../../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ keys = extd.hash.keys,
+ utils = __webpack_require__(/*! ./util.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/util.js");
+
+var parse = function (src, keywords, context) {
+ var orig = src;
+ src = src.replace(/\/\/(.*)/g, "").replace(/\r\n|\r|\n/g, " ");
+
+ var blockTypes = new RegExp("^(" + keys(keywords).join("|") + ")"), index;
+ while (src && (index = utils.findNextTokenIndex(src)) !== -1) {
+ src = src.substr(index);
+ var blockType = src.match(blockTypes);
+ if (blockType !== null) {
+ blockType = blockType[1];
+ if (blockType in keywords) {
+ try {
+ src = keywords[blockType](src, context, parse).replace(/^\s*|\s*$/g, "");
+ } catch (e) {
+ throw new Error("Invalid " + blockType + " definition \n" + e.message + "; \nstarting at : " + orig);
+ }
+ } else {
+ throw new Error("Unknown token" + blockType);
+ }
+ } else {
+ throw new Error("Error parsing " + src);
+ }
+ }
+};
+
+exports.parse = function (src, file) {
+ var context = {define: [], rules: [], scope: [], loaded: [], file: file};
+ parse(src, tokens, context);
+ return context;
+};
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/tokens.js":
+/*!***********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/tokens.js ***!
+ \***********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+"use strict";
+
+
+var utils = __webpack_require__(/*! ./util.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/util.js"),
+ fs = __webpack_require__(/*! fs */ "fs"),
+ extd = __webpack_require__(/*! ../../extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ filter = extd.filter,
+ indexOf = extd.indexOf,
+ predicates = ["not", "or", "exists"],
+ predicateRegExp = new RegExp("^(" + predicates.join("|") + ") *\\((.*)\\)$", "m"),
+ predicateBeginExp = new RegExp(" *(" + predicates.join("|") + ") *\\(", "g");
+
+var isWhiteSpace = function (str) {
+ return str.replace(/[\s|\n|\r|\t]/g, "").length === 0;
+};
+
+var joinFunc = function (m, str) {
+ return "; " + str;
+};
+
+var splitRuleLineByPredicateExpressions = function (ruleLine) {
+ var str = ruleLine.replace(/,\s*(\$?\w+\s*:)/g, joinFunc);
+ var parts = filter(str.split(predicateBeginExp), function (str) {
+ return str !== "";
+ }),
+ l = parts.length, ret = [];
+
+ if (l) {
+ for (var i = 0; i < l; i++) {
+ if (indexOf(predicates, parts[i]) !== -1) {
+ ret.push([parts[i], "(", parts[++i].replace(/, *$/, "")].join(""));
+ } else {
+ ret.push(parts[i].replace(/, *$/, ""));
+ }
+ }
+ } else {
+ return str;
+ }
+ return ret.join(";");
+};
+
+var ruleTokens = {
+
+ salience: (function () {
+ var salienceRegexp = /^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;
+ return function (src, context) {
+ if (salienceRegexp.test(src)) {
+ var parts = src.match(salienceRegexp),
+ priority = parseInt(parts[2], 10);
+ if (!isNaN(priority)) {
+ context.options.priority = priority;
+ } else {
+ throw new Error("Invalid salience/priority " + parts[2]);
+ }
+ return src.replace(parts[0], "");
+ } else {
+ throw new Error("invalid format");
+ }
+ };
+ })(),
+
+ agendaGroup: (function () {
+ var agendaGroupRegexp = /^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;
+ return function (src, context) {
+ if (agendaGroupRegexp.test(src)) {
+ var parts = src.match(agendaGroupRegexp),
+ agendaGroup = parts[2];
+ if (agendaGroup) {
+ context.options.agendaGroup = agendaGroup.replace(/^["']|["']$/g, "");
+ } else {
+ throw new Error("Invalid agenda-group " + parts[2]);
+ }
+ return src.replace(parts[0], "");
+ } else {
+ throw new Error("invalid format");
+ }
+ };
+ })(),
+
+ autoFocus: (function () {
+ var autoFocusRegexp = /^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;
+ return function (src, context) {
+ if (autoFocusRegexp.test(src)) {
+ var parts = src.match(autoFocusRegexp),
+ autoFocus = parts[2];
+ if (autoFocus) {
+ context.options.autoFocus = autoFocus === "true" ? true : false;
+ } else {
+ throw new Error("Invalid auto-focus " + parts[2]);
+ }
+ return src.replace(parts[0], "");
+ } else {
+ throw new Error("invalid format");
+ }
+ };
+ })(),
+
+ "agenda-group": function () {
+ return this.agendaGroup.apply(this, arguments);
+ },
+
+ "auto-focus": function () {
+ return this.autoFocus.apply(this, arguments);
+ },
+
+ priority: function () {
+ return this.salience.apply(this, arguments);
+ },
+
+ when: (function () {
+ /*jshint evil:true*/
+
+ var ruleRegExp = /^(\$?\w+) *: *(\w+)(.*)/;
+
+ var constraintRegExp = /(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/;
+ var fromRegExp = /(\bfrom\s+.*)/;
+ var parseRules = function (str) {
+ var rules = [];
+ var ruleLines = str.split(";"), l = ruleLines.length, ruleLine;
+ for (var i = 0; i < l && (ruleLine = ruleLines[i].replace(/^\s*|\s*$/g, "").replace(/\n/g, "")); i++) {
+ if (!isWhiteSpace(ruleLine)) {
+ var rule = [];
+ if (predicateRegExp.test(ruleLine)) {
+ var m = ruleLine.match(predicateRegExp);
+ var pred = m[1].replace(/^\s*|\s*$/g, "");
+ rule.push(pred);
+ ruleLine = m[2].replace(/^\s*|\s*$/g, "");
+ if (pred === "or") {
+ rule = rule.concat(parseRules(splitRuleLineByPredicateExpressions(ruleLine)));
+ rules.push(rule);
+ continue;
+ }
+
+ }
+ var parts = ruleLine.match(ruleRegExp);
+ if (parts && parts.length) {
+ rule.push(parts[2], parts[1]);
+ var constraints = parts[3].replace(/^\s*|\s*$/g, "");
+ var hashParts = constraints.match(constraintRegExp), from = null, fromMatch;
+ if (hashParts) {
+ var hash = hashParts[1], constraint = constraints.replace(hash, "");
+ if (fromRegExp.test(constraint)) {
+ fromMatch = constraint.match(fromRegExp);
+ from = fromMatch[0];
+ constraint = constraint.replace(fromMatch[0], "");
+ }
+ if (constraint) {
+ rule.push(constraint.replace(/^\s*|\s*$/g, ""));
+ }
+ if (hash) {
+ rule.push(eval("(" + hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g, '"$1" : "$2"') + ")"));
+ }
+ } else if (constraints && !isWhiteSpace(constraints)) {
+ if (fromRegExp.test(constraints)) {
+ fromMatch = constraints.match(fromRegExp);
+ from = fromMatch[0];
+ constraints = constraints.replace(fromMatch[0], "");
+ }
+ rule.push(constraints);
+ }
+ if (from) {
+ rule.push(from);
+ }
+ rules.push(rule);
+ } else {
+ throw new Error("Invalid constraint " + ruleLine);
+ }
+ }
+ }
+ return rules;
+ };
+
+ return function (orig, context) {
+ var src = orig.replace(/^when\s*/, "").replace(/^\s*|\s*$/g, "");
+ if (utils.findNextToken(src) === "{") {
+ var body = utils.getTokensBetween(src, "{", "}", true).join("");
+ src = src.replace(body, "");
+ context.constraints = parseRules(body.replace(/^\{\s*|\}\s*$/g, ""));
+ return src;
+ } else {
+ throw new Error("unexpected token : expected : '{' found : '" + utils.findNextToken(src) + "'");
+ }
+ };
+ })(),
+
+ then: (function () {
+ return function (orig, context) {
+ if (!context.action) {
+ var src = orig.replace(/^then\s*/, "").replace(/^\s*|\s*$/g, "");
+ if (utils.findNextToken(src) === "{") {
+ var body = utils.getTokensBetween(src, "{", "}", true).join("");
+ src = src.replace(body, "");
+ if (!context.action) {
+ context.action = body.replace(/^\{\s*|\}\s*$/g, "");
+ }
+ if (!isWhiteSpace(src)) {
+ throw new Error("Error parsing then block " + orig);
+ }
+ return src;
+ } else {
+ throw new Error("unexpected token : expected : '{' found : '" + utils.findNextToken(src) + "'");
+ }
+ } else {
+ throw new Error("action already defined for rule" + context.name);
+ }
+
+ };
+ })()
+};
+
+var topLevelTokens = {
+ "/": function (orig) {
+ if (orig.match(/^\/\*/)) {
+ // Block Comment parse
+ return orig.replace(/\/\*.*?\*\//, "");
+ } else {
+ return orig;
+ }
+ },
+
+ "define": function (orig, context) {
+ var src = orig.replace(/^define\s*/, "");
+ var name = src.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);
+ if (name) {
+ src = src.replace(name[0], "").replace(/^\s*|\s*$/g, "");
+ if (utils.findNextToken(src) === "{") {
+ name = name[1];
+ var body = utils.getTokensBetween(src, "{", "}", true).join("");
+ src = src.replace(body, "");
+ //should
+ context.define.push({name: name, properties: "(" + body + ")"});
+ return src;
+ } else {
+ throw new Error("unexpected token : expected : '{' found : '" + utils.findNextToken(src) + "'");
+ }
+ } else {
+ throw new Error("missing name");
+ }
+ },
+
+ "import": function (orig, context, parse) {
+ if (typeof window !== 'undefined') {
+ throw new Error("import cannot be used in a browser");
+ }
+ var src = orig.replace(/^import\s*/, "");
+ if (utils.findNextToken(src) === "(") {
+ var file = utils.getParamList(src);
+ src = src.replace(file, "").replace(/^\s*|\s*$/g, "");
+ utils.findNextToken(src) === ";" && (src = src.replace(/\s*;/, ""));
+ file = file.replace(/[\(|\)]/g, "").split(",");
+ if (file.length === 1) {
+ file = utils.resolve(context.file || process.cwd(), file[0].replace(/["|']/g, ""));
+ if (indexOf(context.loaded, file) === -1) {
+ var origFile = context.file;
+ context.file = file;
+ parse(fs.readFileSync(file, "utf8"), topLevelTokens, context);
+ context.loaded.push(file);
+ context.file = origFile;
+ }
+ return src;
+ } else {
+ throw new Error("import accepts a single file");
+ }
+ } else {
+ throw new Error("unexpected token : expected : '(' found : '" + utils.findNextToken(src) + "'");
+ }
+
+ },
+
+ //define a global
+ "global": function (orig, context) {
+ var src = orig.replace(/^global\s*/, "");
+ var name = src.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);
+ if (name) {
+ src = src.replace(name[0], "").replace(/^\s*|\s*$/g, "");
+ if (utils.findNextToken(src) === "=") {
+ name = name[1].replace(/^\s+|\s+$/g, '');
+ var fullbody = utils.getTokensBetween(src, "=", ";", true).join("");
+ var body = fullbody.substring(1, fullbody.length - 1);
+ body = body.replace(/^\s+|\s+$/g, '');
+ if (/^require\(/.test(body)) {
+ var file = utils.getParamList(body.replace("require")).replace(/[\(|\)]/g, "").split(",");
+ if (file.length === 1) {
+ //handle relative require calls
+ file = file[0].replace(/["|']/g, "");
+ body = ["require('", utils.resolve(context.file || process.cwd(), file) , "')"].join("");
+ }
+ }
+ context.scope.push({name: name, body: body});
+ src = src.replace(fullbody, "");
+ return src;
+ } else {
+ throw new Error("unexpected token : expected : '=' found : '" + utils.findNextToken(src) + "'");
+ }
+ } else {
+ throw new Error("missing name");
+ }
+ },
+
+ //define a function
+ "function": function (orig, context) {
+ var src = orig.replace(/^function\s*/, "");
+ //parse the function name
+ var name = src.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);
+ if (name) {
+ src = src.replace(name[0], "");
+ if (utils.findNextToken(src) === "(") {
+ name = name[1];
+ var params = utils.getParamList(src);
+ src = src.replace(params, "").replace(/^\s*|\s*$/g, "");
+ if (utils.findNextToken(src) === "{") {
+ var body = utils.getTokensBetween(src, "{", "}", true).join("");
+ src = src.replace(body, "");
+ //should
+ context.scope.push({name: name, body: "function" + params + body});
+ return src;
+ } else {
+ throw new Error("unexpected token : expected : '{' found : '" + utils.findNextToken(src) + "'");
+ }
+ } else {
+ throw new Error("unexpected token : expected : '(' found : '" + utils.findNextToken(src) + "'");
+ }
+ } else {
+ throw new Error("missing name");
+ }
+ },
+
+ "rule": function (orig, context, parse) {
+ var src = orig.replace(/^rule\s*/, "");
+ var name = src.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);
+ if (name) {
+ src = src.replace(name[0], "").replace(/^\s*|\s*$/g, "");
+ if (utils.findNextToken(src) === "{") {
+ name = name[1].replace(/^["']|["']$/g, "");
+ var rule = {name: name, options: {}, constraints: null, action: null};
+ var body = utils.getTokensBetween(src, "{", "}", true).join("");
+ src = src.replace(body, "");
+ parse(body.replace(/^\{\s*|\}\s*$/g, ""), ruleTokens, rule);
+ context.rules.push(rule);
+ return src;
+ } else {
+ throw new Error("unexpected token : expected : '{' found : '" + utils.findNextToken(src) + "'");
+ }
+ } else {
+ throw new Error("missing name");
+ }
+
+ }
+};
+module.exports = topLevelTokens;
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/util.js":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/nools/util.js ***!
+ \*********************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+
+var path = __webpack_require__(/*! path */ "path");
+var WHITE_SPACE_REG = /[\s|\n|\r|\t]/,
+ pathSep = path.sep || ( process.platform === 'win32' ? '\\' : '/' );
+
+var TOKEN_INVERTS = {
+ "{": "}",
+ "}": "{",
+ "(": ")",
+ ")": "(",
+ "[": "]"
+};
+
+var getTokensBetween = exports.getTokensBetween = function (str, start, stop, includeStartEnd) {
+ var depth = 0, ret = [];
+ if (!start) {
+ start = TOKEN_INVERTS[stop];
+ depth = 1;
+ }
+ if (!stop) {
+ stop = TOKEN_INVERTS[start];
+ }
+ str = Object(str);
+ var startPushing = false, token, cursor = 0, found = false;
+ while ((token = str.charAt(cursor++))) {
+ if (token === start) {
+ depth++;
+ if (!startPushing) {
+ startPushing = true;
+ if (includeStartEnd) {
+ ret.push(token);
+ }
+ } else {
+ ret.push(token);
+ }
+ } else if (token === stop && cursor) {
+ depth--;
+ if (depth === 0) {
+ if (includeStartEnd) {
+ ret.push(token);
+ }
+ found = true;
+ break;
+ }
+ ret.push(token);
+ } else if (startPushing) {
+ ret.push(token);
+ }
+ }
+ if (!found) {
+ throw new Error("Unable to match " + start + " in " + str);
+ }
+ return ret;
+};
+
+exports.getParamList = function (str) {
+ return getTokensBetween(str, "(", ")", true).join("");
+};
+
+exports.resolve = function (from, to) {
+ if (process.platform === 'win32') {
+ to = to.replace(/\//g, '\\');
+ }
+ if (path.extname(from) !== '') {
+ from = path.dirname(from);
+ }
+ if (to.split(pathSep).length === 1) {
+ return to;
+ }
+ return path.resolve(from, to).replace(/\\/g, '/');
+
+};
+
+var findNextTokenIndex = exports.findNextTokenIndex = function (str, startIndex, endIndex) {
+ startIndex = startIndex || 0;
+ endIndex = endIndex || str.length;
+ var ret = -1, l = str.length;
+ if (!endIndex || endIndex > l) {
+ endIndex = l;
+ }
+ for (; startIndex < endIndex; startIndex++) {
+ var c = str.charAt(startIndex);
+ if (!WHITE_SPACE_REG.test(c)) {
+ ret = startIndex;
+ break;
+ }
+ }
+ return ret;
+};
+
+exports.findNextToken = function (str, startIndex, endIndex) {
+ return str.charAt(findNextTokenIndex(str, startIndex, endIndex));
+};
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/pattern.js":
+/*!***********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/pattern.js ***!
+ \***********************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ isEmpty = extd.isEmpty,
+ merge = extd.merge,
+ forEach = extd.forEach,
+ declare = extd.declare,
+ constraintMatcher = __webpack_require__(/*! ./constraintMatcher */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraintMatcher.js"),
+ constraint = __webpack_require__(/*! ./constraint */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/constraint.js"),
+ EqualityConstraint = constraint.EqualityConstraint,
+ FromConstraint = constraint.FromConstraint;
+
+var id = 0;
+var Pattern = declare({});
+
+var ObjectPattern = Pattern.extend({
+ instance: {
+ constructor: function (type, alias, conditions, store, options) {
+ options = options || {};
+ this.id = id++;
+ this.type = type;
+ this.alias = alias;
+ this.conditions = conditions;
+ this.pattern = options.pattern;
+ var constraints = [new constraint.ObjectConstraint(type)];
+ var constrnts = constraintMatcher.toConstraints(conditions, merge({alias: alias}, options));
+ if (constrnts.length) {
+ constraints = constraints.concat(constrnts);
+ } else {
+ var cnstrnt = new constraint.TrueConstraint();
+ constraints.push(cnstrnt);
+ }
+ if (store && !isEmpty(store)) {
+ var atm = new constraint.HashConstraint(store);
+ constraints.push(atm);
+ }
+
+ forEach(constraints, function (constraint) {
+ constraint.set("alias", alias);
+ });
+ this.constraints = constraints;
+ },
+
+ getSpecificity: function () {
+ var constraints = this.constraints, specificity = 0;
+ for (var i = 0, l = constraints.length; i < l; i++) {
+ if (constraints[i] instanceof EqualityConstraint) {
+ specificity++;
+ }
+ }
+ return specificity;
+ },
+
+ hasConstraint: function (type) {
+ return extd.some(this.constraints, function (c) {
+ return c instanceof type;
+ });
+ },
+
+ hashCode: function () {
+ return [this.type, this.alias, extd.format("%j", this.conditions)].join(":");
+ },
+
+ toString: function () {
+ return extd.format("%j", this.constraints);
+ }
+ }
+}).as(exports, "ObjectPattern");
+
+var FromPattern = ObjectPattern.extend({
+ instance: {
+ constructor: function (type, alias, conditions, store, from, options) {
+ this._super([type, alias, conditions, store, options]);
+ this.from = new FromConstraint(from, options);
+ },
+
+ hasConstraint: function (type) {
+ return extd.some(this.constraints, function (c) {
+ return c instanceof type;
+ });
+ },
+
+ getSpecificity: function () {
+ return this._super(arguments) + 1;
+ },
+
+ hashCode: function () {
+ return [this.type, this.alias, extd.format("%j", this.conditions), this.from.from].join(":");
+ },
+
+ toString: function () {
+ return extd.format("%j from %s", this.constraints, this.from.from);
+ }
+ }
+}).as(exports, "FromPattern");
+
+
+FromPattern.extend().as(exports, "FromNotPattern");
+ObjectPattern.extend().as(exports, "NotPattern");
+ObjectPattern.extend().as(exports, "ExistsPattern");
+FromPattern.extend().as(exports, "FromExistsPattern");
+
+Pattern.extend({
+
+ instance: {
+ constructor: function (left, right) {
+ this.id = id++;
+ this.leftPattern = left;
+ this.rightPattern = right;
+ },
+
+ hashCode: function () {
+ return [this.leftPattern.hashCode(), this.rightPattern.hashCode()].join(":");
+ },
+
+ getSpecificity: function () {
+ return this.rightPattern.getSpecificity() + this.leftPattern.getSpecificity();
+ },
+
+ getters: {
+ constraints: function () {
+ return this.leftPattern.constraints.concat(this.rightPattern.constraints);
+ }
+ }
+ }
+
+}).as(exports, "CompositePattern");
+
+
+var InitialFact = declare({
+ instance: {
+ constructor: function () {
+ this.id = id++;
+ this.recency = 0;
+ }
+ }
+}).as(exports, "InitialFact");
+
+ObjectPattern.extend({
+ instance: {
+ constructor: function () {
+ this._super([InitialFact, "__i__", [], {}]);
+ },
+
+ assert: function () {
+ return true;
+ }
+ }
+}).as(exports, "InitialFactPattern");
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/rule.js":
+/*!********************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/rule.js ***!
+ \********************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+var extd = __webpack_require__(/*! ./extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/extended.js"),
+ isArray = extd.isArray,
+ Promise = extd.Promise,
+ declare = extd.declare,
+ isHash = extd.isHash,
+ isString = extd.isString,
+ format = extd.format,
+ parser = __webpack_require__(/*! ./parser */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/parser/index.js"),
+ pattern = __webpack_require__(/*! ./pattern */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/pattern.js"),
+ ObjectPattern = pattern.ObjectPattern,
+ FromPattern = pattern.FromPattern,
+ NotPattern = pattern.NotPattern,
+ ExistsPattern = pattern.ExistsPattern,
+ FromNotPattern = pattern.FromNotPattern,
+ FromExistsPattern = pattern.FromExistsPattern,
+ CompositePattern = pattern.CompositePattern;
+
+var parseConstraint = function (constraint) {
+ if (typeof constraint === 'function') {
+ // No parsing is needed for constraint functions
+ return constraint;
+ }
+ return parser.parseConstraint(constraint);
+};
+
+var parseExtra = extd
+ .switcher()
+ .isUndefinedOrNull(function () {
+ return null;
+ })
+ .isLike(/^from +/, function (s) {
+ return {from: s.replace(/^from +/, "").replace(/^\s*|\s*$/g, "")};
+ })
+ .def(function (o) {
+ throw new Error("invalid rule constraint option " + o);
+ })
+ .switcher();
+
+var normailizeConstraint = extd
+ .switcher()
+ .isLength(1, function (c) {
+ throw new Error("invalid rule constraint " + format("%j", [c]));
+ })
+ .isLength(2, function (c) {
+ c.push("true");
+ return c;
+ })
+ //handle case where c[2] is a hash rather than a constraint string
+ .isLength(3, function (c) {
+ if (isString(c[2]) && /^from +/.test(c[2])) {
+ var extra = c[2];
+ c.splice(2, 0, "true");
+ c[3] = null;
+ c[4] = parseExtra(extra);
+ } else if (isHash(c[2])) {
+ c.splice(2, 0, "true");
+ }
+ return c;
+ })
+ //handle case where c[3] is a from clause rather than a hash for references
+ .isLength(4, function (c) {
+ if (isString(c[3])) {
+ c.splice(3, 0, null);
+ c[4] = parseExtra(c[4]);
+ }
+ return c;
+ })
+ .def(function (c) {
+ if (c.length === 5) {
+ c[4] = parseExtra(c[4]);
+ }
+ return c;
+ })
+ .switcher();
+
+var getParamType = function getParamType(type, scope) {
+ scope = scope || {};
+ var getParamTypeSwitch = extd
+ .switcher()
+ .isEq("string", function () {
+ return String;
+ })
+ .isEq("date", function () {
+ return Date;
+ })
+ .isEq("array", function () {
+ return Array;
+ })
+ .isEq("boolean", function () {
+ return Boolean;
+ })
+ .isEq("regexp", function () {
+ return RegExp;
+ })
+ .isEq("number", function () {
+ return Number;
+ })
+ .isEq("object", function () {
+ return Object;
+ })
+ .isEq("hash", function () {
+ return Object;
+ })
+ .def(function (param) {
+ throw new TypeError("invalid param type " + param);
+ })
+ .switcher();
+
+ var _getParamType = extd
+ .switcher()
+ .isString(function (param) {
+ var t = scope[param];
+ if (!t) {
+ return getParamTypeSwitch(param.toLowerCase());
+ } else {
+ return t;
+ }
+ })
+ .isFunction(function (func) {
+ return func;
+ })
+ .deepEqual([], function () {
+ return Array;
+ })
+ .def(function (param) {
+ throw new Error("invalid param type " + param);
+ })
+ .switcher();
+
+ return _getParamType(type);
+};
+
+var parsePattern = extd
+ .switcher()
+ .containsAt("or", 0, function (condition) {
+ condition.shift();
+ return extd(condition).map(function (cond) {
+ cond.scope = condition.scope;
+ return parsePattern(cond);
+ }).flatten().value();
+ })
+ .containsAt("not", 0, function (condition) {
+ condition.shift();
+ condition = normailizeConstraint(condition);
+ if (condition[4] && condition[4].from) {
+ return [
+ new FromNotPattern(
+ getParamType(condition[0], condition.scope),
+ condition[1] || "m",
+ parseConstraint(condition[2] || "true"),
+ condition[3] || {},
+ parseConstraint(condition[4].from),
+ {scope: condition.scope, pattern: condition[2]}
+ )
+ ];
+ } else {
+ return [
+ new NotPattern(
+ getParamType(condition[0], condition.scope),
+ condition[1] || "m",
+ parseConstraint(condition[2] || "true"),
+ condition[3] || {},
+ {scope: condition.scope, pattern: condition[2]}
+ )
+ ];
+ }
+ })
+ .containsAt("exists", 0, function (condition) {
+ condition.shift();
+ condition = normailizeConstraint(condition);
+ if (condition[4] && condition[4].from) {
+ return [
+ new FromExistsPattern(
+ getParamType(condition[0], condition.scope),
+ condition[1] || "m",
+ parseConstraint(condition[2] || "true"),
+ condition[3] || {},
+ parseConstraint(condition[4].from),
+ {scope: condition.scope, pattern: condition[2]}
+ )
+ ];
+ } else {
+ return [
+ new ExistsPattern(
+ getParamType(condition[0], condition.scope),
+ condition[1] || "m",
+ parseConstraint(condition[2] || "true"),
+ condition[3] || {},
+ {scope: condition.scope, pattern: condition[2]}
+ )
+ ];
+ }
+ })
+ .def(function (condition) {
+ if (typeof condition === 'function') {
+ return [condition];
+ }
+ condition = normailizeConstraint(condition);
+ if (condition[4] && condition[4].from) {
+ return [
+ new FromPattern(
+ getParamType(condition[0], condition.scope),
+ condition[1] || "m",
+ parseConstraint(condition[2] || "true"),
+ condition[3] || {},
+ parseConstraint(condition[4].from),
+ {scope: condition.scope, pattern: condition[2]}
+ )
+ ];
+ } else {
+ return [
+ new ObjectPattern(
+ getParamType(condition[0], condition.scope),
+ condition[1] || "m",
+ parseConstraint(condition[2] || "true"),
+ condition[3] || {},
+ {scope: condition.scope, pattern: condition[2]}
+ )
+ ];
+ }
+ }).switcher();
+
+var Rule = declare({
+ instance: {
+ constructor: function (name, options, pattern, cb) {
+ this.name = name;
+ this.pattern = pattern;
+ this.cb = cb;
+ if (options.agendaGroup) {
+ this.agendaGroup = options.agendaGroup;
+ this.autoFocus = extd.isBoolean(options.autoFocus) ? options.autoFocus : false;
+ }
+ this.priority = options.priority || options.salience || 0;
+ },
+
+ fire: function (flow, match) {
+ var ret = new Promise(), cb = this.cb;
+ try {
+ if (cb.length === 3) {
+ cb.call(flow, match.factHash, flow, ret.resolve);
+ } else {
+ ret = cb.call(flow, match.factHash, flow);
+ }
+ } catch (e) {
+ ret.errback(e);
+ }
+ return ret;
+ }
+ }
+});
+
+function createRule(name, options, conditions, cb) {
+ if (isArray(options)) {
+ cb = conditions;
+ conditions = options;
+ } else {
+ options = options || {};
+ }
+ var isRules = extd.every(conditions, function (cond) {
+ return isArray(cond);
+ });
+ if (isRules && conditions.length === 1) {
+ conditions = conditions[0];
+ isRules = false;
+ }
+ var rules = [];
+ var scope = options.scope || {};
+ conditions.scope = scope;
+ if (isRules) {
+ var _mergePatterns = function (patt, i) {
+ if (!patterns[i]) {
+ patterns[i] = i === 0 ? [] : patterns[i - 1].slice();
+ //remove dup
+ if (i !== 0) {
+ patterns[i].pop();
+ }
+ patterns[i].push(patt);
+ } else {
+ extd(patterns).forEach(function (p) {
+ p.push(patt);
+ });
+ }
+
+ };
+ var l = conditions.length, patterns = [], condition;
+ for (var i = 0; i < l; i++) {
+ condition = conditions[i];
+ condition.scope = scope;
+ extd.forEach(parsePattern(condition), _mergePatterns);
+
+ }
+ rules = extd.map(patterns, function (patterns) {
+ var compPat = null;
+ for (var i = 0; i < patterns.length; i++) {
+ if (compPat === null) {
+ compPat = new CompositePattern(patterns[i++], patterns[i]);
+ } else {
+ compPat = new CompositePattern(compPat, patterns[i]);
+ }
+ }
+ return new Rule(name, options, compPat, cb);
+ });
+ } else {
+ rules = extd.map(parsePattern(conditions), function (cond) {
+ return new Rule(name, options, cond, cb);
+ });
+ }
+ return rules;
+}
+
+exports.createRule = createRule;
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/workingMemory.js":
+/*!*****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/workingMemory.js ***!
+ \*****************************************************************************************************/
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+"use strict";
+
+var declare = __webpack_require__(/*! declare.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js"),
+ LinkedList = __webpack_require__(/*! ./linkedList */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/linkedList.js"),
+ InitialFact = __webpack_require__(/*! ./pattern */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/nools/lib/pattern.js").InitialFact,
+ id = 0;
+
+var Fact = declare({
+
+ instance: {
+ constructor: function (obj) {
+ this.object = obj;
+ this.recency = 0;
+ this.id = id++;
+ },
+
+ equals: function (fact) {
+ return fact === this.object;
+ },
+
+ hashCode: function () {
+ return this.id;
+ }
+ }
+
+});
+
+declare({
+
+ instance: {
+
+ constructor: function () {
+ this.recency = 0;
+ this.facts = new LinkedList();
+ },
+
+ dispose: function () {
+ this.facts.clear();
+ },
+
+ getFacts: function () {
+ var head = {next: this.facts.head}, ret = [], i = 0, val;
+ while ((head = head.next)) {
+ if (!((val = head.data.object) instanceof InitialFact)) {
+ ret[i++] = val;
+ }
+ }
+ return ret;
+ },
+
+ getFactsByType: function (Type) {
+ var head = {next: this.facts.head}, ret = [], i = 0;
+ while ((head = head.next)) {
+ var val = head.data.object;
+ if (!(val instanceof InitialFact) && (val instanceof Type || val.constructor === Type)) {
+ ret[i++] = val;
+ }
+ }
+ return ret;
+ },
+
+ getFactHandle: function (o) {
+ var head = {next: this.facts.head}, ret;
+ while ((head = head.next)) {
+ var existingFact = head.data;
+ if (existingFact.equals(o)) {
+ return existingFact;
+ }
+ }
+ if (!ret) {
+ ret = new Fact(o);
+ ret.recency = this.recency++;
+ //this.facts.push(ret);
+ }
+ return ret;
+ },
+
+ modifyFact: function (fact) {
+ var head = {next: this.facts.head};
+ while ((head = head.next)) {
+ var existingFact = head.data;
+ if (existingFact.equals(fact)) {
+ existingFact.recency = this.recency++;
+ return existingFact;
+ }
+ }
+ //if we made it here we did not find the fact
+ throw new Error("the fact to modify does not exist");
+ },
+
+ assertFact: function (fact) {
+ var ret = new Fact(fact);
+ ret.recency = this.recency++;
+ this.facts.push(ret);
+ return ret;
+ },
+
+ retractFact: function (fact) {
+ var facts = this.facts, head = {next: facts.head};
+ while ((head = head.next)) {
+ var existingFact = head.data;
+ if (existingFact.equals(fact)) {
+ facts.remove(head);
+ return existingFact;
+ }
+ }
+ //if we made it here we did not find the fact
+ throw new Error("the fact to remove does not exist");
+
+
+ }
+ }
+
+}).as(exports, "WorkingMemory");
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/object-extended/index.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/object-extended/index.js ***!
+ \***************************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+ /*global extended isExtended*/
+
+ function defineObject(extended, is, arr) {
+
+ var deepEqual = is.deepEqual,
+ isString = is.isString,
+ isHash = is.isHash,
+ difference = arr.difference,
+ hasOwn = Object.prototype.hasOwnProperty,
+ isFunction = is.isFunction;
+
+ function _merge(target, source) {
+ var name, s;
+ for (name in source) {
+ if (hasOwn.call(source, name)) {
+ s = source[name];
+ if (!(name in target) || (target[name] !== s)) {
+ target[name] = s;
+ }
+ }
+ }
+ return target;
+ }
+
+ function _deepMerge(target, source) {
+ var name, s, t;
+ for (name in source) {
+ if (hasOwn.call(source, name)) {
+ s = source[name];
+ t = target[name];
+ if (!deepEqual(t, s)) {
+ if (isHash(t) && isHash(s)) {
+ target[name] = _deepMerge(t, s);
+ } else if (isHash(s)) {
+ target[name] = _deepMerge({}, s);
+ } else {
+ target[name] = s;
+ }
+ }
+ }
+ }
+ return target;
+ }
+
+
+ function merge(obj) {
+ if (!obj) {
+ obj = {};
+ }
+ for (var i = 1, l = arguments.length; i < l; i++) {
+ _merge(obj, arguments[i]);
+ }
+ return obj; // Object
+ }
+
+ function deepMerge(obj) {
+ if (!obj) {
+ obj = {};
+ }
+ for (var i = 1, l = arguments.length; i < l; i++) {
+ _deepMerge(obj, arguments[i]);
+ }
+ return obj; // Object
+ }
+
+
+ function extend(parent, child) {
+ var proto = parent.prototype || parent;
+ merge(proto, child);
+ return parent;
+ }
+
+ function forEach(hash, iterator, scope) {
+ if (!isHash(hash) || !isFunction(iterator)) {
+ throw new TypeError();
+ }
+ var objKeys = keys(hash), key;
+ for (var i = 0, len = objKeys.length; i < len; ++i) {
+ key = objKeys[i];
+ iterator.call(scope || hash, hash[key], key, hash);
+ }
+ return hash;
+ }
+
+ function filter(hash, iterator, scope) {
+ if (!isHash(hash) || !isFunction(iterator)) {
+ throw new TypeError();
+ }
+ var objKeys = keys(hash), key, value, ret = {};
+ for (var i = 0, len = objKeys.length; i < len; ++i) {
+ key = objKeys[i];
+ value = hash[key];
+ if (iterator.call(scope || hash, value, key, hash)) {
+ ret[key] = value;
+ }
+ }
+ return ret;
+ }
+
+ function values(hash) {
+ if (!isHash(hash)) {
+ throw new TypeError();
+ }
+ var objKeys = keys(hash), ret = [];
+ for (var i = 0, len = objKeys.length; i < len; ++i) {
+ ret.push(hash[objKeys[i]]);
+ }
+ return ret;
+ }
+
+
+ function keys(hash) {
+ if (!isHash(hash)) {
+ throw new TypeError();
+ }
+ var ret = [];
+ for (var i in hash) {
+ if (hasOwn.call(hash, i)) {
+ ret.push(i);
+ }
+ }
+ return ret;
+ }
+
+ function invert(hash) {
+ if (!isHash(hash)) {
+ throw new TypeError();
+ }
+ var objKeys = keys(hash), key, ret = {};
+ for (var i = 0, len = objKeys.length; i < len; ++i) {
+ key = objKeys[i];
+ ret[hash[key]] = key;
+ }
+ return ret;
+ }
+
+ function toArray(hash) {
+ if (!isHash(hash)) {
+ throw new TypeError();
+ }
+ var objKeys = keys(hash), key, ret = [];
+ for (var i = 0, len = objKeys.length; i < len; ++i) {
+ key = objKeys[i];
+ ret.push([key, hash[key]]);
+ }
+ return ret;
+ }
+
+ function omit(hash, omitted) {
+ if (!isHash(hash)) {
+ throw new TypeError();
+ }
+ if (isString(omitted)) {
+ omitted = [omitted];
+ }
+ var objKeys = difference(keys(hash), omitted), key, ret = {};
+ for (var i = 0, len = objKeys.length; i < len; ++i) {
+ key = objKeys[i];
+ ret[key] = hash[key];
+ }
+ return ret;
+ }
+
+ var hash = {
+ forEach: forEach,
+ filter: filter,
+ invert: invert,
+ values: values,
+ toArray: toArray,
+ keys: keys,
+ omit: omit
+ };
+
+
+ var obj = {
+ extend: extend,
+ merge: merge,
+ deepMerge: deepMerge,
+ omit: omit
+ };
+
+ var ret = extended.define(is.isObject, obj).define(isHash, hash).define(is.isFunction, {extend: extend}).expose({hash: hash}).expose(obj);
+ var orig = ret.extend;
+ ret.extend = function __extend() {
+ if (arguments.length === 1) {
+ return orig.extend.apply(ret, arguments);
+ } else {
+ extend.apply(null, arguments);
+ }
+ };
+ return ret;
+
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineObject(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js"), __webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"), __webpack_require__(/*! array-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js"));
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/promise-extended/index.js":
+/*!****************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/promise-extended/index.js ***!
+ \****************************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+ /*global setImmediate, MessageChannel*/
+
+
+ function definePromise(declare, extended, array, is, fn, args) {
+
+ var forEach = array.forEach,
+ isUndefinedOrNull = is.isUndefinedOrNull,
+ isArray = is.isArray,
+ isFunction = is.isFunction,
+ isBoolean = is.isBoolean,
+ bind = fn.bind,
+ bindIgnore = fn.bindIgnore,
+ argsToArray = args.argsToArray;
+
+ function createHandler(fn, promise) {
+ return function _handler() {
+ try {
+ when(fn.apply(null, arguments))
+ .addCallback(promise)
+ .addErrback(promise);
+ } catch (e) {
+ promise.errback(e);
+ }
+ };
+ }
+
+ var nextTick;
+ if (typeof setImmediate === "function") {
+ // In IE10, or use https://github.com/NobleJS/setImmediate
+ if (typeof window !== "undefined") {
+ nextTick = setImmediate.bind(window);
+ } else {
+ nextTick = setImmediate;
+ }
+ } else if (typeof process !== "undefined") {
+ // node
+ nextTick = function (cb) {
+ process.nextTick(cb);
+ };
+ } else if (typeof MessageChannel !== "undefined") {
+ // modern browsers
+ // http://www.nonblocking.io/2011/06/windownexttick.html
+ var channel = new MessageChannel();
+ // linked list of tasks (single, with head node)
+ var head = {}, tail = head;
+ channel.port1.onmessage = function () {
+ head = head.next;
+ var task = head.task;
+ delete head.task;
+ task();
+ };
+ nextTick = function (task) {
+ tail = tail.next = {task: task};
+ channel.port2.postMessage(0);
+ };
+ } else {
+ // old browsers
+ nextTick = function (task) {
+ setTimeout(task, 0);
+ };
+ }
+
+
+ //noinspection JSHint
+ var Promise = declare({
+ instance: {
+ __fired: false,
+
+ __results: null,
+
+ __error: null,
+
+ __errorCbs: null,
+
+ __cbs: null,
+
+ constructor: function () {
+ this.__errorCbs = [];
+ this.__cbs = [];
+ fn.bindAll(this, ["callback", "errback", "resolve", "classic", "__resolve", "addCallback", "addErrback"]);
+ },
+
+ __resolve: function () {
+ if (!this.__fired) {
+ this.__fired = true;
+ var cbs = this.__error ? this.__errorCbs : this.__cbs,
+ len = cbs.length, i,
+ results = this.__error || this.__results;
+ for (i = 0; i < len; i++) {
+ this.__callNextTick(cbs[i], results);
+ }
+
+ }
+ },
+
+ __callNextTick: function (cb, results) {
+ nextTick(function () {
+ cb.apply(this, results);
+ });
+ },
+
+ addCallback: function (cb) {
+ if (cb) {
+ if (isPromiseLike(cb) && cb.callback) {
+ cb = cb.callback;
+ }
+ if (this.__fired && this.__results) {
+ this.__callNextTick(cb, this.__results);
+ } else {
+ this.__cbs.push(cb);
+ }
+ }
+ return this;
+ },
+
+
+ addErrback: function (cb) {
+ if (cb) {
+ if (isPromiseLike(cb) && cb.errback) {
+ cb = cb.errback;
+ }
+ if (this.__fired && this.__error) {
+ this.__callNextTick(cb, this.__error);
+ } else {
+ this.__errorCbs.push(cb);
+ }
+ }
+ return this;
+ },
+
+ callback: function (args) {
+ if (!this.__fired) {
+ this.__results = arguments;
+ this.__resolve();
+ }
+ return this.promise();
+ },
+
+ errback: function (args) {
+ if (!this.__fired) {
+ this.__error = arguments;
+ this.__resolve();
+ }
+ return this.promise();
+ },
+
+ resolve: function (err, args) {
+ if (err) {
+ this.errback(err);
+ } else {
+ this.callback.apply(this, argsToArray(arguments, 1));
+ }
+ return this;
+ },
+
+ classic: function (cb) {
+ if ("function" === typeof cb) {
+ this.addErrback(function (err) {
+ cb(err);
+ });
+ this.addCallback(function () {
+ cb.apply(this, [null].concat(argsToArray(arguments)));
+ });
+ }
+ return this;
+ },
+
+ then: function (callback, errback) {
+
+ var promise = new Promise(), errorHandler = promise;
+ if (isFunction(errback)) {
+ errorHandler = createHandler(errback, promise);
+ }
+ this.addErrback(errorHandler);
+ if (isFunction(callback)) {
+ this.addCallback(createHandler(callback, promise));
+ } else {
+ this.addCallback(promise);
+ }
+
+ return promise.promise();
+ },
+
+ both: function (callback) {
+ return this.then(callback, callback);
+ },
+
+ promise: function () {
+ var ret = {
+ then: bind(this, "then"),
+ both: bind(this, "both"),
+ promise: function () {
+ return ret;
+ }
+ };
+ forEach(["addCallback", "addErrback", "classic"], function (action) {
+ ret[action] = bind(this, function () {
+ this[action].apply(this, arguments);
+ return ret;
+ });
+ }, this);
+
+ return ret;
+ }
+
+
+ }
+ });
+
+
+ var PromiseList = Promise.extend({
+ instance: {
+
+ /*@private*/
+ __results: null,
+
+ /*@private*/
+ __errors: null,
+
+ /*@private*/
+ __promiseLength: 0,
+
+ /*@private*/
+ __defLength: 0,
+
+ /*@private*/
+ __firedLength: 0,
+
+ normalizeResults: false,
+
+ constructor: function (defs, normalizeResults) {
+ this.__errors = [];
+ this.__results = [];
+ this.normalizeResults = isBoolean(normalizeResults) ? normalizeResults : false;
+ this._super(arguments);
+ if (defs && defs.length) {
+ this.__defLength = defs.length;
+ forEach(defs, this.__addPromise, this);
+ } else {
+ this.__resolve();
+ }
+ },
+
+ __addPromise: function (promise, i) {
+ promise.then(
+ bind(this, function () {
+ var args = argsToArray(arguments);
+ args.unshift(i);
+ this.callback.apply(this, args);
+ }),
+ bind(this, function () {
+ var args = argsToArray(arguments);
+ args.unshift(i);
+ this.errback.apply(this, args);
+ })
+ );
+ },
+
+ __resolve: function () {
+ if (!this.__fired) {
+ this.__fired = true;
+ var cbs = this.__errors.length ? this.__errorCbs : this.__cbs,
+ len = cbs.length, i,
+ results = this.__errors.length ? this.__errors : this.__results;
+ for (i = 0; i < len; i++) {
+ this.__callNextTick(cbs[i], results);
+ }
+
+ }
+ },
+
+ __callNextTick: function (cb, results) {
+ nextTick(function () {
+ cb.apply(null, [results]);
+ });
+ },
+
+ addCallback: function (cb) {
+ if (cb) {
+ if (isPromiseLike(cb) && cb.callback) {
+ cb = bind(cb, "callback");
+ }
+ if (this.__fired && !this.__errors.length) {
+ this.__callNextTick(cb, this.__results);
+ } else {
+ this.__cbs.push(cb);
+ }
+ }
+ return this;
+ },
+
+ addErrback: function (cb) {
+ if (cb) {
+ if (isPromiseLike(cb) && cb.errback) {
+ cb = bind(cb, "errback");
+ }
+ if (this.__fired && this.__errors.length) {
+ this.__callNextTick(cb, this.__errors);
+ } else {
+ this.__errorCbs.push(cb);
+ }
+ }
+ return this;
+ },
+
+
+ callback: function (i) {
+ if (this.__fired) {
+ throw new Error("Already fired!");
+ }
+ var args = argsToArray(arguments);
+ if (this.normalizeResults) {
+ args = args.slice(1);
+ args = args.length === 1 ? args.pop() : args;
+ }
+ this.__results[i] = args;
+ this.__firedLength++;
+ if (this.__firedLength === this.__defLength) {
+ this.__resolve();
+ }
+ return this.promise();
+ },
+
+
+ errback: function (i) {
+ if (this.__fired) {
+ throw new Error("Already fired!");
+ }
+ var args = argsToArray(arguments);
+ if (this.normalizeResults) {
+ args = args.slice(1);
+ args = args.length === 1 ? args.pop() : args;
+ }
+ this.__errors[i] = args;
+ this.__firedLength++;
+ if (this.__firedLength === this.__defLength) {
+ this.__resolve();
+ }
+ return this.promise();
+ }
+
+ }
+ });
+
+
+ function callNext(list, results, propogate) {
+ var ret = new Promise().callback();
+ forEach(list, function (listItem) {
+ ret = ret.then(propogate ? listItem : bindIgnore(null, listItem));
+ if (!propogate) {
+ ret = ret.then(function (res) {
+ results.push(res);
+ return results;
+ });
+ }
+ });
+ return ret;
+ }
+
+ function isPromiseLike(obj) {
+ return !isUndefinedOrNull(obj) && (isFunction(obj.then));
+ }
+
+ function wrapThenPromise(p) {
+ var ret = new Promise();
+ p.then(bind(ret, "callback"), bind(ret, "errback"));
+ return ret.promise();
+ }
+
+ function when(args) {
+ var p;
+ args = argsToArray(arguments);
+ if (!args.length) {
+ p = new Promise().callback(args).promise();
+ } else if (args.length === 1) {
+ args = args.pop();
+ if (isPromiseLike(args)) {
+ if (args.addCallback && args.addErrback) {
+ p = new Promise();
+ args.addCallback(p.callback);
+ args.addErrback(p.errback);
+ } else {
+ p = wrapThenPromise(args);
+ }
+ } else if (isArray(args) && array.every(args, isPromiseLike)) {
+ p = new PromiseList(args, true).promise();
+ } else {
+ p = new Promise().callback(args);
+ }
+ } else {
+ p = new PromiseList(array.map(args, function (a) {
+ return when(a);
+ }), true).promise();
+ }
+ return p;
+
+ }
+
+ function wrap(fn, scope) {
+ return function _wrap() {
+ var ret = new Promise();
+ var args = argsToArray(arguments);
+ args.push(ret.resolve);
+ fn.apply(scope || this, args);
+ return ret.promise();
+ };
+ }
+
+ function serial(list) {
+ if (isArray(list)) {
+ return callNext(list, [], false);
+ } else {
+ throw new Error("When calling promise.serial the first argument must be an array");
+ }
+ }
+
+
+ function chain(list) {
+ if (isArray(list)) {
+ return callNext(list, [], true);
+ } else {
+ throw new Error("When calling promise.serial the first argument must be an array");
+ }
+ }
+
+
+ function wait(args, fn) {
+ args = argsToArray(arguments);
+ var resolved = false;
+ fn = args.pop();
+ var p = when(args);
+ return function waiter() {
+ if (!resolved) {
+ args = arguments;
+ return p.then(bind(this, function doneWaiting() {
+ resolved = true;
+ return fn.apply(this, args);
+ }));
+ } else {
+ return when(fn.apply(this, arguments));
+ }
+ };
+ }
+
+ function createPromise() {
+ return new Promise();
+ }
+
+ function createPromiseList(promises) {
+ return new PromiseList(promises, true).promise();
+ }
+
+ function createRejected(val) {
+ return createPromise().errback(val);
+ }
+
+ function createResolved(val) {
+ return createPromise().callback(val);
+ }
+
+
+ return extended
+ .define({
+ isPromiseLike: isPromiseLike
+ }).expose({
+ isPromiseLike: isPromiseLike,
+ when: when,
+ wrap: wrap,
+ wait: wait,
+ serial: serial,
+ chain: chain,
+ Promise: Promise,
+ PromiseList: PromiseList,
+ promise: createPromise,
+ defer: createPromise,
+ deferredList: createPromiseList,
+ reject: createRejected,
+ resolve: createResolved
+ });
+
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = definePromise(__webpack_require__(/*! declare.js */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/declare.js/index.js"), __webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js"), __webpack_require__(/*! array-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js"), __webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"), __webpack_require__(/*! function-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/function-extended/index.js"), __webpack_require__(/*! arguments-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/arguments-extended/index.js"));
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/string-extended/index.js":
+/*!***************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/string-extended/index.js ***!
+ \***************************************************************************************************/
+/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
+
+(function () {
+ "use strict";
+
+ function defineString(extended, is, date, arr) {
+
+ var stringify;
+ if (typeof JSON === "undefined") {
+ /*
+ json2.js
+ 2012-10-08
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+ */
+
+ (function () {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ var isPrimitive = is.tester().isString().isNumber().isBoolean().tester();
+
+ function toJSON(obj) {
+ if (is.isDate(obj)) {
+ return isFinite(obj.valueOf()) ? obj.getUTCFullYear() + '-' +
+ f(obj.getUTCMonth() + 1) + '-' +
+ f(obj.getUTCDate()) + 'T' +
+ f(obj.getUTCHours()) + ':' +
+ f(obj.getUTCMinutes()) + ':' +
+ f(obj.getUTCSeconds()) + 'Z'
+ : null;
+ } else if (isPrimitive(obj)) {
+ return obj.valueOf();
+ }
+ return obj;
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"': '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+ var i, k, v, length, mind = gap, partial, value = holder[key];
+ if (value) {
+ value = toJSON(value);
+ }
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+ case 'number':
+ return isFinite(value) ? String(value) : 'null';
+ case 'boolean':
+ case 'null':
+ return String(value);
+ case 'object':
+ if (!value) {
+ return 'null';
+ }
+ gap += indent;
+ partial = [];
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+ v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+ v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+ stringify = function (value, replacer, space) {
+ var i;
+ gap = '';
+ indent = '';
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+ return str('', {'': value});
+ };
+ }());
+ } else {
+ stringify = JSON.stringify;
+ }
+
+
+ var isHash = is.isHash, aSlice = Array.prototype.slice;
+
+ var FORMAT_REGEX = /%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g;
+ var INTERP_REGEX = /\{(?:\[([^\[|\]]*)\])?(\w+)\}/g;
+ var STR_FORMAT = /(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/;
+ var OBJECT_FORMAT = /([1-9][0-9]*)$/g;
+
+ function formatString(string, format) {
+ var ret = string;
+ if (STR_FORMAT.test(format)) {
+ var match = format.match(STR_FORMAT);
+ var isLeftJustified = match[1], padChar = match[3], width = match[4];
+ if (width) {
+ width = parseInt(width, 10);
+ if (ret.length < width) {
+ ret = pad(ret, width, padChar, isLeftJustified);
+ } else {
+ ret = truncate(ret, width);
+ }
+ }
+ }
+ return ret;
+ }
+
+ function formatNumber(number, format) {
+ var ret;
+ if (is.isNumber(number)) {
+ ret = "" + number;
+ if (STR_FORMAT.test(format)) {
+ var match = format.match(STR_FORMAT);
+ var isLeftJustified = match[1], signed = match[2], padChar = match[3], width = match[4];
+ if (signed) {
+ ret = (number > 0 ? "+" : "") + ret;
+ }
+ if (width) {
+ width = parseInt(width, 10);
+ if (ret.length < width) {
+ ret = pad(ret, width, padChar || "0", isLeftJustified);
+ } else {
+ ret = truncate(ret, width);
+ }
+ }
+
+ }
+ } else {
+ throw new Error("stringExtended.format : when using %d the parameter must be a number!");
+ }
+ return ret;
+ }
+
+ function formatObject(object, format) {
+ var ret, match = format.match(OBJECT_FORMAT), spacing = 0;
+ if (match) {
+ spacing = parseInt(match[0], 10);
+ if (isNaN(spacing)) {
+ spacing = 0;
+ }
+ }
+ try {
+ ret = stringify(object, null, spacing);
+ } catch (e) {
+ throw new Error("stringExtended.format : Unable to parse json from ", object);
+ }
+ return ret;
+ }
+
+
+ var styles = {
+ //styles
+ bold: 1,
+ bright: 1,
+ italic: 3,
+ underline: 4,
+ blink: 5,
+ inverse: 7,
+ crossedOut: 9,
+
+ red: 31,
+ green: 32,
+ yellow: 33,
+ blue: 34,
+ magenta: 35,
+ cyan: 36,
+ white: 37,
+
+ redBackground: 41,
+ greenBackground: 42,
+ yellowBackground: 43,
+ blueBackground: 44,
+ magentaBackground: 45,
+ cyanBackground: 46,
+ whiteBackground: 47,
+
+ encircled: 52,
+ overlined: 53,
+ grey: 90,
+ black: 90
+ };
+
+ var characters = {
+ SMILEY: "☺",
+ SOLID_SMILEY: "☻",
+ HEART: "♥",
+ DIAMOND: "♦",
+ CLOVE: "♣",
+ SPADE: "♠",
+ DOT: "•",
+ SQUARE_CIRCLE: "◘",
+ CIRCLE: "○",
+ FILLED_SQUARE_CIRCLE: "◙",
+ MALE: "♂",
+ FEMALE: "♀",
+ EIGHT_NOTE: "♪",
+ DOUBLE_EIGHTH_NOTE: "♫",
+ SUN: "☼",
+ PLAY: "►",
+ REWIND: "◄",
+ UP_DOWN: "↕",
+ PILCROW: "¶",
+ SECTION: "§",
+ THICK_MINUS: "▬",
+ SMALL_UP_DOWN: "↨",
+ UP_ARROW: "↑",
+ DOWN_ARROW: "↓",
+ RIGHT_ARROW: "→",
+ LEFT_ARROW: "←",
+ RIGHT_ANGLE: "∟",
+ LEFT_RIGHT_ARROW: "↔",
+ TRIANGLE: "▲",
+ DOWN_TRIANGLE: "▼",
+ HOUSE: "⌂",
+ C_CEDILLA: "Ç",
+ U_UMLAUT: "ü",
+ E_ACCENT: "é",
+ A_LOWER_CIRCUMFLEX: "â",
+ A_LOWER_UMLAUT: "ä",
+ A_LOWER_GRAVE_ACCENT: "à",
+ A_LOWER_CIRCLE_OVER: "å",
+ C_LOWER_CIRCUMFLEX: "ç",
+ E_LOWER_CIRCUMFLEX: "ê",
+ E_LOWER_UMLAUT: "ë",
+ E_LOWER_GRAVE_ACCENT: "è",
+ I_LOWER_UMLAUT: "ï",
+ I_LOWER_CIRCUMFLEX: "î",
+ I_LOWER_GRAVE_ACCENT: "ì",
+ A_UPPER_UMLAUT: "Ä",
+ A_UPPER_CIRCLE: "Å",
+ E_UPPER_ACCENT: "É",
+ A_E_LOWER: "æ",
+ A_E_UPPER: "Æ",
+ O_LOWER_CIRCUMFLEX: "ô",
+ O_LOWER_UMLAUT: "ö",
+ O_LOWER_GRAVE_ACCENT: "ò",
+ U_LOWER_CIRCUMFLEX: "û",
+ U_LOWER_GRAVE_ACCENT: "ù",
+ Y_LOWER_UMLAUT: "ÿ",
+ O_UPPER_UMLAUT: "Ö",
+ U_UPPER_UMLAUT: "Ü",
+ CENTS: "¢",
+ POUND: "£",
+ YEN: "¥",
+ CURRENCY: "¤",
+ PTS: "₧",
+ FUNCTION: "ƒ",
+ A_LOWER_ACCENT: "á",
+ I_LOWER_ACCENT: "í",
+ O_LOWER_ACCENT: "ó",
+ U_LOWER_ACCENT: "ú",
+ N_LOWER_TILDE: "ñ",
+ N_UPPER_TILDE: "Ñ",
+ A_SUPER: "ª",
+ O_SUPER: "º",
+ UPSIDEDOWN_QUESTION: "¿",
+ SIDEWAYS_L: "⌐",
+ NEGATION: "¬",
+ ONE_HALF: "½",
+ ONE_FOURTH: "¼",
+ UPSIDEDOWN_EXCLAMATION: "¡",
+ DOUBLE_LEFT: "«",
+ DOUBLE_RIGHT: "»",
+ LIGHT_SHADED_BOX: "░",
+ MEDIUM_SHADED_BOX: "▒",
+ DARK_SHADED_BOX: "▓",
+ VERTICAL_LINE: "│",
+ MAZE__SINGLE_RIGHT_T: "┤",
+ MAZE_SINGLE_RIGHT_TOP: "┐",
+ MAZE_SINGLE_RIGHT_BOTTOM_SMALL: "┘",
+ MAZE_SINGLE_LEFT_TOP_SMALL: "┌",
+ MAZE_SINGLE_LEFT_BOTTOM_SMALL: "└",
+ MAZE_SINGLE_LEFT_T: "├",
+ MAZE_SINGLE_BOTTOM_T: "┴",
+ MAZE_SINGLE_TOP_T: "┬",
+ MAZE_SINGLE_CENTER: "┼",
+ MAZE_SINGLE_HORIZONTAL_LINE: "─",
+ MAZE_SINGLE_RIGHT_DOUBLECENTER_T: "╡",
+ MAZE_SINGLE_RIGHT_DOUBLE_BL: "╛",
+ MAZE_SINGLE_RIGHT_DOUBLE_T: "╢",
+ MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP: "╖",
+ MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP: "╕",
+ MAZE_SINGLE_LEFT_DOUBLE_T: "╞",
+ MAZE_SINGLE_BOTTOM_DOUBLE_T: "╧",
+ MAZE_SINGLE_TOP_DOUBLE_T: "╤",
+ MAZE_SINGLE_TOP_DOUBLECENTER_T: "╥",
+ MAZE_SINGLE_BOTTOM_DOUBLECENTER_T: "╨",
+ MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM: "╘",
+ MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP: "╒",
+ MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP: "╓",
+ MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM: "╙",
+ MAZE_SINGLE_LEFT_TOP: "Γ",
+ MAZE_SINGLE_RIGHT_BOTTOM: "╜",
+ MAZE_SINGLE_LEFT_CENTER: "╟",
+ MAZE_SINGLE_DOUBLECENTER_CENTER: "╫",
+ MAZE_SINGLE_DOUBLECROSS_CENTER: "╪",
+ MAZE_DOUBLE_LEFT_CENTER: "╣",
+ MAZE_DOUBLE_VERTICAL: "║",
+ MAZE_DOUBLE_RIGHT_TOP: "╗",
+ MAZE_DOUBLE_RIGHT_BOTTOM: "╝",
+ MAZE_DOUBLE_LEFT_BOTTOM: "╚",
+ MAZE_DOUBLE_LEFT_TOP: "╔",
+ MAZE_DOUBLE_BOTTOM_T: "╩",
+ MAZE_DOUBLE_TOP_T: "╦",
+ MAZE_DOUBLE_LEFT_T: "╠",
+ MAZE_DOUBLE_HORIZONTAL: "═",
+ MAZE_DOUBLE_CROSS: "╬",
+ SOLID_RECTANGLE: "█",
+ THICK_LEFT_VERTICAL: "▌",
+ THICK_RIGHT_VERTICAL: "▐",
+ SOLID_SMALL_RECTANGLE_BOTTOM: "▄",
+ SOLID_SMALL_RECTANGLE_TOP: "▀",
+ PHI_UPPER: "Φ",
+ INFINITY: "∞",
+ INTERSECTION: "∩",
+ DEFINITION: "≡",
+ PLUS_MINUS: "±",
+ GT_EQ: "≥",
+ LT_EQ: "≤",
+ THEREFORE: "⌠",
+ SINCE: "∵",
+ DOESNOT_EXIST: "∄",
+ EXISTS: "∃",
+ FOR_ALL: "∀",
+ EXCLUSIVE_OR: "⊕",
+ BECAUSE: "⌡",
+ DIVIDE: "÷",
+ APPROX: "≈",
+ DEGREE: "°",
+ BOLD_DOT: "∙",
+ DOT_SMALL: "·",
+ CHECK: "√",
+ ITALIC_X: "✗",
+ SUPER_N: "ⁿ",
+ SQUARED: "²",
+ CUBED: "³",
+ SOLID_BOX: "■",
+ PERMILE: "‰",
+ REGISTERED_TM: "®",
+ COPYRIGHT: "©",
+ TRADEMARK: "™",
+ BETA: "β",
+ GAMMA: "γ",
+ ZETA: "ζ",
+ ETA: "η",
+ IOTA: "ι",
+ KAPPA: "κ",
+ LAMBDA: "λ",
+ NU: "ν",
+ XI: "ξ",
+ OMICRON: "ο",
+ RHO: "ρ",
+ UPSILON: "υ",
+ CHI_LOWER: "φ",
+ CHI_UPPER: "χ",
+ PSI: "ψ",
+ ALPHA: "α",
+ ESZETT: "ß",
+ PI: "π",
+ SIGMA_UPPER: "Σ",
+ SIGMA_LOWER: "σ",
+ MU: "µ",
+ TAU: "τ",
+ THETA: "Θ",
+ OMEGA: "Ω",
+ DELTA: "δ",
+ PHI_LOWER: "φ",
+ EPSILON: "ε"
+ };
+
+ function pad(string, length, ch, end) {
+ string = "" + string; //check for numbers
+ ch = ch || " ";
+ var strLen = string.length;
+ while (strLen < length) {
+ if (end) {
+ string += ch;
+ } else {
+ string = ch + string;
+ }
+ strLen++;
+ }
+ return string;
+ }
+
+ function truncate(string, length, end) {
+ var ret = string;
+ if (is.isString(ret)) {
+ if (string.length > length) {
+ if (end) {
+ var l = string.length;
+ ret = string.substring(l - length, l);
+ } else {
+ ret = string.substring(0, length);
+ }
+ }
+ } else {
+ ret = truncate("" + ret, length);
+ }
+ return ret;
+ }
+
+ function format(str, obj) {
+ if (obj instanceof Array) {
+ var i = 0, len = obj.length;
+ //find the matches
+ return str.replace(FORMAT_REGEX, function (m, format, type) {
+ var replacer, ret;
+ if (i < len) {
+ replacer = obj[i++];
+ } else {
+ //we are out of things to replace with so
+ //just return the match?
+ return m;
+ }
+ if (m === "%s" || m === "%d" || m === "%D") {
+ //fast path!
+ ret = replacer + "";
+ } else if (m === "%Z") {
+ ret = replacer.toUTCString();
+ } else if (m === "%j") {
+ try {
+ ret = stringify(replacer);
+ } catch (e) {
+ throw new Error("stringExtended.format : Unable to parse json from ", replacer);
+ }
+ } else {
+ format = format.replace(/^\[|\]$/g, "");
+ switch (type) {
+ case "s":
+ ret = formatString(replacer, format);
+ break;
+ case "d":
+ ret = formatNumber(replacer, format);
+ break;
+ case "j":
+ ret = formatObject(replacer, format);
+ break;
+ case "D":
+ ret = date.format(replacer, format);
+ break;
+ case "Z":
+ ret = date.format(replacer, format, true);
+ break;
+ }
+ }
+ return ret;
+ });
+ } else if (isHash(obj)) {
+ return str.replace(INTERP_REGEX, function (m, format, value) {
+ value = obj[value];
+ if (!is.isUndefined(value)) {
+ if (format) {
+ if (is.isString(value)) {
+ return formatString(value, format);
+ } else if (is.isNumber(value)) {
+ return formatNumber(value, format);
+ } else if (is.isDate(value)) {
+ return date.format(value, format);
+ } else if (is.isObject(value)) {
+ return formatObject(value, format);
+ }
+ } else {
+ return "" + value;
+ }
+ }
+ return m;
+ });
+ } else {
+ var args = aSlice.call(arguments).slice(1);
+ return format(str, args);
+ }
+ }
+
+ function toArray(testStr, delim) {
+ var ret = [];
+ if (testStr) {
+ if (testStr.indexOf(delim) > 0) {
+ ret = testStr.replace(/\s+/g, "").split(delim);
+ }
+ else {
+ ret.push(testStr);
+ }
+ }
+ return ret;
+ }
+
+ function multiply(str, times) {
+ var ret = [];
+ if (times) {
+ for (var i = 0; i < times; i++) {
+ ret.push(str);
+ }
+ }
+ return ret.join("");
+ }
+
+
+ function style(str, options) {
+ var ret, i, l;
+ if (options) {
+ if (is.isArray(str)) {
+ ret = [];
+ for (i = 0, l = str.length; i < l; i++) {
+ ret.push(style(str[i], options));
+ }
+ } else if (options instanceof Array) {
+ ret = str;
+ for (i = 0, l = options.length; i < l; i++) {
+ ret = style(ret, options[i]);
+ }
+ } else if (options in styles) {
+ ret = '\x1B[' + styles[options] + 'm' + str + '\x1B[0m';
+ }
+ }
+ return ret;
+ }
+
+ function escape(str, except) {
+ return str.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, function (ch) {
+ if (except && arr.indexOf(except, ch) !== -1) {
+ return ch;
+ }
+ return "\\" + ch;
+ });
+ }
+
+ function trim(str) {
+ return str.replace(/^\s*|\s*$/g, "");
+ }
+
+ function trimLeft(str) {
+ return str.replace(/^\s*/, "");
+ }
+
+ function trimRight(str) {
+ return str.replace(/\s*$/, "");
+ }
+
+ function isEmpty(str) {
+ return str.length === 0;
+ }
+
+
+ var string = {
+ toArray: toArray,
+ pad: pad,
+ truncate: truncate,
+ multiply: multiply,
+ format: format,
+ style: style,
+ escape: escape,
+ trim: trim,
+ trimLeft: trimLeft,
+ trimRight: trimRight,
+ isEmpty: isEmpty
+ };
+ return extended.define(is.isString, string).define(is.isArray, {style: style}).expose(string).expose({characters: characters});
+ }
+
+ if (true) {
+ if ( true && module.exports) {
+ module.exports = defineString(__webpack_require__(/*! extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/extended/index.js"), __webpack_require__(/*! is-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/is-extended/index.js"), __webpack_require__(/*! date-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/date-extended/index.js"), __webpack_require__(/*! array-extended */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/array-extended/index.js"));
+
+ }
+ } else {}
+
+}).call(this);
+
+
+
+
+
+
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/underscore/underscore-node-f.cjs":
+/*!***********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/underscore/underscore-node-f.cjs ***!
+ \***********************************************************************************************************/
+/***/ ((__unused_webpack_module, exports) => {
+
+// Underscore.js 1.13.1
+// https://underscorejs.org
+// (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
+// Underscore may be freely distributed under the MIT license.
+
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+
+// Current version.
+var VERSION = '1.13.1';
+
+// Establish the root object, `window` (`self`) in the browser, `global`
+// on the server, or `this` in some virtual machines. We use `self`
+// instead of `window` for `WebWorker` support.
+var root = typeof self == 'object' && self.self === self && self ||
+ typeof global == 'object' && global.global === global && global ||
+ Function('return this')() ||
+ {};
+
+// Save bytes in the minified (but not gzipped) version:
+var ArrayProto = Array.prototype, ObjProto = Object.prototype;
+var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;
+
+// Create quick reference variables for speed access to core prototypes.
+var push = ArrayProto.push,
+ slice = ArrayProto.slice,
+ toString = ObjProto.toString,
+ hasOwnProperty = ObjProto.hasOwnProperty;
+
+// Modern feature detection.
+var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined',
+ supportsDataView = typeof DataView !== 'undefined';
+
+// All **ECMAScript 5+** native function implementations that we hope to use
+// are declared here.
+var nativeIsArray = Array.isArray,
+ nativeKeys = Object.keys,
+ nativeCreate = Object.create,
+ nativeIsView = supportsArrayBuffer && ArrayBuffer.isView;
+
+// Create references to these builtin functions because we override them.
+var _isNaN = isNaN,
+ _isFinite = isFinite;
+
+// Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
+var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
+var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
+ 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
+
+// The largest integer that can be represented exactly.
+var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
+
+// Some functions take a variable number of arguments, or a few expected
+// arguments at the beginning and then a variable number of values to operate
+// on. This helper accumulates all remaining arguments past the function’s
+// argument length (or an explicit `startIndex`), into an array that becomes
+// the last argument. Similar to ES6’s "rest parameter".
+function restArguments(func, startIndex) {
+ startIndex = startIndex == null ? func.length - 1 : +startIndex;
+ return function() {
+ var length = Math.max(arguments.length - startIndex, 0),
+ rest = Array(length),
+ index = 0;
+ for (; index < length; index++) {
+ rest[index] = arguments[index + startIndex];
+ }
+ switch (startIndex) {
+ case 0: return func.call(this, rest);
+ case 1: return func.call(this, arguments[0], rest);
+ case 2: return func.call(this, arguments[0], arguments[1], rest);
+ }
+ var args = Array(startIndex + 1);
+ for (index = 0; index < startIndex; index++) {
+ args[index] = arguments[index];
+ }
+ args[startIndex] = rest;
+ return func.apply(this, args);
+ };
+}
+
+// Is a given variable an object?
+function isObject(obj) {
+ var type = typeof obj;
+ return type === 'function' || type === 'object' && !!obj;
+}
+
+// Is a given value equal to null?
+function isNull(obj) {
+ return obj === null;
+}
+
+// Is a given variable undefined?
+function isUndefined(obj) {
+ return obj === void 0;
+}
+
+// Is a given value a boolean?
+function isBoolean(obj) {
+ return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
+}
+
+// Is a given value a DOM element?
+function isElement(obj) {
+ return !!(obj && obj.nodeType === 1);
+}
+
+// Internal function for creating a `toString`-based type tester.
+function tagTester(name) {
+ var tag = '[object ' + name + ']';
+ return function(obj) {
+ return toString.call(obj) === tag;
+ };
+}
+
+var isString = tagTester('String');
+
+var isNumber = tagTester('Number');
+
+var isDate = tagTester('Date');
+
+var isRegExp = tagTester('RegExp');
+
+var isError = tagTester('Error');
+
+var isSymbol = tagTester('Symbol');
+
+var isArrayBuffer = tagTester('ArrayBuffer');
+
+var isFunction = tagTester('Function');
+
+// Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old
+// v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).
+var nodelist = root.document && root.document.childNodes;
+if ( true && typeof Int8Array != 'object' && typeof nodelist != 'function') {
+ isFunction = function(obj) {
+ return typeof obj == 'function' || false;
+ };
+}
+
+var isFunction$1 = isFunction;
+
+var hasObjectTag = tagTester('Object');
+
+// In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`.
+// In IE 11, the most common among them, this problem also applies to
+// `Map`, `WeakMap` and `Set`.
+var hasStringTagBug = (
+ supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8)))
+ ),
+ isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map));
+
+var isDataView = tagTester('DataView');
+
+// In IE 10 - Edge 13, we need a different heuristic
+// to determine whether an object is a `DataView`.
+function ie10IsDataView(obj) {
+ return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer);
+}
+
+var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView);
+
+// Is a given value an array?
+// Delegates to ECMA5's native `Array.isArray`.
+var isArray = nativeIsArray || tagTester('Array');
+
+// Internal function to check whether `key` is an own property name of `obj`.
+function has$1(obj, key) {
+ return obj != null && hasOwnProperty.call(obj, key);
+}
+
+var isArguments = tagTester('Arguments');
+
+// Define a fallback version of the method in browsers (ahem, IE < 9), where
+// there isn't any inspectable "Arguments" type.
+(function() {
+ if (!isArguments(arguments)) {
+ isArguments = function(obj) {
+ return has$1(obj, 'callee');
+ };
+ }
+}());
+
+var isArguments$1 = isArguments;
+
+// Is a given object a finite number?
+function isFinite$1(obj) {
+ return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));
+}
+
+// Is the given value `NaN`?
+function isNaN$1(obj) {
+ return isNumber(obj) && _isNaN(obj);
+}
+
+// Predicate-generating function. Often useful outside of Underscore.
+function constant(value) {
+ return function() {
+ return value;
+ };
+}
+
+// Common internal logic for `isArrayLike` and `isBufferLike`.
+function createSizePropertyCheck(getSizeProperty) {
+ return function(collection) {
+ var sizeProperty = getSizeProperty(collection);
+ return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX;
+ }
+}
+
+// Internal helper to generate a function to obtain property `key` from `obj`.
+function shallowProperty(key) {
+ return function(obj) {
+ return obj == null ? void 0 : obj[key];
+ };
+}
+
+// Internal helper to obtain the `byteLength` property of an object.
+var getByteLength = shallowProperty('byteLength');
+
+// Internal helper to determine whether we should spend extensive checks against
+// `ArrayBuffer` et al.
+var isBufferLike = createSizePropertyCheck(getByteLength);
+
+// Is a given value a typed array?
+var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
+function isTypedArray(obj) {
+ // `ArrayBuffer.isView` is the most future-proof, so use it when available.
+ // Otherwise, fall back on the above regular expression.
+ return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) :
+ isBufferLike(obj) && typedArrayPattern.test(toString.call(obj));
+}
+
+var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false);
+
+// Internal helper to obtain the `length` property of an object.
+var getLength = shallowProperty('length');
+
+// Internal helper to create a simple lookup structure.
+// `collectNonEnumProps` used to depend on `_.contains`, but this led to
+// circular imports. `emulatedSet` is a one-off solution that only works for
+// arrays of strings.
+function emulatedSet(keys) {
+ var hash = {};
+ for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true;
+ return {
+ contains: function(key) { return hash[key]; },
+ push: function(key) {
+ hash[key] = true;
+ return keys.push(key);
+ }
+ };
+}
+
+// Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't
+// be iterated by `for key in ...` and thus missed. Extends `keys` in place if
+// needed.
+function collectNonEnumProps(obj, keys) {
+ keys = emulatedSet(keys);
+ var nonEnumIdx = nonEnumerableProps.length;
+ var constructor = obj.constructor;
+ var proto = isFunction$1(constructor) && constructor.prototype || ObjProto;
+
+ // Constructor is a special case.
+ var prop = 'constructor';
+ if (has$1(obj, prop) && !keys.contains(prop)) keys.push(prop);
+
+ while (nonEnumIdx--) {
+ prop = nonEnumerableProps[nonEnumIdx];
+ if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) {
+ keys.push(prop);
+ }
+ }
+}
+
+// Retrieve the names of an object's own properties.
+// Delegates to **ECMAScript 5**'s native `Object.keys`.
+function keys(obj) {
+ if (!isObject(obj)) return [];
+ if (nativeKeys) return nativeKeys(obj);
+ var keys = [];
+ for (var key in obj) if (has$1(obj, key)) keys.push(key);
+ // Ahem, IE < 9.
+ if (hasEnumBug) collectNonEnumProps(obj, keys);
+ return keys;
+}
+
+// Is a given array, string, or object empty?
+// An "empty" object has no enumerable own-properties.
+function isEmpty(obj) {
+ if (obj == null) return true;
+ // Skip the more expensive `toString`-based type checks if `obj` has no
+ // `.length`.
+ var length = getLength(obj);
+ if (typeof length == 'number' && (
+ isArray(obj) || isString(obj) || isArguments$1(obj)
+ )) return length === 0;
+ return getLength(keys(obj)) === 0;
+}
+
+// Returns whether an object has a given set of `key:value` pairs.
+function isMatch(object, attrs) {
+ var _keys = keys(attrs), length = _keys.length;
+ if (object == null) return !length;
+ var obj = Object(object);
+ for (var i = 0; i < length; i++) {
+ var key = _keys[i];
+ if (attrs[key] !== obj[key] || !(key in obj)) return false;
+ }
+ return true;
+}
+
+// If Underscore is called as a function, it returns a wrapped object that can
+// be used OO-style. This wrapper holds altered versions of all functions added
+// through `_.mixin`. Wrapped objects may be chained.
+function _$1(obj) {
+ if (obj instanceof _$1) return obj;
+ if (!(this instanceof _$1)) return new _$1(obj);
+ this._wrapped = obj;
+}
+
+_$1.VERSION = VERSION;
+
+// Extracts the result from a wrapped and chained object.
+_$1.prototype.value = function() {
+ return this._wrapped;
+};
+
+// Provide unwrapping proxies for some methods used in engine operations
+// such as arithmetic and JSON stringification.
+_$1.prototype.valueOf = _$1.prototype.toJSON = _$1.prototype.value;
+
+_$1.prototype.toString = function() {
+ return String(this._wrapped);
+};
+
+// Internal function to wrap or shallow-copy an ArrayBuffer,
+// typed array or DataView to a new view, reusing the buffer.
+function toBufferView(bufferSource) {
+ return new Uint8Array(
+ bufferSource.buffer || bufferSource,
+ bufferSource.byteOffset || 0,
+ getByteLength(bufferSource)
+ );
+}
+
+// We use this string twice, so give it a name for minification.
+var tagDataView = '[object DataView]';
+
+// Internal recursive comparison function for `_.isEqual`.
+function eq(a, b, aStack, bStack) {
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
+ // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal).
+ if (a === b) return a !== 0 || 1 / a === 1 / b;
+ // `null` or `undefined` only equal to itself (strict comparison).
+ if (a == null || b == null) return false;
+ // `NaN`s are equivalent, but non-reflexive.
+ if (a !== a) return b !== b;
+ // Exhaust primitive checks
+ var type = typeof a;
+ if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
+ return deepEq(a, b, aStack, bStack);
+}
+
+// Internal recursive comparison function for `_.isEqual`.
+function deepEq(a, b, aStack, bStack) {
+ // Unwrap any wrapped objects.
+ if (a instanceof _$1) a = a._wrapped;
+ if (b instanceof _$1) b = b._wrapped;
+ // Compare `[[Class]]` names.
+ var className = toString.call(a);
+ if (className !== toString.call(b)) return false;
+ // Work around a bug in IE 10 - Edge 13.
+ if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) {
+ if (!isDataView$1(b)) return false;
+ className = tagDataView;
+ }
+ switch (className) {
+ // These types are compared by value.
+ case '[object RegExp]':
+ // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
+ case '[object String]':
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
+ // equivalent to `new String("5")`.
+ return '' + a === '' + b;
+ case '[object Number]':
+ // `NaN`s are equivalent, but non-reflexive.
+ // Object(NaN) is equivalent to NaN.
+ if (+a !== +a) return +b !== +b;
+ // An `egal` comparison is performed for other numeric values.
+ return +a === 0 ? 1 / +a === 1 / b : +a === +b;
+ case '[object Date]':
+ case '[object Boolean]':
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
+ // millisecond representations. Note that invalid dates with millisecond representations
+ // of `NaN` are not equivalent.
+ return +a === +b;
+ case '[object Symbol]':
+ return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
+ case '[object ArrayBuffer]':
+ case tagDataView:
+ // Coerce to typed array so we can fall through.
+ return deepEq(toBufferView(a), toBufferView(b), aStack, bStack);
+ }
+
+ var areArrays = className === '[object Array]';
+ if (!areArrays && isTypedArray$1(a)) {
+ var byteLength = getByteLength(a);
+ if (byteLength !== getByteLength(b)) return false;
+ if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true;
+ areArrays = true;
+ }
+ if (!areArrays) {
+ if (typeof a != 'object' || typeof b != 'object') return false;
+
+ // Objects with different constructors are not equivalent, but `Object`s or `Array`s
+ // from different frames are.
+ var aCtor = a.constructor, bCtor = b.constructor;
+ if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor &&
+ isFunction$1(bCtor) && bCtor instanceof bCtor)
+ && ('constructor' in a && 'constructor' in b)) {
+ return false;
+ }
+ }
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
+
+ // Initializing stack of traversed objects.
+ // It's done here since we only need them for objects and arrays comparison.
+ aStack = aStack || [];
+ bStack = bStack || [];
+ var length = aStack.length;
+ while (length--) {
+ // Linear search. Performance is inversely proportional to the number of
+ // unique nested structures.
+ if (aStack[length] === a) return bStack[length] === b;
+ }
+
+ // Add the first object to the stack of traversed objects.
+ aStack.push(a);
+ bStack.push(b);
+
+ // Recursively compare objects and arrays.
+ if (areArrays) {
+ // Compare array lengths to determine if a deep comparison is necessary.
+ length = a.length;
+ if (length !== b.length) return false;
+ // Deep compare the contents, ignoring non-numeric properties.
+ while (length--) {
+ if (!eq(a[length], b[length], aStack, bStack)) return false;
+ }
+ } else {
+ // Deep compare objects.
+ var _keys = keys(a), key;
+ length = _keys.length;
+ // Ensure that both objects contain the same number of properties before comparing deep equality.
+ if (keys(b).length !== length) return false;
+ while (length--) {
+ // Deep compare each member
+ key = _keys[length];
+ if (!(has$1(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
+ }
+ }
+ // Remove the first object from the stack of traversed objects.
+ aStack.pop();
+ bStack.pop();
+ return true;
+}
+
+// Perform a deep comparison to check if two objects are equal.
+function isEqual(a, b) {
+ return eq(a, b);
+}
+
+// Retrieve all the enumerable property names of an object.
+function allKeys(obj) {
+ if (!isObject(obj)) return [];
+ var keys = [];
+ for (var key in obj) keys.push(key);
+ // Ahem, IE < 9.
+ if (hasEnumBug) collectNonEnumProps(obj, keys);
+ return keys;
+}
+
+// Since the regular `Object.prototype.toString` type tests don't work for
+// some types in IE 11, we use a fingerprinting heuristic instead, based
+// on the methods. It's not great, but it's the best we got.
+// The fingerprint method lists are defined below.
+function ie11fingerprint(methods) {
+ var length = getLength(methods);
+ return function(obj) {
+ if (obj == null) return false;
+ // `Map`, `WeakMap` and `Set` have no enumerable keys.
+ var keys = allKeys(obj);
+ if (getLength(keys)) return false;
+ for (var i = 0; i < length; i++) {
+ if (!isFunction$1(obj[methods[i]])) return false;
+ }
+ // If we are testing against `WeakMap`, we need to ensure that
+ // `obj` doesn't have a `forEach` method in order to distinguish
+ // it from a regular `Map`.
+ return methods !== weakMapMethods || !isFunction$1(obj[forEachName]);
+ };
+}
+
+// In the interest of compact minification, we write
+// each string in the fingerprints only once.
+var forEachName = 'forEach',
+ hasName = 'has',
+ commonInit = ['clear', 'delete'],
+ mapTail = ['get', hasName, 'set'];
+
+// `Map`, `WeakMap` and `Set` each have slightly different
+// combinations of the above sublists.
+var mapMethods = commonInit.concat(forEachName, mapTail),
+ weakMapMethods = commonInit.concat(mapTail),
+ setMethods = ['add'].concat(commonInit, forEachName, hasName);
+
+var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map');
+
+var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap');
+
+var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set');
+
+var isWeakSet = tagTester('WeakSet');
+
+// Retrieve the values of an object's properties.
+function values(obj) {
+ var _keys = keys(obj);
+ var length = _keys.length;
+ var values = Array(length);
+ for (var i = 0; i < length; i++) {
+ values[i] = obj[_keys[i]];
+ }
+ return values;
+}
+
+// Convert an object into a list of `[key, value]` pairs.
+// The opposite of `_.object` with one argument.
+function pairs(obj) {
+ var _keys = keys(obj);
+ var length = _keys.length;
+ var pairs = Array(length);
+ for (var i = 0; i < length; i++) {
+ pairs[i] = [_keys[i], obj[_keys[i]]];
+ }
+ return pairs;
+}
+
+// Invert the keys and values of an object. The values must be serializable.
+function invert(obj) {
+ var result = {};
+ var _keys = keys(obj);
+ for (var i = 0, length = _keys.length; i < length; i++) {
+ result[obj[_keys[i]]] = _keys[i];
+ }
+ return result;
+}
+
+// Return a sorted list of the function names available on the object.
+function functions(obj) {
+ var names = [];
+ for (var key in obj) {
+ if (isFunction$1(obj[key])) names.push(key);
+ }
+ return names.sort();
+}
+
+// An internal function for creating assigner functions.
+function createAssigner(keysFunc, defaults) {
+ return function(obj) {
+ var length = arguments.length;
+ if (defaults) obj = Object(obj);
+ if (length < 2 || obj == null) return obj;
+ for (var index = 1; index < length; index++) {
+ var source = arguments[index],
+ keys = keysFunc(source),
+ l = keys.length;
+ for (var i = 0; i < l; i++) {
+ var key = keys[i];
+ if (!defaults || obj[key] === void 0) obj[key] = source[key];
+ }
+ }
+ return obj;
+ };
+}
+
+// Extend a given object with all the properties in passed-in object(s).
+var extend = createAssigner(allKeys);
+
+// Assigns a given object with all the own properties in the passed-in
+// object(s).
+// (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
+var extendOwn = createAssigner(keys);
+
+// Fill in a given object with default properties.
+var defaults = createAssigner(allKeys, true);
+
+// Create a naked function reference for surrogate-prototype-swapping.
+function ctor() {
+ return function(){};
+}
+
+// An internal function for creating a new object that inherits from another.
+function baseCreate(prototype) {
+ if (!isObject(prototype)) return {};
+ if (nativeCreate) return nativeCreate(prototype);
+ var Ctor = ctor();
+ Ctor.prototype = prototype;
+ var result = new Ctor;
+ Ctor.prototype = null;
+ return result;
+}
+
+// Creates an object that inherits from the given prototype object.
+// If additional properties are provided then they will be added to the
+// created object.
+function create(prototype, props) {
+ var result = baseCreate(prototype);
+ if (props) extendOwn(result, props);
+ return result;
+}
+
+// Create a (shallow-cloned) duplicate of an object.
+function clone(obj) {
+ if (!isObject(obj)) return obj;
+ return isArray(obj) ? obj.slice() : extend({}, obj);
+}
+
+// Invokes `interceptor` with the `obj` and then returns `obj`.
+// The primary purpose of this method is to "tap into" a method chain, in
+// order to perform operations on intermediate results within the chain.
+function tap(obj, interceptor) {
+ interceptor(obj);
+ return obj;
+}
+
+// Normalize a (deep) property `path` to array.
+// Like `_.iteratee`, this function can be customized.
+function toPath$1(path) {
+ return isArray(path) ? path : [path];
+}
+_$1.toPath = toPath$1;
+
+// Internal wrapper for `_.toPath` to enable minification.
+// Similar to `cb` for `_.iteratee`.
+function toPath(path) {
+ return _$1.toPath(path);
+}
+
+// Internal function to obtain a nested property in `obj` along `path`.
+function deepGet(obj, path) {
+ var length = path.length;
+ for (var i = 0; i < length; i++) {
+ if (obj == null) return void 0;
+ obj = obj[path[i]];
+ }
+ return length ? obj : void 0;
+}
+
+// Get the value of the (deep) property on `path` from `object`.
+// If any property in `path` does not exist or if the value is
+// `undefined`, return `defaultValue` instead.
+// The `path` is normalized through `_.toPath`.
+function get(object, path, defaultValue) {
+ var value = deepGet(object, toPath(path));
+ return isUndefined(value) ? defaultValue : value;
+}
+
+// Shortcut function for checking if an object has a given property directly on
+// itself (in other words, not on a prototype). Unlike the internal `has`
+// function, this public version can also traverse nested properties.
+function has(obj, path) {
+ path = toPath(path);
+ var length = path.length;
+ for (var i = 0; i < length; i++) {
+ var key = path[i];
+ if (!has$1(obj, key)) return false;
+ obj = obj[key];
+ }
+ return !!length;
+}
+
+// Keep the identity function around for default iteratees.
+function identity(value) {
+ return value;
+}
+
+// Returns a predicate for checking whether an object has a given set of
+// `key:value` pairs.
+function matcher(attrs) {
+ attrs = extendOwn({}, attrs);
+ return function(obj) {
+ return isMatch(obj, attrs);
+ };
+}
+
+// Creates a function that, when passed an object, will traverse that object’s
+// properties down the given `path`, specified as an array of keys or indices.
+function property(path) {
+ path = toPath(path);
+ return function(obj) {
+ return deepGet(obj, path);
+ };
+}
+
+// Internal function that returns an efficient (for current engines) version
+// of the passed-in callback, to be repeatedly applied in other Underscore
+// functions.
+function optimizeCb(func, context, argCount) {
+ if (context === void 0) return func;
+ switch (argCount == null ? 3 : argCount) {
+ case 1: return function(value) {
+ return func.call(context, value);
+ };
+ // The 2-argument case is omitted because we’re not using it.
+ case 3: return function(value, index, collection) {
+ return func.call(context, value, index, collection);
+ };
+ case 4: return function(accumulator, value, index, collection) {
+ return func.call(context, accumulator, value, index, collection);
+ };
+ }
+ return function() {
+ return func.apply(context, arguments);
+ };
+}
+
+// An internal function to generate callbacks that can be applied to each
+// element in a collection, returning the desired result — either `_.identity`,
+// an arbitrary callback, a property matcher, or a property accessor.
+function baseIteratee(value, context, argCount) {
+ if (value == null) return identity;
+ if (isFunction$1(value)) return optimizeCb(value, context, argCount);
+ if (isObject(value) && !isArray(value)) return matcher(value);
+ return property(value);
+}
+
+// External wrapper for our callback generator. Users may customize
+// `_.iteratee` if they want additional predicate/iteratee shorthand styles.
+// This abstraction hides the internal-only `argCount` argument.
+function iteratee(value, context) {
+ return baseIteratee(value, context, Infinity);
+}
+_$1.iteratee = iteratee;
+
+// The function we call internally to generate a callback. It invokes
+// `_.iteratee` if overridden, otherwise `baseIteratee`.
+function cb(value, context, argCount) {
+ if (_$1.iteratee !== iteratee) return _$1.iteratee(value, context);
+ return baseIteratee(value, context, argCount);
+}
+
+// Returns the results of applying the `iteratee` to each element of `obj`.
+// In contrast to `_.map` it returns an object.
+function mapObject(obj, iteratee, context) {
+ iteratee = cb(iteratee, context);
+ var _keys = keys(obj),
+ length = _keys.length,
+ results = {};
+ for (var index = 0; index < length; index++) {
+ var currentKey = _keys[index];
+ results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
+ }
+ return results;
+}
+
+// Predicate-generating function. Often useful outside of Underscore.
+function noop(){}
+
+// Generates a function for a given object that returns a given property.
+function propertyOf(obj) {
+ if (obj == null) return noop;
+ return function(path) {
+ return get(obj, path);
+ };
+}
+
+// Run a function **n** times.
+function times(n, iteratee, context) {
+ var accum = Array(Math.max(0, n));
+ iteratee = optimizeCb(iteratee, context, 1);
+ for (var i = 0; i < n; i++) accum[i] = iteratee(i);
+ return accum;
+}
+
+// Return a random integer between `min` and `max` (inclusive).
+function random(min, max) {
+ if (max == null) {
+ max = min;
+ min = 0;
+ }
+ return min + Math.floor(Math.random() * (max - min + 1));
+}
+
+// A (possibly faster) way to get the current timestamp as an integer.
+var now = Date.now || function() {
+ return new Date().getTime();
+};
+
+// Internal helper to generate functions for escaping and unescaping strings
+// to/from HTML interpolation.
+function createEscaper(map) {
+ var escaper = function(match) {
+ return map[match];
+ };
+ // Regexes for identifying a key that needs to be escaped.
+ var source = '(?:' + keys(map).join('|') + ')';
+ var testRegexp = RegExp(source);
+ var replaceRegexp = RegExp(source, 'g');
+ return function(string) {
+ string = string == null ? '' : '' + string;
+ return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
+ };
+}
+
+// Internal list of HTML entities for escaping.
+var escapeMap = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": ''',
+ '`': '`'
+};
+
+// Function for escaping strings to HTML interpolation.
+var _escape = createEscaper(escapeMap);
+
+// Internal list of HTML entities for unescaping.
+var unescapeMap = invert(escapeMap);
+
+// Function for unescaping strings from HTML interpolation.
+var _unescape = createEscaper(unescapeMap);
+
+// By default, Underscore uses ERB-style template delimiters. Change the
+// following template settings to use alternative delimiters.
+var templateSettings = _$1.templateSettings = {
+ evaluate: /<%([\s\S]+?)%>/g,
+ interpolate: /<%=([\s\S]+?)%>/g,
+ escape: /<%-([\s\S]+?)%>/g
+};
+
+// When customizing `_.templateSettings`, if you don't want to define an
+// interpolation, evaluation or escaping regex, we need one that is
+// guaranteed not to match.
+var noMatch = /(.)^/;
+
+// Certain characters need to be escaped so that they can be put into a
+// string literal.
+var escapes = {
+ "'": "'",
+ '\\': '\\',
+ '\r': 'r',
+ '\n': 'n',
+ '\u2028': 'u2028',
+ '\u2029': 'u2029'
+};
+
+var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;
+
+function escapeChar(match) {
+ return '\\' + escapes[match];
+}
+
+// In order to prevent third-party code injection through
+// `_.templateSettings.variable`, we test it against the following regular
+// expression. It is intentionally a bit more liberal than just matching valid
+// identifiers, but still prevents possible loopholes through defaults or
+// destructuring assignment.
+var bareIdentifier = /^\s*(\w|\$)+\s*$/;
+
+// JavaScript micro-templating, similar to John Resig's implementation.
+// Underscore templating handles arbitrary delimiters, preserves whitespace,
+// and correctly escapes quotes within interpolated code.
+// NB: `oldSettings` only exists for backwards compatibility.
+function template(text, settings, oldSettings) {
+ if (!settings && oldSettings) settings = oldSettings;
+ settings = defaults({}, settings, _$1.templateSettings);
+
+ // Combine delimiters into one regular expression via alternation.
+ var matcher = RegExp([
+ (settings.escape || noMatch).source,
+ (settings.interpolate || noMatch).source,
+ (settings.evaluate || noMatch).source
+ ].join('|') + '|$', 'g');
+
+ // Compile the template source, escaping string literals appropriately.
+ var index = 0;
+ var source = "__p+='";
+ text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
+ source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
+ index = offset + match.length;
+
+ if (escape) {
+ source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
+ } else if (interpolate) {
+ source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
+ } else if (evaluate) {
+ source += "';\n" + evaluate + "\n__p+='";
+ }
+
+ // Adobe VMs need the match returned to produce the correct offset.
+ return match;
+ });
+ source += "';\n";
+
+ var argument = settings.variable;
+ if (argument) {
+ // Insure against third-party code injection. (CVE-2021-23358)
+ if (!bareIdentifier.test(argument)) throw new Error(
+ 'variable is not a bare identifier: ' + argument
+ );
+ } else {
+ // If a variable is not specified, place data values in local scope.
+ source = 'with(obj||{}){\n' + source + '}\n';
+ argument = 'obj';
+ }
+
+ source = "var __t,__p='',__j=Array.prototype.join," +
+ "print=function(){__p+=__j.call(arguments,'');};\n" +
+ source + 'return __p;\n';
+
+ var render;
+ try {
+ render = new Function(argument, '_', source);
+ } catch (e) {
+ e.source = source;
+ throw e;
+ }
+
+ var template = function(data) {
+ return render.call(this, data, _$1);
+ };
+
+ // Provide the compiled source as a convenience for precompilation.
+ template.source = 'function(' + argument + '){\n' + source + '}';
+
+ return template;
+}
+
+// Traverses the children of `obj` along `path`. If a child is a function, it
+// is invoked with its parent as context. Returns the value of the final
+// child, or `fallback` if any child is undefined.
+function result(obj, path, fallback) {
+ path = toPath(path);
+ var length = path.length;
+ if (!length) {
+ return isFunction$1(fallback) ? fallback.call(obj) : fallback;
+ }
+ for (var i = 0; i < length; i++) {
+ var prop = obj == null ? void 0 : obj[path[i]];
+ if (prop === void 0) {
+ prop = fallback;
+ i = length; // Ensure we don't continue iterating.
+ }
+ obj = isFunction$1(prop) ? prop.call(obj) : prop;
+ }
+ return obj;
+}
+
+// Generate a unique integer id (unique within the entire client session).
+// Useful for temporary DOM ids.
+var idCounter = 0;
+function uniqueId(prefix) {
+ var id = ++idCounter + '';
+ return prefix ? prefix + id : id;
+}
+
+// Start chaining a wrapped Underscore object.
+function chain(obj) {
+ var instance = _$1(obj);
+ instance._chain = true;
+ return instance;
+}
+
+// Internal function to execute `sourceFunc` bound to `context` with optional
+// `args`. Determines whether to execute a function as a constructor or as a
+// normal function.
+function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
+ if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
+ var self = baseCreate(sourceFunc.prototype);
+ var result = sourceFunc.apply(self, args);
+ if (isObject(result)) return result;
+ return self;
+}
+
+// Partially apply a function by creating a version that has had some of its
+// arguments pre-filled, without changing its dynamic `this` context. `_` acts
+// as a placeholder by default, allowing any combination of arguments to be
+// pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
+var partial = restArguments(function(func, boundArgs) {
+ var placeholder = partial.placeholder;
+ var bound = function() {
+ var position = 0, length = boundArgs.length;
+ var args = Array(length);
+ for (var i = 0; i < length; i++) {
+ args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
+ }
+ while (position < arguments.length) args.push(arguments[position++]);
+ return executeBound(func, bound, this, this, args);
+ };
+ return bound;
+});
+
+partial.placeholder = _$1;
+
+// Create a function bound to a given object (assigning `this`, and arguments,
+// optionally).
+var bind = restArguments(function(func, context, args) {
+ if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function');
+ var bound = restArguments(function(callArgs) {
+ return executeBound(func, bound, context, this, args.concat(callArgs));
+ });
+ return bound;
+});
+
+// Internal helper for collection methods to determine whether a collection
+// should be iterated as an array or as an object.
+// Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
+// Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
+var isArrayLike = createSizePropertyCheck(getLength);
+
+// Internal implementation of a recursive `flatten` function.
+function flatten$1(input, depth, strict, output) {
+ output = output || [];
+ if (!depth && depth !== 0) {
+ depth = Infinity;
+ } else if (depth <= 0) {
+ return output.concat(input);
+ }
+ var idx = output.length;
+ for (var i = 0, length = getLength(input); i < length; i++) {
+ var value = input[i];
+ if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) {
+ // Flatten current level of array or arguments object.
+ if (depth > 1) {
+ flatten$1(value, depth - 1, strict, output);
+ idx = output.length;
+ } else {
+ var j = 0, len = value.length;
+ while (j < len) output[idx++] = value[j++];
+ }
+ } else if (!strict) {
+ output[idx++] = value;
+ }
+ }
+ return output;
+}
+
+// Bind a number of an object's methods to that object. Remaining arguments
+// are the method names to be bound. Useful for ensuring that all callbacks
+// defined on an object belong to it.
+var bindAll = restArguments(function(obj, keys) {
+ keys = flatten$1(keys, false, false);
+ var index = keys.length;
+ if (index < 1) throw new Error('bindAll must be passed function names');
+ while (index--) {
+ var key = keys[index];
+ obj[key] = bind(obj[key], obj);
+ }
+ return obj;
+});
+
+// Memoize an expensive function by storing its results.
+function memoize(func, hasher) {
+ var memoize = function(key) {
+ var cache = memoize.cache;
+ var address = '' + (hasher ? hasher.apply(this, arguments) : key);
+ if (!has$1(cache, address)) cache[address] = func.apply(this, arguments);
+ return cache[address];
+ };
+ memoize.cache = {};
+ return memoize;
+}
+
+// Delays a function for the given number of milliseconds, and then calls
+// it with the arguments supplied.
+var delay = restArguments(function(func, wait, args) {
+ return setTimeout(function() {
+ return func.apply(null, args);
+ }, wait);
+});
+
+// Defers a function, scheduling it to run after the current call stack has
+// cleared.
+var defer = partial(delay, _$1, 1);
+
+// Returns a function, that, when invoked, will only be triggered at most once
+// during a given window of time. Normally, the throttled function will run
+// as much as it can, without ever going more than once per `wait` duration;
+// but if you'd like to disable the execution on the leading edge, pass
+// `{leading: false}`. To disable execution on the trailing edge, ditto.
+function throttle(func, wait, options) {
+ var timeout, context, args, result;
+ var previous = 0;
+ if (!options) options = {};
+
+ var later = function() {
+ previous = options.leading === false ? 0 : now();
+ timeout = null;
+ result = func.apply(context, args);
+ if (!timeout) context = args = null;
+ };
+
+ var throttled = function() {
+ var _now = now();
+ if (!previous && options.leading === false) previous = _now;
+ var remaining = wait - (_now - previous);
+ context = this;
+ args = arguments;
+ if (remaining <= 0 || remaining > wait) {
+ if (timeout) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
+ previous = _now;
+ result = func.apply(context, args);
+ if (!timeout) context = args = null;
+ } else if (!timeout && options.trailing !== false) {
+ timeout = setTimeout(later, remaining);
+ }
+ return result;
+ };
+
+ throttled.cancel = function() {
+ clearTimeout(timeout);
+ previous = 0;
+ timeout = context = args = null;
+ };
+
+ return throttled;
+}
+
+// When a sequence of calls of the returned function ends, the argument
+// function is triggered. The end of a sequence is defined by the `wait`
+// parameter. If `immediate` is passed, the argument function will be
+// triggered at the beginning of the sequence instead of at the end.
+function debounce(func, wait, immediate) {
+ var timeout, previous, args, result, context;
+
+ var later = function() {
+ var passed = now() - previous;
+ if (wait > passed) {
+ timeout = setTimeout(later, wait - passed);
+ } else {
+ timeout = null;
+ if (!immediate) result = func.apply(context, args);
+ // This check is needed because `func` can recursively invoke `debounced`.
+ if (!timeout) args = context = null;
+ }
+ };
+
+ var debounced = restArguments(function(_args) {
+ context = this;
+ args = _args;
+ previous = now();
+ if (!timeout) {
+ timeout = setTimeout(later, wait);
+ if (immediate) result = func.apply(context, args);
+ }
+ return result;
+ });
+
+ debounced.cancel = function() {
+ clearTimeout(timeout);
+ timeout = args = context = null;
+ };
+
+ return debounced;
+}
+
+// Returns the first function passed as an argument to the second,
+// allowing you to adjust arguments, run code before and after, and
+// conditionally execute the original function.
+function wrap(func, wrapper) {
+ return partial(wrapper, func);
+}
+
+// Returns a negated version of the passed-in predicate.
+function negate(predicate) {
+ return function() {
+ return !predicate.apply(this, arguments);
+ };
+}
+
+// Returns a function that is the composition of a list of functions, each
+// consuming the return value of the function that follows.
+function compose() {
+ var args = arguments;
+ var start = args.length - 1;
+ return function() {
+ var i = start;
+ var result = args[start].apply(this, arguments);
+ while (i--) result = args[i].call(this, result);
+ return result;
+ };
+}
+
+// Returns a function that will only be executed on and after the Nth call.
+function after(times, func) {
+ return function() {
+ if (--times < 1) {
+ return func.apply(this, arguments);
+ }
+ };
+}
+
+// Returns a function that will only be executed up to (but not including) the
+// Nth call.
+function before(times, func) {
+ var memo;
+ return function() {
+ if (--times > 0) {
+ memo = func.apply(this, arguments);
+ }
+ if (times <= 1) func = null;
+ return memo;
+ };
+}
+
+// Returns a function that will be executed at most one time, no matter how
+// often you call it. Useful for lazy initialization.
+var once = partial(before, 2);
+
+// Returns the first key on an object that passes a truth test.
+function findKey(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var _keys = keys(obj), key;
+ for (var i = 0, length = _keys.length; i < length; i++) {
+ key = _keys[i];
+ if (predicate(obj[key], key, obj)) return key;
+ }
+}
+
+// Internal function to generate `_.findIndex` and `_.findLastIndex`.
+function createPredicateIndexFinder(dir) {
+ return function(array, predicate, context) {
+ predicate = cb(predicate, context);
+ var length = getLength(array);
+ var index = dir > 0 ? 0 : length - 1;
+ for (; index >= 0 && index < length; index += dir) {
+ if (predicate(array[index], index, array)) return index;
+ }
+ return -1;
+ };
+}
+
+// Returns the first index on an array-like that passes a truth test.
+var findIndex = createPredicateIndexFinder(1);
+
+// Returns the last index on an array-like that passes a truth test.
+var findLastIndex = createPredicateIndexFinder(-1);
+
+// Use a comparator function to figure out the smallest index at which
+// an object should be inserted so as to maintain order. Uses binary search.
+function sortedIndex(array, obj, iteratee, context) {
+ iteratee = cb(iteratee, context, 1);
+ var value = iteratee(obj);
+ var low = 0, high = getLength(array);
+ while (low < high) {
+ var mid = Math.floor((low + high) / 2);
+ if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
+ }
+ return low;
+}
+
+// Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
+function createIndexFinder(dir, predicateFind, sortedIndex) {
+ return function(array, item, idx) {
+ var i = 0, length = getLength(array);
+ if (typeof idx == 'number') {
+ if (dir > 0) {
+ i = idx >= 0 ? idx : Math.max(idx + length, i);
+ } else {
+ length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
+ }
+ } else if (sortedIndex && idx && length) {
+ idx = sortedIndex(array, item);
+ return array[idx] === item ? idx : -1;
+ }
+ if (item !== item) {
+ idx = predicateFind(slice.call(array, i, length), isNaN$1);
+ return idx >= 0 ? idx + i : -1;
+ }
+ for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
+ if (array[idx] === item) return idx;
+ }
+ return -1;
+ };
+}
+
+// Return the position of the first occurrence of an item in an array,
+// or -1 if the item is not included in the array.
+// If the array is large and already in sort order, pass `true`
+// for **isSorted** to use binary search.
+var indexOf = createIndexFinder(1, findIndex, sortedIndex);
+
+// Return the position of the last occurrence of an item in an array,
+// or -1 if the item is not included in the array.
+var lastIndexOf = createIndexFinder(-1, findLastIndex);
+
+// Return the first value which passes a truth test.
+function find(obj, predicate, context) {
+ var keyFinder = isArrayLike(obj) ? findIndex : findKey;
+ var key = keyFinder(obj, predicate, context);
+ if (key !== void 0 && key !== -1) return obj[key];
+}
+
+// Convenience version of a common use case of `_.find`: getting the first
+// object containing specific `key:value` pairs.
+function findWhere(obj, attrs) {
+ return find(obj, matcher(attrs));
+}
+
+// The cornerstone for collection functions, an `each`
+// implementation, aka `forEach`.
+// Handles raw objects in addition to array-likes. Treats all
+// sparse array-likes as if they were dense.
+function each(obj, iteratee, context) {
+ iteratee = optimizeCb(iteratee, context);
+ var i, length;
+ if (isArrayLike(obj)) {
+ for (i = 0, length = obj.length; i < length; i++) {
+ iteratee(obj[i], i, obj);
+ }
+ } else {
+ var _keys = keys(obj);
+ for (i = 0, length = _keys.length; i < length; i++) {
+ iteratee(obj[_keys[i]], _keys[i], obj);
+ }
+ }
+ return obj;
+}
+
+// Return the results of applying the iteratee to each element.
+function map(obj, iteratee, context) {
+ iteratee = cb(iteratee, context);
+ var _keys = !isArrayLike(obj) && keys(obj),
+ length = (_keys || obj).length,
+ results = Array(length);
+ for (var index = 0; index < length; index++) {
+ var currentKey = _keys ? _keys[index] : index;
+ results[index] = iteratee(obj[currentKey], currentKey, obj);
+ }
+ return results;
+}
+
+// Internal helper to create a reducing function, iterating left or right.
+function createReduce(dir) {
+ // Wrap code that reassigns argument variables in a separate function than
+ // the one that accesses `arguments.length` to avoid a perf hit. (#1991)
+ var reducer = function(obj, iteratee, memo, initial) {
+ var _keys = !isArrayLike(obj) && keys(obj),
+ length = (_keys || obj).length,
+ index = dir > 0 ? 0 : length - 1;
+ if (!initial) {
+ memo = obj[_keys ? _keys[index] : index];
+ index += dir;
+ }
+ for (; index >= 0 && index < length; index += dir) {
+ var currentKey = _keys ? _keys[index] : index;
+ memo = iteratee(memo, obj[currentKey], currentKey, obj);
+ }
+ return memo;
+ };
+
+ return function(obj, iteratee, memo, context) {
+ var initial = arguments.length >= 3;
+ return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);
+ };
+}
+
+// **Reduce** builds up a single result from a list of values, aka `inject`,
+// or `foldl`.
+var reduce = createReduce(1);
+
+// The right-associative version of reduce, also known as `foldr`.
+var reduceRight = createReduce(-1);
+
+// Return all the elements that pass a truth test.
+function filter(obj, predicate, context) {
+ var results = [];
+ predicate = cb(predicate, context);
+ each(obj, function(value, index, list) {
+ if (predicate(value, index, list)) results.push(value);
+ });
+ return results;
+}
+
+// Return all the elements for which a truth test fails.
+function reject(obj, predicate, context) {
+ return filter(obj, negate(cb(predicate)), context);
+}
+
+// Determine whether all of the elements pass a truth test.
+function every(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var _keys = !isArrayLike(obj) && keys(obj),
+ length = (_keys || obj).length;
+ for (var index = 0; index < length; index++) {
+ var currentKey = _keys ? _keys[index] : index;
+ if (!predicate(obj[currentKey], currentKey, obj)) return false;
+ }
+ return true;
+}
+
+// Determine if at least one element in the object passes a truth test.
+function some(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var _keys = !isArrayLike(obj) && keys(obj),
+ length = (_keys || obj).length;
+ for (var index = 0; index < length; index++) {
+ var currentKey = _keys ? _keys[index] : index;
+ if (predicate(obj[currentKey], currentKey, obj)) return true;
+ }
+ return false;
+}
+
+// Determine if the array or object contains a given item (using `===`).
+function contains(obj, item, fromIndex, guard) {
+ if (!isArrayLike(obj)) obj = values(obj);
+ if (typeof fromIndex != 'number' || guard) fromIndex = 0;
+ return indexOf(obj, item, fromIndex) >= 0;
+}
+
+// Invoke a method (with arguments) on every item in a collection.
+var invoke = restArguments(function(obj, path, args) {
+ var contextPath, func;
+ if (isFunction$1(path)) {
+ func = path;
+ } else {
+ path = toPath(path);
+ contextPath = path.slice(0, -1);
+ path = path[path.length - 1];
+ }
+ return map(obj, function(context) {
+ var method = func;
+ if (!method) {
+ if (contextPath && contextPath.length) {
+ context = deepGet(context, contextPath);
+ }
+ if (context == null) return void 0;
+ method = context[path];
+ }
+ return method == null ? method : method.apply(context, args);
+ });
+});
+
+// Convenience version of a common use case of `_.map`: fetching a property.
+function pluck(obj, key) {
+ return map(obj, property(key));
+}
+
+// Convenience version of a common use case of `_.filter`: selecting only
+// objects containing specific `key:value` pairs.
+function where(obj, attrs) {
+ return filter(obj, matcher(attrs));
+}
+
+// Return the maximum element (or element-based computation).
+function max(obj, iteratee, context) {
+ var result = -Infinity, lastComputed = -Infinity,
+ value, computed;
+ if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
+ obj = isArrayLike(obj) ? obj : values(obj);
+ for (var i = 0, length = obj.length; i < length; i++) {
+ value = obj[i];
+ if (value != null && value > result) {
+ result = value;
+ }
+ }
+ } else {
+ iteratee = cb(iteratee, context);
+ each(obj, function(v, index, list) {
+ computed = iteratee(v, index, list);
+ if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
+ result = v;
+ lastComputed = computed;
+ }
+ });
+ }
+ return result;
+}
+
+// Return the minimum element (or element-based computation).
+function min(obj, iteratee, context) {
+ var result = Infinity, lastComputed = Infinity,
+ value, computed;
+ if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
+ obj = isArrayLike(obj) ? obj : values(obj);
+ for (var i = 0, length = obj.length; i < length; i++) {
+ value = obj[i];
+ if (value != null && value < result) {
+ result = value;
+ }
+ }
+ } else {
+ iteratee = cb(iteratee, context);
+ each(obj, function(v, index, list) {
+ computed = iteratee(v, index, list);
+ if (computed < lastComputed || computed === Infinity && result === Infinity) {
+ result = v;
+ lastComputed = computed;
+ }
+ });
+ }
+ return result;
+}
+
+// Sample **n** random values from a collection using the modern version of the
+// [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
+// If **n** is not specified, returns a single random element.
+// The internal `guard` argument allows it to work with `_.map`.
+function sample(obj, n, guard) {
+ if (n == null || guard) {
+ if (!isArrayLike(obj)) obj = values(obj);
+ return obj[random(obj.length - 1)];
+ }
+ var sample = isArrayLike(obj) ? clone(obj) : values(obj);
+ var length = getLength(sample);
+ n = Math.max(Math.min(n, length), 0);
+ var last = length - 1;
+ for (var index = 0; index < n; index++) {
+ var rand = random(index, last);
+ var temp = sample[index];
+ sample[index] = sample[rand];
+ sample[rand] = temp;
+ }
+ return sample.slice(0, n);
+}
+
+// Shuffle a collection.
+function shuffle(obj) {
+ return sample(obj, Infinity);
+}
+
+// Sort the object's values by a criterion produced by an iteratee.
+function sortBy(obj, iteratee, context) {
+ var index = 0;
+ iteratee = cb(iteratee, context);
+ return pluck(map(obj, function(value, key, list) {
+ return {
+ value: value,
+ index: index++,
+ criteria: iteratee(value, key, list)
+ };
+ }).sort(function(left, right) {
+ var a = left.criteria;
+ var b = right.criteria;
+ if (a !== b) {
+ if (a > b || a === void 0) return 1;
+ if (a < b || b === void 0) return -1;
+ }
+ return left.index - right.index;
+ }), 'value');
+}
+
+// An internal function used for aggregate "group by" operations.
+function group(behavior, partition) {
+ return function(obj, iteratee, context) {
+ var result = partition ? [[], []] : {};
+ iteratee = cb(iteratee, context);
+ each(obj, function(value, index) {
+ var key = iteratee(value, index, obj);
+ behavior(result, value, key);
+ });
+ return result;
+ };
+}
+
+// Groups the object's values by a criterion. Pass either a string attribute
+// to group by, or a function that returns the criterion.
+var groupBy = group(function(result, value, key) {
+ if (has$1(result, key)) result[key].push(value); else result[key] = [value];
+});
+
+// Indexes the object's values by a criterion, similar to `_.groupBy`, but for
+// when you know that your index values will be unique.
+var indexBy = group(function(result, value, key) {
+ result[key] = value;
+});
+
+// Counts instances of an object that group by a certain criterion. Pass
+// either a string attribute to count by, or a function that returns the
+// criterion.
+var countBy = group(function(result, value, key) {
+ if (has$1(result, key)) result[key]++; else result[key] = 1;
+});
+
+// Split a collection into two arrays: one whose elements all pass the given
+// truth test, and one whose elements all do not pass the truth test.
+var partition = group(function(result, value, pass) {
+ result[pass ? 0 : 1].push(value);
+}, true);
+
+// Safely create a real, live array from anything iterable.
+var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
+function toArray(obj) {
+ if (!obj) return [];
+ if (isArray(obj)) return slice.call(obj);
+ if (isString(obj)) {
+ // Keep surrogate pair characters together.
+ return obj.match(reStrSymbol);
+ }
+ if (isArrayLike(obj)) return map(obj, identity);
+ return values(obj);
+}
+
+// Return the number of elements in a collection.
+function size(obj) {
+ if (obj == null) return 0;
+ return isArrayLike(obj) ? obj.length : keys(obj).length;
+}
+
+// Internal `_.pick` helper function to determine whether `key` is an enumerable
+// property name of `obj`.
+function keyInObj(value, key, obj) {
+ return key in obj;
+}
+
+// Return a copy of the object only containing the allowed properties.
+var pick = restArguments(function(obj, keys) {
+ var result = {}, iteratee = keys[0];
+ if (obj == null) return result;
+ if (isFunction$1(iteratee)) {
+ if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
+ keys = allKeys(obj);
+ } else {
+ iteratee = keyInObj;
+ keys = flatten$1(keys, false, false);
+ obj = Object(obj);
+ }
+ for (var i = 0, length = keys.length; i < length; i++) {
+ var key = keys[i];
+ var value = obj[key];
+ if (iteratee(value, key, obj)) result[key] = value;
+ }
+ return result;
+});
+
+// Return a copy of the object without the disallowed properties.
+var omit = restArguments(function(obj, keys) {
+ var iteratee = keys[0], context;
+ if (isFunction$1(iteratee)) {
+ iteratee = negate(iteratee);
+ if (keys.length > 1) context = keys[1];
+ } else {
+ keys = map(flatten$1(keys, false, false), String);
+ iteratee = function(value, key) {
+ return !contains(keys, key);
+ };
+ }
+ return pick(obj, iteratee, context);
+});
+
+// Returns everything but the last entry of the array. Especially useful on
+// the arguments object. Passing **n** will return all the values in
+// the array, excluding the last N.
+function initial(array, n, guard) {
+ return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
+}
+
+// Get the first element of an array. Passing **n** will return the first N
+// values in the array. The **guard** check allows it to work with `_.map`.
+function first(array, n, guard) {
+ if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
+ if (n == null || guard) return array[0];
+ return initial(array, array.length - n);
+}
+
+// Returns everything but the first entry of the `array`. Especially useful on
+// the `arguments` object. Passing an **n** will return the rest N values in the
+// `array`.
+function rest(array, n, guard) {
+ return slice.call(array, n == null || guard ? 1 : n);
+}
+
+// Get the last element of an array. Passing **n** will return the last N
+// values in the array.
+function last(array, n, guard) {
+ if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
+ if (n == null || guard) return array[array.length - 1];
+ return rest(array, Math.max(0, array.length - n));
+}
+
+// Trim out all falsy values from an array.
+function compact(array) {
+ return filter(array, Boolean);
+}
+
+// Flatten out an array, either recursively (by default), or up to `depth`.
+// Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.
+function flatten(array, depth) {
+ return flatten$1(array, depth, false);
+}
+
+// Take the difference between one array and a number of other arrays.
+// Only the elements present in just the first array will remain.
+var difference = restArguments(function(array, rest) {
+ rest = flatten$1(rest, true, true);
+ return filter(array, function(value){
+ return !contains(rest, value);
+ });
+});
+
+// Return a version of the array that does not contain the specified value(s).
+var without = restArguments(function(array, otherArrays) {
+ return difference(array, otherArrays);
+});
+
+// Produce a duplicate-free version of the array. If the array has already
+// been sorted, you have the option of using a faster algorithm.
+// The faster algorithm will not work with an iteratee if the iteratee
+// is not a one-to-one function, so providing an iteratee will disable
+// the faster algorithm.
+function uniq(array, isSorted, iteratee, context) {
+ if (!isBoolean(isSorted)) {
+ context = iteratee;
+ iteratee = isSorted;
+ isSorted = false;
+ }
+ if (iteratee != null) iteratee = cb(iteratee, context);
+ var result = [];
+ var seen = [];
+ for (var i = 0, length = getLength(array); i < length; i++) {
+ var value = array[i],
+ computed = iteratee ? iteratee(value, i, array) : value;
+ if (isSorted && !iteratee) {
+ if (!i || seen !== computed) result.push(value);
+ seen = computed;
+ } else if (iteratee) {
+ if (!contains(seen, computed)) {
+ seen.push(computed);
+ result.push(value);
+ }
+ } else if (!contains(result, value)) {
+ result.push(value);
+ }
+ }
+ return result;
+}
+
+// Produce an array that contains the union: each distinct element from all of
+// the passed-in arrays.
+var union = restArguments(function(arrays) {
+ return uniq(flatten$1(arrays, true, true));
+});
+
+// Produce an array that contains every item shared between all the
+// passed-in arrays.
+function intersection(array) {
+ var result = [];
+ var argsLength = arguments.length;
+ for (var i = 0, length = getLength(array); i < length; i++) {
+ var item = array[i];
+ if (contains(result, item)) continue;
+ var j;
+ for (j = 1; j < argsLength; j++) {
+ if (!contains(arguments[j], item)) break;
+ }
+ if (j === argsLength) result.push(item);
+ }
+ return result;
+}
+
+// Complement of zip. Unzip accepts an array of arrays and groups
+// each array's elements on shared indices.
+function unzip(array) {
+ var length = array && max(array, getLength).length || 0;
+ var result = Array(length);
+
+ for (var index = 0; index < length; index++) {
+ result[index] = pluck(array, index);
+ }
+ return result;
+}
+
+// Zip together multiple lists into a single array -- elements that share
+// an index go together.
+var zip = restArguments(unzip);
+
+// Converts lists into objects. Pass either a single array of `[key, value]`
+// pairs, or two parallel arrays of the same length -- one of keys, and one of
+// the corresponding values. Passing by pairs is the reverse of `_.pairs`.
+function object(list, values) {
+ var result = {};
+ for (var i = 0, length = getLength(list); i < length; i++) {
+ if (values) {
+ result[list[i]] = values[i];
+ } else {
+ result[list[i][0]] = list[i][1];
+ }
+ }
+ return result;
+}
+
+// Generate an integer Array containing an arithmetic progression. A port of
+// the native Python `range()` function. See
+// [the Python documentation](https://docs.python.org/library/functions.html#range).
+function range(start, stop, step) {
+ if (stop == null) {
+ stop = start || 0;
+ start = 0;
+ }
+ if (!step) {
+ step = stop < start ? -1 : 1;
+ }
+
+ var length = Math.max(Math.ceil((stop - start) / step), 0);
+ var range = Array(length);
+
+ for (var idx = 0; idx < length; idx++, start += step) {
+ range[idx] = start;
+ }
+
+ return range;
+}
+
+// Chunk a single array into multiple arrays, each containing `count` or fewer
+// items.
+function chunk(array, count) {
+ if (count == null || count < 1) return [];
+ var result = [];
+ var i = 0, length = array.length;
+ while (i < length) {
+ result.push(slice.call(array, i, i += count));
+ }
+ return result;
+}
+
+// Helper function to continue chaining intermediate results.
+function chainResult(instance, obj) {
+ return instance._chain ? _$1(obj).chain() : obj;
+}
+
+// Add your own custom functions to the Underscore object.
+function mixin(obj) {
+ each(functions(obj), function(name) {
+ var func = _$1[name] = obj[name];
+ _$1.prototype[name] = function() {
+ var args = [this._wrapped];
+ push.apply(args, arguments);
+ return chainResult(this, func.apply(_$1, args));
+ };
+ });
+ return _$1;
+}
+
+// Add all mutator `Array` functions to the wrapper.
+each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
+ var method = ArrayProto[name];
+ _$1.prototype[name] = function() {
+ var obj = this._wrapped;
+ if (obj != null) {
+ method.apply(obj, arguments);
+ if ((name === 'shift' || name === 'splice') && obj.length === 0) {
+ delete obj[0];
+ }
+ }
+ return chainResult(this, obj);
+ };
+});
+
+// Add all accessor `Array` functions to the wrapper.
+each(['concat', 'join', 'slice'], function(name) {
+ var method = ArrayProto[name];
+ _$1.prototype[name] = function() {
+ var obj = this._wrapped;
+ if (obj != null) obj = method.apply(obj, arguments);
+ return chainResult(this, obj);
+ };
+});
+
+// Named Exports
+
+var allExports = {
+ __proto__: null,
+ VERSION: VERSION,
+ restArguments: restArguments,
+ isObject: isObject,
+ isNull: isNull,
+ isUndefined: isUndefined,
+ isBoolean: isBoolean,
+ isElement: isElement,
+ isString: isString,
+ isNumber: isNumber,
+ isDate: isDate,
+ isRegExp: isRegExp,
+ isError: isError,
+ isSymbol: isSymbol,
+ isArrayBuffer: isArrayBuffer,
+ isDataView: isDataView$1,
+ isArray: isArray,
+ isFunction: isFunction$1,
+ isArguments: isArguments$1,
+ isFinite: isFinite$1,
+ isNaN: isNaN$1,
+ isTypedArray: isTypedArray$1,
+ isEmpty: isEmpty,
+ isMatch: isMatch,
+ isEqual: isEqual,
+ isMap: isMap,
+ isWeakMap: isWeakMap,
+ isSet: isSet,
+ isWeakSet: isWeakSet,
+ keys: keys,
+ allKeys: allKeys,
+ values: values,
+ pairs: pairs,
+ invert: invert,
+ functions: functions,
+ methods: functions,
+ extend: extend,
+ extendOwn: extendOwn,
+ assign: extendOwn,
+ defaults: defaults,
+ create: create,
+ clone: clone,
+ tap: tap,
+ get: get,
+ has: has,
+ mapObject: mapObject,
+ identity: identity,
+ constant: constant,
+ noop: noop,
+ toPath: toPath$1,
+ property: property,
+ propertyOf: propertyOf,
+ matcher: matcher,
+ matches: matcher,
+ times: times,
+ random: random,
+ now: now,
+ escape: _escape,
+ unescape: _unescape,
+ templateSettings: templateSettings,
+ template: template,
+ result: result,
+ uniqueId: uniqueId,
+ chain: chain,
+ iteratee: iteratee,
+ partial: partial,
+ bind: bind,
+ bindAll: bindAll,
+ memoize: memoize,
+ delay: delay,
+ defer: defer,
+ throttle: throttle,
+ debounce: debounce,
+ wrap: wrap,
+ negate: negate,
+ compose: compose,
+ after: after,
+ before: before,
+ once: once,
+ findKey: findKey,
+ findIndex: findIndex,
+ findLastIndex: findLastIndex,
+ sortedIndex: sortedIndex,
+ indexOf: indexOf,
+ lastIndexOf: lastIndexOf,
+ find: find,
+ detect: find,
+ findWhere: findWhere,
+ each: each,
+ forEach: each,
+ map: map,
+ collect: map,
+ reduce: reduce,
+ foldl: reduce,
+ inject: reduce,
+ reduceRight: reduceRight,
+ foldr: reduceRight,
+ filter: filter,
+ select: filter,
+ reject: reject,
+ every: every,
+ all: every,
+ some: some,
+ any: some,
+ contains: contains,
+ includes: contains,
+ include: contains,
+ invoke: invoke,
+ pluck: pluck,
+ where: where,
+ max: max,
+ min: min,
+ shuffle: shuffle,
+ sample: sample,
+ sortBy: sortBy,
+ groupBy: groupBy,
+ indexBy: indexBy,
+ countBy: countBy,
+ partition: partition,
+ toArray: toArray,
+ size: size,
+ pick: pick,
+ omit: omit,
+ first: first,
+ head: first,
+ take: first,
+ initial: initial,
+ last: last,
+ rest: rest,
+ tail: rest,
+ drop: rest,
+ compact: compact,
+ flatten: flatten,
+ without: without,
+ uniq: uniq,
+ unique: uniq,
+ union: union,
+ intersection: intersection,
+ difference: difference,
+ unzip: unzip,
+ transpose: unzip,
+ zip: zip,
+ object: object,
+ range: range,
+ chunk: chunk,
+ mixin: mixin,
+ 'default': _$1
+};
+
+// Default Export
+
+// Add all of the Underscore functions to the wrapper object.
+var _ = mixin(allExports);
+// Legacy Node.js API.
+_._ = _;
+
+exports.VERSION = VERSION;
+exports._ = _;
+exports._escape = _escape;
+exports._unescape = _unescape;
+exports.after = after;
+exports.allKeys = allKeys;
+exports.before = before;
+exports.bind = bind;
+exports.bindAll = bindAll;
+exports.chain = chain;
+exports.chunk = chunk;
+exports.clone = clone;
+exports.compact = compact;
+exports.compose = compose;
+exports.constant = constant;
+exports.contains = contains;
+exports.countBy = countBy;
+exports.create = create;
+exports.debounce = debounce;
+exports.defaults = defaults;
+exports.defer = defer;
+exports.delay = delay;
+exports.difference = difference;
+exports.each = each;
+exports.every = every;
+exports.extend = extend;
+exports.extendOwn = extendOwn;
+exports.filter = filter;
+exports.find = find;
+exports.findIndex = findIndex;
+exports.findKey = findKey;
+exports.findLastIndex = findLastIndex;
+exports.findWhere = findWhere;
+exports.first = first;
+exports.flatten = flatten;
+exports.functions = functions;
+exports.get = get;
+exports.groupBy = groupBy;
+exports.has = has;
+exports.identity = identity;
+exports.indexBy = indexBy;
+exports.indexOf = indexOf;
+exports.initial = initial;
+exports.intersection = intersection;
+exports.invert = invert;
+exports.invoke = invoke;
+exports.isArguments = isArguments$1;
+exports.isArray = isArray;
+exports.isArrayBuffer = isArrayBuffer;
+exports.isBoolean = isBoolean;
+exports.isDataView = isDataView$1;
+exports.isDate = isDate;
+exports.isElement = isElement;
+exports.isEmpty = isEmpty;
+exports.isEqual = isEqual;
+exports.isError = isError;
+exports.isFinite = isFinite$1;
+exports.isFunction = isFunction$1;
+exports.isMap = isMap;
+exports.isMatch = isMatch;
+exports.isNaN = isNaN$1;
+exports.isNull = isNull;
+exports.isNumber = isNumber;
+exports.isObject = isObject;
+exports.isRegExp = isRegExp;
+exports.isSet = isSet;
+exports.isString = isString;
+exports.isSymbol = isSymbol;
+exports.isTypedArray = isTypedArray$1;
+exports.isUndefined = isUndefined;
+exports.isWeakMap = isWeakMap;
+exports.isWeakSet = isWeakSet;
+exports.iteratee = iteratee;
+exports.keys = keys;
+exports.last = last;
+exports.lastIndexOf = lastIndexOf;
+exports.map = map;
+exports.mapObject = mapObject;
+exports.matcher = matcher;
+exports.max = max;
+exports.memoize = memoize;
+exports.min = min;
+exports.mixin = mixin;
+exports.negate = negate;
+exports.noop = noop;
+exports.now = now;
+exports.object = object;
+exports.omit = omit;
+exports.once = once;
+exports.pairs = pairs;
+exports.partial = partial;
+exports.partition = partition;
+exports.pick = pick;
+exports.pluck = pluck;
+exports.property = property;
+exports.propertyOf = propertyOf;
+exports.random = random;
+exports.range = range;
+exports.reduce = reduce;
+exports.reduceRight = reduceRight;
+exports.reject = reject;
+exports.rest = rest;
+exports.restArguments = restArguments;
+exports.result = result;
+exports.sample = sample;
+exports.shuffle = shuffle;
+exports.size = size;
+exports.some = some;
+exports.sortBy = sortBy;
+exports.sortedIndex = sortedIndex;
+exports.tap = tap;
+exports.template = template;
+exports.templateSettings = templateSettings;
+exports.throttle = throttle;
+exports.times = times;
+exports.toArray = toArray;
+exports.toPath = toPath$1;
+exports.union = union;
+exports.uniq = uniq;
+exports.uniqueId = uniqueId;
+exports.unzip = unzip;
+exports.values = values;
+exports.where = where;
+exports.without = without;
+exports.wrap = wrap;
+exports.zip = zip;
+//# sourceMappingURL=underscore-node-f.cjs.map
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/underscore/underscore-node.cjs":
+/*!*********************************************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/underscore/underscore-node.cjs ***!
+ \*********************************************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+// Underscore.js 1.13.1
+// https://underscorejs.org
+// (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
+// Underscore may be freely distributed under the MIT license.
+
+var underscoreNodeF = __webpack_require__(/*! ./underscore-node-f.cjs */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/node_modules/underscore/underscore-node-f.cjs");
+
+
+
+module.exports = underscoreNodeF._;
+//# sourceMappingURL=underscore-node.cjs.map
+
+
+/***/ }),
+
+/***/ "./node_modules/cht-core-3-12/shared-libs/rules-engine/src/index.js":
+/*!**************************************************************************!*\
+ !*** ./node_modules/cht-core-3-12/shared-libs/rules-engine/src/index.js ***!
+ \**************************************************************************/
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/**
+ * @module rules-engine
+ *
+ * Business logic for interacting with rules documents
+ */
+
+const pouchdbProvider = __webpack_require__(/*! ./pouchdb-provider */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/src/pouchdb-provider.js");
+const rulesEmitter = __webpack_require__(/*! ./rules-emitter */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/src/rules-emitter.js");
+const rulesStateStore = __webpack_require__(/*! ./rules-state-store */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/src/rules-state-store.js");
+const wireupToProvider = __webpack_require__(/*! ./provider-wireup */ "./node_modules/cht-core-3-12/shared-libs/rules-engine/src/provider-wireup.js");
+
+/**
+ * @param {Object} db Medic pouchdb database
+ */
+module.exports = db => {
+ const provider = pouchdbProvider(db);
+ return {
+ /**
+ * @param {Object} settings Settings for the behavior of the rules engine
+ * @param {Object} settings.rules Rules code from settings doc
+ * @param {Object[]} settings.taskSchedules Task schedules from settings doc
+ * @param {Object[]} settings.targets Target definitions from settings doc
+ * @param {Boolean} settings.enableTasks Flag to enable tasks
+ * @param {Boolean} settings.enableTargets Flag to enable targets
+ * @param {Object} settings.contact User's hydrated contact document
+ * @param {Object} settings.user User's settings document
+ */
+ initialize: (settings) => wireupToProvider.initialize(provider, settings),
+
+ /**
+ * @returns {Boolean} True if the rules engine is enabled and ready for use
+ */
+ isEnabled: () => rulesEmitter.isEnabled() && rulesEmitter.isLatestNoolsSchema(),
+
+ /**
+ * Refreshes all rules documents for a set of contacts and returns their task documents
+ *
+ * @param {string[]} contactIds An array of contact ids. If undefined, all contacts are
+ * @returns {Promise