"use client";
'use strict';

var lucideReact = require('lucide-react');
var jsxRuntime = require('react/jsx-runtime');

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
function PositionsList({ positions, onPositionClick }) {
  const getTickerFromSymbol = /* @__PURE__ */ __name((symbol) => {
    return symbol.split(":")[1] || symbol;
  }, "getTickerFromSymbol");
  if (positions.length === 0) {
    return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center py-8 text-white/40", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: "No open positions" }) });
  }
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 space-y-2", children: positions.map((position) => {
    const pl = (position.currentPrice - position.avgPrice) * position.shares;
    const plPercent = (position.currentPrice - position.avgPrice) / position.avgPrice * 100;
    const totalValue = position.currentPrice * position.shares;
    return /* @__PURE__ */ jsxRuntime.jsxs(
      "div",
      {
        className: `bg-white/5 rounded-lg p-3 ${onPositionClick ? "cursor-pointer hover:bg-white/10 transition-colors" : ""}`,
        onClick: () => onPositionClick?.(position),
        children: [
          /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold text-white", children: getTickerFromSymbol(position.symbol) }),
            /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-1 text-sm ${pl >= 0 ? "text-success" : "text-danger"}`, children: [
              pl >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingUp, { size: 14 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingDown, { size: 14 }),
              pl >= 0 ? "+" : "",
              plPercent.toFixed(2),
              "%"
            ] })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2 text-xs", children: [
            /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Shares" }),
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white font-medium", children: position.shares })
            ] }),
            /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Avg Price" }),
              /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white font-medium", children: [
                "$",
                position.avgPrice.toFixed(2)
              ] })
            ] })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2 text-xs mt-2 pt-2 border-t border-white/10", children: [
            /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Current Price" }),
              /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white font-medium", children: [
                "$",
                position.currentPrice.toFixed(2)
              ] })
            ] }),
            /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Total Value" }),
              /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white font-medium", children: [
                "$",
                totalValue.toFixed(2)
              ] })
            ] })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 pt-2 border-t border-white/10", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center text-xs", children: [
            /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-white/60", children: "P&L" }),
            /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `font-semibold ${pl >= 0 ? "text-success" : "text-danger"}`, children: [
              pl >= 0 ? "+" : "",
              "$",
              pl.toFixed(2)
            ] })
          ] }) })
        ]
      },
      position.symbol
    );
  }) });
}
__name(PositionsList, "PositionsList");

exports.PositionsList = PositionsList;
