"""v3 Step 클래스 레지스트리."""
from app.core.steps.planning_doc_step import PlanningDocAnalysisStep
from app.core.steps.summary_steps import EpisodeSummaryStep, SceneSummaryStep, VisualWorldRulesStep
from app.core.steps.entity_steps import (
    EntityExtractStep, EntityExtractCharacterStep, EntityExtractLocationStep,
    EntityExtractPropStep, EntityFilterStep, EntityMergeStep, EntityDetailStep, EntityT2iStep,
    EntityAllCharacterStep, EntityAllLocationStep, EntityAllPropStep,
)
from app.core.steps.entity_relation_step import EntityRelationStep
from app.core.steps.shot_director_step import ShotDirectorStep
from app.core.steps.text_steps import TextCleanupStep
from app.core.steps.scene_steps import SceneSegmentationStep, SceneSplitStep, SceneSaveStep
from app.core.steps.character_list_step import EntityCharacterListStep
from app.core.steps.beat_shot_steps import BeatExtractStep, ShotExtractStep
from app.core.steps.shot_validator_step import ShotValidatorStep
from app.core.steps.shot_selection_step import ShotSelectionStep
from app.core.steps.shot_cinematography_step import ShotCinematographyStep
from app.core.steps.shot_dependency_step import ShotDependencyStep
from app.core.steps.shot_dependency_t2i_step import ShotDependencyT2iStep
from app.core.steps.director_steps import SceneDirectorStep, SceneCinematographyStep, SceneDependencyStep
from app.core.steps.outlook_steps import (
    OutlookPhase1Step, OutlookPhase2Step, OutlookPhase3Step,
    OutlookExtractionStep, OutlookDedupStep,
)
from app.core.steps.detail_steps import SceneDetailStep, SceneVerifyStep
from app.core.steps.scene_consistency_step import SceneConsistencyStep
from app.core.steps.location_consistency_step import LocationConsistencyStep
from app.core.steps.scene_camera_flow_step import SceneCameraFlowStep
from app.core.steps.t2i_review_step import T2iReviewStep
from app.core.steps.shot_staging_step import ShotStagingStep
from app.core.steps.background_chain_planning_step import BackgroundChainPlanningStep
from app.core.steps.background_chain_render_step import BackgroundChainRenderStep
from app.core.steps.shot_essence_extraction_step import ShotEssenceExtractionStep
from app.core.steps.location_floor_plan_step import LocationFloorPlanStep
from app.core.steps.background_planner_step import BackgroundPlannerStep
from app.core.steps.background_classify_step import BackgroundClassifyStep
from app.core.steps.background_master_plan_step import BackgroundMasterPlanStep
from app.core.steps.floor_plan_prompt_step import FloorPlanPromptStep
from app.core.steps.floor_plan_render_step import FloorPlanRenderStep
from app.core.steps.floor_plan_light_sidecar_step import (
    FloorPlanLightSidecarStep,
)
from app.core.steps.floor_plan_overlay_payload_step import (
    FloorPlanOverlayPayloadStep,
)
from app.core.steps.base_location_dossier_step import (
    BaseLocationDossierStep,
)
from app.core.steps.floor_plan_geometry_readback_step import (
    FloorPlanGeometryReadbackStep,
)
from app.core.steps.floor_plan_semantic_readback_step import (
    FloorPlanSemanticReadbackStep,
)
from app.core.steps.shot_projection_card_step import (
    ShotProjectionCardStep,
)
from app.core.steps.bg_space_partition_step import (
    BgSpacePartitionStep,
)
from app.core.steps.dwelling_zone_map_step import (
    DwellingZoneMapStep,
)
from app.core.steps.space_set_bg_step import (
    SpaceSetBgStep,
)
from app.core.steps.shot_aware_bg_render_plan_step import (
    ShotAwareBgRenderPlanStep,
)
from app.core.steps.visual_continuity_anchor_step import (
    VisualContinuityAnchorStep,
)
from app.core.steps.zoom_continuity_anchor_step import (
    ZoomContinuityAnchorStep,
)
from app.core.steps.outdoor_site_layout_step import (
    OutdoorSiteLayoutStep,
)
from app.core.steps.outdoor_place_spec_step import (
    OutdoorPlaceSpecStep,
)
from app.core.steps.outdoor_place_canon_step import (
    OutdoorPlaceCanonStep,
)
from app.core.steps.outdoor_shot_grounding_step import (
    OutdoorShotGroundingStep,
)
from app.core.steps.outdoor_frame_mode_step import (
    OutdoorFrameModeStep,
)
from app.core.steps.outdoor_lane_plan_step import (
    OutdoorLanePlanStep,
)
from app.core.steps.reference_acquisition_step import (  # noqa: E402
    ReferenceAcquisitionStep,
)
from app.core.steps.outdoor_structure_form_reference_step import (
    OutdoorStructureFormReferenceStep,
)
from app.core.steps.outdoor_structure_seed_step import (
    OutdoorStructureSeedStep,
)
from app.core.steps.background_share_plan_step import (
    BackgroundSharePlanStep,
)
from app.core.steps.shot_ref_classify_step import (
    ShotRefClassifyStep,
)
from app.core.steps.shot_continuity_step import (
    ShotContinuityStep,
)
from app.core.steps.shot_conti_light_step import (
    ShotContiLightStep,
)
from app.core.steps.background_prompt_step import BackgroundPromptStep
from app.core.steps.background_render_step import BackgroundRenderStep
from app.core.steps.episode_reference_policy_step import EpisodeReferencePolicyStep
from app.core.steps.grounding_chunk_step import GroundingChunkStep
from app.core.steps.grounding_screen_step import GroundingScreenStep
from app.core.steps.grounding_steps import (GroundingA0Step,
                                            GroundingPlanStep,
                                            GroundingResearchStep)

# Image steps — import from existing image_steps.py
try:
    from app.core.steps.image_steps import WorldGuideStep, RefImageGenStep, CompositeImageGenStep, CharacterStateVariantStep, SceneImagePipelineStep
except ImportError:
    WorldGuideStep = RefImageGenStep = CompositeImageGenStep = CharacterStateVariantStep = SceneImagePipelineStep = None

# ProjectSummaryStep — check if it exists in summary_steps
try:
    from app.core.steps.summary_steps import ProjectSummaryStep
except ImportError:
    ProjectSummaryStep = None

STEP_CLASSES = {
    "planning_doc_analysis": PlanningDocAnalysisStep,
    "text_cleanup": TextCleanupStep,
    "scene_segmentation": SceneSegmentationStep,
    "episode_summary": EpisodeSummaryStep,
    "visual_world_rules": VisualWorldRulesStep,
    "scene_split": SceneSplitStep,
    "scene_save": SceneSaveStep,
    "scene_summary": SceneSummaryStep,
    "entity_character_list": EntityCharacterListStep,
    "beat_extract": BeatExtractStep,
    "shot_extract": ShotExtractStep,
    "shot_validator": ShotValidatorStep,
    "shot_selection": ShotSelectionStep,
    "shot_cinematography": ShotCinematographyStep,
    "shot_dependency": ShotDependencyStep,
    "shot_dependency_t2i": ShotDependencyT2iStep,
    "entity_extract": EntityExtractStep,  # legacy v2/v3 — step_manifest에는 없음, entity_steps.py:366 _load_prev_checkpoint fallback 전용
    "grounding_a0": GroundingA0Step,
    "entity_all_character": EntityAllCharacterStep,
    "entity_all_location": EntityAllLocationStep,
    "entity_all_prop": EntityAllPropStep,
    "entity_extract_character": EntityExtractCharacterStep,
    "entity_extract_location": EntityExtractLocationStep,
    "entity_extract_prop": EntityExtractPropStep,
    "entity_filter": EntityFilterStep,
    "entity_relation": EntityRelationStep,
    "shot_director": ShotDirectorStep,
    "entity_merge": EntityMergeStep,
    "grounding_plan": GroundingPlanStep,
    "grounding_chunk": GroundingChunkStep,
    "grounding_screen": GroundingScreenStep,
    "reference_acquisition": ReferenceAcquisitionStep,
    "grounding_research": GroundingResearchStep,
    "entity_detail": EntityDetailStep,
    "entity_t2i": EntityT2iStep,
    "scene_director": SceneDirectorStep,
    "scene_cinematography": SceneCinematographyStep,
    "scene_dependency": SceneDependencyStep,
    "outlook_phase1": OutlookPhase1Step,
    "outlook_phase2": OutlookPhase2Step,
    "outlook_phase3": OutlookPhase3Step,
    "outlook_extraction": OutlookExtractionStep,
    "scene_consistency": SceneConsistencyStep,
    "location_consistency": LocationConsistencyStep,
    "scene_camera_flow": SceneCameraFlowStep,
    "scene_detail": SceneDetailStep,
    "scene_verify": SceneVerifyStep,
    "outlook_dedup": OutlookDedupStep,
    "t2i_review": T2iReviewStep,
    "shot_staging": ShotStagingStep,
    "background_chain_planning": BackgroundChainPlanningStep,
    "background_chain_render": BackgroundChainRenderStep,
    "shot_essence_extraction": ShotEssenceExtractionStep,
    "location_floor_plan": LocationFloorPlanStep,
    "background_planner": BackgroundPlannerStep,
    "background_classify": BackgroundClassifyStep,
    "background_master_plan": BackgroundMasterPlanStep,
    "floor_plan_prompt": FloorPlanPromptStep,
    "floor_plan_render": FloorPlanRenderStep,
    "floor_plan_light_sidecar": FloorPlanLightSidecarStep,
    "floor_plan_overlay_payload": FloorPlanOverlayPayloadStep,
    "base_location_dossier": BaseLocationDossierStep,
    "floor_plan_geometry_readback": FloorPlanGeometryReadbackStep,
    "floor_plan_semantic_readback": FloorPlanSemanticReadbackStep,
    "shot_projection_card": ShotProjectionCardStep,
    "bg_space_partition": BgSpacePartitionStep,
    "dwelling_zone_map": DwellingZoneMapStep,
    "space_set_bg": SpaceSetBgStep,
    "shot_aware_bg_render_plan": ShotAwareBgRenderPlanStep,
    "visual_continuity_anchor": VisualContinuityAnchorStep,
    "zoom_continuity_anchor": ZoomContinuityAnchorStep,
    "outdoor_site_layout": OutdoorSiteLayoutStep,
    "outdoor_place_spec": OutdoorPlaceSpecStep,
    "outdoor_place_canon": OutdoorPlaceCanonStep,
    "outdoor_shot_grounding": OutdoorShotGroundingStep,
    "outdoor_lane_plan": OutdoorLanePlanStep,
    "outdoor_frame_mode": OutdoorFrameModeStep,
    "outdoor_structure_form_reference": OutdoorStructureFormReferenceStep,
    "outdoor_structure_seed": OutdoorStructureSeedStep,
    "shot_ref_classify": ShotRefClassifyStep,
    "background_share_plan": BackgroundSharePlanStep,
    "shot_continuity": ShotContinuityStep,
    "shot_conti_light": ShotContiLightStep,
    "background_prompt": BackgroundPromptStep,
    "background_render": BackgroundRenderStep,
    "episode_reference_policy": EpisodeReferencePolicyStep,
}

# Add image steps if available
if WorldGuideStep:
    STEP_CLASSES["world_guide"] = WorldGuideStep
if RefImageGenStep:
    STEP_CLASSES["ref_image_gen"] = RefImageGenStep
if CompositeImageGenStep:
    STEP_CLASSES["composite_image_gen"] = CompositeImageGenStep
if CharacterStateVariantStep:
    STEP_CLASSES["character_state_variant"] = CharacterStateVariantStep
if SceneImagePipelineStep:
    STEP_CLASSES["scene_image_pipeline"] = SceneImagePipelineStep
if ProjectSummaryStep:
    STEP_CLASSES["project_summary"] = ProjectSummaryStep
