[
  {
    "version": "1.0",
    "createSurface": {
      "surfaceId": "integracoes-c21",
      "catalogId": "https://uinova.walderpinheiro.com.br/a2ui/catalog/v1.json",
      "components": [
        {
          "id": "root",
          "component": "Card",
          "title": "Integrações",
          "description": "Conecte ferramentas ao seu workspace.",
          "variant": "outlined",
          "child": "abas"
        },
        {
          "id": "abas",
          "component": "Tabs",
          "variant": "underline",
          "value": { "@path": "/ui/aba" },
          "tabs": [
            { "value": "conectadas", "label": "Conectadas", "icon": "plug", "child": "lista" },
            { "value": "ajuda", "label": "Perguntas frequentes", "icon": "help", "child": "faq" }
          ]
        },
        {
          "id": "lista",
          "component": "List",
          "dividers": true,
          "gap": "3",
          "children": { "componentId": "item_integracao", "path": "/integracoes" }
        },
        {
          "id": "item_integracao",
          "component": "Row",
          "justify": "spaceBetween",
          "children": ["item_info", "item_controles"]
        },
        {
          "id": "item_info",
          "component": "Column",
          "gap": "1",
          "children": ["item_nome", "item_desc"]
        },
        { "id": "item_nome", "component": "Text", "fontWeight": "semibold", "text": { "@path": "nome" } },
        { "id": "item_desc", "component": "Text", "variant": "body-small", "tone": "muted", "text": { "@path": "descricao" } },
        {
          "id": "item_controles",
          "component": "Row",
          "gap": "3",
          "children": ["item_status", "item_ativa", "item_remover"]
        },
        { "id": "item_status", "component": "Badge", "variant": "subtle", "text": { "@path": "statusTexto" } },
        {
          "id": "item_ativa",
          "component": "Switch",
          "label": "Ativa",
          "value": { "@path": "ativa" }
        },
        {
          "id": "item_remover",
          "component": "Button",
          "variant": "icon",
          "child": "item_remover_icone",
          "@accessibility": {
            "label": { "@call": "formatString", "args": { "value": "Remover ${nome}" } }
          },
          "action": {
            "event": { "name": "integracao.pedirRemocao", "context": { "id": { "@path": "id" }, "nome": { "@path": "nome" } } }
          }
        },
        { "id": "item_remover_icone", "component": "Icon", "icon": "trash" },
        {
          "id": "faq",
          "component": "Accordion",
          "variant": "divided",
          "children": ["faq_1", "faq_2"]
        },
        { "id": "faq_1", "component": "AccordionItem", "value": "dados", "title": "Quais dados a integração acessa?", "child": "faq_1_txt" },
        { "id": "faq_1_txt", "component": "Text", "text": "Somente os escopos listados na tela de autorização do provedor." },
        { "id": "faq_2", "component": "AccordionItem", "value": "remover", "title": "O que acontece ao remover?", "child": "faq_2_txt" },
        { "id": "faq_2_txt", "component": "Text", "text": "Os tokens são revogados na hora; o histórico importado é mantido por 30 dias." },
        {
          "id": "confirmar",
          "component": "Modal",
          "variant": "confirmation",
          "intent": "destructive",
          "size": "sm",
          "title": { "@call": "formatString", "args": { "value": "Remover ${/ui/remocao/nome}?" } },
          "description": "Os tokens de acesso serão revogados imediatamente.",
          "confirmText": "Remover",
          "cancelText": "Cancelar",
          "open": { "@path": "/ui/remocao/aberto" },
          "confirmAction": {
            "event": { "name": "integracao.remover", "context": { "id": { "@path": "/ui/remocao/id" } } }
          },
          "cancelAction": {
            "event": { "name": "integracao.cancelarRemocao", "context": { "id": { "@path": "/ui/remocao/id" } } }
          }
        }
      ],
      "dataModel": {
        "ui": { "aba": "conectadas", "remocao": { "aberto": false, "id": null, "nome": "" } },
        "integracoes": [
          { "id": "slack", "nome": "Slack", "descricao": "Notificações em canais", "statusTexto": "Sincronizado", "ativa": true },
          { "id": "drive", "nome": "Google Drive", "descricao": "Anexos de documentos", "statusTexto": "Há 2 h", "ativa": true },
          { "id": "jira", "nome": "Jira", "descricao": "Abertura de tickets", "statusTexto": "Pausada", "ativa": false }
        ]
      }
    }
  },
  {
    "version": "1.0",
    "updateComponents": {
      "surfaceId": "integracoes-c21",
      "components": [
        {
          "id": "root",
          "component": "Card",
          "title": "Integrações",
          "description": "Conecte ferramentas ao seu workspace.",
          "variant": "outlined",
          "child": "conteudo"
        },
        { "id": "conteudo", "component": "Column", "gap": "4", "children": ["abas", "confirmar"] }
      ]
    }
  },
  {
    "version": "1.0",
    "updateDataModel": {
      "surfaceId": "integracoes-c21",
      "path": "/ui/remocao",
      "value": { "aberto": true, "id": "jira", "nome": "Jira" }
    }
  },
  {
    "version": "1.0",
    "updateDataModel": {
      "surfaceId": "integracoes-c21",
      "path": "/integracoes/2",
      "value": null
    }
  },
  {
    "version": "1.0",
    "updateDataModel": {
      "surfaceId": "integracoes-c21",
      "path": "/ui/remocao/aberto",
      "value": false
    }
  }
]
