function readFullInviteConfig(model) {
    if (typeof readBuilderConfig === 'function')
        return readBuilderConfig(model.key) || {};
    try {
        return JSON.parse(localStorage.getItem(model.key) || '{}');
    }
    catch (_) {
        return {};
    }
}
function writeFullInviteConfig(model, config) {
    if (typeof writeBuilderConfig === 'function')
        writeBuilderConfig(model.key, config);
    else
        localStorage.setItem(model.key, JSON.stringify(config));
}
const FULL_INVITE_EDITOR_COPY = {
    sargam: { invitationTitle: 'Sealed with love', invitationHint: 'Guests touch the ruby seal to unfold your family invitation.', eventsHint: 'Choose a living ceremony scene, or use your own still photograph.', scenes: [['mehendi', 'Jasmine garden'], ['sangeet', 'Evening music'], ['vows', 'Pearl mandap']], previewHint: 'pull or tap the keepsake to begin', musicTitle: 'A melody of forever', soundtrack: 'Use Sargam soundtrack', footer: 'Original films · Personal photographs · Guest RSVP' },
    patjhad: { invitationTitle: 'A letter for our forever', invitationHint: 'Your family names gather on autumn leaves before the invitation opens.', eventsHint: 'Choose an autumn celebration scene, or add your own photograph.', scenes: [['garden', 'Autumn garden'], ['evening', 'Amber evening'], ['vows', 'Garden vows']], previewHint: 'brush the leaves aside, then touch the hearts', musicTitle: 'A melody for our autumn', soundtrack: 'Use the sample instrumental', footer: 'Autumn gardens · Personal photographs · Guest RSVP' },
    amethyst: { invitationTitle: 'The next chapter', invitationHint: 'Your family invitation appears inside an opening heart-embossed book.', eventsHint: 'Choose a lilac celebration scene, or add your own photograph.', scenes: [['garden', 'Lilac garden'], ['evening', 'Starlight celebration'], ['vows', 'Garden ceremony']], previewHint: 'touch the doors to enter', musicTitle: 'A melody for our forever', soundtrack: 'Use the sample instrumental', footer: 'A purple fantasy · Personal photographs · Guest RSVP' },
    neelangan: { invitationTitle: 'A keepsake for our forever', invitationHint: 'Your family invitation unfolds among painted gardens on warm parchment.', eventsHint: 'Choose a matching celebration emblem, or add your own photograph.', scenes: [['mehendi', 'Mehendi'], ['haldi', 'Haldi'], ['evening', 'Sangeet'], ['vows', 'The Wedding'], ['reception', 'Reception'], ['vidaai', 'Vidaai']], previewHint: 'touch the invitation to begin', musicTitle: 'A melody for our celebration', soundtrack: 'Use the sample instrumental', footer: 'Parchment & lapis · Personal photographs · Guest RSVP' }
};
function SargamBuilder({ goTo, template, user, openSignIn, projectId }) {
    return React.createElement(FullInvitationBuilder, { key: 'sargam:' + (projectId || 'new'), goTo: goTo, template: template, user: user, openSignIn: openSignIn, projectId: projectId, model: window.SargamModel });
}
function FullInvitationBuilder({ goTo, template, user, openSignIn, projectId, model: M }) {
    const api = typeof useBuilderApi === 'function' ? useBuilderApi() : window.EA;
    const templateId = M.id || 'sargam';
    const templateName = M.name || 'Sargam';
    const copy = FULL_INVITE_EDITOR_COPY[templateId];
    const writeConfig = React.useCallback(config => writeFullInviteConfig(M, config), [M]);
    const [draft, setDraft] = React.useState(() => { const saved = projectId ? {} : readFullInviteConfig(M); return builderNewDraftMusic(M.create(saved), Boolean(projectId || saved && Object.keys(saved).length)); });
    const [tab, setTab] = React.useState('essentials');
    const [activeProjectId, setActiveProjectId] = React.useState(null);
    const [loadedProjectId, setLoadedProjectId] = React.useState(null);
    const [loading, setLoading] = React.useState(Boolean(projectId));
    const [loadError, setLoadError] = React.useState('');
    const [recovery, setRecovery] = React.useState(null);
    const [loadedOwnerId, setLoadedOwnerId] = React.useState(null);
    const [loadVersion, setLoadVersion] = React.useState(0);
    const [previewVersion, setPreviewVersion] = React.useState(1);
    const [isPreviewMode, setIsPreviewMode] = React.useState(false);
    const { enterPreview, returnToEditor } = useBuilderPreviewNavigation(isPreviewMode, setIsPreviewMode);
    const [status, setStatus] = React.useState('Changes save on this device as you edit.');
    const [busy, setBusy] = React.useState('');
    const [musicUploading, setMusicUploading] = React.useState(false);
    const photoUploads = useBuilderPhotoUploads({ templateId, projectId: activeProjectId || projectId, user });
    const mediaUploading = musicUploading || photoUploads.busy;
    const [pendingAction, setPendingAction] = React.useState('');
    const [shareSlug, setShareSlug] = React.useState(null);
    const saveSequence = React.useRef(0);
    const skipAutosave = React.useRef(false);
    const session = React.useRef(templateId + '-' + Date.now().toString(36));
    const config = React.useMemo(() => M.create(draft), [draft]);
    const blocked = loading || Boolean(loadError) || Boolean(recovery) || Boolean(projectId && (loadedOwnerId !== (user?.id || null) || (loadedProjectId !== projectId && activeProjectId !== projectId)));
    const activeTemplate = template || TemplateCatalog.get(templateId);
    const previewSrc = buildBuilderPreviewSrc(resolveWeddingAssetUrl(activeTemplate.builderTemplatePath), templateId, previewVersion, session.current) + (isPreviewMode ? '' : '&skipIntro=1');
    const acceptLoadedProject = React.useCallback((project, source, recovered = false) => {
        const loaded = M.create(source);
        writeConfig(loaded);
        skipAutosave.current = true;
        if (!recovered)
            markBuilderDraftSaved(templateId, project.id, loaded);
        setDraft(loaded);
        setActiveProjectId(project.id);
        setLoadedProjectId(project.id);
        setLoadedOwnerId(user?.id || null);
        setRecovery(null);
        setPreviewVersion(v => v + 1);
        setStatus(recovered ? 'Restored on this device. Save draft to update your account.' : 'Your saved invitation is ready.');
        setLoading(false);
    }, [M, writeConfig, templateId, user?.id]);
    React.useEffect(() => {
        if (!projectId || (projectId === activeProjectId && loadedOwnerId === (user?.id || null)))
            return;
        let cancelled = false;
        setLoading(true);
        setLoadError('');
        setRecovery(null);
        if (!api?.isLoggedIn()) {
            setLoading(false);
            setLoadError('Sign in to load this saved invitation.');
            return;
        }
        api.getProject(projectId).then(({ project }) => {
            if (cancelled)
                return;
            if (!project || project.template_id !== templateId)
                throw new Error('This project does not use ' + templateName + '.');
            const local = readBuilderRecovery(templateId, project);
            if (local) {
                setRecovery({ project, local, ownerId: user?.id || null });
                setLoading(false);
                return;
            }
            acceptLoadedProject(project, project.config);
        }).catch(err => { if (!cancelled) {
            setLoading(false);
            setLoadError(err.message || 'Could not load this invitation.');
        } });
        return () => { cancelled = true; };
    }, [projectId, user?.id, user?.email, loadVersion, templateId, M, writeConfig, acceptLoadedProject]);
    React.useEffect(() => {
        if (blocked || mediaUploading)
            return;
        if (skipAutosave.current) {
            skipAutosave.current = false;
            return;
        }
        const sequence = ++saveSequence.current;
        let cancelled = false;
        try {
            writeConfig(config);
            markBuilderDraftPending(templateId, activeProjectId);
            setStatus('Saved on this device.');
        }
        catch (err) {
            setStatus('Could not save: ' + err.message + '. Try saving again.');
            return;
        }
        const timer = setTimeout(async () => {
            try {
                setPreviewVersion(v => v + 1);
                if (!photoUploads.pending() && activeProjectId && api?.isLoggedIn() && window.EA_UI_PREVIEW !== true) {
                    if (typeof validateBuilderMedia === 'function')
                        validateBuilderMedia(config);
                    await api.saveProject(activeProjectId, config, builderProjectName(config, templateId));
                    markBuilderDraftSaved(templateId, activeProjectId, config);
                    if (!cancelled && sequence === saveSequence.current)
                        setStatus(api.isAdminEditor ? 'Saved for the customer.' : 'Saved to your dashboard.');
                }
            }
            catch (err) {
                if (!cancelled && sequence === saveSequence.current)
                    setStatus('Could not save: ' + err.message + '. Try saving again.');
            }
        }, 900);
        return () => { cancelled = true; clearTimeout(timer); };
    }, [config, activeProjectId, blocked, mediaUploading, templateId, writeConfig, user?.id, user?.email]);
    const update = (path, value) => setDraft(current => setDeepDraft(current, path, value));
    const field = (group, key, label, extra = {}) => React.createElement(BuildField, { key: key, label: label, value: draft[group][key], onChange: v => update([group, key], v), ...extra });
    const toggle = (group, label) => React.createElement(BuildToggle, { label: label, checked: draft[group].show, onChange: v => update([group, 'show'], v) });
    const rows = (group, items, fields) => items.map((item, index) => (React.createElement("div", { className: "builder-repeat", key: item.id || index },
        React.createElement("div", { className: "builder-repeat-head" },
            React.createElement("strong", null, item.name || item.label || `Item ${index + 1}`),
            React.createElement("button", { type: "button", onClick: () => update(group, items.filter((_, i) => i !== index)) }, "Remove")),
        fields.map(([key, label, type]) => React.createElement(BuildField, { key: key, label: label, type: type === 'date' ? 'date' : 'text', multi: type === 'multi', value: item[key], onChange: v => update([...group, index, key], v) })),
        group[0] === 'events' && React.createElement(React.Fragment, null,
            React.createElement(BuildSelect, { label: "Ceremony artwork", value: templateId === 'neelangan' && item.scene === 'garden' ? 'mehendi' : item.scene || 'vows', options: copy.scenes, onChange: v => update(['events', index, 'scene'], v) }),
            React.createElement(BuildPhotoField, { uploadScope: photoUploads, label: "Custom event photograph (optional)", value: item.image || '', onChange: v => update(['events', index, 'image'], v) })))));
    const act = React.useCallback(async (action) => {
        if (blocked || busy || mediaUploading || photoUploads.pending())
            return;
        if (window.EA_UI_PREVIEW === true) {
            if (action === 'publish') {
                setStatus('Publishing is unavailable in this UI preview.');
                return;
            }
            try {
                writeConfig(config);
                setPreviewVersion(v => v + 1);
                setStatus('Draft saved on this device for this UI preview.');
            }
            catch (err) {
                setStatus('Could not save on this device: ' + err.message);
            }
            return;
        }
        if (!api?.isLoggedIn()) {
            setPendingAction(action);
            setStatus('Sign in to save this invitation to your dashboard.');
            openSignIn?.('builder');
            return;
        }
        setBusy(action);
        try {
            const args = { api, templateId, config, writeConfig, projectId: activeProjectId, setProjectId: setActiveProjectId };
            const result = action === 'publish' ? await runPublish(args) : await runSaveDraft(args);
            if (!result.ok)
                throw new Error(result.reason || 'Save failed');
            if (result.projectId) {
                setLoadedProjectId(result.projectId);
                setLoadedOwnerId(user?.id || null);
            }
            if (result.slug)
                setShareSlug(result.slug);
            setStatus(action === 'publish' ? 'Your invitation is published.' : (api.isAdminEditor ? 'Draft saved for the customer.' : 'Draft saved to your dashboard.'));
        }
        catch (err) {
            setStatus('Could not ' + action + ': ' + err.message);
        }
        finally {
            setBusy('');
        }
    }, [config, activeProjectId, blocked, busy, mediaUploading, openSignIn, templateId, writeConfig, user?.id]);
    React.useEffect(() => { if (pendingAction && api?.isLoggedIn() && !blocked) {
        const action = pendingAction;
        setPendingAction('');
        act(action);
    } }, [pendingAction, user, blocked, act]);
    const preview = (event) => { try {
        writeConfig(config);
        setPreviewVersion(v => v + 1);
        enterPreview(event);
    }
    catch (err) {
        setStatus('Preview could not save: ' + err.message);
    } };
    const reset = () => { if (photoUploads.pending())
        return; if (!window.confirm('Reset your ' + templateName + ' invitation to its sample details? Your current changes will be replaced.' + (activeProjectId ? ' Your saved invitation will also update.' : '')))
        return; setDraft(builderNewDraftMusic(M.create(), false)); setTab('essentials'); };
    const tabs = [['sections', 'Sections'], ['essentials', 'The couple'], ['invitation', 'Invitation'], ['events', 'Events'], ['story', 'Our story'], ['gallery', 'Photographs'], ['travel', 'Guest details'], ['rsvp', 'RSVP & closing'], ['music', 'Music']];
    return (React.createElement("div", { className: "saas-template-builder" },
        shareSlug && React.createElement(ShareModal, { slug: shareSlug, onClose: () => setShareSlug(null) }),
        React.createElement("aside", { className: "saas-builder-side" },
            React.createElement("div", { className: "saas-template-switch" },
                React.createElement("div", null,
                    React.createElement("span", null, "Editing your invitation"),
                    React.createElement("strong", null, templateName)),
                React.createElement("button", { type: "button", onClick: () => goTo('builder', { projectId: null }), disabled: Boolean(busy) }, api.isAdminEditor ? 'Administration' : 'Change design')),
            React.createElement("label", { className: "builder-section-picker" },
                React.createElement("span", null, "Editing section"),
                React.createElement("select", { disabled: photoUploads.busy, value: tab, onChange: e => setTab(e.target.value) }, tabs.map(([id, label]) => React.createElement("option", { key: id, value: id }, label)))),
            React.createElement("nav", { className: "saas-builder-tabs", "aria-label": "Builder sections" }, tabs.map(([id, label]) => React.createElement("button", { key: id, disabled: photoUploads.busy, "aria-current": tab === id ? 'step' : undefined, className: tab === id ? 'active' : '', onClick: () => setTab(id) }, label))),
            React.createElement("div", { className: "saas-builder-form" },
                loading && React.createElement("p", { role: "status" }, "Loading your saved invitation\u2026"),
                recovery?.ownerId === (user?.id || null) && React.createElement(BuilderRecoveryNotice, { onRestore: () => acceptLoadedProject(recovery.project, recovery.local, true), onUseSaved: () => acceptLoadedProject(recovery.project, recovery.project.config) }),
                loadError && React.createElement("div", { role: "alert" },
                    React.createElement("p", null, loadError),
                    React.createElement("button", { type: "button", onClick: () => api?.isLoggedIn() ? setLoadVersion(v => v + 1) : openSignIn?.('builder') }, api?.isLoggedIn() ? 'Try again' : 'Sign in')),
                React.createElement("fieldset", { disabled: blocked || mediaUploading || Boolean(busy), style: { border: 0, padding: 0, margin: 0, minWidth: 0 } },
                    React.createElement(TemplateSectionsPanel, { sections: window.EverafterLegacyOptions.definitions(templateId, draft), value: draft.sections, onChange: sections => setDraft(current => window.EverafterLegacyOptions.prepare({ ...current, sections }, templateId)) }),
                    tab === 'essentials' && React.createElement(BuilderPanel, { title: "The couple", hint: "Your names and wedding details appear throughout the invitation." },
                        field('couple', 'bride', "Bride's name"),
                        field('couple', 'groom', "Groom's name"),
                        field('couple', 'date', 'Wedding date', { type: 'date' }),
                        field('couple', 'venue', 'Wedding venue'),
                        field('couple', 'hashtag', 'Wedding hashtag'),
                        field('couple', 'whatsapp', 'Family WhatsApp number', { placeholder: '+91 98765 43210' }),
                        field('gate', 'hint', 'Keepsake hint')),
                    tab === 'invitation' && React.createElement(BuilderPanel, { title: copy.invitationTitle, hint: copy.invitationHint },
                        toggle('invite', 'Show formal invitation'),
                        field('invite', 'blessing', 'Opening blessing', { multi: true }),
                        field('invite', 'brideFather', "Bride's father"),
                        field('invite', 'brideMother', "Bride's mother"),
                        field('invite', 'groomFather', "Groom's father"),
                        field('invite', 'groomMother', "Groom's mother"),
                        templateId === 'patjhad' && React.createElement(React.Fragment, null,
                            React.createElement(BuildField, { label: "More family names", multi: true, rows: 5, value: (draft.invite.familyMembers || []).filter(name => typeof name === 'string').join('\n'), onChange: value => update(['invite', 'familyMembers'], value === '' ? [] : value.split(/\r?\n/)), placeholder: "One family name per line" }),
                            React.createElement("p", { style: { margin: 0, fontSize: 13, lineHeight: 1.55, color: '#6e5d4c' } }, "The parents named above appear automatically. Add other family members here, one name per line. Each name appears on its own leaf during the opening."))),
                    tab === 'events' && React.createElement(BuilderPanel, { title: "Your celebrations", hint: copy.eventsHint },
                        rows(['events'], draft.events, [['name', 'Event name'], ['date', 'Date', 'date'], ['time', 'Time'], ['venue', 'Venue'], ['desc', 'Description', 'multi'], ['dress', 'Dress notes'], ['mapsLink', 'Map link']]),
                        React.createElement("button", { className: "builder-add-btn", onClick: () => update(['events'], [...draft.events, { id: 'event-' + Date.now(), name: 'New celebration', date: draft.couple.date, time: '', venue: '', desc: '', dress: '', scene: 'vows', mapsLink: '' }]) }, "Add celebration")),
                    tab === 'story' && React.createElement(BuilderPanel, { title: "Our story", hint: "Tell your story in your own words and add a portrait if you like." },
                        toggle('story', 'Show your story'),
                        field('story', 'title', 'Story heading'),
                        field('story', 'text', 'Your story', { multi: true, rows: 8 }),
                        React.createElement(BuildPhotoField, { uploadScope: photoUploads, label: "Your portrait", value: draft.story.photo, onChange: v => update(['story', 'photo'], v) }),
                        React.createElement(BuildField, { label: "Little memories (comma separated)", value: draft.story.tags.join(', '), onChange: v => update(['story', 'tags'], v.split(',').map(x => x.trim()).filter(Boolean)) })),
                    tab === 'gallery' && React.createElement(BuilderPanel, { title: "Photographs", hint: "Add up to 20 photographs. Open a photograph below to upload, add a caption or remove it." },
                        toggle('gallery', 'Show photographs'),
                        draft.gallery.photos.map((photo, index) => {
                            const objectPhoto = photo !== null && typeof photo === 'object' && !Array.isArray(photo);
                            return React.createElement(BuilderPhotoDisclosure, { key: index, label: `Photograph ${index + 1}`, value: typeof photo === 'string' ? photo : photo?.src || '', caption: objectPhoto ? photo.caption : '' },
                                React.createElement(BuildPhotoField, { uploadScope: photoUploads, label: `Photograph ${index + 1}`, value: typeof photo === 'string' ? photo : typeof photo?.src === 'string' ? photo.src : '', onChange: v => {
                                        const next = objectPhoto ? { ...photo, src: v } : v;
                                        if (objectPhoto)
                                            delete next.alt;
                                        update(['gallery', 'photos', index], next);
                                    } }),
                                React.createElement(BuildField, { label: `Photograph ${index + 1} caption`, value: objectPhoto ? photo.caption || '' : '', onChange: caption => update(['gallery', 'photos', index], { ...(objectPhoto ? photo : { src: photo }), caption }) }),
                                React.createElement("button", { type: "button", onClick: () => { if (!photoUploads.pending())
                                        update(['gallery', 'photos'], draft.gallery.photos.filter((_, i) => i !== index)); } }, "Remove photograph"));
                        }),
                        draft.gallery.photos.length < 20 && React.createElement("button", { className: "builder-add-btn", onClick: () => { if (!photoUploads.pending())
                                update(['gallery', 'photos'], [...draft.gallery.photos, '']); } }, "Add photograph")),
                    tab === 'travel' && React.createElement(BuilderPanel, { title: "Guest details", hint: "Help your guests plan their visit. Add practical details for your actual venue." },
                        toggle('travel', 'Show guest details'),
                        field('travel', 'title', 'Heading'),
                        field('travel', 'intro', 'Welcome note', { multi: true }),
                        field('travel', 'address', 'Full venue address'),
                        field('travel', 'mapsLink', 'Google Maps link'),
                        rows(['travel', 'items'], draft.travel.items, [['label', 'Detail heading'], ['value', 'Details', 'multi']]),
                        React.createElement("button", { className: "builder-add-btn", onClick: () => update(['travel', 'items'], [...draft.travel.items, { label: 'Guest information', value: '' }]) }, "Add guest detail")),
                    tab === 'rsvp' && React.createElement(BuilderPanel, { title: "Your guest replies", hint: "The built-in form sends replies to your dashboard when the invitation is published." },
                        toggle('rsvp', 'Show RSVP'),
                        React.createElement(BuildSelect, { label: "Reply method", value: draft.rsvp.mode, options: [["native", "Built-in guest RSVP"], ["whatsapp", "WhatsApp"], ["form", "External form"]], onChange: v => update(['rsvp', 'mode'], v) }),
                        field('rsvp', 'heading', 'Heading'),
                        field('rsvp', 'subtext', 'Message', { multi: true }),
                        field('rsvp', 'btnText', 'Button label'),
                        draft.rsvp.mode === 'whatsapp' && field('rsvp', 'whatsapp', 'WhatsApp number with country code'),
                        draft.rsvp.mode === 'form' && field('rsvp', 'form_url', 'RSVP form URL', { type: 'url' }),
                        toggle('closing', 'Show closing message'),
                        field('closing', 'line', 'Closing message', { multi: true })),
                    React.createElement("div", { hidden: tab !== 'music' },
                        React.createElement(BuilderPanel, { title: "Music" },
                            React.createElement(MusicUploadPanel, { value: draft.music, nativeMusic: M.defaults.music, templateId: templateId, projectId: activeProjectId || projectId, scopeKey: projectId || 'new', user: user, disabled: blocked || Boolean(busy) || mediaUploading, onChange: value => update(['music'], value), onBusyChange: setMusicUploading, openSignIn: openSignIn, active: tab === 'music' }))))),
            React.createElement(BuilderProgressActions, { tabs: tabs, tab: tab, onTabChange: setTab, onPreview: preview, disabled: blocked || mediaUploading || Boolean(busy) })),
        React.createElement("main", { className: "saas-builder-preview" },
            React.createElement("div", { className: "saas-builder-topbar" },
                React.createElement("div", { className: "builder-save-status" },
                    React.createElement("span", { className: "builder-status-dot" }),
                    React.createElement("span", null,
                        React.createElement("strong", null, activeProjectId ? templateName + ' invitation' : 'New ' + templateName + ' design'),
                        React.createElement("small", { role: "status" }, status))),
                window.EA_UI_PREVIEW === true && React.createElement(BuilderPreviewNotice, { compact: true }),
                React.createElement("div", { className: "saas-builder-actions" },
                    React.createElement("button", { className: "desktop-reset-action", onClick: reset, disabled: blocked || mediaUploading || Boolean(busy) }, "Reset"),
                    React.createElement("button", { onClick: () => act('save'), disabled: blocked || mediaUploading || Boolean(busy) },
                        React.createElement(BuilderActionLabel, { full: busy === 'save' ? 'Saving…' : 'Save draft', compact: busy === 'save' ? 'Saving…' : 'Save' })),
                    React.createElement("button", { className: "primary", onClick: preview, disabled: blocked || mediaUploading || Boolean(busy) },
                        React.createElement(BuilderActionLabel, { full: "Preview so far", compact: "Preview so far" })),
                    React.createElement("button", { className: "publish", onClick: () => act('publish'), disabled: blocked || mediaUploading || Boolean(busy) || window.EA_UI_PREVIEW === true, title: window.EA_UI_PREVIEW === true ? "Publishing is unavailable in this UI preview." : undefined },
                        React.createElement(BuilderActionLabel, { full: busy === 'publish' ? 'Publishing…' : 'Publish invitation', compact: busy === 'publish' ? 'Publishing…' : 'Publish' })))),
            React.createElement("div", { className: "saas-preview-label" }, "Live preview"),
            React.createElement("div", { className: "saas-preview-workspace" }, !blocked && !isPreviewMode && React.createElement(BuilderPhonePreview, { activeTemplate: activeTemplate, fallbackName: templateName, previewSrc: previewSrc })),
            React.createElement("div", { className: "saas-publish-bar" },
                React.createElement("div", { className: "saas-publish-template" },
                    React.createElement("div", null,
                        React.createElement("strong", null, templateName),
                        React.createElement("span", null, copy.footer))),
                React.createElement("button", { className: "saas-publish-btn", onClick: () => act('publish'), disabled: blocked || mediaUploading || Boolean(busy) || window.EA_UI_PREVIEW === true, title: window.EA_UI_PREVIEW === true ? "Publishing is unavailable in this UI preview." : undefined }, "Publish invitation"))),
        React.createElement(BuilderPreviewWindow, { open: isPreviewMode && !blocked, onClose: returnToEditor, activeTemplate: activeTemplate, fallbackName: templateName, previewSrc: previewSrc })));
}
