import {
  init_logger,
  logger_exports
} from "./chunk-FT3I25QV.mjs";
import "./chunk-UCMJJ3IM.mjs";
import {
  __esm,
  __toCommonJS
} from "./chunk-J7LXIPZS.mjs";

// src/policy/default-engine.ts
var DefaultPolicyEngine;
var init_default_engine = __esm({
  "src/policy/default-engine.ts"() {
    "use strict";
    DefaultPolicyEngine = class {
      async initialize(_config) {
      }
      async evaluateCheckExecution(_checkId, _checkConfig) {
        return { allowed: true };
      }
      async evaluateToolInvocation(_serverName, _methodName, _transport) {
        return { allowed: true };
      }
      async evaluateCapabilities(_checkId, _capabilities) {
        return { allowed: true };
      }
      async shutdown() {
      }
    };
  }
});

// src/enterprise/loader.ts
async function loadEnterprisePolicyEngine(config) {
  try {
    const { LicenseValidator } = await import("./validator-XTZJZZJH.mjs");
    const validator = new LicenseValidator();
    const license = await validator.loadAndValidate();
    if (!license || !validator.hasFeature("policy")) {
      return new DefaultPolicyEngine();
    }
    if (validator.isInGracePeriod()) {
      console.warn(
        "[visor:enterprise] License has expired but is within the 72-hour grace period. Please renew your license."
      );
    }
    const { OpaPolicyEngine } = await import("./opa-policy-engine-QCSSIMUF.mjs");
    const engine = new OpaPolicyEngine(config);
    await engine.initialize(config);
    return engine;
  } catch (err) {
    const msg = err instanceof Error ? err.message : String(err);
    try {
      const { logger } = (init_logger(), __toCommonJS(logger_exports));
      logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
    } catch {
    }
    return new DefaultPolicyEngine();
  }
}
async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
  const { LicenseValidator } = await import("./validator-XTZJZZJH.mjs");
  const validator = new LicenseValidator();
  const license = await validator.loadAndValidate();
  if (!license || !validator.hasFeature("scheduler-sql")) {
    throw new Error(
      `The ${driver} schedule storage driver requires a Visor Enterprise license with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`
    );
  }
  if (validator.isInGracePeriod()) {
    console.warn(
      "[visor:enterprise] License has expired but is within the 72-hour grace period. Please renew your license."
    );
  }
  const { KnexStoreBackend } = await import("./knex-store-QCEW4I4R.mjs");
  return new KnexStoreBackend(driver, storageConfig, haConfig);
}
var init_loader = __esm({
  "src/enterprise/loader.ts"() {
    init_default_engine();
  }
});
init_loader();
export {
  loadEnterprisePolicyEngine,
  loadEnterpriseStoreBackend
};
//# sourceMappingURL=loader-ZNKKJEZ3.mjs.map