"use client";

import React from "react";
import { AutoRegisteringComponentRenderer } from "../../../AutoRegisteringComponentRenderer";
import { V2LocationSwapSelectorDefinition } from "./index";
import { LocationSwapSelectorComponent } from "./LocationSwapSelectorComponent";

/**
 * LocationSwapSelector 렌더러
 */
export class LocationSwapSelectorRenderer extends AutoRegisteringComponentRenderer {
  static componentDefinition = V2LocationSwapSelectorDefinition;

  render(): React.ReactElement {
    const { component, formData, onFormDataChange, isDesignMode, style, userId } = this.props;

    const componentConfig = component?.componentConfig || {};

    return (
      <LocationSwapSelectorComponent
        id={component?.id}
        style={style}
        isDesignMode={isDesignMode}
        formData={formData}
        onFormDataChange={onFormDataChange}
        componentConfig={componentConfig}
        userId={userId}
      />
    );
  }
}

// 자동 등록 실행
LocationSwapSelectorRenderer.registerSelf();

// Hot Reload 지원 (개발 모드)
if (process.env.NODE_ENV === "development") {
  LocationSwapSelectorRenderer.enableHotReload();
}

