{
  "schemaVersion": "1.0",
  "id": "members",
  "title": "Thành viên",
  "purpose": "Roster chung theo capability, owner quản lý membership và guardian duyệt riêng.",
  "roles": [
    "adult"
  ],
  "group": "members-children",
  "variantOf": null,
  "layout": {
    "canvas": {
      "width": 390,
      "height": 844
    },
    "responsive": {
      "minimumWidth": 360,
      "maximumWidth": 430,
      "scroll": "vertical",
      "safeAreaBottom": true,
      "fontScale": "native dynamic type; reflow without clipping",
      "keyboard": "composer sticky within resized viewport; dialog scrolls; no fixed keyboard overlay"
    },
    "regions": [
      {
        "id": "header",
        "order": 0,
        "type": "safe-area/header",
        "height": "intrinsic"
      },
      {
        "id": "content",
        "order": 1,
        "type": "purpose-specific members",
        "componentIds": [
          "screen-header",
          "members-0",
          "members-1",
          "screen-actions",
          "primary-navigation"
        ]
      },
      {
        "id": "actions",
        "order": 2,
        "type": "one primary + secondary controls"
      },
      {
        "id": "navigation",
        "order": 3,
        "type": "adult-four-tabs"
      }
    ]
  },
  "components": [
    {
      "id": "screen-header",
      "type": "Header",
      "props": {
        "homeLabel": "Nhà Lá",
        "scopeGate": "A",
        "backTarget": "members",
        "settingsTarget": "settings"
      },
      "tokens": {
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Thanh đầu màn hình",
        "readingOrder": 0,
        "focusOrder": "back then settings"
      }
    },
    {
      "id": "members-0",
      "type": "Roster",
      "props": {
        "contentText": "A   An · bạn  Chủ nhà · phụ huynh của Bông        M   Minh  Thành viên người lớn        B   Bông  Hồ sơ trẻ · do An quản lý"
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Thành viên · Roster",
        "readingOrder": 1,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "members-1",
      "type": "SettingsGroup",
      "props": {
        "items": [
          {
            "label": "Đang chờ duyệt",
            "description": "Tưới cây nhỏ · Bông",
            "target": "approvals"
          },
          {
            "label": "Lịch sử đóng góp",
            "description": "Những việc đã được xác nhận",
            "target": "history"
          },
          {
            "label": "Thống kê theo kỳ",
            "description": "Cần Pro · không khóa lịch sử",
            "target": "contribution-statistics"
          }
        ]
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Thành viên · SettingsGroup",
        "readingOrder": 2,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "navigate-0",
            "label": "Mời người cùng nhà",
            "kind": "navigate",
            "target": "member-invite",
            "confirmationRequired": false
          },
          {
            "id": "navigate-1",
            "label": "Thêm hồ sơ trẻ",
            "kind": "navigate",
            "target": "child-profile-editor",
            "confirmationRequired": false
          },
          {
            "id": "link-members",
            "label": "Thành viên",
            "kind": "navigate",
            "target": "members",
            "confirmationRequired": false
          },
          {
            "id": "link-settings",
            "label": "Cài đặt",
            "kind": "navigate",
            "target": "settings",
            "confirmationRequired": false
          },
          {
            "id": "link-member-detail",
            "label": "Minh",
            "kind": "navigate",
            "target": "member-detail",
            "confirmationRequired": false
          },
          {
            "id": "link-child-profile-detail",
            "label": "Bông",
            "kind": "navigate",
            "target": "child-profile-detail",
            "confirmationRequired": false
          },
          {
            "id": "link-approvals",
            "label": "Việc chờ bạn duyệt",
            "kind": "navigate",
            "target": "approvals",
            "confirmationRequired": false
          },
          {
            "id": "link-history",
            "label": "Những việc đã cùng làm",
            "kind": "navigate",
            "target": "history",
            "confirmationRequired": false
          },
          {
            "id": "link-contribution-statistics",
            "label": "Công sức cùng nhà",
            "kind": "navigate",
            "target": "contribution-statistics",
            "confirmationRequired": false
          },
          {
            "id": "link-today",
            "label": "Hôm nay",
            "kind": "navigate",
            "target": "today",
            "confirmationRequired": false
          },
          {
            "id": "link-spaces",
            "label": "Không gian",
            "kind": "navigate",
            "target": "spaces",
            "confirmationRequired": false
          },
          {
            "id": "link-calendar-list",
            "label": "Lịch chung",
            "kind": "navigate",
            "target": "calendar-list",
            "confirmationRequired": false
          }
        ],
        "primaryCount": 1
      },
      "tokens": {
        "lightBackground": "{component.light.button.background}",
        "lightForeground": "{component.light.button.foreground}",
        "darkBackground": "{component.dark.button.background}",
        "darkForeground": "{component.dark.button.foreground}",
        "height": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Hành động của màn hình",
        "keyboard": true,
        "focusVisible": true,
        "disabledOnlyLowContrast": true
      }
    },
    {
      "id": "primary-navigation",
      "type": "Navigation",
      "props": {
        "items": [
          [
            "today",
            "Hôm nay",
            "home"
          ],
          [
            "spaces",
            "Không gian",
            "room"
          ],
          [
            "calendar-list",
            "Lịch",
            "calendar"
          ],
          [
            "members",
            "Thành viên",
            "users"
          ]
        ],
        "active": "members"
      },
      "tokens": {
        "activeBackground": "{semantic.light.sage}",
        "activeDarkBackground": "{semantic.dark.sage}",
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Điều hướng chính",
        "ariaCurrent": "page",
        "touchTarget": 48,
        "noColorOnly": true
      }
    }
  ],
  "fields": [],
  "states": [
    {
      "id": "owner",
      "when": "Owner capability active",
      "visibleUI": "Invite/manage membership",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "link-members",
        "link-settings",
        "link-member-detail",
        "link-child-profile-detail",
        "link-approvals",
        "link-history",
        "link-contribution-statistics",
        "link-today",
        "link-spaces",
        "link-calendar-list"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "member",
      "when": "Adult member E",
      "visibleUI": "Xem permitted roster, không invite",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "link-members",
        "link-settings",
        "link-member-detail",
        "link-child-profile-detail",
        "link-approvals",
        "link-history",
        "link-contribution-statistics",
        "link-today",
        "link-spaces",
        "link-calendar-list"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "guardian",
      "when": "Relation active",
      "visibleUI": "Duyệt đúng trẻ và device quản lý",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "link-members",
        "link-settings",
        "link-member-detail",
        "link-child-profile-detail",
        "link-approvals",
        "link-history",
        "link-contribution-statistics",
        "link-today",
        "link-spaces",
        "link-calendar-list"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "hidden-board",
      "when": "Preference hide board",
      "visibleUI": "Không hiện bảng xếp đóng góp",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "link-members",
        "link-settings",
        "link-member-detail",
        "link-child-profile-detail",
        "link-approvals",
        "link-history",
        "link-contribution-statistics",
        "link-today",
        "link-spaces",
        "link-calendar-list"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "navigate-0",
      "label": "Mời người cùng nhà",
      "kind": "navigate",
      "targetScreenId": "member-invite",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "navigate-1",
      "label": "Thêm hồ sơ trẻ",
      "kind": "navigate",
      "targetScreenId": "child-profile-editor",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "link-members",
      "label": "Thành viên",
      "kind": "navigate",
      "targetScreenId": "members",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-settings",
      "label": "Cài đặt",
      "kind": "navigate",
      "targetScreenId": "settings",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-member-detail",
      "label": "Minh",
      "kind": "navigate",
      "targetScreenId": "member-detail",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-child-profile-detail",
      "label": "Bông",
      "kind": "navigate",
      "targetScreenId": "child-profile-detail",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-approvals",
      "label": "Việc chờ bạn duyệt",
      "kind": "navigate",
      "targetScreenId": "approvals",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-history",
      "label": "Những việc đã cùng làm",
      "kind": "navigate",
      "targetScreenId": "history",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-contribution-statistics",
      "label": "Công sức cùng nhà",
      "kind": "navigate",
      "targetScreenId": "contribution-statistics",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-today",
      "label": "Hôm nay",
      "kind": "navigate",
      "targetScreenId": "today",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-spaces",
      "label": "Không gian",
      "kind": "navigate",
      "targetScreenId": "spaces",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-calendar-list",
      "label": "Lịch chung",
      "kind": "navigate",
      "targetScreenId": "calendar-list",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    }
  ],
  "dataBindings": [
    {
      "source": "GET /v1/households/current",
      "shape": {
        "member_id": "opaque ID",
        "kind": "adult|child",
        "display_name": "string",
        "state": "active|archived",
        "owner": "server capability",
        "guardian_relations": "target-specific"
      },
      "sample": {
        "member_id": "minh",
        "kind": "adult",
        "display_name": "Minh",
        "state": "active",
        "owner": false,
        "guardian_relations": []
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Thành viên",
    "primary": "Mời người cùng nhà",
    "empty": null,
    "notices": [],
    "locale": "vi",
    "demoLabel": "Bản thiết kế · dữ liệu mẫu · không kết nối dịch vụ"
  },
  "implementation": {
    "nativeRoute": "/design/members",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "apiRefs": [
      "GET /v1/households/current",
      "GET /v1/households/{hid}/children",
      "GET /v1/households/{hid}/history"
    ],
    "newContractRefs": [],
    "notes": [
      "GET /v1/households/current trả household/membership/adult members theo native api.ts; children theo Phase3 scoped DTO.",
      "Tất cả ví dụ là dữ liệu thiết kế, không bằng chứng native/API/store đã chạy.",
      "Native route dưới đây là đề xuất mapping cho agent, không tuyên bố route source đã tồn tại.",
      "Mọi mutation dùng envelope {data,version,household_revision,replayed}, stable Idempotency-Key và expected_version khi sửa."
    ],
    "integrationStatus": "design complete; local static/draft interactions; native/API adapters pending",
    "sourceAuthority": [
      "docs/product-brief.md",
      "plans/261013-1409-sweepy-vietnam-mobile/mobile-flows.md",
      "plans/261013-1409-sweepy-vietnam-mobile/api-contracts.md",
      "packages/domain/src/contracts/phase2.ts",
      "packages/domain/src/index.ts",
      "packages/domain/src/contracts/phase3.ts",
      "packages/domain/src/contracts/billing.ts",
      "apps/mobile/src/lib/api.ts"
    ],
    "capability": "A",
    "errors": {
      "401": "Stop queue; adult login or child re-pair without parent account.",
      "403": "Do not retry lost capability. FEATURE_REQUIRED never grants Pro.",
      "409": "Fetch canonical scoped state; review/reconfirm new intent, do not rewrite old replay payload.",
      "422": "Field error with retained draft.",
      "429": "Respect Retry-After.",
      "503": "Backoff only retryable commands with original key."
    }
  }
}
