@buildbase/sdk 0.0.67 → 0.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var e=require("./chunks/react-DP8VKZUU.cjs");require("react/jsx-runtime"),require("react"),require("clsx"),require("tailwind-merge"),require("intl-messageformat"),require("@hookform/resolvers/zod"),require("react-hook-form"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("lucide-react"),require("@radix-ui/react-label"),require("zod"),require("@radix-ui/react-avatar"),require("@radix-ui/react-dialog"),require("@radix-ui/react-icons"),require("@radix-ui/react-radio-group"),require("@radix-ui/react-scroll-area"),require("@radix-ui/react-separator"),require("@radix-ui/react-accordion"),require("@radix-ui/react-alert-dialog"),Object.defineProperty(exports,"ApiVersion",{enumerable:!0,get:function(){return e.ApiVersion}}),exports.AuthApi=e.AuthApi,Object.defineProperty(exports,"AuthStatus",{enumerable:!0,get:function(){return e.AuthStatus}}),exports.BBAction=e.BBAction,exports.BBScreen=e.BBScreen,exports.BBStatus=e.BBStatus,exports.BB_PARAM=e.BB_PARAM,exports.BaseApi=e.BaseApi,exports.BetaForm=e.BetaForm,exports.BillingIntervals=e.BillingIntervals,exports.BuildBaseBadge=e.BuildBaseBadge,exports.BuildBaseProvider=e.SaaSOSProvider,exports.CURRENCY_DISPLAY=e.CURRENCY_DISPLAY,exports.CURRENCY_FLAG=e.CURRENCY_FLAG,exports.ConnectMcpGuide=e.ConnectMcpGuide,exports.ConnectedAgents=e.ConnectedAgents,exports.ConnectedAgentsApi=e.ConnectedAgentsApi,exports.CreditActionsProvider=e.CreditActionsProvider,exports.CreditBalance=e.CreditBalance,exports.CreditBalanceContextProvider=e.CreditBalanceContextProvider,exports.CreditBucketSource=e.CreditBucketSource,exports.CreditBucketStatus=e.CreditBucketStatus,exports.CreditStorePage=e.CreditStorePage,exports.CreditTransactionType=e.CreditTransactionType,exports.DEFAULT_ROLE_PERMISSIONS=e.DEFAULT_ROLE_PERMISSIONS,exports.Devices=e.Devices,exports.DevicesApi=e.DevicesApi,exports.DunningState=e.DunningState,exports.EmptyState=e.EmptyState,exports.EventEmitter=e.EventEmitter,exports.FullScreenLoader=e.FullScreenLoader,exports.InvoiceStatuses=e.InvoiceStatuses,exports.LoadingState=e.LoadingState,exports.PLAN_CURRENCY_CODES=e.PLAN_CURRENCY_CODES,exports.PLAN_CURRENCY_OPTIONS=e.PLAN_CURRENCY_OPTIONS,exports.PUSH_SERVICE_WORKER_SCRIPT=e.PUSH_SERVICE_WORKER_SCRIPT,exports.Permission=e.Permission,exports.PricingPage=e.PricingPage,exports.PushApi=e.PushApi,exports.PushNotificationProvider=e.PushNotificationProvider,exports.QuotaUsageContextProvider=e.QuotaUsageContextProvider,exports.SDKEvent=e.SDKEvent,exports.SETTINGS_SCREENS=e.SETTINGS_SCREENS,exports.SUPPORTED_LOCALES=e.SUPPORTED_LOCALES,exports.SaaSOSProvider=e.SaaSOSProvider,exports.SectionHeader=e.SectionHeader,exports.Sessions=e.Sessions,exports.SessionsApi=e.SessionsApi,exports.SettingsApi=e.SettingsApi,exports.SettingsScreen=e.SettingsScreen,exports.SidebarNavItem=e.SidebarNavItem,exports.SidebarNavSection=e.SidebarNavSection,exports.StatusBanner=e.StatusBanner,exports.SubscriptionContextProvider=e.SubscriptionContextProvider,exports.SubscriptionItemType=e.SubscriptionItemType,exports.SubscriptionStatus=e.SubscriptionStatus,exports.UserApi=e.UserApi,exports.WhenAuthenticated=e.WhenAuthenticated,exports.WhenCreditsAvailable=e.WhenCreditsAvailable,exports.WhenCreditsExhausted=e.WhenCreditsExhausted,exports.WhenCreditsLow=e.WhenCreditsLow,exports.WhenNoSubscription=e.WhenNoSubscription,exports.WhenNotTrialing=e.WhenNotTrialing,exports.WhenPermission=e.WhenPermission,exports.WhenQuotaAvailable=e.WhenQuotaAvailable,exports.WhenQuotaExhausted=e.WhenQuotaExhausted,exports.WhenQuotaOverage=e.WhenQuotaOverage,exports.WhenQuotaThreshold=e.WhenQuotaThreshold,exports.WhenRoles=e.WhenRoles,exports.WhenSubscription=e.WhenSubscription,exports.WhenSubscriptionToPlans=e.WhenSubscriptionToPlans,exports.WhenTrialEnding=e.WhenTrialEnding,exports.WhenTrialing=e.WhenTrialing,exports.WhenUnauthenticated=e.WhenUnauthenticated,exports.WhenUserFeatureDisabled=e.WhenUserFeatureDisabled,exports.WhenUserFeatureEnabled=e.WhenUserFeatureEnabled,exports.WhenWorkspaceFeatureDisabled=e.WhenWorkspaceFeatureDisabled,exports.WhenWorkspaceFeatureEnabled=e.WhenWorkspaceFeatureEnabled,exports.WhenWorkspaceRoles=e.WhenWorkspaceRoles,exports.WorkspaceApi=e.WorkspaceApi,exports.WorkspaceSwitcher=e.WorkspaceSwitcher,exports.calculateBillableSeats=e.calculateBillableSeats,exports.calculateSeatOverageCents=e.calculateSeatOverageCents,exports.calculateTotalSubscriptionCents=e.calculateTotalSubscriptionCents,exports.cleanBBParams=e.cleanBBParams,exports.clearAuthIntent=e.clearAuthIntent,exports.coerceBadgeRef=e.coerceBadgeRef,exports.consumeAuthIntent=e.consumeAuthIntent,exports.createBBUrl=e.createBBUrl,exports.createCheckoutRedirectUrls=e.createCheckoutRedirectUrls,exports.createCreditPurchaseRedirectUrls=e.createCreditPurchaseRedirectUrls,exports.eventEmitter=e.eventEmitter,exports.fillMcpTemplate=e.fillMcpTemplate,exports.formatCents=e.formatCents,exports.formatMinorAmountIntl=e.formatMinorAmountIntl,exports.formatOverageRate=e.formatOverageRate,exports.formatOverageRateWithLabel=e.formatOverageRateWithLabel,exports.formatQuotaIncludedOverage=e.formatQuotaIncludedOverage,exports.formatQuotaWithPrice=e.formatQuotaWithPrice,exports.getAvailableCurrenciesFromPlans=e.getAvailableCurrenciesFromPlans,exports.getBasePriceCents=e.getBasePriceCents,exports.getBillingIntervalAndCurrencyFromPriceId=e.getBillingIntervalAndCurrencyFromPriceId,exports.getCurrencyDecimals=e.getCurrencyDecimals,exports.getCurrencyFlag=e.getCurrencyFlag,exports.getCurrencySymbol=e.getCurrencySymbol,exports.getDisplayCurrency=e.getDisplayCurrency,exports.getPerSeatPriceCents=e.getPerSeatPriceCents,exports.getPricingVariant=e.getPricingVariant,exports.getQuotaDisplayValue=e.getQuotaDisplayValue,exports.getQuotaDisplayWithVariant=e.getQuotaDisplayWithVariant,exports.getQuotaOverageCents=e.getQuotaOverageCents,exports.getQuotaUnitLabelFromName=e.getQuotaUnitLabelFromName,exports.getSeatPricing=e.getSeatPricing,exports.getStripePriceIdForInterval=e.getStripePriceIdForInterval,exports.hasPermission=e.hasPermission,exports.invalidateCreditBalance=e.invalidateCreditBalance,exports.invalidateQuotaUsage=e.invalidateQuotaUsage,exports.invalidateSubscription=e.invalidateSubscription,exports.isZeroDecimalCurrency=e.isZeroDecimalCurrency,exports.mcpServerKey=e.mcpServerKey,exports.mergeUIConfig=e.mergeUIConfig,exports.minorAmountToDisplay=e.minorAmountToDisplay,exports.readBBParams=e.readBBParams,exports.resolveMaxUsers=e.resolveMaxUsers,exports.resolvePermissions=e.resolvePermissions,exports.safeRedirect=e.safeRedirect,exports.saveAuthIntent=e.saveAuthIntent,exports.useAllQuotaUsage=e.useAllQuotaUsage,exports.useBillingPortal=e.useBillingPortal,exports.useCancelSubscription=e.useCancelSubscription,exports.useConnectedAgents=e.useConnectedAgents,exports.useConnectedAgentsApi=e.useConnectedAgentsApi,exports.useConsumeCredits=e.useConsumeCredits,exports.useCreateCheckoutSession=e.useCreateCheckoutSession,exports.useCreditBalance=e.useCreditBalance,exports.useCreditBalanceContext=e.useCreditBalanceContext,exports.useCreditPackages=e.useCreditPackages,exports.useCreditTransactions=e.useCreditTransactions,exports.useDevices=e.useDevices,exports.useDevicesApi=e.useDevicesApi,exports.useExpiringCredits=e.useExpiringCredits,exports.useFullScreenLoader=e.useFullScreenLoader,exports.useInvoice=e.useInvoice,exports.useInvoices=e.useInvoices,exports.useMcpConnection=e.useMcpConnection,exports.usePermissions=e.usePermissions,exports.usePlanGroup=e.usePlanGroup,exports.usePlanGroupVersions=e.usePlanGroupVersions,exports.usePublicCreditPackages=e.usePublicCreditPackages,exports.usePublicPlanGroupVersion=e.usePublicPlanGroupVersion,exports.usePublicPlans=e.usePublicPlans,exports.usePurchaseCredits=e.usePurchaseCredits,exports.usePushNotifications=e.usePushNotifications,exports.useQuotaUsageContext=e.useQuotaUsageContext,exports.useQuotaUsageStatus=e.useQuotaUsageStatus,exports.useRecordUsage=e.useRecordUsage,exports.useResumeSubscription=e.useResumeSubscription,exports.useSaaSAuth=e.useSaaSAuth,exports.useSaaSOs=e.useSaaSOs,exports.useSaaSSettings=e.useSaaSSettings,exports.useSaaSWorkspaces=e.useSaaSWorkspaces,exports.useSeatStatus=e.useSeatStatus,exports.useSessions=e.useSessions,exports.useSessionsApi=e.useSessionsApi,exports.useSubscription=e.useSubscription,exports.useSubscriptionContext=e.useSubscriptionContext,exports.useSubscriptionManagement=e.useSubscriptionManagement,exports.useTranslation=e.useTranslation,exports.useTrialStatus=e.useTrialStatus,exports.useUIConfig=e.useUIConfig,exports.useUIVisibility=e.useUIVisibility,exports.useUpdateSubscription=e.useUpdateSubscription,exports.useUsageLogs=e.useUsageLogs,exports.useUserAttributes=e.useUserAttributes,exports.useUserFeatures=e.useUserFeatures,exports.validateInvite=e.validateInvite,exports.validateRedirectUrl=e.validateRedirectUrl,exports.workspaceSettingsManager=e.workspaceSettingsManager;
2
+ "use strict";var e=require("./chunks/react-DSRfaDnZ.cjs");require("react/jsx-runtime"),require("react"),require("clsx"),require("tailwind-merge"),require("intl-messageformat"),require("@hookform/resolvers/zod"),require("react-hook-form"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("lucide-react"),require("@radix-ui/react-label"),require("zod"),require("@radix-ui/react-avatar"),require("@radix-ui/react-dialog"),require("@radix-ui/react-icons"),require("@radix-ui/react-radio-group"),require("@radix-ui/react-scroll-area"),require("@radix-ui/react-separator"),require("@radix-ui/react-accordion"),require("@radix-ui/react-alert-dialog"),Object.defineProperty(exports,"ApiVersion",{enumerable:!0,get:function(){return e.ApiVersion}}),exports.AuthApi=e.AuthApi,Object.defineProperty(exports,"AuthStatus",{enumerable:!0,get:function(){return e.AuthStatus}}),exports.BBAction=e.BBAction,exports.BBScreen=e.BBScreen,exports.BBStatus=e.BBStatus,exports.BB_PARAM=e.BB_PARAM,exports.BaseApi=e.BaseApi,exports.BetaForm=e.BetaForm,exports.BillingIntervals=e.BillingIntervals,exports.BuildBaseBadge=e.BuildBaseBadge,exports.BuildBaseProvider=e.SaaSOSProvider,exports.CURRENCY_DISPLAY=e.CURRENCY_DISPLAY,exports.CURRENCY_FLAG=e.CURRENCY_FLAG,exports.ConnectMcpGuide=e.ConnectMcpGuide,exports.ConnectedAgents=e.ConnectedAgents,exports.ConnectedAgentsApi=e.ConnectedAgentsApi,exports.CreditActionsProvider=e.CreditActionsProvider,exports.CreditBalance=e.CreditBalance,exports.CreditBalanceContextProvider=e.CreditBalanceContextProvider,exports.CreditBucketSource=e.CreditBucketSource,exports.CreditBucketStatus=e.CreditBucketStatus,exports.CreditStorePage=e.CreditStorePage,exports.CreditTransactionType=e.CreditTransactionType,exports.DEFAULT_ROLE_PERMISSIONS=e.DEFAULT_ROLE_PERMISSIONS,exports.Devices=e.Devices,exports.DevicesApi=e.DevicesApi,exports.DunningState=e.DunningState,exports.EmptyState=e.EmptyState,exports.EventEmitter=e.EventEmitter,exports.FullScreenLoader=e.FullScreenLoader,exports.InvoiceStatuses=e.InvoiceStatuses,exports.LoadingState=e.LoadingState,exports.PLAN_CURRENCY_CODES=e.PLAN_CURRENCY_CODES,exports.PLAN_CURRENCY_OPTIONS=e.PLAN_CURRENCY_OPTIONS,exports.PUSH_SERVICE_WORKER_SCRIPT=e.PUSH_SERVICE_WORKER_SCRIPT,exports.Permission=e.Permission,exports.PricingPage=e.PricingPage,exports.PushApi=e.PushApi,exports.PushNotificationProvider=e.PushNotificationProvider,exports.QuotaUsageContextProvider=e.QuotaUsageContextProvider,exports.SDKEvent=e.SDKEvent,exports.SETTINGS_SCREENS=e.SETTINGS_SCREENS,exports.SUPPORTED_LOCALES=e.SUPPORTED_LOCALES,exports.SaaSOSProvider=e.SaaSOSProvider,exports.SectionHeader=e.SectionHeader,exports.Sessions=e.Sessions,exports.SessionsApi=e.SessionsApi,exports.SettingsApi=e.SettingsApi,exports.SettingsScreen=e.SettingsScreen,exports.SidebarNavItem=e.SidebarNavItem,exports.SidebarNavSection=e.SidebarNavSection,exports.StatusBanner=e.StatusBanner,exports.SubscriptionContextProvider=e.SubscriptionContextProvider,exports.SubscriptionItemType=e.SubscriptionItemType,exports.SubscriptionStatus=e.SubscriptionStatus,exports.UserApi=e.UserApi,exports.WhenAuthenticated=e.WhenAuthenticated,exports.WhenCreditsAvailable=e.WhenCreditsAvailable,exports.WhenCreditsExhausted=e.WhenCreditsExhausted,exports.WhenCreditsLow=e.WhenCreditsLow,exports.WhenNoSubscription=e.WhenNoSubscription,exports.WhenNotTrialing=e.WhenNotTrialing,exports.WhenPermission=e.WhenPermission,exports.WhenQuotaAvailable=e.WhenQuotaAvailable,exports.WhenQuotaExhausted=e.WhenQuotaExhausted,exports.WhenQuotaOverage=e.WhenQuotaOverage,exports.WhenQuotaThreshold=e.WhenQuotaThreshold,exports.WhenRoles=e.WhenRoles,exports.WhenSubscription=e.WhenSubscription,exports.WhenSubscriptionToPlans=e.WhenSubscriptionToPlans,exports.WhenTrialEnding=e.WhenTrialEnding,exports.WhenTrialing=e.WhenTrialing,exports.WhenUnauthenticated=e.WhenUnauthenticated,exports.WhenUserFeatureDisabled=e.WhenUserFeatureDisabled,exports.WhenUserFeatureEnabled=e.WhenUserFeatureEnabled,exports.WhenWorkspaceFeatureDisabled=e.WhenWorkspaceFeatureDisabled,exports.WhenWorkspaceFeatureEnabled=e.WhenWorkspaceFeatureEnabled,exports.WhenWorkspaceRoles=e.WhenWorkspaceRoles,exports.WorkspaceApi=e.WorkspaceApi,exports.WorkspaceSwitcher=e.WorkspaceSwitcher,exports.calculateBillableSeats=e.calculateBillableSeats,exports.calculateSeatOverageCents=e.calculateSeatOverageCents,exports.calculateTotalSubscriptionCents=e.calculateTotalSubscriptionCents,exports.cleanBBParams=e.cleanBBParams,exports.clearAuthIntent=e.clearAuthIntent,exports.coerceBadgeRef=e.coerceBadgeRef,exports.consumeAuthIntent=e.consumeAuthIntent,exports.createBBUrl=e.createBBUrl,exports.createCheckoutRedirectUrls=e.createCheckoutRedirectUrls,exports.createCreditPurchaseRedirectUrls=e.createCreditPurchaseRedirectUrls,exports.eventEmitter=e.eventEmitter,exports.fillMcpTemplate=e.fillMcpTemplate,exports.formatCents=e.formatCents,exports.formatMinorAmountIntl=e.formatMinorAmountIntl,exports.formatOverageRate=e.formatOverageRate,exports.formatOverageRateWithLabel=e.formatOverageRateWithLabel,exports.formatQuotaIncludedOverage=e.formatQuotaIncludedOverage,exports.formatQuotaWithPrice=e.formatQuotaWithPrice,exports.getAvailableCurrenciesFromPlans=e.getAvailableCurrenciesFromPlans,exports.getBasePriceCents=e.getBasePriceCents,exports.getBillingIntervalAndCurrencyFromPriceId=e.getBillingIntervalAndCurrencyFromPriceId,exports.getCurrencyDecimals=e.getCurrencyDecimals,exports.getCurrencyFlag=e.getCurrencyFlag,exports.getCurrencySymbol=e.getCurrencySymbol,exports.getDisplayCurrency=e.getDisplayCurrency,exports.getPerSeatPriceCents=e.getPerSeatPriceCents,exports.getPricingVariant=e.getPricingVariant,exports.getQuotaDisplayValue=e.getQuotaDisplayValue,exports.getQuotaDisplayWithVariant=e.getQuotaDisplayWithVariant,exports.getQuotaOverageCents=e.getQuotaOverageCents,exports.getQuotaUnitLabelFromName=e.getQuotaUnitLabelFromName,exports.getSeatPricing=e.getSeatPricing,exports.getStripePriceIdForInterval=e.getStripePriceIdForInterval,exports.hasPermission=e.hasPermission,exports.invalidateCreditBalance=e.invalidateCreditBalance,exports.invalidateQuotaUsage=e.invalidateQuotaUsage,exports.invalidateSubscription=e.invalidateSubscription,exports.isZeroDecimalCurrency=e.isZeroDecimalCurrency,exports.mcpServerKey=e.mcpServerKey,exports.mergeUIConfig=e.mergeUIConfig,exports.minorAmountToDisplay=e.minorAmountToDisplay,exports.readBBParams=e.readBBParams,exports.resolveMaxUsers=e.resolveMaxUsers,exports.resolvePermissions=e.resolvePermissions,exports.safeRedirect=e.safeRedirect,exports.saveAuthIntent=e.saveAuthIntent,exports.useAllQuotaUsage=e.useAllQuotaUsage,exports.useBillingPortal=e.useBillingPortal,exports.useCancelSubscription=e.useCancelSubscription,exports.useConnectedAgents=e.useConnectedAgents,exports.useConnectedAgentsApi=e.useConnectedAgentsApi,exports.useConsumeCredits=e.useConsumeCredits,exports.useCreateCheckoutSession=e.useCreateCheckoutSession,exports.useCreditBalance=e.useCreditBalance,exports.useCreditBalanceContext=e.useCreditBalanceContext,exports.useCreditPackages=e.useCreditPackages,exports.useCreditTransactions=e.useCreditTransactions,exports.useDevices=e.useDevices,exports.useDevicesApi=e.useDevicesApi,exports.useExpiringCredits=e.useExpiringCredits,exports.useFullScreenLoader=e.useFullScreenLoader,exports.useInvoice=e.useInvoice,exports.useInvoices=e.useInvoices,exports.useMcpConnection=e.useMcpConnection,exports.usePermissions=e.usePermissions,exports.usePlanGroup=e.usePlanGroup,exports.usePlanGroupVersions=e.usePlanGroupVersions,exports.usePublicCreditPackages=e.usePublicCreditPackages,exports.usePublicPlanGroupVersion=e.usePublicPlanGroupVersion,exports.usePublicPlans=e.usePublicPlans,exports.usePurchaseCredits=e.usePurchaseCredits,exports.usePushNotifications=e.usePushNotifications,exports.useQuotaUsageContext=e.useQuotaUsageContext,exports.useQuotaUsageStatus=e.useQuotaUsageStatus,exports.useRecordUsage=e.useRecordUsage,exports.useResumeSubscription=e.useResumeSubscription,exports.useSaaSAuth=e.useSaaSAuth,exports.useSaaSOs=e.useSaaSOs,exports.useSaaSSettings=e.useSaaSSettings,exports.useSaaSWorkspaces=e.useSaaSWorkspaces,exports.useSeatStatus=e.useSeatStatus,exports.useSessions=e.useSessions,exports.useSessionsApi=e.useSessionsApi,exports.useSubscription=e.useSubscription,exports.useSubscriptionContext=e.useSubscriptionContext,exports.useSubscriptionManagement=e.useSubscriptionManagement,exports.useTranslation=e.useTranslation,exports.useTrialStatus=e.useTrialStatus,exports.useUIConfig=e.useUIConfig,exports.useUIVisibility=e.useUIVisibility,exports.useUpdateSubscription=e.useUpdateSubscription,exports.useUsageLogs=e.useUsageLogs,exports.useUserAttributes=e.useUserAttributes,exports.useUserFeatures=e.useUserFeatures,exports.validateInvite=e.validateInvite,exports.validateRedirectUrl=e.validateRedirectUrl,exports.workspaceSettingsManager=e.workspaceSettingsManager;
@@ -1290,6 +1290,23 @@ declare class AuthApi extends BaseApi {
1290
1290
  * handling device identity. Returns '' for agent/machine sessions (no device).
1291
1291
  */
1292
1292
  getDeviceToken(sessionId: string, signal?: AbortSignal): Promise<string>;
1293
+ /**
1294
+ * Revoke the session server-side. This is what makes signing out mean
1295
+ * something: dropping the id from storage only hides it from this tab, and
1296
+ * the session stays valid until its TTL, so anyone who still holds the id -
1297
+ * a synced browser profile, a backup, an extension - remains signed in.
1298
+ *
1299
+ * `all: true` revokes every session the user has, which is "sign out
1300
+ * everywhere". Signing out one OTHER session is `SessionsApi.revoke`.
1301
+ *
1302
+ * The endpoint sits ahead of the session gate, so it answers for an id that
1303
+ * has already expired or was never valid, and it is idempotent - calling it
1304
+ * twice is not an error. Failures still throw: the caller decides, and
1305
+ * `signOut` clears local state either way.
1306
+ */
1307
+ logout(sessionId?: string, options?: {
1308
+ all?: boolean;
1309
+ }, signal?: AbortSignal): Promise<void>;
1293
1310
  }
1294
1311
 
1295
1312
  interface IScreenDetail {
@@ -3843,9 +3860,29 @@ declare const WhenUnauthenticated: {
3843
3860
  displayName: string;
3844
3861
  };
3845
3862
 
3863
+ /** What `signOut` accepts. */
3864
+ interface SignOutOptions {
3865
+ /** Revoke every session this user has, on every device, not just this one. */
3866
+ everywhere?: boolean;
3867
+ }
3868
+ /**
3869
+ * What `signOut` will actually be handed.
3870
+ *
3871
+ * `onClick={signOut}` is the documented pattern (README), and React hands an
3872
+ * event to it. An all-optional options type is not assignable from an event, so
3873
+ * typing the parameter as `SignOutOptions` alone would turn every one of those
3874
+ * call sites into a compile error - a code change demanded in exchange for a
3875
+ * security fix, which is how a security fix goes unadopted. So the event shape
3876
+ * is accepted and ignored. `{ nativeEvent }` rather than React's own type
3877
+ * because this module has no reason to import React.
3878
+ */
3879
+ type SignOutArg = SignOutOptions | {
3880
+ nativeEvent: unknown;
3881
+ } | undefined;
3882
+
3846
3883
  declare function useSaaSAuth(): {
3847
3884
  signIn: (returnUrl?: string) => Promise<void>;
3848
- signOut: () => Promise<void>;
3885
+ signOut: (options?: SignOutArg) => Promise<void>;
3849
3886
  openWorkspaceSettings: (section?: WorkspaceSettingsSection) => void;
3850
3887
  openCreditStore: () => void;
3851
3888
  openPlanPicker: () => void;
@@ -6779,4 +6816,4 @@ declare class WorkspaceSettingsManager {
6779
6816
  declare const workspaceSettingsManager: WorkspaceSettingsManager;
6780
6817
 
6781
6818
  export { ApiVersion, AuthApi, AuthStatus, BBAction, BBScreen, BBStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, BuildBaseBadge, SaaSOSProvider as BuildBaseProvider, CURRENCY_DISPLAY, CURRENCY_FLAG, ConnectMcpGuide, ConnectedAgents, ConnectedAgentsApi, CreditActionsProvider, CreditBalance, CreditBalanceContextProvider, CreditBucketSource, CreditBucketStatus, CreditStorePage, CreditTransactionType, DEFAULT_ROLE_PERMISSIONS, Devices, DevicesApi, DunningState, EmptyState, EventEmitter, FullScreenLoader, InvoiceStatuses, LoadingState, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, Permission, PricingPage, PushApi, PushNotificationProvider, QuotaUsageContextProvider, SDKEvent, SETTINGS_SCREENS, SUPPORTED_LOCALES, SaaSOSProvider, SectionHeader, Sessions, SessionsApi, SettingsApi, SettingsScreen, SidebarNavItem, SidebarNavSection, StatusBanner, SubscriptionContextProvider, SubscriptionItemType, SubscriptionStatus, UserApi, WhenAuthenticated, WhenCreditsAvailable, WhenCreditsExhausted, WhenCreditsLow, WhenNoSubscription, WhenNotTrialing, WhenPermission, WhenQuotaAvailable, WhenQuotaExhausted, WhenQuotaOverage, WhenQuotaThreshold, WhenRoles, WhenSubscription, WhenSubscriptionToPlans, WhenTrialEnding, WhenTrialing, WhenUnauthenticated, WhenUserFeatureDisabled, WhenUserFeatureEnabled, WhenWorkspaceFeatureDisabled, WhenWorkspaceFeatureEnabled, WhenWorkspaceRoles, WorkspaceApi, WorkspaceSwitcher, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, clearAuthIntent, coerceBadgeRef, consumeAuthIntent, createBBUrl, createCheckoutRedirectUrls, createCreditPurchaseRedirectUrls, eventEmitter, fillMcpTemplate, formatCents, formatMinorAmountIntl, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyDecimals, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, hasPermission, invalidateCreditBalance, invalidateQuotaUsage, invalidateSubscription, isZeroDecimalCurrency, mcpServerKey, mergeUIConfig, minorAmountToDisplay, readBBParams, resolveMaxUsers, resolvePermissions, safeRedirect, saveAuthIntent, useAllQuotaUsage, useBillingPortal, useCancelSubscription, useConnectedAgents, useConnectedAgentsApi, useConsumeCredits, useCreateCheckoutSession, useCreditBalance, useCreditBalanceContext, useCreditPackages, useCreditTransactions, useDevices, useDevicesApi, useExpiringCredits, useFullScreenLoader, useInvoice, useInvoices, useMcpConnection, usePermissions, usePlanGroup, usePlanGroupVersions, usePublicCreditPackages, usePublicPlanGroupVersion, usePublicPlans, usePurchaseCredits, usePushNotifications, useQuotaUsageContext, useQuotaUsageStatus, useRecordUsage, useResumeSubscription, useSaaSAuth, useSaaSOs, useSaaSSettings, useSaaSWorkspaces, useSeatStatus, useSessions, useSessionsApi, useSubscription, useSubscriptionContext, useSubscriptionManagement, useTranslation, useTrialStatus, useUIConfig, useUIVisibility, useUpdateSubscription, useUsageLogs, useUserAttributes, useUserFeatures, validateInvite, validateRedirectUrl, workspaceSettingsManager };
6782
- export type { BBActionType, BBScreenType, BBStatusType, BadgeHrefOptions, BetaFormData, BetaFormResponse, BillingInterval, BuildBaseBadgeProps, BuildBaseBadgeSize, BuildBaseBadgeTheme, BuildBaseBadgeVariant, SaaSOSProviderProps as BuildBaseProviderProps, CheckoutResult, ConnectMcpGuideProps, ConnectedAgentsProps, CreditActionsDetails, CreditBalanceContextValue, CreditBalanceDetails, CreditBucketSourceType, CreditBucketStatusType, CreditStorePageDetails, CreditTransactionTypeValue, DevicesProps, DunningStateType, EmptyStateProps, EventData, EventType, FormatQuotaWithPriceOptions, FullScreenLoaderProps, GetCheckoutStripeParams, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, ICheckoutStripeOptions, IConnectedAgent, IConsumeCreditsRequest, IConsumeCreditsResponse, ICreditBalance, ICreditBucket, ICreditBucketsQuery, ICreditBucketsResponse, ICreditPackage, ICreditPackagePricingVariant, ICreditPurchaseRequest, ICreditPurchaseResponse, ICreditTransaction, ICreditTransactionsQuery, ICreditTransactionsResponse, IDeviceView, IEventCallbacks, IExpiringCreditsResponse, IInvoice, IInvoiceListResponse, IInvoiceResponse, IIpInfoLite, IOsConfig, IOsState, IPlan, IPlanGroup, IPlanGroupInfo, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionWithPlans, IPlanGroupVersionsResponse, IPlanVersion, IPlanVersionSummary, IPlanVersionWithPlan, IPricingVariant, IPublicCreditPackage, IPublicCreditPackagesResponse, IPublicPlanItem, IPublicPlanItemCategory, IPublicPlanVersion, IPublicPlansResponse, IQuotaByInterval, IQuotaIntervalValue, IQuotaOveragePriceIdsByInterval, IQuotaOveragesByInterval, IQuotaUsageStatus, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, ISessionView, ISettings, IStripePricesByInterval, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUsageLogEntry, IUsageLogsQuery, IUsageLogsResponse, IUser, IWorkspace, InviteBlockReason, InviteValidation, InvoiceStatus, InvoiceStatusType, LoadingProps, LoadingStateProps, MaxUsersConfig, McpClientGuide, McpConnectionConfig, NotificationData, NotificationEvent, NotificationResult, OnWorkspaceChangeParams, PartialSDKMessages, PermissionContext, PermissionKey, PlanVersionWithPricingVariants, PricingPageDetails, PricingPageProps, QuotaDisplayValue, QuotaDisplayWithOverage, QuotaUsageContextValue, RedirectValidationOptions, RolePermissionMap, SDKLocale, SDKMessages, SDKUIConfig, SaaSOSProviderProps, SeatStatus, SectionHeaderProps, SessionsProps, SettingsManagerState, SidebarNavItemProps, SidebarNavSectionProps, StatusBannerProps, StatusBannerVariant, SubscriptionContextValue, SubscriptionItemTypeValue, SubscriptionStatusType, TranslationKey, TrialStatus, UseConnectedAgents, UseDevices, UseSessions, UserCreatedEventData, UserUpdatedEventData, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceSettingsSection, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
6819
+ export type { BBActionType, BBScreenType, BBStatusType, BadgeHrefOptions, BetaFormData, BetaFormResponse, BillingInterval, BuildBaseBadgeProps, BuildBaseBadgeSize, BuildBaseBadgeTheme, BuildBaseBadgeVariant, SaaSOSProviderProps as BuildBaseProviderProps, CheckoutResult, ConnectMcpGuideProps, ConnectedAgentsProps, CreditActionsDetails, CreditBalanceContextValue, CreditBalanceDetails, CreditBucketSourceType, CreditBucketStatusType, CreditStorePageDetails, CreditTransactionTypeValue, DevicesProps, DunningStateType, EmptyStateProps, EventData, EventType, FormatQuotaWithPriceOptions, FullScreenLoaderProps, GetCheckoutStripeParams, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, ICheckoutStripeOptions, IConnectedAgent, IConsumeCreditsRequest, IConsumeCreditsResponse, ICreditBalance, ICreditBucket, ICreditBucketsQuery, ICreditBucketsResponse, ICreditPackage, ICreditPackagePricingVariant, ICreditPurchaseRequest, ICreditPurchaseResponse, ICreditTransaction, ICreditTransactionsQuery, ICreditTransactionsResponse, IDeviceView, IEventCallbacks, IExpiringCreditsResponse, IInvoice, IInvoiceListResponse, IInvoiceResponse, IIpInfoLite, IOsConfig, IOsState, IPlan, IPlanGroup, IPlanGroupInfo, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionWithPlans, IPlanGroupVersionsResponse, IPlanVersion, IPlanVersionSummary, IPlanVersionWithPlan, IPricingVariant, IPublicCreditPackage, IPublicCreditPackagesResponse, IPublicPlanItem, IPublicPlanItemCategory, IPublicPlanVersion, IPublicPlansResponse, IQuotaByInterval, IQuotaIntervalValue, IQuotaOveragePriceIdsByInterval, IQuotaOveragesByInterval, IQuotaUsageStatus, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, ISessionView, ISettings, IStripePricesByInterval, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUsageLogEntry, IUsageLogsQuery, IUsageLogsResponse, IUser, IWorkspace, InviteBlockReason, InviteValidation, InvoiceStatus, InvoiceStatusType, LoadingProps, LoadingStateProps, MaxUsersConfig, McpClientGuide, McpConnectionConfig, NotificationData, NotificationEvent, NotificationResult, OnWorkspaceChangeParams, PartialSDKMessages, PermissionContext, PermissionKey, PlanVersionWithPricingVariants, PricingPageDetails, PricingPageProps, QuotaDisplayValue, QuotaDisplayWithOverage, QuotaUsageContextValue, RedirectValidationOptions, RolePermissionMap, SDKLocale, SDKMessages, SDKUIConfig, SaaSOSProviderProps, SeatStatus, SectionHeaderProps, SessionsProps, SettingsManagerState, SidebarNavItemProps, SidebarNavSectionProps, SignOutOptions, StatusBannerProps, StatusBannerVariant, SubscriptionContextValue, SubscriptionItemTypeValue, SubscriptionStatusType, TranslationKey, TrialStatus, UseConnectedAgents, UseDevices, UseSessions, UserCreatedEventData, UserUpdatedEventData, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceSettingsSection, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{aS as ApiVersion,aT as AuthApi,aU as AuthStatus,o as BBAction,aV as BBScreen,p as BBStatus,aW as BB_PARAM,aX as BaseApi,aY as BetaForm,ag as BillingIntervals,aZ as BuildBaseBadge,a_ as BuildBaseProvider,a$ as CURRENCY_DISPLAY,b0 as CURRENCY_FLAG,b1 as ConnectMcpGuide,C as ConnectedAgents,b2 as ConnectedAgentsApi,b3 as CreditActionsProvider,b4 as CreditBalance,b5 as CreditBalanceContextProvider,b6 as CreditBucketSource,b7 as CreditBucketStatus,b8 as CreditStorePage,y as CreditTransactionType,b9 as DEFAULT_ROLE_PERMISSIONS,R as Devices,ba as DevicesApi,ax as DunningState,E as EmptyState,bb as EventEmitter,bc as FullScreenLoader,ae as InvoiceStatuses,L as LoadingState,bd as PLAN_CURRENCY_CODES,be as PLAN_CURRENCY_OPTIONS,bf as PUSH_SERVICE_WORKER_SCRIPT,P as Permission,bg as PricingPage,bh as PushApi,bi as PushNotificationProvider,bj as QuotaUsageContextProvider,bk as SDKEvent,aO as SETTINGS_SCREENS,bl as SUPPORTED_LOCALES,a_ as SaaSOSProvider,s as SectionHeader,T as Sessions,bm as SessionsApi,bn as SettingsApi,aH as SettingsScreen,aJ as SidebarNavItem,aI as SidebarNavSection,r as StatusBanner,bo as SubscriptionContextProvider,ah as SubscriptionItemType,ak as SubscriptionStatus,bp as UserApi,bq as WhenAuthenticated,br as WhenCreditsAvailable,bs as WhenCreditsExhausted,bt as WhenCreditsLow,bu as WhenNoSubscription,bv as WhenNotTrialing,bw as WhenPermission,bx as WhenQuotaAvailable,by as WhenQuotaExhausted,bz as WhenQuotaOverage,bA as WhenQuotaThreshold,bB as WhenRoles,bC as WhenSubscription,bD as WhenSubscriptionToPlans,bE as WhenTrialEnding,bF as WhenTrialing,bG as WhenUnauthenticated,bH as WhenUserFeatureDisabled,bI as WhenUserFeatureEnabled,bJ as WhenWorkspaceFeatureDisabled,bK as WhenWorkspaceFeatureEnabled,bL as WhenWorkspaceRoles,bM as WorkspaceApi,bN as WorkspaceSwitcher,bO as calculateBillableSeats,bP as calculateSeatOverageCents,bQ as calculateTotalSubscriptionCents,bR as cleanBBParams,bS as clearAuthIntent,bT as coerceBadgeRef,bU as consumeAuthIntent,bV as createBBUrl,az as createCheckoutRedirectUrls,v as createCreditPurchaseRedirectUrls,bW as eventEmitter,bX as fillMcpTemplate,bY as formatCents,f as formatMinorAmountIntl,bZ as formatOverageRate,b_ as formatOverageRateWithLabel,b$ as formatQuotaIncludedOverage,c0 as formatQuotaWithPrice,aQ as getAvailableCurrenciesFromPlans,au as getBasePriceCents,at as getBillingIntervalAndCurrencyFromPriceId,e as getCurrencyDecimals,a0 as getCurrencyFlag,g as getCurrencySymbol,c1 as getDisplayCurrency,aw as getPerSeatPriceCents,aP as getPricingVariant,aj as getQuotaDisplayValue,ai as getQuotaDisplayWithVariant,aD as getQuotaOverageCents,c2 as getQuotaUnitLabelFromName,av as getSeatPricing,ay as getStripePriceIdForInterval,c3 as hasPermission,q as invalidateCreditBalance,c4 as invalidateQuotaUsage,aA as invalidateSubscription,c5 as isZeroDecimalCurrency,c6 as mcpServerKey,aL as mergeUIConfig,c7 as minorAmountToDisplay,c8 as readBBParams,c9 as resolveMaxUsers,ca as resolvePermissions,x as safeRedirect,cb as saveAuthIntent,cc as useAllQuotaUsage,aq as useBillingPortal,ao as useCancelSubscription,cd as useConnectedAgents,ce as useConnectedAgentsApi,cf as useConsumeCredits,an as useCreateCheckoutSession,cg as useCreditBalance,j as useCreditBalanceContext,k as useCreditPackages,m as useCreditTransactions,ch as useDevices,ci as useDevicesApi,l as useExpiringCredits,cj as useFullScreenLoader,ck as useInvoice,ac as useInvoices,cl as useMcpConnection,h as usePermissions,cm as usePlanGroup,ar as usePlanGroupVersions,cn as usePublicCreditPackages,co as usePublicPlanGroupVersion,cp as usePublicPlans,n as usePurchaseCredits,a7 as usePushNotifications,aB as useQuotaUsageContext,cq as useQuotaUsageStatus,cr as useRecordUsage,ap as useResumeSubscription,aE as useSaaSAuth,cs as useSaaSOs,A as useSaaSSettings,z as useSaaSWorkspaces,aF as useSeatStatus,ct as useSessions,cu as useSessionsApi,cv as useSubscription,aC as useSubscriptionContext,am as useSubscriptionManagement,u as useTranslation,cw as useTrialStatus,aK as useUIConfig,i as useUIVisibility,cx as useUpdateSubscription,cy as useUsageLogs,cz as useUserAttributes,cA as useUserFeatures,cB as validateInvite,cC as validateRedirectUrl,w as workspaceSettingsManager}from"./chunks/react-CHhQFy94.mjs";import"react/jsx-runtime";import"react";import"clsx";import"tailwind-merge";import"intl-messageformat";import"@hookform/resolvers/zod";import"react-hook-form";import"@radix-ui/react-slot";import"class-variance-authority";import"lucide-react";import"@radix-ui/react-label";import"zod";import"@radix-ui/react-avatar";import"@radix-ui/react-dialog";import"@radix-ui/react-icons";import"@radix-ui/react-radio-group";import"@radix-ui/react-scroll-area";import"@radix-ui/react-separator";import"@radix-ui/react-accordion";import"@radix-ui/react-alert-dialog";
2
+ export{aS as ApiVersion,aT as AuthApi,aU as AuthStatus,o as BBAction,aV as BBScreen,p as BBStatus,aW as BB_PARAM,aX as BaseApi,aY as BetaForm,ag as BillingIntervals,aZ as BuildBaseBadge,a_ as BuildBaseProvider,a$ as CURRENCY_DISPLAY,b0 as CURRENCY_FLAG,b1 as ConnectMcpGuide,C as ConnectedAgents,b2 as ConnectedAgentsApi,b3 as CreditActionsProvider,b4 as CreditBalance,b5 as CreditBalanceContextProvider,b6 as CreditBucketSource,b7 as CreditBucketStatus,b8 as CreditStorePage,y as CreditTransactionType,b9 as DEFAULT_ROLE_PERMISSIONS,R as Devices,ba as DevicesApi,ax as DunningState,E as EmptyState,bb as EventEmitter,bc as FullScreenLoader,ae as InvoiceStatuses,L as LoadingState,bd as PLAN_CURRENCY_CODES,be as PLAN_CURRENCY_OPTIONS,bf as PUSH_SERVICE_WORKER_SCRIPT,P as Permission,bg as PricingPage,bh as PushApi,bi as PushNotificationProvider,bj as QuotaUsageContextProvider,bk as SDKEvent,aO as SETTINGS_SCREENS,bl as SUPPORTED_LOCALES,a_ as SaaSOSProvider,s as SectionHeader,T as Sessions,bm as SessionsApi,bn as SettingsApi,aH as SettingsScreen,aJ as SidebarNavItem,aI as SidebarNavSection,r as StatusBanner,bo as SubscriptionContextProvider,ah as SubscriptionItemType,ak as SubscriptionStatus,bp as UserApi,bq as WhenAuthenticated,br as WhenCreditsAvailable,bs as WhenCreditsExhausted,bt as WhenCreditsLow,bu as WhenNoSubscription,bv as WhenNotTrialing,bw as WhenPermission,bx as WhenQuotaAvailable,by as WhenQuotaExhausted,bz as WhenQuotaOverage,bA as WhenQuotaThreshold,bB as WhenRoles,bC as WhenSubscription,bD as WhenSubscriptionToPlans,bE as WhenTrialEnding,bF as WhenTrialing,bG as WhenUnauthenticated,bH as WhenUserFeatureDisabled,bI as WhenUserFeatureEnabled,bJ as WhenWorkspaceFeatureDisabled,bK as WhenWorkspaceFeatureEnabled,bL as WhenWorkspaceRoles,bM as WorkspaceApi,bN as WorkspaceSwitcher,bO as calculateBillableSeats,bP as calculateSeatOverageCents,bQ as calculateTotalSubscriptionCents,bR as cleanBBParams,bS as clearAuthIntent,bT as coerceBadgeRef,bU as consumeAuthIntent,bV as createBBUrl,az as createCheckoutRedirectUrls,v as createCreditPurchaseRedirectUrls,bW as eventEmitter,bX as fillMcpTemplate,bY as formatCents,f as formatMinorAmountIntl,bZ as formatOverageRate,b_ as formatOverageRateWithLabel,b$ as formatQuotaIncludedOverage,c0 as formatQuotaWithPrice,aQ as getAvailableCurrenciesFromPlans,au as getBasePriceCents,at as getBillingIntervalAndCurrencyFromPriceId,e as getCurrencyDecimals,a0 as getCurrencyFlag,g as getCurrencySymbol,c1 as getDisplayCurrency,aw as getPerSeatPriceCents,aP as getPricingVariant,aj as getQuotaDisplayValue,ai as getQuotaDisplayWithVariant,aD as getQuotaOverageCents,c2 as getQuotaUnitLabelFromName,av as getSeatPricing,ay as getStripePriceIdForInterval,c3 as hasPermission,q as invalidateCreditBalance,c4 as invalidateQuotaUsage,aA as invalidateSubscription,c5 as isZeroDecimalCurrency,c6 as mcpServerKey,aL as mergeUIConfig,c7 as minorAmountToDisplay,c8 as readBBParams,c9 as resolveMaxUsers,ca as resolvePermissions,x as safeRedirect,cb as saveAuthIntent,cc as useAllQuotaUsage,aq as useBillingPortal,ao as useCancelSubscription,cd as useConnectedAgents,ce as useConnectedAgentsApi,cf as useConsumeCredits,an as useCreateCheckoutSession,cg as useCreditBalance,j as useCreditBalanceContext,k as useCreditPackages,m as useCreditTransactions,ch as useDevices,ci as useDevicesApi,l as useExpiringCredits,cj as useFullScreenLoader,ck as useInvoice,ac as useInvoices,cl as useMcpConnection,h as usePermissions,cm as usePlanGroup,ar as usePlanGroupVersions,cn as usePublicCreditPackages,co as usePublicPlanGroupVersion,cp as usePublicPlans,n as usePurchaseCredits,a7 as usePushNotifications,aB as useQuotaUsageContext,cq as useQuotaUsageStatus,cr as useRecordUsage,ap as useResumeSubscription,aE as useSaaSAuth,cs as useSaaSOs,A as useSaaSSettings,z as useSaaSWorkspaces,aF as useSeatStatus,ct as useSessions,cu as useSessionsApi,cv as useSubscription,aC as useSubscriptionContext,am as useSubscriptionManagement,u as useTranslation,cw as useTrialStatus,aK as useUIConfig,i as useUIVisibility,cx as useUpdateSubscription,cy as useUsageLogs,cz as useUserAttributes,cA as useUserFeatures,cB as validateInvite,cC as validateRedirectUrl,w as workspaceSettingsManager}from"./chunks/react-B0MFoaXI.mjs";import"react/jsx-runtime";import"react";import"clsx";import"tailwind-merge";import"intl-messageformat";import"@hookform/resolvers/zod";import"react-hook-form";import"@radix-ui/react-slot";import"class-variance-authority";import"lucide-react";import"@radix-ui/react-label";import"zod";import"@radix-ui/react-avatar";import"@radix-ui/react-dialog";import"@radix-ui/react-icons";import"@radix-ui/react-radio-group";import"@radix-ui/react-scroll-area";import"@radix-ui/react-separator";import"@radix-ui/react-accordion";import"@radix-ui/react-alert-dialog";
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var e=require("react/jsx-runtime"),t=require("react");const n="__buildbaseBeforeLeave",r=globalThis,i=r[n]??(r[n]=new Set);const o="bb_attr",a=["gclid","gbraid","wbraid","dclid","fbclid","msclkid","li_fat_id","twclid","ttclid","rdt_cid","epik","irclickid","utm_source","utm_medium","utm_campaign","utm_term","utm_content","utm_id"],s=/^[\w.~-]{1,200}$/;function c(){return"undefined"==typeof window?null:window}function d(e,t){if(!e||!e.includes("."))return"";if(/^\d{1,3}(\.\d{1,3}){3}$/.test(e))return"";const n=t??c()?.document;if(!n)return"";const r=e.split(".");for(let e=r.length-2;e>=0;e--){const t="."+r.slice(e).join("."),i=`__bb_probe_${Date.now()}`;n.cookie=`${i}=1; domain=${t}; path=/; SameSite=Lax`;const o=n.cookie.includes(`${i}=1`);if(n.cookie=`${i}=; domain=${t}; path=/; max-age=0; SameSite=Lax`,o)return t}return""}function l(e){const t=e.cookie.split("; ").find(e=>e.startsWith(`${o}=`));if(!t)return{};try{const e=JSON.parse(decodeURIComponent(t.slice(8)));return"object"==typeof e&&e?e:{}}catch{return{}}}function u(){const e=c();if(!e)return{};const t=e.document,n=l(t),r={...function(e){const t=new URLSearchParams(e),n={};for(const e of a){const r=t.get(e);r&&(r.length>200||s.test(r)&&(n[e]=r))}return n}(e.location.search),...n};if(0===Object.keys(r).length)return{};return Object.keys(r).some(e=>void 0===n[e])&&function(e,t,n){const r=encodeURIComponent(JSON.stringify(t));e.cookie=`${o}=${r}; path=/; max-age=7776000; SameSite=Lax`+(n?`; domain=${n}`:"")}(t,r,d(e.location.hostname,t)),r}function p(e){try{const t=new URLSearchParams(e);return t.has("code")&&t.has("state")}catch{return!1}}const g="bb_pending_checkout";function f(){try{return"undefined"==typeof window?null:window.sessionStorage}catch{return null}}const m="bb_co";function h(){try{return"undefined"==typeof window?null:window.document??null}catch{return null}}function y(){const e=h();if(e)try{const t=d(window.location?.hostname??"",e);e.cookie=`${m}=; path=/; max-age=0; SameSite=Lax`+(t?`; domain=${t}`:"")}catch{}}function w(e,t){if(!e)return null;try{const n=JSON.parse(e);return n&&"string"==typeof n.eventId&&n.eventId?"number"!=typeof n.startedAt||t-n.startedAt>216e5?null:n:null}catch{return null}}function v(e=Date.now()){const t=f();if(!t)return null;let n=null;try{n=t.getItem(g),t.removeItem(g)}catch{return null}const r=w(n,e);return r&&y(),r}function _(e){try{return w(f()?.getItem(g)??null,e)}catch{return null}}function k(e,t=Date.now()){let n=null;try{n=new URLSearchParams(e).get("session_id")}catch{return null}if(!n)return null;const r=_(t);if(r?.sessionId===n)return v(t);const i=function(e){const t=h();if(!t||"string"!=typeof t.cookie)return null;const n=t.cookie.split("; ").find(e=>e.startsWith(`${m}=`));return n?w(decodeURIComponent(n.slice(6)),e):null}(t);return i?.sessionId!==n?null:(y(),i)}function b(e,t=Date.now()){return function(e){let t=null;try{t=new URLSearchParams(e).get("bb")}catch{return!1}if(!t)return!1;const n={};for(const e of t.split(",")){const t=e.indexOf(":");if(-1!==t)try{n[decodeURIComponent(e.slice(0,t))]=decodeURIComponent(e.slice(t+1))}catch{}}return"checkout"===n.action&&"cancel"===n.status}(e)&&_(t)?v(t):null}const I=new Set(["bif","clp","djf","gnf","jpy","kmf","krw","mga","pyg","rwf","ugx","vnd","vuv","xaf","xof","xpf"]),C=new Set(["bhd","jod","kwd","omr","tnd"]);function x(e,t){if("number"!=typeof e||!Number.isFinite(e))return;const n=(t??"").toLowerCase();return I.has(n)?e:e/(C.has(n)?1e3:100)}function $(){return"undefined"==typeof window?null:window}function j(e){const t=$();if(!t)return;t.gtag?.("consent","update",{ad_storage:e.marketing?"granted":"denied",ad_user_data:e.marketing?"granted":"denied",ad_personalization:e.marketing?"granted":"denied",analytics_storage:e.analytics?"granted":"denied"});const n=t.fbq;n?.("consent",e.marketing?"grant":"revoke")}const A={gtm:{title:"Google Tag Manager",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Container ID",idPattern:"^GTM-[A-Z0-9]{4,10}$",idExample:"GTM-ABC1234",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"analytics",supportsConsentMode:!0,needsConversionIds:!1},ga4:{title:"Google Analytics 4",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Measurement ID",idPattern:"^G-[A-Z0-9]{8,12}$",idExample:"G-ABCD123456",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"analytics",supportsConsentMode:!0,needsConversionIds:!1},google_ads:{title:"Google Ads",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Conversion ID",idPattern:"^AW-[0-9]{9,12}$",idExample:"AW-123456789",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"marketing",supportsConsentMode:!0,needsConversionIds:!0},meta_pixel:{title:"Meta Pixel",vendor:"Meta Platforms Ireland Limited",privacyUrl:"https://www.facebook.com/privacy/policy",idLabel:"Pixel ID",idPattern:"^[0-9]{15,16}$",idExample:"123456789012345",scriptOrigin:"https://connect.facebook.net",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},x_pixel:{title:"X (Twitter) Pixel",vendor:"X Corp.",privacyUrl:"https://x.com/en/privacy",idLabel:"Pixel ID",idPattern:"^o[a-z0-9]{4,6}$",idExample:"o1a2b3",scriptOrigin:"https://static.ads-twitter.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!0,multiInstance:!0},linkedin:{title:"LinkedIn Insight Tag",vendor:"LinkedIn Ireland Unlimited Company",privacyUrl:"https://www.linkedin.com/legal/privacy-policy",idLabel:"Partner ID",idPattern:"^[0-9]{6,9}$",idExample:"1234567",scriptOrigin:"https://snap.licdn.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!0,multiInstance:!0},tiktok:{title:"TikTok Pixel",vendor:"TikTok Information Technologies UK Limited",privacyUrl:"https://www.tiktok.com/legal/privacy-policy",idLabel:"Pixel ID",idPattern:"^[A-Z0-9]{20}$",idExample:"C4A1B2C3D4E5F6G7H8I9",scriptOrigin:"https://analytics.tiktok.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},reddit:{title:"Reddit Pixel",vendor:"Reddit, Inc.",privacyUrl:"https://www.reddit.com/policies/privacy-policy",idLabel:"Advertiser ID",idPattern:"^t2_[a-z0-9]{4,12}$",idExample:"t2_abc123",scriptOrigin:"https://www.redditstatic.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},bing_uet:{title:"Microsoft Advertising (UET)",vendor:"Microsoft Corporation",privacyUrl:"https://privacy.microsoft.com/en-us/privacystatement",idLabel:"Tag ID",idPattern:"^[0-9]{7,9}$",idExample:"12345678",scriptOrigin:"https://bat.bing.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},clarity:{title:"Microsoft Clarity",vendor:"Microsoft Corporation",privacyUrl:"https://privacy.microsoft.com/en-us/privacystatement",idLabel:"Project ID",idPattern:"^[a-z0-9]{10}$",idExample:"ab12cd34ef",scriptOrigin:"https://www.clarity.ms",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},hotjar:{title:"Hotjar",vendor:"Hotjar Limited",privacyUrl:"https://www.hotjar.com/legal/policies/privacy/",idLabel:"Site ID",idPattern:"^[0-9]{6,9}$",idExample:"1234567",scriptOrigin:"https://static.hotjar.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},posthog:{title:"PostHog",vendor:"PostHog, Inc.",privacyUrl:"https://posthog.com/privacy",idLabel:"Project API key",idPattern:"^phc_[A-Za-z0-9]{32,48}$",idExample:"phc_abcdefghijklmnopqrstuvwxyz012345",scriptOrigin:"https://us-assets.i.posthog.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1,hosts:["us.i.posthog.com","eu.i.posthog.com"]},plausible:{title:"Plausible Analytics",vendor:"Plausible Insights OÜ",privacyUrl:"https://plausible.io/privacy",idLabel:"Domain",idPattern:"^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$",idExample:"example.com",scriptOrigin:"https://plausible.io",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},ahrefs:{title:"Ahrefs Analytics",vendor:"Ahrefs Pte. Ltd.",privacyUrl:"https://ahrefs.com/privacy",idLabel:"Analytics key",idPattern:"^[A-Za-z0-9+/=]{20,64}$",idExample:"AbCdEfGhIjKlMnOpQrStUv==",scriptOrigin:"https://analytics.ahrefs.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1}},q=Object.keys(A);function P(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(A,e)}function S(e,t){return!!P(e)&&("string"==typeof t&&0!==t.length&&new RegExp(A[e].idPattern).test(t))}const E=/^[a-z][a-z0-9-]{0,40}$/,O=/^[\w.:/@+=-]{1,200}$/;function T(e){return function(e){if("string"!=typeof e)return!1;if(0===e.length||e.length>300)return!1;let t;try{t=new URL(e)}catch{return!1}return!("https:"!==t.protocol||!t.hostname||!t.hostname.includes(".")||e.includes("?")||e.includes("#")||t.username||t.password)}(e.src)&&function(e){if(null==e)return!0;if("object"!=typeof e||Array.isArray(e))return!1;const t=Object.entries(e);return!(t.length>12)&&t.every(([e,t])=>E.test(e)&&"string"==typeof t&&O.test(t))}(e.dataAttributes)}const U=Array.from(new Set(q.map(e=>A[e].scriptOrigin))).sort(),L={sign_up:{ga4:"sign_up",meta:"CompleteRegistration",tiktok:"CompleteRegistration",reddit:"SignUp"},login:{ga4:"login",meta:null,tiktok:null,reddit:null},trial_started:{ga4:"begin_checkout",meta:"StartTrial",tiktok:"StartTrial",reddit:"Lead"},checkout_started:{ga4:"begin_checkout",meta:"InitiateCheckout",tiktok:"InitiateCheckout",reddit:"AddToCart"},purchase:{ga4:"purchase",meta:"Purchase",tiktok:"CompletePayment",reddit:"Purchase"},subscription_created:{ga4:"purchase",meta:"Subscribe",tiktok:"Subscribe",reddit:"Purchase"},subscription_upgraded:{ga4:"subscription_upgraded",meta:null,tiktok:null,reddit:null},lead:{ga4:"generate_lead",meta:"Lead",tiktok:"SubmitForm",reddit:"Lead"},workspace_created:{ga4:"workspace_created",meta:null,tiktok:null,reddit:null}},R=Object.keys(L);function M(e){return R.includes(e)}function D(){return"undefined"==typeof window?null:window}const N={gtm:"dataLayer",ga4:"gtag",google_ads:"gtag",meta_pixel:"fbq",x_pixel:"twq",linkedin:"lintrk",tiktok:"ttq",reddit:"rdt",bing_uet:"uetq",clarity:"clarity",hotjar:"hj",posthog:"posthog",plausible:"plausible",ahrefs:"__ahrefs_loaded"};function B(){return"undefined"==typeof window?null:window}function G(e,t={}){const n=B();if(!n)return null;const r=n.document.createElement("script");r.async=!0,r.src=e;for(const[e,n]of Object.entries(t))r.setAttribute(e,n);return n.document.head.appendChild(r),r}function V(e){const t=B();if(!t)return;const n=t.document.createElement("script");n.text=e,t.document.head.appendChild(n)}function z(e){const t=B();t&&(Array.isArray(t[e])||(t[e]=[]),"function"!=typeof t.gtag&&(t.gtag=function(){t[e].push(arguments)}))}const F=new Set;function H(e){for(const t of F)if(t.slice(0,t.indexOf(":"))===e)return!0;return!1}function Z(e,t){const n=B();if(!n)return!1;if("gtm"===e||"ga4"===e||"google_ads"===e){const e=n.google_tag_manager;return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,t)}const r=N[e];if(!r)return!1;if(void 0===n[r])return!1;if(F.has(`${e}:${t}`))return!0;return!A[e].multiInstance||!H(e)}const J={meta_pixel:e=>`fbq('init','${e}');fbq('track','PageView');`,x_pixel:e=>`twq('config','${e}');`,tiktok:e=>`ttq.load('${e}');ttq.page();`,reddit:e=>`rdt('init','${e}');rdt('track','PageVisit');`,bing_uet:e=>`window.uetq=window.uetq||[];window.uetq.push({ti:'${e}',enableAutoSpaTracking:false});`,linkedin:e=>`window._linkedin_data_partner_ids=window._linkedin_data_partner_ids||[];window._linkedin_data_partner_ids.push('${e}');`};function K(e,t,n){const r=function(e,t,n){const r=B();if(!r)return!1;if("external"===e.provider){if(!e.src)return!1;const t={};for(const[n,r]of Object.entries(e.dataAttributes??{}))t[`data-${n}`]=r;return G(e.src,t),!0}const i=e.provider,o=A[i];if(!o)return!1;const a=e.providerId;if(!a)return!1;const s=J[i];if(s&&H(i))return V(s(a)),!0;switch(i){case"gtm":{z(t),r[t].push({"gtm.start":Date.now(),event:"gtm.js"});const e="dataLayer"===t?"":`&l=${t}`;return G(`${o.scriptOrigin}/gtm.js?id=${a}${e}`),!0}case"ga4":case"google_ads":{z(t),G(`${o.scriptOrigin}/gtag/js?id=${a}`);const e=r.gtag;e("js",new Date);const s="ga4"===i&&n?.gaClientId?{client_id:n.gaClientId}:void 0;return s?e("config",a,s):e("config",a),!0}case"meta_pixel":return V(`!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','${o.scriptOrigin}/en_US/fbevents.js');fbq('init','${a}');fbq('track','PageView');`),!0;case"x_pixel":return V(`!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments)},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='${o.scriptOrigin}/uwt.js',a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');twq('config','${a}');`),!0;case"linkedin":return V(`window._linkedin_partner_id='${a}';window._linkedin_data_partner_ids=window._linkedin_data_partner_ids||[];window._linkedin_data_partner_ids.push('${a}');window.lintrk=window.lintrk||function(a,b){(window.lintrk.q=window.lintrk.q||[]).push([a,b])};window.lintrk.q=window.lintrk.q||[];`),G(`${o.scriptOrigin}/li.lms-analytics/insight.min.js`),!0;case"tiktok":return V(`!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=['page','track','identify','instances','debug','on','off','once','ready','alias','group','enableCookie','disableCookie'];ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.load=function(e,n){var r='${o.scriptOrigin}/i18n/pixel/events.js';ttq._i=ttq._i||{};ttq._i[e]=[];ttq._i[e]._u=r;ttq._t=ttq._t||{};ttq._t[e]=+new Date;ttq._o=ttq._o||{};ttq._o[e]=n||{};var o=d.createElement('script');o.type='text/javascript';o.async=!0;o.src=r+'?sdkid='+e+'&lib='+t;var a=d.getElementsByTagName('script')[0];a.parentNode.insertBefore(o,a)};ttq.load('${a}');ttq.page()}(window,document,'ttq');`),!0;case"reddit":return V(`!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement('script');t.src='${o.scriptOrigin}/ads/pixel.js';t.async=!0;var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','${a}');rdt('track','PageVisit');`),!0;case"bing_uet":return V(`(function(w,d,t,r,u){w[u]=w[u]||[];w[u].push({ti:'${a}',enableAutoSpaTracking:false});var o=d.createElement(t);o.src='${o.scriptOrigin}/bat.js';o.async=1;var i=d.getElementsByTagName(t)[0];i.parentNode.insertBefore(o,i)})(window,document,'script',0,'uetq');`),!0;case"clarity":return V(`(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src='${o.scriptOrigin}/tag/'+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y)})(window,document,'clarity','script','${a}');`),!0;case"hotjar":return V(`(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:${a},hjsv:6};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src='${o.scriptOrigin}/hotjar-'+h._hjSettings.hjid+'.js?sv='+h._hjSettings.hjsv;a.appendChild(r)})(window,document);`),!0;case"posthog":{const t=o.hosts,n=t?.includes(e.host??"")?e.host:t?.[0]??"us.i.posthog.com";return V(`!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split('.');2==o.length&&(t=t[o[0]],e=o[1]);t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement('script')).type='text/javascript',p.async=!0,p.src='${o.scriptOrigin}/static/array.js',(r=t.getElementsByTagName('script')[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a='posthog',u.people=u.people||[],u.toString=function(t){var e='posthog';return'posthog'!==a&&(e+='.'+a),t||(e+=' (stub)'),e},u.people.toString=function(){return u.toString(1)+'.people (stub)'},o='init capture register register_once identify alias people.set people.set_once set_config get_distinct_id getFeatureFlag isFeatureEnabled onFeatureFlags reloadFeatureFlags group reset'.split(' '),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);posthog.init('${a}',{api_host:'https://${n}'});`),!0}case"plausible":return V("window.plausible=window.plausible||function(){(window.plausible.q=window.plausible.q||[]).push(arguments)};"),G(`${o.scriptOrigin}/js/script.js`,{"data-domain":a,defer:"true"}),!0;case"ahrefs":return G(`${o.scriptOrigin}/analytics.js`,{"data-key":a}),r.__ahrefs_loaded=!0,!0;default:return!1}}(e,t,n);return r&&"external"!==e.provider&&e.providerId&&F.add(`${e.provider}:${e.providerId}`),r}const W=Symbol.for("@buildbase/sdk.tracking.context"),Q=globalThis,X=Q[W]??(Q[W]=t.createContext(null)),Y={consent:{manifest:[],state:null,set:()=>{}},track:()=>{},setUser:()=>{},setProperties:()=>{},getProperties:()=>({}),completeCheckout:async()=>{},installed:{},ready:!0,attribution:{}};function ee(){return t.useContext(X)??Y}const te=({serverUrl:n,orgId:r,clientId:o,enabled:a=!0,consent:s="auto",autoPageview:c=!0,events:d,onEvent:l,properties:g,enrich:f,identity:m,debug:h=!1,children:y})=>{const w=t.useRef(m);w.current=m;const[v,_]=t.useState(null),[I,C]=t.useState(!1),[q,E]=t.useState(!1),O="granted"===s?{analytics:!0,marketing:!0}:"denied"===s?{analytics:!1,marketing:!1}:null,[U,R]=t.useState(O),N=t.useRef(null),B=t.useRef(l);B.current=l;const G=t.useRef(f);G.current=f;const V=t.useRef({});V.current=g??{};const F=t.useRef({}),H=t.useCallback(()=>({...V.current,...F.current}),[]),J=t.useCallback(e=>{const t={...F.current,...e};for(const[e,n]of Object.entries(t))void 0===n&&delete t[e];F.current=t},[]),[W,Q]=t.useState({}),Y=t.useRef({}),[ee,te]=t.useState(0),ne=v?.dataLayerName??"dataLayer",re=t.useCallback((...e)=>{h&&console.info("[buildbase:tracking]",...e)},[h]);t.useEffect(()=>{return e=()=>{0!==Object.keys(Y.current).length&&window.dispatchEvent("function"==typeof PageTransitionEvent?new PageTransitionEvent("pagehide",{persisted:!1}):new Event("pagehide"))},i.add(e),()=>{i.delete(e)};var e},[]),t.useEffect(()=>{if(!(a&&n&&r&&o))return void C(!0);let e=!1;const t=`${n.replace(/\/$/,"")}/api/v1/public/${r}/tracking?clientId=${encodeURIComponent(o)}`;return fetch(t).then(e=>e.ok?e.json():null).then(t=>{if(e||!t)return;const n=t.data??t;n&&Array.isArray(n.scripts)&&_(n)}).catch(()=>{re("config fetch failed; nothing installed")}).finally(()=>{e||C(!0)}),()=>{e=!0}},[a,n,r,o,re]),t.useEffect(()=>{a&&Q(u())},[a]),t.useEffect(()=>{a&&v?.enabled&&(z(ne),function(e,t){const n=$();if(!n)return;Array.isArray(n[e])||(n[e]=[]),"function"!=typeof n.gtag&&(n.gtag=function(){n[e].push(arguments)});const r="granted"===t?"granted":"denied";n.gtag("consent","default",{ad_storage:r,ad_user_data:r,ad_personalization:r,analytics_storage:r,wait_for_update:500})}(ne,s),N.current&&j(N.current))},[a,v?.enabled,ne,s]);const ie=t.useMemo(()=>v?.enabled?v.scripts.filter(e=>{const t=P(e.provider)&&A[e.provider].supportsConsentMode;return function(e,t,n,r){return"denied"!==r&&("granted"===r||(n?"marketing"===e?n.marketing:n.analytics:t&&"analytics"===e))}(e.consentCategory,t,U,s)}):[],[v,U,s]),[oe,ae]=t.useState(()=>"undefined"==typeof window||!p(window.location.search));t.useEffect(()=>{if(oe)return;const e=setInterval(()=>{p(window.location.search)||ae(!0)},50),t=setTimeout(()=>ae(!0),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[oe]),t.useEffect(()=>{if(!oe)return;if(!a||!v?.enabled)return void(I&&E(!0));let e=0;for(const t of ie)if(!Y.current[t.key]){if("external"===t.provider){if(!T({src:t.src,dataAttributes:t.dataAttributes})){re("rejected external script",t.key);continue}}else{if(!P(t.provider)){re("rejected unknown provider",t.provider);continue}if(!S(t.provider,t.providerId)){re("rejected id for",t.provider);continue}if(Z(t.provider,t.providerId??"")){re(`${t.provider} ${t.providerId} is already on the page; skipping. Configure each tag in exactly one place.`);continue}}K(t,ne,w.current)&&(Y.current[t.key]=t.providerId??t.src??"",e+=1,re("installed",t.key))}e&&te(e=>e+1);const t=window;t.__buildbase=t.__buildbase??{},t.__buildbase.tracking={installed:{...Y.current},dataLayerName:ne,clientId:o};const n=Object.keys(Y.current).length>0,r=null!==U||0===v.scripts.length;(n||r)&&E(!0)},[a,v,ie,I,U,ne,re,oe,o]),t.useEffect(()=>{if(!a||!c||!v?.enabled)return;if("undefined"==typeof window)return;if(!oe)return;let e=null;const t=()=>{e&&clearTimeout(e),e=setTimeout(()=>function(e,t){const n=D();if(!n)return;const r=n[t];Array.isArray(r)&&r.push({event:"page_view",page_path:n.location.pathname,page_location:n.location.href,page_title:n.document.title});for(const t of e)switch(t.provider){case"ga4":n.gtag?.("event","page_view",{send_to:t.providerId,page_path:n.location.pathname,page_location:n.location.href,page_title:n.document.title});break;case"meta_pixel":n.fbq?.("track","PageView");break;case"tiktok":{const e=n.ttq;e?.page?.();break}case"reddit":n.rdt?.("track","PageVisit")}}(ie,ne),50)},n=window.history,r=n.pushState,i=n.replaceState;return n.pushState=function(...e){const n=r.apply(this,e);return t(),n},n.replaceState=function(...e){const n=i.apply(this,e);return t(),n},window.addEventListener("popstate",t),()=>{n.pushState=r,n.replaceState=i,window.removeEventListener("popstate",t),e&&clearTimeout(e)}},[a,c,v?.enabled,ie,ne,oe]),t.useEffect(()=>{if(!a)return;const e=function(e,t){const n=e?.mode??"auto",r=e?.overrides??{};if(("manual"===n||Object.values(r).some(e=>"manual"===e))&&!t)return'[buildbase:tracking] events are set to "manual" but no onEvent handler was provided, so those events would never fire anywhere. Pass onEvent, or use mode "auto".';for(const e of Object.keys(r))if(!M(e))return`[buildbase:tracking] unknown event "${e}" in events.overrides. Overrides only apply to the events the SDK fires itself.`;return null}(d,!!l);if(e)throw new Error(e)},[a,d,l]);const se=t.useCallback((e,t={},n)=>{if(!a)return;const r=n?.eventId||function(){const e=globalThis.crypto;return e?.randomUUID?e.randomUUID():`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}(),i=d?.mode??"auto",o=(M(e)?d?.overrides?.[e]:void 0)??i,s={...V.current,...F.current,...W,...t},c=G.current?.({name:e,params:s})??{},l={...s,...c},u=B.current?.({name:e,params:l,eventId:r,handledBy:o});"manual"!==o&&!0!==u?(!function(e,t,n,r,i){const o=D();if(!o)return;const a=o[i];Array.isArray(a)&&a.push({event:e,...t,event_id:n});const s=M(e)?L[e]:{ga4:e,meta:null,tiktok:null,reddit:null};for(const i of r){const r=i.provider,a=A[r];if(a){if(a.needsConversionIds){const a=i.conversionIds?.[e];if(!a)continue;"google_ads"===r?o.gtag?.("event","conversion",{send_to:`${i.providerId}/${a}`,transaction_id:n,...t}):"x_pixel"===r?o.twq?.("event",a,{...t,conversion_id:n}):"linkedin"===r&&o.lintrk?.("track",{conversion_id:a});continue}switch(r){case"ga4":s.ga4&&o.gtag?.("event",s.ga4,{...t,send_to:i.providerId,event_id:n});break;case"meta_pixel":s.meta&&o.fbq?.("track",s.meta,t,{eventID:n});break;case"tiktok":if(s.tiktok){const e=o.ttq;e?.track?.(s.tiktok,{...t,event_id:n})}break;case"reddit":s.reddit&&o.rdt?.("track",s.reddit,{...t,conversionId:n});break;case"bing_uet":{const r=o.uetq;r?.push?.("event",s.ga4??e,{...t,event_id:n});break}case"clarity":o.clarity?.("event",e);break;case"hotjar":{const t=o.hj;t?.("event",e);break}case"posthog":{const r=o.posthog;r?.capture?.(e,{...t,event_id:n});break}case"plausible":o.plausible?.(e,{props:t})}}}}(e,l,r,ie,ne),re("event fired:",e,r)):re("event handled by app:",e)},[a,d,ie,ne,W,re]),ce=t.useCallback(async(e,t={})=>{const i=function(e){return{name:"trial_started"===e.kind?"trial_started":"purchase",params:{...e.workspaceId?{workspace_id:e.workspaceId}:{},...e.planVersionId?{plan_version_id:e.planVersionId}:{},...e.creditPackageId?{credit_package_id:e.creditPackageId}:{},...e.billingInterval?{billing_interval:e.billingInterval}:{},...e.currency?{currency:e.currency.toUpperCase()}:{},..."number"==typeof e.value?{value:e.value}:{},...e.sessionId?{transaction_id:e.sessionId}:{}}}}(e);let o=i.params;if(e.sessionId&&n&&r){const t=await async function(e,t){try{const n=e.serverUrl.replace(/\/$/,""),r=await fetch(`${n}/api/v1/public/${encodeURIComponent(e.orgId)}/checkout/${encodeURIComponent(t)}`,{credentials:"omit",..."undefined"!=typeof AbortSignal&&AbortSignal.timeout?{signal:AbortSignal.timeout(2e3)}:{}});if(!r.ok)return null;const i=await r.json(),o=i?.data??i;return"number"!=typeof o?.amount?null:{value:x(o.amount,o.currency),currency:"string"==typeof o.currency?o.currency:void 0,...Array.isArray(o.items)&&o.items.length?{items:o.items}:{}}}catch{return null}}({serverUrl:n,orgId:r},e.sessionId);t&&"number"==typeof t.value&&(o={...o,value:t.value,...t.currency?{currency:t.currency.toUpperCase()}:{},...t.items?.length?{items:t.items}:{}})}if(se(i.name,{...o,...t},{eventId:e.eventId}),"purchase"===i.name&&e.sessionId&&n&&r){const t=(v?.scripts??[]).find(e=>"ga4"===e.provider&&e.providerId);t&&Z("ga4",t.providerId??"")&&function(e,t,n){try{const r=e.serverUrl.replace(/\/$/,"");fetch(`${r}/api/v1/public/${encodeURIComponent(e.orgId)}/checkout/${encodeURIComponent(t)}/reported`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n}),keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}({serverUrl:n,orgId:r},e.sessionId,"ga4")}},[n,r,se,v]),[de]=t.useState(()=>"undefined"==typeof window?"":window.location.search);t.useEffect(()=>{if(!a||!q)return;if("undefined"==typeof window)return;const e=k(window.location.search);if(e)return void ce(e);const t=b(de);t&&se("checkout_abandoned",{...t.workspaceId?{workspace_id:t.workspaceId}:{},...t.planVersionId?{plan_version_id:t.planVersionId}:{},...t.creditPackageId?{credit_package_id:t.creditPackageId}:{},...t.billingInterval?{billing_interval:t.billingInterval}:{},...t.currency?{currency:t.currency.toUpperCase()}:{},..."number"==typeof t.value?{value:t.value}:{},seconds_at_checkout:Math.max(0,Math.round((Date.now()-t.startedAt)/1e3))})},[a,q,ce,de,se]);const le=t.useCallback(e=>{N.current=e,R(e),j(e)},[]),ue=t.useCallback((e,t)=>function(e,t,n){const r=D();if(!r)return;const i=!!n&&Object.keys(n).length>0;for(const o of t)switch(o.provider){case"ga4":case"google_ads":r.gtag?.("set",{user_id:e}),i&&r.gtag?.("set",{user_properties:n});break;case"meta_pixel":o.providerId&&r.fbq?.("init",o.providerId,{external_id:e});break;case"posthog":r.posthog?.identify?.(e,i?n:void 0);break;case"clarity":if(r.clarity?.("identify",e),i)for(const[e,t]of Object.entries(n))r.clarity?.("set",e,String(t));break;case"hotjar":r.hj?.("identify",e,{});break;case"tiktok":{const t=r.ttq;t?.identify?.({external_id:e});break}}}(e,ie,t),[ie]),pe=t.useMemo(()=>({consent:{manifest:v?.consent?.manifest??[],state:U,set:le},track:se,setUser:ue,setProperties:J,getProperties:H,completeCheckout:ce,installed:{...Y.current},ready:q,attribution:W}),[v,U,le,se,ue,J,H,ce,q,ee,W]);return e.jsx(X.Provider,{value:pe,children:y})};te.displayName="BuildBaseTracking";exports.ATTRIBUTION_PARAMS=a,exports.BuildBaseTracking=te,exports.EVENT_MAPPINGS=L,exports.FUNNEL_EVENTS={sign_in_started:"The sign-in / sign-up button was pressed.",pricing_viewed:"A <PricingPage> finished loading its plans.",pricing_plan_selected:"A plan was chosen on a <PricingPage>.",workspace_switcher_opened:"The workspace switcher was opened.",workspace_settings_opened:"The workspace settings modal was opened.",workspace_settings_section_viewed:"A different section of the settings modal was opened.",plan_picker_opened:"The plan picker was shown.",billing_interval_changed:"Monthly / quarterly / yearly was switched in the plan picker.",plan_selected:"A plan was chosen in the plan picker.",plan_picker_dismissed:"The plan picker was closed without choosing a plan.",checkout_abandoned:"The customer came back from Stripe without paying.",billing_portal_opened:"Stripe’s billing portal was opened.",subscription_cancel_started:"The cancel-subscription confirmation was opened.",subscription_cancelled:"A subscription was cancelled.",subscription_resumed:"A cancelled subscription was resumed.",feature_gate_shown:'A feature gate rendered its "not on your plan" side.',quota_limit_reached:"A quota gate rendered because a quota is used up.",quota_threshold_reached:"A usage-threshold gate rendered.",plan_gate_shown:'A plan gate rendered its "needs another plan" side.',subscription_notice_shown:"A billing notice (trial ending, payment failed…) was shown.",sdk_error:"An SDK operation failed (component, action and code only)."},exports.TAG_PROVIDERS=A,exports.TAG_PROVIDER_IDS=q,exports.TAG_SCRIPT_ORIGINS=U,exports.captureAttribution=u,exports.getAttribution=function(){const e=c();return e?l(e.document):{}},exports.isCanonicalEvent=M,exports.isTagProviderId=P,exports.isValidProviderId=S,exports.useCheckoutCompleted=function(e={}){const{completeCheckout:n,ready:r}=ee(),i=t.useRef(e);i.current=e;const o=t.useRef(!1);t.useEffect(()=>{if(!r)return;if(o.current)return;const e=k(window.location.search)??v();e&&(o.current=!0,n(e,i.current))},[r,n])},exports.useTracking=ee;
2
+ "use strict";var e=require("react/jsx-runtime"),t=require("react");const n="__buildbaseBeforeLeave",r=globalThis,i=r[n]??(r[n]=new Set);const o="bb_attr",a=["gclid","gbraid","wbraid","dclid","fbclid","msclkid","li_fat_id","twclid","ttclid","rdt_cid","epik","irclickid","utm_source","utm_medium","utm_campaign","utm_term","utm_content","utm_id"],s=/^[\w.~-]{1,200}$/;function c(){return"undefined"==typeof window?null:window}function d(e,t){if(!e||!e.includes("."))return"";if(/^\d{1,3}(\.\d{1,3}){3}$/.test(e))return"";const n=t??c()?.document;if(!n)return"";const r=e.split(".");for(let e=r.length-2;e>=0;e--){const t="."+r.slice(e).join("."),i=`__bb_probe_${Date.now()}`;n.cookie=`${i}=1; domain=${t}; path=/; SameSite=Lax`;const o=n.cookie.includes(`${i}=1`);if(n.cookie=`${i}=; domain=${t}; path=/; max-age=0; SameSite=Lax`,o)return t}return""}function l(e){const t=e.cookie.split("; ").find(e=>e.startsWith(`${o}=`));if(!t)return{};try{const e=JSON.parse(decodeURIComponent(t.slice(8)));return"object"==typeof e&&e?e:{}}catch{return{}}}const u=a.filter(e=>!e.startsWith("utm_")),p=e=>u.some(t=>!!e[t]);function g(){const e=c();if(!e)return{};const t=e.document,n=l(t),r=function(e){const t=new URLSearchParams(e),n={};for(const e of a){const r=t.get(e);r&&(r.length>200||s.test(r)&&(n[e]=r))}return n}(e.location.search),i=Object.keys(r).length>0&&(p(r)||!p(n)),u=i?r:n;return 0===Object.keys(u).length?{}:(i&&!function(e,t){const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const r of n)if(e[r]!==t[r])return!1;return!0}(r,n)&&function(e,t,n){const r=encodeURIComponent(JSON.stringify(t));e.cookie=`${o}=${r}; path=/; max-age=7776000; SameSite=Lax`+(n?`; domain=${n}`:"")}(t,u,d(e.location.hostname,t)),u)}function f(e){try{const t=new URLSearchParams(e);return t.has("code")&&t.has("state")}catch{return!1}}const m="bb_pending_checkout";function h(){try{return"undefined"==typeof window?null:window.sessionStorage}catch{return null}}const y="bb_co";function w(){try{return"undefined"==typeof window?null:window.document??null}catch{return null}}function v(){const e=w();if(e)try{const t=d(window.location?.hostname??"",e);e.cookie=`${y}=; path=/; max-age=0; SameSite=Lax`+(t?`; domain=${t}`:"")}catch{}}function _(e,t){if(!e)return null;try{const n=JSON.parse(e);return n&&"string"==typeof n.eventId&&n.eventId?"number"!=typeof n.startedAt||t-n.startedAt>216e5?null:n:null}catch{return null}}function k(e=Date.now()){const t=h();if(!t)return null;let n=null;try{n=t.getItem(m),t.removeItem(m)}catch{return null}const r=_(n,e);return r&&v(),r}function b(e){try{return _(h()?.getItem(m)??null,e)}catch{return null}}function I(e,t=Date.now()){let n=null;try{n=new URLSearchParams(e).get("session_id")}catch{return null}if(!n)return null;const r=b(t);if(r?.sessionId===n)return k(t);const i=function(e){const t=w();if(!t||"string"!=typeof t.cookie)return null;const n=t.cookie.split("; ").find(e=>e.startsWith(`${y}=`));return n?_(decodeURIComponent(n.slice(6)),e):null}(t);return i?.sessionId!==n?null:(v(),i)}function C(e,t=Date.now()){return function(e){let t=null;try{t=new URLSearchParams(e).get("bb")}catch{return!1}if(!t)return!1;const n={};for(const e of t.split(",")){const t=e.indexOf(":");if(-1!==t)try{n[decodeURIComponent(e.slice(0,t))]=decodeURIComponent(e.slice(t+1))}catch{}}return"checkout"===n.action&&"cancel"===n.status}(e)&&b(t)?k(t):null}const x=new Set(["bif","clp","djf","gnf","jpy","kmf","krw","mga","pyg","rwf","ugx","vnd","vuv","xaf","xof","xpf"]),$=new Set(["bhd","jod","kwd","omr","tnd"]);function j(e,t){if("number"!=typeof e||!Number.isFinite(e))return;const n=(t??"").toLowerCase();return x.has(n)?e:e/($.has(n)?1e3:100)}function A(){return"undefined"==typeof window?null:window}function S(e){const t=A();if(!t)return;t.gtag?.("consent","update",{ad_storage:e.marketing?"granted":"denied",ad_user_data:e.marketing?"granted":"denied",ad_personalization:e.marketing?"granted":"denied",analytics_storage:e.analytics?"granted":"denied"});const n=t.fbq;n?.("consent",e.marketing?"grant":"revoke")}const q={gtm:{title:"Google Tag Manager",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Container ID",idPattern:"^GTM-[A-Z0-9]{4,10}$",idExample:"GTM-ABC1234",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"analytics",supportsConsentMode:!0,needsConversionIds:!1},ga4:{title:"Google Analytics 4",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Measurement ID",idPattern:"^G-[A-Z0-9]{8,12}$",idExample:"G-ABCD123456",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"analytics",supportsConsentMode:!0,needsConversionIds:!1},google_ads:{title:"Google Ads",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Conversion ID",idPattern:"^AW-[0-9]{9,12}$",idExample:"AW-123456789",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"marketing",supportsConsentMode:!0,needsConversionIds:!0},meta_pixel:{title:"Meta Pixel",vendor:"Meta Platforms Ireland Limited",privacyUrl:"https://www.facebook.com/privacy/policy",idLabel:"Pixel ID",idPattern:"^[0-9]{15,16}$",idExample:"123456789012345",scriptOrigin:"https://connect.facebook.net",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},x_pixel:{title:"X (Twitter) Pixel",vendor:"X Corp.",privacyUrl:"https://x.com/en/privacy",idLabel:"Pixel ID",idPattern:"^o[a-z0-9]{4,6}$",idExample:"o1a2b3",scriptOrigin:"https://static.ads-twitter.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!0,multiInstance:!0},linkedin:{title:"LinkedIn Insight Tag",vendor:"LinkedIn Ireland Unlimited Company",privacyUrl:"https://www.linkedin.com/legal/privacy-policy",idLabel:"Partner ID",idPattern:"^[0-9]{6,9}$",idExample:"1234567",scriptOrigin:"https://snap.licdn.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!0,multiInstance:!0},tiktok:{title:"TikTok Pixel",vendor:"TikTok Information Technologies UK Limited",privacyUrl:"https://www.tiktok.com/legal/privacy-policy",idLabel:"Pixel ID",idPattern:"^[A-Z0-9]{20}$",idExample:"C4A1B2C3D4E5F6G7H8I9",scriptOrigin:"https://analytics.tiktok.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},reddit:{title:"Reddit Pixel",vendor:"Reddit, Inc.",privacyUrl:"https://www.reddit.com/policies/privacy-policy",idLabel:"Advertiser ID",idPattern:"^t2_[a-z0-9]{4,12}$",idExample:"t2_abc123",scriptOrigin:"https://www.redditstatic.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},bing_uet:{title:"Microsoft Advertising (UET)",vendor:"Microsoft Corporation",privacyUrl:"https://privacy.microsoft.com/en-us/privacystatement",idLabel:"Tag ID",idPattern:"^[0-9]{7,9}$",idExample:"12345678",scriptOrigin:"https://bat.bing.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},clarity:{title:"Microsoft Clarity",vendor:"Microsoft Corporation",privacyUrl:"https://privacy.microsoft.com/en-us/privacystatement",idLabel:"Project ID",idPattern:"^[a-z0-9]{10}$",idExample:"ab12cd34ef",scriptOrigin:"https://www.clarity.ms",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},hotjar:{title:"Hotjar",vendor:"Hotjar Limited",privacyUrl:"https://www.hotjar.com/legal/policies/privacy/",idLabel:"Site ID",idPattern:"^[0-9]{6,9}$",idExample:"1234567",scriptOrigin:"https://static.hotjar.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},posthog:{title:"PostHog",vendor:"PostHog, Inc.",privacyUrl:"https://posthog.com/privacy",idLabel:"Project API key",idPattern:"^phc_[A-Za-z0-9]{32,48}$",idExample:"phc_abcdefghijklmnopqrstuvwxyz012345",scriptOrigin:"https://us-assets.i.posthog.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1,hosts:["us.i.posthog.com","eu.i.posthog.com"]},plausible:{title:"Plausible Analytics",vendor:"Plausible Insights OÜ",privacyUrl:"https://plausible.io/privacy",idLabel:"Domain",idPattern:"^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$",idExample:"example.com",scriptOrigin:"https://plausible.io",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},ahrefs:{title:"Ahrefs Analytics",vendor:"Ahrefs Pte. Ltd.",privacyUrl:"https://ahrefs.com/privacy",idLabel:"Analytics key",idPattern:"^[A-Za-z0-9+/=]{20,64}$",idExample:"AbCdEfGhIjKlMnOpQrStUv==",scriptOrigin:"https://analytics.ahrefs.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1}},P=Object.keys(q);function E(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(q,e)}function O(e,t){return!!E(e)&&("string"==typeof t&&0!==t.length&&new RegExp(q[e].idPattern).test(t))}const T=/^[a-z][a-z0-9-]{0,40}$/,U=/^[\w.:/@+=-]{1,200}$/;function L(e){return function(e){if("string"!=typeof e)return!1;if(0===e.length||e.length>300)return!1;let t;try{t=new URL(e)}catch{return!1}return!("https:"!==t.protocol||!t.hostname||!t.hostname.includes(".")||e.includes("?")||e.includes("#")||t.username||t.password)}(e.src)&&function(e){if(null==e)return!0;if("object"!=typeof e||Array.isArray(e))return!1;const t=Object.entries(e);return!(t.length>12)&&t.every(([e,t])=>T.test(e)&&"string"==typeof t&&U.test(t))}(e.dataAttributes)}const R=Array.from(new Set(P.map(e=>q[e].scriptOrigin))).sort(),M={sign_up:{ga4:"sign_up",meta:"CompleteRegistration",tiktok:"CompleteRegistration",reddit:"SignUp"},login:{ga4:"login",meta:null,tiktok:null,reddit:null},trial_started:{ga4:"begin_checkout",meta:"StartTrial",tiktok:"StartTrial",reddit:"Lead"},checkout_started:{ga4:"begin_checkout",meta:"InitiateCheckout",tiktok:"InitiateCheckout",reddit:"AddToCart"},purchase:{ga4:"purchase",meta:"Purchase",tiktok:"CompletePayment",reddit:"Purchase"},subscription_created:{ga4:"purchase",meta:"Subscribe",tiktok:"Subscribe",reddit:"Purchase"},subscription_upgraded:{ga4:"subscription_upgraded",meta:null,tiktok:null,reddit:null},lead:{ga4:"generate_lead",meta:"Lead",tiktok:"SubmitForm",reddit:"Lead"},workspace_created:{ga4:"workspace_created",meta:null,tiktok:null,reddit:null}},D=Object.keys(M);function N(e){return D.includes(e)}function B(){return"undefined"==typeof window?null:window}const G={gtm:"dataLayer",ga4:"gtag",google_ads:"gtag",meta_pixel:"fbq",x_pixel:"twq",linkedin:"lintrk",tiktok:"ttq",reddit:"rdt",bing_uet:"uetq",clarity:"clarity",hotjar:"hj",posthog:"posthog",plausible:"plausible",ahrefs:"__ahrefs_loaded"};function V(){return"undefined"==typeof window?null:window}function z(e,t={}){const n=V();if(!n)return null;const r=n.document.createElement("script");r.async=!0,r.src=e;for(const[e,n]of Object.entries(t))r.setAttribute(e,n);return n.document.head.appendChild(r),r}function F(e){const t=V();if(!t)return;const n=t.document.createElement("script");n.text=e,t.document.head.appendChild(n)}function H(e){const t=V();t&&(Array.isArray(t[e])||(t[e]=[]),"function"!=typeof t.gtag&&(t.gtag=function(){t[e].push(arguments)}))}const W=new Set;function Z(e){for(const t of W)if(t.slice(0,t.indexOf(":"))===e)return!0;return!1}function J(e,t){const n=V();if(!n)return!1;if("gtm"===e||"ga4"===e||"google_ads"===e){const e=n.google_tag_manager;return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,t)}const r=G[e];if(!r)return!1;if(void 0===n[r])return!1;if(W.has(`${e}:${t}`))return!0;return!q[e].multiInstance||!Z(e)}const K={meta_pixel:e=>`fbq('init','${e}');fbq('track','PageView');`,x_pixel:e=>`twq('config','${e}');`,tiktok:e=>`ttq.load('${e}');ttq.page();`,reddit:e=>`rdt('init','${e}');rdt('track','PageVisit');`,bing_uet:e=>`window.uetq=window.uetq||[];window.uetq.push({ti:'${e}',enableAutoSpaTracking:false});`,linkedin:e=>`window._linkedin_data_partner_ids=window._linkedin_data_partner_ids||[];window._linkedin_data_partner_ids.push('${e}');`};function Q(e,t,n){const r=function(e,t,n){const r=V();if(!r)return!1;if("external"===e.provider){if(!e.src)return!1;const t={};for(const[n,r]of Object.entries(e.dataAttributes??{}))t[`data-${n}`]=r;return z(e.src,t),!0}const i=e.provider,o=q[i];if(!o)return!1;const a=e.providerId;if(!a)return!1;const s=K[i];if(s&&Z(i))return F(s(a)),!0;switch(i){case"gtm":{H(t),r[t].push({"gtm.start":Date.now(),event:"gtm.js"});const e="dataLayer"===t?"":`&l=${t}`;return z(`${o.scriptOrigin}/gtm.js?id=${a}${e}`),!0}case"ga4":case"google_ads":{H(t),z(`${o.scriptOrigin}/gtag/js?id=${a}`);const e=r.gtag;e("js",new Date);const s="ga4"===i&&n?.gaClientId?{client_id:n.gaClientId}:void 0;return s?e("config",a,s):e("config",a),!0}case"meta_pixel":return F(`!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','${o.scriptOrigin}/en_US/fbevents.js');fbq('init','${a}');fbq('track','PageView');`),!0;case"x_pixel":return F(`!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments)},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='${o.scriptOrigin}/uwt.js',a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');twq('config','${a}');`),!0;case"linkedin":return F(`window._linkedin_partner_id='${a}';window._linkedin_data_partner_ids=window._linkedin_data_partner_ids||[];window._linkedin_data_partner_ids.push('${a}');window.lintrk=window.lintrk||function(a,b){(window.lintrk.q=window.lintrk.q||[]).push([a,b])};window.lintrk.q=window.lintrk.q||[];`),z(`${o.scriptOrigin}/li.lms-analytics/insight.min.js`),!0;case"tiktok":return F(`!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=['page','track','identify','instances','debug','on','off','once','ready','alias','group','enableCookie','disableCookie'];ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.load=function(e,n){var r='${o.scriptOrigin}/i18n/pixel/events.js';ttq._i=ttq._i||{};ttq._i[e]=[];ttq._i[e]._u=r;ttq._t=ttq._t||{};ttq._t[e]=+new Date;ttq._o=ttq._o||{};ttq._o[e]=n||{};var o=d.createElement('script');o.type='text/javascript';o.async=!0;o.src=r+'?sdkid='+e+'&lib='+t;var a=d.getElementsByTagName('script')[0];a.parentNode.insertBefore(o,a)};ttq.load('${a}');ttq.page()}(window,document,'ttq');`),!0;case"reddit":return F(`!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement('script');t.src='${o.scriptOrigin}/ads/pixel.js';t.async=!0;var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','${a}');rdt('track','PageVisit');`),!0;case"bing_uet":return F(`(function(w,d,t,r,u){w[u]=w[u]||[];w[u].push({ti:'${a}',enableAutoSpaTracking:false});var o=d.createElement(t);o.src='${o.scriptOrigin}/bat.js';o.async=1;var i=d.getElementsByTagName(t)[0];i.parentNode.insertBefore(o,i)})(window,document,'script',0,'uetq');`),!0;case"clarity":return F(`(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src='${o.scriptOrigin}/tag/'+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y)})(window,document,'clarity','script','${a}');`),!0;case"hotjar":return F(`(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:${a},hjsv:6};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src='${o.scriptOrigin}/hotjar-'+h._hjSettings.hjid+'.js?sv='+h._hjSettings.hjsv;a.appendChild(r)})(window,document);`),!0;case"posthog":{const t=o.hosts,n=t?.includes(e.host??"")?e.host:t?.[0]??"us.i.posthog.com";return F(`!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split('.');2==o.length&&(t=t[o[0]],e=o[1]);t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement('script')).type='text/javascript',p.async=!0,p.src='${o.scriptOrigin}/static/array.js',(r=t.getElementsByTagName('script')[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a='posthog',u.people=u.people||[],u.toString=function(t){var e='posthog';return'posthog'!==a&&(e+='.'+a),t||(e+=' (stub)'),e},u.people.toString=function(){return u.toString(1)+'.people (stub)'},o='init capture register register_once identify alias people.set people.set_once set_config get_distinct_id getFeatureFlag isFeatureEnabled onFeatureFlags reloadFeatureFlags group reset'.split(' '),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);posthog.init('${a}',{api_host:'https://${n}'});`),!0}case"plausible":return F("window.plausible=window.plausible||function(){(window.plausible.q=window.plausible.q||[]).push(arguments)};"),z(`${o.scriptOrigin}/js/script.js`,{"data-domain":a,defer:"true"}),!0;case"ahrefs":return z(`${o.scriptOrigin}/analytics.js`,{"data-key":a}),r.__ahrefs_loaded=!0,!0;default:return!1}}(e,t,n);return r&&"external"!==e.provider&&e.providerId&&W.add(`${e.provider}:${e.providerId}`),r}const X=Symbol.for("@buildbase/sdk.tracking.context"),Y=globalThis,ee=Y[X]??(Y[X]=t.createContext(null)),te={consent:{manifest:[],state:null,set:()=>{}},track:()=>{},setUser:()=>{},setProperties:()=>{},getProperties:()=>({}),completeCheckout:async()=>{},installed:{},ready:!0,attribution:{}};function ne(){return t.useContext(ee)??te}const re=({serverUrl:n,orgId:r,clientId:o,enabled:a=!0,consent:s="auto",autoPageview:c=!0,events:d,onEvent:l,properties:u,enrich:p,identity:m,debug:h=!1,children:y})=>{const w=t.useRef(m);w.current=m;const[v,_]=t.useState(null),[k,b]=t.useState(!1),[x,$]=t.useState(!1),P="granted"===s?{analytics:!0,marketing:!0}:"denied"===s?{analytics:!1,marketing:!1}:null,[T,U]=t.useState(P),R=t.useRef(null),D=t.useRef(l);D.current=l;const G=t.useRef(p);G.current=p;const V=t.useRef({});V.current=u??{};const z=t.useRef({}),F=t.useCallback(()=>({...V.current,...z.current}),[]),W=t.useCallback(e=>{const t={...z.current,...e};for(const[e,n]of Object.entries(t))void 0===n&&delete t[e];z.current=t},[]),[Z,K]=t.useState({}),X=t.useRef({}),[Y,te]=t.useState(0),ne=v?.dataLayerName??"dataLayer",re=t.useCallback((...e)=>{h&&console.info("[buildbase:tracking]",...e)},[h]);t.useEffect(()=>{return e=()=>{0!==Object.keys(X.current).length&&window.dispatchEvent("function"==typeof PageTransitionEvent?new PageTransitionEvent("pagehide",{persisted:!1}):new Event("pagehide"))},i.add(e),()=>{i.delete(e)};var e},[]),t.useEffect(()=>{if(!(a&&n&&r&&o))return void b(!0);let e=!1;const t=`${n.replace(/\/$/,"")}/api/v1/public/${r}/tracking?clientId=${encodeURIComponent(o)}`;return fetch(t).then(e=>e.ok?e.json():null).then(t=>{if(e||!t)return;const n=t.data??t;n&&Array.isArray(n.scripts)&&_(n)}).catch(()=>{re("config fetch failed; nothing installed")}).finally(()=>{e||b(!0)}),()=>{e=!0}},[a,n,r,o,re]),t.useEffect(()=>{a&&K(g())},[a]),t.useEffect(()=>{a&&v?.enabled&&(H(ne),function(e,t){const n=A();if(!n)return;Array.isArray(n[e])||(n[e]=[]),"function"!=typeof n.gtag&&(n.gtag=function(){n[e].push(arguments)});const r="granted"===t?"granted":"denied";n.gtag("consent","default",{ad_storage:r,ad_user_data:r,ad_personalization:r,analytics_storage:r,wait_for_update:500})}(ne,s),R.current&&S(R.current))},[a,v?.enabled,ne,s]);const ie=t.useMemo(()=>v?.enabled?v.scripts.filter(e=>{const t=E(e.provider)&&q[e.provider].supportsConsentMode;return function(e,t,n,r){return"denied"!==r&&("granted"===r||(n?"marketing"===e?n.marketing:n.analytics:t&&"analytics"===e))}(e.consentCategory,t,T,s)}):[],[v,T,s]),[oe,ae]=t.useState(()=>"undefined"==typeof window||!f(window.location.search));t.useEffect(()=>{if(oe)return;const e=setInterval(()=>{f(window.location.search)||ae(!0)},50),t=setTimeout(()=>ae(!0),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[oe]),t.useEffect(()=>{if(!oe)return;if(!a||!v?.enabled)return void(k&&$(!0));let e=0;for(const t of ie)if(!X.current[t.key]){if("external"===t.provider){if(!L({src:t.src,dataAttributes:t.dataAttributes})){re("rejected external script",t.key);continue}}else{if(!E(t.provider)){re("rejected unknown provider",t.provider);continue}if(!O(t.provider,t.providerId)){re("rejected id for",t.provider);continue}if(J(t.provider,t.providerId??"")){re(`${t.provider} ${t.providerId} is already on the page; skipping. Configure each tag in exactly one place.`);continue}}Q(t,ne,w.current)&&(X.current[t.key]=t.providerId??t.src??"",e+=1,re("installed",t.key))}e&&te(e=>e+1);const t=window;t.__buildbase=t.__buildbase??{},t.__buildbase.tracking={installed:{...X.current},dataLayerName:ne,clientId:o};const n=Object.keys(X.current).length>0,r=null!==T||0===v.scripts.length;(n||r)&&$(!0)},[a,v,ie,k,T,ne,re,oe,o]),t.useEffect(()=>{if(!a||!c||!v?.enabled)return;if("undefined"==typeof window)return;if(!oe)return;let e=null;const t=()=>{e&&clearTimeout(e),e=setTimeout(()=>function(e,t){const n=B();if(!n)return;const r=n[t];Array.isArray(r)&&r.push({event:"page_view",page_path:n.location.pathname,page_location:n.location.href,page_title:n.document.title});for(const t of e)switch(t.provider){case"ga4":n.gtag?.("event","page_view",{send_to:t.providerId,page_path:n.location.pathname,page_location:n.location.href,page_title:n.document.title});break;case"meta_pixel":n.fbq?.("track","PageView");break;case"tiktok":{const e=n.ttq;e?.page?.();break}case"reddit":n.rdt?.("track","PageVisit")}}(ie,ne),50)},n=window.history,r=n.pushState,i=n.replaceState;return n.pushState=function(...e){const n=r.apply(this,e);return t(),n},n.replaceState=function(...e){const n=i.apply(this,e);return t(),n},window.addEventListener("popstate",t),()=>{n.pushState=r,n.replaceState=i,window.removeEventListener("popstate",t),e&&clearTimeout(e)}},[a,c,v?.enabled,ie,ne,oe]),t.useEffect(()=>{if(!a)return;const e=function(e,t){const n=e?.mode??"auto",r=e?.overrides??{};if(("manual"===n||Object.values(r).some(e=>"manual"===e))&&!t)return'[buildbase:tracking] events are set to "manual" but no onEvent handler was provided, so those events would never fire anywhere. Pass onEvent, or use mode "auto".';for(const e of Object.keys(r))if(!N(e))return`[buildbase:tracking] unknown event "${e}" in events.overrides. Overrides only apply to the events the SDK fires itself.`;return null}(d,!!l);if(e)throw new Error(e)},[a,d,l]);const se=t.useCallback((e,t={},n)=>{if(!a)return;const r=n?.eventId||function(){const e=globalThis.crypto;return e?.randomUUID?e.randomUUID():`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}(),i=d?.mode??"auto",o=(N(e)?d?.overrides?.[e]:void 0)??i,s={...V.current,...z.current,...Z,...t},c=G.current?.({name:e,params:s})??{},l={...s,...c},u=D.current?.({name:e,params:l,eventId:r,handledBy:o});"manual"!==o&&!0!==u?(!function(e,t,n,r,i){const o=B();if(!o)return;const a=o[i];Array.isArray(a)&&a.push({event:e,...t,event_id:n});const s=N(e)?M[e]:{ga4:e,meta:null,tiktok:null,reddit:null};for(const i of r){const r=i.provider,a=q[r];if(a){if(a.needsConversionIds){const a=i.conversionIds?.[e];if(!a)continue;"google_ads"===r?o.gtag?.("event","conversion",{send_to:`${i.providerId}/${a}`,transaction_id:n,...t}):"x_pixel"===r?o.twq?.("event",a,{...t,conversion_id:n}):"linkedin"===r&&o.lintrk?.("track",{conversion_id:a});continue}switch(r){case"ga4":s.ga4&&o.gtag?.("event",s.ga4,{...t,send_to:i.providerId,event_id:n});break;case"meta_pixel":s.meta&&o.fbq?.("track",s.meta,t,{eventID:n});break;case"tiktok":if(s.tiktok){const e=o.ttq;e?.track?.(s.tiktok,{...t,event_id:n})}break;case"reddit":s.reddit&&o.rdt?.("track",s.reddit,{...t,conversionId:n});break;case"bing_uet":{const r=o.uetq;r?.push?.("event",s.ga4??e,{...t,event_id:n});break}case"clarity":o.clarity?.("event",e);break;case"hotjar":{const t=o.hj;t?.("event",e);break}case"posthog":{const r=o.posthog;r?.capture?.(e,{...t,event_id:n});break}case"plausible":o.plausible?.(e,{props:t})}}}}(e,l,r,ie,ne),re("event fired:",e,r)):re("event handled by app:",e)},[a,d,ie,ne,Z,re]),ce=t.useCallback(async(e,t={})=>{const i=function(e){return{name:"trial_started"===e.kind?"trial_started":"purchase",params:{...e.workspaceId?{workspace_id:e.workspaceId}:{},...e.planVersionId?{plan_version_id:e.planVersionId}:{},...e.creditPackageId?{credit_package_id:e.creditPackageId}:{},...e.billingInterval?{billing_interval:e.billingInterval}:{},...e.currency?{currency:e.currency.toUpperCase()}:{},..."number"==typeof e.value?{value:e.value}:{},...e.sessionId?{transaction_id:e.sessionId}:{}}}}(e);let o=i.params;if(e.sessionId&&n&&r){const t=await async function(e,t){try{const n=e.serverUrl.replace(/\/$/,""),r=await fetch(`${n}/api/v1/public/${encodeURIComponent(e.orgId)}/checkout/${encodeURIComponent(t)}`,{credentials:"omit",..."undefined"!=typeof AbortSignal&&AbortSignal.timeout?{signal:AbortSignal.timeout(2e3)}:{}});if(!r.ok)return null;const i=await r.json(),o=i?.data??i;return"number"!=typeof o?.amount?null:{value:j(o.amount,o.currency),currency:"string"==typeof o.currency?o.currency:void 0,...Array.isArray(o.items)&&o.items.length?{items:o.items}:{}}}catch{return null}}({serverUrl:n,orgId:r},e.sessionId);t&&"number"==typeof t.value&&(o={...o,value:t.value,...t.currency?{currency:t.currency.toUpperCase()}:{},...t.items?.length?{items:t.items}:{}})}if(se(i.name,{...o,...t},{eventId:e.eventId}),"purchase"===i.name&&e.sessionId&&n&&r){const t=(v?.scripts??[]).find(e=>"ga4"===e.provider&&e.providerId);t&&J("ga4",t.providerId??"")&&function(e,t,n){try{const r=e.serverUrl.replace(/\/$/,"");fetch(`${r}/api/v1/public/${encodeURIComponent(e.orgId)}/checkout/${encodeURIComponent(t)}/reported`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n}),keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}({serverUrl:n,orgId:r},e.sessionId,"ga4")}},[n,r,se,v]),[de]=t.useState(()=>"undefined"==typeof window?"":window.location.search);t.useEffect(()=>{if(!a||!x)return;if("undefined"==typeof window)return;const e=I(window.location.search);if(e)return void ce(e);const t=C(de);t&&se("checkout_abandoned",{...t.workspaceId?{workspace_id:t.workspaceId}:{},...t.planVersionId?{plan_version_id:t.planVersionId}:{},...t.creditPackageId?{credit_package_id:t.creditPackageId}:{},...t.billingInterval?{billing_interval:t.billingInterval}:{},...t.currency?{currency:t.currency.toUpperCase()}:{},..."number"==typeof t.value?{value:t.value}:{},seconds_at_checkout:Math.max(0,Math.round((Date.now()-t.startedAt)/1e3))})},[a,x,ce,de,se]);const le=t.useCallback(e=>{R.current=e,U(e),S(e)},[]),ue=t.useCallback((e,t)=>function(e,t,n){const r=B();if(!r)return;const i=!!n&&Object.keys(n).length>0;for(const o of t)switch(o.provider){case"ga4":case"google_ads":r.gtag?.("set",{user_id:e}),i&&r.gtag?.("set",{user_properties:n});break;case"meta_pixel":o.providerId&&r.fbq?.("init",o.providerId,{external_id:e});break;case"posthog":r.posthog?.identify?.(e,i?n:void 0);break;case"clarity":if(r.clarity?.("identify",e),i)for(const[e,t]of Object.entries(n))r.clarity?.("set",e,String(t));break;case"hotjar":r.hj?.("identify",e,{});break;case"tiktok":{const t=r.ttq;t?.identify?.({external_id:e});break}}}(e,ie,t),[ie]),pe=t.useMemo(()=>({consent:{manifest:v?.consent?.manifest??[],state:T,set:le},track:se,setUser:ue,setProperties:W,getProperties:F,completeCheckout:ce,installed:{...X.current},ready:x,attribution:Z}),[v,T,le,se,ue,W,F,ce,x,Y,Z]);return e.jsx(ee.Provider,{value:pe,children:y})};re.displayName="BuildBaseTracking";exports.ATTRIBUTION_PARAMS=a,exports.BuildBaseTracking=re,exports.EVENT_MAPPINGS=M,exports.FUNNEL_EVENTS={sign_in_started:"The sign-in / sign-up button was pressed.",pricing_viewed:"A <PricingPage> finished loading its plans.",pricing_plan_selected:"A plan was chosen on a <PricingPage>.",workspace_switcher_opened:"The workspace switcher was opened.",workspace_settings_opened:"The workspace settings modal was opened.",workspace_settings_section_viewed:"A different section of the settings modal was opened.",plan_picker_opened:"The plan picker was shown.",billing_interval_changed:"Monthly / quarterly / yearly was switched in the plan picker.",plan_selected:"A plan was chosen in the plan picker.",plan_picker_dismissed:"The plan picker was closed without choosing a plan.",checkout_abandoned:"The customer came back from Stripe without paying.",billing_portal_opened:"Stripe’s billing portal was opened.",subscription_cancel_started:"The cancel-subscription confirmation was opened.",subscription_cancelled:"A subscription was cancelled.",subscription_resumed:"A cancelled subscription was resumed.",feature_gate_shown:'A feature gate rendered its "not on your plan" side.',quota_limit_reached:"A quota gate rendered because a quota is used up.",quota_threshold_reached:"A usage-threshold gate rendered.",plan_gate_shown:'A plan gate rendered its "needs another plan" side.',subscription_notice_shown:"A billing notice (trial ending, payment failed…) was shown.",sdk_error:"An SDK operation failed (component, action and code only)."},exports.TAG_PROVIDERS=q,exports.TAG_PROVIDER_IDS=P,exports.TAG_SCRIPT_ORIGINS=R,exports.captureAttribution=g,exports.getAttribution=function(){const e=c();return e?l(e.document):{}},exports.isCanonicalEvent=N,exports.isTagProviderId=E,exports.isValidProviderId=O,exports.useCheckoutCompleted=function(e={}){const{completeCheckout:n,ready:r}=ne(),i=t.useRef(e);i.current=e;const o=t.useRef(!1);t.useEffect(()=>{if(!r)return;if(o.current)return;const e=I(window.location.search)??k();e&&(o.current=!0,n(e,i.current))},[r,n])},exports.useTracking=ne;
@@ -42,11 +42,23 @@ type Attribution = Partial<Record<AttributionParam, string>>;
42
42
  /**
43
43
  * Capture what this page arrived with, and return everything known so far.
44
44
  *
45
- * First touch wins for any given parameter. A visitor who arrives on an ad,
46
- * comes back later through a newsletter, and only then signs up should still
47
- * credit the ad - overwriting on the second visit would quietly reassign every
48
- * conversion to whatever the last touch happened to be. New parameters are
49
- * still added, so a later campaign tag enriches rather than replaces.
45
+ * One visit is one record. The stored value is always the whole set a single
46
+ * landing carried - never one parameter from this visit and another from an
47
+ * earlier one. It used to merge per parameter, first value winning, and a
48
+ * second ad click then kept the first click's `gclid` beside the second's
49
+ * `utm_campaign`: one record describing two clicks, so Google Ads was sent one
50
+ * click while GA4 showed the other campaign. Found on our own site.
51
+ *
52
+ * Which visit the record describes:
53
+ *
54
+ * - A visit with a click id replaces it. The newest ad click is the one the ad
55
+ * platforms credit, and a click id kept from months ago can have aged out of
56
+ * the platform's window and count for nothing.
57
+ * - A visit with only UTM tags never replaces a stored click id. A visitor who
58
+ * arrives on an ad, comes back through a newsletter and then signs up still
59
+ * credits the ad - the newsletter link carries no click id to match on.
60
+ * - Otherwise a campaign visit replaces a campaign-only record, whole.
61
+ * - A visit with nothing on the URL changes nothing.
50
62
  */
51
63
  declare function captureAttribution(): Attribution;
52
64
  /** What is stored, without touching the URL. */
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e}from"react/jsx-runtime";import{useRef as t,useState as n,useCallback as r,useEffect as i,useMemo as o,useContext as a,createContext as s}from"react";const c="__buildbaseBeforeLeave",d=globalThis,l=d[c]??(d[c]=new Set);const u="bb_attr",p=["gclid","gbraid","wbraid","dclid","fbclid","msclkid","li_fat_id","twclid","ttclid","rdt_cid","epik","irclickid","utm_source","utm_medium","utm_campaign","utm_term","utm_content","utm_id"],g=/^[\w.~-]{1,200}$/;function f(){return"undefined"==typeof window?null:window}function m(e,t){if(!e||!e.includes("."))return"";if(/^\d{1,3}(\.\d{1,3}){3}$/.test(e))return"";const n=t??f()?.document;if(!n)return"";const r=e.split(".");for(let e=r.length-2;e>=0;e--){const t="."+r.slice(e).join("."),i=`__bb_probe_${Date.now()}`;n.cookie=`${i}=1; domain=${t}; path=/; SameSite=Lax`;const o=n.cookie.includes(`${i}=1`);if(n.cookie=`${i}=; domain=${t}; path=/; max-age=0; SameSite=Lax`,o)return t}return""}function h(e){const t=e.cookie.split("; ").find(e=>e.startsWith(`${u}=`));if(!t)return{};try{const e=JSON.parse(decodeURIComponent(t.slice(8)));return"object"==typeof e&&e?e:{}}catch{return{}}}function y(){const e=f();if(!e)return{};const t=e.document,n=h(t),r={...function(e){const t=new URLSearchParams(e),n={};for(const e of p){const r=t.get(e);r&&(r.length>200||g.test(r)&&(n[e]=r))}return n}(e.location.search),...n};if(0===Object.keys(r).length)return{};return Object.keys(r).some(e=>void 0===n[e])&&function(e,t,n){const r=encodeURIComponent(JSON.stringify(t));e.cookie=`${u}=${r}; path=/; max-age=7776000; SameSite=Lax`+(n?`; domain=${n}`:"")}(t,r,m(e.location.hostname,t)),r}function w(){const e=f();return e?h(e.document):{}}function v(e){try{const t=new URLSearchParams(e);return t.has("code")&&t.has("state")}catch{return!1}}const _="bb_pending_checkout";function k(){try{return"undefined"==typeof window?null:window.sessionStorage}catch{return null}}const b="bb_co";function I(){try{return"undefined"==typeof window?null:window.document??null}catch{return null}}function C(){const e=I();if(e)try{const t=m(window.location?.hostname??"",e);e.cookie=`${b}=; path=/; max-age=0; SameSite=Lax`+(t?`; domain=${t}`:"")}catch{}}function $(e,t){if(!e)return null;try{const n=JSON.parse(e);return n&&"string"==typeof n.eventId&&n.eventId?"number"!=typeof n.startedAt||t-n.startedAt>216e5?null:n:null}catch{return null}}function j(e=Date.now()){const t=k();if(!t)return null;let n=null;try{n=t.getItem(_),t.removeItem(_)}catch{return null}const r=$(n,e);return r&&C(),r}function x(e){try{return $(k()?.getItem(_)??null,e)}catch{return null}}function q(e,t=Date.now()){let n=null;try{n=new URLSearchParams(e).get("session_id")}catch{return null}if(!n)return null;const r=x(t);if(r?.sessionId===n)return j(t);const i=function(e){const t=I();if(!t||"string"!=typeof t.cookie)return null;const n=t.cookie.split("; ").find(e=>e.startsWith(`${b}=`));return n?$(decodeURIComponent(n.slice(6)),e):null}(t);return i?.sessionId!==n?null:(C(),i)}function A(e,t=Date.now()){return function(e){let t=null;try{t=new URLSearchParams(e).get("bb")}catch{return!1}if(!t)return!1;const n={};for(const e of t.split(",")){const t=e.indexOf(":");if(-1!==t)try{n[decodeURIComponent(e.slice(0,t))]=decodeURIComponent(e.slice(t+1))}catch{}}return"checkout"===n.action&&"cancel"===n.status}(e)&&x(t)?j(t):null}const P=new Set(["bif","clp","djf","gnf","jpy","kmf","krw","mga","pyg","rwf","ugx","vnd","vuv","xaf","xof","xpf"]),S=new Set(["bhd","jod","kwd","omr","tnd"]);function O(e,t){if("number"!=typeof e||!Number.isFinite(e))return;const n=(t??"").toLowerCase();return P.has(n)?e:e/(S.has(n)?1e3:100)}function E(){return"undefined"==typeof window?null:window}function U(e){const t=E();if(!t)return;t.gtag?.("consent","update",{ad_storage:e.marketing?"granted":"denied",ad_user_data:e.marketing?"granted":"denied",ad_personalization:e.marketing?"granted":"denied",analytics_storage:e.analytics?"granted":"denied"});const n=t.fbq;n?.("consent",e.marketing?"grant":"revoke")}const L={gtm:{title:"Google Tag Manager",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Container ID",idPattern:"^GTM-[A-Z0-9]{4,10}$",idExample:"GTM-ABC1234",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"analytics",supportsConsentMode:!0,needsConversionIds:!1},ga4:{title:"Google Analytics 4",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Measurement ID",idPattern:"^G-[A-Z0-9]{8,12}$",idExample:"G-ABCD123456",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"analytics",supportsConsentMode:!0,needsConversionIds:!1},google_ads:{title:"Google Ads",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Conversion ID",idPattern:"^AW-[0-9]{9,12}$",idExample:"AW-123456789",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"marketing",supportsConsentMode:!0,needsConversionIds:!0},meta_pixel:{title:"Meta Pixel",vendor:"Meta Platforms Ireland Limited",privacyUrl:"https://www.facebook.com/privacy/policy",idLabel:"Pixel ID",idPattern:"^[0-9]{15,16}$",idExample:"123456789012345",scriptOrigin:"https://connect.facebook.net",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},x_pixel:{title:"X (Twitter) Pixel",vendor:"X Corp.",privacyUrl:"https://x.com/en/privacy",idLabel:"Pixel ID",idPattern:"^o[a-z0-9]{4,6}$",idExample:"o1a2b3",scriptOrigin:"https://static.ads-twitter.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!0,multiInstance:!0},linkedin:{title:"LinkedIn Insight Tag",vendor:"LinkedIn Ireland Unlimited Company",privacyUrl:"https://www.linkedin.com/legal/privacy-policy",idLabel:"Partner ID",idPattern:"^[0-9]{6,9}$",idExample:"1234567",scriptOrigin:"https://snap.licdn.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!0,multiInstance:!0},tiktok:{title:"TikTok Pixel",vendor:"TikTok Information Technologies UK Limited",privacyUrl:"https://www.tiktok.com/legal/privacy-policy",idLabel:"Pixel ID",idPattern:"^[A-Z0-9]{20}$",idExample:"C4A1B2C3D4E5F6G7H8I9",scriptOrigin:"https://analytics.tiktok.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},reddit:{title:"Reddit Pixel",vendor:"Reddit, Inc.",privacyUrl:"https://www.reddit.com/policies/privacy-policy",idLabel:"Advertiser ID",idPattern:"^t2_[a-z0-9]{4,12}$",idExample:"t2_abc123",scriptOrigin:"https://www.redditstatic.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},bing_uet:{title:"Microsoft Advertising (UET)",vendor:"Microsoft Corporation",privacyUrl:"https://privacy.microsoft.com/en-us/privacystatement",idLabel:"Tag ID",idPattern:"^[0-9]{7,9}$",idExample:"12345678",scriptOrigin:"https://bat.bing.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},clarity:{title:"Microsoft Clarity",vendor:"Microsoft Corporation",privacyUrl:"https://privacy.microsoft.com/en-us/privacystatement",idLabel:"Project ID",idPattern:"^[a-z0-9]{10}$",idExample:"ab12cd34ef",scriptOrigin:"https://www.clarity.ms",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},hotjar:{title:"Hotjar",vendor:"Hotjar Limited",privacyUrl:"https://www.hotjar.com/legal/policies/privacy/",idLabel:"Site ID",idPattern:"^[0-9]{6,9}$",idExample:"1234567",scriptOrigin:"https://static.hotjar.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},posthog:{title:"PostHog",vendor:"PostHog, Inc.",privacyUrl:"https://posthog.com/privacy",idLabel:"Project API key",idPattern:"^phc_[A-Za-z0-9]{32,48}$",idExample:"phc_abcdefghijklmnopqrstuvwxyz012345",scriptOrigin:"https://us-assets.i.posthog.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1,hosts:["us.i.posthog.com","eu.i.posthog.com"]},plausible:{title:"Plausible Analytics",vendor:"Plausible Insights OÜ",privacyUrl:"https://plausible.io/privacy",idLabel:"Domain",idPattern:"^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$",idExample:"example.com",scriptOrigin:"https://plausible.io",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},ahrefs:{title:"Ahrefs Analytics",vendor:"Ahrefs Pte. Ltd.",privacyUrl:"https://ahrefs.com/privacy",idLabel:"Analytics key",idPattern:"^[A-Za-z0-9+/=]{20,64}$",idExample:"AbCdEfGhIjKlMnOpQrStUv==",scriptOrigin:"https://analytics.ahrefs.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1}},T=Object.keys(L);function M(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(L,e)}function D(e,t){return!!M(e)&&("string"==typeof t&&0!==t.length&&new RegExp(L[e].idPattern).test(t))}const N=/^[a-z][a-z0-9-]{0,40}$/,B=/^[\w.:/@+=-]{1,200}$/;function R(e){return function(e){if("string"!=typeof e)return!1;if(0===e.length||e.length>300)return!1;let t;try{t=new URL(e)}catch{return!1}return!("https:"!==t.protocol||!t.hostname||!t.hostname.includes(".")||e.includes("?")||e.includes("#")||t.username||t.password)}(e.src)&&function(e){if(null==e)return!0;if("object"!=typeof e||Array.isArray(e))return!1;const t=Object.entries(e);return!(t.length>12)&&t.every(([e,t])=>N.test(e)&&"string"==typeof t&&B.test(t))}(e.dataAttributes)}const z=Array.from(new Set(T.map(e=>L[e].scriptOrigin))).sort(),G={sign_up:{ga4:"sign_up",meta:"CompleteRegistration",tiktok:"CompleteRegistration",reddit:"SignUp"},login:{ga4:"login",meta:null,tiktok:null,reddit:null},trial_started:{ga4:"begin_checkout",meta:"StartTrial",tiktok:"StartTrial",reddit:"Lead"},checkout_started:{ga4:"begin_checkout",meta:"InitiateCheckout",tiktok:"InitiateCheckout",reddit:"AddToCart"},purchase:{ga4:"purchase",meta:"Purchase",tiktok:"CompletePayment",reddit:"Purchase"},subscription_created:{ga4:"purchase",meta:"Subscribe",tiktok:"Subscribe",reddit:"Purchase"},subscription_upgraded:{ga4:"subscription_upgraded",meta:null,tiktok:null,reddit:null},lead:{ga4:"generate_lead",meta:"Lead",tiktok:"SubmitForm",reddit:"Lead"},workspace_created:{ga4:"workspace_created",meta:null,tiktok:null,reddit:null}},V=Object.keys(G);function F(e){return V.includes(e)}function H(){return"undefined"==typeof window?null:window}const Z={gtm:"dataLayer",ga4:"gtag",google_ads:"gtag",meta_pixel:"fbq",x_pixel:"twq",linkedin:"lintrk",tiktok:"ttq",reddit:"rdt",bing_uet:"uetq",clarity:"clarity",hotjar:"hj",posthog:"posthog",plausible:"plausible",ahrefs:"__ahrefs_loaded"};function J(){return"undefined"==typeof window?null:window}function K(e,t={}){const n=J();if(!n)return null;const r=n.document.createElement("script");r.async=!0,r.src=e;for(const[e,n]of Object.entries(t))r.setAttribute(e,n);return n.document.head.appendChild(r),r}function W(e){const t=J();if(!t)return;const n=t.document.createElement("script");n.text=e,t.document.head.appendChild(n)}function Q(e){const t=J();t&&(Array.isArray(t[e])||(t[e]=[]),"function"!=typeof t.gtag&&(t.gtag=function(){t[e].push(arguments)}))}const X=new Set;function Y(e){for(const t of X)if(t.slice(0,t.indexOf(":"))===e)return!0;return!1}function ee(e,t){const n=J();if(!n)return!1;if("gtm"===e||"ga4"===e||"google_ads"===e){const e=n.google_tag_manager;return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,t)}const r=Z[e];if(!r)return!1;if(void 0===n[r])return!1;if(X.has(`${e}:${t}`))return!0;return!L[e].multiInstance||!Y(e)}const te={meta_pixel:e=>`fbq('init','${e}');fbq('track','PageView');`,x_pixel:e=>`twq('config','${e}');`,tiktok:e=>`ttq.load('${e}');ttq.page();`,reddit:e=>`rdt('init','${e}');rdt('track','PageVisit');`,bing_uet:e=>`window.uetq=window.uetq||[];window.uetq.push({ti:'${e}',enableAutoSpaTracking:false});`,linkedin:e=>`window._linkedin_data_partner_ids=window._linkedin_data_partner_ids||[];window._linkedin_data_partner_ids.push('${e}');`};function ne(e,t,n){const r=function(e,t,n){const r=J();if(!r)return!1;if("external"===e.provider){if(!e.src)return!1;const t={};for(const[n,r]of Object.entries(e.dataAttributes??{}))t[`data-${n}`]=r;return K(e.src,t),!0}const i=e.provider,o=L[i];if(!o)return!1;const a=e.providerId;if(!a)return!1;const s=te[i];if(s&&Y(i))return W(s(a)),!0;switch(i){case"gtm":{Q(t),r[t].push({"gtm.start":Date.now(),event:"gtm.js"});const e="dataLayer"===t?"":`&l=${t}`;return K(`${o.scriptOrigin}/gtm.js?id=${a}${e}`),!0}case"ga4":case"google_ads":{Q(t),K(`${o.scriptOrigin}/gtag/js?id=${a}`);const e=r.gtag;e("js",new Date);const s="ga4"===i&&n?.gaClientId?{client_id:n.gaClientId}:void 0;return s?e("config",a,s):e("config",a),!0}case"meta_pixel":return W(`!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','${o.scriptOrigin}/en_US/fbevents.js');fbq('init','${a}');fbq('track','PageView');`),!0;case"x_pixel":return W(`!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments)},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='${o.scriptOrigin}/uwt.js',a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');twq('config','${a}');`),!0;case"linkedin":return W(`window._linkedin_partner_id='${a}';window._linkedin_data_partner_ids=window._linkedin_data_partner_ids||[];window._linkedin_data_partner_ids.push('${a}');window.lintrk=window.lintrk||function(a,b){(window.lintrk.q=window.lintrk.q||[]).push([a,b])};window.lintrk.q=window.lintrk.q||[];`),K(`${o.scriptOrigin}/li.lms-analytics/insight.min.js`),!0;case"tiktok":return W(`!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=['page','track','identify','instances','debug','on','off','once','ready','alias','group','enableCookie','disableCookie'];ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.load=function(e,n){var r='${o.scriptOrigin}/i18n/pixel/events.js';ttq._i=ttq._i||{};ttq._i[e]=[];ttq._i[e]._u=r;ttq._t=ttq._t||{};ttq._t[e]=+new Date;ttq._o=ttq._o||{};ttq._o[e]=n||{};var o=d.createElement('script');o.type='text/javascript';o.async=!0;o.src=r+'?sdkid='+e+'&lib='+t;var a=d.getElementsByTagName('script')[0];a.parentNode.insertBefore(o,a)};ttq.load('${a}');ttq.page()}(window,document,'ttq');`),!0;case"reddit":return W(`!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement('script');t.src='${o.scriptOrigin}/ads/pixel.js';t.async=!0;var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','${a}');rdt('track','PageVisit');`),!0;case"bing_uet":return W(`(function(w,d,t,r,u){w[u]=w[u]||[];w[u].push({ti:'${a}',enableAutoSpaTracking:false});var o=d.createElement(t);o.src='${o.scriptOrigin}/bat.js';o.async=1;var i=d.getElementsByTagName(t)[0];i.parentNode.insertBefore(o,i)})(window,document,'script',0,'uetq');`),!0;case"clarity":return W(`(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src='${o.scriptOrigin}/tag/'+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y)})(window,document,'clarity','script','${a}');`),!0;case"hotjar":return W(`(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:${a},hjsv:6};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src='${o.scriptOrigin}/hotjar-'+h._hjSettings.hjid+'.js?sv='+h._hjSettings.hjsv;a.appendChild(r)})(window,document);`),!0;case"posthog":{const t=o.hosts,n=t?.includes(e.host??"")?e.host:t?.[0]??"us.i.posthog.com";return W(`!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split('.');2==o.length&&(t=t[o[0]],e=o[1]);t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement('script')).type='text/javascript',p.async=!0,p.src='${o.scriptOrigin}/static/array.js',(r=t.getElementsByTagName('script')[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a='posthog',u.people=u.people||[],u.toString=function(t){var e='posthog';return'posthog'!==a&&(e+='.'+a),t||(e+=' (stub)'),e},u.people.toString=function(){return u.toString(1)+'.people (stub)'},o='init capture register register_once identify alias people.set people.set_once set_config get_distinct_id getFeatureFlag isFeatureEnabled onFeatureFlags reloadFeatureFlags group reset'.split(' '),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);posthog.init('${a}',{api_host:'https://${n}'});`),!0}case"plausible":return W("window.plausible=window.plausible||function(){(window.plausible.q=window.plausible.q||[]).push(arguments)};"),K(`${o.scriptOrigin}/js/script.js`,{"data-domain":a,defer:"true"}),!0;case"ahrefs":return K(`${o.scriptOrigin}/analytics.js`,{"data-key":a}),r.__ahrefs_loaded=!0,!0;default:return!1}}(e,t,n);return r&&"external"!==e.provider&&e.providerId&&X.add(`${e.provider}:${e.providerId}`),r}const re=Symbol.for("@buildbase/sdk.tracking.context"),ie=globalThis,oe=ie[re]??(ie[re]=s(null)),ae={consent:{manifest:[],state:null,set:()=>{}},track:()=>{},setUser:()=>{},setProperties:()=>{},getProperties:()=>({}),completeCheckout:async()=>{},installed:{},ready:!0,attribution:{}};function se(){return a(oe)??ae}const ce=({serverUrl:a,orgId:s,clientId:c,enabled:d=!0,consent:u="auto",autoPageview:p=!0,events:g,onEvent:f,properties:m,enrich:h,identity:w,debug:_=!1,children:k})=>{const b=t(w);b.current=w;const[I,C]=n(null),[$,j]=n(!1),[x,P]=n(!1),S="granted"===u?{analytics:!0,marketing:!0}:"denied"===u?{analytics:!1,marketing:!1}:null,[T,N]=n(S),B=t(null),z=t(f);z.current=f;const V=t(h);V.current=h;const Z=t({});Z.current=m??{};const J=t({}),K=r(()=>({...Z.current,...J.current}),[]),W=r(e=>{const t={...J.current,...e};for(const[e,n]of Object.entries(t))void 0===n&&delete t[e];J.current=t},[]),[X,Y]=n({}),te=t({}),[re,ie]=n(0),ae=I?.dataLayerName??"dataLayer",se=r((...e)=>{_&&console.info("[buildbase:tracking]",...e)},[_]);i(()=>{return e=()=>{0!==Object.keys(te.current).length&&window.dispatchEvent("function"==typeof PageTransitionEvent?new PageTransitionEvent("pagehide",{persisted:!1}):new Event("pagehide"))},l.add(e),()=>{l.delete(e)};var e},[]),i(()=>{if(!(d&&a&&s&&c))return void j(!0);let e=!1;const t=`${a.replace(/\/$/,"")}/api/v1/public/${s}/tracking?clientId=${encodeURIComponent(c)}`;return fetch(t).then(e=>e.ok?e.json():null).then(t=>{if(e||!t)return;const n=t.data??t;n&&Array.isArray(n.scripts)&&C(n)}).catch(()=>{se("config fetch failed; nothing installed")}).finally(()=>{e||j(!0)}),()=>{e=!0}},[d,a,s,c,se]),i(()=>{d&&Y(y())},[d]),i(()=>{d&&I?.enabled&&(Q(ae),function(e,t){const n=E();if(!n)return;Array.isArray(n[e])||(n[e]=[]),"function"!=typeof n.gtag&&(n.gtag=function(){n[e].push(arguments)});const r="granted"===t?"granted":"denied";n.gtag("consent","default",{ad_storage:r,ad_user_data:r,ad_personalization:r,analytics_storage:r,wait_for_update:500})}(ae,u),B.current&&U(B.current))},[d,I?.enabled,ae,u]);const ce=o(()=>I?.enabled?I.scripts.filter(e=>{const t=M(e.provider)&&L[e.provider].supportsConsentMode;return function(e,t,n,r){return"denied"!==r&&("granted"===r||(n?"marketing"===e?n.marketing:n.analytics:t&&"analytics"===e))}(e.consentCategory,t,T,u)}):[],[I,T,u]),[de,le]=n(()=>"undefined"==typeof window||!v(window.location.search));i(()=>{if(de)return;const e=setInterval(()=>{v(window.location.search)||le(!0)},50),t=setTimeout(()=>le(!0),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[de]),i(()=>{if(!de)return;if(!d||!I?.enabled)return void($&&P(!0));let e=0;for(const t of ce)if(!te.current[t.key]){if("external"===t.provider){if(!R({src:t.src,dataAttributes:t.dataAttributes})){se("rejected external script",t.key);continue}}else{if(!M(t.provider)){se("rejected unknown provider",t.provider);continue}if(!D(t.provider,t.providerId)){se("rejected id for",t.provider);continue}if(ee(t.provider,t.providerId??"")){se(`${t.provider} ${t.providerId} is already on the page; skipping. Configure each tag in exactly one place.`);continue}}ne(t,ae,b.current)&&(te.current[t.key]=t.providerId??t.src??"",e+=1,se("installed",t.key))}e&&ie(e=>e+1);const t=window;t.__buildbase=t.__buildbase??{},t.__buildbase.tracking={installed:{...te.current},dataLayerName:ae,clientId:c};const n=Object.keys(te.current).length>0,r=null!==T||0===I.scripts.length;(n||r)&&P(!0)},[d,I,ce,$,T,ae,se,de,c]),i(()=>{if(!d||!p||!I?.enabled)return;if("undefined"==typeof window)return;if(!de)return;let e=null;const t=()=>{e&&clearTimeout(e),e=setTimeout(()=>function(e,t){const n=H();if(!n)return;const r=n[t];Array.isArray(r)&&r.push({event:"page_view",page_path:n.location.pathname,page_location:n.location.href,page_title:n.document.title});for(const t of e)switch(t.provider){case"ga4":n.gtag?.("event","page_view",{send_to:t.providerId,page_path:n.location.pathname,page_location:n.location.href,page_title:n.document.title});break;case"meta_pixel":n.fbq?.("track","PageView");break;case"tiktok":{const e=n.ttq;e?.page?.();break}case"reddit":n.rdt?.("track","PageVisit")}}(ce,ae),50)},n=window.history,r=n.pushState,i=n.replaceState;return n.pushState=function(...e){const n=r.apply(this,e);return t(),n},n.replaceState=function(...e){const n=i.apply(this,e);return t(),n},window.addEventListener("popstate",t),()=>{n.pushState=r,n.replaceState=i,window.removeEventListener("popstate",t),e&&clearTimeout(e)}},[d,p,I?.enabled,ce,ae,de]),i(()=>{if(!d)return;const e=function(e,t){const n=e?.mode??"auto",r=e?.overrides??{};if(("manual"===n||Object.values(r).some(e=>"manual"===e))&&!t)return'[buildbase:tracking] events are set to "manual" but no onEvent handler was provided, so those events would never fire anywhere. Pass onEvent, or use mode "auto".';for(const e of Object.keys(r))if(!F(e))return`[buildbase:tracking] unknown event "${e}" in events.overrides. Overrides only apply to the events the SDK fires itself.`;return null}(g,!!f);if(e)throw new Error(e)},[d,g,f]);const ue=r((e,t={},n)=>{if(!d)return;const r=n?.eventId||function(){const e=globalThis.crypto;return e?.randomUUID?e.randomUUID():`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}(),i=g?.mode??"auto",o=(F(e)?g?.overrides?.[e]:void 0)??i,a={...Z.current,...J.current,...X,...t},s=V.current?.({name:e,params:a})??{},c={...a,...s},l=z.current?.({name:e,params:c,eventId:r,handledBy:o});"manual"!==o&&!0!==l?(!function(e,t,n,r,i){const o=H();if(!o)return;const a=o[i];Array.isArray(a)&&a.push({event:e,...t,event_id:n});const s=F(e)?G[e]:{ga4:e,meta:null,tiktok:null,reddit:null};for(const i of r){const r=i.provider,a=L[r];if(a){if(a.needsConversionIds){const a=i.conversionIds?.[e];if(!a)continue;"google_ads"===r?o.gtag?.("event","conversion",{send_to:`${i.providerId}/${a}`,transaction_id:n,...t}):"x_pixel"===r?o.twq?.("event",a,{...t,conversion_id:n}):"linkedin"===r&&o.lintrk?.("track",{conversion_id:a});continue}switch(r){case"ga4":s.ga4&&o.gtag?.("event",s.ga4,{...t,send_to:i.providerId,event_id:n});break;case"meta_pixel":s.meta&&o.fbq?.("track",s.meta,t,{eventID:n});break;case"tiktok":if(s.tiktok){const e=o.ttq;e?.track?.(s.tiktok,{...t,event_id:n})}break;case"reddit":s.reddit&&o.rdt?.("track",s.reddit,{...t,conversionId:n});break;case"bing_uet":{const r=o.uetq;r?.push?.("event",s.ga4??e,{...t,event_id:n});break}case"clarity":o.clarity?.("event",e);break;case"hotjar":{const t=o.hj;t?.("event",e);break}case"posthog":{const r=o.posthog;r?.capture?.(e,{...t,event_id:n});break}case"plausible":o.plausible?.(e,{props:t})}}}}(e,c,r,ce,ae),se("event fired:",e,r)):se("event handled by app:",e)},[d,g,ce,ae,X,se]),pe=r(async(e,t={})=>{const n=function(e){return{name:"trial_started"===e.kind?"trial_started":"purchase",params:{...e.workspaceId?{workspace_id:e.workspaceId}:{},...e.planVersionId?{plan_version_id:e.planVersionId}:{},...e.creditPackageId?{credit_package_id:e.creditPackageId}:{},...e.billingInterval?{billing_interval:e.billingInterval}:{},...e.currency?{currency:e.currency.toUpperCase()}:{},..."number"==typeof e.value?{value:e.value}:{},...e.sessionId?{transaction_id:e.sessionId}:{}}}}(e);let r=n.params;if(e.sessionId&&a&&s){const t=await async function(e,t){try{const n=e.serverUrl.replace(/\/$/,""),r=await fetch(`${n}/api/v1/public/${encodeURIComponent(e.orgId)}/checkout/${encodeURIComponent(t)}`,{credentials:"omit",..."undefined"!=typeof AbortSignal&&AbortSignal.timeout?{signal:AbortSignal.timeout(2e3)}:{}});if(!r.ok)return null;const i=await r.json(),o=i?.data??i;return"number"!=typeof o?.amount?null:{value:O(o.amount,o.currency),currency:"string"==typeof o.currency?o.currency:void 0,...Array.isArray(o.items)&&o.items.length?{items:o.items}:{}}}catch{return null}}({serverUrl:a,orgId:s},e.sessionId);t&&"number"==typeof t.value&&(r={...r,value:t.value,...t.currency?{currency:t.currency.toUpperCase()}:{},...t.items?.length?{items:t.items}:{}})}if(ue(n.name,{...r,...t},{eventId:e.eventId}),"purchase"===n.name&&e.sessionId&&a&&s){const t=(I?.scripts??[]).find(e=>"ga4"===e.provider&&e.providerId);t&&ee("ga4",t.providerId??"")&&function(e,t,n){try{const r=e.serverUrl.replace(/\/$/,"");fetch(`${r}/api/v1/public/${encodeURIComponent(e.orgId)}/checkout/${encodeURIComponent(t)}/reported`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n}),keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}({serverUrl:a,orgId:s},e.sessionId,"ga4")}},[a,s,ue,I]),[ge]=n(()=>"undefined"==typeof window?"":window.location.search);i(()=>{if(!d||!x)return;if("undefined"==typeof window)return;const e=q(window.location.search);if(e)return void pe(e);const t=A(ge);t&&ue("checkout_abandoned",{...t.workspaceId?{workspace_id:t.workspaceId}:{},...t.planVersionId?{plan_version_id:t.planVersionId}:{},...t.creditPackageId?{credit_package_id:t.creditPackageId}:{},...t.billingInterval?{billing_interval:t.billingInterval}:{},...t.currency?{currency:t.currency.toUpperCase()}:{},..."number"==typeof t.value?{value:t.value}:{},seconds_at_checkout:Math.max(0,Math.round((Date.now()-t.startedAt)/1e3))})},[d,x,pe,ge,ue]);const fe=r(e=>{B.current=e,N(e),U(e)},[]),me=r((e,t)=>function(e,t,n){const r=H();if(!r)return;const i=!!n&&Object.keys(n).length>0;for(const o of t)switch(o.provider){case"ga4":case"google_ads":r.gtag?.("set",{user_id:e}),i&&r.gtag?.("set",{user_properties:n});break;case"meta_pixel":o.providerId&&r.fbq?.("init",o.providerId,{external_id:e});break;case"posthog":r.posthog?.identify?.(e,i?n:void 0);break;case"clarity":if(r.clarity?.("identify",e),i)for(const[e,t]of Object.entries(n))r.clarity?.("set",e,String(t));break;case"hotjar":r.hj?.("identify",e,{});break;case"tiktok":{const t=r.ttq;t?.identify?.({external_id:e});break}}}(e,ce,t),[ce]),he=o(()=>({consent:{manifest:I?.consent?.manifest??[],state:T,set:fe},track:ue,setUser:me,setProperties:W,getProperties:K,completeCheckout:pe,installed:{...te.current},ready:x,attribution:X}),[I,T,fe,ue,me,W,K,pe,x,re,X]);return e(oe.Provider,{value:he,children:k})};function de(e={}){const{completeCheckout:n,ready:r}=se(),o=t(e);o.current=e;const a=t(!1);i(()=>{if(!r)return;if(a.current)return;const e=q(window.location.search)??j();e&&(a.current=!0,n(e,o.current))},[r,n])}ce.displayName="BuildBaseTracking";const le={sign_in_started:"The sign-in / sign-up button was pressed.",pricing_viewed:"A <PricingPage> finished loading its plans.",pricing_plan_selected:"A plan was chosen on a <PricingPage>.",workspace_switcher_opened:"The workspace switcher was opened.",workspace_settings_opened:"The workspace settings modal was opened.",workspace_settings_section_viewed:"A different section of the settings modal was opened.",plan_picker_opened:"The plan picker was shown.",billing_interval_changed:"Monthly / quarterly / yearly was switched in the plan picker.",plan_selected:"A plan was chosen in the plan picker.",plan_picker_dismissed:"The plan picker was closed without choosing a plan.",checkout_abandoned:"The customer came back from Stripe without paying.",billing_portal_opened:"Stripe’s billing portal was opened.",subscription_cancel_started:"The cancel-subscription confirmation was opened.",subscription_cancelled:"A subscription was cancelled.",subscription_resumed:"A cancelled subscription was resumed.",feature_gate_shown:'A feature gate rendered its "not on your plan" side.',quota_limit_reached:"A quota gate rendered because a quota is used up.",quota_threshold_reached:"A usage-threshold gate rendered.",plan_gate_shown:'A plan gate rendered its "needs another plan" side.',subscription_notice_shown:"A billing notice (trial ending, payment failed…) was shown.",sdk_error:"An SDK operation failed (component, action and code only)."};export{p as ATTRIBUTION_PARAMS,ce as BuildBaseTracking,G as EVENT_MAPPINGS,le as FUNNEL_EVENTS,L as TAG_PROVIDERS,T as TAG_PROVIDER_IDS,z as TAG_SCRIPT_ORIGINS,y as captureAttribution,w as getAttribution,F as isCanonicalEvent,M as isTagProviderId,D as isValidProviderId,de as useCheckoutCompleted,se as useTracking};
2
+ import{jsx as e}from"react/jsx-runtime";import{useRef as t,useState as n,useCallback as r,useEffect as i,useMemo as o,useContext as a,createContext as s}from"react";const c="__buildbaseBeforeLeave",d=globalThis,l=d[c]??(d[c]=new Set);const u="bb_attr",p=["gclid","gbraid","wbraid","dclid","fbclid","msclkid","li_fat_id","twclid","ttclid","rdt_cid","epik","irclickid","utm_source","utm_medium","utm_campaign","utm_term","utm_content","utm_id"],g=/^[\w.~-]{1,200}$/;function f(){return"undefined"==typeof window?null:window}function m(e,t){if(!e||!e.includes("."))return"";if(/^\d{1,3}(\.\d{1,3}){3}$/.test(e))return"";const n=t??f()?.document;if(!n)return"";const r=e.split(".");for(let e=r.length-2;e>=0;e--){const t="."+r.slice(e).join("."),i=`__bb_probe_${Date.now()}`;n.cookie=`${i}=1; domain=${t}; path=/; SameSite=Lax`;const o=n.cookie.includes(`${i}=1`);if(n.cookie=`${i}=; domain=${t}; path=/; max-age=0; SameSite=Lax`,o)return t}return""}function h(e){const t=e.cookie.split("; ").find(e=>e.startsWith(`${u}=`));if(!t)return{};try{const e=JSON.parse(decodeURIComponent(t.slice(8)));return"object"==typeof e&&e?e:{}}catch{return{}}}const y=p.filter(e=>!e.startsWith("utm_")),w=e=>y.some(t=>!!e[t]);function v(){const e=f();if(!e)return{};const t=e.document,n=h(t),r=function(e){const t=new URLSearchParams(e),n={};for(const e of p){const r=t.get(e);r&&(r.length>200||g.test(r)&&(n[e]=r))}return n}(e.location.search),i=Object.keys(r).length>0&&(w(r)||!w(n)),o=i?r:n;return 0===Object.keys(o).length?{}:(i&&!function(e,t){const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const r of n)if(e[r]!==t[r])return!1;return!0}(r,n)&&function(e,t,n){const r=encodeURIComponent(JSON.stringify(t));e.cookie=`${u}=${r}; path=/; max-age=7776000; SameSite=Lax`+(n?`; domain=${n}`:"")}(t,o,m(e.location.hostname,t)),o)}function _(){const e=f();return e?h(e.document):{}}function k(e){try{const t=new URLSearchParams(e);return t.has("code")&&t.has("state")}catch{return!1}}const b="bb_pending_checkout";function I(){try{return"undefined"==typeof window?null:window.sessionStorage}catch{return null}}const C="bb_co";function $(){try{return"undefined"==typeof window?null:window.document??null}catch{return null}}function j(){const e=$();if(e)try{const t=m(window.location?.hostname??"",e);e.cookie=`${C}=; path=/; max-age=0; SameSite=Lax`+(t?`; domain=${t}`:"")}catch{}}function x(e,t){if(!e)return null;try{const n=JSON.parse(e);return n&&"string"==typeof n.eventId&&n.eventId?"number"!=typeof n.startedAt||t-n.startedAt>216e5?null:n:null}catch{return null}}function q(e=Date.now()){const t=I();if(!t)return null;let n=null;try{n=t.getItem(b),t.removeItem(b)}catch{return null}const r=x(n,e);return r&&j(),r}function A(e){try{return x(I()?.getItem(b)??null,e)}catch{return null}}function P(e,t=Date.now()){let n=null;try{n=new URLSearchParams(e).get("session_id")}catch{return null}if(!n)return null;const r=A(t);if(r?.sessionId===n)return q(t);const i=function(e){const t=$();if(!t||"string"!=typeof t.cookie)return null;const n=t.cookie.split("; ").find(e=>e.startsWith(`${C}=`));return n?x(decodeURIComponent(n.slice(6)),e):null}(t);return i?.sessionId!==n?null:(j(),i)}function S(e,t=Date.now()){return function(e){let t=null;try{t=new URLSearchParams(e).get("bb")}catch{return!1}if(!t)return!1;const n={};for(const e of t.split(",")){const t=e.indexOf(":");if(-1!==t)try{n[decodeURIComponent(e.slice(0,t))]=decodeURIComponent(e.slice(t+1))}catch{}}return"checkout"===n.action&&"cancel"===n.status}(e)&&A(t)?q(t):null}const O=new Set(["bif","clp","djf","gnf","jpy","kmf","krw","mga","pyg","rwf","ugx","vnd","vuv","xaf","xof","xpf"]),E=new Set(["bhd","jod","kwd","omr","tnd"]);function U(e,t){if("number"!=typeof e||!Number.isFinite(e))return;const n=(t??"").toLowerCase();return O.has(n)?e:e/(E.has(n)?1e3:100)}function L(){return"undefined"==typeof window?null:window}function T(e){const t=L();if(!t)return;t.gtag?.("consent","update",{ad_storage:e.marketing?"granted":"denied",ad_user_data:e.marketing?"granted":"denied",ad_personalization:e.marketing?"granted":"denied",analytics_storage:e.analytics?"granted":"denied"});const n=t.fbq;n?.("consent",e.marketing?"grant":"revoke")}const M={gtm:{title:"Google Tag Manager",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Container ID",idPattern:"^GTM-[A-Z0-9]{4,10}$",idExample:"GTM-ABC1234",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"analytics",supportsConsentMode:!0,needsConversionIds:!1},ga4:{title:"Google Analytics 4",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Measurement ID",idPattern:"^G-[A-Z0-9]{8,12}$",idExample:"G-ABCD123456",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"analytics",supportsConsentMode:!0,needsConversionIds:!1},google_ads:{title:"Google Ads",vendor:"Google LLC",privacyUrl:"https://policies.google.com/privacy",idLabel:"Conversion ID",idPattern:"^AW-[0-9]{9,12}$",idExample:"AW-123456789",scriptOrigin:"https://www.googletagmanager.com",defaultConsentCategory:"marketing",supportsConsentMode:!0,needsConversionIds:!0},meta_pixel:{title:"Meta Pixel",vendor:"Meta Platforms Ireland Limited",privacyUrl:"https://www.facebook.com/privacy/policy",idLabel:"Pixel ID",idPattern:"^[0-9]{15,16}$",idExample:"123456789012345",scriptOrigin:"https://connect.facebook.net",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},x_pixel:{title:"X (Twitter) Pixel",vendor:"X Corp.",privacyUrl:"https://x.com/en/privacy",idLabel:"Pixel ID",idPattern:"^o[a-z0-9]{4,6}$",idExample:"o1a2b3",scriptOrigin:"https://static.ads-twitter.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!0,multiInstance:!0},linkedin:{title:"LinkedIn Insight Tag",vendor:"LinkedIn Ireland Unlimited Company",privacyUrl:"https://www.linkedin.com/legal/privacy-policy",idLabel:"Partner ID",idPattern:"^[0-9]{6,9}$",idExample:"1234567",scriptOrigin:"https://snap.licdn.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!0,multiInstance:!0},tiktok:{title:"TikTok Pixel",vendor:"TikTok Information Technologies UK Limited",privacyUrl:"https://www.tiktok.com/legal/privacy-policy",idLabel:"Pixel ID",idPattern:"^[A-Z0-9]{20}$",idExample:"C4A1B2C3D4E5F6G7H8I9",scriptOrigin:"https://analytics.tiktok.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},reddit:{title:"Reddit Pixel",vendor:"Reddit, Inc.",privacyUrl:"https://www.reddit.com/policies/privacy-policy",idLabel:"Advertiser ID",idPattern:"^t2_[a-z0-9]{4,12}$",idExample:"t2_abc123",scriptOrigin:"https://www.redditstatic.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},bing_uet:{title:"Microsoft Advertising (UET)",vendor:"Microsoft Corporation",privacyUrl:"https://privacy.microsoft.com/en-us/privacystatement",idLabel:"Tag ID",idPattern:"^[0-9]{7,9}$",idExample:"12345678",scriptOrigin:"https://bat.bing.com",defaultConsentCategory:"marketing",supportsConsentMode:!1,needsConversionIds:!1,multiInstance:!0},clarity:{title:"Microsoft Clarity",vendor:"Microsoft Corporation",privacyUrl:"https://privacy.microsoft.com/en-us/privacystatement",idLabel:"Project ID",idPattern:"^[a-z0-9]{10}$",idExample:"ab12cd34ef",scriptOrigin:"https://www.clarity.ms",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},hotjar:{title:"Hotjar",vendor:"Hotjar Limited",privacyUrl:"https://www.hotjar.com/legal/policies/privacy/",idLabel:"Site ID",idPattern:"^[0-9]{6,9}$",idExample:"1234567",scriptOrigin:"https://static.hotjar.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},posthog:{title:"PostHog",vendor:"PostHog, Inc.",privacyUrl:"https://posthog.com/privacy",idLabel:"Project API key",idPattern:"^phc_[A-Za-z0-9]{32,48}$",idExample:"phc_abcdefghijklmnopqrstuvwxyz012345",scriptOrigin:"https://us-assets.i.posthog.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1,hosts:["us.i.posthog.com","eu.i.posthog.com"]},plausible:{title:"Plausible Analytics",vendor:"Plausible Insights OÜ",privacyUrl:"https://plausible.io/privacy",idLabel:"Domain",idPattern:"^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$",idExample:"example.com",scriptOrigin:"https://plausible.io",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1},ahrefs:{title:"Ahrefs Analytics",vendor:"Ahrefs Pte. Ltd.",privacyUrl:"https://ahrefs.com/privacy",idLabel:"Analytics key",idPattern:"^[A-Za-z0-9+/=]{20,64}$",idExample:"AbCdEfGhIjKlMnOpQrStUv==",scriptOrigin:"https://analytics.ahrefs.com",defaultConsentCategory:"analytics",supportsConsentMode:!1,needsConversionIds:!1}},D=Object.keys(M);function N(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(M,e)}function B(e,t){return!!N(e)&&("string"==typeof t&&0!==t.length&&new RegExp(M[e].idPattern).test(t))}const R=/^[a-z][a-z0-9-]{0,40}$/,z=/^[\w.:/@+=-]{1,200}$/;function G(e){return function(e){if("string"!=typeof e)return!1;if(0===e.length||e.length>300)return!1;let t;try{t=new URL(e)}catch{return!1}return!("https:"!==t.protocol||!t.hostname||!t.hostname.includes(".")||e.includes("?")||e.includes("#")||t.username||t.password)}(e.src)&&function(e){if(null==e)return!0;if("object"!=typeof e||Array.isArray(e))return!1;const t=Object.entries(e);return!(t.length>12)&&t.every(([e,t])=>R.test(e)&&"string"==typeof t&&z.test(t))}(e.dataAttributes)}const V=Array.from(new Set(D.map(e=>M[e].scriptOrigin))).sort(),F={sign_up:{ga4:"sign_up",meta:"CompleteRegistration",tiktok:"CompleteRegistration",reddit:"SignUp"},login:{ga4:"login",meta:null,tiktok:null,reddit:null},trial_started:{ga4:"begin_checkout",meta:"StartTrial",tiktok:"StartTrial",reddit:"Lead"},checkout_started:{ga4:"begin_checkout",meta:"InitiateCheckout",tiktok:"InitiateCheckout",reddit:"AddToCart"},purchase:{ga4:"purchase",meta:"Purchase",tiktok:"CompletePayment",reddit:"Purchase"},subscription_created:{ga4:"purchase",meta:"Subscribe",tiktok:"Subscribe",reddit:"Purchase"},subscription_upgraded:{ga4:"subscription_upgraded",meta:null,tiktok:null,reddit:null},lead:{ga4:"generate_lead",meta:"Lead",tiktok:"SubmitForm",reddit:"Lead"},workspace_created:{ga4:"workspace_created",meta:null,tiktok:null,reddit:null}},H=Object.keys(F);function W(e){return H.includes(e)}function Z(){return"undefined"==typeof window?null:window}const J={gtm:"dataLayer",ga4:"gtag",google_ads:"gtag",meta_pixel:"fbq",x_pixel:"twq",linkedin:"lintrk",tiktok:"ttq",reddit:"rdt",bing_uet:"uetq",clarity:"clarity",hotjar:"hj",posthog:"posthog",plausible:"plausible",ahrefs:"__ahrefs_loaded"};function K(){return"undefined"==typeof window?null:window}function Q(e,t={}){const n=K();if(!n)return null;const r=n.document.createElement("script");r.async=!0,r.src=e;for(const[e,n]of Object.entries(t))r.setAttribute(e,n);return n.document.head.appendChild(r),r}function X(e){const t=K();if(!t)return;const n=t.document.createElement("script");n.text=e,t.document.head.appendChild(n)}function Y(e){const t=K();t&&(Array.isArray(t[e])||(t[e]=[]),"function"!=typeof t.gtag&&(t.gtag=function(){t[e].push(arguments)}))}const ee=new Set;function te(e){for(const t of ee)if(t.slice(0,t.indexOf(":"))===e)return!0;return!1}function ne(e,t){const n=K();if(!n)return!1;if("gtm"===e||"ga4"===e||"google_ads"===e){const e=n.google_tag_manager;return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,t)}const r=J[e];if(!r)return!1;if(void 0===n[r])return!1;if(ee.has(`${e}:${t}`))return!0;return!M[e].multiInstance||!te(e)}const re={meta_pixel:e=>`fbq('init','${e}');fbq('track','PageView');`,x_pixel:e=>`twq('config','${e}');`,tiktok:e=>`ttq.load('${e}');ttq.page();`,reddit:e=>`rdt('init','${e}');rdt('track','PageVisit');`,bing_uet:e=>`window.uetq=window.uetq||[];window.uetq.push({ti:'${e}',enableAutoSpaTracking:false});`,linkedin:e=>`window._linkedin_data_partner_ids=window._linkedin_data_partner_ids||[];window._linkedin_data_partner_ids.push('${e}');`};function ie(e,t,n){const r=function(e,t,n){const r=K();if(!r)return!1;if("external"===e.provider){if(!e.src)return!1;const t={};for(const[n,r]of Object.entries(e.dataAttributes??{}))t[`data-${n}`]=r;return Q(e.src,t),!0}const i=e.provider,o=M[i];if(!o)return!1;const a=e.providerId;if(!a)return!1;const s=re[i];if(s&&te(i))return X(s(a)),!0;switch(i){case"gtm":{Y(t),r[t].push({"gtm.start":Date.now(),event:"gtm.js"});const e="dataLayer"===t?"":`&l=${t}`;return Q(`${o.scriptOrigin}/gtm.js?id=${a}${e}`),!0}case"ga4":case"google_ads":{Y(t),Q(`${o.scriptOrigin}/gtag/js?id=${a}`);const e=r.gtag;e("js",new Date);const s="ga4"===i&&n?.gaClientId?{client_id:n.gaClientId}:void 0;return s?e("config",a,s):e("config",a),!0}case"meta_pixel":return X(`!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','${o.scriptOrigin}/en_US/fbevents.js');fbq('init','${a}');fbq('track','PageView');`),!0;case"x_pixel":return X(`!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments)},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='${o.scriptOrigin}/uwt.js',a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');twq('config','${a}');`),!0;case"linkedin":return X(`window._linkedin_partner_id='${a}';window._linkedin_data_partner_ids=window._linkedin_data_partner_ids||[];window._linkedin_data_partner_ids.push('${a}');window.lintrk=window.lintrk||function(a,b){(window.lintrk.q=window.lintrk.q||[]).push([a,b])};window.lintrk.q=window.lintrk.q||[];`),Q(`${o.scriptOrigin}/li.lms-analytics/insight.min.js`),!0;case"tiktok":return X(`!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=['page','track','identify','instances','debug','on','off','once','ready','alias','group','enableCookie','disableCookie'];ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.load=function(e,n){var r='${o.scriptOrigin}/i18n/pixel/events.js';ttq._i=ttq._i||{};ttq._i[e]=[];ttq._i[e]._u=r;ttq._t=ttq._t||{};ttq._t[e]=+new Date;ttq._o=ttq._o||{};ttq._o[e]=n||{};var o=d.createElement('script');o.type='text/javascript';o.async=!0;o.src=r+'?sdkid='+e+'&lib='+t;var a=d.getElementsByTagName('script')[0];a.parentNode.insertBefore(o,a)};ttq.load('${a}');ttq.page()}(window,document,'ttq');`),!0;case"reddit":return X(`!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement('script');t.src='${o.scriptOrigin}/ads/pixel.js';t.async=!0;var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','${a}');rdt('track','PageVisit');`),!0;case"bing_uet":return X(`(function(w,d,t,r,u){w[u]=w[u]||[];w[u].push({ti:'${a}',enableAutoSpaTracking:false});var o=d.createElement(t);o.src='${o.scriptOrigin}/bat.js';o.async=1;var i=d.getElementsByTagName(t)[0];i.parentNode.insertBefore(o,i)})(window,document,'script',0,'uetq');`),!0;case"clarity":return X(`(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src='${o.scriptOrigin}/tag/'+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y)})(window,document,'clarity','script','${a}');`),!0;case"hotjar":return X(`(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:${a},hjsv:6};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src='${o.scriptOrigin}/hotjar-'+h._hjSettings.hjid+'.js?sv='+h._hjSettings.hjsv;a.appendChild(r)})(window,document);`),!0;case"posthog":{const t=o.hosts,n=t?.includes(e.host??"")?e.host:t?.[0]??"us.i.posthog.com";return X(`!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split('.');2==o.length&&(t=t[o[0]],e=o[1]);t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement('script')).type='text/javascript',p.async=!0,p.src='${o.scriptOrigin}/static/array.js',(r=t.getElementsByTagName('script')[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a='posthog',u.people=u.people||[],u.toString=function(t){var e='posthog';return'posthog'!==a&&(e+='.'+a),t||(e+=' (stub)'),e},u.people.toString=function(){return u.toString(1)+'.people (stub)'},o='init capture register register_once identify alias people.set people.set_once set_config get_distinct_id getFeatureFlag isFeatureEnabled onFeatureFlags reloadFeatureFlags group reset'.split(' '),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);posthog.init('${a}',{api_host:'https://${n}'});`),!0}case"plausible":return X("window.plausible=window.plausible||function(){(window.plausible.q=window.plausible.q||[]).push(arguments)};"),Q(`${o.scriptOrigin}/js/script.js`,{"data-domain":a,defer:"true"}),!0;case"ahrefs":return Q(`${o.scriptOrigin}/analytics.js`,{"data-key":a}),r.__ahrefs_loaded=!0,!0;default:return!1}}(e,t,n);return r&&"external"!==e.provider&&e.providerId&&ee.add(`${e.provider}:${e.providerId}`),r}const oe=Symbol.for("@buildbase/sdk.tracking.context"),ae=globalThis,se=ae[oe]??(ae[oe]=s(null)),ce={consent:{manifest:[],state:null,set:()=>{}},track:()=>{},setUser:()=>{},setProperties:()=>{},getProperties:()=>({}),completeCheckout:async()=>{},installed:{},ready:!0,attribution:{}};function de(){return a(se)??ce}const le=({serverUrl:a,orgId:s,clientId:c,enabled:d=!0,consent:u="auto",autoPageview:p=!0,events:g,onEvent:f,properties:m,enrich:h,identity:y,debug:w=!1,children:_})=>{const b=t(y);b.current=y;const[I,C]=n(null),[$,j]=n(!1),[x,q]=n(!1),A="granted"===u?{analytics:!0,marketing:!0}:"denied"===u?{analytics:!1,marketing:!1}:null,[O,E]=n(A),D=t(null),R=t(f);R.current=f;const z=t(h);z.current=h;const V=t({});V.current=m??{};const H=t({}),J=r(()=>({...V.current,...H.current}),[]),K=r(e=>{const t={...H.current,...e};for(const[e,n]of Object.entries(t))void 0===n&&delete t[e];H.current=t},[]),[Q,X]=n({}),ee=t({}),[te,re]=n(0),oe=I?.dataLayerName??"dataLayer",ae=r((...e)=>{w&&console.info("[buildbase:tracking]",...e)},[w]);i(()=>{return e=()=>{0!==Object.keys(ee.current).length&&window.dispatchEvent("function"==typeof PageTransitionEvent?new PageTransitionEvent("pagehide",{persisted:!1}):new Event("pagehide"))},l.add(e),()=>{l.delete(e)};var e},[]),i(()=>{if(!(d&&a&&s&&c))return void j(!0);let e=!1;const t=`${a.replace(/\/$/,"")}/api/v1/public/${s}/tracking?clientId=${encodeURIComponent(c)}`;return fetch(t).then(e=>e.ok?e.json():null).then(t=>{if(e||!t)return;const n=t.data??t;n&&Array.isArray(n.scripts)&&C(n)}).catch(()=>{ae("config fetch failed; nothing installed")}).finally(()=>{e||j(!0)}),()=>{e=!0}},[d,a,s,c,ae]),i(()=>{d&&X(v())},[d]),i(()=>{d&&I?.enabled&&(Y(oe),function(e,t){const n=L();if(!n)return;Array.isArray(n[e])||(n[e]=[]),"function"!=typeof n.gtag&&(n.gtag=function(){n[e].push(arguments)});const r="granted"===t?"granted":"denied";n.gtag("consent","default",{ad_storage:r,ad_user_data:r,ad_personalization:r,analytics_storage:r,wait_for_update:500})}(oe,u),D.current&&T(D.current))},[d,I?.enabled,oe,u]);const ce=o(()=>I?.enabled?I.scripts.filter(e=>{const t=N(e.provider)&&M[e.provider].supportsConsentMode;return function(e,t,n,r){return"denied"!==r&&("granted"===r||(n?"marketing"===e?n.marketing:n.analytics:t&&"analytics"===e))}(e.consentCategory,t,O,u)}):[],[I,O,u]),[de,le]=n(()=>"undefined"==typeof window||!k(window.location.search));i(()=>{if(de)return;const e=setInterval(()=>{k(window.location.search)||le(!0)},50),t=setTimeout(()=>le(!0),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[de]),i(()=>{if(!de)return;if(!d||!I?.enabled)return void($&&q(!0));let e=0;for(const t of ce)if(!ee.current[t.key]){if("external"===t.provider){if(!G({src:t.src,dataAttributes:t.dataAttributes})){ae("rejected external script",t.key);continue}}else{if(!N(t.provider)){ae("rejected unknown provider",t.provider);continue}if(!B(t.provider,t.providerId)){ae("rejected id for",t.provider);continue}if(ne(t.provider,t.providerId??"")){ae(`${t.provider} ${t.providerId} is already on the page; skipping. Configure each tag in exactly one place.`);continue}}ie(t,oe,b.current)&&(ee.current[t.key]=t.providerId??t.src??"",e+=1,ae("installed",t.key))}e&&re(e=>e+1);const t=window;t.__buildbase=t.__buildbase??{},t.__buildbase.tracking={installed:{...ee.current},dataLayerName:oe,clientId:c};const n=Object.keys(ee.current).length>0,r=null!==O||0===I.scripts.length;(n||r)&&q(!0)},[d,I,ce,$,O,oe,ae,de,c]),i(()=>{if(!d||!p||!I?.enabled)return;if("undefined"==typeof window)return;if(!de)return;let e=null;const t=()=>{e&&clearTimeout(e),e=setTimeout(()=>function(e,t){const n=Z();if(!n)return;const r=n[t];Array.isArray(r)&&r.push({event:"page_view",page_path:n.location.pathname,page_location:n.location.href,page_title:n.document.title});for(const t of e)switch(t.provider){case"ga4":n.gtag?.("event","page_view",{send_to:t.providerId,page_path:n.location.pathname,page_location:n.location.href,page_title:n.document.title});break;case"meta_pixel":n.fbq?.("track","PageView");break;case"tiktok":{const e=n.ttq;e?.page?.();break}case"reddit":n.rdt?.("track","PageVisit")}}(ce,oe),50)},n=window.history,r=n.pushState,i=n.replaceState;return n.pushState=function(...e){const n=r.apply(this,e);return t(),n},n.replaceState=function(...e){const n=i.apply(this,e);return t(),n},window.addEventListener("popstate",t),()=>{n.pushState=r,n.replaceState=i,window.removeEventListener("popstate",t),e&&clearTimeout(e)}},[d,p,I?.enabled,ce,oe,de]),i(()=>{if(!d)return;const e=function(e,t){const n=e?.mode??"auto",r=e?.overrides??{};if(("manual"===n||Object.values(r).some(e=>"manual"===e))&&!t)return'[buildbase:tracking] events are set to "manual" but no onEvent handler was provided, so those events would never fire anywhere. Pass onEvent, or use mode "auto".';for(const e of Object.keys(r))if(!W(e))return`[buildbase:tracking] unknown event "${e}" in events.overrides. Overrides only apply to the events the SDK fires itself.`;return null}(g,!!f);if(e)throw new Error(e)},[d,g,f]);const ue=r((e,t={},n)=>{if(!d)return;const r=n?.eventId||function(){const e=globalThis.crypto;return e?.randomUUID?e.randomUUID():`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}(),i=g?.mode??"auto",o=(W(e)?g?.overrides?.[e]:void 0)??i,a={...V.current,...H.current,...Q,...t},s=z.current?.({name:e,params:a})??{},c={...a,...s},l=R.current?.({name:e,params:c,eventId:r,handledBy:o});"manual"!==o&&!0!==l?(!function(e,t,n,r,i){const o=Z();if(!o)return;const a=o[i];Array.isArray(a)&&a.push({event:e,...t,event_id:n});const s=W(e)?F[e]:{ga4:e,meta:null,tiktok:null,reddit:null};for(const i of r){const r=i.provider,a=M[r];if(a){if(a.needsConversionIds){const a=i.conversionIds?.[e];if(!a)continue;"google_ads"===r?o.gtag?.("event","conversion",{send_to:`${i.providerId}/${a}`,transaction_id:n,...t}):"x_pixel"===r?o.twq?.("event",a,{...t,conversion_id:n}):"linkedin"===r&&o.lintrk?.("track",{conversion_id:a});continue}switch(r){case"ga4":s.ga4&&o.gtag?.("event",s.ga4,{...t,send_to:i.providerId,event_id:n});break;case"meta_pixel":s.meta&&o.fbq?.("track",s.meta,t,{eventID:n});break;case"tiktok":if(s.tiktok){const e=o.ttq;e?.track?.(s.tiktok,{...t,event_id:n})}break;case"reddit":s.reddit&&o.rdt?.("track",s.reddit,{...t,conversionId:n});break;case"bing_uet":{const r=o.uetq;r?.push?.("event",s.ga4??e,{...t,event_id:n});break}case"clarity":o.clarity?.("event",e);break;case"hotjar":{const t=o.hj;t?.("event",e);break}case"posthog":{const r=o.posthog;r?.capture?.(e,{...t,event_id:n});break}case"plausible":o.plausible?.(e,{props:t})}}}}(e,c,r,ce,oe),ae("event fired:",e,r)):ae("event handled by app:",e)},[d,g,ce,oe,Q,ae]),pe=r(async(e,t={})=>{const n=function(e){return{name:"trial_started"===e.kind?"trial_started":"purchase",params:{...e.workspaceId?{workspace_id:e.workspaceId}:{},...e.planVersionId?{plan_version_id:e.planVersionId}:{},...e.creditPackageId?{credit_package_id:e.creditPackageId}:{},...e.billingInterval?{billing_interval:e.billingInterval}:{},...e.currency?{currency:e.currency.toUpperCase()}:{},..."number"==typeof e.value?{value:e.value}:{},...e.sessionId?{transaction_id:e.sessionId}:{}}}}(e);let r=n.params;if(e.sessionId&&a&&s){const t=await async function(e,t){try{const n=e.serverUrl.replace(/\/$/,""),r=await fetch(`${n}/api/v1/public/${encodeURIComponent(e.orgId)}/checkout/${encodeURIComponent(t)}`,{credentials:"omit",..."undefined"!=typeof AbortSignal&&AbortSignal.timeout?{signal:AbortSignal.timeout(2e3)}:{}});if(!r.ok)return null;const i=await r.json(),o=i?.data??i;return"number"!=typeof o?.amount?null:{value:U(o.amount,o.currency),currency:"string"==typeof o.currency?o.currency:void 0,...Array.isArray(o.items)&&o.items.length?{items:o.items}:{}}}catch{return null}}({serverUrl:a,orgId:s},e.sessionId);t&&"number"==typeof t.value&&(r={...r,value:t.value,...t.currency?{currency:t.currency.toUpperCase()}:{},...t.items?.length?{items:t.items}:{}})}if(ue(n.name,{...r,...t},{eventId:e.eventId}),"purchase"===n.name&&e.sessionId&&a&&s){const t=(I?.scripts??[]).find(e=>"ga4"===e.provider&&e.providerId);t&&ne("ga4",t.providerId??"")&&function(e,t,n){try{const r=e.serverUrl.replace(/\/$/,"");fetch(`${r}/api/v1/public/${encodeURIComponent(e.orgId)}/checkout/${encodeURIComponent(t)}/reported`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n}),keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}({serverUrl:a,orgId:s},e.sessionId,"ga4")}},[a,s,ue,I]),[ge]=n(()=>"undefined"==typeof window?"":window.location.search);i(()=>{if(!d||!x)return;if("undefined"==typeof window)return;const e=P(window.location.search);if(e)return void pe(e);const t=S(ge);t&&ue("checkout_abandoned",{...t.workspaceId?{workspace_id:t.workspaceId}:{},...t.planVersionId?{plan_version_id:t.planVersionId}:{},...t.creditPackageId?{credit_package_id:t.creditPackageId}:{},...t.billingInterval?{billing_interval:t.billingInterval}:{},...t.currency?{currency:t.currency.toUpperCase()}:{},..."number"==typeof t.value?{value:t.value}:{},seconds_at_checkout:Math.max(0,Math.round((Date.now()-t.startedAt)/1e3))})},[d,x,pe,ge,ue]);const fe=r(e=>{D.current=e,E(e),T(e)},[]),me=r((e,t)=>function(e,t,n){const r=Z();if(!r)return;const i=!!n&&Object.keys(n).length>0;for(const o of t)switch(o.provider){case"ga4":case"google_ads":r.gtag?.("set",{user_id:e}),i&&r.gtag?.("set",{user_properties:n});break;case"meta_pixel":o.providerId&&r.fbq?.("init",o.providerId,{external_id:e});break;case"posthog":r.posthog?.identify?.(e,i?n:void 0);break;case"clarity":if(r.clarity?.("identify",e),i)for(const[e,t]of Object.entries(n))r.clarity?.("set",e,String(t));break;case"hotjar":r.hj?.("identify",e,{});break;case"tiktok":{const t=r.ttq;t?.identify?.({external_id:e});break}}}(e,ce,t),[ce]),he=o(()=>({consent:{manifest:I?.consent?.manifest??[],state:O,set:fe},track:ue,setUser:me,setProperties:K,getProperties:J,completeCheckout:pe,installed:{...ee.current},ready:x,attribution:Q}),[I,O,fe,ue,me,K,J,pe,x,te,Q]);return e(se.Provider,{value:he,children:_})};function ue(e={}){const{completeCheckout:n,ready:r}=de(),o=t(e);o.current=e;const a=t(!1);i(()=>{if(!r)return;if(a.current)return;const e=P(window.location.search)??q();e&&(a.current=!0,n(e,o.current))},[r,n])}le.displayName="BuildBaseTracking";const pe={sign_in_started:"The sign-in / sign-up button was pressed.",pricing_viewed:"A <PricingPage> finished loading its plans.",pricing_plan_selected:"A plan was chosen on a <PricingPage>.",workspace_switcher_opened:"The workspace switcher was opened.",workspace_settings_opened:"The workspace settings modal was opened.",workspace_settings_section_viewed:"A different section of the settings modal was opened.",plan_picker_opened:"The plan picker was shown.",billing_interval_changed:"Monthly / quarterly / yearly was switched in the plan picker.",plan_selected:"A plan was chosen in the plan picker.",plan_picker_dismissed:"The plan picker was closed without choosing a plan.",checkout_abandoned:"The customer came back from Stripe without paying.",billing_portal_opened:"Stripe’s billing portal was opened.",subscription_cancel_started:"The cancel-subscription confirmation was opened.",subscription_cancelled:"A subscription was cancelled.",subscription_resumed:"A cancelled subscription was resumed.",feature_gate_shown:'A feature gate rendered its "not on your plan" side.',quota_limit_reached:"A quota gate rendered because a quota is used up.",quota_threshold_reached:"A usage-threshold gate rendered.",plan_gate_shown:'A plan gate rendered its "needs another plan" side.',subscription_notice_shown:"A billing notice (trial ending, payment failed…) was shown.",sdk_error:"An SDK operation failed (component, action and code only)."};export{p as ATTRIBUTION_PARAMS,le as BuildBaseTracking,F as EVENT_MAPPINGS,pe as FUNNEL_EVENTS,M as TAG_PROVIDERS,D as TAG_PROVIDER_IDS,V as TAG_SCRIPT_ORIGINS,v as captureAttribution,_ as getAttribution,W as isCanonicalEvent,N as isTagProviderId,B as isValidProviderId,ue as useCheckoutCompleted,de as useTracking};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildbase/sdk",
3
- "version": "0.0.67",
3
+ "version": "0.0.70",
4
4
  "type": "module",
5
5
  "description": "A SDK for Buildbase",
6
6
  "main": "dist/index.cjs",