"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }


var _chunkEAAKDSLMcjs = require('./chunk-EAAKDSLM.cjs');



var _chunkBMZNNHFGcjs = require('./chunk-BMZNNHFG.cjs');

// src/generators/json-schema.ts
_chunkBMZNNHFGcjs.init_cjs_shims.call(void 0, );
var _promises = require('fs/promises');
function generateJsonSchemaFile(schema, file, config) {
  try {
    const jsonSchema = _chunkBMZNNHFGcjs.getOutputFile.call(void 0, file, "json");
    _chunkEAAKDSLMcjs.writeTrace.call(void 0, `Writing JSON schema file ${jsonSchema}`, config);
    return _promises.writeFile.call(void 0, jsonSchema, JSON.stringify(schema, null, 2));
  } catch (error) {
    _chunkEAAKDSLMcjs.writeError.call(void 0, 
      `Error writing JSON schema file for ${file.name}

Error:
${_optionalChain([error, 'optionalAccess', _ => _.message]) ? error.message : JSON.stringify(error)}${_optionalChain([error, 'optionalAccess', _2 => _2.stack]) ? `
Stack Trace: ${error.stack}` : ""}

Parsed schema:
${JSON.stringify(schema)}
`,
      config
    );
    throw error;
  }
}



exports.generateJsonSchemaFile = generateJsonSchemaFile;
