/**
 * Shared watercourse calculation functions
 *
 * This module contains calculation functions that are identical between
 * on-site and off-site watercourse modules (baseline, creation, enhancement).
 *
 * All functions use generics to work with both on-site and off-site types.
 */
import { type Watercourse, type WatercourseLabel } from '../watercourses';
import { type StrategicSignificanceDescription } from '../strategicSignificanceSchema';
import { type WatercourseCondition } from '../watercourseCondition';
import { type WatercourseEncroachment, type RiparianEncroachment } from '../watercourseEncroachment';
import { watercourseEnhancementTemporalMatrix } from '../watercourseEnhancementTemporalMatrix';
/**
 * Enrich data with watercourse properties from the watercourses lookup.
 * Used by baseline modules to add metadata and encroachment multipliers.
 */
export declare function enrichWithBaselineWatercourseData<Data extends {
    length: number;
    lengthRetained: number;
    lengthEnhanced: number;
    watercourseType: WatercourseLabel;
    condition: WatercourseCondition;
    strategicSignificance: StrategicSignificanceDescription;
    watercourseEncroachment: string;
    riparianEncroachment: string;
}>(data: Data): Data & {
    distinctiveness: "V.High" | "High" | "Medium" | "Low";
    distinctivenessScore: 2 | 4 | 8 | 6;
    conditionScore: number | "Not possible";
    strategicSignificanceCategory: "High strategic significance" | "Medium strategic significance" | "Low strategic significance";
    strategicSignificanceMultiplier: 1 | 1.15 | 1.1;
    watercourseEncroachmentMultiplier: 1 | 0.8 | 0.5 | 0.68;
    riparianEncroachmentMultiplier: 1 | 0.8 | 0.75 | 0.84 | 0.87 | 0.85 | 0.9 | 0.92 | 0.95 | 0.98;
    tradingRules: "Same habitat required – bespoke compensation option ⚠" | "Same habitat required =" | "Better distinctiveness habitat required";
    irreplaceable: undefined;
};
/**
 * Calculate baseline units for retained and enhanced portions.
 * Used by both on-site and off-site baseline calculations.
 */
/**
 * Pure calculation: derives baseline units retained and enhanced for watercourses.
 */
export declare function calculateBaselineUnits(input: {
    lengthRetained: number;
    lengthEnhanced: number;
    distinctivenessScore: number;
    conditionScore: number | 'Not possible';
    strategicSignificanceMultiplier: number;
    watercourseEncroachmentMultiplier: number;
    riparianEncroachmentMultiplier: number;
}): {
    unitsRetained: number;
    unitsEnhanced: number;
};
export declare function enrichWithBaselineUnitsData<Data extends {
    length: number;
    lengthRetained: number;
    lengthEnhanced: number;
    distinctivenessScore: number;
    conditionScore: number | 'Not possible';
    strategicSignificanceMultiplier: number;
    watercourseEncroachmentMultiplier: number;
    riparianEncroachmentMultiplier: number;
}>(data: Data): Data & {
    unitsRetained: number;
    unitsEnhanced: number;
};
/**
 * Calculate total watercourse units.
 * Used by both on-site and off-site baseline calculations.
 */
/**
 * Pure calculation: derives totalWatercourseUnits.
 */
export declare function calculateTotalWatercourseUnits(input: {
    length: number;
    distinctivenessScore: number;
    conditionScore: number | 'Not possible';
    strategicSignificanceMultiplier: number;
    watercourseEncroachmentMultiplier: number;
    riparianEncroachmentMultiplier: number;
}): {
    totalWatercourseUnits: number;
};
export declare function enrichWithTotalWatercourseUnits<Data extends {
    length: number;
    lengthRetained: number;
    lengthEnhanced: number;
    distinctivenessScore: number;
    conditionScore: number | 'Not possible';
    strategicSignificanceMultiplier: number;
    watercourseEncroachmentMultiplier: number;
    riparianEncroachmentMultiplier: number;
}>(data: Data): Data & {
    totalWatercourseUnits: number;
};
/**
 * Calculate length lost and units lost.
 * Used by both on-site and off-site baseline calculations.
 */
/**
 * Pure calculation: derives lengthLost and unitsLost.
 */
export declare function calculateUnitsLost(input: {
    length: number;
    lengthRetained: number;
    lengthEnhanced: number;
    totalWatercourseUnits: number;
    unitsRetained: number;
    unitsEnhanced: number;
}): {
    lengthLost: number;
    unitsLost: number;
};
export declare function enrichWithUnitsLost<Data extends {
    length: number;
    lengthRetained: number;
    lengthEnhanced: number;
    totalWatercourseUnits: number;
    unitsRetained: number;
    unitsEnhanced: number;
}>(data: Data): Data & {
    lengthLost: number;
    unitsLost: number;
};
/**
 * Enrich data with watercourse properties from the watercourses lookup.
 * Used by creation modules to add metadata and time to target.
 */
export declare function enrichWithCreationWatercourseData<Data extends {
    watercourseType: WatercourseLabel;
    condition: WatercourseCondition;
    strategicSignificance: StrategicSignificanceDescription;
}>(data: Data): Data & {
    distinctiveness: "V.High" | "High" | "Medium" | "Low";
    distinctivenessScore: 2 | 4 | 8 | 6;
    conditionScore: number | "Not possible";
    strategicSignificanceCategory: "High strategic significance" | "Medium strategic significance" | "Low strategic significance";
    strategicSignificanceMultiplier: 1 | 1.15 | 1.1;
    standardTimeToTarget: 1 | 2 | 8 | 10 | 5;
    standardDifficulty: "High" | "Medium";
    tradingRules: "Same habitat required – bespoke compensation option ⚠" | "Same habitat required =" | "Better distinctiveness habitat required";
    irreplaceable: undefined;
};
/**
 * Pure calculation: computes the standardOrAdjusted message, finalTimeToTarget,
 * and isDitchFairlyCategory flag from input data.
 */
export declare function calculateTemporalAdjustments<Data extends {
    watercourseType: WatercourseLabel;
    condition: WatercourseCondition;
    habitatCreatedInAdvance: number | "30+";
    delayInStarting: number | "30+";
    standardTimeToTarget: number;
}>(data: Data): Data & {
    standardOrAdjustedTimeToTargetCondition: "Check details - Is there evidence that habitat has reached target condition? ⚠" | "Check details - Is there evidence habitat creation started/in place? ⚠" | "Check details- Delay in starting habitat in required condition? ⚠" | "Standard time to target condition applied";
    finalTimeToTarget: number;
    isDitchFairlyCategory: boolean;
};
/**
 * Lookup: attaches temporalMultiplier from finalTimeToTarget.
 */
export declare function lookupTemporalMultiplierFromFinalTime<Data extends {
    finalTimeToTarget: number;
}>(data: Data): Data & {
    temporalMultiplier: number;
};
/**
 * Backwards-compatible composed transform: pure calc → lookup.
 */
export declare function enrichWithTemporalData<Data extends {
    watercourseType: WatercourseLabel;
    condition: WatercourseCondition;
    habitatCreatedInAdvance: number | "30+";
    delayInStarting: number | "30+";
    standardTimeToTarget: number;
}>(data: Data): Data & {
    standardOrAdjustedTimeToTargetCondition: "Check details - Is there evidence that habitat has reached target condition? ⚠" | "Check details - Is there evidence habitat creation started/in place? ⚠" | "Check details- Delay in starting habitat in required condition? ⚠" | "Standard time to target condition applied";
    finalTimeToTarget: number;
    isDitchFairlyCategory: boolean;
} & {
    temporalMultiplier: number;
};
/**
 * Calculate difficulty multiplier.
 * Used by both on-site and off-site creation calculations.
 */
/**
 * Pure calculation: derives appliedDifficulty, finalDifficultyOfCreation and
 * difficultyMultiplier for watercourse creation.
 */
export declare function calculateDifficultyData(input: {
    standardOrAdjustedTimeToTargetCondition: ReturnType<typeof calculateTemporalAdjustments>['standardOrAdjustedTimeToTargetCondition'];
    standardTimeToTarget: ReturnType<typeof enrichWithCreationWatercourseData>['standardTimeToTarget'];
    standardDifficulty: ReturnType<typeof enrichWithCreationWatercourseData>['standardDifficulty'];
    habitatCreatedInAdvance: number | "30+";
}): {
    appliedDifficulty: "Standard difficulty applied" | "Low Difficulty - only applicable if all habitat created before losses ⚠";
    finalDifficultyOfCreation: string;
    difficultyMultiplier: 1 | 0.67 | 0.33;
};
export declare function enrichWithDifficultyData<Data extends {
    standardOrAdjustedTimeToTargetCondition: ReturnType<typeof enrichWithTemporalData>['standardOrAdjustedTimeToTargetCondition'];
    standardTimeToTarget: ReturnType<typeof enrichWithCreationWatercourseData>['standardTimeToTarget'];
    standardDifficulty: ReturnType<typeof enrichWithCreationWatercourseData>['standardDifficulty'];
    isDitchFairlyCategory: boolean;
    habitatCreatedInAdvance: number | "30+";
}>(data: Data): Data & {
    appliedDifficulty: "Standard difficulty applied" | "Low Difficulty - only applicable if all habitat created before losses ⚠";
    finalDifficultyOfCreation: string;
    difficultyMultiplier: 1 | 0.67 | 0.33;
};
/**
 * Calculate encroachment multipliers for creation.
 * Used by both on-site and off-site creation calculations.
 */
export declare function enrichCreationWithEncroachmentData<Data extends {
    watercourseType: WatercourseLabel;
    watercourseEncroachment: WatercourseEncroachment;
    riparianEncroachment: RiparianEncroachment;
}>(data: Data): Data & {
    watercourseEncroachmentMultiplier: 1 | 0.8 | 0.5 | 0.68;
    riparianEncroachmentMultiplier: 1 | 0.8 | 0.75 | 0.84 | 0.87 | 0.85 | 0.9 | 0.92 | 0.95 | 0.98;
};
/**
 * Calculate final net unit change for creation.
 * Used by both on-site and off-site creation calculations.
 */
/**
 * Pure calculation: derives unitsDelivered for a watercourse creation.
 */
export declare function calculateUnitsDelivered(input: {
    length: number;
    distinctivenessScore: number;
    conditionScore: number | 'Not possible';
    strategicSignificanceMultiplier: number;
    temporalMultiplier: number;
    difficultyMultiplier: number;
    watercourseEncroachmentMultiplier: number;
    riparianEncroachmentMultiplier: number;
}): {
    unitsDelivered: number;
};
export declare function enrichWithUnitsDelivered<Data extends {
    length: number;
    distinctivenessScore: number;
    conditionScore: number | 'Not possible';
    strategicSignificanceMultiplier: number;
    temporalMultiplier: number;
    difficultyMultiplier: number;
    watercourseEncroachmentMultiplier: number;
    riparianEncroachmentMultiplier: number;
}>(data: Data): Data & {
    unitsDelivered: number;
};
/**
 * Fallback years when baseline distinctiveness < proposed distinctiveness
 * (i.e., when upgrading to a rarer habitat type)
 */
export declare const DISTINCTIVENESS_UPGRADE_YEARS = 10;
/**
 * Helper to convert years value to number for arithmetic.
 * Used in enhancement calculations.
 */
export declare function yearsToNumber(years: number | "30+"): number;
/**
 * Extract baseline watercourse data including length.
 * The baseline contains the length that is being enhanced.
 * Generic to work with both OnSiteWatercourseBaseline and OffSiteWatercourseBaseline.
 */
/**
 * Pure restructure: extracts baseline-derived fields onto a flat object.
 */
export declare function calculateBaselineWatercourseData<Baseline extends {
    lengthEnhanced: number;
    watercourseType: WatercourseLabel;
    distinctivenessScore: number;
    distinctiveness: string;
    conditionScore: number | 'Not possible';
    condition: WatercourseCondition;
}>(input: {
    baseline: Baseline;
}): {
    length: number;
    _baselineWatercourse: {
        label: "Priority habitat" | "Other rivers and streams" | "Ditches" | "Canals" | "Culvert";
        distinctivenessScore: number;
        distinctivenessCategory: string;
    };
    _baselineCondition: number | "Not possible";
    _baselineConditionLabel: "Good" | "Fairly Good" | "Moderate" | "Fairly Poor" | "Poor";
};
export declare function enrichBaselineWatercourseData<Baseline extends {
    lengthEnhanced: number;
    watercourseType: WatercourseLabel;
    distinctivenessScore: number;
    distinctiveness: string;
    conditionScore: number | 'Not possible';
    condition: WatercourseCondition;
}, Data extends {
    baseline: Baseline;
}>(data: Data): Data & {
    length: number;
    _baselineWatercourse: {
        label: "Priority habitat" | "Other rivers and streams" | "Ditches" | "Canals" | "Culvert";
        distinctivenessScore: number;
        distinctivenessCategory: string;
    };
    _baselineCondition: number | "Not possible";
    _baselineConditionLabel: "Good" | "Fairly Good" | "Moderate" | "Fairly Poor" | "Poor";
};
/**
 * Enrich data with proposed watercourse properties from the watercourses lookup.
 * Used by enhancement modules.
 */
export declare function enrichProposedWatercourseData<Data extends {
    watercourseType: WatercourseLabel;
    condition: WatercourseCondition;
    strategicSignificance: StrategicSignificanceDescription;
}>(data: Data): Data & {
    distinctiveness: "V.High" | "High" | "Medium" | "Low";
    distinctivenessScore: 2 | 4 | 8 | 6;
    conditionScore: number | "Not possible";
    strategicSignificanceCategory: "High strategic significance" | "Medium strategic significance" | "Low strategic significance";
    strategicSignificanceMultiplier: 1 | 1.15 | 1.1;
    tradingRules: "Same habitat required – bespoke compensation option ⚠" | "Same habitat required =" | "Better distinctiveness habitat required";
    technicalDifficulty: "Medium" | "Low" | "N/A";
    irreplaceable: undefined;
};
/**
 * Add enhancement pathway label.
 * Format: "baseline condition to proposed condition"
 */
/**
 * Pure calculation: derives enhancementPathway label.
 */
export declare function calculateEnhancementPathway(input: {
    baselineConditionLabel: WatercourseCondition;
    condition: WatercourseCondition;
}): {
    enhancementPathway: string;
};
export declare function addEnhancementPathway<Data extends {
    _baselineConditionLabel: WatercourseCondition;
    condition: WatercourseCondition;
}>(data: Data): Data & {
    enhancementPathway: string;
};
/**
 * Lookup enhancement time to target from watercourse enhancement temporal data.
 * Uses the enhancement pathway (baseline→proposed condition) to find years to target.
 * Special case: If baseline distinctiveness < proposed distinctiveness, use fallback (10 years).
 */
/**
 * Pure calculation: branches on distinctiveness; for upgrades returns the
 * fixed upgrade years, otherwise resolves the pathway against the matrix.
 */
export declare function calculateEnhancementTimeToTarget(input: {
    baselineDistinctivenessScore: number;
    distinctivenessScore: number;
    enhancementPathway: string;
    enhancementTemporalMatrix: typeof watercourseEnhancementTemporalMatrix;
}): {
    timeToTargetCondition: number | "N/A";
};
export declare function lookupEnhancementTimeToTarget<Data extends {
    _baselineWatercourse: {
        distinctivenessScore: number;
    };
    distinctivenessScore: number;
    enhancementPathway: string;
}>(data: Data): Data & {
    timeToTargetCondition: number | "N/A";
};
/**
 * Calculate final time to target condition based on:
 * - Standard enhancement time (from enhancement temporal data)
 * - Years of watercourse enhanced in advance
 * - Years of delay in starting enhancement
 */
/**
 * Pure calculation: derives finalTimeToTargetCondition for enhancement.
 */
export declare function calculateEnhancementFinalTimeToTargetCondition<Data extends {
    timeToTargetCondition: number | "N/A";
    watercourseEnhancedInAdvance: number | "30+";
    watercourseEnhancedDelay: number | "30+";
}>(data: Data): Data & {
    finalTimeToTargetCondition: number | "30+" | "N/A";
};
/**
 * Lookup: attaches temporalMultiplier from finalTimeToTargetCondition.
 */
export declare function lookupEnhancementTemporalMultiplier<Data extends {
    finalTimeToTargetCondition: number | "30+" | "N/A";
}>(data: Data): Data & {
    temporalMultiplier: string | number;
};
/**
 * Backwards-compatible composed transform: pure calc → lookup.
 */
export declare function calculateFinalTimeToTargetValues<Data extends {
    timeToTargetCondition: number | "N/A";
    watercourseEnhancedInAdvance: number | "30+";
    watercourseEnhancedDelay: number | "30+";
}>(data: Data): Data & {
    finalTimeToTargetCondition: number | "30+" | "N/A";
} & {
    temporalMultiplier: string | number;
};
/**
 * Determine enhancement difficulty based on whether watercourse reached target before losses.
 */
export declare function calculateEnhancementDifficulty(input: {
    watercourseEnhancedInAdvance: number | "30+";
    finalTimeToTargetCondition: number | "30+" | "N/A";
    standardDifficultyOfEnhancement: Watercourse['technicalDifficultyOfEnhancement'];
}): {
    standardDifficultyOfEnhancement: "High" | "Medium" | "Low" | "Very High";
    appliedDifficultyMultiplier: string;
    finalDifficultyOfEnhancement: "High" | "Medium" | "Low" | "Very High";
    difficultyMultiplierApplied: 1 | 0.67 | 0.33 | 0.1;
};
export declare function determineEnhancementDifficulty<Data extends {
    watercourseEnhancedInAdvance: number | "30+";
    finalTimeToTargetCondition: number | "30+" | "N/A";
    technicalDifficulty: Watercourse['technicalDifficultyOfEnhancement'];
}>(data: Data): Data & {
    standardDifficultyOfEnhancement: "High" | "Medium" | "Low" | "Very High";
    appliedDifficultyMultiplier: string;
    finalDifficultyOfEnhancement: "High" | "Medium" | "Low" | "Very High";
    difficultyMultiplierApplied: 1 | 0.67 | 0.33 | 0.1;
};
/**
 * Calculate encroachment multipliers for enhancement.
 * Used by both on-site and off-site enhancement calculations.
 */
export declare function enrichEnhancementWithEncroachmentData<Data extends {
    watercourseEncroachment: WatercourseEncroachment;
    riparianEncroachment: RiparianEncroachment;
}>(data: Data): Data & {
    watercourseEncroachmentMultiplier: 1 | 0.8 | 0.5 | 0.68;
    riparianEncroachmentMultiplier: 1 | 0.8 | 0.75 | 0.84 | 0.87 | 0.85 | 0.9 | 0.92 | 0.95 | 0.98;
};
/**
 * Calculate watercourse units delivered from enhancement as NET GAIN over baseline.
 *
 * Formula (Delta Method):
 * - If proposed length > baseline length:
 *   ((proposedLength × proposedD × proposedC) - (baselineLength × baselineD × baselineC)) × difficulty × temporal
 *   + (baselineLength × baselineD × baselineC)
 *   then apply: × strategic × watercourseEncroachment × riparianEncroachment
 *
 * - If proposed length <= baseline length:
 *   ((proposedLength × proposedD × proposedC) - (proposedLength × baselineD × baselineC)) × difficulty × temporal
 *   + (proposedLength × baselineD × baselineC)
 *   then apply: × strategic × watercourseEncroachment × riparianEncroachment
 *
 * This accounts for partial enhancement scenarios where only part of baseline is enhanced.
 */
/**
 * Pure calculation: derives watercourseUnitsDelivered for an enhancement.
 */
export declare function calculateEnhancementUnitsDeliveredPure(input: {
    proposedLength: number;
    baselineLength: number;
    baselineDistinctivenessScore: number;
    baselineConditionScore: number | 'Not possible';
    distinctivenessScore: number;
    conditionScore: number | 'Not possible';
    strategicSignificanceMultiplier: number;
    temporalMultiplier: number | string;
    difficultyMultiplierApplied: number;
    watercourseEncroachmentMultiplier: number;
    riparianEncroachmentMultiplier: number;
}): {
    watercourseUnitsDelivered: number;
};
export declare function calculateEnhancementUnitsDelivered<Baseline extends {
    lengthEnhanced: number;
}, Data extends {
    length: number;
    _baselineWatercourse: any;
    _baselineCondition: number | 'Not possible';
    distinctivenessScore: number;
    conditionScore: number | 'Not possible';
    strategicSignificanceMultiplier: number;
    temporalMultiplier: number | string;
    difficultyMultiplierApplied: number;
    watercourseEncroachmentMultiplier: number;
    riparianEncroachmentMultiplier: number;
    baseline: Baseline;
}>(data: Data): Data & {
    watercourseUnitsDelivered: number;
};
//# sourceMappingURL=shared.d.ts.map