@codama/renderers-js 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,52 +1,37 @@
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 });
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var nodes = require('@codama/nodes');
6
+ var renderersCore = require('@codama/renderers-core');
7
+ var visitorsCore = require('@codama/visitors-core');
8
+ var codecsStrings = require('@solana/codecs-strings');
9
+ var prettier = require('prettier');
10
+ var estreePlugin = require('prettier/plugins/estree');
11
+ var typeScriptPlugin = require('prettier/plugins/typescript');
12
+ var errors = require('@codama/errors');
13
+ var semver = require('semver');
14
+
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
17
28
  }
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);
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
29
32
 
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- DEFAULT_NAME_TRANSFORMERS: () => DEFAULT_NAME_TRANSFORMERS,
34
- addToImportMap: () => addToImportMap,
35
- createImportMap: () => createImportMap,
36
- default: () => renderVisitor,
37
- getExternalDependencies: () => getExternalDependencies,
38
- getNameApi: () => getNameApi,
39
- getRenderMapVisitor: () => getRenderMapVisitor,
40
- getTypeManifestVisitor: () => getTypeManifestVisitor,
41
- importMapToString: () => importMapToString,
42
- mergeImportMaps: () => mergeImportMaps,
43
- mergeTypeManifests: () => mergeTypeManifests,
44
- parseImportInput: () => parseImportInput,
45
- removeFromImportMap: () => removeFromImportMap,
46
- renderVisitor: () => renderVisitor,
47
- typeManifest: () => typeManifest
48
- });
49
- module.exports = __toCommonJS(index_exports);
33
+ var estreePlugin__namespace = /*#__PURE__*/_interopNamespace(estreePlugin);
34
+ var typeScriptPlugin__namespace = /*#__PURE__*/_interopNamespace(typeScriptPlugin);
50
35
 
51
36
  // src/utils/importMap.ts
52
37
  var DEFAULT_EXTERNAL_MODULE_MAP = {
@@ -103,20 +88,20 @@ function parseImportInput(input) {
103
88
  usedIdentifier: alias ?? name
104
89
  });
105
90
  }
106
- function addToImportMap(importMap, module2, imports) {
91
+ function addToImportMap(importMap, module, imports) {
107
92
  const parsedImports = imports.map(parseImportInput).map((i) => [i.usedIdentifier, i]);
108
- return mergeImportMaps([importMap, /* @__PURE__ */ new Map([[module2, new Map(parsedImports)]])]);
93
+ return mergeImportMaps([importMap, /* @__PURE__ */ new Map([[module, new Map(parsedImports)]])]);
109
94
  }
110
- function removeFromImportMap(importMap, module2, usedIdentifiers) {
95
+ function removeFromImportMap(importMap, module, usedIdentifiers) {
111
96
  const newMap = new Map(importMap);
112
- const newModuleMap = new Map(newMap.get(module2));
97
+ const newModuleMap = new Map(newMap.get(module));
113
98
  usedIdentifiers.forEach((usedIdentifier) => {
114
99
  newModuleMap.delete(usedIdentifier);
115
100
  });
116
101
  if (newModuleMap.size === 0) {
117
- newMap.delete(module2);
102
+ newMap.delete(module);
118
103
  } else {
119
- newMap.set(module2, newModuleMap);
104
+ newMap.set(module, newModuleMap);
120
105
  }
121
106
  return Object.freeze(newMap);
122
107
  }
@@ -125,8 +110,8 @@ function mergeImportMaps(importMaps) {
125
110
  if (importMaps.length === 1) return importMaps[0];
126
111
  const mergedMap = new Map(importMaps[0]);
127
112
  for (const map of importMaps.slice(1)) {
128
- for (const [module2, imports] of map) {
129
- const mergedModuleMap = mergedMap.get(module2) ?? /* @__PURE__ */ new Map();
113
+ for (const [module, imports] of map) {
114
+ const mergedModuleMap = mergedMap.get(module) ?? /* @__PURE__ */ new Map();
130
115
  for (const [usedIdentifier, importInfo] of imports) {
131
116
  const existingImportInfo = mergedModuleMap.get(usedIdentifier);
132
117
  const shouldOverwriteTypeOnly = existingImportInfo && existingImportInfo.importedIdentifier === importInfo.importedIdentifier && existingImportInfo.isType && !importInfo.isType;
@@ -134,7 +119,7 @@ function mergeImportMaps(importMaps) {
134
119
  mergedModuleMap.set(usedIdentifier, importInfo);
135
120
  }
136
121
  }
137
- mergedMap.set(module2, mergedModuleMap);
122
+ mergedMap.set(module, mergedModuleMap);
138
123
  }
139
124
  }
140
125
  return Object.freeze(mergedMap);
@@ -145,14 +130,14 @@ function importMapToString(importMap, dependencyMap = {}, useGranularImports = f
145
130
  const relative = Number(a.startsWith(".")) - Number(b.startsWith("."));
146
131
  if (relative !== 0) return relative;
147
132
  return a.localeCompare(b);
148
- }).map(([module2, imports]) => {
133
+ }).map(([module, imports]) => {
149
134
  const innerImports = [...imports.values()].map(importInfoToString).sort((a, b) => a.localeCompare(b)).join(", ");
150
- return `import { ${innerImports} } from '${module2}';`;
135
+ return `import { ${innerImports} } from '${module}';`;
151
136
  }).join("\n");
152
137
  }
153
138
  function getExternalDependencies(importMap, dependencyMap, useGranularImports) {
154
139
  const resolvedImports = resolveImportMapModules(importMap, dependencyMap, useGranularImports);
155
- return new Set([...resolvedImports.keys()].filter((module2) => !module2.startsWith(".")));
140
+ return new Set([...resolvedImports.keys()].filter((module) => !module.startsWith(".")));
156
141
  }
157
142
  function resolveImportMapModules(importMap, dependencyMap, useGranularImports) {
158
143
  const dependencyMapWithDefaults = {
@@ -161,8 +146,8 @@ function resolveImportMapModules(importMap, dependencyMap, useGranularImports) {
161
146
  ...dependencyMap
162
147
  };
163
148
  return mergeImportMaps(
164
- [...importMap.entries()].map(([module2, imports]) => {
165
- const resolvedModule = dependencyMapWithDefaults[module2] ?? module2;
149
+ [...importMap.entries()].map(([module, imports]) => {
150
+ const resolvedModule = dependencyMapWithDefaults[module] ?? module;
166
151
  return /* @__PURE__ */ new Map([[resolvedModule, imports]]);
167
152
  })
168
153
  );
@@ -171,73 +156,67 @@ function importInfoToString({ importedIdentifier, isType, usedIdentifier }) {
171
156
  const alias = importedIdentifier !== usedIdentifier ? ` as ${usedIdentifier}` : "";
172
157
  return `${isType ? "type " : ""}${importedIdentifier}${alias}`;
173
158
  }
174
-
175
- // src/utils/nameTransformers.ts
176
- var import_nodes = require("@codama/nodes");
177
159
  function getNameApi(transformers) {
178
160
  const helpers = {
179
- camelCase: import_nodes.camelCase,
180
- capitalize: import_nodes.capitalize,
181
- kebabCase: import_nodes.kebabCase,
182
- pascalCase: import_nodes.pascalCase,
183
- snakeCase: import_nodes.snakeCase,
184
- titleCase: import_nodes.titleCase
161
+ camelCase: nodes.camelCase,
162
+ capitalize: nodes.capitalize,
163
+ kebabCase: nodes.kebabCase,
164
+ pascalCase: nodes.pascalCase,
165
+ snakeCase: nodes.snakeCase,
166
+ titleCase: nodes.titleCase
185
167
  };
186
168
  return Object.fromEntries(
187
169
  Object.entries(transformers).map(([key, transformer]) => [key, (name) => transformer(name, helpers)])
188
170
  );
189
171
  }
190
172
  var DEFAULT_NAME_TRANSFORMERS = {
191
- accountDecodeFunction: (name) => `decode${(0, import_nodes.pascalCase)(name)}`,
192
- accountFetchAllFunction: (name) => `fetchAll${(0, import_nodes.pascalCase)(name)}`,
193
- accountFetchAllMaybeFunction: (name) => `fetchAllMaybe${(0, import_nodes.pascalCase)(name)}`,
194
- accountFetchFromSeedsFunction: (name) => `fetch${(0, import_nodes.pascalCase)(name)}FromSeeds`,
195
- accountFetchFunction: (name) => `fetch${(0, import_nodes.pascalCase)(name)}`,
196
- accountFetchMaybeFromSeedsFunction: (name) => `fetchMaybe${(0, import_nodes.pascalCase)(name)}FromSeeds`,
197
- accountFetchMaybeFunction: (name) => `fetchMaybe${(0, import_nodes.pascalCase)(name)}`,
198
- accountGetSizeFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Size`,
199
- codecFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Codec`,
200
- constant: (name) => (0, import_nodes.snakeCase)(name).toUpperCase(),
201
- constantFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Bytes`,
202
- dataArgsType: (name) => `${(0, import_nodes.pascalCase)(name)}Args`,
203
- dataType: (name) => `${(0, import_nodes.pascalCase)(name)}`,
204
- decoderFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Decoder`,
173
+ accountDecodeFunction: (name) => `decode${nodes.pascalCase(name)}`,
174
+ accountFetchAllFunction: (name) => `fetchAll${nodes.pascalCase(name)}`,
175
+ accountFetchAllMaybeFunction: (name) => `fetchAllMaybe${nodes.pascalCase(name)}`,
176
+ accountFetchFromSeedsFunction: (name) => `fetch${nodes.pascalCase(name)}FromSeeds`,
177
+ accountFetchFunction: (name) => `fetch${nodes.pascalCase(name)}`,
178
+ accountFetchMaybeFromSeedsFunction: (name) => `fetchMaybe${nodes.pascalCase(name)}FromSeeds`,
179
+ accountFetchMaybeFunction: (name) => `fetchMaybe${nodes.pascalCase(name)}`,
180
+ accountGetSizeFunction: (name) => `get${nodes.pascalCase(name)}Size`,
181
+ codecFunction: (name) => `get${nodes.pascalCase(name)}Codec`,
182
+ constant: (name) => nodes.snakeCase(name).toUpperCase(),
183
+ constantFunction: (name) => `get${nodes.pascalCase(name)}Bytes`,
184
+ dataArgsType: (name) => `${nodes.pascalCase(name)}Args`,
185
+ dataType: (name) => `${nodes.pascalCase(name)}`,
186
+ decoderFunction: (name) => `get${nodes.pascalCase(name)}Decoder`,
205
187
  discriminatedUnionDiscriminator: () => "__kind",
206
- discriminatedUnionFunction: (name) => `${(0, import_nodes.camelCase)(name)}`,
207
- discriminatedUnionVariant: (name) => `${(0, import_nodes.pascalCase)(name)}`,
208
- encoderFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Encoder`,
209
- enumVariant: (name) => `${(0, import_nodes.pascalCase)(name)}`,
210
- instructionAsyncFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}InstructionAsync`,
211
- instructionAsyncInputType: (name) => `${(0, import_nodes.pascalCase)(name)}AsyncInput`,
212
- instructionDataType: (name) => `${(0, import_nodes.pascalCase)(name)}InstructionData`,
213
- instructionExtraType: (name) => `${(0, import_nodes.pascalCase)(name)}InstructionExtra`,
214
- instructionParseFunction: (name) => `parse${(0, import_nodes.pascalCase)(name)}Instruction`,
215
- instructionParsedType: (name) => `Parsed${(0, import_nodes.pascalCase)(name)}Instruction`,
216
- instructionSyncFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Instruction`,
217
- instructionSyncInputType: (name) => `${(0, import_nodes.pascalCase)(name)}Input`,
218
- instructionType: (name) => `${(0, import_nodes.pascalCase)(name)}Instruction`,
219
- isDiscriminatedUnionFunction: (name) => `is${(0, import_nodes.pascalCase)(name)}`,
220
- pdaFindFunction: (name) => `find${(0, import_nodes.pascalCase)(name)}Pda`,
221
- pdaSeedsType: (name) => `${(0, import_nodes.pascalCase)(name)}Seeds`,
222
- programAccountsEnum: (name) => `${(0, import_nodes.pascalCase)(name)}Account`,
223
- programAccountsEnumVariant: (name) => `${(0, import_nodes.pascalCase)(name)}`,
224
- programAccountsIdentifierFunction: (name) => `identify${(0, import_nodes.pascalCase)(name)}Account`,
225
- programAddressConstant: (name) => `${(0, import_nodes.snakeCase)(name).toUpperCase()}_PROGRAM_ADDRESS`,
226
- programErrorConstant: (name) => (0, import_nodes.snakeCase)(name).toUpperCase(),
227
- programErrorConstantPrefix: (name) => `${(0, import_nodes.snakeCase)(name).toUpperCase()}_ERROR__`,
228
- programErrorMessagesMap: (name) => `${(0, import_nodes.camelCase)(name)}ErrorMessages`,
229
- programErrorUnion: (name) => `${(0, import_nodes.pascalCase)(name)}Error`,
230
- programGetErrorMessageFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}ErrorMessage`,
231
- programInstructionsEnum: (name) => `${(0, import_nodes.pascalCase)(name)}Instruction`,
232
- programInstructionsEnumVariant: (name) => `${(0, import_nodes.pascalCase)(name)}`,
233
- programInstructionsIdentifierFunction: (name) => `identify${(0, import_nodes.pascalCase)(name)}Instruction`,
234
- programInstructionsParsedUnionType: (name) => `Parsed${(0, import_nodes.pascalCase)(name)}Instruction`,
235
- programIsErrorFunction: (name) => `is${(0, import_nodes.pascalCase)(name)}Error`,
236
- resolverFunction: (name) => `${(0, import_nodes.camelCase)(name)}`
188
+ discriminatedUnionFunction: (name) => `${nodes.camelCase(name)}`,
189
+ discriminatedUnionVariant: (name) => `${nodes.pascalCase(name)}`,
190
+ encoderFunction: (name) => `get${nodes.pascalCase(name)}Encoder`,
191
+ enumVariant: (name) => `${nodes.pascalCase(name)}`,
192
+ instructionAsyncFunction: (name) => `get${nodes.pascalCase(name)}InstructionAsync`,
193
+ instructionAsyncInputType: (name) => `${nodes.pascalCase(name)}AsyncInput`,
194
+ instructionDataType: (name) => `${nodes.pascalCase(name)}InstructionData`,
195
+ instructionExtraType: (name) => `${nodes.pascalCase(name)}InstructionExtra`,
196
+ instructionParseFunction: (name) => `parse${nodes.pascalCase(name)}Instruction`,
197
+ instructionParsedType: (name) => `Parsed${nodes.pascalCase(name)}Instruction`,
198
+ instructionSyncFunction: (name) => `get${nodes.pascalCase(name)}Instruction`,
199
+ instructionSyncInputType: (name) => `${nodes.pascalCase(name)}Input`,
200
+ instructionType: (name) => `${nodes.pascalCase(name)}Instruction`,
201
+ isDiscriminatedUnionFunction: (name) => `is${nodes.pascalCase(name)}`,
202
+ pdaFindFunction: (name) => `find${nodes.pascalCase(name)}Pda`,
203
+ pdaSeedsType: (name) => `${nodes.pascalCase(name)}Seeds`,
204
+ programAccountsEnum: (name) => `${nodes.pascalCase(name)}Account`,
205
+ programAccountsEnumVariant: (name) => `${nodes.pascalCase(name)}`,
206
+ programAccountsIdentifierFunction: (name) => `identify${nodes.pascalCase(name)}Account`,
207
+ programAddressConstant: (name) => `${nodes.snakeCase(name).toUpperCase()}_PROGRAM_ADDRESS`,
208
+ programErrorConstant: (name) => nodes.snakeCase(name).toUpperCase(),
209
+ programErrorConstantPrefix: (name) => `${nodes.snakeCase(name).toUpperCase()}_ERROR__`,
210
+ programErrorMessagesMap: (name) => `${nodes.camelCase(name)}ErrorMessages`,
211
+ programErrorUnion: (name) => `${nodes.pascalCase(name)}Error`,
212
+ programGetErrorMessageFunction: (name) => `get${nodes.pascalCase(name)}ErrorMessage`,
213
+ programInstructionsEnum: (name) => `${nodes.pascalCase(name)}Instruction`,
214
+ programInstructionsEnumVariant: (name) => `${nodes.pascalCase(name)}`,
215
+ programInstructionsIdentifierFunction: (name) => `identify${nodes.pascalCase(name)}Instruction`,
216
+ programInstructionsParsedUnionType: (name) => `Parsed${nodes.pascalCase(name)}Instruction`,
217
+ programIsErrorFunction: (name) => `is${nodes.pascalCase(name)}Error`,
218
+ resolverFunction: (name) => `${nodes.camelCase(name)}`
237
219
  };
238
-
239
- // src/utils/fragment.ts
240
- var import_renderers_core = require("@codama/renderers-core");
241
220
  function createFragment(content) {
242
221
  return Object.freeze({ content, features: /* @__PURE__ */ new Set(), imports: createImportMap() });
243
222
  }
@@ -245,7 +224,7 @@ function isFragment(value) {
245
224
  return typeof value === "object" && value !== null && "content" in value;
246
225
  }
247
226
  function fragment(template, ...items) {
248
- return (0, import_renderers_core.createFragmentTemplate)(template, items, isFragment, mergeFragments);
227
+ return renderersCore.createFragmentTemplate(template, items, isFragment, mergeFragments);
249
228
  }
250
229
  function mergeFragments(fragments, mergeContent) {
251
230
  const filteredFragments = fragments.filter((f) => f !== void 0);
@@ -255,24 +234,24 @@ function mergeFragments(fragments, mergeContent) {
255
234
  imports: mergeImportMaps(filteredFragments.map((f) => f.imports))
256
235
  });
257
236
  }
258
- function use(importInput, module2) {
237
+ function use(importInput, module) {
259
238
  const importInfo = parseImportInput(importInput);
260
- return addFragmentImports(createFragment(importInfo.usedIdentifier), module2, [importInput]);
239
+ return addFragmentImports(createFragment(importInfo.usedIdentifier), module, [importInput]);
261
240
  }
262
241
  function mergeFragmentImports(fragment2, importMaps) {
263
242
  return Object.freeze({ ...fragment2, imports: mergeImportMaps([fragment2.imports, ...importMaps]) });
264
243
  }
265
- function addFragmentImports(fragment2, module2, importInputs) {
266
- return Object.freeze({ ...fragment2, imports: addToImportMap(fragment2.imports, module2, importInputs) });
244
+ function addFragmentImports(fragment2, module, importInputs) {
245
+ return Object.freeze({ ...fragment2, imports: addToImportMap(fragment2.imports, module, importInputs) });
267
246
  }
268
- function removeFragmentImports(fragment2, module2, usedIdentifiers) {
269
- return Object.freeze({ ...fragment2, imports: removeFromImportMap(fragment2.imports, module2, usedIdentifiers) });
247
+ function removeFragmentImports(fragment2, module, usedIdentifiers) {
248
+ return Object.freeze({ ...fragment2, imports: removeFromImportMap(fragment2.imports, module, usedIdentifiers) });
270
249
  }
271
250
  function addFragmentFeatures(fragment2, features) {
272
251
  return Object.freeze({ ...fragment2, features: /* @__PURE__ */ new Set([...fragment2.features, ...features]) });
273
252
  }
274
- function getExportAllFragment(module2) {
275
- return fragment`export * from '${module2}';`;
253
+ function getExportAllFragment(module) {
254
+ return fragment`export * from '${module}';`;
276
255
  }
277
256
  function getDocblockFragment(lines, withLineJump = false) {
278
257
  const lineJump = withLineJump ? "\n" : "";
@@ -317,24 +296,12 @@ function mergeTypeManifests(manifests, options = {}) {
317
296
  value: merge((m) => m.value, mergeValues)
318
297
  });
319
298
  }
320
-
321
- // src/visitors/getRenderMapVisitor.ts
322
- var import_nodes29 = require("@codama/nodes");
323
- var import_renderers_core14 = require("@codama/renderers-core");
324
- var import_visitors_core29 = require("@codama/visitors-core");
325
-
326
- // src/fragments/accountFetchHelpers.ts
327
- var import_visitors_core2 = require("@codama/visitors-core");
328
-
329
- // src/utils/async.ts
330
- var import_nodes2 = require("@codama/nodes");
331
- var import_visitors_core = require("@codama/visitors-core");
332
299
  function hasAsyncFunction(instructionNode, resolvedInputs, asyncResolvers) {
333
300
  const hasByteDeltasAsync = (instructionNode.byteDeltas ?? []).some(
334
- ({ value }) => (0, import_nodes2.isNode)(value, "resolverValueNode") && asyncResolvers.includes(value.name)
301
+ ({ value }) => nodes.isNode(value, "resolverValueNode") && asyncResolvers.includes(value.name)
335
302
  );
336
303
  const hasRemainingAccountsAsync = (instructionNode.remainingAccounts ?? []).some(
337
- ({ value }) => (0, import_nodes2.isNode)(value, "resolverValueNode") && asyncResolvers.includes(value.name)
304
+ ({ value }) => nodes.isNode(value, "resolverValueNode") && asyncResolvers.includes(value.name)
338
305
  );
339
306
  return hasAsyncDefaultValues(resolvedInputs, asyncResolvers) || hasByteDeltasAsync || hasRemainingAccountsAsync;
340
307
  }
@@ -356,8 +323,8 @@ function isAsyncDefaultValue(defaultValue, asyncResolvers) {
356
323
  }
357
324
  }
358
325
  function getInstructionDependencies(input, asyncResolvers, useAsync) {
359
- if ((0, import_nodes2.isNode)(input, "instructionNode")) {
360
- return (0, import_visitors_core.deduplicateInstructionDependencies)([
326
+ if (nodes.isNode(input, "instructionNode")) {
327
+ return visitorsCore.deduplicateInstructionDependencies([
361
328
  ...input.accounts.flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync)),
362
329
  ...input.arguments.flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync)),
363
330
  ...(input.extraArguments ?? []).flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync))
@@ -368,29 +335,29 @@ function getInstructionDependencies(input, asyncResolvers, useAsync) {
368
335
  if (!defaultValue) return [];
369
336
  return getInstructionDependencies({ ...input, defaultValue }, asyncResolvers, useAsync);
370
337
  };
371
- if ((0, import_nodes2.isNode)(input.defaultValue, ["accountValueNode", "accountBumpValueNode"])) {
372
- return [(0, import_nodes2.accountValueNode)(input.defaultValue.name)];
338
+ if (nodes.isNode(input.defaultValue, ["accountValueNode", "accountBumpValueNode"])) {
339
+ return [nodes.accountValueNode(input.defaultValue.name)];
373
340
  }
374
- if ((0, import_nodes2.isNode)(input.defaultValue, ["argumentValueNode"])) {
375
- return [(0, import_nodes2.argumentValueNode)(input.defaultValue.name)];
341
+ if (nodes.isNode(input.defaultValue, ["argumentValueNode"])) {
342
+ return [nodes.argumentValueNode(input.defaultValue.name)];
376
343
  }
377
- if ((0, import_nodes2.isNode)(input.defaultValue, "pdaValueNode")) {
344
+ if (nodes.isNode(input.defaultValue, "pdaValueNode")) {
378
345
  const dependencies = /* @__PURE__ */ new Map();
379
346
  input.defaultValue.seeds.forEach((seed) => {
380
- if ((0, import_nodes2.isNode)(seed.value, ["accountValueNode", "argumentValueNode"])) {
347
+ if (nodes.isNode(seed.value, ["accountValueNode", "argumentValueNode"])) {
381
348
  dependencies.set(seed.value.name, { ...seed.value });
382
349
  }
383
350
  });
384
351
  return [...dependencies.values()];
385
352
  }
386
- if ((0, import_nodes2.isNode)(input.defaultValue, "resolverValueNode")) {
353
+ if (nodes.isNode(input.defaultValue, "resolverValueNode")) {
387
354
  const isSynchronousResolver = !asyncResolvers.includes(input.defaultValue.name);
388
355
  if (useAsync || isSynchronousResolver) {
389
356
  return input.defaultValue.dependsOn ?? [];
390
357
  }
391
358
  }
392
- if ((0, import_nodes2.isNode)(input.defaultValue, "conditionalValueNode")) {
393
- return (0, import_visitors_core.deduplicateInstructionDependencies)([
359
+ if (nodes.isNode(input.defaultValue, "conditionalValueNode")) {
360
+ return visitorsCore.deduplicateInstructionDependencies([
394
361
  ...getNestedDependencies(input.defaultValue.condition),
395
362
  ...getNestedDependencies(input.defaultValue.ifTrue),
396
363
  ...getNestedDependencies(input.defaultValue.ifFalse)
@@ -398,58 +365,75 @@ function getInstructionDependencies(input, asyncResolvers, useAsync) {
398
365
  }
399
366
  return [];
400
367
  }
401
-
402
- // src/utils/codecs.ts
403
- var import_codecs_strings = require("@solana/codecs-strings");
404
368
  function getBytesFromBytesValueNode(node) {
405
369
  switch (node.encoding) {
406
370
  case "utf8":
407
- return (0, import_codecs_strings.getUtf8Encoder)().encode(node.data);
371
+ return codecsStrings.getUtf8Encoder().encode(node.data);
408
372
  case "base16":
409
- return (0, import_codecs_strings.getBase16Encoder)().encode(node.data);
373
+ return codecsStrings.getBase16Encoder().encode(node.data);
410
374
  case "base58":
411
- return (0, import_codecs_strings.getBase58Encoder)().encode(node.data);
375
+ return codecsStrings.getBase58Encoder().encode(node.data);
412
376
  case "base64":
413
377
  default:
414
- return (0, import_codecs_strings.getBase64Encoder)().encode(node.data);
378
+ return codecsStrings.getBase64Encoder().encode(node.data);
415
379
  }
416
380
  }
417
-
418
- // src/utils/customData.ts
419
- var import_nodes3 = require("@codama/nodes");
420
381
  var parseCustomDataOptions = (customDataOptions, defaultSuffix) => new Map(
421
382
  customDataOptions.map((o) => {
422
383
  const options = typeof o === "string" ? { name: o } : o;
423
- const importAs = (0, import_nodes3.camelCase)(options.importAs ?? `${options.name}${defaultSuffix}`);
384
+ const importAs = nodes.camelCase(options.importAs ?? `${options.name}${defaultSuffix}`);
424
385
  const importFrom = options.importFrom ?? "hooked";
425
386
  return [
426
- (0, import_nodes3.camelCase)(options.name),
387
+ nodes.camelCase(options.name),
427
388
  {
428
389
  extract: options.extract ?? false,
429
- extractAs: options.extractAs ? (0, import_nodes3.camelCase)(options.extractAs) : importAs,
390
+ extractAs: options.extractAs ? nodes.camelCase(options.extractAs) : importAs,
430
391
  importAs,
431
392
  importFrom,
432
- linkNode: (0, import_nodes3.definedTypeLinkNode)(importAs)
393
+ linkNode: nodes.definedTypeLinkNode(importAs)
433
394
  }
434
395
  ];
435
396
  })
436
397
  );
437
- var getDefinedTypeNodesToExtract = (nodes, parsedCustomDataOptions) => nodes.flatMap((node) => {
398
+ var getDefinedTypeNodesToExtract = (nodes$1, parsedCustomDataOptions) => nodes$1.flatMap((node) => {
438
399
  const options = parsedCustomDataOptions.get(node.name);
439
400
  if (!options || !options.extract) return [];
440
- if ((0, import_nodes3.isNode)(node, "accountNode")) {
441
- return [(0, import_nodes3.definedTypeNode)({ name: options.extractAs, type: { ...node.data } })];
401
+ if (nodes.isNode(node, "accountNode")) {
402
+ return [nodes.definedTypeNode({ name: options.extractAs, type: { ...node.data } })];
442
403
  }
443
404
  return [
444
- (0, import_nodes3.definedTypeNode)({
405
+ nodes.definedTypeNode({
445
406
  name: options.extractAs,
446
- type: (0, import_nodes3.structTypeNodeFromInstructionArgumentNodes)(node.arguments)
407
+ type: nodes.structTypeNodeFromInstructionArgumentNodes(node.arguments)
447
408
  })
448
409
  ];
449
410
  });
450
-
451
- // src/utils/linkOverrides.ts
452
- var import_errors = require("@codama/errors");
411
+ var DEFAULT_PRETTIER_OPTIONS = {
412
+ arrowParens: "always",
413
+ parser: "typescript",
414
+ plugins: [estreePlugin__namespace, typeScriptPlugin__namespace],
415
+ printWidth: 80,
416
+ semi: true,
417
+ singleQuote: true,
418
+ tabWidth: 2,
419
+ trailingComma: "es5",
420
+ useTabs: false
421
+ };
422
+ async function formatCode(renderMap, options) {
423
+ const shouldFormatCode = options.formatCode ?? true;
424
+ if (!shouldFormatCode) return renderMap;
425
+ const prettierOptions = {
426
+ ...DEFAULT_PRETTIER_OPTIONS,
427
+ ...await resolvePrettierOptions(options.packageFolder),
428
+ ...options.prettierOptions
429
+ };
430
+ return await renderersCore.mapRenderMapContentAsync(renderMap, (code) => prettier.format(code, prettierOptions));
431
+ }
432
+ async function resolvePrettierOptions(packageFolder) {
433
+ {
434
+ return null;
435
+ }
436
+ }
453
437
  function getImportFromFactory(overrides, customAccountData, customInstructionData) {
454
438
  const customDataOverrides = Object.fromEntries(
455
439
  [...customAccountData.values(), ...customInstructionData.values()].map(({ importFrom, importAs }) => [
@@ -481,7 +465,7 @@ function getImportFromFactory(overrides, customAccountData, customInstructionDat
481
465
  case "resolverValueNode":
482
466
  return linkOverrides.resolvers[node.name] ?? "hooked";
483
467
  default:
484
- throw new import_errors.CodamaError(import_errors.CODAMA_ERROR__UNEXPECTED_NODE_KIND, {
468
+ throw new errors.CodamaError(errors.CODAMA_ERROR__UNEXPECTED_NODE_KIND, {
485
469
  expectedKinds: [
486
470
  "AccountLinkNode",
487
471
  "DefinedTypeLinkNode",
@@ -496,11 +480,6 @@ function getImportFromFactory(overrides, customAccountData, customInstructionDat
496
480
  }
497
481
  };
498
482
  }
499
-
500
- // src/utils/packageJson.ts
501
- var import_errors2 = require("@codama/errors");
502
- var import_renderers_core2 = require("@codama/renderers-core");
503
- var import_semver = require("semver");
504
483
  var DEFAULT_DEPENDENCY_VERSIONS = {
505
484
  "@solana/accounts": "^5.0.0",
506
485
  "@solana/addresses": "^5.0.0",
@@ -517,11 +496,11 @@ function syncPackageJson(renderMap, options) {
517
496
  const packageFolder = options.packageFolder;
518
497
  if (!packageFolder) {
519
498
  if (shouldSyncPackageJson) {
520
- (0, import_errors2.logWarn)("Cannot sync package.json. Please provide the 'packageFolder' option.");
499
+ errors.logWarn("Cannot sync package.json. Please provide the 'packageFolder' option.");
521
500
  }
522
501
  return;
523
502
  }
524
- const packageJsonPath = (0, import_renderers_core2.joinPath)(packageFolder, "package.json");
503
+ const packageJsonPath = renderersCore.joinPath(packageFolder, "package.json");
525
504
  const usedDependencies = getUsedDependencyVersions(
526
505
  renderMap,
527
506
  options.dependencyMap ?? {},
@@ -529,17 +508,17 @@ function syncPackageJson(renderMap, options) {
529
508
  options.useGranularImports ?? false
530
509
  );
531
510
  if (!shouldSyncPackageJson) {
532
- if ((0, import_renderers_core2.fileExists)(packageJsonPath)) {
533
- checkExistingPackageJson((0, import_renderers_core2.readJson)(packageJsonPath), usedDependencies);
511
+ if (renderersCore.fileExists(packageJsonPath)) {
512
+ checkExistingPackageJson(renderersCore.readJson(packageJsonPath), usedDependencies);
534
513
  }
535
514
  return;
536
515
  }
537
- if ((0, import_renderers_core2.fileExists)(packageJsonPath)) {
538
- const packageJson = updateExistingPackageJson((0, import_renderers_core2.readJson)(packageJsonPath), usedDependencies);
539
- (0, import_renderers_core2.writeFile)(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
516
+ if (renderersCore.fileExists(packageJsonPath)) {
517
+ const packageJson = updateExistingPackageJson(renderersCore.readJson(packageJsonPath), usedDependencies);
518
+ renderersCore.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
540
519
  } else {
541
520
  const packageJson = createNewPackageJson(usedDependencies);
542
- (0, import_renderers_core2.writeFile)(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
521
+ renderersCore.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
543
522
  }
544
523
  }
545
524
  function createNewPackageJson(dependencyVersions) {
@@ -609,7 +588,7 @@ function checkExistingPackageJson(packageJson, dependencyVersions) {
609
588
  `).join("");
610
589
  const outdatedList = dependenciesToUpdate.map((d) => `- ${d} outdated: ${existingDependencies[d]} -> ${dependencyVersions[d]}
611
590
  `).join("");
612
- (0, import_errors2.logWarn)(
591
+ errors.logWarn(
613
592
  `The following dependencies in your \`package.json\` are out-of-date or missing:
614
593
  ${missingList}${outdatedList}`
615
594
  );
@@ -634,7 +613,7 @@ function getUsedDependencyVersions(renderMap, dependencyMap, dependencyVersions,
634
613
  [{}, /* @__PURE__ */ new Set()]
635
614
  );
636
615
  if (missingDependencies.size > 0) {
637
- throw new import_errors2.CodamaError(import_errors2.CODAMA_ERROR__RENDERERS__MISSING_DEPENDENCY_VERSIONS, {
616
+ throw new errors.CodamaError(errors.CODAMA_ERROR__RENDERERS__MISSING_DEPENDENCY_VERSIONS, {
638
617
  dependencies: [...missingDependencies],
639
618
  message: "Please add these dependencies to the `dependencyVersions` option."
640
619
  });
@@ -643,15 +622,15 @@ function getUsedDependencyVersions(renderMap, dependencyMap, dependencyVersions,
643
622
  }
644
623
  function shouldUpdateRange(dependency, currentRange, requiredRange) {
645
624
  try {
646
- if ((0, import_semver.subset)(currentRange, requiredRange)) {
625
+ if (semver.subset(currentRange, requiredRange)) {
647
626
  return false;
648
627
  }
649
- const minRequiredVersion = (0, import_semver.minVersion)(requiredRange);
650
- const minCurrentVersion = (0, import_semver.minVersion)(currentRange);
628
+ const minRequiredVersion = semver.minVersion(requiredRange);
629
+ const minCurrentVersion = semver.minVersion(currentRange);
651
630
  if (!minCurrentVersion || !minRequiredVersion) {
652
631
  throw new Error("Could not determine minimum versions.");
653
632
  }
654
- if ((0, import_semver.lt)(minCurrentVersion, minRequiredVersion)) {
633
+ if (semver.lt(minCurrentVersion, minRequiredVersion)) {
655
634
  return true;
656
635
  }
657
636
  return false;
@@ -671,7 +650,7 @@ function updateDependency(dependencyGroup, dependency, requiredRange) {
671
650
  // src/fragments/accountFetchHelpers.ts
672
651
  function getAccountFetchHelpersFragment(scope) {
673
652
  const { accountPath, typeManifest: typeManifest2, nameApi, customAccountData } = scope;
674
- const accountNode = (0, import_visitors_core2.getLastNodeFromPath)(accountPath);
653
+ const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
675
654
  const decodeFunction = nameApi.accountDecodeFunction(accountNode.name);
676
655
  const fetchAllFunction = nameApi.accountFetchAllFunction(accountNode.name);
677
656
  const fetchAllMaybeFunction = nameApi.accountFetchAllMaybeFunction(accountNode.name);
@@ -680,7 +659,7 @@ function getAccountFetchHelpersFragment(scope) {
680
659
  const hasCustomData = customAccountData.has(accountNode.name);
681
660
  const accountType = hasCustomData ? typeManifest2.strictType : nameApi.dataType(accountNode.name);
682
661
  const decoderFunction = hasCustomData ? typeManifest2.decoder : `${nameApi.decoderFunction(accountNode.name)}()`;
683
- return (0, import_visitors_core2.pipe)(
662
+ return visitorsCore.pipe(
684
663
  fragment`export function ${decodeFunction}<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<${accountType}, TAddress>;
685
664
  export function ${decodeFunction}<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<${accountType}, TAddress>;
686
665
  export function ${decodeFunction}<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>): Account<${accountType}, TAddress> | MaybeAccount<${accountType}, TAddress> {
@@ -740,28 +719,20 @@ export async function ${fetchAllMaybeFunction}(
740
719
  ])
741
720
  );
742
721
  }
743
-
744
- // src/fragments/accountPage.ts
745
- var import_nodes9 = require("@codama/nodes");
746
- var import_visitors_core7 = require("@codama/visitors-core");
747
-
748
- // src/fragments/accountPdaHelpers.ts
749
- var import_nodes4 = require("@codama/nodes");
750
- var import_visitors_core3 = require("@codama/visitors-core");
751
722
  function getAccountPdaHelpersFragment(scope) {
752
723
  const { accountPath, nameApi, linkables, customAccountData, typeManifest: typeManifest2 } = scope;
753
- const accountNode = (0, import_visitors_core3.getLastNodeFromPath)(accountPath);
724
+ const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
754
725
  const pdaNode = accountNode.pda ? linkables.get([...accountPath, accountNode.pda]) : void 0;
755
726
  if (!pdaNode) return;
756
727
  const accountType = customAccountData.has(accountNode.name) ? typeManifest2.strictType : nameApi.dataType(accountNode.name);
757
728
  const importFrom = "generatedPdas";
758
729
  const pdaSeedsType = nameApi.pdaSeedsType(pdaNode.name);
759
730
  const findPdaFunction = nameApi.pdaFindFunction(pdaNode.name);
760
- const hasVariableSeeds = pdaNode.seeds.filter((0, import_nodes4.isNodeFilter)("variablePdaSeedNode")).length > 0;
731
+ const hasVariableSeeds = pdaNode.seeds.filter(nodes.isNodeFilter("variablePdaSeedNode")).length > 0;
761
732
  const fetchFromSeedsFunction = nameApi.accountFetchFromSeedsFunction(accountNode.name);
762
733
  const fetchMaybeFromSeedsFunction = nameApi.accountFetchMaybeFromSeedsFunction(accountNode.name);
763
734
  const fetchMaybeFunction = nameApi.accountFetchMaybeFunction(accountNode.name);
764
- return (0, import_visitors_core3.pipe)(
735
+ return visitorsCore.pipe(
765
736
  fragment`export async function ${fetchFromSeedsFunction}(
766
737
  rpc: Parameters<typeof fetchEncodedAccount>[0],
767
738
  ${hasVariableSeeds ? `seeds: ${pdaSeedsType},` : ""}
@@ -791,12 +762,9 @@ export async function ${fetchMaybeFromSeedsFunction}(
791
762
  ])
792
763
  );
793
764
  }
794
-
795
- // src/fragments/accountSizeHelpers.ts
796
- var import_visitors_core4 = require("@codama/visitors-core");
797
765
  function getAccountSizeHelpersFragment(scope) {
798
766
  const { accountPath, nameApi } = scope;
799
- const accountNode = (0, import_visitors_core4.getLastNodeFromPath)(accountPath);
767
+ const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
800
768
  if (accountNode.size == null) return;
801
769
  const getSizeFunction = nameApi.accountGetSizeFunction(accountNode.name);
802
770
  return fragment`export function ${getSizeFunction}(): number {
@@ -804,10 +772,6 @@ function getAccountSizeHelpersFragment(scope) {
804
772
  }`;
805
773
  }
806
774
 
807
- // src/fragments/accountType.ts
808
- var import_nodes7 = require("@codama/nodes");
809
- var import_visitors_core5 = require("@codama/visitors-core");
810
-
811
775
  // src/fragments/type.ts
812
776
  function getTypeFragment(scope) {
813
777
  const { name, manifest, nameApi, docs = [] } = scope;
@@ -821,9 +785,6 @@ function getTypeFragment(scope) {
821
785
  const looseExport = manifest.strictType.content === manifest.looseType.content ? aliasedLooseName : fragment`export type ${looseName} = ${manifest.looseType};`;
822
786
  return fragment`${docblock}export type ${strictName} = ${manifest.strictType};\n\n${looseExport}`;
823
787
  }
824
-
825
- // src/fragments/typeDecoder.ts
826
- var import_nodes5 = require("@codama/nodes");
827
788
  function getTypeDecoderFragment(scope) {
828
789
  const { name, node, manifest, nameApi, docs = [] } = scope;
829
790
  const decoderFunction = nameApi.decoderFunction(name);
@@ -833,15 +794,12 @@ function getTypeDecoderFragment(scope) {
833
794
  typeof scope.size === "number" ? "type FixedSizeDecoder" : "type Decoder",
834
795
  "solanaCodecsCore"
835
796
  );
836
- const useTypeCast = (0, import_nodes5.isNode)(node, "enumTypeNode") && (0, import_nodes5.isDataEnum)(node) && typeof scope.size === "number";
797
+ const useTypeCast = nodes.isNode(node, "enumTypeNode") && nodes.isDataEnum(node) && typeof scope.size === "number";
837
798
  const typeCast = useTypeCast ? fragment` as ${decoderType}<${strictName}>` : "";
838
799
  return fragment`${docblock}export function ${decoderFunction}(): ${decoderType}<${strictName}> {
839
800
  return ${manifest.decoder}${typeCast};
840
801
  }`;
841
802
  }
842
-
843
- // src/fragments/typeEncoder.ts
844
- var import_nodes6 = require("@codama/nodes");
845
803
  function getTypeEncoderFragment(scope) {
846
804
  const { name, node, manifest, nameApi, docs = [] } = scope;
847
805
  const encoderFunction = nameApi.encoderFunction(name);
@@ -851,7 +809,7 @@ function getTypeEncoderFragment(scope) {
851
809
  typeof scope.size === "number" ? "type FixedSizeEncoder" : "type Encoder",
852
810
  "solanaCodecsCore"
853
811
  );
854
- const useTypeCast = (0, import_nodes6.isNode)(node, "enumTypeNode") && (0, import_nodes6.isDataEnum)(node) && typeof scope.size === "number";
812
+ const useTypeCast = nodes.isNode(node, "enumTypeNode") && nodes.isDataEnum(node) && typeof scope.size === "number";
855
813
  const typeCast = useTypeCast ? fragment` as ${encoderType}<${looseName}>` : "";
856
814
  return fragment`${docblock}export function ${encoderFunction}(): ${encoderType}<${looseName}> {
857
815
  return ${manifest.encoder}${typeCast};
@@ -891,7 +849,7 @@ function getTypeWithCodecFragment(scope) {
891
849
  // src/fragments/accountType.ts
892
850
  function getAccountTypeFragment(scope) {
893
851
  const { accountPath, typeManifest: typeManifest2, nameApi, customAccountData } = scope;
894
- const accountNode = (0, import_visitors_core5.getLastNodeFromPath)(accountPath);
852
+ const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
895
853
  if (customAccountData.has(accountNode.name)) return;
896
854
  return getTypeWithCodecFragment({
897
855
  codecDocs: [`Gets the codec for {@link ${nameApi.dataType(accountNode.name)}} account data.`],
@@ -900,15 +858,11 @@ function getAccountTypeFragment(scope) {
900
858
  manifest: typeManifest2,
901
859
  name: accountNode.name,
902
860
  nameApi,
903
- node: (0, import_nodes7.resolveNestedTypeNode)(accountNode.data),
861
+ node: nodes.resolveNestedTypeNode(accountNode.data),
904
862
  size: scope.size,
905
863
  typeDocs: accountNode.docs
906
864
  });
907
865
  }
908
-
909
- // src/fragments/discriminatorConstants.ts
910
- var import_nodes8 = require("@codama/nodes");
911
- var import_visitors_core6 = require("@codama/visitors-core");
912
866
  function getDiscriminatorConstantsFragment(scope) {
913
867
  const fragments = scope.discriminatorNodes.map((node) => getDiscriminatorConstantFragment(node, scope)).filter(Boolean);
914
868
  return mergeFragments(fragments, (c) => c.join("\n\n"));
@@ -925,22 +879,22 @@ function getDiscriminatorConstantFragment(discriminatorNode, scope) {
925
879
  }
926
880
  function getConstantDiscriminatorConstantFragment(discriminatorNode, scope) {
927
881
  const { discriminatorNodes, typeManifestVisitor, prefix } = scope;
928
- const index = discriminatorNodes.filter((0, import_nodes8.isNodeFilter)("constantDiscriminatorNode")).indexOf(discriminatorNode);
882
+ const index = discriminatorNodes.filter(nodes.isNodeFilter("constantDiscriminatorNode")).indexOf(discriminatorNode);
929
883
  const suffix = index <= 0 ? "" : `_${index + 1}`;
930
- const name = (0, import_nodes8.camelCase)(`${prefix}_discriminator${suffix}`);
931
- const encoder = (0, import_visitors_core6.visit)(discriminatorNode.constant.type, typeManifestVisitor).encoder;
932
- const value = (0, import_visitors_core6.visit)(discriminatorNode.constant.value, typeManifestVisitor).value;
884
+ const name = nodes.camelCase(`${prefix}_discriminator${suffix}`);
885
+ const encoder = visitorsCore.visit(discriminatorNode.constant.type, typeManifestVisitor).encoder;
886
+ const value = visitorsCore.visit(discriminatorNode.constant.value, typeManifestVisitor).value;
933
887
  return getConstantFragment({ ...scope, encoder, name, value });
934
888
  }
935
889
  function getFieldDiscriminatorConstantFragment(discriminatorNode, scope) {
936
890
  const { fields, prefix, typeManifestVisitor } = scope;
937
891
  const field = fields.find((f) => f.name === discriminatorNode.name);
938
- if (!field || !field.defaultValue || !(0, import_nodes8.isNode)(field.defaultValue, import_nodes8.VALUE_NODES)) {
892
+ if (!field || !field.defaultValue || !nodes.isNode(field.defaultValue, nodes.VALUE_NODES)) {
939
893
  return null;
940
894
  }
941
- const name = (0, import_nodes8.camelCase)(`${prefix}_${discriminatorNode.name}`);
942
- const encoder = (0, import_visitors_core6.visit)(field.type, typeManifestVisitor).encoder;
943
- const value = (0, import_visitors_core6.visit)(field.defaultValue, typeManifestVisitor).value;
895
+ const name = nodes.camelCase(`${prefix}_${discriminatorNode.name}`);
896
+ const encoder = visitorsCore.visit(field.type, typeManifestVisitor).encoder;
897
+ const value = visitorsCore.visit(field.defaultValue, typeManifestVisitor).value;
944
898
  return getConstantFragment({ ...scope, encoder, name, value });
945
899
  }
946
900
  function getConstantFragment(scope) {
@@ -952,12 +906,12 @@ function getConstantFragment(scope) {
952
906
 
953
907
  // src/fragments/accountPage.ts
954
908
  function getAccountPageFragment(scope) {
955
- const node = (0, import_visitors_core7.getLastNodeFromPath)(scope.accountPath);
956
- if (!(0, import_visitors_core7.findProgramNodeFromPath)(scope.accountPath)) {
909
+ const node = visitorsCore.getLastNodeFromPath(scope.accountPath);
910
+ if (!visitorsCore.findProgramNodeFromPath(scope.accountPath)) {
957
911
  throw new Error("Account must be visited inside a program.");
958
912
  }
959
- const typeManifest2 = (0, import_visitors_core7.visit)(node, scope.typeManifestVisitor);
960
- const fields = (0, import_nodes9.resolveNestedTypeNode)(node.data).fields;
913
+ const typeManifest2 = visitorsCore.visit(node, scope.typeManifestVisitor);
914
+ const fields = nodes.resolveNestedTypeNode(node.data).fields;
961
915
  return mergeFragments(
962
916
  [
963
917
  getDiscriminatorConstantsFragment({
@@ -974,30 +928,24 @@ function getAccountPageFragment(scope) {
974
928
  (cs) => cs.join("\n\n")
975
929
  );
976
930
  }
977
-
978
- // src/fragments/discriminatorCondition.ts
979
- var import_nodes10 = require("@codama/nodes");
980
- var import_renderers_core3 = require("@codama/renderers-core");
981
- var import_visitors_core8 = require("@codama/visitors-core");
982
- var import_codecs_strings2 = require("@solana/codecs-strings");
983
931
  function getDiscriminatorConditionFragment(scope) {
984
- return (0, import_visitors_core8.pipe)(
932
+ return visitorsCore.pipe(
985
933
  mergeFragments(
986
934
  scope.discriminators.flatMap((discriminator) => {
987
- if ((0, import_nodes10.isNode)(discriminator, "sizeDiscriminatorNode")) {
935
+ if (nodes.isNode(discriminator, "sizeDiscriminatorNode")) {
988
936
  return [getSizeConditionFragment(discriminator, scope)];
989
937
  }
990
- if ((0, import_nodes10.isNode)(discriminator, "constantDiscriminatorNode")) {
938
+ if (nodes.isNode(discriminator, "constantDiscriminatorNode")) {
991
939
  return [getByteConditionFragment(discriminator, scope)];
992
940
  }
993
- if ((0, import_nodes10.isNode)(discriminator, "fieldDiscriminatorNode")) {
941
+ if (nodes.isNode(discriminator, "fieldDiscriminatorNode")) {
994
942
  return [getFieldConditionFragment(discriminator, scope)];
995
943
  }
996
944
  return [];
997
945
  }),
998
946
  (c) => c.join(" && ")
999
947
  ),
1000
- (f) => (0, import_renderers_core3.mapFragmentContent)(f, (c) => `if (${c}) { ${scope.ifTrue} }`)
948
+ (f) => renderersCore.mapFragmentContent(f, (c) => `if (${c}) { ${scope.ifTrue} }`)
1001
949
  );
1002
950
  }
1003
951
  function getSizeConditionFragment(discriminator, scope) {
@@ -1006,7 +954,7 @@ function getSizeConditionFragment(discriminator, scope) {
1006
954
  }
1007
955
  function getByteConditionFragment(discriminator, scope) {
1008
956
  const { dataName, typeManifestVisitor } = scope;
1009
- const constant = (0, import_visitors_core8.visit)(discriminator.constant, typeManifestVisitor).value;
957
+ const constant = visitorsCore.visit(discriminator.constant, typeManifestVisitor).value;
1010
958
  return fragment`${use("containsBytes", "solanaCodecsCore")}(${dataName}, ${constant}, ${discriminator.offset})`;
1011
959
  }
1012
960
  function getFieldConditionFragment(discriminator, scope) {
@@ -1016,17 +964,17 @@ function getFieldConditionFragment(discriminator, scope) {
1016
964
  `Field discriminator "${discriminator.name}" does not have a matching argument with default value.`
1017
965
  );
1018
966
  }
1019
- if ((0, import_nodes10.isNode)(field.type, "arrayTypeNode") && (0, import_nodes10.isNode)(field.type.item, "numberTypeNode") && field.type.item.format === "u8" && (0, import_nodes10.isNode)(field.type.count, "fixedCountNode") && (0, import_nodes10.isNode)(field.defaultValue, "arrayValueNode") && field.defaultValue.items.every((0, import_nodes10.isNodeFilter)("numberValueNode"))) {
1020
- const base64Bytes = (0, import_codecs_strings2.getBase64Decoder)().decode(
967
+ 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"))) {
968
+ const base64Bytes = codecsStrings.getBase64Decoder().decode(
1021
969
  new Uint8Array(field.defaultValue.items.map((node) => node.number))
1022
970
  );
1023
971
  return getByteConditionFragment(
1024
- (0, import_nodes10.constantDiscriminatorNode)((0, import_nodes10.constantValueNodeFromBytes)("base64", base64Bytes), discriminator.offset),
972
+ nodes.constantDiscriminatorNode(nodes.constantValueNodeFromBytes("base64", base64Bytes), discriminator.offset),
1025
973
  scope
1026
974
  );
1027
975
  }
1028
976
  return getByteConditionFragment(
1029
- (0, import_nodes10.constantDiscriminatorNode)((0, import_nodes10.constantValueNode)(field.type, field.defaultValue), discriminator.offset),
977
+ nodes.constantDiscriminatorNode(nodes.constantValueNode(field.type, field.defaultValue), discriminator.offset),
1030
978
  scope
1031
979
  );
1032
980
  }
@@ -1106,19 +1054,13 @@ function getIsErrorFunctionFragment(scope) {
1106
1054
  return ${use("isProgramError", "solanaPrograms")}<TProgramErrorCode>(error, transactionMessage, ${programAddressConstant}, code);
1107
1055
  }`;
1108
1056
  }
1109
-
1110
- // src/fragments/indexPage.ts
1111
- var import_nodes11 = require("@codama/nodes");
1112
1057
  function getIndexPageFragment(items) {
1113
1058
  if (items.length === 0) return;
1114
- const names = items.map((item) => (0, import_nodes11.camelCase)(item.name)).sort((a, b) => a.localeCompare(b)).map((name) => getExportAllFragment(`./${name}`));
1059
+ const names = items.map((item) => nodes.camelCase(item.name)).sort((a, b) => a.localeCompare(b)).map((name) => getExportAllFragment(`./${name}`));
1115
1060
  return mergeFragments(names, (cs) => cs.join("\n"));
1116
1061
  }
1117
-
1118
- // src/fragments/instructionAccountMeta.ts
1119
- var import_nodes12 = require("@codama/nodes");
1120
1062
  function getInstructionAccountMetaFragment(instructionAccountNode) {
1121
- const typeParam = `TAccount${(0, import_nodes12.pascalCase)(instructionAccountNode.name)}`;
1063
+ const typeParam = `TAccount${nodes.pascalCase(instructionAccountNode.name)}`;
1122
1064
  if (instructionAccountNode.isSigner === true && instructionAccountNode.isWritable) {
1123
1065
  return fragment`${use("type WritableSignerAccount", "solanaInstructions")}<${typeParam}> & ${use("type AccountSignerMeta", "solanaSigners")}<${typeParam}>`;
1124
1066
  }
@@ -1130,17 +1072,13 @@ function getInstructionAccountMetaFragment(instructionAccountNode) {
1130
1072
  }
1131
1073
  return fragment`${use("type ReadonlyAccount", "solanaInstructions")}<${typeParam}>`;
1132
1074
  }
1133
-
1134
- // src/fragments/instructionAccountTypeParam.ts
1135
- var import_nodes13 = require("@codama/nodes");
1136
- var import_visitors_core9 = require("@codama/visitors-core");
1137
1075
  function getInstructionAccountTypeParamFragment(scope) {
1138
- const { instructionAccountPath, allowAccountMeta, linkables } = scope;
1139
- const instructionAccountNode = (0, import_visitors_core9.getLastNodeFromPath)(instructionAccountPath);
1140
- const instructionNode = (0, import_visitors_core9.findInstructionNodeFromPath)(instructionAccountPath);
1141
- const programNode = (0, import_visitors_core9.findProgramNodeFromPath)(instructionAccountPath);
1142
- const typeParam = `TAccount${(0, import_nodes13.pascalCase)(instructionAccountNode.name)}`;
1143
- const accountMeta = allowAccountMeta ? fragment` | ${use("type AccountMeta", "solanaInstructions")}<string>` : void 0;
1076
+ const { instructionAccountPath, linkables } = scope;
1077
+ const instructionAccountNode = visitorsCore.getLastNodeFromPath(instructionAccountPath);
1078
+ const instructionNode = visitorsCore.findInstructionNodeFromPath(instructionAccountPath);
1079
+ const programNode = visitorsCore.findProgramNodeFromPath(instructionAccountPath);
1080
+ const typeParam = `TAccount${nodes.pascalCase(instructionAccountNode.name)}`;
1081
+ const accountMeta = fragment` | ${use("type AccountMeta", "solanaInstructions")}<string>` ;
1144
1082
  if (instructionNode.optionalAccountStrategy === "omitted" && instructionAccountNode.isOptional) {
1145
1083
  return fragment`${typeParam} extends string${accountMeta} | undefined = undefined`;
1146
1084
  }
@@ -1160,13 +1098,8 @@ function getDefaultAddress(defaultValue, programId, linkables) {
1160
1098
  return "string";
1161
1099
  }
1162
1100
  }
1163
-
1164
- // src/fragments/instructionByteDelta.ts
1165
- var import_nodes14 = require("@codama/nodes");
1166
- var import_renderers_core4 = require("@codama/renderers-core");
1167
- var import_visitors_core10 = require("@codama/visitors-core");
1168
1101
  function getInstructionByteDeltaFragment(scope) {
1169
- const { byteDeltas } = (0, import_visitors_core10.getLastNodeFromPath)(scope.instructionPath);
1102
+ const { byteDeltas } = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1170
1103
  const fragments = (byteDeltas ?? []).flatMap((c) => getByteDeltaFragment(c, scope));
1171
1104
  if (fragments.length === 0) return;
1172
1105
  return mergeFragments(
@@ -1177,16 +1110,16 @@ const byteDelta: number = [${c.join(",")}].reduce((a, b) => a + b, 0);`
1177
1110
  }
1178
1111
  function getByteDeltaFragment(byteDelta, scope) {
1179
1112
  let bytesFragment = (() => {
1180
- if ((0, import_nodes14.isNode)(byteDelta.value, "numberValueNode")) {
1113
+ if (nodes.isNode(byteDelta.value, "numberValueNode")) {
1181
1114
  return getNumberValueNodeFragment(byteDelta);
1182
1115
  }
1183
- if ((0, import_nodes14.isNode)(byteDelta.value, "argumentValueNode")) {
1116
+ if (nodes.isNode(byteDelta.value, "argumentValueNode")) {
1184
1117
  return getArgumentValueNodeFragment(byteDelta);
1185
1118
  }
1186
- if ((0, import_nodes14.isNode)(byteDelta.value, "accountLinkNode")) {
1119
+ if (nodes.isNode(byteDelta.value, "accountLinkNode")) {
1187
1120
  return getAccountLinkNodeFragment(byteDelta, scope);
1188
1121
  }
1189
- if ((0, import_nodes14.isNode)(byteDelta.value, "resolverValueNode")) {
1122
+ if (nodes.isNode(byteDelta.value, "resolverValueNode")) {
1190
1123
  return getResolverValueNodeFragment(byteDelta, scope);
1191
1124
  }
1192
1125
  return null;
@@ -1196,21 +1129,21 @@ function getByteDeltaFragment(byteDelta, scope) {
1196
1129
  bytesFragment = fragment`${bytesFragment} + ${use("BASE_ACCOUNT_SIZE", "solanaAccounts")}`;
1197
1130
  }
1198
1131
  if (byteDelta.subtract) {
1199
- bytesFragment = (0, import_visitors_core10.pipe)(bytesFragment, (f) => (0, import_renderers_core4.mapFragmentContent)(f, (c) => `- (${c})`));
1132
+ bytesFragment = visitorsCore.pipe(bytesFragment, (f) => renderersCore.mapFragmentContent(f, (c) => `- (${c})`));
1200
1133
  }
1201
1134
  return [bytesFragment];
1202
1135
  }
1203
1136
  function getNumberValueNodeFragment(byteDelta) {
1204
- (0, import_nodes14.assertIsNode)(byteDelta.value, "numberValueNode");
1137
+ nodes.assertIsNode(byteDelta.value, "numberValueNode");
1205
1138
  return fragment`${byteDelta.value.number}`;
1206
1139
  }
1207
1140
  function getArgumentValueNodeFragment(byteDelta) {
1208
- (0, import_nodes14.assertIsNode)(byteDelta.value, "argumentValueNode");
1209
- const argumentName = (0, import_nodes14.camelCase)(byteDelta.value.name);
1141
+ nodes.assertIsNode(byteDelta.value, "argumentValueNode");
1142
+ const argumentName = nodes.camelCase(byteDelta.value.name);
1210
1143
  return fragment`Number(args.${argumentName})`;
1211
1144
  }
1212
1145
  function getAccountLinkNodeFragment(byteDelta, scope) {
1213
- (0, import_nodes14.assertIsNode)(byteDelta.value, "accountLinkNode");
1146
+ nodes.assertIsNode(byteDelta.value, "accountLinkNode");
1214
1147
  const functionName = use(
1215
1148
  scope.nameApi.accountGetSizeFunction(byteDelta.value.name),
1216
1149
  scope.getImportFrom(byteDelta.value)
@@ -1218,7 +1151,7 @@ function getAccountLinkNodeFragment(byteDelta, scope) {
1218
1151
  return fragment`${functionName}()`;
1219
1152
  }
1220
1153
  function getResolverValueNodeFragment(byteDelta, scope) {
1221
- (0, import_nodes14.assertIsNode)(byteDelta.value, "resolverValueNode");
1154
+ nodes.assertIsNode(byteDelta.value, "resolverValueNode");
1222
1155
  const isAsync = scope.asyncResolvers.includes(byteDelta.value.name);
1223
1156
  if (!scope.useAsync && isAsync) return null;
1224
1157
  const awaitKeyword = scope.useAsync && isAsync ? "await " : "";
@@ -1226,55 +1159,32 @@ function getResolverValueNodeFragment(byteDelta, scope) {
1226
1159
  scope.nameApi.resolverFunction(byteDelta.value.name),
1227
1160
  scope.getImportFrom(byteDelta.value)
1228
1161
  );
1229
- return (0, import_visitors_core10.pipe)(
1162
+ return visitorsCore.pipe(
1230
1163
  fragment`${awaitKeyword}${functionName}(resolverScope)`,
1231
1164
  (f) => addFragmentFeatures(f, ["instruction:resolverScopeVariable"])
1232
1165
  );
1233
1166
  }
1234
-
1235
- // src/fragments/instructionData.ts
1236
- var import_nodes15 = require("@codama/nodes");
1237
- var import_visitors_core11 = require("@codama/visitors-core");
1238
1167
  function getInstructionDataFragment(scope) {
1239
1168
  const { instructionPath, dataArgsManifest, nameApi, customInstructionData } = scope;
1240
- const instructionNode = (0, import_visitors_core11.getLastNodeFromPath)(instructionPath);
1169
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1241
1170
  if (instructionNode.arguments.length === 0 || customInstructionData.has(instructionNode.name)) return;
1242
1171
  const instructionDataName = nameApi.instructionDataType(instructionNode.name);
1243
1172
  return getTypeWithCodecFragment({
1244
1173
  manifest: dataArgsManifest,
1245
1174
  name: instructionDataName,
1246
1175
  nameApi,
1247
- node: (0, import_nodes15.structTypeNodeFromInstructionArgumentNodes)(instructionNode.arguments),
1176
+ node: nodes.structTypeNodeFromInstructionArgumentNodes(instructionNode.arguments),
1248
1177
  size: scope.size
1249
1178
  });
1250
1179
  }
1251
-
1252
- // src/fragments/instructionExtraArgs.ts
1253
- var import_renderers_core5 = require("@codama/renderers-core");
1254
- var import_visitors_core12 = require("@codama/visitors-core");
1255
1180
  function getInstructionExtraArgsFragment(scope) {
1256
1181
  const { instructionPath, extraArgsManifest, nameApi } = scope;
1257
- const instructionNode = (0, import_visitors_core12.getLastNodeFromPath)(instructionPath);
1182
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1258
1183
  if ((instructionNode.extraArguments ?? []).length === 0) return;
1259
1184
  const instructionExtraName = nameApi.instructionExtraType(instructionNode.name);
1260
1185
  const looseName = nameApi.dataArgsType(instructionExtraName);
1261
- return (0, import_renderers_core5.mapFragmentContent)(extraArgsManifest.looseType, (c) => `export type ${looseName} = ${c};`);
1186
+ return renderersCore.mapFragmentContent(extraArgsManifest.looseType, (c) => `export type ${looseName} = ${c};`);
1262
1187
  }
1263
-
1264
- // src/fragments/instructionFunction.ts
1265
- var import_nodes20 = require("@codama/nodes");
1266
- var import_renderers_core9 = require("@codama/renderers-core");
1267
- var import_visitors_core17 = require("@codama/visitors-core");
1268
-
1269
- // src/fragments/instructionInputResolved.ts
1270
- var import_nodes17 = require("@codama/nodes");
1271
- var import_renderers_core7 = require("@codama/renderers-core");
1272
- var import_visitors_core14 = require("@codama/visitors-core");
1273
-
1274
- // src/fragments/instructionInputDefault.ts
1275
- var import_nodes16 = require("@codama/nodes");
1276
- var import_renderers_core6 = require("@codama/renderers-core");
1277
- var import_visitors_core13 = require("@codama/visitors-core");
1278
1188
  function getInstructionInputDefaultFragment(scope) {
1279
1189
  const { input, optionalAccountStrategy, asyncResolvers, useAsync, nameApi, typeManifestVisitor, getImportFrom } = scope;
1280
1190
  if (!input.defaultValue) {
@@ -1285,8 +1195,8 @@ function getInstructionInputDefaultFragment(scope) {
1285
1195
  }
1286
1196
  const { defaultValue } = input;
1287
1197
  const defaultFragment = (renderedValue, isWritable) => {
1288
- const inputName = (0, import_nodes16.camelCase)(input.name);
1289
- if (input.kind === "instructionAccountNode" && (0, import_nodes16.isNode)(defaultValue, "resolverValueNode")) {
1198
+ const inputName = nodes.camelCase(input.name);
1199
+ if (input.kind === "instructionAccountNode" && nodes.isNode(defaultValue, "resolverValueNode")) {
1290
1200
  return fragment`accounts.${inputName} = { ...accounts.${inputName}, ...${renderedValue} };`;
1291
1201
  }
1292
1202
  if (input.kind === "instructionAccountNode" && isWritable === void 0) {
@@ -1304,7 +1214,7 @@ function getInstructionInputDefaultFragment(scope) {
1304
1214
  const addressType = use("type Address", "solanaAddresses");
1305
1215
  switch (defaultValue.kind) {
1306
1216
  case "accountValueNode":
1307
- const name = (0, import_nodes16.camelCase)(defaultValue.name);
1217
+ const name = nodes.camelCase(defaultValue.name);
1308
1218
  if (input.kind === "instructionAccountNode" && input.resolvedIsSigner && !input.isSigner) {
1309
1219
  return defaultFragment(fragment`${expectTransactionSigner}(accounts.${name}.value).address`);
1310
1220
  }
@@ -1314,13 +1224,13 @@ function getInstructionInputDefaultFragment(scope) {
1314
1224
  return defaultFragment(fragment`${expectAddress}(accounts.${name}.value)`);
1315
1225
  case "pdaValueNode":
1316
1226
  let pdaProgramValue;
1317
- if ((0, import_nodes16.isNode)(defaultValue.programId, "accountValueNode")) {
1318
- pdaProgramValue = fragment`${expectAddress}(accounts.${(0, import_nodes16.camelCase)(defaultValue.programId.name)}.value)`;
1227
+ if (nodes.isNode(defaultValue.programId, "accountValueNode")) {
1228
+ pdaProgramValue = fragment`${expectAddress}(accounts.${nodes.camelCase(defaultValue.programId.name)}.value)`;
1319
1229
  }
1320
- if ((0, import_nodes16.isNode)(defaultValue.programId, "argumentValueNode")) {
1321
- pdaProgramValue = fragment`${expectAddress}(args.${(0, import_nodes16.camelCase)(defaultValue.programId.name)})`;
1230
+ if (nodes.isNode(defaultValue.programId, "argumentValueNode")) {
1231
+ pdaProgramValue = fragment`${expectAddress}(args.${nodes.camelCase(defaultValue.programId.name)})`;
1322
1232
  }
1323
- if ((0, import_nodes16.isNode)(defaultValue.pda, "pdaNode")) {
1233
+ if (nodes.isNode(defaultValue.pda, "pdaNode")) {
1324
1234
  let pdaProgram = fragment`programAddress`;
1325
1235
  if (pdaProgramValue) {
1326
1236
  pdaProgram = pdaProgramValue;
@@ -1328,29 +1238,29 @@ function getInstructionInputDefaultFragment(scope) {
1328
1238
  pdaProgram = fragment`'${defaultValue.pda.programId}' as ${addressType}<'${defaultValue.pda.programId}'>`;
1329
1239
  }
1330
1240
  const pdaSeeds2 = defaultValue.pda.seeds.flatMap((seed) => {
1331
- if ((0, import_nodes16.isNode)(seed, "constantPdaSeedNode") && (0, import_nodes16.isNode)(seed.value, "programIdValueNode")) {
1241
+ if (nodes.isNode(seed, "constantPdaSeedNode") && nodes.isNode(seed.value, "programIdValueNode")) {
1332
1242
  return [fragment`${use("getAddressEncoder", "solanaAddresses")}().encode(${pdaProgram})`];
1333
1243
  }
1334
- if ((0, import_nodes16.isNode)(seed, "constantPdaSeedNode") && !(0, import_nodes16.isNode)(seed.value, "programIdValueNode")) {
1335
- const typeManifest2 = (0, import_visitors_core13.visit)(seed.type, typeManifestVisitor);
1336
- const valueManifest2 = (0, import_visitors_core13.visit)(seed.value, typeManifestVisitor);
1244
+ if (nodes.isNode(seed, "constantPdaSeedNode") && !nodes.isNode(seed.value, "programIdValueNode")) {
1245
+ const typeManifest2 = visitorsCore.visit(seed.type, typeManifestVisitor);
1246
+ const valueManifest2 = visitorsCore.visit(seed.value, typeManifestVisitor);
1337
1247
  return [fragment`${typeManifest2.encoder}.encode(${valueManifest2.value})`];
1338
1248
  }
1339
- if ((0, import_nodes16.isNode)(seed, "variablePdaSeedNode")) {
1340
- const typeManifest2 = (0, import_visitors_core13.visit)(seed.type, typeManifestVisitor);
1249
+ if (nodes.isNode(seed, "variablePdaSeedNode")) {
1250
+ const typeManifest2 = visitorsCore.visit(seed.type, typeManifestVisitor);
1341
1251
  const valueSeed = defaultValue.seeds.find((s) => s.name === seed.name)?.value;
1342
1252
  if (!valueSeed) return [];
1343
- if ((0, import_nodes16.isNode)(valueSeed, "accountValueNode")) {
1253
+ if (nodes.isNode(valueSeed, "accountValueNode")) {
1344
1254
  return [
1345
- fragment`${typeManifest2.encoder}.encode(${expectAddress}(accounts.${(0, import_nodes16.camelCase)(valueSeed.name)}.value))`
1255
+ fragment`${typeManifest2.encoder}.encode(${expectAddress}(accounts.${nodes.camelCase(valueSeed.name)}.value))`
1346
1256
  ];
1347
1257
  }
1348
- if ((0, import_nodes16.isNode)(valueSeed, "argumentValueNode")) {
1258
+ if (nodes.isNode(valueSeed, "argumentValueNode")) {
1349
1259
  return [
1350
- fragment`${typeManifest2.encoder}.encode(${expectSome}(args.${(0, import_nodes16.camelCase)(valueSeed.name)}))`
1260
+ fragment`${typeManifest2.encoder}.encode(${expectSome}(args.${nodes.camelCase(valueSeed.name)}))`
1351
1261
  ];
1352
1262
  }
1353
- const valueManifest2 = (0, import_visitors_core13.visit)(valueSeed, typeManifestVisitor);
1263
+ const valueManifest2 = visitorsCore.visit(valueSeed, typeManifestVisitor);
1354
1264
  return [fragment`${typeManifest2.encoder}.encode(${valueManifest2.value})`];
1355
1265
  }
1356
1266
  return [];
@@ -1365,20 +1275,20 @@ function getInstructionInputDefaultFragment(scope) {
1365
1275
  const pdaFunction = use(nameApi.pdaFindFunction(defaultValue.pda.name), getImportFrom(defaultValue.pda));
1366
1276
  const pdaArgs = [];
1367
1277
  const pdaSeeds = defaultValue.seeds.map((seed) => {
1368
- if ((0, import_nodes16.isNode)(seed.value, "accountValueNode")) {
1369
- return fragment`${seed.name}: ${expectAddress}(accounts.${(0, import_nodes16.camelCase)(seed.value.name)}.value)`;
1278
+ if (nodes.isNode(seed.value, "accountValueNode")) {
1279
+ return fragment`${seed.name}: ${expectAddress}(accounts.${nodes.camelCase(seed.value.name)}.value)`;
1370
1280
  }
1371
- if ((0, import_nodes16.isNode)(seed.value, "argumentValueNode")) {
1372
- return fragment`${seed.name}: ${expectSome}(args.${(0, import_nodes16.camelCase)(seed.value.name)})`;
1281
+ if (nodes.isNode(seed.value, "argumentValueNode")) {
1282
+ return fragment`${seed.name}: ${expectSome}(args.${nodes.camelCase(seed.value.name)})`;
1373
1283
  }
1374
- return (0, import_visitors_core13.pipe)(
1375
- (0, import_visitors_core13.visit)(seed.value, typeManifestVisitor).value,
1376
- (f) => (0, import_renderers_core6.mapFragmentContent)(f, (c) => `${seed.name}: ${c}`)
1284
+ return visitorsCore.pipe(
1285
+ visitorsCore.visit(seed.value, typeManifestVisitor).value,
1286
+ (f) => renderersCore.mapFragmentContent(f, (c) => `${seed.name}: ${c}`)
1377
1287
  );
1378
1288
  });
1379
- const pdaSeedsFragment = (0, import_visitors_core13.pipe)(
1289
+ const pdaSeedsFragment = visitorsCore.pipe(
1380
1290
  mergeFragments(pdaSeeds, (renders) => renders.join(", ")),
1381
- (f) => (0, import_renderers_core6.mapFragmentContent)(f, (c) => `{ ${c} }`)
1291
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${c} }`)
1382
1292
  );
1383
1293
  if (pdaSeeds.length > 0) {
1384
1294
  pdaArgs.push(pdaSeedsFragment);
@@ -1404,14 +1314,14 @@ function getInstructionInputDefaultFragment(scope) {
1404
1314
  return fragment``;
1405
1315
  case "accountBumpValueNode":
1406
1316
  return defaultFragment(
1407
- fragment`${expectProgramDerivedAddress}(accounts.${(0, import_nodes16.camelCase)(defaultValue.name)}.value)[1]`
1317
+ fragment`${expectProgramDerivedAddress}(accounts.${nodes.camelCase(defaultValue.name)}.value)[1]`
1408
1318
  );
1409
1319
  case "argumentValueNode":
1410
- return defaultFragment(fragment`${expectSome}(args.${(0, import_nodes16.camelCase)(defaultValue.name)})`);
1320
+ return defaultFragment(fragment`${expectSome}(args.${nodes.camelCase(defaultValue.name)})`);
1411
1321
  case "resolverValueNode":
1412
1322
  const resolverFunction = use(nameApi.resolverFunction(defaultValue.name), getImportFrom(defaultValue));
1413
1323
  const resolverAwait = useAsync && asyncResolvers.includes(defaultValue.name) ? "await " : "";
1414
- return (0, import_visitors_core13.pipe)(
1324
+ return visitorsCore.pipe(
1415
1325
  defaultFragment(fragment`${resolverAwait}${resolverFunction}(resolverScope)`),
1416
1326
  (f) => addFragmentFeatures(f, ["instruction:resolverScopeVariable"])
1417
1327
  );
@@ -1436,21 +1346,21 @@ function getInstructionInputDefaultFragment(scope) {
1436
1346
  }
1437
1347
  const negatedCondition = !ifTrueRenderer;
1438
1348
  let condition = "true";
1439
- if ((0, import_nodes16.isNode)(defaultValue.condition, "resolverValueNode")) {
1349
+ if (nodes.isNode(defaultValue.condition, "resolverValueNode")) {
1440
1350
  const conditionalResolverFunction = nameApi.resolverFunction(defaultValue.condition.name);
1441
- const module2 = getImportFrom(defaultValue.condition);
1442
- conditionalFragment = (0, import_visitors_core13.pipe)(
1351
+ const module = getImportFrom(defaultValue.condition);
1352
+ conditionalFragment = visitorsCore.pipe(
1443
1353
  conditionalFragment,
1444
- (f) => addFragmentImports(f, module2, [conditionalResolverFunction]),
1354
+ (f) => addFragmentImports(f, module, [conditionalResolverFunction]),
1445
1355
  (f) => addFragmentFeatures(f, ["instruction:resolverScopeVariable"])
1446
1356
  );
1447
1357
  const conditionalResolverAwait = useAsync && asyncResolvers.includes(defaultValue.condition.name) ? "await " : "";
1448
1358
  condition = `${conditionalResolverAwait}${conditionalResolverFunction}(resolverScope)`;
1449
1359
  condition = negatedCondition ? `!${condition}` : condition;
1450
1360
  } else {
1451
- const comparedInputName = (0, import_nodes16.isNode)(defaultValue.condition, "accountValueNode") ? `accounts.${(0, import_nodes16.camelCase)(defaultValue.condition.name)}.value` : `args.${(0, import_nodes16.camelCase)(defaultValue.condition.name)}`;
1361
+ const comparedInputName = nodes.isNode(defaultValue.condition, "accountValueNode") ? `accounts.${nodes.camelCase(defaultValue.condition.name)}.value` : `args.${nodes.camelCase(defaultValue.condition.name)}`;
1452
1362
  if (defaultValue.value) {
1453
- const comparedValue = (0, import_visitors_core13.visit)(defaultValue.value, typeManifestVisitor).value;
1363
+ const comparedValue = visitorsCore.visit(defaultValue.value, typeManifestVisitor).value;
1454
1364
  conditionalFragment = mergeFragments([conditionalFragment, comparedValue], (c) => c[0]);
1455
1365
  const operator = negatedCondition ? "!==" : "===";
1456
1366
  condition = `${comparedInputName} ${operator} ${comparedValue.content}`;
@@ -1459,7 +1369,7 @@ function getInstructionInputDefaultFragment(scope) {
1459
1369
  }
1460
1370
  }
1461
1371
  if (ifTrueRenderer && ifFalseRenderer) {
1462
- return (0, import_renderers_core6.setFragmentContent)(
1372
+ return renderersCore.setFragmentContent(
1463
1373
  conditionalFragment,
1464
1374
  `if (${condition}) {
1465
1375
  ${ifTrueRenderer.content}
@@ -1468,14 +1378,14 @@ ${ifFalseRenderer.content}
1468
1378
  }`
1469
1379
  );
1470
1380
  }
1471
- return (0, import_renderers_core6.setFragmentContent)(
1381
+ return renderersCore.setFragmentContent(
1472
1382
  conditionalFragment,
1473
1383
  `if (${condition}) {
1474
1384
  ${ifTrueRenderer ? ifTrueRenderer.content : ifFalseRenderer?.content}
1475
1385
  }`
1476
1386
  );
1477
1387
  default:
1478
- const valueManifest = (0, import_visitors_core13.visit)(defaultValue, typeManifestVisitor).value;
1388
+ const valueManifest = visitorsCore.visit(defaultValue, typeManifestVisitor).value;
1479
1389
  return defaultFragment(valueManifest);
1480
1390
  }
1481
1391
  }
@@ -1490,19 +1400,19 @@ function renderNestedInstructionDefault(scope) {
1490
1400
 
1491
1401
  // src/fragments/instructionInputResolved.ts
1492
1402
  function getInstructionInputResolvedFragment(scope) {
1493
- const instructionNode = (0, import_visitors_core14.getLastNodeFromPath)(scope.instructionPath);
1403
+ const instructionNode = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1494
1404
  const resolvedInputFragments = scope.resolvedInputs.flatMap((input) => {
1495
1405
  const inputFragment = getInstructionInputDefaultFragment({
1496
1406
  ...scope,
1497
1407
  input,
1498
- optionalAccountStrategy: (0, import_nodes17.parseOptionalAccountStrategy)(instructionNode.optionalAccountStrategy)
1408
+ optionalAccountStrategy: nodes.parseOptionalAccountStrategy(instructionNode.optionalAccountStrategy)
1499
1409
  });
1500
1410
  if (!inputFragment.content) return [];
1501
- const camelName = (0, import_nodes17.camelCase)(input.name);
1411
+ const camelName = nodes.camelCase(input.name);
1502
1412
  return [
1503
- (0, import_renderers_core7.mapFragmentContent)(
1413
+ renderersCore.mapFragmentContent(
1504
1414
  inputFragment,
1505
- (c) => (0, import_nodes17.isNode)(input, "instructionArgumentNode") ? `if (!args.${camelName}) {
1415
+ (c) => nodes.isNode(input, "instructionArgumentNode") ? `if (!args.${camelName}) {
1506
1416
  ${c}
1507
1417
  }` : `if (!accounts.${camelName}.value) {
1508
1418
  ${c}
@@ -1515,19 +1425,14 @@ ${c}
1515
1425
  }
1516
1426
  return mergeFragments([fragment`// Resolve default values.`, ...resolvedInputFragments], (c) => c.join("\n"));
1517
1427
  }
1518
-
1519
- // src/fragments/instructionInputType.ts
1520
- var import_nodes18 = require("@codama/nodes");
1521
- var import_renderers_core8 = require("@codama/renderers-core");
1522
- var import_visitors_core15 = require("@codama/visitors-core");
1523
1428
  function getInstructionInputTypeFragment(scope) {
1524
1429
  const { instructionPath, useAsync, nameApi } = scope;
1525
- const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(instructionPath);
1430
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1526
1431
  const instructionInputType = useAsync ? nameApi.instructionAsyncInputType(instructionNode.name) : nameApi.instructionSyncInputType(instructionNode.name);
1527
1432
  const [dataArgumentsFragment, customDataArgumentsFragment] = getDataArgumentsFragments(scope);
1528
1433
  let accountTypeParams = "";
1529
1434
  if (instructionNode.accounts.length > 0) {
1530
- accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0, import_nodes18.pascalCase)(account.name)} extends string = string`).join(", ");
1435
+ accountTypeParams = instructionNode.accounts.map((account) => `TAccount${nodes.pascalCase(account.name)} extends string = string`).join(", ");
1531
1436
  accountTypeParams = `<${accountTypeParams}>`;
1532
1437
  }
1533
1438
  const typeBodyFragment = mergeFragments(
@@ -1545,20 +1450,20 @@ function getInstructionInputTypeFragment(scope) {
1545
1450
  }
1546
1451
  function getAccountsFragment(scope) {
1547
1452
  const { instructionPath, resolvedInputs, useAsync, asyncResolvers } = scope;
1548
- const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(instructionPath);
1453
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1549
1454
  const fragments = instructionNode.accounts.map((account) => {
1550
1455
  const resolvedAccount = resolvedInputs.find(
1551
1456
  (input) => input.kind === "instructionAccountNode" && input.name === account.name
1552
1457
  );
1553
- const hasDefaultValue = !!resolvedAccount.defaultValue && !(0, import_nodes18.isNode)(resolvedAccount.defaultValue, ["identityValueNode", "payerValueNode"]) && (useAsync || !isAsyncDefaultValue(resolvedAccount.defaultValue, asyncResolvers));
1458
+ const hasDefaultValue = !!resolvedAccount.defaultValue && !nodes.isNode(resolvedAccount.defaultValue, ["identityValueNode", "payerValueNode"]) && (useAsync || !isAsyncDefaultValue(resolvedAccount.defaultValue, asyncResolvers));
1554
1459
  const docs = getDocblockFragment(account.docs ?? [], true);
1555
1460
  const optionalSign = hasDefaultValue || resolvedAccount.isOptional ? "?" : "";
1556
- return fragment`${docs}${(0, import_nodes18.camelCase)(account.name)}${optionalSign}: ${getAccountTypeFragment2(resolvedAccount)};`;
1461
+ return fragment`${docs}${nodes.camelCase(account.name)}${optionalSign}: ${getAccountTypeFragment2(resolvedAccount)};`;
1557
1462
  });
1558
1463
  return mergeFragments(fragments, (c) => c.join("\n"));
1559
1464
  }
1560
1465
  function getAccountTypeFragment2(account) {
1561
- const typeParam = `TAccount${(0, import_nodes18.pascalCase)(account.name)}`;
1466
+ const typeParam = `TAccount${nodes.pascalCase(account.name)}`;
1562
1467
  const address = use("type Address", "solanaAddresses");
1563
1468
  const signer = use("type TransactionSigner", "solanaSigners");
1564
1469
  const pda = use("type ProgramDerivedAddress", "solanaAddresses");
@@ -1570,15 +1475,15 @@ function getAccountTypeFragment2(account) {
1570
1475
  }
1571
1476
  function getDataArgumentsFragments(scope) {
1572
1477
  const { instructionPath, nameApi } = scope;
1573
- const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(instructionPath);
1478
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1574
1479
  const customData = scope.customInstructionData.get(instructionNode.name);
1575
1480
  if (customData) {
1576
1481
  return [
1577
1482
  void 0,
1578
- (0, import_visitors_core15.pipe)(
1483
+ visitorsCore.pipe(
1579
1484
  fragment`${nameApi.dataArgsType(customData.importAs)}`,
1580
1485
  (f) => mergeFragmentImports(f, [scope.dataArgsManifest.looseType.imports]),
1581
- (f) => (0, import_renderers_core8.mapFragmentContent)(f, (c) => `${c} & `)
1486
+ (f) => renderersCore.mapFragmentContent(f, (c) => `${c} & `)
1582
1487
  )
1583
1488
  ];
1584
1489
  }
@@ -1592,7 +1497,7 @@ function getDataArgumentsFragments(scope) {
1592
1497
  }
1593
1498
  function getExtraArgumentsFragment(scope) {
1594
1499
  const { instructionPath, nameApi } = scope;
1595
- const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(instructionPath);
1500
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1596
1501
  const instructionExtraName = nameApi.instructionExtraType(instructionNode.name);
1597
1502
  const extraArgsType = nameApi.dataArgsType(instructionExtraName);
1598
1503
  const fragments = (instructionNode.extraArguments ?? []).flatMap((arg) => {
@@ -1604,18 +1509,18 @@ function getExtraArgumentsFragment(scope) {
1604
1509
  }
1605
1510
  function getArgumentFragment(arg, argsType, resolvedInputs, renamedArgs) {
1606
1511
  const resolvedArg = resolvedInputs.find(
1607
- (input) => (0, import_nodes18.isNode)(input, "instructionArgumentNode") && input.name === arg.name
1512
+ (input) => nodes.isNode(input, "instructionArgumentNode") && input.name === arg.name
1608
1513
  );
1609
1514
  if (arg.defaultValue && arg.defaultValueStrategy === "omitted") return null;
1610
1515
  const renamedName = renamedArgs.get(arg.name) ?? arg.name;
1611
1516
  const optionalSign = arg.defaultValue || resolvedArg?.defaultValue ? "?" : "";
1612
- return fragment`${(0, import_nodes18.camelCase)(renamedName)}${optionalSign}: ${argsType}["${(0, import_nodes18.camelCase)(arg.name)}"];`;
1517
+ return fragment`${nodes.camelCase(renamedName)}${optionalSign}: ${argsType}["${nodes.camelCase(arg.name)}"];`;
1613
1518
  }
1614
1519
  function getRemainingAccountsFragment(instructionNode) {
1615
1520
  const fragments = (instructionNode.remainingAccounts ?? []).flatMap((remainingAccountsNode) => {
1616
- if ((0, import_nodes18.isNode)(remainingAccountsNode.value, "resolverValueNode")) return [];
1521
+ if (nodes.isNode(remainingAccountsNode.value, "resolverValueNode")) return [];
1617
1522
  const { name } = remainingAccountsNode.value;
1618
- const allArguments = (0, import_nodes18.getAllInstructionArguments)(instructionNode);
1523
+ const allArguments = nodes.getAllInstructionArguments(instructionNode);
1619
1524
  const argumentExists = allArguments.some((arg) => arg.name === name);
1620
1525
  if (argumentExists) return [];
1621
1526
  const isSigner = remainingAccountsNode.isSigner ?? false;
@@ -1626,20 +1531,16 @@ function getRemainingAccountsFragment(instructionNode) {
1626
1531
  if (isSigner === "either") return fragment`${signerFragment} | ${addressFragment}`;
1627
1532
  return isSigner ? signerFragment : addressFragment;
1628
1533
  })();
1629
- return fragment`${(0, import_nodes18.camelCase)(name)}${optionalSign}: Array<${typeFragment}>;`;
1534
+ return fragment`${nodes.camelCase(name)}${optionalSign}: Array<${typeFragment}>;`;
1630
1535
  });
1631
1536
  if (fragments.length === 0) return;
1632
1537
  return mergeFragments(fragments, (c) => c.join("\n"));
1633
1538
  }
1634
-
1635
- // src/fragments/instructionRemainingAccounts.ts
1636
- var import_nodes19 = require("@codama/nodes");
1637
- var import_visitors_core16 = require("@codama/visitors-core");
1638
1539
  function getInstructionRemainingAccountsFragment(scope) {
1639
- const { remainingAccounts } = (0, import_visitors_core16.getLastNodeFromPath)(scope.instructionPath);
1540
+ const { remainingAccounts } = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1640
1541
  const fragments = (remainingAccounts ?? []).flatMap((a) => getRemainingAccountsFragment2(a, scope));
1641
1542
  if (fragments.length === 0) return;
1642
- return (0, import_visitors_core16.pipe)(
1543
+ return visitorsCore.pipe(
1643
1544
  mergeFragments(
1644
1545
  fragments,
1645
1546
  (c) => `// Remaining accounts.
@@ -1650,10 +1551,10 @@ const remainingAccounts: AccountMeta[] = ${c.length === 1 ? c[0] : `[...${c.join
1650
1551
  }
1651
1552
  function getRemainingAccountsFragment2(remainingAccounts, scope) {
1652
1553
  const remainingAccountsFragment = (() => {
1653
- if ((0, import_nodes19.isNode)(remainingAccounts.value, "argumentValueNode")) {
1554
+ if (nodes.isNode(remainingAccounts.value, "argumentValueNode")) {
1654
1555
  return getArgumentValueNodeFragment2(remainingAccounts, scope);
1655
1556
  }
1656
- if ((0, import_nodes19.isNode)(remainingAccounts.value, "resolverValueNode")) {
1557
+ if (nodes.isNode(remainingAccounts.value, "resolverValueNode")) {
1657
1558
  return getResolverValueNodeFragment2(remainingAccounts, scope);
1658
1559
  }
1659
1560
  return null;
@@ -1662,9 +1563,9 @@ function getRemainingAccountsFragment2(remainingAccounts, scope) {
1662
1563
  return [remainingAccountsFragment];
1663
1564
  }
1664
1565
  function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1665
- const instructionNode = (0, import_visitors_core16.getLastNodeFromPath)(scope.instructionPath);
1666
- (0, import_nodes19.assertIsNode)(remainingAccounts.value, "argumentValueNode");
1667
- const argumentName = (0, import_nodes19.camelCase)(remainingAccounts.value.name);
1566
+ const instructionNode = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1567
+ nodes.assertIsNode(remainingAccounts.value, "argumentValueNode");
1568
+ const argumentName = nodes.camelCase(remainingAccounts.value.name);
1668
1569
  const isOptional = remainingAccounts.isOptional ?? false;
1669
1570
  const isSigner = remainingAccounts.isSigner ?? false;
1670
1571
  const isWritable = remainingAccounts.isWritable ?? false;
@@ -1673,7 +1574,7 @@ function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1673
1574
  const signerRole = isWritable ? fragment`${accountRole}.WRITABLE_SIGNER` : fragment`${accountRole}.READONLY_SIGNER`;
1674
1575
  const role = isSigner === true ? signerRole : nonSignerRole;
1675
1576
  const argumentArray = isOptional ? `(args.${argumentName} ?? [])` : `args.${argumentName}`;
1676
- const allArguments = (0, import_nodes19.getAllInstructionArguments)(instructionNode);
1577
+ const allArguments = nodes.getAllInstructionArguments(instructionNode);
1677
1578
  const argumentExists = allArguments.some((arg) => arg.name === remainingAccounts.value.name);
1678
1579
  if (argumentExists || isSigner === false) {
1679
1580
  return fragment`${argumentArray}.map((address) => ({ address, role: ${role} }))`;
@@ -1684,7 +1585,7 @@ function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1684
1585
  return fragment`${argumentArray}.map((signer) => ({ address: signer.address, role: ${signerRole}, signer }))`;
1685
1586
  }
1686
1587
  function getResolverValueNodeFragment2(remainingAccounts, scope) {
1687
- (0, import_nodes19.assertIsNode)(remainingAccounts.value, "resolverValueNode");
1588
+ nodes.assertIsNode(remainingAccounts.value, "resolverValueNode");
1688
1589
  const isAsync = scope.asyncResolvers.includes(remainingAccounts.value.name);
1689
1590
  if (!scope.useAsync && isAsync) return null;
1690
1591
  const awaitKeyword = scope.useAsync && isAsync ? "await " : "";
@@ -1692,7 +1593,7 @@ function getResolverValueNodeFragment2(remainingAccounts, scope) {
1692
1593
  scope.nameApi.resolverFunction(remainingAccounts.value.name),
1693
1594
  scope.getImportFrom(remainingAccounts.value)
1694
1595
  );
1695
- return (0, import_visitors_core16.pipe)(
1596
+ return visitorsCore.pipe(
1696
1597
  fragment`${awaitKeyword}${functionName}(resolverScope)`,
1697
1598
  (f) => addFragmentFeatures(f, ["instruction:resolverScopeVariable"])
1698
1599
  );
@@ -1701,13 +1602,13 @@ function getResolverValueNodeFragment2(remainingAccounts, scope) {
1701
1602
  // src/fragments/instructionFunction.ts
1702
1603
  function getInstructionFunctionFragment(scope) {
1703
1604
  const { useAsync, instructionPath, resolvedInputs, renamedArgs, asyncResolvers, nameApi, customInstructionData } = scope;
1704
- const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
1705
- const programNode = (0, import_visitors_core17.findProgramNodeFromPath)(instructionPath);
1605
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1606
+ const programNode = visitorsCore.findProgramNodeFromPath(instructionPath);
1706
1607
  if (useAsync && !hasAsyncFunction(instructionNode, resolvedInputs, asyncResolvers)) return;
1707
1608
  const customData = customInstructionData.get(instructionNode.name);
1708
1609
  const hasAccounts = instructionNode.accounts.length > 0;
1709
1610
  const instructionDependencies = getInstructionDependencies(instructionNode, asyncResolvers, useAsync);
1710
- const argDependencies = instructionDependencies.filter((0, import_nodes20.isNodeFilter)("argumentValueNode")).map((node) => node.name);
1611
+ const argDependencies = instructionDependencies.filter(nodes.isNodeFilter("argumentValueNode")).map((node) => node.name);
1711
1612
  const hasData = !!customData || instructionNode.arguments.length > 0;
1712
1613
  const argIsNotOmitted = (arg) => !(arg.defaultValue && arg.defaultValueStrategy === "omitted");
1713
1614
  const argIsDependent = (arg) => argDependencies.includes(arg.name);
@@ -1720,7 +1621,7 @@ function getInstructionFunctionFragment(scope) {
1720
1621
  const hasExtraArgs = (instructionNode.extraArguments ?? []).filter(
1721
1622
  (field) => argIsNotOmitted(field) && (argIsDependent(field) || argHasDefaultValue(field))
1722
1623
  ).length > 0;
1723
- const hasRemainingAccountArgs = (instructionNode.remainingAccounts ?? []).filter(({ value }) => (0, import_nodes20.isNode)(value, "argumentValueNode")).length > 0;
1624
+ const hasRemainingAccountArgs = (instructionNode.remainingAccounts ?? []).filter(({ value }) => nodes.isNode(value, "argumentValueNode")).length > 0;
1724
1625
  const hasAnyArgs = hasDataArgs || hasExtraArgs || hasRemainingAccountArgs;
1725
1626
  const hasInput = hasAccounts || hasAnyArgs;
1726
1627
  const programAddressConstant = use(nameApi.programAddressConstant(programNode.name), "generatedPrograms");
@@ -1739,7 +1640,7 @@ function getInstructionFunctionFragment(scope) {
1739
1640
  const typeParams = getTypeParamsFragment(instructionNode, programAddressConstant);
1740
1641
  const returnType = getReturnTypeFragment(instructionTypeFragment, hasByteDeltas, useAsync);
1741
1642
  const inputType = getInstructionInputTypeFragment(scope);
1742
- const inputArg = (0, import_renderers_core9.mapFragmentContent)(getInputTypeCallFragment(scope), (c) => hasInput ? `input: ${c}, ` : "");
1643
+ const inputArg = renderersCore.mapFragmentContent(getInputTypeCallFragment(scope), (c) => hasInput ? `input: ${c}, ` : "");
1743
1644
  const functionBody = mergeFragments(
1744
1645
  [
1745
1646
  getProgramAddressInitializationFragment(programAddressConstant),
@@ -1771,7 +1672,7 @@ function getAccountsInitializationFragment(instructionNode) {
1771
1672
  if (instructionNode.accounts.length === 0) return;
1772
1673
  const accounts = mergeFragments(
1773
1674
  instructionNode.accounts.map((account) => {
1774
- const name = (0, import_nodes20.camelCase)(account.name);
1675
+ const name = nodes.camelCase(account.name);
1775
1676
  const isWritable = account.isWritable ? "true" : "false";
1776
1677
  return fragment`${name}: { value: input.${name} ?? null, isWritable: ${isWritable} }`;
1777
1678
  }),
@@ -1806,7 +1707,7 @@ function getReturnStatementFragment(scope) {
1806
1707
  const hasLegacyOptionalAccounts = instructionNode.optionalAccountStrategy === "omitted" && instructionNode.accounts.some((account) => account.isOptional);
1807
1708
  const getAccountMeta = hasAccounts ? fragment`const getAccountMeta = ${use("getAccountMetaFactory", "shared")}(programAddress, '${optionalAccountStrategy}');` : "";
1808
1709
  const accountItems = [
1809
- ...instructionNode.accounts.map((account) => `getAccountMeta(accounts.${(0, import_nodes20.camelCase)(account.name)})`),
1710
+ ...instructionNode.accounts.map((account) => `getAccountMeta(accounts.${nodes.camelCase(account.name)})`),
1810
1711
  ...hasRemainingAccounts ? ["...remainingAccounts"] : []
1811
1712
  ].join(", ");
1812
1713
  let accounts;
@@ -1827,14 +1728,14 @@ function getReturnStatementFragment(scope) {
1827
1728
  } else if (hasData) {
1828
1729
  data = fragment`data: ${encoderFunctionFragment}.encode({})`;
1829
1730
  }
1830
- const instructionAttributes = (0, import_visitors_core17.pipe)(
1731
+ const instructionAttributes = visitorsCore.pipe(
1831
1732
  [accounts, hasByteDeltas ? fragment`byteDelta` : void 0, data, fragment`programAddress`],
1832
1733
  (fs) => mergeFragments(fs, (cs) => cs.join(", "))
1833
1734
  );
1834
1735
  return fragment`${getAccountMeta}\nreturn Object.freeze({ ${instructionAttributes} } as ${scope.syncReturnTypeFragment});`;
1835
1736
  }
1836
1737
  function getReturnTypeFragment(instructionTypeFragment, hasByteDeltas, useAsync) {
1837
- return (0, import_visitors_core17.pipe)(
1738
+ return visitorsCore.pipe(
1838
1739
  instructionTypeFragment,
1839
1740
  (f) => hasByteDeltas ? fragment`${f} & ${use("type InstructionWithByteDelta", "shared")}` : f,
1840
1741
  (f) => useAsync ? fragment`Promise<${f}>` : f
@@ -1843,7 +1744,7 @@ function getReturnTypeFragment(instructionTypeFragment, hasByteDeltas, useAsync)
1843
1744
  function getTypeParamsFragment(instructionNode, programAddressConstant) {
1844
1745
  return mergeFragments(
1845
1746
  [
1846
- ...instructionNode.accounts.map((account) => fragment`TAccount${(0, import_nodes20.pascalCase)(account.name)} extends string`),
1747
+ ...instructionNode.accounts.map((account) => fragment`TAccount${nodes.pascalCase(account.name)} extends string`),
1847
1748
  fragment`TProgramAddress extends ${use("type Address", "solanaAddresses")} = typeof ${programAddressConstant}`
1848
1749
  ],
1849
1750
  (cs) => `<${cs.join(", ")}>`
@@ -1851,48 +1752,39 @@ function getTypeParamsFragment(instructionNode, programAddressConstant) {
1851
1752
  }
1852
1753
  function getInstructionTypeFragment(scope) {
1853
1754
  const { instructionPath, nameApi } = scope;
1854
- const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
1755
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1855
1756
  const instructionTypeName = nameApi.instructionType(instructionNode.name);
1856
1757
  const accountTypeParamsFragments = instructionNode.accounts.map((account) => {
1857
- const typeParam = fragment`TAccount${(0, import_nodes20.pascalCase)(account.name)}`;
1858
- const camelName = (0, import_nodes20.camelCase)(account.name);
1758
+ const typeParam = fragment`TAccount${nodes.pascalCase(account.name)}`;
1759
+ const camelName = nodes.camelCase(account.name);
1859
1760
  if (account.isSigner === "either") {
1860
1761
  const signerRole = use(
1861
1762
  account.isWritable ? "type WritableSignerAccount" : "type ReadonlySignerAccount",
1862
1763
  "solanaInstructions"
1863
1764
  );
1864
- return (0, import_visitors_core17.pipe)(
1765
+ return visitorsCore.pipe(
1865
1766
  fragment`typeof input["${camelName}"] extends TransactionSigner<${typeParam}> ? ${signerRole}<${typeParam}> & AccountSignerMeta<${typeParam}> : ${typeParam}`,
1866
1767
  (f) => addFragmentImports(f, "solanaSigners", ["type AccountSignerMeta", "type TransactionSigner"])
1867
1768
  );
1868
1769
  }
1869
1770
  return typeParam;
1870
1771
  });
1871
- return (0, import_visitors_core17.pipe)(
1772
+ return visitorsCore.pipe(
1872
1773
  mergeFragments([fragment`TProgramAddress`, ...accountTypeParamsFragments], (c) => c.join(", ")),
1873
- (f) => (0, import_renderers_core9.mapFragmentContent)(f, (c) => `${instructionTypeName}<${c}>`)
1774
+ (f) => renderersCore.mapFragmentContent(f, (c) => `${instructionTypeName}<${c}>`)
1874
1775
  );
1875
1776
  }
1876
1777
  function getInputTypeCallFragment(scope) {
1877
1778
  const { instructionPath, useAsync, nameApi } = scope;
1878
- const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
1779
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1879
1780
  const inputTypeName = useAsync ? nameApi.instructionAsyncInputType(instructionNode.name) : nameApi.instructionSyncInputType(instructionNode.name);
1880
1781
  if (instructionNode.accounts.length === 0) return fragment`${inputTypeName}`;
1881
- const accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0, import_nodes20.pascalCase)(account.name)}`).join(", ");
1782
+ const accountTypeParams = instructionNode.accounts.map((account) => `TAccount${nodes.pascalCase(account.name)}`).join(", ");
1882
1783
  return fragment`${inputTypeName}<${accountTypeParams}>`;
1883
1784
  }
1884
-
1885
- // src/fragments/instructionPage.ts
1886
- var import_errors3 = require("@codama/errors");
1887
- var import_nodes23 = require("@codama/nodes");
1888
- var import_visitors_core20 = require("@codama/visitors-core");
1889
-
1890
- // src/fragments/instructionParseFunction.ts
1891
- var import_nodes21 = require("@codama/nodes");
1892
- var import_visitors_core18 = require("@codama/visitors-core");
1893
1785
  function getInstructionParseFunctionFragment(scope) {
1894
- const instructionNode = (0, import_visitors_core18.getLastNodeFromPath)(scope.instructionPath);
1895
- const programNode = (0, import_visitors_core18.findProgramNodeFromPath)(scope.instructionPath);
1786
+ const instructionNode = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1787
+ const programNode = visitorsCore.findProgramNodeFromPath(scope.instructionPath);
1896
1788
  const programAddressConstant = use(scope.nameApi.programAddressConstant(programNode.name), "generatedPrograms");
1897
1789
  const childScope = { ...scope, instructionNode, programAddressConstant };
1898
1790
  return mergeFragments([getTypeFragment2(childScope), getFunctionFragment(childScope)], (cs) => cs.join("\n\n"));
@@ -1913,7 +1805,7 @@ function getTypeFragment2(scope) {
1913
1805
  const accounts = mergeFragments(
1914
1806
  scope.instructionNode.accounts.map((account, i) => {
1915
1807
  const docs = getDocblockFragment(account.docs ?? [], true);
1916
- const name = (0, import_nodes21.camelCase)(account.name);
1808
+ const name = nodes.camelCase(account.name);
1917
1809
  return fragment`${docs}${name}${account.isOptional ? "?" : ""}: TAccountMetas[${i}]${account.isOptional ? " | undefined" : ""};`;
1918
1810
  }),
1919
1811
  (cs) => hasAccounts ? `
@@ -1947,7 +1839,7 @@ function getFunctionFragment(scope) {
1947
1839
  [
1948
1840
  fragment`${use("type Instruction", "solanaInstructions")}<TProgram>`,
1949
1841
  hasAccounts ? fragment`${use("type InstructionWithAccounts", "solanaInstructions")}<TAccountMetas>` : void 0,
1950
- hasData ? (0, import_visitors_core18.pipe)(
1842
+ hasData ? visitorsCore.pipe(
1951
1843
  fragment`InstructionWithData<ReadonlyUint8Array>`,
1952
1844
  (f) => addFragmentImports(f, "solanaInstructions", ["type InstructionWithData"]),
1953
1845
  (f) => addFragmentImports(f, "solanaCodecsCore", ["type ReadonlyUint8Array"])
@@ -1985,7 +1877,7 @@ const getNextOptionalAccount = () => {
1985
1877
  }
1986
1878
  const accounts = mergeFragments(
1987
1879
  scope.instructionNode.accounts.map(
1988
- (account) => account.isOptional ? fragment`${(0, import_nodes21.camelCase)(account.name)}: getNextOptionalAccount()` : fragment`${(0, import_nodes21.camelCase)(account.name)}: getNextAccount()`
1880
+ (account) => account.isOptional ? fragment`${nodes.camelCase(account.name)}: getNextOptionalAccount()` : fragment`${nodes.camelCase(account.name)}: getNextAccount()`
1989
1881
  ),
1990
1882
  (cs) => hasAccounts ? `, accounts: { ${cs.join(", ")} }` : ""
1991
1883
  );
@@ -1995,15 +1887,10 @@ const getNextOptionalAccount = () => {
1995
1887
  return { programAddress: instruction.programAddress${accounts}${data} };
1996
1888
  }`;
1997
1889
  }
1998
-
1999
- // src/fragments/instructionType.ts
2000
- var import_nodes22 = require("@codama/nodes");
2001
- var import_renderers_core10 = require("@codama/renderers-core");
2002
- var import_visitors_core19 = require("@codama/visitors-core");
2003
1890
  function getInstructionTypeFragment2(scope) {
2004
1891
  const { instructionPath, nameApi, customInstructionData } = scope;
2005
- const instructionNode = (0, import_visitors_core19.getLastNodeFromPath)(instructionPath);
2006
- const programNode = (0, import_visitors_core19.findProgramNodeFromPath)(instructionPath);
1892
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1893
+ const programNode = visitorsCore.findProgramNodeFromPath(instructionPath);
2007
1894
  const hasAccounts = instructionNode.accounts.length > 0;
2008
1895
  const customData = customInstructionData.get(instructionNode.name);
2009
1896
  const hasData = !!customData || instructionNode.arguments.length > 0;
@@ -2013,7 +1900,6 @@ function getInstructionTypeFragment2(scope) {
2013
1900
  instructionNode.accounts.map(
2014
1901
  (account) => getInstructionAccountTypeParamFragment({
2015
1902
  ...scope,
2016
- allowAccountMeta: true,
2017
1903
  instructionAccountPath: [...instructionPath, account]
2018
1904
  })
2019
1905
  ),
@@ -2023,8 +1909,8 @@ function getInstructionTypeFragment2(scope) {
2023
1909
  const usesLegacyOptionalAccounts = instructionNode.optionalAccountStrategy === "omitted";
2024
1910
  const accountMetasFragment = mergeFragments(
2025
1911
  instructionNode.accounts.map(
2026
- (account) => (0, import_renderers_core10.mapFragmentContent)(getInstructionAccountMetaFragment(account), (c) => {
2027
- const typeParam = `TAccount${(0, import_nodes22.pascalCase)(account.name)}`;
1912
+ (account) => renderersCore.mapFragmentContent(getInstructionAccountMetaFragment(account), (c) => {
1913
+ const typeParam = `TAccount${nodes.pascalCase(account.name)}`;
2028
1914
  const isLegacyOptional = account.isOptional && usesLegacyOptionalAccounts;
2029
1915
  const type = `${typeParam} extends string ? ${c} : ${typeParam}`;
2030
1916
  if (!isLegacyOptional) return type;
@@ -2041,17 +1927,17 @@ ${use("type Instruction", "solanaInstructions")}<TProgram>${data}${accounts};`;
2041
1927
 
2042
1928
  // src/fragments/instructionPage.ts
2043
1929
  function getInstructionPageFragment(scope) {
2044
- const node = (0, import_visitors_core20.getLastNodeFromPath)(scope.instructionPath);
2045
- if (!(0, import_visitors_core20.findProgramNodeFromPath)(scope.instructionPath)) {
1930
+ const node = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1931
+ if (!visitorsCore.findProgramNodeFromPath(scope.instructionPath)) {
2046
1932
  throw new Error("Instruction must be visited inside a program.");
2047
1933
  }
2048
1934
  const childScope = {
2049
1935
  ...scope,
2050
- dataArgsManifest: (0, import_visitors_core20.visit)(node, scope.typeManifestVisitor),
2051
- extraArgsManifest: (0, import_visitors_core20.visit)(
2052
- (0, import_nodes23.definedTypeNode)({
1936
+ dataArgsManifest: visitorsCore.visit(node, scope.typeManifestVisitor),
1937
+ extraArgsManifest: visitorsCore.visit(
1938
+ nodes.definedTypeNode({
2053
1939
  name: scope.nameApi.instructionExtraType(node.name),
2054
- type: (0, import_nodes23.structTypeNodeFromInstructionArgumentNodes)(node.extraArguments ?? [])
1940
+ type: nodes.structTypeNodeFromInstructionArgumentNodes(node.extraArguments ?? [])
2055
1941
  }),
2056
1942
  scope.typeManifestVisitor
2057
1943
  ),
@@ -2087,17 +1973,13 @@ function getRenamedArgsMap(instruction) {
2087
1973
  const allNames = [...instruction.accounts.map((account) => account.name), ...argNames];
2088
1974
  const duplicates = allNames.filter((e, i, a) => a.indexOf(e) !== i);
2089
1975
  if (duplicates.length === 0) return /* @__PURE__ */ new Map();
2090
- (0, import_errors3.logWarn)(
1976
+ errors.logWarn(
2091
1977
  `[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.`
2092
1978
  );
2093
- return new Map(duplicates.map((name) => [(0, import_nodes23.camelCase)(name), (0, import_nodes23.camelCase)(`${name}Arg`)]));
1979
+ return new Map(duplicates.map((name) => [nodes.camelCase(name), nodes.camelCase(`${name}Arg`)]));
2094
1980
  }
2095
-
2096
- // src/fragments/pdaFunction.ts
2097
- var import_nodes24 = require("@codama/nodes");
2098
- var import_visitors_core21 = require("@codama/visitors-core");
2099
1981
  function getPdaFunctionFragment(scope) {
2100
- const pdaNode = (0, import_visitors_core21.getLastNodeFromPath)(scope.pdaPath);
1982
+ const pdaNode = visitorsCore.getLastNodeFromPath(scope.pdaPath);
2101
1983
  const seeds = parsePdaSeedNodes(pdaNode.seeds, scope);
2102
1984
  return mergeFragments(
2103
1985
  [getSeedInputTypeFragment(seeds, scope), getFunctionFragment2(seeds, scope)],
@@ -2105,9 +1987,9 @@ function getPdaFunctionFragment(scope) {
2105
1987
  );
2106
1988
  }
2107
1989
  function getSeedInputTypeFragment(seeds, scope) {
2108
- const variableSeeds = seeds.filter((0, import_nodes24.isNodeFilter)("variablePdaSeedNode"));
1990
+ const variableSeeds = seeds.filter(nodes.isNodeFilter("variablePdaSeedNode"));
2109
1991
  if (variableSeeds.length === 0) return;
2110
- const pdaNode = (0, import_visitors_core21.getLastNodeFromPath)(scope.pdaPath);
1992
+ const pdaNode = visitorsCore.getLastNodeFromPath(scope.pdaPath);
2111
1993
  const seedTypeName = scope.nameApi.pdaSeedsType(pdaNode.name);
2112
1994
  const seedAttributes = mergeFragments(
2113
1995
  variableSeeds.map((seed) => seed.inputAttribute),
@@ -2116,15 +1998,15 @@ function getSeedInputTypeFragment(seeds, scope) {
2116
1998
  return fragment`export type ${seedTypeName} = {\n${seedAttributes}\n};`;
2117
1999
  }
2118
2000
  function getFunctionFragment2(seeds, scope) {
2119
- const pdaNode = (0, import_visitors_core21.getLastNodeFromPath)(scope.pdaPath);
2120
- const programNode = (0, import_visitors_core21.findProgramNodeFromPath)(scope.pdaPath);
2001
+ const pdaNode = visitorsCore.getLastNodeFromPath(scope.pdaPath);
2002
+ const programNode = visitorsCore.findProgramNodeFromPath(scope.pdaPath);
2121
2003
  const addressType = use("type Address", "solanaAddresses");
2122
2004
  const pdaType = use("type ProgramDerivedAddress", "solanaAddresses");
2123
2005
  const getPdaFunction = use("getProgramDerivedAddress", "solanaAddresses");
2124
2006
  const seedTypeName = scope.nameApi.pdaSeedsType(pdaNode.name);
2125
2007
  const findPdaFunction = scope.nameApi.pdaFindFunction(pdaNode.name);
2126
2008
  const docs = getDocblockFragment(pdaNode.docs ?? [], true);
2127
- const hasVariableSeeds = seeds.filter((0, import_nodes24.isNodeFilter)("variablePdaSeedNode")).length > 0;
2009
+ const hasVariableSeeds = seeds.filter(nodes.isNodeFilter("variablePdaSeedNode")).length > 0;
2128
2010
  const seedArgument = hasVariableSeeds ? `seeds: ${seedTypeName}, ` : "";
2129
2011
  const programAddress = pdaNode.programId ?? programNode.publicKey;
2130
2012
  const encodedSeeds = mergeFragments(
@@ -2138,39 +2020,31 @@ function getFunctionFragment2(seeds, scope) {
2138
2020
  }
2139
2021
  function parsePdaSeedNodes(seeds, scope) {
2140
2022
  return seeds.map((seed) => {
2141
- if ((0, import_nodes24.isNode)(seed, "variablePdaSeedNode")) {
2142
- const name = (0, import_nodes24.camelCase)(seed.name);
2023
+ if (nodes.isNode(seed, "variablePdaSeedNode")) {
2024
+ const name = nodes.camelCase(seed.name);
2143
2025
  const docs = getDocblockFragment(seed.docs ?? [], true);
2144
- const { encoder: encoder2, looseType } = (0, import_visitors_core21.visit)(seed.type, scope.typeManifestVisitor);
2026
+ const { encoder: encoder2, looseType } = visitorsCore.visit(seed.type, scope.typeManifestVisitor);
2145
2027
  return {
2146
2028
  ...seed,
2147
2029
  encodedValue: fragment`${encoder2}.encode(seeds.${name})`,
2148
2030
  inputAttribute: fragment`${docs}${name}: ${looseType};`
2149
2031
  };
2150
2032
  }
2151
- if ((0, import_nodes24.isNode)(seed.value, "programIdValueNode")) {
2033
+ if (nodes.isNode(seed.value, "programIdValueNode")) {
2152
2034
  const addressEncoder = use("getAddressEncoder", "solanaAddresses");
2153
2035
  return { ...seed, encodedValue: fragment`${addressEncoder}().encode(programAddress)` };
2154
2036
  }
2155
- const { encoder } = (0, import_visitors_core21.visit)(seed.type, scope.typeManifestVisitor);
2156
- const { value } = (0, import_visitors_core21.visit)(seed.value, scope.typeManifestVisitor);
2037
+ const { encoder } = visitorsCore.visit(seed.type, scope.typeManifestVisitor);
2038
+ const { value } = visitorsCore.visit(seed.value, scope.typeManifestVisitor);
2157
2039
  return { ...seed, encodedValue: fragment`${encoder}.encode(${value})` };
2158
2040
  });
2159
2041
  }
2160
-
2161
- // src/fragments/pdaPage.ts
2162
- var import_visitors_core22 = require("@codama/visitors-core");
2163
2042
  function getPdaPageFragment(scope) {
2164
- if (!(0, import_visitors_core22.findProgramNodeFromPath)(scope.pdaPath)) {
2043
+ if (!visitorsCore.findProgramNodeFromPath(scope.pdaPath)) {
2165
2044
  throw new Error("PDA must be visited inside a program.");
2166
2045
  }
2167
2046
  return getPdaFunctionFragment(scope);
2168
2047
  }
2169
-
2170
- // src/fragments/programAccounts.ts
2171
- var import_nodes25 = require("@codama/nodes");
2172
- var import_renderers_core11 = require("@codama/renderers-core");
2173
- var import_visitors_core23 = require("@codama/visitors-core");
2174
2048
  function getProgramAccountsFragment(scope) {
2175
2049
  if (scope.programNode.accounts.length === 0) return;
2176
2050
  return mergeFragments(
@@ -2195,7 +2069,7 @@ function getProgramAccountsIdentifierFunctionFragment(scope) {
2195
2069
  if (!hasAccountDiscriminators) return;
2196
2070
  const programAccountsEnum = nameApi.programAccountsEnum(programNode.name);
2197
2071
  const programAccountsIdentifierFunction = nameApi.programAccountsIdentifierFunction(programNode.name);
2198
- return (0, import_visitors_core23.pipe)(
2072
+ return visitorsCore.pipe(
2199
2073
  mergeFragments(
2200
2074
  accountsWithDiscriminators.map((account) => {
2201
2075
  const variant = nameApi.programAccountsEnumVariant(account.name);
@@ -2204,12 +2078,12 @@ function getProgramAccountsIdentifierFunctionFragment(scope) {
2204
2078
  dataName: "data",
2205
2079
  discriminators: account.discriminators ?? [],
2206
2080
  ifTrue: `return ${programAccountsEnum}.${variant};`,
2207
- struct: (0, import_nodes25.resolveNestedTypeNode)(account.data)
2081
+ struct: nodes.resolveNestedTypeNode(account.data)
2208
2082
  });
2209
2083
  }),
2210
2084
  (c) => c.join("\n")
2211
2085
  ),
2212
- (f) => (0, import_renderers_core11.mapFragmentContent)(
2086
+ (f) => renderersCore.mapFragmentContent(
2213
2087
  f,
2214
2088
  (discriminators) => `export function ${programAccountsIdentifierFunction}(account: { data: ReadonlyUint8Array } | ReadonlyUint8Array): ${programAccountsEnum} {
2215
2089
  const data = 'data' in account ? account.data : account;
@@ -2220,25 +2094,17 @@ throw new Error("The provided account could not be identified as a ${programNode
2220
2094
  (f) => addFragmentImports(f, "solanaCodecsCore", ["type ReadonlyUint8Array"])
2221
2095
  );
2222
2096
  }
2223
-
2224
- // src/fragments/programConstant.ts
2225
- var import_visitors_core24 = require("@codama/visitors-core");
2226
2097
  function getProgramConstantFragment(scope) {
2227
2098
  const { programNode, nameApi } = scope;
2228
2099
  const programAddressConstant = nameApi.programAddressConstant(programNode.name);
2229
- return (0, import_visitors_core24.pipe)(
2100
+ return visitorsCore.pipe(
2230
2101
  fragment`export const ${programAddressConstant} = '${programNode.publicKey}' as Address<'${programNode.publicKey}'>;`,
2231
2102
  (f) => addFragmentImports(f, "solanaAddresses", ["type Address"])
2232
2103
  );
2233
2104
  }
2234
-
2235
- // src/fragments/programInstructions.ts
2236
- var import_nodes26 = require("@codama/nodes");
2237
- var import_renderers_core12 = require("@codama/renderers-core");
2238
- var import_visitors_core25 = require("@codama/visitors-core");
2239
2105
  function getProgramInstructionsFragment(scope) {
2240
2106
  if (scope.programNode.instructions.length === 0) return;
2241
- const allInstructions = (0, import_nodes26.getAllInstructionsWithSubs)(scope.programNode, {
2107
+ const allInstructions = nodes.getAllInstructionsWithSubs(scope.programNode, {
2242
2108
  leavesOnly: !scope.renderParentInstructions,
2243
2109
  subInstructionsFirst: true
2244
2110
  });
@@ -2277,14 +2143,14 @@ function getProgramInstructionsIdentifierFunctionFragment(scope) {
2277
2143
  dataName: "data",
2278
2144
  discriminators: instruction.discriminators ?? [],
2279
2145
  ifTrue: `return ${programInstructionsEnum}.${variant};`,
2280
- struct: (0, import_nodes26.structTypeNodeFromInstructionArgumentNodes)(instruction.arguments)
2146
+ struct: nodes.structTypeNodeFromInstructionArgumentNodes(instruction.arguments)
2281
2147
  });
2282
2148
  }),
2283
2149
  (c) => c.join("\n")
2284
2150
  );
2285
- return (0, import_visitors_core25.pipe)(
2151
+ return visitorsCore.pipe(
2286
2152
  discriminatorsFragment,
2287
- (f) => (0, import_renderers_core12.mapFragmentContent)(
2153
+ (f) => renderersCore.mapFragmentContent(
2288
2154
  f,
2289
2155
  (discriminators) => `export function ${programInstructionsIdentifierFunction}(instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array): ${programInstructionsEnum} {
2290
2156
  const data = 'data' in instruction ? instruction.data : instruction;
@@ -2344,9 +2210,6 @@ function getRootIndexPageFragment(scope) {
2344
2210
  (cs) => cs.join("\n")
2345
2211
  );
2346
2212
  }
2347
-
2348
- // src/fragments/sharedPage.ts
2349
- var import_visitors_core26 = require("@codama/visitors-core");
2350
2213
  function getSharedPageFragment() {
2351
2214
  const sharedPage = fragment`/**
2352
2215
  * Asserts that the given value is not null or undefined.
@@ -2447,7 +2310,7 @@ export function getAccountMetaFactory(
2447
2310
  export function isTransactionSigner<TAddress extends string = string>(value: Address<TAddress> | ProgramDerivedAddress<TAddress> | TransactionSigner<TAddress>): value is TransactionSigner<TAddress> {
2448
2311
  return !!value && typeof value === 'object' && 'address' in value && kitIsTransactionSigner(value);
2449
2312
  }`;
2450
- return (0, import_visitors_core26.pipe)(
2313
+ return visitorsCore.pipe(
2451
2314
  sharedPage,
2452
2315
  (f) => addFragmentImports(f, "solanaAddresses", [
2453
2316
  "type Address",
@@ -2462,12 +2325,9 @@ export function isTransactionSigner<TAddress extends string = string>(value: Add
2462
2325
  ])
2463
2326
  );
2464
2327
  }
2465
-
2466
- // src/fragments/typeDiscriminatedUnionHelpers.ts
2467
- var import_nodes27 = require("@codama/nodes");
2468
2328
  function getTypeDiscriminatedUnionHelpersFragment(scope) {
2469
2329
  const { name, typeNode, nameApi } = scope;
2470
- const isDiscriminatedUnion = (0, import_nodes27.isNode)(typeNode, "enumTypeNode") && (0, import_nodes27.isDataEnum)(typeNode);
2330
+ const isDiscriminatedUnion = nodes.isNode(typeNode, "enumTypeNode") && nodes.isDataEnum(typeNode);
2471
2331
  if (!isDiscriminatedUnion) return;
2472
2332
  const functionName = nameApi.discriminatedUnionFunction(name);
2473
2333
  const isDiscriminatedUnionFunctionName = nameApi.isDiscriminatedUnionFunction(name);
@@ -2479,10 +2339,10 @@ function getTypeDiscriminatedUnionHelpersFragment(scope) {
2479
2339
  const variantSignatures = mergeFragments(
2480
2340
  typeNode.variants.map((variant) => {
2481
2341
  const variantName = nameApi.discriminatedUnionVariant(variant.name);
2482
- if ((0, import_nodes27.isNode)(variant, "enumStructVariantTypeNode")) {
2342
+ if (nodes.isNode(variant, "enumStructVariantTypeNode")) {
2483
2343
  return fragment`export function ${functionName}(kind: '${variantName}', data: ${getVariantContentType}<${looseName}, '${discriminatorName}', '${variantName}'>): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
2484
2344
  }
2485
- if ((0, import_nodes27.isNode)(variant, "enumTupleVariantTypeNode")) {
2345
+ if (nodes.isNode(variant, "enumTupleVariantTypeNode")) {
2486
2346
  return fragment`export function ${functionName}(kind: '${variantName}', data: ${getVariantContentType}<${looseName}, '${discriminatorName}', '${variantName}'>['fields']): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
2487
2347
  }
2488
2348
  return fragment`export function ${functionName}(kind: '${variantName}'): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
@@ -2500,13 +2360,10 @@ export function ${isDiscriminatedUnionFunctionName}<K extends ${strictName}['${d
2500
2360
  };
2501
2361
  `;
2502
2362
  }
2503
-
2504
- // src/fragments/typePage.ts
2505
- var import_visitors_core27 = require("@codama/visitors-core");
2506
2363
  function getTypePageFragment(scope) {
2507
2364
  const node = scope.node;
2508
- const manifest = (0, import_visitors_core27.visit)(node, scope.typeManifestVisitor);
2509
- return (0, import_visitors_core27.pipe)(
2365
+ const manifest = visitorsCore.visit(node, scope.typeManifestVisitor);
2366
+ return visitorsCore.pipe(
2510
2367
  mergeFragments(
2511
2368
  [
2512
2369
  getTypeWithCodecFragment({ ...scope, manifest, name: node.name, node: node.type, typeDocs: node.docs }),
@@ -2523,42 +2380,37 @@ function getTypePageFragment(scope) {
2523
2380
  ])
2524
2381
  );
2525
2382
  }
2526
-
2527
- // src/visitors/getTypeManifestVisitor.ts
2528
- var import_nodes28 = require("@codama/nodes");
2529
- var import_renderers_core13 = require("@codama/renderers-core");
2530
- var import_visitors_core28 = require("@codama/visitors-core");
2531
2383
  function getTypeManifestVisitor(input) {
2532
2384
  const { nameApi, linkables, nonScalarEnums, customAccountData, customInstructionData, getImportFrom } = input;
2533
- const stack = input.stack ?? new import_visitors_core28.NodeStack();
2385
+ const stack = input.stack ?? new visitorsCore.NodeStack();
2534
2386
  let parentName = null;
2535
- return (0, import_visitors_core28.pipe)(
2536
- (0, import_visitors_core28.staticVisitor)(() => typeManifest(), {
2387
+ return visitorsCore.pipe(
2388
+ visitorsCore.staticVisitor(() => typeManifest(), {
2537
2389
  keys: [
2538
- ...import_nodes28.REGISTERED_TYPE_NODE_KINDS,
2539
- ...import_nodes28.REGISTERED_VALUE_NODE_KINDS,
2390
+ ...nodes.REGISTERED_TYPE_NODE_KINDS,
2391
+ ...nodes.REGISTERED_VALUE_NODE_KINDS,
2540
2392
  "definedTypeLinkNode",
2541
2393
  "definedTypeNode",
2542
2394
  "accountNode",
2543
2395
  "instructionNode"
2544
2396
  ]
2545
2397
  }),
2546
- (visitor) => (0, import_visitors_core28.extendVisitor)(visitor, {
2398
+ (visitor) => visitorsCore.extendVisitor(visitor, {
2547
2399
  visitAccount(account, { self }) {
2548
2400
  parentName = {
2549
2401
  loose: nameApi.dataArgsType(account.name),
2550
2402
  strict: nameApi.dataType(account.name)
2551
2403
  };
2552
2404
  const link = customAccountData.get(account.name)?.linkNode;
2553
- const manifest = link ? (0, import_visitors_core28.visit)(link, self) : (0, import_visitors_core28.visit)(account.data, self);
2405
+ const manifest = link ? visitorsCore.visit(link, self) : visitorsCore.visit(account.data, self);
2554
2406
  parentName = null;
2555
2407
  return manifest;
2556
2408
  },
2557
2409
  visitAmountType(amountType, { self }) {
2558
- return (0, import_visitors_core28.visit)(amountType.number, self);
2410
+ return visitorsCore.visit(amountType.number, self);
2559
2411
  },
2560
2412
  visitArrayType(arrayType, { self }) {
2561
- const childManifest = (0, import_visitors_core28.visit)(arrayType.item, self);
2413
+ const childManifest = visitorsCore.visit(arrayType.item, self);
2562
2414
  const sizeManifest = getArrayLikeSizeOption(arrayType.count, self);
2563
2415
  const encoderOptions = sizeManifest.encoder ? fragment`, { ${sizeManifest.encoder} }` : "";
2564
2416
  const decoderOptions = sizeManifest.decoder ? fragment`, { ${sizeManifest.decoder} }` : "";
@@ -2572,16 +2424,16 @@ function getTypeManifestVisitor(input) {
2572
2424
  },
2573
2425
  visitArrayValue(node, { self }) {
2574
2426
  return mergeTypeManifests(
2575
- node.items.map((v) => (0, import_visitors_core28.visit)(v, self)),
2427
+ node.items.map((v) => visitorsCore.visit(v, self)),
2576
2428
  { mergeValues: (renders) => `[${renders.join(", ")}]` }
2577
2429
  );
2578
2430
  },
2579
2431
  visitBooleanType(booleanType, { self }) {
2580
2432
  let sizeEncoder = fragment``;
2581
2433
  let sizeDecoder = fragment``;
2582
- const resolvedSize = (0, import_nodes28.resolveNestedTypeNode)(booleanType.size);
2434
+ const resolvedSize = nodes.resolveNestedTypeNode(booleanType.size);
2583
2435
  if (resolvedSize.format !== "u8" || resolvedSize.endian !== "le") {
2584
- const size = (0, import_visitors_core28.visit)(booleanType.size, self);
2436
+ const size = visitorsCore.visit(booleanType.size, self);
2585
2437
  sizeEncoder = fragment`{ size: ${size.encoder} }`;
2586
2438
  sizeDecoder = fragment`{ size: ${size.decoder} }`;
2587
2439
  }
@@ -2609,22 +2461,22 @@ function getTypeManifestVisitor(input) {
2609
2461
  return typeManifest({ value: fragment`new Uint8Array([${Array.from(bytes).join(", ")}])` });
2610
2462
  },
2611
2463
  visitConstantValue(node, { self }) {
2612
- if ((0, import_nodes28.isNode)(node.type, "bytesTypeNode") && (0, import_nodes28.isNode)(node.value, "bytesValueNode")) {
2613
- return (0, import_visitors_core28.visit)(node.value, self);
2464
+ if (nodes.isNode(node.type, "bytesTypeNode") && nodes.isNode(node.value, "bytesValueNode")) {
2465
+ return visitorsCore.visit(node.value, self);
2614
2466
  }
2615
2467
  return typeManifest({
2616
- value: fragment`${(0, import_visitors_core28.visit)(node.type, self).encoder}.encode(${(0, import_visitors_core28.visit)(node.value, self).value})`
2468
+ value: fragment`${visitorsCore.visit(node.type, self).encoder}.encode(${visitorsCore.visit(node.value, self).value})`
2617
2469
  });
2618
2470
  },
2619
2471
  visitDateTimeType(dateTimeType, { self }) {
2620
- return (0, import_visitors_core28.visit)(dateTimeType.number, self);
2472
+ return visitorsCore.visit(dateTimeType.number, self);
2621
2473
  },
2622
2474
  visitDefinedType(definedType, { self }) {
2623
2475
  parentName = {
2624
2476
  loose: nameApi.dataArgsType(definedType.name),
2625
2477
  strict: nameApi.dataType(definedType.name)
2626
2478
  };
2627
- const manifest = (0, import_visitors_core28.visit)(definedType.type, self);
2479
+ const manifest = visitorsCore.visit(definedType.type, self);
2628
2480
  parentName = null;
2629
2481
  return manifest;
2630
2482
  },
@@ -2642,7 +2494,7 @@ function getTypeManifestVisitor(input) {
2642
2494
  });
2643
2495
  },
2644
2496
  visitEnumEmptyVariantType(enumEmptyVariantType) {
2645
- const discriminator = nameApi.discriminatedUnionDiscriminator((0, import_nodes28.camelCase)(parentName?.strict ?? ""));
2497
+ const discriminator = nameApi.discriminatedUnionDiscriminator(nodes.camelCase(parentName?.strict ?? ""));
2646
2498
  const name = nameApi.discriminatedUnionVariant(enumEmptyVariantType.name);
2647
2499
  const kindAttribute = `${discriminator}: "${name}"`;
2648
2500
  return typeManifest({
@@ -2655,54 +2507,54 @@ function getTypeManifestVisitor(input) {
2655
2507
  visitEnumStructVariantType(enumStructVariantType, { self }) {
2656
2508
  const currentParentName = parentName;
2657
2509
  const discriminator = nameApi.discriminatedUnionDiscriminator(
2658
- (0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
2510
+ nodes.camelCase(currentParentName?.strict ?? "")
2659
2511
  );
2660
2512
  const name = nameApi.discriminatedUnionVariant(enumStructVariantType.name);
2661
2513
  const kindAttribute = `${discriminator}: "${name}"`;
2662
2514
  parentName = null;
2663
- const structManifest = (0, import_visitors_core28.visit)(enumStructVariantType.struct, self);
2515
+ const structManifest = visitorsCore.visit(enumStructVariantType.struct, self);
2664
2516
  parentName = currentParentName;
2665
2517
  return typeManifest({
2666
2518
  ...structManifest,
2667
2519
  decoder: fragment`['${name}', ${structManifest.decoder}]`,
2668
2520
  encoder: fragment`['${name}', ${structManifest.encoder}]`,
2669
- looseType: (0, import_visitors_core28.pipe)(
2521
+ looseType: visitorsCore.pipe(
2670
2522
  structManifest.looseType,
2671
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2523
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2672
2524
  ),
2673
- strictType: (0, import_visitors_core28.pipe)(
2525
+ strictType: visitorsCore.pipe(
2674
2526
  structManifest.strictType,
2675
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2527
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2676
2528
  )
2677
2529
  });
2678
2530
  },
2679
2531
  visitEnumTupleVariantType(enumTupleVariantType, { self }) {
2680
2532
  const currentParentName = parentName;
2681
2533
  const discriminator = nameApi.discriminatedUnionDiscriminator(
2682
- (0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
2534
+ nodes.camelCase(currentParentName?.strict ?? "")
2683
2535
  );
2684
2536
  const name = nameApi.discriminatedUnionVariant(enumTupleVariantType.name);
2685
2537
  const kindAttribute = `${discriminator}: "${name}"`;
2686
- const struct = (0, import_nodes28.structTypeNode)([
2687
- (0, import_nodes28.structFieldTypeNode)({
2538
+ const struct = nodes.structTypeNode([
2539
+ nodes.structFieldTypeNode({
2688
2540
  name: "fields",
2689
2541
  type: enumTupleVariantType.tuple
2690
2542
  })
2691
2543
  ]);
2692
2544
  parentName = null;
2693
- const structManifest = (0, import_visitors_core28.visit)(struct, self);
2545
+ const structManifest = visitorsCore.visit(struct, self);
2694
2546
  parentName = currentParentName;
2695
2547
  return typeManifest({
2696
2548
  ...structManifest,
2697
2549
  decoder: fragment`['${name}', ${structManifest.decoder}]`,
2698
2550
  encoder: fragment`['${name}', ${structManifest.encoder}]`,
2699
- looseType: (0, import_visitors_core28.pipe)(
2551
+ looseType: visitorsCore.pipe(
2700
2552
  structManifest.looseType,
2701
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2553
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2702
2554
  ),
2703
- strictType: (0, import_visitors_core28.pipe)(
2555
+ strictType: visitorsCore.pipe(
2704
2556
  structManifest.strictType,
2705
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2557
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2706
2558
  )
2707
2559
  });
2708
2560
  },
@@ -2710,16 +2562,16 @@ function getTypeManifestVisitor(input) {
2710
2562
  const currentParentName = parentName;
2711
2563
  const encoderOptions = [];
2712
2564
  const decoderOptions = [];
2713
- const enumSize = (0, import_nodes28.resolveNestedTypeNode)(enumType.size);
2565
+ const enumSize = nodes.resolveNestedTypeNode(enumType.size);
2714
2566
  if (enumSize.format !== "u8" || enumSize.endian !== "le") {
2715
- const sizeManifest = (0, import_visitors_core28.visit)(enumType.size, self);
2567
+ const sizeManifest = visitorsCore.visit(enumType.size, self);
2716
2568
  encoderOptions.push(fragment`size: ${sizeManifest.encoder}`);
2717
2569
  decoderOptions.push(fragment`size: ${sizeManifest.decoder}`);
2718
2570
  }
2719
2571
  const discriminator = nameApi.discriminatedUnionDiscriminator(
2720
- (0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
2572
+ nodes.camelCase(currentParentName?.strict ?? "")
2721
2573
  );
2722
- if (!(0, import_nodes28.isScalarEnum)(enumType) && discriminator !== "__kind") {
2574
+ if (!nodes.isScalarEnum(enumType) && discriminator !== "__kind") {
2723
2575
  encoderOptions.push(fragment`discriminator: '${discriminator}'`);
2724
2576
  decoderOptions.push(fragment`discriminator: '${discriminator}'`);
2725
2577
  }
@@ -2731,7 +2583,7 @@ function getTypeManifestVisitor(input) {
2731
2583
  decoderOptions,
2732
2584
  (cs) => cs.length > 0 ? `, { ${cs.join(", ")} }` : ""
2733
2585
  );
2734
- if ((0, import_nodes28.isScalarEnum)(enumType)) {
2586
+ if (nodes.isScalarEnum(enumType)) {
2735
2587
  if (currentParentName === null) {
2736
2588
  throw new Error(
2737
2589
  "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."
@@ -2747,7 +2599,7 @@ function getTypeManifestVisitor(input) {
2747
2599
  });
2748
2600
  }
2749
2601
  const mergedManifest = mergeTypeManifests(
2750
- enumType.variants.map((variant) => (0, import_visitors_core28.visit)(variant, self)),
2602
+ enumType.variants.map((variant) => visitorsCore.visit(variant, self)),
2751
2603
  {
2752
2604
  mergeCodecs: (renders) => renders.join(", "),
2753
2605
  mergeTypes: (renders) => renders.join(" | ")
@@ -2765,14 +2617,14 @@ function getTypeManifestVisitor(input) {
2765
2617
  const enumFunction = nameApi.discriminatedUnionFunction(node.enum.name);
2766
2618
  const importFrom = getImportFrom(node.enum);
2767
2619
  const enumNode = linkables.get([...stack.getPath(), node.enum])?.type;
2768
- const isScalar = enumNode && (0, import_nodes28.isNode)(enumNode, "enumTypeNode") ? (0, import_nodes28.isScalarEnum)(enumNode) : !nonScalarEnums.includes(node.enum.name);
2620
+ const isScalar = enumNode && nodes.isNode(enumNode, "enumTypeNode") ? nodes.isScalarEnum(enumNode) : !nonScalarEnums.includes(node.enum.name);
2769
2621
  if (!node.value && isScalar) {
2770
2622
  const variantName2 = nameApi.enumVariant(node.variant);
2771
2623
  return typeManifest({
2772
2624
  ...manifest,
2773
- value: (0, import_visitors_core28.pipe)(
2625
+ value: visitorsCore.pipe(
2774
2626
  manifest.value,
2775
- (f) => (0, import_renderers_core13.setFragmentContent)(f, `${enumName}.${variantName2}`),
2627
+ (f) => renderersCore.setFragmentContent(f, `${enumName}.${variantName2}`),
2776
2628
  (f) => addFragmentImports(f, importFrom, [enumName])
2777
2629
  )
2778
2630
  });
@@ -2781,24 +2633,24 @@ function getTypeManifestVisitor(input) {
2781
2633
  if (!node.value) {
2782
2634
  return typeManifest({
2783
2635
  ...manifest,
2784
- value: (0, import_visitors_core28.pipe)(
2636
+ value: visitorsCore.pipe(
2785
2637
  manifest.value,
2786
- (f) => (0, import_renderers_core13.setFragmentContent)(f, `${enumFunction}('${variantName}')`),
2638
+ (f) => renderersCore.setFragmentContent(f, `${enumFunction}('${variantName}')`),
2787
2639
  (f) => addFragmentImports(f, importFrom, [enumFunction])
2788
2640
  )
2789
2641
  });
2790
2642
  }
2791
2643
  return typeManifest({
2792
2644
  ...manifest,
2793
- value: (0, import_visitors_core28.pipe)(
2794
- (0, import_visitors_core28.visit)(node.value, self).value,
2795
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `${enumFunction}('${variantName}', ${c})`),
2645
+ value: visitorsCore.pipe(
2646
+ visitorsCore.visit(node.value, self).value,
2647
+ (f) => renderersCore.mapFragmentContent(f, (c) => `${enumFunction}('${variantName}', ${c})`),
2796
2648
  (f) => addFragmentImports(f, importFrom, [enumFunction])
2797
2649
  )
2798
2650
  });
2799
2651
  },
2800
2652
  visitFixedSizeType(node, { self }) {
2801
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2653
+ const manifest = visitorsCore.visit(node.type, self);
2802
2654
  return typeManifest({
2803
2655
  ...manifest,
2804
2656
  decoder: fragment`${use("fixDecoderSize", "solanaCodecsCore")}(${manifest.decoder}, ${node.size})`,
@@ -2806,13 +2658,13 @@ function getTypeManifestVisitor(input) {
2806
2658
  });
2807
2659
  },
2808
2660
  visitHiddenPrefixType(node, { self }) {
2809
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2810
- const prefixes = node.prefix.map((c) => (0, import_visitors_core28.visit)(c, self).value);
2811
- const prefixEncoders = (0, import_visitors_core28.pipe)(
2661
+ const manifest = visitorsCore.visit(node.type, self);
2662
+ const prefixes = node.prefix.map((c) => visitorsCore.visit(c, self).value);
2663
+ const prefixEncoders = visitorsCore.pipe(
2812
2664
  mergeFragments(prefixes, (cs) => cs.map((c) => `getConstantEncoder(${c})`).join(", ")),
2813
2665
  (f) => addFragmentImports(f, "solanaCodecsCore", ["getConstantEncoder"])
2814
2666
  );
2815
- const prefixDecoders = (0, import_visitors_core28.pipe)(
2667
+ const prefixDecoders = visitorsCore.pipe(
2816
2668
  mergeFragments(prefixes, (cs) => cs.map((c) => `getConstantDecoder(${c})`).join(", ")),
2817
2669
  (f) => addFragmentImports(f, "solanaCodecsCore", ["getConstantDecoder"])
2818
2670
  );
@@ -2823,13 +2675,13 @@ function getTypeManifestVisitor(input) {
2823
2675
  });
2824
2676
  },
2825
2677
  visitHiddenSuffixType(node, { self }) {
2826
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2827
- const suffixes = node.suffix.map((c) => (0, import_visitors_core28.visit)(c, self).value);
2828
- const suffixEncoders = (0, import_visitors_core28.pipe)(
2678
+ const manifest = visitorsCore.visit(node.type, self);
2679
+ const suffixes = node.suffix.map((c) => visitorsCore.visit(c, self).value);
2680
+ const suffixEncoders = visitorsCore.pipe(
2829
2681
  mergeFragments(suffixes, (cs) => cs.map((c) => `getConstantEncoder(${c})`).join(", ")),
2830
2682
  (f) => addFragmentImports(f, "solanaCodecsCore", ["getConstantEncoder"])
2831
2683
  );
2832
- const suffixDecoders = (0, import_visitors_core28.pipe)(
2684
+ const suffixDecoders = visitorsCore.pipe(
2833
2685
  mergeFragments(suffixes, (cs) => cs.map((c) => `getConstantDecoder(${c})`).join(", ")),
2834
2686
  (f) => addFragmentImports(f, "solanaCodecsCore", ["getConstantDecoder"])
2835
2687
  );
@@ -2846,19 +2698,19 @@ function getTypeManifestVisitor(input) {
2846
2698
  strict: nameApi.dataType(instructionDataName)
2847
2699
  };
2848
2700
  const link = customInstructionData.get(instruction.name)?.linkNode;
2849
- const struct = (0, import_nodes28.structTypeNodeFromInstructionArgumentNodes)(instruction.arguments);
2850
- const manifest = link ? (0, import_visitors_core28.visit)(link, self) : (0, import_visitors_core28.visit)(struct, self);
2701
+ const struct = nodes.structTypeNodeFromInstructionArgumentNodes(instruction.arguments);
2702
+ const manifest = link ? visitorsCore.visit(link, self) : visitorsCore.visit(struct, self);
2851
2703
  parentName = null;
2852
2704
  return manifest;
2853
2705
  },
2854
2706
  visitMapEntryValue(node, { self }) {
2855
- return mergeTypeManifests([(0, import_visitors_core28.visit)(node.key, self), (0, import_visitors_core28.visit)(node.value, self)], {
2707
+ return mergeTypeManifests([visitorsCore.visit(node.key, self), visitorsCore.visit(node.value, self)], {
2856
2708
  mergeValues: (renders) => `[${renders.join(", ")}]`
2857
2709
  });
2858
2710
  },
2859
2711
  visitMapType(mapType, { self }) {
2860
- const key = (0, import_visitors_core28.visit)(mapType.key, self);
2861
- const value = (0, import_visitors_core28.visit)(mapType.value, self);
2712
+ const key = visitorsCore.visit(mapType.key, self);
2713
+ const value = visitorsCore.visit(mapType.value, self);
2862
2714
  const mergedManifest = mergeTypeManifests([key, value], {
2863
2715
  mergeCodecs: ([k, v]) => `${k}, ${v}`,
2864
2716
  mergeTypes: ([k, v]) => `Map<${k}, ${v}>`
@@ -2873,7 +2725,7 @@ function getTypeManifestVisitor(input) {
2873
2725
  });
2874
2726
  },
2875
2727
  visitMapValue(node, { self }) {
2876
- const entryFragments = node.entries.map((entry) => (0, import_visitors_core28.visit)(entry, self));
2728
+ const entryFragments = node.entries.map((entry) => visitorsCore.visit(entry, self));
2877
2729
  return mergeTypeManifests(entryFragments, {
2878
2730
  mergeValues: (renders) => `new Map([${renders.join(", ")}])`
2879
2731
  });
@@ -2899,12 +2751,12 @@ function getTypeManifestVisitor(input) {
2899
2751
  return typeManifest({ value: fragment`${JSON.stringify(node.number)}` });
2900
2752
  },
2901
2753
  visitOptionType(optionType, { self }) {
2902
- const childManifest = (0, import_visitors_core28.visit)(optionType.item, self);
2754
+ const childManifest = visitorsCore.visit(optionType.item, self);
2903
2755
  const encoderOptions = [];
2904
2756
  const decoderOptions = [];
2905
- const optionPrefix = (0, import_nodes28.resolveNestedTypeNode)(optionType.prefix);
2757
+ const optionPrefix = nodes.resolveNestedTypeNode(optionType.prefix);
2906
2758
  if (optionPrefix.format !== "u8" || optionPrefix.endian !== "le") {
2907
- const prefixManifest = (0, import_visitors_core28.visit)(optionType.prefix, self);
2759
+ const prefixManifest = visitorsCore.visit(optionType.prefix, self);
2908
2760
  encoderOptions.push(fragment`prefix: ${prefixManifest.encoder}`);
2909
2761
  decoderOptions.push(fragment`prefix: ${prefixManifest.decoder}`);
2910
2762
  }
@@ -2929,7 +2781,7 @@ function getTypeManifestVisitor(input) {
2929
2781
  });
2930
2782
  },
2931
2783
  visitPostOffsetType(node, { self }) {
2932
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2784
+ const manifest = visitorsCore.visit(node.type, self);
2933
2785
  if (node.strategy === "padded") {
2934
2786
  return typeManifest({
2935
2787
  ...manifest,
@@ -2955,7 +2807,7 @@ function getTypeManifestVisitor(input) {
2955
2807
  });
2956
2808
  },
2957
2809
  visitPreOffsetType(node, { self }) {
2958
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2810
+ const manifest = visitorsCore.visit(node.type, self);
2959
2811
  if (node.strategy === "padded") {
2960
2812
  return typeManifest({
2961
2813
  ...manifest,
@@ -2992,7 +2844,7 @@ function getTypeManifestVisitor(input) {
2992
2844
  });
2993
2845
  },
2994
2846
  visitRemainderOptionType(node, { self }) {
2995
- const childManifest = (0, import_visitors_core28.visit)(node.item, self);
2847
+ const childManifest = visitorsCore.visit(node.item, self);
2996
2848
  const encoderOptions = ["prefix: null"];
2997
2849
  const decoderOptions = ["prefix: null"];
2998
2850
  const encoderOptionsAsString = encoderOptions.length > 0 ? `, { ${encoderOptions.join(", ")} }` : "";
@@ -3006,8 +2858,8 @@ function getTypeManifestVisitor(input) {
3006
2858
  });
3007
2859
  },
3008
2860
  visitSentinelType(node, { self }) {
3009
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
3010
- const sentinel = (0, import_visitors_core28.visit)(node.sentinel, self).value;
2861
+ const manifest = visitorsCore.visit(node.type, self);
2862
+ const sentinel = visitorsCore.visit(node.sentinel, self).value;
3011
2863
  return typeManifest({
3012
2864
  ...manifest,
3013
2865
  decoder: fragment`${use("addDecoderSentinel", "solanaCodecsCore")}(${manifest.decoder}, ${sentinel})`,
@@ -3015,7 +2867,7 @@ function getTypeManifestVisitor(input) {
3015
2867
  });
3016
2868
  },
3017
2869
  visitSetType(setType, { self }) {
3018
- const childManifest = (0, import_visitors_core28.visit)(setType.item, self);
2870
+ const childManifest = visitorsCore.visit(setType.item, self);
3019
2871
  const sizeManifest = getArrayLikeSizeOption(setType.count, self);
3020
2872
  const encoderOptions = sizeManifest.encoder ? fragment`, { ${sizeManifest.encoder} }` : "";
3021
2873
  const decoderOptions = sizeManifest.decoder ? fragment`, { ${sizeManifest.decoder} }` : "";
@@ -3029,13 +2881,13 @@ function getTypeManifestVisitor(input) {
3029
2881
  },
3030
2882
  visitSetValue(node, { self }) {
3031
2883
  return mergeTypeManifests(
3032
- node.items.map((v) => (0, import_visitors_core28.visit)(v, self)),
2884
+ node.items.map((v) => visitorsCore.visit(v, self)),
3033
2885
  { mergeValues: (renders) => `new Set([${renders.join(", ")}])` }
3034
2886
  );
3035
2887
  },
3036
2888
  visitSizePrefixType(node, { self }) {
3037
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
3038
- const prefix = (0, import_visitors_core28.visit)(node.prefix, self);
2889
+ const manifest = visitorsCore.visit(node.type, self);
2890
+ const prefix = visitorsCore.visit(node.prefix, self);
3039
2891
  return typeManifest({
3040
2892
  ...manifest,
3041
2893
  decoder: fragment`${use("addDecoderSizePrefix", "solanaCodecsCore")}(${manifest.decoder}, ${prefix.decoder})`,
@@ -3043,7 +2895,7 @@ function getTypeManifestVisitor(input) {
3043
2895
  });
3044
2896
  },
3045
2897
  visitSolAmountType({ number }, { self }) {
3046
- const numberManifest = (0, import_visitors_core28.visit)(number, self);
2898
+ const numberManifest = visitorsCore.visit(number, self);
3047
2899
  return typeManifest({
3048
2900
  ...numberManifest,
3049
2901
  decoder: fragment`${use("getLamportsDecoder", "solanaRpcTypes")}(${numberManifest.decoder})`,
@@ -3053,7 +2905,7 @@ function getTypeManifestVisitor(input) {
3053
2905
  });
3054
2906
  },
3055
2907
  visitSomeValue(node, { self }) {
3056
- const innerValue = (0, import_visitors_core28.visit)(node.value, self).value;
2908
+ const innerValue = visitorsCore.visit(node.value, self).value;
3057
2909
  return typeManifest({
3058
2910
  value: fragment`${use("some", "solanaOptions")}(${innerValue})`
3059
2911
  });
@@ -3086,8 +2938,8 @@ function getTypeManifestVisitor(input) {
3086
2938
  });
3087
2939
  },
3088
2940
  visitStructFieldType(structFieldType, { self }) {
3089
- const name = (0, import_nodes28.camelCase)(structFieldType.name);
3090
- const originalChildManifest = (0, import_visitors_core28.visit)(structFieldType.type, self);
2941
+ const name = nodes.camelCase(structFieldType.name);
2942
+ const originalChildManifest = visitorsCore.visit(structFieldType.type, self);
3091
2943
  let docs = getDocblockFragment(structFieldType.docs ?? [], true);
3092
2944
  docs = docs ? fragment`\n${docs}` : docs;
3093
2945
  const childManifest = typeManifest({
@@ -3109,16 +2961,16 @@ function getTypeManifestVisitor(input) {
3109
2961
  return typeManifest({ ...childManifest, looseType: fragment`` });
3110
2962
  },
3111
2963
  visitStructFieldValue(node, { self }) {
3112
- const innerValue = (0, import_visitors_core28.visit)(node.value, self).value;
2964
+ const innerValue = visitorsCore.visit(node.value, self).value;
3113
2965
  return typeManifest({
3114
2966
  value: fragment`${node.name}: ${innerValue}`
3115
2967
  });
3116
2968
  },
3117
2969
  visitStructType(structType, { self }) {
3118
2970
  const optionalFields = structType.fields.filter((f) => !!f.defaultValue);
3119
- const mergedManifest = (0, import_visitors_core28.pipe)(
2971
+ const mergedManifest = visitorsCore.pipe(
3120
2972
  mergeTypeManifests(
3121
- structType.fields.map((field) => (0, import_visitors_core28.visit)(field, self)),
2973
+ structType.fields.map((field) => visitorsCore.visit(field, self)),
3122
2974
  {
3123
2975
  mergeCodecs: (renders) => `([${renders.join(", ")}])`,
3124
2976
  mergeTypes: (renders) => `{ ${renders.join("")} }`
@@ -3134,20 +2986,20 @@ function getTypeManifestVisitor(input) {
3134
2986
  return mergedManifest;
3135
2987
  }
3136
2988
  const parentPath = stack.getPath();
3137
- const instructionNode = (0, import_visitors_core28.findLastNodeFromPath)(parentPath, "instructionNode");
3138
- const accountNode = (0, import_visitors_core28.findLastNodeFromPath)(parentPath, "accountNode");
2989
+ const instructionNode = visitorsCore.findLastNodeFromPath(parentPath, "instructionNode");
2990
+ const accountNode = visitorsCore.findLastNodeFromPath(parentPath, "accountNode");
3139
2991
  const discriminatorPrefix = instructionNode ? instructionNode.name : accountNode?.name;
3140
2992
  const discriminators = (instructionNode ? instructionNode.discriminators : accountNode?.discriminators) ?? [];
3141
- const fieldDiscriminators = discriminators.filter((0, import_nodes28.isNodeFilter)("fieldDiscriminatorNode"));
2993
+ const fieldDiscriminators = discriminators.filter(nodes.isNodeFilter("fieldDiscriminatorNode"));
3142
2994
  const defaultValues = mergeFragments(
3143
2995
  optionalFields.map((f) => {
3144
- const key = (0, import_nodes28.camelCase)(f.name);
2996
+ const key = nodes.camelCase(f.name);
3145
2997
  if (fieldDiscriminators.some((d) => d.name === f.name)) {
3146
- const constantName = nameApi.constant((0, import_nodes28.camelCase)(`${discriminatorPrefix}_${f.name}`));
2998
+ const constantName = nameApi.constant(nodes.camelCase(`${discriminatorPrefix}_${f.name}`));
3147
2999
  return f.defaultValueStrategy === "omitted" ? fragment`${key}: ${constantName}` : fragment`${key}: value.${key} ?? ${constantName}`;
3148
3000
  }
3149
3001
  const defaultValue = f.defaultValue;
3150
- const value = (0, import_visitors_core28.visit)(defaultValue, self).value;
3002
+ const value = visitorsCore.visit(defaultValue, self).value;
3151
3003
  return f.defaultValueStrategy === "omitted" ? fragment`${key}: ${value}` : fragment`${key}: value.${key} ?? ${value}`;
3152
3004
  }),
3153
3005
  (cs) => cs.join(", ")
@@ -3159,12 +3011,12 @@ function getTypeManifestVisitor(input) {
3159
3011
  },
3160
3012
  visitStructValue(node, { self }) {
3161
3013
  return mergeTypeManifests(
3162
- node.fields.map((field) => (0, import_visitors_core28.visit)(field, self)),
3014
+ node.fields.map((field) => visitorsCore.visit(field, self)),
3163
3015
  { mergeValues: (renders) => `{ ${renders.join(", ")} }` }
3164
3016
  );
3165
3017
  },
3166
3018
  visitTupleType(tupleType, { self }) {
3167
- const items = tupleType.items.map((item) => (0, import_visitors_core28.visit)(item, self));
3019
+ const items = tupleType.items.map((item) => visitorsCore.visit(item, self));
3168
3020
  const mergedManifest = mergeTypeManifests(items, {
3169
3021
  mergeCodecs: (codecs) => `[${codecs.join(", ")}]`,
3170
3022
  mergeTypes: (types) => `readonly [${types.join(", ")}]`
@@ -3177,16 +3029,16 @@ function getTypeManifestVisitor(input) {
3177
3029
  },
3178
3030
  visitTupleValue(node, { self }) {
3179
3031
  return mergeTypeManifests(
3180
- node.items.map((v) => (0, import_visitors_core28.visit)(v, self)),
3032
+ node.items.map((v) => visitorsCore.visit(v, self)),
3181
3033
  { mergeValues: (renders) => `[${renders.join(", ")}]` }
3182
3034
  );
3183
3035
  },
3184
3036
  visitZeroableOptionType(node, { self }) {
3185
- const childManifest = (0, import_visitors_core28.visit)(node.item, self);
3037
+ const childManifest = visitorsCore.visit(node.item, self);
3186
3038
  const encoderOptions = [fragment`prefix: null`];
3187
3039
  const decoderOptions = [fragment`prefix: null`];
3188
3040
  if (node.zeroValue) {
3189
- const zeroValueManifest = (0, import_visitors_core28.visit)(node.zeroValue, self);
3041
+ const zeroValueManifest = visitorsCore.visit(node.zeroValue, self);
3190
3042
  encoderOptions.push(fragment`noneValue: ${zeroValueManifest.value}`);
3191
3043
  decoderOptions.push(fragment`noneValue: ${zeroValueManifest.value}`);
3192
3044
  } else {
@@ -3210,41 +3062,41 @@ function getTypeManifestVisitor(input) {
3210
3062
  });
3211
3063
  }
3212
3064
  }),
3213
- (visitor) => (0, import_visitors_core28.recordNodeStackVisitor)(visitor, stack)
3065
+ (visitor) => visitorsCore.recordNodeStackVisitor(visitor, stack)
3214
3066
  );
3215
3067
  }
3216
3068
  function getArrayLikeSizeOption(count, visitor) {
3217
- if ((0, import_nodes28.isNode)(count, "fixedCountNode")) {
3069
+ if (nodes.isNode(count, "fixedCountNode")) {
3218
3070
  return {
3219
3071
  decoder: fragment`size: ${count.value}`,
3220
3072
  encoder: fragment`size: ${count.value}`
3221
3073
  };
3222
3074
  }
3223
- if ((0, import_nodes28.isNode)(count, "remainderCountNode")) {
3075
+ if (nodes.isNode(count, "remainderCountNode")) {
3224
3076
  return {
3225
3077
  decoder: fragment`size: 'remainder'`,
3226
3078
  encoder: fragment`size: 'remainder'`
3227
3079
  };
3228
3080
  }
3229
- const prefix = (0, import_nodes28.resolveNestedTypeNode)(count.prefix);
3081
+ const prefix = nodes.resolveNestedTypeNode(count.prefix);
3230
3082
  if (prefix.format === "u32" && prefix.endian === "le") {
3231
3083
  return { decoder: void 0, encoder: void 0 };
3232
3084
  }
3233
- const prefixManifest = (0, import_visitors_core28.visit)(count.prefix, visitor);
3085
+ const prefixManifest = visitorsCore.visit(count.prefix, visitor);
3234
3086
  return {
3235
- decoder: (0, import_visitors_core28.pipe)(prefixManifest.decoder, (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `size: ${c}`)),
3236
- encoder: (0, import_visitors_core28.pipe)(prefixManifest.encoder, (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `size: ${c}`))
3087
+ decoder: visitorsCore.pipe(prefixManifest.decoder, (f) => renderersCore.mapFragmentContent(f, (c) => `size: ${c}`)),
3088
+ encoder: visitorsCore.pipe(prefixManifest.encoder, (f) => renderersCore.mapFragmentContent(f, (c) => `size: ${c}`))
3237
3089
  };
3238
3090
  }
3239
3091
 
3240
3092
  // src/visitors/getRenderMapVisitor.ts
3241
3093
  function getRenderMapVisitor(options = {}) {
3242
- const linkables = new import_visitors_core29.LinkableDictionary();
3243
- const stack = new import_visitors_core29.NodeStack();
3094
+ const linkables = new visitorsCore.LinkableDictionary();
3095
+ const stack = new visitorsCore.NodeStack();
3244
3096
  const customAccountData = parseCustomDataOptions(options.customAccountData ?? [], "AccountData");
3245
3097
  const customInstructionData = parseCustomDataOptions(options.customInstructionData ?? [], "InstructionData");
3246
3098
  const renderScopeWithTypeManifestVisitor = {
3247
- asyncResolvers: (options.asyncResolvers ?? []).map(import_nodes29.camelCase),
3099
+ asyncResolvers: (options.asyncResolvers ?? []).map(nodes.camelCase),
3248
3100
  customAccountData,
3249
3101
  customInstructionData,
3250
3102
  dependencyMap: options.dependencyMap ?? {},
@@ -3252,15 +3104,15 @@ function getRenderMapVisitor(options = {}) {
3252
3104
  getImportFrom: getImportFromFactory(options.linkOverrides ?? {}, customAccountData, customInstructionData),
3253
3105
  linkables,
3254
3106
  nameApi: getNameApi({ ...DEFAULT_NAME_TRANSFORMERS, ...options.nameTransformers }),
3255
- nonScalarEnums: (options.nonScalarEnums ?? []).map(import_nodes29.camelCase),
3107
+ nonScalarEnums: (options.nonScalarEnums ?? []).map(nodes.camelCase),
3256
3108
  renderParentInstructions: options.renderParentInstructions ?? false,
3257
3109
  useGranularImports: options.useGranularImports ?? false
3258
3110
  };
3259
3111
  const typeManifestVisitor = getTypeManifestVisitor({ ...renderScopeWithTypeManifestVisitor, stack });
3260
3112
  const renderScope = { ...renderScopeWithTypeManifestVisitor, typeManifestVisitor };
3261
- const internalNodes = (options.internalNodes ?? []).map(import_nodes29.camelCase);
3262
- const resolvedInstructionInputVisitor = (0, import_visitors_core29.getResolvedInstructionInputsVisitor)();
3263
- const byteSizeVisitor = (0, import_visitors_core29.getByteSizeVisitor)(linkables, { stack });
3113
+ const internalNodes = (options.internalNodes ?? []).map(nodes.camelCase);
3114
+ const resolvedInstructionInputVisitor = visitorsCore.getResolvedInstructionInputsVisitor();
3115
+ const byteSizeVisitor = visitorsCore.getByteSizeVisitor(linkables, { stack });
3264
3116
  const asPage = (fragment2, dependencyMap = {}) => {
3265
3117
  if (!fragment2) return void 0;
3266
3118
  return getPageFragment(fragment2, {
@@ -3268,47 +3120,47 @@ function getRenderMapVisitor(options = {}) {
3268
3120
  dependencyMap: { ...renderScope.dependencyMap, ...dependencyMap }
3269
3121
  });
3270
3122
  };
3271
- return (0, import_visitors_core29.pipe)(
3272
- (0, import_visitors_core29.staticVisitor)(() => (0, import_renderers_core14.createRenderMap)(), {
3123
+ return visitorsCore.pipe(
3124
+ visitorsCore.staticVisitor(() => renderersCore.createRenderMap(), {
3273
3125
  keys: ["rootNode", "programNode", "pdaNode", "accountNode", "definedTypeNode", "instructionNode"]
3274
3126
  }),
3275
- (v) => (0, import_visitors_core29.extendVisitor)(v, {
3127
+ (v) => visitorsCore.extendVisitor(v, {
3276
3128
  visitAccount(node) {
3277
- return (0, import_renderers_core14.createRenderMap)(
3278
- `accounts/${(0, import_nodes29.camelCase)(node.name)}.ts`,
3129
+ return renderersCore.createRenderMap(
3130
+ `accounts/${nodes.camelCase(node.name)}.ts`,
3279
3131
  asPage(
3280
3132
  getAccountPageFragment({
3281
3133
  ...renderScope,
3282
3134
  accountPath: stack.getPath("accountNode"),
3283
- size: (0, import_visitors_core29.visit)(node, byteSizeVisitor)
3135
+ size: visitorsCore.visit(node, byteSizeVisitor)
3284
3136
  })
3285
3137
  )
3286
3138
  );
3287
3139
  },
3288
3140
  visitDefinedType(node) {
3289
- return (0, import_renderers_core14.createRenderMap)(
3290
- `types/${(0, import_nodes29.camelCase)(node.name)}.ts`,
3291
- asPage(getTypePageFragment({ ...renderScope, node, size: (0, import_visitors_core29.visit)(node, byteSizeVisitor) }), {
3141
+ return renderersCore.createRenderMap(
3142
+ `types/${nodes.camelCase(node.name)}.ts`,
3143
+ asPage(getTypePageFragment({ ...renderScope, node, size: visitorsCore.visit(node, byteSizeVisitor) }), {
3292
3144
  generatedTypes: "."
3293
3145
  })
3294
3146
  );
3295
3147
  },
3296
3148
  visitInstruction(node) {
3297
- return (0, import_renderers_core14.createRenderMap)(
3298
- `instructions/${(0, import_nodes29.camelCase)(node.name)}.ts`,
3149
+ return renderersCore.createRenderMap(
3150
+ `instructions/${nodes.camelCase(node.name)}.ts`,
3299
3151
  asPage(
3300
3152
  getInstructionPageFragment({
3301
3153
  ...renderScope,
3302
3154
  instructionPath: stack.getPath("instructionNode"),
3303
- resolvedInputs: (0, import_visitors_core29.visit)(node, resolvedInstructionInputVisitor),
3304
- size: (0, import_visitors_core29.visit)(node, byteSizeVisitor)
3155
+ resolvedInputs: visitorsCore.visit(node, resolvedInstructionInputVisitor),
3156
+ size: visitorsCore.visit(node, byteSizeVisitor)
3305
3157
  })
3306
3158
  )
3307
3159
  );
3308
3160
  },
3309
3161
  visitPda(node) {
3310
- return (0, import_renderers_core14.createRenderMap)(
3311
- `pdas/${(0, import_nodes29.camelCase)(node.name)}.ts`,
3162
+ return renderersCore.createRenderMap(
3163
+ `pdas/${nodes.camelCase(node.name)}.ts`,
3312
3164
  asPage(getPdaPageFragment({ ...renderScope, pdaPath: stack.getPath("pdaNode") }))
3313
3165
  );
3314
3166
  },
@@ -3318,41 +3170,40 @@ function getRenderMapVisitor(options = {}) {
3318
3170
  ...getDefinedTypeNodesToExtract(node.instructions, customInstructionData)
3319
3171
  ];
3320
3172
  const scope = { ...renderScope, programNode: node };
3321
- return (0, import_renderers_core14.mergeRenderMaps)([
3322
- (0, import_renderers_core14.createRenderMap)({
3323
- [`programs/${(0, import_nodes29.camelCase)(node.name)}.ts`]: asPage(getProgramPageFragment(scope)),
3324
- [`errors/${(0, import_nodes29.camelCase)(node.name)}.ts`]: node.errors.length > 0 ? asPage(getErrorPageFragment(scope)) : void 0
3173
+ return renderersCore.mergeRenderMaps([
3174
+ renderersCore.createRenderMap({
3175
+ [`programs/${nodes.camelCase(node.name)}.ts`]: asPage(getProgramPageFragment(scope)),
3176
+ [`errors/${nodes.camelCase(node.name)}.ts`]: node.errors.length > 0 ? asPage(getErrorPageFragment(scope)) : void 0
3325
3177
  }),
3326
- ...node.pdas.map((p) => (0, import_visitors_core29.visit)(p, self)),
3327
- ...node.accounts.map((a) => (0, import_visitors_core29.visit)(a, self)),
3328
- ...node.definedTypes.map((t) => (0, import_visitors_core29.visit)(t, self)),
3329
- ...customDataDefinedType.map((t) => (0, import_visitors_core29.visit)(t, self)),
3330
- ...(0, import_nodes29.getAllInstructionsWithSubs)(node, { leavesOnly: !renderScope.renderParentInstructions }).map(
3331
- (i) => (0, import_visitors_core29.visit)(i, self)
3178
+ ...node.pdas.map((p) => visitorsCore.visit(p, self)),
3179
+ ...node.accounts.map((a) => visitorsCore.visit(a, self)),
3180
+ ...node.definedTypes.map((t) => visitorsCore.visit(t, self)),
3181
+ ...customDataDefinedType.map((t) => visitorsCore.visit(t, self)),
3182
+ ...nodes.getAllInstructionsWithSubs(node, { leavesOnly: !renderScope.renderParentInstructions }).map(
3183
+ (i) => visitorsCore.visit(i, self)
3332
3184
  )
3333
3185
  ]);
3334
3186
  },
3335
3187
  visitRoot(node, { self }) {
3336
3188
  const isNotInternal = (n) => !internalNodes.includes(n.name);
3337
- const programsToExport = (0, import_nodes29.getAllPrograms)(node).filter(isNotInternal);
3189
+ const programsToExport = nodes.getAllPrograms(node).filter(isNotInternal);
3338
3190
  const programsWithErrorsToExport = programsToExport.filter((p) => p.errors.length > 0);
3339
- const pdasToExport = (0, import_nodes29.getAllPdas)(node);
3340
- const accountsToExport = (0, import_nodes29.getAllAccounts)(node).filter(isNotInternal);
3341
- const instructionsToExport = (0, import_nodes29.getAllInstructionsWithSubs)(node, {
3191
+ const pdasToExport = nodes.getAllPdas(node);
3192
+ const accountsToExport = nodes.getAllAccounts(node).filter(isNotInternal);
3193
+ const instructionsToExport = nodes.getAllInstructionsWithSubs(node, {
3342
3194
  leavesOnly: !renderScope.renderParentInstructions
3343
3195
  }).filter(isNotInternal);
3344
- const definedTypesToExport = (0, import_nodes29.getAllDefinedTypes)(node).filter(isNotInternal);
3196
+ const definedTypesToExport = nodes.getAllDefinedTypes(node).filter(isNotInternal);
3345
3197
  const hasAnythingToExport = programsToExport.length > 0 || accountsToExport.length > 0 || instructionsToExport.length > 0 || definedTypesToExport.length > 0;
3346
3198
  const scope = {
3347
- ...renderScope,
3348
3199
  accountsToExport,
3349
3200
  definedTypesToExport,
3350
3201
  instructionsToExport,
3351
3202
  pdasToExport,
3352
3203
  programsToExport
3353
3204
  };
3354
- return (0, import_renderers_core14.mergeRenderMaps)([
3355
- (0, import_renderers_core14.createRenderMap)({
3205
+ return renderersCore.mergeRenderMaps([
3206
+ renderersCore.createRenderMap({
3356
3207
  ["accounts/index.ts"]: asPage(getIndexPageFragment(accountsToExport)),
3357
3208
  ["errors/index.ts"]: asPage(getIndexPageFragment(programsWithErrorsToExport)),
3358
3209
  ["index.ts"]: asPage(getRootIndexPageFragment(scope)),
@@ -3362,44 +3213,40 @@ function getRenderMapVisitor(options = {}) {
3362
3213
  ["shared/index.ts"]: hasAnythingToExport ? asPage(getSharedPageFragment()) : void 0,
3363
3214
  ["types/index.ts"]: asPage(getIndexPageFragment(definedTypesToExport))
3364
3215
  }),
3365
- ...(0, import_nodes29.getAllPrograms)(node).map((p) => (0, import_visitors_core29.visit)(p, self))
3216
+ ...nodes.getAllPrograms(node).map((p) => visitorsCore.visit(p, self))
3366
3217
  ]);
3367
3218
  }
3368
3219
  }),
3369
- (v) => (0, import_visitors_core29.recordNodeStackVisitor)(v, stack),
3370
- (v) => (0, import_visitors_core29.recordLinkablesOnFirstVisitVisitor)(v, linkables)
3220
+ (v) => visitorsCore.recordNodeStackVisitor(v, stack),
3221
+ (v) => visitorsCore.recordLinkablesOnFirstVisitVisitor(v, linkables)
3371
3222
  );
3372
3223
  }
3373
-
3374
- // src/visitors/renderVisitor.ts
3375
- var import_renderers_core15 = require("@codama/renderers-core");
3376
- var import_visitors_core30 = require("@codama/visitors-core");
3377
- var estreePlugin = __toESM(require("prettier/plugins/estree"));
3378
- var typeScriptPlugin = __toESM(require("prettier/plugins/typescript"));
3379
- var import_standalone = require("prettier/standalone");
3380
- var DEFAULT_PRETTIER_OPTIONS = {
3381
- arrowParens: "always",
3382
- parser: "typescript",
3383
- plugins: [estreePlugin, typeScriptPlugin],
3384
- printWidth: 80,
3385
- semi: true,
3386
- singleQuote: true,
3387
- tabWidth: 2,
3388
- trailingComma: "es5",
3389
- useTabs: false
3390
- };
3391
3224
  function renderVisitor(path, options = {}) {
3392
- return (0, import_visitors_core30.rootNodeVisitor)(async (root) => {
3225
+ return visitorsCore.rootNodeVisitor(async (root) => {
3393
3226
  if (options.deleteFolderBeforeRendering ?? true) {
3394
- (0, import_renderers_core15.deleteDirectory)(path);
3395
- }
3396
- let renderMap = (0, import_visitors_core30.visit)(root, getRenderMapVisitor(options));
3397
- if (options.formatCode ?? true) {
3398
- const prettierOptions = { ...DEFAULT_PRETTIER_OPTIONS, ...options.prettierOptions };
3399
- renderMap = await (0, import_renderers_core15.mapRenderMapContentAsync)(renderMap, (code) => (0, import_standalone.format)(code, prettierOptions));
3227
+ renderersCore.deleteDirectory(path);
3400
3228
  }
3229
+ let renderMap = visitorsCore.visit(root, getRenderMapVisitor(options));
3230
+ renderMap = await formatCode(renderMap, options);
3401
3231
  syncPackageJson(renderMap, options);
3402
- (0, import_renderers_core15.writeRenderMap)(renderMap, path);
3232
+ renderersCore.writeRenderMap(renderMap, path);
3403
3233
  });
3404
3234
  }
3235
+
3236
+ exports.DEFAULT_NAME_TRANSFORMERS = DEFAULT_NAME_TRANSFORMERS;
3237
+ exports.addToImportMap = addToImportMap;
3238
+ exports.createImportMap = createImportMap;
3239
+ exports.default = renderVisitor;
3240
+ exports.getExternalDependencies = getExternalDependencies;
3241
+ exports.getNameApi = getNameApi;
3242
+ exports.getRenderMapVisitor = getRenderMapVisitor;
3243
+ exports.getTypeManifestVisitor = getTypeManifestVisitor;
3244
+ exports.importMapToString = importMapToString;
3245
+ exports.mergeImportMaps = mergeImportMaps;
3246
+ exports.mergeTypeManifests = mergeTypeManifests;
3247
+ exports.parseImportInput = parseImportInput;
3248
+ exports.removeFromImportMap = removeFromImportMap;
3249
+ exports.renderVisitor = renderVisitor;
3250
+ exports.typeManifest = typeManifest;
3251
+ //# sourceMappingURL=index.browser.cjs.map
3405
3252
  //# sourceMappingURL=index.browser.cjs.map