@2sheep/mcp 0.0.0-stage → 0.1.0
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.
- package/README.md +80 -2
- package/dist/cli.js +27 -0
- package/package.json +28 -4
package/dist/cli.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var tD=Object.defineProperty;var E=(e,r)=>tD(e,"name",{value:r,configurable:!0});import{McpServer as OM}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as IM}from"@modelcontextprotocol/sdk/server/stdio.js";import{existsSync as By,mkdirSync as ky,readFileSync as by,writeFileSync as vy}from"node:fs";import{join as ch}from"node:path";var ie;(function(e){e[e.DEV_CARD_UNSPECIFIED=0]="DEV_CARD_UNSPECIFIED",e[e.DEV_CARD_KNIGHT=1]="DEV_CARD_KNIGHT",e[e.DEV_CARD_VICTORY_POINT=2]="DEV_CARD_VICTORY_POINT",e[e.DEV_CARD_ROAD_BUILDING=3]="DEV_CARD_ROAD_BUILDING",e[e.DEV_CARD_YEAR_OF_PLENTY=4]="DEV_CARD_YEAR_OF_PLENTY",e[e.DEV_CARD_MONOPOLY=5]="DEV_CARD_MONOPOLY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ie||(ie={}));var F;(function(e){e[e.BUILDING_UNSPECIFIED=0]="BUILDING_UNSPECIFIED",e[e.BUILDING_DEV_CARD=1]="BUILDING_DEV_CARD",e[e.BUILDING_ROAD=2]="BUILDING_ROAD",e[e.BUILDING_SETTLEMENT=3]="BUILDING_SETTLEMENT",e[e.BUILDING_CITY=4]="BUILDING_CITY",e[e.BUILDING_SHIP=5]="BUILDING_SHIP",e[e.BUILDING_KNIGHT=6]="BUILDING_KNIGHT",e[e.BUILDING_ROAD_OR_SHIP=7]="BUILDING_ROAD_OR_SHIP",e[e.BUILDING_BROKEN_CITY=8]="BUILDING_BROKEN_CITY",e[e.BUILDING_BROKEN_ROAD=9]="BUILDING_BROKEN_ROAD",e[e.BUILDING_BRIDGE=10]="BUILDING_BRIDGE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(F||(F={}));var S;(function(e){e[e.RESOURCE_UNSPECIFIED=0]="RESOURCE_UNSPECIFIED",e[e.RESOURCE_WOOD=1]="RESOURCE_WOOD",e[e.RESOURCE_BRICK=2]="RESOURCE_BRICK",e[e.RESOURCE_SHEEP=3]="RESOURCE_SHEEP",e[e.RESOURCE_WHEAT=4]="RESOURCE_WHEAT",e[e.RESOURCE_ORE=5]="RESOURCE_ORE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(S||(S={}));var Se;(function(e){e[e.FISH_UNSPECIFIED=0]="FISH_UNSPECIFIED",e[e.FISH_ONE_FISH=1]="FISH_ONE_FISH",e[e.FISH_TWO_FISH=2]="FISH_TWO_FISH",e[e.FISH_THREE_FISH=3]="FISH_THREE_FISH",e[e.FISH_OLD_BOOT=4]="FISH_OLD_BOOT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Se||(Se={}));var d;(function(e){e[e.TERRAIN_UNSPECIFIED=0]="TERRAIN_UNSPECIFIED",e[e.TERRAIN_FOREST=1]="TERRAIN_FOREST",e[e.TERRAIN_HILLS=2]="TERRAIN_HILLS",e[e.TERRAIN_PASTURE=3]="TERRAIN_PASTURE",e[e.TERRAIN_FIELDS=4]="TERRAIN_FIELDS",e[e.TERRAIN_MOUNTAINS=5]="TERRAIN_MOUNTAINS",e[e.TERRAIN_DESERT=6]="TERRAIN_DESERT",e[e.TERRAIN_SEA=7]="TERRAIN_SEA",e[e.TERRAIN_GOLD=8]="TERRAIN_GOLD",e[e.TERRAIN_LAKE_A=9]="TERRAIN_LAKE_A",e[e.TERRAIN_LAKE_B=10]="TERRAIN_LAKE_B",e[e.TERRAIN_FOG=11]="TERRAIN_FOG",e[e.TERRAIN_WATERING_HOLE=12]="TERRAIN_WATERING_HOLE",e[e.TERRAIN_SWAMP=13]="TERRAIN_SWAMP",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(d||(d={}));var x;(function(e){e[e.PLAYER_COLOR_UNSPECIFIED=0]="PLAYER_COLOR_UNSPECIFIED",e[e.PLAYER_COLOR_RED=1]="PLAYER_COLOR_RED",e[e.PLAYER_COLOR_BLUE=2]="PLAYER_COLOR_BLUE",e[e.PLAYER_COLOR_WHITE=3]="PLAYER_COLOR_WHITE",e[e.PLAYER_COLOR_ORANGE=4]="PLAYER_COLOR_ORANGE",e[e.PLAYER_COLOR_YELLOW=5]="PLAYER_COLOR_YELLOW",e[e.PLAYER_COLOR_GREEN=6]="PLAYER_COLOR_GREEN",e[e.PLAYER_COLOR_TEAL=7]="PLAYER_COLOR_TEAL",e[e.PLAYER_COLOR_PURPLE=8]="PLAYER_COLOR_PURPLE",e[e.PLAYER_COLOR_PINK=9]="PLAYER_COLOR_PINK",e[e.PLAYER_COLOR_BLACK=10]="PLAYER_COLOR_BLACK",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(x||(x={}));var Ir;(function(e){e[e.FREE_RESOURCE_REASON_UNSPECIFIED=0]="FREE_RESOURCE_REASON_UNSPECIFIED",e[e.FREE_RESOURCE_REASON_YEAR_OF_PLENTY=1]="FREE_RESOURCE_REASON_YEAR_OF_PLENTY",e[e.FREE_RESOURCE_REASON_GOLD_TILE=2]="FREE_RESOURCE_REASON_GOLD_TILE",e[e.FREE_RESOURCE_REASON_AQUEDUCT=3]="FREE_RESOURCE_REASON_AQUEDUCT",e[e.FREE_RESOURCE_REASON_GOLD_TILE_DISCOVERY=4]="FREE_RESOURCE_REASON_GOLD_TILE_DISCOVERY",e[e.FREE_RESOURCE_REASON_FISH=5]="FREE_RESOURCE_REASON_FISH",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Ir||(Ir={}));var dn;(function(e){e[e.FREE_STRUCTURE_REASON_UNSPECIFIED=0]="FREE_STRUCTURE_REASON_UNSPECIFIED",e[e.FREE_STRUCTURE_REASON_FISH=1]="FREE_STRUCTURE_REASON_FISH",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(dn||(dn={}));var ht;(function(e){e[e.WIN_REASON_UNSPECIFIED=0]="WIN_REASON_UNSPECIFIED",e[e.WIN_REASON_VICTORY_POINTS=1]="WIN_REASON_VICTORY_POINTS",e[e.WIN_REASON_ALL_DESERT=2]="WIN_REASON_ALL_DESERT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ht||(ht={}));var zr;(function(e){e[e.ROBBER_MODE_UNSPECIFIED=0]="ROBBER_MODE_UNSPECIFIED",e[e.ROBBER_MODE_NORMAL=1]="ROBBER_MODE_NORMAL",e[e.ROBBER_MODE_FRIENDLY=2]="ROBBER_MODE_FRIENDLY",e[e.ROBBER_MODE_LAZY=3]="ROBBER_MODE_LAZY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(zr||(zr={}));var br;(function(e){e[e.DICE_MODE_UNSPECIFIED=0]="DICE_MODE_UNSPECIFIED",e[e.DICE_MODE_RANDOM=1]="DICE_MODE_RANDOM",e[e.DICE_MODE_SEEDED=2]="DICE_MODE_SEEDED",e[e.DICE_MODE_BALANCED=3]="DICE_MODE_BALANCED",e[e.DICE_MODE_EVENT_CARDS=6]="DICE_MODE_EVENT_CARDS",e[e.DICE_MODE_SEEDED_MIXED=7]="DICE_MODE_SEEDED_MIXED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(br||(br={}));var fr;(function(e){e[e.WIN_CONDITION_UNSPECIFIED=0]="WIN_CONDITION_UNSPECIFIED",e[e.WIN_CONDITION_VICTORY_POINTS=1]="WIN_CONDITION_VICTORY_POINTS",e[e.WIN_CONDITION_BUILD_ALL_SETTLEMENTS=2]="WIN_CONDITION_BUILD_ALL_SETTLEMENTS",e[e.WIN_CONDITION_BUILD_ALL_CITIES=3]="WIN_CONDITION_BUILD_ALL_CITIES",e[e.WIN_CONDITION_BUILD_ALL_ROADS=4]="WIN_CONDITION_BUILD_ALL_ROADS",e[e.WIN_CONDITION_BUILD_ALL_PIECES=5]="WIN_CONDITION_BUILD_ALL_PIECES",e[e.WIN_CONDITION_BUY_ALL_DEV_CARDS=6]="WIN_CONDITION_BUY_ALL_DEV_CARDS",e[e.WIN_CONDITION_COLLECT_RESOURCES=7]="WIN_CONDITION_COLLECT_RESOURCES",e[e.WIN_CONDITION_TURN_LIMIT=8]="WIN_CONDITION_TURN_LIMIT",e[e.WIN_CONDITION_SETTLE_ALL_2TO1_PORTS=9]="WIN_CONDITION_SETTLE_ALL_2TO1_PORTS",e[e.WIN_CONDITION_SETTLE_ALL_3TO1_PORTS=10]="WIN_CONDITION_SETTLE_ALL_3TO1_PORTS",e[e.WIN_CONDITION_BUILD_ALL_COASTAL_ROADS=11]="WIN_CONDITION_BUILD_ALL_COASTAL_ROADS",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(fr||(fr={}));var kt;(function(e){e[e.DYNAMIC_HEX_MODE_UNSPECIFIED=0]="DYNAMIC_HEX_MODE_UNSPECIFIED",e[e.DYNAMIC_HEX_MODE_OFF=1]="DYNAMIC_HEX_MODE_OFF",e[e.DYNAMIC_HEX_MODE_DESERTIFICATION=2]="DYNAMIC_HEX_MODE_DESERTIFICATION",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(kt||(kt={}));var Gn;(function(e){e[e.RESOURCE_GOAL_MODE_UNSPECIFIED=0]="RESOURCE_GOAL_MODE_UNSPECIFIED",e[e.RESOURCE_GOAL_MODE_CUMULATIVE=1]="RESOURCE_GOAL_MODE_CUMULATIVE",e[e.RESOURCE_GOAL_MODE_IN_HAND=2]="RESOURCE_GOAL_MODE_IN_HAND",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Gn||(Gn={}));var lt;(function(e){e[e.FOUND_ON_FOG_MODE_DISABLED=0]="FOUND_ON_FOG_MODE_DISABLED",e[e.FOUND_ON_FOG_MODE_SHORE=1]="FOUND_ON_FOG_MODE_SHORE",e[e.FOUND_ON_FOG_MODE_WITHIN=2]="FOUND_ON_FOG_MODE_WITHIN",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(lt||(lt={}));var Gr;(function(e){e[e.FOG_MODE_UNSPECIFIED=0]="FOG_MODE_UNSPECIFIED",e[e.FOG_MODE_OFF=1]="FOG_MODE_OFF",e[e.FOG_MODE_FOG_START=2]="FOG_MODE_FOG_START",e[e.FOG_MODE_MIST_START=3]="FOG_MODE_MIST_START",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Gr||(Gr={}));var tr;(function(e){e[e.SETUP_PLACEMENT_MODE_NORMAL=0]="SETUP_PLACEMENT_MODE_NORMAL",e[e.SETUP_PLACEMENT_MODE_COASTAL=1]="SETUP_PLACEMENT_MODE_COASTAL",e[e.SETUP_PLACEMENT_MODE_INLAND=2]="SETUP_PLACEMENT_MODE_INLAND",e[e.SETUP_PLACEMENT_MODE_PORT=3]="SETUP_PLACEMENT_MODE_PORT",e[e.SETUP_PLACEMENT_MODE_DESERT=4]="SETUP_PLACEMENT_MODE_DESERT",e[e.SETUP_PLACEMENT_MODE_DIFFERENT_ISLAND=5]="SETUP_PLACEMENT_MODE_DIFFERENT_ISLAND",e[e.SETUP_PLACEMENT_MODE_HIGHEST_PRODUCTION=6]="SETUP_PLACEMENT_MODE_HIGHEST_PRODUCTION",e[e.SETUP_PLACEMENT_MODE_SKIP=7]="SETUP_PLACEMENT_MODE_SKIP",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(tr||(tr={}));var Ys;(function(e){e[e.MAP_SHUFFLE_MODE_NONE=0]="MAP_SHUFFLE_MODE_NONE",e[e.MAP_SHUFFLE_MODE_TERRAIN_AND_NUMBERS=1]="MAP_SHUFFLE_MODE_TERRAIN_AND_NUMBERS",e[e.MAP_SHUFFLE_MODE_TERRAIN_WITH_NUMBERS=2]="MAP_SHUFFLE_MODE_TERRAIN_WITH_NUMBERS",e[e.MAP_SHUFFLE_MODE_RANDOM_DISTRIBUTION=3]="MAP_SHUFFLE_MODE_RANDOM_DISTRIBUTION",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Ys||(Ys={}));var Fs;(function(e){e[e.MAP_SHUFFLE_SCOPE_GLOBAL=0]="MAP_SHUFFLE_SCOPE_GLOBAL",e[e.MAP_SHUFFLE_SCOPE_INTRA_ISLAND=1]="MAP_SHUFFLE_SCOPE_INTRA_ISLAND",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Fs||(Fs={}));var Vr;(function(e){e[e.NUMBER_LAYOUT_UNSPECIFIED=0]="NUMBER_LAYOUT_UNSPECIFIED",e[e.NUMBER_LAYOUT_SPIRAL=1]="NUMBER_LAYOUT_SPIRAL",e[e.NUMBER_LAYOUT_RANDOM_STRICT=2]="NUMBER_LAYOUT_RANDOM_STRICT",e[e.NUMBER_LAYOUT_RANDOM_RELAXED=3]="NUMBER_LAYOUT_RANDOM_RELAXED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Vr||(Vr={}));var ct;(function(e){e[e.PORT_LAYOUT_MODE_UNSPECIFIED=0]="PORT_LAYOUT_MODE_UNSPECIFIED",e[e.PORT_LAYOUT_MODE_RANDOM=1]="PORT_LAYOUT_MODE_RANDOM",e[e.PORT_LAYOUT_MODE_FIXED_6TH_EDITION=2]="PORT_LAYOUT_MODE_FIXED_6TH_EDITION",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ct||(ct={}));var ft;(function(e){e[e.DESERT_PLACEMENT_UNSPECIFIED=0]="DESERT_PLACEMENT_UNSPECIFIED",e[e.DESERT_PLACEMENT_RANDOM=1]="DESERT_PLACEMENT_RANDOM",e[e.DESERT_PLACEMENT_CENTER=2]="DESERT_PLACEMENT_CENTER",e[e.DESERT_PLACEMENT_MIDDLE=3]="DESERT_PLACEMENT_MIDDLE",e[e.DESERT_PLACEMENT_SHORE=4]="DESERT_PLACEMENT_SHORE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ft||(ft={}));var B;(function(e){e[e.MAP_TYPE_UNSPECIFIED=0]="MAP_TYPE_UNSPECIFIED",e[e.MAP_TYPE_BASE_4P=1]="MAP_TYPE_BASE_4P",e[e.MAP_TYPE_BASE_6P=2]="MAP_TYPE_BASE_6P",e[e.MAP_TYPE_BASE_3P=3]="MAP_TYPE_BASE_3P",e[e.MAP_TYPE_BASE_2P=4]="MAP_TYPE_BASE_2P",e[e.MAP_TYPE_BASE_RANDOM_4P=5]="MAP_TYPE_BASE_RANDOM_4P",e[e.MAP_TYPE_BASE_8P=6]="MAP_TYPE_BASE_8P",e[e.MAP_TYPE_SEAFARERS_FORGOTTEN_TRIBE=8]="MAP_TYPE_SEAFARERS_FORGOTTEN_TRIBE",e[e.MAP_TYPE_FISH_PONDS=9]="MAP_TYPE_FISH_PONDS",e[e.MAP_TYPE_FISH_PONDS_6P=10]="MAP_TYPE_FISH_PONDS_6P",e[e.MAP_TYPE_FISH_PONDS_8P=11]="MAP_TYPE_FISH_PONDS_8P",e[e.MAP_TYPE_FISH_PONDS_3P=12]="MAP_TYPE_FISH_PONDS_3P",e[e.MAP_TYPE_FISH_PONDS_2P=13]="MAP_TYPE_FISH_PONDS_2P",e[e.MAP_TYPE_SF_NEW_SHORES_3P=100]="MAP_TYPE_SF_NEW_SHORES_3P",e[e.MAP_TYPE_SF_NEW_SHORES_4P=101]="MAP_TYPE_SF_NEW_SHORES_4P",e[e.MAP_TYPE_SF_NEW_SHORES_6P=102]="MAP_TYPE_SF_NEW_SHORES_6P",e[e.MAP_TYPE_SF_FOUR_ISLANDS_3P=110]="MAP_TYPE_SF_FOUR_ISLANDS_3P",e[e.MAP_TYPE_SF_FOUR_ISLANDS_4P=111]="MAP_TYPE_SF_FOUR_ISLANDS_4P",e[e.MAP_TYPE_SF_FOUR_ISLANDS_RANDOM=112]="MAP_TYPE_SF_FOUR_ISLANDS_RANDOM",e[e.MAP_TYPE_SF_FOG_ISLANDS_3P=120]="MAP_TYPE_SF_FOG_ISLANDS_3P",e[e.MAP_TYPE_SF_FOG_ISLANDS_4P=121]="MAP_TYPE_SF_FOG_ISLANDS_4P",e[e.MAP_TYPE_SF_THROUGH_DESERT_3P=130]="MAP_TYPE_SF_THROUGH_DESERT_3P",e[e.MAP_TYPE_SF_THROUGH_DESERT_4P=131]="MAP_TYPE_SF_THROUGH_DESERT_4P",e[e.MAP_TYPE_SF_NEW_WORLD_3P=140]="MAP_TYPE_SF_NEW_WORLD_3P",e[e.MAP_TYPE_SF_NEW_WORLD_4P=141]="MAP_TYPE_SF_NEW_WORLD_4P",e[e.MAP_TYPE_FOG_BANK_2P=204]="MAP_TYPE_FOG_BANK_2P",e[e.MAP_TYPE_FOG_BANK_3P=203]="MAP_TYPE_FOG_BANK_3P",e[e.MAP_TYPE_FOG_BANK_4P=200]="MAP_TYPE_FOG_BANK_4P",e[e.MAP_TYPE_FOG_BANK_6P=201]="MAP_TYPE_FOG_BANK_6P",e[e.MAP_TYPE_FOG_BANK_8P=202]="MAP_TYPE_FOG_BANK_8P",e[e.MAP_TYPE_MISTY_REALMS_2P=214]="MAP_TYPE_MISTY_REALMS_2P",e[e.MAP_TYPE_MISTY_REALMS_3P=213]="MAP_TYPE_MISTY_REALMS_3P",e[e.MAP_TYPE_MISTY_REALMS_4P=210]="MAP_TYPE_MISTY_REALMS_4P",e[e.MAP_TYPE_MISTY_REALMS_6P=211]="MAP_TYPE_MISTY_REALMS_6P",e[e.MAP_TYPE_MISTY_REALMS_8P=212]="MAP_TYPE_MISTY_REALMS_8P",e[e.MAP_TYPE_RIVER_4P=220]="MAP_TYPE_RIVER_4P",e[e.MAP_TYPE_RIVER_6P=221]="MAP_TYPE_RIVER_6P",e[e.MAP_TYPE_RIVER_8P=222]="MAP_TYPE_RIVER_8P",e[e.MAP_TYPE_CARAVANS_3P=233]="MAP_TYPE_CARAVANS_3P",e[e.MAP_TYPE_CARAVANS_4P=230]="MAP_TYPE_CARAVANS_4P",e[e.MAP_TYPE_CARAVANS_6P=231]="MAP_TYPE_CARAVANS_6P",e[e.MAP_TYPE_CARAVANS_8P=232]="MAP_TYPE_CARAVANS_8P",e[e.MAP_TYPE_DUST_BOWL_3P=243]="MAP_TYPE_DUST_BOWL_3P",e[e.MAP_TYPE_DUST_BOWL_4P=240]="MAP_TYPE_DUST_BOWL_4P",e[e.MAP_TYPE_DUST_BOWL_6P=241]="MAP_TYPE_DUST_BOWL_6P",e[e.MAP_TYPE_DUST_BOWL_8P=242]="MAP_TYPE_DUST_BOWL_8P",e[e.MAP_TYPE_SF_SIX_ISLANDS_6P=150]="MAP_TYPE_SF_SIX_ISLANDS_6P",e[e.MAP_TYPE_SNOW_MAN=250]="MAP_TYPE_SNOW_MAN",e[e.MAP_TYPE_TROLL_BRIDGE_2P=264]="MAP_TYPE_TROLL_BRIDGE_2P",e[e.MAP_TYPE_TROLL_BRIDGE_3P=263]="MAP_TYPE_TROLL_BRIDGE_3P",e[e.MAP_TYPE_TROLL_BRIDGE_4P=260]="MAP_TYPE_TROLL_BRIDGE_4P",e[e.MAP_TYPE_TROLL_BRIDGE_6P=261]="MAP_TYPE_TROLL_BRIDGE_6P",e[e.MAP_TYPE_TROLL_BRIDGE_8P=262]="MAP_TYPE_TROLL_BRIDGE_8P",e[e.MAP_TYPE_FISH_SHOALS_3P=300]="MAP_TYPE_FISH_SHOALS_3P",e[e.MAP_TYPE_FISH_SHOALS_4P=301]="MAP_TYPE_FISH_SHOALS_4P",e[e.MAP_TYPE_FISH_SHOALS_6P=302]="MAP_TYPE_FISH_SHOALS_6P",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(B||(B={}));var Tr;(function(e){e[e.EDGE_REWARD_TYPE_UNSPECIFIED=0]="EDGE_REWARD_TYPE_UNSPECIFIED",e[e.EDGE_REWARD_TYPE_VICTORY_POINT=1]="EDGE_REWARD_TYPE_VICTORY_POINT",e[e.EDGE_REWARD_TYPE_DEV_CARD=2]="EDGE_REWARD_TYPE_DEV_CARD",e[e.EDGE_REWARD_TYPE_PORT=3]="EDGE_REWARD_TYPE_PORT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Tr||(Tr={}));var P;(function(e){e[e.VALIDATION_ERROR_UNSPECIFIED=0]="VALIDATION_ERROR_UNSPECIFIED",e[e.VALIDATION_ERROR_NOT_YOUR_TURN=100]="VALIDATION_ERROR_NOT_YOUR_TURN",e[e.VALIDATION_ERROR_GAME_PAUSED=101]="VALIDATION_ERROR_GAME_PAUSED",e[e.VALIDATION_ERROR_WRONG_PHASE_SETUP=102]="VALIDATION_ERROR_WRONG_PHASE_SETUP",e[e.VALIDATION_ERROR_WRONG_PHASE_NORMAL=103]="VALIDATION_ERROR_WRONG_PHASE_NORMAL",e[e.VALIDATION_ERROR_MUST_ROLL_DICE_FIRST=104]="VALIDATION_ERROR_MUST_ROLL_DICE_FIRST",e[e.VALIDATION_ERROR_DICE_ALREADY_ROLLED=105]="VALIDATION_ERROR_DICE_ALREADY_ROLLED",e[e.VALIDATION_ERROR_CANNOT_END_TURN_SETUP=106]="VALIDATION_ERROR_CANNOT_END_TURN_SETUP",e[e.VALIDATION_ERROR_GAME_OVER=107]="VALIDATION_ERROR_GAME_OVER",e[e.VALIDATION_ERROR_MUST_DISCARD_FIRST=200]="VALIDATION_ERROR_MUST_DISCARD_FIRST",e[e.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST=201]="VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST",e[e.VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES=202]="VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES",e[e.VALIDATION_ERROR_MUST_PLACE_FREE_ROADS=203]="VALIDATION_ERROR_MUST_PLACE_FREE_ROADS",e[e.VALIDATION_ERROR_NO_PENDING_DISCARD=204]="VALIDATION_ERROR_NO_PENDING_DISCARD",e[e.VALIDATION_ERROR_NO_PENDING_ROBBER=205]="VALIDATION_ERROR_NO_PENDING_ROBBER",e[e.VALIDATION_ERROR_NO_PENDING_FREE_RESOURCES=206]="VALIDATION_ERROR_NO_PENDING_FREE_RESOURCES",e[e.VALIDATION_ERROR_NO_PENDING_FREE_ROADS=207]="VALIDATION_ERROR_NO_PENDING_FREE_ROADS",e[e.VALIDATION_ERROR_NO_PENDING_STEAL=208]="VALIDATION_ERROR_NO_PENDING_STEAL",e[e.VALIDATION_ERROR_WRONG_DISCARD_COUNT=209]="VALIDATION_ERROR_WRONG_DISCARD_COUNT",e[e.VALIDATION_ERROR_MUST_COMPLETE_EVENT_CARD_FIRST=210]="VALIDATION_ERROR_MUST_COMPLETE_EVENT_CARD_FIRST",e[e.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST=211]="VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST",e[e.VALIDATION_ERROR_CANNOT_AFFORD_SETTLEMENT=300]="VALIDATION_ERROR_CANNOT_AFFORD_SETTLEMENT",e[e.VALIDATION_ERROR_CANNOT_AFFORD_CITY=301]="VALIDATION_ERROR_CANNOT_AFFORD_CITY",e[e.VALIDATION_ERROR_CANNOT_AFFORD_ROAD=302]="VALIDATION_ERROR_CANNOT_AFFORD_ROAD",e[e.VALIDATION_ERROR_CANNOT_AFFORD_DEV_CARD=303]="VALIDATION_ERROR_CANNOT_AFFORD_DEV_CARD",e[e.VALIDATION_ERROR_INSUFFICIENT_RESOURCES=304]="VALIDATION_ERROR_INSUFFICIENT_RESOURCES",e[e.VALIDATION_ERROR_BANK_EMPTY=305]="VALIDATION_ERROR_BANK_EMPTY",e[e.VALIDATION_ERROR_NO_DEV_CARDS_LEFT=306]="VALIDATION_ERROR_NO_DEV_CARDS_LEFT",e[e.VALIDATION_ERROR_NO_ROADS_REMAINING=307]="VALIDATION_ERROR_NO_ROADS_REMAINING",e[e.VALIDATION_ERROR_VERTEX_OCCUPIED=400]="VALIDATION_ERROR_VERTEX_OCCUPIED",e[e.VALIDATION_ERROR_EDGE_OCCUPIED=401]="VALIDATION_ERROR_EDGE_OCCUPIED",e[e.VALIDATION_ERROR_VERTEX_NOT_ON_LAND=402]="VALIDATION_ERROR_VERTEX_NOT_ON_LAND",e[e.VALIDATION_ERROR_EDGE_NOT_ON_BOARD=403]="VALIDATION_ERROR_EDGE_NOT_ON_BOARD",e[e.VALIDATION_ERROR_TOO_CLOSE_TO_SETTLEMENT=404]="VALIDATION_ERROR_TOO_CLOSE_TO_SETTLEMENT",e[e.VALIDATION_ERROR_ROAD_NOT_CONNECTED=405]="VALIDATION_ERROR_ROAD_NOT_CONNECTED",e[e.VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED=406]="VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED",e[e.VALIDATION_ERROR_NO_SETTLEMENT_AT_LOCATION=407]="VALIDATION_ERROR_NO_SETTLEMENT_AT_LOCATION",e[e.VALIDATION_ERROR_SETTLEMENT_WRONG_OWNER=408]="VALIDATION_ERROR_SETTLEMENT_WRONG_OWNER",e[e.VALIDATION_ERROR_INVALID_HEX_LOCATION=409]="VALIDATION_ERROR_INVALID_HEX_LOCATION",e[e.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS=410]="VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS",e[e.VALIDATION_ERROR_CANNOT_ACCEPT_OWN_TRADE=500]="VALIDATION_ERROR_CANNOT_ACCEPT_OWN_TRADE",e[e.VALIDATION_ERROR_CANNOT_REJECT_OWN_TRADE=501]="VALIDATION_ERROR_CANNOT_REJECT_OWN_TRADE",e[e.VALIDATION_ERROR_CANNOT_CANCEL_OTHERS_TRADE=502]="VALIDATION_ERROR_CANNOT_CANCEL_OTHERS_TRADE",e[e.VALIDATION_ERROR_TRADE_NOT_FOUND=503]="VALIDATION_ERROR_TRADE_NOT_FOUND",e[e.VALIDATION_ERROR_TARGET_NOT_ACCEPTED=504]="VALIDATION_ERROR_TARGET_NOT_ACCEPTED",e[e.VALIDATION_ERROR_ONLY_PROPOSER_CAN_EXECUTE=505]="VALIDATION_ERROR_ONLY_PROPOSER_CAN_EXECUTE",e[e.VALIDATION_ERROR_CANNOT_ACCEPT_REJECTED_TRADE=506]="VALIDATION_ERROR_CANNOT_ACCEPT_REJECTED_TRADE",e[e.VALIDATION_ERROR_TARGET_NO_RESOURCES=507]="VALIDATION_ERROR_TARGET_NO_RESOURCES",e[e.VALIDATION_ERROR_INVALID_TRADE_RATIO=508]="VALIDATION_ERROR_INVALID_TRADE_RATIO",e[e.VALIDATION_ERROR_TRADE_RESOURCES_NOT_OWNED=509]="VALIDATION_ERROR_TRADE_RESOURCES_NOT_OWNED",e[e.VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE=510]="VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE",e[e.VALIDATION_ERROR_PLAYER_TRADES_DISABLED=511]="VALIDATION_ERROR_PLAYER_TRADES_DISABLED",e[e.VALIDATION_ERROR_COUNTER_OFFERS_DISABLED=512]="VALIDATION_ERROR_COUNTER_OFFERS_DISABLED",e[e.VALIDATION_ERROR_NO_KNIGHT_CARD=600]="VALIDATION_ERROR_NO_KNIGHT_CARD",e[e.VALIDATION_ERROR_NO_ROAD_BUILDING_CARD=601]="VALIDATION_ERROR_NO_ROAD_BUILDING_CARD",e[e.VALIDATION_ERROR_NO_YEAR_OF_PLENTY_CARD=602]="VALIDATION_ERROR_NO_YEAR_OF_PLENTY_CARD",e[e.VALIDATION_ERROR_NO_MONOPOLY_CARD=603]="VALIDATION_ERROR_NO_MONOPOLY_CARD",e[e.VALIDATION_ERROR_ALREADY_PLAYED_DEV_CARD=604]="VALIDATION_ERROR_ALREADY_PLAYED_DEV_CARD",e[e.VALIDATION_ERROR_CANNOT_PLAY_VP_CARD=605]="VALIDATION_ERROR_CANNOT_PLAY_VP_CARD",e[e.VALIDATION_ERROR_ROBBER_MUST_MOVE=700]="VALIDATION_ERROR_ROBBER_MUST_MOVE",e[e.VALIDATION_ERROR_ROBBER_NO_LOCATION=701]="VALIDATION_ERROR_ROBBER_NO_LOCATION",e[e.VALIDATION_ERROR_ROBBER_ON_SEA=702]="VALIDATION_ERROR_ROBBER_ON_SEA",e[e.VALIDATION_ERROR_FRIENDLY_ROBBER_BLOCKED=703]="VALIDATION_ERROR_FRIENDLY_ROBBER_BLOCKED",e[e.VALIDATION_ERROR_INVALID_STEAL_TARGET=704]="VALIDATION_ERROR_INVALID_STEAL_TARGET",e[e.VALIDATION_ERROR_ROBBER_NOT_ON_BIGGEST_ISLAND=705]="VALIDATION_ERROR_ROBBER_NOT_ON_BIGGEST_ISLAND",e[e.VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS=706]="VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS",e[e.VALIDATION_ERROR_MUST_SPECIFY_RESOURCE=800]="VALIDATION_ERROR_MUST_SPECIFY_RESOURCE",e[e.VALIDATION_ERROR_MUST_SPECIFY_VERTEX=801]="VALIDATION_ERROR_MUST_SPECIFY_VERTEX",e[e.VALIDATION_ERROR_MUST_SPECIFY_EDGE=802]="VALIDATION_ERROR_MUST_SPECIFY_EDGE",e[e.VALIDATION_ERROR_INVALID_TARGET_PLAYER=803]="VALIDATION_ERROR_INVALID_TARGET_PLAYER",e[e.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE=804]="VALIDATION_ERROR_UNKNOWN_ACTION_TYPE",e[e.VALIDATION_ERROR_NO_TROLL_ON_HEX=900]="VALIDATION_ERROR_NO_TROLL_ON_HEX",e[e.VALIDATION_ERROR_TROLL_INSUFFICIENT_FOOD=901]="VALIDATION_ERROR_TROLL_INSUFFICIENT_FOOD",e[e.VALIDATION_ERROR_TROLL_INVALID_FOOD=902]="VALIDATION_ERROR_TROLL_INVALID_FOOD",e[e.VALIDATION_ERROR_TROLL_KNIGHT_NOT_MIGHTY=903]="VALIDATION_ERROR_TROLL_KNIGHT_NOT_MIGHTY",e[e.VALIDATION_ERROR_TROLL_KNIGHT_NOT_ACTIVE=904]="VALIDATION_ERROR_TROLL_KNIGHT_NOT_ACTIVE",e[e.VALIDATION_ERROR_TROLL_KNIGHT_NOT_ADJACENT=905]="VALIDATION_ERROR_TROLL_KNIGHT_NOT_ADJACENT",e[e.VALIDATION_ERROR_TROLL_NOT_ADJACENT_TO_BUILDING=906]="VALIDATION_ERROR_TROLL_NOT_ADJACENT_TO_BUILDING",e[e.VALIDATION_ERROR_ROBBER_BLOCKED_BY_TROLL=907]="VALIDATION_ERROR_ROBBER_BLOCKED_BY_TROLL",e[e.VALIDATION_ERROR_RIVERS_NOT_ENABLED=1e3]="VALIDATION_ERROR_RIVERS_NOT_ENABLED",e[e.VALIDATION_ERROR_NOT_A_BRIDGE_SITE=1001]="VALIDATION_ERROR_NOT_A_BRIDGE_SITE",e[e.VALIDATION_ERROR_ROAD_ON_BRIDGE_SITE=1002]="VALIDATION_ERROR_ROAD_ON_BRIDGE_SITE",e[e.VALIDATION_ERROR_NO_BRIDGES_REMAINING=1003]="VALIDATION_ERROR_NO_BRIDGES_REMAINING",e[e.VALIDATION_ERROR_CANNOT_AFFORD_BRIDGE=1004]="VALIDATION_ERROR_CANNOT_AFFORD_BRIDGE",e[e.VALIDATION_ERROR_BRIDGE_NOT_CONNECTED=1005]="VALIDATION_ERROR_BRIDGE_NOT_CONNECTED",e[e.VALIDATION_ERROR_INSUFFICIENT_GOLD=1006]="VALIDATION_ERROR_INSUFFICIENT_GOLD",e[e.VALIDATION_ERROR_GOLD_PURCHASE_LIMIT_REACHED=1007]="VALIDATION_ERROR_GOLD_PURCHASE_LIMIT_REACHED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(P||(P={}));var sf;(function(e){e[e.PING_TARGET_TYPE_UNSPECIFIED=0]="PING_TARGET_TYPE_UNSPECIFIED",e[e.PING_TARGET_TYPE_HEX=1]="PING_TARGET_TYPE_HEX",e[e.PING_TARGET_TYPE_VERTEX=2]="PING_TARGET_TYPE_VERTEX",e[e.PING_TARGET_TYPE_EDGE=3]="PING_TARGET_TYPE_EDGE",e[e.PING_TARGET_TYPE_POINT=4]="PING_TARGET_TYPE_POINT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(sf||(sf={}));var _f;(function(e){e[e.PING_TYPE_UNSPECIFIED=0]="PING_TYPE_UNSPECIFIED",e[e.PING_TYPE_EXCLAMATION=1]="PING_TYPE_EXCLAMATION",e[e.PING_TYPE_QUESTION=2]="PING_TYPE_QUESTION",e[e.PING_TYPE_ARROW=3]="PING_TYPE_ARROW",e[e.PING_TYPE_X=4]="PING_TYPE_X",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(_f||(_f={}));var $r;(function(e){e[e.TRADE_MODE_NORMAL=0]="TRADE_MODE_NORMAL",e[e.TRADE_MODE_BANK_ONLY=1]="TRADE_MODE_BANK_ONLY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})($r||($r={}));var j;(function(e){e[e.COMMODITY_UNSPECIFIED=0]="COMMODITY_UNSPECIFIED",e[e.COMMODITY_PAPER=1]="COMMODITY_PAPER",e[e.COMMODITY_CLOTH=2]="COMMODITY_CLOTH",e[e.COMMODITY_COIN=3]="COMMODITY_COIN",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(j||(j={}));var Pe;(function(e){e[e.KNIGHT_STRENGTH_UNSPECIFIED=0]="KNIGHT_STRENGTH_UNSPECIFIED",e[e.KNIGHT_STRENGTH_BASIC=1]="KNIGHT_STRENGTH_BASIC",e[e.KNIGHT_STRENGTH_STRONG=2]="KNIGHT_STRENGTH_STRONG",e[e.KNIGHT_STRENGTH_MIGHTY=3]="KNIGHT_STRENGTH_MIGHTY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Pe||(Pe={}));var ir;(function(e){e[e.KNIGHT_STATUS_UNSPECIFIED=0]="KNIGHT_STATUS_UNSPECIFIED",e[e.KNIGHT_STATUS_INACTIVE=1]="KNIGHT_STATUS_INACTIVE",e[e.KNIGHT_STATUS_ACTIVE=2]="KNIGHT_STATUS_ACTIVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ir||(ir={}));var K;(function(e){e[e.CITY_IMPROVEMENT_TRACK_UNSPECIFIED=0]="CITY_IMPROVEMENT_TRACK_UNSPECIFIED",e[e.CITY_IMPROVEMENT_TRACK_TRADE=1]="CITY_IMPROVEMENT_TRACK_TRADE",e[e.CITY_IMPROVEMENT_TRACK_POLITICS=2]="CITY_IMPROVEMENT_TRACK_POLITICS",e[e.CITY_IMPROVEMENT_TRACK_SCIENCE=3]="CITY_IMPROVEMENT_TRACK_SCIENCE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(K||(K={}));var Ue;(function(e){e[e.EVENT_DIE_RESULT_UNSPECIFIED=0]="EVENT_DIE_RESULT_UNSPECIFIED",e[e.EVENT_DIE_RESULT_BARBARIAN_SHIP=1]="EVENT_DIE_RESULT_BARBARIAN_SHIP",e[e.EVENT_DIE_RESULT_TRADE_GATE=2]="EVENT_DIE_RESULT_TRADE_GATE",e[e.EVENT_DIE_RESULT_POLITICS_GATE=3]="EVENT_DIE_RESULT_POLITICS_GATE",e[e.EVENT_DIE_RESULT_SCIENCE_GATE=4]="EVENT_DIE_RESULT_SCIENCE_GATE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Ue||(Ue={}));var b;(function(e){e[e.PROGRESS_CARD_UNSPECIFIED=0]="PROGRESS_CARD_UNSPECIFIED",e[e.PROGRESS_CARD_ALCHEMIST=1]="PROGRESS_CARD_ALCHEMIST",e[e.PROGRESS_CARD_CRANE=2]="PROGRESS_CARD_CRANE",e[e.PROGRESS_CARD_ENGINEER=3]="PROGRESS_CARD_ENGINEER",e[e.PROGRESS_CARD_INVENTOR=4]="PROGRESS_CARD_INVENTOR",e[e.PROGRESS_CARD_IRRIGATION=5]="PROGRESS_CARD_IRRIGATION",e[e.PROGRESS_CARD_MEDICINE=6]="PROGRESS_CARD_MEDICINE",e[e.PROGRESS_CARD_MINING=7]="PROGRESS_CARD_MINING",e[e.PROGRESS_CARD_PRINTER=8]="PROGRESS_CARD_PRINTER",e[e.PROGRESS_CARD_ROAD_BUILDING=9]="PROGRESS_CARD_ROAD_BUILDING",e[e.PROGRESS_CARD_SMITH=10]="PROGRESS_CARD_SMITH",e[e.PROGRESS_CARD_BISHOP=11]="PROGRESS_CARD_BISHOP",e[e.PROGRESS_CARD_CONSTITUTION=12]="PROGRESS_CARD_CONSTITUTION",e[e.PROGRESS_CARD_DESERTER=13]="PROGRESS_CARD_DESERTER",e[e.PROGRESS_CARD_DIPLOMAT=14]="PROGRESS_CARD_DIPLOMAT",e[e.PROGRESS_CARD_INTRIGUE=15]="PROGRESS_CARD_INTRIGUE",e[e.PROGRESS_CARD_SABOTEUR=16]="PROGRESS_CARD_SABOTEUR",e[e.PROGRESS_CARD_SPY=17]="PROGRESS_CARD_SPY",e[e.PROGRESS_CARD_WARLORD=18]="PROGRESS_CARD_WARLORD",e[e.PROGRESS_CARD_WEDDING=19]="PROGRESS_CARD_WEDDING",e[e.PROGRESS_CARD_COMMERCIAL_HARBOR=20]="PROGRESS_CARD_COMMERCIAL_HARBOR",e[e.PROGRESS_CARD_MASTER_MERCHANT=21]="PROGRESS_CARD_MASTER_MERCHANT",e[e.PROGRESS_CARD_MERCHANT=22]="PROGRESS_CARD_MERCHANT",e[e.PROGRESS_CARD_MERCHANT_FLEET=23]="PROGRESS_CARD_MERCHANT_FLEET",e[e.PROGRESS_CARD_RESOURCE_MONOPOLY=24]="PROGRESS_CARD_RESOURCE_MONOPOLY",e[e.PROGRESS_CARD_TRADE_MONOPOLY=25]="PROGRESS_CARD_TRADE_MONOPOLY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(b||(b={}));var le;(function(e){e[e.EVENT_CARD_UNSPECIFIED=0]="EVENT_CARD_UNSPECIFIED",e[e.EVENT_CARD_BEAUTIFUL_DAY=1]="EVENT_CARD_BEAUTIFUL_DAY",e[e.EVENT_CARD_ROBBER_ATTACKS=2]="EVENT_CARD_ROBBER_ATTACKS",e[e.EVENT_CARD_CALM_SEAS=3]="EVENT_CARD_CALM_SEAS",e[e.EVENT_CARD_GOOD_NEIGHBORS=4]="EVENT_CARD_GOOD_NEIGHBORS",e[e.EVENT_CARD_ROBBER_FLEES=5]="EVENT_CARD_ROBBER_FLEES",e[e.EVENT_CARD_EPIDEMIC=6]="EVENT_CARD_EPIDEMIC",e[e.EVENT_CARD_CONFLICT=7]="EVENT_CARD_CONFLICT",e[e.EVENT_CARD_EARTHQUAKE=8]="EVENT_CARD_EARTHQUAKE",e[e.EVENT_CARD_HELPFUL_NEIGHBOR=9]="EVENT_CARD_HELPFUL_NEIGHBOR",e[e.EVENT_CARD_PLENTIFUL_YEAR=10]="EVENT_CARD_PLENTIFUL_YEAR",e[e.EVENT_CARD_TOURNAMENT=11]="EVENT_CARD_TOURNAMENT",e[e.EVENT_CARD_TRADE_ADVANTAGE=12]="EVENT_CARD_TRADE_ADVANTAGE",e[e.EVENT_CARD_NEW_YEAR=13]="EVENT_CARD_NEW_YEAR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(le||(le={}));import{BinaryReader as Ur,BinaryWriter as Un}from"@bufbuild/protobuf/wire";import{BinaryReader as df,BinaryWriter as nD}from"@bufbuild/protobuf/wire";function uf(){return{seconds:0,nanos:0}}E(uf,"createBaseTimestamp");var bt={encode(e,r=new nD){return e.seconds!==0&&r.uint32(8).int64(e.seconds),e.nanos!==0&&r.uint32(16).int32(e.nanos),r},decode(e,r){let t=e instanceof df?e:new df(e),o=r===void 0?t.len:t.pos+r,i=uf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.seconds=iD(t.int64());continue}case 2:{if(n!==16)break;i.nanos=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return bt.fromPartial(e??{})},fromPartial(e){let r=uf();return r.seconds=e.seconds??0,r.nanos=e.nanos??0,r}};function iD(e){let r=globalThis.Number(e.toString());if(r>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(r<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return r}E(iD,"longToNumber");var Tt;(function(e){e[e.TIMER_MODE_UNSPECIFIED=0]="TIMER_MODE_UNSPECIFIED",e[e.TIMER_MODE_NONE=1]="TIMER_MODE_NONE",e[e.TIMER_MODE_CHESS_CLOCK=2]="TIMER_MODE_CHESS_CLOCK",e[e.TIMER_MODE_LEGACY=3]="TIMER_MODE_LEGACY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Tt||(Tt={}));var Me;(function(e){e[e.GAME_SPEED_MODE_UNSPECIFIED=0]="GAME_SPEED_MODE_UNSPECIFIED",e[e.GAME_SPEED_MODE_NONE=1]="GAME_SPEED_MODE_NONE",e[e.GAME_SPEED_MODE_BULLET=2]="GAME_SPEED_MODE_BULLET",e[e.GAME_SPEED_MODE_BLITZ=3]="GAME_SPEED_MODE_BLITZ",e[e.GAME_SPEED_MODE_RAPID=4]="GAME_SPEED_MODE_RAPID",e[e.GAME_SPEED_MODE_CLASSIC=5]="GAME_SPEED_MODE_CLASSIC",e[e.GAME_SPEED_MODE_RELAXED=6]="GAME_SPEED_MODE_RELAXED",e[e.GAME_SPEED_MODE_ULTRA_BULLET=7]="GAME_SPEED_MODE_ULTRA_BULLET",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Me||(Me={}));var pa;(function(e){e[e.ACTION_SOURCE_UNSPECIFIED=0]="ACTION_SOURCE_UNSPECIFIED",e[e.ACTION_SOURCE_PLAYER=1]="ACTION_SOURCE_PLAYER",e[e.ACTION_SOURCE_TIMEOUT_BOT=2]="ACTION_SOURCE_TIMEOUT_BOT",e[e.ACTION_SOURCE_TAKEOVER_BOT=3]="ACTION_SOURCE_TAKEOVER_BOT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(pa||(pa={}));var Ve;(function(e){e[e.TIMEOUT_ACTION_UNSPECIFIED=0]="TIMEOUT_ACTION_UNSPECIFIED",e[e.TIMEOUT_ACTION_DICE_ROLL=1]="TIMEOUT_ACTION_DICE_ROLL",e[e.TIMEOUT_ACTION_DISCARD=2]="TIMEOUT_ACTION_DISCARD",e[e.TIMEOUT_ACTION_ROBBER_PLACEMENT=3]="TIMEOUT_ACTION_ROBBER_PLACEMENT",e[e.TIMEOUT_ACTION_ROBBER_STEAL=4]="TIMEOUT_ACTION_ROBBER_STEAL",e[e.TIMEOUT_ACTION_SELECT_RESOURCES=5]="TIMEOUT_ACTION_SELECT_RESOURCES",e[e.TIMEOUT_ACTION_SETUP_SETTLEMENT=6]="TIMEOUT_ACTION_SETUP_SETTLEMENT",e[e.TIMEOUT_ACTION_SETUP_ROAD=7]="TIMEOUT_ACTION_SETUP_ROAD",e[e.TIMEOUT_ACTION_FREE_ROAD=8]="TIMEOUT_ACTION_FREE_ROAD",e[e.TIMEOUT_ACTION_END_TURN=9]="TIMEOUT_ACTION_END_TURN",e[e.TIMEOUT_ACTION_MOVE_KNIGHT=10]="TIMEOUT_ACTION_MOVE_KNIGHT",e[e.TIMEOUT_ACTION_PLACE_WALL=11]="TIMEOUT_ACTION_PLACE_WALL",e[e.TIMEOUT_ACTION_PROMOTE_KNIGHT=12]="TIMEOUT_ACTION_PROMOTE_KNIGHT",e[e.TIMEOUT_ACTION_DESTROY_CITY=13]="TIMEOUT_ACTION_DESTROY_CITY",e[e.TIMEOUT_ACTION_SELECT_DEFENDER=14]="TIMEOUT_ACTION_SELECT_DEFENDER",e[e.TIMEOUT_ACTION_WEDDING_CARDS=15]="TIMEOUT_ACTION_WEDDING_CARDS",e[e.TIMEOUT_ACTION_COMMERCIAL_HARBOR=16]="TIMEOUT_ACTION_COMMERCIAL_HARBOR",e[e.TIMEOUT_ACTION_KNIGHT_COMMITMENT=20]="TIMEOUT_ACTION_KNIGHT_COMMITMENT",e[e.TIMEOUT_ACTION_DESERTER_KNIGHT=21]="TIMEOUT_ACTION_DESERTER_KNIGHT",e[e.TIMEOUT_ACTION_METROPOLIS_PLACEMENT=22]="TIMEOUT_ACTION_METROPOLIS_PLACEMENT",e[e.TIMEOUT_ACTION_DISCARD_PROGRESS_CARDS=23]="TIMEOUT_ACTION_DISCARD_PROGRESS_CARDS",e[e.TIMEOUT_ACTION_GOOD_NEIGHBORS=24]="TIMEOUT_ACTION_GOOD_NEIGHBORS",e[e.TIMEOUT_ACTION_HELPFUL_NEIGHBORS=25]="TIMEOUT_ACTION_HELPFUL_NEIGHBORS",e[e.TIMEOUT_ACTION_EVENT_CARD_STEAL=26]="TIMEOUT_ACTION_EVENT_CARD_STEAL",e[e.TIMEOUT_ACTION_EARTHQUAKE=27]="TIMEOUT_ACTION_EARTHQUAKE",e[e.TIMEOUT_ACTION_WAGON_VOTING=28]="TIMEOUT_ACTION_WAGON_VOTING",e[e.TIMEOUT_ACTION_TRADE_RESPONSE=17]="TIMEOUT_ACTION_TRADE_RESPONSE",e[e.TIMEOUT_ACTION_DEVELOPMENT_CARD=18]="TIMEOUT_ACTION_DEVELOPMENT_CARD",e[e.TIMEOUT_ACTION_BUILD_ACTION=19]="TIMEOUT_ACTION_BUILD_ACTION",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Ve||(Ve={}));function Ef(){return{remainingTimeMs:0,clockStartedAt:void 0,extensionsUsed:0,activityBonusesThisTurn:0}}E(Ef,"createBasePlayerTimerStateProto");var Q_={encode(e,r=new Un){return e.remainingTimeMs!==0&&r.uint32(8).int64(e.remainingTimeMs),e.clockStartedAt!==void 0&&bt.encode(td(e.clockStartedAt),r.uint32(18).fork()).join(),e.extensionsUsed!==0&&r.uint32(24).int32(e.extensionsUsed),e.activityBonusesThisTurn!==0&&r.uint32(32).int32(e.activityBonusesThisTurn),r},decode(e,r){let t=e instanceof Ur?e:new Ur(e),o=r===void 0?t.len:t.pos+r,i=Ef();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.remainingTimeMs=oD(t.int64());continue}case 2:{if(n!==18)break;i.clockStartedAt=nd(bt.decode(t,t.uint32()));continue}case 3:{if(n!==24)break;i.extensionsUsed=t.int32();continue}case 4:{if(n!==32)break;i.activityBonusesThisTurn=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Q_.fromPartial(e??{})},fromPartial(e){let r=Ef();return r.remainingTimeMs=e.remainingTimeMs??0,r.clockStartedAt=e.clockStartedAt??void 0,r.extensionsUsed=e.extensionsUsed??0,r.activityBonusesThisTurn=e.activityBonusesThisTurn??0,r}};function lf(){return{player:0,timerState:void 0}}E(lf,"createBasePlayerTimerEntryProto");var j_={encode(e,r=new Un){return e.player!==0&&r.uint32(8).int32(e.player),e.timerState!==void 0&&Q_.encode(e.timerState,r.uint32(18).fork()).join(),r},decode(e,r){let t=e instanceof Ur?e:new Ur(e),o=r===void 0?t.len:t.pos+r,i=lf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==18)break;i.timerState=Q_.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return j_.fromPartial(e??{})},fromPartial(e){let r=lf();return r.player=e.player??0,r.timerState=e.timerState!==void 0&&e.timerState!==null?Q_.fromPartial(e.timerState):void 0,r}};function cf(){return{playerTimers:[],serverTime:void 0,currentAction:0}}E(cf,"createBaseGameTimerStateProto");var Vs={encode(e,r=new Un){for(let t of e.playerTimers)j_.encode(t,r.uint32(10).fork()).join();return e.serverTime!==void 0&&bt.encode(td(e.serverTime),r.uint32(18).fork()).join(),e.currentAction!==0&&r.uint32(24).int32(e.currentAction),r},decode(e,r){let t=e instanceof Ur?e:new Ur(e),o=r===void 0?t.len:t.pos+r,i=cf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.playerTimers.push(j_.decode(t,t.uint32()));continue}case 2:{if(n!==18)break;i.serverTime=nd(bt.decode(t,t.uint32()));continue}case 3:{if(n!==24)break;i.currentAction=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Vs.fromPartial(e??{})},fromPartial(e){let r=cf();return r.playerTimers=e.playerTimers?.map(t=>j_.fromPartial(t))||[],r.serverTime=e.serverTime??void 0,r.currentAction=e.currentAction??0,r}};function ff(){return{player:0,initialTimeMultiplier:0,disableIncrements:!1}}E(ff,"createBasePlayerTimerOverrideProto");var ed={encode(e,r=new Un){return e.player!==0&&r.uint32(8).int32(e.player),e.initialTimeMultiplier!==0&&r.uint32(21).float(e.initialTimeMultiplier),e.disableIncrements!==!1&&r.uint32(24).bool(e.disableIncrements),r},decode(e,r){let t=e instanceof Ur?e:new Ur(e),o=r===void 0?t.len:t.pos+r,i=ff();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==21)break;i.initialTimeMultiplier=t.float();continue}case 3:{if(n!==24)break;i.disableIncrements=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ed.fromPartial(e??{})},fromPartial(e){let r=ff();return r.player=e.player??0,r.initialTimeMultiplier=e.initialTimeMultiplier??0,r.disableIncrements=e.disableIncrements??!1,r}};function Tf(){return{mode:0,speedMode:0,initialTimeMs:0,incrementMs:0,maxExtensions:0,extensionTimeMs:0,playerOverrides:[]}}E(Tf,"createBaseTimerConfigProto");var xs={encode(e,r=new Un){e.mode!==0&&r.uint32(8).int32(e.mode),e.speedMode!==0&&r.uint32(16).int32(e.speedMode),e.initialTimeMs!==0&&r.uint32(24).int32(e.initialTimeMs),e.incrementMs!==0&&r.uint32(32).int32(e.incrementMs),e.maxExtensions!==0&&r.uint32(40).int32(e.maxExtensions),e.extensionTimeMs!==0&&r.uint32(48).int32(e.extensionTimeMs);for(let t of e.playerOverrides)ed.encode(t,r.uint32(58).fork()).join();return r},decode(e,r){let t=e instanceof Ur?e:new Ur(e),o=r===void 0?t.len:t.pos+r,i=Tf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.mode=t.int32();continue}case 2:{if(n!==16)break;i.speedMode=t.int32();continue}case 3:{if(n!==24)break;i.initialTimeMs=t.int32();continue}case 4:{if(n!==32)break;i.incrementMs=t.int32();continue}case 5:{if(n!==40)break;i.maxExtensions=t.int32();continue}case 6:{if(n!==48)break;i.extensionTimeMs=t.int32();continue}case 7:{if(n!==58)break;i.playerOverrides.push(ed.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return xs.fromPartial(e??{})},fromPartial(e){let r=Tf();return r.mode=e.mode??0,r.speedMode=e.speedMode??0,r.initialTimeMs=e.initialTimeMs??0,r.incrementMs=e.incrementMs??0,r.maxExtensions=e.maxExtensions??0,r.extensionTimeMs=e.extensionTimeMs??0,r.playerOverrides=e.playerOverrides?.map(t=>ed.fromPartial(t))||[],r}};function Nf(){return{pausesPerPlayer:0,voteCountdownSeconds:0}}E(Nf,"createBasePauseConfigProto");var ws={encode(e,r=new Un){return e.pausesPerPlayer!==0&&r.uint32(8).int32(e.pausesPerPlayer),e.voteCountdownSeconds!==0&&r.uint32(16).int32(e.voteCountdownSeconds),r},decode(e,r){let t=e instanceof Ur?e:new Ur(e),o=r===void 0?t.len:t.pos+r,i=Nf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.pausesPerPlayer=t.int32();continue}case 2:{if(n!==16)break;i.voteCountdownSeconds=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ws.fromPartial(e??{})},fromPartial(e){let r=Nf();return r.pausesPerPlayer=e.pausesPerPlayer??0,r.voteCountdownSeconds=e.voteCountdownSeconds??0,r}};function Rf(){return{player:0,count:0}}E(Rf,"createBasePlayerPauseCountProto");var rd={encode(e,r=new Un){return e.player!==0&&r.uint32(8).int32(e.player),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof Ur?e:new Ur(e),o=r===void 0?t.len:t.pos+r,i=Rf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return rd.fromPartial(e??{})},fromPartial(e){let r=Rf();return r.player=e.player??0,r.count=e.count??0,r}};function Af(){return{pausedBy:0,pausedAt:void 0,votesToContinue:[],countdownStartedAt:void 0,pauseCounts:[]}}E(Af,"createBasePauseStateProto");var Hs={encode(e,r=new Un){e.pausedBy!==0&&r.uint32(8).int32(e.pausedBy),e.pausedAt!==void 0&&bt.encode(td(e.pausedAt),r.uint32(18).fork()).join(),r.uint32(26).fork();for(let t of e.votesToContinue)r.int32(t);r.join(),e.countdownStartedAt!==void 0&&bt.encode(td(e.countdownStartedAt),r.uint32(34).fork()).join();for(let t of e.pauseCounts)rd.encode(t,r.uint32(42).fork()).join();return r},decode(e,r){let t=e instanceof Ur?e:new Ur(e),o=r===void 0?t.len:t.pos+r,i=Af();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.pausedBy=t.int32();continue}case 2:{if(n!==18)break;i.pausedAt=nd(bt.decode(t,t.uint32()));continue}case 3:{if(n===24){i.votesToContinue.push(t.int32());continue}if(n===26){let a=t.uint32()+t.pos;for(;t.pos<a;)i.votesToContinue.push(t.int32());continue}break}case 4:{if(n!==34)break;i.countdownStartedAt=nd(bt.decode(t,t.uint32()));continue}case 5:{if(n!==42)break;i.pauseCounts.push(rd.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Hs.fromPartial(e??{})},fromPartial(e){let r=Af();return r.pausedBy=e.pausedBy??0,r.pausedAt=e.pausedAt??void 0,r.votesToContinue=e.votesToContinue?.map(t=>t)||[],r.countdownStartedAt=e.countdownStartedAt??void 0,r.pauseCounts=e.pauseCounts?.map(t=>rd.fromPartial(t))||[],r}};function td(e){let r=Math.trunc(e.getTime()/1e3),t=e.getTime()%1e3*1e6;return{seconds:r,nanos:t}}E(td,"toTimestamp");function nd(e){let r=(e.seconds||0)*1e3;return r+=(e.nanos||0)/1e6,new globalThis.Date(r)}E(nd,"fromTimestamp");function oD(e){let r=globalThis.Number(e.toString());if(r>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(r<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return r}E(oD,"longToNumber");import{BinaryReader as se,BinaryWriter as Je}from"@bufbuild/protobuf/wire";var vr;(function(e){e[e.HEX_DIRECTION_TYPE_UNSPECIFIED=0]="HEX_DIRECTION_TYPE_UNSPECIFIED",e[e.HEX_DIRECTION_TYPE_NORTH_EAST=1]="HEX_DIRECTION_TYPE_NORTH_EAST",e[e.HEX_DIRECTION_TYPE_EAST=2]="HEX_DIRECTION_TYPE_EAST",e[e.HEX_DIRECTION_TYPE_SOUTH_EAST=3]="HEX_DIRECTION_TYPE_SOUTH_EAST",e[e.HEX_DIRECTION_TYPE_SOUTH_WEST=4]="HEX_DIRECTION_TYPE_SOUTH_WEST",e[e.HEX_DIRECTION_TYPE_WEST=5]="HEX_DIRECTION_TYPE_WEST",e[e.HEX_DIRECTION_TYPE_NORTH_WEST=6]="HEX_DIRECTION_TYPE_NORTH_WEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(vr||(vr={}));var Dr;(function(e){e[e.VERTEX_DIRECTION_TYPE_UNSPECIFIED=0]="VERTEX_DIRECTION_TYPE_UNSPECIFIED",e[e.VERTEX_DIRECTION_TYPE_NORTH=1]="VERTEX_DIRECTION_TYPE_NORTH",e[e.VERTEX_DIRECTION_TYPE_NORTH_EAST=2]="VERTEX_DIRECTION_TYPE_NORTH_EAST",e[e.VERTEX_DIRECTION_TYPE_NORTH_WEST=3]="VERTEX_DIRECTION_TYPE_NORTH_WEST",e[e.VERTEX_DIRECTION_TYPE_SOUTH=4]="VERTEX_DIRECTION_TYPE_SOUTH",e[e.VERTEX_DIRECTION_TYPE_SOUTH_EAST=5]="VERTEX_DIRECTION_TYPE_SOUTH_EAST",e[e.VERTEX_DIRECTION_TYPE_SOUTH_WEST=6]="VERTEX_DIRECTION_TYPE_SOUTH_WEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Dr||(Dr={}));function Sf(){return{diceTotal:0,count:0}}E(Sf,"createBaseDiceDistributionEntry");var Ks={encode(e,r=new Je){return e.diceTotal!==0&&r.uint32(8).int32(e.diceTotal),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Sf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.diceTotal=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Ks.fromPartial(e??{})},fromPartial(e){let r=Sf();return r.diceTotal=e.diceTotal??0,r.count=e.count??0,r}};function Of(){return{player:0,count:0}}E(Of,"createBasePlayerSevensCount");var Ws={encode(e,r=new Je){return e.player!==0&&r.uint32(8).int32(e.player),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Of();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Ws.fromPartial(e??{})},fromPartial(e){let r=Of();return r.player=e.player??0,r.count=e.count??0,r}};function If(){return{x:0,y:0,z:0}}E(If,"createBaseHexPointProto");var q={encode(e,r=new Je){return e.x!==0&&r.uint32(8).sint32(e.x),e.y!==0&&r.uint32(16).sint32(e.y),e.z!==0&&r.uint32(24).sint32(e.z),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=If();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.x=t.sint32();continue}case 2:{if(n!==16)break;i.y=t.sint32();continue}case 3:{if(n!==24)break;i.z=t.sint32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return q.fromPartial(e??{})},fromPartial(e){let r=If();return r.x=e.x??0,r.y=e.y??0,r.z=e.z??0,r}};function Cf(){return{x:0,y:0,z:0}}E(Cf,"createBaseVertexPointProto");var ee={encode(e,r=new Je){return e.x!==0&&r.uint32(8).sint32(e.x),e.y!==0&&r.uint32(16).sint32(e.y),e.z!==0&&r.uint32(24).sint32(e.z),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Cf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.x=t.sint32();continue}case 2:{if(n!==16)break;i.y=t.sint32();continue}case 3:{if(n!==24)break;i.z=t.sint32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ee.fromPartial(e??{})},fromPartial(e){let r=Cf();return r.x=e.x??0,r.y=e.y??0,r.z=e.z??0,r}};function Pf(){return{vertex:void 0,direction:0}}E(Pf,"createBaseEdgePointProto");var Ie={encode(e,r=new Je){return e.vertex!==void 0&&ee.encode(e.vertex,r.uint32(10).fork()).join(),e.direction!==0&&r.uint32(16).int32(e.direction),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Pf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.vertex=ee.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.direction=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Ie.fromPartial(e??{})},fromPartial(e){let r=Pf();return r.vertex=e.vertex!==void 0&&e.vertex!==null?ee.fromPartial(e.vertex):void 0,r.direction=e.direction??0,r}};function pf(){return{location:void 0,terrain:0,numbers:[],isRiver:!1}}E(pf,"createBaseTileProto");var ha={encode(e,r=new Je){e.location!==void 0&&q.encode(e.location,r.uint32(10).fork()).join(),e.terrain!==0&&r.uint32(16).int32(e.terrain),r.uint32(26).fork();for(let t of e.numbers)r.int32(t);return r.join(),e.isRiver!==!1&&r.uint32(32).bool(e.isRiver),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=pf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.location=q.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.terrain=t.int32();continue}case 3:{if(n===24){i.numbers.push(t.int32());continue}if(n===26){let a=t.uint32()+t.pos;for(;t.pos<a;)i.numbers.push(t.int32());continue}break}case 4:{if(n!==32)break;i.isRiver=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ha.fromPartial(e??{})},fromPartial(e){let r=pf();return r.location=e.location!==void 0&&e.location!==null?q.fromPartial(e.location):void 0,r.terrain=e.terrain??0,r.numbers=e.numbers?.map(t=>t)||[],r.isRiver=e.isRiver??!1,r}};function hf(){return{rate:0,resource:0,hex:void 0,edge:void 0}}E(hf,"createBasePortProto");var Nr={encode(e,r=new Je){return e.rate!==0&&r.uint32(8).int32(e.rate),e.resource!==0&&r.uint32(16).int32(e.resource),e.hex!==void 0&&q.encode(e.hex,r.uint32(26).fork()).join(),e.edge!==void 0&&Ie.encode(e.edge,r.uint32(34).fork()).join(),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=hf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.rate=t.int32();continue}case 2:{if(n!==16)break;i.resource=t.int32();continue}case 3:{if(n!==26)break;i.hex=q.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.edge=Ie.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Nr.fromPartial(e??{})},fromPartial(e){let r=hf();return r.rate=e.rate??0,r.resource=e.resource??0,r.hex=e.hex!==void 0&&e.hex!==null?q.fromPartial(e.hex):void 0,r.edge=e.edge!==void 0&&e.edge!==null?Ie.fromPartial(e.edge):void 0,r}};function Df(){return{edge:void 0,type:0,port:void 0}}E(Df,"createBaseEdgeRewardProto");var Da={encode(e,r=new Je){return e.edge!==void 0&&Ie.encode(e.edge,r.uint32(10).fork()).join(),e.type!==0&&r.uint32(16).int32(e.type),e.port!==void 0&&Nr.encode(e.port,r.uint32(26).fork()).join(),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Df();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.edge=Ie.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.type=t.int32();continue}case 3:{if(n!==26)break;i.port=Nr.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Da.fromPartial(e??{})},fromPartial(e){let r=Df();return r.edge=e.edge!==void 0&&e.edge!==null?Ie.fromPartial(e.edge):void 0,r.type=e.type??0,r.port=e.port!==void 0&&e.port!==null?Nr.fromPartial(e.port):void 0,r}};function mf(){return{player:0,port:void 0}}E(mf,"createBasePendingPortPlacementProto");var Js={encode(e,r=new Je){return e.player!==0&&r.uint32(8).int32(e.player),e.port!==void 0&&Nr.encode(e.port,r.uint32(18).fork()).join(),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=mf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==18)break;i.port=Nr.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Js.fromPartial(e??{})},fromPartial(e){let r=mf();return r.player=e.player??0,r.port=e.port!==void 0&&e.port!==null?Nr.fromPartial(e.port):void 0,r}};function gf(){return{hex:void 0,vertex:void 0,number:0}}E(gf,"createBaseFisheryProto");var ma={encode(e,r=new Je){return e.hex!==void 0&&q.encode(e.hex,r.uint32(10).fork()).join(),e.vertex!==void 0&&ee.encode(e.vertex,r.uint32(18).fork()).join(),e.number!==0&&r.uint32(24).int32(e.number),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=gf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.hex=q.decode(t,t.uint32());continue}case 2:{if(n!==18)break;i.vertex=ee.decode(t,t.uint32());continue}case 3:{if(n!==24)break;i.number=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ma.fromPartial(e??{})},fromPartial(e){let r=gf();return r.hex=e.hex!==void 0&&e.hex!==null?q.fromPartial(e.hex):void 0,r.vertex=e.vertex!==void 0&&e.vertex!==null?ee.fromPartial(e.vertex):void 0,r.number=e.number??0,r}};function yf(){return{edge:void 0,owner:0,building:0}}E(yf,"createBaseEdgeBuildingProto");var ga={encode(e,r=new Je){return e.edge!==void 0&&Ie.encode(e.edge,r.uint32(10).fork()).join(),e.owner!==0&&r.uint32(16).int32(e.owner),e.building!==0&&r.uint32(24).int32(e.building),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=yf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.edge=Ie.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.owner=t.int32();continue}case 3:{if(n!==24)break;i.building=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ga.fromPartial(e??{})},fromPartial(e){let r=yf();return r.edge=e.edge!==void 0&&e.edge!==null?Ie.fromPartial(e.edge):void 0,r.owner=e.owner??0,r.building=e.building??0,r}};function Mf(){return{vertex:void 0,owner:0,building:0}}E(Mf,"createBaseVertexBuildingProto");var ya={encode(e,r=new Je){return e.vertex!==void 0&&ee.encode(e.vertex,r.uint32(10).fork()).join(),e.owner!==0&&r.uint32(16).int32(e.owner),e.building!==0&&r.uint32(24).int32(e.building),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Mf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.vertex=ee.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.owner=t.int32();continue}case 3:{if(n!==24)break;i.building=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ya.fromPartial(e??{})},fromPartial(e){let r=Mf();return r.vertex=e.vertex!==void 0&&e.vertex!==null?ee.fromPartial(e.vertex):void 0,r.owner=e.owner??0,r.building=e.building??0,r}};function Lf(){return{edge:void 0,facing:0}}E(Lf,"createBaseWagonProto");var Bn={encode(e,r=new Je){return e.edge!==void 0&&Ie.encode(e.edge,r.uint32(10).fork()).join(),e.facing!==0&&r.uint32(16).int32(e.facing),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Lf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.edge=Ie.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.facing=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Bn.fromPartial(e??{})},fromPartial(e){let r=Lf();return r.edge=e.edge!==void 0&&e.edge!==null?Ie.fromPartial(e.edge):void 0,r.facing=e.facing??0,r}};function Gf(){return{player:0,woolBid:0,wheatBid:0,preferredEdge:void 0,preferredFacing:0}}E(Gf,"createBaseWagonVoteProto");var kn={encode(e,r=new Je){return e.player!==0&&r.uint32(8).int32(e.player),e.woolBid!==0&&r.uint32(16).int32(e.woolBid),e.wheatBid!==0&&r.uint32(24).int32(e.wheatBid),e.preferredEdge!==void 0&&Ie.encode(e.preferredEdge,r.uint32(34).fork()).join(),e.preferredFacing!==0&&r.uint32(40).int32(e.preferredFacing),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Gf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.woolBid=t.int32();continue}case 3:{if(n!==24)break;i.wheatBid=t.int32();continue}case 4:{if(n!==34)break;i.preferredEdge=Ie.decode(t,t.uint32());continue}case 5:{if(n!==40)break;i.preferredFacing=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return kn.fromPartial(e??{})},fromPartial(e){let r=Gf();return r.player=e.player??0,r.woolBid=e.woolBid??0,r.wheatBid=e.wheatBid??0,r.preferredEdge=e.preferredEdge!==void 0&&e.preferredEdge!==null?Ie.fromPartial(e.preferredEdge):void 0,r.preferredFacing=e.preferredFacing??0,r}};function Uf(){return{activePlayer:0,remainingVoters:[],votes:[]}}E(Uf,"createBasePendingWagonVotingProto");var qs={encode(e,r=new Je){e.activePlayer!==0&&r.uint32(8).int32(e.activePlayer),r.uint32(18).fork();for(let t of e.remainingVoters)r.int32(t);r.join();for(let t of e.votes)kn.encode(t,r.uint32(26).fork()).join();return r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Uf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.activePlayer=t.int32();continue}case 2:{if(n===16){i.remainingVoters.push(t.int32());continue}if(n===18){let a=t.uint32()+t.pos;for(;t.pos<a;)i.remainingVoters.push(t.int32());continue}break}case 3:{if(n!==26)break;i.votes.push(kn.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return qs.fromPartial(e??{})},fromPartial(e){let r=Uf();return r.activePlayer=e.activePlayer??0,r.remainingVoters=e.remainingVoters?.map(t=>t)||[],r.votes=e.votes?.map(t=>kn.fromPartial(t))||[],r}};function Bf(){return{commodity:0,count:0}}E(Bf,"createBaseCommodityCount");var te={encode(e,r=new Je){return e.commodity!==0&&r.uint32(8).int32(e.commodity),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Bf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.commodity=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return te.fromPartial(e??{})},fromPartial(e){let r=Bf();return r.commodity=e.commodity??0,r.count=e.count??0,r}};function kf(){return{card:0,count:0}}E(kf,"createBaseProgressCardCount");var dr={encode(e,r=new Je){return e.card!==0&&r.uint32(8).int32(e.card),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=kf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.card=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return dr.fromPartial(e??{})},fromPartial(e){let r=kf();return r.card=e.card??0,r.count=e.count??0,r}};function bf(){return{fish:0,count:0}}E(bf,"createBaseFishCount");var xe={encode(e,r=new Je){return e.fish!==0&&r.uint32(8).int32(e.fish),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=bf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.fish=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return xe.fromPartial(e??{})},fromPartial(e){let r=bf();return r.fish=e.fish??0,r.count=e.count??0,r}};function vf(){return{hex:void 0,terrain:0,number:0}}E(vf,"createBaseInitialFogRevealProto");var Zs={encode(e,r=new Je){return e.hex!==void 0&&q.encode(e.hex,r.uint32(10).fork()).join(),e.terrain!==0&&r.uint32(16).int32(e.terrain),e.number!==0&&r.uint32(24).int32(e.number),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=vf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.hex=q.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.terrain=t.int32();continue}case 3:{if(n!==24)break;i.number=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Zs.fromPartial(e??{})},fromPartial(e){let r=vf();return r.hex=e.hex!==void 0&&e.hex!==null?q.fromPartial(e.hex):void 0,r.terrain=e.terrain??0,r.number=e.number??0,r}};function Yf(){return{location:void 0,owner:0,strength:0,status:0,activatedThisTurn:!1,promotedThisTurn:!1}}E(Yf,"createBaseKnightProto");var id={encode(e,r=new Je){return e.location!==void 0&&ee.encode(e.location,r.uint32(10).fork()).join(),e.owner!==0&&r.uint32(16).int32(e.owner),e.strength!==0&&r.uint32(24).int32(e.strength),e.status!==0&&r.uint32(32).int32(e.status),e.activatedThisTurn!==!1&&r.uint32(40).bool(e.activatedThisTurn),e.promotedThisTurn!==!1&&r.uint32(48).bool(e.promotedThisTurn),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Yf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.location=ee.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.owner=t.int32();continue}case 3:{if(n!==24)break;i.strength=t.int32();continue}case 4:{if(n!==32)break;i.status=t.int32();continue}case 5:{if(n!==40)break;i.activatedThisTurn=t.bool();continue}case 6:{if(n!==48)break;i.promotedThisTurn=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return id.fromPartial(e??{})},fromPartial(e){let r=Yf();return r.location=e.location!==void 0&&e.location!==null?ee.fromPartial(e.location):void 0,r.owner=e.owner??0,r.strength=e.strength??0,r.status=e.status??0,r.activatedThisTurn=e.activatedThisTurn??!1,r.promotedThisTurn=e.promotedThisTurn??!1,r}};function Ff(){return{location:void 0,owner:0}}E(Ff,"createBaseCityWallProto");var od={encode(e,r=new Je){return e.location!==void 0&&ee.encode(e.location,r.uint32(10).fork()).join(),e.owner!==0&&r.uint32(16).int32(e.owner),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Ff();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.location=ee.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.owner=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return od.fromPartial(e??{})},fromPartial(e){let r=Ff();return r.location=e.location!==void 0&&e.location!==null?ee.fromPartial(e.location):void 0,r.owner=e.owner??0,r}};function Vf(){return{tradeLevel:0,politicsLevel:0,scienceLevel:0}}E(Vf,"createBaseCityImprovementsProto");var Xs={encode(e,r=new Je){return e.tradeLevel!==0&&r.uint32(8).int32(e.tradeLevel),e.politicsLevel!==0&&r.uint32(16).int32(e.politicsLevel),e.scienceLevel!==0&&r.uint32(24).int32(e.scienceLevel),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Vf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.tradeLevel=t.int32();continue}case 2:{if(n!==16)break;i.politicsLevel=t.int32();continue}case 3:{if(n!==24)break;i.scienceLevel=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Xs.fromPartial(e??{})},fromPartial(e){let r=Vf();return r.tradeLevel=e.tradeLevel??0,r.politicsLevel=e.politicsLevel??0,r.scienceLevel=e.scienceLevel??0,r}};function xf(){return{track:0,location:void 0,owner:0}}E(xf,"createBaseMetropolisProto");var bn={encode(e,r=new Je){return e.track!==0&&r.uint32(8).int32(e.track),e.location!==void 0&&ee.encode(e.location,r.uint32(18).fork()).join(),e.owner!==0&&r.uint32(24).int32(e.owner),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=xf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.track=t.int32();continue}case 2:{if(n!==18)break;i.location=ee.decode(t,t.uint32());continue}case 3:{if(n!==24)break;i.owner=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return bn.fromPartial(e??{})},fromPartial(e){let r=xf();return r.track=e.track??0,r.location=e.location!==void 0&&e.location!==null?ee.fromPartial(e.location):void 0,r.owner=e.owner??0,r}};function wf(){return{location:void 0,owner:0}}E(wf,"createBaseMerchantProto");var ad={encode(e,r=new Je){return e.location!==void 0&&q.encode(e.location,r.uint32(10).fork()).join(),e.owner!==0&&r.uint32(16).int32(e.owner),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=wf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.location=q.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.owner=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ad.fromPartial(e??{})},fromPartial(e){let r=wf();return r.location=e.location!==void 0&&e.location!==null?q.fromPartial(e.location):void 0,r.owner=e.owner??0,r}};function Hf(){return{position:0,hasAttacked:!1}}E(Hf,"createBaseBarbarianStateProto");var sd={encode(e,r=new Je){return e.position!==0&&r.uint32(8).int32(e.position),e.hasAttacked!==!1&&r.uint32(16).bool(e.hasAttacked),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Hf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.position=t.int32();continue}case 2:{if(n!==16)break;i.hasAttacked=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return sd.fromPartial(e??{})},fromPartial(e){let r=Hf();return r.position=e.position??0,r.hasAttacked=e.hasAttacked??!1,r}};function Kf(){return{result:0}}E(Kf,"createBaseEventDiceProto");var zs={encode(e,r=new Je){return e.result!==0&&r.uint32(8).int32(e.result),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Kf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.result=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return zs.fromPartial(e??{})},fromPartial(e){let r=Kf();return r.result=e.result??0,r}};function Wf(){return{resource:0,count:0}}E(Wf,"createBaseResourceCount");var ne={encode(e,r=new Je){return e.resource!==0&&r.uint32(8).int32(e.resource),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Wf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.resource=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ne.fromPartial(e??{})},fromPartial(e){let r=Wf();return r.resource=e.resource??0,r.count=e.count??0,r}};function Jf(){return{card:0,count:0}}E(Jf,"createBaseDevCardCount");var Er={encode(e,r=new Je){return e.card!==0&&r.uint32(8).int32(e.card),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Jf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.card=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Er.fromPartial(e??{})},fromPartial(e){let r=Jf();return r.card=e.card??0,r.count=e.count??0,r}};function qf(){return{card:0,count:0}}E(qf,"createBaseEventCardCount");var Rr={encode(e,r=new Je){return e.card!==0&&r.uint32(8).int32(e.card),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=qf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.card=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Rr.fromPartial(e??{})},fromPartial(e){let r=qf();return r.card=e.card??0,r.count=e.count??0,r}};function Zf(){return{tiles:[],ports:[],robbers:[],pirate:void 0,edgeBuildings:[],vertexBuildings:[],knights:[],cityWalls:[],metropolises:[],merchant:void 0,barbarians:void 0,fisheries:[],edgeRewards:[],wagons:[],trolls:[]}}E(Zf,"createBaseGameBoardProto");var $n={encode(e,r=new Je){for(let t of e.tiles)ha.encode(t,r.uint32(10).fork()).join();for(let t of e.ports)Nr.encode(t,r.uint32(18).fork()).join();for(let t of e.robbers)q.encode(t,r.uint32(26).fork()).join();e.pirate!==void 0&&q.encode(e.pirate,r.uint32(34).fork()).join();for(let t of e.edgeBuildings)ga.encode(t,r.uint32(82).fork()).join();for(let t of e.vertexBuildings)ya.encode(t,r.uint32(90).fork()).join();for(let t of e.knights)id.encode(t,r.uint32(42).fork()).join();for(let t of e.cityWalls)od.encode(t,r.uint32(50).fork()).join();for(let t of e.metropolises)bn.encode(t,r.uint32(58).fork()).join();e.merchant!==void 0&&ad.encode(e.merchant,r.uint32(66).fork()).join(),e.barbarians!==void 0&&sd.encode(e.barbarians,r.uint32(74).fork()).join();for(let t of e.fisheries)ma.encode(t,r.uint32(98).fork()).join();for(let t of e.edgeRewards)Da.encode(t,r.uint32(106).fork()).join();for(let t of e.wagons)Bn.encode(t,r.uint32(114).fork()).join();for(let t of e.trolls)q.encode(t,r.uint32(122).fork()).join();return r},decode(e,r){let t=e instanceof se?e:new se(e),o=r===void 0?t.len:t.pos+r,i=Zf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.tiles.push(ha.decode(t,t.uint32()));continue}case 2:{if(n!==18)break;i.ports.push(Nr.decode(t,t.uint32()));continue}case 3:{if(n!==26)break;i.robbers.push(q.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.pirate=q.decode(t,t.uint32());continue}case 10:{if(n!==82)break;i.edgeBuildings.push(ga.decode(t,t.uint32()));continue}case 11:{if(n!==90)break;i.vertexBuildings.push(ya.decode(t,t.uint32()));continue}case 5:{if(n!==42)break;i.knights.push(id.decode(t,t.uint32()));continue}case 6:{if(n!==50)break;i.cityWalls.push(od.decode(t,t.uint32()));continue}case 7:{if(n!==58)break;i.metropolises.push(bn.decode(t,t.uint32()));continue}case 8:{if(n!==66)break;i.merchant=ad.decode(t,t.uint32());continue}case 9:{if(n!==74)break;i.barbarians=sd.decode(t,t.uint32());continue}case 12:{if(n!==98)break;i.fisheries.push(ma.decode(t,t.uint32()));continue}case 13:{if(n!==106)break;i.edgeRewards.push(Da.decode(t,t.uint32()));continue}case 14:{if(n!==114)break;i.wagons.push(Bn.decode(t,t.uint32()));continue}case 15:{if(n!==122)break;i.trolls.push(q.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return $n.fromPartial(e??{})},fromPartial(e){let r=Zf();return r.tiles=e.tiles?.map(t=>ha.fromPartial(t))||[],r.ports=e.ports?.map(t=>Nr.fromPartial(t))||[],r.robbers=e.robbers?.map(t=>q.fromPartial(t))||[],r.pirate=e.pirate!==void 0&&e.pirate!==null?q.fromPartial(e.pirate):void 0,r.edgeBuildings=e.edgeBuildings?.map(t=>ga.fromPartial(t))||[],r.vertexBuildings=e.vertexBuildings?.map(t=>ya.fromPartial(t))||[],r.knights=e.knights?.map(t=>id.fromPartial(t))||[],r.cityWalls=e.cityWalls?.map(t=>od.fromPartial(t))||[],r.metropolises=e.metropolises?.map(t=>bn.fromPartial(t))||[],r.merchant=e.merchant!==void 0&&e.merchant!==null?ad.fromPartial(e.merchant):void 0,r.barbarians=e.barbarians!==void 0&&e.barbarians!==null?sd.fromPartial(e.barbarians):void 0,r.fisheries=e.fisheries?.map(t=>ma.fromPartial(t))||[],r.edgeRewards=e.edgeRewards?.map(t=>Da.fromPartial(t))||[],r.wagons=e.wagons?.map(t=>Bn.fromPartial(t))||[],r.trolls=e.trolls?.map(t=>q.fromPartial(t))||[],r}};import{BinaryReader as fe,BinaryWriter as or}from"@bufbuild/protobuf/wire";function Xf(){return{player:0,unplayedDevCardCount:0,playedDevCards:[],cityImprovements:void 0,progressCardCount:0,defenderOfCatanVp:0,scienceProgressCardCount:0,politicsProgressCardCount:0,tradeProgressCardCount:0,cardCount:0,progressCardVp:0,visibleVictoryPoints:0,longestRoadLength:0,fishTileCount:0,hasOldBoot:!1,newIslandSettlementCount:0,edgeRewardVp:0,heldPortCount:0,gold:0,victoryPointProgressCards:[]}}E(Xf,"createBasePlayerPublicStateProto");var Qn={encode(e,r=new or){e.player!==0&&r.uint32(8).int32(e.player),e.unplayedDevCardCount!==0&&r.uint32(16).int32(e.unplayedDevCardCount);for(let t of e.playedDevCards)Er.encode(t,r.uint32(26).fork()).join();e.cityImprovements!==void 0&&Xs.encode(e.cityImprovements,r.uint32(34).fork()).join(),e.progressCardCount!==0&&r.uint32(40).int32(e.progressCardCount),e.defenderOfCatanVp!==0&&r.uint32(48).int32(e.defenderOfCatanVp),e.scienceProgressCardCount!==0&&r.uint32(136).int32(e.scienceProgressCardCount),e.politicsProgressCardCount!==0&&r.uint32(144).int32(e.politicsProgressCardCount),e.tradeProgressCardCount!==0&&r.uint32(152).int32(e.tradeProgressCardCount),e.cardCount!==0&&r.uint32(56).int32(e.cardCount),e.progressCardVp!==0&&r.uint32(64).int32(e.progressCardVp),e.visibleVictoryPoints!==0&&r.uint32(72).int32(e.visibleVictoryPoints),e.longestRoadLength!==0&&r.uint32(80).int32(e.longestRoadLength),e.fishTileCount!==0&&r.uint32(88).int32(e.fishTileCount),e.hasOldBoot!==!1&&r.uint32(96).bool(e.hasOldBoot),e.newIslandSettlementCount!==0&&r.uint32(104).int32(e.newIslandSettlementCount),e.edgeRewardVp!==0&&r.uint32(112).int32(e.edgeRewardVp),e.heldPortCount!==0&&r.uint32(120).int32(e.heldPortCount),e.gold!==0&&r.uint32(128).int32(e.gold),r.uint32(162).fork();for(let t of e.victoryPointProgressCards)r.int32(t);return r.join(),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=Xf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.unplayedDevCardCount=t.int32();continue}case 3:{if(n!==26)break;i.playedDevCards.push(Er.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.cityImprovements=Xs.decode(t,t.uint32());continue}case 5:{if(n!==40)break;i.progressCardCount=t.int32();continue}case 6:{if(n!==48)break;i.defenderOfCatanVp=t.int32();continue}case 17:{if(n!==136)break;i.scienceProgressCardCount=t.int32();continue}case 18:{if(n!==144)break;i.politicsProgressCardCount=t.int32();continue}case 19:{if(n!==152)break;i.tradeProgressCardCount=t.int32();continue}case 7:{if(n!==56)break;i.cardCount=t.int32();continue}case 8:{if(n!==64)break;i.progressCardVp=t.int32();continue}case 9:{if(n!==72)break;i.visibleVictoryPoints=t.int32();continue}case 10:{if(n!==80)break;i.longestRoadLength=t.int32();continue}case 11:{if(n!==88)break;i.fishTileCount=t.int32();continue}case 12:{if(n!==96)break;i.hasOldBoot=t.bool();continue}case 13:{if(n!==104)break;i.newIslandSettlementCount=t.int32();continue}case 14:{if(n!==112)break;i.edgeRewardVp=t.int32();continue}case 15:{if(n!==120)break;i.heldPortCount=t.int32();continue}case 16:{if(n!==128)break;i.gold=t.int32();continue}case 20:{if(n===160){i.victoryPointProgressCards.push(t.int32());continue}if(n===162){let a=t.uint32()+t.pos;for(;t.pos<a;)i.victoryPointProgressCards.push(t.int32());continue}break}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Qn.fromPartial(e??{})},fromPartial(e){let r=Xf();return r.player=e.player??0,r.unplayedDevCardCount=e.unplayedDevCardCount??0,r.playedDevCards=e.playedDevCards?.map(t=>Er.fromPartial(t))||[],r.cityImprovements=e.cityImprovements!==void 0&&e.cityImprovements!==null?Xs.fromPartial(e.cityImprovements):void 0,r.progressCardCount=e.progressCardCount??0,r.defenderOfCatanVp=e.defenderOfCatanVp??0,r.scienceProgressCardCount=e.scienceProgressCardCount??0,r.politicsProgressCardCount=e.politicsProgressCardCount??0,r.tradeProgressCardCount=e.tradeProgressCardCount??0,r.cardCount=e.cardCount??0,r.progressCardVp=e.progressCardVp??0,r.visibleVictoryPoints=e.visibleVictoryPoints??0,r.longestRoadLength=e.longestRoadLength??0,r.fishTileCount=e.fishTileCount??0,r.hasOldBoot=e.hasOldBoot??!1,r.newIslandSettlementCount=e.newIslandSettlementCount??0,r.edgeRewardVp=e.edgeRewardVp??0,r.heldPortCount=e.heldPortCount??0,r.gold=e.gold??0,r.victoryPointProgressCards=e.victoryPointProgressCards?.map(t=>t)||[],r}};function zf(){return{player:0,hand:[],unplayedDevCards:[],devCardsPurchasedThisTurn:[],commodities:[],progressCards:[],masterMerchantResources:[],masterMerchantCommodities:[],spyVisibleProgressCards:[],fishTiles:[],heldPorts:[],gold:0}}E(zf,"createBasePlayerStateProto");var jn={encode(e,r=new or){e.player!==0&&r.uint32(8).int32(e.player);for(let t of e.hand)ne.encode(t,r.uint32(18).fork()).join();for(let t of e.unplayedDevCards)Er.encode(t,r.uint32(26).fork()).join();for(let t of e.devCardsPurchasedThisTurn)Er.encode(t,r.uint32(34).fork()).join();for(let t of e.commodities)te.encode(t,r.uint32(42).fork()).join();for(let t of e.progressCards)dr.encode(t,r.uint32(50).fork()).join();for(let t of e.masterMerchantResources)ne.encode(t,r.uint32(58).fork()).join();for(let t of e.masterMerchantCommodities)te.encode(t,r.uint32(66).fork()).join();for(let t of e.spyVisibleProgressCards)dr.encode(t,r.uint32(74).fork()).join();for(let t of e.fishTiles)xe.encode(t,r.uint32(82).fork()).join();for(let t of e.heldPorts)Nr.encode(t,r.uint32(90).fork()).join();return e.gold!==0&&r.uint32(96).int32(e.gold),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=zf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==18)break;i.hand.push(ne.decode(t,t.uint32()));continue}case 3:{if(n!==26)break;i.unplayedDevCards.push(Er.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.devCardsPurchasedThisTurn.push(Er.decode(t,t.uint32()));continue}case 5:{if(n!==42)break;i.commodities.push(te.decode(t,t.uint32()));continue}case 6:{if(n!==50)break;i.progressCards.push(dr.decode(t,t.uint32()));continue}case 7:{if(n!==58)break;i.masterMerchantResources.push(ne.decode(t,t.uint32()));continue}case 8:{if(n!==66)break;i.masterMerchantCommodities.push(te.decode(t,t.uint32()));continue}case 9:{if(n!==74)break;i.spyVisibleProgressCards.push(dr.decode(t,t.uint32()));continue}case 10:{if(n!==82)break;i.fishTiles.push(xe.decode(t,t.uint32()));continue}case 11:{if(n!==90)break;i.heldPorts.push(Nr.decode(t,t.uint32()));continue}case 12:{if(n!==96)break;i.gold=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return jn.fromPartial(e??{})},fromPartial(e){let r=zf();return r.player=e.player??0,r.hand=e.hand?.map(t=>ne.fromPartial(t))||[],r.unplayedDevCards=e.unplayedDevCards?.map(t=>Er.fromPartial(t))||[],r.devCardsPurchasedThisTurn=e.devCardsPurchasedThisTurn?.map(t=>Er.fromPartial(t))||[],r.commodities=e.commodities?.map(t=>te.fromPartial(t))||[],r.progressCards=e.progressCards?.map(t=>dr.fromPartial(t))||[],r.masterMerchantResources=e.masterMerchantResources?.map(t=>ne.fromPartial(t))||[],r.masterMerchantCommodities=e.masterMerchantCommodities?.map(t=>te.fromPartial(t))||[],r.spyVisibleProgressCards=e.spyVisibleProgressCards?.map(t=>dr.fromPartial(t))||[],r.fishTiles=e.fishTiles?.map(t=>xe.fromPartial(t))||[],r.heldPorts=e.heldPorts?.map(t=>Nr.fromPartial(t))||[],r.gold=e.gold??0,r}};function $f(){return{die1:0,die2:0,eventDie:0,eventCard:0}}E($f,"createBaseDiceProto");var Dt={encode(e,r=new or){return e.die1!==0&&r.uint32(8).int32(e.die1),e.die2!==0&&r.uint32(16).int32(e.die2),e.eventDie!==0&&r.uint32(24).int32(e.eventDie),e.eventCard!==0&&r.uint32(32).int32(e.eventCard),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=$f();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.die1=t.int32();continue}case 2:{if(n!==16)break;i.die2=t.int32();continue}case 3:{if(n!==24)break;i.eventDie=t.int32();continue}case 4:{if(n!==32)break;i.eventCard=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Dt.fromPartial(e??{})},fromPartial(e){let r=$f();return r.die1=e.die1??0,r.die2=e.die2??0,r.eventDie=e.eventDie??0,r.eventCard=e.eventCard??0,r}};function Qf(){return{id:0,proposer:0,offering:[],requesting:[],acceptingPlayers:[],rejectedPlayers:[],offeringCommodities:[],requestingCommodities:[],offeringGold:0,requestingGold:0,counterTradeId:0}}E(Qf,"createBaseTradeProto");var ei={encode(e,r=new or){e.id!==0&&r.uint32(8).int32(e.id),e.proposer!==0&&r.uint32(16).int32(e.proposer);for(let t of e.offering)ne.encode(t,r.uint32(26).fork()).join();for(let t of e.requesting)ne.encode(t,r.uint32(34).fork()).join();r.uint32(42).fork();for(let t of e.acceptingPlayers)r.int32(t);r.join(),r.uint32(50).fork();for(let t of e.rejectedPlayers)r.int32(t);r.join();for(let t of e.offeringCommodities)te.encode(t,r.uint32(58).fork()).join();for(let t of e.requestingCommodities)te.encode(t,r.uint32(66).fork()).join();return e.offeringGold!==0&&r.uint32(72).int32(e.offeringGold),e.requestingGold!==0&&r.uint32(80).int32(e.requestingGold),e.counterTradeId!==0&&r.uint32(88).int32(e.counterTradeId),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=Qf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.id=t.int32();continue}case 2:{if(n!==16)break;i.proposer=t.int32();continue}case 3:{if(n!==26)break;i.offering.push(ne.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.requesting.push(ne.decode(t,t.uint32()));continue}case 5:{if(n===40){i.acceptingPlayers.push(t.int32());continue}if(n===42){let a=t.uint32()+t.pos;for(;t.pos<a;)i.acceptingPlayers.push(t.int32());continue}break}case 6:{if(n===48){i.rejectedPlayers.push(t.int32());continue}if(n===50){let a=t.uint32()+t.pos;for(;t.pos<a;)i.rejectedPlayers.push(t.int32());continue}break}case 7:{if(n!==58)break;i.offeringCommodities.push(te.decode(t,t.uint32()));continue}case 8:{if(n!==66)break;i.requestingCommodities.push(te.decode(t,t.uint32()));continue}case 9:{if(n!==72)break;i.offeringGold=t.int32();continue}case 10:{if(n!==80)break;i.requestingGold=t.int32();continue}case 11:{if(n!==88)break;i.counterTradeId=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ei.fromPartial(e??{})},fromPartial(e){let r=Qf();return r.id=e.id??0,r.proposer=e.proposer??0,r.offering=e.offering?.map(t=>ne.fromPartial(t))||[],r.requesting=e.requesting?.map(t=>ne.fromPartial(t))||[],r.acceptingPlayers=e.acceptingPlayers?.map(t=>t)||[],r.rejectedPlayers=e.rejectedPlayers?.map(t=>t)||[],r.offeringCommodities=e.offeringCommodities?.map(t=>te.fromPartial(t))||[],r.requestingCommodities=e.requestingCommodities?.map(t=>te.fromPartial(t))||[],r.offeringGold=e.offeringGold??0,r.requestingGold=e.requestingGold??0,r.counterTradeId=e.counterTradeId??0,r}};function jf(){return{proposer:0,offering:[],requesting:[],offeringCommodities:[],requestingCommodities:[],offeringGold:0,requestingGold:0,proposerCardCount:0}}E(jf,"createBaseRejectedTradeOfferProto");var ri={encode(e,r=new or){e.proposer!==0&&r.uint32(8).int32(e.proposer);for(let t of e.offering)ne.encode(t,r.uint32(18).fork()).join();for(let t of e.requesting)ne.encode(t,r.uint32(26).fork()).join();for(let t of e.offeringCommodities)te.encode(t,r.uint32(34).fork()).join();for(let t of e.requestingCommodities)te.encode(t,r.uint32(42).fork()).join();return e.offeringGold!==0&&r.uint32(48).int32(e.offeringGold),e.requestingGold!==0&&r.uint32(56).int32(e.requestingGold),e.proposerCardCount!==0&&r.uint32(64).int32(e.proposerCardCount),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=jf();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.proposer=t.int32();continue}case 2:{if(n!==18)break;i.offering.push(ne.decode(t,t.uint32()));continue}case 3:{if(n!==26)break;i.requesting.push(ne.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.offeringCommodities.push(te.decode(t,t.uint32()));continue}case 5:{if(n!==42)break;i.requestingCommodities.push(te.decode(t,t.uint32()));continue}case 6:{if(n!==48)break;i.offeringGold=t.int32();continue}case 7:{if(n!==56)break;i.requestingGold=t.int32();continue}case 8:{if(n!==64)break;i.proposerCardCount=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ri.fromPartial(e??{})},fromPartial(e){let r=jf();return r.proposer=e.proposer??0,r.offering=e.offering?.map(t=>ne.fromPartial(t))||[],r.requesting=e.requesting?.map(t=>ne.fromPartial(t))||[],r.offeringCommodities=e.offeringCommodities?.map(t=>te.fromPartial(t))||[],r.requestingCommodities=e.requestingCommodities?.map(t=>te.fromPartial(t))||[],r.offeringGold=e.offeringGold??0,r.requestingGold=e.requestingGold??0,r.proposerCardCount=e.proposerCardCount??0,r}};function eT(){return{player:0,count:0}}E(eT,"createBasePendingFreeResourcesProto");var ti={encode(e,r=new or){return e.player!==0&&r.uint32(8).int32(e.player),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=eT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ti.fromPartial(e??{})},fromPartial(e){let r=eT();return r.player=e.player??0,r.count=e.count??0,r}};function rT(){return{player:0,structures:[]}}E(rT,"createBasePendingFreeStructuresProto");var ni={encode(e,r=new or){e.player!==0&&r.uint32(8).int32(e.player),r.uint32(18).fork();for(let t of e.structures)r.int32(t);return r.join(),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=rT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n===16){i.structures.push(t.int32());continue}if(n===18){let a=t.uint32()+t.pos;for(;t.pos<a;)i.structures.push(t.int32());continue}break}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ni.fromPartial(e??{})},fromPartial(e){let r=rT();return r.player=e.player??0,r.structures=e.structures?.map(t=>t)||[],r}};function tT(){return{player:0,count:0}}E(tT,"createBasePendingDiscardsProto");var mt={encode(e,r=new or){return e.player!==0&&r.uint32(8).int32(e.player),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=tT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return mt.fromPartial(e??{})},fromPartial(e){let r=tT();return r.player=e.player??0,r.count=e.count??0,r}};function nT(){return{player:0,weddingPlayer:0}}E(nT,"createBasePendingWeddingCardsProto");var ii={encode(e,r=new or){return e.player!==0&&r.uint32(8).int32(e.player),e.weddingPlayer!==0&&r.uint32(16).int32(e.weddingPlayer),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=nT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.weddingPlayer=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ii.fromPartial(e??{})},fromPartial(e){let r=nT();return r.player=e.player??0,r.weddingPlayer=e.weddingPlayer??0,r}};function iT(){return{opponent:0,harborPlayer:0,resource:0}}E(iT,"createBasePendingCommercialHarborProto");var oi={encode(e,r=new or){return e.opponent!==0&&r.uint32(8).int32(e.opponent),e.harborPlayer!==0&&r.uint32(16).int32(e.harborPlayer),e.resource!==0&&r.uint32(24).int32(e.resource),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=iT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.opponent=t.int32();continue}case 2:{if(n!==16)break;i.harborPlayer=t.int32();continue}case 3:{if(n!==24)break;i.resource=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return oi.fromPartial(e??{})},fromPartial(e){let r=iT();return r.opponent=e.opponent??0,r.harborPlayer=e.harborPlayer??0,r.resource=e.resource??0,r}};function oT(){return{opponent:0,resource:0}}E(oT,"createBaseCommercialHarborTradeProto");var gt={encode(e,r=new or){return e.opponent!==0&&r.uint32(8).int32(e.opponent),e.resource!==0&&r.uint32(16).int32(e.resource),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=oT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.opponent=t.int32();continue}case 2:{if(n!==16)break;i.resource=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return gt.fromPartial(e??{})},fromPartial(e){let r=oT();return r.opponent=e.opponent??0,r.resource=e.resource??0,r}};function aT(){return{player:0,strength:0,status:0,fromVertex:void 0}}E(aT,"createBasePendingKnightProto");var ai={encode(e,r=new or){return e.player!==0&&r.uint32(8).int32(e.player),e.strength!==0&&r.uint32(16).int32(e.strength),e.status!==0&&r.uint32(24).int32(e.status),e.fromVertex!==void 0&&ee.encode(e.fromVertex,r.uint32(34).fork()).join(),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=aT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.strength=t.int32();continue}case 3:{if(n!==24)break;i.status=t.int32();continue}case 4:{if(n!==34)break;i.fromVertex=ee.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ai.fromPartial(e??{})},fromPartial(e){let r=aT();return r.player=e.player??0,r.strength=e.strength??0,r.status=e.status??0,r.fromVertex=e.fromVertex!==void 0&&e.fromVertex!==null?ee.fromPartial(e.fromVertex):void 0,r}};function sT(){return{barbarianStrength:0,committedKnights:[],currentPlayer:0,playersCommitted:[]}}E(sT,"createBasePendingKnightCommitmentProto");var si={encode(e,r=new or){e.barbarianStrength!==0&&r.uint32(8).int32(e.barbarianStrength);for(let t of e.committedKnights)ee.encode(t,r.uint32(18).fork()).join();e.currentPlayer!==0&&r.uint32(24).int32(e.currentPlayer),r.uint32(34).fork();for(let t of e.playersCommitted)r.int32(t);return r.join(),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=sT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.barbarianStrength=t.int32();continue}case 2:{if(n!==18)break;i.committedKnights.push(ee.decode(t,t.uint32()));continue}case 3:{if(n!==24)break;i.currentPlayer=t.int32();continue}case 4:{if(n===32){i.playersCommitted.push(t.int32());continue}if(n===34){let a=t.uint32()+t.pos;for(;t.pos<a;)i.playersCommitted.push(t.int32());continue}break}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return si.fromPartial(e??{})},fromPartial(e){let r=sT();return r.barbarianStrength=e.barbarianStrength??0,r.committedKnights=e.committedKnights?.map(t=>ee.fromPartial(t))||[],r.currentPlayer=e.currentPlayer??0,r.playersCommitted=e.playersCommitted?.map(t=>t)||[],r}};function _T(){return{deserterPlayer:0,targetPlayer:0}}E(_T,"createBasePendingDeserterProto");var _i={encode(e,r=new or){return e.deserterPlayer!==0&&r.uint32(8).int32(e.deserterPlayer),e.targetPlayer!==0&&r.uint32(16).int32(e.targetPlayer),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=_T();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.deserterPlayer=t.int32();continue}case 2:{if(n!==16)break;i.targetPlayer=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return _i.fromPartial(e??{})},fromPartial(e){let r=_T();return r.deserterPlayer=e.deserterPlayer??0,r.targetPlayer=e.targetPlayer??0,r}};function dT(){return{player:0,track:0,isSteal:!1,stolenFrom:0}}E(dT,"createBasePendingMetropolisPlacementProto");var di={encode(e,r=new or){return e.player!==0&&r.uint32(8).int32(e.player),e.track!==0&&r.uint32(16).int32(e.track),e.isSteal!==!1&&r.uint32(24).bool(e.isSteal),e.stolenFrom!==0&&r.uint32(32).int32(e.stolenFrom),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=dT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.track=t.int32();continue}case 3:{if(n!==24)break;i.isSteal=t.bool();continue}case 4:{if(n!==32)break;i.stolenFrom=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return di.fromPartial(e??{})},fromPartial(e){let r=dT();return r.player=e.player??0,r.track=e.track??0,r.isSteal=e.isSteal??!1,r.stolenFrom=e.stolenFrom??0,r}};function uT(){return{resource:0,targetAmount:0,mode:0}}E(uT,"createBaseResourceGoalProto");var $s={encode(e,r=new or){return e.resource!==0&&r.uint32(8).int32(e.resource),e.targetAmount!==0&&r.uint32(16).int32(e.targetAmount),e.mode!==0&&r.uint32(24).int32(e.mode),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=uT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.resource=t.int32();continue}case 2:{if(n!==16)break;i.targetAmount=t.int32();continue}case 3:{if(n!==24)break;i.mode=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return $s.fromPartial(e??{})},fromPartial(e){let r=uT();return r.resource=e.resource??0,r.targetAmount=e.targetAmount??0,r.mode=e.mode??0,r}};function ET(){return{hex:void 0,resources:[],commodities:[],fish:[],isGoldHex:!1,goldResourceCount:0}}E(ET,"createBaseHexProductionProto");var _d={encode(e,r=new or){e.hex!==void 0&&q.encode(e.hex,r.uint32(10).fork()).join();for(let t of e.resources)ne.encode(t,r.uint32(18).fork()).join();for(let t of e.commodities)te.encode(t,r.uint32(26).fork()).join();for(let t of e.fish)xe.encode(t,r.uint32(34).fork()).join();return e.isGoldHex!==!1&&r.uint32(40).bool(e.isGoldHex),e.goldResourceCount!==0&&r.uint32(48).int32(e.goldResourceCount),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=ET();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.hex=q.decode(t,t.uint32());continue}case 2:{if(n!==18)break;i.resources.push(ne.decode(t,t.uint32()));continue}case 3:{if(n!==26)break;i.commodities.push(te.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.fish.push(xe.decode(t,t.uint32()));continue}case 5:{if(n!==40)break;i.isGoldHex=t.bool();continue}case 6:{if(n!==48)break;i.goldResourceCount=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return _d.fromPartial(e??{})},fromPartial(e){let r=ET();return r.hex=e.hex!==void 0&&e.hex!==null?q.fromPartial(e.hex):void 0,r.resources=e.resources?.map(t=>ne.fromPartial(t))||[],r.commodities=e.commodities?.map(t=>te.fromPartial(t))||[],r.fish=e.fish?.map(t=>xe.fromPartial(t))||[],r.isGoldHex=e.isGoldHex??!1,r.goldResourceCount=e.goldResourceCount??0,r}};function lT(){return{player:0,hexProduction:[]}}E(lT,"createBasePlayerProductionProto");var dd={encode(e,r=new or){e.player!==0&&r.uint32(8).int32(e.player);for(let t of e.hexProduction)_d.encode(t,r.uint32(18).fork()).join();return r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=lT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==18)break;i.hexProduction.push(_d.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return dd.fromPartial(e??{})},fromPartial(e){let r=lT();return r.player=e.player??0,r.hexProduction=e.hexProduction?.map(t=>_d.fromPartial(t))||[],r}};function cT(){return{resource:0,player:0,requested:0,received:0}}E(cT,"createBasePartialDistributionProto");var ud={encode(e,r=new or){return e.resource!==0&&r.uint32(8).int32(e.resource),e.player!==0&&r.uint32(16).int32(e.player),e.requested!==0&&r.uint32(24).int32(e.requested),e.received!==0&&r.uint32(32).int32(e.received),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=cT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.resource=t.int32();continue}case 2:{if(n!==16)break;i.player=t.int32();continue}case 3:{if(n!==24)break;i.requested=t.int32();continue}case 4:{if(n!==32)break;i.received=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ud.fromPartial(e??{})},fromPartial(e){let r=cT();return r.resource=e.resource??0,r.player=e.player??0,r.requested=e.requested??0,r.received=e.received??0,r}};function fT(){return{diceTotal:0,playerProduction:[],blockedResources:[],partialDistributions:[],robberBlockedProduction:[]}}E(fT,"createBaseResourceDistributionProto");var Qs={encode(e,r=new or){e.diceTotal!==0&&r.uint32(8).int32(e.diceTotal);for(let t of e.playerProduction)dd.encode(t,r.uint32(18).fork()).join();r.uint32(26).fork();for(let t of e.blockedResources)r.int32(t);r.join();for(let t of e.partialDistributions)ud.encode(t,r.uint32(34).fork()).join();for(let t of e.robberBlockedProduction)Ed.encode(t,r.uint32(42).fork()).join();return r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=fT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.diceTotal=t.int32();continue}case 2:{if(n!==18)break;i.playerProduction.push(dd.decode(t,t.uint32()));continue}case 3:{if(n===24){i.blockedResources.push(t.int32());continue}if(n===26){let a=t.uint32()+t.pos;for(;t.pos<a;)i.blockedResources.push(t.int32());continue}break}case 4:{if(n!==34)break;i.partialDistributions.push(ud.decode(t,t.uint32()));continue}case 5:{if(n!==42)break;i.robberBlockedProduction.push(Ed.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Qs.fromPartial(e??{})},fromPartial(e){let r=fT();return r.diceTotal=e.diceTotal??0,r.playerProduction=e.playerProduction?.map(t=>dd.fromPartial(t))||[],r.blockedResources=e.blockedResources?.map(t=>t)||[],r.partialDistributions=e.partialDistributions?.map(t=>ud.fromPartial(t))||[],r.robberBlockedProduction=e.robberBlockedProduction?.map(t=>Ed.fromPartial(t))||[],r}};function TT(){return{player:0,count:0}}E(TT,"createBaseRobberBlockedProductionProto");var Ed={encode(e,r=new or){return e.player!==0&&r.uint32(8).int32(e.player),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=TT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Ed.fromPartial(e??{})},fromPartial(e){let r=TT();return r.player=e.player??0,r.count=e.count??0,r}};function NT(){return{player:0,count:0}}E(NT,"createBaseMonopolyResultProto");var vt={encode(e,r=new or){return e.player!==0&&r.uint32(8).int32(e.player),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=NT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.player=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return vt.fromPartial(e??{})},fromPartial(e){let r=NT();return r.player=e.player??0,r.count=e.count??0,r}};function RT(){return{embargoingPlayer:0,embargoedPlayer:0}}E(RT,"createBaseTradeEmbargoProto");var ui={encode(e,r=new or){return e.embargoingPlayer!==0&&r.uint32(8).int32(e.embargoingPlayer),e.embargoedPlayer!==0&&r.uint32(16).int32(e.embargoedPlayer),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=RT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.embargoingPlayer=t.int32();continue}case 2:{if(n!==16)break;i.embargoedPlayer=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ui.fromPartial(e??{})},fromPartial(e){let r=RT();return r.embargoingPlayer=e.embargoingPlayer??0,r.embargoedPlayer=e.embargoedPlayer??0,r}};function AT(){return{offering:[],requesting:[],offeringCommodities:[],requestingCommodities:[],offeringGold:0,requestingGold:0,tradeId:0}}E(AT,"createBaseTradeProposalProto");var Qr={encode(e,r=new or){for(let t of e.offering)ne.encode(t,r.uint32(10).fork()).join();for(let t of e.requesting)ne.encode(t,r.uint32(18).fork()).join();for(let t of e.offeringCommodities)te.encode(t,r.uint32(26).fork()).join();for(let t of e.requestingCommodities)te.encode(t,r.uint32(34).fork()).join();return e.offeringGold!==0&&r.uint32(40).int32(e.offeringGold),e.requestingGold!==0&&r.uint32(48).int32(e.requestingGold),e.tradeId!==0&&r.uint32(56).int32(e.tradeId),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=AT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.offering.push(ne.decode(t,t.uint32()));continue}case 2:{if(n!==18)break;i.requesting.push(ne.decode(t,t.uint32()));continue}case 3:{if(n!==26)break;i.offeringCommodities.push(te.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.requestingCommodities.push(te.decode(t,t.uint32()));continue}case 5:{if(n!==40)break;i.offeringGold=t.int32();continue}case 6:{if(n!==48)break;i.requestingGold=t.int32();continue}case 7:{if(n!==56)break;i.tradeId=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Qr.fromPartial(e??{})},fromPartial(e){let r=AT();return r.offering=e.offering?.map(t=>ne.fromPartial(t))||[],r.requesting=e.requesting?.map(t=>ne.fromPartial(t))||[],r.offeringCommodities=e.offeringCommodities?.map(t=>te.fromPartial(t))||[],r.requestingCommodities=e.requestingCommodities?.map(t=>te.fromPartial(t))||[],r.offeringGold=e.offeringGold??0,r.requestingGold=e.requestingGold??0,r.tradeId=e.tradeId??0,r}};function ST(){return{fromPlayer:0,toPlayer:0,balance:0}}E(ST,"createBaseTradeBalanceEntryProto");var Ei={encode(e,r=new or){return e.fromPlayer!==0&&r.uint32(8).int32(e.fromPlayer),e.toPlayer!==0&&r.uint32(16).int32(e.toPlayer),e.balance!==0&&r.uint32(24).int32(e.balance),r},decode(e,r){let t=e instanceof fe?e:new fe(e),o=r===void 0?t.len:t.pos+r,i=ST();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.fromPlayer=t.int32();continue}case 2:{if(n!==16)break;i.toPlayer=t.int32();continue}case 3:{if(n!==24)break;i.balance=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return Ei.fromPartial(e??{})},fromPartial(e){let r=ST();return r.fromPlayer=e.fromPlayer??0,r.toPlayer=e.toPlayer??0,r.balance=e.balance??0,r}};import{BinaryReader as fd,BinaryWriter as CT}from"@bufbuild/protobuf/wire";function OT(){return{numberLayout:0,portLayout:0,desertPlacement:0,resourceAdjacencyTarget:0,portMatchingTarget:0}}E(OT,"createBaseBoardGenerationOptionsProto");var cd={encode(e,r=new CT){return e.numberLayout!==0&&r.uint32(8).int32(e.numberLayout),e.portLayout!==0&&r.uint32(16).int32(e.portLayout),e.desertPlacement!==0&&r.uint32(24).int32(e.desertPlacement),e.resourceAdjacencyTarget!==0&&r.uint32(32).int32(e.resourceAdjacencyTarget),e.portMatchingTarget!==0&&r.uint32(40).int32(e.portMatchingTarget),r},decode(e,r){let t=e instanceof fd?e:new fd(e),o=r===void 0?t.len:t.pos+r,i=OT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.numberLayout=t.int32();continue}case 2:{if(n!==16)break;i.portLayout=t.int32();continue}case 3:{if(n!==24)break;i.desertPlacement=t.int32();continue}case 4:{if(n!==32)break;i.resourceAdjacencyTarget=t.int32();continue}case 5:{if(n!==40)break;i.portMatchingTarget=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return cd.fromPartial(e??{})},fromPartial(e){let r=OT();return r.numberLayout=e.numberLayout??0,r.portLayout=e.portLayout??0,r.desertPlacement=e.desertPlacement??0,r.resourceAdjacencyTarget=e.resourceAdjacencyTarget??0,r.portMatchingTarget=e.portMatchingTarget??0,r}};function IT(){return{victoryPoints:0,discardLimit:0,seafarers:!1,maxSettlements:0,maxCities:0,maxRoads:0,maxShips:0,seed:0,citiesAndKnights:!1,maxBasicKnights:0,maxStrongKnights:0,maxMightyKnights:0,maxCityWalls:0,resourceCardCount:0,commodityCardCount:0,firstFound:0,secondFound:0,fisherman:!1,robberMode:0,diceMode:0,diceSeed:0,winCondition:0,turnLimit:0,resourceGoal:void 0,balancedDiceBounds:0,timerConfig:void 0,pauseConfig:void 0,ckKnightErrant:!1,ckEasyStart:!1,ckNastyBarbarians:!1,turboMode:!1,devCardSeed:0,stealSeed:0,mapType:0,harbormaster:!1,newIslandSettlementBonus:0,desertsBlockIslands:!1,secondSettler:!1,eventCards:!1,dynamicHexMode:0,robberLockedToBiggestIsland:!1,fogReward:0,fogBonusDuringSetup:!1,foundOnFog:0,fogMode:0,merchantTrains:!1,numberWagons:0,rivers:!1,maxBridges:0,firstSettleMode:0,secondSettleMode:0,restrictFoundingToLargestIsland:!1,mapShuffleMode:0,mapShuffleScope:0,setupPrediction:!1,tradeResponseTimeoutMs:0,noSevens:!1,trolls:!1,numberOfRobbers:0,boardGeneration:void 0,rushMode:!1,rushDiceIntervalSeconds:0,tradeMode:0,revealFogOnGameStart:!1,hideDiceStats:!1,hidePlayedDevCards:!1,disableCounterOffers:!1}}E(IT,"createBaseGameOptionsProto");var li={encode(e,r=new CT){return e.victoryPoints!==0&&r.uint32(8).int32(e.victoryPoints),e.discardLimit!==0&&r.uint32(16).int32(e.discardLimit),e.seafarers!==!1&&r.uint32(24).bool(e.seafarers),e.maxSettlements!==0&&r.uint32(32).int32(e.maxSettlements),e.maxCities!==0&&r.uint32(40).int32(e.maxCities),e.maxRoads!==0&&r.uint32(48).int32(e.maxRoads),e.maxShips!==0&&r.uint32(56).int32(e.maxShips),e.seed!==0&&r.uint32(64).int64(e.seed),e.citiesAndKnights!==!1&&r.uint32(72).bool(e.citiesAndKnights),e.maxBasicKnights!==0&&r.uint32(80).int32(e.maxBasicKnights),e.maxStrongKnights!==0&&r.uint32(88).int32(e.maxStrongKnights),e.maxMightyKnights!==0&&r.uint32(96).int32(e.maxMightyKnights),e.maxCityWalls!==0&&r.uint32(104).int32(e.maxCityWalls),e.resourceCardCount!==0&&r.uint32(112).int32(e.resourceCardCount),e.commodityCardCount!==0&&r.uint32(120).int32(e.commodityCardCount),e.firstFound!==0&&r.uint32(128).int32(e.firstFound),e.secondFound!==0&&r.uint32(136).int32(e.secondFound),e.fisherman!==!1&&r.uint32(144).bool(e.fisherman),e.robberMode!==0&&r.uint32(152).int32(e.robberMode),e.diceMode!==0&&r.uint32(160).int32(e.diceMode),e.diceSeed!==0&&r.uint32(168).int64(e.diceSeed),e.winCondition!==0&&r.uint32(176).int32(e.winCondition),e.turnLimit!==0&&r.uint32(184).int32(e.turnLimit),e.resourceGoal!==void 0&&$s.encode(e.resourceGoal,r.uint32(194).fork()).join(),e.balancedDiceBounds!==0&&r.uint32(205).float(e.balancedDiceBounds),e.timerConfig!==void 0&&xs.encode(e.timerConfig,r.uint32(210).fork()).join(),e.pauseConfig!==void 0&&ws.encode(e.pauseConfig,r.uint32(218).fork()).join(),e.ckKnightErrant!==!1&&r.uint32(224).bool(e.ckKnightErrant),e.ckEasyStart!==!1&&r.uint32(232).bool(e.ckEasyStart),e.ckNastyBarbarians!==!1&&r.uint32(240).bool(e.ckNastyBarbarians),e.turboMode!==!1&&r.uint32(248).bool(e.turboMode),e.devCardSeed!==0&&r.uint32(256).int64(e.devCardSeed),e.stealSeed!==0&&r.uint32(264).int64(e.stealSeed),e.mapType!==0&&r.uint32(272).int32(e.mapType),e.harbormaster!==!1&&r.uint32(280).bool(e.harbormaster),e.newIslandSettlementBonus!==0&&r.uint32(288).int32(e.newIslandSettlementBonus),e.desertsBlockIslands!==!1&&r.uint32(296).bool(e.desertsBlockIslands),e.secondSettler!==!1&&r.uint32(304).bool(e.secondSettler),e.eventCards!==!1&&r.uint32(312).bool(e.eventCards),e.dynamicHexMode!==0&&r.uint32(320).int32(e.dynamicHexMode),e.robberLockedToBiggestIsland!==!1&&r.uint32(328).bool(e.robberLockedToBiggestIsland),e.fogReward!==0&&r.uint32(336).int32(e.fogReward),e.fogBonusDuringSetup!==!1&&r.uint32(344).bool(e.fogBonusDuringSetup),e.foundOnFog!==0&&r.uint32(352).int32(e.foundOnFog),e.fogMode!==0&&r.uint32(360).int32(e.fogMode),e.merchantTrains!==!1&&r.uint32(368).bool(e.merchantTrains),e.numberWagons!==0&&r.uint32(376).int32(e.numberWagons),e.rivers!==!1&&r.uint32(384).bool(e.rivers),e.maxBridges!==0&&r.uint32(392).int32(e.maxBridges),e.firstSettleMode!==0&&r.uint32(400).int32(e.firstSettleMode),e.secondSettleMode!==0&&r.uint32(408).int32(e.secondSettleMode),e.restrictFoundingToLargestIsland!==!1&&r.uint32(416).bool(e.restrictFoundingToLargestIsland),e.mapShuffleMode!==0&&r.uint32(424).int32(e.mapShuffleMode),e.mapShuffleScope!==0&&r.uint32(432).int32(e.mapShuffleScope),e.setupPrediction!==!1&&r.uint32(440).bool(e.setupPrediction),e.tradeResponseTimeoutMs!==0&&r.uint32(448).int32(e.tradeResponseTimeoutMs),e.noSevens!==!1&&r.uint32(456).bool(e.noSevens),e.trolls!==!1&&r.uint32(464).bool(e.trolls),e.numberOfRobbers!==0&&r.uint32(472).int32(e.numberOfRobbers),e.boardGeneration!==void 0&&cd.encode(e.boardGeneration,r.uint32(482).fork()).join(),e.rushMode!==!1&&r.uint32(488).bool(e.rushMode),e.rushDiceIntervalSeconds!==0&&r.uint32(496).int32(e.rushDiceIntervalSeconds),e.tradeMode!==0&&r.uint32(504).int32(e.tradeMode),e.revealFogOnGameStart!==!1&&r.uint32(512).bool(e.revealFogOnGameStart),e.hideDiceStats!==!1&&r.uint32(520).bool(e.hideDiceStats),e.hidePlayedDevCards!==!1&&r.uint32(528).bool(e.hidePlayedDevCards),e.disableCounterOffers!==!1&&r.uint32(536).bool(e.disableCounterOffers),r},decode(e,r){let t=e instanceof fd?e:new fd(e),o=r===void 0?t.len:t.pos+r,i=IT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.victoryPoints=t.int32();continue}case 2:{if(n!==16)break;i.discardLimit=t.int32();continue}case 3:{if(n!==24)break;i.seafarers=t.bool();continue}case 4:{if(n!==32)break;i.maxSettlements=t.int32();continue}case 5:{if(n!==40)break;i.maxCities=t.int32();continue}case 6:{if(n!==48)break;i.maxRoads=t.int32();continue}case 7:{if(n!==56)break;i.maxShips=t.int32();continue}case 8:{if(n!==64)break;i.seed=ld(t.int64());continue}case 9:{if(n!==72)break;i.citiesAndKnights=t.bool();continue}case 10:{if(n!==80)break;i.maxBasicKnights=t.int32();continue}case 11:{if(n!==88)break;i.maxStrongKnights=t.int32();continue}case 12:{if(n!==96)break;i.maxMightyKnights=t.int32();continue}case 13:{if(n!==104)break;i.maxCityWalls=t.int32();continue}case 14:{if(n!==112)break;i.resourceCardCount=t.int32();continue}case 15:{if(n!==120)break;i.commodityCardCount=t.int32();continue}case 16:{if(n!==128)break;i.firstFound=t.int32();continue}case 17:{if(n!==136)break;i.secondFound=t.int32();continue}case 18:{if(n!==144)break;i.fisherman=t.bool();continue}case 19:{if(n!==152)break;i.robberMode=t.int32();continue}case 20:{if(n!==160)break;i.diceMode=t.int32();continue}case 21:{if(n!==168)break;i.diceSeed=ld(t.int64());continue}case 22:{if(n!==176)break;i.winCondition=t.int32();continue}case 23:{if(n!==184)break;i.turnLimit=t.int32();continue}case 24:{if(n!==194)break;i.resourceGoal=$s.decode(t,t.uint32());continue}case 25:{if(n!==205)break;i.balancedDiceBounds=t.float();continue}case 26:{if(n!==210)break;i.timerConfig=xs.decode(t,t.uint32());continue}case 27:{if(n!==218)break;i.pauseConfig=ws.decode(t,t.uint32());continue}case 28:{if(n!==224)break;i.ckKnightErrant=t.bool();continue}case 29:{if(n!==232)break;i.ckEasyStart=t.bool();continue}case 30:{if(n!==240)break;i.ckNastyBarbarians=t.bool();continue}case 31:{if(n!==248)break;i.turboMode=t.bool();continue}case 32:{if(n!==256)break;i.devCardSeed=ld(t.int64());continue}case 33:{if(n!==264)break;i.stealSeed=ld(t.int64());continue}case 34:{if(n!==272)break;i.mapType=t.int32();continue}case 35:{if(n!==280)break;i.harbormaster=t.bool();continue}case 36:{if(n!==288)break;i.newIslandSettlementBonus=t.int32();continue}case 37:{if(n!==296)break;i.desertsBlockIslands=t.bool();continue}case 38:{if(n!==304)break;i.secondSettler=t.bool();continue}case 39:{if(n!==312)break;i.eventCards=t.bool();continue}case 40:{if(n!==320)break;i.dynamicHexMode=t.int32();continue}case 41:{if(n!==328)break;i.robberLockedToBiggestIsland=t.bool();continue}case 42:{if(n!==336)break;i.fogReward=t.int32();continue}case 43:{if(n!==344)break;i.fogBonusDuringSetup=t.bool();continue}case 44:{if(n!==352)break;i.foundOnFog=t.int32();continue}case 45:{if(n!==360)break;i.fogMode=t.int32();continue}case 46:{if(n!==368)break;i.merchantTrains=t.bool();continue}case 47:{if(n!==376)break;i.numberWagons=t.int32();continue}case 48:{if(n!==384)break;i.rivers=t.bool();continue}case 49:{if(n!==392)break;i.maxBridges=t.int32();continue}case 50:{if(n!==400)break;i.firstSettleMode=t.int32();continue}case 51:{if(n!==408)break;i.secondSettleMode=t.int32();continue}case 52:{if(n!==416)break;i.restrictFoundingToLargestIsland=t.bool();continue}case 53:{if(n!==424)break;i.mapShuffleMode=t.int32();continue}case 54:{if(n!==432)break;i.mapShuffleScope=t.int32();continue}case 55:{if(n!==440)break;i.setupPrediction=t.bool();continue}case 56:{if(n!==448)break;i.tradeResponseTimeoutMs=t.int32();continue}case 57:{if(n!==456)break;i.noSevens=t.bool();continue}case 58:{if(n!==464)break;i.trolls=t.bool();continue}case 59:{if(n!==472)break;i.numberOfRobbers=t.int32();continue}case 60:{if(n!==482)break;i.boardGeneration=cd.decode(t,t.uint32());continue}case 61:{if(n!==488)break;i.rushMode=t.bool();continue}case 62:{if(n!==496)break;i.rushDiceIntervalSeconds=t.int32();continue}case 63:{if(n!==504)break;i.tradeMode=t.int32();continue}case 64:{if(n!==512)break;i.revealFogOnGameStart=t.bool();continue}case 65:{if(n!==520)break;i.hideDiceStats=t.bool();continue}case 66:{if(n!==528)break;i.hidePlayedDevCards=t.bool();continue}case 67:{if(n!==536)break;i.disableCounterOffers=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return li.fromPartial(e??{})},fromPartial(e){let r=IT();return r.victoryPoints=e.victoryPoints??0,r.discardLimit=e.discardLimit??0,r.seafarers=e.seafarers??!1,r.maxSettlements=e.maxSettlements??0,r.maxCities=e.maxCities??0,r.maxRoads=e.maxRoads??0,r.maxShips=e.maxShips??0,r.seed=e.seed??0,r.citiesAndKnights=e.citiesAndKnights??!1,r.maxBasicKnights=e.maxBasicKnights??0,r.maxStrongKnights=e.maxStrongKnights??0,r.maxMightyKnights=e.maxMightyKnights??0,r.maxCityWalls=e.maxCityWalls??0,r.resourceCardCount=e.resourceCardCount??0,r.commodityCardCount=e.commodityCardCount??0,r.firstFound=e.firstFound??0,r.secondFound=e.secondFound??0,r.fisherman=e.fisherman??!1,r.robberMode=e.robberMode??0,r.diceMode=e.diceMode??0,r.diceSeed=e.diceSeed??0,r.winCondition=e.winCondition??0,r.turnLimit=e.turnLimit??0,r.resourceGoal=e.resourceGoal!==void 0&&e.resourceGoal!==null?$s.fromPartial(e.resourceGoal):void 0,r.balancedDiceBounds=e.balancedDiceBounds??0,r.timerConfig=e.timerConfig!==void 0&&e.timerConfig!==null?xs.fromPartial(e.timerConfig):void 0,r.pauseConfig=e.pauseConfig!==void 0&&e.pauseConfig!==null?ws.fromPartial(e.pauseConfig):void 0,r.ckKnightErrant=e.ckKnightErrant??!1,r.ckEasyStart=e.ckEasyStart??!1,r.ckNastyBarbarians=e.ckNastyBarbarians??!1,r.turboMode=e.turboMode??!1,r.devCardSeed=e.devCardSeed??0,r.stealSeed=e.stealSeed??0,r.mapType=e.mapType??0,r.harbormaster=e.harbormaster??!1,r.newIslandSettlementBonus=e.newIslandSettlementBonus??0,r.desertsBlockIslands=e.desertsBlockIslands??!1,r.secondSettler=e.secondSettler??!1,r.eventCards=e.eventCards??!1,r.dynamicHexMode=e.dynamicHexMode??0,r.robberLockedToBiggestIsland=e.robberLockedToBiggestIsland??!1,r.fogReward=e.fogReward??0,r.fogBonusDuringSetup=e.fogBonusDuringSetup??!1,r.foundOnFog=e.foundOnFog??0,r.fogMode=e.fogMode??0,r.merchantTrains=e.merchantTrains??!1,r.numberWagons=e.numberWagons??0,r.rivers=e.rivers??!1,r.maxBridges=e.maxBridges??0,r.firstSettleMode=e.firstSettleMode??0,r.secondSettleMode=e.secondSettleMode??0,r.restrictFoundingToLargestIsland=e.restrictFoundingToLargestIsland??!1,r.mapShuffleMode=e.mapShuffleMode??0,r.mapShuffleScope=e.mapShuffleScope??0,r.setupPrediction=e.setupPrediction??!1,r.tradeResponseTimeoutMs=e.tradeResponseTimeoutMs??0,r.noSevens=e.noSevens??!1,r.trolls=e.trolls??!1,r.numberOfRobbers=e.numberOfRobbers??0,r.boardGeneration=e.boardGeneration!==void 0&&e.boardGeneration!==null?cd.fromPartial(e.boardGeneration):void 0,r.rushMode=e.rushMode??!1,r.rushDiceIntervalSeconds=e.rushDiceIntervalSeconds??0,r.tradeMode=e.tradeMode??0,r.revealFogOnGameStart=e.revealFogOnGameStart??!1,r.hideDiceStats=e.hideDiceStats??!1,r.hidePlayedDevCards=e.hidePlayedDevCards??!1,r.disableCounterOffers=e.disableCounterOffers??!1,r}};function ld(e){let r=globalThis.Number(e.toString());if(r>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(r<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return r}E(ld,"longToNumber");import{BinaryReader as Td,BinaryWriter as hT}from"@bufbuild/protobuf/wire";function PT(){return{board:void 0,resourceDeck:[],devCardDeck:[],playerStates:[],currentPlayer:0,turnOrder:[],turnNumber:0,playerPublicStates:[],dice:void 0,activeTrades:[],pendingDiceRoll:!1,pendingDiscards:[],pendingWeddingCards:[],pendingCommercialHarborExchanges:[],pendingRobberOrPiratePlacement:!1,playedDevCardThisTurn:!1,pendingFreeResources:[],pendingFreeStructures:[],pendingRobberStealLocation:void 0,pendingPirateStealLocation:void 0,movedShipThisTurn:!1,shipsBuiltThisTurn:[],largestArmyPlayer:0,longestRoadPlayer:0,harbormasterPlayer:0,isSetupPhase:!1,tradesProposedThisTurn:0,tradesExecutedThisTurn:0,winner:0,options:void 0,eventDice:void 0,scienceProgressDeck:[],politicsProgressDeck:[],tradeProgressDeck:[],knightActivatedThisTurn:!1,commodityBank:[],fishBank:[],oldBoot:0,fogTerrainBank:[],fogNumberBank:[],pendingDefenderSelection:[],pendingCityPillage:0,pendingCommercialHarbor:!1,pendingAlchemist:0,pendingProgressCardDraw:[],progressCardsInPlay:[],merchantFleetResource:0,masterMerchantTarget:0,pendingSpyTarget:0,smithFreePromotionsRemaining:0,pendingKnights:[],paused:!1,pendingResourceResolution:!1,diceRollCount:0,diceDistribution:[],sevensPerPlayer:[],timerState:void 0,pauseState:void 0,pendingKnightCommitment:void 0,pendingSecondTurboRoll:!1,isSecondSettlerPhase:!1,secondSettlerPlayer:0,devCardDrawCount:0,stealCount:0,pendingPortPlacement:void 0,eventCardDeck:[],removedEventCards:[],pendingEarthquake:[],pendingGoodNeighbors:[],pendingHelpfulNeighbors:[],pendingEventCardSteal:0,pendingBishopSteal:0,pendingWagonVoting:void 0,wagonsExhausted:!1,pendingDeserter:void 0,goldSpentThisTurn:{},stateVersion:0,mapVersion:0,buildingVersion:0,merchantFleetCommodity:0,pendingMetropolisPlacement:void 0,tradeEmbargoes:[],tradeBalance:[],rushPlayedDevCard:[],rushNextDiceRollAt:0,rushDiceVotes:[],rushRobberPlayer:0,pendingProgressCardDiscard:[],pendingCityPillagePlayers:[],discardsWithoutRobber:!1,nextTradeId:0,rejectedTradeOffers:[]}}E(PT,"createBaseGameProto");var js={encode(e,r=new hT){e.board!==void 0&&$n.encode(e.board,r.uint32(10).fork()).join();for(let t of e.resourceDeck)ne.encode(t,r.uint32(18).fork()).join();for(let t of e.devCardDeck)Er.encode(t,r.uint32(26).fork()).join();for(let t of e.playerStates)jn.encode(t,r.uint32(34).fork()).join();e.currentPlayer!==0&&r.uint32(64).int32(e.currentPlayer),r.uint32(98).fork();for(let t of e.turnOrder)r.int32(t);r.join(),e.turnNumber!==0&&r.uint32(104).int32(e.turnNumber);for(let t of e.playerPublicStates)Qn.encode(t,r.uint32(114).fork()).join();e.dice!==void 0&&Dt.encode(e.dice,r.uint32(122).fork()).join();for(let t of e.activeTrades)ei.encode(t,r.uint32(130).fork()).join();e.pendingDiceRoll!==!1&&r.uint32(40).bool(e.pendingDiceRoll);for(let t of e.pendingDiscards)mt.encode(t,r.uint32(50).fork()).join();for(let t of e.pendingWeddingCards)ii.encode(t,r.uint32(226).fork()).join();for(let t of e.pendingCommercialHarborExchanges)oi.encode(t,r.uint32(418).fork()).join();e.pendingRobberOrPiratePlacement!==!1&&r.uint32(56).bool(e.pendingRobberOrPiratePlacement),e.playedDevCardThisTurn!==!1&&r.uint32(72).bool(e.playedDevCardThisTurn);for(let t of e.pendingFreeResources)ti.encode(t,r.uint32(82).fork()).join();for(let t of e.pendingFreeStructures)ni.encode(t,r.uint32(90).fork()).join();e.pendingRobberStealLocation!==void 0&&q.encode(e.pendingRobberStealLocation,r.uint32(234).fork()).join(),e.pendingPirateStealLocation!==void 0&&q.encode(e.pendingPirateStealLocation,r.uint32(242).fork()).join(),e.movedShipThisTurn!==!1&&r.uint32(200).bool(e.movedShipThisTurn);for(let t of e.shipsBuiltThisTurn)Ie.encode(t,r.uint32(730).fork()).join();e.largestArmyPlayer!==0&&r.uint32(136).int32(e.largestArmyPlayer),e.longestRoadPlayer!==0&&r.uint32(144).int32(e.longestRoadPlayer),e.harbormasterPlayer!==0&&r.uint32(560).int32(e.harbormasterPlayer),e.isSetupPhase!==!1&&r.uint32(176).bool(e.isSetupPhase),e.tradesProposedThisTurn!==0&&r.uint32(424).int32(e.tradesProposedThisTurn),e.tradesExecutedThisTurn!==0&&r.uint32(760).int32(e.tradesExecutedThisTurn),e.winner!==0&&r.uint32(464).int32(e.winner),e.options!==void 0&&li.encode(e.options,r.uint32(218).fork()).join(),e.eventDice!==void 0&&zs.encode(e.eventDice,r.uint32(250).fork()).join(),r.uint32(258).fork();for(let t of e.scienceProgressDeck)r.int32(t);r.join(),r.uint32(266).fork();for(let t of e.politicsProgressDeck)r.int32(t);r.join(),r.uint32(274).fork();for(let t of e.tradeProgressDeck)r.int32(t);r.join(),e.knightActivatedThisTurn!==!1&&r.uint32(280).bool(e.knightActivatedThisTurn);for(let t of e.commodityBank)te.encode(t,r.uint32(290).fork()).join();for(let t of e.fishBank)xe.encode(t,r.uint32(434).fork()).join();e.oldBoot!==0&&r.uint32(440).int32(e.oldBoot),r.uint32(450).fork();for(let t of e.fogTerrainBank)r.int32(t);r.join(),r.uint32(458).fork();for(let t of e.fogNumberBank)r.int32(t);r.join(),r.uint32(298).fork();for(let t of e.pendingDefenderSelection)r.int32(t);r.join(),e.pendingCityPillage!==0&&r.uint32(304).int32(e.pendingCityPillage),e.pendingCommercialHarbor!==!1&&r.uint32(312).bool(e.pendingCommercialHarbor),e.pendingAlchemist!==0&&r.uint32(320).int32(e.pendingAlchemist);for(let t of e.pendingProgressCardDraw)dr.encode(t,r.uint32(330).fork()).join();r.uint32(338).fork();for(let t of e.progressCardsInPlay)r.int32(t);r.join(),e.merchantFleetResource!==0&&r.uint32(344).int32(e.merchantFleetResource),e.masterMerchantTarget!==0&&r.uint32(352).int32(e.masterMerchantTarget),e.pendingSpyTarget!==0&&r.uint32(384).int32(e.pendingSpyTarget),e.smithFreePromotionsRemaining!==0&&r.uint32(368).int32(e.smithFreePromotionsRemaining);for(let t of e.pendingKnights)ai.encode(t,r.uint32(362).fork()).join();e.paused!==!1&&r.uint32(472).bool(e.paused),e.pendingResourceResolution!==!1&&r.uint32(480).bool(e.pendingResourceResolution),e.diceRollCount!==0&&r.uint32(488).int32(e.diceRollCount);for(let t of e.diceDistribution)Ks.encode(t,r.uint32(498).fork()).join();for(let t of e.sevensPerPlayer)Ws.encode(t,r.uint32(506).fork()).join();e.timerState!==void 0&&Vs.encode(e.timerState,r.uint32(514).fork()).join(),e.pauseState!==void 0&&Hs.encode(e.pauseState,r.uint32(522).fork()).join(),e.pendingKnightCommitment!==void 0&&si.encode(e.pendingKnightCommitment,r.uint32(530).fork()).join(),e.pendingSecondTurboRoll!==!1&&r.uint32(536).bool(e.pendingSecondTurboRoll),e.isSecondSettlerPhase!==!1&&r.uint32(584).bool(e.isSecondSettlerPhase),e.secondSettlerPlayer!==0&&r.uint32(592).int32(e.secondSettlerPlayer),e.devCardDrawCount!==0&&r.uint32(544).int32(e.devCardDrawCount),e.stealCount!==0&&r.uint32(552).int32(e.stealCount),e.pendingPortPlacement!==void 0&&Js.encode(e.pendingPortPlacement,r.uint32(570).fork()).join();for(let t of e.eventCardDeck)Rr.encode(t,r.uint32(602).fork()).join();for(let t of e.removedEventCards)Rr.encode(t,r.uint32(610).fork()).join();r.uint32(618).fork();for(let t of e.pendingEarthquake)r.int32(t);r.join(),r.uint32(634).fork();for(let t of e.pendingGoodNeighbors)r.int32(t);r.join(),r.uint32(642).fork();for(let t of e.pendingHelpfulNeighbors)r.int32(t);r.join(),e.pendingEventCardSteal!==0&&r.uint32(648).int32(e.pendingEventCardSteal),e.pendingBishopSteal!==0&&r.uint32(656).int32(e.pendingBishopSteal),e.pendingWagonVoting!==void 0&&qs.encode(e.pendingWagonVoting,r.uint32(666).fork()).join(),e.wagonsExhausted!==!1&&r.uint32(672).bool(e.wagonsExhausted),e.pendingDeserter!==void 0&&_i.encode(e.pendingDeserter,r.uint32(738).fork()).join(),globalThis.Object.entries(e.goldSpentThisTurn).forEach(([t,o])=>{ju.encode({key:t,value:o},r.uint32(698).fork()).join()}),e.stateVersion!==0&&r.uint32(704).int32(e.stateVersion),e.mapVersion!==0&&r.uint32(712).int32(e.mapVersion),e.buildingVersion!==0&&r.uint32(720).int32(e.buildingVersion),e.merchantFleetCommodity!==0&&r.uint32(744).int32(e.merchantFleetCommodity),e.pendingMetropolisPlacement!==void 0&&di.encode(e.pendingMetropolisPlacement,r.uint32(754).fork()).join();for(let t of e.tradeEmbargoes)ui.encode(t,r.uint32(770).fork()).join();for(let t of e.tradeBalance)Ei.encode(t,r.uint32(778).fork()).join();r.uint32(794).fork();for(let t of e.rushPlayedDevCard)r.int32(t);r.join(),e.rushNextDiceRollAt!==0&&r.uint32(800).int64(e.rushNextDiceRollAt),r.uint32(810).fork();for(let t of e.rushDiceVotes)r.int32(t);r.join(),e.rushRobberPlayer!==0&&r.uint32(816).int32(e.rushRobberPlayer);for(let t of e.pendingProgressCardDiscard)mt.encode(t,r.uint32(826).fork()).join();r.uint32(834).fork();for(let t of e.pendingCityPillagePlayers)r.int32(t);r.join(),e.discardsWithoutRobber!==!1&&r.uint32(840).bool(e.discardsWithoutRobber),e.nextTradeId!==0&&r.uint32(848).int32(e.nextTradeId);for(let t of e.rejectedTradeOffers)ri.encode(t,r.uint32(858).fork()).join();return r},decode(e,r){let t=e instanceof Td?e:new Td(e),o=r===void 0?t.len:t.pos+r,i=PT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.board=$n.decode(t,t.uint32());continue}case 2:{if(n!==18)break;i.resourceDeck.push(ne.decode(t,t.uint32()));continue}case 3:{if(n!==26)break;i.devCardDeck.push(Er.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.playerStates.push(jn.decode(t,t.uint32()));continue}case 8:{if(n!==64)break;i.currentPlayer=t.int32();continue}case 12:{if(n===96){i.turnOrder.push(t.int32());continue}if(n===98){let a=t.uint32()+t.pos;for(;t.pos<a;)i.turnOrder.push(t.int32());continue}break}case 13:{if(n!==104)break;i.turnNumber=t.int32();continue}case 14:{if(n!==114)break;i.playerPublicStates.push(Qn.decode(t,t.uint32()));continue}case 15:{if(n!==122)break;i.dice=Dt.decode(t,t.uint32());continue}case 16:{if(n!==130)break;i.activeTrades.push(ei.decode(t,t.uint32()));continue}case 5:{if(n!==40)break;i.pendingDiceRoll=t.bool();continue}case 6:{if(n!==50)break;i.pendingDiscards.push(mt.decode(t,t.uint32()));continue}case 28:{if(n!==226)break;i.pendingWeddingCards.push(ii.decode(t,t.uint32()));continue}case 52:{if(n!==418)break;i.pendingCommercialHarborExchanges.push(oi.decode(t,t.uint32()));continue}case 7:{if(n!==56)break;i.pendingRobberOrPiratePlacement=t.bool();continue}case 9:{if(n!==72)break;i.playedDevCardThisTurn=t.bool();continue}case 10:{if(n!==82)break;i.pendingFreeResources.push(ti.decode(t,t.uint32()));continue}case 11:{if(n!==90)break;i.pendingFreeStructures.push(ni.decode(t,t.uint32()));continue}case 29:{if(n!==234)break;i.pendingRobberStealLocation=q.decode(t,t.uint32());continue}case 30:{if(n!==242)break;i.pendingPirateStealLocation=q.decode(t,t.uint32());continue}case 25:{if(n!==200)break;i.movedShipThisTurn=t.bool();continue}case 91:{if(n!==730)break;i.shipsBuiltThisTurn.push(Ie.decode(t,t.uint32()));continue}case 17:{if(n!==136)break;i.largestArmyPlayer=t.int32();continue}case 18:{if(n!==144)break;i.longestRoadPlayer=t.int32();continue}case 70:{if(n!==560)break;i.harbormasterPlayer=t.int32();continue}case 22:{if(n!==176)break;i.isSetupPhase=t.bool();continue}case 53:{if(n!==424)break;i.tradesProposedThisTurn=t.int32();continue}case 95:{if(n!==760)break;i.tradesExecutedThisTurn=t.int32();continue}case 58:{if(n!==464)break;i.winner=t.int32();continue}case 27:{if(n!==218)break;i.options=li.decode(t,t.uint32());continue}case 31:{if(n!==250)break;i.eventDice=zs.decode(t,t.uint32());continue}case 32:{if(n===256){i.scienceProgressDeck.push(t.int32());continue}if(n===258){let a=t.uint32()+t.pos;for(;t.pos<a;)i.scienceProgressDeck.push(t.int32());continue}break}case 33:{if(n===264){i.politicsProgressDeck.push(t.int32());continue}if(n===266){let a=t.uint32()+t.pos;for(;t.pos<a;)i.politicsProgressDeck.push(t.int32());continue}break}case 34:{if(n===272){i.tradeProgressDeck.push(t.int32());continue}if(n===274){let a=t.uint32()+t.pos;for(;t.pos<a;)i.tradeProgressDeck.push(t.int32());continue}break}case 35:{if(n!==280)break;i.knightActivatedThisTurn=t.bool();continue}case 36:{if(n!==290)break;i.commodityBank.push(te.decode(t,t.uint32()));continue}case 54:{if(n!==434)break;i.fishBank.push(xe.decode(t,t.uint32()));continue}case 55:{if(n!==440)break;i.oldBoot=t.int32();continue}case 56:{if(n===448){i.fogTerrainBank.push(t.int32());continue}if(n===450){let a=t.uint32()+t.pos;for(;t.pos<a;)i.fogTerrainBank.push(t.int32());continue}break}case 57:{if(n===456){i.fogNumberBank.push(t.int32());continue}if(n===458){let a=t.uint32()+t.pos;for(;t.pos<a;)i.fogNumberBank.push(t.int32());continue}break}case 37:{if(n===296){i.pendingDefenderSelection.push(t.int32());continue}if(n===298){let a=t.uint32()+t.pos;for(;t.pos<a;)i.pendingDefenderSelection.push(t.int32());continue}break}case 38:{if(n!==304)break;i.pendingCityPillage=t.int32();continue}case 39:{if(n!==312)break;i.pendingCommercialHarbor=t.bool();continue}case 40:{if(n!==320)break;i.pendingAlchemist=t.int32();continue}case 41:{if(n!==330)break;i.pendingProgressCardDraw.push(dr.decode(t,t.uint32()));continue}case 42:{if(n===336){i.progressCardsInPlay.push(t.int32());continue}if(n===338){let a=t.uint32()+t.pos;for(;t.pos<a;)i.progressCardsInPlay.push(t.int32());continue}break}case 43:{if(n!==344)break;i.merchantFleetResource=t.int32();continue}case 44:{if(n!==352)break;i.masterMerchantTarget=t.int32();continue}case 48:{if(n!==384)break;i.pendingSpyTarget=t.int32();continue}case 46:{if(n!==368)break;i.smithFreePromotionsRemaining=t.int32();continue}case 45:{if(n!==362)break;i.pendingKnights.push(ai.decode(t,t.uint32()));continue}case 59:{if(n!==472)break;i.paused=t.bool();continue}case 60:{if(n!==480)break;i.pendingResourceResolution=t.bool();continue}case 61:{if(n!==488)break;i.diceRollCount=t.int32();continue}case 62:{if(n!==498)break;i.diceDistribution.push(Ks.decode(t,t.uint32()));continue}case 63:{if(n!==506)break;i.sevensPerPlayer.push(Ws.decode(t,t.uint32()));continue}case 64:{if(n!==514)break;i.timerState=Vs.decode(t,t.uint32());continue}case 65:{if(n!==522)break;i.pauseState=Hs.decode(t,t.uint32());continue}case 66:{if(n!==530)break;i.pendingKnightCommitment=si.decode(t,t.uint32());continue}case 67:{if(n!==536)break;i.pendingSecondTurboRoll=t.bool();continue}case 73:{if(n!==584)break;i.isSecondSettlerPhase=t.bool();continue}case 74:{if(n!==592)break;i.secondSettlerPlayer=t.int32();continue}case 68:{if(n!==544)break;i.devCardDrawCount=t.int32();continue}case 69:{if(n!==552)break;i.stealCount=t.int32();continue}case 71:{if(n!==570)break;i.pendingPortPlacement=Js.decode(t,t.uint32());continue}case 75:{if(n!==602)break;i.eventCardDeck.push(Rr.decode(t,t.uint32()));continue}case 76:{if(n!==610)break;i.removedEventCards.push(Rr.decode(t,t.uint32()));continue}case 77:{if(n===616){i.pendingEarthquake.push(t.int32());continue}if(n===618){let a=t.uint32()+t.pos;for(;t.pos<a;)i.pendingEarthquake.push(t.int32());continue}break}case 79:{if(n===632){i.pendingGoodNeighbors.push(t.int32());continue}if(n===634){let a=t.uint32()+t.pos;for(;t.pos<a;)i.pendingGoodNeighbors.push(t.int32());continue}break}case 80:{if(n===640){i.pendingHelpfulNeighbors.push(t.int32());continue}if(n===642){let a=t.uint32()+t.pos;for(;t.pos<a;)i.pendingHelpfulNeighbors.push(t.int32());continue}break}case 81:{if(n!==648)break;i.pendingEventCardSteal=t.int32();continue}case 82:{if(n!==656)break;i.pendingBishopSteal=t.int32();continue}case 83:{if(n!==666)break;i.pendingWagonVoting=qs.decode(t,t.uint32());continue}case 84:{if(n!==672)break;i.wagonsExhausted=t.bool();continue}case 92:{if(n!==738)break;i.pendingDeserter=_i.decode(t,t.uint32());continue}case 87:{if(n!==698)break;let a=ju.decode(t,t.uint32());a.value!==void 0&&(i.goldSpentThisTurn[a.key]=a.value);continue}case 88:{if(n!==704)break;i.stateVersion=t.int32();continue}case 89:{if(n!==712)break;i.mapVersion=t.int32();continue}case 90:{if(n!==720)break;i.buildingVersion=t.int32();continue}case 93:{if(n!==744)break;i.merchantFleetCommodity=t.int32();continue}case 94:{if(n!==754)break;i.pendingMetropolisPlacement=di.decode(t,t.uint32());continue}case 96:{if(n!==770)break;i.tradeEmbargoes.push(ui.decode(t,t.uint32()));continue}case 97:{if(n!==778)break;i.tradeBalance.push(Ei.decode(t,t.uint32()));continue}case 99:{if(n===792){i.rushPlayedDevCard.push(t.int32());continue}if(n===794){let a=t.uint32()+t.pos;for(;t.pos<a;)i.rushPlayedDevCard.push(t.int32());continue}break}case 100:{if(n!==800)break;i.rushNextDiceRollAt=aD(t.int64());continue}case 101:{if(n===808){i.rushDiceVotes.push(t.int32());continue}if(n===810){let a=t.uint32()+t.pos;for(;t.pos<a;)i.rushDiceVotes.push(t.int32());continue}break}case 102:{if(n!==816)break;i.rushRobberPlayer=t.int32();continue}case 103:{if(n!==826)break;i.pendingProgressCardDiscard.push(mt.decode(t,t.uint32()));continue}case 104:{if(n===832){i.pendingCityPillagePlayers.push(t.int32());continue}if(n===834){let a=t.uint32()+t.pos;for(;t.pos<a;)i.pendingCityPillagePlayers.push(t.int32());continue}break}case 105:{if(n!==840)break;i.discardsWithoutRobber=t.bool();continue}case 106:{if(n!==848)break;i.nextTradeId=t.int32();continue}case 107:{if(n!==858)break;i.rejectedTradeOffers.push(ri.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return js.fromPartial(e??{})},fromPartial(e){let r=PT();return r.board=e.board!==void 0&&e.board!==null?$n.fromPartial(e.board):void 0,r.resourceDeck=e.resourceDeck?.map(t=>ne.fromPartial(t))||[],r.devCardDeck=e.devCardDeck?.map(t=>Er.fromPartial(t))||[],r.playerStates=e.playerStates?.map(t=>jn.fromPartial(t))||[],r.currentPlayer=e.currentPlayer??0,r.turnOrder=e.turnOrder?.map(t=>t)||[],r.turnNumber=e.turnNumber??0,r.playerPublicStates=e.playerPublicStates?.map(t=>Qn.fromPartial(t))||[],r.dice=e.dice!==void 0&&e.dice!==null?Dt.fromPartial(e.dice):void 0,r.activeTrades=e.activeTrades?.map(t=>ei.fromPartial(t))||[],r.pendingDiceRoll=e.pendingDiceRoll??!1,r.pendingDiscards=e.pendingDiscards?.map(t=>mt.fromPartial(t))||[],r.pendingWeddingCards=e.pendingWeddingCards?.map(t=>ii.fromPartial(t))||[],r.pendingCommercialHarborExchanges=e.pendingCommercialHarborExchanges?.map(t=>oi.fromPartial(t))||[],r.pendingRobberOrPiratePlacement=e.pendingRobberOrPiratePlacement??!1,r.playedDevCardThisTurn=e.playedDevCardThisTurn??!1,r.pendingFreeResources=e.pendingFreeResources?.map(t=>ti.fromPartial(t))||[],r.pendingFreeStructures=e.pendingFreeStructures?.map(t=>ni.fromPartial(t))||[],r.pendingRobberStealLocation=e.pendingRobberStealLocation!==void 0&&e.pendingRobberStealLocation!==null?q.fromPartial(e.pendingRobberStealLocation):void 0,r.pendingPirateStealLocation=e.pendingPirateStealLocation!==void 0&&e.pendingPirateStealLocation!==null?q.fromPartial(e.pendingPirateStealLocation):void 0,r.movedShipThisTurn=e.movedShipThisTurn??!1,r.shipsBuiltThisTurn=e.shipsBuiltThisTurn?.map(t=>Ie.fromPartial(t))||[],r.largestArmyPlayer=e.largestArmyPlayer??0,r.longestRoadPlayer=e.longestRoadPlayer??0,r.harbormasterPlayer=e.harbormasterPlayer??0,r.isSetupPhase=e.isSetupPhase??!1,r.tradesProposedThisTurn=e.tradesProposedThisTurn??0,r.tradesExecutedThisTurn=e.tradesExecutedThisTurn??0,r.winner=e.winner??0,r.options=e.options!==void 0&&e.options!==null?li.fromPartial(e.options):void 0,r.eventDice=e.eventDice!==void 0&&e.eventDice!==null?zs.fromPartial(e.eventDice):void 0,r.scienceProgressDeck=e.scienceProgressDeck?.map(t=>t)||[],r.politicsProgressDeck=e.politicsProgressDeck?.map(t=>t)||[],r.tradeProgressDeck=e.tradeProgressDeck?.map(t=>t)||[],r.knightActivatedThisTurn=e.knightActivatedThisTurn??!1,r.commodityBank=e.commodityBank?.map(t=>te.fromPartial(t))||[],r.fishBank=e.fishBank?.map(t=>xe.fromPartial(t))||[],r.oldBoot=e.oldBoot??0,r.fogTerrainBank=e.fogTerrainBank?.map(t=>t)||[],r.fogNumberBank=e.fogNumberBank?.map(t=>t)||[],r.pendingDefenderSelection=e.pendingDefenderSelection?.map(t=>t)||[],r.pendingCityPillage=e.pendingCityPillage??0,r.pendingCommercialHarbor=e.pendingCommercialHarbor??!1,r.pendingAlchemist=e.pendingAlchemist??0,r.pendingProgressCardDraw=e.pendingProgressCardDraw?.map(t=>dr.fromPartial(t))||[],r.progressCardsInPlay=e.progressCardsInPlay?.map(t=>t)||[],r.merchantFleetResource=e.merchantFleetResource??0,r.masterMerchantTarget=e.masterMerchantTarget??0,r.pendingSpyTarget=e.pendingSpyTarget??0,r.smithFreePromotionsRemaining=e.smithFreePromotionsRemaining??0,r.pendingKnights=e.pendingKnights?.map(t=>ai.fromPartial(t))||[],r.paused=e.paused??!1,r.pendingResourceResolution=e.pendingResourceResolution??!1,r.diceRollCount=e.diceRollCount??0,r.diceDistribution=e.diceDistribution?.map(t=>Ks.fromPartial(t))||[],r.sevensPerPlayer=e.sevensPerPlayer?.map(t=>Ws.fromPartial(t))||[],r.timerState=e.timerState!==void 0&&e.timerState!==null?Vs.fromPartial(e.timerState):void 0,r.pauseState=e.pauseState!==void 0&&e.pauseState!==null?Hs.fromPartial(e.pauseState):void 0,r.pendingKnightCommitment=e.pendingKnightCommitment!==void 0&&e.pendingKnightCommitment!==null?si.fromPartial(e.pendingKnightCommitment):void 0,r.pendingSecondTurboRoll=e.pendingSecondTurboRoll??!1,r.isSecondSettlerPhase=e.isSecondSettlerPhase??!1,r.secondSettlerPlayer=e.secondSettlerPlayer??0,r.devCardDrawCount=e.devCardDrawCount??0,r.stealCount=e.stealCount??0,r.pendingPortPlacement=e.pendingPortPlacement!==void 0&&e.pendingPortPlacement!==null?Js.fromPartial(e.pendingPortPlacement):void 0,r.eventCardDeck=e.eventCardDeck?.map(t=>Rr.fromPartial(t))||[],r.removedEventCards=e.removedEventCards?.map(t=>Rr.fromPartial(t))||[],r.pendingEarthquake=e.pendingEarthquake?.map(t=>t)||[],r.pendingGoodNeighbors=e.pendingGoodNeighbors?.map(t=>t)||[],r.pendingHelpfulNeighbors=e.pendingHelpfulNeighbors?.map(t=>t)||[],r.pendingEventCardSteal=e.pendingEventCardSteal??0,r.pendingBishopSteal=e.pendingBishopSteal??0,r.pendingWagonVoting=e.pendingWagonVoting!==void 0&&e.pendingWagonVoting!==null?qs.fromPartial(e.pendingWagonVoting):void 0,r.wagonsExhausted=e.wagonsExhausted??!1,r.pendingDeserter=e.pendingDeserter!==void 0&&e.pendingDeserter!==null?_i.fromPartial(e.pendingDeserter):void 0,r.goldSpentThisTurn=globalThis.Object.entries(e.goldSpentThisTurn??{}).reduce((t,[o,i])=>(i!==void 0&&(t[globalThis.Number(o)]=globalThis.Number(i)),t),{}),r.stateVersion=e.stateVersion??0,r.mapVersion=e.mapVersion??0,r.buildingVersion=e.buildingVersion??0,r.merchantFleetCommodity=e.merchantFleetCommodity??0,r.pendingMetropolisPlacement=e.pendingMetropolisPlacement!==void 0&&e.pendingMetropolisPlacement!==null?di.fromPartial(e.pendingMetropolisPlacement):void 0,r.tradeEmbargoes=e.tradeEmbargoes?.map(t=>ui.fromPartial(t))||[],r.tradeBalance=e.tradeBalance?.map(t=>Ei.fromPartial(t))||[],r.rushPlayedDevCard=e.rushPlayedDevCard?.map(t=>t)||[],r.rushNextDiceRollAt=e.rushNextDiceRollAt??0,r.rushDiceVotes=e.rushDiceVotes?.map(t=>t)||[],r.rushRobberPlayer=e.rushRobberPlayer??0,r.pendingProgressCardDiscard=e.pendingProgressCardDiscard?.map(t=>mt.fromPartial(t))||[],r.pendingCityPillagePlayers=e.pendingCityPillagePlayers?.map(t=>t)||[],r.discardsWithoutRobber=e.discardsWithoutRobber??!1,r.nextTradeId=e.nextTradeId??0,r.rejectedTradeOffers=e.rejectedTradeOffers?.map(t=>ri.fromPartial(t))||[],r}};function pT(){return{key:0,value:0}}E(pT,"createBaseGameProto_GoldSpentThisTurnEntry");var ju={encode(e,r=new hT){return e.key!==0&&r.uint32(8).int32(e.key),e.value!==0&&r.uint32(16).int32(e.value),r},decode(e,r){let t=e instanceof Td?e:new Td(e),o=r===void 0?t.len:t.pos+r,i=pT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.key=t.int32();continue}case 2:{if(n!==16)break;i.value=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return ju.fromPartial(e??{})},fromPartial(e){let r=pT();return r.key=e.key??0,r.value=e.value??0,r}};function aD(e){let r=globalThis.Number(e.toString());if(r>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(r<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return r}E(aD,"longToNumber");import{BinaryReader as DT,BinaryWriter as sD}from"@bufbuild/protobuf/wire";var h;(function(e){e[e.GAME_EVENT_TYPE_UNSPECIFIED=0]="GAME_EVENT_TYPE_UNSPECIFIED",e[e.GAME_EVENT_TYPE_ROLL_DICE=1]="GAME_EVENT_TYPE_ROLL_DICE",e[e.GAME_EVENT_TYPE_RECEIVE_RESOURCES=2]="GAME_EVENT_TYPE_RECEIVE_RESOURCES",e[e.GAME_EVENT_TYPE_DISCARD_RESOURCES=3]="GAME_EVENT_TYPE_DISCARD_RESOURCES",e[e.GAME_EVENT_TYPE_MOVE_ROBBER=4]="GAME_EVENT_TYPE_MOVE_ROBBER",e[e.GAME_EVENT_TYPE_STEAL_RESOURCE=5]="GAME_EVENT_TYPE_STEAL_RESOURCE",e[e.GAME_EVENT_TYPE_BUILD_ROAD=6]="GAME_EVENT_TYPE_BUILD_ROAD",e[e.GAME_EVENT_TYPE_BUILD_SETTLEMENT=7]="GAME_EVENT_TYPE_BUILD_SETTLEMENT",e[e.GAME_EVENT_TYPE_BUILD_CITY=8]="GAME_EVENT_TYPE_BUILD_CITY",e[e.GAME_EVENT_TYPE_BUILD_SHIP=9]="GAME_EVENT_TYPE_BUILD_SHIP",e[e.GAME_EVENT_TYPE_BUY_DEV_CARD=10]="GAME_EVENT_TYPE_BUY_DEV_CARD",e[e.GAME_EVENT_TYPE_PLAY_KNIGHT=11]="GAME_EVENT_TYPE_PLAY_KNIGHT",e[e.GAME_EVENT_TYPE_PLAY_ROAD_BUILDING=12]="GAME_EVENT_TYPE_PLAY_ROAD_BUILDING",e[e.GAME_EVENT_TYPE_PLAY_YEAR_OF_PLENTY=13]="GAME_EVENT_TYPE_PLAY_YEAR_OF_PLENTY",e[e.GAME_EVENT_TYPE_PLAY_MONOPOLY=14]="GAME_EVENT_TYPE_PLAY_MONOPOLY",e[e.GAME_EVENT_TYPE_PLAY_VICTORY_POINT=15]="GAME_EVENT_TYPE_PLAY_VICTORY_POINT",e[e.GAME_EVENT_TYPE_TRADE_WITH_PLAYER=16]="GAME_EVENT_TYPE_TRADE_WITH_PLAYER",e[e.GAME_EVENT_TYPE_TRADE_WITH_BANK=17]="GAME_EVENT_TYPE_TRADE_WITH_BANK",e[e.GAME_EVENT_TYPE_END_TURN=18]="GAME_EVENT_TYPE_END_TURN",e[e.GAME_EVENT_TYPE_PROPOSE_TRADE=19]="GAME_EVENT_TYPE_PROPOSE_TRADE",e[e.GAME_EVENT_TYPE_ACCEPT_TRADE=20]="GAME_EVENT_TYPE_ACCEPT_TRADE",e[e.GAME_EVENT_TYPE_REVOKE_TRADE_ACCEPT=21]="GAME_EVENT_TYPE_REVOKE_TRADE_ACCEPT",e[e.GAME_EVENT_TYPE_REJECT_TRADE=22]="GAME_EVENT_TYPE_REJECT_TRADE",e[e.GAME_EVENT_TYPE_CANCEL_TRADE=23]="GAME_EVENT_TYPE_CANCEL_TRADE",e[e.GAME_EVENT_TYPE_EXECUTE_TRADE=24]="GAME_EVENT_TYPE_EXECUTE_TRADE",e[e.GAME_EVENT_TYPE_SELECT_FREE_RESOURCE=25]="GAME_EVENT_TYPE_SELECT_FREE_RESOURCE",e[e.GAME_EVENT_TYPE_PLACE_FREE_STRUCTURE=26]="GAME_EVENT_TYPE_PLACE_FREE_STRUCTURE",e[e.GAME_EVENT_TYPE_MOVE_SHIP=27]="GAME_EVENT_TYPE_MOVE_SHIP",e[e.GAME_EVENT_TYPE_MOVE_PIRATE=28]="GAME_EVENT_TYPE_MOVE_PIRATE",e[e.GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE=29]="GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE",e[e.GAME_EVENT_TYPE_BUILD_KNIGHT=31]="GAME_EVENT_TYPE_BUILD_KNIGHT",e[e.GAME_EVENT_TYPE_ACTIVATE_KNIGHT=32]="GAME_EVENT_TYPE_ACTIVATE_KNIGHT",e[e.GAME_EVENT_TYPE_PROMOTE_KNIGHT=33]="GAME_EVENT_TYPE_PROMOTE_KNIGHT",e[e.GAME_EVENT_TYPE_MOVE_KNIGHT=34]="GAME_EVENT_TYPE_MOVE_KNIGHT",e[e.GAME_EVENT_TYPE_DISPLACE_KNIGHT=35]="GAME_EVENT_TYPE_DISPLACE_KNIGHT",e[e.GAME_EVENT_TYPE_CHASE_ROBBER=36]="GAME_EVENT_TYPE_CHASE_ROBBER",e[e.GAME_EVENT_TYPE_BUILD_CITY_WALL=37]="GAME_EVENT_TYPE_BUILD_CITY_WALL",e[e.GAME_EVENT_TYPE_BUILD_CITY_IMPROVEMENT=38]="GAME_EVENT_TYPE_BUILD_CITY_IMPROVEMENT",e[e.GAME_EVENT_TYPE_RECEIVE_COMMODITIES=39]="GAME_EVENT_TYPE_RECEIVE_COMMODITIES",e[e.GAME_EVENT_TYPE_ROLL_EVENT_DIE=40]="GAME_EVENT_TYPE_ROLL_EVENT_DIE",e[e.GAME_EVENT_TYPE_BARBARIAN_ADVANCE=41]="GAME_EVENT_TYPE_BARBARIAN_ADVANCE",e[e.GAME_EVENT_TYPE_BARBARIAN_ATTACK=42]="GAME_EVENT_TYPE_BARBARIAN_ATTACK",e[e.GAME_EVENT_TYPE_CITY_PILLAGED=43]="GAME_EVENT_TYPE_CITY_PILLAGED",e[e.GAME_EVENT_TYPE_DEFENDER_OF_CATAN=44]="GAME_EVENT_TYPE_DEFENDER_OF_CATAN",e[e.GAME_EVENT_TYPE_KNIGHTS_DEACTIVATED=45]="GAME_EVENT_TYPE_KNIGHTS_DEACTIVATED",e[e.GAME_EVENT_TYPE_DRAW_PROGRESS_CARD=46]="GAME_EVENT_TYPE_DRAW_PROGRESS_CARD",e[e.GAME_EVENT_TYPE_PLAY_ALCHEMIST=47]="GAME_EVENT_TYPE_PLAY_ALCHEMIST",e[e.GAME_EVENT_TYPE_PLAY_CRANE=48]="GAME_EVENT_TYPE_PLAY_CRANE",e[e.GAME_EVENT_TYPE_PLAY_DESERTER=49]="GAME_EVENT_TYPE_PLAY_DESERTER",e[e.GAME_EVENT_TYPE_PLAY_INTRIGUE=50]="GAME_EVENT_TYPE_PLAY_INTRIGUE",e[e.GAME_EVENT_TYPE_PLAY_MERCHANT_CARD=51]="GAME_EVENT_TYPE_PLAY_MERCHANT_CARD",e[e.GAME_EVENT_TYPE_PLAY_RESOURCE_MONOPOLY=52]="GAME_EVENT_TYPE_PLAY_RESOURCE_MONOPOLY",e[e.GAME_EVENT_TYPE_PLAY_PROGRESS_ROAD_BUILDING=53]="GAME_EVENT_TYPE_PLAY_PROGRESS_ROAD_BUILDING",e[e.GAME_EVENT_TYPE_PLAY_SMITH=54]="GAME_EVENT_TYPE_PLAY_SMITH",e[e.GAME_EVENT_TYPE_PLAY_SPY=55]="GAME_EVENT_TYPE_PLAY_SPY",e[e.GAME_EVENT_TYPE_PLAY_WARLORD=56]="GAME_EVENT_TYPE_PLAY_WARLORD",e[e.GAME_EVENT_TYPE_PLAY_BISHOP=57]="GAME_EVENT_TYPE_PLAY_BISHOP",e[e.GAME_EVENT_TYPE_METROPOLIS_BUILT=58]="GAME_EVENT_TYPE_METROPOLIS_BUILT",e[e.GAME_EVENT_TYPE_METROPOLIS_TRANSFERRED=59]="GAME_EVENT_TYPE_METROPOLIS_TRANSFERRED",e[e.GAME_EVENT_TYPE_MERCHANT_PLACED=60]="GAME_EVENT_TYPE_MERCHANT_PLACED",e[e.GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT=61]="GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT",e[e.GAME_EVENT_TYPE_MASTER_MERCHANT_REVEAL=62]="GAME_EVENT_TYPE_MASTER_MERCHANT_REVEAL",e[e.GAME_EVENT_TYPE_MASTER_MERCHANT_STEAL=63]="GAME_EVENT_TYPE_MASTER_MERCHANT_STEAL",e[e.GAME_EVENT_TYPE_PLAY_MERCHANT_FLEET=64]="GAME_EVENT_TYPE_PLAY_MERCHANT_FLEET",e[e.GAME_EVENT_TYPE_PLAY_MEDICINE=65]="GAME_EVENT_TYPE_PLAY_MEDICINE",e[e.GAME_EVENT_TYPE_PLAY_TRADE_MONOPOLY=66]="GAME_EVENT_TYPE_PLAY_TRADE_MONOPOLY",e[e.GAME_EVENT_TYPE_PLAY_MINING=69]="GAME_EVENT_TYPE_PLAY_MINING",e[e.GAME_EVENT_TYPE_PLAY_IRRIGATION=70]="GAME_EVENT_TYPE_PLAY_IRRIGATION",e[e.GAME_EVENT_TYPE_AQUEDUCT_TRIGGERED=71]="GAME_EVENT_TYPE_AQUEDUCT_TRIGGERED",e[e.GAME_EVENT_TYPE_PLAY_ENGINEER=72]="GAME_EVENT_TYPE_PLAY_ENGINEER",e[e.GAME_EVENT_TYPE_PLAY_INVENTOR=73]="GAME_EVENT_TYPE_PLAY_INVENTOR",e[e.GAME_EVENT_TYPE_PLAY_DIPLOMAT=74]="GAME_EVENT_TYPE_PLAY_DIPLOMAT",e[e.GAME_EVENT_TYPE_PLAY_SABOTEUR=75]="GAME_EVENT_TYPE_PLAY_SABOTEUR",e[e.GAME_EVENT_TYPE_PLAY_WEDDING=76]="GAME_EVENT_TYPE_PLAY_WEDDING",e[e.GAME_EVENT_TYPE_GIVE_WEDDING_CARDS=77]="GAME_EVENT_TYPE_GIVE_WEDDING_CARDS",e[e.GAME_EVENT_TYPE_PLAY_COMMERCIAL_HARBOR=78]="GAME_EVENT_TYPE_PLAY_COMMERCIAL_HARBOR",e[e.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_EXCHANGE=79]="GAME_EVENT_TYPE_COMMERCIAL_HARBOR_EXCHANGE",e[e.GAME_EVENT_TYPE_RECEIVE_FISH=80]="GAME_EVENT_TYPE_RECEIVE_FISH",e[e.GAME_EVENT_TYPE_PASS_OLD_BOOT=81]="GAME_EVENT_TYPE_PASS_OLD_BOOT",e[e.GAME_EVENT_TYPE_SPEND_FISH=82]="GAME_EVENT_TYPE_SPEND_FISH",e[e.GAME_EVENT_TYPE_EXCHANGE_FISH=105]="GAME_EVENT_TYPE_EXCHANGE_FISH",e[e.GAME_EVENT_TYPE_REVEAL_FOG=83]="GAME_EVENT_TYPE_REVEAL_FOG",e[e.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_TRADE_CANCELLED=84]="GAME_EVENT_TYPE_COMMERCIAL_HARBOR_TRADE_CANCELLED",e[e.GAME_EVENT_TYPE_RESIGN=85]="GAME_EVENT_TYPE_RESIGN",e[e.GAME_EVENT_TYPE_PAUSE=86]="GAME_EVENT_TYPE_PAUSE",e[e.GAME_EVENT_TYPE_UNPAUSE=87]="GAME_EVENT_TYPE_UNPAUSE",e[e.GAME_EVENT_TYPE_AWARD_LARGEST_ARMY=88]="GAME_EVENT_TYPE_AWARD_LARGEST_ARMY",e[e.GAME_EVENT_TYPE_AWARD_LONGEST_ROAD=89]="GAME_EVENT_TYPE_AWARD_LONGEST_ROAD",e[e.GAME_EVENT_TYPE_AWARD_HARBORMASTER=97]="GAME_EVENT_TYPE_AWARD_HARBORMASTER",e[e.GAME_EVENT_TYPE_FREE_RESOURCE_GRANTED=90]="GAME_EVENT_TYPE_FREE_RESOURCE_GRANTED",e[e.GAME_EVENT_TYPE_GAME_WON=91]="GAME_EVENT_TYPE_GAME_WON",e[e.GAME_EVENT_TYPE_GOLD_PRODUCED=92]="GAME_EVENT_TYPE_GOLD_PRODUCED",e[e.GAME_EVENT_TYPE_VOTE_TO_CONTINUE=93]="GAME_EVENT_TYPE_VOTE_TO_CONTINUE",e[e.GAME_EVENT_TYPE_USE_KNIGHT_ERRANT=94]="GAME_EVENT_TYPE_USE_KNIGHT_ERRANT",e[e.GAME_EVENT_TYPE_AWAIT_KNIGHT_COMMITMENT=95]="GAME_EVENT_TYPE_AWAIT_KNIGHT_COMMITMENT",e[e.GAME_EVENT_TYPE_COMMIT_KNIGHTS_TO_DEFENSE=96]="GAME_EVENT_TYPE_COMMIT_KNIGHTS_TO_DEFENSE",e[e.GAME_EVENT_TYPE_NEW_ISLAND_SETTLEMENT=98]="GAME_EVENT_TYPE_NEW_ISLAND_SETTLEMENT",e[e.GAME_EVENT_TYPE_COLLECT_EDGE_VP=99]="GAME_EVENT_TYPE_COLLECT_EDGE_VP",e[e.GAME_EVENT_TYPE_COLLECT_EDGE_DEV_CARD=100]="GAME_EVENT_TYPE_COLLECT_EDGE_DEV_CARD",e[e.GAME_EVENT_TYPE_COLLECT_EDGE_PORT=101]="GAME_EVENT_TYPE_COLLECT_EDGE_PORT",e[e.GAME_EVENT_TYPE_PLACE_PORT=102]="GAME_EVENT_TYPE_PLACE_PORT",e[e.GAME_EVENT_TYPE_START_SECOND_SETTLER_TURN=103]="GAME_EVENT_TYPE_START_SECOND_SETTLER_TURN",e[e.GAME_EVENT_TYPE_END_SECOND_SETTLER_TURN=104]="GAME_EVENT_TYPE_END_SECOND_SETTLER_TURN",e[e.GAME_EVENT_TYPE_ROAD_DAMAGED=106]="GAME_EVENT_TYPE_ROAD_DAMAGED",e[e.GAME_EVENT_TYPE_GIVE_EVENT_CARD_RESOURCE=118]="GAME_EVENT_TYPE_GIVE_EVENT_CARD_RESOURCE",e[e.GAME_EVENT_TYPE_RESOURCE_DISTRIBUTION=107]="GAME_EVENT_TYPE_RESOURCE_DISTRIBUTION",e[e.GAME_EVENT_TYPE_TILES_DESERTIFIED=108]="GAME_EVENT_TYPE_TILES_DESERTIFIED",e[e.GAME_EVENT_TYPE_WAGON_VOTING_STARTED=109]="GAME_EVENT_TYPE_WAGON_VOTING_STARTED",e[e.GAME_EVENT_TYPE_WAGON_VOTE=110]="GAME_EVENT_TYPE_WAGON_VOTE",e[e.GAME_EVENT_TYPE_WAGON_PLACED=111]="GAME_EVENT_TYPE_WAGON_PLACED",e[e.GAME_EVENT_TYPE_WAGONS_EXHAUSTED=112]="GAME_EVENT_TYPE_WAGONS_EXHAUSTED",e[e.GAME_EVENT_TYPE_RECEIVE_GOLD=113]="GAME_EVENT_TYPE_RECEIVE_GOLD",e[e.GAME_EVENT_TYPE_SPEND_GOLD=114]="GAME_EVENT_TYPE_SPEND_GOLD",e[e.GAME_EVENT_TYPE_BUILD_BRIDGE=115]="GAME_EVENT_TYPE_BUILD_BRIDGE",e[e.GAME_EVENT_TYPE_WEALTHIEST_TRADER_CHANGED=116]="GAME_EVENT_TYPE_WEALTHIEST_TRADER_CHANGED",e[e.GAME_EVENT_TYPE_POOREST_TRADER_CHANGED=117]="GAME_EVENT_TYPE_POOREST_TRADER_CHANGED",e[e.GAME_EVENT_TYPE_FEED_TROLL=121]="GAME_EVENT_TYPE_FEED_TROLL",e[e.GAME_EVENT_TYPE_KICK_TROLL=122]="GAME_EVENT_TYPE_KICK_TROLL",e[e.GAME_EVENT_TYPE_TROLL_SPAWNED=123]="GAME_EVENT_TYPE_TROLL_SPAWNED",e[e.GAME_EVENT_TYPE_TROLLS_INVADED=124]="GAME_EVENT_TYPE_TROLLS_INVADED",e[e.GAME_EVENT_TYPE_INITIALIZE_DECKS=125]="GAME_EVENT_TYPE_INITIALIZE_DECKS",e[e.GAME_EVENT_TYPE_SELECT_DESERTER_KNIGHT=126]="GAME_EVENT_TYPE_SELECT_DESERTER_KNIGHT",e[e.GAME_EVENT_TYPE_SELECT_METROPOLIS_CITY=127]="GAME_EVENT_TYPE_SELECT_METROPOLIS_CITY",e[e.GAME_EVENT_TYPE_VOTE_DICE_ROLL=128]="GAME_EVENT_TYPE_VOTE_DICE_ROLL",e[e.GAME_EVENT_TYPE_RUSH_ROUND_START=129]="GAME_EVENT_TYPE_RUSH_ROUND_START",e[e.GAME_EVENT_TYPE_PROPOSE_MULTI_TRADE=130]="GAME_EVENT_TYPE_PROPOSE_MULTI_TRADE",e[e.GAME_EVENT_TYPE_TRADE_EMBARGO=131]="GAME_EVENT_TYPE_TRADE_EMBARGO",e[e.GAME_EVENT_TYPE_DISCARD_PROGRESS_CARD=132]="GAME_EVENT_TYPE_DISCARD_PROGRESS_CARD",e[e.GAME_EVENT_TYPE_FREE_STRUCTURE_GRANTED=133]="GAME_EVENT_TYPE_FREE_STRUCTURE_GRANTED",e[e.GAME_EVENT_TYPE_BUY_PROGRESS_CARD=134]="GAME_EVENT_TYPE_BUY_PROGRESS_CARD",e[e.GAME_EVENT_TYPE_LAZY_ROBBER_RETREAT=135]="GAME_EVENT_TYPE_LAZY_ROBBER_RETREAT",e[e.GAME_EVENT_TYPE_PROGRESS_CARD_DISCARD_REQUIRED=136]="GAME_EVENT_TYPE_PROGRESS_CARD_DISCARD_REQUIRED",e[e.GAME_EVENT_TYPE_BUY_GOLD=137]="GAME_EVENT_TYPE_BUY_GOLD",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(h||(h={}));function mT(){return{type:0,player:0,dice:void 0,resources:[],robberLocation:void 0,targetPlayer:0,stolenResource:0,edge:void 0,receivedResources:[],vertex:void 0,devCard:0,elapsedTimeMs:0,monopolyResults:[],tradePartner:0,offeredResources:[],monopolyResource:0,tradeId:0,selectedResource:0,building:0,shipFromEdge:void 0,shipToEdge:void 0,pirateLocation:void 0,knightLocation:void 0,knightDestination:void 0,knightStrength:0,knightStatus:0,improvementTrack:0,improvementLevel:0,commodities:[],barbarianPosition:0,barbarianStrength:0,knightDefenseStrength:0,barbarianVictory:!1,progressCard:0,progressCardTrack:0,eventDieResult:0,metropolis:void 0,previousMetropolisOwner:0,merchantLocation:void 0,displacedKnightOwner:0,displacedKnightTo:void 0,pillagedCityLocation:void 0,masterMerchantResources:[],masterMerchantCommodities:[],merchantFleetResource:0,tradeMonopolyCommodity:0,tradeMonopolyResults:[],inventorHex1:void 0,inventorHex2:void 0,spyVisibleProgressCards:[],spyStolenProgressCard:0,fishTiles:[],discardedFishTiles:[],fogHexLocation:void 0,fogRevealedTerrain:0,fogRevealedNumber:0,fogRewardResource:0,commercialHarborTrades:[],previousAwardHolder:0,freeResourceReason:0,freeResourceCount:0,winReason:0,actionSource:0,committedKnights:[],islandBonusVp:0,edgeRewardType:0,collectedPort:void 0,pairedPlayer:0,resourceDistribution:void 0,wagonVotes:[],placedWagon:void 0,goldAmount:0,offeredCommodities:[],receivedCommodities:[],offeredGold:0,receivedGold:0,trollHex:void 0,trollFishPaid:[],trollCount:0,initScienceProgressDeck:[],initPoliticsProgressDeck:[],initTradeProgressDeck:[],initEventCardDeck:[],initRemovedEventCards:[],initialFogReveals:[],lazyRobberFrom:void 0,merchantFleetCommodity:0,tradeProposals:[],embargoActive:!1,rushNextDiceRollAt:0,counterTradeId:0,stolenCommodity:0,freeStructureReason:0,freeStructureBuilding:0,freeDevCard:!1,pillagePlayers:[],defenderPlayers:[],poorTraders:[],previousPoorTraders:[]}}E(mT,"createBaseGameEventProto");var e_={encode(e,r=new sD){e.type!==0&&r.uint32(8).int32(e.type),e.player!==0&&r.uint32(16).int32(e.player),e.dice!==void 0&&Dt.encode(e.dice,r.uint32(26).fork()).join();for(let t of e.resources)ne.encode(t,r.uint32(34).fork()).join();e.robberLocation!==void 0&&q.encode(e.robberLocation,r.uint32(42).fork()).join(),e.targetPlayer!==0&&r.uint32(48).int32(e.targetPlayer),e.stolenResource!==0&&r.uint32(56).int32(e.stolenResource),e.edge!==void 0&&Ie.encode(e.edge,r.uint32(66).fork()).join();for(let t of e.receivedResources)ne.encode(t,r.uint32(74).fork()).join();e.vertex!==void 0&&ee.encode(e.vertex,r.uint32(82).fork()).join(),e.devCard!==0&&r.uint32(88).int32(e.devCard),e.elapsedTimeMs!==0&&r.uint32(96).int64(e.elapsedTimeMs);for(let t of e.monopolyResults)vt.encode(t,r.uint32(106).fork()).join();e.tradePartner!==0&&r.uint32(112).int32(e.tradePartner);for(let t of e.offeredResources)ne.encode(t,r.uint32(122).fork()).join();e.monopolyResource!==0&&r.uint32(128).int32(e.monopolyResource),e.tradeId!==0&&r.uint32(136).int32(e.tradeId),e.selectedResource!==0&&r.uint32(144).int32(e.selectedResource),e.building!==0&&r.uint32(152).int32(e.building),e.shipFromEdge!==void 0&&Ie.encode(e.shipFromEdge,r.uint32(162).fork()).join(),e.shipToEdge!==void 0&&Ie.encode(e.shipToEdge,r.uint32(170).fork()).join(),e.pirateLocation!==void 0&&q.encode(e.pirateLocation,r.uint32(178).fork()).join(),e.knightLocation!==void 0&&ee.encode(e.knightLocation,r.uint32(194).fork()).join(),e.knightDestination!==void 0&&ee.encode(e.knightDestination,r.uint32(202).fork()).join(),e.knightStrength!==0&&r.uint32(208).int32(e.knightStrength),e.knightStatus!==0&&r.uint32(216).int32(e.knightStatus),e.improvementTrack!==0&&r.uint32(224).int32(e.improvementTrack),e.improvementLevel!==0&&r.uint32(232).int32(e.improvementLevel);for(let t of e.commodities)te.encode(t,r.uint32(242).fork()).join();e.barbarianPosition!==0&&r.uint32(248).int32(e.barbarianPosition),e.barbarianStrength!==0&&r.uint32(256).int32(e.barbarianStrength),e.knightDefenseStrength!==0&&r.uint32(264).int32(e.knightDefenseStrength),e.barbarianVictory!==!1&&r.uint32(272).bool(e.barbarianVictory),e.progressCard!==0&&r.uint32(280).int32(e.progressCard),e.progressCardTrack!==0&&r.uint32(288).int32(e.progressCardTrack),e.eventDieResult!==0&&r.uint32(296).int32(e.eventDieResult),e.metropolis!==void 0&&bn.encode(e.metropolis,r.uint32(306).fork()).join(),e.previousMetropolisOwner!==0&&r.uint32(312).int32(e.previousMetropolisOwner),e.merchantLocation!==void 0&&q.encode(e.merchantLocation,r.uint32(322).fork()).join(),e.displacedKnightOwner!==0&&r.uint32(328).int32(e.displacedKnightOwner),e.displacedKnightTo!==void 0&&ee.encode(e.displacedKnightTo,r.uint32(338).fork()).join(),e.pillagedCityLocation!==void 0&&ee.encode(e.pillagedCityLocation,r.uint32(346).fork()).join();for(let t of e.masterMerchantResources)ne.encode(t,r.uint32(354).fork()).join();for(let t of e.masterMerchantCommodities)te.encode(t,r.uint32(362).fork()).join();e.merchantFleetResource!==0&&r.uint32(368).int32(e.merchantFleetResource),e.tradeMonopolyCommodity!==0&&r.uint32(376).int32(e.tradeMonopolyCommodity);for(let t of e.tradeMonopolyResults)vt.encode(t,r.uint32(386).fork()).join();e.inventorHex1!==void 0&&q.encode(e.inventorHex1,r.uint32(394).fork()).join(),e.inventorHex2!==void 0&&q.encode(e.inventorHex2,r.uint32(402).fork()).join();for(let t of e.spyVisibleProgressCards)dr.encode(t,r.uint32(410).fork()).join();e.spyStolenProgressCard!==0&&r.uint32(416).int32(e.spyStolenProgressCard);for(let t of e.fishTiles)xe.encode(t,r.uint32(426).fork()).join();for(let t of e.discardedFishTiles)xe.encode(t,r.uint32(554).fork()).join();e.fogHexLocation!==void 0&&q.encode(e.fogHexLocation,r.uint32(434).fork()).join(),e.fogRevealedTerrain!==0&&r.uint32(440).int32(e.fogRevealedTerrain),e.fogRevealedNumber!==0&&r.uint32(448).int32(e.fogRevealedNumber),e.fogRewardResource!==0&&r.uint32(456).int32(e.fogRewardResource);for(let t of e.commercialHarborTrades)gt.encode(t,r.uint32(466).fork()).join();e.previousAwardHolder!==0&&r.uint32(472).int32(e.previousAwardHolder),e.freeResourceReason!==0&&r.uint32(480).int32(e.freeResourceReason),e.freeResourceCount!==0&&r.uint32(488).int32(e.freeResourceCount),e.winReason!==0&&r.uint32(496).int32(e.winReason),e.actionSource!==0&&r.uint32(504).int32(e.actionSource);for(let t of e.committedKnights)ee.encode(t,r.uint32(514).fork()).join();e.islandBonusVp!==0&&r.uint32(520).int32(e.islandBonusVp),e.edgeRewardType!==0&&r.uint32(528).int32(e.edgeRewardType),e.collectedPort!==void 0&&Nr.encode(e.collectedPort,r.uint32(538).fork()).join(),e.pairedPlayer!==0&&r.uint32(544).int32(e.pairedPlayer),e.resourceDistribution!==void 0&&Qs.encode(e.resourceDistribution,r.uint32(562).fork()).join();for(let t of e.wagonVotes)kn.encode(t,r.uint32(570).fork()).join();e.placedWagon!==void 0&&Bn.encode(e.placedWagon,r.uint32(578).fork()).join(),e.goldAmount!==0&&r.uint32(584).int32(e.goldAmount);for(let t of e.offeredCommodities)te.encode(t,r.uint32(594).fork()).join();for(let t of e.receivedCommodities)te.encode(t,r.uint32(602).fork()).join();e.offeredGold!==0&&r.uint32(608).int32(e.offeredGold),e.receivedGold!==0&&r.uint32(616).int32(e.receivedGold),e.trollHex!==void 0&&q.encode(e.trollHex,r.uint32(626).fork()).join();for(let t of e.trollFishPaid)xe.encode(t,r.uint32(634).fork()).join();e.trollCount!==0&&r.uint32(640).int32(e.trollCount),r.uint32(650).fork();for(let t of e.initScienceProgressDeck)r.int32(t);r.join(),r.uint32(658).fork();for(let t of e.initPoliticsProgressDeck)r.int32(t);r.join(),r.uint32(666).fork();for(let t of e.initTradeProgressDeck)r.int32(t);r.join();for(let t of e.initEventCardDeck)Rr.encode(t,r.uint32(674).fork()).join();for(let t of e.initRemovedEventCards)Rr.encode(t,r.uint32(682).fork()).join();for(let t of e.initialFogReveals)Zs.encode(t,r.uint32(762).fork()).join();e.lazyRobberFrom!==void 0&&q.encode(e.lazyRobberFrom,r.uint32(770).fork()).join(),e.merchantFleetCommodity!==0&&r.uint32(688).int32(e.merchantFleetCommodity);for(let t of e.tradeProposals)Qr.encode(t,r.uint32(698).fork()).join();e.embargoActive!==!1&&r.uint32(704).bool(e.embargoActive),e.rushNextDiceRollAt!==0&&r.uint32(712).int64(e.rushNextDiceRollAt),e.counterTradeId!==0&&r.uint32(720).int32(e.counterTradeId),e.stolenCommodity!==0&&r.uint32(728).int32(e.stolenCommodity),e.freeStructureReason!==0&&r.uint32(736).int32(e.freeStructureReason),e.freeStructureBuilding!==0&&r.uint32(744).int32(e.freeStructureBuilding),e.freeDevCard!==!1&&r.uint32(752).bool(e.freeDevCard),r.uint32(778).fork();for(let t of e.pillagePlayers)r.int32(t);r.join(),r.uint32(786).fork();for(let t of e.defenderPlayers)r.int32(t);r.join(),r.uint32(794).fork();for(let t of e.poorTraders)r.int32(t);r.join(),r.uint32(802).fork();for(let t of e.previousPoorTraders)r.int32(t);return r.join(),r},decode(e,r){let t=e instanceof DT?e:new DT(e),o=r===void 0?t.len:t.pos+r,i=mT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.type=t.int32();continue}case 2:{if(n!==16)break;i.player=t.int32();continue}case 3:{if(n!==26)break;i.dice=Dt.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.resources.push(ne.decode(t,t.uint32()));continue}case 5:{if(n!==42)break;i.robberLocation=q.decode(t,t.uint32());continue}case 6:{if(n!==48)break;i.targetPlayer=t.int32();continue}case 7:{if(n!==56)break;i.stolenResource=t.int32();continue}case 8:{if(n!==66)break;i.edge=Ie.decode(t,t.uint32());continue}case 9:{if(n!==74)break;i.receivedResources.push(ne.decode(t,t.uint32()));continue}case 10:{if(n!==82)break;i.vertex=ee.decode(t,t.uint32());continue}case 11:{if(n!==88)break;i.devCard=t.int32();continue}case 12:{if(n!==96)break;i.elapsedTimeMs=gT(t.int64());continue}case 13:{if(n!==106)break;i.monopolyResults.push(vt.decode(t,t.uint32()));continue}case 14:{if(n!==112)break;i.tradePartner=t.int32();continue}case 15:{if(n!==122)break;i.offeredResources.push(ne.decode(t,t.uint32()));continue}case 16:{if(n!==128)break;i.monopolyResource=t.int32();continue}case 17:{if(n!==136)break;i.tradeId=t.int32();continue}case 18:{if(n!==144)break;i.selectedResource=t.int32();continue}case 19:{if(n!==152)break;i.building=t.int32();continue}case 20:{if(n!==162)break;i.shipFromEdge=Ie.decode(t,t.uint32());continue}case 21:{if(n!==170)break;i.shipToEdge=Ie.decode(t,t.uint32());continue}case 22:{if(n!==178)break;i.pirateLocation=q.decode(t,t.uint32());continue}case 24:{if(n!==194)break;i.knightLocation=ee.decode(t,t.uint32());continue}case 25:{if(n!==202)break;i.knightDestination=ee.decode(t,t.uint32());continue}case 26:{if(n!==208)break;i.knightStrength=t.int32();continue}case 27:{if(n!==216)break;i.knightStatus=t.int32();continue}case 28:{if(n!==224)break;i.improvementTrack=t.int32();continue}case 29:{if(n!==232)break;i.improvementLevel=t.int32();continue}case 30:{if(n!==242)break;i.commodities.push(te.decode(t,t.uint32()));continue}case 31:{if(n!==248)break;i.barbarianPosition=t.int32();continue}case 32:{if(n!==256)break;i.barbarianStrength=t.int32();continue}case 33:{if(n!==264)break;i.knightDefenseStrength=t.int32();continue}case 34:{if(n!==272)break;i.barbarianVictory=t.bool();continue}case 35:{if(n!==280)break;i.progressCard=t.int32();continue}case 36:{if(n!==288)break;i.progressCardTrack=t.int32();continue}case 37:{if(n!==296)break;i.eventDieResult=t.int32();continue}case 38:{if(n!==306)break;i.metropolis=bn.decode(t,t.uint32());continue}case 39:{if(n!==312)break;i.previousMetropolisOwner=t.int32();continue}case 40:{if(n!==322)break;i.merchantLocation=q.decode(t,t.uint32());continue}case 41:{if(n!==328)break;i.displacedKnightOwner=t.int32();continue}case 42:{if(n!==338)break;i.displacedKnightTo=ee.decode(t,t.uint32());continue}case 43:{if(n!==346)break;i.pillagedCityLocation=ee.decode(t,t.uint32());continue}case 44:{if(n!==354)break;i.masterMerchantResources.push(ne.decode(t,t.uint32()));continue}case 45:{if(n!==362)break;i.masterMerchantCommodities.push(te.decode(t,t.uint32()));continue}case 46:{if(n!==368)break;i.merchantFleetResource=t.int32();continue}case 47:{if(n!==376)break;i.tradeMonopolyCommodity=t.int32();continue}case 48:{if(n!==386)break;i.tradeMonopolyResults.push(vt.decode(t,t.uint32()));continue}case 49:{if(n!==394)break;i.inventorHex1=q.decode(t,t.uint32());continue}case 50:{if(n!==402)break;i.inventorHex2=q.decode(t,t.uint32());continue}case 51:{if(n!==410)break;i.spyVisibleProgressCards.push(dr.decode(t,t.uint32()));continue}case 52:{if(n!==416)break;i.spyStolenProgressCard=t.int32();continue}case 53:{if(n!==426)break;i.fishTiles.push(xe.decode(t,t.uint32()));continue}case 69:{if(n!==554)break;i.discardedFishTiles.push(xe.decode(t,t.uint32()));continue}case 54:{if(n!==434)break;i.fogHexLocation=q.decode(t,t.uint32());continue}case 55:{if(n!==440)break;i.fogRevealedTerrain=t.int32();continue}case 56:{if(n!==448)break;i.fogRevealedNumber=t.int32();continue}case 57:{if(n!==456)break;i.fogRewardResource=t.int32();continue}case 58:{if(n!==466)break;i.commercialHarborTrades.push(gt.decode(t,t.uint32()));continue}case 59:{if(n!==472)break;i.previousAwardHolder=t.int32();continue}case 60:{if(n!==480)break;i.freeResourceReason=t.int32();continue}case 61:{if(n!==488)break;i.freeResourceCount=t.int32();continue}case 62:{if(n!==496)break;i.winReason=t.int32();continue}case 63:{if(n!==504)break;i.actionSource=t.int32();continue}case 64:{if(n!==514)break;i.committedKnights.push(ee.decode(t,t.uint32()));continue}case 65:{if(n!==520)break;i.islandBonusVp=t.int32();continue}case 66:{if(n!==528)break;i.edgeRewardType=t.int32();continue}case 67:{if(n!==538)break;i.collectedPort=Nr.decode(t,t.uint32());continue}case 68:{if(n!==544)break;i.pairedPlayer=t.int32();continue}case 70:{if(n!==562)break;i.resourceDistribution=Qs.decode(t,t.uint32());continue}case 71:{if(n!==570)break;i.wagonVotes.push(kn.decode(t,t.uint32()));continue}case 72:{if(n!==578)break;i.placedWagon=Bn.decode(t,t.uint32());continue}case 73:{if(n!==584)break;i.goldAmount=t.int32();continue}case 74:{if(n!==594)break;i.offeredCommodities.push(te.decode(t,t.uint32()));continue}case 75:{if(n!==602)break;i.receivedCommodities.push(te.decode(t,t.uint32()));continue}case 76:{if(n!==608)break;i.offeredGold=t.int32();continue}case 77:{if(n!==616)break;i.receivedGold=t.int32();continue}case 78:{if(n!==626)break;i.trollHex=q.decode(t,t.uint32());continue}case 79:{if(n!==634)break;i.trollFishPaid.push(xe.decode(t,t.uint32()));continue}case 80:{if(n!==640)break;i.trollCount=t.int32();continue}case 81:{if(n===648){i.initScienceProgressDeck.push(t.int32());continue}if(n===650){let a=t.uint32()+t.pos;for(;t.pos<a;)i.initScienceProgressDeck.push(t.int32());continue}break}case 82:{if(n===656){i.initPoliticsProgressDeck.push(t.int32());continue}if(n===658){let a=t.uint32()+t.pos;for(;t.pos<a;)i.initPoliticsProgressDeck.push(t.int32());continue}break}case 83:{if(n===664){i.initTradeProgressDeck.push(t.int32());continue}if(n===666){let a=t.uint32()+t.pos;for(;t.pos<a;)i.initTradeProgressDeck.push(t.int32());continue}break}case 84:{if(n!==674)break;i.initEventCardDeck.push(Rr.decode(t,t.uint32()));continue}case 85:{if(n!==682)break;i.initRemovedEventCards.push(Rr.decode(t,t.uint32()));continue}case 95:{if(n!==762)break;i.initialFogReveals.push(Zs.decode(t,t.uint32()));continue}case 96:{if(n!==770)break;i.lazyRobberFrom=q.decode(t,t.uint32());continue}case 86:{if(n!==688)break;i.merchantFleetCommodity=t.int32();continue}case 87:{if(n!==698)break;i.tradeProposals.push(Qr.decode(t,t.uint32()));continue}case 88:{if(n!==704)break;i.embargoActive=t.bool();continue}case 89:{if(n!==712)break;i.rushNextDiceRollAt=gT(t.int64());continue}case 90:{if(n!==720)break;i.counterTradeId=t.int32();continue}case 91:{if(n!==728)break;i.stolenCommodity=t.int32();continue}case 92:{if(n!==736)break;i.freeStructureReason=t.int32();continue}case 93:{if(n!==744)break;i.freeStructureBuilding=t.int32();continue}case 94:{if(n!==752)break;i.freeDevCard=t.bool();continue}case 97:{if(n===776){i.pillagePlayers.push(t.int32());continue}if(n===778){let a=t.uint32()+t.pos;for(;t.pos<a;)i.pillagePlayers.push(t.int32());continue}break}case 98:{if(n===784){i.defenderPlayers.push(t.int32());continue}if(n===786){let a=t.uint32()+t.pos;for(;t.pos<a;)i.defenderPlayers.push(t.int32());continue}break}case 99:{if(n===792){i.poorTraders.push(t.int32());continue}if(n===794){let a=t.uint32()+t.pos;for(;t.pos<a;)i.poorTraders.push(t.int32());continue}break}case 100:{if(n===800){i.previousPoorTraders.push(t.int32());continue}if(n===802){let a=t.uint32()+t.pos;for(;t.pos<a;)i.previousPoorTraders.push(t.int32());continue}break}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return e_.fromPartial(e??{})},fromPartial(e){let r=mT();return r.type=e.type??0,r.player=e.player??0,r.dice=e.dice!==void 0&&e.dice!==null?Dt.fromPartial(e.dice):void 0,r.resources=e.resources?.map(t=>ne.fromPartial(t))||[],r.robberLocation=e.robberLocation!==void 0&&e.robberLocation!==null?q.fromPartial(e.robberLocation):void 0,r.targetPlayer=e.targetPlayer??0,r.stolenResource=e.stolenResource??0,r.edge=e.edge!==void 0&&e.edge!==null?Ie.fromPartial(e.edge):void 0,r.receivedResources=e.receivedResources?.map(t=>ne.fromPartial(t))||[],r.vertex=e.vertex!==void 0&&e.vertex!==null?ee.fromPartial(e.vertex):void 0,r.devCard=e.devCard??0,r.elapsedTimeMs=e.elapsedTimeMs??0,r.monopolyResults=e.monopolyResults?.map(t=>vt.fromPartial(t))||[],r.tradePartner=e.tradePartner??0,r.offeredResources=e.offeredResources?.map(t=>ne.fromPartial(t))||[],r.monopolyResource=e.monopolyResource??0,r.tradeId=e.tradeId??0,r.selectedResource=e.selectedResource??0,r.building=e.building??0,r.shipFromEdge=e.shipFromEdge!==void 0&&e.shipFromEdge!==null?Ie.fromPartial(e.shipFromEdge):void 0,r.shipToEdge=e.shipToEdge!==void 0&&e.shipToEdge!==null?Ie.fromPartial(e.shipToEdge):void 0,r.pirateLocation=e.pirateLocation!==void 0&&e.pirateLocation!==null?q.fromPartial(e.pirateLocation):void 0,r.knightLocation=e.knightLocation!==void 0&&e.knightLocation!==null?ee.fromPartial(e.knightLocation):void 0,r.knightDestination=e.knightDestination!==void 0&&e.knightDestination!==null?ee.fromPartial(e.knightDestination):void 0,r.knightStrength=e.knightStrength??0,r.knightStatus=e.knightStatus??0,r.improvementTrack=e.improvementTrack??0,r.improvementLevel=e.improvementLevel??0,r.commodities=e.commodities?.map(t=>te.fromPartial(t))||[],r.barbarianPosition=e.barbarianPosition??0,r.barbarianStrength=e.barbarianStrength??0,r.knightDefenseStrength=e.knightDefenseStrength??0,r.barbarianVictory=e.barbarianVictory??!1,r.progressCard=e.progressCard??0,r.progressCardTrack=e.progressCardTrack??0,r.eventDieResult=e.eventDieResult??0,r.metropolis=e.metropolis!==void 0&&e.metropolis!==null?bn.fromPartial(e.metropolis):void 0,r.previousMetropolisOwner=e.previousMetropolisOwner??0,r.merchantLocation=e.merchantLocation!==void 0&&e.merchantLocation!==null?q.fromPartial(e.merchantLocation):void 0,r.displacedKnightOwner=e.displacedKnightOwner??0,r.displacedKnightTo=e.displacedKnightTo!==void 0&&e.displacedKnightTo!==null?ee.fromPartial(e.displacedKnightTo):void 0,r.pillagedCityLocation=e.pillagedCityLocation!==void 0&&e.pillagedCityLocation!==null?ee.fromPartial(e.pillagedCityLocation):void 0,r.masterMerchantResources=e.masterMerchantResources?.map(t=>ne.fromPartial(t))||[],r.masterMerchantCommodities=e.masterMerchantCommodities?.map(t=>te.fromPartial(t))||[],r.merchantFleetResource=e.merchantFleetResource??0,r.tradeMonopolyCommodity=e.tradeMonopolyCommodity??0,r.tradeMonopolyResults=e.tradeMonopolyResults?.map(t=>vt.fromPartial(t))||[],r.inventorHex1=e.inventorHex1!==void 0&&e.inventorHex1!==null?q.fromPartial(e.inventorHex1):void 0,r.inventorHex2=e.inventorHex2!==void 0&&e.inventorHex2!==null?q.fromPartial(e.inventorHex2):void 0,r.spyVisibleProgressCards=e.spyVisibleProgressCards?.map(t=>dr.fromPartial(t))||[],r.spyStolenProgressCard=e.spyStolenProgressCard??0,r.fishTiles=e.fishTiles?.map(t=>xe.fromPartial(t))||[],r.discardedFishTiles=e.discardedFishTiles?.map(t=>xe.fromPartial(t))||[],r.fogHexLocation=e.fogHexLocation!==void 0&&e.fogHexLocation!==null?q.fromPartial(e.fogHexLocation):void 0,r.fogRevealedTerrain=e.fogRevealedTerrain??0,r.fogRevealedNumber=e.fogRevealedNumber??0,r.fogRewardResource=e.fogRewardResource??0,r.commercialHarborTrades=e.commercialHarborTrades?.map(t=>gt.fromPartial(t))||[],r.previousAwardHolder=e.previousAwardHolder??0,r.freeResourceReason=e.freeResourceReason??0,r.freeResourceCount=e.freeResourceCount??0,r.winReason=e.winReason??0,r.actionSource=e.actionSource??0,r.committedKnights=e.committedKnights?.map(t=>ee.fromPartial(t))||[],r.islandBonusVp=e.islandBonusVp??0,r.edgeRewardType=e.edgeRewardType??0,r.collectedPort=e.collectedPort!==void 0&&e.collectedPort!==null?Nr.fromPartial(e.collectedPort):void 0,r.pairedPlayer=e.pairedPlayer??0,r.resourceDistribution=e.resourceDistribution!==void 0&&e.resourceDistribution!==null?Qs.fromPartial(e.resourceDistribution):void 0,r.wagonVotes=e.wagonVotes?.map(t=>kn.fromPartial(t))||[],r.placedWagon=e.placedWagon!==void 0&&e.placedWagon!==null?Bn.fromPartial(e.placedWagon):void 0,r.goldAmount=e.goldAmount??0,r.offeredCommodities=e.offeredCommodities?.map(t=>te.fromPartial(t))||[],r.receivedCommodities=e.receivedCommodities?.map(t=>te.fromPartial(t))||[],r.offeredGold=e.offeredGold??0,r.receivedGold=e.receivedGold??0,r.trollHex=e.trollHex!==void 0&&e.trollHex!==null?q.fromPartial(e.trollHex):void 0,r.trollFishPaid=e.trollFishPaid?.map(t=>xe.fromPartial(t))||[],r.trollCount=e.trollCount??0,r.initScienceProgressDeck=e.initScienceProgressDeck?.map(t=>t)||[],r.initPoliticsProgressDeck=e.initPoliticsProgressDeck?.map(t=>t)||[],r.initTradeProgressDeck=e.initTradeProgressDeck?.map(t=>t)||[],r.initEventCardDeck=e.initEventCardDeck?.map(t=>Rr.fromPartial(t))||[],r.initRemovedEventCards=e.initRemovedEventCards?.map(t=>Rr.fromPartial(t))||[],r.initialFogReveals=e.initialFogReveals?.map(t=>Zs.fromPartial(t))||[],r.lazyRobberFrom=e.lazyRobberFrom!==void 0&&e.lazyRobberFrom!==null?q.fromPartial(e.lazyRobberFrom):void 0,r.merchantFleetCommodity=e.merchantFleetCommodity??0,r.tradeProposals=e.tradeProposals?.map(t=>Qr.fromPartial(t))||[],r.embargoActive=e.embargoActive??!1,r.rushNextDiceRollAt=e.rushNextDiceRollAt??0,r.counterTradeId=e.counterTradeId??0,r.stolenCommodity=e.stolenCommodity??0,r.freeStructureReason=e.freeStructureReason??0,r.freeStructureBuilding=e.freeStructureBuilding??0,r.freeDevCard=e.freeDevCard??!1,r.pillagePlayers=e.pillagePlayers?.map(t=>t)||[],r.defenderPlayers=e.defenderPlayers?.map(t=>t)||[],r.poorTraders=e.poorTraders?.map(t=>t)||[],r.previousPoorTraders=e.previousPoorTraders?.map(t=>t)||[],r}};function gT(e){let r=globalThis.Number(e.toString());if(r>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(r<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return r}E(gT,"longToNumber");import{BinaryReader as yT,BinaryWriter as _D}from"@bufbuild/protobuf/wire";var N;(function(e){e[e.ACTION_TYPE_UNSPECIFIED=0]="ACTION_TYPE_UNSPECIFIED",e[e.ACTION_TYPE_ROLL_DICE=1]="ACTION_TYPE_ROLL_DICE",e[e.ACTION_TYPE_BUILD_ROAD=2]="ACTION_TYPE_BUILD_ROAD",e[e.ACTION_TYPE_BUILD_SHIP=3]="ACTION_TYPE_BUILD_SHIP",e[e.ACTION_TYPE_BUILD_SETTLEMENT=4]="ACTION_TYPE_BUILD_SETTLEMENT",e[e.ACTION_TYPE_BUILD_CITY=5]="ACTION_TYPE_BUILD_CITY",e[e.ACTION_TYPE_BUY_DEV_CARD=6]="ACTION_TYPE_BUY_DEV_CARD",e[e.ACTION_TYPE_PLAY_KNIGHT=7]="ACTION_TYPE_PLAY_KNIGHT",e[e.ACTION_TYPE_PLAY_ROAD_BUILDING=8]="ACTION_TYPE_PLAY_ROAD_BUILDING",e[e.ACTION_TYPE_PLAY_YEAR_OF_PLENTY=9]="ACTION_TYPE_PLAY_YEAR_OF_PLENTY",e[e.ACTION_TYPE_PLAY_MONOPOLY=10]="ACTION_TYPE_PLAY_MONOPOLY",e[e.ACTION_TYPE_PLAY_VICTORY_POINT=11]="ACTION_TYPE_PLAY_VICTORY_POINT",e[e.ACTION_TYPE_PROPOSE_TRADE=12]="ACTION_TYPE_PROPOSE_TRADE",e[e.ACTION_TYPE_ACCEPT_TRADE=13]="ACTION_TYPE_ACCEPT_TRADE",e[e.ACTION_TYPE_REJECT_TRADE=14]="ACTION_TYPE_REJECT_TRADE",e[e.ACTION_TYPE_CANCEL_TRADE=15]="ACTION_TYPE_CANCEL_TRADE",e[e.ACTION_TYPE_EXECUTE_TRADE=16]="ACTION_TYPE_EXECUTE_TRADE",e[e.ACTION_TYPE_TRADE_WITH_BANK=17]="ACTION_TYPE_TRADE_WITH_BANK",e[e.ACTION_TYPE_END_TURN=18]="ACTION_TYPE_END_TURN",e[e.ACTION_TYPE_DISCARD_RESOURCES=19]="ACTION_TYPE_DISCARD_RESOURCES",e[e.ACTION_TYPE_MOVE_ROBBER=20]="ACTION_TYPE_MOVE_ROBBER",e[e.ACTION_TYPE_STEAL_FROM_PLAYER=21]="ACTION_TYPE_STEAL_FROM_PLAYER",e[e.ACTION_TYPE_SELECT_FREE_RESOURCE=22]="ACTION_TYPE_SELECT_FREE_RESOURCE",e[e.ACTION_TYPE_PLACE_FREE_ROAD=23]="ACTION_TYPE_PLACE_FREE_ROAD",e[e.ACTION_TYPE_PLACE_FREE_SHIP=24]="ACTION_TYPE_PLACE_FREE_SHIP",e[e.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT=25]="ACTION_TYPE_PLACE_INITIAL_SETTLEMENT",e[e.ACTION_TYPE_PLACE_INITIAL_ROAD=26]="ACTION_TYPE_PLACE_INITIAL_ROAD",e[e.ACTION_TYPE_PLACE_INITIAL_SHIP=91]="ACTION_TYPE_PLACE_INITIAL_SHIP",e[e.ACTION_TYPE_MOVE_SHIP=27]="ACTION_TYPE_MOVE_SHIP",e[e.ACTION_TYPE_MOVE_PIRATE=28]="ACTION_TYPE_MOVE_PIRATE",e[e.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE=29]="ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE",e[e.ACTION_TYPE_BUILD_KNIGHT=31]="ACTION_TYPE_BUILD_KNIGHT",e[e.ACTION_TYPE_ACTIVATE_KNIGHT=32]="ACTION_TYPE_ACTIVATE_KNIGHT",e[e.ACTION_TYPE_PROMOTE_KNIGHT=33]="ACTION_TYPE_PROMOTE_KNIGHT",e[e.ACTION_TYPE_MOVE_KNIGHT=34]="ACTION_TYPE_MOVE_KNIGHT",e[e.ACTION_TYPE_DISPLACE_KNIGHT=35]="ACTION_TYPE_DISPLACE_KNIGHT",e[e.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT=36]="ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT",e[e.ACTION_TYPE_BUILD_CITY_WALL=37]="ACTION_TYPE_BUILD_CITY_WALL",e[e.ACTION_TYPE_BUILD_CITY_IMPROVEMENT=38]="ACTION_TYPE_BUILD_CITY_IMPROVEMENT",e[e.ACTION_TYPE_PLAY_ALCHEMIST=39]="ACTION_TYPE_PLAY_ALCHEMIST",e[e.ACTION_TYPE_PLAY_CRANE=40]="ACTION_TYPE_PLAY_CRANE",e[e.ACTION_TYPE_PLAY_DESERTER=41]="ACTION_TYPE_PLAY_DESERTER",e[e.ACTION_TYPE_PLAY_INTRIGUE=42]="ACTION_TYPE_PLAY_INTRIGUE",e[e.ACTION_TYPE_PLAY_MERCHANT=43]="ACTION_TYPE_PLAY_MERCHANT",e[e.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY=44]="ACTION_TYPE_PLAY_RESOURCE_MONOPOLY",e[e.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING=45]="ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING",e[e.ACTION_TYPE_PLAY_SMITH=46]="ACTION_TYPE_PLAY_SMITH",e[e.ACTION_TYPE_PLAY_SPY=47]="ACTION_TYPE_PLAY_SPY",e[e.ACTION_TYPE_PLAY_WARLORD=48]="ACTION_TYPE_PLAY_WARLORD",e[e.ACTION_TYPE_PLAY_BISHOP=49]="ACTION_TYPE_PLAY_BISHOP",e[e.ACTION_TYPE_SELECT_ALCHEMIST_DICE=50]="ACTION_TYPE_SELECT_ALCHEMIST_DICE",e[e.ACTION_TYPE_SELECT_DEFENDER_PROGRESS=51]="ACTION_TYPE_SELECT_DEFENDER_PROGRESS",e[e.ACTION_TYPE_SELECT_CITY_TO_PILLAGE=52]="ACTION_TYPE_SELECT_CITY_TO_PILLAGE",e[e.ACTION_TYPE_COMMERCIAL_HARBOR_TRADE=53]="ACTION_TYPE_COMMERCIAL_HARBOR_TRADE",e[e.ACTION_TYPE_SELECT_SPY_TARGET_CARD=54]="ACTION_TYPE_SELECT_SPY_TARGET_CARD",e[e.ACTION_TYPE_PLAY_MASTER_MERCHANT=55]="ACTION_TYPE_PLAY_MASTER_MERCHANT",e[e.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS=56]="ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS",e[e.ACTION_TYPE_PLAY_MERCHANT_FLEET=57]="ACTION_TYPE_PLAY_MERCHANT_FLEET",e[e.ACTION_TYPE_PLAY_MEDICINE=58]="ACTION_TYPE_PLAY_MEDICINE",e[e.ACTION_TYPE_PLAY_TRADE_MONOPOLY=59]="ACTION_TYPE_PLAY_TRADE_MONOPOLY",e[e.ACTION_TYPE_PLAY_MINING=62]="ACTION_TYPE_PLAY_MINING",e[e.ACTION_TYPE_PLAY_IRRIGATION=63]="ACTION_TYPE_PLAY_IRRIGATION",e[e.ACTION_TYPE_PLAY_ENGINEER=64]="ACTION_TYPE_PLAY_ENGINEER",e[e.ACTION_TYPE_PLAY_INVENTOR=65]="ACTION_TYPE_PLAY_INVENTOR",e[e.ACTION_TYPE_PLAY_DIPLOMAT=66]="ACTION_TYPE_PLAY_DIPLOMAT",e[e.ACTION_TYPE_PLAY_SABOTEUR=67]="ACTION_TYPE_PLAY_SABOTEUR",e[e.ACTION_TYPE_PLAY_WEDDING=68]="ACTION_TYPE_PLAY_WEDDING",e[e.ACTION_TYPE_GIVE_WEDDING_CARDS=69]="ACTION_TYPE_GIVE_WEDDING_CARDS",e[e.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR=70]="ACTION_TYPE_PLAY_COMMERCIAL_HARBOR",e[e.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY=71]="ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY",e[e.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE=72]="ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE",e[e.ACTION_TYPE_PASS_OLD_BOOT=73]="ACTION_TYPE_PASS_OLD_BOOT",e[e.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER=74]="ACTION_TYPE_SPEND_FISH_BANISH_ROBBER",e[e.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE=75]="ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE",e[e.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE=76]="ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE",e[e.ACTION_TYPE_SPEND_FISH_BUILD_ROAD=77]="ACTION_TYPE_SPEND_FISH_BUILD_ROAD",e[e.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD=78]="ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD",e[e.ACTION_TYPE_RESIGN=79]="ACTION_TYPE_RESIGN",e[e.ACTION_TYPE_PAUSE=80]="ACTION_TYPE_PAUSE",e[e.ACTION_TYPE_UNPAUSE=81]="ACTION_TYPE_UNPAUSE",e[e.ACTION_TYPE_VOTE_TO_CONTINUE=82]="ACTION_TYPE_VOTE_TO_CONTINUE",e[e.ACTION_TYPE_USE_KNIGHT_ERRANT=83]="ACTION_TYPE_USE_KNIGHT_ERRANT",e[e.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE=84]="ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE",e[e.ACTION_TYPE_PLACE_PORT=85]="ACTION_TYPE_PLACE_PORT",e[e.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD=86]="ACTION_TYPE_SELECT_EARTHQUAKE_ROAD",e[e.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE=88]="ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE",e[e.ACTION_TYPE_EVENT_CARD_STEAL=89]="ACTION_TYPE_EVENT_CARD_STEAL",e[e.ACTION_TYPE_WAGON_VOTE=90]="ACTION_TYPE_WAGON_VOTE",e[e.ACTION_TYPE_FEED_TROLL=92]="ACTION_TYPE_FEED_TROLL",e[e.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT=93]="ACTION_TYPE_KICK_TROLL_WITH_KNIGHT",e[e.ACTION_TYPE_SELECT_DESERTER_KNIGHT=94]="ACTION_TYPE_SELECT_DESERTER_KNIGHT",e[e.ACTION_TYPE_SELECT_METROPOLIS_CITY=95]="ACTION_TYPE_SELECT_METROPOLIS_CITY",e[e.ACTION_TYPE_VOTE_DICE_ROLL=96]="ACTION_TYPE_VOTE_DICE_ROLL",e[e.ACTION_TYPE_PROPOSE_MULTI_TRADE=97]="ACTION_TYPE_PROPOSE_MULTI_TRADE",e[e.ACTION_TYPE_TOGGLE_TRADE_EMBARGO=98]="ACTION_TYPE_TOGGLE_TRADE_EMBARGO",e[e.ACTION_TYPE_DISCARD_PROGRESS_CARD=99]="ACTION_TYPE_DISCARD_PROGRESS_CARD",e[e.ACTION_TYPE_BUY_PROGRESS_CARD=100]="ACTION_TYPE_BUY_PROGRESS_CARD",e[e.ACTION_TYPE_BUILD_BRIDGE=101]="ACTION_TYPE_BUILD_BRIDGE",e[e.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD=102]="ACTION_TYPE_BUY_RESOURCE_WITH_GOLD",e[e.ACTION_TYPE_BUY_GOLD=103]="ACTION_TYPE_BUY_GOLD",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(N||(N={}));function MT(){return{type:0,player:0,edge:void 0,vertex:void 0,robberLocation:void 0,targetPlayer:0,resource:0,resources:[],offering:[],requesting:[],tradeId:0,tradePartner:0,fromEdge:void 0,toEdge:void 0,pirateLocation:void 0,knightLocation:void 0,knightDestination:void 0,knightTargetHex:void 0,improvementTrack:0,cityWallLocation:void 0,alchemistDie1:0,alchemistDie2:0,merchantLocation:void 0,progressCard:0,spyTargetPlayer:0,spyStolenCard:0,deserterTargetPlayer:0,deserterKnightLocation:void 0,pillageCityLocation:void 0,commodities:[],commodity:0,inventorHex1:void 0,inventorHex2:void 0,commercialHarborTrades:[],committedKnights:[],woolBid:0,wheatBid:0,preferredWagonEdge:void 0,preferredWagonFacing:0,offeringCommodities:[],requestingCommodities:[],offeringGold:0,requestingGold:0,trollHex:void 0,trollFish:[],metropolisCityLocation:void 0,tradeProposals:[],counterTradeId:0}}E(MT,"createBasePlayerActionProto");var H={encode(e,r=new _D){e.type!==0&&r.uint32(8).int32(e.type),e.player!==0&&r.uint32(16).int32(e.player),e.edge!==void 0&&Ie.encode(e.edge,r.uint32(26).fork()).join(),e.vertex!==void 0&&ee.encode(e.vertex,r.uint32(34).fork()).join(),e.robberLocation!==void 0&&q.encode(e.robberLocation,r.uint32(42).fork()).join(),e.targetPlayer!==0&&r.uint32(48).int32(e.targetPlayer),e.resource!==0&&r.uint32(56).int32(e.resource);for(let t of e.resources)ne.encode(t,r.uint32(66).fork()).join();for(let t of e.offering)ne.encode(t,r.uint32(74).fork()).join();for(let t of e.requesting)ne.encode(t,r.uint32(82).fork()).join();e.tradeId!==0&&r.uint32(88).int32(e.tradeId),e.tradePartner!==0&&r.uint32(96).int32(e.tradePartner),e.fromEdge!==void 0&&Ie.encode(e.fromEdge,r.uint32(106).fork()).join(),e.toEdge!==void 0&&Ie.encode(e.toEdge,r.uint32(114).fork()).join(),e.pirateLocation!==void 0&&q.encode(e.pirateLocation,r.uint32(122).fork()).join(),e.knightLocation!==void 0&&ee.encode(e.knightLocation,r.uint32(130).fork()).join(),e.knightDestination!==void 0&&ee.encode(e.knightDestination,r.uint32(138).fork()).join(),e.knightTargetHex!==void 0&&q.encode(e.knightTargetHex,r.uint32(146).fork()).join(),e.improvementTrack!==0&&r.uint32(152).int32(e.improvementTrack),e.cityWallLocation!==void 0&&ee.encode(e.cityWallLocation,r.uint32(162).fork()).join(),e.alchemistDie1!==0&&r.uint32(168).int32(e.alchemistDie1),e.alchemistDie2!==0&&r.uint32(176).int32(e.alchemistDie2),e.merchantLocation!==void 0&&q.encode(e.merchantLocation,r.uint32(186).fork()).join(),e.progressCard!==0&&r.uint32(192).int32(e.progressCard),e.spyTargetPlayer!==0&&r.uint32(200).int32(e.spyTargetPlayer),e.spyStolenCard!==0&&r.uint32(208).int32(e.spyStolenCard),e.deserterTargetPlayer!==0&&r.uint32(256).int32(e.deserterTargetPlayer),e.deserterKnightLocation!==void 0&&ee.encode(e.deserterKnightLocation,r.uint32(362).fork()).join(),e.pillageCityLocation!==void 0&&ee.encode(e.pillageCityLocation,r.uint32(218).fork()).join();for(let t of e.commodities)te.encode(t,r.uint32(226).fork()).join();e.commodity!==0&&r.uint32(232).int32(e.commodity),e.inventorHex1!==void 0&&q.encode(e.inventorHex1,r.uint32(242).fork()).join(),e.inventorHex2!==void 0&&q.encode(e.inventorHex2,r.uint32(250).fork()).join();for(let t of e.commercialHarborTrades)gt.encode(t,r.uint32(266).fork()).join();for(let t of e.committedKnights)ee.encode(t,r.uint32(274).fork()).join();e.woolBid!==0&&r.uint32(280).int32(e.woolBid),e.wheatBid!==0&&r.uint32(288).int32(e.wheatBid),e.preferredWagonEdge!==void 0&&Ie.encode(e.preferredWagonEdge,r.uint32(298).fork()).join(),e.preferredWagonFacing!==0&&r.uint32(304).int32(e.preferredWagonFacing);for(let t of e.offeringCommodities)te.encode(t,r.uint32(314).fork()).join();for(let t of e.requestingCommodities)te.encode(t,r.uint32(322).fork()).join();e.offeringGold!==0&&r.uint32(328).int32(e.offeringGold),e.requestingGold!==0&&r.uint32(336).int32(e.requestingGold),e.trollHex!==void 0&&q.encode(e.trollHex,r.uint32(346).fork()).join();for(let t of e.trollFish)xe.encode(t,r.uint32(354).fork()).join();e.metropolisCityLocation!==void 0&&ee.encode(e.metropolisCityLocation,r.uint32(370).fork()).join();for(let t of e.tradeProposals)Qr.encode(t,r.uint32(378).fork()).join();return e.counterTradeId!==0&&r.uint32(384).int32(e.counterTradeId),r},decode(e,r){let t=e instanceof yT?e:new yT(e),o=r===void 0?t.len:t.pos+r,i=MT();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.type=t.int32();continue}case 2:{if(n!==16)break;i.player=t.int32();continue}case 3:{if(n!==26)break;i.edge=Ie.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.vertex=ee.decode(t,t.uint32());continue}case 5:{if(n!==42)break;i.robberLocation=q.decode(t,t.uint32());continue}case 6:{if(n!==48)break;i.targetPlayer=t.int32();continue}case 7:{if(n!==56)break;i.resource=t.int32();continue}case 8:{if(n!==66)break;i.resources.push(ne.decode(t,t.uint32()));continue}case 9:{if(n!==74)break;i.offering.push(ne.decode(t,t.uint32()));continue}case 10:{if(n!==82)break;i.requesting.push(ne.decode(t,t.uint32()));continue}case 11:{if(n!==88)break;i.tradeId=t.int32();continue}case 12:{if(n!==96)break;i.tradePartner=t.int32();continue}case 13:{if(n!==106)break;i.fromEdge=Ie.decode(t,t.uint32());continue}case 14:{if(n!==114)break;i.toEdge=Ie.decode(t,t.uint32());continue}case 15:{if(n!==122)break;i.pirateLocation=q.decode(t,t.uint32());continue}case 16:{if(n!==130)break;i.knightLocation=ee.decode(t,t.uint32());continue}case 17:{if(n!==138)break;i.knightDestination=ee.decode(t,t.uint32());continue}case 18:{if(n!==146)break;i.knightTargetHex=q.decode(t,t.uint32());continue}case 19:{if(n!==152)break;i.improvementTrack=t.int32();continue}case 20:{if(n!==162)break;i.cityWallLocation=ee.decode(t,t.uint32());continue}case 21:{if(n!==168)break;i.alchemistDie1=t.int32();continue}case 22:{if(n!==176)break;i.alchemistDie2=t.int32();continue}case 23:{if(n!==186)break;i.merchantLocation=q.decode(t,t.uint32());continue}case 24:{if(n!==192)break;i.progressCard=t.int32();continue}case 25:{if(n!==200)break;i.spyTargetPlayer=t.int32();continue}case 26:{if(n!==208)break;i.spyStolenCard=t.int32();continue}case 32:{if(n!==256)break;i.deserterTargetPlayer=t.int32();continue}case 45:{if(n!==362)break;i.deserterKnightLocation=ee.decode(t,t.uint32());continue}case 27:{if(n!==218)break;i.pillageCityLocation=ee.decode(t,t.uint32());continue}case 28:{if(n!==226)break;i.commodities.push(te.decode(t,t.uint32()));continue}case 29:{if(n!==232)break;i.commodity=t.int32();continue}case 30:{if(n!==242)break;i.inventorHex1=q.decode(t,t.uint32());continue}case 31:{if(n!==250)break;i.inventorHex2=q.decode(t,t.uint32());continue}case 33:{if(n!==266)break;i.commercialHarborTrades.push(gt.decode(t,t.uint32()));continue}case 34:{if(n!==274)break;i.committedKnights.push(ee.decode(t,t.uint32()));continue}case 35:{if(n!==280)break;i.woolBid=t.int32();continue}case 36:{if(n!==288)break;i.wheatBid=t.int32();continue}case 37:{if(n!==298)break;i.preferredWagonEdge=Ie.decode(t,t.uint32());continue}case 38:{if(n!==304)break;i.preferredWagonFacing=t.int32();continue}case 39:{if(n!==314)break;i.offeringCommodities.push(te.decode(t,t.uint32()));continue}case 40:{if(n!==322)break;i.requestingCommodities.push(te.decode(t,t.uint32()));continue}case 41:{if(n!==328)break;i.offeringGold=t.int32();continue}case 42:{if(n!==336)break;i.requestingGold=t.int32();continue}case 43:{if(n!==346)break;i.trollHex=q.decode(t,t.uint32());continue}case 44:{if(n!==354)break;i.trollFish.push(xe.decode(t,t.uint32()));continue}case 46:{if(n!==370)break;i.metropolisCityLocation=ee.decode(t,t.uint32());continue}case 47:{if(n!==378)break;i.tradeProposals.push(Qr.decode(t,t.uint32()));continue}case 48:{if(n!==384)break;i.counterTradeId=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},create(e){return H.fromPartial(e??{})},fromPartial(e){let r=MT();return r.type=e.type??0,r.player=e.player??0,r.edge=e.edge!==void 0&&e.edge!==null?Ie.fromPartial(e.edge):void 0,r.vertex=e.vertex!==void 0&&e.vertex!==null?ee.fromPartial(e.vertex):void 0,r.robberLocation=e.robberLocation!==void 0&&e.robberLocation!==null?q.fromPartial(e.robberLocation):void 0,r.targetPlayer=e.targetPlayer??0,r.resource=e.resource??0,r.resources=e.resources?.map(t=>ne.fromPartial(t))||[],r.offering=e.offering?.map(t=>ne.fromPartial(t))||[],r.requesting=e.requesting?.map(t=>ne.fromPartial(t))||[],r.tradeId=e.tradeId??0,r.tradePartner=e.tradePartner??0,r.fromEdge=e.fromEdge!==void 0&&e.fromEdge!==null?Ie.fromPartial(e.fromEdge):void 0,r.toEdge=e.toEdge!==void 0&&e.toEdge!==null?Ie.fromPartial(e.toEdge):void 0,r.pirateLocation=e.pirateLocation!==void 0&&e.pirateLocation!==null?q.fromPartial(e.pirateLocation):void 0,r.knightLocation=e.knightLocation!==void 0&&e.knightLocation!==null?ee.fromPartial(e.knightLocation):void 0,r.knightDestination=e.knightDestination!==void 0&&e.knightDestination!==null?ee.fromPartial(e.knightDestination):void 0,r.knightTargetHex=e.knightTargetHex!==void 0&&e.knightTargetHex!==null?q.fromPartial(e.knightTargetHex):void 0,r.improvementTrack=e.improvementTrack??0,r.cityWallLocation=e.cityWallLocation!==void 0&&e.cityWallLocation!==null?ee.fromPartial(e.cityWallLocation):void 0,r.alchemistDie1=e.alchemistDie1??0,r.alchemistDie2=e.alchemistDie2??0,r.merchantLocation=e.merchantLocation!==void 0&&e.merchantLocation!==null?q.fromPartial(e.merchantLocation):void 0,r.progressCard=e.progressCard??0,r.spyTargetPlayer=e.spyTargetPlayer??0,r.spyStolenCard=e.spyStolenCard??0,r.deserterTargetPlayer=e.deserterTargetPlayer??0,r.deserterKnightLocation=e.deserterKnightLocation!==void 0&&e.deserterKnightLocation!==null?ee.fromPartial(e.deserterKnightLocation):void 0,r.pillageCityLocation=e.pillageCityLocation!==void 0&&e.pillageCityLocation!==null?ee.fromPartial(e.pillageCityLocation):void 0,r.commodities=e.commodities?.map(t=>te.fromPartial(t))||[],r.commodity=e.commodity??0,r.inventorHex1=e.inventorHex1!==void 0&&e.inventorHex1!==null?q.fromPartial(e.inventorHex1):void 0,r.inventorHex2=e.inventorHex2!==void 0&&e.inventorHex2!==null?q.fromPartial(e.inventorHex2):void 0,r.commercialHarborTrades=e.commercialHarborTrades?.map(t=>gt.fromPartial(t))||[],r.committedKnights=e.committedKnights?.map(t=>ee.fromPartial(t))||[],r.woolBid=e.woolBid??0,r.wheatBid=e.wheatBid??0,r.preferredWagonEdge=e.preferredWagonEdge!==void 0&&e.preferredWagonEdge!==null?Ie.fromPartial(e.preferredWagonEdge):void 0,r.preferredWagonFacing=e.preferredWagonFacing??0,r.offeringCommodities=e.offeringCommodities?.map(t=>te.fromPartial(t))||[],r.requestingCommodities=e.requestingCommodities?.map(t=>te.fromPartial(t))||[],r.offeringGold=e.offeringGold??0,r.requestingGold=e.requestingGold??0,r.trollHex=e.trollHex!==void 0&&e.trollHex!==null?q.fromPartial(e.trollHex):void 0,r.trollFish=e.trollFish?.map(t=>xe.fromPartial(t))||[],r.metropolisCityLocation=e.metropolisCityLocation!==void 0&&e.metropolisCityLocation!==null?ee.fromPartial(e.metropolisCityLocation):void 0,r.tradeProposals=e.tradeProposals?.map(t=>Qr.fromPartial(t))||[],r.counterTradeId=e.counterTradeId??0,r}};var ci=class{static{E(this,"Point")}x;y;z;constructor(r,t,o){this.x=r,this.y=t,this.z=o}get total(){return this.x+this.y+this.z}get multiplied(){return this.x*this.y*this.z}equals(r){return this.x===r.x&&this.y===r.y&&this.z===r.z}toString(){return`${this.x},${this.y},${this.z}`}};var fi=class{static{E(this,"Direction")}dx;dy;dz;constructor(r,t,o){this.dx=r,this.dy=t,this.dz=o}total(){return this.dx+this.dy+this.dz}equals(r){return this.dx===r.dx&&this.dy===r.dy&&this.dz===r.dz}abs(){return Math.abs(this.dx)+Math.abs(this.dy)+Math.abs(this.dz)}};var C=class e extends fi{static{E(this,"HexDirection")}static NORTH_EAST=new e(1,-1,0);static EAST=new e(1,0,-1);static SOUTH_EAST=new e(0,1,-1);static SOUTH_WEST=new e(-1,1,0);static WEST=new e(-1,0,1);static NORTH_WEST=new e(0,-1,1);static ALL=[e.EAST,e.SOUTH_EAST,e.SOUTH_WEST,e.WEST,e.NORTH_WEST,e.NORTH_EAST];constructor(r,t,o){super(r,t,o)}static fromString(r){if(r==="E")return e.EAST;if(r==="SE")return e.SOUTH_EAST;if(r==="SW")return e.SOUTH_WEST;if(r==="W")return e.WEST;if(r==="NW")return e.NORTH_WEST;if(r==="NE")return e.NORTH_EAST;throw new Error("not a direction")}static fromProto(r){switch(r){case vr.HEX_DIRECTION_TYPE_EAST:return e.EAST;case vr.HEX_DIRECTION_TYPE_SOUTH_EAST:return e.SOUTH_EAST;case vr.HEX_DIRECTION_TYPE_SOUTH_WEST:return e.SOUTH_WEST;case vr.HEX_DIRECTION_TYPE_WEST:return e.WEST;case vr.HEX_DIRECTION_TYPE_NORTH_WEST:return e.NORTH_WEST;case vr.HEX_DIRECTION_TYPE_NORTH_EAST:return e.NORTH_EAST;default:throw new Error(`Invalid HexDirectionType: ${r}`)}}opposite(){if(this.equals(e.NORTH_EAST))return e.SOUTH_WEST;if(this.equals(e.EAST))return e.WEST;if(this.equals(e.NORTH_WEST))return e.SOUTH_EAST;if(this.equals(e.SOUTH_WEST))return e.NORTH_EAST;if(this.equals(e.WEST))return e.EAST;if(this.equals(e.SOUTH_EAST))return e.NORTH_WEST;throw new Error(`uh oh, don't recognize direction ${this.toString()}`)}rotateLeft(){if(this.equals(e.NORTH_EAST))return e.NORTH_WEST;if(this.equals(e.EAST))return e.NORTH_EAST;if(this.equals(e.NORTH_WEST))return e.WEST;if(this.equals(e.SOUTH_WEST))return e.SOUTH_EAST;if(this.equals(e.WEST))return e.SOUTH_WEST;if(this.equals(e.SOUTH_EAST))return e.EAST;throw new Error(`uh oh, don't recognize direction ${this.toString()}`)}rotateRight(){if(this.equals(e.NORTH_EAST))return e.EAST;if(this.equals(e.EAST))return e.SOUTH_EAST;if(this.equals(e.NORTH_WEST))return e.NORTH_EAST;if(this.equals(e.SOUTH_WEST))return e.WEST;if(this.equals(e.WEST))return e.NORTH_WEST;if(this.equals(e.SOUTH_EAST))return e.SOUTH_WEST;throw new Error(`uh oh, don't recognize direction ${this.toString()}`)}isEasterly(){return this.equals(e.EAST)||this.equals(e.SOUTH_EAST)||this.equals(e.NORTH_EAST)}toString(){if(this.equals(e.EAST))return"E";if(this.equals(e.SOUTH_EAST))return"SE";if(this.equals(e.SOUTH_WEST))return"SW";if(this.equals(e.WEST))return"W";if(this.equals(e.NORTH_WEST))return"NW";if(this.equals(e.NORTH_EAST))return"NE";throw new Error("not a direction")}toProto(){if(this.equals(e.EAST))return vr.HEX_DIRECTION_TYPE_EAST;if(this.equals(e.SOUTH_EAST))return vr.HEX_DIRECTION_TYPE_SOUTH_EAST;if(this.equals(e.SOUTH_WEST))return vr.HEX_DIRECTION_TYPE_SOUTH_WEST;if(this.equals(e.WEST))return vr.HEX_DIRECTION_TYPE_WEST;if(this.equals(e.NORTH_WEST))return vr.HEX_DIRECTION_TYPE_NORTH_WEST;if(this.equals(e.NORTH_EAST))return vr.HEX_DIRECTION_TYPE_NORTH_EAST;throw new Error("not a direction")}};var Ce=class e extends fi{static{E(this,"VertexDirection")}static NORTH=new e(0,-1,0);static NORTH_EAST=new e(1,0,0);static NORTH_WEST=new e(0,0,1);static SOUTH=new e(0,1,0);static SOUTH_EAST=new e(-1,0,0);static SOUTH_WEST=new e(0,0,-1);static POS_DIRS=[e.NORTH_EAST,e.NORTH_WEST,e.SOUTH];static NEG_DIRS=[e.NORTH,e.SOUTH_EAST,e.SOUTH_WEST];static ALL=[e.NORTH,e.NORTH_EAST,e.NORTH_WEST,e.SOUTH,e.SOUTH_EAST,e.SOUTH_WEST];constructor(r,t,o){super(r,t,o)}static fromInt(r){if(r===0)return e.NORTH;if(r===1)return e.NORTH_EAST;if(r===2)return e.NORTH_WEST;if(r===3)return e.SOUTH;if(r===4)return e.SOUTH_EAST;if(r===5)return e.SOUTH_WEST;throw new Error("wtf, not a direction")}static fromString(r){switch(r){case"N":return e.NORTH;case"NE":return e.NORTH_EAST;case"NW":return e.NORTH_WEST;case"S":return e.SOUTH;case"SE":return e.SOUTH_EAST;case"SW":return e.SOUTH_WEST}throw new Error("wtf, not a direction")}static fromProto(r){switch(r){case Dr.VERTEX_DIRECTION_TYPE_NORTH:return e.NORTH;case Dr.VERTEX_DIRECTION_TYPE_NORTH_EAST:return e.NORTH_EAST;case Dr.VERTEX_DIRECTION_TYPE_NORTH_WEST:return e.NORTH_WEST;case Dr.VERTEX_DIRECTION_TYPE_SOUTH:return e.SOUTH;case Dr.VERTEX_DIRECTION_TYPE_SOUTH_EAST:return e.SOUTH_EAST;case Dr.VERTEX_DIRECTION_TYPE_SOUTH_WEST:return e.SOUTH_WEST;default:throw new Error(`Invalid VertexDirectionType: ${r}`)}}rotateLeft(){if(this.equals(e.NORTH))return e.NORTH_WEST;if(this.equals(e.NORTH_EAST))return e.NORTH;if(this.equals(e.NORTH_WEST))return e.SOUTH_WEST;if(this.equals(e.SOUTH))return e.SOUTH_EAST;if(this.equals(e.SOUTH_EAST))return e.NORTH_EAST;if(this.equals(e.SOUTH_WEST))return e.SOUTH;throw new Error("wtf, not a direction")}rotateRight(){if(this.equals(e.NORTH))return e.NORTH_EAST;if(this.equals(e.NORTH_EAST))return e.SOUTH_EAST;if(this.equals(e.NORTH_WEST))return e.NORTH;if(this.equals(e.SOUTH))return e.SOUTH_WEST;if(this.equals(e.SOUTH_EAST))return e.SOUTH;if(this.equals(e.SOUTH_WEST))return e.NORTH_WEST;throw new Error("wtf, not a direction")}toString(){if(this.equals(e.NORTH))return"N";if(this.equals(e.NORTH_EAST))return"NE";if(this.equals(e.NORTH_WEST))return"NW";if(this.equals(e.SOUTH))return"S";if(this.equals(e.SOUTH_EAST))return"SE";if(this.equals(e.SOUTH_WEST))return"SW";throw new Error("wtf, not a direction")}toInt(){if(this.equals(e.NORTH))return 0;if(this.equals(e.NORTH_EAST))return 1;if(this.equals(e.NORTH_WEST))return 2;if(this.equals(e.SOUTH))return 3;if(this.equals(e.SOUTH_EAST))return 4;if(this.equals(e.SOUTH_WEST))return 5;throw new Error("wtf, not a direction")}toProto(){if(this.equals(e.NORTH))return Dr.VERTEX_DIRECTION_TYPE_NORTH;if(this.equals(e.NORTH_EAST))return Dr.VERTEX_DIRECTION_TYPE_NORTH_EAST;if(this.equals(e.NORTH_WEST))return Dr.VERTEX_DIRECTION_TYPE_NORTH_WEST;if(this.equals(e.SOUTH))return Dr.VERTEX_DIRECTION_TYPE_SOUTH;if(this.equals(e.SOUTH_EAST))return Dr.VERTEX_DIRECTION_TYPE_SOUTH_EAST;if(this.equals(e.SOUTH_WEST))return Dr.VERTEX_DIRECTION_TYPE_SOUTH_WEST;throw new Error("wtf, not a direction")}};var oe=class e extends ci{static{E(this,"VertexPoint")}static fromProto(r){return new e(r.x,r.y,r.z)}static ofShortString(r,t){let[o,i]=r.split(",").map(n=>parseInt(n));return e.ofShortCords(o,i,t)}static ofShortCords(r,t,o){return new e(r,t,-1*(r+t)+o)}static ofString(r){if(r===void 0||r.length==0)return console.warn(`bad vertex point string ${r}`),new e(1,-2,3);let t=r.split(",");return new e(parseInt(t[0]),parseInt(t[1]),parseInt(t[2]))}static sort(r,t){return r.x!=t.x?t.x-r.x:r.y!=t.y?t.y-r.y:r.z!=t.z?t.z-r.z:0}static _indexToString(r){switch(r){case 0:return"1,-2,3";case 1:return"1,-2,2";case 2:return"1,-1,2";case 3:return"0,-1,2";case 4:return"0,-1,3";case 5:return"0,-2,3";case 6:return"0,0,2";case 7:return"-1,0,2";case 8:return"-1,0,3";case 9:return"-1,-1,3";case 10:return"-1,1,2";case 11:return"-2,1,2";case 12:return"-2,1,3";case 13:return"-2,0,3";case 14:return"-1,1,1";case 15:return"-1,2,1";case 16:return"-2,2,1";case 17:return"-2,2,2";case 18:return"-1,2,0";case 19:return"-1,3,0";case 20:return"-2,3,0";case 21:return"-2,3,1";case 22:return"0,2,0";case 23:return"0,2,-1";case 24:return"0,3,-1";case 25:return"-1,3,-1";case 26:return"1,2,-1";case 27:return"1,2,-2";case 28:return"1,3,-2";case 29:return"0,3,-2";case 30:return"2,1,-1";case 31:return"2,1,-2";case 32:return"2,2,-2";case 33:return"1,1,-1";case 34:return"3,0,-1";case 35:return"3,0,-2";case 36:return"3,1,-2";case 37:return"2,0,-1";case 38:return"3,-1,0";case 39:return"3,-1,-1";case 40:return"2,0,0";case 41:return"2,-1,0";case 42:return"3,-2,1";case 43:return"3,-2,0";case 44:return"2,-1,1";case 45:return"2,-2,1";case 46:return"2,-2,2";case 47:return"1,-1,1";case 48:return"1,0,1";case 49:return"0,0,1";case 50:return"0,1,1";case 51:return"0,1,0";case 52:return"1,1,0";case 53:return"1,0,0";default:return"Unknown"}}static ofStandardBoardVertexIndex(r){let t=e._indexToString(r);return e.ofString(t)}constructor(r,t,o){if(super(r,t,o),!(this.total===1||this.total===2))throw new Error(`Bad coordinates for VertexPoint ${this.toString()}, total is ${this.total}`)}toProto(){return ee.create({x:this.x,y:this.y,z:this.z})}add(r){return new e(this.x+r.dx,this.y+r.dy,this.z+r.dz)}addToCenter(r){return new _(this.x+r.dx,this.y+r.dy,this.z+r.dz)}getValidDirectionsToOtherVerticies(){if(this.total===1)return Ce.POS_DIRS;if(this.total===2)return Ce.NEG_DIRS;throw new Error(`no valid directions for ${this.toString()}`)}getAdjacentVerticies(){return this.getValidDirectionsToOtherVerticies().map(r=>this.add(r))}getHexCenters(){if(this.total===1)return Ce.NEG_DIRS.map(r=>this.addToCenter(r));if(this.total===2)return[this.add(Ce.SOUTH_WEST).addToCenter(Ce.NORTH),this.add(Ce.SOUTH_WEST).addToCenter(Ce.SOUTH_EAST),this.add(Ce.SOUTH_EAST).addToCenter(Ce.NORTH)];throw new Error(`no hex points for ${this.toString()}`)}getEdges(){return this.getAdjacentVerticies().map(r=>new Ne(this,r))}getEdgeInDirection(r){if(!this.getValidDirectionsToOtherVerticies().some(o=>r.equals(o)))throw new Error(`${r} is not a valid direction for vertex ${this.toString()}`);return new Ne(this,this.add(r))}getEdgeTo(r){if(!this.getAdjacentVerticies().some(i=>i.equals(r)))throw new Error(`Vertices ${this.toString()} and ${r.toString()} are not adjacent. Cannot create edge between non-adjacent vertices.`);return new Ne(this,r)}isAdjacentTo(r){return this.getAdjacentVerticies().some(o=>o.equals(r))}toStandardBoardVertexIndexAndEdge(r){if(!r.hasVertex(this))throw new Error("only works when the edge is adjacent to this vertex");let t=r.getOtherVertex(this),o=this.getValidDirectionsToOtherVerticies().filter(a=>this.add(a).equals(t));if(o.length===0)throw new Error("no matches found, this is very weird and should never happen");let i=o[0],n=this.getValidDirectionsToOtherVerticies().map(a=>a.toString()).indexOf(i.toString());return 4*this.standardBoardToVertexPointIndex()+n}toShortInts(){return[this.x,this.y]}toInts(){return[this.x,this.y,this.total]}toShortString(){return`${this.x},${this.y}`}toString(){return`${this.x},${this.y},${this.z}`}standardBoardToVertexPointIndex(){switch(this.toString()){case"1,-2,3":return 0;case"1,-2,2":return 1;case"1,-1,2":return 2;case"0,-1,2":return 3;case"0,-1,3":return 4;case"0,-2,3":return 5;case"0,0,2":return 6;case"-1,0,2":return 7;case"-1,0,3":return 8;case"-1,-1,3":return 9;case"-1,1,2":return 10;case"-2,1,2":return 11;case"-2,1,3":return 12;case"-2,0,3":return 13;case"-1,1,1":return 14;case"-1,2,1":return 15;case"-2,2,1":return 16;case"-2,2,2":return 17;case"-1,2,0":return 18;case"-1,3,0":return 19;case"-2,3,0":return 20;case"-2,3,1":return 21;case"0,2,0":return 22;case"0,2,-1":return 23;case"0,3,-1":return 24;case"-1,3,-1":return 25;case"1,2,-1":return 26;case"1,2,-2":return 27;case"1,3,-2":return 28;case"0,3,-2":return 29;case"2,1,-1":return 30;case"2,1,-2":return 31;case"2,2,-2":return 32;case"1,1,-1":return 33;case"3,0,-1":return 34;case"3,0,-2":return 35;case"3,1,-2":return 36;case"2,0,-1":return 37;case"3,-1,0":return 38;case"3,-1,-1":return 39;case"2,0,0":return 40;case"2,-1,0":return 41;case"3,-2,1":return 42;case"3,-2,0":return 43;case"2,-1,1":return 44;case"2,-2,1":return 45;case"2,-2,2":return 46;case"1,-1,1":return 47;case"1,0,1":return 48;case"0,0,1":return 49;case"0,1,1":return 50;case"0,1,0":return 51;case"1,1,0":return 52;case"1,0,0":return 53;default:return-1}}};var Ne=class e{static{E(this,"EdgePoint")}vertex;direction;static fromProto(r){if(!r.vertex)throw new Error("EdgePointProto must have vertex");return new e(oe.fromProto(r.vertex),oe.fromProto(r.vertex).add(Ce.fromProto(r.direction)))}static ofString(r){if(r===void 0||r.length===0){console.warn(`bad edge string ${r}`);let n=new oe(1,-2,3);return new e(n,n.add(n.getValidDirectionsToOtherVerticies()[0]))}let t=r.split(","),o=oe.ofShortCords(parseInt(t[0]),parseInt(t[1]),1),i=Ce.fromInt(parseInt(t[2]));return new e(o,o.add(i))}static ofInts(r,t,o){let i=oe.ofShortCords(r,t,1),n=Ce.fromInt(o);return new e(i,i.add(n))}static getStandardBoardVertexAndEdge(r){let t=oe.ofStandardBoardVertexIndex(Math.floor(r/4)),o=t.getValidDirectionsToOtherVerticies()[r%4];return[t,t.getEdgeInDirection(o)]}constructor(r,t){if(Math.abs(r.x-t.x)+Math.abs(r.y-t.y)+Math.abs(r.z-t.z)!==1)throw new Error(`Edge can only have verticies 1 apart, ${r.toString()} ${t.toString()}`);if(r.total===1){this.vertex=r;let o=Ce.POS_DIRS.find(i=>r.add(i).equals(t));if(!o)throw new Error(`Could not find direction from ${r.toString()} to ${t.toString()}`);this.direction=o}else{this.vertex=t;let o=Ce.POS_DIRS.find(i=>t.add(i).equals(r));if(!o)throw new Error(`Could not find direction from ${t.toString()} to ${r.toString()}`);this.direction=o}}toProto(){return Ie.create({vertex:this.vertex.toProto(),direction:this.direction.toProto()})}get v1(){return this.vertex}get v2(){return this.vertex.add(this.direction)}get verticies(){return[this.v1,this.v2]}equals(r){return this===void 0||r===void 0?this===r:this.vertex.equals(r.vertex)&&this.direction.equals(r.direction)}getOtherVertex(r){if(this.v1.equals(r))return this.v2;if(this.v2.equals(r))return this.v1;throw new Error("Called without a valid vertex")}isNeighborsWith(r){return this.v1.equals(r.v1)||this.v1.equals(r.v2)||this.v2.equals(r.v1)||this.v2.equals(r.v2)}hasVertex(r){return this.v1.equals(r)||this.v2.equals(r)}getSharedVertexWith(r){if(this.isNeighborsWith(r))return this.v1.equals(r.v1)||this.v1.equals(r.v2)?this.v1:this.v2}connectsTo(r){return this.isNeighborsWith(r)}getSharedVertex(r){return this.getSharedVertexWith(r)}getAdjacentCenters(){let r=this.v1.getHexCenters(),t=this.v2.getHexCenters();return r.filter(o=>t.some(i=>i.equals(o)))}getFourTouchingCenters(){let r=this.v1.getHexCenters();return this.v2.getHexCenters().filter(o=>!r.some(i=>i.equals(o))).forEach(o=>r.push(o)),r}getNeighboringEdgesForVertex(r){if(!this.v1.equals(r)&&!this.v2.equals(r))throw new Error("Can only be called with a vertex connected to this edge");return r.getEdges().filter(t=>!t.equals(this))}getNeighboringEdges(){return this.v1.getEdges().concat(this.v2.getEdges()).filter(r=>!r.equals(this))}directionWhenTravelingTo(r){let t=this.getOtherVertex(r);return Ce.ALL.filter(o=>t.add(o).equals(r))[0]}toInts(){return this.vertex.toShortInts().concat(this.direction.toInt())}toString(){return`${this.vertex.toShortString()},${this.direction.toInt()}`}};var _=class e extends ci{static{E(this,"HexPoint")}static ORIGIN=new e(0,0,0);static SIDE=Math.sqrt(2/3);static OFF_MAP=new e(17,-29,12);static fromProto(r){return new e(r.x,r.y,r.z)}static ofString(r){if(r===void 0||r.length===0)return console.warn(`bad hex string ${r}`),new e(0,0,0);let t=r.split(","),o=parseInt(t[0]),i=parseInt(t[1]),n=-1*(o+i);return Math.abs(o)===0&&(o=Math.abs(o)),Math.abs(i)===0&&(i=Math.abs(i)),Math.abs(n)===0&&(n=Math.abs(n)),new e(o,i,n)}static ofInts(r,t){let o=-1*(r+t);return new e(r,t,o)}static compare(r,t){return r.x<t.x?-1:r.x>t.x?1:r.y<t.y?-1:r.y>t.y?1:r.z<t.z?-1:r.z>t.z?1:0}constructor(r,t,o){if(super(r,t,o),this.total!==0)throw new Error(`HexPoint not 0 (${this.x},${this.y},${this.z})`)}toProto(){return q.create({x:this.x,y:this.y,z:this.z})}get row(){return this.z}get ring(){return Math.max(Math.abs(this.x),Math.abs(this.y),Math.abs(this.z))}getAllNeighbors(){return C.ALL.map(r=>this.add(r))}onMajorAxis(){return this.multiplied===0}add(r){return new e(this.x+r.dx,this.y+r.dy,this.z+r.dz)}getThisPlusNInDir(r,t){let o=e.ofString(this.toString()),i=[o];for(let n=0;n<r;n++)o=o.add(t),i.push(o);return i}addToVertex(r){if(r.equals(Ce.NORTH)||r.equals(Ce.SOUTH_EAST)||r.equals(Ce.SOUTH_WEST))throw new Error("Can't go in that direction");return new oe(this.x+r.dx,this.y+r.dy,this.z+r.dz)}getAllVerticies(){let r=this.addToVertex(Ce.NORTH_EAST),t=r.add(Ce.NORTH_WEST),o=r.add(Ce.SOUTH),i=this.addToVertex(Ce.SOUTH),n=this.addToVertex(Ce.NORTH_WEST),a=n.add(Ce.SOUTH);return[t,r,o,i,a,n]}getAllEdges(){let r=[],t=this.getAllVerticies();for(let o=0;o<5;o++)r.push(new Ne(t[o],t[o+1]));return r.push(new Ne(t[0],t[5])),r}hasEdge(r){return this.getAllEdges().some(t=>t.equals(r))}hasVertex(r){return this.getAllVerticies().some(t=>t.equals(r))}getEdgeInDirection(r){let o=this.add(r).getAllEdges().map(i=>i.toString());return this.getAllEdges().filter(i=>o.includes(i.toString()))[0]}getVertexInDirection(r){let t=[];if(r.equals(Ce.NORTH)?(t.push(C.NORTH_EAST),t.push(C.NORTH_WEST)):r.equals(Ce.NORTH_EAST)?(t.push(C.NORTH_EAST),t.push(C.EAST)):r.equals(Ce.SOUTH_EAST)?(t.push(C.SOUTH_EAST),t.push(C.EAST)):r.equals(Ce.SOUTH)?(t.push(C.SOUTH_EAST),t.push(C.SOUTH_WEST)):r.equals(Ce.SOUTH_WEST)?(t.push(C.WEST),t.push(C.SOUTH_WEST)):r.equals(Ce.NORTH_WEST)&&(t.push(C.WEST),t.push(C.NORTH_WEST)),t.length!==2)throw console.warn("didn't find two edges in dir"),new Error("didn't find two edges in dir");let o=this.getEdgeInDirection(t[0]),i=this.getEdgeInDirection(t[1]),n=o.getSharedVertexWith(i);if(!n)throw console.warn("tried to get edges in dir but failed!"),new Error("tried to get edges in dir but failed!");return n}getVertex(r){if(typeof r=="number")return this.getAllVerticies()[r];{let t=Ce.fromString(r);return this.getVertexInDirection(t)}}clone(){return new e(this.x,this.y,this.z)}rotateRightN(r){let t=this.clone();for(let o=0;o<r;o++)t=t.rotateRight();return t}rotateRight(){return new e(-this.y,-this.z,-this.x)}rotateLeftN(r){let t=this.clone();for(let o=0;o<r;o++)t=t.rotateLeft();return t}rotateLeft(){return new e(-this.z,-this.x,-this.y)}toString(){return`${this.x},${this.y}`}toInts(){return[this.x,this.y]}};var A=class e{static{E(this,"Tile")}location;terrain;numbers;isRiver;static fromProto(r){if(!r.location)throw new Error("TileProto must have location");return new e(_.fromProto(r.location),r.terrain,r.numbers??[],r.isRiver??!1)}constructor(r,t,o=[],i=!1){this.location=r,this.terrain=t,this.numbers=o,this.isRiver=i}toProto(){return ha.create({location:this.location.toProto(),terrain:this.terrain,numbers:this.numbers,isRiver:this.isRiver})}hasNumber(r){return this.numbers.includes(r)}get isDesert(){return this.terrain===d.TERRAIN_DESERT}get isSea(){return this.terrain===d.TERRAIN_SEA}get isGold(){return this.terrain===d.TERRAIN_GOLD}get isLake(){return this.terrain===d.TERRAIN_LAKE_A||this.terrain===d.TERRAIN_LAKE_B}get isFog(){return this.terrain===d.TERRAIN_FOG}get isSwamp(){return this.terrain===d.TERRAIN_SWAMP}get isLand(){return this.terrain!==d.TERRAIN_SEA&&this.terrain!==d.TERRAIN_UNSPECIFIED}get producesResource(){return this.terrain!==d.TERRAIN_DESERT&&this.terrain!==d.TERRAIN_UNSPECIFIED&&this.terrain!==d.TERRAIN_SEA&&this.terrain!==d.TERRAIN_FOG&&this.terrain!==d.TERRAIN_SWAMP}getResource(){return this.terrain}get resource(){switch(this.terrain){case d.TERRAIN_FOREST:return S.RESOURCE_WOOD;case d.TERRAIN_HILLS:return S.RESOURCE_BRICK;case d.TERRAIN_PASTURE:return S.RESOURCE_SHEEP;case d.TERRAIN_FIELDS:return S.RESOURCE_WHEAT;case d.TERRAIN_MOUNTAINS:return S.RESOURCE_ORE;default:return}}getCommodity(){switch(this.terrain){case d.TERRAIN_FOREST:return j.COMMODITY_PAPER;case d.TERRAIN_PASTURE:return j.COMMODITY_CLOTH;case d.TERRAIN_MOUNTAINS:return j.COMMODITY_COIN;default:return j.COMMODITY_UNSPECIFIED}}toString(){return JSON.stringify(this.toProto())}get isProductiveLand(){return this.terrain!==d.TERRAIN_DESERT&&this.terrain!==d.TERRAIN_SEA&&this.terrain!==d.TERRAIN_UNSPECIFIED&&this.terrain!==d.TERRAIN_FOG&&this.terrain!==d.TERRAIN_LAKE_A&&this.terrain!==d.TERRAIN_LAKE_B&&this.terrain!==d.TERRAIN_SWAMP&&this.numbers.length>0}weaken(){let r=[],t=!1;for(let o of this.numbers)o===2||o===12?t=!0:o<7?r.push(o-1):o>7&&r.push(o+1);return t?{tile:new e(this.location,d.TERRAIN_DESERT,[]),becameDesert:!0}:{tile:new e(this.location,this.terrain,r),becameDesert:!1}}};var me=class e{static{E(this,"Port")}rate;resource;hex;edge;static fromProto(r){if(!r.hex||!r.edge)throw new Error("PortProto must have hex and edge");return new e(r.rate,r.resource,_.fromProto(r.hex),Ne.fromProto(r.edge))}constructor(r,t,o,i){this.rate=r,this.resource=t,this.hex=o,this.edge=i}toProto(){return Nr.create({rate:this.rate,resource:this.resource,hex:this.hex.toProto(),edge:this.edge.toProto()})}get isGeneric(){return this.resource===S.RESOURCE_UNSPECIFIED}get is2to1(){return this.rate===2}get is3to1(){return this.rate===3}canTrade(r){return this.isGeneric||this.resource===r}toString(){return JSON.stringify(this.toProto())}};var ar=class e{static{E(this,"EdgeBuilding")}edge;owner;building;static fromProto(r){if(!r.edge)throw new Error("EdgeBuildingProto must have edge");return new e(Ne.fromProto(r.edge),r.owner,r.building)}constructor(r,t,o){this.edge=r,this.owner=t,this.building=o}toProto(){return ga.create({edge:this.edge.toProto(),owner:this.owner,building:this.building})}get isRoad(){return this.building===F.BUILDING_ROAD}get isShip(){return this.building===F.BUILDING_SHIP}get isBrokenRoad(){return this.building===F.BUILDING_BROKEN_ROAD}get isBridge(){return this.building===F.BUILDING_BRIDGE}get isRoadLike(){return this.isRoad||this.isBrokenRoad||this.isBridge}get providesSettlementConnectivity(){return this.isRoad||this.isShip||this.isBridge}equals(r){return this.edge.equals(r.edge)&&this.owner===r.owner&&this.building===r.building}toString(){return JSON.stringify(this.toProto())}};var mr=class e{static{E(this,"VertexBuilding")}vertex;owner;building;static fromProto(r){if(!r.vertex)throw new Error("VertexBuildingProto must have vertex");return new e(oe.fromProto(r.vertex),r.owner,r.building)}constructor(r,t,o){this.vertex=r,this.owner=t,this.building=o}toProto(){return ya.create({vertex:this.vertex.toProto(),owner:this.owner,building:this.building})}get isSettlement(){return this.building===F.BUILDING_SETTLEMENT}get isCity(){return this.building===F.BUILDING_CITY}get isBrokenCity(){return this.building===F.BUILDING_BROKEN_CITY}get victoryPoints(){return this.isSettlement||this.isBrokenCity?1:this.isCity?2:0}get resourceMultiplier(){return this.isSettlement||this.isBrokenCity?1:this.isCity?2:0}equals(r){return this.vertex.equals(r.vertex)&&this.owner===r.owner&&this.building===r.building}toString(){return JSON.stringify(this.toProto())}};var jr=class e{static{E(this,"Knight")}location;owner;strength;status;activatedThisTurn;promotedThisTurn;static fromProto(r){if(!r.location)throw new Error("KnightProto must have location");return new e(oe.fromProto(r.location),r.owner,r.strength,r.status,r.activatedThisTurn,r.promotedThisTurn)}constructor(r,t,o=Pe.KNIGHT_STRENGTH_BASIC,i=ir.KNIGHT_STATUS_INACTIVE,n=!1,a=!1){this.location=r,this.owner=t,this.strength=o,this.status=i,this.activatedThisTurn=n,this.promotedThisTurn=a}toProto(){return{location:this.location.toProto(),owner:this.owner,strength:this.strength,status:this.status,activatedThisTurn:this.activatedThisTurn,promotedThisTurn:this.promotedThisTurn}}get strengthValue(){switch(this.strength){case Pe.KNIGHT_STRENGTH_BASIC:return 1;case Pe.KNIGHT_STRENGTH_STRONG:return 2;case Pe.KNIGHT_STRENGTH_MIGHTY:return 3;default:return 0}}get isActive(){return this.status===ir.KNIGHT_STATUS_ACTIVE}get isInactive(){return this.status===ir.KNIGHT_STATUS_INACTIVE}get canAct(){return this.isActive&&!this.activatedThisTurn}get canPromote(){return this.strength===Pe.KNIGHT_STRENGTH_BASIC||this.strength===Pe.KNIGHT_STRENGTH_STRONG}get nextStrength(){switch(this.strength){case Pe.KNIGHT_STRENGTH_BASIC:return Pe.KNIGHT_STRENGTH_STRONG;case Pe.KNIGHT_STRENGTH_STRONG:return Pe.KNIGHT_STRENGTH_MIGHTY;default:return this.strength}}static getPreviousStrength(r){switch(r){case Pe.KNIGHT_STRENGTH_MIGHTY:return Pe.KNIGHT_STRENGTH_STRONG;case Pe.KNIGHT_STRENGTH_STRONG:return Pe.KNIGHT_STRENGTH_BASIC;default:return}}isStrongerThan(r){return this.strengthValue>r.strengthValue}with(r){return new e(r.location??this.location,this.owner,r.strength??this.strength,r.status??this.status,r.activatedThisTurn??this.activatedThisTurn,r.promotedThisTurn??this.promotedThisTurn)}activate(){return this.with({status:ir.KNIGHT_STATUS_ACTIVE,activatedThisTurn:!0})}deactivate(){return this.with({status:ir.KNIGHT_STATUS_INACTIVE,activatedThisTurn:!1})}promote(){return this.canPromote?this.with({strength:this.nextStrength,promotedThisTurn:!0}):this}moveTo(r){return new e(r,this.owner,this.strength,ir.KNIGHT_STATUS_INACTIVE,!1,!1)}resetTurnFlag(){return!this.activatedThisTurn&&!this.promotedThisTurn?this:this.with({activatedThisTurn:!1,promotedThisTurn:!1})}equals(r){return this.location.equals(r.location)&&this.owner===r.owner&&this.strength===r.strength&&this.status===r.status&&this.activatedThisTurn===r.activatedThisTurn&&this.promotedThisTurn===r.promotedThisTurn}toString(){return JSON.stringify(this.toProto())}};var un=class e{static{E(this,"CityWall")}location;owner;static fromProto(r){if(!r.location)throw new Error("CityWallProto must have location");return new e(oe.fromProto(r.location),r.owner)}constructor(r,t){this.location=r,this.owner=t}toProto(){return{location:this.location.toProto(),owner:this.owner}}equals(r){return this.location.equals(r.location)&&this.owner===r.owner}toString(){return JSON.stringify(this.toProto())}};var Yr=class e{static{E(this,"Metropolis")}track;location;owner;static fromProto(r){if(!r.location)throw new Error("MetropolisProto must have location");return new e(r.track,oe.fromProto(r.location),r.owner)}constructor(r,t,o){this.track=r,this.location=t,this.owner=o}toProto(){return{track:this.track,location:this.location.toProto(),owner:this.owner}}transferTo(r,t){return new e(this.track,t,r)}equals(r){return this.track===r.track&&this.location.equals(r.location)&&this.owner===r.owner}toString(){return JSON.stringify(this.toProto())}};var Ti=class e{static{E(this,"Merchant")}location;owner;static fromProto(r){if(!r.location)throw new Error("MerchantProto must have location");return new e(_.fromProto(r.location),r.owner)}constructor(r,t){this.location=r,this.owner=t}toProto(){return{location:this.location.toProto(),owner:this.owner}}moveTo(r,t){return new e(r,t)}equals(r){return this.location.equals(r.location)&&this.owner===r.owner}toString(){return JSON.stringify(this.toProto())}};var Nt=class e{static{E(this,"BarbarianState")}position;hasAttacked;static fromProto(r){return new e(r.position,r.hasAttacked)}static createInitial(){return new e(0,!1)}constructor(r=0,t=!1){this.position=Math.max(0,Math.min(r_,r)),this.hasAttacked=t}toProto(){return{position:this.position,hasAttacked:this.hasAttacked}}get isAtAttackPosition(){return this.position>=r_}get spacesUntilAttack(){return Math.max(0,r_-this.position)}advance(){return new e(this.position+1,this.hasAttacked)}resetAfterAttack(){return new e(0,!0)}canMoveRobber(){return this.hasAttacked}equals(r){return this.position===r.position&&this.hasAttacked===r.hasAttacked}toString(){return JSON.stringify(this.toProto())}},r_=7;var Ar=class e{static{E(this,"Fishery")}hex;vertex;number;static fromProto(r){if(!r.hex||!r.vertex)throw new Error("FisheryProto must have hex and vertex");return new e(_.fromProto(r.hex),oe.fromProto(r.vertex),r.number)}constructor(r,t,o){this.hex=r,this.vertex=t,this.number=o}toProto(){return ma.create({hex:this.hex.toProto(),vertex:this.vertex.toProto(),number:this.number})}getFishingVertices(){let r=[this.vertex],t=this.hex.getAllVerticies(),o=this.vertex.getAdjacentVerticies();for(let i of t)o.some(n=>n.equals(i))&&r.push(i);return r}canCatchFish(r){return this.getFishingVertices().some(t=>t.equals(r))}toString(){return JSON.stringify(this.toProto())}};var En=class e{static{E(this,"EdgeReward")}edge;type;port;static fromProto(r){if(!r.edge)throw new Error("EdgeRewardProto must have edge");return new e(Ne.fromProto(r.edge),r.type,r.port?me.fromProto(r.port):void 0)}constructor(r,t,o){this.edge=r,this.type=t,this.port=o}toProto(){return Da.create({edge:this.edge.toProto(),type:this.type,port:this.port?.toProto()})}get isVictoryPoint(){return this.type===Tr.EDGE_REWARD_TYPE_VICTORY_POINT}get isDevCard(){return this.type===Tr.EDGE_REWARD_TYPE_DEV_CARD}get isPort(){return this.type===Tr.EDGE_REWARD_TYPE_PORT}toString(){return JSON.stringify(this.toProto())}};var ln=class e{static{E(this,"Wagon")}edge;facing;static fromProto(r){if(!r.edge)throw new Error("WagonProto must have edge");return new e(Ne.fromProto(r.edge),Ce.fromProto(r.facing))}constructor(r,t){this.edge=r,this.facing=t}toProto(){return{edge:this.edge.toProto(),facing:this.facing.toProto()}}get frontVertex(){return this.edge.vertex.add(this.facing)}get backVertex(){return this.frontVertex.equals(this.edge.v1)?this.edge.v2:this.edge.v1}isFacingVertex(r){return this.frontVertex.equals(r)}isOnEdge(r){return this.edge.equals(r)}toString(){return`Wagon(${this.edge.toString()}, facing=${this.facing.toString()})`}equals(r){return this.edge.equals(r.edge)&&this.facing.equals(r.facing)}};var Nd=new _(100,-100,0),ge=class e{static{E(this,"GameBoard")}tileMap;ports;robbers;pirate;edgeBuildingMap;vertexBuildingMap;knights;cityWalls;metropolises;merchant;barbarians;fisheries;edgeRewardMap;wagonMap;trolls;static fromProto(r){let t=(r.tiles??[]).map(g=>A.fromProto(g)),o=(r.ports??[]).map(g=>me.fromProto(g)),i=(r.robbers??[]).map(g=>_.fromProto(g)),n=r.pirate?_.fromProto(r.pirate):void 0,a=(r.edgeBuildings??[]).map(g=>ar.fromProto(g)),s=(r.vertexBuildings??[]).map(g=>mr.fromProto(g)),u=(r.knights??[]).map(g=>jr.fromProto(g)),l=(r.cityWalls??[]).map(g=>un.fromProto(g)),c=(r.metropolises??[]).map(g=>Yr.fromProto(g)),f=r.merchant?Ti.fromProto(r.merchant):void 0,T=r.barbarians?Nt.fromProto(r.barbarians):void 0,R=(r.fisheries??[]).map(g=>Ar.fromProto(g)),O=(r.edgeRewards??[]).map(g=>En.fromProto(g)),I=(r.wagons??[]).map(g=>ln.fromProto(g)),D=(r.trolls??[]).map(g=>_.fromProto(g));return new e(t,o,i,n,a,s,u,l,c,f,T,R,O,I,D)}constructor(r,t,o=[],i,n=[],a=[],s=[],u=[],l=[],c,f,T=[],R=[],O=[],I=[]){this.tileMap=new Map;for(let D of r)this.tileMap.set(D.location.toString(),D);for(let D of t)if(this.tileMap.get(D.hex.toString())?.isLake)throw new Error(`Port cannot be placed on lake tile at ${D.hex.toString()}. Lake tiles are reserved for fisheries in the Fisherman expansion.`);this.ports=t,this.robbers=o,this.pirate=i,this.edgeBuildingMap=new Map;for(let D of n)this.edgeBuildingMap.set(D.edge.toString(),D);this.vertexBuildingMap=new Map;for(let D of a)this.vertexBuildingMap.set(D.vertex.toString(),D);this.knights=s,this.cityWalls=u,this.metropolises=l,this.merchant=c,this.barbarians=f,this.fisheries=T,this.edgeRewardMap=new Map;for(let D of R)this.edgeRewardMap.set(D.edge.toString(),D);this.wagonMap=new Map;for(let D of O)this.wagonMap.set(D.edge.toString(),D);this.trolls=I}toProto(){return $n.create({tiles:this.getTiles().map(r=>r.toProto()),ports:this.ports.map(r=>r.toProto()),robbers:this.robbers.map(r=>r.toProto()),pirate:this.pirate?.toProto(),edgeBuildings:this.getEdgeBuildings().map(r=>r.toProto()),vertexBuildings:this.getVertexBuildings().map(r=>r.toProto()),knights:this.knights.map(r=>r.toProto()),cityWalls:this.cityWalls.map(r=>r.toProto()),metropolises:this.metropolises.map(r=>r.toProto()),merchant:this.merchant?.toProto(),barbarians:this.barbarians?.toProto(),fisheries:this.fisheries.map(r=>r.toProto()),edgeRewards:this.getEdgeRewards().map(r=>r.toProto()),wagons:this.getWagons().map(r=>r.toProto()),trolls:this.trolls.map(r=>r.toProto())})}getTile(r){return this.tileMap.get(r.toString())}hasTile(r){return this.tileMap.has(r.toString())}getTiles(){return Array.from(this.tileMap.values())}getTileLocations(){return this.getTiles().map(r=>r.location)}getTilesWithNumber(r){return this.getTiles().filter(t=>t.hasNumber(r))}getRiverHexes(){return this.getTiles().filter(r=>r.isRiver)}isRiverEdge(r){return r.getAdjacentCenters().some(o=>this.getTile(o)?.isRiver??!1)}isBridgeSite(r){let[t,o]=r.getAdjacentCenters();if(!t||!o)return!1;let i=this.getTile(t),n=this.getTile(o);if(!i&&!n)return!1;let a=E(l=>l===void 0||l.isSea||l.isLake,"isWater"),s=E(l=>l?.isRiver??!1,"isRiver"),u=E(l=>l?.isSwamp??!1,"isSwamp");return!!(s(i)&&s(n)||u(i)&&a(n)||u(n)&&a(i)||s(i)&&a(n)||s(n)&&a(i))}isRiverVertex(r){return r.getHexCenters().some(o=>this.getTile(o)?.isRiver??!1)}getSwampTiles(){return this.getTiles().filter(r=>r.isSwamp)}get tileCount(){return this.tileMap.size}getPortAt(r){return this.ports.find(t=>t.hex.equals(r))}getPortsForVertex(r){return this.ports.filter(t=>t.edge.hasVertex(r))}get portCount(){return this.ports.length}hasRobber(r){return this.robbers.some(t=>t.equals(r))}findFreeDesertForRobber(){let r=this.robbers.slice(1);return this.getTiles().find(t=>t.terrain===d.TERRAIN_DESERT&&!r.some(o=>o.equals(t.location)))?.location}get robberCount(){return this.robbers.length}hasPirate(r){return this.pirate!==void 0&&this.pirate.equals(r)}get hasPirateOnBoard(){return this.pirate!==void 0}get hasRobberOrPirate(){return this.robbers.length>0||this.pirate!==void 0}get canTriggerRobberPlacement(){return this.hasRobberOrPirate&&(this.barbarians?.canMoveRobber()??!0)}isSea(r){let t=this.getTile(r);return t===void 0||t.isSea}isEdgeAdjacentToPirate(r){let t=this.pirate;return t?r.getAdjacentCenters().some(o=>o.equals(t)):!1}getSeaLocations(){let r=[];for(let t of this.getLandTiles())for(let o of t.location.getAllNeighbors())this.isSea(o)&&r.push(o);return r}getSeaTiles(){let r=new Set;for(let t of this.getLandTiles())for(let o of t.location.getAllNeighbors())this.isSea(o)&&r.add(o.toString());return Array.from(r).map(t=>{let o=this.tileMap.get(t);if(o)return o;let i=_.ofString(t);return new A(i,d.TERRAIN_SEA,[])})}getGoldTiles(){return this.getTiles().filter(r=>r.isGold)}getLandTiles(){return this.getTiles().filter(r=>r.isLand)}getLakeTiles(){return this.getTiles().filter(r=>r.isLake)}getEdgeBuilding(r){return this.edgeBuildingMap.get(r.toString())}hasEdgeBuilding(r){return this.edgeBuildingMap.has(r.toString())}getEdgeBuildings(){return Array.from(this.edgeBuildingMap.values())}getEdgeBuildingsByPlayer(r){return this.getEdgeBuildings().filter(t=>t.owner===r)}getRoads(){return this.getEdgeBuildings().filter(r=>r.isRoad)}getShips(){return this.getEdgeBuildings().filter(r=>r.isShip)}getRoadsByPlayer(r){return this.getRoads().filter(t=>t.owner===r)}getShipsByPlayer(r){return this.getShips().filter(t=>t.owner===r)}getBridges(){return this.getEdgeBuildings().filter(r=>r.isBridge)}getBridgesByPlayer(r){return this.getBridges().filter(t=>t.owner===r)}get edgeBuildingCount(){return this.edgeBuildingMap.size}get roadCount(){return this.getRoads().length}get shipCount(){return this.getShips().length}get bridgeCount(){return this.getBridges().length}getVertexBuilding(r){return this.vertexBuildingMap.get(r.toString())}hasVertexBuilding(r){return this.vertexBuildingMap.has(r.toString())}getVertexBuildings(){return Array.from(this.vertexBuildingMap.values())}getVertexBuildingsByPlayer(r){return this.getVertexBuildings().filter(t=>t.owner===r)}getSettlements(){return this.getVertexBuildings().filter(r=>r.isSettlement||r.isBrokenCity)}getCities(){return this.getVertexBuildings().filter(r=>r.isCity)}getSettlementsByPlayer(r){return this.getSettlements().filter(t=>t.owner===r)}getCitiesByPlayer(r){return this.getCities().filter(t=>t.owner===r)}get vertexBuildingCount(){return this.vertexBuildingMap.size}get settlementCount(){return this.getSettlements().length}get cityCount(){return this.getCities().length}getVertexBuildingsOnTile(r){return r.getAllVerticies().map(o=>this.getVertexBuilding(o)).filter(o=>o!==void 0)}getPlayersOnTile(r){let t=this.getVertexBuildingsOnTile(r),o=new Set;for(let i of t)o.add(i.owner);return Array.from(o)}getKnightAt(r){return this.knights.find(t=>t.location.equals(r))}hasKnight(r){return this.getKnightAt(r)!==void 0}getKnightsByPlayer(r){return this.knights.filter(t=>t.owner===r)}getKnights(){return this.knights}getActiveKnightsByPlayer(r){return this.knights.filter(t=>t.owner===r&&t.isActive)}get knightCount(){return this.knights.length}getCityWallAt(r){return this.cityWalls.find(t=>t.location.equals(r))}hasCityWall(r){return this.getCityWallAt(r)!==void 0}getCityWallsByPlayer(r){return this.cityWalls.filter(t=>t.owner===r)}get cityWallCount(){return this.cityWalls.length}getMetropolisAt(r){return this.metropolises.find(t=>t.location.equals(r))}hasMetropolis(r){return this.getMetropolisAt(r)!==void 0}getMetropolisByTrack(r){return this.metropolises.find(t=>t.track===r)}getMetropolisesByPlayer(r){return this.metropolises.filter(t=>t.owner===r)}get metropolisCount(){return this.metropolises.length}hasMerchant(){return this.merchant!==void 0}getMerchantOwner(){return this.merchant?.owner}getMerchantHex(){return this.merchant?.location}get hasBarbarians(){return this.barbarians!==void 0}get barbarianPosition(){return this.barbarians?.position??0}getBarbarianPosition(){return this.barbarianPosition}get barbariansHaveAttacked(){return this.barbarians?.hasAttacked??!1}get barbariansAtAttackPosition(){return this.barbarians?.isAtAttackPosition??!1}getTotalCities(){return this.cityCount}static builder(){return new t_}toBuilder(){return new t_().withTiles(this.getTiles()).withPorts(this.ports).withRobbers(this.robbers).withPirate(this.pirate).withEdgeBuildings(this.getEdgeBuildings()).withVertexBuildings(this.getVertexBuildings()).withKnights(this.knights).withCityWalls(this.cityWalls).withMetropolises(this.metropolises).withMerchant(this.merchant).withBarbarians(this.barbarians).withFisheries(this.fisheries).withEdgeRewards(this.getEdgeRewards()).withWagons(this.getWagons()).withTrolls(this.trolls)}getFisheries(){return this.fisheries}getFisheryAt(r,t){return this.fisheries.find(o=>o.hex.equals(r)&&o.vertex.equals(t))}getFisheriesForVertex(r){return this.fisheries.filter(t=>t.canCatchFish(r))}getFisheriesWithNumber(r){return this.fisheries.filter(t=>t.number===r)}get fisheryCount(){return this.fisheries.length}getEdgeReward(r){return this.edgeRewardMap.get(r.toString())}hasEdgeReward(r){return this.edgeRewardMap.has(r.toString())}getEdgeRewards(){return Array.from(this.edgeRewardMap.values())}get edgeRewardCount(){return this.edgeRewardMap.size}getWagon(r){return this.wagonMap.get(r.toString())}hasWagon(r){return this.wagonMap.has(r.toString())}getWagons(){return Array.from(this.wagonMap.values())}get wagonCount(){return this.wagonMap.size}getAdjacentWagonCount(r){let t=0;for(let o of r.getEdges())this.hasWagon(o)&&t++;return t}getWateringHoleTiles(){return this.getTiles().filter(r=>r.terrain===d.TERRAIN_WATERING_HOLE)}isWateringHole(r){let t=this.getTile(r);return t!==void 0&&t.terrain===d.TERRAIN_WATERING_HOLE}getWateringHoleVertices(){let r=[];for(let t of this.getWateringHoleTiles())for(let o of t.location.getAllVerticies())r.some(i=>i.equals(o))||r.push(o);return r}hasTroll(r){return this.trolls.some(t=>t.equals(r))}getTrolls(){return this.trolls}get trollCount(){return this.trolls.length}},t_=class{static{E(this,"GameBoardBuilder")}tiles=[];ports=[];robbers=[];pirate;edgeBuildings=[];vertexBuildings=[];knights=[];cityWalls=[];metropolises=[];merchant;barbarians;fisheries=[];edgeRewards=[];wagons=[];trolls=[];withTiles(r){return this.tiles=r,this}withPorts(r){return this.ports=r,this}withRobbers(r){return this.robbers=r,this}withPirate(r){return this.pirate=r,this}withEdgeBuildings(r){return this.edgeBuildings=r,this}withVertexBuildings(r){return this.vertexBuildings=r,this}withKnights(r){return this.knights=r,this}withCityWalls(r){return this.cityWalls=r,this}withMetropolises(r){return this.metropolises=r,this}withMerchant(r){return this.merchant=r,this}withBarbarians(r){return this.barbarians=r,this}withFisheries(r){return this.fisheries=r,this}withEdgeRewards(r){return this.edgeRewards=r,this}withWagons(r){return this.wagons=r,this}withTrolls(r){return this.trolls=r,this}build(){return new ge(this.tiles,this.ports,this.robbers,this.pirate,this.edgeBuildings,this.vertexBuildings,this.knights,this.cityWalls,this.metropolises,this.merchant,this.barbarians,this.fisheries,this.edgeRewards,this.wagons,this.trolls)}};var cn=class e{static{E(this,"PlayerState")}player;hand;unplayedDevCards;devCardsPurchasedThisTurn;commodities;progressCards;masterMerchantResources;masterMerchantCommodities;spyVisibleProgressCards;fishTiles;heldPorts;gold;static fromProto(r){let t=new Map;for(let R of r.hand??[])t.set(R.resource,R.count);let o=new Map;for(let R of r.unplayedDevCards??[])o.set(R.card,R.count);let i=new Map;for(let R of r.devCardsPurchasedThisTurn??[])i.set(R.card,R.count);let n=new Map;for(let R of r.commodities??[])n.set(R.commodity,R.count);let a=new Map;for(let R of r.progressCards??[])a.set(R.card,R.count);let s=new Map;for(let R of r.masterMerchantResources??[])s.set(R.resource,R.count);let u=new Map;for(let R of r.masterMerchantCommodities??[])u.set(R.commodity,R.count);let l=new Map;for(let R of r.spyVisibleProgressCards??[])l.set(R.card,R.count);let c=new Map;for(let R of r.fishTiles??[])c.set(R.fish,R.count);let f=(r.heldPorts??[]).map(R=>me.fromProto(R)),T=r.gold??0;return new e(r.player,t,o,i,n,a,s,u,l,c,f,T)}static createEmpty(r){return e.builder(r).build()}static builder(r){return new n_(r)}constructor(r,t,o,i,n,a,s,u,l,c,f=[],T=0){this.player=r,this.hand=t,this.unplayedDevCards=o,this.devCardsPurchasedThisTurn=i,this.commodities=n,this.progressCards=a,this.masterMerchantResources=s,this.masterMerchantCommodities=u,this.spyVisibleProgressCards=l,this.fishTiles=c,this.heldPorts=f,this.gold=T}toBuilder(){return new n_(this.player).withHand(new Map(this.hand)).withUnplayedDevCards(new Map(this.unplayedDevCards)).withDevCardsPurchasedThisTurn(new Map(this.devCardsPurchasedThisTurn)).withCommodities(new Map(this.commodities)).withProgressCards(new Map(this.progressCards)).withMasterMerchantResources(new Map(this.masterMerchantResources)).withMasterMerchantCommodities(new Map(this.masterMerchantCommodities)).withSpyVisibleProgressCards(new Map(this.spyVisibleProgressCards)).withFishTiles(new Map(this.fishTiles)).withHeldPorts([...this.heldPorts]).withGold(this.gold)}toProto(){let r=[];for(let[c,f]of this.hand)r.push(ne.create({resource:c,count:f}));let t=[];for(let[c,f]of this.unplayedDevCards)t.push(Er.create({card:c,count:f}));let o=[];for(let[c,f]of this.devCardsPurchasedThisTurn)o.push(Er.create({card:c,count:f}));let i=[];for(let[c,f]of this.commodities)i.push(te.create({commodity:c,count:f}));let n=[];for(let[c,f]of this.progressCards)n.push(dr.create({card:c,count:f}));let a=[];for(let[c,f]of this.masterMerchantResources)a.push(ne.create({resource:c,count:f}));let s=[];for(let[c,f]of this.masterMerchantCommodities)s.push(te.create({commodity:c,count:f}));let u=[];for(let[c,f]of this.spyVisibleProgressCards)u.push(dr.create({card:c,count:f}));let l=[];for(let[c,f]of this.fishTiles)l.push(xe.create({fish:c,count:f}));return jn.create({player:this.player,hand:r,unplayedDevCards:t,devCardsPurchasedThisTurn:o,commodities:i,progressCards:n,masterMerchantResources:a,masterMerchantCommodities:s,spyVisibleProgressCards:u,fishTiles:l,heldPorts:this.heldPorts.map(c=>c.toProto()),gold:this.gold})}getResourceCount(r){return this.hand.get(r)??0}get resources(){return this.hand}get totalResourcesInHand(){let r=0;for(let t of this.hand.values())r+=t;return r}hasResources(r,t){return this.getResourceCount(r)>=t}hasResourceSet(r){for(let[t,o]of r)if(!this.hasResources(t,o))return!1;return!0}hasResourcesForBuilding(r){switch(r){case F.BUILDING_ROAD:return this.hasResources(S.RESOURCE_WOOD,1)&&this.hasResources(S.RESOURCE_BRICK,1);case F.BUILDING_SHIP:return this.hasResources(S.RESOURCE_WOOD,1)&&this.hasResources(S.RESOURCE_SHEEP,1);case F.BUILDING_SETTLEMENT:return this.hasResources(S.RESOURCE_WOOD,1)&&this.hasResources(S.RESOURCE_BRICK,1)&&this.hasResources(S.RESOURCE_SHEEP,1)&&this.hasResources(S.RESOURCE_WHEAT,1);case F.BUILDING_CITY:return this.hasResources(S.RESOURCE_ORE,3)&&this.hasResources(S.RESOURCE_WHEAT,2);case F.BUILDING_DEV_CARD:return this.hasResources(S.RESOURCE_ORE,1)&&this.hasResources(S.RESOURCE_SHEEP,1)&&this.hasResources(S.RESOURCE_WHEAT,1);case F.BUILDING_KNIGHT:return this.hasResources(S.RESOURCE_SHEEP,1)&&this.hasResources(S.RESOURCE_ORE,1);case F.BUILDING_BRIDGE:return this.hasResources(S.RESOURCE_BRICK,2)&&this.hasResources(S.RESOURCE_WOOD,1);case F.BUILDING_UNSPECIFIED:case F.BUILDING_ROAD_OR_SHIP:case F.BUILDING_BROKEN_CITY:case F.BUILDING_BROKEN_ROAD:default:return!1}}getUnplayedDevCardCount(r){return this.unplayedDevCards.get(r)??0}get totalUnplayedDevCards(){let r=0;for(let t of this.unplayedDevCards.values())r+=t;for(let t of this.devCardsPurchasedThisTurn.values())r+=t;return r}hasUnplayedDevCards(){return this.totalUnplayedDevCards>0}getDevCardsPurchasedThisTurnCount(r){return this.devCardsPurchasedThisTurn.get(r)??0}get totalDevCardsPurchasedThisTurn(){let r=0;for(let t of this.devCardsPurchasedThisTurn.values())r+=t;return r}hasDevCardsPurchasedThisTurn(){return this.totalDevCardsPurchasedThisTurn>0}getCommodityCount(r){return this.commodities.get(r)??0}get totalCommoditiesInHand(){let r=0;for(let t of this.commodities.values())r+=t;return r}hasCommodities(r,t){return this.getCommodityCount(r)>=t}hasCommoditySet(r){for(let[t,o]of r)if(!this.hasCommodities(t,o))return!1;return!0}getProgressCardCount(r){return this.progressCards.get(r)??0}get totalProgressCards(){let r=0;for(let t of this.progressCards.values())r+=t;return r}hasProgressCards(){return this.totalProgressCards>0}getFishCount(r){return this.fishTiles.get(r)??0}get totalFishTiles(){let r=0;for(let t of this.fishTiles.values())r+=t;return r}get totalFishValue(){let r=0;for(let[t,o]of this.fishTiles)t===4?r-=o:r+=t*o;return r}hasFish(r,t){return this.getFishCount(r)>=t}get hasOldBoot(){return this.getFishCount(Se.FISH_OLD_BOOT)>0}toString(){return JSON.stringify(this.toProto())}},n_=class{static{E(this,"PlayerStateBuilder")}_player;_hand=new Map;_unplayedDevCards=new Map;_devCardsPurchasedThisTurn=new Map;_commodities=new Map;_progressCards=new Map;_masterMerchantResources=new Map;_masterMerchantCommodities=new Map;_spyVisibleProgressCards=new Map;_fishTiles=new Map;_heldPorts=[];_gold=0;constructor(r){this._player=r}withHand(r){return this._hand=r,this}withUnplayedDevCards(r){return this._unplayedDevCards=r,this}withDevCardsPurchasedThisTurn(r){return this._devCardsPurchasedThisTurn=r,this}withCommodities(r){return this._commodities=r,this}withProgressCards(r){return this._progressCards=r,this}withMasterMerchantResources(r){return this._masterMerchantResources=r,this}withMasterMerchantCommodities(r){return this._masterMerchantCommodities=r,this}withSpyVisibleProgressCards(r){return this._spyVisibleProgressCards=r,this}withFishTiles(r){return this._fishTiles=r,this}withHeldPorts(r){return this._heldPorts=r,this}withGold(r){return this._gold=r,this}addGold(r){return this._gold+=r,this}addProgressCard(r,t){let o=this._progressCards.get(r)??0;return this._progressCards.set(r,o+t),this}addHeldPort(r){return this._heldPorts=[...this._heldPorts,r],this}removeFirstHeldPort(){return this._heldPorts.length>0&&(this._heldPorts=this._heldPorts.slice(1)),this}build(){return new cn(this._player,this._hand,this._unplayedDevCards,this._devCardsPurchasedThisTurn,this._commodities,this._progressCards,this._masterMerchantResources,this._masterMerchantCommodities,this._spyVisibleProgressCards,this._fishTiles,this._heldPorts,this._gold)}};var Yt=class e{static{E(this,"CityImprovements")}tradeLevel;politicsLevel;scienceLevel;static fromProto(r){return new e(r.tradeLevel,r.politicsLevel,r.scienceLevel)}static createDefault(){return new e(0,0,0)}constructor(r=0,t=0,o=0){this.tradeLevel=Math.max(0,Math.min(5,r)),this.politicsLevel=Math.max(0,Math.min(5,t)),this.scienceLevel=Math.max(0,Math.min(5,o))}toProto(){return{tradeLevel:this.tradeLevel,politicsLevel:this.politicsLevel,scienceLevel:this.scienceLevel}}getLevel(r){switch(r){case K.CITY_IMPROVEMENT_TRACK_TRADE:return this.tradeLevel;case K.CITY_IMPROVEMENT_TRACK_POLITICS:return this.politicsLevel;case K.CITY_IMPROVEMENT_TRACK_SCIENCE:return this.scienceLevel;default:return 0}}improve(r){switch(r){case K.CITY_IMPROVEMENT_TRACK_TRADE:return new e(this.tradeLevel+1,this.politicsLevel,this.scienceLevel);case K.CITY_IMPROVEMENT_TRACK_POLITICS:return new e(this.tradeLevel,this.politicsLevel+1,this.scienceLevel);case K.CITY_IMPROVEMENT_TRACK_SCIENCE:return new e(this.tradeLevel,this.politicsLevel,this.scienceLevel+1);default:return this}}canImprove(r){return this.getLevel(r)<5}getCostToImprove(r,t=!1){let o=this.getLevel(r);if(o>=5)return 0;let i=o+1;return t?Math.max(0,i-1):i}getProgressCardDiceRange(r){let t=this.getLevel(r);return t===0?[]:Array.from({length:t+1},(o,i)=>i+1)}triggersProgressCard(r,t){return this.getProgressCardDiceRange(r).includes(t)}get hasMerchantGuild(){return this.tradeLevel>=3}get hasFortress(){return this.politicsLevel>=3}get hasAqueduct(){return this.scienceLevel>=3}get isEligibleForTradeMetropolis(){return this.tradeLevel>=4}get isEligibleForPoliticsMetropolis(){return this.politicsLevel>=4}get isEligibleForScienceMetropolis(){return this.scienceLevel>=4}isMetropolisProtected(r){return this.getLevel(r)>=5}equals(r){return this.tradeLevel===r.tradeLevel&&this.politicsLevel===r.politicsLevel&&this.scienceLevel===r.scienceLevel}toString(){return JSON.stringify(this.toProto())}};function LT(e){switch(e){case K.CITY_IMPROVEMENT_TRACK_TRADE:return j.COMMODITY_CLOTH;case K.CITY_IMPROVEMENT_TRACK_POLITICS:return j.COMMODITY_COIN;case K.CITY_IMPROVEMENT_TRACK_SCIENCE:return j.COMMODITY_PAPER;default:return j.COMMODITY_UNSPECIFIED}}E(LT,"getTrackCommodity");var vn=class e{static{E(this,"PlayerPublicState")}player;cardCount;unplayedDevCardCount;playedDevCards;cityImprovements;progressCardCount;scienceProgressCardCount;politicsProgressCardCount;tradeProgressCardCount;defenderOfCatanVp;progressCardVp;visibleVictoryPoints;longestRoadLength;fishTileCount;hasOldBoot;newIslandSettlementCount;edgeRewardVp;heldPortCount;gold;victoryPointProgressCards;static fromProto(r){let t=new Map;for(let i of r.playedDevCards??[])t.set(i.card,i.count);let o=r.cityImprovements?Yt.fromProto(r.cityImprovements):void 0;return new e(r.player,r.cardCount,r.unplayedDevCardCount,t,o,r.progressCardCount,r.scienceProgressCardCount??0,r.politicsProgressCardCount??0,r.tradeProgressCardCount??0,r.defenderOfCatanVp,r.progressCardVp,r.visibleVictoryPoints,r.longestRoadLength??0,r.fishTileCount??0,r.hasOldBoot??!1,r.newIslandSettlementCount??0,r.edgeRewardVp??0,r.heldPortCount??0,r.gold??0,r.victoryPointProgressCards??[])}static createEmpty(r){return e.builder(r).build()}static builder(r){return new Rd(r)}constructor(r,t,o,i,n,a=0,s=0,u=0,l=0,c=0,f=0,T=0,R=0,O=0,I=!1,D=0,g=0,k=0,v=0,Y=[]){this.player=r,this.cardCount=t,this.unplayedDevCardCount=o,this.playedDevCards=i,this.cityImprovements=n,this.progressCardCount=a,this.scienceProgressCardCount=s,this.politicsProgressCardCount=u,this.tradeProgressCardCount=l,this.defenderOfCatanVp=c,this.progressCardVp=f,this.visibleVictoryPoints=T,this.longestRoadLength=R,this.fishTileCount=O,this.hasOldBoot=I,this.newIslandSettlementCount=D,this.edgeRewardVp=g,this.heldPortCount=k,this.gold=v,this.victoryPointProgressCards=Y}toBuilder(){return new Rd(this.player).withCardCount(this.cardCount).withUnplayedDevCardCount(this.unplayedDevCardCount).withPlayedDevCards(new Map(this.playedDevCards)).withCityImprovements(this.cityImprovements).withProgressCardCount(this.progressCardCount).withScienceProgressCardCount(this.scienceProgressCardCount).withPoliticsProgressCardCount(this.politicsProgressCardCount).withTradeProgressCardCount(this.tradeProgressCardCount).withDefenderOfCatanVp(this.defenderOfCatanVp).withProgressCardVp(this.progressCardVp).withVisibleVictoryPoints(this.visibleVictoryPoints).withLongestRoadLength(this.longestRoadLength).withFishTileCount(this.fishTileCount).withHasOldBoot(this.hasOldBoot).withNewIslandSettlementCount(this.newIslandSettlementCount).withEdgeRewardVp(this.edgeRewardVp).withHeldPortCount(this.heldPortCount).withGold(this.gold).withVictoryPointProgressCards([...this.victoryPointProgressCards])}toProto(){let r=[];for(let[t,o]of this.playedDevCards)r.push(Er.create({card:t,count:o}));return Qn.create({player:this.player,cardCount:this.cardCount,unplayedDevCardCount:this.unplayedDevCardCount,playedDevCards:r,cityImprovements:this.cityImprovements?.toProto(),progressCardCount:this.progressCardCount,scienceProgressCardCount:this.scienceProgressCardCount,politicsProgressCardCount:this.politicsProgressCardCount,tradeProgressCardCount:this.tradeProgressCardCount,defenderOfCatanVp:this.defenderOfCatanVp,progressCardVp:this.progressCardVp,visibleVictoryPoints:this.visibleVictoryPoints,longestRoadLength:this.longestRoadLength,fishTileCount:this.fishTileCount,hasOldBoot:this.hasOldBoot,newIslandSettlementCount:this.newIslandSettlementCount,edgeRewardVp:this.edgeRewardVp,heldPortCount:this.heldPortCount,gold:this.gold,victoryPointProgressCards:this.victoryPointProgressCards})}getPlayedDevCardCount(r){return this.playedDevCards.get(r)??0}get totalPlayedDevCards(){let r=0;for(let t of this.playedDevCards.values())r+=t;return r}get playedKnights(){return this.getPlayedDevCardCount(ie.DEV_CARD_KNIGHT)}hasPlayedDevCards(){return this.totalPlayedDevCards>0}toString(){return JSON.stringify(this.toProto())}},Rd=class{static{E(this,"PlayerPublicStateBuilder")}_player;_cardCount=0;_unplayedDevCardCount=0;_playedDevCards=new Map;_cityImprovements=void 0;_progressCardCount=0;_scienceProgressCardCount=0;_politicsProgressCardCount=0;_tradeProgressCardCount=0;_defenderOfCatanVp=0;_progressCardVp=0;_visibleVictoryPoints=0;_longestRoadLength=0;_fishTileCount=0;_hasOldBoot=!1;_newIslandSettlementCount=0;_edgeRewardVp=0;_heldPortCount=0;_gold=0;_victoryPointProgressCards=[];constructor(r){this._player=r}withCardCount(r){return this._cardCount=r,this}withUnplayedDevCardCount(r){return this._unplayedDevCardCount=r,this}withPlayedDevCards(r){return this._playedDevCards=r,this}withCityImprovements(r){return this._cityImprovements=r,this}withProgressCardCount(r){return this._progressCardCount=r,this}withScienceProgressCardCount(r){return this._scienceProgressCardCount=r,this}withPoliticsProgressCardCount(r){return this._politicsProgressCardCount=r,this}withTradeProgressCardCount(r){return this._tradeProgressCardCount=r,this}withDefenderOfCatanVp(r){return this._defenderOfCatanVp=r,this}withProgressCardVp(r){return this._progressCardVp=r,this}withVisibleVictoryPoints(r){return this._visibleVictoryPoints=r,this}withLongestRoadLength(r){return this._longestRoadLength=r,this}withFishTileCount(r){return this._fishTileCount=r,this}withHasOldBoot(r){return this._hasOldBoot=r,this}withNewIslandSettlementCount(r){return this._newIslandSettlementCount=r,this}withEdgeRewardVp(r){return this._edgeRewardVp=r,this}withHeldPortCount(r){return this._heldPortCount=r,this}withGold(r){return this._gold=r,this}withVictoryPointProgressCards(r){return this._victoryPointProgressCards=r,this}addVictoryPointProgressCard(r){return this._victoryPointProgressCards=[...this._victoryPointProgressCards,r],this}build(){return new vn(this._player,this._cardCount,this._unplayedDevCardCount,this._playedDevCards,this._cityImprovements,this._progressCardCount,this._scienceProgressCardCount,this._politicsProgressCardCount,this._tradeProgressCardCount,this._defenderOfCatanVp,this._progressCardVp,this._visibleVictoryPoints,this._longestRoadLength,this._fishTileCount,this._hasOldBoot,this._newIslandSettlementCount,this._edgeRewardVp,this._heldPortCount,this._gold,this._victoryPointProgressCards)}};var et=class e{static{E(this,"Dice")}die1;die2;eventDie;eventCard;static fromProto(r){return new e(r.die1,r.die2,r.eventDie,r.eventCard)}constructor(r,t,o=Ue.EVENT_DIE_RESULT_UNSPECIFIED,i=le.EVENT_CARD_UNSPECIFIED){this.die1=r,this.die2=t,this.eventDie=o,this.eventCard=i}toProto(){return Dt.create({die1:this.die1,die2:this.die2,eventDie:this.eventDie,eventCard:this.eventCard})}get total(){return this.die1+this.die2}get hasEventDie(){return this.eventDie!==Ue.EVENT_DIE_RESULT_UNSPECIFIED}get hasEventCard(){return this.eventCard!==le.EVENT_CARD_UNSPECIFIED}equals(r){return this.die1===r.die1&&this.die2===r.die2&&this.eventDie===r.eventDie&&this.eventCard===r.eventCard}toString(){return JSON.stringify(this.toProto())}};var Yn=class e{static{E(this,"Trade")}id;proposer;offering;requesting;acceptingPlayers;rejectedPlayers;offeringCommodities;requestingCommodities;offeringGold;requestingGold;counterTradeId;static fromProto(r){let t=new Map;for(let a of r.offering??[])t.set(a.resource,a.count);let o=new Map;for(let a of r.requesting??[])o.set(a.resource,a.count);let i=new Map;for(let a of r.offeringCommodities??[])i.set(a.commodity,a.count);let n=new Map;for(let a of r.requestingCommodities??[])n.set(a.commodity,a.count);return new e(r.id,r.proposer,t,o,new Set(r.acceptingPlayers??[]),new Set(r.rejectedPlayers??[]),i,n,r.offeringGold,r.requestingGold,r.counterTradeId)}constructor(r,t,o,i,n=new Set,a=new Set,s=new Map,u=new Map,l=0,c=0,f=0){this.id=r,this.proposer=t,this.offering=o,this.requesting=i,this.acceptingPlayers=n,this.rejectedPlayers=a,this.offeringCommodities=s,this.requestingCommodities=u,this.offeringGold=l,this.requestingGold=c,this.counterTradeId=f}toProto(){let r=[];for(let[n,a]of this.offering)r.push(ne.create({resource:n,count:a}));let t=[];for(let[n,a]of this.requesting)t.push(ne.create({resource:n,count:a}));let o=[];for(let[n,a]of this.offeringCommodities)o.push(te.create({commodity:n,count:a}));let i=[];for(let[n,a]of this.requestingCommodities)i.push(te.create({commodity:n,count:a}));return ei.create({id:this.id,proposer:this.proposer,offering:r,requesting:t,acceptingPlayers:Array.from(this.acceptingPlayers),rejectedPlayers:Array.from(this.rejectedPlayers),offeringCommodities:o,requestingCommodities:i,offeringGold:this.offeringGold,requestingGold:this.requestingGold,counterTradeId:this.counterTradeId})}hasAcceptingPlayer(r){return this.acceptingPlayers.has(r)}get acceptingPlayerCount(){return this.acceptingPlayers.size}hasAcceptingPlayers(){return this.acceptingPlayers.size>0}withPlayerAccepting(r){if(r===this.proposer)throw new Error("Proposer cannot accept their own trade");let t=new Set(this.acceptingPlayers);t.add(r);let o=new Set(this.rejectedPlayers);return o.delete(r),new e(this.id,this.proposer,this.offering,this.requesting,t,o,this.offeringCommodities,this.requestingCommodities,this.offeringGold,this.requestingGold,this.counterTradeId)}withPlayerRevoking(r){let t=new Set(this.acceptingPlayers);return t.delete(r),new e(this.id,this.proposer,this.offering,this.requesting,t,this.rejectedPlayers,this.offeringCommodities,this.requestingCommodities,this.offeringGold,this.requestingGold,this.counterTradeId)}withPlayerRejecting(r){if(r===this.proposer)throw new Error("Proposer cannot reject their own trade");let t=new Set(this.rejectedPlayers);t.add(r);let o=new Set(this.acceptingPlayers);return o.delete(r),new e(this.id,this.proposer,this.offering,this.requesting,o,t,this.offeringCommodities,this.requestingCommodities,this.offeringGold,this.requestingGold,this.counterTradeId)}hasRejectedPlayer(r){return this.rejectedPlayers.has(r)}getOfferingCount(r){return this.offering.get(r)??0}getRequestingCount(r){return this.requesting.get(r)??0}getOfferingCommodityCount(r){return this.offeringCommodities.get(r)??0}getRequestingCommodityCount(r){return this.requestingCommodities.get(r)??0}get totalOffering(){let r=0;for(let t of this.offering.values())r+=t;for(let t of this.offeringCommodities.values())r+=t;return r+=this.offeringGold,r}get totalRequesting(){let r=0;for(let t of this.requesting.values())r+=t;for(let t of this.requestingCommodities.values())r+=t;return r+=this.requestingGold,r}};var dD={[Me.GAME_SPEED_MODE_UNSPECIFIED]:[0,0],[Me.GAME_SPEED_MODE_NONE]:[0,0],[Me.GAME_SPEED_MODE_ULTRA_BULLET]:[9e4,5e3],[Me.GAME_SPEED_MODE_BULLET]:[18e4,1e4],[Me.GAME_SPEED_MODE_BLITZ]:[3e5,15e3],[Me.GAME_SPEED_MODE_RAPID]:[6e5,2e4],[Me.GAME_SPEED_MODE_CLASSIC]:[12e5,3e4],[Me.GAME_SPEED_MODE_RELAXED]:[6e6,45e3],[Me.UNRECOGNIZED]:[0,0]},c2={[Me.GAME_SPEED_MODE_UNSPECIFIED]:{turn:0,diceRoll:0,discard:0,robberPlacement:0,robberSteal:0,devCard:0,buildAction:0,tradeResponse:0,resourceSelect:0},[Me.GAME_SPEED_MODE_NONE]:{turn:0,diceRoll:0,discard:0,robberPlacement:0,robberSteal:0,devCard:0,buildAction:0,tradeResponse:0,resourceSelect:0},[Me.GAME_SPEED_MODE_ULTRA_BULLET]:{turn:15e3,diceRoll:5e3,discard:1e4,robberPlacement:1e4,robberSteal:5e3,devCard:1e4,buildAction:1e4,tradeResponse:1e4,resourceSelect:1e4},[Me.GAME_SPEED_MODE_BULLET]:{turn:3e4,diceRoll:1e4,discard:15e3,robberPlacement:15e3,robberSteal:1e4,devCard:15e3,buildAction:15e3,tradeResponse:15e3,resourceSelect:15e3},[Me.GAME_SPEED_MODE_BLITZ]:{turn:6e4,diceRoll:15e3,discard:2e4,robberPlacement:2e4,robberSteal:15e3,devCard:2e4,buildAction:2e4,tradeResponse:2e4,resourceSelect:2e4},[Me.GAME_SPEED_MODE_RAPID]:{turn:12e4,diceRoll:2e4,discard:3e4,robberPlacement:3e4,robberSteal:2e4,devCard:3e4,buildAction:3e4,tradeResponse:3e4,resourceSelect:3e4},[Me.GAME_SPEED_MODE_CLASSIC]:{turn:24e4,diceRoll:3e4,discard:45e3,robberPlacement:45e3,robberSteal:3e4,devCard:45e3,buildAction:45e3,tradeResponse:45e3,resourceSelect:45e3},[Me.GAME_SPEED_MODE_RELAXED]:{turn:36e4,diceRoll:45e3,discard:6e4,robberPlacement:6e4,robberSteal:45e3,devCard:6e4,buildAction:6e4,tradeResponse:6e4,resourceSelect:6e4},[Me.UNRECOGNIZED]:{turn:0,diceRoll:0,discard:0,robberPlacement:0,robberSteal:0,devCard:0,buildAction:0,tradeResponse:0,resourceSelect:0}},f2={[Me.GAME_SPEED_MODE_UNSPECIFIED]:0,[Me.GAME_SPEED_MODE_NONE]:0,[Me.GAME_SPEED_MODE_ULTRA_BULLET]:2e3,[Me.GAME_SPEED_MODE_BULLET]:3e3,[Me.GAME_SPEED_MODE_BLITZ]:5e3,[Me.GAME_SPEED_MODE_RAPID]:8e3,[Me.GAME_SPEED_MODE_CLASSIC]:1e4,[Me.GAME_SPEED_MODE_RELAXED]:15e3,[Me.UNRECOGNIZED]:0},uD=3;var eE=Tt.TIMER_MODE_NONE,rE=Me.GAME_SPEED_MODE_NONE,tE=3,nE=3e4;var ED={initialTimeMultiplier:1,disableIncrements:!1};function lD(e){return e===0?1:e<.01?.01:e>1?1:e}E(lD,"resolveInitialTimeMultiplier");var Ma=class e{static{E(this,"TimerConfig")}mode;speedMode;initialTimeMs;incrementMs;maxExtensions;extensionTimeMs;playerOverrides;constructor(r=eE,t=rE,o,i,n=tE,a=nE,s=new Map){this.mode=r,this.speedMode=t;let u=dD[t]||[0,0];this.initialTimeMs=o!==void 0?o:u[0],this.incrementMs=i!==void 0?i:u[1],this.maxExtensions=n,this.extensionTimeMs=a,this.playerOverrides=s}static builder(){return new iE}getPlayerOverride(r){return this.playerOverrides.get(r)??ED}getInitialTimeMsForPlayer(r){let{initialTimeMultiplier:t}=this.getPlayerOverride(r);return Math.floor(this.initialTimeMs*lD(t))}getIncrementMsForPlayer(r){let{disableIncrements:t}=this.getPlayerOverride(r);return t?0:this.incrementMs}static fromProto(r){if(!r)return new e;let t=new Map;for(let o of r.playerOverrides??[])t.set(o.player,{initialTimeMultiplier:o.initialTimeMultiplier,disableIncrements:o.disableIncrements});return new e(r.mode||eE,r.speedMode||rE,r.initialTimeMs||void 0,r.incrementMs||void 0,r.maxExtensions||tE,r.extensionTimeMs||nE,t)}toProto(){let r=[];for(let[t,o]of this.playerOverrides)r.push({player:t,initialTimeMultiplier:o.initialTimeMultiplier,disableIncrements:o.disableIncrements});return{mode:this.mode,speedMode:this.speedMode,initialTimeMs:this.initialTimeMs,incrementMs:this.incrementMs,maxExtensions:this.maxExtensions,extensionTimeMs:this.extensionTimeMs,playerOverrides:r}}isEnabled(){return this.mode!==Tt.TIMER_MODE_NONE&&this.mode!==Tt.TIMER_MODE_UNSPECIFIED}isChessClock(){return this.mode===Tt.TIMER_MODE_CHESS_CLOCK}isLegacy(){return this.mode===Tt.TIMER_MODE_LEGACY}static createDisabled(){return new e(Tt.TIMER_MODE_NONE)}static createChessClock(r){return e.builder().mode(Tt.TIMER_MODE_CHESS_CLOCK).speedMode(r).build()}static create1v1Rapid(){return e.builder().mode(Tt.TIMER_MODE_CHESS_CLOCK).speedMode(Me.GAME_SPEED_MODE_RAPID).initialTimeMs(6e4).incrementMs(5e3).build()}static create1v1Blitz(){return e.createChessClock(Me.GAME_SPEED_MODE_BLITZ)}static create1v1Bullet(){return e.createChessClock(Me.GAME_SPEED_MODE_BULLET)}static createLegacy(r){return e.builder().mode(Tt.TIMER_MODE_LEGACY).speedMode(r).build()}static createLegacyRapid(){return e.createLegacy(Me.GAME_SPEED_MODE_RAPID)}static createLegacyBlitz(){return e.createLegacy(Me.GAME_SPEED_MODE_BLITZ)}static createLegacyClassic(){return e.createLegacy(Me.GAME_SPEED_MODE_CLASSIC)}},iE=class{static{E(this,"TimerConfigBuilder")}_mode=eE;_speedMode=rE;_initialTimeMs;_incrementMs;_maxExtensions=tE;_extensionTimeMs=nE;_playerOverrides=new Map;mode(r){return this._mode=r,this}speedMode(r){return this._speedMode=r,this}playerOverride(r,t){return this._playerOverrides.set(r,t),this}initialTimeMs(r){return this._initialTimeMs=r,this}incrementMs(r){return this._incrementMs=r,this}maxExtensions(r){return this._maxExtensions=r,this}extensionTimeMs(r){return this._extensionTimeMs=r,this}build(){return new Ma(this._mode,this._speedMode,this._initialTimeMs,this._incrementMs,this._maxExtensions,this._extensionTimeMs,new Map(this._playerOverrides))}},i_=class e{static{E(this,"PlayerTimerState")}remainingTimeMs;clockStartedAt;extensionsUsed;activityBonusesThisTurn;constructor(r=0,t=0,o=0,i=0){this.remainingTimeMs=r,this.clockStartedAt=t,this.extensionsUsed=o,this.activityBonusesThisTurn=i}static fromProto(r){return r?new e(Number(r.remainingTimeMs),r.clockStartedAt?.getTime()??0,r.extensionsUsed,r.activityBonusesThisTurn):new e}toProto(){let r={remainingTimeMs:this.remainingTimeMs,extensionsUsed:this.extensionsUsed,activityBonusesThisTurn:this.activityBonusesThisTurn};return this.clockStartedAt>0&&(r.clockStartedAt=new Date(this.clockStartedAt)),r}isRunning(){return this.clockStartedAt>0}getCurrentRemainingTime(r=Date.now()){if(!this.isRunning())return this.remainingTimeMs;let t=r-this.clockStartedAt;return Math.max(0,this.remainingTimeMs-t)}isExpired(r=Date.now()){return this.getCurrentRemainingTime(r)<=0}startClock(r=Date.now()){this.isRunning()||(this.clockStartedAt=r)}stopClock(r=Date.now()){this.isRunning()&&(this.remainingTimeMs=this.getCurrentRemainingTime(r),this.clockStartedAt=0)}addTime(r){this.remainingTimeMs+=r}resetActivityBonuses(){this.activityBonusesThisTurn=0}clone(){return new e(this.remainingTimeMs,this.clockStartedAt,this.extensionsUsed,this.activityBonusesThisTurn)}},Ft=class e{static{E(this,"GameTimerState")}playerTimers;serverTime;currentAction;constructor(r,t=Date.now(),o=Ve.TIMEOUT_ACTION_UNSPECIFIED){this.playerTimers=r||new Map,this.serverTime=t,this.currentAction=o}static fromProto(r){if(!r)return new e;let t=new Map;for(let o of r.playerTimers)t.set(o.player,i_.fromProto(o.timerState));return new e(t,r.serverTime?.getTime()??0,r.currentAction||Ve.TIMEOUT_ACTION_UNSPECIFIED)}toProto(){let r=[];for(let[t,o]of this.playerTimers)r.push({player:t,timerState:o.toProto()});return{playerTimers:r,serverTime:new Date(this.serverTime),currentAction:this.currentAction}}getPlayerTimer(r){return this.playerTimers.get(r)}setPlayerTimer(r,t){this.playerTimers.set(r,t)}initializeTimers(r,t){for(let o of r)this.playerTimers.set(o,new i_(t.getInitialTimeMsForPlayer(o)));this.serverTime=Date.now()}startPlayerClock(r,t=Date.now()){let o=this.playerTimers.get(r);o&&(o.startClock(t),this.serverTime=t)}stopPlayerClock(r,t=Date.now()){let o=this.playerTimers.get(r);o&&(o.stopClock(t),this.serverTime=t)}stopAllClocks(r=Date.now()){for(let t of this.playerTimers.values())t.stopClock(r);this.serverTime=r}addIncrement(r,t){let o=this.playerTimers.get(r);if(o&&t.isChessClock()){let i=t.getIncrementMsForPlayer(r);i>0&&o.addTime(i)}}resetActivityBonuses(r){let t=this.playerTimers.get(r);t&&t.resetActivityBonuses()}isPlayerTimeExpired(r,t=Date.now()){let o=this.playerTimers.get(r);return o?o.isExpired(t):!1}getPlayers(){return Array.from(this.playerTimers.keys())}clone(){let r=new Map;for(let[t,o]of this.playerTimers)r.set(t,o.clone());return new e(r,this.serverTime,this.currentAction)}setCurrentAction(r){this.currentAction=r}clearCurrentAction(){this.currentAction=Ve.TIMEOUT_ACTION_UNSPECIFIED}initializeLegacyTimers(r){for(let t of r)this.playerTimers.set(t,new i_(0));this.serverTime=Date.now(),this.currentAction=Ve.TIMEOUT_ACTION_UNSPECIFIED}startActionTimer(r,t,o,i=Date.now()){let n=this.playerTimers.get(r);n&&(n.remainingTimeMs=o,n.startClock(i),this.serverTime=i,this.currentAction=t)}completeActionTimer(r,t=Date.now()){let o=this.playerTimers.get(r);o&&(o.stopClock(t),o.remainingTimeMs=0,this.serverTime=t,this.currentAction=Ve.TIMEOUT_ACTION_UNSPECIFIED)}applyActivityBonus(r,t){let o=this.playerTimers.get(r);return!o||o.activityBonusesThisTurn>=uD?!1:(o.addTime(t),o.activityBonusesThisTurn++,!0)}requestExtension(r,t,o){let i=this.playerTimers.get(r);return!i||i.extensionsUsed>=o?!1:(i.addTime(t),i.extensionsUsed++,!0)}getRemainingExtensions(r,t){let o=this.playerTimers.get(r);return o?Math.max(0,t-o.extensionsUsed):0}};var cD=-1,Ad=120,La=class e{static{E(this,"PauseConfig")}pausesPerPlayer;voteCountdownSeconds;constructor(r=cD,t=Ad){this.pausesPerPlayer=r,this.voteCountdownSeconds=t}static fromProto(r){return r?new e(r.pausesPerPlayer,r.voteCountdownSeconds||Ad):new e}toProto(){return{pausesPerPlayer:this.pausesPerPlayer,voteCountdownSeconds:this.voteCountdownSeconds}}isPausingEnabled(){return this.pausesPerPlayer>=0}canPlayerPause(r){return this.isPausingEnabled()?this.pausesPerPlayer===0?!0:r<this.pausesPerPlayer:!1}getRemainingPauses(r){return this.isPausingEnabled()?this.pausesPerPlayer===0?-1:Math.max(0,this.pausesPerPlayer-r):0}static createDisabled(){return new e(-1)}static create1v1Default(){return new e(3,120)}static createUnlimited(r=Ad){return new e(0,r)}static create(r,t=Ad){return new e(r,t)}},Ga=class e{static{E(this,"PauseState")}pausedBy;pausedAt;votesToContinue;countdownStartedAt;pauseCounts;constructor(r=x.PLAYER_COLOR_UNSPECIFIED,t=0,o=new Set,i=0,n=new Map){this.pausedBy=r,this.pausedAt=t,this.votesToContinue=o,this.countdownStartedAt=i,this.pauseCounts=n}static fromProto(r){if(!r||r.pausedBy===x.PLAYER_COLOR_UNSPECIFIED)return;let t=new Set(r.votesToContinue),o=new Map;for(let i of r.pauseCounts)o.set(i.player,i.count);return new e(r.pausedBy,r.pausedAt?.getTime()??0,t,r.countdownStartedAt?.getTime()??0,o)}toProto(){let r=[];for(let[t,o]of this.pauseCounts)r.push({player:t,count:o});return{pausedBy:this.pausedBy,pausedAt:new Date(this.pausedAt),votesToContinue:Array.from(this.votesToContinue),countdownStartedAt:this.countdownStartedAt>0?new Date(this.countdownStartedAt):void 0,pauseCounts:r}}hasVoted(r){return this.votesToContinue.has(r)}getVoteCount(){return this.votesToContinue.size}hasCountdownStarted(){return this.countdownStartedAt>0}getCountdownRemainingMs(r,t=Date.now()){if(!this.hasCountdownStarted())return r.voteCountdownSeconds*1e3;let o=t-this.countdownStartedAt;return r.voteCountdownSeconds*1e3-o}isCountdownExpired(r,t=Date.now()){return this.hasCountdownStarted()&&this.getCountdownRemainingMs(r,t)<=0}getPauseCount(r){return this.pauseCounts.get(r)||0}withVote(r,t=Date.now()){if(this.hasVoted(r))return this;let o=new Set(this.votesToContinue);o.add(r);let i=this.countdownStartedAt||t;return new e(this.pausedBy,this.pausedAt,o,i,new Map(this.pauseCounts))}withIncrementedPauseCount(r){let t=new Map(this.pauseCounts);return t.set(r,(t.get(r)||0)+1),new e(this.pausedBy,this.pausedAt,new Set(this.votesToContinue),this.countdownStartedAt,t)}static create(r,t=Date.now(),o=new Map){let i=new Map(o);return i.set(r,(i.get(r)||0)+1),new e(r,t,new Set,0,i)}allHumansVoted(r){for(let t of r)if(!this.hasVoted(t))return!1;return!0}};var Sd=10,oE=7,aE=!1,sE=5,_E=4,dE=15,uE=15,EE=0,Od=!1,lE=2,cE=2,fE=2,TE=3,GT=13,NE=!1,RE=!1,AE=!1,SE=!1,OE=19,IE=12,CE=F.BUILDING_SETTLEMENT,o_=F.BUILDING_SETTLEMENT,PE=!1,pE=!1,hE=22,DE=!1,mE=3,gE=!1,yE=zr.ROBBER_MODE_NORMAL,ME=br.DICE_MODE_RANDOM,LE=0,GE=0,UE=0,BE=fr.WIN_CONDITION_VICTORY_POINTS,kE=0,bE=.25,UT=Ma.createDisabled(),BT=La.createDisabled(),vE=B.MAP_TYPE_UNSPECIFIED,YE=0,FE=!1,VE=!1,xE=!1,wE=kt.DYNAMIC_HEX_MODE_OFF,HE=!1,KE=1,WE=!0,JE=lt.FOUND_ON_FOG_MODE_DISABLED,qE=Gr.FOG_MODE_OFF,ZE=tr.SETUP_PLACEMENT_MODE_NORMAL,XE=tr.SETUP_PLACEMENT_MODE_NORMAL,zE=!1,$E=Ys.MAP_SHUFFLE_MODE_NONE,QE=Fs.MAP_SHUFFLE_SCOPE_GLOBAL,jE=!1,el=0,rl=!1,tl=!1,nl=!1,il=!1,ol=!1,al=!1,sl=1,_l=!1,dl=15,ul=$r.TRADE_MODE_NORMAL,a_=class e{static{E(this,"BoardGenerationOptions")}numberLayout;portLayout;desertPlacement;resourceAdjacencyTarget;portMatchingTarget;resourceAbundance;constructor(r=Vr.NUMBER_LAYOUT_UNSPECIFIED,t=ct.PORT_LAYOUT_MODE_UNSPECIFIED,o=ft.DESERT_PLACEMENT_UNSPECIFIED,i=0,n=0,a){this.numberLayout=r,this.portLayout=t,this.desertPlacement=o,this.resourceAdjacencyTarget=i,this.portMatchingTarget=n,this.resourceAbundance=a}isCustomized(){return this.numberLayout!==Vr.NUMBER_LAYOUT_UNSPECIFIED||this.portLayout!==ct.PORT_LAYOUT_MODE_UNSPECIFIED||this.desertPlacement!==ft.DESERT_PLACEMENT_UNSPECIFIED||this.resourceAdjacencyTarget!==0||this.portMatchingTarget!==0||this.resourceAbundance!==void 0}static fromProto(r){return r?new e(r.numberLayout,r.portLayout,r.desertPlacement,r.resourceAdjacencyTarget,r.portMatchingTarget):ll}toProto(){return{numberLayout:this.numberLayout,portLayout:this.portLayout,desertPlacement:this.desertPlacement,resourceAdjacencyTarget:this.resourceAdjacencyTarget,portMatchingTarget:this.portMatchingTarget}}static DEFAULT=new e},ll=a_.DEFAULT,Id=class e{static{E(this,"ResourceGoal")}resource;targetAmount;mode;constructor(r=S.RESOURCE_UNSPECIFIED,t=0,o=Gn.RESOURCE_GOAL_MODE_CUMULATIVE){this.resource=r,this.targetAmount=t,this.mode=o}static fromProto(r){if(!(!r||r.resource===S.RESOURCE_UNSPECIFIED))return new e(r.resource,r.targetAmount,r.mode)}toProto(){return{resource:this.resource,targetAmount:this.targetAmount,mode:this.mode}}},El=class{static{E(this,"GameOptionsBuilder")}_victoryPoints=Sd;_discardLimit=oE;_seafarers=aE;_maxSettlements=sE;_maxCities=_E;_maxRoads=dE;_maxShips=uE;_seed=EE;_citiesAndKnights=Od;_maxBasicKnights=lE;_maxStrongKnights=cE;_maxMightyKnights=fE;_maxCityWalls=TE;_resourceCardCount=OE;_commodityCardCount=IE;_firstFound=CE;_secondFound=o_;_secondFoundExplicitlySet=!1;_fisherman=PE;_merchantTrains=pE;_numberWagons=hE;_rivers=DE;_maxBridges=mE;_robberMode=yE;_diceMode=ME;_diceSeed=LE;_devCardSeed=GE;_stealSeed=UE;_winCondition=BE;_turnLimit=kE;_resourceGoal=void 0;_balancedDiceBounds=bE;_timerConfig=UT;_pauseConfig=BT;_ckKnightErrant=NE;_ckEasyStart=RE;_ckNastyBarbarians=AE;_turboMode=SE;_mapType=vE;_harbormaster=gE;_newIslandSettlementBonus=YE;_desertsBlockIslands=FE;_secondSettler=VE;_eventCards=xE;_dynamicHexMode=wE;_robberLockedToBiggestIsland=HE;_fogReward=KE;_fogBonusDuringSetup=WE;_foundOnFog=JE;_fogMode=qE;_firstSettleMode=ZE;_secondSettleMode=XE;_restrictFoundingToLargestIsland=zE;_mapShuffleMode=$E;_mapShuffleScope=QE;_setupPrediction=jE;_tradeResponseTimeoutMs=el;_noSevens=rl;_revealFogOnGameStart=tl;_hideDiceStats=nl;_hidePlayedDevCards=il;_disableCounterOffers=ol;_trolls=al;_numberOfRobbers=sl;_boardGeneration=ll;_rushMode=_l;_rushDiceIntervalSeconds=dl;_tradeMode=ul;victoryPoints(r){return this._victoryPoints=r,this}discardLimit(r){return this._discardLimit=r,this}seafarers(r){return this._seafarers=r,this}maxSettlements(r){return this._maxSettlements=r,this}maxCities(r){return this._maxCities=r,this}maxRoads(r){return this._maxRoads=r,this}maxShips(r){return this._maxShips=r,this}seed(r){return this._seed=r,this}citiesAndKnights(r){return this._citiesAndKnights=r,this}maxBasicKnights(r){return this._maxBasicKnights=r,this}maxStrongKnights(r){return this._maxStrongKnights=r,this}maxMightyKnights(r){return this._maxMightyKnights=r,this}maxCityWalls(r){return this._maxCityWalls=r,this}resourceCardCount(r){return this._resourceCardCount=r,this}commodityCardCount(r){return this._commodityCardCount=r,this}firstFound(r){return this._firstFound=r,this}secondFound(r){return this._secondFound=r,this._secondFoundExplicitlySet=!0,this}fisherman(r){return this._fisherman=r,this}merchantTrains(r){return this._merchantTrains=r,this}numberWagons(r){return this._numberWagons=r,this}rivers(r){return this._rivers=r,this}maxBridges(r){return this._maxBridges=r,this}robberMode(r){return this._robberMode=r,this}diceMode(r){return this._diceMode=r,this}diceSeed(r){return this._diceSeed=r,this}devCardSeed(r){return this._devCardSeed=r,this}stealSeed(r){return this._stealSeed=r,this}winCondition(r){return this._winCondition=r,this}turnLimit(r){return this._turnLimit=r,this}resourceGoal(r){return this._resourceGoal=r,this}balancedDiceBounds(r){return this._balancedDiceBounds=r,this}timerConfig(r){return this._timerConfig=r,this}pauseConfig(r){return this._pauseConfig=r,this}ckKnightErrant(r){return this._ckKnightErrant=r,this}ckEasyStart(r){return this._ckEasyStart=r,this}ckNastyBarbarians(r){return this._ckNastyBarbarians=r,this}turboMode(r){return this._turboMode=r,this}mapType(r){return this._mapType=r,this}harbormaster(r){return this._harbormaster=r,this}newIslandSettlementBonus(r){return this._newIslandSettlementBonus=r,this}desertsBlockIslands(r){return this._desertsBlockIslands=r,this}secondSettler(r){return this._secondSettler=r,this}eventCards(r){return this._eventCards=r,this}dynamicHexMode(r){return this._dynamicHexMode=r,this}robberLockedToBiggestIsland(r){return this._robberLockedToBiggestIsland=r,this}fogReward(r){return this._fogReward=r,this}fogBonusDuringSetup(r){return this._fogBonusDuringSetup=r,this}foundOnFog(r){return this._foundOnFog=r,this}fogMode(r){return this._fogMode=r,this}firstSettleMode(r){return this._firstSettleMode=r,this}secondSettleMode(r){return this._secondSettleMode=r,this}restrictFoundingToLargestIsland(r){return this._restrictFoundingToLargestIsland=r,this}mapShuffleMode(r){return this._mapShuffleMode=r,this}mapShuffleScope(r){return this._mapShuffleScope=r,this}setupPrediction(r){return this._setupPrediction=r,this}tradeResponseTimeoutMs(r){return this._tradeResponseTimeoutMs=r,this}noSevens(r){return this._noSevens=r,this}revealFogOnGameStart(r){return this._revealFogOnGameStart=r,this}hideDiceStats(r){return this._hideDiceStats=r,this}hidePlayedDevCards(r){return this._hidePlayedDevCards=r,this}disableCounterOffers(r){return this._disableCounterOffers=r,this}trolls(r){return this._trolls=r,this}numberOfRobbers(r){return this._numberOfRobbers=r,this}boardGeneration(r){return this._boardGeneration=r,this}rushMode(r){return this._rushMode=r,this}rushDiceIntervalSeconds(r){return this._rushDiceIntervalSeconds=r,this}tradeMode(r){return this._tradeMode=r,this}build(){let r=this._citiesAndKnights&&!this._secondFoundExplicitlySet?F.BUILDING_CITY:this._secondFound,t=this._fogMode===Gr.FOG_MODE_FOG_START||this._fogMode===Gr.FOG_MODE_MIST_START,o=t?lt.FOUND_ON_FOG_MODE_WITHIN:this._foundOnFog,i=t?0:this._fogReward,n=t?!1:this._fogBonusDuringSetup;return new yt(this._victoryPoints,this._discardLimit,this._seafarers,this._maxSettlements,this._maxCities,this._maxRoads,this._maxShips,this._seed,this._citiesAndKnights,this._maxBasicKnights,this._maxStrongKnights,this._maxMightyKnights,this._maxCityWalls,this._resourceCardCount,this._commodityCardCount,this._firstFound,r,this._fisherman,this._merchantTrains,this._numberWagons,this._rivers,this._maxBridges,this._robberMode,this._diceMode,this._diceSeed,this._devCardSeed,this._stealSeed,this._winCondition,this._turnLimit,this._resourceGoal,this._balancedDiceBounds,this._timerConfig,this._pauseConfig,this._ckKnightErrant,this._ckEasyStart,this._ckNastyBarbarians,this._turboMode,this._mapType,this._harbormaster,this._newIslandSettlementBonus,this._desertsBlockIslands,this._secondSettler,this._eventCards,this._dynamicHexMode,this._robberLockedToBiggestIsland,i,n,o,this._fogMode,this._firstSettleMode,this._secondSettleMode,this._restrictFoundingToLargestIsland,this._mapShuffleMode,this._mapShuffleScope,this._setupPrediction,this._tradeResponseTimeoutMs,this._noSevens,this._trolls,this._numberOfRobbers,this._boardGeneration,this._rushMode,this._rushDiceIntervalSeconds,this._tradeMode,this._revealFogOnGameStart,this._hideDiceStats,this._hidePlayedDevCards,this._disableCounterOffers)}},yt=class e{static{E(this,"GameOptions")}victoryPoints;discardLimit;seafarers;maxSettlements;maxCities;maxRoads;maxShips;seed;citiesAndKnights;maxBasicKnights;maxStrongKnights;maxMightyKnights;maxCityWalls;resourceCardCount;commodityCardCount;firstFound;secondFound;fisherman;merchantTrains;numberWagons;rivers;maxBridges;robberMode;diceMode;diceSeed;devCardSeed;stealSeed;winCondition;turnLimit;resourceGoal;balancedDiceBounds;timerConfig;pauseConfig;ckKnightErrant;ckEasyStart;ckNastyBarbarians;turboMode;mapType;harbormaster;newIslandSettlementBonus;desertsBlockIslands;secondSettler;eventCards;dynamicHexMode;robberLockedToBiggestIsland;fogReward;fogBonusDuringSetup;foundOnFog;fogMode;firstSettleMode;secondSettleMode;restrictFoundingToLargestIsland;mapShuffleMode;mapShuffleScope;setupPrediction;tradeResponseTimeoutMs;noSevens;revealFogOnGameStart;hideDiceStats;hidePlayedDevCards;disableCounterOffers;trolls;numberOfRobbers;boardGeneration;rushMode;rushDiceIntervalSeconds;tradeMode;static builder(){return new El}static fromProto(r){let t=e.builder().victoryPoints(r.victoryPoints||Sd).discardLimit(r.discardLimit||oE).seafarers(r.seafarers||aE).maxSettlements(r.maxSettlements||sE).maxCities(r.maxCities||_E).maxRoads(r.maxRoads||dE).maxShips(r.maxShips||uE).seed(Number(r.seed)||EE).citiesAndKnights(r.citiesAndKnights||Od).maxBasicKnights(r.maxBasicKnights||lE).maxStrongKnights(r.maxStrongKnights||cE).maxMightyKnights(r.maxMightyKnights||fE).maxCityWalls(r.maxCityWalls||TE).resourceCardCount(r.resourceCardCount||OE).commodityCardCount(r.commodityCardCount||IE).firstFound(r.firstFound||CE),o=r.secondFound||o_,n=r.citiesAndKnights||Od?F.BUILDING_CITY:o_;return o!==n&&t.secondFound(o),t.fisherman(r.fisherman||PE).merchantTrains(r.merchantTrains||pE).numberWagons(r.numberWagons||hE).rivers(r.rivers||DE).maxBridges(r.maxBridges||mE).robberMode(r.robberMode||yE).diceMode(r.diceMode||ME).diceSeed(Number(r.diceSeed)||LE).devCardSeed(Number(r.devCardSeed)||GE).stealSeed(Number(r.stealSeed)||UE).winCondition(r.winCondition||BE).turnLimit(r.turnLimit||kE).resourceGoal(Id.fromProto(r.resourceGoal)).balancedDiceBounds(r.balancedDiceBounds||bE).timerConfig(Ma.fromProto(r.timerConfig)).pauseConfig(La.fromProto(r.pauseConfig)).ckKnightErrant(r.ckKnightErrant||NE).ckEasyStart(r.ckEasyStart||RE).ckNastyBarbarians(r.ckNastyBarbarians||AE).turboMode(r.turboMode||SE).mapType(r.mapType||vE).harbormaster(r.harbormaster||gE).newIslandSettlementBonus(r.newIslandSettlementBonus||YE).desertsBlockIslands(r.desertsBlockIslands||FE).secondSettler(r.secondSettler||VE).eventCards(r.eventCards||xE).dynamicHexMode(r.dynamicHexMode||wE).robberLockedToBiggestIsland(r.robberLockedToBiggestIsland||HE).fogReward(r.fogReward??KE).fogBonusDuringSetup(r.fogBonusDuringSetup??WE).foundOnFog(r.foundOnFog??JE).fogMode(r.fogMode??qE).firstSettleMode(r.firstSettleMode??ZE).secondSettleMode(r.secondSettleMode??XE).restrictFoundingToLargestIsland(r.restrictFoundingToLargestIsland??zE).mapShuffleMode(r.mapShuffleMode??$E).mapShuffleScope(r.mapShuffleScope??QE).setupPrediction(r.setupPrediction??jE).tradeResponseTimeoutMs(r.tradeResponseTimeoutMs??el).noSevens(r.noSevens??rl).trolls(r.trolls??al).numberOfRobbers(r.numberOfRobbers??sl).boardGeneration(a_.fromProto(r.boardGeneration)).rushMode(r.rushMode??_l).rushDiceIntervalSeconds(r.rushDiceIntervalSeconds||dl).tradeMode(r.tradeMode??ul).revealFogOnGameStart(r.revealFogOnGameStart??tl).hideDiceStats(r.hideDiceStats??nl).hidePlayedDevCards(r.hidePlayedDevCards??il).disableCounterOffers(r.disableCounterOffers??ol).build()}static createDefault(){return e.builder().build()}static createSeafarers(r=Sd){return e.builder().victoryPoints(r).seafarers(!0).build()}static createCitiesAndKnights(){return e.builder().victoryPoints(GT).citiesAndKnights(!0).build()}static createCombinedExpansions(){return e.builder().victoryPoints(GT).seafarers(!0).citiesAndKnights(!0).build()}static createEventCards(){return e.builder().eventCards(!0).diceMode(br.DICE_MODE_EVENT_CARDS).build()}constructor(r=Sd,t=oE,o=aE,i=sE,n=_E,a=dE,s=uE,u=EE,l=Od,c=lE,f=cE,T=fE,R=TE,O=OE,I=IE,D=CE,g=o_,k=PE,v=pE,Y=hE,V=DE,w=mE,J=yE,$=ME,he=LE,De=GE,ve=UE,Be=BE,Ye=kE,Or=void 0,Fe=bE,He=UT,Xr=BT,Fr=NE,Lr=RE,Ln=AE,Pa=SE,Ls=vE,Gs=gE,Us=YE,Bs=FE,ks=VE,bs=xE,X=wE,pt=HE,vs=KE,Gu=WE,Uu=JE,Bu=qE,ku=ZE,bu=XE,vu=zE,Yu=$E,Fu=QE,Vu=jE,xu=el,wu=rl,Hu=al,Ku=sl,Wu=ll,Ju=_l,qu=dl,Zu=ul,Xu=tl,zu=nl,$u=il,Qu=ol){this.victoryPoints=r,this.discardLimit=t,this.seafarers=o,this.maxSettlements=i,this.maxCities=n,this.maxRoads=a,this.maxShips=s,this.seed=u,this.citiesAndKnights=l,this.maxBasicKnights=c,this.maxStrongKnights=f,this.maxMightyKnights=T,this.maxCityWalls=R,this.resourceCardCount=O,this.commodityCardCount=I,this.firstFound=D,this.secondFound=g,this.fisherman=k,this.merchantTrains=v,this.numberWagons=Y,this.rivers=V,this.maxBridges=w,this.robberMode=J,this.diceMode=$,this.diceSeed=he,this.devCardSeed=De,this.stealSeed=ve,this.winCondition=Be,this.turnLimit=Ye,this.resourceGoal=Or,this.balancedDiceBounds=Fe,this.timerConfig=He,this.pauseConfig=Xr,this.ckKnightErrant=Fr,this.ckEasyStart=Lr,this.ckNastyBarbarians=Ln,this.turboMode=Pa,this.mapType=Ls,this.harbormaster=Gs,this.newIslandSettlementBonus=Us,this.desertsBlockIslands=Bs,this.secondSettler=ks,this.eventCards=bs,this.dynamicHexMode=X,this.robberLockedToBiggestIsland=pt,this.fogReward=vs,this.fogBonusDuringSetup=Gu,this.foundOnFog=Uu,this.fogMode=Bu,this.firstSettleMode=ku,this.secondSettleMode=bu,this.restrictFoundingToLargestIsland=vu,this.mapShuffleMode=Yu,this.mapShuffleScope=Fu,this.setupPrediction=Vu,this.tradeResponseTimeoutMs=xu,this.noSevens=wu,this.trolls=Hu,this.numberOfRobbers=Ku,this.boardGeneration=Wu,this.rushMode=Ju,this.rushDiceIntervalSeconds=qu,this.tradeMode=Zu,this.revealFogOnGameStart=Xu,this.hideDiceStats=zu,this.hidePlayedDevCards=$u,this.disableCounterOffers=Qu}toProto(){return li.create({victoryPoints:this.victoryPoints,discardLimit:this.discardLimit,seafarers:this.seafarers,maxSettlements:this.maxSettlements,maxCities:this.maxCities,maxRoads:this.maxRoads,maxShips:this.maxShips,seed:this.seed,citiesAndKnights:this.citiesAndKnights,maxBasicKnights:this.maxBasicKnights,maxStrongKnights:this.maxStrongKnights,maxMightyKnights:this.maxMightyKnights,maxCityWalls:this.maxCityWalls,resourceCardCount:this.resourceCardCount,commodityCardCount:this.commodityCardCount,firstFound:this.firstFound,secondFound:this.secondFound,fisherman:this.fisherman,merchantTrains:this.merchantTrains,numberWagons:this.numberWagons,rivers:this.rivers,maxBridges:this.maxBridges,robberMode:this.robberMode,diceMode:this.diceMode,diceSeed:this.diceSeed,devCardSeed:this.devCardSeed,stealSeed:this.stealSeed,winCondition:this.winCondition,turnLimit:this.turnLimit,resourceGoal:this.resourceGoal?.toProto(),balancedDiceBounds:this.balancedDiceBounds,timerConfig:this.timerConfig.toProto(),pauseConfig:this.pauseConfig.toProto(),ckKnightErrant:this.ckKnightErrant,ckEasyStart:this.ckEasyStart,ckNastyBarbarians:this.ckNastyBarbarians,turboMode:this.turboMode,mapType:this.mapType,harbormaster:this.harbormaster,newIslandSettlementBonus:this.newIslandSettlementBonus,desertsBlockIslands:this.desertsBlockIslands,secondSettler:this.secondSettler,eventCards:this.eventCards,dynamicHexMode:this.dynamicHexMode,robberLockedToBiggestIsland:this.robberLockedToBiggestIsland,fogReward:this.fogReward,fogBonusDuringSetup:this.fogBonusDuringSetup,foundOnFog:this.foundOnFog,fogMode:this.fogMode,firstSettleMode:this.firstSettleMode,secondSettleMode:this.secondSettleMode,restrictFoundingToLargestIsland:this.restrictFoundingToLargestIsland,mapShuffleMode:this.mapShuffleMode,mapShuffleScope:this.mapShuffleScope,setupPrediction:this.setupPrediction,tradeResponseTimeoutMs:this.tradeResponseTimeoutMs,noSevens:this.noSevens,trolls:this.trolls,numberOfRobbers:this.numberOfRobbers,boardGeneration:this.boardGeneration.isCustomized()?this.boardGeneration.toProto():void 0,rushMode:this.rushMode,rushDiceIntervalSeconds:this.rushDiceIntervalSeconds,tradeMode:this.tradeMode,revealFogOnGameStart:this.revealFogOnGameStart,hideDiceStats:this.hideDiceStats,hidePlayedDevCards:this.hidePlayedDevCards,disableCounterOffers:this.disableCounterOffers})}toBuilder(){let r=e.builder().victoryPoints(this.victoryPoints).discardLimit(this.discardLimit).seafarers(this.seafarers).maxSettlements(this.maxSettlements).maxCities(this.maxCities).maxRoads(this.maxRoads).maxShips(this.maxShips).seed(this.seed).citiesAndKnights(this.citiesAndKnights).maxBasicKnights(this.maxBasicKnights).maxStrongKnights(this.maxStrongKnights).maxMightyKnights(this.maxMightyKnights).maxCityWalls(this.maxCityWalls).resourceCardCount(this.resourceCardCount).commodityCardCount(this.commodityCardCount).firstFound(this.firstFound),t=this.citiesAndKnights?F.BUILDING_CITY:o_;return this.secondFound!==t&&r.secondFound(this.secondFound),r.fisherman(this.fisherman).merchantTrains(this.merchantTrains).numberWagons(this.numberWagons).rivers(this.rivers).maxBridges(this.maxBridges).robberMode(this.robberMode).diceMode(this.diceMode).diceSeed(this.diceSeed).devCardSeed(this.devCardSeed).stealSeed(this.stealSeed).winCondition(this.winCondition).turnLimit(this.turnLimit).resourceGoal(this.resourceGoal).balancedDiceBounds(this.balancedDiceBounds).timerConfig(this.timerConfig).pauseConfig(this.pauseConfig).ckKnightErrant(this.ckKnightErrant).ckEasyStart(this.ckEasyStart).ckNastyBarbarians(this.ckNastyBarbarians).turboMode(this.turboMode).mapType(this.mapType).harbormaster(this.harbormaster).newIslandSettlementBonus(this.newIslandSettlementBonus).desertsBlockIslands(this.desertsBlockIslands).secondSettler(this.secondSettler).eventCards(this.eventCards).dynamicHexMode(this.dynamicHexMode).robberLockedToBiggestIsland(this.robberLockedToBiggestIsland).fogReward(this.fogReward).fogBonusDuringSetup(this.fogBonusDuringSetup).foundOnFog(this.foundOnFog).fogMode(this.fogMode).firstSettleMode(this.firstSettleMode).secondSettleMode(this.secondSettleMode).restrictFoundingToLargestIsland(this.restrictFoundingToLargestIsland).mapShuffleMode(this.mapShuffleMode).mapShuffleScope(this.mapShuffleScope).setupPrediction(this.setupPrediction).tradeResponseTimeoutMs(this.tradeResponseTimeoutMs).noSevens(this.noSevens).trolls(this.trolls).numberOfRobbers(this.numberOfRobbers).boardGeneration(this.boardGeneration).rushMode(this.rushMode).rushDiceIntervalSeconds(this.rushDiceIntervalSeconds).tradeMode(this.tradeMode).revealFogOnGameStart(this.revealFogOnGameStart).hideDiceStats(this.hideDiceStats).hidePlayedDevCards(this.hidePlayedDevCards).disableCounterOffers(this.disableCounterOffers)}mustDiscard(r){return r>this.discardLimit}getDiscardCount(r){return this.mustDiscard(r)?Math.floor(r/2):0}hasWon(r){return r>=this.victoryPoints}canBuildSettlement(r){return r<this.maxSettlements}canBuildCity(r){return r<this.maxCities}canBuildRoad(r){return r<this.maxRoads}canBuildShip(r){return r<this.maxShips}canBuildBridge(r){return this.rivers&&r<this.maxBridges}canBuildBasicKnight(r){return this.citiesAndKnights&&r<this.maxBasicKnights}canPromoteToStrongKnight(r){return this.citiesAndKnights&&r<this.maxStrongKnights}canPromoteToMightyKnight(r){return this.citiesAndKnights&&r<this.maxMightyKnights}canBuildCityWall(r){return this.citiesAndKnights&&r<this.maxCityWalls}getDiscardLimitWithWalls(r){return this.citiesAndKnights?this.discardLimit+r*2:this.discardLimit}mustDiscardWithWalls(r,t){return r>this.getDiscardLimitWithWalls(t)}isEasyStartActive(r,t){return!this.citiesAndKnights||!this.ckEasyStart?!1:r<t*2}isSecondSettlerActive(r){return this.secondSettler&&r>=5&&r<=8}getPairedPlayer(r,t){if(!this.secondSettler||t.length<5)return;let o=t.indexOf(r);if(o===-1)return;let i=(o+Math.floor(t.length/2))%t.length;return t[i]}isDeterministicFog(){return this.fogMode===Gr.FOG_MODE_FOG_START||this.fogMode===Gr.FOG_MODE_MIST_START}toString(){return JSON.stringify(this.toProto())}};var Ni=class e{static{E(this,"EventDice")}result;static fromProto(r){return new e(r.result)}constructor(r=Ue.EVENT_DIE_RESULT_UNSPECIFIED){this.result=r}toProto(){return{result:this.result}}get isBarbarianShip(){return this.result===Ue.EVENT_DIE_RESULT_BARBARIAN_SHIP}get isCityGate(){return this.result===Ue.EVENT_DIE_RESULT_TRADE_GATE||this.result===Ue.EVENT_DIE_RESULT_POLITICS_GATE||this.result===Ue.EVENT_DIE_RESULT_SCIENCE_GATE}get gateTrack(){switch(this.result){case Ue.EVENT_DIE_RESULT_TRADE_GATE:return K.CITY_IMPROVEMENT_TRACK_TRADE;case Ue.EVENT_DIE_RESULT_POLITICS_GATE:return K.CITY_IMPROVEMENT_TRACK_POLITICS;case Ue.EVENT_DIE_RESULT_SCIENCE_GATE:return K.CITY_IMPROVEMENT_TRACK_SCIENCE;default:return}}equals(r){return this.result===r.result}toString(){return JSON.stringify(this.toProto())}};var D2=1/6;var fn=class e{static{E(this,"WagonVote")}player;woolBid;wheatBid;preferredEdge;preferredFacing;static fromProto(r){return new e(r.player,r.woolBid,r.wheatBid,r.preferredEdge?Ne.fromProto(r.preferredEdge):void 0,r.preferredFacing?Ce.fromProto(r.preferredFacing):void 0)}constructor(r,t,o,i,n){this.player=r,this.woolBid=t,this.wheatBid=o,this.preferredEdge=i,this.preferredFacing=n}toProto(){return{player:this.player,woolBid:this.woolBid,wheatBid:this.wheatBid,preferredEdge:this.preferredEdge?.toProto(),preferredFacing:this.preferredFacing?.toProto()??Dr.VERTEX_DIRECTION_TYPE_UNSPECIFIED}}get totalBid(){return this.woolBid+this.wheatBid}get isPass(){return this.totalBid===0}toString(){return this.isPass?`WagonVote(player=${this.player}, PASS)`:`WagonVote(player=${this.player}, bid=${this.totalBid}, edge=${this.preferredEdge?.toString()})`}};var Tn=class e{static{E(this,"PendingWagonVoting")}activePlayer;remainingVoters;votes;static fromProto(r){return new e(r.activePlayer,[...r.remainingVoters],r.votes.map(t=>fn.fromProto(t)))}constructor(r,t,o){this.activePlayer=r,this.remainingVoters=t,this.votes=o}toProto(){return{activePlayer:this.activePlayer,remainingVoters:[...this.remainingVoters],votes:this.votes.map(r=>r.toProto())}}needsVoteFrom(r){return this.remainingVoters.includes(r)}get nextVoter(){return this.remainingVoters[0]}get isComplete(){return this.remainingVoters.length===0}withVote(r){return new e(this.activePlayer,this.remainingVoters.filter(t=>t!==r.player),[...this.votes,r])}};var Ua=class e{static{E(this,"FlowState")}currentPlayer;turnNumber;isSetupPhase;pendingDiceRoll;pendingRobberPlacement;pendingRobberStealLocation;pendingPirateStealLocation;playedDevCardThisTurn;pendingDiscards;pendingFreeResources;pendingFreeStructures;pendingDefenderSelection;pendingCityPillage;pendingProgressCardDraw;progressCardsInPlay;pendingAlchemist;merchantFleetResource;merchantFleetCommodity;masterMerchantTarget;pendingSpyTarget;smithFreePromotionsRemaining;pendingKnights;pendingWeddingCards;pendingCommercialHarborExchanges;pendingDeserter;pendingKnightCommitment;pendingMetropolisPlacement;largestArmyPlayer;longestRoadPlayer;harbormasterPlayer;winner;paused;pendingResourceResolution;pendingSecondTurboRoll;isSecondSettlerPhase;secondSettlerPlayer;pendingGoodNeighbors;pendingHelpfulNeighbors;pendingEventCardSteal;pendingEarthquake;pendingBishopSteal;pendingProgressCardDiscard;pendingWagonVoting;wagonsExhausted;rushMode;rushDiceVotes;rushRobberPlayer;constructor(r={}){this.currentPlayer=r.currentPlayer??x.PLAYER_COLOR_UNSPECIFIED,this.turnNumber=r.turnNumber??0,this.isSetupPhase=r.isSetupPhase??!1,this.pendingDiceRoll=r.pendingDiceRoll??!1,this.pendingRobberPlacement=r.pendingRobberPlacement??!1,this.pendingRobberStealLocation=r.pendingRobberStealLocation,this.pendingPirateStealLocation=r.pendingPirateStealLocation,this.playedDevCardThisTurn=r.playedDevCardThisTurn??!1,this.pendingDiscards=new Map(r.pendingDiscards),this.pendingFreeResources=new Map(r.pendingFreeResources),this.pendingFreeStructures=new Map;for(let[t,o]of r.pendingFreeStructures??[])this.pendingFreeStructures.set(t,[...o]);this.pendingDefenderSelection=[...r.pendingDefenderSelection??[]],this.pendingCityPillage=r.pendingCityPillage,this.pendingProgressCardDraw=new Map(r.pendingProgressCardDraw),this.progressCardsInPlay=[...r.progressCardsInPlay??[]],this.pendingAlchemist=r.pendingAlchemist,this.merchantFleetResource=r.merchantFleetResource,this.merchantFleetCommodity=r.merchantFleetCommodity,this.masterMerchantTarget=r.masterMerchantTarget,this.pendingSpyTarget=r.pendingSpyTarget,this.smithFreePromotionsRemaining=r.smithFreePromotionsRemaining??0,this.pendingKnights=[...r.pendingKnights??[]],this.pendingWeddingCards=[...r.pendingWeddingCards??[]],this.pendingCommercialHarborExchanges=[...r.pendingCommercialHarborExchanges??[]],this.pendingDeserter=r.pendingDeserter,this.pendingKnightCommitment=r.pendingKnightCommitment,this.pendingMetropolisPlacement=r.pendingMetropolisPlacement,this.largestArmyPlayer=r.largestArmyPlayer,this.longestRoadPlayer=r.longestRoadPlayer,this.harbormasterPlayer=r.harbormasterPlayer,this.winner=r.winner,this.paused=r.paused??!1,this.pendingResourceResolution=r.pendingResourceResolution??!1,this.pendingSecondTurboRoll=r.pendingSecondTurboRoll??!1,this.isSecondSettlerPhase=r.isSecondSettlerPhase??!1,this.secondSettlerPlayer=r.secondSettlerPlayer,this.pendingGoodNeighbors=[...r.pendingGoodNeighbors??[]],this.pendingHelpfulNeighbors=[...r.pendingHelpfulNeighbors??[]],this.pendingEventCardSteal=r.pendingEventCardSteal,this.pendingEarthquake=[...r.pendingEarthquake??[]],this.pendingBishopSteal=r.pendingBishopSteal,this.pendingProgressCardDiscard=new Map(r.pendingProgressCardDiscard),this.pendingWagonVoting=r.pendingWagonVoting,this.wagonsExhausted=r.wagonsExhausted??!1,this.rushMode=r.rushMode??!1,this.rushDiceVotes=r.rushDiceVotes??new Set,this.rushRobberPlayer=r.rushRobberPlayer}static createInitial(r){return new e({currentPlayer:r,turnNumber:0,isSetupPhase:!0,pendingDiceRoll:!1})}static fromProto(r){let t=new Map;for(let l of r.pendingDiscards??[])l.player&&l.count>0&&t.set(l.player,l.count);let o=new Map;for(let l of r.pendingFreeResources??[])l.player&&l.count>0&&o.set(l.player,l.count);let i=new Map;for(let l of r.pendingFreeStructures??[])l.player&&l.structures&&l.structures.length>0&&i.set(l.player,[...l.structures]);let n=new Map;for(let l of r.pendingProgressCardDraw??[])l.card&&l.count>0&&n.set(l.card,l.count);let a=[];for(let l of r.pendingKnights??[])l.player&&l.strength&&l.status&&a.push({player:l.player,strength:l.strength,status:l.status,fromVertex:l.fromVertex?oe.fromProto(l.fromVertex):void 0});let s=[];for(let l of r.pendingWeddingCards??[])l.player&&l.weddingPlayer&&s.push({player:l.player,weddingPlayer:l.weddingPlayer});let u=[];for(let l of r.pendingCommercialHarborExchanges??[])l.opponent&&l.harborPlayer&&l.resource&&u.push({opponent:l.opponent,harborPlayer:l.harborPlayer,resource:l.resource});return new e({currentPlayer:r.currentPlayer,turnNumber:r.turnNumber,isSetupPhase:r.isSetupPhase,pendingDiceRoll:r.pendingDiceRoll,pendingRobberPlacement:r.pendingRobberPlacement,pendingRobberStealLocation:r.pendingRobberStealLocation?_.fromProto(r.pendingRobberStealLocation):void 0,pendingPirateStealLocation:r.pendingPirateStealLocation?_.fromProto(r.pendingPirateStealLocation):void 0,playedDevCardThisTurn:r.playedDevCardThisTurn,pendingDiscards:t,pendingFreeResources:o,pendingFreeStructures:i,pendingDefenderSelection:r.pendingDefenderSelection??[],pendingCityPillage:r.pendingCityPillage||void 0,pendingProgressCardDraw:n,progressCardsInPlay:r.progressCardsInPlay??[],pendingAlchemist:r.pendingAlchemist||void 0,merchantFleetResource:r.merchantFleetResource||void 0,merchantFleetCommodity:r.merchantFleetCommodity||void 0,masterMerchantTarget:r.masterMerchantTarget||void 0,pendingSpyTarget:r.pendingSpyTarget||void 0,smithFreePromotionsRemaining:r.smithFreePromotionsRemaining??0,pendingKnights:a,pendingWeddingCards:s,pendingCommercialHarborExchanges:u,largestArmyPlayer:r.largestArmyPlayer||void 0,longestRoadPlayer:r.longestRoadPlayer||void 0,harbormasterPlayer:r.harbormasterPlayer||void 0,winner:r.winner||void 0,paused:r.paused??!1,pendingResourceResolution:r.pendingResourceResolution??!1,pendingSecondTurboRoll:r.pendingSecondTurboRoll??!1,isSecondSettlerPhase:r.isSecondSettlerPhase??!1,secondSettlerPlayer:r.secondSettlerPlayer||void 0,pendingGoodNeighbors:[...r.pendingGoodNeighbors],pendingHelpfulNeighbors:[...r.pendingHelpfulNeighbors??[]],pendingEventCardSteal:r.pendingEventCardSteal||void 0,pendingEarthquake:[...r.pendingEarthquake??[]],pendingBishopSteal:r.pendingBishopSteal||void 0,pendingProgressCardDiscard:(()=>{let l=new Map;for(let c of r.pendingProgressCardDiscard??[])c.player&&c.count>0&&l.set(c.player,c.count);return l})(),pendingWagonVoting:r.pendingWagonVoting?Tn.fromProto(r.pendingWagonVoting):void 0,wagonsExhausted:r.wagonsExhausted??!1,pendingDeserter:r.pendingDeserter?{deserterPlayer:r.pendingDeserter.deserterPlayer,targetPlayer:r.pendingDeserter.targetPlayer}:void 0,pendingMetropolisPlacement:r.pendingMetropolisPlacement?{player:r.pendingMetropolisPlacement.player,track:r.pendingMetropolisPlacement.track,isSteal:r.pendingMetropolisPlacement.isSteal,stolenFrom:r.pendingMetropolisPlacement.stolenFrom||void 0}:void 0,rushDiceVotes:new Set((r.rushDiceVotes??[]).filter(l=>l)),rushRobberPlayer:r.rushRobberPlayer||void 0})}toProto(){let r=[];for(let[u,l]of this.pendingDiscards)l>0&&r.push({player:u,count:l});let t=[];for(let[u,l]of this.pendingFreeResources)l>0&&t.push({player:u,count:l});let o=[];for(let[u,l]of this.pendingFreeStructures)l.length>0&&o.push({player:u,structures:[...l]});let i=[];for(let[u,l]of this.pendingProgressCardDraw)l>0&&i.push({card:u,count:l});let n=this.pendingKnights.map(u=>({player:u.player,strength:u.strength,status:u.status,fromVertex:u.fromVertex?u.fromVertex.toProto():void 0})),a=this.pendingWeddingCards.map(u=>({player:u.player,weddingPlayer:u.weddingPlayer})),s=this.pendingCommercialHarborExchanges.map(u=>({opponent:u.opponent,harborPlayer:u.harborPlayer,resource:u.resource}));return{currentPlayer:this.currentPlayer,turnNumber:this.turnNumber,isSetupPhase:this.isSetupPhase,pendingDiceRoll:this.pendingDiceRoll,pendingRobberPlacement:this.pendingRobberPlacement,pendingRobberStealLocation:this.pendingRobberStealLocation?.toProto(),pendingPirateStealLocation:this.pendingPirateStealLocation?.toProto(),playedDevCardThisTurn:this.playedDevCardThisTurn,pendingDiscards:r,pendingFreeResources:t,pendingFreeStructures:o,largestArmyPlayer:this.largestArmyPlayer||x.PLAYER_COLOR_UNSPECIFIED,longestRoadPlayer:this.longestRoadPlayer||x.PLAYER_COLOR_UNSPECIFIED,harbormasterPlayer:this.harbormasterPlayer||x.PLAYER_COLOR_UNSPECIFIED,winner:this.winner||x.PLAYER_COLOR_UNSPECIFIED,pendingDefenderSelection:this.pendingDefenderSelection,pendingCityPillage:this.pendingCityPillage||x.PLAYER_COLOR_UNSPECIFIED,pendingProgressCardDraw:i,progressCardsInPlay:this.progressCardsInPlay,pendingAlchemist:this.pendingAlchemist||x.PLAYER_COLOR_UNSPECIFIED,merchantFleetResource:this.merchantFleetResource||S.RESOURCE_UNSPECIFIED,merchantFleetCommodity:this.merchantFleetCommodity||j.COMMODITY_UNSPECIFIED,masterMerchantTarget:this.masterMerchantTarget||x.PLAYER_COLOR_UNSPECIFIED,pendingSpyTarget:this.pendingSpyTarget||x.PLAYER_COLOR_UNSPECIFIED,smithFreePromotionsRemaining:this.smithFreePromotionsRemaining,pendingKnights:n,pendingWeddingCards:a,pendingCommercialHarborExchanges:s,paused:this.paused,pauseState:void 0,pendingResourceResolution:this.pendingResourceResolution,pendingSecondTurboRoll:this.pendingSecondTurboRoll,isSecondSettlerPhase:this.isSecondSettlerPhase,secondSettlerPlayer:this.secondSettlerPlayer||x.PLAYER_COLOR_UNSPECIFIED,pendingEarthquake:[...this.pendingEarthquake],pendingGoodNeighbors:[...this.pendingGoodNeighbors],pendingHelpfulNeighbors:[...this.pendingHelpfulNeighbors],pendingEventCardSteal:this.pendingEventCardSteal||x.PLAYER_COLOR_UNSPECIFIED,pendingBishopSteal:this.pendingBishopSteal||x.PLAYER_COLOR_UNSPECIFIED,pendingProgressCardDiscard:(()=>{let u=[];for(let[l,c]of this.pendingProgressCardDiscard)c>0&&u.push({player:l,count:c});return u})(),pendingWagonVoting:this.pendingWagonVoting?.toProto(),wagonsExhausted:this.wagonsExhausted,pendingDeserter:this.pendingDeserter?{deserterPlayer:this.pendingDeserter.deserterPlayer,targetPlayer:this.pendingDeserter.targetPlayer}:void 0,pendingMetropolisPlacement:this.pendingMetropolisPlacement?{player:this.pendingMetropolisPlacement.player,track:this.pendingMetropolisPlacement.track,isSteal:this.pendingMetropolisPlacement.isSteal,stolenFrom:this.pendingMetropolisPlacement.stolenFrom||x.PLAYER_COLOR_UNSPECIFIED}:void 0,rushDiceVotes:[...this.rushDiceVotes],rushRobberPlayer:this.rushRobberPlayer??x.PLAYER_COLOR_UNSPECIFIED}}static FIRESTORE_OPTIONS_DEFAULT={citiesKnights:!1,eventCards:!1};toFirestoreObject(r={}){let t=[];for(let[u,l]of this.pendingDiscards)l>0&&t.push({player:u,count:l});let o=[];for(let[u,l]of this.pendingFreeResources)l>0&&o.push({player:u,count:l});let i=[];for(let[u,l]of this.pendingFreeStructures)l.length>0&&i.push({player:u,buildings:[...l]});let{citiesKnights:n=!1,eventCards:a=!1}=r,s={currentPlayer:this.currentPlayer,turnNumber:this.turnNumber,isSetupPhase:this.isSetupPhase,pendingDiceRoll:this.pendingDiceRoll,pendingRobberPlacement:this.pendingRobberPlacement,pendingDiscards:t,pendingFreeResources:o,pendingFreeStructures:i,paused:this.paused};if(this.winner!==void 0&&(s.winner=this.winner),n){let u=[];for(let[T,R]of this.pendingProgressCardDraw)R>0&&u.push({card:T,count:R});let l=this.pendingKnights.map(T=>({player:T.player,strength:T.strength,status:T.status,fromVertex:T.fromVertex?T.fromVertex.toProto():void 0})),c=this.pendingWeddingCards.map(T=>({player:T.player,weddingPlayer:T.weddingPlayer})),f=this.pendingCommercialHarborExchanges.map(T=>({opponent:T.opponent,harborPlayer:T.harborPlayer,resource:T.resource}));if(s.pendingDefenderSelection=this.pendingDefenderSelection,s.pendingProgressCardDraw=u,s.progressCardsInPlay=this.progressCardsInPlay,s.smithFreePromotionsRemaining=this.smithFreePromotionsRemaining,s.pendingKnights=l,s.pendingWeddingCards=c,s.pendingCommercialHarborExchanges=f,s.pendingResourceResolution=this.pendingResourceResolution,s.pendingSecondTurboRoll=this.pendingSecondTurboRoll,s.isSecondSettlerPhase=this.isSecondSettlerPhase,this.secondSettlerPlayer!==void 0&&(s.secondSettlerPlayer=this.secondSettlerPlayer),this.pendingCityPillage!==void 0&&(s.pendingCityPillage=this.pendingCityPillage),this.pendingAlchemist!==void 0&&(s.pendingAlchemist=this.pendingAlchemist),this.merchantFleetResource!==void 0&&(s.merchantFleetResource=this.merchantFleetResource),this.merchantFleetCommodity!==void 0&&(s.merchantFleetCommodity=this.merchantFleetCommodity),this.masterMerchantTarget!==void 0&&(s.masterMerchantTarget=this.masterMerchantTarget),this.pendingSpyTarget!==void 0&&(s.pendingSpyTarget=this.pendingSpyTarget),this.pendingKnightCommitment!==void 0&&(s.pendingKnightCommitment={barbarianStrength:this.pendingKnightCommitment.barbarianStrength,committedKnights:this.pendingKnightCommitment.committedKnights.map(T=>T.toProto()),currentPlayer:this.pendingKnightCommitment.currentPlayer,playersCommitted:[...this.pendingKnightCommitment.playersCommitted]}),this.pendingBishopSteal!==void 0&&(s.pendingBishopSteal=this.pendingBishopSteal),this.pendingProgressCardDiscard.size>0){let T=[];for(let[R,O]of this.pendingProgressCardDiscard)O>0&&T.push({player:R,count:O});s.pendingProgressCardDiscard=T}this.pendingDeserter!==void 0&&(s.pendingDeserter={deserterPlayer:this.pendingDeserter.deserterPlayer,targetPlayer:this.pendingDeserter.targetPlayer}),this.pendingMetropolisPlacement!==void 0&&(s.pendingMetropolisPlacement={player:this.pendingMetropolisPlacement.player,track:this.pendingMetropolisPlacement.track,isSteal:this.pendingMetropolisPlacement.isSteal,stolenFrom:this.pendingMetropolisPlacement.stolenFrom})}return a&&(s.pendingGoodNeighbors=[...this.pendingGoodNeighbors],s.pendingHelpfulNeighbors=[...this.pendingHelpfulNeighbors],s.pendingEarthquake=[...this.pendingEarthquake],this.pendingEventCardSteal!==void 0&&(s.pendingEventCardSteal=this.pendingEventCardSteal)),this.rushMode&&(s.rushMode=!0),this.rushDiceVotes.size>0&&(s.rushDiceVotes=[...this.rushDiceVotes]),this.rushRobberPlayer!==void 0&&(s.rushRobberPlayer=this.rushRobberPlayer),s}static FIRESTORE_OBJECT_SCHEMA={required:["currentPlayer","turnNumber","isSetupPhase","pendingDiceRoll","pendingRobberPlacement"],optionalBase:["pendingDiscards","pendingFreeResources","pendingFreeStructures","winner","paused"],citiesKnights:["pendingDefenderSelection","pendingCityPillage","pendingProgressCardDraw","progressCardsInPlay","pendingAlchemist","merchantFleetResource","merchantFleetCommodity","masterMerchantTarget","pendingSpyTarget","smithFreePromotionsRemaining","pendingKnights","pendingWeddingCards","pendingCommercialHarborExchanges","pendingResourceResolution","pendingKnightCommitment","pendingSecondTurboRoll","isSecondSettlerPhase","secondSettlerPlayer","pendingBishopSteal","pendingDeserter","pendingMetropolisPlacement","pendingProgressCardDiscard"],eventCards:["pendingGoodNeighbors","pendingHelpfulNeighbors","pendingEventCardSteal","pendingEarthquake"]};static fromFirestoreObject(r){let t=new Map;for(let c of r.pendingDiscards??[])c.player&&c.count>0&&t.set(c.player,c.count);let o=new Map;for(let c of r.pendingFreeResources??[])c.player&&c.count>0&&o.set(c.player,c.count);let i=new Map;for(let c of r.pendingFreeStructures??[])c.player&&c.buildings&&c.buildings.length>0&&i.set(c.player,[...c.buildings]);let n=new Map;for(let c of r.pendingProgressCardDraw??[])c.card&&c.count>0&&n.set(c.card,c.count);let a=(r.pendingKnights??[]).map(c=>({player:c.player,strength:c.strength,status:c.status,fromVertex:c.fromVertex?oe.fromProto(c.fromVertex):void 0})),s=(r.pendingWeddingCards??[]).map(c=>({player:c.player,weddingPlayer:c.weddingPlayer})),u=(r.pendingCommercialHarborExchanges??[]).map(c=>({opponent:c.opponent,harborPlayer:c.harborPlayer,resource:c.resource})),l;return r.pendingKnightCommitment&&(l={barbarianStrength:r.pendingKnightCommitment.barbarianStrength,committedKnights:r.pendingKnightCommitment.committedKnights.map(c=>oe.fromProto(c)),currentPlayer:r.pendingKnightCommitment.currentPlayer,playersCommitted:[...r.pendingKnightCommitment.playersCommitted]}),new e({currentPlayer:r.currentPlayer,turnNumber:r.turnNumber,isSetupPhase:r.isSetupPhase,pendingDiceRoll:r.pendingDiceRoll,pendingRobberPlacement:r.pendingRobberPlacement,pendingDiscards:t,pendingFreeResources:o,pendingFreeStructures:i,pendingDefenderSelection:r.pendingDefenderSelection??[],pendingCityPillage:r.pendingCityPillage,pendingProgressCardDraw:n,progressCardsInPlay:r.progressCardsInPlay??[],pendingAlchemist:r.pendingAlchemist,merchantFleetResource:r.merchantFleetResource,merchantFleetCommodity:r.merchantFleetCommodity,masterMerchantTarget:r.masterMerchantTarget,pendingSpyTarget:r.pendingSpyTarget,smithFreePromotionsRemaining:r.smithFreePromotionsRemaining??0,pendingKnights:a,pendingWeddingCards:s,pendingCommercialHarborExchanges:u,pendingKnightCommitment:l,winner:r.winner,paused:r.paused??!1,pendingResourceResolution:r.pendingResourceResolution??!1,pendingSecondTurboRoll:r.pendingSecondTurboRoll??!1,isSecondSettlerPhase:r.isSecondSettlerPhase??!1,secondSettlerPlayer:r.secondSettlerPlayer,pendingGoodNeighbors:r.pendingGoodNeighbors??[],pendingHelpfulNeighbors:r.pendingHelpfulNeighbors??[],pendingEventCardSteal:r.pendingEventCardSteal,pendingEarthquake:r.pendingEarthquake??[],pendingBishopSteal:r.pendingBishopSteal,pendingProgressCardDiscard:(()=>{let c=new Map;for(let f of r.pendingProgressCardDiscard??[])f.player&&f.count>0&&c.set(f.player,f.count);return c})(),pendingDeserter:r.pendingDeserter,pendingMetropolisPlacement:r.pendingMetropolisPlacement?{player:r.pendingMetropolisPlacement.player,track:r.pendingMetropolisPlacement.track,isSteal:r.pendingMetropolisPlacement.isSteal,stolenFrom:r.pendingMetropolisPlacement.stolenFrom}:void 0,rushMode:r.rushMode??!1,rushDiceVotes:new Set(r.rushDiceVotes??[]),rushRobberPlayer:r.rushRobberPlayer})}get hasPendingDiscards(){for(let r of this.pendingDiscards.values())if(r>0)return!0;return!1}hasPendingDiscardsForPlayer(r){return(this.pendingDiscards.get(r)??0)>0}get hasPendingFreeResources(){for(let r of this.pendingFreeResources.values())if(r>0)return!0;return!1}hasPendingFreeResourcesForPlayer(r){return(this.pendingFreeResources.get(r)??0)>0}get hasPendingFreeStructures(){for(let r of this.pendingFreeStructures.values())if(r.length>0)return!0;return!1}hasPendingFreeStructuresForPlayer(r){let t=this.pendingFreeStructures.get(r);return t!==void 0&&t.length>0}hasAnyPendingActionsForPlayer(r){return this.hasPendingDiscardsForPlayer(r)||this.hasPendingFreeResourcesForPlayer(r)||this.hasPendingFreeStructuresForPlayer(r)}get canCurrentPlayerAct(){if(this.paused||this.hasPendingDiscards)return!1;for(let[t,o]of this.pendingFreeResources)if(o>0&&t!==this.currentPlayer)return!1;for(let[t,o]of this.pendingFreeStructures)if(o.length>0&&t!==this.currentPlayer)return!1;if(this.pendingGoodNeighbors.length>0||this.pendingHelpfulNeighbors.length>0||this.pendingEarthquake.length>0||this.pendingEventCardSteal!==void 0||this.pendingDefenderSelection.length>0||this.pendingCityPillage!==void 0||this.pendingResourceResolution||this.pendingKnightCommitment!==void 0||this.pendingDeserter!==void 0||this.pendingKnights.length>0||this.pendingWeddingCards.length>0||this.pendingCommercialHarborExchanges.length>0||this.pendingAlchemist!==void 0||this.pendingSpyTarget!==void 0||this.masterMerchantTarget!==void 0||this.pendingBishopSteal!==void 0)return!1;let r=this.pendingProgressCardDiscard.get(this.currentPlayer);return!(r!==void 0&&r>0||this.pendingMetropolisPlacement!==void 0)}getPlayersWithPendingActions(){let r=new Set;for(let[t,o]of this.pendingDiscards)o>0&&r.add(t);for(let[t,o]of this.pendingFreeResources)o>0&&r.add(t);for(let[t,o]of this.pendingFreeStructures)o.length>0&&r.add(t);for(let t of this.pendingDefenderSelection)r.add(t);this.pendingCityPillage!==void 0&&r.add(this.pendingCityPillage);for(let t of this.pendingWeddingCards)r.add(t.player);for(let t of this.pendingCommercialHarborExchanges)r.add(t.opponent);for(let t of this.pendingKnights)r.add(t.player);this.pendingDeserter!==void 0&&r.add(this.pendingDeserter.targetPlayer),this.pendingKnightCommitment!==void 0&&r.add(this.pendingKnightCommitment.currentPlayer),this.pendingMetropolisPlacement!==void 0&&r.add(this.pendingMetropolisPlacement.player);for(let[t,o]of this.pendingProgressCardDiscard)o>0&&r.add(t);for(let t of this.pendingGoodNeighbors)r.add(t);for(let t of this.pendingHelpfulNeighbors)r.add(t);this.pendingEventCardSteal!==void 0&&r.add(this.pendingEventCardSteal);for(let t of this.pendingEarthquake)r.add(t);if(this.pendingWagonVoting!==void 0)for(let t of this.pendingWagonVoting.remainingVoters)r.add(t);return this.pendingAlchemist!==void 0&&r.add(this.currentPlayer),this.pendingSpyTarget!==void 0&&r.add(this.currentPlayer),this.masterMerchantTarget!==void 0&&r.add(this.currentPlayer),this.pendingBishopSteal!==void 0&&r.add(this.currentPlayer),this.pendingResourceResolution&&r.add(this.currentPlayer),Array.from(r)}get hasPendingDefenderSelection(){return this.pendingDefenderSelection.length>0}hasPendingDefenderSelectionForPlayer(r){return this.pendingDefenderSelection.includes(r)}get hasPendingCityPillage(){return this.pendingCityPillage!==void 0}hasPendingCityPillageForPlayer(r){return this.pendingCityPillage===r}get hasPendingProgressCardDraw(){for(let r of this.pendingProgressCardDraw.values())if(r>0)return!0;return!1}hasPendingProgressCardDrawForPlayer(r){return r!==this.currentPlayer?!1:this.hasPendingProgressCardDraw}get hasPendingKnights(){return this.pendingKnights.length>0}hasPendingKnightsForPlayer(r){return this.pendingKnights.some(t=>t.player===r)}get hasPendingWeddingCards(){return this.pendingWeddingCards.length>0}hasPendingWeddingCardsForPlayer(r){return this.pendingWeddingCards.some(t=>t.player===r)}get hasPendingCommercialHarborExchanges(){return this.pendingCommercialHarborExchanges.length>0}hasPendingCommercialHarborExchangeForPlayer(r){return this.pendingCommercialHarborExchanges.some(t=>t.opponent===r)}get hasPendingKnightCommitment(){return this.pendingKnightCommitment!==void 0}hasPendingKnightCommitmentForPlayer(r){return this.pendingKnightCommitment?.currentPlayer===r}hasAnyCKPendingActionsForPlayer(r){return this.hasPendingDefenderSelectionForPlayer(r)||this.hasPendingCityPillageForPlayer(r)||this.hasPendingKnightsForPlayer(r)||this.hasPendingWeddingCardsForPlayer(r)||this.hasPendingCommercialHarborExchangeForPlayer(r)||this.hasPendingKnightCommitmentForPlayer(r)||this.hasPendingDeserterForPlayer(r)||this.hasPendingMetropolisPlacementForPlayer(r)||this.hasPendingProgressCardDiscardForPlayer(r)}get hasPendingDeserter(){return this.pendingDeserter!==void 0}hasPendingDeserterForPlayer(r){return this.pendingDeserter?.targetPlayer===r}get hasPendingMetropolisPlacement(){return this.pendingMetropolisPlacement!==void 0}hasPendingMetropolisPlacementForPlayer(r){return this.pendingMetropolisPlacement?.player===r}get hasPendingProgressCardDiscard(){for(let r of this.pendingProgressCardDiscard.values())if(r>0)return!0;return!1}hasPendingProgressCardDiscardForPlayer(r){return(this.pendingProgressCardDiscard.get(r)??0)>0}get hasPendingWagonVoting(){return this.pendingWagonVoting!==void 0}hasPendingWagonVotingForPlayer(r){return this.pendingWagonVoting?this.pendingWagonVoting.needsVoteFrom(r):!1}isActionRequired(r){return this.winner!==void 0||this.paused?!1:this.hasPendingDiscardsForPlayer(r)||this.hasPendingFreeResourcesForPlayer(r)||this.hasPendingFreeStructuresForPlayer(r)||this.hasPendingDefenderSelectionForPlayer(r)||this.hasPendingCityPillageForPlayer(r)||this.hasPendingKnightsForPlayer(r)||this.hasPendingWeddingCardsForPlayer(r)||this.hasPendingCommercialHarborExchangeForPlayer(r)||this.hasPendingKnightCommitmentForPlayer(r)||this.hasPendingDeserterForPlayer(r)||this.hasPendingMetropolisPlacementForPlayer(r)||this.hasPendingProgressCardDiscardForPlayer(r)||this.pendingGoodNeighbors.includes(r)||this.pendingHelpfulNeighbors.includes(r)||this.pendingEventCardSteal===r||this.pendingEarthquake.includes(r)||this.hasPendingWagonVotingForPlayer(r)?!0:this.isSecondSettlerPhase?!(r!==this.secondSettlerPlayer||!this.canCurrentPlayerAct):this.rushMode&&!this.isSetupPhase?!0:r!==this.currentPlayer?!1:this.pendingSpyTarget!==void 0||this.pendingAlchemist!==void 0||this.masterMerchantTarget!==void 0||this.pendingBishopSteal!==void 0?!0:!!this.canCurrentPlayerAct}};var kT=3,bT=1,vT=1,Ri=2,s_=2,cl=1,fl=1,Tl=-2;function Ai(e,r){return e.options.rivers&&e.board.isBridgeSite(r)}E(Ai,"isRoadBlockedByRiver");function __(e,r){return e.options.rivers?r.getEdges().some(t=>t.getAdjacentCenters().some(o=>e.board.hasTile(o))&&!e.hasEdgeBuilding(t)&&!e.board.isBridgeSite(t)):!0}E(__,"hasPlaceableInitialRoad");function Nl(e,r,t){return e.options.rivers?t===F.BUILDING_BRIDGE?kT:t===F.BUILDING_ROAD&&e.board.isRiverEdge(r)?bT:0:0}E(Nl,"riverGoldForEdge");function Rl(e,r){return e.options.rivers&&e.board.isRiverVertex(r)?vT:0}E(Rl,"riverGoldForVertex");function YT(e){return e.getPlayerPublicStates().map(r=>({player:r.player,gold:r.gold}))}E(YT,"publicGoldByPlayer");function Ba(e){if(!e.options.rivers)return;let r=YT(e);if(r.length===0)return;let t=Math.max(...r.map(i=>i.gold));if(t<=0)return;let o=r.filter(i=>i.gold===t);if(o.length===1)return o[0].player}E(Ba,"computeWealthiestTrader");function ka(e){if(!e.options.rivers)return[];let r=YT(e);if(r.length===0)return[];let t=Math.min(...r.map(o=>o.gold));return r.filter(o=>o.gold===t).map(o=>o.player)}E(ka,"computePoorTraders");function FT(e,r){if(!e.options.rivers)return 0;let t=0;return e.wealthiestTrader===r&&(t+=fl),e.poorTraders.includes(r)&&(t+=Tl),t}E(FT,"riversVictoryPoints");function Al(e,r){return e.goldSpentThisTurn.get(r)??0}E(Al,"goldPurchasesThisTurn");var ba=class{static{E(this,"VictoryPointsCalculator")}game;constructor(r){this.game=r}getVisibleVictoryPoints(r){let t=0;t+=this.game.getSettlementsByPlayer(r).length,t+=this.game.getCitiesByPlayer(r).length*2,this.game.longestRoadPlayer===r&&(t+=2),this.game.largestArmyPlayer===r&&(t+=2),this.game.options.harbormaster&&this.game.harbormasterPlayer===r&&(t+=2);let o=this.game.getPlayerPublicState(r);if(o&&(t+=o.playedDevCards.get(ie.DEV_CARD_VICTORY_POINT)??0),this.game.options.citiesAndKnights&&o){let i=this.game.board.metropolises.filter(n=>n.owner===r);t+=i.length*2,t+=o.defenderOfCatanVp,t+=o.progressCardVp,this.game.board.getMerchantOwner()===r&&(t+=1)}if(this.game.options.newIslandSettlementBonus>0&&o&&(t+=o.newIslandSettlementCount*this.game.options.newIslandSettlementBonus),o&&(t+=o.edgeRewardVp),this.game.options.merchantTrains)for(let i of this.game.getVertexBuildingsByPlayer(r))this.game.board.getAdjacentWagonCount(i.vertex)>=2&&(t+=1);return t+=FT(this.game,r),t}getTotalVictoryPoints(r){let t=this.getVisibleVictoryPoints(r),o=this.game.getPlayerState(r);return o&&(t+=o.getUnplayedDevCardCount(ie.DEV_CARD_VICTORY_POINT),t+=o.devCardsPurchasedThisTurn.get(ie.DEV_CARD_VICTORY_POINT)??0),t}recalculateAllPlayerVictoryPoints(){let r=[];for(let t of this.game.getPlayerPublicStates()){let o=t.player,i=this.getVisibleVictoryPoints(o),n=t.toBuilder().withVisibleVictoryPoints(i).build();r.push(n)}return r}};var Rt=class{static{E(this,"LongestRoadCalculator")}game;constructor(r){this.game=r}recalculateAllLongestRoadLengths(){let r=[];for(let t of this.game.getPlayerPublicStates()){let o=t.player,i=this.calculateLongestRoadForPlayer(o),n=t.toBuilder().withLongestRoadLength(i).build();r.push(n)}return r}buildDFSContext(r){let t=this.game.getEdgeBuildings().filter(f=>f.owner===r);if(t.length===0)return null;let o=this.game.getVertexBuildings(),i=new Map;for(let f of o)i.set(f.vertex.toString(),f);let n=this.game.board.knights,a=new Map;for(let f of n)a.set(f.location.toString(),f.owner);let s=E(f=>{let T=i.get(f.toString());if(T!==void 0&&T.owner!==r)return!0;let R=a.get(f.toString());return R!==void 0&&R!==r},"vertexBreaksRoad"),u=E(f=>{let T=i.get(f.toString());return T!==void 0&&T.owner===r},"vertexHasPlayerBuilding"),l=new Map;for(let f of t)for(let T of[f.edge.v1,f.edge.v2]){let R=T.toString();l.has(R)||l.set(R,[]),l.get(R).push(f)}let c=new Set;if(this.game.options.merchantTrains)for(let f of this.game.board.getWagons())c.add(f.edge.toString());return{playerRoads:t,vertexBreaksRoad:s,vertexHasPlayerBuilding:u,vertexToEdges:l,wagonEdges:c}}calculateLongestRoadForPlayer(r){let t=this.buildDFSContext(r);if(!t)return 0;let{playerRoads:o,vertexBreaksRoad:i,vertexHasPlayerBuilding:n,vertexToEdges:a,wagonEdges:s}=t,u=E((c,f,T)=>{if(i(c))return 0;let R=0,O=a.get(c.toString())??[];for(let I of O){let D=I.edge.toString();if(f.has(D)||I.isShip!==T.isShip&&!n(c))continue;let g=I.edge.v1.equals(c)?I.edge.v2:I.edge.v1,k=s.has(D)?2:1;f.add(D);let v=k+u(g,f,I);R=Math.max(R,v),f.delete(D)}return R},"dfs"),l=0;for(let c of o){let f=c.edge.toString(),T=s.has(f)?2:1,R=new Set([f]),O=T+u(c.edge.v2,R,c);l=Math.max(l,O);let I=new Set([f]),D=T+u(c.edge.v1,I,c);l=Math.max(l,D)}return l}calculateLongestRoadPath(r){let t=this.buildDFSContext(r);if(!t)return[];let{playerRoads:o,vertexBreaksRoad:i,vertexHasPlayerBuilding:n,vertexToEdges:a,wagonEdges:s}=t,u=0,l=new Set,c=E((R,O,I,D)=>{if(I>u&&(u=I,l=new Set(O)),i(R))return;let g=a.get(R.toString())??[];for(let k of g){let v=k.edge.toString();if(O.has(v)||k.isShip!==D.isShip&&!n(R))continue;let Y=k.edge.v1.equals(R)?k.edge.v2:k.edge.v1,V=s.has(v)?2:1;O.add(v),c(Y,O,I+V,k),O.delete(v)}},"dfs");for(let R of o){let O=R.edge.toString(),I=s.has(O)?2:1,D=new Set([O]);c(R.edge.v2,D,I,R);let g=new Set([O]);c(R.edge.v1,g,I,R)}let f=new Map;for(let R of o)f.set(R.edge.toString(),R.edge);let T=[];for(let R of l){let O=f.get(R);O&&T.push(O)}return T}calculateLongestRoadHolder(){let r=new Set;for(let n of this.game.getEdgeBuildings())r.add(n.owner);let t=new Map;for(let n of r){let a=this.calculateLongestRoadForPlayer(n);t.set(n,a)}let o=4,i;for(let[n,a]of t)a>o&&(o=a,i=n);if(this.game.longestRoadPlayer){let n=t.get(this.game.longestRoadPlayer)??0;if(n>=5&&n>=o)return this.game.longestRoadPlayer}if(!(o<5))return i}};function Ee(){return{valid:!0}}E(Ee,"valid");function p(e,r){return{valid:!1,errorCode:e,error:r}}E(p,"invalid");function VT(e,r){return e.hasPendingFreeResources(r)?p(P.VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES,"Must select free resources first"):e.hasPendingFreeStructures(r)?p(P.VALIDATION_ERROR_MUST_PLACE_FREE_ROADS,"Must place free structures first"):Ee()}E(VT,"checkOwnPendingFreeGrants");function rt(e,r){let t=VT(e,r);return t.valid?e.totalPendingFreeResources>0?p(P.VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES,"Waiting for other players to select their free resources"):Pd(e,r):t}E(rt,"checkNoPendingFreeGrants");function Pd(e,r){for(let[t,o]of e.pendingFreeStructures)if(t!==r&&o.length>0)return p(P.VALIDATION_ERROR_MUST_PLACE_FREE_ROADS,"Waiting for other players to place their free structures");return Ee()}E(Pd,"checkNoOtherPlayersPendingFreeStructures");function va(e,r){if(e.options.rushMode)return fD(e,r);if(e.isSecondSettlerPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Second settler phase active - only paired player can act");if(e.currentPlayer!==r)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");if(e.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot perform this action during setup phase");if(e.pendingDiceRoll)return p(P.VALIDATION_ERROR_MUST_ROLL_DICE_FIRST,"Must roll dice first");if(e.pendingSecondTurboRoll)return p(P.VALIDATION_ERROR_MUST_ROLL_DICE_FIRST,"Must complete second turbo roll first");if(e.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");if(e.pendingRobberOrPiratePlacement)return p(P.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST,"Must place robber first");if(e.pendingRobberStealLocation)return p(P.VALIDATION_ERROR_NO_PENDING_STEAL,"Must steal from a player first");let t=rt(e,r);if(!t.valid)return t;let o=tt(e);if(!o.valid)return o;let i=Vt(e,r);return i.valid?Ee():i}E(va,"checkNormalTurnRequirements");function tt(e){return e.pendingGoodNeighbors.length>0?p(P.VALIDATION_ERROR_MUST_COMPLETE_EVENT_CARD_FIRST,"Players must complete Good Neighbors first"):e.pendingHelpfulNeighbors.length>0?p(P.VALIDATION_ERROR_MUST_COMPLETE_EVENT_CARD_FIRST,"Players must complete Helpful Neighbor first"):e.pendingEarthquake.length>0?p(P.VALIDATION_ERROR_MUST_COMPLETE_EVENT_CARD_FIRST,"Players must select earthquake roads first"):e.pendingEventCardSteal!==void 0?p(P.VALIDATION_ERROR_MUST_COMPLETE_EVENT_CARD_FIRST,"Event card steal must complete first"):Ee()}E(tt,"checkNoPendingEventCardActions");function fD(e,r){if(e.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot perform this action during setup phase");if(e.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");if(e.hasPendingFreeResources(r))return p(P.VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES,"Must select free resources first");if(e.hasPendingFreeStructures(r))return p(P.VALIDATION_ERROR_MUST_PLACE_FREE_ROADS,"Must place free structures first");let t=tt(e);return t.valid?Ee():t}E(fD,"checkRushModeTurnRequirements");function Vt(e,r){return e.options.citiesAndKnights?e.pendingDefenderSelection.length>0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Players must select defender progress cards first"):e.pendingCityPillage!==void 0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Player must select city to pillage first"):e.pendingResourceResolution?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Resource resolution pending after barbarian attack"):e.pendingKnightCommitment!==void 0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Knight commitment must complete first"):e.pendingDeserter!==void 0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Deserter knight selection must complete first"):e.pendingKnights.length>0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Displaced knights must be placed first"):e.pendingWeddingCards.length>0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Wedding card responses must complete first"):e.pendingCommercialHarborExchanges.length>0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Commercial Harbor exchanges must complete first"):e.pendingAlchemist!==void 0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Alchemist dice selection must complete first"):e.pendingSpyTarget!==void 0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Spy card selection must complete first"):e.masterMerchantTarget!==void 0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Master Merchant card selection must complete first"):e.pendingBishopSteal!==void 0?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Bishop steal must complete first"):e.pendingProgressCardDiscard.has(r)?p(P.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST,"Must discard progress cards first"):Ee():Ee()}E(Vt,"checkCKPendingActions");function xT(e,r){if(!e.isSecondSettlerPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not in second settler phase");if(e.secondSettlerPlayer!==r)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Only the paired player can act during second settler phase");if(e.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot perform this action during setup phase");if(e.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");let t=rt(e,r);return t.valid?Ee():t}E(xT,"checkSecondSettlerTurnRequirements");function ze(e,r){let t=va(e,r);return!t.valid&&e.isSecondSettlerPhase?xT(e,r):t}E(ze,"checkTurnRequirements");function Ya(e,r){if(e.options.rushMode)return TD(e,r);if(e.isSecondSettlerPhase)return xT(e,r);if(e.currentPlayer!==r)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");if(e.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot perform this action during setup phase");if(e.pendingSecondTurboRoll)return p(P.VALIDATION_ERROR_MUST_ROLL_DICE_FIRST,"Must complete second turbo roll first");if(e.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");if(e.pendingRobberOrPiratePlacement)return p(P.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST,"Must place robber first");if(e.pendingRobberStealLocation)return p(P.VALIDATION_ERROR_NO_PENDING_STEAL,"Must steal from a player first");let t=rt(e,r);if(!t.valid)return t;let o=tt(e);return o.valid?Ee():o}E(Ya,"checkFishSpendingRequirements");function TD(e,r){if(e.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot perform this action during setup phase");if(e.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");if(e.hasPendingFreeResources(r))return p(P.VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES,"Must select free resources first");if(e.hasPendingFreeStructures(r))return p(P.VALIDATION_ERROR_MUST_PLACE_FREE_ROADS,"Must place free structures first");let t=tt(e);return t.valid?Ee():t}E(TD,"checkRushModeFishSpendingRequirements");function Sl(e,r){let t=r.getAdjacentVerticies();for(let o of t)if(e.hasVertexBuilding(o))return!1;return!0}E(Sl,"checkDistanceRule");function Si(e,r){return r.getHexCenters().some(o=>e.board.hasTile(o))}E(Si,"isVertexOnBoard");function ND(e,r,t){let o=e.getVertexBuilding(t);if(o&&o.owner!==r)return!0;let i=e.board.getKnightAt(t);return!!(i&&i.owner!==r)}E(ND,"isVertexBlockedByOpponent");function nt(e,r,t,o){let i=t.verticies;for(let n of i){let a=e.getVertexBuilding(n);if(a&&a.owner===r)return!0;let s=e.board.getKnightAt(n);if(s&&s.owner===r&&(!o||!n.getEdges().some(c=>{if(c.equals(t))return!1;let f=e.getEdgeBuilding(c);return f&&f.owner===r&&Cd(o,f.building)})))return!0;let u=n.getEdges();for(let l of u){if(l.equals(t))continue;let c=e.getEdgeBuilding(l);if(c&&c.owner===r){let f=t.getSharedVertexWith(l);if(f&&ND(e,r,f))continue;if(o&&Cd(o,c.building)){if(!f)continue;let T=e.getVertexBuilding(f);if(!T||T.owner!==r)continue}return!0}}}return!1}E(nt,"isEdgeConnectedToPlayerNetwork");function Cd(e,r){let t=e===F.BUILDING_ROAD||e===F.BUILDING_BRIDGE,o=r===F.BUILDING_ROAD||r===F.BUILDING_BRIDGE;return t!==o}E(Cd,"isCrossTypeTransition");function d_(e,r,t){let o=t.getEdges();for(let i of o){let n=e.getEdgeBuilding(i);if(n&&n.owner===r)return!0}return!1}E(d_,"isVertexConnectedToPlayerRoads");function Ol(e,r,t,o){return pd(e,r,t).some(i=>i.equals(o))}E(Ol,"isVertexReachableViaPlayerRoads");function Fa(e,r){let t=e.options.foundOnFog;if(t===lt.FOUND_ON_FOG_MODE_WITHIN)return!0;let o=r.getHexCenters();return o.some(a=>e.board.getTile(a)?.isFog)?t===lt.FOUND_ON_FOG_MODE_DISABLED?!1:o.some(a=>{let s=e.board.getTile(a);return s&&!s.isFog&&!s.isSea}):!0}E(Fa,"isVertexValidForFog");function sr(e,r,t){if(!e.options.citiesAndKnights)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Progress cards require the Cities & Knights expansion");if(e.isSecondSettlerPhase){let s=r===e.secondSettlerPlayer?"Progress cards can't be played during your Second Settler mini-turn":r===e.currentPlayer?"Your turn is over: progress cards can't be played during the paired player's mini-turn":"Not your turn";return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,s)}if(e.currentPlayer!==r)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");if(e.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot play progress cards during setup phase");if(e.pendingDiceRoll)return p(P.VALIDATION_ERROR_MUST_ROLL_DICE_FIRST,"Must roll dice before playing progress cards");if(e.pendingRobberOrPiratePlacement)return p(P.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST,"Must resolve robber/pirate placement first");if(e.pendingRobberStealLocation||e.pendingPirateStealLocation)return p(P.VALIDATION_ERROR_NO_PENDING_STEAL,"Must resolve steal selection first");if(e.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Must resolve discards first");let o=e.options.rushMode?VT(e,r):rt(e,r);if(!o.valid)return o;let i=tt(e);if(!i.valid)return i;let n=Vt(e,r);if(!n.valid)return n;let a=e.getPlayerState(r);return a?a.getProgressCardCount(t)<1?p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You don't have this progress card"):Ee():p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found")}E(sr,"checkProgressCardRequirements");function u_(e){let r=0;return e.options.firstFound===F.BUILDING_CITY?r+=2:r+=1,e.options.secondFound===F.BUILDING_CITY?r+=2:r+=1,r}E(u_,"getStartingVictoryPoints");function hd(e){let r=new Set,t=[],o=e.board.getTiles();for(let i of o){let n=i.location.getAllVerticies();for(let a of n){let s=a.toString();r.has(s)||(r.add(s),t.push(a))}}return t}E(hd,"getAllBoardVertices");function wT(e,r){let t=r.getAdjacentVerticies();for(let o of t)if(e.hasVertexBuilding(o))return!1;return!0}E(wT,"checkDistanceRule");function HT(e,r){return r.getAdjacentCenters().some(o=>e.board.hasTile(o))}E(HT,"isEdgeOnBoard");function Dd(e,r,t){let o=t.getEdges();for(let i of o){let n=e.getEdgeBuilding(i);if(n&&n.owner===r&&n.providesSettlementConnectivity)return!0}return!1}E(Dd,"isVertexConnectedToPlayerRoads");function pd(e,r,t){let o=[t],i=new Set([t.toString()]),n=[t];for(;n.length>0;){let a=n.shift();for(let s of a.getEdges()){let u=e.getEdgeBuilding(s);if(!u||u.owner!==r||!u.providesSettlementConnectivity)continue;let l=s.v1.equals(a)?s.v2:s.v1,c=l.toString();if(i.has(c))continue;i.add(c),o.push(l);let f=e.getVertexBuilding(l);if(f&&f.owner!==r)continue;let T=e.board.getKnightAt(l);T&&T.owner!==r||n.push(l)}}return o}E(pd,"getVerticesReachableViaPlayerRoads");function Il(e,r){let t=r.getHexCenters();for(let o of t){let i=e.getTile(o);if(!i||i.isSea||i.isLake)return!0}return!1}E(Il,"isVertexCoastal");function KT(e,r){let t=r.getHexCenters();for(let o of t){let i=e.getTile(o);if(i&&i.terrain===d.TERRAIN_DESERT)return!0}return!1}E(KT,"isVertexNearDesert");function WT(e,r){for(let t of e.ports)if(t.edge.verticies.some(i=>i.equals(r)))return!0;return!1}E(WT,"hasVertexPort");function Cl(e,r){let t=new Map([[2,1],[3,2],[4,3],[5,4],[6,5],[8,5],[9,4],[10,3],[11,2],[12,1]]),o=0,i=r.getHexCenters();for(let n of i){let a=e.getTile(n);if(a&&!a.isDesert&&!a.isSea)for(let s of a.numbers)o+=t.get(s)||0}return o}E(Cl,"getVertexPips");function Pl(e,r,t){let o=e.getTile(r);return!!(!o||o.isSea||o.isLake||t&&o.isDesert)}E(Pl,"isBlockingHex");function qT(e,r,t,o){let i=[r],n=[];for(;i.length>0;){let a=i.pop(),s=a.toString();if(!t.has(s)&&(t.add(s),!Pl(e,a,o))){n.push(a);for(let u of a.getAllNeighbors())t.has(u.toString())||i.push(u)}}return n}E(qT,"dfsIsland");function E_(e,r,t){let o=r.getHexCenters(),i;for(let s of o)if(!Pl(e,s,t)){i=s;break}if(!i)return;let a=qT(e,i,new Set,t);if(a.length!==0)return a.sort(_.compare),a[0].toString()}E(E_,"getIslandIdForVertex");function ZT(e,r,t,o){let i=E_(e,r,o);if(!i)return!1;let n=e.getSettlementsByPlayer(t),a=e.getCitiesByPlayer(t),s=[...n,...a];for(let u of s)if(E_(e,u.vertex,o)===i)return!0;return!1}E(ZT,"playerHasBuildingOnIsland");function Va(e,r){let t=new Set,o=[];for(let a of e.getTiles()){let s=a.location,u=s.toString();if(t.has(u))continue;if(Pl(e,s,r)){t.add(u);continue}let l=qT(e,s,t,r);l.length>0&&o.push(l)}if(o.length===0)return;let i=o[0],n=JT(i);for(let a=1;a<o.length;a++){let s=o[a],u=JT(s);(s.length>i.length||s.length===i.length&&u<n)&&(i=s,n=u)}return i}E(Va,"getBiggestIslandHexes");function JT(e){return e.length===0?"":[...e].sort(_.compare)[0].toString()}E(JT,"getIslandId");function xa(e){let r=[],t=hd(e);for(let o of t)e.hasVertexBuilding(o)||e.board.hasKnight(o)||wT(e,o)&&Fa(e,o)&&r.push(o);return r}E(xa,"getAllValidSettlementSpots");function l_(e,r){return xa(e).filter(i=>Dd(e,r,i))}E(l_,"getValidSettlementPlacements");function RD(e,r,t,o,i=1){let n=e.board,a=!1;switch(o){case tr.SETUP_PLACEMENT_MODE_NORMAL:return t;case tr.SETUP_PLACEMENT_MODE_COASTAL:return t.filter(s=>Il(n,s));case tr.SETUP_PLACEMENT_MODE_INLAND:return t.filter(s=>!Il(n,s));case tr.SETUP_PLACEMENT_MODE_PORT:return t.filter(s=>WT(n,s));case tr.SETUP_PLACEMENT_MODE_DESERT:return t.filter(s=>KT(n,s));case tr.SETUP_PLACEMENT_MODE_DIFFERENT_ISLAND:{if(i<=1)return t;let s=new Set,u=n.getSettlementsByPlayer(r),l=n.getCitiesByPlayer(r);for(let c of[...u,...l]){let f=E_(n,c.vertex,a);f&&s.add(f)}return t.filter(c=>{let f=E_(n,c,a);return f===void 0||!s.has(f)})}case tr.SETUP_PLACEMENT_MODE_HIGHEST_PRODUCTION:{if(t.length===0)return[];let s=Math.max(...t.map(u=>Cl(n,u)));return t.filter(u=>Cl(n,u)===s)}case tr.SETUP_PLACEMENT_MODE_SKIP:return[];default:return t}}E(RD,"filterBySetupPlacementMode");function XT(e,r,t){let o=t??e.getVertexBuildingsByPlayer(r).length+1,i=xa(e).filter(s=>__(e,s));if(e.options.restrictFoundingToLargestIsland){let s=Va(e.board,!1);if(s&&s.length>0){let u=new Set(s.map(c=>c.toString())),l=i.filter(c=>c.getHexCenters().some(T=>u.has(T.toString())));l.length>0&&(i=l)}}let n=o===1?e.options.firstSettleMode:e.options.secondSettleMode,a=RD(e,r,i,n,o);return a.length===0&&i.length>0&&n!==tr.SETUP_PLACEMENT_MODE_SKIP?i:a}E(XT,"getValidSetupPlacements");function pl(e,r){let t=e.getBrokenRoadsByPlayer(r);if(t.length>0)return t.map(u=>u.edge);let o=[],i=e.getEdgeBuildingsByPlayer(r),n=e.getVertexBuildingsByPlayer(r),a=e.board.getKnightsByPlayer(r),s=new Set;for(let u of i)for(let l of u.edge.getNeighboringEdges())s.add(l.toString());for(let u of n)for(let l of u.vertex.getEdges())s.add(l.toString());for(let u of a)for(let l of u.location.getEdges())s.add(l.toString());for(let u of s){let l=Ne.ofString(u);e.hasEdgeBuilding(l)||HT(e,l)&&(Ai(e,l)||nt(e,r,l,F.BUILDING_ROAD)&&o.push(l))}return o}E(pl,"getValidRoadPlacements");function wa(e,r,t){let o=[],i=e.getPlayersOnTile(r);for(let n of i){if(n===t)continue;let a=e.getPlayerState(n);a&&a.totalResourcesInHand+a.totalCommoditiesInHand!==0&&o.push(n)}return o}E(wa,"getStealablePlayers");function md(e,r,t){let o=[],i=e.getPlayersWithShipsAdjacentTo(r);for(let n of i){if(n===t)continue;let a=e.getPlayerState(n);a&&a.totalResourcesInHand+a.totalCommoditiesInHand!==0&&o.push(n)}return o}E(md,"getStealablePlayersPirate");function hl(e,r){if(!e.options.citiesAndKnights)return[];let t=[],o=hd(e);for(let i of o)e.hasVertexBuilding(i)||e.board.hasKnight(i)||Dd(e,r,i)&&t.push(i);return t}E(hl,"getValidKnightPlacements");function gd(e,r){if(!e.options.citiesAndKnights)return[];let t=[],o=e.getCitiesByPlayer(r);for(let i of o)e.board.hasCityWall(i.vertex)||t.push(i.vertex);return t}E(gd,"getValidCityWallPlacements");function Oi(e,r){if(!e.options.citiesAndKnights)return[];let t=[],o=e.getCitiesByPlayer(r);for(let i of o)e.board.hasMetropolis(i.vertex)||t.push(i.vertex);return t}E(Oi,"getPillagableCities");function c_(e,r){let t=new Set,o=e.getVertexBuildings().filter(s=>s.isCity);for(let s of o)e.board.metropolises.some(l=>l.location.equals(s.vertex))||t.add(s.owner);let i=Array.from(r.entries()).sort((s,u)=>s[1]-u[1]),n=-1,a=[];for(let[s,u]of i)if(t.has(s))if(n===-1)n=u,a.push(s);else if(u===n)a.push(s);else break;return a}E(c_,"calculatePlayersToPillage");function Ha(e,r){return e.options.citiesAndKnights?Dl(e.board.knights,r,e):[]}E(Ha,"getSmithPromotableKnights");function Dl(e,r,t){let o=e.filter(n=>n.owner===r),i=[];for(let n of o)if(!(!n.canPromote||n.promotedThisTurn)){if(n.strength===Pe.KNIGHT_STRENGTH_BASIC){let a=o.filter(s=>s.strength===Pe.KNIGHT_STRENGTH_STRONG).length;t.options.canPromoteToStrongKnight(a)&&i.push(n.location)}else if(n.strength===Pe.KNIGHT_STRENGTH_STRONG){if(!t.getPlayerPublicState(r)?.cityImprovements?.hasFortress)continue;let s=o.filter(u=>u.strength===Pe.KNIGHT_STRENGTH_MIGHTY).length;t.options.canPromoteToMightyKnight(s)&&i.push(n.location)}}return i}E(Dl,"promotableKnightLocations");function ml(e,r){let t=e.board.getCityWallsByPlayer(r).length;return e.options.canBuildCityWall(t)?gd(e,r):[]}E(ml,"getEngineerWallPlacements");function Ka(e,r){return e.getCitiesByPlayer(r).filter(o=>!e.board.hasMetropolis(o.vertex))}E(Ka,"getEligibleCitiesForMetropolis");function Ii(e,r,t){return pd(e,r,t).filter(i=>!(i.equals(t)||e.hasVertexBuilding(i)||e.board.hasKnight(i)))}E(Ii,"findAllDisplacementLocations");function gl(e,r){if(!e.options.seafarers)return[];let t=[],o=e.getEdgeBuildingsByPlayer(r),i=e.getVertexBuildingsByPlayer(r),n=new Set;for(let a of o)for(let s of a.edge.getNeighboringEdges())n.add(s.toString());for(let a of i)for(let s of a.vertex.getEdges())n.add(s.toString());for(let a of n){let s=Ne.ofString(a);e.hasEdgeBuilding(s)||!s.getAdjacentCenters().some(c=>!e.board.hasTile(c)||e.board.getTile(c)?.terrain===d.TERRAIN_SEA)||e.board.isEdgeAdjacentToPirate(s)||nt(e,r,s,F.BUILDING_SHIP)&&t.push(s)}return t}E(gl,"getValidShipPlacements");function yl(e,r,t){let o=[],i=e.getVertexBuildingsByPlayer(r);for(let n of i){let a=n.vertex;for(let s of a.getEdges()){let u=s.getAdjacentCenters(),l=!1,c=!1;for(let R of u){let O=e.board.getTile(R);!O||O.terrain===d.TERRAIN_SEA?c=!0:l=!0}if(!l||!c||e.board.getPortsForVertex(a).length>0)continue;let T=s.toString();o.some(R=>R.toString()===T)||o.push(s)}}return o}E(yl,"getValidPortPlacementEdges");function it(e){return e.options.seafarers?F.BUILDING_ROAD_OR_SHIP:F.BUILDING_ROAD}E(it,"freeRoadGrant");function At(e,r,t){if(t===F.BUILDING_ROAD)return zT(e,r);if(t===F.BUILDING_SHIP)return $T(e,r);if(t===F.BUILDING_ROAD_OR_SHIP)return zT(e,r)||$T(e,r);if(t===F.BUILDING_KNIGHT){let i=e.board.getKnightsByPlayer(r).filter(n=>n.strength===Pe.KNIGHT_STRENGTH_BASIC).length;return e.options.canBuildBasicKnight(i)?hl(e,r).length>0:!1}return!0}E(At,"canPlaceFreeStructure");function zT(e,r){let t=e.getRoadsByPlayer(r).length;return e.options.canBuildRoad(t)?pl(e,r).length>0:e.getBrokenRoadsByPlayer(r).length>0}E(zT,"canPlaceFreeRoad");function $T(e,r){return!e.options.seafarers||!e.options.canBuildShip(e.getShipsByPlayer(r).length)?!1:gl(e,r).length>0}E($T,"canPlaceFreeShip");var z0=[S.RESOURCE_WOOD,S.RESOURCE_BRICK,S.RESOURCE_SHEEP,S.RESOURCE_WHEAT,S.RESOURCE_ORE];var r3=new Set([b.PROGRESS_CARD_PRINTER,b.PROGRESS_CARD_CONSTITUTION]),t3=new Set([b.PROGRESS_CARD_CRANE,b.PROGRESS_CARD_MEDICINE,b.PROGRESS_CARD_ENGINEER,b.PROGRESS_CARD_SMITH,b.PROGRESS_CARD_MERCHANT_FLEET,b.PROGRESS_CARD_COMMERCIAL_HARBOR,b.PROGRESS_CARD_SPY,b.PROGRESS_CARD_MASTER_MERCHANT,b.PROGRESS_CARD_WEDDING,b.PROGRESS_CARD_DESERTER,b.PROGRESS_CARD_INTRIGUE]);var Nn=[S.RESOURCE_WOOD,S.RESOURCE_BRICK,S.RESOURCE_SHEEP,S.RESOURCE_WHEAT,S.RESOURCE_ORE],SD=[B.MAP_TYPE_TROLL_BRIDGE_4P,B.MAP_TYPE_TROLL_BRIDGE_6P,B.MAP_TYPE_TROLL_BRIDGE_8P];function f_(e,r){let t=new Map,o=new Map,i=Nn;for(let s of i)t.set(s,{resource:s,ratio:4,source:"bank"});if(e.options.citiesAndKnights){let s=[j.COMMODITY_CLOTH,j.COMMODITY_COIN,j.COMMODITY_PAPER];for(let u of s)o.set(u,{resource:u,ratio:4,source:"bank"})}let n=e.getVertexBuildingsByPlayer(r),a=new Set;for(let s of n){let u=e.board.getPortsForVertex(s.vertex);for(let l of u)a.add(l)}for(let s of a)if(s.isGeneric){for(let[u,l]of t)l.ratio>3&&t.set(u,{resource:u,ratio:3,source:"port"});for(let[u,l]of o)l.ratio>3&&o.set(u,{resource:u,ratio:3,source:"port"})}else if(s.resource!==S.RESOURCE_UNSPECIFIED){let u=t.get(s.resource);u&&u.ratio>2&&t.set(s.resource,{resource:s.resource,ratio:2,source:"port"})}if(e.options.citiesAndKnights&&e.getPlayerPublicState(r)?.cityImprovements?.hasMerchantGuild)for(let[u,l]of o)l.ratio>2&&o.set(u,{resource:u,ratio:2,source:"merchant_guild"});if(e.options.citiesAndKnights&&e.board.merchant&&e.board.getMerchantOwner()===r){let u=e.board.merchant.location,l=e.board.getTile(u);if(l){let c=S.RESOURCE_UNSPECIFIED;switch(l.terrain){case d.TERRAIN_FOREST:c=S.RESOURCE_WOOD;break;case d.TERRAIN_PASTURE:c=S.RESOURCE_SHEEP;break;case d.TERRAIN_MOUNTAINS:c=S.RESOURCE_ORE;break;case d.TERRAIN_HILLS:c=S.RESOURCE_BRICK;break;case d.TERRAIN_FIELDS:c=S.RESOURCE_WHEAT;break}if(c!==S.RESOURCE_UNSPECIFIED){let f=t.get(c);(!f||f.ratio>2)&&t.set(c,{resource:c,ratio:2,source:"merchant"})}}}if(e.options.citiesAndKnights&&e.merchantFleetResource){let s=e.merchantFleetResource,u=t.get(s);u&&u.ratio>2&&t.set(s,{resource:s,ratio:2,source:"merchant_fleet"})}if(e.options.citiesAndKnights&&e.merchantFleetCommodity){let s=e.merchantFleetCommodity,u=o.get(s);u&&u.ratio>2&&o.set(s,{resource:s,ratio:2,source:"merchant_fleet"})}return{resources:t,commodities:o}}E(f_,"getValidTradeRatios");function OD(e,r){return e.resources.get(r)??e.commodities.get(r)}E(OD,"getRatio");function Ml(e,r,t){let o=f_(e,r),i=OD(o,t);return i||{resource:t,ratio:4,source:"bank"}}E(Ml,"getBestTradeRatio");function QT(e,r,t,o,i,n){let a=e.getPlayerState(r);if(!a)return{valid:!1,error:"Player state not found"};if([t,o,i,n].some(R=>R&&Array.from(R.values()).some(O=>O<0)))return{valid:!1,error:"Invalid trade: amounts cannot be negative"};for(let[R,O]of t)if(!(O<=0)&&a.getResourceCount(R)<O)return{valid:!1,error:"You don't have the resources you're offering"};if(i){for(let[R,O]of i)if(!(O<=0)&&a.getCommodityCount(R)<O)return{valid:!1,error:"You don't have the commodities you're offering"}}for(let[R,O]of t)if(!(O<=0)&&o.has(R)&&(o.get(R)??0)>0)return{valid:!1,error:"Cannot trade for the same resource you're offering"};if(i&&n){for(let[R,O]of i)if(!(O<=0)&&n.has(R)&&(n.get(R)??0)>0)return{valid:!1,error:"Cannot trade for the same commodity you're offering"}}for(let[R,O]of o)if(!(O<=0)&&!e.hasResourcesInDeck(R,O))return{valid:!1,error:"Bank doesn't have enough of the requested resource"};if(n)for(let[R,O]of n){if(O<=0)continue;if((e.commodityBank.get(R)??0)<O)return{valid:!1,error:"Bank doesn't have enough of the requested commodity"}}let u=f_(e,r),l=0;for(let[R,O]of t){if(O<=0)continue;let I=u.resources.get(R)?.ratio;if(!I)return{valid:!1,error:"Invalid ratio: that resource cannot be traded with the bank"};if(O%I!==0)return{valid:!1,error:`Invalid ratio: offer must be a multiple of the ${I}:1 rate (no leftover cards)`};l+=O/I}if(i)for(let[R,O]of i){if(O<=0)continue;let I=u.commodities.get(R)?.ratio;if(!I)return{valid:!1,error:"Invalid ratio: that commodity cannot be traded with the bank"};if(O%I!==0)return{valid:!1,error:`Invalid ratio: offer must be a multiple of the ${I}:1 rate (no leftover cards)`};l+=O/I}let c=Array.from(o.values()).reduce((R,O)=>R+O,0),f=n?Array.from(n.values()).reduce((R,O)=>R+O,0):0,T=c+f;return T===0?{valid:!1,error:"Must request at least one resource or commodity"}:l!==T?{valid:!1,error:`Invalid ratio: can receive exactly ${l} resources with what you're offering`}:{valid:!0}}E(QT,"validateMultiBankTrade");function Ll(e){let r=e.pendingEventCardSteal;if(!r)return[];let t=[];for(let o of e.turnOrder){if(o===r)continue;let i=e.getPlayerPublicState(o);!i||i.cardCount===0||t.push(o)}return t}E(Ll,"getValidEventCardStealTargets");function Gl(e){if(e.turnOrder.length<2)return[];let r=new Map(e.turnOrder.map(i=>[i,e.getVisibleVictoryPoints(i)])),t=Math.max(...r.values());return[...r.values()].some(i=>i<t)?e.turnOrder.filter(i=>r.get(i)===t&&(e.getPlayerPublicState(i)?.cardCount??0)>0):[]}E(Gl,"getHelpfulNeighborLeaders");function T_(e,r){let t=r??e.pendingHelpfulNeighbors[0];if(!t||!e.pendingHelpfulNeighbors.includes(t))return[];let o=e.getVisibleVictoryPoints(t),i=e.turnOrder.filter(a=>a!==t),n=i.filter(a=>e.getVisibleVictoryPoints(a)<o);return n.length>0?n:i}E(T_,"getHelpfulNeighborTargets");var de;(function(e){e.DISCARD="discard",e.SELECT_RESOURCES="select_resources",e.PLACE_FREE_STRUCTURE="place_free_structure",e.SELECT_DEFENDER="select_defender",e.CITY_PILLAGE="city_pillage",e.PLACE_DISPLACED_KNIGHT="place_displaced_knight",e.GIVE_WEDDING_CARDS="give_wedding_cards",e.COMMERCIAL_HARBOR_EXCHANGE="commercial_harbor_exchange",e.KNIGHT_COMMITMENT="knight_commitment",e.CHOOSE_DESERTER_KNIGHT="choose_deserter_knight",e.METROPOLIS_PLACEMENT="metropolis_placement",e.DISCARD_PROGRESS_CARDS="discard_progress_cards",e.GOOD_NEIGHBORS="good_neighbors",e.HELPFUL_NEIGHBORS="helpful_neighbors",e.EVENT_CARD_STEAL="event_card_steal",e.EARTHQUAKE="earthquake",e.WAGON_VOTING="wagon_voting",e.VOTE_DICE_ROLL="vote_dice_roll",e.SETUP_TURN="setup_turn",e.ROLL_DICE="roll_dice",e.MOVE_ROBBER="move_robber",e.CHOOSE_STEAL_VICTIM="choose_steal_victim",e.TAKE_TURN="take_turn",e.SELECT_ALCHEMIST_DICE="select_alchemist_dice",e.SELECT_SPY_TARGET_CARD="select_spy_target_card",e.SELECT_MASTER_MERCHANT_CARDS="select_master_merchant_cards",e.COMPLETE_BISHOP_STEAL="complete_bishop_steal",e.RESOLVE_RESOURCES="resolve_resources",e.RESPOND_TO_TRADE="respond_to_trade",e.RESOLVE_TRADE="resolve_trade"})(de||(de={}));function yd(e){if(e.winner!==void 0)return[];let r=e.getFlowState();if(r.winner!==void 0)return[];if(r.paused)return[];let t=[];return ID(e,r,t),r.canCurrentPlayerAct&&CD(r,e.turnOrder,t),t}E(yd,"getPendingActions");function ID(e,r,t){for(let[o,i]of r.pendingDiscards)i>0&&t.push({player:o,action:de.DISCARD});for(let[o,i]of r.pendingFreeResources)i>0&&t.push({player:o,action:de.SELECT_RESOURCES});for(let[o,i]of r.pendingFreeStructures)i.length>0&&t.push({player:o,action:de.PLACE_FREE_STRUCTURE});for(let o of r.pendingDefenderSelection)t.push({player:o,action:de.SELECT_DEFENDER});r.pendingCityPillage!==void 0&&t.push({player:r.pendingCityPillage,action:de.CITY_PILLAGE});for(let o of r.pendingKnights)t.push({player:o.player,action:de.PLACE_DISPLACED_KNIGHT});for(let o of r.pendingWeddingCards)t.push({player:o.player,action:de.GIVE_WEDDING_CARDS});for(let o of r.pendingCommercialHarborExchanges)t.push({player:o.opponent,action:de.COMMERCIAL_HARBOR_EXCHANGE});r.pendingKnightCommitment!==void 0&&t.push({player:r.pendingKnightCommitment.currentPlayer,action:de.KNIGHT_COMMITMENT}),r.pendingDeserter!==void 0&&t.push({player:r.pendingDeserter.targetPlayer,action:de.CHOOSE_DESERTER_KNIGHT}),r.pendingMetropolisPlacement!==void 0&&t.push({player:r.pendingMetropolisPlacement.player,action:de.METROPOLIS_PLACEMENT});for(let[o,i]of r.pendingProgressCardDiscard)i>0&&t.push({player:o,action:de.DISCARD_PROGRESS_CARDS});for(let o of r.pendingGoodNeighbors)t.push({player:o,action:de.GOOD_NEIGHBORS});for(let o of r.pendingHelpfulNeighbors)t.push({player:o,action:de.HELPFUL_NEIGHBORS});r.pendingEventCardSteal!==void 0&&Ll(e).length>0&&t.push({player:r.pendingEventCardSteal,action:de.EVENT_CARD_STEAL});for(let o of r.pendingEarthquake)t.push({player:o,action:de.EARTHQUAKE});if(r.pendingWagonVoting!==void 0)for(let o of r.pendingWagonVoting.remainingVoters)t.push({player:o,action:de.WAGON_VOTING});r.pendingAlchemist!==void 0&&t.push({player:r.currentPlayer,action:de.SELECT_ALCHEMIST_DICE}),r.pendingSpyTarget!==void 0&&t.push({player:r.currentPlayer,action:de.SELECT_SPY_TARGET_CARD}),r.masterMerchantTarget!==void 0&&t.push({player:r.currentPlayer,action:de.SELECT_MASTER_MERCHANT_CARDS}),r.pendingBishopSteal!==void 0&&t.push({player:r.currentPlayer,action:de.COMPLETE_BISHOP_STEAL}),r.pendingResourceResolution&&t.push({player:r.currentPlayer,action:de.RESOLVE_RESOURCES})}E(ID,"addOutOfTurnActions");function CD(e,r,t){if(e.isSecondSettlerPhase){let o=e.secondSettlerPlayer;if(o===void 0)return;Ul(e,o,t);return}if(e.rushMode&&!e.isSetupPhase){if(Ul(e,e.currentPlayer,t),e.pendingDiceRoll)for(let o of r)o!==e.currentPlayer&&!e.rushDiceVotes.has(o)&&t.push({player:o,action:de.VOTE_DICE_ROLL});else for(let o of r)o!==e.currentPlayer&&t.push({player:o,action:de.TAKE_TURN});return}Ul(e,e.currentPlayer,t)}E(CD,"addCurrentPlayerActions");function Ul(e,r,t){if(e.isSetupPhase){t.push({player:r,action:de.SETUP_TURN});return}let o=e.rushRobberPlayer??r;if(e.pendingRobberStealLocation||e.pendingPirateStealLocation){t.push({player:o,action:de.CHOOSE_STEAL_VICTIM});return}if(e.pendingRobberPlacement){t.push({player:o,action:de.MOVE_ROBBER});return}if(e.pendingDiceRoll){t.push({player:r,action:de.ROLL_DICE});return}t.push({player:r,action:de.TAKE_TURN})}E(Ul,"addTurnActions");var PD=new Map([[2,1],[3,2],[4,3],[5,4],[6,5],[8,5],[9,4],[10,3],[11,2],[12,1]]);function jT(e){return PD.get(e)??0}E(jT,"getPipValue");function eN(e){switch(e){case d.TERRAIN_FOREST:return S.RESOURCE_WOOD;case d.TERRAIN_HILLS:return S.RESOURCE_BRICK;case d.TERRAIN_PASTURE:return S.RESOURCE_SHEEP;case d.TERRAIN_FIELDS:return S.RESOURCE_WHEAT;case d.TERRAIN_MOUNTAINS:return S.RESOURCE_ORE;default:return}}E(eN,"terrainToResource");function rN(e){let r=new Map;r.set(S.RESOURCE_WOOD,0),r.set(S.RESOURCE_BRICK,0),r.set(S.RESOURCE_SHEEP,0),r.set(S.RESOURCE_WHEAT,0),r.set(S.RESOURCE_ORE,0);for(let t of e.board.getTiles()){if(t.isDesert)continue;let o=eN(t.terrain);if(!o)continue;let i=t.numbers.reduce((n,a)=>n+jT(a),0);r.set(o,(r.get(o)??0)+i)}return r}E(rN,"getBoardResourceProduction");function Bl(e){let r=rN(e),t=new Map,o=1;for(let i of r.values())i>o&&(o=i);for(let[i,n]of r){let a=n>0?o/n:1/0;t.set(i,{resource:i,totalPips:n,scarcityWeight:a})}return t}E(Bl,"getBoardResourceScarcity");function tN(e){let t=e.getPlayerPublicStates().map(o=>o.player).map(o=>{let i=e.getPlayerState(o),n=e.getTotalVictoryPoints(o),a=0,s=0;if(i){for(let u of i.unplayedDevCards.values())a+=u;s=i.totalResourcesInHand}return{player:o,totalVP:n,devCardCount:a,resourceCount:s}});return t.sort((o,i)=>o.totalVP!==i.totalVP?i.totalVP-o.totalVP:o.devCardCount!==i.devCardCount?i.devCardCount-o.devCardCount:o.resourceCount!==i.resourceCount?i.resourceCount-o.resourceCount:0),t[0].player}E(tN,"determineDesertificationWinner");var Md=new Map([[S.RESOURCE_WOOD,1],[S.RESOURCE_BRICK,1]]),Ld=new Map([[S.RESOURCE_WOOD,1],[S.RESOURCE_BRICK,1],[S.RESOURCE_SHEEP,1],[S.RESOURCE_WHEAT,1]]),Gd=new Map([[S.RESOURCE_ORE,3],[S.RESOURCE_WHEAT,2]]),Ud=new Map([[S.RESOURCE_ORE,2],[S.RESOURCE_WHEAT,1]]),Wa=new Map([[S.RESOURCE_ORE,1],[S.RESOURCE_WHEAT,1],[S.RESOURCE_SHEEP,1]]),Bd=new Map([[S.RESOURCE_WOOD,1],[S.RESOURCE_SHEEP,1]]),Fn=new Map([[S.RESOURCE_BRICK,2],[S.RESOURCE_WOOD,1]]),kd=new Map([[S.RESOURCE_BRICK,2]]),bd=new Map([[S.RESOURCE_SHEEP,1],[S.RESOURCE_ORE,1]]),vd=new Map([[S.RESOURCE_WHEAT,1]]),Yd=new Map([[S.RESOURCE_SHEEP,1],[S.RESOURCE_ORE,1]]);function N_(e,r,t){return f_(e,r).resources.get(t)?.ratio??4}E(N_,"getGoldBuyRate");var Re=class{static{E(this,"SeededRandom")}state;constructor(r){this.state=r===0?1n:BigInt(r)}nextRaw(){let r=this.state;return r^=r<<13n,r^=r>>7n,r^=r<<17n,this.state=r&0xffffffffffffffffn,this.state}next(){let r=this.nextRaw();return Number(r&0xffffffffn)/4294967296}nextInt(r,t){let o=this.nextRaw();return Number((o&0xffffffffn)%BigInt(t-r))+r}shuffle(r){let t=[...r];for(let o=t.length-1;o>0;o--){let i=this.nextInt(0,o+1);[t[o],t[i]]=[t[i],t[o]]}return t}choice(r){return r[this.nextInt(0,r.length)]}};var Fd=class{static{E(this,"TestBoardBuilder")}tiles;ports=[];robbers=[];pirate;edgeBuildings=[];vertexBuildings=[];knights=[];cityWalls=[];metropolises=[];merchant;barbarians;fisheries=[];edgeRewards=[];wagons=[];constructor(r){this.tiles=r}withSettlement(r,t){return this.vertexBuildings.push(new mr(r,t,F.BUILDING_SETTLEMENT)),this}withCity(r,t){return this.vertexBuildings.push(new mr(r,t,F.BUILDING_CITY)),this}withBrokenCity(r,t){return this.vertexBuildings.push(new mr(r,t,F.BUILDING_BROKEN_CITY)),this}withRoad(r,t){return this.edgeBuildings.push(new ar(r,t,F.BUILDING_ROAD)),this}withShip(r,t){return this.edgeBuildings.push(new ar(r,t,F.BUILDING_SHIP)),this}withBrokenRoad(r,t){return this.edgeBuildings.push(new ar(r,t,F.BUILDING_BROKEN_ROAD)),this}withBridge(r,t){return this.edgeBuildings.push(new ar(r,t,F.BUILDING_BRIDGE)),this}withEdgeBuilding(r,t,o){return this.edgeBuildings.push(new ar(r,t,o)),this}withKnight(r,t,o=Pe.KNIGHT_STRENGTH_BASIC,i=ir.KNIGHT_STATUS_INACTIVE){return this.knights.push(new jr(r,t,o,i)),this}withCityWall(r,t){return this.cityWalls.push(new un(r,t)),this}withMetropolis(r,t,o){return this.metropolises.push(new Yr(o,r,t)),this}withRobber(r){return this.robbers=[r],this}withRobbers(r){return this.robbers=r,this}withPirate(r){return this.pirate=r,this}withPorts(r){return this.ports=r,this}withMerchant(r){return this.merchant=r,this}withBarbarians(r){return this.barbarians=r,this}withFisheries(r){return this.fisheries=r,this}withEdgeRewards(r){return this.edgeRewards=r,this}withWagon(r){return this.wagons.push(r),this}withWagons(r){return this.wagons=r,this}hasEdge(r){return this.edgeBuildings.some(t=>t.edge.equals(r))}build(){return new ge(this.tiles,this.ports,this.robbers,this.pirate,this.edgeBuildings,this.vertexBuildings,this.knights,this.cityWalls,this.metropolises,this.merchant,this.barbarians,this.fisheries,this.edgeRewards,this.wagons)}};function lr(e){return new Fd(e)}E(lr,"createTestBoard");var ur=class e{static{E(this,"SeafarersScenarios")}static createHeadingForNewShores3Player(r){let t=new Re(r),o=[new A(new _(-1,2,-1),d.TERRAIN_FIELDS,[4]),new A(new _(0,1,-1),d.TERRAIN_PASTURE,[2]),new A(new _(1,0,-1),d.TERRAIN_HILLS,[8]),new A(new _(-2,2,0),d.TERRAIN_PASTURE,[6]),new A(new _(-1,1,0),d.TERRAIN_MOUNTAINS,[5]),new A(new _(0,0,0),d.TERRAIN_PASTURE,[10]),new A(new _(1,-1,0),d.TERRAIN_FIELDS,[11]),new A(new _(-2,1,1),d.TERRAIN_FOREST,[10]),new A(new _(-1,0,1),d.TERRAIN_PASTURE,[9]),new A(new _(0,-1,1),d.TERRAIN_MOUNTAINS,[3]),new A(new _(1,-2,1),d.TERRAIN_FIELDS,[6]),new A(new _(-2,0,2),d.TERRAIN_FOREST,[8]),new A(new _(-1,-1,2),d.TERRAIN_HILLS,[11]),new A(new _(0,-2,2),d.TERRAIN_FOREST,[5])],i=[new A(new _(-4,3,1),d.TERRAIN_PASTURE,[4]),new A(new _(-5,3,2),d.TERRAIN_MOUNTAINS,[9]),new A(new _(-4,2,2),d.TERRAIN_FIELDS,[3]),new A(new _(-4,1,3),d.TERRAIN_GOLD,[4])],n=[new A(new _(-3,-1,4),d.TERRAIN_MOUNTAINS,[8]),new A(new _(-2,-2,4),d.TERRAIN_HILLS,[10])],a=[new A(new _(-2,4,-2),d.TERRAIN_HILLS,[12]),new A(new _(-3,4,-1),d.TERRAIN_GOLD,[5])],s=this.shuffleTerrainsInRegion(t,o),u=this.shuffleTerrainsInRegion(t,i),l=this.shuffleTerrainsInRegion(t,n),c=this.shuffleTerrainsInRegion(t,a),f=[...s,...u,...l,...c],T=this.createFixedPorts([{hex:new _(-1,-2,3),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,1,2),dir:C.NORTH_EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-3,2,1),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,-3,2),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(0,2,-2),dir:C.WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(1,1,-2),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(2,-1,-1),dir:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(2,-2,0),dir:C.WEST,rate:2,resource:S.RESOURCE_BRICK}]),R=f.find(g=>g.isDesert)||f.find(g=>g.numbers.includes(12)),O=R?R.location:new _(0,0,0),I=new _(1,-3,2);return{board:lr(f).withPorts(T).withRobber(O).withPirate(I).build(),smallIslandHexes:[i.map(g=>g.location),n.map(g=>g.location),a.map(g=>g.location)]}}static createHeadingForNewShores4Player(r){let t=new Re(r),o=[new A(new _(0,2,-2),d.TERRAIN_PASTURE,[5]),new A(new _(1,1,-2),d.TERRAIN_FIELDS,[12]),new A(new _(2,0,-2),d.TERRAIN_HILLS,[6]),new A(new _(-1,2,-1),d.TERRAIN_FOREST,[6]),new A(new _(0,1,-1),d.TERRAIN_HILLS,[11]),new A(new _(1,0,-1),d.TERRAIN_FOREST,[10]),new A(new _(2,-1,-1),d.TERRAIN_MOUNTAINS,[3]),new A(new _(-2,2,0),d.TERRAIN_MOUNTAINS,[4]),new A(new _(-1,1,0),d.TERRAIN_FIELDS,[3]),new A(new _(0,0,0),d.TERRAIN_DESERT,[]),new A(new _(1,-1,0),d.TERRAIN_PASTURE,[4]),new A(new _(2,-2,0),d.TERRAIN_FIELDS,[8]),new A(new _(-2,1,1),d.TERRAIN_PASTURE,[9]),new A(new _(-1,0,1),d.TERRAIN_FIELDS,[11]),new A(new _(0,-1,1),d.TERRAIN_HILLS,[9]),new A(new _(1,-2,1),d.TERRAIN_FOREST,[2]),new A(new _(-2,0,2),d.TERRAIN_FOREST,[5]),new A(new _(-1,-1,2),d.TERRAIN_PASTURE,[8]),new A(new _(0,-2,2),d.TERRAIN_MOUNTAINS,[10])],i=[new A(new _(-4,4,0),d.TERRAIN_GOLD,[4]),new A(new _(-4,3,1),d.TERRAIN_HILLS,[5]),new A(new _(-5,3,2),d.TERRAIN_MOUNTAINS,[2]),new A(new _(-4,2,2),d.TERRAIN_FOREST,[9]),new A(new _(-4,1,3),d.TERRAIN_GOLD,[10])],n=[new A(new _(-3,-1,4),d.TERRAIN_HILLS,[3]),new A(new _(-2,-2,4),d.TERRAIN_FIELDS,[6])],a=[new A(new _(-1,4,-3),d.TERRAIN_MOUNTAINS,[8]),new A(new _(-2,4,-2),d.TERRAIN_PASTURE,[11])],s=this.shuffleTerrainsInRegion(t,o),u=this.shuffleTerrainsInRegion(t,i),l=this.shuffleTerrainsInRegion(t,n),c=this.shuffleTerrainsInRegion(t,a),f=[...s,...u,...l,...c],T=this.createFixedPorts([{hex:new _(-1,-2,3),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,0,3),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,2,1),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-2,3,-1),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(0,3,-3),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(2,1,-3),dir:C.WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(3,-1,-2),dir:C.WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(3,-3,0),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(1,-3,2),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_WOOD}]),R=f.find(g=>g.isDesert),O=R?R.location:new _(0,0,0),I=new _(4,-4,0);return{board:lr(f).withPorts(T).withRobber(O).withPirate(I).build(),smallIslandHexes:[i.map(g=>g.location),n.map(g=>g.location),a.map(g=>g.location)]}}static createFourIslands3Player(r){let t=new Re(r),o=[new A(new _(-3,4,-1),d.TERRAIN_FIELDS,[4]),new A(new _(-4,4,0),d.TERRAIN_PASTURE,[3]),new A(new _(-3,3,0),d.TERRAIN_FIELDS,[9]),new A(new _(-2,2,0),d.TERRAIN_FOREST,[8]),new A(new _(-4,3,1),d.TERRAIN_HILLS,[5]),new A(new _(-3,2,1),d.TERRAIN_HILLS,[11])],i=[new A(new _(2,0,-2),d.TERRAIN_FIELDS,[11]),new A(new _(1,0,-1),d.TERRAIN_MOUNTAINS,[8]),new A(new _(2,-1,-1),d.TERRAIN_FOREST,[5]),new A(new _(0,0,0),d.TERRAIN_FOREST,[3]),new A(new _(1,-1,0),d.TERRAIN_PASTURE,[9]),new A(new _(2,-2,0),d.TERRAIN_PASTURE,[12])],n=[new A(new _(-2,0,2),d.TERRAIN_HILLS,[10]),new A(new _(-1,-1,2),d.TERRAIN_MOUNTAINS,[2]),new A(new _(-3,0,3),d.TERRAIN_HILLS,[6]),new A(new _(-2,-1,3),d.TERRAIN_FIELDS,[5])],a=[new A(new _(0,3,-3),d.TERRAIN_MOUNTAINS,[4]),new A(new _(1,2,-3),d.TERRAIN_FIELDS,[11]),new A(new _(-1,3,-2),d.TERRAIN_FOREST,[9]),new A(new _(0,2,-2),d.TERRAIN_MOUNTAINS,[10])],s=this.shuffleTerrainsInRegion(t,o),u=this.shuffleTerrainsInRegion(t,i),l=this.shuffleTerrainsInRegion(t,n),c=this.shuffleTerrainsInRegion(t,a),f=[...s,...u,...l,...c],T=this.createFixedPorts([{hex:new _(-5,4,1),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,-1,4),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(1,3,-4),dir:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(3,-1,-2),dir:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-2,1,1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(-1,2,-1),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(1,1,-2),dir:C.NORTH_EAST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(1,-2,1),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-1,0,1),dir:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED}]),R=f.find(g=>g.numbers.includes(12)),O=R?R.location:new _(0,0,0),I=new _(-1,1,0);return{board:lr(f).withPorts(T).withRobber(O).withPirate(I).build(),smallIslandHexes:[o.map(g=>g.location),i.map(g=>g.location),n.map(g=>g.location),a.map(g=>g.location)]}}static createFourIslands4Player(r){let t=new Re(r),o=[new A(new _(-3,4,-1),d.TERRAIN_FOREST,[9]),new A(new _(-2,3,-1),d.TERRAIN_MOUNTAINS,[3]),new A(new _(-4,4,0),d.TERRAIN_FOREST,[11]),new A(new _(-3,3,0),d.TERRAIN_FIELDS,[12]),new A(new _(-2,2,0),d.TERRAIN_HILLS,[5]),new A(new _(-1,1,0),d.TERRAIN_FOREST,[6]),new A(new _(-4,3,1),d.TERRAIN_PASTURE,[5]),new A(new _(-3,2,1),d.TERRAIN_MOUNTAINS,[10])],i=[new A(new _(2,0,-2),d.TERRAIN_HILLS,[4]),new A(new _(1,0,-1),d.TERRAIN_PASTURE,[9]),new A(new _(2,-1,-1),d.TERRAIN_FIELDS,[6]),new A(new _(1,-1,0),d.TERRAIN_MOUNTAINS,[4]),new A(new _(2,-2,0),d.TERRAIN_PASTURE,[10]),new A(new _(0,-1,1),d.TERRAIN_HILLS,[2]),new A(new _(1,-2,1),d.TERRAIN_FIELDS,[11])],n=[new A(new _(-1,4,-3),d.TERRAIN_PASTURE,[8]),new A(new _(0,3,-3),d.TERRAIN_HILLS,[10]),new A(new _(1,2,-3),d.TERRAIN_FIELDS,[5]),new A(new _(0,2,-2),d.TERRAIN_FOREST,[3])],a=[new A(new _(-2,0,2),d.TERRAIN_FOREST,[9]),new A(new _(-3,0,3),d.TERRAIN_PASTURE,[11]),new A(new _(-2,-1,3),d.TERRAIN_MOUNTAINS,[8]),new A(new _(-1,-2,3),d.TERRAIN_FIELDS,[4])],s=this.shuffleTerrainsInRegion(t,o),u=this.shuffleTerrainsInRegion(t,i),l=this.shuffleTerrainsInRegion(t,n),c=this.shuffleTerrainsInRegion(t,a),f=[...s,...u,...l,...c],T=this.createFixedPorts([{hex:new _(-3,-1,4),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-4,2,2),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(1,3,-4),dir:C.WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(-3,1,2),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(3,-1,-2),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(3,-2,-1),dir:C.WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-1,2,-1),dir:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,1,-2),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(0,0,0),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED}]),R=f.find(g=>g.numbers.includes(12)),O=R?R.location:new _(0,0,0),I=new _(0,0,0);return{board:lr(f).withPorts(T).withRobber(O).withPirate(I).build(),smallIslandHexes:[o.map(g=>g.location),i.map(g=>g.location),n.map(g=>g.location),a.map(g=>g.location)]}}static createFogIslands3Player(r){let t=new Re(r),o=[new A(new _(-3,2,1),d.TERRAIN_FIELDS,[10]),new A(new _(-2,1,1),d.TERRAIN_FOREST,[9]),new A(new _(-1,0,1),d.TERRAIN_PASTURE,[5]),new A(new _(-4,2,2),d.TERRAIN_PASTURE,[12]),new A(new _(-3,1,2),d.TERRAIN_MOUNTAINS,[8]),new A(new _(-2,0,2),d.TERRAIN_HILLS,[11]),new A(new _(-1,-1,2),d.TERRAIN_FOREST,[6])],i=[new A(new _(0,4,-4),d.TERRAIN_PASTURE,[9]),new A(new _(1,3,-4),d.TERRAIN_FIELDS,[3]),new A(new _(2,2,-4),d.TERRAIN_FOREST,[11]),new A(new _(-1,4,-3),d.TERRAIN_MOUNTAINS,[4]),new A(new _(0,3,-3),d.TERRAIN_PASTURE,[8]),new A(new _(1,2,-3),d.TERRAIN_FOREST,[5]),new A(new _(2,1,-3),d.TERRAIN_HILLS,[6])],n=[new A(new _(-3,5,-2),d.TERRAIN_FOG,[]),new A(new _(-4,5,-1),d.TERRAIN_FOG,[]),new A(new _(-3,4,-1),d.TERRAIN_FOG,[]),new A(new _(-2,3,-1),d.TERRAIN_FOG,[]),new A(new _(-1,2,-1),d.TERRAIN_FOG,[]),new A(new _(0,1,-1),d.TERRAIN_FOG,[]),new A(new _(1,0,-1),d.TERRAIN_FOG,[]),new A(new _(2,-1,-1),d.TERRAIN_FOG,[]),new A(new _(-4,4,0),d.TERRAIN_FOG,[]),new A(new _(1,-1,0),d.TERRAIN_FOG,[]),new A(new _(2,-2,0),d.TERRAIN_FOG,[]),new A(new _(1,-2,1),d.TERRAIN_FOG,[])],a=this.shuffleTerrainsInRegion(t,o),s=this.shuffleTerrainsInRegion(t,i),u=[...a,...s,...n],l=this.createFixedPorts([{hex:new _(-1,5,-4),dir:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,4,-5),dir:C.WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(2,3,-5),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-4,1,3),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-4,3,1),dir:C.NORTH_EAST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(3,1,-4),dir:C.WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-2,-1,3),dir:C.EAST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(-3,0,3),dir:C.EAST,rate:2,resource:S.RESOURCE_WOOD}]),c=u.find(D=>D.numbers.includes(12)),f=c?c.location:new _(-4,2,2),T=new _(2,0,-2),R=lr(u).withPorts(l).withRobber(f).withPirate(T).build(),O=t.shuffle([d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_SEA,d.TERRAIN_SEA]),I=t.shuffle([3,3,4,5,6,8,9,10,11,12]);return{board:R,fogTerrainBank:O,fogNumberBank:I}}static createFogIslands4Player(r){let t=new Re(r),o=[new A(new _(0,4,-4),d.TERRAIN_HILLS,[12]),new A(new _(1,3,-4),d.TERRAIN_MOUNTAINS,[8]),new A(new _(2,2,-4),d.TERRAIN_MOUNTAINS,[11]),new A(new _(-2,5,-3),d.TERRAIN_FOREST,[5]),new A(new _(-1,4,-3),d.TERRAIN_FIELDS,[11]),new A(new _(0,3,-3),d.TERRAIN_PASTURE,[10]),new A(new _(1,2,-3),d.TERRAIN_FOREST,[8]),new A(new _(2,1,-3),d.TERRAIN_FIELDS,[6]),new A(new _(1,1,-2),d.TERRAIN_PASTURE,[9]),new A(new _(2,0,-2),d.TERRAIN_HILLS,[4])],i=[new A(new _(-4,2,2),d.TERRAIN_FOREST,[5]),new A(new _(-3,1,2),d.TERRAIN_PASTURE,[6]),new A(new _(-2,0,2),d.TERRAIN_FOREST,[4]),new A(new _(-1,-1,2),d.TERRAIN_MOUNTAINS,[3]),new A(new _(-4,1,3),d.TERRAIN_PASTURE,[2]),new A(new _(-3,0,3),d.TERRAIN_HILLS,[9]),new A(new _(-2,-1,3),d.TERRAIN_FIELDS,[6])],n=[new A(new _(-4,5,-1),d.TERRAIN_FOG,[]),new A(new _(-3,4,-1),d.TERRAIN_FOG,[]),new A(new _(-2,3,-1),d.TERRAIN_FOG,[]),new A(new _(-1,2,-1),d.TERRAIN_FOG,[]),new A(new _(-4,4,0),d.TERRAIN_FOG,[]),new A(new _(-3,3,0),d.TERRAIN_FOG,[]),new A(new _(-2,2,0),d.TERRAIN_FOG,[]),new A(new _(-1,1,0),d.TERRAIN_FOG,[]),new A(new _(0,0,0),d.TERRAIN_FOG,[]),new A(new _(1,-1,0),d.TERRAIN_FOG,[]),new A(new _(2,-2,0),d.TERRAIN_FOG,[]),new A(new _(1,-2,1),d.TERRAIN_FOG,[])],a=this.shuffleTerrainsInRegion(t,o),s=this.shuffleTerrainsInRegion(t,i),u=[...a,...s,...n],l=this.createFixedPorts([{hex:new _(-5,2,3),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,5,-4),dir:C.WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,4,-5),dir:C.WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(2,3,-5),dir:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,-1,4),dir:C.EAST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(-4,0,4),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(3,1,-4),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(-1,-2,3),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(3,0,-3),dir:C.WEST,rate:2,resource:S.RESOURCE_SHEEP}]),c=u.find(D=>D.numbers.includes(12)),f=c?c.location:new _(0,4,-4),T=new _(4,-4,0),R=lr(u).withPorts(l).withRobber(f).withPirate(T).build(),O=t.shuffle([d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_SEA,d.TERRAIN_SEA]),I=t.shuffle([3,4,5,6,8,9,10,11,11,12]);return{board:R,fogTerrainBank:O,fogNumberBank:I}}static createThroughTheDesert3Player(r){let t=new Re(r),o=[new A(new _(2,2,-4),d.TERRAIN_DESERT,[]),new A(new _(3,1,-4),d.TERRAIN_GOLD,[4]),new A(new _(1,2,-3),d.TERRAIN_FOREST,[4]),new A(new _(2,1,-3),d.TERRAIN_DESERT,[]),new A(new _(3,0,-3),d.TERRAIN_FOREST,[3]),new A(new _(0,2,-2),d.TERRAIN_PASTURE,[6]),new A(new _(1,1,-2),d.TERRAIN_HILLS,[5]),new A(new _(2,0,-2),d.TERRAIN_DESERT,[]),new A(new _(3,-1,-2),d.TERRAIN_FIELDS,[6]),new A(new _(0,1,-1),d.TERRAIN_FOREST,[10]),new A(new _(1,0,-1),d.TERRAIN_MOUNTAINS,[3]),new A(new _(-1,1,0),d.TERRAIN_HILLS,[9]),new A(new _(0,0,0),d.TERRAIN_FIELDS,[2]),new A(new _(1,-1,0),d.TERRAIN_HILLS,[6]),new A(new _(2,-2,0),d.TERRAIN_FOREST,[11]),new A(new _(-1,0,1),d.TERRAIN_FOREST,[8]),new A(new _(0,-1,1),d.TERRAIN_FIELDS,[9]),new A(new _(1,-2,1),d.TERRAIN_MOUNTAINS,[10]),new A(new _(-1,-1,2),d.TERRAIN_PASTURE,[4]),new A(new _(0,-2,2),d.TERRAIN_PASTURE,[8])],i=[new A(new _(0,4,-4),d.TERRAIN_MOUNTAINS,[8]),new A(new _(-1,4,-3),d.TERRAIN_PASTURE,[11])],n=[new A(new _(-3,2,1),d.TERRAIN_FIELDS,[9]),new A(new _(-3,1,2),d.TERRAIN_MOUNTAINS,[5])],a=[new A(new _(-2,3,-1),d.TERRAIN_GOLD,[5])],s=this.shuffleTerrainsInRegion(t,o),u=this.shuffleTerrainsInRegion(t,i),l=this.shuffleTerrainsInRegion(t,n),c=a,f=[...s,...u,...l,...c],T=this.createFixedPorts([{hex:new _(1,3,-4),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(-1,-2,3),dir:C.EAST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(2,-3,1),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(1,-3,2),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(-2,0,2),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-2,1,1),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,2,-1),dir:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(2,-1,-1),dir:C.WEST,rate:2,resource:S.RESOURCE_BRICK}]),R=f.find(g=>g.isDesert),O=R?R.location:new _(2,2,-4),I=new _(4,-3,-1);return{board:lr(f).withPorts(T).withRobber(O).withPirate(I).build(),smallIslandHexes:[i.map(g=>g.location),n.map(g=>g.location),a.map(g=>g.location)]}}static createThroughTheDesert4Player(r){let t=new Re(r),o=[new A(new _(1,3,-4),d.TERRAIN_FOREST,[5]),new A(new _(2,2,-4),d.TERRAIN_DESERT,[]),new A(new _(3,1,-4),d.TERRAIN_GOLD,[10]),new A(new _(0,3,-3),d.TERRAIN_PASTURE,[6]),new A(new _(1,2,-3),d.TERRAIN_HILLS,[3]),new A(new _(2,1,-3),d.TERRAIN_DESERT,[]),new A(new _(3,0,-3),d.TERRAIN_MOUNTAINS,[11]),new A(new _(-1,3,-2),d.TERRAIN_FOREST,[4]),new A(new _(0,2,-2),d.TERRAIN_FIELDS,[10]),new A(new _(1,1,-2),d.TERRAIN_MOUNTAINS,[8]),new A(new _(2,0,-2),d.TERRAIN_DESERT,[]),new A(new _(3,-1,-2),d.TERRAIN_FIELDS,[8]),new A(new _(-1,2,-1),d.TERRAIN_PASTURE,[9]),new A(new _(0,1,-1),d.TERRAIN_HILLS,[11]),new A(new _(1,0,-1),d.TERRAIN_FOREST,[10]),new A(new _(-1,1,0),d.TERRAIN_FOREST,[8]),new A(new _(0,0,0),d.TERRAIN_FIELDS,[5]),new A(new _(1,-1,0),d.TERRAIN_HILLS,[6]),new A(new _(2,-2,0),d.TERRAIN_HILLS,[12]),new A(new _(-1,0,1),d.TERRAIN_MOUNTAINS,[4]),new A(new _(0,-1,1),d.TERRAIN_PASTURE,[11]),new A(new _(1,-2,1),d.TERRAIN_PASTURE,[3]),new A(new _(-1,-1,2),d.TERRAIN_FOREST,[9])],i=[new A(new _(-1,5,-4),d.TERRAIN_MOUNTAINS,[9]),new A(new _(-2,5,-3),d.TERRAIN_FIELDS,[4]),new A(new _(-3,5,-2),d.TERRAIN_HILLS,[2])],n=[new A(new _(-4,2,2),d.TERRAIN_FIELDS,[12]),new A(new _(-3,1,2),d.TERRAIN_MOUNTAINS,[6])],a=[new A(new _(-4,4,0),d.TERRAIN_PASTURE,[3]),new A(new _(-3,3,0),d.TERRAIN_GOLD,[5])],s=this.shuffleTerrainsInRegion(t,o),u=this.shuffleTerrainsInRegion(t,i),l=this.shuffleTerrainsInRegion(t,n),c=this.shuffleTerrainsInRegion(t,a),f=[...s,...u,...l,...c],T=this.createFixedPorts([{hex:new _(-1,4,-3),dir:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(0,4,-4),dir:C.NORTH_EAST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(-1,-2,3),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-2,3,-1),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(2,-3,1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(0,-2,2),dir:C.EAST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(-2,0,2),dir:C.NORTH_EAST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(-2,1,1),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(2,-1,-1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_SHEEP}]),R=f.find(g=>g.isDesert),O=R?R.location:new _(2,2,-4),I=new _(5,-4,-1);return{board:lr(f).withPorts(T).withRobber(O).withPirate(I).build(),smallIslandHexes:[i.map(g=>g.location),n.map(g=>g.location),a.map(g=>g.location)]}}static layOutNewWorld(r,t,o,i,n=1e3){let a=[...t].sort(_.compare),s=E(l=>l===6||l===8,"isRed"),u=i;for(let l=0;l<n;l++){let c=0,f=a.map((O,I)=>{let D=o[I];return D===d.TERRAIN_SEA||D===d.TERRAIN_DESERT?new A(O,D,[]):new A(O,D,[u[c++]])}),T=new Map(f.map(O=>[O.location.toString(),O.numbers[0]]));if(!f.some(O=>s(O.numbers[0])&&O.location.getAllNeighbors().some(I=>s(T.get(I.toString())))))return f;u=r.shuffle(u)}throw new Error(`layOutNewWorld: no layout without touching 6s and 8s after ${n} attempts`)}static createNewWorld3Player(r){let t=new Re(r),o=[new _(-1,5,-4),new _(0,4,-4),new _(1,3,-4),new _(2,2,-4),new _(3,1,-4),new _(-2,5,-3),new _(-1,4,-3),new _(0,3,-3),new _(1,2,-3),new _(2,1,-3),new _(3,0,-3),new _(-3,5,-2),new _(-2,4,-2),new _(-1,3,-2),new _(0,2,-2),new _(1,1,-2),new _(2,0,-2),new _(3,-1,-2),new _(-3,4,-1),new _(-2,3,-1),new _(-1,2,-1),new _(0,1,-1),new _(1,0,-1),new _(2,-1,-1),new _(-4,4,0),new _(-3,3,0),new _(-2,2,0),new _(-1,1,0),new _(0,0,0),new _(1,-1,0),new _(2,-2,0),new _(-4,3,1),new _(-3,2,1),new _(-2,1,1),new _(-1,0,1),new _(0,-1,1),new _(1,-2,1),new _(-4,2,2),new _(-3,1,2),new _(-2,0,2),new _(-1,-1,2),new _(0,-2,2)],i=[],n=new _(-5,4,1),a=t.shuffle([d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA]),s=t.shuffle([2,3,3,3,4,4,4,5,5,5,6,6,8,8,9,9,9,10,10,10,11,11,12]),u=e.layOutNewWorld(t,o,a,s),l=u.find(T=>T.isDesert)||u.find(T=>T.numbers.includes(12)),c=l?l.location:new _(0,0,0);return{board:lr(u).withPorts(i).withRobber(c).withPirate(n).build()}}static createNewWorld4Player(r){let t=new Re(r),o=[new _(-1,5,-4),new _(0,4,-4),new _(1,3,-4),new _(2,2,-4),new _(3,1,-4),new _(-2,5,-3),new _(-1,4,-3),new _(0,3,-3),new _(1,2,-3),new _(2,1,-3),new _(3,0,-3),new _(-3,5,-2),new _(-2,4,-2),new _(-1,3,-2),new _(0,2,-2),new _(1,1,-2),new _(2,0,-2),new _(3,-1,-2),new _(-3,4,-1),new _(-2,3,-1),new _(-1,2,-1),new _(0,1,-1),new _(1,0,-1),new _(2,-1,-1),new _(-4,4,0),new _(-3,3,0),new _(-2,2,0),new _(-1,1,0),new _(0,0,0),new _(1,-1,0),new _(2,-2,0),new _(-4,3,1),new _(-3,2,1),new _(-2,1,1),new _(-1,0,1),new _(0,-1,1),new _(1,-2,1),new _(-4,2,2),new _(-3,1,2),new _(-2,0,2),new _(-1,-1,2),new _(0,-2,2)],i=[],n=new _(-5,4,1),a=t.shuffle([d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA,d.TERRAIN_SEA]),s=t.shuffle([2,3,3,3,4,4,4,5,5,5,6,6,8,8,9,9,9,10,10,10,11,11,12]),u=e.layOutNewWorld(t,o,a,s),l=u.find(T=>T.isDesert)||u.find(T=>T.numbers.includes(12)),c=l?l.location:new _(0,0,0);return{board:lr(u).withPorts(i).withRobber(c).withPirate(n).build()}}static createForgottenTribe(r){let t=new Re(r),o=[new A(new _(-2,0,2),d.TERRAIN_FOREST,[11]),new A(new _(-1,-1,2),d.TERRAIN_PASTURE,[5]),new A(new _(0,-2,2),d.TERRAIN_FOREST,[6]),new A(new _(1,-3,2),d.TERRAIN_FIELDS,[4]),new A(new _(-2,1,1),d.TERRAIN_HILLS,[8]),new A(new _(-1,0,1),d.TERRAIN_FIELDS,[4]),new A(new _(0,-1,1),d.TERRAIN_DESERT,[]),new A(new _(1,-2,1),d.TERRAIN_PASTURE,[5]),new A(new _(2,-3,1),d.TERRAIN_MOUNTAINS,[2]),new A(new _(-1,1,0),d.TERRAIN_MOUNTAINS,[3]),new A(new _(0,0,0),d.TERRAIN_HILLS,[8]),new A(new _(1,-1,0),d.TERRAIN_FIELDS,[10]),new A(new _(2,-2,0),d.TERRAIN_MOUNTAINS,[3])],i=[new A(new _(3,-3,0),d.TERRAIN_PASTURE,[6]),new A(new _(3,-2,-1),d.TERRAIN_MOUNTAINS,[9]),new A(new _(3,-1,-2),d.TERRAIN_PASTURE,[10]),new A(new _(3,0,-3),d.TERRAIN_PASTURE,[11]),new A(new _(2,1,-3),d.TERRAIN_PASTURE,[9])],n=[new A(new _(-3,0,3),d.TERRAIN_FOREST,[]),new A(new _(-2,-1,3),d.TERRAIN_FOREST,[]),new A(new _(-3,1,2),d.TERRAIN_DESERT,[]),new A(new _(-3,2,1),d.TERRAIN_DESERT,[]),new A(new _(-2,2,0),d.TERRAIN_FOREST,[]),new A(new _(-1,2,-1),d.TERRAIN_FOREST,[]),new A(new _(0,2,-2),d.TERRAIN_GOLD,[12]),new A(new _(1,1,-2),d.TERRAIN_GOLD,[])],a=this.shuffleTerrainsInRegion(t,o,n),s=this.shuffleTerrainsInRegion(t,i,[...a,...n]),u=[...a,...s,...n],l=this.createForgottenTribePorts(u,t),c=this.createForgottenTribeEdgeRewards(t),f=u.find(I=>I.isDesert),T=f?f.location:new _(0,-1,1),R=new _(4,-4,0);return{board:lr(u).withPorts(l).withRobber(T).withPirate(R).withEdgeRewards(c).build(),smallIslandHexes:[i.map(I=>I.location),n.map(I=>I.location)]}}static createForgottenTribePorts(r,t){let o=new Set(r.map(u=>u.location.toString())),i=t.shuffle([{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}]),n=[],a=new Set,s=0;for(let u of r){if(s>=i.length)break;let l=u.location.getAllEdges();for(let c of l){if(s>=i.length)break;let f=c.getAdjacentCenters();if(f.filter(R=>o.has(R.toString())).length===1){let R=f.find(k=>!o.has(k.toString()));if(!R)continue;let O=R.toString();if(a.has(O)||R.getAllNeighbors().some(k=>a.has(k.toString())))continue;let g=i[s];n.push(new me(g.rate,g.resource,R,c)),a.add(O),s++}}}return n}static createForgottenTribeEdgeRewards(r){let t=[],o=[new _(3,-3,0),new _(3,-2,-1),new _(3,-1,-2),new _(3,0,-3),new _(2,1,-3),new _(2,-3,1),new _(1,-3,2),new _(0,-2,2),new _(-2,0,2),new _(-2,1,1),new _(-1,2,-1),new _(0,2,-2),new _(1,1,-2)],i=[];for(let a of o){let s=a.getAllVerticies();for(let u=0;u<s.length;u++){let l=s[u],c=s[(u+1)%s.length],f=l.getEdgeTo(c);i.some(T=>T.equals(f))||i.push(f)}}let n=r.shuffle([...i]);for(let a=0;a<8&&a<n.length;a++)t.push(new En(n[a],Tr.EDGE_REWARD_TYPE_VICTORY_POINT));for(let a=8;a<12&&a<n.length;a++)t.push(new En(n[a],Tr.EDGE_REWARD_TYPE_DEV_CARD));for(let a=12;a<18&&a<n.length;a++){let s=n[a],u=new me(3,S.RESOURCE_UNSPECIFIED,_.ORIGIN,s);t.push(new En(s,Tr.EDGE_REWARD_TYPE_PORT,u))}return t}static shuffleTerrainsInRegion(r,t,o,i=10,n=5e3){if(t.length<=1)return t;let a=new Map;t.forEach((R,O)=>a.set(R.location.toString(),O));let s=t.map(R=>{let O=[];for(let I of R.location.getAllNeighbors()){let D=a.get(I.toString());D!==void 0&&O.push(D)}return O}),u=new Map;for(let R of o??[])R.numbers.length>0&&u.set(R.location.toString(),R.numbers[0]);let l=t.map(R=>{let O=[];for(let I of R.location.getAllNeighbors()){let D=u.get(I.toString());D!==void 0&&O.push(D)}return O}),c=E((R,O)=>R===2&&O===12||R===12&&O===2||(R===6||R===8)&&(O===6||O===8),"isViolation"),f=E((R,O,I)=>{let D=R[O].numbers;if(D.length===0)return 0;let g=D[0],k=0;for(let v of s[O]){if(v===I)continue;let Y=R[v].numbers;Y.length!==0&&c(g,Y[0])&&k++}for(let v of l[O])c(g,v)&&k++;return k},"violationsAt"),T=E(R=>{let O=0;for(let I=0;I<R.length;I++){let D=R[I].numbers;if(D.length===0)continue;let g=D[0];for(let k of s[I]){if(k<=I)continue;let v=R[k].numbers;v.length!==0&&c(g,v[0])&&O++}for(let k of l[I])c(g,k)&&O++}return O},"computeTotalViolations");for(let R=0;R<i;R++){let O=r.shuffle(t.map(D=>({terrain:D.terrain,numbers:D.numbers}))),I=T(O);for(let D=0;D<n&&I>0;D++){let g=r.nextInt(0,O.length),k=r.nextInt(0,O.length);if(g===k)continue;let v=f(O,g)+f(O,k,g);[O[g],O[k]]=[O[k],O[g]];let Y=f(O,g)+f(O,k,g);Y>v?[O[g],O[k]]=[O[k],O[g]]:I+=Y-v}if(I===0)return t.map((D,g)=>new A(D.location,O[g].terrain,O[g].numbers))}throw new Error(`shuffleTerrainsInRegion: could not resolve adjacency violations after ${i} restarts`)}static ensureNoAdjacentRedNumbers(r){let t=new Map;for(let o of r)t.set(o.location.toString(),o);for(let o=0;o<100;o++){let i=!1;for(let n of r){if(n.numbers[0]!==6&&n.numbers[0]!==8)continue;let a=n.location.getAllNeighbors();for(let s of a){let u=t.get(s.toString());if(u&&(u.numbers[0]===6||u.numbers[0]===8)){for(let l of r){if(l===n||l===u||l.numbers[0]===6||l.numbers[0]===8||l.numbers.length===0)continue;if(!l.location.getAllNeighbors().some(T=>{let R=t.get(T.toString());return R&&(R.numbers[0]===6||R.numbers[0]===8)})){let T=n.numbers[0];n.numbers=[l.numbers[0]],l.numbers=[T],i=!0;break}}if(i)break}}if(i)break}if(!i)break}}static createFixedPorts(r){return r.map(t=>new me(t.rate,t.resource,t.hex,t.hex.getEdgeInDirection(t.dir)))}static createFourIslandsRandom(r){let t=new Re(r),o=[new _(-2,2,0),new _(-1,1,0),new _(-1,2,-1),new _(-1,3,-2),new _(-2,3,-1),new _(-3,3,0),new _(-3,2,1),new _(-3,0,3),new _(-3,-1,4),new _(-2,-1,3),new _(-2,-2,4),new _(1,0,-1),new _(2,0,-2),new _(3,0,-3),new _(3,-1,-2),new _(2,1,-3),new _(1,-2,1),new _(2,-3,1),new _(3,-4,1),new _(3,-3,0),new _(2,-4,2),new _(1,-3,2),new _(1,-4,3)],i=[d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_DESERT,d.TERRAIN_MOUNTAINS,d.TERRAIN_FIELDS,d.TERRAIN_FOREST,d.TERRAIN_PASTURE,d.TERRAIN_DESERT,d.TERRAIN_MOUNTAINS,d.TERRAIN_FIELDS,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS],n=[2,5,4,8,11,9,0,8,10,4,9,0,3,5,6,10,3,4,6,9,10,11,12],a=t.shuffle([...i]),s=t.shuffle(n.filter(v=>v>0)),u=0,l=o.map((v,Y)=>{let V=a[Y];return V===d.TERRAIN_DESERT?new A(v,V,[]):new A(v,V,[s[u++]])});this.swapBadAdjacencies(l,t);let c=this.createFourIslandsRandomPorts(),T=l.find(v=>v.isDesert)?.location??new _(0,0,0),R=new _(0,0,0),O=lr(l).withPorts(c).withRobber(T).withPirate(R).build(),I=l.filter(v=>v.location.x<=-1&&v.location.y>=1).map(v=>v.location),D=l.filter(v=>v.location.z>=3).map(v=>v.location),g=l.filter(v=>v.location.x>=1&&v.location.z<=-1).map(v=>v.location),k=l.filter(v=>v.location.x>=1&&v.location.y<=-2).map(v=>v.location);return{board:O,smallIslandHexes:[I,D,g,k]}}static swapBadAdjacencies(r,t){let o=new Map(r.map(i=>[i.location.toString(),i]));for(let i=0;i<40;i++){let n=!1;for(let a of r){if(!a.numbers[0]||a.numbers[0]===0)continue;let s=a.location.getAllNeighbors();for(let u of s){let l=o.get(u.toString());if(!l||!l.numbers[0])continue;let c=a.numbers[0],f=l.numbers[0];if(c===f||c===6&&f===8||c===8&&f===6){let R=r.filter(O=>O!==a&&O!==l&&O.numbers[0]&&O.numbers[0]!==c&&O.numbers[0]!==f);if(R.length>0){let O=R[Math.floor(t.next()*R.length)],I=a.numbers[0];a.numbers=[O.numbers[0]],O.numbers=[I],n=!0;break}}}if(n)break}if(!n)break}}static createFourIslandsRandomPorts(){return[{hex:new _(-4,0,4),direction:C.EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-4,4,0),direction:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-2,4,-2),direction:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(2,-1,-1),direction:C.EAST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(4,-1,-3),direction:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(0,-2,2),direction:C.NORTH_EAST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(-2,1,1),direction:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(4,-3,-1),direction:C.WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(4,-5,1),direction:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(2,-5,3),direction:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_WOOD}].map(t=>{let o=t.hex.getEdgeInDirection(t.direction);return new me(t.rate,t.resource,t.hex,o)})}static createHeadingForNewShores6Player(r){let t=new Re(r),o=[new A(new _(-1,4,-3),d.TERRAIN_FOREST,[10]),new A(new _(0,3,-3),d.TERRAIN_MOUNTAINS,[6]),new A(new _(1,2,-3),d.TERRAIN_PASTURE,[3]),new A(new _(2,1,-3),d.TERRAIN_FOREST,[8]),new A(new _(-2,4,-2),d.TERRAIN_FIELDS,[11]),new A(new _(-1,3,-2),d.TERRAIN_PASTURE,[9]),new A(new _(0,2,-2),d.TERRAIN_DESERT,[]),new A(new _(1,1,-2),d.TERRAIN_HILLS,[5]),new A(new _(2,0,-2),d.TERRAIN_FIELDS,[4]),new A(new _(-3,4,-1),d.TERRAIN_MOUNTAINS,[11]),new A(new _(-2,3,-1),d.TERRAIN_PASTURE,[4]),new A(new _(-1,2,-1),d.TERRAIN_FIELDS,[12]),new A(new _(0,1,-1),d.TERRAIN_HILLS,[6]),new A(new _(1,0,-1),d.TERRAIN_FOREST,[9]),new A(new _(2,-1,-1),d.TERRAIN_PASTURE,[8]),new A(new _(-3,3,0),d.TERRAIN_HILLS,[8]),new A(new _(-2,2,0),d.TERRAIN_MOUNTAINS,[5]),new A(new _(-1,1,0),d.TERRAIN_MOUNTAINS,[3]),new A(new _(0,0,0),d.TERRAIN_FIELDS,[12]),new A(new _(1,-1,0),d.TERRAIN_HILLS,[10]),new A(new _(2,-2,0),d.TERRAIN_FIELDS,[2]),new A(new _(-3,2,1),d.TERRAIN_PASTURE,[9]),new A(new _(-2,1,1),d.TERRAIN_FOREST,[10]),new A(new _(-1,0,1),d.TERRAIN_FOREST,[12]),new A(new _(0,-1,1),d.TERRAIN_MOUNTAINS,[11]),new A(new _(1,-2,1),d.TERRAIN_PASTURE,[5]),new A(new _(-3,1,2),d.TERRAIN_FIELDS,[3]),new A(new _(-2,0,2),d.TERRAIN_DESERT,[]),new A(new _(-1,-1,2),d.TERRAIN_HILLS,[6]),new A(new _(0,-2,2),d.TERRAIN_FOREST,[4])],i=[new A(new _(-5,4,1),d.TERRAIN_GOLD,[5]),new A(new _(-5,3,2),d.TERRAIN_FOREST,[2]),new A(new _(-5,2,3),d.TERRAIN_HILLS,[4])],n=[new A(new _(-4,0,4),d.TERRAIN_PASTURE,[8]),new A(new _(-3,-1,4),d.TERRAIN_MOUNTAINS,[11]),new A(new _(-2,-2,4),d.TERRAIN_GOLD,[9])],a=[new A(new _(1,4,-5),d.TERRAIN_GOLD,[10])],s=[new A(new _(3,2,-5),d.TERRAIN_FIELDS,[3])],u=[new A(new _(4,0,-4),d.TERRAIN_HILLS,[12])],l=[new A(new _(4,-2,-2),d.TERRAIN_MOUNTAINS,[6])],c=this.shuffleTerrainsInRegion(t,o),f=this.shuffleTerrainsInRegion(t,i),T=this.shuffleTerrainsInRegion(t,n),R=a,O=s,I=u,D=l,g=[...c,...f,...T,...R,...O,...I,...D],k=this.createFixedPorts([{hex:new _(-3,5,-2),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,5,-4),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(-4,2,2),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-4,4,0),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,3,-4),dir:C.WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(2,2,-4),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-1,-2,3),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,0,3),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(3,0,-3),dir:C.WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(3,-2,-1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(2,-3,1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WOOD}]),Y=g.find(J=>J.isDesert)?.location??new _(0,0,0),V=new _(0,-4,4);return{board:lr(g).withPorts(k).withRobber(Y).withPirate(V).build(),smallIslandHexes:[i.map(J=>J.location),n.map(J=>J.location),a.map(J=>J.location),s.map(J=>J.location),u.map(J=>J.location),l.map(J=>J.location)]}}static createSixIslands6Player(r){let t=new Re(r),o=[new A(new _(-6,4,2),d.TERRAIN_FIELDS,[6]),new A(new _(-5,3,2),d.TERRAIN_FOREST,[5]),new A(new _(-6,3,3),d.TERRAIN_PASTURE,[9]),new A(new _(-5,2,3),d.TERRAIN_HILLS,[8]),new A(new _(-6,2,4),d.TERRAIN_FIELDS,[2]),new A(new _(-5,1,4),d.TERRAIN_HILLS,[5])],i=[new A(new _(2,0,-2),d.TERRAIN_MOUNTAINS,[4]),new A(new _(3,-1,-2),d.TERRAIN_PASTURE,[12]),new A(new _(2,-1,-1),d.TERRAIN_MOUNTAINS,[10]),new A(new _(3,-2,-1),d.TERRAIN_FOREST,[8]),new A(new _(2,-2,0),d.TERRAIN_FIELDS,[9]),new A(new _(3,-3,0),d.TERRAIN_HILLS,[11])],n=[new A(new _(-3,5,-2),d.TERRAIN_PASTURE,[6]),new A(new _(-2,4,-2),d.TERRAIN_MOUNTAINS,[9]),new A(new _(-4,5,-1),d.TERRAIN_HILLS,[10]),new A(new _(-3,4,-1),d.TERRAIN_FIELDS,[3]),new A(new _(-4,4,0),d.TERRAIN_FOREST,[4])],a=[new A(new _(1,-3,2),d.TERRAIN_HILLS,[4]),new A(new _(0,-3,3),d.TERRAIN_FIELDS,[12]),new A(new _(1,-4,3),d.TERRAIN_FOREST,[9]),new A(new _(-1,-3,4),d.TERRAIN_MOUNTAINS,[6]),new A(new _(0,-4,4),d.TERRAIN_PASTURE,[5])],s=[new A(new _(-3,1,2),d.TERRAIN_FOREST,[10]),new A(new _(-2,0,2),d.TERRAIN_PASTURE,[8]),new A(new _(-3,0,3),d.TERRAIN_MOUNTAINS,[3]),new A(new _(-2,-1,3),d.TERRAIN_FIELDS,[5]),new A(new _(-3,-1,4),d.TERRAIN_PASTURE,[2])],u=[new A(new _(0,2,-2),d.TERRAIN_FOREST,[6]),new A(new _(-1,2,-1),d.TERRAIN_HILLS,[10]),new A(new _(0,1,-1),d.TERRAIN_MOUNTAINS,[11]),new A(new _(-1,1,0),d.TERRAIN_FOREST,[4]),new A(new _(0,0,0),d.TERRAIN_PASTURE,[3])],l=this.shuffleTerrainsInRegion(t,o),c=this.shuffleTerrainsInRegion(t,i),f=this.shuffleTerrainsInRegion(t,n),T=this.shuffleTerrainsInRegion(t,a),R=this.shuffleTerrainsInRegion(t,s),O=this.shuffleTerrainsInRegion(t,u),I=[...l,...c,...f,...T,...R,...O],D=this.createFixedPorts([{hex:new _(-7,4,3),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,6,-3),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(-5,0,5),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(2,-5,3),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(-2,-2,4),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,-2,3),dir:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,3,0),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(0,3,-3),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(3,0,-3),dir:C.WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(2,-3,1),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(1,-1,0),dir:C.EAST,rate:2,resource:S.RESOURCE_SHEEP}]),k=I.find(V=>V.numbers.includes(12))?.location??new _(0,0,0),v=new _(1,0,-1);return{board:lr(I).withPorts(D).withRobber(k).withPirate(v).build(),smallIslandHexes:[l.map(V=>V.location),c.map(V=>V.location),f.map(V=>V.location),T.map(V=>V.location),R.map(V=>V.location),O.map(V=>V.location)]}}static createThroughTheDesert6Player(r){let t=new Re(r),o=[new A(new _(3,3,-6),d.TERRAIN_HILLS,[6]),new A(new _(3,2,-5),d.TERRAIN_MOUNTAINS,[3]),new A(new _(2,2,-4),d.TERRAIN_DESERT,[]),new A(new _(3,1,-4),d.TERRAIN_FIELDS,[5]),new A(new _(0,3,-3),d.TERRAIN_HILLS,[8]),new A(new _(1,2,-3),d.TERRAIN_FOREST,[10]),new A(new _(2,1,-3),d.TERRAIN_DESERT,[]),new A(new _(3,0,-3),d.TERRAIN_FOREST,[12]),new A(new _(-1,3,-2),d.TERRAIN_FIELDS,[9]),new A(new _(0,2,-2),d.TERRAIN_FOREST,[4]),new A(new _(1,1,-2),d.TERRAIN_PASTURE,[9]),new A(new _(2,0,-2),d.TERRAIN_DESERT,[]),new A(new _(-1,2,-1),d.TERRAIN_MOUNTAINS,[3]),new A(new _(0,1,-1),d.TERRAIN_PASTURE,[10]),new A(new _(1,0,-1),d.TERRAIN_FOREST,[8]),new A(new _(2,-1,-1),d.TERRAIN_DESERT,[]),new A(new _(3,-2,-1),d.TERRAIN_HILLS,[11]),new A(new _(-1,1,0),d.TERRAIN_HILLS,[11]),new A(new _(0,0,0),d.TERRAIN_HILLS,[5]),new A(new _(1,-1,0),d.TERRAIN_FIELDS,[2]),new A(new _(2,-2,0),d.TERRAIN_DESERT,[]),new A(new _(3,-3,0),d.TERRAIN_MOUNTAINS,[6]),new A(new _(-1,0,1),d.TERRAIN_MOUNTAINS,[6]),new A(new _(0,-1,1),d.TERRAIN_FIELDS,[10]),new A(new _(2,-3,1),d.TERRAIN_PASTURE,[2]),new A(new _(3,-4,1),d.TERRAIN_GOLD,[4]),new A(new _(-1,-1,2),d.TERRAIN_HILLS,[12]),new A(new _(0,-2,2),d.TERRAIN_FOREST,[5]),new A(new _(2,-4,2),d.TERRAIN_FOREST,[5]),new A(new _(-2,-1,3),d.TERRAIN_MOUNTAINS,[11]),new A(new _(-1,-2,3),d.TERRAIN_FIELDS,[3]),new A(new _(0,-3,3),d.TERRAIN_MOUNTAINS,[4]),new A(new _(-3,-1,4),d.TERRAIN_PASTURE,[6]),new A(new _(-2,-2,4),d.TERRAIN_HILLS,[9]),new A(new _(-1,-3,4),d.TERRAIN_PASTURE,[12])],i=[new A(new _(-1,6,-5),d.TERRAIN_MOUNTAINS,[8]),new A(new _(-2,6,-4),d.TERRAIN_FOREST,[3]),new A(new _(-3,6,-3),d.TERRAIN_FIELDS,[9]),new A(new _(-2,5,-3),d.TERRAIN_PASTURE,[11])],n=[new A(new _(-3,2,1),d.TERRAIN_FIELDS,[2]),new A(new _(-3,1,2),d.TERRAIN_PASTURE,[8])],a=[new A(new _(1,5,-6),d.TERRAIN_GOLD,[10])],s=[new A(new _(-3,4,-1),d.TERRAIN_GOLD,[4])],u=this.shuffleTerrainsInRegion(t,o),l=this.shuffleTerrainsInRegion(t,i),c=this.shuffleTerrainsInRegion(t,n),f=a,T=s,R=[...u,...l,...c,...f,...T],O=this.createFixedPorts([{hex:new _(-2,-3,5),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-4,-1,5),dir:C.EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-1,4,-3),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,3,-4),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(1,-4,3),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(-3,0,3),dir:C.NORTH_EAST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(-2,3,-1),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-2,0,2),dir:C.NORTH_EAST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(-2,1,1),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,-2,1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WOOD}]),D=R.find(v=>v.isDesert)?.location??new _(2,2,-4),g=new _(5,-5,0);return{board:lr(R).withPorts(O).withRobber(D).withPirate(g).build(),smallIslandHexes:[i.map(v=>v.location),n.map(v=>v.location),a.map(v=>v.location),s.map(v=>v.location)]}}static createNewWorld6Player(r){let t=new Re(r),o=[new _(-2,5,-3),new _(-1,4,-3),new _(0,3,-3),new _(1,2,-3),new _(2,1,-3),new _(3,0,-3),new _(4,-1,-3),new _(5,-2,-3),new _(-3,5,-2),new _(-2,4,-2),new _(-1,3,-2),new _(0,2,-2),new _(1,1,-2),new _(2,0,-2),new _(3,-1,-2),new _(4,-2,-2),new _(5,-3,-2),new _(-4,5,-1),new _(-3,4,-1),new _(-2,3,-1),new _(-1,2,-1),new _(0,1,-1),new _(1,0,-1),new _(2,-1,-1),new _(3,-2,-1),new _(4,-3,-1),new _(5,-4,-1),new _(-4,4,0),new _(-3,3,0),new _(-2,2,0),new _(-1,1,0),new _(0,0,0),new _(1,-1,0),new _(2,-2,0),new _(3,-3,0),new _(4,-4,0),new _(-5,4,1),new _(-4,3,1),new _(-3,2,1),new _(-2,1,1),new _(-1,0,1),new _(0,-1,1),new _(1,-2,1),new _(2,-3,1),new _(3,-4,1),new _(4,-5,1),new _(-5,3,2),new _(-4,2,2),new _(-3,1,2),new _(-2,0,2),new _(-1,-1,2),new _(0,-2,2),new _(1,-3,2),new _(2,-4,2),new _(3,-5,2),new _(-5,2,3),new _(-4,1,3),new _(-3,0,3),new _(-2,-1,3),new _(-1,-2,3),new _(0,-3,3),new _(1,-4,3),new _(2,-5,3)],i=[],n=new _(6,-6,0),a=t.shuffle([...Array(3).fill(d.TERRAIN_DESERT),...Array(7).fill(d.TERRAIN_FOREST),...Array(7).fill(d.TERRAIN_HILLS),...Array(7).fill(d.TERRAIN_PASTURE),...Array(7).fill(d.TERRAIN_FIELDS),...Array(7).fill(d.TERRAIN_MOUNTAINS),...Array(4).fill(d.TERRAIN_GOLD),...Array(21).fill(d.TERRAIN_SEA)]),s=t.shuffle([...Array(2).fill(2),...Array(3).fill(3),...Array(4).fill(4),...Array(5).fill(5),...Array(5).fill(6),...Array(5).fill(8),...Array(5).fill(9),...Array(4).fill(10),...Array(4).fill(11),...Array(3).fill(12)]),u=e.layOutNewWorld(t,o,a,s),l=u.find(T=>T.isDesert)||u.find(T=>T.numbers.includes(12)),c=l?l.location:new _(0,0,0);return{board:lr(u).withPorts(i).withRobber(c).withPirate(n).build()}}static createFogIslands6Player(r){let t=new Re(r),o=[new A(new _(3,3,-6),d.TERRAIN_FIELDS,[6]),new A(new _(2,3,-5),d.TERRAIN_FOREST,[4]),new A(new _(3,2,-5),d.TERRAIN_MOUNTAINS,[11]),new A(new _(1,3,-4),d.TERRAIN_FOREST,[3]),new A(new _(2,2,-4),d.TERRAIN_HILLS,[12]),new A(new _(3,1,-4),d.TERRAIN_HILLS,[8]),new A(new _(1,2,-3),d.TERRAIN_FIELDS,[10]),new A(new _(2,1,-3),d.TERRAIN_PASTURE,[9]),new A(new _(3,0,-3),d.TERRAIN_HILLS,[11]),new A(new _(0,2,-2),d.TERRAIN_FOREST,[8]),new A(new _(1,1,-2),d.TERRAIN_MOUNTAINS,[12]),new A(new _(2,0,-2),d.TERRAIN_MOUNTAINS,[10]),new A(new _(3,-1,-2),d.TERRAIN_DESERT,[]),new A(new _(0,1,-1),d.TERRAIN_FIELDS,[11]),new A(new _(1,0,-1),d.TERRAIN_HILLS,[3]),new A(new _(2,-1,-1),d.TERRAIN_MOUNTAINS,[6]),new A(new _(3,-2,-1),d.TERRAIN_MOUNTAINS,[3]),new A(new _(0,0,0),d.TERRAIN_FOREST,[5]),new A(new _(1,-1,0),d.TERRAIN_FIELDS,[9]),new A(new _(2,-2,0),d.TERRAIN_PASTURE,[4]),new A(new _(3,-3,0),d.TERRAIN_PASTURE,[6]),new A(new _(1,-2,1),d.TERRAIN_FOREST,[8]),new A(new _(2,-3,1),d.TERRAIN_FIELDS,[2]),new A(new _(3,-4,1),d.TERRAIN_HILLS,[5])],i=[new A(new _(-3,6,-3),d.TERRAIN_GOLD,[10])],n=[new A(new _(-3,-1,4),d.TERRAIN_GOLD,[4])],a=[new A(new _(1,5,-6),d.TERRAIN_FOG,[]),new A(new _(-1,6,-5),d.TERRAIN_FOG,[]),new A(new _(0,5,-5),d.TERRAIN_FOG,[]),new A(new _(-2,6,-4),d.TERRAIN_FOG,[]),new A(new _(-1,5,-4),d.TERRAIN_FOG,[]),new A(new _(-2,5,-3),d.TERRAIN_FOG,[]),new A(new _(-1,4,-3),d.TERRAIN_FOG,[]),new A(new _(-3,5,-2),d.TERRAIN_FOG,[]),new A(new _(-2,4,-2),d.TERRAIN_FOG,[]),new A(new _(-3,4,-1),d.TERRAIN_FOG,[]),new A(new _(-2,3,-1),d.TERRAIN_FOG,[]),new A(new _(-3,3,0),d.TERRAIN_FOG,[]),new A(new _(-2,2,0),d.TERRAIN_FOG,[]),new A(new _(-3,2,1),d.TERRAIN_FOG,[]),new A(new _(-2,1,1),d.TERRAIN_FOG,[]),new A(new _(-3,1,2),d.TERRAIN_FOG,[]),new A(new _(-2,0,2),d.TERRAIN_FOG,[]),new A(new _(-1,-1,2),d.TERRAIN_FOG,[]),new A(new _(-3,0,3),d.TERRAIN_FOG,[]),new A(new _(-2,-1,3),d.TERRAIN_FOG,[]),new A(new _(-1,-2,3),d.TERRAIN_FOG,[]),new A(new _(0,-3,3),d.TERRAIN_FOG,[]),new A(new _(1,-4,3),d.TERRAIN_FOG,[]),new A(new _(-2,-2,4),d.TERRAIN_FOG,[]),new A(new _(-1,-3,4),d.TERRAIN_FOG,[])],u=[...this.shuffleTerrainsInRegion(t,o),...i,...n,...a],l=this.createFixedPorts([{hex:new _(2,4,-6),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(4,2,-6),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(4,0,-4),dir:C.WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(4,-3,-1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(4,-4,0),dir:C.WEST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(2,-4,2),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(0,3,-3),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,2,-1),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(0,-1,1),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED}]),T=(u.find(g=>g.isDesert)??u.find(g=>g.numbers.includes(12)))?.location??new _(3,-1,-2),R=new _(5,-5,0),O=lr(u).withPorts(l).withRobber(T).withPirate(R).build(),I=t.shuffle([...Array(3).fill(d.TERRAIN_FOREST),...Array(2).fill(d.TERRAIN_HILLS),...Array(3).fill(d.TERRAIN_PASTURE),...Array(2).fill(d.TERRAIN_FIELDS),...Array(2).fill(d.TERRAIN_MOUNTAINS),...Array(1).fill(d.TERRAIN_GOLD),...Array(12).fill(d.TERRAIN_SEA)]),D=t.shuffle([...Array(2).fill(2),...Array(1).fill(3),...Array(1).fill(4),...Array(2).fill(5),...Array(1).fill(6),...Array(1).fill(8),...Array(2).fill(9),...Array(1).fill(10),...Array(1).fill(11),...Array(1).fill(12)]);return{board:O,fogTerrainBank:I,fogNumberBank:D}}static createLakeFisheries(r){let t=[];for(let o of r){let i=o.location,n=i.getVertex("N"),a=i.getVertex("S");for(let s of o.numbers)t.push(new Ar(i,n,s)),t.push(new Ar(i,a,s))}return t}static placeIslandFisheries(r,t,o,i,n){let a=0,s=0,u=0;for(let Y of n)a+=Y.location.x,s+=Y.location.y,u+=Y.location.z;a/=n.length,s/=n.length,u/=n.length;let l=new Set;for(let Y of i)l.add(Y.hex.toString());let c=new Set,f=[],T=E(Y=>(Y.x-a)**2+(Y.y-s)**2+(Y.z-u)**2,"distSq"),R=E(Y=>!o.has(Y.toString()),"isOcean"),O=E(Y=>{let V=Y.toString();if(!R(Y)||c.has(V)||l.has(V))return!1;for(let w of Y.getAllNeighbors())if(l.has(w.toString()))return!1;return!0},"isValidOceanHex"),I=E(Y=>{for(let V of Y.getAllNeighbors())if(c.has(V.toString()))return!0;return!1},"hasAdjacentFishery"),D=E(Y=>Y.getHexCenters().filter(w=>O(w)).sort((w,J)=>T(J)-T(w))[0],"findOceanHexForVertex"),g=r.shuffle([4,5,6,8,9,10]),k=0,v=E(()=>{let Y=g[k%g.length];return k++,Y},"nextNumber");for(let Y of t)if(Y.length===1){let w=Y[0].location.getAllVerticies();w.sort((J,$)=>T($)-T(J));for(let J of w){let $=D(J);if($){let he=new Ar($,J,v());f.push(he),c.add($.toString());break}}}else{let V=new Set(Y.map(w=>w.location.toString()));for(let w of Y){let J=w.location;if(I(J))continue;let he=J.getAllNeighbors().find(Ye=>V.has(Ye.toString())&&!I(Ye));if(!he)continue;let De=J.getAllVerticies(),ve=he.getAllVerticies(),Be=De.filter(Ye=>ve.some(Or=>Or.equals(Ye)));if(Be.length!==0){Be.sort((Ye,Or)=>T(Or)-T(Ye));for(let Ye of Be){let Or=D(Ye);if(Or){let Fe=new Ar(Or,Ye,v());f.push(Fe),c.add(Or.toString());break}}}}}return f}static createFishShoals3Player(r){let t=new Re(r),o=[new A(new _(-1,2,-1),d.TERRAIN_FIELDS,[4]),new A(new _(0,1,-1),d.TERRAIN_PASTURE,[2]),new A(new _(1,0,-1),d.TERRAIN_HILLS,[8]),new A(new _(-2,2,0),d.TERRAIN_PASTURE,[6]),new A(new _(-1,1,0),d.TERRAIN_MOUNTAINS,[5]),new A(new _(1,-1,0),d.TERRAIN_FIELDS,[11]),new A(new _(-2,1,1),d.TERRAIN_FOREST,[10]),new A(new _(-1,0,1),d.TERRAIN_PASTURE,[9]),new A(new _(0,-1,1),d.TERRAIN_MOUNTAINS,[3]),new A(new _(1,-2,1),d.TERRAIN_FIELDS,[6]),new A(new _(-2,0,2),d.TERRAIN_FOREST,[8]),new A(new _(-1,-1,2),d.TERRAIN_HILLS,[11]),new A(new _(0,-2,2),d.TERRAIN_FOREST,[5])],i=[new A(new _(0,0,0),d.TERRAIN_LAKE_A,[2,3,11,12])],n=[new A(new _(-4,3,1),d.TERRAIN_PASTURE,[4]),new A(new _(-5,3,2),d.TERRAIN_MOUNTAINS,[9]),new A(new _(-4,2,2),d.TERRAIN_FIELDS,[3]),new A(new _(-4,1,3),d.TERRAIN_GOLD,[4])],a=[new A(new _(-3,-1,4),d.TERRAIN_MOUNTAINS,[8]),new A(new _(-2,-2,4),d.TERRAIN_HILLS,[10])],s=[new A(new _(-2,4,-2),d.TERRAIN_HILLS,[12]),new A(new _(-3,4,-1),d.TERRAIN_GOLD,[5])],u=this.shuffleTerrainsInRegion(t,o),l=this.shuffleTerrainsInRegion(t,n),c=this.shuffleTerrainsInRegion(t,a),f=this.shuffleTerrainsInRegion(t,s),T=[...u,...i,...l,...c,...f],R=this.createFixedPorts([{hex:new _(-1,-2,3),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,1,2),dir:C.NORTH_EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-3,2,1),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,-3,2),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(0,2,-2),dir:C.WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(1,1,-2),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(2,-1,-1),dir:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(2,-2,0),dir:C.WEST,rate:2,resource:S.RESOURCE_BRICK}]),O=new Set(T.map(w=>w.location.toString())),I=this.placeIslandFisheries(t,[n,a,s],O,R,o),D=this.createLakeFisheries(i),g=[...I,...D],v=(u.find(w=>w.numbers.includes(2))||u.find(w=>w.numbers.includes(11)))?.location??new _(0,1,-1),Y=new _(1,-3,2);return{board:lr(T).withPorts(R).withRobber(v).withPirate(Y).withFisheries(g).build(),smallIslandHexes:[n.map(w=>w.location),a.map(w=>w.location),s.map(w=>w.location)]}}static createFishShoals4Player(r){let t=new Re(r),o=[new A(new _(0,2,-2),d.TERRAIN_PASTURE,[5]),new A(new _(1,1,-2),d.TERRAIN_FIELDS,[12]),new A(new _(2,0,-2),d.TERRAIN_HILLS,[6]),new A(new _(-1,2,-1),d.TERRAIN_FOREST,[6]),new A(new _(0,1,-1),d.TERRAIN_HILLS,[11]),new A(new _(1,0,-1),d.TERRAIN_FOREST,[10]),new A(new _(2,-1,-1),d.TERRAIN_MOUNTAINS,[3]),new A(new _(-2,2,0),d.TERRAIN_MOUNTAINS,[4]),new A(new _(0,0,0),d.TERRAIN_FIELDS,[10]),new A(new _(2,-2,0),d.TERRAIN_FIELDS,[8]),new A(new _(-2,1,1),d.TERRAIN_PASTURE,[9]),new A(new _(-1,0,1),d.TERRAIN_FIELDS,[11]),new A(new _(0,-1,1),d.TERRAIN_HILLS,[9]),new A(new _(1,-2,1),d.TERRAIN_FOREST,[2]),new A(new _(-2,0,2),d.TERRAIN_FOREST,[5]),new A(new _(-1,-1,2),d.TERRAIN_PASTURE,[8]),new A(new _(0,-2,2),d.TERRAIN_MOUNTAINS,[10])],i=[new A(new _(-1,1,0),d.TERRAIN_LAKE_A,[2,3,11,12]),new A(new _(1,-1,0),d.TERRAIN_LAKE_B,[4,10])],n=[new A(new _(-4,4,0),d.TERRAIN_GOLD,[4]),new A(new _(-4,3,1),d.TERRAIN_HILLS,[5]),new A(new _(-5,3,2),d.TERRAIN_MOUNTAINS,[2]),new A(new _(-4,2,2),d.TERRAIN_FOREST,[9]),new A(new _(-4,1,3),d.TERRAIN_GOLD,[10])],a=[new A(new _(-3,-1,4),d.TERRAIN_HILLS,[3]),new A(new _(-2,-2,4),d.TERRAIN_FIELDS,[6])],s=[new A(new _(-1,4,-3),d.TERRAIN_MOUNTAINS,[8]),new A(new _(-2,4,-2),d.TERRAIN_PASTURE,[11])],u=this.shuffleTerrainsInRegion(t,o),l=this.shuffleTerrainsInRegion(t,n),c=this.shuffleTerrainsInRegion(t,a),f=this.shuffleTerrainsInRegion(t,s),T=[...u,...i,...l,...c,...f],R=this.createFixedPorts([{hex:new _(-1,-2,3),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,0,3),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,2,1),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-2,3,-1),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(0,3,-3),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(2,1,-3),dir:C.WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(3,-1,-2),dir:C.WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(3,-3,0),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(1,-3,2),dir:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_WOOD}]),O=new Set(T.map(w=>w.location.toString())),I=this.placeIslandFisheries(t,[n,a,s],O,R,o),D=this.createLakeFisheries(i),g=[...I,...D],v=(u.find(w=>w.numbers.includes(12))||u.find(w=>w.numbers.includes(2)))?.location??new _(0,0,0),Y=new _(4,-4,0);return{board:lr(T).withPorts(R).withRobber(v).withPirate(Y).withFisheries(g).build(),smallIslandHexes:[n.map(w=>w.location),a.map(w=>w.location),s.map(w=>w.location)]}}static createFishShoals6Player(r){let t=new Re(r),o=[new A(new _(-1,4,-3),d.TERRAIN_FOREST,[10]),new A(new _(0,3,-3),d.TERRAIN_MOUNTAINS,[6]),new A(new _(1,2,-3),d.TERRAIN_PASTURE,[3]),new A(new _(2,1,-3),d.TERRAIN_FOREST,[8]),new A(new _(-2,4,-2),d.TERRAIN_FIELDS,[11]),new A(new _(-1,3,-2),d.TERRAIN_PASTURE,[9]),new A(new _(0,2,-2),d.TERRAIN_FIELDS,[9]),new A(new _(1,1,-2),d.TERRAIN_HILLS,[5]),new A(new _(2,0,-2),d.TERRAIN_FIELDS,[4]),new A(new _(-3,4,-1),d.TERRAIN_MOUNTAINS,[11]),new A(new _(-2,3,-1),d.TERRAIN_PASTURE,[4]),new A(new _(0,1,-1),d.TERRAIN_HILLS,[6]),new A(new _(1,0,-1),d.TERRAIN_FOREST,[9]),new A(new _(2,-1,-1),d.TERRAIN_PASTURE,[8]),new A(new _(-3,3,0),d.TERRAIN_HILLS,[8]),new A(new _(-2,2,0),d.TERRAIN_MOUNTAINS,[5]),new A(new _(-1,1,0),d.TERRAIN_MOUNTAINS,[3]),new A(new _(1,-1,0),d.TERRAIN_HILLS,[10]),new A(new _(2,-2,0),d.TERRAIN_FIELDS,[2]),new A(new _(-3,2,1),d.TERRAIN_PASTURE,[9]),new A(new _(-1,0,1),d.TERRAIN_FOREST,[12]),new A(new _(0,-1,1),d.TERRAIN_MOUNTAINS,[11]),new A(new _(1,-2,1),d.TERRAIN_PASTURE,[5]),new A(new _(-3,1,2),d.TERRAIN_FIELDS,[3]),new A(new _(-2,0,2),d.TERRAIN_FIELDS,[10]),new A(new _(-1,-1,2),d.TERRAIN_HILLS,[6]),new A(new _(0,-2,2),d.TERRAIN_FOREST,[4])],i=[new A(new _(-1,2,-1),d.TERRAIN_LAKE_A,[2,3,11,12]),new A(new _(0,0,0),d.TERRAIN_LAKE_B,[4,10]),new A(new _(-2,1,1),d.TERRAIN_LAKE_A,[2,3,11,12])],n=[new A(new _(-5,4,1),d.TERRAIN_GOLD,[5]),new A(new _(-5,3,2),d.TERRAIN_FOREST,[2]),new A(new _(-5,2,3),d.TERRAIN_HILLS,[4])],a=[new A(new _(-4,0,4),d.TERRAIN_PASTURE,[8]),new A(new _(-3,-1,4),d.TERRAIN_MOUNTAINS,[11]),new A(new _(-2,-2,4),d.TERRAIN_GOLD,[9])],s=[new A(new _(1,4,-5),d.TERRAIN_GOLD,[10])],u=[new A(new _(3,2,-5),d.TERRAIN_FIELDS,[3])],l=[new A(new _(4,0,-4),d.TERRAIN_HILLS,[12])],c=[new A(new _(4,-2,-2),d.TERRAIN_MOUNTAINS,[6])],f=this.shuffleTerrainsInRegion(t,o),T=this.shuffleTerrainsInRegion(t,n),R=this.shuffleTerrainsInRegion(t,a),O=[...f,...i,...T,...R,...s,...u,...l,...c],I=this.createFixedPorts([{hex:new _(-3,5,-2),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,5,-4),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(-4,2,2),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-4,4,0),dir:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,3,-4),dir:C.WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(2,2,-4),dir:C.NORTH_WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-1,-2,3),dir:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,0,3),dir:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(3,0,-3),dir:C.WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(3,-2,-1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(2,-3,1),dir:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WOOD}]),D=new Set(O.map($=>$.location.toString())),g=this.placeIslandFisheries(t,[n,a,s,u,l,c],D,I,o),k=this.createLakeFisheries(i),v=[...g,...k],V=(f.find($=>$.numbers.includes(12))||f.find($=>$.numbers.includes(2)))?.location??new _(0,1,-1),w=new _(0,-4,4);return{board:lr(O).withPorts(I).withRobber(V).withPirate(w).withFisheries(v).build(),smallIslandHexes:[n.map($=>$.location),a.map($=>$.location),s.map($=>$.location),u.map($=>$.location),l.map($=>$.location),c.map($=>$.location)]}}};var Ja=class{static{E(this,"CaravansScenarios")}static createCaravans4Player(r){let t=new Re(r),o=this.getSpiralHexLocations(),i=[d.TERRAIN_MOUNTAINS,d.TERRAIN_PASTURE,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_FIELDS,d.TERRAIN_FOREST,d.TERRAIN_MOUNTAINS,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FOREST,d.TERRAIN_MOUNTAINS,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_WATERING_HOLE],n=t.shuffle(i.slice(0,12)),a=t.shuffle(i.slice(12,18)),s=[...n,...a,d.TERRAIN_WATERING_HOLE],u=[5,2,6,3,8,10,9,12,11,4,8,10,9,4,5,6,3,11],l=[],c=0;for(let O=0;O<o.length;O++){let I=s[O],D=o[O];if(I===d.TERRAIN_WATERING_HOLE)l.push(new A(D,I,[]));else{let g=u[c];c++,l.push(new A(D,I,[g]))}}let f=this.createStandard4PlayerPorts(t),T=[];return{board:new ge(l,f,T)}}static createCaravans6Player(r){let t=new Re(r),o=this.get6PlayerHexLocations(),i=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS],n=this.findValidWateringHolePositions(o,2,t),a=[5,2,6,3,8,10,9,12,11,4,8,10,9,4,5,6,3,11,3,4,6,5,9,10,8,11,12,2],s=t.shuffle([...i]),u=this.buildTilesWithConstraints(t,o,n,s,a),l=this.createStandard6PlayerPorts(o,t),c=[];return{board:new ge(u,l,c)}}static createCaravans8Player(r){let t=new Re(r),o=this.get8PlayerHexLocations(),i=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_GOLD],n=this.findValidWateringHolePositions(o,3,t),a=[5,2,6,3,8,10,9,12,11,4,8,10,9,4,5,6,3,11,3,4,6,5,9,10,8,11,12,2,5,9,2,3,4,5,6,8,9,10,11,12,3,4],s=t.shuffle([...i]),u=this.buildTilesWithConstraints(t,o,n,s,a),l=this.createStandard8PlayerPorts(o,t),c=[];return{board:new ge(u,l,c)}}static buildTilesWithConstraints(r,t,o,i,n,a=1e4){let s=E(u=>o.some(l=>l.equals(u)),"isWateringHole");for(let u=0;u<a;u++){let l=r.shuffle([...n]),c=[],f=0,T=0;for(let R of t)s(R)?c.push(new A(R,d.TERRAIN_WATERING_HOLE,[])):(c.push(new A(R,i[T],[l[f]])),T++,f++);if(this.validateNumberAdjacency(c))return c}throw new Error(`CaravansScenarios.buildTilesWithConstraints: no valid placement after ${a} attempts`)}static validateNumberAdjacency(r){let t=new Map;for(let o of r)o.numbers.length>0&&t.set(o.location.toString(),o.numbers[0]);for(let o of r){if(o.numbers.length===0)continue;let i=o.numbers[0];for(let n of o.location.getAllNeighbors()){let a=t.get(n.toString());if(a!==void 0&&(i===2&&a===12||i===12&&a===2||(i===6||i===8)&&(a===6||a===8)))return!1}}return!0}static findValidWateringHolePositions(r,t,o){let i=new Set(r.map(u=>u.toString())),n=r.filter(u=>u.getAllNeighbors().every(c=>i.has(c.toString()))),a=o.shuffle([...n]),s=[];for(let u of a){if(s.length>=t)break;s.some(c=>c.getAllNeighbors().some(T=>T.equals(u)))||s.push(u)}for(;s.length<t&&a.length>s.length;){let u=a.filter(l=>!s.some(c=>c.equals(l)));if(u.length>0)s.push(u[0]);else break}return s}static getSpiralHexLocations(){return[new _(2,-2,0),new _(2,-1,-1),new _(2,0,-2),new _(1,1,-2),new _(0,2,-2),new _(-1,2,-1),new _(-2,2,0),new _(-2,1,1),new _(-2,0,2),new _(-1,-1,2),new _(0,-2,2),new _(1,-2,1),new _(1,-1,0),new _(1,0,-1),new _(0,1,-1),new _(-1,1,0),new _(-1,0,1),new _(0,-1,1),new _(0,0,0)]}static get6PlayerHexLocations(){let r=this.getStandardHexLocations(),t=[new _(3,-3,0),new _(2,-3,1),new _(3,-2,-1),new _(1,-3,2),new _(0,-3,3),new _(-1,-2,3),new _(-2,-1,3),new _(-3,0,3),new _(-3,1,2),new _(-3,2,1),new _(-3,3,0)];return[...r,...t]}static get8PlayerHexLocations(){let r=this.get6PlayerHexLocations(),t=[new _(4,-4,0),new _(3,-4,1),new _(2,-4,2),new _(4,-3,-1),new _(1,-4,3),new _(0,-4,4),new _(-1,-3,4),new _(-2,-2,4),new _(-3,-1,4),new _(-4,0,4),new _(-4,1,3),new _(-4,2,2),new _(-4,3,1),new _(-4,4,0),new _(4,-2,-2)];return[...r,...t]}static getStandardHexLocations(){return[new _(0,0,0),new _(1,-1,0),new _(0,-1,1),new _(-1,0,1),new _(-1,1,0),new _(0,1,-1),new _(1,0,-1),new _(2,-2,0),new _(1,-2,1),new _(0,-2,2),new _(-1,-1,2),new _(-2,0,2),new _(-2,1,1),new _(-2,2,0),new _(-1,2,-1),new _(0,2,-2),new _(1,1,-2),new _(2,0,-2),new _(2,-1,-1)]}static createStandard4PlayerPorts(r){let t=r.shuffle([{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}]),o=[{hex:new _(2,-3,1),direction:C.SOUTH_WEST},{hex:new _(3,-2,-1),direction:C.SOUTH_WEST},{hex:new _(3,0,-3),direction:C.WEST},{hex:new _(1,2,-3),direction:C.NORTH_WEST},{hex:new _(-1,3,-2),direction:C.NORTH_WEST},{hex:new _(-3,3,0),direction:C.NORTH_EAST},{hex:new _(0,-3,3),direction:C.SOUTH_EAST},{hex:new _(-3,1,2),direction:C.EAST},{hex:new _(-2,-1,3),direction:C.EAST}],i=[];for(let n=0;n<o.length;n++){let a=o[n],s=t[n],u=a.hex.getEdgeInDirection(a.direction);i.push(new me(s.rate,s.resource,a.hex,u))}return i}static createStandard6PlayerPorts(r,t){let o=new Set(r.map(u=>u.toString())),i=t.shuffle([{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT}]),n=r.slice(19,30),a=[],s=0;for(let u=0;u<n.length&&s<i.length;u++){let l=n[u],c=i[s],f=l.getAllEdges();for(let T of f){let R=T.getAdjacentCenters();if(R.filter(I=>o.has(I.toString())).length===1){let I=R.find(D=>!o.has(D.toString()));if(I){a.push(new me(c.rate,c.resource,I,T)),s++;break}}}}return a}static createStandard8PlayerPorts(r,t){let o=new Set(r.map(u=>u.toString())),i=t.shuffle([{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}]),n=r.slice(30,45),a=[],s=0;for(let u=0;u<n.length&&s<i.length;u++){let l=n[u],c=i[s],f=l.getAllEdges();for(let T of f){let R=T.getAdjacentCenters();if(R.filter(I=>o.has(I.toString())).length===1){let I=R.find(D=>!o.has(D.toString()));if(I){a.push(new me(c.rate,c.resource,I,T)),s++;break}}}}return a}};function hD(e){switch(e){case Vr.NUMBER_LAYOUT_SPIRAL:return"spiral";case Vr.NUMBER_LAYOUT_RANDOM_STRICT:return"random_strict";case Vr.NUMBER_LAYOUT_RANDOM_RELAXED:return"random_relaxed";case Vr.NUMBER_LAYOUT_UNSPECIFIED:return"spiral";case Vr.UNRECOGNIZED:default:return console.warn(`Unrecognized NumberLayout value: ${e}, defaulting to spiral`),"spiral"}}E(hD,"toNumberLayoutMode");function DD(e){switch(e){case ct.PORT_LAYOUT_MODE_RANDOM:return"random";case ct.PORT_LAYOUT_MODE_FIXED_6TH_EDITION:return"fixed_6th_edition";case ct.PORT_LAYOUT_MODE_UNSPECIFIED:return"random";case ct.UNRECOGNIZED:default:return console.warn(`Unrecognized PortLayoutMode value: ${e}, defaulting to random`),"random"}}E(DD,"toPortLayout");function mD(e){switch(e){case ft.DESERT_PLACEMENT_RANDOM:return"random";case ft.DESERT_PLACEMENT_CENTER:return"center";case ft.DESERT_PLACEMENT_MIDDLE:return"middle";case ft.DESERT_PLACEMENT_SHORE:return"shore";case ft.DESERT_PLACEMENT_UNSPECIFIED:return"random";case ft.UNRECOGNIZED:default:return console.warn(`Unrecognized DesertPlacement value: ${e}, defaulting to random`),"random"}}E(mD,"toDesertLocation");function nN(e){return{numberLayout:hD(e.numberLayout),portLayout:DD(e.portLayout),desertLocation:mD(e.desertPlacement),resourceAdjacency:e.resourceAdjacencyTarget>0?{enabled:!0,targetEdges:e.resourceAdjacencyTarget}:void 0,resourceAbundance:e.resourceAbundance?{enabled:!0,terrains:e.resourceAbundance}:void 0,resourcesOnPorts:e.portMatchingTarget>0?{enabled:!0,targetCount:e.portMatchingTarget}:void 0}}E(nN,"toCustomBoardOptions");var Mt=class e{static{E(this,"BoardFactory")}static createVariable4PlayerBoard(r,t){let o=new Re(r),i=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT],n=o.shuffle(i),a=o.nextInt(0,6),s=this.getSpiralHexLocationsFromCorner(a),u=[5,2,6,3,8,10,9,12,11,4,8,10,9,4,5,6,3,11],l=[],c=0;for(let O=0;O<s.length;O++){let I=n[O],D=s[O];if(I===d.TERRAIN_DESERT)l.push(new A(D,I,[]));else{let g=u[c];c++,l.push(new A(D,I,[g]))}}let f;if(t?.fixedPorts)f=this.createFixed4PlayerPorts();else{let O=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],I=o.shuffle(O);f=this.createPortsWithShuffledResources(I)}let T=l.find(O=>O.isDesert)?.location,R=T?[T]:[];return new ge(l,f,R)}static createVariable3PlayerBoard(r){let t=new Re(r),o=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT],i=t.shuffle(o),n=this.get3PlayerHexLocations(),a=[5,6,3,8,10,9,11,4,8,9,5,6],s=[2,12],u=this.assignNumbers3PWithConstraints(t,n,i,a,s,500),l=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],c=t.shuffle(l),f=this.create3PlayerPorts(c),T=u.find(O=>O.isDesert)?.location,R=T?[T]:[];return new ge(u,f,R)}static get3PlayerHexLocations(){return[new _(0,0,0),new _(1,-1,0),new _(1,0,-1),new _(0,1,-1),new _(-1,1,0),new _(-1,0,1),new _(0,-1,1),new _(1,-2,1),new _(0,-2,2),new _(-1,-1,2),new _(-2,0,2),new _(-2,1,1),new _(-2,2,0),new _(-1,2,-1)]}static create3PlayerPorts(r){let t=[{hex:new _(0,-3,3),direction:C.SOUTH_EAST},{hex:new _(-2,-1,3),direction:C.EAST},{hex:new _(-3,1,2),direction:C.EAST},{hex:new _(-3,3,0),direction:C.NORTH_EAST},{hex:new _(-1,3,-2),direction:C.NORTH_WEST},{hex:new _(2,-3,1),direction:C.SOUTH_WEST},{hex:new _(2,-1,-1),direction:C.WEST},{hex:new _(1,1,-2),direction:C.WEST}],o=[];for(let i=0;i<t.length;i++){let n=t[i],a=r[i],s=n.hex.getEdgeInDirection(n.direction);o.push(new me(a.rate,a.resource,n.hex,s))}return o}static createVariable2PlayerBoard(r){let t=new Re(r),o=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS],i=t.shuffle(o),n=this.get2PlayerHexLocations(),a=[2,3,4,5,6,8,9,10,11,12],s=this.assignNumbersWithConstraints(t,n,i,a,500),u=new _(2,-3,1);s.push(new A(u,d.TERRAIN_DESERT,[]));let l=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],c=t.shuffle(l),f=this.create2PlayerPorts(c),T=[u];return new ge(s,f,T)}static get2PlayerHexLocations(){return[new _(0,-1,1),new _(1,-1,0),new _(2,-1,-1),new _(-1,0,1),new _(0,0,0),new _(1,0,-1),new _(2,0,-2),new _(-1,1,0),new _(0,1,-1),new _(1,1,-2)]}static create2PlayerPorts(r){let t=[{hex:new _(-1,-1,2),direction:C.SOUTH_EAST},{hex:new _(-2,1,1),direction:C.EAST},{hex:new _(-1,2,-1),direction:C.NORTH_EAST},{hex:new _(1,-2,1),direction:C.SOUTH_EAST},{hex:new _(3,-2,-1),direction:C.SOUTH_WEST},{hex:new _(1,2,-3),direction:C.NORTH_WEST},{hex:new _(3,0,-3),direction:C.WEST}],o=[];for(let i=0;i<t.length;i++){let n=t[i],a=r[i],s=n.hex.getEdgeInDirection(n.direction);o.push(new me(a.rate,a.resource,n.hex,s))}return o}static createFishPonds3PlayerBoard(r){let t=new Re(r),o=[new _(0,-1,1),new _(-1,1,0)],i=new Set(o.map(w=>w.toString())),a=this.get3PlayerHexLocations().filter(w=>!i.has(w.toString())),s=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS],u=t.shuffle(s),l=[5,6,3,8,10,9,11,4,8,9,5,6],c=this.assignNumbersWithStrictConstraints(t,a,u,l,500),f=[new A(o[0],d.TERRAIN_LAKE_A,[2,3,11,12]),new A(o[1],d.TERRAIN_LAKE_B,[4,10])],T=[...c,...f],R=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],O=t.shuffle(R),I=this.create3PlayerPorts(O),D=t.shuffle([5,6,8,9]),g=this.create3PlayerFisheries(D),k=this.createLakeFisheries(f),v=[...g,...k],Y=c.find(w=>w.numbers.includes(11)),V=Y?[Y.location]:[];return new ge(T,I,V,void 0,[],[],[],[],[],void 0,void 0,v)}static create3PlayerFisheries(r){return[{hex:new _(-1,-2,3),vertex:"SE"},{hex:new _(-3,2,1),vertex:"NE"},{hex:new _(0,2,-2),vertex:"N"},{hex:new _(2,-2,0),vertex:"SW"}].map((o,i)=>{let n=o.hex.getVertex(o.vertex);return new Ar(o.hex,n,r[i])})}static createFishPonds2PlayerBoard(r){let t=new Re(r),o=[new _(0,-1,1),new _(-1,1,0)],i=new Set(o.map($=>$.toString())),a=this.get2PlayerHexLocations().filter($=>!i.has($.toString())),s=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS],u=t.shuffle(s),l=[3,4,5,6,8,9,10,11],c=t.shuffle(l),f=[];for(let $=0;$<a.length;$++)f.push(new A(a[$],u[$],[c[$]]));let T=[new A(o[0],d.TERRAIN_LAKE_A,[2,3,11,12]),new A(o[1],d.TERRAIN_LAKE_B,[4,10])],R=new _(2,-3,1),O=new A(R,d.TERRAIN_DESERT,[]),I=[...f,...T,O],D=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],g=t.shuffle(D),k=this.create2PlayerPorts(g),v=t.shuffle([5,6,8,9]),Y=this.create2PlayerFisheries(v),V=this.createLakeFisheries(T),w=[...Y,...V],J=[R];return new ge(I,k,J,void 0,[],[],[],[],[],void 0,void 0,w)}static create2PlayerFisheries(r){return[{hex:new _(-2,0,2),vertex:"SE"},{hex:new _(-2,2,0),vertex:"NE"},{hex:new _(0,2,-2),vertex:"N"},{hex:new _(2,-2,0),vertex:"SW"}].map((o,i)=>{let n=o.hex.getVertex(o.vertex);return new Ar(o.hex,n,r[i])})}static createVariable6PlayerBoard(r){let t=new Re(r),o=this.get6PlayerHexLocations(),i=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT,d.TERRAIN_DESERT],n=t.shuffle(i),a=[5,2,6,3,8,10,9,12,11,4,8,10,9,4,5,6,3,11,3,4,6,5,9,10,8,11,12,2],s=t.nextInt(0,6),u=o.slice(0,19),l=o.slice(19,30),c=Math.floor(s*l.length/6),f=[...l.slice(c),...l.slice(0,c)],T=[...u,...f],R=this.assignNumbersWithConstraints(t,T,n,a,1e3),O=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT}],I=t.shuffle(O),D=o.slice(19,30),g=this.createShuffled6PlayerPorts(D,I,o),k=R.filter(Y=>Y.isDesert).map(Y=>Y.location),v=k.length>0?[k[0]]:[];return new ge(R,g,v)}static createVariable8PlayerBoard(r){let t=new Re(r),o=this.get8PlayerHexLocations(),i=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT,d.TERRAIN_DESERT],n=t.shuffle(i),a=[2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,12,12],s=this.assignNumbersWithConstraints(t,o,n,a,1e4),u=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE},{rate:2,resource:S.RESOURCE_SHEEP}],l=t.shuffle(u),c=o.slice(19,37),f=this.createShuffled8PlayerPorts(c,l,o),T=s.find(O=>O.isDesert),R=T?[T.location]:[];return new ge(s,f,R)}static createBoardFromMapType(r,t,o){if(o?.isCustomized()){let i=nN(o);switch(r){case B.MAP_TYPE_BASE_4P:return e.createCustom4PlayerBoard(t,i);case B.MAP_TYPE_BASE_RANDOM_4P:return e.createCustom4PlayerBoard(t,i);default:console.warn(`Board generation customization not supported for map type ${r}, using default generation`);break}}switch(r){case B.MAP_TYPE_BASE_4P:return e.createVariable4PlayerBoard(t);case B.MAP_TYPE_BASE_3P:return e.createVariable3PlayerBoard(t);case B.MAP_TYPE_BASE_2P:return e.createVariable2PlayerBoard(t);case B.MAP_TYPE_BASE_6P:return e.createVariable6PlayerBoard(t);case B.MAP_TYPE_BASE_8P:return e.createVariable8PlayerBoard(t);case B.MAP_TYPE_BASE_RANDOM_4P:return e.createFullyRandomized4PlayerBoard(t);case B.MAP_TYPE_SEAFARERS_FORGOTTEN_TRIBE:return ur.createForgottenTribe(t).board;case B.MAP_TYPE_SF_NEW_SHORES_3P:return ur.createHeadingForNewShores3Player(t).board;case B.MAP_TYPE_SF_NEW_SHORES_4P:return ur.createHeadingForNewShores4Player(t).board;case B.MAP_TYPE_SF_NEW_SHORES_6P:return ur.createHeadingForNewShores6Player(t).board;case B.MAP_TYPE_SF_FOUR_ISLANDS_3P:return ur.createFourIslands3Player(t).board;case B.MAP_TYPE_SF_FOUR_ISLANDS_4P:return ur.createFourIslands4Player(t).board;case B.MAP_TYPE_SF_FOUR_ISLANDS_RANDOM:return ur.createFourIslandsRandom(t).board;case B.MAP_TYPE_SF_FOG_ISLANDS_3P:return ur.createFogIslands3Player(t).board;case B.MAP_TYPE_SF_FOG_ISLANDS_4P:return ur.createFogIslands4Player(t).board;case B.MAP_TYPE_SF_THROUGH_DESERT_3P:return ur.createThroughTheDesert3Player(t).board;case B.MAP_TYPE_SF_THROUGH_DESERT_4P:return ur.createThroughTheDesert4Player(t).board;case B.MAP_TYPE_SF_NEW_WORLD_3P:return ur.createNewWorld3Player(t).board;case B.MAP_TYPE_SF_NEW_WORLD_4P:return ur.createNewWorld4Player(t).board;case B.MAP_TYPE_FISH_PONDS:return e.createFishPondsBoard(t);case B.MAP_TYPE_FISH_PONDS_2P:return e.createFishPonds2PlayerBoard(t);case B.MAP_TYPE_FISH_PONDS_3P:return e.createFishPonds3PlayerBoard(t);case B.MAP_TYPE_FISH_PONDS_6P:return e.createFishPonds6PlayerBoard(t);case B.MAP_TYPE_FISH_PONDS_8P:return e.createFishPonds8PlayerBoard(t);case B.MAP_TYPE_FISH_SHOALS_3P:return ur.createFishShoals3Player(t).board;case B.MAP_TYPE_FISH_SHOALS_4P:return ur.createFishShoals4Player(t).board;case B.MAP_TYPE_FISH_SHOALS_6P:return ur.createFishShoals6Player(t).board;case B.MAP_TYPE_FOG_BANK_2P:return Cr.createFogBank2Player(t).board;case B.MAP_TYPE_FOG_BANK_3P:return Cr.createFogBank3Player(t).board;case B.MAP_TYPE_FOG_BANK_4P:return Cr.createFogBank4Player(t).board;case B.MAP_TYPE_FOG_BANK_6P:return Cr.createFogBank6Player(t).board;case B.MAP_TYPE_FOG_BANK_8P:return Cr.createFogBank8Player(t).board;case B.MAP_TYPE_MISTY_REALMS_2P:return Cr.createMistyRealms2Player(t).board;case B.MAP_TYPE_MISTY_REALMS_3P:return Cr.createMistyRealms3Player(t).board;case B.MAP_TYPE_MISTY_REALMS_4P:return Cr.createMistyRealms4Player(t).board;case B.MAP_TYPE_MISTY_REALMS_6P:return Cr.createMistyRealms6Player(t).board;case B.MAP_TYPE_MISTY_REALMS_8P:return Cr.createMistyRealms8Player(t).board;case B.MAP_TYPE_RIVER_4P:return e.createRiver4PlayerBoard(t);case B.MAP_TYPE_RIVER_6P:return e.createRiver6PlayerBoard(t);case B.MAP_TYPE_RIVER_8P:return e.createRiver8PlayerBoard(t);case B.MAP_TYPE_CARAVANS_3P:return e.createVariable3PlayerBoard(t);case B.MAP_TYPE_CARAVANS_4P:return Ja.createCaravans4Player(t).board;case B.MAP_TYPE_CARAVANS_6P:return Ja.createCaravans6Player(t).board;case B.MAP_TYPE_CARAVANS_8P:return Ja.createCaravans8Player(t).board;case B.MAP_TYPE_DUST_BOWL_3P:return e.createVariable3PlayerBoard(t);case B.MAP_TYPE_DUST_BOWL_4P:return e.createVariable4PlayerBoard(t);case B.MAP_TYPE_DUST_BOWL_6P:return e.createVariable6PlayerBoard(t);case B.MAP_TYPE_DUST_BOWL_8P:return e.createVariable8PlayerBoard(t);case B.MAP_TYPE_SF_SIX_ISLANDS_6P:return ur.createSixIslands6Player(t).board;case B.MAP_TYPE_SNOW_MAN:return Cr.createSnowMan(t).board;case B.MAP_TYPE_TROLL_BRIDGE_2P:return e.createVariable2PlayerBoard(t);case B.MAP_TYPE_TROLL_BRIDGE_3P:return e.createVariable3PlayerBoard(t);case B.MAP_TYPE_TROLL_BRIDGE_4P:return e.createVariable4PlayerBoard(t);case B.MAP_TYPE_TROLL_BRIDGE_6P:return e.createVariable6PlayerBoard(t);case B.MAP_TYPE_TROLL_BRIDGE_8P:return e.createVariable8PlayerBoard(t);case B.MAP_TYPE_UNSPECIFIED:default:throw new Error(`Cannot create board from map type: ${r}. Custom maps must be loaded separately.`)}}static getBoardGenerationLimits(r){switch(r){case B.MAP_TYPE_BASE_4P:case B.MAP_TYPE_BASE_RANDOM_4P:return{supportsCustomization:!0,supportsDesertPlacement:!0,desertCount:1,resourcePortCount:5,maxResourceAdjacencyEdges:20,supportedNumberLayouts:[Vr.NUMBER_LAYOUT_SPIRAL,Vr.NUMBER_LAYOUT_RANDOM_STRICT,Vr.NUMBER_LAYOUT_RANDOM_RELAXED],supportedPortLayouts:[ct.PORT_LAYOUT_MODE_RANDOM,ct.PORT_LAYOUT_MODE_FIXED_6TH_EDITION]};case B.MAP_TYPE_BASE_3P:return{supportsCustomization:!1,supportsDesertPlacement:!1,desertCount:1,resourcePortCount:5,maxResourceAdjacencyEdges:18,supportedNumberLayouts:[],supportedPortLayouts:[]};case B.MAP_TYPE_BASE_6P:return{supportsCustomization:!1,supportsDesertPlacement:!1,desertCount:2,resourcePortCount:5,maxResourceAdjacencyEdges:30,supportedNumberLayouts:[],supportedPortLayouts:[]};case B.MAP_TYPE_BASE_8P:return{supportsCustomization:!1,supportsDesertPlacement:!1,desertCount:2,resourcePortCount:6,maxResourceAdjacencyEdges:45,supportedNumberLayouts:[],supportedPortLayouts:[]};default:return{supportsCustomization:!1,supportsDesertPlacement:!1,desertCount:0,resourcePortCount:0,maxResourceAdjacencyEdges:0,supportedNumberLayouts:[],supportedPortLayouts:[]}}}static getFogBanksForMapType(r,t){switch(r){case B.MAP_TYPE_SF_FOG_ISLANDS_3P:{let o=ur.createFogIslands3Player(t);return{fogTerrainBank:o.fogTerrainBank,fogNumberBank:o.fogNumberBank}}case B.MAP_TYPE_SF_FOG_ISLANDS_4P:{let o=ur.createFogIslands4Player(t);return{fogTerrainBank:o.fogTerrainBank,fogNumberBank:o.fogNumberBank}}case B.MAP_TYPE_SNOW_MAN:{let o=Cr.createSnowMan(t);return{fogTerrainBank:o.fogTerrainBank,fogNumberBank:o.fogNumberBank}}default:return}}static applyFogTransformation(r,t){if(t===Gr.FOG_MODE_OFF||t===Gr.FOG_MODE_UNSPECIFIED)return r;let o=r.getTiles().map(i=>t===Gr.FOG_MODE_FOG_START?new A(i.location,d.TERRAIN_FOG,[]):t===Gr.FOG_MODE_MIST_START?i.isDesert?i:new A(i.location,d.TERRAIN_FOG,i.numbers):i);return new ge(o,r.ports,r.robbers,r.pirate)}static createFullyRandomized4PlayerBoard(r){let t=new Re(r),o=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT],i=t.shuffle(o),n=this.getSpiralHexLocations(),a=[5,2,6,3,8,10,9,12,11,4,8,10,9,4,5,6,3,11],s=this.assignNumbersWithStrictConstraints(t,n,i,a,500),u=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],l=t.shuffle(u),c=this.createPortsWithShuffledResources(l),f=s.find(R=>R.isDesert)?.location,T=f?[f]:[];return new ge(s,c,T)}static createCustom4PlayerBoard(r,t){let o=new Re(r),i=this.getSpiralHexLocations(),n=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS],a;if(t.portLayout==="fixed_6th_edition")a=this.create6thEditionPorts();else{let k=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],v=o.shuffle(k);a=this.createPortsWithShuffledResources(v)}let s=o.shuffle([...n]);t.resourcesOnPorts?.enabled&&(s=this.optimizeTerrainsForPorts(o,i,s,a,t.resourcesOnPorts.targetCount,t.resourcesOnPorts.maxAttempts??1e3));let u;if(t.desertLocation==="center")u=18;else if(t.desertLocation==="middle"){let k=[12,13,14,15,16,17];u=k[o.nextInt(0,k.length)]}else if(t.desertLocation==="shore"){let k=[0,1,2,3,4,5,6,7,8,9,10,11];u=k[o.nextInt(0,k.length)]}else u=o.nextInt(0,19);let l=[],c=0;for(let k=0;k<19;k++)k===u?l.push(d.TERRAIN_DESERT):(l.push(s[c]),c++);let f=l;if(t.resourceAdjacency?.enabled){let k=t.resourcesOnPorts?.enabled?this.getPortAdjacentIndices(i,a):new Set;f=this.optimizeResourceAdjacencyWithConstraints(o,i,l,u,k,t.resourceAdjacency.targetEdges,t.resourceAdjacency.maxAttempts??1e3)}let T=[5,2,6,3,8,10,9,12,11,4,8,10,9,4,5,6,3,11],R=t.numberLayout==="spiral"?this.getSpiralHexLocationsFromCorner(o.nextInt(0,6)):i,O=f;if(t.numberLayout==="spiral"){let k=new Map;for(let v=0;v<i.length;v++)k.set(i[v].toString(),f[v]);O=R.map(v=>k.get(v.toString()))}let I;switch(t.numberLayout){case"spiral":I=this.assignNumbersInOrder(R,O,T);break;case"random_strict":I=this.assignNumbersWithStrictConstraints(o,R,O,T,500);break;case"random_relaxed":I=this.assignNumbersWithConstraints(o,R,O,T,100);break;default:I=this.assignNumbersInOrder(R,O,T)}if(t.resourceAbundance?.enabled){let k=t.resourcesOnPorts?.enabled?this.getTileIndicesAdjacentToPorts(I,a):new Set;I=this.optimizeResourceAbundance(o,I,t.resourceAbundance.terrains,k,t.resourceAbundance.maxAttempts??1e3)}let D=I.find(k=>k.isDesert)?.location,g=D?[D]:[];return new ge(I,a,g)}static assignNumbersInOrder(r,t,o){let i=[],n=0;for(let a=0;a<r.length;a++){let s=t[a],u=r[a];if(s===d.TERRAIN_DESERT)i.push(new A(u,s,[]));else{let l=o[n];n++,i.push(new A(u,s,[l]))}}return i}static optimizeResourceAdjacency(r,t,o,i){let n=[...t],a=this.getSpiralHexLocations(),s=E(l=>{let c=new Map;for(let R=0;R<a.length;R++)c.set(a[R].toString(),l[R]);let f=new Set,T=0;for(let R=0;R<a.length;R++){let O=l[R];if(O===d.TERRAIN_DESERT)continue;let I=a[R].getAllNeighbors();for(let D of I){let g=c.get(D.toString());if(!g||g===d.TERRAIN_DESERT||g!==O)continue;let k=a[R].toString(),v=D.toString(),Y=k<v?`${k}-${v}`:`${v}-${k}`;f.has(Y)||(f.add(Y),T++)}}return T},"countEdges"),u=s(n);for(let l=0;l<i&&u!==o;l++){let c=r.nextInt(0,n.length),f=r.nextInt(0,n.length);for(;f===c;)f=r.nextInt(0,n.length);if(n[c]===n[f])continue;[n[c],n[f]]=[n[f],n[c]];let T=s(n),R=Math.abs(u-o);Math.abs(T-o)<=R?u=T:[n[c],n[f]]=[n[f],n[c]]}return n}static create6thEditionPorts(){return[{hex:new _(2,-3,1),direction:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(3,-2,-1),direction:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(3,0,-3),direction:C.WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(1,2,-3),direction:C.NORTH_WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(-1,3,-2),direction:C.NORTH_WEST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(-3,3,0),direction:C.NORTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,1,2),direction:C.EAST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(-2,-1,3),direction:C.EAST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(0,-3,3),direction:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED}].map(t=>{let o=t.hex.getEdgeInDirection(t.direction);return new me(t.rate,t.resource,t.hex,o)})}static optimizeResourcesOnPorts(r,t,o,i,n){let a=E(f=>{let T=0;for(let R of f){if(R.isGeneric)continue;let O=R.edge.getAdjacentCenters(),I=this.resourceToTerrain(R.resource);if(I){for(let D of O)if(t.getTiles().find(k=>k.location.equals(D))?.terrain===I){T++;break}}}return T},"countMatchingPorts"),s=[];for(let f=0;f<o.length;f++)o[f].isGeneric||s.push(f);if(s.length<2)return o;let u=o.map(f=>({rate:f.rate,resource:f.resource})),l=o.map(f=>({hex:f.hex,edge:f.edge})),c=a(o);for(let f=0;f<n&&c!==i;f++){let T=r.nextInt(0,s.length),R=r.nextInt(0,s.length);for(;R===T;)R=r.nextInt(0,s.length);let O=s[T],I=s[R];if(u[O].resource===u[I].resource)continue;[u[O],u[I]]=[u[I],u[O]];let D=u.map((Y,V)=>new me(Y.rate,Y.resource,l[V].hex,l[V].edge)),g=a(D),k=Math.abs(c-i);Math.abs(g-i)<=k?c=g:[u[O],u[I]]=[u[I],u[O]]}return u.map((f,T)=>new me(f.rate,f.resource,l[T].hex,l[T].edge))}static resourceToTerrain(r){switch(r){case S.RESOURCE_WOOD:return d.TERRAIN_FOREST;case S.RESOURCE_BRICK:return d.TERRAIN_HILLS;case S.RESOURCE_SHEEP:return d.TERRAIN_PASTURE;case S.RESOURCE_WHEAT:return d.TERRAIN_FIELDS;case S.RESOURCE_ORE:return d.TERRAIN_MOUNTAINS;default:return}}static optimizeTerrainsForPorts(r,t,o,i,n,a){let s=[...o],u=E(c=>{let f=new Map;for(let R=0;R<t.length;R++)f.set(t[R].toString(),c[R]);let T=0;for(let R of i){if(R.isGeneric)continue;let O=R.edge.getAdjacentCenters(),I=this.resourceToTerrain(R.resource);if(!I)continue;let D=!1;for(let g of O)if(f.get(g.toString())===I){D=!0;break}D&&T++}return T},"countMatchingPorts"),l=u(s);for(let c=0;c<a&&l!==n;c++){let f=r.nextInt(0,s.length),T=r.nextInt(0,s.length);for(;T===f;)T=r.nextInt(0,s.length);if(s[f]===s[T])continue;[s[f],s[T]]=[s[T],s[f]];let R=u(s),O=Math.abs(l-n);Math.abs(R-n)<=O?l=R:[s[f],s[T]]=[s[T],s[f]]}return s}static getPortAdjacentIndices(r,t){let o=new Set,i=new Map;for(let n=0;n<r.length;n++)i.set(r[n].toString(),n);for(let n of t){if(n.isGeneric)continue;let a=n.edge.getAdjacentCenters();for(let s of a){let u=i.get(s.toString());u!==void 0&&o.add(u)}}return o}static optimizeResourceAdjacencyWithConstraints(r,t,o,i,n,a,s){let u=[...o],l=[];for(let T=0;T<u.length;T++)T!==i&&!n.has(T)&&l.push(T);if(l.length<2)return u;let c=E(T=>{let R=new Map;for(let D=0;D<t.length;D++)R.set(t[D].toString(),T[D]);let O=new Set,I=0;for(let D=0;D<t.length;D++){let g=T[D];if(g===d.TERRAIN_DESERT)continue;let k=t[D].getAllNeighbors();for(let v of k){let Y=R.get(v.toString());if(!Y||Y===d.TERRAIN_DESERT||Y!==g)continue;let V=t[D].toString(),w=v.toString(),J=V<w?`${V}-${w}`:`${w}-${V}`;O.has(J)||(O.add(J),I++)}}return I},"countEdges"),f=c(u);for(let T=0;T<s&&f!==a;T++){let R=r.nextInt(0,l.length),O=r.nextInt(0,l.length);for(;O===R;)O=r.nextInt(0,l.length);let I=l[R],D=l[O];if(u[I]===u[D])continue;[u[I],u[D]]=[u[D],u[I]];let g=c(u),k=Math.abs(f-a);Math.abs(g-a)<=k?f=g:[u[I],u[D]]=[u[D],u[I]]}return u}static getTileIndicesAdjacentToPorts(r,t){let o=new Set;for(let i of t){if(i.isGeneric)continue;let n=i.edge.getAdjacentCenters();for(let a=0;a<r.length;a++)n.some(s=>r[a].location.equals(s))&&o.add(a)}return o}static scoreAbundanceTerrain(r,t,o){let i=0;for(let n=0;n<r.length;n++){let a=o.get(r[n]);if(!a||a==="normal")continue;let s=t[n];s!==0&&(a==="abundant"?s===6||s===8?i+=3:s===5||s===9?i+=1:s===3||s===11?i-=1:(s===2||s===12)&&(i-=3):s===2||s===12?i+=3:s===3||s===11?i+=1:s===5||s===9?i-=1:(s===6||s===8)&&(i-=3))}return i}static optimizeResourceAbundance(r,t,o,i,n){let a=!1;for(let f of o.values())if(f!=="normal"){a=!0;break}if(!a)return t;let s=t.map(f=>f.terrain),u=t.map(f=>f.numbers[0]??0),l=[];for(let f=0;f<t.length;f++)!t[f].isDesert&&!i.has(f)&&l.push(f);if(l.length<2)return t;let c=this.scoreAbundanceTerrain(s,u,o);for(let f=0;f<n;f++){let T=r.nextInt(0,l.length),R=r.nextInt(0,l.length);for(;R===T;)R=r.nextInt(0,l.length);let O=l[T],I=l[R];if(s[O]===s[I])continue;[s[O],s[I]]=[s[I],s[O]];let D=this.scoreAbundanceTerrain(s,u,o);D>c?c=D:[s[O],s[I]]=[s[I],s[O]]}return t.map((f,T)=>new A(f.location,s[T],[...f.numbers]))}static createFishPondsBoard(r){let t=new Re(r),o=this.getSpiralHexLocations(),i=new _(0,0,0),n=t.next()<.5?[i.add(C.EAST),i.add(C.NORTH_WEST),i.add(C.SOUTH_WEST)]:[i.add(C.WEST),i.add(C.NORTH_EAST),i.add(C.SOUTH_EAST)],a=new Set(n.map(w=>w.toString())),s=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS],u=t.shuffle(s),l=[5,6,3,10,8,9,11,8,4,10,6,9,5,4,3,11],c=o.filter(w=>!a.has(w.toString())),f=this.assignNumbersWithStrictConstraints(t,c,u,l,500),T=n.map((w,J)=>J%2===0?new A(w,d.TERRAIN_LAKE_A,[2,3,11,12]):new A(w,d.TERRAIN_LAKE_B,[4,10])),R=[...f,...T],O=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],I=t.shuffle(O),D=this.createPortsWithShuffledResources(I),g=this.createStandard4PlayerFisheries(t),k=this.createLakeFisheries(T),v=[...g,...k],Y=f.find(w=>w.numbers.includes(11)),V=Y?[Y.location]:[];return new ge(R,D,V,void 0,[],[],[],[],[],void 0,void 0,v)}static createStandard4PlayerFisheries(r){let t=[{hex:new _(1,-3,2),vertex:"S"},{hex:new _(-1,-2,3),vertex:"SE"},{hex:new _(3,-1,-2),vertex:"SW"},{hex:new _(2,1,-3),vertex:"NW"},{hex:new _(-2,3,-1),vertex:"N"},{hex:new _(-3,2,1),vertex:"NE"}],o=r.shuffle([4,5,6,8,9,10]);return t.map((i,n)=>{let a=i.hex.getVertex(i.vertex);return new Ar(i.hex,a,o[n])})}static createFishPonds6PlayerBoard(r){let t=new Re(r),o=this.get6PlayerHexLocations(),i=t.next()<.5?"east":"west",n=_.ORIGIN,a=i==="east"?[n.add(C.WEST),n.add(C.NORTH_WEST),n.add(C.NORTH_EAST).add(C.NORTH_WEST),n.add(C.NORTH_EAST).add(C.NORTH_EAST),n.add(C.EAST).add(C.NORTH_EAST),n.add(C.EAST).add(C.EAST),n.add(C.EAST).add(C.SOUTH_EAST),n.add(C.SOUTH_EAST).add(C.SOUTH_EAST),n.add(C.SOUTH_EAST).add(C.SOUTH_WEST),n.add(C.SOUTH_WEST)]:[n.add(C.EAST),n.add(C.SOUTH_EAST),n.add(C.SOUTH_WEST).add(C.SOUTH_EAST),n.add(C.SOUTH_WEST).add(C.SOUTH_WEST),n.add(C.WEST).add(C.SOUTH_WEST),n.add(C.WEST).add(C.WEST),n.add(C.WEST).add(C.NORTH_WEST),n.add(C.NORTH_WEST).add(C.NORTH_WEST),n.add(C.NORTH_WEST).add(C.NORTH_EAST),n.add(C.NORTH_EAST)],s=t.next()<.5?0:1,u=[];for(let J=0;J<10;J++)(J+s)%2===0&&u.push(a[J]);let l=new Set(u.map(J=>J.toString())),c=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS],f=t.shuffle(c),T=[2,3,3,4,4,5,5,5,6,6,8,8,9,9,9,10,10,10,11,11,11,12,12,4,3],R=o.filter(J=>!l.has(J.toString())),O=this.assignNumbersWithStrictConstraints(t,R,f,T,500),I=u.map((J,$)=>$%2===0?new A(J,d.TERRAIN_LAKE_A,[2,3,11,12]):new A(J,d.TERRAIN_LAKE_B,[4,10])),D=[...O,...I],g=this.createStandard6PlayerPorts(),k=this.createStandard6PlayerFisheries(t),v=this.createLakeFisheries(I),Y=[...k,...v],V=O.find(J=>J.numbers.length>0&&J.numbers[0]===12),w=V?[V.location]:[];return new ge(D,g,w,void 0,[],[],[],[],[],void 0,void 0,Y)}static createStandard6PlayerFisheries(r){let t=[{hex:new _(2,-4,2),vertex:"S"},{hex:new _(0,-3,3),vertex:"SE"},{hex:new _(-2,-1,3),vertex:"SE"},{hex:new _(-3,1,2),vertex:"NE"},{hex:new _(-3,3,0),vertex:"NE"},{hex:new _(-2,4,-2),vertex:"N"},{hex:new _(2,2,-4),vertex:"NW"},{hex:new _(4,-2,-2),vertex:"SW"}],o=r.shuffle([4,5,5,6,8,9,9,10]);return t.map((i,n)=>{let a=i.hex.getVertex(i.vertex);return new Ar(i.hex,a,o[n])})}static createFishPonds8PlayerBoard(r){let t=new Re(r),o=this.get8PlayerHexLocations(),i=_.ORIGIN,n=[new _(2,-2,0),new _(2,0,-2),new _(0,2,-2),new _(-2,2,0),new _(-2,0,2),new _(0,-2,2)],a=t.next()<.5?0:1,s=[],u=a===0?[1,4]:[2,5];for(let $=0;$<6;$++)u.includes($)||s.push(n[$]);let l=[i,...s],c=new Set(l.map($=>$.toString())),f=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS],T=t.shuffle(f),R=[2,2,3,3,3,4,4,4,5,5,5,6,6,6,8,8,8,9,9,9,10,10,10,11,11,11,12,12,4,5,9,10],O=o.filter($=>!c.has($.toString())),I=this.assignNumbersWithConstraints(t,O,T,R,1e3),D=l.map(($,he)=>he%2===0?new A($,d.TERRAIN_LAKE_A,[2,3,11,12]):new A($,d.TERRAIN_LAKE_B,[4,10])),g=[...I,...D],k=this.createStandard8PlayerPorts(),v=this.createStandard8PlayerFisheries(t),Y=this.createLakeFisheries(D),V=[...v,...Y],w=I.find($=>$.numbers.length>0&&$.numbers[0]===12),J=w?[w.location]:[];return new ge(g,k,J,void 0,[],[],[],[],[],void 0,void 0,V)}static createStandard8PlayerFisheries(r){let t=[{hex:new _(2,-4,2),vertex:"S"},{hex:new _(-2,-2,4),vertex:"SE"},{hex:new _(-4,0,4),vertex:"SE"},{hex:new _(-4,2,2),vertex:"NE"},{hex:new _(-2,4,-2),vertex:"N"},{hex:new _(2,2,-4),vertex:"NW"},{hex:new _(4,0,-4),vertex:"NW"},{hex:new _(4,-2,-2),vertex:"SW"}],o=r.shuffle([4,5,5,6,8,9,9,10]);return t.map((i,n)=>{let a=i.hex.getVertex(i.vertex);return new Ar(i.hex,a,o[n])})}static createLakeFisheries(r){let t=[];for(let o of r){let i=o.location,n=i.getVertex("N"),a=i.getVertex("S");for(let s of o.numbers)t.push(new Ar(i,n,s)),t.push(new Ar(i,a,s))}return t}static assignRiverNumbersWithConstraints(r,t,o,i,n=1e4){for(let a=0;a<n;a++){let s=r.shuffle([...o]),u=r.nextInt(0,t.length),l=[],c=0;for(let f=0;f<t.length;f++){let{location:T,terrain:R,isRiver:O}=t[f];f===u?l.push(new A(T,R,i,O)):(l.push(new A(T,R,[s[c]],O)),c++)}if(this.validateNumberPlacement(l))return l}throw new Error(`assignRiverNumbersWithConstraints: no valid placement after ${n} attempts`)}static createRiver4PlayerBoard(r){let t=new Re(r),o=this.getSpiralHexLocations(),n=(t.next()<.5?"east":"west")==="east"?[new _(1,0,-1),new _(0,1,-1),new _(1,1,-2),new _(0,2,-2),new _(-1,1,0),new _(-1,2,-1)]:[new _(-1,0,1),new _(0,-1,1),new _(-1,-1,2),new _(0,-2,2),new _(1,-1,0),new _(1,-2,1)],a=new Set([n[0].toString(),n[1].toString()]),s=new Set(n.map(v=>v.toString())),u=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS],l=t.shuffle(u),c=[5,6,3,8,10,9,11,8,4,10,6,9,5,4,3,11],f=[2,12],T=o.filter(v=>!a.has(v.toString())),R=[];for(let v=0;v<T.length;v++){let Y=T[v],V=s.has(Y.toString());R.push({location:Y,terrain:l[v],isRiver:V})}let O=this.assignRiverNumbersWithConstraints(t,R,c,f);for(let v of[n[0],n[1]])O.push(new A(v,d.TERRAIN_SWAMP,[],!0));let I=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WOOD},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_SHEEP},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE}],D=t.shuffle(I),g=this.createPortsWithShuffledResources(D),k=[n[0]];return new ge(O,g,k)}static createRiver6PlayerBoard(r){let t=new Re(r),o=this.get6PlayerHexLocations(),n=(t.next()<.5?"east":"west")==="east"?[new _(1,0,-1),new _(0,1,-1),new _(-1,1,0),new _(1,1,-2),new _(0,2,-2),new _(-1,2,-1),new _(-2,2,0),new _(-2,1,1)]:[new _(-1,0,1),new _(0,-1,1),new _(1,-1,0),new _(-1,-1,2),new _(0,-2,2),new _(1,-2,1),new _(2,-2,0),new _(2,-1,-1)],a=new Set([n[0].toString(),n[1].toString(),n[2].toString()]),s=new Set(n.map(g=>g.toString())),u=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_GOLD],l=t.shuffle(u),c=[3,3,4,4,4,5,5,5,6,6,6,8,8,8,9,9,9,10,10,10,11,11,11,3,4,5],f=[2,12],T=o.filter(g=>!a.has(g.toString())),R=[];for(let g=0;g<T.length;g++){let k=T[g],v=s.has(k.toString());R.push({location:k,terrain:l[g],isRiver:v})}let O=this.assignRiverNumbersWithConstraints(t,R,c,f);for(let g=0;g<3;g++)O.push(new A(n[g],d.TERRAIN_SWAMP,[],!0));let I=this.createStandard6PlayerPorts(),D=[n[0]];return new ge(O,I,D)}static createRiver8PlayerBoard(r){let t=new Re(r),o=this.get8PlayerHexLocations(),n=(t.next()<.5?"east":"west")==="east"?[new _(1,0,-1),new _(0,1,-1),new _(-1,1,0),new _(-1,2,-1),new _(1,1,-2),new _(0,2,-2),new _(-2,2,0),new _(-2,1,1),new _(2,0,-2),new _(2,-1,-1)]:[new _(-1,0,1),new _(0,-1,1),new _(1,-1,0),new _(1,-2,1),new _(-1,-1,2),new _(0,-2,2),new _(2,-2,0),new _(2,-1,-1),new _(-2,0,2),new _(-2,-1,3)],a=new Set([n[0].toString(),n[1].toString(),n[2].toString(),n[3].toString()]),s=new Set(n.map(g=>g.toString())),u=[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS],l=t.shuffle(u),c=[2,3,3,3,4,4,4,5,5,5,6,6,6,8,8,8,9,9,9,10,10,10,11,11,11,3,4,5,9,10,11,12],f=[2,12],T=o.filter(g=>!a.has(g.toString())),R=[];for(let g=0;g<T.length;g++){let k=T[g],v=s.has(k.toString());R.push({location:k,terrain:l[g],isRiver:v})}let O=this.assignRiverNumbersWithConstraints(t,R,c,f);for(let g=0;g<4;g++)O.push(new A(n[g],d.TERRAIN_SWAMP,[],!0));let I=this.createStandard8PlayerPorts(),D=[n[0]];return new ge(O,I,D)}static validateStrictNumberPlacement(r){let t=new Map;for(let o of r)o.numbers.length>0&&t.set(o.location.toString(),o.numbers[0]);for(let o of r){if(o.numbers.length===0)continue;let i=o.numbers[0],n=o.location.getAllNeighbors();for(let a of n){let s=t.get(a.toString());if(s!==void 0&&(i===s||i===2&&s===12||i===12&&s===2||(i===6||i===8)&&(s===6||s===8)))return!1}}return!0}static assignNumbersWithStrictConstraints(r,t,o,i,n=500){for(let u=0;u<n;u++){let l=r.shuffle([...i]),c=[],f=0;for(let T=0;T<t.length;T++){let R=o[T],O=t[T];if(R===d.TERRAIN_DESERT)c.push(new A(O,R,[]));else{let I=l[f];f++,c.push(new A(O,R,[I]))}}if(this.validateStrictNumberPlacement(c))return c}let a=[],s=0;for(let u=0;u<t.length;u++){let l=o[u],c=t[u];if(l===d.TERRAIN_DESERT)a.push(new A(c,l,[]));else{let f=i[s];s++,a.push(new A(c,l,[f]))}}return a}static validateNumberPlacement(r){let t=new Map;for(let o of r)o.numbers.length>0&&t.set(o.location.toString(),o.numbers);for(let o of r){if(o.numbers.length===0)continue;let i=o.location.getAllNeighbors();for(let n of i){let a=t.get(n.toString());if(a){for(let s of o.numbers)for(let u of a)if(s===2&&u===12||s===12&&u===2||(s===6||s===8)&&(u===6||u===8))return!1}}}return!0}static assignNumbers3PWithConstraints(r,t,o,i,n,a=500){let s=[];for(let u=0;u<o.length;u++)o[u]!==d.TERRAIN_DESERT&&s.push(u);for(let u=0;u<a;u++){let l=s[r.nextInt(0,s.length)],c=r.shuffle([...i]),f=[],T=0;for(let R=0;R<t.length;R++){let O=o[R],I=t[R];O===d.TERRAIN_DESERT?f.push(new A(I,O,[])):R===l?f.push(new A(I,O,n)):(f.push(new A(I,O,[c[T]])),T++)}if(this.validateNumberPlacement(f))return f}throw new Error(`assignNumbers3PWithConstraints: no valid placement after ${a} attempts`)}static assignNumbersWithConstraints(r,t,o,i,n=100){for(let a=0;a<n;a++){let s=r.shuffle([...i]),u=[],l=0;for(let c=0;c<t.length;c++){let f=o[c],T=t[c];if(f===d.TERRAIN_DESERT)u.push(new A(T,f,[]));else{let R=s[l];l++,u.push(new A(T,f,[R]))}}if(this.validateNumberPlacement(u))return u}throw new Error(`assignNumbersWithConstraints: no valid placement after ${n} attempts (${t.length} locations, ${i.length} numbers)`)}static createSimpleTestBoard(){let r=[new A(new _(0,0,0),d.TERRAIN_FOREST,[6]),new A(new _(1,-1,0),d.TERRAIN_HILLS,[8]),new A(new _(-1,1,0),d.TERRAIN_PASTURE,[5]),new A(new _(0,-1,1),d.TERRAIN_FIELDS,[9]),new A(new _(1,0,-1),d.TERRAIN_MOUNTAINS,[10]),new A(new _(-1,0,1),d.TERRAIN_FIELDS,[4]),new A(new _(0,1,-1),d.TERRAIN_DESERT,[])];return new ge(r,[],[r[6].location])}static getSpiralHexLocations(){return[new _(2,-2,0),new _(2,-1,-1),new _(2,0,-2),new _(1,1,-2),new _(0,2,-2),new _(-1,2,-1),new _(-2,2,0),new _(-2,1,1),new _(-2,0,2),new _(-1,-1,2),new _(0,-2,2),new _(1,-2,1),new _(1,-1,0),new _(1,0,-1),new _(0,1,-1),new _(-1,1,0),new _(-1,0,1),new _(0,-1,1),new _(0,0,0)]}static getSpiralHexLocationsFromCorner(r){let t=[[new _(2,-2,0),new _(2,-1,-1)],[new _(2,0,-2),new _(1,1,-2)],[new _(0,2,-2),new _(-1,2,-1)],[new _(-2,2,0),new _(-2,1,1)],[new _(-2,0,2),new _(-1,-1,2)],[new _(0,-2,2),new _(1,-2,1)]],o=[new _(1,-1,0),new _(1,0,-1),new _(0,1,-1),new _(-1,1,0),new _(-1,0,1),new _(0,-1,1)],i=[],n=[];for(let a=0;a<6;a++){let s=(r+a)%6;i.push(...t[s]),n.push(o[s])}return[...i,...n,new _(0,0,0)]}static createPortsWithShuffledResources(r){let t=[{hex:new _(2,-3,1),direction:C.SOUTH_WEST},{hex:new _(3,-2,-1),direction:C.SOUTH_WEST},{hex:new _(3,0,-3),direction:C.WEST},{hex:new _(1,2,-3),direction:C.NORTH_WEST},{hex:new _(-1,3,-2),direction:C.NORTH_WEST},{hex:new _(-3,3,0),direction:C.NORTH_EAST},{hex:new _(0,-3,3),direction:C.SOUTH_EAST},{hex:new _(-3,1,2),direction:C.EAST},{hex:new _(-2,-1,3),direction:C.EAST}],o=[];for(let i=0;i<t.length;i++){let n=t[i],a=r[i],s=n.hex.getEdgeInDirection(n.direction);o.push(new me(a.rate,a.resource,n.hex,s))}return o}static createFixed4PlayerPorts(){let r=[{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_WHEAT},{rate:2,resource:S.RESOURCE_ORE},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_SHEEP},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:3,resource:S.RESOURCE_UNSPECIFIED},{rate:2,resource:S.RESOURCE_BRICK},{rate:2,resource:S.RESOURCE_WOOD}];return this.createPortsWithShuffledResources(r)}static createShuffledPorts(r,t,o){let i=new Set(o.map(s=>s.toString())),n=[],a=[0,1,3,4,6,7,9,10,11];for(let s=0;s<Math.min(t.length,a.length);s++){let u=a[s],l=r[u],c=t[s],f=l.getAllEdges(),T=null;for(let R of f){let I=R.getAdjacentCenters().filter(D=>i.has(D.toString())).length;if(I>=1&&I<=2&&(T=R,I===1))break}T&&n.push(new me(c.rate,c.resource,l,T))}return n}static getStandardHexLocations(){return[new _(0,0,0),new _(1,-1,0),new _(0,-1,1),new _(-1,0,1),new _(-1,1,0),new _(0,1,-1),new _(1,0,-1),new _(2,-2,0),new _(1,-2,1),new _(0,-2,2),new _(-1,-1,2),new _(-2,0,2),new _(-2,1,1),new _(-2,2,0),new _(-1,2,-1),new _(0,2,-2),new _(1,1,-2),new _(2,0,-2),new _(2,-1,-1)]}static get6PlayerHexLocations(){let r=this.getStandardHexLocations(),t=[new _(-2,3,-1),new _(-1,3,-2),new _(0,3,-3),new _(1,2,-3),new _(2,1,-3),new _(3,0,-3),new _(3,-1,-2),new _(3,-2,-1),new _(3,-3,0),new _(2,-3,1),new _(1,-3,2)];return[...r,...t]}static createStandard6PlayerPorts(){let r=[{hex:new _(-3,0,3),direction:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,-2,3),direction:C.EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(1,-4,3),direction:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(3,-4,1),direction:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(4,-3,-1),direction:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(4,-1,-3),direction:C.WEST,rate:2,resource:S.RESOURCE_WOOD},{hex:new _(3,1,-4),direction:C.WEST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(1,3,-4),direction:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,4,-3),direction:C.NORTH_WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(-3,4,-1),direction:C.NORTH_EAST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(-3,2,1),direction:C.EAST,rate:2,resource:S.RESOURCE_SHEEP}],t=[];for(let o of r){let i=o.hex.getEdgeInDirection(o.direction);t.push(new me(o.rate,o.resource,o.hex,i))}return t}static createShuffled6PlayerPorts(r,t,o){let i=[{hex:new _(-3,0,3),direction:C.EAST},{hex:new _(-1,-2,3),direction:C.EAST},{hex:new _(1,-4,3),direction:C.SOUTH_EAST},{hex:new _(3,-4,1),direction:C.SOUTH_WEST},{hex:new _(4,-3,-1),direction:C.SOUTH_WEST},{hex:new _(4,-1,-3),direction:C.WEST},{hex:new _(3,1,-4),direction:C.WEST},{hex:new _(1,3,-4),direction:C.NORTH_WEST},{hex:new _(-1,4,-3),direction:C.NORTH_WEST},{hex:new _(-3,4,-1),direction:C.NORTH_EAST},{hex:new _(-3,2,1),direction:C.EAST}],n=[];for(let a=0;a<Math.min(t.length,i.length);a++){let s=i[a],u=t[a],l=s.hex.getEdgeInDirection(s.direction);n.push(new me(u.rate,u.resource,s.hex,l))}return n}static get8PlayerHexLocations(){let r=this.getStandardHexLocations(),t=[new _(-3,3,0),new _(-2,3,-1),new _(-1,3,-2),new _(0,3,-3),new _(1,2,-3),new _(2,1,-3),new _(3,0,-3),new _(3,-1,-2),new _(3,-2,-1),new _(3,-3,0),new _(2,-3,1),new _(1,-3,2),new _(0,-3,3),new _(-1,-2,3),new _(-2,-1,3),new _(-3,0,3),new _(-3,1,2),new _(-3,2,1)];return[...r,...t]}static createStandard8PlayerPorts(){let r=[{hex:new _(1,-4,3),direction:C.SOUTH_EAST,rate:2,resource:S.RESOURCE_ORE},{hex:new _(3,-4,1),direction:C.SOUTH_WEST,rate:2,resource:S.RESOURCE_WHEAT},{hex:new _(4,-3,-1),direction:C.SOUTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(4,-1,-3),direction:C.WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(3,1,-4),direction:C.WEST,rate:2,resource:S.RESOURCE_BRICK},{hex:new _(1,3,-4),direction:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-1,4,-3),direction:C.NORTH_WEST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,4,-1),direction:C.NORTH_EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-1,-3,4),direction:C.SOUTH_EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-3,-1,4),direction:C.EAST,rate:2,resource:S.RESOURCE_SHEEP},{hex:new _(-4,1,3),direction:C.EAST,rate:3,resource:S.RESOURCE_UNSPECIFIED},{hex:new _(-4,3,1),direction:C.NORTH_EAST,rate:2,resource:S.RESOURCE_WOOD}],t=[];for(let o of r){let i=o.hex.getEdgeInDirection(o.direction);t.push(new me(o.rate,o.resource,o.hex,i))}return t}static createShuffled8PlayerPorts(r,t,o){let i=[{hex:new _(1,-4,3),direction:C.SOUTH_EAST},{hex:new _(3,-4,1),direction:C.SOUTH_WEST},{hex:new _(4,-3,-1),direction:C.SOUTH_WEST},{hex:new _(4,-1,-3),direction:C.WEST},{hex:new _(3,1,-4),direction:C.WEST},{hex:new _(1,3,-4),direction:C.NORTH_WEST},{hex:new _(-1,4,-3),direction:C.NORTH_WEST},{hex:new _(-3,4,-1),direction:C.NORTH_EAST},{hex:new _(-1,-3,4),direction:C.SOUTH_EAST},{hex:new _(-3,-1,4),direction:C.EAST},{hex:new _(-4,1,3),direction:C.EAST},{hex:new _(-4,3,1),direction:C.NORTH_EAST}],n=[];for(let a=0;a<Math.min(t.length,i.length);a++){let s=i[a],u=t[a],l=s.hex.getEdgeInDirection(s.direction);n.push(new me(u.rate,u.resource,s.hex,l))}return n}static createSeafarersTestBoard(){let r=[new A(new _(0,0,0),d.TERRAIN_FOREST,[6]),new A(new _(1,-1,0),d.TERRAIN_HILLS,[8]),new A(new _(-1,1,0),d.TERRAIN_PASTURE,[5]),new A(new _(0,-1,1),d.TERRAIN_FIELDS,[9]),new A(new _(1,0,-1),d.TERRAIN_MOUNTAINS,[10]),new A(new _(-1,0,1),d.TERRAIN_FIELDS,[4]),new A(new _(0,1,-1),d.TERRAIN_GOLD,[11]),new A(new _(3,-3,0),d.TERRAIN_FOREST,[3]),new A(new _(3,-2,-1),d.TERRAIN_DESERT,[])],t=r.find(n=>n.isDesert)?.location,o=t?[t]:[],i=new _(2,-2,0);return new ge(r,[],o,i)}};var Cr=class{static{E(this,"FogBankScenarios")}static createFogBank(r,t){let o=Mt.createBoardFromMapType(t,r),i=o.getTiles().map(a=>new A(a.location,d.TERRAIN_FOG,[]));return{board:new ge(i,o.ports,o.robbers,o.pirate),baseMapType:t}}static createMistyRealms(r,t){let o=Mt.createBoardFromMapType(t,r),i=o.getTiles().map(a=>a.isDesert?a:new A(a.location,d.TERRAIN_FOG,a.numbers));return{board:new ge(i,o.ports,o.robbers,o.pirate),baseMapType:t}}static createFogBank2Player(r){return this.createFogBank(r,B.MAP_TYPE_BASE_2P)}static createFogBank3Player(r){return this.createFogBank(r,B.MAP_TYPE_BASE_3P)}static createFogBank4Player(r){return this.createFogBank(r,B.MAP_TYPE_BASE_4P)}static createFogBank6Player(r){return this.createFogBank(r,B.MAP_TYPE_BASE_6P)}static createFogBank8Player(r){return this.createFogBank(r,B.MAP_TYPE_BASE_8P)}static createMistyRealms2Player(r){return this.createMistyRealms(r,B.MAP_TYPE_BASE_2P)}static createMistyRealms3Player(r){return this.createMistyRealms(r,B.MAP_TYPE_BASE_3P)}static createMistyRealms4Player(r){return this.createMistyRealms(r,B.MAP_TYPE_BASE_4P)}static createMistyRealms6Player(r){return this.createMistyRealms(r,B.MAP_TYPE_BASE_6P)}static createMistyRealms8Player(r){return this.createMistyRealms(r,B.MAP_TYPE_BASE_8P)}static getBaseMapType(r){switch(r){case B.MAP_TYPE_FOG_BANK_2P:case B.MAP_TYPE_MISTY_REALMS_2P:return B.MAP_TYPE_BASE_2P;case B.MAP_TYPE_FOG_BANK_3P:case B.MAP_TYPE_MISTY_REALMS_3P:return B.MAP_TYPE_BASE_3P;case B.MAP_TYPE_FOG_BANK_4P:case B.MAP_TYPE_MISTY_REALMS_4P:return B.MAP_TYPE_BASE_4P;case B.MAP_TYPE_FOG_BANK_6P:case B.MAP_TYPE_MISTY_REALMS_6P:return B.MAP_TYPE_BASE_6P;case B.MAP_TYPE_FOG_BANK_8P:case B.MAP_TYPE_MISTY_REALMS_8P:return B.MAP_TYPE_BASE_8P;default:return}}static isDeterministicFogMap(r){return r===B.MAP_TYPE_FOG_BANK_2P||r===B.MAP_TYPE_FOG_BANK_3P||r===B.MAP_TYPE_FOG_BANK_4P||r===B.MAP_TYPE_FOG_BANK_6P||r===B.MAP_TYPE_FOG_BANK_8P||r===B.MAP_TYPE_MISTY_REALMS_2P||r===B.MAP_TYPE_MISTY_REALMS_3P||r===B.MAP_TYPE_MISTY_REALMS_4P||r===B.MAP_TYPE_MISTY_REALMS_6P||r===B.MAP_TYPE_MISTY_REALMS_8P}static isFogBankMap(r){return r===B.MAP_TYPE_FOG_BANK_2P||r===B.MAP_TYPE_FOG_BANK_3P||r===B.MAP_TYPE_FOG_BANK_4P||r===B.MAP_TYPE_FOG_BANK_6P||r===B.MAP_TYPE_FOG_BANK_8P}static isMistyRealmsMap(r){return r===B.MAP_TYPE_MISTY_REALMS_2P||r===B.MAP_TYPE_MISTY_REALMS_3P||r===B.MAP_TYPE_MISTY_REALMS_4P||r===B.MAP_TYPE_MISTY_REALMS_6P||r===B.MAP_TYPE_MISTY_REALMS_8P}static discoverFogDeterministically(r,t,o){let i=this.getBaseMapType(t);if(i)return this.discoverFogFromBaseMap(r,i,o)}static discoverFogFromBaseMap(r,t,o){let n=Mt.createBoardFromMapType(t,o).getTile(r);return n?{terrain:n.terrain,number:n.numbers.length>0?n.numbers[0]:0}:{terrain:d.TERRAIN_SEA,number:0}}static createSnowMan(r){let t=new Re(r),i=[new _(0,0,0),new _(0,-1,1),new _(-1,0,1),new _(-1,1,0),new _(0,1,-1),new _(1,0,-1),new _(1,-1,0),new _(0,-2,2),new _(-1,-1,2),new _(-2,1,1),new _(-2,2,0),new _(-1,2,-1),new _(0,2,-2),new _(1,1,-2),new _(2,-1,-1),new _(2,-2,0),new _(1,-2,1),new _(-2,-1,3),new _(-3,2,1),new _(-3,3,0),new _(-2,3,-1),new _(-1,3,-2),new _(0,3,-3),new _(1,2,-3),new _(3,-1,-2),new _(2,-3,1),new _(1,-3,2),new _(-3,-1,4),new _(-3,4,-1),new _(-2,4,-2),new _(-1,4,-3),new _(4,-1,-3),new _(3,-4,1),new _(2,-4,2),new _(1,-4,3),new _(3,-5,2),new _(2,-5,3)].map(T=>new A(T,d.TERRAIN_FOG,[])),n=E((T,R,O,I)=>new me(T,R,O,O.getEdgeInDirection(I)),"createPort"),a=[n(2,S.RESOURCE_BRICK,new _(4,-6,2),C.SOUTH_WEST),n(3,S.RESOURCE_UNSPECIFIED,new _(-4,-1,5),C.EAST),n(2,S.RESOURCE_BRICK,new _(-3,5,-2),C.NORTH_WEST),n(2,S.RESOURCE_SHEEP,new _(5,-1,-4),C.WEST),n(2,S.RESOURCE_WOOD,new _(1,-5,4),C.SOUTH_EAST),n(2,S.RESOURCE_WHEAT,new _(-2,-2,4),C.SOUTH_EAST),n(3,S.RESOURCE_UNSPECIFIED,new _(-4,3,1),C.EAST),n(2,S.RESOURCE_ORE,new _(0,4,-4),C.NORTH_WEST),n(3,S.RESOURCE_UNSPECIFIED,new _(2,2,-4),C.WEST),n(2,S.RESOURCE_WHEAT,new _(4,-4,0),C.WEST),n(3,S.RESOURCE_UNSPECIFIED,new _(0,-3,3),C.SOUTH_EAST),n(2,S.RESOURCE_WOOD,new _(-3,1,2),C.EAST),n(2,S.RESOURCE_ORE,new _(3,-2,-1),C.SOUTH_WEST),n(2,S.RESOURCE_SHEEP,new _(2,0,-2),C.SOUTH_WEST)],s=new _(0,0,0),u=new _(-1,-2,3),l=new ge(i,a,[s],u),c=t.shuffle([d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_DESERT,d.TERRAIN_DESERT,d.TERRAIN_DESERT,d.TERRAIN_DESERT]),f=t.shuffle([2,2,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,12,12]);return{board:l,fogTerrainBank:c,fogNumberBank:f}}};function Rn(e){return e>=b.PROGRESS_CARD_ALCHEMIST&&e<=b.PROGRESS_CARD_SMITH?K.CITY_IMPROVEMENT_TRACK_SCIENCE:e>=b.PROGRESS_CARD_BISHOP&&e<=b.PROGRESS_CARD_WEDDING?K.CITY_IMPROVEMENT_TRACK_POLITICS:e>=b.PROGRESS_CARD_COMMERCIAL_HARBOR&&e<=b.PROGRESS_CARD_TRADE_MONOPOLY?K.CITY_IMPROVEMENT_TRACK_TRADE:K.CITY_IMPROVEMENT_TRACK_UNSPECIFIED}E(Rn,"getProgressCardTrack");function xr(e){return e===b.PROGRESS_CARD_PRINTER||e===b.PROGRESS_CARD_CONSTITUTION}E(xr,"isVictoryPointCard");var R_=18,iN=[{card:b.PROGRESS_CARD_ALCHEMIST,count:2},{card:b.PROGRESS_CARD_CRANE,count:2},{card:b.PROGRESS_CARD_ENGINEER,count:1},{card:b.PROGRESS_CARD_INVENTOR,count:2},{card:b.PROGRESS_CARD_IRRIGATION,count:2},{card:b.PROGRESS_CARD_MEDICINE,count:2},{card:b.PROGRESS_CARD_MINING,count:2},{card:b.PROGRESS_CARD_PRINTER,count:1},{card:b.PROGRESS_CARD_ROAD_BUILDING,count:2},{card:b.PROGRESS_CARD_SMITH,count:2}],oN=[{card:b.PROGRESS_CARD_BISHOP,count:2},{card:b.PROGRESS_CARD_CONSTITUTION,count:1},{card:b.PROGRESS_CARD_DESERTER,count:2},{card:b.PROGRESS_CARD_DIPLOMAT,count:2},{card:b.PROGRESS_CARD_INTRIGUE,count:2},{card:b.PROGRESS_CARD_SABOTEUR,count:2},{card:b.PROGRESS_CARD_SPY,count:3},{card:b.PROGRESS_CARD_WARLORD,count:2},{card:b.PROGRESS_CARD_WEDDING,count:2}],aN=[{card:b.PROGRESS_CARD_COMMERCIAL_HARBOR,count:2},{card:b.PROGRESS_CARD_MASTER_MERCHANT,count:2},{card:b.PROGRESS_CARD_MERCHANT,count:6},{card:b.PROGRESS_CARD_MERCHANT_FLEET,count:2},{card:b.PROGRESS_CARD_RESOURCE_MONOPOLY,count:4},{card:b.PROGRESS_CARD_TRADE_MONOPOLY,count:2}];function qa(e){let r;switch(e){case K.CITY_IMPROVEMENT_TRACK_SCIENCE:r=iN;break;case K.CITY_IMPROVEMENT_TRACK_POLITICS:r=oN;break;case K.CITY_IMPROVEMENT_TRACK_TRADE:r=aN;break;default:return[]}let t=[];for(let o of r)for(let i=0;i<o.count;i++)t.push(o.card);return t}E(qa,"createProgressDeck");function A_(e,r){let t=[...e];for(let o=t.length-1;o>0;o--){let i=Math.floor(r()*(o+1));[t[o],t[i]]=[t[i],t[o]]}return t}E(A_,"shuffleDeck");function S_(e){if(e.length===0)return null;let[r,...t]=e;return[r,t]}E(S_,"drawProgressCard");var xt=4,gD=[b.PROGRESS_CARD_BISHOP,b.PROGRESS_CARD_CRANE,b.PROGRESS_CARD_DESERTER,b.PROGRESS_CARD_INTRIGUE,b.PROGRESS_CARD_MERCHANT,b.PROGRESS_CARD_RESOURCE_MONOPOLY,b.PROGRESS_CARD_ROAD_BUILDING,b.PROGRESS_CARD_SMITH,b.PROGRESS_CARD_SPY,b.PROGRESS_CARD_WARLORD];var yD=new Set([b.PROGRESS_CARD_CRANE,b.PROGRESS_CARD_ENGINEER,b.PROGRESS_CARD_MEDICINE,b.PROGRESS_CARD_SMITH,b.PROGRESS_CARD_MERCHANT_FLEET]);function sN(e){return e.filter(r=>!yD.has(r))}E(sN,"clearTurnBasedProgressCards");function Vd(e){switch(e){case Se.FISH_ONE_FISH:return 1;case Se.FISH_TWO_FISH:return 2;case Se.FISH_THREE_FISH:return 3;case Se.FISH_OLD_BOOT:return-1;default:return 0}}E(Vd,"getFishValue");function O_(e){return e.reduce((r,t)=>r+t.count,0)}E(O_,"getTotalFishCount");function kl(e){return e.reduce((r,t)=>r+Vd(t.fish)*t.count,0)}E(kl,"calculateTotalFish");function Za(e,r){let t=new Map;for(let o of e)t.set(o.fish,(t.get(o.fish)??0)+o.count);for(let o of r)t.set(o.fish,(t.get(o.fish)??0)+o.count);return Array.from(t.entries()).filter(([o,i])=>i>0).map(([o,i])=>({fish:o,count:i}))}E(Za,"addFish");function Xa(e,r){let t=new Map;for(let o of e)t.set(o.fish,o.count);for(let o of r){let i=t.get(o.fish)??0;if(i<o.count)return null;t.set(o.fish,i-o.count)}return Array.from(t.entries()).filter(([o,i])=>i>0).map(([o,i])=>({fish:o,count:i}))}E(Xa,"subtractFish");var MD=[Se.FISH_ONE_FISH,Se.FISH_TWO_FISH,Se.FISH_THREE_FISH,Se.FISH_OLD_BOOT],bl=[{fish:Se.FISH_ONE_FISH,count:20},{fish:Se.FISH_TWO_FISH,count:15},{fish:Se.FISH_THREE_FISH,count:10},{fish:Se.FISH_OLD_BOOT,count:5}],_N=7;function Ci(e,r){let t=e.filter(l=>l.fish!==Se.FISH_OLD_BOOT),o=[];for(let l of t)for(let c=0;c<l.count;c++)o.push(l.fish);if(o.reduce((l,c)=>l+Vd(c),0)<r)return null;let n=null;function a(l,c,f){if(f>=r){let T=f-r;(!n||T<n.waste||T===n.waste&&c.length<n.tiles.length)&&(n={tiles:[...c],total:f,waste:T});return}for(let T=l;T<o.length;T++)c.push(o[T]),a(T+1,c,f+Vd(o[T])),c.pop()}if(E(a,"tryAllCombinations"),a(0,[],0),!n)return null;let s=new Map,u=n;for(let l of u.tiles)s.set(l,(s.get(l)??0)+1);return s}E(Ci,"selectFishToSpend");var dN=5,LD=new Map([[le.EVENT_CARD_BEAUTIFUL_DAY,16],[le.EVENT_CARD_ROBBER_ATTACKS,6],[le.EVENT_CARD_CALM_SEAS,2],[le.EVENT_CARD_GOOD_NEIGHBORS,2],[le.EVENT_CARD_ROBBER_FLEES,2],[le.EVENT_CARD_EPIDEMIC,2],[le.EVENT_CARD_CONFLICT,1],[le.EVENT_CARD_EARTHQUAKE,1],[le.EVENT_CARD_HELPFUL_NEIGHBOR,1],[le.EVENT_CARD_PLENTIFUL_YEAR,1],[le.EVENT_CARD_TOURNAMENT,1],[le.EVENT_CARD_TRADE_ADVANTAGE,1]]);function vl(){return new Map(LD)}E(vl,"createFullEventCardDeck");function uN(e){let r=vl(),t=new Map;for(let o=0;o<dN;o++){let i=xd(r,e);if(i!==void 0){let n=r.get(i)??0;n>1?r.set(i,n-1):r.delete(i),t.set(i,(t.get(i)??0)+1)}}return{deck:r,removed:t}}E(uN,"resetEventCardDeck");function EN(e,r){let t=new Map(e),o=new Map;for(let i=0;i<dN;i++){let n=xd(t,r);if(n!==void 0){let a=t.get(n)??0;a>1?t.set(n,a-1):t.delete(n),o.set(n,(o.get(n)??0)+1)}}return{deck:t,removed:o}}E(EN,"removeRandomCardsFromEventDeck");function xd(e,r){let t=[];for(let[o,i]of e)for(let n=0;n<i;n++)t.push(o);if(t.length!==0)return r.pickRandom(t)}E(xd,"drawRandomCard");function lN(e){let r=0;for(let t of e.values())r+=t;return r===0}E(lN,"isEventCardDeckEmpty");function cN(e,r){let t=new Map(e),o=t.get(r)??0;return o>1?t.set(r,o-1):o===1&&t.delete(r),t}E(cN,"removeCardFromDeck");function wd(e){let r,t,o,i,n;return e<=4?(r=14,t=5,o=2,i=2,n=2):e<=6?(r=20,t=5,o=3,i=3,n=3):(r=26,t=5,o=4,i=4,n=4),new Map([[ie.DEV_CARD_KNIGHT,r],[ie.DEV_CARD_VICTORY_POINT,t],[ie.DEV_CARD_MONOPOLY,o],[ie.DEV_CARD_ROAD_BUILDING,i],[ie.DEV_CARD_YEAR_OF_PLENTY,n]])}E(wd,"createDevCardDeck");var GD=32;function Hd(e,r){let t=new Set([...e?.keys()??[],...r?.keys()??[]]);for(let o of t)if((e?.get(o)??0)!==(r?.get(o)??0))return!1;return!0}E(Hd,"sameCounts");function fN(e,r){return Hd(e.offering,r.offering)&&Hd(e.requesting,r.requesting)&&Hd(e.offeringCommodities,r.offeringCommodities)&&Hd(e.requestingCommodities,r.requestingCommodities)&&(e.offeringGold??0)===(r.offeringGold??0)&&(e.requestingGold??0)===(r.requestingGold??0)}E(fN,"sameTradeTerms");function Yl(e,r){if(r.counterTradeId>0)return e.rejectedTradeOffers;let t={proposer:r.proposer,offering:new Map(r.offering),requesting:new Map(r.requesting),offeringCommodities:new Map(r.offeringCommodities),requestingCommodities:new Map(r.requestingCommodities),offeringGold:r.offeringGold,requestingGold:r.requestingGold,proposerCardCount:e.getPlayerPublicState(r.proposer)?.cardCount??0};return e.rejectedTradeOffers.some(i=>i.proposer===t.proposer&&i.proposerCardCount===t.proposerCardCount&&fN(i,t))?e.rejectedTradeOffers:[...e.rejectedTradeOffers,t].slice(-GD)}E(Yl,"withRejectedTradeOffer");function TN(e){let r=E(o=>new Map((o??[]).map(i=>[i.resource,i.count])),"resources"),t=E(o=>new Map((o??[]).map(i=>[i.commodity,i.count])),"commodities");return{proposer:e.proposer,offering:r(e.offering),requesting:r(e.requesting),offeringCommodities:t(e.offeringCommodities),requestingCommodities:t(e.requestingCommodities),offeringGold:e.offeringGold??0,requestingGold:e.requestingGold??0,proposerCardCount:e.proposerCardCount??0}}E(TN,"rejectedTradeOfferFromProto");function NN(e){let r=E(o=>[...o.entries()].filter(([,i])=>i>0).map(([i,n])=>ne.create({resource:i,count:n})),"resources"),t=E(o=>[...o.entries()].filter(([,i])=>i>0).map(([i,n])=>te.create({commodity:i,count:n})),"commodities");return ri.create({proposer:e.proposer,offering:r(e.offering),requesting:r(e.requesting),offeringCommodities:t(e.offeringCommodities),requestingCommodities:t(e.requestingCommodities),offeringGold:e.offeringGold,requestingGold:e.requestingGold,proposerCardCount:e.proposerCardCount})}E(NN,"rejectedTradeOfferToProto");var gr=class e{static{E(this,"Game")}board;options;resourceDeck;devCardDeck;playerStateMap;playerPublicStateMap;dice;activeTradeMap;pendingDiceRoll;pendingDiscards;pendingRobberOrPiratePlacement;pendingRobberStealLocation;pendingPirateStealLocation;playedDevCardThisTurn;pendingFreeResources;pendingFreeStructures;largestArmyPlayer;longestRoadPlayer;harbormasterPlayer;currentPlayer;turnOrder;turnNumber;isSetupPhase;tradesProposedThisTurn;tradesExecutedThisTurn;nextTradeId;rejectedTradeOffers;winner;movedShipThisTurn;shipsBuiltThisTurn;eventDice;scienceProgressDeck;politicsProgressDeck;tradeProgressDeck;knightActivatedThisTurn;commodityBank;pendingDefenderSelection;pendingCityPillage;pendingCityPillagePlayers;discardsWithoutRobber;pendingAlchemist;pendingProgressCardDraw;progressCardsInPlay;merchantFleetResource;merchantFleetCommodity;masterMerchantTarget;pendingSpyTarget;smithFreePromotionsRemaining;pendingKnights;pendingWeddingCards;pendingCommercialHarborExchanges;pendingDeserter;pendingKnightCommitment;pendingMetropolisPlacement;fishBank;oldBoot;fogTerrainBank;fogNumberBank;paused;pauseState;pendingResourceResolution;pendingSecondTurboRoll;isSecondSettlerPhase;secondSettlerPlayer;diceRollCount;devCardDrawCount;stealCount;diceDistribution;sevensPerPlayer;timerState;eventCardDeck;removedEventCards;pendingGoodNeighbors;pendingHelpfulNeighbors;pendingEventCardSteal;pendingEarthquake;pendingBishopSteal;pendingProgressCardDiscard;pendingWagonVoting;wagonsExhausted;goldSpentThisTurn;tradeEmbargoes;tradeBalance;stateVersion;mapVersion;buildingVersion;rushPlayedDevCard;rushNextDiceRollAt;rushDiceVotes;rushRobberPlayer;static fromProto(r){if(!r.board)throw new Error("GameProto must have board");let t=new Map;for(let X of r.resourceDeck??[])t.set(X.resource,X.count);let o=new Map;for(let X of r.devCardDeck??[])o.set(X.card,X.count);let i=(r.playerStates??[]).map(X=>cn.fromProto(X)),n=(r.playerPublicStates??[]).map(X=>vn.fromProto(X)),a=r.dice?et.fromProto(r.dice):void 0,s=(r.activeTrades??[]).map(X=>Yn.fromProto(X)),u=new Map;for(let X of r.pendingDiscards??[])u.set(X.player,X.count);let l=new Map;for(let X of r.pendingProgressCardDiscard??[])l.set(X.player,X.count);let c=new Map;for(let X of r.pendingFreeResources??[])c.set(X.player,X.count);let f=new Map;for(let X of r.pendingFreeStructures??[])f.set(X.player,[...X.structures??[]]);let T=r.eventDice?Ni.fromProto(r.eventDice):void 0,R=[...r.scienceProgressDeck??[]],O=[...r.politicsProgressDeck??[]],I=[...r.tradeProgressDeck??[]],D=new Map;for(let X of r.commodityBank??[])D.set(X.commodity,X.count);let g=r.pendingCityPillage!==x.PLAYER_COLOR_UNSPECIFIED?r.pendingCityPillage:void 0,k=r.pendingAlchemist!==x.PLAYER_COLOR_UNSPECIFIED?r.pendingAlchemist:void 0,v=new Map;for(let X of r.pendingProgressCardDraw??[])v.set(X.card,X.count);let Y=r.masterMerchantTarget!==x.PLAYER_COLOR_UNSPECIFIED?r.masterMerchantTarget:void 0,V=r.pendingSpyTarget!==x.PLAYER_COLOR_UNSPECIFIED?r.pendingSpyTarget:void 0,w=r.merchantFleetResource!==S.RESOURCE_UNSPECIFIED?r.merchantFleetResource:void 0,J=r.merchantFleetCommodity!==j.COMMODITY_UNSPECIFIED?r.merchantFleetCommodity:void 0,$=(r.pendingKnights??[]).map(X=>({player:X.player,strength:X.strength,status:X.status,fromVertex:X.fromVertex?oe.fromProto(X.fromVertex):void 0})),he=(r.pendingWeddingCards??[]).map(X=>({player:X.player,weddingPlayer:X.weddingPlayer})),De=(r.pendingCommercialHarborExchanges??[]).map(X=>({opponent:X.opponent,harborPlayer:X.harborPlayer,resource:X.resource})),ve=r.pendingDeserter?{deserterPlayer:r.pendingDeserter.deserterPlayer,targetPlayer:r.pendingDeserter.targetPlayer}:void 0,Be=r.pendingKnightCommitment?{barbarianStrength:r.pendingKnightCommitment.barbarianStrength,committedKnights:r.pendingKnightCommitment.committedKnights.map(X=>oe.fromProto(X)),currentPlayer:r.pendingKnightCommitment.currentPlayer,playersCommitted:[...r.pendingKnightCommitment.playersCommitted]}:void 0,Ye=r.pendingMetropolisPlacement?{player:r.pendingMetropolisPlacement.player,track:r.pendingMetropolisPlacement.track,isSteal:r.pendingMetropolisPlacement.isSteal,stolenFrom:r.pendingMetropolisPlacement.stolenFrom!==x.PLAYER_COLOR_UNSPECIFIED?r.pendingMetropolisPlacement.stolenFrom:void 0}:void 0,Or=new Map;for(let X of r.fishBank??[])Or.set(X.fish,X.count);let Fe=r.oldBoot!==x.PLAYER_COLOR_UNSPECIFIED?r.oldBoot:void 0,He=[...r.fogTerrainBank??[]],Xr=[...r.fogNumberBank??[]],Fr=new Map;for(let X of r.eventCardDeck??[])Fr.set(X.card,X.count);let Lr=new Map;for(let X of r.removedEventCards??[])Lr.set(X.card,X.count);let Ln=new Set;for(let X of r.tradeEmbargoes??[])Ln.add(`${X.embargoingPlayer}-${X.embargoedPlayer}`);let Pa=new Map;for(let X of r.tradeBalance??[])Pa.set(`${X.fromPlayer}-${X.toPlayer}`,X.balance);let Ls=r.options?yt.fromProto(r.options):yt.createDefault(),Gs=r.largestArmyPlayer!==x.PLAYER_COLOR_UNSPECIFIED?r.largestArmyPlayer:void 0,Us=r.longestRoadPlayer!==x.PLAYER_COLOR_UNSPECIFIED?r.longestRoadPlayer:void 0,Bs=r.harbormasterPlayer!==x.PLAYER_COLOR_UNSPECIFIED?r.harbormasterPlayer:void 0,ks=r.currentPlayer!==x.PLAYER_COLOR_UNSPECIFIED?r.currentPlayer:x.PLAYER_COLOR_UNSPECIFIED,bs=r.winner!==x.PLAYER_COLOR_UNSPECIFIED?r.winner:void 0;return new e({board:ge.fromProto(r.board),options:Ls,resourceDeck:t,devCardDeck:o,playerStates:i,playerPublicStates:n,dice:a,activeTrades:s,pendingDiceRoll:r.pendingDiceRoll,pendingDiscards:u,pendingRobberOrPiratePlacement:r.pendingRobberOrPiratePlacement,pendingRobberStealLocation:r.pendingRobberStealLocation?_.fromProto(r.pendingRobberStealLocation):void 0,pendingPirateStealLocation:r.pendingPirateStealLocation?_.fromProto(r.pendingPirateStealLocation):void 0,playedDevCardThisTurn:r.playedDevCardThisTurn,pendingFreeResources:c,pendingFreeStructures:f,largestArmyPlayer:Gs,longestRoadPlayer:Us,harbormasterPlayer:Bs,currentPlayer:ks,turnOrder:[...r.turnOrder??[]],turnNumber:r.turnNumber,isSetupPhase:r.isSetupPhase,tradesProposedThisTurn:r.tradesProposedThisTurn,tradesExecutedThisTurn:r.tradesExecutedThisTurn,nextTradeId:r.nextTradeId,rejectedTradeOffers:(r.rejectedTradeOffers??[]).map(TN),winner:bs,movedShipThisTurn:r.movedShipThisTurn,shipsBuiltThisTurn:(r.shipsBuiltThisTurn??[]).map(X=>Ne.fromProto(X)),eventDice:T,scienceProgressDeck:R,politicsProgressDeck:O,tradeProgressDeck:I,knightActivatedThisTurn:r.knightActivatedThisTurn,commodityBank:D,pendingDefenderSelection:[...r.pendingDefenderSelection??[]],pendingCityPillage:g,pendingCityPillagePlayers:[...r.pendingCityPillagePlayers??[]],discardsWithoutRobber:r.discardsWithoutRobber,pendingAlchemist:k,pendingProgressCardDraw:v,progressCardsInPlay:[...r.progressCardsInPlay??[]],merchantFleetResource:w,merchantFleetCommodity:J,masterMerchantTarget:Y,pendingSpyTarget:V,smithFreePromotionsRemaining:r.smithFreePromotionsRemaining,pendingKnights:$,pendingWeddingCards:he,pendingCommercialHarborExchanges:De,pendingDeserter:ve,pendingKnightCommitment:Be,pendingMetropolisPlacement:Ye,fishBank:Or,oldBoot:Fe,fogTerrainBank:He,fogNumberBank:Xr,paused:r.paused??!1,pauseState:Ga.fromProto(r.pauseState),pendingResourceResolution:r.pendingResourceResolution??!1,pendingSecondTurboRoll:r.pendingSecondTurboRoll??!1,isSecondSettlerPhase:r.isSecondSettlerPhase??!1,secondSettlerPlayer:r.secondSettlerPlayer||void 0,diceRollCount:r.diceRollCount??0,devCardDrawCount:r.devCardDrawCount??0,stealCount:r.stealCount??0,diceDistribution:(()=>{let X=new Map;for(let pt of r.diceDistribution??[])X.set(pt.diceTotal,pt.count);return X})(),sevensPerPlayer:(()=>{let X=new Map;for(let pt of r.sevensPerPlayer??[])X.set(pt.player,pt.count);return X})(),timerState:r.timerState?Ft.fromProto(r.timerState):void 0,eventCardDeck:Fr,removedEventCards:Lr,pendingGoodNeighbors:[...r.pendingGoodNeighbors??[]],pendingHelpfulNeighbors:[...r.pendingHelpfulNeighbors??[]],pendingEventCardSteal:r.pendingEventCardSteal!==x.PLAYER_COLOR_UNSPECIFIED?r.pendingEventCardSteal:void 0,pendingEarthquake:[...r.pendingEarthquake??[]],pendingBishopSteal:r.pendingBishopSteal!==x.PLAYER_COLOR_UNSPECIFIED?r.pendingBishopSteal:void 0,pendingProgressCardDiscard:l,pendingWagonVoting:r.pendingWagonVoting?Tn.fromProto(r.pendingWagonVoting):void 0,wagonsExhausted:r.wagonsExhausted??!1,goldSpentThisTurn:(()=>{let X=new Map;for(let[pt,vs]of Object.entries(r.goldSpentThisTurn??{}))X.set(Number(pt),vs);return X})(),tradeEmbargoes:Ln,tradeBalance:Pa,stateVersion:r.stateVersion??0,mapVersion:r.mapVersion??0,buildingVersion:r.buildingVersion??0,rushPlayedDevCard:new Set(r.rushPlayedDevCard?.filter(X=>X!==x.PLAYER_COLOR_UNSPECIFIED)??[]),rushNextDiceRollAt:Number(r.rushNextDiceRollAt)||0,rushDiceVotes:new Set(r.rushDiceVotes?.filter(X=>X!==x.PLAYER_COLOR_UNSPECIFIED)??[]),rushRobberPlayer:r.rushRobberPlayer!==x.PLAYER_COLOR_UNSPECIFIED?r.rushRobberPlayer:void 0})}static createStandardGame(r,t,o=[],i=[],n=yt.createDefault(),a){let s=r,u=n.numberOfRobbers,l=r.robberCount;if(u!==l){let V;u===0?V=[]:u<l?V=r.robbers.slice(0,u):V=r.robbers,s=r.toBuilder().withRobbers(V).build()}n.citiesAndKnights&&!s.barbarians&&(s=s.toBuilder().withBarbarians(Nt.createInitial()).build());let c=new Map([[S.RESOURCE_WOOD,19],[S.RESOURCE_BRICK,19],[S.RESOURCE_SHEEP,19],[S.RESOURCE_WHEAT,19],[S.RESOURCE_ORE,19]]),f=n.citiesAndKnights?new Map:wd(t.length),T=n.citiesAndKnights?new Map([[j.COMMODITY_CLOTH,12],[j.COMMODITY_COIN,12],[j.COMMODITY_PAPER,12]]):new Map,R=n.fisherman?new Map(bl.map(V=>[V.fish,V.count])):new Map,O=n.citiesAndKnights?Array(R_).fill(b.PROGRESS_CARD_UNSPECIFIED):[],I=n.citiesAndKnights?Array(R_).fill(b.PROGRESS_CARD_UNSPECIFIED):[],D=n.citiesAndKnights?Array(R_).fill(b.PROGRESS_CARD_UNSPECIFIED):[],g=n.eventCards?vl():new Map,k;n.timerConfig.isEnabled()&&(k=new Ft,n.timerConfig.isChessClock()?k.initializeTimers(t,n.timerConfig):k.initializeLegacyTimers(t));let v=n.citiesAndKnights?i.map(V=>V.cityImprovements?V:V.toBuilder().withCityImprovements(Yt.createDefault()).build()):i,Y;if(a&&(a.fogTerrainBank.length>0||a.fogNumberBank.length>0)){let V=new Re(n.seed);Y={fogTerrainBank:V.shuffle(a.fogTerrainBank),fogNumberBank:V.shuffle(a.fogNumberBank)}}else Y=Mt.getFogBanksForMapType(n.mapType,n.seed);return new e({board:s,options:n,resourceDeck:c,devCardDeck:f,commodityBank:T,fishBank:R,scienceProgressDeck:O,politicsProgressDeck:I,tradeProgressDeck:D,eventCardDeck:g,playerStates:o,playerPublicStates:v,turnOrder:t,currentPlayer:t[0],turnNumber:0,isSetupPhase:!0,timerState:k,rushRobberPlayer:n.rushMode?t[0]:void 0,fogTerrainBank:Y?.fogTerrainBank,fogNumberBank:Y?.fogNumberBank})}constructor(r){this.board=r.board,this.options=r.options??yt.createDefault(),this.resourceDeck=r.resourceDeck??new Map,this.devCardDeck=r.devCardDeck??new Map,this.playerStateMap=new Map;for(let o of r.playerStates??[])this.playerStateMap.set(o.player,o);this.playerPublicStateMap=new Map;for(let o of r.playerPublicStates??[])this.playerPublicStateMap.set(o.player,o);if(!(typeof process<"u"&&process.env?.NODE_ENV==="test"))for(let[o,i]of this.playerStateMap){if(!i.hand)continue;let n=this.playerPublicStateMap.get(o);if(!n){console.warn(`[Game Constructor] Player ${o} has private state but no public state`);continue}let a=i.totalResourcesInHand+i.totalCommoditiesInHand;a!==n.cardCount&&console.warn(`[Game Constructor] Player ${o} card count mismatch: private state has ${a} cards (${i.totalResourcesInHand} resources + ${i.totalCommoditiesInHand} commodities), public state shows ${n.cardCount} cards`);let s=i.totalProgressCards,u=n.progressCardCount;s!==u&&console.warn(`[Game Constructor] Player ${o} progress card count mismatch: private state has ${s} progress cards, public state shows ${u} progress cards`);let l=i.totalUnplayedDevCards,c=n.unplayedDevCardCount??0;if(l!==c&&console.warn(`[Game Constructor] Player ${o} dev card count mismatch: private state has ${l} unplayed dev cards, public state shows ${c} dev cards`),this.options.fisherman){let f=i.totalFishTiles,T=n.fishTileCount;f!==T&&console.warn(`[Game Constructor] Player ${o} fish tile count mismatch: private state has ${f} fish tiles, public state shows ${T} fish tiles`)}}this.dice=r.dice,this.activeTradeMap=new Map;for(let o of r.activeTrades??[])this.activeTradeMap.set(o.id,o);this.pendingDiceRoll=r.pendingDiceRoll??!1,this.pendingDiscards=r.pendingDiscards??new Map,this.pendingRobberOrPiratePlacement=r.pendingRobberOrPiratePlacement??!1,this.pendingRobberStealLocation=r.pendingRobberStealLocation,this.pendingPirateStealLocation=r.pendingPirateStealLocation,this.playedDevCardThisTurn=r.playedDevCardThisTurn??!1,this.pendingFreeResources=r.pendingFreeResources??new Map,this.pendingFreeStructures=new Map;for(let[o,i]of r.pendingFreeStructures??new Map)this.pendingFreeStructures.set(o,[...i]);this.largestArmyPlayer=r.largestArmyPlayer,this.longestRoadPlayer=r.longestRoadPlayer,this.harbormasterPlayer=r.harbormasterPlayer,this.currentPlayer=r.currentPlayer??x.PLAYER_COLOR_UNSPECIFIED,this.turnOrder=[...r.turnOrder??[]],this.turnNumber=r.turnNumber??0,this.isSetupPhase=r.isSetupPhase??!1,this.tradesProposedThisTurn=r.tradesProposedThisTurn??0,this.tradesExecutedThisTurn=r.tradesExecutedThisTurn??0,this.nextTradeId=r.nextTradeId??0,this.rejectedTradeOffers=r.rejectedTradeOffers??[],this.winner=r.winner,this.movedShipThisTurn=r.movedShipThisTurn??!1,this.shipsBuiltThisTurn=[...r.shipsBuiltThisTurn??[]],this.eventDice=r.eventDice,this.scienceProgressDeck=r.scienceProgressDeck??[],this.politicsProgressDeck=r.politicsProgressDeck??[],this.tradeProgressDeck=r.tradeProgressDeck??[],this.knightActivatedThisTurn=r.knightActivatedThisTurn??!1,this.commodityBank=r.commodityBank??new Map,this.pendingDefenderSelection=[...r.pendingDefenderSelection??[]],this.pendingCityPillage=r.pendingCityPillage,this.pendingCityPillagePlayers=[...r.pendingCityPillagePlayers??[]],this.discardsWithoutRobber=r.discardsWithoutRobber??!1,this.pendingAlchemist=r.pendingAlchemist,this.pendingProgressCardDraw=r.pendingProgressCardDraw??new Map,this.progressCardsInPlay=[...r.progressCardsInPlay??[]],this.merchantFleetResource=r.merchantFleetResource,this.merchantFleetCommodity=r.merchantFleetCommodity,this.masterMerchantTarget=r.masterMerchantTarget,this.pendingSpyTarget=r.pendingSpyTarget,this.smithFreePromotionsRemaining=r.smithFreePromotionsRemaining??0,this.pendingKnights=[...r.pendingKnights??[]],this.pendingWeddingCards=[...r.pendingWeddingCards??[]],this.pendingCommercialHarborExchanges=[...r.pendingCommercialHarborExchanges??[]],this.pendingDeserter=r.pendingDeserter,this.pendingKnightCommitment=r.pendingKnightCommitment,this.pendingMetropolisPlacement=r.pendingMetropolisPlacement,this.fishBank=r.fishBank??new Map,this.oldBoot=r.oldBoot,this.fogTerrainBank=[...r.fogTerrainBank??[]],this.fogNumberBank=[...r.fogNumberBank??[]],this.paused=r.paused??!1,this.pauseState=r.pauseState,this.pendingResourceResolution=r.pendingResourceResolution??!1,this.pendingSecondTurboRoll=r.pendingSecondTurboRoll??!1,this.isSecondSettlerPhase=r.isSecondSettlerPhase??!1,this.secondSettlerPlayer=r.secondSettlerPlayer,this.diceRollCount=r.diceRollCount??0,this.devCardDrawCount=r.devCardDrawCount??0,this.stealCount=r.stealCount??0,this.diceDistribution=r.diceDistribution??new Map,this.sevensPerPlayer=r.sevensPerPlayer??new Map,this.timerState=r.timerState,this.eventCardDeck=r.eventCardDeck??new Map,this.removedEventCards=r.removedEventCards??new Map,this.pendingGoodNeighbors=[...r.pendingGoodNeighbors??[]],this.pendingHelpfulNeighbors=[...r.pendingHelpfulNeighbors??[]],this.pendingEventCardSteal=r.pendingEventCardSteal,this.pendingEarthquake=[...r.pendingEarthquake??[]],this.pendingBishopSteal=r.pendingBishopSteal,this.pendingProgressCardDiscard=r.pendingProgressCardDiscard??new Map,this.pendingWagonVoting=r.pendingWagonVoting,this.wagonsExhausted=r.wagonsExhausted??!1,this.goldSpentThisTurn=r.goldSpentThisTurn??new Map,this.tradeEmbargoes=r.tradeEmbargoes??new Set,this.tradeBalance=r.tradeBalance??new Map,this.stateVersion=r.stateVersion??0,this.mapVersion=r.mapVersion??0,this.buildingVersion=r.buildingVersion??0,this.rushPlayedDevCard=r.rushPlayedDevCard??new Set,this.rushNextDiceRollAt=r.rushNextDiceRollAt??0,this.rushDiceVotes=r.rushDiceVotes??new Set,this.rushRobberPlayer=r.rushRobberPlayer}toOptions(){return{board:this.board,options:this.options,resourceDeck:this.resourceDeck,devCardDeck:this.devCardDeck,playerStates:this.getPlayerStates(),playerPublicStates:this.getPlayerPublicStates(),dice:this.dice,activeTrades:this.getActiveTrades(),pendingDiceRoll:this.pendingDiceRoll,pendingDiscards:this.pendingDiscards,pendingRobberOrPiratePlacement:this.pendingRobberOrPiratePlacement,pendingRobberStealLocation:this.pendingRobberStealLocation,pendingPirateStealLocation:this.pendingPirateStealLocation,playedDevCardThisTurn:this.playedDevCardThisTurn,pendingFreeResources:this.pendingFreeResources,pendingFreeStructures:this.pendingFreeStructures,largestArmyPlayer:this.largestArmyPlayer,longestRoadPlayer:this.longestRoadPlayer,harbormasterPlayer:this.harbormasterPlayer,currentPlayer:this.currentPlayer,turnOrder:this.turnOrder,turnNumber:this.turnNumber,isSetupPhase:this.isSetupPhase,tradesProposedThisTurn:this.tradesProposedThisTurn,tradesExecutedThisTurn:this.tradesExecutedThisTurn,nextTradeId:this.nextTradeId,rejectedTradeOffers:this.rejectedTradeOffers,winner:this.winner,movedShipThisTurn:this.movedShipThisTurn,shipsBuiltThisTurn:this.shipsBuiltThisTurn,eventDice:this.eventDice,scienceProgressDeck:this.scienceProgressDeck,politicsProgressDeck:this.politicsProgressDeck,tradeProgressDeck:this.tradeProgressDeck,knightActivatedThisTurn:this.knightActivatedThisTurn,commodityBank:this.commodityBank,pendingDefenderSelection:this.pendingDefenderSelection,pendingCityPillage:this.pendingCityPillage,pendingCityPillagePlayers:this.pendingCityPillagePlayers,discardsWithoutRobber:this.discardsWithoutRobber,pendingAlchemist:this.pendingAlchemist,pendingProgressCardDraw:this.pendingProgressCardDraw,progressCardsInPlay:this.progressCardsInPlay,merchantFleetResource:this.merchantFleetResource,merchantFleetCommodity:this.merchantFleetCommodity,masterMerchantTarget:this.masterMerchantTarget,pendingSpyTarget:this.pendingSpyTarget,smithFreePromotionsRemaining:this.smithFreePromotionsRemaining,pendingKnights:this.pendingKnights,pendingWeddingCards:this.pendingWeddingCards,pendingCommercialHarborExchanges:this.pendingCommercialHarborExchanges,pendingDeserter:this.pendingDeserter,pendingKnightCommitment:this.pendingKnightCommitment,pendingMetropolisPlacement:this.pendingMetropolisPlacement,fishBank:this.fishBank,oldBoot:this.oldBoot,fogTerrainBank:this.fogTerrainBank,fogNumberBank:this.fogNumberBank,paused:this.paused,pauseState:this.pauseState,pendingResourceResolution:this.pendingResourceResolution,pendingSecondTurboRoll:this.pendingSecondTurboRoll,isSecondSettlerPhase:this.isSecondSettlerPhase,secondSettlerPlayer:this.secondSettlerPlayer,diceRollCount:this.diceRollCount,devCardDrawCount:this.devCardDrawCount,stealCount:this.stealCount,diceDistribution:this.diceDistribution,sevensPerPlayer:this.sevensPerPlayer,timerState:this.timerState,eventCardDeck:this.eventCardDeck,removedEventCards:this.removedEventCards,pendingGoodNeighbors:this.pendingGoodNeighbors,pendingHelpfulNeighbors:this.pendingHelpfulNeighbors,pendingEventCardSteal:this.pendingEventCardSteal,pendingEarthquake:this.pendingEarthquake,pendingBishopSteal:this.pendingBishopSteal,pendingProgressCardDiscard:this.pendingProgressCardDiscard,pendingWagonVoting:this.pendingWagonVoting,wagonsExhausted:this.wagonsExhausted,goldSpentThisTurn:this.goldSpentThisTurn,stateVersion:this.stateVersion,mapVersion:this.mapVersion,buildingVersion:this.buildingVersion,tradeEmbargoes:this.tradeEmbargoes,tradeBalance:this.tradeBalance,rushPlayedDevCard:this.rushPlayedDevCard,rushNextDiceRollAt:this.rushNextDiceRollAt,rushDiceVotes:this.rushDiceVotes,rushRobberPlayer:this.rushRobberPlayer}}toProto(){let r=[];for(let[c,f]of this.resourceDeck)r.push(ne.create({resource:c,count:f}));let t=[];for(let[c,f]of this.devCardDeck)t.push(Er.create({card:c,count:f}));let o=[];for(let[c,f]of this.pendingDiscards)o.push(mt.create({player:c,count:f}));let i=[];for(let[c,f]of this.pendingProgressCardDiscard)i.push(mt.create({player:c,count:f}));let n=[];for(let[c,f]of this.pendingFreeResources)n.push(ti.create({player:c,count:f}));let a=[];for(let[c,f]of this.pendingFreeStructures)a.push(ni.create({player:c,structures:f}));let s=[];for(let[c,f]of this.commodityBank)s.push(te.create({commodity:c,count:f}));let u=[];for(let[c,f]of this.pendingProgressCardDraw)u.push(dr.create({card:c,count:f}));let l=[];for(let[c,f]of this.fishBank)l.push(xe.create({fish:c,count:f}));return js.create({board:this.board.toProto(),resourceDeck:r,devCardDeck:t,playerStates:this.getPlayerStates().map(c=>c.toProto()),playerPublicStates:this.getPlayerPublicStates().map(c=>c.toProto()),dice:this.dice?.toProto(),activeTrades:this.getActiveTrades().map(c=>c.toProto()),pendingDiceRoll:this.pendingDiceRoll,pendingDiscards:o,pendingRobberOrPiratePlacement:this.pendingRobberOrPiratePlacement,pendingRobberStealLocation:this.pendingRobberStealLocation?.toProto(),pendingPirateStealLocation:this.pendingPirateStealLocation?.toProto(),playedDevCardThisTurn:this.playedDevCardThisTurn,pendingFreeResources:n,pendingFreeStructures:a,largestArmyPlayer:this.largestArmyPlayer??x.PLAYER_COLOR_UNSPECIFIED,longestRoadPlayer:this.longestRoadPlayer??x.PLAYER_COLOR_UNSPECIFIED,harbormasterPlayer:this.harbormasterPlayer??x.PLAYER_COLOR_UNSPECIFIED,currentPlayer:this.currentPlayer,turnOrder:this.turnOrder,turnNumber:this.turnNumber,isSetupPhase:this.isSetupPhase,tradesProposedThisTurn:this.tradesProposedThisTurn,tradesExecutedThisTurn:this.tradesExecutedThisTurn,nextTradeId:this.nextTradeId,rejectedTradeOffers:this.rejectedTradeOffers.map(NN),winner:this.winner??x.PLAYER_COLOR_UNSPECIFIED,movedShipThisTurn:this.movedShipThisTurn,shipsBuiltThisTurn:this.shipsBuiltThisTurn.map(c=>c.toProto()),options:this.options.toProto(),eventDice:this.eventDice?.toProto(),scienceProgressDeck:[...this.scienceProgressDeck],politicsProgressDeck:[...this.politicsProgressDeck],tradeProgressDeck:[...this.tradeProgressDeck],knightActivatedThisTurn:this.knightActivatedThisTurn,commodityBank:s,pendingDefenderSelection:this.pendingDefenderSelection,pendingCityPillage:this.pendingCityPillage??x.PLAYER_COLOR_UNSPECIFIED,pendingCityPillagePlayers:this.pendingCityPillagePlayers,discardsWithoutRobber:this.discardsWithoutRobber,pendingAlchemist:this.pendingAlchemist??x.PLAYER_COLOR_UNSPECIFIED,pendingProgressCardDraw:u,progressCardsInPlay:this.progressCardsInPlay,merchantFleetResource:this.merchantFleetResource??S.RESOURCE_UNSPECIFIED,merchantFleetCommodity:this.merchantFleetCommodity??j.COMMODITY_UNSPECIFIED,masterMerchantTarget:this.masterMerchantTarget??x.PLAYER_COLOR_UNSPECIFIED,pendingSpyTarget:this.pendingSpyTarget??x.PLAYER_COLOR_UNSPECIFIED,smithFreePromotionsRemaining:this.smithFreePromotionsRemaining,pendingKnights:this.pendingKnights.map(c=>ai.create({player:c.player,strength:c.strength,status:c.status,fromVertex:c.fromVertex?c.fromVertex.toProto():void 0})),pendingWeddingCards:this.pendingWeddingCards.map(c=>ii.create({player:c.player,weddingPlayer:c.weddingPlayer})),pendingCommercialHarborExchanges:this.pendingCommercialHarborExchanges.map(c=>oi.create({opponent:c.opponent,harborPlayer:c.harborPlayer,resource:c.resource})),pendingDeserter:this.pendingDeserter?_i.create({deserterPlayer:this.pendingDeserter.deserterPlayer,targetPlayer:this.pendingDeserter.targetPlayer}):void 0,pendingKnightCommitment:this.pendingKnightCommitment?si.create({barbarianStrength:this.pendingKnightCommitment.barbarianStrength,committedKnights:this.pendingKnightCommitment.committedKnights.map(c=>c.toProto()),currentPlayer:this.pendingKnightCommitment.currentPlayer,playersCommitted:[...this.pendingKnightCommitment.playersCommitted]}):void 0,pendingMetropolisPlacement:this.pendingMetropolisPlacement?di.create({player:this.pendingMetropolisPlacement.player,track:this.pendingMetropolisPlacement.track,isSteal:this.pendingMetropolisPlacement.isSteal,stolenFrom:this.pendingMetropolisPlacement.stolenFrom??x.PLAYER_COLOR_UNSPECIFIED}):void 0,fishBank:l,oldBoot:this.oldBoot??x.PLAYER_COLOR_UNSPECIFIED,fogTerrainBank:this.fogTerrainBank,fogNumberBank:this.fogNumberBank,paused:this.paused,pauseState:this.pauseState?.toProto(),pendingResourceResolution:this.pendingResourceResolution,pendingSecondTurboRoll:this.pendingSecondTurboRoll,isSecondSettlerPhase:this.isSecondSettlerPhase,secondSettlerPlayer:this.secondSettlerPlayer??x.PLAYER_COLOR_UNSPECIFIED,diceRollCount:this.diceRollCount,devCardDrawCount:this.devCardDrawCount,stealCount:this.stealCount,diceDistribution:Array.from(this.diceDistribution.entries()).map(([c,f])=>({diceTotal:c,count:f})),sevensPerPlayer:Array.from(this.sevensPerPlayer.entries()).map(([c,f])=>({player:c,count:f})),timerState:this.timerState?.toProto(),eventCardDeck:Array.from(this.eventCardDeck.entries()).map(([c,f])=>Rr.create({card:c,count:f})),removedEventCards:Array.from(this.removedEventCards.entries()).map(([c,f])=>Rr.create({card:c,count:f})),pendingGoodNeighbors:[...this.pendingGoodNeighbors],pendingHelpfulNeighbors:[...this.pendingHelpfulNeighbors],pendingEventCardSteal:this.pendingEventCardSteal??x.PLAYER_COLOR_UNSPECIFIED,pendingEarthquake:[...this.pendingEarthquake],pendingBishopSteal:this.pendingBishopSteal??x.PLAYER_COLOR_UNSPECIFIED,pendingProgressCardDiscard:i,pendingWagonVoting:this.pendingWagonVoting?.toProto(),wagonsExhausted:this.wagonsExhausted,goldSpentThisTurn:(()=>{let c={};for(let[f,T]of this.goldSpentThisTurn)c[f]=T;return c})(),tradeEmbargoes:Array.from(this.tradeEmbargoes).map(c=>{let[f,T]=c.split("-").map(Number);return ui.create({embargoingPlayer:f,embargoedPlayer:T})}),tradeBalance:Array.from(this.tradeBalance.entries()).map(([c,f])=>{let[T,R]=c.split("-").map(Number);return Ei.create({fromPlayer:T,toPlayer:R,balance:f})}),stateVersion:this.stateVersion,mapVersion:this.mapVersion,buildingVersion:this.buildingVersion,rushPlayedDevCard:[...this.rushPlayedDevCard],rushNextDiceRollAt:this.rushNextDiceRollAt,rushDiceVotes:[...this.rushDiceVotes],rushRobberPlayer:this.rushRobberPlayer??x.PLAYER_COLOR_UNSPECIFIED})}getPlayerState(r){return this.playerStateMap.get(r)}hasPlayerState(r){return this.playerStateMap.has(r)}getPlayerStates(){return Array.from(this.playerStateMap.values())}get playerStateCount(){return this.playerStateMap.size}getEdgeBuilding(r){return this.board.getEdgeBuilding(r)}hasEdgeBuilding(r){return this.board.hasEdgeBuilding(r)}getEdgeBuildings(){return this.board.getEdgeBuildings()}getEdgeBuildingsByPlayer(r){return this.board.getEdgeBuildingsByPlayer(r)}getRoads(){return this.board.getRoads()}getShips(){return this.board.getShips()}getBrokenRoads(){return this.board.getEdgeBuildings().filter(r=>r.isBrokenRoad)}getBrokenRoadsByPlayer(r){return this.board.getEdgeBuildingsByPlayer(r).filter(t=>t.isBrokenRoad)}playerHasBrokenRoads(r){return this.getBrokenRoadsByPlayer(r).length>0}getRoadsByPlayer(r){return this.board.getRoadsByPlayer(r)}getShipsByPlayer(r){return this.board.getShipsByPlayer(r)}getBridges(){return this.board.getBridges()}getBridgesByPlayer(r){return this.board.getBridgesByPlayer(r)}get edgeBuildingCount(){return this.board.edgeBuildingCount}get roadCount(){return this.board.roadCount}get shipCount(){return this.board.shipCount}get bridgeCount(){return this.board.bridgeCount}get wealthiestTrader(){return Ba(this)}get poorTraders(){return ka(this)}getVertexBuilding(r){return this.board.getVertexBuilding(r)}hasVertexBuilding(r){return this.board.hasVertexBuilding(r)}getVertexBuildings(){return this.board.getVertexBuildings()}getVertexBuildingsByPlayer(r){return this.board.getVertexBuildingsByPlayer(r)}getSettlements(){return this.board.getSettlements()}getCities(){return this.board.getCities()}getSettlementsByPlayer(r){return this.board.getSettlementsByPlayer(r)}getCitiesByPlayer(r){return this.board.getCitiesByPlayer(r)}get vertexBuildingCount(){return this.board.vertexBuildingCount}get settlementCount(){return this.board.settlementCount}get cityCount(){return this.board.cityCount}getKnightsByPlayer(r){return this.board.getKnightsByPlayer(r)}getKnightAtVertex(r){return this.board.getKnightAt(r)}getVertexBuildingsOnTile(r){return this.board.getVertexBuildingsOnTile(r)}getPlayersOnTile(r){return this.board.getPlayersOnTile(r)}getAllValidSettlementSpots(){return xa(this)}getValidSettlementSpotsForPlayer(r){return l_(this,r)}getPlayerPublicState(r){return this.playerPublicStateMap.get(r)}getPlayerPublicStates(){return Array.from(this.playerPublicStateMap.values())}get playerPublicStateCount(){return this.playerPublicStateMap.size}getDevCardsLeftInDeck(){return this.options.citiesAndKnights?0:this.totalDevCardsInDeck}getActiveTrade(r){return this.activeTradeMap.get(r)}hasActiveTrade(r){return this.activeTradeMap.has(r)}getActiveTrades(){return Array.from(this.activeTradeMap.values())}getActiveTradesByProposer(r){return this.getActiveTrades().filter(t=>t.proposer===r)}getCounterOffers(r){return this.getActiveTrades().filter(t=>t.counterTradeId===r)}get activeTradeCount(){return this.activeTradeMap.size}hasEmbargo(r,t){return this.tradeEmbargoes.has(`${r}-${t}`)}getEmbargoesBy(r){let t=[];for(let o of this.tradeEmbargoes){let[i,n]=o.split("-").map(Number);i===r&&t.push(n)}return t}getTradeBalance(r,t){return this.tradeBalance.get(`${r}-${t}`)??0}getResourceCount(r){return this.resourceDeck.get(r)??0}getDevCardCount(r){return this.devCardDeck.get(r)??0}get totalResourcesInDeck(){let r=0;for(let t of this.resourceDeck.values())r+=t;return r}get totalDevCardsInDeck(){let r=0;for(let t of this.devCardDeck.values())r+=t;return r}hasResourcesInDeck(r,t){return this.getResourceCount(r)>=t}hasDevCardsInDeck(){return this.totalDevCardsInDeck>0}getPendingDiscards(r){return this.pendingDiscards.get(r)??0}hasPendingDiscards(r){return this.getPendingDiscards(r)>0}getPlayersWithPendingDiscards(){return Array.from(this.pendingDiscards.entries()).filter(([r,t])=>t>0).map(([r,t])=>r)}get totalPendingDiscards(){let r=0;for(let t of this.pendingDiscards.values())r+=t;return r}get hasPendingDiscardsAny(){return this.totalPendingDiscards>0}getPendingProgressCardDiscard(r){return this.pendingProgressCardDiscard.get(r)??0}hasPendingProgressCardDiscard(r){return this.getPendingProgressCardDiscard(r)>0}get hasPendingProgressCardDiscardAny(){for(let r of this.pendingProgressCardDiscard.values())if(r>0)return!0;return!1}get isRushMode(){return this.options.rushMode}getPendingFreeResourceCount(r){return this.pendingFreeResources.get(r)??0}hasPendingFreeResources(r){return this.getPendingFreeResourceCount(r)>0}getPlayersWithPendingFreeResources(){return Array.from(this.pendingFreeResources.entries()).filter(([r,t])=>t>0).map(([r,t])=>r)}get totalPendingFreeResources(){let r=0;for(let t of this.pendingFreeResources.values())r+=t;return r}getPendingFreeStructures(r){return this.pendingFreeStructures.get(r)??[]}hasPendingFreeStructures(r){return this.getPendingFreeStructures(r).length>0}getNextPendingFreeStructure(r){return this.pendingFreeStructures.get(r)?.[0]}getPlayersWithPendingFreeStructures(){return Array.from(this.pendingFreeStructures.entries()).filter(([r,t])=>t.length>0).map(([r,t])=>r)}get totalPendingFreeStructures(){let r=0;for(let t of this.pendingFreeStructures.values())r+=t.length;return r}get hasPendingKnightCommitment(){return this.pendingKnightCommitment!==void 0}get nextPlayerToCommitKnights(){return this.pendingKnightCommitment?.currentPlayer}get playerCount(){return this.turnOrder.length}getNextSetupPlayer(){if(!this.isSetupPhase)return;let r=this.turnOrder.length*2,t=this.turnNumber+1;if(!(t>=r)){if(t<this.turnOrder.length)return this.turnOrder[t];{let o=r-1-t;return this.turnOrder[o]}}}getNextPlayer(){if(this.turnOrder.length===0)return;let r=this.turnOrder.indexOf(this.currentPlayer);if(r===-1)return this.turnOrder[0];let t=(r+1)%this.turnOrder.length;return this.turnOrder[t]}isMyTurnToAct(r){return this.isSecondSettlerPhase?this.secondSettlerPlayer===r:this.currentPlayer===r}computeWinner(){if(!(this.isSetupPhase||this.currentPlayer===x.PLAYER_COLOR_UNSPECIFIED)){if(this.options.rushMode){for(let r of this.turnOrder)if(this.hasPlayerWon(r))return r;return}if(this.isSecondSettlerPhase&&this.secondSettlerPlayer!==void 0&&this.hasPlayerWon(this.secondSettlerPlayer))return this.secondSettlerPlayer;if(this.hasPlayerWon(this.currentPlayer))return this.currentPlayer}}getFlowState(){let r=this.winner??this.computeWinner();return new Ua({currentPlayer:this.currentPlayer,turnNumber:this.turnNumber,isSetupPhase:this.isSetupPhase,pendingDiceRoll:this.pendingDiceRoll,pendingRobberPlacement:this.pendingRobberOrPiratePlacement,pendingRobberStealLocation:this.pendingRobberStealLocation,pendingPirateStealLocation:this.pendingPirateStealLocation,playedDevCardThisTurn:this.playedDevCardThisTurn,pendingDiscards:this.pendingDiscards,pendingFreeResources:this.pendingFreeResources,pendingFreeStructures:this.pendingFreeStructures,pendingDefenderSelection:this.pendingDefenderSelection,pendingCityPillage:this.pendingCityPillage,pendingProgressCardDraw:this.pendingProgressCardDraw,progressCardsInPlay:this.progressCardsInPlay,pendingAlchemist:this.pendingAlchemist,merchantFleetResource:this.merchantFleetResource,merchantFleetCommodity:this.merchantFleetCommodity,masterMerchantTarget:this.masterMerchantTarget,pendingSpyTarget:this.pendingSpyTarget,smithFreePromotionsRemaining:this.smithFreePromotionsRemaining,pendingKnights:this.pendingKnights,pendingWeddingCards:this.pendingWeddingCards,pendingCommercialHarborExchanges:this.pendingCommercialHarborExchanges,pendingDeserter:this.pendingDeserter,pendingKnightCommitment:this.pendingKnightCommitment,pendingMetropolisPlacement:this.pendingMetropolisPlacement,pendingResourceResolution:this.pendingResourceResolution,pendingSecondTurboRoll:this.pendingSecondTurboRoll,isSecondSettlerPhase:this.isSecondSettlerPhase,secondSettlerPlayer:this.secondSettlerPlayer,pendingGoodNeighbors:this.pendingGoodNeighbors,pendingHelpfulNeighbors:this.pendingHelpfulNeighbors,pendingEventCardSteal:this.pendingEventCardSteal,pendingEarthquake:this.pendingEarthquake,pendingBishopSteal:this.pendingBishopSteal,pendingProgressCardDiscard:this.pendingProgressCardDiscard,pendingWagonVoting:this.pendingWagonVoting,wagonsExhausted:this.wagonsExhausted,rushMode:this.options.rushMode,rushDiceVotes:this.rushDiceVotes,rushRobberPlayer:this.rushRobberPlayer,largestArmyPlayer:this.largestArmyPlayer,longestRoadPlayer:this.longestRoadPlayer,harbormasterPlayer:this.harbormasterPlayer,winner:r,paused:this.paused})}getVisibleVictoryPoints(r){return new ba(this).getVisibleVictoryPoints(r)}getTotalVictoryPoints(r){return new ba(this).getTotalVictoryPoints(r)}getVictoryPointsThreshold(r){let t=this.options.victoryPoints;return this.options.fisherman&&this.oldBoot===r&&(t+=1),t}hasPlayerWon(r){switch(this.options.winCondition){case fr.WIN_CONDITION_VICTORY_POINTS:case fr.WIN_CONDITION_UNSPECIFIED:default:{let t=this.getTotalVictoryPoints(r),o=this.getVictoryPointsThreshold(r);return t>=o}case fr.WIN_CONDITION_BUILD_ALL_SETTLEMENTS:return this.getSettlementsByPlayer(r).length>=this.options.maxSettlements;case fr.WIN_CONDITION_BUILD_ALL_CITIES:return this.getCitiesByPlayer(r).length>=this.options.maxCities;case fr.WIN_CONDITION_BUILD_ALL_ROADS:{let t=this.getRoadsByPlayer(r).length,o=this.getShipsByPlayer(r).length;return t+o>=this.options.maxRoads}case fr.WIN_CONDITION_BUILD_ALL_PIECES:{let t=this.getSettlementsByPlayer(r).length>=this.options.maxSettlements,o=this.getCitiesByPlayer(r).length>=this.options.maxCities,i=this.getRoadsByPlayer(r).length+this.getShipsByPlayer(r).length>=this.options.maxRoads;return t&&o&&i}case fr.WIN_CONDITION_BUY_ALL_DEV_CARDS:return this.totalDevCardsInDeck===0;case fr.WIN_CONDITION_COLLECT_RESOURCES:return this.hasMetResourceGoal(r);case fr.WIN_CONDITION_TURN_LIMIT:return!1;case fr.WIN_CONDITION_SETTLE_ALL_2TO1_PORTS:{let t=this.board.ports.filter(n=>n.is2to1);if(t.length===0)return!1;let o=this.getVertexBuildingsByPlayer(r),i=new Set(o.map(n=>n.vertex.toString()));return t.every(n=>n.edge.verticies.some(a=>i.has(a.toString())))}case fr.WIN_CONDITION_SETTLE_ALL_3TO1_PORTS:{let t=this.board.ports.filter(n=>n.is3to1);if(t.length===0)return!1;let o=this.getVertexBuildingsByPlayer(r),i=new Set(o.map(n=>n.vertex.toString()));return t.every(n=>n.edge.verticies.some(a=>i.has(a.toString())))}case fr.WIN_CONDITION_BUILD_ALL_COASTAL_ROADS:{let t=this.getCoastalEdges();if(t.length===0)return!1;let o=this.getEdgeBuildingsByPlayer(r),i=new Set(o.map(n=>n.edge.toString()));return t.every(n=>i.has(n.toString()))}}}isGameEndedByTurnLimit(){return this.options.winCondition!==fr.WIN_CONDITION_TURN_LIMIT||this.options.turnLimit<=0?!1:this.turnNumber>=this.options.turnLimit}get activePlayer(){return this.isSecondSettlerPhase&&this.secondSettlerPlayer?this.secondSettlerPlayer:this.currentPlayer}hasMetResourceGoal(r){let t=this.options.resourceGoal;if(!t)return!1;let o=this.getPlayerState(r);if(!o)return!1;let i=o.hand.get(t.resource)??0;switch(t.mode){case Gn.RESOURCE_GOAL_MODE_IN_HAND:return i>=t.targetAmount;case Gn.RESOURCE_GOAL_MODE_CUMULATIVE:return i>=t.targetAmount;case Gn.RESOURCE_GOAL_MODE_UNSPECIFIED:default:return i>=t.targetAmount}}getCoastalEdges(){let r=[],t=new Set;for(let o of this.board.getLandTiles()){if(o.isLake)continue;let i=o.location;for(let n of C.ALL){let a=i.add(n),s=this.board.getTile(a);if(s===void 0||s.isSea||s.isLake){let l=i.getEdgeInDirection(n),c=l.toString();t.has(c)||(t.add(c),r.push(l))}}}return r}recalculateAllPlayerVictoryPoints(){return new ba(this).recalculateAllPlayerVictoryPoints()}recalculateAllLongestRoadLengths(){return new Rt(this).recalculateAllLongestRoadLengths()}calculateLongestRoadForPlayer(r){return new Rt(this).calculateLongestRoadForPlayer(r)}calculateLongestRoadHolder(){return new Rt(this).calculateLongestRoadHolder()}getEdgesAdjacentToHex(r){return r.getAllEdges()}getPlayersWithShipsAdjacentTo(r){let t=this.getEdgesAdjacentToHex(r),o=new Set;for(let i of t){let n=this.getEdgeBuilding(i);n&&n.isShip&&o.add(n.owner)}return Array.from(o)}isProgressCardInPlay(r){return this.progressCardsInPlay.includes(r)}get hasProgressCardsInPlay(){return this.progressCardsInPlay.length>0}get isMerchantFleetActive(){return this.isProgressCardInPlay(b.PROGRESS_CARD_MERCHANT_FLEET)&&(this.merchantFleetResource!==void 0||this.merchantFleetCommodity!==void 0)}get isMasterMerchantActive(){return this.isProgressCardInPlay(b.PROGRESS_CARD_MASTER_MERCHANT)&&this.masterMerchantTarget!==void 0}get isCraneActive(){return this.isProgressCardInPlay(b.PROGRESS_CARD_CRANE)}get isMedicineActive(){return this.isProgressCardInPlay(b.PROGRESS_CARD_MEDICINE)}static terrainNeedsNumber(r){switch(r){case d.TERRAIN_FOREST:case d.TERRAIN_HILLS:case d.TERRAIN_PASTURE:case d.TERRAIN_FIELDS:case d.TERRAIN_MOUNTAINS:case d.TERRAIN_GOLD:return!0;default:return!1}}static getTerrainResource(r){switch(r){case d.TERRAIN_FOREST:return S.RESOURCE_WOOD;case d.TERRAIN_HILLS:return S.RESOURCE_BRICK;case d.TERRAIN_PASTURE:return S.RESOURCE_SHEEP;case d.TERRAIN_FIELDS:return S.RESOURCE_WHEAT;case d.TERRAIN_MOUNTAINS:return S.RESOURCE_ORE;default:return}}revealFogHex(r){let t=this.options.mapType,o=this.options.seed??0,i=Cr.getBaseMapType(t)??t;if(i!==B.MAP_TYPE_UNSPECIFIED&&(this.options.isDeterministicFog()||Cr.isDeterministicFogMap(t))){let l=Cr.discoverFogFromBaseMap(r,i,o),c=e.getTerrainResource(l.terrain);return{hexLocation:r,revealedTerrain:l.terrain,revealedNumber:l.number,rewardResource:c}}let a;if(this.fogTerrainBank.length>0){let l=this.fogTerrainBank[0];if(e.terrainNeedsNumber(l)&&this.fogNumberBank.length===0){let c=this.fogTerrainBank.find(f=>!e.terrainNeedsNumber(f));c!==void 0?a=c:a=d.TERRAIN_SEA}else a=l}else a=d.TERRAIN_SEA;let s=0;e.terrainNeedsNumber(a)&&this.fogNumberBank.length>0&&(s=this.fogNumberBank[0]);let u=e.getTerrainResource(a);return{hexLocation:r,revealedTerrain:a,revealedNumber:s,rewardResource:u}}};var rY={"4p":[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT],"6p":[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT,d.TERRAIN_DESERT],"8p":[d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FOREST,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_FIELDS,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_PASTURE,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_HILLS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_MOUNTAINS,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_GOLD,d.TERRAIN_GOLD]};var lY=[{hex:new _(2,-3,1),direction:C.SOUTH_WEST},{hex:new _(3,-2,-1),direction:C.SOUTH_WEST},{hex:new _(3,0,-3),direction:C.WEST},{hex:new _(1,2,-3),direction:C.NORTH_WEST},{hex:new _(-1,3,-2),direction:C.NORTH_WEST},{hex:new _(-3,3,0),direction:C.NORTH_EAST},{hex:new _(0,-3,3),direction:C.SOUTH_EAST},{hex:new _(-3,1,2),direction:C.EAST},{hex:new _(-2,-1,3),direction:C.EAST}];var UD=[[new _(2,-2,0),new _(2,-1,-1)],[new _(2,0,-2),new _(1,1,-2)],[new _(0,2,-2),new _(-1,2,-1)],[new _(-2,2,0),new _(-2,1,1)],[new _(-2,0,2),new _(-1,-1,2)],[new _(0,-2,2),new _(1,-2,1)]],BD=[new _(1,-1,0),new _(1,0,-1),new _(0,1,-1),new _(-1,1,0),new _(-1,0,1),new _(0,-1,1)],kD=new _(0,0,0);function bD(e){let r=[],t=[];for(let o=0;o<6;o++){let i=(e+o)%6;r.push(...UD[i]),t.push(BD[i])}return[...r,...t,kD]}E(bD,"getSpiralLocationsFromCorner");var cY=new Map([[d.TERRAIN_FOREST,0],[d.TERRAIN_HILLS,1],[d.TERRAIN_PASTURE,2],[d.TERRAIN_FIELDS,3],[d.TERRAIN_MOUNTAINS,4],[d.TERRAIN_DESERT,5],[d.TERRAIN_GOLD,6],[d.TERRAIN_FOG,7]]),fY=[d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT,d.TERRAIN_GOLD,d.TERRAIN_FOG];var RN=bD(0);var vD=new Map;for(let e=0;e<RN.length;e++)vD.set(RN[e].toString(),e);var TY=[C.NORTH_EAST,C.EAST,C.SOUTH_EAST,C.SOUTH_WEST,C.WEST,C.NORTH_WEST];var DY=[d.TERRAIN_UNSPECIFIED,d.TERRAIN_FOREST,d.TERRAIN_HILLS,d.TERRAIN_PASTURE,d.TERRAIN_FIELDS,d.TERRAIN_MOUNTAINS,d.TERRAIN_DESERT,d.TERRAIN_SEA,d.TERRAIN_GOLD,d.TERRAIN_LAKE_A,d.TERRAIN_LAKE_B,d.TERRAIN_FOG],mY=[C.NORTH_EAST,C.EAST,C.SOUTH_EAST,C.SOUTH_WEST,C.WEST,C.NORTH_WEST];function AN(e){return!e||!e.isChessClock()?9e4:Math.max(6e4,6*e.incrementMs)}E(AN,"takeoverIdleThresholdMs");var wY={[de.DISCARD]:Ve.TIMEOUT_ACTION_DISCARD,[de.SELECT_RESOURCES]:Ve.TIMEOUT_ACTION_SELECT_RESOURCES,[de.PLACE_FREE_STRUCTURE]:Ve.TIMEOUT_ACTION_FREE_ROAD,[de.SELECT_DEFENDER]:Ve.TIMEOUT_ACTION_SELECT_DEFENDER,[de.CITY_PILLAGE]:Ve.TIMEOUT_ACTION_DESTROY_CITY,[de.PLACE_DISPLACED_KNIGHT]:Ve.TIMEOUT_ACTION_MOVE_KNIGHT,[de.GIVE_WEDDING_CARDS]:Ve.TIMEOUT_ACTION_WEDDING_CARDS,[de.COMMERCIAL_HARBOR_EXCHANGE]:Ve.TIMEOUT_ACTION_COMMERCIAL_HARBOR,[de.KNIGHT_COMMITMENT]:Ve.TIMEOUT_ACTION_KNIGHT_COMMITMENT,[de.CHOOSE_DESERTER_KNIGHT]:Ve.TIMEOUT_ACTION_DESERTER_KNIGHT,[de.METROPOLIS_PLACEMENT]:Ve.TIMEOUT_ACTION_METROPOLIS_PLACEMENT,[de.DISCARD_PROGRESS_CARDS]:Ve.TIMEOUT_ACTION_DISCARD_PROGRESS_CARDS,[de.GOOD_NEIGHBORS]:Ve.TIMEOUT_ACTION_GOOD_NEIGHBORS,[de.HELPFUL_NEIGHBORS]:Ve.TIMEOUT_ACTION_HELPFUL_NEIGHBORS,[de.EVENT_CARD_STEAL]:Ve.TIMEOUT_ACTION_EVENT_CARD_STEAL,[de.EARTHQUAKE]:Ve.TIMEOUT_ACTION_EARTHQUAKE,[de.WAGON_VOTING]:Ve.TIMEOUT_ACTION_WAGON_VOTING,[de.SETUP_TURN]:Ve.TIMEOUT_ACTION_SETUP_SETTLEMENT,[de.ROLL_DICE]:Ve.TIMEOUT_ACTION_DICE_ROLL,[de.MOVE_ROBBER]:Ve.TIMEOUT_ACTION_ROBBER_PLACEMENT,[de.CHOOSE_STEAL_VICTIM]:Ve.TIMEOUT_ACTION_ROBBER_STEAL,[de.TAKE_TURN]:Ve.TIMEOUT_ACTION_END_TURN,[de.VOTE_DICE_ROLL]:Ve.TIMEOUT_ACTION_DICE_ROLL};function za(e,r,t,o=Date.now()){if(!e.timerState)return new Ft;let i=e.options.timerConfig;if(!i.isEnabled())return e.timerState;let n=e.timerState.clone();return n.stopPlayerClock(r,o),i.isChessClock()&&(n.addIncrement(r,i),n.addIncrement(t,i)),n.resetActivityBonuses(t),n.startPlayerClock(t,o),n}E(za,"handleTurnTransition");function SN(e,r,t,o,i=Date.now()){if(!e.timerState)return new Ft;if(!e.options.timerConfig.isChessClock())return e.timerState;let a=e.timerState.clone();if(r!==o&&a.stopPlayerClock(r,i),t.length===0){for(let s of a.getPlayers())s!==o&&a.stopPlayerClock(s,i);a.startPlayerClock(o,i)}return a}E(SN,"handleDiscardComplete");function ON(e,r=Date.now()){if(!e.timerState)return new Ft;let t=e.timerState.clone();return t.stopAllClocks(r),t}E(ON,"handleGameWon");function $a(e,r){let t=e.toProto();return t.timerState=r.toProto(),gr.fromProto(t)}E($a,"withTimerState");var cr={rollDice(e){return{type:N.ACTION_TYPE_ROLL_DICE,player:e}},buildRoad(e,r){return{type:N.ACTION_TYPE_BUILD_ROAD,player:e,edge:r}},buildShip(e,r){return{type:N.ACTION_TYPE_BUILD_SHIP,player:e,edge:r}},buildBridge(e,r){return{type:N.ACTION_TYPE_BUILD_BRIDGE,player:e,edge:r}},buyResourceWithGold(e,r){return{type:N.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD,player:e,resource:r}},buyGold(e,r){return{type:N.ACTION_TYPE_BUY_GOLD,player:e,resource:r}},buildSettlement(e,r){return{type:N.ACTION_TYPE_BUILD_SETTLEMENT,player:e,vertex:r}},buildCity(e,r){return{type:N.ACTION_TYPE_BUILD_CITY,player:e,vertex:r}},buyDevCard(e){return{type:N.ACTION_TYPE_BUY_DEV_CARD,player:e}},buyProgressCard(e,r){return{type:N.ACTION_TYPE_BUY_PROGRESS_CARD,player:e,track:r}},playKnight(e,r,t){return{type:N.ACTION_TYPE_PLAY_KNIGHT,player:e,robberLocation:r,targetPlayer:t}},playRoadBuilding(e){return{type:N.ACTION_TYPE_PLAY_ROAD_BUILDING,player:e}},playYearOfPlenty(e){return{type:N.ACTION_TYPE_PLAY_YEAR_OF_PLENTY,player:e}},playMonopoly(e,r){return{type:N.ACTION_TYPE_PLAY_MONOPOLY,player:e,resource:r}},playVictoryPoint(e){return{type:N.ACTION_TYPE_PLAY_VICTORY_POINT,player:e}},proposeTrade(e,r,t,o){return{type:N.ACTION_TYPE_PROPOSE_TRADE,player:e,offering:r,requesting:t,offeringCommodities:o?.offeringCommodities,requestingCommodities:o?.requestingCommodities,offeringGold:o?.offeringGold,requestingGold:o?.requestingGold,counterTradeId:o?.counterTradeId}},proposeMultiTrade(e,r){return{type:N.ACTION_TYPE_PROPOSE_MULTI_TRADE,player:e,proposals:r}},acceptTrade(e,r){return{type:N.ACTION_TYPE_ACCEPT_TRADE,player:e,tradeId:r}},rejectTrade(e,r){return{type:N.ACTION_TYPE_REJECT_TRADE,player:e,tradeId:r}},cancelTrade(e,r){return{type:N.ACTION_TYPE_CANCEL_TRADE,player:e,tradeId:r}},executeTrade(e,r,t){return{type:N.ACTION_TYPE_EXECUTE_TRADE,player:e,tradeId:r,tradePartner:t}},tradeWithBank(e,r,t,o){return{type:N.ACTION_TYPE_TRADE_WITH_BANK,player:e,offering:r,requesting:t,offeringCommodities:o?.offeringCommodities,requestingCommodities:o?.requestingCommodities}},endTurn(e){return{type:N.ACTION_TYPE_END_TURN,player:e}},discardResources(e,r,t){return{type:N.ACTION_TYPE_DISCARD_RESOURCES,player:e,resources:r,commodities:t}},moveRobber(e,r){return{type:N.ACTION_TYPE_MOVE_ROBBER,player:e,location:r}},stealFromPlayer(e,r){return{type:N.ACTION_TYPE_STEAL_FROM_PLAYER,player:e,targetPlayer:r}},selectFreeResource(e,r){return{type:N.ACTION_TYPE_SELECT_FREE_RESOURCE,player:e,resource:r}},placeFreeRoad(e,r){return{type:N.ACTION_TYPE_PLACE_FREE_ROAD,player:e,edge:r}},placeFreeShip(e,r){return{type:N.ACTION_TYPE_PLACE_FREE_SHIP,player:e,edge:r}},placeInitialSettlement(e,r){return{type:N.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT,player:e,vertex:r}},placeInitialRoad(e,r){return{type:N.ACTION_TYPE_PLACE_INITIAL_ROAD,player:e,edge:r}},placeInitialShip(e,r){return{type:N.ACTION_TYPE_PLACE_INITIAL_SHIP,player:e,edge:r}},moveShip(e,r,t){return{type:N.ACTION_TYPE_MOVE_SHIP,player:e,fromEdge:r,toEdge:t}},movePirate(e,r){return{type:N.ACTION_TYPE_MOVE_PIRATE,player:e,location:r}},stealFromPlayerPirate(e,r){return{type:N.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE,player:e,targetPlayer:r}},selectCityToPillage(e,r){return{type:N.ACTION_TYPE_SELECT_CITY_TO_PILLAGE,player:e,cityVertex:r}},selectDefenderProgress(e,r){return{type:N.ACTION_TYPE_SELECT_DEFENDER_PROGRESS,player:e,track:r}},selectAlchemistDice(e,r,t){return{type:N.ACTION_TYPE_SELECT_ALCHEMIST_DICE,player:e,redDie:r,yellowDie:t}},buildKnight(e,r){return{type:N.ACTION_TYPE_BUILD_KNIGHT,player:e,vertex:r}},activateKnight(e,r){return{type:N.ACTION_TYPE_ACTIVATE_KNIGHT,player:e,vertex:r}},promoteKnight(e,r){return{type:N.ACTION_TYPE_PROMOTE_KNIGHT,player:e,vertex:r}},moveKnight(e,r,t){return{type:N.ACTION_TYPE_MOVE_KNIGHT,player:e,fromVertex:r,toVertex:t}},chaseRobberWithKnight(e,r,t,o){return{type:N.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT,player:e,knightVertex:r,newRobberLocation:t,targetPlayer:o}},useKnightErrant(e,r,t,o){return{type:N.ACTION_TYPE_USE_KNIGHT_ERRANT,player:e,knightVertex:r,newRobberLocation:t,targetPlayer:o}},commitKnightsToDefense(e,r){return{type:N.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE,player:e,knightVertices:r}},buildCityWall(e,r){return{type:N.ACTION_TYPE_BUILD_CITY_WALL,player:e,cityVertex:r}},buildCityImprovement(e,r){return{type:N.ACTION_TYPE_BUILD_CITY_IMPROVEMENT,player:e,track:r}},playMining(e){return{type:N.ACTION_TYPE_PLAY_MINING,player:e}},playIrrigation(e){return{type:N.ACTION_TYPE_PLAY_IRRIGATION,player:e}},playAlchemist(e){return{type:N.ACTION_TYPE_PLAY_ALCHEMIST,player:e}},playEngineer(e){return{type:N.ACTION_TYPE_PLAY_ENGINEER,player:e}},playCrane(e){return{type:N.ACTION_TYPE_PLAY_CRANE,player:e}},playMedicine(e){return{type:N.ACTION_TYPE_PLAY_MEDICINE,player:e}},playBishop(e,r){return{type:N.ACTION_TYPE_PLAY_BISHOP,player:e,robberLocation:r}},playProgressRoadBuilding(e){return{type:N.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING,player:e}},playWarlord(e){return{type:N.ACTION_TYPE_PLAY_WARLORD,player:e}},playSmith(e){return{type:N.ACTION_TYPE_PLAY_SMITH,player:e}},playResourceMonopoly(e,r){return{type:N.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY,player:e,resource:r}},playTradeMonopoly(e,r){return{type:N.ACTION_TYPE_PLAY_TRADE_MONOPOLY,player:e,commodity:r}},playInventor(e,r,t){return{type:N.ACTION_TYPE_PLAY_INVENTOR,player:e,hex1:r,hex2:t}},playMerchant(e,r){return{type:N.ACTION_TYPE_PLAY_MERCHANT,player:e,hex:r}},playMerchantFleet(e,r){return{type:N.ACTION_TYPE_PLAY_MERCHANT_FLEET,player:e,resource:r}},playMerchantFleetCommodity(e,r){return{type:N.ACTION_TYPE_PLAY_MERCHANT_FLEET,player:e,commodity:r}},playDeserter(e,r){return{type:N.ACTION_TYPE_PLAY_DESERTER,player:e,targetPlayer:r}},selectDeserterKnight(e,r){return{type:N.ACTION_TYPE_SELECT_DESERTER_KNIGHT,player:e,knightLocation:r}},selectMetropolisCity(e,r){return{type:N.ACTION_TYPE_SELECT_METROPOLIS_CITY,player:e,cityVertex:r}},playDiplomat(e,r){return{type:N.ACTION_TYPE_PLAY_DIPLOMAT,player:e,targetRoad:r}},playIntrigue(e,r,t){return{type:N.ACTION_TYPE_PLAY_INTRIGUE,player:e,targetKnight:r,destination:t}},playSaboteur(e){return{type:N.ACTION_TYPE_PLAY_SABOTEUR,player:e}},playWedding(e){return{type:N.ACTION_TYPE_PLAY_WEDDING,player:e}},giveWeddingCards(e,r,t){return{type:N.ACTION_TYPE_GIVE_WEDDING_CARDS,player:e,resources:r,commodities:t}},playCommercialHarbor(e,r){return{type:N.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR,player:e,selectedTrades:r}},commercialHarborGiveCommodity(e,r){return{type:N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY,player:e,commodity:r}},commercialHarborGiveResource(e,r,t){return{type:N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE,player:e,resource:r,opponent:t}},playSpy(e,r){return{type:N.ACTION_TYPE_PLAY_SPY,player:e,targetPlayer:r}},selectSpyTargetCard(e,r){return{type:N.ACTION_TYPE_SELECT_SPY_TARGET_CARD,player:e,progressCard:r}},playMasterMerchant(e,r){return{type:N.ACTION_TYPE_PLAY_MASTER_MERCHANT,player:e,targetPlayer:r}},selectMasterMerchantCards(e,r,t){return{type:N.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS,player:e,resources:r,commodities:t}},passOldBoot(e,r){return{type:N.ACTION_TYPE_PASS_OLD_BOOT,player:e,targetPlayer:r}},spendFishBanishRobber(e){return{type:N.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER,player:e}},spendFishStealResource(e,r){return{type:N.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE,player:e,targetPlayer:r}},spendFishTakeResource(e){return{type:N.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE,player:e}},spendFishBuildRoad(e){return{type:N.ACTION_TYPE_SPEND_FISH_BUILD_ROAD,player:e}},spendFishDrawDevCard(e){return{type:N.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD,player:e}},resign(e){return{type:N.ACTION_TYPE_RESIGN,player:e}},pause(e){return{type:N.ACTION_TYPE_PAUSE,player:e}},unpause(e){return{type:N.ACTION_TYPE_UNPAUSE,player:e}},voteToContinue(e){return{type:N.ACTION_TYPE_VOTE_TO_CONTINUE,player:e}},selectEarthquakeRoad(e,r){return{type:N.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD,player:e,edge:r}},giveEventCardResource(e,r,t){return{type:N.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE,player:e,targetPlayer:r,resource:t.resource,commodity:t.commodity}},eventCardSteal(e,r){return{type:N.ACTION_TYPE_EVENT_CARD_STEAL,player:e,targetPlayer:r}},wagonVote(e,r,t,o,i){return{type:N.ACTION_TYPE_WAGON_VOTE,player:e,woolBid:r,wheatBid:t,preferredEdge:o,preferredFacing:i}},feedTroll(e,r,t){return{type:N.ACTION_TYPE_FEED_TROLL,player:e,trollHex:r,resources:t}},kickTrollWithKnight(e,r,t){return{type:N.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT,player:e,knightVertex:r,trollHex:t}},voteDiceRoll(e){return{type:N.ACTION_TYPE_VOTE_DICE_ROLL,player:e}},toggleTradeEmbargo(e,r){return{type:N.ACTION_TYPE_TOGGLE_TRADE_EMBARGO,player:e,targetPlayer:r}},discardProgressCard(e,r){return{type:N.ACTION_TYPE_DISCARD_PROGRESS_CARD,player:e,card:r}}};var I_=class{static{E(this,"CoreValidator")}validateRollDice(r,t){let o=t.player;if(r.options.rushMode)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Cannot roll dice in rush mode - dice are automatic");if(r.isSecondSettlerPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Cannot roll dice during second settler phase");if(r.currentPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");if(r.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot roll dice during setup phase");if(!r.pendingDiceRoll)return p(P.VALIDATION_ERROR_DICE_ALREADY_ROLLED,"Dice already rolled this turn");if(r.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");if(r.pendingRobberOrPiratePlacement)return p(P.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST,"Must place robber first");if(r.pendingRobberStealLocation)return p(P.VALIDATION_ERROR_NO_PENDING_STEAL,"Must steal from a player first");let i=rt(r,o);if(!i.valid)return i;let n=tt(r);if(!n.valid)return n;let a=Vt(r,o);return a.valid?Ee():a}validateBuildRoad(r,t){let o=t.player,i=t.edge,n=ze(r,o);if(!n.valid)return n;let a=r.getBrokenRoadsByPlayer(o);if(a.length>0&&!a.some(R=>R.edge.equals(i)))return p(P.VALIDATION_ERROR_ROAD_NOT_CONNECTED,"Must repair broken roads before building new roads");let s=r.getRoadsByPlayer(o).length;if(!r.options.canBuildRoad(s))return p(P.VALIDATION_ERROR_NO_ROADS_REMAINING,`Maximum roads (${r.options.maxRoads}) already built`);let u=r.getPlayerState(o);if(!u)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found");if(!u.hasResourceSet(Md))return p(P.VALIDATION_ERROR_CANNOT_AFFORD_ROAD,"Not enough resources to build road");let l=r.getEdgeBuilding(i);return l&&!(l.isBrokenRoad&&l.owner===o)?p(P.VALIDATION_ERROR_EDGE_OCCUPIED,"Edge already has a building"):i.getAdjacentCenters().some(T=>r.board.hasTile(T))?Ai(r,i)?p(P.VALIDATION_ERROR_ROAD_ON_BRIDGE_SITE,"Roads cannot cross a river - build a bridge there"):nt(r,o,i,F.BUILDING_ROAD)?Ee():p(P.VALIDATION_ERROR_ROAD_NOT_CONNECTED,"Road must be connected to your road/settlement network"):p(P.VALIDATION_ERROR_EDGE_NOT_ON_BOARD,"Edge is not on the board")}validateBuildSettlement(r,t){let o=t.player,i=t.vertex,n=ze(r,o);if(!n.valid)return n;let a=r.getSettlementsByPlayer(o).length;if(!r.options.canBuildSettlement(a))return p(P.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS,`Maximum settlements (${r.options.maxSettlements}) already built`);let s=r.getPlayerState(o);if(!s)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found");if(!s.hasResourceSet(Ld))return p(P.VALIDATION_ERROR_CANNOT_AFFORD_SETTLEMENT,"Not enough resources to build settlement");if(r.hasVertexBuilding(i))return p(P.VALIDATION_ERROR_VERTEX_OCCUPIED,"Vertex already has a building");if(r.board.hasKnight(i))return p(P.VALIDATION_ERROR_VERTEX_OCCUPIED,"Vertex is occupied by a knight");if(!Sl(r,i))return p(P.VALIDATION_ERROR_TOO_CLOSE_TO_SETTLEMENT,"Settlement too close to another settlement/city");if(!Si(r,i))return p(P.VALIDATION_ERROR_VERTEX_NOT_ON_LAND,"Vertex is not on the board");if(!d_(r,o,i))return p(P.VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED,"Settlement must be connected to your road network");if(!Fa(r,i))return p(P.VALIDATION_ERROR_VERTEX_NOT_ON_LAND,"Cannot build settlement adjacent to fog");let u=i.getEdges();for(let l of u){let c=r.getEdgeBuilding(l);if(c?.isBrokenRoad&&c.owner===o)return p(P.VALIDATION_ERROR_ROAD_NOT_CONNECTED,"Cannot build settlement adjacent to your broken road")}return Ee()}validateBuildCity(r,t){let o=t.player,i=t.vertex,n=ze(r,o);if(!n.valid)return n;let a=r.getCitiesByPlayer(o).length;if(!r.options.canBuildCity(a))return p(P.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS,`Maximum cities (${r.options.maxCities}) already built`);let s=r.getPlayerState(o);if(!s)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found");let u=r.isMedicineActive?Ud:Gd;if(!s.hasResourceSet(u))return p(P.VALIDATION_ERROR_CANNOT_AFFORD_CITY,"Not enough resources to build city");let l=r.getVertexBuilding(i);return l?l.owner!==o?p(P.VALIDATION_ERROR_SETTLEMENT_WRONG_OWNER,"Settlement is not yours"):!l.isSettlement&&!l.isBrokenCity?p(P.VALIDATION_ERROR_VERTEX_OCCUPIED,"This is already a city"):l.isSettlement&&r.board.getVertexBuildings().filter(T=>T.owner===o).some(T=>T.isBrokenCity)?p(P.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS,"Must upgrade broken cities before upgrading settlements"):Ee():p(P.VALIDATION_ERROR_NO_SETTLEMENT_AT_LOCATION,"No settlement at this vertex")}validateBuyDevCard(r,t){let o=t.player;if(r.options.citiesAndKnights)return p(P.VALIDATION_ERROR_NO_DEV_CARDS_LEFT,"Cannot buy development cards in Cities & Knights - use city improvements instead");let i=ze(r,o);if(!i.valid)return i;let n=r.getPlayerState(o);return n?n.hasResourceSet(Wa)?r.hasDevCardsInDeck()?Ee():p(P.VALIDATION_ERROR_NO_DEV_CARDS_LEFT,"No development cards left in deck"):p(P.VALIDATION_ERROR_CANNOT_AFFORD_DEV_CARD,"Not enough resources to buy development card"):p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found")}validateBuyProgressCard(r,t){let o=t.player;if(!r.options.citiesAndKnights||!r.options.fisherman)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Buy progress card requires both Cities & Knights and Fisherman expansions");let i=ze(r,o);if(!i.valid)return i;let n=r.getPlayerState(o);if(!n)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found");if(!n.hasResourceSet(Wa))return p(P.VALIDATION_ERROR_CANNOT_AFFORD_DEV_CARD,"Not enough resources to buy progress card");if(n.totalProgressCards>=xt)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Cannot hold more than 4 progress cards");let a;switch(t.track){case K.CITY_IMPROVEMENT_TRACK_SCIENCE:a=r.scienceProgressDeck.length;break;case K.CITY_IMPROVEMENT_TRACK_POLITICS:a=r.politicsProgressDeck.length;break;case K.CITY_IMPROVEMENT_TRACK_TRADE:a=r.tradeProgressDeck.length;break;default:return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Invalid progress card track")}return a===0?p(P.VALIDATION_ERROR_NO_DEV_CARDS_LEFT,"Selected progress card deck is empty"):Ee()}validateEndTurn(r,t){let o=t.player;if(r.options.rushMode)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Cannot end turn in rush mode - rounds end automatically on dice roll");if(r.isSecondSettlerPhase){if(r.secondSettlerPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Only the paired player can end the second settler turn");if(r.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");if(r.totalPendingFreeResources>0)return p(P.VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES,"All players must select their free resources first");if(r.hasPendingFreeStructures(o)&&r.getPendingFreeStructures(o).some(f=>At(r,o,f)))return p(P.VALIDATION_ERROR_MUST_PLACE_FREE_ROADS,"Must place free structures first");let s=Pd(r,o);if(!s.valid)return s;let u=Vt(r,o);return u.valid?Ee():u}if(r.currentPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");if(r.isSetupPhase)return p(P.VALIDATION_ERROR_CANNOT_END_TURN_SETUP,"Cannot end turn during setup phase");if(r.pendingDiceRoll)return p(P.VALIDATION_ERROR_MUST_ROLL_DICE_FIRST,"Must roll dice before ending turn");if(r.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");if(r.pendingRobberOrPiratePlacement)return p(P.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST,"Must place robber first");if(r.pendingRobberStealLocation)return p(P.VALIDATION_ERROR_NO_PENDING_STEAL,"Must steal from a player first");if(r.totalPendingFreeResources>0)return p(P.VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES,"All players must select their free resources first");if(r.hasPendingFreeStructures(o)&&r.getPendingFreeStructures(o).some(l=>At(r,o,l)))return p(P.VALIDATION_ERROR_MUST_PLACE_FREE_ROADS,"Must place free structures first");let i=Pd(r,o);if(!i.valid)return i;let n=tt(r);if(!n.valid)return n;let a=Vt(r,o);return a.valid?Ee():a}validateDiscardResources(r,t){let o=t.player,i=r.getPendingDiscards(o);if(i===0)return p(P.VALIDATION_ERROR_NO_PENDING_DISCARD,"You don't need to discard");let n=r.getPlayerState(o);if(!n)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found");let a=r.options.citiesAndKnights?n.totalResourcesInHand+n.totalCommoditiesInHand:n.totalResourcesInHand,s=Math.min(i,a),u=Array.from(t.resources.values()).reduce((f,T)=>f+T,0),l=t.commodities?Array.from(t.commodities.values()).reduce((f,T)=>f+T,0):0,c=u+l;return c!==s?a<i?p(P.VALIDATION_ERROR_WRONG_DISCARD_COUNT,`Must discard all ${a} cards (you have fewer than the required ${i})`):p(P.VALIDATION_ERROR_WRONG_DISCARD_COUNT,`Must discard exactly ${i} cards, discarding ${c}`):n.hasResourceSet(t.resources)?t.commodities&&!n.hasCommoditySet(t.commodities)?p(P.VALIDATION_ERROR_TRADE_RESOURCES_NOT_OWNED,"You don't have the commodities you're trying to discard"):Ee():p(P.VALIDATION_ERROR_TRADE_RESOURCES_NOT_OWNED,"You don't have the resources you're trying to discard")}validateMoveRobber(r,t){let o=t.player;if(r.options.rushMode){if(r.rushRobberPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Only the designated robber player can move the robber in rush mode")}else if(r.isSecondSettlerPhase){if(r.secondSettlerPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn")}else if(r.currentPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");if(!r.pendingRobberOrPiratePlacement)return p(P.VALIDATION_ERROR_NO_PENDING_ROBBER,"Robber placement not required");if(r.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"All players must discard first");if(r.board.barbarians&&!r.board.barbarians.canMoveRobber())return p(P.VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS,"Robber cannot be moved until after the first barbarian attack");let i=t.location,n=r.board.robbers;for(let a of n)if(a.equals(i))return p(P.VALIDATION_ERROR_ROBBER_MUST_MOVE,"Robber must move to a different tile");if(!r.board.hasTile(i))return p(P.VALIDATION_ERROR_INVALID_HEX_LOCATION,"Invalid robber location");if(r.board.hasTroll(i))return p(P.VALIDATION_ERROR_ROBBER_BLOCKED_BY_TROLL,"Cannot place robber on hex with troll");if(r.options.robberMode===zr.ROBBER_MODE_FRIENDLY){let a=u_(r),s=r.getPlayersOnTile(i);for(let u of s)if(r.getVisibleVictoryPoints(u)<=a)return p(P.VALIDATION_ERROR_FRIENDLY_ROBBER_BLOCKED,"Cannot block players with starting victory points in friendly mode")}if(r.options.robberLockedToBiggestIsland){let a=Va(r.board,r.options.desertsBlockIslands);if(!a||a.length===0)return p(P.VALIDATION_ERROR_INVALID_HEX_LOCATION,"No valid island for robber placement");if(!a.some(u=>u.equals(i)))return p(P.VALIDATION_ERROR_ROBBER_NOT_ON_BIGGEST_ISLAND,"Robber must be placed on the biggest island")}return Ee()}validateStealFromPlayer(r,t){let o=t.player;if(r.options.rushMode){if(r.rushRobberPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Only the designated robber player can steal in rush mode")}else if(r.isSecondSettlerPhase){if(r.secondSettlerPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn")}else if(r.currentPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");if(!r.pendingRobberStealLocation)return p(P.VALIDATION_ERROR_NO_PENDING_STEAL,"Stealing not required");if(t.targetPlayer===o)return p(P.VALIDATION_ERROR_INVALID_STEAL_TARGET,"Cannot steal from yourself");let i=r.board.robbers;if(i.length===0)return p(P.VALIDATION_ERROR_ROBBER_NO_LOCATION,"No robber on board");let n=!1;for(let a of i)if(r.getPlayersOnTile(a).includes(t.targetPlayer)){n=!0;break}return n?Ee():p(P.VALIDATION_ERROR_INVALID_STEAL_TARGET,"Target player has no buildings adjacent to the robber")}validateSelectFreeResource(r,t){let o=t.player;return r.hasPendingFreeResources(o)?r.hasResourcesInDeck(t.resource,1)?t.resource===S.RESOURCE_UNSPECIFIED?p(P.VALIDATION_ERROR_MUST_SPECIFY_RESOURCE,"Must specify a resource"):Ee():p(P.VALIDATION_ERROR_BANK_EMPTY,"Bank doesn't have this resource"):p(P.VALIDATION_ERROR_NO_PENDING_FREE_RESOURCES,"No free resources to select")}validatePlaceFreeRoad(r,t){let o=t.player,i=t.edge,n=r.getPendingFreeStructures(o);if(!n.includes(F.BUILDING_ROAD)&&!n.includes(F.BUILDING_ROAD_OR_SHIP))return p(P.VALIDATION_ERROR_NO_PENDING_FREE_ROADS,"No free road to place");let a=r.getBrokenRoadsByPlayer(o);if(a.length>0&&!a.some(T=>T.edge.equals(i)))return p(P.VALIDATION_ERROR_ROAD_NOT_CONNECTED,"Must repair broken roads before placing free roads");let s=r.getEdgeBuilding(i),u=s?.isBrokenRoad&&s.owner===o;if(!u){let f=r.getRoadsByPlayer(o).length;if(!r.options.canBuildRoad(f))return p(P.VALIDATION_ERROR_NO_ROADS_REMAINING,`Maximum roads (${r.options.maxRoads}) already built`)}return s&&!u?p(P.VALIDATION_ERROR_EDGE_OCCUPIED,"Edge already has a building"):i.getAdjacentCenters().some(f=>r.board.hasTile(f))?Ai(r,i)?p(P.VALIDATION_ERROR_ROAD_ON_BRIDGE_SITE,"Roads cannot cross a river - build a bridge there"):nt(r,o,i,F.BUILDING_ROAD)?Ee():p(P.VALIDATION_ERROR_ROAD_NOT_CONNECTED,"Road must be connected to your road/settlement network"):p(P.VALIDATION_ERROR_EDGE_NOT_ON_BOARD,"Edge is not on the board")}validatePlaceInitialSettlement(r,t){let o=t.player,i=t.vertex;if(!r.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_NORMAL,"Not in setup phase");if(r.currentPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");let n=r.getSettlementsByPlayer(o),a=r.getCitiesByPlayer(o),s=n.length+a.length,u=r.getRoadsByPlayer(o),l=r.getShipsByPlayer(o),c=u.length+l.length;if(s>c)return p(P.VALIDATION_ERROR_ROAD_NOT_CONNECTED,"Must place road after settlement");let f=n.length;if(!r.options.canBuildSettlement(f))return p(P.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS,`Maximum settlements (${r.options.maxSettlements}) already built`);if(r.hasVertexBuilding(i))return p(P.VALIDATION_ERROR_VERTEX_OCCUPIED,"Vertex already has a building");if(r.board.hasKnight(i))return p(P.VALIDATION_ERROR_VERTEX_OCCUPIED,"Vertex is occupied by a knight");if(!Sl(r,i))return p(P.VALIDATION_ERROR_TOO_CLOSE_TO_SETTLEMENT,"Settlement too close to another settlement/city");if(!Si(r,i))return p(P.VALIDATION_ERROR_VERTEX_NOT_ON_LAND,"Vertex is not on the board");if(!Fa(r,i))return p(P.VALIDATION_ERROR_VERTEX_NOT_ON_LAND,"Cannot build settlement adjacent to fog");if(!__(r,i))return p(P.VALIDATION_ERROR_ROAD_ON_BRIDGE_SITE,"No road can be built from here - every edge crosses a river");let T=s+1,R=T===1?r.options.firstSettleMode:r.options.secondSettleMode;if(r.options.restrictFoundingToLargestIsland||R!==tr.SETUP_PLACEMENT_MODE_NORMAL){let I=XT(r,o,T);if(!I.some(D=>D.equals(i))){if(r.options.restrictFoundingToLargestIsland){let g=Va(r.board,!1);if(g&&g.length>0){let k=new Set(g.map(V=>V.toString())),v=E(V=>V.getHexCenters().some(w=>k.has(w.toString())),"onLargestIsland");if(I.length>0&&I.every(v)&&!v(i))return p(P.VALIDATION_ERROR_VERTEX_NOT_ON_LAND,"Settlement must be on the largest island")}}let D={[tr.SETUP_PLACEMENT_MODE_NORMAL]:"",[tr.SETUP_PLACEMENT_MODE_COASTAL]:"Settlement must be adjacent to water",[tr.SETUP_PLACEMENT_MODE_INLAND]:"Settlement must not be adjacent to water",[tr.SETUP_PLACEMENT_MODE_PORT]:"Settlement must have port access",[tr.SETUP_PLACEMENT_MODE_DESERT]:"Settlement must be adjacent to a desert",[tr.SETUP_PLACEMENT_MODE_DIFFERENT_ISLAND]:"Settlement must be on a different island",[tr.SETUP_PLACEMENT_MODE_HIGHEST_PRODUCTION]:"Settlement must be at highest production location",[tr.SETUP_PLACEMENT_MODE_SKIP]:"This settlement placement is skipped",[tr.UNRECOGNIZED]:"Invalid placement mode"};return p(P.VALIDATION_ERROR_VERTEX_NOT_ON_LAND,D[R]||"Invalid settlement location for placement mode")}}return Ee()}validatePlaceInitialRoad(r,t){let o=t.player,i=t.edge;if(!r.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_NORMAL,"Not in setup phase");if(r.currentPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");let n=r.getRoadsByPlayer(o).length;if(!r.options.canBuildRoad(n))return p(P.VALIDATION_ERROR_NO_ROADS_REMAINING,`Maximum roads (${r.options.maxRoads}) already built`);if(r.hasEdgeBuilding(i))return p(P.VALIDATION_ERROR_EDGE_OCCUPIED,"Edge already has a building");if(!i.getAdjacentCenters().some(O=>r.board.hasTile(O)))return p(P.VALIDATION_ERROR_EDGE_NOT_ON_BOARD,"Edge is not on the board");if(Ai(r,i))return p(P.VALIDATION_ERROR_ROAD_ON_BRIDGE_SITE,"Roads cannot cross a river - build a bridge there");let u=r.getVertexBuildingsByPlayer(o);if(u.length===0)return p(P.VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED,"Must place settlement first");let l=r.getRoadsByPlayer(o),c=r.getShipsByPlayer(o),T=l.length+c.length,R=u[T];return R?i.hasVertex(R.vertex)?Ee():p(P.VALIDATION_ERROR_ROAD_NOT_CONNECTED,"Initial road must be adjacent to your settlement"):p(P.VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED,"Must place settlement first")}validatePlaceInitialShip(r,t){let o=t.player,i=t.edge;if(!r.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_NORMAL,"Not in setup phase");if(!r.options.seafarers)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Ships are not enabled");if(r.currentPlayer!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Not your turn");let n=r.getShipsByPlayer(o).length;if(!r.options.canBuildShip(n))return p(P.VALIDATION_ERROR_NO_ROADS_REMAINING,`Maximum ships (${r.options.maxShips}) already built`);if(r.hasEdgeBuilding(i))return p(P.VALIDATION_ERROR_EDGE_OCCUPIED,"Edge already has a building");if(!i.getAdjacentCenters().some(O=>!r.board.hasTile(O)||r.board.getTile(O)?.terrain===d.TERRAIN_SEA))return p(P.VALIDATION_ERROR_EDGE_NOT_ON_BOARD,"Ship must be adjacent to water");let u=r.getVertexBuildingsByPlayer(o);if(u.length===0)return p(P.VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED,"Must place settlement first");let l=r.getRoadsByPlayer(o),c=r.getShipsByPlayer(o),T=l.length+c.length,R=u[T];return R?i.hasVertex(R.vertex)?Ee():p(P.VALIDATION_ERROR_ROAD_NOT_CONNECTED,"Initial ship must be adjacent to your settlement"):p(P.VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED,"Must place settlement first")}validateResign(r,t){let o=t.player;return r.winner!==void 0?p(P.VALIDATION_ERROR_GAME_OVER,"Game is already over"):r.isSetupPhase?p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot resign during setup phase"):r.turnOrder.length!==2?p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Resign is only available in 1v1 matches"):r.turnOrder.includes(o)?Ee():p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"You are not a player in this game")}validatePause(r,t){let o=t.player,i=r.options.pauseConfig;if(r.winner!==void 0)return p(P.VALIDATION_ERROR_GAME_OVER,"Cannot pause a finished game");if(r.paused)return p(P.VALIDATION_ERROR_GAME_PAUSED,"Game is already paused");if(!r.turnOrder.includes(o))return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"You are not a player in this game");if(!i.isPausingEnabled())return p(P.VALIDATION_ERROR_GAME_PAUSED,"Pausing is not enabled for this game");let n=r.pauseState?.getPauseCount(o)??0;return i.canPlayerPause(n)?Ee():p(P.VALIDATION_ERROR_GAME_PAUSED,"You have used all your pauses")}validateUnpause(r,t){let o=t.player;return r.paused?r.turnOrder.includes(o)?Ee():p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"You are not a player in this game"):p(P.VALIDATION_ERROR_GAME_PAUSED,"Game is not paused")}validateVoteToContinue(r,t){let o=t.player;return r.paused?r.turnOrder.includes(o)?r.pauseState?.hasVoted(o)?p(P.VALIDATION_ERROR_GAME_PAUSED,"You have already voted to continue"):Ee():p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"You are not a player in this game"):p(P.VALIDATION_ERROR_GAME_PAUSED,"Game is not paused")}validateVoteDiceRoll(r,t){let o=t.player;if(!r.options.rushMode)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Vote dice roll is only available in rush mode");if(r.isSetupPhase)return p(P.VALIDATION_ERROR_WRONG_PHASE_SETUP,"Cannot vote for dice roll during setup phase");if(r.paused)return p(P.VALIDATION_ERROR_GAME_PAUSED,"Cannot vote for dice roll while game is paused");if(r.winner!==void 0)return p(P.VALIDATION_ERROR_GAME_OVER,"Game is already over");if(r.hasPendingDiscardsAny)return p(P.VALIDATION_ERROR_MUST_DISCARD_FIRST,"Players must discard first");let i=tt(r);if(!i.valid)return i;if(r.rushRobberPlayer===o){if(r.pendingRobberOrPiratePlacement)return p(P.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST,"Must move robber/pirate before voting");if(r.pendingRobberStealLocation||r.pendingPirateStealLocation)return p(P.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST,"Must complete steal before voting")}return r.rushDiceVotes.has(o)?p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Already voted for dice roll"):r.turnOrder.includes(o)?Ee():p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"You are not a player in this game")}};var C_=class{static{E(this,"DevCardsValidator")}validatePlayKnight(r,t){let o=t.player;if(r.options.rushMode){if(r.isSetupPhase)return{valid:!1,error:"Cannot play dev cards during setup phase"};let a=r.getPlayerState(o);if(!a)return{valid:!1,error:"Player state not found"};if(a.getUnplayedDevCardCount(ie.DEV_CARD_KNIGHT)===0)return{valid:!1,error:"No knight cards to play"};if(r.rushPlayedDevCard.has(o))return{valid:!1,error:"Already played a development card this round"};if(r.hasPendingDiscardsAny)return{valid:!1,error:"Players must discard first"};if(r.pendingRobberOrPiratePlacement)return{valid:!1,error:"Robber placement already pending"};if(r.pendingRobberStealLocation||r.pendingPirateStealLocation)return{valid:!1,error:"Robber steal already pending"}}else{if(r.isSecondSettlerPhase){if(r.secondSettlerPlayer!==o)return{valid:!1,error:"Not your turn"}}else if(r.currentPlayer!==o)return{valid:!1,error:"Not your turn"};if(r.isSetupPhase)return{valid:!1,error:"Cannot play dev cards during setup phase"};let a=r.getPlayerState(o);if(!a)return{valid:!1,error:"Player state not found"};if(a.getUnplayedDevCardCount(ie.DEV_CARD_KNIGHT)===0)return{valid:!1,error:"No knight cards to play"};if(r.playedDevCardThisTurn)return{valid:!1,error:"Already played a development card this turn"};if(r.hasPendingDiscardsAny)return{valid:!1,error:"Players must discard first"};if(r.pendingRobberOrPiratePlacement)return{valid:!1,error:"Robber placement already pending"};if(r.pendingRobberStealLocation)return{valid:!1,error:"Robber steal already pending"}}if(r.options.rushMode){if(r.hasPendingFreeResources(o))return{valid:!1,error:"Must select free resources first"};if(r.hasPendingFreeStructures(o))return{valid:!1,error:"Must place free structures first"}}else{let a=rt(r,o);if(!a.valid)return a}let i=tt(r);if(!i.valid)return i;let n=t.robberLocation;if(n){if(r.board.hasRobber(n))return{valid:!1,error:"Robber must move to a different tile"};if(!r.board.hasTile(n))return{valid:!1,error:"Invalid robber location"};if(t.targetPlayer!==void 0){if(!r.getPlayersOnTile(n).includes(t.targetPlayer))return{valid:!1,error:"Target player has no buildings on this tile"};if(t.targetPlayer===o)return{valid:!1,error:"Cannot steal from yourself"}}}return{valid:!0}}validatePlayRoadBuilding(r,t){let o=t.player,i=this.checkDevCardRequirements(r,o,ie.DEV_CARD_ROAD_BUILDING);return i.valid?At(r,o,it(r))?{valid:!0}:{valid:!1,error:"Cannot play Road Building: no roads or ships available to place"}:i}validatePlayYearOfPlenty(r,t){let o=t.player,i=this.checkDevCardRequirements(r,o,ie.DEV_CARD_YEAR_OF_PLENTY);return i.valid?{valid:!0}:i}validatePlayMonopoly(r,t){let o=t.player,i=this.checkDevCardRequirements(r,o,ie.DEV_CARD_MONOPOLY);return i.valid?t.resource===S.RESOURCE_UNSPECIFIED?{valid:!1,error:"Must specify a resource for monopoly"}:{valid:!0}:i}validatePlayVictoryPoint(r,t){return{valid:!1,error:"Victory point cards are revealed at end of game"}}checkDevCardRequirements(r,t,o){if(r.options.rushMode){if(r.isSetupPhase)return{valid:!1,error:"Cannot play dev cards during setup phase"};let a=r.getPlayerState(t);return a?a.getUnplayedDevCardCount(o)===0?{valid:!1,error:"No such development card to play"}:r.rushPlayedDevCard.has(t)&&o!==ie.DEV_CARD_VICTORY_POINT?{valid:!1,error:"Already played a development card this round"}:r.hasPendingDiscardsAny?{valid:!1,error:"Players must discard first"}:r.hasPendingFreeResources(t)?{valid:!1,error:"Must select free resources first"}:r.hasPendingFreeStructures(t)?{valid:!1,error:"Must place free structures first"}:tt(r):{valid:!1,error:"Player state not found"}}if(r.isSecondSettlerPhase){if(r.secondSettlerPlayer!==t)return{valid:!1,error:"Not your turn"}}else if(r.currentPlayer!==t)return{valid:!1,error:"Not your turn"};if(r.isSetupPhase)return{valid:!1,error:"Cannot play dev cards during setup phase"};let i=r.getPlayerState(t);if(!i)return{valid:!1,error:"Player state not found"};if(i.getUnplayedDevCardCount(o)===0)return{valid:!1,error:"No such development card to play"};if(r.playedDevCardThisTurn&&o!==ie.DEV_CARD_VICTORY_POINT)return{valid:!1,error:"Already played a development card this turn"};if(r.hasPendingDiscardsAny)return{valid:!1,error:"Players must discard first"};if(r.pendingRobberOrPiratePlacement)return{valid:!1,error:"Robber placement already pending"};if(r.pendingRobberStealLocation)return{valid:!1,error:"Robber steal already pending"};let n=rt(r,t);return n.valid?tt(r):n}};var P_=class{static{E(this,"TradingValidator")}validateProposeTrade(r,t){let o=t.player,i=(t.counterTradeId??0)>0;if(r.options.tradeMode===$r.TRADE_MODE_BANK_ONLY)return p(P.VALIDATION_ERROR_PLAYER_TRADES_DISABLED,"Player trades are disabled in bank-only trading mode");if(r.isSecondSettlerPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Cannot trade with players during second settler phase");if(i){if(r.options.disableCounterOffers)return p(P.VALIDATION_ERROR_COUNTER_OFFERS_DISABLED,"Counter offers are turned off in this game");if(r.isSetupPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Cannot trade during setup phase");let I=r.getActiveTrade(t.counterTradeId);if(!I)return p(P.VALIDATION_ERROR_TRADE_NOT_FOUND,"Referenced trade not found");if(I.proposer===o)return p(P.VALIDATION_ERROR_CANNOT_ACCEPT_OWN_TRADE,"Cannot counter-offer your own trade");if(!r.turnOrder.includes(o))return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Player not in this game")}else{let I=va(r,o);if(!I.valid)return I}let n=r.getPlayerState(o);if(!n)return{valid:!1,error:"Player state not found"};if(!n.hasResourceSet(t.offering))return{valid:!1,error:"You don't have the resources you're offering"};let a=IN(t.offeringGold,t.requestingGold);if(!a.valid)return a;let s=Array.from(t.offering.values()).reduce((I,D)=>I+D,0),u=t.offeringCommodities?Array.from(t.offeringCommodities.values()).reduce((I,D)=>I+D,0):0,l=t.offeringGold??0,c=s+u+l,f=Array.from(t.requesting.values()).reduce((I,D)=>I+D,0),T=t.requestingCommodities?Array.from(t.requestingCommodities.values()).reduce((I,D)=>I+D,0):0,R=t.requestingGold??0,O=f+T+R;if(c===0||O===0)return{valid:!1,error:"Trade must offer and request something"};for(let[I]of t.offering)if(t.requesting.has(I)&&(t.requesting.get(I)??0)>0)return p(P.VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE,"Cannot trade for the same resource you're offering");if(t.offeringCommodities&&t.requestingCommodities){for(let[I]of t.offeringCommodities)if(t.requestingCommodities.has(I)&&(t.requestingCommodities.get(I)??0)>0)return p(P.VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE,"Cannot trade for the same commodity you're offering")}return(t.offeringGold??0)>0&&(t.requestingGold??0)>0?p(P.VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE,"Cannot trade gold for gold"):t.offeringCommodities&&!n.hasCommoditySet(t.offeringCommodities)?p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You don't have the commodities you're offering"):(t.offeringGold??0)>n.gold?p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You don't have the gold you're offering"):{valid:!0}}validateProposeMultiTrade(r,t){let o=t.player;if(r.options.tradeMode===$r.TRADE_MODE_BANK_ONLY)return p(P.VALIDATION_ERROR_PLAYER_TRADES_DISABLED,"Player trades are disabled in bank-only trading mode");if(r.isSecondSettlerPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Cannot trade with players during second settler phase");let i=va(r,o);if(!i.valid)return i;if(t.proposals.length===0||t.proposals.length>5)return{valid:!1,error:"Must propose between 1 and 5 trades"};let n=r.getPlayerState(o);if(!n)return{valid:!1,error:"Player state not found"};for(let l of t.proposals){let c=IN(l.offeringGold,l.requestingGold);if(!c.valid)return c;let f=Array.from(l.offering.values()).reduce((v,Y)=>v+Y,0),T=l.offeringCommodities?Array.from(l.offeringCommodities.values()).reduce((v,Y)=>v+Y,0):0,R=l.offeringGold??0,O=f+T+R,I=Array.from(l.requesting.values()).reduce((v,Y)=>v+Y,0),D=l.requestingCommodities?Array.from(l.requestingCommodities.values()).reduce((v,Y)=>v+Y,0):0,g=l.requestingGold??0,k=I+D+g;if(O===0||k===0)return{valid:!1,error:"Each trade must offer and request something"};for(let[v]of l.offering)if(l.requesting.has(v)&&(l.requesting.get(v)??0)>0)return p(P.VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE,"Cannot trade for the same resource you're offering");if(l.offeringCommodities&&l.requestingCommodities){for(let[v]of l.offeringCommodities)if(l.requestingCommodities.has(v)&&(l.requestingCommodities.get(v)??0)>0)return p(P.VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE,"Cannot trade for the same commodity you're offering")}if((l.offeringGold??0)>0&&(l.requestingGold??0)>0)return p(P.VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE,"Cannot trade gold for gold")}let a=new Map;for(let l of t.proposals)for(let[c,f]of l.offering)a.set(c,(a.get(c)??0)+f);if(!n.hasResourceSet(a))return{valid:!1,error:"You don't have enough resources for all combined offerings"};let s=new Map,u=0;for(let l of t.proposals){for(let[c,f]of l.offeringCommodities??[])s.set(c,(s.get(c)??0)+f);u+=l.offeringGold??0}return n.hasCommoditySet(s)?u>n.gold?p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You don't have enough gold for all combined offerings"):{valid:!0}:p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You don't have enough commodities for all combined offerings")}validateAcceptTrade(r,t){let o=t.player;if(r.options.tradeMode===$r.TRADE_MODE_BANK_ONLY)return p(P.VALIDATION_ERROR_PLAYER_TRADES_DISABLED,"Player trades are disabled in bank-only trading mode");if(r.isSecondSettlerPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Cannot trade with players during second settler phase");let i=r.getActiveTrade(t.tradeId);if(!i)return{valid:!1,error:"Trade not found"};if(i.proposer===o)return{valid:!1,error:"Cannot accept your own trade"};if(i.hasRejectedPlayer(o))return{valid:!1,error:"Cannot accept a trade you have rejected"};let n=r.getPlayerState(o);return n?n.hasResourceSet(i.requesting)?i.requestingCommodities&&!n.hasCommoditySet(i.requestingCommodities)?{valid:!1,error:"You don't have the commodities requested"}:i.requestingGold>n.gold?p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You don't have the gold requested"):{valid:!0}:{valid:!1,error:"You don't have the resources requested"}:{valid:!1,error:"Player state not found"}}validateRejectTrade(r,t){let o=t.player;if(r.options.tradeMode===$r.TRADE_MODE_BANK_ONLY)return p(P.VALIDATION_ERROR_PLAYER_TRADES_DISABLED,"Player trades are disabled in bank-only trading mode");if(r.isSecondSettlerPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Cannot trade with players during second settler phase");let i=r.getActiveTrade(t.tradeId);return i?i.proposer===o?{valid:!1,error:"Cannot reject your own trade (use cancel)"}:{valid:!0}:{valid:!1,error:"Trade not found"}}validateCancelTrade(r,t){let o=t.player;if(r.options.tradeMode===$r.TRADE_MODE_BANK_ONLY)return p(P.VALIDATION_ERROR_PLAYER_TRADES_DISABLED,"Player trades are disabled in bank-only trading mode");let i=r.getActiveTrade(t.tradeId);return i?i.proposer!==o&&r.currentPlayer!==o?{valid:!1,error:"Can only cancel your own trades"}:{valid:!0}:{valid:!1,error:"Trade not found"}}validateExecuteTrade(r,t){let o=t.player;if(r.options.tradeMode===$r.TRADE_MODE_BANK_ONLY)return p(P.VALIDATION_ERROR_PLAYER_TRADES_DISABLED,"Player trades are disabled in bank-only trading mode");if(r.isSecondSettlerPhase)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Cannot trade with players during second settler phase");if(!r.options.rushMode&&r.currentPlayer!==o)return{valid:!1,error:"Not your turn"};let i=r.getActiveTrade(t.tradeId);if(!i)return{valid:!1,error:"Trade not found"};if(i.counterTradeId>0){if(i.proposer===o)return{valid:!1,error:"Cannot execute your own counter-offer"};if(t.tradePartner!==i.proposer)return{valid:!1,error:"Trade partner must be the counter-offer proposer"}}else if(i.proposer!==o)return{valid:!1,error:"Can only execute your own trades"};if(r.hasEmbargo(o,t.tradePartner)||r.hasEmbargo(t.tradePartner,o))return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Cannot execute trade with embargoed player");if(!i.hasAcceptingPlayer(t.tradePartner))return{valid:!1,error:"Selected player has not accepted the trade"};if(i.counterTradeId>0){let n=r.getPlayerState(i.proposer),a=r.getPlayerState(o);if(!n||!a)return p(P.VALIDATION_ERROR_TRADE_NOT_FOUND,"Player state not found");if(!n.hasResourceSet(i.offering))return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"Counter-offerer no longer has the offered resources");if(i.offeringCommodities&&!n.hasCommoditySet(i.offeringCommodities))return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"Counter-offerer no longer has the offered commodities");if(!a.hasResourceSet(i.requesting))return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You no longer have the requested resources");if(i.requestingCommodities&&!a.hasCommoditySet(i.requestingCommodities))return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You no longer have the requested commodities");if(i.offeringGold>n.gold)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"Counter-offerer no longer has the offered gold");if(i.requestingGold>a.gold)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You no longer have the requested gold")}else{let n=r.getPlayerState(i.proposer),a=r.getPlayerState(t.tradePartner);if(!n||!a)return{valid:!1,error:"Player state not found"};if(!n.hasResourceSet(i.offering))return{valid:!1,error:"You no longer have the offered resources"};if(i.offeringCommodities&&!n.hasCommoditySet(i.offeringCommodities))return{valid:!1,error:"You no longer have the offered commodities"};if(!a.hasResourceSet(i.requesting))return{valid:!1,error:"Trade partner no longer has the requested resources"};if(i.requestingCommodities&&!a.hasCommoditySet(i.requestingCommodities))return{valid:!1,error:"Trade partner no longer has the requested commodities"};if(i.offeringGold>n.gold)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You no longer have the offered gold");if(i.requestingGold>a.gold)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"Trade partner no longer has the requested gold")}return{valid:!0}}validateTradeWithBank(r,t){let o=t.player,i=ze(r,o);if(!i.valid)return i;let n=QT(r,o,t.offering,t.requesting,t.offeringCommodities,t.requestingCommodities);return n.valid?{valid:!0}:{valid:!1,error:n.error??"Invalid bank trade"}}validateToggleTradeEmbargo(r,t){let o=t.player;return r.isSetupPhase?{valid:!1,error:"Cannot set trade embargo during setup"}:r.turnOrder.includes(o)?r.turnOrder.includes(t.targetPlayer)?o===t.targetPlayer?p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Cannot embargo yourself"):Ee():p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Target player not in this game"):p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"Player not in this game")}};function IN(e,r){for(let t of[e??0,r??0])if(t<0||!Number.isInteger(t))return p(P.VALIDATION_ERROR_UNSPECIFIED,"Gold amounts must be non-negative whole numbers");return Ee()}E(IN,"checkGoldAmounts");var p_=class{static{E(this,"SeafarersValidator")}validateBuildShip(r,t){if(!r.options.seafarers)return{valid:!1,error:"Ships require the Seafarers expansion"};let o=t.player,i=t.edge,n=ze(r,o);if(!n.valid)return n;let a=r.getShipsByPlayer(o).length;if(!r.options.canBuildShip(a))return{valid:!1,error:`Maximum ships (${r.options.maxShips}) already built`};let s=r.getPlayerState(o);return s?s.hasResourceSet(Bd)?r.hasEdgeBuilding(i)?{valid:!1,error:"Edge already has a building"}:i.getAdjacentCenters().some(c=>r.board.isSea(c))?r.board.isEdgeAdjacentToPirate(i)?{valid:!1,error:"Ships cannot be built next to the pirate"}:nt(r,o,i,F.BUILDING_SHIP)?{valid:!0}:{valid:!1,error:"Ship must be connected to your ship/settlement network"}:{valid:!1,error:"Ships must be built adjacent to sea"}:{valid:!1,error:"Not enough resources to build ship"}:{valid:!1,error:"Player state not found"}}validatePlaceFreeShip(r,t){if(!r.options.seafarers)return{valid:!1,error:"Ships require the Seafarers expansion"};let o=t.player,i=t.edge,n=r.getPendingFreeStructures(o);if(!n.includes(F.BUILDING_SHIP)&&!n.includes(F.BUILDING_ROAD_OR_SHIP))return{valid:!1,error:"No free ship to place"};let a=r.getShipsByPlayer(o).length;return r.options.canBuildShip(a)?r.hasEdgeBuilding(i)?{valid:!1,error:"Edge already has a building"}:i.getAdjacentCenters().some(l=>r.board.isSea(l))?r.board.isEdgeAdjacentToPirate(i)?{valid:!1,error:"Ships cannot be built next to the pirate"}:nt(r,o,i,F.BUILDING_SHIP)?{valid:!0}:{valid:!1,error:"Ship must be connected to your ship/settlement network"}:{valid:!1,error:"Ships must be placed adjacent to sea"}:{valid:!1,error:`Maximum ships (${r.options.maxShips}) already built`}}validateMoveShip(r,t){if(!r.options.seafarers)return{valid:!1,error:"Ship movement requires the Seafarers expansion"};let o=t.player,i=t.fromEdge,n=t.toEdge,a=ze(r,o);if(!a.valid)return a;if(r.movedShipThisTurn)return{valid:!1,error:"Already moved a ship this turn"};if(r.shipsBuiltThisTurn.some(c=>c.equals(i)))return{valid:!1,error:"Cannot move a ship that was built this turn"};let s=r.getEdgeBuilding(i);return s?s.owner!==o?{valid:!1,error:"Ship is not yours"}:s.isShip?this.isShipAtEndOfRoute(r,o,i)?r.board.isEdgeAdjacentToPirate(i)?{valid:!1,error:"Ships adjacent to the pirate cannot be moved"}:r.hasEdgeBuilding(n)?{valid:!1,error:"Destination edge already has a building"}:n.getAdjacentCenters().some(c=>r.board.isSea(c))?r.board.isEdgeAdjacentToPirate(n)?{valid:!1,error:"Ships cannot be moved next to the pirate"}:this.isEdgeConnectedToPlayerNetworkExcluding(r,o,n,i)?{valid:!0}:{valid:!1,error:"Destination must be connected to your network"}:{valid:!1,error:"Ships must be moved adjacent to sea"}:{valid:!1,error:"Can only move ships at the end of a shipping route"}:{valid:!1,error:"Building at source edge is not a ship"}:{valid:!1,error:"No building at source edge"}}validateMovePirate(r,t){if(!r.options.seafarers)return{valid:!1,error:"Pirate requires the Seafarers expansion"};let o=t.player,i=t.location;if(r.options.rushMode){if(r.rushRobberPlayer!==o)return{valid:!1,error:"Only the designated robber player can move the pirate in rush mode"}}else if(r.isSecondSettlerPhase){if(r.secondSettlerPlayer!==o)return{valid:!1,error:"Not your turn"}}else if(r.currentPlayer!==o)return{valid:!1,error:"Not your turn"};return r.pendingRobberOrPiratePlacement?r.pendingBishopSteal!==void 0?{valid:!1,error:"Bishop can only move the robber, not the pirate"}:r.board.barbarians&&!r.board.barbarians.canMoveRobber()?{valid:!1,error:"Pirate cannot be moved until after the first barbarian attack",errorCode:P.VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS}:r.board.pirate&&r.board.pirate.equals(i)?{valid:!1,error:"Pirate must move to a different tile"}:r.board.isSea(i)?{valid:!0}:{valid:!1,error:"Pirate must be placed on a sea tile"}:{valid:!1,error:"Pirate placement not required"}}validateStealFromPlayerPirate(r,t){if(!r.options.seafarers)return{valid:!1,error:"Pirate requires the Seafarers expansion"};let o=t.player;if(r.options.rushMode){if(r.rushRobberPlayer!==o)return{valid:!1,error:"Only the designated robber player can steal in rush mode"}}else if(r.isSecondSettlerPhase){if(r.secondSettlerPlayer!==o)return{valid:!1,error:"Not your turn"}}else if(r.currentPlayer!==o)return{valid:!1,error:"Not your turn"};if(!r.pendingPirateStealLocation)return{valid:!1,error:"Pirate stealing not required"};if(t.targetPlayer===o)return{valid:!1,error:"Cannot steal from yourself"};let i=r.board.pirate;return i?r.getPlayersWithShipsAdjacentTo(i).includes(t.targetPlayer)?{valid:!0}:{valid:!1,error:"Target player has no ships adjacent to the pirate"}:{valid:!1,error:"No pirate on board"}}isShipAtEndOfRoute(r,t,o){let i=0,n=o.verticies;for(let a of n){let s=r.getVertexBuilding(a);if(s&&s.owner===t){i++;continue}let u=a.getEdges();for(let l of u){if(l.equals(o))continue;let c=r.getEdgeBuilding(l);if(c&&c.owner===t&&c.isShip){i++;break}}}return i<=1}isEdgeConnectedToPlayerNetworkExcluding(r,t,o,i){let n=o.verticies;for(let a of n){let s=r.getVertexBuilding(a);if(s&&s.owner===t)return!0;let u=a.getEdges();for(let l of u){if(l.equals(o)||l.equals(i))continue;let c=r.getEdgeBuilding(l);if(c&&c.owner===t){let f=o.getSharedVertexWith(l);if(f){let T=r.getVertexBuilding(f);if(T&&T.owner!==t)continue}if(Cd(F.BUILDING_SHIP,c.building)){if(!f)continue;let T=r.getVertexBuilding(f);if(!T||T.owner!==t)continue}return!0}}}return!1}};var h_=class{static{E(this,"CKKnightsValidator")}validateBuildKnight(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"Knights require the Cities & Knights expansion"};let o=t.player,i=t.vertex,n=r.pendingKnights.find(c=>c.player===o);if(n){if(r.hasVertexBuilding(i))return{valid:!1,error:"Vertex already has a building"};if(r.board.hasKnight(i))return{valid:!1,error:"Vertex already has a knight"};if(!Si(r,i))return{valid:!1,error:"Vertex is not on the board"};if(n.fromVertex){if(i.equals(n.fromVertex))return{valid:!1,error:"Cannot place displaced knight on its previous vertex"};if(!Ol(r,o,n.fromVertex,i))return{valid:!1,error:"Displaced knight must be placed on an open intersection connected to its previous location via your road network"}}else if(!d_(r,o,i))return{valid:!1,error:"Knight must be connected to your road network"};return{valid:!0}}let s=r.getPendingFreeStructures(o).includes(F.BUILDING_KNIGHT);if(s){if(r.currentPlayer!==o)return{valid:!1,error:"Not your turn"};if(r.isSetupPhase)return{valid:!1,error:"Cannot perform this action during setup phase"}}else{let c=ze(r,o);if(!c.valid)return c}let l=r.board.getKnightsByPlayer(o).filter(c=>c.strength===Pe.KNIGHT_STRENGTH_BASIC).length;if(!r.options.canBuildBasicKnight(l))return{valid:!1,error:`Maximum basic knights (${r.options.maxBasicKnights}) already built`};if(!s){let c=r.getPlayerState(o);if(!c)return{valid:!1,error:"Player state not found"};if(!c.hasResourceSet(bd))return{valid:!1,error:"Not enough resources to build knight (need 1 sheep, 1 ore)"}}return r.hasVertexBuilding(i)?{valid:!1,error:"Vertex already has a building"}:r.board.hasKnight(i)?{valid:!1,error:"Vertex already has a knight"}:Si(r,i)?d_(r,o,i)?{valid:!0}:{valid:!1,error:"Knight must be connected to your road network"}:{valid:!1,error:"Vertex is not on the board"}}validateActivateKnight(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"Knights require the Cities & Knights expansion"};let o=t.player,i=t.vertex,n=ze(r,o);if(!n.valid)return n;let a=r.getPlayerState(o);if(!a)return{valid:!1,error:"Player state not found"};if(!a.hasResourceSet(vd))return{valid:!1,error:"Not enough resources to activate knight (need 1 wheat)"};let s=r.board.getKnightAt(i);return s?s.owner!==o?{valid:!1,error:"Knight is not yours"}:s.isActive?{valid:!1,error:"Knight is already active"}:{valid:!0}:{valid:!1,error:"No knight at this vertex"}}validatePromoteKnight(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"Knights require the Cities & Knights expansion"};let o=t.player,i=t.vertex,n=ze(r,o);if(!n.valid)return n;let a=r.getPlayerState(o);if(!a)return{valid:!1,error:"Player state not found"};if(!(r.smithFreePromotionsRemaining>0)&&!a.hasResourceSet(Yd))return{valid:!1,error:"Not enough resources to promote knight (need 1 sheep, 1 ore)"};let u=r.board.getKnightAt(i);if(!u)return{valid:!1,error:"No knight at this vertex"};if(u.owner!==o)return{valid:!1,error:"Knight is not yours"};if(!u.canPromote)return{valid:!1,error:"Knight is already at maximum strength"};if(u.promotedThisTurn)return{valid:!1,error:"Knight has already been promoted this turn"};let l=r.board.getKnightsByPlayer(o);if(u.strength===Pe.KNIGHT_STRENGTH_BASIC){let c=l.filter(f=>f.strength===Pe.KNIGHT_STRENGTH_STRONG).length;if(!r.options.canPromoteToStrongKnight(c))return{valid:!1,error:`Maximum strong knights (${r.options.maxStrongKnights}) already built`}}else if(u.strength===Pe.KNIGHT_STRENGTH_STRONG){if(!r.getPlayerPublicState(o)?.cityImprovements?.hasFortress)return{valid:!1,error:"Requires Fortress (Politics level 3) to promote to mighty knight"};let f=l.filter(T=>T.strength===Pe.KNIGHT_STRENGTH_MIGHTY).length;if(!r.options.canPromoteToMightyKnight(f))return{valid:!1,error:`Maximum mighty knights (${r.options.maxMightyKnights}) already built`}}return{valid:!0}}validateMoveKnight(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"Knights require the Cities & Knights expansion"};let o=t.player,i=t.fromVertex,n=t.toVertex,a=ze(r,o);if(!a.valid)return a;let s=r.board.getKnightAt(i);if(!s)return{valid:!1,error:"No knight at source vertex"};if(s.owner!==o)return{valid:!1,error:"Knight is not yours"};if(!s.canAct)return{valid:!1,error:"Knight cannot act (must be active and not activated this turn)"};if(i.equals(n))return{valid:!1,error:"Knight must move to a different vertex"};if(r.hasVertexBuilding(n))return{valid:!1,error:"Destination vertex has a building"};if(!Si(r,n))return{valid:!1,error:"Destination vertex is not on the board"};let u=r.board.getKnightAt(n);if(u){if(u.owner===o)return{valid:!1,error:"Cannot move to a vertex occupied by your own knight"};if(!s.isStrongerThan(u))return{valid:!1,error:"Can only displace weaker enemy knights"}}return Ol(r,o,i,n)?{valid:!0}:{valid:!1,error:"Destination must be connected to your road network"}}validateChaseRobberWithKnight(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"Knights require the Cities & Knights expansion"};if(r.board.barbarians&&!r.board.barbarians.canMoveRobber())return{valid:!1,error:"Cannot chase robber until after the first barbarian attack",errorCode:P.VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS};let o=t.player,i=t.knightVertex,n=t.newRobberLocation,a=ze(r,o);if(!a.valid)return a;let s=r.board.getKnightAt(i);if(!s)return{valid:!1,error:"No knight at this vertex"};if(s.owner!==o)return{valid:!1,error:"Knight is not yours"};if(!s.canAct)return{valid:!1,error:"Knight cannot act (must be active and not activated this turn)"};if(!i.getHexCenters().some(c=>r.board.hasRobber(c)))return{valid:!1,error:"Knight must be adjacent to the robber to chase it"};if(!r.board.hasTile(n))return{valid:!1,error:"Invalid robber destination"};if(r.board.hasRobber(n))return{valid:!1,error:"Robber must move to a different tile"};if(r.options.robberMode===zr.ROBBER_MODE_FRIENDLY){let c=u_(r),f=r.getPlayersOnTile(n);for(let T of f)if(r.getVisibleVictoryPoints(T)<=c)return{valid:!1,error:"Cannot block players with starting victory points in friendly mode",errorCode:P.VALIDATION_ERROR_FRIENDLY_ROBBER_BLOCKED}}if(t.targetPlayer!==void 0){if(!r.getPlayersOnTile(n).includes(t.targetPlayer))return{valid:!1,error:"Target player has no buildings on this tile"};if(t.targetPlayer===o)return{valid:!1,error:"Cannot steal from yourself"}}return{valid:!0}}validateUseKnightErrant(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"Knights require the Cities & Knights expansion"};if(!r.options.ckKnightErrant)return{valid:!1,error:"Knight-Errant variant is not enabled"};if(r.board.barbarians&&!r.board.barbarians.canMoveRobber())return{valid:!1,error:"Cannot use Knight-Errant until after the first barbarian attack",errorCode:P.VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS};let o=t.player,i=t.knightVertex,n=t.newRobberLocation;if(r.currentPlayer!==o)return{valid:!1,error:"Not your turn"};if(!r.pendingDiceRoll)return{valid:!1,error:"Knight-Errant can only be used before rolling dice"};if(r.pendingRobberStealLocation)return{valid:!1,error:"Must steal from a player first",errorCode:P.VALIDATION_ERROR_NO_PENDING_STEAL};let a=Vt(r,o);if(!a.valid)return a;let s=rt(r,o);if(!s.valid)return s;let u=r.board.getKnightAt(i);if(!u)return{valid:!1,error:"No knight at this vertex"};if(u.owner!==o)return{valid:!1,error:"Knight is not yours"};if(!u.canAct)return{valid:!1,error:"Knight cannot act (must be active and not activated this turn)"};if(!i.getHexCenters().some(f=>r.board.hasRobber(f)))return{valid:!1,error:"Knight must be adjacent to the robber to chase it"};if(!r.board.hasTile(n))return{valid:!1,error:"Invalid robber destination"};if(r.board.hasRobber(n))return{valid:!1,error:"Robber must move to a different tile"};if(r.options.robberMode===zr.ROBBER_MODE_FRIENDLY){let f=u_(r),T=r.getPlayersOnTile(n);for(let R of T)if(r.getVisibleVictoryPoints(R)<=f)return{valid:!1,error:"Cannot block players with starting victory points in friendly mode",errorCode:P.VALIDATION_ERROR_FRIENDLY_ROBBER_BLOCKED}}if(t.targetPlayer!==void 0){if(!r.getPlayersOnTile(n).includes(t.targetPlayer))return{valid:!1,error:"Target player has no buildings on this tile"};if(t.targetPlayer===o)return{valid:!1,error:"Cannot steal from yourself"}}return{valid:!0}}};var FD=[new Map([[j.COMMODITY_CLOTH,1]]),new Map([[j.COMMODITY_CLOTH,2]]),new Map([[j.COMMODITY_CLOTH,3]]),new Map([[j.COMMODITY_CLOTH,4]]),new Map([[j.COMMODITY_CLOTH,5]])],VD=[new Map([[j.COMMODITY_COIN,1]]),new Map([[j.COMMODITY_COIN,2]]),new Map([[j.COMMODITY_COIN,3]]),new Map([[j.COMMODITY_COIN,4]]),new Map([[j.COMMODITY_COIN,5]])],xD=[new Map([[j.COMMODITY_PAPER,1]]),new Map([[j.COMMODITY_PAPER,2]]),new Map([[j.COMMODITY_PAPER,3]]),new Map([[j.COMMODITY_PAPER,4]]),new Map([[j.COMMODITY_PAPER,5]])],D_=class{static{E(this,"CKCityImprovementsValidator")}validateBuildCityWall(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"City walls require the Cities & Knights expansion"};let o=t.player,i=t.cityVertex,n=ze(r,o);if(!n.valid)return n;let a=r.board.getCityWallsByPlayer(o);if(!r.options.canBuildCityWall(a.length))return{valid:!1,error:`Maximum city walls (${r.options.maxCityWalls}) already built`};let s=r.getPlayerState(o);if(!s)return{valid:!1,error:"Player state not found"};if(!r.progressCardsInPlay.includes(b.PROGRESS_CARD_ENGINEER)&&!s.hasResourceSet(kd))return{valid:!1,error:"Not enough resources to build city wall (need 2 brick)"};let l=r.getVertexBuilding(i);return l?l.owner!==o?{valid:!1,error:"Building is not yours"}:l.isCity?r.board.hasCityWall(i)?{valid:!1,error:"City already has a wall"}:{valid:!0}:{valid:!1,error:"Can only build city walls on cities"}:{valid:!1,error:"No building at this vertex"}}validateBuildCityImprovement(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"City improvements require the Cities & Knights expansion"};let o=t.player,i=t.track,n=ze(r,o);if(!n.valid)return n;if(r.getCitiesByPlayer(o).length===0)return{valid:!1,error:"Must have at least one city to build improvements"};let s=r.getPlayerPublicState(o);if(!s)return{valid:!1,error:"Player state not found"};let u=s.cityImprovements?.getLevel(i)??0,l=r.getPlayerState(o);if(!l)return{valid:!1,error:"Player state not found"};if(u>=5)return{valid:!1,error:"City improvement already at maximum level"};let c=u+1,f;switch(i){case K.CITY_IMPROVEMENT_TRACK_TRADE:f=FD;break;case K.CITY_IMPROVEMENT_TRACK_POLITICS:f=VD;break;case K.CITY_IMPROVEMENT_TRACK_SCIENCE:f=xD;break;default:return{valid:!1,error:"Invalid improvement track"}}let T=f[c-1];return r.isCraneActive&&(T=this.reduceCommodityCostByOne(T)),l.hasCommoditySet(T)?{valid:!0}:{valid:!1,error:`Not enough commodities to improve ${this.getTrackName(i)} to level ${c}`}}reduceCommodityCostByOne(r){let t=new Map,o=!1;for(let[i,n]of r)!o&&n>0?(n>1&&t.set(i,n-1),o=!0):t.set(i,n);return t}getTrackName(r){switch(r){case K.CITY_IMPROVEMENT_TRACK_TRADE:return"Trade";case K.CITY_IMPROVEMENT_TRACK_POLITICS:return"Politics";case K.CITY_IMPROVEMENT_TRACK_SCIENCE:return"Science";default:return"Unknown"}}validateSelectMetropolisCity(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"Metropolis selection requires the Cities & Knights expansion"};let o=t.player,i=t.cityVertex,n=r.pendingMetropolisPlacement;if(!n)return{valid:!1,error:"No pending metropolis placement"};if(n.player!==o)return{valid:!1,error:"It is not your turn to select a metropolis city"};let a=r.getVertexBuilding(i);return a?a.owner!==o?{valid:!1,error:"Building is not yours"}:a.isCity?r.board.hasMetropolis(i)?{valid:!1,error:"City already has a metropolis"}:{valid:!0}:{valid:!1,error:"Can only place metropolis on cities"}:{valid:!1,error:"No building at this vertex"}}};var m_=class{static{E(this,"CKBarbariansValidator")}validateSelectCityToPillage(r,t){if(!r.options.citiesAndKnights)return{valid:!1,error:"City pillaging requires the Cities & Knights expansion"};let o=t.player,i=t.cityVertex;if(r.pendingCityPillage!==o)return{valid:!1,error:"You don't need to select a city to pillage"};let n=r.getVertexBuilding(i);return n?n.owner!==o?{valid:!1,error:"Building is not yours"}:n.isCity?r.board.hasMetropolis(i)?{valid:!1,error:"Cannot pillage a metropolis city"}:{valid:!0}:{valid:!1,error:"Must select a city"}:{valid:!1,error:"No building at this vertex"}}validateSelectDefenderProgress(r,t){let o=t.player,i=t.track;return r.options.citiesAndKnights?r.pendingDefenderSelection.includes(o)?i!==K.CITY_IMPROVEMENT_TRACK_TRADE&&i!==K.CITY_IMPROVEMENT_TRACK_POLITICS&&i!==K.CITY_IMPROVEMENT_TRACK_SCIENCE?{valid:!1,error:"Invalid progress track"}:{valid:!0}:{valid:!1,error:"You don't need to select a defender progress"}:{valid:!1,error:"Defender progress requires the Cities & Knights expansion"}}validateCommitKnightsToDefense(r,t){let o=t.player,i=t.knightVertices;if(!r.options.citiesAndKnights)return{valid:!1,error:"Knight commitment requires the Cities & Knights expansion"};if(!r.options.ckNastyBarbarians)return{valid:!1,error:"Nasty Barbarians variant is not enabled"};if(!r.pendingKnightCommitment)return{valid:!1,error:"No pending knight commitment"};if(r.pendingKnightCommitment.currentPlayer!==o)return{valid:!1,error:"Not your turn to commit knights"};if(r.pendingKnightCommitment.playersCommitted.includes(o))return{valid:!1,error:"You have already committed your knights"};for(let n of i){let a=r.board.getKnightAt(n);if(!a)return{valid:!1,error:`No knight at vertex ${n.toString()}`};if(a.owner!==o)return{valid:!1,error:"Cannot commit a knight you don't own"};if(!a.isActive)return{valid:!1,error:"Cannot commit an inactive knight"};if(r.pendingKnightCommitment.committedKnights.some(u=>u.equals(n)))return{valid:!1,error:"Knight already committed"}}return{valid:!0}}};var g_=class{static{E(this,"CKScienceCardsValidator")}validatePlayAlchemist(r,t){let o=t.player;if(!r.options.citiesAndKnights)return{valid:!1,error:"Alchemist requires the Cities & Knights expansion"};if(r.currentPlayer!==o)return{valid:!1,error:"Not your turn"};if(r.isSetupPhase)return{valid:!1,error:"Cannot play Alchemist during setup phase"};if(!r.pendingDiceRoll)return{valid:!1,error:"Alchemist must be played before rolling dice"};if(r.pendingAlchemist!==void 0)return{valid:!1,error:"Alchemist already in progress"};let i=Vt(r,o);if(!i.valid)return i;let n=rt(r,o);if(!n.valid)return n;let a=r.getPlayerState(o);return a?a.getProgressCardCount(b.PROGRESS_CARD_ALCHEMIST)<1?{valid:!1,error:"You don't have the Alchemist progress card"}:{valid:!0}:{valid:!1,error:"Player state not found"}}validateSelectAlchemistDice(r,t){let o=t.player,i=t.redDie,n=t.yellowDie;return r.options.citiesAndKnights?r.pendingAlchemist!==o?{valid:!1,error:"You don't need to select alchemist dice"}:i<1||i>6?{valid:!1,error:"Red die must be between 1 and 6"}:n<1||n>6?{valid:!1,error:"Yellow die must be between 1 and 6"}:{valid:!0}:{valid:!1,error:"Alchemist requires the Cities & Knights expansion"}}validatePlayCrane(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_CRANE);if(!o.valid)return o;if(r.progressCardsInPlay.includes(b.PROGRESS_CARD_CRANE))return{valid:!1,error:"You already have a Crane in play - cannot stack Crane cards"};if(r.getCitiesByPlayer(t.player).length===0)return{valid:!1,error:"You need a city to use Crane"};let n=r.getPlayerPublicState(t.player);if(!n)return{valid:!1,error:"Player state not found"};let a=n.cityImprovements?.getLevel(K.CITY_IMPROVEMENT_TRACK_TRADE)??0,s=n.cityImprovements?.getLevel(K.CITY_IMPROVEMENT_TRACK_POLITICS)??0,u=n.cityImprovements?.getLevel(K.CITY_IMPROVEMENT_TRACK_SCIENCE)??0;return a>=5&&s>=5&&u>=5?{valid:!1,error:"All city improvements are already at maximum level"}:{valid:!0}}validatePlayEngineer(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_ENGINEER);return o.valid?ml(r,t.player).length===0?r.getCitiesByPlayer(t.player).length===0?{valid:!1,error:"You have no cities to build a wall on"}:gd(r,t.player).length===0?{valid:!1,error:"All your cities already have walls"}:{valid:!1,error:`You have already built all your city walls (${r.options.maxCityWalls})`}:{valid:!0}:o}validatePlayInventor(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_INVENTOR);if(!o.valid)return o;let i=t.hex1,n=t.hex2;if(i.equals(n))return{valid:!1,error:"Must select two different hexes"};let a=r.board.getTile(i),s=r.board.getTile(n);if(!a)return{valid:!1,error:"First hex is not on the board"};if(!s)return{valid:!1,error:"Second hex is not on the board"};if(a.terrain===d.TERRAIN_DESERT)return{valid:!1,error:"Cannot swap desert hex"};if(s.terrain===d.TERRAIN_DESERT)return{valid:!1,error:"Cannot swap desert hex"};if(a.terrain===d.TERRAIN_SEA)return{valid:!1,error:"Cannot swap sea hex"};if(s.terrain===d.TERRAIN_SEA)return{valid:!1,error:"Cannot swap sea hex"};if(a.terrain===d.TERRAIN_FOG)return{valid:!1,error:"Cannot swap fog hex"};if(s.terrain===d.TERRAIN_FOG)return{valid:!1,error:"Cannot swap fog hex"};if(a.numbers.length===0)return{valid:!1,error:"First hex has no dice number"};if(s.numbers.length===0)return{valid:!1,error:"Second hex has no dice number"};let u=[2,6,8,12],l=a.numbers[0],c=s.numbers[0];return u.includes(l)?{valid:!1,error:`Cannot swap hex with number ${l}`}:u.includes(c)?{valid:!1,error:`Cannot swap hex with number ${c}`}:{valid:!0}}validatePlayIrrigation(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_IRRIGATION);return o.valid?{valid:!0}:o}validatePlayMedicine(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_MEDICINE);if(!o.valid)return o;if(r.progressCardsInPlay.includes(b.PROGRESS_CARD_MEDICINE))return{valid:!1,error:"You already have a Medicine in play - cannot stack Medicine cards"};if(r.getSettlementsByPlayer(t.player).length===0)return{valid:!1,error:"You have no settlements to upgrade"};let n=r.getCitiesByPlayer(t.player).length;return r.options.canBuildCity(n)?{valid:!0}:{valid:!1,error:`Maximum cities (${r.options.maxCities}) already built`}}validatePlayMining(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_MINING);return o.valid?{valid:!0}:o}validatePlayProgressRoadBuilding(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_ROAD_BUILDING);return o.valid?At(r,t.player,it(r))?{valid:!0}:{valid:!1,error:"Cannot play Road Building: no roads or ships available to place"}:o}validatePlaySmith(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_SMITH);return o.valid?r.progressCardsInPlay.includes(b.PROGRESS_CARD_SMITH)?{valid:!1,error:"You already have a Smith in play - cannot stack Smith cards"}:Ha(r,t.player).length===0?{valid:!1,error:"You have no knights that can be promoted"}:{valid:!0}:o}};var y_=class{static{E(this,"CKPoliticsCardsValidator")}validatePlayBishop(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_BISHOP);if(!o.valid)return o;if(r.board.barbarians&&!r.board.barbarians.canMoveRobber())return{valid:!1,error:"Bishop cannot be played until after the first barbarian attack",errorCode:P.VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS};let i=t.robberLocation;return i?r.board.hasRobber(i)?{valid:!1,error:"Robber must move to a different tile"}:r.board.hasTile(i)?r.board.getTile(i)?{valid:!0}:{valid:!1,error:"Invalid robber location"}:{valid:!1,error:"Invalid robber location"}:{valid:!0}}validatePlayDeserter(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_DESERTER);return o.valid?t.targetPlayer===t.player?{valid:!1,error:"Cannot target yourself"}:r.board.getKnightsByPlayer(t.targetPlayer).length===0?{valid:!1,error:"Target player has no knights"}:{valid:!0}:o}validateSelectDeserterKnight(r,t){if(!r.pendingDeserter)return{valid:!1,error:"No Deserter action in progress"};if(r.pendingDeserter.targetPlayer!==t.player)return{valid:!1,error:"You are not the target of the Deserter card"};let o=r.board.getKnightAt(t.knightLocation);return o?o.owner!==t.player?{valid:!1,error:"That knight does not belong to you"}:{valid:!0}:{valid:!1,error:"No knight at that location"}}validatePlayDiplomat(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_DIPLOMAT);if(!o.valid)return o;let i=r.board.getEdgeBuilding(t.targetRoad);return i?i.building!==F.BUILDING_ROAD&&i.building!==F.BUILDING_SHIP?{valid:!1,error:"Target must be a road or ship"}:t.targetRoad.verticies.some(s=>!(r.board.getVertexBuilding(s)||r.board.getKnightAt(s)||s.getEdges().some(c=>!c.equals(t.targetRoad)&&r.board.getEdgeBuilding(c)!==void 0)))?{valid:!0}:{valid:!1,error:"Road or ship must have at least one open endpoint (no buildings, roads, or knights)"}:{valid:!1,error:"No road or ship at that location"}}validatePlayIntrigue(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_INTRIGUE);if(!o.valid)return o;let i=r.board.getKnightAt(t.targetKnight);if(!i)return{valid:!1,error:"No knight at that location"};if(i.owner===t.player)return{valid:!1,error:"Cannot target your own knight"};if(!t.targetKnight.getEdges().some(l=>{let c=r.board.getEdgeBuilding(l);return c!==void 0&&c.owner===t.player&&c.providesSettlementConnectivity}))return{valid:!1,error:"Knight must be on an intersection connected to one of your roads"};let a=Ii(r,i.owner,t.targetKnight);return t.destination?r.board.getKnightAt(t.destination)?{valid:!1,error:"Destination already has a knight"}:r.board.getVertexBuilding(t.destination)?{valid:!1,error:"Destination has a building"}:a.some(l=>l.equals(t.destination))?{valid:!0}:{valid:!1,error:"Destination must be connected to the knight's current location via its owner's road network"}:a.length>0?{valid:!1,error:"Valid destinations exist; you must choose one"}:{valid:!0}}validatePlaySaboteur(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_SABOTEUR);return o.valid?{valid:!0}:o}validatePlaySpy(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_SPY);if(!o.valid)return o;if(!t.targetPlayer)return{valid:!1,error:"Must specify a target player"};if(t.targetPlayer===t.player)return{valid:!1,error:"Cannot spy on yourself"};let i=r.getPlayerPublicState(t.targetPlayer);return!i||i.progressCardCount===0?{valid:!1,error:"Target player has no progress cards"}:{valid:!0}}validateSelectSpyTargetCard(r,t){if(r.currentPlayer!==t.player)return{valid:!1,error:"Not your turn"};if(!r.pendingSpyTarget)return{valid:!1,error:"No Spy action in progress"};if(!t.progressCard)return{valid:!1,error:"Must specify a progress card to steal"};let o=r.getPlayerState(t.player);return o?(o.spyVisibleProgressCards.get(t.progressCard)??0)>0?{valid:!0}:{valid:!1,error:"Selected card is not available to steal"}:{valid:!1,error:"Player state not found"}}validatePlayWarlord(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_WARLORD);return o.valid?r.board.getKnightsByPlayer(t.player).filter(a=>!a.isActive).length===0?{valid:!1,error:"You have no inactive knights to activate"}:{valid:!0}:o}validatePlayWedding(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_WEDDING);return o.valid?{valid:!0}:o}validateGiveWeddingCards(r,t){if(!r.pendingWeddingCards.find(u=>u.player===t.player))return{valid:!1,error:"No pending wedding cards to give"};let i=r.getPlayerState(t.player);if(!i)return{valid:!1,error:"Player state not found"};let n=0;for(let u of i.hand.values())n+=u;for(let u of i.commodities.values())n+=u;let a=Math.min(2,n),s=0;for(let u of t.resources.values())s+=u;for(let u of t.commodities.values())s+=u;if(s!==a)return{valid:!1,error:`Must give exactly ${a} cards`};for(let[u,l]of t.resources){let c=i.hand.get(u)??0;if(l>c)return{valid:!1,error:`Not enough ${u} to give`}}for(let[u,l]of t.commodities){let c=i.commodities.get(u)??0;if(l>c)return{valid:!1,error:`Not enough ${u} to give`}}return{valid:!0}}validateDiscardProgressCard(r,t){if(!r.hasPendingProgressCardDiscard(t.player))return{valid:!1,error:"You do not need to discard progress cards"};let o=r.getPlayerState(t.player);return o?xr(t.card)?{valid:!1,error:"Cannot discard victory point progress cards"}:(o.progressCards.get(t.card)??0)<=0?{valid:!1,error:"You do not have that progress card"}:{valid:!0}:{valid:!1,error:"Player state not found"}}};function Vl(e){switch(e){case j.COMMODITY_PAPER:return"Paper";case j.COMMODITY_CLOTH:return"Cloth";case j.COMMODITY_COIN:return"Coin";default:return"Unknown"}}E(Vl,"getCommodityName");var wD=[j.COMMODITY_PAPER,j.COMMODITY_CLOTH,j.COMMODITY_COIN],HD=[{commodity:j.COMMODITY_PAPER,count:19},{commodity:j.COMMODITY_CLOTH,count:19},{commodity:j.COMMODITY_COIN,count:19}];var M_=class{static{E(this,"CKTradeCardsValidator")}validatePlayCommercialHarbor(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_COMMERCIAL_HARBOR);if(!o.valid)return o;let i=r.getPlayerState(t.player);if(!i)return{valid:!1,error:"Player state not found"};if(i.totalResourcesInHand===0)return{valid:!1,error:"Must have at least 1 resource to play Commercial Harbor"};if(!t.selectedTrades||t.selectedTrades.size===0)return{valid:!1,error:"Must select at least one opponent to trade with"};let n=new Map;for(let[a,s]of t.selectedTrades){if(!r.turnOrder.includes(a))return{valid:!1,error:`Invalid opponent: ${a}`};if(a===t.player)return{valid:!1,error:"Cannot trade with yourself"};if(s===S.RESOURCE_UNSPECIFIED)return{valid:!1,error:"Must specify a valid resource for each trade"};let u=n.get(s)??0;n.set(s,u+1)}for(let[a,s]of n){let u=i.hand.get(a)??0;if(u<s)return{valid:!1,error:`Not enough ${a} to trade (need ${s}, have ${u})`}}return{valid:!0}}validateCommercialHarborGiveCommodity(r,t){if(!r.pendingCommercialHarborExchanges.find(a=>a.opponent===t.player))return{valid:!1,error:"No pending Commercial Harbor exchange for this player"};let i=r.getPlayerState(t.player);return i?(i.commodities.get(t.commodity)??0)<1?{valid:!1,error:`Not enough commodity ${Vl(t.commodity)} to give`}:{valid:!0}:{valid:!1,error:"Player state not found"}}validatePlayMasterMerchant(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_MASTER_MERCHANT);if(!o.valid)return o;if(!t.targetPlayer)return{valid:!1,error:"Must specify a target player"};if(t.targetPlayer===t.player)return{valid:!1,error:"Cannot use Master Merchant on yourself"};let i=r.getVisibleVictoryPoints(t.player);if(r.getVisibleVictoryPoints(t.targetPlayer)<=i)return{valid:!1,error:"Target player must have more victory points than you"};let a=r.getPlayerState(t.targetPlayer);return a?a.totalResourcesInHand+a.totalCommoditiesInHand===0?{valid:!1,error:"Target player has no cards to steal"}:{valid:!0}:{valid:!1,error:"Target player state not found"}}validateSelectMasterMerchantCards(r,t){if(r.currentPlayer!==t.player)return{valid:!1,error:"Not your turn"};if(!r.masterMerchantTarget)return{valid:!1,error:"No Master Merchant action in progress"};let o=0;for(let n of t.resources.values())o+=n;for(let n of t.commodities.values())o+=n;if(o!==2)return{valid:!1,error:"Must select exactly 2 cards to steal"};let i=r.getPlayerState(t.player);if(!i)return{valid:!1,error:"Player state not found"};for(let[n,a]of t.resources){let s=i.masterMerchantResources.get(n)??0;if(a>s)return{valid:!1,error:`Not enough ${n} available to steal`}}for(let[n,a]of t.commodities){let s=i.masterMerchantCommodities.get(n)??0;if(a>s)return{valid:!1,error:`Not enough ${n} available to steal`}}return{valid:!0}}validatePlayMerchant(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_MERCHANT);if(!o.valid)return o;let i=t.hex,n=r.board.getTile(i);return n?n.terrain===d.TERRAIN_DESERT?{valid:!1,error:"Cannot place merchant on desert"}:n.terrain===d.TERRAIN_SEA?{valid:!1,error:"Cannot place merchant on sea"}:i.getAllVerticies().some(u=>{let l=r.board.getVertexBuilding(u);return l&&l.owner===t.player})?{valid:!0}:{valid:!1,error:"You must have a building adjacent to this hex"}:{valid:!1,error:"Hex is not on the board"}}validatePlayMerchantFleet(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_MERCHANT_FLEET);if(!o.valid)return o;let i=t.resource!==void 0&&t.resource!==S.RESOURCE_UNSPECIFIED,n=t.commodity!==void 0&&t.commodity!==j.COMMODITY_UNSPECIFIED;return i&&n?{valid:!1,error:"Must select either a resource or a commodity, not both"}:!i&&!n?{valid:!1,error:"Must select a resource or commodity type"}:{valid:!0}}validatePlayResourceMonopoly(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_RESOURCE_MONOPOLY);return o.valid?t.resource===S.RESOURCE_UNSPECIFIED?{valid:!1,error:"Must specify a resource type"}:{valid:!0}:o}validatePlayTradeMonopoly(r,t){let o=sr(r,t.player,b.PROGRESS_CARD_TRADE_MONOPOLY);return o.valid?t.commodity===j.COMMODITY_UNSPECIFIED?{valid:!1,error:"Must specify a commodity type"}:{valid:!0}:o}};var L_=class{static{E(this,"FishermanValidator")}validatePassOldBoot(r,t){if(!r.options.fisherman)return{valid:!1,error:"Old boot requires the Fisherman of Catan expansion"};let o=t.player,i=t.targetPlayer,n=va(r,o);if(!n.valid)return n;if(r.oldBoot!==o)return{valid:!1,error:"You don't have the old boot"};if(i===o)return{valid:!1,error:"Cannot pass old boot to yourself"};let a=r.getTotalVictoryPoints(o);return r.getTotalVictoryPoints(i)<a?{valid:!1,error:"Can only pass old boot to players with equal or more victory points"}:{valid:!0}}checkHasEnoughFish(r,t,o){let i=r.getPlayerState(t);if(!i)return{valid:!1,error:"Player not found"};let n=Array.from(i.fishTiles.entries()).map(([s,u])=>({fish:s,count:u})),a=kl(n);return a<o?{valid:!1,error:`Need ${o} fish, but only have ${a}`}:{valid:!0}}validateSpendFishBanishRobber(r,t){if(!r.options.fisherman)return{valid:!1,error:"Fish spending requires the Fisherman of Catan expansion"};let o=t.player,i=Ya(r,o);if(!i.valid)return i;let n=this.checkHasEnoughFish(r,o,2);return n.valid?r.board.robbers.length===0?{valid:!1,error:"No robber to banish"}:r.board.barbarians&&!r.board.barbarians.canMoveRobber()?{valid:!1,error:"Robber cannot be moved until after the first barbarian attack",errorCode:P.VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS}:{valid:!0}:n}validateSpendFishStealResource(r,t){if(!r.options.fisherman)return{valid:!1,error:"Fish spending requires the Fisherman of Catan expansion"};let o=t.player,i=t.targetPlayer,n=Ya(r,o);if(!n.valid)return n;let a=this.checkHasEnoughFish(r,o,3);if(!a.valid)return a;if(i===o)return{valid:!1,error:"Cannot steal from yourself"};let s=r.getPlayerState(i),u=r.getPlayerPublicState(i);return u?u.cardCount===0?{valid:!1,error:"Target player has no cards to steal"}:{valid:!0}:{valid:!1,error:"Target player not found"}}validateSpendFishTakeResource(r,t){if(!r.options.fisherman)return{valid:!1,error:"Fish spending requires the Fisherman of Catan expansion"};let o=t.player,i=Ya(r,o);if(!i.valid)return i;let n=this.checkHasEnoughFish(r,o,4);return n.valid?{valid:!0}:n}validateSpendFishBuildRoad(r,t){if(!r.options.fisherman)return{valid:!1,error:"Fish spending requires the Fisherman of Catan expansion"};let o=t.player,i=Ya(r,o);if(!i.valid)return i;let n=this.checkHasEnoughFish(r,o,5);return n.valid?At(r,o,it(r))?{valid:!0}:{valid:!1,error:"Cannot build a road: no road or ship can be placed"}:n}validateSpendFishDrawDevCard(r,t){if(!r.options.fisherman)return{valid:!1,error:"Fish spending requires the Fisherman of Catan expansion"};let o=t.player,i=Ya(r,o);if(!i.valid)return i;let n=this.checkHasEnoughFish(r,o,7);if(!n.valid)return n;let a=0;for(let s of r.devCardDeck.values())a+=s;return a===0?{valid:!1,error:"No development cards available in deck"}:{valid:!0}}};var Kd=class{static{E(this,"EventCardsValidator")}validateSelectEarthquakeRoad(r,t){if(!r.options.eventCards)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Event cards requires the Traders & Barbarians expansion");let o=t.player,i=t.edge;if(!r.pendingEarthquake.includes(o))return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"You are not required to select a road to break");let n=r.getEdgeBuilding(i);return n?n.owner!==o?p(P.VALIDATION_ERROR_SETTLEMENT_WRONG_OWNER,"That road does not belong to you"):n.building!==F.BUILDING_ROAD?n.building===F.BUILDING_BROKEN_ROAD?p(P.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS,"That road is already broken"):p(P.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS,"You must select a road, not a ship"):Ee():p(P.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS,"No road at that location")}validateGiveEventCardResource(r,t){if(!r.options.eventCards)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Event cards requires the Traders & Barbarians expansion");let o=t.player,i=t.resource,n=t.commodity,a=t.targetPlayer,s=r.getFlowState(),u=s.pendingGoodNeighbors.includes(o),l=s.pendingHelpfulNeighbors.includes(o);if(!u&&!l)return p(P.VALIDATION_ERROR_NO_PENDING_FREE_RESOURCES,"You are not required to give a resource");if(a===o)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Cannot give a resource to yourself");if(l&&!u&&!T_(r,o).includes(a))return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"You must give to a player with fewer victory points");let c=i!==void 0&&i!==S.RESOURCE_UNSPECIFIED,f=n!==void 0&&n!==j.COMMODITY_UNSPECIFIED;if(!c&&!f)return p(P.VALIDATION_ERROR_MUST_SPECIFY_RESOURCE,"Must specify a valid resource or commodity");if(c&&f)return p(P.VALIDATION_ERROR_MUST_SPECIFY_RESOURCE,"Cannot specify both a resource and a commodity");if(f&&!r.options.citiesAndKnights)return p(P.VALIDATION_ERROR_MUST_SPECIFY_RESOURCE,"Commodities can only be given in Cities & Knights");let T=r.getPlayerState(o);if(!T)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player not found");if(c){if((T.hand.get(i)??0)===0)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You don't have that resource to give")}else if((T.commodities.get(n)??0)===0)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"You don't have that commodity to give");return Ee()}validateEventCardSteal(r,t){if(!r.options.eventCards)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Event cards requires the Traders & Barbarians expansion");let o=t.player,i=t.targetPlayer;if(r.pendingEventCardSteal!==o)return p(P.VALIDATION_ERROR_NOT_YOUR_TURN,"You are not the designated stealer for this event card");if(i===o)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Cannot steal from yourself");let n=r.getPlayerPublicState(i);return n?n.cardCount===0?p(P.VALIDATION_ERROR_TARGET_NO_RESOURCES,"Target player has no cards to steal"):Ee():p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Target player not found")}};var Wd=class{static{E(this,"MerchantTrainsValidator")}validateWagonVote(r,t){if(!r.options.merchantTrains)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Wagon voting requires the Merchant Trains expansion");let o=t.player,i=r.getFlowState().pendingWagonVoting;if(!i)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"No wagon voting is in progress");if(!i.needsVoteFrom(o))return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"You have already voted or are not part of this voting");let n=t.woolBid,a=t.wheatBid,s=n+a;if(n<0||a<0)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,"Bid amounts cannot be negative");let u=r.getPlayerState(o);if(!u)return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Player state not found");let l=u.getResourceCount(S.RESOURCE_SHEEP),c=u.getResourceCount(S.RESOURCE_WHEAT);if(n>l)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,`Not enough wool. You have ${l} but bid ${n}`);if(a>c)return p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,`Not enough wheat. You have ${c} but bid ${a}`);if(s>0){if(!t.preferredEdge||!t.preferredFacing)return p(P.VALIDATION_ERROR_EDGE_NOT_ON_BOARD,"Must specify edge and facing direction when bidding");let f=t.preferredEdge;if(!r.board.getTiles().some(R=>R.location.getAllEdges().some(O=>O.equals(f))))return p(P.VALIDATION_ERROR_EDGE_NOT_ON_BOARD,"Invalid edge for wagon placement");if(r.board.hasWagon(f))return p(P.VALIDATION_ERROR_EDGE_OCCUPIED,"A wagon is already on this edge")}return Ee()}};var KD=new Set([S.RESOURCE_WOOD,S.RESOURCE_SHEEP,S.RESOURCE_WHEAT]),Jd=class{static{E(this,"TrollsValidator")}validateFeedTroll(r,t){if(!r.options.trolls)return p(P.VALIDATION_ERROR_NO_TROLL_ON_HEX,"Trolls expansion not enabled");let o=t.player,i=ze(r,o);if(!i.valid)return i;if(!r.board.hasTroll(t.trollHex))return p(P.VALIDATION_ERROR_NO_TROLL_ON_HEX,"No troll on this hex");let n=t.trollHex.getAllVerticies(),a=r.getSettlementsByPlayer(o),s=r.getCitiesByPlayer(o);if(!n.some(f=>a.some(T=>T.vertex.equals(f))||s.some(T=>T.vertex.equals(f))))return p(P.VALIDATION_ERROR_TROLL_NOT_ADJACENT_TO_BUILDING,"You must have a settlement or city adjacent to the troll to feed it");let l=0;for(let[f,T]of t.resources){if(!KD.has(f))return p(P.VALIDATION_ERROR_TROLL_INVALID_FOOD,"Only wood, sheep, and wheat can feed trolls");l+=T}if(l<3)return p(P.VALIDATION_ERROR_TROLL_INSUFFICIENT_FOOD,`Need 3 food units to feed troll, but only providing ${l}`);let c=r.getPlayerState(o);return c?c.hasResourceSet(t.resources)?Ee():p(P.VALIDATION_ERROR_TROLL_INSUFFICIENT_FOOD,"You don't have the resources to feed the troll"):p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found")}validateKickTrollWithKnight(r,t){if(!r.options.trolls)return p(P.VALIDATION_ERROR_NO_TROLL_ON_HEX,"Trolls expansion not enabled");if(!r.options.citiesAndKnights)return p(P.VALIDATION_ERROR_TROLL_KNIGHT_NOT_MIGHTY,"Knights require the Cities & Knights expansion");let o=t.player,i=ze(r,o);if(!i.valid)return i;if(!r.board.hasTroll(t.trollHex))return p(P.VALIDATION_ERROR_NO_TROLL_ON_HEX,"No troll on this hex");let n=r.board.getKnightAt(t.knightVertex);return n?n.owner!==o?p(P.VALIDATION_ERROR_TROLL_KNIGHT_NOT_MIGHTY,"This knight doesn't belong to you"):n.strength!==Pe.KNIGHT_STRENGTH_MIGHTY?p(P.VALIDATION_ERROR_TROLL_KNIGHT_NOT_MIGHTY,"Only mighty knights can kick trolls"):n.isActive?t.knightVertex.getHexCenters().some(u=>u.equals(t.trollHex))?Ee():p(P.VALIDATION_ERROR_TROLL_KNIGHT_NOT_ADJACENT,"Knight must be adjacent to the troll hex"):p(P.VALIDATION_ERROR_TROLL_KNIGHT_NOT_ACTIVE,"Knight must be active to kick a troll"):p(P.VALIDATION_ERROR_TROLL_KNIGHT_NOT_MIGHTY,"No knight at this location")}};function xl(e){return e.options.rivers?Ee():p(P.VALIDATION_ERROR_RIVERS_NOT_ENABLED,"The Rivers expansion is not enabled")}E(xl,"checkRiversEnabled");function CN(e){return e===void 0||!Nn.includes(e)?p(P.VALIDATION_ERROR_MUST_SPECIFY_RESOURCE,"Must specify a resource"):Ee()}E(CN,"checkResource");var G_=class{static{E(this,"RiversValidator")}validateBuildBridge(r,t){let o=t.player,i=t.edge,n=xl(r);if(!n.valid)return n;let a=ze(r,o);if(!a.valid)return a;if(!i)return p(P.VALIDATION_ERROR_MUST_SPECIFY_EDGE,"Must specify an edge");if(!r.board.isBridgeSite(i))return p(P.VALIDATION_ERROR_NOT_A_BRIDGE_SITE,"A bridge must be built where a river crosses");if(r.hasEdgeBuilding(i))return p(P.VALIDATION_ERROR_EDGE_OCCUPIED,"Edge already has a building");if(!r.options.canBuildBridge(r.getBridgesByPlayer(o).length))return p(P.VALIDATION_ERROR_NO_BRIDGES_REMAINING,`Maximum bridges (${r.options.maxBridges}) already built`);let s=r.getPlayerState(o);return s?s.hasResourceSet(Fn)?nt(r,o,i,F.BUILDING_BRIDGE)?Ee():p(P.VALIDATION_ERROR_BRIDGE_NOT_CONNECTED,"Bridge must connect to your road, bridge, settlement or city"):p(P.VALIDATION_ERROR_CANNOT_AFFORD_BRIDGE,"Not enough resources to build a bridge (2 brick + 1 wood)"):p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found")}validateBuyResourceWithGold(r,t){let o=t.player,i=xl(r);if(!i.valid)return i;let n=ze(r,o);if(!n.valid)return n;let a=CN(t.resource);if(!a.valid)return a;if(Al(r,o)>=s_)return p(P.VALIDATION_ERROR_GOLD_PURCHASE_LIMIT_REACHED,`You can only buy ${s_} resources with gold per turn`);let s=r.getPlayerState(o);return s?s.gold<Ri?p(P.VALIDATION_ERROR_INSUFFICIENT_GOLD,`A resource costs ${Ri} gold`):(r.resourceDeck.get(t.resource)??0)<=0?p(P.VALIDATION_ERROR_BANK_EMPTY,"The supply has none of that resource"):Ee():p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found")}validateBuyGold(r,t){let o=t.player,i=xl(r);if(!i.valid)return i;let n=ze(r,o);if(!n.valid)return n;let a=CN(t.resource);if(!a.valid)return a;let s=r.getPlayerState(o);if(!s)return p(P.VALIDATION_ERROR_INVALID_TARGET_PLAYER,"Player state not found");let u=N_(r,o,t.resource);return s.getResourceCount(t.resource)<u?p(P.VALIDATION_ERROR_INSUFFICIENT_RESOURCES,`You need ${u} of that resource for 1 gold`):Ee()}};var Vn=class{static{E(this,"ActionValidator")}coreValidator;devCardsValidator;tradingValidator;seafarersValidator;ckKnightsValidator;ckCityImprovementsValidator;ckBarbariansValidator;ckScienceCardsValidator;ckPoliticsCardsValidator;ckTradeCardsValidator;fishermanValidator;eventCardsValidator;merchantTrainsValidator;trollsValidator;riversValidator;constructor(){this.coreValidator=new I_,this.devCardsValidator=new C_,this.tradingValidator=new P_,this.seafarersValidator=new p_,this.ckKnightsValidator=new h_,this.ckCityImprovementsValidator=new D_,this.ckBarbariansValidator=new m_,this.ckScienceCardsValidator=new g_,this.ckPoliticsCardsValidator=new y_,this.ckTradeCardsValidator=new M_,this.fishermanValidator=new L_,this.eventCardsValidator=new Kd,this.merchantTrainsValidator=new Wd,this.trollsValidator=new Jd,this.riversValidator=new G_}validate(r,t){if(r.winner!==void 0)return p(P.VALIDATION_ERROR_GAME_OVER,"Game is over. No more actions are allowed.");if(r.paused&&t.type!==N.ACTION_TYPE_UNPAUSE&&t.type!==N.ACTION_TYPE_VOTE_TO_CONTINUE)return t.type===N.ACTION_TYPE_PAUSE?p(P.VALIDATION_ERROR_GAME_PAUSED,"Game is already paused"):p(P.VALIDATION_ERROR_GAME_PAUSED,"Game is paused. Only unpause or vote to continue actions are allowed.");switch(t.type){case N.ACTION_TYPE_ROLL_DICE:return this.coreValidator.validateRollDice(r,t);case N.ACTION_TYPE_BUILD_ROAD:return this.coreValidator.validateBuildRoad(r,t);case N.ACTION_TYPE_BUILD_SETTLEMENT:return this.coreValidator.validateBuildSettlement(r,t);case N.ACTION_TYPE_BUILD_CITY:return this.coreValidator.validateBuildCity(r,t);case N.ACTION_TYPE_BUY_DEV_CARD:return this.coreValidator.validateBuyDevCard(r,t);case N.ACTION_TYPE_BUY_PROGRESS_CARD:return this.coreValidator.validateBuyProgressCard(r,t);case N.ACTION_TYPE_BUILD_BRIDGE:return this.riversValidator.validateBuildBridge(r,t);case N.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD:return this.riversValidator.validateBuyResourceWithGold(r,t);case N.ACTION_TYPE_BUY_GOLD:return this.riversValidator.validateBuyGold(r,t);case N.ACTION_TYPE_PLAY_KNIGHT:return this.devCardsValidator.validatePlayKnight(r,t);case N.ACTION_TYPE_PLAY_ROAD_BUILDING:return this.devCardsValidator.validatePlayRoadBuilding(r,t);case N.ACTION_TYPE_PLAY_YEAR_OF_PLENTY:return this.devCardsValidator.validatePlayYearOfPlenty(r,t);case N.ACTION_TYPE_PLAY_MONOPOLY:return this.devCardsValidator.validatePlayMonopoly(r,t);case N.ACTION_TYPE_PLAY_VICTORY_POINT:return this.devCardsValidator.validatePlayVictoryPoint(r,t);case N.ACTION_TYPE_PROPOSE_TRADE:return this.tradingValidator.validateProposeTrade(r,t);case N.ACTION_TYPE_PROPOSE_MULTI_TRADE:return this.tradingValidator.validateProposeMultiTrade(r,t);case N.ACTION_TYPE_ACCEPT_TRADE:return this.tradingValidator.validateAcceptTrade(r,t);case N.ACTION_TYPE_REJECT_TRADE:return this.tradingValidator.validateRejectTrade(r,t);case N.ACTION_TYPE_CANCEL_TRADE:return this.tradingValidator.validateCancelTrade(r,t);case N.ACTION_TYPE_EXECUTE_TRADE:return this.tradingValidator.validateExecuteTrade(r,t);case N.ACTION_TYPE_TRADE_WITH_BANK:return this.tradingValidator.validateTradeWithBank(r,t);case N.ACTION_TYPE_TOGGLE_TRADE_EMBARGO:return this.tradingValidator.validateToggleTradeEmbargo(r,t);case N.ACTION_TYPE_END_TURN:return this.coreValidator.validateEndTurn(r,t);case N.ACTION_TYPE_DISCARD_RESOURCES:return this.coreValidator.validateDiscardResources(r,t);case N.ACTION_TYPE_MOVE_ROBBER:return this.coreValidator.validateMoveRobber(r,t);case N.ACTION_TYPE_STEAL_FROM_PLAYER:return this.coreValidator.validateStealFromPlayer(r,t);case N.ACTION_TYPE_SELECT_FREE_RESOURCE:return this.coreValidator.validateSelectFreeResource(r,t);case N.ACTION_TYPE_PLACE_FREE_ROAD:return this.coreValidator.validatePlaceFreeRoad(r,t);case N.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT:return this.coreValidator.validatePlaceInitialSettlement(r,t);case N.ACTION_TYPE_PLACE_INITIAL_ROAD:return this.coreValidator.validatePlaceInitialRoad(r,t);case N.ACTION_TYPE_PLACE_INITIAL_SHIP:return this.coreValidator.validatePlaceInitialShip(r,t);case N.ACTION_TYPE_BUILD_SHIP:return this.seafarersValidator.validateBuildShip(r,t);case N.ACTION_TYPE_PLACE_FREE_SHIP:return this.seafarersValidator.validatePlaceFreeShip(r,t);case N.ACTION_TYPE_MOVE_SHIP:return this.seafarersValidator.validateMoveShip(r,t);case N.ACTION_TYPE_MOVE_PIRATE:return this.seafarersValidator.validateMovePirate(r,t);case N.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE:return this.seafarersValidator.validateStealFromPlayerPirate(r,t);case N.ACTION_TYPE_BUILD_KNIGHT:return this.ckKnightsValidator.validateBuildKnight(r,t);case N.ACTION_TYPE_ACTIVATE_KNIGHT:return this.ckKnightsValidator.validateActivateKnight(r,t);case N.ACTION_TYPE_PROMOTE_KNIGHT:return this.ckKnightsValidator.validatePromoteKnight(r,t);case N.ACTION_TYPE_MOVE_KNIGHT:return this.ckKnightsValidator.validateMoveKnight(r,t);case N.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT:return this.ckKnightsValidator.validateChaseRobberWithKnight(r,t);case N.ACTION_TYPE_USE_KNIGHT_ERRANT:return this.ckKnightsValidator.validateUseKnightErrant(r,t);case N.ACTION_TYPE_BUILD_CITY_WALL:return this.ckCityImprovementsValidator.validateBuildCityWall(r,t);case N.ACTION_TYPE_BUILD_CITY_IMPROVEMENT:return this.ckCityImprovementsValidator.validateBuildCityImprovement(r,t);case N.ACTION_TYPE_SELECT_METROPOLIS_CITY:return this.ckCityImprovementsValidator.validateSelectMetropolisCity(r,t);case N.ACTION_TYPE_SELECT_CITY_TO_PILLAGE:return this.ckBarbariansValidator.validateSelectCityToPillage(r,t);case N.ACTION_TYPE_SELECT_DEFENDER_PROGRESS:return this.ckBarbariansValidator.validateSelectDefenderProgress(r,t);case N.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE:return this.ckBarbariansValidator.validateCommitKnightsToDefense(r,t);case N.ACTION_TYPE_PLAY_ALCHEMIST:return this.ckScienceCardsValidator.validatePlayAlchemist(r,t);case N.ACTION_TYPE_SELECT_ALCHEMIST_DICE:return this.ckScienceCardsValidator.validateSelectAlchemistDice(r,t);case N.ACTION_TYPE_PLAY_CRANE:return this.ckScienceCardsValidator.validatePlayCrane(r,t);case N.ACTION_TYPE_PLAY_ENGINEER:return this.ckScienceCardsValidator.validatePlayEngineer(r,t);case N.ACTION_TYPE_PLAY_INVENTOR:return this.ckScienceCardsValidator.validatePlayInventor(r,t);case N.ACTION_TYPE_PLAY_IRRIGATION:return this.ckScienceCardsValidator.validatePlayIrrigation(r,t);case N.ACTION_TYPE_PLAY_MEDICINE:return this.ckScienceCardsValidator.validatePlayMedicine(r,t);case N.ACTION_TYPE_PLAY_MINING:return this.ckScienceCardsValidator.validatePlayMining(r,t);case N.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING:return this.ckScienceCardsValidator.validatePlayProgressRoadBuilding(r,t);case N.ACTION_TYPE_PLAY_SMITH:return this.ckScienceCardsValidator.validatePlaySmith(r,t);case N.ACTION_TYPE_PLAY_BISHOP:return this.ckPoliticsCardsValidator.validatePlayBishop(r,t);case N.ACTION_TYPE_PLAY_DESERTER:return this.ckPoliticsCardsValidator.validatePlayDeserter(r,t);case N.ACTION_TYPE_SELECT_DESERTER_KNIGHT:return this.ckPoliticsCardsValidator.validateSelectDeserterKnight(r,t);case N.ACTION_TYPE_PLAY_DIPLOMAT:return this.ckPoliticsCardsValidator.validatePlayDiplomat(r,t);case N.ACTION_TYPE_PLAY_INTRIGUE:return this.ckPoliticsCardsValidator.validatePlayIntrigue(r,t);case N.ACTION_TYPE_PLAY_SABOTEUR:return this.ckPoliticsCardsValidator.validatePlaySaboteur(r,t);case N.ACTION_TYPE_PLAY_SPY:return this.ckPoliticsCardsValidator.validatePlaySpy(r,t);case N.ACTION_TYPE_SELECT_SPY_TARGET_CARD:return this.ckPoliticsCardsValidator.validateSelectSpyTargetCard(r,t);case N.ACTION_TYPE_PLAY_WARLORD:return this.ckPoliticsCardsValidator.validatePlayWarlord(r,t);case N.ACTION_TYPE_PLAY_WEDDING:return this.ckPoliticsCardsValidator.validatePlayWedding(r,t);case N.ACTION_TYPE_GIVE_WEDDING_CARDS:return this.ckPoliticsCardsValidator.validateGiveWeddingCards(r,t);case N.ACTION_TYPE_DISCARD_PROGRESS_CARD:return this.ckPoliticsCardsValidator.validateDiscardProgressCard(r,t);case N.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR:return this.ckTradeCardsValidator.validatePlayCommercialHarbor(r,t);case N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY:return this.ckTradeCardsValidator.validateCommercialHarborGiveCommodity(r,t);case N.ACTION_TYPE_PLAY_MASTER_MERCHANT:return this.ckTradeCardsValidator.validatePlayMasterMerchant(r,t);case N.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS:return this.ckTradeCardsValidator.validateSelectMasterMerchantCards(r,t);case N.ACTION_TYPE_PLAY_MERCHANT:return this.ckTradeCardsValidator.validatePlayMerchant(r,t);case N.ACTION_TYPE_PLAY_MERCHANT_FLEET:return this.ckTradeCardsValidator.validatePlayMerchantFleet(r,t);case N.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY:return this.ckTradeCardsValidator.validatePlayResourceMonopoly(r,t);case N.ACTION_TYPE_PLAY_TRADE_MONOPOLY:return this.ckTradeCardsValidator.validatePlayTradeMonopoly(r,t);case N.ACTION_TYPE_PASS_OLD_BOOT:return this.fishermanValidator.validatePassOldBoot(r,t);case N.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER:return this.fishermanValidator.validateSpendFishBanishRobber(r,t);case N.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE:return this.fishermanValidator.validateSpendFishStealResource(r,t);case N.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE:return this.fishermanValidator.validateSpendFishTakeResource(r,t);case N.ACTION_TYPE_SPEND_FISH_BUILD_ROAD:return this.fishermanValidator.validateSpendFishBuildRoad(r,t);case N.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD:return this.fishermanValidator.validateSpendFishDrawDevCard(r,t);case N.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD:return this.eventCardsValidator.validateSelectEarthquakeRoad(r,t);case N.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE:return this.eventCardsValidator.validateGiveEventCardResource(r,t);case N.ACTION_TYPE_EVENT_CARD_STEAL:return this.eventCardsValidator.validateEventCardSteal(r,t);case N.ACTION_TYPE_WAGON_VOTE:return this.merchantTrainsValidator.validateWagonVote(r,t);case N.ACTION_TYPE_FEED_TROLL:return this.trollsValidator.validateFeedTroll(r,t);case N.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT:return this.trollsValidator.validateKickTrollWithKnight(r,t);case N.ACTION_TYPE_RESIGN:return this.coreValidator.validateResign(r,t);case N.ACTION_TYPE_PAUSE:return this.coreValidator.validatePause(r,t);case N.ACTION_TYPE_UNPAUSE:return this.coreValidator.validateUnpause(r,t);case N.ACTION_TYPE_VOTE_TO_CONTINUE:return this.coreValidator.validateVoteToContinue(r,t);case N.ACTION_TYPE_VOTE_DICE_ROLL:return this.coreValidator.validateVoteDiceRoll(r,t);default:return p(P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE,"Unknown action type")}}getValidActions(r,t){let o=[];if(r.hasPendingDiscards(t))return o;if(r.hasPendingFreeResources(t)){let i=Nn;for(let n of i)r.getResourceCount(n)>0&&o.push({type:N.ACTION_TYPE_SELECT_FREE_RESOURCE,player:t,resource:n});return o}if(r.hasPendingFreeStructures(t)){let i=r.getNextPendingFreeStructure(t);return i===F.BUILDING_ROAD||F.BUILDING_SHIP,o}if(r.currentPlayer!==t){for(let i of r.getActiveTrades())i.proposer!==t&&(o.push({type:N.ACTION_TYPE_ACCEPT_TRADE,player:t,tradeId:i.id}),o.push({type:N.ACTION_TYPE_REJECT_TRADE,player:t,tradeId:i.id}));return o}return r.isSetupPhase?o:r.pendingDiceRoll?(o.push({type:N.ACTION_TYPE_ROLL_DICE,player:t}),o):(r.pendingRobberOrPiratePlacement||r.pendingRobberStealLocation||o.push({type:N.ACTION_TYPE_END_TURN,player:t}),o)}};function wt(e){let r=new Map;for(let{resource:t,count:o}of e)o>0&&r.set(t,o);return r}E(wt,"resourceCountsToMap");function An(e){let r=new Map;for(let{commodity:t,count:o}of e)o>0&&r.set(t,o);return r}E(An,"commodityCountsToMap");function Ht(e){let r=[];for(let[t,o]of e)o>0&&r.push({resource:t,count:o});return r}E(Ht,"mapToResourceCounts");function Sn(e){let r=[];for(let[t,o]of e)o>0&&r.push({commodity:t,count:o});return r}E(Sn,"mapToCommodityCounts");function WD(e){let r=[];for(let[t,o]of e)r.push({opponent:t,resource:o});return r}E(WD,"mapToCommercialHarborTrades");function JD(e){let r=new Map;for(let{opponent:t,resource:o}of e)r.set(t,o);return r}E(JD,"commercialHarborTradesToMap");function qd(e){let r={type:e.type,player:e.player};switch(e.type){case N.ACTION_TYPE_ROLL_DICE:return H.fromPartial(r);case N.ACTION_TYPE_BUILD_ROAD:{let t=e;return H.fromPartial({...r,edge:t.edge.toProto()})}case N.ACTION_TYPE_BUILD_SHIP:{let t=e;return H.fromPartial({...r,edge:t.edge.toProto()})}case N.ACTION_TYPE_MOVE_SHIP:{let t=e;return H.fromPartial({...r,fromEdge:t.fromEdge.toProto(),toEdge:t.toEdge.toProto()})}case N.ACTION_TYPE_BUILD_SETTLEMENT:{let t=e;return H.fromPartial({...r,vertex:t.vertex.toProto()})}case N.ACTION_TYPE_BUILD_CITY:{let t=e;return H.fromPartial({...r,vertex:t.vertex.toProto()})}case N.ACTION_TYPE_BUY_DEV_CARD:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_KNIGHT:{let t=e;return H.fromPartial({...r,robberLocation:t.robberLocation?.toProto(),targetPlayer:t.targetPlayer??x.PLAYER_COLOR_UNSPECIFIED})}case N.ACTION_TYPE_PLAY_ROAD_BUILDING:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_YEAR_OF_PLENTY:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_MONOPOLY:{let t=e;return H.fromPartial({...r,resource:t.resource})}case N.ACTION_TYPE_PROPOSE_TRADE:{let t=e;return H.fromPartial({...r,offering:Ht(t.offering),requesting:Ht(t.requesting),offeringCommodities:t.offeringCommodities?Sn(t.offeringCommodities):[],requestingCommodities:t.requestingCommodities?Sn(t.requestingCommodities):[],offeringGold:t.offeringGold??0,requestingGold:t.requestingGold??0,counterTradeId:t.counterTradeId??0})}case N.ACTION_TYPE_PROPOSE_MULTI_TRADE:{let t=e;return H.fromPartial({...r,tradeProposals:t.proposals.map(o=>Qr.create({offering:Ht(o.offering),requesting:Ht(o.requesting),offeringCommodities:o.offeringCommodities?Sn(o.offeringCommodities):[],requestingCommodities:o.requestingCommodities?Sn(o.requestingCommodities):[],offeringGold:o.offeringGold??0,requestingGold:o.requestingGold??0}))})}case N.ACTION_TYPE_ACCEPT_TRADE:{let t=e;return H.fromPartial({...r,tradeId:t.tradeId})}case N.ACTION_TYPE_REJECT_TRADE:{let t=e;return H.fromPartial({...r,tradeId:t.tradeId})}case N.ACTION_TYPE_CANCEL_TRADE:{let t=e;return H.fromPartial({...r,tradeId:t.tradeId})}case N.ACTION_TYPE_EXECUTE_TRADE:{let t=e;return H.fromPartial({...r,tradeId:t.tradeId,tradePartner:t.tradePartner})}case N.ACTION_TYPE_TRADE_WITH_BANK:{let t=e;return H.fromPartial({...r,offering:Ht(t.offering),requesting:Ht(t.requesting),offeringCommodities:t.offeringCommodities?Sn(t.offeringCommodities):[],requestingCommodities:t.requestingCommodities?Sn(t.requestingCommodities):[]})}case N.ACTION_TYPE_END_TURN:return H.fromPartial(r);case N.ACTION_TYPE_DISCARD_RESOURCES:{let t=e;return H.fromPartial({...r,resources:Ht(t.resources),commodities:t.commodities?Sn(t.commodities):[]})}case N.ACTION_TYPE_MOVE_ROBBER:{let t=e;return H.fromPartial({...r,robberLocation:t.location.toProto()})}case N.ACTION_TYPE_STEAL_FROM_PLAYER:{let t=e;return H.fromPartial({...r,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_SELECT_FREE_RESOURCE:{let t=e;return H.fromPartial({...r,resource:t.resource})}case N.ACTION_TYPE_PLACE_FREE_ROAD:{let t=e;return H.fromPartial({...r,edge:t.edge.toProto()})}case N.ACTION_TYPE_PLACE_FREE_SHIP:{let t=e;return H.fromPartial({...r,edge:t.edge.toProto()})}case N.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT:{let t=e;return H.fromPartial({...r,vertex:t.vertex.toProto()})}case N.ACTION_TYPE_PLACE_INITIAL_ROAD:{let t=e;return H.fromPartial({...r,edge:t.edge.toProto()})}case N.ACTION_TYPE_PLACE_INITIAL_SHIP:{let t=e;return H.fromPartial({...r,edge:t.edge.toProto()})}case N.ACTION_TYPE_MOVE_PIRATE:{let t=e;return H.fromPartial({...r,pirateLocation:t.location.toProto()})}case N.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE:{let t=e;return H.fromPartial({...r,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_PLAY_ALCHEMIST:return H.fromPartial(r);case N.ACTION_TYPE_SELECT_ALCHEMIST_DICE:{let t=e;return H.fromPartial({...r,alchemistDie1:t.redDie,alchemistDie2:t.yellowDie})}case N.ACTION_TYPE_PLAY_ENGINEER:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_CRANE:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_MEDICINE:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_MINING:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_IRRIGATION:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_WARLORD:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_SABOTEUR:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY:{let t=e;return H.fromPartial({...r,resource:t.resource})}case N.ACTION_TYPE_PLAY_TRADE_MONOPOLY:{let t=e;return H.fromPartial({...r,commodity:t.commodity})}case N.ACTION_TYPE_PLAY_BISHOP:{let t=e;return H.fromPartial({...r,robberLocation:t.robberLocation?.toProto()})}case N.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_SMITH:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_INVENTOR:{let t=e;return H.fromPartial({...r,inventorHex1:t.hex1.toProto(),inventorHex2:t.hex2.toProto()})}case N.ACTION_TYPE_PLAY_MERCHANT:{let t=e;return H.fromPartial({...r,merchantLocation:t.hex.toProto()})}case N.ACTION_TYPE_PLAY_MERCHANT_FLEET:{let t=e;return H.fromPartial({...r,resource:t.resource??S.RESOURCE_UNSPECIFIED,commodity:t.commodity??j.COMMODITY_UNSPECIFIED})}case N.ACTION_TYPE_PLAY_DESERTER:{let t=e;return H.fromPartial({...r,deserterTargetPlayer:t.targetPlayer})}case N.ACTION_TYPE_SELECT_DESERTER_KNIGHT:{let t=e;return H.fromPartial({...r,deserterKnightLocation:t.knightLocation.toProto()})}case N.ACTION_TYPE_SELECT_METROPOLIS_CITY:{let t=e;return H.fromPartial({...r,metropolisCityLocation:t.cityVertex.toProto()})}case N.ACTION_TYPE_PLAY_DIPLOMAT:{let t=e;return H.fromPartial({...r,edge:t.targetRoad.toProto()})}case N.ACTION_TYPE_PLAY_INTRIGUE:{let t=e;return H.fromPartial({...r,knightLocation:t.targetKnight.toProto(),knightDestination:t.destination?.toProto()})}case N.ACTION_TYPE_PLAY_WEDDING:return H.fromPartial(r);case N.ACTION_TYPE_GIVE_WEDDING_CARDS:{let t=e;return H.fromPartial({...r,resources:Ht(t.resources),commodities:Sn(t.commodities)})}case N.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR:{let t=e;return H.fromPartial({...r,commercialHarborTrades:WD(t.selectedTrades)})}case N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY:{let t=e;return H.fromPartial({...r,commodity:t.commodity})}case N.ACTION_TYPE_PLAY_SPY:{let t=e;return H.fromPartial({...r,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_SELECT_SPY_TARGET_CARD:{let t=e;return H.fromPartial({...r,progressCard:t.progressCard})}case N.ACTION_TYPE_PLAY_MASTER_MERCHANT:{let t=e;return H.fromPartial({...r,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS:{let t=e;return H.fromPartial({...r,resources:Ht(t.resources),commodities:Sn(t.commodities)})}case N.ACTION_TYPE_BUILD_KNIGHT:{let t=e;return H.fromPartial({...r,vertex:t.vertex.toProto()})}case N.ACTION_TYPE_ACTIVATE_KNIGHT:{let t=e;return H.fromPartial({...r,vertex:t.vertex.toProto()})}case N.ACTION_TYPE_PROMOTE_KNIGHT:{let t=e;return H.fromPartial({...r,vertex:t.vertex.toProto()})}case N.ACTION_TYPE_MOVE_KNIGHT:{let t=e;return H.fromPartial({...r,knightLocation:t.fromVertex.toProto(),knightDestination:t.toVertex.toProto()})}case N.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT:{let t=e;return H.fromPartial({...r,knightLocation:t.knightVertex.toProto(),robberLocation:t.newRobberLocation.toProto(),targetPlayer:t.targetPlayer??x.PLAYER_COLOR_UNSPECIFIED})}case N.ACTION_TYPE_USE_KNIGHT_ERRANT:{let t=e;return H.fromPartial({...r,knightLocation:t.knightVertex.toProto(),robberLocation:t.newRobberLocation.toProto(),targetPlayer:t.targetPlayer??x.PLAYER_COLOR_UNSPECIFIED})}case N.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE:{let t=e;return H.fromPartial({...r,committedKnights:t.knightVertices.map(o=>o.toProto())})}case N.ACTION_TYPE_BUILD_CITY_IMPROVEMENT:{let t=e;return H.fromPartial({...r,improvementTrack:t.track})}case N.ACTION_TYPE_BUILD_CITY_WALL:{let t=e;return H.fromPartial({...r,cityWallLocation:t.cityVertex.toProto()})}case N.ACTION_TYPE_SELECT_CITY_TO_PILLAGE:{let t=e;return H.fromPartial({...r,pillageCityLocation:t.cityVertex.toProto()})}case N.ACTION_TYPE_SELECT_DEFENDER_PROGRESS:{let t=e;return H.fromPartial({...r,improvementTrack:t.track})}case N.ACTION_TYPE_PASS_OLD_BOOT:{let t=e;return H.fromPartial({...r,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER:return H.fromPartial(r);case N.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE:{let t=e;return H.fromPartial({...r,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE:return H.fromPartial(r);case N.ACTION_TYPE_SPEND_FISH_BUILD_ROAD:return H.fromPartial(r);case N.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD:return H.fromPartial(r);case N.ACTION_TYPE_RESIGN:return H.fromPartial(r);case N.ACTION_TYPE_PAUSE:return H.fromPartial(r);case N.ACTION_TYPE_UNPAUSE:return H.fromPartial(r);case N.ACTION_TYPE_VOTE_TO_CONTINUE:return H.fromPartial(r);case N.ACTION_TYPE_PLAY_VICTORY_POINT:return H.fromPartial(r);case N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE:{let t=e;return H.fromPartial({...r,resource:t.resource,targetPlayer:t.opponent})}case N.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD:{let t=e;return H.fromPartial({...r,edge:t.edge.toProto()})}case N.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE:{let t=e;return H.fromPartial({...r,resource:t.resource,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_EVENT_CARD_STEAL:{let t=e;return H.fromPartial({...r,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_WAGON_VOTE:{let t=e;return H.fromPartial({...r,woolBid:t.woolBid,wheatBid:t.wheatBid,preferredWagonEdge:t.preferredEdge?.toProto(),preferredWagonFacing:t.preferredFacing?.toProto()})}case N.ACTION_TYPE_FEED_TROLL:{let t=e;return H.fromPartial({...r,trollHex:t.trollHex.toProto(),resources:Ht(t.resources)})}case N.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT:{let t=e;return H.fromPartial({...r,knightLocation:t.knightVertex.toProto(),trollHex:t.trollHex.toProto()})}case N.ACTION_TYPE_VOTE_DICE_ROLL:return H.fromPartial(r);case N.ACTION_TYPE_TOGGLE_TRADE_EMBARGO:{let t=e;return H.fromPartial({...r,targetPlayer:t.targetPlayer})}case N.ACTION_TYPE_DISCARD_PROGRESS_CARD:{let t=e;return H.fromPartial({...r,progressCard:t.card})}case N.ACTION_TYPE_BUY_PROGRESS_CARD:{let t=e;return H.fromPartial({...r,improvementTrack:t.track})}case N.ACTION_TYPE_BUILD_BRIDGE:{let t=e;return H.fromPartial({...r,edge:t.edge.toProto()})}case N.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD:{let t=e;return H.fromPartial({...r,resource:t.resource})}case N.ACTION_TYPE_BUY_GOLD:{let t=e;return H.fromPartial({...r,resource:t.resource})}default:{let t=e;throw new Error(`Unhandled action type: ${t.type}`)}}}E(qd,"actionToProto");function Zd(e){let r={type:e.type,player:e.player};switch(e.type){case N.ACTION_TYPE_ROLL_DICE:return{...r,type:N.ACTION_TYPE_ROLL_DICE};case N.ACTION_TYPE_BUILD_ROAD:return{...r,type:N.ACTION_TYPE_BUILD_ROAD,edge:Ne.fromProto(e.edge)};case N.ACTION_TYPE_BUILD_SHIP:return{...r,type:N.ACTION_TYPE_BUILD_SHIP,edge:Ne.fromProto(e.edge)};case N.ACTION_TYPE_MOVE_SHIP:return{...r,type:N.ACTION_TYPE_MOVE_SHIP,fromEdge:Ne.fromProto(e.fromEdge),toEdge:Ne.fromProto(e.toEdge)};case N.ACTION_TYPE_BUILD_SETTLEMENT:return{...r,type:N.ACTION_TYPE_BUILD_SETTLEMENT,vertex:oe.fromProto(e.vertex)};case N.ACTION_TYPE_BUILD_CITY:return{...r,type:N.ACTION_TYPE_BUILD_CITY,vertex:oe.fromProto(e.vertex)};case N.ACTION_TYPE_BUY_DEV_CARD:return{...r,type:N.ACTION_TYPE_BUY_DEV_CARD};case N.ACTION_TYPE_PLAY_KNIGHT:return{...r,type:N.ACTION_TYPE_PLAY_KNIGHT,robberLocation:e.robberLocation?_.fromProto(e.robberLocation):void 0,targetPlayer:e.targetPlayer!==x.PLAYER_COLOR_UNSPECIFIED?e.targetPlayer:void 0};case N.ACTION_TYPE_PLAY_ROAD_BUILDING:return{...r,type:N.ACTION_TYPE_PLAY_ROAD_BUILDING};case N.ACTION_TYPE_PLAY_YEAR_OF_PLENTY:return{...r,type:N.ACTION_TYPE_PLAY_YEAR_OF_PLENTY};case N.ACTION_TYPE_PLAY_MONOPOLY:return{...r,type:N.ACTION_TYPE_PLAY_MONOPOLY,resource:e.resource};case N.ACTION_TYPE_PROPOSE_TRADE:return{...r,type:N.ACTION_TYPE_PROPOSE_TRADE,offering:wt(e.offering),requesting:wt(e.requesting),offeringCommodities:e.offeringCommodities&&e.offeringCommodities.length>0?An(e.offeringCommodities):void 0,requestingCommodities:e.requestingCommodities&&e.requestingCommodities.length>0?An(e.requestingCommodities):void 0,offeringGold:e.offeringGold!==0?e.offeringGold:void 0,requestingGold:e.requestingGold!==0?e.requestingGold:void 0,counterTradeId:e.counterTradeId!==0?e.counterTradeId:void 0};case N.ACTION_TYPE_PROPOSE_MULTI_TRADE:return{...r,type:N.ACTION_TYPE_PROPOSE_MULTI_TRADE,proposals:e.tradeProposals.map(t=>({offering:wt(t.offering),requesting:wt(t.requesting),offeringCommodities:t.offeringCommodities.length>0?An(t.offeringCommodities):void 0,requestingCommodities:t.requestingCommodities.length>0?An(t.requestingCommodities):void 0,offeringGold:t.offeringGold!==0?t.offeringGold:void 0,requestingGold:t.requestingGold!==0?t.requestingGold:void 0}))};case N.ACTION_TYPE_ACCEPT_TRADE:return{...r,type:N.ACTION_TYPE_ACCEPT_TRADE,tradeId:e.tradeId};case N.ACTION_TYPE_REJECT_TRADE:return{...r,type:N.ACTION_TYPE_REJECT_TRADE,tradeId:e.tradeId};case N.ACTION_TYPE_CANCEL_TRADE:return{...r,type:N.ACTION_TYPE_CANCEL_TRADE,tradeId:e.tradeId};case N.ACTION_TYPE_EXECUTE_TRADE:return{...r,type:N.ACTION_TYPE_EXECUTE_TRADE,tradeId:e.tradeId,tradePartner:e.tradePartner};case N.ACTION_TYPE_TRADE_WITH_BANK:return{...r,type:N.ACTION_TYPE_TRADE_WITH_BANK,offering:wt(e.offering),requesting:wt(e.requesting),offeringCommodities:e.offeringCommodities&&e.offeringCommodities.length>0?An(e.offeringCommodities):void 0,requestingCommodities:e.requestingCommodities&&e.requestingCommodities.length>0?An(e.requestingCommodities):void 0};case N.ACTION_TYPE_END_TURN:return{...r,type:N.ACTION_TYPE_END_TURN};case N.ACTION_TYPE_DISCARD_RESOURCES:return{...r,type:N.ACTION_TYPE_DISCARD_RESOURCES,resources:wt(e.resources),commodities:e.commodities&&e.commodities.length>0?An(e.commodities):void 0};case N.ACTION_TYPE_MOVE_ROBBER:return{...r,type:N.ACTION_TYPE_MOVE_ROBBER,location:_.fromProto(e.robberLocation)};case N.ACTION_TYPE_STEAL_FROM_PLAYER:return{...r,type:N.ACTION_TYPE_STEAL_FROM_PLAYER,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_SELECT_FREE_RESOURCE:return{...r,type:N.ACTION_TYPE_SELECT_FREE_RESOURCE,resource:e.resource};case N.ACTION_TYPE_PLACE_FREE_ROAD:return{...r,type:N.ACTION_TYPE_PLACE_FREE_ROAD,edge:Ne.fromProto(e.edge)};case N.ACTION_TYPE_PLACE_FREE_SHIP:return{...r,type:N.ACTION_TYPE_PLACE_FREE_SHIP,edge:Ne.fromProto(e.edge)};case N.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT:return{...r,type:N.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT,vertex:oe.fromProto(e.vertex)};case N.ACTION_TYPE_PLACE_INITIAL_ROAD:return{...r,type:N.ACTION_TYPE_PLACE_INITIAL_ROAD,edge:Ne.fromProto(e.edge)};case N.ACTION_TYPE_PLACE_INITIAL_SHIP:return{...r,type:N.ACTION_TYPE_PLACE_INITIAL_SHIP,edge:Ne.fromProto(e.edge)};case N.ACTION_TYPE_PLAY_ALCHEMIST:return{...r,type:N.ACTION_TYPE_PLAY_ALCHEMIST};case N.ACTION_TYPE_SELECT_ALCHEMIST_DICE:return{...r,type:N.ACTION_TYPE_SELECT_ALCHEMIST_DICE,redDie:e.alchemistDie1,yellowDie:e.alchemistDie2};case N.ACTION_TYPE_PLAY_ENGINEER:return{...r,type:N.ACTION_TYPE_PLAY_ENGINEER};case N.ACTION_TYPE_PLAY_CRANE:return{...r,type:N.ACTION_TYPE_PLAY_CRANE};case N.ACTION_TYPE_PLAY_MEDICINE:return{...r,type:N.ACTION_TYPE_PLAY_MEDICINE};case N.ACTION_TYPE_PLAY_MINING:return{...r,type:N.ACTION_TYPE_PLAY_MINING};case N.ACTION_TYPE_PLAY_IRRIGATION:return{...r,type:N.ACTION_TYPE_PLAY_IRRIGATION};case N.ACTION_TYPE_PLAY_WARLORD:return{...r,type:N.ACTION_TYPE_PLAY_WARLORD};case N.ACTION_TYPE_PLAY_SABOTEUR:return{...r,type:N.ACTION_TYPE_PLAY_SABOTEUR};case N.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY:return{...r,type:N.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY,resource:e.resource};case N.ACTION_TYPE_PLAY_TRADE_MONOPOLY:return{...r,type:N.ACTION_TYPE_PLAY_TRADE_MONOPOLY,commodity:e.commodity};case N.ACTION_TYPE_MOVE_PIRATE:return{...r,type:N.ACTION_TYPE_MOVE_PIRATE,location:_.fromProto(e.pirateLocation)};case N.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE:return{...r,type:N.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_PASS_OLD_BOOT:return{...r,type:N.ACTION_TYPE_PASS_OLD_BOOT,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER:return{...r,type:N.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER};case N.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE:return{...r,type:N.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE:return{...r,type:N.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE};case N.ACTION_TYPE_SPEND_FISH_BUILD_ROAD:return{...r,type:N.ACTION_TYPE_SPEND_FISH_BUILD_ROAD};case N.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD:return{...r,type:N.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD};case N.ACTION_TYPE_RESIGN:return{...r,type:N.ACTION_TYPE_RESIGN};case N.ACTION_TYPE_PAUSE:return{...r,type:N.ACTION_TYPE_PAUSE};case N.ACTION_TYPE_UNPAUSE:return{...r,type:N.ACTION_TYPE_UNPAUSE};case N.ACTION_TYPE_VOTE_TO_CONTINUE:return{...r,type:N.ACTION_TYPE_VOTE_TO_CONTINUE};case N.ACTION_TYPE_BUILD_KNIGHT:return{...r,type:N.ACTION_TYPE_BUILD_KNIGHT,vertex:oe.fromProto(e.vertex)};case N.ACTION_TYPE_ACTIVATE_KNIGHT:return{...r,type:N.ACTION_TYPE_ACTIVATE_KNIGHT,vertex:oe.fromProto(e.vertex)};case N.ACTION_TYPE_PROMOTE_KNIGHT:return{...r,type:N.ACTION_TYPE_PROMOTE_KNIGHT,vertex:oe.fromProto(e.vertex)};case N.ACTION_TYPE_MOVE_KNIGHT:return{...r,type:N.ACTION_TYPE_MOVE_KNIGHT,fromVertex:oe.fromProto(e.knightLocation),toVertex:oe.fromProto(e.knightDestination)};case N.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT:return{...r,type:N.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT,knightVertex:oe.fromProto(e.knightLocation),newRobberLocation:_.fromProto(e.robberLocation),targetPlayer:e.targetPlayer!==x.PLAYER_COLOR_UNSPECIFIED?e.targetPlayer:void 0};case N.ACTION_TYPE_USE_KNIGHT_ERRANT:return{...r,type:N.ACTION_TYPE_USE_KNIGHT_ERRANT,knightVertex:oe.fromProto(e.knightLocation),newRobberLocation:_.fromProto(e.robberLocation),targetPlayer:e.targetPlayer!==x.PLAYER_COLOR_UNSPECIFIED?e.targetPlayer:void 0};case N.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE:return{...r,type:N.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE,knightVertices:e.committedKnights.map(t=>oe.fromProto(t))};case N.ACTION_TYPE_BUILD_CITY_IMPROVEMENT:return{...r,type:N.ACTION_TYPE_BUILD_CITY_IMPROVEMENT,track:e.improvementTrack};case N.ACTION_TYPE_BUILD_CITY_WALL:return{...r,type:N.ACTION_TYPE_BUILD_CITY_WALL,cityVertex:oe.fromProto(e.cityWallLocation)};case N.ACTION_TYPE_SELECT_CITY_TO_PILLAGE:return{...r,type:N.ACTION_TYPE_SELECT_CITY_TO_PILLAGE,cityVertex:oe.fromProto(e.pillageCityLocation)};case N.ACTION_TYPE_SELECT_DEFENDER_PROGRESS:return{...r,type:N.ACTION_TYPE_SELECT_DEFENDER_PROGRESS,track:e.improvementTrack};case N.ACTION_TYPE_PLAY_BISHOP:return{...r,type:N.ACTION_TYPE_PLAY_BISHOP,robberLocation:e.robberLocation?_.fromProto(e.robberLocation):void 0};case N.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING:return{...r,type:N.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING};case N.ACTION_TYPE_PLAY_SMITH:return{...r,type:N.ACTION_TYPE_PLAY_SMITH};case N.ACTION_TYPE_PLAY_INVENTOR:return{...r,type:N.ACTION_TYPE_PLAY_INVENTOR,hex1:_.fromProto(e.inventorHex1),hex2:_.fromProto(e.inventorHex2)};case N.ACTION_TYPE_PLAY_MERCHANT:return{...r,type:N.ACTION_TYPE_PLAY_MERCHANT,hex:_.fromProto(e.merchantLocation)};case N.ACTION_TYPE_PLAY_MERCHANT_FLEET:return{...r,type:N.ACTION_TYPE_PLAY_MERCHANT_FLEET,resource:e.resource!==S.RESOURCE_UNSPECIFIED?e.resource:void 0,commodity:e.commodity!==j.COMMODITY_UNSPECIFIED?e.commodity:void 0};case N.ACTION_TYPE_PLAY_DESERTER:return{...r,type:N.ACTION_TYPE_PLAY_DESERTER,targetPlayer:e.deserterTargetPlayer};case N.ACTION_TYPE_SELECT_DESERTER_KNIGHT:return{...r,type:N.ACTION_TYPE_SELECT_DESERTER_KNIGHT,knightLocation:oe.fromProto(e.deserterKnightLocation)};case N.ACTION_TYPE_SELECT_METROPOLIS_CITY:return{...r,type:N.ACTION_TYPE_SELECT_METROPOLIS_CITY,cityVertex:oe.fromProto(e.metropolisCityLocation)};case N.ACTION_TYPE_PLAY_DIPLOMAT:return{...r,type:N.ACTION_TYPE_PLAY_DIPLOMAT,targetRoad:Ne.fromProto(e.edge)};case N.ACTION_TYPE_PLAY_INTRIGUE:return{...r,type:N.ACTION_TYPE_PLAY_INTRIGUE,targetKnight:oe.fromProto(e.knightLocation),destination:e.knightDestination?oe.fromProto(e.knightDestination):void 0};case N.ACTION_TYPE_PLAY_WEDDING:return{...r,type:N.ACTION_TYPE_PLAY_WEDDING};case N.ACTION_TYPE_GIVE_WEDDING_CARDS:return{...r,type:N.ACTION_TYPE_GIVE_WEDDING_CARDS,resources:wt(e.resources),commodities:An(e.commodities)};case N.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR:return{...r,type:N.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR,selectedTrades:JD(e.commercialHarborTrades)};case N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY:return{...r,type:N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY,commodity:e.commodity};case N.ACTION_TYPE_PLAY_SPY:return{...r,type:N.ACTION_TYPE_PLAY_SPY,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_SELECT_SPY_TARGET_CARD:return{...r,type:N.ACTION_TYPE_SELECT_SPY_TARGET_CARD,progressCard:e.progressCard};case N.ACTION_TYPE_PLAY_MASTER_MERCHANT:return{...r,type:N.ACTION_TYPE_PLAY_MASTER_MERCHANT,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS:return{...r,type:N.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS,resources:wt(e.resources),commodities:An(e.commodities)};case N.ACTION_TYPE_PLAY_VICTORY_POINT:return{...r,type:N.ACTION_TYPE_PLAY_VICTORY_POINT};case N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE:return{...r,type:N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE,resource:e.resource,opponent:e.targetPlayer};case N.ACTION_TYPE_DISPLACE_KNIGHT:throw new Error("DISPLACE_KNIGHT action is not yet implemented");case N.ACTION_TYPE_PLACE_PORT:throw new Error("PLACE_PORT action is not yet implemented");case N.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD:return{...r,type:N.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD,edge:Ne.fromProto(e.edge)};case N.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE:return{...r,type:N.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE,resource:e.resource,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_EVENT_CARD_STEAL:return{...r,type:N.ACTION_TYPE_EVENT_CARD_STEAL,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_WAGON_VOTE:return{...r,type:N.ACTION_TYPE_WAGON_VOTE,woolBid:e.woolBid??0,wheatBid:e.wheatBid??0,preferredEdge:e.preferredWagonEdge?Ne.fromProto(e.preferredWagonEdge):void 0,preferredFacing:e.preferredWagonFacing?Ce.fromProto(e.preferredWagonFacing):void 0};case N.ACTION_TYPE_FEED_TROLL:return{...r,type:N.ACTION_TYPE_FEED_TROLL,trollHex:_.fromProto(e.trollHex),resources:wt(e.resources)};case N.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT:return{...r,type:N.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT,knightVertex:oe.fromProto(e.knightLocation),trollHex:_.fromProto(e.trollHex)};case N.ACTION_TYPE_VOTE_DICE_ROLL:return{...r,type:N.ACTION_TYPE_VOTE_DICE_ROLL};case N.ACTION_TYPE_TOGGLE_TRADE_EMBARGO:return{...r,type:N.ACTION_TYPE_TOGGLE_TRADE_EMBARGO,targetPlayer:e.targetPlayer};case N.ACTION_TYPE_DISCARD_PROGRESS_CARD:return{...r,type:N.ACTION_TYPE_DISCARD_PROGRESS_CARD,card:e.progressCard};case N.ACTION_TYPE_BUY_PROGRESS_CARD:return{...r,type:N.ACTION_TYPE_BUY_PROGRESS_CARD,track:e.improvementTrack};case N.ACTION_TYPE_BUILD_BRIDGE:return{...r,type:N.ACTION_TYPE_BUILD_BRIDGE,edge:Ne.fromProto(e.edge)};case N.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD:return{...r,type:N.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD,resource:e.resource};case N.ACTION_TYPE_BUY_GOLD:return{...r,type:N.ACTION_TYPE_BUY_GOLD,resource:e.resource};case N.ACTION_TYPE_COMMERCIAL_HARBOR_TRADE:case N.ACTION_TYPE_UNSPECIFIED:case N.UNRECOGNIZED:throw new Error(`Invalid action type: ${e.type}`);default:{let t=e.type;throw new Error(`Unhandled proto action type: ${t}`)}}}E(Zd,"actionFromProto");var xn=class e{static{E(this,"HexProduction")}hex;resources;commodities;fish;isGoldHex;goldResourceCount;constructor(r,t,o,i,n,a){this.hex=r,this.resources=t,this.commodities=o,this.fish=i,this.isGoldHex=n,this.goldResourceCount=a}static fromProto(r){let t=new Map;for(let n of r.resources)t.set(n.resource,n.count);let o=new Map;for(let n of r.commodities)o.set(n.commodity,n.count);let i=new Map;for(let n of r.fish)i.set(n.fish,n.count);return new e(r.hex?_.fromProto(r.hex):new _(0,0,0),t,o,i,r.isGoldHex,r.goldResourceCount)}toProto(){let r=[];for(let[i,n]of this.resources)r.push({resource:i,count:n});let t=[];for(let[i,n]of this.commodities)t.push({commodity:i,count:n});let o=[];for(let[i,n]of this.fish)o.push({fish:i,count:n});return{hex:this.hex.toProto(),resources:r,commodities:t,fish:o,isGoldHex:this.isGoldHex,goldResourceCount:this.goldResourceCount}}static forResources(r,t,o){return new e(r,t,o??new Map,new Map,!1,0)}static forGold(r,t){return new e(r,new Map,new Map,new Map,!0,t)}static forFish(r,t){return new e(r,new Map,new Map,t,!1,0)}},wn=class e{static{E(this,"PlayerProduction")}player;hexProduction;constructor(r,t){this.player=r,this.hexProduction=t}static fromProto(r){return new e(r.player,r.hexProduction.map(t=>xn.fromProto(t)))}toProto(){return{player:this.player,hexProduction:this.hexProduction.map(r=>r.toProto())}}getTotalResources(){let r=new Map;for(let t of this.hexProduction)for(let[o,i]of t.resources)r.set(o,(r.get(o)??0)+i);return r}getTotalCommodities(){let r=new Map;for(let t of this.hexProduction)for(let[o,i]of t.commodities)r.set(o,(r.get(o)??0)+i);return r}getTotalFish(){let r=new Map;for(let t of this.hexProduction)for(let[o,i]of t.fish)r.set(o,(r.get(o)??0)+i);return r}getTotalGoldCount(){let r=0;for(let t of this.hexProduction)r+=t.goldResourceCount;return r}},Qa=class e{static{E(this,"PartialDistribution")}resource;player;requested;received;constructor(r,t,o,i){this.resource=r,this.player=t,this.requested=o,this.received=i}static fromProto(r){return new e(r.resource,r.player,r.requested,r.received)}toProto(){return{resource:this.resource,player:this.player,requested:this.requested,received:this.received}}getShortage(){return this.requested-this.received}},Pi=class e{static{E(this,"ResourceDistribution")}diceTotal;playerProduction;blockedResources;partialDistributions;robberBlockedProduction;constructor(r,t,o=[],i=[],n=new Map){this.diceTotal=r,this.playerProduction=t,this.blockedResources=o,this.partialDistributions=i,this.robberBlockedProduction=n}static fromProto(r){let t=new Map;for(let o of r.robberBlockedProduction??[])t.set(o.player,o.count);return new e(r.diceTotal,r.playerProduction.map(o=>wn.fromProto(o)),r.blockedResources??[],(r.partialDistributions??[]).map(o=>Qa.fromProto(o)),t)}toProto(){let r=[];for(let[t,o]of this.robberBlockedProduction)o>0&&r.push({player:t,count:o});return{diceTotal:this.diceTotal,playerProduction:this.playerProduction.map(t=>t.toProto()),blockedResources:this.blockedResources,partialDistributions:this.partialDistributions.map(t=>t.toProto()),robberBlockedProduction:r}}getPlayerProduction(r){return this.playerProduction.find(t=>t.player===r)}hasAnyProduction(){return this.playerProduction.some(r=>r.hexProduction.length>0)}isResourceBlocked(r){return this.blockedResources.includes(r)}hasBankShortage(){return this.blockedResources.length>0||this.partialDistributions.length>0}getPartialDistribution(r,t){return this.partialDistributions.find(o=>o.player===r&&o.resource===t)}};var PN;function pN(e){PN=e}E(pN,"setGameEventClass");var On=class e{static{E(this,"GameEventBuilder")}type;player;dice;resources;robberLocation;pirateLocation;targetPlayer;stolenResource;edge;vertex;devCard;monopolyResource;monopolyResults;tradePartner;offeredResources;receivedResources;offeredCommodities;receivedCommodities;offeredGold;receivedGold;tradeId;selectedResource;building;knightLocation;knightDestination;knightStrength;knightStatus;improvementTrack;improvementLevel;commodities;barbarianPosition;barbarianStrength;knightDefenseStrength;barbarianVictory;progressCard;progressCardTrack;eventDieResult;metropolis;previousMetropolisOwner;merchantLocation;displacedKnightOwner;displacedKnightTo;pillagedCityLocation;tradeMonopolyCommodity;inventorHex1;inventorHex2;merchantFleetResource;merchantFleetCommodity;commercialHarborTrades;fishTiles;discardedFishTiles;shipFromEdge;shipToEdge;fogHexLocation;fogRevealedTerrain;fogRevealedNumber;fogRewardResource;previousAwardHolder;freeResourceReason;freeResourceCount;winReason;elapsedTimeMs;actionSource;islandBonusVp;edgeRewardType;collectedPort;pairedPlayer;resourceDistribution;placedWagon;wagonVotes;wagonVotingPlayers;wagonValidPlacements;goldAmount;trollCount;trollHex;masterMerchantResources;masterMerchantCommodities;spyVisibleProgressCards;initScienceProgressDeck;initPoliticsProgressDeck;initTradeProgressDeck;initEventCardDeck;initRemovedEventCards;tradeProposals;embargoActive;rushNextDiceRollAt;counterTradeId;stolenCommodity;freeStructureReason;freeStructureBuilding;freeDevCard;initialFogReveals;lazyRobberFrom;pillagePlayers;defenderPlayers;committedKnights;poorTraders;previousPoorTraders;constructor(r,t){this.type=r,this.player=t}setDice(r){return this.dice=r,this}setResources(r){return this.resources=r,this}setRobberLocation(r){return this.robberLocation=r,this}setPirateLocation(r){return this.pirateLocation=r,this}setTargetPlayer(r){return this.targetPlayer=r,this}setStolenResource(r){return this.stolenResource=r,this}setEdge(r){return this.edge=r,this}setVertex(r){return this.vertex=r,this}setDevCard(r){return this.devCard=r,this}setMonopolyResource(r){return this.monopolyResource=r,this}setMonopolyResults(r){return this.monopolyResults=r,this}setTradePartner(r){return this.tradePartner=r,this}setOfferedResources(r){return this.offeredResources=r,this}setReceivedResources(r){return this.receivedResources=r,this}setOfferedCommodities(r){return this.offeredCommodities=r,this}setReceivedCommodities(r){return this.receivedCommodities=r,this}setOfferedGold(r){return this.offeredGold=r,this}setReceivedGold(r){return this.receivedGold=r,this}setTradeId(r){return this.tradeId=r,this}setSelectedResource(r){return this.selectedResource=r,this}setBuilding(r){return this.building=r,this}setKnightLocation(r){return this.knightLocation=r,this}setKnightDestination(r){return this.knightDestination=r,this}setKnightStrength(r){return this.knightStrength=r,this}setKnightStatus(r){return this.knightStatus=r,this}setImprovementTrack(r){return this.improvementTrack=r,this}setImprovementLevel(r){return this.improvementLevel=r,this}setCommodities(r){return this.commodities=r,this}setBarbarianPosition(r){return this.barbarianPosition=r,this}setBarbarianStrength(r){return this.barbarianStrength=r,this}setKnightDefenseStrength(r){return this.knightDefenseStrength=r,this}setBarbarianVictory(r){return this.barbarianVictory=r,this}setProgressCard(r){return this.progressCard=r,this}setProgressCardTrack(r){return this.progressCardTrack=r,this}setEventDieResult(r){return this.eventDieResult=r,this}setMetropolis(r){return this.metropolis=r,this}setPreviousMetropolisOwner(r){return this.previousMetropolisOwner=r,this}setMerchantLocation(r){return this.merchantLocation=r,this}setDisplacedKnightOwner(r){return this.displacedKnightOwner=r,this}setDisplacedKnightTo(r){return this.displacedKnightTo=r,this}setPillagedCityLocation(r){return this.pillagedCityLocation=r,this}setTradeMonopolyCommodity(r){return this.tradeMonopolyCommodity=r,this}setInventorHex1(r){return this.inventorHex1=r,this}setInventorHex2(r){return this.inventorHex2=r,this}setMerchantFleetResource(r){return this.merchantFleetResource=r,this}setMerchantFleetCommodity(r){return this.merchantFleetCommodity=r,this}setCommercialHarborTrades(r){return this.commercialHarborTrades=r,this}setFishTiles(r){return this.fishTiles=r,this}setDiscardedFishTiles(r){return this.discardedFishTiles=r,this}setShipFromEdge(r){return this.shipFromEdge=r,this}setShipToEdge(r){return this.shipToEdge=r,this}setFogHexLocation(r){return this.fogHexLocation=r,this}setFogRevealedTerrain(r){return this.fogRevealedTerrain=r,this}setFogRevealedNumber(r){return this.fogRevealedNumber=r,this}setFogRewardResource(r){return this.fogRewardResource=r,this}setPreviousAwardHolder(r){return this.previousAwardHolder=r,this}setFreeResourceReason(r){return this.freeResourceReason=r,this}setFreeResourceCount(r){return this.freeResourceCount=r,this}setWinReason(r){return this.winReason=r,this}setElapsedTimeMs(r){return this.elapsedTimeMs=r,this}setActionSource(r){return this.actionSource=r,this}setIslandBonusVp(r){return this.islandBonusVp=r,this}setEdgeRewardType(r){return this.edgeRewardType=r,this}setCollectedPort(r){return this.collectedPort=r,this}setPairedPlayer(r){return this.pairedPlayer=r,this}setResourceDistribution(r){return this.resourceDistribution=r,this}setPlacedWagon(r){return this.placedWagon=r,this}setWagonVotes(r){return this.wagonVotes=r,this}setWagonVotingPlayers(r){return this.wagonVotingPlayers=r,this}setWagonValidPlacements(r){return this.wagonValidPlacements=r,this}setGoldAmount(r){return this.goldAmount=r,this}setTrollCount(r){return this.trollCount=r,this}setTrollHex(r){return this.trollHex=r,this}setMasterMerchantResources(r){return this.masterMerchantResources=r,this}setMasterMerchantCommodities(r){return this.masterMerchantCommodities=r,this}setSpyVisibleProgressCards(r){return this.spyVisibleProgressCards=r,this}setInitScienceProgressDeck(r){return this.initScienceProgressDeck=r,this}setInitPoliticsProgressDeck(r){return this.initPoliticsProgressDeck=r,this}setInitTradeProgressDeck(r){return this.initTradeProgressDeck=r,this}setInitEventCardDeck(r){return this.initEventCardDeck=r,this}setInitRemovedEventCards(r){return this.initRemovedEventCards=r,this}setInitialFogReveals(r){return this.initialFogReveals=r,this}setLazyRobberFrom(r){return this.lazyRobberFrom=r,this}setTradeProposals(r){return this.tradeProposals=r,this}setEmbargoActive(r){return this.embargoActive=r,this}setRushNextDiceRollAt(r){return this.rushNextDiceRollAt=r,this}setCounterTradeId(r){return this.counterTradeId=r,this}setStolenCommodity(r){return this.stolenCommodity=r,this}setFreeStructureReason(r){return this.freeStructureReason=r,this}setFreeStructureBuilding(r){return this.freeStructureBuilding=r,this}setFreeDevCard(r){return this.freeDevCard=r,this}setPillagePlayers(r){return this.pillagePlayers=[...r],this}setDefenderPlayers(r){return this.defenderPlayers=[...r],this}setCommittedKnights(r){return this.committedKnights=[...r],this}setPoorTraders(r,t){return this.poorTraders=[...r],this.previousPoorTraders=[...t],this}static fromEvent(r){let t=new e(r.type,r.player);return r.dice&&(t.dice=r.dice),r.resources&&(t.resources=r.resources),r.robberLocation&&(t.robberLocation=r.robberLocation),r.pirateLocation&&(t.pirateLocation=r.pirateLocation),r.targetPlayer&&(t.targetPlayer=r.targetPlayer),r.stolenResource&&(t.stolenResource=r.stolenResource),r.edge&&(t.edge=r.edge),r.vertex&&(t.vertex=r.vertex),r.devCard&&(t.devCard=r.devCard),r.monopolyResource&&(t.monopolyResource=r.monopolyResource),r.monopolyResults&&(t.monopolyResults=r.monopolyResults),r.tradePartner&&(t.tradePartner=r.tradePartner),r.offeredResources&&(t.offeredResources=r.offeredResources),r.receivedResources&&(t.receivedResources=r.receivedResources),r.offeredCommodities&&(t.offeredCommodities=r.offeredCommodities),r.receivedCommodities&&(t.receivedCommodities=r.receivedCommodities),r.offeredGold!==void 0&&(t.offeredGold=r.offeredGold),r.receivedGold!==void 0&&(t.receivedGold=r.receivedGold),r.tradeId&&(t.tradeId=r.tradeId),r.selectedResource&&(t.selectedResource=r.selectedResource),r.building&&(t.building=r.building),r.knightLocation&&(t.knightLocation=r.knightLocation),r.knightDestination&&(t.knightDestination=r.knightDestination),r.knightStrength&&(t.knightStrength=r.knightStrength),r.knightStatus&&(t.knightStatus=r.knightStatus),r.improvementTrack&&(t.improvementTrack=r.improvementTrack),r.improvementLevel!==void 0&&(t.improvementLevel=r.improvementLevel),r.commodities&&(t.commodities=r.commodities),r.barbarianPosition!==void 0&&(t.barbarianPosition=r.barbarianPosition),r.barbarianStrength!==void 0&&(t.barbarianStrength=r.barbarianStrength),r.knightDefenseStrength!==void 0&&(t.knightDefenseStrength=r.knightDefenseStrength),r.barbarianVictory!==void 0&&(t.barbarianVictory=r.barbarianVictory),r.progressCard&&(t.progressCard=r.progressCard),r.progressCardTrack&&(t.progressCardTrack=r.progressCardTrack),r.eventDieResult&&(t.eventDieResult=r.eventDieResult),r.metropolis&&(t.metropolis=r.metropolis),r.previousMetropolisOwner&&(t.previousMetropolisOwner=r.previousMetropolisOwner),r.merchantLocation&&(t.merchantLocation=r.merchantLocation),r.displacedKnightOwner&&(t.displacedKnightOwner=r.displacedKnightOwner),r.displacedKnightTo&&(t.displacedKnightTo=r.displacedKnightTo),r.pillagedCityLocation&&(t.pillagedCityLocation=r.pillagedCityLocation),r.tradeMonopolyCommodity&&(t.tradeMonopolyCommodity=r.tradeMonopolyCommodity),r.inventorHex1&&(t.inventorHex1=r.inventorHex1),r.inventorHex2&&(t.inventorHex2=r.inventorHex2),r.merchantFleetResource&&(t.merchantFleetResource=r.merchantFleetResource),r.merchantFleetCommodity&&(t.merchantFleetCommodity=r.merchantFleetCommodity),r.commercialHarborTrades&&(t.commercialHarborTrades=r.commercialHarborTrades),r.fishTiles&&(t.fishTiles=r.fishTiles),r.discardedFishTiles&&(t.discardedFishTiles=r.discardedFishTiles),r.shipFromEdge&&(t.shipFromEdge=r.shipFromEdge),r.shipToEdge&&(t.shipToEdge=r.shipToEdge),r.fogHexLocation&&(t.fogHexLocation=r.fogHexLocation),r.fogRevealedTerrain&&(t.fogRevealedTerrain=r.fogRevealedTerrain),r.fogRevealedNumber!==void 0&&(t.fogRevealedNumber=r.fogRevealedNumber),r.fogRewardResource&&(t.fogRewardResource=r.fogRewardResource),r.previousAwardHolder&&(t.previousAwardHolder=r.previousAwardHolder),r.freeResourceReason&&(t.freeResourceReason=r.freeResourceReason),r.freeResourceCount!==void 0&&(t.freeResourceCount=r.freeResourceCount),r.winReason&&(t.winReason=r.winReason),r.elapsedTimeMs!==void 0&&(t.elapsedTimeMs=r.elapsedTimeMs),r.actionSource&&(t.actionSource=r.actionSource),r.islandBonusVp!==void 0&&(t.islandBonusVp=r.islandBonusVp),r.edgeRewardType!==void 0&&(t.edgeRewardType=r.edgeRewardType),r.collectedPort&&(t.collectedPort=r.collectedPort),r.pairedPlayer&&(t.pairedPlayer=r.pairedPlayer),r.resourceDistribution&&(t.resourceDistribution=r.resourceDistribution),r.placedWagon&&(t.placedWagon=r.placedWagon),r.wagonVotes&&(t.wagonVotes=r.wagonVotes),r.wagonVotingPlayers&&(t.wagonVotingPlayers=r.wagonVotingPlayers),r.wagonValidPlacements&&(t.wagonValidPlacements=r.wagonValidPlacements),r.goldAmount!==void 0&&(t.goldAmount=r.goldAmount),r.trollCount!==void 0&&(t.trollCount=r.trollCount),r.trollHex&&(t.trollHex=r.trollHex),r.masterMerchantResources&&(t.masterMerchantResources=r.masterMerchantResources),r.masterMerchantCommodities&&(t.masterMerchantCommodities=r.masterMerchantCommodities),r.spyVisibleProgressCards&&(t.spyVisibleProgressCards=r.spyVisibleProgressCards),r.initScienceProgressDeck&&(t.initScienceProgressDeck=r.initScienceProgressDeck),r.initPoliticsProgressDeck&&(t.initPoliticsProgressDeck=r.initPoliticsProgressDeck),r.initTradeProgressDeck&&(t.initTradeProgressDeck=r.initTradeProgressDeck),r.initEventCardDeck&&(t.initEventCardDeck=r.initEventCardDeck),r.initRemovedEventCards&&(t.initRemovedEventCards=r.initRemovedEventCards),r.tradeProposals&&(t.tradeProposals=r.tradeProposals),r.embargoActive!==void 0&&(t.embargoActive=r.embargoActive),r.rushNextDiceRollAt!==void 0&&(t.rushNextDiceRollAt=r.rushNextDiceRollAt),r.counterTradeId!==void 0&&(t.counterTradeId=r.counterTradeId),r.stolenCommodity!==void 0&&(t.stolenCommodity=r.stolenCommodity),r.freeStructureReason!==void 0&&(t.freeStructureReason=r.freeStructureReason),r.freeStructureBuilding!==void 0&&(t.freeStructureBuilding=r.freeStructureBuilding),r.freeDevCard!==void 0&&(t.freeDevCard=r.freeDevCard),r.initialFogReveals&&(t.initialFogReveals=r.initialFogReveals),r.lazyRobberFrom&&(t.lazyRobberFrom=r.lazyRobberFrom),r.pillagePlayers&&(t.pillagePlayers=[...r.pillagePlayers]),r.defenderPlayers&&(t.defenderPlayers=[...r.defenderPlayers]),r.committedKnights&&(t.committedKnights=[...r.committedKnights]),r.poorTraders&&(t.poorTraders=[...r.poorTraders]),r.previousPoorTraders&&(t.previousPoorTraders=[...r.previousPoorTraders]),t}build(){let r=new PN(this.type,this.player,this.dice,this.resources,this.robberLocation,this.pirateLocation,this.targetPlayer,this.stolenResource,this.edge,this.vertex,this.devCard,this.monopolyResource,this.monopolyResults,this.tradePartner,this.offeredResources,this.receivedResources,this.offeredCommodities,this.receivedCommodities,this.offeredGold,this.receivedGold,this.tradeId,this.selectedResource,this.building,this.knightLocation,this.knightDestination,this.knightStrength,this.knightStatus,this.improvementTrack,this.improvementLevel,this.commodities,this.barbarianPosition,this.barbarianStrength,this.knightDefenseStrength,this.barbarianVictory,this.progressCard,this.progressCardTrack,this.eventDieResult,this.metropolis,this.previousMetropolisOwner,this.merchantLocation,this.displacedKnightOwner,this.displacedKnightTo,this.pillagedCityLocation,this.tradeMonopolyCommodity,this.inventorHex1,this.inventorHex2,this.merchantFleetResource,this.merchantFleetCommodity,this.commercialHarborTrades,this.fishTiles,this.discardedFishTiles,this.shipFromEdge,this.shipToEdge,this.fogHexLocation,this.fogRevealedTerrain,this.fogRevealedNumber,this.fogRewardResource,this.previousAwardHolder,this.freeResourceReason,this.freeResourceCount,this.winReason,this.elapsedTimeMs,this.actionSource,this.islandBonusVp,this.edgeRewardType,this.collectedPort,this.pairedPlayer,this.resourceDistribution,this.placedWagon,this.wagonVotes,this.wagonVotingPlayers,this.wagonValidPlacements,this.goldAmount,this.trollCount,this.trollHex,this.masterMerchantResources,this.masterMerchantCommodities,this.spyVisibleProgressCards,this.initScienceProgressDeck,this.initPoliticsProgressDeck,this.initTradeProgressDeck,this.initEventCardDeck,this.initRemovedEventCards,this.tradeProposals,this.embargoActive,this.rushNextDiceRollAt,this.counterTradeId,this.stolenCommodity,this.freeStructureReason,this.freeStructureBuilding,this.freeDevCard,this.initialFogReveals,this.lazyRobberFrom,this.pillagePlayers,this.defenderPlayers,this.committedKnights,this.poorTraders,this.previousPoorTraders);return r.timestampMs=Date.now(),r}};var y=class e{static{E(this,"GameEvent")}type;player;dice;resources;robberLocation;pirateLocation;targetPlayer;stolenResource;edge;vertex;devCard;monopolyResource;monopolyResults;stolenCommodity;tradePartner;offeredResources;receivedResources;offeredCommodities;receivedCommodities;offeredGold;receivedGold;tradeId;selectedResource;building;knightLocation;knightDestination;knightStrength;knightStatus;improvementTrack;improvementLevel;commodities;barbarianPosition;barbarianStrength;knightDefenseStrength;barbarianVictory;progressCard;progressCardTrack;eventDieResult;metropolis;previousMetropolisOwner;merchantLocation;displacedKnightOwner;displacedKnightTo;pillagedCityLocation;tradeMonopolyCommodity;inventorHex1;inventorHex2;merchantFleetResource;merchantFleetCommodity;commercialHarborTrades;fishTiles;discardedFishTiles;shipFromEdge;shipToEdge;fogHexLocation;fogRevealedTerrain;fogRevealedNumber;fogRewardResource;previousAwardHolder;freeResourceReason;freeResourceCount;winReason;elapsedTimeMs;actionSource;islandBonusVp;edgeRewardType;collectedPort;pairedPlayer;resourceDistribution;placedWagon;wagonVotes;wagonVotingPlayers;wagonValidPlacements;goldAmount;trollCount;trollHex;masterMerchantResources;masterMerchantCommodities;spyVisibleProgressCards;initScienceProgressDeck;initPoliticsProgressDeck;initTradeProgressDeck;initEventCardDeck;initRemovedEventCards;initialFogReveals;lazyRobberFrom;tradeProposals;embargoActive;rushNextDiceRollAt;counterTradeId;freeStructureReason;freeStructureBuilding;freeDevCard;pillagePlayers;defenderPlayers;committedKnights;poorTraders;previousPoorTraders;timestampMs;static fromProto(r){let t=r.resources.length>0?ja(r.resources):void 0,o=r.offeredResources.length>0?ja(r.offeredResources):void 0,i=r.receivedResources.length>0?ja(r.receivedResources):void 0,a=r.monopolyResource!==S.RESOURCE_UNSPECIFIED||r.tradeMonopolyCommodity!==j.COMMODITY_UNSPECIFIED?r.monopolyResults.map(V=>({player:V.player,count:V.count})):r.monopolyResults.length>0?r.monopolyResults.map(V=>({player:V.player,count:V.count})):void 0,s=r.commodities.length>0?rs(r.commodities):void 0,u=r.fishTiles.length>0?hN(r.fishTiles):void 0,l=r.discardedFishTiles.length>0?hN(r.discardedFishTiles):void 0,c=r.commercialHarborTrades.length>0?new Map(r.commercialHarborTrades.map(V=>[V.opponent,V.resource])):void 0,f=r.masterMerchantResources.length>0?ja(r.masterMerchantResources):void 0,T=r.masterMerchantCommodities.length>0?rs(r.masterMerchantCommodities):void 0,R=r.spyVisibleProgressCards.length>0?qD(r.spyVisibleProgressCards):void 0,O=r.initScienceProgressDeck.length>0?[...r.initScienceProgressDeck]:void 0,I=r.initPoliticsProgressDeck.length>0?[...r.initPoliticsProgressDeck]:void 0,D=r.initTradeProgressDeck.length>0?[...r.initTradeProgressDeck]:void 0,g=r.initEventCardDeck.length>0?mN(r.initEventCardDeck):void 0,k=r.initRemovedEventCards.length>0?mN(r.initRemovedEventCards):void 0,v=r.initialFogReveals.length>0?r.initialFogReveals.map(V=>({hex:_.fromProto(V.hex),terrain:V.terrain,number:V.number})):void 0,Y=r.tradeProposals.length>0?r.tradeProposals.map(V=>({tradeId:V.tradeId,offering:V.offering.length>0?ja(V.offering):new Map,requesting:V.requesting.length>0?ja(V.requesting):new Map,offeringCommodities:V.offeringCommodities.length>0?rs(V.offeringCommodities):void 0,requestingCommodities:V.requestingCommodities.length>0?rs(V.requestingCommodities):void 0,offeringGold:V.offeringGold!==0?V.offeringGold:void 0,requestingGold:V.requestingGold!==0?V.requestingGold:void 0})):void 0;return new e(r.type,r.player,r.dice?et.fromProto(r.dice):void 0,t,r.robberLocation?_.fromProto(r.robberLocation):void 0,r.pirateLocation?_.fromProto(r.pirateLocation):void 0,r.targetPlayer!==x.PLAYER_COLOR_UNSPECIFIED?r.targetPlayer:void 0,r.stolenResource!==S.RESOURCE_UNSPECIFIED?r.stolenResource:void 0,r.edge?Ne.fromProto(r.edge):void 0,r.vertex?oe.fromProto(r.vertex):void 0,r.devCard!==ie.DEV_CARD_UNSPECIFIED?r.devCard:void 0,r.monopolyResource!==S.RESOURCE_UNSPECIFIED?r.monopolyResource:void 0,a,r.tradePartner!==x.PLAYER_COLOR_UNSPECIFIED?r.tradePartner:void 0,o,i,r.offeredCommodities?.length>0?rs(r.offeredCommodities):void 0,r.receivedCommodities?.length>0?rs(r.receivedCommodities):void 0,r.offeredGold!==0?r.offeredGold:void 0,r.receivedGold!==0?r.receivedGold:void 0,r.tradeId!==0?r.tradeId:void 0,r.selectedResource!==S.RESOURCE_UNSPECIFIED?r.selectedResource:void 0,r.building!==F.BUILDING_UNSPECIFIED?r.building:void 0,r.knightLocation?oe.fromProto(r.knightLocation):void 0,r.knightDestination?oe.fromProto(r.knightDestination):void 0,r.knightStrength!==Pe.KNIGHT_STRENGTH_UNSPECIFIED?r.knightStrength:void 0,r.knightStatus!==ir.KNIGHT_STATUS_UNSPECIFIED?r.knightStatus:void 0,r.improvementTrack!==K.CITY_IMPROVEMENT_TRACK_UNSPECIFIED?r.improvementTrack:void 0,r.improvementLevel!==0?r.improvementLevel:void 0,s,r.barbarianPosition!==0?r.barbarianPosition:void 0,r.barbarianStrength!==0?r.barbarianStrength:void 0,r.knightDefenseStrength!==0?r.knightDefenseStrength:void 0,r.barbarianVictory!==!1?r.barbarianVictory:void 0,r.progressCard!==b.PROGRESS_CARD_UNSPECIFIED?r.progressCard:void 0,r.progressCardTrack!==K.CITY_IMPROVEMENT_TRACK_UNSPECIFIED?r.progressCardTrack:void 0,r.eventDieResult!==Ue.EVENT_DIE_RESULT_UNSPECIFIED?r.eventDieResult:void 0,r.metropolis?Yr.fromProto(r.metropolis):void 0,r.previousMetropolisOwner!==x.PLAYER_COLOR_UNSPECIFIED?r.previousMetropolisOwner:void 0,r.merchantLocation?_.fromProto(r.merchantLocation):void 0,r.displacedKnightOwner!==x.PLAYER_COLOR_UNSPECIFIED?r.displacedKnightOwner:void 0,r.displacedKnightTo?oe.fromProto(r.displacedKnightTo):void 0,r.pillagedCityLocation?oe.fromProto(r.pillagedCityLocation):void 0,r.tradeMonopolyCommodity!==j.COMMODITY_UNSPECIFIED?r.tradeMonopolyCommodity:void 0,r.inventorHex1?_.fromProto(r.inventorHex1):void 0,r.inventorHex2?_.fromProto(r.inventorHex2):void 0,r.merchantFleetResource!==S.RESOURCE_UNSPECIFIED?r.merchantFleetResource:void 0,r.merchantFleetCommodity!==j.COMMODITY_UNSPECIFIED?r.merchantFleetCommodity:void 0,c,u,l,r.shipFromEdge?Ne.fromProto(r.shipFromEdge):void 0,r.shipToEdge?Ne.fromProto(r.shipToEdge):void 0,r.fogHexLocation?_.fromProto(r.fogHexLocation):void 0,r.fogRevealedTerrain!==d.TERRAIN_UNSPECIFIED?r.fogRevealedTerrain:void 0,r.fogRevealedNumber!==0?r.fogRevealedNumber:void 0,r.fogRewardResource!==S.RESOURCE_UNSPECIFIED?r.fogRewardResource:void 0,r.previousAwardHolder!==x.PLAYER_COLOR_UNSPECIFIED?r.previousAwardHolder:void 0,r.freeResourceReason!==Ir.FREE_RESOURCE_REASON_UNSPECIFIED?r.freeResourceReason:void 0,r.freeResourceCount!==0?r.freeResourceCount:void 0,r.winReason!==ht.WIN_REASON_UNSPECIFIED?r.winReason:void 0,r.elapsedTimeMs!==0?Number(r.elapsedTimeMs):void 0,r.actionSource!==pa.ACTION_SOURCE_UNSPECIFIED?r.actionSource:void 0,r.islandBonusVp!==0?r.islandBonusVp:void 0,r.edgeRewardType!==Tr.EDGE_REWARD_TYPE_UNSPECIFIED?r.edgeRewardType:void 0,r.collectedPort?me.fromProto(r.collectedPort):void 0,r.pairedPlayer!==x.PLAYER_COLOR_UNSPECIFIED?r.pairedPlayer:void 0,r.resourceDistribution?Pi.fromProto(r.resourceDistribution):void 0,r.placedWagon?ln.fromProto(r.placedWagon):void 0,r.wagonVotes.length>0?r.wagonVotes.map(V=>fn.fromProto(V)):void 0,void 0,void 0,r.goldAmount!==0?r.goldAmount:void 0,r.trollCount!==0?r.trollCount:void 0,r.trollHex?_.fromProto(r.trollHex):void 0,f,T,R,O,I,D,g,k,Y,r.type===h.GAME_EVENT_TYPE_TRADE_EMBARGO?r.embargoActive:void 0,r.rushNextDiceRollAt!==0?Number(r.rushNextDiceRollAt):void 0,r.counterTradeId!==0?r.counterTradeId:void 0,r.stolenCommodity!==j.COMMODITY_UNSPECIFIED?r.stolenCommodity:void 0,r.freeStructureReason!==dn.FREE_STRUCTURE_REASON_UNSPECIFIED?r.freeStructureReason:void 0,r.freeStructureBuilding!==F.BUILDING_UNSPECIFIED?r.freeStructureBuilding:void 0,r.freeDevCard?!0:void 0,v,r.lazyRobberFrom?_.fromProto(r.lazyRobberFrom):void 0,r.pillagePlayers.length>0?[...r.pillagePlayers]:void 0,r.defenderPlayers.length>0?[...r.defenderPlayers]:void 0,r.committedKnights.length>0?r.committedKnights.map(V=>oe.fromProto(V)):void 0,r.poorTraders.length>0?[...r.poorTraders]:void 0,r.previousPoorTraders.length>0?[...r.previousPoorTraders]:void 0)}constructor(r,t,o,i,n,a,s,u,l,c,f,T,R,O,I,D,g,k,v,Y,V,w,J,$,he,De,ve,Be,Ye,Or,Fe,He,Xr,Fr,Lr,Ln,Pa,Ls,Gs,Us,Bs,ks,bs,X,pt,vs,Gu,Uu,Bu,ku,bu,vu,Yu,Fu,Vu,xu,wu,Hu,Ku,Wu,Ju,qu,Zu,Xu,zu,$u,Qu,hh,Dh,mh,gh,yh,Mh,Lh,Gh,Uh,Bh,kh,bh,vh,Yh,Fh,Vh,xh,wh,Hh,Kh,Wh,Jh,qh,Zh,Xh,zh,$h,Qh,jh,eD,rD){this.type=r,this.player=t,this.dice=o,this.resources=i,this.robberLocation=n,this.pirateLocation=a,this.targetPlayer=s,this.stolenResource=u,this.edge=l,this.vertex=c,this.devCard=f,this.monopolyResource=T,this.monopolyResults=R,this.tradePartner=O,this.offeredResources=I,this.receivedResources=D,this.offeredCommodities=g,this.receivedCommodities=k,this.offeredGold=v,this.receivedGold=Y,this.tradeId=V,this.selectedResource=w,this.building=J,this.knightLocation=$,this.knightDestination=he,this.knightStrength=De,this.knightStatus=ve,this.improvementTrack=Be,this.improvementLevel=Ye,this.commodities=Or,this.barbarianPosition=Fe,this.barbarianStrength=He,this.knightDefenseStrength=Xr,this.barbarianVictory=Fr,this.progressCard=Lr,this.progressCardTrack=Ln,this.eventDieResult=Pa,this.metropolis=Ls,this.previousMetropolisOwner=Gs,this.merchantLocation=Us,this.displacedKnightOwner=Bs,this.displacedKnightTo=ks,this.pillagedCityLocation=bs,this.tradeMonopolyCommodity=X,this.inventorHex1=pt,this.inventorHex2=vs,this.merchantFleetResource=Gu,this.merchantFleetCommodity=Uu,this.commercialHarborTrades=Bu,this.fishTiles=ku,this.discardedFishTiles=bu,this.shipFromEdge=vu,this.shipToEdge=Yu,this.fogHexLocation=Fu,this.fogRevealedTerrain=Vu,this.fogRevealedNumber=xu,this.fogRewardResource=wu,this.previousAwardHolder=Hu,this.freeResourceReason=Ku,this.freeResourceCount=Wu,this.winReason=Ju,this.elapsedTimeMs=qu,this.actionSource=Zu,this.islandBonusVp=Xu,this.edgeRewardType=zu,this.collectedPort=$u,this.pairedPlayer=Qu,this.resourceDistribution=hh,this.placedWagon=Dh,this.wagonVotes=mh,this.wagonVotingPlayers=gh,this.wagonValidPlacements=yh,this.goldAmount=Mh,this.trollCount=Lh,this.trollHex=Gh,this.masterMerchantResources=Uh,this.masterMerchantCommodities=Bh,this.spyVisibleProgressCards=kh,this.initScienceProgressDeck=bh,this.initPoliticsProgressDeck=vh,this.initTradeProgressDeck=Yh,this.initEventCardDeck=Fh,this.initRemovedEventCards=Vh,this.tradeProposals=xh,this.embargoActive=wh,this.rushNextDiceRollAt=Hh,this.counterTradeId=Kh,this.stolenCommodity=Wh,this.freeStructureReason=Jh,this.freeStructureBuilding=qh,this.freeDevCard=Zh,this.initialFogReveals=Xh,this.lazyRobberFrom=zh,this.pillagePlayers=$h,this.defenderPlayers=Qh,this.committedKnights=jh,this.poorTraders=eD,this.previousPoorTraders=rD}toProto(){return e_.create({type:this.type,player:this.player,dice:this.dice?.toProto(),resources:this.resources?es(this.resources):[],robberLocation:this.robberLocation?.toProto(),lazyRobberFrom:this.lazyRobberFrom?.toProto(),pirateLocation:this.pirateLocation?.toProto(),targetPlayer:this.targetPlayer??x.PLAYER_COLOR_UNSPECIFIED,stolenResource:this.stolenResource??S.RESOURCE_UNSPECIFIED,edge:this.edge?.toProto(),vertex:this.vertex?.toProto(),devCard:this.devCard??ie.DEV_CARD_UNSPECIFIED,monopolyResource:this.monopolyResource??S.RESOURCE_UNSPECIFIED,monopolyResults:this.monopolyResults?.map(r=>vt.create({player:r.player,count:r.count}))??[],tradePartner:this.tradePartner??x.PLAYER_COLOR_UNSPECIFIED,offeredResources:this.offeredResources?es(this.offeredResources):[],receivedResources:this.receivedResources?es(this.receivedResources):[],offeredCommodities:this.offeredCommodities?ts(this.offeredCommodities):[],receivedCommodities:this.receivedCommodities?ts(this.receivedCommodities):[],offeredGold:this.offeredGold??0,receivedGold:this.receivedGold??0,tradeId:this.tradeId??0,selectedResource:this.selectedResource??S.RESOURCE_UNSPECIFIED,building:this.building??F.BUILDING_UNSPECIFIED,knightLocation:this.knightLocation?.toProto(),knightDestination:this.knightDestination?.toProto(),knightStrength:this.knightStrength??Pe.KNIGHT_STRENGTH_UNSPECIFIED,knightStatus:this.knightStatus??ir.KNIGHT_STATUS_UNSPECIFIED,improvementTrack:this.improvementTrack??K.CITY_IMPROVEMENT_TRACK_UNSPECIFIED,improvementLevel:this.improvementLevel??0,commodities:this.commodities?ts(this.commodities):[],barbarianPosition:this.barbarianPosition??0,barbarianStrength:this.barbarianStrength??0,knightDefenseStrength:this.knightDefenseStrength??0,barbarianVictory:this.barbarianVictory??!1,progressCard:this.progressCard??b.PROGRESS_CARD_UNSPECIFIED,progressCardTrack:this.progressCardTrack??K.CITY_IMPROVEMENT_TRACK_UNSPECIFIED,eventDieResult:this.eventDieResult??Ue.EVENT_DIE_RESULT_UNSPECIFIED,metropolis:this.metropolis?.toProto(),previousMetropolisOwner:this.previousMetropolisOwner??x.PLAYER_COLOR_UNSPECIFIED,merchantLocation:this.merchantLocation?.toProto(),displacedKnightOwner:this.displacedKnightOwner??x.PLAYER_COLOR_UNSPECIFIED,displacedKnightTo:this.displacedKnightTo?.toProto(),pillagedCityLocation:this.pillagedCityLocation?.toProto(),tradeMonopolyCommodity:this.tradeMonopolyCommodity??j.COMMODITY_UNSPECIFIED,inventorHex1:this.inventorHex1?.toProto(),inventorHex2:this.inventorHex2?.toProto(),merchantFleetResource:this.merchantFleetResource??S.RESOURCE_UNSPECIFIED,merchantFleetCommodity:this.merchantFleetCommodity??j.COMMODITY_UNSPECIFIED,commercialHarborTrades:this.commercialHarborTrades?Array.from(this.commercialHarborTrades.entries()).map(([r,t])=>gt.create({opponent:r,resource:t})):[],fishTiles:this.fishTiles?DN(this.fishTiles):[],discardedFishTiles:this.discardedFishTiles?DN(this.discardedFishTiles):[],shipFromEdge:this.shipFromEdge?.toProto(),shipToEdge:this.shipToEdge?.toProto(),fogHexLocation:this.fogHexLocation?.toProto(),fogRevealedTerrain:this.fogRevealedTerrain??d.TERRAIN_UNSPECIFIED,fogRevealedNumber:this.fogRevealedNumber??0,fogRewardResource:this.fogRewardResource??S.RESOURCE_UNSPECIFIED,previousAwardHolder:this.previousAwardHolder??x.PLAYER_COLOR_UNSPECIFIED,freeResourceReason:this.freeResourceReason??Ir.FREE_RESOURCE_REASON_UNSPECIFIED,freeResourceCount:this.freeResourceCount??0,winReason:this.winReason??ht.WIN_REASON_UNSPECIFIED,elapsedTimeMs:this.elapsedTimeMs??0,actionSource:this.actionSource??pa.ACTION_SOURCE_UNSPECIFIED,islandBonusVp:this.islandBonusVp??0,edgeRewardType:this.edgeRewardType??Tr.EDGE_REWARD_TYPE_UNSPECIFIED,collectedPort:this.collectedPort?.toProto(),pairedPlayer:this.pairedPlayer??x.PLAYER_COLOR_UNSPECIFIED,resourceDistribution:this.resourceDistribution?.toProto(),placedWagon:this.placedWagon?.toProto(),wagonVotes:this.wagonVotes?.map(r=>r.toProto())??[],goldAmount:this.goldAmount??0,trollCount:this.trollCount??0,trollHex:this.trollHex?.toProto(),masterMerchantResources:this.masterMerchantResources?es(this.masterMerchantResources):[],masterMerchantCommodities:this.masterMerchantCommodities?ts(this.masterMerchantCommodities):[],spyVisibleProgressCards:this.spyVisibleProgressCards?ZD(this.spyVisibleProgressCards):[],initScienceProgressDeck:this.initScienceProgressDeck??[],initPoliticsProgressDeck:this.initPoliticsProgressDeck??[],initTradeProgressDeck:this.initTradeProgressDeck??[],initEventCardDeck:this.initEventCardDeck?gN(this.initEventCardDeck):[],initRemovedEventCards:this.initRemovedEventCards?gN(this.initRemovedEventCards):[],initialFogReveals:this.initialFogReveals?this.initialFogReveals.map(r=>({hex:r.hex.toProto(),terrain:r.terrain,number:r.number})):[],tradeProposals:this.tradeProposals?this.tradeProposals.map(r=>Qr.create({tradeId:r.tradeId,offering:es(r.offering),requesting:es(r.requesting),offeringCommodities:r.offeringCommodities?ts(r.offeringCommodities):[],requestingCommodities:r.requestingCommodities?ts(r.requestingCommodities):[],offeringGold:r.offeringGold??0,requestingGold:r.requestingGold??0})):[],embargoActive:this.embargoActive??!1,rushNextDiceRollAt:this.rushNextDiceRollAt??0,counterTradeId:this.counterTradeId??0,stolenCommodity:this.stolenCommodity??j.COMMODITY_UNSPECIFIED,freeStructureReason:this.freeStructureReason??dn.FREE_STRUCTURE_REASON_UNSPECIFIED,freeStructureBuilding:this.freeStructureBuilding??F.BUILDING_UNSPECIFIED,freeDevCard:this.freeDevCard??!1,pillagePlayers:this.pillagePlayers??[],defenderPlayers:this.defenderPlayers??[],committedKnights:this.committedKnights?.map(r=>r.toProto())??[],poorTraders:this.poorTraders??[],previousPoorTraders:this.previousPoorTraders??[]})}static preservesPublicCardCount(r){return r===h.GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT||r===h.GAME_EVENT_TYPE_GIVE_WEDDING_CARDS}static maskCardCounts(r,t){if(r===void 0)return;let o=0;for(let n of r.values())o+=n;let i=new Map;return o>0&&i.set(t,o),i}forPlayer(r){let t=!1,o=!1,i=!1,n=!1,a=!1,s=!1,u=!1;(this.type===h.GAME_EVENT_TYPE_STEAL_RESOURCE||this.type===h.GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE||this.type===h.GAME_EVENT_TYPE_PLAY_KNIGHT)&&r!==this.player&&r!==this.targetPlayer&&(t=!0),this.type===h.GAME_EVENT_TYPE_BUY_DEV_CARD&&r!==this.player&&(o=!0),(this.type===h.GAME_EVENT_TYPE_DRAW_PROGRESS_CARD||this.type===h.GAME_EVENT_TYPE_BUY_PROGRESS_CARD)&&r!==this.player&&!(this.progressCard&&xr(this.progressCard))&&(i=!0),this.type===h.GAME_EVENT_TYPE_PLAY_SPY&&r!==this.player&&r!==this.targetPlayer&&(i=!0),this.type===h.GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT&&(r!==this.player&&r!==this.targetPlayer&&(n=!0),r!==this.player&&(s=!0)),this.type===h.GAME_EVENT_TYPE_PLAY_SPY&&r!==this.player&&(u=!0),this.type===h.GAME_EVENT_TYPE_GIVE_WEDDING_CARDS&&r!==this.player&&r!==this.targetPlayer&&(n=!0),this.type===h.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_EXCHANGE&&r!==this.player&&r!==this.targetPlayer&&(n=!0),this.type===h.GAME_EVENT_TYPE_GIVE_EVENT_CARD_RESOURCE&&r!==this.player&&r!==this.targetPlayer&&(n=!0),(this.type===h.GAME_EVENT_TYPE_RECEIVE_FISH||this.type===h.GAME_EVENT_TYPE_SPEND_FISH||this.type===h.GAME_EVENT_TYPE_EXCHANGE_FISH)&&r!==this.player&&(a=!0);let l=this.type===h.GAME_EVENT_TYPE_INITIALIZE_DECKS;if(!t&&!o&&!i&&!n&&!a&&!s&&!u&&!l)return this;let c=this.fishTiles;if(a&&this.fishTiles){c=new Map;let T=this.fishTiles.get(Se.FISH_OLD_BOOT);T!==void 0&&T>0&&c.set(Se.FISH_OLD_BOOT,T);let R=0;for(let[O,I]of this.fishTiles)O!==Se.FISH_OLD_BOOT&&(R+=I);R>0&&c.set(Se.FISH_UNSPECIFIED,R)}let f=this.discardedFishTiles;if(a&&this.discardedFishTiles){f=new Map;let T=this.discardedFishTiles.get(Se.FISH_OLD_BOOT);T!==void 0&&T>0&&f.set(Se.FISH_OLD_BOOT,T);let R=0;for(let[O,I]of this.discardedFishTiles)O!==Se.FISH_OLD_BOOT&&(R+=I);R>0&&f.set(Se.FISH_UNSPECIFIED,R)}return On.fromEvent(this).setStolenResource(t?this.type===h.GAME_EVENT_TYPE_PLAY_KNIGHT&&(this.stolenResource!==void 0||this.stolenCommodity!==void 0)?S.RESOURCE_UNSPECIFIED:void 0:this.stolenResource).setStolenCommodity(t?void 0:this.stolenCommodity).setDevCard(o?void 0:this.devCard).setProgressCard(i?void 0:this.progressCard).setResources(n?e.preservesPublicCardCount(this.type)?e.maskCardCounts(this.resources,S.RESOURCE_UNSPECIFIED):void 0:this.resources).setCommodities(n?e.preservesPublicCardCount(this.type)?e.maskCardCounts(this.commodities,j.COMMODITY_UNSPECIFIED):void 0:this.commodities).setSelectedResource(n?void 0:this.selectedResource).setFishTiles(a?c:this.fishTiles).setDiscardedFishTiles(a?f:this.discardedFishTiles).setMasterMerchantResources(s?void 0:this.masterMerchantResources).setMasterMerchantCommodities(s?void 0:this.masterMerchantCommodities).setSpyVisibleProgressCards(u?void 0:this.spyVisibleProgressCards).setInitScienceProgressDeck(l?void 0:this.initScienceProgressDeck).setInitPoliticsProgressDeck(l?void 0:this.initPoliticsProgressDeck).setInitTradeProgressDeck(l?void 0:this.initTradeProgressDeck).setInitEventCardDeck(l?void 0:this.initEventCardDeck).setInitRemovedEventCards(l?void 0:this.initRemovedEventCards).build()}forSpectator(){let r=!1,t=!1,o=!1,i=!1,n=!1,a=!1,s=!1;(this.type===h.GAME_EVENT_TYPE_STEAL_RESOURCE||this.type===h.GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE||this.type===h.GAME_EVENT_TYPE_PLAY_KNIGHT)&&(r=!0),this.type===h.GAME_EVENT_TYPE_BUY_DEV_CARD&&(t=!0),(this.type===h.GAME_EVENT_TYPE_DRAW_PROGRESS_CARD||this.type===h.GAME_EVENT_TYPE_BUY_PROGRESS_CARD)&&(this.progressCard&&xr(this.progressCard)||(o=!0)),this.type===h.GAME_EVENT_TYPE_PLAY_SPY&&(o=!0),this.type===h.GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT&&(i=!0,a=!0),this.type===h.GAME_EVENT_TYPE_PLAY_SPY&&(s=!0),this.type===h.GAME_EVENT_TYPE_GIVE_WEDDING_CARDS&&(i=!0),this.type===h.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_EXCHANGE&&(i=!0),this.type===h.GAME_EVENT_TYPE_GIVE_EVENT_CARD_RESOURCE&&(i=!0),(this.type===h.GAME_EVENT_TYPE_RECEIVE_FISH||this.type===h.GAME_EVENT_TYPE_SPEND_FISH||this.type===h.GAME_EVENT_TYPE_EXCHANGE_FISH)&&(n=!0);let u=this.type===h.GAME_EVENT_TYPE_INITIALIZE_DECKS;if(!r&&!t&&!o&&!i&&!n&&!a&&!s&&!u)return this;let l=this.fishTiles;if(n&&this.fishTiles){l=new Map;let f=this.fishTiles.get(Se.FISH_OLD_BOOT);f!==void 0&&f>0&&l.set(Se.FISH_OLD_BOOT,f);let T=0;for(let[R,O]of this.fishTiles)R!==Se.FISH_OLD_BOOT&&(T+=O);T>0&&l.set(Se.FISH_UNSPECIFIED,T)}let c=this.discardedFishTiles;if(n&&this.discardedFishTiles){c=new Map;let f=this.discardedFishTiles.get(Se.FISH_OLD_BOOT);f!==void 0&&f>0&&c.set(Se.FISH_OLD_BOOT,f);let T=0;for(let[R,O]of this.discardedFishTiles)R!==Se.FISH_OLD_BOOT&&(T+=O);T>0&&c.set(Se.FISH_UNSPECIFIED,T)}return On.fromEvent(this).setStolenResource(r?this.type===h.GAME_EVENT_TYPE_PLAY_KNIGHT&&(this.stolenResource!==void 0||this.stolenCommodity!==void 0)?S.RESOURCE_UNSPECIFIED:void 0:this.stolenResource).setStolenCommodity(r?void 0:this.stolenCommodity).setDevCard(t?void 0:this.devCard).setProgressCard(o?void 0:this.progressCard).setResources(i?e.preservesPublicCardCount(this.type)?e.maskCardCounts(this.resources,S.RESOURCE_UNSPECIFIED):void 0:this.resources).setCommodities(i?e.preservesPublicCardCount(this.type)?e.maskCardCounts(this.commodities,j.COMMODITY_UNSPECIFIED):void 0:this.commodities).setSelectedResource(i?void 0:this.selectedResource).setFishTiles(n?l:this.fishTiles).setDiscardedFishTiles(n?c:this.discardedFishTiles).setMasterMerchantResources(a?void 0:this.masterMerchantResources).setMasterMerchantCommodities(a?void 0:this.masterMerchantCommodities).setSpyVisibleProgressCards(s?void 0:this.spyVisibleProgressCards).setInitScienceProgressDeck(u?void 0:this.initScienceProgressDeck).setInitPoliticsProgressDeck(u?void 0:this.initPoliticsProgressDeck).setInitTradeProgressDeck(u?void 0:this.initTradeProgressDeck).setInitEventCardDeck(u?void 0:this.initEventCardDeck).setInitRemovedEventCards(u?void 0:this.initRemovedEventCards).build()}static builder(r,t){return new On(r,t)}static rollDice(r,t){return e.builder(h.GAME_EVENT_TYPE_ROLL_DICE,r).setDice(t).build()}static receiveResources(r,t){return e.builder(h.GAME_EVENT_TYPE_RECEIVE_RESOURCES,r).setResources(t).build()}static discardResources(r,t,o){let i=e.builder(h.GAME_EVENT_TYPE_DISCARD_RESOURCES,r).setResources(t);return o&&i.setCommodities(o),i.build()}static selectFreeResource(r,t){return e.builder(h.GAME_EVENT_TYPE_SELECT_FREE_RESOURCE,r).setSelectedResource(t).build()}static resourceDistributionEvent(r,t){return e.builder(h.GAME_EVENT_TYPE_RESOURCE_DISTRIBUTION,r).setResourceDistribution(t).build()}static moveRobber(r,t){return e.builder(h.GAME_EVENT_TYPE_MOVE_ROBBER,r).setRobberLocation(t).build()}static lazyRobberRetreat(r,t,o){let i=e.builder(h.GAME_EVENT_TYPE_LAZY_ROBBER_RETREAT,r).setLazyRobberFrom(t);return o!==void 0&&i.setRobberLocation(o),i.build()}static stealResource(r,t,o){return e.builder(h.GAME_EVENT_TYPE_STEAL_RESOURCE,r).setTargetPlayer(t).setStolenResource(o).build()}static stealCommodity(r,t,o){return e.builder(h.GAME_EVENT_TYPE_STEAL_RESOURCE,r).setTargetPlayer(t).setStolenCommodity(o).build()}static buildRoad(r,t){return e.builder(h.GAME_EVENT_TYPE_BUILD_ROAD,r).setEdge(t).build()}static buildSettlement(r,t){return e.builder(h.GAME_EVENT_TYPE_BUILD_SETTLEMENT,r).setVertex(t).build()}static buildCity(r,t){return e.builder(h.GAME_EVENT_TYPE_BUILD_CITY,r).setVertex(t).build()}static placeFreeStructure(r,t,o,i){let n=e.builder(h.GAME_EVENT_TYPE_PLACE_FREE_STRUCTURE,r).setBuilding(t);return o!==void 0&&n.setEdge(o),i!==void 0&&n.setVertex(i),n.build()}static buyDevCard(r,t,o=!1){let i=e.builder(h.GAME_EVENT_TYPE_BUY_DEV_CARD,r).setDevCard(t);return o&&i.setFreeDevCard(!0),i.build()}static playKnight(r,t,o,i){let n=e.builder(h.GAME_EVENT_TYPE_PLAY_KNIGHT,r);return t!==void 0&&n.setRobberLocation(t),o!==void 0&&n.setTargetPlayer(o),i!==void 0&&n.setStolenResource(i),n.build()}static playRoadBuilding(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_ROAD_BUILDING,r).build()}static playYearOfPlenty(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_YEAR_OF_PLENTY,r).build()}static playMonopoly(r,t,o){return e.builder(h.GAME_EVENT_TYPE_PLAY_MONOPOLY,r).setMonopolyResource(t).setMonopolyResults(o).build()}static playVictoryPoint(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_VICTORY_POINT,r).build()}static tradeWithPlayer(r,t,o,i){return e.builder(h.GAME_EVENT_TYPE_TRADE_WITH_PLAYER,r).setTradePartner(t).setOfferedResources(o).setReceivedResources(i).build()}static tradeWithBank(r,t,o,i,n){let a=e.builder(h.GAME_EVENT_TYPE_TRADE_WITH_BANK,r).setOfferedResources(t).setReceivedResources(o);return i&&i.size>0&&a.setOfferedCommodities(i),n&&n.size>0&&a.setReceivedCommodities(n),a.build()}static proposeTrade(r,t,o,i,n,a,s,u,l){let c=e.builder(h.GAME_EVENT_TYPE_PROPOSE_TRADE,r).setTradeId(t).setOfferedResources(o).setReceivedResources(i);return n&&c.setOfferedCommodities(n),a&&c.setReceivedCommodities(a),s!==void 0&&s>0&&c.setOfferedGold(s),u!==void 0&&u>0&&c.setReceivedGold(u),l!==void 0&&l>0&&c.setCounterTradeId(l),c.build()}static proposeMultiTrade(r,t){return e.builder(h.GAME_EVENT_TYPE_PROPOSE_MULTI_TRADE,r).setTradeProposals(t).build()}static acceptTrade(r,t){return e.builder(h.GAME_EVENT_TYPE_ACCEPT_TRADE,r).setTradeId(t).build()}static revokeTradeAccept(r,t){return e.builder(h.GAME_EVENT_TYPE_REVOKE_TRADE_ACCEPT,r).setTradeId(t).build()}static rejectTrade(r,t){return e.builder(h.GAME_EVENT_TYPE_REJECT_TRADE,r).setTradeId(t).build()}static cancelTrade(r,t){return e.builder(h.GAME_EVENT_TYPE_CANCEL_TRADE,r).setTradeId(t).build()}static executeTrade(r,t,o,i,n,a,s,u,l){let c=e.builder(h.GAME_EVENT_TYPE_EXECUTE_TRADE,r).setTradeId(t).setTradePartner(o).setOfferedResources(i).setReceivedResources(n);return a&&a.size>0&&c.setOfferedCommodities(a),s&&s.size>0&&c.setReceivedCommodities(s),u!==void 0&&u>0&&c.setOfferedGold(u),l!==void 0&&l>0&&c.setReceivedGold(l),c.build()}static endTurn(r,t){let o=e.builder(h.GAME_EVENT_TYPE_END_TURN,r);return t!==void 0&&o.setElapsedTimeMs(t),o.build()}static buildShip(r,t){return e.builder(h.GAME_EVENT_TYPE_BUILD_SHIP,r).setEdge(t).build()}static moveShip(r,t,o){return e.builder(h.GAME_EVENT_TYPE_MOVE_SHIP,r).setShipFromEdge(t).setShipToEdge(o).build()}static movePirate(r,t){return e.builder(h.GAME_EVENT_TYPE_MOVE_PIRATE,r).setPirateLocation(t).build()}static stealResourcePirate(r,t,o){return e.builder(h.GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE,r).setTargetPlayer(t).setStolenResource(o).build()}static stealCommodityPirate(r,t,o){return e.builder(h.GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE,r).setTargetPlayer(t).setStolenCommodity(o).build()}static buildKnight(r,t,o){return e.builder(h.GAME_EVENT_TYPE_BUILD_KNIGHT,r).setKnightLocation(t).setKnightStrength(o).build()}static activateKnight(r,t){return e.builder(h.GAME_EVENT_TYPE_ACTIVATE_KNIGHT,r).setKnightLocation(t).setKnightStatus(ir.KNIGHT_STATUS_ACTIVE).build()}static promoteKnight(r,t,o){return e.builder(h.GAME_EVENT_TYPE_PROMOTE_KNIGHT,r).setKnightLocation(t).setKnightStrength(o).build()}static moveKnight(r,t,o){return e.builder(h.GAME_EVENT_TYPE_MOVE_KNIGHT,r).setKnightLocation(t).setKnightDestination(o).build()}static displaceKnight(r,t,o,i,n){let a=e.builder(h.GAME_EVENT_TYPE_DISPLACE_KNIGHT,r).setKnightLocation(t).setKnightDestination(o).setDisplacedKnightOwner(i);return n&&a.setDisplacedKnightTo(n),a.build()}static chaseRobber(r,t,o){return e.builder(h.GAME_EVENT_TYPE_CHASE_ROBBER,r).setKnightLocation(t).setRobberLocation(o).build()}static useKnightErrant(r,t,o){return e.builder(h.GAME_EVENT_TYPE_USE_KNIGHT_ERRANT,r).setKnightLocation(t).setRobberLocation(o).build()}static knightsDeactivated(r){return e.builder(h.GAME_EVENT_TYPE_KNIGHTS_DEACTIVATED,r).build()}static buildCityWall(r,t){return e.builder(h.GAME_EVENT_TYPE_BUILD_CITY_WALL,r).setVertex(t).build()}static buildCityImprovement(r,t,o){return e.builder(h.GAME_EVENT_TYPE_BUILD_CITY_IMPROVEMENT,r).setImprovementTrack(t).setImprovementLevel(o).build()}static receiveCommodities(r,t){return e.builder(h.GAME_EVENT_TYPE_RECEIVE_COMMODITIES,r).setCommodities(t).build()}static rollEventDie(r,t){return e.builder(h.GAME_EVENT_TYPE_ROLL_EVENT_DIE,r).setEventDieResult(t).build()}static barbarianAdvance(r,t){return e.builder(h.GAME_EVENT_TYPE_BARBARIAN_ADVANCE,r).setBarbarianPosition(t).build()}static barbarianAttack(r,t,o,i,n,a){let s=e.builder(h.GAME_EVENT_TYPE_BARBARIAN_ATTACK,r).setBarbarianStrength(t).setKnightDefenseStrength(o).setBarbarianVictory(i);return n!==void 0&&s.setPillagePlayers(n),a!==void 0&&s.setDefenderPlayers(a),s.build()}static cityPillaged(r,t){return e.builder(h.GAME_EVENT_TYPE_CITY_PILLAGED,r).setPillagedCityLocation(t).build()}static defenderOfCatan(r){return e.builder(h.GAME_EVENT_TYPE_DEFENDER_OF_CATAN,r).build()}static awaitKnightCommitment(r,t){return e.builder(h.GAME_EVENT_TYPE_AWAIT_KNIGHT_COMMITMENT,r).setBarbarianStrength(t).build()}static commitKnightsToDefense(r,t){let o=e.builder(h.GAME_EVENT_TYPE_COMMIT_KNIGHTS_TO_DEFENSE,r).setCommittedKnights(t);return t.length>0&&o.setKnightLocation(t[0]),o.setKnightDefenseStrength(t.length),o.build()}static drawProgressCard(r,t,o){return e.builder(h.GAME_EVENT_TYPE_DRAW_PROGRESS_CARD,r).setProgressCard(t).setProgressCardTrack(o).build()}static buyProgressCard(r,t,o){return e.builder(h.GAME_EVENT_TYPE_BUY_PROGRESS_CARD,r).setProgressCard(o).setProgressCardTrack(t).build()}static playAlchemist(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_ALCHEMIST,r).build()}static playEngineer(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_ENGINEER,r).build()}static playCrane(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_CRANE,r).build()}static playMedicine(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_MEDICINE,r).build()}static playDeserter(r,t,o){return e.builder(h.GAME_EVENT_TYPE_PLAY_DESERTER,r).setKnightLocation(t).setTargetPlayer(o).build()}static playDeserterStep1(r,t){return e.builder(h.GAME_EVENT_TYPE_PLAY_DESERTER,r).setTargetPlayer(t).build()}static selectDeserterKnight(r,t,o){return e.builder(h.GAME_EVENT_TYPE_SELECT_DESERTER_KNIGHT,r).setKnightLocation(t).setTargetPlayer(o).build()}static playIntrigue(r,t,o,i){let n=e.builder(h.GAME_EVENT_TYPE_PLAY_INTRIGUE,r).setKnightLocation(t).setDisplacedKnightOwner(i);return o&&n.setKnightDestination(o),n.build()}static playMerchantCard(r,t){return e.builder(h.GAME_EVENT_TYPE_PLAY_MERCHANT_CARD,r).setMerchantLocation(t).build()}static playMerchantFleet(r,t,o){let i=e.builder(h.GAME_EVENT_TYPE_PLAY_MERCHANT_FLEET,r);return t&&i.setMerchantFleetResource(t),o&&i.setMerchantFleetCommodity(o),i.build()}static playDiplomat(r,t,o){return e.builder(h.GAME_EVENT_TYPE_PLAY_DIPLOMAT,r).setEdge(t).setTargetPlayer(o).build()}static playResourceMonopoly(r,t,o){return e.builder(h.GAME_EVENT_TYPE_PLAY_RESOURCE_MONOPOLY,r).setMonopolyResource(t).setMonopolyResults(o).build()}static playProgressRoadBuilding(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_PROGRESS_ROAD_BUILDING,r).build()}static playSmith(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_SMITH,r).build()}static progressCardDiscardRequired(r){return e.builder(h.GAME_EVENT_TYPE_PROGRESS_CARD_DISCARD_REQUIRED,r).build()}static discardProgressCard(r,t){return e.builder(h.GAME_EVENT_TYPE_DISCARD_PROGRESS_CARD,r).setProgressCard(t).build()}static playSpy(r,t,o,i){let n=e.builder(h.GAME_EVENT_TYPE_PLAY_SPY,r).setTargetPlayer(t);return o!==void 0&&(n.setProgressCard(o),n.setProgressCardTrack(Rn(o))),i&&n.setSpyVisibleProgressCards(i),n.build()}static playMasterMerchant(r,t,o,i,n,a){let s=e.builder(h.GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT,r).setTargetPlayer(t);return o&&s.setResources(o),i&&s.setCommodities(i),n&&s.setMasterMerchantResources(n),a&&s.setMasterMerchantCommodities(a),s.build()}static playWarlord(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_WARLORD,r).build()}static playSaboteur(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_SABOTEUR,r).build()}static playWedding(r){return e.builder(h.GAME_EVENT_TYPE_PLAY_WEDDING,r).build()}static giveWeddingCards(r,t,o,i){return e.builder(h.GAME_EVENT_TYPE_GIVE_WEDDING_CARDS,r).setTargetPlayer(t).setResources(o).setCommodities(i).build()}static playCommercialHarbor(r,t){return e.builder(h.GAME_EVENT_TYPE_PLAY_COMMERCIAL_HARBOR,r).setCommercialHarborTrades(t).build()}static commercialHarborTradeCancelled(r,t,o){return e.builder(h.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_TRADE_CANCELLED,r).setTargetPlayer(t).setResources(new Map([[o,1]])).build()}static commercialHarborExchange(r,t,o,i){return e.builder(h.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_EXCHANGE,r).setTargetPlayer(t).setResources(o).setCommodities(i).build()}static playMining(r,t){return e.builder(h.GAME_EVENT_TYPE_PLAY_MINING,r).setResources(t).build()}static playIrrigation(r,t){return e.builder(h.GAME_EVENT_TYPE_PLAY_IRRIGATION,r).setResources(t).build()}static playTradeMonopoly(r,t,o){return e.builder(h.GAME_EVENT_TYPE_PLAY_TRADE_MONOPOLY,r).setTradeMonopolyCommodity(t).setMonopolyResults(o).build()}static playBishop(r,t,o){let i=e.builder(h.GAME_EVENT_TYPE_PLAY_BISHOP,r);return t!==void 0&&i.setRobberLocation(t),i.setMonopolyResults(o),i.build()}static playInventor(r,t,o){return e.builder(h.GAME_EVENT_TYPE_PLAY_INVENTOR,r).setInventorHex1(t).setInventorHex2(o).build()}static metropolisBuilt(r,t){return e.builder(h.GAME_EVENT_TYPE_METROPOLIS_BUILT,r).setMetropolis(t).build()}static metropolisTransferred(r,t,o){return e.builder(h.GAME_EVENT_TYPE_METROPOLIS_TRANSFERRED,r).setMetropolis(t).setPreviousMetropolisOwner(o).build()}static selectMetropolisCity(r,t,o){return e.builder(h.GAME_EVENT_TYPE_SELECT_METROPOLIS_CITY,r).setVertex(t).setImprovementTrack(o).build()}static merchantPlaced(r,t){return e.builder(h.GAME_EVENT_TYPE_MERCHANT_PLACED,r).setMerchantLocation(t).build()}static aqueductTriggered(r){return e.builder(h.GAME_EVENT_TYPE_AQUEDUCT_TRIGGERED,r).build()}static goldProduced(r,t){return e.builder(h.GAME_EVENT_TYPE_GOLD_PRODUCED,r).setFreeResourceCount(t).build()}static passOldBoot(r,t){return e.builder(h.GAME_EVENT_TYPE_PASS_OLD_BOOT,r).setTargetPlayer(t).build()}static receiveFish(r,t){return e.builder(h.GAME_EVENT_TYPE_RECEIVE_FISH,r).setFishTiles(t).build()}static spendFish(r,t){return e.builder(h.GAME_EVENT_TYPE_SPEND_FISH,r).setFishTiles(t).build()}static exchangeFish(r,t,o){return e.builder(h.GAME_EVENT_TYPE_EXCHANGE_FISH,r).setFishTiles(t).setDiscardedFishTiles(o).build()}static revealFog(r,t,o,i,n){let a=e.builder(h.GAME_EVENT_TYPE_REVEAL_FOG,r).setFogHexLocation(t).setFogRevealedTerrain(o).setFogRevealedNumber(i);return n!==void 0&&a.setFogRewardResource(n),a.build()}static resign(r){return e.builder(h.GAME_EVENT_TYPE_RESIGN,r).build()}static pause(r){return e.builder(h.GAME_EVENT_TYPE_PAUSE,r).build()}static unpause(r){return e.builder(h.GAME_EVENT_TYPE_UNPAUSE,r).build()}static voteToContinue(r){return e.builder(h.GAME_EVENT_TYPE_VOTE_TO_CONTINUE,r).build()}static awardLargestArmy(r,t){let o=e.builder(h.GAME_EVENT_TYPE_AWARD_LARGEST_ARMY,r);return t!==void 0&&o.setPreviousAwardHolder(t),o.build()}static awardLongestRoad(r,t){let o=e.builder(h.GAME_EVENT_TYPE_AWARD_LONGEST_ROAD,r);return t!==void 0&&o.setPreviousAwardHolder(t),o.build()}static awardHarbormaster(r,t){let o=e.builder(h.GAME_EVENT_TYPE_AWARD_HARBORMASTER,r);return t!==void 0&&o.setPreviousAwardHolder(t),o.build()}static freeResourceGranted(r,t,o){return e.builder(h.GAME_EVENT_TYPE_FREE_RESOURCE_GRANTED,r).setFreeResourceReason(t).setFreeResourceCount(o).build()}static freeStructureGranted(r,t,o){return e.builder(h.GAME_EVENT_TYPE_FREE_STRUCTURE_GRANTED,r).setFreeStructureReason(t).setFreeStructureBuilding(o).build()}static gameWon(r,t){return e.builder(h.GAME_EVENT_TYPE_GAME_WON,r).setWinReason(t).build()}static initializeDecks(r,t,o,i,n,a,s){return e.builder(h.GAME_EVENT_TYPE_INITIALIZE_DECKS,r).setInitScienceProgressDeck(t).setInitPoliticsProgressDeck(o).setInitTradeProgressDeck(i).setInitEventCardDeck(n).setInitRemovedEventCards(a).setInitialFogReveals(s).build()}static newIslandSettlement(r,t){return e.builder(h.GAME_EVENT_TYPE_NEW_ISLAND_SETTLEMENT,r).setIslandBonusVp(t).build()}static collectEdgeVp(r,t){return e.builder(h.GAME_EVENT_TYPE_COLLECT_EDGE_VP,r).setEdge(t).setEdgeRewardType(Tr.EDGE_REWARD_TYPE_VICTORY_POINT).build()}static collectEdgeDevCard(r,t,o){return e.builder(h.GAME_EVENT_TYPE_COLLECT_EDGE_DEV_CARD,r).setEdge(t).setEdgeRewardType(Tr.EDGE_REWARD_TYPE_DEV_CARD).setDevCard(o).build()}static collectEdgePort(r,t,o){return e.builder(h.GAME_EVENT_TYPE_COLLECT_EDGE_PORT,r).setEdge(t).setEdgeRewardType(Tr.EDGE_REWARD_TYPE_PORT).setCollectedPort(o).build()}static placePort(r,t,o){return e.builder(h.GAME_EVENT_TYPE_PLACE_PORT,r).setEdge(t).setCollectedPort(o).build()}static startSecondSettlerTurn(r,t){return e.builder(h.GAME_EVENT_TYPE_START_SECOND_SETTLER_TURN,r).setPairedPlayer(t).build()}static endSecondSettlerTurn(r){return e.builder(h.GAME_EVENT_TYPE_END_SECOND_SETTLER_TURN,r).build()}static roadDamaged(r,t){return e.builder(h.GAME_EVENT_TYPE_ROAD_DAMAGED,r).setEdge(t).build()}static giveEventCardResource(r,t,o){let i=e.builder(h.GAME_EVENT_TYPE_GIVE_EVENT_CARD_RESOURCE,r).setTargetPlayer(t);return o.resource&&i.setSelectedResource(o.resource),o.commodity&&i.setCommodities(new Map([[o.commodity,1]])),i.build()}static tilesDesertified(r){return e.builder(h.GAME_EVENT_TYPE_TILES_DESERTIFIED,r).build()}static wagonVotingStarted(r,t,o){return e.builder(h.GAME_EVENT_TYPE_WAGON_VOTING_STARTED,r).setWagonVotingPlayers(t).setWagonValidPlacements(o).build()}static wagonVote(r,t){return e.builder(h.GAME_EVENT_TYPE_WAGON_VOTE,r).setWagonVotes([t]).build()}static wagonPlaced(r,t){return e.builder(h.GAME_EVENT_TYPE_WAGON_PLACED,x.PLAYER_COLOR_UNSPECIFIED).setPlacedWagon(r).setWagonVotes(t).build()}static wagonsExhausted(){return e.builder(h.GAME_EVENT_TYPE_WAGONS_EXHAUSTED,x.PLAYER_COLOR_UNSPECIFIED).build()}static receiveGold(r,t,o){let i=e.builder(h.GAME_EVENT_TYPE_RECEIVE_GOLD,r).setGoldAmount(t);return o?.building!==void 0&&i.setBuilding(o.building),o?.edge&&i.setEdge(o.edge),o?.vertex&&i.setVertex(o.vertex),i.build()}static spendGold(r,t,o){return e.builder(h.GAME_EVENT_TYPE_SPEND_GOLD,r).setGoldAmount(t).setSelectedResource(o).build()}static buyGold(r,t,o,i){return e.builder(h.GAME_EVENT_TYPE_BUY_GOLD,r).setOfferedResources(new Map([[t,o]])).setGoldAmount(i).build()}static buildBridge(r,t){return e.builder(h.GAME_EVENT_TYPE_BUILD_BRIDGE,r).setEdge(t).build()}static wealthiestTraderChanged(r,t){let o=e.builder(h.GAME_EVENT_TYPE_WEALTHIEST_TRADER_CHANGED,r??x.PLAYER_COLOR_UNSPECIFIED);return t!==void 0&&o.setPreviousAwardHolder(t),o.build()}static poorestTraderChanged(r,t){return e.builder(h.GAME_EVENT_TYPE_POOREST_TRADER_CHANGED,x.PLAYER_COLOR_UNSPECIFIED).setPoorTraders(r,t).build()}static trollsInvaded(r){return e.builder(h.GAME_EVENT_TYPE_TROLLS_INVADED,x.PLAYER_COLOR_UNSPECIFIED).setTrollCount(r).build()}static feedTroll(r,t,o){return e.builder(h.GAME_EVENT_TYPE_FEED_TROLL,r).setTrollHex(t).setResources(o).build()}static kickTroll(r,t,o){return e.builder(h.GAME_EVENT_TYPE_KICK_TROLL,r).setTrollHex(t).setKnightLocation(o).build()}static voteDiceRoll(r){return e.builder(h.GAME_EVENT_TYPE_VOTE_DICE_ROLL,r).build()}static rushRoundStart(r,t){return e.builder(h.GAME_EVENT_TYPE_RUSH_ROUND_START,r).setRushNextDiceRollAt(t).build()}static tradeEmbargo(r,t,o){return e.builder(h.GAME_EVENT_TYPE_TRADE_EMBARGO,r).setTargetPlayer(t).setEmbargoActive(o).build()}};function ja(e){let r=new Map;for(let t of e)r.set(t.resource,t.count);return r}E(ja,"resourceCountsToMap");function es(e){let r=[];for(let[t,o]of e)r.push(ne.create({resource:t,count:o}));return r}E(es,"mapToResourceCounts");function rs(e){let r=new Map;for(let t of e)r.set(t.commodity,t.count);return r}E(rs,"commodityCountsToMap");function ts(e){let r=[];for(let[t,o]of e)r.push(te.create({commodity:t,count:o}));return r}E(ts,"mapToCommodityCounts");function hN(e){let r=new Map;for(let t of e)r.set(t.fish,t.count);return r}E(hN,"fishCountsToMap");function DN(e){let r=[];for(let[t,o]of e)r.push(xe.create({fish:t,count:o}));return r}E(DN,"mapToFishCounts");function qD(e){let r=new Map;for(let t of e)r.set(t.card,t.count);return r}E(qD,"progressCardCountsToMap");function ZD(e){let r=[];for(let[t,o]of e)r.push(dr.create({card:t,count:o}));return r}E(ZD,"mapToProgressCardCounts");function mN(e){let r=new Map;for(let t of e)r.set(t.card,t.count);return r}E(mN,"eventCardCountsToMap");function gN(e){let r=[];for(let[t,o]of e)r.push(Rr.create({card:t,count:o}));return r}E(gN,"mapToEventCardCounts");pN(y);function m(e,r){let t=e.toOptions();return new gr({...t,board:r.board??t.board,resourceDeck:r.resourceDeck??t.resourceDeck,devCardDeck:r.devCardDeck??t.devCardDeck,playerStates:r.playerStates??t.playerStates,playerPublicStates:r.playerPublicStates??t.playerPublicStates,dice:r.dice!==void 0?r.dice:t.dice,activeTrades:r.activeTrades??t.activeTrades,pendingDiceRoll:r.pendingDiceRoll??t.pendingDiceRoll,pendingDiscards:r.pendingDiscards??t.pendingDiscards,pendingRobberOrPiratePlacement:r.pendingRobberOrPiratePlacement??t.pendingRobberOrPiratePlacement,playedDevCardThisTurn:r.playedDevCardThisTurn??t.playedDevCardThisTurn,pendingFreeResources:r.pendingFreeResources??t.pendingFreeResources,pendingFreeStructures:r.pendingFreeStructures??t.pendingFreeStructures,currentPlayer:r.currentPlayer??t.currentPlayer,turnNumber:r.turnNumber??t.turnNumber,isSetupPhase:r.isSetupPhase??t.isSetupPhase,tradesProposedThisTurn:r.tradesProposedThisTurn??t.tradesProposedThisTurn,nextTradeId:r.nextTradeId??t.nextTradeId,rejectedTradeOffers:r.rejectedTradeOffers??t.rejectedTradeOffers,tradesExecutedThisTurn:r.tradesExecutedThisTurn??t.tradesExecutedThisTurn,movedShipThisTurn:r.movedShipThisTurn??t.movedShipThisTurn,shipsBuiltThisTurn:r.shipsBuiltThisTurn??t.shipsBuiltThisTurn,progressCardsInPlay:r.progressCardsInPlay??t.progressCardsInPlay,merchantFleetResource:r.merchantFleetResource===null?void 0:r.merchantFleetResource??t.merchantFleetResource,merchantFleetCommodity:r.merchantFleetCommodity===null?void 0:r.merchantFleetCommodity??t.merchantFleetCommodity,smithFreePromotionsRemaining:r.smithFreePromotionsRemaining??t.smithFreePromotionsRemaining,pendingWeddingCards:r.pendingWeddingCards??t.pendingWeddingCards,pendingCommercialHarborExchanges:r.pendingCommercialHarborExchanges??t.pendingCommercialHarborExchanges,scienceProgressDeck:r.scienceProgressDeck??t.scienceProgressDeck,politicsProgressDeck:r.politicsProgressDeck??t.politicsProgressDeck,tradeProgressDeck:r.tradeProgressDeck??t.tradeProgressDeck,pendingDefenderSelection:r.pendingDefenderSelection??t.pendingDefenderSelection,pendingCityPillagePlayers:r.pendingCityPillagePlayers??t.pendingCityPillagePlayers,discardsWithoutRobber:r.discardsWithoutRobber??t.discardsWithoutRobber,commodityBank:r.commodityBank??t.commodityBank,fishBank:r.fishBank??t.fishBank,oldBoot:r.oldBoot!==void 0?r.oldBoot:t.oldBoot,fogTerrainBank:r.fogTerrainBank??t.fogTerrainBank,fogNumberBank:r.fogNumberBank??t.fogNumberBank,pendingResourceResolution:r.pendingResourceResolution??t.pendingResourceResolution,pendingSecondTurboRoll:r.pendingSecondTurboRoll??t.pendingSecondTurboRoll,isSecondSettlerPhase:r.isSecondSettlerPhase??t.isSecondSettlerPhase,timerState:r.timerState??t.timerState,paused:r.paused??t.paused,winner:r.winner??t.winner,diceRollCount:r.diceRollCount??t.diceRollCount,diceDistribution:r.diceDistribution??t.diceDistribution,sevensPerPlayer:r.sevensPerPlayer??t.sevensPerPlayer,devCardDrawCount:r.devCardDrawCount??t.devCardDrawCount,stealCount:r.stealCount??t.stealCount,eventCardDeck:r.eventCardDeck??t.eventCardDeck,removedEventCards:r.removedEventCards??t.removedEventCards,pendingGoodNeighbors:r.pendingGoodNeighbors??t.pendingGoodNeighbors,pendingHelpfulNeighbors:r.pendingHelpfulNeighbors??t.pendingHelpfulNeighbors,pendingEarthquake:r.pendingEarthquake??t.pendingEarthquake,pendingWagonVoting:r.pendingWagonVoting===null?void 0:r.pendingWagonVoting??t.pendingWagonVoting,wagonsExhausted:r.wagonsExhausted??t.wagonsExhausted,rushPlayedDevCard:r.rushPlayedDevCard??t.rushPlayedDevCard,rushNextDiceRollAt:r.rushNextDiceRollAt??t.rushNextDiceRollAt,rushDiceVotes:r.rushDiceVotes??t.rushDiceVotes,pendingRobberStealLocation:r.pendingRobberStealLocation===null?void 0:r.pendingRobberStealLocation??t.pendingRobberStealLocation,pendingPirateStealLocation:r.pendingPirateStealLocation===null?void 0:r.pendingPirateStealLocation??t.pendingPirateStealLocation,largestArmyPlayer:r.largestArmyPlayer===null?void 0:r.largestArmyPlayer??t.largestArmyPlayer,longestRoadPlayer:r.longestRoadPlayer===null?void 0:r.longestRoadPlayer??t.longestRoadPlayer,harbormasterPlayer:r.harbormasterPlayer===null?void 0:r.harbormasterPlayer??t.harbormasterPlayer,pendingAlchemist:r.pendingAlchemist===null?void 0:r.pendingAlchemist??t.pendingAlchemist,pendingSpyTarget:r.pendingSpyTarget===null?void 0:r.pendingSpyTarget??t.pendingSpyTarget,masterMerchantTarget:r.masterMerchantTarget===null?void 0:r.masterMerchantTarget??t.masterMerchantTarget,pendingCityPillage:r.pendingCityPillage===null?void 0:r.pendingCityPillage??t.pendingCityPillage,secondSettlerPlayer:r.secondSettlerPlayer===null?void 0:r.secondSettlerPlayer??t.secondSettlerPlayer,pendingKnightCommitment:r.pendingKnightCommitment===null?void 0:r.pendingKnightCommitment??t.pendingKnightCommitment,pauseState:r.pauseState===null?void 0:r.pauseState??t.pauseState,pendingEventCardSteal:r.pendingEventCardSteal===null?void 0:r.pendingEventCardSteal??t.pendingEventCardSteal,pendingBishopSteal:r.pendingBishopSteal===null?void 0:r.pendingBishopSteal??t.pendingBishopSteal,pendingProgressCardDiscard:r.pendingProgressCardDiscard??t.pendingProgressCardDiscard,pendingKnights:r.pendingKnights??t.pendingKnights,pendingDeserter:r.pendingDeserter===null?void 0:r.pendingDeserter??t.pendingDeserter,pendingMetropolisPlacement:r.pendingMetropolisPlacement===null?void 0:r.pendingMetropolisPlacement??t.pendingMetropolisPlacement,rushRobberPlayer:r.rushRobberPlayer===null?void 0:r.rushRobberPlayer??t.rushRobberPlayer,tradeEmbargoes:r.tradeEmbargoes??t.tradeEmbargoes,goldSpentThisTurn:r.goldSpentThisTurn??t.goldSpentThisTurn,tradeBalance:r.tradeBalance??t.tradeBalance,stateVersion:e.stateVersion+1,mapVersion:r.incrementMapVersion?e.mapVersion+1:e.mapVersion,buildingVersion:r.incrementBuildingVersion?e.buildingVersion+1:e.buildingVersion})}E(m,"createGame");function In(e,r){return e.length<=1?[r]:[...e.slice(1),r]}E(In,"rotateRobbers");function pe(e,r){let t=e.toBuilder();return r.tiles&&(t=t.withTiles(r.tiles)),r.ports&&(t=t.withPorts(r.ports)),r.robbers&&(t=t.withRobbers(r.robbers)),r.edgeBuildings&&(t=t.withEdgeBuildings(r.edgeBuildings)),r.vertexBuildings&&(t=t.withVertexBuildings(r.vertexBuildings)),r.cityWalls&&(t=t.withCityWalls(r.cityWalls)),r.merchant&&(t=t.withMerchant(r.merchant)),r.knights&&(t=t.withKnights(r.knights)),r.edgeRewards&&(t=t.withEdgeRewards(r.edgeRewards)),r.trolls&&(t=t.withTrolls(r.trolls)),t.build()}E(pe,"createBoard");function yN(e,r){return e.toBuilder().withPirate(r).build()}E(yN,"createBoardWithPirate");function Xd(e,r){return e.toBuilder().withMetropolises(r).build()}E(Xd,"createBoardWithMetropolises");function ot(e){return new Map(e.pendingFreeResources)}E(ot,"copyPendingFreeResources");function Kt(e){let r=new Map;for(let[t,o]of e.pendingFreeStructures)r.set(t,[...o]);return r}E(Kt,"copyPendingFreeStructures");function MN(e){return new Map(e.pendingDiscards)}E(MN,"copyPendingDiscards");function Cn(e){let r=new Map;for(let t of e.getPlayerPublicStates()){let o=e.options.citiesAndKnights?e.board.cityWalls.filter(n=>n.owner===t.player).length:0,i=e.options.getDiscardLimitWithWalls(o);t.cardCount>i&&r.set(t.player,Math.floor(t.cardCount/2))}return r}E(Cn,"calculatePendingDiscards");function wl(e){return new Map(e.pendingProgressCardDiscard)}E(wl,"copyPendingProgressCardDiscard");function z(e,r,t){return e.map(o=>o.player===r?t(o):o)}E(z,"updatePlayerState");function Z(e,r,t){return e.map(o=>o.player===r?t(o):o)}E(Z,"updatePlayerPublicState");function $e(e,r){let t=new Map(e);for(let[o,i]of r)t.set(o,(t.get(o)??0)+i);return t}E($e,"addResourcesToHand");function ke(e,r){let t=new Map(e);for(let[o,i]of r){let a=(t.get(o)??0)-i;a<=0?t.delete(o):t.set(o,a)}return t}E(ke,"removeResourcesFromHand");function Pr(e,r){let t=new Map(e);for(let[o,i]of r)t.set(o,(t.get(o)??0)+i);return t}E(Pr,"addResourcesToBank");function Lt(e,r){let t=new Map(e);for(let[o,i]of r){let n=t.get(o)??0;if(i>n)throw new Error(`Cannot remove ${i} of resource ${o} from bank - only ${n} available`);t.set(o,n-i)}return t}E(Lt,"removeResourcesFromBank");function Qe(e){let r=0;for(let t of e.values())r+=t;return r}E(Qe,"countResources");function yr(e,r){let t=new Map(e);for(let[o,i]of r)t.set(o,(t.get(o)??0)+i);return t}E(yr,"addCommoditiesToHand");function wr(e,r){let t=new Map(e);for(let[o,i]of r){let a=(t.get(o)??0)-i;a<=0?t.delete(o):t.set(o,a)}return t}E(wr,"removeCommoditiesFromHand");function Mr(e){let r=0;for(let t of e.values())r+=t;return r}E(Mr,"countCommodities");function ns(e,r){let t=new Map(e);for(let[o,i]of r)t.set(o,(t.get(o)??0)+i);return t}E(ns,"addCommoditiesToBank");function pi(e,r){let t=new Map(e);for(let[o,i]of r){let n=t.get(o)??0;if(i>n)throw new Error(`Cannot remove ${i} of commodity ${o} from bank - only ${n} available`);t.set(o,n-i)}return t}E(pi,"removeCommoditiesFromBank");function U_(e,r){let t=new Map;for(let[o,i]of r){let n=e.get(o)??0;t.set(o,Math.min(i,n))}return t}E(U_,"capCommoditiesToBank");function je(e,r){if(xr(r))return{};switch(Rn(r)){case K.CITY_IMPROVEMENT_TRACK_SCIENCE:return{scienceProgressDeck:[...e.scienceProgressDeck,r]};case K.CITY_IMPROVEMENT_TRACK_POLITICS:return{politicsProgressDeck:[...e.politicsProgressDeck,r]};case K.CITY_IMPROVEMENT_TRACK_TRADE:return{tradeProgressDeck:[...e.tradeProgressDeck,r]};default:return{}}}E(je,"returnProgressCardToDeck");function zd(e,r){let t=r!==void 0&&r!==ie.DEV_CARD_UNSPECIFIED,o=t&&(e.get(r)??0)>0?r:ie.DEV_CARD_UNSPECIFIED;if((e.get(o)??0)>0)return new Map(e).set(o,e.get(o)-1);if(t)return e;let i=0;for(let n of e.values())i+=n;return i>0?new Map([[ie.DEV_CARD_UNSPECIFIED,i-1]]):e}E(zd,"drawDevCardFromDeck");function Hl(e,r){let t=new Map;for(let[o,i]of e){let n=r.get(o)??0;t.set(o,Math.min(i,n))}return t}E(Hl,"capResourcesToBank");function LN(e,r){if(!r.lazyRobberFrom)throw new Error("LAZY_ROBBER_RETREAT event must have lazyRobberFrom");let t=r.lazyRobberFrom,o=e.board.robbers.findIndex(n=>n.equals(t));if(o===-1)return e;let i=e.board.robbers.filter((n,a)=>a!==o);return r.robberLocation&&i.push(r.robberLocation),m(e,{board:pe(e.board,{robbers:i})})}E(LN,"applyLazyRobberRetreat");var hi=class{static{E(this,"HarbormasterCalculator")}game;constructor(r){this.game=r}calculateHarborPointsForPlayer(r){let t=0,o=new Set;for(let i of this.game.board.ports)o.add(i.edge.v1.toString()),o.add(i.edge.v2.toString());for(let i of this.game.getVertexBuildingsByPlayer(r))o.has(i.vertex.toString())&&(t+=i.isCity?2:1);return t}calculateHarbormasterHolder(){let r=new Map;for(let i of this.game.turnOrder){let n=this.calculateHarborPointsForPlayer(i);r.set(i,n)}let t=2,o;for(let[i,n]of r)n>t&&(t=n,o=i);if(this.game.harbormasterPlayer){let i=r.get(this.game.harbormasterPlayer)??0;if(i>=3&&i>=t)return this.game.harbormasterPlayer}if(!(t<3))return o}};function Kl(e,r){return e.board.getKnightsByPlayer(r).filter(o=>o.status===ir.KNIGHT_STATUS_ACTIVE).reduce((o,i)=>o+i.strengthValue,0)}E(Kl,"getPlayerActiveKnightStrength");function XD(e){if(e.options.citiesAndKnights){let r=0,t;for(let o of e.turnOrder){let i=Kl(e,o);i>r&&(r=i,t=o)}return r>0?t:void 0}else{let r=0,t;for(let o of e.turnOrder){let n=e.getPlayerPublicState(o)?.playedKnights??0;n>r&&(r=n,t=o)}return r>0?t:void 0}}E(XD,"getTournamentWinner");function zD(e){if(e.options.citiesAndKnights){let r=0;for(let o of e.turnOrder){let i=Kl(e,o);i>r&&(r=i)}if(r===0)return;let t=[];for(let o of e.turnOrder)Kl(e,o)===r&&t.push(o);return t.length>1?void 0:t[0]}else{if(e.largestArmyPlayer)return e.largestArmyPlayer;let r=0;for(let o of e.turnOrder){let n=e.getPlayerPublicState(o)?.playedKnights??0;n>r&&(r=n)}if(r===0)return;let t=[];for(let o of e.turnOrder)(e.getPlayerPublicState(o)?.playedKnights??0)===r&&t.push(o);return t.length>1?void 0:t[0]}}E(zD,"getConflictStealer");function $D(e){let r=new Set;for(let n of e.board.ports)r.add(n.hex.toString());let t=new Map,o=0;for(let n of e.turnOrder){let a=0;for(let s of e.board.getSettlementsByPlayer(n)){let u=s.vertex.getHexCenters();for(let l of u)if(r.has(l.toString())){a+=1;break}}for(let s of e.board.getCitiesByPlayer(n)){let u=s.vertex.getHexCenters();for(let l of u)if(r.has(l.toString())){a+=2;break}}t.set(n,a),a>o&&(o=a)}if(o===0)return[];let i=[];for(let n of e.turnOrder)t.get(n)===o&&i.push(n);return i}E($D,"getCalmSeasWinners");function GN(e,r){let t=e.pendingAlchemist!==void 0?m(e,{pendingAlchemist:null}):e,o=QD(t,r);return t.options.turboMode?t.pendingSecondTurboRoll?m(o,{pendingSecondTurboRoll:!1,pendingDiceRoll:!1}):m(o,{pendingSecondTurboRoll:!0,pendingDiceRoll:!0}):o}E(GN,"applyRollDice");function QD(e,r){if(!r.dice)throw new Error("ROLL_DICE event must have dice");if(r.dice.hasEventCard)return jD(e,r,r.dice.eventCard);if(r.dice.total===7){if(e.options.citiesAndKnights){if(r.dice.eventDie===Ue.EVENT_DIE_RESULT_BARBARIAN_SHIP)return m(e,{dice:r.dice,pendingDiceRoll:!1});let o=Cn(e);return m(e,{dice:r.dice,pendingDiceRoll:!1,pendingDiscards:o,discardsWithoutRobber:!1,pendingRobberOrPiratePlacement:o.size===0&&e.board.canTriggerRobberPlacement?!0:void 0})}let t=Cn(e);return m(e,{dice:r.dice,pendingDiceRoll:!1,pendingDiscards:t,discardsWithoutRobber:!1,pendingRobberOrPiratePlacement:t.size===0&&e.board.canTriggerRobberPlacement?!0:void 0})}return m(e,{dice:r.dice,pendingDiceRoll:!1})}E(QD,"applyRollDiceInner");function jD(e,r,t){switch(t){case le.EVENT_CARD_ROBBER_ATTACKS:{let o=Cn(e);return m(e,{dice:r.dice,pendingDiceRoll:!1,pendingDiscards:o,discardsWithoutRobber:!1,pendingRobberOrPiratePlacement:o.size===0&&e.board.canTriggerRobberPlacement?!0:void 0})}case le.EVENT_CARD_EARTHQUAKE:{let o=[];for(let i of e.turnOrder)e.getEdgeBuildings().filter(a=>a.owner===i&&a.isRoad&&!a.isBrokenRoad).length>0&&o.push(i);return o.length>0?m(e,{dice:r.dice,pendingDiceRoll:!1,pendingEarthquake:o}):m(e,{dice:r.dice,pendingDiceRoll:!1})}case le.EVENT_CARD_PLENTIFUL_YEAR:{let o=ot(e);for(let i of e.turnOrder)o.set(i,(o.get(i)??0)+1);return m(e,{dice:r.dice,pendingDiceRoll:!1,pendingFreeResources:o})}case le.EVENT_CARD_GOOD_NEIGHBORS:{if(e.turnOrder.length<2)return m(e,{dice:r.dice,pendingDiceRoll:!1});let o=[];for(let i of e.turnOrder){let n=e.getPlayerPublicState(i);n&&n.cardCount>0&&o.push(i)}return o.length>0?m(e,{dice:r.dice,pendingDiceRoll:!1,pendingGoodNeighbors:o}):m(e,{dice:r.dice,pendingDiceRoll:!1})}case le.EVENT_CARD_HELPFUL_NEIGHBOR:{let o=Gl(e);return m(e,{dice:r.dice,pendingDiceRoll:!1,...o.length>0&&{pendingHelpfulNeighbors:o}})}case le.EVENT_CARD_TOURNAMENT:{let o=XD(e);if(o){let i=ot(e);return i.set(o,(i.get(o)??0)+1),m(e,{dice:r.dice,pendingDiceRoll:!1,pendingFreeResources:i})}return m(e,{dice:r.dice,pendingDiceRoll:!1})}case le.EVENT_CARD_CONFLICT:{let o=zD(e);return o&&e.turnOrder.some(n=>n!==o&&(e.getPlayerPublicState(n)?.cardCount??0)>0)?m(e,{dice:r.dice,pendingDiceRoll:!1,pendingEventCardSteal:o}):m(e,{dice:r.dice,pendingDiceRoll:!1})}case le.EVENT_CARD_TRADE_ADVANTAGE:{let o=e.longestRoadPlayer;return o&&e.turnOrder.some(n=>n!==o&&(e.getPlayerPublicState(n)?.cardCount??0)>0)?m(e,{dice:r.dice,pendingDiceRoll:!1,pendingEventCardSteal:o}):m(e,{dice:r.dice,pendingDiceRoll:!1})}case le.EVENT_CARD_CALM_SEAS:{let o=$D(e);if(o.length>0){let i=ot(e);for(let n of o)i.set(n,(i.get(n)??0)+1);return m(e,{dice:r.dice,pendingDiceRoll:!1,pendingFreeResources:i})}return m(e,{dice:r.dice,pendingDiceRoll:!1})}default:return m(e,{dice:r.dice,pendingDiceRoll:!1})}}E(jD,"applyEventCardEffect");function UN(e,r){let t=r.resources&&r.resources.size>0,o=r.commodities&&r.commodities.size>0;if(!t&&!o)return e;let i=new Map,n=new Map,a=0,s=0;t&&(i=Hl(e.resourceDeck,r.resources),a=Qe(i)),o&&e.options.citiesAndKnights&&(n=U_(e.commodityBank,r.commodities),s=Mr(n));let u=a+s;if(u===0)return e;let l=e.resourceDeck,c=e.commodityBank;a>0&&(l=Lt(e.resourceDeck,i)),s>0&&(c=pi(e.commodityBank,n));let f=e.getPlayerStates();e.hasPlayerState(r.player)&&(f=z(f,r.player,R=>{let O=R.toBuilder();return a>0&&(O=O.withHand($e(R.hand,i))),s>0&&(O=O.withCommodities(yr(R.commodities,n))),O.build()}));let T=Z(e.getPlayerPublicStates(),r.player,R=>R.toBuilder().withCardCount(R.cardCount+u).build());return m(e,{resourceDeck:l,commodityBank:c,playerStates:f,playerPublicStates:T})}E(UN,"applyReceiveResources");function BN(e,r){let t=m(e,{pendingResourceResolution:!1}),o=r.resourceDistribution;if(!o)return t;for(let i of o.playerProduction){let n=i.player,a=new Map,s=new Map;for(let g of i.hexProduction){for(let[k,v]of g.resources)v>0&&k!==S.RESOURCE_UNSPECIFIED&&a.set(k,(a.get(k)??0)+v);for(let[k,v]of g.commodities)v>0&&k!==j.COMMODITY_UNSPECIFIED&&s.set(k,(s.get(k)??0)+v)}let u=Hl(t.resourceDeck,a),l=U_(t.commodityBank,s),c=Qe(u),f=Mr(l),T=c+f;if(T===0)continue;let R=t.resourceDeck,O=t.commodityBank;c>0&&(R=Lt(t.resourceDeck,u)),f>0&&(O=pi(t.commodityBank,l));let I=t.getPlayerStates();t.hasPlayerState(n)&&(I=z(I,n,g=>{let k=g.toBuilder();return c>0&&(k=k.withHand($e(g.hand,u))),f>0&&(k=k.withCommodities(yr(g.commodities,l))),k.build()}));let D=Z(t.getPlayerPublicStates(),n,g=>g.toBuilder().withCardCount(g.cardCount+T).build());t=m(t,{resourceDeck:R,commodityBank:O,playerStates:I,playerPublicStates:D})}return t===e?m(e,{}):t}E(BN,"applyResourceDistribution");function kN(e,r){let t=r.resources??new Map,o=Qe(t),i=r.commodities?Mr(r.commodities):0,n=o+i,a=Pr(e.resourceDeck,t),s=e.commodityBank;r.commodities&&i>0&&(s=ns(e.commodityBank,r.commodities));let u=e.getPlayerStates();e.hasPlayerState(r.player)&&(u=z(u,r.player,I=>{let D=I.toBuilder().withHand(ke(I.hand,t));return r.commodities&&i>0&&(D=D.withCommodities(wr(I.commodities,r.commodities))),D.build()}));let l=Z(e.getPlayerPublicStates(),r.player,I=>I.toBuilder().withCardCount(Math.max(0,I.cardCount-n)).build()),c=MN(e),T=(c.get(r.player)??0)-n;T<=0?c.delete(r.player):c.set(r.player,T);let R=c.size===0,O=R&&!e.discardsWithoutRobber&&e.dice?.total===7&&e.board.canTriggerRobberPlacement;return m(e,{resourceDeck:a,commodityBank:s,playerStates:u,playerPublicStates:l,pendingDiscards:c,discardsWithoutRobber:R?!1:e.discardsWithoutRobber,pendingRobberOrPiratePlacement:O?!0:void 0,...r.rushNextDiceRollAt!==void 0&&r.rushNextDiceRollAt>0&&{rushNextDiceRollAt:r.rushNextDiceRollAt}})}E(kN,"applyDiscardResources");function Wl(e){if(!e.options.rushMode||!e.rushRobberPlayer)return e;let t=(e.turnOrder.indexOf(e.rushRobberPlayer)+1)%e.turnOrder.length;return m(e,{rushRobberPlayer:e.turnOrder[t]})}E(Wl,"advanceRushRobberPlayer");function $d(e,r,t){return e.getPlayersOnTile(r).some(o=>{if(o===t)return!1;let i=e.getPlayerState(o);if(i)return i.totalResourcesInHand+i.totalCommoditiesInHand>0;let n=e.getPlayerPublicState(o);return n!==void 0&&n.cardCount>0})}E($d,"hasStealableTargetsAt");function bN(e,r){if(!r.robberLocation)throw new Error("MOVE_ROBBER event must have robberLocation");let t=In(e.board.robbers,r.robberLocation),o=pe(e.board,{robbers:t});if(e.dice?.eventCard===le.EVENT_CARD_ROBBER_FLEES)return m(e,{board:o,pendingRobberOrPiratePlacement:!1,pendingRobberStealLocation:null});let i=m(e,{board:o}),n=$d(i,r.robberLocation,r.player)?r.robberLocation:void 0,a=e.pendingBishopSteal!==void 0,s=a&&e.options.rushMode;return m(e,{board:o,pendingRobberOrPiratePlacement:!1,pendingRobberStealLocation:n??null,...a?{pendingBishopSteal:null}:{},...s?{rushRobberPlayer:null}:{}})}E(bN,"applyMoveRobber");function vN(e,r){if(!r.targetPlayer)throw new Error("STEAL_RESOURCE event must have targetPlayer");let t=r.stolenResource,o=r.stolenCommodity,i=t?new Map([[t,1]]):void 0,n=o?new Map([[o,1]]):void 0,a=e.getPlayerStates();e.hasPlayerState(r.player)&&(a=z(a,r.player,u=>{let l=u.toBuilder();return i&&(l=l.withHand($e(u.hand,i))),n&&(l=l.withCommodities(yr(u.commodities,n))),l.build()})),e.hasPlayerState(r.targetPlayer)&&(a=z(a,r.targetPlayer,u=>{let l=u.toBuilder();return i&&(l=l.withHand(ke(u.hand,i))),n&&(l=l.withCommodities(wr(u.commodities,n))),l.build()}));let s=Z(e.getPlayerPublicStates(),r.player,u=>u.toBuilder().withCardCount(u.cardCount+1).build());return s=Z(s,r.targetPlayer,u=>u.toBuilder().withCardCount(Math.max(0,u.cardCount-1)).build()),m(e,{playerStates:a,playerPublicStates:s,pendingRobberStealLocation:null,...e.pendingEventCardSteal===r.player?{pendingEventCardSteal:null}:{}})}E(vN,"applyStealResource");function YN(e,r,t,o=[]){let i=e.filter(f=>f.owner===t);if(i.length===0)return 0;let n=new Map;for(let f of r)n.set(f.vertex.toString(),f);let a=new Map;for(let f of o)a.set(f.location.toString(),f.owner);let s=E(f=>{let T=n.get(f.toString());if(T!==void 0&&T.owner!==t)return!0;let R=a.get(f.toString());return R!==void 0&&R!==t},"vertexBreaksRoad"),u=new Map;for(let f of i)for(let T of[f.edge.v1,f.edge.v2]){let R=T.toString();u.has(R)||u.set(R,[]),u.get(R).push(f)}let l=E((f,T)=>{if(s(f))return 0;let R=0,O=u.get(f.toString())??[];for(let I of O){let D=I.edge.toString();if(T.has(D))continue;let g=I.edge.v1.equals(f)?I.edge.v2:I.edge.v1;T.add(D);let k=1+l(g,T);R=Math.max(R,k),T.delete(D)}return R},"dfs"),c=0;for(let f of i){let T=new Set([f.edge.toString()]),R=1+l(f.edge.v2,T);c=Math.max(c,R);let O=new Set([f.edge.toString()]),I=1+l(f.edge.v1,O);c=Math.max(c,I)}return c}E(YN,"calculateLongestRoadLength");function at(e,r,t,o=[]){return e.map(i=>{let n=YN(r,t,i.player,o);return i.toBuilder().withLongestRoadLength(n).build()})}E(at,"updateAllLongestRoadLengths");function st(e,r,t,o=[]){let i=new Set;for(let u of r)i.add(u.owner);let n=new Map;for(let u of i){let l=YN(r,t,u,o);n.set(u,l)}let a=4,s;for(let[u,l]of n)l>a&&(a=l,s=u);if(e.longestRoadPlayer){let u=n.get(e.longestRoadPlayer)??0;if(u>=5&&u>=a)return e.longestRoadPlayer}return a<5?null:s??null}E(st,"calculateLongestRoad");function FN(e,r){if(!r.edge)throw new Error("BUILD_ROAD event must have edge");let t=Md,o=e.getEdgeBuilding(r.edge),i;o?.isBrokenRoad?i=e.getEdgeBuildings().map(c=>c.edge.equals(r.edge)?new ar(r.edge,r.player,F.BUILDING_ROAD):c):i=[...e.getEdgeBuildings(),new ar(r.edge,r.player,F.BUILDING_ROAD)];let n=Pr(e.resourceDeck,t),a=e.getPlayerStates();e.hasPlayerState(r.player)&&(a=z(a,r.player,c=>c.toBuilder().withHand(ke(c.hand,t)).build()));let s=Z(e.getPlayerPublicStates(),r.player,c=>c.toBuilder().withCardCount(Math.max(0,c.cardCount-2)).build()),u=st(e,i,e.getVertexBuildings(),e.board.knights);s=at(s,i,e.getVertexBuildings(),e.board.knights);let l=pe(e.board,{edgeBuildings:i});return m(e,{board:l,resourceDeck:n,playerStates:a,playerPublicStates:s,activeTrades:[],longestRoadPlayer:u,incrementBuildingVersion:!0})}E(FN,"applyBuildRoad");function VN(e,r){if(!r.edge)throw new Error("BUILD_SHIP event must have edge");let t=Bd,o=[...e.getEdgeBuildings(),new ar(r.edge,r.player,F.BUILDING_SHIP)],i=Pr(e.resourceDeck,t),n=e.getPlayerStates();e.hasPlayerState(r.player)&&(n=z(n,r.player,l=>l.toBuilder().withHand(ke(l.hand,t)).build()));let a=Z(e.getPlayerPublicStates(),r.player,l=>l.toBuilder().withCardCount(Math.max(0,l.cardCount-2)).build()),s=st(e,o,e.getVertexBuildings(),e.board.knights);a=at(a,o,e.getVertexBuildings(),e.board.knights);let u=pe(e.board,{edgeBuildings:o});return m(e,{board:u,resourceDeck:i,playerStates:n,playerPublicStates:a,activeTrades:[],longestRoadPlayer:s,incrementBuildingVersion:!0,shipsBuiltThisTurn:[...e.shipsBuiltThisTurn,r.edge]})}E(VN,"applyBuildShip");function xN(e,r){if(!r.vertex)throw new Error("BUILD_SETTLEMENT event must have vertex");let t=Ld,o=[...e.getVertexBuildings(),new mr(r.vertex,r.player,F.BUILDING_SETTLEMENT)],i=Pr(e.resourceDeck,t),n=e.getPlayerStates();e.hasPlayerState(r.player)&&(n=z(n,r.player,f=>f.toBuilder().withHand(ke(f.hand,t)).build()));let a=Z(e.getPlayerPublicStates(),r.player,f=>f.toBuilder().withCardCount(Math.max(0,f.cardCount-4)).build()),s=st(e,e.getEdgeBuildings(),o,e.board.knights);a=at(a,e.getEdgeBuildings(),o,e.board.knights);let u=pe(e.board,{vertexBuildings:o}),l=m(e,{board:u,resourceDeck:i,playerStates:n,playerPublicStates:a,activeTrades:[],longestRoadPlayer:s,incrementBuildingVersion:!0});if(e.options.harbormaster){let f=new hi(l).calculateHarbormasterHolder();l=m(l,{harbormasterPlayer:f??null})}let c=l.recalculateAllPlayerVictoryPoints();return m(l,{playerPublicStates:c})}E(xN,"applyBuildSettlement");function wN(e,r){if(!r.vertex)throw new Error("BUILD_CITY event must have vertex");let t=e.isMedicineActive,o=t?Ud:Gd,i=t?3:5,n=e.getVertexBuildings().map(R=>R.vertex.equals(r.vertex)&&R.owner===r.player?new mr(R.vertex,R.owner,F.BUILDING_CITY):R),a=Pr(e.resourceDeck,o),s=e.getPlayerStates();e.hasPlayerState(r.player)&&(s=z(s,r.player,R=>R.toBuilder().withHand(ke(R.hand,o)).build()));let u=Z(e.getPlayerPublicStates(),r.player,R=>R.toBuilder().withCardCount(Math.max(0,R.cardCount-i)).build()),l=t?e.progressCardsInPlay.filter(R=>R!==6):e.progressCardsInPlay,c=pe(e.board,{vertexBuildings:n}),f=m(e,{board:c,resourceDeck:a,playerStates:s,playerPublicStates:u,activeTrades:[],progressCardsInPlay:l,incrementBuildingVersion:!0});if(e.options.harbormaster){let R=new hi(f).calculateHarbormasterHolder();f=m(f,{harbormasterPlayer:R??null})}let T=f.recalculateAllPlayerVictoryPoints();return m(f,{playerPublicStates:T})}E(wN,"applyBuildCity");function HN(e,r){let t=Wa,o=r.progressCardTrack,i=r.progressCard,n=Pr(e.resourceDeck,t),a=e.scienceProgressDeck,s=e.politicsProgressDeck,u=e.tradeProgressDeck;o===K.CITY_IMPROVEMENT_TRACK_SCIENCE?a=e.scienceProgressDeck.slice(1):o===K.CITY_IMPROVEMENT_TRACK_POLITICS?s=e.politicsProgressDeck.slice(1):o===K.CITY_IMPROVEMENT_TRACK_TRADE&&(u=e.tradeProgressDeck.slice(1));let l=e.getPlayerStates();e.hasPlayerState(r.player)&&(l=z(l,r.player,T=>{let R=T.toBuilder().withHand(ke(T.hand,t));return i&&!xr(i)&&R.addProgressCard(i,1),R.build()}));let c=Z(e.getPlayerPublicStates(),r.player,T=>{let R=T.toBuilder().withCardCount(Math.max(0,T.cardCount-3));return i&&xr(i)?R.addVictoryPointProgressCard(i).withProgressCardVp(T.victoryPointProgressCards.length+1):(R.withProgressCardCount(T.progressCardCount+1),o===K.CITY_IMPROVEMENT_TRACK_SCIENCE?R.withScienceProgressCardCount(T.scienceProgressCardCount+1):o===K.CITY_IMPROVEMENT_TRACK_POLITICS?R.withPoliticsProgressCardCount(T.politicsProgressCardCount+1):o===K.CITY_IMPROVEMENT_TRACK_TRADE&&R.withTradeProgressCardCount(T.tradeProgressCardCount+1)),R.build()}),f=m(e,{resourceDeck:n,scienceProgressDeck:a,politicsProgressDeck:s,tradeProgressDeck:u,playerStates:l,playerPublicStates:c,activeTrades:[]});if(i&&xr(i)){let T=f.recalculateAllPlayerVictoryPoints();f=m(f,{playerPublicStates:T})}return f}E(HN,"applyBuyProgressCard");function KN(e,r){let t=Wa,o=r.devCard,i=r.freeDevCard===!0,n=i?e.resourceDeck:Pr(e.resourceDeck,t),a=zd(e.devCardDeck,o),s=e.getPlayerStates();e.hasPlayerState(r.player)&&(s=z(s,r.player,l=>{let c=new Map(l.devCardsPurchasedThisTurn);o&&c.set(o,(c.get(o)??0)+1);let f=l.toBuilder().withDevCardsPurchasedThisTurn(c);return i||f.withHand(ke(l.hand,t)),f.build()}));let u=Z(e.getPlayerPublicStates(),r.player,l=>{let c=l.toBuilder().withUnplayedDevCardCount(l.unplayedDevCardCount+1);return i||c.withCardCount(Math.max(0,l.cardCount-3)),c.build()});return m(e,{resourceDeck:n,devCardDeck:a,playerStates:s,playerPublicStates:u,activeTrades:[]})}E(KN,"applyBuyDevCard");function WN(e,r,t){return r.hasPlayerState(t)?z(e,t,o=>{let i=new Map(o.unplayedDevCards);for(let[n,a]of o.devCardsPurchasedThisTurn)i.set(n,(i.get(n)??0)+a);return o.toBuilder().withUnplayedDevCards(i).withDevCardsPurchasedThisTurn(new Map).build()}):e}E(WN,"releaseDevCardsPurchasedThisTurn");function Jl(e,r){let t=e.board.knights.map(i=>i.resetTurnFlag());return{board:t.some((i,n)=>i!==e.board.knights[n])?e.board.toBuilder().withKnights(t).build():e.board,playerStates:WN(e.getPlayerStates(),e,r),activeTrades:[],playedDevCardThisTurn:!1,movedShipThisTurn:!1,shipsBuiltThisTurn:[],progressCardsInPlay:sN(e.progressCardsInPlay),merchantFleetResource:null,merchantFleetCommodity:null,smithFreePromotionsRemaining:0,tradesProposedThisTurn:0,tradesExecutedThisTurn:0,rejectedTradeOffers:[],goldSpentThisTurn:new Map}}E(Jl,"turnPassResets");function JN(e,r){let t=e.currentPlayer;if(e.turnOrder.length>0){let a=e.turnOrder.indexOf(e.currentPlayer);if(a===-1)t=e.turnOrder[0];else{let s=(a+1)%e.turnOrder.length;t=e.turnOrder[s]}}let o=e.timerState;if(e.options.timerConfig.isEnabled()&&e.timerState&&r.elapsedTimeMs!==void 0){o=e.timerState.clone();let a=o.getPlayerTimer(r.player);a&&(a.remainingTimeMs=Math.max(0,a.remainingTimeMs-r.elapsedTimeMs),a.clockStartedAt=0),e.options.timerConfig.isChessClock()&&(o.addIncrement(r.player,e.options.timerConfig),o.addIncrement(t,e.options.timerConfig));let s=o.getPlayerTimer(t);s&&(s.clockStartedAt=Date.now())}let i=e.winner;!i&&e.hasPlayerWon(r.player)&&(i=r.player);let n=e.turnNumber+1;if(!i&&e.options.winCondition===fr.WIN_CONDITION_TURN_LIMIT&&e.options.turnLimit>0&&n>=e.options.turnLimit){let a=-1;for(let s of e.turnOrder){let u=e.getTotalVictoryPoints(s);u>a&&(a=u,i=s)}}return m(e,{...Jl(e,r.player),pendingDiceRoll:!0,currentPlayer:t,turnNumber:e.turnNumber+1,timerState:o,winner:i})}E(JN,"applyEndTurn");function qN(e,r){if(!r.selectedResource)throw new Error("SELECT_FREE_RESOURCE event must have selectedResource");let t=ot(e),o=t.get(r.player)??0;if(o<=1?t.delete(r.player):t.set(r.player,o-1),e.getResourceCount(r.selectedResource)<=0)return m(e,{pendingFreeResources:t});let i=Lt(e.resourceDeck,new Map([[r.selectedResource,1]])),n=e.getPlayerStates();e.hasPlayerState(r.player)&&(n=z(n,r.player,s=>s.toBuilder().withHand($e(s.hand,new Map([[r.selectedResource,1]]))).build()));let a=Z(e.getPlayerPublicStates(),r.player,s=>s.toBuilder().withCardCount(s.cardCount+1).build());return m(e,{resourceDeck:i,playerStates:n,playerPublicStates:a,pendingFreeResources:t})}E(qN,"applySelectFreeResource");function ZN(e,r){if(!r.building)throw new Error("PLACE_FREE_STRUCTURE event must have building");let t=Kt(e),o=t.get(r.player)??[];o.length<=1?t.delete(r.player):t.set(r.player,o.slice(1));let i=e.getEdgeBuildings(),n=e.getVertexBuildings();if(r.building===F.BUILDING_ROAD||r.building===F.BUILDING_SHIP){if(!r.edge)throw new Error("PLACE_FREE_STRUCTURE for road/ship must have edge");let l=e.getEdgeBuilding(r.edge);l?.isBrokenRoad&&l.owner===r.player&&r.building===F.BUILDING_ROAD?i=i.map(c=>c.edge.equals(r.edge)?new ar(r.edge,r.player,F.BUILDING_ROAD):c):i=[...i,new ar(r.edge,r.player,r.building)]}else if(r.building===F.BUILDING_SETTLEMENT){if(!r.vertex)throw new Error("PLACE_FREE_STRUCTURE for settlement must have vertex");n=[...n,new mr(r.vertex,r.player,F.BUILDING_SETTLEMENT)]}else if(r.building===F.BUILDING_CITY){if(!r.vertex)throw new Error("PLACE_FREE_STRUCTURE for city must have vertex");n.find(c=>c.vertex.equals(r.vertex)&&c.owner===r.player)?n=n.map(c=>c.vertex.equals(r.vertex)&&c.owner===r.player?new mr(c.vertex,c.owner,F.BUILDING_CITY):c):n=[...n,new mr(r.vertex,r.player,F.BUILDING_CITY)]}let a=st(e,i,n,e.board.knights),s=at(e.getPlayerPublicStates(),i,n,e.board.knights),u=pe(e.board,{edgeBuildings:i,vertexBuildings:n});if(e.isSetupPhase&&(r.building===F.BUILDING_ROAD||r.building===F.BUILDING_SHIP)){let l=e.turnOrder.length*2,c=e.turnNumber+1;if(c>=l){let f=m(e,{board:u,pendingFreeStructures:t,longestRoadPlayer:a,playerPublicStates:s,currentPlayer:e.turnOrder[0],turnNumber:0,isSetupPhase:!1,pendingDiceRoll:!0,incrementBuildingVersion:!0}),T=f.recalculateAllPlayerVictoryPoints();return m(f,{playerPublicStates:T})}else{let f;if(c<e.turnOrder.length)f=e.turnOrder[c];else{let D=l-1-c;f=e.turnOrder[D]}let R=c>=e.turnOrder.length?e.options.secondFound:e.options.firstFound,O=t.get(f)??[];t.set(f,[...O,R]);let I=e.timerState;return e.options.timerConfig.isEnabled()&&e.timerState&&(I=za(e,e.currentPlayer,f)),m(e,{board:u,pendingFreeStructures:t,longestRoadPlayer:a,playerPublicStates:s,currentPlayer:f,turnNumber:c,timerState:I,incrementBuildingVersion:!0})}}return m(e,{board:u,pendingFreeStructures:t,longestRoadPlayer:a,playerPublicStates:s,incrementBuildingVersion:!0})}E(ZN,"applyPlaceFreeStructure");function XN(e,r){let t=Z(e.getPlayerPublicStates(),r.player,n=>n.toBuilder().withNewIslandSettlementCount(n.newIslandSettlementCount+1).build()),o=m(e,{playerPublicStates:t}),i=o.recalculateAllPlayerVictoryPoints();return m(o,{playerPublicStates:i})}E(XN,"applyNewIslandSettlement");function zN(e,r){if(!r.pairedPlayer)throw new Error("START_SECOND_SETTLER_TURN event must have pairedPlayer");return m(e,{...Jl(e,r.player),isSecondSettlerPhase:!0,secondSettlerPlayer:r.pairedPlayer})}E(zN,"applyStartSecondSettlerTurn");function $N(e,r){let t=e.currentPlayer;if(e.turnOrder.length>0){let a=e.turnOrder.indexOf(e.currentPlayer);if(a===-1)t=e.turnOrder[0];else{let s=(a+1)%e.turnOrder.length;t=e.turnOrder[s]}}let o=e.winner;o||(e.hasPlayerWon(e.currentPlayer)?o=e.currentPlayer:e.hasPlayerWon(r.player)&&(o=r.player));let i=e.turnNumber+1;if(!o&&e.options.winCondition===fr.WIN_CONDITION_TURN_LIMIT&&e.options.turnLimit>0&&i>=e.options.turnLimit){let a=-1;for(let s of e.turnOrder){let u=e.getTotalVictoryPoints(s);u>a&&(a=u,o=s)}}let n=e.options.timerConfig.isEnabled()&&e.timerState?za(e,r.player,t):e.timerState;return m(e,{...Jl(e,r.player),timerState:n,isSecondSettlerPhase:!1,secondSettlerPlayer:null,currentPlayer:t,turnNumber:e.turnNumber+1,pendingDiceRoll:!0,winner:o})}E($N,"applyEndSecondSettlerTurn");function QN(e,r){let t=r.player,o=r.targetPlayer,i=r.selectedResource,n=r.commodities&&r.commodities.size>0?Array.from(r.commodities.keys())[0]:void 0;if(!o)throw new Error("GIVE_EVENT_CARD_RESOURCE event must have targetPlayer");let a=e.getPlayerStates();if(i){let c=new Map([[i,1]]);e.hasPlayerState(t)&&(a=z(a,t,f=>f.toBuilder().withHand(ke(f.hand,c)).build())),e.hasPlayerState(o)&&(a=z(a,o,f=>f.toBuilder().withHand($e(f.hand,c)).build()))}else if(n){let c=new Map([[n,1]]);e.hasPlayerState(t)&&(a=z(a,t,f=>f.toBuilder().withCommodities(wr(f.commodities,c)).build())),e.hasPlayerState(o)&&(a=z(a,o,f=>f.toBuilder().withCommodities(yr(f.commodities,c)).build()))}let s=Z(e.getPlayerPublicStates(),t,c=>c.toBuilder().withCardCount(c.cardCount-1).build());s=Z(s,o,c=>c.toBuilder().withCardCount(c.cardCount+1).build());let u=e.pendingGoodNeighbors.filter(c=>c!==t),l=e.pendingHelpfulNeighbors.filter(c=>c!==t);return m(e,{playerStates:a,playerPublicStates:s,pendingGoodNeighbors:u,pendingHelpfulNeighbors:l})}E(QN,"applyGiveEventCardResource");function jN(e,r){let t=e.dice,o=t&&t.total===7?Wl(e).rushRobberPlayer:e.rushRobberPlayer,i=e.getPlayerStates();for(let n of e.turnOrder)i=WN(i,e,n);return m(e,{playerStates:i,currentPlayer:r.player,turnNumber:e.turnNumber+1,pendingDiceRoll:!0,activeTrades:[],playedDevCardThisTurn:!1,movedShipThisTurn:!1,shipsBuiltThisTurn:[],tradesProposedThisTurn:0,rejectedTradeOffers:[],goldSpentThisTurn:new Map,rushPlayedDevCard:new Set,rushDiceVotes:new Set,rushNextDiceRollAt:r.rushNextDiceRollAt,rushRobberPlayer:o,pendingRobberOrPiratePlacement:!1,pendingRobberStealLocation:null,pendingPirateStealLocation:null})}E(jN,"applyRushRoundStart");function eR(e){if(e.pendingFreeResources.size===0)return e;for(let r of e.resourceDeck.values())if(r>0)return e;return m(e,{pendingFreeResources:new Map})}E(eR,"clearUnselectableFreeResources");function rR(e){if(e.pendingFreeStructures.size===0)return e;let r=!1,t=new Map(e.pendingFreeStructures);for(let[o,i]of t){let n=0;for(;n<i.length&&!At(e,o,i[n]);)n++;if(n>0){r=!0;let a=i.slice(n);a.length===0?t.delete(o):t.set(o,a)}}return r?m(e,{pendingFreeStructures:t}):e}E(rR,"clearUnplaceableFreeStructures");function em(e,r,t){let o=r.find(s=>s.player===t);if(!o)return e.largestArmyPlayer;let i=o.playedDevCards.get(ie.DEV_CARD_KNIGHT)??0;if(i<3)return e.largestArmyPlayer;if(!e.largestArmyPlayer||e.largestArmyPlayer===t)return t;let a=r.find(s=>s.player===e.largestArmyPlayer)?.playedDevCards.get(ie.DEV_CARD_KNIGHT)??0;return i>a?t:e.largestArmyPlayer}E(em,"calculateLargestArmy");function tR(e,r){let t=e.getPlayerStates(),o=e.getPlayerPublicStates(),i=e.board,n=e.pendingRobberOrPiratePlacement;if(r.robberLocation){let c=In(e.board.robbers,r.robberLocation);i=pe(e.board,{robbers:c});let f=r.targetPlayer!==void 0&&!e.hasPlayerState(r.player)&&!e.hasPlayerState(r.targetPlayer),T=r.targetPlayer?e.getPlayerPublicState(r.targetPlayer)?.cardCount??0:0,R=r.stolenResource!==void 0||r.stolenCommodity!==void 0||f&&T>0;if(r.targetPlayer&&R){let O=r.stolenResource!==void 0&&r.stolenResource!==S.RESOURCE_UNSPECIFIED?r.stolenResource:void 0,I=O?new Map([[O,1]]):void 0;I&&e.hasPlayerState(r.player)&&(t=z(t,r.player,D=>D.toBuilder().withHand($e(D.hand,I)).build())),I&&e.hasPlayerState(r.targetPlayer)&&(t=z(t,r.targetPlayer,D=>D.toBuilder().withHand(ke(D.hand,I)).build())),o=Z(o,r.player,D=>D.toBuilder().withCardCount(D.cardCount+1).build()),o=Z(o,r.targetPlayer,D=>D.toBuilder().withCardCount(Math.max(0,D.cardCount-1)).build())}}else{let c=e.board.barbarians?.canMoveRobber()??!0;e.options.numberOfRobbers>0&&c&&(n=!0)}e.hasPlayerState(r.player)&&(t=z(t,r.player,c=>{let f=new Map(c.unplayedDevCards),T=f.get(ie.DEV_CARD_KNIGHT)??0;return T>1?f.set(ie.DEV_CARD_KNIGHT,T-1):f.delete(ie.DEV_CARD_KNIGHT),c.toBuilder().withUnplayedDevCards(f).build()})),o=Z(o,r.player,c=>{let f=new Map(c.playedDevCards);return f.set(ie.DEV_CARD_KNIGHT,(f.get(ie.DEV_CARD_KNIGHT)??0)+1),c.toBuilder().withUnplayedDevCardCount(Math.max(0,c.unplayedDevCardCount-1)).withPlayedDevCards(f).build()});let a=em(e,o,r.player),s=e.options.rushMode?new Set([...e.rushPlayedDevCard,r.player]):void 0,u=m(e,{board:i,playerStates:t,playerPublicStates:o,playedDevCardThisTurn:!0,activeTrades:[],largestArmyPlayer:a,pendingRobberOrPiratePlacement:n,rushPlayedDevCard:s}),l=u.recalculateAllPlayerVictoryPoints();return m(u,{playerPublicStates:l})}E(tR,"applyPlayKnight");function nR(e,r){let t=it(e),o=Kt(e),i=o.get(r.player)??[];o.set(r.player,[...i,t,t]);let n=e.getPlayerStates();e.hasPlayerState(r.player)&&(n=z(n,r.player,u=>{let l=new Map(u.unplayedDevCards),c=l.get(ie.DEV_CARD_ROAD_BUILDING)??0;return c>1?l.set(ie.DEV_CARD_ROAD_BUILDING,c-1):l.delete(ie.DEV_CARD_ROAD_BUILDING),u.toBuilder().withUnplayedDevCards(l).build()}));let a=Z(e.getPlayerPublicStates(),r.player,u=>{let l=new Map(u.playedDevCards);return l.set(ie.DEV_CARD_ROAD_BUILDING,(l.get(ie.DEV_CARD_ROAD_BUILDING)??0)+1),u.toBuilder().withUnplayedDevCardCount(Math.max(0,u.unplayedDevCardCount-1)).withPlayedDevCards(l).build()}),s=e.options.rushMode?new Set([...e.rushPlayedDevCard,r.player]):void 0;return m(e,{playerStates:n,playerPublicStates:a,playedDevCardThisTurn:!0,pendingFreeStructures:o,activeTrades:[],rushPlayedDevCard:s})}E(nR,"applyPlayRoadBuilding");function iR(e,r){let t=ot(e),o=t.get(r.player)??0;t.set(r.player,o+2);let i=e.getPlayerStates();e.hasPlayerState(r.player)&&(i=z(i,r.player,s=>{let u=new Map(s.unplayedDevCards),l=u.get(ie.DEV_CARD_YEAR_OF_PLENTY)??0;return l>1?u.set(ie.DEV_CARD_YEAR_OF_PLENTY,l-1):u.delete(ie.DEV_CARD_YEAR_OF_PLENTY),s.toBuilder().withUnplayedDevCards(u).build()}));let n=Z(e.getPlayerPublicStates(),r.player,s=>{let u=new Map(s.playedDevCards);return u.set(ie.DEV_CARD_YEAR_OF_PLENTY,(u.get(ie.DEV_CARD_YEAR_OF_PLENTY)??0)+1),s.toBuilder().withUnplayedDevCardCount(Math.max(0,s.unplayedDevCardCount-1)).withPlayedDevCards(u).build()}),a=e.options.rushMode?new Set([...e.rushPlayedDevCard,r.player]):void 0;return m(e,{playerStates:i,playerPublicStates:n,playedDevCardThisTurn:!0,pendingFreeResources:t,activeTrades:[],rushPlayedDevCard:a})}E(iR,"applyPlayYearOfPlenty");function oR(e,r){if(!r.monopolyResource||!r.monopolyResults)throw new Error("PLAY_MONOPOLY event must have monopolyResource and monopolyResults");let t=0;for(let a of r.monopolyResults)t+=a.count;let o=e.getPlayerStates();if(e.hasPlayerState(r.player)){let a=new Map([[r.monopolyResource,t]]);o=z(o,r.player,s=>{let u=new Map(s.unplayedDevCards),l=u.get(ie.DEV_CARD_MONOPOLY)??0;return l>1?u.set(ie.DEV_CARD_MONOPOLY,l-1):u.delete(ie.DEV_CARD_MONOPOLY),s.toBuilder().withHand($e(s.hand,a)).withUnplayedDevCards(u).build()})}for(let a of r.monopolyResults)if(e.hasPlayerState(a.player)){let s=new Map([[r.monopolyResource,a.count]]);o=z(o,a.player,u=>u.toBuilder().withHand(ke(u.hand,s)).build())}let i=e.getPlayerPublicStates();i=Z(i,r.player,a=>{let s=new Map(a.playedDevCards);return s.set(ie.DEV_CARD_MONOPOLY,(s.get(ie.DEV_CARD_MONOPOLY)??0)+1),a.toBuilder().withCardCount(a.cardCount+t).withUnplayedDevCardCount(Math.max(0,a.unplayedDevCardCount-1)).withPlayedDevCards(s).build()});for(let a of r.monopolyResults)i=Z(i,a.player,s=>s.toBuilder().withCardCount(Math.max(0,s.cardCount-a.count)).build());let n=e.options.rushMode?new Set([...e.rushPlayedDevCard,r.player]):void 0;return m(e,{playerStates:o,playerPublicStates:i,playedDevCardThisTurn:!0,activeTrades:[],rushPlayedDevCard:n})}E(oR,"applyPlayMonopoly");function aR(e,r){let t=e.getPlayerStates();e.hasPlayerState(r.player)&&(t=z(t,r.player,s=>{let u=new Map(s.unplayedDevCards),l=u.get(ie.DEV_CARD_VICTORY_POINT)??0;return l>1?u.set(ie.DEV_CARD_VICTORY_POINT,l-1):u.delete(ie.DEV_CARD_VICTORY_POINT),s.toBuilder().withUnplayedDevCards(u).build()}));let o=Z(e.getPlayerPublicStates(),r.player,s=>{let u=new Map(s.playedDevCards);return u.set(ie.DEV_CARD_VICTORY_POINT,(u.get(ie.DEV_CARD_VICTORY_POINT)??0)+1),s.toBuilder().withUnplayedDevCardCount(Math.max(0,s.unplayedDevCardCount-1)).withPlayedDevCards(u).build()}),i=e.options.rushMode?new Set([...e.rushPlayedDevCard,r.player]):void 0,n=m(e,{playerStates:t,playerPublicStates:o,playedDevCardThisTurn:!0,activeTrades:[],rushPlayedDevCard:i}),a=n.recalculateAllPlayerVictoryPoints();return m(n,{playerPublicStates:a})}E(aR,"applyPlayVictoryPoint");function sR(e,r){return Math.max(e.nextTradeId,...r.map(t=>t+1))}E(sR,"advanceNextTradeId");function _R(e,r){if(r.tradeId===void 0)throw new Error("PROPOSE_TRADE event must have tradeId");let t=r.offeredResources??new Map,o=r.receivedResources??new Map,i=(r.counterTradeId??0)>0,n=new Yn(r.tradeId,r.player,t,o,i?new Set([r.player]):new Set,new Set,r.offeredCommodities??new Map,r.receivedCommodities??new Map,r.offeredGold??0,r.receivedGold??0,r.counterTradeId??0),a=[...e.getActiveTrades(),n];return m(e,{activeTrades:a,tradesProposedThisTurn:i?e.tradesProposedThisTurn:e.tradesProposedThisTurn+1,nextTradeId:sR(e,[r.tradeId])})}E(_R,"applyProposeTrade");function dR(e,r){if(!r.tradeProposals||r.tradeProposals.length===0)throw new Error("PROPOSE_MULTI_TRADE event must have tradeProposals");let t=r.tradeProposals.map(i=>new Yn(i.tradeId,r.player,i.offering,i.requesting,new Set,new Set,i.offeringCommodities??new Map,i.requestingCommodities??new Map,i.offeringGold??0,i.requestingGold??0)),o=[...e.getActiveTrades(),...t];return m(e,{activeTrades:o,tradesProposedThisTurn:e.tradesProposedThisTurn+t.length,nextTradeId:sR(e,t.map(i=>i.id))})}E(dR,"applyProposeMultiTrade");function uR(e,r){if(r.tradeId===void 0)throw new Error("ACCEPT_TRADE event must have tradeId");let t=e.getActiveTrade(r.tradeId);if(!t)return e;let o=t.withPlayerAccepting(r.player),i=e.getActiveTrades().map(n=>n.id===r.tradeId?o:n);return m(e,{activeTrades:i})}E(uR,"applyAcceptTrade");function ER(e,r){if(r.tradeId===void 0)throw new Error("REJECT_TRADE event must have tradeId");let t=e.getActiveTrade(r.tradeId);if(!t)return e;let o=t.withPlayerRejecting(r.player),i=o.counterTradeId>0?e.getActiveTrade(o.counterTradeId):void 0,n=i?[i.proposer]:e.turnOrder.filter(u=>u!==o.proposer),a=n.length>0&&n.every(u=>o.rejectedPlayers.has(u)),s=a?e.getActiveTrades().filter(u=>u.id!==r.tradeId&&u.counterTradeId!==r.tradeId):e.getActiveTrades().map(u=>u.id===r.tradeId?o:u);return m(e,{activeTrades:s,...a&&{rejectedTradeOffers:Yl(e,o)}})}E(ER,"applyRejectTrade");function lR(e,r){if(r.tradeId===void 0)throw new Error("REVOKE_TRADE_ACCEPT event must have tradeId");let t=e.getActiveTrade(r.tradeId);if(!t)return e;let o=t.withPlayerRevoking(r.player),i=e.getActiveTrades().map(n=>n.id===r.tradeId?o:n);return m(e,{activeTrades:i})}E(lR,"applyRevokeTradeAccept");function cR(e,r){if(r.tradeId===void 0)throw new Error("CANCEL_TRADE event must have tradeId");let t=e.getActiveTrades().filter(n=>n.id!==r.tradeId&&n.counterTradeId!==r.tradeId),o=e.getActiveTrade(r.tradeId),i=o!==void 0&&r.player===o.proposer&&o.rejectedPlayers.size>0&&o.acceptingPlayers.size===0;return m(e,{activeTrades:t,...i&&{rejectedTradeOffers:Yl(e,o)}})}E(cR,"applyCancelTrade");function fR(e,r){if(r.tradeId===void 0||!r.tradePartner)throw new Error("EXECUTE_TRADE event must have tradeId and tradePartner");let t=e.getActiveTrade(r.tradeId);if(!t)throw new Error(`Trade ${r.tradeId} not found`);let o=t.counterTradeId>0&&r.player!==t.proposer,i=o?t.requesting:t.offering,n=o?t.offering:t.requesting,a=o?t.offering:t.requesting,s=o?t.requesting:t.offering,u=o?t.requestingCommodities:t.offeringCommodities,l=o?t.offeringCommodities:t.requestingCommodities,c=o?t.offeringCommodities:t.requestingCommodities,f=o?t.requestingCommodities:t.offeringCommodities,T=o?t.requestingGold:t.offeringGold,R=o?t.offeringGold:t.requestingGold,O=o?t.offeringGold:t.requestingGold,I=o?t.requestingGold:t.offeringGold,D=Qe(i)+Mr(u),g=Qe(n)+Mr(l),k=Qe(a)+Mr(c),v=Qe(s)+Mr(f),Y=e.getPlayerStates();e.hasPlayerState(r.player)&&(Y=z(Y,r.player,Fe=>{let He=Fe.toBuilder().withHand($e(ke(Fe.hand,i),n));return(u.size>0||l.size>0)&&(He=He.withCommodities(yr(wr(Fe.commodities,u),l))),(T>0||R>0)&&(He=He.withGold(Fe.gold-T+R)),He.build()})),e.hasPlayerState(r.tradePartner)&&(Y=z(Y,r.tradePartner,Fe=>{let He=Fe.toBuilder().withHand($e(ke(Fe.hand,a),s));return(c.size>0||f.size>0)&&(He=He.withCommodities(yr(wr(Fe.commodities,c),f))),(O>0||I>0)&&(He=He.withGold(Fe.gold-O+I)),He.build()}));let V=Z(e.getPlayerPublicStates(),r.player,Fe=>Fe.toBuilder().withCardCount(Fe.cardCount-D+g).withGold(Fe.gold-T+R).build());V=Z(V,r.tradePartner,Fe=>Fe.toBuilder().withCardCount(Fe.cardCount-k+v).withGold(Fe.gold-O+I).build());let w=Bl(e);function J(Fe){let He=0;for(let[Xr,Fr]of Fe){let Lr=w.get(Xr)?.scarcityWeight??1,Ln=Math.min(Lr,10);He+=Fr*Ln}return He}E(J,"valueResources");function $(Fe){let He=0;for(let[,Xr]of Fe)He+=Xr*1.5;return He}E($,"valueCommodities");let he=J(i)+$(u),De=J(a)+$(c),ve=Math.round((he-De)*100),Be=new Map(e.tradeBalance),Ye=`${r.player}-${r.tradePartner}`,Or=`${r.tradePartner}-${r.player}`;return Be.set(Ye,(Be.get(Ye)??0)+ve),Be.set(Or,(Be.get(Or)??0)-ve),m(e,{playerStates:Y,playerPublicStates:V,activeTrades:[],tradesProposedThisTurn:0,tradesExecutedThisTurn:e.tradesExecutedThisTurn+1,rejectedTradeOffers:[],tradeBalance:Be})}E(fR,"applyExecuteTrade");function TR(e,r){if(!r.tradePartner)throw new Error("TRADE_WITH_PLAYER event must have tradePartner");let t=r.offeredResources??new Map,o=r.receivedResources??new Map,i=Qe(t),n=Qe(o),a=e.getPlayerStates();e.hasPlayerState(r.player)&&(a=z(a,r.player,u=>u.toBuilder().withHand($e(ke(u.hand,t),o)).build())),e.hasPlayerState(r.tradePartner)&&(a=z(a,r.tradePartner,u=>u.toBuilder().withHand($e(ke(u.hand,o),t)).build()));let s=Z(e.getPlayerPublicStates(),r.player,u=>u.toBuilder().withCardCount(u.cardCount-i+n).build());return s=Z(s,r.tradePartner,u=>u.toBuilder().withCardCount(u.cardCount-n+i).build()),m(e,{playerStates:a,playerPublicStates:s})}E(TR,"applyTradeWithPlayer");function NR(e,r){let t=r.offeredResources??new Map,o=r.receivedResources??new Map,i=Qe(t),n=Qe(o),a=r.offeredCommodities?Mr(r.offeredCommodities):0,s=r.receivedCommodities?Mr(r.receivedCommodities):0,u=Pr(e.resourceDeck,t);u=Lt(u,o);let l=e.commodityBank;r.offeredCommodities&&r.offeredCommodities.size>0&&(l=ns(l,r.offeredCommodities)),r.receivedCommodities&&r.receivedCommodities.size>0&&(l=pi(l,r.receivedCommodities));let c=e.getPlayerStates();e.hasPlayerState(r.player)&&(c=z(c,r.player,O=>{let I=O.toBuilder().withHand($e(ke(O.hand,t),o));return(r.offeredCommodities&&r.offeredCommodities.size>0||r.receivedCommodities&&r.receivedCommodities.size>0)&&(I=I.withCommodities(yr(wr(O.commodities,r.offeredCommodities??new Map),r.receivedCommodities??new Map))),I.build()}));let f=i+a,T=n+s,R=Z(e.getPlayerPublicStates(),r.player,O=>O.toBuilder().withCardCount(O.cardCount-f+T).build());return m(e,{resourceDeck:u,commodityBank:l,playerStates:c,playerPublicStates:R})}E(NR,"applyTradeWithBank");function RR(e,r){if(r.targetPlayer===void 0)throw new Error("TRADE_EMBARGO event must have targetPlayer");let t=`${r.player}-${r.targetPlayer}`,o=new Set(e.tradeEmbargoes);return r.embargoActive?o.add(t):o.delete(t),m(e,{tradeEmbargoes:o})}E(RR,"applyTradeEmbargo");function AR(e,r){if(!r.shipFromEdge)throw new Error("MOVE_SHIP event must have shipFromEdge");if(!r.shipToEdge)throw new Error("MOVE_SHIP event must have shipToEdge");let o=[...e.getEdgeBuildings().filter(n=>!n.edge.equals(r.shipFromEdge)),new ar(r.shipToEdge,r.player,F.BUILDING_SHIP)],i=pe(e.board,{edgeBuildings:o});return m(e,{board:i,movedShipThisTurn:!0,incrementBuildingVersion:!0})}E(AR,"applyMoveShip");function SR(e,r){if(!r.pirateLocation)throw new Error("MOVE_PIRATE event must have pirateLocation");let t=yN(e.board,r.pirateLocation),o=m(e,{board:t}),a=o.getPlayersWithShipsAdjacentTo(r.pirateLocation).filter(s=>{if(s===r.player)return!1;let u=o.getPlayerPublicState(s);return u&&u.cardCount>0}).length>1?r.pirateLocation:void 0;return m(e,{board:t,pendingRobberOrPiratePlacement:!1,pendingPirateStealLocation:a??null})}E(SR,"applyMovePirate");function OR(e,r){if(!r.targetPlayer)throw new Error("STEAL_RESOURCE_PIRATE event must have targetPlayer");let t=r.stolenResource,o=r.stolenCommodity,i=t?new Map([[t,1]]):void 0,n=o?new Map([[o,1]]):void 0,a=e.getPlayerStates();e.hasPlayerState(r.player)&&(a=z(a,r.player,u=>{let l=u.toBuilder();return i&&(l=l.withHand($e(u.hand,i))),n&&(l=l.withCommodities(yr(u.commodities,n))),l.build()})),e.hasPlayerState(r.targetPlayer)&&(a=z(a,r.targetPlayer,u=>{let l=u.toBuilder();return i&&(l=l.withHand(ke(u.hand,i))),n&&(l=l.withCommodities(wr(u.commodities,n))),l.build()}));let s=Z(e.getPlayerPublicStates(),r.player,u=>u.toBuilder().withCardCount(u.cardCount+1).build());return s=Z(s,r.targetPlayer,u=>u.toBuilder().withCardCount(Math.max(0,u.cardCount-1)).build()),m(e,{playerStates:a,playerPublicStates:s,pendingPirateStealLocation:null})}E(OR,"applyStealResourcePirate");function IR(e,r){let t=r.freeResourceCount??0;if(t<=0)return e;let o=ot(e),i=o.get(r.player)??0;return o.set(r.player,i+t),m(e,{pendingFreeResources:o})}E(IR,"applyGoldProduced");function CR(e,r){if(!r.edge)throw new Error("COLLECT_EDGE_VP event must have edge");let t=pe(e.board,{edgeRewards:e.board.getEdgeRewards().filter(a=>!a.edge.equals(r.edge))}),o=Z(e.getPlayerPublicStates(),r.player,a=>a.toBuilder().withEdgeRewardVp(a.edgeRewardVp+1).build()),i=m(e,{board:t,playerPublicStates:o}),n=i.recalculateAllPlayerVictoryPoints();return m(i,{playerPublicStates:n})}E(CR,"applyCollectEdgeVp");function PR(e,r){if(!r.edge)throw new Error("COLLECT_EDGE_DEV_CARD event must have edge");let t=pe(e.board,{edgeRewards:e.board.getEdgeRewards().filter(s=>!s.edge.equals(r.edge))}),o=!!r.devCard,i=e.getPlayerStates();o&&e.hasPlayerState(r.player)&&(i=z(i,r.player,s=>{let u=new Map(s.devCardsPurchasedThisTurn),l=u.get(r.devCard)??0;return u.set(r.devCard,l+1),s.toBuilder().withDevCardsPurchasedThisTurn(u).build()}));let n=e.getPlayerPublicStates();o&&(n=Z(n,r.player,s=>s.toBuilder().withUnplayedDevCardCount(s.unplayedDevCardCount+1).build()));let a=o?zd(e.devCardDeck,r.devCard):e.devCardDeck;return m(e,{board:t,playerStates:i,playerPublicStates:n,devCardDeck:a})}E(PR,"applyCollectEdgeDevCard");function pR(e,r){if(!r.edge)throw new Error("COLLECT_EDGE_PORT event must have edge");let t=pe(e.board,{edgeRewards:e.board.getEdgeRewards().filter(o=>!o.edge.equals(r.edge))});return m(e,{board:t})}E(pR,"applyCollectEdgePort");function hR(e,r,t){let o=e.getPlayerStates();e.hasPlayerState(r)&&(o=z(o,r,n=>n.toBuilder().addHeldPort(t).build()));let i=Z(e.getPlayerPublicStates(),r,n=>n.toBuilder().withHeldPortCount(n.heldPortCount+1).build());return m(e,{playerStates:o,playerPublicStates:i})}E(hR,"applyHoldPort");function DR(e,r){if(!r.edge)throw new Error("PLACE_PORT event must have edge");if(!r.collectedPort)throw new Error("PLACE_PORT event must have collectedPort");let t=r.edge.getAdjacentCenters(),o=t[0];for(let f of t){let T=e.board.getTile(f);if(T&&T.terrain!==d.TERRAIN_SEA){o=f;break}}let i=new me(r.collectedPort.rate,r.collectedPort.resource,o,r.edge),n=[...e.board.ports,i],a=pe(e.board,{ports:n}),s=e.getPlayerStates(),u=e.getPlayerPublicState(r.player),l=u&&u.heldPortCount>0;l&&e.hasPlayerState(r.player)&&(s=z(s,r.player,f=>f.toBuilder().removeFirstHeldPort().build()));let c=e.getPlayerPublicStates();return l&&(c=Z(c,r.player,f=>f.toBuilder().withHeldPortCount(Math.max(0,f.heldPortCount-1)).build())),m(e,{board:a,playerStates:s,playerPublicStates:c})}E(DR,"applyPlacePort");function Di(e){let r=Cn(e);return r.size>0?m(e,{pendingDiscards:r,discardsWithoutRobber:!1,pendingResourceResolution:!1}):e.board.canTriggerRobberPlacement?m(e,{pendingRobberOrPiratePlacement:!0,pendingResourceResolution:!1}):e.pendingResourceResolution?m(e,{pendingResourceResolution:!1}):e}E(Di,"setupSevenRollPendingActions");function rm(e){let r=new Map;for(let t of e.turnOrder){if(t===e.currentPlayer)continue;let o=e.getPlayerPublicState(t)?.progressCardCount??0;o>xt&&r.set(t,o-xt)}return r}E(rm,"checkProgressCardOverLimit");function mR(e,r){return e}E(mR,"applyRollEventDie");function gR(e){let r=e.board.knights.filter(o=>o.isActive),t=new Map;for(let o of e.turnOrder){let n=r.filter(a=>a.owner===o).reduce((a,s)=>a+s.strengthValue,0);t.set(o,n)}return t}E(gR,"getPlayerKnightStrengths");function tm(e){let r=gR(e),t=0;for(let o of r.values())o>t&&(t=o);return t===0?[]:[...r.entries()].filter(([,o])=>o===t).map(([o])=>o)}E(tm,"getTiedStrongestDefenders");function yR(e,r){for(let t of r)if(Oi(e,t).length>1)return t}E(yR,"findNextPillagerNeedingChoice");function MR(e,r){if(r.barbarianPosition===void 0)throw new Error("Barbarian advance event must have barbarianPosition");if(!e.board.barbarians)throw new Error("Game must have barbarian state for barbarian advance");let t=new Nt(r.barbarianPosition,e.board.barbarians.hasAttacked),o=e.board.toBuilder().withBarbarians(t).build(),i=m(e,{board:o});return r.barbarianPosition<r_&&e.dice?.total===7&&(i=Di(i)),i}E(MR,"applyBarbarianAdvance");function LR(e,r){if(!e.board.barbarians)throw new Error("Game must have barbarian state for barbarian attack");let t=new Nt(0,!0),o=e.board.toBuilder().withBarbarians(t).build(),i=m(e,{board:o});if(r.barbarianVictory){let a=(r.pillagePlayers??c_(i,gR(i))).filter(u=>Oi(i,u).length>0);i=m(i,{pendingCityPillagePlayers:a});let s=yR(i,a);s!==void 0&&(i=m(i,{pendingCityPillage:s,pendingResourceResolution:!0}))}else{i.pendingCityPillagePlayers.length>0&&(i=m(i,{pendingCityPillagePlayers:[]}));let a=(r.barbarianStrength??0)>0?r.defenderPlayers??tm(e):[];a.length>1&&(i=m(i,{pendingDefenderSelection:a,pendingResourceResolution:!0}))}return i}E(LR,"applyBarbarianAttack");function GR(e,r){if(!r.pillagedCityLocation)throw new Error("City pillaged event must have pillagedCityLocation");let t=e.board.getVertexBuildings().find(O=>O.vertex.equals(r.pillagedCityLocation)&&O.isCity);if(!t)throw new Error("No city found at pillaged location");let o=t.owner,i=e.getSettlementsByPlayer(o),a=e.options.canBuildSettlement(i.length)?F.BUILDING_SETTLEMENT:F.BUILDING_BROKEN_CITY,s=e.board.getVertexBuildings().map(O=>O.vertex.equals(r.pillagedCityLocation)&&O.isCity?new mr(O.vertex,O.owner,a):O),u=e.board.cityWalls.filter(O=>!O.location.equals(r.pillagedCityLocation)),l=e.board.toBuilder().withVertexBuildings(s).withCityWalls(u).build(),c=m(e,{board:l,incrementBuildingVersion:!0}),f=c.recalculateAllPlayerVictoryPoints();if(c=m(c,{playerPublicStates:f}),c.options.harbormaster){let O=new hi(c).calculateHarbormasterHolder();c=m(c,{harbormasterPlayer:O??null})}let T=c.pendingCityPillagePlayers.filter(O=>O!==o&&Oi(c,O).length>0);c=m(c,{pendingCityPillagePlayers:T});let R=yR(c,T);if(R!==void 0)c=m(c,{pendingCityPillage:R});else{c=m(c,{pendingCityPillage:null});let O=T.length===0,I=c.dice?.total===7;O&&I&&(c=Di(c))}return c}E(GR,"applyCityPillaged");function UR(e,r){let t=Z(e.getPlayerPublicStates(),r.player,n=>n.toBuilder().withDefenderOfCatanVp(n.defenderOfCatanVp+1).build()),o=m(e,{playerPublicStates:t}),i=o.recalculateAllPlayerVictoryPoints();return m(o,{playerPublicStates:i})}E(UR,"applyDefenderOfCatan");function BR(e,r){let t=e;if(r.progressCard){let i=r.progressCard,n=xr(i),a=Rn(i);if(a===K.CITY_IMPROVEMENT_TRACK_SCIENCE?t=m(t,{scienceProgressDeck:t.scienceProgressDeck.slice(1)}):a===K.CITY_IMPROVEMENT_TRACK_POLITICS?t=m(t,{politicsProgressDeck:t.politicsProgressDeck.slice(1)}):a===K.CITY_IMPROVEMENT_TRACK_TRADE&&(t=m(t,{tradeProgressDeck:t.tradeProgressDeck.slice(1)})),n){let s=Z(t.getPlayerPublicStates(),r.player,l=>l.toBuilder().addVictoryPointProgressCard(i).withProgressCardVp(l.victoryPointProgressCards.length+1).build());t=m(t,{playerPublicStates:s});let u=t.recalculateAllPlayerVictoryPoints();t=m(t,{playerPublicStates:u})}else{let s=t.getPlayerState(r.player);if(!s)throw new Error(`No player state found for player ${r.player}`);let u=s.toBuilder().addProgressCard(i,1).build(),l=t.getPlayerStates().map(f=>f.player===r.player?u:f),c=Z(t.getPlayerPublicStates(),r.player,f=>{let T=f.toBuilder().withProgressCardCount(f.progressCardCount+1);return a===K.CITY_IMPROVEMENT_TRACK_SCIENCE?T.withScienceProgressCardCount(f.scienceProgressCardCount+1):a===K.CITY_IMPROVEMENT_TRACK_POLITICS?T.withPoliticsProgressCardCount(f.politicsProgressCardCount+1):a===K.CITY_IMPROVEMENT_TRACK_TRADE&&T.withTradeProgressCardCount(f.tradeProgressCardCount+1),T.build()});t=m(t,{playerStates:l,playerPublicStates:c})}}else{let i=Z(t.getPlayerPublicStates(),r.player,n=>{let a=n.toBuilder().withProgressCardCount(n.progressCardCount+1);return r.progressCardTrack===K.CITY_IMPROVEMENT_TRACK_SCIENCE?a.withScienceProgressCardCount(n.scienceProgressCardCount+1):r.progressCardTrack===K.CITY_IMPROVEMENT_TRACK_POLITICS?a.withPoliticsProgressCardCount(n.politicsProgressCardCount+1):r.progressCardTrack===K.CITY_IMPROVEMENT_TRACK_TRADE&&a.withTradeProgressCardCount(n.tradeProgressCardCount+1),a.build()});t=m(t,{playerPublicStates:i})}let o=t.pendingDefenderSelection.filter(i=>i!==r.player);if(t=m(t,{pendingDefenderSelection:o}),o.length===0){let i=rm(t);i.size>0?t=m(t,{pendingProgressCardDiscard:i}):t.dice?.total===7&&(t=Di(t))}return t}E(BR,"applyDrawProgressCard");function kR(e,r){if(r.barbarianStrength===void 0)throw new Error("AWAIT_KNIGHT_COMMITMENT event must have barbarianStrength");let t={barbarianStrength:r.barbarianStrength,committedKnights:[],currentPlayer:e.currentPlayer,playersCommitted:[]};return m(e,{pendingKnightCommitment:t})}E(kR,"applyAwaitKnightCommitment");function bR(e,r){let t=e.pendingKnightCommitment;if(!t)return e;let o=[...t.playersCommitted,r.player],i=r.committedKnights??(r.knightLocation?[r.knightLocation]:[]),n=[...t.committedKnights,...i],a=e.turnOrder.indexOf(t.currentPlayer),s;for(let u=1;u<=e.turnOrder.length;u++){let l=e.turnOrder[(a+u)%e.turnOrder.length];if(!o.includes(l)){s=l;break}}return s?m(e,{pendingKnightCommitment:{...t,committedKnights:n,currentPlayer:s,playersCommitted:o}}):m(e,{pendingKnightCommitment:null})}E(bR,"applyCommitKnightsToDefense");function vR(e,r){if(!r.knightLocation||!r.knightStrength)throw new Error("BUILD_KNIGHT event must have knightLocation and knightStrength");let t=bd,o=e.pendingKnights.findIndex(k=>k.player===r.player),i=o>=0,n=i?e.pendingKnights[o]:void 0,a=e.getPendingFreeStructures(r.player),s=!i&&a.includes(F.BUILDING_KNIGHT),u=i?n.strength:r.knightStrength,l=new jr(r.knightLocation,r.player,u,ir.KNIGHT_STATUS_INACTIVE,!1,!1),c=[...e.board.knights,l],f=e.board.toBuilder().withKnights(c).build(),T=e.getPlayerStates(),R=e.resourceDeck,O=e.getPlayerPublicStates(),I,D;if(i)D=[...e.pendingKnights],D.splice(o,1);else if(s){I=Kt(e);let k=I.get(r.player)??[],v=k.indexOf(F.BUILDING_KNIGHT);if(v>=0){let Y=[...k];Y.splice(v,1),Y.length===0?I.delete(r.player):I.set(r.player,Y)}}else e.hasPlayerState(r.player)&&(T=z(T,r.player,k=>k.toBuilder().withHand(ke(k.hand,t)).build())),R=Pr(e.resourceDeck,t),O=Z(O,r.player,k=>k.toBuilder().withCardCount(k.cardCount-2).build());let g=st(e,e.getEdgeBuildings(),e.getVertexBuildings(),c);return O=at(O,e.getEdgeBuildings(),e.getVertexBuildings(),c),m(e,{board:f,resourceDeck:R,playerStates:T,playerPublicStates:O,longestRoadPlayer:g,activeTrades:[],incrementBuildingVersion:!0,...I!==void 0?{pendingFreeStructures:I}:{},...D!==void 0?{pendingKnights:D}:{}})}E(vR,"applyBuildKnight");function YR(e,r){if(!r.knightLocation)throw new Error("ACTIVATE_KNIGHT event must have knightLocation");let t=vd,o=e.board.knights.map(u=>u.location.equals(r.knightLocation)&&u.owner===r.player?u.activate():u),i=e.board.toBuilder().withKnights(o).build(),n=e.getPlayerStates();e.hasPlayerState(r.player)&&(n=z(n,r.player,u=>u.toBuilder().withHand(ke(u.hand,t)).build()));let a=Pr(e.resourceDeck,t),s=Z(e.getPlayerPublicStates(),r.player,u=>u.toBuilder().withCardCount(u.cardCount-1).build());return m(e,{board:i,resourceDeck:a,playerStates:n,playerPublicStates:s,activeTrades:[],incrementBuildingVersion:!0})}E(YR,"applyActivateKnight");function FR(e,r){if(!r.knightLocation||!r.knightStrength)throw new Error("PROMOTE_KNIGHT event must have knightLocation and knightStrength");let t=Yd,o=e.smithFreePromotionsRemaining>0,i=e.board.knights.map(f=>f.location.equals(r.knightLocation)&&f.owner===r.player?f.with({strength:r.knightStrength,promotedThisTurn:!0}):f),n=e.board.toBuilder().withKnights(i).build(),a=e.getPlayerStates(),s=e.resourceDeck,u=e.getPlayerPublicStates();o||(e.hasPlayerState(r.player)&&(a=z(a,r.player,f=>f.toBuilder().withHand(ke(f.hand,t)).build())),s=Pr(e.resourceDeck,t),u=Z(e.getPlayerPublicStates(),r.player,f=>f.toBuilder().withCardCount(f.cardCount-2).build()));let l=e.smithFreePromotionsRemaining,c=e.progressCardsInPlay;return o&&(l--,l===0?c=c.filter(f=>f!==b.PROGRESS_CARD_SMITH):nm(i,r.player,e)||(l=0,c=c.filter(f=>f!==b.PROGRESS_CARD_SMITH))),m(e,{board:n,resourceDeck:s,playerStates:a,playerPublicStates:u,activeTrades:[],smithFreePromotionsRemaining:l,progressCardsInPlay:c,incrementBuildingVersion:!0})}E(FR,"applyPromoteKnight");function VR(e,r){if(!r.knightLocation||!r.knightDestination)throw new Error("MOVE_KNIGHT event must have knightLocation and knightDestination");let t=e.board.knights.map(a=>a.location.equals(r.knightLocation)&&a.owner===r.player?a.moveTo(r.knightDestination):a),o=e.board.toBuilder().withKnights(t).build(),i=st(e,e.getEdgeBuildings(),e.getVertexBuildings(),t),n=at(e.getPlayerPublicStates(),e.getEdgeBuildings(),e.getVertexBuildings(),t);return m(e,{board:o,playerPublicStates:n,longestRoadPlayer:i,activeTrades:[],incrementBuildingVersion:!0})}E(VR,"applyMoveKnight");function xR(e,r){if(!r.knightLocation||!r.knightDestination||!r.displacedKnightOwner)throw new Error("DISPLACE_KNIGHT event must have knightLocation, knightDestination, and displacedKnightOwner");let t=e.board.knights.find(u=>u.location.equals(r.knightDestination)&&u.owner===r.displacedKnightOwner),o=e.board.knights.filter(u=>!u.location.equals(r.knightDestination));o=o.map(u=>u.location.equals(r.knightLocation)&&u.owner===r.player?u.moveTo(r.knightDestination):u);let i;r.displacedKnightTo?t&&o.push(new jr(r.displacedKnightTo,r.displacedKnightOwner,t.strength,ir.KNIGHT_STATUS_INACTIVE,!1,!1)):t&&Ii(e,r.displacedKnightOwner,r.knightDestination).length>=1&&(i=[...e.pendingKnights,{player:r.displacedKnightOwner,strength:t.strength,status:ir.KNIGHT_STATUS_INACTIVE,fromVertex:r.knightDestination}]);let n=e.board.toBuilder().withKnights(o).build(),a=st(e,e.getEdgeBuildings(),e.getVertexBuildings(),o),s=at(e.getPlayerPublicStates(),e.getEdgeBuildings(),e.getVertexBuildings(),o);return m(e,{board:n,playerPublicStates:s,longestRoadPlayer:a,activeTrades:[],incrementBuildingVersion:!0,...i!==void 0?{pendingKnights:i}:{}})}E(xR,"applyDisplaceKnight");function wR(e,r){if(!r.knightLocation||!r.robberLocation)throw new Error("CHASE_ROBBER event must have knightLocation and robberLocation");let t=e.board.knights.map(a=>a.location.equals(r.knightLocation)&&a.owner===r.player?a.deactivate():a),o=In(e.board.robbers,r.robberLocation),i=e.board.toBuilder().withKnights(t).withRobbers(o).build(),n=$d(m(e,{board:i}),r.robberLocation,r.player)?r.robberLocation:void 0;return m(e,{board:i,pendingRobberStealLocation:n??null,activeTrades:[],incrementBuildingVersion:!0})}E(wR,"applyChaseRobber");function HR(e,r){if(!r.knightLocation||!r.robberLocation)throw new Error("USE_KNIGHT_ERRANT event must have knightLocation and robberLocation");let t=e.board.knights.map(a=>a.location.equals(r.knightLocation)&&a.owner===r.player?a.deactivate():a),o=In(e.board.robbers,r.robberLocation),i=e.board.toBuilder().withKnights(t).withRobbers(o).build(),n=$d(m(e,{board:i}),r.robberLocation,r.player)?r.robberLocation:void 0;return m(e,{board:i,pendingRobberStealLocation:n??null,activeTrades:[],incrementBuildingVersion:!0})}E(HR,"applyUseKnightErrant");function KR(e,r){let t=e.board.knights.map(n=>n.deactivate()),o=e.board.toBuilder().withKnights(t).build(),i=m(e,{board:o,incrementBuildingVersion:!0});return i.dice?.total===7&&i.pendingDefenderSelection.length===0&&i.pendingCityPillage===void 0&&i.pendingProgressCardDiscard.size===0&&i.pendingDiscards.size===0&&!i.pendingRobberOrPiratePlacement&&(i=Di(i)),i}E(KR,"applyKnightsDeactivated");function nm(e,r,t){return Dl(e,r,t).length>0}E(nm,"canAnyKnightBePromoted");function WR(e,r){let t=ot(e),o=t.get(r.player)??0;return t.set(r.player,o+1),m(e,{pendingFreeResources:t})}E(WR,"applyAqueductTriggered");function Qd(e,r,t){if(e.board.getMetropolisByTrack(t))return{type:"none"};let i=Ka(e,r);if(i.length===0)return{type:"none"};if(i.length===1){let n=new Yr(t,i[0].vertex,r);return{type:"auto",event:y.metropolisBuilt(r,n)}}return{type:"pending",pending:{player:r,track:t,isSteal:!1,stolenFrom:void 0}}}E(Qd,"checkMetropolisPlacement");function jd(e,r,t){let o=e.board.getMetropolisByTrack(t);if(!o){let a=Ka(e,r);if(a.length===0)return{type:"none"};if(a.length===1){let s=new Yr(t,a[0].vertex,r);return{type:"auto",event:y.metropolisBuilt(r,s)}}return{type:"pending",pending:{player:r,track:t,isSteal:!1,stolenFrom:void 0}}}if(o.owner===r)return{type:"none"};let i=e.getPlayerPublicState(o.owner);if(i&&(i.cityImprovements?.getLevel(t)??0)>=5)return{type:"none"};let n=Ka(e,r);if(n.length===0)return{type:"none"};if(n.length===1){let a=new Yr(t,n[0].vertex,r);return{type:"auto",event:y.metropolisTransferred(r,a,o.owner)}}return{type:"pending",pending:{player:r,track:t,isSteal:!0,stolenFrom:o.owner}}}E(jd,"checkMetropolisSteal");function qR(e,r){if(!r.vertex)throw new Error("Build city wall event must have a vertex");let t=r.vertex,o=r.player,i=e.progressCardsInPlay.includes(b.PROGRESS_CARD_ENGINEER),n=[...e.board.cityWalls,new un(t,o)],a=pe(e.board,{cityWalls:n}),s=i?e.progressCardsInPlay.filter(T=>T!==b.PROGRESS_CARD_ENGINEER):e.progressCardsInPlay,u=kd,l=e.getPlayerStates();!i&&e.hasPlayerState(o)&&(l=z(l,o,T=>T.toBuilder().withHand(ke(T.hand,u)).build()));let c=e.getPlayerPublicStates();i||(c=Z(c,o,T=>T.toBuilder().withCardCount(Math.max(0,T.cardCount-2)).build()));let f=i?e.resourceDeck:Pr(e.resourceDeck,u);return m(e,{board:a,resourceDeck:f,playerStates:l,playerPublicStates:c,progressCardsInPlay:s,activeTrades:[],incrementBuildingVersion:!0})}E(qR,"applyBuildCityWall");function ZR(e,r){if(!r.improvementTrack||!r.improvementLevel)throw new Error("Build city improvement event must have track and level");let t=e.getPlayerStates(),o=e.getPlayerPublicStates(),i=r.improvementLevel,n=e.isCraneActive,a=n?Math.max(0,i-1):i,s=LT(r.improvementTrack),u=new Map([[s,a]]),l=ns(e.commodityBank,u),c=n?e.progressCardsInPlay.filter(I=>I!==b.PROGRESS_CARD_CRANE):e.progressCardsInPlay;if(t.findIndex(I=>I.player===r.player)===-1){let I=Z(o,r.player,g=>{let v=(g.cityImprovements??Yt.createDefault()).improve(r.improvementTrack);return g.toBuilder().withCityImprovements(v).withCardCount(g.cardCount-a).build()}),D=m(e,{playerPublicStates:I,commodityBank:l,progressCardsInPlay:c});return JR(D,r)}let T=z(t,r.player,I=>{let D=new Map(I.commodities),g=D.get(s)??0;return D.set(s,Math.max(0,g-a)),I.toBuilder().withCommodities(D).build()}),R=Z(o,r.player,I=>{let g=(I.cityImprovements??Yt.createDefault()).improve(r.improvementTrack);return I.toBuilder().withCityImprovements(g).withCardCount(I.cardCount-a).build()}),O=m(e,{playerStates:T,playerPublicStates:R,progressCardsInPlay:c,commodityBank:l});return JR(O,r)}E(ZR,"applyBuildCityImprovement");function JR(e,r){if(r.improvementLevel===4){let t=Qd(e,r.player,r.improvementTrack);if(t.type==="pending")return m(e,{pendingMetropolisPlacement:t.pending})}else if(r.improvementLevel===5){let t=jd(e,r.player,r.improvementTrack);if(t.type==="pending")return m(e,{pendingMetropolisPlacement:t.pending})}return e}E(JR,"maybeSetPendingMetropolis");function XR(e,r){if(!r.metropolis)throw new Error("Metropolis built event must have metropolis");let t=[...e.board.metropolises,r.metropolis],o=Xd(e.board,t),i=m(e,{board:o,incrementBuildingVersion:!0}),n=i.recalculateAllPlayerVictoryPoints();return m(i,{playerPublicStates:n})}E(XR,"applyMetropolisBuilt");function zR(e,r){if(!r.metropolis)throw new Error("Metropolis transferred event must have metropolis");let t=e.board.metropolises.filter(a=>a.track!==r.metropolis.track);t.push(r.metropolis);let o=Xd(e.board,t),i=m(e,{board:o,incrementBuildingVersion:!0}),n=i.recalculateAllPlayerVictoryPoints();return m(i,{playerPublicStates:n})}E(zR,"applyMetropolisTransferred");function $R(e,r){if(!r.vertex)throw new Error("SELECT_METROPOLIS_CITY event must have vertex (city location)");if(!r.improvementTrack)throw new Error("SELECT_METROPOLIS_CITY event must have improvementTrack");let t=e.pendingMetropolisPlacement;if(!t)throw new Error("SELECT_METROPOLIS_CITY requires pendingMetropolisPlacement");if(r.player!==t.player)throw new Error(`SELECT_METROPOLIS_CITY player mismatch: expected ${t.player}, got ${r.player}`);let o=new Yr(t.track,r.vertex,r.player),i;t.isSteal&&t.stolenFrom?(i=e.board.metropolises.filter(u=>u.track!==t.track),i.push(o)):i=[...e.board.metropolises,o];let n=Xd(e.board,i),a=m(e,{board:n,pendingMetropolisPlacement:null,incrementBuildingVersion:!0}),s=a.recalculateAllPlayerVictoryPoints();return m(a,{playerPublicStates:s})}E($R,"applySelectMetropolisCity");function er(e,r,t){let o=e.getPlayerStates(),i=e.getPlayerPublicStates();e.hasPlayerState(r)&&(o=z(o,r,a=>{let s=new Map(a.progressCards),u=s.get(t)??0;return u>1?s.set(t,u-1):s.delete(t),a.toBuilder().withProgressCards(s).build()}));let n=Rn(t);return i=Z(i,r,a=>{let s=a.toBuilder().withProgressCardCount(Math.max(0,a.progressCardCount-1));return n===K.CITY_IMPROVEMENT_TRACK_SCIENCE?s.withScienceProgressCardCount(Math.max(0,a.scienceProgressCardCount-1)):n===K.CITY_IMPROVEMENT_TRACK_POLITICS?s.withPoliticsProgressCardCount(Math.max(0,a.politicsProgressCardCount-1)):n===K.CITY_IMPROVEMENT_TRACK_TRADE&&s.withTradeProgressCardCount(Math.max(0,a.tradeProgressCardCount-1)),s.build()}),{playerStates:o,playerPublicStates:i}}E(er,"removeProgressCardHelper");function QR(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_ENGINEER),i=[...e.progressCardsInPlay,b.PROGRESS_CARD_ENGINEER],n=je(e,b.PROGRESS_CARD_ENGINEER);return m(e,{playerStates:t,playerPublicStates:o,activeTrades:[],progressCardsInPlay:i,...n})}E(QR,"applyPlayEngineer");function jR(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_CRANE),i=[...e.progressCardsInPlay,b.PROGRESS_CARD_CRANE],n=je(e,b.PROGRESS_CARD_CRANE);return m(e,{playerStates:t,playerPublicStates:o,activeTrades:[],progressCardsInPlay:i,...n})}E(jR,"applyPlayCrane");function eA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_MEDICINE),i=[...e.progressCardsInPlay,b.PROGRESS_CARD_MEDICINE],n=je(e,b.PROGRESS_CARD_MEDICINE);return m(e,{playerStates:t,playerPublicStates:o,activeTrades:[],progressCardsInPlay:i,...n})}E(eA,"applyPlayMedicine");function rA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_ALCHEMIST),i=je(e,b.PROGRESS_CARD_ALCHEMIST);return m(e,{playerStates:t,playerPublicStates:o,pendingAlchemist:r.player,activeTrades:[],...i})}E(rA,"applyPlayAlchemist");function tA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_MINING),i=je(e,b.PROGRESS_CARD_MINING);if(!r.resources||Qe(r.resources)===0)return m(e,{playerStates:t,playerPublicStates:o,activeTrades:[],...i});let n=Qe(r.resources),a=Lt(e.resourceDeck,r.resources),s=t;e.hasPlayerState(r.player)&&(s=z(s,r.player,l=>l.toBuilder().withHand($e(l.hand,r.resources)).build()));let u=Z(o,r.player,l=>l.toBuilder().withCardCount(l.cardCount+n).build());return m(e,{resourceDeck:a,playerStates:s,playerPublicStates:u,activeTrades:[],...i})}E(tA,"applyPlayMining");function nA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_IRRIGATION),i=je(e,b.PROGRESS_CARD_IRRIGATION);if(!r.resources||Qe(r.resources)===0)return m(e,{playerStates:t,playerPublicStates:o,activeTrades:[],...i});let n=Qe(r.resources),a=Lt(e.resourceDeck,r.resources),s=t;e.hasPlayerState(r.player)&&(s=z(s,r.player,l=>l.toBuilder().withHand($e(l.hand,r.resources)).build()));let u=Z(o,r.player,l=>l.toBuilder().withCardCount(l.cardCount+n).build());return m(e,{resourceDeck:a,playerStates:s,playerPublicStates:u,activeTrades:[],...i})}E(nA,"applyPlayIrrigation");function iA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_ROAD_BUILDING),i=je(e,b.PROGRESS_CARD_ROAD_BUILDING),n=it(e),a=Kt(e),s=a.get(r.player)??[];return a.set(r.player,[...s,n,n]),m(e,{playerStates:t,playerPublicStates:o,pendingFreeStructures:a,activeTrades:[],...i})}E(iA,"applyPlayProgressRoadBuilding");function oA(e,r){if(!r.inventorHex1||!r.inventorHex2)throw new Error("PLAY_INVENTOR event must have inventorHex1 and inventorHex2");let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_INVENTOR),i=je(e,b.PROGRESS_CARD_INVENTOR),n=e.board.getTile(r.inventorHex1),a=e.board.getTile(r.inventorHex2);if(!n||!a)throw new Error("Invalid hex locations for Inventor");let s=new A(n.location,n.terrain,a.numbers),u=new A(a.location,a.terrain,n.numbers),l=e.board.getTiles().map(f=>f.location.equals(r.inventorHex1)?s:f.location.equals(r.inventorHex2)?u:f),c=pe(e.board,{tiles:l});return m(e,{board:c,playerStates:t,playerPublicStates:o,activeTrades:[],incrementMapVersion:!0,...i})}E(oA,"applyPlayInventor");function aA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_BISHOP),i=je(e,b.PROGRESS_CARD_BISHOP);if(!r.robberLocation)return m(e,{playerStates:t,playerPublicStates:o,activeTrades:[],...i,pendingBishopSteal:r.player,pendingRobberOrPiratePlacement:e.board.hasRobberOrPirate?!0:void 0,rushRobberPlayer:e.options.rushMode?r.player:e.rushRobberPlayer});let n=In(e.board.robbers,r.robberLocation),a=pe(e.board,{robbers:n});return m(e,{board:a,playerStates:t,playerPublicStates:o,activeTrades:[],...i})}E(aA,"applyPlayBishop");function sA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_WARLORD),i=je(e,b.PROGRESS_CARD_WARLORD),n=e.board.knights.map(s=>s.owner===r.player&&!s.isActive?s.activate():s),a=e.board.toBuilder().withKnights(n).build();return m(e,{board:a,playerStates:t,playerPublicStates:o,activeTrades:[],...i,incrementBuildingVersion:!0})}E(sA,"applyPlayWarlord");function _A(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_SMITH),i=je(e,b.PROGRESS_CARD_SMITH),n=[...e.progressCardsInPlay,b.PROGRESS_CARD_SMITH];return m(e,{playerStates:t,playerPublicStates:o,progressCardsInPlay:n,smithFreePromotionsRemaining:2,activeTrades:[],...i})}E(_A,"applyPlaySmith");function dA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_SABOTEUR),i=je(e,b.PROGRESS_CARD_SABOTEUR),n=e.getVisibleVictoryPoints(r.player),a=new Map;for(let s of e.getPlayerPublicStates()){if(s.player===r.player)continue;if(e.getVisibleVictoryPoints(s.player)>=n&&s.cardCount>0){let l=Math.floor(s.cardCount/2);l>0&&a.set(s.player,l)}}return m(e,{playerStates:t,playerPublicStates:o,pendingDiscards:a,discardsWithoutRobber:a.size>0,activeTrades:[],...i})}E(dA,"applyPlaySaboteur");function uA(e,r){let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_WEDDING),i=je(e,b.PROGRESS_CARD_WEDDING),n=e.getVisibleVictoryPoints(r.player),a=[];for(let s of e.getPlayerPublicStates()){if(s.player===r.player)continue;e.getVisibleVictoryPoints(s.player)>n&&s.cardCount>0&&a.push({player:s.player,weddingPlayer:r.player})}return m(e,{playerStates:t,playerPublicStates:o,pendingWeddingCards:a,activeTrades:[],...i})}E(uA,"applyPlayWedding");function EA(e,r){let t=e.pendingWeddingCards.find(f=>f.player===r.player);if(!t)throw new Error("No pending wedding cards entry for player");let o=t.weddingPlayer,i=r.player,n=0,a=0;r.resources&&(n=Qe(r.resources)),r.commodities&&(a=Mr(r.commodities));let s=n+a,u=e.getPlayerStates();e.hasPlayerState(i)&&(u=z(u,i,f=>{let T=f.toBuilder();return r.resources&&(T=T.withHand(ke(f.hand,r.resources))),r.commodities&&(T=T.withCommodities(wr(f.commodities,r.commodities))),T.build()})),e.hasPlayerState(o)&&(u=z(u,o,f=>{let T=f.toBuilder();return r.resources&&(T=T.withHand($e(f.hand,r.resources))),r.commodities&&(T=T.withCommodities(yr(f.commodities,r.commodities))),T.build()}));let l=Z(e.getPlayerPublicStates(),i,f=>f.toBuilder().withCardCount(Math.max(0,f.cardCount-s)).build());l=Z(l,o,f=>f.toBuilder().withCardCount(f.cardCount+s).build());let c=e.pendingWeddingCards.filter(f=>f.player!==i);return m(e,{playerStates:u,playerPublicStates:l,pendingWeddingCards:c,activeTrades:[]})}E(EA,"applyGiveWeddingCards");function lA(e,r){if(!r.targetPlayer)throw new Error("PLAY_DESERTER event must have targetPlayer");let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_DESERTER),i=je(e,b.PROGRESS_CARD_DESERTER);if(!r.knightLocation)return m(e,{playerStates:t,playerPublicStates:o,activeTrades:[],pendingDeserter:{deserterPlayer:r.player,targetPlayer:r.targetPlayer},...i});let n=e.board.getKnightAt(r.knightLocation);if(!n)throw new Error("No knight at the specified location");let a=e.board.knights.filter(c=>!c.location.equals(r.knightLocation)),s=pe(e.board,{knights:a}),u=fA(e,s,r.player,n.strength),l=u!==void 0?[...e.pendingKnights,{player:r.player,strength:u,status:ir.KNIGHT_STATUS_INACTIVE}]:e.pendingKnights;return m(e,{board:s,playerStates:t,playerPublicStates:o,activeTrades:[],pendingKnights:l,...i,incrementBuildingVersion:!0})}E(lA,"applyPlayDeserter");function cA(e,r){if(!r.knightLocation||!r.targetPlayer)throw new Error("SELECT_DESERTER_KNIGHT event must have knightLocation and targetPlayer (deserterPlayer)");let t=r.targetPlayer,o=e.board.getKnightAt(r.knightLocation);if(!o)throw new Error("No knight at the specified location");let i=e.board.knights.filter(u=>!u.location.equals(r.knightLocation)),n=pe(e.board,{knights:i}),a=fA(e,n,t,o.strength),s=a!==void 0?[...e.pendingKnights,{player:t,strength:a,status:ir.KNIGHT_STATUS_INACTIVE}]:e.pendingKnights;return m(e,{board:n,activeTrades:[],pendingKnights:s,pendingDeserter:null,incrementBuildingVersion:!0})}E(cA,"applySelectDeserterKnight");function fA(e,r,t,o){let i=e.getEdgeBuildingsByPlayer(t),n=!1;e:for(let l of i)for(let c of[l.edge.v1,l.edge.v2])if(!e.hasVertexBuilding(c)&&!r.hasKnight(c)){n=!0;break e}if(!n)return;let a=r.getKnightsByPlayer(t),s={[Pe.KNIGHT_STRENGTH_BASIC]:e.options.maxBasicKnights,[Pe.KNIGHT_STRENGTH_STRONG]:e.options.maxStrongKnights,[Pe.KNIGHT_STRENGTH_MIGHTY]:e.options.maxMightyKnights},u=o;for(;u!==void 0;){let l=a.filter(f=>f.strength===u).length,c=s[u]??0;if(l<c)return u;u=jr.getPreviousStrength(u)}}E(fA,"getEffectiveFreeKnightStrength");function TA(e,r){if(!r.edge||!r.targetPlayer)throw new Error("PLAY_DIPLOMAT event must have edge and targetPlayer");let o=e.board.getEdgeBuilding(r.edge)?.building??F.BUILDING_ROAD,{playerStates:i,playerPublicStates:n}=er(e,r.player,b.PROGRESS_CARD_DIPLOMAT),a=je(e,b.PROGRESS_CARD_DIPLOMAT),s=e.board.getEdgeBuildings().filter(T=>!T.edge.equals(r.edge)),u=pe(e.board,{edgeBuildings:s}),l=new Map(e.pendingFreeStructures);if(r.targetPlayer===r.player){let T=l.get(r.player)||[];l.set(r.player,[...T,o])}let c=st(e,s,e.getVertexBuildings(),e.board.knights),f=at(n,s,e.getVertexBuildings(),e.board.knights);return m(e,{board:u,playerStates:i,playerPublicStates:f,longestRoadPlayer:c,activeTrades:[],pendingFreeStructures:l,incrementBuildingVersion:!0,...a})}E(TA,"applyPlayDiplomat");function NA(e,r){if(!r.knightLocation||!r.displacedKnightOwner)throw new Error("PLAY_INTRIGUE event must have knightLocation and displacedKnightOwner");let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_INTRIGUE),i=je(e,b.PROGRESS_CARD_INTRIGUE);if(!e.board.getKnightAt(r.knightLocation))throw new Error("No knight at the specified location");let a;r.knightDestination?a=e.board.knights.map(c=>c.location.equals(r.knightLocation)?new jr(r.knightDestination,c.owner,c.strength,ir.KNIGHT_STATUS_INACTIVE,!1):c):a=e.board.knights.filter(c=>!c.location.equals(r.knightLocation));let s=pe(e.board,{knights:a}),u=st(e,e.getEdgeBuildings(),e.getVertexBuildings(),a),l=at(o,e.getEdgeBuildings(),e.getVertexBuildings(),a);return m(e,{board:s,playerStates:t,playerPublicStates:l,longestRoadPlayer:u,activeTrades:[],incrementBuildingVersion:!0,...i})}E(NA,"applyPlayIntrigue");function RA(e,r){if(!r.targetPlayer)throw new Error("PLAY_SPY event must have targetPlayer");let t=e.pendingSpyTarget===void 0,o=e.getPlayerStates(),i=e.getPlayerPublicStates(),n={};if(t&&({playerStates:o,playerPublicStates:i}=er(e,r.player,b.PROGRESS_CARD_SPY),n=je(e,b.PROGRESS_CARD_SPY)),r.progressCard||r.progressCardTrack){r.progressCard&&(e.hasPlayerState(r.targetPlayer)&&(o=z(o,r.targetPlayer,T=>{let R=new Map(T.progressCards),O=R.get(r.progressCard)??0;return O<=1?R.delete(r.progressCard):R.set(r.progressCard,O-1),T.toBuilder().withProgressCards(R).build()})),e.hasPlayerState(r.player)&&(o=z(o,r.player,T=>{let R=new Map(T.progressCards);return R.set(r.progressCard,(R.get(r.progressCard)??0)+1),T.toBuilder().withProgressCards(R).withSpyVisibleProgressCards(new Map).build()})));let c=r.progressCardTrack;i=Z(i,r.targetPlayer,T=>{let R=T.toBuilder().withProgressCardCount(T.progressCardCount-1);return c===K.CITY_IMPROVEMENT_TRACK_SCIENCE?R.withScienceProgressCardCount(Math.max(0,T.scienceProgressCardCount-1)):c===K.CITY_IMPROVEMENT_TRACK_POLITICS?R.withPoliticsProgressCardCount(Math.max(0,T.politicsProgressCardCount-1)):c===K.CITY_IMPROVEMENT_TRACK_TRADE&&R.withTradeProgressCardCount(Math.max(0,T.tradeProgressCardCount-1)),R.build()}),i=Z(i,r.player,T=>{let R=T.toBuilder().withProgressCardCount(T.progressCardCount+1);return c===K.CITY_IMPROVEMENT_TRACK_SCIENCE?R.withScienceProgressCardCount(T.scienceProgressCardCount+1):c===K.CITY_IMPROVEMENT_TRACK_POLITICS?R.withPoliticsProgressCardCount(T.politicsProgressCardCount+1):c===K.CITY_IMPROVEMENT_TRACK_TRADE&&R.withTradeProgressCardCount(T.tradeProgressCardCount+1),R.build()});let f=e.progressCardsInPlay.filter(T=>T!==b.PROGRESS_CARD_SPY);return m(e,{playerStates:o,playerPublicStates:i,pendingSpyTarget:null,progressCardsInPlay:f,activeTrades:[],...n})}let a=o.find(c=>c.player===r.targetPlayer),s=r.spyVisibleProgressCards??(a?new Map(a.progressCards):new Map);if(e.hasPlayerState(r.player)&&(o=z(o,r.player,c=>c.toBuilder().withSpyVisibleProgressCards(s).build())),![...s.values()].some(c=>c>0))return m(e,{playerStates:o,playerPublicStates:i,pendingSpyTarget:null,activeTrades:[],...n});let l=[...e.progressCardsInPlay,b.PROGRESS_CARD_SPY];return m(e,{playerStates:o,playerPublicStates:i,pendingSpyTarget:r.targetPlayer,progressCardsInPlay:l,activeTrades:[],...n})}E(RA,"applyPlaySpy");function AA(e,r){let o=(e.getPlayerPublicState(r.player)?.progressCardCount??0)-xt;if(o<=0)return e;let i=wl(e);return i.set(r.player,o),m(e,{pendingProgressCardDiscard:i})}E(AA,"applyProgressCardDiscardRequired");function SA(e,r){if(!r.progressCard)throw new Error("DISCARD_PROGRESS_CARD event must have progressCard");let t=r.progressCard,{playerStates:o,playerPublicStates:i}=er(e,r.player,t),n=je(e,t),a=wl(e),u=(a.get(r.player)??0)-1;u<=0?a.delete(r.player):a.set(r.player,u);let l=m(e,{playerStates:o,playerPublicStates:i,...n,pendingProgressCardDiscard:a});return a.size===0&&l.pendingResourceResolution&&l.dice?.total===7&&(l=Di(l)),l}E(SA,"applyDiscardProgressCard");function OA(e,r){if(!r.monopolyResource||!r.monopolyResults)throw new Error("PLAY_RESOURCE_MONOPOLY event must have monopolyResource and monopolyResults");let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_RESOURCE_MONOPOLY),i=je(e,b.PROGRESS_CARD_RESOURCE_MONOPOLY),n=0;for(let u of r.monopolyResults)n+=u.count;let a=t;if(e.hasPlayerState(r.player)){let u=new Map([[r.monopolyResource,n]]);a=z(a,r.player,l=>l.toBuilder().withHand($e(l.hand,u)).build())}for(let u of r.monopolyResults)if(e.hasPlayerState(u.player)){let l=new Map([[r.monopolyResource,u.count]]);a=z(a,u.player,c=>c.toBuilder().withHand(ke(c.hand,l)).build())}let s=o;s=Z(s,r.player,u=>u.toBuilder().withCardCount(u.cardCount+n).build());for(let u of r.monopolyResults)s=Z(s,u.player,l=>l.toBuilder().withCardCount(Math.max(0,l.cardCount-u.count)).build());return m(e,{playerStates:a,playerPublicStates:s,activeTrades:[],...i})}E(OA,"applyPlayResourceMonopoly");function IA(e,r){if(!r.tradeMonopolyCommodity||!r.monopolyResults)throw new Error("PLAY_TRADE_MONOPOLY event must have tradeMonopolyCommodity and monopolyResults");let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_TRADE_MONOPOLY),i=je(e,b.PROGRESS_CARD_TRADE_MONOPOLY),n=0;for(let u of r.monopolyResults)n+=u.count;let a=t;e.hasPlayerState(r.player)&&(a=z(a,r.player,u=>{let l=new Map(u.commodities);return l.set(r.tradeMonopolyCommodity,(l.get(r.tradeMonopolyCommodity)??0)+n),u.toBuilder().withCommodities(l).build()}));for(let u of r.monopolyResults)e.hasPlayerState(u.player)&&(a=z(a,u.player,l=>{let c=new Map(l.commodities),T=(c.get(r.tradeMonopolyCommodity)??0)-u.count;return T<=0?c.delete(r.tradeMonopolyCommodity):c.set(r.tradeMonopolyCommodity,T),l.toBuilder().withCommodities(c).build()}));let s=o;s=Z(s,r.player,u=>u.toBuilder().withCardCount(u.cardCount+n).build());for(let u of r.monopolyResults)s=Z(s,u.player,l=>l.toBuilder().withCardCount(Math.max(0,l.cardCount-u.count)).build());return m(e,{playerStates:a,playerPublicStates:s,activeTrades:[],...i})}E(IA,"applyPlayTradeMonopoly");function CA(e,r){if(!r.merchantLocation)throw new Error("PLAY_MERCHANT_CARD event must have merchantLocation");let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_MERCHANT),i=je(e,b.PROGRESS_CARD_MERCHANT),n=new Ti(r.merchantLocation,r.player),a=pe(e.board,{merchant:n});return m(e,{board:a,playerStates:t,playerPublicStates:o,activeTrades:[],...i})}E(CA,"applyPlayMerchantCard");function PA(e,r){if(!r.merchantFleetResource&&!r.merchantFleetCommodity)throw new Error("PLAY_MERCHANT_FLEET event must have merchantFleetResource or merchantFleetCommodity");let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_MERCHANT_FLEET),i=je(e,b.PROGRESS_CARD_MERCHANT_FLEET),n=[...e.progressCardsInPlay,b.PROGRESS_CARD_MERCHANT_FLEET];return m(e,{playerStates:t,playerPublicStates:o,activeTrades:[],progressCardsInPlay:n,merchantFleetResource:r.merchantFleetResource,merchantFleetCommodity:r.merchantFleetCommodity,...i})}E(PA,"applyPlayMerchantFleet");function pA(e,r){if(!r.commercialHarborTrades)throw new Error("PLAY_COMMERCIAL_HARBOR event must have commercialHarborTrades");let{playerStates:t,playerPublicStates:o}=er(e,r.player,b.PROGRESS_CARD_COMMERCIAL_HARBOR),i=je(e,b.PROGRESS_CARD_COMMERCIAL_HARBOR),n=[];for(let[s,u]of r.commercialHarborTrades)n.push({opponent:s,harborPlayer:r.player,resource:u});let a=n.length>0?[...e.progressCardsInPlay,b.PROGRESS_CARD_COMMERCIAL_HARBOR]:e.progressCardsInPlay;return m(e,{playerStates:t,playerPublicStates:o,pendingCommercialHarborExchanges:n,activeTrades:[],progressCardsInPlay:a,...i})}E(pA,"applyPlayCommercialHarbor");function hA(e,r){if(!r.targetPlayer)throw new Error("COMMERCIAL_HARBOR_TRADE_CANCELLED event must have targetPlayer (opponent)");let t=e.pendingCommercialHarborExchanges.filter(i=>!(i.opponent===r.targetPlayer&&i.harborPlayer===r.player)),o=e.progressCardsInPlay;return t.length===0&&(o=o.filter(i=>i!==b.PROGRESS_CARD_COMMERCIAL_HARBOR)),m(e,{pendingCommercialHarborExchanges:t,progressCardsInPlay:o})}E(hA,"applyCommercialHarborTradeCancelled");function DA(e,r){if(!r.targetPlayer)throw new Error("COMMERCIAL_HARBOR_EXCHANGE event must have targetPlayer (opponent)");if(!e.pendingCommercialHarborExchanges.find(l=>l.opponent===r.targetPlayer&&l.harborPlayer===r.player))throw new Error("No pending Commercial Harbor exchange for this opponent");let o=r.player,i=r.targetPlayer,n=e.getPlayerStates(),a=e.getPlayerPublicStates();r.commodities&&r.resources&&Mr(r.commodities)>0&&Qe(r.resources)>0&&(e.hasPlayerState(i)&&(n=z(n,i,l=>l.toBuilder().withCommodities(wr(l.commodities,r.commodities)).build())),e.hasPlayerState(o)&&(n=z(n,o,l=>l.toBuilder().withHand(ke(l.hand,r.resources)).build())),e.hasPlayerState(i)&&(n=z(n,i,l=>l.toBuilder().withHand($e(l.hand,r.resources)).build())),e.hasPlayerState(o)&&(n=z(n,o,l=>l.toBuilder().withCommodities(yr(l.commodities,r.commodities)).build())));let s=e.pendingCommercialHarborExchanges.filter(l=>!(l.opponent===r.targetPlayer&&l.harborPlayer===r.player)),u=e.progressCardsInPlay;return s.length===0&&(u=u.filter(l=>l!==b.PROGRESS_CARD_COMMERCIAL_HARBOR)),m(e,{playerStates:n,playerPublicStates:a,pendingCommercialHarborExchanges:s,progressCardsInPlay:u})}E(DA,"applyCommercialHarborExchange");function mA(e,r){if(!r.targetPlayer)throw new Error("PLAY_MASTER_MERCHANT event must have targetPlayer");let t=e.masterMerchantTarget===void 0,o=e.getPlayerStates(),i=e.getPlayerPublicStates(),n={};if(t&&({playerStates:o,playerPublicStates:i}=er(e,r.player,b.PROGRESS_CARD_MASTER_MERCHANT),n=je(e,b.PROGRESS_CARD_MASTER_MERCHANT)),r.resources||r.commodities){let c=r.resources??new Map,f=r.commodities??new Map;e.hasPlayerState(r.targetPlayer)&&(o=z(o,r.targetPlayer,O=>{let I=new Map(O.hand),D=new Map(O.commodities);for(let[g,k]of c){let v=I.get(g)??0;v<=k?I.delete(g):I.set(g,v-k)}for(let[g,k]of f){let v=D.get(g)??0;v<=k?D.delete(g):D.set(g,v-k)}return O.toBuilder().withHand(I).withCommodities(D).build()})),e.hasPlayerState(r.player)&&(o=z(o,r.player,O=>{let I=new Map(O.hand),D=new Map(O.commodities);for(let[g,k]of c)I.set(g,(I.get(g)??0)+k);for(let[g,k]of f)D.set(g,(D.get(g)??0)+k);return O.toBuilder().withHand(I).withCommodities(D).withMasterMerchantResources(new Map).withMasterMerchantCommodities(new Map).build()}));let T=Array.from(c.values()).reduce((O,I)=>O+I,0)+Array.from(f.values()).reduce((O,I)=>O+I,0);i=Z(i,r.targetPlayer,O=>O.toBuilder().withCardCount(O.cardCount-T).build()),i=Z(i,r.player,O=>O.toBuilder().withCardCount(O.cardCount+T).build());let R=e.progressCardsInPlay.filter(O=>O!==b.PROGRESS_CARD_MASTER_MERCHANT);return m(e,{playerStates:o,playerPublicStates:i,masterMerchantTarget:null,progressCardsInPlay:R,activeTrades:[],...n})}let a=o.find(c=>c.player===r.targetPlayer),s=r.masterMerchantResources??(a?new Map(a.hand):new Map),u=r.masterMerchantCommodities??(a?new Map(a.commodities):new Map);e.hasPlayerState(r.player)&&(o=z(o,r.player,c=>c.toBuilder().withMasterMerchantResources(s).withMasterMerchantCommodities(u).build()));let l=[...e.progressCardsInPlay,b.PROGRESS_CARD_MASTER_MERCHANT];return m(e,{playerStates:o,playerPublicStates:i,masterMerchantTarget:r.targetPlayer,progressCardsInPlay:l,activeTrades:[],...n})}E(mA,"applyPlayMasterMerchant");function gA(e,r){if(!r.commodities)throw new Error("RECEIVE_COMMODITIES event must have commodities");let t=U_(e.commodityBank,r.commodities),o=Mr(t);if(o===0)return e;let i=pi(e.commodityBank,t),n=e.getPlayerStates();e.hasPlayerState(r.player)&&(n=z(n,r.player,s=>s.toBuilder().withCommodities(yr(s.commodities,t)).build()));let a=Z(e.getPlayerPublicStates(),r.player,s=>s.toBuilder().withCardCount(s.cardCount+o).build());return m(e,{commodityBank:i,playerStates:n,playerPublicStates:a})}E(gA,"applyReceiveCommodities");function yA(e,r){let t=r.targetPlayer;return m(e,{oldBoot:t})}E(yA,"applyPassOldBoot");function MA(e,r){if(!r.fishTiles)throw new Error("RECEIVE_FISH event must have fishTiles");let t=r.player,o=r.fishTiles,i=e.getPlayerState(t);if(!i){let I=0;for(let[k,v]of o)k!==Se.FISH_OLD_BOOT&&(I+=v);let D=(o.get(Se.FISH_OLD_BOOT)??0)>0,g=Z(e.getPlayerPublicStates(),t,k=>k.toBuilder().withFishTileCount(k.fishTileCount+I).build());return m(e,{playerPublicStates:g,oldBoot:D?t:e.oldBoot})}let n=(o.get(Se.FISH_OLD_BOOT)??0)>0,a=new Map(o);n&&a.delete(Se.FISH_OLD_BOOT);let s=Za(Array.from(i.fishTiles.entries()).map(([I,D])=>({fish:I,count:D})),Array.from(a.entries()).map(([I,D])=>({fish:I,count:D}))),u=new Map(s.map(I=>[I.fish,I.count])),l=i.toBuilder().withFishTiles(u).build(),c=e.getPlayerStates().map(I=>I.player===t?l:I),f=O_(s),T=Z(e.getPlayerPublicStates(),t,I=>I.toBuilder().withFishTileCount(f).build()),R=Xa(Array.from(e.fishBank.entries()).map(([I,D])=>({fish:I,count:D})),Array.from(o.entries()).map(([I,D])=>({fish:I,count:D})));if(!R)throw new Error("Insufficient fish in bank");let O=n?t:e.oldBoot;return m(e,{playerStates:c,playerPublicStates:T,fishBank:new Map(R.map(I=>[I.fish,I.count])),oldBoot:O})}E(MA,"applyReceiveFish");function LA(e,r){if(!r.fishTiles)throw new Error("SPEND_FISH event must have fishTiles");let t=r.player,o=r.fishTiles,i=e.getPlayerState(t);if(!i){let T=0;for(let[,O]of o)T+=O;let R=Z(e.getPlayerPublicStates(),t,O=>O.toBuilder().withFishTileCount(Math.max(0,O.fishTileCount-T)).build());return m(e,{playerPublicStates:R})}let n=Xa(Array.from(i.fishTiles.entries()).map(([T,R])=>({fish:T,count:R})),Array.from(o.entries()).map(([T,R])=>({fish:T,count:R})));if(!n)throw new Error("Player doesn't have enough fish to spend");let a=new Map(n.map(T=>[T.fish,T.count])),s=i.toBuilder().withFishTiles(a).build(),u=e.getPlayerStates().map(T=>T.player===t?s:T),l=O_(n),c=Z(e.getPlayerPublicStates(),t,T=>T.toBuilder().withFishTileCount(l).build()),f=Za(Array.from(e.fishBank.entries()).map(([T,R])=>({fish:T,count:R})),Array.from(o.entries()).map(([T,R])=>({fish:T,count:R})));return m(e,{playerStates:u,playerPublicStates:c,fishBank:new Map(f.map(T=>[T.fish,T.count]))})}E(LA,"applySpendFish");function GA(e,r){if(!r.fishTiles)throw new Error("EXCHANGE_FISH event must have fishTiles (received)");if(!r.discardedFishTiles)throw new Error("EXCHANGE_FISH event must have discardedFishTiles");let t=r.player,o=r.fishTiles,i=r.discardedFishTiles,n=e.getPlayerState(t);if(!n){let I=0;for(let[,v]of o)I+=v;let D=0;for(let[,v]of i)D+=v;let g=I-D;if(g===0)return e;let k=Z(e.getPlayerPublicStates(),t,v=>v.toBuilder().withFishTileCount(Math.max(0,v.fishTileCount+g)).build());return m(e,{playerPublicStates:k})}let a=Xa(Array.from(n.fishTiles.entries()).map(([I,D])=>({fish:I,count:D})),Array.from(i.entries()).map(([I,D])=>({fish:I,count:D})));if(!a)throw new Error("Player doesn't have the fish tiles to discard");let s=Za(a,Array.from(o.entries()).map(([I,D])=>({fish:I,count:D}))),u=new Map(s.map(I=>[I.fish,I.count])),l=n.toBuilder().withFishTiles(u).build(),c=e.getPlayerStates().map(I=>I.player===t?l:I),f=O_(s),T=Z(e.getPlayerPublicStates(),t,I=>I.toBuilder().withFishTileCount(f).build()),R=Za(Array.from(e.fishBank.entries()).map(([I,D])=>({fish:I,count:D})),Array.from(i.entries()).map(([I,D])=>({fish:I,count:D}))),O=Xa(R,Array.from(o.entries()).map(([I,D])=>({fish:I,count:D})));if(!O)throw new Error("Insufficient fish in bank for exchange");return m(e,{playerStates:c,playerPublicStates:T,fishBank:new Map(O.map(I=>[I.fish,I.count]))})}E(GA,"applyExchangeFish");function UA(e,r){if(!r.fogHexLocation)throw new Error("REVEAL_FOG event must have fogHexLocation");if(!r.fogRevealedTerrain)throw new Error("REVEAL_FOG event must have fogRevealedTerrain");let t=new A(r.fogHexLocation,r.fogRevealedTerrain,r.fogRevealedNumber?[r.fogRevealedNumber]:[]),i=[...e.board.getTiles().filter(l=>!l.location.equals(r.fogHexLocation)),t],n=pe(e.board,{tiles:i}),a=[...e.fogTerrainBank],s=a.indexOf(r.fogRevealedTerrain);s!==-1&&a.splice(s,1);let u=[...e.fogNumberBank];if(r.fogRevealedNumber){let l=u.indexOf(r.fogRevealedNumber);l!==-1&&u.splice(l,1)}return m(e,{board:n,fogTerrainBank:a,fogNumberBank:u,incrementMapVersion:!0})}E(UA,"applyRevealFog");function eu(e,r){if(r.length===0)return e;let t=e;for(let n of r){let a=t.board.getTile(n.hex);if(!a||!a.isFog)continue;let s=new A(n.hex,n.terrain,n.number?[n.number]:[]),u=t.board.getTiles().filter(R=>!R.location.equals(n.hex)),l=pe(t.board,{tiles:[...u,s]}),c=[...t.fogTerrainBank],f=c.indexOf(n.terrain);f!==-1&&c.splice(f,1);let T=[...t.fogNumberBank];if(n.number){let R=T.indexOf(n.number);R!==-1&&T.splice(R,1)}t=m(t,{board:l,fogTerrainBank:c,fogNumberBank:T,incrementMapVersion:!0})}let o=t.board.getTiles().slice().sort((n,a)=>_.compare(n.location,a.location)),i=pe(t.board,{tiles:o});return m(t,{board:i,incrementMapVersion:!0})}E(eu,"applyInitialFogReveals");function BA(e,r){let t=new Set;for(let s of e.board.getTiles())s.isDesert&&t.add(s.location.toString());let o=[],i=[];for(let s of e.board.getTiles()){if(!s.isProductiveLand){i.push(s);continue}let u=!1;for(let l of s.location.getAllNeighbors())if(t.has(l.toString())){u=!0;break}if(u){let{tile:l}=s.weaken();o.push(l)}else i.push(s)}if(o.length===0)return e;let n=[...i,...o],a=e.board.toBuilder().withTiles(n).build();return m(e,{board:a,incrementMapVersion:!0})}E(BA,"applyTilesDesertified");function tu(e,r){let t=new Set,o=[];for(let i of r)for(let n of i.location.getAllEdges()){let a=n.toString();t.has(a)||(t.add(a),o.push(n))}return new ru(e,r,o).getValidPlacements()}E(tu,"getValidWagonPlacements");var ru=class{static{E(this,"WagonPlacementCalculator")}wagons;wateringHoles;validEdges;constructor(r,t,o){this.wagons=r,this.wateringHoles=t.filter(i=>i.terrain===d.TERRAIN_WATERING_HOLE),this.validEdges=o}getValidPlacements(){let r=this.getExtensionVertices(),t=[];for(let o of r){let i=this.getValidEdgesFromVertex(o);for(let n of i){let a=n.v1.equals(o)?n.v2:n.v1,s=this.getDirectionBetweenVertices(o,a);s&&t.push({edge:n,facing:s})}}return t}getExtensionVertices(){if(this.wagons.length===0)return this.getWateringHoleVertices();let r=[];for(let t of this.wagons){let o=t.frontVertex;this.wagons.some(n=>n===t?!1:n.backVertex.equals(o))||r.some(n=>n.equals(o))||r.push(o)}return r}getWateringHoleVertices(){let r=[];for(let t of this.wateringHoles){let o=t.location.getAllVerticies();for(let i of o)r.some(n=>n.equals(i))||r.push(i)}return r}getDirectionBetweenVertices(r,t){let o=r.getValidDirectionsToOtherVerticies();for(let i of o)if(r.add(i).equals(t))return i}getValidEdgesFromVertex(r){let t=[];for(let o of this.validEdges)(o.v1.equals(r)||o.v2.equals(r))&&(this.wagons.some(n=>n.edge.equals(o))||t.push(o));return t}};var mi=class{static{E(this,"WagonVoteResolver")}votes;activePlayer;validPlacements;constructor(r,t,o){this.votes=r,this.activePlayer=t,this.validPlacements=o}resolve(){let r=this.votes.filter(a=>!a.isPass&&a.preferredEdge&&a.preferredFacing);if(r.length===0)return;let t=this.countVotesPerPlacement(r),o=Math.max(...t.values()),i=[...t.entries()].filter(([,a])=>a===o);if(i.length===1){let[a]=i[0];return this.placementFromKey(a)}return this.resolveTie(i,r)}countVotesPerPlacement(r){let t=new Map;for(let o of r){if(!o.preferredEdge||!o.preferredFacing||!this.validPlacements.some(s=>s.edge.equals(o.preferredEdge)&&s.facing.equals(o.preferredFacing)))continue;let n=this.placementKey(o.preferredEdge,o.preferredFacing),a=t.get(n)||0;t.set(n,a+o.totalBid)}return t}resolveTie(r,t){let o=new Set(r.map(([l])=>l)),i,n=0,a;for(let l of t){if(!l.preferredEdge||!l.preferredFacing)continue;let c=this.placementKey(l.preferredEdge,l.preferredFacing);o.has(c)&&(l.totalBid>n?(n=l.totalBid,i=l.player,a=c):l.totalBid===n&&l.player===this.activePlayer&&(i=l.player,a=c))}if(a)return{...this.placementFromKey(a),winningPlayer:i};let s=t.find(l=>l.player===this.activePlayer);if(s?.preferredEdge&&s?.preferredFacing){let l=this.placementKey(s.preferredEdge,s.preferredFacing);if(o.has(l))return{...this.placementFromKey(l),winningPlayer:this.activePlayer}}let[u]=r[0];return this.placementFromKey(u)}placementKey(r,t){return`${r.toString()}|${t.toString()}`}placementFromKey(r){for(let t of this.validPlacements)if(this.placementKey(t.edge,t.facing)===r)return{edge:t.edge,facing:t.facing};throw new Error(`Invalid placement key: ${r}`)}};function kA(e,r){if(r.type!==h.GAME_EVENT_TYPE_WAGON_VOTING_STARTED)throw new Error(`Expected WAGON_VOTING_STARTED event, got ${r.type}`);let t=new Tn(r.player,r.wagonVotingPlayers??[],[]);return m(e,{pendingWagonVoting:t})}E(kA,"applyWagonVotingStarted");function bA(e,r){if(r.type!==h.GAME_EVENT_TYPE_WAGON_VOTE)throw new Error(`Expected WAGON_VOTE event, got ${r.type}`);let t=e.pendingWagonVoting;if(!t)throw new Error("No pending wagon voting to apply vote to");let o=r.wagonVotes?.[0];if(!o)throw new Error("WAGON_VOTE event must have a vote");let i=t.withVote(o);return i.isComplete&&!new mi(i.votes,i.activePlayer,tu(e.board.getWagons(),e.board.getTiles())).resolve()?m(e,{pendingWagonVoting:null}):m(e,{pendingWagonVoting:i})}E(bA,"applyWagonVote");function vA(e,r){if(r.type!==h.GAME_EVENT_TYPE_WAGON_PLACED)throw new Error(`Expected WAGON_PLACED event, got ${r.type}`);let t=r.placedWagon;if(!t)throw new Error("WAGON_PLACED event must have a placedWagon");let o=im(e.board,t),i=m(e,{board:o,pendingWagonVoting:null,incrementBuildingVersion:!0}),n=new Rt(i),a=n.calculateLongestRoadHolder(),s=n.recalculateAllLongestRoadLengths();return m(i,{longestRoadPlayer:a??null,playerPublicStates:s})}E(vA,"applyWagonPlaced");function YA(e,r){if(r.type!==h.GAME_EVENT_TYPE_WAGONS_EXHAUSTED)throw new Error(`Expected WAGONS_EXHAUSTED event, got ${r.type}`);return m(e,{wagonsExhausted:!0,pendingWagonVoting:null})}E(YA,"applyWagonsExhausted");function im(e,r){let o=[...e.getWagons(),r];return e.toBuilder().withWagons(o).build()}E(im,"addWagonToBoard");function ql(e,r,t){let o=e.getPlayerStates();e.hasPlayerState(r)&&(o=z(o,r,n=>n.toBuilder().withGold(Math.max(0,n.gold+t)).build()));let i=Z(e.getPlayerPublicStates(),r,n=>n.toBuilder().withGold(Math.max(0,n.gold+t)).build());return{playerStates:o,playerPublicStates:i}}E(ql,"changeGold");function FA(e,r){let t=r.goldAmount??0;return t<=0?e:m(e,ql(e,r.player,t))}E(FA,"applyReceiveGold");function VA(e,r){let t=r.goldAmount??0,o=r.selectedResource;if(o===void 0||o===S.RESOURCE_UNSPECIFIED)throw new Error("SPEND_GOLD event must have selectedResource");let i=new Map([[o,1]]),{playerStates:n,playerPublicStates:a}=ql(e,r.player,-t),s=n;e.hasPlayerState(r.player)&&(s=z(s,r.player,c=>c.toBuilder().withHand($e(c.hand,i)).build()));let u=Z(a,r.player,c=>c.toBuilder().withCardCount(c.cardCount+1).build()),l=new Map(e.goldSpentThisTurn);return l.set(r.player,(l.get(r.player)??0)+1),m(e,{resourceDeck:Lt(e.resourceDeck,i),playerStates:s,playerPublicStates:u,goldSpentThisTurn:l})}E(VA,"applySpendGold");function xA(e,r){let t=r.offeredResources??new Map,o=Qe(t),i=r.goldAmount??0,{playerStates:n,playerPublicStates:a}=ql(e,r.player,i),s=n;e.hasPlayerState(r.player)&&(s=z(s,r.player,l=>l.toBuilder().withHand(ke(l.hand,t)).build()));let u=Z(a,r.player,l=>l.toBuilder().withCardCount(Math.max(0,l.cardCount-o)).build());return m(e,{resourceDeck:Pr(e.resourceDeck,t),playerStates:s,playerPublicStates:u})}E(xA,"applyBuyGold");function wA(e,r){let t=r.edge;if(!t)throw new Error("BUILD_BRIDGE event must have edge");let o=[...e.getEdgeBuildings(),new ar(t,r.player,F.BUILDING_BRIDGE)],i=e.getPlayerStates();e.hasPlayerState(r.player)&&(i=z(i,r.player,s=>s.toBuilder().withHand(ke(s.hand,Fn)).build()));let n=Z(e.getPlayerPublicStates(),r.player,s=>s.toBuilder().withCardCount(Math.max(0,s.cardCount-Qe(Fn))).build()),a=st(e,o,e.getVertexBuildings(),e.board.knights);return n=at(n,o,e.getVertexBuildings(),e.board.knights),m(e,{board:pe(e.board,{edgeBuildings:o}),resourceDeck:Pr(e.resourceDeck,Fn),playerStates:i,playerPublicStates:n,activeTrades:[],longestRoadPlayer:a,incrementBuildingVersion:!0})}E(wA,"applyBuildBridge");var Wt=class{static{E(this,"GameStateApplier")}apply(r,t){let o=this.applyEvent(r,t);return eR(rR(o))}applyEvent(r,t){switch(t.type){case h.GAME_EVENT_TYPE_ROLL_DICE:return this.applyRollDice(r,t);case h.GAME_EVENT_TYPE_RECEIVE_RESOURCES:return this.applyReceiveResources(r,t);case h.GAME_EVENT_TYPE_RECEIVE_COMMODITIES:return this.applyReceiveCommodities(r,t);case h.GAME_EVENT_TYPE_DISCARD_RESOURCES:return this.applyDiscardResources(r,t);case h.GAME_EVENT_TYPE_GIVE_WEDDING_CARDS:return this.applyGiveWeddingCards(r,t);case h.GAME_EVENT_TYPE_MOVE_ROBBER:return this.applyMoveRobber(r,t);case h.GAME_EVENT_TYPE_LAZY_ROBBER_RETREAT:return LN(r,t);case h.GAME_EVENT_TYPE_MOVE_SHIP:return this.applyMoveShip(r,t);case h.GAME_EVENT_TYPE_MOVE_PIRATE:return this.applyMovePirate(r,t);case h.GAME_EVENT_TYPE_STEAL_RESOURCE:return this.applyStealResource(r,t);case h.GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE:return this.applyStealResourcePirate(r,t);case h.GAME_EVENT_TYPE_BUILD_ROAD:return this.applyBuildRoad(r,t);case h.GAME_EVENT_TYPE_BUILD_SHIP:return this.applyBuildShip(r,t);case h.GAME_EVENT_TYPE_BUILD_SETTLEMENT:return this.applyBuildSettlement(r,t);case h.GAME_EVENT_TYPE_BUILD_CITY:return this.applyBuildCity(r,t);case h.GAME_EVENT_TYPE_BUY_DEV_CARD:return this.applyBuyDevCard(r,t);case h.GAME_EVENT_TYPE_BUY_PROGRESS_CARD:return this.applyBuyProgressCard(r,t);case h.GAME_EVENT_TYPE_PLAY_KNIGHT:return this.applyPlayKnight(r,t);case h.GAME_EVENT_TYPE_PLAY_ROAD_BUILDING:return this.applyPlayRoadBuilding(r,t);case h.GAME_EVENT_TYPE_PLAY_YEAR_OF_PLENTY:return this.applyPlayYearOfPlenty(r,t);case h.GAME_EVENT_TYPE_PLAY_MONOPOLY:return this.applyPlayMonopoly(r,t);case h.GAME_EVENT_TYPE_PLAY_VICTORY_POINT:return this.applyPlayVictoryPoint(r,t);case h.GAME_EVENT_TYPE_TRADE_WITH_PLAYER:return this.applyTradeWithPlayer(r,t);case h.GAME_EVENT_TYPE_TRADE_WITH_BANK:return this.applyTradeWithBank(r,t);case h.GAME_EVENT_TYPE_END_TURN:return this.applyEndTurn(r,t);case h.GAME_EVENT_TYPE_PROPOSE_TRADE:return this.applyProposeTrade(r,t);case h.GAME_EVENT_TYPE_PROPOSE_MULTI_TRADE:return this.applyProposeMultiTrade(r,t);case h.GAME_EVENT_TYPE_ACCEPT_TRADE:return this.applyAcceptTrade(r,t);case h.GAME_EVENT_TYPE_REJECT_TRADE:return this.applyRejectTrade(r,t);case h.GAME_EVENT_TYPE_REVOKE_TRADE_ACCEPT:return this.applyRevokeTradeAccept(r,t);case h.GAME_EVENT_TYPE_CANCEL_TRADE:return this.applyCancelTrade(r,t);case h.GAME_EVENT_TYPE_EXECUTE_TRADE:return this.applyExecuteTrade(r,t);case h.GAME_EVENT_TYPE_TRADE_EMBARGO:return this.applyTradeEmbargo(r,t);case h.GAME_EVENT_TYPE_SELECT_FREE_RESOURCE:return this.applySelectFreeResource(r,t);case h.GAME_EVENT_TYPE_PLACE_FREE_STRUCTURE:return this.applyPlaceFreeStructure(r,t);case h.GAME_EVENT_TYPE_PLAY_ALCHEMIST:return this.applyPlayAlchemist(r,t);case h.GAME_EVENT_TYPE_PLAY_ENGINEER:return this.applyPlayEngineer(r,t);case h.GAME_EVENT_TYPE_PLAY_CRANE:return this.applyPlayCrane(r,t);case h.GAME_EVENT_TYPE_PLAY_MEDICINE:return this.applyPlayMedicine(r,t);case h.GAME_EVENT_TYPE_PLAY_BISHOP:return this.applyPlayBishop(r,t);case h.GAME_EVENT_TYPE_PLAY_MINING:return this.applyPlayMining(r,t);case h.GAME_EVENT_TYPE_PLAY_IRRIGATION:return this.applyPlayIrrigation(r,t);case h.GAME_EVENT_TYPE_PLAY_WARLORD:return this.applyPlayWarlord(r,t);case h.GAME_EVENT_TYPE_PLAY_SMITH:return this.applyPlaySmith(r,t);case h.GAME_EVENT_TYPE_PLAY_RESOURCE_MONOPOLY:return this.applyPlayResourceMonopoly(r,t);case h.GAME_EVENT_TYPE_PLAY_TRADE_MONOPOLY:return this.applyPlayTradeMonopoly(r,t);case h.GAME_EVENT_TYPE_PLAY_PROGRESS_ROAD_BUILDING:return this.applyPlayProgressRoadBuilding(r,t);case h.GAME_EVENT_TYPE_PLAY_INVENTOR:return this.applyPlayInventor(r,t);case h.GAME_EVENT_TYPE_PLAY_MERCHANT_CARD:return this.applyPlayMerchantCard(r,t);case h.GAME_EVENT_TYPE_PLAY_MERCHANT_FLEET:return this.applyPlayMerchantFleet(r,t);case h.GAME_EVENT_TYPE_PLAY_DESERTER:return this.applyPlayDeserter(r,t);case h.GAME_EVENT_TYPE_SELECT_DESERTER_KNIGHT:return this.applySelectDeserterKnight(r,t);case h.GAME_EVENT_TYPE_PLAY_DIPLOMAT:return this.applyPlayDiplomat(r,t);case h.GAME_EVENT_TYPE_PLAY_INTRIGUE:return this.applyPlayIntrigue(r,t);case h.GAME_EVENT_TYPE_PLAY_SABOTEUR:return this.applyPlaySaboteur(r,t);case h.GAME_EVENT_TYPE_PLAY_WEDDING:return this.applyPlayWedding(r,t);case h.GAME_EVENT_TYPE_PLAY_COMMERCIAL_HARBOR:return this.applyPlayCommercialHarbor(r,t);case h.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_TRADE_CANCELLED:return this.applyCommercialHarborTradeCancelled(r,t);case h.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_EXCHANGE:return this.applyCommercialHarborExchange(r,t);case h.GAME_EVENT_TYPE_PLAY_SPY:return this.applyPlaySpy(r,t);case h.GAME_EVENT_TYPE_DISCARD_PROGRESS_CARD:return this.applyDiscardProgressCard(r,t);case h.GAME_EVENT_TYPE_PROGRESS_CARD_DISCARD_REQUIRED:return AA(r,t);case h.GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT:return this.applyPlayMasterMerchant(r,t);case h.GAME_EVENT_TYPE_BUILD_KNIGHT:return this.applyBuildKnight(r,t);case h.GAME_EVENT_TYPE_ACTIVATE_KNIGHT:return this.applyActivateKnight(r,t);case h.GAME_EVENT_TYPE_PROMOTE_KNIGHT:return this.applyPromoteKnight(r,t);case h.GAME_EVENT_TYPE_MOVE_KNIGHT:return this.applyMoveKnight(r,t);case h.GAME_EVENT_TYPE_DISPLACE_KNIGHT:return this.applyDisplaceKnight(r,t);case h.GAME_EVENT_TYPE_CHASE_ROBBER:return this.applyChaseRobber(r,t);case h.GAME_EVENT_TYPE_USE_KNIGHT_ERRANT:return this.applyUseKnightErrant(r,t);case h.GAME_EVENT_TYPE_KNIGHTS_DEACTIVATED:return this.applyKnightsDeactivated(r,t);case h.GAME_EVENT_TYPE_AQUEDUCT_TRIGGERED:return this.applyAqueductTriggered(r,t);case h.GAME_EVENT_TYPE_BUILD_CITY_WALL:return this.applyBuildCityWall(r,t);case h.GAME_EVENT_TYPE_BUILD_CITY_IMPROVEMENT:return this.applyBuildCityImprovement(r,t);case h.GAME_EVENT_TYPE_METROPOLIS_BUILT:return this.applyMetropolisBuilt(r,t);case h.GAME_EVENT_TYPE_METROPOLIS_TRANSFERRED:return this.applyMetropolisTransferred(r,t);case h.GAME_EVENT_TYPE_SELECT_METROPOLIS_CITY:return this.applySelectMetropolisCity(r,t);case h.GAME_EVENT_TYPE_ROLL_EVENT_DIE:return this.applyRollEventDie(r,t);case h.GAME_EVENT_TYPE_BARBARIAN_ADVANCE:return this.applyBarbarianAdvance(r,t);case h.GAME_EVENT_TYPE_BARBARIAN_ATTACK:return this.applyBarbarianAttack(r,t);case h.GAME_EVENT_TYPE_CITY_PILLAGED:return this.applyCityPillaged(r,t);case h.GAME_EVENT_TYPE_DEFENDER_OF_CATAN:return this.applyDefenderOfCatan(r,t);case h.GAME_EVENT_TYPE_DRAW_PROGRESS_CARD:return this.applyDrawProgressCard(r,t);case h.GAME_EVENT_TYPE_AWAIT_KNIGHT_COMMITMENT:return this.applyAwaitKnightCommitment(r,t);case h.GAME_EVENT_TYPE_COMMIT_KNIGHTS_TO_DEFENSE:return this.applyCommitKnightsToDefense(r,t);case h.GAME_EVENT_TYPE_INITIALIZE_DECKS:return t.initialFogReveals&&t.initialFogReveals.length>0?eu(r,t.initialFogReveals):r;case h.GAME_EVENT_TYPE_PASS_OLD_BOOT:return this.applyPassOldBoot(r,t);case h.GAME_EVENT_TYPE_RECEIVE_FISH:return this.applyReceiveFish(r,t);case h.GAME_EVENT_TYPE_SPEND_FISH:return this.applySpendFish(r,t);case h.GAME_EVENT_TYPE_EXCHANGE_FISH:return this.applyExchangeFish(r,t);case h.GAME_EVENT_TYPE_REVEAL_FOG:return this.applyRevealFog(r,t);case h.GAME_EVENT_TYPE_TILES_DESERTIFIED:return this.applyTilesDesertified(r,t);case h.GAME_EVENT_TYPE_GOLD_PRODUCED:return this.applyGoldProduced(r,t);case h.GAME_EVENT_TYPE_NEW_ISLAND_SETTLEMENT:return this.applyNewIslandSettlement(r,t);case h.GAME_EVENT_TYPE_COLLECT_EDGE_VP:return this.applyCollectEdgeVp(r,t);case h.GAME_EVENT_TYPE_COLLECT_EDGE_DEV_CARD:return this.applyCollectEdgeDevCard(r,t);case h.GAME_EVENT_TYPE_COLLECT_EDGE_PORT:return this.applyCollectEdgePort(r,t);case h.GAME_EVENT_TYPE_PLACE_PORT:return this.applyPlacePort(r,t);case h.GAME_EVENT_TYPE_RESIGN:return this.applyResign(r,t);case h.GAME_EVENT_TYPE_PAUSE:return this.applyPause(r,t);case h.GAME_EVENT_TYPE_UNPAUSE:return this.applyUnpause(r,t);case h.GAME_EVENT_TYPE_VOTE_TO_CONTINUE:return this.applyVoteToContinue(r,t);case h.GAME_EVENT_TYPE_AWARD_LONGEST_ROAD:return r;case h.GAME_EVENT_TYPE_AWARD_LARGEST_ARMY:return r;case h.GAME_EVENT_TYPE_AWARD_HARBORMASTER:return r;case h.GAME_EVENT_TYPE_FREE_RESOURCE_GRANTED:return this.applyFreeResourceGranted(r,t);case h.GAME_EVENT_TYPE_FREE_STRUCTURE_GRANTED:return this.applyFreeStructureGranted(r,t);case h.GAME_EVENT_TYPE_GAME_WON:return this.applyGameWon(r,t);case h.GAME_EVENT_TYPE_START_SECOND_SETTLER_TURN:return this.applyStartSecondSettlerTurn(r,t);case h.GAME_EVENT_TYPE_END_SECOND_SETTLER_TURN:return this.applyEndSecondSettlerTurn(r,t);case h.GAME_EVENT_TYPE_ROAD_DAMAGED:return this.applyRoadDamaged(r,t);case h.GAME_EVENT_TYPE_GIVE_EVENT_CARD_RESOURCE:return this.applyGiveEventCardResource(r,t);case h.GAME_EVENT_TYPE_WAGON_VOTING_STARTED:return this.applyWagonVotingStarted(r,t);case h.GAME_EVENT_TYPE_WAGON_VOTE:return this.applyWagonVote(r,t);case h.GAME_EVENT_TYPE_WAGON_PLACED:return this.applyWagonPlaced(r,t);case h.GAME_EVENT_TYPE_WAGONS_EXHAUSTED:return this.applyWagonsExhausted(r,t);case h.GAME_EVENT_TYPE_RECEIVE_GOLD:return FA(r,t);case h.GAME_EVENT_TYPE_SPEND_GOLD:return VA(r,t);case h.GAME_EVENT_TYPE_BUY_GOLD:return xA(r,t);case h.GAME_EVENT_TYPE_BUILD_BRIDGE:return wA(r,t);case h.GAME_EVENT_TYPE_WEALTHIEST_TRADER_CHANGED:case h.GAME_EVENT_TYPE_POOREST_TRADER_CHANGED:return r;case h.GAME_EVENT_TYPE_RESOURCE_DISTRIBUTION:return this.applyResourceDistribution(r,t);case h.GAME_EVENT_TYPE_FEED_TROLL:return this.applyFeedTroll(r,t);case h.GAME_EVENT_TYPE_KICK_TROLL:return this.applyKickTroll(r,t);case h.GAME_EVENT_TYPE_TROLLS_INVADED:case h.GAME_EVENT_TYPE_TROLL_SPAWNED:return r;case h.GAME_EVENT_TYPE_VOTE_DICE_ROLL:return this.applyVoteDiceRoll(r,t);case h.GAME_EVENT_TYPE_RUSH_ROUND_START:return jN(r,t);default:throw new Error(`Unknown event type: ${t.type}`)}}applyRollDice(r,t){return GN(r,t)}applyReceiveResources(r,t){return UN(r,t)}applyResourceDistribution(r,t){return BN(r,t)}applyReceiveCommodities(r,t){return gA(r,t)}applyDiscardResources(r,t){return kN(r,t)}applyMoveRobber(r,t){return bN(r,t)}applyStealResource(r,t){return vN(r,t)}applyBuildRoad(r,t){return FN(r,t)}applyBuildShip(r,t){return VN(r,t)}applyBuildSettlement(r,t){return xN(r,t)}applyBuildCity(r,t){return wN(r,t)}applyBuyDevCard(r,t){return KN(r,t)}applyBuyProgressCard(r,t){return HN(r,t)}applyPlayKnight(r,t){return tR(r,t)}applyPlayRoadBuilding(r,t){return nR(r,t)}applyPlayYearOfPlenty(r,t){return iR(r,t)}applyPlayMonopoly(r,t){return oR(r,t)}applyPlayVictoryPoint(r,t){return aR(r,t)}applyTradeWithPlayer(r,t){return TR(r,t)}applyTradeWithBank(r,t){return NR(r,t)}applyEndTurn(r,t){return JN(r,t)}applyProposeTrade(r,t){return _R(r,t)}applyProposeMultiTrade(r,t){return dR(r,t)}applyAcceptTrade(r,t){return uR(r,t)}applyRejectTrade(r,t){return ER(r,t)}applyRevokeTradeAccept(r,t){return lR(r,t)}applyCancelTrade(r,t){return cR(r,t)}applyExecuteTrade(r,t){return fR(r,t)}applyTradeEmbargo(r,t){return RR(r,t)}applySelectFreeResource(r,t){return qN(r,t)}applyPlaceFreeStructure(r,t){return ZN(r,t)}applyMoveShip(r,t){return AR(r,t)}applyMovePirate(r,t){return SR(r,t)}applyStealResourcePirate(r,t){return OR(r,t)}applyGoldProduced(r,t){return IR(r,t)}applyNewIslandSettlement(r,t){return XN(r,t)}applyCollectEdgeVp(r,t){return CR(r,t)}applyCollectEdgeDevCard(r,t){return PR(r,t)}applyCollectEdgePort(r,t){return pR(r,t)}applyPlacePort(r,t){return DR(r,t)}applyBuildKnight(r,t){return vR(r,t)}applyActivateKnight(r,t){return YR(r,t)}applyPromoteKnight(r,t){return FR(r,t)}applyMoveKnight(r,t){return VR(r,t)}applyDisplaceKnight(r,t){return xR(r,t)}applyChaseRobber(r,t){return wR(r,t)}applyUseKnightErrant(r,t){return HR(r,t)}applyKnightsDeactivated(r,t){return KR(r,t)}applyAqueductTriggered(r,t){return WR(r,t)}applyBuildCityWall(r,t){return qR(r,t)}applyBuildCityImprovement(r,t){return ZR(r,t)}applyMetropolisBuilt(r,t){return XR(r,t)}applyMetropolisTransferred(r,t){return zR(r,t)}applySelectMetropolisCity(r,t){return $R(r,t)}applyPendingMetropolisPlacement(r,t){return m(r,{pendingMetropolisPlacement:t})}applyRollEventDie(r,t){return mR(r,t)}applyBarbarianAdvance(r,t){return MR(r,t)}applyBarbarianAttack(r,t){return LR(r,t)}applyCityPillaged(r,t){return GR(r,t)}applyDefenderOfCatan(r,t){return UR(r,t)}applyDrawProgressCard(r,t){return BR(r,t)}applyAwaitKnightCommitment(r,t){return kR(r,t)}applyCommitKnightsToDefense(r,t){return bR(r,t)}applyPlayEngineer(r,t){return QR(r,t)}applyPlayCrane(r,t){return jR(r,t)}applyPlayMedicine(r,t){return eA(r,t)}applyPlayAlchemist(r,t){return rA(r,t)}applyPlayMining(r,t){return tA(r,t)}applyPlayIrrigation(r,t){return nA(r,t)}applyPlayProgressRoadBuilding(r,t){return iA(r,t)}applyPlayInventor(r,t){return oA(r,t)}applyPlayBishop(r,t){return aA(r,t)}applyPlayWarlord(r,t){return sA(r,t)}applyPlaySmith(r,t){return _A(r,t)}applyPlaySaboteur(r,t){return dA(r,t)}applyPlayWedding(r,t){return uA(r,t)}applyGiveWeddingCards(r,t){return EA(r,t)}applyPlayDeserter(r,t){return lA(r,t)}applySelectDeserterKnight(r,t){return cA(r,t)}applyPlayDiplomat(r,t){return TA(r,t)}applyPlayIntrigue(r,t){return NA(r,t)}applyPlaySpy(r,t){return RA(r,t)}applyDiscardProgressCard(r,t){return SA(r,t)}applyPlayResourceMonopoly(r,t){return OA(r,t)}applyPlayTradeMonopoly(r,t){return IA(r,t)}applyPlayMerchantCard(r,t){return CA(r,t)}applyPlayMerchantFleet(r,t){return PA(r,t)}applyPlayCommercialHarbor(r,t){return pA(r,t)}applyCommercialHarborTradeCancelled(r,t){return hA(r,t)}applyCommercialHarborExchange(r,t){return DA(r,t)}applyPlayMasterMerchant(r,t){return mA(r,t)}applyPassOldBoot(r,t){return yA(r,t)}applyReceiveFish(r,t){return MA(r,t)}applySpendFish(r,t){return LA(r,t)}applyExchangeFish(r,t){return GA(r,t)}applyRevealFog(r,t){return UA(r,t)}applyTilesDesertified(r,t){return BA(r,t)}applyResign(r,t){let o=t.player,i=r.turnOrder.find(a=>a!==o);if(!i)return r;let n=r.toProto();return n.winner=i,gr.fromProto(n)}applyPause(r,t){let o=r.pauseState?.pauseCounts??new Map,i=Ga.create(t.player,Date.now(),o);return m(r,{paused:!0,pauseState:i})}applyUnpause(r,t){return m(r,{paused:!1})}applyVoteToContinue(r,t){if(!r.pauseState)return r;let o=r.pauseState.withVote(t.player,Date.now());return m(r,{pauseState:o})}applyGameWon(r,t){let o=m(r,{winner:t.player});if(r.options.timerConfig.isEnabled()&&o.timerState){let i=ON(o);o=$a(o,i)}return o}applyFreeResourceGranted(r,t){if(t.freeResourceReason!==Ir.FREE_RESOURCE_REASON_FISH&&t.freeResourceReason!==Ir.FREE_RESOURCE_REASON_GOLD_TILE_DISCOVERY)return r;let o=t.freeResourceCount??0;if(o<=0)return r;let i=ot(r),n=i.get(t.player)??0;return i.set(t.player,n+o),m(r,{pendingFreeResources:i})}applyFreeStructureGranted(r,t){if(t.freeStructureReason!==dn.FREE_STRUCTURE_REASON_FISH)return r;let o=t.freeStructureBuilding;if(o!==F.BUILDING_ROAD&&o!==F.BUILDING_SHIP&&o!==F.BUILDING_ROAD_OR_SHIP&&o!==F.BUILDING_KNIGHT&&o!==F.BUILDING_SETTLEMENT&&o!==F.BUILDING_CITY)return r;let i=Kt(r),n=i.get(t.player)??[];return i.set(t.player,[...n,o]),m(r,{pendingFreeStructures:i})}applyStartSecondSettlerTurn(r,t){return zN(r,t)}applyEndSecondSettlerTurn(r,t){return $N(r,t)}calculateResourceDistribution(r,t){let o=new Map,i=new Map;for(let[a,s]of t)for(let[u,l]of s){o.set(u,(o.get(u)??0)+l);let c=i.get(u)??[];c.push(a),i.set(u,c)}let n=new Map;for(let a of t.keys())n.set(a,new Map);for(let[a,s]of o){let u=r.get(a)??0,l=i.get(a)??[];if(l.length!==0){if(l.length===1){let c=l[0],f=t.get(c)?.get(a)??0,T=Math.min(f,u);T>0&&n.get(c).set(a,T)}else if(u>=s)for(let c of l){let f=t.get(c)?.get(a)??0;f>0&&n.get(c).set(a,f)}}}return n}calculateCommodityDistribution(r,t){let o=new Map,i=new Map;for(let[a,s]of t)for(let[u,l]of s){let c=u;o.set(c,(o.get(c)??0)+l);let f=i.get(c)??[];f.push(a),i.set(c,f)}let n=new Map;for(let a of t.keys())n.set(a,new Map);for(let[a,s]of o){let u=r.get(a)??0,l=i.get(a)??[];if(l.length!==0){if(l.length===1){let c=l[0],f=t.get(c)?.get(a)??0,T=Math.min(f,u);T>0&&n.get(c).set(a,T)}else if(u>=s)for(let c of l){let f=t.get(c)?.get(a)??0;f>0&&n.get(c).set(a,f)}}}return n}applyRoadDamaged(r,t){if(!t.edge)throw new Error("ROAD_DAMAGED event must have edge");if(!t.player)throw new Error("ROAD_DAMAGED event must have player");let o=r.getEdgeBuildings().map(a=>a.edge.equals(t.edge)&&a.owner===t.player&&a.isRoad?new ar(a.edge,a.owner,F.BUILDING_BROKEN_ROAD):a),i=pe(r.board,{edgeBuildings:o}),n=r.pendingEarthquake.filter(a=>a!==t.player);return m(r,{board:i,pendingEarthquake:n,incrementBuildingVersion:!0})}applyGiveEventCardResource(r,t){return QN(r,t)}applyWagonVotingStarted(r,t){return kA(r,t)}applyWagonVote(r,t){return bA(r,t)}applyWagonPlaced(r,t){return vA(r,t)}applyWagonsExhausted(r,t){return YA(r,t)}applyVoteDiceRoll(r,t){let o=t.player,i=new Set(r.rushDiceVotes);return i.add(o),m(r,{rushDiceVotes:i})}applyFeedTroll(r,t){if(!t.trollHex)throw new Error("FEED_TROLL event must have trollHex");let o=t.resources?Qe(t.resources):0,i=r.getPlayerStates(),n=r.resourceDeck;if(t.resources&&r.hasPlayerState(t.player)){i=i.map(l=>{if(l.player!==t.player)return l;let c=new Map(l.hand);for(let[f,T]of t.resources)c.set(f,(c.get(f)??0)-T);return l.toBuilder().withHand(c).build()}),n=new Map(r.resourceDeck);for(let[l,c]of t.resources)n.set(l,(n.get(l)??0)+c)}let a=Z(r.getPlayerPublicStates(),t.player,l=>l.toBuilder().withCardCount(Math.max(0,l.cardCount-o)).build()),s=r.board.getTrolls().filter(l=>!l.equals(t.trollHex)),u=r.board.toBuilder().withTrolls(s).build();return m(r,{board:u,playerStates:i,playerPublicStates:a,resourceDeck:n})}applyKickTroll(r,t){if(!t.trollHex)throw new Error("KICK_TROLL event must have trollHex");if(!t.knightLocation)throw new Error("KICK_TROLL event must have knightLocation");let o=r.board.getKnights().map(a=>a.location.equals(t.knightLocation)?a.deactivate():a),i=r.board.getTrolls().filter(a=>!a.equals(t.trollHex)),n=r.board.toBuilder().withKnights(o).withTrolls(i).build();return m(r,{board:n})}};var gi=class{static{E(this,"DefaultRandomSource")}random(){return Math.random()}rollDie(){return Math.floor(Math.random()*6)+1}rollEventDie(){let r=Math.floor(Math.random()*6)+1;return r<=3?Ue.EVENT_DIE_RESULT_BARBARIAN_SHIP:r===4?Ue.EVENT_DIE_RESULT_TRADE_GATE:r===5?Ue.EVENT_DIE_RESULT_POLITICS_GATE:Ue.EVENT_DIE_RESULT_SCIENCE_GATE}pickRandom(r){return r[Math.floor(Math.random()*r.length)]}shuffle(r){let t=[...r];for(let o=t.length-1;o>0;o--){let i=Math.floor(Math.random()*(o+1));[t[o],t[i]]=[t[i],t[o]]}return t}},St=class{static{E(this,"SeededRandomSource")}state;constructor(r){this.state=r===0n?1n:r}getState(){return this.state}next(){let r=this.state;return r^=r<<13n,r^=r>>7n,r^=r<<17n,this.state=r&0xffffffffffffffffn,this.state}nextInt(r){let t=this.next();return Number((t&0xffffffffn)%BigInt(r))}random(){let r=this.next();return Number(r&0x1fffffffffffffn)/9007199254740992}rollDie(){return this.nextInt(6)+1}rollEventDie(){let r=this.nextInt(6)+1;return r<=3?Ue.EVENT_DIE_RESULT_BARBARIAN_SHIP:r===4?Ue.EVENT_DIE_RESULT_TRADE_GATE:r===5?Ue.EVENT_DIE_RESULT_POLITICS_GATE:Ue.EVENT_DIE_RESULT_SCIENCE_GATE}pickRandom(r){if(r.length===0)throw new Error("Cannot pick from empty array");return r[this.nextInt(r.length)]}shuffle(r){let t=[...r];for(let o=t.length-1;o>0;o--){let i=this.nextInt(o+1);[t[o],t[i]]=[t[i],t[o]]}return t}};function HA(e,r,t,o,i){let n=[],a=t.pendingResourceResolution,s=y.cityPillaged(o,i);n.push(s);let u=e.apply(t,s);if(a&&u.pendingCityPillage===void 0){let l=u.dice?.total??0;if(l!==7&&l>0){let c=Jt(e,u,l);for(let f of c)u=e.apply(u,f),n.push(f);if(u.options.fisherman){let f=Hn(e,r,u,l);for(let T of f)u=e.apply(u,T),n.push(T)}}u=m(u,{pendingResourceResolution:!1})}return{success:!0,game:u,events:n}}E(HA,"executeSelectCityToPillage");function nu(e,r,t,o,i){let n=t.pendingResourceResolution,a;if(i===K.CITY_IMPROVEMENT_TRACK_SCIENCE)a=t.scienceProgressDeck;else if(i===K.CITY_IMPROVEMENT_TRACK_POLITICS)a=t.politicsProgressDeck;else if(i===K.CITY_IMPROVEMENT_TRACK_TRADE)a=t.tradeProgressDeck;else return{success:!1,error:`Invalid track selection: ${i}`,game:t,events:[]};if(!a||a.length===0)return{success:!1,error:"Selected deck is empty",game:t,events:[]};let s=S_(a);if(!s)return{success:!1,error:"Selected deck is empty",game:t,events:[]};let[u]=s,l=[];l.push(y.drawProgressCard(o,u,i));let c=t;for(let f of l)c=e.apply(c,f);if(n&&c.pendingDefenderSelection.length===0&&!c.hasPendingProgressCardDiscardAny){let f=c.dice?.total??0;if(f!==7&&f>0){let T=Jt(e,c,f);for(let R of T)c=e.apply(c,R),l.push(R);if(c.options.fisherman){let R=Hn(e,r,c,f);for(let O of R)c=e.apply(c,O),l.push(O)}}c=m(c,{pendingResourceResolution:!1})}return{success:!0,game:c,events:l}}E(nu,"executeSelectDefenderProgress");function iu(e,r){let t=[];if(!e.board.barbarians)return t;let o=e.board.barbarians.position+1;if(t.push(y.barbarianAdvance(r,o)),o>=7){let n=e.getVertexBuildings().filter(a=>a.isCity).length;if(e.options.ckNastyBarbarians&&n>0)t.push(y.awaitKnightCommitment(r,n));else{let a=om(e,r);t.push(...a)}}return t}E(iu,"advanceBarbarians");function KA(e){let r=0;for(let t of e.values())t>r&&(r=t);return r===0?[]:[...e.entries()].filter(([,t])=>t===r).map(([t])=>t)}E(KA,"getStrongestDefenders");function WA(e,r){let t=[];for(let o of r){let i=Oi(e,o);i.length===1&&t.push(y.cityPillaged(o,i[0]))}return t}E(WA,"emitAutoPillageEvents");function JA(e){let r=[];if(e.scienceProgressDeck.length>0&&r.push(K.CITY_IMPROVEMENT_TRACK_SCIENCE),e.politicsProgressDeck.length>0&&r.push(K.CITY_IMPROVEMENT_TRACK_POLITICS),e.tradeProgressDeck.length>0&&r.push(K.CITY_IMPROVEMENT_TRACK_TRADE),r.length===1)return r[0]}E(JA,"getSingleAvailableProgressDeck");function om(e,r){let t=[],i=e.getVertexBuildings().filter(f=>f.isCity).length,n=e.board.knights.filter(f=>f.isActive),a=n.reduce((f,T)=>f+T.strengthValue,0);if(i===0)return t.push(y.barbarianAttack(r,0,a,!1)),t.push(y.knightsDeactivated(r)),t;let s=a<i,u=new Map;for(let f of e.turnOrder){let R=n.filter(O=>O.owner===f).reduce((O,I)=>O+I.strengthValue,0);u.set(f,R)}let l=s?c_(e,u):void 0,c=s?void 0:KA(u);return t.push(y.barbarianAttack(r,i,a,s,l,c&&c.length>0?c:void 0)),s?t.push(...WA(e,l??[])):c&&c.length===1&&t.push(y.defenderOfCatan(c[0])),t.push(y.knightsDeactivated(r)),t}E(om,"resolveBarbarianAttack");function qA(e,r,t,o,i){let n=[];if(!t.pendingKnightCommitment)return{success:!1,error:"No pending knight commitment",game:t,events:[]};let a=t.pendingKnightCommitment,s=y.commitKnightsToDefense(o,i);n.push(s);let u=e.apply(t,s);if(!u.pendingKnightCommitment){let l=m(t,{pendingKnightCommitment:{...a,committedKnights:[...a.committedKnights,...i],playersCommitted:[...a.playersCommitted,o]}}),c=am(l,o);for(let T of c)u=e.apply(u,T),n.push(T);if(t.pendingResourceResolution&&!u.pendingCityPillage&&u.pendingDefenderSelection.length===0){let T=u.dice?.total??0;if(T!==7&&T>0){let R=Jt(e,u,T);for(let O of R)u=e.apply(u,O),n.push(O);if(u.options.fisherman){let O=Hn(e,r,u,T);for(let I of O)u=e.apply(u,I),n.push(I)}}u=m(u,{pendingResourceResolution:!1})}}return{success:!0,game:u,events:n}}E(qA,"executeCommitKnightsToDefense");function am(e,r){let t=[];if(!e.pendingKnightCommitment)return t;let o=e.pendingKnightCommitment.committedKnights,i=e.pendingKnightCommitment.barbarianStrength,n=0,a=new Map;for(let c of e.turnOrder)a.set(c,0);for(let c of o){let f=e.board.getKnightAt(c);if(f){n+=f.strengthValue;let T=a.get(f.owner)??0;a.set(f.owner,T+f.strengthValue)}}if(i===0)return t.push(y.barbarianAttack(r,0,n,!1)),t.push(y.knightsDeactivated(r)),t;let s=n<i,u=s?c_(e,a):void 0,l=s?void 0:KA(a);return t.push(y.barbarianAttack(r,i,n,s,u,l&&l.length>0?l:void 0)),s?t.push(...WA(e,u??[])):l&&l.length===1&&t.push(y.defenderOfCatan(l[0])),t.push(y.knightsDeactivated(r)),t}E(am,"resolveNastyBarbarianAttack");function ZA(e,r,t){if(!e.options.trolls||!t||t!==6&&t!==8||e.board.hasTroll(r))return e;let i=[...e.board.getTrolls(),r],n=pe(e.board,{trolls:i});return m(e,{board:n})}E(ZA,"spawnTrollOnRevealedHex");function XA(e,r,t,o,i){let n=r.options.fogReward;if(!(n>0&&(r.options.fogBonusDuringSetup||!r.isSetupPhase)))return r;let s=r;if(o.revealedTerrain===d.TERRAIN_GOLD){let u=y.freeResourceGranted(t,Ir.FREE_RESOURCE_REASON_GOLD_TILE_DISCOVERY,n);i.push(u),s=e.apply(s,u)}else if(o.rewardResource!==void 0){let u=new Map([[o.rewardResource,n]]),l=y.receiveResources(t,u);i.push(l),s=e.apply(s,l)}return s}E(XA,"grantFogReward");function zA(e){let r=[],t=e.board.getTiles().filter(i=>i.isFog).map(i=>i.location).sort(_.compare),o=e;for(let i of t){let n=o.revealFogHex(i);r.push({hex:n.hexLocation,terrain:n.revealedTerrain,number:n.revealedNumber});let a=[...o.fogTerrainBank],s=a.indexOf(n.revealedTerrain);s!==-1&&a.splice(s,1);let u=[...o.fogNumberBank];if(n.revealedNumber){let l=u.indexOf(n.revealedNumber);l!==-1&&u.splice(l,1)}o=m(o,{fogTerrainBank:a,fogNumberBank:u})}return r}E(zA,"computeInitialFogReveals");function ou(e,r,t,o){let i=[],n=r,a=o.getHexCenters();for(let s of a){let u=n.board.getTile(s);if(u&&u.isFog){let l=n.revealFogHex(s),c=y.revealFog(t,l.hexLocation,l.revealedTerrain,l.revealedNumber,l.rewardResource);i.push(c),n=e.apply(n,c),n=XA(e,n,t,l,i),n=ZA(n,s,l.revealedNumber)}}return{game:n,events:i}}E(ou,"revealFogAdjacentToVertex");function Pn(e,r,t,o){let i=[],n=r,a=o.getFourTouchingCenters();for(let s of a){let u=n.board.getTile(s);if(u&&u.isFog){let l=n.revealFogHex(s),c=y.revealFog(t,l.hexLocation,l.revealedTerrain,l.revealedNumber,l.rewardResource);i.push(c),n=e.apply(n,c),n=XA(e,n,t,l,i),n=ZA(n,s,l.revealedNumber)}}return{game:n,events:i}}E(Pn,"revealFogAdjacentToEdge");function $A(e,r){if(e.options.dynamicHexMode!==kt.DYNAMIC_HEX_MODE_DESERTIFICATION)return{events:[],allDesert:!1};let t=new Set;for(let a of e.board.getTiles())a.isDesert&&t.add(a.location.toString());let o=!1;for(let a of e.board.getTiles())if(a.isProductiveLand){for(let s of a.location.getAllNeighbors())if(t.has(s.toString())){o=!0;break}if(o)break}if(!o)return{events:[],allDesert:!1};let i=[y.tilesDesertified(r)],n=!0;for(let a of e.board.getTiles())if(!(a.terrain===d.TERRAIN_SEA||a.terrain===d.TERRAIN_UNSPECIFIED||a.terrain===d.TERRAIN_FOG)&&!(a.terrain===d.TERRAIN_LAKE_A||a.terrain===d.TERRAIN_LAKE_B)&&a.isProductiveLand){let s=!1;for(let u of a.location.getAllNeighbors())if(t.has(u.toString())){s=!0;break}if(s){if(!a.numbers.some(l=>l===2||l===12)){n=!1;break}}else{n=!1;break}}return{events:i,allDesert:n}}E($A,"executeDesertification");var Zl=0xffffffffffffffffn;function QA(e){let r=e+0x9e3779b97f4a7c15n&Zl;return r=(r^r>>30n)*0xbf58476d1ce4e5b9n&Zl,r=(r^r>>27n)*0x94d049bb133111ebn&Zl,r^r>>31n}E(QA,"mixSeed");function _m(e,r){return QA(QA(BigInt.asUintN(64,BigInt(e)))^BigInt(r))}E(_m,"mixedRollSeed");var Xl=new Map([[2,1/36],[3,2/36],[4,3/36],[5,4/36],[6,5/36],[7,6/36],[8,5/36],[9,4/36],[10,3/36],[11,2/36],[12,1/36]]),B_=new Map([[2,[[1,1]]],[3,[[1,2],[2,1]]],[4,[[1,3],[2,2],[3,1]]],[5,[[1,4],[2,3],[3,2],[4,1]]],[6,[[1,5],[2,4],[3,3],[4,2],[5,1]]],[7,[[1,6],[2,5],[3,4],[4,3],[5,2],[6,1]]],[8,[[2,6],[3,5],[4,4],[5,3],[6,2]]],[9,[[3,6],[4,5],[5,4],[6,3]]],[10,[[4,6],[5,5],[6,4]]],[11,[[5,6],[6,5]]],[12,[[6,6]]]]),is=class e{static{E(this,"DiceRoller")}static MAX_NO_SEVENS_ATTEMPTS=100;static roll(r,t,o,i,n,a,s){let u=1,l=1,c=n,f=new Map(a),T=new Map(s);if((t.diceMode===br.DICE_MODE_SEEDED||t.diceMode===br.DICE_MODE_SEEDED_MIXED)&&t.diceSeed!==0)for(let O=0;O<e.MAX_NO_SEVENS_ATTEMPTS;O++){let I=t.diceMode===br.DICE_MODE_SEEDED_MIXED?e.rollSeededMixed(t.diceSeed,c):e.rollSeeded(t.diceSeed,c);if(u=I.die1,l=I.die2,c++,!t.noSevens||u+l!==7)break}else if(t.diceMode===br.DICE_MODE_BALANCED){let O=e.rollBalanced(r,o,i,a,s,t.balancedDiceBounds,t.noSevens);u=O.die1,l=O.die2,c=n+1;let I=u+l;f.set(I,(f.get(I)??0)+1),I===7&&T.set(o,(T.get(o)??0)+1)}else for(let O=0;O<e.MAX_NO_SEVENS_ATTEMPTS&&(u=r.rollDie(),l=r.rollDie(),!(!t.noSevens||u+l!==7));O++);return{die1:u,die2:l,total:u+l,newDiceRollCount:c,newDiceDistribution:f,newSevensPerPlayer:T}}static rollSeeded(r,t){let o=BigInt(r)<<32n|BigInt(t),i=new St(o);return{die1:i.rollDie(),die2:i.rollDie()}}static rollSeededMixed(r,t){let o=new St(_m(r,t));return{die1:o.rollDie(),die2:o.rollDie()}}static rollBalanced(r,t,o,i,n,a=.25,s=!1){let u=s?!1:e.canPlayerRollSeven(t,n,o);for(let l=0;l<100;l++){let c=e.rollBalancedTotal(r,i,a);if(c===7&&!u)continue;let f=B_.get(c),[T,R]=r.pickRandom(f);return{die1:T,die2:R}}for(let l=2;l<=12;l++)if(l!==7){let c=B_.get(l),[f,T]=r.pickRandom(c);return{die1:f,die2:T}}return{die1:3,die2:4}}static rollBalancedTotal(r,t,o=.25){let i=0;for(let l of t.values())i+=l;if(i===0){let l=r.rollDie(),c=r.rollDie();return l+c}let n=new Map,a=0;for(let l=2;l<=12;l++){let f=(t.get(l)??0)/i,T=Xl.get(l),R=f-T,O=Math.max(-o,Math.min(o,R)),D=Math.max(0,1-O/o)*T;n.set(l,D),a+=D}let s=r.random()*a,u=0;for(let l=2;l<=12;l++)if(u+=n.get(l),s<=u)return l;return 7}static canPlayerRollSeven(r,t,o,i=2){let n=(t.get(r)??0)+1,a=1/0;for(let s of o){let u=t.get(s)??0;u<a&&(a=u)}return a===1/0&&(a=0),n-a<=i}static getExpectedProbability(r){return Xl.get(r)??0}static getCombinations(r){return B_.get(r)??[]}static getDistributionStats(r){let t=0;for(let i of r.values())t+=i;let o=new Map;for(let i=2;i<=12;i++){let n=r.get(i)??0,a=t>0?n/t:0,s=Xl.get(i),u=a-s;o.set(i,{actual:a,expected:s,deviation:u})}return{totalRolls:t,frequencies:o}}static MAX_NON_SEVEN_REROLL_ATTEMPTS=100;static rollWithEventCards(r,t,o,i,n,a=.25){let s=new Map(i),u=new Map(n),l=!1,c;if(lN(s)){l=!0,c=le.EVENT_CARD_NEW_YEAR;let I=uN(r);s=I.deck,u=I.removed}else c=xd(s,r)??le.EVENT_CARD_BEAUTIFUL_DAY,s=cN(s,c);let f,T;if(c===le.EVENT_CARD_ROBBER_ATTACKS){let I=B_.get(7);[f,T]=r.pickRandom(I)}else{let I=e.rollBalancedNonSeven(r,o,a);f=I.die1,T=I.die2}let R=f+T,O=new Map(o);return O.set(R,(O.get(R)??0)+1),{die1:f,die2:T,total:R,eventCard:c,newDiceRollCount:t+1,newDiceDistribution:O,newEventCardDeck:s,newRemovedEventCards:u,triggeredNewYear:l}}static rollBalancedNonSeven(r,t,o=.25){for(let i=0;i<e.MAX_NON_SEVEN_REROLL_ATTEMPTS;i++){let n=e.rollBalancedTotal(r,t,o);if(n!==7){let a=B_.get(n),[s,u]=r.pickRandom(a);return{die1:s,die2:u}}}return console.warn(`DiceRoller: Exceeded ${e.MAX_NON_SEVEN_REROLL_ATTEMPTS} attempts to roll non-7 with event cards. Defaulting to 4+4.`),{die1:4,die2:4}}};function jA(e,r,t){let o=BigInt(e)<<32n|BigInt(r);return new St(o).pickRandom(t)}E(jA,"pickSeededResource");function yi(e){let r=[];for(let[t,o]of e.hand)for(let i=0;i<o;i++)r.push({kind:"resource",resource:t});for(let[t,o]of e.commodities)for(let i=0;i<o;i++)r.push({kind:"commodity",commodity:t});return r}E(yi,"buildStealableCardPool");function qt(e,r,t,o){let i=yi(r);if(i.length!==0){if(t!==0){let n=BigInt(t)<<32n|BigInt(o);return new St(n).pickRandom(i)}return e.pickRandom(i)}}E(qt,"pickStealableCard");function k_(e,r,t,o,i){let n=Nl(r,o,i);if(n<=0)return{game:r,events:[]};let a=y.receiveGold(t,n,{building:i,edge:o});return{game:e.apply(r,a),events:[a]}}E(k_,"riverGoldForNewEdgePiece");function zl(e,r,t,o,i){let n=Rl(r,o);if(n<=0)return{game:r,events:[]};let a=y.receiveGold(t,n,{building:i,vertex:o});return{game:e.apply(r,a),events:[a]}}E(zl,"riverGoldForNewVertexPiece");function eS(e,r){if(!r.options.rivers)return[];let t=[],o=Ba(e),i=Ba(r);o!==i&&t.push(y.wealthiestTraderChanged(i,o));let n=ka(e),a=ka(r);return n.length===a.length&&n.every(u=>a.includes(u))||t.push(y.poorestTraderChanged(a,n)),t}E(eS,"wealthStatusChangeEvents");function rS(e,r,t,o){let i=[],n=y.buildBridge(t,o);i.push(n);let a=e.apply(r,n);a.longestRoadPlayer!==r.longestRoadPlayer&&i.push(y.awardLongestRoad(a.longestRoadPlayer,r.longestRoadPlayer));let s=k_(e,a,t,o,F.BUILDING_BRIDGE);return a=s.game,i.push(...s.events),{success:!0,game:a,events:i}}E(rS,"executeBuildBridge");function tS(e,r,t,o){let i=y.spendGold(t,Ri,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(tS,"executeBuyResourceWithGold");function nS(e,r,t,o){let i=N_(r,t,o),n=y.buyGold(t,o,i,cl);return{success:!0,game:e.apply(r,n),events:[n]}}E(nS,"executeBuyGold");function $l(e,r){let t=[],o=r;for(let[i,n]of[...o.pendingDiscards]){let a=o.getPlayerState(i);if(!a)continue;let s=a.totalResourcesInHand,u=a.totalCommoditiesInHand;if(s+u===n){let c=new Map(a.hand),f=o.options.citiesAndKnights?new Map(a.commodities):void 0,T=y.discardResources(i,c,f);o=e.apply(o,T),t.push(T)}}return{game:o,events:t}}E($l,"processAutoDiscards");function um(e,r){let t=[],o=r;for(let i of[...o.pendingEarthquake]){let n=o.getEdgeBuildings().filter(a=>a.owner===i&&a.isRoad&&!a.isBrokenRoad);if(n.length===1){let a=n[0].edge,s=y.roadDamaged(i,a);o=e.apply(o,s),t.push(s)}}return{game:o,events:t}}E(um,"processAutoEarthquakeRoads");function Em(e,r){let t=[],o=r;for(let i of[...o.pendingGoodNeighbors]){let n=o.getPlayerState(i);if(!n)continue;let a=o.turnOrder.indexOf(i);if(a===-1)continue;let s=(a+1)%o.turnOrder.length,u=o.turnOrder[s],l=[];for(let[T,R]of n.hand)R>0&&l.push(T);let c=[];if(o.options.citiesAndKnights)for(let[T,R]of n.commodities)R>0&&c.push(T);if(l.length+c.length===1){let T=l.length===1?y.giveEventCardResource(i,u,{resource:l[0]}):y.giveEventCardResource(i,u,{commodity:c[0]});o=e.apply(o,T),t.push(T)}}return{game:o,events:t}}E(Em,"processAutoGoodNeighbors");function lm(e,r){let t=[],o=r;for(let i of[...o.pendingHelpfulNeighbors]){let n=o.getPlayerState(i);if(!n)continue;let a=T_(o,i);if(a.length!==1)continue;let s=a[0],u=[];for(let[f,T]of n.hand)T>0&&u.push(f);let l=[];if(o.options.citiesAndKnights)for(let[f,T]of n.commodities)T>0&&l.push(f);if(u.length+l.length===1){let f=u.length===1?y.giveEventCardResource(i,s,{resource:u[0]}):y.giveEventCardResource(i,s,{commodity:l[0]});o=e.apply(o,f),t.push(f)}}return{game:o,events:t}}E(lm,"processAutoHelpfulNeighbors");function Ql(e,r,t,o){let i=[],n=r,s=new Ni(t).gateTrack;if(!s)return{events:i,updatedGame:n};let u=E(l=>{switch(s){case K.CITY_IMPROVEMENT_TRACK_TRADE:return l.tradeProgressDeck;case K.CITY_IMPROVEMENT_TRACK_POLITICS:return l.politicsProgressDeck;case K.CITY_IMPROVEMENT_TRACK_SCIENCE:return l.scienceProgressDeck}},"getDeck");for(let l of r.turnOrder){let c=r.getPlayerPublicState(l);if(!c)continue;let f=c.cityImprovements;if(!f||r.getCitiesByPlayer(l).length===0||!f.triggersProgressCard(s,o))continue;let R=u(n);if(!R||R.length===0)break;let O=S_(R);if(!O)break;let[I]=O,D=y.drawProgressCard(l,I,s);i.push(D),n=e.apply(n,D)}return{events:i,updatedGame:n}}E(Ql,"handleCityGateProgressCardDraw");function cm(e,r,t,o,i){let n=[],a=t;switch(o){case le.EVENT_CARD_BEAUTIFUL_DAY:case le.EVENT_CARD_NEW_YEAR:break;case le.EVENT_CARD_ROBBER_ATTACKS:{let s=Cn(t);if(s.size>0){a=m(a,{pendingDiscards:s});let u=$l(e,a);a=u.game,n.push(...u.events)}a.pendingDiscards.size===0&&a.board.canTriggerRobberPlacement&&(a=m(a,{pendingRobberOrPiratePlacement:!0}))}break;case le.EVENT_CARD_ROBBER_FLEES:{if(t.board.robbers.length===0||t.board.barbarians&&!t.board.barbarians.canMoveRobber())break;let s=t.board.robbers[0];if(!(t.board.getTile(s)?.terrain===d.TERRAIN_DESERT)){let c=t.board.findFreeDesertForRobber()??Nd,f=y.moveRobber(i,c);n.push(f),a=e.apply(a,f),a=m(a,{pendingRobberStealLocation:null})}}break;case le.EVENT_CARD_EARTHQUAKE:case le.EVENT_CARD_PLENTIFUL_YEAR:case le.EVENT_CARD_GOOD_NEIGHBORS:case le.EVENT_CARD_HELPFUL_NEIGHBOR:case le.EVENT_CARD_TOURNAMENT:case le.EVENT_CARD_CONFLICT:case le.EVENT_CARD_TRADE_ADVANTAGE:case le.EVENT_CARD_CALM_SEAS:case le.EVENT_CARD_EPIDEMIC:break;default:break}return{game:a,events:n}}E(cm,"handleEventCardEffect");function au(e,r,t,o){let i=t.options.isEasyStartActive(t.turnNumber,t.turnOrder.length),n=t.options.eventCards&&t.options.diceMode===br.DICE_MODE_EVENT_CARDS,a,s=t,u=le.EVENT_CARD_UNSPECIFIED,l=t.options.citiesAndKnights&&!i?r.rollEventDie():Ue.EVENT_DIE_RESULT_UNSPECIFIED;if(n){let T=is.rollWithEventCards(r,t.diceRollCount,t.diceDistribution,t.eventCardDeck,t.removedEventCards,t.options.balancedDiceBounds);a=new et(T.die1,T.die2,l,T.eventCard),u=T.eventCard,s=m(t,{diceRollCount:T.newDiceRollCount,diceDistribution:T.newDiceDistribution,eventCardDeck:T.newEventCardDeck,removedEventCards:T.newRemovedEventCards})}else{let T=is.roll(r,t.options,o,t.turnOrder,t.diceRollCount,t.diceDistribution,t.sevensPerPlayer);if(i)for(;T.die1+T.die2===7;)T=is.roll(r,t.options,o,t.turnOrder,T.newDiceRollCount,T.newDiceDistribution,T.newSevensPerPlayer);a=new et(T.die1,T.die2,l),(T.newDiceRollCount!==t.diceRollCount||T.newDiceDistribution.size!==t.diceDistribution.size||T.newSevensPerPlayer.size!==t.sevensPerPlayer.size)&&(s=m(t,{diceRollCount:T.newDiceRollCount,diceDistribution:T.newDiceDistribution,sevensPerPlayer:T.newSevensPerPlayer}))}let c=[];c.push(y.rollDice(o,a)),s=e.apply(s,c[0]);let f=!1;if(l!==Ue.EVENT_DIE_RESULT_UNSPECIFIED)if(l===Ue.EVENT_DIE_RESULT_BARBARIAN_SHIP){let T=iu(s,o);for(let R of T)s=e.apply(s,R),c.push(R),R.type===h.GAME_EVENT_TYPE_BARBARIAN_ATTACK&&(R.barbarianStrength??0)>0&&(f=!0)}else{let T=Ql(e,s,l,a.die1);s=T.updatedGame;for(let R of T.events)c.push(R)}if(f){if(s.pendingDefenderSelection.length>0){let O=JA(s);if(O!==void 0)for(let I of[...s.pendingDefenderSelection]){let D=nu(e,r,s,I,O);D.success&&D.game&&(s=D.game,D.events&&c.push(...D.events))}}if(s.pendingCityPillage!==void 0||s.pendingDefenderSelection.length>0)return{success:!0,game:s,events:c};let R=c.some(O=>O.type===h.GAME_EVENT_TYPE_RESOURCE_DISTRIBUTION);if(a.total!==7&&!R){let O=Jt(e,s,a.total,u);for(let I of O)s=e.apply(s,I),c.push(I);if(s.options.fisherman){let I=Hn(e,r,s,a.total);for(let D of I)s=e.apply(s,D),c.push(D)}}return{success:!0,game:s,events:c}}if(a.total===7){let T=$A(s,o);for(let R of T.events)s=e.apply(s,R),c.push(R);if(T.allDesert){let R=tN(s),O=y.gameWon(R,ht.WIN_REASON_ALL_DESERT);return s=e.apply(s,O),c.push(O),{success:!0,game:s,events:c}}if(t.options.citiesAndKnights){let R=Cn(s);if(R.size>0){s=m(s,{pendingDiscards:R});let O=$l(e,s);s=O.game,c.push(...O.events)}else s.board.canTriggerRobberPlacement&&(s=m(s,{pendingRobberOrPiratePlacement:!0}))}else if(s.pendingDiscards.size>0){let R=$l(e,s);s=R.game,c.push(...R.events)}}else{let T=Jt(e,s,a.total,u);for(let R of T)s=e.apply(s,R),c.push(R);if(t.options.fisherman){let R=Hn(e,r,s,a.total);for(let O of R)s=e.apply(s,O),c.push(O)}}if(u!==le.EVENT_CARD_UNSPECIFIED){let T=cm(e,r,s,u,o);s=T.game;for(let R of T.events)c.push(R);if(s.pendingEarthquake.length>0){let R=um(e,s);s=R.game,c.push(...R.events)}if(s.pendingGoodNeighbors.length>0){let R=Em(e,s);s=R.game,c.push(...R.events)}if(s.pendingHelpfulNeighbors.length>0){let R=lm(e,s);s=R.game,c.push(...R.events)}}return{success:!0,game:s,events:c}}E(au,"executeRollDice");function Jt(e,r,t,o=le.EVENT_CARD_UNSPECIFIED){let i=o===le.EVENT_CARD_EPIDEMIC,n=[],a=r.board.getTilesWithNumber(t),s=new Map,u=new Map,l=new Map,c=new Map,f=new Map,T=E(Y=>{let V=r.getVertexBuildingsOnTile(Y.location);for(let w of V){let J=0;Y.isGold?J=w.isCity&&!i?2:1:Y.resource&&(w.isCity&&r.options.citiesAndKnights?J=i?1:2:J=w.isCity&&!i?2:1),J>0&&f.set(w.owner,(f.get(w.owner)??0)+J)}},"trackBlockedProduction");for(let Y of a){if(r.board.hasRobber(Y.location)){T(Y);continue}if(r.board.hasTroll(Y.location)){T(Y);continue}let V=Y.location.toString(),w=r.getVertexBuildingsOnTile(Y.location);for(let J of w){s.has(J.owner)||s.set(J.owner,new Map);let $=s.get(J.owner);$.has(V)||$.set(V,{hex:Y.location,resources:new Map,commodities:new Map,isGold:Y.isGold,goldCount:0});let he=$.get(V);if(Y.isGold){let Be=J.isCity&&!i?2:1;he.goldCount+=Be,c.set(J.owner,(c.get(J.owner)??0)+Be);continue}let De=Y.resource;if(!De)continue;u.has(J.owner)||u.set(J.owner,new Map);let ve=u.get(J.owner);if(J.isCity&&r.options.citiesAndKnights){let Be=i?void 0:Y.getCommodity();if(Be){ve.set(De,(ve.get(De)??0)+1),he.resources.set(De,(he.resources.get(De)??0)+1),l.has(J.owner)||l.set(J.owner,new Map);let Ye=l.get(J.owner);Ye.set(Be,(Ye.get(Be)??0)+1),he.commodities.set(Be,(he.commodities.get(Be)??0)+1)}else{let Ye=i?1:2;ve.set(De,(ve.get(De)??0)+Ye),he.resources.set(De,(he.resources.get(De)??0)+Ye)}}else{let Be=J.isCity&&!i?2:1;ve.set(De,(ve.get(De)??0)+Be),he.resources.set(De,(he.resources.get(De)??0)+Be)}}}let R=e.calculateResourceDistribution(r.resourceDeck,u),O=r.options.citiesAndKnights?e.calculateCommodityDistribution(r.commodityBank,l):new Map,I=[],D=[];for(let[Y,V]of u){let w=R.get(Y)??new Map;for(let[J,$]of V){let he=w.get(J)??0;if(he===0&&$>0){let De=0;for(let[,ve]of u)(ve.get(J)??0)>0&&De++;De>1&&!I.includes(J)&&I.push(J)}else he<$&&he>0&&D.push(new Qa(J,Y,$,he))}}let g=[],k=new Set;for(let[Y,V]of s){let w=[],J=R.get(Y)??new Map,$=O.get(Y)??new Map,he=new Map(J),De=new Map($);for(let[,ve]of V){let Be=new Map,Ye=new Map;for(let[He,Xr]of ve.resources){let Fr=he.get(He)??0,Lr=Math.min(Xr,Fr);Lr>0&&(Be.set(He,Lr),he.set(He,Fr-Lr))}for(let[He,Xr]of ve.commodities){let Fr=De.get(He)??0,Lr=Math.min(Xr,Fr);Lr>0&&(Ye.set(He,Lr),De.set(He,Fr-Lr))}let Or=Be.size>0||Ye.size>0,Fe=ve.goldCount>0;(Or||Fe)&&(Fe?w.push(xn.forGold(ve.hex,ve.goldCount)):w.push(xn.forResources(ve.hex,Be,Ye)),k.add(Y))}w.length>0&&g.push(new wn(Y,w))}if(r.options.fisherman){let Y=r.board.getFisheriesWithNumber(t),V=new Map;for(let w of Y){let J=w.getFishingVertices();for(let $ of J){let he=r.board.getVertexBuilding($);if(he){let De=he.owner,ve=he.isCity?2:1;V.has(De)||V.set(De,new Map);let Be=V.get(De),Ye=w.hex.toString();Be.has(Ye)||Be.set(Ye,{hex:w.hex,count:0}),Be.get(Ye).count+=ve}}}for(let[w,J]of V){let $=[];for(let[,De]of J){let ve=new Map([[Se.FISH_ONE_FISH,De.count]]);$.push(xn.forFish(De.hex,ve))}let he=g.find(De=>De.player===w);if(he){let De=[...he.hexProduction,...$],ve=g.indexOf(he);g[ve]=new wn(w,De)}else g.push(new wn(w,$))}}let v=new Pi(t,g,I,D,f);n.push(y.resourceDistributionEvent(r.currentPlayer,v));for(let Y of g)k.add(Y.player);for(let[Y,V]of c)V>0&&(n.push(y.goldProduced(Y,V)),n.push(y.freeResourceGranted(Y,Ir.FREE_RESOURCE_REASON_GOLD_TILE,V)),k.add(Y));if(r.options.citiesAndKnights)for(let Y of r.getPlayerPublicStates())Y.cityImprovements?.hasAqueduct&&!k.has(Y.player)&&(n.push(y.aqueductTriggered(Y.player)),n.push(y.freeResourceGranted(Y.player,Ir.FREE_RESOURCE_REASON_AQUEDUCT,1)));return n.push(...fm(r,t)),n}E(Jt,"distributeResources");function fm(e,r){if(e.options.robberMode!==zr.ROBBER_MODE_LAZY)return[];let t=[],o=[...e.board.robbers];for(let i of e.board.robbers){let n=e.board.getTile(i);if(!n||!n.hasNumber(r))continue;let a=e.board.getTiles().find(u=>u.terrain===d.TERRAIN_DESERT&&!o.some(l=>l.equals(u.location)));t.push(y.lazyRobberRetreat(e.currentPlayer,i,a?.location));let s=o.findIndex(u=>u.equals(i));s!==-1&&o.splice(s,1),a&&o.push(a.location)}return t}E(fm,"createLazyRobberRetreatEvents");function Hn(e,r,t,o){let i=[],n=t.board.getFisheriesWithNumber(o),a=new Map;for(let f of n){let T=f.getFishingVertices();for(let R of T){let O=t.board.getVertexBuilding(R);if(O){let I=O.owner,D=O.isCity?2:1;a.set(I,(a.get(I)??0)+D)}}}let s=0;for(let f of a.values())s+=f;let u=0;for(let f of t.fishBank.values())u+=f;let l=a.size;if(l===0||s===0)return i;let c=t;if(l===1){let[[f,T]]=Array.from(a.entries()),R=Math.min(T,u);if(R>0){let O=iS(e,r,c,f,R);c=O.game,i.push(...O.events)}}else if(u>=s){for(let[f,T]of a)if(T>0){let R=iS(e,r,c,f,T);c=R.game,i.push(...R.events)}}return i}E(Hn,"distributeFish");function iS(e,r,t,o,i){let n=[],a=t,s=a.getPlayerState(o);if(!s)return{events:n,game:a};let u=s.totalFishTiles,c=Math.max(0,_N-u),f=Math.min(i,c),T=i-f;if(f>0){let R=oS(r,a,f);if(R.size>0){let O=y.receiveFish(o,R);n.push(O),a=e.apply(a,O)}}if(T>0){let R=a.getPlayerState(o)?.fishTiles??s.fishTiles,O=Tm(R,T);if(O.size>0){let I=oS(r,a,T);if(I.size>0){let D=y.exchangeFish(o,I,O);n.push(D),a=e.apply(a,D)}}}return{events:n,game:a}}E(iS,"distributeFishToPlayer");function Tm(e,r){let t=new Map,o=r,i=[Se.FISH_ONE_FISH,Se.FISH_TWO_FISH,Se.FISH_THREE_FISH];for(let n of i){if(o<=0)break;let a=e.get(n)??0,s=Math.min(a,o);s>0&&(t.set(n,s),o-=s)}return t}E(Tm,"selectLowestValueFish");function oS(e,r,t){let o=[];for(let[a,s]of r.fishBank)for(let u=0;u<s;u++)o.push(a);if(o.length===0)return new Map;let i=Math.min(t,o.length),n=new Map;for(let a=0;a<i;a++){let s=e.pickRandom(o),u=o.indexOf(s);u>-1&&o.splice(u,1),n.set(s,(n.get(s)??0)+1)}return n}E(oS,"drawFishFromBank");function Nm(e){let r=0;for(let t of e.values())r+=t;return r}E(Nm,"countResources");function aS(e,r,t,o){let i=[],n=r.getEdgeBuilding(o)!==void 0,a=y.buildRoad(t,o);i.push(a);let s=e.apply(r,a);if(s.longestRoadPlayer!==r.longestRoadPlayer){let l=y.awardLongestRoad(s.longestRoadPlayer,r.longestRoadPlayer);i.push(l)}if(!n){let l=k_(e,s,t,o,F.BUILDING_ROAD);s=l.game,i.push(...l.events)}let u=Pn(e,s,t,o);return s=u.game,i.push(...u.events),{success:!0,game:s,events:i}}E(aS,"executeBuildRoad");function sS(e,r,t,o){let i=[],n=!1;r.options.newIslandSettlementBonus>0&&(n=!ZT(r.board,o,t,r.options.desertsBlockIslands));let a=y.buildSettlement(t,o);i.push(a);let s=e.apply(r,a),u=zl(e,s,t,o,F.BUILDING_SETTLEMENT);if(s=u.game,i.push(...u.events),s.longestRoadPlayer!==r.longestRoadPlayer){let c=y.awardLongestRoad(s.longestRoadPlayer,r.longestRoadPlayer);i.push(c)}if(r.options.harbormaster&&s.harbormasterPlayer!==r.harbormasterPlayer){let c=y.awardHarbormaster(s.harbormasterPlayer,r.harbormasterPlayer);i.push(c)}if(n){let c=y.newIslandSettlement(t,r.options.newIslandSettlementBonus);i.push(c),s=e.apply(s,c)}let l=ou(e,s,t,o);return s=l.game,i.push(...l.events),{success:!0,game:s,events:i}}E(sS,"executeBuildSettlement");function _S(e,r,t,o){let i=[],n=y.buildCity(t,o);i.push(n);let a=e.apply(r,n);if(r.options.harbormaster&&a.harbormasterPlayer!==r.harbormasterPlayer){let u=y.awardHarbormaster(a.harbormasterPlayer,r.harbormasterPlayer);i.push(u)}let s=ou(e,a,t,o);return a=s.game,i.push(...s.events),{success:!0,game:a,events:i}}E(_S,"executeBuildCity");function jl(e,r,t){let o=BigInt(e)<<32n|BigInt(r);return new St(o).pickRandom(t)}E(jl,"pickSeededDevCard");function dS(e,r,t,o){let i;switch(o){case K.CITY_IMPROVEMENT_TRACK_SCIENCE:i=r.scienceProgressDeck;break;case K.CITY_IMPROVEMENT_TRACK_POLITICS:i=r.politicsProgressDeck;break;case K.CITY_IMPROVEMENT_TRACK_TRADE:i=r.tradeProgressDeck;break;default:return{success:!1,error:"Invalid progress card track"}}if(i.length===0)return{success:!1,error:"Selected progress card deck is empty"};let n=i[0],a=y.buyProgressCard(t,o,n);return{success:!0,game:e.apply(r,a),events:[a]}}E(dS,"executeBuyProgressCard");function uS(e,r,t,o){let i=[];for(let[l,c]of t.devCardDeck)for(let f=0;f<c;f++)i.push(l);if(i.length===0)return{success:!1,error:"No dev cards left in deck"};let n,a=t.devCardDrawCount;t.options.devCardSeed!==0?(n=jl(t.options.devCardSeed,t.devCardDrawCount,i),a=t.devCardDrawCount+1):n=r.pickRandom(i);let s=y.buyDevCard(o,n),u=e.apply(t,s);return t.options.devCardSeed!==0&&(u=m(u,{devCardDrawCount:a})),{success:!0,game:u,events:[s]}}E(uS,"executeBuyDevCard");function ec(e,r,t,o=Date.now()){let i=[],n;if(r.options.timerConfig.isEnabled()&&r.timerState){let s=r.timerState.getPlayerTimer(t);s&&s.isRunning()&&(n=o-s.clockStartedAt)}if(r.options.citiesAndKnights&&!r.isSetupPhase&&(r.getPlayerPublicState(t)?.progressCardCount??0)>xt){let u=y.progressCardDiscardRequired(t);return{success:!0,game:e.apply(r,u),events:[u]}}if(r.isSecondSettlerPhase){let s=y.endSecondSettlerTurn(t);i.push(s);let u=e.apply(r,s);if(r.options.timerConfig.isEnabled()&&r.timerState){let l=u.currentPlayer,c=za(r,t,l,o);u=$a(u,c)}return{success:!0,game:u,events:i}}if(r.options.isSecondSettlerActive(r.turnOrder.length)){let s=r.options.getPairedPlayer(t,r.turnOrder);if(s){let u=y.startSecondSettlerTurn(t,s);return i.push(u),{success:!0,game:e.apply(r,u),events:i}}}i.push(y.endTurn(t,n));let a=e.apply(r,i[0]);if(r.options.timerConfig.isEnabled()&&r.timerState){let s=a.currentPlayer,u=za(r,t,s,o);a=$a(a,u)}return{success:!0,game:a,events:i}}E(ec,"executeEndTurn");function ES(e,r,t,o,i,n=Date.now()){let a=y.discardResources(t,o,i),s=e.apply(r,a);if(s.pendingDiscards.size===0&&r.options.rushMode&&!r.isSetupPhase){let u=n+r.options.rushDiceIntervalSeconds*1e3;a=On.fromEvent(a).setRushNextDiceRollAt(u).build(),s=e.apply(r,a)}if(r.options.timerConfig.isChessClock()&&r.timerState){let u=Array.from(s.pendingDiscards.keys()),l=SN(r,t,u,r.currentPlayer,n);s=$a(s,l)}return{success:!0,game:s,events:[a]}}E(ES,"executeDiscardResources");function lS(e,r,t,o,i){let n=y.moveRobber(o,i),a=e.apply(t,n),s=[n];if(t.pendingBishopSteal!==void 0){let l=i.getAllVerticies(),c=new Set;for(let f of l){let T=a.board.getVertexBuilding(f);T&&T.owner!==o&&c.add(T.owner)}for(let f of c){let T=a.getPlayerState(f);if(!T)continue;let R=yi(T);if(R.length===0)continue;let O=r.pickRandom(R),I=O.kind==="resource"?y.stealResource(o,f,O.resource):y.stealCommodity(o,f,O.commodity);a=e.apply(a,I),s.push(I)}return{success:!0,game:a,events:s}}let u=wa(a,i,o);if(u.length===1){let l=u[0],c=a.getPlayerState(l);if(c){let f=qt(r,c,t.options.stealSeed,t.stealCount);if(f){t.options.stealSeed!==0&&(a=m(a,{stealCount:t.stealCount+1}));let T=f.kind==="resource"?y.stealResource(o,l,f.resource):y.stealCommodity(o,l,f.commodity);a=e.apply(a,T),s.push(T)}}}return u.length===0&&a.pendingRobberStealLocation&&(a=m(a,{pendingRobberStealLocation:null})),{success:!0,game:a,events:s}}E(lS,"executeMoveRobber");function rc(e,r,t,o,i){let n=t.getPlayerState(i),a=n?n.totalResourcesInHand+n.totalCommoditiesInHand:0;if(!n||a===0){let c=t.pendingRobberStealLocation;if(c){let f=wa(t,c,o);if(f.length===0)return{success:!0,game:m(t,{pendingRobberStealLocation:null}),events:[]};let T=f.length===1?f[0]:r.pickRandom(f);return rc(e,r,t,o,T)}return{success:!1,error:"Target has no cards"}}let s=qt(r,n,t.options.stealSeed,t.stealCount);if(!s)return{success:!1,error:"Target has no cards"};let u=s.kind==="resource"?y.stealResource(o,i,s.resource):y.stealCommodity(o,i,s.commodity),l=e.apply(t,u);return t.options.stealSeed!==0&&(l=m(l,{stealCount:t.stealCount+1})),{success:!0,game:l,events:[u]}}E(rc,"executeStealFromPlayer");function cS(e,r,t,o){let i=y.selectFreeResource(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(cS,"executeSelectFreeResource");function fS(e,r,t,o){let i=[],n=r.getEdgeBuilding(o)!==void 0,a=y.placeFreeStructure(t,F.BUILDING_ROAD,o);i.push(a);let s=e.apply(r,a);if(s.longestRoadPlayer!==r.longestRoadPlayer){let l=y.awardLongestRoad(s.longestRoadPlayer,r.longestRoadPlayer);i.push(l)}if(!n){let l=k_(e,s,t,o,F.BUILDING_ROAD);s=l.game,i.push(...l.events)}let u=Pn(e,s,t,o);return s=u.game,i.push(...u.events),{success:!0,game:s,events:i}}E(fS,"executePlaceFreeRoad");function TS(e,r,t,o){let i=[],n=r.getSettlementsByPlayer(t).length,a=r.getCitiesByPlayer(t).length,u=n+a===1,l=u?r.options.secondFound:r.options.firstFound,c=y.placeFreeStructure(t,l,void 0,o);i.push(c);let f=e.apply(r,c),T=zl(e,f,t,o,l);f=T.game,i.push(...T.events);let R=ou(e,f,t,o);if(f=R.game,i.push(...R.events),u){let O=o.getHexCenters(),I=new Map;for(let D of O){let g=f.board.getTile(D);g&&g.resource&&I.set(g.resource,(I.get(g.resource)??0)+1)}if(Nm(I)>0){let D=y.receiveResources(t,I);i.push(D),f=e.apply(f,D)}}return{success:!0,game:f,events:i}}E(TS,"executePlaceInitialSettlement");function NS(e,r,t,o){let i=[],n=y.placeFreeStructure(t,F.BUILDING_ROAD,o);i.push(n);let a=e.apply(r,n),s=k_(e,a,t,o,F.BUILDING_ROAD);a=s.game,i.push(...s.events);let u=Pn(e,a,t,o);return a=u.game,i.push(...u.events),{success:!0,game:a,events:i}}E(NS,"executePlaceInitialRoad");function RS(e,r,t,o){let i=[],n=y.placeFreeStructure(t,F.BUILDING_SHIP,o);i.push(n);let a=e.apply(r,n),s=Pn(e,a,t,o);return a=s.game,i.push(...s.events),{success:!0,game:a,events:i}}E(RS,"executePlaceInitialShip");function tc(e,r){if(e.options.citiesAndKnights){let o=e.scienceProgressDeck[0];if(o!==void 0&&o!==b.PROGRESS_CARD_UNSPECIFIED)return e}let t=e;if(t.options.citiesAndKnights){let o=A_(qa(K.CITY_IMPROVEMENT_TRACK_SCIENCE),()=>r.random()),i=A_(qa(K.CITY_IMPROVEMENT_TRACK_POLITICS),()=>r.random()),n=A_(qa(K.CITY_IMPROVEMENT_TRACK_TRADE),()=>r.random());t=m(t,{scienceProgressDeck:o,politicsProgressDeck:i,tradeProgressDeck:n})}if(t.options.eventCards&&t.options.diceMode===br.DICE_MODE_EVENT_CARDS&&t.removedEventCards.size===0){let{deck:o,removed:i}=EN(t.eventCardDeck,r);t=m(t,{eventCardDeck:o,removedEventCards:i})}if(t.options.citiesAndKnights&&!t.board.barbarians){let o=t.board.toBuilder().withBarbarians(Nt.createInitial()).build();t=m(t,{board:o})}return t}E(tc,"initializeGameDecks");function AS(e,r,t,o,i,n){let a,s=t.stealCount;if(i&&n){let f=t.getPlayerState(n);if(f&&f.totalResourcesInHand>0){let T=[];for(let[R,O]of f.hand)for(let I=0;I<O;I++)T.push(R);t.options.stealSeed!==0?(a=jA(t.options.stealSeed,t.stealCount,T),s=t.stealCount+1):a=r.pickRandom(T)}}let u=y.playKnight(o,i,n,a),l=e.apply(t,u);t.options.stealSeed!==0&&s!==t.stealCount&&(l=m(l,{stealCount:s}));let c=[u];if(l.largestArmyPlayer!==t.largestArmyPlayer){let f=y.awardLargestArmy(l.largestArmyPlayer,t.largestArmyPlayer);c.push(f)}return{success:!0,game:l,events:c}}E(AS,"executePlayKnight");function SS(e,r,t){let o=y.playRoadBuilding(t);return{success:!0,game:e.apply(r,o),events:[o]}}E(SS,"executePlayRoadBuilding");function OS(e,r,t){let o=y.playYearOfPlenty(t),i=e.apply(r,o),n=y.freeResourceGranted(t,Ir.FREE_RESOURCE_REASON_YEAR_OF_PLENTY,2);return{success:!0,game:i,events:[o,n]}}E(OS,"executePlayYearOfPlenty");function IS(e,r,t,o){let i=[];for(let s of r.getPlayerStates()){if(s.player===t)continue;let u=s.getResourceCount(o);u>0&&i.push({player:s.player,count:u})}let n=y.playMonopoly(t,o,i);return{success:!0,game:e.apply(r,n),events:[n]}}E(IS,"executePlayMonopoly");function CS(e){let r=e.getActiveTrades(),t=r.length>0?Math.max(...r.map(o=>o.id))+1:1;return Math.max(e.nextTradeId,t)}E(CS,"getNextTradeId");function PS(e,r){let t=0;for(let o of e.values())t+=o;for(let o of r?.values()??[])t+=o;return t}E(PS,"countCards");function pS(e,r,t,o){if(t>0&&r.cardCount===0)return!0;let i=e.getPlayerState(r.player)?.gold??r.gold;return o>i}E(pS,"cannotPayRequest");function hS(e,r,t,o,i,n,a,s,u,l){let c=CS(r),f=y.proposeTrade(t,c,o,i,n,a,s,u,l),T=e.apply(r,f),R=[f];if(!l||l===0){let O=PS(i,a);for(let I of r.getPlayerPublicStates())if(I.player!==t&&(pS(r,I,O,u??0)||r.hasEmbargo(I.player,t)||r.hasEmbargo(t,I.player))){let D=y.rejectTrade(I.player,c);R.push(D),T=e.apply(T,D)}}return{success:!0,game:T,events:R}}E(hS,"executeProposeTrade");function DS(e,r,t,o){let i=CS(r),n=o.map(c=>({tradeId:i++,offering:c.offering,requesting:c.requesting,offeringCommodities:c.offeringCommodities,requestingCommodities:c.requestingCommodities,offeringGold:c.offeringGold,requestingGold:c.requestingGold})),a=y.proposeMultiTrade(t,n),s=e.apply(r,a),u=[a],l=n.map(c=>PS(c.requesting,c.requestingCommodities));for(let c of r.getPlayerPublicStates()){if(c.player===t)continue;let f=r.hasEmbargo(c.player,t)||r.hasEmbargo(t,c.player);for(let[T,R]of n.entries()){let O=pS(r,c,l[T],R.requestingGold??0);if(f||O){let I=y.rejectTrade(c.player,R.tradeId);u.push(I),s=e.apply(s,I)}}}return{success:!0,game:s,events:u}}E(DS,"executeProposeMultiTrade");function mS(e,r,t,o){let i=y.acceptTrade(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(mS,"executeAcceptTrade");function gS(e,r,t,o){let i=y.rejectTrade(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(gS,"executeRejectTrade");function yS(e,r,t,o){let i=y.cancelTrade(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(yS,"executeCancelTrade");function MS(e,r,t,o,i){let n=r.getActiveTrade(o);if(!n)return{success:!1,error:`Trade ${o} not found`};let a=y.executeTrade(t,o,i,n.offering,n.requesting,n.offeringCommodities.size>0?n.offeringCommodities:void 0,n.requestingCommodities.size>0?n.requestingCommodities:void 0,n.offeringGold>0?n.offeringGold:void 0,n.requestingGold>0?n.requestingGold:void 0);return{success:!0,game:e.apply(r,a),events:[a]}}E(MS,"executeExecuteTrade");function LS(e,r,t,o,i,n,a){let s=y.tradeWithBank(t,o,i,n,a);return{success:!0,game:e.apply(r,s),events:[s]}}E(LS,"executeTradeWithBank");function GS(e,r,t,o){let n=!r.hasEmbargo(t,o),a=y.tradeEmbargo(t,o,n),s=e.apply(r,a),u=[a];if(n)for(let l of r.getActiveTrades()){if(l.proposer===o&&!l.hasRejectedPlayer(t)){let c=y.rejectTrade(t,l.id);u.push(c),s=e.apply(s,c)}if(l.proposer===t&&!l.hasRejectedPlayer(o)){let c=y.rejectTrade(o,l.id);u.push(c),s=e.apply(s,c)}}return{success:!0,game:s,events:u}}E(GS,"executeToggleTradeEmbargo");function US(e,r,t,o,i){let n=[],a=y.buildShip(o,i);n.push(a);let s=e.apply(t,a);if(s.longestRoadPlayer!==t.longestRoadPlayer){let c=y.awardLongestRoad(s.longestRoadPlayer,t.longestRoadPlayer);n.push(c)}let u=Pn(e,s,o,i);s=u.game,n.push(...u.events);let l=ic(e,r,s,o,i);return l.success?(s=l.game,n.push(...l.events??[]),{success:!0,game:s,events:n}):l}E(US,"executeBuildShip");function BS(e,r,t,o){let i=[],n=y.placeFreeStructure(t,F.BUILDING_SHIP,o);i.push(n);let a=e.apply(r,n);if(a.longestRoadPlayer!==r.longestRoadPlayer){let u=y.awardLongestRoad(a.longestRoadPlayer,r.longestRoadPlayer);i.push(u)}let s=Pn(e,a,t,o);return a=s.game,i.push(...s.events),{success:!0,game:a,events:i}}E(BS,"executePlaceFreeShip");function kS(e,r,t,o,i){let n=[],a=y.moveShip(t,o,i);n.push(a);let s=e.apply(r,a);if(s.longestRoadPlayer!==r.longestRoadPlayer){let l=y.awardLongestRoad(s.longestRoadPlayer,r.longestRoadPlayer);n.push(l)}let u=Pn(e,s,t,i);return s=u.game,n.push(...u.events),{success:!0,game:s,events:n}}E(kS,"executeMoveShip");function bS(e,r,t,o,i){let n=y.movePirate(o,i),a=e.apply(t,n),s=[n],u=md(a,i,o);if(u.length===1){let l=u[0],c=a.getPlayerState(l);if(c){let f=qt(r,c,t.options.stealSeed,t.stealCount);if(f){t.options.stealSeed!==0&&(a=m(a,{stealCount:t.stealCount+1}));let T=f.kind==="resource"?y.stealResourcePirate(o,l,f.resource):y.stealCommodityPirate(o,l,f.commodity);a=e.apply(a,T),s.push(T)}}}return u.length===0&&a.pendingPirateStealLocation&&(a=m(a,{pendingPirateStealLocation:null})),{success:!0,game:a,events:s}}E(bS,"executeMovePirate");function nc(e,r,t,o,i){let n=t.getPlayerState(i),a=n?n.totalResourcesInHand+n.totalCommoditiesInHand:0;if(!n||a===0){let c=t.pendingPirateStealLocation;if(c){let f=md(t,c,o);if(f.length===0)return{success:!0,game:m(t,{pendingPirateStealLocation:null}),events:[]};let T=f.length===1?f[0]:r.pickRandom(f);return nc(e,r,t,o,T)}return{success:!1,error:"Target has no cards"}}let s=qt(r,n,t.options.stealSeed,t.stealCount);if(!s)return{success:!1,error:"Target has no cards"};let u=s.kind==="resource"?y.stealResourcePirate(o,i,s.resource):y.stealCommodityPirate(o,i,s.commodity),l=e.apply(t,u);return t.options.stealSeed!==0&&(l=m(l,{stealCount:t.stealCount+1})),{success:!0,game:l,events:[u]}}E(nc,"executeStealFromPlayerPirate");function ic(e,r,t,o,i){let n=t.board.getEdgeReward(i);if(!n)return{success:!0,game:t,events:[]};switch(n.type){case Tr.EDGE_REWARD_TYPE_VICTORY_POINT:return Om(e,t,o,i);case Tr.EDGE_REWARD_TYPE_DEV_CARD:return Im(e,r,t,o,i);case Tr.EDGE_REWARD_TYPE_PORT:return Cm(e,t,o,i,n);default:return{success:!0,game:t,events:[]}}}E(ic,"executeEdgeReward");function Om(e,r,t,o){let i=y.collectEdgeVp(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(Om,"executeCollectEdgeVp");function Im(e,r,t,o,i){let n=[];for(let[c,f]of t.devCardDeck)for(let T=0;T<f;T++)n.push(c);if(n.length===0){let c=y.collectEdgeDevCard(o,i,ie.DEV_CARD_UNSPECIFIED);return{success:!0,game:e.apply(t,c),events:[c]}}let a,s=t.devCardDrawCount;t.options.devCardSeed!==0?(a=jl(t.options.devCardSeed,t.devCardDrawCount,n),s=t.devCardDrawCount+1):a=r.pickRandom(n);let u=y.collectEdgeDevCard(o,i,a),l=e.apply(t,u);return t.options.devCardSeed!==0&&(l=m(l,{devCardDrawCount:s})),{success:!0,game:l,events:[u]}}E(Im,"executeCollectEdgeDevCard");function Cm(e,r,t,o,i){let n=[];if(!i.port)throw new Error("Port edge reward must have a port");let a=y.collectEdgePort(t,o,i.port);n.push(a);let s=e.apply(r,a),u=yl(s,t,i.port);if(u.length===0)s=hR(s,t,i.port);else{let l=u[0],c=y.placePort(t,l,i.port);n.push(c),s=e.apply(s,c)}return{success:!0,game:s,events:n}}E(Cm,"executeCollectEdgePort");function oc(e,r,t){let o=[],i=r,n=i.getPlayerState(t);if(!n||n.heldPorts.length===0)return{success:!0,game:i,events:o};for(let a of n.heldPorts){let s=yl(i,t,a);if(s.length>0){let u=s[0],l=y.placePort(t,u,a);o.push(l),i=e.apply(i,l);break}}return{success:!0,game:i,events:o}}E(oc,"executeCheckHeldPorts");function vS(e,r,t,o){let i=r.pendingKnights.find(u=>u.player===t),n=i?i.strength:Pe.KNIGHT_STRENGTH_BASIC,a=y.buildKnight(t,o,n);return{success:!0,game:e.apply(r,a),events:[a]}}E(vS,"executeBuildKnight");function YS(e,r,t,o){let i=y.activateKnight(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(YS,"executeActivateKnight");function FS(e,r,t,o){let i=r.board.getKnightAt(o);if(!i)return{success:!1,error:"No knight at this vertex"};let n=i.nextStrength,a=y.promoteKnight(t,o,n);return{success:!0,game:e.apply(r,a),events:[a]}}E(FS,"executePromoteKnight");function VS(e,r,t,o,i){let n=r.board.getKnightAt(i);if(n&&n.owner!==t){let u=Ii(r,n.owner,i);if(u.length===1){let c=y.displaceKnight(t,o,i,n.owner,u[0]);return{success:!0,game:e.apply(r,c),events:[c]}}let l=y.displaceKnight(t,o,i,n.owner,void 0);return{success:!0,game:e.apply(r,l),events:[l]}}let a=y.moveKnight(t,o,i);return{success:!0,game:e.apply(r,a),events:[a]}}E(VS,"executeMoveKnight");function xS(e,r,t,o,i,n,a,s){let u=o,l=wa(u,n,i),c=a!==void 0&&l.includes(a)?a:void 0;if(c===void 0&&l.length===1&&(c=l[0]),c===void 0)return l.length===0&&u.pendingRobberStealLocation&&(u=m(u,{pendingRobberStealLocation:null})),u;let f=u.getPlayerState(c);if(!f)return u;let T=qt(r,f,t.options.stealSeed,t.stealCount);if(!T)return u;let R=T.kind==="resource"?y.stealResource(i,c,T.resource):y.stealCommodity(i,c,T.commodity);return u=e.apply(u,R),s.push(R),t.options.stealSeed!==0&&(u=m(u,{stealCount:t.stealCount+1})),u}E(xS,"resolveRobberSteal");function wS(e,r,t,o,i,n,a){let s=[],u=y.chaseRobber(o,i,n),l=e.apply(t,u);return s.push(u),l=xS(e,r,t,l,o,n,a,s),{success:!0,game:l,events:s}}E(wS,"executeChaseRobberWithKnight");function HS(e,r,t,o,i,n,a){let s=[],u=y.useKnightErrant(o,i,n),l=e.apply(t,u);return s.push(u),l=xS(e,r,t,l,o,n,a,s),{success:!0,game:l,events:s}}E(HS,"executeUseKnightErrant");function KS(e,r,t,o){let i=y.buildCityWall(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(KS,"executeBuildCityWall");function WS(e,r,t,o){let i=[],n=r.getPlayerPublicState(t);if(!n)return{success:!1,error:"Player state not found"};let s=(n.cityImprovements?.getLevel(o)??0)+1,u=y.buildCityImprovement(t,o,s),l=e.apply(r,u);if(i.push(u),s===4){let c=Qd(l,t,o);c.type==="auto"?(l=e.apply(l,c.event),i.push(c.event)):c.type==="pending"&&(l=e.applyPendingMetropolisPlacement(l,c.pending))}if(s===5){let c=jd(l,t,o);c.type==="auto"?(l=e.apply(l,c.event),i.push(c.event)):c.type==="pending"&&(l=e.applyPendingMetropolisPlacement(l,c.pending))}return{success:!0,game:l,events:i}}E(WS,"executeBuildCityImprovement");function JS(e,r,t,o){let i=r.pendingMetropolisPlacement;if(!i)return{success:!1,error:"No pending metropolis placement"};if(i.player!==t)return{success:!1,error:"Not your turn to select metropolis city"};let n=y.selectMetropolisCity(t,o,i.track);return{success:!0,game:e.apply(r,n),events:[n]}}E(JS,"executeSelectMetropolisCity");function qS(e,r,t){let o=y.playAlchemist(t);return{success:!0,game:e.apply(r,o),events:[o]}}E(qS,"executePlayAlchemist");function ZS(e,r,t,o,i,n){let a=t.options.citiesAndKnights?r.rollEventDie():Ue.EVENT_DIE_RESULT_UNSPECIFIED,s=new et(i,n,a),u=[],l=m(t,{pendingAlchemist:null});if(u.push(y.rollDice(o,s)),l=e.apply(l,u[0]),a!==Ue.EVENT_DIE_RESULT_UNSPECIFIED)if(a===Ue.EVENT_DIE_RESULT_BARBARIAN_SHIP){let c=iu(l,o);for(let f of c)l=e.apply(l,f),u.push(f)}else{let c=Ql(e,l,a,s.die1);l=c.updatedGame,u.push(...c.events)}if(s.total!==7){let c=Jt(e,l,s.total);for(let f of c)l=e.apply(l,f),u.push(f)}return{success:!0,game:l,events:u}}E(ZS,"executeSelectAlchemistDice");function XS(e,r,t){let o=y.playEngineer(r);return{success:!0,game:t.apply(e,o),events:[o]}}E(XS,"executePlayEngineer");function zS(e,r,t){let o=y.playCrane(r);return{success:!0,game:t.apply(e,o),events:[o]}}E(zS,"executePlayCrane");function $S(e,r,t){let o=y.playMedicine(r);return{success:!0,game:t.apply(e,o),events:[o]}}E($S,"executePlayMedicine");function QS(e,r,t){let o=Dm(e,r),i=y.playMining(r,o);return{success:!0,game:t.apply(e,i),events:[i]}}E(QS,"executePlayMining");function jS(e,r,t){let o=mm(e,r),i=y.playIrrigation(r,o);return{success:!0,game:t.apply(e,i),events:[i]}}E(jS,"executePlayIrrigation");function eO(e,r,t,o,i){let n=y.playInventor(t,o,i);return{success:!0,game:e.apply(r,n),events:[n]}}E(eO,"executePlayInventor");function rO(e,r,t){let o=y.playProgressRoadBuilding(r);return{success:!0,game:t.apply(e,o),events:[o]}}E(rO,"executePlayProgressRoadBuilding");function Dm(e,r){return tO(e,r,d.TERRAIN_MOUNTAINS,S.RESOURCE_ORE)}E(Dm,"calculateMiningResources");function mm(e,r){return tO(e,r,d.TERRAIN_FIELDS,S.RESOURCE_WHEAT)}E(mm,"calculateIrrigationResources");function tO(e,r,t,o){let i=new Set;for(let a of e.getVertexBuildings())if(a.owner===r)for(let s of a.vertex.getHexCenters()){let u=e.board.getTile(s);u&&u.terrain===t&&i.add(s.toString())}let n=new Map;if(i.size>0){let a=e.resourceDeck.get(o)??0;n.set(o,Math.min(i.size*2,a))}return n}E(tO,"calculateTerrainBonus");function nO(e,r,t,o,i){let n=[];if(!i){let T=y.playBishop(o,void 0,[]);return n.push(T),{success:!0,game:e.apply(t,T),events:n}}let a=i.getAllVerticies(),s=new Set;for(let T of a){let R=t.board.getVertexBuilding(T);R&&R.owner!==o&&s.add(R.owner)}let u=[],l=[];for(let T of s){let R=t.getPlayerState(T);if(!R)continue;let O=yi(R);if(O.length===0)continue;let I=r.pickRandom(O);l.push(I.kind==="resource"?{targetPlayer:T,resource:I.resource}:{targetPlayer:T,commodity:I.commodity}),u.push({player:T,count:1})}let c=y.playBishop(o,i,u);n.push(c);let f=e.apply(t,c);for(let T of l){let R=T.resource!==void 0?y.stealResource(o,T.targetPlayer,T.resource):y.stealCommodity(o,T.targetPlayer,T.commodity);n.push(R),f=e.apply(f,R)}return{success:!0,game:f,events:n}}E(nO,"executePlayBishop");function iO(e,r,t){let o=y.playWarlord(r);return{success:!0,game:t.apply(e,o),events:[o]}}E(iO,"executePlayWarlord");function oO(e,r,t){let o=[],i=y.playSmith(r);o.push(i);let n=t.apply(e,i);if(Ha(n,r).length<=2)for(;n.smithFreePromotionsRemaining>0;){let s=Ha(n,r);if(s.length===0)break;let u=s[0],l=n.board.getKnightAt(u);if(!l)break;let c=y.promoteKnight(r,u,l.nextStrength);o.push(c),n=t.apply(n,c)}return{success:!0,game:n,events:o}}E(oO,"executePlaySmith");function aO(e,r,t){let o=y.playSaboteur(r);return{success:!0,game:t.apply(e,o),events:[o]}}E(aO,"executePlaySaboteur");function sO(e,r,t){let o=[],i=y.playWedding(r);o.push(i);let n=t.apply(e,i),a=[];for(let s of n.pendingWeddingCards){let u=n.getPlayerState(s.player),l=n.getPlayerPublicState(s.player);u&&l&&l.cardCount<=2&&a.push(s.player)}for(let s of a){let u=n.getPlayerState(s),l=n.pendingWeddingCards.find(c=>c.player===s);if(u&&l){let c=new Map(u.hand),f=new Map(u.commodities),T=y.giveWeddingCards(s,l.weddingPlayer,c,f);o.push(T),n=t.apply(n,T)}}return{success:!0,game:n,events:o}}E(sO,"executePlayWedding");function _O(e,r,t,o,i){let n=r.pendingWeddingCards.find(u=>u.player===t);if(!n)return{success:!1,error:"No pending wedding cards entry for player"};let a=y.giveWeddingCards(t,n.weddingPlayer,o,i);return{success:!0,game:e.apply(r,a),events:[a]}}E(_O,"executeGiveWeddingCards");function dO(e,r,t,o){let i=r.board.getKnightsByPlayer(o);if(i.length===0)return{success:!1,error:"Target player has no knights"};if(i.length===1){let s=i[0],u=y.playDeserter(t,s.location,o);return{success:!0,game:e.apply(r,u),events:[u]}}let n=y.playDeserterStep1(t,o);return{success:!0,game:e.apply(r,n),events:[n]}}E(dO,"executePlayDeserter");function uO(e,r,t,o){if(!r.pendingDeserter)return{success:!1,error:"No Deserter action in progress"};let i=r.pendingDeserter.deserterPlayer,n=y.selectDeserterKnight(t,o,i);return{success:!0,game:e.apply(r,n),events:[n]}}E(uO,"executeSelectDeserterKnight");function EO(e,r,t,o){let i=r.board.getEdgeBuilding(o);if(!i)return{success:!1,error:"No road or ship at target location"};let n=y.playDiplomat(t,o,i.owner);return{success:!0,game:e.apply(r,n),events:[n]}}E(EO,"executePlayDiplomat");function lO(e,r,t,o,i){let n=r.board.getKnightAt(o);if(!n)return{success:!1,error:"No knight at target location"};let a=y.playIntrigue(t,o,i,n.owner);return{success:!0,game:e.apply(r,a),events:[a]}}E(lO,"executePlayIntrigue");function cO(e,r,t,o){let i=r.getPlayerState(o),n=i?new Map(i.progressCards):void 0;if(i&&Array.from(i.progressCards.values()).reduce((l,c)=>l+c,0)===1){let l=[...i.progressCards.entries()].find(([,c])=>c>0)?.[0];if(l!==void 0){let c=y.playSpy(t,o,l,n);return{success:!0,game:e.apply(r,c),events:[c]}}}let a=y.playSpy(t,o,void 0,n);return{success:!0,game:e.apply(r,a),events:[a]}}E(cO,"executePlaySpy");function fO(e,r,t,o){let i=r.pendingSpyTarget;if(!i)return{success:!1,error:"No Spy action in progress"};let n=y.playSpy(t,i,o);return{success:!0,game:e.apply(r,n),events:[n]}}E(fO,"executeSelectSpyTargetCard");function TO(e,r,t,o){let i=y.discardProgressCard(r,t);return{success:!0,game:o.apply(e,i),events:[i]}}E(TO,"executeDiscardProgressCard");function NO(e,r,t,o){let i=y.playMerchantCard(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(NO,"executePlayMerchant");function RO(e,r,t,o,i){let n=y.playMerchantFleet(t,o,i);return{success:!0,game:e.apply(r,n),events:[n]}}E(RO,"executePlayMerchantFleet");function AO(e,r,t,o){let i=[],n=y.playCommercialHarbor(t,o);i.push(n);let a=e.apply(r,n);for(let[u,l]of o){let c=a.getPlayerState(u);if(!c)continue;if(!(c.totalCommoditiesInHand>0)){let T=y.commercialHarborTradeCancelled(t,u,l);i.push(T),a=e.apply(a,T)}}let s=[...a.pendingCommercialHarborExchanges];for(let u of s){let l=a.getPlayerState(u.opponent);if(l&&l.totalCommoditiesInHand===1){let c=[...l.commodities.entries()].find(([,O])=>O>0)?.[0];if(c===void 0)continue;let f=new Map([[u.resource,1]]),T=new Map([[c,1]]),R=y.commercialHarborExchange(u.harborPlayer,u.opponent,f,T);i.push(R),a=e.apply(a,R)}}return{success:!0,game:a,events:i}}E(AO,"executePlayCommercialHarbor");function SO(e,r,t,o){let i=r.pendingCommercialHarborExchanges.find(c=>c.opponent===t);if(!i)return{success:!1,error:"No pending Commercial Harbor exchange for player"};let n=i.resource,a=new Map([[n,1]]),s=new Map([[o,1]]),u=y.commercialHarborExchange(i.harborPlayer,t,a,s);return{success:!0,game:e.apply(r,u),events:[u]}}E(SO,"executeCommercialHarborGiveCommodity");function OO(e,r,t,o){let i=r.getPlayerState(o),n=i?new Map(i.hand):void 0,a=i?new Map(i.commodities):void 0;if(i){let l=Array.from(i.hand.values()).reduce((T,R)=>T+R,0),c=Array.from(i.commodities.values()).reduce((T,R)=>T+R,0),f=l+c;if(f<=2&&f>0){let T=new Map(i.hand),R=new Map(i.commodities),O=y.playMasterMerchant(t,o,T,R,n,a);return{success:!0,game:e.apply(r,O),events:[O]}}}let s=y.playMasterMerchant(t,o,void 0,void 0,n,a);return{success:!0,game:e.apply(r,s),events:[s]}}E(OO,"executePlayMasterMerchant");function IO(e,r,t,o,i){let n=r.masterMerchantTarget;if(!n)return{success:!1,error:"No Master Merchant action in progress"};let a=y.playMasterMerchant(t,n,o,i);return{success:!0,game:e.apply(r,a),events:[a]}}E(IO,"executeSelectMasterMerchantCards");function CO(e,r,t,o){let i=[];for(let s of r.getPlayerStates()){if(s.player===t)continue;let u=s.getResourceCount(o);u>0&&i.push({player:s.player,count:Math.min(u,2)})}let n=y.playResourceMonopoly(t,o,i);return{success:!0,game:e.apply(r,n),events:[n]}}E(CO,"executePlayResourceMonopoly");function PO(e,r,t,o){let i=[];for(let s of r.getPlayerStates()){if(s.player===t)continue;s.getCommodityCount(o)>0&&i.push({player:s.player,count:1})}let n=y.playTradeMonopoly(t,o,i);return{success:!0,game:e.apply(r,n),events:[n]}}E(PO,"executePlayTradeMonopoly");function pO(e,r,t,o){let i=y.passOldBoot(t,o);return{success:!0,game:e.apply(r,i),events:[i]}}E(pO,"executePassOldBoot");function hO(e,r,t){let o=[];if(r.board.robbers.length===0)return{success:!1,events:[],error:"No robber to banish"};let i=r.board.findFreeDesertForRobber()??Nd,n=r.getPlayerState(t);if(!n)throw new Error(`Player ${t} not found`);let a=Array.from(n.fishTiles.entries()).map(([l,c])=>({fish:l,count:c})),s=Ci(a,2);if(!s)throw new Error("Not enough fish to spend");o.push(y.spendFish(t,s)),o.push(y.moveRobber(t,i));let u=r;for(let l of o)u=e.apply(u,l);return{success:!0,game:u,events:o}}E(hO,"executeSpendFishBanishRobber");function DO(e,r,t,o,i){let n=[],a=t.getPlayerState(o);if(!a)throw new Error(`Player ${o} not found`);let s=Array.from(a.fishTiles.entries()).map(([T,R])=>({fish:T,count:R})),u=Ci(s,3);if(!u)throw new Error("Not enough fish to spend");n.push(y.spendFish(o,u));let l=!1,c=t.getPlayerState(i);if(c){let T=qt(r,c,t.options.stealSeed,t.stealCount);T&&(n.push(T.kind==="resource"?y.stealResource(o,i,T.resource):y.stealCommodity(o,i,T.commodity)),l=!0)}let f=t;for(let T of n)f=e.apply(f,T);return l&&t.options.stealSeed!==0&&(f=m(f,{stealCount:t.stealCount+1})),{success:!0,game:f,events:n}}E(DO,"executeSpendFishStealResource");function mO(e,r,t){let o=[],i=r.getPlayerState(t);if(!i)throw new Error(`Player ${t} not found`);let n=Array.from(i.fishTiles.entries()).map(([u,l])=>({fish:u,count:l})),a=Ci(n,4);if(!a)throw new Error("Not enough fish to spend");o.push(y.spendFish(t,a)),o.push(y.freeResourceGranted(t,Ir.FREE_RESOURCE_REASON_FISH,1));let s=r;for(let u of o)s=e.apply(s,u);return{success:!0,game:s,events:o}}E(mO,"executeSpendFishTakeResource");function gO(e,r,t){let o=[],i=r.getPlayerState(t);if(!i)throw new Error(`Player ${t} not found`);let n=Array.from(i.fishTiles.entries()).map(([l,c])=>({fish:l,count:c})),a=Ci(n,5);if(!a)throw new Error("Not enough fish to spend");o.push(y.spendFish(t,a));let s=it(r);o.push(y.freeStructureGranted(t,dn.FREE_STRUCTURE_REASON_FISH,s));let u=r;for(let l of o)u=e.apply(u,l);return{success:!0,game:u,events:o}}E(gO,"executeSpendFishBuildRoad");function yO(e,r,t,o){let i=[],n=t.getPlayerState(o);if(!n)throw new Error(`Player ${o} not found`);let a=Array.from(n.fishTiles.entries()).map(([f,T])=>({fish:f,count:T})),s=Ci(a,7);if(!s)throw new Error("Not enough fish to spend");i.push(y.spendFish(o,s));let u=[];for(let[f,T]of t.devCardDeck)for(let R=0;R<T;R++)u.push(f);if(u.length===0)throw new Error("No dev cards available in deck");let l=r.pickRandom(u);if(l===void 0)throw new Error("Failed to pick random dev card");i.push(y.buyDevCard(o,l,!0));let c=t;for(let f of i)c=e.apply(c,f);return{success:!0,game:c,events:i}}E(yO,"executeSpendFishDrawDevCard");var os=class{static{E(this,"EventCardsExecutor")}applier;constructor(r){this.applier=r}executeSelectEarthquakeRoad(r,t){let o=[],i=t.player,n=t.edge;o.push(y.roadDamaged(i,n));let a=r.getEdgeBuildings().map(T=>T.edge.equals(n)&&T.owner===i?new ar(T.edge,T.owner,F.BUILDING_BROKEN_ROAD):T),s=pe(r.board,{edgeBuildings:a}),u=m(r,{board:s,pendingEarthquake:r.pendingEarthquake.filter(T=>T!==i),incrementBuildingVersion:!0}),l=new Rt(u),c=l.recalculateAllLongestRoadLengths(),f=l.calculateLongestRoadHolder();return u=m(u,{playerPublicStates:c,longestRoadPlayer:f}),{game:u,events:o}}executeGiveEventCardResource(r,t){let o=[],i=t.player,n=t.targetPlayer,a=y.giveEventCardResource(i,n,{resource:t.resource,commodity:t.commodity});return o.push(a),{game:this.applier.apply(r,a),events:o}}executeEventCardSteal(r,t,o){let i=[],n=t.player,a=t.targetPlayer,s=r.getPlayerState(a);if(!s)return{game:m(r,{pendingEventCardSteal:null}),events:i};let u=yi(s);if(u.length===0)return{game:m(r,{pendingEventCardSteal:null}),events:i};let l=o.pickRandom(u),c=l.kind==="resource"?y.stealResource(n,a,l.resource):y.stealCommodity(n,a,l.commodity);i.push(c);let f=this.applier.apply(r,c);return f=m(f,{pendingEventCardSteal:null}),{game:f,events:i}}};var su=class{static{E(this,"MerchantTrainsExecutor")}applier;constructor(r){this.applier=r}startWagonVoting(r,t){let o=[];if(r.getFlowState().wagonsExhausted)return{game:r,events:o};if(r.board.wagonCount>=r.options.numberWagons){let u=y.wagonsExhausted();return o.push(u),{game:this.applier.apply(r,u),events:o}}let i=this.getValidPlacements(r);if(i.length===0){let u=y.wagonsExhausted();return o.push(u),{game:this.applier.apply(r,u),events:o}}let n=r.getPlayerStates().map(u=>u.player),a=y.wagonVotingStarted(t,n,i);return o.push(a),{game:this.applier.apply(r,a),events:o}}executeWagonVote(r,t){let o=[],i=t.player,n=new fn(i,t.woolBid,t.wheatBid,t.preferredEdge,t.preferredFacing),a=y.wagonVote(i,n);o.push(a);let s=this.applier.apply(r,a),u=s.getFlowState().pendingWagonVoting;if(u&&u.isComplete){let{game:l,events:c}=this.resolveVotes(s);o.push(...c),s=l}return{game:s,events:o}}resolveVotes(r){let t=[],o=r.getFlowState().pendingWagonVoting,i=this.getValidPlacements(r),a=new mi(o.votes,o.activePlayer,i).resolve();if(a){let s=new ln(a.edge,a.facing),u=y.wagonPlaced(s,o.votes);t.push(u);let l=this.applier.apply(r,u);for(let c of o.votes)if(!c.isPass){let f=new Map;if(c.woolBid>0&&f.set(S.RESOURCE_SHEEP,c.woolBid),c.wheatBid>0&&f.set(S.RESOURCE_WHEAT,c.wheatBid),f.size>0){let T=y.discardResources(c.player,f);t.push(T),l=this.applier.apply(l,T)}}return{game:l,events:t}}else return{game:m(r,{pendingWagonVoting:null}),events:t}}getValidPlacements(r){return tu(r.board.getWagons(),r.board.getTiles())}};var b_=class{static{E(this,"TrollsExecutor")}applier;constructor(r){this.applier=r}executeFeedTroll(r,t){let o=[],i=t.player,n=t.trollHex,a=y.feedTroll(i,n,t.resources);o.push(a);let s=this.applier.apply(r,a),u=this.triggerHexProduction(s,n,i);return s=u.game,o.push(...u.events),{game:s,events:o}}executeKickTrollWithKnight(r,t){let o=[],i=t.player,n=t.trollHex,a=t.knightVertex,s=y.kickTroll(i,n,a);o.push(s);let u=this.applier.apply(r,s),l=this.triggerHexProduction(u,n,i);return u=l.game,o.push(...l.events),{game:u,events:o}}triggerHexProduction(r,t,o){let i=[],n=r.board.getTile(t);if(!n)return{game:r,events:i};let a=n.resource;if(!a)return{game:r,events:i};let s=t.getAllVerticies(),u=new Map;for(let c of s){let f=r.board.getVertexBuilding(c);if(!f)continue;let T=f.owner,R=f.isCity?2:1;u.has(T)||u.set(T,new Map);let O=u.get(T);O.set(a,(O.get(a)||0)+R)}let l=r;for(let[c,f]of u){let T=y.receiveResources(c,f);i.push(T),l=this.applier.apply(l,T)}return{game:l,events:i}}};function MO(e,r,t,o){let i=[],n=t.dice,a=t;n&&n.total===7&&(a=Wl(a)),a=m(a,{pendingRobberOrPiratePlacement:!1,pendingRobberStealLocation:null,pendingPirateStealLocation:null});let s=a.getPlayerStates();for(let O of a.turnOrder)a.hasPlayerState(O)&&(s=z(s,O,I=>{let D=new Map(I.unplayedDevCards);for(let[g,k]of I.devCardsPurchasedThisTurn)D.set(g,(D.get(g)??0)+k);return I.toBuilder().withUnplayedDevCards(D).withDevCardsPurchasedThisTurn(new Map).build()}));let l=(a.turnOrder.indexOf(a.currentPlayer)+1)%a.turnOrder.length,c=a.turnOrder[l];a=m(a,{playerStates:s,activeTrades:[],pendingDiceRoll:!0,playedDevCardThisTurn:!1,movedShipThisTurn:!1,shipsBuiltThisTurn:[],tradesProposedThisTurn:0,rejectedTradeOffers:[],rushPlayedDevCard:new Set,rushDiceVotes:new Set,pendingRobberOrPiratePlacement:!1,pendingRobberStealLocation:null,pendingPirateStealLocation:null,currentPlayer:c,turnNumber:a.turnNumber+1});let f=au(e,r,a,c);if(!f.success||!f.game)return{success:!1,error:f.error??"Failed to execute rush dice roll"};a=f.game;let T=o+a.options.rushDiceIntervalSeconds*1e3;a=m(a,{rushNextDiceRollAt:T});let R=y.rushRoundStart(c,T);return i.push(R),f.events&&i.push(...f.events),{success:!0,game:a,events:i}}E(MO,"executeRushDiceRoll");var pn=class{static{E(this,"LocalActionExecutor")}validator;applier;random;games=new Map;constructor(r=new gi){this.validator=new Vn,this.applier=new Wt,this.random=r}registerGame(r,t){this.games.set(r,t)}getGame(r){return this.games.get(r)}removeGame(r){return this.games.delete(r)}async execute(r){let{gameId:t,action:o}=r;if(!o)return{success:!1,game:void 0,events:[],error:"No action provided",errorCode:P.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE};let i=this.games.get(t);if(!i)return{success:!1,game:void 0,events:[],error:`Game not found: ${t}`,errorCode:P.VALIDATION_ERROR_UNSPECIFIED};let n=this.actionFromProto(o),a=this.executeSync(i,n);return a.success&&a.game&&this.games.set(t,a.game),{success:a.success,game:a.game?.toProto(),events:a.events?.map(s=>s.toProto())??[],error:a.error??"",errorCode:a.errorCode??P.VALIDATION_ERROR_UNSPECIFIED}}executeSync(r,t){let o=this.validator.validate(r,t);if(!o.valid)return{success:!1,error:o.error,errorCode:o.errorCode};let i=this.executeValidatedAction(r,t);if(i.success&&i.game&&r.isSetupPhase&&!i.game.isSetupPhase){i.game=tc(i.game,this.random);let n;if(i.game.options.revealFogOnGameStart){let s=zA(i.game);s.length>0&&(i.game=eu(i.game,s),n=s)}let a=y.initializeDecks(i.game.currentPlayer,i.game.options.citiesAndKnights?i.game.scienceProgressDeck:void 0,i.game.options.citiesAndKnights?i.game.politicsProgressDeck:void 0,i.game.options.citiesAndKnights?i.game.tradeProgressDeck:void 0,i.game.options.eventCards?i.game.eventCardDeck:void 0,i.game.options.eventCards?i.game.removedEventCards:void 0,n);if(i.events=[...i.events??[],a],i.game.options.rushMode){let s=this.executeRushDiceRoll(i.game,Date.now());s.success&&s.game&&(i.game=s.game,i.events=[...i.events??[],...s.events??[]])}}if(i.success&&i.game&&r.hasPendingProgressCardDiscardAny&&!i.game.hasPendingProgressCardDiscardAny){if(r.pendingResourceResolution&&r.currentPlayer!==t.player){let n=i.game.dice?.total??0;if(n!==7&&n>0){let a=Jt(this.applier,i.game,n);for(let s of a)i.game=this.applier.apply(i.game,s),i.events=[...i.events??[],s];if(i.game.options.fisherman){let s=Hn(this.applier,this.random,i.game,n);for(let u of s)i.game=this.applier.apply(i.game,u),i.events=[...i.events??[],u]}}i.game=new gr({...i.game.toOptions(),pendingResourceResolution:!1})}else if(r.currentPlayer===t.player&&!r.pendingDiceRoll){let n=ec(this.applier,i.game,t.player,Date.now());n.success&&(i.game=n.game,i.events=[...i.events??[],...n.events??[]])}}if(i.success&&i.game&&i.game.options.rivers){let n=eS(r,i.game);for(let a of n)i.game=this.applier.apply(i.game,a);n.length>0&&(i.events=[...i.events??[],...n])}return this.checkAndHandleVictory(i)}checkAndHandleVictory(r){if(!r.success||!r.game||r.game.winner!==void 0&&r.game.winner!==x.PLAYER_COLOR_UNSPECIFIED)return r;let t;try{t=r.game.getFlowState()}catch{return r}if(t.winner!==void 0&&t.winner!==x.PLAYER_COLOR_UNSPECIFIED){let o=y.gameWon(t.winner,ht.WIN_REASON_VICTORY_POINTS),i=[...r.events??[],o];return{success:!0,game:this.applier.apply(r.game,o),events:i}}return r}actionFromProto(r){return Zd(r)}executeValidatedAction(r,t){switch(t.type){case N.ACTION_TYPE_ROLL_DICE:return this.executeRollDice(r,t.player);case N.ACTION_TYPE_BUILD_ROAD:{let o=t;return this.executeBuildRoad(r,o.player,o.edge)}case N.ACTION_TYPE_BUILD_SHIP:{let o=t;return this.executeBuildShip(r,o.player,o.edge)}case N.ACTION_TYPE_BUILD_SETTLEMENT:{let o=t;return this.executeBuildSettlement(r,o.player,o.vertex)}case N.ACTION_TYPE_BUILD_CITY:{let o=t;return this.executeBuildCity(r,o.player,o.vertex)}case N.ACTION_TYPE_BUY_DEV_CARD:return this.executeBuyDevCard(r,t.player);case N.ACTION_TYPE_BUY_PROGRESS_CARD:{let o=t;return dS(this.applier,r,o.player,o.track)}case N.ACTION_TYPE_BUILD_BRIDGE:{let o=t;return rS(this.applier,r,o.player,o.edge)}case N.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD:{let o=t;return tS(this.applier,r,o.player,o.resource)}case N.ACTION_TYPE_BUY_GOLD:{let o=t;return nS(this.applier,r,o.player,o.resource)}case N.ACTION_TYPE_PLAY_KNIGHT:{let o=t;return this.executePlayKnight(r,o.player,o.robberLocation,o.targetPlayer)}case N.ACTION_TYPE_PLAY_ROAD_BUILDING:return this.executePlayRoadBuilding(r,t.player);case N.ACTION_TYPE_PLAY_YEAR_OF_PLENTY:return this.executePlayYearOfPlenty(r,t.player);case N.ACTION_TYPE_PLAY_MONOPOLY:{let o=t;return this.executePlayMonopoly(r,o.player,o.resource)}case N.ACTION_TYPE_PROPOSE_TRADE:{let o=t;return this.executeProposeTrade(r,o.player,o.offering,o.requesting,o.offeringCommodities,o.requestingCommodities,o.offeringGold,o.requestingGold,o.counterTradeId)}case N.ACTION_TYPE_PROPOSE_MULTI_TRADE:{let o=t;return this.executeProposeMultiTrade(r,o.player,o.proposals)}case N.ACTION_TYPE_ACCEPT_TRADE:{let o=t;return this.executeAcceptTrade(r,o.player,o.tradeId)}case N.ACTION_TYPE_REJECT_TRADE:{let o=t;return this.executeRejectTrade(r,o.player,o.tradeId)}case N.ACTION_TYPE_CANCEL_TRADE:{let o=t;return this.executeCancelTrade(r,o.player,o.tradeId)}case N.ACTION_TYPE_EXECUTE_TRADE:{let o=t;return this.executeExecuteTrade(r,o.player,o.tradeId,o.tradePartner)}case N.ACTION_TYPE_TRADE_WITH_BANK:{let o=t;return this.executeTradeWithBank(r,o.player,o.offering,o.requesting,o.offeringCommodities,o.requestingCommodities)}case N.ACTION_TYPE_END_TURN:return this.executeEndTurn(r,t.player);case N.ACTION_TYPE_DISCARD_RESOURCES:{let o=t;return this.executeDiscardResources(r,o.player,o.resources,o.commodities)}case N.ACTION_TYPE_MOVE_ROBBER:{let o=t;return this.executeMoveRobber(r,o.player,o.location)}case N.ACTION_TYPE_STEAL_FROM_PLAYER:{let o=t;return this.executeStealFromPlayer(r,o.player,o.targetPlayer)}case N.ACTION_TYPE_MOVE_PIRATE:{let o=t;return this.executeMovePirate(r,o.player,o.location)}case N.ACTION_TYPE_MOVE_SHIP:{let o=t;return this.executeMoveShip(r,o.player,o.fromEdge,o.toEdge)}case N.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE:{let o=t;return this.executeStealFromPlayerPirate(r,o.player,o.targetPlayer)}case N.ACTION_TYPE_SELECT_FREE_RESOURCE:{let o=t;return this.executeSelectFreeResource(r,o.player,o.resource)}case N.ACTION_TYPE_PLACE_FREE_ROAD:{let o=t;return this.executePlaceFreeRoad(r,o.player,o.edge)}case N.ACTION_TYPE_PLACE_FREE_SHIP:{let o=t;return this.executePlaceFreeShip(r,o.player,o.edge)}case N.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT:{let o=t;return this.executePlaceInitialSettlement(r,o.player,o.vertex)}case N.ACTION_TYPE_PLACE_INITIAL_ROAD:{let o=t;return this.executePlaceInitialRoad(r,o.player,o.edge)}case N.ACTION_TYPE_PLACE_INITIAL_SHIP:{let o=t;return this.executePlaceInitialShip(r,o.player,o.edge)}case N.ACTION_TYPE_BUILD_KNIGHT:{let o=t;return this.executeBuildKnight(r,o.player,o.vertex)}case N.ACTION_TYPE_ACTIVATE_KNIGHT:{let o=t;return this.executeActivateKnight(r,o.player,o.vertex)}case N.ACTION_TYPE_PROMOTE_KNIGHT:{let o=t;return this.executePromoteKnight(r,o.player,o.vertex)}case N.ACTION_TYPE_MOVE_KNIGHT:{let o=t;return this.executeMoveKnight(r,o.player,o.fromVertex,o.toVertex)}case N.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT:{let o=t;return this.executeChaseRobberWithKnight(r,o.player,o.knightVertex,o.newRobberLocation,o.targetPlayer)}case N.ACTION_TYPE_USE_KNIGHT_ERRANT:{let o=t;return this.executeUseKnightErrant(r,o.player,o.knightVertex,o.newRobberLocation,o.targetPlayer)}case N.ACTION_TYPE_BUILD_CITY_IMPROVEMENT:{let o=t;return this.executeBuildCityImprovement(r,o.player,o.track)}case N.ACTION_TYPE_BUILD_CITY_WALL:{let o=t;return this.executeBuildCityWall(r,o.player,o.cityVertex)}case N.ACTION_TYPE_SELECT_METROPOLIS_CITY:{let o=t;return this.executeSelectMetropolisCity(r,o.player,o.cityVertex)}case N.ACTION_TYPE_SELECT_CITY_TO_PILLAGE:{let o=t;return this.executeSelectCityToPillage(r,o.player,o.cityVertex)}case N.ACTION_TYPE_SELECT_DEFENDER_PROGRESS:{let o=t;return this.executeSelectDefenderProgress(r,o.player,o.track)}case N.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE:{let o=t;return this.executeCommitKnightsToDefense(r,o.player,o.knightVertices)}case N.ACTION_TYPE_PLAY_ALCHEMIST:return this.executePlayAlchemist(r,t.player);case N.ACTION_TYPE_SELECT_ALCHEMIST_DICE:{let o=t;return this.executeSelectAlchemistDice(r,o.player,o.redDie,o.yellowDie)}case N.ACTION_TYPE_PLAY_ENGINEER:return this.executePlayEngineer(r,t.player);case N.ACTION_TYPE_PLAY_CRANE:return this.executePlayCrane(r,t.player);case N.ACTION_TYPE_PLAY_MEDICINE:return this.executePlayMedicine(r,t.player);case N.ACTION_TYPE_PLAY_BISHOP:{let o=t;return this.executePlayBishop(r,o.player,o.robberLocation)}case N.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING:return this.executePlayProgressRoadBuilding(r,t.player);case N.ACTION_TYPE_PLAY_MINING:return this.executePlayMining(r,t.player);case N.ACTION_TYPE_PLAY_IRRIGATION:return this.executePlayIrrigation(r,t.player);case N.ACTION_TYPE_PLAY_WARLORD:return this.executePlayWarlord(r,t.player);case N.ACTION_TYPE_PLAY_SMITH:return this.executePlaySmith(r,t.player);case N.ACTION_TYPE_PLAY_SABOTEUR:return this.executePlaySaboteur(r,t.player);case N.ACTION_TYPE_PLAY_WEDDING:return this.executePlayWedding(r,t.player);case N.ACTION_TYPE_GIVE_WEDDING_CARDS:{let o=t;return this.executeGiveWeddingCards(r,o.player,o.resources,o.commodities)}case N.ACTION_TYPE_DISCARD_PROGRESS_CARD:{let o=t;return this.executeDiscardProgressCard(r,o.player,o.card)}case N.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR:{let o=t;return this.executePlayCommercialHarbor(r,o.player,o.selectedTrades)}case N.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY:{let o=t;return this.executeCommercialHarborGiveCommodity(r,o.player,o.commodity)}case N.ACTION_TYPE_PLAY_SPY:{let o=t;return this.executePlaySpy(r,o.player,o.targetPlayer)}case N.ACTION_TYPE_SELECT_SPY_TARGET_CARD:{let o=t;return this.executeSelectSpyTargetCard(r,o.player,o.progressCard)}case N.ACTION_TYPE_PLAY_MASTER_MERCHANT:{let o=t;return this.executePlayMasterMerchant(r,o.player,o.targetPlayer)}case N.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS:{let o=t;return this.executeSelectMasterMerchantCards(r,o.player,o.resources,o.commodities)}case N.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY:{let o=t;return this.executePlayResourceMonopoly(r,o.player,o.resource)}case N.ACTION_TYPE_PLAY_TRADE_MONOPOLY:{let o=t;return this.executePlayTradeMonopoly(r,o.player,o.commodity)}case N.ACTION_TYPE_PLAY_INVENTOR:{let o=t;return this.executePlayInventor(r,o.player,o.hex1,o.hex2)}case N.ACTION_TYPE_PLAY_MERCHANT:{let o=t;return this.executePlayMerchant(r,o.player,o.hex)}case N.ACTION_TYPE_PLAY_MERCHANT_FLEET:{let o=t;return this.executePlayMerchantFleet(r,o.player,o.resource,o.commodity)}case N.ACTION_TYPE_PLAY_DESERTER:{let o=t;return this.executePlayDeserter(r,o.player,o.targetPlayer)}case N.ACTION_TYPE_SELECT_DESERTER_KNIGHT:{let o=t;return this.executeSelectDeserterKnight(r,o.player,o.knightLocation)}case N.ACTION_TYPE_PLAY_DIPLOMAT:{let o=t;return this.executePlayDiplomat(r,o.player,o.targetRoad)}case N.ACTION_TYPE_PLAY_INTRIGUE:{let o=t;return this.executePlayIntrigue(r,o.player,o.targetKnight,o.destination)}case N.ACTION_TYPE_PASS_OLD_BOOT:{let o=t;return this.executePassOldBoot(r,o.player,o.targetPlayer)}case N.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER:return this.executeSpendFishBanishRobber(r,t.player);case N.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE:{let o=t;return this.executeSpendFishStealResource(r,o.player,o.targetPlayer)}case N.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE:return this.executeSpendFishTakeResource(r,t.player);case N.ACTION_TYPE_SPEND_FISH_BUILD_ROAD:return this.executeSpendFishBuildRoad(r,t.player);case N.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD:return this.executeSpendFishDrawDevCard(r,t.player);case N.ACTION_TYPE_RESIGN:return this.executeResign(r,t.player);case N.ACTION_TYPE_PAUSE:return this.executePause(r,t.player);case N.ACTION_TYPE_UNPAUSE:return this.executeUnpause(r,t.player);case N.ACTION_TYPE_VOTE_TO_CONTINUE:return this.executeVoteToContinue(r,t.player);case N.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD:{let o=t;return this.executeSelectEarthquakeRoad(r,o)}case N.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE:{let o=t;return this.executeGiveEventCardResource(r,o)}case N.ACTION_TYPE_EVENT_CARD_STEAL:{let o=t;return this.executeEventCardSteal(r,o)}case N.ACTION_TYPE_WAGON_VOTE:{let o=t;return this.executeWagonVote(r,o)}case N.ACTION_TYPE_FEED_TROLL:{let o=t;return this.executeFeedTroll(r,o)}case N.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT:{let o=t;return this.executeKickTrollWithKnight(r,o)}case N.ACTION_TYPE_VOTE_DICE_ROLL:return this.executeVoteDiceRoll(r,t);case N.ACTION_TYPE_TOGGLE_TRADE_EMBARGO:{let o=t;return this.executeToggleTradeEmbargo(r,o.player,o.targetPlayer)}default:return{success:!1,error:"Unknown action type"}}}executeRollDice(r,t){return au(this.applier,this.random,r,t)}executeBuildRoad(r,t,o){let i=aS(this.applier,r,t,o);if(!i.success||!i.game)return i;let n=ic(this.applier,this.random,i.game,t,o);return n.success?{success:!0,game:n.game,events:[...i.events??[],...n.events??[]]}:n}executeBuildSettlement(r,t,o){let i=sS(this.applier,r,t,o);if(!i.success||!i.game)return i;let n=oc(this.applier,i.game,t);return n.success?{success:!0,game:n.game,events:[...i.events??[],...n.events??[]]}:n}executeBuildCity(r,t,o){let i=_S(this.applier,r,t,o);if(!i.success||!i.game)return i;let n=oc(this.applier,i.game,t);return n.success?{success:!0,game:n.game,events:[...i.events??[],...n.events??[]]}:n}executeBuyDevCard(r,t){return uS(this.applier,this.random,r,t)}executePlayKnight(r,t,o,i){return AS(this.applier,this.random,r,t,o,i)}executePlayRoadBuilding(r,t){return SS(this.applier,r,t)}executePlayYearOfPlenty(r,t){return OS(this.applier,r,t)}executePlayMonopoly(r,t,o){return IS(this.applier,r,t,o)}executeProposeTrade(r,t,o,i,n,a,s,u,l){return hS(this.applier,r,t,o,i,n,a,s,u,l)}executeProposeMultiTrade(r,t,o){return DS(this.applier,r,t,o)}executeAcceptTrade(r,t,o){return mS(this.applier,r,t,o)}executeRejectTrade(r,t,o){return gS(this.applier,r,t,o)}executeCancelTrade(r,t,o){return yS(this.applier,r,t,o)}executeExecuteTrade(r,t,o,i){return MS(this.applier,r,t,o,i)}executeTradeWithBank(r,t,o,i,n,a){return LS(this.applier,r,t,o,i,n,a)}executeToggleTradeEmbargo(r,t,o){return GS(this.applier,r,t,o)}executeEndTurn(r,t){return ec(this.applier,r,t)}executeDiscardResources(r,t,o,i){return ES(this.applier,r,t,o,i)}executeMoveRobber(r,t,o){return lS(this.applier,this.random,r,t,o)}executeStealFromPlayer(r,t,o){return rc(this.applier,this.random,r,t,o)}executeSelectFreeResource(r,t,o){return cS(this.applier,r,t,o)}executePlaceFreeRoad(r,t,o){return fS(this.applier,r,t,o)}executePlaceInitialSettlement(r,t,o){return TS(this.applier,r,t,o)}executePlaceInitialRoad(r,t,o){return NS(this.applier,r,t,o)}executePlaceInitialShip(r,t,o){return RS(this.applier,r,t,o)}executeBuildShip(r,t,o){return US(this.applier,this.random,r,t,o)}executePlaceFreeShip(r,t,o){return BS(this.applier,r,t,o)}executeMoveShip(r,t,o,i){return kS(this.applier,r,t,o,i)}executeMovePirate(r,t,o){return bS(this.applier,this.random,r,t,o)}executeStealFromPlayerPirate(r,t,o){return nc(this.applier,this.random,r,t,o)}executeBuildKnight(r,t,o){return vS(this.applier,r,t,o)}executeActivateKnight(r,t,o){return YS(this.applier,r,t,o)}executePromoteKnight(r,t,o){return FS(this.applier,r,t,o)}executeMoveKnight(r,t,o,i){return VS(this.applier,r,t,o,i)}executeChaseRobberWithKnight(r,t,o,i,n){return wS(this.applier,this.random,r,t,o,i,n)}executeUseKnightErrant(r,t,o,i,n){return HS(this.applier,this.random,r,t,o,i,n)}executeBuildCityImprovement(r,t,o){return WS(this.applier,r,t,o)}executeBuildCityWall(r,t,o){return KS(this.applier,r,t,o)}executeSelectMetropolisCity(r,t,o){return JS(this.applier,r,t,o)}executeSelectCityToPillage(r,t,o){return HA(this.applier,this.random,r,t,o)}executeSelectDefenderProgress(r,t,o){return nu(this.applier,this.random,r,t,o)}executeCommitKnightsToDefense(r,t,o){return qA(this.applier,this.random,r,t,o)}executePlayAlchemist(r,t){return qS(this.applier,r,t)}executeSelectAlchemistDice(r,t,o,i){return ZS(this.applier,this.random,r,t,o,i)}executePlayEngineer(r,t){return XS(r,t,this.applier)}executePlayCrane(r,t){return zS(r,t,this.applier)}executePlayMedicine(r,t){return $S(r,t,this.applier)}executePlayMining(r,t){return QS(r,t,this.applier)}executePlayIrrigation(r,t){return jS(r,t,this.applier)}executePlayInventor(r,t,o,i){return eO(this.applier,r,t,o,i)}executePlayProgressRoadBuilding(r,t){return rO(r,t,this.applier)}executePlayBishop(r,t,o){return nO(this.applier,this.random,r,t,o)}executePlayWarlord(r,t){return iO(r,t,this.applier)}executePlaySmith(r,t){return oO(r,t,this.applier)}executePlaySaboteur(r,t){return aO(r,t,this.applier)}executePlayWedding(r,t){return sO(r,t,this.applier)}executeGiveWeddingCards(r,t,o,i){return _O(this.applier,r,t,o,i)}executeDiscardProgressCard(r,t,o){return TO(r,t,o,this.applier)}executePlayDeserter(r,t,o){return dO(this.applier,r,t,o)}executeSelectDeserterKnight(r,t,o){return uO(this.applier,r,t,o)}executePlayDiplomat(r,t,o){return EO(this.applier,r,t,o)}executePlayIntrigue(r,t,o,i){return lO(this.applier,r,t,o,i)}executePlaySpy(r,t,o){return cO(this.applier,r,t,o)}executeSelectSpyTargetCard(r,t,o){return fO(this.applier,r,t,o)}executePlayMerchant(r,t,o){return NO(this.applier,r,t,o)}executePlayMerchantFleet(r,t,o,i){return RO(this.applier,r,t,o,i)}executePlayCommercialHarbor(r,t,o){return AO(this.applier,r,t,o)}executeCommercialHarborGiveCommodity(r,t,o){return SO(this.applier,r,t,o)}executePlayMasterMerchant(r,t,o){return OO(this.applier,r,t,o)}executeSelectMasterMerchantCards(r,t,o,i){return IO(this.applier,r,t,o,i)}executePlayResourceMonopoly(r,t,o){return CO(this.applier,r,t,o)}executePlayTradeMonopoly(r,t,o){return PO(this.applier,r,t,o)}executePassOldBoot(r,t,o){return pO(this.applier,r,t,o)}executeSpendFishBanishRobber(r,t){return hO(this.applier,r,t)}executeSpendFishStealResource(r,t,o){return DO(this.applier,this.random,r,t,o)}executeSpendFishTakeResource(r,t){return mO(this.applier,r,t)}executeSpendFishBuildRoad(r,t){return gO(this.applier,r,t)}executeSpendFishDrawDevCard(r,t){return yO(this.applier,this.random,r,t)}executeSelectEarthquakeRoad(r,t){let o=new os(this.applier),{game:i,events:n}=o.executeSelectEarthquakeRoad(r,t);return{success:!0,game:i,events:n}}executeGiveEventCardResource(r,t){let o=new os(this.applier),{game:i,events:n}=o.executeGiveEventCardResource(r,t);return{success:!0,game:i,events:n}}executeEventCardSteal(r,t){let o=new os(this.applier),{game:i,events:n}=o.executeEventCardSteal(r,t,this.random);return{success:!0,game:i,events:n}}executeWagonVote(r,t){let o=new su(this.applier),{game:i,events:n}=o.executeWagonVote(r,t);return{success:!0,game:i,events:n}}executeFeedTroll(r,t){let o=new b_(this.applier),{game:i,events:n}=o.executeFeedTroll(r,t);return{success:!0,game:i,events:n}}executeKickTrollWithKnight(r,t){let o=new b_(this.applier),{game:i,events:n}=o.executeKickTrollWithKnight(r,t);return{success:!0,game:i,events:n}}executeVoteDiceRoll(r,t){let o=[];o.push(y.voteDiceRoll(t.player));let i=this.applyEvents(r,o);if(i.turnOrder.every(a=>i.rushDiceVotes.has(a))){let a=this.executeRushDiceRoll(i,Date.now());if(a.success&&a.game)return{success:!0,game:a.game,events:[...o,...a.events??[]]}}return{success:!0,game:i,events:o}}executeRushDiceRoll(r,t){return MO(this.applier,this.random,r,t)}applyEvents(r,t){let o=r;for(let i of t)o=this.applier.apply(o,i);return o}executeResign(r,t){if(!r.turnOrder.find(a=>a!==t))return{success:!1,error:"No opponent found in 1v1 game"};let i=y.resign(t);return{success:!0,game:this.applier.apply(r,i),events:[i]}}executePause(r,t){let o=y.pause(t);return{success:!0,game:this.applier.apply(r,o),events:[o]}}executeUnpause(r,t){let o=y.unpause(t);return{success:!0,game:this.applier.apply(r,o),events:[o]}}executeVoteToContinue(r,t){let o=y.voteToContinue(t);return{success:!0,game:this.applier.apply(r,o),events:[o]}}resolveBarbarianAttack(r){let t=[],o=r.getVertexBuildings().filter(T=>T.isCity),i=o.length,n=r.board.knights.filter(T=>T.isActive),a=n.reduce((T,R)=>T+R.strengthValue,0);if(i===0)return{success:!0,barbarianStrength:0,knightDefenseStrength:a,barbarianVictory:!1,defendersOfCatan:[],pillagedCities:[],game:r,events:[y.barbarianAttack(r.currentPlayer,0,a,!1)]};let s=a<i,u=new Map;for(let T of r.turnOrder){let O=n.filter(I=>I.owner===T).reduce((I,D)=>I+D.strengthValue,0);u.set(T,O)}let l=[],c=[];if(s){let T=Array.from(u.entries()).sort((D,g)=>D[1]-g[1]),R=new Set;for(let D of o)r.board.metropolises.some(k=>k.location.equals(D.vertex))||R.add(D.owner);let O=-1,I=[];for(let[D,g]of T)if(R.has(D))if(O===-1)O=g,I.push(D);else if(g===O)I.push(D);else break;for(let D of I){let g=o.filter(k=>k.owner===D);for(let k of g)if(!r.board.metropolises.some(Y=>Y.location.equals(k.vertex))){c.push({owner:D,vertex:k.vertex});break}}}else{let T=0;for(let[,R]of u)R>T&&(T=R);if(T>0)for(let[R,O]of u)O===T&&l.push(R)}let f=y.barbarianAttack(r.currentPlayer,i,a,s);return t.push(f),{success:!0,barbarianStrength:i,knightDefenseStrength:a,barbarianVictory:s,defendersOfCatan:l,pillagedCities:c,game:r,events:t}}};var pr=10,YO=12,FO=13,as=14,dc=12,km=22,bm=33,vm=44,Mi=2,uc=19,hn=25,ss=30,Ec=12,Dn=16,_s=20;function _u(e){return e.victoryPoints(pr).seafarers(!1)}E(_u,"configureBaseGame");function LO(e){return e.victoryPoints(as).seafarers(!0).newIslandSettlementBonus(Mi)}E(LO,"configureHeadingForNewShores");function ac(e){return e.victoryPoints(FO).seafarers(!0).newIslandSettlementBonus(Mi)}E(ac,"configureFourIslands");function GO(e){return e.victoryPoints(YO).seafarers(!0)}E(GO,"configureFogIslands");function UO(e){return e.victoryPoints(as).seafarers(!0).newIslandSettlementBonus(Mi).desertsBlockIslands(!0)}E(UO,"configureThroughTheDesert");function BO(e){return e.victoryPoints(YO).seafarers(!0)}E(BO,"configureNewWorld");function Ym(e){return e.victoryPoints(FO).seafarers(!0)}E(Ym,"configureForgottenTribe");function Fm(e){return e.victoryPoints(pr).seafarers(!1).resourceCardCount(hn).commodityCardCount(Dn)}E(Fm,"configure6PlayerBase");function Vm(e){return e.victoryPoints(pr).seafarers(!1).resourceCardCount(ss).commodityCardCount(_s)}E(Vm,"configure8PlayerBase");function sc(e){return e.victoryPoints(pr).fisherman(!0).resourceCardCount(uc).commodityCardCount(Ec)}E(sc,"configureFishPonds");function xm(e){return e.victoryPoints(pr).fisherman(!0).resourceCardCount(hn).commodityCardCount(Dn)}E(xm,"configureFishPonds6P");function wm(e){return e.victoryPoints(pr).fisherman(!0).resourceCardCount(ss).commodityCardCount(_s)}E(wm,"configureFishPonds8P");function v_(e){return e.victoryPoints(pr).foundOnFog(lt.FOUND_ON_FOG_MODE_WITHIN).fogReward(0).fogBonusDuringSetup(!1).fogMode(Gr.FOG_MODE_FOG_START)}E(v_,"configureFogBank");function Y_(e){return e.victoryPoints(pr).foundOnFog(lt.FOUND_ON_FOG_MODE_WITHIN).fogReward(0).fogBonusDuringSetup(!1).fogMode(Gr.FOG_MODE_MIST_START)}E(Y_,"configureMistyRealms");function Hm(e){return e.victoryPoints(pr).rivers(!0).resourceCardCount(uc).commodityCardCount(Ec)}E(Hm,"configureRivers");function Km(e){return e.victoryPoints(pr).rivers(!0).resourceCardCount(hn).commodityCardCount(Dn)}E(Km,"configureRivers6P");function Wm(e){return e.victoryPoints(pr).rivers(!0).resourceCardCount(ss).commodityCardCount(_s)}E(Wm,"configureRivers8P");function kO(e){return e.victoryPoints(dc).merchantTrains(!0).numberWagons(km)}E(kO,"configureCaravans");function Jm(e){return e.victoryPoints(dc).merchantTrains(!0).numberWagons(bm).resourceCardCount(hn).commodityCardCount(Dn)}E(Jm,"configureCaravans6P");function qm(e){return e.victoryPoints(dc).merchantTrains(!0).numberWagons(vm).resourceCardCount(ss).commodityCardCount(_s)}E(qm,"configureCaravans8P");function bO(e){return e.victoryPoints(pr).dynamicHexMode(kt.DYNAMIC_HEX_MODE_DESERTIFICATION)}E(bO,"configureDustBowl");function Zm(e){return e.victoryPoints(pr).dynamicHexMode(kt.DYNAMIC_HEX_MODE_DESERTIFICATION).resourceCardCount(hn).commodityCardCount(Dn)}E(Zm,"configureDustBowl6P");function Xm(e){return e.victoryPoints(pr).dynamicHexMode(kt.DYNAMIC_HEX_MODE_DESERTIFICATION).resourceCardCount(ss).commodityCardCount(_s)}E(Xm,"configureDustBowl8P");function _c(e){return e.victoryPoints(pr).trolls(!0).resourceCardCount(uc).commodityCardCount(Ec)}E(_c,"configureTrollBridge");function zm(e){return e.victoryPoints(pr).trolls(!0).resourceCardCount(hn).commodityCardCount(Dn)}E(zm,"configureTrollBridge6P");function $m(e){return e.victoryPoints(pr).trolls(!0).resourceCardCount(ss).commodityCardCount(_s)}E($m,"configureTrollBridge8P");function Qm(e){return e.victoryPoints(as).seafarers(!0).newIslandSettlementBonus(Mi).resourceCardCount(hn).commodityCardCount(Dn)}E(Qm,"configureSixIslands6P");function jm(e){return e.victoryPoints(pr).foundOnFog(lt.FOUND_ON_FOG_MODE_WITHIN).fogReward(0).fogBonusDuringSetup(!1)}E(jm,"configureSnowMan");function eg(e){return e.victoryPoints(as).seafarers(!0).newIslandSettlementBonus(Mi).resourceCardCount(hn).commodityCardCount(Dn)}E(eg,"configureHeadingForNewShores6P");function vO(e){return e.victoryPoints(as).seafarers(!0).fisherman(!0).newIslandSettlementBonus(Mi)}E(vO,"configureFishShoals");function rg(e){return e.victoryPoints(as).seafarers(!0).fisherman(!0).newIslandSettlementBonus(Mi).resourceCardCount(hn).commodityCardCount(Dn)}E(rg,"configureFishShoals6P");var HJ={[B.MAP_TYPE_UNSPECIFIED]:void 0,[B.MAP_TYPE_BASE_4P]:_u,[B.MAP_TYPE_BASE_RANDOM_4P]:_u,[B.MAP_TYPE_BASE_2P]:_u,[B.MAP_TYPE_BASE_3P]:_u,[B.MAP_TYPE_BASE_6P]:Fm,[B.MAP_TYPE_BASE_8P]:Vm,[B.MAP_TYPE_FISH_PONDS]:sc,[B.MAP_TYPE_FISH_PONDS_2P]:sc,[B.MAP_TYPE_FISH_PONDS_3P]:sc,[B.MAP_TYPE_FISH_PONDS_6P]:xm,[B.MAP_TYPE_FISH_PONDS_8P]:wm,[B.MAP_TYPE_SEAFARERS_FORGOTTEN_TRIBE]:Ym,[B.MAP_TYPE_SF_NEW_SHORES_3P]:LO,[B.MAP_TYPE_SF_NEW_SHORES_4P]:LO,[B.MAP_TYPE_SF_NEW_SHORES_6P]:eg,[B.MAP_TYPE_SF_FOUR_ISLANDS_3P]:ac,[B.MAP_TYPE_SF_FOUR_ISLANDS_4P]:ac,[B.MAP_TYPE_SF_FOUR_ISLANDS_RANDOM]:ac,[B.MAP_TYPE_SF_FOG_ISLANDS_3P]:GO,[B.MAP_TYPE_SF_FOG_ISLANDS_4P]:GO,[B.MAP_TYPE_SF_THROUGH_DESERT_3P]:UO,[B.MAP_TYPE_SF_THROUGH_DESERT_4P]:UO,[B.MAP_TYPE_SF_NEW_WORLD_3P]:BO,[B.MAP_TYPE_SF_NEW_WORLD_4P]:BO,[B.MAP_TYPE_FOG_BANK_2P]:v_,[B.MAP_TYPE_FOG_BANK_3P]:v_,[B.MAP_TYPE_FOG_BANK_4P]:v_,[B.MAP_TYPE_FOG_BANK_6P]:v_,[B.MAP_TYPE_FOG_BANK_8P]:v_,[B.MAP_TYPE_MISTY_REALMS_2P]:Y_,[B.MAP_TYPE_MISTY_REALMS_3P]:Y_,[B.MAP_TYPE_MISTY_REALMS_4P]:Y_,[B.MAP_TYPE_MISTY_REALMS_6P]:Y_,[B.MAP_TYPE_MISTY_REALMS_8P]:Y_,[B.MAP_TYPE_RIVER_4P]:Hm,[B.MAP_TYPE_RIVER_6P]:Km,[B.MAP_TYPE_RIVER_8P]:Wm,[B.MAP_TYPE_CARAVANS_3P]:kO,[B.MAP_TYPE_CARAVANS_4P]:kO,[B.MAP_TYPE_CARAVANS_6P]:Jm,[B.MAP_TYPE_CARAVANS_8P]:qm,[B.MAP_TYPE_DUST_BOWL_3P]:bO,[B.MAP_TYPE_DUST_BOWL_4P]:bO,[B.MAP_TYPE_DUST_BOWL_6P]:Zm,[B.MAP_TYPE_DUST_BOWL_8P]:Xm,[B.MAP_TYPE_SF_SIX_ISLANDS_6P]:Qm,[B.MAP_TYPE_SNOW_MAN]:jm,[B.MAP_TYPE_TROLL_BRIDGE_2P]:_c,[B.MAP_TYPE_TROLL_BRIDGE_3P]:_c,[B.MAP_TYPE_TROLL_BRIDGE_4P]:_c,[B.MAP_TYPE_TROLL_BRIDGE_6P]:zm,[B.MAP_TYPE_TROLL_BRIDGE_8P]:$m,[B.MAP_TYPE_FISH_SHOALS_3P]:vO,[B.MAP_TYPE_FISH_SHOALS_4P]:vO,[B.MAP_TYPE_FISH_SHOALS_6P]:rg,[B.UNRECOGNIZED]:void 0};var VO=[x.PLAYER_COLOR_RED,x.PLAYER_COLOR_BLUE],tg=[x.PLAYER_COLOR_RED,x.PLAYER_COLOR_BLUE,x.PLAYER_COLOR_WHITE],ng=[x.PLAYER_COLOR_RED,x.PLAYER_COLOR_BLUE,x.PLAYER_COLOR_WHITE,x.PLAYER_COLOR_ORANGE],xO=x.PLAYER_COLOR_RED,wO=x.PLAYER_COLOR_BLUE,ig=x.PLAYER_COLOR_WHITE,og=x.PLAYER_COLOR_ORANGE,ag=S.RESOURCE_WOOD,sg=S.RESOURCE_BRICK,_g=S.RESOURCE_SHEEP,dg=S.RESOURCE_WHEAT,ug=S.RESOURCE_ORE;var Eg={CENTER_N:new _(0,0,0).getVertex("N"),CENTER_S:new _(0,0,0).getVertex("S"),CENTER_NW:new _(0,0,0).getVertex("NW"),CENTER_NE:new _(0,0,0).getVertex("NE"),CENTER_SW:new _(0,0,0).getVertex("SW"),CENTER_SE:new _(0,0,0).getVertex("SE")},lg={CENTER_N:new _(0,0,0).getVertex("N").getEdgeTo(new _(0,0,0).getVertex("NE")),CENTER_S:new _(0,0,0).getVertex("S").getEdgeTo(new _(0,0,0).getVertex("SE"))},cg={CENTER:new _(0,0,0),EAST:new _(1,-1,0),WEST:new _(-1,1,0)};var lc={kind:"spectator"};function cc(e,r){if(!r)return lc;let t=Object.keys(e).find(o=>e[o].uid===r);return t===void 0?lc:{kind:"player",uid:r,key:t,color:e[t].color}}E(cc,"findViewer");function du(e,r){let t=r.kind==="player"?r.uid:"OBSERVER";return`game-events/${e}/player/${t}/events`}E(du,"eventStreamPath");function fc(e){let r=atob(e),t=new Uint8Array(r.length);for(let o=0;o<r.length;o++)t[o]=r.charCodeAt(o);return t}E(fc,"base64ToBytes");function Tc(e,r){let t=js.decode(fc(e));return t.playerStates=r.kind==="player"?t.playerStates.filter(o=>o.player===r.color):[],gr.fromProto(t)}E(Tc,"decodeInitialGame");function Nc(e){let r=e_.decode(fc(e));return{proto:r,event:y.fromProto(r)}}E(Nc,"decodeGameEvent");var Rc=[[0,0,0],[1,-1,0],[1,0,-1],[0,1,-1],[-1,1,0],[-1,0,1],[0,-1,1],[2,-2,0],[2,-1,-1],[2,0,-2],[1,1,-2],[0,2,-2],[-1,2,-1],[-2,2,0],[-2,1,1],[-2,0,2],[-1,-1,2],[0,-2,2],[1,-2,1]],F_=[[-2,0,3],[-2,1,2],[-2,2,1],[-2,3,0],[-1,-1,3],[-1,0,2],[-1,1,1],[-1,2,0],[-1,3,-1],[0,-2,3],[0,-1,2],[0,0,1],[0,1,0],[0,2,-1],[0,3,-2],[1,-2,2],[1,-1,1],[1,0,0],[1,1,-1],[1,2,-2],[2,-2,1],[2,-1,0],[2,0,-1],[2,1,-2],[3,-2,0],[3,-1,-1],[3,0,-2],[-2,1,3],[-2,2,2],[-2,3,1],[-1,0,3],[-1,1,2],[-1,2,1],[-1,3,0],[0,-1,3],[0,0,2],[0,1,1],[0,2,0],[0,3,-1],[1,-2,3],[1,-1,2],[1,0,1],[1,1,0],[1,2,-1],[1,3,-2],[2,-2,2],[2,-1,1],[2,0,0],[2,1,-1],[2,2,-2],[3,-2,1],[3,-1,0],[3,0,-1],[3,1,-2]],Ac=(()=>{let e=new Set(F_.map(Zt)),r=[];for(let t of F_)if(t[0]+t[1]+t[2]===1)for(let o of[[1,0,0],[0,1,0],[0,0,1]]){let i=[t[0]+o[0],t[1]+o[1],t[2]+o[2]];e.has(Zt(i))&&r.push([t,i])}return r})();function Zt(e){return Array.isArray(e)?e.join(","):`${e.x},${e.y},${e.z}`}E(Zt,"tripleKey");var hg=new Map(Rc.map((e,r)=>[Zt(e),r])),Dg=new Map(F_.map((e,r)=>[Zt(e),r])),mg=new Map(Ac.map(([e,r],t)=>[`${Zt(e)}|${Zt(r)}`,t])),Ot=class extends Error{static{E(this,"OHCoordinateError")}constructor(r){super(r),this.name="OHCoordinateError"}};function ds(e){return{x:e.x+0,y:e.y+0,z:e.z+0}}E(ds,"point");function Kn(e){return`(${e.x},${e.y},${e.z})`}E(Kn,"describe");function Sc(e,r,t,o){let i=e.get(r);if(i===void 0)throw new Ot(`${t} ${o} is not on the standard 19-hex board, so it has no index`);return i}E(Sc,"indexOf");function Hr(e,r="coordinates"){let t=ds(e);return r==="indices"?Sc(hg,Zt(t),"Hex",Kn(t)):t}E(Hr,"hexToOH");function Gt(e,r="coordinates"){let t=ds(e);return r==="indices"?Sc(Dg,Zt(t),"Vertex",Kn(t)):t}E(Gt,"vertexToOH");function Xt(e,r="coordinates"){let t=[ds(e.v1),ds(e.v2)];if(r==="coordinates")return t;let o=`${Zt(t[0])}|${Zt(t[1])}`;return Sc(mg,o,"Edge",`${Kn(t[0])}-${Kn(t[1])}`)}E(Xt,"edgeToOH");function HO(e,r){let t=e;if(!t||typeof t!="object"||![t.x,t.y,t.z].every(o=>Number.isInteger(o)))throw new Ot(`${r} must be {"x": int, "y": int, "z": int} or an index, got ${JSON.stringify(e)}`);return{x:t.x,y:t.y,z:t.z}}E(HO,"readPoint");function Oc(e,r,t){if(!Number.isInteger(r)||r<0||r>=e.length)throw new Ot(`${t} index must be an integer from 0 to ${e.length-1}, got ${r}`);return e[r]}E(Oc,"fromTable");function Li(e){if(typeof e=="number"){let[t,o,i]=Oc(Rc,e,"Hex");return new _(t,o,i)}let r=HO(e,"Hex");if(r.x+r.y+r.z!==0)throw new Ot(`Hex ${Kn(r)} must have x+y+z = 0`);return new _(r.x,r.y,r.z)}E(Li,"hexFromOH");function Wn(e){if(typeof e=="number"){let[o,i,n]=Oc(F_,e,"Vertex");return new oe(o,i,n)}let r=HO(e,"Vertex"),t=r.x+r.y+r.z;if(t!==1&&t!==2)throw new Ot(`Vertex ${Kn(r)} must have x+y+z = 1 or 2`);return new oe(r.x,r.y,r.z)}E(Wn,"vertexFromOH");function us(e){if(typeof e=="number"){let[s,u]=Oc(Ac,e,"Edge");return new Ne(new oe(...s),new oe(...u))}if(!Array.isArray(e)||e.length!==2)throw new Ot(`Edge must be two vertices [{x,y,z}, {x,y,z}] or an index, got ${JSON.stringify(e)}`);let r=Wn(e[0]),t=Wn(e[1]),[o,i]=r.x+r.y+r.z===1?[r,t]:[t,r],n=[i.x-o.x,i.y-o.y,i.z-o.z];if(!(o.x+o.y+o.z===1&&n.filter(s=>s===1).length===1&&n.filter(s=>s===0).length===2))throw new Ot(`Edge ${Kn(ds(r))}-${Kn(ds(t))} must join two adjacent vertices: one with x+y+z = 1, the other one step away in x, y or z`);return new Ne(o,i)}E(us,"edgeFromOH");var _t=["wood","brick","sheep","wheat","ore"],Ic=["knight","victoryPoint","roadBuilding","yearOfPlenty","monopoly"];function Cc(e){return new Map(Object.entries(e).map(([r,t])=>[t,r]))}E(Cc,"invert");var V_={red:x.PLAYER_COLOR_RED,blue:x.PLAYER_COLOR_BLUE,white:x.PLAYER_COLOR_WHITE,orange:x.PLAYER_COLOR_ORANGE},gg=Cc(V_),zt={wood:S.RESOURCE_WOOD,brick:S.RESOURCE_BRICK,sheep:S.RESOURCE_SHEEP,wheat:S.RESOURCE_WHEAT,ore:S.RESOURCE_ORE},yg=Cc(zt),Pc={knight:ie.DEV_CARD_KNIGHT,victoryPoint:ie.DEV_CARD_VICTORY_POINT,roadBuilding:ie.DEV_CARD_ROAD_BUILDING,yearOfPlenty:ie.DEV_CARD_YEAR_OF_PLENTY,monopoly:ie.DEV_CARD_MONOPOLY},Mg=Cc(Pc),Lg=new Map([[d.TERRAIN_FOREST,"forest"],[d.TERRAIN_HILLS,"hills"],[d.TERRAIN_PASTURE,"pasture"],[d.TERRAIN_FIELDS,"fields"],[d.TERRAIN_MOUNTAINS,"mountains"],[d.TERRAIN_DESERT,"desert"]]),uu=class extends Error{static{E(this,"OHUnsupportedError")}constructor(r){super(r),this.name="OHUnsupportedError"}};function Eu(e,r,t){let o=e.get(r);if(o===void 0)throw new uu(`OpenHex has no ${t} for engine value ${String(r)}`);return o}E(Eu,"named");var Ze=E(e=>Eu(gg,e,"colour"),"ohColor"),Gi=E(e=>Eu(yg,e,"resource"),"ohResource"),KO=E(e=>Eu(Mg,e,"development card"),"ohDevCard"),WO=E(e=>Eu(Lg,e,"terrain"),"ohTerrain");function dt(e){let r={};for(let t of _t){let o=e?.get(zt[t])??0;o>0&&(r[t]=o)}return r}E(dt,"ohResourceMap");function lu(...e){let r={};for(let t of Ic){let o=e.reduce((i,n)=>i+(n?.get(Pc[t])??0),0);o>0&&(r[t]=o)}return r}E(lu,"ohDevCardMap");function Jn(e,r,t){return e.getPlayersOnTile(r).filter(o=>o!==t&&(e.getPlayerPublicState(o)?.cardCount??0)>0)}E(Jn,"stealTargets");function pc(e){let r=e.turnOrder.length,t=e.turnNumber,o=t<r?1:2,i=e.currentPlayer,n=e.board.getRoadsByPlayer(i),a=e.board.getSettlements().filter(s=>s.owner===i).map(s=>s.vertex).find(s=>!n.some(u=>u.edge.hasVertex(s)));return{round:o,index:o===1?t:t-r,placedSettlement:a!==void 0,settlement:a}}E(pc,"setupStep");function cu(e){return e===void 0||e===x.PLAYER_COLOR_UNSPECIFIED?null:Ze(e)}E(cu,"colorOrNull");function Gg(e,r){if(cu(e.winner)!==null)return null;if(e.isSetupPhase)return pc(e).placedSettlement?{type:"placeInitialRoad"}:{type:"placeInitialSettlement"};let t={};for(let[n,a]of e.pendingDiscards)a>0&&(t[Ze(n)]=a);if(Object.keys(t).length>0)return{type:"discardResources",players:t};let o=e.pendingRobberStealLocation;if(o)return{type:"stealFromPlayer",hex:Hr(o,r),targets:Jn(e,o,e.currentPlayer).map(Ze)};if(e.pendingRobberOrPiratePlacement)return{type:"moveRobber"};let i=(e.pendingFreeStructures.get(e.currentPlayer)??[]).filter(n=>n===F.BUILDING_ROAD).length;return i>0?{type:"placeFreeRoad",remaining:i}:e.pendingDiceRoll?{type:"rollDice"}:null}E(Gg,"pendingAction");function Ug(e,r){let t=e.board,o={tiles:t.getTiles().map(s=>({hex:Hr(s.location,r),terrain:WO(s.terrain),...s.numbers.length>0&&{number:s.numbers[0]}})),ports:t.ports.map(s=>({edge:Xt(s.edge,r),rate:s.rate,...!s.isGeneric&&{resource:Gi(s.resource)}}))};t.robbers.length>0&&(o.robberHex=Hr(t.robbers[0],r));let i=t.getSettlements().map(s=>({vertex:Gt(s.vertex,r),player:Ze(s.owner)})),n=t.getCities().map(s=>({vertex:Gt(s.vertex,r),player:Ze(s.owner)})),a=t.getRoads().map(s=>({edge:Xt(s.edge,r),player:Ze(s.owner)}));return i.length>0&&(o.settlements=i),n.length>0&&(o.cities=n),a.length>0&&(o.roads=a),o}E(Ug,"board");function Bg(e,r,t){let o=e.getPlayerPublicState(r),i={color:Ze(r),playedDevCards:lu(o?.playedDevCards),knightsPlayed:o?.playedKnights??0,longestRoadLength:o?.longestRoadLength??0},n=r===t?e.getPlayerState(r):void 0;return n?{...i,hand:dt(n.hand),devCards:lu(n.unplayedDevCards,n.devCardsPurchasedThisTurn),devCardsBoughtThisTurn:lu(n.devCardsPurchasedThisTurn)}:{...i,hand:{},devCards:{},devCardsBoughtThisTurn:{},handSize:o?.cardCount??0,devCardCount:o?.unplayedDevCardCount??0}}E(Bg,"player");function Es(e,r,t={}){let o=t.format??"coordinates",i=e.options,n=e.isSetupPhase?pc(e):void 0,a={config:{victoryPoints:i.victoryPoints,discardLimit:i.discardLimit,numPlayers:e.turnOrder.length,robberMode:i.robberMode===zr.ROBBER_MODE_FRIENDLY?"friendly":"normal",diceMode:i.diceMode===br.DICE_MODE_BALANCED?"balanced":"random",maxSettlements:i.maxSettlements,maxCities:i.maxCities,maxRoads:i.maxRoads},board:Ug(e,o),bank:dt(e.resourceDeck),devCardDeck:{remaining:e.getDevCardsLeftInDeck()},players:e.turnOrder.map(s=>Bg(e,s,r)),currentPlayer:Ze(e.currentPlayer),turnOrder:e.turnOrder.map(Ze),turnNumber:e.isSetupPhase?0:e.turnNumber+1,isSetupPhase:e.isSetupPhase,dice:e.dice&&!e.isSetupPhase&&!e.pendingDiceRoll?{die1:e.dice.die1,die2:e.dice.die2}:null,pendingAction:t.pendingOverride??Gg(e,o),playedDevCardThisTurn:e.playedDevCardThisTurn,trades:e.getActiveTrades().map(s=>({tradeId:s.id,proposer:Ze(s.proposer),offering:dt(s.offering),requesting:dt(s.requesting),accepting:[...s.acceptingPlayers].map(Ze),rejected:[...s.rejectedPlayers].map(Ze),counterTo:s.counterTradeId||null})),tradesProposedThisTurn:e.tradesProposedThisTurn,longestRoadPlayer:cu(e.longestRoadPlayer),largestArmyPlayer:cu(e.largestArmyPlayer),winner:cu(e.winner),nextTradeId:e.nextTradeId,setupRound:n?.round??2,setupIndex:n?.index??e.turnOrder.length,setupPlacedSettlement:n?.placedSettlement??!1};return n?.settlement&&(a.lastSetupSettlement=Gt(n.settlement,o)),a}E(Es,"toOpenHexState");var x_=class{static{E(this,"LocalGame")}viewer;current;last;applier=new Wt;listeners=new Set;constructor(r,t){this.viewer=t,this.current=Tc(r,t)}get game(){return this.current}get lastKey(){return this.last}apply(r,t){if(this.last!==void 0&&r<=this.last)return!1;let o=Nc(t),i=this.current;this.current=this.applier.apply(i,o.event),this.last=r;let n;for(let a of this.listeners)try{a(this.current,o,r,i)}catch(s){n??=s}if(n!==void 0)throw n;return!0}applyAll(r){let t=0;for(let o of Object.keys(r??{}).sort())this.apply(o,r[o])&&t++;return t}onChange(r){return this.listeners.add(r),()=>this.listeners.delete(r)}};var we=class extends Error{static{E(this,"OHActionError")}constructor(r){super(r),this.name="OHActionError"}},JO=["placeInitialSettlement","placeInitialRoad","rollDice","buildRoad","buildSettlement","buildCity","buyDevCard","playKnight","playRoadBuilding","playYearOfPlenty","playMonopoly","tradeWithBank","moveRobber","stealFromPlayer","discardResources","placeFreeRoad","endTurn"],kg=["proposeTrade","acceptTrade","rejectTrade","withdrawTradeAnswer","confirmTrade","cancelTrade"];function mc(e,r){if(typeof e!="string"||!_t.includes(e))throw new we(`${r} must be one of ${_t.join(", ")}, got ${JSON.stringify(e)}`);return e}E(mc,"resource");function hc(e,r){if(!e||typeof e!="object"||Array.isArray(e))throw new we(`${r} must be a map like {"wood": 2}, got ${JSON.stringify(e)}`);let t={};for(let[o,i]of Object.entries(e)){let n=mc(o,`${r} key`);if(!Number.isInteger(i)||i<0)throw new we(`${r}.${o} must be a whole number of cards, got ${JSON.stringify(i)}`);i>0&&(t[n]=i)}return t}E(hc,"resourceMap");function Dc(e){return new Map(Object.entries(e).map(([r,t])=>[zt[r],t]))}E(Dc,"engineMap");function bg(e,r){if(typeof e!="string"||!(e in V_))throw new we(`${r} must be a seat colour (red, blue, white, orange), got ${JSON.stringify(e)}`);return e}E(bg,"color");function gc(e){try{return vg(e)}catch(r){throw r instanceof Ot?new we(r.message):r}}E(gc,"parseOpenHexAction");function vg(e){if(!e||typeof e!="object"||Array.isArray(e))throw new we(`An action must be an object with a "type", got ${JSON.stringify(e)}`);let r={...e};r.hex===void 0&&r.location!==void 0&&(r.hex=r.location),r.edge===void 0&&r.vertices!==void 0&&(r.edge=r.vertices);let t=r.type;if(typeof t=="string"&&kg.includes(t))throw new we(`${t}: trading between players is not available here; trade with the bank (tradeWithBank)`);if(typeof t!="string"||!JO.includes(t))throw new we(`Unknown action type ${JSON.stringify(t)}; expected one of ${JO.join(", ")}`);let o=E(i=>{if(r[i]===void 0)throw new we(`${t} needs "${i}"`);return r[i]},"need");switch(t){case"placeInitialSettlement":case"buildSettlement":case"buildCity":{let i=o("vertex");return Wn(i),{type:t,vertex:i}}case"placeInitialRoad":case"buildRoad":case"placeFreeRoad":{let i=o("edge");return us(i),{type:t,edge:i}}case"playKnight":case"moveRobber":{let i=o("hex");return Li(i),{type:t,hex:i}}case"playYearOfPlenty":{let i=o("resources");if(!Array.isArray(i)||i.length!==2)throw new we('playYearOfPlenty needs "resources": a list of 2, e.g. ["wheat", "ore"]');return{type:"playYearOfPlenty",resources:i.map((n,a)=>mc(n,`resources[${a}]`))}}case"playMonopoly":return{type:"playMonopoly",resource:mc(o("resource"),"resource")};case"tradeWithBank":return{type:"tradeWithBank",offering:hc(o("offering"),"offering"),requesting:hc(o("requesting"),"requesting")};case"stealFromPlayer":return{type:"stealFromPlayer",target:bg(o("target"),"target")};case"discardResources":return{type:"discardResources",resources:hc(o("resources"),"resources")};default:return{type:t}}}E(vg,"parse");function ls(e,r,t){switch(t.type){case"placeInitialSettlement":return[cr.placeInitialSettlement(r,Wn(t.vertex))];case"placeInitialRoad":return[cr.placeInitialRoad(r,us(t.edge))];case"rollDice":return[cr.rollDice(r)];case"buildRoad":return[cr.buildRoad(r,us(t.edge))];case"buildSettlement":return[cr.buildSettlement(r,Wn(t.vertex))];case"buildCity":return[cr.buildCity(r,Wn(t.vertex))];case"buyDevCard":return[cr.buyDevCard(r)];case"playKnight":return[cr.playKnight(r),cr.moveRobber(r,Li(t.hex))];case"playRoadBuilding":return[cr.playRoadBuilding(r)];case"playYearOfPlenty":{let o=e.pendingFreeResources.get(r)??0,i=t.resources.map(n=>cr.selectFreeResource(r,zt[n]));return o>0?i.slice(0,o):[cr.playYearOfPlenty(r),...i]}case"playMonopoly":return[cr.playMonopoly(r,zt[t.resource])];case"tradeWithBank":return[cr.tradeWithBank(r,Dc(t.offering),Dc(t.requesting))];case"moveRobber":return[cr.moveRobber(r,Li(t.hex))];case"stealFromPlayer":return[cr.stealFromPlayer(r,V_[t.target])];case"discardResources":return[cr.discardResources(r,Dc(t.resources))];case"placeFreeRoad":return[cr.placeFreeRoad(r,us(t.edge))];case"endTurn":return[cr.endTurn(r)]}}E(ls,"toEngineActions");var qO=new Vn;function w_(e,r,t){if(t.type==="stealFromPlayer"){let n=e.pendingRobberStealLocation;if(!n||e.currentPlayer!==r)return"There is no steal to choose now";let a=Jn(e,n,r).map(Ze);return a.includes(t.target)?void 0:`You can steal from ${a.join(" or ")}, not ${t.target}`}if(t.type==="buyDevCard"&&e.getDevCardsLeftInDeck()<=0)return"The development card deck is empty";let o=ls(e,r,t),i=qO.validate(e,o[0]);if(!i.valid)return i.error??"Not legal now";if(t.type==="playKnight"){let n=new pn().executeSync(e,o[0]);if(!n.success||!n.game)return n.error??"Not legal now";let a=n.game.winner;if(a!==void 0&&a!==x.PLAYER_COLOR_UNSPECIFIED)return;let s=qO.validate(n.game,o[1]);if(!s.valid)return s.error??"The robber cannot go there"}if(t.type==="playYearOfPlenty")for(let n of new Set(t.resources)){let a=t.resources.filter(s=>s===n).length;if((e.resourceDeck.get(zt[n])??0)<a)return`The bank does not have ${a} ${n}`}}E(w_,"whyIllegal");function Yg(e){let r=e.board.getTiles().map(i=>i.location),t=new Map,o=new Map;for(let i of r){for(let n of i.getAllVerticies())t.set(n.toString(),n);for(let n of i.getAllEdges())o.set(n.toString(),n)}return{hexes:r,vertices:[...t.values()],edges:[...o.values()]}}E(Yg,"boardPoints");function Fg(e,r){let t=_t.filter(n=>(e[n]??0)>0),o=[],i=E((n,a,s)=>{if(a===0){o.push({...s});return}if(n===t.length)return;let u=t[n];for(let l=Math.min(a,e[u]??0);l>=0;l--)l>0?s[u]=l:delete s[u],i(n+1,a-l,s);delete s[u]},"pick");return i(0,r,{}),o}E(Fg,"discardChoices");function Vg(e,r){return yd(e).some(t=>t.player===r)}E(Vg,"isAskedToAct");function yc(e,r,t="coordinates"){if(!Vg(e,r))return[];let{hexes:o,vertices:i,edges:n}=Yg(e),a=E(T=>Hr(T,t),"hex"),s=E(T=>Gt(T,t),"vertex"),u=E(T=>Xt(T,t),"edge"),l=[],c=e.currentPlayer===r,f=e.pendingDiscards.get(r)??0;if(f>0){let T=dt(e.getPlayerState(r)?.hand);l.push(...Fg(T,f).map(R=>({type:"discardResources",resources:R})))}else if(e.isSetupPhase)c&&(l.push(...i.map(T=>({type:"placeInitialSettlement",vertex:s(T)}))),l.push(...n.map(T=>({type:"placeInitialRoad",edge:u(T)}))));else if(c&&e.pendingRobberStealLocation)for(let T of Jn(e,e.pendingRobberStealLocation,r))l.push({type:"stealFromPlayer",target:Ze(T)});else c&&e.pendingRobberOrPiratePlacement?l.push(...o.map(T=>({type:"moveRobber",hex:a(T)}))):c&&(e.pendingFreeStructures.get(r)?.length??0)>0?l.push(...n.map(T=>({type:"placeFreeRoad",edge:u(T)}))):c&&(e.pendingFreeResources.get(r)??0)>0?l.push(...ZO()):c&&(l.push({type:"rollDice"}),l.push(...o.map(T=>({type:"playKnight",hex:a(T)}))),l.push(...n.map(T=>({type:"buildRoad",edge:u(T)}))),l.push(...i.map(T=>({type:"buildSettlement",vertex:s(T)}))),l.push(...i.map(T=>({type:"buildCity",vertex:s(T)}))),l.push({type:"buyDevCard"}),l.push({type:"playRoadBuilding"}),l.push(...ZO()),l.push(..._t.map(T=>({type:"playMonopoly",resource:T}))),l.push(...xg(e,r)),l.push({type:"endTurn"}));return l.filter(T=>w_(e,r,T)===void 0)}E(yc,"legalActions");function ZO(){let e=[];return _t.forEach((r,t)=>{for(let o of _t.slice(t))e.push({type:"playYearOfPlenty",resources:[r,o]})}),e}E(ZO,"yearOfPlentyPicks");function xg(e,r){let t=[];for(let o of _t){let i=Ml(e,r,zt[o]).ratio;for(let n of _t)n!==o&&t.push({type:"tradeWithBank",offering:{[o]:i},requesting:{[n]:1}})}return t}E(xg,"bankTrades");var H_=class{static{E(this,"OpenHexSeat")}source;seat;format;held;constructor(r,t,o="coordinates"){this.source=r,this.seat=t,this.format=o}heldNow(){return this.held&&this.held.game!==this.source.game&&(this.held=void 0),this.held}state(){let r=this.heldNow();return r?Es(r.preview,this.seat,{format:this.format,pendingOverride:r.pending}):Es(this.source.game,this.seat,{format:this.format})}legalActions(){let r=this.heldNow();return r?r.pending.targets.map(t=>({type:"stealFromPlayer",target:t})):yc(this.source.game,this.seat,this.format)}prepare(r){let t=gc(r),o=this.source.game,i=this.heldNow();if(i){if(t.type!=="stealFromPlayer")throw new we(`Choose whom to steal from first: stealFromPlayer with target ${i.pending.targets.join(" or ")}`);if(!i.pending.targets.includes(t.target))throw new we(`You can steal from ${i.pending.targets.join(" or ")}, not ${t.target}`);return this.held=void 0,{action:t,send:ls(o,this.seat,i.action)}}let n=w_(o,this.seat,t);if(n)throw new we(`${t.type}: ${n}`);if(t.type==="moveRobber"||t.type==="playKnight"){let a=Li(t.hex),s=Jn(o,a,this.seat);if(s.length===1){let u=wg(o,ls(o,this.seat,t));if(u)return this.held={game:o,action:t,preview:u,pending:{type:"stealFromPlayer",hex:Hr(a,this.format),targets:s.map(Ze)}},{action:t,send:[]}}}return{action:t,send:ls(o,this.seat,t)}}};function wg(e,r){let t=new pn,o=e;for(let i of r){let n=t.executeSync(o,i);if(!n.success||!n.game)return;o=n.game}return o}E(wg,"playLocally");var Xe=h;function K_(e){return e===void 0||e===x.PLAYER_COLOR_UNSPECIFIED?null:Ze(e)}E(K_,"colorOrNull");function XO(e,r,t){let o=e.getTotalVictoryPoints(r);return t===ht.WIN_REASON_VICTORY_POINTS?Math.max(o,e.getVictoryPointsThreshold(r)):o}E(XO,"winnerPoints");var fu=class{static{E(this,"OpenHexEventTranslator")}format;knight;plenty;constructor(r="coordinates"){this.format=r}translate(r,t,o){let i=this.one(r,t,o);if(this.knight&&r.type!==Xe.GAME_EVENT_TYPE_PLAY_KNIGHT)if(r.type===Xe.GAME_EVENT_TYPE_MOVE_ROBBER&&r.player===this.knight.player)i=[...i,...this.knight.held],this.knight=void 0;else if(r.type===Xe.GAME_EVENT_TYPE_AWARD_LARGEST_ARMY)this.knight.held.push(...i),i=[];else{let n=t.board.robbers[0];i=[...n?[{type:"knightPlayed",player:Ze(this.knight.player),hex:Hr(n,this.format)}]:[],...this.knight.held,...i],this.knight=void 0}return r.type!==Xe.GAME_EVENT_TYPE_GAME_WON&&!K_(t.winner)&&K_(o.winner)&&i.push({type:"gameWon",player:Ze(o.winner),victoryPoints:XO(o,o.winner,void 0)}),i}one(r,t,o){let i=this.format,n=K_(r.player);if(this.plenty&&r.type!==Xe.GAME_EVENT_TYPE_SELECT_FREE_RESOURCE&&r.type!==Xe.GAME_EVENT_TYPE_FREE_RESOURCE_GRANTED)return[this.finishPlenty(),...this.one(r,t,o)];switch(r.type){case Xe.GAME_EVENT_TYPE_PLACE_FREE_STRUCTURE:return r.building===F.BUILDING_SETTLEMENT&&r.vertex&&t.isSetupPhase?[{type:"setupSettlementPlaced",player:n,vertex:Gt(r.vertex,i)}]:r.building===F.BUILDING_ROAD&&r.edge?t.isSetupPhase?[{type:"setupRoadPlaced",player:n,edge:Xt(r.edge,i)}]:[{type:"freeRoadPlaced",player:n,edge:Xt(r.edge,i)}]:[];case Xe.GAME_EVENT_TYPE_RECEIVE_RESOURCES:return t.isSetupPhase?[{type:"setupResourcesGranted",player:n,resources:dt(r.resources)}]:[];case Xe.GAME_EVENT_TYPE_ROLL_DICE:return r.dice?[{type:"diceRolled",player:n,die1:r.dice.die1,die2:r.dice.die2}]:[];case Xe.GAME_EVENT_TYPE_RESOURCE_DISTRIBUTION:{let a=r.resourceDistribution;if(!a)return[];let s={};for(let u of a.playerProduction){let l=dt(u.getTotalResources());Object.keys(l).length>0&&(s[Ze(u.player)]=l)}return Object.keys(s).length>0?[{type:"resourcesProduced",diceTotal:a.diceTotal,production:s}]:[]}case Xe.GAME_EVENT_TYPE_BUILD_SETTLEMENT:return r.vertex?[{type:"settlementBuilt",player:n,vertex:Gt(r.vertex,i)}]:[];case Xe.GAME_EVENT_TYPE_BUILD_CITY:return r.vertex?[{type:"cityBuilt",player:n,vertex:Gt(r.vertex,i)}]:[];case Xe.GAME_EVENT_TYPE_BUILD_ROAD:return r.edge?[{type:"roadBuilt",player:n,edge:Xt(r.edge,i)}]:[];case Xe.GAME_EVENT_TYPE_BUY_DEV_CARD:return[{type:"devCardBought",player:n,...r.devCard?{card:KO(r.devCard)}:{}}];case Xe.GAME_EVENT_TYPE_PLAY_KNIGHT:if(r.robberLocation){let a=K_(r.targetPlayer)?[{type:"resourceStolen",player:n,target:Ze(r.targetPlayer),...r.stolenResource?{resource:Gi(r.stolenResource)}:{}}]:[];return[{type:"knightPlayed",player:n,hex:Hr(r.robberLocation,i)},...a]}return this.knight={player:r.player,held:[]},[];case Xe.GAME_EVENT_TYPE_MOVE_ROBBER:return r.robberLocation?this.knight?.player===r.player?[{type:"knightPlayed",player:n,hex:Hr(r.robberLocation,i)}]:[{type:"robberMoved",player:n,hex:Hr(r.robberLocation,i)}]:[];case Xe.GAME_EVENT_TYPE_STEAL_RESOURCE:return K_(r.targetPlayer)?[{type:"resourceStolen",player:n,target:Ze(r.targetPlayer),...r.stolenResource?{resource:Gi(r.stolenResource)}:{}}]:[];case Xe.GAME_EVENT_TYPE_DISCARD_RESOURCES:return[{type:"resourcesDiscarded",player:n,resources:dt(r.resources)}];case Xe.GAME_EVENT_TYPE_PLAY_ROAD_BUILDING:return[{type:"roadBuildingPlayed",player:n}];case Xe.GAME_EVENT_TYPE_PLAY_YEAR_OF_PLENTY:return this.plenty={player:n,owed:2,picks:[]},[];case Xe.GAME_EVENT_TYPE_FREE_RESOURCE_GRANTED:return!this.plenty||r.freeResourceReason!==Ir.FREE_RESOURCE_REASON_YEAR_OF_PLENTY?[]:(this.plenty.owed=r.freeResourceCount??2,this.plenty.owed<=this.plenty.picks.length?[this.finishPlenty()]:[]);case Xe.GAME_EVENT_TYPE_SELECT_FREE_RESOURCE:return!this.plenty||r.selectedResource===void 0?[]:(this.plenty.picks.push(Gi(r.selectedResource)),this.plenty.picks.length>=this.plenty.owed?[this.finishPlenty()]:[]);case Xe.GAME_EVENT_TYPE_PLAY_MONOPOLY:{if(r.monopolyResource===void 0)return[];let a={};for(let s of r.monopolyResults??[])s.count>0&&(a[Ze(s.player)]=s.count);return[{type:"monopolyPlayed",player:n,resource:Gi(r.monopolyResource),collected:a}]}case Xe.GAME_EVENT_TYPE_TRADE_WITH_BANK:return[{type:"bankTradeExecuted",player:n,offering:dt(r.offeredResources),requesting:dt(r.receivedResources)}];case Xe.GAME_EVENT_TYPE_END_TURN:return t.isSetupPhase?[]:[{type:"turnEnded",player:n,turnNumber:t.turnNumber+1}];case Xe.GAME_EVENT_TYPE_AWARD_LONGEST_ROAD:return n?[{type:"longestRoadAwarded",player:n,length:o.getPlayerPublicState(r.player)?.longestRoadLength??0}]:[{type:"longestRoadAwarded",player:null,length:0}];case Xe.GAME_EVENT_TYPE_AWARD_LARGEST_ARMY:return n?[{type:"largestArmyAwarded",player:n,knights:o.getPlayerPublicState(r.player)?.playedKnights??0}]:[];case Xe.GAME_EVENT_TYPE_GAME_WON:return n?[{type:"gameWon",player:n,victoryPoints:XO(o,r.player,r.winReason)}]:[];case Xe.GAME_EVENT_TYPE_RESIGN:return n?[{type:"playerResigned",player:n}]:[];default:return[]}}finishPlenty(){let r=this.plenty;return this.plenty=void 0,{type:"yearOfPlentyPlayed",player:r.player,resources:r.picks}}},W_=class{static{E(this,"OpenHexEventLog")}entries=[];skipped=[];translator;stop;constructor(r,t="coordinates"){if(r.lastKey!==void 0)throw new Error("OpenHexEventLog must be attached before the LocalGame applies its first event");this.translator=new fu(t),this.stop=r.onChange((o,i,n,a)=>{let s;try{s=this.translator.translate(i.event,a,o)}catch(u){this.skipped.push(`${n}: ${u instanceof Error?u.message:String(u)}`);return}for(let u of s)this.entries.push({seq:this.entries.length,event:u})})}after(r=-1){return this.entries.slice(Math.max(0,r+1))}get lastSeq(){return this.entries.length-1}detach(){this.stop()}};var Hg="Another action is being processed",zO=E(e=>new Promise(r=>setTimeout(r,e)),"sleep");async function Kg(e,r,t){let o=Date.now()+t;for(let i=250;Date.now()<o;i=Math.min(i*2,2e3))if(await zO(i),!(await e.getGame(r))?.loading)return;throw new Error(`Game ${r} is still waiting for the other players to load after ${Math.round(t/1e3)} s`)}E(Kg,"waitWhileLoading");var J_=class e{static{E(this,"GameSession")}transport;gameId;viewer;local;log;seat;options;applied=0;endedOnServer=!1;authors=[];closed=!1;streamError;waiters=new Set;stopEvents=E(()=>{},"stopEvents");stopCounting;constructor(r,t,o,i,n,a,s){this.transport=r,this.gameId=t,this.viewer=o,this.local=i,this.log=n,this.seat=a,this.options=s,this.stopCounting=i.onChange((u,l)=>{this.authors.push(l.event.player),this.applied++,this.wake()})}follow(){this.stopEvents=this.transport.followEvents(du(this.gameId,this.viewer),this.local.lastKey,(r,t)=>{try{this.local.apply(r,t)}catch(o){this.fail(new Error(`Could not apply game event ${r}: ${o instanceof Error?o.message:String(o)}. The game may use something this client does not support, or the client is older than the server.`))}},r=>this.fail(r))}fail(r){this.streamError??=r,this.wake()}static async open(r,t){let o=await r.getGame(t.gameId);if(!o)throw new Error(`No game ${t.gameId}`);if(!o.initialGameState)throw new Error(`Game ${t.gameId} has no initial state (it may have been cleaned up)`);let i=cc(o.players,t.uid),n=t.format??"coordinates",a=new x_(o.initialGameState,i),s=new W_(a,n),u=i.kind==="player"?new H_(a,i.color,n):void 0,l=new e(r,t.gameId,i,a,s,u,{format:n,syncTimeoutMs:t.syncTimeoutMs??15e3,busyRetries:t.busyRetries??8,busyDelayMs:t.busyDelayMs??250});try{return r.loadEvents&&a.applyAll(await r.loadEvents(du(t.gameId,i))),l.follow(),i.kind==="player"&&o.players[i.key]?.loading&&await r.reportLoaded?.(t.gameId),o.loading&&await Kg(r,t.gameId,t.loadingTimeoutMs??6e4),l}catch(c){throw l.close(),c}}get color(){return this.viewer.kind==="player"?Ze(this.viewer.color):null}get eventCount(){return this.applied}get version(){return`${this.local.lastKey??"-"}:${this.seat?.state().pendingAction?.type??""}`}get isOver(){let r=this.local.game.winner;return this.endedOnServer||r!==void 0&&r!==x.PLAYER_COLOR_UNSPECIFIED}get paused(){return this.local.game.paused}state(){return this.seat?this.seat.state():Es(this.local.game,void 0,{format:this.options.format})}legalActions(){return this.seat&&!this.isOver?this.seat.legalActions():[]}events(r=-1){return this.log.after(r)}async waitForTurn(r){let t=E(()=>this.isOver||this.legalActions().length>0,"ready");if(!await this.waitUntil(t,r)){if(this.closed)return"timeout";let o=await this.transport.getGame(this.gameId).catch(()=>{});return o===null||o?.ended?(this.endedOnServer=!0,"game_over"):"timeout"}return this.isOver?"game_over":"your_turn"}async act(r){if(!this.seat)throw new we("You are watching this game, not playing in it");if(this.isOver)throw new we("The game is over");let t=this.seat.prepare(r);for(let o of t.send){if(this.isOver)break;let i=this.applied,n=await this.send(o);if(!n.success)throw new we(`The server refused ${t.action.type}: ${n.error??"no reason given"}`);if(!await this.waitUntil(()=>this.ownEventsApplied(i,o.player,n.eventCount),this.options.syncTimeoutMs))throw new Error(`The server accepted ${t.action.type}, but its result has not arrived after ${Math.round(this.options.syncTimeoutMs/1e3)} s, so the game shown may be out of date. Check the connection, then wait_for_turn.`)}return{action:t.action,sent:t.send.length}}ownEventsApplied(r,t,o){if(o<=0)return!0;let i=this.authors.indexOf(t,r);return i>=0&&this.applied-i>=o}close(){this.closed=!0,this.stopEvents(),this.stopCounting(),this.log.detach(),this.wake()}async send(r){let t=this.options.busyDelayMs;for(let o=0;;o++){let i=await this.transport.executeAction(this.gameId,r);if(i.success||i.error!==Hg||o>=this.options.busyRetries)return i;await zO(t),t*=2}}waitUntil(r,t){return this.streamError?Promise.reject(this.streamError):r()?Promise.resolve(!0):this.closed?Promise.resolve(!1):new Promise((o,i)=>{let n=E(()=>{try{this.closed?(s(),o(!1)):this.streamError?(s(),i(this.streamError)):r()&&(s(),o(!0))}catch(u){s(),i(u)}},"check"),a=setTimeout(()=>{s(),o(!1)},t),s=E(()=>{clearTimeout(a),this.waiters.delete(n)},"done");this.waiters.add(n)})}wake(){for(let r of[...this.waiters])r()}};var Sr;(function(e){e[e.PLAYER_TYPE_UNSPECIFIED=0]="PLAYER_TYPE_UNSPECIFIED",e[e.PLAYER_TYPE_HUMAN=1]="PLAYER_TYPE_HUMAN",e[e.PLAYER_TYPE_AI_EASY=2]="PLAYER_TYPE_AI_EASY",e[e.PLAYER_TYPE_AI_MEDIUM=3]="PLAYER_TYPE_AI_MEDIUM",e[e.PLAYER_TYPE_AI_HARD=4]="PLAYER_TYPE_AI_HARD",e[e.PLAYER_TYPE_AI_EXPERT=5]="PLAYER_TYPE_AI_EXPERT",e[e.PLAYER_TYPE_OPEN=6]="PLAYER_TYPE_OPEN",e[e.PLAYER_TYPE_CLOSED=7]="PLAYER_TYPE_CLOSED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Sr||(Sr={}));function q_(e){switch(e){case 0:case"PLAYER_TYPE_UNSPECIFIED":return Sr.PLAYER_TYPE_UNSPECIFIED;case 1:case"PLAYER_TYPE_HUMAN":return Sr.PLAYER_TYPE_HUMAN;case 2:case"PLAYER_TYPE_AI_EASY":return Sr.PLAYER_TYPE_AI_EASY;case 3:case"PLAYER_TYPE_AI_MEDIUM":return Sr.PLAYER_TYPE_AI_MEDIUM;case 4:case"PLAYER_TYPE_AI_HARD":return Sr.PLAYER_TYPE_AI_HARD;case 5:case"PLAYER_TYPE_AI_EXPERT":return Sr.PLAYER_TYPE_AI_EXPERT;case 6:case"PLAYER_TYPE_OPEN":return Sr.PLAYER_TYPE_OPEN;case 7:case"PLAYER_TYPE_CLOSED":return Sr.PLAYER_TYPE_CLOSED;default:return Sr.UNRECOGNIZED}}E(q_,"playerTypeFromJSON");function Tu(e){switch(e){case Sr.PLAYER_TYPE_UNSPECIFIED:return"PLAYER_TYPE_UNSPECIFIED";case Sr.PLAYER_TYPE_HUMAN:return"PLAYER_TYPE_HUMAN";case Sr.PLAYER_TYPE_AI_EASY:return"PLAYER_TYPE_AI_EASY";case Sr.PLAYER_TYPE_AI_MEDIUM:return"PLAYER_TYPE_AI_MEDIUM";case Sr.PLAYER_TYPE_AI_HARD:return"PLAYER_TYPE_AI_HARD";case Sr.PLAYER_TYPE_AI_EXPERT:return"PLAYER_TYPE_AI_EXPERT";case Sr.PLAYER_TYPE_OPEN:return"PLAYER_TYPE_OPEN";case Sr.PLAYER_TYPE_CLOSED:return"PLAYER_TYPE_CLOSED";case Sr.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Tu,"playerTypeToJSON");var ut;(function(e){e[e.AGENT_KIND_NONE=0]="AGENT_KIND_NONE",e[e.AGENT_KIND_LLM=1]="AGENT_KIND_LLM",e[e.AGENT_KIND_PROGRAM=2]="AGENT_KIND_PROGRAM",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ut||(ut={}));function Kr(e){switch(e){case 0:case"AGENT_KIND_NONE":return ut.AGENT_KIND_NONE;case 1:case"AGENT_KIND_LLM":return ut.AGENT_KIND_LLM;case 2:case"AGENT_KIND_PROGRAM":return ut.AGENT_KIND_PROGRAM;default:return ut.UNRECOGNIZED}}E(Kr,"agentKindFromJSON");function Ut(e){switch(e){case ut.AGENT_KIND_NONE:return"AGENT_KIND_NONE";case ut.AGENT_KIND_LLM:return"AGENT_KIND_LLM";case ut.AGENT_KIND_PROGRAM:return"AGENT_KIND_PROGRAM";case ut.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Ut,"agentKindToJSON");import{BinaryReader as ae,BinaryWriter as We}from"@bufbuild/protobuf/wire";var $O;(function(e){e[e.DEV_CARD_UNSPECIFIED=0]="DEV_CARD_UNSPECIFIED",e[e.DEV_CARD_KNIGHT=1]="DEV_CARD_KNIGHT",e[e.DEV_CARD_VICTORY_POINT=2]="DEV_CARD_VICTORY_POINT",e[e.DEV_CARD_ROAD_BUILDING=3]="DEV_CARD_ROAD_BUILDING",e[e.DEV_CARD_YEAR_OF_PLENTY=4]="DEV_CARD_YEAR_OF_PLENTY",e[e.DEV_CARD_MONOPOLY=5]="DEV_CARD_MONOPOLY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})($O||($O={}));var QO;(function(e){e[e.BUILDING_UNSPECIFIED=0]="BUILDING_UNSPECIFIED",e[e.BUILDING_DEV_CARD=1]="BUILDING_DEV_CARD",e[e.BUILDING_ROAD=2]="BUILDING_ROAD",e[e.BUILDING_SETTLEMENT=3]="BUILDING_SETTLEMENT",e[e.BUILDING_CITY=4]="BUILDING_CITY",e[e.BUILDING_SHIP=5]="BUILDING_SHIP",e[e.BUILDING_KNIGHT=6]="BUILDING_KNIGHT",e[e.BUILDING_ROAD_OR_SHIP=7]="BUILDING_ROAD_OR_SHIP",e[e.BUILDING_BROKEN_CITY=8]="BUILDING_BROKEN_CITY",e[e.BUILDING_BROKEN_ROAD=9]="BUILDING_BROKEN_ROAD",e[e.BUILDING_BRIDGE=10]="BUILDING_BRIDGE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(QO||(QO={}));var Br;(function(e){e[e.RESOURCE_UNSPECIFIED=0]="RESOURCE_UNSPECIFIED",e[e.RESOURCE_WOOD=1]="RESOURCE_WOOD",e[e.RESOURCE_BRICK=2]="RESOURCE_BRICK",e[e.RESOURCE_SHEEP=3]="RESOURCE_SHEEP",e[e.RESOURCE_WHEAT=4]="RESOURCE_WHEAT",e[e.RESOURCE_ORE=5]="RESOURCE_ORE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Br||(Br={}));function $t(e){switch(e){case 0:case"RESOURCE_UNSPECIFIED":return Br.RESOURCE_UNSPECIFIED;case 1:case"RESOURCE_WOOD":return Br.RESOURCE_WOOD;case 2:case"RESOURCE_BRICK":return Br.RESOURCE_BRICK;case 3:case"RESOURCE_SHEEP":return Br.RESOURCE_SHEEP;case 4:case"RESOURCE_WHEAT":return Br.RESOURCE_WHEAT;case 5:case"RESOURCE_ORE":return Br.RESOURCE_ORE;default:return Br.UNRECOGNIZED}}E($t,"resourceFromJSON");function Qt(e){switch(e){case Br.RESOURCE_UNSPECIFIED:return"RESOURCE_UNSPECIFIED";case Br.RESOURCE_WOOD:return"RESOURCE_WOOD";case Br.RESOURCE_BRICK:return"RESOURCE_BRICK";case Br.RESOURCE_SHEEP:return"RESOURCE_SHEEP";case Br.RESOURCE_WHEAT:return"RESOURCE_WHEAT";case Br.RESOURCE_ORE:return"RESOURCE_ORE";case Br.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Qt,"resourceToJSON");var Wr;(function(e){e[e.FISH_UNSPECIFIED=0]="FISH_UNSPECIFIED",e[e.FISH_ONE_FISH=1]="FISH_ONE_FISH",e[e.FISH_TWO_FISH=2]="FISH_TWO_FISH",e[e.FISH_THREE_FISH=3]="FISH_THREE_FISH",e[e.FISH_OLD_BOOT=4]="FISH_OLD_BOOT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Wr||(Wr={}));function CI(e){switch(e){case 0:case"FISH_UNSPECIFIED":return Wr.FISH_UNSPECIFIED;case 1:case"FISH_ONE_FISH":return Wr.FISH_ONE_FISH;case 2:case"FISH_TWO_FISH":return Wr.FISH_TWO_FISH;case 3:case"FISH_THREE_FISH":return Wr.FISH_THREE_FISH;case 4:case"FISH_OLD_BOOT":return Wr.FISH_OLD_BOOT;default:return Wr.UNRECOGNIZED}}E(CI,"fishFromJSON");function PI(e){switch(e){case Wr.FISH_UNSPECIFIED:return"FISH_UNSPECIFIED";case Wr.FISH_ONE_FISH:return"FISH_ONE_FISH";case Wr.FISH_TWO_FISH:return"FISH_TWO_FISH";case Wr.FISH_THREE_FISH:return"FISH_THREE_FISH";case Wr.FISH_OLD_BOOT:return"FISH_OLD_BOOT";case Wr.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(PI,"fishToJSON");var jO;(function(e){e[e.TERRAIN_UNSPECIFIED=0]="TERRAIN_UNSPECIFIED",e[e.TERRAIN_FOREST=1]="TERRAIN_FOREST",e[e.TERRAIN_HILLS=2]="TERRAIN_HILLS",e[e.TERRAIN_PASTURE=3]="TERRAIN_PASTURE",e[e.TERRAIN_FIELDS=4]="TERRAIN_FIELDS",e[e.TERRAIN_MOUNTAINS=5]="TERRAIN_MOUNTAINS",e[e.TERRAIN_DESERT=6]="TERRAIN_DESERT",e[e.TERRAIN_SEA=7]="TERRAIN_SEA",e[e.TERRAIN_GOLD=8]="TERRAIN_GOLD",e[e.TERRAIN_LAKE_A=9]="TERRAIN_LAKE_A",e[e.TERRAIN_LAKE_B=10]="TERRAIN_LAKE_B",e[e.TERRAIN_FOG=11]="TERRAIN_FOG",e[e.TERRAIN_WATERING_HOLE=12]="TERRAIN_WATERING_HOLE",e[e.TERRAIN_SWAMP=13]="TERRAIN_SWAMP",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(jO||(jO={}));var nr;(function(e){e[e.PLAYER_COLOR_UNSPECIFIED=0]="PLAYER_COLOR_UNSPECIFIED",e[e.PLAYER_COLOR_RED=1]="PLAYER_COLOR_RED",e[e.PLAYER_COLOR_BLUE=2]="PLAYER_COLOR_BLUE",e[e.PLAYER_COLOR_WHITE=3]="PLAYER_COLOR_WHITE",e[e.PLAYER_COLOR_ORANGE=4]="PLAYER_COLOR_ORANGE",e[e.PLAYER_COLOR_YELLOW=5]="PLAYER_COLOR_YELLOW",e[e.PLAYER_COLOR_GREEN=6]="PLAYER_COLOR_GREEN",e[e.PLAYER_COLOR_TEAL=7]="PLAYER_COLOR_TEAL",e[e.PLAYER_COLOR_PURPLE=8]="PLAYER_COLOR_PURPLE",e[e.PLAYER_COLOR_PINK=9]="PLAYER_COLOR_PINK",e[e.PLAYER_COLOR_BLACK=10]="PLAYER_COLOR_BLACK",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(nr||(nr={}));function Ke(e){switch(e){case 0:case"PLAYER_COLOR_UNSPECIFIED":return nr.PLAYER_COLOR_UNSPECIFIED;case 1:case"PLAYER_COLOR_RED":return nr.PLAYER_COLOR_RED;case 2:case"PLAYER_COLOR_BLUE":return nr.PLAYER_COLOR_BLUE;case 3:case"PLAYER_COLOR_WHITE":return nr.PLAYER_COLOR_WHITE;case 4:case"PLAYER_COLOR_ORANGE":return nr.PLAYER_COLOR_ORANGE;case 5:case"PLAYER_COLOR_YELLOW":return nr.PLAYER_COLOR_YELLOW;case 6:case"PLAYER_COLOR_GREEN":return nr.PLAYER_COLOR_GREEN;case 7:case"PLAYER_COLOR_TEAL":return nr.PLAYER_COLOR_TEAL;case 8:case"PLAYER_COLOR_PURPLE":return nr.PLAYER_COLOR_PURPLE;case 9:case"PLAYER_COLOR_PINK":return nr.PLAYER_COLOR_PINK;case 10:case"PLAYER_COLOR_BLACK":return nr.PLAYER_COLOR_BLACK;default:return nr.UNRECOGNIZED}}E(Ke,"playerColorFromJSON");function _r(e){switch(e){case nr.PLAYER_COLOR_UNSPECIFIED:return"PLAYER_COLOR_UNSPECIFIED";case nr.PLAYER_COLOR_RED:return"PLAYER_COLOR_RED";case nr.PLAYER_COLOR_BLUE:return"PLAYER_COLOR_BLUE";case nr.PLAYER_COLOR_WHITE:return"PLAYER_COLOR_WHITE";case nr.PLAYER_COLOR_ORANGE:return"PLAYER_COLOR_ORANGE";case nr.PLAYER_COLOR_YELLOW:return"PLAYER_COLOR_YELLOW";case nr.PLAYER_COLOR_GREEN:return"PLAYER_COLOR_GREEN";case nr.PLAYER_COLOR_TEAL:return"PLAYER_COLOR_TEAL";case nr.PLAYER_COLOR_PURPLE:return"PLAYER_COLOR_PURPLE";case nr.PLAYER_COLOR_PINK:return"PLAYER_COLOR_PINK";case nr.PLAYER_COLOR_BLACK:return"PLAYER_COLOR_BLACK";case nr.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(_r,"playerColorToJSON");var eI;(function(e){e[e.FREE_RESOURCE_REASON_UNSPECIFIED=0]="FREE_RESOURCE_REASON_UNSPECIFIED",e[e.FREE_RESOURCE_REASON_YEAR_OF_PLENTY=1]="FREE_RESOURCE_REASON_YEAR_OF_PLENTY",e[e.FREE_RESOURCE_REASON_GOLD_TILE=2]="FREE_RESOURCE_REASON_GOLD_TILE",e[e.FREE_RESOURCE_REASON_AQUEDUCT=3]="FREE_RESOURCE_REASON_AQUEDUCT",e[e.FREE_RESOURCE_REASON_GOLD_TILE_DISCOVERY=4]="FREE_RESOURCE_REASON_GOLD_TILE_DISCOVERY",e[e.FREE_RESOURCE_REASON_FISH=5]="FREE_RESOURCE_REASON_FISH",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(eI||(eI={}));var rI;(function(e){e[e.FREE_STRUCTURE_REASON_UNSPECIFIED=0]="FREE_STRUCTURE_REASON_UNSPECIFIED",e[e.FREE_STRUCTURE_REASON_FISH=1]="FREE_STRUCTURE_REASON_FISH",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(rI||(rI={}));var tI;(function(e){e[e.WIN_REASON_UNSPECIFIED=0]="WIN_REASON_UNSPECIFIED",e[e.WIN_REASON_VICTORY_POINTS=1]="WIN_REASON_VICTORY_POINTS",e[e.WIN_REASON_ALL_DESERT=2]="WIN_REASON_ALL_DESERT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(tI||(tI={}));var nI;(function(e){e[e.ROBBER_MODE_UNSPECIFIED=0]="ROBBER_MODE_UNSPECIFIED",e[e.ROBBER_MODE_NORMAL=1]="ROBBER_MODE_NORMAL",e[e.ROBBER_MODE_FRIENDLY=2]="ROBBER_MODE_FRIENDLY",e[e.ROBBER_MODE_LAZY=3]="ROBBER_MODE_LAZY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(nI||(nI={}));var iI;(function(e){e[e.DICE_MODE_UNSPECIFIED=0]="DICE_MODE_UNSPECIFIED",e[e.DICE_MODE_RANDOM=1]="DICE_MODE_RANDOM",e[e.DICE_MODE_SEEDED=2]="DICE_MODE_SEEDED",e[e.DICE_MODE_BALANCED=3]="DICE_MODE_BALANCED",e[e.DICE_MODE_EVENT_CARDS=6]="DICE_MODE_EVENT_CARDS",e[e.DICE_MODE_SEEDED_MIXED=7]="DICE_MODE_SEEDED_MIXED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(iI||(iI={}));var oI;(function(e){e[e.WIN_CONDITION_UNSPECIFIED=0]="WIN_CONDITION_UNSPECIFIED",e[e.WIN_CONDITION_VICTORY_POINTS=1]="WIN_CONDITION_VICTORY_POINTS",e[e.WIN_CONDITION_BUILD_ALL_SETTLEMENTS=2]="WIN_CONDITION_BUILD_ALL_SETTLEMENTS",e[e.WIN_CONDITION_BUILD_ALL_CITIES=3]="WIN_CONDITION_BUILD_ALL_CITIES",e[e.WIN_CONDITION_BUILD_ALL_ROADS=4]="WIN_CONDITION_BUILD_ALL_ROADS",e[e.WIN_CONDITION_BUILD_ALL_PIECES=5]="WIN_CONDITION_BUILD_ALL_PIECES",e[e.WIN_CONDITION_BUY_ALL_DEV_CARDS=6]="WIN_CONDITION_BUY_ALL_DEV_CARDS",e[e.WIN_CONDITION_COLLECT_RESOURCES=7]="WIN_CONDITION_COLLECT_RESOURCES",e[e.WIN_CONDITION_TURN_LIMIT=8]="WIN_CONDITION_TURN_LIMIT",e[e.WIN_CONDITION_SETTLE_ALL_2TO1_PORTS=9]="WIN_CONDITION_SETTLE_ALL_2TO1_PORTS",e[e.WIN_CONDITION_SETTLE_ALL_3TO1_PORTS=10]="WIN_CONDITION_SETTLE_ALL_3TO1_PORTS",e[e.WIN_CONDITION_BUILD_ALL_COASTAL_ROADS=11]="WIN_CONDITION_BUILD_ALL_COASTAL_ROADS",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(oI||(oI={}));var aI;(function(e){e[e.DYNAMIC_HEX_MODE_UNSPECIFIED=0]="DYNAMIC_HEX_MODE_UNSPECIFIED",e[e.DYNAMIC_HEX_MODE_OFF=1]="DYNAMIC_HEX_MODE_OFF",e[e.DYNAMIC_HEX_MODE_DESERTIFICATION=2]="DYNAMIC_HEX_MODE_DESERTIFICATION",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(aI||(aI={}));var sI;(function(e){e[e.RESOURCE_GOAL_MODE_UNSPECIFIED=0]="RESOURCE_GOAL_MODE_UNSPECIFIED",e[e.RESOURCE_GOAL_MODE_CUMULATIVE=1]="RESOURCE_GOAL_MODE_CUMULATIVE",e[e.RESOURCE_GOAL_MODE_IN_HAND=2]="RESOURCE_GOAL_MODE_IN_HAND",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(sI||(sI={}));var _I;(function(e){e[e.FOUND_ON_FOG_MODE_DISABLED=0]="FOUND_ON_FOG_MODE_DISABLED",e[e.FOUND_ON_FOG_MODE_SHORE=1]="FOUND_ON_FOG_MODE_SHORE",e[e.FOUND_ON_FOG_MODE_WITHIN=2]="FOUND_ON_FOG_MODE_WITHIN",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(_I||(_I={}));var dI;(function(e){e[e.FOG_MODE_UNSPECIFIED=0]="FOG_MODE_UNSPECIFIED",e[e.FOG_MODE_OFF=1]="FOG_MODE_OFF",e[e.FOG_MODE_FOG_START=2]="FOG_MODE_FOG_START",e[e.FOG_MODE_MIST_START=3]="FOG_MODE_MIST_START",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(dI||(dI={}));var uI;(function(e){e[e.SETUP_PLACEMENT_MODE_NORMAL=0]="SETUP_PLACEMENT_MODE_NORMAL",e[e.SETUP_PLACEMENT_MODE_COASTAL=1]="SETUP_PLACEMENT_MODE_COASTAL",e[e.SETUP_PLACEMENT_MODE_INLAND=2]="SETUP_PLACEMENT_MODE_INLAND",e[e.SETUP_PLACEMENT_MODE_PORT=3]="SETUP_PLACEMENT_MODE_PORT",e[e.SETUP_PLACEMENT_MODE_DESERT=4]="SETUP_PLACEMENT_MODE_DESERT",e[e.SETUP_PLACEMENT_MODE_DIFFERENT_ISLAND=5]="SETUP_PLACEMENT_MODE_DIFFERENT_ISLAND",e[e.SETUP_PLACEMENT_MODE_HIGHEST_PRODUCTION=6]="SETUP_PLACEMENT_MODE_HIGHEST_PRODUCTION",e[e.SETUP_PLACEMENT_MODE_SKIP=7]="SETUP_PLACEMENT_MODE_SKIP",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(uI||(uI={}));var EI;(function(e){e[e.MAP_SHUFFLE_MODE_NONE=0]="MAP_SHUFFLE_MODE_NONE",e[e.MAP_SHUFFLE_MODE_TERRAIN_AND_NUMBERS=1]="MAP_SHUFFLE_MODE_TERRAIN_AND_NUMBERS",e[e.MAP_SHUFFLE_MODE_TERRAIN_WITH_NUMBERS=2]="MAP_SHUFFLE_MODE_TERRAIN_WITH_NUMBERS",e[e.MAP_SHUFFLE_MODE_RANDOM_DISTRIBUTION=3]="MAP_SHUFFLE_MODE_RANDOM_DISTRIBUTION",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(EI||(EI={}));var lI;(function(e){e[e.MAP_SHUFFLE_SCOPE_GLOBAL=0]="MAP_SHUFFLE_SCOPE_GLOBAL",e[e.MAP_SHUFFLE_SCOPE_INTRA_ISLAND=1]="MAP_SHUFFLE_SCOPE_INTRA_ISLAND",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(lI||(lI={}));var cI;(function(e){e[e.NUMBER_LAYOUT_UNSPECIFIED=0]="NUMBER_LAYOUT_UNSPECIFIED",e[e.NUMBER_LAYOUT_SPIRAL=1]="NUMBER_LAYOUT_SPIRAL",e[e.NUMBER_LAYOUT_RANDOM_STRICT=2]="NUMBER_LAYOUT_RANDOM_STRICT",e[e.NUMBER_LAYOUT_RANDOM_RELAXED=3]="NUMBER_LAYOUT_RANDOM_RELAXED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(cI||(cI={}));var fI;(function(e){e[e.PORT_LAYOUT_MODE_UNSPECIFIED=0]="PORT_LAYOUT_MODE_UNSPECIFIED",e[e.PORT_LAYOUT_MODE_RANDOM=1]="PORT_LAYOUT_MODE_RANDOM",e[e.PORT_LAYOUT_MODE_FIXED_6TH_EDITION=2]="PORT_LAYOUT_MODE_FIXED_6TH_EDITION",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(fI||(fI={}));var TI;(function(e){e[e.DESERT_PLACEMENT_UNSPECIFIED=0]="DESERT_PLACEMENT_UNSPECIFIED",e[e.DESERT_PLACEMENT_RANDOM=1]="DESERT_PLACEMENT_RANDOM",e[e.DESERT_PLACEMENT_CENTER=2]="DESERT_PLACEMENT_CENTER",e[e.DESERT_PLACEMENT_MIDDLE=3]="DESERT_PLACEMENT_MIDDLE",e[e.DESERT_PLACEMENT_SHORE=4]="DESERT_PLACEMENT_SHORE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(TI||(TI={}));var NI;(function(e){e[e.MAP_TYPE_UNSPECIFIED=0]="MAP_TYPE_UNSPECIFIED",e[e.MAP_TYPE_BASE_4P=1]="MAP_TYPE_BASE_4P",e[e.MAP_TYPE_BASE_6P=2]="MAP_TYPE_BASE_6P",e[e.MAP_TYPE_BASE_3P=3]="MAP_TYPE_BASE_3P",e[e.MAP_TYPE_BASE_2P=4]="MAP_TYPE_BASE_2P",e[e.MAP_TYPE_BASE_RANDOM_4P=5]="MAP_TYPE_BASE_RANDOM_4P",e[e.MAP_TYPE_BASE_8P=6]="MAP_TYPE_BASE_8P",e[e.MAP_TYPE_SEAFARERS_FORGOTTEN_TRIBE=8]="MAP_TYPE_SEAFARERS_FORGOTTEN_TRIBE",e[e.MAP_TYPE_FISH_PONDS=9]="MAP_TYPE_FISH_PONDS",e[e.MAP_TYPE_FISH_PONDS_6P=10]="MAP_TYPE_FISH_PONDS_6P",e[e.MAP_TYPE_FISH_PONDS_8P=11]="MAP_TYPE_FISH_PONDS_8P",e[e.MAP_TYPE_FISH_PONDS_3P=12]="MAP_TYPE_FISH_PONDS_3P",e[e.MAP_TYPE_FISH_PONDS_2P=13]="MAP_TYPE_FISH_PONDS_2P",e[e.MAP_TYPE_SF_NEW_SHORES_3P=100]="MAP_TYPE_SF_NEW_SHORES_3P",e[e.MAP_TYPE_SF_NEW_SHORES_4P=101]="MAP_TYPE_SF_NEW_SHORES_4P",e[e.MAP_TYPE_SF_NEW_SHORES_6P=102]="MAP_TYPE_SF_NEW_SHORES_6P",e[e.MAP_TYPE_SF_FOUR_ISLANDS_3P=110]="MAP_TYPE_SF_FOUR_ISLANDS_3P",e[e.MAP_TYPE_SF_FOUR_ISLANDS_4P=111]="MAP_TYPE_SF_FOUR_ISLANDS_4P",e[e.MAP_TYPE_SF_FOUR_ISLANDS_RANDOM=112]="MAP_TYPE_SF_FOUR_ISLANDS_RANDOM",e[e.MAP_TYPE_SF_FOG_ISLANDS_3P=120]="MAP_TYPE_SF_FOG_ISLANDS_3P",e[e.MAP_TYPE_SF_FOG_ISLANDS_4P=121]="MAP_TYPE_SF_FOG_ISLANDS_4P",e[e.MAP_TYPE_SF_THROUGH_DESERT_3P=130]="MAP_TYPE_SF_THROUGH_DESERT_3P",e[e.MAP_TYPE_SF_THROUGH_DESERT_4P=131]="MAP_TYPE_SF_THROUGH_DESERT_4P",e[e.MAP_TYPE_SF_NEW_WORLD_3P=140]="MAP_TYPE_SF_NEW_WORLD_3P",e[e.MAP_TYPE_SF_NEW_WORLD_4P=141]="MAP_TYPE_SF_NEW_WORLD_4P",e[e.MAP_TYPE_FOG_BANK_2P=204]="MAP_TYPE_FOG_BANK_2P",e[e.MAP_TYPE_FOG_BANK_3P=203]="MAP_TYPE_FOG_BANK_3P",e[e.MAP_TYPE_FOG_BANK_4P=200]="MAP_TYPE_FOG_BANK_4P",e[e.MAP_TYPE_FOG_BANK_6P=201]="MAP_TYPE_FOG_BANK_6P",e[e.MAP_TYPE_FOG_BANK_8P=202]="MAP_TYPE_FOG_BANK_8P",e[e.MAP_TYPE_MISTY_REALMS_2P=214]="MAP_TYPE_MISTY_REALMS_2P",e[e.MAP_TYPE_MISTY_REALMS_3P=213]="MAP_TYPE_MISTY_REALMS_3P",e[e.MAP_TYPE_MISTY_REALMS_4P=210]="MAP_TYPE_MISTY_REALMS_4P",e[e.MAP_TYPE_MISTY_REALMS_6P=211]="MAP_TYPE_MISTY_REALMS_6P",e[e.MAP_TYPE_MISTY_REALMS_8P=212]="MAP_TYPE_MISTY_REALMS_8P",e[e.MAP_TYPE_RIVER_4P=220]="MAP_TYPE_RIVER_4P",e[e.MAP_TYPE_RIVER_6P=221]="MAP_TYPE_RIVER_6P",e[e.MAP_TYPE_RIVER_8P=222]="MAP_TYPE_RIVER_8P",e[e.MAP_TYPE_CARAVANS_3P=233]="MAP_TYPE_CARAVANS_3P",e[e.MAP_TYPE_CARAVANS_4P=230]="MAP_TYPE_CARAVANS_4P",e[e.MAP_TYPE_CARAVANS_6P=231]="MAP_TYPE_CARAVANS_6P",e[e.MAP_TYPE_CARAVANS_8P=232]="MAP_TYPE_CARAVANS_8P",e[e.MAP_TYPE_DUST_BOWL_3P=243]="MAP_TYPE_DUST_BOWL_3P",e[e.MAP_TYPE_DUST_BOWL_4P=240]="MAP_TYPE_DUST_BOWL_4P",e[e.MAP_TYPE_DUST_BOWL_6P=241]="MAP_TYPE_DUST_BOWL_6P",e[e.MAP_TYPE_DUST_BOWL_8P=242]="MAP_TYPE_DUST_BOWL_8P",e[e.MAP_TYPE_SF_SIX_ISLANDS_6P=150]="MAP_TYPE_SF_SIX_ISLANDS_6P",e[e.MAP_TYPE_SNOW_MAN=250]="MAP_TYPE_SNOW_MAN",e[e.MAP_TYPE_TROLL_BRIDGE_2P=264]="MAP_TYPE_TROLL_BRIDGE_2P",e[e.MAP_TYPE_TROLL_BRIDGE_3P=263]="MAP_TYPE_TROLL_BRIDGE_3P",e[e.MAP_TYPE_TROLL_BRIDGE_4P=260]="MAP_TYPE_TROLL_BRIDGE_4P",e[e.MAP_TYPE_TROLL_BRIDGE_6P=261]="MAP_TYPE_TROLL_BRIDGE_6P",e[e.MAP_TYPE_TROLL_BRIDGE_8P=262]="MAP_TYPE_TROLL_BRIDGE_8P",e[e.MAP_TYPE_FISH_SHOALS_3P=300]="MAP_TYPE_FISH_SHOALS_3P",e[e.MAP_TYPE_FISH_SHOALS_4P=301]="MAP_TYPE_FISH_SHOALS_4P",e[e.MAP_TYPE_FISH_SHOALS_6P=302]="MAP_TYPE_FISH_SHOALS_6P",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(NI||(NI={}));var RI;(function(e){e[e.EDGE_REWARD_TYPE_UNSPECIFIED=0]="EDGE_REWARD_TYPE_UNSPECIFIED",e[e.EDGE_REWARD_TYPE_VICTORY_POINT=1]="EDGE_REWARD_TYPE_VICTORY_POINT",e[e.EDGE_REWARD_TYPE_DEV_CARD=2]="EDGE_REWARD_TYPE_DEV_CARD",e[e.EDGE_REWARD_TYPE_PORT=3]="EDGE_REWARD_TYPE_PORT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(RI||(RI={}));var AI;(function(e){e[e.VALIDATION_ERROR_UNSPECIFIED=0]="VALIDATION_ERROR_UNSPECIFIED",e[e.VALIDATION_ERROR_NOT_YOUR_TURN=100]="VALIDATION_ERROR_NOT_YOUR_TURN",e[e.VALIDATION_ERROR_GAME_PAUSED=101]="VALIDATION_ERROR_GAME_PAUSED",e[e.VALIDATION_ERROR_WRONG_PHASE_SETUP=102]="VALIDATION_ERROR_WRONG_PHASE_SETUP",e[e.VALIDATION_ERROR_WRONG_PHASE_NORMAL=103]="VALIDATION_ERROR_WRONG_PHASE_NORMAL",e[e.VALIDATION_ERROR_MUST_ROLL_DICE_FIRST=104]="VALIDATION_ERROR_MUST_ROLL_DICE_FIRST",e[e.VALIDATION_ERROR_DICE_ALREADY_ROLLED=105]="VALIDATION_ERROR_DICE_ALREADY_ROLLED",e[e.VALIDATION_ERROR_CANNOT_END_TURN_SETUP=106]="VALIDATION_ERROR_CANNOT_END_TURN_SETUP",e[e.VALIDATION_ERROR_GAME_OVER=107]="VALIDATION_ERROR_GAME_OVER",e[e.VALIDATION_ERROR_MUST_DISCARD_FIRST=200]="VALIDATION_ERROR_MUST_DISCARD_FIRST",e[e.VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST=201]="VALIDATION_ERROR_MUST_MOVE_ROBBER_FIRST",e[e.VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES=202]="VALIDATION_ERROR_MUST_SELECT_FREE_RESOURCES",e[e.VALIDATION_ERROR_MUST_PLACE_FREE_ROADS=203]="VALIDATION_ERROR_MUST_PLACE_FREE_ROADS",e[e.VALIDATION_ERROR_NO_PENDING_DISCARD=204]="VALIDATION_ERROR_NO_PENDING_DISCARD",e[e.VALIDATION_ERROR_NO_PENDING_ROBBER=205]="VALIDATION_ERROR_NO_PENDING_ROBBER",e[e.VALIDATION_ERROR_NO_PENDING_FREE_RESOURCES=206]="VALIDATION_ERROR_NO_PENDING_FREE_RESOURCES",e[e.VALIDATION_ERROR_NO_PENDING_FREE_ROADS=207]="VALIDATION_ERROR_NO_PENDING_FREE_ROADS",e[e.VALIDATION_ERROR_NO_PENDING_STEAL=208]="VALIDATION_ERROR_NO_PENDING_STEAL",e[e.VALIDATION_ERROR_WRONG_DISCARD_COUNT=209]="VALIDATION_ERROR_WRONG_DISCARD_COUNT",e[e.VALIDATION_ERROR_MUST_COMPLETE_EVENT_CARD_FIRST=210]="VALIDATION_ERROR_MUST_COMPLETE_EVENT_CARD_FIRST",e[e.VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST=211]="VALIDATION_ERROR_MUST_COMPLETE_CK_ACTION_FIRST",e[e.VALIDATION_ERROR_CANNOT_AFFORD_SETTLEMENT=300]="VALIDATION_ERROR_CANNOT_AFFORD_SETTLEMENT",e[e.VALIDATION_ERROR_CANNOT_AFFORD_CITY=301]="VALIDATION_ERROR_CANNOT_AFFORD_CITY",e[e.VALIDATION_ERROR_CANNOT_AFFORD_ROAD=302]="VALIDATION_ERROR_CANNOT_AFFORD_ROAD",e[e.VALIDATION_ERROR_CANNOT_AFFORD_DEV_CARD=303]="VALIDATION_ERROR_CANNOT_AFFORD_DEV_CARD",e[e.VALIDATION_ERROR_INSUFFICIENT_RESOURCES=304]="VALIDATION_ERROR_INSUFFICIENT_RESOURCES",e[e.VALIDATION_ERROR_BANK_EMPTY=305]="VALIDATION_ERROR_BANK_EMPTY",e[e.VALIDATION_ERROR_NO_DEV_CARDS_LEFT=306]="VALIDATION_ERROR_NO_DEV_CARDS_LEFT",e[e.VALIDATION_ERROR_NO_ROADS_REMAINING=307]="VALIDATION_ERROR_NO_ROADS_REMAINING",e[e.VALIDATION_ERROR_VERTEX_OCCUPIED=400]="VALIDATION_ERROR_VERTEX_OCCUPIED",e[e.VALIDATION_ERROR_EDGE_OCCUPIED=401]="VALIDATION_ERROR_EDGE_OCCUPIED",e[e.VALIDATION_ERROR_VERTEX_NOT_ON_LAND=402]="VALIDATION_ERROR_VERTEX_NOT_ON_LAND",e[e.VALIDATION_ERROR_EDGE_NOT_ON_BOARD=403]="VALIDATION_ERROR_EDGE_NOT_ON_BOARD",e[e.VALIDATION_ERROR_TOO_CLOSE_TO_SETTLEMENT=404]="VALIDATION_ERROR_TOO_CLOSE_TO_SETTLEMENT",e[e.VALIDATION_ERROR_ROAD_NOT_CONNECTED=405]="VALIDATION_ERROR_ROAD_NOT_CONNECTED",e[e.VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED=406]="VALIDATION_ERROR_SETTLEMENT_NOT_CONNECTED",e[e.VALIDATION_ERROR_NO_SETTLEMENT_AT_LOCATION=407]="VALIDATION_ERROR_NO_SETTLEMENT_AT_LOCATION",e[e.VALIDATION_ERROR_SETTLEMENT_WRONG_OWNER=408]="VALIDATION_ERROR_SETTLEMENT_WRONG_OWNER",e[e.VALIDATION_ERROR_INVALID_HEX_LOCATION=409]="VALIDATION_ERROR_INVALID_HEX_LOCATION",e[e.VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS=410]="VALIDATION_ERROR_NO_VALID_PLACEMENT_SPOTS",e[e.VALIDATION_ERROR_CANNOT_ACCEPT_OWN_TRADE=500]="VALIDATION_ERROR_CANNOT_ACCEPT_OWN_TRADE",e[e.VALIDATION_ERROR_CANNOT_REJECT_OWN_TRADE=501]="VALIDATION_ERROR_CANNOT_REJECT_OWN_TRADE",e[e.VALIDATION_ERROR_CANNOT_CANCEL_OTHERS_TRADE=502]="VALIDATION_ERROR_CANNOT_CANCEL_OTHERS_TRADE",e[e.VALIDATION_ERROR_TRADE_NOT_FOUND=503]="VALIDATION_ERROR_TRADE_NOT_FOUND",e[e.VALIDATION_ERROR_TARGET_NOT_ACCEPTED=504]="VALIDATION_ERROR_TARGET_NOT_ACCEPTED",e[e.VALIDATION_ERROR_ONLY_PROPOSER_CAN_EXECUTE=505]="VALIDATION_ERROR_ONLY_PROPOSER_CAN_EXECUTE",e[e.VALIDATION_ERROR_CANNOT_ACCEPT_REJECTED_TRADE=506]="VALIDATION_ERROR_CANNOT_ACCEPT_REJECTED_TRADE",e[e.VALIDATION_ERROR_TARGET_NO_RESOURCES=507]="VALIDATION_ERROR_TARGET_NO_RESOURCES",e[e.VALIDATION_ERROR_INVALID_TRADE_RATIO=508]="VALIDATION_ERROR_INVALID_TRADE_RATIO",e[e.VALIDATION_ERROR_TRADE_RESOURCES_NOT_OWNED=509]="VALIDATION_ERROR_TRADE_RESOURCES_NOT_OWNED",e[e.VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE=510]="VALIDATION_ERROR_CANNOT_TRADE_SAME_TYPE",e[e.VALIDATION_ERROR_PLAYER_TRADES_DISABLED=511]="VALIDATION_ERROR_PLAYER_TRADES_DISABLED",e[e.VALIDATION_ERROR_COUNTER_OFFERS_DISABLED=512]="VALIDATION_ERROR_COUNTER_OFFERS_DISABLED",e[e.VALIDATION_ERROR_NO_KNIGHT_CARD=600]="VALIDATION_ERROR_NO_KNIGHT_CARD",e[e.VALIDATION_ERROR_NO_ROAD_BUILDING_CARD=601]="VALIDATION_ERROR_NO_ROAD_BUILDING_CARD",e[e.VALIDATION_ERROR_NO_YEAR_OF_PLENTY_CARD=602]="VALIDATION_ERROR_NO_YEAR_OF_PLENTY_CARD",e[e.VALIDATION_ERROR_NO_MONOPOLY_CARD=603]="VALIDATION_ERROR_NO_MONOPOLY_CARD",e[e.VALIDATION_ERROR_ALREADY_PLAYED_DEV_CARD=604]="VALIDATION_ERROR_ALREADY_PLAYED_DEV_CARD",e[e.VALIDATION_ERROR_CANNOT_PLAY_VP_CARD=605]="VALIDATION_ERROR_CANNOT_PLAY_VP_CARD",e[e.VALIDATION_ERROR_ROBBER_MUST_MOVE=700]="VALIDATION_ERROR_ROBBER_MUST_MOVE",e[e.VALIDATION_ERROR_ROBBER_NO_LOCATION=701]="VALIDATION_ERROR_ROBBER_NO_LOCATION",e[e.VALIDATION_ERROR_ROBBER_ON_SEA=702]="VALIDATION_ERROR_ROBBER_ON_SEA",e[e.VALIDATION_ERROR_FRIENDLY_ROBBER_BLOCKED=703]="VALIDATION_ERROR_FRIENDLY_ROBBER_BLOCKED",e[e.VALIDATION_ERROR_INVALID_STEAL_TARGET=704]="VALIDATION_ERROR_INVALID_STEAL_TARGET",e[e.VALIDATION_ERROR_ROBBER_NOT_ON_BIGGEST_ISLAND=705]="VALIDATION_ERROR_ROBBER_NOT_ON_BIGGEST_ISLAND",e[e.VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS=706]="VALIDATION_ERROR_ROBBER_LOCKED_BEFORE_BARBARIANS",e[e.VALIDATION_ERROR_MUST_SPECIFY_RESOURCE=800]="VALIDATION_ERROR_MUST_SPECIFY_RESOURCE",e[e.VALIDATION_ERROR_MUST_SPECIFY_VERTEX=801]="VALIDATION_ERROR_MUST_SPECIFY_VERTEX",e[e.VALIDATION_ERROR_MUST_SPECIFY_EDGE=802]="VALIDATION_ERROR_MUST_SPECIFY_EDGE",e[e.VALIDATION_ERROR_INVALID_TARGET_PLAYER=803]="VALIDATION_ERROR_INVALID_TARGET_PLAYER",e[e.VALIDATION_ERROR_UNKNOWN_ACTION_TYPE=804]="VALIDATION_ERROR_UNKNOWN_ACTION_TYPE",e[e.VALIDATION_ERROR_NO_TROLL_ON_HEX=900]="VALIDATION_ERROR_NO_TROLL_ON_HEX",e[e.VALIDATION_ERROR_TROLL_INSUFFICIENT_FOOD=901]="VALIDATION_ERROR_TROLL_INSUFFICIENT_FOOD",e[e.VALIDATION_ERROR_TROLL_INVALID_FOOD=902]="VALIDATION_ERROR_TROLL_INVALID_FOOD",e[e.VALIDATION_ERROR_TROLL_KNIGHT_NOT_MIGHTY=903]="VALIDATION_ERROR_TROLL_KNIGHT_NOT_MIGHTY",e[e.VALIDATION_ERROR_TROLL_KNIGHT_NOT_ACTIVE=904]="VALIDATION_ERROR_TROLL_KNIGHT_NOT_ACTIVE",e[e.VALIDATION_ERROR_TROLL_KNIGHT_NOT_ADJACENT=905]="VALIDATION_ERROR_TROLL_KNIGHT_NOT_ADJACENT",e[e.VALIDATION_ERROR_TROLL_NOT_ADJACENT_TO_BUILDING=906]="VALIDATION_ERROR_TROLL_NOT_ADJACENT_TO_BUILDING",e[e.VALIDATION_ERROR_ROBBER_BLOCKED_BY_TROLL=907]="VALIDATION_ERROR_ROBBER_BLOCKED_BY_TROLL",e[e.VALIDATION_ERROR_RIVERS_NOT_ENABLED=1e3]="VALIDATION_ERROR_RIVERS_NOT_ENABLED",e[e.VALIDATION_ERROR_NOT_A_BRIDGE_SITE=1001]="VALIDATION_ERROR_NOT_A_BRIDGE_SITE",e[e.VALIDATION_ERROR_ROAD_ON_BRIDGE_SITE=1002]="VALIDATION_ERROR_ROAD_ON_BRIDGE_SITE",e[e.VALIDATION_ERROR_NO_BRIDGES_REMAINING=1003]="VALIDATION_ERROR_NO_BRIDGES_REMAINING",e[e.VALIDATION_ERROR_CANNOT_AFFORD_BRIDGE=1004]="VALIDATION_ERROR_CANNOT_AFFORD_BRIDGE",e[e.VALIDATION_ERROR_BRIDGE_NOT_CONNECTED=1005]="VALIDATION_ERROR_BRIDGE_NOT_CONNECTED",e[e.VALIDATION_ERROR_INSUFFICIENT_GOLD=1006]="VALIDATION_ERROR_INSUFFICIENT_GOLD",e[e.VALIDATION_ERROR_GOLD_PURCHASE_LIMIT_REACHED=1007]="VALIDATION_ERROR_GOLD_PURCHASE_LIMIT_REACHED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(AI||(AI={}));var SI;(function(e){e[e.PING_TARGET_TYPE_UNSPECIFIED=0]="PING_TARGET_TYPE_UNSPECIFIED",e[e.PING_TARGET_TYPE_HEX=1]="PING_TARGET_TYPE_HEX",e[e.PING_TARGET_TYPE_VERTEX=2]="PING_TARGET_TYPE_VERTEX",e[e.PING_TARGET_TYPE_EDGE=3]="PING_TARGET_TYPE_EDGE",e[e.PING_TARGET_TYPE_POINT=4]="PING_TARGET_TYPE_POINT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(SI||(SI={}));var OI;(function(e){e[e.PING_TYPE_UNSPECIFIED=0]="PING_TYPE_UNSPECIFIED",e[e.PING_TYPE_EXCLAMATION=1]="PING_TYPE_EXCLAMATION",e[e.PING_TYPE_QUESTION=2]="PING_TYPE_QUESTION",e[e.PING_TYPE_ARROW=3]="PING_TYPE_ARROW",e[e.PING_TYPE_X=4]="PING_TYPE_X",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(OI||(OI={}));var II;(function(e){e[e.TRADE_MODE_NORMAL=0]="TRADE_MODE_NORMAL",e[e.TRADE_MODE_BANK_ONLY=1]="TRADE_MODE_BANK_ONLY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(II||(II={}));import{BinaryReader as pI,BinaryWriter as Wg}from"@bufbuild/protobuf/wire";function hI(){return{seconds:0,nanos:0}}E(hI,"createBaseTimestamp");var Le={encode(e,r=new Wg){return e.seconds!==0&&r.uint32(8).int64(e.seconds),e.nanos!==0&&r.uint32(16).int32(e.nanos),r},decode(e,r){let t=e instanceof pI?e:new pI(e),o=r===void 0?t.len:t.pos+r,i=hI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.seconds=Jg(t.int64());continue}case 2:{if(n!==16)break;i.nanos=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{seconds:DI(e.seconds)?globalThis.Number(e.seconds):0,nanos:DI(e.nanos)?globalThis.Number(e.nanos):0}},toJSON(e){let r={};return e.seconds!==0&&(r.seconds=Math.round(e.seconds)),e.nanos!==0&&(r.nanos=Math.round(e.nanos)),r},create(e){return Le.fromPartial(e??{})},fromPartial(e){let r=hI();return r.seconds=e.seconds??0,r.nanos=e.nanos??0,r}};function Jg(e){let r=globalThis.Number(e.toString());if(r>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(r<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return r}E(Jg,"longToNumber");function DI(e){return e!=null}E(DI,"isSet");var ce;(function(e){e[e.LOBBY_ACTION_UNSPECIFIED=0]="LOBBY_ACTION_UNSPECIFIED",e[e.LOBBY_ACTION_CREATE=1]="LOBBY_ACTION_CREATE",e[e.LOBBY_ACTION_JOIN=2]="LOBBY_ACTION_JOIN",e[e.LOBBY_ACTION_LEAVE=3]="LOBBY_ACTION_LEAVE",e[e.LOBBY_ACTION_UPDATE_BOTS=4]="LOBBY_ACTION_UPDATE_BOTS",e[e.LOBBY_ACTION_UPDATE_CONFIG=5]="LOBBY_ACTION_UPDATE_CONFIG",e[e.LOBBY_ACTION_MOVE_TO_SPECTATOR=6]="LOBBY_ACTION_MOVE_TO_SPECTATOR",e[e.LOBBY_ACTION_MOVE_TO_PLAYER=7]="LOBBY_ACTION_MOVE_TO_PLAYER",e[e.LOBBY_ACTION_SEND_CHAT=8]="LOBBY_ACTION_SEND_CHAT",e[e.LOBBY_ACTION_MUTE=9]="LOBBY_ACTION_MUTE",e[e.LOBBY_ACTION_BAN=10]="LOBBY_ACTION_BAN",e[e.LOBBY_ACTION_HEARTBEAT=11]="LOBBY_ACTION_HEARTBEAT",e[e.LOBBY_ACTION_INVITE=12]="LOBBY_ACTION_INVITE",e[e.LOBBY_ACTION_RESPOND_INVITE=13]="LOBBY_ACTION_RESPOND_INVITE",e[e.LOBBY_ACTION_CHANGE_COLOR=14]="LOBBY_ACTION_CHANGE_COLOR",e[e.LOBBY_ACTION_SUBMIT_MAP_CHOICE=15]="LOBBY_ACTION_SUBMIT_MAP_CHOICE",e[e.LOBBY_ACTION_TOGGLE_READY=16]="LOBBY_ACTION_TOGGLE_READY",e[e.LOBBY_ACTION_SEND_COUNTDOWN_MESSAGE=17]="LOBBY_ACTION_SEND_COUNTDOWN_MESSAGE",e[e.LOBBY_ACTION_START_GAME=18]="LOBBY_ACTION_START_GAME",e[e.LOBBY_ACTION_PROCESS_MAP_CHOICE_EXPIRY=19]="LOBBY_ACTION_PROCESS_MAP_CHOICE_EXPIRY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ce||(ce={}));function mI(e){switch(e){case 0:case"LOBBY_ACTION_UNSPECIFIED":return ce.LOBBY_ACTION_UNSPECIFIED;case 1:case"LOBBY_ACTION_CREATE":return ce.LOBBY_ACTION_CREATE;case 2:case"LOBBY_ACTION_JOIN":return ce.LOBBY_ACTION_JOIN;case 3:case"LOBBY_ACTION_LEAVE":return ce.LOBBY_ACTION_LEAVE;case 4:case"LOBBY_ACTION_UPDATE_BOTS":return ce.LOBBY_ACTION_UPDATE_BOTS;case 5:case"LOBBY_ACTION_UPDATE_CONFIG":return ce.LOBBY_ACTION_UPDATE_CONFIG;case 6:case"LOBBY_ACTION_MOVE_TO_SPECTATOR":return ce.LOBBY_ACTION_MOVE_TO_SPECTATOR;case 7:case"LOBBY_ACTION_MOVE_TO_PLAYER":return ce.LOBBY_ACTION_MOVE_TO_PLAYER;case 8:case"LOBBY_ACTION_SEND_CHAT":return ce.LOBBY_ACTION_SEND_CHAT;case 9:case"LOBBY_ACTION_MUTE":return ce.LOBBY_ACTION_MUTE;case 10:case"LOBBY_ACTION_BAN":return ce.LOBBY_ACTION_BAN;case 11:case"LOBBY_ACTION_HEARTBEAT":return ce.LOBBY_ACTION_HEARTBEAT;case 12:case"LOBBY_ACTION_INVITE":return ce.LOBBY_ACTION_INVITE;case 13:case"LOBBY_ACTION_RESPOND_INVITE":return ce.LOBBY_ACTION_RESPOND_INVITE;case 14:case"LOBBY_ACTION_CHANGE_COLOR":return ce.LOBBY_ACTION_CHANGE_COLOR;case 15:case"LOBBY_ACTION_SUBMIT_MAP_CHOICE":return ce.LOBBY_ACTION_SUBMIT_MAP_CHOICE;case 16:case"LOBBY_ACTION_TOGGLE_READY":return ce.LOBBY_ACTION_TOGGLE_READY;case 17:case"LOBBY_ACTION_SEND_COUNTDOWN_MESSAGE":return ce.LOBBY_ACTION_SEND_COUNTDOWN_MESSAGE;case 18:case"LOBBY_ACTION_START_GAME":return ce.LOBBY_ACTION_START_GAME;case 19:case"LOBBY_ACTION_PROCESS_MAP_CHOICE_EXPIRY":return ce.LOBBY_ACTION_PROCESS_MAP_CHOICE_EXPIRY;default:return ce.UNRECOGNIZED}}E(mI,"lobbyActionTypeFromJSON");function qg(e){switch(e){case ce.LOBBY_ACTION_UNSPECIFIED:return"LOBBY_ACTION_UNSPECIFIED";case ce.LOBBY_ACTION_CREATE:return"LOBBY_ACTION_CREATE";case ce.LOBBY_ACTION_JOIN:return"LOBBY_ACTION_JOIN";case ce.LOBBY_ACTION_LEAVE:return"LOBBY_ACTION_LEAVE";case ce.LOBBY_ACTION_UPDATE_BOTS:return"LOBBY_ACTION_UPDATE_BOTS";case ce.LOBBY_ACTION_UPDATE_CONFIG:return"LOBBY_ACTION_UPDATE_CONFIG";case ce.LOBBY_ACTION_MOVE_TO_SPECTATOR:return"LOBBY_ACTION_MOVE_TO_SPECTATOR";case ce.LOBBY_ACTION_MOVE_TO_PLAYER:return"LOBBY_ACTION_MOVE_TO_PLAYER";case ce.LOBBY_ACTION_SEND_CHAT:return"LOBBY_ACTION_SEND_CHAT";case ce.LOBBY_ACTION_MUTE:return"LOBBY_ACTION_MUTE";case ce.LOBBY_ACTION_BAN:return"LOBBY_ACTION_BAN";case ce.LOBBY_ACTION_HEARTBEAT:return"LOBBY_ACTION_HEARTBEAT";case ce.LOBBY_ACTION_INVITE:return"LOBBY_ACTION_INVITE";case ce.LOBBY_ACTION_RESPOND_INVITE:return"LOBBY_ACTION_RESPOND_INVITE";case ce.LOBBY_ACTION_CHANGE_COLOR:return"LOBBY_ACTION_CHANGE_COLOR";case ce.LOBBY_ACTION_SUBMIT_MAP_CHOICE:return"LOBBY_ACTION_SUBMIT_MAP_CHOICE";case ce.LOBBY_ACTION_TOGGLE_READY:return"LOBBY_ACTION_TOGGLE_READY";case ce.LOBBY_ACTION_SEND_COUNTDOWN_MESSAGE:return"LOBBY_ACTION_SEND_COUNTDOWN_MESSAGE";case ce.LOBBY_ACTION_START_GAME:return"LOBBY_ACTION_START_GAME";case ce.LOBBY_ACTION_PROCESS_MAP_CHOICE_EXPIRY:return"LOBBY_ACTION_PROCESS_MAP_CHOICE_EXPIRY";case ce.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(qg,"lobbyActionTypeToJSON");var jt;(function(e){e[e.BOT_ACTION_UNSPECIFIED=0]="BOT_ACTION_UNSPECIFIED",e[e.BOT_ACTION_ADD=1]="BOT_ACTION_ADD",e[e.BOT_ACTION_REMOVE=2]="BOT_ACTION_REMOVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(jt||(jt={}));function gI(e){switch(e){case 0:case"BOT_ACTION_UNSPECIFIED":return jt.BOT_ACTION_UNSPECIFIED;case 1:case"BOT_ACTION_ADD":return jt.BOT_ACTION_ADD;case 2:case"BOT_ACTION_REMOVE":return jt.BOT_ACTION_REMOVE;default:return jt.UNRECOGNIZED}}E(gI,"botActionFromJSON");function Zg(e){switch(e){case jt.BOT_ACTION_UNSPECIFIED:return"BOT_ACTION_UNSPECIFIED";case jt.BOT_ACTION_ADD:return"BOT_ACTION_ADD";case jt.BOT_ACTION_REMOVE:return"BOT_ACTION_REMOVE";case jt.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Zg,"botActionToJSON");var rn;(function(e){e[e.LOBBY_STATUS_UNSPECIFIED=0]="LOBBY_STATUS_UNSPECIFIED",e[e.LOBBY_STATUS_OPEN=1]="LOBBY_STATUS_OPEN",e[e.LOBBY_STATUS_STARTING=2]="LOBBY_STATUS_STARTING",e[e.LOBBY_STATUS_STARTED=3]="LOBBY_STATUS_STARTED",e[e.LOBBY_STATUS_CANCELLED=4]="LOBBY_STATUS_CANCELLED",e[e.LOBBY_STATUS_MAP_VOTING=5]="LOBBY_STATUS_MAP_VOTING",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(rn||(rn={}));var en;(function(e){e[e.MAP_CHOICE_MODE_UNSPECIFIED=0]="MAP_CHOICE_MODE_UNSPECIFIED",e[e.MAP_CHOICE_MODE_VETO=1]="MAP_CHOICE_MODE_VETO",e[e.MAP_CHOICE_MODE_VOTE=2]="MAP_CHOICE_MODE_VOTE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(en||(en={}));function Nu(e){switch(e){case 0:case"MAP_CHOICE_MODE_UNSPECIFIED":return en.MAP_CHOICE_MODE_UNSPECIFIED;case 1:case"MAP_CHOICE_MODE_VETO":return en.MAP_CHOICE_MODE_VETO;case 2:case"MAP_CHOICE_MODE_VOTE":return en.MAP_CHOICE_MODE_VOTE;default:return en.UNRECOGNIZED}}E(Nu,"mapChoiceModeFromJSON");function Mc(e){switch(e){case en.MAP_CHOICE_MODE_UNSPECIFIED:return"MAP_CHOICE_MODE_UNSPECIFIED";case en.MAP_CHOICE_MODE_VETO:return"MAP_CHOICE_MODE_VETO";case en.MAP_CHOICE_MODE_VOTE:return"MAP_CHOICE_MODE_VOTE";case en.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Mc,"mapChoiceModeToJSON");var yI;(function(e){e[e.MAP_CHOICE_REASON_UNSPECIFIED=0]="MAP_CHOICE_REASON_UNSPECIFIED",e[e.MAP_CHOICE_REASON_ONLY_NON_VETOED=1]="MAP_CHOICE_REASON_ONLY_NON_VETOED",e[e.MAP_CHOICE_REASON_RANDOM_NON_VETOED=2]="MAP_CHOICE_REASON_RANDOM_NON_VETOED",e[e.MAP_CHOICE_REASON_ALL_VETOED_RANDOM=3]="MAP_CHOICE_REASON_ALL_VETOED_RANDOM",e[e.MAP_CHOICE_REASON_MOST_VOTES=4]="MAP_CHOICE_REASON_MOST_VOTES",e[e.MAP_CHOICE_REASON_RANDOM_TIEBREAKER=5]="MAP_CHOICE_REASON_RANDOM_TIEBREAKER",e[e.MAP_CHOICE_REASON_NO_VOTES_RANDOM=6]="MAP_CHOICE_REASON_NO_VOTES_RANDOM",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(yI||(yI={}));function MI(){return{slot:0,type:0}}E(MI,"createBaseBotSlotConfig");var cs={encode(e,r=new We){return e.slot!==0&&r.uint32(8).int32(e.slot),e.type!==0&&r.uint32(16).int32(e.type),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=MI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.slot=t.int32();continue}case 2:{if(n!==16)break;i.type=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{slot:G(e.slot)?globalThis.Number(e.slot):0,type:G(e.type)?q_(e.type):0}},toJSON(e){let r={};return e.slot!==0&&(r.slot=Math.round(e.slot)),e.type!==0&&(r.type=Tu(e.type)),r},create(e){return cs.fromPartial(e??{})},fromPartial(e){let r=MI();return r.slot=e.slot??0,r.type=e.type??0,r}};function LI(){return{displayName:"",config:void 0,bots:[],mapId:"",useGoEngine:!1}}E(LI,"createBaseCreateLobbyParams");var fs={encode(e,r=new We){e.displayName!==""&&r.uint32(10).string(e.displayName),e.config!==void 0&&Et.encode(e.config,r.uint32(18).fork()).join();for(let t of e.bots)cs.encode(t,r.uint32(26).fork()).join();return e.mapId!==""&&r.uint32(34).string(e.mapId),e.useGoEngine!==!1&&r.uint32(40).bool(e.useGoEngine),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=LI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.displayName=t.string();continue}case 2:{if(n!==18)break;i.config=Et.decode(t,t.uint32());continue}case 3:{if(n!==26)break;i.bots.push(cs.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.mapId=t.string();continue}case 5:{if(n!==40)break;i.useGoEngine=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{displayName:G(e.displayName)?globalThis.String(e.displayName):G(e.display_name)?globalThis.String(e.display_name):"",config:G(e.config)?Et.fromJSON(e.config):void 0,bots:globalThis.Array.isArray(e?.bots)?e.bots.map(r=>cs.fromJSON(r)):[],mapId:G(e.mapId)?globalThis.String(e.mapId):G(e.map_id)?globalThis.String(e.map_id):"",useGoEngine:G(e.useGoEngine)?globalThis.Boolean(e.useGoEngine):G(e.use_go_engine)?globalThis.Boolean(e.use_go_engine):!1}},toJSON(e){let r={};return e.displayName!==""&&(r.displayName=e.displayName),e.config!==void 0&&(r.config=Et.toJSON(e.config)),e.bots?.length&&(r.bots=e.bots.map(t=>cs.toJSON(t))),e.mapId!==""&&(r.mapId=e.mapId),e.useGoEngine!==!1&&(r.useGoEngine=e.useGoEngine),r},create(e){return fs.fromPartial(e??{})},fromPartial(e){let r=LI();return r.displayName=e.displayName??"",r.config=e.config!==void 0&&e.config!==null?Et.fromPartial(e.config):void 0,r.bots=e.bots?.map(t=>cs.fromPartial(t))||[],r.mapId=e.mapId??"",r.useGoEngine=e.useGoEngine??!1,r}};function GI(){return{lobbyId:"",displayName:"",asSpectator:!1}}E(GI,"createBaseJoinLobbyParams");var Ts={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.displayName!==""&&r.uint32(18).string(e.displayName),e.asSpectator!==!1&&r.uint32(24).bool(e.asSpectator),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=GI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==18)break;i.displayName=t.string();continue}case 3:{if(n!==24)break;i.asSpectator=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",displayName:G(e.displayName)?globalThis.String(e.displayName):G(e.display_name)?globalThis.String(e.display_name):"",asSpectator:G(e.asSpectator)?globalThis.Boolean(e.asSpectator):G(e.as_spectator)?globalThis.Boolean(e.as_spectator):!1}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.displayName!==""&&(r.displayName=e.displayName),e.asSpectator!==!1&&(r.asSpectator=e.asSpectator),r},create(e){return Ts.fromPartial(e??{})},fromPartial(e){let r=GI();return r.lobbyId=e.lobbyId??"",r.displayName=e.displayName??"",r.asSpectator=e.asSpectator??!1,r}};function UI(){return{lobbyId:""}}E(UI,"createBaseLeaveLobbyParams");var Ns={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=UI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),r},create(e){return Ns.fromPartial(e??{})},fromPartial(e){let r=UI();return r.lobbyId=e.lobbyId??"",r}};function BI(){return{lobbyId:"",botAction:0,botType:0,botIndex:0}}E(BI,"createBaseUpdateBotsParams");var Ui={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.botAction!==0&&r.uint32(16).int32(e.botAction),e.botType!==0&&r.uint32(24).int32(e.botType),e.botIndex!==0&&r.uint32(32).int32(e.botIndex),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=BI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==16)break;i.botAction=t.int32();continue}case 3:{if(n!==24)break;i.botType=t.int32();continue}case 4:{if(n!==32)break;i.botIndex=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",botAction:G(e.botAction)?gI(e.botAction):G(e.bot_action)?gI(e.bot_action):0,botType:G(e.botType)?q_(e.botType):G(e.bot_type)?q_(e.bot_type):0,botIndex:G(e.botIndex)?globalThis.Number(e.botIndex):G(e.bot_index)?globalThis.Number(e.bot_index):0}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.botAction!==0&&(r.botAction=Zg(e.botAction)),e.botType!==0&&(r.botType=Tu(e.botType)),e.botIndex!==0&&(r.botIndex=Math.round(e.botIndex)),r},create(e){return Ui.fromPartial(e??{})},fromPartial(e){let r=BI();return r.lobbyId=e.lobbyId??"",r.botAction=e.botAction??0,r.botType=e.botType??0,r.botIndex=e.botIndex??0,r}};function kI(){return{lobbyId:"",config:void 0,updateFields:[]}}E(kI,"createBaseUpdateConfigParams");var Bi={encode(e,r=new We){e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.config!==void 0&&Et.encode(e.config,r.uint32(18).fork()).join();for(let t of e.updateFields)r.uint32(26).string(t);return r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=kI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==18)break;i.config=Et.decode(t,t.uint32());continue}case 3:{if(n!==26)break;i.updateFields.push(t.string());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",config:G(e.config)?Et.fromJSON(e.config):void 0,updateFields:globalThis.Array.isArray(e?.updateFields)?e.updateFields.map(r=>globalThis.String(r)):globalThis.Array.isArray(e?.update_fields)?e.update_fields.map(r=>globalThis.String(r)):[]}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.config!==void 0&&(r.config=Et.toJSON(e.config)),e.updateFields?.length&&(r.updateFields=e.updateFields),r},create(e){return Bi.fromPartial(e??{})},fromPartial(e){let r=kI();return r.lobbyId=e.lobbyId??"",r.config=e.config!==void 0&&e.config!==null?Et.fromPartial(e.config):void 0,r.updateFields=e.updateFields?.map(t=>t)||[],r}};function bI(){return{lobbyId:"",targetUid:""}}E(bI,"createBaseMoveToSpectatorParams");var ki={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.targetUid!==""&&r.uint32(18).string(e.targetUid),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=bI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==18)break;i.targetUid=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",targetUid:G(e.targetUid)?globalThis.String(e.targetUid):G(e.target_uid)?globalThis.String(e.target_uid):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.targetUid!==""&&(r.targetUid=e.targetUid),r},create(e){return ki.fromPartial(e??{})},fromPartial(e){let r=bI();return r.lobbyId=e.lobbyId??"",r.targetUid=e.targetUid??"",r}};function vI(){return{lobbyId:"",targetUid:""}}E(vI,"createBaseMoveToPlayerParams");var bi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.targetUid!==""&&r.uint32(18).string(e.targetUid),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=vI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==18)break;i.targetUid=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",targetUid:G(e.targetUid)?globalThis.String(e.targetUid):G(e.target_uid)?globalThis.String(e.target_uid):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.targetUid!==""&&(r.targetUid=e.targetUid),r},create(e){return bi.fromPartial(e??{})},fromPartial(e){let r=vI();return r.lobbyId=e.lobbyId??"",r.targetUid=e.targetUid??"",r}};function YI(){return{lobbyId:"",message:""}}E(YI,"createBaseSendChatParams");var vi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.message!==""&&r.uint32(18).string(e.message),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=YI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==18)break;i.message=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",message:G(e.message)?globalThis.String(e.message):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.message!==""&&(r.message=e.message),r},create(e){return vi.fromPartial(e??{})},fromPartial(e){let r=YI();return r.lobbyId=e.lobbyId??"",r.message=e.message??"",r}};function FI(){return{lobbyId:"",targetUid:"",mute:!1}}E(FI,"createBaseMutePlayerParams");var Rs={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.targetUid!==""&&r.uint32(18).string(e.targetUid),e.mute!==!1&&r.uint32(24).bool(e.mute),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=FI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==18)break;i.targetUid=t.string();continue}case 3:{if(n!==24)break;i.mute=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",targetUid:G(e.targetUid)?globalThis.String(e.targetUid):G(e.target_uid)?globalThis.String(e.target_uid):"",mute:G(e.mute)?globalThis.Boolean(e.mute):!1}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.targetUid!==""&&(r.targetUid=e.targetUid),e.mute!==!1&&(r.mute=e.mute),r},create(e){return Rs.fromPartial(e??{})},fromPartial(e){let r=FI();return r.lobbyId=e.lobbyId??"",r.targetUid=e.targetUid??"",r.mute=e.mute??!1,r}};function VI(){return{lobbyId:"",targetUid:""}}E(VI,"createBaseBanPlayerParams");var As={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.targetUid!==""&&r.uint32(18).string(e.targetUid),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=VI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==18)break;i.targetUid=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",targetUid:G(e.targetUid)?globalThis.String(e.targetUid):G(e.target_uid)?globalThis.String(e.target_uid):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.targetUid!==""&&(r.targetUid=e.targetUid),r},create(e){return As.fromPartial(e??{})},fromPartial(e){let r=VI();return r.lobbyId=e.lobbyId??"",r.targetUid=e.targetUid??"",r}};function xI(){return{lobbyId:""}}E(xI,"createBaseHeartbeatParams");var Ss={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=xI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),r},create(e){return Ss.fromPartial(e??{})},fromPartial(e){let r=xI();return r.lobbyId=e.lobbyId??"",r}};function wI(){return{lobbyId:"",targetUid:""}}E(wI,"createBaseSendInviteParams");var Os={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.targetUid!==""&&r.uint32(18).string(e.targetUid),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=wI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==18)break;i.targetUid=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",targetUid:G(e.targetUid)?globalThis.String(e.targetUid):G(e.target_uid)?globalThis.String(e.target_uid):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.targetUid!==""&&(r.targetUid=e.targetUid),r},create(e){return Os.fromPartial(e??{})},fromPartial(e){let r=wI();return r.lobbyId=e.lobbyId??"",r.targetUid=e.targetUid??"",r}};function HI(){return{lobbyId:"",accept:!1}}E(HI,"createBaseRespondInviteParams");var Yi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.accept!==!1&&r.uint32(16).bool(e.accept),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=HI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==16)break;i.accept=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",accept:G(e.accept)?globalThis.Boolean(e.accept):!1}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.accept!==!1&&(r.accept=e.accept),r},create(e){return Yi.fromPartial(e??{})},fromPartial(e){let r=HI();return r.lobbyId=e.lobbyId??"",r.accept=e.accept??!1,r}};function KI(){return{lobbyId:"",newColor:0,botIndex:0}}E(KI,"createBaseChangeColorParams");var Fi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.newColor!==0&&r.uint32(16).int32(e.newColor),e.botIndex!==0&&r.uint32(24).int32(e.botIndex),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=KI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==16)break;i.newColor=t.int32();continue}case 3:{if(n!==24)break;i.botIndex=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",newColor:G(e.newColor)?Ke(e.newColor):G(e.new_color)?Ke(e.new_color):0,botIndex:G(e.botIndex)?globalThis.Number(e.botIndex):G(e.bot_index)?globalThis.Number(e.bot_index):0}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.newColor!==0&&(r.newColor=_r(e.newColor)),e.botIndex!==0&&(r.botIndex=Math.round(e.botIndex)),r},create(e){return Fi.fromPartial(e??{})},fromPartial(e){let r=KI();return r.lobbyId=e.lobbyId??"",r.newColor=e.newColor??0,r.botIndex=e.botIndex??0,r}};function WI(){return{lobbyId:"",mapChoice:0}}E(WI,"createBaseSubmitMapChoiceParams");var Vi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.mapChoice!==0&&r.uint32(16).int32(e.mapChoice),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=WI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==16)break;i.mapChoice=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",mapChoice:G(e.mapChoice)?globalThis.Number(e.mapChoice):G(e.map_choice)?globalThis.Number(e.map_choice):0}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.mapChoice!==0&&(r.mapChoice=Math.round(e.mapChoice)),r},create(e){return Vi.fromPartial(e??{})},fromPartial(e){let r=WI();return r.lobbyId=e.lobbyId??"",r.mapChoice=e.mapChoice??0,r}};function JI(){return{lobbyId:""}}E(JI,"createBaseToggleReadyParams");var xi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=JI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),r},create(e){return xi.fromPartial(e??{})},fromPartial(e){let r=JI();return r.lobbyId=e.lobbyId??"",r}};function qI(){return{lobbyId:"",seconds:0}}E(qI,"createBaseSendCountdownMessageParams");var wi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),e.seconds!==0&&r.uint32(16).int32(e.seconds),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=qI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}case 2:{if(n!==16)break;i.seconds=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):"",seconds:G(e.seconds)?globalThis.Number(e.seconds):0}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.seconds!==0&&(r.seconds=Math.round(e.seconds)),r},create(e){return wi.fromPartial(e??{})},fromPartial(e){let r=qI();return r.lobbyId=e.lobbyId??"",r.seconds=e.seconds??0,r}};function ZI(){return{lobbyId:""}}E(ZI,"createBaseStartGameParams");var Hi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=ZI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),r},create(e){return Hi.fromPartial(e??{})},fromPartial(e){let r=ZI();return r.lobbyId=e.lobbyId??"",r}};function XI(){return{lobbyId:""}}E(XI,"createBaseProcessMapChoiceExpiryParams");var Ki={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=XI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),r},create(e){return Ki.fromPartial(e??{})},fromPartial(e){let r=XI();return r.lobbyId=e.lobbyId??"",r}};function zI(){return{actionType:0,create:void 0,join:void 0,leave:void 0,updateBots:void 0,updateConfig:void 0,moveToSpectator:void 0,moveToPlayer:void 0,sendChat:void 0,mute:void 0,ban:void 0,heartbeat:void 0,invite:void 0,respondInvite:void 0,changeColor:void 0,submitMapChoice:void 0,toggleReady:void 0,sendCountdownMessage:void 0,startGame:void 0,processMapChoiceExpiry:void 0}}E(zI,"createBaseLobbyActionRequest");var Ru={encode(e,r=new We){return e.actionType!==0&&r.uint32(8).int32(e.actionType),e.create!==void 0&&fs.encode(e.create,r.uint32(18).fork()).join(),e.join!==void 0&&Ts.encode(e.join,r.uint32(26).fork()).join(),e.leave!==void 0&&Ns.encode(e.leave,r.uint32(34).fork()).join(),e.updateBots!==void 0&&Ui.encode(e.updateBots,r.uint32(42).fork()).join(),e.updateConfig!==void 0&&Bi.encode(e.updateConfig,r.uint32(50).fork()).join(),e.moveToSpectator!==void 0&&ki.encode(e.moveToSpectator,r.uint32(58).fork()).join(),e.moveToPlayer!==void 0&&bi.encode(e.moveToPlayer,r.uint32(66).fork()).join(),e.sendChat!==void 0&&vi.encode(e.sendChat,r.uint32(74).fork()).join(),e.mute!==void 0&&Rs.encode(e.mute,r.uint32(82).fork()).join(),e.ban!==void 0&&As.encode(e.ban,r.uint32(90).fork()).join(),e.heartbeat!==void 0&&Ss.encode(e.heartbeat,r.uint32(98).fork()).join(),e.invite!==void 0&&Os.encode(e.invite,r.uint32(106).fork()).join(),e.respondInvite!==void 0&&Yi.encode(e.respondInvite,r.uint32(114).fork()).join(),e.changeColor!==void 0&&Fi.encode(e.changeColor,r.uint32(122).fork()).join(),e.submitMapChoice!==void 0&&Vi.encode(e.submitMapChoice,r.uint32(130).fork()).join(),e.toggleReady!==void 0&&xi.encode(e.toggleReady,r.uint32(138).fork()).join(),e.sendCountdownMessage!==void 0&&wi.encode(e.sendCountdownMessage,r.uint32(146).fork()).join(),e.startGame!==void 0&&Hi.encode(e.startGame,r.uint32(154).fork()).join(),e.processMapChoiceExpiry!==void 0&&Ki.encode(e.processMapChoiceExpiry,r.uint32(162).fork()).join(),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=zI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.actionType=t.int32();continue}case 2:{if(n!==18)break;i.create=fs.decode(t,t.uint32());continue}case 3:{if(n!==26)break;i.join=Ts.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.leave=Ns.decode(t,t.uint32());continue}case 5:{if(n!==42)break;i.updateBots=Ui.decode(t,t.uint32());continue}case 6:{if(n!==50)break;i.updateConfig=Bi.decode(t,t.uint32());continue}case 7:{if(n!==58)break;i.moveToSpectator=ki.decode(t,t.uint32());continue}case 8:{if(n!==66)break;i.moveToPlayer=bi.decode(t,t.uint32());continue}case 9:{if(n!==74)break;i.sendChat=vi.decode(t,t.uint32());continue}case 10:{if(n!==82)break;i.mute=Rs.decode(t,t.uint32());continue}case 11:{if(n!==90)break;i.ban=As.decode(t,t.uint32());continue}case 12:{if(n!==98)break;i.heartbeat=Ss.decode(t,t.uint32());continue}case 13:{if(n!==106)break;i.invite=Os.decode(t,t.uint32());continue}case 14:{if(n!==114)break;i.respondInvite=Yi.decode(t,t.uint32());continue}case 15:{if(n!==122)break;i.changeColor=Fi.decode(t,t.uint32());continue}case 16:{if(n!==130)break;i.submitMapChoice=Vi.decode(t,t.uint32());continue}case 17:{if(n!==138)break;i.toggleReady=xi.decode(t,t.uint32());continue}case 18:{if(n!==146)break;i.sendCountdownMessage=wi.decode(t,t.uint32());continue}case 19:{if(n!==154)break;i.startGame=Hi.decode(t,t.uint32());continue}case 20:{if(n!==162)break;i.processMapChoiceExpiry=Ki.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{actionType:G(e.actionType)?mI(e.actionType):G(e.action_type)?mI(e.action_type):0,create:G(e.create)?fs.fromJSON(e.create):void 0,join:G(e.join)?Ts.fromJSON(e.join):void 0,leave:G(e.leave)?Ns.fromJSON(e.leave):void 0,updateBots:G(e.updateBots)?Ui.fromJSON(e.updateBots):G(e.update_bots)?Ui.fromJSON(e.update_bots):void 0,updateConfig:G(e.updateConfig)?Bi.fromJSON(e.updateConfig):G(e.update_config)?Bi.fromJSON(e.update_config):void 0,moveToSpectator:G(e.moveToSpectator)?ki.fromJSON(e.moveToSpectator):G(e.move_to_spectator)?ki.fromJSON(e.move_to_spectator):void 0,moveToPlayer:G(e.moveToPlayer)?bi.fromJSON(e.moveToPlayer):G(e.move_to_player)?bi.fromJSON(e.move_to_player):void 0,sendChat:G(e.sendChat)?vi.fromJSON(e.sendChat):G(e.send_chat)?vi.fromJSON(e.send_chat):void 0,mute:G(e.mute)?Rs.fromJSON(e.mute):void 0,ban:G(e.ban)?As.fromJSON(e.ban):void 0,heartbeat:G(e.heartbeat)?Ss.fromJSON(e.heartbeat):void 0,invite:G(e.invite)?Os.fromJSON(e.invite):void 0,respondInvite:G(e.respondInvite)?Yi.fromJSON(e.respondInvite):G(e.respond_invite)?Yi.fromJSON(e.respond_invite):void 0,changeColor:G(e.changeColor)?Fi.fromJSON(e.changeColor):G(e.change_color)?Fi.fromJSON(e.change_color):void 0,submitMapChoice:G(e.submitMapChoice)?Vi.fromJSON(e.submitMapChoice):G(e.submit_map_choice)?Vi.fromJSON(e.submit_map_choice):void 0,toggleReady:G(e.toggleReady)?xi.fromJSON(e.toggleReady):G(e.toggle_ready)?xi.fromJSON(e.toggle_ready):void 0,sendCountdownMessage:G(e.sendCountdownMessage)?wi.fromJSON(e.sendCountdownMessage):G(e.send_countdown_message)?wi.fromJSON(e.send_countdown_message):void 0,startGame:G(e.startGame)?Hi.fromJSON(e.startGame):G(e.start_game)?Hi.fromJSON(e.start_game):void 0,processMapChoiceExpiry:G(e.processMapChoiceExpiry)?Ki.fromJSON(e.processMapChoiceExpiry):G(e.process_map_choice_expiry)?Ki.fromJSON(e.process_map_choice_expiry):void 0}},toJSON(e){let r={};return e.actionType!==0&&(r.actionType=qg(e.actionType)),e.create!==void 0&&(r.create=fs.toJSON(e.create)),e.join!==void 0&&(r.join=Ts.toJSON(e.join)),e.leave!==void 0&&(r.leave=Ns.toJSON(e.leave)),e.updateBots!==void 0&&(r.updateBots=Ui.toJSON(e.updateBots)),e.updateConfig!==void 0&&(r.updateConfig=Bi.toJSON(e.updateConfig)),e.moveToSpectator!==void 0&&(r.moveToSpectator=ki.toJSON(e.moveToSpectator)),e.moveToPlayer!==void 0&&(r.moveToPlayer=bi.toJSON(e.moveToPlayer)),e.sendChat!==void 0&&(r.sendChat=vi.toJSON(e.sendChat)),e.mute!==void 0&&(r.mute=Rs.toJSON(e.mute)),e.ban!==void 0&&(r.ban=As.toJSON(e.ban)),e.heartbeat!==void 0&&(r.heartbeat=Ss.toJSON(e.heartbeat)),e.invite!==void 0&&(r.invite=Os.toJSON(e.invite)),e.respondInvite!==void 0&&(r.respondInvite=Yi.toJSON(e.respondInvite)),e.changeColor!==void 0&&(r.changeColor=Fi.toJSON(e.changeColor)),e.submitMapChoice!==void 0&&(r.submitMapChoice=Vi.toJSON(e.submitMapChoice)),e.toggleReady!==void 0&&(r.toggleReady=xi.toJSON(e.toggleReady)),e.sendCountdownMessage!==void 0&&(r.sendCountdownMessage=wi.toJSON(e.sendCountdownMessage)),e.startGame!==void 0&&(r.startGame=Hi.toJSON(e.startGame)),e.processMapChoiceExpiry!==void 0&&(r.processMapChoiceExpiry=Ki.toJSON(e.processMapChoiceExpiry)),r},create(e){return Ru.fromPartial(e??{})},fromPartial(e){let r=zI();return r.actionType=e.actionType??0,r.create=e.create!==void 0&&e.create!==null?fs.fromPartial(e.create):void 0,r.join=e.join!==void 0&&e.join!==null?Ts.fromPartial(e.join):void 0,r.leave=e.leave!==void 0&&e.leave!==null?Ns.fromPartial(e.leave):void 0,r.updateBots=e.updateBots!==void 0&&e.updateBots!==null?Ui.fromPartial(e.updateBots):void 0,r.updateConfig=e.updateConfig!==void 0&&e.updateConfig!==null?Bi.fromPartial(e.updateConfig):void 0,r.moveToSpectator=e.moveToSpectator!==void 0&&e.moveToSpectator!==null?ki.fromPartial(e.moveToSpectator):void 0,r.moveToPlayer=e.moveToPlayer!==void 0&&e.moveToPlayer!==null?bi.fromPartial(e.moveToPlayer):void 0,r.sendChat=e.sendChat!==void 0&&e.sendChat!==null?vi.fromPartial(e.sendChat):void 0,r.mute=e.mute!==void 0&&e.mute!==null?Rs.fromPartial(e.mute):void 0,r.ban=e.ban!==void 0&&e.ban!==null?As.fromPartial(e.ban):void 0,r.heartbeat=e.heartbeat!==void 0&&e.heartbeat!==null?Ss.fromPartial(e.heartbeat):void 0,r.invite=e.invite!==void 0&&e.invite!==null?Os.fromPartial(e.invite):void 0,r.respondInvite=e.respondInvite!==void 0&&e.respondInvite!==null?Yi.fromPartial(e.respondInvite):void 0,r.changeColor=e.changeColor!==void 0&&e.changeColor!==null?Fi.fromPartial(e.changeColor):void 0,r.submitMapChoice=e.submitMapChoice!==void 0&&e.submitMapChoice!==null?Vi.fromPartial(e.submitMapChoice):void 0,r.toggleReady=e.toggleReady!==void 0&&e.toggleReady!==null?xi.fromPartial(e.toggleReady):void 0,r.sendCountdownMessage=e.sendCountdownMessage!==void 0&&e.sendCountdownMessage!==null?wi.fromPartial(e.sendCountdownMessage):void 0,r.startGame=e.startGame!==void 0&&e.startGame!==null?Hi.fromPartial(e.startGame):void 0,r.processMapChoiceExpiry=e.processMapChoiceExpiry!==void 0&&e.processMapChoiceExpiry!==null?Ki.fromPartial(e.processMapChoiceExpiry):void 0,r}};function $I(){return{lobbyId:""}}E($I,"createBaseCreateLobbyResult");var Wi={encode(e,r=new We){return e.lobbyId!==""&&r.uint32(10).string(e.lobbyId),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=$I();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.lobbyId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{lobbyId:G(e.lobbyId)?globalThis.String(e.lobbyId):G(e.lobby_id)?globalThis.String(e.lobby_id):""}},toJSON(e){let r={};return e.lobbyId!==""&&(r.lobbyId=e.lobbyId),r},create(e){return Wi.fromPartial(e??{})},fromPartial(e){let r=$I();return r.lobbyId=e.lobbyId??"",r}};function QI(){return{color:0,isSpectator:!1}}E(QI,"createBaseJoinLobbyResult");var Ji={encode(e,r=new We){return e.color!==0&&r.uint32(8).int32(e.color),e.isSpectator!==!1&&r.uint32(16).bool(e.isSpectator),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=QI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.color=t.int32();continue}case 2:{if(n!==16)break;i.isSpectator=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{color:G(e.color)?Ke(e.color):0,isSpectator:G(e.isSpectator)?globalThis.Boolean(e.isSpectator):G(e.is_spectator)?globalThis.Boolean(e.is_spectator):!1}},toJSON(e){let r={};return e.color!==0&&(r.color=_r(e.color)),e.isSpectator!==!1&&(r.isSpectator=e.isSpectator),r},create(e){return Ji.fromPartial(e??{})},fromPartial(e){let r=QI();return r.color=e.color??0,r.isSpectator=e.isSpectator??!1,r}};function jI(){return{success:!1,color:0}}E(jI,"createBaseMoveToPlayerResult");var qi={encode(e,r=new We){return e.success!==!1&&r.uint32(8).bool(e.success),e.color!==0&&r.uint32(16).int32(e.color),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=jI();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==16)break;i.color=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:G(e.success)?globalThis.Boolean(e.success):!1,color:G(e.color)?Ke(e.color):0}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.color!==0&&(r.color=_r(e.color)),r},create(e){return qi.fromPartial(e??{})},fromPartial(e){let r=jI();return r.success=e.success??!1,r.color=e.color??0,r}};function eC(){return{mapPool:[]}}E(eC,"createBaseSubmitMapChoiceResult");var Zi={encode(e,r=new We){r.uint32(10).fork();for(let t of e.mapPool)r.int32(t);return r.join(),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=eC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n===8){i.mapPool.push(t.int32());continue}if(n===10){let a=t.uint32()+t.pos;for(;t.pos<a;)i.mapPool.push(t.int32());continue}break}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{mapPool:globalThis.Array.isArray(e?.mapPool)?e.mapPool.map(r=>globalThis.Number(r)):globalThis.Array.isArray(e?.map_pool)?e.map_pool.map(r=>globalThis.Number(r)):[]}},toJSON(e){let r={};return e.mapPool?.length&&(r.mapPool=e.mapPool.map(t=>Math.round(t))),r},create(e){return Zi.fromPartial(e??{})},fromPartial(e){let r=eC();return r.mapPool=e.mapPool?.map(t=>t)||[],r}};function rC(){return{isReady:!1,startingAt:void 0}}E(rC,"createBaseToggleReadyResult");var Xi={encode(e,r=new We){return e.isReady!==!1&&r.uint32(8).bool(e.isReady),e.startingAt!==void 0&&Le.encode(Xg(e.startingAt),r.uint32(18).fork()).join(),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=rC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.isReady=t.bool();continue}case 2:{if(n!==18)break;i.startingAt=_C(Le.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{isReady:G(e.isReady)?globalThis.Boolean(e.isReady):G(e.is_ready)?globalThis.Boolean(e.is_ready):!1,startingAt:G(e.startingAt)?sC(e.startingAt):G(e.starting_at)?sC(e.starting_at):void 0}},toJSON(e){let r={};return e.isReady!==!1&&(r.isReady=e.isReady),e.startingAt!==void 0&&(r.startingAt=e.startingAt.toISOString()),r},create(e){return Xi.fromPartial(e??{})},fromPartial(e){let r=rC();return r.isReady=e.isReady??!1,r.startingAt=e.startingAt??void 0,r}};function tC(){return{gameId:""}}E(tC,"createBaseStartGameResult");var zi={encode(e,r=new We){return e.gameId!==""&&r.uint32(10).string(e.gameId),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=tC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:G(e.gameId)?globalThis.String(e.gameId):G(e.game_id)?globalThis.String(e.game_id):""}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),r},create(e){return zi.fromPartial(e??{})},fromPartial(e){let r=tC();return r.gameId=e.gameId??"",r}};function nC(){return{status:"",gameId:""}}E(nC,"createBaseProcessMapChoiceExpiryResult");var $i={encode(e,r=new We){return e.status!==""&&r.uint32(10).string(e.status),e.gameId!==""&&r.uint32(18).string(e.gameId),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=nC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.status=t.string();continue}case 2:{if(n!==18)break;i.gameId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{status:G(e.status)?globalThis.String(e.status):"",gameId:G(e.gameId)?globalThis.String(e.gameId):G(e.game_id)?globalThis.String(e.game_id):""}},toJSON(e){let r={};return e.status!==""&&(r.status=e.status),e.gameId!==""&&(r.gameId=e.gameId),r},create(e){return $i.fromPartial(e??{})},fromPartial(e){let r=nC();return r.status=e.status??"",r.gameId=e.gameId??"",r}};function iC(){return{success:!1,error:"",createResult:void 0,joinResult:void 0,moveToPlayerResult:void 0,submitMapChoiceResult:void 0,toggleReadyResult:void 0,startGameResult:void 0,processMapChoiceExpiryResult:void 0}}E(iC,"createBaseLobbyActionResponse");var Lc={encode(e,r=new We){return e.success!==!1&&r.uint32(8).bool(e.success),e.error!==""&&r.uint32(18).string(e.error),e.createResult!==void 0&&Wi.encode(e.createResult,r.uint32(26).fork()).join(),e.joinResult!==void 0&&Ji.encode(e.joinResult,r.uint32(34).fork()).join(),e.moveToPlayerResult!==void 0&&qi.encode(e.moveToPlayerResult,r.uint32(42).fork()).join(),e.submitMapChoiceResult!==void 0&&Zi.encode(e.submitMapChoiceResult,r.uint32(50).fork()).join(),e.toggleReadyResult!==void 0&&Xi.encode(e.toggleReadyResult,r.uint32(58).fork()).join(),e.startGameResult!==void 0&&zi.encode(e.startGameResult,r.uint32(66).fork()).join(),e.processMapChoiceExpiryResult!==void 0&&$i.encode(e.processMapChoiceExpiryResult,r.uint32(74).fork()).join(),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=iC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==18)break;i.error=t.string();continue}case 3:{if(n!==26)break;i.createResult=Wi.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.joinResult=Ji.decode(t,t.uint32());continue}case 5:{if(n!==42)break;i.moveToPlayerResult=qi.decode(t,t.uint32());continue}case 6:{if(n!==50)break;i.submitMapChoiceResult=Zi.decode(t,t.uint32());continue}case 7:{if(n!==58)break;i.toggleReadyResult=Xi.decode(t,t.uint32());continue}case 8:{if(n!==66)break;i.startGameResult=zi.decode(t,t.uint32());continue}case 9:{if(n!==74)break;i.processMapChoiceExpiryResult=$i.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:G(e.success)?globalThis.Boolean(e.success):!1,error:G(e.error)?globalThis.String(e.error):"",createResult:G(e.createResult)?Wi.fromJSON(e.createResult):G(e.create_result)?Wi.fromJSON(e.create_result):void 0,joinResult:G(e.joinResult)?Ji.fromJSON(e.joinResult):G(e.join_result)?Ji.fromJSON(e.join_result):void 0,moveToPlayerResult:G(e.moveToPlayerResult)?qi.fromJSON(e.moveToPlayerResult):G(e.move_to_player_result)?qi.fromJSON(e.move_to_player_result):void 0,submitMapChoiceResult:G(e.submitMapChoiceResult)?Zi.fromJSON(e.submitMapChoiceResult):G(e.submit_map_choice_result)?Zi.fromJSON(e.submit_map_choice_result):void 0,toggleReadyResult:G(e.toggleReadyResult)?Xi.fromJSON(e.toggleReadyResult):G(e.toggle_ready_result)?Xi.fromJSON(e.toggle_ready_result):void 0,startGameResult:G(e.startGameResult)?zi.fromJSON(e.startGameResult):G(e.start_game_result)?zi.fromJSON(e.start_game_result):void 0,processMapChoiceExpiryResult:G(e.processMapChoiceExpiryResult)?$i.fromJSON(e.processMapChoiceExpiryResult):G(e.process_map_choice_expiry_result)?$i.fromJSON(e.process_map_choice_expiry_result):void 0}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.error!==""&&(r.error=e.error),e.createResult!==void 0&&(r.createResult=Wi.toJSON(e.createResult)),e.joinResult!==void 0&&(r.joinResult=Ji.toJSON(e.joinResult)),e.moveToPlayerResult!==void 0&&(r.moveToPlayerResult=qi.toJSON(e.moveToPlayerResult)),e.submitMapChoiceResult!==void 0&&(r.submitMapChoiceResult=Zi.toJSON(e.submitMapChoiceResult)),e.toggleReadyResult!==void 0&&(r.toggleReadyResult=Xi.toJSON(e.toggleReadyResult)),e.startGameResult!==void 0&&(r.startGameResult=zi.toJSON(e.startGameResult)),e.processMapChoiceExpiryResult!==void 0&&(r.processMapChoiceExpiryResult=$i.toJSON(e.processMapChoiceExpiryResult)),r},create(e){return Lc.fromPartial(e??{})},fromPartial(e){let r=iC();return r.success=e.success??!1,r.error=e.error??"",r.createResult=e.createResult!==void 0&&e.createResult!==null?Wi.fromPartial(e.createResult):void 0,r.joinResult=e.joinResult!==void 0&&e.joinResult!==null?Ji.fromPartial(e.joinResult):void 0,r.moveToPlayerResult=e.moveToPlayerResult!==void 0&&e.moveToPlayerResult!==null?qi.fromPartial(e.moveToPlayerResult):void 0,r.submitMapChoiceResult=e.submitMapChoiceResult!==void 0&&e.submitMapChoiceResult!==null?Zi.fromPartial(e.submitMapChoiceResult):void 0,r.toggleReadyResult=e.toggleReadyResult!==void 0&&e.toggleReadyResult!==null?Xi.fromPartial(e.toggleReadyResult):void 0,r.startGameResult=e.startGameResult!==void 0&&e.startGameResult!==null?zi.fromPartial(e.startGameResult):void 0,r.processMapChoiceExpiryResult=e.processMapChoiceExpiryResult!==void 0&&e.processMapChoiceExpiryResult!==null?$i.fromPartial(e.processMapChoiceExpiryResult):void 0,r}};function oC(){return{pausesPerPlayer:0,voteCountdownSeconds:0}}E(oC,"createBasePauseConfig");var Qi={encode(e,r=new We){return e.pausesPerPlayer!==0&&r.uint32(8).int32(e.pausesPerPlayer),e.voteCountdownSeconds!==0&&r.uint32(16).int32(e.voteCountdownSeconds),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=oC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.pausesPerPlayer=t.int32();continue}case 2:{if(n!==16)break;i.voteCountdownSeconds=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{pausesPerPlayer:G(e.pausesPerPlayer)?globalThis.Number(e.pausesPerPlayer):G(e.pauses_per_player)?globalThis.Number(e.pauses_per_player):0,voteCountdownSeconds:G(e.voteCountdownSeconds)?globalThis.Number(e.voteCountdownSeconds):G(e.vote_countdown_seconds)?globalThis.Number(e.vote_countdown_seconds):0}},toJSON(e){let r={};return e.pausesPerPlayer!==0&&(r.pausesPerPlayer=Math.round(e.pausesPerPlayer)),e.voteCountdownSeconds!==0&&(r.voteCountdownSeconds=Math.round(e.voteCountdownSeconds)),r},create(e){return Qi.fromPartial(e??{})},fromPartial(e){let r=oC();return r.pausesPerPlayer=e.pausesPerPlayer??0,r.voteCountdownSeconds=e.voteCountdownSeconds??0,r}};function aC(){return{numPlayers:0,expansions:[],boardLayout:"",victoryPoints:0,friendlyRobber:!1,speedRobber:!1,mapChoiceMode:0,mapPoolSize:0,discardLimit:0,pauseConfig:void 0,eventCards:!1,randomizePlayerOrder:!1,secondSettler:!1,rushMode:!1,turboMode:!1,mapType:0,chessClockSpeed:0,chessClockInitialSeconds:0,chessClockIncrementSeconds:0,firstSettleMode:0,secondSettleMode:0,firstFound:0,secondFound:0,lazyRobber:!1,hideDiceStats:!1,hidePlayedDevCards:!1,allowPlayerTrades:!1,disableCounterOffers:!1}}E(aC,"createBaseLobbyConfig");var Et={encode(e,r=new We){e.numPlayers!==0&&r.uint32(8).int32(e.numPlayers);for(let t of e.expansions)r.uint32(18).string(t);return e.boardLayout!==""&&r.uint32(26).string(e.boardLayout),e.victoryPoints!==0&&r.uint32(32).int32(e.victoryPoints),e.friendlyRobber!==!1&&r.uint32(40).bool(e.friendlyRobber),e.speedRobber!==!1&&r.uint32(48).bool(e.speedRobber),e.mapChoiceMode!==0&&r.uint32(56).int32(e.mapChoiceMode),e.mapPoolSize!==0&&r.uint32(64).int32(e.mapPoolSize),e.discardLimit!==0&&r.uint32(72).int32(e.discardLimit),e.pauseConfig!==void 0&&Qi.encode(e.pauseConfig,r.uint32(82).fork()).join(),e.eventCards!==!1&&r.uint32(88).bool(e.eventCards),e.randomizePlayerOrder!==!1&&r.uint32(96).bool(e.randomizePlayerOrder),e.secondSettler!==!1&&r.uint32(104).bool(e.secondSettler),e.rushMode!==!1&&r.uint32(112).bool(e.rushMode),e.turboMode!==!1&&r.uint32(120).bool(e.turboMode),e.mapType!==0&&r.uint32(128).int32(e.mapType),e.chessClockSpeed!==0&&r.uint32(136).int32(e.chessClockSpeed),e.chessClockInitialSeconds!==0&&r.uint32(144).int32(e.chessClockInitialSeconds),e.chessClockIncrementSeconds!==0&&r.uint32(152).int32(e.chessClockIncrementSeconds),e.firstSettleMode!==0&&r.uint32(160).int32(e.firstSettleMode),e.secondSettleMode!==0&&r.uint32(168).int32(e.secondSettleMode),e.firstFound!==0&&r.uint32(176).int32(e.firstFound),e.secondFound!==0&&r.uint32(184).int32(e.secondFound),e.lazyRobber!==!1&&r.uint32(192).bool(e.lazyRobber),e.hideDiceStats!==!1&&r.uint32(200).bool(e.hideDiceStats),e.hidePlayedDevCards!==!1&&r.uint32(208).bool(e.hidePlayedDevCards),e.allowPlayerTrades!==!1&&r.uint32(216).bool(e.allowPlayerTrades),e.disableCounterOffers!==!1&&r.uint32(224).bool(e.disableCounterOffers),r},decode(e,r){let t=e instanceof ae?e:new ae(e),o=r===void 0?t.len:t.pos+r,i=aC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.numPlayers=t.int32();continue}case 2:{if(n!==18)break;i.expansions.push(t.string());continue}case 3:{if(n!==26)break;i.boardLayout=t.string();continue}case 4:{if(n!==32)break;i.victoryPoints=t.int32();continue}case 5:{if(n!==40)break;i.friendlyRobber=t.bool();continue}case 6:{if(n!==48)break;i.speedRobber=t.bool();continue}case 7:{if(n!==56)break;i.mapChoiceMode=t.int32();continue}case 8:{if(n!==64)break;i.mapPoolSize=t.int32();continue}case 9:{if(n!==72)break;i.discardLimit=t.int32();continue}case 10:{if(n!==82)break;i.pauseConfig=Qi.decode(t,t.uint32());continue}case 11:{if(n!==88)break;i.eventCards=t.bool();continue}case 12:{if(n!==96)break;i.randomizePlayerOrder=t.bool();continue}case 13:{if(n!==104)break;i.secondSettler=t.bool();continue}case 14:{if(n!==112)break;i.rushMode=t.bool();continue}case 15:{if(n!==120)break;i.turboMode=t.bool();continue}case 16:{if(n!==128)break;i.mapType=t.int32();continue}case 17:{if(n!==136)break;i.chessClockSpeed=t.int32();continue}case 18:{if(n!==144)break;i.chessClockInitialSeconds=t.int32();continue}case 19:{if(n!==152)break;i.chessClockIncrementSeconds=t.int32();continue}case 20:{if(n!==160)break;i.firstSettleMode=t.int32();continue}case 21:{if(n!==168)break;i.secondSettleMode=t.int32();continue}case 22:{if(n!==176)break;i.firstFound=t.int32();continue}case 23:{if(n!==184)break;i.secondFound=t.int32();continue}case 24:{if(n!==192)break;i.lazyRobber=t.bool();continue}case 25:{if(n!==200)break;i.hideDiceStats=t.bool();continue}case 26:{if(n!==208)break;i.hidePlayedDevCards=t.bool();continue}case 27:{if(n!==216)break;i.allowPlayerTrades=t.bool();continue}case 28:{if(n!==224)break;i.disableCounterOffers=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{numPlayers:G(e.numPlayers)?globalThis.Number(e.numPlayers):G(e.num_players)?globalThis.Number(e.num_players):0,expansions:globalThis.Array.isArray(e?.expansions)?e.expansions.map(r=>globalThis.String(r)):[],boardLayout:G(e.boardLayout)?globalThis.String(e.boardLayout):G(e.board_layout)?globalThis.String(e.board_layout):"",victoryPoints:G(e.victoryPoints)?globalThis.Number(e.victoryPoints):G(e.victory_points)?globalThis.Number(e.victory_points):0,friendlyRobber:G(e.friendlyRobber)?globalThis.Boolean(e.friendlyRobber):G(e.friendly_robber)?globalThis.Boolean(e.friendly_robber):!1,speedRobber:G(e.speedRobber)?globalThis.Boolean(e.speedRobber):G(e.speed_robber)?globalThis.Boolean(e.speed_robber):!1,mapChoiceMode:G(e.mapChoiceMode)?Nu(e.mapChoiceMode):G(e.map_choice_mode)?Nu(e.map_choice_mode):0,mapPoolSize:G(e.mapPoolSize)?globalThis.Number(e.mapPoolSize):G(e.map_pool_size)?globalThis.Number(e.map_pool_size):0,discardLimit:G(e.discardLimit)?globalThis.Number(e.discardLimit):G(e.discard_limit)?globalThis.Number(e.discard_limit):0,pauseConfig:G(e.pauseConfig)?Qi.fromJSON(e.pauseConfig):G(e.pause_config)?Qi.fromJSON(e.pause_config):void 0,eventCards:G(e.eventCards)?globalThis.Boolean(e.eventCards):G(e.event_cards)?globalThis.Boolean(e.event_cards):!1,randomizePlayerOrder:G(e.randomizePlayerOrder)?globalThis.Boolean(e.randomizePlayerOrder):G(e.randomize_player_order)?globalThis.Boolean(e.randomize_player_order):!1,secondSettler:G(e.secondSettler)?globalThis.Boolean(e.secondSettler):G(e.second_settler)?globalThis.Boolean(e.second_settler):!1,rushMode:G(e.rushMode)?globalThis.Boolean(e.rushMode):G(e.rush_mode)?globalThis.Boolean(e.rush_mode):!1,turboMode:G(e.turboMode)?globalThis.Boolean(e.turboMode):G(e.turbo_mode)?globalThis.Boolean(e.turbo_mode):!1,mapType:G(e.mapType)?globalThis.Number(e.mapType):G(e.map_type)?globalThis.Number(e.map_type):0,chessClockSpeed:G(e.chessClockSpeed)?globalThis.Number(e.chessClockSpeed):G(e.chess_clock_speed)?globalThis.Number(e.chess_clock_speed):0,chessClockInitialSeconds:G(e.chessClockInitialSeconds)?globalThis.Number(e.chessClockInitialSeconds):G(e.chess_clock_initial_seconds)?globalThis.Number(e.chess_clock_initial_seconds):0,chessClockIncrementSeconds:G(e.chessClockIncrementSeconds)?globalThis.Number(e.chessClockIncrementSeconds):G(e.chess_clock_increment_seconds)?globalThis.Number(e.chess_clock_increment_seconds):0,firstSettleMode:G(e.firstSettleMode)?globalThis.Number(e.firstSettleMode):G(e.first_settle_mode)?globalThis.Number(e.first_settle_mode):0,secondSettleMode:G(e.secondSettleMode)?globalThis.Number(e.secondSettleMode):G(e.second_settle_mode)?globalThis.Number(e.second_settle_mode):0,firstFound:G(e.firstFound)?globalThis.Number(e.firstFound):G(e.first_found)?globalThis.Number(e.first_found):0,secondFound:G(e.secondFound)?globalThis.Number(e.secondFound):G(e.second_found)?globalThis.Number(e.second_found):0,lazyRobber:G(e.lazyRobber)?globalThis.Boolean(e.lazyRobber):G(e.lazy_robber)?globalThis.Boolean(e.lazy_robber):!1,hideDiceStats:G(e.hideDiceStats)?globalThis.Boolean(e.hideDiceStats):G(e.hide_dice_stats)?globalThis.Boolean(e.hide_dice_stats):!1,hidePlayedDevCards:G(e.hidePlayedDevCards)?globalThis.Boolean(e.hidePlayedDevCards):G(e.hide_played_dev_cards)?globalThis.Boolean(e.hide_played_dev_cards):!1,allowPlayerTrades:G(e.allowPlayerTrades)?globalThis.Boolean(e.allowPlayerTrades):G(e.allow_player_trades)?globalThis.Boolean(e.allow_player_trades):!1,disableCounterOffers:G(e.disableCounterOffers)?globalThis.Boolean(e.disableCounterOffers):G(e.disable_counter_offers)?globalThis.Boolean(e.disable_counter_offers):!1}},toJSON(e){let r={};return e.numPlayers!==0&&(r.numPlayers=Math.round(e.numPlayers)),e.expansions?.length&&(r.expansions=e.expansions),e.boardLayout!==""&&(r.boardLayout=e.boardLayout),e.victoryPoints!==0&&(r.victoryPoints=Math.round(e.victoryPoints)),e.friendlyRobber!==!1&&(r.friendlyRobber=e.friendlyRobber),e.speedRobber!==!1&&(r.speedRobber=e.speedRobber),e.mapChoiceMode!==0&&(r.mapChoiceMode=Mc(e.mapChoiceMode)),e.mapPoolSize!==0&&(r.mapPoolSize=Math.round(e.mapPoolSize)),e.discardLimit!==0&&(r.discardLimit=Math.round(e.discardLimit)),e.pauseConfig!==void 0&&(r.pauseConfig=Qi.toJSON(e.pauseConfig)),e.eventCards!==!1&&(r.eventCards=e.eventCards),e.randomizePlayerOrder!==!1&&(r.randomizePlayerOrder=e.randomizePlayerOrder),e.secondSettler!==!1&&(r.secondSettler=e.secondSettler),e.rushMode!==!1&&(r.rushMode=e.rushMode),e.turboMode!==!1&&(r.turboMode=e.turboMode),e.mapType!==0&&(r.mapType=Math.round(e.mapType)),e.chessClockSpeed!==0&&(r.chessClockSpeed=Math.round(e.chessClockSpeed)),e.chessClockInitialSeconds!==0&&(r.chessClockInitialSeconds=Math.round(e.chessClockInitialSeconds)),e.chessClockIncrementSeconds!==0&&(r.chessClockIncrementSeconds=Math.round(e.chessClockIncrementSeconds)),e.firstSettleMode!==0&&(r.firstSettleMode=Math.round(e.firstSettleMode)),e.secondSettleMode!==0&&(r.secondSettleMode=Math.round(e.secondSettleMode)),e.firstFound!==0&&(r.firstFound=Math.round(e.firstFound)),e.secondFound!==0&&(r.secondFound=Math.round(e.secondFound)),e.lazyRobber!==!1&&(r.lazyRobber=e.lazyRobber),e.hideDiceStats!==!1&&(r.hideDiceStats=e.hideDiceStats),e.hidePlayedDevCards!==!1&&(r.hidePlayedDevCards=e.hidePlayedDevCards),e.allowPlayerTrades!==!1&&(r.allowPlayerTrades=e.allowPlayerTrades),e.disableCounterOffers!==!1&&(r.disableCounterOffers=e.disableCounterOffers),r},create(e){return Et.fromPartial(e??{})},fromPartial(e){let r=aC();return r.numPlayers=e.numPlayers??0,r.expansions=e.expansions?.map(t=>t)||[],r.boardLayout=e.boardLayout??"",r.victoryPoints=e.victoryPoints??0,r.friendlyRobber=e.friendlyRobber??!1,r.speedRobber=e.speedRobber??!1,r.mapChoiceMode=e.mapChoiceMode??0,r.mapPoolSize=e.mapPoolSize??0,r.discardLimit=e.discardLimit??0,r.pauseConfig=e.pauseConfig!==void 0&&e.pauseConfig!==null?Qi.fromPartial(e.pauseConfig):void 0,r.eventCards=e.eventCards??!1,r.randomizePlayerOrder=e.randomizePlayerOrder??!1,r.secondSettler=e.secondSettler??!1,r.rushMode=e.rushMode??!1,r.turboMode=e.turboMode??!1,r.mapType=e.mapType??0,r.chessClockSpeed=e.chessClockSpeed??0,r.chessClockInitialSeconds=e.chessClockInitialSeconds??0,r.chessClockIncrementSeconds=e.chessClockIncrementSeconds??0,r.firstSettleMode=e.firstSettleMode??0,r.secondSettleMode=e.secondSettleMode??0,r.firstFound=e.firstFound??0,r.secondFound=e.secondFound??0,r.lazyRobber=e.lazyRobber??!1,r.hideDiceStats=e.hideDiceStats??!1,r.hidePlayedDevCards=e.hidePlayedDevCards??!1,r.allowPlayerTrades=e.allowPlayerTrades??!1,r.disableCounterOffers=e.disableCounterOffers??!1,r}};function Xg(e){let r=Math.trunc(e.getTime()/1e3),t=e.getTime()%1e3*1e6;return{seconds:r,nanos:t}}E(Xg,"toTimestamp");function _C(e){let r=(e.seconds||0)*1e3;return r+=(e.nanos||0)/1e6,new globalThis.Date(r)}E(_C,"fromTimestamp");function sC(e){return e instanceof globalThis.Date?e:typeof e=="string"?new globalThis.Date(e):_C(Le.fromJSON(e))}E(sC,"fromJsonTimestamp");function G(e){return e!=null}E(G,"isSet");import{BinaryReader as Q,BinaryWriter as Ge}from"@bufbuild/protobuf/wire";import{BinaryReader as vC,BinaryWriter as sy}from"@bufbuild/protobuf/wire";import{BinaryReader as Pt,BinaryWriter as ps}from"@bufbuild/protobuf/wire";var It;(function(e){e[e.COMMODITY_UNSPECIFIED=0]="COMMODITY_UNSPECIFIED",e[e.COMMODITY_PAPER=1]="COMMODITY_PAPER",e[e.COMMODITY_CLOTH=2]="COMMODITY_CLOTH",e[e.COMMODITY_COIN=3]="COMMODITY_COIN",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(It||(It={}));function Is(e){switch(e){case 0:case"COMMODITY_UNSPECIFIED":return It.COMMODITY_UNSPECIFIED;case 1:case"COMMODITY_PAPER":return It.COMMODITY_PAPER;case 2:case"COMMODITY_CLOTH":return It.COMMODITY_CLOTH;case 3:case"COMMODITY_COIN":return It.COMMODITY_COIN;default:return It.UNRECOGNIZED}}E(Is,"commodityFromJSON");function Cs(e){switch(e){case It.COMMODITY_UNSPECIFIED:return"COMMODITY_UNSPECIFIED";case It.COMMODITY_PAPER:return"COMMODITY_PAPER";case It.COMMODITY_CLOTH:return"COMMODITY_CLOTH";case It.COMMODITY_COIN:return"COMMODITY_COIN";case It.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Cs,"commodityToJSON");var dC;(function(e){e[e.KNIGHT_STRENGTH_UNSPECIFIED=0]="KNIGHT_STRENGTH_UNSPECIFIED",e[e.KNIGHT_STRENGTH_BASIC=1]="KNIGHT_STRENGTH_BASIC",e[e.KNIGHT_STRENGTH_STRONG=2]="KNIGHT_STRENGTH_STRONG",e[e.KNIGHT_STRENGTH_MIGHTY=3]="KNIGHT_STRENGTH_MIGHTY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(dC||(dC={}));var uC;(function(e){e[e.KNIGHT_STATUS_UNSPECIFIED=0]="KNIGHT_STATUS_UNSPECIFIED",e[e.KNIGHT_STATUS_INACTIVE=1]="KNIGHT_STATUS_INACTIVE",e[e.KNIGHT_STATUS_ACTIVE=2]="KNIGHT_STATUS_ACTIVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(uC||(uC={}));var Ct;(function(e){e[e.CITY_IMPROVEMENT_TRACK_UNSPECIFIED=0]="CITY_IMPROVEMENT_TRACK_UNSPECIFIED",e[e.CITY_IMPROVEMENT_TRACK_TRADE=1]="CITY_IMPROVEMENT_TRACK_TRADE",e[e.CITY_IMPROVEMENT_TRACK_POLITICS=2]="CITY_IMPROVEMENT_TRACK_POLITICS",e[e.CITY_IMPROVEMENT_TRACK_SCIENCE=3]="CITY_IMPROVEMENT_TRACK_SCIENCE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Ct||(Ct={}));function Ps(e){switch(e){case 0:case"CITY_IMPROVEMENT_TRACK_UNSPECIFIED":return Ct.CITY_IMPROVEMENT_TRACK_UNSPECIFIED;case 1:case"CITY_IMPROVEMENT_TRACK_TRADE":return Ct.CITY_IMPROVEMENT_TRACK_TRADE;case 2:case"CITY_IMPROVEMENT_TRACK_POLITICS":return Ct.CITY_IMPROVEMENT_TRACK_POLITICS;case 3:case"CITY_IMPROVEMENT_TRACK_SCIENCE":return Ct.CITY_IMPROVEMENT_TRACK_SCIENCE;default:return Ct.UNRECOGNIZED}}E(Ps,"cityImprovementTrackFromJSON");function Z_(e){switch(e){case Ct.CITY_IMPROVEMENT_TRACK_UNSPECIFIED:return"CITY_IMPROVEMENT_TRACK_UNSPECIFIED";case Ct.CITY_IMPROVEMENT_TRACK_TRADE:return"CITY_IMPROVEMENT_TRACK_TRADE";case Ct.CITY_IMPROVEMENT_TRACK_POLITICS:return"CITY_IMPROVEMENT_TRACK_POLITICS";case Ct.CITY_IMPROVEMENT_TRACK_SCIENCE:return"CITY_IMPROVEMENT_TRACK_SCIENCE";case Ct.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Z_,"cityImprovementTrackToJSON");var EC;(function(e){e[e.EVENT_DIE_RESULT_UNSPECIFIED=0]="EVENT_DIE_RESULT_UNSPECIFIED",e[e.EVENT_DIE_RESULT_BARBARIAN_SHIP=1]="EVENT_DIE_RESULT_BARBARIAN_SHIP",e[e.EVENT_DIE_RESULT_TRADE_GATE=2]="EVENT_DIE_RESULT_TRADE_GATE",e[e.EVENT_DIE_RESULT_POLITICS_GATE=3]="EVENT_DIE_RESULT_POLITICS_GATE",e[e.EVENT_DIE_RESULT_SCIENCE_GATE=4]="EVENT_DIE_RESULT_SCIENCE_GATE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(EC||(EC={}));var ue;(function(e){e[e.PROGRESS_CARD_UNSPECIFIED=0]="PROGRESS_CARD_UNSPECIFIED",e[e.PROGRESS_CARD_ALCHEMIST=1]="PROGRESS_CARD_ALCHEMIST",e[e.PROGRESS_CARD_CRANE=2]="PROGRESS_CARD_CRANE",e[e.PROGRESS_CARD_ENGINEER=3]="PROGRESS_CARD_ENGINEER",e[e.PROGRESS_CARD_INVENTOR=4]="PROGRESS_CARD_INVENTOR",e[e.PROGRESS_CARD_IRRIGATION=5]="PROGRESS_CARD_IRRIGATION",e[e.PROGRESS_CARD_MEDICINE=6]="PROGRESS_CARD_MEDICINE",e[e.PROGRESS_CARD_MINING=7]="PROGRESS_CARD_MINING",e[e.PROGRESS_CARD_PRINTER=8]="PROGRESS_CARD_PRINTER",e[e.PROGRESS_CARD_ROAD_BUILDING=9]="PROGRESS_CARD_ROAD_BUILDING",e[e.PROGRESS_CARD_SMITH=10]="PROGRESS_CARD_SMITH",e[e.PROGRESS_CARD_BISHOP=11]="PROGRESS_CARD_BISHOP",e[e.PROGRESS_CARD_CONSTITUTION=12]="PROGRESS_CARD_CONSTITUTION",e[e.PROGRESS_CARD_DESERTER=13]="PROGRESS_CARD_DESERTER",e[e.PROGRESS_CARD_DIPLOMAT=14]="PROGRESS_CARD_DIPLOMAT",e[e.PROGRESS_CARD_INTRIGUE=15]="PROGRESS_CARD_INTRIGUE",e[e.PROGRESS_CARD_SABOTEUR=16]="PROGRESS_CARD_SABOTEUR",e[e.PROGRESS_CARD_SPY=17]="PROGRESS_CARD_SPY",e[e.PROGRESS_CARD_WARLORD=18]="PROGRESS_CARD_WARLORD",e[e.PROGRESS_CARD_WEDDING=19]="PROGRESS_CARD_WEDDING",e[e.PROGRESS_CARD_COMMERCIAL_HARBOR=20]="PROGRESS_CARD_COMMERCIAL_HARBOR",e[e.PROGRESS_CARD_MASTER_MERCHANT=21]="PROGRESS_CARD_MASTER_MERCHANT",e[e.PROGRESS_CARD_MERCHANT=22]="PROGRESS_CARD_MERCHANT",e[e.PROGRESS_CARD_MERCHANT_FLEET=23]="PROGRESS_CARD_MERCHANT_FLEET",e[e.PROGRESS_CARD_RESOURCE_MONOPOLY=24]="PROGRESS_CARD_RESOURCE_MONOPOLY",e[e.PROGRESS_CARD_TRADE_MONOPOLY=25]="PROGRESS_CARD_TRADE_MONOPOLY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ue||(ue={}));function mn(e){switch(e){case 0:case"PROGRESS_CARD_UNSPECIFIED":return ue.PROGRESS_CARD_UNSPECIFIED;case 1:case"PROGRESS_CARD_ALCHEMIST":return ue.PROGRESS_CARD_ALCHEMIST;case 2:case"PROGRESS_CARD_CRANE":return ue.PROGRESS_CARD_CRANE;case 3:case"PROGRESS_CARD_ENGINEER":return ue.PROGRESS_CARD_ENGINEER;case 4:case"PROGRESS_CARD_INVENTOR":return ue.PROGRESS_CARD_INVENTOR;case 5:case"PROGRESS_CARD_IRRIGATION":return ue.PROGRESS_CARD_IRRIGATION;case 6:case"PROGRESS_CARD_MEDICINE":return ue.PROGRESS_CARD_MEDICINE;case 7:case"PROGRESS_CARD_MINING":return ue.PROGRESS_CARD_MINING;case 8:case"PROGRESS_CARD_PRINTER":return ue.PROGRESS_CARD_PRINTER;case 9:case"PROGRESS_CARD_ROAD_BUILDING":return ue.PROGRESS_CARD_ROAD_BUILDING;case 10:case"PROGRESS_CARD_SMITH":return ue.PROGRESS_CARD_SMITH;case 11:case"PROGRESS_CARD_BISHOP":return ue.PROGRESS_CARD_BISHOP;case 12:case"PROGRESS_CARD_CONSTITUTION":return ue.PROGRESS_CARD_CONSTITUTION;case 13:case"PROGRESS_CARD_DESERTER":return ue.PROGRESS_CARD_DESERTER;case 14:case"PROGRESS_CARD_DIPLOMAT":return ue.PROGRESS_CARD_DIPLOMAT;case 15:case"PROGRESS_CARD_INTRIGUE":return ue.PROGRESS_CARD_INTRIGUE;case 16:case"PROGRESS_CARD_SABOTEUR":return ue.PROGRESS_CARD_SABOTEUR;case 17:case"PROGRESS_CARD_SPY":return ue.PROGRESS_CARD_SPY;case 18:case"PROGRESS_CARD_WARLORD":return ue.PROGRESS_CARD_WARLORD;case 19:case"PROGRESS_CARD_WEDDING":return ue.PROGRESS_CARD_WEDDING;case 20:case"PROGRESS_CARD_COMMERCIAL_HARBOR":return ue.PROGRESS_CARD_COMMERCIAL_HARBOR;case 21:case"PROGRESS_CARD_MASTER_MERCHANT":return ue.PROGRESS_CARD_MASTER_MERCHANT;case 22:case"PROGRESS_CARD_MERCHANT":return ue.PROGRESS_CARD_MERCHANT;case 23:case"PROGRESS_CARD_MERCHANT_FLEET":return ue.PROGRESS_CARD_MERCHANT_FLEET;case 24:case"PROGRESS_CARD_RESOURCE_MONOPOLY":return ue.PROGRESS_CARD_RESOURCE_MONOPOLY;case 25:case"PROGRESS_CARD_TRADE_MONOPOLY":return ue.PROGRESS_CARD_TRADE_MONOPOLY;default:return ue.UNRECOGNIZED}}E(mn,"progressCardFromJSON");function ji(e){switch(e){case ue.PROGRESS_CARD_UNSPECIFIED:return"PROGRESS_CARD_UNSPECIFIED";case ue.PROGRESS_CARD_ALCHEMIST:return"PROGRESS_CARD_ALCHEMIST";case ue.PROGRESS_CARD_CRANE:return"PROGRESS_CARD_CRANE";case ue.PROGRESS_CARD_ENGINEER:return"PROGRESS_CARD_ENGINEER";case ue.PROGRESS_CARD_INVENTOR:return"PROGRESS_CARD_INVENTOR";case ue.PROGRESS_CARD_IRRIGATION:return"PROGRESS_CARD_IRRIGATION";case ue.PROGRESS_CARD_MEDICINE:return"PROGRESS_CARD_MEDICINE";case ue.PROGRESS_CARD_MINING:return"PROGRESS_CARD_MINING";case ue.PROGRESS_CARD_PRINTER:return"PROGRESS_CARD_PRINTER";case ue.PROGRESS_CARD_ROAD_BUILDING:return"PROGRESS_CARD_ROAD_BUILDING";case ue.PROGRESS_CARD_SMITH:return"PROGRESS_CARD_SMITH";case ue.PROGRESS_CARD_BISHOP:return"PROGRESS_CARD_BISHOP";case ue.PROGRESS_CARD_CONSTITUTION:return"PROGRESS_CARD_CONSTITUTION";case ue.PROGRESS_CARD_DESERTER:return"PROGRESS_CARD_DESERTER";case ue.PROGRESS_CARD_DIPLOMAT:return"PROGRESS_CARD_DIPLOMAT";case ue.PROGRESS_CARD_INTRIGUE:return"PROGRESS_CARD_INTRIGUE";case ue.PROGRESS_CARD_SABOTEUR:return"PROGRESS_CARD_SABOTEUR";case ue.PROGRESS_CARD_SPY:return"PROGRESS_CARD_SPY";case ue.PROGRESS_CARD_WARLORD:return"PROGRESS_CARD_WARLORD";case ue.PROGRESS_CARD_WEDDING:return"PROGRESS_CARD_WEDDING";case ue.PROGRESS_CARD_COMMERCIAL_HARBOR:return"PROGRESS_CARD_COMMERCIAL_HARBOR";case ue.PROGRESS_CARD_MASTER_MERCHANT:return"PROGRESS_CARD_MASTER_MERCHANT";case ue.PROGRESS_CARD_MERCHANT:return"PROGRESS_CARD_MERCHANT";case ue.PROGRESS_CARD_MERCHANT_FLEET:return"PROGRESS_CARD_MERCHANT_FLEET";case ue.PROGRESS_CARD_RESOURCE_MONOPOLY:return"PROGRESS_CARD_RESOURCE_MONOPOLY";case ue.PROGRESS_CARD_TRADE_MONOPOLY:return"PROGRESS_CARD_TRADE_MONOPOLY";case ue.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(ji,"progressCardToJSON");var lC;(function(e){e[e.EVENT_CARD_UNSPECIFIED=0]="EVENT_CARD_UNSPECIFIED",e[e.EVENT_CARD_BEAUTIFUL_DAY=1]="EVENT_CARD_BEAUTIFUL_DAY",e[e.EVENT_CARD_ROBBER_ATTACKS=2]="EVENT_CARD_ROBBER_ATTACKS",e[e.EVENT_CARD_CALM_SEAS=3]="EVENT_CARD_CALM_SEAS",e[e.EVENT_CARD_GOOD_NEIGHBORS=4]="EVENT_CARD_GOOD_NEIGHBORS",e[e.EVENT_CARD_ROBBER_FLEES=5]="EVENT_CARD_ROBBER_FLEES",e[e.EVENT_CARD_EPIDEMIC=6]="EVENT_CARD_EPIDEMIC",e[e.EVENT_CARD_CONFLICT=7]="EVENT_CARD_CONFLICT",e[e.EVENT_CARD_EARTHQUAKE=8]="EVENT_CARD_EARTHQUAKE",e[e.EVENT_CARD_HELPFUL_NEIGHBOR=9]="EVENT_CARD_HELPFUL_NEIGHBOR",e[e.EVENT_CARD_PLENTIFUL_YEAR=10]="EVENT_CARD_PLENTIFUL_YEAR",e[e.EVENT_CARD_TOURNAMENT=11]="EVENT_CARD_TOURNAMENT",e[e.EVENT_CARD_TRADE_ADVANTAGE=12]="EVENT_CARD_TRADE_ADVANTAGE",e[e.EVENT_CARD_NEW_YEAR=13]="EVENT_CARD_NEW_YEAR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(lC||(lC={}));var cC;(function(e){e[e.HEX_DIRECTION_TYPE_UNSPECIFIED=0]="HEX_DIRECTION_TYPE_UNSPECIFIED",e[e.HEX_DIRECTION_TYPE_NORTH_EAST=1]="HEX_DIRECTION_TYPE_NORTH_EAST",e[e.HEX_DIRECTION_TYPE_EAST=2]="HEX_DIRECTION_TYPE_EAST",e[e.HEX_DIRECTION_TYPE_SOUTH_EAST=3]="HEX_DIRECTION_TYPE_SOUTH_EAST",e[e.HEX_DIRECTION_TYPE_SOUTH_WEST=4]="HEX_DIRECTION_TYPE_SOUTH_WEST",e[e.HEX_DIRECTION_TYPE_WEST=5]="HEX_DIRECTION_TYPE_WEST",e[e.HEX_DIRECTION_TYPE_NORTH_WEST=6]="HEX_DIRECTION_TYPE_NORTH_WEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(cC||(cC={}));var hr;(function(e){e[e.VERTEX_DIRECTION_TYPE_UNSPECIFIED=0]="VERTEX_DIRECTION_TYPE_UNSPECIFIED",e[e.VERTEX_DIRECTION_TYPE_NORTH=1]="VERTEX_DIRECTION_TYPE_NORTH",e[e.VERTEX_DIRECTION_TYPE_NORTH_EAST=2]="VERTEX_DIRECTION_TYPE_NORTH_EAST",e[e.VERTEX_DIRECTION_TYPE_NORTH_WEST=3]="VERTEX_DIRECTION_TYPE_NORTH_WEST",e[e.VERTEX_DIRECTION_TYPE_SOUTH=4]="VERTEX_DIRECTION_TYPE_SOUTH",e[e.VERTEX_DIRECTION_TYPE_SOUTH_EAST=5]="VERTEX_DIRECTION_TYPE_SOUTH_EAST",e[e.VERTEX_DIRECTION_TYPE_SOUTH_WEST=6]="VERTEX_DIRECTION_TYPE_SOUTH_WEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(hr||(hr={}));function Ou(e){switch(e){case 0:case"VERTEX_DIRECTION_TYPE_UNSPECIFIED":return hr.VERTEX_DIRECTION_TYPE_UNSPECIFIED;case 1:case"VERTEX_DIRECTION_TYPE_NORTH":return hr.VERTEX_DIRECTION_TYPE_NORTH;case 2:case"VERTEX_DIRECTION_TYPE_NORTH_EAST":return hr.VERTEX_DIRECTION_TYPE_NORTH_EAST;case 3:case"VERTEX_DIRECTION_TYPE_NORTH_WEST":return hr.VERTEX_DIRECTION_TYPE_NORTH_WEST;case 4:case"VERTEX_DIRECTION_TYPE_SOUTH":return hr.VERTEX_DIRECTION_TYPE_SOUTH;case 5:case"VERTEX_DIRECTION_TYPE_SOUTH_EAST":return hr.VERTEX_DIRECTION_TYPE_SOUTH_EAST;case 6:case"VERTEX_DIRECTION_TYPE_SOUTH_WEST":return hr.VERTEX_DIRECTION_TYPE_SOUTH_WEST;default:return hr.UNRECOGNIZED}}E(Ou,"vertexDirectionTypeFromJSON");function Gc(e){switch(e){case hr.VERTEX_DIRECTION_TYPE_UNSPECIFIED:return"VERTEX_DIRECTION_TYPE_UNSPECIFIED";case hr.VERTEX_DIRECTION_TYPE_NORTH:return"VERTEX_DIRECTION_TYPE_NORTH";case hr.VERTEX_DIRECTION_TYPE_NORTH_EAST:return"VERTEX_DIRECTION_TYPE_NORTH_EAST";case hr.VERTEX_DIRECTION_TYPE_NORTH_WEST:return"VERTEX_DIRECTION_TYPE_NORTH_WEST";case hr.VERTEX_DIRECTION_TYPE_SOUTH:return"VERTEX_DIRECTION_TYPE_SOUTH";case hr.VERTEX_DIRECTION_TYPE_SOUTH_EAST:return"VERTEX_DIRECTION_TYPE_SOUTH_EAST";case hr.VERTEX_DIRECTION_TYPE_SOUTH_WEST:return"VERTEX_DIRECTION_TYPE_SOUTH_WEST";case hr.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Gc,"vertexDirectionTypeToJSON");function fC(){return{x:0,y:0,z:0}}E(fC,"createBaseHexPointProto");var Ae={encode(e,r=new ps){return e.x!==0&&r.uint32(8).sint32(e.x),e.y!==0&&r.uint32(16).sint32(e.y),e.z!==0&&r.uint32(24).sint32(e.z),r},decode(e,r){let t=e instanceof Pt?e:new Pt(e),o=r===void 0?t.len:t.pos+r,i=fC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.x=t.sint32();continue}case 2:{if(n!==16)break;i.y=t.sint32();continue}case 3:{if(n!==24)break;i.z=t.sint32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{x:Jr(e.x)?globalThis.Number(e.x):0,y:Jr(e.y)?globalThis.Number(e.y):0,z:Jr(e.z)?globalThis.Number(e.z):0}},toJSON(e){let r={};return e.x!==0&&(r.x=Math.round(e.x)),e.y!==0&&(r.y=Math.round(e.y)),e.z!==0&&(r.z=Math.round(e.z)),r},create(e){return Ae.fromPartial(e??{})},fromPartial(e){let r=fC();return r.x=e.x??0,r.y=e.y??0,r.z=e.z??0,r}};function TC(){return{x:0,y:0,z:0}}E(TC,"createBaseVertexPointProto");var _e={encode(e,r=new ps){return e.x!==0&&r.uint32(8).sint32(e.x),e.y!==0&&r.uint32(16).sint32(e.y),e.z!==0&&r.uint32(24).sint32(e.z),r},decode(e,r){let t=e instanceof Pt?e:new Pt(e),o=r===void 0?t.len:t.pos+r,i=TC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.x=t.sint32();continue}case 2:{if(n!==16)break;i.y=t.sint32();continue}case 3:{if(n!==24)break;i.z=t.sint32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{x:Jr(e.x)?globalThis.Number(e.x):0,y:Jr(e.y)?globalThis.Number(e.y):0,z:Jr(e.z)?globalThis.Number(e.z):0}},toJSON(e){let r={};return e.x!==0&&(r.x=Math.round(e.x)),e.y!==0&&(r.y=Math.round(e.y)),e.z!==0&&(r.z=Math.round(e.z)),r},create(e){return _e.fromPartial(e??{})},fromPartial(e){let r=TC();return r.x=e.x??0,r.y=e.y??0,r.z=e.z??0,r}};function NC(){return{vertex:void 0,direction:0}}E(NC,"createBaseEdgePointProto");var rr={encode(e,r=new ps){return e.vertex!==void 0&&_e.encode(e.vertex,r.uint32(10).fork()).join(),e.direction!==0&&r.uint32(16).int32(e.direction),r},decode(e,r){let t=e instanceof Pt?e:new Pt(e),o=r===void 0?t.len:t.pos+r,i=NC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.vertex=_e.decode(t,t.uint32());continue}case 2:{if(n!==16)break;i.direction=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{vertex:Jr(e.vertex)?_e.fromJSON(e.vertex):void 0,direction:Jr(e.direction)?Ou(e.direction):0}},toJSON(e){let r={};return e.vertex!==void 0&&(r.vertex=_e.toJSON(e.vertex)),e.direction!==0&&(r.direction=Gc(e.direction)),r},create(e){return rr.fromPartial(e??{})},fromPartial(e){let r=NC();return r.vertex=e.vertex!==void 0&&e.vertex!==null?_e.fromPartial(e.vertex):void 0,r.direction=e.direction??0,r}};function RC(){return{commodity:0,count:0}}E(RC,"createBaseCommodityCount");var be={encode(e,r=new ps){return e.commodity!==0&&r.uint32(8).int32(e.commodity),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof Pt?e:new Pt(e),o=r===void 0?t.len:t.pos+r,i=RC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.commodity=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{commodity:Jr(e.commodity)?Is(e.commodity):0,count:Jr(e.count)?globalThis.Number(e.count):0}},toJSON(e){let r={};return e.commodity!==0&&(r.commodity=Cs(e.commodity)),e.count!==0&&(r.count=Math.round(e.count)),r},create(e){return be.fromPartial(e??{})},fromPartial(e){let r=RC();return r.commodity=e.commodity??0,r.count=e.count??0,r}};function AC(){return{fish:0,count:0}}E(AC,"createBaseFishCount");var Bt={encode(e,r=new ps){return e.fish!==0&&r.uint32(8).int32(e.fish),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof Pt?e:new Pt(e),o=r===void 0?t.len:t.pos+r,i=AC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.fish=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{fish:Jr(e.fish)?CI(e.fish):0,count:Jr(e.count)?globalThis.Number(e.count):0}},toJSON(e){let r={};return e.fish!==0&&(r.fish=PI(e.fish)),e.count!==0&&(r.count=Math.round(e.count)),r},create(e){return Bt.fromPartial(e??{})},fromPartial(e){let r=AC();return r.fish=e.fish??0,r.count=e.count??0,r}};function SC(){return{resource:0,count:0}}E(SC,"createBaseResourceCount");var qe={encode(e,r=new ps){return e.resource!==0&&r.uint32(8).int32(e.resource),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof Pt?e:new Pt(e),o=r===void 0?t.len:t.pos+r,i=SC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.resource=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{resource:Jr(e.resource)?$t(e.resource):0,count:Jr(e.count)?globalThis.Number(e.count):0}},toJSON(e){let r={};return e.resource!==0&&(r.resource=Qt(e.resource)),e.count!==0&&(r.count=Math.round(e.count)),r},create(e){return qe.fromPartial(e??{})},fromPartial(e){let r=SC();return r.resource=e.resource??0,r.count=e.count??0,r}};function Jr(e){return e!=null}E(Jr,"isSet");import{BinaryReader as iZ,BinaryWriter as oZ}from"@bufbuild/protobuf/wire";import{BinaryReader as Iu,BinaryWriter as LC}from"@bufbuild/protobuf/wire";function gC(){return{opponent:0,resource:0}}E(gC,"createBaseCommercialHarborTradeProto");var gn={encode(e,r=new LC){return e.opponent!==0&&r.uint32(8).int32(e.opponent),e.resource!==0&&r.uint32(16).int32(e.resource),r},decode(e,r){let t=e instanceof Iu?e:new Iu(e),o=r===void 0?t.len:t.pos+r,i=gC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.opponent=t.int32();continue}case 2:{if(n!==16)break;i.resource=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{opponent:qn(e.opponent)?Ke(e.opponent):0,resource:qn(e.resource)?$t(e.resource):0}},toJSON(e){let r={};return e.opponent!==0&&(r.opponent=_r(e.opponent)),e.resource!==0&&(r.resource=Qt(e.resource)),r},create(e){return gn.fromPartial(e??{})},fromPartial(e){let r=gC();return r.opponent=e.opponent??0,r.resource=e.resource??0,r}};function yC(){return{offering:[],requesting:[],offeringCommodities:[],requestingCommodities:[],offeringGold:0,requestingGold:0,tradeId:0}}E(yC,"createBaseTradeProposalProto");var yn={encode(e,r=new LC){for(let t of e.offering)qe.encode(t,r.uint32(10).fork()).join();for(let t of e.requesting)qe.encode(t,r.uint32(18).fork()).join();for(let t of e.offeringCommodities)be.encode(t,r.uint32(26).fork()).join();for(let t of e.requestingCommodities)be.encode(t,r.uint32(34).fork()).join();return e.offeringGold!==0&&r.uint32(40).int32(e.offeringGold),e.requestingGold!==0&&r.uint32(48).int32(e.requestingGold),e.tradeId!==0&&r.uint32(56).int32(e.tradeId),r},decode(e,r){let t=e instanceof Iu?e:new Iu(e),o=r===void 0?t.len:t.pos+r,i=yC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.offering.push(qe.decode(t,t.uint32()));continue}case 2:{if(n!==18)break;i.requesting.push(qe.decode(t,t.uint32()));continue}case 3:{if(n!==26)break;i.offeringCommodities.push(be.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.requestingCommodities.push(be.decode(t,t.uint32()));continue}case 5:{if(n!==40)break;i.offeringGold=t.int32();continue}case 6:{if(n!==48)break;i.requestingGold=t.int32();continue}case 7:{if(n!==56)break;i.tradeId=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{offering:globalThis.Array.isArray(e?.offering)?e.offering.map(r=>qe.fromJSON(r)):[],requesting:globalThis.Array.isArray(e?.requesting)?e.requesting.map(r=>qe.fromJSON(r)):[],offeringCommodities:globalThis.Array.isArray(e?.offeringCommodities)?e.offeringCommodities.map(r=>be.fromJSON(r)):globalThis.Array.isArray(e?.offering_commodities)?e.offering_commodities.map(r=>be.fromJSON(r)):[],requestingCommodities:globalThis.Array.isArray(e?.requestingCommodities)?e.requestingCommodities.map(r=>be.fromJSON(r)):globalThis.Array.isArray(e?.requesting_commodities)?e.requesting_commodities.map(r=>be.fromJSON(r)):[],offeringGold:qn(e.offeringGold)?globalThis.Number(e.offeringGold):qn(e.offering_gold)?globalThis.Number(e.offering_gold):0,requestingGold:qn(e.requestingGold)?globalThis.Number(e.requestingGold):qn(e.requesting_gold)?globalThis.Number(e.requesting_gold):0,tradeId:qn(e.tradeId)?globalThis.Number(e.tradeId):qn(e.trade_id)?globalThis.Number(e.trade_id):0}},toJSON(e){let r={};return e.offering?.length&&(r.offering=e.offering.map(t=>qe.toJSON(t))),e.requesting?.length&&(r.requesting=e.requesting.map(t=>qe.toJSON(t))),e.offeringCommodities?.length&&(r.offeringCommodities=e.offeringCommodities.map(t=>be.toJSON(t))),e.requestingCommodities?.length&&(r.requestingCommodities=e.requestingCommodities.map(t=>be.toJSON(t))),e.offeringGold!==0&&(r.offeringGold=Math.round(e.offeringGold)),e.requestingGold!==0&&(r.requestingGold=Math.round(e.requestingGold)),e.tradeId!==0&&(r.tradeId=Math.round(e.tradeId)),r},create(e){return yn.fromPartial(e??{})},fromPartial(e){let r=yC();return r.offering=e.offering?.map(t=>qe.fromPartial(t))||[],r.requesting=e.requesting?.map(t=>qe.fromPartial(t))||[],r.offeringCommodities=e.offeringCommodities?.map(t=>be.fromPartial(t))||[],r.requestingCommodities=e.requestingCommodities?.map(t=>be.fromPartial(t))||[],r.offeringGold=e.offeringGold??0,r.requestingGold=e.requestingGold??0,r.tradeId=e.tradeId??0,r}};function qn(e){return e!=null}E(qn,"isSet");import{BinaryReader as v9,BinaryWriter as Y9}from"@bufbuild/protobuf/wire";var GC;(function(e){e[e.TIMER_MODE_UNSPECIFIED=0]="TIMER_MODE_UNSPECIFIED",e[e.TIMER_MODE_NONE=1]="TIMER_MODE_NONE",e[e.TIMER_MODE_CHESS_CLOCK=2]="TIMER_MODE_CHESS_CLOCK",e[e.TIMER_MODE_LEGACY=3]="TIMER_MODE_LEGACY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(GC||(GC={}));var UC;(function(e){e[e.GAME_SPEED_MODE_UNSPECIFIED=0]="GAME_SPEED_MODE_UNSPECIFIED",e[e.GAME_SPEED_MODE_NONE=1]="GAME_SPEED_MODE_NONE",e[e.GAME_SPEED_MODE_BULLET=2]="GAME_SPEED_MODE_BULLET",e[e.GAME_SPEED_MODE_BLITZ=3]="GAME_SPEED_MODE_BLITZ",e[e.GAME_SPEED_MODE_RAPID=4]="GAME_SPEED_MODE_RAPID",e[e.GAME_SPEED_MODE_CLASSIC=5]="GAME_SPEED_MODE_CLASSIC",e[e.GAME_SPEED_MODE_RELAXED=6]="GAME_SPEED_MODE_RELAXED",e[e.GAME_SPEED_MODE_ULTRA_BULLET=7]="GAME_SPEED_MODE_ULTRA_BULLET",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(UC||(UC={}));var BC;(function(e){e[e.ACTION_SOURCE_UNSPECIFIED=0]="ACTION_SOURCE_UNSPECIFIED",e[e.ACTION_SOURCE_PLAYER=1]="ACTION_SOURCE_PLAYER",e[e.ACTION_SOURCE_TIMEOUT_BOT=2]="ACTION_SOURCE_TIMEOUT_BOT",e[e.ACTION_SOURCE_TAKEOVER_BOT=3]="ACTION_SOURCE_TAKEOVER_BOT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(BC||(BC={}));var kC;(function(e){e[e.TIMEOUT_ACTION_UNSPECIFIED=0]="TIMEOUT_ACTION_UNSPECIFIED",e[e.TIMEOUT_ACTION_DICE_ROLL=1]="TIMEOUT_ACTION_DICE_ROLL",e[e.TIMEOUT_ACTION_DISCARD=2]="TIMEOUT_ACTION_DISCARD",e[e.TIMEOUT_ACTION_ROBBER_PLACEMENT=3]="TIMEOUT_ACTION_ROBBER_PLACEMENT",e[e.TIMEOUT_ACTION_ROBBER_STEAL=4]="TIMEOUT_ACTION_ROBBER_STEAL",e[e.TIMEOUT_ACTION_SELECT_RESOURCES=5]="TIMEOUT_ACTION_SELECT_RESOURCES",e[e.TIMEOUT_ACTION_SETUP_SETTLEMENT=6]="TIMEOUT_ACTION_SETUP_SETTLEMENT",e[e.TIMEOUT_ACTION_SETUP_ROAD=7]="TIMEOUT_ACTION_SETUP_ROAD",e[e.TIMEOUT_ACTION_FREE_ROAD=8]="TIMEOUT_ACTION_FREE_ROAD",e[e.TIMEOUT_ACTION_END_TURN=9]="TIMEOUT_ACTION_END_TURN",e[e.TIMEOUT_ACTION_MOVE_KNIGHT=10]="TIMEOUT_ACTION_MOVE_KNIGHT",e[e.TIMEOUT_ACTION_PLACE_WALL=11]="TIMEOUT_ACTION_PLACE_WALL",e[e.TIMEOUT_ACTION_PROMOTE_KNIGHT=12]="TIMEOUT_ACTION_PROMOTE_KNIGHT",e[e.TIMEOUT_ACTION_DESTROY_CITY=13]="TIMEOUT_ACTION_DESTROY_CITY",e[e.TIMEOUT_ACTION_SELECT_DEFENDER=14]="TIMEOUT_ACTION_SELECT_DEFENDER",e[e.TIMEOUT_ACTION_WEDDING_CARDS=15]="TIMEOUT_ACTION_WEDDING_CARDS",e[e.TIMEOUT_ACTION_COMMERCIAL_HARBOR=16]="TIMEOUT_ACTION_COMMERCIAL_HARBOR",e[e.TIMEOUT_ACTION_KNIGHT_COMMITMENT=20]="TIMEOUT_ACTION_KNIGHT_COMMITMENT",e[e.TIMEOUT_ACTION_DESERTER_KNIGHT=21]="TIMEOUT_ACTION_DESERTER_KNIGHT",e[e.TIMEOUT_ACTION_METROPOLIS_PLACEMENT=22]="TIMEOUT_ACTION_METROPOLIS_PLACEMENT",e[e.TIMEOUT_ACTION_DISCARD_PROGRESS_CARDS=23]="TIMEOUT_ACTION_DISCARD_PROGRESS_CARDS",e[e.TIMEOUT_ACTION_GOOD_NEIGHBORS=24]="TIMEOUT_ACTION_GOOD_NEIGHBORS",e[e.TIMEOUT_ACTION_HELPFUL_NEIGHBORS=25]="TIMEOUT_ACTION_HELPFUL_NEIGHBORS",e[e.TIMEOUT_ACTION_EVENT_CARD_STEAL=26]="TIMEOUT_ACTION_EVENT_CARD_STEAL",e[e.TIMEOUT_ACTION_EARTHQUAKE=27]="TIMEOUT_ACTION_EARTHQUAKE",e[e.TIMEOUT_ACTION_WAGON_VOTING=28]="TIMEOUT_ACTION_WAGON_VOTING",e[e.TIMEOUT_ACTION_TRADE_RESPONSE=17]="TIMEOUT_ACTION_TRADE_RESPONSE",e[e.TIMEOUT_ACTION_DEVELOPMENT_CARD=18]="TIMEOUT_ACTION_DEVELOPMENT_CARD",e[e.TIMEOUT_ACTION_BUILD_ACTION=19]="TIMEOUT_ACTION_BUILD_ACTION",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(kC||(kC={}));var bC;(function(e){e[e.GAME_EVENT_TYPE_UNSPECIFIED=0]="GAME_EVENT_TYPE_UNSPECIFIED",e[e.GAME_EVENT_TYPE_ROLL_DICE=1]="GAME_EVENT_TYPE_ROLL_DICE",e[e.GAME_EVENT_TYPE_RECEIVE_RESOURCES=2]="GAME_EVENT_TYPE_RECEIVE_RESOURCES",e[e.GAME_EVENT_TYPE_DISCARD_RESOURCES=3]="GAME_EVENT_TYPE_DISCARD_RESOURCES",e[e.GAME_EVENT_TYPE_MOVE_ROBBER=4]="GAME_EVENT_TYPE_MOVE_ROBBER",e[e.GAME_EVENT_TYPE_STEAL_RESOURCE=5]="GAME_EVENT_TYPE_STEAL_RESOURCE",e[e.GAME_EVENT_TYPE_BUILD_ROAD=6]="GAME_EVENT_TYPE_BUILD_ROAD",e[e.GAME_EVENT_TYPE_BUILD_SETTLEMENT=7]="GAME_EVENT_TYPE_BUILD_SETTLEMENT",e[e.GAME_EVENT_TYPE_BUILD_CITY=8]="GAME_EVENT_TYPE_BUILD_CITY",e[e.GAME_EVENT_TYPE_BUILD_SHIP=9]="GAME_EVENT_TYPE_BUILD_SHIP",e[e.GAME_EVENT_TYPE_BUY_DEV_CARD=10]="GAME_EVENT_TYPE_BUY_DEV_CARD",e[e.GAME_EVENT_TYPE_PLAY_KNIGHT=11]="GAME_EVENT_TYPE_PLAY_KNIGHT",e[e.GAME_EVENT_TYPE_PLAY_ROAD_BUILDING=12]="GAME_EVENT_TYPE_PLAY_ROAD_BUILDING",e[e.GAME_EVENT_TYPE_PLAY_YEAR_OF_PLENTY=13]="GAME_EVENT_TYPE_PLAY_YEAR_OF_PLENTY",e[e.GAME_EVENT_TYPE_PLAY_MONOPOLY=14]="GAME_EVENT_TYPE_PLAY_MONOPOLY",e[e.GAME_EVENT_TYPE_PLAY_VICTORY_POINT=15]="GAME_EVENT_TYPE_PLAY_VICTORY_POINT",e[e.GAME_EVENT_TYPE_TRADE_WITH_PLAYER=16]="GAME_EVENT_TYPE_TRADE_WITH_PLAYER",e[e.GAME_EVENT_TYPE_TRADE_WITH_BANK=17]="GAME_EVENT_TYPE_TRADE_WITH_BANK",e[e.GAME_EVENT_TYPE_END_TURN=18]="GAME_EVENT_TYPE_END_TURN",e[e.GAME_EVENT_TYPE_PROPOSE_TRADE=19]="GAME_EVENT_TYPE_PROPOSE_TRADE",e[e.GAME_EVENT_TYPE_ACCEPT_TRADE=20]="GAME_EVENT_TYPE_ACCEPT_TRADE",e[e.GAME_EVENT_TYPE_REVOKE_TRADE_ACCEPT=21]="GAME_EVENT_TYPE_REVOKE_TRADE_ACCEPT",e[e.GAME_EVENT_TYPE_REJECT_TRADE=22]="GAME_EVENT_TYPE_REJECT_TRADE",e[e.GAME_EVENT_TYPE_CANCEL_TRADE=23]="GAME_EVENT_TYPE_CANCEL_TRADE",e[e.GAME_EVENT_TYPE_EXECUTE_TRADE=24]="GAME_EVENT_TYPE_EXECUTE_TRADE",e[e.GAME_EVENT_TYPE_SELECT_FREE_RESOURCE=25]="GAME_EVENT_TYPE_SELECT_FREE_RESOURCE",e[e.GAME_EVENT_TYPE_PLACE_FREE_STRUCTURE=26]="GAME_EVENT_TYPE_PLACE_FREE_STRUCTURE",e[e.GAME_EVENT_TYPE_MOVE_SHIP=27]="GAME_EVENT_TYPE_MOVE_SHIP",e[e.GAME_EVENT_TYPE_MOVE_PIRATE=28]="GAME_EVENT_TYPE_MOVE_PIRATE",e[e.GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE=29]="GAME_EVENT_TYPE_STEAL_RESOURCE_PIRATE",e[e.GAME_EVENT_TYPE_BUILD_KNIGHT=31]="GAME_EVENT_TYPE_BUILD_KNIGHT",e[e.GAME_EVENT_TYPE_ACTIVATE_KNIGHT=32]="GAME_EVENT_TYPE_ACTIVATE_KNIGHT",e[e.GAME_EVENT_TYPE_PROMOTE_KNIGHT=33]="GAME_EVENT_TYPE_PROMOTE_KNIGHT",e[e.GAME_EVENT_TYPE_MOVE_KNIGHT=34]="GAME_EVENT_TYPE_MOVE_KNIGHT",e[e.GAME_EVENT_TYPE_DISPLACE_KNIGHT=35]="GAME_EVENT_TYPE_DISPLACE_KNIGHT",e[e.GAME_EVENT_TYPE_CHASE_ROBBER=36]="GAME_EVENT_TYPE_CHASE_ROBBER",e[e.GAME_EVENT_TYPE_BUILD_CITY_WALL=37]="GAME_EVENT_TYPE_BUILD_CITY_WALL",e[e.GAME_EVENT_TYPE_BUILD_CITY_IMPROVEMENT=38]="GAME_EVENT_TYPE_BUILD_CITY_IMPROVEMENT",e[e.GAME_EVENT_TYPE_RECEIVE_COMMODITIES=39]="GAME_EVENT_TYPE_RECEIVE_COMMODITIES",e[e.GAME_EVENT_TYPE_ROLL_EVENT_DIE=40]="GAME_EVENT_TYPE_ROLL_EVENT_DIE",e[e.GAME_EVENT_TYPE_BARBARIAN_ADVANCE=41]="GAME_EVENT_TYPE_BARBARIAN_ADVANCE",e[e.GAME_EVENT_TYPE_BARBARIAN_ATTACK=42]="GAME_EVENT_TYPE_BARBARIAN_ATTACK",e[e.GAME_EVENT_TYPE_CITY_PILLAGED=43]="GAME_EVENT_TYPE_CITY_PILLAGED",e[e.GAME_EVENT_TYPE_DEFENDER_OF_CATAN=44]="GAME_EVENT_TYPE_DEFENDER_OF_CATAN",e[e.GAME_EVENT_TYPE_KNIGHTS_DEACTIVATED=45]="GAME_EVENT_TYPE_KNIGHTS_DEACTIVATED",e[e.GAME_EVENT_TYPE_DRAW_PROGRESS_CARD=46]="GAME_EVENT_TYPE_DRAW_PROGRESS_CARD",e[e.GAME_EVENT_TYPE_PLAY_ALCHEMIST=47]="GAME_EVENT_TYPE_PLAY_ALCHEMIST",e[e.GAME_EVENT_TYPE_PLAY_CRANE=48]="GAME_EVENT_TYPE_PLAY_CRANE",e[e.GAME_EVENT_TYPE_PLAY_DESERTER=49]="GAME_EVENT_TYPE_PLAY_DESERTER",e[e.GAME_EVENT_TYPE_PLAY_INTRIGUE=50]="GAME_EVENT_TYPE_PLAY_INTRIGUE",e[e.GAME_EVENT_TYPE_PLAY_MERCHANT_CARD=51]="GAME_EVENT_TYPE_PLAY_MERCHANT_CARD",e[e.GAME_EVENT_TYPE_PLAY_RESOURCE_MONOPOLY=52]="GAME_EVENT_TYPE_PLAY_RESOURCE_MONOPOLY",e[e.GAME_EVENT_TYPE_PLAY_PROGRESS_ROAD_BUILDING=53]="GAME_EVENT_TYPE_PLAY_PROGRESS_ROAD_BUILDING",e[e.GAME_EVENT_TYPE_PLAY_SMITH=54]="GAME_EVENT_TYPE_PLAY_SMITH",e[e.GAME_EVENT_TYPE_PLAY_SPY=55]="GAME_EVENT_TYPE_PLAY_SPY",e[e.GAME_EVENT_TYPE_PLAY_WARLORD=56]="GAME_EVENT_TYPE_PLAY_WARLORD",e[e.GAME_EVENT_TYPE_PLAY_BISHOP=57]="GAME_EVENT_TYPE_PLAY_BISHOP",e[e.GAME_EVENT_TYPE_METROPOLIS_BUILT=58]="GAME_EVENT_TYPE_METROPOLIS_BUILT",e[e.GAME_EVENT_TYPE_METROPOLIS_TRANSFERRED=59]="GAME_EVENT_TYPE_METROPOLIS_TRANSFERRED",e[e.GAME_EVENT_TYPE_MERCHANT_PLACED=60]="GAME_EVENT_TYPE_MERCHANT_PLACED",e[e.GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT=61]="GAME_EVENT_TYPE_PLAY_MASTER_MERCHANT",e[e.GAME_EVENT_TYPE_MASTER_MERCHANT_REVEAL=62]="GAME_EVENT_TYPE_MASTER_MERCHANT_REVEAL",e[e.GAME_EVENT_TYPE_MASTER_MERCHANT_STEAL=63]="GAME_EVENT_TYPE_MASTER_MERCHANT_STEAL",e[e.GAME_EVENT_TYPE_PLAY_MERCHANT_FLEET=64]="GAME_EVENT_TYPE_PLAY_MERCHANT_FLEET",e[e.GAME_EVENT_TYPE_PLAY_MEDICINE=65]="GAME_EVENT_TYPE_PLAY_MEDICINE",e[e.GAME_EVENT_TYPE_PLAY_TRADE_MONOPOLY=66]="GAME_EVENT_TYPE_PLAY_TRADE_MONOPOLY",e[e.GAME_EVENT_TYPE_PLAY_MINING=69]="GAME_EVENT_TYPE_PLAY_MINING",e[e.GAME_EVENT_TYPE_PLAY_IRRIGATION=70]="GAME_EVENT_TYPE_PLAY_IRRIGATION",e[e.GAME_EVENT_TYPE_AQUEDUCT_TRIGGERED=71]="GAME_EVENT_TYPE_AQUEDUCT_TRIGGERED",e[e.GAME_EVENT_TYPE_PLAY_ENGINEER=72]="GAME_EVENT_TYPE_PLAY_ENGINEER",e[e.GAME_EVENT_TYPE_PLAY_INVENTOR=73]="GAME_EVENT_TYPE_PLAY_INVENTOR",e[e.GAME_EVENT_TYPE_PLAY_DIPLOMAT=74]="GAME_EVENT_TYPE_PLAY_DIPLOMAT",e[e.GAME_EVENT_TYPE_PLAY_SABOTEUR=75]="GAME_EVENT_TYPE_PLAY_SABOTEUR",e[e.GAME_EVENT_TYPE_PLAY_WEDDING=76]="GAME_EVENT_TYPE_PLAY_WEDDING",e[e.GAME_EVENT_TYPE_GIVE_WEDDING_CARDS=77]="GAME_EVENT_TYPE_GIVE_WEDDING_CARDS",e[e.GAME_EVENT_TYPE_PLAY_COMMERCIAL_HARBOR=78]="GAME_EVENT_TYPE_PLAY_COMMERCIAL_HARBOR",e[e.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_EXCHANGE=79]="GAME_EVENT_TYPE_COMMERCIAL_HARBOR_EXCHANGE",e[e.GAME_EVENT_TYPE_RECEIVE_FISH=80]="GAME_EVENT_TYPE_RECEIVE_FISH",e[e.GAME_EVENT_TYPE_PASS_OLD_BOOT=81]="GAME_EVENT_TYPE_PASS_OLD_BOOT",e[e.GAME_EVENT_TYPE_SPEND_FISH=82]="GAME_EVENT_TYPE_SPEND_FISH",e[e.GAME_EVENT_TYPE_EXCHANGE_FISH=105]="GAME_EVENT_TYPE_EXCHANGE_FISH",e[e.GAME_EVENT_TYPE_REVEAL_FOG=83]="GAME_EVENT_TYPE_REVEAL_FOG",e[e.GAME_EVENT_TYPE_COMMERCIAL_HARBOR_TRADE_CANCELLED=84]="GAME_EVENT_TYPE_COMMERCIAL_HARBOR_TRADE_CANCELLED",e[e.GAME_EVENT_TYPE_RESIGN=85]="GAME_EVENT_TYPE_RESIGN",e[e.GAME_EVENT_TYPE_PAUSE=86]="GAME_EVENT_TYPE_PAUSE",e[e.GAME_EVENT_TYPE_UNPAUSE=87]="GAME_EVENT_TYPE_UNPAUSE",e[e.GAME_EVENT_TYPE_AWARD_LARGEST_ARMY=88]="GAME_EVENT_TYPE_AWARD_LARGEST_ARMY",e[e.GAME_EVENT_TYPE_AWARD_LONGEST_ROAD=89]="GAME_EVENT_TYPE_AWARD_LONGEST_ROAD",e[e.GAME_EVENT_TYPE_AWARD_HARBORMASTER=97]="GAME_EVENT_TYPE_AWARD_HARBORMASTER",e[e.GAME_EVENT_TYPE_FREE_RESOURCE_GRANTED=90]="GAME_EVENT_TYPE_FREE_RESOURCE_GRANTED",e[e.GAME_EVENT_TYPE_GAME_WON=91]="GAME_EVENT_TYPE_GAME_WON",e[e.GAME_EVENT_TYPE_GOLD_PRODUCED=92]="GAME_EVENT_TYPE_GOLD_PRODUCED",e[e.GAME_EVENT_TYPE_VOTE_TO_CONTINUE=93]="GAME_EVENT_TYPE_VOTE_TO_CONTINUE",e[e.GAME_EVENT_TYPE_USE_KNIGHT_ERRANT=94]="GAME_EVENT_TYPE_USE_KNIGHT_ERRANT",e[e.GAME_EVENT_TYPE_AWAIT_KNIGHT_COMMITMENT=95]="GAME_EVENT_TYPE_AWAIT_KNIGHT_COMMITMENT",e[e.GAME_EVENT_TYPE_COMMIT_KNIGHTS_TO_DEFENSE=96]="GAME_EVENT_TYPE_COMMIT_KNIGHTS_TO_DEFENSE",e[e.GAME_EVENT_TYPE_NEW_ISLAND_SETTLEMENT=98]="GAME_EVENT_TYPE_NEW_ISLAND_SETTLEMENT",e[e.GAME_EVENT_TYPE_COLLECT_EDGE_VP=99]="GAME_EVENT_TYPE_COLLECT_EDGE_VP",e[e.GAME_EVENT_TYPE_COLLECT_EDGE_DEV_CARD=100]="GAME_EVENT_TYPE_COLLECT_EDGE_DEV_CARD",e[e.GAME_EVENT_TYPE_COLLECT_EDGE_PORT=101]="GAME_EVENT_TYPE_COLLECT_EDGE_PORT",e[e.GAME_EVENT_TYPE_PLACE_PORT=102]="GAME_EVENT_TYPE_PLACE_PORT",e[e.GAME_EVENT_TYPE_START_SECOND_SETTLER_TURN=103]="GAME_EVENT_TYPE_START_SECOND_SETTLER_TURN",e[e.GAME_EVENT_TYPE_END_SECOND_SETTLER_TURN=104]="GAME_EVENT_TYPE_END_SECOND_SETTLER_TURN",e[e.GAME_EVENT_TYPE_ROAD_DAMAGED=106]="GAME_EVENT_TYPE_ROAD_DAMAGED",e[e.GAME_EVENT_TYPE_GIVE_EVENT_CARD_RESOURCE=118]="GAME_EVENT_TYPE_GIVE_EVENT_CARD_RESOURCE",e[e.GAME_EVENT_TYPE_RESOURCE_DISTRIBUTION=107]="GAME_EVENT_TYPE_RESOURCE_DISTRIBUTION",e[e.GAME_EVENT_TYPE_TILES_DESERTIFIED=108]="GAME_EVENT_TYPE_TILES_DESERTIFIED",e[e.GAME_EVENT_TYPE_WAGON_VOTING_STARTED=109]="GAME_EVENT_TYPE_WAGON_VOTING_STARTED",e[e.GAME_EVENT_TYPE_WAGON_VOTE=110]="GAME_EVENT_TYPE_WAGON_VOTE",e[e.GAME_EVENT_TYPE_WAGON_PLACED=111]="GAME_EVENT_TYPE_WAGON_PLACED",e[e.GAME_EVENT_TYPE_WAGONS_EXHAUSTED=112]="GAME_EVENT_TYPE_WAGONS_EXHAUSTED",e[e.GAME_EVENT_TYPE_RECEIVE_GOLD=113]="GAME_EVENT_TYPE_RECEIVE_GOLD",e[e.GAME_EVENT_TYPE_SPEND_GOLD=114]="GAME_EVENT_TYPE_SPEND_GOLD",e[e.GAME_EVENT_TYPE_BUILD_BRIDGE=115]="GAME_EVENT_TYPE_BUILD_BRIDGE",e[e.GAME_EVENT_TYPE_WEALTHIEST_TRADER_CHANGED=116]="GAME_EVENT_TYPE_WEALTHIEST_TRADER_CHANGED",e[e.GAME_EVENT_TYPE_POOREST_TRADER_CHANGED=117]="GAME_EVENT_TYPE_POOREST_TRADER_CHANGED",e[e.GAME_EVENT_TYPE_FEED_TROLL=121]="GAME_EVENT_TYPE_FEED_TROLL",e[e.GAME_EVENT_TYPE_KICK_TROLL=122]="GAME_EVENT_TYPE_KICK_TROLL",e[e.GAME_EVENT_TYPE_TROLL_SPAWNED=123]="GAME_EVENT_TYPE_TROLL_SPAWNED",e[e.GAME_EVENT_TYPE_TROLLS_INVADED=124]="GAME_EVENT_TYPE_TROLLS_INVADED",e[e.GAME_EVENT_TYPE_INITIALIZE_DECKS=125]="GAME_EVENT_TYPE_INITIALIZE_DECKS",e[e.GAME_EVENT_TYPE_SELECT_DESERTER_KNIGHT=126]="GAME_EVENT_TYPE_SELECT_DESERTER_KNIGHT",e[e.GAME_EVENT_TYPE_SELECT_METROPOLIS_CITY=127]="GAME_EVENT_TYPE_SELECT_METROPOLIS_CITY",e[e.GAME_EVENT_TYPE_VOTE_DICE_ROLL=128]="GAME_EVENT_TYPE_VOTE_DICE_ROLL",e[e.GAME_EVENT_TYPE_RUSH_ROUND_START=129]="GAME_EVENT_TYPE_RUSH_ROUND_START",e[e.GAME_EVENT_TYPE_PROPOSE_MULTI_TRADE=130]="GAME_EVENT_TYPE_PROPOSE_MULTI_TRADE",e[e.GAME_EVENT_TYPE_TRADE_EMBARGO=131]="GAME_EVENT_TYPE_TRADE_EMBARGO",e[e.GAME_EVENT_TYPE_DISCARD_PROGRESS_CARD=132]="GAME_EVENT_TYPE_DISCARD_PROGRESS_CARD",e[e.GAME_EVENT_TYPE_FREE_STRUCTURE_GRANTED=133]="GAME_EVENT_TYPE_FREE_STRUCTURE_GRANTED",e[e.GAME_EVENT_TYPE_BUY_PROGRESS_CARD=134]="GAME_EVENT_TYPE_BUY_PROGRESS_CARD",e[e.GAME_EVENT_TYPE_LAZY_ROBBER_RETREAT=135]="GAME_EVENT_TYPE_LAZY_ROBBER_RETREAT",e[e.GAME_EVENT_TYPE_PROGRESS_CARD_DISCARD_REQUIRED=136]="GAME_EVENT_TYPE_PROGRESS_CARD_DISCARD_REQUIRED",e[e.GAME_EVENT_TYPE_BUY_GOLD=137]="GAME_EVENT_TYPE_BUY_GOLD",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(bC||(bC={}));import{BinaryReader as CX,BinaryWriter as PX}from"@bufbuild/protobuf/wire";import{BinaryReader as WZ,BinaryWriter as JZ}from"@bufbuild/protobuf/wire";var L;(function(e){e[e.ACTION_TYPE_UNSPECIFIED=0]="ACTION_TYPE_UNSPECIFIED",e[e.ACTION_TYPE_ROLL_DICE=1]="ACTION_TYPE_ROLL_DICE",e[e.ACTION_TYPE_BUILD_ROAD=2]="ACTION_TYPE_BUILD_ROAD",e[e.ACTION_TYPE_BUILD_SHIP=3]="ACTION_TYPE_BUILD_SHIP",e[e.ACTION_TYPE_BUILD_SETTLEMENT=4]="ACTION_TYPE_BUILD_SETTLEMENT",e[e.ACTION_TYPE_BUILD_CITY=5]="ACTION_TYPE_BUILD_CITY",e[e.ACTION_TYPE_BUY_DEV_CARD=6]="ACTION_TYPE_BUY_DEV_CARD",e[e.ACTION_TYPE_PLAY_KNIGHT=7]="ACTION_TYPE_PLAY_KNIGHT",e[e.ACTION_TYPE_PLAY_ROAD_BUILDING=8]="ACTION_TYPE_PLAY_ROAD_BUILDING",e[e.ACTION_TYPE_PLAY_YEAR_OF_PLENTY=9]="ACTION_TYPE_PLAY_YEAR_OF_PLENTY",e[e.ACTION_TYPE_PLAY_MONOPOLY=10]="ACTION_TYPE_PLAY_MONOPOLY",e[e.ACTION_TYPE_PLAY_VICTORY_POINT=11]="ACTION_TYPE_PLAY_VICTORY_POINT",e[e.ACTION_TYPE_PROPOSE_TRADE=12]="ACTION_TYPE_PROPOSE_TRADE",e[e.ACTION_TYPE_ACCEPT_TRADE=13]="ACTION_TYPE_ACCEPT_TRADE",e[e.ACTION_TYPE_REJECT_TRADE=14]="ACTION_TYPE_REJECT_TRADE",e[e.ACTION_TYPE_CANCEL_TRADE=15]="ACTION_TYPE_CANCEL_TRADE",e[e.ACTION_TYPE_EXECUTE_TRADE=16]="ACTION_TYPE_EXECUTE_TRADE",e[e.ACTION_TYPE_TRADE_WITH_BANK=17]="ACTION_TYPE_TRADE_WITH_BANK",e[e.ACTION_TYPE_END_TURN=18]="ACTION_TYPE_END_TURN",e[e.ACTION_TYPE_DISCARD_RESOURCES=19]="ACTION_TYPE_DISCARD_RESOURCES",e[e.ACTION_TYPE_MOVE_ROBBER=20]="ACTION_TYPE_MOVE_ROBBER",e[e.ACTION_TYPE_STEAL_FROM_PLAYER=21]="ACTION_TYPE_STEAL_FROM_PLAYER",e[e.ACTION_TYPE_SELECT_FREE_RESOURCE=22]="ACTION_TYPE_SELECT_FREE_RESOURCE",e[e.ACTION_TYPE_PLACE_FREE_ROAD=23]="ACTION_TYPE_PLACE_FREE_ROAD",e[e.ACTION_TYPE_PLACE_FREE_SHIP=24]="ACTION_TYPE_PLACE_FREE_SHIP",e[e.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT=25]="ACTION_TYPE_PLACE_INITIAL_SETTLEMENT",e[e.ACTION_TYPE_PLACE_INITIAL_ROAD=26]="ACTION_TYPE_PLACE_INITIAL_ROAD",e[e.ACTION_TYPE_PLACE_INITIAL_SHIP=91]="ACTION_TYPE_PLACE_INITIAL_SHIP",e[e.ACTION_TYPE_MOVE_SHIP=27]="ACTION_TYPE_MOVE_SHIP",e[e.ACTION_TYPE_MOVE_PIRATE=28]="ACTION_TYPE_MOVE_PIRATE",e[e.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE=29]="ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE",e[e.ACTION_TYPE_BUILD_KNIGHT=31]="ACTION_TYPE_BUILD_KNIGHT",e[e.ACTION_TYPE_ACTIVATE_KNIGHT=32]="ACTION_TYPE_ACTIVATE_KNIGHT",e[e.ACTION_TYPE_PROMOTE_KNIGHT=33]="ACTION_TYPE_PROMOTE_KNIGHT",e[e.ACTION_TYPE_MOVE_KNIGHT=34]="ACTION_TYPE_MOVE_KNIGHT",e[e.ACTION_TYPE_DISPLACE_KNIGHT=35]="ACTION_TYPE_DISPLACE_KNIGHT",e[e.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT=36]="ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT",e[e.ACTION_TYPE_BUILD_CITY_WALL=37]="ACTION_TYPE_BUILD_CITY_WALL",e[e.ACTION_TYPE_BUILD_CITY_IMPROVEMENT=38]="ACTION_TYPE_BUILD_CITY_IMPROVEMENT",e[e.ACTION_TYPE_PLAY_ALCHEMIST=39]="ACTION_TYPE_PLAY_ALCHEMIST",e[e.ACTION_TYPE_PLAY_CRANE=40]="ACTION_TYPE_PLAY_CRANE",e[e.ACTION_TYPE_PLAY_DESERTER=41]="ACTION_TYPE_PLAY_DESERTER",e[e.ACTION_TYPE_PLAY_INTRIGUE=42]="ACTION_TYPE_PLAY_INTRIGUE",e[e.ACTION_TYPE_PLAY_MERCHANT=43]="ACTION_TYPE_PLAY_MERCHANT",e[e.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY=44]="ACTION_TYPE_PLAY_RESOURCE_MONOPOLY",e[e.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING=45]="ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING",e[e.ACTION_TYPE_PLAY_SMITH=46]="ACTION_TYPE_PLAY_SMITH",e[e.ACTION_TYPE_PLAY_SPY=47]="ACTION_TYPE_PLAY_SPY",e[e.ACTION_TYPE_PLAY_WARLORD=48]="ACTION_TYPE_PLAY_WARLORD",e[e.ACTION_TYPE_PLAY_BISHOP=49]="ACTION_TYPE_PLAY_BISHOP",e[e.ACTION_TYPE_SELECT_ALCHEMIST_DICE=50]="ACTION_TYPE_SELECT_ALCHEMIST_DICE",e[e.ACTION_TYPE_SELECT_DEFENDER_PROGRESS=51]="ACTION_TYPE_SELECT_DEFENDER_PROGRESS",e[e.ACTION_TYPE_SELECT_CITY_TO_PILLAGE=52]="ACTION_TYPE_SELECT_CITY_TO_PILLAGE",e[e.ACTION_TYPE_COMMERCIAL_HARBOR_TRADE=53]="ACTION_TYPE_COMMERCIAL_HARBOR_TRADE",e[e.ACTION_TYPE_SELECT_SPY_TARGET_CARD=54]="ACTION_TYPE_SELECT_SPY_TARGET_CARD",e[e.ACTION_TYPE_PLAY_MASTER_MERCHANT=55]="ACTION_TYPE_PLAY_MASTER_MERCHANT",e[e.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS=56]="ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS",e[e.ACTION_TYPE_PLAY_MERCHANT_FLEET=57]="ACTION_TYPE_PLAY_MERCHANT_FLEET",e[e.ACTION_TYPE_PLAY_MEDICINE=58]="ACTION_TYPE_PLAY_MEDICINE",e[e.ACTION_TYPE_PLAY_TRADE_MONOPOLY=59]="ACTION_TYPE_PLAY_TRADE_MONOPOLY",e[e.ACTION_TYPE_PLAY_MINING=62]="ACTION_TYPE_PLAY_MINING",e[e.ACTION_TYPE_PLAY_IRRIGATION=63]="ACTION_TYPE_PLAY_IRRIGATION",e[e.ACTION_TYPE_PLAY_ENGINEER=64]="ACTION_TYPE_PLAY_ENGINEER",e[e.ACTION_TYPE_PLAY_INVENTOR=65]="ACTION_TYPE_PLAY_INVENTOR",e[e.ACTION_TYPE_PLAY_DIPLOMAT=66]="ACTION_TYPE_PLAY_DIPLOMAT",e[e.ACTION_TYPE_PLAY_SABOTEUR=67]="ACTION_TYPE_PLAY_SABOTEUR",e[e.ACTION_TYPE_PLAY_WEDDING=68]="ACTION_TYPE_PLAY_WEDDING",e[e.ACTION_TYPE_GIVE_WEDDING_CARDS=69]="ACTION_TYPE_GIVE_WEDDING_CARDS",e[e.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR=70]="ACTION_TYPE_PLAY_COMMERCIAL_HARBOR",e[e.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY=71]="ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY",e[e.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE=72]="ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE",e[e.ACTION_TYPE_PASS_OLD_BOOT=73]="ACTION_TYPE_PASS_OLD_BOOT",e[e.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER=74]="ACTION_TYPE_SPEND_FISH_BANISH_ROBBER",e[e.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE=75]="ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE",e[e.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE=76]="ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE",e[e.ACTION_TYPE_SPEND_FISH_BUILD_ROAD=77]="ACTION_TYPE_SPEND_FISH_BUILD_ROAD",e[e.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD=78]="ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD",e[e.ACTION_TYPE_RESIGN=79]="ACTION_TYPE_RESIGN",e[e.ACTION_TYPE_PAUSE=80]="ACTION_TYPE_PAUSE",e[e.ACTION_TYPE_UNPAUSE=81]="ACTION_TYPE_UNPAUSE",e[e.ACTION_TYPE_VOTE_TO_CONTINUE=82]="ACTION_TYPE_VOTE_TO_CONTINUE",e[e.ACTION_TYPE_USE_KNIGHT_ERRANT=83]="ACTION_TYPE_USE_KNIGHT_ERRANT",e[e.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE=84]="ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE",e[e.ACTION_TYPE_PLACE_PORT=85]="ACTION_TYPE_PLACE_PORT",e[e.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD=86]="ACTION_TYPE_SELECT_EARTHQUAKE_ROAD",e[e.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE=88]="ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE",e[e.ACTION_TYPE_EVENT_CARD_STEAL=89]="ACTION_TYPE_EVENT_CARD_STEAL",e[e.ACTION_TYPE_WAGON_VOTE=90]="ACTION_TYPE_WAGON_VOTE",e[e.ACTION_TYPE_FEED_TROLL=92]="ACTION_TYPE_FEED_TROLL",e[e.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT=93]="ACTION_TYPE_KICK_TROLL_WITH_KNIGHT",e[e.ACTION_TYPE_SELECT_DESERTER_KNIGHT=94]="ACTION_TYPE_SELECT_DESERTER_KNIGHT",e[e.ACTION_TYPE_SELECT_METROPOLIS_CITY=95]="ACTION_TYPE_SELECT_METROPOLIS_CITY",e[e.ACTION_TYPE_VOTE_DICE_ROLL=96]="ACTION_TYPE_VOTE_DICE_ROLL",e[e.ACTION_TYPE_PROPOSE_MULTI_TRADE=97]="ACTION_TYPE_PROPOSE_MULTI_TRADE",e[e.ACTION_TYPE_TOGGLE_TRADE_EMBARGO=98]="ACTION_TYPE_TOGGLE_TRADE_EMBARGO",e[e.ACTION_TYPE_DISCARD_PROGRESS_CARD=99]="ACTION_TYPE_DISCARD_PROGRESS_CARD",e[e.ACTION_TYPE_BUY_PROGRESS_CARD=100]="ACTION_TYPE_BUY_PROGRESS_CARD",e[e.ACTION_TYPE_BUILD_BRIDGE=101]="ACTION_TYPE_BUILD_BRIDGE",e[e.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD=102]="ACTION_TYPE_BUY_RESOURCE_WITH_GOLD",e[e.ACTION_TYPE_BUY_GOLD=103]="ACTION_TYPE_BUY_GOLD",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(L||(L={}));function _y(e){switch(e){case 0:case"ACTION_TYPE_UNSPECIFIED":return L.ACTION_TYPE_UNSPECIFIED;case 1:case"ACTION_TYPE_ROLL_DICE":return L.ACTION_TYPE_ROLL_DICE;case 2:case"ACTION_TYPE_BUILD_ROAD":return L.ACTION_TYPE_BUILD_ROAD;case 3:case"ACTION_TYPE_BUILD_SHIP":return L.ACTION_TYPE_BUILD_SHIP;case 4:case"ACTION_TYPE_BUILD_SETTLEMENT":return L.ACTION_TYPE_BUILD_SETTLEMENT;case 5:case"ACTION_TYPE_BUILD_CITY":return L.ACTION_TYPE_BUILD_CITY;case 6:case"ACTION_TYPE_BUY_DEV_CARD":return L.ACTION_TYPE_BUY_DEV_CARD;case 7:case"ACTION_TYPE_PLAY_KNIGHT":return L.ACTION_TYPE_PLAY_KNIGHT;case 8:case"ACTION_TYPE_PLAY_ROAD_BUILDING":return L.ACTION_TYPE_PLAY_ROAD_BUILDING;case 9:case"ACTION_TYPE_PLAY_YEAR_OF_PLENTY":return L.ACTION_TYPE_PLAY_YEAR_OF_PLENTY;case 10:case"ACTION_TYPE_PLAY_MONOPOLY":return L.ACTION_TYPE_PLAY_MONOPOLY;case 11:case"ACTION_TYPE_PLAY_VICTORY_POINT":return L.ACTION_TYPE_PLAY_VICTORY_POINT;case 12:case"ACTION_TYPE_PROPOSE_TRADE":return L.ACTION_TYPE_PROPOSE_TRADE;case 13:case"ACTION_TYPE_ACCEPT_TRADE":return L.ACTION_TYPE_ACCEPT_TRADE;case 14:case"ACTION_TYPE_REJECT_TRADE":return L.ACTION_TYPE_REJECT_TRADE;case 15:case"ACTION_TYPE_CANCEL_TRADE":return L.ACTION_TYPE_CANCEL_TRADE;case 16:case"ACTION_TYPE_EXECUTE_TRADE":return L.ACTION_TYPE_EXECUTE_TRADE;case 17:case"ACTION_TYPE_TRADE_WITH_BANK":return L.ACTION_TYPE_TRADE_WITH_BANK;case 18:case"ACTION_TYPE_END_TURN":return L.ACTION_TYPE_END_TURN;case 19:case"ACTION_TYPE_DISCARD_RESOURCES":return L.ACTION_TYPE_DISCARD_RESOURCES;case 20:case"ACTION_TYPE_MOVE_ROBBER":return L.ACTION_TYPE_MOVE_ROBBER;case 21:case"ACTION_TYPE_STEAL_FROM_PLAYER":return L.ACTION_TYPE_STEAL_FROM_PLAYER;case 22:case"ACTION_TYPE_SELECT_FREE_RESOURCE":return L.ACTION_TYPE_SELECT_FREE_RESOURCE;case 23:case"ACTION_TYPE_PLACE_FREE_ROAD":return L.ACTION_TYPE_PLACE_FREE_ROAD;case 24:case"ACTION_TYPE_PLACE_FREE_SHIP":return L.ACTION_TYPE_PLACE_FREE_SHIP;case 25:case"ACTION_TYPE_PLACE_INITIAL_SETTLEMENT":return L.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT;case 26:case"ACTION_TYPE_PLACE_INITIAL_ROAD":return L.ACTION_TYPE_PLACE_INITIAL_ROAD;case 91:case"ACTION_TYPE_PLACE_INITIAL_SHIP":return L.ACTION_TYPE_PLACE_INITIAL_SHIP;case 27:case"ACTION_TYPE_MOVE_SHIP":return L.ACTION_TYPE_MOVE_SHIP;case 28:case"ACTION_TYPE_MOVE_PIRATE":return L.ACTION_TYPE_MOVE_PIRATE;case 29:case"ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE":return L.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE;case 31:case"ACTION_TYPE_BUILD_KNIGHT":return L.ACTION_TYPE_BUILD_KNIGHT;case 32:case"ACTION_TYPE_ACTIVATE_KNIGHT":return L.ACTION_TYPE_ACTIVATE_KNIGHT;case 33:case"ACTION_TYPE_PROMOTE_KNIGHT":return L.ACTION_TYPE_PROMOTE_KNIGHT;case 34:case"ACTION_TYPE_MOVE_KNIGHT":return L.ACTION_TYPE_MOVE_KNIGHT;case 35:case"ACTION_TYPE_DISPLACE_KNIGHT":return L.ACTION_TYPE_DISPLACE_KNIGHT;case 36:case"ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT":return L.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT;case 37:case"ACTION_TYPE_BUILD_CITY_WALL":return L.ACTION_TYPE_BUILD_CITY_WALL;case 38:case"ACTION_TYPE_BUILD_CITY_IMPROVEMENT":return L.ACTION_TYPE_BUILD_CITY_IMPROVEMENT;case 39:case"ACTION_TYPE_PLAY_ALCHEMIST":return L.ACTION_TYPE_PLAY_ALCHEMIST;case 40:case"ACTION_TYPE_PLAY_CRANE":return L.ACTION_TYPE_PLAY_CRANE;case 41:case"ACTION_TYPE_PLAY_DESERTER":return L.ACTION_TYPE_PLAY_DESERTER;case 42:case"ACTION_TYPE_PLAY_INTRIGUE":return L.ACTION_TYPE_PLAY_INTRIGUE;case 43:case"ACTION_TYPE_PLAY_MERCHANT":return L.ACTION_TYPE_PLAY_MERCHANT;case 44:case"ACTION_TYPE_PLAY_RESOURCE_MONOPOLY":return L.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY;case 45:case"ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING":return L.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING;case 46:case"ACTION_TYPE_PLAY_SMITH":return L.ACTION_TYPE_PLAY_SMITH;case 47:case"ACTION_TYPE_PLAY_SPY":return L.ACTION_TYPE_PLAY_SPY;case 48:case"ACTION_TYPE_PLAY_WARLORD":return L.ACTION_TYPE_PLAY_WARLORD;case 49:case"ACTION_TYPE_PLAY_BISHOP":return L.ACTION_TYPE_PLAY_BISHOP;case 50:case"ACTION_TYPE_SELECT_ALCHEMIST_DICE":return L.ACTION_TYPE_SELECT_ALCHEMIST_DICE;case 51:case"ACTION_TYPE_SELECT_DEFENDER_PROGRESS":return L.ACTION_TYPE_SELECT_DEFENDER_PROGRESS;case 52:case"ACTION_TYPE_SELECT_CITY_TO_PILLAGE":return L.ACTION_TYPE_SELECT_CITY_TO_PILLAGE;case 53:case"ACTION_TYPE_COMMERCIAL_HARBOR_TRADE":return L.ACTION_TYPE_COMMERCIAL_HARBOR_TRADE;case 54:case"ACTION_TYPE_SELECT_SPY_TARGET_CARD":return L.ACTION_TYPE_SELECT_SPY_TARGET_CARD;case 55:case"ACTION_TYPE_PLAY_MASTER_MERCHANT":return L.ACTION_TYPE_PLAY_MASTER_MERCHANT;case 56:case"ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS":return L.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS;case 57:case"ACTION_TYPE_PLAY_MERCHANT_FLEET":return L.ACTION_TYPE_PLAY_MERCHANT_FLEET;case 58:case"ACTION_TYPE_PLAY_MEDICINE":return L.ACTION_TYPE_PLAY_MEDICINE;case 59:case"ACTION_TYPE_PLAY_TRADE_MONOPOLY":return L.ACTION_TYPE_PLAY_TRADE_MONOPOLY;case 62:case"ACTION_TYPE_PLAY_MINING":return L.ACTION_TYPE_PLAY_MINING;case 63:case"ACTION_TYPE_PLAY_IRRIGATION":return L.ACTION_TYPE_PLAY_IRRIGATION;case 64:case"ACTION_TYPE_PLAY_ENGINEER":return L.ACTION_TYPE_PLAY_ENGINEER;case 65:case"ACTION_TYPE_PLAY_INVENTOR":return L.ACTION_TYPE_PLAY_INVENTOR;case 66:case"ACTION_TYPE_PLAY_DIPLOMAT":return L.ACTION_TYPE_PLAY_DIPLOMAT;case 67:case"ACTION_TYPE_PLAY_SABOTEUR":return L.ACTION_TYPE_PLAY_SABOTEUR;case 68:case"ACTION_TYPE_PLAY_WEDDING":return L.ACTION_TYPE_PLAY_WEDDING;case 69:case"ACTION_TYPE_GIVE_WEDDING_CARDS":return L.ACTION_TYPE_GIVE_WEDDING_CARDS;case 70:case"ACTION_TYPE_PLAY_COMMERCIAL_HARBOR":return L.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR;case 71:case"ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY":return L.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY;case 72:case"ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE":return L.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE;case 73:case"ACTION_TYPE_PASS_OLD_BOOT":return L.ACTION_TYPE_PASS_OLD_BOOT;case 74:case"ACTION_TYPE_SPEND_FISH_BANISH_ROBBER":return L.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER;case 75:case"ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE":return L.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE;case 76:case"ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE":return L.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE;case 77:case"ACTION_TYPE_SPEND_FISH_BUILD_ROAD":return L.ACTION_TYPE_SPEND_FISH_BUILD_ROAD;case 78:case"ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD":return L.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD;case 79:case"ACTION_TYPE_RESIGN":return L.ACTION_TYPE_RESIGN;case 80:case"ACTION_TYPE_PAUSE":return L.ACTION_TYPE_PAUSE;case 81:case"ACTION_TYPE_UNPAUSE":return L.ACTION_TYPE_UNPAUSE;case 82:case"ACTION_TYPE_VOTE_TO_CONTINUE":return L.ACTION_TYPE_VOTE_TO_CONTINUE;case 83:case"ACTION_TYPE_USE_KNIGHT_ERRANT":return L.ACTION_TYPE_USE_KNIGHT_ERRANT;case 84:case"ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE":return L.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE;case 85:case"ACTION_TYPE_PLACE_PORT":return L.ACTION_TYPE_PLACE_PORT;case 86:case"ACTION_TYPE_SELECT_EARTHQUAKE_ROAD":return L.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD;case 88:case"ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE":return L.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE;case 89:case"ACTION_TYPE_EVENT_CARD_STEAL":return L.ACTION_TYPE_EVENT_CARD_STEAL;case 90:case"ACTION_TYPE_WAGON_VOTE":return L.ACTION_TYPE_WAGON_VOTE;case 92:case"ACTION_TYPE_FEED_TROLL":return L.ACTION_TYPE_FEED_TROLL;case 93:case"ACTION_TYPE_KICK_TROLL_WITH_KNIGHT":return L.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT;case 94:case"ACTION_TYPE_SELECT_DESERTER_KNIGHT":return L.ACTION_TYPE_SELECT_DESERTER_KNIGHT;case 95:case"ACTION_TYPE_SELECT_METROPOLIS_CITY":return L.ACTION_TYPE_SELECT_METROPOLIS_CITY;case 96:case"ACTION_TYPE_VOTE_DICE_ROLL":return L.ACTION_TYPE_VOTE_DICE_ROLL;case 97:case"ACTION_TYPE_PROPOSE_MULTI_TRADE":return L.ACTION_TYPE_PROPOSE_MULTI_TRADE;case 98:case"ACTION_TYPE_TOGGLE_TRADE_EMBARGO":return L.ACTION_TYPE_TOGGLE_TRADE_EMBARGO;case 99:case"ACTION_TYPE_DISCARD_PROGRESS_CARD":return L.ACTION_TYPE_DISCARD_PROGRESS_CARD;case 100:case"ACTION_TYPE_BUY_PROGRESS_CARD":return L.ACTION_TYPE_BUY_PROGRESS_CARD;case 101:case"ACTION_TYPE_BUILD_BRIDGE":return L.ACTION_TYPE_BUILD_BRIDGE;case 102:case"ACTION_TYPE_BUY_RESOURCE_WITH_GOLD":return L.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD;case 103:case"ACTION_TYPE_BUY_GOLD":return L.ACTION_TYPE_BUY_GOLD;default:return L.UNRECOGNIZED}}E(_y,"actionTypeFromJSON");function dy(e){switch(e){case L.ACTION_TYPE_UNSPECIFIED:return"ACTION_TYPE_UNSPECIFIED";case L.ACTION_TYPE_ROLL_DICE:return"ACTION_TYPE_ROLL_DICE";case L.ACTION_TYPE_BUILD_ROAD:return"ACTION_TYPE_BUILD_ROAD";case L.ACTION_TYPE_BUILD_SHIP:return"ACTION_TYPE_BUILD_SHIP";case L.ACTION_TYPE_BUILD_SETTLEMENT:return"ACTION_TYPE_BUILD_SETTLEMENT";case L.ACTION_TYPE_BUILD_CITY:return"ACTION_TYPE_BUILD_CITY";case L.ACTION_TYPE_BUY_DEV_CARD:return"ACTION_TYPE_BUY_DEV_CARD";case L.ACTION_TYPE_PLAY_KNIGHT:return"ACTION_TYPE_PLAY_KNIGHT";case L.ACTION_TYPE_PLAY_ROAD_BUILDING:return"ACTION_TYPE_PLAY_ROAD_BUILDING";case L.ACTION_TYPE_PLAY_YEAR_OF_PLENTY:return"ACTION_TYPE_PLAY_YEAR_OF_PLENTY";case L.ACTION_TYPE_PLAY_MONOPOLY:return"ACTION_TYPE_PLAY_MONOPOLY";case L.ACTION_TYPE_PLAY_VICTORY_POINT:return"ACTION_TYPE_PLAY_VICTORY_POINT";case L.ACTION_TYPE_PROPOSE_TRADE:return"ACTION_TYPE_PROPOSE_TRADE";case L.ACTION_TYPE_ACCEPT_TRADE:return"ACTION_TYPE_ACCEPT_TRADE";case L.ACTION_TYPE_REJECT_TRADE:return"ACTION_TYPE_REJECT_TRADE";case L.ACTION_TYPE_CANCEL_TRADE:return"ACTION_TYPE_CANCEL_TRADE";case L.ACTION_TYPE_EXECUTE_TRADE:return"ACTION_TYPE_EXECUTE_TRADE";case L.ACTION_TYPE_TRADE_WITH_BANK:return"ACTION_TYPE_TRADE_WITH_BANK";case L.ACTION_TYPE_END_TURN:return"ACTION_TYPE_END_TURN";case L.ACTION_TYPE_DISCARD_RESOURCES:return"ACTION_TYPE_DISCARD_RESOURCES";case L.ACTION_TYPE_MOVE_ROBBER:return"ACTION_TYPE_MOVE_ROBBER";case L.ACTION_TYPE_STEAL_FROM_PLAYER:return"ACTION_TYPE_STEAL_FROM_PLAYER";case L.ACTION_TYPE_SELECT_FREE_RESOURCE:return"ACTION_TYPE_SELECT_FREE_RESOURCE";case L.ACTION_TYPE_PLACE_FREE_ROAD:return"ACTION_TYPE_PLACE_FREE_ROAD";case L.ACTION_TYPE_PLACE_FREE_SHIP:return"ACTION_TYPE_PLACE_FREE_SHIP";case L.ACTION_TYPE_PLACE_INITIAL_SETTLEMENT:return"ACTION_TYPE_PLACE_INITIAL_SETTLEMENT";case L.ACTION_TYPE_PLACE_INITIAL_ROAD:return"ACTION_TYPE_PLACE_INITIAL_ROAD";case L.ACTION_TYPE_PLACE_INITIAL_SHIP:return"ACTION_TYPE_PLACE_INITIAL_SHIP";case L.ACTION_TYPE_MOVE_SHIP:return"ACTION_TYPE_MOVE_SHIP";case L.ACTION_TYPE_MOVE_PIRATE:return"ACTION_TYPE_MOVE_PIRATE";case L.ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE:return"ACTION_TYPE_STEAL_FROM_PLAYER_PIRATE";case L.ACTION_TYPE_BUILD_KNIGHT:return"ACTION_TYPE_BUILD_KNIGHT";case L.ACTION_TYPE_ACTIVATE_KNIGHT:return"ACTION_TYPE_ACTIVATE_KNIGHT";case L.ACTION_TYPE_PROMOTE_KNIGHT:return"ACTION_TYPE_PROMOTE_KNIGHT";case L.ACTION_TYPE_MOVE_KNIGHT:return"ACTION_TYPE_MOVE_KNIGHT";case L.ACTION_TYPE_DISPLACE_KNIGHT:return"ACTION_TYPE_DISPLACE_KNIGHT";case L.ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT:return"ACTION_TYPE_CHASE_ROBBER_WITH_KNIGHT";case L.ACTION_TYPE_BUILD_CITY_WALL:return"ACTION_TYPE_BUILD_CITY_WALL";case L.ACTION_TYPE_BUILD_CITY_IMPROVEMENT:return"ACTION_TYPE_BUILD_CITY_IMPROVEMENT";case L.ACTION_TYPE_PLAY_ALCHEMIST:return"ACTION_TYPE_PLAY_ALCHEMIST";case L.ACTION_TYPE_PLAY_CRANE:return"ACTION_TYPE_PLAY_CRANE";case L.ACTION_TYPE_PLAY_DESERTER:return"ACTION_TYPE_PLAY_DESERTER";case L.ACTION_TYPE_PLAY_INTRIGUE:return"ACTION_TYPE_PLAY_INTRIGUE";case L.ACTION_TYPE_PLAY_MERCHANT:return"ACTION_TYPE_PLAY_MERCHANT";case L.ACTION_TYPE_PLAY_RESOURCE_MONOPOLY:return"ACTION_TYPE_PLAY_RESOURCE_MONOPOLY";case L.ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING:return"ACTION_TYPE_PLAY_PROGRESS_ROAD_BUILDING";case L.ACTION_TYPE_PLAY_SMITH:return"ACTION_TYPE_PLAY_SMITH";case L.ACTION_TYPE_PLAY_SPY:return"ACTION_TYPE_PLAY_SPY";case L.ACTION_TYPE_PLAY_WARLORD:return"ACTION_TYPE_PLAY_WARLORD";case L.ACTION_TYPE_PLAY_BISHOP:return"ACTION_TYPE_PLAY_BISHOP";case L.ACTION_TYPE_SELECT_ALCHEMIST_DICE:return"ACTION_TYPE_SELECT_ALCHEMIST_DICE";case L.ACTION_TYPE_SELECT_DEFENDER_PROGRESS:return"ACTION_TYPE_SELECT_DEFENDER_PROGRESS";case L.ACTION_TYPE_SELECT_CITY_TO_PILLAGE:return"ACTION_TYPE_SELECT_CITY_TO_PILLAGE";case L.ACTION_TYPE_COMMERCIAL_HARBOR_TRADE:return"ACTION_TYPE_COMMERCIAL_HARBOR_TRADE";case L.ACTION_TYPE_SELECT_SPY_TARGET_CARD:return"ACTION_TYPE_SELECT_SPY_TARGET_CARD";case L.ACTION_TYPE_PLAY_MASTER_MERCHANT:return"ACTION_TYPE_PLAY_MASTER_MERCHANT";case L.ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS:return"ACTION_TYPE_SELECT_MASTER_MERCHANT_CARDS";case L.ACTION_TYPE_PLAY_MERCHANT_FLEET:return"ACTION_TYPE_PLAY_MERCHANT_FLEET";case L.ACTION_TYPE_PLAY_MEDICINE:return"ACTION_TYPE_PLAY_MEDICINE";case L.ACTION_TYPE_PLAY_TRADE_MONOPOLY:return"ACTION_TYPE_PLAY_TRADE_MONOPOLY";case L.ACTION_TYPE_PLAY_MINING:return"ACTION_TYPE_PLAY_MINING";case L.ACTION_TYPE_PLAY_IRRIGATION:return"ACTION_TYPE_PLAY_IRRIGATION";case L.ACTION_TYPE_PLAY_ENGINEER:return"ACTION_TYPE_PLAY_ENGINEER";case L.ACTION_TYPE_PLAY_INVENTOR:return"ACTION_TYPE_PLAY_INVENTOR";case L.ACTION_TYPE_PLAY_DIPLOMAT:return"ACTION_TYPE_PLAY_DIPLOMAT";case L.ACTION_TYPE_PLAY_SABOTEUR:return"ACTION_TYPE_PLAY_SABOTEUR";case L.ACTION_TYPE_PLAY_WEDDING:return"ACTION_TYPE_PLAY_WEDDING";case L.ACTION_TYPE_GIVE_WEDDING_CARDS:return"ACTION_TYPE_GIVE_WEDDING_CARDS";case L.ACTION_TYPE_PLAY_COMMERCIAL_HARBOR:return"ACTION_TYPE_PLAY_COMMERCIAL_HARBOR";case L.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY:return"ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_COMMODITY";case L.ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE:return"ACTION_TYPE_COMMERCIAL_HARBOR_GIVE_RESOURCE";case L.ACTION_TYPE_PASS_OLD_BOOT:return"ACTION_TYPE_PASS_OLD_BOOT";case L.ACTION_TYPE_SPEND_FISH_BANISH_ROBBER:return"ACTION_TYPE_SPEND_FISH_BANISH_ROBBER";case L.ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE:return"ACTION_TYPE_SPEND_FISH_STEAL_RESOURCE";case L.ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE:return"ACTION_TYPE_SPEND_FISH_TAKE_RESOURCE";case L.ACTION_TYPE_SPEND_FISH_BUILD_ROAD:return"ACTION_TYPE_SPEND_FISH_BUILD_ROAD";case L.ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD:return"ACTION_TYPE_SPEND_FISH_DRAW_DEV_CARD";case L.ACTION_TYPE_RESIGN:return"ACTION_TYPE_RESIGN";case L.ACTION_TYPE_PAUSE:return"ACTION_TYPE_PAUSE";case L.ACTION_TYPE_UNPAUSE:return"ACTION_TYPE_UNPAUSE";case L.ACTION_TYPE_VOTE_TO_CONTINUE:return"ACTION_TYPE_VOTE_TO_CONTINUE";case L.ACTION_TYPE_USE_KNIGHT_ERRANT:return"ACTION_TYPE_USE_KNIGHT_ERRANT";case L.ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE:return"ACTION_TYPE_COMMIT_KNIGHTS_TO_DEFENSE";case L.ACTION_TYPE_PLACE_PORT:return"ACTION_TYPE_PLACE_PORT";case L.ACTION_TYPE_SELECT_EARTHQUAKE_ROAD:return"ACTION_TYPE_SELECT_EARTHQUAKE_ROAD";case L.ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE:return"ACTION_TYPE_GIVE_EVENT_CARD_RESOURCE";case L.ACTION_TYPE_EVENT_CARD_STEAL:return"ACTION_TYPE_EVENT_CARD_STEAL";case L.ACTION_TYPE_WAGON_VOTE:return"ACTION_TYPE_WAGON_VOTE";case L.ACTION_TYPE_FEED_TROLL:return"ACTION_TYPE_FEED_TROLL";case L.ACTION_TYPE_KICK_TROLL_WITH_KNIGHT:return"ACTION_TYPE_KICK_TROLL_WITH_KNIGHT";case L.ACTION_TYPE_SELECT_DESERTER_KNIGHT:return"ACTION_TYPE_SELECT_DESERTER_KNIGHT";case L.ACTION_TYPE_SELECT_METROPOLIS_CITY:return"ACTION_TYPE_SELECT_METROPOLIS_CITY";case L.ACTION_TYPE_VOTE_DICE_ROLL:return"ACTION_TYPE_VOTE_DICE_ROLL";case L.ACTION_TYPE_PROPOSE_MULTI_TRADE:return"ACTION_TYPE_PROPOSE_MULTI_TRADE";case L.ACTION_TYPE_TOGGLE_TRADE_EMBARGO:return"ACTION_TYPE_TOGGLE_TRADE_EMBARGO";case L.ACTION_TYPE_DISCARD_PROGRESS_CARD:return"ACTION_TYPE_DISCARD_PROGRESS_CARD";case L.ACTION_TYPE_BUY_PROGRESS_CARD:return"ACTION_TYPE_BUY_PROGRESS_CARD";case L.ACTION_TYPE_BUILD_BRIDGE:return"ACTION_TYPE_BUILD_BRIDGE";case L.ACTION_TYPE_BUY_RESOURCE_WITH_GOLD:return"ACTION_TYPE_BUY_RESOURCE_WITH_GOLD";case L.ACTION_TYPE_BUY_GOLD:return"ACTION_TYPE_BUY_GOLD";case L.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(dy,"actionTypeToJSON");function YC(){return{type:0,player:0,edge:void 0,vertex:void 0,robberLocation:void 0,targetPlayer:0,resource:0,resources:[],offering:[],requesting:[],tradeId:0,tradePartner:0,fromEdge:void 0,toEdge:void 0,pirateLocation:void 0,knightLocation:void 0,knightDestination:void 0,knightTargetHex:void 0,improvementTrack:0,cityWallLocation:void 0,alchemistDie1:0,alchemistDie2:0,merchantLocation:void 0,progressCard:0,spyTargetPlayer:0,spyStolenCard:0,deserterTargetPlayer:0,deserterKnightLocation:void 0,pillageCityLocation:void 0,commodities:[],commodity:0,inventorHex1:void 0,inventorHex2:void 0,commercialHarborTrades:[],committedKnights:[],woolBid:0,wheatBid:0,preferredWagonEdge:void 0,preferredWagonFacing:0,offeringCommodities:[],requestingCommodities:[],offeringGold:0,requestingGold:0,trollHex:void 0,trollFish:[],metropolisCityLocation:void 0,tradeProposals:[],counterTradeId:0}}E(YC,"createBasePlayerActionProto");var ro={encode(e,r=new sy){e.type!==0&&r.uint32(8).int32(e.type),e.player!==0&&r.uint32(16).int32(e.player),e.edge!==void 0&&rr.encode(e.edge,r.uint32(26).fork()).join(),e.vertex!==void 0&&_e.encode(e.vertex,r.uint32(34).fork()).join(),e.robberLocation!==void 0&&Ae.encode(e.robberLocation,r.uint32(42).fork()).join(),e.targetPlayer!==0&&r.uint32(48).int32(e.targetPlayer),e.resource!==0&&r.uint32(56).int32(e.resource);for(let t of e.resources)qe.encode(t,r.uint32(66).fork()).join();for(let t of e.offering)qe.encode(t,r.uint32(74).fork()).join();for(let t of e.requesting)qe.encode(t,r.uint32(82).fork()).join();e.tradeId!==0&&r.uint32(88).int32(e.tradeId),e.tradePartner!==0&&r.uint32(96).int32(e.tradePartner),e.fromEdge!==void 0&&rr.encode(e.fromEdge,r.uint32(106).fork()).join(),e.toEdge!==void 0&&rr.encode(e.toEdge,r.uint32(114).fork()).join(),e.pirateLocation!==void 0&&Ae.encode(e.pirateLocation,r.uint32(122).fork()).join(),e.knightLocation!==void 0&&_e.encode(e.knightLocation,r.uint32(130).fork()).join(),e.knightDestination!==void 0&&_e.encode(e.knightDestination,r.uint32(138).fork()).join(),e.knightTargetHex!==void 0&&Ae.encode(e.knightTargetHex,r.uint32(146).fork()).join(),e.improvementTrack!==0&&r.uint32(152).int32(e.improvementTrack),e.cityWallLocation!==void 0&&_e.encode(e.cityWallLocation,r.uint32(162).fork()).join(),e.alchemistDie1!==0&&r.uint32(168).int32(e.alchemistDie1),e.alchemistDie2!==0&&r.uint32(176).int32(e.alchemistDie2),e.merchantLocation!==void 0&&Ae.encode(e.merchantLocation,r.uint32(186).fork()).join(),e.progressCard!==0&&r.uint32(192).int32(e.progressCard),e.spyTargetPlayer!==0&&r.uint32(200).int32(e.spyTargetPlayer),e.spyStolenCard!==0&&r.uint32(208).int32(e.spyStolenCard),e.deserterTargetPlayer!==0&&r.uint32(256).int32(e.deserterTargetPlayer),e.deserterKnightLocation!==void 0&&_e.encode(e.deserterKnightLocation,r.uint32(362).fork()).join(),e.pillageCityLocation!==void 0&&_e.encode(e.pillageCityLocation,r.uint32(218).fork()).join();for(let t of e.commodities)be.encode(t,r.uint32(226).fork()).join();e.commodity!==0&&r.uint32(232).int32(e.commodity),e.inventorHex1!==void 0&&Ae.encode(e.inventorHex1,r.uint32(242).fork()).join(),e.inventorHex2!==void 0&&Ae.encode(e.inventorHex2,r.uint32(250).fork()).join();for(let t of e.commercialHarborTrades)gn.encode(t,r.uint32(266).fork()).join();for(let t of e.committedKnights)_e.encode(t,r.uint32(274).fork()).join();e.woolBid!==0&&r.uint32(280).int32(e.woolBid),e.wheatBid!==0&&r.uint32(288).int32(e.wheatBid),e.preferredWagonEdge!==void 0&&rr.encode(e.preferredWagonEdge,r.uint32(298).fork()).join(),e.preferredWagonFacing!==0&&r.uint32(304).int32(e.preferredWagonFacing);for(let t of e.offeringCommodities)be.encode(t,r.uint32(314).fork()).join();for(let t of e.requestingCommodities)be.encode(t,r.uint32(322).fork()).join();e.offeringGold!==0&&r.uint32(328).int32(e.offeringGold),e.requestingGold!==0&&r.uint32(336).int32(e.requestingGold),e.trollHex!==void 0&&Ae.encode(e.trollHex,r.uint32(346).fork()).join();for(let t of e.trollFish)Bt.encode(t,r.uint32(354).fork()).join();e.metropolisCityLocation!==void 0&&_e.encode(e.metropolisCityLocation,r.uint32(370).fork()).join();for(let t of e.tradeProposals)yn.encode(t,r.uint32(378).fork()).join();return e.counterTradeId!==0&&r.uint32(384).int32(e.counterTradeId),r},decode(e,r){let t=e instanceof vC?e:new vC(e),o=r===void 0?t.len:t.pos+r,i=YC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.type=t.int32();continue}case 2:{if(n!==16)break;i.player=t.int32();continue}case 3:{if(n!==26)break;i.edge=rr.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.vertex=_e.decode(t,t.uint32());continue}case 5:{if(n!==42)break;i.robberLocation=Ae.decode(t,t.uint32());continue}case 6:{if(n!==48)break;i.targetPlayer=t.int32();continue}case 7:{if(n!==56)break;i.resource=t.int32();continue}case 8:{if(n!==66)break;i.resources.push(qe.decode(t,t.uint32()));continue}case 9:{if(n!==74)break;i.offering.push(qe.decode(t,t.uint32()));continue}case 10:{if(n!==82)break;i.requesting.push(qe.decode(t,t.uint32()));continue}case 11:{if(n!==88)break;i.tradeId=t.int32();continue}case 12:{if(n!==96)break;i.tradePartner=t.int32();continue}case 13:{if(n!==106)break;i.fromEdge=rr.decode(t,t.uint32());continue}case 14:{if(n!==114)break;i.toEdge=rr.decode(t,t.uint32());continue}case 15:{if(n!==122)break;i.pirateLocation=Ae.decode(t,t.uint32());continue}case 16:{if(n!==130)break;i.knightLocation=_e.decode(t,t.uint32());continue}case 17:{if(n!==138)break;i.knightDestination=_e.decode(t,t.uint32());continue}case 18:{if(n!==146)break;i.knightTargetHex=Ae.decode(t,t.uint32());continue}case 19:{if(n!==152)break;i.improvementTrack=t.int32();continue}case 20:{if(n!==162)break;i.cityWallLocation=_e.decode(t,t.uint32());continue}case 21:{if(n!==168)break;i.alchemistDie1=t.int32();continue}case 22:{if(n!==176)break;i.alchemistDie2=t.int32();continue}case 23:{if(n!==186)break;i.merchantLocation=Ae.decode(t,t.uint32());continue}case 24:{if(n!==192)break;i.progressCard=t.int32();continue}case 25:{if(n!==200)break;i.spyTargetPlayer=t.int32();continue}case 26:{if(n!==208)break;i.spyStolenCard=t.int32();continue}case 32:{if(n!==256)break;i.deserterTargetPlayer=t.int32();continue}case 45:{if(n!==362)break;i.deserterKnightLocation=_e.decode(t,t.uint32());continue}case 27:{if(n!==218)break;i.pillageCityLocation=_e.decode(t,t.uint32());continue}case 28:{if(n!==226)break;i.commodities.push(be.decode(t,t.uint32()));continue}case 29:{if(n!==232)break;i.commodity=t.int32();continue}case 30:{if(n!==242)break;i.inventorHex1=Ae.decode(t,t.uint32());continue}case 31:{if(n!==250)break;i.inventorHex2=Ae.decode(t,t.uint32());continue}case 33:{if(n!==266)break;i.commercialHarborTrades.push(gn.decode(t,t.uint32()));continue}case 34:{if(n!==274)break;i.committedKnights.push(_e.decode(t,t.uint32()));continue}case 35:{if(n!==280)break;i.woolBid=t.int32();continue}case 36:{if(n!==288)break;i.wheatBid=t.int32();continue}case 37:{if(n!==298)break;i.preferredWagonEdge=rr.decode(t,t.uint32());continue}case 38:{if(n!==304)break;i.preferredWagonFacing=t.int32();continue}case 39:{if(n!==314)break;i.offeringCommodities.push(be.decode(t,t.uint32()));continue}case 40:{if(n!==322)break;i.requestingCommodities.push(be.decode(t,t.uint32()));continue}case 41:{if(n!==328)break;i.offeringGold=t.int32();continue}case 42:{if(n!==336)break;i.requestingGold=t.int32();continue}case 43:{if(n!==346)break;i.trollHex=Ae.decode(t,t.uint32());continue}case 44:{if(n!==354)break;i.trollFish.push(Bt.decode(t,t.uint32()));continue}case 46:{if(n!==370)break;i.metropolisCityLocation=_e.decode(t,t.uint32());continue}case 47:{if(n!==378)break;i.tradeProposals.push(yn.decode(t,t.uint32()));continue}case 48:{if(n!==384)break;i.counterTradeId=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{type:re(e.type)?_y(e.type):0,player:re(e.player)?Ke(e.player):0,edge:re(e.edge)?rr.fromJSON(e.edge):void 0,vertex:re(e.vertex)?_e.fromJSON(e.vertex):void 0,robberLocation:re(e.robberLocation)?Ae.fromJSON(e.robberLocation):re(e.robber_location)?Ae.fromJSON(e.robber_location):void 0,targetPlayer:re(e.targetPlayer)?Ke(e.targetPlayer):re(e.target_player)?Ke(e.target_player):0,resource:re(e.resource)?$t(e.resource):0,resources:globalThis.Array.isArray(e?.resources)?e.resources.map(r=>qe.fromJSON(r)):[],offering:globalThis.Array.isArray(e?.offering)?e.offering.map(r=>qe.fromJSON(r)):[],requesting:globalThis.Array.isArray(e?.requesting)?e.requesting.map(r=>qe.fromJSON(r)):[],tradeId:re(e.tradeId)?globalThis.Number(e.tradeId):re(e.trade_id)?globalThis.Number(e.trade_id):0,tradePartner:re(e.tradePartner)?Ke(e.tradePartner):re(e.trade_partner)?Ke(e.trade_partner):0,fromEdge:re(e.fromEdge)?rr.fromJSON(e.fromEdge):re(e.from_edge)?rr.fromJSON(e.from_edge):void 0,toEdge:re(e.toEdge)?rr.fromJSON(e.toEdge):re(e.to_edge)?rr.fromJSON(e.to_edge):void 0,pirateLocation:re(e.pirateLocation)?Ae.fromJSON(e.pirateLocation):re(e.pirate_location)?Ae.fromJSON(e.pirate_location):void 0,knightLocation:re(e.knightLocation)?_e.fromJSON(e.knightLocation):re(e.knight_location)?_e.fromJSON(e.knight_location):void 0,knightDestination:re(e.knightDestination)?_e.fromJSON(e.knightDestination):re(e.knight_destination)?_e.fromJSON(e.knight_destination):void 0,knightTargetHex:re(e.knightTargetHex)?Ae.fromJSON(e.knightTargetHex):re(e.knight_target_hex)?Ae.fromJSON(e.knight_target_hex):void 0,improvementTrack:re(e.improvementTrack)?Ps(e.improvementTrack):re(e.improvement_track)?Ps(e.improvement_track):0,cityWallLocation:re(e.cityWallLocation)?_e.fromJSON(e.cityWallLocation):re(e.city_wall_location)?_e.fromJSON(e.city_wall_location):void 0,alchemistDie1:re(e.alchemistDie1)?globalThis.Number(e.alchemistDie1):re(e.alchemist_die1)?globalThis.Number(e.alchemist_die1):0,alchemistDie2:re(e.alchemistDie2)?globalThis.Number(e.alchemistDie2):re(e.alchemist_die2)?globalThis.Number(e.alchemist_die2):0,merchantLocation:re(e.merchantLocation)?Ae.fromJSON(e.merchantLocation):re(e.merchant_location)?Ae.fromJSON(e.merchant_location):void 0,progressCard:re(e.progressCard)?mn(e.progressCard):re(e.progress_card)?mn(e.progress_card):0,spyTargetPlayer:re(e.spyTargetPlayer)?Ke(e.spyTargetPlayer):re(e.spy_target_player)?Ke(e.spy_target_player):0,spyStolenCard:re(e.spyStolenCard)?mn(e.spyStolenCard):re(e.spy_stolen_card)?mn(e.spy_stolen_card):0,deserterTargetPlayer:re(e.deserterTargetPlayer)?Ke(e.deserterTargetPlayer):re(e.deserter_target_player)?Ke(e.deserter_target_player):0,deserterKnightLocation:re(e.deserterKnightLocation)?_e.fromJSON(e.deserterKnightLocation):re(e.deserter_knight_location)?_e.fromJSON(e.deserter_knight_location):void 0,pillageCityLocation:re(e.pillageCityLocation)?_e.fromJSON(e.pillageCityLocation):re(e.pillage_city_location)?_e.fromJSON(e.pillage_city_location):void 0,commodities:globalThis.Array.isArray(e?.commodities)?e.commodities.map(r=>be.fromJSON(r)):[],commodity:re(e.commodity)?Is(e.commodity):0,inventorHex1:re(e.inventorHex1)?Ae.fromJSON(e.inventorHex1):re(e.inventor_hex_1)?Ae.fromJSON(e.inventor_hex_1):void 0,inventorHex2:re(e.inventorHex2)?Ae.fromJSON(e.inventorHex2):re(e.inventor_hex_2)?Ae.fromJSON(e.inventor_hex_2):void 0,commercialHarborTrades:globalThis.Array.isArray(e?.commercialHarborTrades)?e.commercialHarborTrades.map(r=>gn.fromJSON(r)):globalThis.Array.isArray(e?.commercial_harbor_trades)?e.commercial_harbor_trades.map(r=>gn.fromJSON(r)):[],committedKnights:globalThis.Array.isArray(e?.committedKnights)?e.committedKnights.map(r=>_e.fromJSON(r)):globalThis.Array.isArray(e?.committed_knights)?e.committed_knights.map(r=>_e.fromJSON(r)):[],woolBid:re(e.woolBid)?globalThis.Number(e.woolBid):re(e.wool_bid)?globalThis.Number(e.wool_bid):0,wheatBid:re(e.wheatBid)?globalThis.Number(e.wheatBid):re(e.wheat_bid)?globalThis.Number(e.wheat_bid):0,preferredWagonEdge:re(e.preferredWagonEdge)?rr.fromJSON(e.preferredWagonEdge):re(e.preferred_wagon_edge)?rr.fromJSON(e.preferred_wagon_edge):void 0,preferredWagonFacing:re(e.preferredWagonFacing)?Ou(e.preferredWagonFacing):re(e.preferred_wagon_facing)?Ou(e.preferred_wagon_facing):0,offeringCommodities:globalThis.Array.isArray(e?.offeringCommodities)?e.offeringCommodities.map(r=>be.fromJSON(r)):globalThis.Array.isArray(e?.offering_commodities)?e.offering_commodities.map(r=>be.fromJSON(r)):[],requestingCommodities:globalThis.Array.isArray(e?.requestingCommodities)?e.requestingCommodities.map(r=>be.fromJSON(r)):globalThis.Array.isArray(e?.requesting_commodities)?e.requesting_commodities.map(r=>be.fromJSON(r)):[],offeringGold:re(e.offeringGold)?globalThis.Number(e.offeringGold):re(e.offering_gold)?globalThis.Number(e.offering_gold):0,requestingGold:re(e.requestingGold)?globalThis.Number(e.requestingGold):re(e.requesting_gold)?globalThis.Number(e.requesting_gold):0,trollHex:re(e.trollHex)?Ae.fromJSON(e.trollHex):re(e.troll_hex)?Ae.fromJSON(e.troll_hex):void 0,trollFish:globalThis.Array.isArray(e?.trollFish)?e.trollFish.map(r=>Bt.fromJSON(r)):globalThis.Array.isArray(e?.troll_fish)?e.troll_fish.map(r=>Bt.fromJSON(r)):[],metropolisCityLocation:re(e.metropolisCityLocation)?_e.fromJSON(e.metropolisCityLocation):re(e.metropolis_city_location)?_e.fromJSON(e.metropolis_city_location):void 0,tradeProposals:globalThis.Array.isArray(e?.tradeProposals)?e.tradeProposals.map(r=>yn.fromJSON(r)):globalThis.Array.isArray(e?.trade_proposals)?e.trade_proposals.map(r=>yn.fromJSON(r)):[],counterTradeId:re(e.counterTradeId)?globalThis.Number(e.counterTradeId):re(e.counter_trade_id)?globalThis.Number(e.counter_trade_id):0}},toJSON(e){let r={};return e.type!==0&&(r.type=dy(e.type)),e.player!==0&&(r.player=_r(e.player)),e.edge!==void 0&&(r.edge=rr.toJSON(e.edge)),e.vertex!==void 0&&(r.vertex=_e.toJSON(e.vertex)),e.robberLocation!==void 0&&(r.robberLocation=Ae.toJSON(e.robberLocation)),e.targetPlayer!==0&&(r.targetPlayer=_r(e.targetPlayer)),e.resource!==0&&(r.resource=Qt(e.resource)),e.resources?.length&&(r.resources=e.resources.map(t=>qe.toJSON(t))),e.offering?.length&&(r.offering=e.offering.map(t=>qe.toJSON(t))),e.requesting?.length&&(r.requesting=e.requesting.map(t=>qe.toJSON(t))),e.tradeId!==0&&(r.tradeId=Math.round(e.tradeId)),e.tradePartner!==0&&(r.tradePartner=_r(e.tradePartner)),e.fromEdge!==void 0&&(r.fromEdge=rr.toJSON(e.fromEdge)),e.toEdge!==void 0&&(r.toEdge=rr.toJSON(e.toEdge)),e.pirateLocation!==void 0&&(r.pirateLocation=Ae.toJSON(e.pirateLocation)),e.knightLocation!==void 0&&(r.knightLocation=_e.toJSON(e.knightLocation)),e.knightDestination!==void 0&&(r.knightDestination=_e.toJSON(e.knightDestination)),e.knightTargetHex!==void 0&&(r.knightTargetHex=Ae.toJSON(e.knightTargetHex)),e.improvementTrack!==0&&(r.improvementTrack=Z_(e.improvementTrack)),e.cityWallLocation!==void 0&&(r.cityWallLocation=_e.toJSON(e.cityWallLocation)),e.alchemistDie1!==0&&(r.alchemistDie1=Math.round(e.alchemistDie1)),e.alchemistDie2!==0&&(r.alchemistDie2=Math.round(e.alchemistDie2)),e.merchantLocation!==void 0&&(r.merchantLocation=Ae.toJSON(e.merchantLocation)),e.progressCard!==0&&(r.progressCard=ji(e.progressCard)),e.spyTargetPlayer!==0&&(r.spyTargetPlayer=_r(e.spyTargetPlayer)),e.spyStolenCard!==0&&(r.spyStolenCard=ji(e.spyStolenCard)),e.deserterTargetPlayer!==0&&(r.deserterTargetPlayer=_r(e.deserterTargetPlayer)),e.deserterKnightLocation!==void 0&&(r.deserterKnightLocation=_e.toJSON(e.deserterKnightLocation)),e.pillageCityLocation!==void 0&&(r.pillageCityLocation=_e.toJSON(e.pillageCityLocation)),e.commodities?.length&&(r.commodities=e.commodities.map(t=>be.toJSON(t))),e.commodity!==0&&(r.commodity=Cs(e.commodity)),e.inventorHex1!==void 0&&(r.inventorHex1=Ae.toJSON(e.inventorHex1)),e.inventorHex2!==void 0&&(r.inventorHex2=Ae.toJSON(e.inventorHex2)),e.commercialHarborTrades?.length&&(r.commercialHarborTrades=e.commercialHarborTrades.map(t=>gn.toJSON(t))),e.committedKnights?.length&&(r.committedKnights=e.committedKnights.map(t=>_e.toJSON(t))),e.woolBid!==0&&(r.woolBid=Math.round(e.woolBid)),e.wheatBid!==0&&(r.wheatBid=Math.round(e.wheatBid)),e.preferredWagonEdge!==void 0&&(r.preferredWagonEdge=rr.toJSON(e.preferredWagonEdge)),e.preferredWagonFacing!==0&&(r.preferredWagonFacing=Gc(e.preferredWagonFacing)),e.offeringCommodities?.length&&(r.offeringCommodities=e.offeringCommodities.map(t=>be.toJSON(t))),e.requestingCommodities?.length&&(r.requestingCommodities=e.requestingCommodities.map(t=>be.toJSON(t))),e.offeringGold!==0&&(r.offeringGold=Math.round(e.offeringGold)),e.requestingGold!==0&&(r.requestingGold=Math.round(e.requestingGold)),e.trollHex!==void 0&&(r.trollHex=Ae.toJSON(e.trollHex)),e.trollFish?.length&&(r.trollFish=e.trollFish.map(t=>Bt.toJSON(t))),e.metropolisCityLocation!==void 0&&(r.metropolisCityLocation=_e.toJSON(e.metropolisCityLocation)),e.tradeProposals?.length&&(r.tradeProposals=e.tradeProposals.map(t=>yn.toJSON(t))),e.counterTradeId!==0&&(r.counterTradeId=Math.round(e.counterTradeId)),r},create(e){return ro.fromPartial(e??{})},fromPartial(e){let r=YC();return r.type=e.type??0,r.player=e.player??0,r.edge=e.edge!==void 0&&e.edge!==null?rr.fromPartial(e.edge):void 0,r.vertex=e.vertex!==void 0&&e.vertex!==null?_e.fromPartial(e.vertex):void 0,r.robberLocation=e.robberLocation!==void 0&&e.robberLocation!==null?Ae.fromPartial(e.robberLocation):void 0,r.targetPlayer=e.targetPlayer??0,r.resource=e.resource??0,r.resources=e.resources?.map(t=>qe.fromPartial(t))||[],r.offering=e.offering?.map(t=>qe.fromPartial(t))||[],r.requesting=e.requesting?.map(t=>qe.fromPartial(t))||[],r.tradeId=e.tradeId??0,r.tradePartner=e.tradePartner??0,r.fromEdge=e.fromEdge!==void 0&&e.fromEdge!==null?rr.fromPartial(e.fromEdge):void 0,r.toEdge=e.toEdge!==void 0&&e.toEdge!==null?rr.fromPartial(e.toEdge):void 0,r.pirateLocation=e.pirateLocation!==void 0&&e.pirateLocation!==null?Ae.fromPartial(e.pirateLocation):void 0,r.knightLocation=e.knightLocation!==void 0&&e.knightLocation!==null?_e.fromPartial(e.knightLocation):void 0,r.knightDestination=e.knightDestination!==void 0&&e.knightDestination!==null?_e.fromPartial(e.knightDestination):void 0,r.knightTargetHex=e.knightTargetHex!==void 0&&e.knightTargetHex!==null?Ae.fromPartial(e.knightTargetHex):void 0,r.improvementTrack=e.improvementTrack??0,r.cityWallLocation=e.cityWallLocation!==void 0&&e.cityWallLocation!==null?_e.fromPartial(e.cityWallLocation):void 0,r.alchemistDie1=e.alchemistDie1??0,r.alchemistDie2=e.alchemistDie2??0,r.merchantLocation=e.merchantLocation!==void 0&&e.merchantLocation!==null?Ae.fromPartial(e.merchantLocation):void 0,r.progressCard=e.progressCard??0,r.spyTargetPlayer=e.spyTargetPlayer??0,r.spyStolenCard=e.spyStolenCard??0,r.deserterTargetPlayer=e.deserterTargetPlayer??0,r.deserterKnightLocation=e.deserterKnightLocation!==void 0&&e.deserterKnightLocation!==null?_e.fromPartial(e.deserterKnightLocation):void 0,r.pillageCityLocation=e.pillageCityLocation!==void 0&&e.pillageCityLocation!==null?_e.fromPartial(e.pillageCityLocation):void 0,r.commodities=e.commodities?.map(t=>be.fromPartial(t))||[],r.commodity=e.commodity??0,r.inventorHex1=e.inventorHex1!==void 0&&e.inventorHex1!==null?Ae.fromPartial(e.inventorHex1):void 0,r.inventorHex2=e.inventorHex2!==void 0&&e.inventorHex2!==null?Ae.fromPartial(e.inventorHex2):void 0,r.commercialHarborTrades=e.commercialHarborTrades?.map(t=>gn.fromPartial(t))||[],r.committedKnights=e.committedKnights?.map(t=>_e.fromPartial(t))||[],r.woolBid=e.woolBid??0,r.wheatBid=e.wheatBid??0,r.preferredWagonEdge=e.preferredWagonEdge!==void 0&&e.preferredWagonEdge!==null?rr.fromPartial(e.preferredWagonEdge):void 0,r.preferredWagonFacing=e.preferredWagonFacing??0,r.offeringCommodities=e.offeringCommodities?.map(t=>be.fromPartial(t))||[],r.requestingCommodities=e.requestingCommodities?.map(t=>be.fromPartial(t))||[],r.offeringGold=e.offeringGold??0,r.requestingGold=e.requestingGold??0,r.trollHex=e.trollHex!==void 0&&e.trollHex!==null?Ae.fromPartial(e.trollHex):void 0,r.trollFish=e.trollFish?.map(t=>Bt.fromPartial(t))||[],r.metropolisCityLocation=e.metropolisCityLocation!==void 0&&e.metropolisCityLocation!==null?_e.fromPartial(e.metropolisCityLocation):void 0,r.tradeProposals=e.tradeProposals?.map(t=>yn.fromPartial(t))||[],r.counterTradeId=e.counterTradeId??0,r}};function re(e){return e!=null}E(re,"isSet");import{BinaryReader as Cu,BinaryWriter as WC}from"@bufbuild/protobuf/wire";import{BinaryReader as WX,BinaryWriter as JX}from"@bufbuild/protobuf/wire";var FC;(function(e){e[e.CANNED_MSG_UNSPECIFIED=0]="CANNED_MSG_UNSPECIFIED",e[e.CANNED_MSG_UI_CLICK_VP_COUNT=1]="CANNED_MSG_UI_CLICK_VP_COUNT",e[e.CANNED_MSG_UI_CLICK_VP_STATUS=2]="CANNED_MSG_UI_CLICK_VP_STATUS",e[e.CANNED_MSG_UI_CLICK_VP_ABOUT_TO_WIN=3]="CANNED_MSG_UI_CLICK_VP_ABOUT_TO_WIN",e[e.CANNED_MSG_UI_CLICK_VP_SELF_CLOSE=4]="CANNED_MSG_UI_CLICK_VP_SELF_CLOSE",e[e.CANNED_MSG_UI_CLICK_LR_HAS=5]="CANNED_MSG_UI_CLICK_LR_HAS",e[e.CANNED_MSG_UI_CLICK_LR_SELF=6]="CANNED_MSG_UI_CLICK_LR_SELF",e[e.CANNED_MSG_UI_CLICK_LR_DOMINATE=7]="CANNED_MSG_UI_CLICK_LR_DOMINATE",e[e.CANNED_MSG_UI_CLICK_LR_NEEDS_MORE=8]="CANNED_MSG_UI_CLICK_LR_NEEDS_MORE",e[e.CANNED_MSG_UI_CLICK_LA_HAS=9]="CANNED_MSG_UI_CLICK_LA_HAS",e[e.CANNED_MSG_UI_CLICK_LA_SELF=10]="CANNED_MSG_UI_CLICK_LA_SELF",e[e.CANNED_MSG_UI_CLICK_LA_FORMIDABLE=11]="CANNED_MSG_UI_CLICK_LA_FORMIDABLE",e[e.CANNED_MSG_UI_CLICK_RES_COUNT=12]="CANNED_MSG_UI_CLICK_RES_COUNT",e[e.CANNED_MSG_UI_CLICK_RES_COUNT_ONE=13]="CANNED_MSG_UI_CLICK_RES_COUNT_ONE",e[e.CANNED_MSG_UI_CLICK_RES_ROBBER_WARNING=14]="CANNED_MSG_UI_CLICK_RES_ROBBER_WARNING",e[e.CANNED_MSG_UI_CLICK_RES_SELF_SEVEN=15]="CANNED_MSG_UI_CLICK_RES_SELF_SEVEN",e[e.CANNED_MSG_UI_CLICK_RES_WANT_SEVEN=16]="CANNED_MSG_UI_CLICK_RES_WANT_SEVEN",e[e.CANNED_MSG_UI_CLICK_CITY_COUNT=17]="CANNED_MSG_UI_CLICK_CITY_COUNT",e[e.CANNED_MSG_UI_CLICK_CITY_COUNT_ONE=18]="CANNED_MSG_UI_CLICK_CITY_COUNT_ONE",e[e.CANNED_MSG_UI_CLICK_CITY_EMPIRE=19]="CANNED_MSG_UI_CLICK_CITY_EMPIRE",e[e.CANNED_MSG_UI_CLICK_DEV_COUNT=20]="CANNED_MSG_UI_CLICK_DEV_COUNT",e[e.CANNED_MSG_UI_CLICK_DEV_COUNT_ONE=21]="CANNED_MSG_UI_CLICK_DEV_COUNT_ONE",e[e.CANNED_MSG_UI_CLICK_ROAD_LENGTH=22]="CANNED_MSG_UI_CLICK_ROAD_LENGTH",e[e.CANNED_MSG_UI_CLICK_ARMY_SIZE=23]="CANNED_MSG_UI_CLICK_ARMY_SIZE",e[e.CANNED_MSG_UI_CLICK_FISH_COUNT=24]="CANNED_MSG_UI_CLICK_FISH_COUNT",e[e.CANNED_MSG_UI_CLICK_DICE_ROLLED=25]="CANNED_MSG_UI_CLICK_DICE_ROLLED",e[e.CANNED_MSG_UI_CLICK_DICE_SEVEN=26]="CANNED_MSG_UI_CLICK_DICE_SEVEN",e[e.CANNED_MSG_UI_CLICK_DICE_SEVEN_DISCARD=27]="CANNED_MSG_UI_CLICK_DICE_SEVEN_DISCARD",e[e.CANNED_MSG_UI_CLICK_DICE_SNAKE_EYES=28]="CANNED_MSG_UI_CLICK_DICE_SNAKE_EYES",e[e.CANNED_MSG_UI_CLICK_DICE_BOXCARS=29]="CANNED_MSG_UI_CLICK_DICE_BOXCARS",e[e.CANNED_MSG_REACTION_SETTLEMENT_NICE=30]="CANNED_MSG_REACTION_SETTLEMENT_NICE",e[e.CANNED_MSG_REACTION_SETTLEMENT_EXPANDING=31]="CANNED_MSG_REACTION_SETTLEMENT_EXPANDING",e[e.CANNED_MSG_REACTION_SETTLEMENT_SELF=32]="CANNED_MSG_REACTION_SETTLEMENT_SELF",e[e.CANNED_MSG_REACTION_CITY_COMPLETE=33]="CANNED_MSG_REACTION_CITY_COMPLETE",e[e.CANNED_MSG_REACTION_CITY_UPGRADED=34]="CANNED_MSG_REACTION_CITY_UPGRADED",e[e.CANNED_MSG_REACTION_KNIGHT_PLAYED=35]="CANNED_MSG_REACTION_KNIGHT_PLAYED",e[e.CANNED_MSG_REACTION_KNIGHT_SELF=36]="CANNED_MSG_REACTION_KNIGHT_SELF",e[e.CANNED_MSG_REACTION_STOLEN_FROM_ME=37]="CANNED_MSG_REACTION_STOLEN_FROM_ME",e[e.CANNED_MSG_REACTION_ROBBER_TIME=38]="CANNED_MSG_REACTION_ROBBER_TIME",e[e.CANNED_MSG_REACTION_SEVEN_TROUBLE=39]="CANNED_MSG_REACTION_SEVEN_TROUBLE",e[e.CANNED_MSG_REACTION_ROBBER_MERCY=40]="CANNED_MSG_REACTION_ROBBER_MERCY",e[e.CANNED_MSG_REACTION_ROBBER_IM_BEHIND=41]="CANNED_MSG_REACTION_ROBBER_IM_BEHIND",e[e.CANNED_MSG_REACTION_COMMON_ROLL=42]="CANNED_MSG_REACTION_COMMON_ROLL",e[e.CANNED_MSG_REACTION_LR_GAINED=43]="CANNED_MSG_REACTION_LR_GAINED",e[e.CANNED_MSG_REACTION_LR_TAKEN=44]="CANNED_MSG_REACTION_LR_TAKEN",e[e.CANNED_MSG_REACTION_LA_GAINED=45]="CANNED_MSG_REACTION_LA_GAINED",e[e.CANNED_MSG_REACTION_LA_TAKEN=46]="CANNED_MSG_REACTION_LA_TAKEN",e[e.CANNED_MSG_OBSERVE_LEADER=47]="CANNED_MSG_OBSERVE_LEADER",e[e.CANNED_MSG_OBSERVE_SELF_WINNING=48]="CANNED_MSG_OBSERVE_SELF_WINNING",e[e.CANNED_MSG_OBSERVE_STOP_LEADER=49]="CANNED_MSG_OBSERVE_STOP_LEADER",e[e.CANNED_MSG_OBSERVE_DONT_TRADE_LEADER=50]="CANNED_MSG_OBSERVE_DONT_TRADE_LEADER",e[e.CANNED_MSG_OBSERVE_NO_HELP_LEADER=51]="CANNED_MSG_OBSERVE_NO_HELP_LEADER",e[e.CANNED_MSG_OBSERVE_ONE_FROM_WIN=52]="CANNED_MSG_OBSERVE_ONE_FROM_WIN",e[e.CANNED_MSG_OBSERVE_NO_RESOURCES=53]="CANNED_MSG_OBSERVE_NO_RESOURCES",e[e.CANNED_MSG_OBSERVE_NEED_PRODUCTION=54]="CANNED_MSG_OBSERVE_NEED_PRODUCTION",e[e.CANNED_MSG_OBSERVE_RICH=55]="CANNED_MSG_OBSERVE_RICH",e[e.CANNED_MSG_OBSERVE_PLOW_INCOMING=56]="CANNED_MSG_OBSERVE_PLOW_INCOMING",e[e.CANNED_MSG_OBSERVE_BOARD_LOTS_OF=57]="CANNED_MSG_OBSERVE_BOARD_LOTS_OF",e[e.CANNED_MSG_OBSERVE_BOARD_NOT_MUCH=58]="CANNED_MSG_OBSERVE_BOARD_NOT_MUCH",e[e.CANNED_MSG_OBSERVE_BOARD_BALANCED=59]="CANNED_MSG_OBSERVE_BOARD_BALANCED",e[e.CANNED_MSG_OBSERVE_BOARD_INTERESTING=60]="CANNED_MSG_OBSERVE_BOARD_INTERESTING",e[e.CANNED_MSG_OBSERVE_BOARD_ORE_HEAVY=61]="CANNED_MSG_OBSERVE_BOARD_ORE_HEAVY",e[e.CANNED_MSG_OBSERVE_BOARD_WOOD_BRICK=62]="CANNED_MSG_OBSERVE_BOARD_WOOD_BRICK",e[e.CANNED_MSG_SOCIAL_GOOD_LUCK=63]="CANNED_MSG_SOCIAL_GOOD_LUCK",e[e.CANNED_MSG_SOCIAL_GREAT_GAME=64]="CANNED_MSG_SOCIAL_GREAT_GAME",e[e.CANNED_MSG_SOCIAL_ANYONE_TRADE=65]="CANNED_MSG_SOCIAL_ANYONE_TRADE",e[e.CANNED_MSG_SOCIAL_INTENSE=66]="CANNED_MSG_SOCIAL_INTENSE",e[e.CANNED_MSG_SOCIAL_WELL_PLAYED=67]="CANNED_MSG_SOCIAL_WELL_PLAYED",e[e.CANNED_MSG_SOCIAL_GOOD_START=68]="CANNED_MSG_SOCIAL_GOOD_START",e[e.CANNED_MSG_SOCIAL_LONG_GAME=69]="CANNED_MSG_SOCIAL_LONG_GAME",e[e.CANNED_MSG_DICE_HOPE_SEVEN=70]="CANNED_MSG_DICE_HOPE_SEVEN",e[e.CANNED_MSG_DICE_NO_SEVEN=71]="CANNED_MSG_DICE_NO_SEVEN",e[e.CANNED_MSG_DICE_NEED_COMMON=72]="CANNED_MSG_DICE_NEED_COMMON",e[e.CANNED_MSG_DICE_UNLUCKY=73]="CANNED_MSG_DICE_UNLUCKY",e[e.CANNED_MSG_DICE_LUCKY=74]="CANNED_MSG_DICE_LUCKY",e[e.CANNED_MSG_TRADE_HAVE_BRICK=75]="CANNED_MSG_TRADE_HAVE_BRICK",e[e.CANNED_MSG_TRADE_HAVE_WOOD=76]="CANNED_MSG_TRADE_HAVE_WOOD",e[e.CANNED_MSG_TRADE_HAVE_WHEAT=77]="CANNED_MSG_TRADE_HAVE_WHEAT",e[e.CANNED_MSG_TRADE_HAVE_SHEEP=78]="CANNED_MSG_TRADE_HAVE_SHEEP",e[e.CANNED_MSG_TRADE_HAVE_ORE=79]="CANNED_MSG_TRADE_HAVE_ORE",e[e.CANNED_MSG_TRADE_NEED_BRICK=80]="CANNED_MSG_TRADE_NEED_BRICK",e[e.CANNED_MSG_TRADE_NEED_WOOD=81]="CANNED_MSG_TRADE_NEED_WOOD",e[e.CANNED_MSG_TRADE_NEED_WHEAT=82]="CANNED_MSG_TRADE_NEED_WHEAT",e[e.CANNED_MSG_TRADE_NEED_SHEEP=83]="CANNED_MSG_TRADE_NEED_SHEEP",e[e.CANNED_MSG_TRADE_NEED_ORE=84]="CANNED_MSG_TRADE_NEED_ORE",e[e.CANNED_MSG_TRADE_OFFER_BRICK=85]="CANNED_MSG_TRADE_OFFER_BRICK",e[e.CANNED_MSG_TRADE_OFFER_WOOD=86]="CANNED_MSG_TRADE_OFFER_WOOD",e[e.CANNED_MSG_TRADE_OFFER_WHEAT=87]="CANNED_MSG_TRADE_OFFER_WHEAT",e[e.CANNED_MSG_TRADE_OFFER_SHEEP=88]="CANNED_MSG_TRADE_OFFER_SHEEP",e[e.CANNED_MSG_TRADE_OFFER_ORE=89]="CANNED_MSG_TRADE_OFFER_ORE",e[e.CANNED_MSG_TRADE_LOOKING_BRICK=90]="CANNED_MSG_TRADE_LOOKING_BRICK",e[e.CANNED_MSG_TRADE_LOOKING_WOOD=91]="CANNED_MSG_TRADE_LOOKING_WOOD",e[e.CANNED_MSG_TRADE_LOOKING_WHEAT=92]="CANNED_MSG_TRADE_LOOKING_WHEAT",e[e.CANNED_MSG_TRADE_LOOKING_SHEEP=93]="CANNED_MSG_TRADE_LOOKING_SHEEP",e[e.CANNED_MSG_TRADE_LOOKING_ORE=94]="CANNED_MSG_TRADE_LOOKING_ORE",e[e.CANNED_MSG_TRADE_TWO_FOR_ONE=95]="CANNED_MSG_TRADE_TWO_FOR_ONE",e[e.CANNED_MSG_TRADE_FAIR_ONLY=96]="CANNED_MSG_TRADE_FAIR_ONLY",e[e.CANNED_MSG_START_GLHF=97]="CANNED_MSG_START_GLHF",e[e.CANNED_MSG_START_GOOD_LUCK=98]="CANNED_MSG_START_GOOD_LUCK",e[e.CANNED_MSG_START_GREAT_GAME=99]="CANNED_MSG_START_GREAT_GAME",e[e.CANNED_MSG_START_BEST_WIN=100]="CANNED_MSG_START_BEST_WIN",e[e.CANNED_MSG_START_HERE_WE_GO=101]="CANNED_MSG_START_HERE_WE_GO",e[e.CANNED_MSG_END_I_WON=102]="CANNED_MSG_END_I_WON",e[e.CANNED_MSG_END_VICTORY_MINE=103]="CANNED_MSG_END_VICTORY_MINE",e[e.CANNED_MSG_END_WINNER_WELL_PLAYED=104]="CANNED_MSG_END_WINNER_WELL_PLAYED",e[e.CANNED_MSG_END_WINNER_THANKS=105]="CANNED_MSG_END_WINNER_THANKS",e[e.CANNED_MSG_END_CONGRATS_WINNER=106]="CANNED_MSG_END_CONGRATS_WINNER",e[e.CANNED_MSG_END_LOSER_WELL_PLAYED=107]="CANNED_MSG_END_LOSER_WELL_PLAYED",e[e.CANNED_MSG_END_GOOD_GAME=108]="CANNED_MSG_END_GOOD_GAME",e[e.CANNED_MSG_END_NEXT_TIME=109]="CANNED_MSG_END_NEXT_TIME",e[e.CANNED_MSG_MOOD_POSITIVE_SETUP=110]="CANNED_MSG_MOOD_POSITIVE_SETUP",e[e.CANNED_MSG_MOOD_POSITIVE_PRE_ROLL=111]="CANNED_MSG_MOOD_POSITIVE_PRE_ROLL",e[e.CANNED_MSG_MOOD_POSITIVE_POST_ROLL=112]="CANNED_MSG_MOOD_POSITIVE_POST_ROLL",e[e.CANNED_MSG_MOOD_POSITIVE_MAIN=113]="CANNED_MSG_MOOD_POSITIVE_MAIN",e[e.CANNED_MSG_MOOD_POSITIVE_TRADE=114]="CANNED_MSG_MOOD_POSITIVE_TRADE",e[e.CANNED_MSG_MOOD_POSITIVE_ROBBER=115]="CANNED_MSG_MOOD_POSITIVE_ROBBER",e[e.CANNED_MSG_MOOD_NEGATIVE_SETUP=116]="CANNED_MSG_MOOD_NEGATIVE_SETUP",e[e.CANNED_MSG_MOOD_NEGATIVE_PRE_ROLL=117]="CANNED_MSG_MOOD_NEGATIVE_PRE_ROLL",e[e.CANNED_MSG_MOOD_NEGATIVE_POST_ROLL=118]="CANNED_MSG_MOOD_NEGATIVE_POST_ROLL",e[e.CANNED_MSG_MOOD_NEGATIVE_MAIN=119]="CANNED_MSG_MOOD_NEGATIVE_MAIN",e[e.CANNED_MSG_MOOD_NEGATIVE_TRADE=120]="CANNED_MSG_MOOD_NEGATIVE_TRADE",e[e.CANNED_MSG_MOOD_NEGATIVE_ROBBER=121]="CANNED_MSG_MOOD_NEGATIVE_ROBBER",e[e.CANNED_MSG_MOOD_SURPRISED_SETUP=122]="CANNED_MSG_MOOD_SURPRISED_SETUP",e[e.CANNED_MSG_MOOD_SURPRISED_PRE_ROLL=123]="CANNED_MSG_MOOD_SURPRISED_PRE_ROLL",e[e.CANNED_MSG_MOOD_SURPRISED_POST_ROLL=124]="CANNED_MSG_MOOD_SURPRISED_POST_ROLL",e[e.CANNED_MSG_MOOD_SURPRISED_MAIN=125]="CANNED_MSG_MOOD_SURPRISED_MAIN",e[e.CANNED_MSG_MOOD_SURPRISED_TRADE=126]="CANNED_MSG_MOOD_SURPRISED_TRADE",e[e.CANNED_MSG_MOOD_SURPRISED_ROBBER=127]="CANNED_MSG_MOOD_SURPRISED_ROBBER",e[e.CANNED_MSG_MOOD_PLAYFUL_SETUP=128]="CANNED_MSG_MOOD_PLAYFUL_SETUP",e[e.CANNED_MSG_MOOD_PLAYFUL_PRE_ROLL=129]="CANNED_MSG_MOOD_PLAYFUL_PRE_ROLL",e[e.CANNED_MSG_MOOD_PLAYFUL_POST_ROLL=130]="CANNED_MSG_MOOD_PLAYFUL_POST_ROLL",e[e.CANNED_MSG_MOOD_PLAYFUL_MAIN=131]="CANNED_MSG_MOOD_PLAYFUL_MAIN",e[e.CANNED_MSG_MOOD_PLAYFUL_TRADE=132]="CANNED_MSG_MOOD_PLAYFUL_TRADE",e[e.CANNED_MSG_MOOD_PLAYFUL_ROBBER=133]="CANNED_MSG_MOOD_PLAYFUL_ROBBER",e[e.CANNED_MSG_UI_CLICK_KNIGHT_COUNT=134]="CANNED_MSG_UI_CLICK_KNIGHT_COUNT",e[e.CANNED_MSG_UI_CLICK_ACTIVE_KNIGHTS=135]="CANNED_MSG_UI_CLICK_ACTIVE_KNIGHTS",e[e.CANNED_MSG_UI_CLICK_CITY_IMPROVEMENTS=136]="CANNED_MSG_UI_CLICK_CITY_IMPROVEMENTS",e[e.CANNED_MSG_UI_CLICK_METROPOLIS=137]="CANNED_MSG_UI_CLICK_METROPOLIS",e[e.CANNED_MSG_UI_CLICK_BARBARIAN_POSITION=138]="CANNED_MSG_UI_CLICK_BARBARIAN_POSITION",e[e.CANNED_MSG_UI_CLICK_PROGRESS_CARDS=139]="CANNED_MSG_UI_CLICK_PROGRESS_CARDS",e[e.CANNED_MSG_UI_CLICK_COMMODITIES=140]="CANNED_MSG_UI_CLICK_COMMODITIES",e[e.CANNED_MSG_UI_CLICK_SHIPS=141]="CANNED_MSG_UI_CLICK_SHIPS",e[e.CANNED_MSG_UI_CLICK_PIRATE=142]="CANNED_MSG_UI_CLICK_PIRATE",e[e.CANNED_MSG_UI_CLICK_FISH_SAVED=143]="CANNED_MSG_UI_CLICK_FISH_SAVED",e[e.CANNED_MSG_UI_CLICK_OLD_BOOT_HOLDER=144]="CANNED_MSG_UI_CLICK_OLD_BOOT_HOLDER",e[e.CANNED_MSG_UI_CLICK_FISHERY=145]="CANNED_MSG_UI_CLICK_FISHERY",e[e.CANNED_MSG_OBSERVE_CK_WEAK_DEFENSE=146]="CANNED_MSG_OBSERVE_CK_WEAK_DEFENSE",e[e.CANNED_MSG_OBSERVE_CK_STRONG_DEFENSE=147]="CANNED_MSG_OBSERVE_CK_STRONG_DEFENSE",e[e.CANNED_MSG_OBSERVE_CK_BARBARIAN_DANGER=148]="CANNED_MSG_OBSERVE_CK_BARBARIAN_DANGER",e[e.CANNED_MSG_OBSERVE_CK_NEED_ACTIVATE=149]="CANNED_MSG_OBSERVE_CK_NEED_ACTIVATE",e[e.CANNED_MSG_OBSERVE_CK_METROPOLIS_RACE=150]="CANNED_MSG_OBSERVE_CK_METROPOLIS_RACE",e[e.CANNED_MSG_OBSERVE_SF_SEA_CONTROL=151]="CANNED_MSG_OBSERVE_SF_SEA_CONTROL",e[e.CANNED_MSG_OBSERVE_SF_ISLAND_RACE=152]="CANNED_MSG_OBSERVE_SF_ISLAND_RACE",e[e.CANNED_MSG_OBSERVE_FISH_RICH=153]="CANNED_MSG_OBSERVE_FISH_RICH",e[e.CANNED_MSG_OBSERVE_FISH_BOOT_LEADER=154]="CANNED_MSG_OBSERVE_FISH_BOOT_LEADER",e[e.CANNED_MSG_REACTION_CK_LOST_TO_BARBARIANS=155]="CANNED_MSG_REACTION_CK_LOST_TO_BARBARIANS",e[e.CANNED_MSG_REACTION_CK_SAVED_FROM_BARBARIANS=156]="CANNED_MSG_REACTION_CK_SAVED_FROM_BARBARIANS",e[e.CANNED_MSG_REACTION_CK_PROGRESS_STOLEN=157]="CANNED_MSG_REACTION_CK_PROGRESS_STOLEN",e[e.CANNED_MSG_REACTION_SF_SHIP_NETWORK=158]="CANNED_MSG_REACTION_SF_SHIP_NETWORK",e[e.CANNED_MSG_REACTION_FISH_BIG_CATCH=159]="CANNED_MSG_REACTION_FISH_BIG_CATCH",e[e.CANNED_MSG_REACTION_FISH_BOOT_SURPRISE=160]="CANNED_MSG_REACTION_FISH_BOOT_SURPRISE",e[e.CANNED_MSG_TRADE_NEED_FOR_BUILDING=161]="CANNED_MSG_TRADE_NEED_FOR_BUILDING",e[e.CANNED_MSG_TRADE_NEED_FOR_DEV=162]="CANNED_MSG_TRADE_NEED_FOR_DEV",e[e.CANNED_MSG_TRADE_NEED_FOR_CITY=163]="CANNED_MSG_TRADE_NEED_FOR_CITY",e[e.CANNED_MSG_DICE_NO_RESOURCES_ALL_GAME=164]="CANNED_MSG_DICE_NO_RESOURCES_ALL_GAME",e[e.CANNED_MSG_DICE_LUCKY_ROLL=165]="CANNED_MSG_DICE_LUCKY_ROLL",e[e.CANNED_MSG_DICE_NEED_A=166]="CANNED_MSG_DICE_NEED_A",e[e.CANNED_MSG_DICE_NO_SEVEN_PLEASE=167]="CANNED_MSG_DICE_NO_SEVEN_PLEASE",e[e.CANNED_MSG_CK_KNIGHT_ACTIVATED=200]="CANNED_MSG_CK_KNIGHT_ACTIVATED",e[e.CANNED_MSG_CK_KNIGHT_ACTIVATED_OTHER=201]="CANNED_MSG_CK_KNIGHT_ACTIVATED_OTHER",e[e.CANNED_MSG_CK_KNIGHT_PROMOTED=202]="CANNED_MSG_CK_KNIGHT_PROMOTED",e[e.CANNED_MSG_CK_KNIGHT_PROMOTED_OTHER=203]="CANNED_MSG_CK_KNIGHT_PROMOTED_OTHER",e[e.CANNED_MSG_CK_KNIGHT_MOVED=204]="CANNED_MSG_CK_KNIGHT_MOVED",e[e.CANNED_MSG_CK_KNIGHT_DISPLACED=205]="CANNED_MSG_CK_KNIGHT_DISPLACED",e[e.CANNED_MSG_CK_KNIGHT_CHASED_ROBBER=206]="CANNED_MSG_CK_KNIGHT_CHASED_ROBBER",e[e.CANNED_MSG_CK_MIGHTY_KNIGHT=207]="CANNED_MSG_CK_MIGHTY_KNIGHT",e[e.CANNED_MSG_CK_DEFENDING_WITH_KNIGHTS=208]="CANNED_MSG_CK_DEFENDING_WITH_KNIGHTS",e[e.CANNED_MSG_CK_NEED_MORE_KNIGHTS=209]="CANNED_MSG_CK_NEED_MORE_KNIGHTS",e[e.CANNED_MSG_CK_BARBARIANS_APPROACHING=210]="CANNED_MSG_CK_BARBARIANS_APPROACHING",e[e.CANNED_MSG_CK_BARBARIANS_ONE_AWAY=211]="CANNED_MSG_CK_BARBARIANS_ONE_AWAY",e[e.CANNED_MSG_CK_BARBARIANS_DEFEATED=212]="CANNED_MSG_CK_BARBARIANS_DEFEATED",e[e.CANNED_MSG_CK_BARBARIANS_VICTORIOUS=213]="CANNED_MSG_CK_BARBARIANS_VICTORIOUS",e[e.CANNED_MSG_CK_DEFENDER_OF_CATAN=214]="CANNED_MSG_CK_DEFENDER_OF_CATAN",e[e.CANNED_MSG_CK_DEFENDER_OF_CATAN_OTHER=215]="CANNED_MSG_CK_DEFENDER_OF_CATAN_OTHER",e[e.CANNED_MSG_CK_CITY_PILLAGED=216]="CANNED_MSG_CK_CITY_PILLAGED",e[e.CANNED_MSG_CK_CITY_PILLAGED_OTHER=217]="CANNED_MSG_CK_CITY_PILLAGED_OTHER",e[e.CANNED_MSG_CK_BARBARIAN_STRENGTH=218]="CANNED_MSG_CK_BARBARIAN_STRENGTH",e[e.CANNED_MSG_CK_KNIGHT_STRENGTH=219]="CANNED_MSG_CK_KNIGHT_STRENGTH",e[e.CANNED_MSG_CK_BUILT_CITY_WALL=220]="CANNED_MSG_CK_BUILT_CITY_WALL",e[e.CANNED_MSG_CK_BUILT_CITY_WALL_OTHER=221]="CANNED_MSG_CK_BUILT_CITY_WALL_OTHER",e[e.CANNED_MSG_CK_CITY_IMPROVEMENT_TRADE=222]="CANNED_MSG_CK_CITY_IMPROVEMENT_TRADE",e[e.CANNED_MSG_CK_CITY_IMPROVEMENT_POLITICS=223]="CANNED_MSG_CK_CITY_IMPROVEMENT_POLITICS",e[e.CANNED_MSG_CK_CITY_IMPROVEMENT_SCIENCE=224]="CANNED_MSG_CK_CITY_IMPROVEMENT_SCIENCE",e[e.CANNED_MSG_CK_AQUEDUCT_BUILT=225]="CANNED_MSG_CK_AQUEDUCT_BUILT",e[e.CANNED_MSG_CK_FORTRESS_BUILT=226]="CANNED_MSG_CK_FORTRESS_BUILT",e[e.CANNED_MSG_CK_UNIVERSITY_BUILT=227]="CANNED_MSG_CK_UNIVERSITY_BUILT",e[e.CANNED_MSG_CK_METROPOLIS_BUILT=228]="CANNED_MSG_CK_METROPOLIS_BUILT",e[e.CANNED_MSG_CK_METROPOLIS_BUILT_OTHER=229]="CANNED_MSG_CK_METROPOLIS_BUILT_OTHER",e[e.CANNED_MSG_CK_LOST_METROPOLIS=230]="CANNED_MSG_CK_LOST_METROPOLIS",e[e.CANNED_MSG_CK_PROGRESS_CARD_DRAWN=231]="CANNED_MSG_CK_PROGRESS_CARD_DRAWN",e[e.CANNED_MSG_CK_ALCHEMIST_PLAYED=232]="CANNED_MSG_CK_ALCHEMIST_PLAYED",e[e.CANNED_MSG_CK_BISHOP_PLAYED=233]="CANNED_MSG_CK_BISHOP_PLAYED",e[e.CANNED_MSG_CK_COMMERCIAL_HARBOR=234]="CANNED_MSG_CK_COMMERCIAL_HARBOR",e[e.CANNED_MSG_CK_CONSTITUTION_VP=235]="CANNED_MSG_CK_CONSTITUTION_VP",e[e.CANNED_MSG_CK_CRANE_ACTIVE=236]="CANNED_MSG_CK_CRANE_ACTIVE",e[e.CANNED_MSG_CK_DESERTER_PLAYED=237]="CANNED_MSG_CK_DESERTER_PLAYED",e[e.CANNED_MSG_CK_DIPLOMAT_ROAD=238]="CANNED_MSG_CK_DIPLOMAT_ROAD",e[e.CANNED_MSG_CK_ENGINEER_WALL=239]="CANNED_MSG_CK_ENGINEER_WALL",e[e.CANNED_MSG_CK_INTRIGUE_KNIGHT=240]="CANNED_MSG_CK_INTRIGUE_KNIGHT",e[e.CANNED_MSG_CK_INVENTOR_SWAP=241]="CANNED_MSG_CK_INVENTOR_SWAP",e[e.CANNED_MSG_CK_IRRIGATION_GRAIN=242]="CANNED_MSG_CK_IRRIGATION_GRAIN",e[e.CANNED_MSG_CK_MASTER_MERCHANT=243]="CANNED_MSG_CK_MASTER_MERCHANT",e[e.CANNED_MSG_CK_MEDICINE_CITY=244]="CANNED_MSG_CK_MEDICINE_CITY",e[e.CANNED_MSG_CK_MERCHANT_PLACED=245]="CANNED_MSG_CK_MERCHANT_PLACED",e[e.CANNED_MSG_CK_MERCHANT_FLEET=246]="CANNED_MSG_CK_MERCHANT_FLEET",e[e.CANNED_MSG_CK_MINING_ORE=247]="CANNED_MSG_CK_MINING_ORE",e[e.CANNED_MSG_CK_PRINTER_VP=248]="CANNED_MSG_CK_PRINTER_VP",e[e.CANNED_MSG_CK_RESOURCE_MONOPOLY=249]="CANNED_MSG_CK_RESOURCE_MONOPOLY",e[e.CANNED_MSG_CK_ROAD_BUILDING_PROG=250]="CANNED_MSG_CK_ROAD_BUILDING_PROG",e[e.CANNED_MSG_CK_SABOTEUR_DISCARD=251]="CANNED_MSG_CK_SABOTEUR_DISCARD",e[e.CANNED_MSG_CK_SMITH_PROMOTES=252]="CANNED_MSG_CK_SMITH_PROMOTES",e[e.CANNED_MSG_CK_SPY_STEAL_CARD=253]="CANNED_MSG_CK_SPY_STEAL_CARD",e[e.CANNED_MSG_CK_TRADE_MONOPOLY=254]="CANNED_MSG_CK_TRADE_MONOPOLY",e[e.CANNED_MSG_CK_WARLORD_ACTIVATE=255]="CANNED_MSG_CK_WARLORD_ACTIVATE",e[e.CANNED_MSG_CK_WEDDING_GIFTS=256]="CANNED_MSG_CK_WEDDING_GIFTS",e[e.CANNED_MSG_CK_COMMODITY_PAPER=257]="CANNED_MSG_CK_COMMODITY_PAPER",e[e.CANNED_MSG_CK_COMMODITY_CLOTH=258]="CANNED_MSG_CK_COMMODITY_CLOTH",e[e.CANNED_MSG_CK_COMMODITY_COIN=259]="CANNED_MSG_CK_COMMODITY_COIN",e[e.CANNED_MSG_CK_NEED_COMMODITIES=260]="CANNED_MSG_CK_NEED_COMMODITIES",e[e.CANNED_MSG_CK_TRADING_COMMODITIES=261]="CANNED_MSG_CK_TRADING_COMMODITIES",e[e.CANNED_MSG_CK_EVENT_BARBARIAN=262]="CANNED_MSG_CK_EVENT_BARBARIAN",e[e.CANNED_MSG_CK_EVENT_TRADE_GATE=263]="CANNED_MSG_CK_EVENT_TRADE_GATE",e[e.CANNED_MSG_CK_EVENT_POLITICS_GATE=264]="CANNED_MSG_CK_EVENT_POLITICS_GATE",e[e.CANNED_MSG_CK_EVENT_SCIENCE_GATE=265]="CANNED_MSG_CK_EVENT_SCIENCE_GATE",e[e.CANNED_MSG_CK_GOT_PROGRESS_CARD=266]="CANNED_MSG_CK_GOT_PROGRESS_CARD",e[e.CANNED_MSG_CK_SF_KNIGHT_ON_SHIP=267]="CANNED_MSG_CK_SF_KNIGHT_ON_SHIP",e[e.CANNED_MSG_CK_SF_PIRATE_VS_KNIGHT=268]="CANNED_MSG_CK_SF_PIRATE_VS_KNIGHT",e[e.CANNED_MSG_CK_FISH_MERCHANT_FISH_TRADE=269]="CANNED_MSG_CK_FISH_MERCHANT_FISH_TRADE",e[e.CANNED_MSG_CK_FISH_PROGRESS_WITH_FISH=270]="CANNED_MSG_CK_FISH_PROGRESS_WITH_FISH",e[e.CANNED_MSG_CK_KNIGHTS_DEACTIVATED=271]="CANNED_MSG_CK_KNIGHTS_DEACTIVATED",e[e.CANNED_MSG_CK_KNIGHTS_DEACTIVATED_RELIEF=272]="CANNED_MSG_CK_KNIGHTS_DEACTIVATED_RELIEF",e[e.CANNED_MSG_CK_KNIGHTS_DEACTIVATED_FRUSTRATED=273]="CANNED_MSG_CK_KNIGHTS_DEACTIVATED_FRUSTRATED",e[e.CANNED_MSG_CK_KNIGHTS_DEACTIVATED_PLAYFUL=274]="CANNED_MSG_CK_KNIGHTS_DEACTIVATED_PLAYFUL",e[e.CANNED_MSG_CK_KNIGHT_ERRANT_USED=275]="CANNED_MSG_CK_KNIGHT_ERRANT_USED",e[e.CANNED_MSG_CK_KNIGHT_ERRANT_USED_OTHER=276]="CANNED_MSG_CK_KNIGHT_ERRANT_USED_OTHER",e[e.CANNED_MSG_CK_AWAIT_KNIGHT_COMMITMENT=277]="CANNED_MSG_CK_AWAIT_KNIGHT_COMMITMENT",e[e.CANNED_MSG_CK_AWAIT_KNIGHT_COMMITMENT_URGENT=278]="CANNED_MSG_CK_AWAIT_KNIGHT_COMMITMENT_URGENT",e[e.CANNED_MSG_CK_COMMIT_KNIGHTS=279]="CANNED_MSG_CK_COMMIT_KNIGHTS",e[e.CANNED_MSG_CK_COMMIT_KNIGHTS_OTHER=280]="CANNED_MSG_CK_COMMIT_KNIGHTS_OTHER",e[e.CANNED_MSG_CK_COMMIT_KNIGHTS_HERO=281]="CANNED_MSG_CK_COMMIT_KNIGHTS_HERO",e[e.CANNED_MSG_CK_COMMIT_KNIGHTS_NONE=282]="CANNED_MSG_CK_COMMIT_KNIGHTS_NONE",e[e.CANNED_MSG_SF_SHIP_BUILT=300]="CANNED_MSG_SF_SHIP_BUILT",e[e.CANNED_MSG_SF_SHIP_BUILT_OTHER=301]="CANNED_MSG_SF_SHIP_BUILT_OTHER",e[e.CANNED_MSG_SF_SHIP_MOVED=302]="CANNED_MSG_SF_SHIP_MOVED",e[e.CANNED_MSG_SF_SHIPPING_ROUTE=303]="CANNED_MSG_SF_SHIPPING_ROUTE",e[e.CANNED_MSG_SF_LONGEST_TRADE_ROUTE=304]="CANNED_MSG_SF_LONGEST_TRADE_ROUTE",e[e.CANNED_MSG_SF_LONGEST_TRADE_ROUTE_OTHER=305]="CANNED_MSG_SF_LONGEST_TRADE_ROUTE_OTHER",e[e.CANNED_MSG_SF_PIRATE_PLACED=306]="CANNED_MSG_SF_PIRATE_PLACED",e[e.CANNED_MSG_SF_PIRATE_THREAT=307]="CANNED_MSG_SF_PIRATE_THREAT",e[e.CANNED_MSG_SF_GOLD_DISCOVERED=308]="CANNED_MSG_SF_GOLD_DISCOVERED",e[e.CANNED_MSG_SF_GOLD_CHOICE=309]="CANNED_MSG_SF_GOLD_CHOICE",e[e.CANNED_MSG_SF_ISLAND_SETTLED=310]="CANNED_MSG_SF_ISLAND_SETTLED",e[e.CANNED_MSG_SF_COASTAL_SETTLEMENT=311]="CANNED_MSG_SF_COASTAL_SETTLEMENT",e[e.CANNED_MSG_SF_SEA_EXPANSION=312]="CANNED_MSG_SF_SEA_EXPANSION",e[e.CANNED_MSG_SF_NEED_SHIPS=313]="CANNED_MSG_SF_NEED_SHIPS",e[e.CANNED_MSG_SF_SHIP_BREAKING=314]="CANNED_MSG_SF_SHIP_BREAKING",e[e.CANNED_MSG_SF_FOG_EXPLORING=315]="CANNED_MSG_SF_FOG_EXPLORING",e[e.CANNED_MSG_SF_FOG_REVEALED_LAND=316]="CANNED_MSG_SF_FOG_REVEALED_LAND",e[e.CANNED_MSG_SF_FOG_REVEALED_SEA=317]="CANNED_MSG_SF_FOG_REVEALED_SEA",e[e.CANNED_MSG_SF_FOG_REVEALED_GOLD=318]="CANNED_MSG_SF_FOG_REVEALED_GOLD",e[e.CANNED_MSG_SF_FOG_REVEALED_DESERT=319]="CANNED_MSG_SF_FOG_REVEALED_DESERT",e[e.CANNED_MSG_SF_FOG_NUMBER_REVEALED=320]="CANNED_MSG_SF_FOG_NUMBER_REVEALED",e[e.CANNED_MSG_SF_FOG_PORT_DISCOVERED=321]="CANNED_MSG_SF_FOG_PORT_DISCOVERED",e[e.CANNED_MSG_SF_FOG_MYSTERY=322]="CANNED_MSG_SF_FOG_MYSTERY",e[e.CANNED_MSG_SF_FISH_SHIP_TO_FISHING=323]="CANNED_MSG_SF_FISH_SHIP_TO_FISHING",e[e.CANNED_MSG_SF_HARBORMASTER=324]="CANNED_MSG_SF_HARBORMASTER",e[e.CANNED_MSG_SF_HARBORMASTER_OTHER=325]="CANNED_MSG_SF_HARBORMASTER_OTHER",e[e.CANNED_MSG_SF_HARBORMASTER_LOST=326]="CANNED_MSG_SF_HARBORMASTER_LOST",e[e.CANNED_MSG_SF_HARBORMASTER_RACE=327]="CANNED_MSG_SF_HARBORMASTER_RACE",e[e.CANNED_MSG_SF_EDGE_VP=328]="CANNED_MSG_SF_EDGE_VP",e[e.CANNED_MSG_SF_EDGE_VP_EXCITED=329]="CANNED_MSG_SF_EDGE_VP_EXCITED",e[e.CANNED_MSG_SF_EDGE_VP_OTHER=330]="CANNED_MSG_SF_EDGE_VP_OTHER",e[e.CANNED_MSG_SF_EDGE_DEV_CARD=331]="CANNED_MSG_SF_EDGE_DEV_CARD",e[e.CANNED_MSG_SF_EDGE_DEV_CARD_EXCITED=332]="CANNED_MSG_SF_EDGE_DEV_CARD_EXCITED",e[e.CANNED_MSG_SF_EDGE_DEV_CARD_OTHER=333]="CANNED_MSG_SF_EDGE_DEV_CARD_OTHER",e[e.CANNED_MSG_SF_EDGE_PORT=334]="CANNED_MSG_SF_EDGE_PORT",e[e.CANNED_MSG_SF_EDGE_PORT_EXCITED=335]="CANNED_MSG_SF_EDGE_PORT_EXCITED",e[e.CANNED_MSG_SF_EDGE_PORT_OTHER=336]="CANNED_MSG_SF_EDGE_PORT_OTHER",e[e.CANNED_MSG_SF_PORT_PLACED=337]="CANNED_MSG_SF_PORT_PLACED",e[e.CANNED_MSG_SF_PORT_PLACED_STRATEGIC=338]="CANNED_MSG_SF_PORT_PLACED_STRATEGIC",e[e.CANNED_MSG_SF_PORT_PLACED_OTHER=339]="CANNED_MSG_SF_PORT_PLACED_OTHER",e[e.CANNED_MSG_FISH_CAUGHT_ONE=350]="CANNED_MSG_FISH_CAUGHT_ONE",e[e.CANNED_MSG_FISH_CAUGHT_MULTIPLE=351]="CANNED_MSG_FISH_CAUGHT_MULTIPLE",e[e.CANNED_MSG_FISH_GOT_OLD_BOOT=352]="CANNED_MSG_FISH_GOT_OLD_BOOT",e[e.CANNED_MSG_FISH_PASSED_OLD_BOOT=353]="CANNED_MSG_FISH_PASSED_OLD_BOOT",e[e.CANNED_MSG_FISH_RECEIVED_OLD_BOOT=354]="CANNED_MSG_FISH_RECEIVED_OLD_BOOT",e[e.CANNED_MSG_FISH_OLD_BOOT_PENALTY=355]="CANNED_MSG_FISH_OLD_BOOT_PENALTY",e[e.CANNED_MSG_FISH_NEAR_WIN_WITH_BOOT=356]="CANNED_MSG_FISH_NEAR_WIN_WITH_BOOT",e[e.CANNED_MSG_FISH_BANISH_ROBBER=357]="CANNED_MSG_FISH_BANISH_ROBBER",e[e.CANNED_MSG_FISH_STEAL_RESOURCE=358]="CANNED_MSG_FISH_STEAL_RESOURCE",e[e.CANNED_MSG_FISH_TAKE_RESOURCE=359]="CANNED_MSG_FISH_TAKE_RESOURCE",e[e.CANNED_MSG_FISH_BUILD_ROAD=360]="CANNED_MSG_FISH_BUILD_ROAD",e[e.CANNED_MSG_FISH_DRAW_DEV_CARD=361]="CANNED_MSG_FISH_DRAW_DEV_CARD",e[e.CANNED_MSG_FISH_SPENDING_FISH=362]="CANNED_MSG_FISH_SPENDING_FISH",e[e.CANNED_MSG_FISH_SAVING_FISH=363]="CANNED_MSG_FISH_SAVING_FISH",e[e.CANNED_MSG_FISH_FISHING_SPOT=364]="CANNED_MSG_FISH_FISHING_SPOT",e[e.CANNED_MSG_FISH_FISHERY_BUILT=365]="CANNED_MSG_FISH_FISHERY_BUILT",e[e.CANNED_MSG_FISH_LAKE_PRODUCTION=366]="CANNED_MSG_FISH_LAKE_PRODUCTION",e[e.CANNED_MSG_FISH_GOOD_CATCH=367]="CANNED_MSG_FISH_GOOD_CATCH",e[e.CANNED_MSG_FISH_POOR_CATCH=368]="CANNED_MSG_FISH_POOR_CATCH",e[e.CANNED_MSG_FISH_NO_FISH=369]="CANNED_MSG_FISH_NO_FISH",e[e.CANNED_MSG_FISH_EXCHANGED=370]="CANNED_MSG_FISH_EXCHANGED",e[e.CANNED_MSG_FISH_EXCHANGED_HAPPY=371]="CANNED_MSG_FISH_EXCHANGED_HAPPY",e[e.CANNED_MSG_FISH_EXCHANGED_ANNOYED=372]="CANNED_MSG_FISH_EXCHANGED_ANNOYED",e[e.CANNED_MSG_FISH_TOO_MANY=373]="CANNED_MSG_FISH_TOO_MANY",e[e.CANNED_MSG_EC_ROAD_DAMAGED=400]="CANNED_MSG_EC_ROAD_DAMAGED",e[e.CANNED_MSG_EC_ROAD_DAMAGED_OTHER=401]="CANNED_MSG_EC_ROAD_DAMAGED_OTHER",e[e.CANNED_MSG_EC_ROAD_DAMAGED_FRUSTRATED=402]="CANNED_MSG_EC_ROAD_DAMAGED_FRUSTRATED",e[e.CANNED_MSG_EC_ROAD_DAMAGED_RELIEVED=403]="CANNED_MSG_EC_ROAD_DAMAGED_RELIEVED",e[e.CANNED_MSG_EC_ROAD_DAMAGED_PLAYFUL=404]="CANNED_MSG_EC_ROAD_DAMAGED_PLAYFUL",e[e.CANNED_MSG_SS_TURN_START=420]="CANNED_MSG_SS_TURN_START",e[e.CANNED_MSG_SS_TURN_START_EXCITED=421]="CANNED_MSG_SS_TURN_START_EXCITED",e[e.CANNED_MSG_SS_TURN_END=422]="CANNED_MSG_SS_TURN_END",e[e.CANNED_MSG_SS_TEAMWORK=423]="CANNED_MSG_SS_TEAMWORK",e[e.CANNED_MSG_GAME_RESIGN=440]="CANNED_MSG_GAME_RESIGN",e[e.CANNED_MSG_GAME_RESIGN_OTHER=441]="CANNED_MSG_GAME_RESIGN_OTHER",e[e.CANNED_MSG_GAME_RESIGN_SURPRISED=442]="CANNED_MSG_GAME_RESIGN_SURPRISED",e[e.CANNED_MSG_GAME_RESIGN_GRACEFUL=443]="CANNED_MSG_GAME_RESIGN_GRACEFUL",e[e.CANNED_MSG_GAME_PAUSED=444]="CANNED_MSG_GAME_PAUSED",e[e.CANNED_MSG_GAME_PAUSED_BRB=445]="CANNED_MSG_GAME_PAUSED_BRB",e[e.CANNED_MSG_GAME_PAUSED_TAKE_TIME=446]="CANNED_MSG_GAME_PAUSED_TAKE_TIME",e[e.CANNED_MSG_GAME_UNPAUSED=447]="CANNED_MSG_GAME_UNPAUSED",e[e.CANNED_MSG_GAME_UNPAUSED_READY=448]="CANNED_MSG_GAME_UNPAUSED_READY",e[e.CANNED_MSG_GAME_UNPAUSED_LETS_GO=449]="CANNED_MSG_GAME_UNPAUSED_LETS_GO",e[e.CANNED_MSG_GAME_VOTE_CONTINUE=450]="CANNED_MSG_GAME_VOTE_CONTINUE",e[e.CANNED_MSG_GAME_VOTE_CONTINUE_PLEASE=451]="CANNED_MSG_GAME_VOTE_CONTINUE_PLEASE",e[e.CANNED_MSG_GAME_VOTE_WAITING=452]="CANNED_MSG_GAME_VOTE_WAITING",e[e.CANNED_MSG_ROB_TARGET_LEADER=500]="CANNED_MSG_ROB_TARGET_LEADER",e[e.CANNED_MSG_ROB_TARGET_LEADER_OBVIOUS=501]="CANNED_MSG_ROB_TARGET_LEADER_OBVIOUS",e[e.CANNED_MSG_ROB_TARGET_LEADER_RUNAWAY=502]="CANNED_MSG_ROB_TARGET_LEADER_RUNAWAY",e[e.CANNED_MSG_ROB_TARGET_MOST_CARDS=503]="CANNED_MSG_ROB_TARGET_MOST_CARDS",e[e.CANNED_MSG_ROB_TARGET_TOO_MANY=504]="CANNED_MSG_ROB_TARGET_TOO_MANY",e[e.CANNED_MSG_ROB_TARGET_HOARDING=505]="CANNED_MSG_ROB_TARGET_HOARDING",e[e.CANNED_MSG_ROB_TARGET_ABOUT_TO_BUILD=506]="CANNED_MSG_ROB_TARGET_ABOUT_TO_BUILD",e[e.CANNED_MSG_ROB_TARGET_CLOSE_TO_WIN=507]="CANNED_MSG_ROB_TARGET_CLOSE_TO_WIN",e[e.CANNED_MSG_ROB_TARGET_ONE_FROM_WIN=508]="CANNED_MSG_ROB_TARGET_ONE_FROM_WIN",e[e.CANNED_MSG_ROB_TARGET_CHECK_THEIR_POINTS=509]="CANNED_MSG_ROB_TARGET_CHECK_THEIR_POINTS",e[e.CANNED_MSG_ROB_TARGET_DONT_LET_THEM_WIN=510]="CANNED_MSG_ROB_TARGET_DONT_LET_THEM_WIN",e[e.CANNED_MSG_ROB_TARGET_STOP_THEM=511]="CANNED_MSG_ROB_TARGET_STOP_THEM",e[e.CANNED_MSG_ROB_TARGET_OBVIOUS_CHOICE=512]="CANNED_MSG_ROB_TARGET_OBVIOUS_CHOICE",e[e.CANNED_MSG_ROB_TARGET_LOOK_AT_BOARD=513]="CANNED_MSG_ROB_TARGET_LOOK_AT_BOARD",e[e.CANNED_MSG_ROB_TARGET_THEY_CAN_WIN=514]="CANNED_MSG_ROB_TARGET_THEY_CAN_WIN",e[e.CANNED_MSG_ROB_BLOCK_THEIR_PRODUCTION=515]="CANNED_MSG_ROB_BLOCK_THEIR_PRODUCTION",e[e.CANNED_MSG_ROB_BLOCK_THEIR_CITY=516]="CANNED_MSG_ROB_BLOCK_THEIR_CITY",e[e.CANNED_MSG_ROB_BLOCK_HIGH_NUMBER=517]="CANNED_MSG_ROB_BLOCK_HIGH_NUMBER",e[e.CANNED_MSG_ROB_BLOCK_DOUBLE_PRODUCTION=518]="CANNED_MSG_ROB_BLOCK_DOUBLE_PRODUCTION",e[e.CANNED_MSG_ROB_BLOCK_KEY_RESOURCE=519]="CANNED_MSG_ROB_BLOCK_KEY_RESOURCE",e[e.CANNED_MSG_ROB_BLOCK_ORE=520]="CANNED_MSG_ROB_BLOCK_ORE",e[e.CANNED_MSG_ROB_BLOCK_WHEAT=521]="CANNED_MSG_ROB_BLOCK_WHEAT",e[e.CANNED_MSG_ROB_BLOCK_BRICK_WOOD=522]="CANNED_MSG_ROB_BLOCK_BRICK_WOOD",e[e.CANNED_MSG_ROB_NOT_ME_PLEASE=523]="CANNED_MSG_ROB_NOT_ME_PLEASE",e[e.CANNED_MSG_ROB_NOT_ME_IM_BEHIND=524]="CANNED_MSG_ROB_NOT_ME_IM_BEHIND",e[e.CANNED_MSG_ROB_NOT_ME_IM_POOR=525]="CANNED_MSG_ROB_NOT_ME_IM_POOR",e[e.CANNED_MSG_ROB_NOT_ME_BARELY_ANY=526]="CANNED_MSG_ROB_NOT_ME_BARELY_ANY",e[e.CANNED_MSG_ROB_NOT_ME_JUST_LOST=527]="CANNED_MSG_ROB_NOT_ME_JUST_LOST",e[e.CANNED_MSG_ROB_NOT_ME_ALREADY_BLOCKED=528]="CANNED_MSG_ROB_NOT_ME_ALREADY_BLOCKED",e[e.CANNED_MSG_ROB_WHY_ME=529]="CANNED_MSG_ROB_WHY_ME",e[e.CANNED_MSG_ROB_SERIOUSLY=530]="CANNED_MSG_ROB_SERIOUSLY",e[e.CANNED_MSG_ROB_COME_ON=531]="CANNED_MSG_ROB_COME_ON",e[e.CANNED_MSG_ROB_REALLY=532]="CANNED_MSG_ROB_REALLY",e[e.CANNED_MSG_ROB_THERE_ARE_BETTER_TARGETS=533]="CANNED_MSG_ROB_THERE_ARE_BETTER_TARGETS",e[e.CANNED_MSG_ROB_IM_NOT_WINNING=534]="CANNED_MSG_ROB_IM_NOT_WINNING",e[e.CANNED_MSG_ROB_IM_NOT_THREAT=535]="CANNED_MSG_ROB_IM_NOT_THREAT",e[e.CANNED_MSG_ROB_CHECK_THE_SCORE=536]="CANNED_MSG_ROB_CHECK_THE_SCORE",e[e.CANNED_MSG_ROB_LOOK_WHOS_WINNING=537]="CANNED_MSG_ROB_LOOK_WHOS_WINNING",e[e.CANNED_MSG_ROB_REACTION_THANKS=538]="CANNED_MSG_ROB_REACTION_THANKS",e[e.CANNED_MSG_ROB_REACTION_GOOD_CHOICE=539]="CANNED_MSG_ROB_REACTION_GOOD_CHOICE",e[e.CANNED_MSG_ROB_REACTION_SMART_MOVE=540]="CANNED_MSG_ROB_REACTION_SMART_MOVE",e[e.CANNED_MSG_ROB_REACTION_FINALLY=541]="CANNED_MSG_ROB_REACTION_FINALLY",e[e.CANNED_MSG_ROB_REACTION_ABOUT_TIME=542]="CANNED_MSG_ROB_REACTION_ABOUT_TIME",e[e.CANNED_MSG_ROB_REACTION_WHY_ALWAYS_ME=543]="CANNED_MSG_ROB_REACTION_WHY_ALWAYS_ME",e[e.CANNED_MSG_ROB_REACTION_UNFAIR=544]="CANNED_MSG_ROB_REACTION_UNFAIR",e[e.CANNED_MSG_ROB_REACTION_EVERYONE_ROBS_ME=545]="CANNED_MSG_ROB_REACTION_EVERYONE_ROBS_ME",e[e.CANNED_MSG_ROB_REACTION_REMEMBER_THIS=546]="CANNED_MSG_ROB_REACTION_REMEMBER_THIS",e[e.CANNED_MSG_ROB_REACTION_NOTED=547]="CANNED_MSG_ROB_REACTION_NOTED",e[e.CANNED_MSG_ROB_REACTION_WOW=548]="CANNED_MSG_ROB_REACTION_WOW",e[e.CANNED_MSG_ROB_REACTION_INTERESTING=549]="CANNED_MSG_ROB_REACTION_INTERESTING",e[e.CANNED_MSG_ROB_REACTION_QUESTIONABLE=550]="CANNED_MSG_ROB_REACTION_QUESTIONABLE",e[e.CANNED_MSG_TRADE_NEG_GOOD_DEAL=600]="CANNED_MSG_TRADE_NEG_GOOD_DEAL",e[e.CANNED_MSG_TRADE_NEG_FAIR_TRADE=601]="CANNED_MSG_TRADE_NEG_FAIR_TRADE",e[e.CANNED_MSG_TRADE_NEG_ACCEPT_IT=602]="CANNED_MSG_TRADE_NEG_ACCEPT_IT",e[e.CANNED_MSG_TRADE_NEG_WIN_WIN=603]="CANNED_MSG_TRADE_NEG_WIN_WIN",e[e.CANNED_MSG_TRADE_NEG_HELPS_BOTH=604]="CANNED_MSG_TRADE_NEG_HELPS_BOTH",e[e.CANNED_MSG_TRADE_NEG_MUTUAL_BENEFIT=605]="CANNED_MSG_TRADE_NEG_MUTUAL_BENEFIT",e[e.CANNED_MSG_TRADE_NEG_PLEASE_TRADE=606]="CANNED_MSG_TRADE_NEG_PLEASE_TRADE",e[e.CANNED_MSG_TRADE_NEG_REALLY_NEED=607]="CANNED_MSG_TRADE_NEG_REALLY_NEED",e[e.CANNED_MSG_TRADE_NEG_DESPERATE=608]="CANNED_MSG_TRADE_NEG_DESPERATE",e[e.CANNED_MSG_TRADE_NEG_HELP_ME_OUT=609]="CANNED_MSG_TRADE_NEG_HELP_ME_OUT",e[e.CANNED_MSG_TRADE_NEG_BE_NICE=610]="CANNED_MSG_TRADE_NEG_BE_NICE",e[e.CANNED_MSG_TRADE_NEG_GOOD_OFFER=611]="CANNED_MSG_TRADE_NEG_GOOD_OFFER",e[e.CANNED_MSG_TRADE_NEG_GENEROUS=612]="CANNED_MSG_TRADE_NEG_GENEROUS",e[e.CANNED_MSG_TRADE_NEG_OVERPAYING=613]="CANNED_MSG_TRADE_NEG_OVERPAYING",e[e.CANNED_MSG_TRADE_NEG_GIVING_EXTRA=614]="CANNED_MSG_TRADE_NEG_GIVING_EXTRA",e[e.CANNED_MSG_TRADE_NEG_DONT_TRADE_LEADER=615]="CANNED_MSG_TRADE_NEG_DONT_TRADE_LEADER",e[e.CANNED_MSG_TRADE_NEG_NO_HELP_LEADER=616]="CANNED_MSG_TRADE_NEG_NO_HELP_LEADER",e[e.CANNED_MSG_TRADE_NEG_THEY_WILL_WIN=617]="CANNED_MSG_TRADE_NEG_THEY_WILL_WIN",e[e.CANNED_MSG_TRADE_NEG_ENABLES_WIN=618]="CANNED_MSG_TRADE_NEG_ENABLES_WIN",e[e.CANNED_MSG_TRADE_NEG_DONT_DO_IT=619]="CANNED_MSG_TRADE_NEG_DONT_DO_IT",e[e.CANNED_MSG_TRADE_NEG_TERRIBLE_DEAL=620]="CANNED_MSG_TRADE_NEG_TERRIBLE_DEAL",e[e.CANNED_MSG_TRADE_NEG_GETTING_ROBBED=621]="CANNED_MSG_TRADE_NEG_GETTING_ROBBED",e[e.CANNED_MSG_TRADE_NEG_NOT_FAIR=622]="CANNED_MSG_TRADE_NEG_NOT_FAIR",e[e.CANNED_MSG_TRADE_NEG_BAD_TRADE=623]="CANNED_MSG_TRADE_NEG_BAD_TRADE",e[e.CANNED_MSG_TRADE_NEG_RIPOFF=624]="CANNED_MSG_TRADE_NEG_RIPOFF",e[e.CANNED_MSG_TRADE_NEG_HIGHWAY_ROBBERY=625]="CANNED_MSG_TRADE_NEG_HIGHWAY_ROBBERY",e[e.CANNED_MSG_TRADE_NEG_ARE_YOU_SERIOUS=626]="CANNED_MSG_TRADE_NEG_ARE_YOU_SERIOUS",e[e.CANNED_MSG_TRADE_NEG_NO_WAY=627]="CANNED_MSG_TRADE_NEG_NO_WAY",e[e.CANNED_MSG_TRADE_NEG_NEVER=628]="CANNED_MSG_TRADE_NEG_NEVER",e[e.CANNED_MSG_TRADE_NEG_DREAM_ON=629]="CANNED_MSG_TRADE_NEG_DREAM_ON",e[e.CANNED_MSG_TRADE_NEG_NEED_MORE=630]="CANNED_MSG_TRADE_NEG_NEED_MORE",e[e.CANNED_MSG_TRADE_NEG_ADD_ONE_MORE=631]="CANNED_MSG_TRADE_NEG_ADD_ONE_MORE",e[e.CANNED_MSG_TRADE_NEG_TWO_FOR_ONE=632]="CANNED_MSG_TRADE_NEG_TWO_FOR_ONE",e[e.CANNED_MSG_TRADE_NEG_THREE_FOR_TWO=633]="CANNED_MSG_TRADE_NEG_THREE_FOR_TWO",e[e.CANNED_MSG_TRADE_NEG_THROW_IN_EXTRA=634]="CANNED_MSG_TRADE_NEG_THROW_IN_EXTRA",e[e.CANNED_MSG_TRADE_NEG_SWEETEN_DEAL=635]="CANNED_MSG_TRADE_NEG_SWEETEN_DEAL",e[e.CANNED_MSG_TRADE_NEG_ALMOST_BUT=636]="CANNED_MSG_TRADE_NEG_ALMOST_BUT",e[e.CANNED_MSG_TRADE_NEG_CLOSE_BUT=637]="CANNED_MSG_TRADE_NEG_CLOSE_BUT",e[e.CANNED_MSG_TRADE_NEG_IF_YOU_ADD=638]="CANNED_MSG_TRADE_NEG_IF_YOU_ADD",e[e.CANNED_MSG_TRADE_NEG_ONLY_IF=639]="CANNED_MSG_TRADE_NEG_ONLY_IF",e[e.CANNED_MSG_TRADE_SOCIAL_ILL_OWE_YOU=640]="CANNED_MSG_TRADE_SOCIAL_ILL_OWE_YOU",e[e.CANNED_MSG_TRADE_SOCIAL_YOU_OWE_ME=641]="CANNED_MSG_TRADE_SOCIAL_YOU_OWE_ME",e[e.CANNED_MSG_TRADE_SOCIAL_REMEMBER_FAVOR=642]="CANNED_MSG_TRADE_SOCIAL_REMEMBER_FAVOR",e[e.CANNED_MSG_TRADE_SOCIAL_PAYING_BACK=643]="CANNED_MSG_TRADE_SOCIAL_PAYING_BACK",e[e.CANNED_MSG_TRADE_SOCIAL_WE_RE_EVEN=644]="CANNED_MSG_TRADE_SOCIAL_WE_RE_EVEN",e[e.CANNED_MSG_TRADE_SOCIAL_THANKS_FRIEND=645]="CANNED_MSG_TRADE_SOCIAL_THANKS_FRIEND",e[e.CANNED_MSG_TRADE_SOCIAL_APPRECIATE_IT=646]="CANNED_MSG_TRADE_SOCIAL_APPRECIATE_IT",e[e.CANNED_MSG_TRADE_SOCIAL_YOURE_THE_BEST=647]="CANNED_MSG_TRADE_SOCIAL_YOURE_THE_BEST",e[e.CANNED_MSG_TRADE_SOCIAL_LIFE_SAVER=648]="CANNED_MSG_TRADE_SOCIAL_LIFE_SAVER",e[e.CANNED_MSG_TRADE_SOCIAL_MY_HERO=649]="CANNED_MSG_TRADE_SOCIAL_MY_HERO",e[e.CANNED_MSG_TRADE_SOCIAL_WONT_FORGET=650]="CANNED_MSG_TRADE_SOCIAL_WONT_FORGET",e[e.CANNED_MSG_TRADE_SOCIAL_HELP_ME_ONCE=651]="CANNED_MSG_TRADE_SOCIAL_HELP_ME_ONCE",e[e.CANNED_MSG_TRADE_SOCIAL_REMEMBER_WHEN=652]="CANNED_MSG_TRADE_SOCIAL_REMEMBER_WHEN",e[e.CANNED_MSG_TRADE_SOCIAL_YOUR_TURN_HELP=653]="CANNED_MSG_TRADE_SOCIAL_YOUR_TURN_HELP",e[e.CANNED_MSG_TRADE_SOCIAL_SCRATCH_BACK=654]="CANNED_MSG_TRADE_SOCIAL_SCRATCH_BACK",e[e.CANNED_MSG_TRADE_ACCEPT_DEAL=655]="CANNED_MSG_TRADE_ACCEPT_DEAL",e[e.CANNED_MSG_TRADE_ACCEPT_OK=656]="CANNED_MSG_TRADE_ACCEPT_OK",e[e.CANNED_MSG_TRADE_ACCEPT_SURE=657]="CANNED_MSG_TRADE_ACCEPT_SURE",e[e.CANNED_MSG_TRADE_ACCEPT_LETS_DO_IT=658]="CANNED_MSG_TRADE_ACCEPT_LETS_DO_IT",e[e.CANNED_MSG_TRADE_ACCEPT_AGREED=659]="CANNED_MSG_TRADE_ACCEPT_AGREED",e[e.CANNED_MSG_TRADE_ACCEPT_FINE=660]="CANNED_MSG_TRADE_ACCEPT_FINE",e[e.CANNED_MSG_TRADE_ACCEPT_I_GUESS=661]="CANNED_MSG_TRADE_ACCEPT_I_GUESS",e[e.CANNED_MSG_TRADE_ACCEPT_IF_I_MUST=662]="CANNED_MSG_TRADE_ACCEPT_IF_I_MUST",e[e.CANNED_MSG_TRADE_REJECT_NO_THANKS=663]="CANNED_MSG_TRADE_REJECT_NO_THANKS",e[e.CANNED_MSG_TRADE_REJECT_PASS=664]="CANNED_MSG_TRADE_REJECT_PASS",e[e.CANNED_MSG_TRADE_REJECT_CANT=665]="CANNED_MSG_TRADE_REJECT_CANT",e[e.CANNED_MSG_TRADE_REJECT_SORRY=666]="CANNED_MSG_TRADE_REJECT_SORRY",e[e.CANNED_MSG_TRADE_REJECT_WISH_I_COULD=667]="CANNED_MSG_TRADE_REJECT_WISH_I_COULD",e[e.CANNED_MSG_TRADE_REJECT_NOT_NOW=668]="CANNED_MSG_TRADE_REJECT_NOT_NOW",e[e.CANNED_MSG_TRADE_REJECT_MAYBE_LATER=669]="CANNED_MSG_TRADE_REJECT_MAYBE_LATER",e[e.CANNED_MSG_TRADE_BEFORE_BUILDING=670]="CANNED_MSG_TRADE_BEFORE_BUILDING",e[e.CANNED_MSG_TRADE_LAST_CHANCE=671]="CANNED_MSG_TRADE_LAST_CHANCE",e[e.CANNED_MSG_TRADE_ENDING_TURN=672]="CANNED_MSG_TRADE_ENDING_TURN",e[e.CANNED_MSG_TRADE_MONOPOLY_WARNING=673]="CANNED_MSG_TRADE_MONOPOLY_WARNING",e[e.CANNED_MSG_TRADE_THEY_HAVE_TONS=674]="CANNED_MSG_TRADE_THEY_HAVE_TONS",e[e.CANNED_MSG_TRADE_ONLY_SOURCE=675]="CANNED_MSG_TRADE_ONLY_SOURCE",e[e.CANNED_MSG_TRADE_NO_ONE_ELSE_HAS=676]="CANNED_MSG_TRADE_NO_ONE_ELSE_HAS",e[e.CANNED_MSG_STRATEGY_WATCH_OUT=750]="CANNED_MSG_STRATEGY_WATCH_OUT",e[e.CANNED_MSG_STRATEGY_KEEP_EYE_ON=751]="CANNED_MSG_STRATEGY_KEEP_EYE_ON",e[e.CANNED_MSG_STRATEGY_SNEAKY=752]="CANNED_MSG_STRATEGY_SNEAKY",e[e.CANNED_MSG_STRATEGY_QUIET_THREAT=753]="CANNED_MSG_STRATEGY_QUIET_THREAT",e[e.CANNED_MSG_STRATEGY_DONT_IGNORE=754]="CANNED_MSG_STRATEGY_DONT_IGNORE",e[e.CANNED_MSG_STRATEGY_SECRET_POINTS=755]="CANNED_MSG_STRATEGY_SECRET_POINTS",e[e.CANNED_MSG_STRATEGY_COUNT_CARDS=756]="CANNED_MSG_STRATEGY_COUNT_CARDS",e[e.CANNED_MSG_STRATEGY_COULD_HAVE_VP=757]="CANNED_MSG_STRATEGY_COULD_HAVE_VP",e[e.CANNED_MSG_STRATEGY_BUILDING_TO_WIN=758]="CANNED_MSG_STRATEGY_BUILDING_TO_WIN",e[e.CANNED_MSG_STRATEGY_ONE_CARD_WIN=759]="CANNED_MSG_STRATEGY_ONE_CARD_WIN",e[e.CANNED_MSG_STRATEGY_WORK_TOGETHER=760]="CANNED_MSG_STRATEGY_WORK_TOGETHER",e[e.CANNED_MSG_STRATEGY_STOP_LEADER_TOGETHER=761]="CANNED_MSG_STRATEGY_STOP_LEADER_TOGETHER",e[e.CANNED_MSG_STRATEGY_TEAM_UP=762]="CANNED_MSG_STRATEGY_TEAM_UP",e[e.CANNED_MSG_STRATEGY_TEMPORARY_ALLIANCE=763]="CANNED_MSG_STRATEGY_TEMPORARY_ALLIANCE",e[e.CANNED_MSG_STRATEGY_MUTUAL_INTEREST=764]="CANNED_MSG_STRATEGY_MUTUAL_INTEREST",e[e.CANNED_MSG_STRATEGY_BOTH_LOSE_IF=765]="CANNED_MSG_STRATEGY_BOTH_LOSE_IF",e[e.CANNED_MSG_STRATEGY_HELP_EACH_OTHER=766]="CANNED_MSG_STRATEGY_HELP_EACH_OTHER",e[e.CANNED_MSG_STRATEGY_NOT_ENEMIES=767]="CANNED_MSG_STRATEGY_NOT_ENEMIES",e[e.CANNED_MSG_STRATEGY_COMMON_THREAT=768]="CANNED_MSG_STRATEGY_COMMON_THREAT",e[e.CANNED_MSG_STRATEGY_UNITE_AGAINST=769]="CANNED_MSG_STRATEGY_UNITE_AGAINST",e[e.CANNED_MSG_DICE_MY_NUMBER_NEVER_ROLLS=800]="CANNED_MSG_DICE_MY_NUMBER_NEVER_ROLLS",e[e.CANNED_MSG_DICE_WHEN_WILL_ROLL=801]="CANNED_MSG_DICE_WHEN_WILL_ROLL",e[e.CANNED_MSG_DICE_STILL_WAITING_FOR=802]="CANNED_MSG_DICE_STILL_WAITING_FOR",e[e.CANNED_MSG_DICE_ZERO_TIMES=803]="CANNED_MSG_DICE_ZERO_TIMES",e[e.CANNED_MSG_DICE_FORGOT_NUMBER_EXISTS=804]="CANNED_MSG_DICE_FORGOT_NUMBER_EXISTS",e[e.CANNED_MSG_DICE_IS_NUMBER_BROKEN=805]="CANNED_MSG_DICE_IS_NUMBER_BROKEN",e[e.CANNED_MSG_DICE_CURSED_NUMBER=806]="CANNED_MSG_DICE_CURSED_NUMBER",e[e.CANNED_MSG_DICE_NEVER_GET_PRODUCTION=807]="CANNED_MSG_DICE_NEVER_GET_PRODUCTION",e[e.CANNED_MSG_DICE_STARVING_HERE=808]="CANNED_MSG_DICE_STARVING_HERE",e[e.CANNED_MSG_DICE_DICE_HATE_ME=809]="CANNED_MSG_DICE_DICE_HATE_ME",e[e.CANNED_MSG_DICE_WORST_LUCK=810]="CANNED_MSG_DICE_WORST_LUCK",e[e.CANNED_MSG_DICE_THIS_IS_RIGGED=811]="CANNED_MSG_DICE_THIS_IS_RIGGED",e[e.CANNED_MSG_DICE_UNBELIEVABLE=812]="CANNED_MSG_DICE_UNBELIEVABLE",e[e.CANNED_MSG_DICE_ARE_YOU_KIDDING=813]="CANNED_MSG_DICE_ARE_YOU_KIDDING",e[e.CANNED_MSG_DICE_NUMBER_ROLLING_TOO_MUCH=814]="CANNED_MSG_DICE_NUMBER_ROLLING_TOO_MUCH",e[e.CANNED_MSG_DICE_ANOTHER_NUMBER=815]="CANNED_MSG_DICE_ANOTHER_NUMBER",e[e.CANNED_MSG_DICE_NUMBER_AGAIN=816]="CANNED_MSG_DICE_NUMBER_AGAIN",e[e.CANNED_MSG_DICE_HOW_MANY_TIMES=817]="CANNED_MSG_DICE_HOW_MANY_TIMES",e[e.CANNED_MSG_DICE_STOP_ROLLING=818]="CANNED_MSG_DICE_STOP_ROLLING",e[e.CANNED_MSG_DICE_ENOUGH_WITH_NUMBER=819]="CANNED_MSG_DICE_ENOUGH_WITH_NUMBER",e[e.CANNED_MSG_DICE_NUMBER_MONOPOLY=820]="CANNED_MSG_DICE_NUMBER_MONOPOLY",e[e.CANNED_MSG_DICE_ONLY_NUMBER_THAT_ROLLS=821]="CANNED_MSG_DICE_ONLY_NUMBER_THAT_ROLLS",e[e.CANNED_MSG_DICE_BROKEN_DICE=822]="CANNED_MSG_DICE_BROKEN_DICE",e[e.CANNED_MSG_DICE_NOT_RANDOM=823]="CANNED_MSG_DICE_NOT_RANDOM",e[e.CANNED_MSG_DICE_STATISTICALLY_IMPOSSIBLE=824]="CANNED_MSG_DICE_STATISTICALLY_IMPOSSIBLE",e[e.CANNED_MSG_DICE_FIVE_IN_ROW=825]="CANNED_MSG_DICE_FIVE_IN_ROW",e[e.CANNED_MSG_DICE_CHECK_THE_DICE=826]="CANNED_MSG_DICE_CHECK_THE_DICE",e[e.CANNED_MSG_DICE_NEW_DICE_PLEASE=827]="CANNED_MSG_DICE_NEW_DICE_PLEASE",e[e.CANNED_MSG_DICE_WEIGHTED_DICE=828]="CANNED_MSG_DICE_WEIGHTED_DICE",e[e.CANNED_MSG_DICE_NOT_ANOTHER_SEVEN=829]="CANNED_MSG_DICE_NOT_ANOTHER_SEVEN",e[e.CANNED_MSG_DICE_SEVEN_AGAIN=830]="CANNED_MSG_DICE_SEVEN_AGAIN",e[e.CANNED_MSG_DICE_TOO_MANY_SEVENS=831]="CANNED_MSG_DICE_TOO_MANY_SEVENS",e[e.CANNED_MSG_DICE_STOP_THE_SEVENS=832]="CANNED_MSG_DICE_STOP_THE_SEVENS",e[e.CANNED_MSG_DICE_SEVEN_EVERY_TURN=833]="CANNED_MSG_DICE_SEVEN_EVERY_TURN",e[e.CANNED_MSG_DICE_ROBBER_FESTIVAL=834]="CANNED_MSG_DICE_ROBBER_FESTIVAL",e[e.CANNED_MSG_DICE_SEVEN_PERCENT=835]="CANNED_MSG_DICE_SEVEN_PERCENT",e[e.CANNED_MSG_DICE_HATE_SEVENS=836]="CANNED_MSG_DICE_HATE_SEVENS",e[e.CANNED_MSG_DICE_PLEASE_NO_SEVEN=837]="CANNED_MSG_DICE_PLEASE_NO_SEVEN",e[e.CANNED_MSG_DICE_ANYTHING_BUT_SEVEN=838]="CANNED_MSG_DICE_ANYTHING_BUT_SEVEN",e[e.CANNED_MSG_DICE_LOST_HALF_AGAIN=839]="CANNED_MSG_DICE_LOST_HALF_AGAIN",e[e.CANNED_MSG_DICE_STOP_DISCARDING=840]="CANNED_MSG_DICE_STOP_DISCARDING",e[e.CANNED_MSG_DICE_CANT_HOLD_CARDS=841]="CANNED_MSG_DICE_CANT_HOLD_CARDS",e[e.CANNED_MSG_DICE_SEVEN_CURSE=842]="CANNED_MSG_DICE_SEVEN_CURSE",e[e.CANNED_MSG_DICE_ROBBER_PARTY=843]="CANNED_MSG_DICE_ROBBER_PARTY",e[e.CANNED_MSG_DICE_FINALLY=844]="CANNED_MSG_DICE_FINALLY",e[e.CANNED_MSG_DICE_ABOUT_TIME=845]="CANNED_MSG_DICE_ABOUT_TIME",e[e.CANNED_MSG_DICE_MY_NUMBER=846]="CANNED_MSG_DICE_MY_NUMBER",e[e.CANNED_MSG_DICE_YES_NUMBER=847]="CANNED_MSG_DICE_YES_NUMBER",e[e.CANNED_MSG_DICE_THANK_YOU_DICE=848]="CANNED_MSG_DICE_THANK_YOU_DICE",e[e.CANNED_MSG_DICE_BLESSED=849]="CANNED_MSG_DICE_BLESSED",e[e.CANNED_MSG_DICE_PERFECT_TIMING=850]="CANNED_MSG_DICE_PERFECT_TIMING",e[e.CANNED_MSG_DICE_EXACTLY_WHAT_NEEDED=851]="CANNED_MSG_DICE_EXACTLY_WHAT_NEEDED",e[e.CANNED_MSG_DICE_JACKPOT=852]="CANNED_MSG_DICE_JACKPOT",e[e.CANNED_MSG_DICE_DOUBLE_PRODUCTION=853]="CANNED_MSG_DICE_DOUBLE_PRODUCTION",e[e.CANNED_MSG_DICE_TRIPLE_PRODUCTION=854]="CANNED_MSG_DICE_TRIPLE_PRODUCTION",e[e.CANNED_MSG_DICE_RESOURCE_EXPLOSION=855]="CANNED_MSG_DICE_RESOURCE_EXPLOSION",e[e.CANNED_MSG_DICE_RICH=856]="CANNED_MSG_DICE_RICH",e[e.CANNED_MSG_DICE_SWIMMING_IN_RESOURCES=857]="CANNED_MSG_DICE_SWIMMING_IN_RESOURCES",e[e.CANNED_MSG_DICE_CALLING_NUMBER=858]="CANNED_MSG_DICE_CALLING_NUMBER",e[e.CANNED_MSG_DICE_PLEASE_ROLL=859]="CANNED_MSG_DICE_PLEASE_ROLL",e[e.CANNED_MSG_DICE_PRAYING_FOR=860]="CANNED_MSG_DICE_PRAYING_FOR",e[e.CANNED_MSG_DICE_MANIFESTING=861]="CANNED_MSG_DICE_MANIFESTING",e[e.CANNED_MSG_DICE_WISH_FOR=862]="CANNED_MSG_DICE_WISH_FOR",e[e.CANNED_MSG_DICE_BET_ITS=863]="CANNED_MSG_DICE_BET_ITS",e[e.CANNED_MSG_DICE_WATCH_THIS=864]="CANNED_MSG_DICE_WATCH_THIS",e[e.CANNED_MSG_DICE_GUARANTEED=865]="CANNED_MSG_DICE_GUARANTEED",e[e.CANNED_MSG_DICE_FEELING_NUMBER=866]="CANNED_MSG_DICE_FEELING_NUMBER",e[e.CANNED_MSG_DICE_DUE_FOR=867]="CANNED_MSG_DICE_DUE_FOR",e[e.CANNED_MSG_DICE_TIME_FOR=868]="CANNED_MSG_DICE_TIME_FOR",e[e.CANNED_MSG_DICE_NOT_SEVEN=869]="CANNED_MSG_DICE_NOT_SEVEN",e[e.CANNED_MSG_DICE_ANYTHING_BUT=870]="CANNED_MSG_DICE_ANYTHING_BUT",e[e.CANNED_MSG_DEV_MONOPOLY_INCOMING=900]="CANNED_MSG_DEV_MONOPOLY_INCOMING",e[e.CANNED_MSG_DEV_MONOPOLY_OH_NO=901]="CANNED_MSG_DEV_MONOPOLY_OH_NO",e[e.CANNED_MSG_DEV_MONOPOLY_RIP=902]="CANNED_MSG_DEV_MONOPOLY_RIP",e[e.CANNED_MSG_DEV_MONOPOLY_GG=903]="CANNED_MSG_DEV_MONOPOLY_GG",e[e.CANNED_MSG_DEV_MONOPOLY_DEVASTATING=904]="CANNED_MSG_DEV_MONOPOLY_DEVASTATING",e[e.CANNED_MSG_DEV_MONOPOLY_GAME_CHANGER=905]="CANNED_MSG_DEV_MONOPOLY_GAME_CHANGER",e[e.CANNED_MSG_DEV_MONOPOLY_HUGE=906]="CANNED_MSG_DEV_MONOPOLY_HUGE",e[e.CANNED_MSG_DEV_MONOPOLY_PROTECT_RESOURCES=907]="CANNED_MSG_DEV_MONOPOLY_PROTECT_RESOURCES",e[e.CANNED_MSG_DEV_MONOPOLY_HIDE_YOUR=908]="CANNED_MSG_DEV_MONOPOLY_HIDE_YOUR",e[e.CANNED_MSG_DEV_MONOPOLY_GOODBYE_CARDS=909]="CANNED_MSG_DEV_MONOPOLY_GOODBYE_CARDS",e[e.CANNED_MSG_DEV_MONOPOLY_BRUTAL=910]="CANNED_MSG_DEV_MONOPOLY_BRUTAL",e[e.CANNED_MSG_DEV_MONOPOLY_SAVAGE=911]="CANNED_MSG_DEV_MONOPOLY_SAVAGE",e[e.CANNED_MSG_DEV_MONOPOLY_TAKING_EVERYTHING=912]="CANNED_MSG_DEV_MONOPOLY_TAKING_EVERYTHING",e[e.CANNED_MSG_DEV_MONOPOLY_CLEANED_OUT=913]="CANNED_MSG_DEV_MONOPOLY_CLEANED_OUT",e[e.CANNED_MSG_DEV_MONOPOLY_BEST_CARD=914]="CANNED_MSG_DEV_MONOPOLY_BEST_CARD",e[e.CANNED_MSG_DEV_IS_THAT_VP=915]="CANNED_MSG_DEV_IS_THAT_VP",e[e.CANNED_MSG_DEV_THATS_VP=916]="CANNED_MSG_DEV_THATS_VP",e[e.CANNED_MSG_DEV_DEFINITELY_VP=917]="CANNED_MSG_DEV_DEFINITELY_VP",e[e.CANNED_MSG_DEV_HIDING_POINTS=918]="CANNED_MSG_DEV_HIDING_POINTS",e[e.CANNED_MSG_DEV_SECRET_VP=919]="CANNED_MSG_DEV_SECRET_VP",e[e.CANNED_MSG_DEV_CHECK_THEIR_POINTS=920]="CANNED_MSG_DEV_CHECK_THEIR_POINTS",e[e.CANNED_MSG_DEV_COUNT_THEIR_CARDS=921]="CANNED_MSG_DEV_COUNT_THEIR_CARDS",e[e.CANNED_MSG_DEV_HOW_MANY_VPS=922]="CANNED_MSG_DEV_HOW_MANY_VPS",e[e.CANNED_MSG_DEV_SITTING_ON_VPS=923]="CANNED_MSG_DEV_SITTING_ON_VPS",e[e.CANNED_MSG_DEV_MULTIPLE_VPS=924]="CANNED_MSG_DEV_MULTIPLE_VPS",e[e.CANNED_MSG_DEV_THREE_VPS_HIDDEN=925]="CANNED_MSG_DEV_THREE_VPS_HIDDEN",e[e.CANNED_MSG_DEV_THEYRE_AT_NINE=926]="CANNED_MSG_DEV_THEYRE_AT_NINE",e[e.CANNED_MSG_DEV_ONE_VP_FROM_WIN=927]="CANNED_MSG_DEV_ONE_VP_FROM_WIN",e[e.CANNED_MSG_DEV_CHECK_BEFORE_TOO_LATE=928]="CANNED_MSG_DEV_CHECK_BEFORE_TOO_LATE",e[e.CANNED_MSG_DEV_SNEAKY_WIN=929]="CANNED_MSG_DEV_SNEAKY_WIN",e[e.CANNED_MSG_DEV_KNIGHT_ARMY=930]="CANNED_MSG_DEV_KNIGHT_ARMY",e[e.CANNED_MSG_DEV_ANOTHER_KNIGHT=931]="CANNED_MSG_DEV_ANOTHER_KNIGHT",e[e.CANNED_MSG_DEV_KNIGHT_SPAM=932]="CANNED_MSG_DEV_KNIGHT_SPAM",e[e.CANNED_MSG_DEV_LARGEST_ARMY_SOON=933]="CANNED_MSG_DEV_LARGEST_ARMY_SOON",e[e.CANNED_MSG_DEV_STOP_THE_KNIGHTS=934]="CANNED_MSG_DEV_STOP_THE_KNIGHTS",e[e.CANNED_MSG_DEV_TOO_MANY_KNIGHTS=935]="CANNED_MSG_DEV_TOO_MANY_KNIGHTS",e[e.CANNED_MSG_DEV_KNIGHT_FESTIVAL=936]="CANNED_MSG_DEV_KNIGHT_FESTIVAL",e[e.CANNED_MSG_DEV_ROBBER_CONTROL=937]="CANNED_MSG_DEV_ROBBER_CONTROL",e[e.CANNED_MSG_DEV_KNIGHT_MONOPOLY=938]="CANNED_MSG_DEV_KNIGHT_MONOPOLY",e[e.CANNED_MSG_DEV_ARMY_GROWING=939]="CANNED_MSG_DEV_ARMY_GROWING",e[e.CANNED_MSG_DEV_ROAD_BUILDING_NICE=940]="CANNED_MSG_DEV_ROAD_BUILDING_NICE",e[e.CANNED_MSG_DEV_FREE_ROADS=941]="CANNED_MSG_DEV_FREE_ROADS",e[e.CANNED_MSG_DEV_ROAD_EXPLOSION=942]="CANNED_MSG_DEV_ROAD_EXPLOSION",e[e.CANNED_MSG_DEV_LONGEST_ROAD_THREAT=943]="CANNED_MSG_DEV_LONGEST_ROAD_THREAT",e[e.CANNED_MSG_DEV_WATCH_THE_ROADS=944]="CANNED_MSG_DEV_WATCH_THE_ROADS",e[e.CANNED_MSG_DEV_CONNECTING_EVERYTHING=945]="CANNED_MSG_DEV_CONNECTING_EVERYTHING",e[e.CANNED_MSG_DEV_ROAD_NETWORK=946]="CANNED_MSG_DEV_ROAD_NETWORK",e[e.CANNED_MSG_DEV_YEAR_OF_PLENTY_NICE=947]="CANNED_MSG_DEV_YEAR_OF_PLENTY_NICE",e[e.CANNED_MSG_DEV_FREE_STUFF=948]="CANNED_MSG_DEV_FREE_STUFF",e[e.CANNED_MSG_DEV_LUCKY_DRAW=949]="CANNED_MSG_DEV_LUCKY_DRAW",e[e.CANNED_MSG_DEV_PERFECT_RESOURCES=950]="CANNED_MSG_DEV_PERFECT_RESOURCES",e[e.CANNED_MSG_DEV_JUST_WHAT_NEEDED=951]="CANNED_MSG_DEV_JUST_WHAT_NEEDED",e[e.CANNED_MSG_DEV_BUYING_SPREE=952]="CANNED_MSG_DEV_BUYING_SPREE",e[e.CANNED_MSG_DEV_STOP_BUYING_DEVS=953]="CANNED_MSG_DEV_STOP_BUYING_DEVS",e[e.CANNED_MSG_DEV_ANOTHER_DEV=954]="CANNED_MSG_DEV_ANOTHER_DEV",e[e.CANNED_MSG_DEV_DEV_CARD_STRATEGY=955]="CANNED_MSG_DEV_DEV_CARD_STRATEGY",e[e.CANNED_MSG_DEV_GAMBLING=956]="CANNED_MSG_DEV_GAMBLING",e[e.CANNED_MSG_DEV_DEV_CARD_LUCK=957]="CANNED_MSG_DEV_DEV_CARD_LUCK",e[e.CANNED_MSG_DEV_WHAT_DID_YOU_GET=958]="CANNED_MSG_DEV_WHAT_DID_YOU_GET",e[e.CANNED_MSG_DEV_SHOW_US=959]="CANNED_MSG_DEV_SHOW_US",e[e.CANNED_MSG_DEV_REVEAL_IT=960]="CANNED_MSG_DEV_REVEAL_IT",e[e.CANNED_MSG_DEV_USE_IT=961]="CANNED_MSG_DEV_USE_IT",e[e.CANNED_MSG_EMPHASIS_SERIOUSLY=1e3]="CANNED_MSG_EMPHASIS_SERIOUSLY",e[e.CANNED_MSG_EMPHASIS_FOR_REAL=1001]="CANNED_MSG_EMPHASIS_FOR_REAL",e[e.CANNED_MSG_EMPHASIS_TRUST_ME=1002]="CANNED_MSG_EMPHASIS_TRUST_ME",e[e.CANNED_MSG_EMPHASIS_LISTEN=1003]="CANNED_MSG_EMPHASIS_LISTEN",e[e.CANNED_MSG_EMPHASIS_LOOK=1004]="CANNED_MSG_EMPHASIS_LOOK",e[e.CANNED_MSG_EMPHASIS_OBVIOUS=1005]="CANNED_MSG_EMPHASIS_OBVIOUS",e[e.CANNED_MSG_EMPHASIS_CANT_YOU_SEE=1006]="CANNED_MSG_EMPHASIS_CANT_YOU_SEE",e[e.CANNED_MSG_EMPHASIS_WAKE_UP=1007]="CANNED_MSG_EMPHASIS_WAKE_UP",e[e.CANNED_MSG_EMPHASIS_PAY_ATTENTION=1008]="CANNED_MSG_EMPHASIS_PAY_ATTENTION",e[e.CANNED_MSG_EMPHASIS_THINK=1009]="CANNED_MSG_EMPHASIS_THINK",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(FC||(FC={}));var VC;(function(e){e[e.REPLAY_TYPE_UNSPECIFIED=0]="REPLAY_TYPE_UNSPECIFIED",e[e.REPLAY_TYPE_CHALLENGE=1]="REPLAY_TYPE_CHALLENGE",e[e.REPLAY_TYPE_LOBBY=2]="REPLAY_TYPE_LOBBY",e[e.REPLAY_TYPE_BOT_GAME=3]="REPLAY_TYPE_BOT_GAME",e[e.REPLAY_TYPE_IMPORTED=4]="REPLAY_TYPE_IMPORTED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(VC||(VC={}));var xC;(function(e){e[e.REPLAY_VIEW_MODE_UNSPECIFIED=0]="REPLAY_VIEW_MODE_UNSPECIFIED",e[e.REPLAY_VIEW_MODE_SPECTATOR=1]="REPLAY_VIEW_MODE_SPECTATOR",e[e.REPLAY_VIEW_MODE_PLAYER=2]="REPLAY_VIEW_MODE_PLAYER",e[e.REPLAY_VIEW_MODE_OMNISCIENT=3]="REPLAY_VIEW_MODE_OMNISCIENT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(xC||(xC={}));function wC(){return{eventIndex:0,winProbs:{}}}E(wC,"createBaseEvalStepInfo");var Zn={encode(e,r=new WC){return e.eventIndex!==0&&r.uint32(8).int32(e.eventIndex),globalThis.Object.entries(e.winProbs).forEach(([t,o])=>{Uc.encode({key:t,value:o},r.uint32(18).fork()).join()}),r},decode(e,r){let t=e instanceof Cu?e:new Cu(e),o=r===void 0?t.len:t.pos+r,i=wC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.eventIndex=t.int32();continue}case 2:{if(n!==18)break;let a=Uc.decode(t,t.uint32());a.value!==void 0&&(i.winProbs[a.key]=a.value);continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{eventIndex:Pu(e.eventIndex)?globalThis.Number(e.eventIndex):Pu(e.event_index)?globalThis.Number(e.event_index):0,winProbs:KC(e.winProbs)?globalThis.Object.entries(e.winProbs).reduce((r,[t,o])=>(r[globalThis.Number(t)]=globalThis.Number(o),r),{}):KC(e.win_probs)?globalThis.Object.entries(e.win_probs).reduce((r,[t,o])=>(r[globalThis.Number(t)]=globalThis.Number(o),r),{}):{}}},toJSON(e){let r={};if(e.eventIndex!==0&&(r.eventIndex=Math.round(e.eventIndex)),e.winProbs){let t=globalThis.Object.entries(e.winProbs);t.length>0&&(r.winProbs={},t.forEach(([o,i])=>{r.winProbs[o]=i}))}return r},create(e){return Zn.fromPartial(e??{})},fromPartial(e){let r=wC();return r.eventIndex=e.eventIndex??0,r.winProbs=globalThis.Object.entries(e.winProbs??{}).reduce((t,[o,i])=>(i!==void 0&&(t[globalThis.Number(o)]=globalThis.Number(i)),t),{}),r}};function HC(){return{key:0,value:0}}E(HC,"createBaseEvalStepInfo_WinProbsEntry");var Uc={encode(e,r=new WC){return e.key!==0&&r.uint32(8).int32(e.key),e.value!==0&&r.uint32(21).float(e.value),r},decode(e,r){let t=e instanceof Cu?e:new Cu(e),o=r===void 0?t.len:t.pos+r,i=HC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.key=t.int32();continue}case 2:{if(n!==21)break;i.value=t.float();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{key:Pu(e.key)?globalThis.Number(e.key):0,value:Pu(e.value)?globalThis.Number(e.value):0}},toJSON(e){let r={};return e.key!==0&&(r.key=Math.round(e.key)),e.value!==0&&(r.value=e.value),r},create(e){return Uc.fromPartial(e??{})},fromPartial(e){let r=HC();return r.key=e.key??0,r.value=e.value??0,r}};function KC(e){return typeof e=="object"&&e!==null}E(KC,"isObject");function Pu(e){return e!=null}E(Pu,"isSet");var ye;(function(e){e[e.GAME_ACTION_UNSPECIFIED=0]="GAME_ACTION_UNSPECIFIED",e[e.GAME_ACTION_BOT_MOVE=1]="GAME_ACTION_BOT_MOVE",e[e.GAME_ACTION_SEND_PING=2]="GAME_ACTION_SEND_PING",e[e.GAME_ACTION_SUBMIT_GAME_FEEDBACK=3]="GAME_ACTION_SUBMIT_GAME_FEEDBACK",e[e.GAME_ACTION_SAVE_BOT_GAME_REPLAY=4]="GAME_ACTION_SAVE_BOT_GAME_REPLAY",e[e.GAME_ACTION_SEND_GAME_CHAT=5]="GAME_ACTION_SEND_GAME_CHAT",e[e.GAME_ACTION_TOGGLE_CHAT_REACTION=6]="GAME_ACTION_TOGGLE_CHAT_REACTION",e[e.GAME_ACTION_JOIN_GAME_AS_SPECTATOR=7]="GAME_ACTION_JOIN_GAME_AS_SPECTATOR",e[e.GAME_ACTION_UPDATE_PLAYER_LOADING_STATUS=8]="GAME_ACTION_UPDATE_PLAYER_LOADING_STATUS",e[e.GAME_ACTION_GET_REPLAY=9]="GAME_ACTION_GET_REPLAY",e[e.GAME_ACTION_GET_REPLAY_URL=10]="GAME_ACTION_GET_REPLAY_URL",e[e.GAME_ACTION_REPORT_TIME_EXPIRED=11]="GAME_ACTION_REPORT_TIME_EXPIRED",e[e.GAME_ACTION_REPORT_PAUSE_EXPIRED=12]="GAME_ACTION_REPORT_PAUSE_EXPIRED",e[e.GAME_ACTION_REPORT_RUSH_DICE_ROLL=13]="GAME_ACTION_REPORT_RUSH_DICE_ROLL",e[e.GAME_ACTION_REPORT_INACTIVITY=14]="GAME_ACTION_REPORT_INACTIVITY",e[e.GAME_ACTION_RETURN_FROM_TAKEOVER=15]="GAME_ACTION_RETURN_FROM_TAKEOVER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(ye||(ye={}));function JC(e){switch(e){case 0:case"GAME_ACTION_UNSPECIFIED":return ye.GAME_ACTION_UNSPECIFIED;case 1:case"GAME_ACTION_BOT_MOVE":return ye.GAME_ACTION_BOT_MOVE;case 2:case"GAME_ACTION_SEND_PING":return ye.GAME_ACTION_SEND_PING;case 3:case"GAME_ACTION_SUBMIT_GAME_FEEDBACK":return ye.GAME_ACTION_SUBMIT_GAME_FEEDBACK;case 4:case"GAME_ACTION_SAVE_BOT_GAME_REPLAY":return ye.GAME_ACTION_SAVE_BOT_GAME_REPLAY;case 5:case"GAME_ACTION_SEND_GAME_CHAT":return ye.GAME_ACTION_SEND_GAME_CHAT;case 6:case"GAME_ACTION_TOGGLE_CHAT_REACTION":return ye.GAME_ACTION_TOGGLE_CHAT_REACTION;case 7:case"GAME_ACTION_JOIN_GAME_AS_SPECTATOR":return ye.GAME_ACTION_JOIN_GAME_AS_SPECTATOR;case 8:case"GAME_ACTION_UPDATE_PLAYER_LOADING_STATUS":return ye.GAME_ACTION_UPDATE_PLAYER_LOADING_STATUS;case 9:case"GAME_ACTION_GET_REPLAY":return ye.GAME_ACTION_GET_REPLAY;case 10:case"GAME_ACTION_GET_REPLAY_URL":return ye.GAME_ACTION_GET_REPLAY_URL;case 11:case"GAME_ACTION_REPORT_TIME_EXPIRED":return ye.GAME_ACTION_REPORT_TIME_EXPIRED;case 12:case"GAME_ACTION_REPORT_PAUSE_EXPIRED":return ye.GAME_ACTION_REPORT_PAUSE_EXPIRED;case 13:case"GAME_ACTION_REPORT_RUSH_DICE_ROLL":return ye.GAME_ACTION_REPORT_RUSH_DICE_ROLL;case 14:case"GAME_ACTION_REPORT_INACTIVITY":return ye.GAME_ACTION_REPORT_INACTIVITY;case 15:case"GAME_ACTION_RETURN_FROM_TAKEOVER":return ye.GAME_ACTION_RETURN_FROM_TAKEOVER;default:return ye.UNRECOGNIZED}}E(JC,"gameActionTypeFromJSON");function uy(e){switch(e){case ye.GAME_ACTION_UNSPECIFIED:return"GAME_ACTION_UNSPECIFIED";case ye.GAME_ACTION_BOT_MOVE:return"GAME_ACTION_BOT_MOVE";case ye.GAME_ACTION_SEND_PING:return"GAME_ACTION_SEND_PING";case ye.GAME_ACTION_SUBMIT_GAME_FEEDBACK:return"GAME_ACTION_SUBMIT_GAME_FEEDBACK";case ye.GAME_ACTION_SAVE_BOT_GAME_REPLAY:return"GAME_ACTION_SAVE_BOT_GAME_REPLAY";case ye.GAME_ACTION_SEND_GAME_CHAT:return"GAME_ACTION_SEND_GAME_CHAT";case ye.GAME_ACTION_TOGGLE_CHAT_REACTION:return"GAME_ACTION_TOGGLE_CHAT_REACTION";case ye.GAME_ACTION_JOIN_GAME_AS_SPECTATOR:return"GAME_ACTION_JOIN_GAME_AS_SPECTATOR";case ye.GAME_ACTION_UPDATE_PLAYER_LOADING_STATUS:return"GAME_ACTION_UPDATE_PLAYER_LOADING_STATUS";case ye.GAME_ACTION_GET_REPLAY:return"GAME_ACTION_GET_REPLAY";case ye.GAME_ACTION_GET_REPLAY_URL:return"GAME_ACTION_GET_REPLAY_URL";case ye.GAME_ACTION_REPORT_TIME_EXPIRED:return"GAME_ACTION_REPORT_TIME_EXPIRED";case ye.GAME_ACTION_REPORT_PAUSE_EXPIRED:return"GAME_ACTION_REPORT_PAUSE_EXPIRED";case ye.GAME_ACTION_REPORT_RUSH_DICE_ROLL:return"GAME_ACTION_REPORT_RUSH_DICE_ROLL";case ye.GAME_ACTION_REPORT_INACTIVITY:return"GAME_ACTION_REPORT_INACTIVITY";case ye.GAME_ACTION_RETURN_FROM_TAKEOVER:return"GAME_ACTION_RETURN_FROM_TAKEOVER";case ye.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(uy,"gameActionTypeToJSON");var tn;(function(e){e[e.FEEDBACK_RATING_UNSPECIFIED=0]="FEEDBACK_RATING_UNSPECIFIED",e[e.FEEDBACK_RATING_POSITIVE=1]="FEEDBACK_RATING_POSITIVE",e[e.FEEDBACK_RATING_NEGATIVE=2]="FEEDBACK_RATING_NEGATIVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(tn||(tn={}));function Ey(e){switch(e){case 0:case"FEEDBACK_RATING_UNSPECIFIED":return tn.FEEDBACK_RATING_UNSPECIFIED;case 1:case"FEEDBACK_RATING_POSITIVE":return tn.FEEDBACK_RATING_POSITIVE;case 2:case"FEEDBACK_RATING_NEGATIVE":return tn.FEEDBACK_RATING_NEGATIVE;default:return tn.UNRECOGNIZED}}E(Ey,"feedbackRatingFromJSON");function ly(e){switch(e){case tn.FEEDBACK_RATING_UNSPECIFIED:return"FEEDBACK_RATING_UNSPECIFIED";case tn.FEEDBACK_RATING_POSITIVE:return"FEEDBACK_RATING_POSITIVE";case tn.FEEDBACK_RATING_NEGATIVE:return"FEEDBACK_RATING_NEGATIVE";case tn.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(ly,"feedbackRatingToJSON");var qC;(function(e){e[e.GAME_SOURCE_UNSPECIFIED=0]="GAME_SOURCE_UNSPECIFIED",e[e.GAME_SOURCE_LOBBY=1]="GAME_SOURCE_LOBBY",e[e.GAME_SOURCE_MATCHMAKING=2]="GAME_SOURCE_MATCHMAKING",e[e.GAME_SOURCE_BOT_GAME=3]="GAME_SOURCE_BOT_GAME",e[e.GAME_SOURCE_ARENA=4]="GAME_SOURCE_ARENA",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(qC||(qC={}));var hs;(function(e){e[e.GAME_STATUS_UNSPECIFIED=0]="GAME_STATUS_UNSPECIFIED",e[e.GAME_STATUS_LOADING=1]="GAME_STATUS_LOADING",e[e.GAME_STATUS_ACTIVE=2]="GAME_STATUS_ACTIVE",e[e.GAME_STATUS_COMPLETED=3]="GAME_STATUS_COMPLETED",e[e.GAME_STATUS_ABANDONED=4]="GAME_STATUS_ABANDONED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(hs||(hs={}));var qr;(function(e){e[e.PLAYER_LOADING_STATUS_UNSPECIFIED=0]="PLAYER_LOADING_STATUS_UNSPECIFIED",e[e.PLAYER_LOADING_STATUS_LOADING=1]="PLAYER_LOADING_STATUS_LOADING",e[e.PLAYER_LOADING_STATUS_READY=2]="PLAYER_LOADING_STATUS_READY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(qr||(qr={}));function cy(e){switch(e){case 0:case"PLAYER_LOADING_STATUS_UNSPECIFIED":return qr.PLAYER_LOADING_STATUS_UNSPECIFIED;case 1:case"PLAYER_LOADING_STATUS_LOADING":return qr.PLAYER_LOADING_STATUS_LOADING;case 2:case"PLAYER_LOADING_STATUS_READY":return qr.PLAYER_LOADING_STATUS_READY;default:return qr.UNRECOGNIZED}}E(cy,"playerLoadingStatusFromJSON");function fy(e){switch(e){case qr.PLAYER_LOADING_STATUS_UNSPECIFIED:return"PLAYER_LOADING_STATUS_UNSPECIFIED";case qr.PLAYER_LOADING_STATUS_LOADING:return"PLAYER_LOADING_STATUS_LOADING";case qr.PLAYER_LOADING_STATUS_READY:return"PLAYER_LOADING_STATUS_READY";case qr.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(fy,"playerLoadingStatusToJSON");function ZC(){return{color:0,isBot:!1,botType:""}}E(ZC,"createBaseBotGamePlayerSlot");var to={encode(e,r=new Ge){return e.color!==0&&r.uint32(8).int32(e.color),e.isBot!==!1&&r.uint32(16).bool(e.isBot),e.botType!==""&&r.uint32(26).string(e.botType),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=ZC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.color=t.int32();continue}case 2:{if(n!==16)break;i.isBot=t.bool();continue}case 3:{if(n!==26)break;i.botType=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{color:U(e.color)?Ke(e.color):0,isBot:U(e.isBot)?globalThis.Boolean(e.isBot):U(e.is_bot)?globalThis.Boolean(e.is_bot):!1,botType:U(e.botType)?globalThis.String(e.botType):U(e.bot_type)?globalThis.String(e.bot_type):""}},toJSON(e){let r={};return e.color!==0&&(r.color=_r(e.color)),e.isBot!==!1&&(r.isBot=e.isBot),e.botType!==""&&(r.botType=e.botType),r},create(e){return to.fromPartial(e??{})},fromPartial(e){let r=ZC();return r.color=e.color??0,r.isBot=e.isBot??!1,r.botType=e.botType??"",r}};function XC(){return{gameId:"",turnNumber:0}}E(XC,"createBaseBotMoveParams");var no={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.turnNumber!==0&&r.uint32(16).int32(e.turnNumber),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=XC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==16)break;i.turnNumber=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",turnNumber:U(e.turnNumber)?globalThis.Number(e.turnNumber):U(e.turn_number)?globalThis.Number(e.turn_number):0}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.turnNumber!==0&&(r.turnNumber=Math.round(e.turnNumber)),r},create(e){return no.fromPartial(e??{})},fromPartial(e){let r=XC();return r.gameId=e.gameId??"",r.turnNumber=e.turnNumber??0,r}};function zC(){return{gameId:"",pingData:new Uint8Array(0)}}E(zC,"createBaseSendPingParams");var io={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.pingData.length!==0&&r.uint32(18).bytes(e.pingData),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=zC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==18)break;i.pingData=t.bytes();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",pingData:U(e.pingData)?ko(e.pingData):U(e.ping_data)?ko(e.ping_data):new Uint8Array(0)}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.pingData.length!==0&&(r.pingData=pu(e.pingData)),r},create(e){return io.fromPartial(e??{})},fromPartial(e){let r=zC();return r.gameId=e.gameId??"",r.pingData=e.pingData??new Uint8Array(0),r}};function $C(){return{gameId:"",rating:0,reason:"",customReason:"",isWinner:!1}}E($C,"createBaseSubmitGameFeedbackParams");var oo={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.rating!==0&&r.uint32(16).int32(e.rating),e.reason!==""&&r.uint32(26).string(e.reason),e.customReason!==""&&r.uint32(34).string(e.customReason),e.isWinner!==!1&&r.uint32(40).bool(e.isWinner),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=$C();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==16)break;i.rating=t.int32();continue}case 3:{if(n!==26)break;i.reason=t.string();continue}case 4:{if(n!==34)break;i.customReason=t.string();continue}case 5:{if(n!==40)break;i.isWinner=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",rating:U(e.rating)?Ey(e.rating):0,reason:U(e.reason)?globalThis.String(e.reason):"",customReason:U(e.customReason)?globalThis.String(e.customReason):U(e.custom_reason)?globalThis.String(e.custom_reason):"",isWinner:U(e.isWinner)?globalThis.Boolean(e.isWinner):U(e.is_winner)?globalThis.Boolean(e.is_winner):!1}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.rating!==0&&(r.rating=ly(e.rating)),e.reason!==""&&(r.reason=e.reason),e.customReason!==""&&(r.customReason=e.customReason),e.isWinner!==!1&&(r.isWinner=e.isWinner),r},create(e){return oo.fromPartial(e??{})},fromPartial(e){let r=$C();return r.gameId=e.gameId??"",r.rating=e.rating??0,r.reason=e.reason??"",r.customReason=e.customReason??"",r.isWinner=e.isWinner??!1,r}};function QC(){return{initialGameState:new Uint8Array(0),events:[],playerSlots:[],winner:0,startedAt:void 0,completedAt:void 0,victoryPoints:0,expansions:[],botBattleMode:"",botBattleLevel:0,jaxModel:"",jaxSims:0,evalData:[],titanMode:"",botLadderMode:"",botLadderGameId:""}}E(QC,"createBaseSaveBotGameReplayParams");var ao={encode(e,r=new Ge){e.initialGameState.length!==0&&r.uint32(10).bytes(e.initialGameState);for(let t of e.events)r.uint32(18).bytes(t);for(let t of e.playerSlots)to.encode(t,r.uint32(26).fork()).join();e.winner!==0&&r.uint32(32).int32(e.winner),e.startedAt!==void 0&&Le.encode(hu(e.startedAt),r.uint32(42).fork()).join(),e.completedAt!==void 0&&Le.encode(hu(e.completedAt),r.uint32(50).fork()).join(),e.victoryPoints!==0&&r.uint32(56).int32(e.victoryPoints);for(let t of e.expansions)r.uint32(66).string(t);e.botBattleMode!==""&&r.uint32(74).string(e.botBattleMode),e.botBattleLevel!==0&&r.uint32(80).int32(e.botBattleLevel),e.jaxModel!==""&&r.uint32(90).string(e.jaxModel),e.jaxSims!==0&&r.uint32(96).int32(e.jaxSims);for(let t of e.evalData)Zn.encode(t,r.uint32(106).fork()).join();return e.titanMode!==""&&r.uint32(114).string(e.titanMode),e.botLadderMode!==""&&r.uint32(122).string(e.botLadderMode),e.botLadderGameId!==""&&r.uint32(130).string(e.botLadderGameId),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=QC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.initialGameState=t.bytes();continue}case 2:{if(n!==18)break;i.events.push(t.bytes());continue}case 3:{if(n!==26)break;i.playerSlots.push(to.decode(t,t.uint32()));continue}case 4:{if(n!==32)break;i.winner=t.int32();continue}case 5:{if(n!==42)break;i.startedAt=X_(Le.decode(t,t.uint32()));continue}case 6:{if(n!==50)break;i.completedAt=X_(Le.decode(t,t.uint32()));continue}case 7:{if(n!==56)break;i.victoryPoints=t.int32();continue}case 8:{if(n!==66)break;i.expansions.push(t.string());continue}case 9:{if(n!==74)break;i.botBattleMode=t.string();continue}case 10:{if(n!==80)break;i.botBattleLevel=t.int32();continue}case 11:{if(n!==90)break;i.jaxModel=t.string();continue}case 12:{if(n!==96)break;i.jaxSims=t.int32();continue}case 13:{if(n!==106)break;i.evalData.push(Zn.decode(t,t.uint32()));continue}case 14:{if(n!==114)break;i.titanMode=t.string();continue}case 15:{if(n!==122)break;i.botLadderMode=t.string();continue}case 16:{if(n!==130)break;i.botLadderGameId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{initialGameState:U(e.initialGameState)?ko(e.initialGameState):U(e.initial_game_state)?ko(e.initial_game_state):new Uint8Array(0),events:globalThis.Array.isArray(e?.events)?e.events.map(r=>ko(r)):[],playerSlots:globalThis.Array.isArray(e?.playerSlots)?e.playerSlots.map(r=>to.fromJSON(r)):globalThis.Array.isArray(e?.player_slots)?e.player_slots.map(r=>to.fromJSON(r)):[],winner:U(e.winner)?Ke(e.winner):0,startedAt:U(e.startedAt)?Xn(e.startedAt):U(e.started_at)?Xn(e.started_at):void 0,completedAt:U(e.completedAt)?Xn(e.completedAt):U(e.completed_at)?Xn(e.completed_at):void 0,victoryPoints:U(e.victoryPoints)?globalThis.Number(e.victoryPoints):U(e.victory_points)?globalThis.Number(e.victory_points):0,expansions:globalThis.Array.isArray(e?.expansions)?e.expansions.map(r=>globalThis.String(r)):[],botBattleMode:U(e.botBattleMode)?globalThis.String(e.botBattleMode):U(e.bot_battle_mode)?globalThis.String(e.bot_battle_mode):"",botBattleLevel:U(e.botBattleLevel)?globalThis.Number(e.botBattleLevel):U(e.bot_battle_level)?globalThis.Number(e.bot_battle_level):0,jaxModel:U(e.jaxModel)?globalThis.String(e.jaxModel):U(e.jax_model)?globalThis.String(e.jax_model):"",jaxSims:U(e.jaxSims)?globalThis.Number(e.jaxSims):U(e.jax_sims)?globalThis.Number(e.jax_sims):0,evalData:globalThis.Array.isArray(e?.evalData)?e.evalData.map(r=>Zn.fromJSON(r)):globalThis.Array.isArray(e?.eval_data)?e.eval_data.map(r=>Zn.fromJSON(r)):[],titanMode:U(e.titanMode)?globalThis.String(e.titanMode):U(e.titan_mode)?globalThis.String(e.titan_mode):"",botLadderMode:U(e.botLadderMode)?globalThis.String(e.botLadderMode):U(e.bot_ladder_mode)?globalThis.String(e.bot_ladder_mode):"",botLadderGameId:U(e.botLadderGameId)?globalThis.String(e.botLadderGameId):U(e.bot_ladder_game_id)?globalThis.String(e.bot_ladder_game_id):""}},toJSON(e){let r={};return e.initialGameState.length!==0&&(r.initialGameState=pu(e.initialGameState)),e.events?.length&&(r.events=e.events.map(t=>pu(t))),e.playerSlots?.length&&(r.playerSlots=e.playerSlots.map(t=>to.toJSON(t))),e.winner!==0&&(r.winner=_r(e.winner)),e.startedAt!==void 0&&(r.startedAt=e.startedAt.toISOString()),e.completedAt!==void 0&&(r.completedAt=e.completedAt.toISOString()),e.victoryPoints!==0&&(r.victoryPoints=Math.round(e.victoryPoints)),e.expansions?.length&&(r.expansions=e.expansions),e.botBattleMode!==""&&(r.botBattleMode=e.botBattleMode),e.botBattleLevel!==0&&(r.botBattleLevel=Math.round(e.botBattleLevel)),e.jaxModel!==""&&(r.jaxModel=e.jaxModel),e.jaxSims!==0&&(r.jaxSims=Math.round(e.jaxSims)),e.evalData?.length&&(r.evalData=e.evalData.map(t=>Zn.toJSON(t))),e.titanMode!==""&&(r.titanMode=e.titanMode),e.botLadderMode!==""&&(r.botLadderMode=e.botLadderMode),e.botLadderGameId!==""&&(r.botLadderGameId=e.botLadderGameId),r},create(e){return ao.fromPartial(e??{})},fromPartial(e){let r=QC();return r.initialGameState=e.initialGameState??new Uint8Array(0),r.events=e.events?.map(t=>t)||[],r.playerSlots=e.playerSlots?.map(t=>to.fromPartial(t))||[],r.winner=e.winner??0,r.startedAt=e.startedAt??void 0,r.completedAt=e.completedAt??void 0,r.victoryPoints=e.victoryPoints??0,r.expansions=e.expansions?.map(t=>t)||[],r.botBattleMode=e.botBattleMode??"",r.botBattleLevel=e.botBattleLevel??0,r.jaxModel=e.jaxModel??"",r.jaxSims=e.jaxSims??0,r.evalData=e.evalData?.map(t=>Zn.fromPartial(t))||[],r.titanMode=e.titanMode??"",r.botLadderMode=e.botLadderMode??"",r.botLadderGameId=e.botLadderGameId??"",r}};function jC(){return{gameId:"",message:"",cannedMessageId:"",cannedParams:{},targetChannel:""}}E(jC,"createBaseSendGameChatParams");var so={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.message!==""&&r.uint32(18).string(e.message),e.cannedMessageId!==""&&r.uint32(26).string(e.cannedMessageId),globalThis.Object.entries(e.cannedParams).forEach(([t,o])=>{Bc.encode({key:t,value:o},r.uint32(34).fork()).join()}),e.targetChannel!==""&&r.uint32(42).string(e.targetChannel),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=jC();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==18)break;i.message=t.string();continue}case 3:{if(n!==26)break;i.cannedMessageId=t.string();continue}case 4:{if(n!==34)break;let a=Bc.decode(t,t.uint32());a.value!==void 0&&(i.cannedParams[a.key]=a.value);continue}case 5:{if(n!==42)break;i.targetChannel=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",message:U(e.message)?globalThis.String(e.message):"",cannedMessageId:U(e.cannedMessageId)?globalThis.String(e.cannedMessageId):U(e.canned_message_id)?globalThis.String(e.canned_message_id):"",cannedParams:LP(e.cannedParams)?globalThis.Object.entries(e.cannedParams).reduce((r,[t,o])=>(r[t]=globalThis.String(o),r),{}):LP(e.canned_params)?globalThis.Object.entries(e.canned_params).reduce((r,[t,o])=>(r[t]=globalThis.String(o),r),{}):{},targetChannel:U(e.targetChannel)?globalThis.String(e.targetChannel):U(e.target_channel)?globalThis.String(e.target_channel):""}},toJSON(e){let r={};if(e.gameId!==""&&(r.gameId=e.gameId),e.message!==""&&(r.message=e.message),e.cannedMessageId!==""&&(r.cannedMessageId=e.cannedMessageId),e.cannedParams){let t=globalThis.Object.entries(e.cannedParams);t.length>0&&(r.cannedParams={},t.forEach(([o,i])=>{r.cannedParams[o]=i}))}return e.targetChannel!==""&&(r.targetChannel=e.targetChannel),r},create(e){return so.fromPartial(e??{})},fromPartial(e){let r=jC();return r.gameId=e.gameId??"",r.message=e.message??"",r.cannedMessageId=e.cannedMessageId??"",r.cannedParams=globalThis.Object.entries(e.cannedParams??{}).reduce((t,[o,i])=>(i!==void 0&&(t[o]=globalThis.String(i)),t),{}),r.targetChannel=e.targetChannel??"",r}};function eP(){return{key:"",value:""}}E(eP,"createBaseSendGameChatParams_CannedParamsEntry");var Bc={encode(e,r=new Ge){return e.key!==""&&r.uint32(10).string(e.key),e.value!==""&&r.uint32(18).string(e.value),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=eP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.key=t.string();continue}case 2:{if(n!==18)break;i.value=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{key:U(e.key)?globalThis.String(e.key):"",value:U(e.value)?globalThis.String(e.value):""}},toJSON(e){let r={};return e.key!==""&&(r.key=e.key),e.value!==""&&(r.value=e.value),r},create(e){return Bc.fromPartial(e??{})},fromPartial(e){let r=eP();return r.key=e.key??"",r.value=e.value??"",r}};function rP(){return{gameId:"",messageId:"",emoji:""}}E(rP,"createBaseToggleChatReactionParams");var _o={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.messageId!==""&&r.uint32(18).string(e.messageId),e.emoji!==""&&r.uint32(26).string(e.emoji),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=rP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==18)break;i.messageId=t.string();continue}case 3:{if(n!==26)break;i.emoji=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",messageId:U(e.messageId)?globalThis.String(e.messageId):U(e.message_id)?globalThis.String(e.message_id):"",emoji:U(e.emoji)?globalThis.String(e.emoji):""}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.messageId!==""&&(r.messageId=e.messageId),e.emoji!==""&&(r.emoji=e.emoji),r},create(e){return _o.fromPartial(e??{})},fromPartial(e){let r=rP();return r.gameId=e.gameId??"",r.messageId=e.messageId??"",r.emoji=e.emoji??"",r}};function tP(){return{gameId:"",displayName:""}}E(tP,"createBaseJoinGameAsSpectatorParams");var uo={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.displayName!==""&&r.uint32(18).string(e.displayName),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=tP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==18)break;i.displayName=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",displayName:U(e.displayName)?globalThis.String(e.displayName):U(e.display_name)?globalThis.String(e.display_name):""}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.displayName!==""&&(r.displayName=e.displayName),r},create(e){return uo.fromPartial(e??{})},fromPartial(e){let r=tP();return r.gameId=e.gameId??"",r.displayName=e.displayName??"",r}};function nP(){return{gameId:"",status:0}}E(nP,"createBaseUpdatePlayerLoadingStatusParams");var Eo={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.status!==0&&r.uint32(16).int32(e.status),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=nP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==16)break;i.status=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",status:U(e.status)?cy(e.status):0}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.status!==0&&(r.status=fy(e.status)),r},create(e){return Eo.fromPartial(e??{})},fromPartial(e){let r=nP();return r.gameId=e.gameId??"",r.status=e.status??0,r}};function iP(){return{gameId:""}}E(iP,"createBaseGetReplayParams");var lo={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=iP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):""}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),r},create(e){return lo.fromPartial(e??{})},fromPartial(e){let r=iP();return r.gameId=e.gameId??"",r}};function oP(){return{gameId:""}}E(oP,"createBaseGetReplayUrlParams");var co={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=oP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):""}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),r},create(e){return co.fromPartial(e??{})},fromPartial(e){let r=oP();return r.gameId=e.gameId??"",r}};function aP(){return{resource:0,count:0}}E(aP,"createBaseResourceCount");var fo={encode(e,r=new Ge){return e.resource!==0&&r.uint32(8).int32(e.resource),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=aP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.resource=t.int32();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{resource:U(e.resource)?$t(e.resource):0,count:U(e.count)?globalThis.Number(e.count):0}},toJSON(e){let r={};return e.resource!==0&&(r.resource=Qt(e.resource)),e.count!==0&&(r.count=Math.round(e.count)),r},create(e){return fo.fromPartial(e??{})},fromPartial(e){let r=aP();return r.resource=e.resource??0,r.count=e.count??0,r}};function sP(){return{gameId:"",turnNumber:0,selectedResourcesToDiscard:[],action:0}}E(sP,"createBaseReportTimeExpiredParams");var To={encode(e,r=new Ge){e.gameId!==""&&r.uint32(10).string(e.gameId),e.turnNumber!==0&&r.uint32(16).int32(e.turnNumber);for(let t of e.selectedResourcesToDiscard)fo.encode(t,r.uint32(26).fork()).join();return e.action!==0&&r.uint32(32).int32(e.action),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=sP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==16)break;i.turnNumber=t.int32();continue}case 3:{if(n!==26)break;i.selectedResourcesToDiscard.push(fo.decode(t,t.uint32()));continue}case 4:{if(n!==32)break;i.action=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",turnNumber:U(e.turnNumber)?globalThis.Number(e.turnNumber):U(e.turn_number)?globalThis.Number(e.turn_number):0,selectedResourcesToDiscard:globalThis.Array.isArray(e?.selectedResourcesToDiscard)?e.selectedResourcesToDiscard.map(r=>fo.fromJSON(r)):globalThis.Array.isArray(e?.selected_resources_to_discard)?e.selected_resources_to_discard.map(r=>fo.fromJSON(r)):[],action:U(e.action)?globalThis.Number(e.action):0}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.turnNumber!==0&&(r.turnNumber=Math.round(e.turnNumber)),e.selectedResourcesToDiscard?.length&&(r.selectedResourcesToDiscard=e.selectedResourcesToDiscard.map(t=>fo.toJSON(t))),e.action!==0&&(r.action=Math.round(e.action)),r},create(e){return To.fromPartial(e??{})},fromPartial(e){let r=sP();return r.gameId=e.gameId??"",r.turnNumber=e.turnNumber??0,r.selectedResourcesToDiscard=e.selectedResourcesToDiscard?.map(t=>fo.fromPartial(t))||[],r.action=e.action??0,r}};function _P(){return{gameId:"",pausedAt:void 0}}E(_P,"createBaseReportPauseExpiredParams");var No={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.pausedAt!==void 0&&Le.encode(hu(e.pausedAt),r.uint32(18).fork()).join(),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=_P();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==18)break;i.pausedAt=X_(Le.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",pausedAt:U(e.pausedAt)?Xn(e.pausedAt):U(e.paused_at)?Xn(e.paused_at):void 0}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.pausedAt!==void 0&&(r.pausedAt=e.pausedAt.toISOString()),r},create(e){return No.fromPartial(e??{})},fromPartial(e){let r=_P();return r.gameId=e.gameId??"",r.pausedAt=e.pausedAt??void 0,r}};function dP(){return{gameId:"",turnNumber:0}}E(dP,"createBaseReportRushDiceRollParams");var Ro={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.turnNumber!==0&&r.uint32(16).int32(e.turnNumber),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=dP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==16)break;i.turnNumber=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",turnNumber:U(e.turnNumber)?globalThis.Number(e.turnNumber):U(e.turn_number)?globalThis.Number(e.turn_number):0}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.turnNumber!==0&&(r.turnNumber=Math.round(e.turnNumber)),r},create(e){return Ro.fromPartial(e??{})},fromPartial(e){let r=dP();return r.gameId=e.gameId??"",r.turnNumber=e.turnNumber??0,r}};function uP(){return{gameId:"",color:0}}E(uP,"createBaseReportInactivityParams");var Ao={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.color!==0&&r.uint32(16).int32(e.color),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=uP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==16)break;i.color=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",color:U(e.color)?Ke(e.color):0}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.color!==0&&(r.color=_r(e.color)),r},create(e){return Ao.fromPartial(e??{})},fromPartial(e){let r=uP();return r.gameId=e.gameId??"",r.color=e.color??0,r}};function EP(){return{gameId:""}}E(EP,"createBaseReturnFromTakeoverParams");var So={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=EP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):""}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),r},create(e){return So.fromPartial(e??{})},fromPartial(e){let r=EP();return r.gameId=e.gameId??"",r}};function lP(){return{actionType:0,botMove:void 0,sendPing:void 0,submitGameFeedback:void 0,saveBotGameReplay:void 0,sendGameChat:void 0,toggleChatReaction:void 0,joinGameAsSpectator:void 0,updatePlayerLoadingStatus:void 0,getReplay:void 0,getReplayUrl:void 0,reportTimeExpired:void 0,reportPauseExpired:void 0,reportRushDiceRoll:void 0,reportInactivity:void 0,returnFromTakeover:void 0}}E(lP,"createBaseGameActionRequest");var Du={encode(e,r=new Ge){return e.actionType!==0&&r.uint32(8).int32(e.actionType),e.botMove!==void 0&&no.encode(e.botMove,r.uint32(18).fork()).join(),e.sendPing!==void 0&&io.encode(e.sendPing,r.uint32(26).fork()).join(),e.submitGameFeedback!==void 0&&oo.encode(e.submitGameFeedback,r.uint32(34).fork()).join(),e.saveBotGameReplay!==void 0&&ao.encode(e.saveBotGameReplay,r.uint32(42).fork()).join(),e.sendGameChat!==void 0&&so.encode(e.sendGameChat,r.uint32(50).fork()).join(),e.toggleChatReaction!==void 0&&_o.encode(e.toggleChatReaction,r.uint32(58).fork()).join(),e.joinGameAsSpectator!==void 0&&uo.encode(e.joinGameAsSpectator,r.uint32(66).fork()).join(),e.updatePlayerLoadingStatus!==void 0&&Eo.encode(e.updatePlayerLoadingStatus,r.uint32(74).fork()).join(),e.getReplay!==void 0&&lo.encode(e.getReplay,r.uint32(82).fork()).join(),e.getReplayUrl!==void 0&&co.encode(e.getReplayUrl,r.uint32(90).fork()).join(),e.reportTimeExpired!==void 0&&To.encode(e.reportTimeExpired,r.uint32(98).fork()).join(),e.reportPauseExpired!==void 0&&No.encode(e.reportPauseExpired,r.uint32(106).fork()).join(),e.reportRushDiceRoll!==void 0&&Ro.encode(e.reportRushDiceRoll,r.uint32(114).fork()).join(),e.reportInactivity!==void 0&&Ao.encode(e.reportInactivity,r.uint32(122).fork()).join(),e.returnFromTakeover!==void 0&&So.encode(e.returnFromTakeover,r.uint32(130).fork()).join(),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=lP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.actionType=t.int32();continue}case 2:{if(n!==18)break;i.botMove=no.decode(t,t.uint32());continue}case 3:{if(n!==26)break;i.sendPing=io.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.submitGameFeedback=oo.decode(t,t.uint32());continue}case 5:{if(n!==42)break;i.saveBotGameReplay=ao.decode(t,t.uint32());continue}case 6:{if(n!==50)break;i.sendGameChat=so.decode(t,t.uint32());continue}case 7:{if(n!==58)break;i.toggleChatReaction=_o.decode(t,t.uint32());continue}case 8:{if(n!==66)break;i.joinGameAsSpectator=uo.decode(t,t.uint32());continue}case 9:{if(n!==74)break;i.updatePlayerLoadingStatus=Eo.decode(t,t.uint32());continue}case 10:{if(n!==82)break;i.getReplay=lo.decode(t,t.uint32());continue}case 11:{if(n!==90)break;i.getReplayUrl=co.decode(t,t.uint32());continue}case 12:{if(n!==98)break;i.reportTimeExpired=To.decode(t,t.uint32());continue}case 13:{if(n!==106)break;i.reportPauseExpired=No.decode(t,t.uint32());continue}case 14:{if(n!==114)break;i.reportRushDiceRoll=Ro.decode(t,t.uint32());continue}case 15:{if(n!==122)break;i.reportInactivity=Ao.decode(t,t.uint32());continue}case 16:{if(n!==130)break;i.returnFromTakeover=So.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{actionType:U(e.actionType)?JC(e.actionType):U(e.action_type)?JC(e.action_type):0,botMove:U(e.botMove)?no.fromJSON(e.botMove):U(e.bot_move)?no.fromJSON(e.bot_move):void 0,sendPing:U(e.sendPing)?io.fromJSON(e.sendPing):U(e.send_ping)?io.fromJSON(e.send_ping):void 0,submitGameFeedback:U(e.submitGameFeedback)?oo.fromJSON(e.submitGameFeedback):U(e.submit_game_feedback)?oo.fromJSON(e.submit_game_feedback):void 0,saveBotGameReplay:U(e.saveBotGameReplay)?ao.fromJSON(e.saveBotGameReplay):U(e.save_bot_game_replay)?ao.fromJSON(e.save_bot_game_replay):void 0,sendGameChat:U(e.sendGameChat)?so.fromJSON(e.sendGameChat):U(e.send_game_chat)?so.fromJSON(e.send_game_chat):void 0,toggleChatReaction:U(e.toggleChatReaction)?_o.fromJSON(e.toggleChatReaction):U(e.toggle_chat_reaction)?_o.fromJSON(e.toggle_chat_reaction):void 0,joinGameAsSpectator:U(e.joinGameAsSpectator)?uo.fromJSON(e.joinGameAsSpectator):U(e.join_game_as_spectator)?uo.fromJSON(e.join_game_as_spectator):void 0,updatePlayerLoadingStatus:U(e.updatePlayerLoadingStatus)?Eo.fromJSON(e.updatePlayerLoadingStatus):U(e.update_player_loading_status)?Eo.fromJSON(e.update_player_loading_status):void 0,getReplay:U(e.getReplay)?lo.fromJSON(e.getReplay):U(e.get_replay)?lo.fromJSON(e.get_replay):void 0,getReplayUrl:U(e.getReplayUrl)?co.fromJSON(e.getReplayUrl):U(e.get_replay_url)?co.fromJSON(e.get_replay_url):void 0,reportTimeExpired:U(e.reportTimeExpired)?To.fromJSON(e.reportTimeExpired):U(e.report_time_expired)?To.fromJSON(e.report_time_expired):void 0,reportPauseExpired:U(e.reportPauseExpired)?No.fromJSON(e.reportPauseExpired):U(e.report_pause_expired)?No.fromJSON(e.report_pause_expired):void 0,reportRushDiceRoll:U(e.reportRushDiceRoll)?Ro.fromJSON(e.reportRushDiceRoll):U(e.report_rush_dice_roll)?Ro.fromJSON(e.report_rush_dice_roll):void 0,reportInactivity:U(e.reportInactivity)?Ao.fromJSON(e.reportInactivity):U(e.report_inactivity)?Ao.fromJSON(e.report_inactivity):void 0,returnFromTakeover:U(e.returnFromTakeover)?So.fromJSON(e.returnFromTakeover):U(e.return_from_takeover)?So.fromJSON(e.return_from_takeover):void 0}},toJSON(e){let r={};return e.actionType!==0&&(r.actionType=uy(e.actionType)),e.botMove!==void 0&&(r.botMove=no.toJSON(e.botMove)),e.sendPing!==void 0&&(r.sendPing=io.toJSON(e.sendPing)),e.submitGameFeedback!==void 0&&(r.submitGameFeedback=oo.toJSON(e.submitGameFeedback)),e.saveBotGameReplay!==void 0&&(r.saveBotGameReplay=ao.toJSON(e.saveBotGameReplay)),e.sendGameChat!==void 0&&(r.sendGameChat=so.toJSON(e.sendGameChat)),e.toggleChatReaction!==void 0&&(r.toggleChatReaction=_o.toJSON(e.toggleChatReaction)),e.joinGameAsSpectator!==void 0&&(r.joinGameAsSpectator=uo.toJSON(e.joinGameAsSpectator)),e.updatePlayerLoadingStatus!==void 0&&(r.updatePlayerLoadingStatus=Eo.toJSON(e.updatePlayerLoadingStatus)),e.getReplay!==void 0&&(r.getReplay=lo.toJSON(e.getReplay)),e.getReplayUrl!==void 0&&(r.getReplayUrl=co.toJSON(e.getReplayUrl)),e.reportTimeExpired!==void 0&&(r.reportTimeExpired=To.toJSON(e.reportTimeExpired)),e.reportPauseExpired!==void 0&&(r.reportPauseExpired=No.toJSON(e.reportPauseExpired)),e.reportRushDiceRoll!==void 0&&(r.reportRushDiceRoll=Ro.toJSON(e.reportRushDiceRoll)),e.reportInactivity!==void 0&&(r.reportInactivity=Ao.toJSON(e.reportInactivity)),e.returnFromTakeover!==void 0&&(r.returnFromTakeover=So.toJSON(e.returnFromTakeover)),r},create(e){return Du.fromPartial(e??{})},fromPartial(e){let r=lP();return r.actionType=e.actionType??0,r.botMove=e.botMove!==void 0&&e.botMove!==null?no.fromPartial(e.botMove):void 0,r.sendPing=e.sendPing!==void 0&&e.sendPing!==null?io.fromPartial(e.sendPing):void 0,r.submitGameFeedback=e.submitGameFeedback!==void 0&&e.submitGameFeedback!==null?oo.fromPartial(e.submitGameFeedback):void 0,r.saveBotGameReplay=e.saveBotGameReplay!==void 0&&e.saveBotGameReplay!==null?ao.fromPartial(e.saveBotGameReplay):void 0,r.sendGameChat=e.sendGameChat!==void 0&&e.sendGameChat!==null?so.fromPartial(e.sendGameChat):void 0,r.toggleChatReaction=e.toggleChatReaction!==void 0&&e.toggleChatReaction!==null?_o.fromPartial(e.toggleChatReaction):void 0,r.joinGameAsSpectator=e.joinGameAsSpectator!==void 0&&e.joinGameAsSpectator!==null?uo.fromPartial(e.joinGameAsSpectator):void 0,r.updatePlayerLoadingStatus=e.updatePlayerLoadingStatus!==void 0&&e.updatePlayerLoadingStatus!==null?Eo.fromPartial(e.updatePlayerLoadingStatus):void 0,r.getReplay=e.getReplay!==void 0&&e.getReplay!==null?lo.fromPartial(e.getReplay):void 0,r.getReplayUrl=e.getReplayUrl!==void 0&&e.getReplayUrl!==null?co.fromPartial(e.getReplayUrl):void 0,r.reportTimeExpired=e.reportTimeExpired!==void 0&&e.reportTimeExpired!==null?To.fromPartial(e.reportTimeExpired):void 0,r.reportPauseExpired=e.reportPauseExpired!==void 0&&e.reportPauseExpired!==null?No.fromPartial(e.reportPauseExpired):void 0,r.reportRushDiceRoll=e.reportRushDiceRoll!==void 0&&e.reportRushDiceRoll!==null?Ro.fromPartial(e.reportRushDiceRoll):void 0,r.reportInactivity=e.reportInactivity!==void 0&&e.reportInactivity!==null?Ao.fromPartial(e.reportInactivity):void 0,r.returnFromTakeover=e.returnFromTakeover!==void 0&&e.returnFromTakeover!==null?So.fromPartial(e.returnFromTakeover):void 0,r}};function cP(){return{actionExecuted:!1,eventCount:0}}E(cP,"createBaseBotMoveResult");var Oo={encode(e,r=new Ge){return e.actionExecuted!==!1&&r.uint32(8).bool(e.actionExecuted),e.eventCount!==0&&r.uint32(16).int32(e.eventCount),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=cP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.actionExecuted=t.bool();continue}case 2:{if(n!==16)break;i.eventCount=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{actionExecuted:U(e.actionExecuted)?globalThis.Boolean(e.actionExecuted):U(e.action_executed)?globalThis.Boolean(e.action_executed):!1,eventCount:U(e.eventCount)?globalThis.Number(e.eventCount):U(e.event_count)?globalThis.Number(e.event_count):0}},toJSON(e){let r={};return e.actionExecuted!==!1&&(r.actionExecuted=e.actionExecuted),e.eventCount!==0&&(r.eventCount=Math.round(e.eventCount)),r},create(e){return Oo.fromPartial(e??{})},fromPartial(e){let r=cP();return r.actionExecuted=e.actionExecuted??!1,r.eventCount=e.eventCount??0,r}};function fP(){return{}}E(fP,"createBaseSendPingResult");var Io={encode(e,r=new Ge){return r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=fP();for(;t.pos<o;){let n=t.uint32();if(n>>>3,(n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{}},toJSON(e){return{}},create(e){return Io.fromPartial(e??{})},fromPartial(e){return fP()}};function TP(){return{feedbackId:""}}E(TP,"createBaseSubmitGameFeedbackResult");var Co={encode(e,r=new Ge){return e.feedbackId!==""&&r.uint32(10).string(e.feedbackId),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=TP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.feedbackId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{feedbackId:U(e.feedbackId)?globalThis.String(e.feedbackId):U(e.feedback_id)?globalThis.String(e.feedback_id):""}},toJSON(e){let r={};return e.feedbackId!==""&&(r.feedbackId=e.feedbackId),r},create(e){return Co.fromPartial(e??{})},fromPartial(e){let r=TP();return r.feedbackId=e.feedbackId??"",r}};function NP(){return{gameId:""}}E(NP,"createBaseSaveBotGameReplayResult");var Po={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=NP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):""}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),r},create(e){return Po.fromPartial(e??{})},fromPartial(e){let r=NP();return r.gameId=e.gameId??"",r}};function RP(){return{}}E(RP,"createBaseSendGameChatResult");var po={encode(e,r=new Ge){return r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=RP();for(;t.pos<o;){let n=t.uint32();if(n>>>3,(n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{}},toJSON(e){return{}},create(e){return po.fromPartial(e??{})},fromPartial(e){return RP()}};function AP(){return{added:!1}}E(AP,"createBaseToggleChatReactionResult");var ho={encode(e,r=new Ge){return e.added!==!1&&r.uint32(8).bool(e.added),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=AP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.added=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{added:U(e.added)?globalThis.Boolean(e.added):!1}},toJSON(e){let r={};return e.added!==!1&&(r.added=e.added),r},create(e){return ho.fromPartial(e??{})},fromPartial(e){let r=AP();return r.added=e.added??!1,r}};function SP(){return{}}E(SP,"createBaseJoinGameAsSpectatorResult");var Do={encode(e,r=new Ge){return r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=SP();for(;t.pos<o;){let n=t.uint32();if(n>>>3,(n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{}},toJSON(e){return{}},create(e){return Do.fromPartial(e??{})},fromPartial(e){return SP()}};function OP(){return{allReady:!1}}E(OP,"createBaseUpdatePlayerLoadingStatusResult");var mo={encode(e,r=new Ge){return e.allReady!==!1&&r.uint32(8).bool(e.allReady),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=OP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.allReady=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{allReady:U(e.allReady)?globalThis.Boolean(e.allReady):U(e.all_ready)?globalThis.Boolean(e.all_ready):!1}},toJSON(e){let r={};return e.allReady!==!1&&(r.allReady=e.allReady),r},create(e){return mo.fromPartial(e??{})},fromPartial(e){let r=OP();return r.allReady=e.allReady??!1,r}};function IP(){return{replayData:new Uint8Array(0)}}E(IP,"createBaseGetReplayResult");var go={encode(e,r=new Ge){return e.replayData.length!==0&&r.uint32(10).bytes(e.replayData),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=IP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.replayData=t.bytes();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{replayData:U(e.replayData)?ko(e.replayData):U(e.replay_data)?ko(e.replay_data):new Uint8Array(0)}},toJSON(e){let r={};return e.replayData.length!==0&&(r.replayData=pu(e.replayData)),r},create(e){return go.fromPartial(e??{})},fromPartial(e){let r=IP();return r.replayData=e.replayData??new Uint8Array(0),r}};function CP(){return{url:"",expiresAt:void 0}}E(CP,"createBaseGetReplayUrlResult");var yo={encode(e,r=new Ge){return e.url!==""&&r.uint32(10).string(e.url),e.expiresAt!==void 0&&Le.encode(hu(e.expiresAt),r.uint32(18).fork()).join(),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=CP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.url=t.string();continue}case 2:{if(n!==18)break;i.expiresAt=X_(Le.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{url:U(e.url)?globalThis.String(e.url):"",expiresAt:U(e.expiresAt)?Xn(e.expiresAt):U(e.expires_at)?Xn(e.expires_at):void 0}},toJSON(e){let r={};return e.url!==""&&(r.url=e.url),e.expiresAt!==void 0&&(r.expiresAt=e.expiresAt.toISOString()),r},create(e){return yo.fromPartial(e??{})},fromPartial(e){let r=CP();return r.url=e.url??"",r.expiresAt=e.expiresAt??void 0,r}};function PP(){return{eventCount:0}}E(PP,"createBaseReportTimeExpiredResult");var Mo={encode(e,r=new Ge){return e.eventCount!==0&&r.uint32(8).int32(e.eventCount),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=PP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.eventCount=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{eventCount:U(e.eventCount)?globalThis.Number(e.eventCount):U(e.event_count)?globalThis.Number(e.event_count):0}},toJSON(e){let r={};return e.eventCount!==0&&(r.eventCount=Math.round(e.eventCount)),r},create(e){return Mo.fromPartial(e??{})},fromPartial(e){let r=PP();return r.eventCount=e.eventCount??0,r}};function pP(){return{eventCount:0}}E(pP,"createBaseReportPauseExpiredResult");var Lo={encode(e,r=new Ge){return e.eventCount!==0&&r.uint32(8).int32(e.eventCount),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=pP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.eventCount=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{eventCount:U(e.eventCount)?globalThis.Number(e.eventCount):U(e.event_count)?globalThis.Number(e.event_count):0}},toJSON(e){let r={};return e.eventCount!==0&&(r.eventCount=Math.round(e.eventCount)),r},create(e){return Lo.fromPartial(e??{})},fromPartial(e){let r=pP();return r.eventCount=e.eventCount??0,r}};function hP(){return{eventCount:0}}E(hP,"createBaseReportRushDiceRollResult");var Go={encode(e,r=new Ge){return e.eventCount!==0&&r.uint32(8).int32(e.eventCount),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=hP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.eventCount=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{eventCount:U(e.eventCount)?globalThis.Number(e.eventCount):U(e.event_count)?globalThis.Number(e.event_count):0}},toJSON(e){let r={};return e.eventCount!==0&&(r.eventCount=Math.round(e.eventCount)),r},create(e){return Go.fromPartial(e??{})},fromPartial(e){let r=hP();return r.eventCount=e.eventCount??0,r}};function DP(){return{takenOver:!1}}E(DP,"createBaseReportInactivityResult");var Uo={encode(e,r=new Ge){return e.takenOver!==!1&&r.uint32(8).bool(e.takenOver),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=DP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.takenOver=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{takenOver:U(e.takenOver)?globalThis.Boolean(e.takenOver):U(e.taken_over)?globalThis.Boolean(e.taken_over):!1}},toJSON(e){let r={};return e.takenOver!==!1&&(r.takenOver=e.takenOver),r},create(e){return Uo.fromPartial(e??{})},fromPartial(e){let r=DP();return r.takenOver=e.takenOver??!1,r}};function mP(){return{returned:!1}}E(mP,"createBaseReturnFromTakeoverResult");var Bo={encode(e,r=new Ge){return e.returned!==!1&&r.uint32(8).bool(e.returned),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=mP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.returned=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{returned:U(e.returned)?globalThis.Boolean(e.returned):!1}},toJSON(e){let r={};return e.returned!==!1&&(r.returned=e.returned),r},create(e){return Bo.fromPartial(e??{})},fromPartial(e){let r=mP();return r.returned=e.returned??!1,r}};function gP(){return{success:!1,error:"",botMoveResult:void 0,sendPingResult:void 0,submitGameFeedbackResult:void 0,saveBotGameReplayResult:void 0,sendGameChatResult:void 0,toggleChatReactionResult:void 0,joinGameAsSpectatorResult:void 0,updatePlayerLoadingStatusResult:void 0,getReplayResult:void 0,getReplayUrlResult:void 0,reportTimeExpiredResult:void 0,reportPauseExpiredResult:void 0,reportRushDiceRollResult:void 0,reportInactivityResult:void 0,returnFromTakeoverResult:void 0}}E(gP,"createBaseGameActionResponse");var kc={encode(e,r=new Ge){return e.success!==!1&&r.uint32(8).bool(e.success),e.error!==""&&r.uint32(18).string(e.error),e.botMoveResult!==void 0&&Oo.encode(e.botMoveResult,r.uint32(26).fork()).join(),e.sendPingResult!==void 0&&Io.encode(e.sendPingResult,r.uint32(34).fork()).join(),e.submitGameFeedbackResult!==void 0&&Co.encode(e.submitGameFeedbackResult,r.uint32(42).fork()).join(),e.saveBotGameReplayResult!==void 0&&Po.encode(e.saveBotGameReplayResult,r.uint32(50).fork()).join(),e.sendGameChatResult!==void 0&&po.encode(e.sendGameChatResult,r.uint32(58).fork()).join(),e.toggleChatReactionResult!==void 0&&ho.encode(e.toggleChatReactionResult,r.uint32(66).fork()).join(),e.joinGameAsSpectatorResult!==void 0&&Do.encode(e.joinGameAsSpectatorResult,r.uint32(74).fork()).join(),e.updatePlayerLoadingStatusResult!==void 0&&mo.encode(e.updatePlayerLoadingStatusResult,r.uint32(82).fork()).join(),e.getReplayResult!==void 0&&go.encode(e.getReplayResult,r.uint32(90).fork()).join(),e.getReplayUrlResult!==void 0&&yo.encode(e.getReplayUrlResult,r.uint32(98).fork()).join(),e.reportTimeExpiredResult!==void 0&&Mo.encode(e.reportTimeExpiredResult,r.uint32(106).fork()).join(),e.reportPauseExpiredResult!==void 0&&Lo.encode(e.reportPauseExpiredResult,r.uint32(114).fork()).join(),e.reportRushDiceRollResult!==void 0&&Go.encode(e.reportRushDiceRollResult,r.uint32(122).fork()).join(),e.reportInactivityResult!==void 0&&Uo.encode(e.reportInactivityResult,r.uint32(130).fork()).join(),e.returnFromTakeoverResult!==void 0&&Bo.encode(e.returnFromTakeoverResult,r.uint32(138).fork()).join(),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=gP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==18)break;i.error=t.string();continue}case 3:{if(n!==26)break;i.botMoveResult=Oo.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.sendPingResult=Io.decode(t,t.uint32());continue}case 5:{if(n!==42)break;i.submitGameFeedbackResult=Co.decode(t,t.uint32());continue}case 6:{if(n!==50)break;i.saveBotGameReplayResult=Po.decode(t,t.uint32());continue}case 7:{if(n!==58)break;i.sendGameChatResult=po.decode(t,t.uint32());continue}case 8:{if(n!==66)break;i.toggleChatReactionResult=ho.decode(t,t.uint32());continue}case 9:{if(n!==74)break;i.joinGameAsSpectatorResult=Do.decode(t,t.uint32());continue}case 10:{if(n!==82)break;i.updatePlayerLoadingStatusResult=mo.decode(t,t.uint32());continue}case 11:{if(n!==90)break;i.getReplayResult=go.decode(t,t.uint32());continue}case 12:{if(n!==98)break;i.getReplayUrlResult=yo.decode(t,t.uint32());continue}case 13:{if(n!==106)break;i.reportTimeExpiredResult=Mo.decode(t,t.uint32());continue}case 14:{if(n!==114)break;i.reportPauseExpiredResult=Lo.decode(t,t.uint32());continue}case 15:{if(n!==122)break;i.reportRushDiceRollResult=Go.decode(t,t.uint32());continue}case 16:{if(n!==130)break;i.reportInactivityResult=Uo.decode(t,t.uint32());continue}case 17:{if(n!==138)break;i.returnFromTakeoverResult=Bo.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:U(e.success)?globalThis.Boolean(e.success):!1,error:U(e.error)?globalThis.String(e.error):"",botMoveResult:U(e.botMoveResult)?Oo.fromJSON(e.botMoveResult):U(e.bot_move_result)?Oo.fromJSON(e.bot_move_result):void 0,sendPingResult:U(e.sendPingResult)?Io.fromJSON(e.sendPingResult):U(e.send_ping_result)?Io.fromJSON(e.send_ping_result):void 0,submitGameFeedbackResult:U(e.submitGameFeedbackResult)?Co.fromJSON(e.submitGameFeedbackResult):U(e.submit_game_feedback_result)?Co.fromJSON(e.submit_game_feedback_result):void 0,saveBotGameReplayResult:U(e.saveBotGameReplayResult)?Po.fromJSON(e.saveBotGameReplayResult):U(e.save_bot_game_replay_result)?Po.fromJSON(e.save_bot_game_replay_result):void 0,sendGameChatResult:U(e.sendGameChatResult)?po.fromJSON(e.sendGameChatResult):U(e.send_game_chat_result)?po.fromJSON(e.send_game_chat_result):void 0,toggleChatReactionResult:U(e.toggleChatReactionResult)?ho.fromJSON(e.toggleChatReactionResult):U(e.toggle_chat_reaction_result)?ho.fromJSON(e.toggle_chat_reaction_result):void 0,joinGameAsSpectatorResult:U(e.joinGameAsSpectatorResult)?Do.fromJSON(e.joinGameAsSpectatorResult):U(e.join_game_as_spectator_result)?Do.fromJSON(e.join_game_as_spectator_result):void 0,updatePlayerLoadingStatusResult:U(e.updatePlayerLoadingStatusResult)?mo.fromJSON(e.updatePlayerLoadingStatusResult):U(e.update_player_loading_status_result)?mo.fromJSON(e.update_player_loading_status_result):void 0,getReplayResult:U(e.getReplayResult)?go.fromJSON(e.getReplayResult):U(e.get_replay_result)?go.fromJSON(e.get_replay_result):void 0,getReplayUrlResult:U(e.getReplayUrlResult)?yo.fromJSON(e.getReplayUrlResult):U(e.get_replay_url_result)?yo.fromJSON(e.get_replay_url_result):void 0,reportTimeExpiredResult:U(e.reportTimeExpiredResult)?Mo.fromJSON(e.reportTimeExpiredResult):U(e.report_time_expired_result)?Mo.fromJSON(e.report_time_expired_result):void 0,reportPauseExpiredResult:U(e.reportPauseExpiredResult)?Lo.fromJSON(e.reportPauseExpiredResult):U(e.report_pause_expired_result)?Lo.fromJSON(e.report_pause_expired_result):void 0,reportRushDiceRollResult:U(e.reportRushDiceRollResult)?Go.fromJSON(e.reportRushDiceRollResult):U(e.report_rush_dice_roll_result)?Go.fromJSON(e.report_rush_dice_roll_result):void 0,reportInactivityResult:U(e.reportInactivityResult)?Uo.fromJSON(e.reportInactivityResult):U(e.report_inactivity_result)?Uo.fromJSON(e.report_inactivity_result):void 0,returnFromTakeoverResult:U(e.returnFromTakeoverResult)?Bo.fromJSON(e.returnFromTakeoverResult):U(e.return_from_takeover_result)?Bo.fromJSON(e.return_from_takeover_result):void 0}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.error!==""&&(r.error=e.error),e.botMoveResult!==void 0&&(r.botMoveResult=Oo.toJSON(e.botMoveResult)),e.sendPingResult!==void 0&&(r.sendPingResult=Io.toJSON(e.sendPingResult)),e.submitGameFeedbackResult!==void 0&&(r.submitGameFeedbackResult=Co.toJSON(e.submitGameFeedbackResult)),e.saveBotGameReplayResult!==void 0&&(r.saveBotGameReplayResult=Po.toJSON(e.saveBotGameReplayResult)),e.sendGameChatResult!==void 0&&(r.sendGameChatResult=po.toJSON(e.sendGameChatResult)),e.toggleChatReactionResult!==void 0&&(r.toggleChatReactionResult=ho.toJSON(e.toggleChatReactionResult)),e.joinGameAsSpectatorResult!==void 0&&(r.joinGameAsSpectatorResult=Do.toJSON(e.joinGameAsSpectatorResult)),e.updatePlayerLoadingStatusResult!==void 0&&(r.updatePlayerLoadingStatusResult=mo.toJSON(e.updatePlayerLoadingStatusResult)),e.getReplayResult!==void 0&&(r.getReplayResult=go.toJSON(e.getReplayResult)),e.getReplayUrlResult!==void 0&&(r.getReplayUrlResult=yo.toJSON(e.getReplayUrlResult)),e.reportTimeExpiredResult!==void 0&&(r.reportTimeExpiredResult=Mo.toJSON(e.reportTimeExpiredResult)),e.reportPauseExpiredResult!==void 0&&(r.reportPauseExpiredResult=Lo.toJSON(e.reportPauseExpiredResult)),e.reportRushDiceRollResult!==void 0&&(r.reportRushDiceRollResult=Go.toJSON(e.reportRushDiceRollResult)),e.reportInactivityResult!==void 0&&(r.reportInactivityResult=Uo.toJSON(e.reportInactivityResult)),e.returnFromTakeoverResult!==void 0&&(r.returnFromTakeoverResult=Bo.toJSON(e.returnFromTakeoverResult)),r},create(e){return kc.fromPartial(e??{})},fromPartial(e){let r=gP();return r.success=e.success??!1,r.error=e.error??"",r.botMoveResult=e.botMoveResult!==void 0&&e.botMoveResult!==null?Oo.fromPartial(e.botMoveResult):void 0,r.sendPingResult=e.sendPingResult!==void 0&&e.sendPingResult!==null?Io.fromPartial(e.sendPingResult):void 0,r.submitGameFeedbackResult=e.submitGameFeedbackResult!==void 0&&e.submitGameFeedbackResult!==null?Co.fromPartial(e.submitGameFeedbackResult):void 0,r.saveBotGameReplayResult=e.saveBotGameReplayResult!==void 0&&e.saveBotGameReplayResult!==null?Po.fromPartial(e.saveBotGameReplayResult):void 0,r.sendGameChatResult=e.sendGameChatResult!==void 0&&e.sendGameChatResult!==null?po.fromPartial(e.sendGameChatResult):void 0,r.toggleChatReactionResult=e.toggleChatReactionResult!==void 0&&e.toggleChatReactionResult!==null?ho.fromPartial(e.toggleChatReactionResult):void 0,r.joinGameAsSpectatorResult=e.joinGameAsSpectatorResult!==void 0&&e.joinGameAsSpectatorResult!==null?Do.fromPartial(e.joinGameAsSpectatorResult):void 0,r.updatePlayerLoadingStatusResult=e.updatePlayerLoadingStatusResult!==void 0&&e.updatePlayerLoadingStatusResult!==null?mo.fromPartial(e.updatePlayerLoadingStatusResult):void 0,r.getReplayResult=e.getReplayResult!==void 0&&e.getReplayResult!==null?go.fromPartial(e.getReplayResult):void 0,r.getReplayUrlResult=e.getReplayUrlResult!==void 0&&e.getReplayUrlResult!==null?yo.fromPartial(e.getReplayUrlResult):void 0,r.reportTimeExpiredResult=e.reportTimeExpiredResult!==void 0&&e.reportTimeExpiredResult!==null?Mo.fromPartial(e.reportTimeExpiredResult):void 0,r.reportPauseExpiredResult=e.reportPauseExpiredResult!==void 0&&e.reportPauseExpiredResult!==null?Lo.fromPartial(e.reportPauseExpiredResult):void 0,r.reportRushDiceRollResult=e.reportRushDiceRollResult!==void 0&&e.reportRushDiceRollResult!==null?Go.fromPartial(e.reportRushDiceRollResult):void 0,r.reportInactivityResult=e.reportInactivityResult!==void 0&&e.reportInactivityResult!==null?Uo.fromPartial(e.reportInactivityResult):void 0,r.returnFromTakeoverResult=e.returnFromTakeoverResult!==void 0&&e.returnFromTakeoverResult!==null?Bo.fromPartial(e.returnFromTakeoverResult):void 0,r}};function yP(){return{gameId:"",action:void 0,warmup:!1}}E(yP,"createBaseFirebaseExecuteActionRequest");var bc={encode(e,r=new Ge){return e.gameId!==""&&r.uint32(10).string(e.gameId),e.action!==void 0&&ro.encode(e.action,r.uint32(18).fork()).join(),e.warmup!==!1&&r.uint32(24).bool(e.warmup),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=yP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==18)break;i.action=ro.decode(t,t.uint32());continue}case 3:{if(n!==24)break;i.warmup=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:U(e.gameId)?globalThis.String(e.gameId):U(e.game_id)?globalThis.String(e.game_id):"",action:U(e.action)?ro.fromJSON(e.action):void 0,warmup:U(e.warmup)?globalThis.Boolean(e.warmup):!1}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.action!==void 0&&(r.action=ro.toJSON(e.action)),e.warmup!==!1&&(r.warmup=e.warmup),r},create(e){return bc.fromPartial(e??{})},fromPartial(e){let r=yP();return r.gameId=e.gameId??"",r.action=e.action!==void 0&&e.action!==null?ro.fromPartial(e.action):void 0,r.warmup=e.warmup??!1,r}};function MP(){return{success:!1,eventCount:0,error:""}}E(MP,"createBaseFirebaseExecuteActionResponse");var vc={encode(e,r=new Ge){return e.success!==!1&&r.uint32(8).bool(e.success),e.eventCount!==0&&r.uint32(16).int32(e.eventCount),e.error!==""&&r.uint32(26).string(e.error),r},decode(e,r){let t=e instanceof Q?e:new Q(e),o=r===void 0?t.len:t.pos+r,i=MP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==16)break;i.eventCount=t.int32();continue}case 3:{if(n!==26)break;i.error=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:U(e.success)?globalThis.Boolean(e.success):!1,eventCount:U(e.eventCount)?globalThis.Number(e.eventCount):U(e.event_count)?globalThis.Number(e.event_count):0,error:U(e.error)?globalThis.String(e.error):""}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.eventCount!==0&&(r.eventCount=Math.round(e.eventCount)),e.error!==""&&(r.error=e.error),r},create(e){return vc.fromPartial(e??{})},fromPartial(e){let r=MP();return r.success=e.success??!1,r.eventCount=e.eventCount??0,r.error=e.error??"",r}};function ko(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{let r=globalThis.atob(e),t=new Uint8Array(r.length);for(let o=0;o<r.length;++o)t[o]=r.charCodeAt(o);return t}}E(ko,"bytesFromBase64");function pu(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{let r=[];return e.forEach(t=>{r.push(globalThis.String.fromCharCode(t))}),globalThis.btoa(r.join(""))}}E(pu,"base64FromBytes");function hu(e){let r=Math.trunc(e.getTime()/1e3),t=e.getTime()%1e3*1e6;return{seconds:r,nanos:t}}E(hu,"toTimestamp");function X_(e){let r=(e.seconds||0)*1e3;return r+=(e.nanos||0)/1e6,new globalThis.Date(r)}E(X_,"fromTimestamp");function Xn(e){return e instanceof globalThis.Date?e:typeof e=="string"?new globalThis.Date(e):X_(Le.fromJSON(e))}E(Xn,"fromJsonTimestamp");function LP(e){return typeof e=="object"&&e!==null}E(LP,"isObject");function U(e){return e!=null}E(U,"isSet");import{BinaryReader as Oz,BinaryWriter as Iz}from"@bufbuild/protobuf/wire";var GP;(function(e){e[e.QUEUE_STATUS_UNSPECIFIED=0]="QUEUE_STATUS_UNSPECIFIED",e[e.QUEUE_STATUS_QUEUED=1]="QUEUE_STATUS_QUEUED",e[e.QUEUE_STATUS_MATCHED=2]="QUEUE_STATUS_MATCHED",e[e.QUEUE_STATUS_TIMED_OUT=3]="QUEUE_STATUS_TIMED_OUT",e[e.QUEUE_STATUS_CANCELLED=4]="QUEUE_STATUS_CANCELLED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(GP||(GP={}));var UP;(function(e){e[e.READY_CHECK_STATUS_UNSPECIFIED=0]="READY_CHECK_STATUS_UNSPECIFIED",e[e.READY_CHECK_STATUS_ACTIVE=1]="READY_CHECK_STATUS_ACTIVE",e[e.READY_CHECK_STATUS_COMPLETED=2]="READY_CHECK_STATUS_COMPLETED",e[e.READY_CHECK_STATUS_FAILED=3]="READY_CHECK_STATUS_FAILED",e[e.READY_CHECK_STATUS_CANCELLED=4]="READY_CHECK_STATUS_CANCELLED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(UP||(UP={}));import{BinaryReader as gz,BinaryWriter as yz}from"@bufbuild/protobuf/wire";var BP;(function(e){e[e.LADDER_TYPE_UNSPECIFIED=0]="LADDER_TYPE_UNSPECIFIED",e[e.LADDER_TYPE_RANKED=1]="LADDER_TYPE_RANKED",e[e.LADDER_TYPE_CASUAL=2]="LADDER_TYPE_CASUAL",e[e.LADDER_TYPE_TOURNAMENT=3]="LADDER_TYPE_TOURNAMENT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(BP||(BP={}));var kP;(function(e){e[e.SEASON_PERIOD_UNSPECIFIED=0]="SEASON_PERIOD_UNSPECIFIED",e[e.SEASON_PERIOD_DAY=1]="SEASON_PERIOD_DAY",e[e.SEASON_PERIOD_WEEK=2]="SEASON_PERIOD_WEEK",e[e.SEASON_PERIOD_MONTH=3]="SEASON_PERIOD_MONTH",e[e.SEASON_PERIOD_CUSTOM=4]="SEASON_PERIOD_CUSTOM",e[e.SEASON_PERIOD_INFINITE=5]="SEASON_PERIOD_INFINITE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(kP||(kP={}));var bP;(function(e){e[e.SEASON_STATUS_UNSPECIFIED=0]="SEASON_STATUS_UNSPECIFIED",e[e.SEASON_STATUS_ACTIVE=1]="SEASON_STATUS_ACTIVE",e[e.SEASON_STATUS_FROZEN=2]="SEASON_STATUS_FROZEN",e[e.SEASON_STATUS_ARCHIVED=3]="SEASON_STATUS_ARCHIVED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(bP||(bP={}));var vP;(function(e){e[e.LADDER_ACTION_UNSPECIFIED=0]="LADDER_ACTION_UNSPECIFIED",e[e.LADDER_ACTION_JOIN=1]="LADDER_ACTION_JOIN",e[e.LADDER_ACTION_GET_LEADERBOARD=2]="LADDER_ACTION_GET_LEADERBOARD",e[e.LADDER_ACTION_GET_PLAYER_RATING=3]="LADDER_ACTION_GET_PLAYER_RATING",e[e.LADDER_ACTION_LIST=4]="LADDER_ACTION_LIST",e[e.LADDER_ACTION_GET_CURRENT_SEASON=5]="LADDER_ACTION_GET_CURRENT_SEASON",e[e.LADDER_ACTION_CREATE=6]="LADDER_ACTION_CREATE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(vP||(vP={}));var YP;(function(e){e[e.MATCH_ACTION_UNSPECIFIED=0]="MATCH_ACTION_UNSPECIFIED",e[e.MATCH_ACTION_JOIN_QUEUE=1]="MATCH_ACTION_JOIN_QUEUE",e[e.MATCH_ACTION_LEAVE_QUEUE=2]="MATCH_ACTION_LEAVE_QUEUE",e[e.MATCH_ACTION_GET_QUEUE_STATUS=3]="MATCH_ACTION_GET_QUEUE_STATUS",e[e.MATCH_ACTION_CONFIRM_READY=4]="MATCH_ACTION_CONFIRM_READY",e[e.MATCH_ACTION_DECLINE_READY=5]="MATCH_ACTION_DECLINE_READY",e[e.MATCH_ACTION_SUBMIT_MAP_CHOICE=6]="MATCH_ACTION_SUBMIT_MAP_CHOICE",e[e.MATCH_ACTION_REPORT_READY_TIMEOUT=7]="MATCH_ACTION_REPORT_READY_TIMEOUT",e[e.MATCH_ACTION_REPORT_LOADING_TIMEOUT=8]="MATCH_ACTION_REPORT_LOADING_TIMEOUT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(YP||(YP={}));import{BinaryReader as vz,BinaryWriter as Yz}from"@bufbuild/protobuf/wire";var FP;(function(e){e[e.LEADERBOARD_STAT_UNSPECIFIED=0]="LEADERBOARD_STAT_UNSPECIFIED",e[e.LEADERBOARD_STAT_RESOURCES_GAINED=1]="LEADERBOARD_STAT_RESOURCES_GAINED",e[e.LEADERBOARD_STAT_RESOURCES_SPENT=2]="LEADERBOARD_STAT_RESOURCES_SPENT",e[e.LEADERBOARD_STAT_RESOURCES_LOST=3]="LEADERBOARD_STAT_RESOURCES_LOST",e[e.LEADERBOARD_STAT_SETTLEMENT_COUNT=4]="LEADERBOARD_STAT_SETTLEMENT_COUNT",e[e.LEADERBOARD_STAT_CITY_COUNT=5]="LEADERBOARD_STAT_CITY_COUNT",e[e.LEADERBOARD_STAT_ROAD_COUNT=6]="LEADERBOARD_STAT_ROAD_COUNT",e[e.LEADERBOARD_STAT_DEV_CARDS_BOUGHT=7]="LEADERBOARD_STAT_DEV_CARDS_BOUGHT",e[e.LEADERBOARD_STAT_DEV_CARDS_PLAYED=8]="LEADERBOARD_STAT_DEV_CARDS_PLAYED",e[e.LEADERBOARD_STAT_VICTORY_POINTS=9]="LEADERBOARD_STAT_VICTORY_POINTS",e[e.LEADERBOARD_STAT_GAME_LENGTH_TURNS=10]="LEADERBOARD_STAT_GAME_LENGTH_TURNS",e[e.LEADERBOARD_STAT_TOTAL_ROLLS=11]="LEADERBOARD_STAT_TOTAL_ROLLS",e[e.LEADERBOARD_STAT_BANK_TRADES=12]="LEADERBOARD_STAT_BANK_TRADES",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(FP||(FP={}));var VP;(function(e){e[e.LEADERBOARD_ORDER_UNSPECIFIED=0]="LEADERBOARD_ORDER_UNSPECIFIED",e[e.LEADERBOARD_ORDER_ASCENDING=1]="LEADERBOARD_ORDER_ASCENDING",e[e.LEADERBOARD_ORDER_DESCENDING=2]="LEADERBOARD_ORDER_DESCENDING",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(VP||(VP={}));var xP;(function(e){e[e.CHALLENGE_ATTEMPT_STATUS_UNSPECIFIED=0]="CHALLENGE_ATTEMPT_STATUS_UNSPECIFIED",e[e.CHALLENGE_ATTEMPT_STATUS_IN_PROGRESS=1]="CHALLENGE_ATTEMPT_STATUS_IN_PROGRESS",e[e.CHALLENGE_ATTEMPT_STATUS_COMPLETED=2]="CHALLENGE_ATTEMPT_STATUS_COMPLETED",e[e.CHALLENGE_ATTEMPT_STATUS_ABORTED=3]="CHALLENGE_ATTEMPT_STATUS_ABORTED",e[e.CHALLENGE_ATTEMPT_STATUS_VERIFIED=4]="CHALLENGE_ATTEMPT_STATUS_VERIFIED",e[e.CHALLENGE_ATTEMPT_STATUS_INVALID=5]="CHALLENGE_ATTEMPT_STATUS_INVALID",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(xP||(xP={}));var wP;(function(e){e[e.CHALLENGE_ACTION_UNSPECIFIED=0]="CHALLENGE_ACTION_UNSPECIFIED",e[e.CHALLENGE_ACTION_GET_TODAY=1]="CHALLENGE_ACTION_GET_TODAY",e[e.CHALLENGE_ACTION_START_ATTEMPT=2]="CHALLENGE_ACTION_START_ATTEMPT",e[e.CHALLENGE_ACTION_VERIFY=3]="CHALLENGE_ACTION_VERIFY",e[e.CHALLENGE_ACTION_GET_LEADERBOARD=4]="CHALLENGE_ACTION_GET_LEADERBOARD",e[e.CHALLENGE_ACTION_GET_MY_ATTEMPTS=5]="CHALLENGE_ACTION_GET_MY_ATTEMPTS",e[e.CHALLENGE_ACTION_GET_REPLAY=6]="CHALLENGE_ACTION_GET_REPLAY",e[e.CHALLENGE_ACTION_SUBMIT_SUGGESTION=7]="CHALLENGE_ACTION_SUBMIT_SUGGESTION",e[e.CHALLENGE_ACTION_GET_SUGGESTIONS=8]="CHALLENGE_ACTION_GET_SUGGESTIONS",e[e.CHALLENGE_ACTION_REVIEW_SUGGESTION=9]="CHALLENGE_ACTION_REVIEW_SUGGESTION",e[e.CHALLENGE_ACTION_RESET_LEADERBOARD=10]="CHALLENGE_ACTION_RESET_LEADERBOARD",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(wP||(wP={}));var HP;(function(e){e[e.CHALLENGE_SUGGESTION_STATUS_UNSPECIFIED=0]="CHALLENGE_SUGGESTION_STATUS_UNSPECIFIED",e[e.CHALLENGE_SUGGESTION_STATUS_PENDING=1]="CHALLENGE_SUGGESTION_STATUS_PENDING",e[e.CHALLENGE_SUGGESTION_STATUS_APPROVED=2]="CHALLENGE_SUGGESTION_STATUS_APPROVED",e[e.CHALLENGE_SUGGESTION_STATUS_REJECTED=3]="CHALLENGE_SUGGESTION_STATUS_REJECTED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(HP||(HP={}));import{BinaryReader as Wz,BinaryWriter as Jz}from"@bufbuild/protobuf/wire";var KP;(function(e){e[e.ARENA_STATUS_UNSPECIFIED=0]="ARENA_STATUS_UNSPECIFIED",e[e.ARENA_STATUS_SCHEDULED=1]="ARENA_STATUS_SCHEDULED",e[e.ARENA_STATUS_ACTIVE=2]="ARENA_STATUS_ACTIVE",e[e.ARENA_STATUS_COMPLETED=3]="ARENA_STATUS_COMPLETED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(KP||(KP={}));var WP;(function(e){e[e.ARENA_ACTION_UNSPECIFIED=0]="ARENA_ACTION_UNSPECIFIED",e[e.ARENA_ACTION_CREATE=1]="ARENA_ACTION_CREATE",e[e.ARENA_ACTION_JOIN=2]="ARENA_ACTION_JOIN",e[e.ARENA_ACTION_LEAVE=3]="ARENA_ACTION_LEAVE",e[e.ARENA_ACTION_GET_ARENA=4]="ARENA_ACTION_GET_ARENA",e[e.ARENA_ACTION_GET_LEADERBOARD=5]="ARENA_ACTION_GET_LEADERBOARD",e[e.ARENA_ACTION_LIST=6]="ARENA_ACTION_LIST",e[e.ARENA_ACTION_SET_BERSERK=7]="ARENA_ACTION_SET_BERSERK",e[e.ARENA_ACTION_JOIN_QUEUE=8]="ARENA_ACTION_JOIN_QUEUE",e[e.ARENA_ACTION_LEAVE_QUEUE=9]="ARENA_ACTION_LEAVE_QUEUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(WP||(WP={}));import{BinaryReader as W,BinaryWriter as Oe}from"@bufbuild/protobuf/wire";var Te;(function(e){e[e.USER_ACTION_UNSPECIFIED=0]="USER_ACTION_UNSPECIFIED",e[e.USER_ACTION_CREATE_OR_UPDATE_PROFILE=1]="USER_ACTION_CREATE_OR_UPDATE_PROFILE",e[e.USER_ACTION_DELETE_PROFILE=2]="USER_ACTION_DELETE_PROFILE",e[e.USER_ACTION_GET_RECENT_GAMES=3]="USER_ACTION_GET_RECENT_GAMES",e[e.USER_ACTION_MANAGE_FRIEND=4]="USER_ACTION_MANAGE_FRIEND",e[e.USER_ACTION_ACCEPT_FRIEND_REQUEST=5]="USER_ACTION_ACCEPT_FRIEND_REQUEST",e[e.USER_ACTION_DECLINE_FRIEND_REQUEST=6]="USER_ACTION_DECLINE_FRIEND_REQUEST",e[e.USER_ACTION_REMOVE_FRIEND=7]="USER_ACTION_REMOVE_FRIEND",e[e.USER_ACTION_MANAGE_IGNORE=8]="USER_ACTION_MANAGE_IGNORE",e[e.USER_ACTION_ENSURE_USER_DOC=9]="USER_ACTION_ENSURE_USER_DOC",e[e.USER_ACTION_COMPLETE_GOOGLE_SIGN_IN=10]="USER_ACTION_COMPLETE_GOOGLE_SIGN_IN",e[e.USER_ACTION_MANAGE_BLOCK=11]="USER_ACTION_MANAGE_BLOCK",e[e.USER_ACTION_EQUIP_COSMETIC=12]="USER_ACTION_EQUIP_COSMETIC",e[e.USER_ACTION_UPDATE_DISPLAY_OPTIONS=13]="USER_ACTION_UPDATE_DISPLAY_OPTIONS",e[e.USER_ACTION_MARK_NOTIFICATION_READ=14]="USER_ACTION_MARK_NOTIFICATION_READ",e[e.USER_ACTION_DISMISS_NOTIFICATION=15]="USER_ACTION_DISMISS_NOTIFICATION",e[e.USER_ACTION_MARK_ALL_NOTIFICATIONS_READ=16]="USER_ACTION_MARK_ALL_NOTIFICATIONS_READ",e[e.USER_ACTION_GET_PROFILE_BY_USERNAME=17]="USER_ACTION_GET_PROFILE_BY_USERNAME",e[e.USER_ACTION_UPDATE_PINNED_ACHIEVEMENTS=18]="USER_ACTION_UPDATE_PINNED_ACHIEVEMENTS",e[e.USER_ACTION_WARMUP=19]="USER_ACTION_WARMUP",e[e.USER_ACTION_TOGGLE_EXPANSION_REACTION=20]="USER_ACTION_TOGGLE_EXPANSION_REACTION",e[e.USER_ACTION_SAVE_UI_LAYOUT_SIZE=21]="USER_ACTION_SAVE_UI_LAYOUT_SIZE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Te||(Te={}));function JP(e){switch(e){case 0:case"USER_ACTION_UNSPECIFIED":return Te.USER_ACTION_UNSPECIFIED;case 1:case"USER_ACTION_CREATE_OR_UPDATE_PROFILE":return Te.USER_ACTION_CREATE_OR_UPDATE_PROFILE;case 2:case"USER_ACTION_DELETE_PROFILE":return Te.USER_ACTION_DELETE_PROFILE;case 3:case"USER_ACTION_GET_RECENT_GAMES":return Te.USER_ACTION_GET_RECENT_GAMES;case 4:case"USER_ACTION_MANAGE_FRIEND":return Te.USER_ACTION_MANAGE_FRIEND;case 5:case"USER_ACTION_ACCEPT_FRIEND_REQUEST":return Te.USER_ACTION_ACCEPT_FRIEND_REQUEST;case 6:case"USER_ACTION_DECLINE_FRIEND_REQUEST":return Te.USER_ACTION_DECLINE_FRIEND_REQUEST;case 7:case"USER_ACTION_REMOVE_FRIEND":return Te.USER_ACTION_REMOVE_FRIEND;case 8:case"USER_ACTION_MANAGE_IGNORE":return Te.USER_ACTION_MANAGE_IGNORE;case 9:case"USER_ACTION_ENSURE_USER_DOC":return Te.USER_ACTION_ENSURE_USER_DOC;case 10:case"USER_ACTION_COMPLETE_GOOGLE_SIGN_IN":return Te.USER_ACTION_COMPLETE_GOOGLE_SIGN_IN;case 11:case"USER_ACTION_MANAGE_BLOCK":return Te.USER_ACTION_MANAGE_BLOCK;case 12:case"USER_ACTION_EQUIP_COSMETIC":return Te.USER_ACTION_EQUIP_COSMETIC;case 13:case"USER_ACTION_UPDATE_DISPLAY_OPTIONS":return Te.USER_ACTION_UPDATE_DISPLAY_OPTIONS;case 14:case"USER_ACTION_MARK_NOTIFICATION_READ":return Te.USER_ACTION_MARK_NOTIFICATION_READ;case 15:case"USER_ACTION_DISMISS_NOTIFICATION":return Te.USER_ACTION_DISMISS_NOTIFICATION;case 16:case"USER_ACTION_MARK_ALL_NOTIFICATIONS_READ":return Te.USER_ACTION_MARK_ALL_NOTIFICATIONS_READ;case 17:case"USER_ACTION_GET_PROFILE_BY_USERNAME":return Te.USER_ACTION_GET_PROFILE_BY_USERNAME;case 18:case"USER_ACTION_UPDATE_PINNED_ACHIEVEMENTS":return Te.USER_ACTION_UPDATE_PINNED_ACHIEVEMENTS;case 19:case"USER_ACTION_WARMUP":return Te.USER_ACTION_WARMUP;case 20:case"USER_ACTION_TOGGLE_EXPANSION_REACTION":return Te.USER_ACTION_TOGGLE_EXPANSION_REACTION;case 21:case"USER_ACTION_SAVE_UI_LAYOUT_SIZE":return Te.USER_ACTION_SAVE_UI_LAYOUT_SIZE;default:return Te.UNRECOGNIZED}}E(JP,"userActionTypeFromJSON");function Ty(e){switch(e){case Te.USER_ACTION_UNSPECIFIED:return"USER_ACTION_UNSPECIFIED";case Te.USER_ACTION_CREATE_OR_UPDATE_PROFILE:return"USER_ACTION_CREATE_OR_UPDATE_PROFILE";case Te.USER_ACTION_DELETE_PROFILE:return"USER_ACTION_DELETE_PROFILE";case Te.USER_ACTION_GET_RECENT_GAMES:return"USER_ACTION_GET_RECENT_GAMES";case Te.USER_ACTION_MANAGE_FRIEND:return"USER_ACTION_MANAGE_FRIEND";case Te.USER_ACTION_ACCEPT_FRIEND_REQUEST:return"USER_ACTION_ACCEPT_FRIEND_REQUEST";case Te.USER_ACTION_DECLINE_FRIEND_REQUEST:return"USER_ACTION_DECLINE_FRIEND_REQUEST";case Te.USER_ACTION_REMOVE_FRIEND:return"USER_ACTION_REMOVE_FRIEND";case Te.USER_ACTION_MANAGE_IGNORE:return"USER_ACTION_MANAGE_IGNORE";case Te.USER_ACTION_ENSURE_USER_DOC:return"USER_ACTION_ENSURE_USER_DOC";case Te.USER_ACTION_COMPLETE_GOOGLE_SIGN_IN:return"USER_ACTION_COMPLETE_GOOGLE_SIGN_IN";case Te.USER_ACTION_MANAGE_BLOCK:return"USER_ACTION_MANAGE_BLOCK";case Te.USER_ACTION_EQUIP_COSMETIC:return"USER_ACTION_EQUIP_COSMETIC";case Te.USER_ACTION_UPDATE_DISPLAY_OPTIONS:return"USER_ACTION_UPDATE_DISPLAY_OPTIONS";case Te.USER_ACTION_MARK_NOTIFICATION_READ:return"USER_ACTION_MARK_NOTIFICATION_READ";case Te.USER_ACTION_DISMISS_NOTIFICATION:return"USER_ACTION_DISMISS_NOTIFICATION";case Te.USER_ACTION_MARK_ALL_NOTIFICATIONS_READ:return"USER_ACTION_MARK_ALL_NOTIFICATIONS_READ";case Te.USER_ACTION_GET_PROFILE_BY_USERNAME:return"USER_ACTION_GET_PROFILE_BY_USERNAME";case Te.USER_ACTION_UPDATE_PINNED_ACHIEVEMENTS:return"USER_ACTION_UPDATE_PINNED_ACHIEVEMENTS";case Te.USER_ACTION_WARMUP:return"USER_ACTION_WARMUP";case Te.USER_ACTION_TOGGLE_EXPANSION_REACTION:return"USER_ACTION_TOGGLE_EXPANSION_REACTION";case Te.USER_ACTION_SAVE_UI_LAYOUT_SIZE:return"USER_ACTION_SAVE_UI_LAYOUT_SIZE";case Te.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Ty,"userActionTypeToJSON");var nn;(function(e){e[e.FRIEND_ACTION_UNSPECIFIED=0]="FRIEND_ACTION_UNSPECIFIED",e[e.FRIEND_ACTION_ADD=1]="FRIEND_ACTION_ADD",e[e.FRIEND_ACTION_REMOVE=2]="FRIEND_ACTION_REMOVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(nn||(nn={}));function qP(e){switch(e){case 0:case"FRIEND_ACTION_UNSPECIFIED":return nn.FRIEND_ACTION_UNSPECIFIED;case 1:case"FRIEND_ACTION_ADD":return nn.FRIEND_ACTION_ADD;case 2:case"FRIEND_ACTION_REMOVE":return nn.FRIEND_ACTION_REMOVE;default:return nn.UNRECOGNIZED}}E(qP,"friendActionFromJSON");function Ny(e){switch(e){case nn.FRIEND_ACTION_UNSPECIFIED:return"FRIEND_ACTION_UNSPECIFIED";case nn.FRIEND_ACTION_ADD:return"FRIEND_ACTION_ADD";case nn.FRIEND_ACTION_REMOVE:return"FRIEND_ACTION_REMOVE";case nn.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Ny,"friendActionToJSON");var on;(function(e){e[e.IGNORE_ACTION_UNSPECIFIED=0]="IGNORE_ACTION_UNSPECIFIED",e[e.IGNORE_ACTION_ADD=1]="IGNORE_ACTION_ADD",e[e.IGNORE_ACTION_REMOVE=2]="IGNORE_ACTION_REMOVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(on||(on={}));function ZP(e){switch(e){case 0:case"IGNORE_ACTION_UNSPECIFIED":return on.IGNORE_ACTION_UNSPECIFIED;case 1:case"IGNORE_ACTION_ADD":return on.IGNORE_ACTION_ADD;case 2:case"IGNORE_ACTION_REMOVE":return on.IGNORE_ACTION_REMOVE;default:return on.UNRECOGNIZED}}E(ZP,"ignoreActionFromJSON");function Ry(e){switch(e){case on.IGNORE_ACTION_UNSPECIFIED:return"IGNORE_ACTION_UNSPECIFIED";case on.IGNORE_ACTION_ADD:return"IGNORE_ACTION_ADD";case on.IGNORE_ACTION_REMOVE:return"IGNORE_ACTION_REMOVE";case on.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Ry,"ignoreActionToJSON");var an;(function(e){e[e.BLOCK_ACTION_UNSPECIFIED=0]="BLOCK_ACTION_UNSPECIFIED",e[e.BLOCK_ACTION_ADD=1]="BLOCK_ACTION_ADD",e[e.BLOCK_ACTION_REMOVE=2]="BLOCK_ACTION_REMOVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(an||(an={}));function XP(e){switch(e){case 0:case"BLOCK_ACTION_UNSPECIFIED":return an.BLOCK_ACTION_UNSPECIFIED;case 1:case"BLOCK_ACTION_ADD":return an.BLOCK_ACTION_ADD;case 2:case"BLOCK_ACTION_REMOVE":return an.BLOCK_ACTION_REMOVE;default:return an.UNRECOGNIZED}}E(XP,"blockActionFromJSON");function Ay(e){switch(e){case an.BLOCK_ACTION_UNSPECIFIED:return"BLOCK_ACTION_UNSPECIFIED";case an.BLOCK_ACTION_ADD:return"BLOCK_ACTION_ADD";case an.BLOCK_ACTION_REMOVE:return"BLOCK_ACTION_REMOVE";case an.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Ay,"blockActionToJSON");var Zr;(function(e){e[e.COSMETIC_TYPE_UNSPECIFIED=0]="COSMETIC_TYPE_UNSPECIFIED",e[e.COSMETIC_TYPE_ROBBER=1]="COSMETIC_TYPE_ROBBER",e[e.COSMETIC_TYPE_TILE_SET=2]="COSMETIC_TYPE_TILE_SET",e[e.COSMETIC_TYPE_BUILDINGS=3]="COSMETIC_TYPE_BUILDINGS",e[e.COSMETIC_TYPE_DICE=4]="COSMETIC_TYPE_DICE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Zr||(Zr={}));function zP(e){switch(e){case 0:case"COSMETIC_TYPE_UNSPECIFIED":return Zr.COSMETIC_TYPE_UNSPECIFIED;case 1:case"COSMETIC_TYPE_ROBBER":return Zr.COSMETIC_TYPE_ROBBER;case 2:case"COSMETIC_TYPE_TILE_SET":return Zr.COSMETIC_TYPE_TILE_SET;case 3:case"COSMETIC_TYPE_BUILDINGS":return Zr.COSMETIC_TYPE_BUILDINGS;case 4:case"COSMETIC_TYPE_DICE":return Zr.COSMETIC_TYPE_DICE;default:return Zr.UNRECOGNIZED}}E(zP,"cosmeticTypeFromJSON");function Sy(e){switch(e){case Zr.COSMETIC_TYPE_UNSPECIFIED:return"COSMETIC_TYPE_UNSPECIFIED";case Zr.COSMETIC_TYPE_ROBBER:return"COSMETIC_TYPE_ROBBER";case Zr.COSMETIC_TYPE_TILE_SET:return"COSMETIC_TYPE_TILE_SET";case Zr.COSMETIC_TYPE_BUILDINGS:return"COSMETIC_TYPE_BUILDINGS";case Zr.COSMETIC_TYPE_DICE:return"COSMETIC_TYPE_DICE";case Zr.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Sy,"cosmeticTypeToJSON");var $P;(function(e){e[e.COSMETIC_GRANT_STATUS_UNSPECIFIED=0]="COSMETIC_GRANT_STATUS_UNSPECIFIED",e[e.COSMETIC_GRANT_STATUS_ACTIVE=1]="COSMETIC_GRANT_STATUS_ACTIVE",e[e.COSMETIC_GRANT_STATUS_REVOKED=2]="COSMETIC_GRANT_STATUS_REVOKED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})($P||($P={}));var sn;(function(e){e[e.SITE_THEME_UNSPECIFIED=0]="SITE_THEME_UNSPECIFIED",e[e.SITE_THEME_WOOD=1]="SITE_THEME_WOOD",e[e.SITE_THEME_CLASSIC=2]="SITE_THEME_CLASSIC",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(sn||(sn={}));function Oy(e){switch(e){case 0:case"SITE_THEME_UNSPECIFIED":return sn.SITE_THEME_UNSPECIFIED;case 1:case"SITE_THEME_WOOD":return sn.SITE_THEME_WOOD;case 2:case"SITE_THEME_CLASSIC":return sn.SITE_THEME_CLASSIC;default:return sn.UNRECOGNIZED}}E(Oy,"siteThemeFromJSON");function Iy(e){switch(e){case sn.SITE_THEME_UNSPECIFIED:return"SITE_THEME_UNSPECIFIED";case sn.SITE_THEME_WOOD:return"SITE_THEME_WOOD";case sn.SITE_THEME_CLASSIC:return"SITE_THEME_CLASSIC";case sn.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Iy,"siteThemeToJSON");var _n;(function(e){e[e.UI_LAYOUT_SIZE_KIND_UNSPECIFIED=0]="UI_LAYOUT_SIZE_KIND_UNSPECIFIED",e[e.UI_LAYOUT_SIZE_KIND_ACTION_BAR=1]="UI_LAYOUT_SIZE_KIND_ACTION_BAR",e[e.UI_LAYOUT_SIZE_KIND_SIDEBAR_WIDTH=2]="UI_LAYOUT_SIZE_KIND_SIDEBAR_WIDTH",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(_n||(_n={}));function Cy(e){switch(e){case 0:case"UI_LAYOUT_SIZE_KIND_UNSPECIFIED":return _n.UI_LAYOUT_SIZE_KIND_UNSPECIFIED;case 1:case"UI_LAYOUT_SIZE_KIND_ACTION_BAR":return _n.UI_LAYOUT_SIZE_KIND_ACTION_BAR;case 2:case"UI_LAYOUT_SIZE_KIND_SIDEBAR_WIDTH":return _n.UI_LAYOUT_SIZE_KIND_SIDEBAR_WIDTH;default:return _n.UNRECOGNIZED}}E(Cy,"uiLayoutSizeKindFromJSON");function Py(e){switch(e){case _n.UI_LAYOUT_SIZE_KIND_UNSPECIFIED:return"UI_LAYOUT_SIZE_KIND_UNSPECIFIED";case _n.UI_LAYOUT_SIZE_KIND_ACTION_BAR:return"UI_LAYOUT_SIZE_KIND_ACTION_BAR";case _n.UI_LAYOUT_SIZE_KIND_SIDEBAR_WIDTH:return"UI_LAYOUT_SIZE_KIND_SIDEBAR_WIDTH";case _n.UNRECOGNIZED:default:return"UNRECOGNIZED"}}E(Py,"uiLayoutSizeKindToJSON");var QP;(function(e){e[e.NAME_REFUSAL_REASON_UNSPECIFIED=0]="NAME_REFUSAL_REASON_UNSPECIFIED",e[e.NAME_REFUSAL_REASON_TOO_SHORT=1]="NAME_REFUSAL_REASON_TOO_SHORT",e[e.NAME_REFUSAL_REASON_TOO_LONG=2]="NAME_REFUSAL_REASON_TOO_LONG",e[e.NAME_REFUSAL_REASON_INVALID_CHARACTERS=3]="NAME_REFUSAL_REASON_INVALID_CHARACTERS",e[e.NAME_REFUSAL_REASON_RESERVED=4]="NAME_REFUSAL_REASON_RESERVED",e[e.NAME_REFUSAL_REASON_TAKEN=5]="NAME_REFUSAL_REASON_TAKEN",e[e.NAME_REFUSAL_REASON_NOT_ALLOWED=6]="NAME_REFUSAL_REASON_NOT_ALLOWED",e[e.NAME_REFUSAL_REASON_TOO_MANY_ATTEMPTS=7]="NAME_REFUSAL_REASON_TOO_MANY_ATTEMPTS",e[e.NAME_REFUSAL_REASON_LOCKED=8]="NAME_REFUSAL_REASON_LOCKED",e[e.NAME_REFUSAL_REASON_AGENT_PREFIX_REQUIRED=9]="NAME_REFUSAL_REASON_AGENT_PREFIX_REQUIRED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(QP||(QP={}));function jP(){return{referralCode:"",agentKind:0}}E(jP,"createBaseEnsureUserDocParams");var bo={encode(e,r=new Oe){return e.referralCode!==""&&r.uint32(10).string(e.referralCode),e.agentKind!==0&&r.uint32(16).int32(e.agentKind),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=jP();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.referralCode=t.string();continue}case 2:{if(n!==16)break;i.agentKind=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{referralCode:M(e.referralCode)?globalThis.String(e.referralCode):M(e.referral_code)?globalThis.String(e.referral_code):"",agentKind:M(e.agentKind)?Kr(e.agentKind):M(e.agent_kind)?Kr(e.agent_kind):0}},toJSON(e){let r={};return e.referralCode!==""&&(r.referralCode=e.referralCode),e.agentKind!==0&&(r.agentKind=Ut(e.agentKind)),r},create(e){return bo.fromPartial(e??{})},fromPartial(e){let r=jP();return r.referralCode=e.referralCode??"",r.agentKind=e.agentKind??0,r}};function ep(){return{}}E(ep,"createBaseCompleteGoogleSignInParams");var vo={encode(e,r=new Oe){return r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=ep();for(;t.pos<o;){let n=t.uint32();if(n>>>3,(n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{}},toJSON(e){return{}},create(e){return vo.fromPartial(e??{})},fromPartial(e){return ep()}};function rp(){return{displayName:""}}E(rp,"createBaseCreateOrUpdateProfileParams");var Yo={encode(e,r=new Oe){return e.displayName!==""&&r.uint32(10).string(e.displayName),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=rp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.displayName=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{displayName:M(e.displayName)?globalThis.String(e.displayName):M(e.display_name)?globalThis.String(e.display_name):""}},toJSON(e){let r={};return e.displayName!==""&&(r.displayName=e.displayName),r},create(e){return Yo.fromPartial(e??{})},fromPartial(e){let r=rp();return r.displayName=e.displayName??"",r}};function tp(){return{confirmDelete:!1}}E(tp,"createBaseDeleteProfileParams");var Fo={encode(e,r=new Oe){return e.confirmDelete!==!1&&r.uint32(8).bool(e.confirmDelete),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=tp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.confirmDelete=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{confirmDelete:M(e.confirmDelete)?globalThis.Boolean(e.confirmDelete):M(e.confirm_delete)?globalThis.Boolean(e.confirm_delete):!1}},toJSON(e){let r={};return e.confirmDelete!==!1&&(r.confirmDelete=e.confirmDelete),r},create(e){return Fo.fromPartial(e??{})},fromPartial(e){let r=tp();return r.confirmDelete=e.confirmDelete??!1,r}};function np(){return{limit:0}}E(np,"createBaseGetRecentGamesParams");var Vo={encode(e,r=new Oe){return e.limit!==0&&r.uint32(8).int32(e.limit),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=np();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.limit=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{limit:M(e.limit)?globalThis.Number(e.limit):0}},toJSON(e){let r={};return e.limit!==0&&(r.limit=Math.round(e.limit)),r},create(e){return Vo.fromPartial(e??{})},fromPartial(e){let r=np();return r.limit=e.limit??0,r}};function ip(){return{targetUid:"",friendAction:0}}E(ip,"createBaseManageFriendParams");var xo={encode(e,r=new Oe){return e.targetUid!==""&&r.uint32(10).string(e.targetUid),e.friendAction!==0&&r.uint32(16).int32(e.friendAction),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=ip();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.targetUid=t.string();continue}case 2:{if(n!==16)break;i.friendAction=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{targetUid:M(e.targetUid)?globalThis.String(e.targetUid):M(e.target_uid)?globalThis.String(e.target_uid):"",friendAction:M(e.friendAction)?qP(e.friendAction):M(e.friend_action)?qP(e.friend_action):0}},toJSON(e){let r={};return e.targetUid!==""&&(r.targetUid=e.targetUid),e.friendAction!==0&&(r.friendAction=Ny(e.friendAction)),r},create(e){return xo.fromPartial(e??{})},fromPartial(e){let r=ip();return r.targetUid=e.targetUid??"",r.friendAction=e.friendAction??0,r}};function op(){return{requesterUid:""}}E(op,"createBaseAcceptFriendRequestParams");var wo={encode(e,r=new Oe){return e.requesterUid!==""&&r.uint32(10).string(e.requesterUid),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=op();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.requesterUid=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{requesterUid:M(e.requesterUid)?globalThis.String(e.requesterUid):M(e.requester_uid)?globalThis.String(e.requester_uid):""}},toJSON(e){let r={};return e.requesterUid!==""&&(r.requesterUid=e.requesterUid),r},create(e){return wo.fromPartial(e??{})},fromPartial(e){let r=op();return r.requesterUid=e.requesterUid??"",r}};function ap(){return{requesterUid:""}}E(ap,"createBaseDeclineFriendRequestParams");var Ho={encode(e,r=new Oe){return e.requesterUid!==""&&r.uint32(10).string(e.requesterUid),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=ap();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.requesterUid=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{requesterUid:M(e.requesterUid)?globalThis.String(e.requesterUid):M(e.requester_uid)?globalThis.String(e.requester_uid):""}},toJSON(e){let r={};return e.requesterUid!==""&&(r.requesterUid=e.requesterUid),r},create(e){return Ho.fromPartial(e??{})},fromPartial(e){let r=ap();return r.requesterUid=e.requesterUid??"",r}};function sp(){return{friendUid:""}}E(sp,"createBaseRemoveFriendParams");var Ko={encode(e,r=new Oe){return e.friendUid!==""&&r.uint32(10).string(e.friendUid),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=sp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.friendUid=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{friendUid:M(e.friendUid)?globalThis.String(e.friendUid):M(e.friend_uid)?globalThis.String(e.friend_uid):""}},toJSON(e){let r={};return e.friendUid!==""&&(r.friendUid=e.friendUid),r},create(e){return Ko.fromPartial(e??{})},fromPartial(e){let r=sp();return r.friendUid=e.friendUid??"",r}};function _p(){return{targetUid:"",ignoreAction:0,lobbyId:"",gameId:""}}E(_p,"createBaseManageIgnoreParams");var Wo={encode(e,r=new Oe){return e.targetUid!==""&&r.uint32(10).string(e.targetUid),e.ignoreAction!==0&&r.uint32(16).int32(e.ignoreAction),e.lobbyId!==""&&r.uint32(26).string(e.lobbyId),e.gameId!==""&&r.uint32(34).string(e.gameId),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=_p();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.targetUid=t.string();continue}case 2:{if(n!==16)break;i.ignoreAction=t.int32();continue}case 3:{if(n!==26)break;i.lobbyId=t.string();continue}case 4:{if(n!==34)break;i.gameId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{targetUid:M(e.targetUid)?globalThis.String(e.targetUid):M(e.target_uid)?globalThis.String(e.target_uid):"",ignoreAction:M(e.ignoreAction)?ZP(e.ignoreAction):M(e.ignore_action)?ZP(e.ignore_action):0,lobbyId:M(e.lobbyId)?globalThis.String(e.lobbyId):M(e.lobby_id)?globalThis.String(e.lobby_id):"",gameId:M(e.gameId)?globalThis.String(e.gameId):M(e.game_id)?globalThis.String(e.game_id):""}},toJSON(e){let r={};return e.targetUid!==""&&(r.targetUid=e.targetUid),e.ignoreAction!==0&&(r.ignoreAction=Ry(e.ignoreAction)),e.lobbyId!==""&&(r.lobbyId=e.lobbyId),e.gameId!==""&&(r.gameId=e.gameId),r},create(e){return Wo.fromPartial(e??{})},fromPartial(e){let r=_p();return r.targetUid=e.targetUid??"",r.ignoreAction=e.ignoreAction??0,r.lobbyId=e.lobbyId??"",r.gameId=e.gameId??"",r}};function dp(){return{targetUid:"",blockAction:0}}E(dp,"createBaseManageBlockParams");var Jo={encode(e,r=new Oe){return e.targetUid!==""&&r.uint32(10).string(e.targetUid),e.blockAction!==0&&r.uint32(16).int32(e.blockAction),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=dp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.targetUid=t.string();continue}case 2:{if(n!==16)break;i.blockAction=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{targetUid:M(e.targetUid)?globalThis.String(e.targetUid):M(e.target_uid)?globalThis.String(e.target_uid):"",blockAction:M(e.blockAction)?XP(e.blockAction):M(e.block_action)?XP(e.block_action):0}},toJSON(e){let r={};return e.targetUid!==""&&(r.targetUid=e.targetUid),e.blockAction!==0&&(r.blockAction=Ay(e.blockAction)),r},create(e){return Jo.fromPartial(e??{})},fromPartial(e){let r=dp();return r.targetUid=e.targetUid??"",r.blockAction=e.blockAction??0,r}};function up(){return{cosmeticType:0,cosmeticId:""}}E(up,"createBaseEquipCosmeticParams");var qo={encode(e,r=new Oe){return e.cosmeticType!==0&&r.uint32(8).int32(e.cosmeticType),e.cosmeticId!==""&&r.uint32(18).string(e.cosmeticId),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=up();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.cosmeticType=t.int32();continue}case 2:{if(n!==18)break;i.cosmeticId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{cosmeticType:M(e.cosmeticType)?zP(e.cosmeticType):M(e.cosmetic_type)?zP(e.cosmetic_type):0,cosmeticId:M(e.cosmeticId)?globalThis.String(e.cosmeticId):M(e.cosmetic_id)?globalThis.String(e.cosmetic_id):""}},toJSON(e){let r={};return e.cosmeticType!==0&&(r.cosmeticType=Sy(e.cosmeticType)),e.cosmeticId!==""&&(r.cosmeticId=e.cosmeticId),r},create(e){return qo.fromPartial(e??{})},fromPartial(e){let r=up();return r.cosmeticType=e.cosmeticType??0,r.cosmeticId=e.cosmeticId??"",r}};function Ep(){return{colorblindMode:void 0,preferredColor:0,language:"",disableResourceAnimations:void 0,disableLongestRoadHighlight:void 0,theme:0,onlyPresentFields:!1}}E(Ep,"createBaseUpdateDisplayOptionsParams");var Zo={encode(e,r=new Oe){return e.colorblindMode!==void 0&&r.uint32(8).int32(e.colorblindMode),e.preferredColor!==0&&r.uint32(16).int32(e.preferredColor),e.language!==""&&r.uint32(26).string(e.language),e.disableResourceAnimations!==void 0&&r.uint32(32).bool(e.disableResourceAnimations),e.disableLongestRoadHighlight!==void 0&&r.uint32(40).bool(e.disableLongestRoadHighlight),e.theme!==0&&r.uint32(48).int32(e.theme),e.onlyPresentFields!==!1&&r.uint32(56).bool(e.onlyPresentFields),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Ep();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.colorblindMode=t.int32();continue}case 2:{if(n!==16)break;i.preferredColor=t.int32();continue}case 3:{if(n!==26)break;i.language=t.string();continue}case 4:{if(n!==32)break;i.disableResourceAnimations=t.bool();continue}case 5:{if(n!==40)break;i.disableLongestRoadHighlight=t.bool();continue}case 6:{if(n!==48)break;i.theme=t.int32();continue}case 7:{if(n!==56)break;i.onlyPresentFields=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{colorblindMode:M(e.colorblindMode)?globalThis.Number(e.colorblindMode):M(e.colorblind_mode)?globalThis.Number(e.colorblind_mode):void 0,preferredColor:M(e.preferredColor)?globalThis.Number(e.preferredColor):M(e.preferred_color)?globalThis.Number(e.preferred_color):0,language:M(e.language)?globalThis.String(e.language):"",disableResourceAnimations:M(e.disableResourceAnimations)?globalThis.Boolean(e.disableResourceAnimations):M(e.disable_resource_animations)?globalThis.Boolean(e.disable_resource_animations):void 0,disableLongestRoadHighlight:M(e.disableLongestRoadHighlight)?globalThis.Boolean(e.disableLongestRoadHighlight):M(e.disable_longest_road_highlight)?globalThis.Boolean(e.disable_longest_road_highlight):void 0,theme:M(e.theme)?Oy(e.theme):0,onlyPresentFields:M(e.onlyPresentFields)?globalThis.Boolean(e.onlyPresentFields):M(e.only_present_fields)?globalThis.Boolean(e.only_present_fields):!1}},toJSON(e){let r={};return e.colorblindMode!==void 0&&(r.colorblindMode=Math.round(e.colorblindMode)),e.preferredColor!==0&&(r.preferredColor=Math.round(e.preferredColor)),e.language!==""&&(r.language=e.language),e.disableResourceAnimations!==void 0&&(r.disableResourceAnimations=e.disableResourceAnimations),e.disableLongestRoadHighlight!==void 0&&(r.disableLongestRoadHighlight=e.disableLongestRoadHighlight),e.theme!==0&&(r.theme=Iy(e.theme)),e.onlyPresentFields!==!1&&(r.onlyPresentFields=e.onlyPresentFields),r},create(e){return Zo.fromPartial(e??{})},fromPartial(e){let r=Ep();return r.colorblindMode=e.colorblindMode??void 0,r.preferredColor=e.preferredColor??0,r.language=e.language??"",r.disableResourceAnimations=e.disableResourceAnimations??void 0,r.disableLongestRoadHighlight=e.disableLongestRoadHighlight??void 0,r.theme=e.theme??0,r.onlyPresentFields=e.onlyPresentFields??!1,r}};function lp(){return{notificationId:""}}E(lp,"createBaseMarkNotificationReadParams");var Xo={encode(e,r=new Oe){return e.notificationId!==""&&r.uint32(10).string(e.notificationId),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=lp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.notificationId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{notificationId:M(e.notificationId)?globalThis.String(e.notificationId):M(e.notification_id)?globalThis.String(e.notification_id):""}},toJSON(e){let r={};return e.notificationId!==""&&(r.notificationId=e.notificationId),r},create(e){return Xo.fromPartial(e??{})},fromPartial(e){let r=lp();return r.notificationId=e.notificationId??"",r}};function cp(){return{notificationId:""}}E(cp,"createBaseDismissNotificationParams");var zo={encode(e,r=new Oe){return e.notificationId!==""&&r.uint32(10).string(e.notificationId),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=cp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.notificationId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{notificationId:M(e.notificationId)?globalThis.String(e.notificationId):M(e.notification_id)?globalThis.String(e.notification_id):""}},toJSON(e){let r={};return e.notificationId!==""&&(r.notificationId=e.notificationId),r},create(e){return zo.fromPartial(e??{})},fromPartial(e){let r=cp();return r.notificationId=e.notificationId??"",r}};function fp(){return{}}E(fp,"createBaseMarkAllNotificationsReadParams");var $o={encode(e,r=new Oe){return r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=fp();for(;t.pos<o;){let n=t.uint32();if(n>>>3,(n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{}},toJSON(e){return{}},create(e){return $o.fromPartial(e??{})},fromPartial(e){return fp()}};function Tp(){return{username:""}}E(Tp,"createBaseGetProfileByUsernameParams");var Qo={encode(e,r=new Oe){return e.username!==""&&r.uint32(10).string(e.username),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Tp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.username=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{username:M(e.username)?globalThis.String(e.username):""}},toJSON(e){let r={};return e.username!==""&&(r.username=e.username),r},create(e){return Qo.fromPartial(e??{})},fromPartial(e){let r=Tp();return r.username=e.username??"",r}};function Np(){return{achievementIds:[]}}E(Np,"createBaseUpdatePinnedAchievementsParams");var jo={encode(e,r=new Oe){for(let t of e.achievementIds)r.uint32(10).string(t);return r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Np();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.achievementIds.push(t.string());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{achievementIds:globalThis.Array.isArray(e?.achievementIds)?e.achievementIds.map(r=>globalThis.String(r)):globalThis.Array.isArray(e?.achievement_ids)?e.achievement_ids.map(r=>globalThis.String(r)):[]}},toJSON(e){let r={};return e.achievementIds?.length&&(r.achievementIds=e.achievementIds),r},create(e){return jo.fromPartial(e??{})},fromPartial(e){let r=Np();return r.achievementIds=e.achievementIds?.map(t=>t)||[],r}};function Rp(){return{layoutKey:"",scale:0,updatedAt:0,kind:0}}E(Rp,"createBaseSaveUiLayoutSizeParams");var ea={encode(e,r=new Oe){return e.layoutKey!==""&&r.uint32(10).string(e.layoutKey),e.scale!==0&&r.uint32(17).double(e.scale),e.updatedAt!==0&&r.uint32(24).int64(e.updatedAt),e.kind!==0&&r.uint32(32).int32(e.kind),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Rp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.layoutKey=t.string();continue}case 2:{if(n!==17)break;i.scale=t.double();continue}case 3:{if(n!==24)break;i.updatedAt=py(t.int64());continue}case 4:{if(n!==32)break;i.kind=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{layoutKey:M(e.layoutKey)?globalThis.String(e.layoutKey):M(e.layout_key)?globalThis.String(e.layout_key):"",scale:M(e.scale)?globalThis.Number(e.scale):0,updatedAt:M(e.updatedAt)?globalThis.Number(e.updatedAt):M(e.updated_at)?globalThis.Number(e.updated_at):0,kind:M(e.kind)?Cy(e.kind):0}},toJSON(e){let r={};return e.layoutKey!==""&&(r.layoutKey=e.layoutKey),e.scale!==0&&(r.scale=e.scale),e.updatedAt!==0&&(r.updatedAt=Math.round(e.updatedAt)),e.kind!==0&&(r.kind=Py(e.kind)),r},create(e){return ea.fromPartial(e??{})},fromPartial(e){let r=Rp();return r.layoutKey=e.layoutKey??"",r.scale=e.scale??0,r.updatedAt=e.updatedAt??0,r.kind=e.kind??0,r}};function Ap(){return{expansionId:""}}E(Ap,"createBaseToggleExpansionReactionParams");var ra={encode(e,r=new Oe){return e.expansionId!==""&&r.uint32(10).string(e.expansionId),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Ap();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.expansionId=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{expansionId:M(e.expansionId)?globalThis.String(e.expansionId):M(e.expansion_id)?globalThis.String(e.expansion_id):""}},toJSON(e){let r={};return e.expansionId!==""&&(r.expansionId=e.expansionId),r},create(e){return ra.fromPartial(e??{})},fromPartial(e){let r=Ap();return r.expansionId=e.expansionId??"",r}};function Sp(){return{actionType:0,createOrUpdateProfile:void 0,deleteProfile:void 0,getRecentGames:void 0,manageFriend:void 0,acceptFriendRequest:void 0,declineFriendRequest:void 0,removeFriend:void 0,manageIgnore:void 0,ensureUserDoc:void 0,completeGoogleSignIn:void 0,manageBlock:void 0,equipCosmetic:void 0,updateDisplayOptions:void 0,markNotificationRead:void 0,dismissNotification:void 0,markAllNotificationsRead:void 0,getProfileByUsername:void 0,updatePinnedAchievements:void 0,toggleExpansionReaction:void 0,saveUiLayoutSize:void 0}}E(Sp,"createBaseUserActionRequest");var gu={encode(e,r=new Oe){return e.actionType!==0&&r.uint32(8).int32(e.actionType),e.createOrUpdateProfile!==void 0&&Yo.encode(e.createOrUpdateProfile,r.uint32(18).fork()).join(),e.deleteProfile!==void 0&&Fo.encode(e.deleteProfile,r.uint32(26).fork()).join(),e.getRecentGames!==void 0&&Vo.encode(e.getRecentGames,r.uint32(34).fork()).join(),e.manageFriend!==void 0&&xo.encode(e.manageFriend,r.uint32(42).fork()).join(),e.acceptFriendRequest!==void 0&&wo.encode(e.acceptFriendRequest,r.uint32(50).fork()).join(),e.declineFriendRequest!==void 0&&Ho.encode(e.declineFriendRequest,r.uint32(58).fork()).join(),e.removeFriend!==void 0&&Ko.encode(e.removeFriend,r.uint32(66).fork()).join(),e.manageIgnore!==void 0&&Wo.encode(e.manageIgnore,r.uint32(74).fork()).join(),e.ensureUserDoc!==void 0&&bo.encode(e.ensureUserDoc,r.uint32(82).fork()).join(),e.completeGoogleSignIn!==void 0&&vo.encode(e.completeGoogleSignIn,r.uint32(90).fork()).join(),e.manageBlock!==void 0&&Jo.encode(e.manageBlock,r.uint32(98).fork()).join(),e.equipCosmetic!==void 0&&qo.encode(e.equipCosmetic,r.uint32(106).fork()).join(),e.updateDisplayOptions!==void 0&&Zo.encode(e.updateDisplayOptions,r.uint32(114).fork()).join(),e.markNotificationRead!==void 0&&Xo.encode(e.markNotificationRead,r.uint32(122).fork()).join(),e.dismissNotification!==void 0&&zo.encode(e.dismissNotification,r.uint32(130).fork()).join(),e.markAllNotificationsRead!==void 0&&$o.encode(e.markAllNotificationsRead,r.uint32(138).fork()).join(),e.getProfileByUsername!==void 0&&Qo.encode(e.getProfileByUsername,r.uint32(146).fork()).join(),e.updatePinnedAchievements!==void 0&&jo.encode(e.updatePinnedAchievements,r.uint32(154).fork()).join(),e.toggleExpansionReaction!==void 0&&ra.encode(e.toggleExpansionReaction,r.uint32(162).fork()).join(),e.saveUiLayoutSize!==void 0&&ea.encode(e.saveUiLayoutSize,r.uint32(170).fork()).join(),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Sp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.actionType=t.int32();continue}case 2:{if(n!==18)break;i.createOrUpdateProfile=Yo.decode(t,t.uint32());continue}case 3:{if(n!==26)break;i.deleteProfile=Fo.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.getRecentGames=Vo.decode(t,t.uint32());continue}case 5:{if(n!==42)break;i.manageFriend=xo.decode(t,t.uint32());continue}case 6:{if(n!==50)break;i.acceptFriendRequest=wo.decode(t,t.uint32());continue}case 7:{if(n!==58)break;i.declineFriendRequest=Ho.decode(t,t.uint32());continue}case 8:{if(n!==66)break;i.removeFriend=Ko.decode(t,t.uint32());continue}case 9:{if(n!==74)break;i.manageIgnore=Wo.decode(t,t.uint32());continue}case 10:{if(n!==82)break;i.ensureUserDoc=bo.decode(t,t.uint32());continue}case 11:{if(n!==90)break;i.completeGoogleSignIn=vo.decode(t,t.uint32());continue}case 12:{if(n!==98)break;i.manageBlock=Jo.decode(t,t.uint32());continue}case 13:{if(n!==106)break;i.equipCosmetic=qo.decode(t,t.uint32());continue}case 14:{if(n!==114)break;i.updateDisplayOptions=Zo.decode(t,t.uint32());continue}case 15:{if(n!==122)break;i.markNotificationRead=Xo.decode(t,t.uint32());continue}case 16:{if(n!==130)break;i.dismissNotification=zo.decode(t,t.uint32());continue}case 17:{if(n!==138)break;i.markAllNotificationsRead=$o.decode(t,t.uint32());continue}case 18:{if(n!==146)break;i.getProfileByUsername=Qo.decode(t,t.uint32());continue}case 19:{if(n!==154)break;i.updatePinnedAchievements=jo.decode(t,t.uint32());continue}case 20:{if(n!==162)break;i.toggleExpansionReaction=ra.decode(t,t.uint32());continue}case 21:{if(n!==170)break;i.saveUiLayoutSize=ea.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{actionType:M(e.actionType)?JP(e.actionType):M(e.action_type)?JP(e.action_type):0,createOrUpdateProfile:M(e.createOrUpdateProfile)?Yo.fromJSON(e.createOrUpdateProfile):M(e.create_or_update_profile)?Yo.fromJSON(e.create_or_update_profile):void 0,deleteProfile:M(e.deleteProfile)?Fo.fromJSON(e.deleteProfile):M(e.delete_profile)?Fo.fromJSON(e.delete_profile):void 0,getRecentGames:M(e.getRecentGames)?Vo.fromJSON(e.getRecentGames):M(e.get_recent_games)?Vo.fromJSON(e.get_recent_games):void 0,manageFriend:M(e.manageFriend)?xo.fromJSON(e.manageFriend):M(e.manage_friend)?xo.fromJSON(e.manage_friend):void 0,acceptFriendRequest:M(e.acceptFriendRequest)?wo.fromJSON(e.acceptFriendRequest):M(e.accept_friend_request)?wo.fromJSON(e.accept_friend_request):void 0,declineFriendRequest:M(e.declineFriendRequest)?Ho.fromJSON(e.declineFriendRequest):M(e.decline_friend_request)?Ho.fromJSON(e.decline_friend_request):void 0,removeFriend:M(e.removeFriend)?Ko.fromJSON(e.removeFriend):M(e.remove_friend)?Ko.fromJSON(e.remove_friend):void 0,manageIgnore:M(e.manageIgnore)?Wo.fromJSON(e.manageIgnore):M(e.manage_ignore)?Wo.fromJSON(e.manage_ignore):void 0,ensureUserDoc:M(e.ensureUserDoc)?bo.fromJSON(e.ensureUserDoc):M(e.ensure_user_doc)?bo.fromJSON(e.ensure_user_doc):void 0,completeGoogleSignIn:M(e.completeGoogleSignIn)?vo.fromJSON(e.completeGoogleSignIn):M(e.complete_google_sign_in)?vo.fromJSON(e.complete_google_sign_in):void 0,manageBlock:M(e.manageBlock)?Jo.fromJSON(e.manageBlock):M(e.manage_block)?Jo.fromJSON(e.manage_block):void 0,equipCosmetic:M(e.equipCosmetic)?qo.fromJSON(e.equipCosmetic):M(e.equip_cosmetic)?qo.fromJSON(e.equip_cosmetic):void 0,updateDisplayOptions:M(e.updateDisplayOptions)?Zo.fromJSON(e.updateDisplayOptions):M(e.update_display_options)?Zo.fromJSON(e.update_display_options):void 0,markNotificationRead:M(e.markNotificationRead)?Xo.fromJSON(e.markNotificationRead):M(e.mark_notification_read)?Xo.fromJSON(e.mark_notification_read):void 0,dismissNotification:M(e.dismissNotification)?zo.fromJSON(e.dismissNotification):M(e.dismiss_notification)?zo.fromJSON(e.dismiss_notification):void 0,markAllNotificationsRead:M(e.markAllNotificationsRead)?$o.fromJSON(e.markAllNotificationsRead):M(e.mark_all_notifications_read)?$o.fromJSON(e.mark_all_notifications_read):void 0,getProfileByUsername:M(e.getProfileByUsername)?Qo.fromJSON(e.getProfileByUsername):M(e.get_profile_by_username)?Qo.fromJSON(e.get_profile_by_username):void 0,updatePinnedAchievements:M(e.updatePinnedAchievements)?jo.fromJSON(e.updatePinnedAchievements):M(e.update_pinned_achievements)?jo.fromJSON(e.update_pinned_achievements):void 0,toggleExpansionReaction:M(e.toggleExpansionReaction)?ra.fromJSON(e.toggleExpansionReaction):M(e.toggle_expansion_reaction)?ra.fromJSON(e.toggle_expansion_reaction):void 0,saveUiLayoutSize:M(e.saveUiLayoutSize)?ea.fromJSON(e.saveUiLayoutSize):M(e.save_ui_layout_size)?ea.fromJSON(e.save_ui_layout_size):void 0}},toJSON(e){let r={};return e.actionType!==0&&(r.actionType=Ty(e.actionType)),e.createOrUpdateProfile!==void 0&&(r.createOrUpdateProfile=Yo.toJSON(e.createOrUpdateProfile)),e.deleteProfile!==void 0&&(r.deleteProfile=Fo.toJSON(e.deleteProfile)),e.getRecentGames!==void 0&&(r.getRecentGames=Vo.toJSON(e.getRecentGames)),e.manageFriend!==void 0&&(r.manageFriend=xo.toJSON(e.manageFriend)),e.acceptFriendRequest!==void 0&&(r.acceptFriendRequest=wo.toJSON(e.acceptFriendRequest)),e.declineFriendRequest!==void 0&&(r.declineFriendRequest=Ho.toJSON(e.declineFriendRequest)),e.removeFriend!==void 0&&(r.removeFriend=Ko.toJSON(e.removeFriend)),e.manageIgnore!==void 0&&(r.manageIgnore=Wo.toJSON(e.manageIgnore)),e.ensureUserDoc!==void 0&&(r.ensureUserDoc=bo.toJSON(e.ensureUserDoc)),e.completeGoogleSignIn!==void 0&&(r.completeGoogleSignIn=vo.toJSON(e.completeGoogleSignIn)),e.manageBlock!==void 0&&(r.manageBlock=Jo.toJSON(e.manageBlock)),e.equipCosmetic!==void 0&&(r.equipCosmetic=qo.toJSON(e.equipCosmetic)),e.updateDisplayOptions!==void 0&&(r.updateDisplayOptions=Zo.toJSON(e.updateDisplayOptions)),e.markNotificationRead!==void 0&&(r.markNotificationRead=Xo.toJSON(e.markNotificationRead)),e.dismissNotification!==void 0&&(r.dismissNotification=zo.toJSON(e.dismissNotification)),e.markAllNotificationsRead!==void 0&&(r.markAllNotificationsRead=$o.toJSON(e.markAllNotificationsRead)),e.getProfileByUsername!==void 0&&(r.getProfileByUsername=Qo.toJSON(e.getProfileByUsername)),e.updatePinnedAchievements!==void 0&&(r.updatePinnedAchievements=jo.toJSON(e.updatePinnedAchievements)),e.toggleExpansionReaction!==void 0&&(r.toggleExpansionReaction=ra.toJSON(e.toggleExpansionReaction)),e.saveUiLayoutSize!==void 0&&(r.saveUiLayoutSize=ea.toJSON(e.saveUiLayoutSize)),r},create(e){return gu.fromPartial(e??{})},fromPartial(e){let r=Sp();return r.actionType=e.actionType??0,r.createOrUpdateProfile=e.createOrUpdateProfile!==void 0&&e.createOrUpdateProfile!==null?Yo.fromPartial(e.createOrUpdateProfile):void 0,r.deleteProfile=e.deleteProfile!==void 0&&e.deleteProfile!==null?Fo.fromPartial(e.deleteProfile):void 0,r.getRecentGames=e.getRecentGames!==void 0&&e.getRecentGames!==null?Vo.fromPartial(e.getRecentGames):void 0,r.manageFriend=e.manageFriend!==void 0&&e.manageFriend!==null?xo.fromPartial(e.manageFriend):void 0,r.acceptFriendRequest=e.acceptFriendRequest!==void 0&&e.acceptFriendRequest!==null?wo.fromPartial(e.acceptFriendRequest):void 0,r.declineFriendRequest=e.declineFriendRequest!==void 0&&e.declineFriendRequest!==null?Ho.fromPartial(e.declineFriendRequest):void 0,r.removeFriend=e.removeFriend!==void 0&&e.removeFriend!==null?Ko.fromPartial(e.removeFriend):void 0,r.manageIgnore=e.manageIgnore!==void 0&&e.manageIgnore!==null?Wo.fromPartial(e.manageIgnore):void 0,r.ensureUserDoc=e.ensureUserDoc!==void 0&&e.ensureUserDoc!==null?bo.fromPartial(e.ensureUserDoc):void 0,r.completeGoogleSignIn=e.completeGoogleSignIn!==void 0&&e.completeGoogleSignIn!==null?vo.fromPartial(e.completeGoogleSignIn):void 0,r.manageBlock=e.manageBlock!==void 0&&e.manageBlock!==null?Jo.fromPartial(e.manageBlock):void 0,r.equipCosmetic=e.equipCosmetic!==void 0&&e.equipCosmetic!==null?qo.fromPartial(e.equipCosmetic):void 0,r.updateDisplayOptions=e.updateDisplayOptions!==void 0&&e.updateDisplayOptions!==null?Zo.fromPartial(e.updateDisplayOptions):void 0,r.markNotificationRead=e.markNotificationRead!==void 0&&e.markNotificationRead!==null?Xo.fromPartial(e.markNotificationRead):void 0,r.dismissNotification=e.dismissNotification!==void 0&&e.dismissNotification!==null?zo.fromPartial(e.dismissNotification):void 0,r.markAllNotificationsRead=e.markAllNotificationsRead!==void 0&&e.markAllNotificationsRead!==null?$o.fromPartial(e.markAllNotificationsRead):void 0,r.getProfileByUsername=e.getProfileByUsername!==void 0&&e.getProfileByUsername!==null?Qo.fromPartial(e.getProfileByUsername):void 0,r.updatePinnedAchievements=e.updatePinnedAchievements!==void 0&&e.updatePinnedAchievements!==null?jo.fromPartial(e.updatePinnedAchievements):void 0,r.toggleExpansionReaction=e.toggleExpansionReaction!==void 0&&e.toggleExpansionReaction!==null?ra.fromPartial(e.toggleExpansionReaction):void 0,r.saveUiLayoutSize=e.saveUiLayoutSize!==void 0&&e.saveUiLayoutSize!==null?ea.fromPartial(e.saveUiLayoutSize):void 0,r}};function Op(){return{uid:"",displayName:"",createdAt:void 0,lastSeen:void 0,currentLobbyId:"",currentGameId:"",pinnedAchievements:[],agentKind:0}}E(Op,"createBaseUserProfile");var kr={encode(e,r=new Oe){e.uid!==""&&r.uint32(10).string(e.uid),e.displayName!==""&&r.uint32(18).string(e.displayName),e.createdAt!==void 0&&Le.encode(mu(e.createdAt),r.uint32(26).fork()).join(),e.lastSeen!==void 0&&Le.encode(mu(e.lastSeen),r.uint32(34).fork()).join(),e.currentLobbyId!==""&&r.uint32(42).string(e.currentLobbyId),e.currentGameId!==""&&r.uint32(50).string(e.currentGameId);for(let t of e.pinnedAchievements)r.uint32(58).string(t);return e.agentKind!==0&&r.uint32(64).int32(e.agentKind),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Op();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.uid=t.string();continue}case 2:{if(n!==18)break;i.displayName=t.string();continue}case 3:{if(n!==26)break;i.createdAt=z_(Le.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.lastSeen=z_(Le.decode(t,t.uint32()));continue}case 5:{if(n!==42)break;i.currentLobbyId=t.string();continue}case 6:{if(n!==50)break;i.currentGameId=t.string();continue}case 7:{if(n!==58)break;i.pinnedAchievements.push(t.string());continue}case 8:{if(n!==64)break;i.agentKind=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{uid:M(e.uid)?globalThis.String(e.uid):"",displayName:M(e.displayName)?globalThis.String(e.displayName):M(e.display_name)?globalThis.String(e.display_name):"",createdAt:M(e.createdAt)?zn(e.createdAt):M(e.created_at)?zn(e.created_at):void 0,lastSeen:M(e.lastSeen)?zn(e.lastSeen):M(e.last_seen)?zn(e.last_seen):void 0,currentLobbyId:M(e.currentLobbyId)?globalThis.String(e.currentLobbyId):M(e.current_lobby_id)?globalThis.String(e.current_lobby_id):"",currentGameId:M(e.currentGameId)?globalThis.String(e.currentGameId):M(e.current_game_id)?globalThis.String(e.current_game_id):"",pinnedAchievements:globalThis.Array.isArray(e?.pinnedAchievements)?e.pinnedAchievements.map(r=>globalThis.String(r)):globalThis.Array.isArray(e?.pinned_achievements)?e.pinned_achievements.map(r=>globalThis.String(r)):[],agentKind:M(e.agentKind)?Kr(e.agentKind):M(e.agent_kind)?Kr(e.agent_kind):0}},toJSON(e){let r={};return e.uid!==""&&(r.uid=e.uid),e.displayName!==""&&(r.displayName=e.displayName),e.createdAt!==void 0&&(r.createdAt=e.createdAt.toISOString()),e.lastSeen!==void 0&&(r.lastSeen=e.lastSeen.toISOString()),e.currentLobbyId!==""&&(r.currentLobbyId=e.currentLobbyId),e.currentGameId!==""&&(r.currentGameId=e.currentGameId),e.pinnedAchievements?.length&&(r.pinnedAchievements=e.pinnedAchievements),e.agentKind!==0&&(r.agentKind=Ut(e.agentKind)),r},create(e){return kr.fromPartial(e??{})},fromPartial(e){let r=Op();return r.uid=e.uid??"",r.displayName=e.displayName??"",r.createdAt=e.createdAt??void 0,r.lastSeen=e.lastSeen??void 0,r.currentLobbyId=e.currentLobbyId??"",r.currentGameId=e.currentGameId??"",r.pinnedAchievements=e.pinnedAchievements?.map(t=>t)||[],r.agentKind=e.agentKind??0,r}};function Ip(){return{gameId:"",createdAt:void 0,completedAt:void 0,status:"",numPlayers:0,expansions:[],victoryPoints:0,playerColor:0,isWinner:!1,players:[]}}E(Ip,"createBaseRecentGameSummary");var Ds={encode(e,r=new Oe){e.gameId!==""&&r.uint32(10).string(e.gameId),e.createdAt!==void 0&&Le.encode(mu(e.createdAt),r.uint32(18).fork()).join(),e.completedAt!==void 0&&Le.encode(mu(e.completedAt),r.uint32(26).fork()).join(),e.status!==""&&r.uint32(34).string(e.status),e.numPlayers!==0&&r.uint32(40).int32(e.numPlayers);for(let t of e.expansions)r.uint32(50).string(t);e.victoryPoints!==0&&r.uint32(56).int32(e.victoryPoints),e.playerColor!==0&&r.uint32(64).int32(e.playerColor),e.isWinner!==!1&&r.uint32(72).bool(e.isWinner);for(let t of e.players)ms.encode(t,r.uint32(82).fork()).join();return r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Ip();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.gameId=t.string();continue}case 2:{if(n!==18)break;i.createdAt=z_(Le.decode(t,t.uint32()));continue}case 3:{if(n!==26)break;i.completedAt=z_(Le.decode(t,t.uint32()));continue}case 4:{if(n!==34)break;i.status=t.string();continue}case 5:{if(n!==40)break;i.numPlayers=t.int32();continue}case 6:{if(n!==50)break;i.expansions.push(t.string());continue}case 7:{if(n!==56)break;i.victoryPoints=t.int32();continue}case 8:{if(n!==64)break;i.playerColor=t.int32();continue}case 9:{if(n!==72)break;i.isWinner=t.bool();continue}case 10:{if(n!==82)break;i.players.push(ms.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{gameId:M(e.gameId)?globalThis.String(e.gameId):M(e.game_id)?globalThis.String(e.game_id):"",createdAt:M(e.createdAt)?zn(e.createdAt):M(e.created_at)?zn(e.created_at):void 0,completedAt:M(e.completedAt)?zn(e.completedAt):M(e.completed_at)?zn(e.completed_at):void 0,status:M(e.status)?globalThis.String(e.status):"",numPlayers:M(e.numPlayers)?globalThis.Number(e.numPlayers):M(e.num_players)?globalThis.Number(e.num_players):0,expansions:globalThis.Array.isArray(e?.expansions)?e.expansions.map(r=>globalThis.String(r)):[],victoryPoints:M(e.victoryPoints)?globalThis.Number(e.victoryPoints):M(e.victory_points)?globalThis.Number(e.victory_points):0,playerColor:M(e.playerColor)?Ke(e.playerColor):M(e.player_color)?Ke(e.player_color):0,isWinner:M(e.isWinner)?globalThis.Boolean(e.isWinner):M(e.is_winner)?globalThis.Boolean(e.is_winner):!1,players:globalThis.Array.isArray(e?.players)?e.players.map(r=>ms.fromJSON(r)):[]}},toJSON(e){let r={};return e.gameId!==""&&(r.gameId=e.gameId),e.createdAt!==void 0&&(r.createdAt=e.createdAt.toISOString()),e.completedAt!==void 0&&(r.completedAt=e.completedAt.toISOString()),e.status!==""&&(r.status=e.status),e.numPlayers!==0&&(r.numPlayers=Math.round(e.numPlayers)),e.expansions?.length&&(r.expansions=e.expansions),e.victoryPoints!==0&&(r.victoryPoints=Math.round(e.victoryPoints)),e.playerColor!==0&&(r.playerColor=_r(e.playerColor)),e.isWinner!==!1&&(r.isWinner=e.isWinner),e.players?.length&&(r.players=e.players.map(t=>ms.toJSON(t))),r},create(e){return Ds.fromPartial(e??{})},fromPartial(e){let r=Ip();return r.gameId=e.gameId??"",r.createdAt=e.createdAt??void 0,r.completedAt=e.completedAt??void 0,r.status=e.status??"",r.numPlayers=e.numPlayers??0,r.expansions=e.expansions?.map(t=>t)||[],r.victoryPoints=e.victoryPoints??0,r.playerColor=e.playerColor??0,r.isWinner=e.isWinner??!1,r.players=e.players?.map(t=>ms.fromPartial(t))||[],r}};function Cp(){return{displayName:"",color:0,isWinner:!1}}E(Cp,"createBaseGamePlayerSummary");var ms={encode(e,r=new Oe){return e.displayName!==""&&r.uint32(10).string(e.displayName),e.color!==0&&r.uint32(16).int32(e.color),e.isWinner!==!1&&r.uint32(24).bool(e.isWinner),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Cp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.displayName=t.string();continue}case 2:{if(n!==16)break;i.color=t.int32();continue}case 3:{if(n!==24)break;i.isWinner=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{displayName:M(e.displayName)?globalThis.String(e.displayName):M(e.display_name)?globalThis.String(e.display_name):"",color:M(e.color)?Ke(e.color):0,isWinner:M(e.isWinner)?globalThis.Boolean(e.isWinner):M(e.is_winner)?globalThis.Boolean(e.is_winner):!1}},toJSON(e){let r={};return e.displayName!==""&&(r.displayName=e.displayName),e.color!==0&&(r.color=_r(e.color)),e.isWinner!==!1&&(r.isWinner=e.isWinner),r},create(e){return ms.fromPartial(e??{})},fromPartial(e){let r=Cp();return r.displayName=e.displayName??"",r.color=e.color??0,r.isWinner=e.isWinner??!1,r}};function Pp(){return{success:!1,profile:void 0}}E(Pp,"createBaseCreateOrUpdateProfileResult");var ta={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),e.profile!==void 0&&kr.encode(e.profile,r.uint32(18).fork()).join(),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Pp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==18)break;i.profile=kr.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1,profile:M(e.profile)?kr.fromJSON(e.profile):void 0}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.profile!==void 0&&(r.profile=kr.toJSON(e.profile)),r},create(e){return ta.fromPartial(e??{})},fromPartial(e){let r=Pp();return r.success=e.success??!1,r.profile=e.profile!==void 0&&e.profile!==null?kr.fromPartial(e.profile):void 0,r}};function pp(){return{success:!1}}E(pp,"createBaseDeleteProfileResult");var na={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=pp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return na.fromPartial(e??{})},fromPartial(e){let r=pp();return r.success=e.success??!1,r}};function hp(){return{games:[]}}E(hp,"createBaseGetRecentGamesResult");var ia={encode(e,r=new Oe){for(let t of e.games)Ds.encode(t,r.uint32(10).fork()).join();return r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=hp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.games.push(Ds.decode(t,t.uint32()));continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{games:globalThis.Array.isArray(e?.games)?e.games.map(r=>Ds.fromJSON(r)):[]}},toJSON(e){let r={};return e.games?.length&&(r.games=e.games.map(t=>Ds.toJSON(t))),r},create(e){return ia.fromPartial(e??{})},fromPartial(e){let r=hp();return r.games=e.games?.map(t=>Ds.fromPartial(t))||[],r}};function Dp(){return{success:!1}}E(Dp,"createBaseManageFriendResult");var oa={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Dp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return oa.fromPartial(e??{})},fromPartial(e){let r=Dp();return r.success=e.success??!1,r}};function mp(){return{success:!1}}E(mp,"createBaseAcceptFriendRequestResult");var aa={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=mp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return aa.fromPartial(e??{})},fromPartial(e){let r=mp();return r.success=e.success??!1,r}};function gp(){return{success:!1}}E(gp,"createBaseDeclineFriendRequestResult");var sa={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=gp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return sa.fromPartial(e??{})},fromPartial(e){let r=gp();return r.success=e.success??!1,r}};function yp(){return{success:!1}}E(yp,"createBaseRemoveFriendResult");var _a={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=yp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return _a.fromPartial(e??{})},fromPartial(e){let r=yp();return r.success=e.success??!1,r}};function Mp(){return{success:!1}}E(Mp,"createBaseManageIgnoreResult");var da={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Mp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return da.fromPartial(e??{})},fromPartial(e){let r=Mp();return r.success=e.success??!1,r}};function Lp(){return{success:!1,profile:void 0,created:!1}}E(Lp,"createBaseEnsureUserDocResult");var ua={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),e.profile!==void 0&&kr.encode(e.profile,r.uint32(18).fork()).join(),e.created!==!1&&r.uint32(24).bool(e.created),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Lp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==18)break;i.profile=kr.decode(t,t.uint32());continue}case 3:{if(n!==24)break;i.created=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1,profile:M(e.profile)?kr.fromJSON(e.profile):void 0,created:M(e.created)?globalThis.Boolean(e.created):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.profile!==void 0&&(r.profile=kr.toJSON(e.profile)),e.created!==!1&&(r.created=e.created),r},create(e){return ua.fromPartial(e??{})},fromPartial(e){let r=Lp();return r.success=e.success??!1,r.profile=e.profile!==void 0&&e.profile!==null?kr.fromPartial(e.profile):void 0,r.created=e.created??!1,r}};function Gp(){return{success:!1,profile:void 0,suggestedName:""}}E(Gp,"createBaseCompleteGoogleSignInResult");var Ea={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),e.profile!==void 0&&kr.encode(e.profile,r.uint32(18).fork()).join(),e.suggestedName!==""&&r.uint32(26).string(e.suggestedName),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Gp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==18)break;i.profile=kr.decode(t,t.uint32());continue}case 3:{if(n!==26)break;i.suggestedName=t.string();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1,profile:M(e.profile)?kr.fromJSON(e.profile):void 0,suggestedName:M(e.suggestedName)?globalThis.String(e.suggestedName):M(e.suggested_name)?globalThis.String(e.suggested_name):""}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.profile!==void 0&&(r.profile=kr.toJSON(e.profile)),e.suggestedName!==""&&(r.suggestedName=e.suggestedName),r},create(e){return Ea.fromPartial(e??{})},fromPartial(e){let r=Gp();return r.success=e.success??!1,r.profile=e.profile!==void 0&&e.profile!==null?kr.fromPartial(e.profile):void 0,r.suggestedName=e.suggestedName??"",r}};function Up(){return{success:!1}}E(Up,"createBaseManageBlockResult");var la={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Up();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return la.fromPartial(e??{})},fromPartial(e){let r=Up();return r.success=e.success??!1,r}};function Bp(){return{success:!1}}E(Bp,"createBaseEquipCosmeticResult");var ca={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Bp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return ca.fromPartial(e??{})},fromPartial(e){let r=Bp();return r.success=e.success??!1,r}};function kp(){return{success:!1}}E(kp,"createBaseUpdateDisplayOptionsResult");var fa={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=kp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return fa.fromPartial(e??{})},fromPartial(e){let r=kp();return r.success=e.success??!1,r}};function bp(){return{success:!1}}E(bp,"createBaseMarkNotificationReadResult");var Ta={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=bp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return Ta.fromPartial(e??{})},fromPartial(e){let r=bp();return r.success=e.success??!1,r}};function vp(){return{success:!1}}E(vp,"createBaseDismissNotificationResult");var Na={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=vp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return Na.fromPartial(e??{})},fromPartial(e){let r=vp();return r.success=e.success??!1,r}};function Yp(){return{success:!1,count:0}}E(Yp,"createBaseMarkAllNotificationsReadResult");var Ra={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Yp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1,count:M(e.count)?globalThis.Number(e.count):0}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.count!==0&&(r.count=Math.round(e.count)),r},create(e){return Ra.fromPartial(e??{})},fromPartial(e){let r=Yp();return r.success=e.success??!1,r.count=e.count??0,r}};function Fp(){return{uid:"",displayName:"",gamesPlayed:0,gamesWon:0,preferredColor:void 0,pinnedAchievements:[],agentKind:0}}E(Fp,"createBasePublicProfile");var gs={encode(e,r=new Oe){e.uid!==""&&r.uint32(10).string(e.uid),e.displayName!==""&&r.uint32(18).string(e.displayName),e.gamesPlayed!==0&&r.uint32(24).int32(e.gamesPlayed),e.gamesWon!==0&&r.uint32(32).int32(e.gamesWon),e.preferredColor!==void 0&&r.uint32(40).int32(e.preferredColor);for(let t of e.pinnedAchievements)r.uint32(50).string(t);return e.agentKind!==0&&r.uint32(56).int32(e.agentKind),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Fp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.uid=t.string();continue}case 2:{if(n!==18)break;i.displayName=t.string();continue}case 3:{if(n!==24)break;i.gamesPlayed=t.int32();continue}case 4:{if(n!==32)break;i.gamesWon=t.int32();continue}case 5:{if(n!==40)break;i.preferredColor=t.int32();continue}case 6:{if(n!==50)break;i.pinnedAchievements.push(t.string());continue}case 7:{if(n!==56)break;i.agentKind=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{uid:M(e.uid)?globalThis.String(e.uid):"",displayName:M(e.displayName)?globalThis.String(e.displayName):M(e.display_name)?globalThis.String(e.display_name):"",gamesPlayed:M(e.gamesPlayed)?globalThis.Number(e.gamesPlayed):M(e.games_played)?globalThis.Number(e.games_played):0,gamesWon:M(e.gamesWon)?globalThis.Number(e.gamesWon):M(e.games_won)?globalThis.Number(e.games_won):0,preferredColor:M(e.preferredColor)?globalThis.Number(e.preferredColor):M(e.preferred_color)?globalThis.Number(e.preferred_color):void 0,pinnedAchievements:globalThis.Array.isArray(e?.pinnedAchievements)?e.pinnedAchievements.map(r=>globalThis.String(r)):globalThis.Array.isArray(e?.pinned_achievements)?e.pinned_achievements.map(r=>globalThis.String(r)):[],agentKind:M(e.agentKind)?Kr(e.agentKind):M(e.agent_kind)?Kr(e.agent_kind):0}},toJSON(e){let r={};return e.uid!==""&&(r.uid=e.uid),e.displayName!==""&&(r.displayName=e.displayName),e.gamesPlayed!==0&&(r.gamesPlayed=Math.round(e.gamesPlayed)),e.gamesWon!==0&&(r.gamesWon=Math.round(e.gamesWon)),e.preferredColor!==void 0&&(r.preferredColor=Math.round(e.preferredColor)),e.pinnedAchievements?.length&&(r.pinnedAchievements=e.pinnedAchievements),e.agentKind!==0&&(r.agentKind=Ut(e.agentKind)),r},create(e){return gs.fromPartial(e??{})},fromPartial(e){let r=Fp();return r.uid=e.uid??"",r.displayName=e.displayName??"",r.gamesPlayed=e.gamesPlayed??0,r.gamesWon=e.gamesWon??0,r.preferredColor=e.preferredColor??void 0,r.pinnedAchievements=e.pinnedAchievements?.map(t=>t)||[],r.agentKind=e.agentKind??0,r}};function Vp(){return{profile:void 0}}E(Vp,"createBaseGetProfileByUsernameResult");var Aa={encode(e,r=new Oe){return e.profile!==void 0&&gs.encode(e.profile,r.uint32(10).fork()).join(),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Vp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==10)break;i.profile=gs.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{profile:M(e.profile)?gs.fromJSON(e.profile):void 0}},toJSON(e){let r={};return e.profile!==void 0&&(r.profile=gs.toJSON(e.profile)),r},create(e){return Aa.fromPartial(e??{})},fromPartial(e){let r=Vp();return r.profile=e.profile!==void 0&&e.profile!==null?gs.fromPartial(e.profile):void 0,r}};function xp(){return{success:!1}}E(xp,"createBaseUpdatePinnedAchievementsResult");var Sa={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=xp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return Sa.fromPartial(e??{})},fromPartial(e){let r=xp();return r.success=e.success??!1,r}};function wp(){return{success:!1}}E(wp,"createBaseSaveUiLayoutSizeResult");var Oa={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=wp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),r},create(e){return Oa.fromPartial(e??{})},fromPartial(e){let r=wp();return r.success=e.success??!1,r}};function Hp(){return{reacted:!1,count:0}}E(Hp,"createBaseToggleExpansionReactionResult");var Ia={encode(e,r=new Oe){return e.reacted!==!1&&r.uint32(8).bool(e.reacted),e.count!==0&&r.uint32(16).int32(e.count),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Hp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.reacted=t.bool();continue}case 2:{if(n!==16)break;i.count=t.int32();continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{reacted:M(e.reacted)?globalThis.Boolean(e.reacted):!1,count:M(e.count)?globalThis.Number(e.count):0}},toJSON(e){let r={};return e.reacted!==!1&&(r.reacted=e.reacted),e.count!==0&&(r.count=Math.round(e.count)),r},create(e){return Ia.fromPartial(e??{})},fromPartial(e){let r=Hp();return r.reacted=e.reacted??!1,r.count=e.count??0,r}};function Kp(){return{success:!1,error:"",createOrUpdateProfileResult:void 0,deleteProfileResult:void 0,getRecentGamesResult:void 0,manageFriendResult:void 0,acceptFriendRequestResult:void 0,declineFriendRequestResult:void 0,removeFriendResult:void 0,manageIgnoreResult:void 0,ensureUserDocResult:void 0,completeGoogleSignInResult:void 0,manageBlockResult:void 0,equipCosmeticResult:void 0,updateDisplayOptionsResult:void 0,markNotificationReadResult:void 0,dismissNotificationResult:void 0,markAllNotificationsReadResult:void 0,getProfileByUsernameResult:void 0,updatePinnedAchievementsResult:void 0,toggleExpansionReactionResult:void 0,saveUiLayoutSizeResult:void 0}}E(Kp,"createBaseUserActionResponse");var Yc={encode(e,r=new Oe){return e.success!==!1&&r.uint32(8).bool(e.success),e.error!==""&&r.uint32(18).string(e.error),e.createOrUpdateProfileResult!==void 0&&ta.encode(e.createOrUpdateProfileResult,r.uint32(26).fork()).join(),e.deleteProfileResult!==void 0&&na.encode(e.deleteProfileResult,r.uint32(34).fork()).join(),e.getRecentGamesResult!==void 0&&ia.encode(e.getRecentGamesResult,r.uint32(42).fork()).join(),e.manageFriendResult!==void 0&&oa.encode(e.manageFriendResult,r.uint32(50).fork()).join(),e.acceptFriendRequestResult!==void 0&&aa.encode(e.acceptFriendRequestResult,r.uint32(58).fork()).join(),e.declineFriendRequestResult!==void 0&&sa.encode(e.declineFriendRequestResult,r.uint32(66).fork()).join(),e.removeFriendResult!==void 0&&_a.encode(e.removeFriendResult,r.uint32(74).fork()).join(),e.manageIgnoreResult!==void 0&&da.encode(e.manageIgnoreResult,r.uint32(82).fork()).join(),e.ensureUserDocResult!==void 0&&ua.encode(e.ensureUserDocResult,r.uint32(90).fork()).join(),e.completeGoogleSignInResult!==void 0&&Ea.encode(e.completeGoogleSignInResult,r.uint32(98).fork()).join(),e.manageBlockResult!==void 0&&la.encode(e.manageBlockResult,r.uint32(106).fork()).join(),e.equipCosmeticResult!==void 0&&ca.encode(e.equipCosmeticResult,r.uint32(114).fork()).join(),e.updateDisplayOptionsResult!==void 0&&fa.encode(e.updateDisplayOptionsResult,r.uint32(122).fork()).join(),e.markNotificationReadResult!==void 0&&Ta.encode(e.markNotificationReadResult,r.uint32(130).fork()).join(),e.dismissNotificationResult!==void 0&&Na.encode(e.dismissNotificationResult,r.uint32(138).fork()).join(),e.markAllNotificationsReadResult!==void 0&&Ra.encode(e.markAllNotificationsReadResult,r.uint32(146).fork()).join(),e.getProfileByUsernameResult!==void 0&&Aa.encode(e.getProfileByUsernameResult,r.uint32(154).fork()).join(),e.updatePinnedAchievementsResult!==void 0&&Sa.encode(e.updatePinnedAchievementsResult,r.uint32(162).fork()).join(),e.toggleExpansionReactionResult!==void 0&&Ia.encode(e.toggleExpansionReactionResult,r.uint32(170).fork()).join(),e.saveUiLayoutSizeResult!==void 0&&Oa.encode(e.saveUiLayoutSizeResult,r.uint32(178).fork()).join(),r},decode(e,r){let t=e instanceof W?e:new W(e),o=r===void 0?t.len:t.pos+r,i=Kp();for(;t.pos<o;){let n=t.uint32();switch(n>>>3){case 1:{if(n!==8)break;i.success=t.bool();continue}case 2:{if(n!==18)break;i.error=t.string();continue}case 3:{if(n!==26)break;i.createOrUpdateProfileResult=ta.decode(t,t.uint32());continue}case 4:{if(n!==34)break;i.deleteProfileResult=na.decode(t,t.uint32());continue}case 5:{if(n!==42)break;i.getRecentGamesResult=ia.decode(t,t.uint32());continue}case 6:{if(n!==50)break;i.manageFriendResult=oa.decode(t,t.uint32());continue}case 7:{if(n!==58)break;i.acceptFriendRequestResult=aa.decode(t,t.uint32());continue}case 8:{if(n!==66)break;i.declineFriendRequestResult=sa.decode(t,t.uint32());continue}case 9:{if(n!==74)break;i.removeFriendResult=_a.decode(t,t.uint32());continue}case 10:{if(n!==82)break;i.manageIgnoreResult=da.decode(t,t.uint32());continue}case 11:{if(n!==90)break;i.ensureUserDocResult=ua.decode(t,t.uint32());continue}case 12:{if(n!==98)break;i.completeGoogleSignInResult=Ea.decode(t,t.uint32());continue}case 13:{if(n!==106)break;i.manageBlockResult=la.decode(t,t.uint32());continue}case 14:{if(n!==114)break;i.equipCosmeticResult=ca.decode(t,t.uint32());continue}case 15:{if(n!==122)break;i.updateDisplayOptionsResult=fa.decode(t,t.uint32());continue}case 16:{if(n!==130)break;i.markNotificationReadResult=Ta.decode(t,t.uint32());continue}case 17:{if(n!==138)break;i.dismissNotificationResult=Na.decode(t,t.uint32());continue}case 18:{if(n!==146)break;i.markAllNotificationsReadResult=Ra.decode(t,t.uint32());continue}case 19:{if(n!==154)break;i.getProfileByUsernameResult=Aa.decode(t,t.uint32());continue}case 20:{if(n!==162)break;i.updatePinnedAchievementsResult=Sa.decode(t,t.uint32());continue}case 21:{if(n!==170)break;i.toggleExpansionReactionResult=Ia.decode(t,t.uint32());continue}case 22:{if(n!==178)break;i.saveUiLayoutSizeResult=Oa.decode(t,t.uint32());continue}}if((n&7)===4||n===0)break;t.skip(n&7)}return i},fromJSON(e){return{success:M(e.success)?globalThis.Boolean(e.success):!1,error:M(e.error)?globalThis.String(e.error):"",createOrUpdateProfileResult:M(e.createOrUpdateProfileResult)?ta.fromJSON(e.createOrUpdateProfileResult):M(e.create_or_update_profile_result)?ta.fromJSON(e.create_or_update_profile_result):void 0,deleteProfileResult:M(e.deleteProfileResult)?na.fromJSON(e.deleteProfileResult):M(e.delete_profile_result)?na.fromJSON(e.delete_profile_result):void 0,getRecentGamesResult:M(e.getRecentGamesResult)?ia.fromJSON(e.getRecentGamesResult):M(e.get_recent_games_result)?ia.fromJSON(e.get_recent_games_result):void 0,manageFriendResult:M(e.manageFriendResult)?oa.fromJSON(e.manageFriendResult):M(e.manage_friend_result)?oa.fromJSON(e.manage_friend_result):void 0,acceptFriendRequestResult:M(e.acceptFriendRequestResult)?aa.fromJSON(e.acceptFriendRequestResult):M(e.accept_friend_request_result)?aa.fromJSON(e.accept_friend_request_result):void 0,declineFriendRequestResult:M(e.declineFriendRequestResult)?sa.fromJSON(e.declineFriendRequestResult):M(e.decline_friend_request_result)?sa.fromJSON(e.decline_friend_request_result):void 0,removeFriendResult:M(e.removeFriendResult)?_a.fromJSON(e.removeFriendResult):M(e.remove_friend_result)?_a.fromJSON(e.remove_friend_result):void 0,manageIgnoreResult:M(e.manageIgnoreResult)?da.fromJSON(e.manageIgnoreResult):M(e.manage_ignore_result)?da.fromJSON(e.manage_ignore_result):void 0,ensureUserDocResult:M(e.ensureUserDocResult)?ua.fromJSON(e.ensureUserDocResult):M(e.ensure_user_doc_result)?ua.fromJSON(e.ensure_user_doc_result):void 0,completeGoogleSignInResult:M(e.completeGoogleSignInResult)?Ea.fromJSON(e.completeGoogleSignInResult):M(e.complete_google_sign_in_result)?Ea.fromJSON(e.complete_google_sign_in_result):void 0,manageBlockResult:M(e.manageBlockResult)?la.fromJSON(e.manageBlockResult):M(e.manage_block_result)?la.fromJSON(e.manage_block_result):void 0,equipCosmeticResult:M(e.equipCosmeticResult)?ca.fromJSON(e.equipCosmeticResult):M(e.equip_cosmetic_result)?ca.fromJSON(e.equip_cosmetic_result):void 0,updateDisplayOptionsResult:M(e.updateDisplayOptionsResult)?fa.fromJSON(e.updateDisplayOptionsResult):M(e.update_display_options_result)?fa.fromJSON(e.update_display_options_result):void 0,markNotificationReadResult:M(e.markNotificationReadResult)?Ta.fromJSON(e.markNotificationReadResult):M(e.mark_notification_read_result)?Ta.fromJSON(e.mark_notification_read_result):void 0,dismissNotificationResult:M(e.dismissNotificationResult)?Na.fromJSON(e.dismissNotificationResult):M(e.dismiss_notification_result)?Na.fromJSON(e.dismiss_notification_result):void 0,markAllNotificationsReadResult:M(e.markAllNotificationsReadResult)?Ra.fromJSON(e.markAllNotificationsReadResult):M(e.mark_all_notifications_read_result)?Ra.fromJSON(e.mark_all_notifications_read_result):void 0,getProfileByUsernameResult:M(e.getProfileByUsernameResult)?Aa.fromJSON(e.getProfileByUsernameResult):M(e.get_profile_by_username_result)?Aa.fromJSON(e.get_profile_by_username_result):void 0,updatePinnedAchievementsResult:M(e.updatePinnedAchievementsResult)?Sa.fromJSON(e.updatePinnedAchievementsResult):M(e.update_pinned_achievements_result)?Sa.fromJSON(e.update_pinned_achievements_result):void 0,toggleExpansionReactionResult:M(e.toggleExpansionReactionResult)?Ia.fromJSON(e.toggleExpansionReactionResult):M(e.toggle_expansion_reaction_result)?Ia.fromJSON(e.toggle_expansion_reaction_result):void 0,saveUiLayoutSizeResult:M(e.saveUiLayoutSizeResult)?Oa.fromJSON(e.saveUiLayoutSizeResult):M(e.save_ui_layout_size_result)?Oa.fromJSON(e.save_ui_layout_size_result):void 0}},toJSON(e){let r={};return e.success!==!1&&(r.success=e.success),e.error!==""&&(r.error=e.error),e.createOrUpdateProfileResult!==void 0&&(r.createOrUpdateProfileResult=ta.toJSON(e.createOrUpdateProfileResult)),e.deleteProfileResult!==void 0&&(r.deleteProfileResult=na.toJSON(e.deleteProfileResult)),e.getRecentGamesResult!==void 0&&(r.getRecentGamesResult=ia.toJSON(e.getRecentGamesResult)),e.manageFriendResult!==void 0&&(r.manageFriendResult=oa.toJSON(e.manageFriendResult)),e.acceptFriendRequestResult!==void 0&&(r.acceptFriendRequestResult=aa.toJSON(e.acceptFriendRequestResult)),e.declineFriendRequestResult!==void 0&&(r.declineFriendRequestResult=sa.toJSON(e.declineFriendRequestResult)),e.removeFriendResult!==void 0&&(r.removeFriendResult=_a.toJSON(e.removeFriendResult)),e.manageIgnoreResult!==void 0&&(r.manageIgnoreResult=da.toJSON(e.manageIgnoreResult)),e.ensureUserDocResult!==void 0&&(r.ensureUserDocResult=ua.toJSON(e.ensureUserDocResult)),e.completeGoogleSignInResult!==void 0&&(r.completeGoogleSignInResult=Ea.toJSON(e.completeGoogleSignInResult)),e.manageBlockResult!==void 0&&(r.manageBlockResult=la.toJSON(e.manageBlockResult)),e.equipCosmeticResult!==void 0&&(r.equipCosmeticResult=ca.toJSON(e.equipCosmeticResult)),e.updateDisplayOptionsResult!==void 0&&(r.updateDisplayOptionsResult=fa.toJSON(e.updateDisplayOptionsResult)),e.markNotificationReadResult!==void 0&&(r.markNotificationReadResult=Ta.toJSON(e.markNotificationReadResult)),e.dismissNotificationResult!==void 0&&(r.dismissNotificationResult=Na.toJSON(e.dismissNotificationResult)),e.markAllNotificationsReadResult!==void 0&&(r.markAllNotificationsReadResult=Ra.toJSON(e.markAllNotificationsReadResult)),e.getProfileByUsernameResult!==void 0&&(r.getProfileByUsernameResult=Aa.toJSON(e.getProfileByUsernameResult)),e.updatePinnedAchievementsResult!==void 0&&(r.updatePinnedAchievementsResult=Sa.toJSON(e.updatePinnedAchievementsResult)),e.toggleExpansionReactionResult!==void 0&&(r.toggleExpansionReactionResult=Ia.toJSON(e.toggleExpansionReactionResult)),e.saveUiLayoutSizeResult!==void 0&&(r.saveUiLayoutSizeResult=Oa.toJSON(e.saveUiLayoutSizeResult)),r},create(e){return Yc.fromPartial(e??{})},fromPartial(e){let r=Kp();return r.success=e.success??!1,r.error=e.error??"",r.createOrUpdateProfileResult=e.createOrUpdateProfileResult!==void 0&&e.createOrUpdateProfileResult!==null?ta.fromPartial(e.createOrUpdateProfileResult):void 0,r.deleteProfileResult=e.deleteProfileResult!==void 0&&e.deleteProfileResult!==null?na.fromPartial(e.deleteProfileResult):void 0,r.getRecentGamesResult=e.getRecentGamesResult!==void 0&&e.getRecentGamesResult!==null?ia.fromPartial(e.getRecentGamesResult):void 0,r.manageFriendResult=e.manageFriendResult!==void 0&&e.manageFriendResult!==null?oa.fromPartial(e.manageFriendResult):void 0,r.acceptFriendRequestResult=e.acceptFriendRequestResult!==void 0&&e.acceptFriendRequestResult!==null?aa.fromPartial(e.acceptFriendRequestResult):void 0,r.declineFriendRequestResult=e.declineFriendRequestResult!==void 0&&e.declineFriendRequestResult!==null?sa.fromPartial(e.declineFriendRequestResult):void 0,r.removeFriendResult=e.removeFriendResult!==void 0&&e.removeFriendResult!==null?_a.fromPartial(e.removeFriendResult):void 0,r.manageIgnoreResult=e.manageIgnoreResult!==void 0&&e.manageIgnoreResult!==null?da.fromPartial(e.manageIgnoreResult):void 0,r.ensureUserDocResult=e.ensureUserDocResult!==void 0&&e.ensureUserDocResult!==null?ua.fromPartial(e.ensureUserDocResult):void 0,r.completeGoogleSignInResult=e.completeGoogleSignInResult!==void 0&&e.completeGoogleSignInResult!==null?Ea.fromPartial(e.completeGoogleSignInResult):void 0,r.manageBlockResult=e.manageBlockResult!==void 0&&e.manageBlockResult!==null?la.fromPartial(e.manageBlockResult):void 0,r.equipCosmeticResult=e.equipCosmeticResult!==void 0&&e.equipCosmeticResult!==null?ca.fromPartial(e.equipCosmeticResult):void 0,r.updateDisplayOptionsResult=e.updateDisplayOptionsResult!==void 0&&e.updateDisplayOptionsResult!==null?fa.fromPartial(e.updateDisplayOptionsResult):void 0,r.markNotificationReadResult=e.markNotificationReadResult!==void 0&&e.markNotificationReadResult!==null?Ta.fromPartial(e.markNotificationReadResult):void 0,r.dismissNotificationResult=e.dismissNotificationResult!==void 0&&e.dismissNotificationResult!==null?Na.fromPartial(e.dismissNotificationResult):void 0,r.markAllNotificationsReadResult=e.markAllNotificationsReadResult!==void 0&&e.markAllNotificationsReadResult!==null?Ra.fromPartial(e.markAllNotificationsReadResult):void 0,r.getProfileByUsernameResult=e.getProfileByUsernameResult!==void 0&&e.getProfileByUsernameResult!==null?Aa.fromPartial(e.getProfileByUsernameResult):void 0,r.updatePinnedAchievementsResult=e.updatePinnedAchievementsResult!==void 0&&e.updatePinnedAchievementsResult!==null?Sa.fromPartial(e.updatePinnedAchievementsResult):void 0,r.toggleExpansionReactionResult=e.toggleExpansionReactionResult!==void 0&&e.toggleExpansionReactionResult!==null?Ia.fromPartial(e.toggleExpansionReactionResult):void 0,r.saveUiLayoutSizeResult=e.saveUiLayoutSizeResult!==void 0&&e.saveUiLayoutSizeResult!==null?Oa.fromPartial(e.saveUiLayoutSizeResult):void 0,r}};function mu(e){let r=Math.trunc(e.getTime()/1e3),t=e.getTime()%1e3*1e6;return{seconds:r,nanos:t}}E(mu,"toTimestamp");function z_(e){let r=(e.seconds||0)*1e3;return r+=(e.nanos||0)/1e6,new globalThis.Date(r)}E(z_,"fromTimestamp");function zn(e){return e instanceof globalThis.Date?e:typeof e=="string"?new globalThis.Date(e):z_(Le.fromJSON(e))}E(zn,"fromJsonTimestamp");function py(e){let r=globalThis.Number(e.toString());if(r>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(r<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return r}E(py,"longToNumber");function M(e){return e!=null}E(M,"isSet");import{BinaryReader as o$,BinaryWriter as a$}from"@bufbuild/protobuf/wire";var Wp;(function(e){e[e.MAP_SORT_BY_UNSPECIFIED=0]="MAP_SORT_BY_UNSPECIFIED",e[e.MAP_SORT_BY_CREATED_AT=1]="MAP_SORT_BY_CREATED_AT",e[e.MAP_SORT_BY_VIEW_COUNT=2]="MAP_SORT_BY_VIEW_COUNT",e[e.MAP_SORT_BY_PLAY_COUNT=3]="MAP_SORT_BY_PLAY_COUNT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Wp||(Wp={}));var Jp;(function(e){e[e.MAP_ACTION_UNSPECIFIED=0]="MAP_ACTION_UNSPECIFIED",e[e.MAP_ACTION_VIEW=1]="MAP_ACTION_VIEW",e[e.MAP_ACTION_LIST=2]="MAP_ACTION_LIST",e[e.MAP_ACTION_TOGGLE_FAVORITE=3]="MAP_ACTION_TOGGLE_FAVORITE",e[e.MAP_ACTION_INCREMENT_PLAY_COUNT=4]="MAP_ACTION_INCREMENT_PLAY_COUNT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Jp||(Jp={}));import{BinaryReader as E$,BinaryWriter as l$}from"@bufbuild/protobuf/wire";var qp;(function(e){e[e.ADMIN_ACTION_UNSPECIFIED=0]="ADMIN_ACTION_UNSPECIFIED",e[e.ADMIN_ACTION_REVIEW_NAME_REPORT=1]="ADMIN_ACTION_REVIEW_NAME_REPORT",e[e.ADMIN_ACTION_FORCE_RENAME=2]="ADMIN_ACTION_FORCE_RENAME",e[e.ADMIN_ACTION_UNLOCK_NAME_CHANGE=3]="ADMIN_ACTION_UNLOCK_NAME_CHANGE",e[e.ADMIN_ACTION_GET_PENDING_NAME_REPORTS=4]="ADMIN_ACTION_GET_PENDING_NAME_REPORTS",e[e.ADMIN_ACTION_GET_FAILED_NAME_ATTEMPTS=5]="ADMIN_ACTION_GET_FAILED_NAME_ATTEMPTS",e[e.ADMIN_ACTION_GRANT_COSMETIC=6]="ADMIN_ACTION_GRANT_COSMETIC",e[e.ADMIN_ACTION_REVOKE_COSMETIC=7]="ADMIN_ACTION_REVOKE_COSMETIC",e[e.ADMIN_ACTION_GET_USER_COSMETICS=8]="ADMIN_ACTION_GET_USER_COSMETICS",e[e.ADMIN_ACTION_GET_ROBBER_COSMETICS=9]="ADMIN_ACTION_GET_ROBBER_COSMETICS",e[e.ADMIN_ACTION_GET_COSMETICS_BY_TYPE=10]="ADMIN_ACTION_GET_COSMETICS_BY_TYPE",e[e.ADMIN_ACTION_LIST_ALL_COSMETIC_GRANTS=11]="ADMIN_ACTION_LIST_ALL_COSMETIC_GRANTS",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(qp||(qp={}));var Zp;(function(e){e[e.ADMIN_REVIEW_ACTION_UNSPECIFIED=0]="ADMIN_REVIEW_ACTION_UNSPECIFIED",e[e.ADMIN_REVIEW_ACTION_FORCE_RENAME=1]="ADMIN_REVIEW_ACTION_FORCE_RENAME",e[e.ADMIN_REVIEW_ACTION_DISMISS=2]="ADMIN_REVIEW_ACTION_DISMISS",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Zp||(Zp={}));var Xp;(function(e){e[e.ADMIN_RENAME_SEVERITY_UNSPECIFIED=0]="ADMIN_RENAME_SEVERITY_UNSPECIFIED",e[e.ADMIN_RENAME_SEVERITY_MINOR=1]="ADMIN_RENAME_SEVERITY_MINOR",e[e.ADMIN_RENAME_SEVERITY_SEVERE=2]="ADMIN_RENAME_SEVERITY_SEVERE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Xp||(Xp={}));import{BinaryReader as R$,BinaryWriter as A$}from"@bufbuild/protobuf/wire";var zp;(function(e){e[e.CREATOR_ACTION_UNSPECIFIED=0]="CREATOR_ACTION_UNSPECIFIED",e[e.CREATOR_ACTION_START_SESSION=1]="CREATOR_ACTION_START_SESSION",e[e.CREATOR_ACTION_PARSE_MAP=2]="CREATOR_ACTION_PARSE_MAP",e[e.CREATOR_ACTION_PARSE_EVENTS=3]="CREATOR_ACTION_PARSE_EVENTS",e[e.CREATOR_ACTION_CLARIFY_TIMESTAMP=4]="CREATOR_ACTION_CLARIFY_TIMESTAMP",e[e.CREATOR_ACTION_RUN_SOLVERS=5]="CREATOR_ACTION_RUN_SOLVERS",e[e.CREATOR_ACTION_RESOLVE_STEAL=6]="CREATOR_ACTION_RESOLVE_STEAL",e[e.CREATOR_ACTION_RESOLVE_DEV_CARD=7]="CREATOR_ACTION_RESOLVE_DEV_CARD",e[e.CREATOR_ACTION_SAVE_IMPORT=8]="CREATOR_ACTION_SAVE_IMPORT",e[e.CREATOR_ACTION_GET_SESSION=9]="CREATOR_ACTION_GET_SESSION",e[e.CREATOR_ACTION_SAVE_REPLAY=10]="CREATOR_ACTION_SAVE_REPLAY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(zp||(zp={}));import{BinaryReader as P$,BinaryWriter as p$}from"@bufbuild/protobuf/wire";var $p;(function(e){e[e.MODERATION_ACTION_UNSPECIFIED=0]="MODERATION_ACTION_UNSPECIFIED",e[e.MODERATION_ACTION_REPORT_CHAT=1]="MODERATION_ACTION_REPORT_CHAT",e[e.MODERATION_ACTION_REPORT_NAME=2]="MODERATION_ACTION_REPORT_NAME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})($p||($p={}));var Qp;(function(e){e[e.REPORT_CONTEXT_UNSPECIFIED=0]="REPORT_CONTEXT_UNSPECIFIED",e[e.REPORT_CONTEXT_GAME=1]="REPORT_CONTEXT_GAME",e[e.REPORT_CONTEXT_LOBBY=2]="REPORT_CONTEXT_LOBBY",e[e.REPORT_CONTEXT_SPECTATOR=3]="REPORT_CONTEXT_SPECTATOR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(Qp||(Qp={}));var jp;(function(e){e[e.MODERATION_CONFIDENCE_UNSPECIFIED=0]="MODERATION_CONFIDENCE_UNSPECIFIED",e[e.MODERATION_CONFIDENCE_HIGH=1]="MODERATION_CONFIDENCE_HIGH",e[e.MODERATION_CONFIDENCE_MEDIUM=2]="MODERATION_CONFIDENCE_MEDIUM",e[e.MODERATION_CONFIDENCE_LOW=3]="MODERATION_CONFIDENCE_LOW",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(jp||(jp={}));var eh;(function(e){e[e.NAME_REPORT_STATUS_UNSPECIFIED=0]="NAME_REPORT_STATUS_UNSPECIFIED",e[e.NAME_REPORT_STATUS_PENDING=1]="NAME_REPORT_STATUS_PENDING",e[e.NAME_REPORT_STATUS_APPROVED=2]="NAME_REPORT_STATUS_APPROVED",e[e.NAME_REPORT_STATUS_REJECTED=3]="NAME_REPORT_STATUS_REJECTED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(eh||(eh={}));var rh;(function(e){e[e.CHAT_REPORT_STATUS_UNSPECIFIED=0]="CHAT_REPORT_STATUS_UNSPECIFIED",e[e.CHAT_REPORT_STATUS_PENDING=1]="CHAT_REPORT_STATUS_PENDING",e[e.CHAT_REPORT_STATUS_PROCESSED=2]="CHAT_REPORT_STATUS_PROCESSED",e[e.CHAT_REPORT_STATUS_DISMISSED=3]="CHAT_REPORT_STATUS_DISMISSED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(rh||(rh={}));import{BinaryReader as g$,BinaryWriter as y$}from"@bufbuild/protobuf/wire";var th;(function(e){e[e.NAME_RECHECK_CAUSE_UNSPECIFIED=0]="NAME_RECHECK_CAUSE_UNSPECIFIED",e[e.NAME_RECHECK_CAUSE_TIMEOUT=1]="NAME_RECHECK_CAUSE_TIMEOUT",e[e.NAME_RECHECK_CAUSE_ERROR=2]="NAME_RECHECK_CAUSE_ERROR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(th||(th={}));var nh;(function(e){e[e.NAME_RECHECK_STATUS_UNSPECIFIED=0]="NAME_RECHECK_STATUS_UNSPECIFIED",e[e.NAME_RECHECK_STATUS_PENDING=1]="NAME_RECHECK_STATUS_PENDING",e[e.NAME_RECHECK_STATUS_CHECKING=2]="NAME_RECHECK_STATUS_CHECKING",e[e.NAME_RECHECK_STATUS_ALLOWED=3]="NAME_RECHECK_STATUS_ALLOWED",e[e.NAME_RECHECK_STATUS_REPORTED=4]="NAME_RECHECK_STATUS_REPORTED",e[e.NAME_RECHECK_STATUS_UNCHECKED=5]="NAME_RECHECK_STATUS_UNCHECKED",e[e.NAME_RECHECK_STATUS_SKIPPED=6]="NAME_RECHECK_STATUS_SKIPPED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"})(nh||(nh={}));function ih(e){if(typeof Buffer<"u")return Buffer.from(e).toString("base64");let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return btoa(r)}E(ih,"bytesToBase64");function oh(e){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(e,"base64"));let r=atob(e),t=new Uint8Array(r.length);for(let o=0;o<r.length;o++)t[o]=r.charCodeAt(o);return t}E(oh,"base64ToBytes");function ys(e,r,t){return async o=>{let i=r.encode(o).finish(),n=ih(i),a=await e({data:n}),s=oh(a.data.data);return t.decode(s)}}E(ys,"createProtoRpc");var Fc;(function(e){e.Users="users",e.Games="games",e.Lobbies="lobbies",e.Maps="maps",e.Friends="friends",e.FriendRequests="friend-requests",e.Ignores="ignores",e.Blocks="blocks",e.BlockedBy="blocked-by",e.LobbyInvites="lobby-invites",e.LobbyList="lobby-list",e.LiveGames="live-games",e.ActiveGameParticipants="active-game-participants",e.Ladders="ladders",e.MatchmakingQueues="matchmaking-queues",e.MatchmakingQueue="matchmaking-queue",e.LadderSeasons="ladder-seasons",e.ArchivedLeaderboards="archived_leaderboards",e.ReadyChecks="ready-checks",e.PlayerRatings="player-ratings",e.PlayerLadderMembership="player-ladder-membership",e.Arenas="arenas",e.ArenaParticipants="arena-participants",e.Challenges="challenges",e.DailyChallenges="daily-challenges",e.ChallengeQueue="challenge-queue",e.ChallengeSuggestions="challenge-suggestions",e.ChallengeAttempts="challenge-attempts",e.CreatorSessions="creator-sessions",e.ImportedReplays="imported-replays",e.NameReports="name-reports",e.ChatReports="chat-reports",e.FailedNameAttempts="failed-name-attempts",e.NameRechecks="name-rechecks",e.AdminAuditLogs="admin-audit-logs",e.CosmeticGrants="cosmetic-grants",e.Notifications="notifications",e.Pings="pings",e.Versions="versions",e.RateLimits="rate-limits",e.RatingFailures="rating-failures",e.GameFeedback="game-feedback",e.BugReports="bug-reports",e.PredictionStats="prediction-stats",e.PredictionLeaderboards="prediction-leaderboards",e.PredictionHistory="prediction-history",e.ReferralStats="referral-stats",e.GameCounts="game-counts",e.ActiveUsers="active-users",e.SiteStats="site-stats",e.MapFavorites="map-favorites",e.ExpansionReactionCounts="expansion-reaction-counts",e.JaxStats="jax-stats",e.BotLadders="bot-ladders"})(Fc||(Fc={}));var Vc;(function(e){e.Private="private",e.PlayerStats="player-stats",e.CategoryStats="category-stats",e.ChallengeStats="challenge-stats",e.Achievements="achievements",e.ChatTimeout="chat-timeout",e.ModerationHistory="moderation-history",e.CosmeticGrants="cosmetic-grants",e.Notifications="notifications",e.MapViews="map-views",e.JaxStats="jax-stats",e.ExpansionReactions="expansion-reactions",e.BotLadderPending="bot-ladder-pending"})(Vc||(Vc={}));var xc;(function(e){e.PlayerChat="player-chat",e.SpectatorChat="spectator-chat",e.Pings="pings"})(xc||(xc={}));var wc;(function(e){e.Messages="messages"})(wc||(wc={}));var Hc;(function(e){e.Friendships="friendships",e.Incoming="incoming",e.Outgoing="outgoing",e.Ignored="ignored",e.Blocked="blocked",e.Blockers="blockers"})(Hc||(Hc={}));var Kc;(function(e){e.Invites="invites"})(Kc||(Kc={}));var Wc;(function(e){e.Favorites="favorites",e.FavoriteMaps="favorite-maps"})(Wc||(Wc={}));var Jc;(function(e){e.Seasons="seasons",e.Players="players"})(Jc||(Jc={}));var qc;(function(e){e.Ratings="ratings"})(qc||(qc={}));var Zc;(function(e){e.Ladders="ladders",e.LadderSeasons="ladder-seasons"})(Zc||(Zc={}));var Xc;(function(e){e.Entries="entries",e.Participants="participants"})(Xc||(Xc={}));var zc;(function(e){e.Entries="entries"})(zc||(zc={}));var $c;(function(e){e.Attempts="attempts"})($c||($c={}));var Qc;(function(e){e.Data="data",e.Info="info",e.Current="current",e.Levels="levels",e.All="all",e.OneVOne="one-v-one",e.FourPlayer="four-player",e.Other="other",e.Arena="arena",e.Creator="creator",e.Challenge="challenge"})(Qc||(Qc={}));var Yy=[0,B.MAP_TYPE_BASE_4P,B.MAP_TYPE_BASE_RANDOM_4P];function Fy(e){let r=e.config;if(r){if(r.numPlayers!==2)return`it is a ${r.numPlayers}-player game, and AI agents play 1v1 only`;if(r.expansions?.length)return`it uses expansions (${r.expansions.join(", ")})`;if(r.rushMode)return"it is a rush mode game";if(r.turboMode)return"it uses turbo mode (two rolls a turn)";if(r.eventCards)return"it uses event cards instead of dice";if(r.secondSettler)return"it uses the second settler rule";if(r.allowPlayerTrades)return"it allows trades between players, and AI agents trade with the bank only";if(r.lazyRobber)return"it uses the lazy robber";if(r.speedRobber)return"it uses the speed robber";if(r.firstSettleMode||r.secondSettleMode||r.firstFound||r.secondFound)return"it changes how the starting pieces are placed";if(e.mapId)return"it is played on a custom map";if(!Yy.includes(r.mapType??0))return"it is played on a special map"}}E(Fy,"unsupportedLobby");var yu=class{constructor(r,t){this.backend=r;this.options=t}backend;options;static{E(this,"TwoSheepAgent")}user;lobby;session;lastLegal;seenSeq=-1;pendingGameId;queue=Promise.resolve();serial(r){let t=this.queue.then(r,r);return this.queue=t.catch(()=>{}),t}async whoami(){return this.user||(this.user=await this.backend.signIn()),this.user}joinLobby(r,t){return this.serial(async()=>{let o=await this.whoami();return r=r.trim().toUpperCase(),await this.leaveGame(),await this.backend.api.joinLobby(r,o.displayName),this.watch(r),this.waitForGame(t)})}createLobby(r,t){return this.serial(async()=>{let o=await this.whoami();await this.leaveGame();let i=await this.backend.api.createLobby(o.displayName,r);return this.watch(i),{code:i,...await this.waitForGame(t)}})}async waitForTurn(r){let t=Date.now()+r;if(!this.session)if(this.pendingGameId)await this.openGame(this.pendingGameId);else{if(this.lobby)return this.waitForGame(r);await this.resumeLastGame()}let o=await this.requireSession().waitForTurn(Math.max(0,t-Date.now()));return this.report(o)}state(){return this.requireSession().state()}legalActions(){let r=this.requireSession(),t=r.legalActions();return this.lastLegal={version:r.version,actions:t},t.map((o,i)=>({id:i,action:o}))}act(r){return this.serial(()=>this.actNow(r))}async actNow(r){let t=this.requireSession(),o=r.action;if(r.id!==void 0){if(!this.lastLegal||this.lastLegal.version!==t.version)throw new we("The game has moved on since those legal actions were listed; list them again (ids are only good for one position)");if(o=this.lastLegal.actions[r.id],o===void 0)throw new we(`No legal action ${r.id}; ids run from 0 to ${this.lastLegal.actions.length-1}`)}if(o===void 0)throw new we("Give an action id from legalActions, or an OpenHex action object");return{played:(await t.act(o)).action,...this.report(this.whoseMove(t))}}events(r){return this.requireSession().events(r)}resign(){return this.serial(()=>this.resignNow())}async resignNow(){let r=this.requireSession();if(r.viewer.kind!=="player")throw new we("You are watching this game, not playing in it");let t=await this.backend.transport.executeAction(r.gameId,cr.resign(r.viewer.color));if(!t.success)throw new we(`The server refused to resign: ${t.error??"no reason given"}`);return await r.waitForTurn(5e3),this.report(this.whoseMove(r))}close(){return this.leaveGame()}requireSession(){if(!this.session)throw new we("Not in a game yet: join_lobby or create_lobby first");return this.session}whoseMove(r){return r.isOver?"game_over":r.legalActions().length>0?"your_turn":"opponent_to_move"}report(r){let t=this.requireSession(),o=t.events(this.seenSeq);this.seenSeq=t.log.lastSeq;let i={status:r,gameId:t.gameId,you:t.color,newEvents:o};r!=="timeout"&&(i.state=t.state(),r==="your_turn"&&(i.legalActions=this.legalActions(),i.actWithinSeconds=Math.round(AN(t.local.game.options.timerConfig)/1e3)));let n=this.notes(t);return n.length>0&&(i.notes=n),i}notes(r){let t=[];return r.isOver&&!r.state().winner&&t.push("The game ended on the server without a winner (abandoned, for example after a long time with no moves)."),r.paused&&t.push("The game is paused. Moves wait until a player resumes it; keep calling wait_for_turn."),r.local.game.options.tradeMode===$r.TRADE_MODE_NORMAL&&t.push("This lobby allows trades between players. You can only trade with the bank (tradeWithBank)."),t}watch(r){let t={code:r,doc:null,waiters:new Set,started:!1,stop:E(()=>{},"stop"),heartbeat:setInterval(()=>{this.backend.api.heartbeat(r).catch(()=>{})},this.options.heartbeatMs??6e4)};this.lobby=t,this.backend.api.heartbeat(r).catch(()=>{});let o=E(a=>{t.error??=a,this.wakeLobby()},"fail"),i=!1,n=!1;t.stop=this.backend.watchLobby(r,a=>{t.doc=a;let s=this.user?.uid??"",u=a?.status===rn.LOBBY_STATUS_OPEN;if(a?.status===rn.LOBBY_STATUS_STARTED&&(t.started=!0),a&&u){let c=Fy(a);if(c){this.backend.api.leaveLobby(r).catch(()=>{}),o(new we(`This lobby is not one an AI agent can play: ${c}. You left lobby ${r}.`));return}let f=a.players[s];if(f)n=!0;else if(n&&!a.spectators?.[s]){o(new we(`You are no longer in lobby ${r} (removed by the host, or for missing heartbeats).`));return}f&&!f.isReady&&!i&&(i=!0,this.backend.api.toggleReady(r).catch(()=>{}).finally(()=>i=!1))}let l=u&&a?.hostUid===s?a.startingAt:void 0;l!==t.startFor&&(clearTimeout(t.startTimer),t.startFor=l,t.startTimer=l?this.scheduleStart(t,l,o):void 0),this.wakeLobby()},o)}scheduleStart(r,t,o,i=0){let n=Math.max(0,t-Date.now())+250+i*1e3;return setTimeout(()=>{r.startFor!==t||this.lobby!==r||this.backend.api.startGame(r.code).catch(a=>{/not finished|countdown/i.test(a.message)&&i<5&&r.startFor===t?r.startTimer=this.scheduleStart(r,t,o,i+1):r.doc?.status===rn.LOBBY_STATUS_OPEN&&o(a)})},n)}wakeLobby(){for(let r of[...this.lobby?.waiters??[]])r()}async waitForGame(r){let t=this.lobby;if(!t)throw new we("Not in a lobby: join_lobby or create_lobby first");let o=E(()=>{let a=t.doc;return a&&a.status===rn.LOBBY_STATUS_STARTED&&a.gameId?a.gameId:void 0},"started");if(await new Promise(a=>{let s=E(()=>{(o()||t.error||t.doc?.status===rn.LOBBY_STATUS_CANCELLED)&&(l(),a())},"check"),u=setTimeout(()=>{l(),a()},r),l=E(()=>{clearTimeout(u),t.waiters.delete(s)},"done");t.waiters.add(s),s()}),t.error){let a=t.error;throw this.stopLobby(),a}if(t.doc?.status===rn.LOBBY_STATUS_CANCELLED)throw this.stopLobby(),new we(`Lobby ${t.code} was closed`);let i=o();if(!i)return{status:"waiting_for_game",newEvents:[],notes:[this.lobbyNote(t)]};this.stopLobby(),this.pendingGameId=i,this.saveLastGame(i),await this.openGame(i);let n=this.requireSession();return await n.waitForTurn(1e3),this.report(this.whoseMove(n))}lobbyNote(r){let t=r.doc;if(!t)return`Waiting for lobby ${r.code}. Call wait_for_turn to keep waiting.`;let o=Object.entries(t.players).filter(([n])=>n!==this.user?.uid).map(([,n])=>n);if(o.length===0)return`Lobby ${r.code}: waiting for an opponent to join. Call wait_for_turn to keep waiting.`;let i=o.filter(n=>!n.isReady).map(n=>n.displayName??"a player");return i.length>0?`Lobby ${r.code}: waiting for ${i.join(", ")} to get ready. Call wait_for_turn to keep waiting.`:`Lobby ${r.code}: everyone is ready; the game starts after the countdown. Call wait_for_turn.`}async openGame(r){let t=await this.whoami();this.session?.close(),this.session=void 0,this.session=await J_.open(this.backend.transport,{gameId:r,uid:t.uid,format:this.options.format}),this.pendingGameId=void 0,this.seenSeq=-1,this.lastLegal=void 0,this.saveLastGame(r)}async resumeLastGame(){let r=ch(this.options.profileDir,"state.json");if(!By(r))return;let t;try{({lastGameId:t}=JSON.parse(by(r,"utf8")))}catch{return}t&&await this.openGame(t)}saveLastGame(r){try{ky(this.options.profileDir,{recursive:!0,mode:448}),vy(ch(this.options.profileDir,"state.json"),JSON.stringify({lastGameId:r}),{mode:384})}catch{}}stopLobby(){this.lobby&&(clearInterval(this.lobby.heartbeat),clearTimeout(this.lobby.startTimer),this.lobby.stop(),this.lobby=void 0)}async leaveGame(){let r=this.lobby;this.stopLobby(),r&&!r.started&&r.doc?.status===rn.LOBBY_STATUS_OPEN&&await this.backend.api.leaveLobby(r.code).catch(()=>{}),this.session?.close(),this.session=void 0,this.pendingGameId=void 0,this.lastLegal=void 0,this.seenSeq=-1}};import{signInAnonymously as qy}from"firebase/auth";import{doc as Zy,onSnapshot as Xy}from"firebase/firestore";import{httpsCallable as Vy}from"firebase/functions";var fh={victoryPoints:15,discardLimit:9},Mu=class{static{E(this,"TwoSheepApi")}lobbyRpc;gameRpc;userRpc;executeRpc;constructor(r){let t=E(o=>{let i=Vy(r,o);return async n=>({data:(await i(n)).data})},"callable");this.lobbyRpc=ys(t("lobbyAction"),Ru,Lc),this.gameRpc=ys(t("gameAction"),Du,kc),this.userRpc=ys(t("userAction"),gu,Yc),this.executeRpc=ys(t("executeAction"),bc,vc)}async ensureUserDoc(){let r=await this.userRpc(gu.fromPartial({actionType:Te.USER_ACTION_ENSURE_USER_DOC,ensureUserDoc:{referralCode:"",agentKind:ut.AGENT_KIND_LLM}}));if(!r.success)throw new Error(r.error||"Could not create the TwoSheep account");let t=r.ensureUserDocResult?.profile;return{uid:t?.uid??"",displayName:t?.displayName??"",created:r.ensureUserDocResult?.created??!1,agentKind:t?.agentKind??ut.AGENT_KIND_NONE}}async lobby(r,t){let o=await this.lobbyRpc(Ru.fromPartial(r));if(!o.success)throw new Error(o.error||`Could not ${t}`);return o}async createLobby(r,t=fh.victoryPoints){return(await this.lobby({actionType:ce.LOBBY_ACTION_CREATE,create:{displayName:r,config:Et.fromPartial({numPlayers:2,victoryPoints:t,discardLimit:fh.discardLimit,friendlyRobber:!0,randomizePlayerOrder:!0,allowPlayerTrades:!1}),bots:[],mapId:"",useGoEngine:!1}},"create the lobby")).createResult?.lobbyId??""}async joinLobby(r,t){await this.lobby({actionType:ce.LOBBY_ACTION_JOIN,join:{lobbyId:r,displayName:t,asSpectator:!1}},`join lobby ${r}`)}async leaveLobby(r){await this.lobby({actionType:ce.LOBBY_ACTION_LEAVE,leave:{lobbyId:r}},`leave lobby ${r}`)}async heartbeat(r){await this.lobby({actionType:ce.LOBBY_ACTION_HEARTBEAT,heartbeat:{lobbyId:r}},"stay in the lobby")}async toggleReady(r){return(await this.lobby({actionType:ce.LOBBY_ACTION_TOGGLE_READY,toggleReady:{lobbyId:r}},"change ready")).toggleReadyResult?.isReady??!1}async startGame(r){return(await this.lobby({actionType:ce.LOBBY_ACTION_START_GAME,startGame:{lobbyId:r}},"start the game")).startGameResult?.gameId??""}async reportLoaded(r){let t=await this.gameRpc(Du.fromPartial({actionType:ye.GAME_ACTION_UPDATE_PLAYER_LOADING_STATUS,updatePlayerLoadingStatus:{gameId:r,status:qr.PLAYER_LOADING_STATUS_READY}}));if(!t.success)throw new Error(t.error||"Could not report the game loaded")}async executeAction(r,t){try{let o=await this.executeRpc({gameId:r,action:qd(t),warmup:!1});return{success:o.success,error:o.error||void 0,eventCount:o.eventCount}}catch(o){let i=o;if(i?.code==="functions/failed-precondition")return{success:!1,error:String(i.message),eventCount:0};throw o}}};import{doc as xy,getDoc as wy}from"firebase/firestore";import{get as Hy,onChildAdded as Ky,orderByKey as jc,query as ef,ref as Th,startAfter as Wy}from"firebase/database";var Lu=class{constructor(r,t,o){this.firestore=r;this.database=t;this.api=o}firestore;database;api;static{E(this,"FirebaseTransport")}async getGame(r){let t=await wy(xy(this.firestore,"games",r));return t.exists()?Jy(t.data()):null}async loadEvents(r){return(await Hy(ef(Th(this.database,r),jc()))).val()??null}followEvents(r,t,o,i){let n=Th(this.database,r),a=t===void 0?ef(n,jc()):ef(n,jc(),Wy(t));return Ky(a,s=>{try{s.key&&typeof s.val()=="string"&&o(s.key,s.val())}catch(u){i(u instanceof Error?u:new Error(String(u)))}},i)}executeAction(r,t){return this.api.executeAction(r,t)}reportLoaded(r){return this.api.reportLoaded(r)}};function Jy(e){let r={};for(let[t,o]of Object.entries(e.players??{}))r[t]={uid:o.uid||void 0,color:o.color,displayName:o.displayName,loading:o.loadingStatus===qr.PLAYER_LOADING_STATUS_LOADING};return{initialGameState:e.initialGameState,players:r,loading:e.status===hs.GAME_STATUS_LOADING,ended:e.status===hs.GAME_STATUS_COMPLETED||e.status===hs.GAME_STATUS_ABANDONED}}E(Jy,"gameInfo");function Nh(e){let r=new Mu(e.functions);return{api:r,transport:new Lu(e.firestore,e.database,r),async signIn(){await e.auth.authStateReady();let t=e.auth.currentUser??(await qy(e.auth)).user,o=await r.ensureUserDoc();return{uid:t.uid,displayName:o.displayName}},watchLobby(t,o,i){return Xy(Zy(e.firestore,"lobbies",t),n=>o(n.exists()?n.data():null),i)}}}E(Nh,"firebaseBackend");import{homedir as zy}from"node:os";import{join as rf}from"node:path";var $y="sheep-e3c19",Rh={apiKey:"AIzaSyC7w6TORjAfY-FimAYv1mk8qtwVvSJNqd4",authDomain:"sheep-e3c19.firebaseapp.com",projectId:"sheep-e3c19",storageBucket:"sheep-e3c19.firebasestorage.app",messagingSenderId:"13083042524",appId:"1:13083042524:web:a8732b96269c820a904a19",databaseURL:"https://sheep-e3c19-default-rtdb.firebaseio.com"},Qy={auth:9099,firestore:8180,database:9e3,functions:5001};function jy(e){let r={...Qy};for(let t of(e??"").split(",").filter(Boolean)){let[o,i]=t.split("="),n=Number(i);if(!(o in r)||!Number.isInteger(n)||n<=0)throw new Error(`--emulator-ports: "${t}" is not name=port with name auth, firestore, database or functions`);r[o]=n}return r}E(jy,"parsePorts");var Ah=["emulator-host","emulator-ports","emulator-project","emulator-db-namespace","format","profile"],eM=["emulator"];function rM(e){for(let r=0;r<e.length;r++){let t=e[r],o=t.startsWith("--")?t.slice(2).split("=")[0]:"";if(!(eM.includes(o)&&!t.includes("="))){if(Ah.includes(o)){if(!t.includes("=")){if(r+1>=e.length||e[r+1].startsWith("--"))throw new Error(`--${o} needs a value`);r++}continue}throw new Error(`Unknown argument "${t}". Options: --emulator, ${Ah.map(i=>`--${i} <value>`).join(", ")}`)}}}E(rM,"checkArgs");function Ms(e,r){let t=e.indexOf(`--${r}`);return t>=0?e[t+1]:e.find(i=>i.startsWith(`--${r}=`))?.slice(r.length+3)}E(Ms,"flag");function Sh(e,r){rM(e);let t=e.includes("--emulator")||r.TWOSHEEP_EMULATOR==="1",o=Ms(e,"emulator-host")??r.TWOSHEEP_EMULATOR_HOST??"localhost",i=jy(Ms(e,"emulator-ports")??r.TWOSHEEP_EMULATOR_PORTS),n=Ms(e,"emulator-project")??r.TWOSHEEP_EMULATOR_PROJECT??$y,a=Ms(e,"emulator-db-namespace")??r.TWOSHEEP_EMULATOR_DB_NAMESPACE??(n.startsWith("demo-")?n:`${n}-default-rtdb`),s=Ms(e,"format")??r.TWOSHEEP_FORMAT??"coordinates";if(s!=="coordinates"&&s!=="indices")throw new Error(`--format must be "coordinates" or "indices", not "${s}"`);let u=Ms(e,"profile")??r.TWOSHEEP_PROFILE??"default";if(!/^[\w-]+$/.test(u))throw new Error("--profile may use letters, digits, - and _ only");let l=r.TWOSHEEP_CONFIG_DIR??rf(r.XDG_CONFIG_HOME??rf(zy(),".config"),"twosheep"),c,f;if(t)c="emulator",f={apiKey:"fake-api-key",authDomain:`${n}.firebaseapp.com`,projectId:n,storageBucket:`${n}.appspot.com`,messagingSenderId:"000000000000",appId:"1:000000000000:web:demo",databaseURL:`http://${o}:${i.database}/?ns=${a}`};else if(r.TWOSHEEP_FIREBASE_CONFIG){try{f=JSON.parse(r.TWOSHEEP_FIREBASE_CONFIG)}catch{throw new Error("TWOSHEEP_FIREBASE_CONFIG is not JSON: it should be a Firebase web config object")}if(!f||typeof f!="object"||!f.projectId||!f.apiKey)throw new Error('TWOSHEEP_FIREBASE_CONFIG needs at least "projectId" and "apiKey"');if(typeof f.projectId!="string"||!/^[a-z0-9-]+$/.test(f.projectId))throw new Error(`TWOSHEEP_FIREBASE_CONFIG: ${JSON.stringify(f.projectId)} is not a Firebase project id`);c=f.projectId===Rh.projectId?"production":`project-${f.projectId}`}else c="production",f=Rh;let T=rf(l,c,u);return{emulator:t,emulatorHost:o,emulatorPorts:i,firebase:f,format:s,profile:u,profileDir:T}}E(Sh,"loadConfig");import{join as dM}from"node:path";import{initializeApp as uM}from"firebase/app";import{connectAuthEmulator as EM,initializeAuth as lM}from"firebase/auth";import{connectFirestoreEmulator as cM,getFirestore as fM}from"firebase/firestore";import{connectDatabaseEmulator as TM,getDatabase as NM}from"firebase/database";import{connectFunctionsEmulator as RM,getFunctions as AM}from"firebase/functions";import{chmodSync as tM,existsSync as nM,mkdirSync as iM,readFileSync as oM,renameSync as aM,writeFileSync as sM}from"node:fs";import{dirname as _M}from"node:path";function tf(e){if(!nM(e))return{};try{return JSON.parse(oM(e,"utf8"))}catch{return{}}}E(tf,"read");function Oh(e,r){iM(_M(e),{recursive:!0,mode:448});let t=`${e}.${process.pid}.tmp`;sM(t,JSON.stringify(r),{mode:384}),aM(t,e),tM(e,384)}E(Oh,"write");function Ih(e){class r{static{E(this,"FilePersistence")}static type="LOCAL";type="LOCAL";async _isAvailable(){return!0}async _set(o,i){let n=tf(e);n[o]=i,Oh(e,n)}async _get(o){let i=tf(e)[o];return i===void 0?null:i}async _remove(o){let i=tf(e);o in i&&(delete i[o],Oh(e,i))}_addListener(){}_removeListener(){}}return r}E(Ih,"filePersistence");function Ch(e){let r=uM(e.firebase,`twosheep-mcp-${e.profile}`),t=lM(r,{persistence:Ih(dM(e.profileDir,"auth.json"))}),o=fM(r),i=NM(r),n=AM(r);if(e.emulator){let{emulatorHost:a,emulatorPorts:s}=e;EM(t,`http://${a}:${s.auth}`,{disableWarnings:!0}),cM(o,a,s.firestore),TM(i,a,s.database),RM(n,a,s.functions)}return{app:r,auth:t,firestore:o,database:i,functions:n}}E(Ch,"connectFirebase");import{z as Ca}from"zod";var Ph=`TwoSheep is a free hex-board trading and building game site. These tools let you play a live 1v1 game there against a person or another agent. You play exactly as a human does: the server checks every move. Your account is marked as an AI agent and your opponent sees that.
|
|
3
|
+
|
|
4
|
+
How a game goes:
|
|
5
|
+
1. join_lobby with the 6-character code you were given (or create_lobby and share its code). Both wait for the game to start; if they return "waiting_for_game", call wait_for_turn to keep waiting.
|
|
6
|
+
2. Loop: wait_for_turn until status is "your_turn", then act. act also returns the next legal actions while it is still your move, so a turn is one wait plus a few acts. End your turn with the endTurn action.
|
|
7
|
+
3. Stop when status is "game_over" (state.winner).
|
|
8
|
+
|
|
9
|
+
Act promptly: when it is your move you have actWithinSeconds (usually 90). Against a person, their browser then hands your seat to a bot, and in 1v1 you forfeit after the bot plays two of your turns. Any action resets the clock. If the game is paused, keep waiting; if it ends without a winner (abandoned), you are told so.
|
|
10
|
+
|
|
11
|
+
Only base-game 1v1 lobbies on the standard board are supported; join_lobby refuses others and leaves them.
|
|
12
|
+
|
|
13
|
+
Rules: base game on the standard 19-hex board, with bank trades only (4:1, or better at your ports). The points to win, the discard limit and the robber rule are the lobby's: read them from state.config. Lobbies you create use 15 points, discard half your cards on a 7 if you hold more than 9, and the friendly robber (it may not block a player who only has their starting points).
|
|
14
|
+
|
|
15
|
+
State, actions and events are OpenHex JSON (https://github.com/bovard/open-hex): cube coordinates {x,y,z} where x+y+z=0 for hexes, vertices have x+y+z of 1 or 2, and an edge is its two vertices. Pick moves from legalActions by id (ids are only good for the position they were listed in), or send an OpenHex action object.`;function SM(e){return{content:[{type:"text",text:JSON.stringify(e)}]}}E(SM,"ok");async function Mn(e){try{return SM(await e())}catch(r){return{isError:!0,content:[{type:"text",text:r instanceof Error?r.message:String(r)}]}}}E(Mn,"run");var nf=Ca.number().int().min(1).max(600).optional().describe("How long to wait, in seconds (default 50, at most 600; many MCP clients give up on a call after 60)"),of=E(e=>(e??50)*1e3,"ms");function ph(e,r){e.registerTool("whoami",{title:"Who am I",description:"Sign in (creating your anonymous TwoSheep account the first time) and return your user id and display name."},()=>Mn(()=>r.whoami())),e.registerTool("join_lobby",{title:"Join a lobby",description:"Join a lobby by its 6-character code, get ready, and wait for the host to start the game. Returns your colour, the state and, if you move first, your legal actions.",inputSchema:{code:Ca.string().min(4).max(12).describe('The lobby code, e.g. "K7QM2P"'),timeoutSec:nf}},({code:t,timeoutSec:o})=>Mn(()=>r.joinLobby(t,of(o)))),e.registerTool("create_lobby",{title:"Create a lobby",description:"Create a 1v1 lobby and wait for an opponent to join and get ready; the game starts by itself after a 10-second countdown. Share the returned code with your opponent.",inputSchema:{victoryPoints:Ca.number().int().min(3).max(20).optional().describe("Points to win (default 15)"),timeoutSec:nf}},({victoryPoints:t,timeoutSec:o})=>Mn(()=>r.createLobby(t,of(o)))),e.registerTool("wait_for_turn",{title:"Wait for your turn",description:"Wait until it is your move (or the game starts, or ends). Returns what happened since you last looked (newEvents), the state, and your legal actions.",inputSchema:{timeoutSec:nf}},({timeoutSec:t})=>Mn(()=>r.waitForTurn(of(t)))),e.registerTool("get_state",{title:"Game state",description:"The game as you see it, as OpenHex state JSON (your hand; other players show handSize and devCardCount).",annotations:{readOnlyHint:!0}},()=>Mn(()=>r.state())),e.registerTool("get_legal_actions",{title:"Legal actions",description:"Every action you may take now, numbered. Pass an id to act.",annotations:{readOnlyHint:!0}},()=>Mn(()=>r.legalActions())),e.registerTool("act",{title:"Take an action",description:'Play one action: an id from the latest legal actions, or an OpenHex action object such as {"type":"buildRoad","edge":[{"x":0,"y":0,"z":1},{"x":1,"y":0,"z":0}]}. Returns the new state and, if it is still your move, the next legal actions.',inputSchema:{id:Ca.number().int().min(0).optional().describe("An id from the latest legal actions"),action:Ca.looseObject({type:Ca.string()}).optional().describe("An OpenHex action, instead of an id")}},({id:t,action:o})=>Mn(()=>r.act({id:t,action:o}))),e.registerTool("get_events",{title:"Game events",description:"The game log as OpenHex events, after a sequence number (all of them by default).",inputSchema:{afterSeq:Ca.number().int().min(-1).optional().describe("Return events with seq greater than this")},annotations:{readOnlyHint:!0}},({afterSeq:t})=>Mn(()=>r.events(t??-1))),e.registerTool("resign",{title:"Resign",description:"Resign the current game; your opponent wins.",annotations:{destructiveHint:!0}},()=>Mn(()=>r.resign()))}E(ph,"registerTools");var $_="0.1.0";var af=E((...e)=>console.error(...e),"toStderr");console.log=af;console.info=af;console.debug=af;var CM=`twosheep-mcp ${$_}: an MCP stdio server that lets an AI agent play live TwoSheep games.
|
|
16
|
+
|
|
17
|
+
Add it to your agent, for example: claude mcp add twosheep --scope user -- npx -y @2sheep/mcp@latest
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
--profile <name> a separate agent account (two agents on one machine need two)
|
|
21
|
+
--format coordinates|indices board positions as OpenHex coordinates (default) or numbered spots
|
|
22
|
+
--emulator use local Firebase emulators instead of the live site, with
|
|
23
|
+
--emulator-host <host> --emulator-ports auth=9099,firestore=8180,database=9000,functions=5001
|
|
24
|
+
--emulator-project <id> --emulator-db-namespace <ns>
|
|
25
|
+
--version, --help`;async function PM(){let e=process.argv.slice(2);if(e.includes("--version"))return void process.stdout.write(`${$_}
|
|
26
|
+
`);if(e.includes("--help")||e.includes("-h"))return void process.stdout.write(`${CM}
|
|
27
|
+
`);let r=Sh(e,process.env),t=new yu(Nh(Ch(r)),{format:r.format,profileDir:r.profileDir}),o=new OM({name:"twosheep",version:$_},{instructions:Ph});ph(o,t);let i=E(()=>{let a=E(()=>process.exit(0),"exit");setTimeout(a,2e3).unref(),t.close().finally(a)},"shutdown");process.on("SIGINT",i),process.on("SIGTERM",i),process.stdin.on("close",i),await o.connect(new IM);let n=r.emulator?"emulator":`project ${r.firebase.projectId}`;console.error(`twosheep-mcp ${$_} ready (${n}, profile dir ${r.profileDir})`)}E(PM,"main");PM().catch(e=>{console.error(e instanceof Error?e.message:e),process.exit(1)});
|