@carlonicora/nextjs-jsonapi 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/README.md +208 -127
  2. package/dist/{ApiResponseInterface-DDI7QQPR.d.ts → ApiResponseInterface-CfcC7pPC.d.mts} +11 -2
  3. package/dist/{ApiResponseInterface-BHN5D9r5.d.mts → ApiResponseInterface-DTBJaV5R.d.ts} +11 -2
  4. package/dist/{BlockNoteEditor-QV6ESIQA.js → BlockNoteEditor-7FM7B737.js} +19 -24
  5. package/dist/BlockNoteEditor-7FM7B737.js.map +1 -0
  6. package/dist/{BlockNoteEditor-U2IHUVUF.mjs → BlockNoteEditor-RVL76ZAS.mjs} +11 -16
  7. package/dist/BlockNoteEditor-RVL76ZAS.mjs.map +1 -0
  8. package/dist/JsonApiRequest-KOKGVPBI.js +25 -0
  9. package/dist/{JsonApiRequest-UJ7FGIVI.js.map → JsonApiRequest-KOKGVPBI.js.map} +1 -1
  10. package/dist/{JsonApiRequest-6UR7DIAR.mjs → JsonApiRequest-VCCRO732.mjs} +2 -2
  11. package/dist/chunk-2Z56AS2S.js +2723 -0
  12. package/dist/chunk-2Z56AS2S.js.map +1 -0
  13. package/dist/{chunk-HTLEKZND.mjs → chunk-37NJZ2VD.mjs} +281 -1019
  14. package/dist/chunk-37NJZ2VD.mjs.map +1 -0
  15. package/dist/{chunk-2K3Q24UF.js → chunk-3ZPK4QOB.js} +24 -14
  16. package/dist/chunk-3ZPK4QOB.js.map +1 -0
  17. package/dist/chunk-AGWQ75PQ.js +142 -0
  18. package/dist/chunk-AGWQ75PQ.js.map +1 -0
  19. package/dist/{chunk-32HM6MDD.js → chunk-CSM6AIAP.js} +1 -1
  20. package/dist/{chunk-32HM6MDD.js.map → chunk-CSM6AIAP.js.map} +1 -1
  21. package/dist/{chunk-IKBA4AHN.mjs → chunk-F4Y3GZG4.mjs} +3 -3
  22. package/dist/{chunk-YF5XQZDR.mjs → chunk-F5UNXZ3J.mjs} +1 -1
  23. package/dist/chunk-F5UNXZ3J.mjs.map +1 -0
  24. package/dist/chunk-IGOWVLJH.mjs +142 -0
  25. package/dist/chunk-IGOWVLJH.mjs.map +1 -0
  26. package/dist/{chunk-HAG77QBV.mjs → chunk-K4W5QXL5.mjs} +1 -1
  27. package/dist/chunk-KFL5ZFM4.mjs +2723 -0
  28. package/dist/chunk-KFL5ZFM4.mjs.map +1 -0
  29. package/dist/{chunk-HR4H2FP7.mjs → chunk-KJ4ETLJB.mjs} +24 -14
  30. package/dist/chunk-KJ4ETLJB.mjs.map +1 -0
  31. package/dist/chunk-LOSPCUCF.js +637 -0
  32. package/dist/chunk-LOSPCUCF.js.map +1 -0
  33. package/dist/{chunk-E2HRC2OG.js → chunk-SVX7E6RR.js} +10360 -6256
  34. package/dist/chunk-SVX7E6RR.js.map +1 -0
  35. package/dist/{chunk-EFJEWLRL.js → chunk-YUO55Q5A.js} +1 -1
  36. package/dist/chunk-YUO55Q5A.js.map +1 -0
  37. package/dist/chunk-ZQTFZKLJ.mjs +12089 -0
  38. package/dist/chunk-ZQTFZKLJ.mjs.map +1 -0
  39. package/dist/{chunk-PMXG5WBC.js → chunk-ZUEEIQHW.js} +3 -3
  40. package/dist/{chunk-PMXG5WBC.js.map → chunk-ZUEEIQHW.js.map} +1 -1
  41. package/dist/client/index.d.mts +161 -11
  42. package/dist/client/index.d.ts +161 -11
  43. package/dist/client/index.js +74 -12
  44. package/dist/client/index.js.map +1 -1
  45. package/dist/client/index.mjs +73 -11
  46. package/dist/components/index.d.mts +762 -73
  47. package/dist/components/index.d.ts +762 -73
  48. package/dist/components/index.js +465 -12
  49. package/dist/components/index.js.map +1 -1
  50. package/dist/components/index.mjs +466 -13
  51. package/dist/config-B43zxEvn.d.mts +69 -0
  52. package/dist/config-D2OUrI_G.d.ts +69 -0
  53. package/dist/content.fields-Ck5lkQ5d.d.mts +47 -0
  54. package/dist/content.fields-Ck5lkQ5d.d.ts +47 -0
  55. package/dist/{content.interface-C_PGZMuy.d.ts → content.interface-Bs8a7uW6.d.mts} +2 -3
  56. package/dist/{content.interface-D_WS6CrB.d.mts → content.interface-UtsJ-mzs.d.ts} +2 -3
  57. package/dist/contexts/index.d.mts +13 -6
  58. package/dist/contexts/index.d.ts +13 -6
  59. package/dist/contexts/index.js +10 -12
  60. package/dist/contexts/index.js.map +1 -1
  61. package/dist/contexts/index.mjs +9 -11
  62. package/dist/core/index.d.mts +539 -8
  63. package/dist/core/index.d.ts +539 -8
  64. package/dist/core/index.js +104 -2
  65. package/dist/core/index.js.map +1 -1
  66. package/dist/core/index.mjs +105 -3
  67. package/dist/index.d.mts +131 -70
  68. package/dist/index.d.ts +131 -70
  69. package/dist/index.js +97 -7
  70. package/dist/index.js.map +1 -1
  71. package/dist/index.mjs +118 -28
  72. package/dist/notification.interface-BdcwkuQE.d.mts +228 -0
  73. package/dist/notification.interface-BdcwkuQE.d.ts +228 -0
  74. package/dist/request-GBLBPYFM.js +8 -0
  75. package/dist/request-GBLBPYFM.js.map +1 -0
  76. package/dist/request-XABCMU25.mjs +8 -0
  77. package/dist/{AbstractService-wLid8dB0.d.ts → s3.interface-D7ttGatc.d.ts} +36 -26
  78. package/dist/{AbstractService-BsY6W3Ej.d.mts → s3.interface-DlaMDRTn.d.mts} +36 -26
  79. package/dist/scripts/generate-web-module/generator.d.ts.map +1 -1
  80. package/dist/scripts/generate-web-module/generator.js +8 -5
  81. package/dist/scripts/generate-web-module/generator.js.map +1 -1
  82. package/dist/scripts/generate-web-module/index.js +1 -1
  83. package/dist/scripts/generate-web-module/index.js.map +1 -1
  84. package/dist/scripts/generate-web-module/templates/components/editor.template.js +8 -1
  85. package/dist/scripts/generate-web-module/templates/components/editor.template.js.map +1 -1
  86. package/dist/scripts/generate-web-module/transformers/parent-detector.d.ts +4 -3
  87. package/dist/scripts/generate-web-module/transformers/parent-detector.d.ts.map +1 -1
  88. package/dist/scripts/generate-web-module/transformers/parent-detector.js +9 -3
  89. package/dist/scripts/generate-web-module/transformers/parent-detector.js.map +1 -1
  90. package/dist/scripts/generate-web-module/transformers/relationship-resolver.d.ts +11 -0
  91. package/dist/scripts/generate-web-module/transformers/relationship-resolver.d.ts.map +1 -1
  92. package/dist/scripts/generate-web-module/transformers/relationship-resolver.js +36 -9
  93. package/dist/scripts/generate-web-module/transformers/relationship-resolver.js.map +1 -1
  94. package/dist/scripts/generate-web-module/types/json-schema.interface.d.ts +2 -0
  95. package/dist/scripts/generate-web-module/types/json-schema.interface.d.ts.map +1 -1
  96. package/dist/scripts/generate-web-module/types/template-data.interface.d.ts +1 -0
  97. package/dist/scripts/generate-web-module/types/template-data.interface.d.ts.map +1 -1
  98. package/dist/scripts/generate-web-module/utils/i18n-updater.d.ts +4 -3
  99. package/dist/scripts/generate-web-module/utils/i18n-updater.d.ts.map +1 -1
  100. package/dist/scripts/generate-web-module/utils/i18n-updater.js +9 -9
  101. package/dist/scripts/generate-web-module/utils/i18n-updater.js.map +1 -1
  102. package/dist/scripts/generate-web-module/validators/json-schema-validator.js +3 -3
  103. package/dist/scripts/generate-web-module/validators/json-schema-validator.js.map +1 -1
  104. package/dist/server/index.d.mts +299 -4
  105. package/dist/server/index.d.ts +299 -4
  106. package/dist/server/index.js +215 -5
  107. package/dist/server/index.js.map +1 -1
  108. package/dist/server/index.mjs +214 -4
  109. package/dist/server/index.mjs.map +1 -1
  110. package/dist/token-2UWQJY5T.js +8 -0
  111. package/dist/token-2UWQJY5T.js.map +1 -0
  112. package/dist/token-EOK3N45S.mjs +8 -0
  113. package/dist/{useSocket-DzMKRKCA.d.ts → useSocket-8vwK_R_c.d.ts} +1 -1
  114. package/dist/{useSocket-Cn7fB_B1.d.mts → useSocket-BWJUXuOl.d.mts} +1 -1
  115. package/package.json +12 -52
  116. package/scripts/generate-web-module/generator.ts +8 -5
  117. package/scripts/generate-web-module/index.ts +1 -1
  118. package/scripts/generate-web-module/templates/components/editor.template.ts +7 -2
  119. package/scripts/generate-web-module/transformers/parent-detector.ts +10 -3
  120. package/scripts/generate-web-module/transformers/relationship-resolver.ts +36 -9
  121. package/scripts/generate-web-module/types/json-schema.interface.ts +2 -0
  122. package/scripts/generate-web-module/types/template-data.interface.ts +1 -0
  123. package/scripts/generate-web-module/utils/i18n-updater.ts +9 -9
  124. package/scripts/generate-web-module/validators/json-schema-validator.ts +3 -3
  125. package/src/client/JsonApiClient.ts +248 -0
  126. package/src/client/config.ts +78 -0
  127. package/src/client/index.ts +6 -1
  128. package/src/components/containers/TabsContainer.tsx +1 -1
  129. package/src/components/editors/BlockNoteEditor.tsx +3 -1
  130. package/src/components/index.ts +4 -0
  131. package/src/components/navigations/Breadcrumb.tsx +1 -1
  132. package/src/components/navigations/Header.tsx +2 -2
  133. package/src/contexts/CommonContext.tsx +1 -1
  134. package/src/contexts/SocketContext.tsx +1 -1
  135. package/src/contexts/index.ts +3 -0
  136. package/src/core/abstracts/ClientAbstractService.ts +255 -0
  137. package/src/core/abstracts/ServerAbstractService.ts +180 -0
  138. package/src/core/abstracts/index.ts +2 -0
  139. package/src/core/index.ts +32 -3
  140. package/src/discord/config.ts +15 -0
  141. package/src/discord/index.ts +1 -0
  142. package/src/features/auth/components/details/LandingComponent.tsx +2 -2
  143. package/src/features/auth/components/forms/AcceptInvitation.tsx +1 -1
  144. package/src/features/auth/components/forms/ActivateAccount.tsx +1 -1
  145. package/src/features/auth/components/forms/Cookies.tsx +2 -1
  146. package/src/features/auth/components/forms/ForgotPassword.tsx +1 -1
  147. package/src/features/auth/components/forms/Login.tsx +1 -1
  148. package/src/features/auth/components/forms/Logout.tsx +1 -1
  149. package/src/features/auth/components/forms/RefreshUser.tsx +2 -1
  150. package/src/features/auth/components/forms/Register.tsx +1 -1
  151. package/src/features/auth/components/forms/ResetPassword.tsx +1 -1
  152. package/src/features/auth/data/auth.service.ts +1 -1
  153. package/src/features/auth/data/index.ts +0 -1
  154. package/src/features/auth/utils/AuthCookies.ts +1 -1
  155. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +4 -2
  156. package/src/features/company/components/forms/CompanyDeleter.tsx +2 -1
  157. package/src/features/company/components/forms/CompanyEditor.tsx +6 -3
  158. package/src/features/company/components/forms/CompanyLicense.tsx +4 -2
  159. package/src/features/company/components/lists/CompaniesList.tsx +2 -1
  160. package/src/features/company/data/index.ts +0 -1
  161. package/src/features/content/components/lists/ContentsListById.tsx +2 -1
  162. package/src/features/content/components/lists/RelevantContentsList.tsx +2 -1
  163. package/src/features/content/data/index.ts +0 -1
  164. package/src/features/feature/data/index.ts +0 -1
  165. package/src/features/notification/components/lists/NotificationsList.tsx +2 -1
  166. package/src/features/notification/contexts/NotificationContext.tsx +2 -1
  167. package/src/features/notification/data/index.ts +0 -1
  168. package/src/features/push/data/index.ts +0 -1
  169. package/src/features/role/components/forms/RemoveUserFromRole.tsx +4 -2
  170. package/src/features/role/components/forms/UserRoleAdd.tsx +2 -1
  171. package/src/features/role/components/lists/RolesList.tsx +2 -1
  172. package/src/features/role/components/lists/UserRolesList.tsx +2 -1
  173. package/src/features/role/data/index.ts +0 -1
  174. package/src/features/s3/data/index.ts +0 -1
  175. package/src/features/user/components/forms/RoleUserAdd.tsx +4 -2
  176. package/src/features/user/components/forms/UserDeleter.tsx +2 -1
  177. package/src/features/user/components/forms/UserEditor.tsx +6 -3
  178. package/src/features/user/components/forms/UserMultiSelect.tsx +2 -1
  179. package/src/features/user/components/forms/UserReactivator.tsx +2 -1
  180. package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -1
  181. package/src/features/user/components/forms/UserSelector.tsx +2 -1
  182. package/src/features/user/components/lists/AdminUsersList.tsx +2 -1
  183. package/src/features/user/components/lists/CompanyUsersList.tsx +2 -1
  184. package/src/features/user/components/lists/RelevantUsersList.tsx +2 -1
  185. package/src/features/user/components/lists/RoleUsersList.tsx +2 -1
  186. package/src/features/user/components/lists/UsersListByContentIds.tsx +2 -1
  187. package/src/features/user/data/index.ts +0 -1
  188. package/src/features/user/hooks/useUserSearch.ts +2 -1
  189. package/src/features/user/index.ts +1 -0
  190. package/src/hooks/useDataListRetriever.ts +4 -4
  191. package/src/hooks/usePageTracker.ts +1 -1
  192. package/src/hooks/usePushNotifications.ts +3 -2
  193. package/src/hooks/useSocket.ts +1 -1
  194. package/src/index.ts +7 -2
  195. package/src/roles/config.ts +0 -15
  196. package/src/roles/index.ts +1 -9
  197. package/src/server/JsonApiServer.ts +249 -0
  198. package/src/server/cache.ts +1 -1
  199. package/src/server/index.ts +13 -0
  200. package/src/server/request.ts +32 -18
  201. package/src/server/token.ts +1 -1
  202. package/dist/ApiData-DPKNfY-9.d.mts +0 -10
  203. package/dist/ApiData-DPKNfY-9.d.ts +0 -10
  204. package/dist/ApiDataInterface-DPP8s46n.d.mts +0 -21
  205. package/dist/ApiDataInterface-DPP8s46n.d.ts +0 -21
  206. package/dist/BlockNoteEditor-QV6ESIQA.js.map +0 -1
  207. package/dist/BlockNoteEditor-U2IHUVUF.mjs.map +0 -1
  208. package/dist/JsonApiRequest-UJ7FGIVI.js +0 -25
  209. package/dist/atoms/index.d.mts +0 -12
  210. package/dist/atoms/index.d.ts +0 -12
  211. package/dist/atoms/index.js +0 -9
  212. package/dist/atoms/index.js.map +0 -1
  213. package/dist/atoms/index.mjs +0 -9
  214. package/dist/chunk-2K3Q24UF.js.map +0 -1
  215. package/dist/chunk-3FBCC4G3.js +0 -8
  216. package/dist/chunk-3FBCC4G3.js.map +0 -1
  217. package/dist/chunk-3UELCPIN.js +0 -46
  218. package/dist/chunk-3UELCPIN.js.map +0 -1
  219. package/dist/chunk-5IET37O4.js +0 -4210
  220. package/dist/chunk-5IET37O4.js.map +0 -1
  221. package/dist/chunk-AYHKQWHH.js +0 -68
  222. package/dist/chunk-AYHKQWHH.js.map +0 -1
  223. package/dist/chunk-DEYKTLA3.js +0 -1131
  224. package/dist/chunk-DEYKTLA3.js.map +0 -1
  225. package/dist/chunk-E2HRC2OG.js.map +0 -1
  226. package/dist/chunk-EFJEWLRL.js.map +0 -1
  227. package/dist/chunk-FMBQZAIP.mjs +0 -490
  228. package/dist/chunk-FMBQZAIP.mjs.map +0 -1
  229. package/dist/chunk-HR4H2FP7.mjs.map +0 -1
  230. package/dist/chunk-HTLEKZND.mjs.map +0 -1
  231. package/dist/chunk-JGFWIT2E.mjs +0 -1131
  232. package/dist/chunk-JGFWIT2E.mjs.map +0 -1
  233. package/dist/chunk-P2F54I7Q.mjs +0 -4210
  234. package/dist/chunk-P2F54I7Q.mjs.map +0 -1
  235. package/dist/chunk-PO5Q3H5I.js +0 -1375
  236. package/dist/chunk-PO5Q3H5I.js.map +0 -1
  237. package/dist/chunk-Q2N6SQYW.mjs +0 -8
  238. package/dist/chunk-Q2N6SQYW.mjs.map +0 -1
  239. package/dist/chunk-Q4FXESVT.js +0 -490
  240. package/dist/chunk-Q4FXESVT.js.map +0 -1
  241. package/dist/chunk-R2ONK22M.mjs +0 -7985
  242. package/dist/chunk-R2ONK22M.mjs.map +0 -1
  243. package/dist/chunk-SM63SZCP.mjs +0 -68
  244. package/dist/chunk-SM63SZCP.mjs.map +0 -1
  245. package/dist/chunk-SZZYEG3P.mjs +0 -46
  246. package/dist/chunk-SZZYEG3P.mjs.map +0 -1
  247. package/dist/chunk-YF5XQZDR.mjs.map +0 -1
  248. package/dist/config-BmnK65TD.d.mts +0 -35
  249. package/dist/config-BmnK65TD.d.ts +0 -35
  250. package/dist/config-DQeAo9Kf.d.mts +0 -49
  251. package/dist/config-DQeAo9Kf.d.ts +0 -49
  252. package/dist/content.fields-cHPdM8GJ.d.mts +0 -27
  253. package/dist/content.fields-cHPdM8GJ.d.ts +0 -27
  254. package/dist/d3.link.interface-ClC4Irqp.d.mts +0 -21
  255. package/dist/d3.link.interface-ClC4Irqp.d.ts +0 -21
  256. package/dist/features/index.d.mts +0 -476
  257. package/dist/features/index.d.ts +0 -476
  258. package/dist/features/index.js +0 -87
  259. package/dist/features/index.js.map +0 -1
  260. package/dist/features/index.mjs +0 -87
  261. package/dist/hooks/index.d.mts +0 -69
  262. package/dist/hooks/index.d.ts +0 -69
  263. package/dist/hooks/index.js +0 -56
  264. package/dist/hooks/index.js.map +0 -1
  265. package/dist/hooks/index.mjs +0 -56
  266. package/dist/hooks/index.mjs.map +0 -1
  267. package/dist/interfaces/index.d.mts +0 -4
  268. package/dist/interfaces/index.d.ts +0 -4
  269. package/dist/interfaces/index.js +0 -2
  270. package/dist/interfaces/index.js.map +0 -1
  271. package/dist/interfaces/index.mjs +0 -2
  272. package/dist/interfaces/index.mjs.map +0 -1
  273. package/dist/notification.interface-BBgMUdLR.d.mts +0 -14
  274. package/dist/notification.interface-gyvT-Z2F.d.ts +0 -14
  275. package/dist/permissions/index.d.mts +0 -41
  276. package/dist/permissions/index.d.ts +0 -41
  277. package/dist/permissions/index.js +0 -14
  278. package/dist/permissions/index.js.map +0 -1
  279. package/dist/permissions/index.mjs +0 -14
  280. package/dist/permissions/index.mjs.map +0 -1
  281. package/dist/request-7FE3LJLV.mjs +0 -9
  282. package/dist/request-7FE3LJLV.mjs.map +0 -1
  283. package/dist/request-QFS7NEIE.js +0 -9
  284. package/dist/request-QFS7NEIE.js.map +0 -1
  285. package/dist/roles/index.d.mts +0 -39
  286. package/dist/roles/index.d.ts +0 -39
  287. package/dist/roles/index.js +0 -18
  288. package/dist/roles/index.js.map +0 -1
  289. package/dist/roles/index.mjs +0 -18
  290. package/dist/roles/index.mjs.map +0 -1
  291. package/dist/shadcnui/index.d.mts +0 -698
  292. package/dist/shadcnui/index.d.ts +0 -698
  293. package/dist/shadcnui/index.js +0 -468
  294. package/dist/shadcnui/index.js.map +0 -1
  295. package/dist/shadcnui/index.mjs +0 -467
  296. package/dist/shadcnui/index.mjs.map +0 -1
  297. package/dist/token-IJSPOMW6.mjs +0 -9
  298. package/dist/token-IJSPOMW6.mjs.map +0 -1
  299. package/dist/token-UYE7CV6X.js +0 -9
  300. package/dist/token-UYE7CV6X.js.map +0 -1
  301. package/dist/types-B2QRyqyK.d.ts +0 -39
  302. package/dist/types-CgvNmxTd.d.mts +0 -39
  303. package/dist/types-t2PyXhDu.d.mts +0 -116
  304. package/dist/types-t2PyXhDu.d.ts +0 -116
  305. package/dist/user.interface-CAsTIbuQ.d.mts +0 -85
  306. package/dist/user.interface-CbWqMaaU.d.ts +0 -85
  307. package/dist/utils/index.d.mts +0 -224
  308. package/dist/utils/index.d.ts +0 -224
  309. package/dist/utils/index.js +0 -46
  310. package/dist/utils/index.js.map +0 -1
  311. package/dist/utils/index.mjs +0 -46
  312. package/dist/utils/index.mjs.map +0 -1
  313. /package/dist/{JsonApiRequest-6UR7DIAR.mjs.map → JsonApiRequest-VCCRO732.mjs.map} +0 -0
  314. /package/dist/{chunk-IKBA4AHN.mjs.map → chunk-F4Y3GZG4.mjs.map} +0 -0
  315. /package/dist/{chunk-HAG77QBV.mjs.map → chunk-K4W5QXL5.mjs.map} +0 -0
  316. /package/dist/{atoms/index.mjs.map → request-XABCMU25.mjs.map} +0 -0
  317. /package/dist/{features/index.mjs.map → token-EOK3N45S.mjs.map} +0 -0
@@ -0,0 +1,2723 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5;
2
+
3
+ var _chunkIBS6NI7Djs = require('./chunk-IBS6NI7D.js');
4
+
5
+
6
+
7
+
8
+ var _chunkAGAJMJ4Tjs = require('./chunk-AGAJMJ4T.js');
9
+
10
+
11
+ var _chunkLXKSUWAVjs = require('./chunk-LXKSUWAV.js');
12
+
13
+
14
+ var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
15
+
16
+ // src/core/factories/RehydrationFactory.ts
17
+ var RehydrationFactory = class {
18
+ static {
19
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "RehydrationFactory");
20
+ }
21
+ static rehydrate(classKey, data) {
22
+ const factoryClass = _chunkAGAJMJ4Tjs.DataClassRegistry.get(classKey);
23
+ const instance = new factoryClass();
24
+ return instance.rehydrate(data);
25
+ }
26
+ static rehydrateList(classKey, data) {
27
+ const factoryClass = _chunkAGAJMJ4Tjs.DataClassRegistry.get(classKey);
28
+ const response = data.map((item) => {
29
+ const instance = new factoryClass();
30
+ return instance.rehydrate(item);
31
+ });
32
+ return response;
33
+ }
34
+ };
35
+
36
+ // src/core/abstracts/AbstractApiData.ts
37
+ var AbstractApiData = class {
38
+ static {
39
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "AbstractApiData");
40
+ }
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+ get type() {
49
+ if (!this._type) throw new Error("Type is not set.");
50
+ return this._type;
51
+ }
52
+ get id() {
53
+ if (!this._id) throw new Error("Id is not set.");
54
+ return this._id;
55
+ }
56
+ get self() {
57
+ return this._self;
58
+ }
59
+ get createdAt() {
60
+ return _nullishCoalesce(this._createdAt, () => ( /* @__PURE__ */ new Date()));
61
+ }
62
+ get updatedAt() {
63
+ return _nullishCoalesce(this._updatedAt, () => ( /* @__PURE__ */ new Date()));
64
+ }
65
+ get included() {
66
+ return _nullishCoalesce(this._included, () => ( []));
67
+ }
68
+ get jsonApi() {
69
+ return this._jsonApi;
70
+ }
71
+ ingestJsonApi(_data) {
72
+ }
73
+ generateApiUrl(_params) {
74
+ throw new Error("Method not implemented.");
75
+ }
76
+ createJsonApi(_data) {
77
+ throw new Error("Method not implemented.");
78
+ }
79
+ _readIncluded(data, type, dataType) {
80
+ if (data.included === void 0 || data.included.length === 0 || data.jsonApi.relationships === void 0 || data.jsonApi.relationships[type] === void 0 || data.jsonApi.relationships[type].data === void 0) {
81
+ return void 0;
82
+ }
83
+ if (Array.isArray(data.jsonApi.relationships[type].data)) {
84
+ const response = data.jsonApi.relationships[type].data.map((jsonApiData) => {
85
+ const includedData2 = data.included.find(
86
+ (includedData3) => includedData3.id === jsonApiData.id && includedData3.type === jsonApiData.type
87
+ );
88
+ if (includedData2 === void 0) return void 0;
89
+ return RehydrationFactory.rehydrate(dataType, {
90
+ jsonApi: includedData2,
91
+ included: data.included
92
+ });
93
+ });
94
+ return response.filter((item) => item !== void 0);
95
+ }
96
+ const includedData = data.included.find(
97
+ (includedData2) => includedData2.id === data.jsonApi.relationships[type].data.id && includedData2.type === data.jsonApi.relationships[type].data.type
98
+ );
99
+ if (includedData === void 0 && data.allData !== void 0) {
100
+ const fallbackData = data.allData.find(
101
+ (includedData2) => includedData2.id === data.jsonApi.relationships[type].data.id && includedData2.type === data.jsonApi.relationships[type].data.type
102
+ );
103
+ if (fallbackData !== void 0) {
104
+ return RehydrationFactory.rehydrate(dataType, {
105
+ jsonApi: fallbackData,
106
+ included: data.included
107
+ });
108
+ }
109
+ }
110
+ if (includedData === void 0) return void 0;
111
+ return RehydrationFactory.rehydrate(dataType, {
112
+ jsonApi: includedData,
113
+ included: data.included
114
+ });
115
+ }
116
+ dehydrate() {
117
+ return {
118
+ jsonApi: this._jsonApi,
119
+ included: _nullishCoalesce(this._included, () => ( []))
120
+ };
121
+ }
122
+ rehydrate(data) {
123
+ this._jsonApi = data.jsonApi;
124
+ this._included = data.included;
125
+ this._type = this._jsonApi.type;
126
+ this._id = this._jsonApi.id;
127
+ this._createdAt = _optionalChain([this, 'access', _2 => _2._jsonApi, 'access', _3 => _3.meta, 'optionalAccess', _4 => _4.createdAt]) !== void 0 ? new Date(this._jsonApi.meta.createdAt) : void 0;
128
+ this._updatedAt = _optionalChain([this, 'access', _5 => _5._jsonApi, 'access', _6 => _6.meta, 'optionalAccess', _7 => _7.updatedAt]) !== void 0 ? new Date(this._jsonApi.meta.updatedAt) : void 0;
129
+ this._self = _nullishCoalesce(_optionalChain([this, 'access', _8 => _8._jsonApi, 'access', _9 => _9.links, 'optionalAccess', _10 => _10.self]), () => ( void 0));
130
+ return this;
131
+ }
132
+ };
133
+
134
+ // src/core/abstracts/AbstractService.ts
135
+ var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
136
+ HttpMethod2["GET"] = "GET";
137
+ HttpMethod2["POST"] = "POST";
138
+ HttpMethod2["PUT"] = "PUT";
139
+ HttpMethod2["PATCH"] = "PATCH";
140
+ HttpMethod2["DELETE"] = "DELETE";
141
+ return HttpMethod2;
142
+ })(HttpMethod || {});
143
+ var globalErrorHandler = null;
144
+ function setGlobalErrorHandler(handler) {
145
+ globalErrorHandler = handler;
146
+ }
147
+ _chunk7QVYU63Ejs.__name.call(void 0, setGlobalErrorHandler, "setGlobalErrorHandler");
148
+ function getGlobalErrorHandler() {
149
+ return globalErrorHandler;
150
+ }
151
+ _chunk7QVYU63Ejs.__name.call(void 0, getGlobalErrorHandler, "getGlobalErrorHandler");
152
+ var AbstractService = class {
153
+ static {
154
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "AbstractService");
155
+ }
156
+ /**
157
+ * Extract locale from client-side URL pathname
158
+ * URL structure: /{locale}/route-path (e.g., /it/accounts)
159
+ * Fallback chain: URL locale → navigator.language → "en"
160
+ */
161
+ static getClientLocale() {
162
+ if (typeof window === "undefined") {
163
+ return "en";
164
+ }
165
+ const pathSegments = window.location.pathname.split("/").filter(Boolean);
166
+ const urlLocale = pathSegments[0];
167
+ const supportedLocales = ["en"];
168
+ if (urlLocale && supportedLocales.includes(urlLocale)) {
169
+ return urlLocale;
170
+ }
171
+ const navigatorLocale = navigator.language.split("-")[0];
172
+ if (navigatorLocale && supportedLocales.includes(navigatorLocale)) {
173
+ return navigatorLocale;
174
+ }
175
+ return "en";
176
+ }
177
+ static async next(params) {
178
+ return await this.callApi({
179
+ method: "GET" /* GET */,
180
+ type: params.type,
181
+ endpoint: params.endpoint,
182
+ next: params.next,
183
+ previous: params.previous,
184
+ self: params.self
185
+ });
186
+ }
187
+ /**
188
+ * Fetch the previous page of results.
189
+ */
190
+ static async previous(params) {
191
+ return await this.callApi({
192
+ method: "GET" /* GET */,
193
+ type: params.type,
194
+ endpoint: params.endpoint,
195
+ next: params.next,
196
+ previous: params.previous,
197
+ self: params.self
198
+ });
199
+ }
200
+ /**
201
+ * Make an API call with automatic environment detection and error handling.
202
+ */
203
+ static async callApi(params) {
204
+ const { JsonApiGet, JsonApiPost, JsonApiPut, JsonApiPatch, JsonApiDelete } = await Promise.resolve().then(() => _interopRequireWildcard(require("./JsonApiRequest-KOKGVPBI.js")));
205
+ let apiResponse;
206
+ let language = "en";
207
+ if (typeof window === "undefined") {
208
+ const { getLocale } = await Promise.resolve().then(() => _interopRequireWildcard(require("next-intl/server")));
209
+ language = await _asyncNullishCoalesce(await getLocale(), async () => ( "en"));
210
+ } else {
211
+ language = this.getClientLocale();
212
+ }
213
+ switch (params.method) {
214
+ case "GET" /* GET */:
215
+ apiResponse = await JsonApiGet({
216
+ classKey: params.type,
217
+ endpoint: params.endpoint,
218
+ companyId: params.companyId,
219
+ language
220
+ });
221
+ break;
222
+ case "POST" /* POST */:
223
+ apiResponse = await JsonApiPost({
224
+ classKey: params.type,
225
+ endpoint: params.endpoint,
226
+ companyId: params.companyId,
227
+ body: params.input,
228
+ overridesJsonApiCreation: params.overridesJsonApiCreation,
229
+ language,
230
+ responseType: params.responseType,
231
+ files: params.files
232
+ });
233
+ break;
234
+ case "PUT" /* PUT */:
235
+ apiResponse = await JsonApiPut({
236
+ classKey: params.type,
237
+ endpoint: params.endpoint,
238
+ companyId: params.companyId,
239
+ body: params.input,
240
+ language,
241
+ responseType: params.responseType,
242
+ files: params.files
243
+ });
244
+ break;
245
+ case "PATCH" /* PATCH */:
246
+ apiResponse = await JsonApiPatch({
247
+ classKey: params.type,
248
+ endpoint: params.endpoint,
249
+ companyId: params.companyId,
250
+ body: params.input,
251
+ overridesJsonApiCreation: params.overridesJsonApiCreation,
252
+ language,
253
+ responseType: params.responseType,
254
+ files: params.files
255
+ });
256
+ break;
257
+ case "DELETE" /* DELETE */:
258
+ apiResponse = await JsonApiDelete({
259
+ classKey: params.type,
260
+ endpoint: params.endpoint,
261
+ companyId: params.companyId,
262
+ language,
263
+ responseType: params.responseType
264
+ });
265
+ break;
266
+ default:
267
+ throw new Error("Method not found");
268
+ }
269
+ if (!apiResponse.ok) {
270
+ if (globalErrorHandler && typeof window !== "undefined") {
271
+ globalErrorHandler(apiResponse.response, apiResponse.error);
272
+ return void 0;
273
+ } else {
274
+ const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
275
+ error.status = apiResponse.response;
276
+ error.digest = `HTTP_${apiResponse.response}`;
277
+ throw error;
278
+ }
279
+ }
280
+ if (apiResponse.next && params.next) params.next.next = apiResponse.next;
281
+ if (apiResponse.prev && params.previous) params.previous.previous = apiResponse.prev;
282
+ if (apiResponse.self && params.self) params.self.self = apiResponse.self;
283
+ return apiResponse.data;
284
+ }
285
+ /**
286
+ * Get raw JSON:API response data without deserialization.
287
+ */
288
+ static async getRawData(params) {
289
+ const { JsonApiGet } = await Promise.resolve().then(() => _interopRequireWildcard(require("./JsonApiRequest-KOKGVPBI.js")));
290
+ let language = "en";
291
+ if (typeof window === "undefined") {
292
+ const { getLocale } = await Promise.resolve().then(() => _interopRequireWildcard(require("next-intl/server")));
293
+ language = await _asyncNullishCoalesce(await getLocale(), async () => ( "en"));
294
+ } else {
295
+ language = this.getClientLocale();
296
+ }
297
+ const apiResponse = await JsonApiGet({
298
+ classKey: params.type,
299
+ endpoint: params.endpoint,
300
+ companyId: params.companyId,
301
+ language
302
+ });
303
+ if (!apiResponse.ok) {
304
+ if (globalErrorHandler && typeof window !== "undefined") {
305
+ globalErrorHandler(apiResponse.response, apiResponse.error);
306
+ return void 0;
307
+ } else {
308
+ const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
309
+ error.status = apiResponse.response;
310
+ error.digest = `HTTP_${apiResponse.response}`;
311
+ throw error;
312
+ }
313
+ }
314
+ return apiResponse.raw;
315
+ }
316
+ };
317
+
318
+ // src/client/JsonApiClient.ts
319
+ var _clientConfig = null;
320
+ function configureClientJsonApi(config) {
321
+ _clientConfig = config;
322
+ if (config.bootstrapper) {
323
+ config.bootstrapper();
324
+ }
325
+ }
326
+ _chunk7QVYU63Ejs.__name.call(void 0, configureClientJsonApi, "configureClientJsonApi");
327
+ function getClientApiUrl() {
328
+ if (_optionalChain([_clientConfig, 'optionalAccess', _11 => _11.apiUrl])) {
329
+ return _clientConfig.apiUrl;
330
+ }
331
+ const envUrl = process.env.NEXT_PUBLIC_API_URL;
332
+ if (!envUrl) {
333
+ throw new Error("API URL not configured. Use configureClientJsonApi() or set NEXT_PUBLIC_API_URL environment variable.");
334
+ }
335
+ return envUrl;
336
+ }
337
+ _chunk7QVYU63Ejs.__name.call(void 0, getClientApiUrl, "getClientApiUrl");
338
+ function getClientAppUrl() {
339
+ if (_optionalChain([_clientConfig, 'optionalAccess', _12 => _12.appUrl])) {
340
+ return _clientConfig.appUrl;
341
+ }
342
+ const envUrl = process.env.NEXT_PUBLIC_ADDRESS;
343
+ if (!envUrl) {
344
+ throw new Error("App URL not configured. Use configureClientJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable.");
345
+ }
346
+ return envUrl.trim().replace(/\/+$/, "");
347
+ }
348
+ _chunk7QVYU63Ejs.__name.call(void 0, getClientAppUrl, "getClientAppUrl");
349
+ function getClientTrackablePages() {
350
+ return _nullishCoalesce(_optionalChain([_clientConfig, 'optionalAccess', _13 => _13.trackablePages]), () => ( []));
351
+ }
352
+ _chunk7QVYU63Ejs.__name.call(void 0, getClientTrackablePages, "getClientTrackablePages");
353
+ function runClientBootstrapper() {
354
+ if (_optionalChain([_clientConfig, 'optionalAccess', _14 => _14.bootstrapper])) {
355
+ _clientConfig.bootstrapper();
356
+ }
357
+ }
358
+ _chunk7QVYU63Ejs.__name.call(void 0, runClientBootstrapper, "runClientBootstrapper");
359
+ function buildClientUrl(endpoint) {
360
+ const apiUrl = getClientApiUrl();
361
+ return endpoint.startsWith("http") ? endpoint : `${apiUrl}${endpoint}`;
362
+ }
363
+ _chunk7QVYU63Ejs.__name.call(void 0, buildClientUrl, "buildClientUrl");
364
+ async function ClientJsonApiGet(params) {
365
+ runClientBootstrapper();
366
+ const token = await _chunkLXKSUWAVjs.getClientToken.call(void 0, );
367
+ const apiResponse = await _chunkIBS6NI7Djs.directFetch.call(void 0, {
368
+ method: "GET",
369
+ url: buildClientUrl(params.endpoint),
370
+ token,
371
+ companyId: params.companyId,
372
+ language: params.language,
373
+ additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _15 => _15.additionalHeaders])
374
+ });
375
+ return _chunkAGAJMJ4Tjs.translateResponse.call(void 0, {
376
+ classKey: params.classKey,
377
+ apiResponse,
378
+ companyId: params.companyId,
379
+ language: params.language,
380
+ paginationHandler: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (endpoint) => ClientJsonApiGet({
381
+ classKey: params.classKey,
382
+ endpoint,
383
+ companyId: params.companyId,
384
+ language: params.language
385
+ }), "paginationHandler")
386
+ });
387
+ }
388
+ _chunk7QVYU63Ejs.__name.call(void 0, ClientJsonApiGet, "ClientJsonApiGet");
389
+ async function ClientJsonApiPost(params) {
390
+ runClientBootstrapper();
391
+ const token = await _chunkLXKSUWAVjs.getClientToken.call(void 0, );
392
+ let body = params.body;
393
+ if (!body) {
394
+ body = {};
395
+ } else if (params.overridesJsonApiCreation !== true) {
396
+ body = _chunkAGAJMJ4Tjs.JsonApiDataFactory.create(params.classKey, body);
397
+ }
398
+ const apiResponse = await _chunkIBS6NI7Djs.directFetch.call(void 0, {
399
+ method: "POST",
400
+ url: buildClientUrl(params.endpoint),
401
+ token,
402
+ body,
403
+ files: params.files,
404
+ companyId: params.companyId,
405
+ language: params.language,
406
+ additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _16 => _16.additionalHeaders])
407
+ });
408
+ return _chunkAGAJMJ4Tjs.translateResponse.call(void 0, {
409
+ classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
410
+ apiResponse,
411
+ companyId: params.companyId,
412
+ language: params.language
413
+ });
414
+ }
415
+ _chunk7QVYU63Ejs.__name.call(void 0, ClientJsonApiPost, "ClientJsonApiPost");
416
+ async function ClientJsonApiPut(params) {
417
+ runClientBootstrapper();
418
+ const token = await _chunkLXKSUWAVjs.getClientToken.call(void 0, );
419
+ let body = params.body;
420
+ if (!body) {
421
+ body = {};
422
+ } else {
423
+ body = _chunkAGAJMJ4Tjs.JsonApiDataFactory.create(params.classKey, body);
424
+ }
425
+ const apiResponse = await _chunkIBS6NI7Djs.directFetch.call(void 0, {
426
+ method: "PUT",
427
+ url: buildClientUrl(params.endpoint),
428
+ token,
429
+ body,
430
+ files: params.files,
431
+ companyId: params.companyId,
432
+ language: params.language,
433
+ additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _17 => _17.additionalHeaders])
434
+ });
435
+ return _chunkAGAJMJ4Tjs.translateResponse.call(void 0, {
436
+ classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
437
+ apiResponse,
438
+ companyId: params.companyId,
439
+ language: params.language
440
+ });
441
+ }
442
+ _chunk7QVYU63Ejs.__name.call(void 0, ClientJsonApiPut, "ClientJsonApiPut");
443
+ async function ClientJsonApiPatch(params) {
444
+ runClientBootstrapper();
445
+ const token = await _chunkLXKSUWAVjs.getClientToken.call(void 0, );
446
+ let body = params.body;
447
+ if (!body) {
448
+ body = {};
449
+ } else if (params.overridesJsonApiCreation !== true) {
450
+ body = _chunkAGAJMJ4Tjs.JsonApiDataFactory.create(params.classKey, body);
451
+ }
452
+ const apiResponse = await _chunkIBS6NI7Djs.directFetch.call(void 0, {
453
+ method: "PATCH",
454
+ url: buildClientUrl(params.endpoint),
455
+ token,
456
+ body,
457
+ files: params.files,
458
+ companyId: params.companyId,
459
+ language: params.language,
460
+ additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _18 => _18.additionalHeaders])
461
+ });
462
+ return _chunkAGAJMJ4Tjs.translateResponse.call(void 0, {
463
+ classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
464
+ apiResponse,
465
+ companyId: params.companyId,
466
+ language: params.language
467
+ });
468
+ }
469
+ _chunk7QVYU63Ejs.__name.call(void 0, ClientJsonApiPatch, "ClientJsonApiPatch");
470
+ async function ClientJsonApiDelete(params) {
471
+ runClientBootstrapper();
472
+ const token = await _chunkLXKSUWAVjs.getClientToken.call(void 0, );
473
+ const apiResponse = await _chunkIBS6NI7Djs.directFetch.call(void 0, {
474
+ method: "DELETE",
475
+ url: buildClientUrl(params.endpoint),
476
+ token,
477
+ companyId: params.companyId,
478
+ language: params.language,
479
+ additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _19 => _19.additionalHeaders])
480
+ });
481
+ return _chunkAGAJMJ4Tjs.translateResponse.call(void 0, {
482
+ classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
483
+ apiResponse,
484
+ companyId: params.companyId,
485
+ language: params.language
486
+ });
487
+ }
488
+ _chunk7QVYU63Ejs.__name.call(void 0, ClientJsonApiDelete, "ClientJsonApiDelete");
489
+
490
+ // src/core/abstracts/ClientAbstractService.ts
491
+ var ClientHttpMethod = /* @__PURE__ */ ((ClientHttpMethod2) => {
492
+ ClientHttpMethod2["GET"] = "GET";
493
+ ClientHttpMethod2["POST"] = "POST";
494
+ ClientHttpMethod2["PUT"] = "PUT";
495
+ ClientHttpMethod2["PATCH"] = "PATCH";
496
+ ClientHttpMethod2["DELETE"] = "DELETE";
497
+ return ClientHttpMethod2;
498
+ })(ClientHttpMethod || {});
499
+ var globalErrorHandler2 = null;
500
+ function setClientGlobalErrorHandler(handler) {
501
+ globalErrorHandler2 = handler;
502
+ }
503
+ _chunk7QVYU63Ejs.__name.call(void 0, setClientGlobalErrorHandler, "setClientGlobalErrorHandler");
504
+ function getClientGlobalErrorHandler() {
505
+ return globalErrorHandler2;
506
+ }
507
+ _chunk7QVYU63Ejs.__name.call(void 0, getClientGlobalErrorHandler, "getClientGlobalErrorHandler");
508
+ var ClientAbstractService = class {
509
+ static {
510
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "ClientAbstractService");
511
+ }
512
+ /**
513
+ * Extract locale from client-side URL pathname
514
+ * URL structure: /{locale}/route-path (e.g., /it/accounts)
515
+ * Fallback chain: URL locale → navigator.language → "en"
516
+ */
517
+ static getClientLocale() {
518
+ if (typeof window === "undefined") {
519
+ return "en";
520
+ }
521
+ const pathSegments = window.location.pathname.split("/").filter(Boolean);
522
+ const urlLocale = pathSegments[0];
523
+ const supportedLocales = ["en"];
524
+ if (urlLocale && supportedLocales.includes(urlLocale)) {
525
+ return urlLocale;
526
+ }
527
+ const navigatorLocale = navigator.language.split("-")[0];
528
+ if (navigatorLocale && supportedLocales.includes(navigatorLocale)) {
529
+ return navigatorLocale;
530
+ }
531
+ return "en";
532
+ }
533
+ /**
534
+ * Fetch the next page of results.
535
+ */
536
+ static async next(params) {
537
+ return await this.callApi({
538
+ method: "GET" /* GET */,
539
+ type: params.type,
540
+ endpoint: params.endpoint,
541
+ next: params.next,
542
+ previous: params.previous,
543
+ self: params.self
544
+ });
545
+ }
546
+ /**
547
+ * Fetch the previous page of results.
548
+ */
549
+ static async previous(params) {
550
+ return await this.callApi({
551
+ method: "GET" /* GET */,
552
+ type: params.type,
553
+ endpoint: params.endpoint,
554
+ next: params.next,
555
+ previous: params.previous,
556
+ self: params.self
557
+ });
558
+ }
559
+ /**
560
+ * Make a client-side API call.
561
+ */
562
+ static async callApi(params) {
563
+ let apiResponse;
564
+ const language = this.getClientLocale();
565
+ switch (params.method) {
566
+ case "GET" /* GET */:
567
+ apiResponse = await ClientJsonApiGet({
568
+ classKey: params.type,
569
+ endpoint: params.endpoint,
570
+ companyId: params.companyId,
571
+ language
572
+ });
573
+ break;
574
+ case "POST" /* POST */:
575
+ apiResponse = await ClientJsonApiPost({
576
+ classKey: params.type,
577
+ endpoint: params.endpoint,
578
+ companyId: params.companyId,
579
+ body: params.input,
580
+ overridesJsonApiCreation: params.overridesJsonApiCreation,
581
+ language,
582
+ responseType: params.responseType,
583
+ files: params.files
584
+ });
585
+ break;
586
+ case "PUT" /* PUT */:
587
+ apiResponse = await ClientJsonApiPut({
588
+ classKey: params.type,
589
+ endpoint: params.endpoint,
590
+ companyId: params.companyId,
591
+ body: params.input,
592
+ language,
593
+ responseType: params.responseType,
594
+ files: params.files
595
+ });
596
+ break;
597
+ case "PATCH" /* PATCH */:
598
+ apiResponse = await ClientJsonApiPatch({
599
+ classKey: params.type,
600
+ endpoint: params.endpoint,
601
+ companyId: params.companyId,
602
+ body: params.input,
603
+ overridesJsonApiCreation: params.overridesJsonApiCreation,
604
+ language,
605
+ responseType: params.responseType,
606
+ files: params.files
607
+ });
608
+ break;
609
+ case "DELETE" /* DELETE */:
610
+ apiResponse = await ClientJsonApiDelete({
611
+ classKey: params.type,
612
+ endpoint: params.endpoint,
613
+ companyId: params.companyId,
614
+ language,
615
+ responseType: params.responseType
616
+ });
617
+ break;
618
+ default:
619
+ throw new Error("Method not found");
620
+ }
621
+ if (!apiResponse.ok) {
622
+ if (globalErrorHandler2) {
623
+ globalErrorHandler2(apiResponse.response, apiResponse.error);
624
+ return void 0;
625
+ } else {
626
+ const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
627
+ error.status = apiResponse.response;
628
+ error.digest = `HTTP_${apiResponse.response}`;
629
+ throw error;
630
+ }
631
+ }
632
+ if (apiResponse.next && params.next) params.next.next = apiResponse.next;
633
+ if (apiResponse.prev && params.previous) params.previous.previous = apiResponse.prev;
634
+ if (apiResponse.self && params.self) params.self.self = apiResponse.self;
635
+ return apiResponse.data;
636
+ }
637
+ /**
638
+ * Get raw JSON:API response data without deserialization.
639
+ */
640
+ static async getRawData(params) {
641
+ const language = this.getClientLocale();
642
+ const apiResponse = await ClientJsonApiGet({
643
+ classKey: params.type,
644
+ endpoint: params.endpoint,
645
+ companyId: params.companyId,
646
+ language
647
+ });
648
+ if (!apiResponse.ok) {
649
+ if (globalErrorHandler2) {
650
+ globalErrorHandler2(apiResponse.response, apiResponse.error);
651
+ return void 0;
652
+ } else {
653
+ const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
654
+ error.status = apiResponse.response;
655
+ error.digest = `HTTP_${apiResponse.response}`;
656
+ throw error;
657
+ }
658
+ }
659
+ return apiResponse.raw;
660
+ }
661
+ };
662
+
663
+ // src/core/registry/ModuleRegistrar.ts
664
+ var ModuleRegistrar = (_class = class {
665
+ static {
666
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "ModuleRegistrar");
667
+ }
668
+ static __initStatic() {this._isBootstrapped = false}
669
+ /**
670
+ * Bootstrap the registry from a Modules class.
671
+ * Automatically detects static getters and registers their models.
672
+ *
673
+ * @param modulesClass - The Modules class with static getters
674
+ */
675
+ static bootstrap(modulesClass) {
676
+ if (this._isBootstrapped) return;
677
+ const data = Object.getOwnPropertyNames(modulesClass).filter((key) => {
678
+ const descriptor = Object.getOwnPropertyDescriptor(modulesClass, key);
679
+ return descriptor && typeof descriptor.get === "function";
680
+ }).map((key) => modulesClass[key]);
681
+ data.forEach((item) => {
682
+ if (item && item.model) {
683
+ _chunkAGAJMJ4Tjs.DataClassRegistry.registerObjectClass(item, item.model);
684
+ }
685
+ });
686
+ this._isBootstrapped = true;
687
+ }
688
+ /**
689
+ * Reset the bootstrapped state. Useful for testing.
690
+ */
691
+ static reset() {
692
+ this._isBootstrapped = false;
693
+ _chunkAGAJMJ4Tjs.DataClassRegistry.clear();
694
+ }
695
+ }, _class.__initStatic(), _class);
696
+
697
+ // src/core/registry/ModuleRegistry.ts
698
+ var ModuleRegistryClass = (_class2 = class {constructor() { _class2.prototype.__init.call(this); }
699
+ static {
700
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "ModuleRegistryClass");
701
+ }
702
+ __init() {this._modules = /* @__PURE__ */ new Map()}
703
+ register(name, module) {
704
+ this._modules.set(name, module);
705
+ }
706
+ get(name) {
707
+ const module = this._modules.get(name);
708
+ if (!module) {
709
+ throw new Error(`Module "${String(name)}" not registered. Call bootstrap() first.`);
710
+ }
711
+ return module;
712
+ }
713
+ findByName(moduleName) {
714
+ for (const module of this._modules.values()) {
715
+ if (module.name === moduleName) {
716
+ return module;
717
+ }
718
+ }
719
+ throw new Error(`Module not found: ${moduleName}`);
720
+ }
721
+ findByModelName(modelName) {
722
+ const module = this._modules.get(modelName);
723
+ if (!module) {
724
+ throw new Error(`Module not found for model: ${modelName}`);
725
+ }
726
+ return module;
727
+ }
728
+ }, _class2);
729
+ var ModuleRegistry = new ModuleRegistryClass();
730
+ var Modules = new Proxy({}, {
731
+ get(_, prop) {
732
+ if (prop === "findByName") {
733
+ return (name) => ModuleRegistry.findByName(name);
734
+ }
735
+ if (prop === "findByModelName") {
736
+ return (name) => ModuleRegistry.findByModelName(name);
737
+ }
738
+ return ModuleRegistry.get(prop);
739
+ }
740
+ });
741
+
742
+ // src/core/endpoint/EndpointCreator.ts
743
+ var EndpointCreator = class {
744
+ static {
745
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "EndpointCreator");
746
+ }
747
+
748
+ constructor(params) {
749
+ this._endpoint = {
750
+ endpoint: params.endpoint,
751
+ id: params.id,
752
+ childEndpoint: params.childEndpoint,
753
+ childId: params.childId,
754
+ additionalParams: _nullishCoalesce(params.additionalParams, () => ( []))
755
+ };
756
+ }
757
+ endpoint(value) {
758
+ this._endpoint.endpoint = value;
759
+ return this;
760
+ }
761
+ id(value) {
762
+ this._endpoint.id = value;
763
+ return this;
764
+ }
765
+ childEndpoint(value) {
766
+ this._endpoint.childEndpoint = value;
767
+ return this;
768
+ }
769
+ childId(value) {
770
+ this._endpoint.childId = value;
771
+ return this;
772
+ }
773
+ set additionalParams(value) {
774
+ this._endpoint.additionalParams = value;
775
+ }
776
+ addAdditionalParam(key, value) {
777
+ if (!this._endpoint.additionalParams) this._endpoint.additionalParams = [];
778
+ this._endpoint.additionalParams.push({ key, value });
779
+ return this;
780
+ }
781
+ limitToType(selectors) {
782
+ this.addAdditionalParam(`include`, selectors.join(","));
783
+ return this;
784
+ }
785
+ limitToFields(selectors) {
786
+ if (selectors.length === 0) return this;
787
+ selectors.forEach((selector) => {
788
+ const fieldString = selector.fields.join(",");
789
+ this.addAdditionalParam(`fields[${selector.type}]`, fieldString);
790
+ });
791
+ return this;
792
+ }
793
+ generate() {
794
+ let additionalParams = "";
795
+ if (this._endpoint.additionalParams) {
796
+ additionalParams = this._endpoint.additionalParams.map((param) => `${param.key}=${param.value}`).join("&");
797
+ }
798
+ let response = `${this._endpoint.endpoint.name}`;
799
+ if (this._endpoint.id) response += `/${this._endpoint.id}`;
800
+ if (this._endpoint.childEndpoint) {
801
+ response += `/${typeof this._endpoint.childEndpoint === "string" ? this._endpoint.childEndpoint : this._endpoint.childEndpoint.name}`;
802
+ }
803
+ if (this._endpoint.childId) response += `/${this._endpoint.childId}`;
804
+ if (additionalParams) response += `?${additionalParams}`;
805
+ return response;
806
+ }
807
+ };
808
+
809
+ // src/core/fields/FieldSelector.ts
810
+ function createJsonApiInclusion(dataType, fields) {
811
+ return {
812
+ type: dataType,
813
+ fields
814
+ };
815
+ }
816
+ _chunk7QVYU63Ejs.__name.call(void 0, createJsonApiInclusion, "createJsonApiInclusion");
817
+
818
+ // src/core/utils/rehydrate.ts
819
+ function rehydrate(classKey, data) {
820
+ return RehydrationFactory.rehydrate(classKey, data);
821
+ }
822
+ _chunk7QVYU63Ejs.__name.call(void 0, rehydrate, "rehydrate");
823
+ function rehydrateList(classKey, data) {
824
+ return RehydrationFactory.rehydrateList(classKey, data);
825
+ }
826
+ _chunk7QVYU63Ejs.__name.call(void 0, rehydrateList, "rehydrateList");
827
+
828
+ // src/utils/cn.ts
829
+ var _clsx = require('clsx');
830
+ var _tailwindmerge = require('tailwind-merge');
831
+ function cn(...inputs) {
832
+ return _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, inputs));
833
+ }
834
+ _chunk7QVYU63Ejs.__name.call(void 0, cn, "cn");
835
+
836
+ // src/utils/compose-refs.ts
837
+ var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
838
+ function setRef(ref, value) {
839
+ if (typeof ref === "function") {
840
+ return ref(value);
841
+ }
842
+ if (ref !== null && ref !== void 0) {
843
+ ref.current = value;
844
+ }
845
+ }
846
+ _chunk7QVYU63Ejs.__name.call(void 0, setRef, "setRef");
847
+ function composeRefs(...refs) {
848
+ return (node) => {
849
+ let hasCleanup = false;
850
+ const cleanups = refs.map((ref) => {
851
+ const cleanup = setRef(ref, node);
852
+ if (!hasCleanup && typeof cleanup === "function") {
853
+ hasCleanup = true;
854
+ }
855
+ return cleanup;
856
+ });
857
+ if (hasCleanup) {
858
+ return () => {
859
+ for (let i = 0; i < cleanups.length; i++) {
860
+ const cleanup = cleanups[i];
861
+ if (typeof cleanup === "function") {
862
+ cleanup();
863
+ } else {
864
+ setRef(refs[i], null);
865
+ }
866
+ }
867
+ };
868
+ }
869
+ };
870
+ }
871
+ _chunk7QVYU63Ejs.__name.call(void 0, composeRefs, "composeRefs");
872
+ function useComposedRefs(...refs) {
873
+ return React.useCallback(composeRefs(...refs), refs);
874
+ }
875
+ _chunk7QVYU63Ejs.__name.call(void 0, useComposedRefs, "useComposedRefs");
876
+
877
+ // src/utils/use-mobile.tsx
878
+
879
+ var MOBILE_BREAKPOINT = 768;
880
+ function useIsMobile() {
881
+ const [isMobile, setIsMobile] = React2.useState(void 0);
882
+ React2.useEffect(() => {
883
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
884
+ const onChange = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
885
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
886
+ }, "onChange");
887
+ mql.addEventListener("change", onChange);
888
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
889
+ return () => mql.removeEventListener("change", onChange);
890
+ }, []);
891
+ return !!isMobile;
892
+ }
893
+ _chunk7QVYU63Ejs.__name.call(void 0, useIsMobile, "useIsMobile");
894
+
895
+ // src/utils/date-formatter.ts
896
+ var formatDate = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (eventDate, formatOption) => {
897
+ const browserLocale = navigator.language || "en-US";
898
+ const formatPart = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (date, options) => new Intl.DateTimeFormat(browserLocale, options).format(date), "formatPart");
899
+ const now = /* @__PURE__ */ new Date();
900
+ const diff = now.getTime() - eventDate.getTime();
901
+ if (formatOption === "default") {
902
+ if (diff < 24 * 60 * 60 * 1e3) formatOption = "timeSince";
903
+ else formatOption = "dateTime";
904
+ }
905
+ if (formatOption === "timeSince") {
906
+ const seconds = Math.floor(diff / 1e3);
907
+ const minutes = Math.floor(seconds / 60);
908
+ const hours = Math.floor(minutes / 60);
909
+ const days = Math.floor(hours / 24);
910
+ if (days > 0) return `${days} days ago`;
911
+ if (hours > 0) return `${hours} hours ago`;
912
+ if (minutes > 0) return `${minutes} minutes ago`;
913
+ return `${seconds} seconds ago`;
914
+ }
915
+ const dateOptions = {
916
+ year: "numeric",
917
+ month: "2-digit",
918
+ day: "2-digit"
919
+ };
920
+ const timeOptions = {
921
+ hour: "2-digit",
922
+ minute: "2-digit"
923
+ };
924
+ switch (formatOption) {
925
+ case "date":
926
+ return formatPart(eventDate, dateOptions);
927
+ case "time":
928
+ return formatPart(eventDate, timeOptions);
929
+ case "dateTime":
930
+ return `${formatPart(eventDate, dateOptions)} ${formatPart(eventDate, timeOptions)}`;
931
+ default:
932
+ throw new Error("Invalid format option");
933
+ }
934
+ }, "formatDate");
935
+
936
+ // src/utils/exists.ts
937
+ var exists = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (itemOrArray) => {
938
+ if (!itemOrArray) return false;
939
+ if (Array.isArray(itemOrArray)) {
940
+ return itemOrArray.length > 0;
941
+ }
942
+ return true;
943
+ }, "exists");
944
+
945
+ // src/utils/table-options.ts
946
+
947
+ var TableOptions = class {
948
+ static {
949
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "TableOptions");
950
+ }
951
+
952
+
953
+ constructor(hasPermissionToModule) {
954
+ this._hasPermissionToModule = hasPermissionToModule;
955
+ this._components = [];
956
+ }
957
+ addOption(component, module, action) {
958
+ if (!component || module && action && !this._hasPermissionToModule({ module, action })) return;
959
+ this._components.push(component);
960
+ }
961
+ getComponents() {
962
+ return this._components;
963
+ }
964
+ getOptions() {
965
+ if (this._components.length === 0) return null;
966
+ const response = this._components.map(
967
+ (option, index) => _react.cloneElement.call(void 0, option, { key: _nullishCoalesce(option.key, () => ( index)) })
968
+ );
969
+ return _react.createElement.call(void 0, _react.Fragment, {}, response);
970
+ }
971
+ };
972
+ function getTableOptions(params) {
973
+ const tableOptions = new TableOptions(params.hasPermissionToModule);
974
+ params.options.forEach((option) => tableOptions.addOption(option.component, option.module, option.action));
975
+ return tableOptions.getOptions();
976
+ }
977
+ _chunk7QVYU63Ejs.__name.call(void 0, getTableOptions, "getTableOptions");
978
+ function getTableComponents(params) {
979
+ const tableOptions = new TableOptions(params.hasPermissionToModule);
980
+ params.options.forEach((option) => tableOptions.addOption(option.component, option.module, option.action));
981
+ return tableOptions.getComponents();
982
+ }
983
+ _chunk7QVYU63Ejs.__name.call(void 0, getTableComponents, "getTableComponents");
984
+
985
+ // src/utils/schemas/user.object.schema.ts
986
+ var _zod = require('zod');
987
+ var userObjectSchema = _zod.z.object({
988
+ id: _zod.z.string(),
989
+ name: _zod.z.string(),
990
+ avatar: _zod.z.string().optional()
991
+ });
992
+
993
+ // src/utils/schemas/entity.object.schema.ts
994
+
995
+ var entityObjectSchema = _zod.z.object({
996
+ id: _zod.z.uuidv4(),
997
+ name: _zod.z.string()
998
+ });
999
+
1000
+ // src/utils/blocknote-diff.util.ts
1001
+ var BlockNoteDiffUtil = (_class3 = class {
1002
+ static {
1003
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "BlockNoteDiffUtil");
1004
+ }
1005
+ static __initStatic2() {this.DEFAULT_OPTIONS = {
1006
+ ignoreIds: false,
1007
+ compareContent: true,
1008
+ similarityThreshold: 0.8
1009
+ }}
1010
+ /**
1011
+ * Compare two BlockNote documents and return diff result
1012
+ */
1013
+ static diff(originalBlocks = [], newBlocks = [], options = {}) {
1014
+ const opts = { ...this.DEFAULT_OPTIONS, ...options };
1015
+ const originalMap = /* @__PURE__ */ new Map();
1016
+ const newMap = /* @__PURE__ */ new Map();
1017
+ originalBlocks.forEach((block) => {
1018
+ if (block.id) {
1019
+ originalMap.set(block.id, block);
1020
+ }
1021
+ });
1022
+ newBlocks.forEach((block) => {
1023
+ if (block.id) {
1024
+ newMap.set(block.id, block);
1025
+ }
1026
+ });
1027
+ const diffBlocks = [];
1028
+ const processedNewIds = /* @__PURE__ */ new Set();
1029
+ for (const originalBlock of originalBlocks) {
1030
+ const blockId = originalBlock.id;
1031
+ const processId = blockId || crypto.randomUUID();
1032
+ const newBlock = blockId ? newMap.get(blockId) : null;
1033
+ if (!newBlock) {
1034
+ const removedBlock = {
1035
+ ...originalBlock,
1036
+ id: processId,
1037
+ diffType: "removed",
1038
+ diffId: `removed-${processId}`
1039
+ };
1040
+ diffBlocks.push(removedBlock);
1041
+ } else {
1042
+ if (blockId) {
1043
+ processedNewIds.add(blockId);
1044
+ }
1045
+ if (this.areBlocksEqual(originalBlock, newBlock, opts)) {
1046
+ const unchangedBlock = {
1047
+ ...newBlock,
1048
+ diffType: "unchanged"
1049
+ };
1050
+ diffBlocks.push(unchangedBlock);
1051
+ } else {
1052
+ const wordDiffs = this.generateWordDiffs(originalBlock.content, newBlock.content, processId);
1053
+ const modifiedBlock = {
1054
+ ...newBlock,
1055
+ diffType: "modified",
1056
+ originalContent: originalBlock.content,
1057
+ diffId: `modified-${processId}`,
1058
+ wordDiffs
1059
+ };
1060
+ diffBlocks.push(modifiedBlock);
1061
+ }
1062
+ }
1063
+ }
1064
+ for (const newBlock of newBlocks) {
1065
+ const blockId = newBlock.id;
1066
+ if (blockId && processedNewIds.has(blockId)) continue;
1067
+ const generatedId = blockId || crypto.randomUUID();
1068
+ const addedBlock = {
1069
+ ...newBlock,
1070
+ id: generatedId,
1071
+ diffType: "added",
1072
+ diffId: `added-${generatedId}`
1073
+ };
1074
+ diffBlocks.push(addedBlock);
1075
+ }
1076
+ const sortedDiffBlocks = this.sortDiffBlocks(diffBlocks, originalBlocks, newBlocks);
1077
+ return {
1078
+ blocks: sortedDiffBlocks,
1079
+ hasChanges: sortedDiffBlocks.some((block) => block.diffType !== "unchanged")
1080
+ };
1081
+ }
1082
+ /**
1083
+ * Compare two blocks for equality
1084
+ */
1085
+ static areBlocksEqual(block1, block2, options) {
1086
+ if (block1.type !== block2.type) {
1087
+ return false;
1088
+ }
1089
+ if (!this.deepEqual(block1.props, block2.props)) {
1090
+ return false;
1091
+ }
1092
+ if (options.compareContent) {
1093
+ if (!this.deepEqual(block1.content, block2.content)) {
1094
+ return false;
1095
+ }
1096
+ }
1097
+ const children1 = block1.children || [];
1098
+ const children2 = block2.children || [];
1099
+ if (children1.length !== children2.length) {
1100
+ return false;
1101
+ }
1102
+ for (let i = 0; i < children1.length; i++) {
1103
+ if (!this.areBlocksEqual(children1[i], children2[i], options)) {
1104
+ return false;
1105
+ }
1106
+ }
1107
+ return true;
1108
+ }
1109
+ /**
1110
+ * Deep equality comparison for objects
1111
+ */
1112
+ static deepEqual(obj1, obj2) {
1113
+ if (obj1 === obj2) return true;
1114
+ if (obj1 == null || obj2 == null) return obj1 === obj2;
1115
+ if (typeof obj1 !== typeof obj2) return false;
1116
+ if (typeof obj1 !== "object") return obj1 === obj2;
1117
+ if (Array.isArray(obj1) !== Array.isArray(obj2)) return false;
1118
+ if (Array.isArray(obj1)) {
1119
+ if (obj1.length !== obj2.length) return false;
1120
+ for (let i = 0; i < obj1.length; i++) {
1121
+ if (!this.deepEqual(obj1[i], obj2[i])) return false;
1122
+ }
1123
+ return true;
1124
+ }
1125
+ const keys1 = Object.keys(obj1);
1126
+ const keys2 = Object.keys(obj2);
1127
+ if (keys1.length !== keys2.length) return false;
1128
+ for (const key of keys1) {
1129
+ if (!keys2.includes(key)) return false;
1130
+ if (!this.deepEqual(obj1[key], obj2[key])) return false;
1131
+ }
1132
+ return true;
1133
+ }
1134
+ /**
1135
+ * Sort diff blocks to maintain logical order
1136
+ */
1137
+ static sortDiffBlocks(diffBlocks, originalBlocks, newBlocks) {
1138
+ const originalPositions = /* @__PURE__ */ new Map();
1139
+ const newPositions = /* @__PURE__ */ new Map();
1140
+ originalBlocks.forEach((block, index) => {
1141
+ if (block.id) {
1142
+ originalPositions.set(block.id, index);
1143
+ }
1144
+ });
1145
+ newBlocks.forEach((block, index) => {
1146
+ if (block.id) {
1147
+ newPositions.set(block.id, index);
1148
+ }
1149
+ });
1150
+ return diffBlocks.sort((a, b) => {
1151
+ const aId = a.id;
1152
+ const bId = b.id;
1153
+ if (!aId || !bId) return 0;
1154
+ const aPos = _nullishCoalesce(_nullishCoalesce(newPositions.get(aId), () => ( originalPositions.get(aId))), () => ( Infinity));
1155
+ const bPos = _nullishCoalesce(_nullishCoalesce(newPositions.get(bId), () => ( originalPositions.get(bId))), () => ( Infinity));
1156
+ return aPos - bPos;
1157
+ });
1158
+ }
1159
+ /**
1160
+ * Calculate similarity between two text contents
1161
+ */
1162
+ static calculateSimilarity(content1, content2) {
1163
+ if (!content1 || !content2) return 0;
1164
+ const text1 = this.extractTextFromContent(content1);
1165
+ const text2 = this.extractTextFromContent(content2);
1166
+ if (text1 === text2) return 1;
1167
+ if (!text1 || !text2) return 0;
1168
+ const maxLength = Math.max(text1.length, text2.length);
1169
+ const distance = this.levenshteinDistance(text1, text2);
1170
+ return 1 - distance / maxLength;
1171
+ }
1172
+ /**
1173
+ * Extract plain text from BlockNote content array
1174
+ */
1175
+ static extractTextFromContent(content) {
1176
+ if (!Array.isArray(content)) return "";
1177
+ return content.map((item) => {
1178
+ if (item.type === "text") {
1179
+ return item.text || "";
1180
+ }
1181
+ return "";
1182
+ }).join("");
1183
+ }
1184
+ /**
1185
+ * Calculate Levenshtein distance between two strings
1186
+ */
1187
+ static levenshteinDistance(str1, str2) {
1188
+ const matrix = Array(str2.length + 1).fill(null).map(() => Array(str1.length + 1).fill(null));
1189
+ for (let i = 0; i <= str1.length; i++) {
1190
+ matrix[0][i] = i;
1191
+ }
1192
+ for (let j = 0; j <= str2.length; j++) {
1193
+ matrix[j][0] = j;
1194
+ }
1195
+ for (let j = 1; j <= str2.length; j++) {
1196
+ for (let i = 1; i <= str1.length; i++) {
1197
+ const substitutionCost = str1[i - 1] === str2[j - 1] ? 0 : 1;
1198
+ matrix[j][i] = Math.min(
1199
+ matrix[j][i - 1] + 1,
1200
+ // deletion
1201
+ matrix[j - 1][i] + 1,
1202
+ // insertion
1203
+ matrix[j - 1][i - 1] + substitutionCost
1204
+ // substitution
1205
+ );
1206
+ }
1207
+ }
1208
+ return matrix[str2.length][str1.length];
1209
+ }
1210
+ /**
1211
+ * Generate word-level diffs between two content arrays
1212
+ */
1213
+ static generateWordDiffs(originalContent, newContent, blockId) {
1214
+ const originalText = this.extractTextFromContent(originalContent || []);
1215
+ const newText = this.extractTextFromContent(newContent || []);
1216
+ if (!originalText && !newText) return [];
1217
+ if (!originalText) {
1218
+ return newText.split(/\s+/).filter((word) => word.trim()).map((word, index) => ({
1219
+ type: "added",
1220
+ text: word,
1221
+ diffId: `${blockId}-add-${index}`,
1222
+ accepted: false,
1223
+ rejected: false
1224
+ }));
1225
+ }
1226
+ if (!newText) {
1227
+ return originalText.split(/\s+/).filter((word) => word.trim()).map((word, index) => ({
1228
+ type: "removed",
1229
+ text: word,
1230
+ diffId: `${blockId}-remove-${index}`,
1231
+ accepted: false,
1232
+ rejected: false
1233
+ }));
1234
+ }
1235
+ return this.diffWords(originalText, newText, blockId);
1236
+ }
1237
+ /**
1238
+ * Perform word-level diff using word-only approach (no space tokenization)
1239
+ */
1240
+ static diffWords(text1, text2, blockId) {
1241
+ const words1 = text1.split(/\s+/).filter((word) => word.length > 0);
1242
+ const words2 = text2.split(/\s+/).filter((word) => word.length > 0);
1243
+ const diffs = this.myersDiff(words1, words2);
1244
+ const consolidatedDiffs = this.consolidateAdjacentChanges(diffs);
1245
+ const result = [];
1246
+ let diffIndex = 0;
1247
+ for (let i = 0; i < consolidatedDiffs.length; i++) {
1248
+ const diff = consolidatedDiffs[i];
1249
+ const isLastDiff = i === consolidatedDiffs.length - 1;
1250
+ switch (diff.type) {
1251
+ case "equal":
1252
+ result.push({
1253
+ type: "unchanged",
1254
+ text: diff.value,
1255
+ diffId: `${blockId}-unchanged-${diffIndex++}`,
1256
+ accepted: true,
1257
+ rejected: false
1258
+ });
1259
+ if (!isLastDiff) {
1260
+ result.push({
1261
+ type: "unchanged",
1262
+ text: " ",
1263
+ diffId: `${blockId}-space-${diffIndex++}`,
1264
+ accepted: true,
1265
+ rejected: false
1266
+ });
1267
+ }
1268
+ break;
1269
+ case "delete":
1270
+ if (diff.consolidated) {
1271
+ const nextDiff = i + 1 < consolidatedDiffs.length ? consolidatedDiffs[i + 1] : null;
1272
+ const isConsolidatedReplacement = nextDiff && nextDiff.type === "insert" && nextDiff.consolidated;
1273
+ if (isConsolidatedReplacement) {
1274
+ const replacementId = `${blockId}-replace-${diffIndex++}`;
1275
+ result.push({
1276
+ type: "removed",
1277
+ text: diff.value,
1278
+ diffId: replacementId,
1279
+ accepted: false,
1280
+ rejected: false
1281
+ });
1282
+ result.push({
1283
+ type: "added",
1284
+ text: nextDiff.value,
1285
+ diffId: replacementId,
1286
+ accepted: false,
1287
+ rejected: false
1288
+ });
1289
+ i++;
1290
+ if (i < consolidatedDiffs.length - 1) {
1291
+ result.push({
1292
+ type: "unchanged",
1293
+ text: " ",
1294
+ diffId: `${blockId}-space-${diffIndex++}`,
1295
+ accepted: true,
1296
+ rejected: false
1297
+ });
1298
+ }
1299
+ } else {
1300
+ result.push({
1301
+ type: "removed",
1302
+ text: diff.value,
1303
+ diffId: `${blockId}-remove-${diffIndex++}`,
1304
+ accepted: false,
1305
+ rejected: false
1306
+ });
1307
+ if (!isLastDiff) {
1308
+ result.push({
1309
+ type: "unchanged",
1310
+ text: " ",
1311
+ diffId: `${blockId}-space-${diffIndex++}`,
1312
+ accepted: true,
1313
+ rejected: false
1314
+ });
1315
+ }
1316
+ }
1317
+ } else {
1318
+ const nextDiff = i + 1 < consolidatedDiffs.length ? consolidatedDiffs[i + 1] : null;
1319
+ const isReplacement = nextDiff && nextDiff.type === "insert" && this.areWordsSimilar(diff.value, nextDiff.value);
1320
+ if (isReplacement) {
1321
+ const replacementId = `${blockId}-replace-${diffIndex++}`;
1322
+ result.push({
1323
+ type: "removed",
1324
+ text: diff.value,
1325
+ diffId: replacementId,
1326
+ accepted: false,
1327
+ rejected: false
1328
+ });
1329
+ result.push({
1330
+ type: "added",
1331
+ text: nextDiff.value,
1332
+ diffId: replacementId,
1333
+ accepted: false,
1334
+ rejected: false
1335
+ });
1336
+ i++;
1337
+ if (i < consolidatedDiffs.length - 1) {
1338
+ result.push({
1339
+ type: "unchanged",
1340
+ text: " ",
1341
+ diffId: `${blockId}-space-${diffIndex++}`,
1342
+ accepted: true,
1343
+ rejected: false
1344
+ });
1345
+ }
1346
+ } else {
1347
+ result.push({
1348
+ type: "removed",
1349
+ text: diff.value,
1350
+ diffId: `${blockId}-remove-${diffIndex++}`,
1351
+ accepted: false,
1352
+ rejected: false
1353
+ });
1354
+ if (!isLastDiff) {
1355
+ result.push({
1356
+ type: "unchanged",
1357
+ text: " ",
1358
+ diffId: `${blockId}-space-${diffIndex++}`,
1359
+ accepted: true,
1360
+ rejected: false
1361
+ });
1362
+ }
1363
+ }
1364
+ }
1365
+ break;
1366
+ case "insert":
1367
+ if (diff.consolidated) {
1368
+ const prevDiff = i > 0 ? consolidatedDiffs[i - 1] : null;
1369
+ const wasProcessedAsConsolidatedReplacement = prevDiff && prevDiff.type === "delete" && prevDiff.consolidated;
1370
+ if (!wasProcessedAsConsolidatedReplacement) {
1371
+ result.push({
1372
+ type: "added",
1373
+ text: diff.value,
1374
+ diffId: `${blockId}-add-${diffIndex++}`,
1375
+ accepted: false,
1376
+ rejected: false
1377
+ });
1378
+ if (!isLastDiff) {
1379
+ result.push({
1380
+ type: "unchanged",
1381
+ text: " ",
1382
+ diffId: `${blockId}-space-${diffIndex++}`,
1383
+ accepted: true,
1384
+ rejected: false
1385
+ });
1386
+ }
1387
+ }
1388
+ } else {
1389
+ const prevDiff = i > 0 ? consolidatedDiffs[i - 1] : null;
1390
+ const wasProcessedAsReplacement = prevDiff && prevDiff.type === "delete" && this.areWordsSimilar(prevDiff.value, diff.value);
1391
+ if (!wasProcessedAsReplacement) {
1392
+ result.push({
1393
+ type: "added",
1394
+ text: diff.value,
1395
+ diffId: `${blockId}-add-${diffIndex++}`,
1396
+ accepted: false,
1397
+ rejected: false
1398
+ });
1399
+ if (!isLastDiff) {
1400
+ result.push({
1401
+ type: "unchanged",
1402
+ text: " ",
1403
+ diffId: `${blockId}-space-${diffIndex++}`,
1404
+ accepted: true,
1405
+ rejected: false
1406
+ });
1407
+ }
1408
+ }
1409
+ }
1410
+ break;
1411
+ }
1412
+ }
1413
+ return result;
1414
+ }
1415
+ /**
1416
+ * Improved diff algorithm that better handles word insertions
1417
+ * Uses a combination of LCS and heuristics to minimize false changes
1418
+ */
1419
+ static myersDiff(a, b) {
1420
+ if (a.length === 0) {
1421
+ return b.map((value) => ({ type: "insert", value }));
1422
+ }
1423
+ if (b.length === 0) {
1424
+ return a.map((value) => ({ type: "delete", value }));
1425
+ }
1426
+ const dp = this.computeEditScript(a, b);
1427
+ return this.reconstructDiff(a, b, dp);
1428
+ }
1429
+ /**
1430
+ * Compute edit script using dynamic programming
1431
+ */
1432
+ static computeEditScript(a, b) {
1433
+ const m = a.length;
1434
+ const n = b.length;
1435
+ const dp = Array(m + 1).fill(null).map(() => Array(n + 1).fill(0));
1436
+ for (let i = 0; i <= m; i++) dp[i][0] = i;
1437
+ for (let j = 0; j <= n; j++) dp[0][j] = j;
1438
+ for (let i = 1; i <= m; i++) {
1439
+ for (let j = 1; j <= n; j++) {
1440
+ if (a[i - 1] === b[j - 1]) {
1441
+ dp[i][j] = dp[i - 1][j - 1];
1442
+ } else {
1443
+ dp[i][j] = 1 + Math.min(
1444
+ dp[i - 1][j],
1445
+ // Delete from a
1446
+ dp[i][j - 1],
1447
+ // Insert into a
1448
+ dp[i - 1][j - 1]
1449
+ // Replace
1450
+ );
1451
+ }
1452
+ }
1453
+ }
1454
+ return dp;
1455
+ }
1456
+ /**
1457
+ * Reconstruct the actual diff from the DP table
1458
+ */
1459
+ static reconstructDiff(a, b, dp) {
1460
+ const result = [];
1461
+ let i = a.length;
1462
+ let j = b.length;
1463
+ while (i > 0 || j > 0) {
1464
+ if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
1465
+ result.unshift({ type: "equal", value: a[i - 1] });
1466
+ i--;
1467
+ j--;
1468
+ } else {
1469
+ const deleteCost = i > 0 ? dp[i - 1][j] : Infinity;
1470
+ const insertCost = j > 0 ? dp[i][j - 1] : Infinity;
1471
+ const replaceCost = i > 0 && j > 0 ? dp[i - 1][j - 1] : Infinity;
1472
+ const minCost = Math.min(deleteCost, insertCost, replaceCost);
1473
+ if (minCost === insertCost && j > 0) {
1474
+ result.unshift({ type: "insert", value: b[j - 1] });
1475
+ j--;
1476
+ } else if (minCost === deleteCost && i > 0) {
1477
+ result.unshift({ type: "delete", value: a[i - 1] });
1478
+ i--;
1479
+ } else if (minCost === replaceCost && i > 0 && j > 0) {
1480
+ if (this.areWordsSimilar(a[i - 1], b[j - 1])) {
1481
+ result.unshift({ type: "insert", value: b[j - 1], sharedDiffId: true });
1482
+ result.unshift({ type: "delete", value: a[i - 1], sharedDiffId: true });
1483
+ i--;
1484
+ j--;
1485
+ } else {
1486
+ result.unshift({ type: "insert", value: b[j - 1] });
1487
+ j--;
1488
+ }
1489
+ }
1490
+ }
1491
+ }
1492
+ return result;
1493
+ }
1494
+ /**
1495
+ * Consolidate adjacent changes to reduce fragmentation
1496
+ * e.g., if we have: delete "Key", insert "Key!", delete "Challenges"
1497
+ * We can consolidate this into: replace ["Key", "Challenges"] with ["Key!"]
1498
+ */
1499
+ static consolidateAdjacentChanges(diffs) {
1500
+ const result = [];
1501
+ let i = 0;
1502
+ while (i < diffs.length) {
1503
+ const current = diffs[i];
1504
+ if (current.type === "equal") {
1505
+ result.push(current);
1506
+ i++;
1507
+ continue;
1508
+ }
1509
+ const changeSequence = [];
1510
+ let j = i;
1511
+ while (j < diffs.length && diffs[j].type !== "equal") {
1512
+ changeSequence.push(diffs[j]);
1513
+ j++;
1514
+ }
1515
+ if (changeSequence.length <= 1) {
1516
+ result.push(current);
1517
+ i++;
1518
+ continue;
1519
+ }
1520
+ const shouldConsolidate = this.shouldConsolidateChanges(
1521
+ changeSequence
1522
+ );
1523
+ if (shouldConsolidate) {
1524
+ const deletedWords = changeSequence.filter((c) => c.type === "delete").map((c) => c.value);
1525
+ const insertedWords = changeSequence.filter((c) => c.type === "insert").map((c) => c.value);
1526
+ if (deletedWords.length > 0) {
1527
+ result.push({
1528
+ type: "delete",
1529
+ value: deletedWords.join(" "),
1530
+ consolidated: true
1531
+ });
1532
+ }
1533
+ if (insertedWords.length > 0) {
1534
+ result.push({
1535
+ type: "insert",
1536
+ value: insertedWords.join(" "),
1537
+ consolidated: true
1538
+ });
1539
+ }
1540
+ } else {
1541
+ changeSequence.forEach((change) => result.push(change));
1542
+ }
1543
+ i = j;
1544
+ }
1545
+ return result;
1546
+ }
1547
+ /**
1548
+ * Determine if a sequence of changes should be consolidated
1549
+ */
1550
+ static shouldConsolidateChanges(changes) {
1551
+ const hasDeletes = changes.some((c) => c.type === "delete");
1552
+ const hasInserts = changes.some((c) => c.type === "insert");
1553
+ return hasDeletes && hasInserts;
1554
+ }
1555
+ /**
1556
+ * Check if two words are similar enough to be considered a replacement
1557
+ */
1558
+ static areWordsSimilar(word1, word2) {
1559
+ if (word1 === word2) return true;
1560
+ const maxLen = Math.max(word1.length, word2.length);
1561
+ const minLen = Math.min(word1.length, word2.length);
1562
+ if (maxLen > minLen * 2) {
1563
+ return false;
1564
+ }
1565
+ const word1Clean = word1.replace(/[^\w]/g, "");
1566
+ const word2Clean = word2.replace(/[^\w]/g, "");
1567
+ if (word1Clean === word2Clean && word1 !== word2) {
1568
+ return false;
1569
+ }
1570
+ const distance = this.levenshteinDistance(word1, word2);
1571
+ const similarity = 1 - distance / maxLen;
1572
+ return similarity > 0.7;
1573
+ }
1574
+ }, _class3.__initStatic2(), _class3);
1575
+
1576
+ // src/utils/blocknote-word-diff-renderer.util.ts
1577
+ var BlockNoteWordDiffRendererUtil = class {
1578
+ static {
1579
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "BlockNoteWordDiffRendererUtil");
1580
+ }
1581
+ static renderWordDiffs(diffBlocks, onAcceptChange, onRejectChange, acceptedChanges, rejectedChanges) {
1582
+ if (acceptedChanges || rejectedChanges) {
1583
+ diffBlocks = this.updateWordDiffStates(diffBlocks, acceptedChanges, rejectedChanges);
1584
+ }
1585
+ return diffBlocks.map((block) => this.renderDiffBlock(block, onAcceptChange, onRejectChange));
1586
+ }
1587
+ static updateWordDiffStates(diffBlocks, acceptedChanges, rejectedChanges) {
1588
+ return diffBlocks.map((block) => {
1589
+ const updatedBlock = { ...block };
1590
+ if (updatedBlock.diffId) {
1591
+ updatedBlock.accepted = _optionalChain([acceptedChanges, 'optionalAccess', _20 => _20.has, 'call', _21 => _21(updatedBlock.diffId)]) || false;
1592
+ updatedBlock.rejected = _optionalChain([rejectedChanges, 'optionalAccess', _22 => _22.has, 'call', _23 => _23(updatedBlock.diffId)]) || false;
1593
+ }
1594
+ if (updatedBlock.wordDiffs) {
1595
+ updatedBlock.wordDiffs = updatedBlock.wordDiffs.map((wordDiff) => ({
1596
+ ...wordDiff,
1597
+ accepted: _optionalChain([acceptedChanges, 'optionalAccess', _24 => _24.has, 'call', _25 => _25(wordDiff.diffId)]) || false,
1598
+ rejected: _optionalChain([rejectedChanges, 'optionalAccess', _26 => _26.has, 'call', _27 => _27(wordDiff.diffId)]) || false
1599
+ }));
1600
+ }
1601
+ if (updatedBlock.children) {
1602
+ updatedBlock.children = this.updateWordDiffStates(
1603
+ updatedBlock.children,
1604
+ acceptedChanges,
1605
+ rejectedChanges
1606
+ );
1607
+ }
1608
+ return updatedBlock;
1609
+ });
1610
+ }
1611
+ static renderDiffBlock(block, onAcceptChange, onRejectChange) {
1612
+ if (block.diffType === "modified" && block.wordDiffs) {
1613
+ return this.renderWordLevelDiff(block, onAcceptChange, onRejectChange);
1614
+ }
1615
+ if (block.diffType === "added" || block.diffType === "removed") {
1616
+ return this.renderBlockLevelDiff(block, onAcceptChange, onRejectChange);
1617
+ }
1618
+ const baseBlock = {
1619
+ id: block.id || crypto.randomUUID(),
1620
+ type: block.type || "paragraph",
1621
+ props: this.getBlockProps(block),
1622
+ content: Array.isArray(block.content) ? block.content : [],
1623
+ children: _optionalChain([block, 'access', _28 => _28.children, 'optionalAccess', _29 => _29.map, 'call', _30 => _30(
1624
+ (child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
1625
+ )])
1626
+ };
1627
+ return baseBlock;
1628
+ }
1629
+ static renderBlockLevelDiff(block, onAcceptChange, onRejectChange) {
1630
+ if (!block.diffId) {
1631
+ return {
1632
+ id: block.id || crypto.randomUUID(),
1633
+ type: block.type || "paragraph",
1634
+ props: block.props || {},
1635
+ content: Array.isArray(block.content) ? block.content : [],
1636
+ children: _optionalChain([block, 'access', _31 => _31.children, 'optionalAccess', _32 => _32.map, 'call', _33 => _33(
1637
+ (child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
1638
+ )])
1639
+ };
1640
+ }
1641
+ const blockAccepted = block.accepted || false;
1642
+ const blockRejected = block.rejected || false;
1643
+ let content = Array.isArray(block.content) ? [...block.content] : [];
1644
+ if (block.diffType === "added") {
1645
+ if (blockRejected) {
1646
+ return {
1647
+ id: block.id || crypto.randomUUID(),
1648
+ type: "paragraph",
1649
+ props: {},
1650
+ content: [],
1651
+ children: []
1652
+ };
1653
+ } else if (!blockAccepted) {
1654
+ content = content.map((item) => ({
1655
+ ...item,
1656
+ styles: { ...item.styles, bold: true }
1657
+ }));
1658
+ content.push({
1659
+ type: "diffActions",
1660
+ props: { diffIds: block.diffId }
1661
+ });
1662
+ }
1663
+ } else if (block.diffType === "removed") {
1664
+ if (blockAccepted) {
1665
+ return {
1666
+ id: block.id || crypto.randomUUID(),
1667
+ type: "paragraph",
1668
+ props: {},
1669
+ content: [],
1670
+ children: []
1671
+ };
1672
+ } else if (!blockRejected) {
1673
+ content = content.map((item) => ({
1674
+ ...item,
1675
+ styles: { ...item.styles, strike: true }
1676
+ }));
1677
+ content.push({
1678
+ type: "diffActions",
1679
+ props: { diffIds: block.diffId }
1680
+ });
1681
+ }
1682
+ }
1683
+ const baseBlock = {
1684
+ id: block.id || crypto.randomUUID(),
1685
+ type: block.type || "paragraph",
1686
+ props: this.getBlockProps(block),
1687
+ content,
1688
+ children: _optionalChain([block, 'access', _34 => _34.children, 'optionalAccess', _35 => _35.map, 'call', _36 => _36(
1689
+ (child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
1690
+ )])
1691
+ };
1692
+ return baseBlock;
1693
+ }
1694
+ static renderWordLevelDiff(block, onAcceptChange, onRejectChange) {
1695
+ if (!block.wordDiffs) {
1696
+ return {
1697
+ id: block.id || crypto.randomUUID(),
1698
+ type: block.type || "paragraph",
1699
+ props: block.props || {},
1700
+ content: Array.isArray(block.content) ? block.content : [],
1701
+ children: []
1702
+ };
1703
+ }
1704
+ const content = this.groupAndRenderWordDiffs(block.wordDiffs);
1705
+ return {
1706
+ id: block.id || crypto.randomUUID(),
1707
+ type: block.type || "paragraph",
1708
+ props: block.props || {},
1709
+ content: Array.isArray(content) ? content : [],
1710
+ children: _optionalChain([block, 'access', _37 => _37.children, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange))]) || []
1711
+ };
1712
+ }
1713
+ static groupAndRenderWordDiffs(wordDiffs) {
1714
+ const content = [];
1715
+ for (let i = 0; i < wordDiffs.length; i++) {
1716
+ const wordDiff = wordDiffs[i];
1717
+ const isLastOfGroup = this.isLastDiffInGroup(wordDiffs, i);
1718
+ const textContent = this.createTextContent(wordDiff, isLastOfGroup);
1719
+ if (textContent) {
1720
+ if (Array.isArray(textContent)) {
1721
+ content.push(...textContent);
1722
+ } else {
1723
+ content.push(textContent);
1724
+ }
1725
+ }
1726
+ }
1727
+ const cleanedContent = this.cleanupSpaces(content);
1728
+ return cleanedContent;
1729
+ }
1730
+ static cleanupSpaces(content) {
1731
+ const filtered = content.filter((item) => item !== null && item !== void 0);
1732
+ const cleaned = [];
1733
+ for (let i = 0; i < filtered.length; i++) {
1734
+ const current = filtered[i];
1735
+ if (current.type === "text" && current.text === " ") {
1736
+ const lastItem = cleaned[cleaned.length - 1];
1737
+ if (i === 0 || i === filtered.length - 1 || lastItem && lastItem.type === "text" && lastItem.text === " " || lastItem && lastItem.type === "diffActions") {
1738
+ continue;
1739
+ }
1740
+ }
1741
+ if (current.type === "diffActions") {
1742
+ const nextItem = i + 1 < filtered.length ? filtered[i + 1] : null;
1743
+ cleaned.push(current);
1744
+ if (nextItem && nextItem.type === "text" && nextItem.text !== " " && nextItem.type !== "diffActions") {
1745
+ cleaned.push({
1746
+ type: "text",
1747
+ text: " ",
1748
+ styles: {}
1749
+ });
1750
+ }
1751
+ continue;
1752
+ }
1753
+ cleaned.push(current);
1754
+ }
1755
+ return cleaned;
1756
+ }
1757
+ static isLastDiffInGroup(wordDiffs, currentIndex) {
1758
+ const currentDiff = wordDiffs[currentIndex];
1759
+ if (currentDiff.type === "unchanged") {
1760
+ return false;
1761
+ }
1762
+ for (let i = currentIndex + 1; i < wordDiffs.length; i++) {
1763
+ const nextDiff = wordDiffs[i];
1764
+ if (nextDiff.diffId === currentDiff.diffId && (nextDiff.type === "added" || nextDiff.type === "removed")) {
1765
+ return false;
1766
+ }
1767
+ if (nextDiff.type !== "unchanged" && nextDiff.diffId !== currentDiff.diffId) {
1768
+ break;
1769
+ }
1770
+ }
1771
+ return true;
1772
+ }
1773
+ static createTextContent(wordDiff, isLastOfGroup) {
1774
+ switch (wordDiff.type) {
1775
+ case "added":
1776
+ if (wordDiff.accepted) {
1777
+ return {
1778
+ type: "text",
1779
+ text: wordDiff.text,
1780
+ styles: {}
1781
+ };
1782
+ } else if (wordDiff.rejected) {
1783
+ return null;
1784
+ } else {
1785
+ if (wordDiff.text.trim() === "") {
1786
+ return {
1787
+ type: "text",
1788
+ text: wordDiff.text,
1789
+ styles: { backgroundColor: "#dcfce7" }
1790
+ };
1791
+ } else {
1792
+ const baseContent = {
1793
+ type: "text",
1794
+ text: wordDiff.text,
1795
+ styles: { bold: true }
1796
+ };
1797
+ if (isLastOfGroup) {
1798
+ return [
1799
+ baseContent,
1800
+ {
1801
+ type: "diffActions",
1802
+ props: { diffIds: wordDiff.diffId }
1803
+ }
1804
+ ];
1805
+ } else {
1806
+ return baseContent;
1807
+ }
1808
+ }
1809
+ }
1810
+ case "removed":
1811
+ if (wordDiff.accepted) {
1812
+ return null;
1813
+ } else if (wordDiff.rejected) {
1814
+ return {
1815
+ type: "text",
1816
+ text: wordDiff.text,
1817
+ styles: {}
1818
+ };
1819
+ } else {
1820
+ if (wordDiff.text.trim() === "") {
1821
+ return {
1822
+ type: "text",
1823
+ text: wordDiff.text,
1824
+ styles: { strike: true }
1825
+ };
1826
+ } else {
1827
+ const baseContent = {
1828
+ type: "text",
1829
+ text: wordDiff.text,
1830
+ styles: { strike: true }
1831
+ };
1832
+ if (isLastOfGroup) {
1833
+ return [
1834
+ baseContent,
1835
+ {
1836
+ type: "diffActions",
1837
+ props: { diffIds: wordDiff.diffId }
1838
+ }
1839
+ ];
1840
+ } else {
1841
+ return baseContent;
1842
+ }
1843
+ }
1844
+ }
1845
+ case "unchanged":
1846
+ default:
1847
+ return {
1848
+ type: "text",
1849
+ text: wordDiff.text,
1850
+ styles: {}
1851
+ };
1852
+ }
1853
+ }
1854
+ static getBlockProps(block) {
1855
+ const baseProps = block.props || {};
1856
+ return baseProps;
1857
+ }
1858
+ static generateChangeSummary(diffBlocks) {
1859
+ let totalWords = 0;
1860
+ let addedWords = 0;
1861
+ let removedWords = 0;
1862
+ let acceptedChanges = 0;
1863
+ let rejectedChanges = 0;
1864
+ let pendingChanges = 0;
1865
+ const processBlock = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (block) => {
1866
+ if (block.wordDiffs) {
1867
+ block.wordDiffs.forEach((wordDiff) => {
1868
+ totalWords++;
1869
+ if (wordDiff.type === "added") {
1870
+ addedWords++;
1871
+ } else if (wordDiff.type === "removed") {
1872
+ removedWords++;
1873
+ }
1874
+ if (wordDiff.accepted) {
1875
+ acceptedChanges++;
1876
+ } else if (wordDiff.rejected) {
1877
+ rejectedChanges++;
1878
+ } else if (wordDiff.type !== "unchanged") {
1879
+ pendingChanges++;
1880
+ }
1881
+ });
1882
+ }
1883
+ if (block.children) {
1884
+ block.children.forEach((child) => processBlock(child));
1885
+ }
1886
+ }, "processBlock");
1887
+ diffBlocks.forEach(processBlock);
1888
+ return {
1889
+ totalWords,
1890
+ addedWords,
1891
+ removedWords,
1892
+ acceptedChanges,
1893
+ rejectedChanges,
1894
+ pendingChanges
1895
+ };
1896
+ }
1897
+ };
1898
+
1899
+ // src/utils/icons.tsx
1900
+ var _jsxruntime = require('react/jsx-runtime');
1901
+ var getIconByModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => {
1902
+ const IconComponent = getLucideIconByModule({ module: params.module });
1903
+ if (!IconComponent) return null;
1904
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, IconComponent, { className: cn(``, params.className) });
1905
+ }, "getIconByModule");
1906
+ var getIcon = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => {
1907
+ const IconComponent = getLucideIcon({ element: params.element });
1908
+ if (!IconComponent) return null;
1909
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, IconComponent, { className: cn(``, params.className) });
1910
+ }, "getIcon");
1911
+ var getIconByModuleName = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => {
1912
+ return getIconByModule({ module: Modules.findByModelName(params.name), className: params.className });
1913
+ }, "getIconByModuleName");
1914
+ var getLucideIcon = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => {
1915
+ if (params.element.type === "contents") {
1916
+ const contentType = params.element.contentType;
1917
+ if (!contentType) return null;
1918
+ return getLucideIconByModule({ module: Modules.findByModelName(contentType) });
1919
+ }
1920
+ return getLucideIconByModule({ module: Modules.findByName(params.element.type) });
1921
+ }, "getLucideIcon");
1922
+ var getLucideIconByModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => {
1923
+ return _nullishCoalesce(params.module.icon, () => ( null));
1924
+ }, "getLucideIconByModule");
1925
+ var getLucideIconByModuleName = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => {
1926
+ return getLucideIconByModule({ module: Modules.findByModelName(params.name) });
1927
+ }, "getLucideIconByModuleName");
1928
+
1929
+ // src/features/auth/data/auth.ts
1930
+ var Auth = class extends AbstractApiData {
1931
+ static {
1932
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "Auth");
1933
+ }
1934
+
1935
+
1936
+
1937
+ get token() {
1938
+ if (!this._token) throw new Error("Token is not defined");
1939
+ return this._token;
1940
+ }
1941
+ get refreshToken() {
1942
+ if (!this._refreshToken) throw new Error("Refresh token is not defined");
1943
+ return this._refreshToken;
1944
+ }
1945
+ get user() {
1946
+ if (!this._user) throw new Error("User is not defined");
1947
+ return this._user;
1948
+ }
1949
+ rehydrate(data) {
1950
+ super.rehydrate(data);
1951
+ this._token = _nullishCoalesce(data.jsonApi.attributes.token, () => ( void 0));
1952
+ this._refreshToken = _nullishCoalesce(data.jsonApi.attributes.refreshToken, () => ( void 0));
1953
+ this._user = this._readIncluded(data, "user", Modules.User);
1954
+ return this;
1955
+ }
1956
+ createJsonApi(data) {
1957
+ const response = {
1958
+ data: {
1959
+ type: Modules.Auth.name,
1960
+ attributes: {}
1961
+ }
1962
+ };
1963
+ if (data.id) response.data.id = data.id;
1964
+ if (data.email !== void 0) response.data.attributes.email = data.email;
1965
+ if (data.name !== void 0) response.data.attributes.name = data.name;
1966
+ if (data.companyName !== void 0) response.data.attributes.companyName = data.companyName;
1967
+ if (data.password !== void 0) response.data.attributes.password = data.password;
1968
+ if (data.partitaIva !== void 0) response.data.attributes.partitaIva = data.partitaIva;
1969
+ if (data.codiceFiscale !== void 0) response.data.attributes.codiceFiscale = data.codiceFiscale;
1970
+ return response;
1971
+ }
1972
+ };
1973
+
1974
+ // src/features/auth/enums/AuthComponent.ts
1975
+ var AuthComponent = /* @__PURE__ */ ((AuthComponent2) => {
1976
+ AuthComponent2[AuthComponent2["Login"] = 0] = "Login";
1977
+ AuthComponent2[AuthComponent2["ForgotPassword"] = 1] = "ForgotPassword";
1978
+ AuthComponent2[AuthComponent2["ResetPassword"] = 2] = "ResetPassword";
1979
+ AuthComponent2[AuthComponent2["ActivateAccount"] = 3] = "ActivateAccount";
1980
+ AuthComponent2[AuthComponent2["AcceptInvitation"] = 4] = "AcceptInvitation";
1981
+ AuthComponent2[AuthComponent2["Register"] = 5] = "Register";
1982
+ AuthComponent2[AuthComponent2["Landing"] = 6] = "Landing";
1983
+ return AuthComponent2;
1984
+ })(AuthComponent || {});
1985
+
1986
+ // src/features/auth/config.ts
1987
+ var _tokenHandler = null;
1988
+ function configureAuth(handler) {
1989
+ _tokenHandler = handler;
1990
+ }
1991
+ _chunk7QVYU63Ejs.__name.call(void 0, configureAuth, "configureAuth");
1992
+ function getTokenHandler() {
1993
+ return _tokenHandler;
1994
+ }
1995
+ _chunk7QVYU63Ejs.__name.call(void 0, getTokenHandler, "getTokenHandler");
1996
+
1997
+ // src/features/auth/auth.module.ts
1998
+ var AuthModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
1999
+ pageUrl: "/auth",
2000
+ name: "auth",
2001
+ model: Auth
2002
+ }), "AuthModule");
2003
+
2004
+ // src/features/company/data/company.ts
2005
+ var Company = class extends AbstractApiData {
2006
+ static {
2007
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "Company");
2008
+ }
2009
+
2010
+
2011
+
2012
+
2013
+
2014
+
2015
+
2016
+ get name() {
2017
+ if (this._name === void 0) throw new Error("Name is not defined");
2018
+ return this._name;
2019
+ }
2020
+ get logo() {
2021
+ return this._logo;
2022
+ }
2023
+ get logoUrl() {
2024
+ return this._logoUrl;
2025
+ }
2026
+ get licenseExpirationDate() {
2027
+ return this._licenseExpirationDate;
2028
+ }
2029
+ get features() {
2030
+ return _nullishCoalesce(this._features, () => ( []));
2031
+ }
2032
+ get modules() {
2033
+ return _nullishCoalesce(this._modules, () => ( []));
2034
+ }
2035
+ get configurations() {
2036
+ return this._configurations;
2037
+ }
2038
+ rehydrate(data) {
2039
+ super.rehydrate(data);
2040
+ this._name = data.jsonApi.attributes.name;
2041
+ this._configurations = data.jsonApi.attributes.configurations ? JSON.parse(data.jsonApi.attributes.configurations) : void 0;
2042
+ this._logo = data.jsonApi.attributes.logo;
2043
+ this._logoUrl = data.jsonApi.attributes.logoUrl;
2044
+ this._licenseExpirationDate = data.jsonApi.attributes.licenseExpirationDate ? new Date(data.jsonApi.attributes.licenseExpirationDate) : void 0;
2045
+ this._features = this._readIncluded(data, "features", Modules.Feature);
2046
+ this._modules = this._readIncluded(data, "modules", Modules.Module);
2047
+ return this;
2048
+ }
2049
+ createJsonApi(data) {
2050
+ const response = {
2051
+ data: {
2052
+ type: Modules.Company.name,
2053
+ id: data.id,
2054
+ attributes: {},
2055
+ meta: {},
2056
+ relationships: {}
2057
+ },
2058
+ included: []
2059
+ };
2060
+ if (data.name) response.data.attributes.name = data.name;
2061
+ if (data.configurations) response.data.attributes.configurations = JSON.stringify(data.configurations);
2062
+ if (data.logo) response.data.attributes.logo = data.logo;
2063
+ if (data.license) response.data.attributes.license = data.license;
2064
+ if (data.privateKey) response.data.attributes.privateKey = data.privateKey;
2065
+ if (data.featureIds && data.featureIds.length > 0) {
2066
+ response.data.relationships.features = {
2067
+ data: data.featureIds.map((featureId) => ({
2068
+ type: Modules.Feature.name,
2069
+ id: featureId
2070
+ }))
2071
+ };
2072
+ }
2073
+ if (data.moduleIds && data.moduleIds.length > 0) {
2074
+ response.data.relationships.modules = {
2075
+ data: data.moduleIds.map((moduleId) => ({
2076
+ type: Modules.Module.name,
2077
+ id: moduleId
2078
+ }))
2079
+ };
2080
+ }
2081
+ return response;
2082
+ }
2083
+ };
2084
+
2085
+ // src/features/company/data/company.fields.ts
2086
+ var CompanyFields = /* @__PURE__ */ ((CompanyFields2) => {
2087
+ CompanyFields2["companyId"] = "companyId";
2088
+ CompanyFields2["name"] = "name";
2089
+ CompanyFields2["createdAt"] = "createdAt";
2090
+ CompanyFields2["updatedAt"] = "updatedAt";
2091
+ return CompanyFields2;
2092
+ })(CompanyFields || {});
2093
+
2094
+ // src/features/company/company.module.ts
2095
+ var CompanyModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2096
+ pageUrl: "/companies",
2097
+ name: "companies",
2098
+ model: Company,
2099
+ moduleId: "f9e77c8f-bfd1-4fd4-80b0-e1d891ab7113"
2100
+ }), "CompanyModule");
2101
+
2102
+ // src/features/content/data/content.ts
2103
+ var Content = class extends AbstractApiData {
2104
+ static {
2105
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "Content");
2106
+ }
2107
+
2108
+
2109
+
2110
+
2111
+
2112
+
2113
+
2114
+
2115
+ get searchResult() {
2116
+ return _nullishCoalesce(this._name, () => ( ""));
2117
+ }
2118
+ get contentType() {
2119
+ return this._contentType;
2120
+ }
2121
+ get name() {
2122
+ if (this._name === void 0) throw new Error("JsonApi error: content name is missing");
2123
+ return this._name;
2124
+ }
2125
+ get abstract() {
2126
+ return this._abstract;
2127
+ }
2128
+ get tldr() {
2129
+ return this._tldr;
2130
+ }
2131
+ get aiStatus() {
2132
+ return _nullishCoalesce(this._aiStatus, () => ( ""));
2133
+ }
2134
+ get relevance() {
2135
+ return this._relevance;
2136
+ }
2137
+ get author() {
2138
+ if (this._author === void 0) throw new Error("JsonApi error: document author is missing");
2139
+ return this._author;
2140
+ }
2141
+ get editors() {
2142
+ return _nullishCoalesce(this._editors, () => ( []));
2143
+ }
2144
+ rehydrate(data) {
2145
+ super.rehydrate(data);
2146
+ this._contentType = data.jsonApi.meta.contentType;
2147
+ this._name = data.jsonApi.attributes.name;
2148
+ this._abstract = data.jsonApi.attributes.abstract;
2149
+ this._tldr = data.jsonApi.attributes.tldr;
2150
+ this._aiStatus = data.jsonApi.meta.aiStatus;
2151
+ this._relevance = data.jsonApi.meta.relevance;
2152
+ this._author = this._readIncluded(data, "author", Modules.User);
2153
+ this._editors = this._readIncluded(data, "editors", Modules.User);
2154
+ return this;
2155
+ }
2156
+ addContentInput(response, data) {
2157
+ if (data.name) response.data.attributes.name = data.name;
2158
+ if (data.authorId) {
2159
+ response.data.relationships.author = {
2160
+ data: {
2161
+ type: Modules.User.name,
2162
+ id: data.authorId
2163
+ }
2164
+ };
2165
+ }
2166
+ }
2167
+ };
2168
+
2169
+ // src/features/content/data/content.fields.ts
2170
+ var ContentFields = /* @__PURE__ */ ((ContentFields2) => {
2171
+ ContentFields2["contentId"] = "contentId";
2172
+ ContentFields2["name"] = "name";
2173
+ ContentFields2["relevance"] = "relevance";
2174
+ ContentFields2["authors"] = "authors";
2175
+ ContentFields2["createdAt"] = "createdAt";
2176
+ ContentFields2["updatedAt"] = "updatedAt";
2177
+ return ContentFields2;
2178
+ })(ContentFields || {});
2179
+
2180
+ // src/features/content/content.module.ts
2181
+ var ContentModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2182
+ pageUrl: "/contents",
2183
+ name: "contents",
2184
+ model: Content,
2185
+ inclusions: {
2186
+ lists: {
2187
+ fields: [
2188
+ createJsonApiInclusion("content", [`name`, `tldr`, `abstract`, `aiStatus`, `relevance`]),
2189
+ createJsonApiInclusion("users", [`name`, `avatar`]),
2190
+ createJsonApiInclusion("topics", [`name`]),
2191
+ createJsonApiInclusion("expertises", [`name`])
2192
+ ]
2193
+ }
2194
+ }
2195
+ }), "ContentModule");
2196
+
2197
+ // src/features/feature/data/feature.ts
2198
+ var Feature = (_class4 = class extends AbstractApiData {constructor(...args) { super(...args); _class4.prototype.__init2.call(this); }
2199
+ static {
2200
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "Feature");
2201
+ }
2202
+
2203
+
2204
+ __init2() {this._modules = []}
2205
+ get name() {
2206
+ return _nullishCoalesce(this._name, () => ( ""));
2207
+ }
2208
+ get isProduction() {
2209
+ return this._isProduction == true ? true : false;
2210
+ }
2211
+ get modules() {
2212
+ return this._modules;
2213
+ }
2214
+ rehydrate(data) {
2215
+ super.rehydrate(data);
2216
+ this._name = data.jsonApi.attributes.name;
2217
+ this._isProduction = _nullishCoalesce(data.jsonApi.attributes.isProduction, () => ( false));
2218
+ this._modules = this._readIncluded(data, `modules`, Modules.Module);
2219
+ return this;
2220
+ }
2221
+ }, _class4);
2222
+
2223
+ // src/features/feature/feature.module.ts
2224
+ var FeatureModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2225
+ pageUrl: "/features",
2226
+ name: "features",
2227
+ model: Feature,
2228
+ moduleId: "025fdd23-2803-4360-9fd9-eaa3612c2e23"
2229
+ }), "FeatureModule");
2230
+
2231
+ // src/features/module/data/module.ts
2232
+ var Module = class extends AbstractApiData {
2233
+ static {
2234
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "Module");
2235
+ }
2236
+
2237
+
2238
+
2239
+ get name() {
2240
+ if (!this._name) throw new Error("Name is not defined");
2241
+ return _nullishCoalesce(this._name, () => ( ""));
2242
+ }
2243
+ get isCore() {
2244
+ return _nullishCoalesce(this._isCore, () => ( false));
2245
+ }
2246
+ get permissions() {
2247
+ if (!this._permissions) throw new Error("Permissions is not defined");
2248
+ return this._permissions;
2249
+ }
2250
+ rehydrate(data) {
2251
+ super.rehydrate(data);
2252
+ this._name = data.jsonApi.attributes.name;
2253
+ this._isCore = data.jsonApi.attributes.isCore;
2254
+ this._permissions = data.jsonApi.meta.permissions;
2255
+ return this;
2256
+ }
2257
+ };
2258
+
2259
+ // src/features/module/module.module.ts
2260
+ var ModuleModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2261
+ pageUrl: "/modules",
2262
+ name: "modules",
2263
+ model: Module,
2264
+ moduleId: "25ffd868-8341-4ca7-963b-6e1c56b03b1d"
2265
+ }), "ModuleModule");
2266
+
2267
+ // src/features/notification/data/notification.ts
2268
+ var Notification = class extends AbstractApiData {
2269
+ static {
2270
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "Notification");
2271
+ }
2272
+
2273
+
2274
+
2275
+ get notificationType() {
2276
+ if (this._notificationType === void 0) throw new Error("notificationType is not set");
2277
+ return this._notificationType;
2278
+ }
2279
+ get isRead() {
2280
+ return this._isRead === void 0 ? false : this._isRead;
2281
+ }
2282
+ get actor() {
2283
+ return this._actor;
2284
+ }
2285
+ rehydrate(data) {
2286
+ super.rehydrate(data);
2287
+ this._notificationType = data.jsonApi.attributes.notificationType;
2288
+ this._isRead = data.jsonApi.attributes.isRead;
2289
+ this._actor = this._readIncluded(data, "actor", Modules.User);
2290
+ return this;
2291
+ }
2292
+ createJsonApi(data) {
2293
+ const response = {
2294
+ data: {
2295
+ type: Modules.Notification.name,
2296
+ id: data.id,
2297
+ attributes: {
2298
+ isRead: data.isRead
2299
+ },
2300
+ meta: {},
2301
+ relationships: {}
2302
+ },
2303
+ included: []
2304
+ };
2305
+ return response;
2306
+ }
2307
+ };
2308
+
2309
+ // src/features/notification/data/notification.fields.ts
2310
+ var NotificationFields = /* @__PURE__ */ ((NotificationFields2) => {
2311
+ NotificationFields2["notificationId"] = "notificationId";
2312
+ NotificationFields2["name"] = "name";
2313
+ NotificationFields2["createdAt"] = "createdAt";
2314
+ NotificationFields2["updatedAt"] = "updatedAt";
2315
+ return NotificationFields2;
2316
+ })(NotificationFields || {});
2317
+
2318
+ // src/features/notification/notification.module.ts
2319
+ var NotificationModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2320
+ pageUrl: "/notifications",
2321
+ name: "notifications",
2322
+ model: Notification,
2323
+ moduleId: "9259d704-c670-4e77-a3a1-a728ffc5be3d"
2324
+ }), "NotificationModule");
2325
+
2326
+ // src/features/push/data/push.ts
2327
+ var Push = class extends AbstractApiData {
2328
+ static {
2329
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "Push");
2330
+ }
2331
+ createJsonApi(data) {
2332
+ const response = {
2333
+ data: {
2334
+ type: Modules.Push.name,
2335
+ attributes: {
2336
+ key: data.key
2337
+ }
2338
+ },
2339
+ included: []
2340
+ };
2341
+ return response;
2342
+ }
2343
+ };
2344
+
2345
+ // src/features/push/push.module.ts
2346
+ var PushModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2347
+ pageUrl: "/push",
2348
+ name: "push",
2349
+ model: Push,
2350
+ moduleId: ""
2351
+ }), "PushModule");
2352
+
2353
+ // src/features/role/data/role.ts
2354
+ var Role = class extends AbstractApiData {
2355
+ static {
2356
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "Role");
2357
+ }
2358
+
2359
+
2360
+
2361
+
2362
+ get name() {
2363
+ if (!this._name) throw new Error("Name is not defined");
2364
+ return this._name;
2365
+ }
2366
+ get description() {
2367
+ return _nullishCoalesce(this._description, () => ( ""));
2368
+ }
2369
+ get isSelectable() {
2370
+ return _nullishCoalesce(this._isSelectable, () => ( false));
2371
+ }
2372
+ get requiredFeature() {
2373
+ return this._requiredFeature;
2374
+ }
2375
+ rehydrate(data) {
2376
+ super.rehydrate(data);
2377
+ this._name = _nullishCoalesce(data.jsonApi.attributes.name, () => ( void 0));
2378
+ this._description = _nullishCoalesce(data.jsonApi.attributes.description, () => ( void 0));
2379
+ this._isSelectable = _nullishCoalesce(data.jsonApi.attributes.isSelectable, () => ( void 0));
2380
+ this._requiredFeature = this._readIncluded(
2381
+ data,
2382
+ "requiredFeature",
2383
+ Modules.Feature
2384
+ );
2385
+ return this;
2386
+ }
2387
+ createJsonApi(data) {
2388
+ const response = {
2389
+ data: {
2390
+ type: Modules.Role.name,
2391
+ id: data.id,
2392
+ attributes: {
2393
+ name: data.name
2394
+ },
2395
+ meta: {}
2396
+ },
2397
+ included: []
2398
+ };
2399
+ if (data.description !== void 0) response.data.attributes.description = data.description;
2400
+ return response;
2401
+ }
2402
+ };
2403
+
2404
+ // src/features/role/data/role.fields.ts
2405
+ var RoleFields = /* @__PURE__ */ ((RoleFields2) => {
2406
+ RoleFields2["roleId"] = "roleId";
2407
+ RoleFields2["name"] = "name";
2408
+ RoleFields2["description"] = "description";
2409
+ RoleFields2["createdAt"] = "createdAt";
2410
+ RoleFields2["updatedAt"] = "updatedAt";
2411
+ return RoleFields2;
2412
+ })(RoleFields || {});
2413
+
2414
+ // src/features/role/role.module.ts
2415
+ var RoleModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2416
+ pageUrl: "/roles",
2417
+ name: "roles",
2418
+ model: Role,
2419
+ moduleId: "9f6416e6-7b9b-4e1a-a99f-833191eca8a9"
2420
+ }), "RoleModule");
2421
+
2422
+ // src/features/s3/data/s3.ts
2423
+ var S3 = class extends AbstractApiData {
2424
+ static {
2425
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "S3");
2426
+ }
2427
+
2428
+
2429
+
2430
+
2431
+
2432
+ get url() {
2433
+ if (!this._url) throw new Error("Image URL is not set.");
2434
+ return this._url;
2435
+ }
2436
+ get headers() {
2437
+ const headers = {};
2438
+ if (this._contentType) {
2439
+ headers["Content-Type"] = this._contentType;
2440
+ }
2441
+ if (this._blobType) {
2442
+ headers["x-ms-blob-type"] = this._blobType;
2443
+ }
2444
+ if (this._acl) {
2445
+ headers["x-amz-acl"] = this._acl;
2446
+ }
2447
+ return headers;
2448
+ }
2449
+ rehydrate(data) {
2450
+ super.rehydrate(data);
2451
+ this._url = _nullishCoalesce(data.jsonApi.attributes.url, () => ( void 0));
2452
+ this._storageType = _nullishCoalesce(data.jsonApi.attributes.storageType, () => ( void 0));
2453
+ this._contentType = _nullishCoalesce(data.jsonApi.attributes.contentType, () => ( void 0));
2454
+ this._blobType = _nullishCoalesce(data.jsonApi.attributes.blobType, () => ( void 0));
2455
+ this._acl = _nullishCoalesce(data.jsonApi.attributes.acl, () => ( void 0));
2456
+ return this;
2457
+ }
2458
+ createJsonApi(data) {
2459
+ const response = {
2460
+ data: {
2461
+ type: Modules.S3.name,
2462
+ attributes: {
2463
+ key: data.key
2464
+ }
2465
+ },
2466
+ included: []
2467
+ };
2468
+ if (data.contentType) response.data.attributes.contentType = data.contentType;
2469
+ return response;
2470
+ }
2471
+ };
2472
+
2473
+ // src/features/s3/s3.module.ts
2474
+ var S3Module = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2475
+ pageUrl: "/s3",
2476
+ name: "s3",
2477
+ model: S3,
2478
+ moduleId: "db41ba46-e171-4324-8845-99353eba8568"
2479
+ }), "S3Module");
2480
+
2481
+ // src/features/user/data/user.ts
2482
+ var User = (_class5 = class extends AbstractApiData {constructor(...args2) { super(...args2); _class5.prototype.__init3.call(this);_class5.prototype.__init4.call(this); }
2483
+ static {
2484
+ _chunk7QVYU63Ejs.__name.call(void 0, this, "User");
2485
+ }
2486
+
2487
+
2488
+
2489
+
2490
+
2491
+
2492
+
2493
+
2494
+
2495
+
2496
+
2497
+
2498
+ __init3() {this._roles = []}
2499
+
2500
+ __init4() {this._modules = []}
2501
+ get searchResult() {
2502
+ return _nullishCoalesce(this._name, () => ( ""));
2503
+ }
2504
+ get name() {
2505
+ return _nullishCoalesce(this._name, () => ( ""));
2506
+ }
2507
+ get email() {
2508
+ return _nullishCoalesce(this._email, () => ( ""));
2509
+ }
2510
+ get title() {
2511
+ return _nullishCoalesce(this._title, () => ( ""));
2512
+ }
2513
+ get bio() {
2514
+ return _nullishCoalesce(this._bio, () => ( ""));
2515
+ }
2516
+ get avatar() {
2517
+ return this._avatar;
2518
+ }
2519
+ get avatarUrl() {
2520
+ return this._avatarUrl;
2521
+ }
2522
+ get phone() {
2523
+ return this._phone;
2524
+ }
2525
+ get rate() {
2526
+ return this._rate;
2527
+ }
2528
+ get relevance() {
2529
+ return this._relevance;
2530
+ }
2531
+ get isActivated() {
2532
+ return _nullishCoalesce(this._isActivated, () => ( false));
2533
+ }
2534
+ get isDeleted() {
2535
+ return _nullishCoalesce(this._isDeleted, () => ( false));
2536
+ }
2537
+ get lastLogin() {
2538
+ return this._lastLogin;
2539
+ }
2540
+ get roles() {
2541
+ return this._roles;
2542
+ }
2543
+ get company() {
2544
+ return this._company;
2545
+ }
2546
+ get modules() {
2547
+ return this._modules;
2548
+ }
2549
+ rehydrate(data) {
2550
+ super.rehydrate(data);
2551
+ this._name = data.jsonApi.attributes.name;
2552
+ this._email = data.jsonApi.attributes.email;
2553
+ this._title = data.jsonApi.attributes.title;
2554
+ this._bio = data.jsonApi.attributes.bio;
2555
+ this._phone = data.jsonApi.attributes.phone;
2556
+ this._rate = data.jsonApi.attributes.rate;
2557
+ this._avatar = data.jsonApi.attributes.avatar;
2558
+ this._avatarUrl = data.jsonApi.attributes.avatarUrl;
2559
+ this._isActivated = data.jsonApi.meta.isActive;
2560
+ this._isDeleted = data.jsonApi.meta.isDeleted;
2561
+ this._lastLogin = data.jsonApi.meta.lastLogin ? new Date(data.jsonApi.meta.lastLogin) : void 0;
2562
+ this._relevance = data.jsonApi.meta.relevance;
2563
+ this._roles = this._readIncluded(data, "roles", Modules.Role);
2564
+ this._company = this._readIncluded(data, "company", Modules.Company);
2565
+ this._modules = this._readIncluded(data, "modules", Modules.Module);
2566
+ return this;
2567
+ }
2568
+ createJsonApi(data) {
2569
+ const response = {
2570
+ data: {
2571
+ type: Modules.User.name,
2572
+ id: data.id,
2573
+ attributes: {
2574
+ name: data.name
2575
+ },
2576
+ meta: {},
2577
+ relationships: {}
2578
+ },
2579
+ included: []
2580
+ };
2581
+ if (data.email !== void 0) response.data.attributes.email = data.email;
2582
+ if (data.title !== void 0) response.data.attributes.title = data.title;
2583
+ if (data.bio !== void 0) response.data.attributes.bio = data.bio;
2584
+ if (data.phone !== void 0) response.data.attributes.phone = data.phone;
2585
+ if (data.password !== void 0) response.data.attributes.password = data.password;
2586
+ if (data.sendInvitationEmail) response.data.attributes.sendInvitationEmail = true;
2587
+ if (data.adminCreated) response.data.attributes.adminCreated = true;
2588
+ if (data.avatar) response.data.attributes.avatar = data.avatar;
2589
+ if (data.rate !== void 0) response.data.attributes.rate = data.rate;
2590
+ if (data.roleIds) {
2591
+ response.data.relationships.roles = {
2592
+ data: data.roleIds.map((roleId) => ({
2593
+ type: Modules.Role.name,
2594
+ id: roleId
2595
+ }))
2596
+ };
2597
+ }
2598
+ if (data.companyId) {
2599
+ response.data.relationships.company = {
2600
+ data: {
2601
+ type: Modules.Company.name,
2602
+ id: data.companyId
2603
+ }
2604
+ };
2605
+ }
2606
+ return response;
2607
+ }
2608
+ }, _class5);
2609
+
2610
+ // src/features/user/data/user.fields.ts
2611
+ var UserFields = /* @__PURE__ */ ((UserFields2) => {
2612
+ UserFields2["userId"] = "userId";
2613
+ UserFields2["name"] = "name";
2614
+ UserFields2["email"] = "email";
2615
+ UserFields2["relevance"] = "relevance";
2616
+ UserFields2["createdAt"] = "createdAt";
2617
+ UserFields2["updatedAt"] = "updatedAt";
2618
+ return UserFields2;
2619
+ })(UserFields || {});
2620
+
2621
+ // src/features/user/user.module.ts
2622
+ var UserModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2623
+ pageUrl: "/users",
2624
+ name: "users",
2625
+ model: User,
2626
+ moduleId: "04cfc677-0fd2-4f5e-adf4-2483a00c0277",
2627
+ inclusions: {
2628
+ lists: {
2629
+ fields: [
2630
+ createJsonApiInclusion("users", [`name`, `email`, `avatar`, `title`]),
2631
+ createJsonApiInclusion("usertopics", [`level`]),
2632
+ createJsonApiInclusion("userexpertises", [`level`]),
2633
+ createJsonApiInclusion("topics", [`name`])
2634
+ ]
2635
+ }
2636
+ }
2637
+ }), "UserModule");
2638
+
2639
+ // src/features/user/author.module.ts
2640
+ var AuthorModule = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (factory) => factory({
2641
+ pageUrl: "/authors",
2642
+ name: "authors",
2643
+ model: User,
2644
+ moduleId: "04cfc677-0fd2-4f5e-adf4-2483a00c0277"
2645
+ }), "AuthorModule");
2646
+
2647
+
2648
+
2649
+
2650
+
2651
+
2652
+
2653
+
2654
+
2655
+
2656
+
2657
+
2658
+
2659
+
2660
+
2661
+
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+
2680
+
2681
+
2682
+
2683
+
2684
+
2685
+
2686
+
2687
+
2688
+
2689
+
2690
+
2691
+
2692
+
2693
+
2694
+
2695
+
2696
+
2697
+
2698
+
2699
+
2700
+
2701
+
2702
+
2703
+
2704
+
2705
+
2706
+
2707
+
2708
+
2709
+
2710
+
2711
+
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+ exports.RehydrationFactory = RehydrationFactory; exports.AbstractApiData = AbstractApiData; exports.HttpMethod = HttpMethod; exports.setGlobalErrorHandler = setGlobalErrorHandler; exports.getGlobalErrorHandler = getGlobalErrorHandler; exports.AbstractService = AbstractService; exports.configureClientJsonApi = configureClientJsonApi; exports.getClientApiUrl = getClientApiUrl; exports.getClientAppUrl = getClientAppUrl; exports.getClientTrackablePages = getClientTrackablePages; exports.ClientJsonApiGet = ClientJsonApiGet; exports.ClientJsonApiPost = ClientJsonApiPost; exports.ClientJsonApiPut = ClientJsonApiPut; exports.ClientJsonApiPatch = ClientJsonApiPatch; exports.ClientJsonApiDelete = ClientJsonApiDelete; exports.ClientHttpMethod = ClientHttpMethod; exports.setClientGlobalErrorHandler = setClientGlobalErrorHandler; exports.getClientGlobalErrorHandler = getClientGlobalErrorHandler; exports.ClientAbstractService = ClientAbstractService; exports.ModuleRegistrar = ModuleRegistrar; exports.ModuleRegistry = ModuleRegistry; exports.Modules = Modules; exports.EndpointCreator = EndpointCreator; exports.createJsonApiInclusion = createJsonApiInclusion; exports.rehydrate = rehydrate; exports.rehydrateList = rehydrateList; exports.cn = cn; exports.composeRefs = composeRefs; exports.useComposedRefs = useComposedRefs; exports.useIsMobile = useIsMobile; exports.formatDate = formatDate; exports.exists = exists; exports.TableOptions = TableOptions; exports.getTableOptions = getTableOptions; exports.getTableComponents = getTableComponents; exports.userObjectSchema = userObjectSchema; exports.entityObjectSchema = entityObjectSchema; exports.BlockNoteDiffUtil = BlockNoteDiffUtil; exports.BlockNoteWordDiffRendererUtil = BlockNoteWordDiffRendererUtil; exports.getIconByModule = getIconByModule; exports.getIcon = getIcon; exports.getIconByModuleName = getIconByModuleName; exports.getLucideIcon = getLucideIcon; exports.getLucideIconByModule = getLucideIconByModule; exports.getLucideIconByModuleName = getLucideIconByModuleName; exports.Auth = Auth; exports.AuthComponent = AuthComponent; exports.configureAuth = configureAuth; exports.getTokenHandler = getTokenHandler; exports.AuthModule = AuthModule; exports.Company = Company; exports.CompanyFields = CompanyFields; exports.CompanyModule = CompanyModule; exports.Content = Content; exports.ContentFields = ContentFields; exports.ContentModule = ContentModule; exports.Feature = Feature; exports.FeatureModule = FeatureModule; exports.Module = Module; exports.ModuleModule = ModuleModule; exports.Notification = Notification; exports.NotificationFields = NotificationFields; exports.NotificationModule = NotificationModule; exports.Push = Push; exports.PushModule = PushModule; exports.Role = Role; exports.RoleFields = RoleFields; exports.RoleModule = RoleModule; exports.S3 = S3; exports.S3Module = S3Module; exports.User = User; exports.UserFields = UserFields; exports.UserModule = UserModule; exports.AuthorModule = AuthorModule;
2723
+ //# sourceMappingURL=chunk-2Z56AS2S.js.map