@dxos/react-ui-gameboard 0.8.2-staging.7ac8446 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/lib/browser/index.mjs +667 -536
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +667 -536
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +667 -536
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/Board/Container.d.ts +3 -3
  11. package/dist/types/src/Board/Container.d.ts.map +1 -1
  12. package/dist/types/src/Board/types.d.ts.map +1 -1
  13. package/dist/types/src/Board/util.d.ts.map +1 -1
  14. package/dist/types/src/Chessboard/Chessboard.stories.d.ts.map +1 -1
  15. package/dist/types/src/Chessboard/chess.d.ts.map +1 -1
  16. package/dist/types/src/gen/pieces/chess/alpha/bB.d.ts.map +1 -1
  17. package/dist/types/src/gen/pieces/chess/alpha/bK.d.ts.map +1 -1
  18. package/dist/types/src/gen/pieces/chess/alpha/bN.d.ts.map +1 -1
  19. package/dist/types/src/gen/pieces/chess/alpha/bP.d.ts.map +1 -1
  20. package/dist/types/src/gen/pieces/chess/alpha/bQ.d.ts.map +1 -1
  21. package/dist/types/src/gen/pieces/chess/alpha/bR.d.ts.map +1 -1
  22. package/dist/types/src/gen/pieces/chess/alpha/wB.d.ts.map +1 -1
  23. package/dist/types/src/gen/pieces/chess/alpha/wK.d.ts.map +1 -1
  24. package/dist/types/src/gen/pieces/chess/alpha/wN.d.ts.map +1 -1
  25. package/dist/types/src/gen/pieces/chess/alpha/wP.d.ts.map +1 -1
  26. package/dist/types/src/gen/pieces/chess/alpha/wQ.d.ts.map +1 -1
  27. package/dist/types/src/gen/pieces/chess/alpha/wR.d.ts.map +1 -1
  28. package/dist/types/src/gen/pieces/chess/cburnett/bB.d.ts.map +1 -1
  29. package/dist/types/src/gen/pieces/chess/cburnett/bK.d.ts.map +1 -1
  30. package/dist/types/src/gen/pieces/chess/cburnett/bN.d.ts.map +1 -1
  31. package/dist/types/src/gen/pieces/chess/cburnett/bP.d.ts.map +1 -1
  32. package/dist/types/src/gen/pieces/chess/cburnett/bQ.d.ts.map +1 -1
  33. package/dist/types/src/gen/pieces/chess/cburnett/bR.d.ts.map +1 -1
  34. package/dist/types/src/gen/pieces/chess/cburnett/wB.d.ts.map +1 -1
  35. package/dist/types/src/gen/pieces/chess/cburnett/wK.d.ts.map +1 -1
  36. package/dist/types/src/gen/pieces/chess/cburnett/wN.d.ts.map +1 -1
  37. package/dist/types/src/gen/pieces/chess/cburnett/wP.d.ts.map +1 -1
  38. package/dist/types/src/gen/pieces/chess/cburnett/wQ.d.ts.map +1 -1
  39. package/dist/types/src/gen/pieces/chess/cburnett/wR.d.ts.map +1 -1
  40. package/dist/types/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +13 -12
  42. package/src/Board/Container.tsx +2 -2
  43. package/src/Chessboard/chess.ts +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/Board/context.ts", "../../../src/Board/types.ts", "../../../src/Board/util.ts", "../../../src/Board/Board.tsx", "../../../src/Board/Container.tsx", "../../../src/Board/Square.tsx", "../../../src/Board/Piece.tsx", "../../../src/Chessboard/chess.ts", "../../../src/gen/pieces/chess/alpha/bB.tsx", "../../../src/gen/pieces/chess/alpha/bK.tsx", "../../../src/gen/pieces/chess/alpha/bN.tsx", "../../../src/gen/pieces/chess/alpha/bP.tsx", "../../../src/gen/pieces/chess/alpha/bQ.tsx", "../../../src/gen/pieces/chess/alpha/bR.tsx", "../../../src/gen/pieces/chess/alpha/wB.tsx", "../../../src/gen/pieces/chess/alpha/wK.tsx", "../../../src/gen/pieces/chess/alpha/wN.tsx", "../../../src/gen/pieces/chess/alpha/wP.tsx", "../../../src/gen/pieces/chess/alpha/wQ.tsx", "../../../src/gen/pieces/chess/alpha/wR.tsx", "../../../src/Chessboard/Chessboard.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type PieceRecord, type BoardModel, type Move } from './types';\n\nexport type BoardContextType = {\n model?: BoardModel;\n dragging?: boolean; // TODO(burdon): Change to PieceRecord.\n promoting?: PieceRecord;\n onPromotion: (move: Move) => void;\n};\n\nexport const BoardContext = createContext<BoardContextType | undefined>(undefined);\n\nexport const useBoardContext = () => {\n return useContext(BoardContext) ?? raise(new Error('Missing BoardContext'));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReadonlySignal } from '@preact/signals-core';\n\nexport type Player = 'black' | 'white';\n\nexport type Location = [number, number];\n\nexport type PieceType = string;\n\nexport type PieceRecord<T extends PieceType = PieceType> = {\n id: string;\n type: T;\n side: Player;\n location: Location;\n};\n\n/**\n * Map of pieces by location.\n */\nexport type PieceMap<T extends PieceType = PieceType> = Record<string, PieceRecord<T>>;\n\nexport type Move = {\n from: Location;\n to: Location;\n piece: PieceType;\n promotion?: PieceType;\n};\n\nexport const locationToString = (location: Location): string => location.join('-');\nexport const stringToLocation = (str: string): Location => str.split('-').map(Number) as Location;\n\n// Type guard.\nexport const isPiece = (piece: unknown): piece is PieceRecord =>\n piece != null &&\n typeof piece === 'object' &&\n 'id' in piece &&\n 'type' in piece &&\n 'location' in piece &&\n isLocation(piece.location);\n\n// Type guard.\nexport const isLocation = (token: unknown): token is Location =>\n Array.isArray(token) && token.length === 2 && token.every((val) => typeof val === 'number');\n\nexport const isEqualLocation = (l1: Location, l2: Location): boolean => l1[0] === l2[0] && l1[1] === l2[1];\n\n/**\n * Generic board model.\n */\nexport interface BoardModel<T extends PieceType = PieceType> {\n turn: Player;\n pieces: ReadonlySignal<PieceMap<T>>;\n isValidMove: (move: Move) => boolean;\n canPromote?: (move: Move) => boolean;\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport type DOMRectBounds = Pick<DOMRect, 'top' | 'left' | 'width' | 'height'>;\n\nexport const getRelativeBounds = (container: HTMLElement, element: HTMLElement): DOMRectBounds => {\n const containerRect = container.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n return {\n top: elementRect.top - containerRect.top,\n left: elementRect.left - containerRect.left,\n width: elementRect.width,\n height: elementRect.height,\n };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport React, { type PropsWithChildren, useCallback, useEffect, useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { Container } from './Container';\nimport { BoardContext, type BoardContextType } from './context';\nimport { type BoardModel, isLocation, isPiece, type Move, type PieceRecord } from './types';\n\ntype RootProps = ThemedClassName<\n PropsWithChildren<{\n model?: BoardModel;\n onDrop?: (move: Move) => boolean;\n }>\n>;\n\n/**\n * Generic board container.\n */\nconst Root = ({ children, classNames, model, onDrop }: RootProps) => {\n const [dragging, setDragging] = useState(false);\n const [promoting, setPromoting] = useState<PieceRecord | undefined>();\n\n // Handle promotion.\n const onPromotion = useCallback<BoardContextType['onPromotion']>((move) => {\n log('onPromotion', { move });\n setPromoting(undefined);\n onDrop?.(move);\n }, []);\n\n useEffect(() => {\n if (!model) {\n return;\n }\n\n // TODO(burdon): Should target specific container.\n return monitorForElements({\n onDragStart: ({ source }) => {\n log('onDragStart', { source });\n setDragging(true);\n },\n onDrop: ({ source, location }) => {\n log('onDrop', { source, location });\n const target = location.current.dropTargets[0];\n if (!target) {\n return;\n }\n\n const targetLocation = target.data.location;\n const piece = source.data.piece;\n if (!isLocation(targetLocation) || !isPiece(piece)) {\n return;\n }\n\n const move: Move = { from: piece.location, to: targetLocation, piece: piece.type };\n if (model.canPromote?.(move)) {\n setPromoting({ ...piece, location: targetLocation });\n } else {\n onDrop?.(move);\n }\n\n setDragging(false);\n },\n });\n }, [model]);\n\n return (\n <BoardContext.Provider value={{ model, dragging, promoting, onPromotion }}>\n <Container classNames={mx('aspect-square', classNames)}>{children}</Container>\n </BoardContext.Provider>\n );\n};\n\nRoot.displayName = 'Board.Root';\n\nexport const Board = {\n Root,\n};\n\nexport type { RootProps as BoardRootProps };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { forwardRef, type PropsWithChildren } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nexport type ContainerProps = ThemedClassName<\n PropsWithChildren<{\n style?: React.CSSProperties;\n }>\n>;\n\n/**\n * Container centers the board.\n */\nexport const Container = forwardRef<HTMLDivElement, ContainerProps>(({ children, classNames, style }, forwardedRef) => {\n return (\n <div ref={forwardedRef} style={style} className='flex w-full h-full justify-center overflow-hidden'>\n <div className={mx('max-w-full max-h-full content-center', classNames)}>{children}</div>\n </div>\n );\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport React, { useRef, useState, useEffect, memo } from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { useBoardContext } from './context';\nimport { isPiece, type Location } from './types';\nimport { type DOMRectBounds } from './util';\n\ntype HoveredState = 'idle' | 'validMove' | 'invalidMove';\n\nexport type SquareProps = ThemedClassName<{\n location: Location;\n bounds: DOMRectBounds;\n label?: string;\n}>;\n\nexport const Square = memo(({ location, bounds, label, classNames }: SquareProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const [state, setState] = useState<HoveredState>('idle');\n const { model } = useBoardContext();\n\n useEffect(() => {\n const el = ref.current;\n invariant(el);\n\n return dropTargetForElements({\n element: el,\n getData: () => ({ location }),\n canDrop: ({ source }) => {\n log('canDrop', { source: source.data });\n return true;\n },\n onDragEnter: ({ source }) => {\n log('onDragEnter', { source: source.data });\n const piece = source.data.piece;\n if (!isPiece(piece)) {\n return;\n }\n\n if (model?.isValidMove({ from: piece.location, to: location, piece: piece.type })) {\n setState('validMove');\n } else {\n setState('invalidMove');\n }\n },\n onDragLeave: () => setState('idle'),\n onDrop: () => setState('idle'),\n });\n }, [model, location]);\n\n return (\n <div\n ref={ref}\n style={bounds}\n className={mx(\n 'absolute flex justify-center items-center border-2 box-border select-none',\n classNames,\n state === 'validMove' ? 'border-neutral-800' : 'border-transparent',\n )}\n >\n {label && <div className={mx('absolute bottom-1 left-1 text-xs text-neutral-500')}>{label}</div>}\n </div>\n );\n});\n\nSquare.displayName = 'Square';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\n// import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source';\nimport { centerUnderPointer } from '@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer';\nimport { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';\nimport React, { useState, useRef, useEffect, type FC, type SVGProps, memo } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { useDynamicRef, useTrackProps, type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { useBoardContext } from './context';\nimport { isEqualLocation, isLocation, type Location, type PieceRecord, type Player } from './types';\nimport { type DOMRectBounds } from './util';\n\nexport type PieceProps = ThemedClassName<{\n piece: PieceRecord;\n bounds: DOMRectBounds;\n label?: string;\n orientation?: Player;\n Component: FC<SVGProps<SVGSVGElement>>;\n}>;\n\nexport const Piece = memo(({ classNames, piece, orientation, bounds, label, Component }: PieceProps) => {\n useTrackProps({ classNames, piece, orientation, bounds, label, Component }, Piece.displayName, false);\n const { model } = useBoardContext();\n\n const { dragging: isDragging, promoting } = useBoardContext();\n const promotingRef = useDynamicRef(promoting);\n const [dragging, setDragging] = useState(false);\n const [preview, setPreview] = useState<HTMLElement>();\n\n // Current position.\n const [current, setCurrent] = useState<{ location?: Location; bounds?: DOMRectBounds }>({});\n\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const el = ref.current;\n invariant(el);\n\n return draggable({\n element: el,\n getInitialData: () => ({ piece }),\n onGenerateDragPreview: ({ nativeSetDragImage, location, source }) => {\n log('onGenerateDragPreview', { source: source.data });\n setCustomNativeDragPreview({\n getOffset: centerUnderPointer,\n // getOffset: preserveOffsetOnSource({\n // element: source.element,\n // input: location.current.input,\n // }),\n render: ({ container }) => {\n setPreview(container);\n const { width, height } = el.getBoundingClientRect();\n container.style.width = width + 'px';\n container.style.height = height + 'px';\n return () => {\n setPreview(undefined);\n };\n },\n nativeSetDragImage,\n });\n },\n canDrag: () => !promotingRef.current && model?.turn === piece.side,\n onDragStart: () => setDragging(true),\n onDrop: ({ location: { current } }) => {\n const location = current.dropTargets[0].data.location;\n if (isLocation(location)) {\n setCurrent((current) => ({ ...current, location }));\n }\n\n setDragging(false);\n },\n });\n }, [model, piece]);\n\n // Must update position independently of render cycle (otherwise animation is interrupted).\n useEffect(() => {\n requestAnimationFrame(() => {\n if (!ref.current || !bounds) {\n return;\n }\n\n // Check if piece moved.\n if (!current.location || !isEqualLocation(current.location, piece.location)) {\n ref.current.style.transition = 'top 400ms ease-out, left 400ms ease-out';\n ref.current.style.top = bounds.top + 'px';\n ref.current.style.left = bounds.left + 'px';\n setCurrent({ location: piece.location, bounds });\n } else if (current.bounds !== bounds) {\n ref.current.style.transition = 'none';\n ref.current.style.top = bounds.top + 'px';\n ref.current.style.left = bounds.left + 'px';\n setCurrent({ location: piece.location, bounds });\n }\n });\n }, [current, piece.location, bounds]);\n\n return (\n <>\n <div\n ref={ref}\n style={{\n width: bounds?.width,\n height: bounds?.height,\n }}\n className={mx(\n 'absolute',\n classNames,\n // orientation === 'black' && '_rotate-180',\n dragging && 'opacity-20', // Must not unmount component while dragging.\n isDragging && 'pointer-events-none', // Don't block the square's drop target.\n )}\n >\n <Component className='grow' />\n {label && <div className='absolute inset-1 text-xs text-black'>{label}</div>}\n </div>\n\n {preview &&\n createPortal(\n <div className={mx(classNames)}>\n <Component className='grow' />\n </div>,\n preview,\n )}\n </>\n );\n});\n\nPiece.displayName = 'Piece';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReadonlySignal, signal } from '@preact/signals-core';\nimport { Chess, validateFen } from 'chess.js';\nimport { type FC, type SVGProps } from 'react';\n\nimport { log } from '@dxos/log';\n\nimport {\n type Move,\n type Location,\n type PieceMap,\n locationToString,\n type PieceType,\n type BoardModel,\n type Player,\n} from '../Board';\nimport * as Alpha from '../gen/pieces/chess/alpha';\n\nexport type ChessPiece = 'BK' | 'BQ' | 'BR' | 'BB' | 'BN' | 'BP' | 'WK' | 'WQ' | 'WR' | 'WB' | 'WN' | 'WP';\n\nexport const ChessPieces: Record<ChessPiece, FC<SVGProps<SVGSVGElement>>> = Alpha;\n\nexport const posToLocation = (pos: string): Location => {\n const col = pos.charCodeAt(0) - 'a'.charCodeAt(0);\n const row = parseInt(pos[1]) - 1;\n return [row, col];\n};\n\nexport const locationToPos = ([row, col]: Location): string => {\n return String.fromCharCode(col + 'a'.charCodeAt(0)) + (row + 1);\n};\n\nconst styles = {\n neutral: {\n black: 'bg-neutral-50',\n white: 'bg-neutral-200',\n promotion: 'bg-neutral-200 hover:bg-neutral-300 opacity-70 hover:opacity-100',\n },\n original: {\n black: 'bg-[#6C95B9]',\n white: 'bg-[#CCD3DB]',\n promotion: 'duration-500 bg-[#CCD3DB] opacity-70 hover:opacity-100',\n },\n blue: {\n black: 'bg-[#608BC1]',\n white: 'bg-[#CBDCEB]',\n promotion: 'duration-500 bg-[#CBDCEB] opacity-70 hover:opacity-100',\n },\n green: {\n black: 'bg-[#8EB486]',\n white: 'bg-[#FDF7F4]',\n promotion: 'duration-500 bg-[#FDF7F4] opacity-70 hover:opacity-100',\n },\n};\n\nexport const boardStyles = styles.original;\n\nexport const getSquareColor = ([row, col]: Location) => {\n return (col + row) % 2 === 0 ? boardStyles.black : boardStyles.white;\n};\n\n/**\n * Attempt move.\n */\nconst makeMove = (game: Chess, move: Move): Chess | null => {\n const from = locationToPos(move.from);\n const to = locationToPos(move.to);\n try {\n log('makeMove', { move });\n const promotion = move.promotion ? move.promotion[1].toLowerCase() : 'q';\n game.move({ from, to, promotion }, { strict: false });\n return game;\n } catch (err) {\n // Ignore.\n return null;\n }\n};\n\n/**\n * Chess model.\n */\nexport class ChessModel implements BoardModel<ChessPiece> {\n private _game!: Chess;\n private readonly _pieces = signal<PieceMap<ChessPiece>>({});\n\n constructor(fen?: string) {\n this.initialize(fen);\n }\n\n get turn(): Player {\n return this._game.turn() === 'w' ? 'white' : 'black';\n }\n\n get pieces(): ReadonlySignal<PieceMap<ChessPiece>> {\n return this._pieces;\n }\n\n get game(): Chess {\n return this._game;\n }\n\n get fen(): string {\n return this._game.fen();\n }\n\n initialize(fen?: string) {\n this._pieces.value = {};\n this._game = new Chess(fen ? (validateFen(fen).ok ? fen : undefined) : undefined);\n this._update();\n }\n\n isValidMove(move: Move): boolean {\n return makeMove(new Chess(this._game.fen()), move) !== null;\n }\n\n canPromote(move: Move): boolean {\n const isPawnMove = move.piece === 'BP' || move.piece === 'WP';\n const isToLastRank = move.to[0] === 0 || move.to[0] === 7;\n return isPawnMove && isToLastRank;\n }\n\n makeMove(move: Move): boolean {\n const game = makeMove(this._game, move);\n if (!game) {\n return false;\n }\n\n this._game = game;\n this._update();\n return true;\n }\n\n makeRandomMove(): boolean {\n const moves = this._game.moves();\n if (!moves.length) {\n return false;\n }\n\n const move = moves[Math.floor(Math.random() * moves.length)];\n this._game.move(move);\n this._update();\n return true;\n }\n\n /**\n * Update pieces preserving identity.\n */\n private _update() {\n const pieces: PieceMap<ChessPiece> = {};\n this._game.board().flatMap((row) =>\n row.forEach((record) => {\n if (!record) {\n return;\n }\n\n const { square, type, color } = record;\n const pieceType = `${color.toUpperCase()}${type.toUpperCase()}` as ChessPiece;\n const location = posToLocation(square);\n pieces[locationToString(location)] = {\n id: `${square}-${pieceType}`,\n type: pieceType,\n side: color === 'w' ? 'white' : 'black',\n location,\n };\n }),\n );\n\n this._pieces.value = mapPieces(this._pieces.value, pieces);\n }\n}\n\n/**\n * Preserve the original piece objects (and IDs).\n */\nexport const mapPieces = <T extends PieceType>(before: PieceMap<T>, after: PieceMap<T>): PieceMap<T> => {\n const difference: { added: PieceMap; removed: PieceMap } = {\n removed: {},\n added: {},\n };\n\n (Object.keys(before) as Array<keyof typeof before>).forEach((square) => {\n if (after[square]?.type !== before[square]?.type) {\n difference.removed[square] = before[square];\n }\n });\n\n (Object.keys(after) as Array<keyof typeof after>).forEach((square) => {\n if (before[square]?.type !== after[square]?.type) {\n difference.added[square] = after[square];\n } else {\n after[square] = before[square];\n }\n });\n\n for (const piece of Object.values(difference.added)) {\n const previous = Object.values(difference.removed).find((p) => p.type === piece.type);\n if (previous) {\n piece.id = previous.id;\n }\n }\n\n log('delta', {\n before: Object.keys(before).length,\n after: Object.keys(after).length,\n removed: Object.keys(difference.removed).length,\n added: Object.keys(difference.added).length,\n });\n\n return after;\n};\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBB = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path fill='#f9f9f9' d='M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z' />\n <path\n fill='#101010'\n d='M768 1365q-5 39-26 82h564q-18-36-26-82zm495-73 46-73q-142-49-285-47-144-2-285 47l46 73q118-40 239-38 120-2 239 38m-432 227H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-207l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60zm146-701h-95v89h95v165h94V907h95v-89h-95V714h-94z'\n />\n </svg>\n);\nexport default SvgBB;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBK = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m553 1485-55 320 1048 5-48-335s324-313 330-467c7-153-35-331-241-406-183-67-372 121-372 121l-182-161-190 160S658 586 587 592a373 373 0 0 0-362 333c10 331 328 560 328 560'\n />\n <path\n fill='#101010'\n d='M1024 1769h489l-12-73H547l-12 73zm0-921q-25-60-62-111 31-48 62-65 30 17 62 65-38 51-62 111m-97 454q-154 11-303 58-123-108-200-213t-77-202q0-89 74-159t148-70q67 0 135 63t102 130q30 54 75 175t46 218m-350 217-26 156 145-84zm447-907q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m0 775q-1-126-42-267t-84-227l-14-27-12-23q-28-43-48-69-51-63-120-105t-134-42q-103 0-208 93T257 949q0 120 99 255t249 259q201-74 419-76m0 456H448l61-365q-325-280-326-535-1-159 125-274t267-116q78 0 159 47t142 119q61 74 99 165t49 150q12-60 49-150t99-165q61-72 142-119t159-47q140 0 266 116t126 274q-2 255-326 535l61 365zm97-541q0-97 45-218t76-175q34-68 102-130t135-63q74 0 148 70t74 159q0 96-77 202t-200 213q-150-47-303-58m350 217-119 72 145 84zm-447-132q217 2 419 76 150-125 249-259t99-255q0-136-105-229t-208-93q-66 0-135 42t-119 105q-21 26-48 69l-12 23-14 27q-44 85-85 227t-41 267m-139 159 139 86 139-84-139-86zm92-1248v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95z'\n />\n </svg>\n);\nexport default SvgBK;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBN = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='M1658 1806c-408-301-71-920-452-1343l60-16s296 167 320 257c182 468 41 691 135 1077zM972 523l120 176-312-3zM498 981l-93-41 42-93 127 28z'\n />\n <path\n fill='#101010'\n d='m502 868-52 1-26 64 69 21 46-55zm536-187q34 1-16-68t-80-42L826 680zm-338-98q6-39 116-107t220-144l115-154 96 217q342 172 433 418t47 603q-18 128 5 236t57 190l-1242 1q-9-178 39-301t183-238q50-11 83-39t53-59l63-1 138-29 139-97 66-207q0-17-8-34t-12-37q-62 228-161 289t-191 58q-236-42-292 60l-56 102-217-121 115-82-51-50-122 86-12-297zm981 1192q-102-130-85-308t27-363-50-351-316-276q220 164 253 342t16 351-12 329 167 276'\n />\n </svg>\n);\nexport default SvgBN;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBP = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#101010'\n d='M1024 1843H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74z'\n />\n </svg>\n);\nexport default SvgBP;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBQ = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path fill='#f9f9f9' d='m520 1801.8 41.5-448.7 474-128.9 458 133.5 34.4 446.4z' />\n <path\n fill='#101010'\n d='M590 1519q4 72-15 158l134-86zm434 324H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zm0-450q109 0 222 28.5t213 67.5q2-41 11-89-108-42-221.5-68t-224.5-26-225 26-221 68q8 48 11 89 99-39 212-67.5t223-28.5m0 376h478q-15-34-24-73H570q-10 39-24 73zm434-250-119 72 134 86q-20-86-15-158m-573 47 139 87 139-84-139-86z'\n />\n </svg>\n);\nexport default SvgBQ;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBR = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path fill='#f9f9f9' d='m674 732-76 807 851 14-75-833z' />\n <path\n fill='#101010'\n d='M1024 1843H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-989h333l-6-88H697l-6 88zm0 647h381l-6-87H649l-6 87z'\n />\n </svg>\n);\nexport default SvgBR;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWB = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m948 366 1-139 148-7 1 147zM564 860c114-267 456-443 456-443s392 176 476 502c-9 209-183 332-183 332l27 221-653 6 46-233s-230-171-169-385m-101 790c175 6 355 23 425-142h92s0 190-88 246c-163 103-625 38-625 38s-15-146 196-142m631 37-36-185 102 5s22 153 315 131c381-17 318 153 318 153l-483 5z'\n />\n <path\n fill='#101010'\n d='M1024 356q66 0 64-66 1-55-64-55-66 0-64 55-3 66 64 66m0 1204q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60l10-16h76q-7 21-3 13-45 105-109 125t-146 19H409q-52 0-86 40t-34 53h424q66 0 159-65t93-185H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-341q0 120 93 185t159 65h424q0-13-34-53t-86-40h-240q-83 0-146-19t-109-125q4 8-3-13h76l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199m0-114h283q-28-84-29-154-120-41-254-38-135-3-254 38-2 70-29 154zm0-267q159-1 285 42 189-180 142-346-60-193-427-431-368 238-427 431-48 166 142 346 125-43 285-42m-47-361V714h94v104h95v89h-95v165h-94V907h-95v-89z'\n />\n </svg>\n);\nexport default SvgWB;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWK = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m501.6 1811 48.4-354.4-260-269.2s-166.4-288.2 29.9-481C582.2 448.7 826 727.2 826 727.2l195.6-165.7 184 165.7s216.4-232.5 430.4-76 255.4 317.6 117.4 531.6c-138.1 214-250.9 280.7-250.9 280.7L1558 1811z'\n />\n <path\n fill='#101010'\n d='M977 298v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95zm47 314q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m-447 907-26 156 145-84zm410-206q-1-147-36.5-274.5T870 845q-45-88-131.5-153T570 627q-103 0-208 93T257 949q0 109 86.5 236T546 1408q212-88 441-95m37 530H448l61-365q-325-280-326-535-1-159 125-274.5T575 553q78 0 158.5 47T876 719q61 74 98.5 164.5T1024 1034q12-60 49-150.5t99-164.5q61-72 142-119t159-47q140 0 266 115.5T1865 943q-2 255-326 535l61 365zm0-74h489l-50-298q-216-84-439-84t-439 84l-50 298zm447-250 26 156-145-84zm-410-206q229 7 441 95 115-96 202-223t87-236q0-136-105.5-229T1478 627q-83 0-169.5 65T1178 845q-46 66-81.5 193.5T1061 1313m-176 233 141-84 137 86-141 84z'\n />\n </svg>\n);\nexport default SvgWK;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWN = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m352 861 787-569 94 148s336 103 398 388c63 286 51 974 51 974l-1088 9s-37-290 184-460c221-171 221-212 221-212s-226-71-295-16-117 138-117 138l-129-67 74-85-88-97-94 56z'\n />\n <path\n fill='#101010'\n d='m1151 178-115 154c-74 50-147 98-220 144-73 45-112 81-116 107L304 846l12 297 122-86 51 50-115 82 217 121 56-102c37-68 135-88 292-60l-55 85c-25 37-63 60-115 71a608 608 0 0 0-183 238c-32 82-45 182-39 301h1242c-23-55-42-118-57-190-15-73-17-152-5-237 29-239 13-440-47-603-61-164-205-303-433-418zm-17 145 59 133a664 664 0 0 1 262 188c55 72 100 150 134 234 27 97 40 181 41 253 0 71-3 140-9 205-7 65-11 131-13 199-2 67 9 145 32 234H621c-4-84 12-158 48-223s85-124 146-177c78-22 129-56 152-102s53-90 90-131c13-10 27-15 38-15 10-1 21 0 33-2 52-7 95-36 129-85 33-49 51-104 52-165l-19-67c-37 159-99 245-188 257l-45 6c-16 1-33 10-52 26-41-25-87-35-138-31q-111 9-165 27l-108 73-39 45-47-28 78-65-138-144-64 41-4-125 366-241c15-34 58-74 131-120l208-131zM960 564c-6 0-12 2-18 7L826 671l212 2c23 0 17-21-16-63-24-31-44-46-62-46M502 868l-33 4-33 56 57 26 46-55z'\n />\n </svg>\n);\nexport default SvgWN;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWP = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m734 981 196-193s-189-82-79-288c79-149 303-114 361 50 63 179-113 240-113 240l226 197Zm-235 799s-8-107 50-154c196-173 338-386 371-599l210 2c33 206 182 447 321 561 101 59 99 199 99 199z'\n />\n <path\n fill='#101010'\n d='M520 1769h1008q8-97-132-182-132-101-196-239t-80-309H928q-15 170-79 309t-197 239q-141 85-132 182m504 74H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74zM756 974h536l-225-191q134-31 134-171 0-76-52-126t-125-51q-73 0-125 51t-52 126q0 140 134 171z'\n />\n </svg>\n);\nexport default SvgWP;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWQ = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m508.5 1815.6 48.4-356.7-216.3-554.6-135.8-20.7-16.1-126.5 112.7-43.8 78.3 73.7-18.4 99 246.2 197.8 112.8-568.3L635 428l78.3-108 112.8 43.7-23 161 223.2 474 244-490-66.8-105.9 92-92 105.9 73.6L1337 534l103.5 529.2 260-161-16-142.7 131-46 57.6 131.1-207 103.6-175 529.2 48.4 308.4z'\n />\n <path\n fill='#101010'\n d='M1024 1769h478q-53-130-43-280-100-39-213-67.5t-222-28.5q-110 0-223 28.5T589 1489q9 150-43 280zm0-450q111 0 223.5 26.5T1468 1413q17-105 60.5-212.5T1634 988l-220 155-123-601-267 555-267-555-123 601-220-155q61 105 104.5 212.5T580 1413q108-41 220.5-67.5T1024 1319m0 524H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zM276 746q-62 0-62 62t62 62q63 0 63-62t-63-62m466-394q-62 0-62 62t62 62 62-62-62-62M590 1519l119 72-134 86q19-86 15-158m1182-773q-63 0-63 62t63 62q62 0 62-62t-62-62m-466-394q-62 0-62 62t62 62 62-62-62-62m152 1167-119 72 134 86q-20-86-15-158m-573 47 139-83 139 86-139 84z'\n />\n </svg>\n);\nexport default SvgWQ;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWR = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m435 1804 16-212 152-115 51-688-148-115-7-276 210-2 4 138 198 2 7-140 212-3 14 145 193-4 5-138h204l-7 285-145 106 42 693 172 124 19 207z'\n />\n <path\n fill='#101010'\n d='M1024 1501H643l5-74h752l5 74zm0-661H692l5-74h654l5 74zm0 1003H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-74h557l-15-149-161-119-54-735 152-109 13-230h-138v148h-285V427H955v148H670V427H532l13 230 152 109-54 735-161 119-15 149z'\n />\n </svg>\n);\nexport default SvgWR;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, useRef, useMemo, useEffect, useState, memo } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { useTrackProps } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\nimport { isNotFalsy } from '@dxos/util';\n\nimport { boardStyles, type ChessPiece, ChessPieces, getSquareColor, locationToPos } from './chess';\nimport {\n type DOMRectBounds,\n type Location,\n type PieceRecord,\n type Player,\n Piece,\n Square,\n getRelativeBounds,\n locationToString,\n} from '../Board';\nimport { useBoardContext } from '../Board';\n\nexport type ChessboardProps = PropsWithChildren<{\n orientation?: Player;\n showLabels?: boolean;\n debug?: boolean;\n rows?: number;\n cols?: number;\n}>;\n\n/**\n * Chessboard layout.\n */\nexport const Chessboard = memo(({ orientation, showLabels, debug, rows = 8, cols = 8 }: ChessboardProps) => {\n useTrackProps({ orientation, showLabels, debug }, Chessboard.displayName, false);\n const { ref: containerRef, width, height } = useResizeDetector({ refreshRate: 200 });\n const { model, promoting, onPromotion } = useBoardContext();\n\n const locations = useMemo<Location[]>(() => {\n return Array.from({ length: rows }, (_, i) => (orientation === 'black' ? i : rows - 1 - i)).flatMap((row) =>\n Array.from({ length: cols }).map((_, col) => [row, col] as Location),\n );\n }, [orientation, rows, cols]);\n\n // Use DOM grid layout to position squares.\n const layout = useMemo(() => {\n return locations.map((location) => {\n return (\n <div\n key={locationToString(location)}\n {...{\n ['data-location' as const]: locationToString(location),\n }}\n />\n );\n });\n }, [locations]);\n\n // Build map of square locations to bounds.\n const [grid, setGrid] = useState<Record<string, DOMRectBounds>>({});\n const gridRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n setGrid(\n locations.reduce(\n (acc, location) => {\n const square = getSquareLocation(gridRef.current!, location)!;\n const bounds = getRelativeBounds(gridRef.current!, square);\n return { ...acc, [locationToString(location)]: bounds };\n },\n {} as Record<string, DOMRectBounds>,\n ),\n );\n }, [locations, width, height]);\n\n // Get the bounds of each square and piece.\n const positions = useMemo<{ piece: PieceRecord; bounds: DOMRectBounds }[]>(() => {\n if (!gridRef.current) {\n return [];\n }\n\n return Object.values(model?.pieces.value ?? {})\n .map((piece) => {\n if (piece.id === promoting?.id) {\n return null;\n }\n\n const bounds = grid[locationToString(piece.location)];\n return { piece, bounds };\n })\n .filter(isNotFalsy);\n }, [grid, model?.pieces.value, promoting]);\n\n return (\n <div ref={containerRef} className='relative'>\n <div ref={gridRef} className='grid grid-rows-8 grid-cols-8 aspect-square select-none'>\n {layout}\n </div>\n <div>\n {locations.map((location) => (\n <Square\n key={locationToString(location)}\n location={location}\n label={showLabels ? locationToPos(location) : undefined}\n bounds={grid[locationToString(location)]}\n classNames={getSquareColor(location)}\n />\n ))}\n </div>\n <div className={mx(promoting && 'opacity-50')}>\n {positions.map(({ bounds, piece }) => (\n <Piece\n key={piece.id}\n piece={piece}\n bounds={bounds}\n label={debug ? piece.id : undefined}\n orientation={orientation}\n Component={ChessPieces[piece.type as ChessPiece]}\n />\n ))}\n </div>\n <div>\n {promoting && (\n <PromotionSelector\n grid={grid}\n piece={promoting}\n onSelect={(piece) => {\n onPromotion({\n from: Object.values(model!.pieces.value).find((p) => p.id === promoting.id)!.location,\n to: piece.location,\n piece: promoting.type,\n promotion: piece.type,\n });\n }}\n />\n )}\n </div>\n </div>\n );\n});\n\nChessboard.displayName = 'Chessboard';\n\nconst getSquareLocation = (container: HTMLElement, location: Location): HTMLElement | null => {\n return container.querySelector(`[data-location=\"${locationToString(location)}\"]`);\n};\n\nconst PromotionSelector = ({\n grid,\n piece,\n onSelect,\n}: {\n grid: Record<string, DOMRectBounds>;\n piece: PieceRecord;\n onSelect: (piece: PieceRecord) => void;\n}) => {\n const positions = ['Q', 'N', 'R', 'B'].map((pieceType, i) => {\n const location = [piece.location[0] + (piece.location[0] === 0 ? i : -i), piece.location[1]] as Location;\n return {\n piece: {\n id: `promotion-${pieceType}`,\n type: (piece.side === 'black' ? 'B' : 'W') + pieceType,\n side: piece.side,\n location,\n },\n bounds: grid[locationToString(location)],\n };\n });\n\n const handleSelect = (selected: PieceRecord) => {\n onSelect({ ...piece, type: selected.type });\n };\n\n // TODO(burdon): Circle.\n return (\n <div>\n {positions.map(({ piece, bounds }) => (\n <div key={piece.id} style={bounds} onClick={() => handleSelect(piece)}>\n <Piece\n piece={piece}\n bounds={bounds}\n Component={ChessPieces[piece.type as ChessPiece]}\n classNames={mx('border-2 border-neutral-700 rounded-full', boardStyles.promotion)}\n />\n </div>\n ))}\n </div>\n );\n};\n"],
5
- "mappings": ";;;;;;;AAIA,SAASA,eAAeC,kBAAkB;AAE1C,SAASC,aAAa;AAWf,IAAMC,eAAeC,cAA4CC,MAAAA;AAEjE,IAAMC,kBAAkB,MAAA;AAC7B,SAAOC,WAAWJ,YAAAA,KAAiBK,MAAM,IAAIC,MAAM,sBAAA,CAAA;AACrD;;;ACUO,IAAMC,mBAAmB,CAACC,aAA+BA,SAASC,KAAK,GAAA;AACvE,IAAMC,mBAAmB,CAACC,QAA0BA,IAAIC,MAAM,GAAA,EAAKC,IAAIC,MAAAA;AAGvE,IAAMC,UAAU,CAACC,UACtBA,SAAS,QACT,OAAOA,UAAU,YACjB,QAAQA,SACR,UAAUA,SACV,cAAcA,SACdC,WAAWD,MAAMR,QAAQ;AAGpB,IAAMS,aAAa,CAACC,UACzBC,MAAMC,QAAQF,KAAAA,KAAUA,MAAMG,WAAW,KAAKH,MAAMI,MAAM,CAACC,QAAQ,OAAOA,QAAQ,QAAA;AAE7E,IAAMC,kBAAkB,CAACC,IAAcC,OAA0BD,GAAG,CAAA,MAAOC,GAAG,CAAA,KAAMD,GAAG,CAAA,MAAOC,GAAG,CAAA;;;ACzCjG,IAAMC,oBAAoB,CAACC,WAAwBC,YAAAA;AACxD,QAAMC,gBAAgBF,UAAUG,sBAAqB;AACrD,QAAMC,cAAcH,QAAQE,sBAAqB;AACjD,SAAO;IACLE,KAAKD,YAAYC,MAAMH,cAAcG;IACrCC,MAAMF,YAAYE,OAAOJ,cAAcI;IACvCC,OAAOH,YAAYG;IACnBC,QAAQJ,YAAYI;EACtB;AACF;;;ACXA,SAASC,0BAA0B;AACnC,OAAOC,UAAiCC,aAAaC,WAAWC,gBAAgB;AAEhF,SAASC,WAAW;AAEpB,SAASC,MAAAA,WAAU;;;ACLnB,OAAOC,SAAS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AMqC,oBAAoB,CAAC+B,WAAwB7C,aAAAA;AACjD,SAAO6C,UAAUC,cAAc,mBAAmB1C,iBAAiBJ,QAAAA,CAAAA,IAAa;AAClF;AAEA,IAAMuC,oBAAoB,CAAC,EACzBlC,MACAkB,OACAiB,SAAQ,MAKT;AACC,QAAMtB,YAAY;IAAC;IAAK;IAAK;IAAK;IAAKrB,IAAI,CAACkD,WAAWrD,MAAAA;AACrD,UAAMM,WAAW;MAACuB,MAAMvB,SAAS,CAAA,KAAMuB,MAAMvB,SAAS,CAAA,MAAO,IAAIN,IAAI,CAACA;MAAI6B,MAAMvB,SAAS,CAAA;;AACzF,WAAO;MACLuB,OAAO;QACLC,IAAI,aAAauB,SAAAA;QACjBT,OAAOf,MAAMyB,SAAS,UAAU,MAAM,OAAOD;QAC7CC,MAAMzB,MAAMyB;QACZhD;MACF;MACAgB,QAAQX,KAAKD,iBAAiBJ,QAAAA,CAAAA;IAChC;EACF,CAAA;AAEA,QAAMiD,eAAe,CAACC,aAAAA;AACpBV,aAAS;MAAE,GAAGjB;MAAOe,MAAMY,SAASZ;IAAK,CAAA;EAC3C;AAGA,SACE,gBAAArC,QAAA,cAACC,OAAAA,MACEgB,UAAUrB,IAAI,CAAC,EAAE0B,OAAAA,QAAOP,OAAM,MAC7B,gBAAAf,QAAA,cAACC,OAAAA;IAAIC,KAAKoB,OAAMC;IAAI2B,OAAOnC;IAAQoC,SAAS,MAAMH,aAAa1B,MAAAA;KAC7D,gBAAAtB,QAAA,cAACkC,OAAAA;IACCZ,OAAOA;IACPP;IACAoB,WAAWC,YAAYd,OAAMe,IAAI;IACjCN,YAAYE,IAAG,4CAA4CmB,YAAYT,SAAS;;AAM5F;",
6
- "names": ["createContext", "useContext", "raise", "BoardContext", "createContext", "undefined", "useBoardContext", "useContext", "raise", "Error", "locationToString", "location", "join", "stringToLocation", "str", "split", "map", "Number", "isPiece", "piece", "isLocation", "token", "Array", "isArray", "length", "every", "val", "isEqualLocation", "l1", "l2", "getRelativeBounds", "container", "element", "containerRect", "getBoundingClientRect", "elementRect", "top", "left", "width", "height", "monitorForElements", "React", "useCallback", "useEffect", "useState", "log", "mx", "React", "forwardRef", "mx", "Container", "forwardRef", "children", "classNames", "style", "forwardedRef", "div", "ref", "className", "mx", "Root", "children", "classNames", "model", "onDrop", "dragging", "setDragging", "useState", "promoting", "setPromoting", "onPromotion", "useCallback", "move", "log", "undefined", "useEffect", "monitorForElements", "onDragStart", "source", "location", "target", "current", "dropTargets", "targetLocation", "data", "piece", "isLocation", "isPiece", "from", "to", "type", "canPromote", "React", "BoardContext", "Provider", "value", "Container", "mx", "displayName", "Board", "dropTargetForElements", "React", "useRef", "useState", "useEffect", "memo", "invariant", "log", "mx", "Square", "memo", "location", "bounds", "label", "classNames", "ref", "useRef", "state", "setState", "useState", "model", "useBoardContext", "useEffect", "el", "current", "invariant", "dropTargetForElements", "element", "getData", "canDrop", "source", "log", "data", "onDragEnter", "piece", "isPiece", "isValidMove", "from", "to", "type", "onDragLeave", "onDrop", "React", "div", "style", "className", "mx", "displayName", "draggable", "centerUnderPointer", "setCustomNativeDragPreview", "React", "useState", "useRef", "useEffect", "memo", "createPortal", "invariant", "log", "useDynamicRef", "useTrackProps", "mx", "Piece", "memo", "classNames", "piece", "orientation", "bounds", "label", "Component", "useTrackProps", "displayName", "model", "useBoardContext", "dragging", "isDragging", "promoting", "promotingRef", "useDynamicRef", "setDragging", "useState", "preview", "setPreview", "current", "setCurrent", "ref", "useRef", "useEffect", "el", "invariant", "draggable", "element", "getInitialData", "onGenerateDragPreview", "nativeSetDragImage", "location", "source", "log", "data", "setCustomNativeDragPreview", "getOffset", "centerUnderPointer", "render", "container", "width", "height", "getBoundingClientRect", "style", "undefined", "canDrag", "turn", "side", "onDragStart", "onDrop", "dropTargets", "isLocation", "requestAnimationFrame", "isEqualLocation", "transition", "top", "left", "React", "div", "className", "mx", "createPortal", "signal", "Chess", "validateFen", "log", "React", "SvgBB", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBK", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBN", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBP", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBQ", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBR", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWB", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWK", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWN", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWP", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWQ", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWR", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "ChessPieces", "Alpha", "posToLocation", "pos", "col", "charCodeAt", "row", "parseInt", "locationToPos", "String", "fromCharCode", "styles", "neutral", "black", "white", "promotion", "original", "blue", "green", "boardStyles", "getSquareColor", "makeMove", "game", "move", "from", "to", "log", "toLowerCase", "strict", "err", "ChessModel", "constructor", "fen", "_pieces", "signal", "initialize", "turn", "_game", "pieces", "value", "Chess", "validateFen", "ok", "undefined", "_update", "isValidMove", "canPromote", "isPawnMove", "piece", "isToLastRank", "makeRandomMove", "moves", "length", "Math", "floor", "random", "board", "flatMap", "forEach", "record", "square", "type", "color", "pieceType", "toUpperCase", "location", "locationToString", "id", "side", "mapPieces", "before", "after", "difference", "removed", "added", "Object", "keys", "values", "previous", "find", "p", "React", "useRef", "useMemo", "useEffect", "useState", "memo", "useResizeDetector", "useTrackProps", "mx", "isNotFalsy", "Chessboard", "memo", "orientation", "showLabels", "debug", "rows", "cols", "useTrackProps", "displayName", "ref", "containerRef", "width", "height", "useResizeDetector", "refreshRate", "model", "promoting", "onPromotion", "useBoardContext", "locations", "useMemo", "Array", "from", "length", "_", "i", "flatMap", "row", "map", "col", "layout", "location", "React", "div", "key", "locationToString", "grid", "setGrid", "useState", "gridRef", "useRef", "useEffect", "reduce", "acc", "square", "getSquareLocation", "current", "bounds", "getRelativeBounds", "positions", "Object", "values", "pieces", "value", "piece", "id", "filter", "isNotFalsy", "className", "Square", "label", "locationToPos", "undefined", "classNames", "getSquareColor", "mx", "Piece", "Component", "ChessPieces", "type", "PromotionSelector", "onSelect", "find", "p", "to", "promotion", "container", "querySelector", "pieceType", "side", "handleSelect", "selected", "style", "onClick", "boardStyles"]
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type PieceRecord, type BoardModel, type Move } from './types';\n\nexport type BoardContextType = {\n model?: BoardModel;\n dragging?: boolean; // TODO(burdon): Change to PieceRecord.\n promoting?: PieceRecord;\n onPromotion: (move: Move) => void;\n};\n\nexport const BoardContext = createContext<BoardContextType | undefined>(undefined);\n\nexport const useBoardContext = () => {\n return useContext(BoardContext) ?? raise(new Error('Missing BoardContext'));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReadonlySignal } from '@preact/signals-core';\n\nexport type Player = 'black' | 'white';\n\nexport type Location = [number, number];\n\nexport type PieceType = string;\n\nexport type PieceRecord<T extends PieceType = PieceType> = {\n id: string;\n type: T;\n side: Player;\n location: Location;\n};\n\n/**\n * Map of pieces by location.\n */\nexport type PieceMap<T extends PieceType = PieceType> = Record<string, PieceRecord<T>>;\n\nexport type Move = {\n from: Location;\n to: Location;\n piece: PieceType;\n promotion?: PieceType;\n};\n\nexport const locationToString = (location: Location): string => location.join('-');\nexport const stringToLocation = (str: string): Location => str.split('-').map(Number) as Location;\n\n// Type guard.\nexport const isPiece = (piece: unknown): piece is PieceRecord =>\n piece != null &&\n typeof piece === 'object' &&\n 'id' in piece &&\n 'type' in piece &&\n 'location' in piece &&\n isLocation(piece.location);\n\n// Type guard.\nexport const isLocation = (token: unknown): token is Location =>\n Array.isArray(token) && token.length === 2 && token.every((val) => typeof val === 'number');\n\nexport const isEqualLocation = (l1: Location, l2: Location): boolean => l1[0] === l2[0] && l1[1] === l2[1];\n\n/**\n * Generic board model.\n */\nexport interface BoardModel<T extends PieceType = PieceType> {\n turn: Player;\n pieces: ReadonlySignal<PieceMap<T>>;\n isValidMove: (move: Move) => boolean;\n canPromote?: (move: Move) => boolean;\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport type DOMRectBounds = Pick<DOMRect, 'top' | 'left' | 'width' | 'height'>;\n\nexport const getRelativeBounds = (container: HTMLElement, element: HTMLElement): DOMRectBounds => {\n const containerRect = container.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n return {\n top: elementRect.top - containerRect.top,\n left: elementRect.left - containerRect.left,\n width: elementRect.width,\n height: elementRect.height,\n };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport React, { type PropsWithChildren, useCallback, useEffect, useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { Container } from './Container';\nimport { BoardContext, type BoardContextType } from './context';\nimport { type BoardModel, isLocation, isPiece, type Move, type PieceRecord } from './types';\n\ntype RootProps = ThemedClassName<\n PropsWithChildren<{\n model?: BoardModel;\n onDrop?: (move: Move) => boolean;\n }>\n>;\n\n/**\n * Generic board container.\n */\nconst Root = ({ children, classNames, model, onDrop }: RootProps) => {\n const [dragging, setDragging] = useState(false);\n const [promoting, setPromoting] = useState<PieceRecord | undefined>();\n\n // Handle promotion.\n const onPromotion = useCallback<BoardContextType['onPromotion']>((move) => {\n log('onPromotion', { move });\n setPromoting(undefined);\n onDrop?.(move);\n }, []);\n\n useEffect(() => {\n if (!model) {\n return;\n }\n\n // TODO(burdon): Should target specific container.\n return monitorForElements({\n onDragStart: ({ source }) => {\n log('onDragStart', { source });\n setDragging(true);\n },\n onDrop: ({ source, location }) => {\n log('onDrop', { source, location });\n const target = location.current.dropTargets[0];\n if (!target) {\n return;\n }\n\n const targetLocation = target.data.location;\n const piece = source.data.piece;\n if (!isLocation(targetLocation) || !isPiece(piece)) {\n return;\n }\n\n const move: Move = { from: piece.location, to: targetLocation, piece: piece.type };\n if (model.canPromote?.(move)) {\n setPromoting({ ...piece, location: targetLocation });\n } else {\n onDrop?.(move);\n }\n\n setDragging(false);\n },\n });\n }, [model]);\n\n return (\n <BoardContext.Provider value={{ model, dragging, promoting, onPromotion }}>\n <Container classNames={mx('aspect-square', classNames)}>{children}</Container>\n </BoardContext.Provider>\n );\n};\n\nRoot.displayName = 'Board.Root';\n\nexport const Board = {\n Root,\n};\n\nexport type { RootProps as BoardRootProps };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type CSSProperties, forwardRef, type PropsWithChildren } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nexport type ContainerProps = ThemedClassName<\n PropsWithChildren<{\n style?: CSSProperties;\n }>\n>;\n\n/**\n * Container centers the board.\n */\nexport const Container = forwardRef<HTMLDivElement, ContainerProps>(({ children, classNames, style }, forwardedRef) => {\n return (\n <div ref={forwardedRef} style={style} className='flex w-full h-full justify-center overflow-hidden'>\n <div className={mx('max-w-full max-h-full content-center', classNames)}>{children}</div>\n </div>\n );\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport React, { useRef, useState, useEffect, memo } from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { useBoardContext } from './context';\nimport { isPiece, type Location } from './types';\nimport { type DOMRectBounds } from './util';\n\ntype HoveredState = 'idle' | 'validMove' | 'invalidMove';\n\nexport type SquareProps = ThemedClassName<{\n location: Location;\n bounds: DOMRectBounds;\n label?: string;\n}>;\n\nexport const Square = memo(({ location, bounds, label, classNames }: SquareProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const [state, setState] = useState<HoveredState>('idle');\n const { model } = useBoardContext();\n\n useEffect(() => {\n const el = ref.current;\n invariant(el);\n\n return dropTargetForElements({\n element: el,\n getData: () => ({ location }),\n canDrop: ({ source }) => {\n log('canDrop', { source: source.data });\n return true;\n },\n onDragEnter: ({ source }) => {\n log('onDragEnter', { source: source.data });\n const piece = source.data.piece;\n if (!isPiece(piece)) {\n return;\n }\n\n if (model?.isValidMove({ from: piece.location, to: location, piece: piece.type })) {\n setState('validMove');\n } else {\n setState('invalidMove');\n }\n },\n onDragLeave: () => setState('idle'),\n onDrop: () => setState('idle'),\n });\n }, [model, location]);\n\n return (\n <div\n ref={ref}\n style={bounds}\n className={mx(\n 'absolute flex justify-center items-center border-2 box-border select-none',\n classNames,\n state === 'validMove' ? 'border-neutral-800' : 'border-transparent',\n )}\n >\n {label && <div className={mx('absolute bottom-1 left-1 text-xs text-neutral-500')}>{label}</div>}\n </div>\n );\n});\n\nSquare.displayName = 'Square';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\n// import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source';\nimport { centerUnderPointer } from '@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer';\nimport { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';\nimport React, { useState, useRef, useEffect, type FC, type SVGProps, memo } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { useDynamicRef, useTrackProps, type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { useBoardContext } from './context';\nimport { isEqualLocation, isLocation, type Location, type PieceRecord, type Player } from './types';\nimport { type DOMRectBounds } from './util';\n\nexport type PieceProps = ThemedClassName<{\n piece: PieceRecord;\n bounds: DOMRectBounds;\n label?: string;\n orientation?: Player;\n Component: FC<SVGProps<SVGSVGElement>>;\n}>;\n\nexport const Piece = memo(({ classNames, piece, orientation, bounds, label, Component }: PieceProps) => {\n useTrackProps({ classNames, piece, orientation, bounds, label, Component }, Piece.displayName, false);\n const { model } = useBoardContext();\n\n const { dragging: isDragging, promoting } = useBoardContext();\n const promotingRef = useDynamicRef(promoting);\n const [dragging, setDragging] = useState(false);\n const [preview, setPreview] = useState<HTMLElement>();\n\n // Current position.\n const [current, setCurrent] = useState<{ location?: Location; bounds?: DOMRectBounds }>({});\n\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const el = ref.current;\n invariant(el);\n\n return draggable({\n element: el,\n getInitialData: () => ({ piece }),\n onGenerateDragPreview: ({ nativeSetDragImage, location, source }) => {\n log('onGenerateDragPreview', { source: source.data });\n setCustomNativeDragPreview({\n getOffset: centerUnderPointer,\n // getOffset: preserveOffsetOnSource({\n // element: source.element,\n // input: location.current.input,\n // }),\n render: ({ container }) => {\n setPreview(container);\n const { width, height } = el.getBoundingClientRect();\n container.style.width = width + 'px';\n container.style.height = height + 'px';\n return () => {\n setPreview(undefined);\n };\n },\n nativeSetDragImage,\n });\n },\n canDrag: () => !promotingRef.current && model?.turn === piece.side,\n onDragStart: () => setDragging(true),\n onDrop: ({ location: { current } }) => {\n const location = current.dropTargets[0].data.location;\n if (isLocation(location)) {\n setCurrent((current) => ({ ...current, location }));\n }\n\n setDragging(false);\n },\n });\n }, [model, piece]);\n\n // Must update position independently of render cycle (otherwise animation is interrupted).\n useEffect(() => {\n requestAnimationFrame(() => {\n if (!ref.current || !bounds) {\n return;\n }\n\n // Check if piece moved.\n if (!current.location || !isEqualLocation(current.location, piece.location)) {\n ref.current.style.transition = 'top 400ms ease-out, left 400ms ease-out';\n ref.current.style.top = bounds.top + 'px';\n ref.current.style.left = bounds.left + 'px';\n setCurrent({ location: piece.location, bounds });\n } else if (current.bounds !== bounds) {\n ref.current.style.transition = 'none';\n ref.current.style.top = bounds.top + 'px';\n ref.current.style.left = bounds.left + 'px';\n setCurrent({ location: piece.location, bounds });\n }\n });\n }, [current, piece.location, bounds]);\n\n return (\n <>\n <div\n ref={ref}\n style={{\n width: bounds?.width,\n height: bounds?.height,\n }}\n className={mx(\n 'absolute',\n classNames,\n // orientation === 'black' && '_rotate-180',\n dragging && 'opacity-20', // Must not unmount component while dragging.\n isDragging && 'pointer-events-none', // Don't block the square's drop target.\n )}\n >\n <Component className='grow' />\n {label && <div className='absolute inset-1 text-xs text-black'>{label}</div>}\n </div>\n\n {preview &&\n createPortal(\n <div className={mx(classNames)}>\n <Component className='grow' />\n </div>,\n preview,\n )}\n </>\n );\n});\n\nPiece.displayName = 'Piece';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReadonlySignal, signal } from '@preact/signals-core';\nimport { Chess, validateFen } from 'chess.js';\nimport { type FC, type SVGProps } from 'react';\n\nimport { log } from '@dxos/log';\n\nimport {\n type Move,\n type Location,\n type PieceMap,\n locationToString,\n type PieceType,\n type BoardModel,\n type Player,\n} from '../Board';\nimport * as Alpha from '../gen/pieces/chess/alpha';\n\nexport type ChessPiece = 'BK' | 'BQ' | 'BR' | 'BB' | 'BN' | 'BP' | 'WK' | 'WQ' | 'WR' | 'WB' | 'WN' | 'WP';\n\nexport const ChessPieces: Record<ChessPiece, FC<SVGProps<SVGSVGElement>>> = Alpha;\n\nexport const posToLocation = (pos: string): Location => {\n const col = pos.charCodeAt(0) - 'a'.charCodeAt(0);\n const row = parseInt(pos[1]) - 1;\n return [row, col];\n};\n\nexport const locationToPos = ([row, col]: Location): string => {\n return String.fromCharCode(col + 'a'.charCodeAt(0)) + (row + 1);\n};\n\nconst styles = {\n neutral: {\n black: 'bg-neutral-50',\n white: 'bg-neutral-200',\n promotion: 'bg-neutral-200 hover:bg-neutral-300 opacity-70 hover:opacity-100',\n },\n original: {\n black: 'bg-[#6C95B9]',\n white: 'bg-[#CCD3DB]',\n promotion: 'duration-500 bg-[#CCD3DB] opacity-70 hover:opacity-100',\n },\n blue: {\n black: 'bg-[#608BC1]',\n white: 'bg-[#CBDCEB]',\n promotion: 'duration-500 bg-[#CBDCEB] opacity-70 hover:opacity-100',\n },\n green: {\n black: 'bg-[#8EB486]',\n white: 'bg-[#FDF7F4]',\n promotion: 'duration-500 bg-[#FDF7F4] opacity-70 hover:opacity-100',\n },\n};\n\nexport const boardStyles = styles.original;\n\nexport const getSquareColor = ([row, col]: Location) => {\n return (col + row) % 2 === 0 ? boardStyles.black : boardStyles.white;\n};\n\n/**\n * Attempt move.\n */\nconst makeMove = (game: Chess, move: Move): Chess | null => {\n const from = locationToPos(move.from);\n const to = locationToPos(move.to);\n try {\n log('makeMove', { move });\n const promotion = move.promotion ? move.promotion[1].toLowerCase() : 'q';\n game.move({ from, to, promotion }, { strict: false });\n return game;\n } catch (err) {\n // Ignore.\n return null;\n }\n};\n\n/**\n * Chess model.\n */\nexport class ChessModel implements BoardModel<ChessPiece> {\n private _game!: Chess;\n private readonly _pieces = signal<PieceMap<ChessPiece>>({});\n\n constructor(fen?: string) {\n this.initialize(fen);\n }\n\n get turn(): Player {\n return this._game.turn() === 'w' ? 'white' : 'black';\n }\n\n get pieces(): ReadonlySignal<PieceMap<ChessPiece>> {\n return this._pieces;\n }\n\n get game(): Chess {\n return this._game;\n }\n\n get fen(): string {\n return this._game.fen();\n }\n\n initialize(fen?: string): void {\n this._pieces.value = {};\n this._game = new Chess(fen ? (validateFen(fen).ok ? fen : undefined) : undefined);\n this._update();\n }\n\n isValidMove(move: Move): boolean {\n return makeMove(new Chess(this._game.fen()), move) !== null;\n }\n\n canPromote(move: Move): boolean {\n const isPawnMove = move.piece === 'BP' || move.piece === 'WP';\n const isToLastRank = move.to[0] === 0 || move.to[0] === 7;\n return isPawnMove && isToLastRank;\n }\n\n makeMove(move: Move): boolean {\n const game = makeMove(this._game, move);\n if (!game) {\n return false;\n }\n\n this._game = game;\n this._update();\n return true;\n }\n\n makeRandomMove(): boolean {\n const moves = this._game.moves();\n if (!moves.length) {\n return false;\n }\n\n const move = moves[Math.floor(Math.random() * moves.length)];\n this._game.move(move);\n this._update();\n return true;\n }\n\n /**\n * Update pieces preserving identity.\n */\n private _update(): void {\n const pieces: PieceMap<ChessPiece> = {};\n this._game.board().flatMap((row) =>\n row.forEach((record) => {\n if (!record) {\n return;\n }\n\n const { square, type, color } = record;\n const pieceType = `${color.toUpperCase()}${type.toUpperCase()}` as ChessPiece;\n const location = posToLocation(square);\n pieces[locationToString(location)] = {\n id: `${square}-${pieceType}`,\n type: pieceType,\n side: color === 'w' ? 'white' : 'black',\n location,\n };\n }),\n );\n\n this._pieces.value = mapPieces(this._pieces.value, pieces);\n }\n}\n\n/**\n * Preserve the original piece objects (and IDs).\n */\nexport const mapPieces = <T extends PieceType>(before: PieceMap<T>, after: PieceMap<T>): PieceMap<T> => {\n const difference: { added: PieceMap; removed: PieceMap } = {\n removed: {},\n added: {},\n };\n\n (Object.keys(before) as Array<keyof typeof before>).forEach((square) => {\n if (after[square]?.type !== before[square]?.type) {\n difference.removed[square] = before[square];\n }\n });\n\n (Object.keys(after) as Array<keyof typeof after>).forEach((square) => {\n if (before[square]?.type !== after[square]?.type) {\n difference.added[square] = after[square];\n } else {\n after[square] = before[square];\n }\n });\n\n for (const piece of Object.values(difference.added)) {\n const previous = Object.values(difference.removed).find((p) => p.type === piece.type);\n if (previous) {\n piece.id = previous.id;\n }\n }\n\n log('delta', {\n before: Object.keys(before).length,\n after: Object.keys(after).length,\n removed: Object.keys(difference.removed).length,\n added: Object.keys(difference.added).length,\n });\n\n return after;\n};\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBB = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path fill='#f9f9f9' d='M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z' />\n <path\n fill='#101010'\n d='M768 1365q-5 39-26 82h564q-18-36-26-82zm495-73 46-73q-142-49-285-47-144-2-285 47l46 73q118-40 239-38 120-2 239 38m-432 227H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-207l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60zm146-701h-95v89h95v165h94V907h95v-89h-95V714h-94z'\n />\n </svg>\n);\nexport default SvgBB;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBK = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m553 1485-55 320 1048 5-48-335s324-313 330-467c7-153-35-331-241-406-183-67-372 121-372 121l-182-161-190 160S658 586 587 592a373 373 0 0 0-362 333c10 331 328 560 328 560'\n />\n <path\n fill='#101010'\n d='M1024 1769h489l-12-73H547l-12 73zm0-921q-25-60-62-111 31-48 62-65 30 17 62 65-38 51-62 111m-97 454q-154 11-303 58-123-108-200-213t-77-202q0-89 74-159t148-70q67 0 135 63t102 130q30 54 75 175t46 218m-350 217-26 156 145-84zm447-907q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m0 775q-1-126-42-267t-84-227l-14-27-12-23q-28-43-48-69-51-63-120-105t-134-42q-103 0-208 93T257 949q0 120 99 255t249 259q201-74 419-76m0 456H448l61-365q-325-280-326-535-1-159 125-274t267-116q78 0 159 47t142 119q61 74 99 165t49 150q12-60 49-150t99-165q61-72 142-119t159-47q140 0 266 116t126 274q-2 255-326 535l61 365zm97-541q0-97 45-218t76-175q34-68 102-130t135-63q74 0 148 70t74 159q0 96-77 202t-200 213q-150-47-303-58m350 217-119 72 145 84zm-447-132q217 2 419 76 150-125 249-259t99-255q0-136-105-229t-208-93q-66 0-135 42t-119 105q-21 26-48 69l-12 23-14 27q-44 85-85 227t-41 267m-139 159 139 86 139-84-139-86zm92-1248v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95z'\n />\n </svg>\n);\nexport default SvgBK;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBN = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='M1658 1806c-408-301-71-920-452-1343l60-16s296 167 320 257c182 468 41 691 135 1077zM972 523l120 176-312-3zM498 981l-93-41 42-93 127 28z'\n />\n <path\n fill='#101010'\n d='m502 868-52 1-26 64 69 21 46-55zm536-187q34 1-16-68t-80-42L826 680zm-338-98q6-39 116-107t220-144l115-154 96 217q342 172 433 418t47 603q-18 128 5 236t57 190l-1242 1q-9-178 39-301t183-238q50-11 83-39t53-59l63-1 138-29 139-97 66-207q0-17-8-34t-12-37q-62 228-161 289t-191 58q-236-42-292 60l-56 102-217-121 115-82-51-50-122 86-12-297zm981 1192q-102-130-85-308t27-363-50-351-316-276q220 164 253 342t16 351-12 329 167 276'\n />\n </svg>\n);\nexport default SvgBN;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBP = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#101010'\n d='M1024 1843H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74z'\n />\n </svg>\n);\nexport default SvgBP;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBQ = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path fill='#f9f9f9' d='m520 1801.8 41.5-448.7 474-128.9 458 133.5 34.4 446.4z' />\n <path\n fill='#101010'\n d='M590 1519q4 72-15 158l134-86zm434 324H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zm0-450q109 0 222 28.5t213 67.5q2-41 11-89-108-42-221.5-68t-224.5-26-225 26-221 68q8 48 11 89 99-39 212-67.5t223-28.5m0 376h478q-15-34-24-73H570q-10 39-24 73zm434-250-119 72 134 86q-20-86-15-158m-573 47 139 87 139-84-139-86z'\n />\n </svg>\n);\nexport default SvgBQ;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgBR = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path fill='#f9f9f9' d='m674 732-76 807 851 14-75-833z' />\n <path\n fill='#101010'\n d='M1024 1843H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-989h333l-6-88H697l-6 88zm0 647h381l-6-87H649l-6 87z'\n />\n </svg>\n);\nexport default SvgBR;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWB = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m948 366 1-139 148-7 1 147zM564 860c114-267 456-443 456-443s392 176 476 502c-9 209-183 332-183 332l27 221-653 6 46-233s-230-171-169-385m-101 790c175 6 355 23 425-142h92s0 190-88 246c-163 103-625 38-625 38s-15-146 196-142m631 37-36-185 102 5s22 153 315 131c381-17 318 153 318 153l-483 5z'\n />\n <path\n fill='#101010'\n d='M1024 356q66 0 64-66 1-55-64-55-66 0-64 55-3 66 64 66m0 1204q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60l10-16h76q-7 21-3 13-45 105-109 125t-146 19H409q-52 0-86 40t-34 53h424q66 0 159-65t93-185H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-341q0 120 93 185t159 65h424q0-13-34-53t-86-40h-240q-83 0-146-19t-109-125q4 8-3-13h76l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199m0-114h283q-28-84-29-154-120-41-254-38-135-3-254 38-2 70-29 154zm0-267q159-1 285 42 189-180 142-346-60-193-427-431-368 238-427 431-48 166 142 346 125-43 285-42m-47-361V714h94v104h95v89h-95v165h-94V907h-95v-89z'\n />\n </svg>\n);\nexport default SvgWB;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWK = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m501.6 1811 48.4-354.4-260-269.2s-166.4-288.2 29.9-481C582.2 448.7 826 727.2 826 727.2l195.6-165.7 184 165.7s216.4-232.5 430.4-76 255.4 317.6 117.4 531.6c-138.1 214-250.9 280.7-250.9 280.7L1558 1811z'\n />\n <path\n fill='#101010'\n d='M977 298v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95zm47 314q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m-447 907-26 156 145-84zm410-206q-1-147-36.5-274.5T870 845q-45-88-131.5-153T570 627q-103 0-208 93T257 949q0 109 86.5 236T546 1408q212-88 441-95m37 530H448l61-365q-325-280-326-535-1-159 125-274.5T575 553q78 0 158.5 47T876 719q61 74 98.5 164.5T1024 1034q12-60 49-150.5t99-164.5q61-72 142-119t159-47q140 0 266 115.5T1865 943q-2 255-326 535l61 365zm0-74h489l-50-298q-216-84-439-84t-439 84l-50 298zm447-250 26 156-145-84zm-410-206q229 7 441 95 115-96 202-223t87-236q0-136-105.5-229T1478 627q-83 0-169.5 65T1178 845q-46 66-81.5 193.5T1061 1313m-176 233 141-84 137 86-141 84z'\n />\n </svg>\n);\nexport default SvgWK;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWN = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m352 861 787-569 94 148s336 103 398 388c63 286 51 974 51 974l-1088 9s-37-290 184-460c221-171 221-212 221-212s-226-71-295-16-117 138-117 138l-129-67 74-85-88-97-94 56z'\n />\n <path\n fill='#101010'\n d='m1151 178-115 154c-74 50-147 98-220 144-73 45-112 81-116 107L304 846l12 297 122-86 51 50-115 82 217 121 56-102c37-68 135-88 292-60l-55 85c-25 37-63 60-115 71a608 608 0 0 0-183 238c-32 82-45 182-39 301h1242c-23-55-42-118-57-190-15-73-17-152-5-237 29-239 13-440-47-603-61-164-205-303-433-418zm-17 145 59 133a664 664 0 0 1 262 188c55 72 100 150 134 234 27 97 40 181 41 253 0 71-3 140-9 205-7 65-11 131-13 199-2 67 9 145 32 234H621c-4-84 12-158 48-223s85-124 146-177c78-22 129-56 152-102s53-90 90-131c13-10 27-15 38-15 10-1 21 0 33-2 52-7 95-36 129-85 33-49 51-104 52-165l-19-67c-37 159-99 245-188 257l-45 6c-16 1-33 10-52 26-41-25-87-35-138-31q-111 9-165 27l-108 73-39 45-47-28 78-65-138-144-64 41-4-125 366-241c15-34 58-74 131-120l208-131zM960 564c-6 0-12 2-18 7L826 671l212 2c23 0 17-21-16-63-24-31-44-46-62-46M502 868l-33 4-33 56 57 26 46-55z'\n />\n </svg>\n);\nexport default SvgWN;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWP = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m734 981 196-193s-189-82-79-288c79-149 303-114 361 50 63 179-113 240-113 240l226 197Zm-235 799s-8-107 50-154c196-173 338-386 371-599l210 2c33 206 182 447 321 561 101 59 99 199 99 199z'\n />\n <path\n fill='#101010'\n d='M520 1769h1008q8-97-132-182-132-101-196-239t-80-309H928q-15 170-79 309t-197 239q-141 85-132 182m504 74H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74zM756 974h536l-225-191q134-31 134-171 0-76-52-126t-125-51q-73 0-125 51t-52 126q0 140 134 171z'\n />\n </svg>\n);\nexport default SvgWP;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWQ = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m508.5 1815.6 48.4-356.7-216.3-554.6-135.8-20.7-16.1-126.5 112.7-43.8 78.3 73.7-18.4 99 246.2 197.8 112.8-568.3L635 428l78.3-108 112.8 43.7-23 161 223.2 474 244-490-66.8-105.9 92-92 105.9 73.6L1337 534l103.5 529.2 260-161-16-142.7 131-46 57.6 131.1-207 103.6-175 529.2 48.4 308.4z'\n />\n <path\n fill='#101010'\n d='M1024 1769h478q-53-130-43-280-100-39-213-67.5t-222-28.5q-110 0-223 28.5T589 1489q9 150-43 280zm0-450q111 0 223.5 26.5T1468 1413q17-105 60.5-212.5T1634 988l-220 155-123-601-267 555-267-555-123 601-220-155q61 105 104.5 212.5T580 1413q108-41 220.5-67.5T1024 1319m0 524H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zM276 746q-62 0-62 62t62 62q63 0 63-62t-63-62m466-394q-62 0-62 62t62 62 62-62-62-62M590 1519l119 72-134 86q19-86 15-158m1182-773q-63 0-63 62t63 62q62 0 62-62t-62-62m-466-394q-62 0-62 62t62 62 62-62-62-62m152 1167-119 72 134 86q-20-86-15-158m-573 47 139-83 139 86-139 84z'\n />\n </svg>\n);\nexport default SvgWQ;\n", "import * as React from 'react';\nimport type { SVGProps } from 'react';\nconst SvgWR = (props: SVGProps<SVGSVGElement>) => (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2048 2048' {...props}>\n <path\n fill='#f9f9f9'\n d='m435 1804 16-212 152-115 51-688-148-115-7-276 210-2 4 138 198 2 7-140 212-3 14 145 193-4 5-138h204l-7 285-145 106 42 693 172 124 19 207z'\n />\n <path\n fill='#101010'\n d='M1024 1501H643l5-74h752l5 74zm0-661H692l5-74h654l5 74zm0 1003H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-74h557l-15-149-161-119-54-735 152-109 13-230h-138v148h-285V427H955v148H670V427H532l13 230 152 109-54 735-161 119-15 149z'\n />\n </svg>\n);\nexport default SvgWR;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, useRef, useMemo, useEffect, useState, memo } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { useTrackProps } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\nimport { isNotFalsy } from '@dxos/util';\n\nimport { boardStyles, type ChessPiece, ChessPieces, getSquareColor, locationToPos } from './chess';\nimport {\n type DOMRectBounds,\n type Location,\n type PieceRecord,\n type Player,\n Piece,\n Square,\n getRelativeBounds,\n locationToString,\n} from '../Board';\nimport { useBoardContext } from '../Board';\n\nexport type ChessboardProps = PropsWithChildren<{\n orientation?: Player;\n showLabels?: boolean;\n debug?: boolean;\n rows?: number;\n cols?: number;\n}>;\n\n/**\n * Chessboard layout.\n */\nexport const Chessboard = memo(({ orientation, showLabels, debug, rows = 8, cols = 8 }: ChessboardProps) => {\n useTrackProps({ orientation, showLabels, debug }, Chessboard.displayName, false);\n const { ref: containerRef, width, height } = useResizeDetector({ refreshRate: 200 });\n const { model, promoting, onPromotion } = useBoardContext();\n\n const locations = useMemo<Location[]>(() => {\n return Array.from({ length: rows }, (_, i) => (orientation === 'black' ? i : rows - 1 - i)).flatMap((row) =>\n Array.from({ length: cols }).map((_, col) => [row, col] as Location),\n );\n }, [orientation, rows, cols]);\n\n // Use DOM grid layout to position squares.\n const layout = useMemo(() => {\n return locations.map((location) => {\n return (\n <div\n key={locationToString(location)}\n {...{\n ['data-location' as const]: locationToString(location),\n }}\n />\n );\n });\n }, [locations]);\n\n // Build map of square locations to bounds.\n const [grid, setGrid] = useState<Record<string, DOMRectBounds>>({});\n const gridRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n setGrid(\n locations.reduce(\n (acc, location) => {\n const square = getSquareLocation(gridRef.current!, location)!;\n const bounds = getRelativeBounds(gridRef.current!, square);\n return { ...acc, [locationToString(location)]: bounds };\n },\n {} as Record<string, DOMRectBounds>,\n ),\n );\n }, [locations, width, height]);\n\n // Get the bounds of each square and piece.\n const positions = useMemo<{ piece: PieceRecord; bounds: DOMRectBounds }[]>(() => {\n if (!gridRef.current) {\n return [];\n }\n\n return Object.values(model?.pieces.value ?? {})\n .map((piece) => {\n if (piece.id === promoting?.id) {\n return null;\n }\n\n const bounds = grid[locationToString(piece.location)];\n return { piece, bounds };\n })\n .filter(isNotFalsy);\n }, [grid, model?.pieces.value, promoting]);\n\n return (\n <div ref={containerRef} className='relative'>\n <div ref={gridRef} className='grid grid-rows-8 grid-cols-8 aspect-square select-none'>\n {layout}\n </div>\n <div>\n {locations.map((location) => (\n <Square\n key={locationToString(location)}\n location={location}\n label={showLabels ? locationToPos(location) : undefined}\n bounds={grid[locationToString(location)]}\n classNames={getSquareColor(location)}\n />\n ))}\n </div>\n <div className={mx(promoting && 'opacity-50')}>\n {positions.map(({ bounds, piece }) => (\n <Piece\n key={piece.id}\n piece={piece}\n bounds={bounds}\n label={debug ? piece.id : undefined}\n orientation={orientation}\n Component={ChessPieces[piece.type as ChessPiece]}\n />\n ))}\n </div>\n <div>\n {promoting && (\n <PromotionSelector\n grid={grid}\n piece={promoting}\n onSelect={(piece) => {\n onPromotion({\n from: Object.values(model!.pieces.value).find((p) => p.id === promoting.id)!.location,\n to: piece.location,\n piece: promoting.type,\n promotion: piece.type,\n });\n }}\n />\n )}\n </div>\n </div>\n );\n});\n\nChessboard.displayName = 'Chessboard';\n\nconst getSquareLocation = (container: HTMLElement, location: Location): HTMLElement | null => {\n return container.querySelector(`[data-location=\"${locationToString(location)}\"]`);\n};\n\nconst PromotionSelector = ({\n grid,\n piece,\n onSelect,\n}: {\n grid: Record<string, DOMRectBounds>;\n piece: PieceRecord;\n onSelect: (piece: PieceRecord) => void;\n}) => {\n const positions = ['Q', 'N', 'R', 'B'].map((pieceType, i) => {\n const location = [piece.location[0] + (piece.location[0] === 0 ? i : -i), piece.location[1]] as Location;\n return {\n piece: {\n id: `promotion-${pieceType}`,\n type: (piece.side === 'black' ? 'B' : 'W') + pieceType,\n side: piece.side,\n location,\n },\n bounds: grid[locationToString(location)],\n };\n });\n\n const handleSelect = (selected: PieceRecord) => {\n onSelect({ ...piece, type: selected.type });\n };\n\n // TODO(burdon): Circle.\n return (\n <div>\n {positions.map(({ piece, bounds }) => (\n <div key={piece.id} style={bounds} onClick={() => handleSelect(piece)}>\n <Piece\n piece={piece}\n bounds={bounds}\n Component={ChessPieces[piece.type as ChessPiece]}\n classNames={mx('border-2 border-neutral-700 rounded-full', boardStyles.promotion)}\n />\n </div>\n ))}\n </div>\n );\n};\n"],
5
+ "mappings": ";;;;;;;AAIA,SAASA,eAAeC,kBAAkB;AAE1C,SAASC,aAAa;AAWf,IAAMC,eAAeC,cAA4CC,MAAAA;AAEjE,IAAMC,kBAAkB,MAAA;AAC7B,SAAOC,WAAWJ,YAAAA,KAAiBK,MAAM,IAAIC,MAAM,sBAAA,CAAA;AACrD;;;ACUO,IAAMC,mBAAmB,CAACC,aAA+BA,SAASC,KAAK,GAAA;AACvE,IAAMC,mBAAmB,CAACC,QAA0BA,IAAIC,MAAM,GAAA,EAAKC,IAAIC,MAAAA;AAGvE,IAAMC,UAAU,CAACC,UACtBA,SAAS,QACT,OAAOA,UAAU,YACjB,QAAQA,SACR,UAAUA,SACV,cAAcA,SACdC,WAAWD,MAAMR,QAAQ;AAGpB,IAAMS,aAAa,CAACC,UACzBC,MAAMC,QAAQF,KAAAA,KAAUA,MAAMG,WAAW,KAAKH,MAAMI,MAAM,CAACC,QAAQ,OAAOA,QAAQ,QAAA;AAE7E,IAAMC,kBAAkB,CAACC,IAAcC,OAA0BD,GAAG,CAAA,MAAOC,GAAG,CAAA,KAAMD,GAAG,CAAA,MAAOC,GAAG,CAAA;;;ACzCjG,IAAMC,oBAAoB,CAACC,WAAwBC,YAAAA;AACxD,QAAMC,gBAAgBF,UAAUG,sBAAqB;AACrD,QAAMC,cAAcH,QAAQE,sBAAqB;AACjD,SAAO;IACLE,KAAKD,YAAYC,MAAMH,cAAcG;IACrCC,MAAMF,YAAYE,OAAOJ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B,gBAAAf,QAAA,cAACC,OAAAA;MAAIC,KAAKoB,OAAMC;MAAI2B,OAAOnC;MAAQoC,SAAS,MAAMH,aAAa1B,MAAAA;OAC7D,gBAAAtB,QAAA,cAACkC,OAAAA;MACCZ,OAAOA;MACPP;MACAoB,WAAWC,YAAYd,OAAMe,IAAI;MACjCN,YAAYE,IAAG,4CAA4CmB,YAAYT,SAAS;;;;;AAM5F;",
6
+ "names": ["createContext", "useContext", "raise", "BoardContext", "createContext", "undefined", "useBoardContext", "useContext", "raise", "Error", "locationToString", "location", "join", "stringToLocation", "str", "split", "map", "Number", "isPiece", "piece", "isLocation", "token", "Array", "isArray", "length", "every", "val", "isEqualLocation", "l1", "l2", "getRelativeBounds", "container", "element", "containerRect", "getBoundingClientRect", "elementRect", "top", "left", "width", "height", "monitorForElements", "React", "useCallback", "useEffect", "useState", "log", "mx", "React", "forwardRef", "mx", "Container", "forwardRef", "children", "classNames", "style", "forwardedRef", "div", "ref", "className", "mx", "Root", "children", "classNames", "model", "onDrop", "dragging", "setDragging", "useState", "promoting", "setPromoting", "onPromotion", "useCallback", "move", "log", "undefined", "useEffect", "monitorForElements", "onDragStart", "source", "location", "target", "current", "dropTargets", "targetLocation", "data", "piece", "isLocation", "isPiece", "from", "to", "type", "canPromote", "React", "BoardContext", "Provider", "value", "Container", "mx", "displayName", "Board", "dropTargetForElements", "React", "useRef", "useState", "useEffect", "memo", "invariant", "log", "mx", "Square", "memo", "location", "bounds", "label", "classNames", "ref", "useRef", "state", "setState", "useState", "model", "useBoardContext", "useEffect", "el", "current", "invariant", "dropTargetForElements", "element", "getData", "canDrop", "source", "log", "data", "onDragEnter", "piece", "isPiece", "isValidMove", "from", "to", "type", "onDragLeave", "onDrop", "React", "div", "style", "className", "mx", "displayName", "draggable", "centerUnderPointer", "setCustomNativeDragPreview", "React", "useState", "useRef", "useEffect", "memo", "createPortal", "invariant", "log", "useDynamicRef", "useTrackProps", "mx", "Piece", "memo", "classNames", "piece", "orientation", "bounds", "label", "Component", "useTrackProps", "displayName", "model", "useBoardContext", "dragging", "isDragging", "promoting", "promotingRef", "useDynamicRef", "setDragging", "useState", "preview", "setPreview", "current", "setCurrent", "ref", "useRef", "useEffect", "el", "invariant", "draggable", "element", "getInitialData", "onGenerateDragPreview", "nativeSetDragImage", "location", "source", "log", "data", "setCustomNativeDragPreview", "getOffset", "centerUnderPointer", "render", "container", "width", "height", "getBoundingClientRect", "style", "undefined", "canDrag", "turn", "side", "onDragStart", "onDrop", "dropTargets", "isLocation", "requestAnimationFrame", "isEqualLocation", "transition", "top", "left", "React", "div", "className", "mx", "createPortal", "signal", "Chess", "validateFen", "log", "React", "SvgBB", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBK", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBN", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBP", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBQ", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgBR", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWB", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWK", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWN", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWP", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWQ", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "React", "SvgWR", "props", "svg", "xmlns", "viewBox", "path", "fill", "d", "ChessPieces", "Alpha", "posToLocation", "pos", "col", "charCodeAt", "row", "parseInt", "locationToPos", "String", "fromCharCode", "styles", "neutral", "black", "white", "promotion", "original", "blue", "green", "boardStyles", "getSquareColor", "makeMove", "game", "move", "from", "to", "log", "toLowerCase", "strict", "err", "ChessModel", "fen", "_pieces", "signal", "initialize", "turn", "_game", "pieces", "value", "Chess", "validateFen", "ok", "undefined", "_update", "isValidMove", "canPromote", "isPawnMove", "piece", "isToLastRank", "makeRandomMove", "moves", "length", "Math", "floor", "random", "board", "flatMap", "forEach", "record", "square", "type", "color", "pieceType", "toUpperCase", "location", "locationToString", "id", "side", "mapPieces", "before", "after", "difference", "removed", "added", "Object", "keys", "values", "previous", "find", "p", "React", "useRef", "useMemo", "useEffect", "useState", "memo", "useResizeDetector", "useTrackProps", "mx", "isNotFalsy", "Chessboard", "memo", "orientation", "showLabels", "debug", "rows", "cols", "useTrackProps", "displayName", "ref", "containerRef", "width", "height", "useResizeDetector", "refreshRate", "model", "promoting", "onPromotion", "useBoardContext", "locations", "useMemo", "Array", "from", "length", "_", "i", "flatMap", "row", "map", "col", "layout", "location", "React", "div", "key", "locationToString", "grid", "setGrid", "useState", "gridRef", "useRef", "useEffect", "reduce", "acc", "square", "getSquareLocation", "current", "bounds", "getRelativeBounds", "positions", "Object", "values", "pieces", "value", "piece", "id", "filter", "isNotFalsy", "className", "Square", "label", "locationToPos", "undefined", "classNames", "getSquareColor", "mx", "Piece", "Component", "ChessPieces", "type", "PromotionSelector", "onSelect", "find", "p", "to", "promotion", "container", "querySelector", "pieceType", "side", "handleSelect", "selected", "style", "onClick", "boardStyles"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/ui/react-ui-gameboard/src/Board/context.ts":{"bytes":1813,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/types.ts":{"bytes":3933,"imports":[],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/util.ts":{"bytes":1953,"imports":[],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/Container.tsx":{"bytes":2409,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/Board.tsx":{"bytes":9211,"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Board/Container.tsx","kind":"import-statement","original":"./Container"},{"path":"packages/ui/react-ui-gameboard/src/Board/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/ui/react-ui-gameboard/src/Board/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/Square.tsx":{"bytes":8175,"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Board/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/ui/react-ui-gameboard/src/Board/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/Piece.tsx":{"bytes":17474,"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-dom","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Board/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/ui/react-ui-gameboard/src/Board/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/index.ts":{"bytes":1013,"imports":[{"path":"packages/ui/react-ui-gameboard/src/Board/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/ui/react-ui-gameboard/src/Board/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/ui/react-ui-gameboard/src/Board/util.ts","kind":"import-statement","original":"./util"},{"path":"packages/ui/react-ui-gameboard/src/Board/Board.tsx","kind":"import-statement","original":"./Board"},{"path":"packages/ui/react-ui-gameboard/src/Board/Container.tsx","kind":"import-statement","original":"./Container"},{"path":"packages/ui/react-ui-gameboard/src/Board/Square.tsx","kind":"import-statement","original":"./Square"},{"path":"packages/ui/react-ui-gameboard/src/Board/Piece.tsx","kind":"import-statement","original":"./Piece"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bB.tsx":{"bytes":2824,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bK.tsx":{"bytes":4192,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bN.tsx":{"bytes":2800,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bP.tsx":{"bytes":1777,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bQ.tsx":{"bytes":3209,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bR.tsx":{"bytes":1986,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wB.tsx":{"bytes":4010,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wK.tsx":{"bytes":3654,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wN.tsx":{"bytes":3872,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wP.tsx":{"bytes":2843,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wQ.tsx":{"bytes":4397,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wR.tsx":{"bytes":2540,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/index.ts":{"bytes":2020,"imports":[{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bB.tsx","kind":"import-statement","original":"./bB"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bK.tsx","kind":"import-statement","original":"./bK"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bN.tsx","kind":"import-statement","original":"./bN"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bP.tsx","kind":"import-statement","original":"./bP"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bQ.tsx","kind":"import-statement","original":"./bQ"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bR.tsx","kind":"import-statement","original":"./bR"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wB.tsx","kind":"import-statement","original":"./wB"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wK.tsx","kind":"import-statement","original":"./wK"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wN.tsx","kind":"import-statement","original":"./wN"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wP.tsx","kind":"import-statement","original":"./wP"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wQ.tsx","kind":"import-statement","original":"./wQ"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wR.tsx","kind":"import-statement","original":"./wR"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Chessboard/chess.ts":{"bytes":19843,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"chess.js","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Board/index.ts","kind":"import-statement","original":"../Board"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/index.ts","kind":"import-statement","original":"../gen/pieces/chess/alpha"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Chessboard/Chessboard.tsx":{"bytes":20219,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Chessboard/chess.ts","kind":"import-statement","original":"./chess"},{"path":"packages/ui/react-ui-gameboard/src/Board/index.ts","kind":"import-statement","original":"../Board"},{"path":"packages/ui/react-ui-gameboard/src/Board/index.ts","kind":"import-statement","original":"../Board"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Chessboard/index.ts":{"bytes":604,"imports":[{"path":"packages/ui/react-ui-gameboard/src/Chessboard/chess.ts","kind":"import-statement","original":"./chess"},{"path":"packages/ui/react-ui-gameboard/src/Chessboard/Chessboard.tsx","kind":"import-statement","original":"./Chessboard"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/index.ts":{"bytes":589,"imports":[{"path":"packages/ui/react-ui-gameboard/src/Board/index.ts","kind":"import-statement","original":"./Board"},{"path":"packages/ui/react-ui-gameboard/src/Chessboard/index.ts","kind":"import-statement","original":"./Chessboard"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-gameboard/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":59432},"packages/ui/react-ui-gameboard/dist/lib/browser/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-dom","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"chess.js","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Board","BoardContext","ChessModel","ChessPieces","Chessboard","Container","Piece","Square","boardStyles","getRelativeBounds","getSquareColor","isEqualLocation","isLocation","isPiece","locationToPos","locationToString","mapPieces","posToLocation","stringToLocation","useBoardContext"],"entryPoint":"packages/ui/react-ui-gameboard/src/index.ts","inputs":{"packages/ui/react-ui-gameboard/src/Board/context.ts":{"bytesInOutput":242},"packages/ui/react-ui-gameboard/src/Board/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-gameboard/src/Board/types.ts":{"bytesInOutput":466},"packages/ui/react-ui-gameboard/src/Board/util.ts":{"bytesInOutput":339},"packages/ui/react-ui-gameboard/src/Board/Board.tsx":{"bytesInOutput":2292},"packages/ui/react-ui-gameboard/src/Board/Container.tsx":{"bytesInOutput":478},"packages/ui/react-ui-gameboard/src/Board/Square.tsx":{"bytesInOutput":2268},"packages/ui/react-ui-gameboard/src/Board/Piece.tsx":{"bytesInOutput":4619},"packages/ui/react-ui-gameboard/src/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-gameboard/src/Chessboard/chess.ts":{"bytesInOutput":4543},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/index.ts":{"bytesInOutput":341},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bB.tsx":{"bytesInOutput":932},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bK.tsx":{"bytesInOutput":1508},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bN.tsx":{"bytesInOutput":912},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bP.tsx":{"bytesInOutput":486},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bQ.tsx":{"bytesInOutput":1097},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bR.tsx":{"bytesInOutput":578},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wB.tsx":{"bytesInOutput":1434},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wK.tsx":{"bytesInOutput":1282},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wN.tsx":{"bytesInOutput":1376},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wP.tsx":{"bytesInOutput":935},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wQ.tsx":{"bytesInOutput":1601},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wR.tsx":{"bytesInOutput":804},"packages/ui/react-ui-gameboard/src/Chessboard/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-gameboard/src/Chessboard/Chessboard.tsx":{"bytesInOutput":4689}},"bytes":35264}}}
1
+ {"inputs":{"packages/ui/react-ui-gameboard/src/Board/context.ts":{"bytes":1773,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/types.ts":{"bytes":3893,"imports":[],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/util.ts":{"bytes":1909,"imports":[],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/Container.tsx":{"bytes":2587,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/Board.tsx":{"bytes":9565,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Board/Container.tsx","kind":"import-statement","original":"./Container"},{"path":"packages/ui/react-ui-gameboard/src/Board/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/ui/react-ui-gameboard/src/Board/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/Square.tsx":{"bytes":8497,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Board/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/ui/react-ui-gameboard/src/Board/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/Piece.tsx":{"bytes":17948,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-dom","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Board/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/ui/react-ui-gameboard/src/Board/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Board/index.ts":{"bytes":973,"imports":[{"path":"packages/ui/react-ui-gameboard/src/Board/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/ui/react-ui-gameboard/src/Board/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/ui/react-ui-gameboard/src/Board/util.ts","kind":"import-statement","original":"./util"},{"path":"packages/ui/react-ui-gameboard/src/Board/Board.tsx","kind":"import-statement","original":"./Board"},{"path":"packages/ui/react-ui-gameboard/src/Board/Container.tsx","kind":"import-statement","original":"./Container"},{"path":"packages/ui/react-ui-gameboard/src/Board/Square.tsx","kind":"import-statement","original":"./Square"},{"path":"packages/ui/react-ui-gameboard/src/Board/Piece.tsx","kind":"import-statement","original":"./Piece"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bB.tsx":{"bytes":3014,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bK.tsx":{"bytes":4382,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bN.tsx":{"bytes":2994,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bP.tsx":{"bytes":1959,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bQ.tsx":{"bytes":3399,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bR.tsx":{"bytes":2180,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wB.tsx":{"bytes":4200,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wK.tsx":{"bytes":3848,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wN.tsx":{"bytes":4066,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wP.tsx":{"bytes":3037,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wQ.tsx":{"bytes":4591,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wR.tsx":{"bytes":2730,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/index.ts":{"bytes":1980,"imports":[{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bB.tsx","kind":"import-statement","original":"./bB"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bK.tsx","kind":"import-statement","original":"./bK"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bN.tsx","kind":"import-statement","original":"./bN"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bP.tsx","kind":"import-statement","original":"./bP"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bQ.tsx","kind":"import-statement","original":"./bQ"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bR.tsx","kind":"import-statement","original":"./bR"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wB.tsx","kind":"import-statement","original":"./wB"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wK.tsx","kind":"import-statement","original":"./wK"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wN.tsx","kind":"import-statement","original":"./wN"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wP.tsx","kind":"import-statement","original":"./wP"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wQ.tsx","kind":"import-statement","original":"./wQ"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wR.tsx","kind":"import-statement","original":"./wR"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Chessboard/chess.ts":{"bytes":19535,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"chess.js","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Board/index.ts","kind":"import-statement","original":"../Board"},{"path":"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/index.ts","kind":"import-statement","original":"../gen/pieces/chess/alpha"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Chessboard/Chessboard.tsx":{"bytes":20854,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-gameboard/src/Chessboard/chess.ts","kind":"import-statement","original":"./chess"},{"path":"packages/ui/react-ui-gameboard/src/Board/index.ts","kind":"import-statement","original":"../Board"},{"path":"packages/ui/react-ui-gameboard/src/Board/index.ts","kind":"import-statement","original":"../Board"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/Chessboard/index.ts":{"bytes":572,"imports":[{"path":"packages/ui/react-ui-gameboard/src/Chessboard/chess.ts","kind":"import-statement","original":"./chess"},{"path":"packages/ui/react-ui-gameboard/src/Chessboard/Chessboard.tsx","kind":"import-statement","original":"./Chessboard"}],"format":"esm"},"packages/ui/react-ui-gameboard/src/index.ts":{"bytes":557,"imports":[{"path":"packages/ui/react-ui-gameboard/src/Board/index.ts","kind":"import-statement","original":"./Board"},{"path":"packages/ui/react-ui-gameboard/src/Chessboard/index.ts","kind":"import-statement","original":"./Chessboard"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-gameboard/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":59644},"packages/ui/react-ui-gameboard/dist/lib/browser/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-dom","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"chess.js","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Board","BoardContext","ChessModel","ChessPieces","Chessboard","Container","Piece","Square","boardStyles","getRelativeBounds","getSquareColor","isEqualLocation","isLocation","isPiece","locationToPos","locationToString","mapPieces","posToLocation","stringToLocation","useBoardContext"],"entryPoint":"packages/ui/react-ui-gameboard/src/index.ts","inputs":{"packages/ui/react-ui-gameboard/src/Board/context.ts":{"bytesInOutput":242},"packages/ui/react-ui-gameboard/src/Board/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-gameboard/src/Board/types.ts":{"bytesInOutput":466},"packages/ui/react-ui-gameboard/src/Board/util.ts":{"bytesInOutput":339},"packages/ui/react-ui-gameboard/src/Board/Board.tsx":{"bytesInOutput":2605},"packages/ui/react-ui-gameboard/src/Board/Container.tsx":{"bytesInOutput":647},"packages/ui/react-ui-gameboard/src/Board/Square.tsx":{"bytesInOutput":2559},"packages/ui/react-ui-gameboard/src/Board/Piece.tsx":{"bytesInOutput":5026},"packages/ui/react-ui-gameboard/src/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-gameboard/src/Chessboard/chess.ts":{"bytesInOutput":4543},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/index.ts":{"bytesInOutput":341},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bB.tsx":{"bytesInOutput":1145},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bK.tsx":{"bytesInOutput":1721},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bN.tsx":{"bytesInOutput":1125},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bP.tsx":{"bytesInOutput":687},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bQ.tsx":{"bytesInOutput":1310},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/bR.tsx":{"bytesInOutput":793},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wB.tsx":{"bytesInOutput":1649},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wK.tsx":{"bytesInOutput":1497},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wN.tsx":{"bytesInOutput":1591},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wP.tsx":{"bytesInOutput":1150},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wQ.tsx":{"bytesInOutput":1816},"packages/ui/react-ui-gameboard/src/gen/pieces/chess/alpha/wR.tsx":{"bytesInOutput":1019},"packages/ui/react-ui-gameboard/src/Chessboard/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-gameboard/src/Chessboard/Chessboard.tsx":{"bytesInOutput":5198}},"bytes":39511}}}