@divkitframework/jsonbuilder 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1418 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var crypto = require('crypto');
6
+
7
+ // Generated code. Do not modify.
8
+ /**
9
+ * A Boolean variable in binary format.
10
+ */
11
+ class BooleanVariable {
12
+ constructor(props) {
13
+ this.type = 'boolean';
14
+ this.name = props.name;
15
+ this.value = props.value;
16
+ }
17
+ }
18
+
19
+ // Generated code. Do not modify.
20
+ /**
21
+ * Variable — HEX color as a string.
22
+ */
23
+ class ColorVariable {
24
+ constructor(props) {
25
+ this.type = 'color';
26
+ this.name = props.name;
27
+ this.value = props.value;
28
+ }
29
+ }
30
+
31
+ // Generated code. Do not modify.
32
+ /**
33
+ * A set of animations to be applied simultaneously.
34
+ */
35
+ class DivAppearanceSetTransition {
36
+ constructor(props) {
37
+ this.type = 'set';
38
+ this.items = props.items;
39
+ }
40
+ }
41
+
42
+ // Generated code. Do not modify.
43
+ /**
44
+ * Element position and size change animation.
45
+ */
46
+ class DivChangeBoundsTransition {
47
+ constructor(props) {
48
+ this.type = 'change_bounds';
49
+ this.duration = props === null || props === void 0 ? void 0 : props.duration;
50
+ this.interpolator = props === null || props === void 0 ? void 0 : props.interpolator;
51
+ this.start_delay = props === null || props === void 0 ? void 0 : props.start_delay;
52
+ }
53
+ }
54
+
55
+ // Generated code. Do not modify.
56
+ /**
57
+ * Animations.
58
+ */
59
+ class DivChangeSetTransition {
60
+ constructor(props) {
61
+ this.type = 'set';
62
+ this.items = props.items;
63
+ }
64
+ }
65
+
66
+ // Generated code. Do not modify.
67
+ /**
68
+ * Container. It contains other elements and is responsible for their location. It is used to
69
+ * arrange elements vertically, horizontally, and with an overlay in a certain order, simulating
70
+ * the third dimension.
71
+ */
72
+ class DivContainer {
73
+ constructor(props) {
74
+ this.type = 'container';
75
+ this.accessibility = props.accessibility;
76
+ this.action = props.action;
77
+ this.action_animation = props.action_animation;
78
+ this.actions = props.actions;
79
+ this.alignment_horizontal = props.alignment_horizontal;
80
+ this.alignment_vertical = props.alignment_vertical;
81
+ this.alpha = props.alpha;
82
+ this.background = props.background;
83
+ this.border = props.border;
84
+ this.column_span = props.column_span;
85
+ this.content_alignment_horizontal = props.content_alignment_horizontal;
86
+ this.content_alignment_vertical = props.content_alignment_vertical;
87
+ this.doubletap_actions = props.doubletap_actions;
88
+ this.extensions = props.extensions;
89
+ this.focus = props.focus;
90
+ this.height = props.height;
91
+ this.id = props.id;
92
+ this.items = props.items;
93
+ this.longtap_actions = props.longtap_actions;
94
+ this.margins = props.margins;
95
+ this.orientation = props.orientation;
96
+ this.paddings = props.paddings;
97
+ this.row_span = props.row_span;
98
+ this.selected_actions = props.selected_actions;
99
+ this.tooltips = props.tooltips;
100
+ this.transform = props.transform;
101
+ this.transition_change = props.transition_change;
102
+ this.transition_in = props.transition_in;
103
+ this.transition_out = props.transition_out;
104
+ this.transition_triggers = props.transition_triggers;
105
+ this.visibility = props.visibility;
106
+ this.visibility_action = props.visibility_action;
107
+ this.visibility_actions = props.visibility_actions;
108
+ this.width = props.width;
109
+ }
110
+ }
111
+
112
+ // Generated code. Do not modify.
113
+ /**
114
+ * Custom element. It is delegated to a host application to create native elements depending on
115
+ * the platform.
116
+ */
117
+ class DivCustom {
118
+ constructor(props) {
119
+ this.type = 'custom';
120
+ this.accessibility = props.accessibility;
121
+ this.alignment_horizontal = props.alignment_horizontal;
122
+ this.alignment_vertical = props.alignment_vertical;
123
+ this.alpha = props.alpha;
124
+ this.background = props.background;
125
+ this.border = props.border;
126
+ this.column_span = props.column_span;
127
+ this.custom_props = props.custom_props;
128
+ this.custom_type = props.custom_type;
129
+ this.extensions = props.extensions;
130
+ this.focus = props.focus;
131
+ this.height = props.height;
132
+ this.id = props.id;
133
+ this.items = props.items;
134
+ this.margins = props.margins;
135
+ this.paddings = props.paddings;
136
+ this.row_span = props.row_span;
137
+ this.selected_actions = props.selected_actions;
138
+ this.tooltips = props.tooltips;
139
+ this.transform = props.transform;
140
+ this.transition_change = props.transition_change;
141
+ this.transition_in = props.transition_in;
142
+ this.transition_out = props.transition_out;
143
+ this.transition_triggers = props.transition_triggers;
144
+ this.visibility = props.visibility;
145
+ this.visibility_action = props.visibility_action;
146
+ this.visibility_actions = props.visibility_actions;
147
+ this.width = props.width;
148
+ }
149
+ }
150
+
151
+ // Generated code. Do not modify.
152
+ /**
153
+ * Transparency animation.
154
+ */
155
+ class DivFadeTransition {
156
+ constructor(props) {
157
+ this.type = 'fade';
158
+ this.alpha = props === null || props === void 0 ? void 0 : props.alpha;
159
+ this.duration = props === null || props === void 0 ? void 0 : props.duration;
160
+ this.interpolator = props === null || props === void 0 ? void 0 : props.interpolator;
161
+ this.start_delay = props === null || props === void 0 ? void 0 : props.start_delay;
162
+ }
163
+ }
164
+
165
+ // Generated code. Do not modify.
166
+ /**
167
+ * Fixed number of repetitions.
168
+ */
169
+ class DivFixedCount {
170
+ constructor(props) {
171
+ this.type = 'fixed';
172
+ this.value = props.value;
173
+ }
174
+ }
175
+
176
+ // Generated code. Do not modify.
177
+ /**
178
+ * Fixed size of an element.
179
+ */
180
+ class DivFixedSize {
181
+ constructor(props) {
182
+ this.type = 'fixed';
183
+ this.unit = props.unit;
184
+ this.value = props.value;
185
+ }
186
+ }
187
+
188
+ // Generated code. Do not modify.
189
+ /**
190
+ * Gallery. It contains a horizontal or vertical set of cards that can be scrolled.
191
+ */
192
+ class DivGallery {
193
+ constructor(props) {
194
+ this.type = 'gallery';
195
+ this.accessibility = props.accessibility;
196
+ this.alignment_horizontal = props.alignment_horizontal;
197
+ this.alignment_vertical = props.alignment_vertical;
198
+ this.alpha = props.alpha;
199
+ this.background = props.background;
200
+ this.border = props.border;
201
+ this.column_count = props.column_count;
202
+ this.column_span = props.column_span;
203
+ this.cross_content_alignment = props.cross_content_alignment;
204
+ this.default_item = props.default_item;
205
+ this.extensions = props.extensions;
206
+ this.focus = props.focus;
207
+ this.height = props.height;
208
+ this.id = props.id;
209
+ this.item_spacing = props.item_spacing;
210
+ this.items = props.items;
211
+ this.margins = props.margins;
212
+ this.orientation = props.orientation;
213
+ this.paddings = props.paddings;
214
+ this.restrict_parent_scroll = props.restrict_parent_scroll;
215
+ this.row_span = props.row_span;
216
+ this.scroll_mode = props.scroll_mode;
217
+ this.selected_actions = props.selected_actions;
218
+ this.tooltips = props.tooltips;
219
+ this.transform = props.transform;
220
+ this.transition_change = props.transition_change;
221
+ this.transition_in = props.transition_in;
222
+ this.transition_out = props.transition_out;
223
+ this.transition_triggers = props.transition_triggers;
224
+ this.visibility = props.visibility;
225
+ this.visibility_action = props.visibility_action;
226
+ this.visibility_actions = props.visibility_actions;
227
+ this.width = props.width;
228
+ }
229
+ }
230
+
231
+ // Generated code. Do not modify.
232
+ /**
233
+ * Animated GIF image.
234
+ */
235
+ class DivGifImage {
236
+ constructor(props) {
237
+ this.type = 'gif';
238
+ this.accessibility = props.accessibility;
239
+ this.action = props.action;
240
+ this.action_animation = props.action_animation;
241
+ this.actions = props.actions;
242
+ this.alignment_horizontal = props.alignment_horizontal;
243
+ this.alignment_vertical = props.alignment_vertical;
244
+ this.alpha = props.alpha;
245
+ this.aspect = props.aspect;
246
+ this.background = props.background;
247
+ this.border = props.border;
248
+ this.column_span = props.column_span;
249
+ this.content_alignment_horizontal = props.content_alignment_horizontal;
250
+ this.content_alignment_vertical = props.content_alignment_vertical;
251
+ this.doubletap_actions = props.doubletap_actions;
252
+ this.extensions = props.extensions;
253
+ this.focus = props.focus;
254
+ this.gif_url = props.gif_url;
255
+ this.height = props.height;
256
+ this.id = props.id;
257
+ this.longtap_actions = props.longtap_actions;
258
+ this.margins = props.margins;
259
+ this.paddings = props.paddings;
260
+ this.placeholder_color = props.placeholder_color;
261
+ this.preload_required = props.preload_required;
262
+ this.preview = props.preview;
263
+ this.row_span = props.row_span;
264
+ this.scale = props.scale;
265
+ this.selected_actions = props.selected_actions;
266
+ this.tooltips = props.tooltips;
267
+ this.transform = props.transform;
268
+ this.transition_change = props.transition_change;
269
+ this.transition_in = props.transition_in;
270
+ this.transition_out = props.transition_out;
271
+ this.transition_triggers = props.transition_triggers;
272
+ this.visibility = props.visibility;
273
+ this.visibility_action = props.visibility_action;
274
+ this.visibility_actions = props.visibility_actions;
275
+ this.width = props.width;
276
+ }
277
+ }
278
+
279
+ // Generated code. Do not modify.
280
+ /**
281
+ * Gradient background.
282
+ */
283
+ class DivGradientBackground {
284
+ constructor(props) {
285
+ this.type = 'gradient';
286
+ this.angle = props.angle;
287
+ this.colors = props.colors;
288
+ }
289
+ }
290
+
291
+ // Generated code. Do not modify.
292
+ /**
293
+ * A grid with an option to merge cells vertically and horizontally.
294
+ */
295
+ class DivGrid {
296
+ constructor(props) {
297
+ this.type = 'grid';
298
+ this.accessibility = props.accessibility;
299
+ this.action = props.action;
300
+ this.action_animation = props.action_animation;
301
+ this.actions = props.actions;
302
+ this.alignment_horizontal = props.alignment_horizontal;
303
+ this.alignment_vertical = props.alignment_vertical;
304
+ this.alpha = props.alpha;
305
+ this.background = props.background;
306
+ this.border = props.border;
307
+ this.column_count = props.column_count;
308
+ this.column_span = props.column_span;
309
+ this.content_alignment_horizontal = props.content_alignment_horizontal;
310
+ this.content_alignment_vertical = props.content_alignment_vertical;
311
+ this.doubletap_actions = props.doubletap_actions;
312
+ this.extensions = props.extensions;
313
+ this.focus = props.focus;
314
+ this.height = props.height;
315
+ this.id = props.id;
316
+ this.items = props.items;
317
+ this.longtap_actions = props.longtap_actions;
318
+ this.margins = props.margins;
319
+ this.paddings = props.paddings;
320
+ this.row_span = props.row_span;
321
+ this.selected_actions = props.selected_actions;
322
+ this.tooltips = props.tooltips;
323
+ this.transform = props.transform;
324
+ this.transition_change = props.transition_change;
325
+ this.transition_in = props.transition_in;
326
+ this.transition_out = props.transition_out;
327
+ this.transition_triggers = props.transition_triggers;
328
+ this.visibility = props.visibility;
329
+ this.visibility_action = props.visibility_action;
330
+ this.visibility_actions = props.visibility_actions;
331
+ this.width = props.width;
332
+ }
333
+ }
334
+
335
+ // Generated code. Do not modify.
336
+ /**
337
+ * Image.
338
+ */
339
+ class DivImage {
340
+ constructor(props) {
341
+ this.type = 'image';
342
+ this.accessibility = props.accessibility;
343
+ this.action = props.action;
344
+ this.action_animation = props.action_animation;
345
+ this.actions = props.actions;
346
+ this.alignment_horizontal = props.alignment_horizontal;
347
+ this.alignment_vertical = props.alignment_vertical;
348
+ this.alpha = props.alpha;
349
+ this.appearance_animation = props.appearance_animation;
350
+ this.aspect = props.aspect;
351
+ this.background = props.background;
352
+ this.border = props.border;
353
+ this.column_span = props.column_span;
354
+ this.content_alignment_horizontal = props.content_alignment_horizontal;
355
+ this.content_alignment_vertical = props.content_alignment_vertical;
356
+ this.doubletap_actions = props.doubletap_actions;
357
+ this.extensions = props.extensions;
358
+ this.focus = props.focus;
359
+ this.height = props.height;
360
+ this.high_priority_preview_show = props.high_priority_preview_show;
361
+ this.id = props.id;
362
+ this.image_url = props.image_url;
363
+ this.longtap_actions = props.longtap_actions;
364
+ this.margins = props.margins;
365
+ this.paddings = props.paddings;
366
+ this.placeholder_color = props.placeholder_color;
367
+ this.preload_required = props.preload_required;
368
+ this.preview = props.preview;
369
+ this.row_span = props.row_span;
370
+ this.scale = props.scale;
371
+ this.selected_actions = props.selected_actions;
372
+ this.tint_color = props.tint_color;
373
+ this.tooltips = props.tooltips;
374
+ this.transform = props.transform;
375
+ this.transition_change = props.transition_change;
376
+ this.transition_in = props.transition_in;
377
+ this.transition_out = props.transition_out;
378
+ this.transition_triggers = props.transition_triggers;
379
+ this.visibility = props.visibility;
380
+ this.visibility_action = props.visibility_action;
381
+ this.visibility_actions = props.visibility_actions;
382
+ this.width = props.width;
383
+ }
384
+ }
385
+
386
+ // Generated code. Do not modify.
387
+ /**
388
+ * Background image.
389
+ */
390
+ class DivImageBackground {
391
+ constructor(props) {
392
+ this.type = 'image';
393
+ this.alpha = props.alpha;
394
+ this.content_alignment_horizontal = props.content_alignment_horizontal;
395
+ this.content_alignment_vertical = props.content_alignment_vertical;
396
+ this.image_url = props.image_url;
397
+ this.preload_required = props.preload_required;
398
+ this.scale = props.scale;
399
+ }
400
+ }
401
+
402
+ // Generated code. Do not modify.
403
+ /**
404
+ * Progress indicator for [pager](div-pager.md).
405
+ */
406
+ class DivIndicator {
407
+ constructor(props) {
408
+ this.type = 'indicator';
409
+ this.accessibility = props === null || props === void 0 ? void 0 : props.accessibility;
410
+ this.active_item_color = props === null || props === void 0 ? void 0 : props.active_item_color;
411
+ this.active_item_size = props === null || props === void 0 ? void 0 : props.active_item_size;
412
+ this.alignment_horizontal = props === null || props === void 0 ? void 0 : props.alignment_horizontal;
413
+ this.alignment_vertical = props === null || props === void 0 ? void 0 : props.alignment_vertical;
414
+ this.alpha = props === null || props === void 0 ? void 0 : props.alpha;
415
+ this.animation = props === null || props === void 0 ? void 0 : props.animation;
416
+ this.background = props === null || props === void 0 ? void 0 : props.background;
417
+ this.border = props === null || props === void 0 ? void 0 : props.border;
418
+ this.column_span = props === null || props === void 0 ? void 0 : props.column_span;
419
+ this.extensions = props === null || props === void 0 ? void 0 : props.extensions;
420
+ this.focus = props === null || props === void 0 ? void 0 : props.focus;
421
+ this.height = props === null || props === void 0 ? void 0 : props.height;
422
+ this.id = props === null || props === void 0 ? void 0 : props.id;
423
+ this.inactive_item_color = props === null || props === void 0 ? void 0 : props.inactive_item_color;
424
+ this.margins = props === null || props === void 0 ? void 0 : props.margins;
425
+ this.minimum_item_size = props === null || props === void 0 ? void 0 : props.minimum_item_size;
426
+ this.paddings = props === null || props === void 0 ? void 0 : props.paddings;
427
+ this.pager_id = props === null || props === void 0 ? void 0 : props.pager_id;
428
+ this.row_span = props === null || props === void 0 ? void 0 : props.row_span;
429
+ this.selected_actions = props === null || props === void 0 ? void 0 : props.selected_actions;
430
+ this.shape = props === null || props === void 0 ? void 0 : props.shape;
431
+ this.space_between_centers = props === null || props === void 0 ? void 0 : props.space_between_centers;
432
+ this.tooltips = props === null || props === void 0 ? void 0 : props.tooltips;
433
+ this.transform = props === null || props === void 0 ? void 0 : props.transform;
434
+ this.transition_change = props === null || props === void 0 ? void 0 : props.transition_change;
435
+ this.transition_in = props === null || props === void 0 ? void 0 : props.transition_in;
436
+ this.transition_out = props === null || props === void 0 ? void 0 : props.transition_out;
437
+ this.transition_triggers = props === null || props === void 0 ? void 0 : props.transition_triggers;
438
+ this.visibility = props === null || props === void 0 ? void 0 : props.visibility;
439
+ this.visibility_action = props === null || props === void 0 ? void 0 : props.visibility_action;
440
+ this.visibility_actions = props === null || props === void 0 ? void 0 : props.visibility_actions;
441
+ this.width = props === null || props === void 0 ? void 0 : props.width;
442
+ }
443
+ }
444
+
445
+ // Generated code. Do not modify.
446
+ /**
447
+ * Infinite number of repetitions.
448
+ */
449
+ class DivInfinityCount {
450
+ constructor(props) {
451
+ this.type = 'infinity';
452
+ }
453
+ }
454
+
455
+ // Generated code. Do not modify.
456
+ /**
457
+ * Text input element.
458
+ */
459
+ class DivInput {
460
+ constructor(props) {
461
+ this.type = 'input';
462
+ this.accessibility = props.accessibility;
463
+ this.alignment_horizontal = props.alignment_horizontal;
464
+ this.alignment_vertical = props.alignment_vertical;
465
+ this.alpha = props.alpha;
466
+ this.background = props.background;
467
+ this.border = props.border;
468
+ this.column_span = props.column_span;
469
+ this.extensions = props.extensions;
470
+ this.focus = props.focus;
471
+ this.font_family = props.font_family;
472
+ this.font_size = props.font_size;
473
+ this.font_size_unit = props.font_size_unit;
474
+ this.font_weight = props.font_weight;
475
+ this.height = props.height;
476
+ this.highlight_color = props.highlight_color;
477
+ this.hint_color = props.hint_color;
478
+ this.hint_text = props.hint_text;
479
+ this.id = props.id;
480
+ this.keyboard_type = props.keyboard_type;
481
+ this.letter_spacing = props.letter_spacing;
482
+ this.line_height = props.line_height;
483
+ this.margins = props.margins;
484
+ this.max_visible_lines = props.max_visible_lines;
485
+ this.native_interface = props.native_interface;
486
+ this.paddings = props.paddings;
487
+ this.row_span = props.row_span;
488
+ this.select_all_on_focus = props.select_all_on_focus;
489
+ this.selected_actions = props.selected_actions;
490
+ this.text_color = props.text_color;
491
+ this.text_variable = props.text_variable;
492
+ this.tooltips = props.tooltips;
493
+ this.transform = props.transform;
494
+ this.transition_change = props.transition_change;
495
+ this.transition_in = props.transition_in;
496
+ this.transition_out = props.transition_out;
497
+ this.transition_triggers = props.transition_triggers;
498
+ this.visibility = props.visibility;
499
+ this.visibility_action = props.visibility_action;
500
+ this.visibility_actions = props.visibility_actions;
501
+ this.width = props.width;
502
+ }
503
+ }
504
+
505
+ // Generated code. Do not modify.
506
+ /**
507
+ * Element size adjusts to a parent element.
508
+ */
509
+ class DivMatchParentSize {
510
+ constructor(props) {
511
+ this.type = 'match_parent';
512
+ this.weight = props === null || props === void 0 ? void 0 : props.weight;
513
+ }
514
+ }
515
+
516
+ // Generated code. Do not modify.
517
+ /**
518
+ * Fixed width value of the visible part of a neighbouring page.
519
+ */
520
+ class DivNeighbourPageSize {
521
+ constructor(props) {
522
+ this.type = 'fixed';
523
+ this.neighbour_page_width = props.neighbour_page_width;
524
+ }
525
+ }
526
+
527
+ // Generated code. Do not modify.
528
+ /**
529
+ * Percentage value of the page width.
530
+ */
531
+ class DivPageSize {
532
+ constructor(props) {
533
+ this.type = 'percentage';
534
+ this.page_width = props.page_width;
535
+ }
536
+ }
537
+
538
+ // Generated code. Do not modify.
539
+ /**
540
+ * Pager. It contains a horizontal set of cards that can be scrolled page by page. It shows the
541
+ * main page and the beginning of the next one.
542
+ */
543
+ class DivPager {
544
+ constructor(props) {
545
+ this.type = 'pager';
546
+ this.accessibility = props.accessibility;
547
+ this.alignment_horizontal = props.alignment_horizontal;
548
+ this.alignment_vertical = props.alignment_vertical;
549
+ this.alpha = props.alpha;
550
+ this.background = props.background;
551
+ this.border = props.border;
552
+ this.column_span = props.column_span;
553
+ this.default_item = props.default_item;
554
+ this.extensions = props.extensions;
555
+ this.focus = props.focus;
556
+ this.height = props.height;
557
+ this.id = props.id;
558
+ this.item_spacing = props.item_spacing;
559
+ this.items = props.items;
560
+ this.layout_mode = props.layout_mode;
561
+ this.margins = props.margins;
562
+ this.orientation = props.orientation;
563
+ this.paddings = props.paddings;
564
+ this.restrict_parent_scroll = props.restrict_parent_scroll;
565
+ this.row_span = props.row_span;
566
+ this.selected_actions = props.selected_actions;
567
+ this.tooltips = props.tooltips;
568
+ this.transform = props.transform;
569
+ this.transition_change = props.transition_change;
570
+ this.transition_in = props.transition_in;
571
+ this.transition_out = props.transition_out;
572
+ this.transition_triggers = props.transition_triggers;
573
+ this.visibility = props.visibility;
574
+ this.visibility_action = props.visibility_action;
575
+ this.visibility_actions = props.visibility_actions;
576
+ this.width = props.width;
577
+ }
578
+ }
579
+
580
+ // Generated code. Do not modify.
581
+ /**
582
+ * Percentage value of the element size.
583
+ */
584
+ class DivPercentageSize {
585
+ constructor(props) {
586
+ this.type = 'percentage';
587
+ this.value = props.value;
588
+ }
589
+ }
590
+
591
+ // Generated code. Do not modify.
592
+ /**
593
+ * Value of the offset of the coordinates of the axis of rotation.
594
+ */
595
+ class DivPivotFixed {
596
+ constructor(props) {
597
+ this.type = 'pivot-fixed';
598
+ this.unit = props === null || props === void 0 ? void 0 : props.unit;
599
+ this.value = props === null || props === void 0 ? void 0 : props.value;
600
+ }
601
+ }
602
+
603
+ // Generated code. Do not modify.
604
+ /**
605
+ * Location of the coordinate of the axis of rotation as a percentage relative to the element.
606
+ */
607
+ class DivPivotPercentage {
608
+ constructor(props) {
609
+ this.type = 'pivot-percentage';
610
+ this.value = props.value;
611
+ }
612
+ }
613
+
614
+ // Generated code. Do not modify.
615
+ /**
616
+ * A rectangle with rounded corners.
617
+ */
618
+ class DivRoundedRectangleShape {
619
+ constructor(props) {
620
+ this.type = 'rounded_rectangle';
621
+ this.corner_radius = props === null || props === void 0 ? void 0 : props.corner_radius;
622
+ this.item_height = props === null || props === void 0 ? void 0 : props.item_height;
623
+ this.item_width = props === null || props === void 0 ? void 0 : props.item_width;
624
+ }
625
+ }
626
+
627
+ // Generated code. Do not modify.
628
+ /**
629
+ * Scale animation.
630
+ */
631
+ class DivScaleTransition {
632
+ constructor(props) {
633
+ this.type = 'scale';
634
+ this.duration = props === null || props === void 0 ? void 0 : props.duration;
635
+ this.interpolator = props === null || props === void 0 ? void 0 : props.interpolator;
636
+ this.pivot_x = props === null || props === void 0 ? void 0 : props.pivot_x;
637
+ this.pivot_y = props === null || props === void 0 ? void 0 : props.pivot_y;
638
+ this.scale = props === null || props === void 0 ? void 0 : props.scale;
639
+ this.start_delay = props === null || props === void 0 ? void 0 : props.start_delay;
640
+ }
641
+ }
642
+
643
+ // Generated code. Do not modify.
644
+ /**
645
+ * A separating line between elements.
646
+ */
647
+ class DivSeparator {
648
+ constructor(props) {
649
+ this.type = 'separator';
650
+ this.accessibility = props === null || props === void 0 ? void 0 : props.accessibility;
651
+ this.action = props === null || props === void 0 ? void 0 : props.action;
652
+ this.action_animation = props === null || props === void 0 ? void 0 : props.action_animation;
653
+ this.actions = props === null || props === void 0 ? void 0 : props.actions;
654
+ this.alignment_horizontal = props === null || props === void 0 ? void 0 : props.alignment_horizontal;
655
+ this.alignment_vertical = props === null || props === void 0 ? void 0 : props.alignment_vertical;
656
+ this.alpha = props === null || props === void 0 ? void 0 : props.alpha;
657
+ this.background = props === null || props === void 0 ? void 0 : props.background;
658
+ this.border = props === null || props === void 0 ? void 0 : props.border;
659
+ this.column_span = props === null || props === void 0 ? void 0 : props.column_span;
660
+ this.delimiter_style = props === null || props === void 0 ? void 0 : props.delimiter_style;
661
+ this.doubletap_actions = props === null || props === void 0 ? void 0 : props.doubletap_actions;
662
+ this.extensions = props === null || props === void 0 ? void 0 : props.extensions;
663
+ this.focus = props === null || props === void 0 ? void 0 : props.focus;
664
+ this.height = props === null || props === void 0 ? void 0 : props.height;
665
+ this.id = props === null || props === void 0 ? void 0 : props.id;
666
+ this.longtap_actions = props === null || props === void 0 ? void 0 : props.longtap_actions;
667
+ this.margins = props === null || props === void 0 ? void 0 : props.margins;
668
+ this.paddings = props === null || props === void 0 ? void 0 : props.paddings;
669
+ this.row_span = props === null || props === void 0 ? void 0 : props.row_span;
670
+ this.selected_actions = props === null || props === void 0 ? void 0 : props.selected_actions;
671
+ this.tooltips = props === null || props === void 0 ? void 0 : props.tooltips;
672
+ this.transform = props === null || props === void 0 ? void 0 : props.transform;
673
+ this.transition_change = props === null || props === void 0 ? void 0 : props.transition_change;
674
+ this.transition_in = props === null || props === void 0 ? void 0 : props.transition_in;
675
+ this.transition_out = props === null || props === void 0 ? void 0 : props.transition_out;
676
+ this.transition_triggers = props === null || props === void 0 ? void 0 : props.transition_triggers;
677
+ this.visibility = props === null || props === void 0 ? void 0 : props.visibility;
678
+ this.visibility_action = props === null || props === void 0 ? void 0 : props.visibility_action;
679
+ this.visibility_actions = props === null || props === void 0 ? void 0 : props.visibility_actions;
680
+ this.width = props === null || props === void 0 ? void 0 : props.width;
681
+ }
682
+ }
683
+
684
+ // Generated code. Do not modify.
685
+ /**
686
+ * Drawable of a simple geometric shape.
687
+ */
688
+ class DivShapeDrawable {
689
+ constructor(props) {
690
+ this.type = 'shape_drawable';
691
+ this.color = props.color;
692
+ this.shape = props.shape;
693
+ this.stroke = props.stroke;
694
+ }
695
+ }
696
+
697
+ // Generated code. Do not modify.
698
+ /**
699
+ * Slide animation.
700
+ */
701
+ class DivSlideTransition {
702
+ constructor(props) {
703
+ this.type = 'slide';
704
+ this.distance = props === null || props === void 0 ? void 0 : props.distance;
705
+ this.duration = props === null || props === void 0 ? void 0 : props.duration;
706
+ this.edge = props === null || props === void 0 ? void 0 : props.edge;
707
+ this.interpolator = props === null || props === void 0 ? void 0 : props.interpolator;
708
+ this.start_delay = props === null || props === void 0 ? void 0 : props.start_delay;
709
+ }
710
+ }
711
+
712
+ // Generated code. Do not modify.
713
+ /**
714
+ * Slider for selecting a value in the range.
715
+ */
716
+ class DivSlider {
717
+ constructor(props) {
718
+ this.type = 'slider';
719
+ this.accessibility = props.accessibility;
720
+ this.alignment_horizontal = props.alignment_horizontal;
721
+ this.alignment_vertical = props.alignment_vertical;
722
+ this.alpha = props.alpha;
723
+ this.background = props.background;
724
+ this.border = props.border;
725
+ this.column_span = props.column_span;
726
+ this.extensions = props.extensions;
727
+ this.focus = props.focus;
728
+ this.height = props.height;
729
+ this.id = props.id;
730
+ this.margins = props.margins;
731
+ this.max_value = props.max_value;
732
+ this.min_value = props.min_value;
733
+ this.paddings = props.paddings;
734
+ this.row_span = props.row_span;
735
+ this.secondary_value_accessibility = props.secondary_value_accessibility;
736
+ this.selected_actions = props.selected_actions;
737
+ this.thumb_secondary_style = props.thumb_secondary_style;
738
+ this.thumb_secondary_text_style = props.thumb_secondary_text_style;
739
+ this.thumb_secondary_value_variable = props.thumb_secondary_value_variable;
740
+ this.thumb_style = props.thumb_style;
741
+ this.thumb_text_style = props.thumb_text_style;
742
+ this.thumb_value_variable = props.thumb_value_variable;
743
+ this.tick_mark_active_style = props.tick_mark_active_style;
744
+ this.tick_mark_inactive_style = props.tick_mark_inactive_style;
745
+ this.tooltips = props.tooltips;
746
+ this.track_active_style = props.track_active_style;
747
+ this.track_inactive_style = props.track_inactive_style;
748
+ this.transform = props.transform;
749
+ this.transition_change = props.transition_change;
750
+ this.transition_in = props.transition_in;
751
+ this.transition_out = props.transition_out;
752
+ this.transition_triggers = props.transition_triggers;
753
+ this.visibility = props.visibility;
754
+ this.visibility_action = props.visibility_action;
755
+ this.visibility_actions = props.visibility_actions;
756
+ this.width = props.width;
757
+ }
758
+ }
759
+
760
+ // Generated code. Do not modify.
761
+ /**
762
+ * Solid background color.
763
+ */
764
+ class DivSolidBackground {
765
+ constructor(props) {
766
+ this.type = 'solid';
767
+ this.color = props.color;
768
+ }
769
+ }
770
+
771
+ // Generated code. Do not modify.
772
+ /**
773
+ * It contains sets of states for visual elements and switches between them.
774
+ */
775
+ class DivState {
776
+ constructor(props) {
777
+ this.type = 'state';
778
+ this.accessibility = props.accessibility;
779
+ this.alignment_horizontal = props.alignment_horizontal;
780
+ this.alignment_vertical = props.alignment_vertical;
781
+ this.alpha = props.alpha;
782
+ this.background = props.background;
783
+ this.border = props.border;
784
+ this.column_span = props.column_span;
785
+ this.default_state_id = props.default_state_id;
786
+ this.div_id = props.div_id;
787
+ this.extensions = props.extensions;
788
+ this.focus = props.focus;
789
+ this.height = props.height;
790
+ this.id = props.id;
791
+ this.margins = props.margins;
792
+ this.paddings = props.paddings;
793
+ this.row_span = props.row_span;
794
+ this.selected_actions = props.selected_actions;
795
+ this.states = props.states;
796
+ this.tooltips = props.tooltips;
797
+ this.transform = props.transform;
798
+ this.transition_animation_selector = props.transition_animation_selector;
799
+ this.transition_change = props.transition_change;
800
+ this.transition_in = props.transition_in;
801
+ this.transition_out = props.transition_out;
802
+ this.transition_triggers = props.transition_triggers;
803
+ this.visibility = props.visibility;
804
+ this.visibility_action = props.visibility_action;
805
+ this.visibility_actions = props.visibility_actions;
806
+ this.width = props.width;
807
+ }
808
+ }
809
+
810
+ // Generated code. Do not modify.
811
+ /**
812
+ * Tabs. Height of the first tab is determined by its contents, and height of the remaining
813
+ * [depends on the platform](../../location.dita#tabs).
814
+ */
815
+ class DivTabs {
816
+ constructor(props) {
817
+ this.type = 'tabs';
818
+ this.accessibility = props.accessibility;
819
+ this.alignment_horizontal = props.alignment_horizontal;
820
+ this.alignment_vertical = props.alignment_vertical;
821
+ this.alpha = props.alpha;
822
+ this.background = props.background;
823
+ this.border = props.border;
824
+ this.column_span = props.column_span;
825
+ this.dynamic_height = props.dynamic_height;
826
+ this.extensions = props.extensions;
827
+ this.focus = props.focus;
828
+ this.has_separator = props.has_separator;
829
+ this.height = props.height;
830
+ this.id = props.id;
831
+ this.items = props.items;
832
+ this.margins = props.margins;
833
+ this.paddings = props.paddings;
834
+ this.restrict_parent_scroll = props.restrict_parent_scroll;
835
+ this.row_span = props.row_span;
836
+ this.selected_actions = props.selected_actions;
837
+ this.selected_tab = props.selected_tab;
838
+ this.separator_color = props.separator_color;
839
+ this.separator_paddings = props.separator_paddings;
840
+ this.switch_tabs_by_content_swipe_enabled = props.switch_tabs_by_content_swipe_enabled;
841
+ this.tab_title_style = props.tab_title_style;
842
+ this.title_paddings = props.title_paddings;
843
+ this.tooltips = props.tooltips;
844
+ this.transform = props.transform;
845
+ this.transition_change = props.transition_change;
846
+ this.transition_in = props.transition_in;
847
+ this.transition_out = props.transition_out;
848
+ this.transition_triggers = props.transition_triggers;
849
+ this.visibility = props.visibility;
850
+ this.visibility_action = props.visibility_action;
851
+ this.visibility_actions = props.visibility_actions;
852
+ this.width = props.width;
853
+ }
854
+ }
855
+
856
+ // Generated code. Do not modify.
857
+ /**
858
+ * Text.
859
+ */
860
+ class DivText {
861
+ constructor(props) {
862
+ this.type = 'text';
863
+ this.accessibility = props.accessibility;
864
+ this.action = props.action;
865
+ this.action_animation = props.action_animation;
866
+ this.actions = props.actions;
867
+ this.alignment_horizontal = props.alignment_horizontal;
868
+ this.alignment_vertical = props.alignment_vertical;
869
+ this.alpha = props.alpha;
870
+ this.auto_ellipsize = props.auto_ellipsize;
871
+ this.background = props.background;
872
+ this.border = props.border;
873
+ this.column_span = props.column_span;
874
+ this.doubletap_actions = props.doubletap_actions;
875
+ this.ellipsis = props.ellipsis;
876
+ this.extensions = props.extensions;
877
+ this.focus = props.focus;
878
+ this.focused_text_color = props.focused_text_color;
879
+ this.font_family = props.font_family;
880
+ this.font_size = props.font_size;
881
+ this.font_size_unit = props.font_size_unit;
882
+ this.font_weight = props.font_weight;
883
+ this.height = props.height;
884
+ this.id = props.id;
885
+ this.images = props.images;
886
+ this.letter_spacing = props.letter_spacing;
887
+ this.line_height = props.line_height;
888
+ this.longtap_actions = props.longtap_actions;
889
+ this.margins = props.margins;
890
+ this.max_lines = props.max_lines;
891
+ this.min_hidden_lines = props.min_hidden_lines;
892
+ this.paddings = props.paddings;
893
+ this.ranges = props.ranges;
894
+ this.row_span = props.row_span;
895
+ this.selectable = props.selectable;
896
+ this.selected_actions = props.selected_actions;
897
+ this.strike = props.strike;
898
+ this.text = props.text;
899
+ this.text_alignment_horizontal = props.text_alignment_horizontal;
900
+ this.text_alignment_vertical = props.text_alignment_vertical;
901
+ this.text_color = props.text_color;
902
+ this.text_gradient = props.text_gradient;
903
+ this.tooltips = props.tooltips;
904
+ this.transform = props.transform;
905
+ this.transition_change = props.transition_change;
906
+ this.transition_in = props.transition_in;
907
+ this.transition_out = props.transition_out;
908
+ this.transition_triggers = props.transition_triggers;
909
+ this.truncate = props.truncate;
910
+ this.underline = props.underline;
911
+ this.visibility = props.visibility;
912
+ this.visibility_action = props.visibility_action;
913
+ this.visibility_actions = props.visibility_actions;
914
+ this.width = props.width;
915
+ }
916
+ }
917
+
918
+ // Generated code. Do not modify.
919
+ /**
920
+ * The size of an element adjusts to its contents.
921
+ */
922
+ class DivWrapContentSize {
923
+ constructor(props) {
924
+ this.type = 'wrap_content';
925
+ this.constrained = props === null || props === void 0 ? void 0 : props.constrained;
926
+ }
927
+ }
928
+
929
+ // Generated code. Do not modify.
930
+ /**
931
+ * An integer variable.
932
+ */
933
+ class IntegerVariable {
934
+ constructor(props) {
935
+ this.type = 'integer';
936
+ this.name = props.name;
937
+ this.value = props.value;
938
+ }
939
+ }
940
+
941
+ // Generated code. Do not modify.
942
+ /**
943
+ * A floating-point variable.
944
+ */
945
+ class NumberVariable {
946
+ constructor(props) {
947
+ this.type = 'number';
948
+ this.name = props.name;
949
+ this.value = props.value;
950
+ }
951
+ }
952
+
953
+ // Generated code. Do not modify.
954
+ /**
955
+ * A string variable.
956
+ */
957
+ class StringVariable {
958
+ constructor(props) {
959
+ this.type = 'string';
960
+ this.name = props.name;
961
+ this.value = props.value;
962
+ }
963
+ }
964
+
965
+ // Generated code. Do not modify.
966
+ /**
967
+ * Variable — URL as a string.
968
+ */
969
+ class UrlVariable {
970
+ constructor(props) {
971
+ this.type = 'url';
972
+ this.name = props.name;
973
+ this.value = props.value;
974
+ }
975
+ }
976
+
977
+ function fixed(value, unit = undefined) {
978
+ if (unit === undefined) {
979
+ return new DivFixedSize({ value: value });
980
+ }
981
+ return new DivFixedSize({ unit: unit, value: value });
982
+ }
983
+ function matchParent() {
984
+ return new DivMatchParentSize();
985
+ }
986
+ function weighted(weight) {
987
+ return new DivMatchParentSize({ weight: weight });
988
+ }
989
+ function wrapContent() {
990
+ return new DivWrapContentSize();
991
+ }
992
+
993
+ /**
994
+ * DFS-Обход js-объекта как дерева с выполнением в каждом
995
+ * узле заданного действия
996
+ * @param tree js-объект
997
+ * @param nodeAction действие, выполняемое для каждого узла дерева
998
+ */
999
+ function treeWalkDFS(tree, nodeAction) {
1000
+ const stack = [[tree, []]];
1001
+ while (stack.length) {
1002
+ const [node, path] = stack.shift();
1003
+ nodeAction(node, path);
1004
+ if (typeof node === 'object' && node !== null) {
1005
+ stack.unshift(...Object.entries(node).map(([key, obj]) => [obj, [...path, key]]));
1006
+ }
1007
+ }
1008
+ }
1009
+ function copyTemplates(templates) {
1010
+ const copy = {};
1011
+ const placeHolder = (node) => {
1012
+ if (!node || ['string', 'number'].includes(typeof node)) {
1013
+ return node;
1014
+ }
1015
+ if (Array.isArray(node)) {
1016
+ return [];
1017
+ }
1018
+ return Object.create(Object.getPrototypeOf(node));
1019
+ };
1020
+ const clone = (node, path) => {
1021
+ let parentPointer = copy;
1022
+ path = [...path];
1023
+ while (path.length > 1) {
1024
+ parentPointer = parentPointer[path.shift()];
1025
+ }
1026
+ const cur = path[0];
1027
+ if (!cur) {
1028
+ return;
1029
+ }
1030
+ parentPointer[cur] = placeHolder(node);
1031
+ };
1032
+ treeWalkDFS(templates, clone);
1033
+ return copy;
1034
+ }
1035
+
1036
+ const expr = Symbol();
1037
+ class UnsafeDivExpression {
1038
+ constructor(expression) {
1039
+ this[expr] = expression;
1040
+ }
1041
+ toJSON() {
1042
+ return this[expr];
1043
+ }
1044
+ toString() {
1045
+ return this[expr];
1046
+ }
1047
+ }
1048
+
1049
+ function expression(expression) {
1050
+ return new UnsafeDivExpression(expression);
1051
+ }
1052
+ const replacer = {
1053
+ '\\': '\\\\',
1054
+ '@{': '\\@{',
1055
+ };
1056
+ function escapeExpression(str) {
1057
+ return str.replace(/\\|(@{)/g, (full) => {
1058
+ return replacer[full];
1059
+ });
1060
+ }
1061
+
1062
+ /* eslint-disable @typescript-eslint/ban-types */
1063
+ class TemplatePropertyReference {
1064
+ constructor(name) {
1065
+ this.name = name;
1066
+ }
1067
+ }
1068
+ function reference(name) {
1069
+ return new TemplatePropertyReference(name);
1070
+ }
1071
+ class TemplateBlock {
1072
+ constructor(type, props) {
1073
+ this.type = type;
1074
+ Object.assign(this, props);
1075
+ }
1076
+ getProps() {
1077
+ return Object.keys(this).reduce((acc, k) => {
1078
+ if (k !== 'type') {
1079
+ acc[k] = true;
1080
+ }
1081
+ return acc;
1082
+ }, {});
1083
+ }
1084
+ }
1085
+ function template(type, props) {
1086
+ return new TemplateBlock(type, props);
1087
+ }
1088
+ function escapeCard(obj) {
1089
+ if (typeof obj === 'string') {
1090
+ return escapeExpression(obj);
1091
+ }
1092
+ else if (obj instanceof UnsafeDivExpression) {
1093
+ return obj.toJSON();
1094
+ }
1095
+ else if (obj && typeof obj === 'object') {
1096
+ if (Array.isArray(obj)) {
1097
+ return obj.map(escapeCard);
1098
+ }
1099
+ else {
1100
+ return Object.keys(obj).reduce((acc, item) => {
1101
+ acc[item] = escapeCard(obj[item]);
1102
+ return acc;
1103
+ }, {});
1104
+ }
1105
+ }
1106
+ return obj;
1107
+ }
1108
+ class Card {
1109
+ constructor(templates, card) {
1110
+ this.templates = templates;
1111
+ this.card = card;
1112
+ }
1113
+ toJSON() {
1114
+ return escapeCard(this);
1115
+ }
1116
+ }
1117
+ function divCard(templates, card) {
1118
+ return new Card(templates, card);
1119
+ }
1120
+
1121
+ /* eslint-disable @typescript-eslint/ban-types */
1122
+ /**
1123
+ * Creates typed functions for templates instance construction
1124
+ * @param templates templates map of the form { template_name: template }
1125
+ * @example
1126
+ * const templates = {
1127
+ * template: new DivContainer({
1128
+ * paddings: { left: 3 },
1129
+ * items: [ new DivText({ text: reference('var') }) ]
1130
+ * })
1131
+ * };
1132
+ * const helpers = templateHelper(templates);
1133
+ * helpers.template({var: '123'});
1134
+ */
1135
+ function templateHelper(templates) {
1136
+ const helpers = {};
1137
+ for (const key of Object.keys(templates)) {
1138
+ helpers[key] = (props) => new TemplateBlock(key, props);
1139
+ }
1140
+ return helpers;
1141
+ }
1142
+
1143
+ /**
1144
+ * Проверяет имя шаблона и возвращает true,
1145
+ * если имя шаблона нужно сохранить.
1146
+ * Например, в веб-морде есть 'мета-шаблон'
1147
+ * home:block, который нельзя переименовывать
1148
+ */
1149
+ function isExternalTemplate(templateName) {
1150
+ return templateName.startsWith('home:');
1151
+ }
1152
+ /**
1153
+ * Поиск вложенных шаблонов для заданного шаблона
1154
+ * @param name - имя заданного шаблона
1155
+ * @param templates - список всех шаблонов для проверки
1156
+ * разрешимости зависимостей
1157
+ */
1158
+ function findPlainDeps(template) {
1159
+ const deps = new Set();
1160
+ treeWalkDFS(template, (node) => {
1161
+ if (node instanceof TemplateBlock && !isExternalTemplate(node.type)) {
1162
+ deps.add(node.type);
1163
+ }
1164
+ });
1165
+ return deps;
1166
+ }
1167
+ const inProgress = 1;
1168
+ const isFinished = 2;
1169
+ /**
1170
+ * Обход шаблонов с разрешением зависимостей
1171
+ * перед выполнением действия
1172
+ * @param templates
1173
+ * @param resolvedAction действие выполнямое для шаблона,
1174
+ * когда все его зависимости разрешены
1175
+ * @param depsResolved ранее разрешенные зависимости, например для общих шаблонов
1176
+ */
1177
+ function runResolveDeps(templates, resolvedAction, depsResolved = {}) {
1178
+ depsResolved = Object.assign({}, depsResolved);
1179
+ const progress = {};
1180
+ for (const k of Object.keys(depsResolved)) {
1181
+ progress[k] = isFinished;
1182
+ }
1183
+ const stack = Object.keys(templates);
1184
+ while (stack.length) {
1185
+ const name = stack.pop();
1186
+ if (progress[name] === isFinished) {
1187
+ continue;
1188
+ }
1189
+ const plainDeps = [...findPlainDeps(templates[name])];
1190
+ const unresolvedDeps = plainDeps.filter((dep) => !(progress[dep] === isFinished));
1191
+ const unsolvableDeps = unresolvedDeps.filter((depName) => !templates[depName]);
1192
+ if (unsolvableDeps.length !== 0) {
1193
+ throw new Error(`template '${name}' unsolvable dependencies: ${unsolvableDeps.map((b) => `'${b}'`).join(',')}`);
1194
+ }
1195
+ if (unresolvedDeps.length === 0) {
1196
+ const template = templates[name];
1197
+ depsResolved[name] = resolvedAction({ name, template, plainDeps, depsResolved });
1198
+ progress[name] = isFinished;
1199
+ }
1200
+ else if (progress[name] === inProgress) {
1201
+ throw new Error(`template ${name}: cyclic depdendencies`);
1202
+ }
1203
+ else {
1204
+ progress[name] = inProgress;
1205
+ stack.push(name, ...unresolvedDeps);
1206
+ }
1207
+ }
1208
+ return depsResolved;
1209
+ }
1210
+ /**
1211
+ * Поиск зависимостей шаблонов
1212
+ * @param templates шаблоны
1213
+ * @returns для каждого шаблона список его зависимостей
1214
+ */
1215
+ function templatesDepsMap(templates, depsResolved = {}) {
1216
+ return runResolveDeps(templates, ({ name, plainDeps, depsResolved }) => {
1217
+ const deps = new Set([name]);
1218
+ for (const plainDep of plainDeps) {
1219
+ for (const dep of depsResolved[plainDep]) {
1220
+ deps.add(dep);
1221
+ }
1222
+ }
1223
+ return [...deps];
1224
+ }, depsResolved);
1225
+ }
1226
+
1227
+ /**
1228
+ * templateHelper with memoization of templates names for later
1229
+ * selection of used templates. It memoizes only explicitly used
1230
+ * names without tracking dependencies.
1231
+ * @param options
1232
+ * @param options.customName adds templates names mapping.
1233
+ * Instead of original template name adjust template's type to custom value
1234
+ * returned by customName. Can be used for templates versioning.
1235
+ */
1236
+ function thelperWithMemo(options) {
1237
+ const used = new Set();
1238
+ const proxyHandler = {
1239
+ get(_, templateName) {
1240
+ const templateRenamed = (options === null || options === void 0 ? void 0 : options.customName) ? options.customName(templateName) : templateName;
1241
+ used.add(templateName);
1242
+ return (props) => (Object.assign(Object.assign({}, props), { type: templateRenamed }));
1243
+ },
1244
+ };
1245
+ const thelper = new Proxy({}, proxyHandler);
1246
+ return { used, thelper };
1247
+ }
1248
+
1249
+ /**
1250
+ * Переписывание шаблонов с заменой имен вложенных шаблонов
1251
+ * Например, в шаблоне
1252
+ * new DivContainer({
1253
+ * items: [
1254
+ * template('template2')
1255
+ * ]
1256
+ * })
1257
+ * 'template2' будет заменен на `template2/${hash(templates.template2)}`
1258
+ * @param templates шаблоны для перезаписи
1259
+ * @param rename функция, возвращающая новое имя
1260
+ * @param depsResolved ранее вычисленные имена, например общих шаблонов
1261
+ * @returns переписанные шаблоны + хэшмап новых имен
1262
+ */
1263
+ function rewriteNames(templates, rename, resolvedNames = {}) {
1264
+ templates = copyTemplates(templates);
1265
+ resolvedNames = runResolveDeps(templates, ({ name, template, depsResolved }) => {
1266
+ treeWalkDFS(template, (node) => {
1267
+ if (node instanceof TemplateBlock && !isExternalTemplate(node.type)) {
1268
+ node.type = depsResolved[node.type];
1269
+ }
1270
+ });
1271
+ return rename(name, templates);
1272
+ }, resolvedNames);
1273
+ return { templates, resolvedNames };
1274
+ }
1275
+
1276
+ function rewriteRefsTemplate(template) {
1277
+ const stack = [template];
1278
+ while (stack.length > 0) {
1279
+ const obj = stack.pop();
1280
+ if (obj && typeof obj === 'object') {
1281
+ for (const key in obj) {
1282
+ const objChild = obj[key];
1283
+ if (objChild && typeof objChild === 'object') {
1284
+ if (objChild instanceof TemplatePropertyReference) {
1285
+ obj[key] = undefined; // delete ломает валидатор
1286
+ if (objChild.name !== key) {
1287
+ obj['$' + key] = objChild.name;
1288
+ }
1289
+ }
1290
+ else {
1291
+ stack.push(objChild);
1292
+ }
1293
+ }
1294
+ }
1295
+ }
1296
+ }
1297
+ }
1298
+ /**
1299
+ * Заменяет в шаблонах замену параметры вида
1300
+ * prop: reference('template_prop')
1301
+ * на
1302
+ * $prop: 'template_prop'
1303
+ * @param templates Шаблоны
1304
+ * @returns Шаблоны, готовые для сериализации в формате DivKit
1305
+ */
1306
+ function rewriteRefs(templates) {
1307
+ const result = copyTemplates(templates);
1308
+ for (const template of Object.values(result)) {
1309
+ rewriteRefsTemplate(template);
1310
+ }
1311
+ return result;
1312
+ }
1313
+
1314
+ function getTemplateHash(template) {
1315
+ return crypto.createHash('md5').update(JSON.stringify(template), 'utf8').digest('hex');
1316
+ }
1317
+ function getHashes(templates) {
1318
+ const hashes = {};
1319
+ for (const template of Object.keys(templates)) {
1320
+ hashes[template] = getTemplateHash(templates[template]);
1321
+ }
1322
+ return hashes;
1323
+ }
1324
+ function versionName(name, hash) {
1325
+ return `${name}/${hash}`;
1326
+ }
1327
+ function thelperVersion(templates) {
1328
+ const hashes = getHashes(templates);
1329
+ return (name) => versionName(name, hashes[name]);
1330
+ }
1331
+ /**
1332
+ * Переписывает вызовы TemplateBlock в шаблонах,
1333
+ * добавляя к их именам версии (md5 хэш).
1334
+ * Имена корневых шаблонов (ключи объекта templates) не меняются!
1335
+ * @param templates шаблоны
1336
+ * @param resolvedNames ранее вычисленные имена, например общих шаблонов
1337
+ * @returns хэшмап новых имен шаблонов
1338
+ */
1339
+ function rewriteTemplateVersions(templates, resolvedNames) {
1340
+ const hashes = {};
1341
+ const rename = (name, templates) => {
1342
+ var _a;
1343
+ const template = templates[name];
1344
+ if (!template) {
1345
+ throw new Error(`No template ${name}`);
1346
+ }
1347
+ const hash = (_a = hashes[name]) !== null && _a !== void 0 ? _a : getTemplateHash(template);
1348
+ return versionName(name, hash);
1349
+ };
1350
+ return rewriteNames(templates, rename, resolvedNames);
1351
+ }
1352
+
1353
+ exports.BooleanVariable = BooleanVariable;
1354
+ exports.ColorVariable = ColorVariable;
1355
+ exports.DivAppearanceSetTransition = DivAppearanceSetTransition;
1356
+ exports.DivChangeBoundsTransition = DivChangeBoundsTransition;
1357
+ exports.DivChangeSetTransition = DivChangeSetTransition;
1358
+ exports.DivContainer = DivContainer;
1359
+ exports.DivCustom = DivCustom;
1360
+ exports.DivFadeTransition = DivFadeTransition;
1361
+ exports.DivFixedCount = DivFixedCount;
1362
+ exports.DivFixedSize = DivFixedSize;
1363
+ exports.DivGallery = DivGallery;
1364
+ exports.DivGifImage = DivGifImage;
1365
+ exports.DivGradientBackground = DivGradientBackground;
1366
+ exports.DivGrid = DivGrid;
1367
+ exports.DivImage = DivImage;
1368
+ exports.DivImageBackground = DivImageBackground;
1369
+ exports.DivIndicator = DivIndicator;
1370
+ exports.DivInfinityCount = DivInfinityCount;
1371
+ exports.DivInput = DivInput;
1372
+ exports.DivMatchParentSize = DivMatchParentSize;
1373
+ exports.DivNeighbourPageSize = DivNeighbourPageSize;
1374
+ exports.DivPageSize = DivPageSize;
1375
+ exports.DivPager = DivPager;
1376
+ exports.DivPercentageSize = DivPercentageSize;
1377
+ exports.DivPivotFixed = DivPivotFixed;
1378
+ exports.DivPivotPercentage = DivPivotPercentage;
1379
+ exports.DivRoundedRectangleShape = DivRoundedRectangleShape;
1380
+ exports.DivScaleTransition = DivScaleTransition;
1381
+ exports.DivSeparator = DivSeparator;
1382
+ exports.DivShapeDrawable = DivShapeDrawable;
1383
+ exports.DivSlideTransition = DivSlideTransition;
1384
+ exports.DivSlider = DivSlider;
1385
+ exports.DivSolidBackground = DivSolidBackground;
1386
+ exports.DivState = DivState;
1387
+ exports.DivTabs = DivTabs;
1388
+ exports.DivText = DivText;
1389
+ exports.DivWrapContentSize = DivWrapContentSize;
1390
+ exports.IntegerVariable = IntegerVariable;
1391
+ exports.NumberVariable = NumberVariable;
1392
+ exports.StringVariable = StringVariable;
1393
+ exports.TemplateBlock = TemplateBlock;
1394
+ exports.TemplatePropertyReference = TemplatePropertyReference;
1395
+ exports.UrlVariable = UrlVariable;
1396
+ exports.copyTemplates = copyTemplates;
1397
+ exports.divCard = divCard;
1398
+ exports.escapeCard = escapeCard;
1399
+ exports.escapeExpression = escapeExpression;
1400
+ exports.expression = expression;
1401
+ exports.fixed = fixed;
1402
+ exports.getTemplateHash = getTemplateHash;
1403
+ exports.isExternalTemplate = isExternalTemplate;
1404
+ exports.matchParent = matchParent;
1405
+ exports.reference = reference;
1406
+ exports.rewriteNames = rewriteNames;
1407
+ exports.rewriteRefs = rewriteRefs;
1408
+ exports.rewriteTemplateVersions = rewriteTemplateVersions;
1409
+ exports.runResolveDeps = runResolveDeps;
1410
+ exports.template = template;
1411
+ exports.templateHelper = templateHelper;
1412
+ exports.templatesDepsMap = templatesDepsMap;
1413
+ exports.thelperVersion = thelperVersion;
1414
+ exports.thelperWithMemo = thelperWithMemo;
1415
+ exports.treeWalkDFS = treeWalkDFS;
1416
+ exports.weighted = weighted;
1417
+ exports.wrapContent = wrapContent;
1418
+ //# sourceMappingURL=jsonbuilder.js.map