{ "version": 3, "sources": ["../../state/permission_hooks.ts"], "sourcesContent": ["import * as React from \"react\"\nimport type {Card} from \"@cling/lib.shared.model\"\nimport {BoardContext} from \"../board_context\"\nimport {current_user} from \"./index\"\nimport type {BoardPermissions, CardPermissions} from \"@cling/lib.web.resources\"\n\nexport function useCardPermission(card?: Card): CardPermissions {\n const {current_board} = React.useContext(BoardContext)\n if (!current_board.board || !card || card.board_uid !== current_board.board.uid) {\n return {\n can_add_comment: false,\n can_add_board: false,\n can_add_card: false,\n can_archive_card: false,\n can_copy_card: false,\n can_cut_card: false,\n can_edit_card: false,\n can_edit_task: false,\n can_move_card: false,\n can_remove_card: false,\n can_report_abuse: false,\n }\n }\n return current_user.card_permissions(current_board.board, current_board.display_version, card)\n}\n\nexport function useCurrentBoardPermission(): BoardPermissions {\n const {\n current_board: {board, display_version},\n } = React.useContext(BoardContext)\n const [permissions, set_permissions] = React.useState(\n board ? current_user.board_permissions(board, display_version) : undefined,\n )\n React.useEffect(() => {\n set_permissions(board ? current_user.board_permissions(board, display_version) : undefined)\n }, [board, display_version])\n if (!board || !permissions) {\n return {\n can_leave_board: false,\n can_archive_board: false,\n can_view_history: false,\n can_change_board_settings: false,\n can_change_board_common_settings: false,\n can_change_board_notification_settings: false,\n can_export_board: false,\n can_copy_board: false,\n can_import_data: false,\n can_join_video_meeting: false,\n can_remove_board: false,\n can_rename_board: false,\n can_set_custom_access_level: false,\n can_share_board: false,\n can_upload_board_background_image: false,\n could_export_board_in_cling_pro: false,\n could_set_custom_access_level_in_cling_pro: false,\n could_upload_board_background_image_in_cling_pro: false,\n could_view_whole_history: false,\n can_view_whole_history: false,\n }\n }\n return permissions\n}\n"], "mappings": "qLAAAA,IAMO,SAASC,EAAkBC,EAA8B,CAC5D,GAAM,CAAC,cAAAC,CAAa,EAAUC,EAAWC,CAAY,EACrD,MAAI,CAACF,EAAc,OAAS,CAACD,GAAQA,EAAK,YAAcC,EAAc,MAAM,IACjE,CACH,gBAAiB,GACjB,cAAe,GACf,aAAc,GACd,iBAAkB,GAClB,cAAe,GACf,aAAc,GACd,cAAe,GACf,cAAe,GACf,cAAe,GACf,gBAAiB,GACjB,iBAAkB,EACtB,EAEGG,EAAa,iBAAiBH,EAAc,MAAOA,EAAc,gBAAiBD,CAAI,CACjG,CAlBgBK,EAAAN,EAAA,qBAoBT,SAASO,GAA8C,CAC1D,GAAM,CACF,cAAe,CAAC,MAAAC,EAAO,gBAAAC,CAAe,CAC1C,EAAUN,EAAWC,CAAY,EAC3B,CAACM,EAAaC,CAAe,EAAUC,EACzCJ,EAAQH,EAAa,kBAAkBG,EAAOC,CAAe,EAAI,MACrE,EAIA,OAHMI,EAAU,IAAM,CAClBF,EAAgBH,EAAQH,EAAa,kBAAkBG,EAAOC,CAAe,EAAI,MAAS,CAC9F,EAAG,CAACD,EAAOC,CAAe,CAAC,EACvB,CAACD,GAAS,CAACE,EACJ,CACH,gBAAiB,GACjB,kBAAmB,GACnB,iBAAkB,GAClB,0BAA2B,GAC3B,iCAAkC,GAClC,uCAAwC,GACxC,iBAAkB,GAClB,eAAgB,GAChB,gBAAiB,GACjB,uBAAwB,GACxB,iBAAkB,GAClB,iBAAkB,GAClB,4BAA6B,GAC7B,gBAAiB,GACjB,kCAAmC,GACnC,gCAAiC,GACjC,2CAA4C,GAC5C,iDAAkD,GAClD,yBAA0B,GAC1B,uBAAwB,EAC5B,EAEGA,CACX,CAnCgBJ,EAAAC,EAAA", "names": ["init_compat_module", "useCardPermission", "card", "current_board", "x", "BoardContext", "current_user", "__name", "useCurrentBoardPermission", "board", "display_version", "permissions", "set_permissions", "d", "y"] }