{
  "meta": {
    "is_partial": true,
    "description": "통화 선택 드롭다운"
  },
  "type": "basic",
  "name": "Div",
  "props": { "className": "relative" },
  "children": [
    {
      "type": "basic",
      "name": "Button",
      "props": { "className": "flex items-center gap-1.5 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors" },
      "children": [
        { "type": "basic", "name": "Icon", "props": { "name": "globe", "className": "w-4 h-4" } },
        { "type": "basic", "name": "Span", "text": "{{_global.preferredCurrency ?? 'KRW'}}" },
        { "type": "basic", "name": "Icon", "props": { "name": "chevron-down", "className": "w-3 h-3" } }
      ],
      "actions": [
        {
          "type": "click",
          "handler": "setState",
          "params": { "target": "local", "showCurrencyDropdown": "{{!_local.showCurrencyDropdown}}" }
        }
      ]
    },
    {
      "comment": "드롭다운 메뉴",
      "type": "basic",
      "name": "Div",
      "if": "{{_local.showCurrencyDropdown}}",
      "props": { "className": "absolute right-0 top-full mt-1 w-44 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 py-1 overflow-hidden" },
      "children": [
        {
          "type": "basic",
          "name": "Div",
          "iteration": { "source": "{{_global.availableCurrencies ?? []}}", "item_var": "currency" },
          "children": [
            {
              "type": "basic",
              "name": "Button",
              "props": {
                "className": "w-full px-4 py-2.5 text-left text-sm flex items-center gap-3 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors {{_global.preferredCurrency === currency.code ? 'bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400' : 'text-gray-700 dark:text-gray-300'}}"
              },
              "children": [
                { "type": "basic", "name": "Span", "props": { "className": "text-base" }, "text": "{{currency.flag}}" },
                {
                  "type": "basic",
                  "name": "Div",
                  "props": { "className": "flex-1" },
                  "children": [
                    { "type": "basic", "name": "Span", "props": { "className": "font-medium" }, "text": "{{currency.code}}" },
                    { "type": "basic", "name": "Span", "props": { "className": "text-gray-500 dark:text-gray-400 ml-1" }, "text": "({{currency.symbol}})" }
                  ]
                },
                {
                  "type": "basic",
                  "name": "Icon",
                  "if": "{{_global.preferredCurrency === currency.code}}",
                  "props": { "name": "check", "className": "w-4 h-4" }
                }
              ],
              "actions": [
                {
                  "type": "click",
                  "handler": "sequence",
                  "actions": [
                    { "handler": "setState", "params": { "target": "global", "preferredCurrency": "{{currency.code}}" } },
                    { "handler": "saveToLocalStorage", "params": { "key": "g7_preferred_currency", "value": "{{currency.code}}" } },
                    { "handler": "setState", "params": { "target": "local", "showCurrencyDropdown": false } }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "comment": "배경 클릭 시 닫기",
      "type": "basic",
      "name": "Div",
      "if": "{{_local.showCurrencyDropdown}}",
      "props": { "className": "fixed inset-0 z-40" },
      "actions": [
        {
          "type": "click",
          "handler": "setState",
          "params": { "target": "local", "showCurrencyDropdown": false }
        }
      ]
    }
  ]
}
