"use client";
import { useRef, useEffect } from 'react';
import { jsx } from 'react/jsx-runtime';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
function TechnicalAnalysis({
  symbol = "NASDAQ:AAPL",
  interval = "15m",
  width = "100%",
  height = "500",
  locale = "en",
  colorTheme = "dark",
  isTransparent = false,
  showIntervalTabs = true,
  displayMode = "single"
}) {
  const containerRef = useRef(null);
  useEffect(() => {
    if (!containerRef.current) return;
    if (containerRef.current.dataset.initialized === "true") {
      return;
    }
    containerRef.current.dataset.initialized = "true";
    const script = document.createElement("script");
    script.src = "https://s3.tradingview.com/external-embedding/embed-widget-technical-analysis.js";
    script.async = true;
    script.innerHTML = JSON.stringify({
      interval,
      width,
      isTransparent,
      height,
      symbol,
      showIntervalTabs,
      displayMode,
      locale,
      colorTheme
    });
    containerRef.current.appendChild(script);
    return () => {
      if (containerRef.current) {
        delete containerRef.current.dataset.initialized;
        const scripts = containerRef.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, [symbol, interval, width, height, locale, colorTheme, isTransparent, showIntervalTabs, displayMode]);
  return /* @__PURE__ */ jsx("div", { className: "tradingview-widget-container w-full h-[500px]", ref: containerRef, children: /* @__PURE__ */ jsx("div", { className: "tradingview-widget-container__widget h-full" }) });
}
__name(TechnicalAnalysis, "TechnicalAnalysis");

export { TechnicalAnalysis as default };
