import { z } from "zod";
const SpecVerseResourceSchema = z.object({
  uri: z.string().min(1, "URI is required").regex(/^specverse:\/\//, "URI must start with specverse://"),
  name: z.string().min(1, "Name is required"),
  description: z.string().min(1, "Description is required"),
  mimeType: z.string().min(1, "MIME type is required"),
  content: z.string().optional(),
  metadata: z.record(z.any()).optional()
});
class SpecVerseResourceModel {
  constructor(uri, name, description, mimeType, content, metadata) {
    this.uri = uri;
    this.name = name;
    this.description = description;
    this.mimeType = mimeType;
    this.content = content;
    this.metadata = metadata;
  }
  static create(data) {
    const validated = SpecVerseResourceSchema.parse(data);
    return new SpecVerseResourceModel(
      validated.uri,
      validated.name,
      validated.description,
      validated.mimeType,
      validated.content,
      validated.metadata
    );
  }
  static fromJson(json) {
    const data = JSON.parse(json);
    return this.create(data);
  }
  toJson() {
    return JSON.stringify({
      uri: this.uri,
      name: this.name,
      description: this.description,
      mimeType: this.mimeType,
      content: this.content,
      metadata: this.metadata
    });
  }
  withContent(content) {
    return new SpecVerseResourceModel(
      this.uri,
      this.name,
      this.description,
      this.mimeType,
      content,
      this.metadata
    );
  }
  matches(uri) {
    return this.uri === uri;
  }
  isLoaded() {
    return this.content !== void 0;
  }
}
export {
  SpecVerseResourceModel,
  SpecVerseResourceSchema
};
