import { environment } from '../environments/environment'; import { hostedMountContext, isHostedMount } from './hostedMount'; // - 'public' IS GONE FROM THIS UNION ON PURPOSE. It named the anonymous public-form mount // that rendered the form inside the practice's own document. The form is a cross-origin frame now, no PHP // emits `data-akashic-mount="public"` any more, and leaving the value in the type kept a branch alive that // any page carrying the legacy markup could still reach. // Do not re-add it to "be safe": an unreachable value here is what let the deleted surface keep working. export type MountContext = 'admin' | 'frontend' | 'staff'; // WordPress states the context and keeps deciding it. The hosted target has no WordPress payload, so // the path answers instead - and the fallback below stays for a WordPress mount whose payload is // present but says nothing, which is not the same case. export const getMountContext = (): MountContext => (environment.wpData?.context as MountContext) ?? (isHostedMount() ? hostedMountContext() : 'frontend'); // Audience = the STAFF dashboard experience: wp-admin OR the new staff front-end portal. export const isStaffExperience = (): boolean => { const c = getMountContext(); return c === 'admin' || c === 'staff'; }; // Audience = the PATIENT portal experience. export const isPatientExperience = (): boolean => getMountContext() === 'frontend'; // Mount = the WordPress admin dashboard specifically (org-setup wizard, admin-ajax capability). export const isWpAdminMount = (): boolean => getMountContext() === 'admin';