{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.zeropress.dev/wxr-import-base/v0.7/schema.json",
  "title": "ZeroPress WXR Import Base v0.7",
  "description": "Base preset for @zeropress/wxr-import. WXR-generated content and menus are not accepted in this file.",
  "type": "object",
  "additionalProperties": false,
  "required": ["version"],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Optional JSON Schema URI or path used by editors and tooling."
    },
    "version": {
      "const": "0.7",
      "description": "WXR Import Base contract version."
    },
    "site": {
      "$ref": "#/$defs/site"
    },
    "meta": {
      "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/previewMeta",
      "description": "Values copied unchanged to preview-data site.meta. Keys are not interpreted or reserved by the importer."
    },
    "comments": {
      "$ref": "#/$defs/comments"
    },
    "newsletter": {
      "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteNewsletter"
    },
    "widgets": {
      "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/widgets",
      "description": "Widget areas copied to preview-data. When omitted, the importer materializes its recommended sidebar defaults in preview-data and the resolved base. An explicit empty object disables that fallback, and any provided object is preserved without augmentation."
    },
    "collections": {
      "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/collections",
      "description": "Values copied to preview-data collections."
    },
    "custom_css": {
      "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/customCss",
      "description": "Canonical preview-data custom_css value."
    },
    "custom_html": {
      "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/customHtml",
      "description": "Trusted raw HTML strings copied to preview-data custom_html."
    },
    "import": {
      "$ref": "#/$defs/import"
    }
  },
  "$defs": {
    "site": {
      "type": "object",
      "description": "Closed set of values copied into preview-data site before WXR-derived defaults are applied. Configure meta, newsletter, and comments with their top-level base properties.",
      "additionalProperties": false,
      "properties": {
        "title": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/site/properties/title"
        },
        "description": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/site/properties/description"
        },
        "url": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteOrigin"
        },
        "media_origin": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/mediaOrigin",
          "description": "Optional explicit HTTP(S) media origin. An empty or omitted value keeps automatic inference enabled; inferred values are written to preview-data and report.inferred.media_origin, while the resolved base retains the empty auto sentinel.",
          "examples": ["", "https://media.example.com"]
        },
        "media_delivery_mode": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/site/properties/media_delivery_mode",
          "description": "Media delivery behavior copied to Preview Data. media_domain requires an explicit non-empty media_origin."
        },
        "favicon": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteFavicon"
        },
        "logo": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteLogo"
        },
        "expose_generator": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/site/properties/expose_generator"
        },
        "locale": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/locale"
        },
        "posts_per_page": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/site/properties/posts_per_page"
        },
        "date_style": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/site/properties/date_style"
        },
        "time_style": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/site/properties/time_style"
        },
        "timezone": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/timezone",
          "description": "Optional authoritative IANA time zone or canonical ±HH:MM offset. When omitted, the importer infers one fixed offset from trustworthy published Post/Page date pairs, falls back to UTC when inference is unavailable or ambiguous, and materializes the effective value in the resolved base.",
          "examples": ["UTC", "Asia/Seoul", "+09:00"]
        },
        "search": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteFeatureState"
        },
        "feed": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteFeatureState"
        },
        "archive": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteFeatureState"
        },
        "robots": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteRobots"
        },
        "permalinks": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/permalinks"
        },
        "front_page": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/frontPage"
        },
        "post_index": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/postIndex"
        },
        "footer": {
          "$ref": "https://schemas.zeropress.dev/preview-data/v0.7/schema.json#/$defs/siteFooter"
        }
      },
      "allOf": [
        {
          "if": {
            "required": ["media_delivery_mode"],
            "properties": {
              "media_delivery_mode": { "const": "media_domain" }
            }
          },
          "then": {
            "required": ["media_origin"],
            "properties": {
              "media_origin": { "type": "string", "minLength": 1 }
            }
          }
        }
      ]
    },
    "comments": {
      "type": "object",
      "description": "WordPress comment API configuration copied to preview-data site.comments. api_base_url is required when this block is present; omit the complete block to infer it from the WXR source URL. enabled defaults to true and all omitted optional fields are materialized in the resolved base.",
      "additionalProperties": false,
      "required": ["api_base_url"],
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "api_base_url": {
          "type": "string",
          "pattern": "^(?:[hH][tT][tT][pP][sS]?://(?:\\[[0-9A-Fa-f:.]+\\]|[^\\s\\\\/:?#@]+)(?::[0-9]+)?(?:/(?:[^\\s\\\\?#%]|%[0-9A-Fa-f]{2})*)?|/(?!/)(?:[^\\s\\\\?#%]|%[0-9A-Fa-f]{2})*)$",
          "description": "WordPress REST API base URL, normally ending in /wp-json/wp/v2. It may be an absolute HTTP(S) URL or a root-relative path and must not contain credentials, a query, or a fragment."
        },
        "provider": {
          "const": "wordpress",
          "default": "wordpress",
          "description": "The WXR bridge uses the WordPress comment provider."
        },
        "per_page": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 50
        },
        "order": {
          "type": "string",
          "enum": ["asc", "desc"],
          "default": "desc"
        },
        "threading": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": true
            },
            "max_depth": {
              "type": "integer",
              "minimum": 2,
              "maximum": 10,
              "default": 2
            }
          }
        }
      }
    },
    "import": {
      "type": "object",
      "additionalProperties": false,
      "dependentRequired": {
        "media_from": ["media_to"],
        "media_to": ["media_from"]
      },
      "properties": {
        "media_from": {
          "$ref": "#/$defs/mediaUrlPrefix",
          "description": "Original WordPress media URL prefix. When the pair is omitted, the importer may infer and seed an identity pair from safe WordPress attachment URLs."
        },
        "media_to": {
          "$ref": "#/$defs/mediaUrlPrefix",
          "description": "Replacement media URL prefix. A normalized value equal to media_from is allowed and disables runtime rewriting."
        }
      }
    },
    "mediaUrlPrefix": {
      "type": "string",
      "format": "uri",
      "minLength": 1,
      "pattern": "^[hH][tT][tT][pP][sS]?://\\S+$",
      "not": {
        "anyOf": [
          {
            "pattern": "^[hH][tT][tT][pP][sS]?://[^/?#]*@"
          },
          {
            "pattern": "[?#]"
          }
        ]
      },
      "description": "Absolute HTTP(S) URL prefix without credentials, query, or fragment. The importer normalizes it to a trailing slash."
    }
  },
  "examples": [
    {
      "$schema": "https://schemas.zeropress.dev/wxr-import-base/v0.7/schema.json",
      "version": "0.7",
      "site": {
        "title": "Imported Site",
        "url": "https://example.com",
        "locale": "en",
        "timezone": "UTC",
        "archive": {
          "enabled": false
        }
      },
      "comments": {
        "enabled": true,
        "api_base_url": "https://example.com/wp-json/wp/v2",
        "provider": "wordpress",
        "per_page": 50,
        "order": "desc",
        "threading": {
          "enabled": true,
          "max_depth": 2
        }
      },
      "import": {
        "media_from": "https://example.com/wp-content/uploads/",
        "media_to": "https://media.example.com/imported/"
      }
    }
  ]
}
