import { isUrl } from "./is-url.js";
//#region src/components/ImportCollection/utils/import-collection.ts
async function importCollection({ store, workspace, source, watchMode, onSuccess, onError }) {
	try {
		if (source && workspace) {
			if (isUrl(source)) {
				const [error, entities] = await store.importSpecFromUrl(source, workspace.uid, {
					proxyUrl: workspace.proxyUrl,
					watchMode
				});
				if (!error) onSuccess(entities?.collection);
				return;
			}
			onSuccess((await store.importSpecFile(source, workspace.uid))?.collection);
		}
	} catch (error) {
		onError(error);
	}
}
//#endregion
export { importCollection };

//# sourceMappingURL=import-collection.js.map