@velastack/patterns 0.15.2 → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/chunks/_page-CFeYIl2d.js +5 -0
  2. package/dist/chunks/_page-CFeYIl2d.js.map +1 -0
  3. package/dist/chunks/_page-DkCd_o3E.js +5 -0
  4. package/dist/chunks/{_page-BFUn0CG1.js.map → _page-DkCd_o3E.js.map} +1 -1
  5. package/dist/chunks/{auth-pages-D8n8gfCL.js → auth-pages-mZeR1WIj.js} +2 -2
  6. package/dist/chunks/{auth-pages-D8n8gfCL.js.map → auth-pages-mZeR1WIj.js.map} +1 -1
  7. package/dist/chunks/{currency.server-BkzwY17R.js → currency.server-CHzEhyTx.js} +74 -74
  8. package/dist/chunks/currency.server-CHzEhyTx.js.map +1 -0
  9. package/dist/chunks/dispatch-DSkRrJFe.js +5 -0
  10. package/dist/chunks/{dispatch-BxlKS_5v.js.map → dispatch-DSkRrJFe.js.map} +1 -1
  11. package/dist/chunks/{generate-DI58vuk1.js → generate-DZ2S8KDR.js} +3 -3
  12. package/dist/chunks/{generate-DI58vuk1.js.map → generate-DZ2S8KDR.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-C3IswX7B.js → generate.runtime-373mTxeo.js} +112 -103
  14. package/dist/chunks/generate.runtime-373mTxeo.js.map +1 -0
  15. package/dist/chunks/{generate.runtime-BH6hHygm.js → generate.runtime-BjTZ2Ls-.js} +74 -74
  16. package/dist/chunks/generate.runtime-BjTZ2Ls-.js.map +1 -0
  17. package/dist/chunks/{generate.runtime-B1Y2JrGW.js → generate.runtime-Bn17HK_S.js} +96 -94
  18. package/dist/chunks/generate.runtime-Bn17HK_S.js.map +1 -0
  19. package/dist/chunks/{generate.runtime-JftBoKYS.js → generate.runtime-DIIeK2w9.js} +2 -2
  20. package/dist/chunks/{generate.runtime-JftBoKYS.js.map → generate.runtime-DIIeK2w9.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-CdZ3GzPS.js → generate.runtime-DVZUNxtv.js} +3 -3
  22. package/dist/chunks/{generate.runtime-CdZ3GzPS.js.map → generate.runtime-DVZUNxtv.js.map} +1 -1
  23. package/dist/chunks/{generate.runtime-DdY44Ulv.js → generate.runtime-DXqBku2y.js} +2 -2
  24. package/dist/chunks/{generate.runtime-DdY44Ulv.js.map → generate.runtime-DXqBku2y.js.map} +1 -1
  25. package/dist/chunks/{generate.runtime-D7KYlnvb.js → generate.runtime-DgKiFemb.js} +2 -2
  26. package/dist/chunks/{generate.runtime-D7KYlnvb.js.map → generate.runtime-DgKiFemb.js.map} +1 -1
  27. package/dist/chunks/{generate.runtime-Bs77Oc8P.js → generate.runtime-DmbDEjMA.js} +2 -2
  28. package/dist/chunks/{generate.runtime-Bs77Oc8P.js.map → generate.runtime-DmbDEjMA.js.map} +1 -1
  29. package/dist/chunks/{generate.runtime-DlAJQ5Js.js → generate.runtime-VZIxJWlr.js} +69 -61
  30. package/dist/chunks/generate.runtime-VZIxJWlr.js.map +1 -0
  31. package/dist/chunks/{generate.runtime-DjEj-n6m.js → generate.runtime-sey-wxXB.js} +2 -2
  32. package/dist/chunks/{generate.runtime-DjEj-n6m.js.map → generate.runtime-sey-wxXB.js.map} +1 -1
  33. package/dist/chunks/{unmodify-load-CdWXJ_Ac.js → unmodify-load-DWixBz7y.js} +17 -4
  34. package/dist/chunks/unmodify-load-DWixBz7y.js.map +1 -0
  35. package/dist/index.js +1852 -1842
  36. package/dist/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunks/_page-BFUn0CG1.js +0 -5
  39. package/dist/chunks/_page-Bt37d4uo.js +0 -5
  40. package/dist/chunks/_page-Bt37d4uo.js.map +0 -1
  41. package/dist/chunks/currency.server-BkzwY17R.js.map +0 -1
  42. package/dist/chunks/dispatch-BxlKS_5v.js +0 -5
  43. package/dist/chunks/generate.runtime-B1Y2JrGW.js.map +0 -1
  44. package/dist/chunks/generate.runtime-BH6hHygm.js.map +0 -1
  45. package/dist/chunks/generate.runtime-C3IswX7B.js.map +0 -1
  46. package/dist/chunks/generate.runtime-DlAJQ5Js.js.map +0 -1
  47. package/dist/chunks/unmodify-load-CdWXJ_Ac.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-373mTxeo.js","names":["FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","stripeCustomerHelper","_layout_server_default","_layout_default","nav_user_default","_page_server_default","app_sidebar_default","dispatch_default","InvalidArgumentError","getLogger","keepMissing","modifyOutcomeToFile","dedent","withInMemoryScript","ensureBlankLineAfterImports","formatLikeSource","ensureImports","SvelteFile","modifyNavUser","stripe_customer_default","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$5","SUBSCRIPTION_CASES_SNIPPET","modifyWebhookServer","filePath","original","addedCases","sf","switchStmt","SyntaxKind","stmt","clauses","defaultClause","c","prefix","last","source","LOAD_LINE","NOT_FOUND_HINT$4","failureHint","helper","helperFrom","clean","template","start","end","findLoad","varDecl","init","fn","modifyAppLayoutServer","Project","QuoteKind","load","body","block","params","first","pattern","el","rest","binding","hasLocals","userIndex","s","d","statements","ret","returned","text","writer","FAILURE_HINT$1","NOT_FOUND_HINT$3","modifyAppLayoutSvelte","file","SUBSCRIPTION_TYPE","FAILURE_HINT","NOT_FOUND_HINT$2","updateScript","wasAdded","out","decl","nameNode","elements","typeNode","intersection","member","lit","propTexts","p","t","elementTexts","insertIdx","modifyAppSidebar","scriptChanged","src","templateChanged","modifyByTemplate","notFoundHint","current","idempotencyMarker","stripped","NOT_FOUND_HINT$1","modifyBillingPageServer","NOT_FOUND_HINT","modifyBillingPageSvelte","STRIPE_CUSTOMER_HELPER","BILLING_PAGE","assertPaymentsAppMode","root","previewRaw","_page_default","content","relativePath","generate","logger","options","modifies","pushResult","webhookServerPath","appLayoutServerPath","appLayoutSveltePath","appSidebarPath","navUserPath","billingPageServerPath","billingPageSveltePath"],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/enable/subscriptions/modifies/modify-by-template.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/enable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wire the subscription event handlers into src/routes/webhooks/stripe/handlers/dispatch.ts:\n\n Add imports:\n import { handleSubscriptionCreated } from \"./subscription/created\";\n import { handleSubscriptionUpdated } from \"./subscription/updated\";\n import { handleSubscriptionDeleted } from \"./subscription/deleted\";\n\n Add switch cases inside the event.type switch:\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nconst NOT_FOUND_HINT =\n \"Enable payments first — src/routes/webhooks/stripe/handlers/dispatch.ts is created by enable-payments.\";\n\nconst SUBSCRIPTION_CASES_SNIPPET = dedent`\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nexport function modifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n let addedCases = false;\n const { source } = withInMemoryScript(original, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"handleSubscriptionCreated\"],\n moduleSpecifier: \"./subscription/created\",\n },\n {\n namedImports: [\"handleSubscriptionUpdated\"],\n moduleSpecifier: \"./subscription/updated\",\n },\n {\n namedImports: [\"handleSubscriptionDeleted\"],\n moduleSpecifier: \"./subscription/deleted\",\n },\n ]);\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n const clauses = caseBlock.getClauses();\n const defaultClause = clauses.find(\n (c) => c.getKind() === SyntaxKind.DefaultClause,\n );\n\n // Prepend subscription cases in front of the default clause, or append\n // before the closing brace of the case block if there's no default.\n const prefix = `${SUBSCRIPTION_CASES_SNIPPET}\\n\\n`;\n if (defaultClause) {\n defaultClause.replaceWithText(prefix + defaultClause.getText());\n } else if (clauses.length > 0) {\n const last = clauses[clauses.length - 1];\n last.replaceWithText(\n last.getText() + `\\n\\n${SUBSCRIPTION_CASES_SNIPPET}`,\n );\n } else {\n return;\n }\n\n formatLikeSource(sf);\n addedCases = true;\n });\n\n if (!addedCases) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureBlankLineAfterImports,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst LOAD_LINE =\n \"const subscription = await loadActiveSubscription(locals, user.id);\";\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\",\n \"Enable auth first — the (app) layout is provided by the velastack-auth baseline.\",\n].join(\"\\n\");\n\nconst failureHint = (helper: string) =>\n [\n \"Could not find the user and the returned object in the (app) layout load.\",\n \"Add the active subscription to it by hand:\",\n \"\",\n helper,\n \"\",\n \"// In load, once `user` is set:\",\n LOAD_LINE,\n \"// ...and return it with the rest:\",\n \"return { ..., subscription };\",\n ].join(\"\\n\");\n\n/**\n * The `loadActiveSubscription` helper, taken from the preview template so the\n * docs and what gets written stay the same.\n */\nfunction helperFrom(template: string): string {\n const clean = template.replace(\n /^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm,\n \"\",\n );\n const start = clean.indexOf(\"async function loadActiveSubscription\");\n const end = clean.indexOf(\"\\n}\\n\", start);\n if (start === -1 || end === -1) {\n throw new Error(\"No loadActiveSubscription in the layout template\");\n }\n return clean.slice(start, end + 2);\n}\n\nfunction findLoad(sf: SourceFile) {\n const varDecl = sf.getVariableDeclaration(\"load\");\n if (varDecl?.getVariableStatement()?.hasExportKeyword()) {\n const init = varDecl.getInitializer();\n const fn =\n varDecl.getInitializerIfKind(SyntaxKind.ArrowFunction) ??\n init?.getFirstDescendantByKind(SyntaxKind.ArrowFunction) ??\n init?.getFirstDescendantByKind(SyntaxKind.FunctionExpression);\n if (fn) return { fn, statement: varDecl.getVariableStatement()! };\n }\n const fn = sf.getFunction(\"load\");\n return fn?.isExported() ? { fn, statement: fn } : undefined;\n}\n\n/**\n * Adds the active subscription to the (app) layout's data: the\n * `loadActiveSubscription` helper, a call to it in `load`, and `subscription`\n * in what `load` returns. Edits the file rather than replacing it, so what\n * other patterns put in the load (teams' `team`/`teams`, say) stays.\n */\nexport function modifyAppLayoutServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"loadActiveSubscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const helper = helperFrom(template);\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sf = project.addSourceFileAtPath(filePath);\n const load = findLoad(sf);\n const body = load?.fn.getBody();\n if (!load || !body || body.getKind() !== SyntaxKind.Block) {\n return { status: \"failed\", message: failureHint(helper) };\n }\n const block = body.asKindOrThrow(SyntaxKind.Block);\n\n // The call needs `locals` and `user`, and goes before the return. The\n // stock load takes no argument (it gets its user from `requireUser()`), so\n // `locals` is added to it; one that names its event some other way is left\n // for the hint.\n const params = load.fn.getParameters();\n if (params.length === 0) {\n load.fn.insertParameter(0, { name: \"{ locals }\" });\n } else {\n const first = params[0]!;\n const pattern = first.getNameNode().asKind(SyntaxKind.ObjectBindingPattern);\n if (\n pattern &&\n !pattern.getElements().some((el) => el.getName() === \"locals\")\n ) {\n const rest = pattern.getElements().map((el) => el.getText());\n first.set({ name: `{ ${[\"locals\", ...rest].join(\", \")} }` });\n }\n }\n const binding = load.fn.getParameters()[0]?.getNameNode();\n const hasLocals =\n binding?.getKind() === SyntaxKind.ObjectBindingPattern &&\n binding\n .asKindOrThrow(SyntaxKind.ObjectBindingPattern)\n .getElements()\n .some((el) => el.getName() === \"locals\");\n const userIndex = block.getStatements().findIndex(\n (s) =>\n s.getKind() === SyntaxKind.VariableStatement &&\n s\n .asKindOrThrow(SyntaxKind.VariableStatement)\n .getDeclarations()\n .some((d) => d.getName() === \"user\"),\n );\n const statements = block.getStatements();\n const ret = [...statements]\n .reverse()\n .find((s) => s.getKind() === SyntaxKind.ReturnStatement)\n ?.asKind(SyntaxKind.ReturnStatement);\n const returned = ret\n ?.getExpression()\n ?.asKind(SyntaxKind.ObjectLiteralExpression);\n if (!hasLocals || userIndex === -1 || !ret || !returned) {\n return { status: \"failed\", message: failureHint(helper) };\n }\n\n block.insertStatements(statements.indexOf(ret), LOAD_LINE);\n if (!returned.getProperty(\"subscription\")) {\n const text = returned.getText();\n if (text.includes(\"\\n\")) {\n returned.addShorthandPropertyAssignment({ name: \"subscription\" });\n } else {\n // Kept on one line, as written.\n returned.replaceWithText(text.replace(/\\s*\\}$/, \", subscription }\"));\n }\n }\n if (!load.fn.isAsync()) load.fn.setIsAsync(true);\n sf.insertStatements(sf.getStatements().indexOf(load.statement), (writer) =>\n writer.write(helper).blankLine(),\n );\n\n formatLikeSource(sf);\n // The helper goes in above `load`, which in the stock file is right under\n // the import.\n ensureBlankLineAfterImports(sf);\n sf.saveSync();\n return { status: \"success\", changed: sf.getFullText() !== original };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\",\n \"\",\n \"<AppSidebar user={data.user} subscription={data.subscription} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const appended = file.appendToAttributes(\n \"AppSidebar\",\n \" subscription={data.subscription}\",\n );\n if (!appended) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\n\nconst FAILURE_HINT = [\n \"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:\",\n \"\",\n \"1. Add `subscription = null` to the destructured $props() call.\",\n `2. Add \\`subscription?: ${SUBSCRIPTION_TYPE}\\` to the props type.`,\n \"3. Pass `{subscription}` to <NavUser>.\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/lib/components/app-sidebar.svelte before enabling subscriptions.\",\n].join(\"\\n\");\n\nfunction updateScript(source: string): {\n source: string;\n wasAdded: boolean;\n} {\n let wasAdded = false;\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n if (elements.some((e) => e.getName() === \"subscription\")) {\n // Already has subscription prop — no-op.\n return;\n }\n\n // Insert subscription?: ... into the props type literal if present.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^\\s*subscription\\??\\s*:/.test(t))) {\n continue;\n }\n propTexts.push(`subscription?: ${SUBSCRIPTION_TYPE}`);\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Insert `subscription = null` before the first rest/default-only element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elementTexts.length;\n elementTexts.splice(insertIdx, 0, \"subscription = null\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n wasAdded = true;\n }\n formatLikeSource(sf);\n });\n return { source: out, wasAdded };\n}\n\nexport function modifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (\n original.includes(\"subscription?: {\") ||\n original.includes(\"subscription={subscription}\") ||\n original.includes(\"{subscription}\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n if (!file.hasElement(\"NavUser\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const scriptChanged = file.modifyScript((src) => updateScript(src).source);\n\n const templateChanged = !file.hasAttribute(\"NavUser\", \"subscription\")\n ? file.appendToAttributes(\"NavUser\", \" {subscription}\")\n : false;\n\n if (!scriptChanged && !templateChanged) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Overwrites a file with the given template content, guarded by an idempotency\n * marker: if the current file already contains the marker, the modify is a\n * no-op. Used for complex rewrites where surgical AST changes aren't worth it\n * (e.g. pages that are largely replaced).\n *\n * Strips leading `// [!code highlight:N]` and `<!-- [!code highlight:N] -->`\n * lines so the same content can be shared with preview-modifies, which uses\n * those comments for documentation highlighting.\n */\nexport function modifyByTemplate(\n filePath: string,\n template: string,\n idempotencyMarker: string,\n notFoundHint: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: notFoundHint };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(idempotencyMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.server.ts is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"selectPlan\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.svelte is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageSvelte(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"availablePlans\", NOT_FOUND_HINT);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { keepMissing, modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { modifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { modifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\nimport stripeCustomerHelper from \"../payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts?raw\";\n\n// The billing page imports this payments helper, which apps that enabled\n// payments before it existed do not have yet.\nconst STRIPE_CUSTOMER_HELPER = \"src/lib/server/stripe-customer.ts\";\n\n// enable-payments writes the billing page (and the stripe_customers collection\n// subscriptions relate to) only when auth is already on.\nconst BILLING_PAGE = \"src/routes/(app)/billing/+page.server.ts\";\n\n/**\n * Refuses a project whose payments were enabled before auth. Every `requires`\n * flag passes there (auth and payments are both on), yet the billing page and\n * `stripe_customers` don't exist, so this runs before any collection is made.\n */\nexport function assertPaymentsAppMode(root: string): void {\n if (fs.existsSync(path.join(root, BILLING_PAGE))) return;\n throw new InvalidArgumentError(\n [\n \"Subscriptions need payments set up with auth on: they add plans to the billing page\",\n `(${BILLING_PAGE}) and link to the stripe_customers collection, which enable-payments`,\n \"creates only when auth is already enabled. This project enabled payments before auth.\",\n \"\",\n \"Re-enable payments now that auth is on: `vela disable payments`, then `vela enable payments`.\",\n \"disable-payments drops the catalog collections, which the sync workflow refills from Stripe.\",\n ].join(\"\\n\"),\n );\n}\n\n// Share the final-state files between preview (rendered as-is) and runtime\n// (used as overwrite templates for modifies that amount to full rewrites).\nconst previewRaw = import.meta.glob<string>(\"./preview-modifies/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nfunction template(relativePath: string): string {\n const key = `./preview-modifies/${relativePath}`;\n const content = previewRaw[key];\n if (content === undefined) {\n throw new Error(\n `Missing template for ${relativePath} in subscriptions preview-modifies`,\n );\n }\n return content;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n modifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n modifyAppLayoutServer(\n appLayoutServerPath,\n template(\"src/routes/(app)/+layout.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n modifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Modifying app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n logger.info(\"Modifying billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n modifyBillingPageServer(\n billingPageServerPath,\n template(\"src/routes/(app)/billing/+page.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n modifyBillingPageSvelte(\n billingPageSveltePath,\n template(\"src/routes/(app)/billing/+page.svelte\"),\n ),\n ),\n );\n\n const creates = keepMissing(\n [\n {\n path: STRIPE_CUSTOMER_HELPER,\n language: \"ts\",\n content: stripeCustomerHelper,\n status: \"success\",\n },\n ],\n options.root,\n );\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,IAAMA,IAAe,CAAM;;;;;;;;;;;;;;;;;;GAoBrBC,IACJ,0GAEIoC,IAA6B,CAAM;;;;;;;;;;;;;AAczC,SAAgBC,EAAoB,GAAiC;CACnE,IAAI,CAACL,EAAG,WAAWM,CAAQ,GACzB,OAAO;EAAE,QAAQ;EAAa,SAAStC;CAAe;CAGxD,IAAMuC,IAAWP,EAAG,aAAaM,GAAU,MAAM;CACjD,IAAIC,EAAS,SAAS,2BAA2B,GAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAIC,IAAa,IACX,EAAE,cAAWf,EAAmBc,IAAW,MAAO;EACtD,EAAcE,GAAI;GAChB;IACE,cAAc,CAAC,2BAA2B;IAC1C,iBAAiB;GACnB;GACA;IACE,cAAc,CAAC,2BAA2B;IAC1C,iBAAiB;GACnB;GACA;IACE,cAAc,CAAC,2BAA2B;IAC1C,iBAAiB;GACnB;EACF,CAAC;EAED,IAAMC,IAAaD,EAChB,qBAAqBE,EAAW,eAAe,CAAC,CAChD,MAAM,MAASC,EAAK,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,YAAY,CAAC;EACvE,IAAI,CAACF,GAAY;EAGjB,IAAMG,IADYH,EAAW,aACb,CAAA,CAAU,WAAW,GAC/BI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C,CACtE,GAEAP,EAAO,KAAK,2BAA2B;CACvC,IAAMQ,IAAcxG,EAAK,KACvBiG,EAAQ,MACR,OACA,OACA,cACA,iBACF;CAGA,AAFAE,EAAW7G,EAAoBkH,GAAa3G,EAAc2G,CAAW,CAAC,CAAC,GAEvER,EAAO,KAAK,mCAAmC;CAC/C,IAAMS,IAAwBzG,EAAK,KACjCiG,EAAQ,MACR,OACA,UACA,SACA,WACA,iBACF;CAWA,AAVAE,EACE7G,EACEmH,GACArB,EACEqB,GACAjF,EAAS,0CAA0C,CACrD,CACF,CACF,GAEAwE,EAAO,KAAK,gCAAgC;CAC5C,IAAMU,IAAwB1G,EAAK,KACjCiG,EAAQ,MACR,OACA,UACA,SACA,WACA,cACF;CAuBA,OAtBAE,EACE7G,EACEoH,GACApB,EACEoB,GACAlF,EAAS,uCAAuC,CAClD,CACF,CACF,GAcO;EACL,SAbcnC,EACd,CACE;GACE,MAAMkG;GACN,UAAU;GACV,SAAS3G;GACT,QAAQ;EACV,CACF,GACAqH,EAAQ,IAIR;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,57 +1,57 @@
1
1
  import { n as e } from "./logger-t1HxmpG2.js";
2
2
  import { r as t } from "./modify-file-BOEKlIDw.js";
3
3
  import { t as n } from "./shared-CSwGWMcN.js";
4
- import { _ as r, h as i, o as a, u as o } from "./ts-morph-helpers-B4KZXP44.js";
5
- import { t as s } from "./svelte-file-DfplF3BU.js";
6
- import { t as c } from "./unmodify-load-CdWXJ_Ac.js";
7
- import { r as l, t as u } from "./modify-nav-user--7OwY9fI.js";
8
- import { n as d, t as f } from "./_page-Bt37d4uo.js";
9
- import p from "node:fs";
10
- import m from "node:path";
11
- import { Project as h, QuoteKind as g, SyntaxKind as _ } from "ts-morph";
4
+ import { _ as r, h as i, n as a, o, u as s } from "./ts-morph-helpers-B4KZXP44.js";
5
+ import { t as c } from "./svelte-file-DfplF3BU.js";
6
+ import { t as l } from "./unmodify-load-DWixBz7y.js";
7
+ import { r as u, t as d } from "./modify-nav-user--7OwY9fI.js";
8
+ import { n as f, t as p } from "./_page-CFeYIl2d.js";
9
+ import m from "node:fs";
10
+ import h from "node:path";
11
+ import { Project as g, QuoteKind as _, SyntaxKind as v } from "ts-morph";
12
12
  // src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts
13
- var v = /* @__PURE__ */ new Set([
13
+ var y = /* @__PURE__ */ new Set([
14
14
  "customer.subscription.created",
15
15
  "customer.subscription.updated",
16
16
  "customer.subscription.deleted"
17
17
  ]);
18
- function y(e) {
19
- if (!p.existsSync(e)) return {
18
+ function b(e) {
19
+ if (!m.existsSync(e)) return {
20
20
  status: "success",
21
21
  changed: !1
22
22
  };
23
- let t = p.readFileSync(e, "utf8");
23
+ let t = m.readFileSync(e, "utf8");
24
24
  if (!t.includes("handleSubscriptionCreated")) return {
25
25
  status: "success",
26
26
  changed: !1
27
27
  };
28
28
  let { source: n } = r(t, (e) => {
29
- o(e, "./subscription/created"), o(e, "./subscription/updated"), o(e, "./subscription/deleted");
30
- let t = e.getDescendantsOfKind(_.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
29
+ s(e, "./subscription/created"), s(e, "./subscription/updated"), s(e, "./subscription/deleted");
30
+ let t = e.getDescendantsOfKind(v.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
31
31
  if (!t) return;
32
32
  let n = t.getCaseBlock().getClauses().filter((e) => {
33
- if (e.getKind() !== _.CaseClause) return !1;
34
- let t = e.asKindOrThrow(_.CaseClause).getExpression(), n = t.asKind(_.StringLiteral) ?? t.asKind(_.NoSubstitutionTemplateLiteral);
35
- return n ? v.has(n.getLiteralValue()) : !1;
36
- }).map((e) => e.asKindOrThrow(_.CaseClause));
33
+ if (e.getKind() !== v.CaseClause) return !1;
34
+ let t = e.asKindOrThrow(v.CaseClause).getExpression(), n = t.asKind(v.StringLiteral) ?? t.asKind(v.NoSubstitutionTemplateLiteral);
35
+ return n ? y.has(n.getLiteralValue()) : !1;
36
+ }).map((e) => e.asKindOrThrow(v.CaseClause));
37
37
  for (let e of n.reverse()) e.remove();
38
- a(e);
38
+ o(e);
39
39
  }), i = n.replace(/(break;)\n(\s*default:)/, "$1\n\n$2");
40
40
  return i === t ? {
41
41
  status: "success",
42
42
  changed: !1
43
- } : (p.writeFileSync(e, i, "utf8"), {
43
+ } : (m.writeFileSync(e, i, "utf8"), {
44
44
  status: "success",
45
45
  changed: !0
46
46
  });
47
47
  }
48
48
  // src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts
49
- function b(e) {
50
- if (!p.existsSync(e)) return {
49
+ function x(e) {
50
+ if (!m.existsSync(e)) return {
51
51
  status: "success",
52
52
  changed: !1
53
53
  };
54
- let t = s.fromPath(e);
54
+ let t = c.fromPath(e);
55
55
  return !t.hasElement("AppSidebar") || !t.hasAttribute("AppSidebar", "subscription") || !t.removeAttribute("AppSidebar", "subscription") ? {
56
56
  status: "success",
57
57
  changed: !1
@@ -61,19 +61,19 @@ function b(e) {
61
61
  });
62
62
  }
63
63
  // src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts
64
- function x(e) {
64
+ function S(e) {
65
65
  let { source: t } = r(e, (e) => {
66
66
  for (let t of e.getVariableDeclarations()) {
67
67
  let e = t.getInitializer();
68
68
  if (!e || e.getText() !== "$props()") continue;
69
69
  let n = t.getNameNode();
70
- if (n.getKind() !== _.ObjectBindingPattern) continue;
71
- let r = n.asKindOrThrow(_.ObjectBindingPattern), i = r.getElements(), a = i.some((e) => e.getName() === "subscription"), o = t.getTypeNode();
72
- if (o?.getKind() === _.IntersectionType) {
73
- let e = o.asKindOrThrow(_.IntersectionType);
70
+ if (n.getKind() !== v.ObjectBindingPattern) continue;
71
+ let r = n.asKindOrThrow(v.ObjectBindingPattern), i = r.getElements(), a = i.some((e) => e.getName() === "subscription"), o = t.getTypeNode();
72
+ if (o?.getKind() === v.IntersectionType) {
73
+ let e = o.asKindOrThrow(v.IntersectionType);
74
74
  for (let t of e.getTypeNodes()) {
75
- if (t.getKind() !== _.TypeLiteral) continue;
76
- let e = t.asKindOrThrow(_.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, "")).filter((e) => !/^\s*subscription\??\s*:/.test(e));
75
+ if (t.getKind() !== v.TypeLiteral) continue;
76
+ let e = t.asKindOrThrow(v.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, "")).filter((e) => !/^\s*subscription\??\s*:/.test(e));
77
77
  e.replaceWithText(n.length ? `{ ${n.join("; ")}; }` : "{}");
78
78
  break;
79
79
  }
@@ -83,76 +83,76 @@ function x(e) {
83
83
  r.replaceWithText(`{ ${e.join(", ")} }`);
84
84
  }
85
85
  }
86
- a(e);
86
+ o(e);
87
87
  });
88
88
  return t;
89
89
  }
90
- function S(e) {
91
- if (!p.existsSync(e)) return {
90
+ function C(e) {
91
+ if (!m.existsSync(e)) return {
92
92
  status: "success",
93
93
  changed: !1
94
94
  };
95
- let t = p.readFileSync(e, "utf8"), n = /subscription\??\s*:\s*\{/.test(t), r = /\bsubscription\s*=\s*null\b/.test(t), i = new s(t), a = i.hasElement("NavUser") && i.hasAttribute("NavUser", "subscription");
95
+ let t = m.readFileSync(e, "utf8"), n = /subscription\??\s*:\s*\{/.test(t), r = /\bsubscription\s*=\s*null\b/.test(t), i = new c(t), a = i.hasElement("NavUser") && i.hasAttribute("NavUser", "subscription");
96
96
  return !n && !r && !a ? {
97
97
  status: "success",
98
98
  changed: !1
99
- } : ((n || r) && i.modifyScript(x), a && i.removeAttribute("NavUser", "subscription"), i.writeTo(e), {
99
+ } : ((n || r) && i.modifyScript(S), a && i.removeAttribute("NavUser", "subscription"), i.writeTo(e), {
100
100
  status: "success",
101
101
  changed: i.hasChanged()
102
102
  });
103
103
  }
104
104
  // src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts
105
- function C(e) {
106
- if (!p.existsSync(e)) return {
105
+ function w(e) {
106
+ if (!m.existsSync(e)) return {
107
107
  status: "success",
108
108
  changed: !1
109
109
  };
110
- let t = p.readFileSync(e, "utf8");
110
+ let t = m.readFileSync(e, "utf8");
111
111
  if (!t.includes("loadActiveSubscription")) return {
112
112
  status: "success",
113
113
  changed: !1
114
114
  };
115
- let n = c(e, {
115
+ let n = l(e, {
116
116
  variables: ["subscription"],
117
117
  dependsKeys: [],
118
118
  returnProps: ["subscription"]
119
119
  });
120
120
  if (n.status !== "success") return n;
121
- let r = new h({ manipulationSettings: { quoteKind: g.Single } }).addSourceFileAtPath(e);
122
- return i(r, "loadActiveSubscription"), a(r), r.saveSync(), {
121
+ let r = new g({ manipulationSettings: { quoteKind: _.Single } }).addSourceFileAtPath(e);
122
+ return i(r, "loadActiveSubscription"), o(r), a(r), r.saveSync(), {
123
123
  status: "success",
124
- changed: p.readFileSync(e, "utf8") !== t
124
+ changed: m.readFileSync(e, "utf8") !== t
125
125
  };
126
126
  }
127
127
  // src/patterns/disable/subscriptions/modifies/modify-nav-user.ts
128
- function w(e) {
129
- if (!p.existsSync(e)) return {
128
+ function T(e) {
129
+ if (!m.existsSync(e)) return {
130
130
  status: "success",
131
131
  changed: !1
132
132
  };
133
- let t = p.readFileSync(e, "utf8");
133
+ let t = m.readFileSync(e, "utf8");
134
134
  if (!t.includes("planLabel")) return {
135
135
  status: "success",
136
136
  changed: !1
137
137
  };
138
- let n = new s(t);
138
+ let n = new c(t);
139
139
  n.modifyScript((e) => r(e.replace(/\n[ \t]*\n[ \t]*const planLabel = \$derived\([^\n]*\);/, ""), (e) => {
140
- let t = l(e)?.getDeclarations()[0], n = t?.getNameNode().asKind(_.ObjectBindingPattern), r = n?.getElements().filter((e) => e.getName() !== "subscription").map((e) => e.getText());
141
- n && r && n.replaceWithText(u(n.getText(), r)), t?.getTypeNode()?.asKind(_.TypeLiteral)?.getProperty("subscription")?.remove();
140
+ let t = u(e)?.getDeclarations()[0], n = t?.getNameNode().asKind(v.ObjectBindingPattern), r = n?.getElements().filter((e) => e.getName() !== "subscription").map((e) => e.getText());
141
+ n && r && n.replaceWithText(d(n.getText(), r)), t?.getTypeNode()?.asKind(v.TypeLiteral)?.getProperty("subscription")?.remove();
142
142
  }).source);
143
143
  let i = n.toString().replace(/\n[ \t]*<span class="[^"]*">\s*\{planLabel\}\s*<\/span>/g, "");
144
- return p.writeFileSync(e, i, "utf8"), {
144
+ return m.writeFileSync(e, i, "utf8"), {
145
145
  status: "success",
146
146
  changed: i !== t
147
147
  };
148
148
  }
149
149
  // src/patterns/disable/subscriptions/modifies/revert-by-template.ts
150
- function T(e, t, n) {
151
- if (!p.existsSync(e)) return {
150
+ function E(e, t, n) {
151
+ if (!m.existsSync(e)) return {
152
152
  status: "success",
153
153
  changed: !1
154
154
  };
155
- let r = p.readFileSync(e, "utf8");
155
+ let r = m.readFileSync(e, "utf8");
156
156
  if (!r.includes(n)) return {
157
157
  status: "success",
158
158
  changed: !1
@@ -161,39 +161,39 @@ function T(e, t, n) {
161
161
  return r === i ? {
162
162
  status: "success",
163
163
  changed: !1
164
- } : (p.writeFileSync(e, i, "utf8"), {
164
+ } : (m.writeFileSync(e, i, "utf8"), {
165
165
  status: "success",
166
166
  changed: !0
167
167
  });
168
168
  }
169
169
  // src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts
170
- function E(e, t) {
171
- return T(e, t, "selectPlan");
170
+ function D(e, t) {
171
+ return E(e, t, "selectPlan");
172
172
  }
173
173
  // src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts
174
- function D(e, t) {
175
- return T(e, t, "availablePlans");
174
+ function O(e, t) {
175
+ return E(e, t, "availablePlans");
176
176
  }
177
177
  // src/patterns/disable/subscriptions/generate.runtime.ts
178
- async function O(r) {
178
+ async function k(r) {
179
179
  let i = e(r), a = [], o = (e) => {
180
180
  e && a.push(e);
181
181
  };
182
182
  i.info("Reverting webhooks/stripe/handlers/dispatch.ts");
183
- let s = m.join(r.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
184
- o(t(s, y(s))), i.info("Reverting (app)/+layout.server.ts");
185
- let c = m.join(r.root, "src", "routes", "(app)", "+layout.server.ts");
186
- o(t(c, C(c))), i.info("Reverting (app)/+layout.svelte");
187
- let l = m.join(r.root, "src", "routes", "(app)", "+layout.svelte");
188
- o(t(l, b(l))), i.info("Reverting app-sidebar.svelte");
189
- let u = m.join(r.root, "src", "lib", "components", "app-sidebar.svelte");
190
- o(t(u, S(u))), i.info("Reverting nav-user.svelte");
191
- let p = m.join(r.root, "src", "lib", "components", "nav-user.svelte");
192
- o(t(p, w(p))), i.info("Reverting billing/+page.server.ts");
193
- let h = m.join(r.root, "src", "routes", "(app)", "billing", "+page.server.ts");
194
- o(t(h, E(h, d))), i.info("Reverting billing/+page.svelte");
195
- let g = m.join(r.root, "src", "routes", "(app)", "billing", "+page.svelte");
196
- return o(t(g, D(g, f))), {
183
+ let s = h.join(r.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
184
+ o(t(s, b(s))), i.info("Reverting (app)/+layout.server.ts");
185
+ let c = h.join(r.root, "src", "routes", "(app)", "+layout.server.ts");
186
+ o(t(c, w(c))), i.info("Reverting (app)/+layout.svelte");
187
+ let l = h.join(r.root, "src", "routes", "(app)", "+layout.svelte");
188
+ o(t(l, x(l))), i.info("Reverting app-sidebar.svelte");
189
+ let u = h.join(r.root, "src", "lib", "components", "app-sidebar.svelte");
190
+ o(t(u, C(u))), i.info("Reverting nav-user.svelte");
191
+ let d = h.join(r.root, "src", "lib", "components", "nav-user.svelte");
192
+ o(t(d, T(d))), i.info("Reverting billing/+page.server.ts");
193
+ let m = h.join(r.root, "src", "routes", "(app)", "billing", "+page.server.ts");
194
+ o(t(m, D(m, f))), i.info("Reverting billing/+page.svelte");
195
+ let g = h.join(r.root, "src", "routes", "(app)", "billing", "+page.svelte");
196
+ return o(t(g, O(g, p))), {
197
197
  creates: [],
198
198
  modifies: a,
199
199
  deletes: [],
@@ -204,6 +204,6 @@ async function O(r) {
204
204
  collectionDrops: await n(["stripe_subscriptions"], r)
205
205
  };
206
206
  }
207
- export { O as generate };
207
+ export { k as generate };
208
208
 
209
- //# sourceMappingURL=generate.runtime-BH6hHygm.js.map
209
+ //# sourceMappingURL=generate.runtime-BjTZ2Ls-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-BjTZ2Ls-.js","names":["paymentsBillingPageServerTemplate","paymentsBillingPageSvelteTemplate","getLogger","modifyOutcomeToFile","planDropsForCollections","withInMemoryScript","removeTopLevelStatementByIdentifier","ensureBlankLineAfterImports","removeImportByModuleSpecifier","SvelteFile","removeFromLoad","propsStatement","bindingText","_page_server_default","_page_default","fs","path","SUBSCRIPTION_CASE_VALUES","unmodifyWebhookServer","filePath","original","sf","switchStmt","SyntaxKind","stmt","toRemove","clause","expr","literal","c","spaced","source","unmodifyAppLayoutSvelte","file","updateScript","out","decl","init","nameNode","pattern","elements","hasSub","typeNode","intersection","member","lit","propTexts","p","t","remaining","unmodifyAppSidebar","hasSubPropType","hasSubProp","hasNavUserSubAttr","unmodifyAppLayoutServer","fromLoad","Project","QuoteKind","formatLikeSource","unmodifyNavUser","content","binding","kept","revertByTemplate","current","enabledMarker","stripped","template","unmodifyBillingPageServer","paymentsBillingPageServerTemplate","unmodifyBillingPageSvelte","paymentsBillingPageSvelteTemplate","generate","logger","options","modifies","pushResult","webhookServerPath","appLayoutServerPath","appLayoutSveltePath","appSidebarPath","navUserPath","billingPageServerPath","billingPageSveltePath"],"sources":["../../src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/disable/subscriptions/modifies/revert-by-template.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/disable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst SUBSCRIPTION_CASE_VALUES = new Set([\n \"customer.subscription.created\",\n \"customer.subscription.updated\",\n \"customer.subscription.deleted\",\n]);\n\nexport function unmodifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n const { source } = withInMemoryScript(original, (sf) => {\n removeImportByModuleSpecifier(sf, \"./subscription/created\");\n removeImportByModuleSpecifier(sf, \"./subscription/updated\");\n removeImportByModuleSpecifier(sf, \"./subscription/deleted\");\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n // Collect matching case clauses first — removing invalidates node refs.\n const toRemove = caseBlock\n .getClauses()\n .filter((clause) => {\n if (clause.getKind() !== SyntaxKind.CaseClause) return false;\n const caseClause = clause.asKindOrThrow(SyntaxKind.CaseClause);\n const expr = caseClause.getExpression();\n const literal =\n expr.asKind(SyntaxKind.StringLiteral) ??\n expr.asKind(SyntaxKind.NoSubstitutionTemplateLiteral);\n if (!literal) return false;\n return SUBSCRIPTION_CASE_VALUES.has(literal.getLiteralValue());\n })\n .map((c) => c.asKindOrThrow(SyntaxKind.CaseClause));\n\n for (const clause of toRemove.reverse()) {\n clause.remove();\n }\n\n formatLikeSource(sf);\n });\n\n // Removing the clauses takes the blank line before `default:` with them.\n const spaced = source.replace(/(break;)\\n(\\s*default:)/, \"$1\\n\\n$2\");\n\n if (spaced === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, spaced, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const removed = file.removeAttribute(\"AppSidebar\", \"subscription\");\n if (!removed) {\n return { status: \"success\", changed: false };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction updateScript(source: string): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n const hasSub = elements.some((e) => e.getName() === \"subscription\");\n\n // Strip subscription from the props type literal (the specific type\n // added by enable-subscriptions — leave unrelated `subscription` props\n // alone).\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"))\n .filter((t) => !/^\\s*subscription\\??\\s*:/.test(t));\n lit.replaceWithText(\n propTexts.length ? `{ ${propTexts.join(\"; \")}; }` : \"{}\",\n );\n break;\n }\n }\n\n if (hasSub) {\n const remaining = elements\n .filter((e) => e.getName() !== \"subscription\")\n .map((e) => e.getText());\n pattern.replaceWithText(`{ ${remaining.join(\", \")} }`);\n }\n }\n formatLikeSource(sf);\n });\n return out;\n}\n\nexport function unmodifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(filePath, \"utf8\");\n const hasSubPropType = /subscription\\??\\s*:\\s*\\{/.test(source);\n const hasSubProp = /\\bsubscription\\s*=\\s*null\\b/.test(source);\n\n const file = new SvelteFile(source);\n const hasNavUserSubAttr =\n file.hasElement(\"NavUser\") && file.hasAttribute(\"NavUser\", \"subscription\");\n\n if (!hasSubPropType && !hasSubProp && !hasNavUserSubAttr) {\n return { status: \"success\", changed: false };\n }\n\n if (hasSubPropType || hasSubProp) {\n file.modifyScript(updateScript);\n }\n if (hasNavUserSubAttr) {\n file.removeAttribute(\"NavUser\", \"subscription\");\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeFromLoad } from \"../../../../runtime/unmodify-load\";\nimport {\n ensureBlankLineAfterImports,\n formatLikeSource,\n removeTopLevelStatementByIdentifier,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/**\n * Takes out what enable-subscriptions added to the (app) layout load: the\n * `subscription` it loads and returns, and the `loadActiveSubscription`\n * helper. The rest of the load (what other patterns added) stays.\n */\nexport function unmodifyAppLayoutServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"loadActiveSubscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const fromLoad = removeFromLoad(filePath, {\n variables: [\"subscription\"],\n dependsKeys: [],\n returnProps: [\"subscription\"],\n });\n if (fromLoad.status !== \"success\") return fromLoad;\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sf = project.addSourceFileAtPath(filePath);\n removeTopLevelStatementByIdentifier(sf, \"loadActiveSubscription\");\n formatLikeSource(sf);\n // The helper sat between the import and `load`.\n ensureBlankLineAfterImports(sf);\n sf.saveSync();\n\n return {\n status: \"success\",\n changed: fs.readFileSync(filePath, \"utf8\") !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\nimport {\n bindingText,\n propsStatement,\n} from \"../../../enable/subscriptions/modifies/modify-nav-user\";\n\n/**\n * Takes the plan label out of nav-user: the lines showing it, `planLabel`\n * and the `subscription` prop. What other patterns added stays.\n */\nexport function unmodifyNavUser(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"planLabel\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n file.modifyScript(\n (content) =>\n withInMemoryScript(\n // With the blank line enable-subscriptions put before it.\n content.replace(\n /\\n[ \\t]*\\n[ \\t]*const planLabel = \\$derived\\([^\\n]*\\);/,\n \"\",\n ),\n (sf) => {\n const decl = propsStatement(sf)?.getDeclarations()[0];\n const binding = decl\n ?.getNameNode()\n .asKind(SyntaxKind.ObjectBindingPattern);\n const kept = binding\n ?.getElements()\n .filter((e) => e.getName() !== \"subscription\")\n .map((e) => e.getText());\n if (binding && kept) {\n binding.replaceWithText(bindingText(binding.getText(), kept));\n }\n decl\n ?.getTypeNode()\n ?.asKind(SyntaxKind.TypeLiteral)\n ?.getProperty(\"subscription\")\n ?.remove();\n },\n ).source,\n );\n\n // The lines under the name, with the line break before them.\n const out = file\n .toString()\n .replace(/\\n[ \\t]*<span class=\"[^\"]*\">\\s*\\{planLabel\\}\\s*<\\/span>/g, \"\");\n\n fs.writeFileSync(filePath, out, \"utf8\");\n return { status: \"success\", changed: out !== original };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Rewrites a file to the given `template` if the current content still shows\n * the `enabledMarker` (meaning enable-subscriptions is applied). If the marker\n * is absent (already reverted or never applied), it's a no-op.\n *\n * Strips leading `// [!code highlight:N]` / `<!-- [!code highlight:N] -->`\n * lines so templates can be pulled from `preview-modifies/` directories which\n * use those for documentation highlighting.\n */\nexport function revertByTemplate(\n filePath: string,\n template: string,\n enabledMarker: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (!current.includes(enabledMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageServer(\n filePath: string,\n paymentsBillingPageServerTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageServerTemplate,\n \"selectPlan\",\n );\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageSvelte(\n filePath: string,\n paymentsBillingPageSvelteTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageSvelteTemplate,\n \"availablePlans\",\n );\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\nimport { unmodifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { unmodifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { unmodifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { unmodifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { unmodifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Pull the \"post-payments\" state of files that enable-subscriptions fully\n// overwrote. For the billing pages, that's exactly what enable-payments\n// writes in creates-app-mode; for nav-user it's the payments preview-modifies\n// snapshot (with highlight annotations stripped by the revert helper).\nimport paymentsBillingPageServerTemplate from \"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.server.ts?raw\";\nimport paymentsBillingPageSvelteTemplate from \"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.svelte?raw\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n unmodifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n unmodifyAppLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n unmodifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Reverting app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, unmodifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n unmodifyBillingPageServer(\n billingPageServerPath,\n paymentsBillingPageServerTemplate,\n ),\n ),\n );\n\n logger.info(\"Reverting billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n unmodifyBillingPageSvelte(\n billingPageSveltePath,\n paymentsBillingPageSvelteTemplate,\n ),\n ),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"stripe_subscriptions\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AASA,IAAMiB,oBAA2B,IAAI,IAAI;CACvC;CACA;CACA;AACF,CAAC;AAED,SAAgBC,EAAsB,GAAiC;CACrE,IAAI,CAACH,EAAG,WAAWI,CAAQ,GACzB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE7C,IAAMC,IAAWL,EAAG,aAAaI,GAAU,MAAM;CACjD,IAAI,CAACC,EAAS,SAAS,2BAA2B,GAChD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,EAAE,cAAWf,EAAmBe,IAAW,MAAO;EAGtD,AAFAZ,EAA8Ba,GAAI,wBAAwB,GAC1Db,EAA8Ba,GAAI,wBAAwB,GAC1Db,EAA8Ba,GAAI,wBAAwB;EAE1D,IAAMC,IAAaD,EAChB,qBAAqBE,EAAW,eAAe,CAAC,CAChD,MAAM,MAASC,EAAK,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,YAAY,CAAC;EACvE,IAAI,CAACF,GAAY;EAIjB,IAAMG,IAFYH,EAAW,aAEZ,CAAA,CACd,WAAW,CAAC,CACZ,QAAQ,MAAW;GAClB,IAAII,EAAO,QAAQ,MAAMH,EAAW,YAAY,OAAO;GAEvD,IAAMI,IADaD,EAAO,cAAcH,EAAW,UACtC,CAAA,CAAW,cAAc,GAChCK,IACJD,EAAK,OAAOJ,EAAW,aAAa,KACpCI,EAAK,OAAOJ,EAAW,6BAA6B;GAEtD,OADKK,IACEX,EAAyB,IAAIW,EAAQ,gBAAgB,CAAC,IADxC;EAEvB,CAAC,CAAC,CACD,KAAK,MAAMC,EAAE,cAAcN,EAAW,UAAU,CAAC;EAEpD,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