@velastack/patterns 0.12.0 → 0.13.1

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 (229) hide show
  1. package/README.md +21 -2
  2. package/dist/chunks/{_layout-DQhSAhfF.js → _layout-Dju9EYqa.js} +6 -8
  3. package/dist/chunks/{_layout-DQhSAhfF.js.map → _layout-Dju9EYqa.js.map} +1 -1
  4. package/dist/chunks/{_page-C7kGoW7_.js → _page-44USwLXO.js} +2 -3
  5. package/dist/chunks/{_page-C7kGoW7_.js.map → _page-44USwLXO.js.map} +1 -1
  6. package/dist/chunks/{_page-DoPdZgZv.js → _page-Bt37d4uo.js} +2 -3
  7. package/dist/chunks/_page-Bt37d4uo.js.map +1 -0
  8. package/dist/chunks/{_page-B6yd6_Vl.js → _page-DcbEFpyw.js} +2 -3
  9. package/dist/chunks/_page-DcbEFpyw.js.map +1 -0
  10. package/dist/chunks/{auth-pages-jsyDV1GR.js → auth-pages-BW3_yluN.js} +6 -9
  11. package/dist/chunks/{auth-pages-jsyDV1GR.js.map → auth-pages-BW3_yluN.js.map} +1 -1
  12. package/dist/chunks/{collections-DZOuRpvS.js → collections-CFW9ZqUE.js} +5 -7
  13. package/dist/chunks/{collections-DZOuRpvS.js.map → collections-CFW9ZqUE.js.map} +1 -1
  14. package/dist/chunks/{collections-DzwWwFUQ.js → collections-D-xbHi4M.js} +39 -45
  15. package/dist/chunks/{collections-DzwWwFUQ.js.map → collections-D-xbHi4M.js.map} +1 -1
  16. package/dist/chunks/{compose-handle-BBlamPfx.js → compose-handle-Da7m6lV_.js} +3 -4
  17. package/dist/chunks/{compose-handle-BBlamPfx.js.map → compose-handle-Da7m6lV_.js.map} +1 -1
  18. package/dist/chunks/{config-target-BgyFkbFL.js → config-target-DJbVHwHl.js} +3 -4
  19. package/dist/chunks/{config-target-BgyFkbFL.js.map → config-target-DJbVHwHl.js.map} +1 -1
  20. package/dist/chunks/constants-DpK-r_m5.js +85 -0
  21. package/dist/chunks/constants-DpK-r_m5.js.map +1 -0
  22. package/dist/chunks/{currency.server-CzHS7Svd.js → currency.server-BwuXG0a9.js} +9 -11
  23. package/dist/chunks/{currency.server-CzHS7Svd.js.map → currency.server-BwuXG0a9.js.map} +1 -1
  24. package/dist/chunks/{dedent-Gq6Krl4n.js → dedent-CCUOcPFW.js} +2 -3
  25. package/dist/chunks/{dedent-Gq6Krl4n.js.map → dedent-CCUOcPFW.js.map} +1 -1
  26. package/dist/chunks/{dispatch-BIvOwbKN.js → dispatch-BxlKS_5v.js} +2 -3
  27. package/dist/chunks/{dispatch-BIvOwbKN.js.map → dispatch-BxlKS_5v.js.map} +1 -1
  28. package/dist/chunks/{env-BugddEjd.js → env-AxyRWcC_.js} +2 -3
  29. package/dist/chunks/{env-BugddEjd.js.map → env-AxyRWcC_.js.map} +1 -1
  30. package/dist/chunks/{env-vars-mnRA0hOe.js → env-vars-CUh4mLM_.js} +2 -3
  31. package/dist/chunks/{env-vars-mnRA0hOe.js.map → env-vars-CUh4mLM_.js.map} +1 -1
  32. package/dist/chunks/{env-vars-CNH-ItSY.js → env-vars-CVn2076k.js} +58 -59
  33. package/dist/chunks/{env-vars-CNH-ItSY.js.map → env-vars-CVn2076k.js.map} +1 -1
  34. package/dist/chunks/{env-vars-Cr4lbMD_.js → env-vars-T3_7JNSg.js} +3 -4
  35. package/dist/chunks/{env-vars-Cr4lbMD_.js.map → env-vars-T3_7JNSg.js.map} +1 -1
  36. package/dist/chunks/{env-vars-file-B_6esJW3.js → env-vars-file-B2zHQZqO.js} +2 -3
  37. package/dist/chunks/{env-vars-file-B_6esJW3.js.map → env-vars-file-B2zHQZqO.js.map} +1 -1
  38. package/dist/chunks/{env.preview-uMRKT5Pc.js → env.preview-C676UTOP.js} +2 -3
  39. package/dist/chunks/{env.preview-uMRKT5Pc.js.map → env.preview-C676UTOP.js.map} +1 -1
  40. package/dist/chunks/{errors-DR3gF_7a.js → errors-DdSUZI8f.js} +2 -3
  41. package/dist/chunks/{errors-DR3gF_7a.js.map → errors-DdSUZI8f.js.map} +1 -1
  42. package/dist/chunks/{format-result-BVoLVknk.js → format-result-CojavkIZ.js} +2 -3
  43. package/dist/chunks/{format-result-BVoLVknk.js.map → format-result-CojavkIZ.js.map} +1 -1
  44. package/dist/chunks/{generate-BEc_h7OI.js → generate-BCYvhyF9.js} +62 -63
  45. package/dist/chunks/{generate-BEc_h7OI.js.map → generate-BCYvhyF9.js.map} +1 -1
  46. package/dist/chunks/{generate-DyV5R8NP.js → generate-CKuUg3p-.js} +3 -4
  47. package/dist/chunks/{generate-DyV5R8NP.js.map → generate-CKuUg3p-.js.map} +1 -1
  48. package/dist/chunks/{generate-CtQcmjPM.js → generate-CY_Ii_bz.js} +79 -82
  49. package/dist/chunks/generate-CY_Ii_bz.js.map +1 -0
  50. package/dist/chunks/generate-CuOm66dn.js +57 -0
  51. package/dist/chunks/{generate-D21dCU-o.js.map → generate-CuOm66dn.js.map} +1 -1
  52. package/dist/chunks/{generate-BrOPb9tW.js → generate-DYq5Oj58.js} +3 -4
  53. package/dist/chunks/{generate-BrOPb9tW.js.map → generate-DYq5Oj58.js.map} +1 -1
  54. package/dist/chunks/{generate-DiwvSC9c.js → generate-F4FDWvFo.js} +13 -14
  55. package/dist/chunks/{generate-DiwvSC9c.js.map → generate-F4FDWvFo.js.map} +1 -1
  56. package/dist/chunks/{generate-C3OaUggX.js → generate-oZ1QeqPr.js} +25 -27
  57. package/dist/chunks/generate-oZ1QeqPr.js.map +1 -0
  58. package/dist/chunks/{generate.runtime-DOv-bhM6.js → generate.runtime-22jW8aVT.js} +37 -41
  59. package/dist/chunks/{generate.runtime-DOv-bhM6.js.map → generate.runtime-22jW8aVT.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-CtFCayo8.js → generate.runtime-B06rPt_j.js} +103 -108
  61. package/dist/chunks/{generate.runtime-CtFCayo8.js.map → generate.runtime-B06rPt_j.js.map} +1 -1
  62. package/dist/chunks/{generate.runtime-HkvT9gm6.js → generate.runtime-BEmSIAop.js} +44 -47
  63. package/dist/chunks/generate.runtime-BEmSIAop.js.map +1 -0
  64. package/dist/chunks/{generate.runtime-DRuPb-67.js → generate.runtime-BgGeOqYG.js} +19 -21
  65. package/dist/chunks/{generate.runtime-DRuPb-67.js.map → generate.runtime-BgGeOqYG.js.map} +1 -1
  66. package/dist/chunks/generate.runtime-Bz9z0VPR.js +108 -0
  67. package/dist/chunks/{generate.runtime-DUBOC6AA.js.map → generate.runtime-Bz9z0VPR.js.map} +1 -1
  68. package/dist/chunks/{generate.runtime-D34lCyet.js → generate.runtime-C37djibw.js} +25 -27
  69. package/dist/chunks/{generate.runtime-D34lCyet.js.map → generate.runtime-C37djibw.js.map} +1 -1
  70. package/dist/chunks/{generate.runtime-Drpy9sWO.js → generate.runtime-CM3bj0nP.js} +12 -14
  71. package/dist/chunks/{generate.runtime-Drpy9sWO.js.map → generate.runtime-CM3bj0nP.js.map} +1 -1
  72. package/dist/chunks/generate.runtime-CMuxVUIY.js +46 -0
  73. package/dist/chunks/{generate.runtime-DVwha8lZ.js.map → generate.runtime-CMuxVUIY.js.map} +1 -1
  74. package/dist/chunks/{generate.runtime-DlPeHx19.js → generate.runtime-CVqPHddZ.js} +44 -46
  75. package/dist/chunks/generate.runtime-CVqPHddZ.js.map +1 -0
  76. package/dist/chunks/generate.runtime-Cco2mFW2.js +63 -0
  77. package/dist/chunks/{generate.runtime-CPDJolef.js.map → generate.runtime-Cco2mFW2.js.map} +1 -1
  78. package/dist/chunks/generate.runtime-Cg-dfN9B.js +48 -0
  79. package/dist/chunks/{generate.runtime-CAO_SpsA.js.map → generate.runtime-Cg-dfN9B.js.map} +1 -1
  80. package/dist/chunks/{generate.runtime-Dy9uuf7M.js → generate.runtime-Cgam_XCc.js} +47 -50
  81. package/dist/chunks/{generate.runtime-Dy9uuf7M.js.map → generate.runtime-Cgam_XCc.js.map} +1 -1
  82. package/dist/chunks/{generate.runtime-DOWDoe6B.js → generate.runtime-CjqX4tDg.js} +5 -6
  83. package/dist/chunks/{generate.runtime-DOWDoe6B.js.map → generate.runtime-CjqX4tDg.js.map} +1 -1
  84. package/dist/chunks/generate.runtime-Cry-DBNl.js +111 -0
  85. package/dist/chunks/{generate.runtime-CaOO0281.js.map → generate.runtime-Cry-DBNl.js.map} +1 -1
  86. package/dist/chunks/{generate.runtime-CeoqgxiO.js → generate.runtime-Ct7cG8va.js} +76 -79
  87. package/dist/chunks/generate.runtime-Ct7cG8va.js.map +1 -0
  88. package/dist/chunks/generate.runtime-Cxg1b_BK.js +63 -0
  89. package/dist/chunks/{generate.runtime-DbMDlglD.js.map → generate.runtime-Cxg1b_BK.js.map} +1 -1
  90. package/dist/chunks/{generate.runtime-CowdMKQs.js → generate.runtime-CyWuhV6m.js} +16 -18
  91. package/dist/chunks/{generate.runtime-CowdMKQs.js.map → generate.runtime-CyWuhV6m.js.map} +1 -1
  92. package/dist/chunks/{generate.runtime-C_5Ghjri.js → generate.runtime-D769VJFt.js} +3 -4
  93. package/dist/chunks/{generate.runtime-C_5Ghjri.js.map → generate.runtime-D769VJFt.js.map} +1 -1
  94. package/dist/chunks/{generate.runtime-DroVnvQz.js → generate.runtime-DGnXHELM.js} +84 -89
  95. package/dist/chunks/{generate.runtime-DroVnvQz.js.map → generate.runtime-DGnXHELM.js.map} +1 -1
  96. package/dist/chunks/{generate.runtime-CGJ_4VS_.js → generate.runtime-DHJqOJTr.js} +93 -98
  97. package/dist/chunks/{generate.runtime-CGJ_4VS_.js.map → generate.runtime-DHJqOJTr.js.map} +1 -1
  98. package/dist/chunks/{generate.runtime-r9Ouwr5B.js → generate.runtime-DICcLOts.js} +19 -22
  99. package/dist/chunks/{generate.runtime-r9Ouwr5B.js.map → generate.runtime-DICcLOts.js.map} +1 -1
  100. package/dist/chunks/generate.runtime-DWHoDisZ.js +42 -0
  101. package/dist/chunks/{generate.runtime-BL62aRng.js.map → generate.runtime-DWHoDisZ.js.map} +1 -1
  102. package/dist/chunks/{generate.runtime-kEHEiLBL.js → generate.runtime-DfHFd8xs.js} +36 -44
  103. package/dist/chunks/{generate.runtime-kEHEiLBL.js.map → generate.runtime-DfHFd8xs.js.map} +1 -1
  104. package/dist/chunks/{generate.runtime-CCE-9xQV.js → generate.runtime-DhNspd-h.js} +64 -76
  105. package/dist/chunks/generate.runtime-DhNspd-h.js.map +1 -0
  106. package/dist/chunks/{generate.runtime-D_HYO-mG.js → generate.runtime-DkS7CBmK.js} +8 -10
  107. package/dist/chunks/{generate.runtime-D_HYO-mG.js.map → generate.runtime-DkS7CBmK.js.map} +1 -1
  108. package/dist/chunks/generate.runtime-Dtae524O.js +34 -0
  109. package/dist/chunks/{generate.runtime-C8-mjcn8.js.map → generate.runtime-Dtae524O.js.map} +1 -1
  110. package/dist/chunks/{generate.runtime-Bx_CaBZD.js → generate.runtime-Dtf3tF3-.js} +82 -92
  111. package/dist/chunks/generate.runtime-Dtf3tF3-.js.map +1 -0
  112. package/dist/chunks/{generate.runtime-B3yuIjJD.js → generate.runtime-DvTbN-no.js} +88 -145
  113. package/dist/chunks/{generate.runtime-B3yuIjJD.js.map → generate.runtime-DvTbN-no.js.map} +1 -1
  114. package/dist/chunks/{generate.runtime-BK7x32md.js → generate.runtime-EB8vpc7D.js} +57 -66
  115. package/dist/chunks/{generate.runtime-BK7x32md.js.map → generate.runtime-EB8vpc7D.js.map} +1 -1
  116. package/dist/chunks/{generate.runtime-sALBNh1T.js → generate.runtime-TCVlsBbJ.js} +7 -8
  117. package/dist/chunks/{generate.runtime-sALBNh1T.js.map → generate.runtime-TCVlsBbJ.js.map} +1 -1
  118. package/dist/chunks/{generate.runtime-BTHuPon9.js → generate.runtime-YFyuyFhh.js} +108 -132
  119. package/dist/chunks/generate.runtime-YFyuyFhh.js.map +1 -0
  120. package/dist/chunks/{generate.runtime-Ce2O5uWy.js → generate.runtime-cYh0CQ5d.js} +36 -41
  121. package/dist/chunks/{generate.runtime-Ce2O5uWy.js.map → generate.runtime-cYh0CQ5d.js.map} +1 -1
  122. package/dist/chunks/generate.runtime-erWI6j7m.js +64 -0
  123. package/dist/chunks/{generate.runtime-BBfiR_Le.js.map → generate.runtime-erWI6j7m.js.map} +1 -1
  124. package/dist/chunks/{generate.runtime-Brakd35X.js → generate.runtime-hq8xt0m_.js} +21 -23
  125. package/dist/chunks/generate.runtime-hq8xt0m_.js.map +1 -0
  126. package/dist/chunks/{generate.runtime--VeSxyIm.js → generate.runtime-i3tMIA1A.js} +85 -108
  127. package/dist/chunks/{generate.runtime--VeSxyIm.js.map → generate.runtime-i3tMIA1A.js.map} +1 -1
  128. package/dist/chunks/generate.runtime-j_5K3Uue.js +120 -0
  129. package/dist/chunks/generate.runtime-j_5K3Uue.js.map +1 -0
  130. package/dist/chunks/{generate.runtime-DbSRJF-C.js → generate.runtime-mE0knt2T.js} +34 -38
  131. package/dist/chunks/{generate.runtime-DbSRJF-C.js.map → generate.runtime-mE0knt2T.js.map} +1 -1
  132. package/dist/chunks/{layout.svelte-Cb12mxua.js → layout.svelte-B6wOQ7SM.js} +10 -11
  133. package/dist/chunks/{layout.svelte-Cb12mxua.js.map → layout.svelte-B6wOQ7SM.js.map} +1 -1
  134. package/dist/chunks/{lib-specifier-Cngo1zF_.js → lib-specifier-C3M0WTev.js} +2 -3
  135. package/dist/chunks/{lib-specifier-Cngo1zF_.js.map → lib-specifier-C3M0WTev.js.map} +1 -1
  136. package/dist/chunks/{load-function-Dmkhg1pQ.js → load-function-BFvIVsh7.js} +3 -4
  137. package/dist/chunks/{load-function-Dmkhg1pQ.js.map → load-function-BFvIVsh7.js.map} +1 -1
  138. package/dist/chunks/{logger-CQONztPm.js → logger-t1HxmpG2.js} +2 -3
  139. package/dist/chunks/{logger-CQONztPm.js.map → logger-t1HxmpG2.js.map} +1 -1
  140. package/dist/chunks/{modify-file-DdXJCMHN.js → modify-file-CRZ_gMg0.js} +7 -10
  141. package/dist/chunks/{modify-file-DdXJCMHN.js.map → modify-file-CRZ_gMg0.js.map} +1 -1
  142. package/dist/chunks/{modify-nav-user-CJ1LevSU.js → modify-nav-user--7OwY9fI.js} +7 -16
  143. package/dist/chunks/{modify-nav-user-CJ1LevSU.js.map → modify-nav-user--7OwY9fI.js.map} +1 -1
  144. package/dist/chunks/{modify-nav-user-iUpv2lm-.js → modify-nav-user-D42kWyU6.js} +8 -14
  145. package/dist/chunks/{modify-nav-user-iUpv2lm-.js.map → modify-nav-user-D42kWyU6.js.map} +1 -1
  146. package/dist/chunks/modify-svelte-config-remote-wE5K2bU_.js +20 -0
  147. package/dist/chunks/{modify-svelte-config-remote-CEyYydL7.js.map → modify-svelte-config-remote-wE5K2bU_.js.map} +1 -1
  148. package/dist/chunks/{modify-user-signup-DLtopazD.js → modify-user-signup-ENhadGKH.js} +5 -6
  149. package/dist/chunks/{modify-user-signup-DLtopazD.js.map → modify-user-signup-ENhadGKH.js.map} +1 -1
  150. package/dist/chunks/{modify-utils-Cw-on_cL.js → modify-utils--zro3IGe.js} +3 -4
  151. package/dist/chunks/{modify-utils-Cw-on_cL.js.map → modify-utils--zro3IGe.js.map} +1 -1
  152. package/dist/chunks/{package-imports-B9Asv3ZH.js → package-imports-CcIIHbp5.js} +3 -4
  153. package/dist/chunks/{package-imports-B9Asv3ZH.js.map → package-imports-CcIIHbp5.js.map} +1 -1
  154. package/dist/chunks/{pocketbase-C5GS-Dh5.js → pocketbase-CvsJYXj-.js} +2 -3
  155. package/dist/chunks/{pocketbase-C5GS-Dh5.js.map → pocketbase-CvsJYXj-.js.map} +1 -1
  156. package/dist/chunks/{pocketbase-DpudAAmd.js → pocketbase-YG9yht8R.js} +2 -3
  157. package/dist/chunks/{pocketbase-DpudAAmd.js.map → pocketbase-YG9yht8R.js.map} +1 -1
  158. package/dist/chunks/{pocketbase-uOpghyT5.js → pocketbase-gUn2UrDd.js} +6 -14
  159. package/dist/chunks/{pocketbase-uOpghyT5.js.map → pocketbase-gUn2UrDd.js.map} +1 -1
  160. package/dist/chunks/{providers-ypCW70Mb.js → providers-BB3Z2TrN.js} +4 -5
  161. package/dist/chunks/{providers-ypCW70Mb.js.map → providers-BB3Z2TrN.js.map} +1 -1
  162. package/dist/chunks/{providers-CL9kQ4hp.js → providers-tjlFH5di.js} +4 -5
  163. package/dist/chunks/{providers-CL9kQ4hp.js.map → providers-tjlFH5di.js.map} +1 -1
  164. package/dist/chunks/{rolldown-runtime-5HNE8Q1r.js → rolldown-runtime-CwxnZyOB.js} +1 -2
  165. package/dist/chunks/{root-layout.svelte-CUVbnlX-.js → root-layout.svelte-DE0c_y-T.js} +12 -16
  166. package/dist/chunks/{root-layout.svelte-CUVbnlX-.js.map → root-layout.svelte-DE0c_y-T.js.map} +1 -1
  167. package/dist/chunks/{shared-DIDAkVts.js → shared-DE-J_b1j.js} +4 -5
  168. package/dist/chunks/{shared-DIDAkVts.js.map → shared-DE-J_b1j.js.map} +1 -1
  169. package/dist/chunks/{site-CVtsbO_S.js → site-B9hDxucR.js} +11 -12
  170. package/dist/chunks/{site-CVtsbO_S.js.map → site-B9hDxucR.js.map} +1 -1
  171. package/dist/chunks/{stripe-customer-B3tP8gtD.js → stripe-customer-5S-nOXP1.js} +2 -3
  172. package/dist/chunks/stripe-customer-5S-nOXP1.js.map +1 -0
  173. package/dist/chunks/{svelte-file-Dv5-bl79.js → svelte-file-DfplF3BU.js} +2 -3
  174. package/dist/chunks/{svelte-file-Dv5-bl79.js.map → svelte-file-DfplF3BU.js.map} +1 -1
  175. package/dist/chunks/table-core-BXmnfjln.js +120 -0
  176. package/dist/chunks/table-core-BXmnfjln.js.map +1 -0
  177. package/dist/chunks/{taggedTemplateLiteral-KSUnuvOk.js → taggedTemplateLiteral-CLenToGE.js} +1 -2
  178. package/dist/chunks/{test-setup-B37g3TRn.js → test-setup-CbwhAJT4.js} +8 -11
  179. package/dist/chunks/{test-setup-B37g3TRn.js.map → test-setup-CbwhAJT4.js.map} +1 -1
  180. package/dist/chunks/{ts-morph-helpers-CHI9wAil.js → ts-morph-helpers-B4KZXP44.js} +2 -3
  181. package/dist/chunks/{ts-morph-helpers-CHI9wAil.js.map → ts-morph-helpers-B4KZXP44.js.map} +1 -1
  182. package/dist/chunks/{ui-Ct_9B91R.js → ui-Ct6YQuPw.js} +53 -55
  183. package/dist/chunks/{ui-Ct_9B91R.js.map → ui-Ct6YQuPw.js.map} +1 -1
  184. package/dist/chunks/{ui-DD4NltyN.js → ui-D5xgIDR_.js} +3 -4
  185. package/dist/chunks/{ui-DD4NltyN.js.map → ui-D5xgIDR_.js.map} +1 -1
  186. package/dist/chunks/{unmodify-load-Buak-r1f.js → unmodify-load-CdWXJ_Ac.js} +3 -4
  187. package/dist/chunks/{unmodify-load-Buak-r1f.js.map → unmodify-load-CdWXJ_Ac.js.map} +1 -1
  188. package/dist/chunks/{util-BLYliuUK.js → util-ILWdjRAd.js} +2 -3
  189. package/dist/chunks/{util-BLYliuUK.js.map → util-ILWdjRAd.js.map} +1 -1
  190. package/dist/chunks/{whatsapp-Dr29ohbb.js → whatsapp-Bt4o4_q2.js} +3 -4
  191. package/dist/chunks/{whatsapp-Dr29ohbb.js.map → whatsapp-Bt4o4_q2.js.map} +1 -1
  192. package/dist/chunks/write-result-B5KFCqxw.js +487 -0
  193. package/dist/chunks/{write-result-mtVbmDyQ.js.map → write-result-B5KFCqxw.js.map} +1 -1
  194. package/dist/chunks/{wuchale-config-c3Q4JVSF.js → wuchale-config-CNXoq4rc.js} +2 -3
  195. package/dist/chunks/{wuchale-config-c3Q4JVSF.js.map → wuchale-config-CNXoq4rc.js.map} +1 -1
  196. package/dist/index.d.ts +57 -17
  197. package/dist/index.js +2272 -2350
  198. package/dist/index.js.map +1 -1
  199. package/package.json +6 -3
  200. package/dist/chunks/_page-B6yd6_Vl.js.map +0 -1
  201. package/dist/chunks/_page-DoPdZgZv.js.map +0 -1
  202. package/dist/chunks/constants-8cLxGOB0.js +0 -6
  203. package/dist/chunks/constants-8cLxGOB0.js.map +0 -1
  204. package/dist/chunks/generate-C3OaUggX.js.map +0 -1
  205. package/dist/chunks/generate-CtQcmjPM.js.map +0 -1
  206. package/dist/chunks/generate-D21dCU-o.js +0 -58
  207. package/dist/chunks/generate.runtime--yCjGZ6-.js +0 -124
  208. package/dist/chunks/generate.runtime--yCjGZ6-.js.map +0 -1
  209. package/dist/chunks/generate.runtime-BBfiR_Le.js +0 -67
  210. package/dist/chunks/generate.runtime-BL62aRng.js +0 -43
  211. package/dist/chunks/generate.runtime-BTHuPon9.js.map +0 -1
  212. package/dist/chunks/generate.runtime-Brakd35X.js.map +0 -1
  213. package/dist/chunks/generate.runtime-Bx_CaBZD.js.map +0 -1
  214. package/dist/chunks/generate.runtime-C8-mjcn8.js +0 -35
  215. package/dist/chunks/generate.runtime-CAO_SpsA.js +0 -50
  216. package/dist/chunks/generate.runtime-CCE-9xQV.js.map +0 -1
  217. package/dist/chunks/generate.runtime-CPDJolef.js +0 -65
  218. package/dist/chunks/generate.runtime-CaOO0281.js +0 -114
  219. package/dist/chunks/generate.runtime-CeoqgxiO.js.map +0 -1
  220. package/dist/chunks/generate.runtime-DUBOC6AA.js +0 -112
  221. package/dist/chunks/generate.runtime-DVwha8lZ.js +0 -48
  222. package/dist/chunks/generate.runtime-DbMDlglD.js +0 -64
  223. package/dist/chunks/generate.runtime-DlPeHx19.js.map +0 -1
  224. package/dist/chunks/generate.runtime-HkvT9gm6.js.map +0 -1
  225. package/dist/chunks/modify-svelte-config-remote-CEyYydL7.js +0 -42
  226. package/dist/chunks/stripe-customer-B3tP8gtD.js.map +0 -1
  227. package/dist/chunks/table-core-CUGp4Rf2.js +0 -127
  228. package/dist/chunks/table-core-CUGp4Rf2.js.map +0 -1
  229. package/dist/chunks/write-result-mtVbmDyQ.js +0 -499
@@ -1,35 +1,18 @@
1
- import { t as e } from "./dedent-Gq6Krl4n.js";
2
- import { t } from "./ui-DD4NltyN.js";
3
- import { n } from "./logger-CQONztPm.js";
4
- import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-CHI9wAil.js";
5
- import { r as s } from "./modify-file-DdXJCMHN.js";
6
- import { t as c } from "./svelte-file-Dv5-bl79.js";
7
- import { t as l } from "./compose-handle-BBlamPfx.js";
8
- import { a as u, t as d } from "./config-target-BgyFkbFL.js";
9
- import { i as f, n as p } from "./_layout-DQhSAhfF.js";
10
- import { r as m, t as h } from "./wuchale-config-c3Q4JVSF.js";
1
+ import { n as e } from "./logger-t1HxmpG2.js";
2
+ import { t } from "./ui-D5xgIDR_.js";
3
+ import { r as n } from "./modify-file-CRZ_gMg0.js";
4
+ import { a as r, t as i } from "./config-target-DJbVHwHl.js";
5
+ import { _ as a, i as o, o as s, r as c } from "./ts-morph-helpers-B4KZXP44.js";
6
+ import { i as l, n as u } from "./_layout-Dju9EYqa.js";
7
+ import { t as d } from "./dedent-CCUOcPFW.js";
8
+ import { t as f } from "./compose-handle-Da7m6lV_.js";
9
+ import { t as p } from "./svelte-file-DfplF3BU.js";
10
+ import { r as m, t as h } from "./wuchale-config-CNXoq4rc.js";
11
11
  import g from "node:fs";
12
12
  import _ from "node:path";
13
13
  import { Project as v, QuoteKind as y, SyntaxKind as b } from "ts-morph";
14
- //#region src/patterns/enable/i18n/modifies/vite-config.ts
15
- var x = [
16
- "Add the wuchale plugin to your Vite config:",
17
- "",
18
- "import { wuchale } from 'wuchale/vite';",
19
- "",
20
- "export default defineConfig({",
21
- " plugins: [wuchale(), /* ...existing plugins */],",
22
- "});"
23
- ].join("\n"), S = [
24
- "Create a Vite config with the wuchale plugin:",
25
- "",
26
- "import { defineConfig } from 'vite';",
27
- "import { wuchale } from 'wuchale/vite';",
28
- "",
29
- "export default defineConfig({",
30
- " plugins: [wuchale()],",
31
- "});"
32
- ].join("\n");
14
+ // src/patterns/enable/i18n/modifies/vite-config.ts
15
+ var x = "Add the wuchale plugin to your Vite config:\n\nimport { wuchale } from 'wuchale/vite';\n\nexport default defineConfig({\n plugins: [wuchale(), /* ...existing plugins */],\n});", S = "Create a Vite config with the wuchale plugin:\n\nimport { defineConfig } from 'vite';\nimport { wuchale } from 'wuchale/vite';\n\nexport default defineConfig({\n plugins: [wuchale()],\n});";
33
16
  function C(e) {
34
17
  if (!g.existsSync(e)) return {
35
18
  status: "not-found",
@@ -43,11 +26,11 @@ function C(e) {
43
26
  namedImports: ["wuchale"],
44
27
  moduleSpecifier: "wuchale/vite"
45
28
  }), n = !0);
46
- let i = t.getDescendantsOfKind(b.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], o = i?.getKind() === b.ObjectLiteralExpression ? i : null;
47
- if (!o) r = !0;
29
+ let i = t.getDescendantsOfKind(b.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], a = i?.getKind() === b.ObjectLiteralExpression ? i : null;
30
+ if (!a) r = !0;
48
31
  else {
49
- let e = o.getProperty("plugins");
50
- if (!e) o.addPropertyAssignment({
32
+ let e = a.getProperty("plugins");
33
+ if (!e) a.addPropertyAssignment({
51
34
  name: "plugins",
52
35
  initializer: "[wuchale()]"
53
36
  }), n = !0;
@@ -62,7 +45,7 @@ function C(e) {
62
45
  }
63
46
  }
64
47
  }
65
- return n && (a(t), t.saveSync()), r ? {
48
+ return n && (s(t), t.saveSync()), r ? {
66
49
  status: "failed",
67
50
  message: x
68
51
  } : {
@@ -70,9 +53,8 @@ function C(e) {
70
53
  changed: n
71
54
  };
72
55
  }
73
- //#endregion
74
- //#region src/patterns/enable/i18n/modifies/hooks.server.ts
75
- var w = "handleWuchale", T = e`
56
+ // src/patterns/enable/i18n/modifies/hooks.server.ts
57
+ var w = "handleWuchale", T = d`
76
58
  Wrap your exported handle with the wuchale i18n handler:
77
59
 
78
60
  import { sequence } from '@sveltejs/kit/hooks';
@@ -96,7 +78,7 @@ var w = "handleWuchale", T = e`
96
78
  };
97
79
 
98
80
  export const handle = sequence(handleWuchale, /* your existing handle */);
99
- `, E = e`
81
+ `, E = d`
100
82
  import type { Handle } from '@sveltejs/kit/hooks';
101
83
  import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';
102
84
  import { getLocale } from '#locales/main.url.js';
@@ -124,33 +106,33 @@ function D(e, t, n) {
124
106
  moduleSpecifier: t
125
107
  });
126
108
  }
127
- function O(t) {
128
- if (!g.existsSync(t)) return g.existsSync(t.replace(/\.ts$/, ".js")) ? {
109
+ function O(e) {
110
+ if (!g.existsSync(e)) return g.existsSync(e.replace(/\.ts$/, ".js")) ? {
129
111
  status: "failed",
130
112
  message: T
131
- } : (g.mkdirSync(_.dirname(t), { recursive: !0 }), g.writeFileSync(t, E + "\n"), {
113
+ } : (g.mkdirSync(_.dirname(e), { recursive: !0 }), g.writeFileSync(e, E + "\n"), {
132
114
  status: "success",
133
115
  changed: !0
134
116
  });
135
- let n = g.readFileSync(t, "utf8");
136
- if (n.includes("runWithLocale") || n.includes("loadLocales(")) return {
117
+ let t = g.readFileSync(e, "utf8");
118
+ if (t.includes("runWithLocale") || t.includes("loadLocales(")) return {
137
119
  status: "success",
138
120
  changed: !1
139
121
  };
140
- let r = new v({
122
+ let n = new v({
141
123
  compilerOptions: { allowJs: !0 },
142
124
  manipulationSettings: { quoteKind: y.Single }
143
- }).addSourceFileAtPath(t), o = l(r, { expression: w });
144
- if (o.status === "unsupported" || !o.statement) return {
125
+ }).addSourceFileAtPath(e), r = f(n, { expression: w });
126
+ if (r.status === "unsupported" || !r.statement) return {
145
127
  status: "failed",
146
128
  message: T
147
129
  };
148
- let s = o.statement;
149
- i(r, "wuchale/load-utils/server", "runWithLocale"), i(r, "wuchale/load-utils/server", "loadLocales"), i(r, "#locales/main.url.js", "getLocale"), i(r, "#locales/data.js", "locales"), D(r, "#locales/main.loader.server.svelte.js", "main"), D(r, "#locales/js.loader.server.js", "js");
150
- let c = e`
130
+ let i = r.statement;
131
+ o(n, "wuchale/load-utils/server", "runWithLocale"), o(n, "wuchale/load-utils/server", "loadLocales"), o(n, "#locales/main.url.js", "getLocale"), o(n, "#locales/data.js", "locales"), D(n, "#locales/main.loader.server.svelte.js", "main"), D(n, "#locales/js.loader.server.js", "js");
132
+ let a = d`
151
133
  loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
152
134
  loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
153
- `, u = e`
135
+ `, c = d`
154
136
  const ${w} = async ({ event, resolve }: any) => {
155
137
  const locale = getLocale(event.url);
156
138
  return await runWithLocale(locale, () =>
@@ -161,20 +143,19 @@ function O(t) {
161
143
  );
162
144
  };
163
145
  `;
164
- return r.insertText(s.getStart(!0), `${c}\n\n${u}\n\n`), a(r), r.saveSync(), {
146
+ return n.insertText(i.getStart(!0), `${a}\n\n${c}\n\n`), s(n), n.saveSync(), {
165
147
  status: "success",
166
148
  changed: !0
167
149
  };
168
150
  }
169
- //#endregion
170
- //#region src/patterns/enable/i18n/modifies/hooks.ts
171
- var k = e`
151
+ // src/patterns/enable/i18n/modifies/hooks.ts
152
+ var k = d`
172
153
  const rerouteDeLocalize = (url: string) => {
173
154
  const [upath, locale] = deLocalizeDefault(url, locales);
174
155
  const { path } = matchUrl(upath, locale);
175
156
  return path ?? url;
176
157
  };
177
- `, A = e`
158
+ `, A = d`
178
159
  import { deLocalizeDefault } from 'wuchale/url';
179
160
  import { matchUrl } from '#locales/main.url.js';
180
161
  import { locales } from '#locales/data.js';
@@ -186,7 +167,7 @@ var k = e`
186
167
  };
187
168
 
188
169
  export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);
189
- `, j = e`
170
+ `, j = d`
190
171
  Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:
191
172
 
192
173
  import { deLocalizeDefault } from 'wuchale/url';
@@ -205,7 +186,7 @@ function N(e) {
205
186
  return e.getFunction("reroute") ? !0 : e.getExportDeclarations().some((e) => e.getNamedExports().some((e) => (e.getAliasNode()?.getText() ?? e.getName()) === "reroute"));
206
187
  }
207
188
  function P(e) {
208
- i(e, "wuchale/url", "deLocalizeDefault"), i(e, "#locales/main.url.js", "matchUrl"), i(e, "#locales/data.js", "locales");
189
+ o(e, "wuchale/url", "deLocalizeDefault"), o(e, "#locales/main.url.js", "matchUrl"), o(e, "#locales/data.js", "locales");
209
190
  }
210
191
  function ee(e) {
211
192
  if (!g.existsSync(e)) return g.mkdirSync(_.dirname(e), { recursive: !0 }), g.writeFileSync(e, A + "\n"), {
@@ -223,7 +204,7 @@ function ee(e) {
223
204
  if (!n) return N(t) ? {
224
205
  status: "failed",
225
206
  message: j
226
- } : (P(t), t.addStatements(`\n${k}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), a(t), t.saveSync(), {
207
+ } : (P(t), t.addStatements(`\n${k}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), s(t), t.saveSync(), {
227
208
  status: "success",
228
209
  changed: !0
229
210
  });
@@ -238,31 +219,13 @@ function ee(e) {
238
219
  };
239
220
  P(t), n.setInitializer("({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))");
240
221
  let i = t.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getName() === "reroute"));
241
- return t.insertText(i.getStart(!0), `${k}\n\n`), a(t), t.saveSync(), {
222
+ return t.insertText(i.getStart(!0), `${k}\n\n`), s(t), t.saveSync(), {
242
223
  status: "success",
243
224
  changed: !0
244
225
  };
245
226
  }
246
- //#endregion
247
- //#region src/patterns/enable/i18n/modifies/app-html.ts
248
- var F = [
249
- "Add the sveltekit lang placeholder to the <html> tag:",
250
- "",
251
- "<html lang=\"%sveltekit.lang%\">"
252
- ].join("\n"), I = [
253
- "Create src/app.html with a lang placeholder:",
254
- "",
255
- "<!doctype html>",
256
- "<html lang=\"%sveltekit.lang%\">",
257
- " <head>",
258
- " <meta charset=\"utf-8\" />",
259
- " %sveltekit.head%",
260
- " </head>",
261
- " <body data-sveltekit-preload-data=\"hover\">",
262
- " <div style=\"display: contents\">%sveltekit.body%</div>",
263
- " </body>",
264
- "</html>"
265
- ].join("\n");
227
+ // src/patterns/enable/i18n/modifies/app-html.ts
228
+ var F = "Add the sveltekit lang placeholder to the <html> tag:\n\n<html lang=\"%sveltekit.lang%\">", I = "Create src/app.html with a lang placeholder:\n\n<!doctype html>\n<html lang=\"%sveltekit.lang%\">\n <head>\n <meta charset=\"utf-8\" />\n %sveltekit.head%\n </head>\n <body data-sveltekit-preload-data=\"hover\">\n <div style=\"display: contents\">%sveltekit.body%</div>\n </body>\n</html>";
266
229
  function L(e) {
267
230
  if (!g.existsSync(e)) return {
268
231
  status: "not-found",
@@ -282,36 +245,29 @@ function L(e) {
282
245
  changed: !0
283
246
  });
284
247
  }
285
- //#endregion
286
- //#region src/patterns/enable/i18n/modifies/gitignore.ts
287
- var R = [
288
- "Create a .gitignore with the wuchale cache ignored:",
289
- "",
290
- "# Wuchale",
291
- "src/locales/.wuchale"
292
- ].join("\n");
293
- function z(t) {
294
- if (!g.existsSync(t)) return {
248
+ // src/patterns/enable/i18n/modifies/gitignore.ts
249
+ var R = "Create a .gitignore with the wuchale cache ignored:\n\n# Wuchale\nsrc/locales/.wuchale";
250
+ function z(e) {
251
+ if (!g.existsSync(e)) return {
295
252
  status: "not-found",
296
253
  message: R
297
254
  };
298
- let n = g.readFileSync(t, "utf8");
299
- if (n.includes("src/locales/.wuchale")) return {
255
+ let t = g.readFileSync(e, "utf8");
256
+ if (t.includes("src/locales/.wuchale")) return {
300
257
  status: "success",
301
258
  changed: !1
302
259
  };
303
- let r = e`
260
+ let n = d`
304
261
  # Wuchale
305
262
  src/locales/.wuchale
306
- `, i = n + (n.length > 0 && !n.endsWith("\n") ? "\n" : "") + "\n" + r + "\n";
307
- return g.writeFileSync(t, i), {
263
+ `, r = t + (t.length > 0 && !t.endsWith("\n") ? "\n" : "") + "\n" + n + "\n";
264
+ return g.writeFileSync(e, r), {
308
265
  status: "success",
309
266
  changed: !0
310
267
  };
311
268
  }
312
- //#endregion
313
- //#region src/patterns/enable/i18n/modifies/root-layout.svelte.ts
314
- var B = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", V = "<LanguageSelect />", H = e`
269
+ // src/patterns/enable/i18n/modifies/root-layout.svelte.ts
270
+ var B = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", V = "<LanguageSelect />", H = d`
315
271
  import LanguageSelect from '#lib/components/language-select.svelte';
316
272
  `, U = [
317
273
  "Add the language select inside your <Navbar.List> in the root layout.",
@@ -354,8 +310,8 @@ var B = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", V = "<L
354
310
  ].join("\n");
355
311
  function q(e) {
356
312
  e.modifyScript((e) => {
357
- let { source: t } = r(e, (e) => {
358
- o(e, [{
313
+ let { source: t } = a(e, (e) => {
314
+ c(e, [{
359
315
  defaultImport: "LanguageSelect",
360
316
  moduleSpecifier: "#lib/components/language-select.svelte"
361
317
  }]);
@@ -369,7 +325,7 @@ function J(e, t = "shadcn") {
369
325
  status: "not-found",
370
326
  message: n ? K : W
371
327
  };
372
- let r = c.fromPath(e);
328
+ let r = p.fromPath(e);
373
329
  return r.hasElement("LanguageSelect") ? {
374
330
  status: "success",
375
331
  changed: !1
@@ -387,9 +343,8 @@ function J(e, t = "shadcn") {
387
343
  message: U
388
344
  };
389
345
  }
390
- //#endregion
391
- //#region src/patterns/enable/i18n/welcome-catalog.ts
392
- var Y = "src/routes/+page.svelte", X = "src/locales/es.po", Z = ["<h1>Welcome to SvelteKit</h1>", "<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>"].join("\n"), Q = [{
346
+ // src/patterns/enable/i18n/welcome-catalog.ts
347
+ var Y = "src/routes/+page.svelte", X = "src/locales/es.po", Z = "<h1>Welcome to SvelteKit</h1>\n<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>", Q = [{
393
348
  reference: Y,
394
349
  msgid: "Welcome to SvelteKit",
395
350
  msgstr: "Bienvenido a SvelteKit"
@@ -401,17 +356,7 @@ var Y = "src/routes/+page.svelte", X = "src/locales/es.po", Z = ["<h1>Welcome to
401
356
  reference: "src/lib/components/language-select.svelte",
402
357
  msgid: "Language",
403
358
  msgstr: "Idioma"
404
- }, ne = [
405
- "msgid \"\"",
406
- "msgstr \"\"",
407
- "\"Source-Language: en\\n\"",
408
- "\"Language: es\\n\"",
409
- "\"MIME-Version: 1.0\\n\"",
410
- "\"Content-Type: text/plain; charset=utf-8\\n\"",
411
- "\"Content-Transfer-Encoding: 8bit\\n\"",
412
- "\"Plural-Forms: nplurals=3\\n\"",
413
- "\"X-Plurals-Order: one, many, other\\n\""
414
- ].join("\n"), $ = (e) => e.replace(/\s+/g, "");
359
+ }, ne = "msgid \"\"\nmsgstr \"\"\n\"Source-Language: en\\n\"\n\"Language: es\\n\"\n\"MIME-Version: 1.0\\n\"\n\"Content-Type: text/plain; charset=utf-8\\n\"\n\"Content-Transfer-Encoding: 8bit\\n\"\n\"Plural-Forms: nplurals=3\\n\"\n\"X-Plurals-Order: one, many, other\\n\"", $ = (e) => e.replace(/\s+/g, "");
415
360
  function re(e, t) {
416
361
  if (g.existsSync(_.join(e, X))) return null;
417
362
  let n = _.join(e, Y);
@@ -426,8 +371,7 @@ function re(e, t) {
426
371
  status: "success"
427
372
  };
428
373
  }
429
- //#endregion
430
- //#region src/patterns/enable/i18n/generate.runtime.ts
374
+ // src/patterns/enable/i18n/generate.runtime.ts
431
375
  function ie(e, t) {
432
376
  let n = h.filter((t) => g.existsSync(_.join(e, t)));
433
377
  return n.length === 0 ? t : t.map((e) => {
@@ -439,36 +383,36 @@ function ie(e, t) {
439
383
  } : e;
440
384
  });
441
385
  }
442
- async function ae(e) {
443
- let r = n(e), i = [], a = (e) => {
444
- e && i.push(e);
386
+ async function ae(a) {
387
+ let o = e(a), s = [], c = (e) => {
388
+ e && s.push(e);
445
389
  };
446
- r.info("Modifying vite.config");
447
- let o = u(e.root, d) ?? _.join(e.root, d[0]);
448
- a(s(o, C(o))), r.info("Adding #locales to package.json imports");
449
- let c = f(e.root);
450
- a(s(c.filePath, c.outcome)), r.info("Modifying hooks.server.ts");
451
- let l = _.join(e.root, "src", "hooks.server.ts");
452
- a(s(l, O(l))), r.info("Modifying hooks.ts");
453
- let m = _.join(e.root, "src", "hooks.ts");
454
- a(s(m, ee(m))), r.info("Modifying app.html");
455
- let h = _.join(e.root, "src", "app.html");
456
- a(s(h, L(h))), r.info("Modifying root +layout.ts");
457
- let v = _.join(e.root, "src", "routes", "+layout.ts");
458
- a(s(v, p(v))), r.info("Modifying root layout language select");
390
+ o.info("Modifying vite.config");
391
+ let d = r(a.root, i) ?? _.join(a.root, i[0]);
392
+ c(n(d, C(d))), o.info("Adding #locales to package.json imports");
393
+ let f = l(a.root);
394
+ c(n(f.filePath, f.outcome)), o.info("Modifying hooks.server.ts");
395
+ let p = _.join(a.root, "src", "hooks.server.ts");
396
+ c(n(p, O(p))), o.info("Modifying hooks.ts");
397
+ let m = _.join(a.root, "src", "hooks.ts");
398
+ c(n(m, ee(m))), o.info("Modifying app.html");
399
+ let h = _.join(a.root, "src", "app.html");
400
+ c(n(h, L(h))), o.info("Modifying root +layout.ts");
401
+ let v = _.join(a.root, "src", "routes", "+layout.ts");
402
+ c(n(v, u(v))), o.info("Modifying root layout language select");
459
403
  let y = [
460
- _.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
461
- _.join(e.root, "src", "routes", "root-layout.svelte"),
462
- _.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
463
- _.join(e.root, "src", "routes", "+layout.svelte")
464
- ], b = t(e), x = y.find((e) => g.existsSync(e)) ?? (b === "plain" ? y[3] : y[0]);
465
- a(s(x, J(x, b))), r.info("Updating .gitignore");
466
- let S = _.join(e.root, ".gitignore");
467
- a(s(S, z(S)));
468
- let w = re(e.root, b);
469
- return w && r.info("Translating the welcome page into Spanish"), {
404
+ _.join(a.root, "src", "routes", "(public)", "root-layout.svelte"),
405
+ _.join(a.root, "src", "routes", "root-layout.svelte"),
406
+ _.join(a.root, "src", "routes", "(public)", "+layout.svelte"),
407
+ _.join(a.root, "src", "routes", "+layout.svelte")
408
+ ], b = t(a), x = y.find((e) => g.existsSync(e)) ?? (b === "plain" ? y[3] : y[0]);
409
+ c(n(x, J(x, b))), o.info("Updating .gitignore");
410
+ let S = _.join(a.root, ".gitignore");
411
+ c(n(S, z(S)));
412
+ let w = re(a.root, b);
413
+ return w && o.info("Translating the welcome page into Spanish"), {
470
414
  creates: w ? [w] : [],
471
- modifies: i,
415
+ modifies: s,
472
416
  deletes: [],
473
417
  components: [],
474
418
  packages: [],
@@ -477,7 +421,6 @@ async function ae(e) {
477
421
  collectionDrops: []
478
422
  };
479
423
  }
480
- //#endregion
481
424
  export { ae as generate, ie as withLibraryTexts };
482
425
 
483
- //# sourceMappingURL=generate.runtime-B3yuIjJD.js.map
426
+ //# sourceMappingURL=generate.runtime-DvTbN-no.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-B3yuIjJD.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","dedent","withInMemoryScript","formatLikeSource","ensureImports","modifyOutcomeToFile","SvelteFile","addHandle","probeFirstExisting","VITE_CONFIG_CANDIDATES","modifyPackageImportsI18n","ensureRootLayoutI18n","withWuchaleJsFiles","TRANSLATED_LIB_FILES","fs","path","FAILURE_HINT$4","NOT_FOUND_HINT$3","modifyViteConfig","viteConfigPath","sourceFile","Project","QuoteKind","changed","failed","d","configArg","SyntaxKind","ce","configObj","pluginsProp","pluginsInit","arr","el","I18N_HANDLE","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","ensureNamespaceImport","moduleSpecifier","ns","modifyHooksServerI18n","hooksServerPath","original","composed","handleStmt","ensureNamedImport","startupSnippet","i18nHandleSnippet","DELOCALIZE_HELPER","HOOKS_SNIPPET","FAILURE_HINT$2","NEGOTIATE_ONLY_REROUTE","hasOtherReroute","n","ensureDeLocalizeImports","modifyHooksI18n","hooksPath","rerouteDecl","init","target","s","FAILURE_HINT$1","NOT_FOUND_HINT$2","modifyAppHtml","appHtmlPath","updated","match","NOT_FOUND_HINT$1","modifyGitignore","gitignorePath","block","LANGUAGE_SELECT_SNIPPET","PLAIN_LANGUAGE_SELECT_SNIPPET","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","PLAIN_FAILURE_HINT","PLAIN_NOT_FOUND_HINT","addImport","out","source","sf","modifyRootLayoutLanguageSelect","plain","ui","layoutPath","file","PAGE_PATH","CATALOG_PATH","WELCOME_PAGE","PAGE_ENTRIES","PLAIN_SELECT_ENTRY","HEADER","normalize","welcomePageCatalog","root","pagePath","entry","withLibraryTexts","present","creates","edited","generate","logger","getLogger","options","modifies","pushResult","imports","rootLayoutCandidates","resolveUi","rootLayoutPath","p","catalog"],"sources":["../../src/patterns/enable/i18n/modifies/vite-config.ts","../../src/patterns/enable/i18n/modifies/hooks.server.ts","../../src/patterns/enable/i18n/modifies/hooks.ts","../../src/patterns/enable/i18n/modifies/app-html.ts","../../src/patterns/enable/i18n/modifies/gitignore.ts","../../src/patterns/enable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/enable/i18n/welcome-catalog.ts","../../src/patterns/enable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the wuchale plugin to your Vite config:\",\n \"\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the wuchale plugin:\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale()],\",\n \"});\",\n].join(\"\\n\");\n\nexport function modifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"wuchale/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"wuchale\"],\n moduleSpecifier: \"wuchale/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as import(\"ts-morph\").ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: \"[wuchale()]\",\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (\n pluginsProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[wuchale()]\",\n );\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasWuchale = arr\n .getElements()\n .some((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n\n if (!hasWuchale) {\n arr.insertElement(0, \"wuchale()\");\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst I18N_HANDLE = \"handleWuchale\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the wuchale i18n handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale),\n }),\n );\n };\n\n export const handle = sequence(handleWuchale, /* your existing handle */);\n`;\n\n/**\n * The whole file, for a project that had no server hooks: a fresh `sv create`\n * app or a static site. `disable-i18n` deletes it again once the i18n handle\n * is all that is left.\n */\nexport const HOOKS_SERVER_SNIPPET = dedent`\n import type { Handle } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale: Handle = async ({ event, resolve }) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }) => html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n\n export const handle = handleWuchale;\n`;\n\nfunction ensureNamespaceImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n ns: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({ namespaceImport: ns, moduleSpecifier });\n}\n\nexport function modifyHooksServerI18n(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"runWithLocale\") || original.includes(\"loadLocales(\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Composed first: an unsupported handle leaves the file untouched.\n const composed = addHandle(sourceFile, { expression: I18N_HANDLE });\n if (composed.status === \"unsupported\" || !composed.statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const handleStmt = composed.statement;\n\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"runWithLocale\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"loadLocales\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"getLocale\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n ensureNamespaceImport(\n sourceFile,\n \"#locales/main.loader.server.svelte.js\",\n \"main\",\n );\n ensureNamespaceImport(sourceFile, \"#locales/js.loader.server.js\", \"js\");\n\n const startupSnippet = dedent`\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n `;\n\n const i18nHandleSnippet = dedent`\n const ${I18N_HANDLE} = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n `;\n\n // Above the handle and its JSDoc, so `handleWuchale` is declared before\n // the handle reads it.\n sourceFile.insertText(\n handleStmt.getStart(true),\n `${startupSnippet}\\n\\n${i18nHandleSnippet}\\n\\n`,\n );\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst DELOCALIZE_HELPER = dedent`\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n`;\n\n/**\n * The whole file, for a project that had no universal hooks. `disable-i18n`\n * deletes it again once the de-localizing reroute is all that is left.\n */\nexport const HOOKS_SNIPPET = dedent`\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:\n\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));\n`;\n\n/** What `enable-content-negotiation` leaves behind, to the whitespace. */\nconst NEGOTIATE_ONLY_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*negotiateReroute\\(\\s*url\\.pathname\\s*\\)$/;\n\n/** A `reroute` this modifier cannot compose with: not a variable declaration. */\nfunction hasOtherReroute(sourceFile: SourceFile): boolean {\n if (sourceFile.getFunction(\"reroute\")) return true;\n return sourceFile\n .getExportDeclarations()\n .some((d) =>\n d\n .getNamedExports()\n .some(\n (n) => (n.getAliasNode()?.getText() ?? n.getName()) === \"reroute\",\n ),\n );\n}\n\nfunction ensureDeLocalizeImports(sourceFile: SourceFile) {\n ensureNamedImport(sourceFile, \"wuchale/url\", \"deLocalizeDefault\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"matchUrl\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n}\n\n/**\n * Add the de-localizing reroute to `src/hooks.ts`, composing with the one\n * `enable-content-negotiation` wrote rather than replacing the file: either\n * pattern may be enabled first, and negotiation's `modifyHooksNegotiate`\n * composes the other way round.\n */\nexport function modifyHooksI18n(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, HOOKS_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (original.includes(\"rerouteDeLocalize\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n\n if (!rerouteDecl) {\n // A reroute in a shape ts-morph cannot rewrite (a function declaration,\n // a re-export) would collide with the one added below.\n if (hasOtherReroute(sourceFile)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n ensureDeLocalizeImports(sourceFile);\n sourceFile.addStatements(\n `\\n${DELOCALIZE_HELPER}\\n\\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init || !NEGOTIATE_ONLY_REROUTE.test(init.getText())) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureDeLocalizeImports(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n\n // Last: inserting text forgets the nodes above, and the helper has to be\n // declared before the reroute that reads it.\n const target = sourceFile\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === \"reroute\"))!;\n sourceFile.insertText(target.getStart(true), `${DELOCALIZE_HELPER}\\n\\n`);\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Add the sveltekit lang placeholder to the <html> tag:\",\n \"\",\n '<html lang=\"%sveltekit.lang%\">',\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/app.html with a lang placeholder:\",\n \"\",\n \"<!doctype html>\",\n '<html lang=\"%sveltekit.lang%\">',\n \" <head>\",\n ' <meta charset=\"utf-8\" />',\n \" %sveltekit.head%\",\n \" </head>\",\n ' <body data-sveltekit-preload-data=\"hover\">',\n ' <div style=\"display: contents\">%sveltekit.body%</div>',\n \" </body>\",\n \"</html>\",\n].join(\"\\n\");\n\nexport function modifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n if (\n original.includes('lang=\"%sveltekit.lang%\"') ||\n original.includes(\"lang='%sveltekit.lang%'\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const updated = original.replace(/<html(\\s[^>]*?)?>/i, (match) => {\n // A static lang (the templates ship lang=\"en\") is replaced by the\n // placeholder so the server hook can fill in the negotiated locale.\n if (/\\slang\\s*=/i.test(match)) {\n return match.replace(\n /\\slang\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+)/i,\n ' lang=\"%sveltekit.lang%\"',\n );\n }\n return match.replace(/<html/i, '<html lang=\"%sveltekit.lang%\"');\n });\n\n if (updated === original) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.writeFileSync(appHtmlPath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create a .gitignore with the wuchale cache ignored:\",\n \"\",\n \"# Wuchale\",\n \"src/locales/.wuchale\",\n].join(\"\\n\");\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const block = dedent`\n # Wuchale\n src/locales/.wuchale\n `;\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const updated = original + (needsNewline ? \"\\n\" : \"\") + \"\\n\" + block + \"\\n\";\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { Ui } from \"../../../../core/field/ui\";\n\nconst LANGUAGE_SELECT_SNIPPET = `<Navbar.Item>\n\t\t\t\t<LanguageSelect />\n\t\t\t</Navbar.Item>\n\t\t\t`;\n\nconst PLAIN_LANGUAGE_SELECT_SNIPPET = \"<LanguageSelect />\";\n\nconst IMPORT_SNIPPET = dedent`\n import LanguageSelect from '#lib/components/language-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the language select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a language select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_FAILURE_HINT = [\n \"Add the language select to your root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add wherever it should render, e.g. above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_NOT_FOUND_HINT = [\n \"Create a root layout that includes the language select.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nfunction addImport(file: SvelteFile): void {\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"LanguageSelect\",\n moduleSpecifier: \"#lib/components/language-select.svelte\",\n },\n ]);\n });\n return out;\n });\n}\n\n/**\n * A vela layout gets the select as the last `<Navbar.List>` item. A plain one\n * (a project vela did not create) has no navbar, so the select goes above the\n * layout's children.\n */\nexport function modifyRootLayoutLanguageSelect(\n layoutPath: string,\n ui: Ui = \"shadcn\",\n): ModifyOutcome {\n const plain = ui === \"plain\";\n if (!fs.existsSync(layoutPath)) {\n return {\n status: \"not-found\",\n message: plain ? PLAIN_NOT_FOUND_HINT : NOT_FOUND_HINT,\n };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n if (plain) {\n // Without a <script> the import has nowhere to go, and the markup alone\n // would not compile.\n if (!file.getScript()) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n if (!file.insertBeforeChildren(PLAIN_LANGUAGE_SELECT_SNIPPET)) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n addImport(file);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n }\n\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n addImport(file);\n file.insertBeforeClosingTag(\"Navbar.List\", LANGUAGE_SELECT_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File } from \"../../../core/types\";\nimport type { Ui } from \"../../../core/field/ui\";\n\nconst PAGE_PATH = \"src/routes/+page.svelte\";\nconst CATALOG_PATH = \"src/locales/es.po\";\n\n/** `src/routes/+page.svelte` as `sv create` writes it. */\nconst WELCOME_PAGE = [\n \"<h1>Welcome to SvelteKit</h1>\",\n '<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>',\n].join(\"\\n\");\n\ninterface Entry {\n reference: string;\n msgid: string;\n msgstr: string;\n}\n\nconst PAGE_ENTRIES: Entry[] = [\n {\n reference: PAGE_PATH,\n msgid: \"Welcome to SvelteKit\",\n msgstr: \"Bienvenido a SvelteKit\",\n },\n {\n reference: PAGE_PATH,\n msgid: \"Visit <0>svelte.dev/docs/kit</0> to read the documentation\",\n msgstr: \"Visita <0>svelte.dev/docs/kit</0> para leer la documentación\",\n },\n];\n\n// The native <select>'s aria-label. The shadcn select has no text of its own:\n// locale names come from Intl.DisplayNames.\nconst PLAIN_SELECT_ENTRY: Entry = {\n reference: \"src/lib/components/language-select.svelte\",\n msgid: \"Language\",\n msgstr: \"Idioma\",\n};\n\n// What wuchale writes for `es`. It rewrites the file on the first extraction,\n// keeping these translations and adding the source locale's catalog.\nconst HEADER = [\n 'msgid \"\"',\n 'msgstr \"\"',\n '\"Source-Language: en\\\\n\"',\n '\"Language: es\\\\n\"',\n '\"MIME-Version: 1.0\\\\n\"',\n '\"Content-Type: text/plain; charset=utf-8\\\\n\"',\n '\"Content-Transfer-Encoding: 8bit\\\\n\"',\n '\"Plural-Forms: nplurals=3\\\\n\"',\n '\"X-Plurals-Order: one, many, other\\\\n\"',\n].join(\"\\n\");\n\n// Whitespace is ignored so a page prettier has rewrapped still counts.\nconst normalize = (source: string) => source.replace(/\\s+/g, \"\");\n\n/**\n * A Spanish catalog for the `sv create` welcome page, so the language select\n * visibly does something on a fresh project. Anything else in the project is\n * left for the user to translate. Null unless the page is untouched, and never\n * over an existing catalog.\n */\nexport function welcomePageCatalog(root: string, ui: Ui): File | null {\n if (fs.existsSync(path.join(root, CATALOG_PATH))) return null;\n\n const pagePath = path.join(root, PAGE_PATH);\n if (!fs.existsSync(pagePath)) return null;\n const page = fs.readFileSync(pagePath, \"utf8\");\n if (normalize(page) !== normalize(WELCOME_PAGE)) return null;\n\n const entries =\n ui === \"plain\" ? [...PAGE_ENTRIES, PLAIN_SELECT_ENTRY] : PAGE_ENTRIES;\n const blocks = entries.map((entry) =>\n [\n `#: ${entry.reference}`,\n `msgid \"${entry.msgid}\"`,\n `msgstr \"${entry.msgstr}\"`,\n ].join(\"\\n\"),\n );\n\n return {\n path: CATALOG_PATH,\n language: \"text\",\n content: [HEADER, ...blocks].join(\"\\n\\n\") + \"\\n\",\n status: \"success\",\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { resolveUi } from \"../../../core/field/ui\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport { modifyPackageImportsI18n } from \"./modifies/package-imports\";\nimport { modifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { modifyHooksI18n } from \"./modifies/hooks\";\nimport { modifyAppHtml } from \"./modifies/app-html\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\nimport { modifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\nimport { welcomePageCatalog } from \"./welcome-catalog\";\nimport {\n TRANSLATED_LIB_FILES,\n withWuchaleJsFiles,\n} from \"../../../runtime/wuchale-config\";\n\n/**\n * The `wuchale.config.js` create, with the library modules that carry\n * visitor-facing text and already exist in the project (the WhatsApp order\n * message, say) listed for the js adapter. A pattern enabled later adds its\n * own module to the written config.\n */\nexport function withLibraryTexts(root: string, creates: File[]): File[] {\n const present = TRANSLATED_LIB_FILES.filter((file) =>\n fs.existsSync(path.join(root, file)),\n );\n if (present.length === 0) return creates;\n return creates.map((file) => {\n if (!file.path.endsWith(\"wuchale.config.js\")) return file;\n const edited = withWuchaleJsFiles(file.content, present);\n return edited?.changed ? { ...file, content: edited.source } : file;\n });\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, modifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Adding #locales to package.json imports\");\n const imports = modifyPackageImportsI18n(options.root);\n pushResult(modifyOutcomeToFile(imports.filePath, imports.outcome));\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerI18n(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksI18n(hooksPath)));\n\n logger.info(\"Modifying app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, modifyAppHtml(appHtmlPath)));\n\n logger.info(\"Modifying root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n pushResult(modifyOutcomeToFile(layoutPath, ensureRootLayoutI18n(layoutPath)));\n\n logger.info(\"Modifying root layout language select\");\n const rootLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const ui = resolveUi(options);\n // With no layout at all, a plain project's not-found hint names the\n // +layout.svelte it would have rather than vela's root-layout.svelte.\n const rootLayoutPath =\n rootLayoutCandidates.find((p) => fs.existsSync(p)) ??\n (ui === \"plain\" ? rootLayoutCandidates[3] : rootLayoutCandidates[0]);\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyRootLayoutLanguageSelect(rootLayoutPath, ui),\n ),\n );\n\n logger.info(\"Updating .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, modifyGitignore(gitignorePath)),\n );\n\n const catalog = welcomePageCatalog(options.root, ui);\n if (catalog) logger.info(\"Translating the welcome page into Spanish\");\n\n return {\n creates: catalog ? [catalog] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,IAAMA,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgBuB,EAAiB,GAAuC;CACtE,IAAI,CAACJ,EAAG,WAAWK,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAASxB;CAAe;CAOxD,IAAMyB,IAAa,IAJCC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBH,CAAc,GAEzDI,IAAU,IACVC,IAAS;CAMb,AAJkBJ,EACf,sBAAsB,CAAC,CACvB,MAAM,MAAMK,EAAE,wBAAwB,MAAM,cAE1C,MACHL,EAAW,wBAAwB,GAAG;EACpC,cAAc,CAAC,SAAS;EACxB,iBAAiB;CACnB,CAAC,GACD,IAAU;CAOZ,IAAMM,IAJmBN,EACtB,qBAAqBO,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,cAE/B,CAAA,EAAkB,aAAa,CAAC,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D,EAAK,KAAK0F,EAAQ,MAAM,YAAY;CAC1D,EACEpG,EAAoBgE,GAAeD,EAAgBC,CAAa,CAAC,CACnE;CAEA,IAAM4C,IAAUnB,GAAmBW,EAAQ,MAAMrB,CAAE;CAGnD,OAFI6B,KAASV,EAAO,KAAK,2CAA2C,GAE7D;EACL,SAASU,IAAU,CAACA,CAAO,IAAI,CAAC;EAChC;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate.runtime-DvTbN-no.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","getLogger","modifyOutcomeToFile","probeFirstExisting","VITE_CONFIG_CANDIDATES","withInMemoryScript","ensureNamedImport","formatLikeSource","ensureImports","modifyPackageImportsI18n","ensureRootLayoutI18n","dedent","addHandle","SvelteFile","withWuchaleJsFiles","TRANSLATED_LIB_FILES","fs","path","FAILURE_HINT$4","NOT_FOUND_HINT$3","modifyViteConfig","viteConfigPath","sourceFile","Project","QuoteKind","changed","failed","d","configArg","SyntaxKind","ce","configObj","pluginsProp","pluginsInit","arr","el","I18N_HANDLE","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","ensureNamespaceImport","moduleSpecifier","ns","modifyHooksServerI18n","hooksServerPath","original","composed","handleStmt","startupSnippet","i18nHandleSnippet","DELOCALIZE_HELPER","HOOKS_SNIPPET","FAILURE_HINT$2","NEGOTIATE_ONLY_REROUTE","hasOtherReroute","n","ensureDeLocalizeImports","modifyHooksI18n","hooksPath","rerouteDecl","init","target","s","FAILURE_HINT$1","NOT_FOUND_HINT$2","modifyAppHtml","appHtmlPath","updated","match","NOT_FOUND_HINT$1","modifyGitignore","gitignorePath","block","LANGUAGE_SELECT_SNIPPET","PLAIN_LANGUAGE_SELECT_SNIPPET","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","PLAIN_FAILURE_HINT","PLAIN_NOT_FOUND_HINT","addImport","out","source","sf","modifyRootLayoutLanguageSelect","plain","ui","layoutPath","file","PAGE_PATH","CATALOG_PATH","WELCOME_PAGE","PAGE_ENTRIES","PLAIN_SELECT_ENTRY","HEADER","normalize","welcomePageCatalog","root","pagePath","entry","withLibraryTexts","present","creates","edited","generate","logger","options","modifies","pushResult","imports","rootLayoutCandidates","resolveUi","rootLayoutPath","p","catalog"],"sources":["../../src/patterns/enable/i18n/modifies/vite-config.ts","../../src/patterns/enable/i18n/modifies/hooks.server.ts","../../src/patterns/enable/i18n/modifies/hooks.ts","../../src/patterns/enable/i18n/modifies/app-html.ts","../../src/patterns/enable/i18n/modifies/gitignore.ts","../../src/patterns/enable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/enable/i18n/welcome-catalog.ts","../../src/patterns/enable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the wuchale plugin to your Vite config:\",\n \"\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the wuchale plugin:\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale()],\",\n \"});\",\n].join(\"\\n\");\n\nexport function modifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"wuchale/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"wuchale\"],\n moduleSpecifier: \"wuchale/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as import(\"ts-morph\").ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: \"[wuchale()]\",\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (\n pluginsProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[wuchale()]\",\n );\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasWuchale = arr\n .getElements()\n .some((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n\n if (!hasWuchale) {\n arr.insertElement(0, \"wuchale()\");\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst I18N_HANDLE = \"handleWuchale\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the wuchale i18n handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale),\n }),\n );\n };\n\n export const handle = sequence(handleWuchale, /* your existing handle */);\n`;\n\n/**\n * The whole file, for a project that had no server hooks: a fresh `sv create`\n * app or a static site. `disable-i18n` deletes it again once the i18n handle\n * is all that is left.\n */\nexport const HOOKS_SERVER_SNIPPET = dedent`\n import type { Handle } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale: Handle = async ({ event, resolve }) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }) => html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n\n export const handle = handleWuchale;\n`;\n\nfunction ensureNamespaceImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n ns: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({ namespaceImport: ns, moduleSpecifier });\n}\n\nexport function modifyHooksServerI18n(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"runWithLocale\") || original.includes(\"loadLocales(\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Composed first: an unsupported handle leaves the file untouched.\n const composed = addHandle(sourceFile, { expression: I18N_HANDLE });\n if (composed.status === \"unsupported\" || !composed.statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const handleStmt = composed.statement;\n\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"runWithLocale\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"loadLocales\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"getLocale\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n ensureNamespaceImport(\n sourceFile,\n \"#locales/main.loader.server.svelte.js\",\n \"main\",\n );\n ensureNamespaceImport(sourceFile, \"#locales/js.loader.server.js\", \"js\");\n\n const startupSnippet = dedent`\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n `;\n\n const i18nHandleSnippet = dedent`\n const ${I18N_HANDLE} = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n `;\n\n // Above the handle and its JSDoc, so `handleWuchale` is declared before\n // the handle reads it.\n sourceFile.insertText(\n handleStmt.getStart(true),\n `${startupSnippet}\\n\\n${i18nHandleSnippet}\\n\\n`,\n );\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst DELOCALIZE_HELPER = dedent`\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n`;\n\n/**\n * The whole file, for a project that had no universal hooks. `disable-i18n`\n * deletes it again once the de-localizing reroute is all that is left.\n */\nexport const HOOKS_SNIPPET = dedent`\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:\n\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));\n`;\n\n/** What `enable-content-negotiation` leaves behind, to the whitespace. */\nconst NEGOTIATE_ONLY_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*negotiateReroute\\(\\s*url\\.pathname\\s*\\)$/;\n\n/** A `reroute` this modifier cannot compose with: not a variable declaration. */\nfunction hasOtherReroute(sourceFile: SourceFile): boolean {\n if (sourceFile.getFunction(\"reroute\")) return true;\n return sourceFile\n .getExportDeclarations()\n .some((d) =>\n d\n .getNamedExports()\n .some(\n (n) => (n.getAliasNode()?.getText() ?? n.getName()) === \"reroute\",\n ),\n );\n}\n\nfunction ensureDeLocalizeImports(sourceFile: SourceFile) {\n ensureNamedImport(sourceFile, \"wuchale/url\", \"deLocalizeDefault\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"matchUrl\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n}\n\n/**\n * Add the de-localizing reroute to `src/hooks.ts`, composing with the one\n * `enable-content-negotiation` wrote rather than replacing the file: either\n * pattern may be enabled first, and negotiation's `modifyHooksNegotiate`\n * composes the other way round.\n */\nexport function modifyHooksI18n(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, HOOKS_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (original.includes(\"rerouteDeLocalize\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n\n if (!rerouteDecl) {\n // A reroute in a shape ts-morph cannot rewrite (a function declaration,\n // a re-export) would collide with the one added below.\n if (hasOtherReroute(sourceFile)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n ensureDeLocalizeImports(sourceFile);\n sourceFile.addStatements(\n `\\n${DELOCALIZE_HELPER}\\n\\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init || !NEGOTIATE_ONLY_REROUTE.test(init.getText())) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureDeLocalizeImports(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n\n // Last: inserting text forgets the nodes above, and the helper has to be\n // declared before the reroute that reads it.\n const target = sourceFile\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === \"reroute\"))!;\n sourceFile.insertText(target.getStart(true), `${DELOCALIZE_HELPER}\\n\\n`);\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Add the sveltekit lang placeholder to the <html> tag:\",\n \"\",\n '<html lang=\"%sveltekit.lang%\">',\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/app.html with a lang placeholder:\",\n \"\",\n \"<!doctype html>\",\n '<html lang=\"%sveltekit.lang%\">',\n \" <head>\",\n ' <meta charset=\"utf-8\" />',\n \" %sveltekit.head%\",\n \" </head>\",\n ' <body data-sveltekit-preload-data=\"hover\">',\n ' <div style=\"display: contents\">%sveltekit.body%</div>',\n \" </body>\",\n \"</html>\",\n].join(\"\\n\");\n\nexport function modifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n if (\n original.includes('lang=\"%sveltekit.lang%\"') ||\n original.includes(\"lang='%sveltekit.lang%'\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const updated = original.replace(/<html(\\s[^>]*?)?>/i, (match) => {\n // A static lang (the templates ship lang=\"en\") is replaced by the\n // placeholder so the server hook can fill in the negotiated locale.\n if (/\\slang\\s*=/i.test(match)) {\n return match.replace(\n /\\slang\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+)/i,\n ' lang=\"%sveltekit.lang%\"',\n );\n }\n return match.replace(/<html/i, '<html lang=\"%sveltekit.lang%\"');\n });\n\n if (updated === original) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.writeFileSync(appHtmlPath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create a .gitignore with the wuchale cache ignored:\",\n \"\",\n \"# Wuchale\",\n \"src/locales/.wuchale\",\n].join(\"\\n\");\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const block = dedent`\n # Wuchale\n src/locales/.wuchale\n `;\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const updated = original + (needsNewline ? \"\\n\" : \"\") + \"\\n\" + block + \"\\n\";\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { Ui } from \"../../../../core/field/ui\";\n\nconst LANGUAGE_SELECT_SNIPPET = `<Navbar.Item>\n\t\t\t\t<LanguageSelect />\n\t\t\t</Navbar.Item>\n\t\t\t`;\n\nconst PLAIN_LANGUAGE_SELECT_SNIPPET = \"<LanguageSelect />\";\n\nconst IMPORT_SNIPPET = dedent`\n import LanguageSelect from '#lib/components/language-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the language select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a language select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_FAILURE_HINT = [\n \"Add the language select to your root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add wherever it should render, e.g. above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_NOT_FOUND_HINT = [\n \"Create a root layout that includes the language select.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nfunction addImport(file: SvelteFile): void {\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"LanguageSelect\",\n moduleSpecifier: \"#lib/components/language-select.svelte\",\n },\n ]);\n });\n return out;\n });\n}\n\n/**\n * A vela layout gets the select as the last `<Navbar.List>` item. A plain one\n * (a project vela did not create) has no navbar, so the select goes above the\n * layout's children.\n */\nexport function modifyRootLayoutLanguageSelect(\n layoutPath: string,\n ui: Ui = \"shadcn\",\n): ModifyOutcome {\n const plain = ui === \"plain\";\n if (!fs.existsSync(layoutPath)) {\n return {\n status: \"not-found\",\n message: plain ? PLAIN_NOT_FOUND_HINT : NOT_FOUND_HINT,\n };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n if (plain) {\n // Without a <script> the import has nowhere to go, and the markup alone\n // would not compile.\n if (!file.getScript()) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n if (!file.insertBeforeChildren(PLAIN_LANGUAGE_SELECT_SNIPPET)) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n addImport(file);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n }\n\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n addImport(file);\n file.insertBeforeClosingTag(\"Navbar.List\", LANGUAGE_SELECT_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File } from \"../../../core/types\";\nimport type { Ui } from \"../../../core/field/ui\";\n\nconst PAGE_PATH = \"src/routes/+page.svelte\";\nconst CATALOG_PATH = \"src/locales/es.po\";\n\n/** `src/routes/+page.svelte` as `sv create` writes it. */\nconst WELCOME_PAGE = [\n \"<h1>Welcome to SvelteKit</h1>\",\n '<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>',\n].join(\"\\n\");\n\ninterface Entry {\n reference: string;\n msgid: string;\n msgstr: string;\n}\n\nconst PAGE_ENTRIES: Entry[] = [\n {\n reference: PAGE_PATH,\n msgid: \"Welcome to SvelteKit\",\n msgstr: \"Bienvenido a SvelteKit\",\n },\n {\n reference: PAGE_PATH,\n msgid: \"Visit <0>svelte.dev/docs/kit</0> to read the documentation\",\n msgstr: \"Visita <0>svelte.dev/docs/kit</0> para leer la documentación\",\n },\n];\n\n// The native <select>'s aria-label. The shadcn select has no text of its own:\n// locale names come from Intl.DisplayNames.\nconst PLAIN_SELECT_ENTRY: Entry = {\n reference: \"src/lib/components/language-select.svelte\",\n msgid: \"Language\",\n msgstr: \"Idioma\",\n};\n\n// What wuchale writes for `es`. It rewrites the file on the first extraction,\n// keeping these translations and adding the source locale's catalog.\nconst HEADER = [\n 'msgid \"\"',\n 'msgstr \"\"',\n '\"Source-Language: en\\\\n\"',\n '\"Language: es\\\\n\"',\n '\"MIME-Version: 1.0\\\\n\"',\n '\"Content-Type: text/plain; charset=utf-8\\\\n\"',\n '\"Content-Transfer-Encoding: 8bit\\\\n\"',\n '\"Plural-Forms: nplurals=3\\\\n\"',\n '\"X-Plurals-Order: one, many, other\\\\n\"',\n].join(\"\\n\");\n\n// Whitespace is ignored so a page prettier has rewrapped still counts.\nconst normalize = (source: string) => source.replace(/\\s+/g, \"\");\n\n/**\n * A Spanish catalog for the `sv create` welcome page, so the language select\n * visibly does something on a fresh project. Anything else in the project is\n * left for the user to translate. Null unless the page is untouched, and never\n * over an existing catalog.\n */\nexport function welcomePageCatalog(root: string, ui: Ui): File | null {\n if (fs.existsSync(path.join(root, CATALOG_PATH))) return null;\n\n const pagePath = path.join(root, PAGE_PATH);\n if (!fs.existsSync(pagePath)) return null;\n const page = fs.readFileSync(pagePath, \"utf8\");\n if (normalize(page) !== normalize(WELCOME_PAGE)) return null;\n\n const entries =\n ui === \"plain\" ? [...PAGE_ENTRIES, PLAIN_SELECT_ENTRY] : PAGE_ENTRIES;\n const blocks = entries.map((entry) =>\n [\n `#: ${entry.reference}`,\n `msgid \"${entry.msgid}\"`,\n `msgstr \"${entry.msgstr}\"`,\n ].join(\"\\n\"),\n );\n\n return {\n path: CATALOG_PATH,\n language: \"text\",\n content: [HEADER, ...blocks].join(\"\\n\\n\") + \"\\n\",\n status: \"success\",\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { resolveUi } from \"../../../core/field/ui\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport { modifyPackageImportsI18n } from \"./modifies/package-imports\";\nimport { modifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { modifyHooksI18n } from \"./modifies/hooks\";\nimport { modifyAppHtml } from \"./modifies/app-html\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\nimport { modifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\nimport { welcomePageCatalog } from \"./welcome-catalog\";\nimport {\n TRANSLATED_LIB_FILES,\n withWuchaleJsFiles,\n} from \"../../../runtime/wuchale-config\";\n\n/**\n * The `wuchale.config.js` create, with the library modules that carry\n * visitor-facing text and already exist in the project (the WhatsApp order\n * message, say) listed for the js adapter. A pattern enabled later adds its\n * own module to the written config.\n */\nexport function withLibraryTexts(root: string, creates: File[]): File[] {\n const present = TRANSLATED_LIB_FILES.filter((file) =>\n fs.existsSync(path.join(root, file)),\n );\n if (present.length === 0) return creates;\n return creates.map((file) => {\n if (!file.path.endsWith(\"wuchale.config.js\")) return file;\n const edited = withWuchaleJsFiles(file.content, present);\n return edited?.changed ? { ...file, content: edited.source } : file;\n });\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, modifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Adding #locales to package.json imports\");\n const imports = modifyPackageImportsI18n(options.root);\n pushResult(modifyOutcomeToFile(imports.filePath, imports.outcome));\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerI18n(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksI18n(hooksPath)));\n\n logger.info(\"Modifying app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, modifyAppHtml(appHtmlPath)));\n\n logger.info(\"Modifying root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n pushResult(modifyOutcomeToFile(layoutPath, ensureRootLayoutI18n(layoutPath)));\n\n logger.info(\"Modifying root layout language select\");\n const rootLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const ui = resolveUi(options);\n // With no layout at all, a plain project's not-found hint names the\n // +layout.svelte it would have rather than vela's root-layout.svelte.\n const rootLayoutPath =\n rootLayoutCandidates.find((p) => fs.existsSync(p)) ??\n (ui === \"plain\" ? rootLayoutCandidates[3] : rootLayoutCandidates[0]);\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyRootLayoutLanguageSelect(rootLayoutPath, ui),\n ),\n );\n\n logger.info(\"Updating .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, modifyGitignore(gitignorePath)),\n );\n\n const catalog = welcomePageCatalog(options.root, ui);\n if (catalog) logger.info(\"Translating the welcome page into Spanish\");\n\n return {\n creates: catalog ? [catalog] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,IAAMA,IAAe,oLAUfC,IAAiB;AAWvB,SAAgByB,EAAiB,GAAuC;CACtE,IAAI,CAACJ,EAAG,WAAWK,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAAS1B;CAAe;CAOxD,IAAM2B,IAAa,IAJCC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBH,CAAc,GAEzDI,IAAU,IACVC,IAAS;CAMb,AAJkBJ,EACf,sBAAsB,CAAC,CACvB,MAAM,MAAMK,EAAE,wBAAwB,MAAM,cAE1C,MACHL,EAAW,wBAAwB,GAAG;EACpC,cAAc,CAAC,SAAS;EACxB,iBAAiB;CACnB,CAAC,GACD,IAAU;CAOZ,IAAMM,IAJmBN,EACtB,qBAAqBO,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,cAE/B,CAAA,EAAkB,aAAa,CAAC,GAAG,IAC/CC,IACJH,GAAW,QAAQ,MAAMC,EAAW,0BAC/BD,IACD;CAEN,IAAI,CAACG,GACH,IAAS;MACJ;EACL,IAAMC,IAAcD,EAAU,YAAY,SAAS;EACnD,IAAI,CAACC,GAKH,AAJAD,EAAU,sBAAsB;GAC9B,MAAM;GACN,aAAa;EACf,CAAC,GAC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