"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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 _chunkNJK5F5TFcjs = require('./chunk-NJK5F5TF.cjs');

// src/authorize.ts
var authorize = (client, token) => {
  if (typeof token === "string") {
    client.defaults.headers.common.authorization = `Bearer ${token}`;
  } else {
    client.interceptors.request.use(async (config) => {
      const resolved = await token();
      config.headers.authorization = `Bearer ${resolved}`;
      return config;
    });
  }
  return client;
};

// import("./docs/**/*") in src/help.ts
var globImport_docs = _chunkNJK5F5TFcjs.__glob.call(void 0, {
  "./docs/README.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./README-Z5AKTGJA.cjs"))),
  "./docs/_index.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./_index-O7JDGRSE.cjs"))),
  "./docs/access-token.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./access-token-6BJDZSFE.cjs"))),
  "./docs/address-suggestions.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./address-suggestions-IUQMYF27.cjs"))),
  "./docs/address.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./address-HA4RMRNQ.cjs"))),
  "./docs/ai-agents.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./ai-agents-PWHKNRCX.cjs"))),
  "./docs/app.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./app-PL3IOROO.cjs"))),
  "./docs/audit-logs.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./audit-logs-D2LFUA2R.cjs"))),
  "./docs/automation.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./automation-IOCVCTKR.cjs"))),
  "./docs/billing.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./billing-DUWDISHP.cjs"))),
  "./docs/blueprint-manifest.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./blueprint-manifest-VBOWPK52.cjs"))),
  "./docs/consent.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./consent-CS2ZBZX4.cjs"))),
  "./docs/customer-portal.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./customer-portal-AEFMNNYP.cjs"))),
  "./docs/dashboard.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./dashboard-UHYR5RTY.cjs"))),
  "./docs/data-governance.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./data-governance-2U5UU4GM.cjs"))),
  "./docs/deduplication.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./deduplication-PKKTZAEA.cjs"))),
  "./docs/design.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./design-NISDHPFD.cjs"))),
  "./docs/document.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./document-RYQ7MF6U.cjs"))),
  "./docs/email-settings.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./email-settings-NQJJKS2P.cjs"))),
  "./docs/email-template.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./email-template-M2VVL4TI.cjs"))),
  "./docs/entity-mapping.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./entity-mapping-ZNMFCUKK.cjs"))),
  "./docs/entity.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./entity-TFMH5VTZ.cjs"))),
  "./docs/environments.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./environments-P2JS4F5N.cjs"))),
  "./docs/erp-integration.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./erp-integration-PAVHSUDM.cjs"))),
  "./docs/event-catalog.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./event-catalog-C45ISVMP.cjs"))),
  "./docs/file.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./file-UOWBTDIU.cjs"))),
  "./docs/iban.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./iban-24GHLFDB.cjs"))),
  "./docs/integration-toolkit.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./integration-toolkit-VNMDI55O.cjs"))),
  "./docs/journey.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./journey-REBN4TGQ.cjs"))),
  "./docs/kanban.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./kanban-E2UOBVBK.cjs"))),
  "./docs/message.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./message-J2SFQJNB.cjs"))),
  "./docs/metering.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./metering-DZNZPPY6.cjs"))),
  "./docs/notes.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./notes-MPWOQC5J.cjs"))),
  "./docs/notification.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./notification-PZOCUYD5.cjs"))),
  "./docs/organization.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./organization-RARYYG2E.cjs"))),
  "./docs/partner-directory.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./partner-directory-ZQIBKD5Q.cjs"))),
  "./docs/permissions.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./permissions-ZJHUIBWY.cjs"))),
  "./docs/pricing-tier.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./pricing-tier-NI35WOUP.cjs"))),
  "./docs/pricing.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./pricing-4Z4TOETA.cjs"))),
  "./docs/purpose.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./purpose-AKOEUHZ4.cjs"))),
  "./docs/sandbox.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./sandbox-2KN4X66E.cjs"))),
  "./docs/sharing.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./sharing-MR7ANOST.cjs"))),
  "./docs/submission.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./submission-Q24BU4GS.cjs"))),
  "./docs/targeting.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./targeting-EYGYZD6M.cjs"))),
  "./docs/template-variables.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./template-variables-I72B5WS6.cjs"))),
  "./docs/user.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./user-NJJ7XVKB.cjs"))),
  "./docs/validation-rules.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./validation-rules-VDU3CIZV.cjs"))),
  "./docs/webhooks.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./webhooks-H3RT33BF.cjs"))),
  "./docs/workflow-definition.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./workflow-definition-CVBYKAUY.cjs"))),
  "./docs/workflow.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./workflow-CQOBZ25C.cjs")))
});

// src/help.ts
var kebabCase = (str) => str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
var resolveDoc = async (filename) => {
  try {
    const mod = await globImport_docs(`./docs/${filename}`);
    return _nullishCoalesce(mod.default, () => ( mod));
  } catch (e) {
    return `No documentation found for "${filename}". Run help() to see available APIs.`;
  }
};
var help = async (apiName) => {
  return resolveDoc(apiName ? `${kebabCase(apiName)}.json` : "README.json");
};

// import("./definitions/**/*.json") in src/openapi.ts
var globImport_definitions_json = _chunkNJK5F5TFcjs.__glob.call(void 0, {
  "./definitions/access-token-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./access-token-runtime-NZWZJPWV.cjs"))),
  "./definitions/access-token.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./access-token-RKP2A2F7.cjs"))),
  "./definitions/address-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./address-runtime-2MNO2YRD.cjs"))),
  "./definitions/address-suggestions-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./address-suggestions-runtime-ZNGLDADE.cjs"))),
  "./definitions/address-suggestions.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./address-suggestions-ERVGGO6Z.cjs"))),
  "./definitions/address.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./address-HLBX47SQ.cjs"))),
  "./definitions/ai-agents-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./ai-agents-runtime-TILIO3UM.cjs"))),
  "./definitions/ai-agents.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./ai-agents-6VHVYRCC.cjs"))),
  "./definitions/app-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./app-runtime-SSNHSBR7.cjs"))),
  "./definitions/app.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./app-5VPBDFW2.cjs"))),
  "./definitions/audit-logs-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./audit-logs-runtime-4WMHPWNX.cjs"))),
  "./definitions/audit-logs.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./audit-logs-RFEMBILB.cjs"))),
  "./definitions/automation-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./automation-runtime-DO5QSGJJ.cjs"))),
  "./definitions/automation.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./automation-HZASSUCS.cjs"))),
  "./definitions/billing-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./billing-runtime-L4Y7MLM3.cjs"))),
  "./definitions/billing.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./billing-3VZPNG6M.cjs"))),
  "./definitions/blueprint-manifest-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./blueprint-manifest-runtime-G4UK5VEX.cjs"))),
  "./definitions/blueprint-manifest.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./blueprint-manifest-5TNVSDKC.cjs"))),
  "./definitions/consent-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./consent-runtime-KZ5D4XZU.cjs"))),
  "./definitions/consent.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./consent-6SIH4NQS.cjs"))),
  "./definitions/customer-portal-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./customer-portal-runtime-3LTXCTKD.cjs"))),
  "./definitions/customer-portal.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./customer-portal-MXILX4KH.cjs"))),
  "./definitions/dashboard-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./dashboard-runtime-EXP2AM44.cjs"))),
  "./definitions/dashboard.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./dashboard-RKUQLIME.cjs"))),
  "./definitions/data-governance-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./data-governance-runtime-TDGFG67G.cjs"))),
  "./definitions/data-governance.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./data-governance-ZJ2K4ZWX.cjs"))),
  "./definitions/deduplication-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./deduplication-runtime-5QS6I4S7.cjs"))),
  "./definitions/deduplication.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./deduplication-7RTGTLN5.cjs"))),
  "./definitions/design-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./design-runtime-OXEXKZVG.cjs"))),
  "./definitions/design.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./design-AO6EGLHD.cjs"))),
  "./definitions/document-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./document-runtime-RG3F4R6O.cjs"))),
  "./definitions/document.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./document-OVTR7RVH.cjs"))),
  "./definitions/email-settings-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./email-settings-runtime-WGVLI7N6.cjs"))),
  "./definitions/email-settings.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./email-settings-SEGEKVMF.cjs"))),
  "./definitions/email-template-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./email-template-runtime-UI2FS4H5.cjs"))),
  "./definitions/email-template.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./email-template-26SANLRD.cjs"))),
  "./definitions/entity-mapping-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./entity-mapping-runtime-734TTUA2.cjs"))),
  "./definitions/entity-mapping.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./entity-mapping-PK2XAARN.cjs"))),
  "./definitions/entity-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./entity-runtime-DUJTRYLQ.cjs"))),
  "./definitions/entity.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./entity-UKAWTND4.cjs"))),
  "./definitions/environments-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./environments-runtime-L6TJCVW6.cjs"))),
  "./definitions/environments.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./environments-5IS2ZJYQ.cjs"))),
  "./definitions/erp-integration-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./erp-integration-runtime-Y6VWGQ3L.cjs"))),
  "./definitions/erp-integration.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./erp-integration-W7FZDJOB.cjs"))),
  "./definitions/event-catalog-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./event-catalog-runtime-5HQSAJVX.cjs"))),
  "./definitions/event-catalog.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./event-catalog-MZYFJ23V.cjs"))),
  "./definitions/file-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./file-runtime-SFZIKODF.cjs"))),
  "./definitions/file.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./file-637CTR4Y.cjs"))),
  "./definitions/iban-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./iban-runtime-TUM5LVHO.cjs"))),
  "./definitions/iban.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./iban-ETTCKOHK.cjs"))),
  "./definitions/integration-toolkit-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./integration-toolkit-runtime-5KG3LGXF.cjs"))),
  "./definitions/journey-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./journey-runtime-SPBL3F32.cjs"))),
  "./definitions/journey.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./journey-XIMSLSZC.cjs"))),
  "./definitions/kanban-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./kanban-runtime-NHEUWTCG.cjs"))),
  "./definitions/kanban.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./kanban-M4P7R5TM.cjs"))),
  "./definitions/message-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./message-runtime-CGFCT6FU.cjs"))),
  "./definitions/message.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./message-2VOVRXBB.cjs"))),
  "./definitions/metering-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./metering-runtime-HAIWXZXJ.cjs"))),
  "./definitions/metering.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./metering-KEMILE75.cjs"))),
  "./definitions/notes-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./notes-runtime-E3YYF74V.cjs"))),
  "./definitions/notes.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./notes-OBM5POWI.cjs"))),
  "./definitions/notification-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./notification-runtime-7QLZTPHG.cjs"))),
  "./definitions/notification.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./notification-EEYPLPUV.cjs"))),
  "./definitions/organization-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./organization-runtime-LBCVCZ3W.cjs"))),
  "./definitions/organization.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./organization-2UK7QZLQ.cjs"))),
  "./definitions/partner-directory-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./partner-directory-runtime-AUHVA5Q3.cjs"))),
  "./definitions/partner-directory.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./partner-directory-CG5CYJGB.cjs"))),
  "./definitions/permissions-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./permissions-runtime-O5LH7WOU.cjs"))),
  "./definitions/permissions.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./permissions-WCOABHKQ.cjs"))),
  "./definitions/pricing-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./pricing-runtime-6XNS4EOF.cjs"))),
  "./definitions/pricing-tier-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./pricing-tier-runtime-32BCKJ7Y.cjs"))),
  "./definitions/pricing-tier.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./pricing-tier-FKQPW2ND.cjs"))),
  "./definitions/pricing.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./pricing-VYHPSVKM.cjs"))),
  "./definitions/purpose-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./purpose-runtime-C6IGTUA6.cjs"))),
  "./definitions/purpose.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./purpose-JC2E7W3M.cjs"))),
  "./definitions/sandbox-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./sandbox-runtime-GKEK3GQB.cjs"))),
  "./definitions/sandbox.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./sandbox-CLZTN7IW.cjs"))),
  "./definitions/sharing-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./sharing-runtime-VOFLBIFW.cjs"))),
  "./definitions/sharing.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./sharing-WG4L7LH2.cjs"))),
  "./definitions/submission-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./submission-runtime-5FD4AQSD.cjs"))),
  "./definitions/submission.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./submission-6FD67HIE.cjs"))),
  "./definitions/targeting-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./targeting-runtime-6JFMP262.cjs"))),
  "./definitions/targeting.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./targeting-4CQDSEKL.cjs"))),
  "./definitions/template-variables-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./template-variables-runtime-LFOA32UM.cjs"))),
  "./definitions/template-variables.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./template-variables-JYHE2VCH.cjs"))),
  "./definitions/user-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./user-runtime-7O2HLFVQ.cjs"))),
  "./definitions/user.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./user-DKA6DDPX.cjs"))),
  "./definitions/validation-rules-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./validation-rules-runtime-X7M3QE5I.cjs"))),
  "./definitions/validation-rules.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./validation-rules-AYCAOVDZ.cjs"))),
  "./definitions/webhooks-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./webhooks-runtime-EBM4M3SU.cjs"))),
  "./definitions/webhooks.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./webhooks-L3FXPRKT.cjs"))),
  "./definitions/workflow-definition-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./workflow-definition-runtime-GACBV4WM.cjs"))),
  "./definitions/workflow-definition.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./workflow-definition-7BA4H6W3.cjs"))),
  "./definitions/workflow-runtime.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./workflow-runtime-VKFESVFX.cjs"))),
  "./definitions/workflow.json": () => Promise.resolve().then(() => _interopRequireWildcard(require("./workflow-YJHUCGVK.cjs")))
});

// src/openapi.ts
var kebabCase2 = (str) => str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
var openapi = async (apiName) => {
  const mod = await globImport_definitions_json(`./definitions/${kebabCase2(apiName)}.json`);
  return _nullishCoalesce(mod.default, () => ( mod));
};

// src/compact.ts
var L = { p: "path", q: "query", h: "header", c: "cookie" };
var ep = (p) => {
  const r = { name: p[0], in: L[p[1]] };
  let i = 2;
  if (typeof p[i] === "boolean") {
    if (p[i]) r.required = true;
    i++;
  }
  if (typeof p[i] === "string") {
    r.style = p[i];
    i++;
  }
  if (typeof p[i] === "boolean") {
    r.explode = p[i];
    i++;
  }
  return r;
};
var mp = (ps) => ps.map((p) => p.length === 1 ? { $ref: `#/components/parameters/${p[0]}` } : ep(p));
var expand = (c) => {
  const paths = {};
  for (const [id, m, p, ps, b] of c.o) {
    const op = { operationId: id, responses: {} };
    if (_optionalChain([ps, 'optionalAccess', _2 => _2.length])) op.parameters = mp(ps);
    if (b) op.requestBody = { content: { "application/json": {} } };
    if (!paths[p]) paths[p] = {};
    paths[p][m] = op;
  }
  if (c.pp)
    for (const [p, ps] of Object.entries(c.pp)) {
      if (!paths[p]) paths[p] = {};
      paths[p].parameters = mp(ps);
    }
  const doc = {
    openapi: c.v || "3.0.2",
    info: { title: "", version: "" },
    paths,
    servers: c.s ? [{ url: c.s, ...c.sv ? { variables: c.sv } : {} }] : []
  };
  if (c.cp) {
    const params = {};
    for (const [k, v] of Object.entries(c.cp)) params[k] = ep(v);
    doc.components = { parameters: params };
  }
  return doc;
};

// src/client-factory.ts
var _openapiclientaxios = require('openapi-client-axios'); var _openapiclientaxios2 = _interopRequireDefault(_openapiclientaxios);
var createApiClient = (params) => {
  const { definition, token, headers, apiName } = params;
  const api = new (0, _openapiclientaxios2.default)({ definition, quick: true });
  const client = api.initSync();
  if (headers && Object.keys(headers).length > 0) {
    client.defaults.headers.common = {
      ..._nullishCoalesce(client.defaults.headers.common, () => ( {})),
      ...headers
    };
  }
  if (token) {
    authorize(client, token);
  }
  if (apiName) {
    client.help = () => help(apiName);
    client.openapi = () => openapi(apiName);
  }
  return client;
};

// src/proxy.ts
var createApiHandle = (params) => {
  const { resolveClient, createClient } = params;
  return new Proxy({}, {
    get(_, prop) {
      if (prop === "getClient") {
        return () => resolveClient();
      }
      if (prop === "createClient") {
        return () => createClient();
      }
      if (prop === "then" || prop === "catch" || prop === "finally") {
        return void 0;
      }
      return (...args) => {
        const client = resolveClient();
        const method = client[prop];
        if (typeof method === "function") {
          return method.apply(client, args);
        }
        return method;
      };
    }
  });
};








exports.authorize = authorize; exports.help = help; exports.openapi = openapi; exports.expand = expand; exports.createApiClient = createApiClient; exports.createApiHandle = createApiHandle;
