{"version":3,"file":"ops.mjs","names":["id","planExposeProperty","planRenameExposure","planRetargetExposure","planRemoveExposure","planRemoveExposedSlot","planAddVariant","planRenameVariant","planDeleteVariant","planSetVariantValue","planResetVariantValue"],"sources":["../src/composition-actions.ts","../src/bindings/binding-ops.ts","../src/conditions/condition-ops.ts","../src/template-actions.ts"],"sourcesContent":["/**\n * The composition actions as data: what an API client, a script or an agent\n * sends to change a page or a component's definition, with the schema that\n * judges it and, for a definition, the planner each edit is.\n *\n * Published from the server-safe `ops` subpath beside the ops themselves,\n * because an action is the request form of an edit the editor already makes.\n * The page builder's routes parse their bodies with these schemas, so a client\n * that validates against them is refused for exactly what the server refuses,\n * and an agent that registers them as tool inputs offers the same actions the\n * routes take. `z.toJSONSchema(schema, { io: \"input\" })` gives their JSON\n * Schema form, which the page builder's manifest carries.\n *\n * A definition edit is pure: {@link planDefinitionAction} runs the editor's\n * own planner over a definition, so the edit a client previews offline is the\n * edit the server would make. A page action needs the stored page, the pattern\n * it copies and the caller's rights, so it is planned by the route.\n *\n * @experimental Settles when the composition API ships.\n * @module composition-actions\n */\nimport {\n  planAddVariant,\n  planDeleteVariant,\n  planExposeProperty,\n  planRemoveExposedSlot,\n  planRemoveExposure,\n  planRenameExposure,\n  planRenameVariant,\n  planResetVariantValue,\n  planRetargetExposure,\n  planSetVariantValue,\n  type BlockDocument,\n  type DocumentLimits,\n  type ExposureEditResult,\n  type ExposureSources,\n  type ExposureTarget,\n  BINDING_SOURCES,\n  CONDITION_MAX,\n  CONDITION_OPS,\n  isPlainRecord,\n  type Binding,\n  type BindingFormat,\n  LIST_FILTER_OPS,\n  type ConditionOp,\n  type ListFilter,\n  type ListRelation,\n  type OpPosition,\n  type RetiredExposures,\n  type VariantEditResult,\n} from \"@nextlyhq/blocks-engine\";\nimport { z } from \"zod\";\n\n/** Where on the page an inserted block goes; the end of the page when absent. */\nexport type ActionPosition = OpPosition;\n\n/**\n * One action on a stored page.\n *\n * @experimental Settles when the composition API ships.\n */\nexport type PageAction =\n  /** Insert a published pattern's blocks, copied, as the editor's insert panel does. */\n  | {\n      readonly kind: \"insert-pattern\";\n      readonly patternId: string;\n      readonly at?: ActionPosition;\n    }\n  /** Place a component by reference, optionally choosing a variant and values. */\n  | {\n      readonly kind: \"place-component\";\n      readonly componentId: string;\n      readonly variant?: string;\n      readonly values?: Readonly<Record<string, unknown>>;\n      readonly at?: ActionPosition;\n    }\n  /**\n   * Set a placement's exposed values, keyed by exposure id. `{ \"$unset\": true }`\n   * empties a field (\"Cleared\"); `reset` returns fields to what the variant or\n   * the definition gives them.\n   */\n  | {\n      readonly kind: \"set-placement-values\";\n      readonly instanceId: string;\n      readonly values?: Readonly<Record<string, unknown>>;\n      readonly reset?: readonly string[];\n    }\n  /** Choose a placement's variant by its stable id, or `null` for the defaults. */\n  | {\n      readonly kind: \"choose-variant\";\n      readonly instanceId: string;\n      readonly variant: string | null;\n    }\n  /**\n   * Change a collection list's query: its source, filters, sort, limit and\n   * offset, each part set when given, removed when `null`, and kept as\n   * stored when absent. The write is judged as an editor save is, so a limit\n   * outside 1 to 100, a negative offset, a field the collection lacks or\n   * visitors can't see, a related list nested too deep, and a split into\n   * pages a page cannot serve are refused.\n   */\n  | {\n      readonly kind: \"set-list-query\";\n      readonly listId: string;\n      readonly query: ListQueryChange;\n    }\n  /**\n   * Set a block's visibility conditions: an OR of AND groups of\n   * `{ field, op, value? }`, or `null` to show it to everyone. The write is\n   * judged as an editor save is, so an operator conditions do not have, a\n   * field the entry or list item lacks or visitors can't see, and a value\n   * its field does not take are refused. The devices a block shows on are\n   * kept.\n   */\n  | {\n      readonly kind: \"set-conditions\";\n      readonly nodeId: string;\n      readonly conditions: readonly (readonly ConditionInput[])[] | null;\n    }\n  /**\n   * Bind a block's prop to a field: `binding` as a block stores it (`$bind`,\n   * its `source`, a Single's `sourceKey`, and a `fallback` or `format`). The\n   * write is judged as an editor save is, so a prop the block lacks, a field\n   * its source lacks, a type that does not fit and a fallback the prop can't\n   * hold are refused.\n   */\n  | {\n      readonly kind: \"bind-prop\";\n      readonly nodeId: string;\n      readonly prop: string;\n      readonly binding: Binding;\n    }\n  /**\n   * Unbind a block's prop, keeping a value in its place. By default the value\n   * a visitor sees now, resolved on the server from the published page with\n   * the public's access; `{ entry }` or `{ item }` names the entry or list\n   * item whose value to keep, read the same way; `{ value }` supplies it. A\n   * value a visitor can't see is never copied in: the fallback, or the prop's\n   * own value, is kept instead, and the answer says which and why.\n   */\n  | {\n      readonly kind: \"unbind-prop\";\n      readonly nodeId: string;\n      readonly prop: string;\n      readonly keep?: UnbindKeep;\n    }\n  /**\n   * Choose the page's Layout: a Layout's id, or `null` for the site's default.\n   * `noHeaderFooter: true` switches the Layout off for this page; absent, it\n   * is turned back on, as choosing a Layout in the editor does.\n   */\n  | {\n      readonly kind: \"set-layout\";\n      readonly layout: string | null;\n      readonly noHeaderFooter?: boolean;\n    }\n  /**\n   * Place an Entry content block on a template, where the entry's own blocks\n   * content is drawn: `field` names the top-level blocks field of the\n   * template's collection it draws. Absent, the collection's one blocks\n   * field where it has one; where it has several the write is refused\n   * until one is named. A second one, one on any document but a template,\n   * and a field the collection lacks are refused as an editor save is.\n   *\n   * @experimental Settles when collection templates ship.\n   */\n  | {\n      readonly kind: \"place-entry-content\";\n      readonly field?: string;\n      readonly at?: OpPosition;\n    }\n  /**\n   * Choose the blocks field the template's Entry content block draws,\n   * judged as an editor save is.\n   *\n   * @experimental Settles when collection templates ship.\n   */\n  | {\n      readonly kind: \"set-entry-content-field\";\n      readonly nodeId: string;\n      readonly field: string;\n    };\n\n/**\n * Which value an `unbind-prop` action keeps: the visitor's, as the page shows\n * it now (the default); that of a named entry or list item, read as a visitor\n * reads it; or a value the caller supplies.\n *\n * @experimental Settles when the composition API ships.\n */\nexport type UnbindKeep =\n  | \"visitor\"\n  | { readonly entry: string }\n  | { readonly item: string }\n  | { readonly value: unknown };\n\n/**\n * What an unbind kept in a prop's place and why, as the one unbind decision\n * answers the page actions API and the inspector alike.\n *\n * @experimental Settles when the composition API ships.\n */\nexport interface UnbindAnswer {\n  /**\n   * What was kept: what a visitor sees now, the binding's fallback, the\n   * prop's own value, or a value the caller gave.\n   */\n  readonly kept: \"visitor\" | \"fallback\" | \"own\" | \"value\";\n  /** The value kept; absent when the prop keeps its own. */\n  readonly value?: unknown;\n  /** The prop an image's address was kept in, where the bound prop could not hold it. */\n  readonly into?: string;\n  /**\n   * Set where the binding read a field visitors can't read: its value was\n   * not copied in, and the fallback or the prop's own value was kept.\n   */\n  readonly unreadable?: true;\n  /**\n   * Set where the unbound prop is a link's entry id, bound to a related\n   * entry: the id visitors saw is kept beside the link's collection, so the\n   * link keeps going to that entry's page, by reference. Its title where a\n   * visitor may read it.\n   */\n  readonly entry?: { readonly title?: string };\n  /** Why, in words an author reads. */\n  readonly reason: string;\n}\n\n/**\n * The parts of a collection list's query a `set-list-query` action changes:\n * each one set when given, removed when `null`, kept when absent. Shaped as\n * the block stores them (`ListQuery` in the engine reads them back).\n *\n * @experimental Settles when the composition API ships.\n */\nexport interface ListQueryChange {\n  /** The collection read, or the one a related source's entries are in. */\n  readonly collection?: string | null;\n  /** A to-many relation of the page's entry or of the outer list's item. */\n  readonly relation?: ListRelation | null;\n  /** Rows an entry must all meet. */\n  readonly filters?: readonly ListFilter[] | null;\n  /** Sort keys, comma-separated, `-` for descending: `-publishedAt,title`. */\n  readonly sort?: string | null;\n  /** How many entries to show, 1 to 100. */\n  readonly limit?: number | null;\n  /** How many matching entries to skip, from 0. */\n  readonly offset?: number | null;\n  /**\n   * Split into pages of `limit` entries, each at its own address\n   * (`/news/page/2`). One list on a page may be, and not one inside another\n   * list, one showing related entries, or one in a component or a Layout\n   * region; the write is refused naming the reason.\n   */\n  readonly paginate?: boolean | null;\n  /**\n   * A custom source: a named query the site registers, and one literal per\n   * input set. Choosing one removes the collection, related entries, filters\n   * and sort in the same write; inputs are replaced whole, not merged.\n   */\n  readonly namedQuery?: {\n    readonly name: string;\n    readonly params?: Readonly<Record<string, string | number | boolean>>;\n  } | null;\n}\n\n/**\n * One condition a `set-conditions` action sets, as a block stores it.\n *\n * @experimental Settles when the composition API ships.\n */\nexport interface ConditionInput {\n  readonly field: string;\n  readonly op: ConditionOp;\n  readonly value?: string | number | boolean;\n}\n\n/** Which part of a block an exposure targets: a prop, or its visibility. */\nexport type ExposureTargetInput =\n  | { readonly nodeId: string; readonly propPath: string }\n  | { readonly nodeId: string; readonly visibility: true };\n\n/**\n * One edit to a component's definition, each the editor's own planner.\n *\n * @experimental Settles when the composition API ships.\n */\nexport type DefinitionAction =\n  | ({ readonly kind: \"expose\"; readonly label: string } & ExposureTargetInput)\n  | {\n      readonly kind: \"rename-exposure\";\n      readonly exposureId: string;\n      readonly label: string;\n    }\n  | ({\n      readonly kind: \"retarget-exposure\";\n      readonly exposureId: string;\n    } & ExposureTargetInput)\n  | { readonly kind: \"remove-exposure\"; readonly exposureId: string }\n  | { readonly kind: \"remove-exposed-slot\"; readonly slotId: string }\n  | { readonly kind: \"add-variant\"; readonly label: string }\n  | {\n      readonly kind: \"rename-variant\";\n      readonly variantId: string;\n      readonly label: string;\n    }\n  | { readonly kind: \"delete-variant\"; readonly variantId: string }\n  | {\n      readonly kind: \"set-variant-value\";\n      readonly variantId: string;\n      readonly exposureId: string;\n      readonly value: unknown;\n    }\n  | {\n      readonly kind: \"reset-variant-value\";\n      readonly variantId: string;\n      readonly exposureId: string;\n    };\n\nconst id = z.string().min(1).max(512);\n\n/**\n * A binding's format: a plain object, judged by a function. Named so the JSON\n * Schema form can state it as an object rather than as any value.\n */\nconst bindingFormatSchema = z.custom<BindingFormat>(value =>\n  isPlainRecord(value)\n);\n\n/** A binding as a block stores it; whether it fits is the write's to judge. */\nconst bindingShape = {\n  $bind: z.string().min(1).max(512),\n  fallback: z.unknown().optional(),\n  format: bindingFormatSchema.optional(),\n};\nconst bindingSchema: z.ZodType<Binding> = z.union([\n  z.strictObject({\n    ...bindingShape,\n    source: z\n      .enum(\n        BINDING_SOURCES.filter(source => source !== \"single\") as [\n          \"entry\",\n          \"item\",\n          \"site\",\n        ]\n      )\n      .optional(),\n    // The enclosing list an item binding reads; the write judges that it\n    // is one, around the block.\n    list: id.optional(),\n  }),\n  z.strictObject({\n    ...bindingShape,\n    source: z.literal(\"single\"),\n    sourceKey: id,\n  }),\n]);\n\nconst unbindKeepSchema: z.ZodType<UnbindKeep> = z.union([\n  z.literal(\"visitor\"),\n  z.strictObject({ entry: id }),\n  z.strictObject({ item: id }),\n  // A value given, never an empty object read as \"keep nothing\".\n  z.strictObject({\n    value: z.custom<unknown>(value => value !== undefined),\n  }),\n]);\nconst label = z.string().max(200);\nconst position = z.union([\n  z.strictObject({ index: z.number().int().nonnegative() }),\n  z.strictObject({\n    parentId: id,\n    slot: id,\n    index: z.number().int().nonnegative(),\n  }),\n]);\nconst values = z.record(z.string().max(512), z.unknown());\nconst filterScalar = z.union([z.string().max(2048), z.number(), z.boolean()]);\n\n/**\n * Each page action's shape, once: the schema is their union, and the kinds a\n * client is told about are read off them, so the two cannot disagree.\n */\nconst pageActionOptions = [\n  z.strictObject({\n    kind: z.literal(\"insert-pattern\"),\n    patternId: id,\n    at: position.optional(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"place-component\"),\n    componentId: id,\n    variant: id.optional(),\n    values: values.optional(),\n    at: position.optional(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"set-placement-values\"),\n    instanceId: id,\n    values: values.optional(),\n    reset: z.array(z.string().max(512)).max(200).optional(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"choose-variant\"),\n    instanceId: id,\n    variant: id.nullable(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"set-list-query\"),\n    listId: id,\n    // The shape the block stores, and no more: what each part may hold (the\n    // bounds, a field the collection has and visitors may read, how deep\n    // related lists go) is the page's blocks field to judge on the write, so\n    // a client is refused in the editor's own words, not by a second set here.\n    query: z.strictObject({\n      collection: z.string().max(512).nullable().optional(),\n      relation: z\n        .strictObject({ of: z.enum([\"entry\", \"item\"]), field: id })\n        .nullable()\n        .optional(),\n      filters: z\n        .array(\n          z.strictObject({\n            field: id,\n            op: z.enum(LIST_FILTER_OPS),\n            value: z.union([filterScalar, z.array(filterScalar).max(200)]),\n          })\n        )\n        .max(100)\n        .nullable()\n        .optional(),\n      sort: z.string().max(2048).nullable().optional(),\n      // The shape only: whether the query exists and its inputs fit it is\n      // the blocks field's to judge, in the editor's words.\n      namedQuery: z\n        .strictObject({\n          name: z.string().max(64),\n          params: z\n            .record(id, z.union([z.string().max(200), z.number(), z.boolean()]))\n            .optional(),\n        })\n        .nullable()\n        .optional(),\n      limit: z.number().nullable().optional(),\n      offset: z.number().nullable().optional(),\n      paginate: z.boolean().nullable().optional(),\n    }),\n  }),\n  z.strictObject({\n    kind: z.literal(\"set-conditions\"),\n    nodeId: id,\n    // The shape a block stores, in the operators' own spellings, and no\n    // more: whether a field fits its entry, visitors may read it, or a value\n    // fits it is the page's blocks field to judge on the write, in the\n    // editor's own words.\n    conditions: z\n      .array(\n        z\n          .array(\n            z.strictObject({\n              field: id,\n              op: z.enum(CONDITION_OPS),\n              value: filterScalar.optional(),\n            })\n          )\n          .max(CONDITION_MAX)\n      )\n      .max(CONDITION_MAX)\n      .nullable(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"bind-prop\"),\n    nodeId: id,\n    prop: id,\n    binding: bindingSchema,\n  }),\n  z.strictObject({\n    kind: z.literal(\"unbind-prop\"),\n    nodeId: id,\n    prop: id,\n    keep: unbindKeepSchema.optional(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"set-layout\"),\n    layout: id.nullable(),\n    noHeaderFooter: z.boolean().optional(),\n  }),\n  // A field is named by its name; whether the template's collection has it\n  // as a top-level blocks field is the blocks field's to judge on the write.\n  z.strictObject({\n    kind: z.literal(\"place-entry-content\"),\n    field: id.optional(),\n    at: position.optional(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"set-entry-content-field\"),\n    nodeId: id,\n    field: id,\n  }),\n] as const;\n\n/**\n * A page action, as the page actions route reads `action`.\n *\n * @experimental Settles when the composition API ships.\n */\nexport const pageActionSchema: z.ZodType<PageAction> = z.discriminatedUnion(\n  \"kind\",\n  pageActionOptions\n);\n\n/** Every page action's `kind`, in the order the schema lists them. */\nexport const PAGE_ACTION_KINDS: readonly PageAction[\"kind\"][] =\n  pageActionOptions.map(option => option.shape.kind.value);\n\n/**\n * A prop path or the visibility switch. Both are optional in the shape, so\n * that naming both, or neither, is refused in words rather than as a union\n * that matched nothing.\n */\nconst target = {\n  nodeId: id,\n  propPath: z\n    .string()\n    .min(1)\n    .max(512)\n    .optional()\n    .describe(\"The prop to expose. Send this or `visibility`, not both.\"),\n  visibility: z\n    .literal(true)\n    .optional()\n    .describe(\"Expose whether the block shows. Send this or `propPath`.\"),\n};\n\n/** Refuse a target naming both a prop and the visibility switch, or neither. */\nfunction oneTarget(\n  value: { propPath?: string | undefined; visibility?: true | undefined },\n  ctx: z.RefinementCtx\n): void {\n  if ((value.propPath === undefined) !== (value.visibility === undefined))\n    return;\n  ctx.addIssue({\n    code: \"custom\",\n    path: [\"propPath\"],\n    message:\n      \"Name the field to expose by `propPath`, or `visibility: true`, but not both.\",\n  });\n}\n\n/** Each definition action's shape, once, for the reason the page actions' are. */\nconst definitionActionOptions = [\n  z\n    .strictObject({ kind: z.literal(\"expose\"), label, ...target })\n    .superRefine(oneTarget),\n  z.strictObject({\n    kind: z.literal(\"rename-exposure\"),\n    exposureId: id,\n    label,\n  }),\n  z\n    .strictObject({\n      kind: z.literal(\"retarget-exposure\"),\n      exposureId: id,\n      ...target,\n    })\n    .superRefine(oneTarget),\n  z.strictObject({ kind: z.literal(\"remove-exposure\"), exposureId: id }),\n  z.strictObject({ kind: z.literal(\"remove-exposed-slot\"), slotId: id }),\n  z.strictObject({ kind: z.literal(\"add-variant\"), label }),\n  z.strictObject({ kind: z.literal(\"rename-variant\"), variantId: id, label }),\n  z.strictObject({ kind: z.literal(\"delete-variant\"), variantId: id }),\n  z.strictObject({\n    kind: z.literal(\"set-variant-value\"),\n    variantId: id,\n    exposureId: id,\n    value: z.unknown(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"reset-variant-value\"),\n    variantId: id,\n    exposureId: id,\n  }),\n] as const;\n\n/**\n * A definition action, as the definition actions route reads `action`.\n *\n * @experimental Settles when the composition API ships.\n */\nexport const definitionActionSchema: z.ZodType<DefinitionAction> = z\n  .discriminatedUnion(\"kind\", definitionActionOptions)\n  .transform((parsed): DefinitionAction => {\n    // A target as the contract types it: exactly the one of the two it names,\n    // which the refinement above has already required.\n    if (parsed.kind !== \"expose\" && parsed.kind !== \"retarget-exposure\")\n      return parsed;\n    const { propPath, visibility: _visibility, ...rest } = parsed;\n    return propPath === undefined\n      ? { ...rest, visibility: true }\n      : { ...rest, propPath };\n  });\n\n/** Every definition action's `kind`, in the order the schema lists them. */\nexport const DEFINITION_ACTION_KINDS: readonly DefinitionAction[\"kind\"][] =\n  definitionActionOptions.map(option => option.shape.kind.value);\n\n/**\n * The JSON Schema form of a page action, as a client that does not run zod\n * reads it: the input the schema accepts, before the parse normalises it.\n *\n * A binding's `format` and an unbind's kept `value` are judged by a function,\n * which JSON Schema cannot state; the converter refuses such a schema outright\n * otherwise, and the manifest that carries this form with it. A format is\n * written as an object, which is what its function asks; a kept value as any\n * value (`{}`), since it may be any JSON. Each stays required where the action\n * requires it, and is judged by the route.\n *\n * @experimental Settles when the composition API ships.\n */\nexport function pageActionJsonSchema(): Record<string, unknown> {\n  return z.toJSONSchema(pageActionSchema, {\n    io: \"input\",\n    unrepresentable: \"any\",\n    override: ({ zodSchema, jsonSchema }) => {\n      if (zodSchema === bindingFormatSchema) jsonSchema.type = \"object\";\n    },\n  });\n}\n\n/**\n * The JSON Schema form of a definition action. The refinement that a target\n * names exactly one of `propPath` and `visibility` has no JSON Schema form of\n * its own, so it is written into each targeted action here: a tool that\n * validates against this schema refuses what the route refuses.\n *\n * @experimental Settles when the composition API ships.\n */\nexport function definitionActionJsonSchema(): Record<string, unknown> {\n  const schema: { oneOf?: Record<string, unknown>[] } = z.toJSONSchema(\n    definitionActionSchema,\n    { io: \"input\" }\n  );\n  return {\n    ...schema,\n    ...(schema.oneOf === undefined\n      ? {}\n      : { oneOf: schema.oneOf.map(withExactlyOneTarget) }),\n  };\n}\n\n/** The actions whose target is a prop or the visibility switch. */\nconst TARGETED_KINDS: ReadonlySet<unknown> = new Set([\n  \"expose\",\n  \"retarget-exposure\",\n]);\n\n/** One action's JSON Schema, requiring exactly one target where it takes one. */\nfunction withExactlyOneTarget(\n  option: Record<string, unknown>\n): Record<string, unknown> {\n  const properties = option.properties as\n    | { kind?: { const?: unknown } }\n    | undefined;\n  if (!TARGETED_KINDS.has(properties?.kind?.const)) return option;\n  return {\n    ...option,\n    oneOf: [\n      { required: [\"propPath\"], not: { required: [\"visibility\"] } },\n      { required: [\"visibility\"], not: { required: [\"propPath\"] } },\n    ],\n  };\n}\n\n/**\n * What a definition edit reads besides the definition.\n *\n * @experimental Settles when the composition API ships.\n */\nexport interface DefinitionActionSources {\n  /** The block definitions, for each prop's type and each slot's lock. */\n  readonly definitions: ExposureSources[\"definitions\"];\n  /** The ids the component has retired, never to be handed out again. */\n  readonly retired?: RetiredExposures;\n  /** The host's document limits, which its save judges the definition under. */\n  readonly limits?: DocumentLimits;\n}\n\n/**\n * Plan one definition edit with the editor's own planner: the edited\n * definition, or why the edit is refused. The definition passed in is never\n * changed.\n *\n * @experimental Settles when the composition API ships.\n */\nexport function planDefinitionAction(\n  definition: BlockDocument,\n  action: DefinitionAction,\n  sources: DefinitionActionSources\n): ExposureEditResult | VariantEditResult {\n  const { limits, retired } = sources;\n  const exposure: ExposureSources = {\n    definitions: sources.definitions,\n    ...(retired === undefined ? {} : { retired }),\n    ...(limits === undefined ? {} : { limits }),\n  };\n  switch (action.kind) {\n    case \"expose\":\n      return planExposeProperty(\n        definition,\n        { ...targetOf(action), label: action.label },\n        exposure\n      );\n    case \"rename-exposure\":\n      return planRenameExposure(\n        definition,\n        action.exposureId,\n        action.label,\n        limits\n      );\n    case \"retarget-exposure\":\n      return planRetargetExposure(\n        definition,\n        action.exposureId,\n        targetOf(action),\n        exposure\n      );\n    case \"remove-exposure\":\n      return planRemoveExposure(definition, action.exposureId, limits);\n    case \"remove-exposed-slot\":\n      return planRemoveExposedSlot(definition, action.slotId, limits);\n    case \"add-variant\":\n      return planAddVariant(\n        definition,\n        action.label,\n        limits === undefined ? {} : { limits }\n      );\n    case \"rename-variant\":\n      return planRenameVariant(\n        definition,\n        action.variantId,\n        action.label,\n        limits\n      );\n    case \"delete-variant\":\n      return planDeleteVariant(definition, action.variantId, limits);\n    case \"set-variant-value\":\n      return planSetVariantValue(\n        definition,\n        action.variantId,\n        action.exposureId,\n        action.value,\n        limits\n      );\n    case \"reset-variant-value\":\n      return planResetVariantValue(\n        definition,\n        action.variantId,\n        action.exposureId,\n        limits\n      );\n  }\n}\n\n/** An exposure's target, as the planners take it. */\nfunction targetOf(input: ExposureTargetInput): ExposureTarget {\n  return \"visibility\" in input\n    ? { nodeId: input.nodeId, visibility: true }\n    : { nodeId: input.nodeId, propPath: input.propPath };\n}\n","/**\n * The ops that bind a block's prop to a field and unbind it, for the\n * inspector's binding controls and the page actions API alike, so both write\n * a binding the one way.\n *\n * Neither decides whether the binding fits: the write is judged as any save\n * is, against the schema of what it reads. An unbind writes what the caller\n * resolved to keep (on the server, as a visitor sees it): the prop's value,\n * or for an image a visitor saw by its address, that address in the block's\n * declared address prop, the media prop then emptied.\n *\n * @module binding-ops\n */\nimport {\n  findNode,\n  isPlainRecord,\n  type Binding,\n  type BlockDocument,\n} from \"@nextlyhq/blocks-engine\";\n\nimport type { BuilderOp } from \"../op-vocabulary\";\n\n/** A node's bindings, as a fresh record; none when it has none. */\nfunction bindingsOf(node: {\n  readonly bindings?: Readonly<Record<string, Binding>>;\n}): Record<string, Binding> {\n  return node.bindings === undefined ? {} : { ...node.bindings };\n}\n\n/**\n * The op binding `prop` of block `id` to `binding`, replacing a binding the\n * prop already had; `null` when the document holds no such block.\n *\n * `clear` names props emptied in the same op, for a prop another prop would\n * win over once bound: a button's entry reference is followed before its\n * address, so binding the address alone would leave the button going to the\n * entry. Only props the block holds are named in the patch, so a bind with\n * nothing to clear writes the bindings alone.\n *\n * @experimental Settles with the editor's binding controls.\n */\nexport function bindOp(\n  document: BlockDocument,\n  id: string,\n  prop: string,\n  binding: Binding,\n  clear: readonly string[] = [],\n  more: {\n    /**\n     * Props set in the same edit: what the bound value needs beside it,\n     * such as the collection of the entry a link's bound id names.\n     */\n    readonly set?: Readonly<Record<string, unknown>>;\n    /**\n     * Other props' bindings removed in the same edit: one the block would\n     * follow before this one, such as a link's address bound before the\n     * entry it now points at.\n     */\n    readonly unbind?: readonly string[];\n  } = {}\n): BuilderOp | null {\n  const node = findNode(document.nodes, id);\n  if (node === undefined) return null;\n  const kept = Object.entries(bindingsOf(node)).filter(\n    ([name]) => name === prop || !(more.unbind ?? []).includes(name)\n  );\n  const bindings = { ...Object.fromEntries(kept), [prop]: binding };\n  const props: Record<string, unknown> = isPlainRecord(node.props)\n    ? { ...node.props }\n    : {};\n  const held = clear.filter(name => Object.hasOwn(props, name));\n  const setting = Object.entries(more.set ?? {});\n  if (held.length === 0 && setting.length === 0) {\n    return { kind: \"update\", id, patch: { bindings } };\n  }\n  for (const name of held) delete props[name];\n  for (const [name, value] of setting) {\n    // Defined rather than assigned, so a prop's name can't reach the\n    // prototype.\n    Object.defineProperty(props, name, {\n      value,\n      enumerable: true,\n      writable: true,\n      configurable: true,\n    });\n  }\n  return { kind: \"update\", id, patch: { bindings, props } };\n}\n\n/**\n * What an unbind keeps in the block's props: values to set, and props to\n * empty. For an image a visitor saw by its address, the address is set on\n * the declared address prop and the media prop emptied.\n *\n * @experimental Settles with the editor's binding controls.\n */\nexport interface KeptProps {\n  readonly set: Readonly<Record<string, unknown>>;\n  readonly empty?: readonly string[];\n}\n\n/**\n * The op unbinding `prop` of block `id`, keeping `kept` in its props; `null`\n * when the document holds no such block. A block left with no binding stores\n * none.\n *\n * @experimental Settles with the editor's binding controls.\n */\nexport function unbindOp(\n  document: BlockDocument,\n  id: string,\n  prop: string,\n  kept: KeptProps\n): BuilderOp | null {\n  const node = findNode(document.nodes, id);\n  if (node === undefined) return null;\n  const bindings = bindingsOf(node);\n  delete bindings[prop];\n  const props: Record<string, unknown> = {\n    ...(isPlainRecord(node.props) ? node.props : {}),\n    ...kept.set,\n  };\n  for (const name of kept.empty ?? []) delete props[name];\n  return Object.keys(bindings).length === 0\n    ? { kind: \"update\", id, patch: { props }, unset: [\"bindings\"] }\n    : { kind: \"update\", id, patch: { props, bindings } };\n}\n","/**\n * The op that sets a block's visibility conditions, for the editor's \"Show\n * when\" controls and the page actions API alike, so both write a block's\n * conditions the one way: the engine's `withConditions`, which keeps the\n * devices a block shows on and stores nothing for a block shown everywhere\n * to everyone.\n *\n * @module condition-ops\n */\nimport {\n  findNode,\n  withConditions,\n  type BlockDocument,\n  type Condition,\n} from \"@nextlyhq/blocks-engine\";\n\nimport type { BuilderOp } from \"../op-vocabulary\";\n\n/**\n * The op setting a block's conditions to `conditions`, an OR of AND groups;\n * `null` or no groups removes them. `null` when the document holds no such\n * block.\n *\n * @experimental Settles with the editor's condition controls.\n */\nexport function conditionsOp(\n  document: BlockDocument,\n  id: string,\n  conditions: readonly (readonly Condition[])[] | null\n): BuilderOp | null {\n  const node = findNode(document.nodes, id);\n  if (node === undefined) return null;\n  const next = withConditions(node.visibility, conditions ?? undefined);\n  return next === undefined\n    ? { kind: \"update\", id, patch: {}, unset: [\"visibility\"] }\n    : { kind: \"update\", id, patch: { visibility: next } };\n}\n","/**\n * The collection template actions as data: what an API client, a script or an\n * agent sends to give a collection its template, to publish it and to delete\n * it, and to give one entry a design of its own or take it away, with the\n * schema that judges it.\n *\n * Published from the `ops` subpath beside the composition actions, for the\n * same reason: the page builder's template route parses its bodies with this\n * schema, so a client that validates against it is refused for exactly what\n * the server refuses. What a template may be (which collections can have one,\n * and that a collection has at most one) is the server's to judge, so the\n * schema holds the request's shape and no more.\n *\n * @experimental Settles when collection templates ship.\n * @module template-actions\n */\nimport { z } from \"zod\";\n\n/**\n * One action on a collection's template.\n *\n * @experimental Settles when collection templates ship.\n */\nexport type TemplateAction =\n  /**\n   * Give a collection its template: an empty template document, saved as a\n   * draft unless `publish` is set. Refused when the collection already has\n   * one, naming it.\n   */\n  | {\n      readonly kind: \"create-template\";\n      /** The collection whose entries the template renders, by slug. */\n      readonly collection: string;\n      /** The template's name in the admin; the collection's name by default. */\n      readonly title?: string;\n      readonly publish?: boolean;\n    }\n  /** Publish a template, its working draft included, as the editor's Publish does. */\n  | {\n      readonly kind: \"publish-template\";\n      readonly id: string;\n    }\n  /**\n   * Give an entry its own design: a copy of its collection's published\n   * template, saved as a draft, so the entry keeps being drawn with the\n   * template until the copy is published. Refused when the collection has no\n   * published template, or the entry already has its own design.\n   */\n  | {\n      readonly kind: \"give-entry-design\";\n      /** The entry's collection, by slug. */\n      readonly collection: string;\n      /** The entry's id. */\n      readonly entry: string;\n      /** The own design's name in the admin; the entry's title by default. */\n      readonly title?: string;\n    }\n  /**\n   * Remove an entry's own design, so the entry is drawn with its\n   * collection's template again.\n   */\n  | {\n      readonly kind: \"remove-entry-design\";\n      readonly collection: string;\n      readonly entry: string;\n    }\n  /**\n   * Delete a template by id: a collection's template, after which the\n   * collection's entries without their own design are not shown as pages until\n   * it has a published template again, or an entry's own design, after which\n   * the entry is drawn with its collection's template. A dry run answers the\n   * template it would delete, so a client can say what that means first.\n   */\n  | {\n      readonly kind: \"delete-template\";\n      readonly id: string;\n    }\n  /**\n   * Set, change or (with `null`) remove the address a collection's entries\n   * are served at, stored on its template: for a collection created at\n   * runtime, whose address is not declared in code. Needs the routing\n   * permission (`manage-template-routing`) beside updating templates. A\n   * published template's entries move at once: their old addresses are\n   * freed, and each waits where its new one is held.\n   */\n  | {\n      readonly kind: \"set-template-address\";\n      readonly id: string;\n      /** A path such as `/blog`, in its one spelling, or `null` for none. */\n      readonly address: string | null;\n    };\n\nconst id = z.string().min(1).max(512);\n\n/**\n * Each template action's shape, once: the schema is their union, and the\n * kinds a client is told about are read off them, so the two cannot disagree.\n */\nconst templateActionOptions = [\n  z.strictObject({\n    kind: z.literal(\"create-template\"),\n    collection: id,\n    title: z.string().trim().min(1).max(255).optional(),\n    publish: z.boolean().optional(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"publish-template\"),\n    id,\n  }),\n  z.strictObject({\n    kind: z.literal(\"give-entry-design\"),\n    collection: id,\n    entry: id,\n    title: z.string().trim().min(1).max(255).optional(),\n  }),\n  z.strictObject({\n    kind: z.literal(\"remove-entry-design\"),\n    collection: id,\n    entry: id,\n  }),\n  z.strictObject({\n    kind: z.literal(\"delete-template\"),\n    id,\n  }),\n  z.strictObject({\n    kind: z.literal(\"set-template-address\"),\n    id,\n    // The address's form is the server's to judge, in its own words; the\n    // schema bounds its length only.\n    address: z.string().max(255).nullable(),\n  }),\n] as const;\n\n/**\n * A template action, as the template actions route reads `action`.\n *\n * @experimental Settles when collection templates ship.\n */\nexport const templateActionSchema: z.ZodType<TemplateAction> =\n  z.discriminatedUnion(\"kind\", templateActionOptions);\n\n/** Every template action's `kind`, in the order the schema lists them. */\nexport const TEMPLATE_ACTION_KINDS: readonly TemplateAction[\"kind\"][] =\n  templateActionOptions.map(option => option.shape.kind.value);\n\n/**\n * The JSON Schema form of a template action.\n *\n * @experimental Settles when collection templates ship.\n */\nexport function templateActionJsonSchema(): Record<string, unknown> {\n  return z.toJSONSchema(templateActionSchema, { io: \"input\" });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+TA,MAAMA,OAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;;;;;AAMpC,MAAM,sBAAsB,EAAE,QAAsB,UAClD,cAAc,KAAK,CACrB;;AAGA,MAAM,eAAe;CACnB,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG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