import type { BidwrightStore } from "./models";
import {
  googleHotelsOutputTemplate,
  googleShoppingOutputTemplate,
  homeDepotSearchOutputTemplate,
} from "./plugin-output-templates";

export const mockStore: BidwrightStore = {
  projects: [
    {
      id: "project-hospital-expansion",
      name: "City Hospital Mechanical Plant Expansion",
      clientName: "City Health Authority",
      location: "Toronto, ON",
      scope: "",
      packageName: "City Hospital RFQ Package",
      packageUploadedAt: "2026-03-21T14:30:00.000Z",
      ingestionStatus: "review",
      summary:
        "Deep bid package with specs, RFQ, coordinated drawings, addenda, and a large estimating reference library. The current estimate is grounded in source citations and reviewed AI output.",
      isStandalone: true,
      createdAt: "2026-03-21T14:30:00.000Z",
      updatedAt: "2026-03-22T11:45:00.000Z",
    },
  ],
  sourceDocuments: [
    {
      id: "doc-rfq",
      projectId: "project-hospital-expansion",
      fileName: "RFQ_01.pdf",
      fileType: "pdf",
      documentType: "rfq",
      pageCount: 42,
      checksum: "sha256:rfq-01",
      storagePath: "projects/project-hospital-expansion/source/rfq_01.pdf",
      extractedText: "Request for Quotation covering mechanical plant expansion and shutdown work.",
      createdAt: "2026-03-21T14:31:00.000Z",
      updatedAt: "2026-03-21T14:32:00.000Z",
    },
    {
      id: "doc-specs",
      projectId: "project-hospital-expansion",
      fileName: "Project_Specifications.pdf",
      fileType: "pdf",
      documentType: "spec",
      pageCount: 318,
      checksum: "sha256:spec-01",
      storagePath: "projects/project-hospital-expansion/source/specs.pdf",
      extractedText:
        "Mechanical specification sections for piping, insulation, controls, test and balance, and commissioning.",
      createdAt: "2026-03-21T14:31:00.000Z",
      updatedAt: "2026-03-21T14:34:00.000Z",
    },
    {
      id: "doc-drawings",
      projectId: "project-hospital-expansion",
      fileName: "Issued_For_Bid_Drawings.zip",
      fileType: "zip",
      documentType: "drawing",
      pageCount: 76,
      checksum: "sha256:drawing-01",
      storagePath: "projects/project-hospital-expansion/source/drawings.zip",
      extractedText:
        "Sheet set includes mechanical plans, risers, details, and equipment schedules.",
      createdAt: "2026-03-21T14:31:00.000Z",
      updatedAt: "2026-03-21T14:35:00.000Z",
    },
  ],
  quotes: [
    {
      id: "quote-main",
      projectId: "project-hospital-expansion",
      quoteNumber: "BW-260321-001",
      title: "Hospital Mechanical Plant Expansion",
      status: "review",
      currentRevisionId: "rev-0",
      customerExistingNew: "Existing",
      customerId: null,
      customerString: "City Health Authority",
      customerContactId: null,
      customerContactString: "Alex Mercer",
      customerContactEmailString: "alex.mercer@cityhealth.example",
      departmentId: null,
      userId: null,
      createdAt: "2026-03-21T14:40:00.000Z",
      updatedAt: "2026-03-22T11:45:00.000Z",
    },
  ],
  revisions: [
    {
      id: "rev-0",
      quoteId: "quote-main",
      revisionNumber: 0,
      title: "Budgetary Takeoff",
      description:
        "Mechanical piping, equipment setting, insulation, and commissioning scope pulled from the uploaded customer package.",
      notes:
        "Review shutdown window, crane access, and phasing assumptions before release.",
      breakoutStyle: "phase_detail",
      type: "Budget",
      scratchpad: "",
      leadLetter: "",
      dateEstimatedShip: null,
      dateQuote: "2026-03-21",
      dateDue: "2026-04-15",
      dateWalkdown: null,
      dateWorkStart: "2026-05-01",
      dateWorkEnd: "2026-09-30",
      shippingMethod: "",
      shippingTerms: "",
      freightOnBoard: "",
      status: "Open",
      defaultMarkup: 0.2,
      followUpNote: "",
      printEmptyNotesColumn: false,
      printCategory: [],
      printPhaseTotalOnly: false,
      grandTotal: 1330268.12,
      regHours: 2584,
      overHours: 0,
      doubleHours: 0,
      breakoutPackage: [],
      calculatedCategoryTotals: [],
      summaryLayoutPreset: "custom",
      pdfPreferences: {},
      pricingLadder: {
        version: 1,
        directCost: 969040,
        lineSubtotal: 1239854,
        adjustmentTotal: 90414.12,
        netTotal: 1330268.12,
        grandTotal: 1330268.12,
        internalProfit: 361228.12,
        internalMargin: 0.27,
        rows: [],
      },
      subtotal: 1330268.12,
      cost: 969040,
      estimatedProfit: 361228.12,
      estimatedMargin: 0.27,
      calculatedTotal: 1330268.12,
      totalHours: 2584,
      createdAt: "2026-03-21T14:42:00.000Z",
      updatedAt: "2026-03-22T11:44:00.000Z",
    },
  ],
  worksheets: [
    { id: "ws-general", revisionId: "rev-0", name: "General Conditions", order: 1 },
    { id: "ws-piping", revisionId: "rev-0", name: "Piping", order: 2 },
    { id: "ws-equipment", revisionId: "rev-0", name: "Equipment", order: 3 },
  ],
  worksheetItems: [
    {
      id: "li-1",
      worksheetId: "ws-piping",
      phaseId: "phase-2",
      category: "Labour",
      entityType: "Labour",
      entityName: "Journeyman Pipefitter",
      description: "Install chilled water piping and supports",
      quantity: 1480,
      uom: "HR",
      cost: 119040 / 1480,
      markup: 0.6,
      price: 190464,
      lineOrder: 1,
    },
    {
      id: "li-2",
      worksheetId: "ws-piping",
      phaseId: "phase-2",
      category: "Materials",
      entityType: "Material",
      entityName: "Pipe and Fittings",
      description: "8-inch and 10-inch steel pipe, fittings, hangers, and accessories",
      quantity: 1,
      uom: "LS",
      cost: 356500,
      markup: 0.25,
      price: 445625,
      lineOrder: 2,
    },
    {
      id: "li-3",
      worksheetId: "ws-equipment",
      phaseId: "phase-2",
      category: "Equipment",
      entityType: "Equipment",
      entityName: "75 Ton Crane",
      description: "Mobilization, pick, and reset support",
      quantity: 4,
      uom: "DAY",
      cost: 18500 / 4,
      markup: 0.25,
      price: 23125,
      lineOrder: 1,
    },
    {
      id: "li-4",
      worksheetId: "ws-general",
      phaseId: "phase-1",
      category: "Subcontractors",
      entityType: "Subcontractor",
      entityName: "Test and Balance",
      description: "TAB contractor for final system balancing and verification",
      quantity: 1,
      uom: "LS",
      cost: 62000,
      markup: 0.18,
      price: 73160,
      lineOrder: 1,
    },
    {
      id: "li-5",
      worksheetId: "ws-piping",
      phaseId: "phase-2",
      category: "Materials",
      entityType: "Material",
      entityName: "Insulation Package",
      description: "Pipe insulation, jacketing, and accessories for exposed runs",
      quantity: 1,
      uom: "LS",
      cost: 121000,
      markup: 0.23,
      price: 148830,
      lineOrder: 3,
    },
    {
      id: "li-6",
      worksheetId: "ws-general",
      phaseId: "phase-2",
      category: "Subcontractors",
      entityType: "Subcontractor",
      entityName: "Controls Integration",
      description: "BMS integration, controls programming, and point-to-point testing",
      quantity: 1,
      uom: "LS",
      cost: 182000,
      markup: 0.2,
      price: 218400,
      lineOrder: 2,
    },
    {
      id: "li-7",
      worksheetId: "ws-general",
      phaseId: "phase-2",
      category: "Labour",
      entityType: "Labour",
      entityName: "Commissioning Crew",
      description: "Commissioning support, turnover, and closeout assistance",
      quantity: 1100,
      uom: "HR",
      cost: 100,
      markup: 0.275,
      price: 140250,
      lineOrder: 3,
    },
  ],
  phases: [
    {
      id: "phase-1",
      revisionId: "rev-0",
      number: "01",
      name: "Preconstruction and Mobilization",
      description: "Submittals, coordination, permits, and site setup.",
      order: 1,
    },
    {
      id: "phase-2",
      revisionId: "rev-0",
      number: "02",
      name: "Mechanical Rough-In",
      description: "Main piping, equipment setting, and insulation rough-in.",
      order: 2,
    },
  ],
  estimateFactors: [],
  adjustments: [
    {
      id: "adj-mod-1",
      revisionId: "rev-0",
      order: 0,
      kind: "modifier",
      pricingMode: "modifier",
      name: "Contingency",
      description: "",
      type: "Surcharge",
      financialCategory: "contingency",
      calculationBase: "selected_scope",
      active: true,
      appliesTo: "All",
      percentage: 0.05,
      amount: null,
      show: "Yes",
    },
    {
      id: "adj-mod-2",
      revisionId: "rev-0",
      order: 1,
      kind: "modifier",
      pricingMode: "modifier",
      name: "Fuel Surcharge",
      description: "",
      type: "Surcharge",
      financialCategory: "fee",
      calculationBase: "selected_scope",
      active: true,
      appliesTo: "Labour",
      percentage: 0.03,
      amount: null,
      show: "No",
    },
    {
      id: "adj-ali-1",
      revisionId: "rev-0",
      order: 2,
      kind: "line_item",
      pricingMode: "line_item_additional",
      name: "Bid Bond Allowance",
      description: "Allow for bond premium associated with submission requirements.",
      type: "LineItemAdditional",
      financialCategory: "bond",
      calculationBase: "line_subtotal",
      active: true,
      appliesTo: "All",
      percentage: null,
      amount: 18500,
      show: "Yes",
    },
  ],
  modifiers: [
    {
      id: "mod-1",
      revisionId: "rev-0",
      name: "Contingency",
      type: "Surcharge",
      appliesTo: "All",
      percentage: 0.05,
      amount: null,
      show: "Yes",
    },
    {
      id: "mod-2",
      revisionId: "rev-0",
      name: "Fuel Surcharge",
      type: "Surcharge",
      appliesTo: "Labour",
      percentage: 0.03,
      amount: null,
      show: "No",
    },
  ],
  additionalLineItems: [
    {
      id: "ali-1",
      revisionId: "rev-0",
      name: "Bid Bond Allowance",
      description: "Allow for bond premium associated with submission requirements.",
      type: "LineItemAdditional",
      amount: 18500,
    },
  ],
  summaryRows: [],
  conditions: [
    {
      id: "cond-1",
      revisionId: "rev-0",
      type: "inclusion",
      value: "Includes standard working hours and one mobilization.",
      order: 1,
    },
    {
      id: "cond-2",
      revisionId: "rev-0",
      type: "exclusion",
      value: "Excludes asbestos abatement, major structural steel, and night shift premiums.",
      order: 2,
    },
  ],
  catalogs: [
    {
      id: "catalog-labor",
      name: "Mechanical Labor Book",
      kind: "labor",
      scope: "global",
      projectId: null,
      description: "Standalone labor class catalog with rates and burdens.",
      source: "manual",
      sourceDescription: "",
      isTemplate: false,
      sourceTemplateId: null,
      createdAt: "2025-01-01T00:00:00.000Z",
      updatedAt: "2025-01-01T00:00:00.000Z",
    },
    {
      id: "catalog-equipment",
      name: "Rental Equipment Rates",
      kind: "equipment",
      scope: "global",
      projectId: null,
      description: "Equipment rate book for cranes, lifts, and specialty rental.",
      source: "manual",
      sourceDescription: "",
      isTemplate: false,
      sourceTemplateId: null,
      createdAt: "2025-01-01T00:00:00.000Z",
      updatedAt: "2025-01-01T00:00:00.000Z",
    },
    {
      id: "catalog-library",
      name: "Mechanical Pipefitting Library",
      kind: "knowledge_library",
      scope: "global",
      projectId: null,
      description: "Long-form reference knowledge for estimating and production planning.",
      source: "manual",
      sourceDescription: "",
      isTemplate: false,
      sourceTemplateId: null,
      createdAt: "2025-01-01T00:00:00.000Z",
      updatedAt: "2025-01-01T00:00:00.000Z",
    },
  ],
  catalogItems: [
    {
      id: "catalog-item-l1",
      catalogId: "catalog-labor",
      code: "LAB-PF-01",
      name: "Journeyman Pipefitter",
      unit: "HR",
      unitCost: 62,
      unitPrice: 95,
      metadata: { burdenIncluded: false, trade: "Mechanical" },
    },
    {
      id: "catalog-item-e1",
      catalogId: "catalog-equipment",
      code: "EQ-CRANE-75",
      name: "75 Ton Crane",
      unit: "DAY",
      unitCost: 16800,
      unitPrice: 21000,
      metadata: { operatorIncluded: false },
    },
    {
      id: "catalog-item-k1",
      catalogId: "catalog-library",
      code: "BOOK-PIPE-2025",
      name: "Mechanical Pipefitting Handbook",
      unit: "PAGE",
      unitCost: 0,
      unitPrice: 0,
      metadata: { pages: 392, sourceType: "reference_book" },
    },
  ],
  aiRuns: [
    {
      id: "airun-1",
      projectId: "project-hospital-expansion",
      revisionId: "rev-0",
      kind: "scope",
      status: "complete",
      model: "gpt-5.4-mini",
      promptVersion: "scope-v1",
      input: {
        sources: ["doc-rfq", "doc-specs", "doc-drawings"],
        question: "Break the package into phases and estimate scope risk.",
      },
      output: {
        phases: ["Preconstruction and Mobilization", "Mechanical Rough-In"],
        riskFlags: ["shutdown window", "crane access", "night work not priced"],
      },
      createdAt: "2026-03-22T10:15:00.000Z",
      updatedAt: "2026-03-22T10:17:00.000Z",
    },
  ],
  citations: [
    {
      id: "cite-1",
      projectId: "project-hospital-expansion",
      aiRunId: "airun-1",
      sourceDocumentId: "doc-specs",
      resourceType: "source_document",
      resourceKey: "Project_Specifications.pdf#p112",
      pageStart: 112,
      pageEnd: 114,
      excerpt: "Mechanical contractor shall coordinate shutdowns with facility operations.",
      confidence: 0.92,
    },
    {
      id: "cite-2",
      projectId: "project-hospital-expansion",
      aiRunId: "airun-1",
      sourceDocumentId: "doc-drawings",
      resourceType: "source_document",
      resourceKey: "Issued_For_Bid_Drawings.zip#sheet-m301",
      pageStart: 31,
      pageEnd: 31,
      excerpt: "Mechanical room layout shows major equipment replacement and rerouting.",
      confidence: 0.88,
    },
  ],
  activities: [],
  conditionLibrary: [],
  reportSections: [],
  jobs: [],
  fileNodes: [],
  plugins: [
            {
      id: "plugin-methvin",
      name: "Methvin Trade Tools",
      slug: "methvin",
      icon: "Flame",
      category: "labour",
      description: "Pipe welding, fabrication, and conduit/cable labour calculation tools with detailed work breakdown tables.",
      llmDescription: "Methvin provides detailed trade-specific labour calculators for pipe welding, fabrication, and conduit/cable installation. Each tool uses interactive tables where individual components, weld types, fittings, and installation tasks are itemized with their respective man-hours.",
      version: "1.0.0",
      author: "Bidwright",
      enabled: true,
      config: {},
      configSchema: [],
      tags: ["welding", "pipe", "fabrication", "conduit", "cable", "methvin"],
      supportedCategories: ["Labour"],
      defaultOutputType: "line_items",
      toolDefinitions: [
        {
          id: "methvin.pipe",
          name: "Methvin Pipe Welding",
          description: "Calculate pipe welding man-hours with alloy groups, wall thickness, and efficiency modifiers",
          llmDescription: "Comprehensive pipe welding calculator. Select alloy group, wall thickness, and pipe size, then itemize weld components in a table. Calculates total man-hours with efficiency adjustments.",
          parameters: [
            { name: "alloyGroup", type: "string", description: "Alloy group (Carbon Steel, Stainless Steel, Chrome-Moly, etc.)", required: true },
            { name: "wallThickness", type: "string", description: "Wall thickness schedule (SCH 40, SCH 80, etc.)", required: true },
            { name: "pipeSize", type: "string", description: "Nominal pipe size", required: true },
            { name: "efficiencyModifier", type: "number", description: "Efficiency modifier (0.5 - 2.0, default 1.0)", required: false, default: 1.0 },
          ],
          outputType: "line_items",
          execution: {
            type: "table_hours",
            tableId: "weldComponents",
            totalField: "totalMH",
            quantityField: "quantity",
            rateField: "mhPerUnit",
            multiplierField: "efficiencyModifier",
            defaultMultiplier: 1,
            descriptionDefault: "Methvin pipe welding",
          },
          requiresConfirmation: false,
          mutates: true,
          tags: ["welding", "pipe", "methvin"],
          ui: {
            layout: "single",
            submitLabel: "Add Welding Hours",
            showPreview: true,
            sections: [
              {
                id: "pipeConfig",
                type: "fields",
                label: "Pipe Configuration",
                order: 0,
                fields: [
                  {
                    id: "alloyGroup", type: "select", label: "Alloy Group", validation: { required: true }, width: "half", order: 0,
                    options: [
                      { value: "carbon-steel", label: "Carbon Steel" },
                      { value: "stainless-304", label: "Stainless Steel 304" },
                      { value: "stainless-316", label: "Stainless Steel 316" },
                      { value: "chrome-moly", label: "Chrome-Moly" },
                      { value: "duplex", label: "Duplex Stainless" },
                      { value: "copper-nickel", label: "Copper-Nickel" },
                    ],
                  },
                  {
                    id: "wallThickness", type: "select", label: "Wall Thickness", validation: { required: true }, width: "half", order: 1,
                    options: [
                      { value: "sch-10", label: "SCH 10" }, { value: "sch-40", label: "SCH 40" },
                      { value: "sch-80", label: "SCH 80" }, { value: "sch-160", label: "SCH 160" },
                      { value: "xxs", label: "XXS (Double Extra Strong)" },
                    ],
                  },
                  {
                    id: "pipeSize", type: "select", label: "Pipe Size", validation: { required: true }, width: "half", order: 2,
                    options: [
                      { value: "0.5", label: "1/2\"" }, { value: "0.75", label: "3/4\"" }, { value: "1", label: "1\"" },
                      { value: "1.5", label: "1-1/2\"" }, { value: "2", label: "2\"" }, { value: "3", label: "3\"" },
                      { value: "4", label: "4\"" }, { value: "6", label: "6\"" }, { value: "8", label: "8\"" },
                      { value: "10", label: "10\"" }, { value: "12", label: "12\"" }, { value: "16", label: "16\"" },
                      { value: "20", label: "20\"" }, { value: "24", label: "24\"" },
                    ],
                  },
                  { id: "efficiencyModifier", type: "slider", label: "Efficiency Modifier", defaultValue: 1.0, validation: { min: 0.5, max: 2.0 }, width: "half", order: 3 },
                  { id: "serviceItem", type: "select", label: "Service Item", optionsSource: { type: "dataset", datasetId: "ds-labour-items", column: "name" }, validation: { required: true }, width: "full", order: 4 },
                ],
              },
              {
                id: "weldTable",
                type: "table",
                label: "Weld Components",
                description: "Itemize each weld type and quantity",
                order: 1,
                table: {
                  id: "weldComponents",
                  label: "Weld Breakdown",
                  columns: [
                    { id: "component", label: "Component", type: "select", width: "200px", editable: true, options: [
                      { value: "butt-weld", label: "Butt Weld" }, { value: "socket-weld", label: "Socket Weld" },
                      { value: "fillet-weld", label: "Fillet Weld" }, { value: "branch-conn", label: "Branch Connection" },
                      { value: "flange", label: "Flange" }, { value: "valve", label: "Valve" },
                      { value: "fitting-90", label: "90° Elbow" }, { value: "fitting-45", label: "45° Elbow" },
                      { value: "tee", label: "Tee" }, { value: "reducer", label: "Reducer" }, { value: "cap", label: "Cap" },
                    ]},
                    { id: "quantity", label: "Qty", type: "number", width: "80px", editable: true, defaultValue: 1, aggregate: "sum" },
                    { id: "mhPerUnit", label: "MH/Unit", type: "number", width: "100px", editable: true, defaultValue: 0 },
                    { id: "totalMH", label: "Total MH", type: "computed", width: "100px", computation: { formula: "quantity * mhPerUnit", dependencies: ["quantity", "mhPerUnit"], format: "hours" }, aggregate: "sum" },
                  ],
                  defaultRows: [{ component: "butt-weld", quantity: 0, mhPerUnit: 0, totalMH: 0 }],
                  allowAddRow: true,
                  allowDeleteRow: true,
                  allowReorder: true,
                  totalsRow: true,
                  rowTemplate: { component: "", quantity: 1, mhPerUnit: 0, totalMH: 0 },
                },
              },
              {
                id: "totals",
                type: "fields",
                label: "Totals",
                order: 2,
                fields: [
                  {
                    id: "totalWeldHours", type: "computed", label: "Total Weld Hours",
                    computation: { formula: "sum(weldComponents, 'totalMH') * efficiencyModifier", dependencies: ["efficiencyModifier"], format: "hours" },
                    width: "full", order: 0,
                  },
                ],
              },
            ],
          },
        },
        {
          id: "methvin.fabrication",
          name: "Methvin Fabrication",
          description: "Calculate fabrication man-hours using work task breakdown",
          llmDescription: "Fabrication labour calculator using a task-based table. List fabrication tasks with quantities and hours per unit. Returns total fabrication labour.",
          parameters: [],
          outputType: "line_items",
          execution: {
            type: "table_hours",
            tableId: "fabTasks",
            totalField: "totalHours",
            quantityField: "quantity",
            rateField: "hoursPerUnit",
            descriptionDefault: "Methvin fabrication",
          },
          tags: ["fabrication", "methvin"],
          ui: {
            layout: "single",
            submitLabel: "Add Fabrication Hours",
            showPreview: true,
            sections: [
              {
                id: "fabTable",
                type: "table",
                label: "Fabrication Tasks",
                order: 0,
                table: {
                  id: "fabTasks",
                  label: "Work Breakdown",
                  columns: [
                    { id: "task", label: "Task", type: "text", width: "200px", editable: true },
                    { id: "quantity", label: "Qty", type: "number", width: "80px", editable: true, defaultValue: 1, aggregate: "sum" },
                    { id: "hoursPerUnit", label: "Hrs/Unit", type: "number", width: "100px", editable: true, defaultValue: 0 },
                    { id: "totalHours", label: "Total Hrs", type: "computed", width: "100px", computation: { formula: "quantity * hoursPerUnit", dependencies: ["quantity", "hoursPerUnit"], format: "hours" }, aggregate: "sum" },
                  ],
                  defaultRows: [
                    { task: "Cutting", quantity: 0, hoursPerUnit: 0, totalHours: 0 },
                    { task: "Beveling", quantity: 0, hoursPerUnit: 0, totalHours: 0 },
                    { task: "Fit-Up", quantity: 0, hoursPerUnit: 0, totalHours: 0 },
                    { task: "Tack Welding", quantity: 0, hoursPerUnit: 0, totalHours: 0 },
                    { task: "Weld-Out", quantity: 0, hoursPerUnit: 0, totalHours: 0 },
                    { task: "Grinding/Finishing", quantity: 0, hoursPerUnit: 0, totalHours: 0 },
                  ],
                  allowAddRow: true, allowDeleteRow: true, allowReorder: true, totalsRow: true,
                  rowTemplate: { task: "", quantity: 1, hoursPerUnit: 0, totalHours: 0 },
                },
              },
              {
                id: "serviceItem",
                type: "fields",
                order: 1,
                fields: [
                  { id: "serviceItem", type: "select", label: "Service Item", optionsSource: { type: "dataset", datasetId: "ds-labour-items", column: "name" }, validation: { required: true }, width: "full", order: 0 },
                ],
              },
            ],
          },
        },
        {
          id: "methvin.conduit",
          name: "Methvin Conduit & Cable",
          description: "Calculate conduit and cable installation man-hours",
          llmDescription: "Estimate conduit and cable installation labour. Specify cable types, sizes, distances, and quantities to calculate total installation hours.",
          parameters: [
            { name: "cableType", type: "string", description: "Type of cable/conduit", required: true },
            { name: "size", type: "string", description: "Cable/conduit size", required: true },
            { name: "distance", type: "number", description: "Total run distance in feet", required: true },
          ],
          outputType: "line_items",
          execution: {
            type: "table_hours",
            tableId: "cableRuns",
            totalField: "totalMH",
            quantityField: "distance",
            rateField: "mhPerFoot",
            descriptionDefault: "Methvin conduit & cable",
          },
          tags: ["conduit", "cable", "electrical", "methvin"],
          ui: {
            layout: "single",
            submitLabel: "Add Installation Hours",
            showPreview: true,
            sections: [
              {
                id: "cableTable",
                type: "table",
                label: "Conduit & Cable Runs",
                order: 0,
                table: {
                  id: "cableRuns",
                  label: "Cable/Conduit Breakdown",
                  columns: [
                    { id: "type", label: "Type", type: "select", width: "160px", editable: true, options: [
                      { value: "emt", label: "EMT" }, { value: "rigid", label: "Rigid" },
                      { value: "pvc", label: "PVC" }, { value: "mc-cable", label: "MC Cable" },
                      { value: "tray", label: "Cable Tray" }, { value: "flex", label: "Flex Conduit" },
                    ]},
                    { id: "size", label: "Size", type: "select", width: "100px", editable: true, options: [
                      { value: "0.5", label: "1/2\"" }, { value: "0.75", label: "3/4\"" }, { value: "1", label: "1\"" },
                      { value: "1.5", label: "1-1/2\"" }, { value: "2", label: "2\"" }, { value: "3", label: "3\"" }, { value: "4", label: "4\"" },
                    ]},
                    { id: "distance", label: "Distance (ft)", type: "number", width: "110px", editable: true, aggregate: "sum" },
                    { id: "mhPerFoot", label: "MH/ft", type: "number", width: "80px", editable: true, defaultValue: 0 },
                    { id: "totalMH", label: "Total MH", type: "computed", width: "100px", computation: { formula: "distance * mhPerFoot", dependencies: ["distance", "mhPerFoot"], format: "hours" }, aggregate: "sum" },
                  ],
                  allowAddRow: true, allowDeleteRow: true, totalsRow: true,
                  rowTemplate: { type: "", size: "", distance: 0, mhPerFoot: 0, totalMH: 0 },
                },
              },
              {
                id: "serviceItem",
                type: "fields",
                order: 1,
                fields: [
                  { id: "serviceItem", type: "select", label: "Service Item", optionsSource: { type: "dataset", datasetId: "ds-labour-items", column: "name" }, validation: { required: true }, width: "full", order: 0 },
                ],
              },
            ],
          },
        },
      ],
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
    {
      id: "plugin-home-depot",
      name: "Home Depot Product Search",
      slug: "home-depot",
      icon: "ShoppingCart",
      category: "material",
      description: "Search Home Depot for product pricing and add material items directly to your estimate.",
      llmDescription: "Search the Home Depot product catalog by keyword. Returns product results with pricing. Select a product to add it as a material line item with cost and default 15% markup. Requires a SerpAPI key.",
      version: "1.0.0",
      author: "Bidwright",
      enabled: true,
      config: { apiKey: "" },
      configSchema: [
        { key: "apiKey", label: "SerpAPI Key", type: "password", description: "API key for SerpAPI Home Depot search", required: true, placeholder: "Enter your SerpAPI key" },
      ],
      tags: ["material", "shopping", "home-depot", "pricing"],
      supportedCategories: ["Material"],
      defaultOutputType: "line_items",
      toolDefinitions: [
        {
          id: "homedepot.search",
          name: "Home Depot Search",
          description: "Search Home Depot products by name and add to estimate",
          llmDescription: "Search the Home Depot product catalog. Returns matching products with prices. When the user mentions a material, use this to find current pricing.",
          parameters: [
            { name: "query", type: "string", description: "Search query for products", required: true },
            { name: "maxResults", type: "number", description: "Maximum number of results (default 10)", required: false, default: 10 },
          ],
          outputType: "line_items",
          outputTemplate: homeDepotSearchOutputTemplate,
          tags: ["search", "material", "pricing"],
          ui: {
            layout: "single",
            submitLabel: "Add to Estimate",
            showPreview: true,
            sections: [
              {
                id: "search",
                type: "search",
                label: "Product Search",
                order: 0,
                fields: [
                  {
                    id: "query", type: "search", label: "Search Products",
                    placeholder: "e.g., 3/4 inch copper pipe type L",
                    validation: { required: true, minLength: 2 },
                    searchConfig: {
                      queryParam: "q",
                      displayField: "title",
                      valueField: "title",
                      resultFields: ["vendor", "price", "rating"],
                      populateFields: { name: "title", vendor: "vendor", cost: "price", description: "title" },
                      dataSource: {
                        type: "http-json",
                        url: "https://serpapi.com/search.json",
                        query: {
                          engine: "home_depot",
                          api_key: { from: "config", key: "apiKey", env: "SERPAPI_API_KEY", required: true, label: "SerpAPI key" },
                          q: { from: "query", key: "q", required: true, label: "Search query" },
                          country: { from: "config", key: "country", env: "SERPAPI_HOME_DEPOT_COUNTRY", default: "us" },
                          store_id: { from: "config", key: "storeId", env: "SERPAPI_HOME_DEPOT_STORE_ID" },
                          delivery_zip: { from: "config", key: "deliveryZip", env: "SERPAPI_HOME_DEPOT_DELIVERY_ZIP" },
                          ps: { from: "limit", default: 10, max: 24 },
                        },
                        resultPaths: ["products", "search_results", "organic_results"],
                        resultDefaults: { vendor: "Home Depot" },
                        resultMap: {
                          id: ["product_id", "item_id", "model_number", "link"],
                          product_id: ["product_id", "item_id"],
                          title: ["title", "name"],
                          price: ["extracted_price", "price"],
                          rating: "rating",
                          thumbnail: ["thumbnail", "image", "thumbnails"],
                          link: ["link", "product_link"],
                          brand: "brand",
                          model: ["model_number", "model"],
                        },
                        resultTypes: { price: "number", rating: "number", thumbnail: "image" },
                        dedupeFields: ["product_id", "link", "title"],
                      },
                    },
                    width: "full", order: 0,
                  },
                ],
              },
              {
                id: "itemDetails",
                type: "fields",
                label: "Item Details",
                order: 1,
                fields: [
                  { id: "name", type: "text", label: "Item Name", width: "full", order: 0 },
                  { id: "description", type: "textarea", label: "Description", width: "full", order: 1 },
                  { id: "cost", type: "currency", label: "Unit Cost", validation: { required: true, min: 0 }, width: "third", order: 2 },
                  { id: "quantity", type: "number", label: "Quantity", defaultValue: 1, validation: { required: true, min: 1 }, width: "third", order: 3 },
                  { id: "markup", type: "percentage", label: "Markup", defaultValue: 15, width: "third", order: 4 },
                ],
              },
            ],
          },
        },
      ],
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
    {
      id: "plugin-google-shopping",
      name: "Google Shopping",
      slug: "google-shopping",
      icon: "Search",
      category: "material",
      description: "Search Google Shopping for product pricing across multiple vendors.",
      llmDescription: "Search Google Shopping to find product pricing from multiple vendors. Returns product listings with vendor, price, and availability.",
      version: "1.0.0",
      author: "Bidwright",
      enabled: true,
      config: { apiKey: "" },
      configSchema: [
        { key: "apiKey", label: "SerpAPI Key", type: "password", description: "API key for SerpAPI Google Shopping", required: true, placeholder: "Enter your SerpAPI key" },
      ],
      tags: ["material", "shopping", "pricing", "comparison"],
      supportedCategories: ["Material"],
      defaultOutputType: "line_items",
      toolDefinitions: [{
        id: "google.shopping",
        name: "Google Shopping Search",
        description: "Search products across multiple vendors",
        llmDescription: "Search Google Shopping for product pricing. Returns results from multiple vendors for price comparison.",
        parameters: [{ name: "query", type: "string", description: "Search query", required: true }],
        outputType: "line_items",
        outputTemplate: googleShoppingOutputTemplate,
        tags: ["search", "material", "comparison"],
        ui: {
          layout: "single",
          submitLabel: "Add to Estimate",
          showPreview: true,
          sections: [
            {
              id: "search",
              type: "search",
              label: "Google Shopping Search",
              order: 0,
              fields: [{
                id: "query", type: "search", label: "Search Products",
                placeholder: "e.g., 10/2 NM-B wire 250ft",
                validation: { required: true, minLength: 2 },
                searchConfig: {
                  queryParam: "q",
                  displayField: "title",
                  valueField: "title",
                  resultFields: ["vendor", "price", "rating"],
                  populateFields: { name: "title", vendor: "vendor", cost: "price", description: "title" },
                  dataSource: {
                    type: "http-json",
                    url: "https://serpapi.com/search.json",
                    query: {
                      engine: "google_shopping",
                      api_key: { from: "config", key: "apiKey", env: "SERPAPI_API_KEY", required: true, label: "SerpAPI key" },
                      q: { from: "query", key: "q", required: true, label: "Search query" },
                      gl: { from: "config", key: "gl", env: "SERPAPI_GL", default: "us" },
                      hl: { from: "config", key: "hl", env: "SERPAPI_HL", default: "en" },
                      location: { from: "config", key: "location", env: "SERPAPI_GOOGLE_LOCATION" },
                      google_domain: { from: "config", key: "googleDomain", env: "SERPAPI_GOOGLE_DOMAIN" },
                      num: { from: "limit", default: 10, max: 20 },
                    },
                    resultPaths: ["shopping_results", "inline_shopping_results", "organic_results", "categorized_shopping_results.*.shopping_results", "categorized_shopping_results.*.products"],
                    resultMap: {
                      id: ["product_id", "position", "product_link", "link"],
                      product_id: "product_id",
                      title: "title",
                      vendor: ["source", "seller", "vendor"],
                      price: ["extracted_price", "price"],
                      rating: "rating",
                      thumbnail: ["thumbnail", "serpapi_thumbnail", "thumbnails"],
                      link: ["product_link", "link"],
                      delivery: "delivery",
                    },
                    resultTypes: { price: "number", rating: "number", thumbnail: "image" },
                    dedupeFields: ["product_id", "link", "title"],
                  },
                },
                width: "full", order: 0,
              }],
            },
            {
              id: "itemDetails",
              type: "fields",
              label: "Item Details",
              order: 1,
              fields: [
                { id: "name", type: "text", label: "Item Name", width: "full", order: 0 },
                { id: "vendor", type: "text", label: "Vendor", width: "half", order: 1 },
                { id: "cost", type: "currency", label: "Unit Cost", validation: { required: true, min: 0 }, width: "half", order: 2 },
                { id: "quantity", type: "number", label: "Quantity", defaultValue: 1, validation: { required: true, min: 1 }, width: "third", order: 3 },
                { id: "markup", type: "percentage", label: "Markup", defaultValue: 15, width: "third", order: 4 },
              ],
            },
          ],
        },
      }],
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
    {
      id: "plugin-google-hotels",
      name: "Google Hotels",
      slug: "google-hotels",
      icon: "Hotel",
      category: "travel",
      description: "Search Google Hotels for travel cost estimation with date-based pricing.",
      llmDescription: "Search Google Hotels to find accommodation pricing near the project site. Creates travel & per diem line items. Use when estimating travel costs for crew lodging.",
      version: "1.0.0",
      author: "Bidwright",
      enabled: true,
      config: { apiKey: "" },
      configSchema: [
        { key: "apiKey", label: "SerpAPI Key", type: "password", description: "API key for SerpAPI Google Hotels", required: true, placeholder: "Enter your SerpAPI key" },
      ],
      tags: ["travel", "hotels", "per-diem", "accommodation"],
      supportedCategories: ["Travel & Per Diem"],
      defaultOutputType: "line_items",
      toolDefinitions: [{
        id: "google.hotels",
        name: "Hotel Search",
        description: "Search hotels for travel pricing near the project site",
        llmDescription: "Search Google Hotels for accommodation near a project location. Provide the location, check-in, and check-out dates. Creates a travel & per diem line item.",
        parameters: [
          { name: "location", type: "string", description: "City or address near the project site", required: true },
          { name: "checkin", type: "string", description: "Check-in date (YYYY-MM-DD)", required: true },
          { name: "checkout", type: "string", description: "Check-out date (YYYY-MM-DD)", required: true },
          { name: "crewSize", type: "number", description: "Number of crew members needing rooms", required: false, default: 1 },
        ],
        outputType: "line_items",
        outputTemplate: googleHotelsOutputTemplate,
        tags: ["travel", "hotels", "search"],
        ui: {
          layout: "single",
          submitLabel: "Add Travel Cost",
          showPreview: true,
          sections: [
            {
              id: "search",
              type: "fields",
              label: "Hotel Search",
              order: 0,
              fields: [
                { id: "location", type: "text", label: "Location", placeholder: "e.g., Toronto, ON", validation: { required: true }, width: "full", order: 0 },
                { id: "checkin", type: "date", label: "Check-in", validation: { required: true }, width: "third", order: 1 },
                { id: "checkout", type: "date", label: "Check-out", validation: { required: true }, width: "third", order: 2 },
                { id: "crewSize", type: "number", label: "Crew Size", defaultValue: 1, validation: { required: true, min: 1 }, width: "third", order: 3 },
              ],
            },
            {
              id: "results",
              type: "search",
              label: "Available Hotels",
              order: 1,
              fields: [{
                id: "hotelSearch", type: "search", label: "Search Results",
                searchConfig: {
                  queryParam: "q",
                  displayField: "name",
                  valueField: "name",
                  resultFields: ["price", "rating", "type"],
                  params: { checkin: "checkin", checkout: "checkout", adults: "crewSize" },
                  populateFields: { hotelName: "name", nightlyRate: "price" },
                  dataSource: {
                    type: "http-json",
                    url: "https://serpapi.com/search.json",
                    query: {
                      engine: "google_hotels",
                      api_key: { from: "config", key: "apiKey", env: "SERPAPI_API_KEY", required: true, label: "SerpAPI key" },
                      q: { from: "query", key: "q", required: true, label: "Hotel search" },
                      gl: { from: "config", key: "gl", env: "SERPAPI_GL", default: "us" },
                      hl: { from: "config", key: "hl", env: "SERPAPI_HL", default: "en" },
                      currency: { from: "config", key: "currency", env: "SERPAPI_CURRENCY", default: "USD" },
                      check_in_date: { from: "field", key: "checkin", required: true, label: "Check-in date" },
                      check_out_date: { from: "field", key: "checkout", required: true, label: "Check-out date" },
                      adults: { from: "field", key: "adults", default: "2" },
                      children: { from: "config", key: "children", env: "SERPAPI_HOTELS_CHILDREN", default: "0" },
                    },
                    resultPaths: ["properties", "ads", "hotel_results", "hotels_results", "$"],
                    resultMap: {
                      id: ["property_token", "hotel_id", "name"],
                      property_token: "property_token",
                      name: ["name", "title"],
                      price: ["rate_per_night.extracted_lowest", "rate_per_night.extracted_price", "total_rate.extracted_lowest", "total_rate.extracted_price", "extracted_price", "price"],
                      rating: ["overall_rating", "rating"],
                      type: "type",
                      vendor: ["source", "brand"],
                      thumbnail: "thumbnail",
                      link: ["link", "serpapi_property_details_link"],
                      address: "address",
                    },
                    resultTypes: { price: "number", rating: "number", thumbnail: "image" },
                    dedupeFields: ["property_token", "link", "name"],
                  },
                },
                width: "full", order: 0,
              }],
            },
            {
              id: "hotelDetails",
              type: "fields",
              label: "Selected Hotel",
              order: 2,
              fields: [
                { id: "hotelName", type: "text", label: "Hotel Name", width: "full", order: 0 },
                { id: "nightlyRate", type: "currency", label: "Nightly Rate", validation: { min: 0 }, width: "third", order: 1 },
                { id: "nights", type: "computed", label: "Nights", computation: { formula: "daysBetween(checkin, checkout)", dependencies: ["checkin", "checkout"], format: "number" }, width: "third", order: 2 },
                { id: "totalCost", type: "computed", label: "Total Cost", computation: { formula: "nightlyRate * nights * crewSize", dependencies: ["nightlyRate", "nights", "crewSize"], format: "currency" }, width: "third", order: 3 },
                { id: "markup", type: "percentage", label: "Markup", defaultValue: 15, width: "half", order: 4 },
              ],
            },
          ],
        },
      }],
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
    {
      id: "plugin-scope-writer",
      name: "Scope & Content Writer",
      slug: "scope-writer",
      icon: "FileText",
      category: "general",
      description: "AI-powered content generation for quote documents — lead letters, scope descriptions, exclusions, and notes.",
      llmDescription: "Generate professional content for quote document fields. Can write lead letters, scope of work descriptions, terms and conditions, exclusions, and customer-facing revision notes. Uses project context and source documents to produce accurate, tailored content.",
      version: "1.0.0",
      author: "Bidwright",
      enabled: true,
      config: {},
      configSchema: [],
      tags: ["content", "writing", "scope", "lead-letter", "ai"],
      defaultOutputType: "text_content",
      toolDefinitions: [
        {
          id: "scope.leadLetter",
          name: "Lead Letter Generator",
          description: "Generate a professional cover letter for the quote",
          llmDescription: "Generate a cover letter for a quote. Uses project details, client name, scope summary, and quote totals to create a professional letter. Output goes to revision.leadLetter field.",
          parameters: [
            { name: "tone", type: "string", description: "Tone: formal, professional, friendly", required: false, enum: ["formal", "professional", "friendly"], default: "professional" },
            { name: "highlights", type: "string", description: "Key points to emphasize", required: false },
            { name: "additionalContext", type: "string", description: "Any additional context for the letter", required: false },
          ],
          outputType: "text_content",
          tags: ["content", "lead-letter"],
          ui: {
            layout: "single",
            submitLabel: "Generate Lead Letter",
            showPreview: true,
            sections: [
              {
                id: "config",
                type: "fields",
                label: "Letter Configuration",
                order: 0,
                fields: [
                  {
                    id: "tone", type: "radio", label: "Tone", defaultValue: "professional", width: "full", order: 0,
                    options: [
                      { value: "formal", label: "Formal", description: "Traditional business correspondence" },
                      { value: "professional", label: "Professional", description: "Clear and direct" },
                      { value: "friendly", label: "Friendly", description: "Approachable but business-appropriate" },
                    ],
                  },
                  { id: "highlights", type: "textarea", label: "Key Highlights", description: "Points to emphasize in the letter", placeholder: "e.g., competitive pricing, fast turnaround", width: "full", order: 1 },
                  { id: "additionalContext", type: "textarea", label: "Additional Context", placeholder: "Any special considerations", width: "full", order: 2 },
                ],
              },
              { id: "preview", type: "preview", label: "Generated Letter Preview", order: 1 },
            ],
          },
        },
        {
          id: "scope.description",
          name: "Scope Description Writer",
          description: "Generate scope of work description from project documents",
          llmDescription: "Analyze source documents and existing estimate to generate a detailed scope of work description. Outputs markdown text for revision fields.",
          parameters: [
            { name: "detail", type: "string", description: "Detail level: brief, standard, detailed", required: false, enum: ["brief", "standard", "detailed"], default: "standard" },
            { name: "targetField", type: "string", description: "Where to write: scratchpad (internal), notes (customer-facing), description", required: false, default: "scratchpad" },
          ],
          outputType: "text_content",
          tags: ["content", "scope"],
          ui: {
            layout: "single",
            submitLabel: "Generate Scope",
            showPreview: true,
            sections: [
              {
                id: "config",
                type: "fields",
                label: "Scope Configuration",
                order: 0,
                fields: [
                  {
                    id: "detail", type: "select", label: "Detail Level", defaultValue: "standard", width: "half", order: 0,
                    options: [
                      { value: "brief", label: "Brief", description: "High-level summary" },
                      { value: "standard", label: "Standard", description: "Normal scope description" },
                      { value: "detailed", label: "Detailed", description: "Comprehensive with sub-sections" },
                    ],
                  },
                  {
                    id: "targetField", type: "select", label: "Output To", defaultValue: "scratchpad", width: "half", order: 1,
                    options: [
                      { value: "scratchpad", label: "Scratchpad (internal)" },
                      { value: "notes", label: "Revision Notes (customer-facing)" },
                      { value: "description", label: "Revision Description" },
                    ],
                  },
                  { id: "focus", type: "textarea", label: "Focus Areas", placeholder: "Specific areas or systems to focus on", width: "full", order: 2 },
                ],
              },
              { id: "preview", type: "preview", label: "Generated Scope Preview", order: 1 },
            ],
          },
        },
        {
          id: "scope.exclusions",
          name: "Exclusions & Qualifications",
          description: "Generate standard exclusions and qualifications for the quote",
          llmDescription: "Generate exclusions, qualifications, and conditions for a quote based on the project scope and trade. Outputs conditions that get added to the revision.",
          parameters: [
            { name: "trade", type: "string", description: "Primary trade", required: false, enum: ["electrical", "mechanical", "plumbing", "hvac", "fire-protection", "general"] },
          ],
          outputType: "composite",
          tags: ["content", "exclusions", "conditions"],
          ui: {
            layout: "single",
            submitLabel: "Generate Exclusions",
            showPreview: true,
            sections: [
              {
                id: "config",
                type: "fields",
                label: "Configuration",
                order: 0,
                fields: [
                  {
                    id: "trade", type: "select", label: "Primary Trade", width: "half", order: 0,
                    options: [
                      { value: "electrical", label: "Electrical" }, { value: "mechanical", label: "Mechanical" },
                      { value: "plumbing", label: "Plumbing" }, { value: "hvac", label: "HVAC" },
                      { value: "fire-protection", label: "Fire Protection" }, { value: "general", label: "General Contractor" },
                    ],
                  },
                  { id: "includeStandard", type: "boolean", label: "Include Standard Exclusions", description: "Add industry-standard exclusion items", defaultValue: true, width: "half", order: 1 },
                ],
              },
              { id: "preview", type: "preview", label: "Generated Exclusions", order: 1 },
            ],
          },
        },
      ],
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
  ],
  pluginExecutions: [],
  knowledgeBooks: [],
  knowledgeChunks: [],
  knowledgeDocuments: [],
  knowledgeDocumentPages: [],
  knowledgeDocumentChunks: [],
  datasets: [
        {
      id: "ds-equipment-rates",
      name: "Equipment Rental Rates",
      description: "Standard equipment rental rates (daily, weekly, monthly)",
      category: "equipment_rates",
      scope: "global",
      projectId: null,
      columns: [
        { key: "name", name: "Equipment", type: "text", required: true },
        { key: "category", name: "Category", type: "select", required: true, options: ["Aerial", "Earthmoving", "Material Handling", "Compaction", "Generators", "Welding", "Other"] },
        { key: "daily", name: "Daily Rate", type: "currency", required: true, unit: "$/day" },
        { key: "weekly", name: "Weekly Rate", type: "currency", required: true, unit: "$/week" },
        { key: "monthly", name: "Monthly Rate", type: "currency", required: true, unit: "$/month" },
        { key: "mobilization", name: "Mobilization", type: "currency", required: false, unit: "$" },
      ],
      rowCount: 0,
      cabinetId: null,
      source: "manual",
      sourceDescription: "Company equipment rate book",
      isTemplate: false,
      sourceTemplateId: null,
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
    {
      id: "ds-productivity",
      name: "Productivity Factors",
      description: "Labour productivity adjustment factors by condition",
      category: "productivity",
      scope: "global",
      projectId: null,
      columns: [
        { key: "condition", name: "Condition", type: "text", required: true },
        { key: "factor", name: "Factor", type: "number", required: true },
        { key: "description", name: "Description", type: "text", required: false },
      ],
      rowCount: 0,
      cabinetId: null,
      source: "manual",
      sourceDescription: "Productivity adjustment factors",
      isTemplate: false,
      sourceTemplateId: null,
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
  ],
  datasetRows: [],
  users: [
    {
      id: "user-admin",
      email: "admin@bidwright.app",
      name: "Admin",
      role: "admin",
      active: true,
      passwordHash: "",
      lastLoginAt: null,
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
    {
      id: "user-estimator",
      email: "estimator@bidwright.app",
      name: "Estimator",
      role: "estimator",
      active: true,
      passwordHash: "",
      lastLoginAt: null,
      createdAt: "2026-03-20T00:00:00.000Z",
      updatedAt: "2026-03-20T00:00:00.000Z",
    },
  ],
  authSessions: [],
  entityCategories: [
    {
      id: "ec-labour", name: "Labour", entityType: "Labour", shortform: "L", defaultUom: "HR",
      validUoms: ["HR", "DAY", "WK", "MO"],
      editableFields: { quantity: true, cost: false, markup: false, price: false, tierUnits: true },
      unitLabels: {},
      calculationType: "tiered_rate" as const, calcFormula: "", itemSource: "rate_schedule" as const, color: "#3b82f6", order: 1, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-equipment", name: "Equipment", entityType: "Equipment", shortform: "E", defaultUom: "DAY",
      validUoms: ["DAY", "WK", "MO", "EA"],
      editableFields: { quantity: true, cost: false, markup: false, price: false, tierUnits: true },
      unitLabels: {},
      calculationType: "duration_rate" as const, calcFormula: "", itemSource: "catalog" as const, color: "#f59e0b", order: 2, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-material", name: "Material", entityType: "Material", shortform: "M", defaultUom: "EA",
      validUoms: ["EA", "FT", "LF", "SF", "M", "IN", "YD", "LB", "KG", "TON", "GAL"],
      editableFields: { quantity: true, cost: true, markup: true, price: false, tierUnits: false },
      unitLabels: {},
      calculationType: "manual" as const, calcFormula: "", itemSource: "freeform" as const, color: "#22c55e", order: 3, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-subcontractor", name: "Subcontractor", entityType: "Subcontractor", shortform: "S", defaultUom: "LS",
      validUoms: ["HR", "EA", "LS"],
      editableFields: { quantity: true, cost: true, markup: true, price: false, tierUnits: false },
      unitLabels: {},
      calculationType: "manual" as const, calcFormula: "", itemSource: "freeform" as const, color: "#8b5cf6", order: 4, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-vendor-service", name: "Vendor Services", entityType: "VendorService", shortform: "VS", defaultUom: "LS",
      validUoms: ["HR", "DAY", "EA", "LS"],
      editableFields: { quantity: true, cost: true, markup: true, price: false, tierUnits: false },
      unitLabels: {},
      calculationType: "manual" as const, calcFormula: "", itemSource: "freeform" as const, color: "#0ea5e9", order: 5, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-consumable", name: "Consumables", entityType: "Consumable", shortform: "C", defaultUom: "EA",
      validUoms: ["EA", "KG", "LB"],
      editableFields: { quantity: true, cost: false, markup: true, price: false, tierUnits: false },
      unitLabels: {},
      calculationType: "quantity_markup" as const, calcFormula: "", itemSource: "freeform" as const, color: "#6b7280", order: 6, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-rental", name: "Rental Equipment", entityType: "RentalEquipment", shortform: "R", defaultUom: "DAY",
      validUoms: ["HR", "DAY", "WK", "MO", "EA"],
      editableFields: { quantity: true, cost: true, markup: true, price: false, tierUnits: false },
      unitLabels: {},
      calculationType: "duration_rate" as const, calcFormula: "", itemSource: "rate_schedule" as const, color: "#ec4899", order: 7, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-travel", name: "Travel & Per Diem", entityType: "Travel", shortform: "T", defaultUom: "DAY",
      validUoms: ["DAY", "EA"],
      editableFields: { quantity: true, cost: true, markup: true, price: false, tierUnits: false },
      unitLabels: {},
      calculationType: "manual" as const, calcFormula: "", itemSource: "freeform" as const, color: "#f97316", order: 8, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-other", name: "Other Charges", entityType: "OtherCharges", shortform: "O", defaultUom: "LS",
      validUoms: ["EA", "LS"],
      editableFields: { quantity: false, cost: false, markup: false, price: true, tierUnits: false },
      unitLabels: {},
      calculationType: "direct_total" as const, calcFormula: "", itemSource: "freeform" as const, color: "#ef4444", order: 9, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-allowance", name: "Allowances", entityType: "Allowance", shortform: "A", defaultUom: "LS",
      validUoms: ["EA", "LS", "%"],
      editableFields: { quantity: true, cost: true, markup: false, price: false, tierUnits: false },
      unitLabels: {},
      calculationType: "direct_total" as const, calcFormula: "", itemSource: "freeform" as const, color: "#06b6d4", order: 10, isBuiltIn: true, enabled: true,
    },
    {
      id: "ec-overhead", name: "Overhead", entityType: "Overhead", shortform: "H", defaultUom: "%",
      validUoms: ["%", "EA"],
      editableFields: { quantity: true, cost: true, markup: false, price: false, tierUnits: false },
      unitLabels: {},
      calculationType: "direct_total" as const, calcFormula: "", itemSource: "freeform" as const, color: "#78716c", order: 11, isBuiltIn: true, enabled: true,
    },
  ],

  scheduleTasks: [],
  scheduleDependencies: [],
  scheduleCalendars: [],
  scheduleBaselines: [],
  scheduleBaselineTasks: [],
  scheduleResources: [],
  scheduleTaskAssignments: [],

  // ── Rate Schedules ───────────────────────────────────────────────────
  rateSchedules: [
    {
      id: "rs-mechanical-labor-book-2026",
      organizationId: "org-seed",
      name: "Mechanical Labor Book",
      description: "Revision-imported mechanical labour ratebook. Catalog items are resource identities; priced estimate rows use RateScheduleItem IDs.",
      category: "Labour",
      scope: "revision",
      projectId: "project-hospital-expansion",
      revisionId: "rev-0",
      sourceScheduleId: null,
      effectiveDate: "2026-01-01",
      expiryDate: "2026-12-31",
      defaultMarkup: 0,
      autoCalculate: true,
      metadata: { sourceRole: "ratebook", entityCategoryId: "ec-labour" },
      createdAt: "2026-01-01T00:00:00.000Z",
      updatedAt: "2026-01-01T00:00:00.000Z",
    },
  ],
  rateScheduleTiers: [
    { id: "rst-mech-labor-reg", scheduleId: "rs-mechanical-labor-book-2026", name: "Regular", multiplier: 1, sortOrder: 0, uom: "HR" },
    { id: "rst-mech-labor-ot", scheduleId: "rs-mechanical-labor-book-2026", name: "Overtime", multiplier: 1.5, sortOrder: 1, uom: "HR" },
    { id: "rst-mech-labor-dt", scheduleId: "rs-mechanical-labor-book-2026", name: "Double Time", multiplier: 2, sortOrder: 2, uom: "HR" },
  ],
  rateScheduleItems: [
    {
      id: "rsi-mech-pipefitter-2026",
      scheduleId: "rs-mechanical-labor-book-2026",
      catalogItemId: "catalog-item-l1",
      resourceId: null,
      catalogUnitCost: 62,
      catalogUnitPrice: 95,
      catalogUnit: "HR",
      code: "LAB-PF-01",
      name: "Journeyman Pipefitter",
      unit: "HR",
      rates: {
        "rst-mech-labor-reg": 95,
        "rst-mech-labor-ot": 142.5,
        "rst-mech-labor-dt": 190,
      },
      costRates: {},
      burden: 0,
      perDiem: 0,
      metadata: { sourceCatalogItemId: "catalog-item-l1" },
      sortOrder: 0,
    },
  ],
  pickupLinks: [],
};
