import {
  NotificationDeepLinkZ
} from "./chunk-3EK46GSN.js";
import {
  AuthoringFieldsZ,
  TriggerWhenZ
} from "./chunk-LSU6P3XW.js";

// src/actions/schema.ts
import { z } from "zod";
var ActionTriggerZ = {
  triggerWhen: TriggerWhenZ
};
var AnchorIdZ = z.object({
  selector: z.string(),
  route: z.union([z.string(), z.array(z.string())])
}).strict();
var HighlightStyleZ = z.object({
  color: z.string().optional(),
  scrimOpacity: z.number().min(0).max(1).optional(),
  paddingPx: z.number().optional(),
  radiusPx: z.number().optional()
}).strict();
var BadgePositionZ = z.enum(["top-left", "top-right", "bottom-left", "bottom-right"]);
var PlacementZ = z.enum([
  "top",
  "top-start",
  "top-end",
  "bottom",
  "bottom-start",
  "bottom-end",
  "left",
  "left-start",
  "left-end",
  "right",
  "right-start",
  "right-end"
]);
var SAFE_HREF_PATTERN = /^(?:[/.#?]|[hH][tT][tT][pP][sS]?:\/\/|[mM][aA][iI][lL][tT][oO]:|[tT][eE][lL]:)/;
var HrefZ = z.string().min(1).regex(SAFE_HREF_PATTERN, {
  message: "href must start with /, ./, ../, #, ?, http(s)://, mailto:, or tel: \u2014 javascript:, data:, and vbscript: are not allowed"
}).refine(
  (s) => {
    try {
      const parsed = new URL(s, "https://syntro.local/");
      return ["http:", "https:", "mailto:", "tel:"].includes(parsed.protocol);
    } catch {
      return false;
    }
  },
  { message: "href resolves to an unsupported protocol" }
);
var CtaButtonZ = z.object({
  label: z.string().describe("Visible button label."),
  actionId: z.string().describe(
    'Identifier emitted on action.modal_cta_clicked / action.tooltip_cta_clicked. Use "dismiss" to close the overlay without publishing an event or navigating, even if href is set.'
  ),
  primary: z.boolean().optional().describe("When true, renders as the primary (filled) button. Defaults to false."),
  href: HrefZ.optional().describe(
    'URL to navigate to when the button is clicked. Use this to drive users to a destination (product page, signup, etc.) \u2014 set href on a non-dismiss button rather than relying on actionId conventions or content:setAttr tricks. Accepts relative paths ("/product/x"), fragments ("#section"), query strings, and absolute http(s) URLs. javascript:/data:/vbscript: are rejected.'
  ),
  target: z.enum(["_self", "_blank"]).optional().describe(
    'Navigation target. "_self" (default) replaces the current tab; "_blank" opens a new tab with noopener,noreferrer.'
  )
}).strict();
var TooltipContentZ = z.object({
  title: z.string().optional(),
  body: z.string(),
  ctaButtons: z.array(CtaButtonZ).optional()
}).strict();
var ModalContentZ = z.object({
  title: z.string().optional(),
  body: z.string()
}).strict();
var InsertPositionZ = z.enum(["before", "after", "prepend", "append", "replace"]);
var TooltipTriggerZ = z.enum(["immediate", "hover", "click"]);
var WidgetConfigZ = z.object({
  widgetId: z.string(),
  props: z.record(z.unknown()).optional(),
  priority: z.number().optional()
}).strict();
var TourStepForSchemaZ = z.object({
  id: z.string(),
  action: z.any(),
  route: z.string().optional(),
  onAction: z.record(z.string()).optional()
}).passthrough();
var ScrollBehaviorZ = z.enum(["auto", "smooth", "instant"]);
var ScrollLogicalPositionZ = z.enum(["start", "center", "end", "nearest"]);
var SetTextZ = z.object({
  kind: z.literal("content:setText"),
  anchorId: AnchorIdZ,
  text: z.string(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var SetAttrZ = z.object({
  kind: z.literal("content:setAttr"),
  anchorId: AnchorIdZ,
  attr: z.string(),
  value: z.string(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var AddClassZ = z.object({
  kind: z.literal("content:addClass"),
  anchorId: AnchorIdZ,
  className: z.string(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var RemoveClassZ = z.object({
  kind: z.literal("content:removeClass"),
  anchorId: AnchorIdZ,
  className: z.string(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var SetStyleZ = z.object({
  kind: z.literal("content:setStyle"),
  anchorId: AnchorIdZ,
  styles: z.record(z.string()),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var InsertHtmlZ = z.object({
  kind: z.literal("content:insertHtml"),
  anchorId: AnchorIdZ,
  html: z.string(),
  position: InsertPositionZ,
  deepLink: NotificationDeepLinkZ.optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var HighlightZ = z.object({
  kind: z.literal("overlays:highlight"),
  anchorId: AnchorIdZ,
  style: HighlightStyleZ.optional(),
  duration: z.number().optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var PulseZ = z.object({
  kind: z.literal("overlays:pulse"),
  anchorId: AnchorIdZ,
  duration: z.number().optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var BadgeZ = z.object({
  kind: z.literal("overlays:badge"),
  anchorId: AnchorIdZ,
  content: z.string(),
  position: BadgePositionZ.optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var TooltipZ = z.object({
  kind: z.literal("overlays:tooltip"),
  anchorId: AnchorIdZ,
  content: TooltipContentZ,
  trigger: TooltipTriggerZ.optional(),
  placement: PlacementZ.optional(),
  waitFor: z.string().optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var ModalZ = z.object({
  kind: z.literal("overlays:modal"),
  content: ModalContentZ,
  size: z.enum(["sm", "md", "lg"]).optional(),
  blocking: z.boolean().optional(),
  scrim: z.object({
    opacity: z.number().min(0).max(1).optional()
  }).strict().optional(),
  dismiss: z.object({
    onEsc: z.boolean().optional(),
    closeButton: z.boolean().optional(),
    timeoutMs: z.number().min(0).optional()
  }).strict().optional(),
  ctaButtons: z.array(CtaButtonZ).optional(),
  waitFor: z.string().optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var ScrollToZ = z.object({
  kind: z.literal("navigation:scrollTo"),
  anchorId: AnchorIdZ,
  behavior: ScrollBehaviorZ.optional(),
  block: ScrollLogicalPositionZ.optional(),
  inline: ScrollLogicalPositionZ.optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var NavigateZ = z.object({
  kind: z.literal("navigation:navigate"),
  url: z.string(),
  target: z.enum(["_self", "_blank"]).optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var MountWidgetZ = z.object({
  kind: z.literal("core:mountWidget"),
  slot: z.string(),
  widget: WidgetConfigZ,
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var WaitZ = z.object({
  kind: z.literal("core:wait"),
  durationMs: z.number().min(0).optional(),
  event: z.string().optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var SequenceZ = z.object({
  kind: z.literal("core:sequence"),
  actions: z.array(z.any()),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var ParallelZ = z.object({
  kind: z.literal("core:parallel"),
  actions: z.array(z.any()),
  waitFor: z.enum(["all", "any"]).optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).strict();
var TourZ = z.object({
  kind: z.literal("overlays:tour"),
  tourId: z.string(),
  steps: z.array(TourStepForSchemaZ).min(1),
  startStep: z.string().optional(),
  autoStart: z.boolean().optional(),
  label: z.string().optional()
}).extend(ActionTriggerZ).extend(AuthoringFieldsZ).passthrough();
var coreActionStepSchemas = [
  { defName: "setText", schema: SetTextZ },
  { defName: "setAttr", schema: SetAttrZ },
  { defName: "addClass", schema: AddClassZ },
  { defName: "removeClass", schema: RemoveClassZ },
  { defName: "setStyle", schema: SetStyleZ },
  { defName: "insertHtml", schema: InsertHtmlZ },
  { defName: "highlight", schema: HighlightZ },
  { defName: "pulse", schema: PulseZ },
  { defName: "badge", schema: BadgeZ },
  { defName: "tooltip", schema: TooltipZ },
  { defName: "modal", schema: ModalZ },
  { defName: "scrollTo", schema: ScrollToZ },
  { defName: "navigate", schema: NavigateZ },
  { defName: "mountWidget", schema: MountWidgetZ },
  { defName: "wait", schema: WaitZ },
  { defName: "sequence", schema: SequenceZ },
  { defName: "parallel", schema: ParallelZ },
  { defName: "tour", schema: TourZ }
];

export {
  AnchorIdZ,
  HighlightStyleZ,
  BadgePositionZ,
  PlacementZ,
  CtaButtonZ,
  TooltipContentZ,
  ModalContentZ,
  InsertPositionZ,
  TooltipTriggerZ,
  WidgetConfigZ,
  TourStepForSchemaZ,
  ScrollBehaviorZ,
  ScrollLogicalPositionZ,
  SetTextZ,
  SetAttrZ,
  AddClassZ,
  RemoveClassZ,
  SetStyleZ,
  InsertHtmlZ,
  HighlightZ,
  PulseZ,
  BadgeZ,
  TooltipZ,
  ModalZ,
  ScrollToZ,
  NavigateZ,
  MountWidgetZ,
  WaitZ,
  SequenceZ,
  ParallelZ,
  TourZ,
  coreActionStepSchemas
};
//# sourceMappingURL=chunk-TVREQFRK.js.map
