@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.
- package/README.md +21 -2
- package/dist/chunks/{_layout-DQhSAhfF.js → _layout-Dju9EYqa.js} +6 -8
- package/dist/chunks/{_layout-DQhSAhfF.js.map → _layout-Dju9EYqa.js.map} +1 -1
- package/dist/chunks/{_page-C7kGoW7_.js → _page-44USwLXO.js} +2 -3
- package/dist/chunks/{_page-C7kGoW7_.js.map → _page-44USwLXO.js.map} +1 -1
- package/dist/chunks/{_page-DoPdZgZv.js → _page-Bt37d4uo.js} +2 -3
- package/dist/chunks/_page-Bt37d4uo.js.map +1 -0
- package/dist/chunks/{_page-B6yd6_Vl.js → _page-DcbEFpyw.js} +2 -3
- package/dist/chunks/_page-DcbEFpyw.js.map +1 -0
- package/dist/chunks/{auth-pages-jsyDV1GR.js → auth-pages-BW3_yluN.js} +6 -9
- package/dist/chunks/{auth-pages-jsyDV1GR.js.map → auth-pages-BW3_yluN.js.map} +1 -1
- package/dist/chunks/{collections-DZOuRpvS.js → collections-CFW9ZqUE.js} +5 -7
- package/dist/chunks/{collections-DZOuRpvS.js.map → collections-CFW9ZqUE.js.map} +1 -1
- package/dist/chunks/{collections-DzwWwFUQ.js → collections-D-xbHi4M.js} +39 -45
- package/dist/chunks/{collections-DzwWwFUQ.js.map → collections-D-xbHi4M.js.map} +1 -1
- package/dist/chunks/{compose-handle-BBlamPfx.js → compose-handle-Da7m6lV_.js} +3 -4
- package/dist/chunks/{compose-handle-BBlamPfx.js.map → compose-handle-Da7m6lV_.js.map} +1 -1
- package/dist/chunks/{config-target-BgyFkbFL.js → config-target-DJbVHwHl.js} +3 -4
- package/dist/chunks/{config-target-BgyFkbFL.js.map → config-target-DJbVHwHl.js.map} +1 -1
- package/dist/chunks/constants-DpK-r_m5.js +85 -0
- package/dist/chunks/constants-DpK-r_m5.js.map +1 -0
- package/dist/chunks/{currency.server-CzHS7Svd.js → currency.server-BwuXG0a9.js} +9 -11
- package/dist/chunks/{currency.server-CzHS7Svd.js.map → currency.server-BwuXG0a9.js.map} +1 -1
- package/dist/chunks/{dedent-Gq6Krl4n.js → dedent-CCUOcPFW.js} +2 -3
- package/dist/chunks/{dedent-Gq6Krl4n.js.map → dedent-CCUOcPFW.js.map} +1 -1
- package/dist/chunks/{dispatch-BIvOwbKN.js → dispatch-BxlKS_5v.js} +2 -3
- package/dist/chunks/{dispatch-BIvOwbKN.js.map → dispatch-BxlKS_5v.js.map} +1 -1
- package/dist/chunks/{env-BugddEjd.js → env-AxyRWcC_.js} +2 -3
- package/dist/chunks/{env-BugddEjd.js.map → env-AxyRWcC_.js.map} +1 -1
- package/dist/chunks/{env-vars-mnRA0hOe.js → env-vars-CUh4mLM_.js} +2 -3
- package/dist/chunks/{env-vars-mnRA0hOe.js.map → env-vars-CUh4mLM_.js.map} +1 -1
- package/dist/chunks/{env-vars-CNH-ItSY.js → env-vars-CVn2076k.js} +58 -59
- package/dist/chunks/{env-vars-CNH-ItSY.js.map → env-vars-CVn2076k.js.map} +1 -1
- package/dist/chunks/{env-vars-Cr4lbMD_.js → env-vars-T3_7JNSg.js} +3 -4
- package/dist/chunks/{env-vars-Cr4lbMD_.js.map → env-vars-T3_7JNSg.js.map} +1 -1
- package/dist/chunks/{env-vars-file-B_6esJW3.js → env-vars-file-B2zHQZqO.js} +2 -3
- package/dist/chunks/{env-vars-file-B_6esJW3.js.map → env-vars-file-B2zHQZqO.js.map} +1 -1
- package/dist/chunks/{env.preview-uMRKT5Pc.js → env.preview-C676UTOP.js} +2 -3
- package/dist/chunks/{env.preview-uMRKT5Pc.js.map → env.preview-C676UTOP.js.map} +1 -1
- package/dist/chunks/{errors-DR3gF_7a.js → errors-DdSUZI8f.js} +2 -3
- package/dist/chunks/{errors-DR3gF_7a.js.map → errors-DdSUZI8f.js.map} +1 -1
- package/dist/chunks/{format-result-BVoLVknk.js → format-result-CojavkIZ.js} +2 -3
- package/dist/chunks/{format-result-BVoLVknk.js.map → format-result-CojavkIZ.js.map} +1 -1
- package/dist/chunks/{generate-BEc_h7OI.js → generate-BCYvhyF9.js} +62 -63
- package/dist/chunks/{generate-BEc_h7OI.js.map → generate-BCYvhyF9.js.map} +1 -1
- package/dist/chunks/{generate-DyV5R8NP.js → generate-CKuUg3p-.js} +3 -4
- package/dist/chunks/{generate-DyV5R8NP.js.map → generate-CKuUg3p-.js.map} +1 -1
- package/dist/chunks/{generate-CtQcmjPM.js → generate-CY_Ii_bz.js} +79 -82
- package/dist/chunks/generate-CY_Ii_bz.js.map +1 -0
- package/dist/chunks/generate-CuOm66dn.js +57 -0
- package/dist/chunks/{generate-D21dCU-o.js.map → generate-CuOm66dn.js.map} +1 -1
- package/dist/chunks/{generate-BrOPb9tW.js → generate-DYq5Oj58.js} +3 -4
- package/dist/chunks/{generate-BrOPb9tW.js.map → generate-DYq5Oj58.js.map} +1 -1
- package/dist/chunks/{generate-DiwvSC9c.js → generate-F4FDWvFo.js} +13 -14
- package/dist/chunks/{generate-DiwvSC9c.js.map → generate-F4FDWvFo.js.map} +1 -1
- package/dist/chunks/{generate-C3OaUggX.js → generate-oZ1QeqPr.js} +25 -27
- package/dist/chunks/generate-oZ1QeqPr.js.map +1 -0
- package/dist/chunks/{generate.runtime-DOv-bhM6.js → generate.runtime-22jW8aVT.js} +37 -41
- package/dist/chunks/{generate.runtime-DOv-bhM6.js.map → generate.runtime-22jW8aVT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CtFCayo8.js → generate.runtime-B06rPt_j.js} +103 -108
- package/dist/chunks/{generate.runtime-CtFCayo8.js.map → generate.runtime-B06rPt_j.js.map} +1 -1
- package/dist/chunks/{generate.runtime-HkvT9gm6.js → generate.runtime-BEmSIAop.js} +44 -47
- package/dist/chunks/generate.runtime-BEmSIAop.js.map +1 -0
- package/dist/chunks/{generate.runtime-DRuPb-67.js → generate.runtime-BgGeOqYG.js} +19 -21
- package/dist/chunks/{generate.runtime-DRuPb-67.js.map → generate.runtime-BgGeOqYG.js.map} +1 -1
- package/dist/chunks/generate.runtime-Bz9z0VPR.js +108 -0
- package/dist/chunks/{generate.runtime-DUBOC6AA.js.map → generate.runtime-Bz9z0VPR.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D34lCyet.js → generate.runtime-C37djibw.js} +25 -27
- package/dist/chunks/{generate.runtime-D34lCyet.js.map → generate.runtime-C37djibw.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Drpy9sWO.js → generate.runtime-CM3bj0nP.js} +12 -14
- package/dist/chunks/{generate.runtime-Drpy9sWO.js.map → generate.runtime-CM3bj0nP.js.map} +1 -1
- package/dist/chunks/generate.runtime-CMuxVUIY.js +46 -0
- package/dist/chunks/{generate.runtime-DVwha8lZ.js.map → generate.runtime-CMuxVUIY.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DlPeHx19.js → generate.runtime-CVqPHddZ.js} +44 -46
- package/dist/chunks/generate.runtime-CVqPHddZ.js.map +1 -0
- package/dist/chunks/generate.runtime-Cco2mFW2.js +63 -0
- package/dist/chunks/{generate.runtime-CPDJolef.js.map → generate.runtime-Cco2mFW2.js.map} +1 -1
- package/dist/chunks/generate.runtime-Cg-dfN9B.js +48 -0
- package/dist/chunks/{generate.runtime-CAO_SpsA.js.map → generate.runtime-Cg-dfN9B.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dy9uuf7M.js → generate.runtime-Cgam_XCc.js} +47 -50
- package/dist/chunks/{generate.runtime-Dy9uuf7M.js.map → generate.runtime-Cgam_XCc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DOWDoe6B.js → generate.runtime-CjqX4tDg.js} +5 -6
- package/dist/chunks/{generate.runtime-DOWDoe6B.js.map → generate.runtime-CjqX4tDg.js.map} +1 -1
- package/dist/chunks/generate.runtime-Cry-DBNl.js +111 -0
- package/dist/chunks/{generate.runtime-CaOO0281.js.map → generate.runtime-Cry-DBNl.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CeoqgxiO.js → generate.runtime-Ct7cG8va.js} +76 -79
- package/dist/chunks/generate.runtime-Ct7cG8va.js.map +1 -0
- package/dist/chunks/generate.runtime-Cxg1b_BK.js +63 -0
- package/dist/chunks/{generate.runtime-DbMDlglD.js.map → generate.runtime-Cxg1b_BK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CowdMKQs.js → generate.runtime-CyWuhV6m.js} +16 -18
- package/dist/chunks/{generate.runtime-CowdMKQs.js.map → generate.runtime-CyWuhV6m.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C_5Ghjri.js → generate.runtime-D769VJFt.js} +3 -4
- package/dist/chunks/{generate.runtime-C_5Ghjri.js.map → generate.runtime-D769VJFt.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DroVnvQz.js → generate.runtime-DGnXHELM.js} +84 -89
- package/dist/chunks/{generate.runtime-DroVnvQz.js.map → generate.runtime-DGnXHELM.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CGJ_4VS_.js → generate.runtime-DHJqOJTr.js} +93 -98
- package/dist/chunks/{generate.runtime-CGJ_4VS_.js.map → generate.runtime-DHJqOJTr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-r9Ouwr5B.js → generate.runtime-DICcLOts.js} +19 -22
- package/dist/chunks/{generate.runtime-r9Ouwr5B.js.map → generate.runtime-DICcLOts.js.map} +1 -1
- package/dist/chunks/generate.runtime-DWHoDisZ.js +42 -0
- package/dist/chunks/{generate.runtime-BL62aRng.js.map → generate.runtime-DWHoDisZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-kEHEiLBL.js → generate.runtime-DfHFd8xs.js} +36 -44
- package/dist/chunks/{generate.runtime-kEHEiLBL.js.map → generate.runtime-DfHFd8xs.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CCE-9xQV.js → generate.runtime-DhNspd-h.js} +64 -76
- package/dist/chunks/generate.runtime-DhNspd-h.js.map +1 -0
- package/dist/chunks/{generate.runtime-D_HYO-mG.js → generate.runtime-DkS7CBmK.js} +8 -10
- package/dist/chunks/{generate.runtime-D_HYO-mG.js.map → generate.runtime-DkS7CBmK.js.map} +1 -1
- package/dist/chunks/generate.runtime-Dtae524O.js +34 -0
- package/dist/chunks/{generate.runtime-C8-mjcn8.js.map → generate.runtime-Dtae524O.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bx_CaBZD.js → generate.runtime-Dtf3tF3-.js} +82 -92
- package/dist/chunks/generate.runtime-Dtf3tF3-.js.map +1 -0
- package/dist/chunks/{generate.runtime-B3yuIjJD.js → generate.runtime-DvTbN-no.js} +88 -145
- package/dist/chunks/{generate.runtime-B3yuIjJD.js.map → generate.runtime-DvTbN-no.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BK7x32md.js → generate.runtime-EB8vpc7D.js} +57 -66
- package/dist/chunks/{generate.runtime-BK7x32md.js.map → generate.runtime-EB8vpc7D.js.map} +1 -1
- package/dist/chunks/{generate.runtime-sALBNh1T.js → generate.runtime-TCVlsBbJ.js} +7 -8
- package/dist/chunks/{generate.runtime-sALBNh1T.js.map → generate.runtime-TCVlsBbJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BTHuPon9.js → generate.runtime-YFyuyFhh.js} +108 -132
- package/dist/chunks/generate.runtime-YFyuyFhh.js.map +1 -0
- package/dist/chunks/{generate.runtime-Ce2O5uWy.js → generate.runtime-cYh0CQ5d.js} +36 -41
- package/dist/chunks/{generate.runtime-Ce2O5uWy.js.map → generate.runtime-cYh0CQ5d.js.map} +1 -1
- package/dist/chunks/generate.runtime-erWI6j7m.js +64 -0
- package/dist/chunks/{generate.runtime-BBfiR_Le.js.map → generate.runtime-erWI6j7m.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Brakd35X.js → generate.runtime-hq8xt0m_.js} +21 -23
- package/dist/chunks/generate.runtime-hq8xt0m_.js.map +1 -0
- package/dist/chunks/{generate.runtime--VeSxyIm.js → generate.runtime-i3tMIA1A.js} +85 -108
- package/dist/chunks/{generate.runtime--VeSxyIm.js.map → generate.runtime-i3tMIA1A.js.map} +1 -1
- package/dist/chunks/generate.runtime-j_5K3Uue.js +120 -0
- package/dist/chunks/generate.runtime-j_5K3Uue.js.map +1 -0
- package/dist/chunks/{generate.runtime-DbSRJF-C.js → generate.runtime-mE0knt2T.js} +34 -38
- package/dist/chunks/{generate.runtime-DbSRJF-C.js.map → generate.runtime-mE0knt2T.js.map} +1 -1
- package/dist/chunks/{layout.svelte-Cb12mxua.js → layout.svelte-B6wOQ7SM.js} +10 -11
- package/dist/chunks/{layout.svelte-Cb12mxua.js.map → layout.svelte-B6wOQ7SM.js.map} +1 -1
- package/dist/chunks/{lib-specifier-Cngo1zF_.js → lib-specifier-C3M0WTev.js} +2 -3
- package/dist/chunks/{lib-specifier-Cngo1zF_.js.map → lib-specifier-C3M0WTev.js.map} +1 -1
- package/dist/chunks/{load-function-Dmkhg1pQ.js → load-function-BFvIVsh7.js} +3 -4
- package/dist/chunks/{load-function-Dmkhg1pQ.js.map → load-function-BFvIVsh7.js.map} +1 -1
- package/dist/chunks/{logger-CQONztPm.js → logger-t1HxmpG2.js} +2 -3
- package/dist/chunks/{logger-CQONztPm.js.map → logger-t1HxmpG2.js.map} +1 -1
- package/dist/chunks/{modify-file-DdXJCMHN.js → modify-file-CRZ_gMg0.js} +7 -10
- package/dist/chunks/{modify-file-DdXJCMHN.js.map → modify-file-CRZ_gMg0.js.map} +1 -1
- package/dist/chunks/{modify-nav-user-CJ1LevSU.js → modify-nav-user--7OwY9fI.js} +7 -16
- package/dist/chunks/{modify-nav-user-CJ1LevSU.js.map → modify-nav-user--7OwY9fI.js.map} +1 -1
- package/dist/chunks/{modify-nav-user-iUpv2lm-.js → modify-nav-user-D42kWyU6.js} +8 -14
- package/dist/chunks/{modify-nav-user-iUpv2lm-.js.map → modify-nav-user-D42kWyU6.js.map} +1 -1
- package/dist/chunks/modify-svelte-config-remote-wE5K2bU_.js +20 -0
- package/dist/chunks/{modify-svelte-config-remote-CEyYydL7.js.map → modify-svelte-config-remote-wE5K2bU_.js.map} +1 -1
- package/dist/chunks/{modify-user-signup-DLtopazD.js → modify-user-signup-ENhadGKH.js} +5 -6
- package/dist/chunks/{modify-user-signup-DLtopazD.js.map → modify-user-signup-ENhadGKH.js.map} +1 -1
- package/dist/chunks/{modify-utils-Cw-on_cL.js → modify-utils--zro3IGe.js} +3 -4
- package/dist/chunks/{modify-utils-Cw-on_cL.js.map → modify-utils--zro3IGe.js.map} +1 -1
- package/dist/chunks/{package-imports-B9Asv3ZH.js → package-imports-CcIIHbp5.js} +3 -4
- package/dist/chunks/{package-imports-B9Asv3ZH.js.map → package-imports-CcIIHbp5.js.map} +1 -1
- package/dist/chunks/{pocketbase-C5GS-Dh5.js → pocketbase-CvsJYXj-.js} +2 -3
- package/dist/chunks/{pocketbase-C5GS-Dh5.js.map → pocketbase-CvsJYXj-.js.map} +1 -1
- package/dist/chunks/{pocketbase-DpudAAmd.js → pocketbase-YG9yht8R.js} +2 -3
- package/dist/chunks/{pocketbase-DpudAAmd.js.map → pocketbase-YG9yht8R.js.map} +1 -1
- package/dist/chunks/{pocketbase-uOpghyT5.js → pocketbase-gUn2UrDd.js} +6 -14
- package/dist/chunks/{pocketbase-uOpghyT5.js.map → pocketbase-gUn2UrDd.js.map} +1 -1
- package/dist/chunks/{providers-ypCW70Mb.js → providers-BB3Z2TrN.js} +4 -5
- package/dist/chunks/{providers-ypCW70Mb.js.map → providers-BB3Z2TrN.js.map} +1 -1
- package/dist/chunks/{providers-CL9kQ4hp.js → providers-tjlFH5di.js} +4 -5
- package/dist/chunks/{providers-CL9kQ4hp.js.map → providers-tjlFH5di.js.map} +1 -1
- package/dist/chunks/{rolldown-runtime-5HNE8Q1r.js → rolldown-runtime-CwxnZyOB.js} +1 -2
- package/dist/chunks/{root-layout.svelte-CUVbnlX-.js → root-layout.svelte-DE0c_y-T.js} +12 -16
- package/dist/chunks/{root-layout.svelte-CUVbnlX-.js.map → root-layout.svelte-DE0c_y-T.js.map} +1 -1
- package/dist/chunks/{shared-DIDAkVts.js → shared-DE-J_b1j.js} +4 -5
- package/dist/chunks/{shared-DIDAkVts.js.map → shared-DE-J_b1j.js.map} +1 -1
- package/dist/chunks/{site-CVtsbO_S.js → site-B9hDxucR.js} +11 -12
- package/dist/chunks/{site-CVtsbO_S.js.map → site-B9hDxucR.js.map} +1 -1
- package/dist/chunks/{stripe-customer-B3tP8gtD.js → stripe-customer-5S-nOXP1.js} +2 -3
- package/dist/chunks/stripe-customer-5S-nOXP1.js.map +1 -0
- package/dist/chunks/{svelte-file-Dv5-bl79.js → svelte-file-DfplF3BU.js} +2 -3
- package/dist/chunks/{svelte-file-Dv5-bl79.js.map → svelte-file-DfplF3BU.js.map} +1 -1
- package/dist/chunks/table-core-BXmnfjln.js +120 -0
- package/dist/chunks/table-core-BXmnfjln.js.map +1 -0
- package/dist/chunks/{taggedTemplateLiteral-KSUnuvOk.js → taggedTemplateLiteral-CLenToGE.js} +1 -2
- package/dist/chunks/{test-setup-B37g3TRn.js → test-setup-CbwhAJT4.js} +8 -11
- package/dist/chunks/{test-setup-B37g3TRn.js.map → test-setup-CbwhAJT4.js.map} +1 -1
- package/dist/chunks/{ts-morph-helpers-CHI9wAil.js → ts-morph-helpers-B4KZXP44.js} +2 -3
- package/dist/chunks/{ts-morph-helpers-CHI9wAil.js.map → ts-morph-helpers-B4KZXP44.js.map} +1 -1
- package/dist/chunks/{ui-Ct_9B91R.js → ui-Ct6YQuPw.js} +53 -55
- package/dist/chunks/{ui-Ct_9B91R.js.map → ui-Ct6YQuPw.js.map} +1 -1
- package/dist/chunks/{ui-DD4NltyN.js → ui-D5xgIDR_.js} +3 -4
- package/dist/chunks/{ui-DD4NltyN.js.map → ui-D5xgIDR_.js.map} +1 -1
- package/dist/chunks/{unmodify-load-Buak-r1f.js → unmodify-load-CdWXJ_Ac.js} +3 -4
- package/dist/chunks/{unmodify-load-Buak-r1f.js.map → unmodify-load-CdWXJ_Ac.js.map} +1 -1
- package/dist/chunks/{util-BLYliuUK.js → util-ILWdjRAd.js} +2 -3
- package/dist/chunks/{util-BLYliuUK.js.map → util-ILWdjRAd.js.map} +1 -1
- package/dist/chunks/{whatsapp-Dr29ohbb.js → whatsapp-Bt4o4_q2.js} +3 -4
- package/dist/chunks/{whatsapp-Dr29ohbb.js.map → whatsapp-Bt4o4_q2.js.map} +1 -1
- package/dist/chunks/write-result-B5KFCqxw.js +487 -0
- package/dist/chunks/{write-result-mtVbmDyQ.js.map → write-result-B5KFCqxw.js.map} +1 -1
- package/dist/chunks/{wuchale-config-c3Q4JVSF.js → wuchale-config-CNXoq4rc.js} +2 -3
- package/dist/chunks/{wuchale-config-c3Q4JVSF.js.map → wuchale-config-CNXoq4rc.js.map} +1 -1
- package/dist/index.d.ts +57 -17
- package/dist/index.js +2272 -2350
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/dist/chunks/_page-B6yd6_Vl.js.map +0 -1
- package/dist/chunks/_page-DoPdZgZv.js.map +0 -1
- package/dist/chunks/constants-8cLxGOB0.js +0 -6
- package/dist/chunks/constants-8cLxGOB0.js.map +0 -1
- package/dist/chunks/generate-C3OaUggX.js.map +0 -1
- package/dist/chunks/generate-CtQcmjPM.js.map +0 -1
- package/dist/chunks/generate-D21dCU-o.js +0 -58
- package/dist/chunks/generate.runtime--yCjGZ6-.js +0 -124
- package/dist/chunks/generate.runtime--yCjGZ6-.js.map +0 -1
- package/dist/chunks/generate.runtime-BBfiR_Le.js +0 -67
- package/dist/chunks/generate.runtime-BL62aRng.js +0 -43
- package/dist/chunks/generate.runtime-BTHuPon9.js.map +0 -1
- package/dist/chunks/generate.runtime-Brakd35X.js.map +0 -1
- package/dist/chunks/generate.runtime-Bx_CaBZD.js.map +0 -1
- package/dist/chunks/generate.runtime-C8-mjcn8.js +0 -35
- package/dist/chunks/generate.runtime-CAO_SpsA.js +0 -50
- package/dist/chunks/generate.runtime-CCE-9xQV.js.map +0 -1
- package/dist/chunks/generate.runtime-CPDJolef.js +0 -65
- package/dist/chunks/generate.runtime-CaOO0281.js +0 -114
- package/dist/chunks/generate.runtime-CeoqgxiO.js.map +0 -1
- package/dist/chunks/generate.runtime-DUBOC6AA.js +0 -112
- package/dist/chunks/generate.runtime-DVwha8lZ.js +0 -48
- package/dist/chunks/generate.runtime-DbMDlglD.js +0 -64
- package/dist/chunks/generate.runtime-DlPeHx19.js.map +0 -1
- package/dist/chunks/generate.runtime-HkvT9gm6.js.map +0 -1
- package/dist/chunks/modify-svelte-config-remote-CEyYydL7.js +0 -42
- package/dist/chunks/stripe-customer-B3tP8gtD.js.map +0 -1
- package/dist/chunks/table-core-CUGp4Rf2.js +0 -127
- package/dist/chunks/table-core-CUGp4Rf2.js.map +0 -1
- package/dist/chunks/write-result-mtVbmDyQ.js +0 -499
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var e = {
|
|
2
|
+
node: "22.22.0",
|
|
3
|
+
packages: {
|
|
4
|
+
"@ai-sdk/anthropic": "^4.0.99",
|
|
5
|
+
"@ai-sdk/openai": "^4.0.111",
|
|
6
|
+
"@ai-sdk/svelte": "^5.0.165",
|
|
7
|
+
"@internationalized/date": "^3.12.4",
|
|
8
|
+
"@lucide/svelte": "^1.70.0",
|
|
9
|
+
"@sveltejs/adapter-node": "^6.0.2",
|
|
10
|
+
"@sveltejs/adapter-static": "^4.0.1",
|
|
11
|
+
"@sveltejs/kit": "^3.2.0",
|
|
12
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
13
|
+
"@tailwindcss/forms": "^0.5.11",
|
|
14
|
+
"@tailwindcss/typography": "^0.5.20",
|
|
15
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
16
|
+
"@takumi-rs/core": "^2.20.0",
|
|
17
|
+
"@tanstack/table-core": "^9.3.1",
|
|
18
|
+
"@types/node": "^26.6.6",
|
|
19
|
+
"@types/supertest": "^7.2.1",
|
|
20
|
+
"@velastack/cms": "^0.9.1",
|
|
21
|
+
"@velastack/kit": "^0.4.1",
|
|
22
|
+
"@velastack/pocketbase": "^0.4.3",
|
|
23
|
+
"@velastack/whatsapp": "^0.1.0",
|
|
24
|
+
"@wuchale/svelte": "^0.21.4",
|
|
25
|
+
ai: "^7.0.165",
|
|
26
|
+
"bits-ui": "^2.20.6",
|
|
27
|
+
clsx: "^2.1.1",
|
|
28
|
+
croner: "^10.0.1",
|
|
29
|
+
formsnap: "^2.1.0",
|
|
30
|
+
marked: "^18.1.3",
|
|
31
|
+
mdsvex: "^0.12.8",
|
|
32
|
+
"mode-watcher": "^1.1.0",
|
|
33
|
+
openworkflow: "^0.11.0",
|
|
34
|
+
"openworkflow-pocketbase": "^0.2.1",
|
|
35
|
+
"pocketbase-sveltekit": "^0.28.2",
|
|
36
|
+
prettier: "^3.9.10",
|
|
37
|
+
"prettier-plugin-svelte": "^4.1.1",
|
|
38
|
+
"shadcn-svelte": "^1.8.0",
|
|
39
|
+
supertest: "^7.3.2",
|
|
40
|
+
svelte: "^5.57.2",
|
|
41
|
+
"svelte-check": "^4.7.8",
|
|
42
|
+
"svelte-meta-tags": "^5.0.3",
|
|
43
|
+
"svelte-sonner": "^1.2.3",
|
|
44
|
+
"sveltekit-flash-message": "^3.0.0",
|
|
45
|
+
"sveltekit-negotiate": "^0.3.1",
|
|
46
|
+
"sveltekit-superforms": "^3.1.0",
|
|
47
|
+
"tailwind-merge": "^3.7.0",
|
|
48
|
+
"tailwind-variants": "^3.3.1",
|
|
49
|
+
tailwindcss: "^4.3.5",
|
|
50
|
+
"tw-animate-css": "^1.4.0",
|
|
51
|
+
typescript: "^6.0.3",
|
|
52
|
+
vite: "^8.3.6",
|
|
53
|
+
vitest: "^5.1.0",
|
|
54
|
+
wuchale: "^0.26.7",
|
|
55
|
+
zod: "^4.6.7"
|
|
56
|
+
},
|
|
57
|
+
tracks: { svelte: {
|
|
58
|
+
source: "sv-create",
|
|
59
|
+
reason: "The floor sv create's minimal template ships, so a vela project and a plain SvelteKit one start alike."
|
|
60
|
+
} },
|
|
61
|
+
holds: {
|
|
62
|
+
croner: {
|
|
63
|
+
reason: "11.0 is a major; the cron matching in the workflows runtime has not been checked against it.",
|
|
64
|
+
since: "2026-11-11"
|
|
65
|
+
},
|
|
66
|
+
"tailwind-variants": {
|
|
67
|
+
reason: "4.0 is a major; the shadcn-svelte components and the templates' own tv() calls have not been checked against it.",
|
|
68
|
+
since: "2026-11-11"
|
|
69
|
+
},
|
|
70
|
+
typescript: {
|
|
71
|
+
reason: "TypeScript 7 (the native port) is outside @sveltejs/kit's peer range (^6.0.0) and breaks the install. Blocked upstream: lift once Kit admits 7.",
|
|
72
|
+
since: "2026-11-11"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, t = e.packages, n = e.holds, r = e.tracks, i = e.node;
|
|
76
|
+
function a(e) {
|
|
77
|
+
let n = t[e];
|
|
78
|
+
if (n === void 0) throw Error(`${e} is not in src/core/versions.json; add it there before installing it.`);
|
|
79
|
+
return `${e}@${n}`;
|
|
80
|
+
}
|
|
81
|
+
// src/core/constants.ts
|
|
82
|
+
var o = "data", s = "migrations", c = "(public)", l = "(app)", u = a("@tanstack/table-core"), d = Number(/\d+/.exec(t["@tanstack/table-core"])[0]), f = a("formsnap"), p = t["sveltekit-superforms"], m = a("sveltekit-superforms"), h = a("sveltekit-flash-message"), g = a("@sveltejs/adapter-node"), _ = a("@sveltejs/adapter-static"), v = a("@velastack/kit"), y = a("@velastack/pocketbase"), b = a("@velastack/cms"), x = a("@velastack/whatsapp"), S = a("sveltekit-negotiate"), C = a("zod"), w = a("@takumi-rs/core"), T = a("wuchale"), E = a("@wuchale/svelte");
|
|
83
|
+
export { t as C, a as E, i as S, r as T, y as _, h as a, E as b, S as c, p as d, w as f, v as g, b as h, o as i, c as l, d as m, _ as n, f as o, u as p, l as r, s, g as t, m as u, x as v, n as w, C as x, T as y };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=constants-DpK-r_m5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-DpK-r_m5.js","names":["data","versions_default","\"ai\"","\"clsx\"","\"croner\"","\"formsnap\"","\"marked\"","\"mdsvex\"","\"openworkflow\"","\"prettier\"","\"supertest\"","\"svelte\"","\"tailwindcss\"","\"typescript\"","\"vite\"","\"vitest\"","\"wuchale\"","\"zod\"","\"source\"","\"reason\"","\"since\"","VERSIONS","VERSION_HOLDS","VERSION_TRACKS","NODE_FLOOR","spec","range","name","DATA_DIR","MIGRATIONS_DIR","PUBLIC_DIR","APP_DIR","TANSTACK_TABLE_CORE","TANSTACK_TABLE_CORE_MAJOR","FORMSNAP","SUPERFORMS_VERSION","SUPERFORMS","FLASH","ADAPTER_NODE","ADAPTER_STATIC","VELASTACK_KIT","VELASTACK_POCKETBASE","VELASTACK_CMS","VELASTACK_WHATSAPP","NEGOTIATE","ZOD","TAKUMI","WUCHALE","WUCHALE_SVELTE"],"sources":["../../src/core/versions.json","../../src/core/versions.ts","../../src/core/constants.ts"],"sourcesContent":["{\n \"node\": \"22.22.0\",\n \"packages\": {\n \"@ai-sdk/anthropic\": \"^4.0.99\",\n \"@ai-sdk/openai\": \"^4.0.111\",\n \"@ai-sdk/svelte\": \"^5.0.165\",\n \"@internationalized/date\": \"^3.12.4\",\n \"@lucide/svelte\": \"^1.70.0\",\n \"@sveltejs/adapter-node\": \"^6.0.2\",\n \"@sveltejs/adapter-static\": \"^4.0.1\",\n \"@sveltejs/kit\": \"^3.2.0\",\n \"@sveltejs/vite-plugin-svelte\": \"^7.3.1\",\n \"@tailwindcss/forms\": \"^0.5.11\",\n \"@tailwindcss/typography\": \"^0.5.20\",\n \"@tailwindcss/vite\": \"^4.3.5\",\n \"@takumi-rs/core\": \"^2.20.0\",\n \"@tanstack/table-core\": \"^9.3.1\",\n \"@types/node\": \"^26.6.6\",\n \"@types/supertest\": \"^7.2.1\",\n \"@velastack/cms\": \"^0.9.1\",\n \"@velastack/kit\": \"^0.4.1\",\n \"@velastack/pocketbase\": \"^0.4.3\",\n \"@velastack/whatsapp\": \"^0.1.0\",\n \"@wuchale/svelte\": \"^0.21.4\",\n \"ai\": \"^7.0.165\",\n \"bits-ui\": \"^2.20.6\",\n \"clsx\": \"^2.1.1\",\n \"croner\": \"^10.0.1\",\n \"formsnap\": \"^2.1.0\",\n \"marked\": \"^18.1.3\",\n \"mdsvex\": \"^0.12.8\",\n \"mode-watcher\": \"^1.1.0\",\n \"openworkflow\": \"^0.11.0\",\n \"openworkflow-pocketbase\": \"^0.2.1\",\n \"pocketbase-sveltekit\": \"^0.28.2\",\n \"prettier\": \"^3.9.10\",\n \"prettier-plugin-svelte\": \"^4.1.1\",\n \"shadcn-svelte\": \"^1.8.0\",\n \"supertest\": \"^7.3.2\",\n \"svelte\": \"^5.57.2\",\n \"svelte-check\": \"^4.7.8\",\n \"svelte-meta-tags\": \"^5.0.3\",\n \"svelte-sonner\": \"^1.2.3\",\n \"sveltekit-flash-message\": \"^3.0.0\",\n \"sveltekit-negotiate\": \"^0.3.1\",\n \"sveltekit-superforms\": \"^3.1.0\",\n \"tailwind-merge\": \"^3.7.0\",\n \"tailwind-variants\": \"^3.3.1\",\n \"tailwindcss\": \"^4.3.5\",\n \"tw-animate-css\": \"^1.4.0\",\n \"typescript\": \"^6.0.3\",\n \"vite\": \"^8.3.6\",\n \"vitest\": \"^5.1.0\",\n \"wuchale\": \"^0.26.7\",\n \"zod\": \"^4.6.7\"\n },\n \"tracks\": {\n \"svelte\": {\n \"source\": \"sv-create\",\n \"reason\": \"The floor sv create's minimal template ships, so a vela project and a plain SvelteKit one start alike.\"\n }\n },\n \"holds\": {\n \"croner\": {\n \"reason\": \"11.0 is a major; the cron matching in the workflows runtime has not been checked against it.\",\n \"since\": \"2026-11-11\"\n },\n \"tailwind-variants\": {\n \"reason\": \"4.0 is a major; the shadcn-svelte components and the templates' own tv() calls have not been checked against it.\",\n \"since\": \"2026-11-11\"\n },\n \"typescript\": {\n \"reason\": \"TypeScript 7 (the native port) is outside @sveltejs/kit's peer range (^6.0.0) and breaks the install. Blocked upstream: lift once Kit admits 7.\",\n \"since\": \"2026-11-11\"\n }\n }\n}\n","import data from \"./versions.json\";\n\n/**\n * The dependency ranges every vela project starts from, in one place:\n * `versions.json` beside this file.\n *\n * Three things read it. The patterns here install from it (`spec`). The vela\n * CLI's `minimal` and `static` templates, and the velastack-templates\n * baselines built on them, list the same ranges and each carry a test that\n * they still do. And `scripts/bump-versions.ts` keeps it current.\n *\n * So a version is changed here and nowhere else; the other copies follow it,\n * and their tests fail until they do.\n */\nexport const VERSIONS: Readonly<Record<string, string>> = data.packages;\n\n/** Packages kept below their latest release on purpose, and why. */\nexport const VERSION_HOLDS: Readonly<\n Record<string, { reason: string; since: string }>\n> = data.holds;\n\n/** Packages whose range follows another project's rather than npm's latest. */\nexport const VERSION_TRACKS: Readonly<\n Record<string, { source: string; reason: string }>\n> = data.tracks;\n\n/**\n * The oldest Node a vela project may run on: the floor of its `engines.node`.\n * Projects set `engine-strict`, so no listed package may require a later one.\n */\nexport const NODE_FLOOR: string = data.node;\n\n/** The install spec for a listed package: `spec(\"zod\")` is `zod@^4.6.7`. */\nexport function spec(name: string): string {\n const range = VERSIONS[name];\n if (range === undefined) {\n throw new Error(\n `${name} is not in src/core/versions.json; add it there before installing it.`,\n );\n }\n return `${name}@${range}`;\n}\n","import { VERSIONS, spec } from \"./versions\";\n\nexport const DATA_DIR = \"data\";\nexport const MIGRATIONS_DIR = \"migrations\";\nexport const FIXTURE_PREFIX = \"vela\";\nexport const PUBLIC_DIR = \"(public)\";\nexport const APP_DIR = \"(app)\";\nexport const AUTHED_REDIRECT_PATH = \"/dashboard\";\nexport const API_URL = \"http://localhost:5173\";\n\n/**\n * The table helpers this repo ships (`data-table`, `column-header`,\n * `faceted-filter`, `pagination`) and the pages the scaffold generators emit\n * target TanStack Table v9, whose API and types are incompatible with v8; see\n * `assertTableCoreV9` for projects that still have the v8 helpers.\n */\nexport const TANSTACK_TABLE_CORE = spec(\"@tanstack/table-core\");\n\n/** The major `TANSTACK_TABLE_CORE` pins. */\nexport const TANSTACK_TABLE_CORE_MAJOR = Number(\n /\\d+/.exec(VERSIONS[\"@tanstack/table-core\"]!)![0],\n);\n\n/**\n * `file-form` and `multiselect` build on formsnap's field context. 2.1.0 is\n * the first release whose superforms peer admits 3.x; 2.0 needed an npm\n * override, which `writeResult` now removes (`reconcileFormsnap`).\n */\nexport const FORMSNAP = spec(\"formsnap\");\n\n/**\n * The superforms range a project starts on: 3.x, the line that supports\n * SvelteKit 3. A caret like any other dependency, now that formsnap 2.1 peers\n * `^3.0.0`; it was an exact version while 3.0 was a `next` prerelease, because\n * a caret on a prerelease follows every later `next` build. `writeResult`,\n * `vela migrate` and `vela bless` still move a project off one of those\n * prerelease pins (`reconcileFormsnap`).\n *\n * The name is from the exact-pin days and is kept for the CLI, which imports\n * it; the value is a range.\n */\nexport const SUPERFORMS_VERSION = VERSIONS[\"sveltekit-superforms\"]!;\n\n/**\n * What a generated superforms page needs. Vela's templates already carry\n * both; a project vela did not create may have neither.\n */\nexport const SUPERFORMS = spec(\"sveltekit-superforms\");\n\n/** The flash-message line that supports SvelteKit 3. */\nexport const FLASH = spec(\"sveltekit-flash-message\");\n\n/** The adapter `vela enable backend` moves a project to. */\nexport const ADAPTER_NODE = spec(\"@sveltejs/adapter-node\");\n\n/** The adapter a static project builds with (`vela disable backend`). */\nexport const ADAPTER_STATIC = spec(\"@sveltejs/adapter-static\");\n\n/** The VelaStack libraries' SvelteKit 3 releases. */\nexport const VELASTACK_KIT = spec(\"@velastack/kit\");\n/** 0.4.2 or later: it proxies plugin webhooks (pocketbase-whatsapp) to PocketBase. */\nexport const VELASTACK_POCKETBASE = spec(\"@velastack/pocketbase\");\nexport const VELASTACK_CMS = spec(\"@velastack/cms\");\n/** wa.me links, order messages and hosted order recording, for payments on WhatsApp. */\nexport const VELASTACK_WHATSAPP = spec(\"@velastack/whatsapp\");\nexport const NEGOTIATE = spec(\"sveltekit-negotiate\");\nexport const ZOD = spec(\"zod\");\n/** Renders HTML and CSS to an image; a native module, so it must be a dependency. */\nexport const TAKUMI = spec(\"@takumi-rs/core\");\n\n/** What `vela enable i18n` installs: wuchale and its Svelte adapter. */\nexport const WUCHALE = spec(\"wuchale\");\nexport const WUCHALE_SVELTE = spec(\"@wuchale/svelte\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A,GCcaqB,IAA6CrB,EAAK,UAGlDsB,IAETtB,EAAK,OAGIuB,IAETvB,EAAK,QAMIwB,IAAqBxB,EAAK;AAGvC,SAAgByB,EAAK,GAAsB;CACzC,IAAMC,IAAQL,EAASM;CACvB,IAAID,MAAU,KAAA,GACZ,MAAU,MACR,GAAGC,EAAK,sEACV;CAEF,OAAO,GAAGA,EAAK,GAAGD;AACpB;;ACvCA,IAAaE,IAAW,QACXC,IAAiB,cAEjBC,IAAa,YACbC,IAAU,SAUVC,IAAsBP,EAAK,sBAAsB,GAGjDQ,IAA4B,OACvC,MAAM,KAAKZ,EAAS,uBAAwB,CAAC,CAAE,EACjD,GAOaa,IAAWT,EAAK,UAAU,GAa1BU,IAAqBd,EAAS,yBAM9Be,IAAaX,EAAK,sBAAsB,GAGxCY,IAAQZ,EAAK,yBAAyB,GAGtCa,IAAeb,EAAK,wBAAwB,GAG5Cc,IAAiBd,EAAK,0BAA0B,GAGhDe,IAAgBf,EAAK,gBAAgB,GAErCgB,IAAuBhB,EAAK,uBAAuB,GACnDiB,IAAgBjB,EAAK,gBAAgB,GAErCkB,IAAqBlB,EAAK,qBAAqB,GAC/CmB,IAAYnB,EAAK,qBAAqB,GACtCoB,IAAMpB,EAAK,KAAK,GAEhBqB,IAASrB,EAAK,iBAAiB,GAG/BsB,IAAUtB,EAAK,SAAS,GACxBuB,IAAiBvB,EAAK,iBAAiB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as e } from "./errors-
|
|
2
|
-
import {
|
|
3
|
-
import { r as n } from "./util-
|
|
4
|
-
import { c as r, i, r as a } from "./providers-
|
|
5
|
-
import { t as o } from "./stripe-customer-
|
|
6
|
-
import { n as s, t as c } from "./_page-
|
|
7
|
-
|
|
1
|
+
import { t as e } from "./errors-DdSUZI8f.js";
|
|
2
|
+
import { v as t } from "./constants-DpK-r_m5.js";
|
|
3
|
+
import { r as n } from "./util-ILWdjRAd.js";
|
|
4
|
+
import { c as r, i, r as a } from "./providers-tjlFH5di.js";
|
|
5
|
+
import { t as o } from "./stripe-customer-5S-nOXP1.js";
|
|
6
|
+
import { n as s, t as c } from "./_page-Bt37d4uo.js";
|
|
7
|
+
// src/patterns/enable/payments/creates/src/lib/components/currency-select.svelte?raw
|
|
8
8
|
var l = "<script lang=\"ts\">\n import { onMount } from 'svelte';\n import * as Select from '#lib/components/ui/select/index.js';\n import { currency, offered, pageLocale } from '#lib/currency.svelte.js';\n\n // Nothing to pick from until the business offers a second currency.\n let { class: className }: { class?: string } = $props();\n\n onMount(() => currency.load());\n\n function label(code: string): string {\n const names = new Intl.DisplayNames(pageLocale(), { type: 'currency' });\n return `${code} · ${names.of(code) ?? code}`;\n }\n<\/script>\n\n{#if offered.length > 1}\n <Select.Root type=\"single\" value={currency.current} onValueChange={(code) => currency.set(code)}>\n <Select.Trigger class={className} aria-label=\"Currency\">{currency.current}</Select.Trigger>\n <Select.Content>\n {#each offered as code (code)}\n <Select.Item value={code}>{label(code)}</Select.Item>\n {/each}\n </Select.Content>\n </Select.Root>\n{/if}\n", u = "import { browser } from '$app/env';\nimport { invalidateAll } from '$app/navigation';\nimport { site } from '#lib/site.js';\n\n/**\n * Prices and the currency they show in.\n *\n * Every price on the site is in the business's currency, `site.currency`.\n * When `site.currencies` offers more, a visitor can pick one of them and\n * sees each price converted at the day's rate, marked `≈`: an estimate, not\n * what they are charged. The choice is kept in a cookie for a year.\n *\n * Rates come from velastack.dev, which publishes central bank reference\n * rates once for every site (see https://velastack.dev/v1/rates). They are\n * fetched in the browser once a day and kept in localStorage.\n */\n\nconst RATES_URL = 'https://velastack.dev/v1/rates';\nconst COOKIE = 'currency';\nconst RATES_KEY = 'rates';\nconst DAY = 24 * 60 * 60 * 1000;\n\ninterface Rates {\n base: string;\n date: string;\n rates: Record<string, number>;\n fetchedAt: number;\n}\n\n/** The day's rates as velastack.dev sends them, before the store stamps when it got them. */\nexport type RatesPayload = Pick<Rates, 'base' | 'date' | 'rates'>;\n\n// `site.ts` declares these once payments asked for them; a project that\n// enabled payments before that has none, and formats in each price's own\n// currency with nothing to convert to.\nconst business = site as unknown as { currency?: string; country?: string; currencies?: string[] };\nconst home = business.currency ?? '';\n\n/** The currencies the business shows prices in: its own, then the others it offers. */\nexport const offered: string[] = home\n ? [home, ...(business.currencies ?? []).filter((code) => code !== home)]\n : [];\n\n/**\n * The page's language in the business's country (`es-MX`, not `es`), so a\n * price reads the way the business's customers read it: an English page on\n * a Mexican site shows MXN as `MX$5.50`, a Spanish one as `$5.50`. A bare\n * language would print `360,00 MXN`. On the server the language is the\n * site's default; the server and the browser then agree on the first render.\n */\nexport function pageLocale(): string {\n // app.html ships `lang=\"en\"`; with i18n the server hook fills the page's own.\n const language = (browser && document.documentElement.lang) || 'en';\n if (!business.country || language.includes('-')) return language;\n return `${language}-${business.country}`;\n}\n\nclass Currency {\n /** The currency prices show in: the business's own until the visitor picks another. */\n current = $state(home);\n rates = $state<Rates | null>(null);\n\n #loaded = false;\n\n /**\n * Starts from what the server resolved (`handleCurrency`, through the root\n * layout's data), so the first render shows the visitor's currency on the\n * server and in the browser alike. Called from the root layout, before any\n * child renders; a static site has no server to call it. On the server this\n * sets module state per request, which is sound because Svelte renders a\n * request synchronously: nothing else runs between this call and the end\n * of the page.\n */\n hydrate(current: string, rates: RatesPayload | null) {\n if (offered.includes(current)) this.current = current;\n if (rates) this.rates = { ...rates, fetchedAt: Date.now() };\n }\n\n /** Reads the cookie and the day's rates, once, in the browser. */\n load() {\n if (!browser || this.#loaded || offered.length < 2) return;\n this.#loaded = true;\n const saved = document.cookie.match(/(?:^|;\\s*)currency=([A-Z]{3})/)?.[1];\n if (saved && offered.includes(saved)) this.current = saved;\n this.#loadRates();\n }\n\n /** Shows prices in `code`, one of `offered`, and remembers it. */\n set(code: string) {\n if (!offered.includes(code)) return;\n this.current = code;\n document.cookie = `${COOKIE}=${code}; path=/; max-age=${365 * 24 * 60 * 60}; samesite=lax`;\n if (code !== home) this.#loadRates();\n // A load that prices by the currency (a Shopify market) runs again.\n void invalidateAll();\n }\n\n /** `amount` in `from` as the current currency, or `null` without a rate for either. */\n convert(amount: number, from = home): number | null {\n if (from === this.current || !this.current) return amount;\n const rates = this.rates?.rates;\n const fromRate = rates?.[from];\n const toRate = rates?.[this.current];\n if (!fromRate || !toRate) return null;\n return (amount / fromRate) * toRate;\n }\n\n /**\n * `amount` in `from`, as the visitor should read it: in the current\n * currency with `≈` when it was converted, else as it is. Formatted for\n * the page's language in the business's country.\n */\n format(amount: number, from = home): string {\n const converted = this.convert(amount, from);\n if (converted === null || from === this.current || !this.current) return money(amount, from);\n return `≈ ${money(converted, this.current)}`;\n }\n\n async #loadRates() {\n if (this.rates && Date.now() - this.rates.fetchedAt < DAY) return;\n try {\n const cached = JSON.parse(localStorage.getItem(RATES_KEY) ?? 'null') as Rates | null;\n if (cached && Date.now() - cached.fetchedAt < DAY) {\n this.rates = cached;\n return;\n }\n } catch {\n // Unreadable storage: fetch instead.\n }\n try {\n const response = await fetch(RATES_URL);\n if (!response.ok) return;\n const body = (await response.json()) as RatesPayload;\n const rates: Rates = { base: body.base, date: body.date, rates: body.rates, fetchedAt: Date.now() };\n this.rates = rates;\n localStorage.setItem(RATES_KEY, JSON.stringify(rates));\n } catch {\n // No rates: prices stay in the business's currency.\n }\n }\n}\n\nexport const currency = new Currency();\n\n/** `amount` in `code`, formatted for the page's language in the business's country. */\nexport function money(amount: number, code: string): string {\n return new Intl.NumberFormat(pageLocale(), { style: 'currency', currency: code }).format(amount);\n}\n\n/**\n * The currency a `load` should price by: what the server resolved into the\n * root layout's data (`currency`, with a server), else what the store holds.\n */\nexport function currencyFrom(data: object): string {\n const resolved = 'currency' in data ? data.currency : undefined;\n return typeof resolved === 'string' && offered.includes(resolved) ? resolved : currency.current;\n}\n\n/** A price in the business's currency, shown the way the visitor reads prices. */\nexport function formatPrice(amount: number, from = home): string {\n return currency.format(amount, from);\n}\n", d = "<script lang=\"ts\">\n import { toast } from 'svelte-sonner';\n import { Button } from '#lib/components/ui/button/index.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n import { marketCountry, storefront } from '#lib/shopify.js';\n import { currency } from '#lib/currency.svelte.js';\n\n interface Props {\n /** The product variant to buy: `gid://shopify/ProductVariant/...`. */\n variantId: string;\n quantity?: number;\n label?: string;\n processingLabel?: string;\n }\n\n let {\n variantId,\n quantity = 1,\n label = 'Buy now',\n processingLabel = 'Redirecting...',\n disabled,\n ...rest\n }: Props & ButtonProps = $props();\n\n const CART_CREATE = `#graphql\n mutation BuyNow($lines: [CartLineInput!]!, $country: CountryCode) @inContext(country: $country) {\n cartCreate(input: { lines: $lines, buyerIdentity: { countryCode: $country } }) {\n cart {\n checkoutUrl\n }\n userErrors {\n message\n }\n }\n }\n `;\n\n let isProcessing = $state(false);\n\n // A one-line cart in the visitor's market, then Shopify's checkout for it.\n async function buy() {\n isProcessing = true;\n try {\n const country = await marketCountry(currency.current);\n const { data, errors } = await storefront().request(CART_CREATE, {\n variables: { lines: [{ merchandiseId: variantId, quantity }], country }\n });\n const checkoutUrl = data?.cartCreate?.cart?.checkoutUrl;\n if (errors || !checkoutUrl) {\n throw new Error(\n data?.cartCreate?.userErrors?.[0]?.message ?? errors?.message ?? 'No checkout URL'\n );\n }\n window.location.assign(checkoutUrl);\n } catch (error) {\n console.error('Shopify checkout failed:', error);\n toast.error('Could not start checkout');\n isProcessing = false;\n }\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={buy} {...rest}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n", f = "import { PUBLIC_SHOPIFY_STORE_DOMAIN, PUBLIC_SHOPIFY_STOREFRONT_TOKEN } from '$app/env/public';\nimport {\n createStorefrontApiClient,\n type StorefrontApiClient\n} from '@shopify/storefront-api-client';\n\n/** Shopify supports each Storefront API version for a year; move this forward when it nears its end. */\nexport const SHOPIFY_API_VERSION = '2026-10';\n\nlet client: StorefrontApiClient | undefined;\n\n/**\n * The Storefront API client. Built on first use, not on import: it refuses to\n * be created without a token, and a build or prerender with an empty `.env`\n * should still pass, failing only the requests that need Shopify.\n */\nexport function storefront(): StorefrontApiClient {\n if (!client) {\n if (!PUBLIC_SHOPIFY_STORE_DOMAIN || !PUBLIC_SHOPIFY_STOREFRONT_TOKEN) {\n throw new Error(\n 'PUBLIC_SHOPIFY_STORE_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN are not set, so Shopify cannot be called.'\n );\n }\n client = createStorefrontApiClient({\n storeDomain: PUBLIC_SHOPIFY_STORE_DOMAIN,\n apiVersion: SHOPIFY_API_VERSION,\n publicAccessToken: PUBLIC_SHOPIFY_STOREFRONT_TOKEN\n });\n }\n return client;\n}\n\nconst LOCALIZATION = `#graphql\n query Localization {\n localization {\n availableCountries {\n isoCode\n currency {\n isoCode\n }\n }\n }\n }\n`;\n\nlet markets: Promise<Record<string, string>> | undefined;\n\n/**\n * The country whose market prices in `currency`, when the store sells in one\n * (Shopify Markets): a query run `@inContext` of it comes back priced by\n * Shopify in that currency, and a cart created in it checks out in it.\n * `null` when no market does; the store's markets are learned once.\n */\nexport async function marketCountry(currency: string): Promise<string | null> {\n markets ??= storefront()\n .request(LOCALIZATION)\n .then(({ data }) => {\n const byCurrency: Record<string, string> = {};\n const countries = (data?.localization?.availableCountries ?? []) as {\n isoCode: string;\n currency: { isoCode: string };\n }[];\n for (const country of countries) byCurrency[country.currency.isoCode] ??= country.isoCode;\n return byCurrency;\n })\n .catch((error) => {\n console.error('Could not read the Shopify markets:', error);\n markets = undefined;\n return {};\n });\n return (await markets)[currency] ?? null;\n}\n", p = "<script lang=\"ts\">\n import type { Stripe } from '@stripe/stripe-js';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n brand?: string;\n last4?: string;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n brand,\n last4,\n clientSecret,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n const brandNames = {\n amex: 'American Express',\n cartes_bancaires: 'Cartes Bancaires',\n diners: 'Diners',\n discover: 'Discover',\n eftpos_au: 'Eftpos Au',\n jcb: 'Jcb',\n link: 'Link',\n mastercard: 'Mastercard',\n unionpay: 'Unionpay',\n visa: 'Visa',\n unknown: 'Unknown'\n };\n\n let isProcessing = $state(false);\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !clientSecret) return;\n\n isProcessing = true;\n\n try {\n const { error: confirmError } = await stripe.confirmPayment({\n clientSecret,\n confirmParams: {\n return_url: page.url.toString()\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <!-- Stripe's card form is tall: scroll within the screen so the buttons stay reachable -->\n <Dialog.Content class=\"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Confirm payment</Dialog.Title>\n <Dialog.Description>\n Are you sure you want to pay {amountFormatted} with your\n {brandNames[brand as keyof typeof brandNames]}\n credit card ending in **** {last4}?\n </Dialog.Description>\n </Dialog.Header>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", m = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import PaymentDialog from '#lib/components/payments/payment-dialog.svelte';\n import ConfirmDialog from '#lib/components/payments/confirm-dialog.svelte';\n import { useStripe } from '#lib/components/payments/use-stripe.svelte.js';\n import { usePaymentIntent } from '#lib/components/payments/use-payment-intent.svelte.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n\n interface Props {\n priceId: string;\n user?: { email?: string; name?: string } | null;\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n priceId,\n user,\n disabled = false,\n isProcessing = false,\n label = 'Purchase',\n processingLabel = 'Processing...',\n onsuccess,\n ...rest\n }: Props & ButtonProps = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let mode = $state<'payment' | 'confirm'>('payment');\n let showDialog = $state(false);\n let amount = $state<number>(0);\n let currency = $state<string>('usd');\n let clientSecret = $state<string>();\n let brand = $state<string>();\n let last4 = $state<string>();\n let setupFutureUsage = $state<'off_session' | null>(null);\n\n async function handleBuyClick() {\n const result = await paymentIntentManager.fetchPaymentIntent({\n priceId\n });\n\n if (!result) return;\n\n if (result.type === 'confirm') {\n mode = 'confirm';\n brand = result.brand;\n last4 = result.last4;\n } else if (result.type === 'payment') {\n mode = 'payment';\n }\n\n amount = result.amount || 0;\n currency = result.currency || 'usd';\n clientSecret = result.clientSecret;\n setupFutureUsage = result.setupFutureUsage ?? null;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleBuyClick} {...rest}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n{#if mode === 'confirm'}\n <ConfirmDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {brand}\n {last4}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{:else if mode === 'payment'}\n <PaymentDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {clientSecret}\n {setupFutureUsage}\n {user}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{/if}\n", h = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n import { Label } from '#lib/components/ui/label/index.js';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n clientSecret?: string;\n /** From the intent: `off_session` when the card is kept for the customer. */\n setupFutureUsage?: 'off_session' | null;\n user?: { email?: string; name?: string } | null;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n clientSecret,\n setupFutureUsage = null,\n user = null,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let savePaymentMethod = $state(false);\n let email = $state<string>();\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to pay for your purchase');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmPayment({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n billing_details: {\n // Stripe rejects an empty string.\n email: email || user?.email || undefined\n },\n allow_redisplay: savePaymentMethod ? 'always' : 'unspecified'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <!-- Stripe's card form is tall: scroll within the screen so the buttons stay reachable -->\n <Dialog.Content class=\"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>{amountFormatted}</Dialog.Title>\n <Dialog.Description>Enter your card details to pay for your purchase.</Dialog.Description>\n </Dialog.Header>\n <!-- For the receipt: guests, and accounts made with a phone number -->\n {#if !user?.email}\n <div class=\"space-y-2\">\n <Label for=\"email\">Email</Label>\n <Input type=\"email\" bind:value={email} />\n </div>\n {/if}\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"payment\"\n {stripe}\n {amount}\n {currency}\n {savePaymentMethod}\n {setupFutureUsage}\n {user}\n onchange={handleCardChange}\n />\n {/if}\n </div>\n <!-- Only a signed-in customer's card is kept, and so can be shown again -->\n {#if setupFutureUsage}\n <div class=\"flex items-center gap-2\">\n <input type=\"checkbox\" id=\"savePaymentMethod\" bind:checked={savePaymentMethod} />\n <label for=\"savePaymentMethod\" class=\"text-sm text-muted-foreground\">\n Save payment method for future purchases\n </label>\n </div>\n {/if}\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", g = "export const TERMS_AUTO = {\n applePay: \"auto\" as const,\n auBecsDebit: \"auto\" as const,\n bancontact: \"auto\" as const,\n card: \"auto\" as const,\n cashapp: \"auto\" as const,\n googlePay: \"auto\" as const,\n ideal: \"auto\" as const,\n paypal: \"auto\" as const,\n sepaDebit: \"auto\" as const,\n sofort: \"auto\" as const,\n usBankAccount: \"auto\" as const,\n};\n\nexport const TERMS_NEVER = {\n applePay: \"never\" as const,\n auBecsDebit: \"never\" as const,\n bancontact: \"never\" as const,\n card: \"never\" as const,\n cashapp: \"never\" as const,\n googlePay: \"never\" as const,\n ideal: \"never\" as const,\n paypal: \"never\" as const,\n sepaDebit: \"never\" as const,\n sofort: \"never\" as const,\n usBankAccount: \"never\" as const,\n};\n", _ = "<script lang=\"ts\">\n import type {\n Stripe,\n StripeElements,\n StripePaymentElement,\n StripeElementsOptionsMode\n } from '@stripe/stripe-js';\n import { mode as modeWatcher } from 'mode-watcher';\n import { TERMS_AUTO, TERMS_NEVER } from './stripe-constants';\n import { onMount } from 'svelte';\n\n interface Props {\n stripe: Stripe;\n mode: 'payment' | 'setup';\n amount?: number;\n currency?: string;\n savePaymentMethod?: boolean;\n /**\n * The intent's `setup_future_usage`, which Elements must match. A setup\n * (adding a card) always keeps the card.\n */\n setupFutureUsage?: 'off_session' | null;\n user?: { email?: string; name?: string } | null;\n onchange: (complete: boolean) => void;\n }\n\n let {\n stripe,\n mode,\n amount = 0,\n currency = 'usd',\n savePaymentMethod = false,\n setupFutureUsage = null,\n user,\n onchange\n }: Props = $props();\n\n let cardContainer = $state<HTMLDivElement | null>(null);\n let elements = $state<StripeElements | null>(null);\n let paymentElement = $state<StripePaymentElement | null>(null);\n\n function initializeElements() {\n if (!stripe) return;\n\n // Clean up previous elements\n if (paymentElement) {\n paymentElement.destroy();\n paymentElement = null;\n }\n\n const appearance = {\n theme: modeWatcher.current === 'dark' ? ('night' as const) : ('stripe' as const),\n inputs: 'condensed' as const,\n labels: 'floating' as const\n };\n\n elements = stripe.elements({\n mode,\n appearance,\n currency,\n ...(mode === 'payment' && {\n amount: amount\n }),\n ...(mode === 'setup' || setupFutureUsage\n ? {\n setupFutureUsage: 'off_session' as const\n }\n : {})\n } as StripeElementsOptionsMode);\n\n paymentElement = elements.create('payment', {\n layout: 'tabs',\n defaultValues: {\n billingDetails: {\n email: user?.email || undefined,\n name: user?.name || undefined\n }\n },\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n\n if (cardContainer && paymentElement) {\n paymentElement.mount(cardContainer);\n paymentElement.on('change', (event: any) => {\n onchange(event.complete);\n });\n }\n }\n\n // Initialize elements when component mounts\n onMount(() => {\n initializeElements();\n\n return () => {\n if (paymentElement) {\n paymentElement.destroy();\n }\n };\n });\n\n // Update terms when savePaymentMethod changes\n $effect(() => {\n if (paymentElement) {\n paymentElement.update({\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n }\n });\n\n export function getElements() {\n return elements;\n }\n<\/script>\n\n<div bind:this={cardContainer}></div>\n", v = "import { toast } from \"svelte-sonner\";\n\nexport interface PaymentIntentResult {\n type: \"payment\" | \"confirm\";\n amount?: number;\n currency?: string;\n clientSecret?: string;\n brand?: string;\n last4?: string;\n /**\n * What the intent was created with: `off_session` when the card is kept\n * for the signed-in customer. The card form has to match it.\n */\n setupFutureUsage?: \"off_session\" | null;\n}\n\nexport function usePaymentIntent() {\n let isLoading = $state(false);\n\n async function fetchPaymentIntent({\n priceId,\n }: {\n priceId: string;\n }): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/payment-intent\", {\n method: \"POST\",\n body: JSON.stringify({\n priceId: priceId,\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize payment\");\n return null;\n }\n\n return res.json();\n }\n\n async function fetchSetupIntent(): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/setup-intent\", {\n method: \"POST\",\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize setup\");\n return null;\n }\n\n return res.json();\n }\n\n return {\n get isLoading() {\n return isLoading;\n },\n fetchPaymentIntent,\n fetchSetupIntent,\n };\n}\n", y = "import { loadStripe, type Stripe } from \"@stripe/stripe-js\";\nimport { toast } from \"svelte-sonner\";\nimport { PUBLIC_STRIPE_PUBLISHABLE_KEY } from \"$app/env/public\";\n\nexport function useStripe() {\n let stripe = $state<Stripe | null>(null);\n let isLoading = $state(true);\n let error = $state<string | null>(null);\n\n async function initialize() {\n try {\n stripe = await loadStripe(PUBLIC_STRIPE_PUBLISHABLE_KEY);\n isLoading = false;\n } catch (err) {\n console.error(\"Failed to load Stripe:\", err);\n error = \"Failed to initialize payment system\";\n toast.error(\"Failed to initialize payment system\");\n isLoading = false;\n }\n }\n\n // Auto-initialize\n initialize();\n\n return {\n get stripe() {\n return stripe;\n },\n get isLoading() {\n return isLoading;\n },\n get error() {\n return error;\n },\n };\n}\n", b = "import { STRIPE_SECRET_KEY } from \"$app/env/private\";\nimport Stripe from \"stripe\";\n\nlet client: Stripe | undefined;\n\nfunction getClient(): Stripe {\n if (!client) {\n if (!STRIPE_SECRET_KEY) {\n throw new Error(\n \"STRIPE_SECRET_KEY is not set, so Stripe cannot be called.\",\n );\n }\n // No apiVersion: the SDK pins the version it was built for, and naming one\n // here fell behind it in every fresh project.\n client = new Stripe(STRIPE_SECRET_KEY);\n }\n return client;\n}\n\n// Built on first use, not on import. The workflow worker imports every workflow\n// at startup, and some import this module, so a client built at module scope\n// takes the whole server down wherever the key is unset - a pull request\n// preview, say - instead of failing only the requests that need Stripe.\nconst stripe = new Proxy({} as Stripe, {\n get(_target, property) {\n const value = Reflect.get(getClient(), property);\n return typeof value === \"function\" ? value.bind(getClient()) : value;\n },\n});\n\nexport default stripe;\n", x = "import type Stripe from 'stripe';\nimport { getAdmin, ow } from '#lib/server/workflows.js';\nimport { dispatchStripeEvent } from '../../routes/webhooks/stripe/handlers/dispatch';\n\n/**\n * One run per Stripe event, keyed on the event id by the webhook route, so\n * Stripe's retries and a replay from its dashboard land on the run that\n * already exists. A handler that throws is retried with backoff; the run and\n * its error are listed under Workflows in the PocketBase dashboard.\n */\nexport const handleStripeEvent = ow.defineWorkflow<Stripe.Event, void>(\n { name: 'stripe-event', retryPolicy: { maximumAttempts: 5 } },\n async ({ input: event, step }) => {\n await step.run({ name: event.type }, async () => {\n const admin = await getAdmin();\n await dispatchStripeEvent(event, { admin } as App.Locals);\n });\n }\n);\n", S = "import stripe from '#lib/stripe.js';\nimport { getAdmin, ow } from '#lib/server/workflows.js';\n\n/** Copies every Stripe product into stripe_products, adding new ones and updating the rest. */\nexport const syncStripeProducts = ow.defineWorkflow(\n { name: 'sync-stripe-products', retryPolicy: { maximumAttempts: 3 } },\n async ({ step }) => {\n const products = await step.run({ name: 'list' }, async () => {\n const rows = [];\n for await (const product of stripe.products.list({ limit: 100 })) {\n rows.push({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price:\n typeof product.default_price === 'string'\n ? product.default_price\n : (product.default_price?.id ?? null),\n description: product.description,\n images: product.images,\n metadata: product.metadata,\n url: product.url\n });\n }\n return rows;\n });\n\n await step.run({ name: 'upsert' }, async () => {\n const admin = await getAdmin();\n for (const product of products) {\n try {\n await admin.collection('stripe_products').update(product.id, product);\n } catch {\n await admin.collection('stripe_products').create(product);\n }\n }\n });\n\n return { synced: products.length };\n }\n);\n\n/** The same for prices. */\nexport const syncStripePrices = ow.defineWorkflow(\n { name: 'sync-stripe-prices', retryPolicy: { maximumAttempts: 3 } },\n async ({ step }) => {\n const prices = await step.run({ name: 'list' }, async () => {\n const rows = [];\n // `currency_options` (fixed amounts in other currencies, set in the\n // dashboard) comes only when asked for.\n for await (const price of stripe.prices.list({\n limit: 100,\n expand: ['data.currency_options']\n })) {\n rows.push({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: typeof price.product === 'string' ? price.product : price.product.id,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n nickname: price.nickname,\n lookup_key: price.lookup_key,\n currency_options: price.currency_options ?? null\n });\n }\n return rows;\n });\n\n await step.run({ name: 'upsert' }, async () => {\n const admin = await getAdmin();\n for (const price of prices) {\n try {\n await admin.collection('stripe_prices').update(price.id, price);\n } catch {\n await admin.collection('stripe_prices').create(price);\n }\n }\n });\n\n return { synced: prices.length };\n }\n);\n\n/** Both run on this schedule; a product or price changed in Stripe shows up within ten minutes. */\nexport const cron = '*/10 * * * *';\n", C = "import stripe from \"#lib/stripe.js\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (price: Stripe.Price) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n // A guest's card is not kept, so the card form must not ask to keep it.\n setupFutureUsage: null,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return Response.json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return Response.json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return Response.json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return Response.json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n try {\n const res = await createPaymentIntent(price);\n return Response.json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return Response.json({ error: errorMessage }, { status: 500 });\n }\n};\n", w = "import { describe, it, expect, beforeAll } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"#lib/stripe.js\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n expect(response.body.setupFutureUsage).toBeNull();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", T = "import Stripe from 'stripe';\nimport { STRIPE_WEBHOOK_SECRET } from '$app/env/private';\nimport stripe from '#lib/stripe.js';\nimport { handleStripeEvent } from '#lib/workflows/stripe-event.js';\n\nasync function verifyWebhookSignature(request: Request, webhookSecret: string): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get('stripe-signature');\n\n if (!signature) {\n throw new Error('Missing stripe-signature header');\n }\n\n if (!webhookSecret) {\n throw new Error('Missing webhook secret');\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error('Webhook signature verification failed:', err);\n throw new Error('Invalid signature');\n }\n}\n\nexport const POST = async ({ request }) => {\n try {\n const event = await verifyWebhookSignature(request, STRIPE_WEBHOOK_SECRET);\n\n // Queued, not handled here: the workflow runs the handler with retries,\n // and its idempotency key means a redelivery of the same event returns\n // the existing run instead of handling it twice.\n const handle = await handleStripeEvent.run(event, { idempotencyKey: event.id });\n console.log(`Queued webhook event ${event.type} (${event.id}) as run ${handle.workflowRun.id}`);\n\n return Response.json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n runId: handle.workflowRun.id\n });\n } catch (error) {\n console.error('Webhook processing error:', error);\n\n return Response.json(\n {\n error: 'Webhook processing failed',\n message: error instanceof Error ? error.message : 'Unknown error'\n },\n { status: 400 }\n );\n }\n};\n", E = "import type Stripe from 'stripe';\nimport { handlePaymentIntentSucceeded } from './payment-intent/succeeded';\n\n/**\n * Routes a verified Stripe event to its handler. Runs inside the stripe-event\n * workflow, so a handler that throws is retried with backoff rather than lost.\n */\nexport async function dispatchStripeEvent(event: Stripe.Event, locals: App.Locals) {\n switch (event.type) {\n case 'payment_intent.succeeded':\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n}\n", D = "import { describe, it, expect } from \"vitest\";\nimport stripe from \"#lib/stripe.js\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n it(\"handles a payment intent successfully\", async (context) => {\n const paymentIntent = await stripe.paymentIntents.create({\n amount: 2000,\n currency: \"usd\",\n });\n const locals = { admin: context.admin } as App.Locals;\n const result = await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n expect(result).toEqual({});\n });\n});\n", O = "import Stripe from \"stripe\";\n\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n return {};\n}\n", k = "import { describe, it, expect } from \"vitest\";\nimport type { RouteId } from \"./$types\";\nimport type { Match } from \"@velastack/kit\";\nimport type Stripe from \"stripe\";\nimport stripe from \"#lib/stripe.js\";\n\ndescribe(\"POST /webhooks/stripe\", () => {\n it(\"accepts valid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2026-08-26.dahlia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(200);\n expect(response.body.received).toBe(true);\n expect(response.body.eventId).toBe(event.id);\n expect(response.body.eventType).toBe(\"test.event\");\n });\n\n it(\"rejects invalid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2026-08-26.dahlia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", \"invalid_signature\")\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n });\n\n it(\"rejects request without signature header\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2026-08-26.dahlia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n expect(response.body.message).toBe(\"Missing stripe-signature header\");\n });\n\n it(\"handles duplicate webhook events\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2026-08-26.dahlia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n // Send first webhook\n const response1 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response1.status).toBe(200);\n expect(response1.body.received).toBe(true);\n\n // Send duplicate webhook\n const response2 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n // The same event id lands on the same workflow run.\n expect(response2.status).toBe(200);\n expect(response2.body.received).toBe(true);\n expect(response2.body.runId).toBe(response1.body.runId);\n });\n});\n", A = "<script lang=\"ts\">\n import { Input } from '#lib/components/ui/input/index.js';\n import { Label } from '#lib/components/ui/label/index.js';\n import { Textarea } from '#lib/components/ui/textarea/index.js';\n\n /** Who is ordering: what the business needs to follow up an order whose chat was never sent. */\n let { disabled = false }: { disabled?: boolean } = $props();\n<\/script>\n\n<div class=\"grid gap-2\">\n <Label for=\"order-name\">Name</Label>\n <Input id=\"order-name\" name=\"name\" autocomplete=\"name\" required {disabled} />\n</div>\n<div class=\"grid gap-2\">\n <Label for=\"order-phone\">Phone</Label>\n <Input id=\"order-phone\" name=\"phone\" type=\"tel\" autocomplete=\"tel\" required {disabled} />\n</div>\n<div class=\"grid gap-2\">\n <Label for=\"order-note\">Note (optional)</Label>\n <Textarea id=\"order-note\" name=\"note\" rows={2} {disabled} />\n</div>\n<!-- A person never sees this; a bot that fills it is dropped by the hosted form. -->\n<input type=\"text\" name=\"_gotcha\" tabindex=\"-1\" autocomplete=\"off\" aria-hidden=\"true\" class=\"hidden\" />\n", j = "<script lang=\"ts\">\n import { toast } from 'svelte-sonner';\n import { formToken, orderRef, orderSubtotal, type OrderLine } from '@velastack/whatsapp';\n import { Button, buttonVariants } from '#lib/components/ui/button/index.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import CustomerFields from './customer-fields.svelte';\n import { ORDER_FORM, placeOrder } from '#lib/order.js';\n import { site } from '#lib/site.js';\n\n interface Props {\n /** What is being ordered, as the business will read it. */\n name: string;\n /** The unit price in `site.currency`, written as you would (`4.5`). Leave it out to quote in the chat. */\n price?: number;\n quantity?: number;\n label?: string;\n }\n\n let {\n name,\n price,\n quantity = 1,\n label = 'Order on WhatsApp',\n ...rest\n }: Props & ButtonProps = $props();\n\n let open = $state(false);\n let placed = $state<{ ref: string; href: string } | null>(null);\n // Fetched once, the first time the dialog opens: the hosted form refuses\n // a token younger than two seconds, and filling the form in takes longer.\n let token: string | null = null;\n\n $effect(() => {\n if (!open || !ORDER_FORM || token) return;\n formToken(ORDER_FORM).then((value) => (token = value));\n });\n\n function submit(event: SubmitEvent) {\n event.preventDefault();\n const data = new FormData(event.currentTarget as HTMLFormElement);\n const lines: OrderLine[] = [{ name, quantity, price }];\n const order = {\n ref: orderRef(),\n name: String(data.get('name') ?? ''),\n phone: String(data.get('phone') ?? ''),\n note: String(data.get('note') ?? '') || undefined,\n currency: site.currency,\n lines,\n subtotal: orderSubtotal(lines, site.currency)\n };\n const href = placeOrder(order, { token, gotcha: String(data.get('_gotcha') ?? '') });\n if (!href) {\n toast.error('WhatsApp ordering is not set up yet');\n return;\n }\n placed = { ref: order.ref, href };\n }\n\n function close() {\n open = false;\n placed = null;\n }\n<\/script>\n\n<Button onclick={() => (open = true)} {...rest}>{label}</Button>\n\n<Dialog.Root bind:open onOpenChange={(value) => !value && close()}>\n <Dialog.Content class=\"sm:max-w-md\">\n {#if placed}\n <Dialog.Header>\n <Dialog.Title>Order {placed.ref} opened in WhatsApp</Dialog.Title>\n <Dialog.Description>\n Send the message in WhatsApp to place your order. We'll reply there.\n </Dialog.Description>\n </Dialog.Header>\n <Dialog.Footer>\n <a\n href={placed.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class={buttonVariants({ variant: 'outline' })}\n >\n Open WhatsApp again\n </a>\n <Button onclick={close}>Done</Button>\n </Dialog.Footer>\n {:else}\n <form class=\"grid gap-4\" onsubmit={submit}>\n <Dialog.Header>\n <Dialog.Title>Order {name}</Dialog.Title>\n <Dialog.Description>\n Your order opens in WhatsApp, ready to send.\n </Dialog.Description>\n </Dialog.Header>\n <CustomerFields />\n <Dialog.Footer>\n <Button type=\"submit\">Continue in WhatsApp</Button>\n </Dialog.Footer>\n </form>\n {/if}\n </Dialog.Content>\n</Dialog.Root>\n", M = "import { describe, expect, it, vi } from 'vitest';\nimport { openChat, recordOrder, whatsappHref } from '@velastack/whatsapp';\nimport { orderMessage, placeOrder } from './order.js';\n\n// `vi.mock` is hoisted above every import, so what its factories read has to\n// be hoisted with it.\nconst { NUMBER, FORM } = vi.hoisted(() => ({\n NUMBER: '+52 55 1234 5678',\n FORM: 'https://velastack.dev/v1/projects/test/forms/order'\n}));\n\nvi.mock('$app/env', () => ({ browser: true }));\n// The currency store reads the page's language from the document stubbed below.\nvi.mock('$app/env/public', () => ({\n PUBLIC_WHATSAPP_NUMBER: NUMBER,\n PUBLIC_WHATSAPP_ORDER_FORM: FORM\n}));\nvi.mock('#lib/site.js', () => ({\n site: { name: 'Test', url: 'http://localhost:5173', currency: 'MXN' }\n}));\nvi.mock('@velastack/whatsapp', async (importOriginal) => ({\n ...(await importOriginal<typeof import('@velastack/whatsapp')>()),\n openChat: vi.fn(() => true),\n recordOrder: vi.fn(() => Promise.resolve(new Response(null, { status: 200 })))\n}));\n\n// Prices follow the page's language, not the test runner's: on a Mexican\n// Spanish page MXN reads as `$`.\nvi.stubGlobal('document', { documentElement: { lang: 'es-MX' } });\n\nconst order = {\n ref: 'A7K-3Q2',\n name: 'Ana',\n phone: '+52 55 8765 4321',\n currency: 'MXN',\n lines: [{ name: 'Concha', quantity: 2, price: 12 }],\n subtotal: 24\n};\n\ndescribe('orderMessage', () => {\n it('writes the lines, the total and the customer in the business currency', () => {\n const message = orderMessage(order);\n expect(message).toContain('(A7K-3Q2)');\n expect(message).toContain('2 × Concha · $24.00');\n expect(message).toContain('Total: $24.00');\n expect(message).toContain('Name: Ana');\n expect(message).toContain('Phone: +52 55 8765 4321');\n });\n});\n\ndescribe('placeOrder', () => {\n it('records the order and opens the chat before anything is awaited', () => {\n const href = placeOrder(order, { token: 'tok', gotcha: '' });\n\n // Both happen inside the call, with no await in between: a chat opened\n // after an await has lost the click's user activation and is blocked.\n expect(href).toBe(whatsappHref(NUMBER, orderMessage(order)));\n expect(recordOrder).toHaveBeenCalledWith(FORM, order, {\n message: orderMessage(order),\n token: 'tok',\n gotcha: ''\n });\n expect(openChat).toHaveBeenCalledWith(href);\n expect(vi.mocked(recordOrder).mock.invocationCallOrder[0]).toBeLessThan(\n vi.mocked(openChat).mock.invocationCallOrder[0]\n );\n });\n});\n", N = "import { PUBLIC_WHATSAPP_NUMBER, PUBLIC_WHATSAPP_ORDER_FORM } from '$app/env/public';\nimport { formatLines, openChat, recordOrder, whatsappHref, type Order } from '@velastack/whatsapp';\nimport { currency, money, pageLocale } from '#lib/currency.svelte.js';\n\n/** The hosted VelaStack form each order is recorded to. Empty records nothing. */\nexport const ORDER_FORM = PUBLIC_WHATSAPP_ORDER_FORM;\n\n/**\n * The message the customer sends the business. It is yours to change: this\n * is what lands in the business's WhatsApp. Prices are in the business's\n * currency; when the customer was reading them in another, one line gives\n * their estimate, since that is the figure they expect to see.\n */\nexport function orderMessage(order: Order): string {\n const lines = [\n `Hi! I'd like to place an order (${order.ref}):`,\n '',\n formatLines(order.lines, order.currency, pageLocale())\n ];\n if (order.subtotal !== undefined) {\n lines.push('', `Total: ${money(order.subtotal, order.currency)}`);\n const estimate = currency.convert(order.subtotal, order.currency);\n if (currency.current !== order.currency && estimate !== null) {\n lines.push(`≈ ${money(estimate, currency.current)} at today's rate`);\n }\n }\n lines.push('', `Name: ${order.name}`, `Phone: ${order.phone}`);\n if (order.note) lines.push(`Note: ${order.note}`);\n return lines.join('\\n');\n}\n\n/**\n * Records the order and opens the chat with the business. Call it straight\n * from the submit handler: the chat has to open before anything is awaited,\n * or the browser blocks it. Returns the chat link, or `null` when\n * `PUBLIC_WHATSAPP_NUMBER` is not set.\n */\nexport function placeOrder(\n order: Order,\n form: { token: string | null; gotcha: string }\n): string | null {\n const message = orderMessage(order);\n const href = whatsappHref(PUBLIC_WHATSAPP_NUMBER, message);\n if (!href) return null;\n if (ORDER_FORM) {\n recordOrder(ORDER_FORM, order, { message, ...form }).catch((error) => {\n console.error('Recording the order failed:', error);\n });\n }\n openChat(href);\n return href;\n}\n", P = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import SetupDialog from '#lib/components/payments/setup-dialog.svelte';\n import { useStripe } from '#lib/components/payments/use-stripe.svelte.js';\n import { usePaymentIntent } from '#lib/components/payments/use-payment-intent.svelte.js';\n\n interface Props {\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n disabled = false,\n isProcessing = false,\n label,\n processingLabel,\n onsuccess\n }: Props = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let showDialog = $state(false);\n let clientSecret = $state<string>();\n\n async function handleSetupClick() {\n const result = await paymentIntentManager.fetchSetupIntent();\n\n if (!result) return;\n\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleSetupClick}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n<SetupDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n/>\n", F = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let { stripe, open = $bindable(), clientSecret, onopenchange, onsuccess }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handleSetupPaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to add payment method');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmSetup({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n allow_redisplay: 'always'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to add payment method');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment method added successfully');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error adding payment method:', err);\n toast.error('Failed to add payment method');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <!-- Stripe's card form is tall: scroll within the screen so the buttons stay reachable -->\n <Dialog.Content class=\"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Add payment method</Dialog.Title>\n <Dialog.Description>Enter your card details to add a new payment method.</Dialog.Description>\n </Dialog.Header>\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"setup\"\n {stripe}\n onchange={handleCardChange}\n savePaymentMethod={true}\n />\n {/if}\n </div>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handleSetupPaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Add Card'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", I = "import { z } from 'zod';\nimport stripe from '#lib/stripe.js';\nimport { getAdmin, ow } from '#lib/server/workflows.js';\n\n/**\n * Gives a user a Stripe customer, reusing one that already carries the email\n * and copying over its saved cards. A user without an email (one made with a\n * phone number) gets a new customer under their name and number. Signup starts\n * it with the user's id as the idempotency key, so however many times it is\n * started or retried there is one run and one customer per user.\n */\nexport const linkStripeCustomer = ow.defineWorkflow(\n {\n name: 'link-stripe-customer',\n schema: z.object({ userId: z.string(), email: z.string().optional() }),\n retryPolicy: { maximumAttempts: 5 }\n },\n async ({ input, step }) => {\n const customer = await step.run({ name: 'find-or-create-customer' }, async () => {\n if (!input.email) {\n const admin = await getAdmin();\n // `phone` is there once enable-whatsapp has added it.\n const user: { name?: string; phone?: string } = await admin\n .collection('users')\n .getOne(input.userId);\n const created = await stripe.customers.create({\n name: user.name || undefined,\n phone: user.phone || undefined\n });\n return { id: created.id, existing: false, defaultPaymentMethod: null };\n }\n\n const matching = await stripe.customers.list({\n email: input.email,\n limit: 1,\n expand: ['data.invoice_settings']\n });\n const existing = matching.data[0];\n if (existing) {\n const method = existing.invoice_settings?.default_payment_method;\n return {\n id: existing.id,\n existing: true,\n defaultPaymentMethod: typeof method === 'string' ? method : (method?.id ?? null)\n };\n }\n const created = await stripe.customers.create({ email: input.email });\n return { id: created.id, existing: false, defaultPaymentMethod: null };\n });\n\n await step.run({ name: 'record-customer' }, async () => {\n const admin = await getAdmin();\n try {\n await admin.collection('stripe_customers').getOne(customer.id);\n } catch {\n await admin.collection('stripe_customers').create({ id: customer.id, user: input.userId });\n }\n });\n\n if (!customer.existing) return { customerId: customer.id, cards: 0 };\n\n const cards = await step.run({ name: 'list-cards' }, async () => {\n const methods = await stripe.customers.listPaymentMethods(customer.id, {\n type: 'card',\n allow_redisplay: 'always'\n });\n return methods.data\n .filter((method) => method.allow_redisplay !== 'unspecified')\n .map((method) => ({\n id: method.id,\n brand: method.card?.brand,\n last4: method.card?.last4,\n exp_month: method.card?.exp_month,\n exp_year: method.card?.exp_year\n }));\n });\n\n await step.run({ name: 'record-cards' }, async () => {\n const admin = await getAdmin();\n for (const card of cards) {\n try {\n await admin.collection('stripe_payment_methods').create({ ...card, customer: customer.id });\n } catch {\n // Already recorded by an earlier attempt.\n }\n }\n if (customer.defaultPaymentMethod) {\n try {\n await admin.collection('stripe_customers').update(customer.id, {\n default_payment_method: customer.defaultPaymentMethod\n });\n } catch {\n // The default card was not one that can be shown again.\n }\n }\n });\n\n return { customerId: customer.id, cards: cards.length };\n }\n);\n", L = "import { getAdmin, ow } from '#lib/server/workflows.js';\nimport { linkStripeCustomer } from './link-stripe-customer';\n\n/**\n * The safety net for users that did not come through signup (the dashboard,\n * an import): starts link-stripe-customer for each one without a customer.\n * The idempotency key means a user whose run already exists, finished or\n * still retrying, is left alone.\n */\nexport const syncStripeCustomers = ow.defineWorkflow(\n { name: 'sync-stripe-customers', retryPolicy: { maximumAttempts: 3 } },\n async ({ step }) => {\n const users = await step.run({ name: 'find-unlinked' }, async () => {\n const admin = await getAdmin();\n const rows = await admin\n .collection('users')\n .getFullList({ filter: 'stripe_customers_via_user.id = null' });\n return rows.map((user) => ({ id: user.id, email: user.email || undefined }));\n });\n\n await step.run({ name: 'start-links' }, async () => {\n for (const user of users) {\n await linkStripeCustomer.run(\n { userId: user.id, email: user.email },\n { idempotencyKey: user.id }\n );\n }\n });\n\n return { queued: users.length };\n }\n);\n\nexport const cron = '*/10 * * * *';\n", R = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Billing\", url: \"/billing\" }],\n };\n};\n", z = "# Billing Page - Stripe Payment Methods\n\nThis billing page provides a modern UI for managing payment methods with Stripe.\n\n## Features\n\n✅ **Display Payment Methods** - Shows all saved cards with brand, last 4 digits, and expiration\n✅ **Add Payment Methods** - Secure card input using Stripe Elements\n✅ **Remove Payment Methods** - Delete cards with confirmation dialog\n✅ **Default Payment Method** - Set and display the default payment method\n✅ **Responsive Design** - Mobile-friendly layout\n✅ **Error Handling** - Toast notifications for user feedback\n\n## Current Status\n\nThe frontend is **fully functional** with mock data. To connect to your backend, follow the integration steps below.\n\n## Backend Integration\n\n### 1. Update Stripe Publishable Key\n\nIn `+page.svelte`, replace the placeholder with your actual Stripe publishable key:\n\n```typescript\nconst STRIPE_PUBLISHABLE_KEY = \"pk_test_YOUR_KEY_HERE\";\n```\n\nOr better yet, load it from environment variables:\n\n```typescript\nimport { PUBLIC_STRIPE_PUBLISHABLE_KEY } from \"$app/env/public\";\nconst STRIPE_PUBLISHABLE_KEY = PUBLIC_STRIPE_PUBLISHABLE_KEY;\n```\n\n### 2. Fetch Payment Methods on Load\n\nUpdate `+page.server.ts` to fetch payment methods:\n\n```typescript\nexport const load: PageServerLoad = async ({ locals }) => {\n const user = locals.user;\n\n if (!user?.stripeCustomerId) {\n return { paymentMethods: [] };\n }\n\n // Fetch payment methods from Stripe\n const stripe = await import(\"#lib/stripe.js\").then((m) => m.default);\n const paymentMethods = await stripe.paymentMethods.list({\n customer: user.stripeCustomerId,\n type: \"card\",\n });\n\n return {\n paymentMethods: paymentMethods.data.map((pm) => ({\n id: pm.id,\n brand: pm.card?.brand || \"unknown\",\n last4: pm.card?.last4 || \"0000\",\n expMonth: pm.card?.exp_month || 1,\n expYear: pm.card?.exp_year || 2025,\n isDefault: false, // You'll need to track this separately\n })),\n };\n};\n```\n\n### 3. Create API Endpoints\n\nCreate the following server endpoints:\n\n#### Add Payment Method: `+page.server.ts`\n\n```typescript\nexport const actions = {\n addPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Attach payment method to customer\n const stripe = await import(\"#lib/stripe.js\").then((m) => m.default);\n await stripe.paymentMethods.attach(paymentMethodId, {\n customer: locals.user.stripeCustomerId,\n });\n\n return { success: true };\n },\n\n removePaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Detach payment method from customer\n const stripe = await import(\"#lib/stripe.js\").then((m) => m.default);\n await stripe.paymentMethods.detach(paymentMethodId);\n\n return { success: true };\n },\n\n setDefaultPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Update customer's default payment method\n const stripe = await import(\"#lib/stripe.js\").then((m) => m.default);\n await stripe.customers.update(locals.user.stripeCustomerId, {\n invoice_settings: {\n default_payment_method: paymentMethodId,\n },\n });\n\n return { success: true };\n },\n};\n```\n\n### 4. Update Frontend to Use Actions\n\nReplace the mock functions in `+page.svelte`:\n\n```typescript\nasync function handleAddPaymentMethod() {\n if (!stripe || !cardElement || !cardComplete) return;\n\n isProcessing = true;\n\n try {\n const { error, paymentMethod } = await stripe.createPaymentMethod({\n type: \"card\",\n card: cardElement,\n });\n\n if (error) {\n toast.error(error.message);\n return;\n }\n\n // Submit to your backend\n const formData = new FormData();\n formData.append(\"paymentMethodId\", paymentMethod.id);\n\n const response = await fetch(\"?/addPaymentMethod\", {\n method: \"POST\",\n body: formData,\n });\n\n if (response.ok) {\n toast.success(\"Payment method added\");\n // Reload page to fetch updated payment methods\n window.location.reload();\n }\n } finally {\n isProcessing = false;\n }\n}\n```\n\n## Security Considerations\n\n⚠️ **Important**: Never expose your Stripe secret key on the frontend\n✅ All sensitive operations should happen on your backend\n✅ Use Stripe's publishable key for frontend operations\n✅ Validate user permissions before modifying payment methods\n✅ Use HTTPS in production\n\n## Testing\n\nUse [Stripe's test cards](https://stripe.com/docs/testing) for testing:\n\n- **Success**: 4242 4242 4242 4242\n- **Decline**: 4000 0000 0000 0002\n- **Requires authentication**: 4000 0025 0000 3155\n\nUse any future expiration date and any 3-digit CVC.\n\n## Styling\n\nThe page uses Tailwind CSS and shadcn/ui components. All components are styled to match your existing design system with support for light/dark modes.\n\n### Stripe Elements Styling\n\nSince Stripe Elements render in an iframe, they cannot access CSS variables directly. Additionally, Stripe only accepts HEX, RGB, or HSL colors (not modern formats like OKLCH).\n\nThe implementation:\n\n1. **Creates temporary DOM elements** with CSS variables applied\n2. **Lets the browser compute colors** - converts OKLCH/HSL/any format to RGB\n3. **Extracts RGB values** that Stripe Elements can understand\n4. **Passes computed colors** to Stripe Elements on initialization\n5. **Matches the current theme** automatically (light/dark mode)\n\nThis approach works with any CSS color format (oklch, hsl, rgb, hex) and ensures Stripe Elements always match your theme when the \"Add Payment Method\" dialog opens.\n\n## Dependencies\n\n- `@stripe/stripe-js` - Stripe.js for frontend\n- `stripe` - Stripe Node.js SDK for backend\n- `svelte-sonner` - Toast notifications\n- `@lucide/svelte` - Icons\n- shadcn/ui components\n", B = "import stripe from \"#lib/stripe.js\";\nimport type { Stripe } from \"stripe\";\nimport { getStripeCustomerId } from \"#lib/server/stripe-customer.js\";\n\nconst createPaymentIntent = async (\n price: Stripe.Price,\n customer?: { id: string; default_payment_method?: string },\n) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n // Guest\n if (!customer) {\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n setupFutureUsage: null,\n };\n }\n\n // Customer with saved payment method\n if (customer.default_payment_method) {\n const paymentMethod = await stripe.customers.retrievePaymentMethod(\n customer.id,\n customer.default_payment_method,\n );\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n payment_method: customer.default_payment_method,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return {\n type: \"confirm\",\n clientSecret: intent.client_secret,\n setupFutureUsage: null,\n amount: price.unit_amount,\n currency: price.currency,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n };\n }\n\n // Customer without saved payment method\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n setup_future_usage: \"off_session\",\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n // The card form must set the same `setupFutureUsage` as the intent, or\n // Stripe refuses to confirm it.\n setupFutureUsage: \"off_session\",\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n const user = locals.pb.authStore.record;\n\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return Response.json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return Response.json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return Response.json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return Response.json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n let customer;\n\n if (user) {\n try {\n // Links the user to a Stripe customer first if they have none yet (a\n // signup whose link run has not finished, a one-time-code signup).\n const customerId = await getStripeCustomerId(locals.admin, user);\n customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(customerId);\n } catch (error) {\n // Not linked in time: pay as a guest rather than not at all.\n console.log(\"No Stripe customer for user, paying as a guest:\", user.id);\n }\n }\n\n try {\n const res = await createPaymentIntent(price, customer);\n return Response.json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return Response.json({ error: errorMessage }, { status: 500 });\n }\n};\n", V = "import { describe, it, expect, beforeAll, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"#lib/stripe.js\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n beforeEach(async (context) => {\n // Create a Stripe customer for authenticated user tests\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Create a payment method for the customer\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n });\n\n afterEach(async () => {\n if (paymentMethod?.id) {\n await stripe.paymentMethods.detach(paymentMethod.id);\n }\n\n if (stripeCustomer?.id) {\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n expect(response.body.setupFutureUsage).toBeNull();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user without Stripe customer\", () => {\n it(\"should link a Stripe customer and keep the card for them\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.setupFutureUsage).toBe(\"off_session\");\n\n // The link-stripe-customer run linked one on the spot, reusing the\n // Stripe customer that already has the user's email.\n const linked = await context.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n context.admin.filter(\"user = {:user}\", { user: context.user.id }),\n );\n expect(linked.id).toBe(stripeCustomer.id);\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.customer).toBe(linked.id);\n expect(intent.setup_future_usage).toBe(\"off_session\");\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n await context.admin.collection(\"stripe_customers\").delete(linked.id);\n });\n });\n\n describe(\"Authenticated user with Stripe customer\", () => {\n let customerRecord: { id: string };\n\n beforeEach(async (context) => {\n // Link the Stripe customer to the PocketBase user\n customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .create({\n user: context.user.id,\n id: stripeCustomer.id,\n email: stripeCustomer.email,\n });\n });\n\n afterEach(async (context) => {\n // Clean up the PocketBase customer record\n await context.admin\n .collection(\"stripe_customers\")\n .delete(customerRecord.id);\n });\n\n it(\"should create payment intent with setup_future_usage for user without default payment method\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n expect(response.body.setupFutureUsage).toBe(\"off_session\");\n\n // Verify the payment intent has setup_future_usage\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.setup_future_usage).toBe(\"off_session\");\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n\n it(\"should create payment intent with default payment method for customer with saved payment method\", async (context) => {\n // Set default payment method\n await stripe.customers.update(stripeCustomer.id, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n const customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n context.admin.filter(\"user = {:user}\", { user: context.user.id }),\n );\n\n await context.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customerRecord.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n\n await context.admin\n .collection(\"stripe_customers\")\n .update(customerRecord.id, {\n default_payment_method: paymentMethod.id,\n });\n\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"confirm\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBe(\"visa\");\n expect(response.body.last4).toBeDefined();\n expect(response.body.last4).toMatch(/^\\d{4}$/);\n expect(response.body.setupFutureUsage).toBeNull();\n\n // Verify the payment intent has the payment method attached\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.payment_method).toBe(paymentMethod.id);\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", H = "import stripe from \"#lib/stripe.js\";\nimport { getStripeCustomerId } from \"#lib/server/stripe-customer.js\";\n\nexport const POST = async ({ locals }) => {\n const user = locals.pb.authStore.record;\n\n if (!user) {\n return Response.json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n let customer: string;\n try {\n customer = await getStripeCustomerId(locals.admin, user);\n } catch {\n return Response.json(\n { error: \"Billing is still being set up. Try again shortly.\" },\n { status: 503 },\n );\n }\n\n const setupIntent = await stripe.setupIntents.create({\n customer,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return Response.json({ clientSecret: setupIntent.client_secret });\n};\n", U = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type Stripe from \"stripe\";\nimport stripe from \"#lib/stripe.js\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /api/stripe/setup-intent\", () => {\n let stripeCustomer: Stripe.Customer;\n\n beforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n });\n\n afterEach(async (context) => {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n });\n\n it(\"creates a setup intent\", async (context) => {\n const response = await context.agent.post(\n \"/api/stripe/setup-intent\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n expect(response.body.clientSecret).toBeDefined();\n });\n});\n", W = "import type Stripe from 'stripe';\nimport { handlePaymentIntentSucceeded } from './payment-intent/succeeded';\nimport { handlePaymentMethodAttached } from './payment-method/attached';\n\n/**\n * Routes a verified Stripe event to its handler. Runs inside the stripe-event\n * workflow, so a handler that throws is retried with backoff rather than lost.\n */\nexport async function dispatchStripeEvent(event: Stripe.Event, locals: App.Locals) {\n switch (event.type) {\n case 'payment_intent.succeeded':\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n case 'payment_method.attached':\n await handlePaymentMethodAttached(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n}\n", G = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"#lib/stripe.js\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentIntent: Stripe.PaymentIntent;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n // Create a Stripe customer\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Link the Stripe customer to the test user\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n // Create a payment method for testing\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n // Attach payment method to customer\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n // Create a payment intent\n paymentIntent = await stripe.paymentIntents.create({\n amount: 2000, // $20.00\n currency: \"usd\",\n customer: stripeCustomer.id,\n payment_method: paymentMethod.id,\n confirm: true,\n return_url: \"https://example.com/return\",\n });\n });\n\n afterEach(async (context) => {\n // Clean up transactions\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\"stripe_customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n for (const transaction of transactions) {\n await context.admin.collection(\"transactions\").delete(transaction.id);\n }\n\n // Clean up Stripe resources\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch (e) {\n // Payment method may already be detached\n }\n }\n\n // Delete customer (this will also delete associated payment methods)\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a transaction record when payment intent succeeds\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_customer).toBe(stripeCustomer.id);\n expect(transaction.amount).toBe(2000);\n expect(transaction.currency).toBe(\"usd\");\n expect(transaction.user).toBe(context.user.id);\n expect(transaction.stripe_charge).toBeDefined();\n expect(transaction.last4).toBeDefined();\n expect(transaction.brand).toBeDefined();\n expect(transaction.created).toBeDefined();\n expect(transaction.receipt_url).toBeDefined();\n });\n\n it(\"handles payment intent with charge object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded charge\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"latest_charge\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_charge).toBeDefined();\n });\n\n it(\"handles payment intent with customer object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded customer\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n expect(transactions[0].stripe_customer).toBe(stripeCustomer.id);\n });\n\n it(\"handles missing charge ID gracefully\", async (context) => {\n const paymentIntentWithoutCharge = {\n ...paymentIntent,\n latest_charge: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCharge, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n\n it(\"handles missing customer ID gracefully\", async (context) => {\n const paymentIntentWithoutCustomer = {\n ...paymentIntent,\n customer: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCustomer, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n});\n", K = "import Stripe from \"stripe\";\nimport stripe from \"#lib/stripe.js\";\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n const chargeId =\n typeof paymentIntent.latest_charge === \"string\"\n ? paymentIntent.latest_charge\n : paymentIntent.latest_charge?.id;\n\n if (!chargeId) {\n console.error(\"No charge ID found for payment intent\");\n return;\n }\n\n const charge = await stripe.charges.retrieve(chargeId);\n\n const customerId =\n typeof paymentIntent.customer === \"string\"\n ? paymentIntent.customer\n : paymentIntent.customer?.id;\n\n if (!customerId) {\n console.error(\"No customer ID found for payment intent\");\n return;\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(customerId);\n const created = new Date(charge.created * 1000);\n\n await locals.admin.collection(\"transactions\").create({\n stripe_payment_intent: paymentIntent.id,\n stripe_charge: chargeId,\n stripe_customer: customerId,\n amount: paymentIntent.amount,\n currency: paymentIntent.currency,\n created: created.toISOString(),\n last4: charge.payment_method_details?.card?.last4,\n brand: charge.payment_method_details?.card?.brand,\n receipt_url: charge.receipt_url,\n user: customer.user,\n });\n}\n", q = "import Stripe from \"stripe\";\nimport stripe from \"#lib/stripe.js\";\n\n/**\n * Handles payment_method.attached event\n */\nexport async function handlePaymentMethodAttached(\n paymentMethod: Stripe.PaymentMethod,\n locals: App.Locals,\n) {\n if (\n paymentMethod.allow_redisplay === \"unspecified\" ||\n !paymentMethod.customer\n ) {\n return;\n }\n\n const customer =\n typeof paymentMethod.customer === \"string\"\n ? paymentMethod.customer\n : paymentMethod.customer?.id;\n\n await locals.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customer,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n\n const paymentMethodRecords = await locals.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: locals.admin.filter(\"customer = {:customer}\", {\n customer: customer,\n }),\n });\n\n if (paymentMethodRecords.length === 1) {\n const paymentMethod = paymentMethodRecords[0];\n\n await stripe.customers.update(customer, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n await locals.admin.collection(\"stripe_customers\").update(customer, {\n default_payment_method: paymentMethod.id,\n });\n }\n}\n", J = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"#lib/stripe.js\";\nimport { handlePaymentMethodAttached } from \"./attached\";\n\ndescribe(\"payment_method.attached\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n paymentMethod = await stripe.paymentMethods.update(paymentMethod.id, {\n allow_redisplay: \"always\",\n });\n });\n\n afterEach(async (context) => {\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n\n for (const pm of paymentMethods) {\n await context.admin.collection(\"stripe_payment_methods\").delete(pm.id);\n }\n\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch {}\n }\n\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a payment method record when payment method is attached\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n const pm = paymentMethods[0];\n\n expect(pm.id).toBe(paymentMethod.id);\n expect(pm.customer).toBe(stripeCustomer.id);\n expect(pm.brand).toBe(paymentMethod.card?.brand);\n expect(pm.last4).toBe(paymentMethod.card?.last4);\n expect(pm.exp_month).toBe(paymentMethod.card?.exp_month);\n expect(pm.exp_year).toBe(paymentMethod.card?.exp_year);\n });\n\n it(\"sets payment method as default when it is the first one\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default in database\n const customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Verify it was set as default in Stripe\n const stripeCustomerUpdated = await stripe.customers.retrieve(\n stripeCustomer.id,\n );\n if (\"deleted\" in stripeCustomerUpdated) {\n throw new Error(\"Customer should not be deleted\");\n }\n expect(stripeCustomerUpdated.invoice_settings.default_payment_method).toBe(\n paymentMethod.id,\n );\n });\n\n it(\"does not set as default when there are already payment methods\", async (context) => {\n // Handle the first payment method\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default\n let customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Create and attach a first payment method\n let secondPaymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_mastercard\",\n },\n });\n\n await stripe.paymentMethods.attach(secondPaymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n secondPaymentMethod = await stripe.paymentMethods.update(\n secondPaymentMethod.id,\n {\n allow_redisplay: \"always\",\n },\n );\n\n // Now handle the second payment method\n await handlePaymentMethodAttached(secondPaymentMethod, locals);\n\n // Verify the default did NOT change\n customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Clean up the second payment method\n await context.admin\n .collection(\"stripe_payment_methods\")\n .delete(secondPaymentMethod.id);\n await stripe.paymentMethods.detach(secondPaymentMethod.id);\n });\n\n it(\"handles payment method with customer object instead of string\", async (context) => {\n // Retrieve the payment method with expanded customer\n const expandedPaymentMethod = await stripe.paymentMethods.retrieve(\n paymentMethod.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(expandedPaymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n expect(paymentMethods[0].customer).toBe(stripeCustomer.id);\n });\n\n it(\"does not create record when allow_redisplay is unspecified\", async (context) => {\n // Update payment method to have unspecified allow_redisplay\n const unspecifiedPaymentMethod = await stripe.paymentMethods.update(\n paymentMethod.id,\n {\n allow_redisplay: \"unspecified\",\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(unspecifiedPaymentMethod, locals);\n\n // Verify no payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(0);\n });\n});\n", Y = [
|
|
9
9
|
{
|
|
10
10
|
id: "stripe",
|
|
@@ -171,10 +171,8 @@ async function ie(t, { unitTests: i = !1 } = {}) {
|
|
|
171
171
|
collectionDrops: []
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
-
|
|
175
|
-
//#region src/patterns/enable/payments/creates-server/src/lib/currency.server.test.ts?raw
|
|
174
|
+
// src/patterns/enable/payments/creates-server/src/lib/currency.server.test.ts?raw
|
|
176
175
|
var ae = "import { describe, expect, it } from 'vitest';\nimport { requestCountry } from './currency.server.js';\n\nconst request = (headers: Record<string, string>) =>\n new Request('https://example.com/', { headers });\n\ndescribe('requestCountry', () => {\n it('trusts the CDN first', () => {\n expect(requestCountry(request({ 'cf-ipcountry': 'mx', 'accept-language': 'en-US' }))).toBe(\n 'MX'\n );\n expect(requestCountry(request({ 'x-vercel-ip-country': 'GT' }))).toBe('GT');\n });\n\n it('falls back to the first Accept-Language region', () => {\n expect(requestCountry(request({ 'accept-language': 'es-MX,es;q=0.9,en;q=0.8' }))).toBe('MX');\n expect(requestCountry(request({ 'accept-language': 'en-us' }))).toBe('US');\n });\n\n it('gives up on a language without a region, or an unknown CDN value', () => {\n expect(requestCountry(request({ 'accept-language': 'es' }))).toBeNull();\n expect(requestCountry(request({ 'cf-ipcountry': 'XX1' }))).toBeNull();\n expect(requestCountry(request({}))).toBeNull();\n });\n});\n", oe = "import type { RequestEvent } from '@sveltejs/kit';\nimport type { Handle } from '@sveltejs/kit/hooks';\nimport { offered } from '#lib/currency.svelte.js';\n\n/**\n * The currency a visitor reads prices in, decided on the server so the first\n * render already shows it: the one they picked (the `currency` cookie), else\n * their region's when the site offers it, else the business's own. The\n * business's prices never change; the others are estimates at the day's rate.\n *\n * `handleCurrency` puts it in `locals.currency`; the root layout load returns\n * it with the rates, and `currency.hydrate` starts the store from them.\n */\n\ndeclare global {\n namespace App {\n interface Locals {\n /** One of the currencies the site offers; `handleCurrency` sets it. */\n currency: string;\n }\n }\n}\n\nconst RATES_URL = 'https://velastack.dev/v1/rates';\nconst DAY = 24 * 60 * 60 * 1000;\nconst RETRY = 5 * 60 * 1000;\n\nexport interface Rates {\n base: string;\n date: string;\n rates: Record<string, number>;\n /** The currency each country pays in, to go from a visitor's region to one. */\n countries: Record<string, string>;\n}\n\nlet cached: { rates: Rates; fetchedAt: number } | null = null;\nlet failedAt = 0;\nlet inflight: Promise<Rates | null> | null = null;\n\n/**\n * The day's rates from velastack.dev, fetched once a day and shared by every\n * request; the last ones known when it can't be reached, else `null`.\n */\nexport async function fetchRates(): Promise<Rates | null> {\n if (cached && Date.now() - cached.fetchedAt < DAY) return cached.rates;\n if (Date.now() - failedAt < RETRY) return cached?.rates ?? null;\n inflight ??= (async () => {\n try {\n const response = await fetch(RATES_URL);\n if (!response.ok) throw new Error(`${response.status} from ${RATES_URL}`);\n const rates = (await response.json()) as Rates;\n cached = { rates, fetchedAt: Date.now() };\n return rates;\n } catch (error) {\n console.error('Could not fetch exchange rates:', error);\n failedAt = Date.now();\n return cached?.rates ?? null;\n } finally {\n inflight = null;\n }\n })();\n return inflight;\n}\n\n/** What the page needs to convert into `currency`: nothing when it is the business's own, or the site offers one. */\nexport async function displayRates(currency: string): Promise<Rates | null> {\n return offered.length < 2 || currency === offered[0] ? null : fetchRates();\n}\n\n/** The headers a CDN reports the visitor's country in. */\nconst COUNTRY_HEADERS = ['cf-ipcountry', 'x-vercel-ip-country', 'cloudfront-viewer-country'];\n\n/** The visitor's country as the CDN reports it, else the first Accept-Language region, else `null`. */\nexport function requestCountry(request: Request): string | null {\n for (const name of COUNTRY_HEADERS) {\n const value = request.headers.get(name)?.trim().toUpperCase();\n if (value && /^[A-Z]{2}$/.test(value)) return value;\n }\n const first = request.headers.get('accept-language')?.split(',')[0]?.trim();\n const region = first?.match(/^[A-Za-z]{2,3}-([A-Za-z]{2})(?:[-;]|$)/)?.[1];\n return region?.toUpperCase() ?? null;\n}\n\nexport async function resolveCurrency(\n event: Pick<RequestEvent, 'cookies' | 'request'>\n): Promise<string> {\n const home = offered[0] ?? '';\n if (offered.length < 2) return home;\n const picked = event.cookies.get('currency')?.toUpperCase();\n if (picked && offered.includes(picked)) return picked;\n const country = requestCountry(event.request);\n if (!country) return home;\n const regional = (await fetchRates())?.countries[country];\n return regional && offered.includes(regional) ? regional : home;\n}\n\nexport const handleCurrency: Handle = async ({ event, resolve }) => {\n event.locals.currency = await resolveCurrency(event);\n return resolve(event);\n};\n";
|
|
177
|
-
//#endregion
|
|
178
176
|
export { T as A, h as B, M as C, O as D, k as E, b as F, u as G, p as H, y as I, l as K, v as L, C as M, S as N, D as O, x as P, _ as R, N as S, A as T, f as U, m as V, d as W, R as _, Z as a, F as b, q as c, W as d, U as f, z as g, B as h, Y as i, w as j, E as k, K as l, V as m, ae as n, ie as o, H as p, X as r, J as s, oe as t, G as u, L as v, j as w, P as x, I as y, g as z };
|
|
179
177
|
|
|
180
|
-
//# sourceMappingURL=currency.server-
|
|
178
|
+
//# sourceMappingURL=currency.server-BwuXG0a9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.server-CzHS7Svd.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__1_2_","__import_glob__1_3_","__import_glob__1_4_","__import_glob__1_5_","__import_glob__1_6_","__import_glob__1_7_","__import_glob__1_8_","__import_glob__1_9_","__import_glob__1_10_","__import_glob__1_11_","__import_glob__1_12_","__import_glob__1_13_","__import_glob__1_14_","__import_glob__1_15_","__import_glob__1_16_","__import_glob__1_17_","__import_glob__1_18_","__import_glob__1_19_","__import_glob__1_20_","__import_glob__1_21_","__import_glob__1_22_","__import_glob__2_0_","__import_glob__2_1_","__import_glob__2_2_","__import_glob__2_3_","__import_glob__2_4_","__import_glob__2_5_","__import_glob__2_6_","__import_glob__2_7_","__import_glob__2_8_","__import_glob__2_9_","__import_glob__2_10_","__import_glob__2_11_","__import_glob__2_12_","__import_glob__2_13_","__import_glob__2_14_","__import_glob__2_15_","__import_glob__2_16_","__import_glob__2_17_","InvalidArgumentError","VELASTACK_WHATSAPP","filesFromGlob","resolveProvider","providerCreates","stripe_customer_default","_page_server_default","_page_default","currency_select_default","currency_svelte_default","buy_button_default","shopify_default","confirm_dialog_default","payment_button_default","payment_dialog_default","stripe_constants_default","stripe_payment_form_default","use_payment_intent_svelte_default","use_stripe_svelte_default","stripe_default","stripe_event_default","sync_stripe_catalog_default","_server_default$3","server_test_default$6","_server_default$2","dispatch_default$1","server_test_default$5","succeeded_default$1","server_test_default$4","customer_fields_default","order_button_default","order_test_default","order_default","setup_button_default","setup_dialog_default","link_stripe_customer_default","sync_stripe_customers_default","_layout_server_default","README_default","_server_default$1","server_test_default$3","_server_default","server_test_default$2","dispatch_default","server_test_default$1","succeeded_default","attached_default","server_test_default","PROVIDERS","META","envEditsFor","providerEnvEdits","provider","supplied","COMPONENTS","PACKAGES","createsRaw","providersRaw","providersAppModeRaw","isUnitTest","path","generate","options","current","label","candidate","isAppMode","creates","unitTests","file","components","a","b","currency_server_test_default","currency_server_default"],"sources":["../../src/patterns/enable/payments/generate.ts"],"sourcesContent":["import type {\n Component,\n Options,\n Package,\n Provider,\n Result,\n} from \"../../../core/types\";\nimport type { EnvEdit } from \"../../../runtime/env\";\nimport {\n providerCreates,\n providerEnvEdits,\n resolveProvider,\n} from \"../../../core/providers\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { VELASTACK_WHATSAPP } from \"../../../core/constants\";\nimport { filesFromGlob } from \"../../../core/util\";\n\n/**\n * The providers in prompt order. Each one's `env` keys are what the CLI asks\n * for, what `generate.runtime.ts` writes to `.env` (in this order, under a\n * `# <Label> credentials` heading) and declares in `src/env.ts`.\n */\nexport const PROVIDERS: Provider[] = [\n {\n id: \"stripe\",\n label: \"Stripe\",\n env: [\n {\n key: \"STRIPE_SECRET_KEY\",\n label: \"Stripe secret key\",\n placeholder: \"sk_...\",\n secret: true,\n required: true,\n description:\n \"Stripe secret key (`sk_...`) the server calls the Stripe API with.\",\n },\n {\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n label: \"Stripe publishable key\",\n placeholder: \"pk_...\",\n public: true,\n required: true,\n description:\n \"Stripe publishable key (`pk_...`) that Stripe.js loads in the browser.\",\n },\n {\n key: \"STRIPE_WEBHOOK_SECRET\",\n label: \"Stripe webhook signing secret\",\n placeholder: \"whsec_...\",\n secret: true,\n required: true,\n description:\n \"Signing secret (`whsec_...`) that `/webhooks/stripe` verifies events with.\",\n },\n ],\n // The webhook route predates the `src/env.ts` declarations, so a project\n // that enabled payments before them is still recognised.\n markers: [\n { env: \"STRIPE_SECRET_KEY\" },\n { path: \"src/routes/webhooks/stripe\" },\n ],\n // Products, prices and customers are synced into PocketBase by workflows.\n requires: { backend: true, workflows: true },\n },\n {\n id: \"shopify\",\n label: \"Shopify\",\n env: [\n {\n key: \"PUBLIC_SHOPIFY_STORE_DOMAIN\",\n label: \"Shopify store domain\",\n placeholder: \"your-store.myshopify.com\",\n public: true,\n required: true,\n description:\n \"The store's `*.myshopify.com` domain the Storefront API is called on.\",\n },\n {\n key: \"PUBLIC_SHOPIFY_STOREFRONT_TOKEN\",\n label: \"Shopify Storefront API public access token\",\n public: true,\n required: true,\n description:\n \"Public Storefront API access token, from the store's Headless channel.\",\n },\n ],\n },\n {\n id: \"whatsapp\",\n label: \"WhatsApp\",\n env: [\n {\n key: \"PUBLIC_WHATSAPP_NUMBER\",\n label: \"WhatsApp number orders are sent to\",\n placeholder: \"+353 1 555 0100\",\n public: true,\n required: true,\n description:\n \"The business's WhatsApp number, with country code, that orders open a chat with.\",\n },\n {\n key: \"PUBLIC_WHATSAPP_ORDER_FORM\",\n label: \"Hosted VelaStack form orders are recorded to\",\n placeholder: \"https://velastack.dev/v1/projects/<project>/forms/order\",\n public: true,\n description:\n \"The hosted VelaStack form each order is recorded to, so it is kept even if the chat is never sent. Empty records nothing.\",\n },\n ],\n },\n];\n\n/** What `resolveProvider` needs; `index.ts` spreads the rest of the metadata. */\nexport const META = { slug: \"enable-payments\", providers: PROVIDERS };\n\n/** The `.env` lines for a provider, under a `# <Label> credentials` heading. */\nexport function envEditsFor(\n provider: Provider,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return providerEnvEdits(provider, `${provider.label} credentials`, supplied);\n}\n\n// `select` is the currency select every provider gets.\nconst COMPONENTS: Record<string, Component[]> = {\n stripe: [\"dialog\", \"input\", \"label\", \"select\"],\n shopify: [\"button\", \"select\"],\n whatsapp: [\"button\", \"dialog\", \"input\", \"label\", \"textarea\", \"select\"],\n};\n\nconst PACKAGES: Record<string, Package[]> = {\n stripe: [\"stripe\", \"@stripe/stripe-js\"],\n shopify: [\"@shopify/storefront-api-client\"],\n whatsapp: [VELASTACK_WHATSAPP],\n};\n\n// Shared by every provider: the currency prices show in, and its select.\nconst createsRaw = import.meta.glob<string>(\"./creates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersRaw = import.meta.glob<string>(\"./providers/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersAppModeRaw = import.meta.glob<string>(\n \"./providers-app-mode/**\",\n { query: \"?raw\", import: \"default\", eager: true },\n);\n\nexport interface GenerateContext {\n /**\n * The project can run unit tests (vitest is installed), so a provider's\n * `*.test.ts` beside its code is written too. Server tests (`server.test.ts`)\n * always are: they run under `vela test:server`, which brings its own runner.\n */\n unitTests?: boolean;\n}\n\nconst isUnitTest = (path: string) =>\n path.endsWith(\".test.ts\") && !path.endsWith(\"server.test.ts\");\n\nexport async function generate(\n options: Options,\n { unitTests = false }: GenerateContext = {},\n) {\n const provider = resolveProvider(META, options);\n\n // A second provider would leave the project with both, and the patterns\n // built on payments could no longer tell which one it uses.\n const current = options.providers?.payments;\n if (current !== undefined && current !== provider.id) {\n const label =\n PROVIDERS.find((candidate) => candidate.id === current)?.label ?? current;\n throw new InvalidArgumentError(\n `This project already uses ${label} payments. To switch to ${provider.label}, ` +\n \"run `vela disable payments` first, then enable payments again.\",\n );\n }\n // Stripe keeps cards and customers for signed-in users; Shopify's checkout\n // owns its customers and WhatsApp has none, so neither has app-mode files.\n const isAppMode = options.features.auth;\n\n const creates = new Map(\n [\n ...Object.values(filesFromGlob(createsRaw, \"./creates/\")),\n ...providerCreates(providersRaw, provider.id),\n ]\n .filter((file) => unitTests || !isUnitTest(file.path))\n .map((file) => [file.path, file]),\n );\n if (isAppMode) {\n for (const file of providerCreates(\n providersAppModeRaw,\n provider.id,\n \"./providers-app-mode/\",\n )) {\n creates.set(file.path, file);\n }\n }\n\n const components = [...(COMPONENTS[provider.id] ?? [])];\n if (isAppMode && provider.id === \"stripe\") components.push(\"alert-dialog\");\n\n return {\n creates: [...creates.values()].sort((a, b) => a.path.localeCompare(b.path)),\n modifies: [],\n deletes: [],\n components,\n packages: PACKAGES[provider.id] ?? [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"currency.server-BwuXG0a9.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__1_2_","__import_glob__1_3_","__import_glob__1_4_","__import_glob__1_5_","__import_glob__1_6_","__import_glob__1_7_","__import_glob__1_8_","__import_glob__1_9_","__import_glob__1_10_","__import_glob__1_11_","__import_glob__1_12_","__import_glob__1_13_","__import_glob__1_14_","__import_glob__1_15_","__import_glob__1_16_","__import_glob__1_17_","__import_glob__1_18_","__import_glob__1_19_","__import_glob__1_20_","__import_glob__1_21_","__import_glob__1_22_","__import_glob__2_0_","__import_glob__2_1_","__import_glob__2_2_","__import_glob__2_3_","__import_glob__2_4_","__import_glob__2_5_","__import_glob__2_6_","__import_glob__2_7_","__import_glob__2_8_","__import_glob__2_9_","__import_glob__2_10_","__import_glob__2_11_","__import_glob__2_12_","__import_glob__2_13_","__import_glob__2_14_","__import_glob__2_15_","__import_glob__2_16_","__import_glob__2_17_","InvalidArgumentError","VELASTACK_WHATSAPP","filesFromGlob","resolveProvider","providerCreates","stripe_customer_default","_page_server_default","_page_default","currency_select_default","currency_svelte_default","buy_button_default","shopify_default","confirm_dialog_default","payment_button_default","payment_dialog_default","stripe_constants_default","stripe_payment_form_default","use_payment_intent_svelte_default","use_stripe_svelte_default","stripe_default","stripe_event_default","sync_stripe_catalog_default","_server_default$3","server_test_default$6","_server_default$2","dispatch_default$1","server_test_default$5","succeeded_default$1","server_test_default$4","customer_fields_default","order_button_default","order_test_default","order_default","setup_button_default","setup_dialog_default","link_stripe_customer_default","sync_stripe_customers_default","_layout_server_default","README_default","_server_default$1","server_test_default$3","_server_default","server_test_default$2","dispatch_default","server_test_default$1","succeeded_default","attached_default","server_test_default","PROVIDERS","META","envEditsFor","providerEnvEdits","provider","supplied","COMPONENTS","PACKAGES","createsRaw","providersRaw","providersAppModeRaw","isUnitTest","path","generate","options","current","label","candidate","isAppMode","creates","unitTests","file","components","a","b","currency_server_test_default","currency_server_default"],"sources":["../../src/patterns/enable/payments/generate.ts"],"sourcesContent":["import type {\n Component,\n Options,\n Package,\n Provider,\n Result,\n} from \"../../../core/types\";\nimport type { EnvEdit } from \"../../../runtime/env\";\nimport {\n providerCreates,\n providerEnvEdits,\n resolveProvider,\n} from \"../../../core/providers\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { VELASTACK_WHATSAPP } from \"../../../core/constants\";\nimport { filesFromGlob } from \"../../../core/util\";\n\n/**\n * The providers in prompt order. Each one's `env` keys are what the CLI asks\n * for, what `generate.runtime.ts` writes to `.env` (in this order, under a\n * `# <Label> credentials` heading) and declares in `src/env.ts`.\n */\nexport const PROVIDERS: Provider[] = [\n {\n id: \"stripe\",\n label: \"Stripe\",\n env: [\n {\n key: \"STRIPE_SECRET_KEY\",\n label: \"Stripe secret key\",\n placeholder: \"sk_...\",\n secret: true,\n required: true,\n description:\n \"Stripe secret key (`sk_...`) the server calls the Stripe API with.\",\n },\n {\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n label: \"Stripe publishable key\",\n placeholder: \"pk_...\",\n public: true,\n required: true,\n description:\n \"Stripe publishable key (`pk_...`) that Stripe.js loads in the browser.\",\n },\n {\n key: \"STRIPE_WEBHOOK_SECRET\",\n label: \"Stripe webhook signing secret\",\n placeholder: \"whsec_...\",\n secret: true,\n required: true,\n description:\n \"Signing secret (`whsec_...`) that `/webhooks/stripe` verifies events with.\",\n },\n ],\n // The webhook route predates the `src/env.ts` declarations, so a project\n // that enabled payments before them is still recognised.\n markers: [\n { env: \"STRIPE_SECRET_KEY\" },\n { path: \"src/routes/webhooks/stripe\" },\n ],\n // Products, prices and customers are synced into PocketBase by workflows.\n requires: { backend: true, workflows: true },\n },\n {\n id: \"shopify\",\n label: \"Shopify\",\n env: [\n {\n key: \"PUBLIC_SHOPIFY_STORE_DOMAIN\",\n label: \"Shopify store domain\",\n placeholder: \"your-store.myshopify.com\",\n public: true,\n required: true,\n description:\n \"The store's `*.myshopify.com` domain the Storefront API is called on.\",\n },\n {\n key: \"PUBLIC_SHOPIFY_STOREFRONT_TOKEN\",\n label: \"Shopify Storefront API public access token\",\n public: true,\n required: true,\n description:\n \"Public Storefront API access token, from the store's Headless channel.\",\n },\n ],\n },\n {\n id: \"whatsapp\",\n label: \"WhatsApp\",\n env: [\n {\n key: \"PUBLIC_WHATSAPP_NUMBER\",\n label: \"WhatsApp number orders are sent to\",\n placeholder: \"+353 1 555 0100\",\n public: true,\n required: true,\n description:\n \"The business's WhatsApp number, with country code, that orders open a chat with.\",\n },\n {\n key: \"PUBLIC_WHATSAPP_ORDER_FORM\",\n label: \"Hosted VelaStack form orders are recorded to\",\n placeholder: \"https://velastack.dev/v1/projects/<project>/forms/order\",\n public: true,\n description:\n \"The hosted VelaStack form each order is recorded to, so it is kept even if the chat is never sent. Empty records nothing.\",\n },\n ],\n },\n];\n\n/** What `resolveProvider` needs; `index.ts` spreads the rest of the metadata. */\nexport const META = { slug: \"enable-payments\", providers: PROVIDERS };\n\n/** The `.env` lines for a provider, under a `# <Label> credentials` heading. */\nexport function envEditsFor(\n provider: Provider,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return providerEnvEdits(provider, `${provider.label} credentials`, supplied);\n}\n\n// `select` is the currency select every provider gets.\nconst COMPONENTS: Record<string, Component[]> = {\n stripe: [\"dialog\", \"input\", \"label\", \"select\"],\n shopify: [\"button\", \"select\"],\n whatsapp: [\"button\", \"dialog\", \"input\", \"label\", \"textarea\", \"select\"],\n};\n\nconst PACKAGES: Record<string, Package[]> = {\n stripe: [\"stripe\", \"@stripe/stripe-js\"],\n shopify: [\"@shopify/storefront-api-client\"],\n whatsapp: [VELASTACK_WHATSAPP],\n};\n\n// Shared by every provider: the currency prices show in, and its select.\nconst createsRaw = import.meta.glob<string>(\"./creates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersRaw = import.meta.glob<string>(\"./providers/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersAppModeRaw = import.meta.glob<string>(\n \"./providers-app-mode/**\",\n { query: \"?raw\", import: \"default\", eager: true },\n);\n\nexport interface GenerateContext {\n /**\n * The project can run unit tests (vitest is installed), so a provider's\n * `*.test.ts` beside its code is written too. Server tests (`server.test.ts`)\n * always are: they run under `vela test:server`, which brings its own runner.\n */\n unitTests?: boolean;\n}\n\nconst isUnitTest = (path: string) =>\n path.endsWith(\".test.ts\") && !path.endsWith(\"server.test.ts\");\n\nexport async function generate(\n options: Options,\n { unitTests = false }: GenerateContext = {},\n) {\n const provider = resolveProvider(META, options);\n\n // A second provider would leave the project with both, and the patterns\n // built on payments could no longer tell which one it uses.\n const current = options.providers?.payments;\n if (current !== undefined && current !== provider.id) {\n const label =\n PROVIDERS.find((candidate) => candidate.id === current)?.label ?? current;\n throw new InvalidArgumentError(\n `This project already uses ${label} payments. To switch to ${provider.label}, ` +\n \"run `vela disable payments` first, then enable payments again.\",\n );\n }\n // Stripe keeps cards and customers for signed-in users; Shopify's checkout\n // owns its customers and WhatsApp has none, so neither has app-mode files.\n const isAppMode = options.features.auth;\n\n const creates = new Map(\n [\n ...Object.values(filesFromGlob(createsRaw, \"./creates/\")),\n ...providerCreates(providersRaw, provider.id),\n ]\n .filter((file) => unitTests || !isUnitTest(file.path))\n .map((file) => [file.path, file]),\n );\n if (isAppMode) {\n for (const file of providerCreates(\n providersAppModeRaw,\n provider.id,\n \"./providers-app-mode/\",\n )) {\n creates.set(file.path, file);\n }\n }\n\n const components = [...(COMPONENTS[provider.id] ?? [])];\n if (isAppMode && provider.id === \"stripe\") components.push(\"alert-dialog\");\n\n return {\n creates: [...creates.values()].sort((a, b) => a.path.localeCompare(b.path)),\n modifies: [],\n deletes: [],\n components,\n packages: PACKAGES[provider.id] ?? [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// node_modules/dedent/dist/dedent.mjs
|
|
2
2
|
function e(e, t) {
|
|
3
3
|
var n = Object.keys(e);
|
|
4
4
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -81,7 +81,6 @@ function s(e, t) {
|
|
|
81
81
|
}
|
|
82
82
|
return e;
|
|
83
83
|
}
|
|
84
|
-
//#endregion
|
|
85
84
|
export { a as t };
|
|
86
85
|
|
|
87
|
-
//# sourceMappingURL=dedent-
|
|
86
|
+
//# sourceMappingURL=dedent-CCUOcPFW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedent-
|
|
1
|
+
{"version":3,"file":"dedent-CCUOcPFW.js","names":["ownKeys","keys","object","symbols","sym","_objectSpread","i","source","target","key","_defineProperty","_toPropertyKey","obj","value","_toPrimitive","arg","input","prim","res","hint","dedent","createDedent","options","newOptions","values","raw","strings","result","next","escapeSpecialCharacters","alignValues","alignValue","lines","mindent","l","m","indent","trimWhitespace","h","hex","braced","unbraced","indentMatch","precedingText"],"sources":["../../node_modules/dedent/dist/dedent.mjs"],"sourcesContent":["function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return typeof key === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (typeof input !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (typeof res !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nconst dedent = createDedent({});\nexport default dedent;\nfunction createDedent(options) {\n dedent.withOptions = newOptions => createDedent(_objectSpread(_objectSpread({}, options), newOptions));\n return dedent;\n function dedent(strings, ...values) {\n const raw = typeof strings === \"string\" ? [strings] : strings.raw;\n const {\n alignValues = false,\n escapeSpecialCharacters = Array.isArray(strings),\n trimWhitespace = true\n } = options;\n\n // first, perform interpolation\n let result = \"\";\n for (let i = 0; i < raw.length; i++) {\n let next = raw[i];\n if (escapeSpecialCharacters) {\n // handle escaped newlines, backticks, and interpolation characters\n next = next.replace(/\\\\\\n[ \\t]*/g, \"\").replace(/\\\\`/g, \"`\").replace(/\\\\\\$/g, \"$\").replace(/\\\\\\{/g, \"{\");\n }\n result += next;\n if (i < values.length) {\n const value = alignValues ? alignValue(values[i], result) : values[i];\n\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n result += value;\n }\n }\n\n // now strip indentation\n const lines = result.split(\"\\n\");\n let mindent = null;\n for (const l of lines) {\n const m = l.match(/^(\\s+)\\S+/);\n if (m) {\n const indent = m[1].length;\n if (!mindent) {\n // this is the first indented line\n mindent = indent;\n } else {\n mindent = Math.min(mindent, indent);\n }\n }\n }\n if (mindent !== null) {\n const m = mindent; // appease TypeScript\n result = lines\n // https://github.com/typescript-eslint/typescript-eslint/issues/7140\n // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with\n .map(l => l[0] === \" \" || l[0] === \"\\t\" ? l.slice(m) : l).join(\"\\n\");\n }\n\n // dedent eats leading and trailing whitespace too\n if (trimWhitespace) {\n result = result.trim();\n }\n\n // Unescape escapes after trimming so sequences like `\\n`, `\\t`,\n // `\\xHH` and `\\u{...}` are preserved (fixes #24)\n if (escapeSpecialCharacters) {\n result = result.replace(/\\\\n/g, \"\\n\").replace(/\\\\t/g, \"\\t\").replace(/\\\\r/g, \"\\r\").replace(/\\\\v/g, \"\\v\").replace(/\\\\b/g, \"\\b\").replace(/\\\\f/g, \"\\f\").replace(/\\\\0/g, \"\\0\").replace(/\\\\x([\\da-fA-F]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\\\u\\{([\\da-fA-F]{1,6})\\}/g, (_, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\\\u([\\da-fA-F]{4})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));\n }\n\n // Workaround for Bun issue with Unicode characters\n // https://github.com/oven-sh/bun/issues/8745\n if (typeof Bun !== \"undefined\") {\n result = result.replace(\n // Matches e.g. \\\\u{1f60a} or \\\\u5F1F\n /\\\\u(?:\\{([\\da-fA-F]{1,6})\\}|([\\da-fA-F]{4}))/g, (_, braced, unbraced) => {\n var _ref;\n const hex = (_ref = braced !== null && braced !== void 0 ? braced : unbraced) !== null && _ref !== void 0 ? _ref : \"\";\n return String.fromCodePoint(parseInt(hex, 16));\n });\n }\n return result;\n }\n}\n\n/**\n * Adjusts the indentation of a multi-line interpolated value to match the current line.\n */\nfunction alignValue(value, precedingText) {\n if (typeof value !== \"string\" || !value.includes(\"\\n\")) {\n return value;\n }\n const currentLine = precedingText.slice(precedingText.lastIndexOf(\"\\n\") + 1);\n const indentMatch = currentLine.match(/^(\\s+)/);\n if (indentMatch) {\n const indent = indentMatch[1];\n return value.replace(/\\n/g, `\\n${indent}`);\n }\n return value;\n}\n"],"ignoreList":[0],"mappings":"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"}
|