1 | const _ = require('lodash');
|
2 |
|
3 | function getChildren(it) {
|
4 | return _.union([it, _.map(it.children, getChildren)]);
|
5 | }
|
6 |
|
7 | function extractDialogBookingEngine(chatTree) {
|
8 | return _.flattenDeep(getChildren(chatTree)).find(_.matchesProperty('type', 'booking-engine'));
|
9 | }
|
10 |
|
11 | module.exports = {
|
12 | extractDialogBookingEngine: extractDialogBookingEngine,
|
13 | };
|