@codama/renderers-js 1.2.6 → 1.2.7

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.
@@ -1,42 +1,46 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var visitorsCore = require('@codama/visitors-core');
6
- var path = require('path');
7
- var nodes = require('@codama/nodes');
8
- var codecsStrings = require('@solana/codecs-strings');
9
- var errors = require('@codama/errors');
10
- require('url');
11
- var nunjucks = require('nunjucks');
12
- var renderersCore = require('@codama/renderers-core');
13
- var estreePlugin = require('prettier/plugins/estree');
14
- var typeScriptPlugin = require('prettier/plugins/typescript');
15
- var standalone = require('prettier/standalone');
16
-
17
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
18
-
19
- function _interopNamespace(e) {
20
- if (e && e.__esModule) return e;
21
- var n = Object.create(null);
22
- if (e) {
23
- Object.keys(e).forEach(function (k) {
24
- if (k !== 'default') {
25
- var d = Object.getOwnPropertyDescriptor(e, k);
26
- Object.defineProperty(n, k, d.get ? d : {
27
- enumerable: true,
28
- get: function () { return e[k]; }
29
- });
30
- }
31
- });
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
17
  }
33
- n.default = e;
34
- return Object.freeze(n);
35
- }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
29
 
37
- var nunjucks__default = /*#__PURE__*/_interopDefault(nunjucks);
38
- var estreePlugin__namespace = /*#__PURE__*/_interopNamespace(estreePlugin);
39
- var typeScriptPlugin__namespace = /*#__PURE__*/_interopNamespace(typeScriptPlugin);
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ DEFAULT_NAME_TRANSFORMERS: () => DEFAULT_NAME_TRANSFORMERS,
34
+ ImportMap: () => ImportMap,
35
+ default: () => renderVisitor,
36
+ getNameApi: () => getNameApi,
37
+ getRenderMapVisitor: () => getRenderMapVisitor,
38
+ getTypeManifestVisitor: () => getTypeManifestVisitor,
39
+ mergeManifests: () => mergeManifests,
40
+ renderVisitor: () => renderVisitor,
41
+ typeManifest: () => typeManifest
42
+ });
43
+ module.exports = __toCommonJS(index_exports);
40
44
 
41
45
  // src/ImportMap.ts
42
46
  var DEFAULT_EXTERNAL_MODULE_MAP = {
@@ -83,35 +87,35 @@ var DEFAULT_INTERNAL_MODULE_MAP = {
83
87
  var ImportMap = class {
84
88
  _imports = /* @__PURE__ */ new Map();
85
89
  _aliases = /* @__PURE__ */ new Map();
86
- add(module, imports) {
90
+ add(module2, imports) {
87
91
  const newImports = new Set(typeof imports === "string" ? [imports] : imports);
88
92
  if (newImports.size === 0) return this;
89
- const currentImports = this._imports.get(module) ?? /* @__PURE__ */ new Set();
93
+ const currentImports = this._imports.get(module2) ?? /* @__PURE__ */ new Set();
90
94
  newImports.forEach((i) => currentImports.add(i));
91
- this._imports.set(module, currentImports);
95
+ this._imports.set(module2, currentImports);
92
96
  return this;
93
97
  }
94
- remove(module, imports) {
98
+ remove(module2, imports) {
95
99
  const importsToRemove = new Set(typeof imports === "string" ? [imports] : imports);
96
100
  if (importsToRemove.size === 0) return this;
97
- const currentImports = this._imports.get(module) ?? /* @__PURE__ */ new Set();
101
+ const currentImports = this._imports.get(module2) ?? /* @__PURE__ */ new Set();
98
102
  importsToRemove.forEach((i) => currentImports.delete(i));
99
103
  if (currentImports.size === 0) {
100
- this._imports.delete(module);
104
+ this._imports.delete(module2);
101
105
  } else {
102
- this._imports.set(module, currentImports);
106
+ this._imports.set(module2, currentImports);
103
107
  }
104
108
  return this;
105
109
  }
106
110
  mergeWith(...others) {
107
111
  others.forEach((rawOther) => {
108
112
  const other = "imports" in rawOther ? rawOther.imports : rawOther;
109
- other._imports.forEach((imports, module) => {
110
- this.add(module, imports);
113
+ other._imports.forEach((imports, module2) => {
114
+ this.add(module2, imports);
111
115
  });
112
- other._aliases.forEach((aliases, module) => {
116
+ other._aliases.forEach((aliases, module2) => {
113
117
  Object.entries(aliases).forEach(([name, alias]) => {
114
- this.addAlias(module, name, alias);
118
+ this.addAlias(module2, name, alias);
115
119
  });
116
120
  });
117
121
  });
@@ -120,10 +124,10 @@ var ImportMap = class {
120
124
  mergeWithManifest(manifest) {
121
125
  return this.mergeWith(manifest.strictType, manifest.looseType, manifest.encoder, manifest.decoder);
122
126
  }
123
- addAlias(module, name, alias) {
124
- const currentAliases = this._aliases.get(module) ?? {};
127
+ addAlias(module2, name, alias) {
128
+ const currentAliases = this._aliases.get(module2) ?? {};
125
129
  currentAliases[name] = alias;
126
- this._aliases.set(module, currentAliases);
130
+ this._aliases.set(module2, currentAliases);
127
131
  return this;
128
132
  }
129
133
  isEmpty() {
@@ -131,10 +135,10 @@ var ImportMap = class {
131
135
  }
132
136
  resolve(dependencies = {}, useGranularImports = false) {
133
137
  const aliasedMap = new Map(
134
- [...this._imports.entries()].map(([module, imports]) => {
135
- const aliasMap = this._aliases.get(module) ?? {};
138
+ [...this._imports.entries()].map(([module2, imports]) => {
139
+ const aliasMap = this._aliases.get(module2) ?? {};
136
140
  const joinedImports = [...imports].map((i) => aliasMap[i] ? `${i} as ${aliasMap[i]}` : i);
137
- return [module, new Set(joinedImports)];
141
+ return [module2, new Set(joinedImports)];
138
142
  })
139
143
  );
140
144
  const dependencyMap = {
@@ -143,8 +147,8 @@ var ImportMap = class {
143
147
  ...dependencies
144
148
  };
145
149
  const resolvedMap = /* @__PURE__ */ new Map();
146
- aliasedMap.forEach((imports, module) => {
147
- const resolvedModule = dependencyMap[module] ?? module;
150
+ aliasedMap.forEach((imports, module2) => {
151
+ const resolvedModule = dependencyMap[module2] ?? module2;
148
152
  const currentImports = resolvedMap.get(resolvedModule) ?? /* @__PURE__ */ new Set();
149
153
  imports.forEach((i) => currentImports.add(i));
150
154
  resolvedMap.set(resolvedModule, currentImports);
@@ -158,7 +162,7 @@ var ImportMap = class {
158
162
  if (aIsRelative && !bIsRelative) return 1;
159
163
  if (!aIsRelative && bIsRelative) return -1;
160
164
  return a.localeCompare(b);
161
- }).map(([module, imports]) => {
165
+ }).map(([module2, imports]) => {
162
166
  const joinedImports = [...imports].sort().filter((i) => {
163
167
  const name = i.split(" ");
164
168
  if (name.length > 1) {
@@ -166,16 +170,26 @@ var ImportMap = class {
166
170
  }
167
171
  return true;
168
172
  }).join(", ");
169
- return `import { ${joinedImports} } from '${module}';`;
173
+ return `import { ${joinedImports} } from '${module2}';`;
170
174
  }).join("\n");
171
175
  }
172
176
  };
177
+
178
+ // src/fragments/accountFetchHelpers.ts
179
+ var import_visitors_core2 = require("@codama/visitors-core");
180
+
181
+ // src/fragments/common.ts
182
+ var import_node_path2 = require("path");
183
+
184
+ // src/utils/async.ts
185
+ var import_nodes = require("@codama/nodes");
186
+ var import_visitors_core = require("@codama/visitors-core");
173
187
  function hasAsyncFunction(instructionNode, resolvedInputs, asyncResolvers) {
174
188
  const hasByteDeltasAsync = (instructionNode.byteDeltas ?? []).some(
175
- ({ value }) => nodes.isNode(value, "resolverValueNode") && asyncResolvers.includes(value.name)
189
+ ({ value }) => (0, import_nodes.isNode)(value, "resolverValueNode") && asyncResolvers.includes(value.name)
176
190
  );
177
191
  const hasRemainingAccountsAsync = (instructionNode.remainingAccounts ?? []).some(
178
- ({ value }) => nodes.isNode(value, "resolverValueNode") && asyncResolvers.includes(value.name)
192
+ ({ value }) => (0, import_nodes.isNode)(value, "resolverValueNode") && asyncResolvers.includes(value.name)
179
193
  );
180
194
  return hasAsyncDefaultValues(resolvedInputs, asyncResolvers) || hasByteDeltasAsync || hasRemainingAccountsAsync;
181
195
  }
@@ -197,8 +211,8 @@ function isAsyncDefaultValue(defaultValue, asyncResolvers) {
197
211
  }
198
212
  }
199
213
  function getInstructionDependencies(input, asyncResolvers, useAsync) {
200
- if (nodes.isNode(input, "instructionNode")) {
201
- return visitorsCore.deduplicateInstructionDependencies([
214
+ if ((0, import_nodes.isNode)(input, "instructionNode")) {
215
+ return (0, import_visitors_core.deduplicateInstructionDependencies)([
202
216
  ...input.accounts.flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync)),
203
217
  ...input.arguments.flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync)),
204
218
  ...(input.extraArguments ?? []).flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync))
@@ -209,29 +223,29 @@ function getInstructionDependencies(input, asyncResolvers, useAsync) {
209
223
  if (!defaultValue) return [];
210
224
  return getInstructionDependencies({ ...input, defaultValue }, asyncResolvers, useAsync);
211
225
  };
212
- if (nodes.isNode(input.defaultValue, ["accountValueNode", "accountBumpValueNode"])) {
213
- return [nodes.accountValueNode(input.defaultValue.name)];
226
+ if ((0, import_nodes.isNode)(input.defaultValue, ["accountValueNode", "accountBumpValueNode"])) {
227
+ return [(0, import_nodes.accountValueNode)(input.defaultValue.name)];
214
228
  }
215
- if (nodes.isNode(input.defaultValue, ["argumentValueNode"])) {
216
- return [nodes.argumentValueNode(input.defaultValue.name)];
229
+ if ((0, import_nodes.isNode)(input.defaultValue, ["argumentValueNode"])) {
230
+ return [(0, import_nodes.argumentValueNode)(input.defaultValue.name)];
217
231
  }
218
- if (nodes.isNode(input.defaultValue, "pdaValueNode")) {
232
+ if ((0, import_nodes.isNode)(input.defaultValue, "pdaValueNode")) {
219
233
  const dependencies = /* @__PURE__ */ new Map();
220
234
  input.defaultValue.seeds.forEach((seed) => {
221
- if (nodes.isNode(seed.value, ["accountValueNode", "argumentValueNode"])) {
235
+ if ((0, import_nodes.isNode)(seed.value, ["accountValueNode", "argumentValueNode"])) {
222
236
  dependencies.set(seed.value.name, { ...seed.value });
223
237
  }
224
238
  });
225
239
  return [...dependencies.values()];
226
240
  }
227
- if (nodes.isNode(input.defaultValue, "resolverValueNode")) {
241
+ if ((0, import_nodes.isNode)(input.defaultValue, "resolverValueNode")) {
228
242
  const isSynchronousResolver = !asyncResolvers.includes(input.defaultValue.name);
229
243
  if (useAsync || isSynchronousResolver) {
230
244
  return input.defaultValue.dependsOn ?? [];
231
245
  }
232
246
  }
233
- if (nodes.isNode(input.defaultValue, "conditionalValueNode")) {
234
- return visitorsCore.deduplicateInstructionDependencies([
247
+ if ((0, import_nodes.isNode)(input.defaultValue, "conditionalValueNode")) {
248
+ return (0, import_visitors_core.deduplicateInstructionDependencies)([
235
249
  ...getNestedDependencies(input.defaultValue.condition),
236
250
  ...getNestedDependencies(input.defaultValue.ifTrue),
237
251
  ...getNestedDependencies(input.defaultValue.ifFalse)
@@ -239,49 +253,58 @@ function getInstructionDependencies(input, asyncResolvers, useAsync) {
239
253
  }
240
254
  return [];
241
255
  }
256
+
257
+ // src/utils/codecs.ts
258
+ var import_codecs_strings = require("@solana/codecs-strings");
242
259
  function getBytesFromBytesValueNode(node) {
243
260
  switch (node.encoding) {
244
261
  case "utf8":
245
- return codecsStrings.getUtf8Encoder().encode(node.data);
262
+ return (0, import_codecs_strings.getUtf8Encoder)().encode(node.data);
246
263
  case "base16":
247
- return codecsStrings.getBase16Encoder().encode(node.data);
264
+ return (0, import_codecs_strings.getBase16Encoder)().encode(node.data);
248
265
  case "base58":
249
- return codecsStrings.getBase58Encoder().encode(node.data);
266
+ return (0, import_codecs_strings.getBase58Encoder)().encode(node.data);
250
267
  case "base64":
251
268
  default:
252
- return codecsStrings.getBase64Encoder().encode(node.data);
269
+ return (0, import_codecs_strings.getBase64Encoder)().encode(node.data);
253
270
  }
254
271
  }
272
+
273
+ // src/utils/customData.ts
274
+ var import_nodes2 = require("@codama/nodes");
255
275
  var parseCustomDataOptions = (customDataOptions, defaultSuffix) => new Map(
256
276
  customDataOptions.map((o) => {
257
277
  const options = typeof o === "string" ? { name: o } : o;
258
- const importAs = nodes.camelCase(options.importAs ?? `${options.name}${defaultSuffix}`);
278
+ const importAs = (0, import_nodes2.camelCase)(options.importAs ?? `${options.name}${defaultSuffix}`);
259
279
  const importFrom = options.importFrom ?? "hooked";
260
280
  return [
261
- nodes.camelCase(options.name),
281
+ (0, import_nodes2.camelCase)(options.name),
262
282
  {
263
283
  extract: options.extract ?? false,
264
- extractAs: options.extractAs ? nodes.camelCase(options.extractAs) : importAs,
284
+ extractAs: options.extractAs ? (0, import_nodes2.camelCase)(options.extractAs) : importAs,
265
285
  importAs,
266
286
  importFrom,
267
- linkNode: nodes.definedTypeLinkNode(importAs)
287
+ linkNode: (0, import_nodes2.definedTypeLinkNode)(importAs)
268
288
  }
269
289
  ];
270
290
  })
271
291
  );
272
- var getDefinedTypeNodesToExtract = (nodes$1, parsedCustomDataOptions) => nodes$1.flatMap((node) => {
292
+ var getDefinedTypeNodesToExtract = (nodes, parsedCustomDataOptions) => nodes.flatMap((node) => {
273
293
  const options = parsedCustomDataOptions.get(node.name);
274
294
  if (!options || !options.extract) return [];
275
- if (nodes.isNode(node, "accountNode")) {
276
- return [nodes.definedTypeNode({ name: options.extractAs, type: { ...node.data } })];
295
+ if ((0, import_nodes2.isNode)(node, "accountNode")) {
296
+ return [(0, import_nodes2.definedTypeNode)({ name: options.extractAs, type: { ...node.data } })];
277
297
  }
278
298
  return [
279
- nodes.definedTypeNode({
299
+ (0, import_nodes2.definedTypeNode)({
280
300
  name: options.extractAs,
281
- type: nodes.structTypeNodeFromInstructionArgumentNodes(node.arguments)
301
+ type: (0, import_nodes2.structTypeNodeFromInstructionArgumentNodes)(node.arguments)
282
302
  })
283
303
  ];
284
304
  });
305
+
306
+ // src/utils/linkOverrides.ts
307
+ var import_errors = require("@codama/errors");
285
308
  function getImportFromFactory(overrides, customAccountData, customInstructionData) {
286
309
  const customDataOverrides = Object.fromEntries(
287
310
  [...customAccountData.values(), ...customInstructionData.values()].map(({ importFrom, importAs }) => [
@@ -313,7 +336,7 @@ function getImportFromFactory(overrides, customAccountData, customInstructionDat
313
336
  case "resolverValueNode":
314
337
  return linkOverrides.resolvers[node.name] ?? "hooked";
315
338
  default:
316
- throw new errors.CodamaError(errors.CODAMA_ERROR__UNEXPECTED_NODE_KIND, {
339
+ throw new import_errors.CodamaError(import_errors.CODAMA_ERROR__UNEXPECTED_NODE_KIND, {
317
340
  expectedKinds: [
318
341
  "AccountLinkNode",
319
342
  "DefinedTypeLinkNode",
@@ -328,6 +351,12 @@ function getImportFromFactory(overrides, customAccountData, customInstructionDat
328
351
  }
329
352
  };
330
353
  }
354
+
355
+ // src/utils/render.ts
356
+ var import_node_path = require("path");
357
+ var import_node_url = require("url");
358
+ var import_nodes3 = require("@codama/nodes");
359
+ var import_nunjucks = __toESM(require("nunjucks"));
331
360
  function jsDocblock(docs) {
332
361
  if (docs.length <= 0) return "";
333
362
  if (docs.length === 1) return `/** ${docs[0]} */
@@ -339,14 +368,14 @@ ${lines.join("\n")}
339
368
  `;
340
369
  }
341
370
  var render = (template, context, options) => {
342
- const dirname = __dirname;
343
- const templates = path.join(dirname, "templates");
344
- const env = nunjucks__default.default.configure(templates, { autoescape: false, trimBlocks: true, ...options });
345
- env.addFilter("pascalCase", nodes.pascalCase);
346
- env.addFilter("camelCase", nodes.camelCase);
347
- env.addFilter("snakeCase", nodes.snakeCase);
348
- env.addFilter("kebabCase", nodes.kebabCase);
349
- env.addFilter("titleCase", nodes.titleCase);
371
+ const dirname = false ? pathDirname(fileURLToPath(import_meta.url)) : __dirname;
372
+ const templates = false ? (0, import_node_path.join)(dirname, "..", "..", "public", "templates") : (0, import_node_path.join)(dirname, "templates");
373
+ const env = import_nunjucks.default.configure(templates, { autoescape: false, trimBlocks: true, ...options });
374
+ env.addFilter("pascalCase", import_nodes3.pascalCase);
375
+ env.addFilter("camelCase", import_nodes3.camelCase);
376
+ env.addFilter("snakeCase", import_nodes3.snakeCase);
377
+ env.addFilter("kebabCase", import_nodes3.kebabCase);
378
+ env.addFilter("titleCase", import_nodes3.titleCase);
350
379
  env.addFilter("jsDocblock", jsDocblock);
351
380
  return env.render(template, context);
352
381
  };
@@ -356,7 +385,7 @@ function fragment(render2, imports) {
356
385
  return new Fragment(render2, imports);
357
386
  }
358
387
  function fragmentFromTemplate(fragmentFile, context, options) {
359
- return fragment(render(path.join("fragments", fragmentFile), context, options));
388
+ return fragment(render((0, import_node_path2.join)("fragments", fragmentFile), context, options));
360
389
  }
361
390
  function mergeFragments(fragments, mergeRenders) {
362
391
  return new Fragment(
@@ -382,20 +411,20 @@ var Fragment = class _Fragment {
382
411
  this.render = fn(this.render);
383
412
  return this;
384
413
  }
385
- addImports(module, imports) {
386
- this.imports.add(module, imports);
414
+ addImports(module2, imports) {
415
+ this.imports.add(module2, imports);
387
416
  return this;
388
417
  }
389
- removeImports(module, imports) {
390
- this.imports.remove(module, imports);
418
+ removeImports(module2, imports) {
419
+ this.imports.remove(module2, imports);
391
420
  return this;
392
421
  }
393
422
  mergeImportsWith(...others) {
394
423
  this.imports.mergeWith(...others);
395
424
  return this;
396
425
  }
397
- addImportAlias(module, name, alias) {
398
- this.imports.addAlias(module, name, alias);
426
+ addImportAlias(module2, name, alias) {
427
+ this.imports.addAlias(module2, name, alias);
399
428
  return this;
400
429
  }
401
430
  addFeatures(features) {
@@ -427,7 +456,7 @@ var Fragment = class _Fragment {
427
456
  // src/fragments/accountFetchHelpers.ts
428
457
  function getAccountFetchHelpersFragment(scope) {
429
458
  const { accountPath, typeManifest: typeManifest2, nameApi, customAccountData } = scope;
430
- const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
459
+ const accountNode = (0, import_visitors_core2.getLastNodeFromPath)(accountPath);
431
460
  const hasCustomData = customAccountData.has(accountNode.name);
432
461
  const accountTypeFragment = hasCustomData ? typeManifest2.strictType.clone() : fragment(nameApi.dataType(accountNode.name));
433
462
  const decoderFunctionFragment = hasCustomData ? typeManifest2.decoder.clone() : fragment(`${nameApi.decoderFunction(accountNode.name)}()`);
@@ -453,10 +482,14 @@ function getAccountFetchHelpersFragment(scope) {
453
482
  "type MaybeEncodedAccount"
454
483
  ]);
455
484
  }
485
+
486
+ // src/fragments/accountPdaHelpers.ts
487
+ var import_nodes4 = require("@codama/nodes");
488
+ var import_visitors_core3 = require("@codama/visitors-core");
456
489
  function getAccountPdaHelpersFragment(scope) {
457
490
  const { accountPath, nameApi, linkables, customAccountData, typeManifest: typeManifest2 } = scope;
458
- const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
459
- const programNode = visitorsCore.findProgramNodeFromPath(accountPath);
491
+ const accountNode = (0, import_visitors_core3.getLastNodeFromPath)(accountPath);
492
+ const programNode = (0, import_visitors_core3.findProgramNodeFromPath)(accountPath);
460
493
  const pdaNode = accountNode.pda ? linkables.get([...accountPath, accountNode.pda]) : void 0;
461
494
  if (!pdaNode) {
462
495
  return fragment("");
@@ -465,7 +498,7 @@ function getAccountPdaHelpersFragment(scope) {
465
498
  const importFrom = "generatedPdas";
466
499
  const pdaSeedsType = nameApi.pdaSeedsType(pdaNode.name);
467
500
  const findPdaFunction = nameApi.pdaFindFunction(pdaNode.name);
468
- const hasVariableSeeds = pdaNode.seeds.filter(nodes.isNodeFilter("variablePdaSeedNode")).length > 0;
501
+ const hasVariableSeeds = pdaNode.seeds.filter((0, import_nodes4.isNodeFilter)("variablePdaSeedNode")).length > 0;
469
502
  return fragmentFromTemplate("accountPdaHelpers.njk", {
470
503
  accountType: accountTypeFragment.render,
471
504
  fetchFromSeedsFunction: nameApi.accountFetchFromSeedsFunction(accountNode.name),
@@ -483,9 +516,12 @@ function getAccountPdaHelpersFragment(scope) {
483
516
  "type MaybeAccount"
484
517
  ]);
485
518
  }
519
+
520
+ // src/fragments/accountSizeHelpers.ts
521
+ var import_visitors_core4 = require("@codama/visitors-core");
486
522
  function getAccountSizeHelpersFragment(scope) {
487
523
  const { accountPath, nameApi } = scope;
488
- const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
524
+ const accountNode = (0, import_visitors_core4.getLastNodeFromPath)(accountPath);
489
525
  if (accountNode.size == null) {
490
526
  return fragment("");
491
527
  }
@@ -495,6 +531,9 @@ function getAccountSizeHelpersFragment(scope) {
495
531
  });
496
532
  }
497
533
 
534
+ // src/fragments/accountType.ts
535
+ var import_visitors_core5 = require("@codama/visitors-core");
536
+
498
537
  // src/fragments/type.ts
499
538
  function getTypeFragment(scope) {
500
539
  const { name, manifest, nameApi, docs = [] } = scope;
@@ -566,7 +605,7 @@ function getTypeWithCodecFragment(scope) {
566
605
  // src/fragments/accountType.ts
567
606
  function getAccountTypeFragment(scope) {
568
607
  const { accountPath, typeManifest: typeManifest2, nameApi, customAccountData } = scope;
569
- const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
608
+ const accountNode = (0, import_visitors_core5.getLastNodeFromPath)(accountPath);
570
609
  if (customAccountData.has(accountNode.name)) {
571
610
  return fragment("");
572
611
  }
@@ -576,16 +615,21 @@ function getAccountTypeFragment(scope) {
576
615
  nameApi
577
616
  });
578
617
  }
618
+
619
+ // src/fragments/discriminatorCondition.ts
620
+ var import_nodes5 = require("@codama/nodes");
621
+ var import_visitors_core6 = require("@codama/visitors-core");
622
+ var import_codecs_strings2 = require("@solana/codecs-strings");
579
623
  function getDiscriminatorConditionFragment(scope) {
580
624
  return mergeFragments(
581
625
  scope.discriminators.flatMap((discriminator) => {
582
- if (nodes.isNode(discriminator, "sizeDiscriminatorNode")) {
626
+ if ((0, import_nodes5.isNode)(discriminator, "sizeDiscriminatorNode")) {
583
627
  return [getSizeConditionFragment(discriminator, scope)];
584
628
  }
585
- if (nodes.isNode(discriminator, "constantDiscriminatorNode")) {
629
+ if ((0, import_nodes5.isNode)(discriminator, "constantDiscriminatorNode")) {
586
630
  return [getByteConditionFragment(discriminator, scope)];
587
631
  }
588
- if (nodes.isNode(discriminator, "fieldDiscriminatorNode")) {
632
+ if ((0, import_nodes5.isNode)(discriminator, "fieldDiscriminatorNode")) {
589
633
  return [getFieldConditionFragment(discriminator, scope)];
590
634
  }
591
635
  return [];
@@ -599,7 +643,7 @@ function getSizeConditionFragment(discriminator, scope) {
599
643
  }
600
644
  function getByteConditionFragment(discriminator, scope) {
601
645
  const { dataName, typeManifestVisitor } = scope;
602
- const constant = visitorsCore.visit(discriminator.constant, typeManifestVisitor).value;
646
+ const constant = (0, import_visitors_core6.visit)(discriminator.constant, typeManifestVisitor).value;
603
647
  return constant.mapRender((r) => `containsBytes(${dataName}, ${r}, ${discriminator.offset})`).addImports("solanaCodecsCore", "containsBytes");
604
648
  }
605
649
  function getFieldConditionFragment(discriminator, scope) {
@@ -609,22 +653,25 @@ function getFieldConditionFragment(discriminator, scope) {
609
653
  `Field discriminator "${discriminator.name}" does not have a matching argument with default value.`
610
654
  );
611
655
  }
612
- if (nodes.isNode(field.type, "arrayTypeNode") && nodes.isNode(field.type.item, "numberTypeNode") && field.type.item.format === "u8" && nodes.isNode(field.type.count, "fixedCountNode") && nodes.isNode(field.defaultValue, "arrayValueNode") && field.defaultValue.items.every(nodes.isNodeFilter("numberValueNode"))) {
613
- const base64Bytes = codecsStrings.getBase64Decoder().decode(
656
+ if ((0, import_nodes5.isNode)(field.type, "arrayTypeNode") && (0, import_nodes5.isNode)(field.type.item, "numberTypeNode") && field.type.item.format === "u8" && (0, import_nodes5.isNode)(field.type.count, "fixedCountNode") && (0, import_nodes5.isNode)(field.defaultValue, "arrayValueNode") && field.defaultValue.items.every((0, import_nodes5.isNodeFilter)("numberValueNode"))) {
657
+ const base64Bytes = (0, import_codecs_strings2.getBase64Decoder)().decode(
614
658
  new Uint8Array(field.defaultValue.items.map((node) => node.number))
615
659
  );
616
660
  return getByteConditionFragment(
617
- nodes.constantDiscriminatorNode(nodes.constantValueNodeFromBytes("base64", base64Bytes), discriminator.offset),
661
+ (0, import_nodes5.constantDiscriminatorNode)((0, import_nodes5.constantValueNodeFromBytes)("base64", base64Bytes), discriminator.offset),
618
662
  scope
619
663
  );
620
664
  }
621
665
  return getByteConditionFragment(
622
- nodes.constantDiscriminatorNode(nodes.constantValueNode(field.type, field.defaultValue), discriminator.offset),
666
+ (0, import_nodes5.constantDiscriminatorNode)((0, import_nodes5.constantValueNode)(field.type, field.defaultValue), discriminator.offset),
623
667
  scope
624
668
  );
625
669
  }
670
+
671
+ // src/fragments/instructionAccountMeta.ts
672
+ var import_nodes6 = require("@codama/nodes");
626
673
  function getInstructionAccountMetaFragment(instructionAccountNode) {
627
- const typeParam = `TAccount${nodes.pascalCase(instructionAccountNode.name)}`;
674
+ const typeParam = `TAccount${(0, import_nodes6.pascalCase)(instructionAccountNode.name)}`;
628
675
  if (instructionAccountNode.isSigner === true && instructionAccountNode.isWritable) {
629
676
  return fragment(`WritableSignerAccount<${typeParam}> & IAccountSignerMeta<${typeParam}>`).addImports("solanaInstructions", ["type WritableSignerAccount"]).addImports("solanaSigners", ["type IAccountSignerMeta"]);
630
677
  }
@@ -636,15 +683,19 @@ function getInstructionAccountMetaFragment(instructionAccountNode) {
636
683
  }
637
684
  return fragment(`ReadonlyAccount<${typeParam}>`).addImports("solanaInstructions", "type ReadonlyAccount");
638
685
  }
686
+
687
+ // src/fragments/instructionAccountTypeParam.ts
688
+ var import_nodes7 = require("@codama/nodes");
689
+ var import_visitors_core7 = require("@codama/visitors-core");
639
690
  function getInstructionAccountTypeParamFragment(scope) {
640
- const { instructionAccountPath, linkables } = scope;
641
- const instructionAccountNode = visitorsCore.getLastNodeFromPath(instructionAccountPath);
642
- const instructionNode = visitorsCore.findInstructionNodeFromPath(instructionAccountPath);
643
- const programNode = visitorsCore.findProgramNodeFromPath(instructionAccountPath);
644
- const typeParam = `TAccount${nodes.pascalCase(instructionAccountNode.name)}`;
645
- const accountMeta = " | IAccountMeta<string>" ;
691
+ const { instructionAccountPath, allowAccountMeta, linkables } = scope;
692
+ const instructionAccountNode = (0, import_visitors_core7.getLastNodeFromPath)(instructionAccountPath);
693
+ const instructionNode = (0, import_visitors_core7.findInstructionNodeFromPath)(instructionAccountPath);
694
+ const programNode = (0, import_visitors_core7.findProgramNodeFromPath)(instructionAccountPath);
695
+ const typeParam = `TAccount${(0, import_nodes7.pascalCase)(instructionAccountNode.name)}`;
696
+ const accountMeta = allowAccountMeta ? " | IAccountMeta<string>" : "";
646
697
  const imports = new ImportMap();
647
- {
698
+ if (allowAccountMeta) {
648
699
  imports.add("solanaInstructions", "type IAccountMeta");
649
700
  }
650
701
  if (instructionNode.optionalAccountStrategy === "omitted" && instructionAccountNode.isOptional) {
@@ -666,8 +717,12 @@ function getDefaultAddress(defaultValue, programId, linkables) {
666
717
  return "string";
667
718
  }
668
719
  }
720
+
721
+ // src/fragments/instructionByteDelta.ts
722
+ var import_nodes8 = require("@codama/nodes");
723
+ var import_visitors_core8 = require("@codama/visitors-core");
669
724
  function getInstructionByteDeltaFragment(scope) {
670
- const { byteDeltas } = visitorsCore.getLastNodeFromPath(scope.instructionPath);
725
+ const { byteDeltas } = (0, import_visitors_core8.getLastNodeFromPath)(scope.instructionPath);
671
726
  const fragments = (byteDeltas ?? []).flatMap((r) => getByteDeltaFragment(r, scope));
672
727
  if (fragments.length === 0) return fragment("");
673
728
  return mergeFragments(
@@ -678,16 +733,16 @@ const byteDelta: number = [${r.join(",")}].reduce((a, b) => a + b, 0);`
678
733
  }
679
734
  function getByteDeltaFragment(byteDelta, scope) {
680
735
  const bytesFragment = (() => {
681
- if (nodes.isNode(byteDelta.value, "numberValueNode")) {
736
+ if ((0, import_nodes8.isNode)(byteDelta.value, "numberValueNode")) {
682
737
  return getNumberValueNodeFragment(byteDelta);
683
738
  }
684
- if (nodes.isNode(byteDelta.value, "argumentValueNode")) {
739
+ if ((0, import_nodes8.isNode)(byteDelta.value, "argumentValueNode")) {
685
740
  return getArgumentValueNodeFragment(byteDelta);
686
741
  }
687
- if (nodes.isNode(byteDelta.value, "accountLinkNode")) {
742
+ if ((0, import_nodes8.isNode)(byteDelta.value, "accountLinkNode")) {
688
743
  return getAccountLinkNodeFragment(byteDelta, scope);
689
744
  }
690
- if (nodes.isNode(byteDelta.value, "resolverValueNode")) {
745
+ if ((0, import_nodes8.isNode)(byteDelta.value, "resolverValueNode")) {
691
746
  return getResolverValueNodeFragment(byteDelta, scope);
692
747
  }
693
748
  return null;
@@ -702,30 +757,33 @@ function getByteDeltaFragment(byteDelta, scope) {
702
757
  return [bytesFragment];
703
758
  }
704
759
  function getNumberValueNodeFragment(byteDelta) {
705
- nodes.assertIsNode(byteDelta.value, "numberValueNode");
760
+ (0, import_nodes8.assertIsNode)(byteDelta.value, "numberValueNode");
706
761
  return fragment(byteDelta.value.number.toString());
707
762
  }
708
763
  function getArgumentValueNodeFragment(byteDelta) {
709
- nodes.assertIsNode(byteDelta.value, "argumentValueNode");
710
- const argumentName = nodes.camelCase(byteDelta.value.name);
764
+ (0, import_nodes8.assertIsNode)(byteDelta.value, "argumentValueNode");
765
+ const argumentName = (0, import_nodes8.camelCase)(byteDelta.value.name);
711
766
  return fragment(`Number(args.${argumentName})`);
712
767
  }
713
768
  function getAccountLinkNodeFragment(byteDelta, scope) {
714
- nodes.assertIsNode(byteDelta.value, "accountLinkNode");
769
+ (0, import_nodes8.assertIsNode)(byteDelta.value, "accountLinkNode");
715
770
  const functionName = scope.nameApi.accountGetSizeFunction(byteDelta.value.name);
716
771
  return fragment(`${functionName}()`).addImports(scope.getImportFrom(byteDelta.value), functionName);
717
772
  }
718
773
  function getResolverValueNodeFragment(byteDelta, scope) {
719
- nodes.assertIsNode(byteDelta.value, "resolverValueNode");
774
+ (0, import_nodes8.assertIsNode)(byteDelta.value, "resolverValueNode");
720
775
  const isAsync = scope.asyncResolvers.includes(byteDelta.value.name);
721
776
  if (!scope.useAsync && isAsync) return null;
722
777
  const awaitKeyword = scope.useAsync && isAsync ? "await " : "";
723
778
  const functionName = scope.nameApi.resolverFunction(byteDelta.value.name);
724
779
  return fragment(`${awaitKeyword}${functionName}(resolverScope)`).addImports(scope.getImportFrom(byteDelta.value), functionName).addFeatures(["instruction:resolverScopeVariable"]);
725
780
  }
781
+
782
+ // src/fragments/instructionData.ts
783
+ var import_visitors_core9 = require("@codama/visitors-core");
726
784
  function getInstructionDataFragment(scope) {
727
785
  const { instructionPath, dataArgsManifest, nameApi, customInstructionData } = scope;
728
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
786
+ const instructionNode = (0, import_visitors_core9.getLastNodeFromPath)(instructionPath);
729
787
  if (instructionNode.arguments.length === 0 || customInstructionData.has(instructionNode.name)) {
730
788
  return fragment("");
731
789
  }
@@ -736,6 +794,10 @@ function getInstructionDataFragment(scope) {
736
794
  nameApi
737
795
  });
738
796
  }
797
+
798
+ // src/fragments/discriminatorConstants.ts
799
+ var import_nodes9 = require("@codama/nodes");
800
+ var import_visitors_core10 = require("@codama/visitors-core");
739
801
  function getDiscriminatorConstantsFragment(scope) {
740
802
  const fragments = scope.discriminatorNodes.map((node) => getDiscriminatorConstantFragment(node, scope)).filter(Boolean);
741
803
  return mergeFragments(fragments, (r) => r.join("\n\n"));
@@ -752,22 +814,22 @@ function getDiscriminatorConstantFragment(discriminatorNode, scope) {
752
814
  }
753
815
  function getConstantDiscriminatorConstantFragment(discriminatorNode, scope) {
754
816
  const { discriminatorNodes, typeManifestVisitor, prefix } = scope;
755
- const index = discriminatorNodes.filter(nodes.isNodeFilter("constantDiscriminatorNode")).indexOf(discriminatorNode);
817
+ const index = discriminatorNodes.filter((0, import_nodes9.isNodeFilter)("constantDiscriminatorNode")).indexOf(discriminatorNode);
756
818
  const suffix = index <= 0 ? "" : `_${index + 1}`;
757
- const name = nodes.camelCase(`${prefix}_discriminator${suffix}`);
758
- const encoder = visitorsCore.visit(discriminatorNode.constant.type, typeManifestVisitor).encoder;
759
- const value = visitorsCore.visit(discriminatorNode.constant.value, typeManifestVisitor).value;
819
+ const name = (0, import_nodes9.camelCase)(`${prefix}_discriminator${suffix}`);
820
+ const encoder = (0, import_visitors_core10.visit)(discriminatorNode.constant.type, typeManifestVisitor).encoder;
821
+ const value = (0, import_visitors_core10.visit)(discriminatorNode.constant.value, typeManifestVisitor).value;
760
822
  return getConstantFragment({ ...scope, encoder, name, value });
761
823
  }
762
824
  function getFieldDiscriminatorConstantFragment(discriminatorNode, scope) {
763
825
  const { fields, prefix, typeManifestVisitor } = scope;
764
826
  const field = fields.find((f) => f.name === discriminatorNode.name);
765
- if (!field || !field.defaultValue || !nodes.isNode(field.defaultValue, nodes.VALUE_NODES)) {
827
+ if (!field || !field.defaultValue || !(0, import_nodes9.isNode)(field.defaultValue, import_nodes9.VALUE_NODES)) {
766
828
  return null;
767
829
  }
768
- const name = nodes.camelCase(`${prefix}_${discriminatorNode.name}`);
769
- const encoder = visitorsCore.visit(field.type, typeManifestVisitor).encoder;
770
- const value = visitorsCore.visit(field.defaultValue, typeManifestVisitor).value;
830
+ const name = (0, import_nodes9.camelCase)(`${prefix}_${discriminatorNode.name}`);
831
+ const encoder = (0, import_visitors_core10.visit)(field.type, typeManifestVisitor).encoder;
832
+ const value = (0, import_visitors_core10.visit)(field.defaultValue, typeManifestVisitor).value;
771
833
  return getConstantFragment({ ...scope, encoder, name, value });
772
834
  }
773
835
  function getConstantFragment(scope) {
@@ -782,9 +844,12 @@ function getConstantFragment(scope) {
782
844
  (r) => r.join("\n\n")
783
845
  );
784
846
  }
847
+
848
+ // src/fragments/instructionExtraArgs.ts
849
+ var import_visitors_core11 = require("@codama/visitors-core");
785
850
  function getInstructionExtraArgsFragment(scope) {
786
851
  const { instructionPath, extraArgsManifest, nameApi } = scope;
787
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
852
+ const instructionNode = (0, import_visitors_core11.getLastNodeFromPath)(instructionPath);
788
853
  if ((instructionNode.extraArguments ?? []).length === 0) {
789
854
  return fragment("");
790
855
  }
@@ -795,6 +860,18 @@ function getInstructionExtraArgsFragment(scope) {
795
860
  strictName: nameApi.dataType(instructionExtraName)
796
861
  }).mergeImportsWith(extraArgsManifest.looseType);
797
862
  }
863
+
864
+ // src/fragments/instructionFunction.ts
865
+ var import_nodes14 = require("@codama/nodes");
866
+ var import_visitors_core16 = require("@codama/visitors-core");
867
+
868
+ // src/fragments/instructionInputResolved.ts
869
+ var import_nodes11 = require("@codama/nodes");
870
+ var import_visitors_core13 = require("@codama/visitors-core");
871
+
872
+ // src/fragments/instructionInputDefault.ts
873
+ var import_nodes10 = require("@codama/nodes");
874
+ var import_visitors_core12 = require("@codama/visitors-core");
798
875
  function getInstructionInputDefaultFragment(scope) {
799
876
  const { input, optionalAccountStrategy, asyncResolvers, useAsync, nameApi, typeManifestVisitor, getImportFrom } = scope;
800
877
  if (!input.defaultValue) {
@@ -805,8 +882,8 @@ function getInstructionInputDefaultFragment(scope) {
805
882
  }
806
883
  const { defaultValue } = input;
807
884
  const defaultFragment = (renderedValue, isWritable) => {
808
- const inputName = nodes.camelCase(input.name);
809
- if (input.kind === "instructionAccountNode" && nodes.isNode(defaultValue, "resolverValueNode")) {
885
+ const inputName = (0, import_nodes10.camelCase)(input.name);
886
+ if (input.kind === "instructionAccountNode" && (0, import_nodes10.isNode)(defaultValue, "resolverValueNode")) {
810
887
  return fragment(`accounts.${inputName} = { ...accounts.${inputName}, ...${renderedValue} };`);
811
888
  }
812
889
  if (input.kind === "instructionAccountNode" && isWritable === void 0) {
@@ -822,7 +899,7 @@ accounts.${inputName}.isWritable = ${isWritable ? "true" : "false"}`
822
899
  };
823
900
  switch (defaultValue.kind) {
824
901
  case "accountValueNode":
825
- const name = nodes.camelCase(defaultValue.name);
902
+ const name = (0, import_nodes10.camelCase)(defaultValue.name);
826
903
  if (input.kind === "instructionAccountNode" && input.resolvedIsSigner && !input.isSigner) {
827
904
  return defaultFragment(`expectTransactionSigner(accounts.${name}.value).address`).addImports(
828
905
  "shared",
@@ -834,44 +911,44 @@ accounts.${inputName}.isWritable = ${isWritable ? "true" : "false"}`
834
911
  }
835
912
  return defaultFragment(`expectAddress(accounts.${name}.value)`).addImports("shared", "expectAddress");
836
913
  case "pdaValueNode":
837
- if (nodes.isNode(defaultValue.pda, "pdaNode")) {
914
+ if ((0, import_nodes10.isNode)(defaultValue.pda, "pdaNode")) {
838
915
  const pdaProgram = defaultValue.pda.programId ? fragment(
839
916
  `'${defaultValue.pda.programId}' as Address<'${defaultValue.pda.programId}'>`
840
917
  ).addImports("solanaAddresses", "type Address") : fragment("programAddress");
841
918
  const pdaSeeds2 = defaultValue.pda.seeds.flatMap((seed) => {
842
- if (nodes.isNode(seed, "constantPdaSeedNode") && nodes.isNode(seed.value, "programIdValueNode")) {
919
+ if ((0, import_nodes10.isNode)(seed, "constantPdaSeedNode") && (0, import_nodes10.isNode)(seed.value, "programIdValueNode")) {
843
920
  return [
844
921
  fragment(`getAddressEncoder().encode(${pdaProgram.render})`).mergeImportsWith(pdaProgram).addImports("solanaAddresses", "getAddressEncoder")
845
922
  ];
846
923
  }
847
- if (nodes.isNode(seed, "constantPdaSeedNode") && !nodes.isNode(seed.value, "programIdValueNode")) {
848
- const typeManifest2 = visitorsCore.visit(seed.type, typeManifestVisitor);
849
- const valueManifest2 = visitorsCore.visit(seed.value, typeManifestVisitor);
924
+ if ((0, import_nodes10.isNode)(seed, "constantPdaSeedNode") && !(0, import_nodes10.isNode)(seed.value, "programIdValueNode")) {
925
+ const typeManifest2 = (0, import_visitors_core12.visit)(seed.type, typeManifestVisitor);
926
+ const valueManifest2 = (0, import_visitors_core12.visit)(seed.value, typeManifestVisitor);
850
927
  return [
851
928
  fragment(
852
929
  `${typeManifest2.encoder.render}.encode(${valueManifest2.value.render})`
853
930
  ).mergeImportsWith(typeManifest2.encoder, valueManifest2.value)
854
931
  ];
855
932
  }
856
- if (nodes.isNode(seed, "variablePdaSeedNode")) {
857
- const typeManifest2 = visitorsCore.visit(seed.type, typeManifestVisitor);
933
+ if ((0, import_nodes10.isNode)(seed, "variablePdaSeedNode")) {
934
+ const typeManifest2 = (0, import_visitors_core12.visit)(seed.type, typeManifestVisitor);
858
935
  const valueSeed = defaultValue.seeds.find((s) => s.name === seed.name)?.value;
859
936
  if (!valueSeed) return [];
860
- if (nodes.isNode(valueSeed, "accountValueNode")) {
937
+ if ((0, import_nodes10.isNode)(valueSeed, "accountValueNode")) {
861
938
  return [
862
939
  fragment(
863
- `${typeManifest2.encoder.render}.encode(expectAddress(accounts.${nodes.camelCase(valueSeed.name)}.value))`
940
+ `${typeManifest2.encoder.render}.encode(expectAddress(accounts.${(0, import_nodes10.camelCase)(valueSeed.name)}.value))`
864
941
  ).mergeImportsWith(typeManifest2.encoder).addImports("shared", "expectAddress")
865
942
  ];
866
943
  }
867
- if (nodes.isNode(valueSeed, "argumentValueNode")) {
944
+ if ((0, import_nodes10.isNode)(valueSeed, "argumentValueNode")) {
868
945
  return [
869
946
  fragment(
870
- `${typeManifest2.encoder.render}.encode(expectSome(args.${nodes.camelCase(valueSeed.name)}))`
947
+ `${typeManifest2.encoder.render}.encode(expectSome(args.${(0, import_nodes10.camelCase)(valueSeed.name)}))`
871
948
  ).mergeImportsWith(typeManifest2.encoder).addImports("shared", "expectSome")
872
949
  ];
873
950
  }
874
- const valueManifest2 = visitorsCore.visit(valueSeed, typeManifestVisitor);
951
+ const valueManifest2 = (0, import_visitors_core12.visit)(valueSeed, typeManifestVisitor);
875
952
  return [
876
953
  fragment(
877
954
  `${typeManifest2.encoder.render}.encode(${valueManifest2.value.render})`
@@ -889,18 +966,18 @@ accounts.${inputName}.isWritable = ${isWritable ? "true" : "false"}`
889
966
  const pdaFunction = nameApi.pdaFindFunction(defaultValue.pda.name);
890
967
  const pdaArgs = [];
891
968
  const pdaSeeds = defaultValue.seeds.map((seed) => {
892
- if (nodes.isNode(seed.value, "accountValueNode")) {
969
+ if ((0, import_nodes10.isNode)(seed.value, "accountValueNode")) {
893
970
  return fragment(
894
- `${seed.name}: expectAddress(accounts.${nodes.camelCase(seed.value.name)}.value)`
971
+ `${seed.name}: expectAddress(accounts.${(0, import_nodes10.camelCase)(seed.value.name)}.value)`
895
972
  ).addImports("shared", "expectAddress");
896
973
  }
897
- if (nodes.isNode(seed.value, "argumentValueNode")) {
898
- return fragment(`${seed.name}: expectSome(args.${nodes.camelCase(seed.value.name)})`).addImports(
974
+ if ((0, import_nodes10.isNode)(seed.value, "argumentValueNode")) {
975
+ return fragment(`${seed.name}: expectSome(args.${(0, import_nodes10.camelCase)(seed.value.name)})`).addImports(
899
976
  "shared",
900
977
  "expectSome"
901
978
  );
902
979
  }
903
- return visitorsCore.visit(seed.value, typeManifestVisitor).value.mapRender((r) => `${seed.name}: ${r}`);
980
+ return (0, import_visitors_core12.visit)(seed.value, typeManifestVisitor).value.mapRender((r) => `${seed.name}: ${r}`);
904
981
  });
905
982
  const pdaSeedsFragment = mergeFragments(pdaSeeds, (renders) => renders.join(", ")).mapRender((r) => `{ ${r} }`);
906
983
  if (pdaSeeds.length > 0) {
@@ -925,10 +1002,10 @@ accounts.${inputName}.isWritable = ${isWritable ? "true" : "false"}`
925
1002
  return fragment("");
926
1003
  case "accountBumpValueNode":
927
1004
  return defaultFragment(
928
- `expectProgramDerivedAddress(accounts.${nodes.camelCase(defaultValue.name)}.value)[1]`
1005
+ `expectProgramDerivedAddress(accounts.${(0, import_nodes10.camelCase)(defaultValue.name)}.value)[1]`
929
1006
  ).addImports("shared", "expectProgramDerivedAddress");
930
1007
  case "argumentValueNode":
931
- return defaultFragment(`expectSome(args.${nodes.camelCase(defaultValue.name)})`).addImports(
1008
+ return defaultFragment(`expectSome(args.${(0, import_nodes10.camelCase)(defaultValue.name)})`).addImports(
932
1009
  "shared",
933
1010
  "expectSome"
934
1011
  );
@@ -957,16 +1034,16 @@ accounts.${inputName}.isWritable = ${isWritable ? "true" : "false"}`
957
1034
  }
958
1035
  const negatedCondition = !ifTrueRenderer;
959
1036
  let condition = "true";
960
- if (nodes.isNode(defaultValue.condition, "resolverValueNode")) {
1037
+ if ((0, import_nodes10.isNode)(defaultValue.condition, "resolverValueNode")) {
961
1038
  const conditionalResolverFunction = nameApi.resolverFunction(defaultValue.condition.name);
962
1039
  conditionalFragment.addImports(getImportFrom(defaultValue.condition), conditionalResolverFunction).addFeatures(["instruction:resolverScopeVariable"]);
963
1040
  const conditionalResolverAwait = useAsync && asyncResolvers.includes(defaultValue.condition.name) ? "await " : "";
964
1041
  condition = `${conditionalResolverAwait}${conditionalResolverFunction}(resolverScope)`;
965
1042
  condition = negatedCondition ? `!${condition}` : condition;
966
1043
  } else {
967
- const comparedInputName = nodes.isNode(defaultValue.condition, "accountValueNode") ? `accounts.${nodes.camelCase(defaultValue.condition.name)}.value` : `args.${nodes.camelCase(defaultValue.condition.name)}`;
1044
+ const comparedInputName = (0, import_nodes10.isNode)(defaultValue.condition, "accountValueNode") ? `accounts.${(0, import_nodes10.camelCase)(defaultValue.condition.name)}.value` : `args.${(0, import_nodes10.camelCase)(defaultValue.condition.name)}`;
968
1045
  if (defaultValue.value) {
969
- const comparedValue = visitorsCore.visit(defaultValue.value, typeManifestVisitor).value;
1046
+ const comparedValue = (0, import_visitors_core12.visit)(defaultValue.value, typeManifestVisitor).value;
970
1047
  conditionalFragment.mergeImportsWith(comparedValue).mergeFeaturesWith(comparedValue);
971
1048
  const operator = negatedCondition ? "!==" : "===";
972
1049
  condition = `${comparedInputName} ${operator} ${comparedValue.render}`;
@@ -989,7 +1066,7 @@ ${ifTrueRenderer ? ifTrueRenderer.render : ifFalseRenderer?.render}
989
1066
  }`
990
1067
  );
991
1068
  default:
992
- const valueManifest = visitorsCore.visit(defaultValue, typeManifestVisitor).value;
1069
+ const valueManifest = (0, import_visitors_core12.visit)(defaultValue, typeManifestVisitor).value;
993
1070
  return defaultFragment(valueManifest.render).mergeImportsWith(valueManifest);
994
1071
  }
995
1072
  }
@@ -1004,7 +1081,7 @@ function renderNestedInstructionDefault(scope) {
1004
1081
 
1005
1082
  // src/fragments/instructionInputResolved.ts
1006
1083
  function getInstructionInputResolvedFragment(scope) {
1007
- const instructionNode = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1084
+ const instructionNode = (0, import_visitors_core13.getLastNodeFromPath)(scope.instructionPath);
1008
1085
  const resolvedInputFragments = scope.resolvedInputs.flatMap((input) => {
1009
1086
  const inputFragment = getInstructionInputDefaultFragment({
1010
1087
  ...scope,
@@ -1012,10 +1089,10 @@ function getInstructionInputResolvedFragment(scope) {
1012
1089
  optionalAccountStrategy: instructionNode.optionalAccountStrategy
1013
1090
  });
1014
1091
  if (!inputFragment.render) return [];
1015
- const camelName = nodes.camelCase(input.name);
1092
+ const camelName = (0, import_nodes11.camelCase)(input.name);
1016
1093
  return [
1017
1094
  inputFragment.mapRender(
1018
- (r) => nodes.isNode(input, "instructionArgumentNode") ? `if (!args.${camelName}) {
1095
+ (r) => (0, import_nodes11.isNode)(input, "instructionArgumentNode") ? `if (!args.${camelName}) {
1019
1096
  ${r}
1020
1097
  }` : `if (!accounts.${camelName}.value) {
1021
1098
  ${r}
@@ -1031,9 +1108,13 @@ ${r}
1031
1108
  (renders) => renders.join("\n")
1032
1109
  );
1033
1110
  }
1111
+
1112
+ // src/fragments/instructionInputType.ts
1113
+ var import_nodes12 = require("@codama/nodes");
1114
+ var import_visitors_core14 = require("@codama/visitors-core");
1034
1115
  function getInstructionInputTypeFragment(scope) {
1035
1116
  const { instructionPath, useAsync, nameApi } = scope;
1036
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1117
+ const instructionNode = (0, import_visitors_core14.getLastNodeFromPath)(instructionPath);
1037
1118
  const instructionInputType = useAsync ? nameApi.instructionAsyncInputType(instructionNode.name) : nameApi.instructionSyncInputType(instructionNode.name);
1038
1119
  const accountsFragment = getAccountsFragment(scope);
1039
1120
  const [dataArgumentsFragment, customDataArgumentsFragment] = getDataArgumentsFragments(scope);
@@ -1057,22 +1138,22 @@ function getInstructionInputTypeFragment(scope) {
1057
1138
  }
1058
1139
  function getAccountsFragment(scope) {
1059
1140
  const { instructionPath, resolvedInputs, useAsync, asyncResolvers } = scope;
1060
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1141
+ const instructionNode = (0, import_visitors_core14.getLastNodeFromPath)(instructionPath);
1061
1142
  const fragments = instructionNode.accounts.map((account) => {
1062
1143
  const resolvedAccount = resolvedInputs.find(
1063
1144
  (input) => input.kind === "instructionAccountNode" && input.name === account.name
1064
1145
  );
1065
- const hasDefaultValue = !!resolvedAccount.defaultValue && !nodes.isNode(resolvedAccount.defaultValue, ["identityValueNode", "payerValueNode"]) && (useAsync || !isAsyncDefaultValue(resolvedAccount.defaultValue, asyncResolvers));
1146
+ const hasDefaultValue = !!resolvedAccount.defaultValue && !(0, import_nodes12.isNode)(resolvedAccount.defaultValue, ["identityValueNode", "payerValueNode"]) && (useAsync || !isAsyncDefaultValue(resolvedAccount.defaultValue, asyncResolvers));
1066
1147
  const docblock = account.docs.length > 0 ? jsDocblock(account.docs) : "";
1067
1148
  const optionalSign = hasDefaultValue || resolvedAccount.isOptional ? "?" : "";
1068
1149
  return getAccountTypeFragment2(resolvedAccount).mapRender(
1069
- (r) => `${docblock}${nodes.camelCase(account.name)}${optionalSign}: ${r};`
1150
+ (r) => `${docblock}${(0, import_nodes12.camelCase)(account.name)}${optionalSign}: ${r};`
1070
1151
  );
1071
1152
  });
1072
1153
  return mergeFragments(fragments, (r) => r.join("\n"));
1073
1154
  }
1074
1155
  function getAccountTypeFragment2(account) {
1075
- const typeParam = `TAccount${nodes.pascalCase(account.name)}`;
1156
+ const typeParam = `TAccount${(0, import_nodes12.pascalCase)(account.name)}`;
1076
1157
  if (account.isPda && account.isSigner === false) {
1077
1158
  return fragment(`ProgramDerivedAddress<${typeParam}>`).addImports("solanaAddresses", [
1078
1159
  "type ProgramDerivedAddress"
@@ -1091,7 +1172,7 @@ function getAccountTypeFragment2(account) {
1091
1172
  }
1092
1173
  function getDataArgumentsFragments(scope) {
1093
1174
  const { instructionPath, nameApi } = scope;
1094
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1175
+ const instructionNode = (0, import_visitors_core14.getLastNodeFromPath)(instructionPath);
1095
1176
  const customData = scope.customInstructionData.get(instructionNode.name);
1096
1177
  if (customData) {
1097
1178
  return [
@@ -1109,7 +1190,7 @@ function getDataArgumentsFragments(scope) {
1109
1190
  }
1110
1191
  function getExtraArgumentsFragment(scope) {
1111
1192
  const { instructionPath, nameApi } = scope;
1112
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1193
+ const instructionNode = (0, import_visitors_core14.getLastNodeFromPath)(instructionPath);
1113
1194
  const instructionExtraName = nameApi.instructionExtraType(instructionNode.name);
1114
1195
  const extraArgsType = nameApi.dataArgsType(instructionExtraName);
1115
1196
  const fragments = (instructionNode.extraArguments ?? []).flatMap((arg) => {
@@ -1120,18 +1201,18 @@ function getExtraArgumentsFragment(scope) {
1120
1201
  }
1121
1202
  function getArgumentFragment(arg, argsType, resolvedInputs, renamedArgs) {
1122
1203
  const resolvedArg = resolvedInputs.find(
1123
- (input) => nodes.isNode(input, "instructionArgumentNode") && input.name === arg.name
1204
+ (input) => (0, import_nodes12.isNode)(input, "instructionArgumentNode") && input.name === arg.name
1124
1205
  );
1125
1206
  if (arg.defaultValue && arg.defaultValueStrategy === "omitted") return null;
1126
1207
  const renamedName = renamedArgs.get(arg.name) ?? arg.name;
1127
1208
  const optionalSign = arg.defaultValue || resolvedArg?.defaultValue ? "?" : "";
1128
- return argsType.mapRender((r) => `${nodes.camelCase(renamedName)}${optionalSign}: ${r}["${nodes.camelCase(arg.name)}"];`);
1209
+ return argsType.mapRender((r) => `${(0, import_nodes12.camelCase)(renamedName)}${optionalSign}: ${r}["${(0, import_nodes12.camelCase)(arg.name)}"];`);
1129
1210
  }
1130
1211
  function getRemainingAccountsFragment(instructionNode) {
1131
1212
  const fragments = (instructionNode.remainingAccounts ?? []).flatMap((remainingAccountsNode) => {
1132
- if (nodes.isNode(remainingAccountsNode.value, "resolverValueNode")) return [];
1213
+ if ((0, import_nodes12.isNode)(remainingAccountsNode.value, "resolverValueNode")) return [];
1133
1214
  const { name } = remainingAccountsNode.value;
1134
- const allArguments = nodes.getAllInstructionArguments(instructionNode);
1215
+ const allArguments = (0, import_nodes12.getAllInstructionArguments)(instructionNode);
1135
1216
  const argumentExists = allArguments.some((arg) => arg.name === name);
1136
1217
  if (argumentExists) return [];
1137
1218
  const isSigner = remainingAccountsNode.isSigner ?? false;
@@ -1143,12 +1224,16 @@ function getRemainingAccountsFragment(instructionNode) {
1143
1224
  return mergeFragments([signerFragment, addressFragment], (r) => r.join(" | "));
1144
1225
  }
1145
1226
  return isSigner ? signerFragment : addressFragment;
1146
- })().mapRender((r) => `${nodes.camelCase(name)}${optionalSign}: Array<${r}>;`);
1227
+ })().mapRender((r) => `${(0, import_nodes12.camelCase)(name)}${optionalSign}: Array<${r}>;`);
1147
1228
  });
1148
1229
  return mergeFragments(fragments, (r) => r.join("\n"));
1149
1230
  }
1231
+
1232
+ // src/fragments/instructionRemainingAccounts.ts
1233
+ var import_nodes13 = require("@codama/nodes");
1234
+ var import_visitors_core15 = require("@codama/visitors-core");
1150
1235
  function getInstructionRemainingAccountsFragment(scope) {
1151
- const { remainingAccounts } = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1236
+ const { remainingAccounts } = (0, import_visitors_core15.getLastNodeFromPath)(scope.instructionPath);
1152
1237
  const fragments = (remainingAccounts ?? []).flatMap((r) => getRemainingAccountsFragment2(r, scope));
1153
1238
  if (fragments.length === 0) return fragment("");
1154
1239
  return mergeFragments(
@@ -1159,10 +1244,10 @@ const remainingAccounts: IAccountMeta[] = ${r.length === 1 ? r[0] : `[...${r.joi
1159
1244
  }
1160
1245
  function getRemainingAccountsFragment2(remainingAccounts, scope) {
1161
1246
  const remainingAccountsFragment = (() => {
1162
- if (nodes.isNode(remainingAccounts.value, "argumentValueNode")) {
1247
+ if ((0, import_nodes13.isNode)(remainingAccounts.value, "argumentValueNode")) {
1163
1248
  return getArgumentValueNodeFragment2(remainingAccounts, scope);
1164
1249
  }
1165
- if (nodes.isNode(remainingAccounts.value, "resolverValueNode")) {
1250
+ if ((0, import_nodes13.isNode)(remainingAccounts.value, "resolverValueNode")) {
1166
1251
  return getResolverValueNodeFragment2(remainingAccounts, scope);
1167
1252
  }
1168
1253
  return null;
@@ -1171,9 +1256,9 @@ function getRemainingAccountsFragment2(remainingAccounts, scope) {
1171
1256
  return [remainingAccountsFragment];
1172
1257
  }
1173
1258
  function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1174
- const instructionNode = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1175
- nodes.assertIsNode(remainingAccounts.value, "argumentValueNode");
1176
- const argumentName = nodes.camelCase(remainingAccounts.value.name);
1259
+ const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(scope.instructionPath);
1260
+ (0, import_nodes13.assertIsNode)(remainingAccounts.value, "argumentValueNode");
1261
+ const argumentName = (0, import_nodes13.camelCase)(remainingAccounts.value.name);
1177
1262
  const isOptional = remainingAccounts.isOptional ?? false;
1178
1263
  const isSigner = remainingAccounts.isSigner ?? false;
1179
1264
  const isWritable = remainingAccounts.isWritable ?? false;
@@ -1181,7 +1266,7 @@ function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1181
1266
  const signerRole = isWritable ? "AccountRole.WRITABLE_SIGNER" : "AccountRole.READONLY_SIGNER";
1182
1267
  const role = isSigner === true ? signerRole : nonSignerRole;
1183
1268
  const argumentArray = isOptional ? `(args.${argumentName} ?? [])` : `args.${argumentName}`;
1184
- const allArguments = nodes.getAllInstructionArguments(instructionNode);
1269
+ const allArguments = (0, import_nodes13.getAllInstructionArguments)(instructionNode);
1185
1270
  const argumentExists = allArguments.some((arg) => arg.name === remainingAccounts.value.name);
1186
1271
  if (argumentExists || isSigner === false) {
1187
1272
  return fragment(`${argumentArray}.map((address) => ({ address, role: ${role} }))`).addImports(
@@ -1202,7 +1287,7 @@ function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1202
1287
  ).addImports("solanaInstructions", ["AccountRole"]);
1203
1288
  }
1204
1289
  function getResolverValueNodeFragment2(remainingAccounts, scope) {
1205
- nodes.assertIsNode(remainingAccounts.value, "resolverValueNode");
1290
+ (0, import_nodes13.assertIsNode)(remainingAccounts.value, "resolverValueNode");
1206
1291
  const isAsync = scope.asyncResolvers.includes(remainingAccounts.value.name);
1207
1292
  if (!scope.useAsync && isAsync) return null;
1208
1293
  const awaitKeyword = scope.useAsync && isAsync ? "await " : "";
@@ -1222,8 +1307,8 @@ function getInstructionFunctionFragment(scope) {
1222
1307
  nameApi,
1223
1308
  customInstructionData
1224
1309
  } = scope;
1225
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1226
- const programNode = visitorsCore.findProgramNodeFromPath(instructionPath);
1310
+ const instructionNode = (0, import_visitors_core16.getLastNodeFromPath)(instructionPath);
1311
+ const programNode = (0, import_visitors_core16.findProgramNodeFromPath)(instructionPath);
1227
1312
  if (useAsync && !hasAsyncFunction(instructionNode, resolvedInputs, asyncResolvers)) {
1228
1313
  return fragment("");
1229
1314
  }
@@ -1231,7 +1316,7 @@ function getInstructionFunctionFragment(scope) {
1231
1316
  const hasAccounts = instructionNode.accounts.length > 0;
1232
1317
  const hasLegacyOptionalAccounts = instructionNode.optionalAccountStrategy === "omitted" && instructionNode.accounts.some((account) => account.isOptional);
1233
1318
  const instructionDependencies = getInstructionDependencies(instructionNode, asyncResolvers, useAsync);
1234
- const argDependencies = instructionDependencies.filter(nodes.isNodeFilter("argumentValueNode")).map((node) => node.name);
1319
+ const argDependencies = instructionDependencies.filter((0, import_nodes14.isNodeFilter)("argumentValueNode")).map((node) => node.name);
1235
1320
  const hasData = !!customData || instructionNode.arguments.length > 0;
1236
1321
  const argIsNotOmitted = (arg) => !(arg.defaultValue && arg.defaultValueStrategy === "omitted");
1237
1322
  const argIsDependent = (arg) => argDependencies.includes(arg.name);
@@ -1244,7 +1329,7 @@ function getInstructionFunctionFragment(scope) {
1244
1329
  const hasExtraArgs = (instructionNode.extraArguments ?? []).filter(
1245
1330
  (field) => argIsNotOmitted(field) && (argIsDependent(field) || argHasDefaultValue(field))
1246
1331
  ).length > 0;
1247
- const hasRemainingAccountArgs = (instructionNode.remainingAccounts ?? []).filter(({ value }) => nodes.isNode(value, "argumentValueNode")).length > 0;
1332
+ const hasRemainingAccountArgs = (instructionNode.remainingAccounts ?? []).filter(({ value }) => (0, import_nodes14.isNode)(value, "argumentValueNode")).length > 0;
1248
1333
  const hasAnyArgs = hasDataArgs || hasExtraArgs || hasRemainingAccountArgs;
1249
1334
  const hasInput = hasAccounts || hasAnyArgs;
1250
1335
  const instructionDataName = nameApi.instructionDataType(instructionNode.name);
@@ -1320,18 +1405,18 @@ function getInstructionFunctionFragment(scope) {
1320
1405
  return functionFragment;
1321
1406
  }
1322
1407
  function getTypeParams(instructionNode, programAddressConstant) {
1323
- const typeParams = instructionNode.accounts.map((account) => `TAccount${nodes.pascalCase(account.name)} extends string`);
1408
+ const typeParams = instructionNode.accounts.map((account) => `TAccount${(0, import_nodes14.pascalCase)(account.name)} extends string`);
1324
1409
  typeParams.push(`TProgramAddress extends Address = typeof ${programAddressConstant}`);
1325
1410
  return fragment(typeParams.filter((x) => !!x).join(", ")).mapRender((r) => `<${r}>`).addImports("generatedPrograms", [programAddressConstant]);
1326
1411
  }
1327
1412
  function getInstructionType(scope) {
1328
1413
  const { instructionPath, nameApi } = scope;
1329
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1414
+ const instructionNode = (0, import_visitors_core16.getLastNodeFromPath)(instructionPath);
1330
1415
  const instructionTypeName = nameApi.instructionType(instructionNode.name);
1331
1416
  const programAddressFragment = fragment("TProgramAddress");
1332
1417
  const accountTypeParamsFragments = instructionNode.accounts.map((account) => {
1333
- const typeParam = `TAccount${nodes.pascalCase(account.name)}`;
1334
- const camelName = nodes.camelCase(account.name);
1418
+ const typeParam = `TAccount${(0, import_nodes14.pascalCase)(account.name)}`;
1419
+ const camelName = (0, import_nodes14.camelCase)(account.name);
1335
1420
  if (account.isSigner === "either") {
1336
1421
  const signerRole = account.isWritable ? "WritableSignerAccount" : "ReadonlySignerAccount";
1337
1422
  return fragment(
@@ -1347,16 +1432,19 @@ function getInstructionType(scope) {
1347
1432
  }
1348
1433
  function getInputTypeCall(scope) {
1349
1434
  const { instructionPath, useAsync, nameApi } = scope;
1350
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1435
+ const instructionNode = (0, import_visitors_core16.getLastNodeFromPath)(instructionPath);
1351
1436
  const inputTypeName = useAsync ? nameApi.instructionAsyncInputType(instructionNode.name) : nameApi.instructionSyncInputType(instructionNode.name);
1352
1437
  if (instructionNode.accounts.length === 0) return fragment(inputTypeName);
1353
- const accountTypeParams = instructionNode.accounts.map((account) => `TAccount${nodes.pascalCase(account.name)}`).join(", ");
1438
+ const accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0, import_nodes14.pascalCase)(account.name)}`).join(", ");
1354
1439
  return fragment(`${inputTypeName}<${accountTypeParams}>`);
1355
1440
  }
1441
+
1442
+ // src/fragments/instructionParseFunction.ts
1443
+ var import_visitors_core17 = require("@codama/visitors-core");
1356
1444
  function getInstructionParseFunctionFragment(scope) {
1357
1445
  const { instructionPath, dataArgsManifest, nameApi, customInstructionData } = scope;
1358
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1359
- const programNode = visitorsCore.findProgramNodeFromPath(instructionPath);
1446
+ const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
1447
+ const programNode = (0, import_visitors_core17.findProgramNodeFromPath)(instructionPath);
1360
1448
  const customData = customInstructionData.get(instructionNode.name);
1361
1449
  const hasAccounts = instructionNode.accounts.length > 0;
1362
1450
  const hasOptionalAccounts = instructionNode.accounts.some((account) => account.isOptional);
@@ -1384,20 +1472,25 @@ function getInstructionParseFunctionFragment(scope) {
1384
1472
  programAddressConstant
1385
1473
  }).mergeImportsWith(dataTypeFragment).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaInstructions", ["type IInstruction"]).addImports("solanaInstructions", hasAccounts ? ["type IInstructionWithAccounts", "type IAccountMeta"] : []).addImports("solanaInstructions", hasData ? ["type IInstructionWithData"] : []);
1386
1474
  }
1475
+
1476
+ // src/fragments/instructionType.ts
1477
+ var import_nodes15 = require("@codama/nodes");
1478
+ var import_visitors_core18 = require("@codama/visitors-core");
1387
1479
  function getInstructionTypeFragment(scope) {
1388
1480
  const { instructionPath, nameApi, customInstructionData } = scope;
1389
- const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1390
- const programNode = visitorsCore.findProgramNodeFromPath(instructionPath);
1481
+ const instructionNode = (0, import_visitors_core18.getLastNodeFromPath)(instructionPath);
1482
+ const programNode = (0, import_visitors_core18.findProgramNodeFromPath)(instructionPath);
1391
1483
  const hasAccounts = instructionNode.accounts.length > 0;
1392
1484
  const customData = customInstructionData.get(instructionNode.name);
1393
1485
  const hasData = !!customData || instructionNode.arguments.length > 0;
1394
1486
  const instructionDataName = nameApi.instructionDataType(instructionNode.name);
1395
1487
  const programAddressConstant = nameApi.programAddressConstant(programNode.name);
1396
- const dataType = customData ? nodes.pascalCase(customData.importAs) : nodes.pascalCase(instructionDataName);
1488
+ const dataType = customData ? (0, import_nodes15.pascalCase)(customData.importAs) : (0, import_nodes15.pascalCase)(instructionDataName);
1397
1489
  const accountTypeParamsFragment = mergeFragments(
1398
1490
  instructionNode.accounts.map(
1399
1491
  (account) => getInstructionAccountTypeParamFragment({
1400
1492
  ...scope,
1493
+ allowAccountMeta: true,
1401
1494
  instructionAccountPath: [...instructionPath, account]
1402
1495
  })
1403
1496
  ),
@@ -1407,7 +1500,7 @@ function getInstructionTypeFragment(scope) {
1407
1500
  const accountMetasFragment = mergeFragments(
1408
1501
  instructionNode.accounts.map(
1409
1502
  (account) => getInstructionAccountMetaFragment(account).mapRender((r) => {
1410
- const typeParam = `TAccount${nodes.pascalCase(account.name)}`;
1503
+ const typeParam = `TAccount${(0, import_nodes15.pascalCase)(account.name)}`;
1411
1504
  const isLegacyOptional = account.isOptional && usesLegacyOptionalAccounts;
1412
1505
  const type = `${typeParam} extends string ? ${r} : ${typeParam}`;
1413
1506
  if (!isLegacyOptional) return type;
@@ -1433,28 +1526,32 @@ function getInstructionTypeFragment(scope) {
1433
1526
  ]);
1434
1527
  return fragment2;
1435
1528
  }
1529
+
1530
+ // src/fragments/pdaFunction.ts
1531
+ var import_nodes16 = require("@codama/nodes");
1532
+ var import_visitors_core19 = require("@codama/visitors-core");
1436
1533
  function getPdaFunctionFragment(scope) {
1437
1534
  const { pdaPath, typeManifestVisitor, nameApi } = scope;
1438
- const pdaNode = visitorsCore.getLastNodeFromPath(pdaPath);
1439
- const programNode = visitorsCore.findProgramNodeFromPath(pdaPath);
1535
+ const pdaNode = (0, import_visitors_core19.getLastNodeFromPath)(pdaPath);
1536
+ const programNode = (0, import_visitors_core19.findProgramNodeFromPath)(pdaPath);
1440
1537
  const imports = new ImportMap();
1441
1538
  const seeds = pdaNode.seeds.map((seed) => {
1442
- if (nodes.isNode(seed, "variablePdaSeedNode")) {
1443
- const seedManifest2 = visitorsCore.visit(seed.type, typeManifestVisitor);
1539
+ if ((0, import_nodes16.isNode)(seed, "variablePdaSeedNode")) {
1540
+ const seedManifest2 = (0, import_visitors_core19.visit)(seed.type, typeManifestVisitor);
1444
1541
  imports.mergeWith(seedManifest2.looseType, seedManifest2.encoder);
1445
1542
  return { ...seed, typeManifest: seedManifest2 };
1446
1543
  }
1447
- if (nodes.isNode(seed.value, "programIdValueNode")) {
1544
+ if ((0, import_nodes16.isNode)(seed.value, "programIdValueNode")) {
1448
1545
  imports.add("solanaAddresses", "getAddressEncoder");
1449
1546
  return seed;
1450
1547
  }
1451
- const seedManifest = visitorsCore.visit(seed.type, typeManifestVisitor);
1548
+ const seedManifest = (0, import_visitors_core19.visit)(seed.type, typeManifestVisitor);
1452
1549
  imports.mergeWith(seedManifest.encoder);
1453
- const valueManifest = visitorsCore.visit(seed.value, typeManifestVisitor).value;
1550
+ const valueManifest = (0, import_visitors_core19.visit)(seed.value, typeManifestVisitor).value;
1454
1551
  imports.mergeWith(valueManifest.imports);
1455
1552
  return { ...seed, typeManifest: seedManifest, valueManifest };
1456
1553
  });
1457
- const hasVariableSeeds = pdaNode.seeds.filter(nodes.isNodeFilter("variablePdaSeedNode")).length > 0;
1554
+ const hasVariableSeeds = pdaNode.seeds.filter((0, import_nodes16.isNodeFilter)("variablePdaSeedNode")).length > 0;
1458
1555
  return fragmentFromTemplate("pdaFunction.njk", {
1459
1556
  findPdaFunction: nameApi.pdaFindFunction(pdaNode.name),
1460
1557
  hasVariableSeeds,
@@ -1472,6 +1569,9 @@ function getProgramFragment(scope) {
1472
1569
  programAddressConstant: nameApi.programAddressConstant(programNode.name)
1473
1570
  }).addImports("solanaAddresses", ["type Address"]);
1474
1571
  }
1572
+
1573
+ // src/fragments/programAccounts.ts
1574
+ var import_nodes17 = require("@codama/nodes");
1475
1575
  function getProgramAccountsFragment(scope) {
1476
1576
  if (scope.programNode.accounts.length === 0) return fragment("");
1477
1577
  return mergeFragments(
@@ -1505,7 +1605,7 @@ function getProgramAccountsIdentifierFunctionFragment(scope) {
1505
1605
  dataName: "data",
1506
1606
  discriminators: account.discriminators ?? [],
1507
1607
  ifTrue: `return ${programAccountsEnum}.${variant};`,
1508
- struct: nodes.resolveNestedTypeNode(account.data)
1608
+ struct: (0, import_nodes17.resolveNestedTypeNode)(account.data)
1509
1609
  });
1510
1610
  }),
1511
1611
  (r) => r.join("\n")
@@ -1533,9 +1633,12 @@ function getProgramErrorsFragment(scope) {
1533
1633
  programIsErrorFunction: nameApi.programIsErrorFunction(programNode.name)
1534
1634
  }).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaPrograms", ["isProgramError"]).addImports("solanaErrors", ["type SolanaError", "type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM"]).addImports("solanaAddresses", ["type Address"]);
1535
1635
  }
1636
+
1637
+ // src/fragments/programInstructions.ts
1638
+ var import_nodes18 = require("@codama/nodes");
1536
1639
  function getProgramInstructionsFragment(scope) {
1537
1640
  if (scope.programNode.instructions.length === 0) return fragment("");
1538
- const allInstructions = nodes.getAllInstructionsWithSubs(scope.programNode, {
1641
+ const allInstructions = (0, import_nodes18.getAllInstructionsWithSubs)(scope.programNode, {
1539
1642
  leavesOnly: !scope.renderParentInstructions,
1540
1643
  subInstructionsFirst: true
1541
1644
  });
@@ -1577,7 +1680,7 @@ function getProgramInstructionsIdentifierFunctionFragment(scope) {
1577
1680
  dataName: "data",
1578
1681
  discriminators: instruction.discriminators ?? [],
1579
1682
  ifTrue: `return ${programInstructionsEnum}.${variant};`,
1580
- struct: nodes.structTypeNodeFromInstructionArgumentNodes(instruction.arguments)
1683
+ struct: (0, import_nodes18.structTypeNodeFromInstructionArgumentNodes)(instruction.arguments)
1581
1684
  });
1582
1685
  }),
1583
1686
  (r) => r.join("\n")
@@ -1610,9 +1713,12 @@ function getProgramInstructionsParsedUnionTypeFragment(scope) {
1610
1713
  (r) => r.join("\n")
1611
1714
  );
1612
1715
  }
1716
+
1717
+ // src/fragments/typeDiscriminatedUnionHelpers.ts
1718
+ var import_nodes19 = require("@codama/nodes");
1613
1719
  function getTypeDiscriminatedUnionHelpersFragment(scope) {
1614
1720
  const { name, typeNode, nameApi } = scope;
1615
- const isDiscriminatedUnion = nodes.isNode(typeNode, "enumTypeNode") && nodes.isDataEnum(typeNode);
1721
+ const isDiscriminatedUnion = (0, import_nodes19.isNode)(typeNode, "enumTypeNode") && (0, import_nodes19.isDataEnum)(typeNode);
1616
1722
  if (!isDiscriminatedUnion) {
1617
1723
  return fragment("");
1618
1724
  }
@@ -1653,12 +1759,23 @@ function mergeManifests(manifests, options = {}) {
1653
1759
  value: merge((m) => m.value, mergeValues)
1654
1760
  };
1655
1761
  }
1762
+
1763
+ // src/getRenderMapVisitor.ts
1764
+ var import_node_path3 = require("path");
1765
+ var import_errors2 = require("@codama/errors");
1766
+ var import_nodes22 = require("@codama/nodes");
1767
+ var import_renderers_core = require("@codama/renderers-core");
1768
+ var import_visitors_core21 = require("@codama/visitors-core");
1769
+
1770
+ // src/getTypeManifestVisitor.ts
1771
+ var import_nodes20 = require("@codama/nodes");
1772
+ var import_visitors_core20 = require("@codama/visitors-core");
1656
1773
  function getTypeManifestVisitor(input) {
1657
1774
  const { nameApi, linkables, nonScalarEnums, customAccountData, customInstructionData, getImportFrom } = input;
1658
- const stack = input.stack ?? new visitorsCore.NodeStack();
1775
+ const stack = input.stack ?? new import_visitors_core20.NodeStack();
1659
1776
  let parentName = null;
1660
- return visitorsCore.pipe(
1661
- visitorsCore.staticVisitor(
1777
+ return (0, import_visitors_core20.pipe)(
1778
+ (0, import_visitors_core20.staticVisitor)(
1662
1779
  () => ({
1663
1780
  decoder: fragment(""),
1664
1781
  encoder: fragment(""),
@@ -1669,8 +1786,8 @@ function getTypeManifestVisitor(input) {
1669
1786
  }),
1670
1787
  {
1671
1788
  keys: [
1672
- ...nodes.REGISTERED_TYPE_NODE_KINDS,
1673
- ...nodes.REGISTERED_VALUE_NODE_KINDS,
1789
+ ...import_nodes20.REGISTERED_TYPE_NODE_KINDS,
1790
+ ...import_nodes20.REGISTERED_VALUE_NODE_KINDS,
1674
1791
  "definedTypeLinkNode",
1675
1792
  "definedTypeNode",
1676
1793
  "accountNode",
@@ -1678,22 +1795,22 @@ function getTypeManifestVisitor(input) {
1678
1795
  ]
1679
1796
  }
1680
1797
  ),
1681
- (visitor) => visitorsCore.extendVisitor(visitor, {
1798
+ (visitor) => (0, import_visitors_core20.extendVisitor)(visitor, {
1682
1799
  visitAccount(account, { self }) {
1683
1800
  parentName = {
1684
1801
  loose: nameApi.dataArgsType(account.name),
1685
1802
  strict: nameApi.dataType(account.name)
1686
1803
  };
1687
1804
  const link = customAccountData.get(account.name)?.linkNode;
1688
- const manifest = link ? visitorsCore.visit(link, self) : visitorsCore.visit(account.data, self);
1805
+ const manifest = link ? (0, import_visitors_core20.visit)(link, self) : (0, import_visitors_core20.visit)(account.data, self);
1689
1806
  parentName = null;
1690
1807
  return manifest;
1691
1808
  },
1692
1809
  visitAmountType(amountType, { self }) {
1693
- return visitorsCore.visit(amountType.number, self);
1810
+ return (0, import_visitors_core20.visit)(amountType.number, self);
1694
1811
  },
1695
1812
  visitArrayType(arrayType, { self }) {
1696
- const childManifest = visitorsCore.visit(arrayType.item, self);
1813
+ const childManifest = (0, import_visitors_core20.visit)(arrayType.item, self);
1697
1814
  childManifest.looseType.mapRender((r) => `Array<${r}>`);
1698
1815
  childManifest.strictType.mapRender((r) => `Array<${r}>`);
1699
1816
  const sizeManifest = getArrayLikeSizeOption(arrayType.count, self);
@@ -1705,7 +1822,7 @@ function getTypeManifestVisitor(input) {
1705
1822
  },
1706
1823
  visitArrayValue(node, { self }) {
1707
1824
  return mergeManifests(
1708
- node.items.map((v) => visitorsCore.visit(v, self)),
1825
+ node.items.map((v) => (0, import_visitors_core20.visit)(v, self)),
1709
1826
  { mergeValues: (renders) => `[${renders.join(", ")}]` }
1710
1827
  );
1711
1828
  },
@@ -1714,9 +1831,9 @@ function getTypeManifestVisitor(input) {
1714
1831
  const decoderImports = new ImportMap().add("solanaCodecsDataStructures", "getBooleanDecoder");
1715
1832
  let sizeEncoder = "";
1716
1833
  let sizeDecoder = "";
1717
- const resolvedSize = nodes.resolveNestedTypeNode(booleanType.size);
1834
+ const resolvedSize = (0, import_nodes20.resolveNestedTypeNode)(booleanType.size);
1718
1835
  if (resolvedSize.format !== "u8" || resolvedSize.endian !== "le") {
1719
- const size = visitorsCore.visit(booleanType.size, self);
1836
+ const size = (0, import_visitors_core20.visit)(booleanType.size, self);
1720
1837
  encoderImports.mergeWith(size.encoder);
1721
1838
  decoderImports.mergeWith(size.decoder);
1722
1839
  sizeEncoder = `{ size: ${size.encoder.render} }`;
@@ -1765,26 +1882,26 @@ function getTypeManifestVisitor(input) {
1765
1882
  return manifest;
1766
1883
  },
1767
1884
  visitConstantValue(node, { self }) {
1768
- if (nodes.isNode(node.type, "bytesTypeNode") && nodes.isNode(node.value, "bytesValueNode")) {
1769
- return visitorsCore.visit(node.value, self);
1885
+ if ((0, import_nodes20.isNode)(node.type, "bytesTypeNode") && (0, import_nodes20.isNode)(node.value, "bytesValueNode")) {
1886
+ return (0, import_visitors_core20.visit)(node.value, self);
1770
1887
  }
1771
1888
  return {
1772
1889
  ...typeManifest(),
1773
1890
  value: mergeFragments(
1774
- [visitorsCore.visit(node.type, self).encoder, visitorsCore.visit(node.value, self).value],
1891
+ [(0, import_visitors_core20.visit)(node.type, self).encoder, (0, import_visitors_core20.visit)(node.value, self).value],
1775
1892
  ([encoderFunction, value]) => `${encoderFunction}.encode(${value})`
1776
1893
  )
1777
1894
  };
1778
1895
  },
1779
1896
  visitDateTimeType(dateTimeType, { self }) {
1780
- return visitorsCore.visit(dateTimeType.number, self);
1897
+ return (0, import_visitors_core20.visit)(dateTimeType.number, self);
1781
1898
  },
1782
1899
  visitDefinedType(definedType, { self }) {
1783
1900
  parentName = {
1784
1901
  loose: nameApi.dataArgsType(definedType.name),
1785
1902
  strict: nameApi.dataType(definedType.name)
1786
1903
  };
1787
- const manifest = visitorsCore.visit(definedType.type, self);
1904
+ const manifest = (0, import_visitors_core20.visit)(definedType.type, self);
1788
1905
  parentName = null;
1789
1906
  return manifest;
1790
1907
  },
@@ -1804,7 +1921,7 @@ function getTypeManifestVisitor(input) {
1804
1921
  };
1805
1922
  },
1806
1923
  visitEnumEmptyVariantType(enumEmptyVariantType) {
1807
- const discriminator = nameApi.discriminatedUnionDiscriminator(nodes.camelCase(parentName?.strict ?? ""));
1924
+ const discriminator = nameApi.discriminatedUnionDiscriminator((0, import_nodes20.camelCase)(parentName?.strict ?? ""));
1808
1925
  const name = nameApi.discriminatedUnionVariant(enumEmptyVariantType.name);
1809
1926
  const kindAttribute = `${discriminator}: "${name}"`;
1810
1927
  return {
@@ -1825,12 +1942,12 @@ function getTypeManifestVisitor(input) {
1825
1942
  visitEnumStructVariantType(enumStructVariantType, { self }) {
1826
1943
  const currentParentName = parentName;
1827
1944
  const discriminator = nameApi.discriminatedUnionDiscriminator(
1828
- nodes.camelCase(currentParentName?.strict ?? "")
1945
+ (0, import_nodes20.camelCase)(currentParentName?.strict ?? "")
1829
1946
  );
1830
1947
  const name = nameApi.discriminatedUnionVariant(enumStructVariantType.name);
1831
1948
  const kindAttribute = `${discriminator}: "${name}"`;
1832
1949
  parentName = null;
1833
- const structManifest = visitorsCore.visit(enumStructVariantType.struct, self);
1950
+ const structManifest = (0, import_visitors_core20.visit)(enumStructVariantType.struct, self);
1834
1951
  parentName = currentParentName;
1835
1952
  structManifest.strictType.mapRender((r) => `{ ${kindAttribute},${r.slice(1, -1)}}`);
1836
1953
  structManifest.looseType.mapRender((r) => `{ ${kindAttribute},${r.slice(1, -1)}}`);
@@ -1841,18 +1958,18 @@ function getTypeManifestVisitor(input) {
1841
1958
  visitEnumTupleVariantType(enumTupleVariantType, { self }) {
1842
1959
  const currentParentName = parentName;
1843
1960
  const discriminator = nameApi.discriminatedUnionDiscriminator(
1844
- nodes.camelCase(currentParentName?.strict ?? "")
1961
+ (0, import_nodes20.camelCase)(currentParentName?.strict ?? "")
1845
1962
  );
1846
1963
  const name = nameApi.discriminatedUnionVariant(enumTupleVariantType.name);
1847
1964
  const kindAttribute = `${discriminator}: "${name}"`;
1848
- const struct = nodes.structTypeNode([
1849
- nodes.structFieldTypeNode({
1965
+ const struct = (0, import_nodes20.structTypeNode)([
1966
+ (0, import_nodes20.structFieldTypeNode)({
1850
1967
  name: "fields",
1851
1968
  type: enumTupleVariantType.tuple
1852
1969
  })
1853
1970
  ]);
1854
1971
  parentName = null;
1855
- const structManifest = visitorsCore.visit(struct, self);
1972
+ const structManifest = (0, import_visitors_core20.visit)(struct, self);
1856
1973
  parentName = currentParentName;
1857
1974
  structManifest.strictType.mapRender((r) => `{ ${kindAttribute},${r.slice(1, -1)}}`);
1858
1975
  structManifest.looseType.mapRender((r) => `{ ${kindAttribute},${r.slice(1, -1)}}`);
@@ -1866,24 +1983,24 @@ function getTypeManifestVisitor(input) {
1866
1983
  const decoderImports = new ImportMap();
1867
1984
  const encoderOptions = [];
1868
1985
  const decoderOptions = [];
1869
- const enumSize = nodes.resolveNestedTypeNode(enumType.size);
1986
+ const enumSize = (0, import_nodes20.resolveNestedTypeNode)(enumType.size);
1870
1987
  if (enumSize.format !== "u8" || enumSize.endian !== "le") {
1871
- const sizeManifest = visitorsCore.visit(enumType.size, self);
1988
+ const sizeManifest = (0, import_visitors_core20.visit)(enumType.size, self);
1872
1989
  encoderImports.mergeWith(sizeManifest.encoder);
1873
1990
  decoderImports.mergeWith(sizeManifest.decoder);
1874
1991
  encoderOptions.push(`size: ${sizeManifest.encoder.render}`);
1875
1992
  decoderOptions.push(`size: ${sizeManifest.decoder.render}`);
1876
1993
  }
1877
1994
  const discriminator = nameApi.discriminatedUnionDiscriminator(
1878
- nodes.camelCase(currentParentName?.strict ?? "")
1995
+ (0, import_nodes20.camelCase)(currentParentName?.strict ?? "")
1879
1996
  );
1880
- if (!nodes.isScalarEnum(enumType) && discriminator !== "__kind") {
1997
+ if (!(0, import_nodes20.isScalarEnum)(enumType) && discriminator !== "__kind") {
1881
1998
  encoderOptions.push(`discriminator: '${discriminator}'`);
1882
1999
  decoderOptions.push(`discriminator: '${discriminator}'`);
1883
2000
  }
1884
2001
  const encoderOptionsAsString = encoderOptions.length > 0 ? `, { ${encoderOptions.join(", ")} }` : "";
1885
2002
  const decoderOptionsAsString = decoderOptions.length > 0 ? `, { ${decoderOptions.join(", ")} }` : "";
1886
- if (nodes.isScalarEnum(enumType)) {
2003
+ if ((0, import_nodes20.isScalarEnum)(enumType)) {
1887
2004
  if (currentParentName === null) {
1888
2005
  throw new Error(
1889
2006
  "Scalar enums cannot be inlined and must be introduced via a defined type. Ensure you are not inlining a defined type that is a scalar enum through a visitor."
@@ -1906,7 +2023,7 @@ function getTypeManifestVisitor(input) {
1906
2023
  };
1907
2024
  }
1908
2025
  const mergedManifest = mergeManifests(
1909
- enumType.variants.map((variant) => visitorsCore.visit(variant, self)),
2026
+ enumType.variants.map((variant) => (0, import_visitors_core20.visit)(variant, self)),
1910
2027
  {
1911
2028
  mergeCodecs: (renders) => renders.join(", "),
1912
2029
  mergeTypes: (renders) => renders.join(" | ")
@@ -1922,7 +2039,7 @@ function getTypeManifestVisitor(input) {
1922
2039
  const enumFunction = nameApi.discriminatedUnionFunction(node.enum.name);
1923
2040
  const importFrom = getImportFrom(node.enum);
1924
2041
  const enumNode = linkables.get([...stack.getPath(), node.enum])?.type;
1925
- const isScalar = enumNode && nodes.isNode(enumNode, "enumTypeNode") ? nodes.isScalarEnum(enumNode) : !nonScalarEnums.includes(node.enum.name);
2042
+ const isScalar = enumNode && (0, import_nodes20.isNode)(enumNode, "enumTypeNode") ? (0, import_nodes20.isScalarEnum)(enumNode) : !nonScalarEnums.includes(node.enum.name);
1926
2043
  if (!node.value && isScalar) {
1927
2044
  const variantName2 = nameApi.enumVariant(node.variant);
1928
2045
  manifest.value.setRender(`${enumName}.${variantName2}`).addImports(importFrom, enumName);
@@ -1933,18 +2050,18 @@ function getTypeManifestVisitor(input) {
1933
2050
  manifest.value.setRender(`${enumFunction}('${variantName}')`).addImports(importFrom, enumFunction);
1934
2051
  return manifest;
1935
2052
  }
1936
- manifest.value = visitorsCore.visit(node.value, self).value.mapRender((r) => `${enumFunction}('${variantName}', ${r})`).addImports(importFrom, enumFunction);
2053
+ manifest.value = (0, import_visitors_core20.visit)(node.value, self).value.mapRender((r) => `${enumFunction}('${variantName}', ${r})`).addImports(importFrom, enumFunction);
1937
2054
  return manifest;
1938
2055
  },
1939
2056
  visitFixedSizeType(node, { self }) {
1940
- const manifest = visitorsCore.visit(node.type, self);
2057
+ const manifest = (0, import_visitors_core20.visit)(node.type, self);
1941
2058
  manifest.encoder.mapRender((r) => `fixEncoderSize(${r}, ${node.size})`).addImports("solanaCodecsCore", "fixEncoderSize");
1942
2059
  manifest.decoder.mapRender((r) => `fixDecoderSize(${r}, ${node.size})`).addImports("solanaCodecsCore", "fixDecoderSize");
1943
2060
  return manifest;
1944
2061
  },
1945
2062
  visitHiddenPrefixType(node, { self }) {
1946
- const manifest = visitorsCore.visit(node.type, self);
1947
- const prefixes = node.prefix.map((c) => visitorsCore.visit(c, self).value);
2063
+ const manifest = (0, import_visitors_core20.visit)(node.type, self);
2064
+ const prefixes = node.prefix.map((c) => (0, import_visitors_core20.visit)(c, self).value);
1948
2065
  const prefixEncoders = fragment(prefixes.map((c) => `getConstantEncoder(${c.render})`).join(", ")).addImports("solanaCodecsCore", "getConstantEncoder").mergeImportsWith(...prefixes);
1949
2066
  const prefixDecoders = fragment(prefixes.map((c) => `getConstantDecoder(${c.render})`).join(", ")).addImports("solanaCodecsCore", "getConstantDecoder").mergeImportsWith(...prefixes);
1950
2067
  manifest.encoder.mapRender((r) => `getHiddenPrefixEncoder(${r}, [${prefixEncoders.render}])`).mergeImportsWith(prefixEncoders).addImports("solanaCodecsDataStructures", "getHiddenPrefixEncoder");
@@ -1952,8 +2069,8 @@ function getTypeManifestVisitor(input) {
1952
2069
  return manifest;
1953
2070
  },
1954
2071
  visitHiddenSuffixType(node, { self }) {
1955
- const manifest = visitorsCore.visit(node.type, self);
1956
- const suffixes = node.suffix.map((c) => visitorsCore.visit(c, self).value);
2072
+ const manifest = (0, import_visitors_core20.visit)(node.type, self);
2073
+ const suffixes = node.suffix.map((c) => (0, import_visitors_core20.visit)(c, self).value);
1957
2074
  const suffixEncoders = fragment(suffixes.map((c) => `getConstantEncoder(${c.render})`).join(", ")).addImports("solanaCodecsCore", "getConstantEncoder").mergeImportsWith(...suffixes);
1958
2075
  const suffixDecoders = fragment(suffixes.map((c) => `getConstantDecoder(${c.render})`).join(", ")).addImports("solanaCodecsCore", "getConstantDecoder").mergeImportsWith(...suffixes);
1959
2076
  manifest.encoder.mapRender((r) => `getHiddenSuffixEncoder(${r}, [${suffixEncoders.render}])`).mergeImportsWith(suffixEncoders).addImports("solanaCodecsDataStructures", "getHiddenSuffixEncoder");
@@ -1967,19 +2084,19 @@ function getTypeManifestVisitor(input) {
1967
2084
  strict: nameApi.dataType(instructionDataName)
1968
2085
  };
1969
2086
  const link = customInstructionData.get(instruction.name)?.linkNode;
1970
- const struct = nodes.structTypeNodeFromInstructionArgumentNodes(instruction.arguments);
1971
- const manifest = link ? visitorsCore.visit(link, self) : visitorsCore.visit(struct, self);
2087
+ const struct = (0, import_nodes20.structTypeNodeFromInstructionArgumentNodes)(instruction.arguments);
2088
+ const manifest = link ? (0, import_visitors_core20.visit)(link, self) : (0, import_visitors_core20.visit)(struct, self);
1972
2089
  parentName = null;
1973
2090
  return manifest;
1974
2091
  },
1975
2092
  visitMapEntryValue(node, { self }) {
1976
- return mergeManifests([visitorsCore.visit(node.key, self), visitorsCore.visit(node.value, self)], {
2093
+ return mergeManifests([(0, import_visitors_core20.visit)(node.key, self), (0, import_visitors_core20.visit)(node.value, self)], {
1977
2094
  mergeValues: (renders) => `[${renders.join(", ")}]`
1978
2095
  });
1979
2096
  },
1980
2097
  visitMapType(mapType, { self }) {
1981
- const key = visitorsCore.visit(mapType.key, self);
1982
- const value = visitorsCore.visit(mapType.value, self);
2098
+ const key = (0, import_visitors_core20.visit)(mapType.key, self);
2099
+ const value = (0, import_visitors_core20.visit)(mapType.value, self);
1983
2100
  const mergedManifest = mergeManifests([key, value], {
1984
2101
  mergeCodecs: ([k, v]) => `${k}, ${v}`,
1985
2102
  mergeTypes: ([k, v]) => `Map<${k}, ${v}>`
@@ -1992,7 +2109,7 @@ function getTypeManifestVisitor(input) {
1992
2109
  return mergedManifest;
1993
2110
  },
1994
2111
  visitMapValue(node, { self }) {
1995
- const entryFragments = node.entries.map((entry) => visitorsCore.visit(entry, self));
2112
+ const entryFragments = node.entries.map((entry) => (0, import_visitors_core20.visit)(entry, self));
1996
2113
  return mergeManifests(entryFragments, {
1997
2114
  mergeValues: (renders) => `new Map([${renders.join(", ")}])`
1998
2115
  });
@@ -2029,14 +2146,14 @@ function getTypeManifestVisitor(input) {
2029
2146
  return manifest;
2030
2147
  },
2031
2148
  visitOptionType(optionType, { self }) {
2032
- const childManifest = visitorsCore.visit(optionType.item, self);
2149
+ const childManifest = (0, import_visitors_core20.visit)(optionType.item, self);
2033
2150
  childManifest.strictType.mapRender((r) => `Option<${r}>`).addImports("solanaOptions", "type Option");
2034
2151
  childManifest.looseType.mapRender((r) => `OptionOrNullable<${r}>`).addImports("solanaOptions", "type OptionOrNullable");
2035
2152
  const encoderOptions = [];
2036
2153
  const decoderOptions = [];
2037
- const optionPrefix = nodes.resolveNestedTypeNode(optionType.prefix);
2154
+ const optionPrefix = (0, import_nodes20.resolveNestedTypeNode)(optionType.prefix);
2038
2155
  if (optionPrefix.format !== "u8" || optionPrefix.endian !== "le") {
2039
- const prefixManifest = visitorsCore.visit(optionType.prefix, self);
2156
+ const prefixManifest = (0, import_visitors_core20.visit)(optionType.prefix, self);
2040
2157
  childManifest.encoder.mergeImportsWith(prefixManifest.encoder);
2041
2158
  childManifest.decoder.mergeImportsWith(prefixManifest.decoder);
2042
2159
  encoderOptions.push(`prefix: ${prefixManifest.encoder.render}`);
@@ -2053,7 +2170,7 @@ function getTypeManifestVisitor(input) {
2053
2170
  return childManifest;
2054
2171
  },
2055
2172
  visitPostOffsetType(node, { self }) {
2056
- const manifest = visitorsCore.visit(node.type, self);
2173
+ const manifest = (0, import_visitors_core20.visit)(node.type, self);
2057
2174
  if (node.strategy === "padded") {
2058
2175
  manifest.encoder.mapRender((r) => `padRightEncoder(${r}, ${node.offset})`).addImports("solanaCodecsCore", "padRightEncoder");
2059
2176
  manifest.decoder.mapRender((r) => `padRightDecoder(${r}, ${node.offset})`).addImports("solanaCodecsCore", "padRightDecoder");
@@ -2075,7 +2192,7 @@ function getTypeManifestVisitor(input) {
2075
2192
  return manifest;
2076
2193
  },
2077
2194
  visitPreOffsetType(node, { self }) {
2078
- const manifest = visitorsCore.visit(node.type, self);
2195
+ const manifest = (0, import_visitors_core20.visit)(node.type, self);
2079
2196
  if (node.strategy === "padded") {
2080
2197
  manifest.encoder.mapRender((r) => `padLeftEncoder(${r}, ${node.offset})`).addImports("solanaCodecsCore", "padLeftEncoder");
2081
2198
  manifest.decoder.mapRender((r) => `padLeftDecoder(${r}, ${node.offset})`).addImports("solanaCodecsCore", "padLeftDecoder");
@@ -2111,7 +2228,7 @@ function getTypeManifestVisitor(input) {
2111
2228
  return manifest;
2112
2229
  },
2113
2230
  visitRemainderOptionType(node, { self }) {
2114
- const childManifest = visitorsCore.visit(node.item, self);
2231
+ const childManifest = (0, import_visitors_core20.visit)(node.item, self);
2115
2232
  childManifest.strictType.mapRender((r) => `Option<${r}>`).addImports("solanaOptions", "type Option");
2116
2233
  childManifest.looseType.mapRender((r) => `OptionOrNullable<${r}>`).addImports("solanaOptions", "type OptionOrNullable");
2117
2234
  const encoderOptions = ["prefix: null"];
@@ -2123,14 +2240,14 @@ function getTypeManifestVisitor(input) {
2123
2240
  return childManifest;
2124
2241
  },
2125
2242
  visitSentinelType(node, { self }) {
2126
- const manifest = visitorsCore.visit(node.type, self);
2127
- const sentinel = visitorsCore.visit(node.sentinel, self).value;
2243
+ const manifest = (0, import_visitors_core20.visit)(node.type, self);
2244
+ const sentinel = (0, import_visitors_core20.visit)(node.sentinel, self).value;
2128
2245
  manifest.encoder.mapRender((r) => `addEncoderSentinel(${r}, ${sentinel.render})`).mergeImportsWith(sentinel).addImports("solanaCodecsCore", "addEncoderSentinel");
2129
2246
  manifest.decoder.mapRender((r) => `addDecoderSentinel(${r}, ${sentinel.render})`).mergeImportsWith(sentinel).addImports("solanaCodecsCore", "addDecoderSentinel");
2130
2247
  return manifest;
2131
2248
  },
2132
2249
  visitSetType(setType, { self }) {
2133
- const childManifest = visitorsCore.visit(setType.item, self);
2250
+ const childManifest = (0, import_visitors_core20.visit)(setType.item, self);
2134
2251
  childManifest.strictType.mapRender((r) => `Set<${r}>`);
2135
2252
  childManifest.looseType.mapRender((r) => `Set<${r}>`);
2136
2253
  const sizeManifest = getArrayLikeSizeOption(setType.count, self);
@@ -2142,19 +2259,19 @@ function getTypeManifestVisitor(input) {
2142
2259
  },
2143
2260
  visitSetValue(node, { self }) {
2144
2261
  return mergeManifests(
2145
- node.items.map((v) => visitorsCore.visit(v, self)),
2262
+ node.items.map((v) => (0, import_visitors_core20.visit)(v, self)),
2146
2263
  { mergeValues: (renders) => `new Set([${renders.join(", ")}])` }
2147
2264
  );
2148
2265
  },
2149
2266
  visitSizePrefixType(node, { self }) {
2150
- const manifest = visitorsCore.visit(node.type, self);
2151
- const prefix = visitorsCore.visit(node.prefix, self);
2267
+ const manifest = (0, import_visitors_core20.visit)(node.type, self);
2268
+ const prefix = (0, import_visitors_core20.visit)(node.prefix, self);
2152
2269
  manifest.encoder.mapRender((r) => `addEncoderSizePrefix(${r}, ${prefix.encoder.render})`).mergeImportsWith(prefix.encoder).addImports("solanaCodecsCore", "addEncoderSizePrefix");
2153
2270
  manifest.decoder.mapRender((r) => `addDecoderSizePrefix(${r}, ${prefix.decoder.render})`).mergeImportsWith(prefix.decoder).addImports("solanaCodecsCore", "addDecoderSizePrefix");
2154
2271
  return manifest;
2155
2272
  },
2156
2273
  visitSolAmountType({ number }, { self }) {
2157
- const numberManifest = visitorsCore.visit(number, self);
2274
+ const numberManifest = (0, import_visitors_core20.visit)(number, self);
2158
2275
  const lamportsType = "Lamports";
2159
2276
  const lamportsImport = new ImportMap().add("solanaRpcTypes", "type Lamports");
2160
2277
  return {
@@ -2167,7 +2284,7 @@ function getTypeManifestVisitor(input) {
2167
2284
  },
2168
2285
  visitSomeValue(node, { self }) {
2169
2286
  const manifest = typeManifest();
2170
- manifest.value = visitorsCore.visit(node.value, self).value.mapRender((r) => `some(${r})`).addImports("solanaOptions", "some");
2287
+ manifest.value = (0, import_visitors_core20.visit)(node.value, self).value.mapRender((r) => `some(${r})`).addImports("solanaOptions", "some");
2171
2288
  return manifest;
2172
2289
  },
2173
2290
  visitStringType(stringType) {
@@ -2200,8 +2317,8 @@ function getTypeManifestVisitor(input) {
2200
2317
  return manifest;
2201
2318
  },
2202
2319
  visitStructFieldType(structFieldType, { self }) {
2203
- const name = nodes.camelCase(structFieldType.name);
2204
- const childManifest = visitorsCore.visit(structFieldType.type, self);
2320
+ const name = (0, import_nodes20.camelCase)(structFieldType.name);
2321
+ const childManifest = (0, import_visitors_core20.visit)(structFieldType.type, self);
2205
2322
  const docblock = structFieldType.docs.length > 0 ? `
2206
2323
  ${jsDocblock(structFieldType.docs)}` : "";
2207
2324
  const originalLooseType = childManifest.looseType.render;
@@ -2221,13 +2338,13 @@ ${jsDocblock(structFieldType.docs)}` : "";
2221
2338
  },
2222
2339
  visitStructFieldValue(node, { self }) {
2223
2340
  const manifest = typeManifest();
2224
- manifest.value = visitorsCore.visit(node.value, self).value.mapRender((r) => `${node.name}: ${r}`);
2341
+ manifest.value = (0, import_visitors_core20.visit)(node.value, self).value.mapRender((r) => `${node.name}: ${r}`);
2225
2342
  return manifest;
2226
2343
  },
2227
2344
  visitStructType(structType, { self }) {
2228
2345
  const optionalFields = structType.fields.filter((f) => !!f.defaultValue);
2229
2346
  const mergedManifest = mergeManifests(
2230
- structType.fields.map((field) => visitorsCore.visit(field, self)),
2347
+ structType.fields.map((field) => (0, import_visitors_core20.visit)(field, self)),
2231
2348
  {
2232
2349
  mergeCodecs: (renders) => `([${renders.join(", ")}])`,
2233
2350
  mergeTypes: (renders) => `{ ${renders.join("")} }`
@@ -2239,19 +2356,19 @@ ${jsDocblock(structFieldType.docs)}` : "";
2239
2356
  return mergedManifest;
2240
2357
  }
2241
2358
  const parentPath = stack.getPath();
2242
- const instructionNode = visitorsCore.findLastNodeFromPath(parentPath, "instructionNode");
2243
- const accountNode = visitorsCore.findLastNodeFromPath(parentPath, "accountNode");
2359
+ const instructionNode = (0, import_visitors_core20.findLastNodeFromPath)(parentPath, "instructionNode");
2360
+ const accountNode = (0, import_visitors_core20.findLastNodeFromPath)(parentPath, "accountNode");
2244
2361
  const discriminatorPrefix = instructionNode ? instructionNode.name : accountNode?.name;
2245
2362
  const discriminators = (instructionNode ? instructionNode.discriminators : accountNode?.discriminators) ?? [];
2246
- const fieldDiscriminators = discriminators.filter(nodes.isNodeFilter("fieldDiscriminatorNode"));
2363
+ const fieldDiscriminators = discriminators.filter((0, import_nodes20.isNodeFilter)("fieldDiscriminatorNode"));
2247
2364
  const defaultValues = optionalFields.map((f) => {
2248
- const key = nodes.camelCase(f.name);
2365
+ const key = (0, import_nodes20.camelCase)(f.name);
2249
2366
  if (fieldDiscriminators.some((d) => d.name === f.name)) {
2250
- const constantName = nameApi.constant(nodes.camelCase(`${discriminatorPrefix}_${f.name}`));
2367
+ const constantName = nameApi.constant((0, import_nodes20.camelCase)(`${discriminatorPrefix}_${f.name}`));
2251
2368
  return f.defaultValueStrategy === "omitted" ? `${key}: ${constantName}` : `${key}: value.${key} ?? ${constantName}`;
2252
2369
  }
2253
2370
  const defaultValue = f.defaultValue;
2254
- const { render: renderedValue, imports } = visitorsCore.visit(defaultValue, self).value;
2371
+ const { render: renderedValue, imports } = (0, import_visitors_core20.visit)(defaultValue, self).value;
2255
2372
  mergedManifest.encoder.mergeImportsWith(imports);
2256
2373
  return f.defaultValueStrategy === "omitted" ? `${key}: ${renderedValue}` : `${key}: value.${key} ?? ${renderedValue}`;
2257
2374
  }).join(", ");
@@ -2260,12 +2377,12 @@ ${jsDocblock(structFieldType.docs)}` : "";
2260
2377
  },
2261
2378
  visitStructValue(node, { self }) {
2262
2379
  return mergeManifests(
2263
- node.fields.map((field) => visitorsCore.visit(field, self)),
2380
+ node.fields.map((field) => (0, import_visitors_core20.visit)(field, self)),
2264
2381
  { mergeValues: (renders) => `{ ${renders.join(", ")} }` }
2265
2382
  );
2266
2383
  },
2267
2384
  visitTupleType(tupleType, { self }) {
2268
- const items = tupleType.items.map((item) => visitorsCore.visit(item, self));
2385
+ const items = tupleType.items.map((item) => (0, import_visitors_core20.visit)(item, self));
2269
2386
  const mergedManifest = mergeManifests(items, {
2270
2387
  mergeCodecs: (codecs) => `[${codecs.join(", ")}]`,
2271
2388
  mergeTypes: (types) => `readonly [${types.join(", ")}]`
@@ -2276,18 +2393,18 @@ ${jsDocblock(structFieldType.docs)}` : "";
2276
2393
  },
2277
2394
  visitTupleValue(node, { self }) {
2278
2395
  return mergeManifests(
2279
- node.items.map((v) => visitorsCore.visit(v, self)),
2396
+ node.items.map((v) => (0, import_visitors_core20.visit)(v, self)),
2280
2397
  { mergeValues: (renders) => `[${renders.join(", ")}]` }
2281
2398
  );
2282
2399
  },
2283
2400
  visitZeroableOptionType(node, { self }) {
2284
- const childManifest = visitorsCore.visit(node.item, self);
2401
+ const childManifest = (0, import_visitors_core20.visit)(node.item, self);
2285
2402
  childManifest.strictType.mapRender((r) => `Option<${r}>`).addImports("solanaOptions", "type Option");
2286
2403
  childManifest.looseType.mapRender((r) => `OptionOrNullable<${r}>`).addImports("solanaOptions", "type OptionOrNullable");
2287
2404
  const encoderOptions = ["prefix: null"];
2288
2405
  const decoderOptions = ["prefix: null"];
2289
2406
  if (node.zeroValue) {
2290
- const zeroValueManifest = visitorsCore.visit(node.zeroValue, self);
2407
+ const zeroValueManifest = (0, import_visitors_core20.visit)(node.zeroValue, self);
2291
2408
  childManifest.encoder.mergeImportsWith(zeroValueManifest.value);
2292
2409
  childManifest.decoder.mergeImportsWith(zeroValueManifest.value);
2293
2410
  encoderOptions.push(`noneValue: ${zeroValueManifest.value.render}`);
@@ -2303,97 +2420,100 @@ ${jsDocblock(structFieldType.docs)}` : "";
2303
2420
  return childManifest;
2304
2421
  }
2305
2422
  }),
2306
- (visitor) => visitorsCore.recordNodeStackVisitor(visitor, stack)
2423
+ (visitor) => (0, import_visitors_core20.recordNodeStackVisitor)(visitor, stack)
2307
2424
  );
2308
2425
  }
2309
2426
  function getArrayLikeSizeOption(count, visitor) {
2310
- if (nodes.isNode(count, "fixedCountNode")) {
2427
+ if ((0, import_nodes20.isNode)(count, "fixedCountNode")) {
2311
2428
  return {
2312
2429
  decoder: fragment(`size: ${count.value}`),
2313
2430
  encoder: fragment(`size: ${count.value}`)
2314
2431
  };
2315
2432
  }
2316
- if (nodes.isNode(count, "remainderCountNode")) {
2433
+ if ((0, import_nodes20.isNode)(count, "remainderCountNode")) {
2317
2434
  return {
2318
2435
  decoder: fragment(`size: 'remainder'`),
2319
2436
  encoder: fragment(`size: 'remainder'`)
2320
2437
  };
2321
2438
  }
2322
- const prefix = nodes.resolveNestedTypeNode(count.prefix);
2439
+ const prefix = (0, import_nodes20.resolveNestedTypeNode)(count.prefix);
2323
2440
  if (prefix.format === "u32" && prefix.endian === "le") {
2324
2441
  return { decoder: fragment(""), encoder: fragment("") };
2325
2442
  }
2326
- const prefixManifest = visitorsCore.visit(count.prefix, visitor);
2443
+ const prefixManifest = (0, import_visitors_core20.visit)(count.prefix, visitor);
2327
2444
  prefixManifest.encoder.mapRender((r) => `size: ${r}`);
2328
2445
  prefixManifest.decoder.mapRender((r) => `size: ${r}`);
2329
2446
  return prefixManifest;
2330
2447
  }
2448
+
2449
+ // src/nameTransformers.ts
2450
+ var import_nodes21 = require("@codama/nodes");
2331
2451
  function getNameApi(transformers) {
2332
2452
  const helpers = {
2333
- camelCase: nodes.camelCase,
2334
- capitalize: nodes.capitalize,
2335
- kebabCase: nodes.kebabCase,
2336
- pascalCase: nodes.pascalCase,
2337
- snakeCase: nodes.snakeCase,
2338
- titleCase: nodes.titleCase
2453
+ camelCase: import_nodes21.camelCase,
2454
+ capitalize: import_nodes21.capitalize,
2455
+ kebabCase: import_nodes21.kebabCase,
2456
+ pascalCase: import_nodes21.pascalCase,
2457
+ snakeCase: import_nodes21.snakeCase,
2458
+ titleCase: import_nodes21.titleCase
2339
2459
  };
2340
2460
  return Object.fromEntries(
2341
2461
  Object.entries(transformers).map(([key, transformer]) => [key, (name) => transformer(name, helpers)])
2342
2462
  );
2343
2463
  }
2344
2464
  var DEFAULT_NAME_TRANSFORMERS = {
2345
- accountDecodeFunction: (name) => `decode${nodes.pascalCase(name)}`,
2346
- accountFetchAllFunction: (name) => `fetchAll${nodes.pascalCase(name)}`,
2347
- accountFetchAllMaybeFunction: (name) => `fetchAllMaybe${nodes.pascalCase(name)}`,
2348
- accountFetchFromSeedsFunction: (name) => `fetch${nodes.pascalCase(name)}FromSeeds`,
2349
- accountFetchFunction: (name) => `fetch${nodes.pascalCase(name)}`,
2350
- accountFetchMaybeFromSeedsFunction: (name) => `fetchMaybe${nodes.pascalCase(name)}FromSeeds`,
2351
- accountFetchMaybeFunction: (name) => `fetchMaybe${nodes.pascalCase(name)}`,
2352
- accountGetSizeFunction: (name) => `get${nodes.pascalCase(name)}Size`,
2353
- codecFunction: (name) => `get${nodes.pascalCase(name)}Codec`,
2354
- constant: (name) => nodes.snakeCase(name).toUpperCase(),
2355
- constantFunction: (name) => `get${nodes.pascalCase(name)}Bytes`,
2356
- dataArgsType: (name) => `${nodes.pascalCase(name)}Args`,
2357
- dataType: (name) => `${nodes.pascalCase(name)}`,
2358
- decoderFunction: (name) => `get${nodes.pascalCase(name)}Decoder`,
2465
+ accountDecodeFunction: (name) => `decode${(0, import_nodes21.pascalCase)(name)}`,
2466
+ accountFetchAllFunction: (name) => `fetchAll${(0, import_nodes21.pascalCase)(name)}`,
2467
+ accountFetchAllMaybeFunction: (name) => `fetchAllMaybe${(0, import_nodes21.pascalCase)(name)}`,
2468
+ accountFetchFromSeedsFunction: (name) => `fetch${(0, import_nodes21.pascalCase)(name)}FromSeeds`,
2469
+ accountFetchFunction: (name) => `fetch${(0, import_nodes21.pascalCase)(name)}`,
2470
+ accountFetchMaybeFromSeedsFunction: (name) => `fetchMaybe${(0, import_nodes21.pascalCase)(name)}FromSeeds`,
2471
+ accountFetchMaybeFunction: (name) => `fetchMaybe${(0, import_nodes21.pascalCase)(name)}`,
2472
+ accountGetSizeFunction: (name) => `get${(0, import_nodes21.pascalCase)(name)}Size`,
2473
+ codecFunction: (name) => `get${(0, import_nodes21.pascalCase)(name)}Codec`,
2474
+ constant: (name) => (0, import_nodes21.snakeCase)(name).toUpperCase(),
2475
+ constantFunction: (name) => `get${(0, import_nodes21.pascalCase)(name)}Bytes`,
2476
+ dataArgsType: (name) => `${(0, import_nodes21.pascalCase)(name)}Args`,
2477
+ dataType: (name) => `${(0, import_nodes21.pascalCase)(name)}`,
2478
+ decoderFunction: (name) => `get${(0, import_nodes21.pascalCase)(name)}Decoder`,
2359
2479
  discriminatedUnionDiscriminator: () => "__kind",
2360
- discriminatedUnionFunction: (name) => `${nodes.camelCase(name)}`,
2361
- discriminatedUnionVariant: (name) => `${nodes.pascalCase(name)}`,
2362
- encoderFunction: (name) => `get${nodes.pascalCase(name)}Encoder`,
2363
- enumVariant: (name) => `${nodes.pascalCase(name)}`,
2364
- instructionAsyncFunction: (name) => `get${nodes.pascalCase(name)}InstructionAsync`,
2365
- instructionAsyncInputType: (name) => `${nodes.pascalCase(name)}AsyncInput`,
2366
- instructionDataType: (name) => `${nodes.pascalCase(name)}InstructionData`,
2367
- instructionExtraType: (name) => `${nodes.pascalCase(name)}InstructionExtra`,
2368
- instructionParseFunction: (name) => `parse${nodes.pascalCase(name)}Instruction`,
2369
- instructionParsedType: (name) => `Parsed${nodes.pascalCase(name)}Instruction`,
2370
- instructionSyncFunction: (name) => `get${nodes.pascalCase(name)}Instruction`,
2371
- instructionSyncInputType: (name) => `${nodes.pascalCase(name)}Input`,
2372
- instructionType: (name) => `${nodes.pascalCase(name)}Instruction`,
2373
- isDiscriminatedUnionFunction: (name) => `is${nodes.pascalCase(name)}`,
2374
- pdaFindFunction: (name) => `find${nodes.pascalCase(name)}Pda`,
2375
- pdaSeedsType: (name) => `${nodes.pascalCase(name)}Seeds`,
2376
- programAccountsEnum: (name) => `${nodes.pascalCase(name)}Account`,
2377
- programAccountsEnumVariant: (name) => `${nodes.pascalCase(name)}`,
2378
- programAccountsIdentifierFunction: (name) => `identify${nodes.pascalCase(name)}Account`,
2379
- programAddressConstant: (name) => `${nodes.snakeCase(name).toUpperCase()}_PROGRAM_ADDRESS`,
2380
- programErrorConstant: (name) => nodes.snakeCase(name).toUpperCase(),
2381
- programErrorConstantPrefix: (name) => `${nodes.snakeCase(name).toUpperCase()}_ERROR__`,
2382
- programErrorMessagesMap: (name) => `${nodes.camelCase(name)}ErrorMessages`,
2383
- programErrorUnion: (name) => `${nodes.pascalCase(name)}Error`,
2384
- programGetErrorMessageFunction: (name) => `get${nodes.pascalCase(name)}ErrorMessage`,
2385
- programInstructionsEnum: (name) => `${nodes.pascalCase(name)}Instruction`,
2386
- programInstructionsEnumVariant: (name) => `${nodes.pascalCase(name)}`,
2387
- programInstructionsIdentifierFunction: (name) => `identify${nodes.pascalCase(name)}Instruction`,
2388
- programInstructionsParsedUnionType: (name) => `Parsed${nodes.pascalCase(name)}Instruction`,
2389
- programIsErrorFunction: (name) => `is${nodes.pascalCase(name)}Error`,
2390
- resolverFunction: (name) => `${nodes.camelCase(name)}`
2480
+ discriminatedUnionFunction: (name) => `${(0, import_nodes21.camelCase)(name)}`,
2481
+ discriminatedUnionVariant: (name) => `${(0, import_nodes21.pascalCase)(name)}`,
2482
+ encoderFunction: (name) => `get${(0, import_nodes21.pascalCase)(name)}Encoder`,
2483
+ enumVariant: (name) => `${(0, import_nodes21.pascalCase)(name)}`,
2484
+ instructionAsyncFunction: (name) => `get${(0, import_nodes21.pascalCase)(name)}InstructionAsync`,
2485
+ instructionAsyncInputType: (name) => `${(0, import_nodes21.pascalCase)(name)}AsyncInput`,
2486
+ instructionDataType: (name) => `${(0, import_nodes21.pascalCase)(name)}InstructionData`,
2487
+ instructionExtraType: (name) => `${(0, import_nodes21.pascalCase)(name)}InstructionExtra`,
2488
+ instructionParseFunction: (name) => `parse${(0, import_nodes21.pascalCase)(name)}Instruction`,
2489
+ instructionParsedType: (name) => `Parsed${(0, import_nodes21.pascalCase)(name)}Instruction`,
2490
+ instructionSyncFunction: (name) => `get${(0, import_nodes21.pascalCase)(name)}Instruction`,
2491
+ instructionSyncInputType: (name) => `${(0, import_nodes21.pascalCase)(name)}Input`,
2492
+ instructionType: (name) => `${(0, import_nodes21.pascalCase)(name)}Instruction`,
2493
+ isDiscriminatedUnionFunction: (name) => `is${(0, import_nodes21.pascalCase)(name)}`,
2494
+ pdaFindFunction: (name) => `find${(0, import_nodes21.pascalCase)(name)}Pda`,
2495
+ pdaSeedsType: (name) => `${(0, import_nodes21.pascalCase)(name)}Seeds`,
2496
+ programAccountsEnum: (name) => `${(0, import_nodes21.pascalCase)(name)}Account`,
2497
+ programAccountsEnumVariant: (name) => `${(0, import_nodes21.pascalCase)(name)}`,
2498
+ programAccountsIdentifierFunction: (name) => `identify${(0, import_nodes21.pascalCase)(name)}Account`,
2499
+ programAddressConstant: (name) => `${(0, import_nodes21.snakeCase)(name).toUpperCase()}_PROGRAM_ADDRESS`,
2500
+ programErrorConstant: (name) => (0, import_nodes21.snakeCase)(name).toUpperCase(),
2501
+ programErrorConstantPrefix: (name) => `${(0, import_nodes21.snakeCase)(name).toUpperCase()}_ERROR__`,
2502
+ programErrorMessagesMap: (name) => `${(0, import_nodes21.camelCase)(name)}ErrorMessages`,
2503
+ programErrorUnion: (name) => `${(0, import_nodes21.pascalCase)(name)}Error`,
2504
+ programGetErrorMessageFunction: (name) => `get${(0, import_nodes21.pascalCase)(name)}ErrorMessage`,
2505
+ programInstructionsEnum: (name) => `${(0, import_nodes21.pascalCase)(name)}Instruction`,
2506
+ programInstructionsEnumVariant: (name) => `${(0, import_nodes21.pascalCase)(name)}`,
2507
+ programInstructionsIdentifierFunction: (name) => `identify${(0, import_nodes21.pascalCase)(name)}Instruction`,
2508
+ programInstructionsParsedUnionType: (name) => `Parsed${(0, import_nodes21.pascalCase)(name)}Instruction`,
2509
+ programIsErrorFunction: (name) => `is${(0, import_nodes21.pascalCase)(name)}Error`,
2510
+ resolverFunction: (name) => `${(0, import_nodes21.camelCase)(name)}`
2391
2511
  };
2392
2512
 
2393
2513
  // src/getRenderMapVisitor.ts
2394
2514
  function getRenderMapVisitor(options = {}) {
2395
- const linkables = new visitorsCore.LinkableDictionary();
2396
- const stack = new visitorsCore.NodeStack();
2515
+ const linkables = new import_visitors_core21.LinkableDictionary();
2516
+ const stack = new import_visitors_core21.NodeStack();
2397
2517
  const nameTransformers = {
2398
2518
  ...DEFAULT_NAME_TRANSFORMERS,
2399
2519
  ...options.nameTransformers
@@ -2402,9 +2522,9 @@ function getRenderMapVisitor(options = {}) {
2402
2522
  const renderParentInstructions = options.renderParentInstructions ?? false;
2403
2523
  const dependencyMap = options.dependencyMap ?? {};
2404
2524
  const useGranularImports = options.useGranularImports ?? false;
2405
- const asyncResolvers = (options.asyncResolvers ?? []).map(nodes.camelCase);
2406
- const nonScalarEnums = (options.nonScalarEnums ?? []).map(nodes.camelCase);
2407
- const internalNodes = (options.internalNodes ?? []).map(nodes.camelCase);
2525
+ const asyncResolvers = (options.asyncResolvers ?? []).map(import_nodes22.camelCase);
2526
+ const nonScalarEnums = (options.nonScalarEnums ?? []).map(import_nodes22.camelCase);
2527
+ const internalNodes = (options.internalNodes ?? []).map(import_nodes22.camelCase);
2408
2528
  const customAccountData = parseCustomDataOptions(options.customAccountData ?? [], "AccountData");
2409
2529
  const customInstructionData = parseCustomDataOptions(options.customInstructionData ?? [], "InstructionData");
2410
2530
  const getImportFrom = getImportFromFactory(options.linkOverrides ?? {}, customAccountData, customInstructionData);
@@ -2417,7 +2537,7 @@ function getRenderMapVisitor(options = {}) {
2417
2537
  nonScalarEnums,
2418
2538
  stack
2419
2539
  });
2420
- const resolvedInstructionInputVisitor = visitorsCore.getResolvedInstructionInputsVisitor();
2540
+ const resolvedInstructionInputVisitor = (0, import_visitors_core21.getResolvedInstructionInputsVisitor)();
2421
2541
  const globalScope = {
2422
2542
  asyncResolvers,
2423
2543
  customAccountData,
@@ -2430,24 +2550,24 @@ function getRenderMapVisitor(options = {}) {
2430
2550
  typeManifestVisitor
2431
2551
  };
2432
2552
  const render2 = (template, context, renderOptions) => {
2433
- return render(path.join("pages", template), context, renderOptions);
2553
+ return render((0, import_node_path3.join)("pages", template), context, renderOptions);
2434
2554
  };
2435
- return visitorsCore.pipe(
2436
- visitorsCore.staticVisitor(() => new renderersCore.RenderMap(), {
2555
+ return (0, import_visitors_core21.pipe)(
2556
+ (0, import_visitors_core21.staticVisitor)(() => new import_renderers_core.RenderMap(), {
2437
2557
  keys: ["rootNode", "programNode", "pdaNode", "accountNode", "definedTypeNode", "instructionNode"]
2438
2558
  }),
2439
- (v) => visitorsCore.extendVisitor(v, {
2559
+ (v) => (0, import_visitors_core21.extendVisitor)(v, {
2440
2560
  visitAccount(node) {
2441
2561
  const accountPath = stack.getPath("accountNode");
2442
- if (!visitorsCore.findProgramNodeFromPath(accountPath)) {
2562
+ if (!(0, import_visitors_core21.findProgramNodeFromPath)(accountPath)) {
2443
2563
  throw new Error("Account must be visited inside a program.");
2444
2564
  }
2445
2565
  const scope = {
2446
2566
  ...globalScope,
2447
2567
  accountPath,
2448
- typeManifest: visitorsCore.visit(node, typeManifestVisitor)
2568
+ typeManifest: (0, import_visitors_core21.visit)(node, typeManifestVisitor)
2449
2569
  };
2450
- const fields = nodes.resolveNestedTypeNode(node.data).fields;
2570
+ const fields = (0, import_nodes22.resolveNestedTypeNode)(node.data).fields;
2451
2571
  const accountDiscriminatorConstantsFragment = getDiscriminatorConstantsFragment({
2452
2572
  ...scope,
2453
2573
  discriminatorNodes: node.discriminators ?? [],
@@ -2465,8 +2585,8 @@ function getRenderMapVisitor(options = {}) {
2465
2585
  accountSizeHelpersFragment,
2466
2586
  accountPdaHelpersFragment
2467
2587
  );
2468
- return new renderersCore.RenderMap().add(
2469
- `accounts/${nodes.camelCase(node.name)}.ts`,
2588
+ return new import_renderers_core.RenderMap().add(
2589
+ `accounts/${(0, import_nodes22.camelCase)(node.name)}.ts`,
2470
2590
  render2("accountsPage.njk", {
2471
2591
  accountDiscriminatorConstantsFragment,
2472
2592
  accountFetchHelpersFragment,
@@ -2483,7 +2603,7 @@ function getRenderMapVisitor(options = {}) {
2483
2603
  codecDocs: [],
2484
2604
  decoderDocs: [],
2485
2605
  encoderDocs: [],
2486
- manifest: visitorsCore.visit(node, typeManifestVisitor),
2606
+ manifest: (0, import_visitors_core21.visit)(node, typeManifestVisitor),
2487
2607
  name: node.name,
2488
2608
  typeDocs: node.docs,
2489
2609
  typeNode: node.type
@@ -2497,8 +2617,8 @@ function getRenderMapVisitor(options = {}) {
2497
2617
  nameApi.decoderFunction(node.name),
2498
2618
  nameApi.codecFunction(node.name)
2499
2619
  ]);
2500
- return new renderersCore.RenderMap().add(
2501
- `types/${nodes.camelCase(node.name)}.ts`,
2620
+ return new import_renderers_core.RenderMap().add(
2621
+ `types/${(0, import_nodes22.camelCase)(node.name)}.ts`,
2502
2622
  render2("definedTypesPage.njk", {
2503
2623
  imports: imports.toString({
2504
2624
  ...dependencyMap,
@@ -2511,23 +2631,23 @@ function getRenderMapVisitor(options = {}) {
2511
2631
  },
2512
2632
  visitInstruction(node) {
2513
2633
  const instructionPath = stack.getPath("instructionNode");
2514
- if (!visitorsCore.findProgramNodeFromPath(instructionPath)) {
2634
+ if (!(0, import_visitors_core21.findProgramNodeFromPath)(instructionPath)) {
2515
2635
  throw new Error("Instruction must be visited inside a program.");
2516
2636
  }
2517
2637
  const instructionExtraName = nameApi.instructionExtraType(node.name);
2518
2638
  const scope = {
2519
2639
  ...globalScope,
2520
- dataArgsManifest: visitorsCore.visit(node, typeManifestVisitor),
2521
- extraArgsManifest: visitorsCore.visit(
2522
- nodes.definedTypeNode({
2640
+ dataArgsManifest: (0, import_visitors_core21.visit)(node, typeManifestVisitor),
2641
+ extraArgsManifest: (0, import_visitors_core21.visit)(
2642
+ (0, import_nodes22.definedTypeNode)({
2523
2643
  name: instructionExtraName,
2524
- type: nodes.structTypeNodeFromInstructionArgumentNodes(node.extraArguments ?? [])
2644
+ type: (0, import_nodes22.structTypeNodeFromInstructionArgumentNodes)(node.extraArguments ?? [])
2525
2645
  }),
2526
2646
  typeManifestVisitor
2527
2647
  ),
2528
2648
  instructionPath,
2529
2649
  renamedArgs: getRenamedArgsMap(node),
2530
- resolvedInputs: visitorsCore.visit(node, resolvedInstructionInputVisitor)
2650
+ resolvedInputs: (0, import_visitors_core21.visit)(node, resolvedInstructionInputVisitor)
2531
2651
  };
2532
2652
  const instructionDiscriminatorConstantsFragment = getDiscriminatorConstantsFragment({
2533
2653
  ...scope,
@@ -2556,8 +2676,8 @@ function getRenderMapVisitor(options = {}) {
2556
2676
  instructionFunctionSyncFragment,
2557
2677
  instructionParseFunctionFragment
2558
2678
  );
2559
- return new renderersCore.RenderMap().add(
2560
- `instructions/${nodes.camelCase(node.name)}.ts`,
2679
+ return new import_renderers_core.RenderMap().add(
2680
+ `instructions/${(0, import_nodes22.camelCase)(node.name)}.ts`,
2561
2681
  render2("instructionsPage.njk", {
2562
2682
  imports: imports.toString(dependencyMap, useGranularImports),
2563
2683
  instruction: node,
@@ -2573,14 +2693,14 @@ function getRenderMapVisitor(options = {}) {
2573
2693
  },
2574
2694
  visitPda(node) {
2575
2695
  const pdaPath = stack.getPath("pdaNode");
2576
- if (!visitorsCore.findProgramNodeFromPath(pdaPath)) {
2696
+ if (!(0, import_visitors_core21.findProgramNodeFromPath)(pdaPath)) {
2577
2697
  throw new Error("Account must be visited inside a program.");
2578
2698
  }
2579
2699
  const scope = { ...globalScope, pdaPath };
2580
2700
  const pdaFunctionFragment = getPdaFunctionFragment(scope);
2581
2701
  const imports = new ImportMap().mergeWith(pdaFunctionFragment);
2582
- return new renderersCore.RenderMap().add(
2583
- `pdas/${nodes.camelCase(node.name)}.ts`,
2702
+ return new import_renderers_core.RenderMap().add(
2703
+ `pdas/${(0, import_nodes22.camelCase)(node.name)}.ts`,
2584
2704
  render2("pdasPage.njk", {
2585
2705
  imports: imports.toString(dependencyMap, useGranularImports),
2586
2706
  pdaFunctionFragment
@@ -2593,11 +2713,11 @@ function getRenderMapVisitor(options = {}) {
2593
2713
  ...getDefinedTypeNodesToExtract(node.instructions, customInstructionData)
2594
2714
  ];
2595
2715
  const scope = { ...globalScope, programNode: node };
2596
- const renderMap = new renderersCore.RenderMap().mergeWith(...node.pdas.map((p) => visitorsCore.visit(p, self))).mergeWith(...node.accounts.map((a) => visitorsCore.visit(a, self))).mergeWith(...node.definedTypes.map((t) => visitorsCore.visit(t, self))).mergeWith(...customDataDefinedType.map((t) => visitorsCore.visit(t, self)));
2716
+ const renderMap = new import_renderers_core.RenderMap().mergeWith(...node.pdas.map((p) => (0, import_visitors_core21.visit)(p, self))).mergeWith(...node.accounts.map((a) => (0, import_visitors_core21.visit)(a, self))).mergeWith(...node.definedTypes.map((t) => (0, import_visitors_core21.visit)(t, self))).mergeWith(...customDataDefinedType.map((t) => (0, import_visitors_core21.visit)(t, self)));
2597
2717
  if (node.errors.length > 0) {
2598
2718
  const programErrorsFragment = getProgramErrorsFragment(scope);
2599
2719
  renderMap.add(
2600
- `errors/${nodes.camelCase(node.name)}.ts`,
2720
+ `errors/${(0, import_nodes22.camelCase)(node.name)}.ts`,
2601
2721
  render2("errorsPage.njk", {
2602
2722
  imports: new ImportMap().mergeWith(programErrorsFragment).toString(dependencyMap, useGranularImports),
2603
2723
  programErrorsFragment
@@ -2608,7 +2728,7 @@ function getRenderMapVisitor(options = {}) {
2608
2728
  const programAccountsFragment = getProgramAccountsFragment(scope);
2609
2729
  const programInstructionsFragment = getProgramInstructionsFragment(scope);
2610
2730
  renderMap.add(
2611
- `programs/${nodes.camelCase(node.name)}.ts`,
2731
+ `programs/${(0, import_nodes22.camelCase)(node.name)}.ts`,
2612
2732
  render2("programsPage.njk", {
2613
2733
  imports: new ImportMap().mergeWith(programFragment, programAccountsFragment, programInstructionsFragment).toString(dependencyMap, useGranularImports),
2614
2734
  programAccountsFragment,
@@ -2617,22 +2737,22 @@ function getRenderMapVisitor(options = {}) {
2617
2737
  })
2618
2738
  );
2619
2739
  renderMap.mergeWith(
2620
- ...nodes.getAllInstructionsWithSubs(node, {
2740
+ ...(0, import_nodes22.getAllInstructionsWithSubs)(node, {
2621
2741
  leavesOnly: !renderParentInstructions
2622
- }).map((ix) => visitorsCore.visit(ix, self))
2742
+ }).map((ix) => (0, import_visitors_core21.visit)(ix, self))
2623
2743
  );
2624
2744
  return renderMap;
2625
2745
  },
2626
2746
  visitRoot(node, { self }) {
2627
2747
  const isNotInternal = (n) => !internalNodes.includes(n.name);
2628
- const programsToExport = nodes.getAllPrograms(node).filter(isNotInternal);
2748
+ const programsToExport = (0, import_nodes22.getAllPrograms)(node).filter(isNotInternal);
2629
2749
  const programsWithErrorsToExport = programsToExport.filter((p) => p.errors.length > 0);
2630
- const pdasToExport = nodes.getAllPdas(node);
2631
- const accountsToExport = nodes.getAllAccounts(node).filter(isNotInternal);
2632
- const instructionsToExport = nodes.getAllInstructionsWithSubs(node, {
2750
+ const pdasToExport = (0, import_nodes22.getAllPdas)(node);
2751
+ const accountsToExport = (0, import_nodes22.getAllAccounts)(node).filter(isNotInternal);
2752
+ const instructionsToExport = (0, import_nodes22.getAllInstructionsWithSubs)(node, {
2633
2753
  leavesOnly: !renderParentInstructions
2634
2754
  }).filter(isNotInternal);
2635
- const definedTypesToExport = nodes.getAllDefinedTypes(node).filter(isNotInternal);
2755
+ const definedTypesToExport = (0, import_nodes22.getAllDefinedTypes)(node).filter(isNotInternal);
2636
2756
  const hasAnythingToExport = programsToExport.length > 0 || accountsToExport.length > 0 || instructionsToExport.length > 0 || definedTypesToExport.length > 0;
2637
2757
  const ctx = {
2638
2758
  accountsToExport,
@@ -2644,7 +2764,7 @@ function getRenderMapVisitor(options = {}) {
2644
2764
  programsWithErrorsToExport,
2645
2765
  root: node
2646
2766
  };
2647
- const map = new renderersCore.RenderMap();
2767
+ const map = new import_renderers_core.RenderMap();
2648
2768
  if (hasAnythingToExport) {
2649
2769
  map.add(
2650
2770
  "shared/index.ts",
@@ -2684,11 +2804,11 @@ function getRenderMapVisitor(options = {}) {
2684
2804
  if (definedTypesToExport.length > 0) {
2685
2805
  map.add("types/index.ts", render2("definedTypesIndex.njk", ctx));
2686
2806
  }
2687
- return map.add("index.ts", render2("rootIndex.njk", ctx)).mergeWith(...nodes.getAllPrograms(node).map((p) => visitorsCore.visit(p, self)));
2807
+ return map.add("index.ts", render2("rootIndex.njk", ctx)).mergeWith(...(0, import_nodes22.getAllPrograms)(node).map((p) => (0, import_visitors_core21.visit)(p, self)));
2688
2808
  }
2689
2809
  }),
2690
- (v) => visitorsCore.recordNodeStackVisitor(v, stack),
2691
- (v) => visitorsCore.recordLinkablesOnFirstVisitVisitor(v, linkables)
2810
+ (v) => (0, import_visitors_core21.recordNodeStackVisitor)(v, stack),
2811
+ (v) => (0, import_visitors_core21.recordLinkablesOnFirstVisitVisitor)(v, linkables)
2692
2812
  );
2693
2813
  }
2694
2814
  function getRenamedArgsMap(instruction) {
@@ -2703,15 +2823,22 @@ function getRenamedArgsMap(instruction) {
2703
2823
  const allNames = [...instruction.accounts.map((account) => account.name), ...argNames];
2704
2824
  const duplicates = allNames.filter((e, i, a) => a.indexOf(e) !== i);
2705
2825
  if (duplicates.length === 0) return /* @__PURE__ */ new Map();
2706
- errors.logWarn(
2826
+ (0, import_errors2.logWarn)(
2707
2827
  `[JavaScript] Accounts and args of instruction [${instruction.name}] have the following conflicting attributes [${duplicates.join(", ")}]. Thus, the arguments have been renamed to avoid conflicts in the input type.`
2708
2828
  );
2709
- return new Map(duplicates.map((name) => [nodes.camelCase(name), nodes.camelCase(`${name}Arg`)]));
2829
+ return new Map(duplicates.map((name) => [(0, import_nodes22.camelCase)(name), (0, import_nodes22.camelCase)(`${name}Arg`)]));
2710
2830
  }
2831
+
2832
+ // src/renderVisitor.ts
2833
+ var import_renderers_core2 = require("@codama/renderers-core");
2834
+ var import_visitors_core22 = require("@codama/visitors-core");
2835
+ var estreePlugin = __toESM(require("prettier/plugins/estree"));
2836
+ var typeScriptPlugin = __toESM(require("prettier/plugins/typescript"));
2837
+ var import_standalone = require("prettier/standalone");
2711
2838
  var DEFAULT_PRETTIER_OPTIONS = {
2712
2839
  arrowParens: "always",
2713
2840
  parser: "typescript",
2714
- plugins: [estreePlugin__namespace, typeScriptPlugin__namespace],
2841
+ plugins: [estreePlugin, typeScriptPlugin],
2715
2842
  printWidth: 80,
2716
2843
  semi: true,
2717
2844
  singleQuote: true,
@@ -2720,27 +2847,27 @@ var DEFAULT_PRETTIER_OPTIONS = {
2720
2847
  useTabs: false
2721
2848
  };
2722
2849
  function renderVisitor(path, options = {}) {
2723
- return visitorsCore.rootNodeVisitor(async (root) => {
2850
+ return (0, import_visitors_core22.rootNodeVisitor)(async (root) => {
2724
2851
  if (options.deleteFolderBeforeRendering ?? true) {
2725
- renderersCore.deleteDirectory(path);
2852
+ (0, import_renderers_core2.deleteDirectory)(path);
2726
2853
  }
2727
- const renderMap = visitorsCore.visit(root, getRenderMapVisitor(options));
2854
+ const renderMap = (0, import_visitors_core22.visit)(root, getRenderMapVisitor(options));
2728
2855
  if (options.formatCode ?? true) {
2729
2856
  const prettierOptions = { ...DEFAULT_PRETTIER_OPTIONS, ...options.prettierOptions };
2730
- await renderMap.mapContentAsync((code) => standalone.format(code, prettierOptions));
2857
+ await renderMap.mapContentAsync((code) => (0, import_standalone.format)(code, prettierOptions));
2731
2858
  }
2732
2859
  renderMap.write(path);
2733
2860
  });
2734
2861
  }
2735
-
2736
- exports.DEFAULT_NAME_TRANSFORMERS = DEFAULT_NAME_TRANSFORMERS;
2737
- exports.ImportMap = ImportMap;
2738
- exports.default = renderVisitor;
2739
- exports.getNameApi = getNameApi;
2740
- exports.getRenderMapVisitor = getRenderMapVisitor;
2741
- exports.getTypeManifestVisitor = getTypeManifestVisitor;
2742
- exports.mergeManifests = mergeManifests;
2743
- exports.renderVisitor = renderVisitor;
2744
- exports.typeManifest = typeManifest;
2745
- //# sourceMappingURL=index.node.cjs.map
2862
+ // Annotate the CommonJS export names for ESM import in node:
2863
+ 0 && (module.exports = {
2864
+ DEFAULT_NAME_TRANSFORMERS,
2865
+ ImportMap,
2866
+ getNameApi,
2867
+ getRenderMapVisitor,
2868
+ getTypeManifestVisitor,
2869
+ mergeManifests,
2870
+ renderVisitor,
2871
+ typeManifest
2872
+ });
2746
2873
  //# sourceMappingURL=index.node.cjs.map