@almadar/cli 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (607) hide show
  1. package/bin/almadar +32 -1
  2. package/package.json +8 -6
  3. package/scripts/postinstall.js +41 -0
  4. package/shells/python-shell/.dockerignore +50 -0
  5. package/shells/python-shell/.env.example +55 -0
  6. package/shells/python-shell/Dockerfile +56 -0
  7. package/shells/python-shell/README.md +253 -0
  8. package/shells/python-shell/cloudbuild.yaml +76 -0
  9. package/shells/python-shell/docker-compose.yaml +57 -0
  10. package/shells/python-shell/pyproject.toml +28 -0
  11. package/shells/python-shell/scripts/deploy.sh +108 -0
  12. package/shells/python-shell/scripts/setup-secrets.sh +104 -0
  13. package/shells/python-shell/src/orbital_app/__init__.py +8 -0
  14. package/shells/python-shell/src/orbital_app/core/__init__.py +40 -0
  15. package/shells/python-shell/src/orbital_app/core/bindings.py +75 -0
  16. package/shells/python-shell/src/orbital_app/core/effect_executor.py +196 -0
  17. package/shells/python-shell/src/orbital_app/core/event_bus.py +119 -0
  18. package/shells/python-shell/src/orbital_app/core/event_router.py +38 -0
  19. package/shells/python-shell/src/orbital_app/core/firebase.py +112 -0
  20. package/shells/python-shell/src/orbital_app/core/repository.py +257 -0
  21. package/shells/python-shell/src/orbital_app/core/settings.py +74 -0
  22. package/shells/python-shell/src/orbital_app/core/websocket.py +202 -0
  23. package/shells/python-shell/src/orbital_app/main.py +108 -0
  24. package/shells/python-shell/src/orbital_app/middleware/__init__.py +18 -0
  25. package/shells/python-shell/src/orbital_app/middleware/auth.py +126 -0
  26. package/shells/python-shell/src/orbital_app/nn/__init__.py +28 -0
  27. package/shells/python-shell/src/orbital_app/nn/constraints.py +104 -0
  28. package/shells/python-shell/src/orbital_app/nn/forward.py +34 -0
  29. package/shells/python-shell/src/orbital_app/nn/training.py +101 -0
  30. package/shells/python-shell/src/orbital_app/tensor/__init__.py +46 -0
  31. package/shells/python-shell/src/orbital_app/tensor/contracts.py +112 -0
  32. package/shells/python-shell/src/orbital_app/tensor/ops.py +196 -0
  33. package/shells/python-shell/tests/conftest.py +63 -0
  34. package/shells/python-shell/tests/test_effect_executor.py +197 -0
  35. package/shells/python-shell/tests/test_event_bus.py +194 -0
  36. package/shells/python-shell/tests/test_generated_traits.py +268 -0
  37. package/shells/python-shell/tests/test_integration.py +347 -0
  38. package/shells/python-shell/tests/test_nn_builder.py +113 -0
  39. package/shells/python-shell/tests/test_nn_constraints.py +187 -0
  40. package/shells/python-shell/tests/test_nn_forward.py +98 -0
  41. package/shells/python-shell/tests/test_nn_training.py +130 -0
  42. package/shells/python-shell/tests/test_repository.py +151 -0
  43. package/shells/python-shell/tests/test_tensor_contracts.py +168 -0
  44. package/shells/python-shell/tests/test_tensor_ops.py +260 -0
  45. package/shells/typescript-shell/.env.example +30 -0
  46. package/shells/typescript-shell/.firebaserc.template +14 -0
  47. package/shells/typescript-shell/.prettierrc +7 -0
  48. package/shells/typescript-shell/Dockerfile +0 -0
  49. package/shells/typescript-shell/apphosting.yaml.template +0 -0
  50. package/shells/typescript-shell/firebase.json.template +0 -0
  51. package/shells/typescript-shell/firestore.indexes.json +4 -0
  52. package/shells/typescript-shell/firestore.rules.template +0 -0
  53. package/shells/typescript-shell/infra/aws/alb.tf +0 -0
  54. package/shells/typescript-shell/infra/aws/cloudfront.tf +0 -0
  55. package/shells/typescript-shell/infra/aws/ecs.tf +0 -0
  56. package/shells/typescript-shell/infra/aws/main.tf +0 -0
  57. package/shells/typescript-shell/infra/aws/rds.tf +0 -0
  58. package/shells/typescript-shell/infra/docker/Dockerfile.client +0 -0
  59. package/shells/typescript-shell/infra/docker/Dockerfile.server +0 -0
  60. package/shells/typescript-shell/infra/docker/docker-compose.prod.yml +45 -0
  61. package/shells/typescript-shell/infra/docker/docker-compose.yml +57 -0
  62. package/shells/typescript-shell/infra/docker/nginx.conf +0 -0
  63. package/shells/typescript-shell/infra/main.tf +0 -0
  64. package/shells/typescript-shell/infra/terraform/aws/alb.tf +0 -0
  65. package/shells/typescript-shell/infra/terraform/aws/cloudfront.tf +0 -0
  66. package/shells/typescript-shell/infra/terraform/aws/ecs.tf +0 -0
  67. package/shells/typescript-shell/infra/terraform/aws/main.tf +0 -0
  68. package/shells/typescript-shell/infra/terraform/aws/rds.tf +0 -0
  69. package/shells/typescript-shell/infra/terraform/main.tf +0 -0
  70. package/shells/typescript-shell/infra/terraform/variables.tf +0 -0
  71. package/shells/typescript-shell/infra/variables.tf +0 -0
  72. package/shells/typescript-shell/package-lock.json +15210 -0
  73. package/shells/typescript-shell/package.json +64 -0
  74. package/shells/typescript-shell/packages/client/.env.example +30 -0
  75. package/shells/typescript-shell/packages/client/index.html +13 -0
  76. package/shells/typescript-shell/packages/client/package.json +52 -0
  77. package/shells/typescript-shell/packages/client/postcss.config.js +6 -0
  78. package/shells/typescript-shell/packages/client/src/App.tsx +56 -0
  79. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/CreditExpirationAlert.stories.tsx +75 -0
  80. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/CreditExpirationAlert.tsx +157 -0
  81. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/CreditMeter.stories.tsx +155 -0
  82. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/CreditMeter.tsx +370 -0
  83. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/ExerciseVideoLink.stories.tsx +50 -0
  84. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/ExerciseVideoLink.tsx +143 -0
  85. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/ShareableLinkGenerator.stories.tsx +54 -0
  86. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/ShareableLinkGenerator.tsx +210 -0
  87. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/atoms/index.ts +4 -0
  88. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/index.ts +83 -0
  89. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/BodyMeasurementInput.stories.tsx +117 -0
  90. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/BodyMeasurementInput.tsx +343 -0
  91. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/DailyProgressInput.stories.tsx +82 -0
  92. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/DailyProgressInput.tsx +345 -0
  93. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/GroupSessionCard.stories.tsx +155 -0
  94. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/GroupSessionCard.tsx +319 -0
  95. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/LiftTracker.stories.tsx +110 -0
  96. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/LiftTracker.tsx +395 -0
  97. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/MealPlanCard.stories.tsx +132 -0
  98. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/MealPlanCard.tsx +394 -0
  99. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/NutritionSummary.stories.tsx +127 -0
  100. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/NutritionSummary.tsx +360 -0
  101. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/ProgressChart.stories.tsx +119 -0
  102. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/ProgressChart.tsx +377 -0
  103. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/SpecialExerciseCard.stories.tsx +115 -0
  104. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/SpecialExerciseCard.tsx +294 -0
  105. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/TraineeCard.stories.tsx +139 -0
  106. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/TraineeCard.tsx +306 -0
  107. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/WorkoutPlanCard.stories.tsx +140 -0
  108. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/WorkoutPlanCard.tsx +379 -0
  109. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/molecules/index.ts +10 -0
  110. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/AIAnalysisPanel.stories.tsx +171 -0
  111. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/AIAnalysisPanel.tsx +257 -0
  112. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/KinesiologyExamForm.stories.tsx +157 -0
  113. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/KinesiologyExamForm.tsx +383 -0
  114. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/SessionScheduler.stories.tsx +249 -0
  115. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/SessionScheduler.tsx +637 -0
  116. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/TraineeComparison.stories.tsx +221 -0
  117. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/TraineeComparison.tsx +438 -0
  118. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/WeeklyCalendar.stories.tsx +208 -0
  119. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/WeeklyCalendar.tsx +380 -0
  120. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/organisms/index.ts +5 -0
  121. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/CreditsTemplate.stories.tsx +243 -0
  122. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/CreditsTemplate.tsx +496 -0
  123. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/FitnessTemplate.stories.tsx +237 -0
  124. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/FitnessTemplate.tsx +457 -0
  125. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/MealPlanDetailTemplate.stories.tsx +184 -0
  126. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/MealPlanDetailTemplate.tsx +414 -0
  127. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/MealPlansTemplate.stories.tsx +198 -0
  128. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/MealPlansTemplate.tsx +296 -0
  129. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/ProgressTemplate.stories.tsx +242 -0
  130. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/ProgressTemplate.tsx +497 -0
  131. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/ScheduleTemplate.stories.tsx +267 -0
  132. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/ScheduleTemplate.tsx +424 -0
  133. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/SessionDetailTemplate.stories.tsx +214 -0
  134. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/SessionDetailTemplate.tsx +518 -0
  135. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/SessionsTemplate.stories.tsx +207 -0
  136. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/SessionsTemplate.tsx +508 -0
  137. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/TraineeDetailTemplate.stories.tsx +178 -0
  138. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/TraineeDetailTemplate.tsx +396 -0
  139. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/TraineesTemplate.stories.tsx +168 -0
  140. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/TraineesTemplate.tsx +429 -0
  141. package/shells/typescript-shell/packages/client/src/clients/blaz-kelemnc/templates/index.ts +44 -0
  142. package/shells/typescript-shell/packages/client/src/clients/inspection-system/atoms/LawReferenceBadge.stories.tsx +78 -0
  143. package/shells/typescript-shell/packages/client/src/clients/inspection-system/atoms/LawReferenceBadge.tsx +87 -0
  144. package/shells/typescript-shell/packages/client/src/clients/inspection-system/atoms/PhaseIndicator.stories.tsx +91 -0
  145. package/shells/typescript-shell/packages/client/src/clients/inspection-system/atoms/PhaseIndicator.tsx +142 -0
  146. package/shells/typescript-shell/packages/client/src/clients/inspection-system/atoms/index.ts +8 -0
  147. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/index.ts +79 -0
  148. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-001-uvod.json +361 -0
  149. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-001-uvod.ts +361 -0
  150. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-002-podjetje.json +115 -0
  151. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-002-podjetje.ts +115 -0
  152. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-003-udelezenci.json +78 -0
  153. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-003-udelezenci.ts +78 -0
  154. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-004-izbira-podrocja.json +85 -0
  155. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-004-izbira-podrocja.ts +94 -0
  156. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-005-trgovina.json +1056 -0
  157. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-005-trgovina.ts +1056 -0
  158. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-006-ugotovitve.json +128 -0
  159. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-006-ugotovitve.ts +128 -0
  160. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-007-odlocbe.json +136 -0
  161. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-007-odlocbe.ts +136 -0
  162. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-008-pripombe.json +148 -0
  163. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-008-pripombe.ts +148 -0
  164. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-009-zakljucek.json +207 -0
  165. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T-009-zakljucek.ts +207 -0
  166. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T2-1-oznacevanje-cen.json +1265 -0
  167. package/shells/typescript-shell/packages/client/src/clients/inspection-system/configs/tabs/T2-1-oznacevanje-cen.ts +1265 -0
  168. package/shells/typescript-shell/packages/client/src/clients/inspection-system/index.ts +137 -0
  169. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/CardSelector.stories.tsx +128 -0
  170. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/CardSelector.tsx +174 -0
  171. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/ComplianceSummary.stories.tsx +115 -0
  172. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/ComplianceSummary.tsx +263 -0
  173. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/ConditionalField.tsx +254 -0
  174. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/DocumentPreview.tsx +249 -0
  175. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/EntitySearch.tsx +290 -0
  176. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/InspectionTimeline.stories.tsx +138 -0
  177. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/InspectionTimeline.tsx +253 -0
  178. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/ObjectionRecorder.tsx +213 -0
  179. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/ParticipantList.stories.tsx +86 -0
  180. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/ParticipantList.tsx +227 -0
  181. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/PhotoAttachment.tsx +276 -0
  182. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/ProgressHeader.stories.tsx +89 -0
  183. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/ProgressHeader.tsx +157 -0
  184. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/RepeatableFormSection.tsx +189 -0
  185. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/RuleCheckItem.stories.tsx +118 -0
  186. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/RuleCheckItem.tsx +237 -0
  187. package/shells/typescript-shell/packages/client/src/clients/inspection-system/molecules/index.ts +18 -0
  188. package/shells/typescript-shell/packages/client/src/clients/inspection-system/organisms/FloatingActionMenu.stories.tsx +75 -0
  189. package/shells/typescript-shell/packages/client/src/clients/inspection-system/organisms/FloatingActionMenu.tsx +197 -0
  190. package/shells/typescript-shell/packages/client/src/clients/inspection-system/organisms/SignatureCapture.stories.tsx +96 -0
  191. package/shells/typescript-shell/packages/client/src/clients/inspection-system/organisms/SignatureCapture.tsx +278 -0
  192. package/shells/typescript-shell/packages/client/src/clients/inspection-system/organisms/index.ts +8 -0
  193. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/CompaniesTemplate.stories.tsx +107 -0
  194. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/CompaniesTemplate.tsx +266 -0
  195. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectionFormDemoTemplate.stories.tsx +607 -0
  196. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectionFormDemoTemplate.tsx +1428 -0
  197. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectionProcessTemplate.stories.tsx +713 -0
  198. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectionProcessTemplate.tsx +1582 -0
  199. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectionWizardTemplate.stories.tsx +174 -0
  200. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectionWizardTemplate.tsx +264 -0
  201. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectionsTemplate.stories.tsx +129 -0
  202. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectionsTemplate.tsx +287 -0
  203. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectorsTemplate.stories.tsx +94 -0
  204. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/InspectorsTemplate.tsx +255 -0
  205. package/shells/typescript-shell/packages/client/src/clients/inspection-system/templates/index.ts +47 -0
  206. package/shells/typescript-shell/packages/client/src/clients/kflow/atoms/MindMapConnections.stories.tsx +82 -0
  207. package/shells/typescript-shell/packages/client/src/clients/kflow/atoms/MindMapConnections.tsx +75 -0
  208. package/shells/typescript-shell/packages/client/src/clients/kflow/atoms/index.ts +2 -0
  209. package/shells/typescript-shell/packages/client/src/clients/kflow/index.ts +96 -0
  210. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/ConceptMetaTags.stories.tsx +64 -0
  211. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/ConceptMetaTags.tsx +77 -0
  212. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/GraphLegend.stories.tsx +100 -0
  213. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/GraphLegend.tsx +120 -0
  214. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/LayerNavigator.stories.tsx +109 -0
  215. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/LayerNavigator.tsx +157 -0
  216. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/LearningGoalDisplay.stories.tsx +62 -0
  217. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/LearningGoalDisplay.tsx +138 -0
  218. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/MindMapHeader.tsx +47 -0
  219. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/MindMapNode.stories.tsx +212 -0
  220. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/MindMapNode.tsx +294 -0
  221. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/NoteContent.stories.tsx +98 -0
  222. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/NoteContent.tsx +163 -0
  223. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/NoteListItem.stories.tsx +196 -0
  224. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/NoteListItem.tsx +239 -0
  225. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/QuizBlock.tsx +3 -0
  226. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/StreamingDisplay.stories.tsx +132 -0
  227. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/StreamingDisplay.tsx +232 -0
  228. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/index.ts +28 -0
  229. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/ActivationBlock.stories.tsx +71 -0
  230. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/ActivationBlock.tsx +127 -0
  231. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/BloomQuizBlock.stories.tsx +154 -0
  232. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/BloomQuizBlock.tsx +232 -0
  233. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/ConnectionBlock.stories.tsx +57 -0
  234. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/ConnectionBlock.tsx +60 -0
  235. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/QuizBlock.tsx +138 -0
  236. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/ReflectionBlock.stories.tsx +90 -0
  237. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/ReflectionBlock.tsx +151 -0
  238. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/learning/index.ts +14 -0
  239. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/markdown/CodeBlock.stories.tsx +188 -0
  240. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/markdown/CodeBlock.tsx +165 -0
  241. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/markdown/MarkdownContent.stories.tsx +160 -0
  242. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/markdown/MarkdownContent.tsx +131 -0
  243. package/shells/typescript-shell/packages/client/src/clients/kflow/molecules/markdown/index.ts +5 -0
  244. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/ConceptCard.stories.tsx +155 -0
  245. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/ConceptCard.tsx +301 -0
  246. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/FlashCard.stories.tsx +105 -0
  247. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/FlashCard.tsx +200 -0
  248. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/FlashCardStack.stories.tsx +97 -0
  249. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/FlashCardStack.tsx +163 -0
  250. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/FlashCardsDisplay.tsx +236 -0
  251. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/ForceDirectedGraph.stories.tsx +230 -0
  252. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/ForceDirectedGraph.tsx +488 -0
  253. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/MindMapCanvas.stories.tsx +256 -0
  254. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/MindMapCanvas.tsx +185 -0
  255. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/NoteList.stories.tsx +178 -0
  256. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/NoteList.tsx +209 -0
  257. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/SegmentRenderer.stories.tsx +238 -0
  258. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/SegmentRenderer.tsx +196 -0
  259. package/shells/typescript-shell/packages/client/src/clients/kflow/organisms/index.ts +18 -0
  260. package/shells/typescript-shell/packages/client/src/clients/kflow/patterns/component-mapping.json +122 -0
  261. package/shells/typescript-shell/packages/client/src/clients/kflow/patterns/event-contracts.json +145 -0
  262. package/shells/typescript-shell/packages/client/src/clients/kflow/patterns/index.ts +46 -0
  263. package/shells/typescript-shell/packages/client/src/clients/kflow/templates/ConceptDetailTemplate.stories.tsx +148 -0
  264. package/shells/typescript-shell/packages/client/src/clients/kflow/templates/ConceptDetailTemplate.tsx +266 -0
  265. package/shells/typescript-shell/packages/client/src/clients/kflow/templates/KnowledgeGraphTemplate.stories.tsx +215 -0
  266. package/shells/typescript-shell/packages/client/src/clients/kflow/templates/KnowledgeGraphTemplate.tsx +302 -0
  267. package/shells/typescript-shell/packages/client/src/clients/kflow/templates/LessonTemplate.stories.tsx +161 -0
  268. package/shells/typescript-shell/packages/client/src/clients/kflow/templates/LessonTemplate.tsx +264 -0
  269. package/shells/typescript-shell/packages/client/src/clients/kflow/templates/index.ts +4 -0
  270. package/shells/typescript-shell/packages/client/src/clients/kflow/types/index.ts +9 -0
  271. package/shells/typescript-shell/packages/client/src/clients/kflow/types/mindMapTypes.ts +13 -0
  272. package/shells/typescript-shell/packages/client/src/clients/kflow/utils/index.ts +6 -0
  273. package/shells/typescript-shell/packages/client/src/clients/kflow/utils/parseLessonSegments.ts +191 -0
  274. package/shells/typescript-shell/packages/client/src/clients/winning-11/atoms/CareIndicator.tsx +113 -0
  275. package/shells/typescript-shell/packages/client/src/clients/winning-11/atoms/GrowthMeter.tsx +216 -0
  276. package/shells/typescript-shell/packages/client/src/clients/winning-11/atoms/SeasonIndicator.tsx +140 -0
  277. package/shells/typescript-shell/packages/client/src/clients/winning-11/atoms/TrustMeter.tsx +221 -0
  278. package/shells/typescript-shell/packages/client/src/clients/winning-11/atoms/index.ts +15 -0
  279. package/shells/typescript-shell/packages/client/src/clients/winning-11/index.ts +159 -0
  280. package/shells/typescript-shell/packages/client/src/clients/winning-11/molecules/HarvestCard.tsx +254 -0
  281. package/shells/typescript-shell/packages/client/src/clients/winning-11/molecules/PlantCard.tsx +412 -0
  282. package/shells/typescript-shell/packages/client/src/clients/winning-11/molecules/WeatherWidget.tsx +229 -0
  283. package/shells/typescript-shell/packages/client/src/clients/winning-11/molecules/index.ts +12 -0
  284. package/shells/typescript-shell/packages/client/src/clients/winning-11/organisms/GardenView.tsx +344 -0
  285. package/shells/typescript-shell/packages/client/src/clients/winning-11/organisms/index.ts +6 -0
  286. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/AdminDashboardTemplate.tsx +423 -0
  287. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/AssessmentTemplate.tsx +409 -0
  288. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/ConnectionsTemplate.tsx +465 -0
  289. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/GraphIntelligenceTemplate.tsx +388 -0
  290. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/InvitesTemplate.tsx +359 -0
  291. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/ProjectDetailTemplate.tsx +483 -0
  292. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/ProjectsTemplate.tsx +474 -0
  293. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/RelationshipGardenTemplate.tsx +198 -0
  294. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/SeedNetworkTemplate.tsx +410 -0
  295. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/SuggestionsTemplate.tsx +352 -0
  296. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/TeamDetailTemplate.tsx +494 -0
  297. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/TeamMembersTemplate.tsx +427 -0
  298. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/TeamsTemplate.tsx +424 -0
  299. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/TrustIntelligenceTemplate.tsx +312 -0
  300. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/UserProfileTemplate.tsx +308 -0
  301. package/shells/typescript-shell/packages/client/src/clients/winning-11/templates/UsersTemplate.tsx +303 -0
  302. package/shells/typescript-shell/packages/client/src/components/atoms/Avatar.tsx +226 -0
  303. package/shells/typescript-shell/packages/client/src/components/atoms/Badge.tsx +79 -0
  304. package/shells/typescript-shell/packages/client/src/components/atoms/Box.tsx +262 -0
  305. package/shells/typescript-shell/packages/client/src/components/atoms/Button.tsx +150 -0
  306. package/shells/typescript-shell/packages/client/src/components/atoms/Card.tsx +151 -0
  307. package/shells/typescript-shell/packages/client/src/components/atoms/Center.tsx +67 -0
  308. package/shells/typescript-shell/packages/client/src/components/atoms/Checkbox.tsx +46 -0
  309. package/shells/typescript-shell/packages/client/src/components/atoms/ConditionalWrapper.tsx +139 -0
  310. package/shells/typescript-shell/packages/client/src/components/atoms/Divider.tsx +102 -0
  311. package/shells/typescript-shell/packages/client/src/components/atoms/Icon.tsx +224 -0
  312. package/shells/typescript-shell/packages/client/src/components/atoms/Input.tsx +192 -0
  313. package/shells/typescript-shell/packages/client/src/components/atoms/Label.tsx +26 -0
  314. package/shells/typescript-shell/packages/client/src/components/atoms/LawReferenceTooltip.tsx +190 -0
  315. package/shells/typescript-shell/packages/client/src/components/atoms/Overlay.tsx +37 -0
  316. package/shells/typescript-shell/packages/client/src/components/atoms/ProgressBar.tsx +256 -0
  317. package/shells/typescript-shell/packages/client/src/components/atoms/Radio.tsx +164 -0
  318. package/shells/typescript-shell/packages/client/src/components/atoms/Select.tsx +62 -0
  319. package/shells/typescript-shell/packages/client/src/components/atoms/Spacer.tsx +68 -0
  320. package/shells/typescript-shell/packages/client/src/components/atoms/Spinner.tsx +32 -0
  321. package/shells/typescript-shell/packages/client/src/components/atoms/Stack.tsx +151 -0
  322. package/shells/typescript-shell/packages/client/src/components/atoms/Switch.tsx +91 -0
  323. package/shells/typescript-shell/packages/client/src/components/atoms/TextHighlight.tsx +111 -0
  324. package/shells/typescript-shell/packages/client/src/components/atoms/Textarea.tsx +32 -0
  325. package/shells/typescript-shell/packages/client/src/components/atoms/ThemeSelector.tsx +128 -0
  326. package/shells/typescript-shell/packages/client/src/components/atoms/ThemeToggle.tsx +91 -0
  327. package/shells/typescript-shell/packages/client/src/components/atoms/Typography.tsx +207 -0
  328. package/shells/typescript-shell/packages/client/src/components/atoms/game/ControlButton.tsx +118 -0
  329. package/shells/typescript-shell/packages/client/src/components/atoms/game/HealthBar.tsx +93 -0
  330. package/shells/typescript-shell/packages/client/src/components/atoms/game/ScoreDisplay.tsx +86 -0
  331. package/shells/typescript-shell/packages/client/src/components/atoms/game/Sprite.tsx +188 -0
  332. package/shells/typescript-shell/packages/client/src/components/atoms/game/index.ts +12 -0
  333. package/shells/typescript-shell/packages/client/src/components/atoms/index.ts +88 -0
  334. package/shells/typescript-shell/packages/client/src/components/index.ts +4 -0
  335. package/shells/typescript-shell/packages/client/src/components/molecules/Accordion.tsx +223 -0
  336. package/shells/typescript-shell/packages/client/src/components/molecules/Alert.tsx +117 -0
  337. package/shells/typescript-shell/packages/client/src/components/molecules/Breadcrumb.tsx +159 -0
  338. package/shells/typescript-shell/packages/client/src/components/molecules/ButtonGroup.tsx +226 -0
  339. package/shells/typescript-shell/packages/client/src/components/molecules/Card.tsx +135 -0
  340. package/shells/typescript-shell/packages/client/src/components/molecules/Container.tsx +78 -0
  341. package/shells/typescript-shell/packages/client/src/components/molecules/Drawer.tsx +254 -0
  342. package/shells/typescript-shell/packages/client/src/components/molecules/EmptyState.tsx +132 -0
  343. package/shells/typescript-shell/packages/client/src/components/molecules/ErrorState.tsx +48 -0
  344. package/shells/typescript-shell/packages/client/src/components/molecules/FilterGroup.tsx +529 -0
  345. package/shells/typescript-shell/packages/client/src/components/molecules/Flex.tsx +131 -0
  346. package/shells/typescript-shell/packages/client/src/components/molecules/FloatingActionButton.tsx +264 -0
  347. package/shells/typescript-shell/packages/client/src/components/molecules/FormField.tsx +48 -0
  348. package/shells/typescript-shell/packages/client/src/components/molecules/FormSectionHeader.tsx +139 -0
  349. package/shells/typescript-shell/packages/client/src/components/molecules/Grid.tsx +194 -0
  350. package/shells/typescript-shell/packages/client/src/components/molecules/InputGroup.tsx +109 -0
  351. package/shells/typescript-shell/packages/client/src/components/molecules/LoadingState.tsx +39 -0
  352. package/shells/typescript-shell/packages/client/src/components/molecules/Menu.tsx +266 -0
  353. package/shells/typescript-shell/packages/client/src/components/molecules/Modal.tsx +171 -0
  354. package/shells/typescript-shell/packages/client/src/components/molecules/Pagination.tsx +254 -0
  355. package/shells/typescript-shell/packages/client/src/components/molecules/Popover.tsx +201 -0
  356. package/shells/typescript-shell/packages/client/src/components/molecules/RelationSelect.tsx +328 -0
  357. package/shells/typescript-shell/packages/client/src/components/molecules/RepeatableFormSection.tsx +236 -0
  358. package/shells/typescript-shell/packages/client/src/components/molecules/SearchInput.tsx +196 -0
  359. package/shells/typescript-shell/packages/client/src/components/molecules/SidePanel.tsx +116 -0
  360. package/shells/typescript-shell/packages/client/src/components/molecules/SimpleGrid.tsx +90 -0
  361. package/shells/typescript-shell/packages/client/src/components/molecules/Tabs.tsx +208 -0
  362. package/shells/typescript-shell/packages/client/src/components/molecules/Toast.tsx +154 -0
  363. package/shells/typescript-shell/packages/client/src/components/molecules/Tooltip.tsx +172 -0
  364. package/shells/typescript-shell/packages/client/src/components/molecules/ViolationAlert.tsx +253 -0
  365. package/shells/typescript-shell/packages/client/src/components/molecules/WizardNavigation.tsx +166 -0
  366. package/shells/typescript-shell/packages/client/src/components/molecules/WizardProgress.tsx +140 -0
  367. package/shells/typescript-shell/packages/client/src/components/molecules/game/ActionButtons.tsx +148 -0
  368. package/shells/typescript-shell/packages/client/src/components/molecules/game/DPad.tsx +98 -0
  369. package/shells/typescript-shell/packages/client/src/components/molecules/game/StatBadge.tsx +104 -0
  370. package/shells/typescript-shell/packages/client/src/components/molecules/game/index.ts +11 -0
  371. package/shells/typescript-shell/packages/client/src/components/molecules/index.ts +36 -0
  372. package/shells/typescript-shell/packages/client/src/components/organisms/CardGrid.tsx +479 -0
  373. package/shells/typescript-shell/packages/client/src/components/organisms/ComponentPatterns.tsx +1000 -0
  374. package/shells/typescript-shell/packages/client/src/components/organisms/ConfirmDialog.tsx +165 -0
  375. package/shells/typescript-shell/packages/client/src/components/organisms/CustomPattern.tsx +479 -0
  376. package/shells/typescript-shell/packages/client/src/components/organisms/DataTable.tsx +816 -0
  377. package/shells/typescript-shell/packages/client/src/components/organisms/DetailPanel.tsx +626 -0
  378. package/shells/typescript-shell/packages/client/src/components/organisms/DrawerSlot.tsx +86 -0
  379. package/shells/typescript-shell/packages/client/src/components/organisms/Form.tsx +968 -0
  380. package/shells/typescript-shell/packages/client/src/components/organisms/FormSection.tsx +168 -0
  381. package/shells/typescript-shell/packages/client/src/components/organisms/Header.tsx +263 -0
  382. package/shells/typescript-shell/packages/client/src/components/organisms/LayoutPatterns.tsx +325 -0
  383. package/shells/typescript-shell/packages/client/src/components/organisms/List.tsx +838 -0
  384. package/shells/typescript-shell/packages/client/src/components/organisms/MasterDetail.tsx +85 -0
  385. package/shells/typescript-shell/packages/client/src/components/organisms/ModalSlot.tsx +81 -0
  386. package/shells/typescript-shell/packages/client/src/components/organisms/Navigation.tsx +157 -0
  387. package/shells/typescript-shell/packages/client/src/components/organisms/OrbitalVisualization.tsx +480 -0
  388. package/shells/typescript-shell/packages/client/src/components/organisms/PageHeader.tsx +244 -0
  389. package/shells/typescript-shell/packages/client/src/components/organisms/Section.tsx +131 -0
  390. package/shells/typescript-shell/packages/client/src/components/organisms/Sidebar.tsx +270 -0
  391. package/shells/typescript-shell/packages/client/src/components/organisms/Split.tsx +121 -0
  392. package/shells/typescript-shell/packages/client/src/components/organisms/StatCard.tsx +360 -0
  393. package/shells/typescript-shell/packages/client/src/components/organisms/Table.tsx +394 -0
  394. package/shells/typescript-shell/packages/client/src/components/organisms/ToastSlot.tsx +106 -0
  395. package/shells/typescript-shell/packages/client/src/components/organisms/UISlotRenderer.tsx +647 -0
  396. package/shells/typescript-shell/packages/client/src/components/organisms/WizardContainer.tsx +369 -0
  397. package/shells/typescript-shell/packages/client/src/components/organisms/debug/RuntimeDebugger.css +102 -0
  398. package/shells/typescript-shell/packages/client/src/components/organisms/debug/RuntimeDebugger.tsx +176 -0
  399. package/shells/typescript-shell/packages/client/src/components/organisms/debug/hooks/useDebugData.ts +100 -0
  400. package/shells/typescript-shell/packages/client/src/components/organisms/debug/index.ts +10 -0
  401. package/shells/typescript-shell/packages/client/src/components/organisms/debug/tabs/EntitiesTab.tsx +130 -0
  402. package/shells/typescript-shell/packages/client/src/components/organisms/debug/tabs/EventFlowTab.tsx +135 -0
  403. package/shells/typescript-shell/packages/client/src/components/organisms/debug/tabs/GuardsPanel.tsx +124 -0
  404. package/shells/typescript-shell/packages/client/src/components/organisms/debug/tabs/TicksTab.tsx +100 -0
  405. package/shells/typescript-shell/packages/client/src/components/organisms/debug/tabs/TraitsTab.tsx +102 -0
  406. package/shells/typescript-shell/packages/client/src/components/organisms/game/CollisionDetector.tsx +195 -0
  407. package/shells/typescript-shell/packages/client/src/components/organisms/game/DialogueBox.tsx +279 -0
  408. package/shells/typescript-shell/packages/client/src/components/organisms/game/GameCanvas.tsx +550 -0
  409. package/shells/typescript-shell/packages/client/src/components/organisms/game/GameControls.tsx +173 -0
  410. package/shells/typescript-shell/packages/client/src/components/organisms/game/GameHud.tsx +135 -0
  411. package/shells/typescript-shell/packages/client/src/components/organisms/game/GameMenu.tsx +188 -0
  412. package/shells/typescript-shell/packages/client/src/components/organisms/game/GameOverScreen.tsx +241 -0
  413. package/shells/typescript-shell/packages/client/src/components/organisms/game/GamePauseOverlay.tsx +158 -0
  414. package/shells/typescript-shell/packages/client/src/components/organisms/game/InputListener.tsx +161 -0
  415. package/shells/typescript-shell/packages/client/src/components/organisms/game/InventoryPanel.tsx +230 -0
  416. package/shells/typescript-shell/packages/client/src/components/organisms/game/LevelSelect.tsx +236 -0
  417. package/shells/typescript-shell/packages/client/src/components/organisms/game/TilemapRenderer.tsx +233 -0
  418. package/shells/typescript-shell/packages/client/src/components/organisms/game/index.ts +28 -0
  419. package/shells/typescript-shell/packages/client/src/components/organisms/index.ts +83 -0
  420. package/shells/typescript-shell/packages/client/src/components/organisms/layout/DashboardGrid.tsx +94 -0
  421. package/shells/typescript-shell/packages/client/src/components/organisms/layout/MasterDetail.tsx +93 -0
  422. package/shells/typescript-shell/packages/client/src/components/organisms/layout/SplitPane.tsx +136 -0
  423. package/shells/typescript-shell/packages/client/src/components/organisms/layout/TabbedContainer.tsx +162 -0
  424. package/shells/typescript-shell/packages/client/src/components/organisms/layout/index.ts +10 -0
  425. package/shells/typescript-shell/packages/client/src/components/templates/AuthLayout.tsx +125 -0
  426. package/shells/typescript-shell/packages/client/src/components/templates/CounterTemplate.tsx +224 -0
  427. package/shells/typescript-shell/packages/client/src/components/templates/CrudTemplate.tsx +511 -0
  428. package/shells/typescript-shell/packages/client/src/components/templates/DashboardLayout.tsx +295 -0
  429. package/shells/typescript-shell/packages/client/src/components/templates/FormTemplate.tsx +328 -0
  430. package/shells/typescript-shell/packages/client/src/components/templates/GameTemplate.tsx +142 -0
  431. package/shells/typescript-shell/packages/client/src/components/templates/GenericAppTemplate.tsx +79 -0
  432. package/shells/typescript-shell/packages/client/src/components/templates/ListTemplate.tsx +361 -0
  433. package/shells/typescript-shell/packages/client/src/components/templates/SettingsTemplate.tsx +459 -0
  434. package/shells/typescript-shell/packages/client/src/components/templates/index.ts +54 -0
  435. package/shells/typescript-shell/packages/client/src/config/firebase.ts +58 -0
  436. package/shells/typescript-shell/packages/client/src/context/DesignThemeContext.tsx +40 -0
  437. package/shells/typescript-shell/packages/client/src/context/ThemeContext.tsx +321 -0
  438. package/shells/typescript-shell/packages/client/src/context/UISlotContext.tsx +143 -0
  439. package/shells/typescript-shell/packages/client/src/context/UserContext.tsx +259 -0
  440. package/shells/typescript-shell/packages/client/src/context/index.ts +44 -0
  441. package/shells/typescript-shell/packages/client/src/evaluator/SExpressionEvaluator.ts +715 -0
  442. package/shells/typescript-shell/packages/client/src/evaluator/context.ts +196 -0
  443. package/shells/typescript-shell/packages/client/src/evaluator/index.ts +52 -0
  444. package/shells/typescript-shell/packages/client/src/evaluator/operators/arithmetic.ts +120 -0
  445. package/shells/typescript-shell/packages/client/src/evaluator/operators/collections.ts +177 -0
  446. package/shells/typescript-shell/packages/client/src/evaluator/operators/comparison.ts +130 -0
  447. package/shells/typescript-shell/packages/client/src/evaluator/operators/control.ts +86 -0
  448. package/shells/typescript-shell/packages/client/src/evaluator/operators/effects.ts +285 -0
  449. package/shells/typescript-shell/packages/client/src/evaluator/operators/index.ts +69 -0
  450. package/shells/typescript-shell/packages/client/src/evaluator/operators/logic.ts +66 -0
  451. package/shells/typescript-shell/packages/client/src/evaluator/std/array.ts +657 -0
  452. package/shells/typescript-shell/packages/client/src/evaluator/std/async.ts +210 -0
  453. package/shells/typescript-shell/packages/client/src/evaluator/std/format.ts +224 -0
  454. package/shells/typescript-shell/packages/client/src/evaluator/std/index.ts +206 -0
  455. package/shells/typescript-shell/packages/client/src/evaluator/std/math.ts +219 -0
  456. package/shells/typescript-shell/packages/client/src/evaluator/std/object.ts +435 -0
  457. package/shells/typescript-shell/packages/client/src/evaluator/std/str.ts +372 -0
  458. package/shells/typescript-shell/packages/client/src/evaluator/std/time.ts +594 -0
  459. package/shells/typescript-shell/packages/client/src/evaluator/std/validate.ts +445 -0
  460. package/shells/typescript-shell/packages/client/src/evaluator/types/expression.ts +297 -0
  461. package/shells/typescript-shell/packages/client/src/features/auth/AuthContext.tsx +192 -0
  462. package/shells/typescript-shell/packages/client/src/features/auth/authService.ts +90 -0
  463. package/shells/typescript-shell/packages/client/src/features/auth/components/Login.tsx +282 -0
  464. package/shells/typescript-shell/packages/client/src/features/auth/components/ProtectedRoute.tsx +28 -0
  465. package/shells/typescript-shell/packages/client/src/features/auth/components/UserProfile.tsx +52 -0
  466. package/shells/typescript-shell/packages/client/src/features/auth/components/index.ts +3 -0
  467. package/shells/typescript-shell/packages/client/src/features/auth/index.ts +4 -0
  468. package/shells/typescript-shell/packages/client/src/features/auth/types.ts +33 -0
  469. package/shells/typescript-shell/packages/client/src/hooks/event-bus-types.ts +70 -0
  470. package/shells/typescript-shell/packages/client/src/hooks/index.ts +84 -0
  471. package/shells/typescript-shell/packages/client/src/hooks/useEntities.ts +118 -0
  472. package/shells/typescript-shell/packages/client/src/hooks/useEntityData.ts +288 -0
  473. package/shells/typescript-shell/packages/client/src/hooks/useEntityMutations.ts +258 -0
  474. package/shells/typescript-shell/packages/client/src/hooks/useEventBus.ts +166 -0
  475. package/shells/typescript-shell/packages/client/src/hooks/useOrbitalMutations.ts +234 -0
  476. package/shells/typescript-shell/packages/client/src/hooks/useQuerySingleton.ts +179 -0
  477. package/shells/typescript-shell/packages/client/src/hooks/useUIEvents.ts +228 -0
  478. package/shells/typescript-shell/packages/client/src/hooks/useUISlots.ts +320 -0
  479. package/shells/typescript-shell/packages/client/src/index.css +15 -0
  480. package/shells/typescript-shell/packages/client/src/lib/api-client.ts +134 -0
  481. package/shells/typescript-shell/packages/client/src/lib/cn.ts +10 -0
  482. package/shells/typescript-shell/packages/client/src/lib/debug.ts +114 -0
  483. package/shells/typescript-shell/packages/client/src/lib/debugRegistry.ts +108 -0
  484. package/shells/typescript-shell/packages/client/src/lib/debugUtils.ts +62 -0
  485. package/shells/typescript-shell/packages/client/src/lib/entityDebug.ts +79 -0
  486. package/shells/typescript-shell/packages/client/src/lib/guardRegistry.ts +79 -0
  487. package/shells/typescript-shell/packages/client/src/lib/tickRegistry.ts +86 -0
  488. package/shells/typescript-shell/packages/client/src/lib/traitRegistry.ts +84 -0
  489. package/shells/typescript-shell/packages/client/src/loaders/AssetLoader.ts +315 -0
  490. package/shells/typescript-shell/packages/client/src/loaders/index.ts +17 -0
  491. package/shells/typescript-shell/packages/client/src/main.tsx +24 -0
  492. package/shells/typescript-shell/packages/client/src/pages/index.ts +2 -0
  493. package/shells/typescript-shell/packages/client/src/providers/EventBusProvider.tsx +212 -0
  494. package/shells/typescript-shell/packages/client/src/providers/FetchedDataProvider.tsx +280 -0
  495. package/shells/typescript-shell/packages/client/src/providers/OrbitalProvider.tsx +136 -0
  496. package/shells/typescript-shell/packages/client/src/providers/SelectionProvider.tsx +232 -0
  497. package/shells/typescript-shell/packages/client/src/providers/index.ts +31 -0
  498. package/shells/typescript-shell/packages/client/src/renderer/client-effect-executor.ts +267 -0
  499. package/shells/typescript-shell/packages/client/src/renderer/data-resolver.ts +253 -0
  500. package/shells/typescript-shell/packages/client/src/renderer/index.ts +138 -0
  501. package/shells/typescript-shell/packages/client/src/renderer/offline-executor.ts +610 -0
  502. package/shells/typescript-shell/packages/client/src/renderer/pattern-resolver.ts +209 -0
  503. package/shells/typescript-shell/packages/client/src/renderer/slot-definitions.ts +154 -0
  504. package/shells/typescript-shell/packages/client/src/renderer/types.ts +214 -0
  505. package/shells/typescript-shell/packages/client/src/renderer/useClientEffects.ts +236 -0
  506. package/shells/typescript-shell/packages/client/src/stores/entityStore.ts +233 -0
  507. package/shells/typescript-shell/packages/client/src/stores/filtering.ts +180 -0
  508. package/shells/typescript-shell/packages/client/src/stores/index.ts +11 -0
  509. package/shells/typescript-shell/packages/client/src/test/setup.ts +126 -0
  510. package/shells/typescript-shell/packages/client/src/themes/almadar.css +196 -0
  511. package/shells/typescript-shell/packages/client/src/themes/index.css +11 -0
  512. package/shells/typescript-shell/packages/client/src/themes/minimalist.css +193 -0
  513. package/shells/typescript-shell/packages/client/src/themes/wireframe.css +188 -0
  514. package/shells/typescript-shell/packages/client/src/types/__tests__/event-contracts.test.ts +204 -0
  515. package/shells/typescript-shell/packages/client/src/types/event-contracts.ts +267 -0
  516. package/shells/typescript-shell/packages/client/tailwind.config.js +55 -0
  517. package/shells/typescript-shell/packages/client/tsconfig.json +33 -0
  518. package/shells/typescript-shell/packages/client/tsconfig.node.json +12 -0
  519. package/shells/typescript-shell/packages/client/vite.config.d.ts +3 -0
  520. package/shells/typescript-shell/packages/client/vite.config.d.ts.map +1 -0
  521. package/shells/typescript-shell/packages/client/vite.config.js +43 -0
  522. package/shells/typescript-shell/packages/client/vite.config.js.map +1 -0
  523. package/shells/typescript-shell/packages/client/vite.config.ts +48 -0
  524. package/shells/typescript-shell/packages/server/.env.development +8 -0
  525. package/shells/typescript-shell/packages/server/.env.example +22 -0
  526. package/shells/typescript-shell/packages/server/package.json +41 -0
  527. package/shells/typescript-shell/packages/server/src/__tests__/integration.test.ts +23 -0
  528. package/shells/typescript-shell/packages/server/src/app.ts +53 -0
  529. package/shells/typescript-shell/packages/server/src/features/.gitkeep +10 -0
  530. package/shells/typescript-shell/packages/server/src/index.ts +60 -0
  531. package/shells/typescript-shell/packages/server/src/integrators/INTEGRATORS.md +357 -0
  532. package/shells/typescript-shell/packages/server/src/integrators/__tests__/registry.test.ts +419 -0
  533. package/shells/typescript-shell/packages/server/src/integrators/__tests__/types.test.ts +382 -0
  534. package/shells/typescript-shell/packages/server/src/integrators/__tests__/youtube.closed-circuit.test.ts +454 -0
  535. package/shells/typescript-shell/packages/server/src/integrators/__tests__/youtube.test.ts +519 -0
  536. package/shells/typescript-shell/packages/server/src/integrators/index.ts +67 -0
  537. package/shells/typescript-shell/packages/server/src/integrators/llm.ts +585 -0
  538. package/shells/typescript-shell/packages/server/src/integrators/registry.ts +318 -0
  539. package/shells/typescript-shell/packages/server/src/integrators/types.ts +248 -0
  540. package/shells/typescript-shell/packages/server/src/integrators/youtube.ts +614 -0
  541. package/shells/typescript-shell/packages/server/src/lib/db.ts +130 -0
  542. package/shells/typescript-shell/packages/server/src/lib/env.ts +47 -0
  543. package/shells/typescript-shell/packages/server/src/lib/eventBus.ts +80 -0
  544. package/shells/typescript-shell/packages/server/src/lib/index.ts +10 -0
  545. package/shells/typescript-shell/packages/server/src/lib/logger.ts +48 -0
  546. package/shells/typescript-shell/packages/server/src/lib/websocket.ts +161 -0
  547. package/shells/typescript-shell/packages/server/src/middleware/authenticateFirebase.ts +29 -0
  548. package/shells/typescript-shell/packages/server/src/middleware/errorHandler.ts +135 -0
  549. package/shells/typescript-shell/packages/server/src/middleware/index.ts +15 -0
  550. package/shells/typescript-shell/packages/server/src/middleware/validation.ts +77 -0
  551. package/shells/typescript-shell/packages/server/src/routes/__tests__/orbitals.e2e.test.ts +405 -0
  552. package/shells/typescript-shell/packages/server/src/routes/features/.gitkeep +0 -0
  553. package/shells/typescript-shell/packages/server/src/routes/index.ts +11 -0
  554. package/shells/typescript-shell/packages/server/src/routes/orbitals.ts +138 -0
  555. package/shells/typescript-shell/packages/server/src/routes/register.ts +19 -0
  556. package/shells/typescript-shell/packages/server/src/routes.ts +58 -0
  557. package/shells/typescript-shell/packages/server/src/seedMockData.ts +27 -0
  558. package/shells/typescript-shell/packages/server/src/services/DataService.ts +402 -0
  559. package/shells/typescript-shell/packages/server/src/services/MockDataService.ts +347 -0
  560. package/shells/typescript-shell/packages/server/src/services/index.ts +8 -0
  561. package/shells/typescript-shell/packages/server/src/types/express.d.ts +13 -0
  562. package/shells/typescript-shell/packages/server/src/utils/index.ts +9 -0
  563. package/shells/typescript-shell/packages/server/src/utils/queryFilters.ts +231 -0
  564. package/shells/typescript-shell/packages/server/tsconfig.json +28 -0
  565. package/shells/typescript-shell/packages/shared/package.json +22 -0
  566. package/shells/typescript-shell/packages/shared/src/__tests__/entities/atom-demo.test.ts +61 -0
  567. package/shells/typescript-shell/packages/shared/src/__tests__/entities/container-demo.test.ts +43 -0
  568. package/shells/typescript-shell/packages/shared/src/__tests__/entities/content-item.test.ts +55 -0
  569. package/shells/typescript-shell/packages/shared/src/__tests__/entities/game-state.test.ts +67 -0
  570. package/shells/typescript-shell/packages/shared/src/__tests__/entities/layout-demo.test.ts +43 -0
  571. package/shells/typescript-shell/packages/shared/src/__tests__/entities/modal-item.test.ts +49 -0
  572. package/shells/typescript-shell/packages/shared/src/__tests__/entities/molecule-demo.test.ts +55 -0
  573. package/shells/typescript-shell/packages/shared/src/__tests__/entities/nav-item.test.ts +55 -0
  574. package/shells/typescript-shell/packages/shared/src/__tests__/entities/product.test.ts +78 -0
  575. package/shells/typescript-shell/packages/shared/src/__tests__/entities/project.test.ts +85 -0
  576. package/shells/typescript-shell/packages/shared/src/__tests__/entities/searchable-item.test.ts +61 -0
  577. package/shells/typescript-shell/packages/shared/src/__tests__/entities/state-demo.test.ts +43 -0
  578. package/shells/typescript-shell/packages/shared/src/__tests__/entities/wizard-data.test.ts +61 -0
  579. package/shells/typescript-shell/packages/shared/src/evaluator/SExpressionEvaluator.ts +715 -0
  580. package/shells/typescript-shell/packages/shared/src/evaluator/context.ts +196 -0
  581. package/shells/typescript-shell/packages/shared/src/evaluator/index.ts +52 -0
  582. package/shells/typescript-shell/packages/shared/src/evaluator/operators/arithmetic.ts +120 -0
  583. package/shells/typescript-shell/packages/shared/src/evaluator/operators/collections.ts +177 -0
  584. package/shells/typescript-shell/packages/shared/src/evaluator/operators/comparison.ts +130 -0
  585. package/shells/typescript-shell/packages/shared/src/evaluator/operators/control.ts +86 -0
  586. package/shells/typescript-shell/packages/shared/src/evaluator/operators/effects.ts +285 -0
  587. package/shells/typescript-shell/packages/shared/src/evaluator/operators/index.ts +69 -0
  588. package/shells/typescript-shell/packages/shared/src/evaluator/operators/logic.ts +66 -0
  589. package/shells/typescript-shell/packages/shared/src/evaluator/std/array.ts +657 -0
  590. package/shells/typescript-shell/packages/shared/src/evaluator/std/async.ts +210 -0
  591. package/shells/typescript-shell/packages/shared/src/evaluator/std/format.ts +224 -0
  592. package/shells/typescript-shell/packages/shared/src/evaluator/std/index.ts +206 -0
  593. package/shells/typescript-shell/packages/shared/src/evaluator/std/math.ts +219 -0
  594. package/shells/typescript-shell/packages/shared/src/evaluator/std/object.ts +435 -0
  595. package/shells/typescript-shell/packages/shared/src/evaluator/std/str.ts +372 -0
  596. package/shells/typescript-shell/packages/shared/src/evaluator/std/time.ts +594 -0
  597. package/shells/typescript-shell/packages/shared/src/evaluator/std/validate.ts +445 -0
  598. package/shells/typescript-shell/packages/shared/src/evaluator/types/expression.ts +297 -0
  599. package/shells/typescript-shell/packages/shared/src/index.ts +12 -0
  600. package/shells/typescript-shell/packages/shared/src/schemas/entities.ts +13 -0
  601. package/shells/typescript-shell/packages/shared/src/types/entities.ts +321 -0
  602. package/shells/typescript-shell/packages/shared/src/types/events.ts +82 -0
  603. package/shells/typescript-shell/packages/shared/tsconfig.json +16 -0
  604. package/shells/typescript-shell/tests/setup.ts +22 -0
  605. package/shells/typescript-shell/tsconfig.base.json +21 -0
  606. package/shells/typescript-shell/tsconfig.json +13 -0
  607. package/shells/typescript-shell/vitest.config.ts +54 -0
@@ -0,0 +1,1428 @@
1
+ /**
2
+ * InspectionFormDemoTemplate
3
+ *
4
+ * A comprehensive demo template that showcases all 5 inspection phases
5
+ * with config-driven dynamic forms. This template is designed for presenting
6
+ * to the client to demonstrate the complete inspection workflow.
7
+ *
8
+ * Features:
9
+ * - Loads form configs from config/tabs/*.json
10
+ * - Renders forms with conditional fields
11
+ * - Shows global variable propagation between tabs
12
+ * - Displays violation tracking
13
+ * - Debug panel for HG-* variables
14
+ */
15
+
16
+ import React, { useState, useCallback, useMemo } from "react";
17
+ import { cn } from "../../../lib/cn";
18
+ import { Box } from "../../../components/atoms/Box";
19
+ import { VStack, HStack } from "../../../components/atoms/Stack";
20
+ import { Typography } from "../../../components/atoms/Typography";
21
+ import { Button } from "../../../components/atoms/Button";
22
+ import { Card } from "../../../components/atoms/Card";
23
+ import { Badge } from "../../../components/atoms/Badge";
24
+ import { useEventBus } from "../../../hooks/useEventBus";
25
+
26
+ // Atoms
27
+ import { PhaseIndicator, InspectionPhase } from "../atoms/PhaseIndicator";
28
+
29
+ // Molecules
30
+ import { RepeatableFormSection } from "../molecules/RepeatableFormSection";
31
+ import { CardSelector, CardSelectorOption } from "../molecules/CardSelector";
32
+
33
+ // Organisms
34
+ import { SignatureCapture } from "../organisms/SignatureCapture";
35
+
36
+ // Components
37
+ import { StatCard } from "../../../components/organisms/StatCard";
38
+
39
+ // Evaluator - stub implementation for design system (actual implementation in @almadar/shared)
40
+ class SExpressionEvaluator {
41
+ evaluate(expr: unknown, _context: Record<string, unknown>): unknown {
42
+ // Stub implementation - always returns true for design system demos
43
+ if (typeof expr === "boolean") return expr;
44
+ return true;
45
+ }
46
+ }
47
+ const createMinimalContext = (
48
+ _options?: Record<string, unknown>,
49
+ ): Record<string, unknown> => ({});
50
+
51
+ import {
52
+ ArrowLeft,
53
+ ArrowRight,
54
+ ChevronDown,
55
+ ChevronRight,
56
+ CheckCircle,
57
+ AlertTriangle,
58
+ Bug,
59
+ Briefcase,
60
+ ClipboardCheck,
61
+ FileText,
62
+ FileCheck,
63
+ PenTool,
64
+ } from "lucide-react";
65
+
66
+ // =============================================================================
67
+ // Types
68
+ // =============================================================================
69
+
70
+ export type DemoPhase =
71
+ | "introduction"
72
+ | "content"
73
+ | "preparation"
74
+ | "record"
75
+ | "closing";
76
+
77
+ export interface FormTabConfig {
78
+ tabId: string;
79
+ name: string;
80
+ globalVariablesSet?: string[];
81
+ globalVariablesRequired?: string[];
82
+ localVariables?: string[];
83
+ sections: FormSection[];
84
+ }
85
+
86
+ export interface FormSection {
87
+ id: string;
88
+ title: string;
89
+ condition?: SExpression;
90
+ fields: FormField[];
91
+ subsections?: FormSection[];
92
+ }
93
+
94
+ export interface FormField {
95
+ id: string;
96
+ label: string;
97
+ type:
98
+ | "text"
99
+ | "textarea"
100
+ | "date"
101
+ | "datetime"
102
+ | "dropdown"
103
+ | "radio"
104
+ | "checkbox"
105
+ | "comment"
106
+ | "currency"
107
+ | "integer"
108
+ | "decimal"
109
+ | "person"
110
+ | "info-display"
111
+ | "card-selector"
112
+ | "signature"
113
+ | "stats-grid"
114
+ | "multi-select"
115
+ | "entity-list"
116
+ | "entity-cards"
117
+ | "checklist";
118
+ required?: boolean;
119
+ repeatable?: boolean;
120
+ options?: Array<{
121
+ value: string;
122
+ label: string;
123
+ isDefault?: boolean;
124
+ icon?: string;
125
+ description?: string;
126
+ }>;
127
+ defaultValue?: string;
128
+ condition?: SExpression;
129
+ contextMenu?: string[];
130
+ lawReference?: { law: string; article: string };
131
+ hiddenCalculation?: { variable: string; scope: "global" | "local" };
132
+ violationTrigger?: {
133
+ id: string;
134
+ condition: SExpression;
135
+ lawReference: string;
136
+ };
137
+ entityField?: string;
138
+ // Info-display specific
139
+ displayContent?: string;
140
+ displayVariant?: "info" | "warning" | "success" | "error";
141
+ // Card-selector specific
142
+ columns?: 1 | 2 | 3 | 4;
143
+ multiple?: boolean;
144
+ // Stats-grid specific
145
+ stats?: Array<{ label: string; value: string | number; icon?: string }>;
146
+ // Entity-list/cards specific
147
+ entityType?: string;
148
+ displayFields?: string[];
149
+ // Checklist specific
150
+ checklistItems?: Array<{ id: string; label: string; required?: boolean }>;
151
+ }
152
+
153
+ export type SExpression = string | number | boolean | SExpression[];
154
+
155
+ export interface ViolationRecord {
156
+ id: string;
157
+ tabId: string;
158
+ fieldId: string;
159
+ lawReference: string;
160
+ adminAction?: string;
161
+ penaltyAction?: string;
162
+ description?: string;
163
+ timestamp: string;
164
+ }
165
+
166
+ export interface FormState {
167
+ formValues: Record<string, unknown>;
168
+ globalVariables: Record<string, unknown>;
169
+ localVariables: Record<string, unknown>;
170
+ violations: ViolationRecord[];
171
+ completedTabs: string[];
172
+ }
173
+
174
+ export interface PhaseDefinition {
175
+ id: DemoPhase;
176
+ label: string;
177
+ labelSl: string;
178
+ icon: typeof Briefcase;
179
+ tabs: string[];
180
+ }
181
+
182
+ /**
183
+ * Mock entity data structure matching the .orb schema entity definitions.
184
+ * Keys are entity names (e.g., "InspectionField", "Company", "Participant")
185
+ * Values are arrays of entity records with fields matching the schema.
186
+ */
187
+ export type MockEntityData = Record<string, Array<Record<string, unknown>>>;
188
+
189
+ export interface InspectionFormDemoTemplateProps {
190
+ /** Form tab configs keyed by tabId */
191
+ configs: Record<string, FormTabConfig>;
192
+ /** Initial form state */
193
+ initialState?: Partial<FormState>;
194
+ /**
195
+ * Mock entity data for dynamic field types (card-selector, entity-list, etc.)
196
+ * Structure matches .orb schema entities. Example:
197
+ * ```
198
+ * {
199
+ * InspectionField: [
200
+ * { id: "1", name: "Trgovina", description: "...", fieldType: "merchant", isActive: true, ruleCount: 45 },
201
+ * { id: "2", name: "Gostinstvo", description: "...", fieldType: "merchant", isActive: true, ruleCount: 32 }
202
+ * ],
203
+ * Company: [
204
+ * { id: "1", name: "Podjetje d.o.o.", registrationNumber: "123456", ... }
205
+ * ]
206
+ * }
207
+ * ```
208
+ */
209
+ mockData?: MockEntityData;
210
+ /** Current phase override */
211
+ currentPhase?: DemoPhase;
212
+ /** Current tab override */
213
+ currentTab?: string;
214
+ /** Show debug panel */
215
+ showDebugPanel?: boolean;
216
+ /** Additional class names */
217
+ className?: string;
218
+ /** Tab change handler */
219
+ onTabChange?: (tabId: string) => void;
220
+ /** Phase change handler */
221
+ onPhaseChange?: (phase: DemoPhase) => void;
222
+ /** Form value change handler */
223
+ onFormValueChange?: (fieldId: string, value: unknown) => void;
224
+ /** Violation detected handler */
225
+ onViolationDetected?: (violation: ViolationRecord) => void;
226
+ }
227
+
228
+ // =============================================================================
229
+ // Phase Configuration
230
+ // =============================================================================
231
+
232
+ const phases: PhaseDefinition[] = [
233
+ {
234
+ id: "introduction",
235
+ label: "Introduction",
236
+ labelSl: "Uvod",
237
+ icon: Briefcase,
238
+ tabs: ["T-001", "T-002", "T-003", "T-004"],
239
+ },
240
+ {
241
+ id: "content",
242
+ label: "Content",
243
+ labelSl: "Vsebina",
244
+ icon: ClipboardCheck,
245
+ tabs: ["T-005", "T2-1"],
246
+ },
247
+ {
248
+ id: "preparation",
249
+ label: "Preparation",
250
+ labelSl: "Priprava",
251
+ icon: FileText,
252
+ tabs: ["T-006", "T-007"],
253
+ },
254
+ {
255
+ id: "record",
256
+ label: "Record",
257
+ labelSl: "Zapisnik",
258
+ icon: FileCheck,
259
+ tabs: ["T-008"],
260
+ },
261
+ {
262
+ id: "closing",
263
+ label: "Closing",
264
+ labelSl: "Zaključek",
265
+ icon: PenTool,
266
+ tabs: ["T-009"],
267
+ },
268
+ ];
269
+
270
+ // =============================================================================
271
+ // S-Expression Evaluator (using real evaluator from almadar-shared)
272
+ // =============================================================================
273
+
274
+ // Create a singleton evaluator instance
275
+ const sexprEvaluator = new SExpressionEvaluator();
276
+
277
+ function evaluateSExpression(
278
+ expr: SExpression | undefined,
279
+ context: {
280
+ formValues: Record<string, unknown>;
281
+ globalVariables: Record<string, unknown>;
282
+ },
283
+ ): boolean {
284
+ if (expr === undefined || expr === null) return true;
285
+ if (typeof expr === "boolean") return expr;
286
+ if (typeof expr === "string" || typeof expr === "number")
287
+ return Boolean(expr);
288
+ if (!Array.isArray(expr) || expr.length === 0) return true;
289
+
290
+ try {
291
+ // Create evaluation context with entity bindings
292
+ const evalContext = createMinimalContext({
293
+ entity: {
294
+ formValues: context.formValues,
295
+ globalVariables: context.globalVariables,
296
+ },
297
+ });
298
+
299
+ // Evaluate the expression using the real evaluator
300
+ const result = sexprEvaluator.evaluate(expr, evalContext);
301
+ return Boolean(result);
302
+ } catch (error) {
303
+ console.warn("S-expression evaluation error:", error, "Expression:", expr);
304
+ return true; // Default to visible on error
305
+ }
306
+ }
307
+
308
+ // =============================================================================
309
+ // Sub-Components
310
+ // =============================================================================
311
+
312
+ interface FieldRendererProps {
313
+ field: FormField;
314
+ value: unknown;
315
+ onChange: (value: unknown) => void;
316
+ isVisible: boolean;
317
+ mockData?: MockEntityData;
318
+ }
319
+
320
+ // Single field input renderer (used by both single and repeatable fields)
321
+ const SingleFieldInput: React.FC<{
322
+ field: FormField;
323
+ value: unknown;
324
+ onChange: (value: unknown) => void;
325
+ inputClasses: string;
326
+ instanceId?: string;
327
+ mockData?: MockEntityData;
328
+ }> = ({ field, value, onChange, inputClasses, instanceId, mockData = {} }) => {
329
+ const radioName = instanceId ? `${field.id}-${instanceId}` : field.id;
330
+
331
+ return (
332
+ <>
333
+ {field.type === "text" && (
334
+ <input
335
+ type="text"
336
+ className={inputClasses}
337
+ value={String(value || "")}
338
+ onChange={(e) => onChange(e.target.value)}
339
+ />
340
+ )}
341
+
342
+ {field.type === "textarea" && (
343
+ <textarea
344
+ className={cn(inputClasses, "min-h-[80px]")}
345
+ value={String(value || "")}
346
+ onChange={(e) => onChange(e.target.value)}
347
+ />
348
+ )}
349
+
350
+ {field.type === "date" && (
351
+ <input
352
+ type="date"
353
+ className={inputClasses}
354
+ value={String(value || "")}
355
+ onChange={(e) => onChange(e.target.value)}
356
+ />
357
+ )}
358
+
359
+ {field.type === "dropdown" && (
360
+ <select
361
+ className={inputClasses}
362
+ value={String(value || field.defaultValue || "")}
363
+ onChange={(e) => onChange(e.target.value)}
364
+ >
365
+ {field.options?.map((opt) => (
366
+ <option key={opt.value} value={opt.value}>
367
+ {opt.label}
368
+ </option>
369
+ ))}
370
+ </select>
371
+ )}
372
+
373
+ {field.type === "radio" && (
374
+ <div className="flex gap-4">
375
+ {field.options?.map((opt) => (
376
+ <label
377
+ key={opt.value}
378
+ className="flex items-center gap-2 cursor-pointer"
379
+ >
380
+ <input
381
+ type="radio"
382
+ name={radioName}
383
+ value={opt.value}
384
+ checked={String(value || field.defaultValue) === opt.value}
385
+ onChange={(e) => onChange(e.target.value)}
386
+ className="w-4 h-4"
387
+ />
388
+ <span className={opt.isDefault ? "font-semibold" : ""}>
389
+ {opt.label}
390
+ </span>
391
+ </label>
392
+ ))}
393
+ </div>
394
+ )}
395
+
396
+ {field.type === "checkbox" && (
397
+ <input
398
+ type="checkbox"
399
+ className="w-4 h-4"
400
+ checked={Boolean(value)}
401
+ onChange={(e) => onChange(e.target.checked)}
402
+ />
403
+ )}
404
+
405
+ {(field.type === "currency" || field.type === "decimal") && (
406
+ <input
407
+ type="number"
408
+ step="0.01"
409
+ className={inputClasses}
410
+ value={String(value || "")}
411
+ onChange={(e) => onChange(parseFloat(e.target.value))}
412
+ />
413
+ )}
414
+
415
+ {field.type === "integer" && (
416
+ <input
417
+ type="number"
418
+ step="1"
419
+ className={inputClasses}
420
+ value={String(value || "")}
421
+ onChange={(e) => onChange(parseInt(e.target.value))}
422
+ />
423
+ )}
424
+
425
+ {field.type === "person" && (
426
+ <input
427
+ type="text"
428
+ className={inputClasses}
429
+ placeholder="Search person..."
430
+ value={String(value || "")}
431
+ onChange={(e) => onChange(e.target.value)}
432
+ />
433
+ )}
434
+
435
+ {/* === NEW FIELD TYPES === */}
436
+
437
+ {/* 1. Info-display: Read-only informational text */}
438
+ {field.type === "info-display" && (
439
+ <Box
440
+ className={cn(
441
+ "p-4 rounded-lg border-l-4",
442
+ field.displayVariant === "warning" &&
443
+ "bg-yellow-50 border-yellow-400 text-yellow-800",
444
+ field.displayVariant === "success" &&
445
+ "bg-green-50 border-green-400 text-green-800",
446
+ field.displayVariant === "error" &&
447
+ "bg-red-50 border-red-400 text-red-800",
448
+ (!field.displayVariant || field.displayVariant === "info") &&
449
+ "bg-blue-50 border-blue-400 text-blue-800",
450
+ )}
451
+ >
452
+ <Typography variant="body">
453
+ {field.displayContent || field.label}
454
+ </Typography>
455
+ </Box>
456
+ )}
457
+
458
+ {/* 2. Card-selector: Card-based selection component */}
459
+ {field.type === "card-selector" &&
460
+ (() => {
461
+ // If entityType is specified, use mockData; otherwise use static options
462
+ const entityData = field.entityType
463
+ ? mockData[field.entityType] || []
464
+ : [];
465
+ const optionsFromEntity = entityData.map(
466
+ (item) =>
467
+ ({
468
+ id: String(item.id),
469
+ title: String(item.name || item.label || item.id),
470
+ description: item.description
471
+ ? String(item.description)
472
+ : undefined,
473
+ }) as CardSelectorOption,
474
+ );
475
+
476
+ const optionsFromConfig = (field.options || []).map(
477
+ (opt) =>
478
+ ({
479
+ id: opt.value,
480
+ title: opt.label,
481
+ description: opt.description,
482
+ }) as CardSelectorOption,
483
+ );
484
+
485
+ // Prefer entity data if available, fall back to config options
486
+ const options =
487
+ optionsFromEntity.length > 0
488
+ ? optionsFromEntity
489
+ : optionsFromConfig;
490
+
491
+ return (
492
+ <CardSelector
493
+ options={options}
494
+ selectedId={field.multiple ? undefined : String(value || "")}
495
+ selectedIds={
496
+ field.multiple && Array.isArray(value)
497
+ ? (value as string[])
498
+ : []
499
+ }
500
+ multiple={field.multiple}
501
+ columns={field.columns || 3}
502
+ onChange={(selectedId) => onChange(selectedId)}
503
+ onMultiChange={(selectedIds) => onChange(selectedIds)}
504
+ />
505
+ );
506
+ })()}
507
+
508
+ {/* 3. Signature: Canvas-based signature capture */}
509
+ {field.type === "signature" && (
510
+ <SignatureCapture
511
+ title={field.label}
512
+ participantId={instanceId || field.id}
513
+ required={field.required}
514
+ onCapture={(signatureData) => onChange(signatureData)}
515
+ onClear={() => onChange(null)}
516
+ />
517
+ )}
518
+
519
+ {/* 4. Stats-grid: Grid of statistic cards */}
520
+ {field.type === "stats-grid" && (
521
+ <div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
522
+ {(field.stats || []).map((stat, idx) => (
523
+ <StatCard key={idx} label={stat.label} value={stat.value} />
524
+ ))}
525
+ </div>
526
+ )}
527
+
528
+ {/* 5. Multi-select: Multiple selection dropdown/checkboxes */}
529
+ {field.type === "multi-select" && (
530
+ <div className="space-y-2 p-3 border rounded bg-neutral-50">
531
+ {field.options?.map((opt) => {
532
+ const selectedValues = Array.isArray(value) ? value : [];
533
+ const isChecked = selectedValues.includes(opt.value);
534
+ return (
535
+ <label
536
+ key={opt.value}
537
+ className="flex items-center gap-2 cursor-pointer"
538
+ >
539
+ <input
540
+ type="checkbox"
541
+ className="w-4 h-4"
542
+ checked={isChecked}
543
+ onChange={(e) => {
544
+ if (e.target.checked) {
545
+ onChange([...selectedValues, opt.value]);
546
+ } else {
547
+ onChange(
548
+ selectedValues.filter((v: string) => v !== opt.value),
549
+ );
550
+ }
551
+ }}
552
+ />
553
+ <span>{opt.label}</span>
554
+ </label>
555
+ );
556
+ })}
557
+ </div>
558
+ )}
559
+
560
+ {/* 6. Entity-list: Display a list of entities */}
561
+ {field.type === "entity-list" &&
562
+ (() => {
563
+ // Use mockData if entityType specified, otherwise use value (which may be set via formValues)
564
+ const entityData = field.entityType
565
+ ? mockData[field.entityType] || []
566
+ : [];
567
+ const items =
568
+ entityData.length > 0
569
+ ? entityData
570
+ : Array.isArray(value)
571
+ ? value
572
+ : [];
573
+
574
+ return (
575
+ <Box className="border rounded overflow-hidden">
576
+ <table className="w-full text-sm">
577
+ <thead className="bg-neutral-100">
578
+ <tr>
579
+ {(field.displayFields || ["name"]).map((fieldName) => (
580
+ <th
581
+ key={fieldName}
582
+ className="px-3 py-2 text-left font-medium text-neutral-700"
583
+ >
584
+ {fieldName.charAt(0).toUpperCase() + fieldName.slice(1)}
585
+ </th>
586
+ ))}
587
+ </tr>
588
+ </thead>
589
+ <tbody>
590
+ {items.length > 0 ? (
591
+ items.map((item: Record<string, unknown>, idx: number) => (
592
+ <tr key={idx} className="border-t hover:bg-neutral-50">
593
+ {(field.displayFields || ["name"]).map((fieldName) => (
594
+ <td
595
+ key={fieldName}
596
+ className="px-3 py-2 text-neutral-600"
597
+ >
598
+ {String(item[fieldName] || "-")}
599
+ </td>
600
+ ))}
601
+ </tr>
602
+ ))
603
+ ) : (
604
+ <tr>
605
+ <td
606
+ colSpan={(field.displayFields || ["name"]).length}
607
+ className="px-3 py-4 text-center text-neutral-500"
608
+ >
609
+ No items to display
610
+ </td>
611
+ </tr>
612
+ )}
613
+ </tbody>
614
+ </table>
615
+ </Box>
616
+ );
617
+ })()}
618
+
619
+ {/* 7. Entity-cards: Display entities as cards */}
620
+ {field.type === "entity-cards" &&
621
+ (() => {
622
+ // Use mockData if entityType specified, otherwise use value
623
+ const entityData = field.entityType
624
+ ? mockData[field.entityType] || []
625
+ : [];
626
+ const items =
627
+ entityData.length > 0
628
+ ? entityData
629
+ : Array.isArray(value)
630
+ ? value
631
+ : [];
632
+
633
+ return (
634
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
635
+ {items.length > 0 ? (
636
+ items.map((item: Record<string, unknown>, idx: number) => (
637
+ <Card key={idx} className="p-4">
638
+ <VStack gap="xs">
639
+ {(field.displayFields || ["name"]).map((fieldName) => (
640
+ <Typography key={fieldName} variant="body">
641
+ <span className="font-medium">{fieldName}:</span>{" "}
642
+ {String(item[fieldName] || "-")}
643
+ </Typography>
644
+ ))}
645
+ </VStack>
646
+ </Card>
647
+ ))
648
+ ) : (
649
+ <Box className="col-span-full p-4 text-center text-neutral-500 border rounded">
650
+ No items to display
651
+ </Box>
652
+ )}
653
+ </div>
654
+ );
655
+ })()}
656
+
657
+ {/* 8. Datetime: Date and time input */}
658
+ {field.type === "datetime" && (
659
+ <input
660
+ type="datetime-local"
661
+ className={inputClasses}
662
+ value={String(value || "")}
663
+ onChange={(e) => onChange(e.target.value)}
664
+ />
665
+ )}
666
+
667
+ {/* 9. Checklist: List of checkable items */}
668
+ {field.type === "checklist" && (
669
+ <div className="space-y-2 p-3 border rounded bg-neutral-50">
670
+ {(field.checklistItems || field.options || []).map(
671
+ (item: { id?: string; value?: string; label: string }) => {
672
+ const itemId = item.id ?? item.value ?? "";
673
+ const itemLabel = item.label;
674
+ const checklistValue = (value as Record<string, boolean>) || {};
675
+ const isChecked = Boolean(checklistValue[itemId]);
676
+ return (
677
+ <label
678
+ key={itemId}
679
+ className="flex items-start gap-3 cursor-pointer p-2 hover:bg-neutral-100 rounded"
680
+ >
681
+ <input
682
+ type="checkbox"
683
+ className="w-5 h-5 mt-0.5"
684
+ checked={isChecked}
685
+ onChange={(e) => {
686
+ onChange({
687
+ ...checklistValue,
688
+ [itemId]: e.target.checked,
689
+ });
690
+ }}
691
+ />
692
+ <span
693
+ className={cn(isChecked && "line-through text-neutral-500")}
694
+ >
695
+ {String(itemLabel)}
696
+ {"required" in item &&
697
+ (item as { required?: boolean }).required && (
698
+ <span className="text-red-500 ml-1">*</span>
699
+ )}
700
+ </span>
701
+ </label>
702
+ );
703
+ },
704
+ )}
705
+ </div>
706
+ )}
707
+ </>
708
+ );
709
+ };
710
+
711
+ const FieldRenderer: React.FC<FieldRendererProps> = ({
712
+ field,
713
+ value,
714
+ onChange,
715
+ isVisible,
716
+ mockData = {},
717
+ }) => {
718
+ if (!isVisible) return null;
719
+ if (field.type === "comment") {
720
+ return (
721
+ <Box className="p-3 bg-blue-50 border-l-4 border-blue-400 rounded">
722
+ <Typography variant="small" className="text-blue-800">
723
+ {field.label}
724
+ </Typography>
725
+ </Box>
726
+ );
727
+ }
728
+
729
+ const inputClasses =
730
+ "w-full p-2 border rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500";
731
+
732
+ // Handle repeatable fields
733
+ if (field.repeatable) {
734
+ // Value should be an array of items for repeatable fields
735
+ const items = Array.isArray(value)
736
+ ? value
737
+ : value
738
+ ? [{ id: "1", value }]
739
+ : [];
740
+
741
+ const handleAdd = () => {
742
+ const newItem = { id: String(Date.now()), value: "" };
743
+ onChange([...items, newItem]);
744
+ };
745
+
746
+ const handleRemove = (itemId: string) => {
747
+ onChange(items.filter((item: { id: string }) => item.id !== itemId));
748
+ };
749
+
750
+ const handleItemChange = (itemId: string, newValue: unknown) => {
751
+ onChange(
752
+ items.map((item: { id: string; value: unknown }) =>
753
+ item.id === itemId ? { ...item, value: newValue } : item,
754
+ ),
755
+ );
756
+ };
757
+
758
+ return (
759
+ <RepeatableFormSection
760
+ sectionType={field.id}
761
+ title={field.label}
762
+ items={items}
763
+ minItems={field.required ? 1 : 0}
764
+ addLabel={`Add ${field.label}`}
765
+ emptyMessage={`No ${field.label.toLowerCase()} added yet`}
766
+ onAdd={handleAdd}
767
+ onRemove={handleRemove}
768
+ renderItem={(item) => (
769
+ <Box className="space-y-1">
770
+ <SingleFieldInput
771
+ field={field}
772
+ value={item.value}
773
+ onChange={(newValue) => handleItemChange(item.id, newValue)}
774
+ inputClasses={inputClasses}
775
+ instanceId={item.id}
776
+ mockData={mockData}
777
+ />
778
+ {field.lawReference && (
779
+ <Typography variant="small" className="text-green-600">
780
+ ({field.lawReference.law} {field.lawReference.article})
781
+ </Typography>
782
+ )}
783
+ </Box>
784
+ )}
785
+ />
786
+ );
787
+ }
788
+
789
+ // Non-repeatable field
790
+ return (
791
+ <Box className="space-y-1">
792
+ <label className="flex items-center gap-1 text-sm font-medium text-neutral-700">
793
+ {field.label}
794
+ {field.required && <span className="text-red-500">*</span>}
795
+ </label>
796
+
797
+ <SingleFieldInput
798
+ field={field}
799
+ value={value}
800
+ onChange={onChange}
801
+ inputClasses={inputClasses}
802
+ mockData={mockData}
803
+ />
804
+
805
+ {field.lawReference && (
806
+ <Typography variant="small" className="text-green-600">
807
+ ({field.lawReference.law} {field.lawReference.article})
808
+ </Typography>
809
+ )}
810
+ </Box>
811
+ );
812
+ };
813
+
814
+ interface SectionRendererProps {
815
+ section: FormSection;
816
+ formValues: Record<string, unknown>;
817
+ globalVariables: Record<string, unknown>;
818
+ onFieldChange: (fieldId: string, value: unknown) => void;
819
+ mockData?: MockEntityData;
820
+ depth?: number;
821
+ }
822
+
823
+ const SectionRenderer: React.FC<SectionRendererProps> = ({
824
+ section,
825
+ formValues,
826
+ globalVariables,
827
+ onFieldChange,
828
+ mockData = {},
829
+ depth = 0,
830
+ }) => {
831
+ const [isExpanded, setIsExpanded] = useState(true);
832
+
833
+ const isVisible = evaluateSExpression(section.condition, {
834
+ formValues,
835
+ globalVariables,
836
+ });
837
+ if (!isVisible) return null;
838
+
839
+ return (
840
+ <Card className={cn("p-4", depth > 0 && "ml-4 border-l-4 border-blue-200")}>
841
+ <button
842
+ onClick={() => setIsExpanded(!isExpanded)}
843
+ className="flex items-center gap-2 w-full text-left mb-3"
844
+ >
845
+ {isExpanded ? (
846
+ <ChevronDown className="h-4 w-4 text-neutral-500" />
847
+ ) : (
848
+ <ChevronRight className="h-4 w-4 text-neutral-500" />
849
+ )}
850
+ <Typography variant="h4" className="text-neutral-800">
851
+ {section.title}
852
+ </Typography>
853
+ <Badge variant="default" className="ml-auto">
854
+ {section.id}
855
+ </Badge>
856
+ </button>
857
+
858
+ {isExpanded && (
859
+ <VStack gap="md" align="stretch">
860
+ {section.fields.map((field) => {
861
+ const fieldVisible = evaluateSExpression(field.condition, {
862
+ formValues,
863
+ globalVariables,
864
+ });
865
+ return (
866
+ <FieldRenderer
867
+ key={field.id}
868
+ field={field}
869
+ value={formValues[field.id]}
870
+ onChange={(val) => onFieldChange(field.id, val)}
871
+ isVisible={fieldVisible}
872
+ mockData={mockData}
873
+ />
874
+ );
875
+ })}
876
+
877
+ {section.subsections?.map((sub) => (
878
+ <SectionRenderer
879
+ key={sub.id}
880
+ section={sub}
881
+ formValues={formValues}
882
+ globalVariables={globalVariables}
883
+ onFieldChange={onFieldChange}
884
+ mockData={mockData}
885
+ depth={depth + 1}
886
+ />
887
+ ))}
888
+ </VStack>
889
+ )}
890
+ </Card>
891
+ );
892
+ };
893
+
894
+ interface DebugPanelProps {
895
+ globalVariables: Record<string, unknown>;
896
+ localVariables: Record<string, unknown>;
897
+ violations: ViolationRecord[];
898
+ completedTabs: string[];
899
+ isOpen: boolean;
900
+ onToggle: () => void;
901
+ }
902
+
903
+ const DebugPanel: React.FC<DebugPanelProps> = ({
904
+ globalVariables,
905
+ localVariables,
906
+ violations,
907
+ completedTabs,
908
+ isOpen,
909
+ onToggle,
910
+ }) => {
911
+ return (
912
+ <Card className="bg-neutral-900 text-neutral-100 overflow-hidden">
913
+ <button
914
+ onClick={onToggle}
915
+ className="flex items-center gap-2 w-full p-3 bg-neutral-800 hover:bg-neutral-700"
916
+ >
917
+ <Bug className="h-4 w-4" />
918
+ <Typography variant="small" className="font-mono">
919
+ Debug Panel
920
+ </Typography>
921
+ {isOpen ? (
922
+ <ChevronDown className="h-4 w-4 ml-auto" />
923
+ ) : (
924
+ <ChevronRight className="h-4 w-4 ml-auto" />
925
+ )}
926
+ </button>
927
+
928
+ {isOpen && (
929
+ <div className="p-3 space-y-4 font-mono text-xs">
930
+ <div>
931
+ <Typography variant="small" className="text-green-400 mb-1">
932
+ Global Variables (HG-*)
933
+ </Typography>
934
+ <pre className="bg-neutral-800 p-2 rounded overflow-x-auto">
935
+ {JSON.stringify(globalVariables, null, 2) || "{}"}
936
+ </pre>
937
+ </div>
938
+
939
+ <div>
940
+ <Typography variant="small" className="text-blue-400 mb-1">
941
+ Local Variables (H-*)
942
+ </Typography>
943
+ <pre className="bg-neutral-800 p-2 rounded overflow-x-auto">
944
+ {JSON.stringify(localVariables, null, 2) || "{}"}
945
+ </pre>
946
+ </div>
947
+
948
+ <div>
949
+ <Typography variant="small" className="text-red-400 mb-1">
950
+ Violations ({violations.length})
951
+ </Typography>
952
+ <pre className="bg-neutral-800 p-2 rounded overflow-x-auto">
953
+ {JSON.stringify(violations, null, 2) || "[]"}
954
+ </pre>
955
+ </div>
956
+
957
+ <div>
958
+ <Typography variant="small" className="text-yellow-400 mb-1">
959
+ Completed Tabs
960
+ </Typography>
961
+ <pre className="bg-neutral-800 p-2 rounded">
962
+ {completedTabs.join(", ") || "(none)"}
963
+ </pre>
964
+ </div>
965
+ </div>
966
+ )}
967
+ </Card>
968
+ );
969
+ };
970
+
971
+ // =============================================================================
972
+ // Main Component
973
+ // =============================================================================
974
+
975
+ export const InspectionFormDemoTemplate: React.FC<
976
+ InspectionFormDemoTemplateProps
977
+ > = ({
978
+ configs,
979
+ initialState,
980
+ mockData = {},
981
+ currentPhase: controlledPhase,
982
+ currentTab: controlledTab,
983
+ showDebugPanel = true,
984
+ className,
985
+ onTabChange,
986
+ onPhaseChange,
987
+ onFormValueChange,
988
+ onViolationDetected,
989
+ }) => {
990
+ const eventBus = useEventBus();
991
+
992
+ // State
993
+ const [formState, setFormState] = useState<FormState>({
994
+ formValues: initialState?.formValues || {},
995
+ globalVariables: initialState?.globalVariables || {},
996
+ localVariables: initialState?.localVariables || {},
997
+ violations: initialState?.violations || [],
998
+ completedTabs: initialState?.completedTabs || [],
999
+ });
1000
+
1001
+ const [activePhase, setActivePhase] = useState<DemoPhase>(
1002
+ controlledPhase || "introduction",
1003
+ );
1004
+ const [activeTab, setActiveTab] = useState<string>(controlledTab || "T-001");
1005
+ const [isDebugOpen, setIsDebugOpen] = useState(false);
1006
+
1007
+ // Derived state
1008
+ const currentPhaseConfig = useMemo(
1009
+ () => phases.find((p) => p.id === activePhase) || phases[0],
1010
+ [activePhase],
1011
+ );
1012
+
1013
+ const currentTabConfig = useMemo(
1014
+ () => configs[activeTab],
1015
+ [configs, activeTab],
1016
+ );
1017
+
1018
+ const phaseIndex = phases.findIndex((p) => p.id === activePhase);
1019
+ const tabIndex = currentPhaseConfig.tabs.indexOf(activeTab);
1020
+ const isFirstTab = phaseIndex === 0 && tabIndex === 0;
1021
+ const isLastTab =
1022
+ phaseIndex === phases.length - 1 &&
1023
+ tabIndex === currentPhaseConfig.tabs.length - 1;
1024
+
1025
+ // Handlers
1026
+ const handleFieldChange = useCallback(
1027
+ (fieldId: string, value: unknown) => {
1028
+ setFormState((prev) => ({
1029
+ ...prev,
1030
+ formValues: {
1031
+ ...prev.formValues,
1032
+ [fieldId]: value,
1033
+ },
1034
+ }));
1035
+
1036
+ onFormValueChange?.(fieldId, value);
1037
+ eventBus.emit("UI:FIELD_CHANGED", { fieldId, value, tabId: activeTab });
1038
+
1039
+ // Check for hidden calculations that set global variables
1040
+ const field = currentTabConfig?.sections
1041
+ .flatMap((s) => [
1042
+ ...s.fields,
1043
+ ...(s.subsections?.flatMap((ss) => ss.fields) || []),
1044
+ ])
1045
+ .find((f) => f.id === fieldId);
1046
+
1047
+ if (field?.hiddenCalculation?.scope === "global") {
1048
+ setFormState((prev) => ({
1049
+ ...prev,
1050
+ globalVariables: {
1051
+ ...prev.globalVariables,
1052
+ [field.hiddenCalculation!.variable]: value,
1053
+ },
1054
+ }));
1055
+ eventBus.emit("UI:GLOBAL_VARIABLE_SET", {
1056
+ variable: field.hiddenCalculation!.variable,
1057
+ value,
1058
+ sourceTab: activeTab,
1059
+ });
1060
+ }
1061
+ },
1062
+ [activeTab, currentTabConfig, eventBus, onFormValueChange],
1063
+ );
1064
+
1065
+ const handlePhaseChange = useCallback(
1066
+ (phase: DemoPhase) => {
1067
+ setActivePhase(phase);
1068
+ const firstTab = phases.find((p) => p.id === phase)?.tabs[0];
1069
+ if (firstTab) {
1070
+ setActiveTab(firstTab);
1071
+ onTabChange?.(firstTab);
1072
+ }
1073
+ onPhaseChange?.(phase);
1074
+ },
1075
+ [onPhaseChange, onTabChange],
1076
+ );
1077
+
1078
+ const handleTabChange = useCallback(
1079
+ (tabId: string) => {
1080
+ setActiveTab(tabId);
1081
+ onTabChange?.(tabId);
1082
+ },
1083
+ [onTabChange],
1084
+ );
1085
+
1086
+ const handlePrevious = useCallback(() => {
1087
+ if (tabIndex > 0) {
1088
+ handleTabChange(currentPhaseConfig.tabs[tabIndex - 1]);
1089
+ } else if (phaseIndex > 0) {
1090
+ const prevPhase = phases[phaseIndex - 1];
1091
+ handlePhaseChange(prevPhase.id);
1092
+ handleTabChange(prevPhase.tabs[prevPhase.tabs.length - 1]);
1093
+ }
1094
+ }, [
1095
+ tabIndex,
1096
+ phaseIndex,
1097
+ currentPhaseConfig.tabs,
1098
+ handleTabChange,
1099
+ handlePhaseChange,
1100
+ ]);
1101
+
1102
+ const handleNext = useCallback(() => {
1103
+ // Mark current tab as complete
1104
+ if (!formState.completedTabs.includes(activeTab)) {
1105
+ setFormState((prev) => ({
1106
+ ...prev,
1107
+ completedTabs: [...prev.completedTabs, activeTab],
1108
+ }));
1109
+ }
1110
+
1111
+ if (tabIndex < currentPhaseConfig.tabs.length - 1) {
1112
+ handleTabChange(currentPhaseConfig.tabs[tabIndex + 1]);
1113
+ } else if (phaseIndex < phases.length - 1) {
1114
+ const nextPhase = phases[phaseIndex + 1];
1115
+ handlePhaseChange(nextPhase.id);
1116
+ }
1117
+ }, [
1118
+ tabIndex,
1119
+ phaseIndex,
1120
+ currentPhaseConfig.tabs,
1121
+ activeTab,
1122
+ formState.completedTabs,
1123
+ handleTabChange,
1124
+ handlePhaseChange,
1125
+ ]);
1126
+
1127
+ const mapPhaseToIndicator = (phase: DemoPhase): InspectionPhase => {
1128
+ const mapping: Record<DemoPhase, InspectionPhase> = {
1129
+ introduction: "preparation",
1130
+ content: "execution",
1131
+ preparation: "documentation",
1132
+ record: "review",
1133
+ closing: "completed",
1134
+ };
1135
+ return mapping[phase];
1136
+ };
1137
+
1138
+ // ==========================================================================
1139
+ // Render
1140
+ // ==========================================================================
1141
+
1142
+ return (
1143
+ <VStack gap="none" className={cn("min-h-screen bg-neutral-100", className)}>
1144
+ {/* Header */}
1145
+ <Box className="bg-white border-b shadow-sm sticky top-0 z-50">
1146
+ <Box className="max-w-7xl mx-auto p-4">
1147
+ <HStack justify="between" align="center">
1148
+ <VStack gap="xs">
1149
+ <Typography variant="h3">Inspection Form Demo</Typography>
1150
+ <Typography variant="small" className="text-neutral-500">
1151
+ Config-driven dynamic forms with all 5 phases
1152
+ </Typography>
1153
+ </VStack>
1154
+ <PhaseIndicator phase={mapPhaseToIndicator(activePhase)} />
1155
+ </HStack>
1156
+ </Box>
1157
+ </Box>
1158
+
1159
+ {/* Phase Navigation */}
1160
+ <Box className="bg-white border-b">
1161
+ <Box className="max-w-7xl mx-auto">
1162
+ <HStack gap="none" className="overflow-x-auto">
1163
+ {phases.map((phase, idx) => {
1164
+ const isActive = phase.id === activePhase;
1165
+ const isComplete = idx < phaseIndex;
1166
+ const Icon = phase.icon;
1167
+
1168
+ return (
1169
+ <button
1170
+ key={phase.id}
1171
+ onClick={() => handlePhaseChange(phase.id)}
1172
+ className={cn(
1173
+ "flex-1 p-4 border-b-3 transition-all flex items-center justify-center gap-2",
1174
+ isActive && "border-blue-500 bg-blue-50",
1175
+ isComplete && !isActive && "border-green-500 bg-green-50",
1176
+ !isActive &&
1177
+ !isComplete &&
1178
+ "border-transparent hover:bg-neutral-50",
1179
+ )}
1180
+ >
1181
+ {isComplete ? (
1182
+ <CheckCircle className="h-5 w-5 text-green-600" />
1183
+ ) : (
1184
+ <Icon
1185
+ className={cn(
1186
+ "h-5 w-5",
1187
+ isActive ? "text-blue-600" : "text-neutral-400",
1188
+ )}
1189
+ />
1190
+ )}
1191
+ <VStack gap="none" align="start">
1192
+ <Typography
1193
+ variant="small"
1194
+ weight={isActive ? "semibold" : "normal"}
1195
+ className={cn(
1196
+ isActive && "text-blue-700",
1197
+ isComplete && !isActive && "text-green-700",
1198
+ )}
1199
+ >
1200
+ {phase.label}
1201
+ </Typography>
1202
+ <Typography variant="small" className="text-neutral-500">
1203
+ {phase.labelSl}
1204
+ </Typography>
1205
+ </VStack>
1206
+ </button>
1207
+ );
1208
+ })}
1209
+ </HStack>
1210
+ </Box>
1211
+ </Box>
1212
+
1213
+ {/* Tab Navigation */}
1214
+ <Box className="bg-white border-b">
1215
+ <Box className="max-w-7xl mx-auto px-4">
1216
+ <HStack gap="sm" className="py-2 overflow-x-auto">
1217
+ {currentPhaseConfig.tabs.map((tabId) => {
1218
+ const tabConfig = configs[tabId];
1219
+ const isActive = tabId === activeTab;
1220
+ const isComplete = formState.completedTabs.includes(tabId);
1221
+
1222
+ return (
1223
+ <button
1224
+ key={tabId}
1225
+ onClick={() => handleTabChange(tabId)}
1226
+ className={cn(
1227
+ "px-4 py-2 rounded-lg transition-all flex items-center gap-2 whitespace-nowrap",
1228
+ isActive && "bg-blue-100 text-blue-700",
1229
+ !isActive && isComplete && "bg-green-100 text-green-700",
1230
+ !isActive &&
1231
+ !isComplete &&
1232
+ "bg-neutral-100 text-neutral-600 hover:bg-neutral-200",
1233
+ )}
1234
+ >
1235
+ {isComplete && <CheckCircle className="h-4 w-4" />}
1236
+ <span className="font-medium">{tabId}</span>
1237
+ {tabConfig && (
1238
+ <span className="text-xs opacity-70">{tabConfig.name}</span>
1239
+ )}
1240
+ </button>
1241
+ );
1242
+ })}
1243
+ </HStack>
1244
+ </Box>
1245
+ </Box>
1246
+
1247
+ {/* Main Content */}
1248
+ <Box className="flex-1">
1249
+ <Box className="max-w-5xl mx-auto p-4">
1250
+ <VStack gap="lg" align="stretch">
1251
+ {/* Form Area */}
1252
+ <div>
1253
+ {currentTabConfig ? (
1254
+ <VStack gap="md" align="stretch">
1255
+ <Card className="p-4 bg-blue-50 border-blue-200">
1256
+ <HStack justify="between" align="center">
1257
+ <VStack gap="xs">
1258
+ <Typography variant="h3">
1259
+ {currentTabConfig.name}
1260
+ </Typography>
1261
+ <Typography
1262
+ variant="small"
1263
+ className="text-neutral-600"
1264
+ >
1265
+ Tab {currentTabConfig.tabId}
1266
+ </Typography>
1267
+ </VStack>
1268
+ {currentTabConfig.globalVariablesSet &&
1269
+ currentTabConfig.globalVariablesSet.length > 0 && (
1270
+ <Badge variant="primary">
1271
+ Sets:{" "}
1272
+ {currentTabConfig.globalVariablesSet.join(", ")}
1273
+ </Badge>
1274
+ )}
1275
+ </HStack>
1276
+ </Card>
1277
+
1278
+ {currentTabConfig.sections.map((section) => (
1279
+ <SectionRenderer
1280
+ key={section.id}
1281
+ section={section}
1282
+ formValues={formState.formValues}
1283
+ globalVariables={formState.globalVariables}
1284
+ onFieldChange={handleFieldChange}
1285
+ mockData={mockData}
1286
+ />
1287
+ ))}
1288
+ </VStack>
1289
+ ) : (
1290
+ <Card className="p-8 text-center">
1291
+ <AlertTriangle className="h-12 w-12 text-yellow-500 mx-auto mb-4" />
1292
+ <Typography variant="h4" className="text-neutral-600">
1293
+ Config not found for tab: {activeTab}
1294
+ </Typography>
1295
+ <Typography variant="small" className="text-neutral-500 mt-2">
1296
+ Make sure the config file exists in config/tabs/
1297
+ </Typography>
1298
+ </Card>
1299
+ )}
1300
+ </div>
1301
+
1302
+ {/* Violations Summary - at bottom */}
1303
+ {formState.violations.length > 0 && (
1304
+ <Card className="p-4">
1305
+ <Typography
1306
+ variant="h4"
1307
+ className="mb-3 flex items-center gap-2"
1308
+ >
1309
+ <AlertTriangle className="h-5 w-5 text-red-500" />
1310
+ Violations ({formState.violations.length})
1311
+ </Typography>
1312
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2">
1313
+ {formState.violations.map((violation) => (
1314
+ <Box
1315
+ key={violation.id}
1316
+ className="p-2 bg-red-50 border border-red-200 rounded text-sm"
1317
+ >
1318
+ <HStack justify="between" align="center">
1319
+ <Typography
1320
+ variant="small"
1321
+ className="font-medium text-red-700"
1322
+ >
1323
+ {violation.id}
1324
+ </Typography>
1325
+ <Badge className="bg-red-100 text-red-700">
1326
+ {violation.lawReference}
1327
+ </Badge>
1328
+ </HStack>
1329
+ {violation.description && (
1330
+ <Typography
1331
+ variant="small"
1332
+ className="text-red-600 mt-1"
1333
+ >
1334
+ {violation.description}
1335
+ </Typography>
1336
+ )}
1337
+ </Box>
1338
+ ))}
1339
+ </div>
1340
+ </Card>
1341
+ )}
1342
+
1343
+ {/* Global Variables Panel - at bottom */}
1344
+ <Card className="p-4">
1345
+ <Typography variant="h4" className="mb-3">
1346
+ Global Variables
1347
+ </Typography>
1348
+ {Object.keys(formState.globalVariables).length > 0 ? (
1349
+ <div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2">
1350
+ {Object.entries(formState.globalVariables).map(
1351
+ ([key, value]) => (
1352
+ <HStack
1353
+ key={key}
1354
+ justify="between"
1355
+ className="text-sm bg-neutral-50 p-2 rounded"
1356
+ >
1357
+ <code className="text-blue-600 text-xs">{key}</code>
1358
+ <Badge variant="default">{String(value)}</Badge>
1359
+ </HStack>
1360
+ ),
1361
+ )}
1362
+ </div>
1363
+ ) : (
1364
+ <Typography variant="small" className="text-neutral-500">
1365
+ No global variables set yet
1366
+ </Typography>
1367
+ )}
1368
+ </Card>
1369
+
1370
+ {/* Debug Panel - at bottom */}
1371
+ {showDebugPanel && (
1372
+ <DebugPanel
1373
+ globalVariables={formState.globalVariables}
1374
+ localVariables={formState.localVariables}
1375
+ violations={formState.violations}
1376
+ completedTabs={formState.completedTabs}
1377
+ isOpen={isDebugOpen}
1378
+ onToggle={() => setIsDebugOpen(!isDebugOpen)}
1379
+ />
1380
+ )}
1381
+ </VStack>
1382
+ </Box>
1383
+ </Box>
1384
+
1385
+ {/* Footer Navigation */}
1386
+ <Box className="bg-white border-t sticky bottom-0 z-40">
1387
+ <Box className="max-w-7xl mx-auto p-4">
1388
+ <HStack justify="between" align="center">
1389
+ <Button
1390
+ variant="secondary"
1391
+ onClick={handlePrevious}
1392
+ disabled={isFirstTab}
1393
+ className="gap-2"
1394
+ >
1395
+ <ArrowLeft className="h-4 w-4" />
1396
+ Previous
1397
+ </Button>
1398
+
1399
+ <Typography variant="small" className="text-neutral-500">
1400
+ {currentPhaseConfig.label} • {activeTab}
1401
+ </Typography>
1402
+
1403
+ <Button
1404
+ variant="primary"
1405
+ onClick={handleNext}
1406
+ disabled={isLastTab}
1407
+ className="gap-2"
1408
+ >
1409
+ {isLastTab ? (
1410
+ <>
1411
+ <CheckCircle className="h-4 w-4" />
1412
+ Complete
1413
+ </>
1414
+ ) : (
1415
+ <>
1416
+ Next
1417
+ <ArrowRight className="h-4 w-4" />
1418
+ </>
1419
+ )}
1420
+ </Button>
1421
+ </HStack>
1422
+ </Box>
1423
+ </Box>
1424
+ </VStack>
1425
+ );
1426
+ };
1427
+
1428
+ InspectionFormDemoTemplate.displayName = "InspectionFormDemoTemplate";