@guidelytech/shared 0.2.1 → 0.4.1

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 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/targeting.ts","../src/targeting-eval.ts","../src/guide.ts","../src/events.ts","../src/events-util.ts","../src/sdk-api.ts","../src/messenger.ts","../src/templates.ts"],"sourcesContent":["export * from \"./utils\";\nexport * from \"./targeting\";\nexport * from \"./guide\";\nexport * from \"./events\";\nexport * from \"./sdk-api\";\nexport * from \"./messenger\";\nexport * from \"./templates\";\nexport const SDK_API_VERSION = \"v1\";\nexport const SHARED_VERSION = \"0.2.1\";\n","/** FNV-1a 32-bit hash; deterministic across SDK and server for rollout bucketing. */\nexport function fnv1a(input: string): number {\n let h = 0x811c9dc5;\n for (let i = 0; i < input.length; i++) {\n h ^= input.charCodeAt(i);\n h = Math.imul(h, 0x01000193) >>> 0;\n }\n return h >>> 0;\n}\n\n/** Deterministic 0-99 bucket for percentage rollouts. */\nexport function rolloutBucket(subject: string, salt: string): number {\n return fnv1a(`${salt}:${subject}`) % 100;\n}\n\nexport function slugify(input: string): string {\n return input\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 64) || \"untitled\";\n}\n\nconst ALPHABET = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n/** URL-safe random id. Uses crypto when available, falls back to Math.random (ids are not secrets). */\nexport function randomId(size = 16): string {\n const g: any = typeof globalThis !== \"undefined\" ? globalThis : {};\n let bytes: Uint8Array;\n if (g.crypto && typeof g.crypto.getRandomValues === \"function\") {\n bytes = new Uint8Array(size);\n g.crypto.getRandomValues(bytes);\n } else {\n bytes = new Uint8Array(size);\n for (let i = 0; i < size; i++) bytes[i] = Math.floor(Math.random() * 256);\n }\n let out = \"\";\n for (let i = 0; i < size; i++) out += ALPHABET[(bytes[i] as number) % ALPHABET.length];\n return out;\n}\n\nexport function isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/** Safe nested getter: get(obj, \"account.plan\") */\nexport function getPath(obj: unknown, path: string): unknown {\n if (!path) return obj;\n let cur: any = obj;\n for (const part of path.split(\".\")) {\n if (cur == null) return undefined;\n cur = cur[part];\n }\n return cur;\n}\n\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\n/** Glob-style URL pattern match: `*` matches any chars except `/`, `**` matches anything. */\nexport function matchUrlPattern(pattern: string, url: string): boolean {\n if (!pattern) return true;\n if (pattern === url) return true;\n const escaped = pattern\n .replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n .replace(/\\*\\*/g, \"__GLOBSTAR__\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/__GLOBSTAR__/g, \".*\");\n const re = new RegExp(`^${escaped}$`);\n return re.test(url) || re.test(stripOrigin(url));\n}\n\nexport function stripOrigin(url: string): string {\n try {\n const u = new URL(url);\n return u.pathname + u.search + u.hash;\n } catch {\n return url;\n }\n}\n\n/** Safe regexp construction with a length cap to limit ReDoS exposure. */\nexport function safeRegExp(source: string, flags = \"i\"): RegExp | null {\n if (!source || source.length > 200) return null;\n try {\n return new RegExp(source, flags);\n } catch {\n return null;\n }\n}\n","import { z } from \"zod\";\nimport { RULE_FIELDS, RULE_OPERATORS, type Rule, type RuleGroup } from \"./targeting-eval\";\n\nexport * from \"./targeting-eval\";\n\nexport const RuleSchema: z.ZodType<Rule> = z.object({\n id: z.string().min(1),\n field: z.enum(RULE_FIELDS),\n key: z.string().max(200).optional(),\n op: z.enum(RULE_OPERATORS),\n value: z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]).optional(),\n negate: z.boolean().optional(),\n});\n\nexport const RuleGroupSchema: z.ZodType<RuleGroup> = z.lazy(() =>\n z.object({\n id: z.string().min(1),\n op: z.enum([\"and\", \"or\"]),\n rules: z.array(z.union([RuleSchema, RuleGroupSchema])).max(100),\n negate: z.boolean().optional(),\n }),\n);\n","/**\n * Zod-free targeting evaluation. Imported by the browser SDK via `@guidelytech/shared/runtime`\n * so the runtime bundle does not pull in zod. Schemas live in ./targeting.ts.\n */\nimport { getPath, matchUrlPattern, rolloutBucket, safeRegExp } from \"./utils\";\n\nexport const RULE_OPERATORS = [\n \"equals\",\n \"not_equals\",\n \"contains\",\n \"not_contains\",\n \"starts_with\",\n \"ends_with\",\n \"exists\",\n \"not_exists\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"in\",\n \"not_in\",\n \"regex\",\n \"is_true\",\n \"is_false\",\n \"before\",\n \"after\",\n] as const;\nexport type RuleOperator = (typeof RULE_OPERATORS)[number];\n\nexport const RULE_FIELDS = [\n \"user.attribute\",\n \"account.attribute\",\n \"user.role\",\n \"user.plan\",\n \"url.path\",\n \"url.full\",\n \"url.query\",\n \"device.type\",\n \"device.browser\",\n \"device.os\",\n \"visitor.firstVisit\",\n \"visitor.returning\",\n \"event.seen\",\n \"guide.completed\",\n \"guide.dismissed\",\n \"guide.seen\",\n \"checklist.completed\",\n \"audience.member\",\n \"datetime.now\",\n \"datetime.dayOfWeek\",\n \"datetime.hour\",\n \"rollout.percentage\",\n \"environment\",\n \"locale\",\n] as const;\nexport type RuleField = (typeof RULE_FIELDS)[number];\n\nexport interface Rule {\n id: string;\n field: RuleField;\n /** For attribute/query/event fields: the attribute key, query param name, event name, guide id... */\n key?: string;\n op: RuleOperator;\n value?: string | number | boolean | string[];\n /** When true, the rule is negated (exclusion rule). */\n negate?: boolean;\n}\n\nexport type RuleGroup = {\n id: string;\n op: \"and\" | \"or\";\n rules: Array<Rule | RuleGroup>;\n negate?: boolean;\n};\n\nexport function isRuleGroup(r: Rule | RuleGroup): r is RuleGroup {\n return (r as RuleGroup).rules !== undefined;\n}\n\nexport function emptyRuleGroup(id = \"root\"): RuleGroup {\n return { id, op: \"and\", rules: [] };\n}\n\n/** Everything targeting evaluation can see. Built by the SDK (browser) or the server. */\nexport interface TargetingContext {\n userId?: string | null;\n anonymousId: string;\n userAttributes: Record<string, unknown>;\n accountAttributes: Record<string, unknown>;\n url: string;\n path: string;\n query: Record<string, string>;\n device: { type: \"desktop\" | \"tablet\" | \"mobile\"; browser?: string; os?: string };\n firstVisit: boolean;\n eventsSeen: Set<string> | string[];\n completedGuides: Set<string> | string[];\n dismissedGuides: Set<string> | string[];\n seenGuides: Set<string> | string[];\n completedChecklists: Set<string> | string[];\n audienceIds: Set<string> | string[];\n now: Date;\n environment: string;\n locale?: string;\n /** Salt for rollout (guide id). Set per guide before evaluating. */\n rolloutSalt?: string;\n}\n\nfunction has(set: Set<string> | string[] | undefined, v: string): boolean {\n if (!set) return false;\n return set instanceof Set ? set.has(v) : set.includes(v);\n}\n\nfunction resolveField(rule: Rule, ctx: TargetingContext): unknown {\n switch (rule.field) {\n case \"user.attribute\":\n return rule.key ? getPath(ctx.userAttributes, rule.key) : undefined;\n case \"account.attribute\":\n return rule.key ? getPath(ctx.accountAttributes, rule.key) : undefined;\n case \"user.role\":\n return ctx.userAttributes.role;\n case \"user.plan\":\n return ctx.userAttributes.plan ?? ctx.accountAttributes.plan;\n case \"url.path\":\n return ctx.path;\n case \"url.full\":\n return ctx.url;\n case \"url.query\":\n return rule.key ? ctx.query[rule.key] : undefined;\n case \"device.type\":\n return ctx.device.type;\n case \"device.browser\":\n return ctx.device.browser;\n case \"device.os\":\n return ctx.device.os;\n case \"visitor.firstVisit\":\n return ctx.firstVisit;\n case \"visitor.returning\":\n return !ctx.firstVisit;\n case \"event.seen\":\n return rule.key ? has(ctx.eventsSeen, rule.key) : false;\n case \"guide.completed\":\n return rule.key ? has(ctx.completedGuides, rule.key) : false;\n case \"guide.dismissed\":\n return rule.key ? has(ctx.dismissedGuides, rule.key) : false;\n case \"guide.seen\":\n return rule.key ? has(ctx.seenGuides, rule.key) : false;\n case \"checklist.completed\":\n return rule.key ? has(ctx.completedChecklists, rule.key) : false;\n case \"audience.member\":\n return rule.key ? has(ctx.audienceIds, rule.key) : false;\n case \"datetime.now\":\n return ctx.now.toISOString();\n case \"datetime.dayOfWeek\":\n return ctx.now.getDay();\n case \"datetime.hour\":\n return ctx.now.getHours();\n case \"rollout.percentage\":\n return rolloutBucket(ctx.userId || ctx.anonymousId, ctx.rolloutSalt || \"guidely\");\n case \"environment\":\n return ctx.environment;\n case \"locale\":\n return ctx.locale;\n default:\n return undefined;\n }\n}\n\nfunction toNumber(v: unknown): number | null {\n if (typeof v === \"number\") return v;\n if (typeof v === \"string\" && v.trim() !== \"\" && !Number.isNaN(Number(v))) return Number(v);\n if (v instanceof Date) return v.getTime();\n return null;\n}\n\nfunction toDateMs(v: unknown): number | null {\n if (v instanceof Date) return v.getTime();\n if (typeof v === \"string\") {\n const t = Date.parse(v);\n return Number.isNaN(t) ? null : t;\n }\n if (typeof v === \"number\") return v;\n return null;\n}\n\nexport function compare(op: RuleOperator, actual: unknown, expected: Rule[\"value\"]): boolean {\n switch (op) {\n case \"exists\":\n return actual !== undefined && actual !== null && actual !== \"\";\n case \"not_exists\":\n return actual === undefined || actual === null || actual === \"\";\n case \"is_true\":\n return actual === true || actual === \"true\";\n case \"is_false\":\n return actual === false || actual === \"false\";\n case \"equals\":\n if (typeof actual === \"boolean\") return String(actual) === String(expected);\n return String(actual ?? \"\") === String(expected ?? \"\");\n case \"not_equals\":\n return String(actual ?? \"\") !== String(expected ?? \"\");\n case \"contains\":\n return typeof actual === \"string\" && actual.toLowerCase().includes(String(expected ?? \"\").toLowerCase());\n case \"not_contains\":\n return !(typeof actual === \"string\" && actual.toLowerCase().includes(String(expected ?? \"\").toLowerCase()));\n case \"starts_with\":\n return typeof actual === \"string\" && actual.startsWith(String(expected ?? \"\"));\n case \"ends_with\":\n return typeof actual === \"string\" && actual.endsWith(String(expected ?? \"\"));\n case \"gt\":\n case \"gte\":\n case \"lt\":\n case \"lte\": {\n const a = toNumber(actual);\n const b = toNumber(expected);\n if (a === null || b === null) return false;\n return op === \"gt\" ? a > b : op === \"gte\" ? a >= b : op === \"lt\" ? a < b : a <= b;\n }\n case \"in\": {\n const list = Array.isArray(expected) ? expected : String(expected ?? \"\").split(\",\").map((s) => s.trim());\n return list.includes(String(actual ?? \"\"));\n }\n case \"not_in\": {\n const list = Array.isArray(expected) ? expected : String(expected ?? \"\").split(\",\").map((s) => s.trim());\n return !list.includes(String(actual ?? \"\"));\n }\n case \"regex\": {\n const re = safeRegExp(String(expected ?? \"\"));\n return !!re && typeof actual === \"string\" && re.test(actual);\n }\n case \"before\": {\n const a = toDateMs(actual);\n const b = toDateMs(expected);\n return a !== null && b !== null && a < b;\n }\n case \"after\": {\n const a = toDateMs(actual);\n const b = toDateMs(expected);\n return a !== null && b !== null && a > b;\n }\n default:\n return false;\n }\n}\n\nexport function evaluateRule(rule: Rule, ctx: TargetingContext): boolean {\n let result: boolean;\n if (rule.field === \"url.path\" || rule.field === \"url.full\") {\n const actual = String(resolveField(rule, ctx) ?? \"\");\n if (rule.op === \"equals\") result = matchUrlPattern(String(rule.value ?? \"\"), actual);\n else if (rule.op === \"not_equals\") result = !matchUrlPattern(String(rule.value ?? \"\"), actual);\n else result = compare(rule.op, actual, rule.value);\n } else {\n result = compare(rule.op, resolveField(rule, ctx), rule.value);\n }\n return rule.negate ? !result : result;\n}\n\n/** Evaluate a rule tree. An empty group matches everyone. */\nexport function evaluateRules(group: RuleGroup | null | undefined, ctx: TargetingContext): boolean {\n if (!group || group.rules.length === 0) return group?.negate ? false : true;\n const results = group.rules.map((r) => (isRuleGroup(r) ? evaluateRules(r, ctx) : evaluateRule(r, ctx)));\n const value = group.op === \"and\" ? results.every(Boolean) : results.some(Boolean);\n return group.negate ? !value : value;\n}\n\n/** Fields whose evaluation requires server-held data. Used by docs/UI to annotate rules. */\nexport const SERVER_ASSISTED_FIELDS: RuleField[] = [\"audience.member\", \"guide.completed\", \"guide.dismissed\", \"guide.seen\", \"checklist.completed\"];\n\nexport function describeRule(rule: Rule): string {\n const subject = rule.key ? `${rule.field}[${rule.key}]` : rule.field;\n const v = Array.isArray(rule.value) ? rule.value.join(\", \") : rule.value === undefined ? \"\" : String(rule.value);\n return `${rule.negate ? \"NOT \" : \"\"}${subject} ${rule.op.replace(/_/g, \" \")}${v ? ` \"${v}\"` : \"\"}`;\n}\n","import { z } from \"zod\";\nimport { RuleGroupSchema, emptyRuleGroup, type RuleGroup } from \"./targeting\";\n\nexport const GUIDE_KINDS = [\"flow\", \"modal\", \"tooltip\", \"banner\", \"checklist\", \"survey\", \"announcement\"] as const;\nexport type GuideKind = (typeof GUIDE_KINDS)[number];\n\nexport const GUIDE_STATUSES = [\"draft\", \"published\", \"paused\", \"archived\"] as const;\nexport type GuideStatus = (typeof GUIDE_STATUSES)[number];\n\nexport const STEP_TYPES = [\"modal\", \"tooltip\", \"popover\", \"spotlight\", \"hotspot\", \"banner\", \"slideout\", \"checklist\", \"custom\", \"survey\"] as const;\nexport type StepType = (typeof STEP_TYPES)[number];\n\nexport const PLACEMENTS = [\"top\", \"top-start\", \"top-end\", \"right\", \"right-start\", \"right-end\", \"bottom\", \"bottom-start\", \"bottom-end\", \"left\", \"left-start\", \"left-end\", \"auto\"] as const;\nexport type Placement = (typeof PLACEMENTS)[number];\n\nexport const SELECTOR_KINDS = [\"css\", \"id\", \"data-attr\", \"aria\", \"text\", \"xpath\"] as const;\nexport const SelectorStrategySchema = z.object({\n kind: z.enum(SELECTOR_KINDS),\n value: z.string().min(1).max(1000),\n /** Optional human-readable label captured at pick time. */\n label: z.string().max(200).optional(),\n});\nexport type SelectorStrategy = z.infer<typeof SelectorStrategySchema>;\n\nexport const TargetSchema = z.object({\n /** Ordered strategies; the first one resolving to exactly one element wins. */\n selectors: z.array(SelectorStrategySchema).max(10),\n /** How long to wait for the element before applying fallback. */\n waitMs: z.number().int().min(0).max(60000).default(5000),\n /** What to do when the element never shows up. */\n fallback: z.enum([\"skip\", \"show_as_modal\", \"end_guide\", \"wait\"]).default(\"skip\"),\n /** Scroll the element into view before positioning. */\n scrollIntoView: z.boolean().default(true),\n /** Text snapshot captured at pick time; used for authoring warnings. */\n textSnapshot: z.string().max(200).optional(),\n});\nexport type StepTarget = z.infer<typeof TargetSchema>;\n\nexport const BUTTON_ACTIONS = [\"next\", \"back\", \"dismiss\", \"complete\", \"skip\", \"url\", \"start_guide\", \"event\", \"open_resource_center\", \"none\"] as const;\nexport const ButtonSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1).max(80),\n action: z.enum(BUTTON_ACTIONS),\n variant: z.enum([\"primary\", \"secondary\", \"ghost\", \"link\"]).default(\"primary\"),\n /** url for `url`, guide id for `start_guide`, event name for `event`, step id for `next` branch override */\n value: z.string().max(2000).optional(),\n newTab: z.boolean().optional(),\n});\nexport type StepButton = z.infer<typeof ButtonSchema>;\n\nexport const StepBranchSchema = z.object({\n id: z.string(),\n /** Rule group evaluated against targeting context when leaving the step. */\n when: RuleGroupSchema,\n /** Step id to jump to. */\n goTo: z.string(),\n});\n\nexport const ADVANCE_ON = [\"button\", \"element_click\", \"element_visible\", \"event\", \"delay\", \"any\"] as const;\n\nexport const StepSchema = z.object({\n id: z.string().min(1).max(64),\n type: z.enum(STEP_TYPES),\n title: z.string().max(200).default(\"\"),\n /** Sanitized HTML body (links, images, lists, formatting). */\n body: z.string().max(20000).default(\"\"),\n imageUrl: z.string().url().max(2000).optional().or(z.literal(\"\")),\n buttons: z.array(ButtonSchema).max(6).default([]),\n target: TargetSchema.optional(),\n placement: z.enum(PLACEMENTS).default(\"auto\"),\n /** Pixel offset between anchor and card. */\n offset: z.number().int().min(0).max(64).default(10),\n showOverlay: z.boolean().default(false),\n showProgress: z.boolean().default(true),\n showClose: z.boolean().default(true),\n dismissOnOutsideClick: z.boolean().default(false),\n /** Highlight padding for spotlight. */\n spotlightPadding: z.number().int().min(0).max(64).default(6),\n /** Banner/slideout position. */\n position: z.enum([\"top\", \"bottom\", \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\", \"center\"]).default(\"bottom-right\"),\n /** URL pattern this step belongs to (for multi-page flows). */\n url: z.string().max(500).optional(),\n /** Automatic advancement. */\n advanceOn: z.enum(ADVANCE_ON).default(\"button\"),\n advanceValue: z.string().max(500).optional(),\n advanceDelayMs: z.number().int().min(0).max(600000).optional(),\n branches: z.array(StepBranchSchema).max(10).default([]),\n width: z.number().int().min(200).max(900).optional(),\n /** Step-level targeting: skip step when rules do not match. */\n targeting: RuleGroupSchema.optional(),\n /** Hotspot pulse dot settings. */\n hotspot: z.object({ size: z.number().int().min(8).max(40).default(14), pulse: z.boolean().default(true), openOn: z.enum([\"click\", \"hover\"]).default(\"click\") }).optional(),\n /** Custom step: arbitrary sanitized HTML with no chrome. */\n customHtml: z.string().max(50000).optional(),\n});\nexport type GuideStep = z.infer<typeof StepSchema>;\nexport type GuideStepInput = z.input<typeof StepSchema>;\n\nexport const TRIGGER_TYPES = [\"page_load\", \"url_match\", \"event\", \"element_click\", \"element_visible\", \"manual\", \"delay\", \"after_guide\", \"segment_enter\"] as const;\nexport const TriggerSchema = z.object({\n type: z.enum(TRIGGER_TYPES).default(\"page_load\"),\n /** url pattern, event name, selector, guide id, audience id depending on type */\n value: z.string().max(1000).optional(),\n delayMs: z.number().int().min(0).max(600000).default(0),\n /** Also require URL to match this pattern (any trigger). */\n urlPattern: z.string().max(500).optional(),\n});\nexport type TriggerConfig = z.infer<typeof TriggerSchema>;\n\nexport const FrequencySchema = z.object({\n mode: z.enum([\"once\", \"once_per_session\", \"every_time\", \"interval\"]).default(\"once\"),\n intervalHours: z.number().int().min(1).max(8760).optional(),\n maxImpressions: z.number().int().min(1).max(1000).optional(),\n /** Hours to wait after dismissal before eligible again (when not `once`). */\n cooldownHours: z.number().int().min(0).max(8760).default(0),\n /** Lower number wins when multiple guides qualify. */\n priority: z.number().int().min(0).max(1000).default(100),\n /** Guide ids that must not be active at the same time. */\n mutuallyExclusiveWith: z.array(z.string()).max(50).default([]),\n /** Re-show if dismissed (otherwise dismissal counts as completion for frequency). */\n reshowAfterDismiss: z.boolean().default(false),\n});\nexport type FrequencyConfig = z.infer<typeof FrequencySchema>;\n\nexport const AppearanceSchema = z.object({\n theme: z.enum([\"light\", \"dark\", \"auto\"]).default(\"auto\"),\n primaryColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),\n backgroundColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),\n textColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),\n borderRadius: z.number().int().min(0).max(32).optional(),\n fontFamily: z.string().max(200).optional(),\n overlayOpacity: z.number().min(0).max(1).optional(),\n zIndex: z.number().int().min(1).max(2147483647).optional(),\n preset: z.string().max(50).optional(),\n animation: z.enum([\"fade\", \"slide\", \"none\"]).default(\"fade\"),\n});\nexport type Appearance = z.infer<typeof AppearanceSchema>;\n\nexport const ChecklistTaskSchema = z.object({\n id: z.string().min(1),\n title: z.string().min(1).max(200),\n description: z.string().max(2000).default(\"\"),\n /** How the task completes. */\n completion: z.enum([\"manual\", \"event\", \"guide_completed\", \"url_visited\", \"click\"]).default(\"manual\"),\n completionValue: z.string().max(500).optional(),\n /** Optional action when clicking the task. */\n action: z.enum([\"none\", \"start_guide\", \"url\", \"event\"]).default(\"none\"),\n actionValue: z.string().max(2000).optional(),\n required: z.boolean().default(true),\n});\nexport type ChecklistTask = z.infer<typeof ChecklistTaskSchema>;\n\nexport const ChecklistConfigSchema = z.object({\n tasks: z.array(ChecklistTaskSchema).min(1).max(30),\n ordered: z.boolean().default(false),\n launcherLabel: z.string().max(60).default(\"Getting started\"),\n position: z.enum([\"bottom-right\", \"bottom-left\"]).default(\"bottom-right\"),\n completionTitle: z.string().max(200).default(\"You're all set!\"),\n completionBody: z.string().max(2000).default(\"\"),\n autoOpen: z.boolean().default(true),\n dismissible: z.boolean().default(true),\n});\nexport type ChecklistConfig = z.infer<typeof ChecklistConfigSchema>;\n\nexport const SURVEY_QUESTION_TYPES = [\"nps\", \"csat\", \"thumbs\", \"single_choice\", \"multiple_choice\", \"text\", \"rating\"] as const;\nexport const SurveyQuestionSchema = z.object({\n id: z.string().min(1),\n type: z.enum(SURVEY_QUESTION_TYPES),\n title: z.string().min(1).max(500),\n description: z.string().max(1000).default(\"\"),\n required: z.boolean().default(true),\n options: z.array(z.object({ id: z.string(), label: z.string().max(200) })).max(20).default([]),\n scaleMax: z.number().int().min(2).max(10).optional(),\n lowLabel: z.string().max(60).optional(),\n highLabel: z.string().max(60).optional(),\n placeholder: z.string().max(200).optional(),\n /** Conditional follow-up: show only when a previous answer matches. */\n showWhen: z.object({ questionId: z.string(), op: z.enum([\"equals\", \"lte\", \"gte\", \"in\"]), value: z.union([z.string(), z.number(), z.array(z.string())]) }).optional(),\n});\nexport type SurveyQuestion = z.infer<typeof SurveyQuestionSchema>;\n\nexport const SurveyConfigSchema = z.object({\n questions: z.array(SurveyQuestionSchema).min(1).max(20),\n thankYouTitle: z.string().max(200).default(\"Thanks for your feedback!\"),\n thankYouBody: z.string().max(2000).default(\"\"),\n position: z.enum([\"bottom-right\", \"bottom-left\", \"center\"]).default(\"bottom-right\"),\n startAt: z.string().datetime().optional(),\n endAt: z.string().datetime().optional(),\n});\nexport type SurveyConfig = z.infer<typeof SurveyConfigSchema>;\n\nexport const GuideConfigSchema = z.object({\n steps: z.array(StepSchema).max(50).default([]),\n targeting: RuleGroupSchema.default(() => emptyRuleGroup()),\n trigger: TriggerSchema.default({}),\n frequency: FrequencySchema.default({}),\n appearance: AppearanceSchema.default({}),\n checklist: ChecklistConfigSchema.optional(),\n survey: SurveyConfigSchema.optional(),\n /** Restrict guide to url pattern(s) (applied before trigger). */\n urlPatterns: z.array(z.string().max(500)).max(20).default([]),\n});\nexport type GuideConfig = z.infer<typeof GuideConfigSchema>;\nexport type GuideConfigInput = z.input<typeof GuideConfigSchema>;\n\nexport function defaultGuideConfig(kind: GuideKind): GuideConfig {\n return GuideConfigSchema.parse({\n steps: kind === \"checklist\" || kind === \"survey\" ? [] : [defaultStep(kind === \"flow\" ? \"tooltip\" : kind === \"banner\" ? \"banner\" : kind === \"tooltip\" ? \"tooltip\" : \"modal\")],\n checklist: kind === \"checklist\" ? { tasks: [{ id: \"task-1\", title: \"Complete your profile\" }] } : undefined,\n survey: kind === \"survey\" ? { questions: [{ id: \"q1\", type: \"nps\", title: \"How likely are you to recommend us to a friend?\" }] } : undefined,\n trigger: kind === \"checklist\" ? { type: \"page_load\" } : {},\n });\n}\n\nlet stepCounter = 0;\nexport function defaultStep(type: StepType, overrides: Partial<GuideStepInput> = {}): GuideStep {\n stepCounter += 1;\n const base: GuideStepInput = {\n id: `step-${Date.now().toString(36)}-${stepCounter}`,\n type,\n title: type === \"modal\" ? \"Welcome!\" : \"Step title\",\n body: \"<p>Describe what the user should do here.</p>\",\n buttons: [\n { id: \"btn-back\", label: \"Back\", action: \"back\", variant: \"ghost\" },\n { id: \"btn-next\", label: \"Next\", action: \"next\", variant: \"primary\" },\n ],\n placement: type === \"banner\" ? \"top\" : \"auto\",\n showOverlay: type === \"modal\" || type === \"spotlight\",\n ...overrides,\n };\n if ([\"tooltip\", \"popover\", \"spotlight\", \"hotspot\"].includes(type) && !base.target) {\n base.target = { selectors: [], waitMs: 5000, fallback: \"skip\", scrollIntoView: true };\n }\n return StepSchema.parse(base);\n}\n\n/** Buttons to show for a step; \"back\" buttons are hidden when there is no previous step to return to. */\nexport function visibleButtons(step: GuideStep, canGoBack: boolean): GuideStep[\"buttons\"] {\n return canGoBack ? step.buttons : step.buttons.filter((b) => b.action !== \"back\");\n}\n\n/** Validation beyond Zod shape: returns human-readable problems that block publishing. */\nexport interface ValidationIssue {\n level: \"error\" | \"warning\";\n stepId?: string;\n message: string;\n}\nexport function validateGuideConfig(kind: GuideKind, config: GuideConfig): ValidationIssue[] {\n const issues: ValidationIssue[] = [];\n if (kind === \"checklist\") {\n if (!config.checklist || config.checklist.tasks.length === 0) issues.push({ level: \"error\", message: \"Checklist needs at least one task.\" });\n } else if (kind === \"survey\") {\n if (!config.survey || config.survey.questions.length === 0) issues.push({ level: \"error\", message: \"Survey needs at least one question.\" });\n config.survey?.questions.forEach((q) => {\n if ((q.type === \"single_choice\" || q.type === \"multiple_choice\") && q.options.length < 2) issues.push({ level: \"error\", message: `Question \"${q.title}\" needs at least two options.` });\n });\n } else {\n if (config.steps.length === 0) issues.push({ level: \"error\", message: \"Add at least one step.\" });\n }\n const ids = new Set<string>();\n config.steps.forEach((step, i) => {\n if (ids.has(step.id)) issues.push({ level: \"error\", stepId: step.id, message: `Duplicate step id \"${step.id}\".` });\n ids.add(step.id);\n const anchored = [\"tooltip\", \"popover\", \"spotlight\", \"hotspot\"].includes(step.type);\n if (anchored && (!step.target || step.target.selectors.length === 0)) issues.push({ level: \"error\", stepId: step.id, message: `Step ${i + 1} (${step.type}) needs a target element.` });\n if (!step.title && !step.body && step.type !== \"custom\") issues.push({ level: \"warning\", stepId: step.id, message: `Step ${i + 1} has no title or body.` });\n if (step.buttons.length === 0 && step.advanceOn === \"button\" && step.type !== \"hotspot\" && step.type !== \"custom\") issues.push({ level: \"warning\", stepId: step.id, message: `Step ${i + 1} has no buttons and advances on button; users can only close it.` });\n step.buttons.forEach((b) => {\n if (b.action === \"url\" && !/^https?:\\/\\//i.test(b.value || \"\") && !(b.value || \"\").startsWith(\"/\")) issues.push({ level: \"error\", stepId: step.id, message: `Button \"${b.label}\" needs an http(s) or relative URL.` });\n if (b.action === \"start_guide\" && !b.value) issues.push({ level: \"error\", stepId: step.id, message: `Button \"${b.label}\" needs a guide to start.` });\n });\n step.branches.forEach((br) => {\n if (!ids.has(br.goTo) && !config.steps.some((s) => s.id === br.goTo)) issues.push({ level: \"error\", stepId: step.id, message: `Branch points to unknown step \"${br.goTo}\".` });\n });\n });\n if (config.trigger.type === \"event\" && !config.trigger.value) issues.push({ level: \"error\", message: \"Event trigger needs an event name.\" });\n if (config.trigger.type === \"element_click\" && !config.trigger.value) issues.push({ level: \"error\", message: \"Element click trigger needs a selector.\" });\n if (config.trigger.type === \"url_match\" && !config.trigger.value) issues.push({ level: \"error\", message: \"URL trigger needs a pattern.\" });\n if (config.frequency.mode === \"interval\" && !config.frequency.intervalHours) issues.push({ level: \"error\", message: \"Interval frequency needs an interval in hours.\" });\n return issues;\n}\n\nexport interface ProjectTheme {\n primaryColor: string;\n backgroundColor: string;\n textColor: string;\n borderRadius: number;\n fontFamily: string;\n logoUrl?: string;\n brandName?: string;\n}\nexport const ProjectThemeSchema = z.object({\n primaryColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).default(\"#4f46e5\"),\n backgroundColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).default(\"#ffffff\"),\n textColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).default(\"#111827\"),\n borderRadius: z.number().int().min(0).max(32).default(12),\n fontFamily: z.string().max(200).default(\"Inter, system-ui, -apple-system, sans-serif\"),\n logoUrl: z.string().max(2000).optional(),\n brandName: z.string().max(100).optional(),\n});\n\nexport type { RuleGroup };\n","import { z } from \"zod\";\n\nexport const EVENT_NAMES = [\n \"guide_viewed\",\n \"guide_started\",\n \"step_viewed\",\n \"step_completed\",\n \"guide_completed\",\n \"guide_skipped\",\n \"guide_dismissed\",\n \"guide_abandoned\",\n \"checklist_task_completed\",\n \"checklist_completed\",\n \"checklist_dismissed\",\n \"survey_displayed\",\n \"survey_submitted\",\n \"survey_dismissed\",\n \"resource_center_opened\",\n \"article_viewed\",\n \"messenger_opened\",\n \"conversation_started\",\n \"conversation_handed_off\",\n \"scout_answered\",\n \"custom\",\n \"page_view\",\n \"identify\",\n] as const;\nexport type EventName = (typeof EVENT_NAMES)[number];\n\nexport const GUIDE_LIFECYCLE_EVENTS = [\"guide_viewed\", \"guide_started\", \"step_viewed\", \"step_completed\", \"guide_completed\", \"guide_skipped\", \"guide_dismissed\", \"guide_abandoned\"] as const;\n\n/** Event as produced by the SDK and accepted by POST /api/v1/sdk/events */\nexport const SdkEventSchema = z.object({\n eventId: z.string().min(8).max(64),\n name: z.enum(EVENT_NAMES),\n /** For `custom` events: the application-defined name. */\n customName: z.string().min(1).max(120).optional(),\n occurredAt: z.string().datetime({ offset: true }),\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n accountId: z.string().max(256).optional().nullable(),\n sessionId: z.string().max(128).optional(),\n guideId: z.string().max(64).optional(),\n guideVersion: z.number().int().optional(),\n stepId: z.string().max(64).optional(),\n stepIndex: z.number().int().min(0).optional(),\n url: z.string().max(2000).optional(),\n properties: z.record(z.unknown()).optional(),\n});\nexport type SdkEvent = z.infer<typeof SdkEventSchema>;\n\nexport const EventBatchSchema = z.object({\n events: z.array(SdkEventSchema).min(1).max(50),\n sentAt: z.string().datetime({ offset: true }).optional(),\n sdk: z.object({ name: z.string().max(60), version: z.string().max(30) }).optional(),\n});\nexport type EventBatch = z.infer<typeof EventBatchSchema>;\n\nexport * from \"./events-util\";\n","/** Reserved property names that are stripped from `properties` to avoid collecting sensitive data. */\nexport const SENSITIVE_PROPERTY_PATTERN = /(password|passwd|secret|token|credit|card|cvv|ssn|iban)/i;\n\nexport const MAX_PROPERTY_BYTES = 8 * 1024;\n\nexport function sanitizeProperties(props: Record<string, unknown> | undefined): Record<string, unknown> {\n if (!props) return {};\n const out: Record<string, unknown> = {};\n let size = 0;\n for (const [k, v] of Object.entries(props)) {\n if (SENSITIVE_PROPERTY_PATTERN.test(k)) continue;\n if (typeof v === \"function\" || typeof v === \"symbol\") continue;\n const str = typeof v === \"string\" ? v : JSON.stringify(v ?? null);\n size += k.length + (str?.length ?? 0);\n if (size > MAX_PROPERTY_BYTES) break;\n out[k.slice(0, 100)] = typeof v === \"string\" ? v.slice(0, 1000) : v;\n }\n return out;\n}\n","import { z } from \"zod\";\nimport { GuideConfigSchema, ProjectThemeSchema, type GuideKind, type GuideConfig } from \"./guide\";\nimport type { MessengerConfig } from \"./messenger\";\n\n/** A published guide as delivered to the SDK. Draft-only data (author, notes) is never included. */\nexport interface PublishedGuide {\n id: string;\n key: string;\n name: string;\n kind: GuideKind;\n version: number;\n config: GuideConfig;\n publishedAt: string;\n}\n\nexport interface ResourceCenterArticle {\n id: string;\n slug: string;\n title: string;\n summary: string;\n body: string;\n /** True when `body` was left out of the config to keep it small; fetch it from `GET /sdk/articles/:id`. */\n bodyOmitted?: boolean;\n collectionId?: string | null;\n externalUrl?: string | null;\n updatedAt: string;\n}\n\nexport interface ResourceCenterConfig {\n enabled: boolean;\n title: string;\n launcher: { position: \"bottom-right\" | \"bottom-left\"; label: string; showIcon: boolean };\n collections: Array<{ id: string; name: string; description: string; order: number }>;\n articles: ResourceCenterArticle[];\n recommendedGuideIds: string[];\n checklistGuideIds: string[];\n links: Array<{ id: string; label: string; url: string }>;\n faqs: Array<{ id: string; question: string; answer: string }>;\n}\n\nexport interface SdkConfigResponse {\n projectId: string;\n environment: string;\n configVersion: number;\n theme: z.infer<typeof ProjectThemeSchema>;\n guides: PublishedGuide[];\n resourceCenter: ResourceCenterConfig | null;\n /** Scout messenger; absent from servers that predate it. */\n messenger?: MessengerConfig | null;\n settings: {\n analyticsEnabled: boolean;\n collectUrls: boolean;\n maskSelectors: string[];\n sessionTimeoutMinutes: number;\n };\n generatedAt: string;\n}\n\nexport const IdentifyRequestSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().min(1).max(256).optional().nullable(),\n traits: z.record(z.unknown()).optional(),\n account: z\n .object({ id: z.string().min(1).max(256), traits: z.record(z.unknown()).optional() })\n .optional()\n .nullable(),\n sessionId: z.string().max(128).optional(),\n url: z.string().max(2000).optional(),\n});\nexport type IdentifyRequest = z.infer<typeof IdentifyRequestSchema>;\n\n/** Server-held state the SDK needs for targeting & frequency. */\nexport interface IdentifyResponse {\n endUserId: string;\n audienceIds: string[];\n guideState: Record<\n string,\n { impressions: number; completedAt?: string | null; dismissedAt?: string | null; lastShownAt?: string | null }\n >;\n checklistProgress: Record<string, { completedTaskIds: string[]; completedAt?: string | null; dismissedAt?: string | null }>;\n surveysSubmitted: string[];\n firstSeenAt: string;\n}\n\nexport const ChecklistProgressRequestSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n guideVersion: z.number().int().optional(),\n completedTaskIds: z.array(z.string().max(64)).max(100),\n dismissed: z.boolean().optional(),\n completed: z.boolean().optional(),\n});\nexport type ChecklistProgressRequest = z.infer<typeof ChecklistProgressRequestSchema>;\n\nexport const SurveyResponseRequestSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n accountId: z.string().max(256).optional().nullable(),\n guideVersion: z.number().int(),\n answers: z.record(z.union([z.string().max(5000), z.number(), z.boolean(), z.array(z.string().max(500)).max(50)])),\n responseId: z.string().min(8).max(64),\n});\nexport type SurveyResponseRequest = z.infer<typeof SurveyResponseRequestSchema>;\n\nexport const GuideStateUpdateSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n updates: z\n .array(\n z.object({\n guideId: z.string(),\n impression: z.boolean().optional(),\n completed: z.boolean().optional(),\n dismissed: z.boolean().optional(),\n }),\n )\n .max(50),\n});\n\nexport const AuthoringPickSchema = z.object({\n stepId: z.string().max(64).optional(),\n selectors: z.array(z.object({ kind: z.string(), value: z.string().max(1000), label: z.string().max(200).optional() })).max(10),\n textSnapshot: z.string().max(200).optional(),\n url: z.string().max(2000).optional(),\n rect: z.object({ x: z.number(), y: z.number(), width: z.number(), height: z.number() }).optional(),\n});\nexport type AuthoringPick = z.infer<typeof AuthoringPickSchema>;\n\n/**\n * Static, script-free copy of the page an authoring session is connected to. The SDK posts it to\n * the dashboard (never to the API) so the editor canvas can show the customer's real app.\n */\nexport interface AppSnapshot {\n /** Full HTML document (doctype included) with scripts and Guidely UI removed and a `<base>` pointing at `url`. */\n html: string;\n url: string;\n title: string;\n /** Viewport the snapshot was taken at, in CSS pixels. */\n width: number;\n height: number;\n capturedAt: string;\n}\n\nexport interface AuthoringSessionInfo {\n id: string;\n projectId: string;\n environment: string;\n guideId: string | null;\n dashboardOrigin: string;\n expiresAt: string;\n /** Draft guide config to preview while authoring (not published). */\n draft: { id: string; key: string; name: string; kind: GuideKind; config: GuideConfig } | null;\n}\n\nexport const PublishedGuideSchema = z.object({\n id: z.string(),\n key: z.string(),\n name: z.string(),\n kind: z.string(),\n version: z.number(),\n config: GuideConfigSchema,\n publishedAt: z.string(),\n});\n\nexport interface ApiError {\n error: { code: string; message: string; details?: unknown };\n}\n","import { z } from \"zod\";\n\n/** Messenger settings delivered to the SDK in `SdkConfigResponse.messenger`. */\nexport interface MessengerConfig {\n enabled: boolean;\n /** Display name of the AI agent (\"Scout\"). */\n name: string;\n greeting: string;\n /** Scout answers with AI; when false every conversation goes to the team inbox. */\n aiAvailable: boolean;\n handoffEnabled: boolean;\n launcher: { position: \"bottom-right\" | \"bottom-left\" };\n}\n\nexport const MESSAGE_AUTHORS = [\"user\", \"scout\", \"agent\", \"system\"] as const;\nexport type MessageAuthor = (typeof MESSAGE_AUTHORS)[number];\nexport type ConversationStatus = \"bot\" | \"open\" | \"closed\";\n\nexport interface MessengerCitation {\n articleId: string;\n title: string;\n}\n\nexport interface MessengerSuggestedGuide {\n key: string;\n name: string;\n}\n\nexport interface MessengerMessage {\n id: string;\n author: MessageAuthor;\n /** Team member name for `agent` messages. */\n authorName?: string | null;\n body: string;\n citations: MessengerCitation[];\n suggestedGuides: MessengerSuggestedGuide[];\n status: \"pending\" | \"complete\" | \"failed\";\n createdAt: string;\n}\n\nexport interface MessengerConversation {\n id: string;\n status: ConversationStatus;\n subject: string;\n lastMessageAt: string;\n lastMessagePreview: string;\n unread: number;\n rating: number | null;\n}\n\nexport const MAX_MESSAGE_LENGTH = 4000;\nconst messageText = z.string().trim().min(1).max(MAX_MESSAGE_LENGTH);\n\nexport const StartConversationSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n message: messageText,\n pageUrl: z.string().max(2000).optional(),\n});\nexport type StartConversationRequest = z.infer<typeof StartConversationSchema>;\n\nexport interface StartConversationResponse {\n conversation: MessengerConversation;\n /** Secret that authorises this browser to read and post in the conversation. Store it; it is not shown again. */\n token: string;\n messages: MessengerMessage[];\n}\n\nexport const ConversationLookupSchema = z.object({\n tokens: z.array(z.string().min(16).max(128)).max(50),\n});\n\nexport interface ConversationLookupResponse {\n conversations: Array<MessengerConversation & { token: string }>;\n}\n\nexport const PostMessageSchema = z.object({ message: messageText });\n\nexport const ConversationRatingSchema = z.object({\n rating: z.number().int().min(1).max(5),\n comment: z.string().max(1000).optional(),\n});\n\nexport interface ConversationMessagesResponse {\n conversation: MessengerConversation;\n messages: MessengerMessage[];\n}\n\n/**\n * Server-sent events streamed by `POST /sdk/conversations` and `POST /sdk/conversations/:id/messages`\n * while Scout replies. `conversation` (start only) carries the new conversation and its token, `message`\n * each stored message, `delta` reply text as it is generated, and `done` the final stored message.\n */\nexport type ScoutStreamEvent =\n | { event: \"conversation\"; data: StartConversationResponse }\n | { event: \"message\"; data: MessengerMessage }\n | { event: \"delta\"; data: { messageId: string; text: string } }\n | { event: \"done\"; data: { message: MessengerMessage; conversation: MessengerConversation } }\n | { event: \"error\"; data: { message: string } };\n\n/** Article list entry for the messenger Help tab (bodies are fetched on demand). */\nexport interface SdkArticleSummary {\n id: string;\n slug: string;\n title: string;\n summary: string;\n collectionId: string | null;\n externalUrl: string | null;\n updatedAt: string;\n}\n\nexport interface SdkArticlesResponse {\n collections: Array<{ id: string; name: string; description: string; order: number }>;\n articles: SdkArticleSummary[];\n}\n","import { GuideConfigSchema, type GuideConfigInput, type GuideKind } from \"./guide\";\n\nexport interface GuideTemplate {\n id: string;\n name: string;\n description: string;\n kind: GuideKind;\n category: \"onboarding\" | \"feature\" | \"setup\" | \"forms\" | \"announcement\" | \"help\" | \"feedback\";\n config: GuideConfigInput;\n}\n\nconst nav = (opts: { last?: boolean; first?: boolean } = {}) =>\n [\n ...(opts.first ? [] : [{ id: \"back\", label: \"Back\", action: \"back\" as const, variant: \"ghost\" as const }]),\n opts.last\n ? { id: \"done\", label: \"Finish\", action: \"complete\" as const, variant: \"primary\" as const }\n : { id: \"next\", label: \"Next\", action: \"next\" as const, variant: \"primary\" as const },\n ];\n\nexport const GUIDE_TEMPLATES: GuideTemplate[] = [\n {\n id: \"new-user-onboarding\",\n name: \"New-user onboarding tour\",\n description: \"A welcome modal followed by three anchored steps that introduce the main navigation.\",\n kind: \"flow\",\n category: \"onboarding\",\n config: {\n steps: [\n { id: \"welcome\", type: \"modal\", title: \"Welcome aboard 👋\", body: \"<p>We'll show you around in under a minute. You can skip at any time.</p>\", showOverlay: true, buttons: [{ id: \"skip\", label: \"Skip tour\", action: \"dismiss\", variant: \"ghost\" }, { id: \"start\", label: \"Show me around\", action: \"next\" }] },\n { id: \"nav\", type: \"tooltip\", title: \"Your navigation\", body: \"<p>Everything lives in the sidebar. Switch between dashboards, contacts and settings here.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='sidebar']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"right\", buttons: nav() },\n { id: \"create\", type: \"spotlight\", title: \"Create your first record\", body: \"<p>Use the primary button to add something new. We'll highlight it for you.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='primary-action']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", showOverlay: true, buttons: nav() },\n { id: \"help\", type: \"tooltip\", title: \"Need help later?\", body: \"<p>Open the help menu any time to replay this tour or browse the resource center.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='help']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", buttons: nav({ last: true }) },\n ],\n trigger: { type: \"page_load\" },\n frequency: { mode: \"once\", priority: 10 },\n targeting: { id: \"root\", op: \"and\", rules: [{ id: \"r1\", field: \"visitor.firstVisit\", op: \"is_true\" }] },\n },\n },\n {\n id: \"feature-discovery\",\n name: \"First-time feature discovery\",\n description: \"A hotspot that draws attention to a new capability and expands into a tooltip.\",\n kind: \"tooltip\",\n category: \"feature\",\n config: {\n steps: [{ id: \"hotspot\", type: \"hotspot\", title: \"New: smart filters\", body: \"<p>Filters now understand natural language. Try <em>“deals closing this month”</em>.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='filters']\" }], waitMs: 8000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", buttons: [{ id: \"got-it\", label: \"Got it\", action: \"complete\" }], hotspot: { size: 14, pulse: true, openOn: \"click\" }, showProgress: false }],\n trigger: { type: \"element_visible\", value: \"[data-tour='filters']\" },\n frequency: { mode: \"once\", maxImpressions: 3, priority: 50 },\n },\n },\n {\n id: \"setup-wizard\",\n name: \"Setup wizard\",\n description: \"Multi-step modal wizard that walks a new admin through initial configuration with branching.\",\n kind: \"flow\",\n category: \"setup\",\n config: {\n steps: [\n { id: \"intro\", type: \"modal\", title: \"Let's set up your workspace\", body: \"<p>Three quick steps: invite your team, connect a data source, and choose a plan.</p>\", showOverlay: true, buttons: [{ id: \"later\", label: \"Later\", action: \"dismiss\", variant: \"ghost\" }, { id: \"go\", label: \"Start setup\", action: \"next\" }] },\n { id: \"team\", type: \"popover\", title: \"Invite teammates\", body: \"<p>Guidely works best with your whole team. Add a few emails here.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='invite']\" }], waitMs: 5000, fallback: \"show_as_modal\", scrollIntoView: true }, buttons: nav() },\n { id: \"data\", type: \"popover\", title: \"Connect a data source\", body: \"<p>Import contacts from a CSV or connect your CRM.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='import']\" }], waitMs: 5000, fallback: \"show_as_modal\", scrollIntoView: true }, buttons: nav() },\n { id: \"done\", type: \"modal\", title: \"You're ready 🎉\", body: \"<p>That's it. Explore the dashboard, and open the help menu if you get stuck.</p>\", showOverlay: true, buttons: nav({ last: true }) },\n ],\n trigger: { type: \"page_load\", urlPattern: \"/dashboard\" },\n frequency: { mode: \"once\", priority: 20 },\n targeting: { id: \"root\", op: \"and\", rules: [{ id: \"r1\", field: \"user.role\", op: \"equals\", value: \"admin\" }] },\n },\n },\n {\n id: \"form-completion\",\n name: \"Form completion helper\",\n description: \"Tooltips that advance as the user fills out each field of a form.\",\n kind: \"flow\",\n category: \"forms\",\n config: {\n steps: [\n { id: \"name\", type: \"tooltip\", title: \"Name the contact\", body: \"<p>Use their full name so search works well.</p>\", target: { selectors: [{ kind: \"css\", value: \"input[name='name']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"right\", advanceOn: \"element_click\", advanceValue: \"input[name='email']\", buttons: [] },\n { id: \"email\", type: \"tooltip\", title: \"Add an email\", body: \"<p>We'll use it for sequences and reminders.</p>\", target: { selectors: [{ kind: \"css\", value: \"input[name='email']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"right\", buttons: nav() },\n { id: \"save\", type: \"spotlight\", title: \"Save\", body: \"<p>Hit save, and your contact appears in the list.</p>\", target: { selectors: [{ kind: \"css\", value: \"button[type='submit']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"top\", showOverlay: true, buttons: nav({ last: true }) },\n ],\n trigger: { type: \"url_match\", value: \"/contacts/new\" },\n frequency: { mode: \"once\", priority: 40 },\n },\n },\n {\n id: \"workflow-walkthrough\",\n name: \"Complex workflow walkthrough\",\n description: \"A multi-page flow that follows the user across routes with URL-aware steps.\",\n kind: \"flow\",\n category: \"onboarding\",\n config: {\n steps: [\n { id: \"start\", type: \"modal\", title: \"Close your first deal\", body: \"<p>We'll go from pipeline to closed-won in four steps.</p>\", showOverlay: true, buttons: [{ id: \"skip\", label: \"Not now\", action: \"dismiss\", variant: \"ghost\" }, { id: \"next\", label: \"Let's go\", action: \"next\" }] },\n { id: \"pipeline\", type: \"tooltip\", title: \"Open the pipeline\", body: \"<p>Click here to see your deals by stage.</p>\", url: \"/dashboard\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='nav-deals']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"right\", advanceOn: \"element_click\", advanceValue: \"[data-tour='nav-deals']\", buttons: [] },\n { id: \"drag\", type: \"spotlight\", title: \"Move a deal\", body: \"<p>Drag a card to the next stage, or use the stage menu.</p>\", url: \"/deals\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='deal-card']\" }], waitMs: 8000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", showOverlay: true, buttons: nav() },\n { id: \"won\", type: \"tooltip\", title: \"Mark as won\", body: \"<p>When it closes, mark it won to update your forecast.</p>\", url: \"/deals\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='mark-won']\" }], waitMs: 8000, fallback: \"skip\", scrollIntoView: true }, placement: \"left\", buttons: nav({ last: true }) },\n ],\n trigger: { type: \"manual\" },\n frequency: { mode: \"every_time\", priority: 30 },\n },\n },\n {\n id: \"feature-announcement\",\n name: \"New feature announcement\",\n description: \"A centered modal with an image announcing a new capability.\",\n kind: \"announcement\",\n category: \"announcement\",\n config: {\n steps: [{ id: \"announce\", type: \"modal\", title: \"Introducing Reports 2.0\", body: \"<p>Build custom reports with drag-and-drop metrics, scheduled emails and shareable links.</p><ul><li>12 new chart types</li><li>Export to CSV and PDF</li></ul>\", imageUrl: \"https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=800&q=60\", showOverlay: true, buttons: [{ id: \"later\", label: \"Maybe later\", action: \"dismiss\", variant: \"ghost\" }, { id: \"try\", label: \"Try it now\", action: \"url\", value: \"/reports\" }], showProgress: false }],\n trigger: { type: \"page_load\", delayMs: 1500 },\n frequency: { mode: \"once\", priority: 60 },\n },\n },\n {\n id: \"contextual-tooltip\",\n name: \"Contextual tooltip\",\n description: \"A single tooltip that appears when a specific element becomes visible.\",\n kind: \"tooltip\",\n category: \"help\",\n config: {\n steps: [{ id: \"tip\", type: \"tooltip\", title: \"Pro tip\", body: \"<p>Press <strong>⌘K</strong> to jump anywhere.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='search']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", buttons: [{ id: \"ok\", label: \"Got it\", action: \"complete\" }], showProgress: false }],\n trigger: { type: \"element_visible\", value: \"[data-tour='search']\", delayMs: 500 },\n frequency: { mode: \"once\", priority: 80 },\n },\n },\n {\n id: \"product-update-banner\",\n name: \"Product update notification\",\n description: \"A dismissible top banner linking to release notes.\",\n kind: \"banner\",\n category: \"announcement\",\n config: {\n steps: [{ id: \"banner\", type: \"banner\", title: \"\", body: \"<p><strong>Scheduled maintenance</strong> on Saturday 02:00–03:00 UTC. <a href='/status'>Read more</a>.</p>\", position: \"top\", placement: \"top\", buttons: [{ id: \"dismiss\", label: \"Dismiss\", action: \"dismiss\", variant: \"ghost\" }], showProgress: false }],\n trigger: { type: \"page_load\" },\n frequency: { mode: \"once_per_session\", priority: 90 },\n },\n },\n {\n id: \"onboarding-checklist\",\n name: \"User onboarding checklist\",\n description: \"A persistent checklist with four tasks that complete automatically from events.\",\n kind: \"checklist\",\n category: \"onboarding\",\n config: {\n steps: [],\n checklist: {\n tasks: [\n { id: \"profile\", title: \"Complete your profile\", description: \"Add a photo and your role.\", completion: \"event\", completionValue: \"profile_completed\", action: \"url\", actionValue: \"/settings/profile\" },\n { id: \"contact\", title: \"Add your first contact\", description: \"Import or create a contact.\", completion: \"event\", completionValue: \"contact_created\", action: \"url\", actionValue: \"/contacts/new\" },\n { id: \"deal\", title: \"Create a deal\", description: \"Track your first opportunity.\", completion: \"event\", completionValue: \"deal_created\", action: \"url\", actionValue: \"/deals\" },\n { id: \"tour\", title: \"Take the product tour\", description: \"A 60-second walkthrough.\", completion: \"guide_completed\", completionValue: \"new-user-onboarding\", action: \"start_guide\", actionValue: \"new-user-onboarding\", required: false },\n ],\n ordered: false,\n launcherLabel: \"Getting started\",\n position: \"bottom-right\",\n completionTitle: \"You're all set! 🎉\",\n completionBody: \"You've completed onboarding. Explore the rest of the app at your own pace.\",\n autoOpen: true,\n dismissible: true,\n },\n trigger: { type: \"page_load\" },\n frequency: { mode: \"every_time\", priority: 200 },\n },\n },\n {\n id: \"nps-survey\",\n name: \"NPS survey\",\n description: \"Net Promoter Score with a conditional follow-up question.\",\n kind: \"survey\",\n category: \"feedback\",\n config: {\n steps: [],\n survey: {\n questions: [\n { id: \"nps\", type: \"nps\", title: \"How likely are you to recommend us to a colleague?\", lowLabel: \"Not likely\", highLabel: \"Very likely\" },\n { id: \"why-low\", type: \"text\", title: \"What could we do better?\", required: false, placeholder: \"Tell us more…\", showWhen: { questionId: \"nps\", op: \"lte\", value: 6 } },\n { id: \"why-high\", type: \"text\", title: \"What do you like most?\", required: false, placeholder: \"Tell us more…\", showWhen: { questionId: \"nps\", op: \"gte\", value: 9 } },\n ],\n position: \"bottom-right\",\n },\n trigger: { type: \"page_load\", delayMs: 5000 },\n frequency: { mode: \"interval\", intervalHours: 2160, priority: 150 },\n targeting: { id: \"root\", op: \"and\", rules: [{ id: \"r1\", field: \"visitor.returning\", op: \"is_true\" }] },\n },\n },\n];\n\nexport function templateConfig(id: string) {\n const t = GUIDE_TEMPLATES.find((x) => x.id === id);\n if (!t) return null;\n return { template: t, config: GuideConfigSchema.parse(t.config) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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C,EAAG,QAAO;AACf,SAAO,EAAE,UAAU,GAAG,QAAQ,kBAAkB,MAAM,EAAE,MAAM,EAAE;AAClE;;;ATxLO,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;","names":["import_zod","import_zod","import_zod","import_zod"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/platform.ts","../src/widgets.ts","../src/targeting.ts","../src/targeting-eval.ts","../src/guide.ts","../src/events.ts","../src/events-util.ts","../src/errors.ts","../src/sdk-api.ts","../src/messenger.ts","../src/capture.ts","../src/network.ts","../src/templates.ts"],"sourcesContent":["export * from \"./utils\";\nexport * from \"./platform\";\nexport * from \"./widgets\";\nexport * from \"./targeting\";\nexport * from \"./guide\";\nexport * from \"./events\";\nexport * from \"./sdk-api\";\nexport * from \"./messenger\";\nexport * from \"./capture\";\nexport * from \"./network\";\nexport * from \"./templates\";\nexport const SDK_API_VERSION = \"v1\";\nexport const SHARED_VERSION = \"0.4.1\";\n","/** FNV-1a 32-bit hash; deterministic across SDK and server for rollout bucketing. */\nexport function fnv1a(input: string): number {\n let h = 0x811c9dc5;\n for (let i = 0; i < input.length; i++) {\n h ^= input.charCodeAt(i);\n h = Math.imul(h, 0x01000193) >>> 0;\n }\n return h >>> 0;\n}\n\n/** Deterministic 0-99 bucket for percentage rollouts. */\nexport function rolloutBucket(subject: string, salt: string): number {\n return fnv1a(`${salt}:${subject}`) % 100;\n}\n\nexport function slugify(input: string): string {\n return input\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 64) || \"untitled\";\n}\n\nconst ALPHABET = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n/** URL-safe random id. Uses crypto when available, falls back to Math.random (ids are not secrets). */\nexport function randomId(size = 16): string {\n const g: any = typeof globalThis !== \"undefined\" ? globalThis : {};\n let bytes: Uint8Array;\n if (g.crypto && typeof g.crypto.getRandomValues === \"function\") {\n bytes = new Uint8Array(size);\n g.crypto.getRandomValues(bytes);\n } else {\n bytes = new Uint8Array(size);\n for (let i = 0; i < size; i++) bytes[i] = Math.floor(Math.random() * 256);\n }\n let out = \"\";\n for (let i = 0; i < size; i++) out += ALPHABET[(bytes[i] as number) % ALPHABET.length];\n return out;\n}\n\nexport function isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/** Safe nested getter: get(obj, \"account.plan\") */\nexport function getPath(obj: unknown, path: string): unknown {\n if (!path) return obj;\n let cur: any = obj;\n for (const part of path.split(\".\")) {\n if (cur == null) return undefined;\n cur = cur[part];\n }\n return cur;\n}\n\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\n/** Glob-style URL pattern match: `*` matches any chars except `/`, `**` matches anything. */\nexport function matchUrlPattern(pattern: string, url: string): boolean {\n if (!pattern) return true;\n if (pattern === url) return true;\n const escaped = pattern\n .replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n .replace(/\\*\\*/g, \"__GLOBSTAR__\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/__GLOBSTAR__/g, \".*\");\n const re = new RegExp(`^${escaped}$`);\n return re.test(url) || re.test(stripOrigin(url));\n}\n\nexport function stripOrigin(url: string): string {\n try {\n const u = new URL(url);\n return u.pathname + u.search + u.hash;\n } catch {\n return url;\n }\n}\n\n/** Safe regexp construction with a length cap to limit ReDoS exposure. */\nexport function safeRegExp(source: string, flags = \"i\"): RegExp | null {\n if (!source || source.length > 200) return null;\n try {\n return new RegExp(source, flags);\n } catch {\n return null;\n }\n}\n","/**\n * Cross-platform helpers shared by the web SDK, the React Native SDK and (as a reference for) the\n * native iOS/Android SDKs. Zod-free so it can ship in runtime bundles.\n */\n\n/** Platforms a guide can be delivered to. */\nexport const PLATFORMS = [\"web\", \"ios\", \"android\"] as const;\nexport type Platform = (typeof PLATFORMS)[number];\n\n/** Guides published before platforms existed have no `platforms` field and are web-only. */\nexport const DEFAULT_PLATFORMS: Platform[] = [\"web\"];\n\n/** Platforms a guide config targets (missing field → web only). */\nexport function guidePlatforms(config: { platforms?: readonly string[] | null }): string[] {\n return Array.isArray(config.platforms) ? [...config.platforms] : [...DEFAULT_PLATFORMS];\n}\n\nexport function supportsPlatform(config: { platforms?: readonly string[] | null }, platform: string): boolean {\n return guidePlatforms(config).includes(platform);\n}\n\n/** Attribute web apps put on elements to share a target id with their mobile apps. */\nexport const GUIDELY_ID_ATTRIBUTE = \"data-guidely-id\";\n\n/**\n * Extracts a Guidely target id from a trigger / advance / checklist value so the same guide works on\n * web and mobile. Accepts a bare id (`new-deal`), `#new-deal`, or `[data-guidely-id=\"new-deal\"]`\n * (also `data-testid` / `data-tour`). Returns null for selectors that cannot name a single id.\n */\nexport function guidelyIdFromSelector(value: string | null | undefined): string | null {\n const v = (value ?? \"\").trim();\n if (!v) return null;\n if (/^[A-Za-z0-9_][A-Za-z0-9_\\-:.]*$/.test(v)) return v;\n const hash = v.match(/^#([A-Za-z0-9_][A-Za-z0-9_\\-:.]*)$/);\n if (hash) return hash[1] as string;\n const attr = v.match(/^(?:[a-z][a-z0-9]*)?\\[\\s*data-(?:guidely-id|testid|tour)\\s*=\\s*([\"']?)([^\"'\\]]+)\\1\\s*\\]$/i);\n if (attr) return (attr[2] as string).trim();\n return null;\n}\n\n/**\n * Mobile SDKs have screens instead of URLs. URL-based features (URL patterns, `url_match` triggers,\n * multi-page steps, `url_visited` checklist tasks) match against the screen path `/<ScreenName>`.\n */\nexport function screenPath(screen: string | null | undefined): string {\n const s = (screen ?? \"\").trim();\n if (!s) return \"/\";\n return s.startsWith(\"/\") ? s : `/${s}`;\n}\n\n/**\n * Compares dotted version strings numerically (`2.10.0` > `2.9.3`). Non-numeric parts compare as\n * strings; a missing part counts as 0 (`2.1` == `2.1.0`). Returns -1, 0 or 1, or null when either\n * side is empty.\n */\nexport function compareVersions(a: unknown, b: unknown): -1 | 0 | 1 | null {\n const sa = a == null ? \"\" : String(a).trim().replace(/^v/i, \"\");\n const sb = b == null ? \"\" : String(b).trim().replace(/^v/i, \"\");\n if (!sa || !sb) return null;\n const pa = sa.split(/[.+-]/);\n const pb = sb.split(/[.+-]/);\n const n = Math.max(pa.length, pb.length);\n for (let i = 0; i < n; i++) {\n const x = pa[i] ?? \"0\";\n const y = pb[i] ?? \"0\";\n const nx = /^\\d+$/.test(x) ? Number(x) : NaN;\n const ny = /^\\d+$/.test(y) ? Number(y) : NaN;\n if (!Number.isNaN(nx) && !Number.isNaN(ny)) {\n if (nx !== ny) return nx < ny ? -1 : 1;\n } else if (x !== y) {\n return x < y ? -1 : 1;\n }\n }\n return 0;\n}\n","/**\n * Pure checklist / survey logic shared by every renderer (web runtime, React Native, and the\n * reference for the native SDKs). Zod-free; uses structural types so it stays in the runtime entry.\n */\n\nexport type SurveyAnswer = string | number | boolean | string[];\nexport type SurveyAnswers = Record<string, SurveyAnswer>;\n\nexport interface ShowWhen {\n questionId: string;\n op: \"equals\" | \"lte\" | \"gte\" | \"in\";\n value: string | number | string[];\n}\n\n/** Evaluates a question's `showWhen` condition against current answers. */\nexport function isQuestionVisible(q: { showWhen?: ShowWhen }, answers: SurveyAnswers): boolean {\n if (!q.showWhen) return true;\n const actual = answers[q.showWhen.questionId];\n if (actual === undefined) return false;\n const expected = q.showWhen.value;\n switch (q.showWhen.op) {\n case \"equals\":\n return Array.isArray(actual) ? actual.includes(String(expected)) : String(actual) === String(expected);\n case \"lte\":\n return Number(actual) <= Number(expected);\n case \"gte\":\n return Number(actual) >= Number(expected);\n case \"in\": {\n const list = Array.isArray(expected) ? expected : [String(expected)];\n return Array.isArray(actual) ? actual.some((a) => list.includes(a)) : list.includes(String(actual));\n }\n default:\n return false;\n }\n}\n\n/** Are all required tasks done? */\nexport function isChecklistComplete(config: { tasks: Array<{ id: string; required: boolean }> }, progress: { completedTaskIds: string[] }): boolean {\n const done = new Set(progress.completedTaskIds);\n return config.tasks.filter((t) => t.required).every((t) => done.has(t.id));\n}\n","import { z } from \"zod\";\nimport { RULE_FIELDS, RULE_OPERATORS, type Rule, type RuleGroup } from \"./targeting-eval\";\n\nexport * from \"./targeting-eval\";\n\nexport const RuleSchema: z.ZodType<Rule> = z.object({\n id: z.string().min(1),\n field: z.enum(RULE_FIELDS),\n key: z.string().max(200).optional(),\n op: z.enum(RULE_OPERATORS),\n value: z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]).optional(),\n negate: z.boolean().optional(),\n});\n\nexport const RuleGroupSchema: z.ZodType<RuleGroup> = z.lazy(() =>\n z.object({\n id: z.string().min(1),\n op: z.enum([\"and\", \"or\"]),\n rules: z.array(z.union([RuleSchema, RuleGroupSchema])).max(100),\n negate: z.boolean().optional(),\n }),\n);\n","/**\n * Zod-free targeting evaluation. Imported by the browser SDK via `@guidelytech/shared/runtime`\n * so the runtime bundle does not pull in zod. Schemas live in ./targeting.ts.\n */\nimport { compareVersions } from \"./platform\";\nimport { getPath, matchUrlPattern, rolloutBucket, safeRegExp } from \"./utils\";\n\nexport const RULE_OPERATORS = [\n \"equals\",\n \"not_equals\",\n \"contains\",\n \"not_contains\",\n \"starts_with\",\n \"ends_with\",\n \"exists\",\n \"not_exists\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"in\",\n \"not_in\",\n \"regex\",\n \"is_true\",\n \"is_false\",\n \"before\",\n \"after\",\n] as const;\nexport type RuleOperator = (typeof RULE_OPERATORS)[number];\n\nexport const RULE_FIELDS = [\n \"user.attribute\",\n \"account.attribute\",\n \"user.role\",\n \"user.plan\",\n \"url.path\",\n \"url.full\",\n \"url.query\",\n \"device.type\",\n \"device.browser\",\n \"device.os\",\n \"visitor.firstVisit\",\n \"visitor.returning\",\n \"event.seen\",\n \"guide.completed\",\n \"guide.dismissed\",\n \"guide.seen\",\n \"checklist.completed\",\n \"audience.member\",\n \"datetime.now\",\n \"datetime.dayOfWeek\",\n \"datetime.hour\",\n \"rollout.percentage\",\n \"environment\",\n \"locale\",\n \"app.platform\",\n \"app.screen\",\n \"app.version\",\n] as const;\nexport type RuleField = (typeof RULE_FIELDS)[number];\n\nexport interface Rule {\n id: string;\n field: RuleField;\n /** For attribute/query/event fields: the attribute key, query param name, event name, guide id... */\n key?: string;\n op: RuleOperator;\n value?: string | number | boolean | string[];\n /** When true, the rule is negated (exclusion rule). */\n negate?: boolean;\n}\n\nexport type RuleGroup = {\n id: string;\n op: \"and\" | \"or\";\n rules: Array<Rule | RuleGroup>;\n negate?: boolean;\n};\n\nexport function isRuleGroup(r: Rule | RuleGroup): r is RuleGroup {\n return (r as RuleGroup).rules !== undefined;\n}\n\nexport function emptyRuleGroup(id = \"root\"): RuleGroup {\n return { id, op: \"and\", rules: [] };\n}\n\n/** Everything targeting evaluation can see. Built by the SDK (browser) or the server. */\nexport interface TargetingContext {\n userId?: string | null;\n anonymousId: string;\n userAttributes: Record<string, unknown>;\n accountAttributes: Record<string, unknown>;\n url: string;\n path: string;\n query: Record<string, string>;\n device: { type: \"desktop\" | \"tablet\" | \"mobile\"; browser?: string; os?: string };\n firstVisit: boolean;\n eventsSeen: Set<string> | string[];\n completedGuides: Set<string> | string[];\n dismissedGuides: Set<string> | string[];\n seenGuides: Set<string> | string[];\n completedChecklists: Set<string> | string[];\n audienceIds: Set<string> | string[];\n now: Date;\n environment: string;\n locale?: string;\n /** `web`, `ios` or `android`. Missing means web. */\n platform?: string;\n /** Current screen name (mobile SDKs; set via `screen()`). */\n screen?: string;\n /** Host app version (mobile SDKs), e.g. `2.4.1`. */\n appVersion?: string;\n /** Salt for rollout (guide id). Set per guide before evaluating. */\n rolloutSalt?: string;\n}\n\nfunction has(set: Set<string> | string[] | undefined, v: string): boolean {\n if (!set) return false;\n return set instanceof Set ? set.has(v) : set.includes(v);\n}\n\nfunction resolveField(rule: Rule, ctx: TargetingContext): unknown {\n switch (rule.field) {\n case \"user.attribute\":\n return rule.key ? getPath(ctx.userAttributes, rule.key) : undefined;\n case \"account.attribute\":\n return rule.key ? getPath(ctx.accountAttributes, rule.key) : undefined;\n case \"user.role\":\n return ctx.userAttributes.role;\n case \"user.plan\":\n return ctx.userAttributes.plan ?? ctx.accountAttributes.plan;\n case \"url.path\":\n return ctx.path;\n case \"url.full\":\n return ctx.url;\n case \"url.query\":\n return rule.key ? ctx.query[rule.key] : undefined;\n case \"device.type\":\n return ctx.device.type;\n case \"device.browser\":\n return ctx.device.browser;\n case \"device.os\":\n return ctx.device.os;\n case \"visitor.firstVisit\":\n return ctx.firstVisit;\n case \"visitor.returning\":\n return !ctx.firstVisit;\n case \"event.seen\":\n return rule.key ? has(ctx.eventsSeen, rule.key) : false;\n case \"guide.completed\":\n return rule.key ? has(ctx.completedGuides, rule.key) : false;\n case \"guide.dismissed\":\n return rule.key ? has(ctx.dismissedGuides, rule.key) : false;\n case \"guide.seen\":\n return rule.key ? has(ctx.seenGuides, rule.key) : false;\n case \"checklist.completed\":\n return rule.key ? has(ctx.completedChecklists, rule.key) : false;\n case \"audience.member\":\n return rule.key ? has(ctx.audienceIds, rule.key) : false;\n case \"datetime.now\":\n return ctx.now.toISOString();\n case \"datetime.dayOfWeek\":\n return ctx.now.getDay();\n case \"datetime.hour\":\n return ctx.now.getHours();\n case \"rollout.percentage\":\n return rolloutBucket(ctx.userId || ctx.anonymousId, ctx.rolloutSalt || \"guidely\");\n case \"environment\":\n return ctx.environment;\n case \"locale\":\n return ctx.locale;\n case \"app.platform\":\n return ctx.platform ?? \"web\";\n case \"app.screen\":\n return ctx.screen;\n case \"app.version\":\n return ctx.appVersion;\n default:\n return undefined;\n }\n}\n\nfunction toNumber(v: unknown): number | null {\n if (typeof v === \"number\") return v;\n if (typeof v === \"string\" && v.trim() !== \"\" && !Number.isNaN(Number(v))) return Number(v);\n if (v instanceof Date) return v.getTime();\n return null;\n}\n\nfunction toDateMs(v: unknown): number | null {\n if (v instanceof Date) return v.getTime();\n if (typeof v === \"string\") {\n const t = Date.parse(v);\n return Number.isNaN(t) ? null : t;\n }\n if (typeof v === \"number\") return v;\n return null;\n}\n\nexport function compare(op: RuleOperator, actual: unknown, expected: Rule[\"value\"]): boolean {\n switch (op) {\n case \"exists\":\n return actual !== undefined && actual !== null && actual !== \"\";\n case \"not_exists\":\n return actual === undefined || actual === null || actual === \"\";\n case \"is_true\":\n return actual === true || actual === \"true\";\n case \"is_false\":\n return actual === false || actual === \"false\";\n case \"equals\":\n if (typeof actual === \"boolean\") return String(actual) === String(expected);\n return String(actual ?? \"\") === String(expected ?? \"\");\n case \"not_equals\":\n return String(actual ?? \"\") !== String(expected ?? \"\");\n case \"contains\":\n return typeof actual === \"string\" && actual.toLowerCase().includes(String(expected ?? \"\").toLowerCase());\n case \"not_contains\":\n return !(typeof actual === \"string\" && actual.toLowerCase().includes(String(expected ?? \"\").toLowerCase()));\n case \"starts_with\":\n return typeof actual === \"string\" && actual.startsWith(String(expected ?? \"\"));\n case \"ends_with\":\n return typeof actual === \"string\" && actual.endsWith(String(expected ?? \"\"));\n case \"gt\":\n case \"gte\":\n case \"lt\":\n case \"lte\": {\n const a = toNumber(actual);\n const b = toNumber(expected);\n if (a === null || b === null) return false;\n return op === \"gt\" ? a > b : op === \"gte\" ? a >= b : op === \"lt\" ? a < b : a <= b;\n }\n case \"in\": {\n const list = Array.isArray(expected) ? expected : String(expected ?? \"\").split(\",\").map((s) => s.trim());\n return list.includes(String(actual ?? \"\"));\n }\n case \"not_in\": {\n const list = Array.isArray(expected) ? expected : String(expected ?? \"\").split(\",\").map((s) => s.trim());\n return !list.includes(String(actual ?? \"\"));\n }\n case \"regex\": {\n const re = safeRegExp(String(expected ?? \"\"));\n return !!re && typeof actual === \"string\" && re.test(actual);\n }\n case \"before\": {\n const a = toDateMs(actual);\n const b = toDateMs(expected);\n return a !== null && b !== null && a < b;\n }\n case \"after\": {\n const a = toDateMs(actual);\n const b = toDateMs(expected);\n return a !== null && b !== null && a > b;\n }\n default:\n return false;\n }\n}\n\nexport function evaluateRule(rule: Rule, ctx: TargetingContext): boolean {\n let result: boolean;\n if (rule.field === \"url.path\" || rule.field === \"url.full\" || rule.field === \"app.screen\") {\n const actual = String(resolveField(rule, ctx) ?? \"\");\n if (rule.op === \"equals\") result = matchUrlPattern(String(rule.value ?? \"\"), actual);\n else if (rule.op === \"not_equals\") result = !matchUrlPattern(String(rule.value ?? \"\"), actual);\n else result = compare(rule.op, actual, rule.value);\n } else if (rule.field === \"app.version\" && [\"equals\", \"not_equals\", \"gt\", \"gte\", \"lt\", \"lte\"].includes(rule.op)) {\n const c = compareVersions(resolveField(rule, ctx), rule.value);\n if (c === null) result = rule.op === \"not_equals\";\n else result = rule.op === \"equals\" ? c === 0 : rule.op === \"not_equals\" ? c !== 0 : rule.op === \"gt\" ? c > 0 : rule.op === \"gte\" ? c >= 0 : rule.op === \"lt\" ? c < 0 : c <= 0;\n } else {\n result = compare(rule.op, resolveField(rule, ctx), rule.value);\n }\n return rule.negate ? !result : result;\n}\n\n/** Evaluate a rule tree. An empty group matches everyone. */\nexport function evaluateRules(group: RuleGroup | null | undefined, ctx: TargetingContext): boolean {\n if (!group || group.rules.length === 0) return group?.negate ? false : true;\n const results = group.rules.map((r) => (isRuleGroup(r) ? evaluateRules(r, ctx) : evaluateRule(r, ctx)));\n const value = group.op === \"and\" ? results.every(Boolean) : results.some(Boolean);\n return group.negate ? !value : value;\n}\n\n/** Fields whose evaluation requires server-held data. Used by docs/UI to annotate rules. */\nexport const SERVER_ASSISTED_FIELDS: RuleField[] = [\"audience.member\", \"guide.completed\", \"guide.dismissed\", \"guide.seen\", \"checklist.completed\"];\n\nexport function describeRule(rule: Rule): string {\n const subject = rule.key ? `${rule.field}[${rule.key}]` : rule.field;\n const v = Array.isArray(rule.value) ? rule.value.join(\", \") : rule.value === undefined ? \"\" : String(rule.value);\n return `${rule.negate ? \"NOT \" : \"\"}${subject} ${rule.op.replace(/_/g, \" \")}${v ? ` \"${v}\"` : \"\"}`;\n}\n","import { z } from \"zod\";\nimport { PLATFORMS } from \"./platform\";\nimport { RuleGroupSchema, emptyRuleGroup, type RuleGroup } from \"./targeting\";\n\nexport const GUIDE_KINDS = [\"flow\", \"modal\", \"tooltip\", \"banner\", \"checklist\", \"survey\", \"announcement\"] as const;\nexport type GuideKind = (typeof GUIDE_KINDS)[number];\n\nexport const GUIDE_STATUSES = [\"draft\", \"published\", \"paused\", \"archived\"] as const;\nexport type GuideStatus = (typeof GUIDE_STATUSES)[number];\n\nexport const STEP_TYPES = [\"modal\", \"tooltip\", \"popover\", \"spotlight\", \"hotspot\", \"banner\", \"slideout\", \"checklist\", \"custom\", \"survey\"] as const;\nexport type StepType = (typeof STEP_TYPES)[number];\n\nexport const PLACEMENTS = [\"top\", \"top-start\", \"top-end\", \"right\", \"right-start\", \"right-end\", \"bottom\", \"bottom-start\", \"bottom-end\", \"left\", \"left-start\", \"left-end\", \"auto\"] as const;\nexport type Placement = (typeof PLACEMENTS)[number];\n\n/** `guidely-id` is cross-platform: `data-guidely-id` on web, `GuidelyTarget` / `guidelyTarget()` on mobile. */\nexport const SELECTOR_KINDS = [\"css\", \"id\", \"data-attr\", \"aria\", \"text\", \"xpath\", \"guidely-id\"] as const;\nexport const SelectorStrategySchema = z.object({\n kind: z.enum(SELECTOR_KINDS),\n value: z.string().min(1).max(1000),\n /** Optional human-readable label captured at pick time. */\n label: z.string().max(200).optional(),\n});\nexport type SelectorStrategy = z.infer<typeof SelectorStrategySchema>;\n\nexport const TargetSchema = z.object({\n /** Ordered strategies; the first one resolving to exactly one element wins. */\n selectors: z.array(SelectorStrategySchema).max(10),\n /** How long to wait for the element before applying fallback. */\n waitMs: z.number().int().min(0).max(60000).default(5000),\n /** What to do when the element never shows up. */\n fallback: z.enum([\"skip\", \"show_as_modal\", \"end_guide\", \"wait\"]).default(\"skip\"),\n /** Scroll the element into view before positioning. */\n scrollIntoView: z.boolean().default(true),\n /** Text snapshot captured at pick time; used for authoring warnings. */\n textSnapshot: z.string().max(200).optional(),\n});\nexport type StepTarget = z.infer<typeof TargetSchema>;\n\nexport const BUTTON_ACTIONS = [\"next\", \"back\", \"dismiss\", \"complete\", \"skip\", \"url\", \"start_guide\", \"event\", \"open_resource_center\", \"none\"] as const;\nexport const ButtonSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1).max(80),\n action: z.enum(BUTTON_ACTIONS),\n variant: z.enum([\"primary\", \"secondary\", \"ghost\", \"link\"]).default(\"primary\"),\n /** url for `url`, guide id for `start_guide`, event name for `event`, step id for `next` branch override */\n value: z.string().max(2000).optional(),\n newTab: z.boolean().optional(),\n});\nexport type StepButton = z.infer<typeof ButtonSchema>;\n\nexport const StepBranchSchema = z.object({\n id: z.string(),\n /** Rule group evaluated against targeting context when leaving the step. */\n when: RuleGroupSchema,\n /** Step id to jump to. */\n goTo: z.string(),\n});\n\nexport const ADVANCE_ON = [\"button\", \"element_click\", \"element_visible\", \"event\", \"delay\", \"any\"] as const;\n\nexport const StepSchema = z.object({\n id: z.string().min(1).max(64),\n type: z.enum(STEP_TYPES),\n title: z.string().max(200).default(\"\"),\n /** Sanitized HTML body (links, images, lists, formatting). */\n body: z.string().max(20000).default(\"\"),\n imageUrl: z.string().url().max(2000).optional().or(z.literal(\"\")),\n buttons: z.array(ButtonSchema).max(6).default([]),\n target: TargetSchema.optional(),\n placement: z.enum(PLACEMENTS).default(\"auto\"),\n /** Pixel offset between anchor and card. */\n offset: z.number().int().min(0).max(64).default(10),\n showOverlay: z.boolean().default(false),\n showProgress: z.boolean().default(true),\n showClose: z.boolean().default(true),\n dismissOnOutsideClick: z.boolean().default(false),\n /** Highlight padding for spotlight. */\n spotlightPadding: z.number().int().min(0).max(64).default(6),\n /** Banner/slideout position. */\n position: z.enum([\"top\", \"bottom\", \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\", \"center\"]).default(\"bottom-right\"),\n /** URL pattern this step belongs to (for multi-page flows). */\n url: z.string().max(500).optional(),\n /** Automatic advancement. */\n advanceOn: z.enum(ADVANCE_ON).default(\"button\"),\n advanceValue: z.string().max(500).optional(),\n advanceDelayMs: z.number().int().min(0).max(600000).optional(),\n branches: z.array(StepBranchSchema).max(10).default([]),\n width: z.number().int().min(200).max(900).optional(),\n /** Step-level targeting: skip step when rules do not match. */\n targeting: RuleGroupSchema.optional(),\n /** Hotspot pulse dot settings. */\n hotspot: z.object({ size: z.number().int().min(8).max(40).default(14), pulse: z.boolean().default(true), openOn: z.enum([\"click\", \"hover\"]).default(\"click\") }).optional(),\n /** Custom step: arbitrary sanitized HTML with no chrome. */\n customHtml: z.string().max(50000).optional(),\n});\nexport type GuideStep = z.infer<typeof StepSchema>;\nexport type GuideStepInput = z.input<typeof StepSchema>;\n\nexport const TRIGGER_TYPES = [\"page_load\", \"url_match\", \"event\", \"element_click\", \"element_visible\", \"manual\", \"delay\", \"after_guide\", \"segment_enter\"] as const;\nexport const TriggerSchema = z.object({\n type: z.enum(TRIGGER_TYPES).default(\"page_load\"),\n /** url pattern, event name, selector, guide id, audience id depending on type */\n value: z.string().max(1000).optional(),\n delayMs: z.number().int().min(0).max(600000).default(0),\n /** Also require URL to match this pattern (any trigger). */\n urlPattern: z.string().max(500).optional(),\n});\nexport type TriggerConfig = z.infer<typeof TriggerSchema>;\n\nexport const FrequencySchema = z.object({\n mode: z.enum([\"once\", \"once_per_session\", \"every_time\", \"interval\"]).default(\"once\"),\n intervalHours: z.number().int().min(1).max(8760).optional(),\n maxImpressions: z.number().int().min(1).max(1000).optional(),\n /** Hours to wait after dismissal before eligible again (when not `once`). */\n cooldownHours: z.number().int().min(0).max(8760).default(0),\n /** Lower number wins when multiple guides qualify. */\n priority: z.number().int().min(0).max(1000).default(100),\n /** Guide ids that must not be active at the same time. */\n mutuallyExclusiveWith: z.array(z.string()).max(50).default([]),\n /** Re-show if dismissed (otherwise dismissal counts as completion for frequency). */\n reshowAfterDismiss: z.boolean().default(false),\n});\nexport type FrequencyConfig = z.infer<typeof FrequencySchema>;\n\nexport const AppearanceSchema = z.object({\n theme: z.enum([\"light\", \"dark\", \"auto\"]).default(\"auto\"),\n primaryColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),\n backgroundColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),\n textColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),\n borderRadius: z.number().int().min(0).max(32).optional(),\n fontFamily: z.string().max(200).optional(),\n overlayOpacity: z.number().min(0).max(1).optional(),\n zIndex: z.number().int().min(1).max(2147483647).optional(),\n preset: z.string().max(50).optional(),\n animation: z.enum([\"fade\", \"slide\", \"none\"]).default(\"fade\"),\n});\nexport type Appearance = z.infer<typeof AppearanceSchema>;\n\nexport const ChecklistTaskSchema = z.object({\n id: z.string().min(1),\n title: z.string().min(1).max(200),\n description: z.string().max(2000).default(\"\"),\n /** How the task completes. */\n completion: z.enum([\"manual\", \"event\", \"guide_completed\", \"url_visited\", \"click\"]).default(\"manual\"),\n completionValue: z.string().max(500).optional(),\n /** Optional action when clicking the task. */\n action: z.enum([\"none\", \"start_guide\", \"url\", \"event\"]).default(\"none\"),\n actionValue: z.string().max(2000).optional(),\n required: z.boolean().default(true),\n});\nexport type ChecklistTask = z.infer<typeof ChecklistTaskSchema>;\n\nexport const ChecklistConfigSchema = z.object({\n tasks: z.array(ChecklistTaskSchema).min(1).max(30),\n ordered: z.boolean().default(false),\n launcherLabel: z.string().max(60).default(\"Getting started\"),\n position: z.enum([\"bottom-right\", \"bottom-left\"]).default(\"bottom-right\"),\n completionTitle: z.string().max(200).default(\"You're all set!\"),\n completionBody: z.string().max(2000).default(\"\"),\n autoOpen: z.boolean().default(true),\n dismissible: z.boolean().default(true),\n});\nexport type ChecklistConfig = z.infer<typeof ChecklistConfigSchema>;\n\nexport const SURVEY_QUESTION_TYPES = [\"nps\", \"csat\", \"thumbs\", \"single_choice\", \"multiple_choice\", \"text\", \"rating\"] as const;\nexport const SurveyQuestionSchema = z.object({\n id: z.string().min(1),\n type: z.enum(SURVEY_QUESTION_TYPES),\n title: z.string().min(1).max(500),\n description: z.string().max(1000).default(\"\"),\n required: z.boolean().default(true),\n options: z.array(z.object({ id: z.string(), label: z.string().max(200) })).max(20).default([]),\n scaleMax: z.number().int().min(2).max(10).optional(),\n lowLabel: z.string().max(60).optional(),\n highLabel: z.string().max(60).optional(),\n placeholder: z.string().max(200).optional(),\n /** Conditional follow-up: show only when a previous answer matches. */\n showWhen: z.object({ questionId: z.string(), op: z.enum([\"equals\", \"lte\", \"gte\", \"in\"]), value: z.union([z.string(), z.number(), z.array(z.string())]) }).optional(),\n});\nexport type SurveyQuestion = z.infer<typeof SurveyQuestionSchema>;\n\nexport const SurveyConfigSchema = z.object({\n questions: z.array(SurveyQuestionSchema).min(1).max(20),\n thankYouTitle: z.string().max(200).default(\"Thanks for your feedback!\"),\n thankYouBody: z.string().max(2000).default(\"\"),\n position: z.enum([\"bottom-right\", \"bottom-left\", \"center\"]).default(\"bottom-right\"),\n startAt: z.string().datetime().optional(),\n endAt: z.string().datetime().optional(),\n});\nexport type SurveyConfig = z.infer<typeof SurveyConfigSchema>;\n\nexport const GuideConfigSchema = z.object({\n steps: z.array(StepSchema).max(50).default([]),\n targeting: RuleGroupSchema.default(() => emptyRuleGroup()),\n trigger: TriggerSchema.default({}),\n frequency: FrequencySchema.default({}),\n appearance: AppearanceSchema.default({}),\n checklist: ChecklistConfigSchema.optional(),\n survey: SurveyConfigSchema.optional(),\n /** Restrict guide to url pattern(s) (applied before trigger). On mobile these match the screen path `/<Screen>`. */\n urlPatterns: z.array(z.string().max(500)).max(20).default([]),\n /** Platforms that receive this guide. Guides created before mobile support are web-only. */\n platforms: z.array(z.enum(PLATFORMS)).max(PLATFORMS.length).default([\"web\"]),\n});\nexport type GuideConfig = z.infer<typeof GuideConfigSchema>;\nexport type GuideConfigInput = z.input<typeof GuideConfigSchema>;\n\nexport function defaultGuideConfig(kind: GuideKind): GuideConfig {\n return GuideConfigSchema.parse({\n steps: kind === \"checklist\" || kind === \"survey\" ? [] : [defaultStep(kind === \"flow\" ? \"tooltip\" : kind === \"banner\" ? \"banner\" : kind === \"tooltip\" ? \"tooltip\" : \"modal\")],\n checklist: kind === \"checklist\" ? { tasks: [{ id: \"task-1\", title: \"Complete your profile\" }] } : undefined,\n survey: kind === \"survey\" ? { questions: [{ id: \"q1\", type: \"nps\", title: \"How likely are you to recommend us to a friend?\" }] } : undefined,\n trigger: kind === \"checklist\" ? { type: \"page_load\" } : {},\n });\n}\n\nlet stepCounter = 0;\nexport function defaultStep(type: StepType, overrides: Partial<GuideStepInput> = {}): GuideStep {\n stepCounter += 1;\n const base: GuideStepInput = {\n id: `step-${Date.now().toString(36)}-${stepCounter}`,\n type,\n title: type === \"modal\" ? \"Welcome!\" : \"Step title\",\n body: \"<p>Describe what the user should do here.</p>\",\n buttons: [\n { id: \"btn-back\", label: \"Back\", action: \"back\", variant: \"ghost\" },\n { id: \"btn-next\", label: \"Next\", action: \"next\", variant: \"primary\" },\n ],\n placement: type === \"banner\" ? \"top\" : \"auto\",\n showOverlay: type === \"modal\" || type === \"spotlight\",\n ...overrides,\n };\n if ([\"tooltip\", \"popover\", \"spotlight\", \"hotspot\"].includes(type) && !base.target) {\n base.target = { selectors: [], waitMs: 5000, fallback: \"skip\", scrollIntoView: true };\n }\n return StepSchema.parse(base);\n}\n\n/** Buttons to show for a step; \"back\" buttons are hidden when there is no previous step to return to. */\nexport function visibleButtons(step: GuideStep, canGoBack: boolean): GuideStep[\"buttons\"] {\n return canGoBack ? step.buttons : step.buttons.filter((b) => b.action !== \"back\");\n}\n\n/** Validation beyond Zod shape: returns human-readable problems that block publishing. */\nexport interface ValidationIssue {\n level: \"error\" | \"warning\";\n stepId?: string;\n message: string;\n}\nexport function validateGuideConfig(kind: GuideKind, config: GuideConfig): ValidationIssue[] {\n const issues: ValidationIssue[] = [];\n if (kind === \"checklist\") {\n if (!config.checklist || config.checklist.tasks.length === 0) issues.push({ level: \"error\", message: \"Checklist needs at least one task.\" });\n } else if (kind === \"survey\") {\n if (!config.survey || config.survey.questions.length === 0) issues.push({ level: \"error\", message: \"Survey needs at least one question.\" });\n config.survey?.questions.forEach((q) => {\n if ((q.type === \"single_choice\" || q.type === \"multiple_choice\") && q.options.length < 2) issues.push({ level: \"error\", message: `Question \"${q.title}\" needs at least two options.` });\n });\n } else {\n if (config.steps.length === 0) issues.push({ level: \"error\", message: \"Add at least one step.\" });\n }\n if (config.platforms.length === 0) issues.push({ level: \"error\", message: \"Choose at least one platform (web, iOS or Android).\" });\n const mobile = config.platforms.some((p) => p !== \"web\");\n const ids = new Set<string>();\n config.steps.forEach((step, i) => {\n if (ids.has(step.id)) issues.push({ level: \"error\", stepId: step.id, message: `Duplicate step id \"${step.id}\".` });\n ids.add(step.id);\n const anchored = [\"tooltip\", \"popover\", \"spotlight\", \"hotspot\"].includes(step.type);\n if (anchored && (!step.target || step.target.selectors.length === 0)) issues.push({ level: \"error\", stepId: step.id, message: `Step ${i + 1} (${step.type}) needs a target element.` });\n if (mobile && anchored && step.target && step.target.selectors.length > 0 && !step.target.selectors.some((s) => s.kind === \"guidely-id\" || s.kind === \"id\"))\n issues.push({ level: \"warning\", stepId: step.id, message: `Step ${i + 1} has no Guidely id or element id target, so mobile apps cannot find its element.` });\n if (mobile && step.type === \"custom\") issues.push({ level: \"warning\", stepId: step.id, message: `Step ${i + 1} is a custom HTML step; mobile apps show it as a plain modal.` });\n if (!step.title && !step.body && step.type !== \"custom\") issues.push({ level: \"warning\", stepId: step.id, message: `Step ${i + 1} has no title or body.` });\n if (step.buttons.length === 0 && step.advanceOn === \"button\" && step.type !== \"hotspot\" && step.type !== \"custom\") issues.push({ level: \"warning\", stepId: step.id, message: `Step ${i + 1} has no buttons and advances on button; users can only close it.` });\n step.buttons.forEach((b) => {\n if (b.action === \"url\" && !/^https?:\\/\\//i.test(b.value || \"\") && !(b.value || \"\").startsWith(\"/\")) issues.push({ level: \"error\", stepId: step.id, message: `Button \"${b.label}\" needs an http(s) or relative URL.` });\n if (b.action === \"start_guide\" && !b.value) issues.push({ level: \"error\", stepId: step.id, message: `Button \"${b.label}\" needs a guide to start.` });\n });\n step.branches.forEach((br) => {\n if (!ids.has(br.goTo) && !config.steps.some((s) => s.id === br.goTo)) issues.push({ level: \"error\", stepId: step.id, message: `Branch points to unknown step \"${br.goTo}\".` });\n });\n });\n if (config.trigger.type === \"event\" && !config.trigger.value) issues.push({ level: \"error\", message: \"Event trigger needs an event name.\" });\n if (config.trigger.type === \"element_click\" && !config.trigger.value) issues.push({ level: \"error\", message: \"Element click trigger needs a selector.\" });\n if (config.trigger.type === \"url_match\" && !config.trigger.value) issues.push({ level: \"error\", message: \"URL trigger needs a pattern.\" });\n if (config.frequency.mode === \"interval\" && !config.frequency.intervalHours) issues.push({ level: \"error\", message: \"Interval frequency needs an interval in hours.\" });\n return issues;\n}\n\nexport interface ProjectTheme {\n primaryColor: string;\n backgroundColor: string;\n textColor: string;\n borderRadius: number;\n fontFamily: string;\n logoUrl?: string;\n brandName?: string;\n}\nexport const ProjectThemeSchema = z.object({\n primaryColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).default(\"#4f46e5\"),\n backgroundColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).default(\"#ffffff\"),\n textColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).default(\"#111827\"),\n borderRadius: z.number().int().min(0).max(32).default(12),\n fontFamily: z.string().max(200).default(\"Inter, system-ui, -apple-system, sans-serif\"),\n logoUrl: z.string().max(2000).optional(),\n brandName: z.string().max(100).optional(),\n});\n\nexport type { RuleGroup };\n","import { z } from \"zod\";\n\nexport const EVENT_NAMES = [\n \"guide_viewed\",\n \"guide_started\",\n \"step_viewed\",\n \"step_completed\",\n \"guide_completed\",\n \"guide_skipped\",\n \"guide_dismissed\",\n \"guide_abandoned\",\n \"checklist_task_completed\",\n \"checklist_completed\",\n \"checklist_dismissed\",\n \"survey_displayed\",\n \"survey_submitted\",\n \"survey_dismissed\",\n \"resource_center_opened\",\n \"article_viewed\",\n \"messenger_opened\",\n \"conversation_started\",\n \"conversation_handed_off\",\n \"scout_answered\",\n \"custom\",\n \"page_view\",\n \"identify\",\n // Product analytics (autocapture + error tracking)\n \"page_leave\",\n \"click\",\n \"rage_click\",\n \"exception\",\n \"heatmap\",\n] as const;\nexport type EventName = (typeof EVENT_NAMES)[number];\n\n/** Events the SDK records on its own (page analytics, click autocapture, error tracking). */\nexport const AUTOCAPTURE_EVENTS = [\"page_view\", \"page_leave\", \"click\", \"rage_click\", \"exception\", \"heatmap\"] as const;\n\nexport const GUIDE_LIFECYCLE_EVENTS = [\"guide_viewed\", \"guide_started\", \"step_viewed\", \"step_completed\", \"guide_completed\", \"guide_skipped\", \"guide_dismissed\", \"guide_abandoned\"] as const;\n\n/** Event as produced by the SDK and accepted by POST /api/v1/sdk/events */\nexport const SdkEventSchema = z.object({\n eventId: z.string().min(8).max(64),\n name: z.enum(EVENT_NAMES),\n /** For `custom` events: the application-defined name. */\n customName: z.string().min(1).max(120).optional(),\n occurredAt: z.string().datetime({ offset: true }),\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n accountId: z.string().max(256).optional().nullable(),\n sessionId: z.string().max(128).optional(),\n guideId: z.string().max(64).optional(),\n guideVersion: z.number().int().optional(),\n stepId: z.string().max(64).optional(),\n stepIndex: z.number().int().min(0).optional(),\n url: z.string().max(2000).optional(),\n properties: z.record(z.unknown()).optional(),\n});\nexport type SdkEvent = z.infer<typeof SdkEventSchema>;\n\nexport const EventBatchSchema = z.object({\n events: z.array(SdkEventSchema).min(1).max(50),\n sentAt: z.string().datetime({ offset: true }).optional(),\n sdk: z.object({ name: z.string().max(60), version: z.string().max(30) }).optional(),\n});\nexport type EventBatch = z.infer<typeof EventBatchSchema>;\n\nexport * from \"./events-util\";\nexport * from \"./errors\";\n","/** Reserved property names that are stripped from `properties` to avoid collecting sensitive data. */\nexport const SENSITIVE_PROPERTY_PATTERN = /(password|passwd|secret|token|credit|card|cvv|ssn|iban)/i;\n\nexport const MAX_PROPERTY_BYTES = 8 * 1024;\n\nexport function sanitizeProperties(props: Record<string, unknown> | undefined): Record<string, unknown> {\n if (!props) return {};\n const out: Record<string, unknown> = {};\n let size = 0;\n for (const [k, v] of Object.entries(props)) {\n if (SENSITIVE_PROPERTY_PATTERN.test(k)) continue;\n if (typeof v === \"function\" || typeof v === \"symbol\") continue;\n const str = typeof v === \"string\" ? v : JSON.stringify(v ?? null);\n size += k.length + (str?.length ?? 0);\n if (size > MAX_PROPERTY_BYTES) break;\n out[k.slice(0, 100)] = typeof v === \"string\" ? v.slice(0, 1000) : v;\n }\n return out;\n}\n","import { fnv1a } from \"./utils\";\n\n/** One parsed stack frame. `file` is the script URL (or path) as the browser reported it. */\nexport interface StackFrame {\n fn?: string;\n file?: string;\n line?: number;\n col?: number;\n}\n\n/** Properties carried by an `exception` event (see `docs/product-analytics.md`). */\nexport interface ExceptionProperties {\n type: string;\n message: string;\n frames: StackFrame[];\n /** `onerror` | `unhandledrejection` | `manual` (captureException) | `console`. */\n source?: string;\n handled?: boolean;\n /** App version or commit (SDK option `release`); selects the matching uploaded source maps. */\n release?: string;\n /** Set by the server at ingestion; groups occurrences into an issue. */\n fingerprint?: string;\n}\n\nexport const MAX_STACK_FRAMES = 30;\n\n// Chrome / Edge / Node: \" at fn (https://x/app.js:1:2)\" or \" at https://x/app.js:1:2\"\nconst V8 = /^\\s*at (?:(.+?) \\()?((?:[a-z][\\w+.-]*:)?[^\\s()]+?):(\\d+):(\\d+)\\)?\\s*$/i;\n// Firefox / Safari: \"fn@https://x/app.js:1:2\" or \"@https://x/app.js:1:2\"\nconst GECKO = /^\\s*(.*?)@(.+?):(\\d+):(\\d+)\\s*$/;\n\n/** Parses `Error.stack` from V8, SpiderMonkey and JavaScriptCore into frames (innermost first). */\nexport function parseStack(stack: string | undefined | null, max = MAX_STACK_FRAMES): StackFrame[] {\n if (!stack || typeof stack !== \"string\") return [];\n const frames: StackFrame[] = [];\n for (const raw of stack.split(\"\\n\")) {\n if (frames.length >= max) break;\n const line = raw.slice(0, 1000);\n const m = V8.exec(line) ?? GECKO.exec(line);\n if (!m) continue;\n const fn = (m[1] || \"\").trim();\n frames.push({ fn: fn ? fn.slice(0, 200) : undefined, file: m[2]?.slice(0, 500), line: Number(m[3]), col: Number(m[4]) });\n }\n return frames;\n}\n\n/** Replaces volatile parts of a message (numbers, ids, quoted values) so repeats group together. */\nexport function normalizeErrorMessage(message: string): string {\n return (message || \"\")\n .slice(0, 500)\n .replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, \"<uuid>\")\n .replace(/([\"'`]).*?\\1/g, \"<str>\")\n .replace(/\\b0x[0-9a-f]+\\b/gi, \"<hex>\")\n .replace(/\\d+(\\.\\d+)?/g, \"<n>\")\n .replace(/\\s+/g, \" \")\n .trim();\n}\n\n/** Strips origin, query, hash and build hashes (`main.3f2a1b9c.js` → `main.js`) from a script URL. */\nexport function normalizeFrameFile(file: string | undefined): string {\n if (!file) return \"\";\n let path = file;\n try {\n path = new URL(file).pathname;\n } catch {\n path = file.replace(/[?#].*$/, \"\");\n }\n return path.replace(/[.-][0-9a-f]{6,}(?=\\.\\w+$)/i, \"\").replace(/\\/\\d+\\//g, \"/<n>/\");\n}\n\n/** Source map upload limits (`POST /api/v1/sourcemaps/upload`). */\nexport const SOURCEMAP_MAX_FILE_BYTES = 25 * 1024 * 1024;\nexport const SOURCEMAP_MAX_FILES_PER_UPLOAD = 200;\n\n/**\n * Stable issue key for an exception: error type + normalised message + the innermost frame that\n * has a file (path without build hash + function name, or its original source + name when a source\n * map resolved it). Line/column numbers are left out because they change with every deploy of a\n * minified bundle.\n */\nexport function fingerprintError(input: { type?: string; message?: string; frames?: StackFrame[]; original?: { source: string; name?: string | null } | null }): string {\n const top = (input.frames ?? []).find((f) => f.file);\n // With a source map the original file and function name identify the frame across deploys, even\n // when a minifier renames functions between builds.\n const frameKey = input.original ? `src:${input.original.source}:${input.original.name || \"?\"}` : top ? `${normalizeFrameFile(top.file)}:${top.fn || \"?\"}` : \"\";\n const key = [input.type || \"Error\", normalizeErrorMessage(input.message || \"\"), frameKey].join(\"|\");\n const a = fnv1a(key).toString(16).padStart(8, \"0\");\n const b = fnv1a(`guidely:${key}`).toString(16).padStart(8, \"0\");\n return a + b;\n}\n","import { z } from \"zod\";\nimport { GuideConfigSchema, ProjectThemeSchema, type GuideKind, type GuideConfig } from \"./guide\";\nimport type { MessengerConfig } from \"./messenger\";\nimport type { AutocaptureSettings, ErrorTrackingSettings, ReplaySettings } from \"./capture\";\n\n/** A published guide as delivered to the SDK. Draft-only data (author, notes) is never included. */\nexport interface PublishedGuide {\n id: string;\n key: string;\n name: string;\n kind: GuideKind;\n version: number;\n config: GuideConfig;\n publishedAt: string;\n}\n\nexport interface ResourceCenterArticle {\n id: string;\n slug: string;\n title: string;\n summary: string;\n body: string;\n /** True when `body` was left out of the config to keep it small; fetch it from `GET /sdk/articles/:id`. */\n bodyOmitted?: boolean;\n collectionId?: string | null;\n externalUrl?: string | null;\n updatedAt: string;\n}\n\nexport interface ResourceCenterConfig {\n enabled: boolean;\n title: string;\n launcher: { position: \"bottom-right\" | \"bottom-left\"; label: string; showIcon: boolean };\n collections: Array<{ id: string; name: string; description: string; order: number }>;\n articles: ResourceCenterArticle[];\n recommendedGuideIds: string[];\n checklistGuideIds: string[];\n links: Array<{ id: string; label: string; url: string }>;\n faqs: Array<{ id: string; question: string; answer: string }>;\n}\n\nexport interface SdkConfigResponse {\n projectId: string;\n environment: string;\n configVersion: number;\n theme: z.infer<typeof ProjectThemeSchema>;\n guides: PublishedGuide[];\n resourceCenter: ResourceCenterConfig | null;\n /** Scout messenger; absent from servers that predate it. */\n messenger?: MessengerConfig | null;\n settings: {\n analyticsEnabled: boolean;\n collectUrls: boolean;\n maskSelectors: string[];\n sessionTimeoutMinutes: number;\n /** Product analytics; absent from servers that predate it (the SDK then captures nothing extra). */\n autocapture?: AutocaptureSettings;\n errorTracking?: ErrorTrackingSettings;\n /** `retentionDays` is server-side only and not sent. */\n replay?: Omit<ReplaySettings, \"retentionDays\">;\n };\n generatedAt: string;\n}\n\nexport const IdentifyRequestSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().min(1).max(256).optional().nullable(),\n traits: z.record(z.unknown()).optional(),\n account: z\n .object({ id: z.string().min(1).max(256), traits: z.record(z.unknown()).optional() })\n .optional()\n .nullable(),\n sessionId: z.string().max(128).optional(),\n url: z.string().max(2000).optional(),\n});\nexport type IdentifyRequest = z.infer<typeof IdentifyRequestSchema>;\n\n/** Server-held state the SDK needs for targeting & frequency. */\nexport interface IdentifyResponse {\n endUserId: string;\n audienceIds: string[];\n guideState: Record<\n string,\n { impressions: number; completedAt?: string | null; dismissedAt?: string | null; lastShownAt?: string | null }\n >;\n checklistProgress: Record<string, { completedTaskIds: string[]; completedAt?: string | null; dismissedAt?: string | null }>;\n surveysSubmitted: string[];\n firstSeenAt: string;\n}\n\nexport const ChecklistProgressRequestSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n guideVersion: z.number().int().optional(),\n completedTaskIds: z.array(z.string().max(64)).max(100),\n dismissed: z.boolean().optional(),\n completed: z.boolean().optional(),\n});\nexport type ChecklistProgressRequest = z.infer<typeof ChecklistProgressRequestSchema>;\n\nexport const SurveyResponseRequestSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n accountId: z.string().max(256).optional().nullable(),\n guideVersion: z.number().int(),\n answers: z.record(z.union([z.string().max(5000), z.number(), z.boolean(), z.array(z.string().max(500)).max(50)])),\n responseId: z.string().min(8).max(64),\n});\nexport type SurveyResponseRequest = z.infer<typeof SurveyResponseRequestSchema>;\n\nexport const GuideStateUpdateSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n updates: z\n .array(\n z.object({\n guideId: z.string(),\n impression: z.boolean().optional(),\n completed: z.boolean().optional(),\n dismissed: z.boolean().optional(),\n }),\n )\n .max(50),\n});\n\nexport const AuthoringPickSchema = z.object({\n stepId: z.string().max(64).optional(),\n selectors: z.array(z.object({ kind: z.string(), value: z.string().max(1000), label: z.string().max(200).optional() })).max(10),\n textSnapshot: z.string().max(200).optional(),\n url: z.string().max(2000).optional(),\n rect: z.object({ x: z.number(), y: z.number(), width: z.number(), height: z.number() }).optional(),\n});\nexport type AuthoringPick = z.infer<typeof AuthoringPickSchema>;\n\n/**\n * Static, script-free copy of the page an authoring session is connected to. The SDK posts it to\n * the dashboard (never to the API) so the editor canvas can show the customer's real app.\n */\nexport interface AppSnapshot {\n /** Full HTML document (doctype included) with scripts and Guidely UI removed and a `<base>` pointing at `url`. */\n html: string;\n url: string;\n title: string;\n /** Viewport the snapshot was taken at, in CSS pixels. */\n width: number;\n height: number;\n capturedAt: string;\n}\n\nexport interface AuthoringSessionInfo {\n id: string;\n projectId: string;\n environment: string;\n guideId: string | null;\n dashboardOrigin: string;\n expiresAt: string;\n /** Draft guide config to preview while authoring (not published). */\n draft: { id: string; key: string; name: string; kind: GuideKind; config: GuideConfig } | null;\n}\n\nexport const PublishedGuideSchema = z.object({\n id: z.string(),\n key: z.string(),\n name: z.string(),\n kind: z.string(),\n version: z.number(),\n config: GuideConfigSchema,\n publishedAt: z.string(),\n});\n\nexport interface ApiError {\n error: { code: string; message: string; details?: unknown };\n}\n","import { z } from \"zod\";\n\n/** Messenger settings delivered to the SDK in `SdkConfigResponse.messenger`. */\nexport interface MessengerConfig {\n enabled: boolean;\n /** Display name of the AI agent (\"Scout\"). */\n name: string;\n greeting: string;\n /** Scout answers with AI; when false every conversation goes to the team inbox. */\n aiAvailable: boolean;\n handoffEnabled: boolean;\n launcher: { position: \"bottom-right\" | \"bottom-left\" };\n}\n\nexport const MESSAGE_AUTHORS = [\"user\", \"scout\", \"agent\", \"system\"] as const;\nexport type MessageAuthor = (typeof MESSAGE_AUTHORS)[number];\nexport type ConversationStatus = \"bot\" | \"open\" | \"closed\";\n\nexport interface MessengerCitation {\n articleId: string;\n title: string;\n}\n\nexport interface MessengerSuggestedGuide {\n key: string;\n name: string;\n}\n\nexport interface MessengerMessage {\n id: string;\n author: MessageAuthor;\n /** Team member name for `agent` messages. */\n authorName?: string | null;\n body: string;\n citations: MessengerCitation[];\n suggestedGuides: MessengerSuggestedGuide[];\n status: \"pending\" | \"complete\" | \"failed\";\n createdAt: string;\n}\n\nexport interface MessengerConversation {\n id: string;\n status: ConversationStatus;\n subject: string;\n lastMessageAt: string;\n lastMessagePreview: string;\n unread: number;\n rating: number | null;\n}\n\nexport const MAX_MESSAGE_LENGTH = 4000;\nconst messageText = z.string().trim().min(1).max(MAX_MESSAGE_LENGTH);\n\nexport const StartConversationSchema = z.object({\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n message: messageText,\n pageUrl: z.string().max(2000).optional(),\n});\nexport type StartConversationRequest = z.infer<typeof StartConversationSchema>;\n\nexport interface StartConversationResponse {\n conversation: MessengerConversation;\n /** Secret that authorises this browser to read and post in the conversation. Store it; it is not shown again. */\n token: string;\n messages: MessengerMessage[];\n}\n\nexport const ConversationLookupSchema = z.object({\n tokens: z.array(z.string().min(16).max(128)).max(50),\n});\n\nexport interface ConversationLookupResponse {\n conversations: Array<MessengerConversation & { token: string }>;\n}\n\nexport const PostMessageSchema = z.object({ message: messageText });\n\nexport const ConversationRatingSchema = z.object({\n rating: z.number().int().min(1).max(5),\n comment: z.string().max(1000).optional(),\n});\n\nexport interface ConversationMessagesResponse {\n conversation: MessengerConversation;\n messages: MessengerMessage[];\n}\n\n/**\n * Server-sent events streamed by `POST /sdk/conversations` and `POST /sdk/conversations/:id/messages`\n * while Scout replies. `conversation` (start only) carries the new conversation and its token, `message`\n * each stored message, `delta` reply text as it is generated, and `done` the final stored message.\n */\nexport type ScoutStreamEvent =\n | { event: \"conversation\"; data: StartConversationResponse }\n | { event: \"message\"; data: MessengerMessage }\n | { event: \"delta\"; data: { messageId: string; text: string } }\n | { event: \"done\"; data: { message: MessengerMessage; conversation: MessengerConversation } }\n | { event: \"error\"; data: { message: string } };\n\n/** Article list entry for the messenger Help tab (bodies are fetched on demand). */\nexport interface SdkArticleSummary {\n id: string;\n slug: string;\n title: string;\n summary: string;\n collectionId: string | null;\n externalUrl: string | null;\n updatedAt: string;\n}\n\nexport interface SdkArticlesResponse {\n collections: Array<{ id: string; name: string; description: string; order: number }>;\n articles: SdkArticleSummary[];\n}\n","import { z } from \"zod\";\n\n/**\n * Product-analytics capture settings. Stored on `Project.settings` (keys `autocapture`,\n * `errorTracking`, `replay`) and delivered to the SDK in `SdkConfigResponse.settings`. The project\n * setting turns a capability on; SDK options can only turn it off for one installation.\n */\nexport interface AutocaptureSettings {\n /** `page_view` on load and on every SPA navigation. */\n pageviews: boolean;\n /** `page_leave` with visible time on page and scroll depth. */\n pageLeave: boolean;\n /** `click` on buttons, links and other interactive elements. */\n clicks: boolean;\n /** `rage_click` when the same spot is clicked 3+ times within a second. */\n rageClicks: boolean;\n /** Batched click positions on every element (`heatmap` events) for click heatmaps. */\n heatmaps: boolean;\n /** Mouse-movement heatmaps: pointer position sampled while it moves, aggregated in the browser into `heatmap` events. */\n mouseMovement: boolean;\n}\n\nexport interface ErrorTrackingSettings {\n /** Uncaught errors and unhandled promise rejections become `exception` events. */\n enabled: boolean;\n}\n\nexport interface ReplaySettings {\n enabled: boolean;\n /** Percentage of sessions recorded (0–100), decided once per session. */\n sampleRate: number;\n /** Record console.log/warn/error output into the recording. */\n recordConsole: boolean;\n /** Record network requests (method, URL with sensitive query values redacted, status, timing, size). */\n recordNetwork: boolean;\n /** Also record request/response headers and text/JSON bodies (redacted, ≤10KB each). Off by default. */\n recordNetworkPayloads: boolean;\n /** Mask every text node (inputs are always masked). */\n maskAllText: boolean;\n /** Elements replaced by a placeholder box in recordings (in addition to `[data-guidely-block]`). */\n blockSelectors: string[];\n /** Days recordings are kept before the worker deletes them. */\n retentionDays: number;\n}\n\nexport interface CaptureSettings {\n autocapture: AutocaptureSettings;\n errorTracking: ErrorTrackingSettings;\n replay: ReplaySettings;\n}\n\nexport const AutocaptureSettingsSchema = z.object({ pageviews: z.boolean(), pageLeave: z.boolean(), clicks: z.boolean(), rageClicks: z.boolean(), heatmaps: z.boolean(), mouseMovement: z.boolean() }).partial();\nexport const ErrorTrackingSettingsSchema = z.object({ enabled: z.boolean() }).partial();\nexport const ReplaySettingsSchema = z\n .object({\n enabled: z.boolean(),\n sampleRate: z.number().int().min(0).max(100),\n recordConsole: z.boolean(),\n recordNetwork: z.boolean(),\n recordNetworkPayloads: z.boolean(),\n maskAllText: z.boolean(),\n blockSelectors: z.array(z.string().min(1).max(200)).max(50),\n retentionDays: z.number().int().min(1).max(365),\n })\n .partial();\n\nexport const DEFAULT_CAPTURE_SETTINGS: CaptureSettings = {\n autocapture: { pageviews: true, pageLeave: true, clicks: true, rageClicks: true, heatmaps: true, mouseMovement: true },\n errorTracking: { enabled: true },\n replay: { enabled: false, sampleRate: 100, recordConsole: true, recordNetwork: true, recordNetworkPayloads: false, maskAllText: false, blockSelectors: [], retentionDays: 30 },\n};\n\n/** Fills defaults for whatever a project's stored settings leave out. */\nexport function resolveCaptureSettings(settings: unknown): CaptureSettings {\n const s = (settings && typeof settings === \"object\" ? settings : {}) as Record<string, unknown>;\n const obj = (v: unknown) => (v && typeof v === \"object\" && !Array.isArray(v) ? (v as Record<string, unknown>) : {});\n const d = DEFAULT_CAPTURE_SETTINGS;\n const a = AutocaptureSettingsSchema.safeParse(obj(s.autocapture));\n const e = ErrorTrackingSettingsSchema.safeParse(obj(s.errorTracking));\n const r = ReplaySettingsSchema.safeParse(obj(s.replay));\n return {\n autocapture: { ...d.autocapture, ...(a.success ? a.data : {}) },\n errorTracking: { ...d.errorTracking, ...(e.success ? e.data : {}) },\n replay: { ...d.replay, ...(r.success ? r.data : {}) },\n };\n}\n\n/**\n * One position in a `heatmap` event (`properties.points`). `x`/`y` are page coordinates in CSS\n * pixels; `s` is a stable selector for the element and `rx`/`ry` the position inside it (0–1), which\n * lets the dashboard place the point on the element even when layouts differ.\n *\n * Mouse movement (`k: \"m\"`) is sampled at most every 200ms while the pointer moves and binned in the\n * browser (per element at 0.1 of `rx`/`ry`, else on a 16px page grid); `w` is the number of samples\n * in the bin, so a minute of movement costs a few dozen points rather than thousands.\n */\nexport interface HeatmapPoint {\n /** `c` click, `r` part of a rage-click burst, `m` mouse movement. */\n k: \"c\" | \"r\" | \"m\";\n x: number;\n y: number;\n s?: string;\n rx?: number;\n ry?: number;\n /** Weight: samples aggregated into this point (movement only; clicks are 1). */\n w?: number;\n}\n\n/** Properties of a `heatmap` event: a batch of clicks on one page (flushed at ~40 points and on page leave). */\nexport interface HeatmapProperties {\n path?: string;\n viewportWidth: number;\n viewportHeight: number;\n /** Document scroll height when the batch was sent. */\n pageHeight: number;\n points: HeatmapPoint[];\n}\n\n/** Viewport buckets heatmaps are split by (CSS px of `viewportWidth`). */\nexport const HEATMAP_VIEWPORTS = { mobile: [0, 767], tablet: [768, 1279], desktop: [1280, 100_000] } as const;\nexport type HeatmapViewport = keyof typeof HEATMAP_VIEWPORTS;\n\n/**\n * One upload of rrweb events for a recording, `POST /api/v1/sdk/replay`. The SDK sends it as JSON,\n * or gzip-compressed JSON with `?enc=gzip`. A recording is keyed by the SDK session id; every page\n * load starts a new `windowId` whose uploads are numbered by `seq`.\n */\nexport const ReplayChunkSchema = z.object({\n sessionId: z.string().min(1).max(128),\n windowId: z.string().min(1).max(64),\n seq: z.number().int().min(0).max(1_000_000),\n anonymousId: z.string().min(1).max(128),\n userId: z.string().max(256).optional().nullable(),\n /** rrweb `eventWithTime` objects, in order. */\n events: z.array(z.object({ type: z.number().int(), timestamp: z.number() }).passthrough()).min(1).max(50_000),\n url: z.string().max(2000).optional(),\n device: z.object({ type: z.string().max(20), browser: z.string().max(40).optional(), os: z.string().max(40).optional() }).optional(),\n viewport: z.object({ width: z.number().int().min(0).max(100_000), height: z.number().int().min(0).max(100_000) }).optional(),\n sdk: z.object({ name: z.string().max(60), version: z.string().max(30) }).optional(),\n});\nexport type ReplayChunk = z.infer<typeof ReplayChunkSchema>;\n\n/** Max upload sizes for one replay chunk (bytes on the wire, and after decompression). */\nexport const REPLAY_MAX_COMPRESSED_BYTES = 2 * 1024 * 1024;\nexport const REPLAY_MAX_RAW_BYTES = 16 * 1024 * 1024;\n","/* Network requests recorded into session replays (zod-free: imported by the SDK recorder). */\n\n/** rrweb plugin name for network events in recordings (event type 6, `data.plugin`). */\nexport const NETWORK_PLUGIN = \"guidely/network@1\";\n\n/** Request kinds, from `fetch`/`XMLHttpRequest` patching or `PerformanceResourceTiming.initiatorType`. */\nexport type NetworkRequestType = \"fetch\" | \"xhr\" | \"websocket\" | \"document\" | \"script\" | \"stylesheet\" | \"image\" | \"font\" | \"media\" | \"beacon\" | \"other\";\n\n/**\n * One network request in a recording: the payload of an rrweb plugin event\n * `{ type: 6, data: { plugin: NETWORK_PLUGIN, payload: NetworkPluginPayload } }`, batched.\n * Times are epoch milliseconds (same clock as rrweb event timestamps).\n *\n * A WebSocket is a request with `type: \"websocket\"` and `method: \"GET\"`, emitted when it opens\n * (`startTime`) and again, with the same `id`, when it closes (`endTime`, `closeCode`, `closeReason`,\n * totals in `messages`). Its frames are `WebSocketMessage`s referencing that `id`.\n */\nexport interface NetworkRequest {\n /** Stable id within the recording. */\n id: string;\n type: NetworkRequestType;\n method: string;\n /** Absolute URL; values of sensitive-looking query parameters replaced with `[redacted]`. */\n url: string;\n startTime: number;\n endTime?: number;\n durationMs?: number;\n /** HTTP status; 0 for network errors / blocked / aborted. Absent when the browser doesn't expose it. */\n status?: number;\n /** Set for failed requests: network error, abort or timeout message. */\n error?: string;\n /** Encoded bytes transferred / decoded response size, when known. */\n transferSize?: number;\n responseSize?: number;\n /** Only when `recordNetworkPayloads` is on; sensitive headers are `[redacted]`. */\n requestHeaders?: Record<string, string>;\n responseHeaders?: Record<string, string>;\n /** Text/JSON bodies, ≤10KB, sensitive JSON fields masked; `[binary]` / `[truncated]` markers otherwise. */\n requestBody?: string;\n responseBody?: string;\n /** WebSocket only: negotiated subprotocol, close details, and frame totals (all frames, including ones not recorded). */\n protocol?: string;\n closeCode?: number;\n closeReason?: string;\n messages?: { sent: number; received: number; sentBytes: number; receivedBytes: number; recorded: number };\n}\n\n/** One WebSocket frame. At most `WS_MAX_MESSAGES_PER_SOCKET` are recorded per connection per page load. */\nexport interface WebSocketMessage {\n /** The `NetworkRequest.id` of the connection. */\n socketId: string;\n dir: \"send\" | \"recv\";\n time: number;\n /** Bytes (UTF-8 length for text frames). */\n size: number;\n binary?: boolean;\n /** Only with `recordNetworkPayloads`: text ≤ 2KB (JSON with sensitive keys masked), else `[truncated]`; binary frames are `[binary <n> B]`. */\n data?: string;\n}\n\nexport interface NetworkPluginPayload {\n requests?: NetworkRequest[];\n messages?: WebSocketMessage[];\n /** Requests/frames dropped since the previous payload because a cap was reached. */\n dropped?: { requests?: number; messages?: number };\n}\n\nexport const WS_MAX_MESSAGES_PER_SOCKET = 200;\nexport const WS_MAX_MESSAGE_BYTES = 2048;\n\n/** Header names always replaced with `[redacted]` when payload capture is on. */\nexport const SENSITIVE_HEADER_PATTERN = /^(authorization|proxy-authorization|cookie|set-cookie|x-api-key|x-auth-token|x-csrf-token|x-xsrf-token|x-guidely-key|x-guidely-conversation)$/i;\n\n/** Query parameter and JSON field names whose values are redacted. */\nexport const SENSITIVE_PARAM_PATTERN = /(token|key|secret|password|passwd|pwd|auth|session|code|sig|signature|credential|ssn|card|cvv|iban)/i;\n","import { GuideConfigSchema, type GuideConfigInput, type GuideKind } from \"./guide\";\n\nexport interface GuideTemplate {\n id: string;\n name: string;\n description: string;\n kind: GuideKind;\n category: \"onboarding\" | \"feature\" | \"setup\" | \"forms\" | \"announcement\" | \"help\" | \"feedback\";\n config: GuideConfigInput;\n}\n\nconst nav = (opts: { last?: boolean; first?: boolean } = {}) =>\n [\n ...(opts.first ? [] : [{ id: \"back\", label: \"Back\", action: \"back\" as const, variant: \"ghost\" as const }]),\n opts.last\n ? { id: \"done\", label: \"Finish\", action: \"complete\" as const, variant: \"primary\" as const }\n : { id: \"next\", label: \"Next\", action: \"next\" as const, variant: \"primary\" as const },\n ];\n\nexport const GUIDE_TEMPLATES: GuideTemplate[] = [\n {\n id: \"new-user-onboarding\",\n name: \"New-user onboarding tour\",\n description: \"A welcome modal followed by three anchored steps that introduce the main navigation.\",\n kind: \"flow\",\n category: \"onboarding\",\n config: {\n steps: [\n { id: \"welcome\", type: \"modal\", title: \"Welcome aboard 👋\", body: \"<p>We'll show you around in under a minute. You can skip at any time.</p>\", showOverlay: true, buttons: [{ id: \"skip\", label: \"Skip tour\", action: \"dismiss\", variant: \"ghost\" }, { id: \"start\", label: \"Show me around\", action: \"next\" }] },\n { id: \"nav\", type: \"tooltip\", title: \"Your navigation\", body: \"<p>Everything lives in the sidebar. Switch between dashboards, contacts and settings here.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='sidebar']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"right\", buttons: nav() },\n { id: \"create\", type: \"spotlight\", title: \"Create your first record\", body: \"<p>Use the primary button to add something new. We'll highlight it for you.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='primary-action']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", showOverlay: true, buttons: nav() },\n { id: \"help\", type: \"tooltip\", title: \"Need help later?\", body: \"<p>Open the help menu any time to replay this tour or browse the resource center.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='help']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", buttons: nav({ last: true }) },\n ],\n trigger: { type: \"page_load\" },\n frequency: { mode: \"once\", priority: 10 },\n targeting: { id: \"root\", op: \"and\", rules: [{ id: \"r1\", field: \"visitor.firstVisit\", op: \"is_true\" }] },\n },\n },\n {\n id: \"feature-discovery\",\n name: \"First-time feature discovery\",\n description: \"A hotspot that draws attention to a new capability and expands into a tooltip.\",\n kind: \"tooltip\",\n category: \"feature\",\n config: {\n steps: [{ id: \"hotspot\", type: \"hotspot\", title: \"New: smart filters\", body: \"<p>Filters now understand natural language. Try <em>“deals closing this month”</em>.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='filters']\" }], waitMs: 8000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", buttons: [{ id: \"got-it\", label: \"Got it\", action: \"complete\" }], hotspot: { size: 14, pulse: true, openOn: \"click\" }, showProgress: false }],\n trigger: { type: \"element_visible\", value: \"[data-tour='filters']\" },\n frequency: { mode: \"once\", maxImpressions: 3, priority: 50 },\n },\n },\n {\n id: \"setup-wizard\",\n name: \"Setup wizard\",\n description: \"Multi-step modal wizard that walks a new admin through initial configuration with branching.\",\n kind: \"flow\",\n category: \"setup\",\n config: {\n steps: [\n { id: \"intro\", type: \"modal\", title: \"Let's set up your workspace\", body: \"<p>Three quick steps: invite your team, connect a data source, and choose a plan.</p>\", showOverlay: true, buttons: [{ id: \"later\", label: \"Later\", action: \"dismiss\", variant: \"ghost\" }, { id: \"go\", label: \"Start setup\", action: \"next\" }] },\n { id: \"team\", type: \"popover\", title: \"Invite teammates\", body: \"<p>Guidely works best with your whole team. Add a few emails here.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='invite']\" }], waitMs: 5000, fallback: \"show_as_modal\", scrollIntoView: true }, buttons: nav() },\n { id: \"data\", type: \"popover\", title: \"Connect a data source\", body: \"<p>Import contacts from a CSV or connect your CRM.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='import']\" }], waitMs: 5000, fallback: \"show_as_modal\", scrollIntoView: true }, buttons: nav() },\n { id: \"done\", type: \"modal\", title: \"You're ready 🎉\", body: \"<p>That's it. Explore the dashboard, and open the help menu if you get stuck.</p>\", showOverlay: true, buttons: nav({ last: true }) },\n ],\n trigger: { type: \"page_load\", urlPattern: \"/dashboard\" },\n frequency: { mode: \"once\", priority: 20 },\n targeting: { id: \"root\", op: \"and\", rules: [{ id: \"r1\", field: \"user.role\", op: \"equals\", value: \"admin\" }] },\n },\n },\n {\n id: \"form-completion\",\n name: \"Form completion helper\",\n description: \"Tooltips that advance as the user fills out each field of a form.\",\n kind: \"flow\",\n category: \"forms\",\n config: {\n steps: [\n { id: \"name\", type: \"tooltip\", title: \"Name the contact\", body: \"<p>Use their full name so search works well.</p>\", target: { selectors: [{ kind: \"css\", value: \"input[name='name']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"right\", advanceOn: \"element_click\", advanceValue: \"input[name='email']\", buttons: [] },\n { id: \"email\", type: \"tooltip\", title: \"Add an email\", body: \"<p>We'll use it for sequences and reminders.</p>\", target: { selectors: [{ kind: \"css\", value: \"input[name='email']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"right\", buttons: nav() },\n { id: \"save\", type: \"spotlight\", title: \"Save\", body: \"<p>Hit save, and your contact appears in the list.</p>\", target: { selectors: [{ kind: \"css\", value: \"button[type='submit']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"top\", showOverlay: true, buttons: nav({ last: true }) },\n ],\n trigger: { type: \"url_match\", value: \"/contacts/new\" },\n frequency: { mode: \"once\", priority: 40 },\n },\n },\n {\n id: \"workflow-walkthrough\",\n name: \"Complex workflow walkthrough\",\n description: \"A multi-page flow that follows the user across routes with URL-aware steps.\",\n kind: \"flow\",\n category: \"onboarding\",\n config: {\n steps: [\n { id: \"start\", type: \"modal\", title: \"Close your first deal\", body: \"<p>We'll go from pipeline to closed-won in four steps.</p>\", showOverlay: true, buttons: [{ id: \"skip\", label: \"Not now\", action: \"dismiss\", variant: \"ghost\" }, { id: \"next\", label: \"Let's go\", action: \"next\" }] },\n { id: \"pipeline\", type: \"tooltip\", title: \"Open the pipeline\", body: \"<p>Click here to see your deals by stage.</p>\", url: \"/dashboard\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='nav-deals']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"right\", advanceOn: \"element_click\", advanceValue: \"[data-tour='nav-deals']\", buttons: [] },\n { id: \"drag\", type: \"spotlight\", title: \"Move a deal\", body: \"<p>Drag a card to the next stage, or use the stage menu.</p>\", url: \"/deals\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='deal-card']\" }], waitMs: 8000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", showOverlay: true, buttons: nav() },\n { id: \"won\", type: \"tooltip\", title: \"Mark as won\", body: \"<p>When it closes, mark it won to update your forecast.</p>\", url: \"/deals\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='mark-won']\" }], waitMs: 8000, fallback: \"skip\", scrollIntoView: true }, placement: \"left\", buttons: nav({ last: true }) },\n ],\n trigger: { type: \"manual\" },\n frequency: { mode: \"every_time\", priority: 30 },\n },\n },\n {\n id: \"feature-announcement\",\n name: \"New feature announcement\",\n description: \"A centered modal with an image announcing a new capability.\",\n kind: \"announcement\",\n category: \"announcement\",\n config: {\n steps: [{ id: \"announce\", type: \"modal\", title: \"Introducing Reports 2.0\", body: \"<p>Build custom reports with drag-and-drop metrics, scheduled emails and shareable links.</p><ul><li>12 new chart types</li><li>Export to CSV and PDF</li></ul>\", imageUrl: \"https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=800&q=60\", showOverlay: true, buttons: [{ id: \"later\", label: \"Maybe later\", action: \"dismiss\", variant: \"ghost\" }, { id: \"try\", label: \"Try it now\", action: \"url\", value: \"/reports\" }], showProgress: false }],\n trigger: { type: \"page_load\", delayMs: 1500 },\n frequency: { mode: \"once\", priority: 60 },\n },\n },\n {\n id: \"contextual-tooltip\",\n name: \"Contextual tooltip\",\n description: \"A single tooltip that appears when a specific element becomes visible.\",\n kind: \"tooltip\",\n category: \"help\",\n config: {\n steps: [{ id: \"tip\", type: \"tooltip\", title: \"Pro tip\", body: \"<p>Press <strong>⌘K</strong> to jump anywhere.</p>\", target: { selectors: [{ kind: \"data-attr\", value: \"[data-tour='search']\" }], waitMs: 5000, fallback: \"skip\", scrollIntoView: true }, placement: \"bottom\", buttons: [{ id: \"ok\", label: \"Got it\", action: \"complete\" }], showProgress: false }],\n trigger: { type: \"element_visible\", value: \"[data-tour='search']\", delayMs: 500 },\n frequency: { mode: \"once\", priority: 80 },\n },\n },\n {\n id: \"product-update-banner\",\n name: \"Product update notification\",\n description: \"A dismissible top banner linking to release notes.\",\n kind: \"banner\",\n category: \"announcement\",\n config: {\n steps: [{ id: \"banner\", type: \"banner\", title: \"\", body: \"<p><strong>Scheduled maintenance</strong> on Saturday 02:00–03:00 UTC. <a href='/status'>Read more</a>.</p>\", position: \"top\", placement: \"top\", buttons: [{ id: \"dismiss\", label: \"Dismiss\", action: \"dismiss\", variant: \"ghost\" }], showProgress: false }],\n trigger: { type: \"page_load\" },\n frequency: { mode: \"once_per_session\", priority: 90 },\n },\n },\n {\n id: \"onboarding-checklist\",\n name: \"User onboarding checklist\",\n description: \"A persistent checklist with four tasks that complete automatically from events.\",\n kind: \"checklist\",\n category: \"onboarding\",\n config: {\n steps: [],\n checklist: {\n tasks: [\n { id: \"profile\", title: \"Complete your profile\", description: \"Add a photo and your role.\", completion: \"event\", completionValue: \"profile_completed\", action: \"url\", actionValue: \"/settings/profile\" },\n { id: \"contact\", title: \"Add your first contact\", description: \"Import or create a contact.\", completion: \"event\", completionValue: \"contact_created\", action: \"url\", actionValue: \"/contacts/new\" },\n { id: \"deal\", title: \"Create a deal\", description: \"Track your first opportunity.\", completion: \"event\", completionValue: \"deal_created\", action: \"url\", actionValue: \"/deals\" },\n { id: \"tour\", title: \"Take the product tour\", description: \"A 60-second walkthrough.\", completion: \"guide_completed\", completionValue: \"new-user-onboarding\", action: \"start_guide\", actionValue: \"new-user-onboarding\", required: false },\n ],\n ordered: false,\n launcherLabel: \"Getting started\",\n position: \"bottom-right\",\n completionTitle: \"You're all set! 🎉\",\n completionBody: \"You've completed onboarding. Explore the rest of the app at your own pace.\",\n autoOpen: true,\n dismissible: true,\n },\n trigger: { type: \"page_load\" },\n frequency: { mode: \"every_time\", priority: 200 },\n },\n },\n {\n id: \"nps-survey\",\n name: \"NPS survey\",\n description: \"Net Promoter Score with a conditional follow-up question.\",\n kind: \"survey\",\n category: \"feedback\",\n config: {\n steps: [],\n survey: {\n questions: [\n { id: \"nps\", type: \"nps\", title: \"How likely are you to recommend us to a colleague?\", lowLabel: \"Not likely\", highLabel: \"Very likely\" },\n { id: \"why-low\", type: \"text\", title: \"What could we do better?\", required: false, placeholder: \"Tell us more…\", showWhen: { questionId: \"nps\", op: \"lte\", value: 6 } },\n { id: \"why-high\", type: \"text\", title: \"What do you like most?\", required: false, placeholder: \"Tell us more…\", showWhen: { questionId: \"nps\", op: \"gte\", value: 9 } },\n ],\n position: \"bottom-right\",\n },\n trigger: { type: \"page_load\", delayMs: 5000 },\n frequency: { mode: \"interval\", intervalHours: 2160, priority: 150 },\n targeting: { id: \"root\", op: \"and\", rules: [{ id: \"r1\", field: \"visitor.returning\", op: \"is_true\" }] },\n },\n },\n];\n\nexport function templateConfig(id: string) {\n const t = GUIDE_TEMPLATES.find((x) => x.id === id);\n if (!t) return null;\n return { template: t, config: GuideConfigSchema.parse(t.config) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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