// src/decisions/schema.ts
import { z as z2 } from "zod";

// ../sdk-contracts/dist/icons.js
var PREFIX = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"';
var EMOJI_SVG_PATHS = {
  // ── existing in adaptive-nav ─────────────────────────────────────────────
  "\u{1F4B5}": [
    '<rect width="20" height="12" x="2" y="6" rx="2"/>',
    '<circle cx="12" cy="12" r="2"/>',
    '<path d="M6 12h.01M18 12h.01"/>'
  ],
  "\u{1F3DB}\uFE0F": [
    '<line x1="3" x2="21" y1="22" y2="22"/>',
    '<line x1="6" x2="6" y1="18" y2="11"/>',
    '<line x1="10" x2="10" y1="18" y2="11"/>',
    '<line x1="14" x2="14" y1="18" y2="11"/>',
    '<line x1="18" x2="18" y1="18" y2="11"/>',
    '<polygon points="12 2 20 7 4 7"/>'
  ],
  "\u23ED\uFE0F": ['<polygon points="5 4 15 12 5 20 5 4"/>', '<line x1="19" x2="19" y1="5" y2="19"/>'],
  "\u27A1\uFE0F": ['<path d="M5 12h14"/>', '<path d="m12 5 7 7-7 7"/>'],
  "\u{1F4A1}": [
    '<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/>',
    '<path d="M9 18h6"/>',
    '<path d="M10 22h4"/>'
  ],
  "\u{1F4B0}": [
    '<rect width="20" height="12" x="2" y="6" rx="2"/>',
    '<circle cx="12" cy="12" r="2"/>',
    '<path d="M6 12h.01M18 12h.01"/>'
  ],
  "\u{1F4CB}": [
    '<rect width="8" height="4" x="8" y="2" rx="1" ry="1"/>',
    '<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/>',
    '<path d="M12 11h4"/>',
    '<path d="M12 16h4"/>',
    '<path d="M8 11h.01"/>',
    '<path d="M8 16h.01"/>'
  ],
  "\u2705": ['<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>', '<path d="m9 11 3 3L22 4"/>'],
  "\u26A0\uFE0F": [
    '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/>',
    '<path d="M12 9v4"/>',
    '<path d="M12 17h.01"/>'
  ],
  // ── added for healthmaxxer action_plans ──────────────────────────────────
  "\u{1F6E1}\uFE0F": [
    '<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/>'
  ],
  "\u{1F4C8}": [
    '<polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/>',
    '<polyline points="16 7 22 7 22 13"/>'
  ],
  "\u{1F52C}": [
    '<path d="M6 18h8"/>',
    '<path d="M3 22h18"/>',
    '<path d="M14 22a7 7 0 1 0 0-14h-1"/>',
    '<path d="M9 14h2"/>',
    '<path d="M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z"/>',
    '<path d="M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3"/>'
  ],
  "\u{1F48A}": [
    '<path d="m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z"/>',
    '<path d="m8.5 8.5 7 7"/>'
  ],
  "\u{1F4C4}": [
    '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/>',
    '<path d="M14 2v4a2 2 0 0 0 2 2h4"/>',
    '<path d="M10 9H8"/>',
    '<path d="M16 13H8"/>',
    '<path d="M16 17H8"/>'
  ],
  "\u{1F9EA}": [
    '<path d="M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2"/>',
    '<path d="M6.453 15h11.094"/>',
    '<path d="M8.5 2h7"/>'
  ],
  "\u{1F501}": [
    '<path d="m17 2 4 4-4 4"/>',
    '<path d="M3 11v-1a4 4 0 0 1 4-4h14"/>',
    '<path d="m7 22-4-4 4-4"/>',
    '<path d="M21 13v1a4 4 0 0 1-4 4H3"/>'
  ],
  "\u{1F9E0}": [
    '<path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/>',
    '<path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/>',
    '<path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/>',
    '<path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/>',
    '<path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/>',
    '<path d="M3.477 10.896a4 4 0 0 1 .585-.396"/>',
    '<path d="M19.938 10.5a4 4 0 0 1 .585.396"/>',
    '<path d="M6 18a4 4 0 0 1-1.967-.516"/>',
    '<path d="M19.967 17.484A4 4 0 0 1 18 18"/>'
  ],
  "\u{1F319}": ['<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'],
  "\u{1F4E6}": [
    '<path d="M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"/>',
    '<path d="M12 22V12"/>',
    '<path d="m3.3 7 8.7 5 8.7-5"/>',
    '<path d="m7.5 4.27 9 5.15"/>'
  ],
  "\u{1F69A}": [
    // Lucide truck
    '<path d="M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2"/>',
    '<path d="M15 18H9"/>',
    '<path d="M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14"/>',
    '<circle cx="17" cy="18" r="2"/>',
    '<circle cx="7" cy="18" r="2"/>'
  ],
  "\u{1F331}": [
    '<path d="M7 20h10"/>',
    '<path d="M10 20c5.5-2.5.8-6.4 3-10"/>',
    '<path d="M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z"/>',
    '<path d="M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z"/>'
  ],
  "\u26A1": [
    '<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>'
  ],
  "\u{1F525}": [
    // Lucide flame
    '<path d="M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"/>'
  ],
  "\u{1F333}": [
    '<path d="M12 22V8"/>',
    '<path d="m17 8-5-6-5 6"/>',
    '<path d="M12 12c-2-2-4-2-4-2 0 0 0 4 2 6 1.5 1.5 3 1 4 0"/>',
    '<path d="M12 12c2-2 4-2 4-2 0 0 0 4-2 6-1.5 1.5-3 1-4 0"/>'
  ],
  "\u{1F33F}": [
    '<path d="M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19.2 2.96a1 1 0 0 1 1.8.5c0 6-2 11-9 16.5"/>',
    '<path d="M2 21c0-3 1.85-5.36 5.08-6"/>'
  ],
  // ── added for runtime-sdk SyntroTileCard / SyntroToastStack ──────────────
  "\u2753": [
    // HelpCircle
    '<circle cx="12" cy="12" r="10"/>',
    '<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/>',
    '<path d="M12 17h.01"/>'
  ],
  "\u{1F9ED}": [
    // Compass
    '<circle cx="12" cy="12" r="10"/>',
    '<polygon points="16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76"/>'
  ],
  "\u{1F4DD}": [
    // FileText
    '<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>',
    '<polyline points="14 2 14 8 20 8"/>',
    '<line x1="16" y1="13" x2="8" y2="13"/>',
    '<line x1="16" y1="17" x2="8" y2="17"/>',
    '<line x1="10" y1="9" x2="8" y2="9"/>'
  ],
  "\u{1F3AF}": [
    // Layers (bullseye-shaped emoji rendered as Lucide Layers — historical)
    '<polygon points="12 2 2 7 12 12 22 7 12 2"/>',
    '<polyline points="2 17 12 22 22 17"/>',
    '<polyline points="2 12 12 17 22 12"/>'
  ],
  "\u{1F3C6}": [
    // Trophy
    '<path d="M6 9H4.5a2.5 2.5 0 0 1 0-5H6"/>',
    '<path d="M18 9h1.5a2.5 2.5 0 0 0 0-5H18"/>',
    '<path d="M4 22h16"/>',
    '<path d="M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"/>',
    '<path d="M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"/>',
    '<path d="M18 2H6v7a6 6 0 0 0 12 0V2Z"/>'
  ],
  "\u2728": [
    // Sparkles
    '<path d="m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z"/>',
    '<path d="M5 3v4"/>',
    '<path d="M19 17v4"/>',
    '<path d="M3 5h4"/>',
    '<path d="M17 19h4"/>'
  ],
  "\u{1F4AC}": [
    // MessageCircle
    '<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/>'
  ],
  "\u{1F3AE}": [
    // Gamepad2
    '<line x1="6" y1="11" x2="10" y2="11"/>',
    '<line x1="8" y1="9" x2="8" y2="13"/>',
    '<line x1="15" y1="12" x2="15.01" y2="12"/>',
    '<line x1="18" y1="10" x2="18.01" y2="10"/>',
    '<path d="M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z"/>'
  ],
  "\u23F1\uFE0F": [
    // Timer
    '<line x1="10" y1="2" x2="14" y2="2"/>',
    '<line x1="12" y1="14" x2="12" y2="8"/>',
    '<circle cx="12" cy="14" r="8"/>'
  ],
  "\u{1F4D6}": [
    // BookOpen
    '<path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/>',
    '<path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/>'
  ],
  "\u{1F514}": [
    // Bell
    '<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/>',
    '<path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>'
  ],
  // ── common UI icons ──────────────────────────────────────────────────────
  "\u{1F393}": [
    // GraduationCap
    '<path d="M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z"/>',
    '<path d="M22 10v6"/>',
    '<path d="M6 12.5V16a6 3 0 0 0 12 0v-3.5"/>'
  ],
  "\u23F0": [
    // AlarmClock
    '<circle cx="12" cy="13" r="8"/>',
    '<path d="M12 9v4l2 2"/>',
    '<path d="M5 3 2 6"/>',
    '<path d="m22 6-3-3"/>',
    '<path d="M6.38 18.7 4 21"/>',
    '<path d="M17.64 18.67 20 21"/>'
  ],
  "\u{1F504}": [
    // RefreshCw
    '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/>',
    '<path d="M21 3v5h-5"/>',
    '<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/>',
    '<path d="M8 16H3v5"/>'
  ],
  "\u{1F464}": [
    // User
    '<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/>',
    '<circle cx="12" cy="7" r="4"/>'
  ],
  "\u{1F3E0}": [
    // House
    '<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/>',
    '<path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>'
  ],
  "\u{1F6D2}": [
    // ShoppingCart
    '<circle cx="8" cy="21" r="1"/>',
    '<circle cx="19" cy="21" r="1"/>',
    '<path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>'
  ],
  // ── viz / chart icons (paired with adaptive-viz) ─────────────────────────
  "\u{1F4CA}": [
    // BarChart3 — pairs with 📈 (TrendingUp)
    '<path d="M3 3v18h18"/>',
    '<path d="M18 17V9"/>',
    '<path d="M13 17V5"/>',
    '<path d="M8 17v-3"/>'
  ],
  "\u{1F4C9}": [
    // TrendingDown
    '<polyline points="22 17 13.5 8.5 8.5 13.5 2 7"/>',
    '<polyline points="16 17 22 17 22 11"/>'
  ],
  "\u{1F967}": [
    // PieChart
    '<path d="M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z"/>',
    '<path d="M21.21 15.89A10 10 0 1 1 8 2.83"/>'
  ],
  "\u{1F4B9}": [
    // Activity — line-chart-style waveform
    '<path d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.5.5 0 0 1-.96 0L9.24 2.18a.5.5 0 0 0-.96 0l-2.35 8.36A2 2 0 0 1 4.02 12H2"/>'
  ],
  "\u{1F321}\uFE0F": [
    // Thermometer — gauge-style indicator
    '<path d="M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z"/>'
  ]
};
function renderIcon(emoji, options = {}) {
  var _a, _b;
  const paths = EMOJI_SVG_PATHS[emoji];
  if (!paths)
    return "";
  const size = (_a = options.size) != null ? _a : 14;
  const stroke = (_b = options.color) != null ? _b : "currentColor";
  return `${PREFIX} width="${size}" height="${size}" stroke="${stroke}">${paths.join("")}</svg>`;
}

// ../sdk-contracts/dist/schemas.js
import { z } from "zod";
var AnchorIdZ = z.object({
  selector: z.string(),
  route: z.union([z.string(), z.array(z.string())])
}).strict();
var AuthoringFieldsZ = {
  title: z.string().max(200).optional().describe("Authoring-only: short label shown on the action plan dashboard. Stripped before serving to the runtime SDK."),
  description: z.string().max(1e3).optional().describe("Authoring-only: one-sentence explanation of what this action does and why. Stripped before serving to the runtime SDK."),
  validation: z.array(z.string().max(500)).max(10).optional().describe("Authoring-only: ordered steps a reviewer can follow to trigger this action and visually confirm it works. Each entry is one step. Stripped before serving to the runtime SDK.")
};
var COUNTABLE_EVENTS = [
  // User interactions (from PostHog autocapture normalization)
  "ui.click",
  "ui.scroll",
  "ui.input",
  "ui.change",
  "ui.submit",
  // Behavioral detectors (from event-processor)
  "ui.hover",
  "ui.idle",
  "ui.scroll_thrash",
  "ui.focus_bounce",
  // Navigation
  "nav.page_view",
  "nav.page_leave",
  // Derived behavioral signals
  "behavior.rage_click",
  "behavior.hesitation",
  "behavior.confusion"
];
var CountableEventZ = z.enum(COUNTABLE_EVENTS).describe("Event name to count. ui.* = user interactions and behavioral detectors, nav.* = page navigation, behavior.* = derived behavioral signals.");
var SESSION_METRIC_KEYS = ["time_on_page", "page_views", "scroll_depth"];
var SessionMetricKeyZ = z.enum(SESSION_METRIC_KEYS).describe("Session metric key. time_on_page = seconds on current page, page_views = pages visited this session, scroll_depth = 0-100 percentage.");
var PageUrlConditionZ = z.object({
  type: z.literal("page_url"),
  url: z.string().describe('URL path to match (e.g. "/pricing", "/dashboard")')
}).describe('Fires when the current page URL matches. Use for page-specific actions. Example: {"type": "page_url", "url": "/pricing"}');
var RouteConditionZ = z.object({
  type: z.literal("route"),
  routeId: z.string().describe("Named route ID from the route filter")
}).describe("Fires when the current route matches a named route ID.");
var AnchorVisibleConditionZ = z.object({
  type: z.literal("anchor_visible"),
  anchorId: z.string().describe("CSS selector of the anchor element"),
  state: z.enum(["visible", "present", "absent"]).describe('"visible" = in viewport, "present" = in DOM, "absent" = not in DOM')
}).describe(`Fires based on a DOM element's visibility state. Example: {"type": "anchor_visible", "anchorId": "#cta-button", "state": "visible"}`);
var EventOccurredConditionZ = z.object({
  type: z.literal("event_occurred"),
  eventName: z.string().describe('Event name (e.g. "ui.click", "$pageview")'),
  withinMs: z.number().optional().describe("Time window in ms. Omit = any time this session.")
}).describe('Fires when a specific event has occurred during this session. Example: {"type": "event_occurred", "eventName": "ui.click", "withinMs": 5000}');
var StateEqualsConditionZ = z.object({
  type: z.literal("state_equals"),
  key: z.string().describe("Key in the SDK persistent state store (localStorage). Only valid for keys the host app explicitly sets via syntro.state.set()."),
  value: z.unknown().describe("Expected value to match against")
}).describe("Checks the SDK persistent state store (localStorage). ONLY for host-app state set via syntro.state.set() \u2014 NOT for user attributes like region, device, or UTM params (those are handled by segment targeting). Do NOT use this for targeting. If you do not know the valid state keys, do not use this condition type.");
var ViewportConditionZ = z.object({
  type: z.literal("viewport"),
  minWidth: z.number().optional().describe("Minimum viewport width in pixels"),
  maxWidth: z.number().optional().describe("Maximum viewport width in pixels"),
  minHeight: z.number().optional().describe("Minimum viewport height in pixels"),
  maxHeight: z.number().optional().describe("Maximum viewport height in pixels")
}).describe('Fires based on viewport (screen) size. Use for responsive behavior. Example: {"type": "viewport", "minWidth": 768} \u2014 fires on tablet and larger.');
var SessionMetricConditionZ = z.object({
  type: z.literal("session_metric"),
  key: SessionMetricKeyZ,
  operator: z.enum(["gte", "lte", "eq", "gt", "lt"]),
  threshold: z.number().describe("Numeric threshold to compare against")
}).describe('Fires when a session metric crosses a threshold. Valid keys: "time_on_page" (seconds), "page_views" (count), "scroll_depth" (0-100). Example: {"type": "session_metric", "key": "time_on_page", "operator": "gte", "threshold": 30}');
var DismissedConditionZ = z.object({
  type: z.literal("dismissed"),
  key: z.string().describe("Dismissal key (usually a tile or action ID)"),
  inverted: z.boolean().optional().describe("When true, fires if NOT dismissed (default behavior)")
}).describe("Checks if an item has been dismissed by the user. Use with inverted: true to show only if not dismissed.");
var CooldownActiveConditionZ = z.object({
  type: z.literal("cooldown_active"),
  key: z.string().describe("Cooldown key"),
  inverted: z.boolean().optional().describe("When true, fires if cooldown is NOT active")
}).describe("Checks if a cooldown timer is currently active. Use to prevent showing the same intervention too frequently.");
var FrequencyLimitConditionZ = z.object({
  type: z.literal("frequency_limit"),
  key: z.string().describe("Frequency counter key"),
  limit: z.number().describe("Maximum allowed count"),
  inverted: z.boolean().optional().describe("When true, fires if limit NOT reached")
}).describe("Checks if a frequency limit has been reached. Use to cap how many times an action fires per session.");
var MatchOpZ = z.object({
  equals: z.union([z.string(), z.number(), z.boolean()]).optional(),
  contains: z.string().optional()
}).describe("Match operator for counter filters. Exactly one of equals or contains must be specified.");
var CounterDefZ = z.object({
  events: z.array(CountableEventZ).min(1).describe("Event names to count. Use values from the countable events enum."),
  match: z.record(z.string(), MatchOpZ).optional().describe("Property filters. Keys are event prop names or element-chain fields (tag_name, $el_text, attr__*). All entries AND together.")
}).describe("Defines what events to count. Registered as an accumulator predicate at config-load time.");
var EventCountConditionZ = z.object({
  type: z.literal("event_count"),
  key: z.string().describe("Unique key for this counter (used for accumulator registration)"),
  operator: z.enum(["gte", "lte", "eq", "gt", "lt"]),
  count: z.number().int().min(0).describe("Target count threshold"),
  withinMs: z.number().positive().optional().describe("Time window in ms. Omit = count across entire session."),
  counter: CounterDefZ.optional().describe("Inline counter definition. Defines what events to count.")
}).describe('Fires when accumulated event count crosses a threshold. Most powerful trigger type. Example: {"type": "event_count", "key": "pricing-clicks", "operator": "gte", "count": 3, "counter": {"events": ["ui.click"], "match": {"attr__data-cta": {"contains": "pricing"}}}}');
var ConditionZ = z.discriminatedUnion("type", [
  PageUrlConditionZ,
  RouteConditionZ,
  AnchorVisibleConditionZ,
  EventOccurredConditionZ,
  StateEqualsConditionZ,
  ViewportConditionZ,
  SessionMetricConditionZ,
  DismissedConditionZ,
  CooldownActiveConditionZ,
  FrequencyLimitConditionZ,
  EventCountConditionZ
]);
var RuleZ = z.object({
  conditions: z.array(ConditionZ).describe("Array of conditions \u2014 ALL must match (AND logic) for this rule to fire."),
  value: z.unknown().describe("Value returned when all conditions match. For triggerWhen: true = fire the action.")
}).describe("A single rule. ALL conditions must match (AND logic). Rules in a strategy are evaluated top-to-bottom \u2014 first rule where all conditions match wins and returns its value.");
var RuleStrategyZ = z.object({
  type: z.literal("rules"),
  rules: z.array(RuleZ).describe("Ordered list of rules. Evaluated top-to-bottom \u2014 first match wins."),
  default: z.unknown().describe("Fallback value when no rule matches. For triggerWhen: false = do not fire by default.")
}).describe("Rule-based strategy. Evaluates rules top-to-bottom. First rule where ALL conditions match returns its value. If no rule matches, returns default. For triggerWhen: set value=true on matching rules, default=false.");
var ScoreStrategyZ = z.object({
  type: z.literal("score"),
  field: z.string(),
  threshold: z.number(),
  above: z.unknown(),
  below: z.unknown()
}).describe("Score-based strategy. Compares a field value against a threshold.");
var ModelStrategyZ = z.object({
  type: z.literal("model"),
  modelId: z.string(),
  inputs: z.array(z.string()),
  outputMapping: z.record(z.string(), z.unknown()),
  default: z.unknown()
}).describe("ML model strategy. Sends inputs to a model and maps outputs.");
var ExternalStrategyZ = z.object({
  type: z.literal("external"),
  endpoint: z.string(),
  method: z.enum(["GET", "POST"]).optional(),
  default: z.unknown(),
  timeoutMs: z.number().optional()
}).describe("External API strategy. Calls an endpoint to determine the value.");
var DecisionStrategyZ = z.discriminatedUnion("type", [
  RuleStrategyZ,
  ScoreStrategyZ,
  ModelStrategyZ,
  ExternalStrategyZ
]);
var TriggerWhenZ = DecisionStrategyZ.nullable().optional();
var EventScopeZ = z.object({
  events: z.array(z.string()),
  urlContains: z.string().optional(),
  props: z.record(z.union([z.string(), z.number(), z.boolean()])).optional()
});
var NotifyZ = z.object({
  title: z.string().optional(),
  body: z.string().optional(),
  icon: z.string().optional()
}).nullable().optional();

// src/decisions/schema.ts
var RouteFilterZ = z2.object({
  include: z2.array(z2.string()).optional().describe(
    "URL patterns where this tile appears. Supports *, **, :param wildcards. Use sparingly \u2014 mostly to isolate to specific webapp functionality. Omit to appear on all routes."
  ),
  exclude: z2.array(z2.string()).optional().describe("URL patterns where this tile should NOT appear. Evaluated before include.")
});
var ActivationConfigZ = z2.object({
  routes: RouteFilterZ,
  onlyIfPopulated: z2.boolean().optional().describe(
    "When true, tile is hidden if none of its props.actions[] have an active triggerWhen. Useful for tiles with all-deferred FAQ questions or nav tips. Default: false."
  )
});
function validateCondition(data) {
  return ConditionZ.safeParse(data);
}
function validateStrategy(data) {
  return DecisionStrategyZ.safeParse(data);
}
function validateActivationConfig(data) {
  return ActivationConfigZ.safeParse(data);
}
var decisionSchemas = [
  { defName: "matchOp", schema: MatchOpZ },
  { defName: "counterDef", schema: CounterDefZ },
  { defName: "activationConfig", schema: ActivationConfigZ },
  { defName: "routeFilter", schema: RouteFilterZ },
  { defName: "ruleStrategy", schema: RuleStrategyZ },
  { defName: "scoreStrategy", schema: ScoreStrategyZ },
  { defName: "modelStrategy", schema: ModelStrategyZ },
  { defName: "externalStrategy", schema: ExternalStrategyZ },
  { defName: "rule", schema: RuleZ },
  { defName: "condition", schema: ConditionZ }
];

export {
  renderIcon,
  AuthoringFieldsZ,
  PageUrlConditionZ,
  RouteConditionZ,
  AnchorVisibleConditionZ,
  EventOccurredConditionZ,
  StateEqualsConditionZ,
  ViewportConditionZ,
  SessionMetricConditionZ,
  DismissedConditionZ,
  CooldownActiveConditionZ,
  FrequencyLimitConditionZ,
  MatchOpZ,
  CounterDefZ,
  EventCountConditionZ,
  ConditionZ,
  RuleZ,
  RuleStrategyZ,
  ScoreStrategyZ,
  ModelStrategyZ,
  ExternalStrategyZ,
  DecisionStrategyZ,
  TriggerWhenZ,
  RouteFilterZ,
  ActivationConfigZ,
  validateCondition,
  validateStrategy,
  validateActivationConfig,
  decisionSchemas
};
//# sourceMappingURL=chunk-LSU6P3XW.js.map
