// Emit a reviewable patch; all mutations are applied by apply_patch. const fs = require('node:fs') const { createRequire } = require('node:module') const { resolve } = require('node:path') const root = resolve(__dirname, '../..') const requireFrontend = createRequire(resolve(root, 'frontend/package.json')) const { parse } = requireFrontend('vue/compiler-sfc') const path = resolve(root, 'frontend/src/components/account/EditAccountModal.vue') const source = fs.readFileSync(path, 'utf8').replace(/\r\n/g, '\n') const form = parse(source).descriptor.template.ast.children.find(x => x.tag === 'BaseDialog').children.find(x => x.tag === 'form') const children = form.children.filter(x => x.type === 1) const find = text => { const n = children.find(x => x.loc.source.includes(text)); if (!n) throw Error(text); return n.loc.source } const summary = find('data-testid="account-info-summary"') const proxy = find(' x.tag === 'UpstreamRequestIdHeaderField').loc.source const groups = children.find(x => x.tag === 'GroupSelector').loc.source const status = find('v-model="form.status"') const expiry = find("t('admin.accounts.expiresAt')") const grid = children.find(x => x.loc.source.includes('v-model.number="form.concurrency"')) const concurrency = grid.children.find(x => x.type === 1).loc.source const hunks = [] function replace(old, next) { const position = source.indexOf(old) if (position < 0) throw Error('missing fragment') const start = source.lastIndexOf('\n', position - 1) + 1 let end = source.indexOf('\n', position + old.length) if (end < 0) end = source.length const before = source.slice(start, end) const after = source.slice(start, position) + next + source.slice(position + old.length, end) hunks.push({ start, end, text: '@@\n'+before.split('\n').map(x=>'-'+x).join('\n')+'\n'+after.split('\n').map(x=>'+'+x).join('\n') }) } replace(' \n \n \n \n ', '
\n
\n ') replace(summary, groups+'\n'+status+'\n'+expiry+'\n
\n
') const trafficLine = source.split('\n').find(line => line.includes(''+concurrency+'\n'+trafficLine) replace(' ', '
\n
\n '+proxy+'\n'+header+'\n ') const advancedStart = children.find(x => x.loc.source.includes('account.platform === \'antigravity\'') && x.loc.source.includes('border-t') && x.loc.start.line > 1433) if (!advancedStart) throw Error('advanced boundary missing') const opening = advancedStart.loc.source.split('\n')[0] replace(opening, '
\n
\n'+opening) for (const chunk of [proxy, header, groups, status, expiry, concurrency]) replace(chunk, '') replace(' ', '
\n \n ') hunks.sort((a,b)=>a.start-b.start) for(let i=1;ih.text).join('\n')+'\n*** End Patch')