2023-02-17 13:23:30 +00:00
|
|
|
import type { GlobalCal } from "@calcom/embed-core";
|
2022-06-09 05:05:18 +00:00
|
|
|
import EmbedSnippet from "@calcom/embed-snippet";
|
2022-05-18 16:25:30 +00:00
|
|
|
|
2022-04-25 04:33:00 +00:00
|
|
|
import Cal from "./Cal";
|
|
|
|
|
2023-02-17 13:23:30 +00:00
|
|
|
export const getCalApi = (): Promise<GlobalCal> =>
|
2022-05-18 16:25:30 +00:00
|
|
|
new Promise(function tryReadingFromWindow(resolve) {
|
2022-06-09 05:05:18 +00:00
|
|
|
EmbedSnippet();
|
2023-02-17 13:23:30 +00:00
|
|
|
const api = window.Cal;
|
2022-05-18 16:25:30 +00:00
|
|
|
if (!api) {
|
|
|
|
setTimeout(() => {
|
|
|
|
tryReadingFromWindow(resolve);
|
|
|
|
}, 50);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
resolve(api);
|
|
|
|
});
|
|
|
|
|
2022-04-25 04:33:00 +00:00
|
|
|
export default Cal;
|