import e from "axios";
//#region src/plugins/top-bar/actions/import-url.js
var t = "editor_import_url_started", n = "editor_import_url_success", r = "editor_import_url_failure", i = ({ url: e, requestId: n }) => ({
	type: t,
	payload: e,
	meta: { requestId: n }
}), a = ({ definition: e, requestId: t, url: r }) => ({
	type: n,
	payload: e,
	meta: {
		requestId: t,
		url: r
	}
}), o = ({ error: e, url: t, requestId: n }) => ({
	type: r,
	payload: e,
	error: !0,
	meta: {
		url: t,
		errorMessage: e.response ? "The request was made and the server responded with a status code that falls out of the range of 2xx" : e.request ? "The request was made but no response was received" : e.message ? e.message : "Unknown error occurred",
		requestId: n
	}
}), s = (t) => async (n) => {
	let { editorActions: r, fn: i } = n, a = i.generateRequestId(), o = i.sanitizeUrl(t);
	if (r.importUrlStarted({
		url: o,
		requestId: a
	}), o === "about:blank") return r.importUrlFailure({
		error: /* @__PURE__ */ Error("Invalid url provided"),
		url: o,
		requestId: a
	});
	try {
		let t = await e.get(o);
		return r.importUrlSuccess({
			definition: t.request.responseText,
			requestId: a,
			url: o
		});
	} catch (e) {
		return r.importUrlFailure({
			error: e,
			url: o,
			requestId: a
		});
	}
};
//#endregion
export { a, i, s as n, o as r, n as t };

//# sourceMappingURL=import-url-YUIKviqI.js.map