{ "version": 3, "sources": ["../../board/board_chooser_props.tsx"], "sourcesContent": ["import * as React from \"react\"\nimport {\n AccessLevel,\n AccountUID,\n BoardInfo,\n BoardType,\n is_AccountUID,\n is_TeamUID,\n TeamUID,\n} from \"@cling/lib.shared.model\"\nimport {\n account_resource,\n board_info_resource,\n meet_status_resource,\n team_resource,\n} from \"@cling/lib.web.resources\"\nimport {current_user, ui_state} from \"../state/index\"\nimport type {BoardChooserItem} from \"@cling/lib.web.board_chooser/board_chooser_items\"\nimport {background_style} from \"@cling/lib.web.layout\"\nimport {full_name} from \"@cling/lib.shared.utils\"\nimport {PrincipalInfo} from \"../account/principal_info\"\nimport {i18n} from \"@cling/lib.web.i18n\"\nimport {board_name} from \"./board_name\"\nimport {Icon} from \"@cling/lib.web.mdc\"\nimport {simple_tooltip_event_handlers} from \"@cling/lib.web.mdc/simple_tooltip\"\nimport {board_background_image_url} from \"@cling/lib.web.resources/thumbnails\"\n\n// TODO: Test the filtering, min_access_level etc.\nexport function board_chooser_board_infos(\n filter?: \"system_boards_only\" | \"dashboard_and_user_boards\" | \"user_boards\",\n min_access_level?: AccessLevel,\n) {\n return (\n board_info_resource\n .read_all()\n .filter(\n (x) =>\n x.board_type !== BoardType.people &&\n (filter !== \"system_boards_only\" || x.is_system_board) &&\n (filter !== \"dashboard_and_user_boards\" || x.is_dashboard_or_user_board) &&\n (filter !== \"user_boards\" || x.is_user_board),\n )\n .filter(\n (x) =>\n !min_access_level ||\n (x.acl.access_level(current_user.account_attributes) || 0) >= min_access_level,\n )\n // Filter out boards the user only sees because they are public ...\n .filter(\n (x) =>\n !x.acl.is_public || x.acl.entries(current_user.account_attributes).length > 0,\n )\n )\n}\n\nfunction can_be_folded(board_info: BoardInfo, archived?: boolean) {\n if (board_info.board_type === BoardType.dashboard) {\n return false\n }\n const fourteen_days_ago = Date.now() - 14 * 24 * 60 * 60 * 1000\n return (\n archived ||\n ((board_info.last_important_change || board_info.last_change).date.getTime() <\n fourteen_days_ago &&\n (ui_state.board_last_seen(board_info.uid)?.getTime() ?? Date.now()) < fourteen_days_ago)\n )\n}\n\nexport function board_chooser_props(\n filter?: \"system_boards_only\" | \"dashboard_and_user_boards\" | \"user_boards\",\n min_access_level?: AccessLevel,\n): {items: BoardChooserItem[]} {\n const {account_settings} = current_user\n const board_infos = board_chooser_board_infos(filter, min_access_level)\n function title(board_info: BoardInfo) {\n const {acl} = board_info\n const {all} = acl\n if (all.length === 1) {\n return (\n <div className=\"board-chooser-item__title\">\n <div>{board_name(board_info)}</div>\n <div />\n </div>\n )\n }\n let shared_with = `${i18n.shared_with} `\n const team_names = all\n .filter((x) => is_TeamUID(x))\n .map((x) => team_resource.read(x as TeamUID)?.name || \"...\")\n .sort((a, b) => a.localeCompare(b))\n // SEC: It is important that a user only sees the team if a board is shared with a team\n // and other individual users. In a team-scenario (say a school) we don't want\n // team-members to know who else has access to a board (especially if the team has\n // not full-access to the board)\n if (team_names.length > 0) {\n shared_with += team_names[0]\n } else {\n if (board_info.owner !== current_user.account.uid) {\n shared_with += full_name(account_resource.read(board_info.owner))\n } else {\n const account_names = all\n .filter((x) => is_AccountUID(x))\n .filter((x) => x !== current_user.account.uid)\n .map((x) => full_name(account_resource.read(x as AccountUID)))\n .sort((a, b) => a.localeCompare(b))\n shared_with += account_names[0]\n }\n }\n const is_public = acl.is_public\n if (is_public) {\n if (board_info.indexed_by_search_engines) {\n shared_with = i18n.public\n } else {\n shared_with = i18n.shared_as_link\n }\n } else if (all.length > 2) {\n shared_with += ` +${all.length - 2}`\n }\n return (\n <div className=\"board-chooser-item__title\">\n <div>{board_name(board_info)}</div>\n {is_public && board_info.indexed_by_search_engines && (\n <Icon\n icon=\"public\"\n outlined\n small\n aria-label={shared_with}\n {...simple_tooltip_event_handlers}\n />\n )}\n {is_public && !board_info.indexed_by_search_engines && (\n <Icon\n icon=\"visibility\"\n outlined\n small\n aria-label={shared_with}\n {...simple_tooltip_event_handlers}\n />\n )}\n {!is_public && all.length > 1 && board_info.board_type !== BoardType.people && (\n <Icon\n icon=\"people\"\n outlined\n small\n aria-label={shared_with}\n {...simple_tooltip_event_handlers}\n />\n )}\n {!is_public && all.length === 1 && <div />}\n </div>\n )\n }\n return {\n items: board_infos.map((x) => {\n const archived = account_settings.board_setting(x.uid)?.archived\n const name = board_name(x)\n return {\n uid: x.uid,\n sort: {\n name: name,\n date_ms: (x.last_important_change || x.last_change).date.getTime(),\n },\n user_board_title: title(x),\n user_board_title_str: name,\n archived,\n show_badge: !!(x.is_user_board && ui_state.is_new_or_changed(x)),\n background_style: board_background_style(x),\n can_be_folded: can_be_folded(x, archived),\n selected: ui_state.current_board_uid === x.uid,\n num_participants_in_video_chat:\n meet_status_resource.read(x.uid)?.participants.length ?? 0,\n }\n }),\n }\n}\n\nexport function board_background_style(board_info: BoardInfo): React.CSSProperties {\n if (board_info.board_type === BoardType.people) {\n const shared_with_uid = board_info.people_board_shared_with(current_user.account.uid)\n const shared_with_account = account_resource.read(shared_with_uid)\n return {\n backgroundImage: `url(${shared_with_account?.profile_image_url})`,\n backgroundSize: \"cover\",\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: \"center center\",\n }\n }\n return background_style({\n url: board_background_image_url(board_info.board_style, {dim: 128}),\n color: board_info.board_style.background_color,\n is_pattern: board_info.board_style.background_is_pattern,\n })\n}\n\nexport function people_chooser_board_infos() {\n return board_info_resource.read_all().filter((x) => x.board_type === BoardType.people)\n}\n\nexport function people_chooser_props(): {items: BoardChooserItem[]} {\n const {\n account: {uid: account_uid},\n account_settings,\n } = current_user\n const board_infos = people_chooser_board_infos()\n return {\n items: board_infos.map((x) => {\n const shared_with_uid = x.people_board_shared_with(account_uid)\n const archived = account_settings.board_setting(x.uid)?.archived\n const name = board_name(x)\n return {\n uid: x.uid,\n sort: {name, date_ms: (x.last_important_change || x.last_change).date.getTime()},\n user_board_title: (\n <PrincipalInfo\n className=\"mdc-list-item__text\"\n display=\"full_name\"\n prefix={archived ? `[${i18n.archived}] ` : \"\"}\n uid={shared_with_uid}\n />\n ),\n user_board_title_str: name,\n archived,\n show_badge: !!ui_state.is_new_or_changed(x),\n background_style: board_background_style(x),\n can_be_folded: can_be_folded(x, archived),\n selected: ui_state.current_board_uid === x.uid,\n num_participants_in_video_chat:\n meet_status_resource.read(x.uid)?.participants.length ?? 0,\n }\n }),\n }\n}\n"], "mappings": "4eAAAA,IA4BO,SAASC,EACZC,EACAC,EACF,CACE,OACIC,EACK,SAAS,EACT,OACIC,GACGA,EAAE,aAAe,IAChBH,IAAW,sBAAwBG,EAAE,mBACrCH,IAAW,6BAA+BG,EAAE,8BAC5CH,IAAW,eAAiBG,EAAE,cACvC,EACC,OACIA,GACG,CAACF,IACAE,EAAE,IAAI,aAAaC,EAAa,kBAAkB,GAAK,IAAMH,CACtE,EAEC,OACIE,GACG,CAACA,EAAE,IAAI,WAAaA,EAAE,IAAI,QAAQC,EAAa,kBAAkB,EAAE,OAAS,CACpF,CAEZ,CAzBgBC,EAAAN,EAAA,6BA2BhB,SAASO,EAAcC,EAAuBC,EAAoB,CAC9D,GAAID,EAAW,aAAe,EAC1B,MAAO,GAEX,IAAME,EAAoB,KAAK,IAAI,EAAI,GAAK,GAAK,GAAK,GAAK,IAC3D,OACID,IACED,EAAW,uBAAyBA,EAAW,aAAa,KAAK,QAAQ,EACvEE,IACCC,EAAS,gBAAgBH,EAAW,GAAG,GAAG,QAAQ,GAAK,KAAK,IAAI,GAAKE,CAElF,CAXSJ,EAAAC,EAAA,iBAaF,SAASK,GACZX,EACAC,EAC2B,CAC3B,GAAM,CAAC,iBAAAW,CAAgB,EAAIR,EACrBS,EAAcd,EAA0BC,EAAQC,CAAgB,EACtE,SAASa,EAAMP,EAAuB,CAClC,GAAM,CAAC,IAAAQ,CAAG,EAAIR,EACR,CAAC,IAAAS,CAAG,EAAID,EACd,GAAIC,EAAI,SAAW,EACf,OACIC,EAAC,OAAI,UAAU,6BACXA,EAAC,WAAKC,EAAWX,CAAU,CAAE,EAC7BU,EAAC,UAAI,CACT,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AAC,IAAKC,CAAW,EAC1B,iBAAA7B,CACJ,EAAIR,EAEJ,MAAO,CACH,MAFgBmC,EAA2B,EAExB,IAAKpC,GAAM,CAC1B,IAAMiC,EAAkBjC,EAAE,yBAAyBsC,CAAW,EACxDjC,EAAWI,EAAiB,cAAcT,EAAE,GAAG,GAAG,SAClD8B,EAAOf,EAAWf,CAAC,EACzB,MAAO,CACH,IAAKA,EAAE,IACP,KAAM,CAAC,KAAA8B,EAAM,SAAU9B,EAAE,uBAAyBA,EAAE,aAAa,KAAK,QAAQ,CAAC,EAC/E,iBACIc,EAACyB,EAAA,CACG,UAAU,sBACV,QAAQ,YACR,OAAQlC,EAAW,IAAIY,EAAK,QAAQ,KAAO,GAC3C,IAAKgB,EACT,EAEJ,qBAAsBH,EACtB,SAAAzB,EACA,WAAY,CAAC,CAACE,EAAS,kBAAkBP,CAAC,EAC1C,iBAAkB+B,EAAuB/B,CAAC,EAC1C,cAAeG,EAAcH,EAAGK,CAAQ,EACxC,SAAUE,EAAS,oBAAsBP,EAAE,IAC3C,+BACIgC,EAAqB,KAAKhC,EAAE,GAAG,GAAG,aAAa,QAAU,CACjE,CACJ,CAAC,CACL,CACJ,CAjCgBE,EAAAmC,GAAA", "names": ["init_compat_module", "board_chooser_board_infos", "filter", "min_access_level", "board_info_resource", "x", "current_user", "__name", "can_be_folded", "board_info", "archived", "fourteen_days_ago", "ui_state", "board_chooser_props", "account_settings", "board_infos", "title", "acl", "all", "_", "board_name", "shared_with", "i18n", "team_names", "is_TeamUID", "team_resource", "a", "b", "full_name", "account_resource", "account_names", "is_AccountUID", "is_public", "Icon", "simple_tooltip_event_handlers", "name", "board_background_style", "meet_status_resource", "shared_with_uid", "background_style", "board_background_image_url", "people_chooser_board_infos", "people_chooser_props", "account_uid", "PrincipalInfo"] }