import{NotificationManager}from'./notifications.js';export function getTaskNotificationGroupId(_0x408052){return _0x408052?.['groupId']||_0x408052?.['group_id']||_0x408052?.['originalGroupId']||null;}export function createGroupCompletionNotifier({getTaskGroup:_0x32be6b,getTrackedTasks:_0x22abb6,getGroupNotificationChecks:_0x2aa3ff,getCurrentUser:_0x4a0ebd,onTaskNotified:onTaskNotified=()=>{},logger:logger=console}){async function _0x2912f9(_0x5b1d79){const _0x1d63a6=getTaskNotificationGroupId(_0x5b1d79);if(!_0x1d63a6)return{'suppressTaskNotification':![],'notified':![]};const _0xa3d1e1=_0x2aa3ff(),_0x4b34bc=_0xa3d1e1['get'](_0x1d63a6);if(_0x4b34bc)return _0x4b34bc['needsRefresh']=!![],_0x4b34bc['latestTask']=_0x5b1d79,!_0x4b34bc['refreshPromise']&&(_0x4b34bc['refreshPromise']=_0x4b34bc['promise']['then'](async _0x42cb3d=>{if(!_0x42cb3d['notified']&&_0x4b34bc['needsRefresh'])return _0x2912f9(_0x4b34bc['latestTask']||_0x5b1d79);return _0x42cb3d;})['finally'](()=>{_0x4b34bc['refreshPromise']=null;})),_0x4b34bc['refreshPromise'];const _0x29b6f4={'latestTask':_0x5b1d79,'needsRefresh':![],'promise':null,'refreshPromise':null},_0x8b48f1=((async()=>{try{const _0x52b1b1=await _0x32be6b(_0x1d63a6),_0xaf437e=(_0x52b1b1['tasks']||[])['map'](_0x1b6ece=>_0x1b6ece['taskId']===_0x5b1d79?.['taskId']?{..._0x5b1d79,..._0x1b6ece}:_0x1b6ece);if(_0xaf437e['length']<=0x1)return{'suppressTaskNotification':![],'notified':![]};if(_0x52b1b1['completionNotificationReady']!==!![])return{'suppressTaskNotification':!![],'notified':![],'pending':!![]};const _0x5ca4cf=_0x22abb6();if(!NotificationManager['shouldNotifyGroup'](_0x1d63a6,_0xaf437e,_0x5ca4cf))return{'suppressTaskNotification':!![],'notified':![]};return await NotificationManager['notifyTaskGroupComplete'](_0x52b1b1,_0xaf437e),NotificationManager['markGroupNotified'](_0x1d63a6),_0xaf437e['forEach'](_0x35b3e2=>{_0x35b3e2['taskId']&&(NotificationManager['markNotified'](_0x35b3e2['taskId']),_0x5ca4cf['delete'](_0x35b3e2['taskId']),onTaskNotified(_0x35b3e2));}),{'suppressTaskNotification':!![],'notified':!![]};}catch(_0x40f6eb){return logger['error']('Failed\x20to\x20check\x20task\x20group\x20notification\x20state:',_0x40f6eb),{'suppressTaskNotification':![],'notified':![]};}})());return _0x29b6f4['promise']=_0x8b48f1['finally'](()=>{_0xa3d1e1['get'](_0x1d63a6)===_0x29b6f4&&_0xa3d1e1['delete'](_0x1d63a6);}),_0xa3d1e1['set'](_0x1d63a6,_0x29b6f4),_0x29b6f4['promise'];}async function _0x538802(_0x166d7b){if(!_0x166d7b?.['groupId']||_0x166d7b['isTerminal']!==!![]||_0x166d7b['completionNotificationReady']!==!![])return;if(!NotificationManager['isGroupMode'](_0x4a0ebd()))return;await _0x2912f9({'groupId':_0x166d7b['groupId']});}return{'maybeNotifyGroupCompletionForTask':_0x2912f9,'maybeNotifyGroupCompletionFromStatusSignal':_0x538802};}