@mathscan/math-exercise-engine 1.0.6 → 1.0.8

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.
package/dist/index.d.ts CHANGED
@@ -29,8 +29,16 @@ export declare const AST_TYPES: {
29
29
  readonly TEXT_BLOCK: "TextBlock";
30
30
  /** Line containing inline elements */
31
31
  readonly LINE_BLOCK: "LineBlock";
32
+ /** Table layout block */
33
+ readonly TABLE_BLOCK: "TableBlock";
34
+ /** Row within a table */
35
+ readonly TABLE_ROW: "TableRow";
36
+ /** Cell within a table row */
37
+ readonly TABLE_CELL: "TableCell";
32
38
  /** Drag-and-drop options tool */
33
39
  readonly DRAG_OPTIONS: "DragOptions";
40
+ /** Radio button options tool */
41
+ readonly RADIO_OPTIONS: "RadioOptions";
34
42
  /** Numeric keypad input tool */
35
43
  readonly NUMERIC_KEYPAD: "NumericKeypad";
36
44
  /** Simple answer matching validation */
@@ -186,7 +194,7 @@ export declare function compileWithAST(dsl: string): {
186
194
  type: "ExpressionValidation";
187
195
  };
188
196
  type: "ExerciseDocument";
189
- lines: {
197
+ lines: ({
190
198
  type: "LineBlock";
191
199
  inlines: ({
192
200
  value: string;
@@ -219,7 +227,53 @@ export declare function compileWithAST(dsl: string): {
219
227
  digits: number;
220
228
  answer?: string | number | undefined;
221
229
  })[];
222
- }[];
230
+ } | {
231
+ type: "TableBlock";
232
+ cols: number;
233
+ rows: {
234
+ type: "TableRow";
235
+ cells: {
236
+ type: "TableCell";
237
+ inlines: ({
238
+ value: string;
239
+ type: "FreeText";
240
+ } | {
241
+ type: "Space";
242
+ } | {
243
+ value: string;
244
+ type: "HighlightedText";
245
+ highlight?: [number, number] | undefined;
246
+ } | {
247
+ value: string;
248
+ type: "ColorText";
249
+ color: string;
250
+ highlight?: [number, number] | undefined;
251
+ } | {
252
+ value: string;
253
+ type: "BoldText";
254
+ highlight?: [number, number] | undefined;
255
+ } | {
256
+ length: number;
257
+ type: "InlineInput";
258
+ inputType: "string";
259
+ name: string;
260
+ answer?: string | number | undefined;
261
+ } | {
262
+ type: "InlineInput";
263
+ inputType: "numeric";
264
+ name: string;
265
+ digits: number;
266
+ answer?: string | number | undefined;
267
+ })[];
268
+ colspan?: number | undefined;
269
+ }[];
270
+ }[];
271
+ } | {
272
+ type: "RadioOptions";
273
+ options: string[];
274
+ name: string;
275
+ answer: string;
276
+ })[];
223
277
  question?: {
224
278
  value: string;
225
279
  type: "TextBlock";
@@ -253,6 +307,9 @@ export declare function compileWithAST(dsl: string): {
253
307
  } | {
254
308
  type: "drag-options";
255
309
  options: string[];
310
+ } | {
311
+ type: "radio-options";
312
+ options: string[];
256
313
  } | {
257
314
  type: "numeric-keypad";
258
315
  includeOperators?: boolean | undefined;
@@ -268,688 +325,1638 @@ export declare function compileWithAST(dsl: string): {
268
325
  };
269
326
  };
270
327
 
271
- /**
272
- * Create a bold text inline element
273
- */
274
- export declare function createBoldText(value: string, highlight?: [number, number]): BoldTextInline;
275
-
276
- /**
277
- * Create a color text inline element
278
- */
279
- export declare function createColorText(value: string, color: string, highlight?: [number, number]): ColorTextInline;
280
-
281
- /**
282
- * Create a drag options tool
283
- */
284
- export declare function createDragOptions(options: string[]): DragOptionsTool;
285
-
286
- /**
287
- * Create an exercise document
288
- */
289
- export declare function createExerciseDocument(question: z.infer<typeof TextBlockSchema> | undefined, lines: z.infer<typeof LineBlockSchema>[], validation: z.infer<typeof ValidationNodeSchema>, tools?: z.infer<typeof ToolNodeSchema>[]): ExerciseDocument;
290
-
291
- /**
292
- * Create an expression validation node
293
- */
294
- export declare function createExpressionValidation(expression: string): ExpressionValidation;
295
-
296
- /**
297
- * Create a free text inline element
298
- */
299
- export declare function createFreeText(value: string): FreeTextInline;
300
-
301
- /**
302
- * Create a highlighted text inline element
303
- */
304
- export declare function createHighlightedText(value: string, highlight?: [number, number]): HighlightedTextInline;
305
-
306
- /**
307
- * Create a line block
308
- */
309
- export declare function createLineBlock(inlines: any[]): LineBlock;
310
-
311
- /**
312
- * Create a numeric inline input widget (W_N_I)
313
- */
314
- export declare function createNumericInput(name: string, digits: number, answer?: string | number): InlineInputWidget;
315
-
316
- /**
317
- * Create a numeric keypad tool
318
- */
319
- export declare function createNumericKeypad(includeOperators?: boolean, includeDecimal?: boolean): NumericKeypadTool;
320
-
321
- /**
322
- * Create a simple validation node
323
- */
324
- export declare function createSimpleValidation(): SimpleValidation;
325
-
326
- /**
327
- * Create a space inline element
328
- */
329
- export declare function createSpace(): SpaceInline;
330
-
331
- /**
332
- * Create a string inline input widget (W_S_I)
333
- */
334
- export declare function createStringInput(name: string, length: number, answer?: string | number): InlineInputWidget;
335
-
336
- /**
337
- * Create a text block (question)
338
- */
339
- export declare function createTextBlock(value: string): TextBlock;
340
-
341
- export declare type DragOptionsJSON = z.infer<typeof DragOptionsJSONSchema>;
342
-
343
- export declare const DragOptionsJSONSchema: z.ZodObject<{
344
- type: z.ZodLiteral<"drag-options">;
345
- options: z.ZodArray<z.ZodString, "many">;
346
- }, "strip", z.ZodTypeAny, {
347
- type: "drag-options";
348
- options: string[];
349
- }, {
350
- type: "drag-options";
351
- options: string[];
352
- }>;
353
-
354
- export declare type DragOptionsTool = z.infer<typeof DragOptionsToolSchema>;
355
-
356
- /**
357
- * Drag options tool schema - draggable buttons/options
358
- *
359
- * Common use cases:
360
- * - Comparison symbols: ["<", ">", "="]
361
- * - Yes/No: ["نعم", "لا"]
362
- * - Multiple choice: ["A", "B", "C", "D"]
363
- *
364
- * @example
365
- * {
366
- * type: "DragOptions",
367
- * options: ["<", ">", "="]
368
- * }
369
- */
370
- export declare const DragOptionsToolSchema: z.ZodObject<{
371
- type: z.ZodLiteral<"DragOptions">;
372
- options: z.ZodArray<z.ZodString, "many">;
373
- }, "strip", z.ZodTypeAny, {
374
- type: "DragOptions";
375
- options: string[];
376
- }, {
377
- type: "DragOptions";
378
- options: string[];
379
- }>;
380
-
381
- /**
382
- * Base error class for all engine errors
383
- */
384
- export declare class EngineError extends Error {
385
- constructor(message: string);
386
- }
387
-
388
- /**
389
- * Evaluate a mathematical expression with the given variable scope
390
- *
391
- * @param expression - The expression to evaluate (e.g., "(a * b) + (c * d) == 1200")
392
- * @param scope - Variable bindings (e.g., { a: 10, b: 5, c: 20, d: 30 })
393
- * @returns The boolean result of the expression
394
- * @throws Error if evaluation fails
395
- */
396
- export declare function evaluate(expression: string, scope: Record<string, number>): boolean;
397
-
398
- export declare type ExerciseDocument = z.infer<typeof ExerciseDocumentSchema>;
328
+ export declare type ContentBlock = z.infer<typeof ContentBlockSchema>;
399
329
 
400
- /**
401
- * Exercise document schema - the complete exercise structure
402
- *
403
- * Structure:
404
- * 1. Question: What the student should do
405
- * 2. Lines: Visual rows with inline elements
406
- * 3. Tools: Standalone interactive elements (optional)
407
- * 4. Validation: How to check answers
408
- *
409
- * @example
410
- * {
411
- * type: "ExerciseDocument",
412
- * question: {
413
- * type: "TextBlock",
414
- * value: "أقارن كل عددين باستعمال الرمر المناسب"
415
- * },
416
- * lines: [
417
- * {
418
- * type: "LineBlock",
419
- * inlines: [
420
- * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
421
- * { type: "InlineInput", name: "x", length: 1 },
422
- * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
423
- * ]
424
- * }
425
- * ],
426
- * tools: [
427
- * { type: "DragOptions", options: ["<", ">", "="] }
428
- * ],
429
- * validation: {
430
- * type: "SimpleValidation"
431
- * }
432
- * }
433
- */
434
- export declare const ExerciseDocumentSchema: z.ZodObject<{
435
- type: z.ZodLiteral<"ExerciseDocument">;
436
- question: z.ZodOptional<z.ZodObject<{
437
- type: z.ZodLiteral<"TextBlock">;
330
+ export declare const ContentBlockSchema: z.ZodUnion<[z.ZodObject<{
331
+ type: z.ZodLiteral<"LineBlock">;
332
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
333
+ type: z.ZodLiteral<"FreeText">;
438
334
  value: z.ZodString;
439
335
  }, "strip", z.ZodTypeAny, {
440
336
  value: string;
441
- type: "TextBlock";
337
+ type: "FreeText";
442
338
  }, {
443
339
  value: string;
444
- type: "TextBlock";
445
- }>>;
446
- lines: z.ZodArray<z.ZodObject<{
447
- type: z.ZodLiteral<"LineBlock">;
448
- inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
449
- type: z.ZodLiteral<"FreeText">;
450
- value: z.ZodString;
451
- }, "strip", z.ZodTypeAny, {
452
- value: string;
453
- type: "FreeText";
454
- }, {
455
- value: string;
456
- type: "FreeText";
457
- }>, z.ZodObject<{
458
- type: z.ZodLiteral<"Space">;
459
- }, "strip", z.ZodTypeAny, {
460
- type: "Space";
461
- }, {
462
- type: "Space";
463
- }>, z.ZodObject<{
464
- type: z.ZodLiteral<"HighlightedText">;
465
- value: z.ZodString;
466
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
467
- }, "strip", z.ZodTypeAny, {
468
- value: string;
469
- type: "HighlightedText";
470
- highlight?: [number, number] | undefined;
471
- }, {
472
- value: string;
473
- type: "HighlightedText";
474
- highlight?: [number, number] | undefined;
475
- }>, z.ZodObject<{
476
- type: z.ZodLiteral<"ColorText">;
477
- value: z.ZodString;
478
- color: z.ZodString;
479
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
480
- }, "strip", z.ZodTypeAny, {
481
- value: string;
482
- type: "ColorText";
483
- color: string;
484
- highlight?: [number, number] | undefined;
485
- }, {
486
- value: string;
487
- type: "ColorText";
488
- color: string;
489
- highlight?: [number, number] | undefined;
490
- }>, z.ZodObject<{
491
- type: z.ZodLiteral<"BoldText">;
492
- value: z.ZodString;
493
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
494
- }, "strip", z.ZodTypeAny, {
495
- value: string;
496
- type: "BoldText";
497
- highlight?: [number, number] | undefined;
498
- }, {
499
- value: string;
500
- type: "BoldText";
501
- highlight?: [number, number] | undefined;
502
- }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
503
- type: z.ZodLiteral<"InlineInput">;
504
- name: z.ZodString;
505
- inputType: z.ZodLiteral<"string">;
506
- length: z.ZodNumber;
507
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
508
- }, "strip", z.ZodTypeAny, {
509
- length: number;
510
- type: "InlineInput";
511
- inputType: "string";
512
- name: string;
513
- answer?: string | number | undefined;
514
- }, {
515
- length: number;
516
- type: "InlineInput";
517
- inputType: "string";
518
- name: string;
519
- answer?: string | number | undefined;
520
- }>, z.ZodObject<{
521
- type: z.ZodLiteral<"InlineInput">;
522
- name: z.ZodString;
523
- inputType: z.ZodLiteral<"numeric">;
524
- digits: z.ZodNumber;
525
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
526
- }, "strip", z.ZodTypeAny, {
527
- type: "InlineInput";
528
- inputType: "numeric";
529
- name: string;
530
- digits: number;
531
- answer?: string | number | undefined;
532
- }, {
533
- type: "InlineInput";
534
- inputType: "numeric";
535
- name: string;
536
- digits: number;
537
- answer?: string | number | undefined;
538
- }>]>]>, "many">;
340
+ type: "FreeText";
341
+ }>, z.ZodObject<{
342
+ type: z.ZodLiteral<"Space">;
539
343
  }, "strip", z.ZodTypeAny, {
540
- type: "LineBlock";
541
- inlines: ({
542
- value: string;
543
- type: "FreeText";
544
- } | {
545
- type: "Space";
546
- } | {
547
- value: string;
548
- type: "HighlightedText";
549
- highlight?: [number, number] | undefined;
550
- } | {
551
- value: string;
552
- type: "ColorText";
553
- color: string;
554
- highlight?: [number, number] | undefined;
555
- } | {
556
- value: string;
557
- type: "BoldText";
558
- highlight?: [number, number] | undefined;
559
- } | {
560
- length: number;
561
- type: "InlineInput";
562
- inputType: "string";
563
- name: string;
564
- answer?: string | number | undefined;
565
- } | {
566
- type: "InlineInput";
567
- inputType: "numeric";
568
- name: string;
569
- digits: number;
570
- answer?: string | number | undefined;
571
- })[];
344
+ type: "Space";
572
345
  }, {
573
- type: "LineBlock";
574
- inlines: ({
575
- value: string;
576
- type: "FreeText";
577
- } | {
578
- type: "Space";
579
- } | {
580
- value: string;
581
- type: "HighlightedText";
582
- highlight?: [number, number] | undefined;
583
- } | {
584
- value: string;
585
- type: "ColorText";
586
- color: string;
587
- highlight?: [number, number] | undefined;
588
- } | {
589
- value: string;
590
- type: "BoldText";
591
- highlight?: [number, number] | undefined;
592
- } | {
593
- length: number;
594
- type: "InlineInput";
595
- inputType: "string";
596
- name: string;
597
- answer?: string | number | undefined;
598
- } | {
599
- type: "InlineInput";
600
- inputType: "numeric";
601
- name: string;
602
- digits: number;
603
- answer?: string | number | undefined;
604
- })[];
605
- }>, "many">;
606
- tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
607
- type: z.ZodLiteral<"DragOptions">;
608
- options: z.ZodArray<z.ZodString, "many">;
346
+ type: "Space";
347
+ }>, z.ZodObject<{
348
+ type: z.ZodLiteral<"HighlightedText">;
349
+ value: z.ZodString;
350
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
609
351
  }, "strip", z.ZodTypeAny, {
610
- type: "DragOptions";
611
- options: string[];
352
+ value: string;
353
+ type: "HighlightedText";
354
+ highlight?: [number, number] | undefined;
612
355
  }, {
613
- type: "DragOptions";
614
- options: string[];
356
+ value: string;
357
+ type: "HighlightedText";
358
+ highlight?: [number, number] | undefined;
615
359
  }>, z.ZodObject<{
616
- type: z.ZodLiteral<"NumericKeypad">;
617
- includeOperators: z.ZodOptional<z.ZodBoolean>;
618
- includeDecimal: z.ZodOptional<z.ZodBoolean>;
360
+ type: z.ZodLiteral<"ColorText">;
361
+ value: z.ZodString;
362
+ color: z.ZodString;
363
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
619
364
  }, "strip", z.ZodTypeAny, {
620
- type: "NumericKeypad";
621
- includeOperators?: boolean | undefined;
622
- includeDecimal?: boolean | undefined;
365
+ value: string;
366
+ type: "ColorText";
367
+ color: string;
368
+ highlight?: [number, number] | undefined;
623
369
  }, {
624
- type: "NumericKeypad";
625
- includeOperators?: boolean | undefined;
626
- includeDecimal?: boolean | undefined;
627
- }>]>, "many">>;
628
- validation: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
629
- type: z.ZodLiteral<"SimpleValidation">;
370
+ value: string;
371
+ type: "ColorText";
372
+ color: string;
373
+ highlight?: [number, number] | undefined;
374
+ }>, z.ZodObject<{
375
+ type: z.ZodLiteral<"BoldText">;
376
+ value: z.ZodString;
377
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
630
378
  }, "strip", z.ZodTypeAny, {
631
- type: "SimpleValidation";
379
+ value: string;
380
+ type: "BoldText";
381
+ highlight?: [number, number] | undefined;
632
382
  }, {
633
- type: "SimpleValidation";
383
+ value: string;
384
+ type: "BoldText";
385
+ highlight?: [number, number] | undefined;
386
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
387
+ type: z.ZodLiteral<"InlineInput">;
388
+ name: z.ZodString;
389
+ inputType: z.ZodLiteral<"string">;
390
+ length: z.ZodNumber;
391
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
392
+ }, "strip", z.ZodTypeAny, {
393
+ length: number;
394
+ type: "InlineInput";
395
+ inputType: "string";
396
+ name: string;
397
+ answer?: string | number | undefined;
398
+ }, {
399
+ length: number;
400
+ type: "InlineInput";
401
+ inputType: "string";
402
+ name: string;
403
+ answer?: string | number | undefined;
634
404
  }>, z.ZodObject<{
635
- type: z.ZodLiteral<"ExpressionValidation">;
636
- expression: z.ZodString;
405
+ type: z.ZodLiteral<"InlineInput">;
406
+ name: z.ZodString;
407
+ inputType: z.ZodLiteral<"numeric">;
408
+ digits: z.ZodNumber;
409
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
637
410
  }, "strip", z.ZodTypeAny, {
638
- expression: string;
639
- type: "ExpressionValidation";
411
+ type: "InlineInput";
412
+ inputType: "numeric";
413
+ name: string;
414
+ digits: number;
415
+ answer?: string | number | undefined;
640
416
  }, {
641
- expression: string;
642
- type: "ExpressionValidation";
643
- }>]>;
417
+ type: "InlineInput";
418
+ inputType: "numeric";
419
+ name: string;
420
+ digits: number;
421
+ answer?: string | number | undefined;
422
+ }>]>]>, "many">;
644
423
  }, "strip", z.ZodTypeAny, {
645
- validation: {
646
- type: "SimpleValidation";
424
+ type: "LineBlock";
425
+ inlines: ({
426
+ value: string;
427
+ type: "FreeText";
428
+ } | {
429
+ type: "Space";
647
430
  } | {
648
- expression: string;
649
- type: "ExpressionValidation";
650
- };
651
- type: "ExerciseDocument";
652
- lines: {
653
- type: "LineBlock";
654
- inlines: ({
655
- value: string;
656
- type: "FreeText";
657
- } | {
658
- type: "Space";
659
- } | {
660
- value: string;
661
- type: "HighlightedText";
662
- highlight?: [number, number] | undefined;
663
- } | {
664
- value: string;
665
- type: "ColorText";
666
- color: string;
667
- highlight?: [number, number] | undefined;
668
- } | {
669
- value: string;
670
- type: "BoldText";
671
- highlight?: [number, number] | undefined;
672
- } | {
673
- length: number;
674
- type: "InlineInput";
675
- inputType: "string";
676
- name: string;
677
- answer?: string | number | undefined;
678
- } | {
679
- type: "InlineInput";
680
- inputType: "numeric";
681
- name: string;
682
- digits: number;
683
- answer?: string | number | undefined;
684
- })[];
685
- }[];
686
- question?: {
687
431
  value: string;
688
- type: "TextBlock";
689
- } | undefined;
690
- tools?: ({
691
- type: "DragOptions";
692
- options: string[];
432
+ type: "HighlightedText";
433
+ highlight?: [number, number] | undefined;
693
434
  } | {
694
- type: "NumericKeypad";
695
- includeOperators?: boolean | undefined;
696
- includeDecimal?: boolean | undefined;
697
- })[] | undefined;
698
- }, {
699
- validation: {
700
- type: "SimpleValidation";
435
+ value: string;
436
+ type: "ColorText";
437
+ color: string;
438
+ highlight?: [number, number] | undefined;
701
439
  } | {
702
- expression: string;
703
- type: "ExpressionValidation";
704
- };
705
- type: "ExerciseDocument";
706
- lines: {
707
- type: "LineBlock";
708
- inlines: ({
709
- value: string;
710
- type: "FreeText";
711
- } | {
712
- type: "Space";
713
- } | {
714
- value: string;
715
- type: "HighlightedText";
716
- highlight?: [number, number] | undefined;
717
- } | {
718
- value: string;
719
- type: "ColorText";
720
- color: string;
721
- highlight?: [number, number] | undefined;
722
- } | {
723
- value: string;
724
- type: "BoldText";
725
- highlight?: [number, number] | undefined;
726
- } | {
727
- length: number;
728
- type: "InlineInput";
729
- inputType: "string";
730
- name: string;
731
- answer?: string | number | undefined;
732
- } | {
733
- type: "InlineInput";
734
- inputType: "numeric";
735
- name: string;
736
- digits: number;
737
- answer?: string | number | undefined;
738
- })[];
739
- }[];
740
- question?: {
741
440
  value: string;
742
- type: "TextBlock";
743
- } | undefined;
744
- tools?: ({
745
- type: "DragOptions";
746
- options: string[];
441
+ type: "BoldText";
442
+ highlight?: [number, number] | undefined;
747
443
  } | {
748
- type: "NumericKeypad";
749
- includeOperators?: boolean | undefined;
750
- includeDecimal?: boolean | undefined;
751
- })[] | undefined;
752
- }>;
753
-
754
- export declare type ExerciseJSON = z.infer<typeof ExerciseJSONSchema>;
755
-
756
- export declare const ExerciseJSONSchema: z.ZodObject<{
757
- version: z.ZodLiteral<"2.0">;
758
- id: z.ZodOptional<z.ZodString>;
759
- layout: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
760
- widgets: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
761
- type: z.ZodLiteral<"inline-input">;
762
- inputType: z.ZodLiteral<"string">;
763
- length: z.ZodNumber;
764
- }, "strip", z.ZodTypeAny, {
765
- length: number;
766
- type: "inline-input";
767
- inputType: "string";
768
- }, {
769
- length: number;
770
- type: "inline-input";
771
- inputType: "string";
772
- }>, z.ZodObject<{
773
- type: z.ZodLiteral<"inline-input">;
774
- inputType: z.ZodLiteral<"numeric">;
775
- digits: z.ZodNumber;
776
- }, "strip", z.ZodTypeAny, {
777
- type: "inline-input";
778
- inputType: "numeric";
779
- digits: number;
780
- }, {
781
- type: "inline-input";
782
- inputType: "numeric";
783
- digits: number;
784
- }>]>, z.ZodObject<{
785
- type: z.ZodLiteral<"drag-options">;
786
- options: z.ZodArray<z.ZodString, "many">;
787
- }, "strip", z.ZodTypeAny, {
788
- type: "drag-options";
789
- options: string[];
790
- }, {
791
- type: "drag-options";
792
- options: string[];
793
- }>, z.ZodObject<{
794
- type: z.ZodLiteral<"numeric-keypad">;
795
- includeOperators: z.ZodOptional<z.ZodBoolean>;
796
- includeDecimal: z.ZodOptional<z.ZodBoolean>;
797
- }, "strip", z.ZodTypeAny, {
798
- type: "numeric-keypad";
799
- includeOperators?: boolean | undefined;
800
- includeDecimal?: boolean | undefined;
801
- }, {
802
- type: "numeric-keypad";
803
- includeOperators?: boolean | undefined;
804
- includeDecimal?: boolean | undefined;
805
- }>]>>;
806
- validation: z.ZodObject<{
807
- mode: z.ZodEnum<["simple", "expression"]>;
808
- answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
809
- expression: z.ZodOptional<z.ZodString>;
810
- variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
811
- }, "strip", z.ZodTypeAny, {
812
- mode: "simple" | "expression";
813
- expression?: string | undefined;
814
- answers?: Record<string, string | number> | undefined;
815
- variables?: string[] | undefined;
816
- }, {
817
- mode: "simple" | "expression";
818
- expression?: string | undefined;
819
- answers?: Record<string, string | number> | undefined;
820
- variables?: string[] | undefined;
821
- }>;
822
- meta: z.ZodOptional<z.ZodObject<{
823
- createdAt: z.ZodOptional<z.ZodString>;
824
- author: z.ZodOptional<z.ZodString>;
825
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
826
- difficulty: z.ZodOptional<z.ZodNumber>;
827
- }, "strip", z.ZodTypeAny, {
828
- createdAt?: string | undefined;
829
- author?: string | undefined;
830
- tags?: string[] | undefined;
831
- difficulty?: number | undefined;
832
- }, {
833
- createdAt?: string | undefined;
834
- author?: string | undefined;
835
- tags?: string[] | undefined;
836
- difficulty?: number | undefined;
837
- }>>;
838
- }, "strip", z.ZodTypeAny, {
839
- validation: {
840
- mode: "simple" | "expression";
841
- expression?: string | undefined;
842
- answers?: Record<string, string | number> | undefined;
843
- variables?: string[] | undefined;
844
- };
845
- version: "2.0";
846
- layout: any[];
847
- widgets: Record<string, {
848
444
  length: number;
849
- type: "inline-input";
445
+ type: "InlineInput";
850
446
  inputType: "string";
447
+ name: string;
448
+ answer?: string | number | undefined;
851
449
  } | {
852
- type: "inline-input";
450
+ type: "InlineInput";
853
451
  inputType: "numeric";
452
+ name: string;
854
453
  digits: number;
454
+ answer?: string | number | undefined;
455
+ })[];
456
+ }, {
457
+ type: "LineBlock";
458
+ inlines: ({
459
+ value: string;
460
+ type: "FreeText";
855
461
  } | {
856
- type: "drag-options";
857
- options: string[];
462
+ type: "Space";
463
+ } | {
464
+ value: string;
465
+ type: "HighlightedText";
466
+ highlight?: [number, number] | undefined;
467
+ } | {
468
+ value: string;
469
+ type: "ColorText";
470
+ color: string;
471
+ highlight?: [number, number] | undefined;
472
+ } | {
473
+ value: string;
474
+ type: "BoldText";
475
+ highlight?: [number, number] | undefined;
858
476
  } | {
859
- type: "numeric-keypad";
860
- includeOperators?: boolean | undefined;
861
- includeDecimal?: boolean | undefined;
862
- }>;
863
- id?: string | undefined;
864
- meta?: {
865
- createdAt?: string | undefined;
866
- author?: string | undefined;
867
- tags?: string[] | undefined;
868
- difficulty?: number | undefined;
869
- } | undefined;
870
- }, {
871
- validation: {
872
- mode: "simple" | "expression";
873
- expression?: string | undefined;
874
- answers?: Record<string, string | number> | undefined;
875
- variables?: string[] | undefined;
876
- };
877
- version: "2.0";
878
- layout: any[];
879
- widgets: Record<string, {
880
477
  length: number;
881
- type: "inline-input";
478
+ type: "InlineInput";
882
479
  inputType: "string";
480
+ name: string;
481
+ answer?: string | number | undefined;
883
482
  } | {
884
- type: "inline-input";
483
+ type: "InlineInput";
885
484
  inputType: "numeric";
485
+ name: string;
886
486
  digits: number;
887
- } | {
888
- type: "drag-options";
889
- options: string[];
890
- } | {
891
- type: "numeric-keypad";
892
- includeOperators?: boolean | undefined;
893
- includeDecimal?: boolean | undefined;
894
- }>;
895
- id?: string | undefined;
896
- meta?: {
897
- createdAt?: string | undefined;
898
- author?: string | undefined;
899
- tags?: string[] | undefined;
900
- difficulty?: number | undefined;
901
- } | undefined;
902
- }>;
903
-
904
- export declare type ExerciseMeta = z.infer<typeof ExerciseMetaSchema>;
905
-
906
- export declare const ExerciseMetaSchema: z.ZodObject<{
907
- createdAt: z.ZodOptional<z.ZodString>;
908
- author: z.ZodOptional<z.ZodString>;
909
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
910
- difficulty: z.ZodOptional<z.ZodNumber>;
911
- }, "strip", z.ZodTypeAny, {
912
- createdAt?: string | undefined;
913
- author?: string | undefined;
914
- tags?: string[] | undefined;
915
- difficulty?: number | undefined;
916
- }, {
917
- createdAt?: string | undefined;
918
- author?: string | undefined;
919
- tags?: string[] | undefined;
920
- difficulty?: number | undefined;
921
- }>;
922
-
923
- /**
924
- * Main renderer component - the contract for rendering exercises.
925
- *
926
- * This component is DUMB - it only collects values and passes them up.
927
- * The parent decides correctness via validation.
928
- */
929
- export declare const ExerciseRenderer: ForwardRefExoticComponent<ExerciseRendererProps & RefAttributes<ExerciseRendererRef>>;
930
-
931
- export declare interface ExerciseRendererProps {
932
- json: ExerciseJSON;
933
- onSubmit?: (values: Record<string, string>) => void;
934
- onChange?: (values: Record<string, string>) => void;
935
- showSubmitButton?: boolean;
936
- className?: string;
937
- }
938
-
939
- export declare interface ExerciseRendererRef {
940
- submit: () => ValidationResult;
941
- getValues: () => Record<string, string>;
942
- reset: () => void;
943
- focusFirstInput: () => void;
944
- }
945
-
946
- export declare type ExpressionValidation = z.infer<typeof ExpressionValidationSchema>;
947
-
948
- /**
949
- * Expression validation schema - validates using a boolean expression
950
- *
951
- * The expression can reference widget values by name.
952
- * Example: "a + b === 10"
487
+ answer?: string | number | undefined;
488
+ })[];
489
+ }>, z.ZodObject<{
490
+ type: z.ZodLiteral<"TableBlock">;
491
+ cols: z.ZodNumber;
492
+ rows: z.ZodArray<z.ZodObject<{
493
+ type: z.ZodLiteral<"TableRow">;
494
+ cells: z.ZodArray<z.ZodObject<{
495
+ type: z.ZodLiteral<"TableCell">;
496
+ colspan: z.ZodOptional<z.ZodNumber>;
497
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
498
+ type: z.ZodLiteral<"FreeText">;
499
+ value: z.ZodString;
500
+ }, "strip", z.ZodTypeAny, {
501
+ value: string;
502
+ type: "FreeText";
503
+ }, {
504
+ value: string;
505
+ type: "FreeText";
506
+ }>, z.ZodObject<{
507
+ type: z.ZodLiteral<"Space">;
508
+ }, "strip", z.ZodTypeAny, {
509
+ type: "Space";
510
+ }, {
511
+ type: "Space";
512
+ }>, z.ZodObject<{
513
+ type: z.ZodLiteral<"HighlightedText">;
514
+ value: z.ZodString;
515
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
516
+ }, "strip", z.ZodTypeAny, {
517
+ value: string;
518
+ type: "HighlightedText";
519
+ highlight?: [number, number] | undefined;
520
+ }, {
521
+ value: string;
522
+ type: "HighlightedText";
523
+ highlight?: [number, number] | undefined;
524
+ }>, z.ZodObject<{
525
+ type: z.ZodLiteral<"ColorText">;
526
+ value: z.ZodString;
527
+ color: z.ZodString;
528
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
529
+ }, "strip", z.ZodTypeAny, {
530
+ value: string;
531
+ type: "ColorText";
532
+ color: string;
533
+ highlight?: [number, number] | undefined;
534
+ }, {
535
+ value: string;
536
+ type: "ColorText";
537
+ color: string;
538
+ highlight?: [number, number] | undefined;
539
+ }>, z.ZodObject<{
540
+ type: z.ZodLiteral<"BoldText">;
541
+ value: z.ZodString;
542
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
543
+ }, "strip", z.ZodTypeAny, {
544
+ value: string;
545
+ type: "BoldText";
546
+ highlight?: [number, number] | undefined;
547
+ }, {
548
+ value: string;
549
+ type: "BoldText";
550
+ highlight?: [number, number] | undefined;
551
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
552
+ type: z.ZodLiteral<"InlineInput">;
553
+ name: z.ZodString;
554
+ inputType: z.ZodLiteral<"string">;
555
+ length: z.ZodNumber;
556
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
557
+ }, "strip", z.ZodTypeAny, {
558
+ length: number;
559
+ type: "InlineInput";
560
+ inputType: "string";
561
+ name: string;
562
+ answer?: string | number | undefined;
563
+ }, {
564
+ length: number;
565
+ type: "InlineInput";
566
+ inputType: "string";
567
+ name: string;
568
+ answer?: string | number | undefined;
569
+ }>, z.ZodObject<{
570
+ type: z.ZodLiteral<"InlineInput">;
571
+ name: z.ZodString;
572
+ inputType: z.ZodLiteral<"numeric">;
573
+ digits: z.ZodNumber;
574
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
575
+ }, "strip", z.ZodTypeAny, {
576
+ type: "InlineInput";
577
+ inputType: "numeric";
578
+ name: string;
579
+ digits: number;
580
+ answer?: string | number | undefined;
581
+ }, {
582
+ type: "InlineInput";
583
+ inputType: "numeric";
584
+ name: string;
585
+ digits: number;
586
+ answer?: string | number | undefined;
587
+ }>]>]>, "many">;
588
+ }, "strip", z.ZodTypeAny, {
589
+ type: "TableCell";
590
+ inlines: ({
591
+ value: string;
592
+ type: "FreeText";
593
+ } | {
594
+ type: "Space";
595
+ } | {
596
+ value: string;
597
+ type: "HighlightedText";
598
+ highlight?: [number, number] | undefined;
599
+ } | {
600
+ value: string;
601
+ type: "ColorText";
602
+ color: string;
603
+ highlight?: [number, number] | undefined;
604
+ } | {
605
+ value: string;
606
+ type: "BoldText";
607
+ highlight?: [number, number] | undefined;
608
+ } | {
609
+ length: number;
610
+ type: "InlineInput";
611
+ inputType: "string";
612
+ name: string;
613
+ answer?: string | number | undefined;
614
+ } | {
615
+ type: "InlineInput";
616
+ inputType: "numeric";
617
+ name: string;
618
+ digits: number;
619
+ answer?: string | number | undefined;
620
+ })[];
621
+ colspan?: number | undefined;
622
+ }, {
623
+ type: "TableCell";
624
+ inlines: ({
625
+ value: string;
626
+ type: "FreeText";
627
+ } | {
628
+ type: "Space";
629
+ } | {
630
+ value: string;
631
+ type: "HighlightedText";
632
+ highlight?: [number, number] | undefined;
633
+ } | {
634
+ value: string;
635
+ type: "ColorText";
636
+ color: string;
637
+ highlight?: [number, number] | undefined;
638
+ } | {
639
+ value: string;
640
+ type: "BoldText";
641
+ highlight?: [number, number] | undefined;
642
+ } | {
643
+ length: number;
644
+ type: "InlineInput";
645
+ inputType: "string";
646
+ name: string;
647
+ answer?: string | number | undefined;
648
+ } | {
649
+ type: "InlineInput";
650
+ inputType: "numeric";
651
+ name: string;
652
+ digits: number;
653
+ answer?: string | number | undefined;
654
+ })[];
655
+ colspan?: number | undefined;
656
+ }>, "many">;
657
+ }, "strip", z.ZodTypeAny, {
658
+ type: "TableRow";
659
+ cells: {
660
+ type: "TableCell";
661
+ inlines: ({
662
+ value: string;
663
+ type: "FreeText";
664
+ } | {
665
+ type: "Space";
666
+ } | {
667
+ value: string;
668
+ type: "HighlightedText";
669
+ highlight?: [number, number] | undefined;
670
+ } | {
671
+ value: string;
672
+ type: "ColorText";
673
+ color: string;
674
+ highlight?: [number, number] | undefined;
675
+ } | {
676
+ value: string;
677
+ type: "BoldText";
678
+ highlight?: [number, number] | undefined;
679
+ } | {
680
+ length: number;
681
+ type: "InlineInput";
682
+ inputType: "string";
683
+ name: string;
684
+ answer?: string | number | undefined;
685
+ } | {
686
+ type: "InlineInput";
687
+ inputType: "numeric";
688
+ name: string;
689
+ digits: number;
690
+ answer?: string | number | undefined;
691
+ })[];
692
+ colspan?: number | undefined;
693
+ }[];
694
+ }, {
695
+ type: "TableRow";
696
+ cells: {
697
+ type: "TableCell";
698
+ inlines: ({
699
+ value: string;
700
+ type: "FreeText";
701
+ } | {
702
+ type: "Space";
703
+ } | {
704
+ value: string;
705
+ type: "HighlightedText";
706
+ highlight?: [number, number] | undefined;
707
+ } | {
708
+ value: string;
709
+ type: "ColorText";
710
+ color: string;
711
+ highlight?: [number, number] | undefined;
712
+ } | {
713
+ value: string;
714
+ type: "BoldText";
715
+ highlight?: [number, number] | undefined;
716
+ } | {
717
+ length: number;
718
+ type: "InlineInput";
719
+ inputType: "string";
720
+ name: string;
721
+ answer?: string | number | undefined;
722
+ } | {
723
+ type: "InlineInput";
724
+ inputType: "numeric";
725
+ name: string;
726
+ digits: number;
727
+ answer?: string | number | undefined;
728
+ })[];
729
+ colspan?: number | undefined;
730
+ }[];
731
+ }>, "many">;
732
+ }, "strip", z.ZodTypeAny, {
733
+ type: "TableBlock";
734
+ cols: number;
735
+ rows: {
736
+ type: "TableRow";
737
+ cells: {
738
+ type: "TableCell";
739
+ inlines: ({
740
+ value: string;
741
+ type: "FreeText";
742
+ } | {
743
+ type: "Space";
744
+ } | {
745
+ value: string;
746
+ type: "HighlightedText";
747
+ highlight?: [number, number] | undefined;
748
+ } | {
749
+ value: string;
750
+ type: "ColorText";
751
+ color: string;
752
+ highlight?: [number, number] | undefined;
753
+ } | {
754
+ value: string;
755
+ type: "BoldText";
756
+ highlight?: [number, number] | undefined;
757
+ } | {
758
+ length: number;
759
+ type: "InlineInput";
760
+ inputType: "string";
761
+ name: string;
762
+ answer?: string | number | undefined;
763
+ } | {
764
+ type: "InlineInput";
765
+ inputType: "numeric";
766
+ name: string;
767
+ digits: number;
768
+ answer?: string | number | undefined;
769
+ })[];
770
+ colspan?: number | undefined;
771
+ }[];
772
+ }[];
773
+ }, {
774
+ type: "TableBlock";
775
+ cols: number;
776
+ rows: {
777
+ type: "TableRow";
778
+ cells: {
779
+ type: "TableCell";
780
+ inlines: ({
781
+ value: string;
782
+ type: "FreeText";
783
+ } | {
784
+ type: "Space";
785
+ } | {
786
+ value: string;
787
+ type: "HighlightedText";
788
+ highlight?: [number, number] | undefined;
789
+ } | {
790
+ value: string;
791
+ type: "ColorText";
792
+ color: string;
793
+ highlight?: [number, number] | undefined;
794
+ } | {
795
+ value: string;
796
+ type: "BoldText";
797
+ highlight?: [number, number] | undefined;
798
+ } | {
799
+ length: number;
800
+ type: "InlineInput";
801
+ inputType: "string";
802
+ name: string;
803
+ answer?: string | number | undefined;
804
+ } | {
805
+ type: "InlineInput";
806
+ inputType: "numeric";
807
+ name: string;
808
+ digits: number;
809
+ answer?: string | number | undefined;
810
+ })[];
811
+ colspan?: number | undefined;
812
+ }[];
813
+ }[];
814
+ }>, z.ZodObject<{
815
+ type: z.ZodLiteral<"RadioOptions">;
816
+ name: z.ZodString;
817
+ options: z.ZodArray<z.ZodString, "many">;
818
+ answer: z.ZodString;
819
+ }, "strip", z.ZodTypeAny, {
820
+ type: "RadioOptions";
821
+ options: string[];
822
+ name: string;
823
+ answer: string;
824
+ }, {
825
+ type: "RadioOptions";
826
+ options: string[];
827
+ name: string;
828
+ answer: string;
829
+ }>]>;
830
+
831
+ /**
832
+ * Create a bold text inline element
833
+ */
834
+ export declare function createBoldText(value: string, highlight?: [number, number]): BoldTextInline;
835
+
836
+ /**
837
+ * Create a color text inline element
838
+ */
839
+ export declare function createColorText(value: string, color: string, highlight?: [number, number]): ColorTextInline;
840
+
841
+ /**
842
+ * Create a drag options tool
843
+ */
844
+ export declare function createDragOptions(options: string[]): DragOptionsTool;
845
+
846
+ /**
847
+ * Create an exercise document
848
+ */
849
+ export declare function createExerciseDocument(question: z.infer<typeof TextBlockSchema> | undefined, lines: ContentBlock[], validation: z.infer<typeof ValidationNodeSchema>, tools?: z.infer<typeof ToolNodeSchema>[]): ExerciseDocument;
850
+
851
+ /**
852
+ * Create an expression validation node
853
+ */
854
+ export declare function createExpressionValidation(expression: string): ExpressionValidation;
855
+
856
+ /**
857
+ * Create a free text inline element
858
+ */
859
+ export declare function createFreeText(value: string): FreeTextInline;
860
+
861
+ /**
862
+ * Create a highlighted text inline element
863
+ */
864
+ export declare function createHighlightedText(value: string, highlight?: [number, number]): HighlightedTextInline;
865
+
866
+ /**
867
+ * Create a line block
868
+ */
869
+ export declare function createLineBlock(inlines: InlineNode[]): LineBlock;
870
+
871
+ /**
872
+ * Create a numeric inline input widget (W_N_I)
873
+ */
874
+ export declare function createNumericInput(name: string, digits: number, answer?: string | number): InlineInputWidget;
875
+
876
+ /**
877
+ * Create a numeric keypad tool
878
+ */
879
+ export declare function createNumericKeypad(includeOperators?: boolean, includeDecimal?: boolean): NumericKeypadTool;
880
+
881
+ /**
882
+ * Create a simple validation node
883
+ */
884
+ export declare function createSimpleValidation(): SimpleValidation;
885
+
886
+ /**
887
+ * Create a space inline element
888
+ */
889
+ export declare function createSpace(): SpaceInline;
890
+
891
+ /**
892
+ * Create a string inline input widget (W_S_I)
893
+ */
894
+ export declare function createStringInput(name: string, length: number, answer?: string | number): InlineInputWidget;
895
+
896
+ /**
897
+ * Create a text block (question)
898
+ */
899
+ export declare function createTextBlock(value: string): TextBlock;
900
+
901
+ export declare type DragOptionsJSON = z.infer<typeof DragOptionsJSONSchema>;
902
+
903
+ export declare const DragOptionsJSONSchema: z.ZodObject<{
904
+ type: z.ZodLiteral<"drag-options">;
905
+ options: z.ZodArray<z.ZodString, "many">;
906
+ }, "strip", z.ZodTypeAny, {
907
+ type: "drag-options";
908
+ options: string[];
909
+ }, {
910
+ type: "drag-options";
911
+ options: string[];
912
+ }>;
913
+
914
+ export declare type DragOptionsTool = z.infer<typeof DragOptionsToolSchema>;
915
+
916
+ /**
917
+ * Drag options tool schema - draggable buttons/options
918
+ *
919
+ * Common use cases:
920
+ * - Comparison symbols: ["<", ">", "="]
921
+ * - Yes/No: ["نعم", "لا"]
922
+ * - Multiple choice: ["A", "B", "C", "D"]
923
+ *
924
+ * @example
925
+ * {
926
+ * type: "DragOptions",
927
+ * options: ["<", ">", "="]
928
+ * }
929
+ */
930
+ export declare const DragOptionsToolSchema: z.ZodObject<{
931
+ type: z.ZodLiteral<"DragOptions">;
932
+ options: z.ZodArray<z.ZodString, "many">;
933
+ }, "strip", z.ZodTypeAny, {
934
+ type: "DragOptions";
935
+ options: string[];
936
+ }, {
937
+ type: "DragOptions";
938
+ options: string[];
939
+ }>;
940
+
941
+ /**
942
+ * Base error class for all engine errors
943
+ */
944
+ export declare class EngineError extends Error {
945
+ constructor(message: string);
946
+ }
947
+
948
+ /**
949
+ * Evaluate a mathematical expression with the given variable scope
950
+ *
951
+ * @param expression - The expression to evaluate (e.g., "(a * b) + (c * d) == 1200")
952
+ * @param scope - Variable bindings (e.g., { a: 10, b: 5, c: 20, d: 30 })
953
+ * @returns The boolean result of the expression
954
+ * @throws Error if evaluation fails
955
+ */
956
+ export declare function evaluate(expression: string, scope: Record<string, number>): boolean;
957
+
958
+ export declare type ExerciseDocument = z.infer<typeof ExerciseDocumentSchema>;
959
+
960
+ /**
961
+ * Exercise document schema - the complete exercise structure
962
+ *
963
+ * Structure:
964
+ * 1. Question: What the student should do
965
+ * 2. Lines: Visual rows with inline elements
966
+ * 3. Tools: Standalone interactive elements (optional)
967
+ * 4. Validation: How to check answers
968
+ *
969
+ * @example
970
+ * {
971
+ * type: "ExerciseDocument",
972
+ * question: {
973
+ * type: "TextBlock",
974
+ * value: "أقارن كل عددين باستعمال الرمر المناسب"
975
+ * },
976
+ * lines: [
977
+ * {
978
+ * type: "LineBlock",
979
+ * inlines: [
980
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
981
+ * { type: "InlineInput", name: "x", length: 1 },
982
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
983
+ * ]
984
+ * }
985
+ * ],
986
+ * tools: [
987
+ * { type: "DragOptions", options: ["<", ">", "="] }
988
+ * ],
989
+ * validation: {
990
+ * type: "SimpleValidation"
991
+ * }
992
+ * }
993
+ */
994
+ export declare const ExerciseDocumentSchema: z.ZodObject<{
995
+ type: z.ZodLiteral<"ExerciseDocument">;
996
+ question: z.ZodOptional<z.ZodObject<{
997
+ type: z.ZodLiteral<"TextBlock">;
998
+ value: z.ZodString;
999
+ }, "strip", z.ZodTypeAny, {
1000
+ value: string;
1001
+ type: "TextBlock";
1002
+ }, {
1003
+ value: string;
1004
+ type: "TextBlock";
1005
+ }>>;
1006
+ lines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1007
+ type: z.ZodLiteral<"LineBlock">;
1008
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1009
+ type: z.ZodLiteral<"FreeText">;
1010
+ value: z.ZodString;
1011
+ }, "strip", z.ZodTypeAny, {
1012
+ value: string;
1013
+ type: "FreeText";
1014
+ }, {
1015
+ value: string;
1016
+ type: "FreeText";
1017
+ }>, z.ZodObject<{
1018
+ type: z.ZodLiteral<"Space">;
1019
+ }, "strip", z.ZodTypeAny, {
1020
+ type: "Space";
1021
+ }, {
1022
+ type: "Space";
1023
+ }>, z.ZodObject<{
1024
+ type: z.ZodLiteral<"HighlightedText">;
1025
+ value: z.ZodString;
1026
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1027
+ }, "strip", z.ZodTypeAny, {
1028
+ value: string;
1029
+ type: "HighlightedText";
1030
+ highlight?: [number, number] | undefined;
1031
+ }, {
1032
+ value: string;
1033
+ type: "HighlightedText";
1034
+ highlight?: [number, number] | undefined;
1035
+ }>, z.ZodObject<{
1036
+ type: z.ZodLiteral<"ColorText">;
1037
+ value: z.ZodString;
1038
+ color: z.ZodString;
1039
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1040
+ }, "strip", z.ZodTypeAny, {
1041
+ value: string;
1042
+ type: "ColorText";
1043
+ color: string;
1044
+ highlight?: [number, number] | undefined;
1045
+ }, {
1046
+ value: string;
1047
+ type: "ColorText";
1048
+ color: string;
1049
+ highlight?: [number, number] | undefined;
1050
+ }>, z.ZodObject<{
1051
+ type: z.ZodLiteral<"BoldText">;
1052
+ value: z.ZodString;
1053
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1054
+ }, "strip", z.ZodTypeAny, {
1055
+ value: string;
1056
+ type: "BoldText";
1057
+ highlight?: [number, number] | undefined;
1058
+ }, {
1059
+ value: string;
1060
+ type: "BoldText";
1061
+ highlight?: [number, number] | undefined;
1062
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1063
+ type: z.ZodLiteral<"InlineInput">;
1064
+ name: z.ZodString;
1065
+ inputType: z.ZodLiteral<"string">;
1066
+ length: z.ZodNumber;
1067
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1068
+ }, "strip", z.ZodTypeAny, {
1069
+ length: number;
1070
+ type: "InlineInput";
1071
+ inputType: "string";
1072
+ name: string;
1073
+ answer?: string | number | undefined;
1074
+ }, {
1075
+ length: number;
1076
+ type: "InlineInput";
1077
+ inputType: "string";
1078
+ name: string;
1079
+ answer?: string | number | undefined;
1080
+ }>, z.ZodObject<{
1081
+ type: z.ZodLiteral<"InlineInput">;
1082
+ name: z.ZodString;
1083
+ inputType: z.ZodLiteral<"numeric">;
1084
+ digits: z.ZodNumber;
1085
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1086
+ }, "strip", z.ZodTypeAny, {
1087
+ type: "InlineInput";
1088
+ inputType: "numeric";
1089
+ name: string;
1090
+ digits: number;
1091
+ answer?: string | number | undefined;
1092
+ }, {
1093
+ type: "InlineInput";
1094
+ inputType: "numeric";
1095
+ name: string;
1096
+ digits: number;
1097
+ answer?: string | number | undefined;
1098
+ }>]>]>, "many">;
1099
+ }, "strip", z.ZodTypeAny, {
1100
+ type: "LineBlock";
1101
+ inlines: ({
1102
+ value: string;
1103
+ type: "FreeText";
1104
+ } | {
1105
+ type: "Space";
1106
+ } | {
1107
+ value: string;
1108
+ type: "HighlightedText";
1109
+ highlight?: [number, number] | undefined;
1110
+ } | {
1111
+ value: string;
1112
+ type: "ColorText";
1113
+ color: string;
1114
+ highlight?: [number, number] | undefined;
1115
+ } | {
1116
+ value: string;
1117
+ type: "BoldText";
1118
+ highlight?: [number, number] | undefined;
1119
+ } | {
1120
+ length: number;
1121
+ type: "InlineInput";
1122
+ inputType: "string";
1123
+ name: string;
1124
+ answer?: string | number | undefined;
1125
+ } | {
1126
+ type: "InlineInput";
1127
+ inputType: "numeric";
1128
+ name: string;
1129
+ digits: number;
1130
+ answer?: string | number | undefined;
1131
+ })[];
1132
+ }, {
1133
+ type: "LineBlock";
1134
+ inlines: ({
1135
+ value: string;
1136
+ type: "FreeText";
1137
+ } | {
1138
+ type: "Space";
1139
+ } | {
1140
+ value: string;
1141
+ type: "HighlightedText";
1142
+ highlight?: [number, number] | undefined;
1143
+ } | {
1144
+ value: string;
1145
+ type: "ColorText";
1146
+ color: string;
1147
+ highlight?: [number, number] | undefined;
1148
+ } | {
1149
+ value: string;
1150
+ type: "BoldText";
1151
+ highlight?: [number, number] | undefined;
1152
+ } | {
1153
+ length: number;
1154
+ type: "InlineInput";
1155
+ inputType: "string";
1156
+ name: string;
1157
+ answer?: string | number | undefined;
1158
+ } | {
1159
+ type: "InlineInput";
1160
+ inputType: "numeric";
1161
+ name: string;
1162
+ digits: number;
1163
+ answer?: string | number | undefined;
1164
+ })[];
1165
+ }>, z.ZodObject<{
1166
+ type: z.ZodLiteral<"TableBlock">;
1167
+ cols: z.ZodNumber;
1168
+ rows: z.ZodArray<z.ZodObject<{
1169
+ type: z.ZodLiteral<"TableRow">;
1170
+ cells: z.ZodArray<z.ZodObject<{
1171
+ type: z.ZodLiteral<"TableCell">;
1172
+ colspan: z.ZodOptional<z.ZodNumber>;
1173
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1174
+ type: z.ZodLiteral<"FreeText">;
1175
+ value: z.ZodString;
1176
+ }, "strip", z.ZodTypeAny, {
1177
+ value: string;
1178
+ type: "FreeText";
1179
+ }, {
1180
+ value: string;
1181
+ type: "FreeText";
1182
+ }>, z.ZodObject<{
1183
+ type: z.ZodLiteral<"Space">;
1184
+ }, "strip", z.ZodTypeAny, {
1185
+ type: "Space";
1186
+ }, {
1187
+ type: "Space";
1188
+ }>, z.ZodObject<{
1189
+ type: z.ZodLiteral<"HighlightedText">;
1190
+ value: z.ZodString;
1191
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1192
+ }, "strip", z.ZodTypeAny, {
1193
+ value: string;
1194
+ type: "HighlightedText";
1195
+ highlight?: [number, number] | undefined;
1196
+ }, {
1197
+ value: string;
1198
+ type: "HighlightedText";
1199
+ highlight?: [number, number] | undefined;
1200
+ }>, z.ZodObject<{
1201
+ type: z.ZodLiteral<"ColorText">;
1202
+ value: z.ZodString;
1203
+ color: z.ZodString;
1204
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1205
+ }, "strip", z.ZodTypeAny, {
1206
+ value: string;
1207
+ type: "ColorText";
1208
+ color: string;
1209
+ highlight?: [number, number] | undefined;
1210
+ }, {
1211
+ value: string;
1212
+ type: "ColorText";
1213
+ color: string;
1214
+ highlight?: [number, number] | undefined;
1215
+ }>, z.ZodObject<{
1216
+ type: z.ZodLiteral<"BoldText">;
1217
+ value: z.ZodString;
1218
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1219
+ }, "strip", z.ZodTypeAny, {
1220
+ value: string;
1221
+ type: "BoldText";
1222
+ highlight?: [number, number] | undefined;
1223
+ }, {
1224
+ value: string;
1225
+ type: "BoldText";
1226
+ highlight?: [number, number] | undefined;
1227
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1228
+ type: z.ZodLiteral<"InlineInput">;
1229
+ name: z.ZodString;
1230
+ inputType: z.ZodLiteral<"string">;
1231
+ length: z.ZodNumber;
1232
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1233
+ }, "strip", z.ZodTypeAny, {
1234
+ length: number;
1235
+ type: "InlineInput";
1236
+ inputType: "string";
1237
+ name: string;
1238
+ answer?: string | number | undefined;
1239
+ }, {
1240
+ length: number;
1241
+ type: "InlineInput";
1242
+ inputType: "string";
1243
+ name: string;
1244
+ answer?: string | number | undefined;
1245
+ }>, z.ZodObject<{
1246
+ type: z.ZodLiteral<"InlineInput">;
1247
+ name: z.ZodString;
1248
+ inputType: z.ZodLiteral<"numeric">;
1249
+ digits: z.ZodNumber;
1250
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1251
+ }, "strip", z.ZodTypeAny, {
1252
+ type: "InlineInput";
1253
+ inputType: "numeric";
1254
+ name: string;
1255
+ digits: number;
1256
+ answer?: string | number | undefined;
1257
+ }, {
1258
+ type: "InlineInput";
1259
+ inputType: "numeric";
1260
+ name: string;
1261
+ digits: number;
1262
+ answer?: string | number | undefined;
1263
+ }>]>]>, "many">;
1264
+ }, "strip", z.ZodTypeAny, {
1265
+ type: "TableCell";
1266
+ inlines: ({
1267
+ value: string;
1268
+ type: "FreeText";
1269
+ } | {
1270
+ type: "Space";
1271
+ } | {
1272
+ value: string;
1273
+ type: "HighlightedText";
1274
+ highlight?: [number, number] | undefined;
1275
+ } | {
1276
+ value: string;
1277
+ type: "ColorText";
1278
+ color: string;
1279
+ highlight?: [number, number] | undefined;
1280
+ } | {
1281
+ value: string;
1282
+ type: "BoldText";
1283
+ highlight?: [number, number] | undefined;
1284
+ } | {
1285
+ length: number;
1286
+ type: "InlineInput";
1287
+ inputType: "string";
1288
+ name: string;
1289
+ answer?: string | number | undefined;
1290
+ } | {
1291
+ type: "InlineInput";
1292
+ inputType: "numeric";
1293
+ name: string;
1294
+ digits: number;
1295
+ answer?: string | number | undefined;
1296
+ })[];
1297
+ colspan?: number | undefined;
1298
+ }, {
1299
+ type: "TableCell";
1300
+ inlines: ({
1301
+ value: string;
1302
+ type: "FreeText";
1303
+ } | {
1304
+ type: "Space";
1305
+ } | {
1306
+ value: string;
1307
+ type: "HighlightedText";
1308
+ highlight?: [number, number] | undefined;
1309
+ } | {
1310
+ value: string;
1311
+ type: "ColorText";
1312
+ color: string;
1313
+ highlight?: [number, number] | undefined;
1314
+ } | {
1315
+ value: string;
1316
+ type: "BoldText";
1317
+ highlight?: [number, number] | undefined;
1318
+ } | {
1319
+ length: number;
1320
+ type: "InlineInput";
1321
+ inputType: "string";
1322
+ name: string;
1323
+ answer?: string | number | undefined;
1324
+ } | {
1325
+ type: "InlineInput";
1326
+ inputType: "numeric";
1327
+ name: string;
1328
+ digits: number;
1329
+ answer?: string | number | undefined;
1330
+ })[];
1331
+ colspan?: number | undefined;
1332
+ }>, "many">;
1333
+ }, "strip", z.ZodTypeAny, {
1334
+ type: "TableRow";
1335
+ cells: {
1336
+ type: "TableCell";
1337
+ inlines: ({
1338
+ value: string;
1339
+ type: "FreeText";
1340
+ } | {
1341
+ type: "Space";
1342
+ } | {
1343
+ value: string;
1344
+ type: "HighlightedText";
1345
+ highlight?: [number, number] | undefined;
1346
+ } | {
1347
+ value: string;
1348
+ type: "ColorText";
1349
+ color: string;
1350
+ highlight?: [number, number] | undefined;
1351
+ } | {
1352
+ value: string;
1353
+ type: "BoldText";
1354
+ highlight?: [number, number] | undefined;
1355
+ } | {
1356
+ length: number;
1357
+ type: "InlineInput";
1358
+ inputType: "string";
1359
+ name: string;
1360
+ answer?: string | number | undefined;
1361
+ } | {
1362
+ type: "InlineInput";
1363
+ inputType: "numeric";
1364
+ name: string;
1365
+ digits: number;
1366
+ answer?: string | number | undefined;
1367
+ })[];
1368
+ colspan?: number | undefined;
1369
+ }[];
1370
+ }, {
1371
+ type: "TableRow";
1372
+ cells: {
1373
+ type: "TableCell";
1374
+ inlines: ({
1375
+ value: string;
1376
+ type: "FreeText";
1377
+ } | {
1378
+ type: "Space";
1379
+ } | {
1380
+ value: string;
1381
+ type: "HighlightedText";
1382
+ highlight?: [number, number] | undefined;
1383
+ } | {
1384
+ value: string;
1385
+ type: "ColorText";
1386
+ color: string;
1387
+ highlight?: [number, number] | undefined;
1388
+ } | {
1389
+ value: string;
1390
+ type: "BoldText";
1391
+ highlight?: [number, number] | undefined;
1392
+ } | {
1393
+ length: number;
1394
+ type: "InlineInput";
1395
+ inputType: "string";
1396
+ name: string;
1397
+ answer?: string | number | undefined;
1398
+ } | {
1399
+ type: "InlineInput";
1400
+ inputType: "numeric";
1401
+ name: string;
1402
+ digits: number;
1403
+ answer?: string | number | undefined;
1404
+ })[];
1405
+ colspan?: number | undefined;
1406
+ }[];
1407
+ }>, "many">;
1408
+ }, "strip", z.ZodTypeAny, {
1409
+ type: "TableBlock";
1410
+ cols: number;
1411
+ rows: {
1412
+ type: "TableRow";
1413
+ cells: {
1414
+ type: "TableCell";
1415
+ inlines: ({
1416
+ value: string;
1417
+ type: "FreeText";
1418
+ } | {
1419
+ type: "Space";
1420
+ } | {
1421
+ value: string;
1422
+ type: "HighlightedText";
1423
+ highlight?: [number, number] | undefined;
1424
+ } | {
1425
+ value: string;
1426
+ type: "ColorText";
1427
+ color: string;
1428
+ highlight?: [number, number] | undefined;
1429
+ } | {
1430
+ value: string;
1431
+ type: "BoldText";
1432
+ highlight?: [number, number] | undefined;
1433
+ } | {
1434
+ length: number;
1435
+ type: "InlineInput";
1436
+ inputType: "string";
1437
+ name: string;
1438
+ answer?: string | number | undefined;
1439
+ } | {
1440
+ type: "InlineInput";
1441
+ inputType: "numeric";
1442
+ name: string;
1443
+ digits: number;
1444
+ answer?: string | number | undefined;
1445
+ })[];
1446
+ colspan?: number | undefined;
1447
+ }[];
1448
+ }[];
1449
+ }, {
1450
+ type: "TableBlock";
1451
+ cols: number;
1452
+ rows: {
1453
+ type: "TableRow";
1454
+ cells: {
1455
+ type: "TableCell";
1456
+ inlines: ({
1457
+ value: string;
1458
+ type: "FreeText";
1459
+ } | {
1460
+ type: "Space";
1461
+ } | {
1462
+ value: string;
1463
+ type: "HighlightedText";
1464
+ highlight?: [number, number] | undefined;
1465
+ } | {
1466
+ value: string;
1467
+ type: "ColorText";
1468
+ color: string;
1469
+ highlight?: [number, number] | undefined;
1470
+ } | {
1471
+ value: string;
1472
+ type: "BoldText";
1473
+ highlight?: [number, number] | undefined;
1474
+ } | {
1475
+ length: number;
1476
+ type: "InlineInput";
1477
+ inputType: "string";
1478
+ name: string;
1479
+ answer?: string | number | undefined;
1480
+ } | {
1481
+ type: "InlineInput";
1482
+ inputType: "numeric";
1483
+ name: string;
1484
+ digits: number;
1485
+ answer?: string | number | undefined;
1486
+ })[];
1487
+ colspan?: number | undefined;
1488
+ }[];
1489
+ }[];
1490
+ }>, z.ZodObject<{
1491
+ type: z.ZodLiteral<"RadioOptions">;
1492
+ name: z.ZodString;
1493
+ options: z.ZodArray<z.ZodString, "many">;
1494
+ answer: z.ZodString;
1495
+ }, "strip", z.ZodTypeAny, {
1496
+ type: "RadioOptions";
1497
+ options: string[];
1498
+ name: string;
1499
+ answer: string;
1500
+ }, {
1501
+ type: "RadioOptions";
1502
+ options: string[];
1503
+ name: string;
1504
+ answer: string;
1505
+ }>]>, "many">;
1506
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1507
+ type: z.ZodLiteral<"DragOptions">;
1508
+ options: z.ZodArray<z.ZodString, "many">;
1509
+ }, "strip", z.ZodTypeAny, {
1510
+ type: "DragOptions";
1511
+ options: string[];
1512
+ }, {
1513
+ type: "DragOptions";
1514
+ options: string[];
1515
+ }>, z.ZodObject<{
1516
+ type: z.ZodLiteral<"NumericKeypad">;
1517
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1518
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1519
+ }, "strip", z.ZodTypeAny, {
1520
+ type: "NumericKeypad";
1521
+ includeOperators?: boolean | undefined;
1522
+ includeDecimal?: boolean | undefined;
1523
+ }, {
1524
+ type: "NumericKeypad";
1525
+ includeOperators?: boolean | undefined;
1526
+ includeDecimal?: boolean | undefined;
1527
+ }>]>, "many">>;
1528
+ validation: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1529
+ type: z.ZodLiteral<"SimpleValidation">;
1530
+ }, "strip", z.ZodTypeAny, {
1531
+ type: "SimpleValidation";
1532
+ }, {
1533
+ type: "SimpleValidation";
1534
+ }>, z.ZodObject<{
1535
+ type: z.ZodLiteral<"ExpressionValidation">;
1536
+ expression: z.ZodString;
1537
+ }, "strip", z.ZodTypeAny, {
1538
+ expression: string;
1539
+ type: "ExpressionValidation";
1540
+ }, {
1541
+ expression: string;
1542
+ type: "ExpressionValidation";
1543
+ }>]>;
1544
+ }, "strip", z.ZodTypeAny, {
1545
+ validation: {
1546
+ type: "SimpleValidation";
1547
+ } | {
1548
+ expression: string;
1549
+ type: "ExpressionValidation";
1550
+ };
1551
+ type: "ExerciseDocument";
1552
+ lines: ({
1553
+ type: "LineBlock";
1554
+ inlines: ({
1555
+ value: string;
1556
+ type: "FreeText";
1557
+ } | {
1558
+ type: "Space";
1559
+ } | {
1560
+ value: string;
1561
+ type: "HighlightedText";
1562
+ highlight?: [number, number] | undefined;
1563
+ } | {
1564
+ value: string;
1565
+ type: "ColorText";
1566
+ color: string;
1567
+ highlight?: [number, number] | undefined;
1568
+ } | {
1569
+ value: string;
1570
+ type: "BoldText";
1571
+ highlight?: [number, number] | undefined;
1572
+ } | {
1573
+ length: number;
1574
+ type: "InlineInput";
1575
+ inputType: "string";
1576
+ name: string;
1577
+ answer?: string | number | undefined;
1578
+ } | {
1579
+ type: "InlineInput";
1580
+ inputType: "numeric";
1581
+ name: string;
1582
+ digits: number;
1583
+ answer?: string | number | undefined;
1584
+ })[];
1585
+ } | {
1586
+ type: "TableBlock";
1587
+ cols: number;
1588
+ rows: {
1589
+ type: "TableRow";
1590
+ cells: {
1591
+ type: "TableCell";
1592
+ inlines: ({
1593
+ value: string;
1594
+ type: "FreeText";
1595
+ } | {
1596
+ type: "Space";
1597
+ } | {
1598
+ value: string;
1599
+ type: "HighlightedText";
1600
+ highlight?: [number, number] | undefined;
1601
+ } | {
1602
+ value: string;
1603
+ type: "ColorText";
1604
+ color: string;
1605
+ highlight?: [number, number] | undefined;
1606
+ } | {
1607
+ value: string;
1608
+ type: "BoldText";
1609
+ highlight?: [number, number] | undefined;
1610
+ } | {
1611
+ length: number;
1612
+ type: "InlineInput";
1613
+ inputType: "string";
1614
+ name: string;
1615
+ answer?: string | number | undefined;
1616
+ } | {
1617
+ type: "InlineInput";
1618
+ inputType: "numeric";
1619
+ name: string;
1620
+ digits: number;
1621
+ answer?: string | number | undefined;
1622
+ })[];
1623
+ colspan?: number | undefined;
1624
+ }[];
1625
+ }[];
1626
+ } | {
1627
+ type: "RadioOptions";
1628
+ options: string[];
1629
+ name: string;
1630
+ answer: string;
1631
+ })[];
1632
+ question?: {
1633
+ value: string;
1634
+ type: "TextBlock";
1635
+ } | undefined;
1636
+ tools?: ({
1637
+ type: "DragOptions";
1638
+ options: string[];
1639
+ } | {
1640
+ type: "NumericKeypad";
1641
+ includeOperators?: boolean | undefined;
1642
+ includeDecimal?: boolean | undefined;
1643
+ })[] | undefined;
1644
+ }, {
1645
+ validation: {
1646
+ type: "SimpleValidation";
1647
+ } | {
1648
+ expression: string;
1649
+ type: "ExpressionValidation";
1650
+ };
1651
+ type: "ExerciseDocument";
1652
+ lines: ({
1653
+ type: "LineBlock";
1654
+ inlines: ({
1655
+ value: string;
1656
+ type: "FreeText";
1657
+ } | {
1658
+ type: "Space";
1659
+ } | {
1660
+ value: string;
1661
+ type: "HighlightedText";
1662
+ highlight?: [number, number] | undefined;
1663
+ } | {
1664
+ value: string;
1665
+ type: "ColorText";
1666
+ color: string;
1667
+ highlight?: [number, number] | undefined;
1668
+ } | {
1669
+ value: string;
1670
+ type: "BoldText";
1671
+ highlight?: [number, number] | undefined;
1672
+ } | {
1673
+ length: number;
1674
+ type: "InlineInput";
1675
+ inputType: "string";
1676
+ name: string;
1677
+ answer?: string | number | undefined;
1678
+ } | {
1679
+ type: "InlineInput";
1680
+ inputType: "numeric";
1681
+ name: string;
1682
+ digits: number;
1683
+ answer?: string | number | undefined;
1684
+ })[];
1685
+ } | {
1686
+ type: "TableBlock";
1687
+ cols: number;
1688
+ rows: {
1689
+ type: "TableRow";
1690
+ cells: {
1691
+ type: "TableCell";
1692
+ inlines: ({
1693
+ value: string;
1694
+ type: "FreeText";
1695
+ } | {
1696
+ type: "Space";
1697
+ } | {
1698
+ value: string;
1699
+ type: "HighlightedText";
1700
+ highlight?: [number, number] | undefined;
1701
+ } | {
1702
+ value: string;
1703
+ type: "ColorText";
1704
+ color: string;
1705
+ highlight?: [number, number] | undefined;
1706
+ } | {
1707
+ value: string;
1708
+ type: "BoldText";
1709
+ highlight?: [number, number] | undefined;
1710
+ } | {
1711
+ length: number;
1712
+ type: "InlineInput";
1713
+ inputType: "string";
1714
+ name: string;
1715
+ answer?: string | number | undefined;
1716
+ } | {
1717
+ type: "InlineInput";
1718
+ inputType: "numeric";
1719
+ name: string;
1720
+ digits: number;
1721
+ answer?: string | number | undefined;
1722
+ })[];
1723
+ colspan?: number | undefined;
1724
+ }[];
1725
+ }[];
1726
+ } | {
1727
+ type: "RadioOptions";
1728
+ options: string[];
1729
+ name: string;
1730
+ answer: string;
1731
+ })[];
1732
+ question?: {
1733
+ value: string;
1734
+ type: "TextBlock";
1735
+ } | undefined;
1736
+ tools?: ({
1737
+ type: "DragOptions";
1738
+ options: string[];
1739
+ } | {
1740
+ type: "NumericKeypad";
1741
+ includeOperators?: boolean | undefined;
1742
+ includeDecimal?: boolean | undefined;
1743
+ })[] | undefined;
1744
+ }>;
1745
+
1746
+ export declare type ExerciseJSON = z.infer<typeof ExerciseJSONSchema>;
1747
+
1748
+ export declare const ExerciseJSONSchema: z.ZodObject<{
1749
+ version: z.ZodLiteral<"2.0">;
1750
+ id: z.ZodOptional<z.ZodString>;
1751
+ layout: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
1752
+ widgets: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1753
+ type: z.ZodLiteral<"inline-input">;
1754
+ inputType: z.ZodLiteral<"string">;
1755
+ length: z.ZodNumber;
1756
+ }, "strip", z.ZodTypeAny, {
1757
+ length: number;
1758
+ type: "inline-input";
1759
+ inputType: "string";
1760
+ }, {
1761
+ length: number;
1762
+ type: "inline-input";
1763
+ inputType: "string";
1764
+ }>, z.ZodObject<{
1765
+ type: z.ZodLiteral<"inline-input">;
1766
+ inputType: z.ZodLiteral<"numeric">;
1767
+ digits: z.ZodNumber;
1768
+ }, "strip", z.ZodTypeAny, {
1769
+ type: "inline-input";
1770
+ inputType: "numeric";
1771
+ digits: number;
1772
+ }, {
1773
+ type: "inline-input";
1774
+ inputType: "numeric";
1775
+ digits: number;
1776
+ }>]>, z.ZodObject<{
1777
+ type: z.ZodLiteral<"drag-options">;
1778
+ options: z.ZodArray<z.ZodString, "many">;
1779
+ }, "strip", z.ZodTypeAny, {
1780
+ type: "drag-options";
1781
+ options: string[];
1782
+ }, {
1783
+ type: "drag-options";
1784
+ options: string[];
1785
+ }>, z.ZodObject<{
1786
+ type: z.ZodLiteral<"radio-options">;
1787
+ options: z.ZodArray<z.ZodString, "many">;
1788
+ }, "strip", z.ZodTypeAny, {
1789
+ type: "radio-options";
1790
+ options: string[];
1791
+ }, {
1792
+ type: "radio-options";
1793
+ options: string[];
1794
+ }>, z.ZodObject<{
1795
+ type: z.ZodLiteral<"numeric-keypad">;
1796
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1797
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1798
+ }, "strip", z.ZodTypeAny, {
1799
+ type: "numeric-keypad";
1800
+ includeOperators?: boolean | undefined;
1801
+ includeDecimal?: boolean | undefined;
1802
+ }, {
1803
+ type: "numeric-keypad";
1804
+ includeOperators?: boolean | undefined;
1805
+ includeDecimal?: boolean | undefined;
1806
+ }>]>>;
1807
+ validation: z.ZodObject<{
1808
+ mode: z.ZodEnum<["simple", "expression"]>;
1809
+ answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
1810
+ expression: z.ZodOptional<z.ZodString>;
1811
+ variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1812
+ }, "strip", z.ZodTypeAny, {
1813
+ mode: "simple" | "expression";
1814
+ expression?: string | undefined;
1815
+ answers?: Record<string, string | number> | undefined;
1816
+ variables?: string[] | undefined;
1817
+ }, {
1818
+ mode: "simple" | "expression";
1819
+ expression?: string | undefined;
1820
+ answers?: Record<string, string | number> | undefined;
1821
+ variables?: string[] | undefined;
1822
+ }>;
1823
+ meta: z.ZodOptional<z.ZodObject<{
1824
+ createdAt: z.ZodOptional<z.ZodString>;
1825
+ author: z.ZodOptional<z.ZodString>;
1826
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1827
+ difficulty: z.ZodOptional<z.ZodNumber>;
1828
+ }, "strip", z.ZodTypeAny, {
1829
+ createdAt?: string | undefined;
1830
+ author?: string | undefined;
1831
+ tags?: string[] | undefined;
1832
+ difficulty?: number | undefined;
1833
+ }, {
1834
+ createdAt?: string | undefined;
1835
+ author?: string | undefined;
1836
+ tags?: string[] | undefined;
1837
+ difficulty?: number | undefined;
1838
+ }>>;
1839
+ }, "strip", z.ZodTypeAny, {
1840
+ validation: {
1841
+ mode: "simple" | "expression";
1842
+ expression?: string | undefined;
1843
+ answers?: Record<string, string | number> | undefined;
1844
+ variables?: string[] | undefined;
1845
+ };
1846
+ version: "2.0";
1847
+ layout: any[];
1848
+ widgets: Record<string, {
1849
+ length: number;
1850
+ type: "inline-input";
1851
+ inputType: "string";
1852
+ } | {
1853
+ type: "inline-input";
1854
+ inputType: "numeric";
1855
+ digits: number;
1856
+ } | {
1857
+ type: "drag-options";
1858
+ options: string[];
1859
+ } | {
1860
+ type: "radio-options";
1861
+ options: string[];
1862
+ } | {
1863
+ type: "numeric-keypad";
1864
+ includeOperators?: boolean | undefined;
1865
+ includeDecimal?: boolean | undefined;
1866
+ }>;
1867
+ id?: string | undefined;
1868
+ meta?: {
1869
+ createdAt?: string | undefined;
1870
+ author?: string | undefined;
1871
+ tags?: string[] | undefined;
1872
+ difficulty?: number | undefined;
1873
+ } | undefined;
1874
+ }, {
1875
+ validation: {
1876
+ mode: "simple" | "expression";
1877
+ expression?: string | undefined;
1878
+ answers?: Record<string, string | number> | undefined;
1879
+ variables?: string[] | undefined;
1880
+ };
1881
+ version: "2.0";
1882
+ layout: any[];
1883
+ widgets: Record<string, {
1884
+ length: number;
1885
+ type: "inline-input";
1886
+ inputType: "string";
1887
+ } | {
1888
+ type: "inline-input";
1889
+ inputType: "numeric";
1890
+ digits: number;
1891
+ } | {
1892
+ type: "drag-options";
1893
+ options: string[];
1894
+ } | {
1895
+ type: "radio-options";
1896
+ options: string[];
1897
+ } | {
1898
+ type: "numeric-keypad";
1899
+ includeOperators?: boolean | undefined;
1900
+ includeDecimal?: boolean | undefined;
1901
+ }>;
1902
+ id?: string | undefined;
1903
+ meta?: {
1904
+ createdAt?: string | undefined;
1905
+ author?: string | undefined;
1906
+ tags?: string[] | undefined;
1907
+ difficulty?: number | undefined;
1908
+ } | undefined;
1909
+ }>;
1910
+
1911
+ export declare type ExerciseMeta = z.infer<typeof ExerciseMetaSchema>;
1912
+
1913
+ export declare const ExerciseMetaSchema: z.ZodObject<{
1914
+ createdAt: z.ZodOptional<z.ZodString>;
1915
+ author: z.ZodOptional<z.ZodString>;
1916
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1917
+ difficulty: z.ZodOptional<z.ZodNumber>;
1918
+ }, "strip", z.ZodTypeAny, {
1919
+ createdAt?: string | undefined;
1920
+ author?: string | undefined;
1921
+ tags?: string[] | undefined;
1922
+ difficulty?: number | undefined;
1923
+ }, {
1924
+ createdAt?: string | undefined;
1925
+ author?: string | undefined;
1926
+ tags?: string[] | undefined;
1927
+ difficulty?: number | undefined;
1928
+ }>;
1929
+
1930
+ /**
1931
+ * Main renderer component - the contract for rendering exercises.
1932
+ *
1933
+ * This component is DUMB - it only collects values and passes them up.
1934
+ * The parent decides correctness via validation.
1935
+ */
1936
+ export declare const ExerciseRenderer: ForwardRefExoticComponent<ExerciseRendererProps & RefAttributes<ExerciseRendererRef>>;
1937
+
1938
+ export declare interface ExerciseRendererProps {
1939
+ json: ExerciseJSON;
1940
+ onSubmit?: (values: Record<string, string>) => void;
1941
+ onChange?: (values: Record<string, string>) => void;
1942
+ showSubmitButton?: boolean;
1943
+ className?: string;
1944
+ }
1945
+
1946
+ export declare interface ExerciseRendererRef {
1947
+ submit: () => ValidationResult;
1948
+ getValues: () => Record<string, string>;
1949
+ reset: () => void;
1950
+ focusFirstInput: () => void;
1951
+ }
1952
+
1953
+ export declare type ExpressionValidation = z.infer<typeof ExpressionValidationSchema>;
1954
+
1955
+ /**
1956
+ * Expression validation schema - validates using a boolean expression
1957
+ *
1958
+ * The expression can reference widget values by name.
1959
+ * Example: "a + b === 10"
953
1960
  *
954
1961
  * @example
955
1962
  * {
@@ -1275,209 +2282,1027 @@ export declare const InlineNodeSchema: z.ZodUnion<[z.ZodObject<{
1275
2282
  }>]>]>;
1276
2283
 
1277
2284
  /**
1278
- * Type guard for BoldText
2285
+ * Type guard for BoldText
2286
+ */
2287
+ export declare function isBoldText(item: LayoutItem): item is Extract<LayoutItem, {
2288
+ type: 'bold-text';
2289
+ }>;
2290
+
2291
+ /**
2292
+ * Type guard for ColorText
2293
+ */
2294
+ export declare function isColorText(item: LayoutItem): item is Extract<LayoutItem, {
2295
+ type: 'color-text';
2296
+ }>;
2297
+
2298
+ export declare function isDragOptions(value: unknown): value is DragOptionsTool;
2299
+
2300
+ /**
2301
+ * Type guard for DragOptionsJSON
2302
+ */
2303
+ export declare function isDragOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
2304
+ type: 'drag-options';
2305
+ }>;
2306
+
2307
+ export declare function isExerciseDocument(value: unknown): value is ExerciseDocument;
2308
+
2309
+ export declare function isExpressionValidation(value: unknown): value is ExpressionValidation;
2310
+
2311
+ export declare function isFreeText(value: unknown): value is FreeTextInline;
2312
+
2313
+ /**
2314
+ * Type guard for GroupItem
2315
+ */
2316
+ export declare function isGroupItem(item: LayoutItem): item is Extract<LayoutItem, {
2317
+ type: 'group';
2318
+ }>;
2319
+
2320
+ /**
2321
+ * Type guard for HighlightedText
2322
+ */
2323
+ export declare function isHighlightedText(item: LayoutItem): item is Extract<LayoutItem, {
2324
+ type: 'highlighted-text';
2325
+ }>;
2326
+
2327
+ export declare function isInlineInput(value: unknown): value is InlineInputWidget;
2328
+
2329
+ /**
2330
+ * Type guard for InlineInputJSON
2331
+ */
2332
+ export declare function isInlineInputJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
2333
+ type: 'inline-input';
2334
+ }>;
2335
+
2336
+ export declare function isInlineNode(value: unknown): value is InlineNode;
2337
+
2338
+ export declare function isLineBlock(value: unknown): value is LineBlock;
2339
+
2340
+ /**
2341
+ * Type guard for Linebreak
2342
+ */
2343
+ export declare function isLinebreak(item: LayoutItem): item is Extract<LayoutItem, {
2344
+ type: 'linebreak';
2345
+ }>;
2346
+
2347
+ export declare function isNumericKeypad(value: unknown): value is NumericKeypadTool;
2348
+
2349
+ /**
2350
+ * Type guard for NumericKeypadJSON
2351
+ */
2352
+ export declare function isNumericKeypadJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
2353
+ type: 'numeric-keypad';
2354
+ }>;
2355
+
2356
+ /**
2357
+ * Type guard for OperatorItem
2358
+ */
2359
+ export declare function isOperatorItem(item: LayoutItem): item is Extract<LayoutItem, {
2360
+ type: 'operator';
2361
+ }>;
2362
+
2363
+ /**
2364
+ * Type guard for QuestionText
2365
+ */
2366
+ export declare function isQuestionText(item: LayoutItem): item is Extract<LayoutItem, {
2367
+ type: 'question-text';
2368
+ }>;
2369
+
2370
+ /**
2371
+ * Type guard for RadioOptionsJSON
2372
+ */
2373
+ export declare function isRadioOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
2374
+ type: 'radio-options';
2375
+ }>;
2376
+
2377
+ export declare function isSimpleValidation(value: unknown): value is SimpleValidation;
2378
+
2379
+ export declare function isSpace(value: unknown): value is SpaceInline;
2380
+
2381
+ /**
2382
+ * Type guard for SpaceItem
2383
+ */
2384
+ export declare function isSpaceItem(item: LayoutItem): item is Extract<LayoutItem, {
2385
+ type: 'space';
2386
+ }>;
2387
+
2388
+ /**
2389
+ * Type guard for TableCellItem
2390
+ */
2391
+ export declare function isTableCellItem(item: LayoutItem): item is Extract<LayoutItem, {
2392
+ type: 'table-cell';
2393
+ }>;
2394
+
2395
+ /**
2396
+ * Type guard for TableItem
2397
+ */
2398
+ export declare function isTableItem(item: LayoutItem): item is Extract<LayoutItem, {
2399
+ type: 'table';
2400
+ }>;
2401
+
2402
+ /**
2403
+ * Type guard for TableRowItem
2404
+ */
2405
+ export declare function isTableRowItem(item: LayoutItem): item is Extract<LayoutItem, {
2406
+ type: 'table-row';
2407
+ }>;
2408
+
2409
+ export declare function isTextBlock(value: unknown): value is TextBlock;
2410
+
2411
+ /**
2412
+ * Type guard for TextItem
2413
+ */
2414
+ export declare function isTextItem(item: LayoutItem): item is Extract<LayoutItem, {
2415
+ type: 'text';
2416
+ }>;
2417
+
2418
+ export declare function isToolNode(value: unknown): value is ToolNode;
2419
+
2420
+ export declare function isValidationNode(value: unknown): value is ValidationNode;
2421
+
2422
+ /**
2423
+ * Check if an expression is syntactically valid
2424
+ *
2425
+ * @param expression - The expression to check
2426
+ * @returns true if valid, false otherwise
2427
+ */
2428
+ export declare function isValidExpression(expression: string): boolean;
2429
+
2430
+ /**
2431
+ * Type guard for WidgetRef
1279
2432
  */
1280
- export declare function isBoldText(item: LayoutItem): item is Extract<LayoutItem, {
1281
- type: 'bold-text';
2433
+ export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutItem, {
2434
+ type: 'widget-ref';
1282
2435
  }>;
1283
2436
 
1284
2437
  /**
1285
- * Type guard for ColorText
2438
+ * JSON Layout Item Types
2439
+ *
2440
+ * These are the types used in the JSON output format.
1286
2441
  */
1287
- export declare function isColorText(item: LayoutItem): item is Extract<LayoutItem, {
1288
- type: 'color-text';
1289
- }>;
2442
+ export declare const JSON_TYPES: {
2443
+ /** Question/instruction text */
2444
+ readonly QUESTION_TEXT: "question-text";
2445
+ /** Regular text element */
2446
+ readonly TEXT: "text";
2447
+ /** Spacing element */
2448
+ readonly SPACE: "space";
2449
+ /** Text with optional highlighting */
2450
+ readonly HIGHLIGHTED_TEXT: "highlighted-text";
2451
+ /** Text with color styling */
2452
+ readonly COLOR_TEXT: "color-text";
2453
+ /** Bold text */
2454
+ readonly BOLD_TEXT: "bold-text";
2455
+ /** Reference to a widget */
2456
+ readonly WIDGET_REF: "widget-ref";
2457
+ /** Line break element */
2458
+ readonly LINEBREAK: "linebreak";
2459
+ /** Grouped layout items */
2460
+ readonly GROUP: "group";
2461
+ /** Operator symbol */
2462
+ readonly OPERATOR: "operator";
2463
+ /** Table layout block */
2464
+ readonly TABLE: "table";
2465
+ /** Row within a table */
2466
+ readonly TABLE_ROW: "table-row";
2467
+ /** Cell within a table */
2468
+ readonly TABLE_CELL: "table-cell";
2469
+ /** Inline input widget (string or numeric) */
2470
+ readonly INLINE_INPUT: "inline-input";
2471
+ /** Drag-and-drop options widget */
2472
+ readonly DRAG_OPTIONS: "drag-options";
2473
+ /** Radio button options widget */
2474
+ readonly RADIO_OPTIONS: "radio-options";
2475
+ /** Numeric keypad widget */
2476
+ readonly NUMERIC_KEYPAD: "numeric-keypad";
2477
+ };
1290
2478
 
1291
- export declare function isDragOptions(value: unknown): value is DragOptionsTool;
2479
+ /**
2480
+ * Type helper to get all JSON type values as a union type
2481
+ */
2482
+ export declare type JSONType = typeof JSON_TYPES[keyof typeof JSON_TYPES];
2483
+
2484
+ export declare type LayoutItem = z.infer<typeof LayoutItemSchema>;
2485
+
2486
+ export declare const LayoutItemSchema: z.ZodType<any>;
1292
2487
 
1293
2488
  /**
1294
- * Type guard for DragOptionsJSON
2489
+ * DUMB layout renderer - no opinions about spacing or layout.
1295
2490
  */
1296
- export declare function isDragOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
1297
- type: 'drag-options';
1298
- }>;
2491
+ export declare const LayoutRenderer: default_2.FC<LayoutRendererProps>;
1299
2492
 
1300
- export declare function isExerciseDocument(value: unknown): value is ExerciseDocument;
2493
+ export declare interface LayoutRendererProps {
2494
+ item: LayoutItem;
2495
+ widgets: Record<string, WidgetJSON>;
2496
+ values: Record<string, string>;
2497
+ droppedInputs: Set<string>;
2498
+ onChange: (widgetId: string, value: string, fromDrop?: boolean, sourceOptionId?: string) => void;
2499
+ onInputFocus?: (widgetId: string) => void;
2500
+ }
1301
2501
 
1302
- export declare function isExpressionValidation(value: unknown): value is ExpressionValidation;
2502
+ /**
2503
+ * Error thrown when lexer fails to tokenize input
2504
+ */
2505
+ export declare class LexerError extends EngineError {
2506
+ readonly lexerErrors: ILexingError[];
2507
+ readonly positions: SourcePosition[];
2508
+ constructor(errors: ILexingError[]);
2509
+ }
2510
+
2511
+ export declare type LineBlock = z.infer<typeof LineBlockSchema>;
2512
+
2513
+ /**
2514
+ * Line block schema - represents a visual row of inline elements
2515
+ *
2516
+ * One line = one visual row in the UI
2517
+ * Contains an ordered sequence of inline elements
2518
+ *
2519
+ * @example
2520
+ * {
2521
+ * type: "LineBlock",
2522
+ * inlines: [
2523
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
2524
+ * { type: "InlineInput", name: "x", length: 1 },
2525
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
2526
+ * ]
2527
+ * }
2528
+ */
2529
+ export declare const LineBlockSchema: z.ZodObject<{
2530
+ type: z.ZodLiteral<"LineBlock">;
2531
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
2532
+ type: z.ZodLiteral<"FreeText">;
2533
+ value: z.ZodString;
2534
+ }, "strip", z.ZodTypeAny, {
2535
+ value: string;
2536
+ type: "FreeText";
2537
+ }, {
2538
+ value: string;
2539
+ type: "FreeText";
2540
+ }>, z.ZodObject<{
2541
+ type: z.ZodLiteral<"Space">;
2542
+ }, "strip", z.ZodTypeAny, {
2543
+ type: "Space";
2544
+ }, {
2545
+ type: "Space";
2546
+ }>, z.ZodObject<{
2547
+ type: z.ZodLiteral<"HighlightedText">;
2548
+ value: z.ZodString;
2549
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2550
+ }, "strip", z.ZodTypeAny, {
2551
+ value: string;
2552
+ type: "HighlightedText";
2553
+ highlight?: [number, number] | undefined;
2554
+ }, {
2555
+ value: string;
2556
+ type: "HighlightedText";
2557
+ highlight?: [number, number] | undefined;
2558
+ }>, z.ZodObject<{
2559
+ type: z.ZodLiteral<"ColorText">;
2560
+ value: z.ZodString;
2561
+ color: z.ZodString;
2562
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2563
+ }, "strip", z.ZodTypeAny, {
2564
+ value: string;
2565
+ type: "ColorText";
2566
+ color: string;
2567
+ highlight?: [number, number] | undefined;
2568
+ }, {
2569
+ value: string;
2570
+ type: "ColorText";
2571
+ color: string;
2572
+ highlight?: [number, number] | undefined;
2573
+ }>, z.ZodObject<{
2574
+ type: z.ZodLiteral<"BoldText">;
2575
+ value: z.ZodString;
2576
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2577
+ }, "strip", z.ZodTypeAny, {
2578
+ value: string;
2579
+ type: "BoldText";
2580
+ highlight?: [number, number] | undefined;
2581
+ }, {
2582
+ value: string;
2583
+ type: "BoldText";
2584
+ highlight?: [number, number] | undefined;
2585
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
2586
+ type: z.ZodLiteral<"InlineInput">;
2587
+ name: z.ZodString;
2588
+ inputType: z.ZodLiteral<"string">;
2589
+ length: z.ZodNumber;
2590
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
2591
+ }, "strip", z.ZodTypeAny, {
2592
+ length: number;
2593
+ type: "InlineInput";
2594
+ inputType: "string";
2595
+ name: string;
2596
+ answer?: string | number | undefined;
2597
+ }, {
2598
+ length: number;
2599
+ type: "InlineInput";
2600
+ inputType: "string";
2601
+ name: string;
2602
+ answer?: string | number | undefined;
2603
+ }>, z.ZodObject<{
2604
+ type: z.ZodLiteral<"InlineInput">;
2605
+ name: z.ZodString;
2606
+ inputType: z.ZodLiteral<"numeric">;
2607
+ digits: z.ZodNumber;
2608
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
2609
+ }, "strip", z.ZodTypeAny, {
2610
+ type: "InlineInput";
2611
+ inputType: "numeric";
2612
+ name: string;
2613
+ digits: number;
2614
+ answer?: string | number | undefined;
2615
+ }, {
2616
+ type: "InlineInput";
2617
+ inputType: "numeric";
2618
+ name: string;
2619
+ digits: number;
2620
+ answer?: string | number | undefined;
2621
+ }>]>]>, "many">;
2622
+ }, "strip", z.ZodTypeAny, {
2623
+ type: "LineBlock";
2624
+ inlines: ({
2625
+ value: string;
2626
+ type: "FreeText";
2627
+ } | {
2628
+ type: "Space";
2629
+ } | {
2630
+ value: string;
2631
+ type: "HighlightedText";
2632
+ highlight?: [number, number] | undefined;
2633
+ } | {
2634
+ value: string;
2635
+ type: "ColorText";
2636
+ color: string;
2637
+ highlight?: [number, number] | undefined;
2638
+ } | {
2639
+ value: string;
2640
+ type: "BoldText";
2641
+ highlight?: [number, number] | undefined;
2642
+ } | {
2643
+ length: number;
2644
+ type: "InlineInput";
2645
+ inputType: "string";
2646
+ name: string;
2647
+ answer?: string | number | undefined;
2648
+ } | {
2649
+ type: "InlineInput";
2650
+ inputType: "numeric";
2651
+ name: string;
2652
+ digits: number;
2653
+ answer?: string | number | undefined;
2654
+ })[];
2655
+ }, {
2656
+ type: "LineBlock";
2657
+ inlines: ({
2658
+ value: string;
2659
+ type: "FreeText";
2660
+ } | {
2661
+ type: "Space";
2662
+ } | {
2663
+ value: string;
2664
+ type: "HighlightedText";
2665
+ highlight?: [number, number] | undefined;
2666
+ } | {
2667
+ value: string;
2668
+ type: "ColorText";
2669
+ color: string;
2670
+ highlight?: [number, number] | undefined;
2671
+ } | {
2672
+ value: string;
2673
+ type: "BoldText";
2674
+ highlight?: [number, number] | undefined;
2675
+ } | {
2676
+ length: number;
2677
+ type: "InlineInput";
2678
+ inputType: "string";
2679
+ name: string;
2680
+ answer?: string | number | undefined;
2681
+ } | {
2682
+ type: "InlineInput";
2683
+ inputType: "numeric";
2684
+ name: string;
2685
+ digits: number;
2686
+ answer?: string | number | undefined;
2687
+ })[];
2688
+ }>;
1303
2689
 
1304
- export declare function isFreeText(value: unknown): value is FreeTextInline;
2690
+ export declare type Linebreak = z.infer<typeof LinebreakSchema>;
1305
2691
 
1306
- /**
1307
- * Type guard for GroupItem
1308
- */
1309
- export declare function isGroupItem(item: LayoutItem): item is Extract<LayoutItem, {
1310
- type: 'group';
2692
+ export declare const LinebreakSchema: z.ZodObject<{
2693
+ id: z.ZodString;
2694
+ type: z.ZodLiteral<"linebreak">;
2695
+ }, "strip", z.ZodTypeAny, {
2696
+ type: "linebreak";
2697
+ id: string;
2698
+ }, {
2699
+ type: "linebreak";
2700
+ id: string;
1311
2701
  }>;
1312
2702
 
1313
- /**
1314
- * Type guard for HighlightedText
1315
- */
1316
- export declare function isHighlightedText(item: LayoutItem): item is Extract<LayoutItem, {
1317
- type: 'highlighted-text';
2703
+ export declare type NumericKeypadJSON = z.infer<typeof NumericKeypadJSONSchema>;
2704
+
2705
+ export declare const NumericKeypadJSONSchema: z.ZodObject<{
2706
+ type: z.ZodLiteral<"numeric-keypad">;
2707
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
2708
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
2709
+ }, "strip", z.ZodTypeAny, {
2710
+ type: "numeric-keypad";
2711
+ includeOperators?: boolean | undefined;
2712
+ includeDecimal?: boolean | undefined;
2713
+ }, {
2714
+ type: "numeric-keypad";
2715
+ includeOperators?: boolean | undefined;
2716
+ includeDecimal?: boolean | undefined;
1318
2717
  }>;
1319
2718
 
1320
- export declare function isInlineInput(value: unknown): value is InlineInputWidget;
2719
+ export declare type NumericKeypadTool = z.infer<typeof NumericKeypadToolSchema>;
1321
2720
 
1322
2721
  /**
1323
- * Type guard for InlineInputJSON
2722
+ * Numeric keypad tool schema - on-screen number pad
2723
+ *
2724
+ * Use cases:
2725
+ * - Touch-friendly number entry
2726
+ * - Restricting input to numbers only
2727
+ * - Consistent cross-device experience
2728
+ *
2729
+ * @example
2730
+ * {
2731
+ * type: "NumericKeypad",
2732
+ * includeOperators: true
2733
+ * }
1324
2734
  */
1325
- export declare function isInlineInputJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
1326
- type: 'inline-input';
2735
+ export declare const NumericKeypadToolSchema: z.ZodObject<{
2736
+ type: z.ZodLiteral<"NumericKeypad">;
2737
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
2738
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
2739
+ }, "strip", z.ZodTypeAny, {
2740
+ type: "NumericKeypad";
2741
+ includeOperators?: boolean | undefined;
2742
+ includeDecimal?: boolean | undefined;
2743
+ }, {
2744
+ type: "NumericKeypad";
2745
+ includeOperators?: boolean | undefined;
2746
+ includeDecimal?: boolean | undefined;
1327
2747
  }>;
1328
2748
 
1329
- export declare function isInlineNode(value: unknown): value is InlineNode;
1330
-
1331
- export declare function isLineBlock(value: unknown): value is LineBlock;
2749
+ export declare type OperatorItem = z.infer<typeof OperatorItemSchema>;
1332
2750
 
1333
- /**
1334
- * Type guard for Linebreak
1335
- */
1336
- export declare function isLinebreak(item: LayoutItem): item is Extract<LayoutItem, {
1337
- type: 'linebreak';
2751
+ export declare const OperatorItemSchema: z.ZodObject<{
2752
+ id: z.ZodString;
2753
+ type: z.ZodLiteral<"operator">;
2754
+ operator: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
2755
+ }, "strip", z.ZodTypeAny, {
2756
+ operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
2757
+ type: "operator";
2758
+ id: string;
2759
+ }, {
2760
+ operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
2761
+ type: "operator";
2762
+ id: string;
1338
2763
  }>;
1339
2764
 
1340
- export declare function isNumericKeypad(value: unknown): value is NumericKeypadTool;
2765
+ export declare const OperatorSchema: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
1341
2766
 
1342
2767
  /**
1343
- * Type guard for NumericKeypadJSON
2768
+ * Parse DSL tokens into CST
1344
2769
  */
1345
- export declare function isNumericKeypadJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
1346
- type: 'numeric-keypad';
1347
- }>;
2770
+ export declare function parse(tokens: IToken[]): CstNode;
1348
2771
 
1349
2772
  /**
1350
- * Type guard for OperatorItem
2773
+ * Error thrown when parser fails to parse tokens
1351
2774
  */
1352
- export declare function isOperatorItem(item: LayoutItem): item is Extract<LayoutItem, {
1353
- type: 'operator';
1354
- }>;
2775
+ export declare class ParseError extends EngineError {
2776
+ readonly parseErrors: IRecognitionException[];
2777
+ readonly positions: SourcePosition[];
2778
+ constructor(errors: IRecognitionException[]);
2779
+ }
1355
2780
 
1356
2781
  /**
1357
- * Type guard for QuestionText
2782
+ * Parse DSL tokens into CST (safe version - returns errors instead of throwing)
1358
2783
  */
1359
- export declare function isQuestionText(item: LayoutItem): item is Extract<LayoutItem, {
1360
- type: 'question-text';
1361
- }>;
2784
+ export declare function parseSafe(tokens: IToken[]): {
2785
+ success: true;
2786
+ cst: CstNode;
2787
+ error?: undefined;
2788
+ } | {
2789
+ success: false;
2790
+ error: unknown;
2791
+ cst?: undefined;
2792
+ };
1362
2793
 
1363
- export declare function isSimpleValidation(value: unknown): value is SimpleValidation;
2794
+ export declare type QuestionText = z.infer<typeof QuestionTextSchema>;
1364
2795
 
1365
- export declare function isSpace(value: unknown): value is SpaceInline;
2796
+ export declare const QuestionTextSchema: z.ZodObject<{
2797
+ id: z.ZodString;
2798
+ type: z.ZodLiteral<"question-text">;
2799
+ value: z.ZodString;
2800
+ }, "strip", z.ZodTypeAny, {
2801
+ value: string;
2802
+ type: "question-text";
2803
+ id: string;
2804
+ }, {
2805
+ value: string;
2806
+ type: "question-text";
2807
+ id: string;
2808
+ }>;
1366
2809
 
1367
- export declare function isTextBlock(value: unknown): value is TextBlock;
2810
+ export declare type RadioOptionsBlock = z.infer<typeof RadioOptionsBlockSchema>;
1368
2811
 
1369
2812
  /**
1370
- * Type guard for TextItem
2813
+ * Radio options block schema - single-choice radio buttons
2814
+ *
2815
+ * @example
2816
+ * {
2817
+ * type: "RadioOptions",
2818
+ * name: "q1",
2819
+ * options: ["apple", "orange", "banana"],
2820
+ * answer: "apple"
2821
+ * }
1371
2822
  */
1372
- export declare function isTextItem(item: LayoutItem): item is Extract<LayoutItem, {
1373
- type: 'text';
2823
+ declare const RadioOptionsBlockSchema: z.ZodObject<{
2824
+ type: z.ZodLiteral<"RadioOptions">;
2825
+ name: z.ZodString;
2826
+ options: z.ZodArray<z.ZodString, "many">;
2827
+ answer: z.ZodString;
2828
+ }, "strip", z.ZodTypeAny, {
2829
+ type: "RadioOptions";
2830
+ options: string[];
2831
+ name: string;
2832
+ answer: string;
2833
+ }, {
2834
+ type: "RadioOptions";
2835
+ options: string[];
2836
+ name: string;
2837
+ answer: string;
1374
2838
  }>;
1375
2839
 
1376
- export declare function isToolNode(value: unknown): value is ToolNode;
2840
+ export declare type RadioOptionsJSON = z.infer<typeof RadioOptionsJSONSchema>;
1377
2841
 
1378
- export declare function isValidationNode(value: unknown): value is ValidationNode;
2842
+ export declare const RadioOptionsJSONSchema: z.ZodObject<{
2843
+ type: z.ZodLiteral<"radio-options">;
2844
+ options: z.ZodArray<z.ZodString, "many">;
2845
+ }, "strip", z.ZodTypeAny, {
2846
+ type: "radio-options";
2847
+ options: string[];
2848
+ }, {
2849
+ type: "radio-options";
2850
+ options: string[];
2851
+ }>;
1379
2852
 
1380
2853
  /**
1381
- * Check if an expression is syntactically valid
2854
+ * DOM helper for quick usage / demos.
1382
2855
  *
1383
- * @param expression - The expression to check
1384
- * @returns true if valid, false otherwise
2856
+ * This couples the engine to DOM + React root creation.
2857
+ * For production use, prefer <ExerciseRenderer /> directly in your React tree.
2858
+ *
2859
+ * @example
2860
+ * ```typescript
2861
+ * import { compile, renderExercise } from 'math-exercise-engine';
2862
+ *
2863
+ * const json = compile(dsl);
2864
+ * const unmount = renderExercise({
2865
+ * container: '#app',
2866
+ * json,
2867
+ * onSubmit: (values) => {
2868
+ * // Parent decides correctness
2869
+ * const result = validate(json, values);
2870
+ * console.log(result.isCorrect);
2871
+ * }
2872
+ * });
2873
+ *
2874
+ * // Later: unmount()
2875
+ * ```
1385
2876
  */
1386
- export declare function isValidExpression(expression: string): boolean;
2877
+ export declare function renderExercise(options: RenderOptions): () => void;
2878
+
2879
+ export declare interface RenderOptions {
2880
+ container: HTMLElement | string;
2881
+ json: ExerciseJSON;
2882
+ onSubmit?: (values: Record<string, string>) => void;
2883
+ onChange?: (values: Record<string, string>) => void;
2884
+ showSubmitButton?: boolean;
2885
+ className?: string;
2886
+ }
2887
+
2888
+ export declare type SimpleValidation = z.infer<typeof SimpleValidationSchema>;
1387
2889
 
1388
2890
  /**
1389
- * Type guard for WidgetRef
2891
+ * Simple validation schema - direct answer matching
2892
+ *
2893
+ * Each input has a predetermined correct answer.
2894
+ * No complex expressions or calculations.
2895
+ *
2896
+ * @example
2897
+ * {
2898
+ * type: "SimpleValidation"
2899
+ * }
2900
+ *
2901
+ * Note: Actual answer values are stored separately (in widget definitions)
1390
2902
  */
1391
- export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutItem, {
1392
- type: 'widget-ref';
2903
+ export declare const SimpleValidationSchema: z.ZodObject<{
2904
+ type: z.ZodLiteral<"SimpleValidation">;
2905
+ }, "strip", z.ZodTypeAny, {
2906
+ type: "SimpleValidation";
2907
+ }, {
2908
+ type: "SimpleValidation";
1393
2909
  }>;
1394
2910
 
1395
2911
  /**
1396
- * JSON Layout Item Types
1397
- *
1398
- * These are the types used in the JSON output format.
2912
+ * Source position information for error reporting
1399
2913
  */
1400
- export declare const JSON_TYPES: {
1401
- /** Question/instruction text */
1402
- readonly QUESTION_TEXT: "question-text";
1403
- /** Regular text element */
1404
- readonly TEXT: "text";
1405
- /** Spacing element */
1406
- readonly SPACE: "space";
1407
- /** Text with optional highlighting */
1408
- readonly HIGHLIGHTED_TEXT: "highlighted-text";
1409
- /** Text with color styling */
1410
- readonly COLOR_TEXT: "color-text";
1411
- /** Bold text */
1412
- readonly BOLD_TEXT: "bold-text";
1413
- /** Reference to a widget */
1414
- readonly WIDGET_REF: "widget-ref";
1415
- /** Line break element */
1416
- readonly LINEBREAK: "linebreak";
1417
- /** Grouped layout items */
1418
- readonly GROUP: "group";
1419
- /** Operator symbol */
1420
- readonly OPERATOR: "operator";
1421
- /** Inline input widget (string or numeric) */
1422
- readonly INLINE_INPUT: "inline-input";
1423
- /** Drag-and-drop options widget */
1424
- readonly DRAG_OPTIONS: "drag-options";
1425
- /** Numeric keypad widget */
1426
- readonly NUMERIC_KEYPAD: "numeric-keypad";
1427
- };
2914
+ export declare interface SourcePosition {
2915
+ startLine: number;
2916
+ startColumn: number;
2917
+ endLine: number;
2918
+ endColumn: number;
2919
+ }
2920
+
2921
+ export declare type SpaceInline = z.infer<typeof SpaceInlineSchema>;
1428
2922
 
1429
2923
  /**
1430
- * Type helper to get all JSON type values as a union type
2924
+ * Space inline schema - explicit spacing element
2925
+ *
2926
+ * Represents one or more consecutive spaces as a single space element.
2927
+ * This allows for deterministic and explicit control over spacing in the layout.
2928
+ *
2929
+ * @example
2930
+ * { type: "Space" }
1431
2931
  */
1432
- export declare type JSONType = typeof JSON_TYPES[keyof typeof JSON_TYPES];
2932
+ export declare const SpaceInlineSchema: z.ZodObject<{
2933
+ type: z.ZodLiteral<"Space">;
2934
+ }, "strip", z.ZodTypeAny, {
2935
+ type: "Space";
2936
+ }, {
2937
+ type: "Space";
2938
+ }>;
1433
2939
 
1434
- export declare type LayoutItem = z.infer<typeof LayoutItemSchema>;
2940
+ export declare type SpaceItem = z.infer<typeof SpaceItemSchema>;
1435
2941
 
1436
- export declare const LayoutItemSchema: z.ZodType<any>;
2942
+ export declare const SpaceItemSchema: z.ZodObject<{
2943
+ id: z.ZodString;
2944
+ type: z.ZodLiteral<"space">;
2945
+ }, "strip", z.ZodTypeAny, {
2946
+ type: "space";
2947
+ id: string;
2948
+ }, {
2949
+ type: "space";
2950
+ id: string;
2951
+ }>;
1437
2952
 
1438
- /**
1439
- * DUMB layout renderer - no opinions about spacing or layout.
1440
- */
1441
- export declare const LayoutRenderer: default_2.FC<LayoutRendererProps>;
2953
+ export declare type TableBlock = z.infer<typeof TableBlockSchema>;
2954
+
2955
+ declare const TableBlockSchema: z.ZodObject<{
2956
+ type: z.ZodLiteral<"TableBlock">;
2957
+ cols: z.ZodNumber;
2958
+ rows: z.ZodArray<z.ZodObject<{
2959
+ type: z.ZodLiteral<"TableRow">;
2960
+ cells: z.ZodArray<z.ZodObject<{
2961
+ type: z.ZodLiteral<"TableCell">;
2962
+ colspan: z.ZodOptional<z.ZodNumber>;
2963
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
2964
+ type: z.ZodLiteral<"FreeText">;
2965
+ value: z.ZodString;
2966
+ }, "strip", z.ZodTypeAny, {
2967
+ value: string;
2968
+ type: "FreeText";
2969
+ }, {
2970
+ value: string;
2971
+ type: "FreeText";
2972
+ }>, z.ZodObject<{
2973
+ type: z.ZodLiteral<"Space">;
2974
+ }, "strip", z.ZodTypeAny, {
2975
+ type: "Space";
2976
+ }, {
2977
+ type: "Space";
2978
+ }>, z.ZodObject<{
2979
+ type: z.ZodLiteral<"HighlightedText">;
2980
+ value: z.ZodString;
2981
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2982
+ }, "strip", z.ZodTypeAny, {
2983
+ value: string;
2984
+ type: "HighlightedText";
2985
+ highlight?: [number, number] | undefined;
2986
+ }, {
2987
+ value: string;
2988
+ type: "HighlightedText";
2989
+ highlight?: [number, number] | undefined;
2990
+ }>, z.ZodObject<{
2991
+ type: z.ZodLiteral<"ColorText">;
2992
+ value: z.ZodString;
2993
+ color: z.ZodString;
2994
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2995
+ }, "strip", z.ZodTypeAny, {
2996
+ value: string;
2997
+ type: "ColorText";
2998
+ color: string;
2999
+ highlight?: [number, number] | undefined;
3000
+ }, {
3001
+ value: string;
3002
+ type: "ColorText";
3003
+ color: string;
3004
+ highlight?: [number, number] | undefined;
3005
+ }>, z.ZodObject<{
3006
+ type: z.ZodLiteral<"BoldText">;
3007
+ value: z.ZodString;
3008
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3009
+ }, "strip", z.ZodTypeAny, {
3010
+ value: string;
3011
+ type: "BoldText";
3012
+ highlight?: [number, number] | undefined;
3013
+ }, {
3014
+ value: string;
3015
+ type: "BoldText";
3016
+ highlight?: [number, number] | undefined;
3017
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
3018
+ type: z.ZodLiteral<"InlineInput">;
3019
+ name: z.ZodString;
3020
+ inputType: z.ZodLiteral<"string">;
3021
+ length: z.ZodNumber;
3022
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
3023
+ }, "strip", z.ZodTypeAny, {
3024
+ length: number;
3025
+ type: "InlineInput";
3026
+ inputType: "string";
3027
+ name: string;
3028
+ answer?: string | number | undefined;
3029
+ }, {
3030
+ length: number;
3031
+ type: "InlineInput";
3032
+ inputType: "string";
3033
+ name: string;
3034
+ answer?: string | number | undefined;
3035
+ }>, z.ZodObject<{
3036
+ type: z.ZodLiteral<"InlineInput">;
3037
+ name: z.ZodString;
3038
+ inputType: z.ZodLiteral<"numeric">;
3039
+ digits: z.ZodNumber;
3040
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
3041
+ }, "strip", z.ZodTypeAny, {
3042
+ type: "InlineInput";
3043
+ inputType: "numeric";
3044
+ name: string;
3045
+ digits: number;
3046
+ answer?: string | number | undefined;
3047
+ }, {
3048
+ type: "InlineInput";
3049
+ inputType: "numeric";
3050
+ name: string;
3051
+ digits: number;
3052
+ answer?: string | number | undefined;
3053
+ }>]>]>, "many">;
3054
+ }, "strip", z.ZodTypeAny, {
3055
+ type: "TableCell";
3056
+ inlines: ({
3057
+ value: string;
3058
+ type: "FreeText";
3059
+ } | {
3060
+ type: "Space";
3061
+ } | {
3062
+ value: string;
3063
+ type: "HighlightedText";
3064
+ highlight?: [number, number] | undefined;
3065
+ } | {
3066
+ value: string;
3067
+ type: "ColorText";
3068
+ color: string;
3069
+ highlight?: [number, number] | undefined;
3070
+ } | {
3071
+ value: string;
3072
+ type: "BoldText";
3073
+ highlight?: [number, number] | undefined;
3074
+ } | {
3075
+ length: number;
3076
+ type: "InlineInput";
3077
+ inputType: "string";
3078
+ name: string;
3079
+ answer?: string | number | undefined;
3080
+ } | {
3081
+ type: "InlineInput";
3082
+ inputType: "numeric";
3083
+ name: string;
3084
+ digits: number;
3085
+ answer?: string | number | undefined;
3086
+ })[];
3087
+ colspan?: number | undefined;
3088
+ }, {
3089
+ type: "TableCell";
3090
+ inlines: ({
3091
+ value: string;
3092
+ type: "FreeText";
3093
+ } | {
3094
+ type: "Space";
3095
+ } | {
3096
+ value: string;
3097
+ type: "HighlightedText";
3098
+ highlight?: [number, number] | undefined;
3099
+ } | {
3100
+ value: string;
3101
+ type: "ColorText";
3102
+ color: string;
3103
+ highlight?: [number, number] | undefined;
3104
+ } | {
3105
+ value: string;
3106
+ type: "BoldText";
3107
+ highlight?: [number, number] | undefined;
3108
+ } | {
3109
+ length: number;
3110
+ type: "InlineInput";
3111
+ inputType: "string";
3112
+ name: string;
3113
+ answer?: string | number | undefined;
3114
+ } | {
3115
+ type: "InlineInput";
3116
+ inputType: "numeric";
3117
+ name: string;
3118
+ digits: number;
3119
+ answer?: string | number | undefined;
3120
+ })[];
3121
+ colspan?: number | undefined;
3122
+ }>, "many">;
3123
+ }, "strip", z.ZodTypeAny, {
3124
+ type: "TableRow";
3125
+ cells: {
3126
+ type: "TableCell";
3127
+ inlines: ({
3128
+ value: string;
3129
+ type: "FreeText";
3130
+ } | {
3131
+ type: "Space";
3132
+ } | {
3133
+ value: string;
3134
+ type: "HighlightedText";
3135
+ highlight?: [number, number] | undefined;
3136
+ } | {
3137
+ value: string;
3138
+ type: "ColorText";
3139
+ color: string;
3140
+ highlight?: [number, number] | undefined;
3141
+ } | {
3142
+ value: string;
3143
+ type: "BoldText";
3144
+ highlight?: [number, number] | undefined;
3145
+ } | {
3146
+ length: number;
3147
+ type: "InlineInput";
3148
+ inputType: "string";
3149
+ name: string;
3150
+ answer?: string | number | undefined;
3151
+ } | {
3152
+ type: "InlineInput";
3153
+ inputType: "numeric";
3154
+ name: string;
3155
+ digits: number;
3156
+ answer?: string | number | undefined;
3157
+ })[];
3158
+ colspan?: number | undefined;
3159
+ }[];
3160
+ }, {
3161
+ type: "TableRow";
3162
+ cells: {
3163
+ type: "TableCell";
3164
+ inlines: ({
3165
+ value: string;
3166
+ type: "FreeText";
3167
+ } | {
3168
+ type: "Space";
3169
+ } | {
3170
+ value: string;
3171
+ type: "HighlightedText";
3172
+ highlight?: [number, number] | undefined;
3173
+ } | {
3174
+ value: string;
3175
+ type: "ColorText";
3176
+ color: string;
3177
+ highlight?: [number, number] | undefined;
3178
+ } | {
3179
+ value: string;
3180
+ type: "BoldText";
3181
+ highlight?: [number, number] | undefined;
3182
+ } | {
3183
+ length: number;
3184
+ type: "InlineInput";
3185
+ inputType: "string";
3186
+ name: string;
3187
+ answer?: string | number | undefined;
3188
+ } | {
3189
+ type: "InlineInput";
3190
+ inputType: "numeric";
3191
+ name: string;
3192
+ digits: number;
3193
+ answer?: string | number | undefined;
3194
+ })[];
3195
+ colspan?: number | undefined;
3196
+ }[];
3197
+ }>, "many">;
3198
+ }, "strip", z.ZodTypeAny, {
3199
+ type: "TableBlock";
3200
+ cols: number;
3201
+ rows: {
3202
+ type: "TableRow";
3203
+ cells: {
3204
+ type: "TableCell";
3205
+ inlines: ({
3206
+ value: string;
3207
+ type: "FreeText";
3208
+ } | {
3209
+ type: "Space";
3210
+ } | {
3211
+ value: string;
3212
+ type: "HighlightedText";
3213
+ highlight?: [number, number] | undefined;
3214
+ } | {
3215
+ value: string;
3216
+ type: "ColorText";
3217
+ color: string;
3218
+ highlight?: [number, number] | undefined;
3219
+ } | {
3220
+ value: string;
3221
+ type: "BoldText";
3222
+ highlight?: [number, number] | undefined;
3223
+ } | {
3224
+ length: number;
3225
+ type: "InlineInput";
3226
+ inputType: "string";
3227
+ name: string;
3228
+ answer?: string | number | undefined;
3229
+ } | {
3230
+ type: "InlineInput";
3231
+ inputType: "numeric";
3232
+ name: string;
3233
+ digits: number;
3234
+ answer?: string | number | undefined;
3235
+ })[];
3236
+ colspan?: number | undefined;
3237
+ }[];
3238
+ }[];
3239
+ }, {
3240
+ type: "TableBlock";
3241
+ cols: number;
3242
+ rows: {
3243
+ type: "TableRow";
3244
+ cells: {
3245
+ type: "TableCell";
3246
+ inlines: ({
3247
+ value: string;
3248
+ type: "FreeText";
3249
+ } | {
3250
+ type: "Space";
3251
+ } | {
3252
+ value: string;
3253
+ type: "HighlightedText";
3254
+ highlight?: [number, number] | undefined;
3255
+ } | {
3256
+ value: string;
3257
+ type: "ColorText";
3258
+ color: string;
3259
+ highlight?: [number, number] | undefined;
3260
+ } | {
3261
+ value: string;
3262
+ type: "BoldText";
3263
+ highlight?: [number, number] | undefined;
3264
+ } | {
3265
+ length: number;
3266
+ type: "InlineInput";
3267
+ inputType: "string";
3268
+ name: string;
3269
+ answer?: string | number | undefined;
3270
+ } | {
3271
+ type: "InlineInput";
3272
+ inputType: "numeric";
3273
+ name: string;
3274
+ digits: number;
3275
+ answer?: string | number | undefined;
3276
+ })[];
3277
+ colspan?: number | undefined;
3278
+ }[];
3279
+ }[];
3280
+ }>;
1442
3281
 
1443
- export declare interface LayoutRendererProps {
1444
- item: LayoutItem;
1445
- widgets: Record<string, WidgetJSON>;
1446
- values: Record<string, string>;
1447
- droppedInputs: Set<string>;
1448
- onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
1449
- onInputFocus?: (widgetId: string) => void;
1450
- }
3282
+ export declare type TableCell = z.infer<typeof TableCellSchema>;
1451
3283
 
1452
- /**
1453
- * Error thrown when lexer fails to tokenize input
1454
- */
1455
- export declare class LexerError extends EngineError {
1456
- readonly lexerErrors: ILexingError[];
1457
- readonly positions: SourcePosition[];
1458
- constructor(errors: ILexingError[]);
1459
- }
3284
+ export declare type TableCellItem = z.infer<typeof TableCellItemSchema>;
1460
3285
 
1461
- export declare type LineBlock = z.infer<typeof LineBlockSchema>;
3286
+ export declare const TableCellItemSchema: z.ZodObject<{
3287
+ id: z.ZodString;
3288
+ type: z.ZodLiteral<"table-cell">;
3289
+ colspan: z.ZodOptional<z.ZodNumber>;
3290
+ items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
3291
+ }, "strip", z.ZodTypeAny, {
3292
+ type: "table-cell";
3293
+ id: string;
3294
+ items: any[];
3295
+ colspan?: number | undefined;
3296
+ }, {
3297
+ type: "table-cell";
3298
+ id: string;
3299
+ items: any[];
3300
+ colspan?: number | undefined;
3301
+ }>;
1462
3302
 
1463
- /**
1464
- * Line block schema - represents a visual row of inline elements
1465
- *
1466
- * One line = one visual row in the UI
1467
- * Contains an ordered sequence of inline elements
1468
- *
1469
- * @example
1470
- * {
1471
- * type: "LineBlock",
1472
- * inlines: [
1473
- * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
1474
- * { type: "InlineInput", name: "x", length: 1 },
1475
- * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
1476
- * ]
1477
- * }
1478
- */
1479
- export declare const LineBlockSchema: z.ZodObject<{
1480
- type: z.ZodLiteral<"LineBlock">;
3303
+ declare const TableCellSchema: z.ZodObject<{
3304
+ type: z.ZodLiteral<"TableCell">;
3305
+ colspan: z.ZodOptional<z.ZodNumber>;
1481
3306
  inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1482
3307
  type: z.ZodLiteral<"FreeText">;
1483
3308
  value: z.ZodString;
@@ -1570,7 +3395,7 @@ export declare const LineBlockSchema: z.ZodObject<{
1570
3395
  answer?: string | number | undefined;
1571
3396
  }>]>]>, "many">;
1572
3397
  }, "strip", z.ZodTypeAny, {
1573
- type: "LineBlock";
3398
+ type: "TableCell";
1574
3399
  inlines: ({
1575
3400
  value: string;
1576
3401
  type: "FreeText";
@@ -1602,8 +3427,9 @@ export declare const LineBlockSchema: z.ZodObject<{
1602
3427
  digits: number;
1603
3428
  answer?: string | number | undefined;
1604
3429
  })[];
3430
+ colspan?: number | undefined;
1605
3431
  }, {
1606
- type: "LineBlock";
3432
+ type: "TableCell";
1607
3433
  inlines: ({
1608
3434
  value: string;
1609
3435
  type: "FreeText";
@@ -1635,213 +3461,365 @@ export declare const LineBlockSchema: z.ZodObject<{
1635
3461
  digits: number;
1636
3462
  answer?: string | number | undefined;
1637
3463
  })[];
3464
+ colspan?: number | undefined;
1638
3465
  }>;
1639
3466
 
1640
- export declare type Linebreak = z.infer<typeof LinebreakSchema>;
1641
-
1642
- export declare const LinebreakSchema: z.ZodObject<{
1643
- id: z.ZodString;
1644
- type: z.ZodLiteral<"linebreak">;
1645
- }, "strip", z.ZodTypeAny, {
1646
- type: "linebreak";
1647
- id: string;
1648
- }, {
1649
- type: "linebreak";
1650
- id: string;
1651
- }>;
1652
-
1653
- export declare type NumericKeypadJSON = z.infer<typeof NumericKeypadJSONSchema>;
1654
-
1655
- export declare const NumericKeypadJSONSchema: z.ZodObject<{
1656
- type: z.ZodLiteral<"numeric-keypad">;
1657
- includeOperators: z.ZodOptional<z.ZodBoolean>;
1658
- includeDecimal: z.ZodOptional<z.ZodBoolean>;
1659
- }, "strip", z.ZodTypeAny, {
1660
- type: "numeric-keypad";
1661
- includeOperators?: boolean | undefined;
1662
- includeDecimal?: boolean | undefined;
1663
- }, {
1664
- type: "numeric-keypad";
1665
- includeOperators?: boolean | undefined;
1666
- includeDecimal?: boolean | undefined;
1667
- }>;
1668
-
1669
- export declare type NumericKeypadTool = z.infer<typeof NumericKeypadToolSchema>;
1670
-
1671
- /**
1672
- * Numeric keypad tool schema - on-screen number pad
1673
- *
1674
- * Use cases:
1675
- * - Touch-friendly number entry
1676
- * - Restricting input to numbers only
1677
- * - Consistent cross-device experience
1678
- *
1679
- * @example
1680
- * {
1681
- * type: "NumericKeypad",
1682
- * includeOperators: true
1683
- * }
1684
- */
1685
- export declare const NumericKeypadToolSchema: z.ZodObject<{
1686
- type: z.ZodLiteral<"NumericKeypad">;
1687
- includeOperators: z.ZodOptional<z.ZodBoolean>;
1688
- includeDecimal: z.ZodOptional<z.ZodBoolean>;
1689
- }, "strip", z.ZodTypeAny, {
1690
- type: "NumericKeypad";
1691
- includeOperators?: boolean | undefined;
1692
- includeDecimal?: boolean | undefined;
1693
- }, {
1694
- type: "NumericKeypad";
1695
- includeOperators?: boolean | undefined;
1696
- includeDecimal?: boolean | undefined;
1697
- }>;
1698
-
1699
- export declare type OperatorItem = z.infer<typeof OperatorItemSchema>;
3467
+ export declare type TableItem = z.infer<typeof TableItemSchema>;
1700
3468
 
1701
- export declare const OperatorItemSchema: z.ZodObject<{
3469
+ export declare const TableItemSchema: z.ZodObject<{
1702
3470
  id: z.ZodString;
1703
- type: z.ZodLiteral<"operator">;
1704
- operator: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
3471
+ type: z.ZodLiteral<"table">;
3472
+ cols: z.ZodNumber;
3473
+ rows: z.ZodArray<z.ZodObject<{
3474
+ id: z.ZodString;
3475
+ type: z.ZodLiteral<"table-row">;
3476
+ cells: z.ZodArray<z.ZodObject<{
3477
+ id: z.ZodString;
3478
+ type: z.ZodLiteral<"table-cell">;
3479
+ colspan: z.ZodOptional<z.ZodNumber>;
3480
+ items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
3481
+ }, "strip", z.ZodTypeAny, {
3482
+ type: "table-cell";
3483
+ id: string;
3484
+ items: any[];
3485
+ colspan?: number | undefined;
3486
+ }, {
3487
+ type: "table-cell";
3488
+ id: string;
3489
+ items: any[];
3490
+ colspan?: number | undefined;
3491
+ }>, "many">;
3492
+ }, "strip", z.ZodTypeAny, {
3493
+ type: "table-row";
3494
+ cells: {
3495
+ type: "table-cell";
3496
+ id: string;
3497
+ items: any[];
3498
+ colspan?: number | undefined;
3499
+ }[];
3500
+ id: string;
3501
+ }, {
3502
+ type: "table-row";
3503
+ cells: {
3504
+ type: "table-cell";
3505
+ id: string;
3506
+ items: any[];
3507
+ colspan?: number | undefined;
3508
+ }[];
3509
+ id: string;
3510
+ }>, "many">;
1705
3511
  }, "strip", z.ZodTypeAny, {
1706
- operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1707
- type: "operator";
3512
+ type: "table";
3513
+ cols: number;
3514
+ rows: {
3515
+ type: "table-row";
3516
+ cells: {
3517
+ type: "table-cell";
3518
+ id: string;
3519
+ items: any[];
3520
+ colspan?: number | undefined;
3521
+ }[];
3522
+ id: string;
3523
+ }[];
1708
3524
  id: string;
1709
3525
  }, {
1710
- operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1711
- type: "operator";
3526
+ type: "table";
3527
+ cols: number;
3528
+ rows: {
3529
+ type: "table-row";
3530
+ cells: {
3531
+ type: "table-cell";
3532
+ id: string;
3533
+ items: any[];
3534
+ colspan?: number | undefined;
3535
+ }[];
3536
+ id: string;
3537
+ }[];
1712
3538
  id: string;
1713
3539
  }>;
1714
3540
 
1715
- export declare const OperatorSchema: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
1716
-
1717
- /**
1718
- * Parse DSL tokens into CST
1719
- */
1720
- export declare function parse(tokens: IToken[]): CstNode;
1721
-
1722
- /**
1723
- * Error thrown when parser fails to parse tokens
1724
- */
1725
- export declare class ParseError extends EngineError {
1726
- readonly parseErrors: IRecognitionException[];
1727
- readonly positions: SourcePosition[];
1728
- constructor(errors: IRecognitionException[]);
1729
- }
1730
-
1731
- /**
1732
- * Parse DSL tokens into CST (safe version - returns errors instead of throwing)
1733
- */
1734
- export declare function parseSafe(tokens: IToken[]): {
1735
- success: true;
1736
- cst: CstNode;
1737
- error?: undefined;
1738
- } | {
1739
- success: false;
1740
- error: unknown;
1741
- cst?: undefined;
1742
- };
3541
+ export declare type TableRow = z.infer<typeof TableRowSchema>;
1743
3542
 
1744
- export declare type QuestionText = z.infer<typeof QuestionTextSchema>;
3543
+ export declare type TableRowItem = z.infer<typeof TableRowItemSchema>;
1745
3544
 
1746
- export declare const QuestionTextSchema: z.ZodObject<{
3545
+ export declare const TableRowItemSchema: z.ZodObject<{
1747
3546
  id: z.ZodString;
1748
- type: z.ZodLiteral<"question-text">;
1749
- value: z.ZodString;
1750
- }, "strip", z.ZodTypeAny, {
1751
- value: string;
1752
- type: "question-text";
1753
- id: string;
1754
- }, {
1755
- value: string;
1756
- type: "question-text";
1757
- id: string;
1758
- }>;
1759
-
1760
- /**
1761
- * DOM helper for quick usage / demos.
1762
- *
1763
- * This couples the engine to DOM + React root creation.
1764
- * For production use, prefer <ExerciseRenderer /> directly in your React tree.
1765
- *
1766
- * @example
1767
- * ```typescript
1768
- * import { compile, renderExercise } from 'math-exercise-engine';
1769
- *
1770
- * const json = compile(dsl);
1771
- * const unmount = renderExercise({
1772
- * container: '#app',
1773
- * json,
1774
- * onSubmit: (values) => {
1775
- * // Parent decides correctness
1776
- * const result = validate(json, values);
1777
- * console.log(result.isCorrect);
1778
- * }
1779
- * });
1780
- *
1781
- * // Later: unmount()
1782
- * ```
1783
- */
1784
- export declare function renderExercise(options: RenderOptions): () => void;
1785
-
1786
- export declare interface RenderOptions {
1787
- container: HTMLElement | string;
1788
- json: ExerciseJSON;
1789
- onSubmit?: (values: Record<string, string>) => void;
1790
- onChange?: (values: Record<string, string>) => void;
1791
- showSubmitButton?: boolean;
1792
- className?: string;
1793
- }
1794
-
1795
- export declare type SimpleValidation = z.infer<typeof SimpleValidationSchema>;
1796
-
1797
- /**
1798
- * Simple validation schema - direct answer matching
1799
- *
1800
- * Each input has a predetermined correct answer.
1801
- * No complex expressions or calculations.
1802
- *
1803
- * @example
1804
- * {
1805
- * type: "SimpleValidation"
1806
- * }
1807
- *
1808
- * Note: Actual answer values are stored separately (in widget definitions)
1809
- */
1810
- export declare const SimpleValidationSchema: z.ZodObject<{
1811
- type: z.ZodLiteral<"SimpleValidation">;
3547
+ type: z.ZodLiteral<"table-row">;
3548
+ cells: z.ZodArray<z.ZodObject<{
3549
+ id: z.ZodString;
3550
+ type: z.ZodLiteral<"table-cell">;
3551
+ colspan: z.ZodOptional<z.ZodNumber>;
3552
+ items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
3553
+ }, "strip", z.ZodTypeAny, {
3554
+ type: "table-cell";
3555
+ id: string;
3556
+ items: any[];
3557
+ colspan?: number | undefined;
3558
+ }, {
3559
+ type: "table-cell";
3560
+ id: string;
3561
+ items: any[];
3562
+ colspan?: number | undefined;
3563
+ }>, "many">;
1812
3564
  }, "strip", z.ZodTypeAny, {
1813
- type: "SimpleValidation";
1814
- }, {
1815
- type: "SimpleValidation";
1816
- }>;
1817
-
1818
- /**
1819
- * Source position information for error reporting
1820
- */
1821
- export declare interface SourcePosition {
1822
- startLine: number;
1823
- startColumn: number;
1824
- endLine: number;
1825
- endColumn: number;
1826
- }
1827
-
1828
- export declare type SpaceInline = z.infer<typeof SpaceInlineSchema>;
3565
+ type: "table-row";
3566
+ cells: {
3567
+ type: "table-cell";
3568
+ id: string;
3569
+ items: any[];
3570
+ colspan?: number | undefined;
3571
+ }[];
3572
+ id: string;
3573
+ }, {
3574
+ type: "table-row";
3575
+ cells: {
3576
+ type: "table-cell";
3577
+ id: string;
3578
+ items: any[];
3579
+ colspan?: number | undefined;
3580
+ }[];
3581
+ id: string;
3582
+ }>;
1829
3583
 
1830
- /**
1831
- * Space inline schema - explicit spacing element
1832
- *
1833
- * Represents one or more consecutive spaces as a single space element.
1834
- * This allows for deterministic and explicit control over spacing in the layout.
1835
- *
1836
- * @example
1837
- * { type: "Space" }
1838
- */
1839
- export declare const SpaceInlineSchema: z.ZodObject<{
1840
- type: z.ZodLiteral<"Space">;
3584
+ declare const TableRowSchema: z.ZodObject<{
3585
+ type: z.ZodLiteral<"TableRow">;
3586
+ cells: z.ZodArray<z.ZodObject<{
3587
+ type: z.ZodLiteral<"TableCell">;
3588
+ colspan: z.ZodOptional<z.ZodNumber>;
3589
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
3590
+ type: z.ZodLiteral<"FreeText">;
3591
+ value: z.ZodString;
3592
+ }, "strip", z.ZodTypeAny, {
3593
+ value: string;
3594
+ type: "FreeText";
3595
+ }, {
3596
+ value: string;
3597
+ type: "FreeText";
3598
+ }>, z.ZodObject<{
3599
+ type: z.ZodLiteral<"Space">;
3600
+ }, "strip", z.ZodTypeAny, {
3601
+ type: "Space";
3602
+ }, {
3603
+ type: "Space";
3604
+ }>, z.ZodObject<{
3605
+ type: z.ZodLiteral<"HighlightedText">;
3606
+ value: z.ZodString;
3607
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3608
+ }, "strip", z.ZodTypeAny, {
3609
+ value: string;
3610
+ type: "HighlightedText";
3611
+ highlight?: [number, number] | undefined;
3612
+ }, {
3613
+ value: string;
3614
+ type: "HighlightedText";
3615
+ highlight?: [number, number] | undefined;
3616
+ }>, z.ZodObject<{
3617
+ type: z.ZodLiteral<"ColorText">;
3618
+ value: z.ZodString;
3619
+ color: z.ZodString;
3620
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3621
+ }, "strip", z.ZodTypeAny, {
3622
+ value: string;
3623
+ type: "ColorText";
3624
+ color: string;
3625
+ highlight?: [number, number] | undefined;
3626
+ }, {
3627
+ value: string;
3628
+ type: "ColorText";
3629
+ color: string;
3630
+ highlight?: [number, number] | undefined;
3631
+ }>, z.ZodObject<{
3632
+ type: z.ZodLiteral<"BoldText">;
3633
+ value: z.ZodString;
3634
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3635
+ }, "strip", z.ZodTypeAny, {
3636
+ value: string;
3637
+ type: "BoldText";
3638
+ highlight?: [number, number] | undefined;
3639
+ }, {
3640
+ value: string;
3641
+ type: "BoldText";
3642
+ highlight?: [number, number] | undefined;
3643
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
3644
+ type: z.ZodLiteral<"InlineInput">;
3645
+ name: z.ZodString;
3646
+ inputType: z.ZodLiteral<"string">;
3647
+ length: z.ZodNumber;
3648
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
3649
+ }, "strip", z.ZodTypeAny, {
3650
+ length: number;
3651
+ type: "InlineInput";
3652
+ inputType: "string";
3653
+ name: string;
3654
+ answer?: string | number | undefined;
3655
+ }, {
3656
+ length: number;
3657
+ type: "InlineInput";
3658
+ inputType: "string";
3659
+ name: string;
3660
+ answer?: string | number | undefined;
3661
+ }>, z.ZodObject<{
3662
+ type: z.ZodLiteral<"InlineInput">;
3663
+ name: z.ZodString;
3664
+ inputType: z.ZodLiteral<"numeric">;
3665
+ digits: z.ZodNumber;
3666
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
3667
+ }, "strip", z.ZodTypeAny, {
3668
+ type: "InlineInput";
3669
+ inputType: "numeric";
3670
+ name: string;
3671
+ digits: number;
3672
+ answer?: string | number | undefined;
3673
+ }, {
3674
+ type: "InlineInput";
3675
+ inputType: "numeric";
3676
+ name: string;
3677
+ digits: number;
3678
+ answer?: string | number | undefined;
3679
+ }>]>]>, "many">;
3680
+ }, "strip", z.ZodTypeAny, {
3681
+ type: "TableCell";
3682
+ inlines: ({
3683
+ value: string;
3684
+ type: "FreeText";
3685
+ } | {
3686
+ type: "Space";
3687
+ } | {
3688
+ value: string;
3689
+ type: "HighlightedText";
3690
+ highlight?: [number, number] | undefined;
3691
+ } | {
3692
+ value: string;
3693
+ type: "ColorText";
3694
+ color: string;
3695
+ highlight?: [number, number] | undefined;
3696
+ } | {
3697
+ value: string;
3698
+ type: "BoldText";
3699
+ highlight?: [number, number] | undefined;
3700
+ } | {
3701
+ length: number;
3702
+ type: "InlineInput";
3703
+ inputType: "string";
3704
+ name: string;
3705
+ answer?: string | number | undefined;
3706
+ } | {
3707
+ type: "InlineInput";
3708
+ inputType: "numeric";
3709
+ name: string;
3710
+ digits: number;
3711
+ answer?: string | number | undefined;
3712
+ })[];
3713
+ colspan?: number | undefined;
3714
+ }, {
3715
+ type: "TableCell";
3716
+ inlines: ({
3717
+ value: string;
3718
+ type: "FreeText";
3719
+ } | {
3720
+ type: "Space";
3721
+ } | {
3722
+ value: string;
3723
+ type: "HighlightedText";
3724
+ highlight?: [number, number] | undefined;
3725
+ } | {
3726
+ value: string;
3727
+ type: "ColorText";
3728
+ color: string;
3729
+ highlight?: [number, number] | undefined;
3730
+ } | {
3731
+ value: string;
3732
+ type: "BoldText";
3733
+ highlight?: [number, number] | undefined;
3734
+ } | {
3735
+ length: number;
3736
+ type: "InlineInput";
3737
+ inputType: "string";
3738
+ name: string;
3739
+ answer?: string | number | undefined;
3740
+ } | {
3741
+ type: "InlineInput";
3742
+ inputType: "numeric";
3743
+ name: string;
3744
+ digits: number;
3745
+ answer?: string | number | undefined;
3746
+ })[];
3747
+ colspan?: number | undefined;
3748
+ }>, "many">;
1841
3749
  }, "strip", z.ZodTypeAny, {
1842
- type: "Space";
3750
+ type: "TableRow";
3751
+ cells: {
3752
+ type: "TableCell";
3753
+ inlines: ({
3754
+ value: string;
3755
+ type: "FreeText";
3756
+ } | {
3757
+ type: "Space";
3758
+ } | {
3759
+ value: string;
3760
+ type: "HighlightedText";
3761
+ highlight?: [number, number] | undefined;
3762
+ } | {
3763
+ value: string;
3764
+ type: "ColorText";
3765
+ color: string;
3766
+ highlight?: [number, number] | undefined;
3767
+ } | {
3768
+ value: string;
3769
+ type: "BoldText";
3770
+ highlight?: [number, number] | undefined;
3771
+ } | {
3772
+ length: number;
3773
+ type: "InlineInput";
3774
+ inputType: "string";
3775
+ name: string;
3776
+ answer?: string | number | undefined;
3777
+ } | {
3778
+ type: "InlineInput";
3779
+ inputType: "numeric";
3780
+ name: string;
3781
+ digits: number;
3782
+ answer?: string | number | undefined;
3783
+ })[];
3784
+ colspan?: number | undefined;
3785
+ }[];
1843
3786
  }, {
1844
- type: "Space";
3787
+ type: "TableRow";
3788
+ cells: {
3789
+ type: "TableCell";
3790
+ inlines: ({
3791
+ value: string;
3792
+ type: "FreeText";
3793
+ } | {
3794
+ type: "Space";
3795
+ } | {
3796
+ value: string;
3797
+ type: "HighlightedText";
3798
+ highlight?: [number, number] | undefined;
3799
+ } | {
3800
+ value: string;
3801
+ type: "ColorText";
3802
+ color: string;
3803
+ highlight?: [number, number] | undefined;
3804
+ } | {
3805
+ value: string;
3806
+ type: "BoldText";
3807
+ highlight?: [number, number] | undefined;
3808
+ } | {
3809
+ length: number;
3810
+ type: "InlineInput";
3811
+ inputType: "string";
3812
+ name: string;
3813
+ answer?: string | number | undefined;
3814
+ } | {
3815
+ type: "InlineInput";
3816
+ inputType: "numeric";
3817
+ name: string;
3818
+ digits: number;
3819
+ answer?: string | number | undefined;
3820
+ })[];
3821
+ colspan?: number | undefined;
3822
+ }[];
1845
3823
  }>;
1846
3824
 
1847
3825
  export declare type TextBlock = z.infer<typeof TextBlockSchema>;
@@ -1885,7 +3863,7 @@ export declare const TextItemSchema: z.ZodObject<{
1885
3863
  /**
1886
3864
  * Transform CST to AST
1887
3865
  */
1888
- export declare function toAST(cst: any): ExerciseDocument;
3866
+ export declare function toAST(cst: CstNode): ExerciseDocument;
1889
3867
 
1890
3868
  /**
1891
3869
  * Transform AST to JSON
@@ -2020,6 +3998,9 @@ export declare function validateExerciseJSON(data: unknown): {
2020
3998
  } | {
2021
3999
  type: "drag-options";
2022
4000
  options: string[];
4001
+ } | {
4002
+ type: "radio-options";
4003
+ options: string[];
2023
4004
  } | {
2024
4005
  type: "numeric-keypad";
2025
4006
  includeOperators?: boolean | undefined;
@@ -2070,6 +4051,9 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
2070
4051
  } | {
2071
4052
  type: "drag-options";
2072
4053
  options: string[];
4054
+ } | {
4055
+ type: "radio-options";
4056
+ options: string[];
2073
4057
  } | {
2074
4058
  type: "numeric-keypad";
2075
4059
  includeOperators?: boolean | undefined;
@@ -2102,6 +4086,9 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
2102
4086
  } | {
2103
4087
  type: "drag-options";
2104
4088
  options: string[];
4089
+ } | {
4090
+ type: "radio-options";
4091
+ options: string[];
2105
4092
  } | {
2106
4093
  type: "numeric-keypad";
2107
4094
  includeOperators?: boolean | undefined;
@@ -2162,6 +4149,9 @@ export declare function validateWidgetJSON(data: unknown): {
2162
4149
  } | {
2163
4150
  type: "drag-options";
2164
4151
  options: string[];
4152
+ } | {
4153
+ type: "radio-options";
4154
+ options: string[];
2165
4155
  } | {
2166
4156
  type: "numeric-keypad";
2167
4157
  includeOperators?: boolean | undefined;
@@ -2185,6 +4175,9 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
2185
4175
  } | {
2186
4176
  type: "drag-options";
2187
4177
  options: string[];
4178
+ } | {
4179
+ type: "radio-options";
4180
+ options: string[];
2188
4181
  } | {
2189
4182
  type: "numeric-keypad";
2190
4183
  includeOperators?: boolean | undefined;
@@ -2200,6 +4193,9 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
2200
4193
  } | {
2201
4194
  type: "drag-options";
2202
4195
  options: string[];
4196
+ } | {
4197
+ type: "radio-options";
4198
+ options: string[];
2203
4199
  } | {
2204
4200
  type: "numeric-keypad";
2205
4201
  includeOperators?: boolean | undefined;
@@ -2308,6 +4304,15 @@ export declare const WidgetJSONSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"inpu
2308
4304
  }, {
2309
4305
  type: "drag-options";
2310
4306
  options: string[];
4307
+ }>, z.ZodObject<{
4308
+ type: z.ZodLiteral<"radio-options">;
4309
+ options: z.ZodArray<z.ZodString, "many">;
4310
+ }, "strip", z.ZodTypeAny, {
4311
+ type: "radio-options";
4312
+ options: string[];
4313
+ }, {
4314
+ type: "radio-options";
4315
+ options: string[];
2311
4316
  }>, z.ZodObject<{
2312
4317
  type: z.ZodLiteral<"numeric-keypad">;
2313
4318
  includeOperators: z.ZodOptional<z.ZodBoolean>;
@@ -2350,7 +4355,7 @@ export declare interface WidgetRendererProps {
2350
4355
  widgetId: string;
2351
4356
  value: string;
2352
4357
  isDropped?: boolean;
2353
- onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
4358
+ onChange: (widgetId: string, value: string, fromDrop?: boolean, sourceOptionId?: string) => void;
2354
4359
  onInputFocus?: (widgetId: string) => void;
2355
4360
  onKeypadChange?: (value: string) => void;
2356
4361
  }