{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mrdoge-bet-slip-adapter",
  "title": "Bet Slip Adapter (Mr. Doge SDK)",
  "description": "Builds a BetSlipPick from a real match, one of its markets, and a selected line id.",
  "dependencies": [
    "@mrdoge/protocol"
  ],
  "registryDependencies": [
    "bet-slip"
  ],
  "files": [
    {
      "path": "lib/mrdoge-adapters/bet-slip.ts",
      "content": "import type { MatchDetail, Market } from \"@mrdoge/protocol\"\nimport type { BetSlipPick } from \"@/registry/mrdoge-ui/bet-slip/bet-slip\"\nimport type { OddsMovement } from \"@/registry/mrdoge-ui/odds-selector/odds-selector\"\n\n// Over/Under outcomes only carry a generic \"O\"/\"U\" code, no threshold in\n// it. The threshold lives in the caption instead (\"Over 1.5\", \"Under\n// 1.5\"), so that's what has to be parsed for conflict-checking.\nfunction parseThreshold(caption: string | null | undefined): number | undefined {\n  const match = caption?.match(/[\\d.]+/)\n  const value = match ? parseFloat(match[0]) : NaN\n  return Number.isNaN(value) ? undefined : value\n}\n\n// Public, unauthenticated, cached CDN. Not part of the Team shape itself.\n// See /docs/reference/images.\nfunction teamLogoUrl(teamId: number) {\n  return `https://api.mrdoge.co/images/teams/${teamId}.png`\n}\n\n/**\n * Builds a `BetSlipPick` from a real match, one of its markets, and a\n * selected line id. A pick is basically a selected odds line. Returns\n * `undefined` if `lineId` isn't found in `market.lines`; filter those out\n * when mapping several selections at once.\n *\n * `movementById` is optional. Pass `useOddsMovement(market)`'s result to\n * color the pick's price as odds change; omit it and the price renders\n * without any color change.\n */\nexport function toBetSlipPick(\n  match: MatchDetail,\n  market: Market,\n  lineId: string,\n  movementById?: Record<string, OddsMovement>\n): BetSlipPick | undefined {\n  const line = market.lines.find((l) => l.id === lineId)\n  if (!line) return undefined\n\n  const isTotals = line.code.startsWith(\"O\") || line.code.startsWith(\"U\")\n\n  return {\n    id: line.id,\n    eventLabel: `${match.homeTeam.name} vs ${match.awayTeam.name}`,\n    market: market.displayName,\n    selection: line.caption ?? line.code,\n    price: line.price,\n    movement: movementById?.[line.id],\n    unavailable: !line.isAvailable,\n    home: { name: match.homeTeam.name, logoUrl: teamLogoUrl(match.homeTeam.id) },\n    away: { name: match.awayTeam.name, logoUrl: teamLogoUrl(match.awayTeam.id) },\n    kickoff: match.startTime,\n    matchId: match.id,\n    betType: market.betType,\n    code: line.code,\n    threshold: isTotals ? parseThreshold(line.caption) : undefined,\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/mrdoge-adapters/bet-slip.ts"
    }
  ],
  "type": "registry:lib"
}