import { i as PASSTHROUGH_GEMINI_REPLAY_HOOKS } from "../../provider-model-shared-C3XFO8Tx.js";
import { t as definePluginEntry } from "../../plugin-entry-DyZc6JGI.js";
import { t as createProviderApiKeyAuthMethod } from "../../provider-api-key-auth-KHklus-s.js";
import "../../provider-auth-api-key-CD23mLCY.js";
import { n as applyOpencodeGoConfig, t as OPENCODE_GO_DEFAULT_MODEL_REF } from "../../onboard-BduhIStg.js";
import "../../api-DFXGKMzz.js";
import { t as opencodeGoMediaUnderstandingProvider } from "../../media-understanding-provider-zAiGuxPc.js";
import { a as resolveOpencodeGoSupplementalModel, i as normalizeOpencodeGoBaseUrl, r as listOpencodeGoSupplementalModelCatalogEntries } from "../../provider-catalog-B6JEqe8_.js";
import { t as createOpencodeGoDeepSeekV4Wrapper } from "../../stream-BgwHy7My.js";
//#region extensions/opencode-go/index.ts
const PROVIDER_ID = "opencode-go";
const OPENCODE_SHARED_PROFILE_IDS = ["opencode:default", "opencode-go:default"];
const OPENCODE_SHARED_HINT = "Shared API key for Zen + Go catalogs";
const OPENCODE_SHARED_WIZARD_GROUP = {
	groupId: "opencode",
	groupLabel: "OpenCode",
	groupHint: OPENCODE_SHARED_HINT
};
var opencode_go_default = definePluginEntry({
	id: PROVIDER_ID,
	name: "OpenCode Go Provider",
	description: "Bundled OpenCode Go provider plugin",
	register(api) {
		api.registerProvider({
			id: PROVIDER_ID,
			label: "OpenCode Go",
			docsPath: "/providers/models",
			envVars: ["OPENCODE_API_KEY", "OPENCODE_ZEN_API_KEY"],
			auth: [createProviderApiKeyAuthMethod({
				providerId: PROVIDER_ID,
				methodId: "api-key",
				label: "OpenCode Go 目录",
				hint: OPENCODE_SHARED_HINT,
				optionKey: "opencodeGoApiKey",
				flagName: "--opencode-go-api-key",
				envVar: "OPENCODE_API_KEY",
				promptMessage: "Enter OpenCode API key",
				profileIds: [...OPENCODE_SHARED_PROFILE_IDS],
				defaultModel: OPENCODE_GO_DEFAULT_MODEL_REF,
				applyConfig: (cfg) => applyOpencodeGoConfig(cfg),
				expectedProviders: ["opencode", "opencode-go"],
				noteMessage: [
					"OpenCode 使用一个 API 密钥，同时适用于 Zen 和 Go 目录。",
					"Go 专注于 Kimi、GLM、MiniMax 编码模型。",
					"在此获取 API 密钥: https://opencode.ai/auth"
				].join("\n"),
				noteTitle: "OpenCode",
				wizard: {
					choiceId: "opencode-go",
					choiceLabel: "OpenCode Go 目录",
					...OPENCODE_SHARED_WIZARD_GROUP
				}
			})],
			normalizeConfig: ({ providerConfig }) => {
				const normalizedBaseUrl = normalizeOpencodeGoBaseUrl({
					api: providerConfig.api,
					baseUrl: providerConfig.baseUrl
				});
				return normalizedBaseUrl && normalizedBaseUrl !== providerConfig.baseUrl ? {
					...providerConfig,
					baseUrl: normalizedBaseUrl
				} : void 0;
			},
			normalizeResolvedModel: ({ model }) => {
				const normalizedBaseUrl = normalizeOpencodeGoBaseUrl({
					api: model.api,
					baseUrl: model.baseUrl
				});
				return normalizedBaseUrl && normalizedBaseUrl !== model.baseUrl ? {
					...model,
					baseUrl: normalizedBaseUrl
				} : void 0;
			},
			normalizeTransport: ({ api, baseUrl }) => {
				const normalizedBaseUrl = normalizeOpencodeGoBaseUrl({
					api,
					baseUrl
				});
				return normalizedBaseUrl && normalizedBaseUrl !== baseUrl ? {
					api,
					baseUrl: normalizedBaseUrl
				} : void 0;
			},
			resolveDynamicModel: ({ modelId }) => resolveOpencodeGoSupplementalModel(modelId),
			augmentModelCatalog: () => listOpencodeGoSupplementalModelCatalogEntries(),
			...PASSTHROUGH_GEMINI_REPLAY_HOOKS,
			wrapStreamFn: (ctx) => createOpencodeGoDeepSeekV4Wrapper(ctx.streamFn, ctx.thinkingLevel),
			isModernModelRef: () => true
		});
		api.registerMediaUnderstandingProvider(opencodeGoMediaUnderstandingProvider);
	}
});
//#endregion
export { opencode_go_default as default };
