"use strict";Object.defineProperty(exports, "__esModule", {value: true});



var _chunk4CV4JOE5js = require('./chunk-4CV4JOE5.js');

// __generated__/ActivityLogsPaginationQuery.graphql.ts
var node, ActivityLogsPaginationQuery_graphql_default;
var init_ActivityLogsPaginationQuery_graphql = _chunk4CV4JOE5js.__esm.call(void 0, {
  "__generated__/ActivityLogsPaginationQuery.graphql.ts"() {
    "use strict";
    node = /* @__PURE__ */ function() {
      var v0 = [
        {
          "defaultValue": 10,
          "kind": "LocalArgument",
          "name": "count"
        },
        {
          "defaultValue": null,
          "kind": "LocalArgument",
          "name": "createdFrom"
        },
        {
          "defaultValue": null,
          "kind": "LocalArgument",
          "name": "createdTo"
        },
        {
          "defaultValue": null,
          "kind": "LocalArgument",
          "name": "cursor"
        },
        {
          "defaultValue": null,
          "kind": "LocalArgument",
          "name": "userName"
        }
      ], v1 = {
        "kind": "Variable",
        "name": "createdFrom",
        "variableName": "createdFrom"
      }, v2 = {
        "kind": "Variable",
        "name": "createdTo",
        "variableName": "createdTo"
      }, v3 = {
        "kind": "Variable",
        "name": "userName",
        "variableName": "userName"
      }, v4 = [
        {
          "kind": "Variable",
          "name": "after",
          "variableName": "cursor"
        },
        v1,
        v2,
        {
          "kind": "Variable",
          "name": "first",
          "variableName": "count"
        },
        v3
      ], v5 = {
        "alias": null,
        "args": null,
        "kind": "ScalarField",
        "name": "id",
        "storageKey": null
      }, v6 = {
        "alias": null,
        "args": null,
        "kind": "ScalarField",
        "name": "url",
        "storageKey": null
      };
      return {
        "fragment": {
          "argumentDefinitions": v0,
          "kind": "Fragment",
          "metadata": null,
          "name": "ActivityLogsPaginationQuery",
          "selections": [
            {
              "args": [
                {
                  "kind": "Variable",
                  "name": "count",
                  "variableName": "count"
                },
                v1,
                v2,
                {
                  "kind": "Variable",
                  "name": "cursor",
                  "variableName": "cursor"
                },
                v3
              ],
              "kind": "FragmentSpread",
              "name": "ActivityLogsFragment"
            }
          ],
          "type": "Query",
          "abstractKey": null
        },
        "kind": "Request",
        "operation": {
          "argumentDefinitions": v0,
          "kind": "Operation",
          "name": "ActivityLogsPaginationQuery",
          "selections": [
            {
              "alias": null,
              "args": v4,
              "concreteType": "ActivityLogConnection",
              "kind": "LinkedField",
              "name": "activityLogs",
              "plural": false,
              "selections": [
                {
                  "alias": null,
                  "args": null,
                  "concreteType": "ActivityLogEdge",
                  "kind": "LinkedField",
                  "name": "edges",
                  "plural": true,
                  "selections": [
                    {
                      "alias": null,
                      "args": null,
                      "concreteType": "ActivityLog",
                      "kind": "LinkedField",
                      "name": "node",
                      "plural": false,
                      "selections": [
                        v5,
                        {
                          "alias": null,
                          "args": null,
                          "kind": "ScalarField",
                          "name": "createdAt",
                          "storageKey": null
                        },
                        {
                          "alias": null,
                          "args": null,
                          "concreteType": "NodeLogEventConnection",
                          "kind": "LinkedField",
                          "name": "events",
                          "plural": false,
                          "selections": [
                            {
                              "alias": null,
                              "args": null,
                              "concreteType": "NodeLogEventEdge",
                              "kind": "LinkedField",
                              "name": "edges",
                              "plural": true,
                              "selections": [
                                {
                                  "alias": null,
                                  "args": null,
                                  "concreteType": "NodeLogEvent",
                                  "kind": "LinkedField",
                                  "name": "node",
                                  "plural": false,
                                  "selections": [
                                    {
                                      "alias": null,
                                      "args": null,
                                      "kind": "ScalarField",
                                      "name": "label",
                                      "storageKey": null
                                    },
                                    {
                                      "alias": null,
                                      "args": null,
                                      "kind": "ScalarField",
                                      "name": "diff",
                                      "storageKey": null
                                    },
                                    v5
                                  ],
                                  "storageKey": null
                                }
                              ],
                              "storageKey": null
                            }
                          ],
                          "storageKey": null
                        },
                        {
                          "alias": null,
                          "args": null,
                          "kind": "ScalarField",
                          "name": "verb",
                          "storageKey": null
                        },
                        v6,
                        {
                          "alias": null,
                          "args": null,
                          "concreteType": "User",
                          "kind": "LinkedField",
                          "name": "user",
                          "plural": false,
                          "selections": [
                            v5,
                            {
                              "alias": null,
                              "args": null,
                              "kind": "ScalarField",
                              "name": "fullName",
                              "storageKey": null
                            },
                            {
                              "alias": null,
                              "args": null,
                              "kind": "ScalarField",
                              "name": "email",
                              "storageKey": null
                            },
                            {
                              "alias": null,
                              "args": [
                                {
                                  "kind": "Literal",
                                  "name": "height",
                                  "value": 48
                                },
                                {
                                  "kind": "Literal",
                                  "name": "width",
                                  "value": 48
                                }
                              ],
                              "concreteType": "File",
                              "kind": "LinkedField",
                              "name": "avatar",
                              "plural": false,
                              "selections": [
                                v6
                              ],
                              "storageKey": "avatar(height:48,width:48)"
                            }
                          ],
                          "storageKey": null
                        },
                        {
                          "alias": null,
                          "args": null,
                          "kind": "ScalarField",
                          "name": "__typename",
                          "storageKey": null
                        }
                      ],
                      "storageKey": null
                    },
                    {
                      "alias": null,
                      "args": null,
                      "kind": "ScalarField",
                      "name": "cursor",
                      "storageKey": null
                    }
                  ],
                  "storageKey": null
                },
                {
                  "alias": null,
                  "args": null,
                  "concreteType": "PageInfo",
                  "kind": "LinkedField",
                  "name": "pageInfo",
                  "plural": false,
                  "selections": [
                    {
                      "alias": null,
                      "args": null,
                      "kind": "ScalarField",
                      "name": "endCursor",
                      "storageKey": null
                    },
                    {
                      "alias": null,
                      "args": null,
                      "kind": "ScalarField",
                      "name": "hasNextPage",
                      "storageKey": null
                    }
                  ],
                  "storageKey": null
                }
              ],
              "storageKey": null
            },
            {
              "alias": null,
              "args": v4,
              "filters": [
                "userName",
                "createdFrom",
                "createdTo"
              ],
              "handle": "connection",
              "key": "ActivityLogs_activityLogs",
              "kind": "LinkedHandle",
              "name": "activityLogs"
            }
          ]
        },
        "params": {
          "cacheID": "0cf140296c61a78216ad563591dd2c03",
          "id": null,
          "metadata": {},
          "name": "ActivityLogsPaginationQuery",
          "operationKind": "query",
          "text": "query ActivityLogsPaginationQuery(\n  $count: Int = 10\n  $createdFrom: Date = null\n  $createdTo: Date = null\n  $cursor: String\n  $userName: String = null\n) {\n  ...ActivityLogsFragment_4k2xyr\n}\n\nfragment ActivityLogsFragment_4k2xyr on Query {\n  activityLogs(first: $count, after: $cursor, userName: $userName, createdFrom: $createdFrom, createdTo: $createdTo) {\n    edges {\n      node {\n        id\n        createdAt\n        events {\n          edges {\n            node {\n              label\n              diff\n              id\n            }\n          }\n        }\n        verb\n        url\n        user {\n          id\n          fullName\n          email\n          avatar(width: 48, height: 48) {\n            url\n          }\n        }\n        __typename\n      }\n      cursor\n    }\n    pageInfo {\n      endCursor\n      hasNextPage\n    }\n  }\n}\n"
        }
      };
    }();
    node.hash = "331e3d4312fbe40053110fe98844df70";
    ActivityLogsPaginationQuery_graphql_default = node;
  }
});

// __generated__/ActivityLogsFragment.graphql.ts
var ActivityLogsFragment_graphql_exports = {};
_chunk4CV4JOE5js.__export.call(void 0, ActivityLogsFragment_graphql_exports, {
  default: () => ActivityLogsFragment_graphql_default
});
var node2, ActivityLogsFragment_graphql_default;
var init_ActivityLogsFragment_graphql = _chunk4CV4JOE5js.__esm.call(void 0, {
  "__generated__/ActivityLogsFragment.graphql.ts"() {
    "use strict";
    init_ActivityLogsPaginationQuery_graphql();
    node2 = /* @__PURE__ */ function() {
      var v0 = [
        "activityLogs"
      ], v1 = {
        "alias": null,
        "args": null,
        "kind": "ScalarField",
        "name": "id",
        "storageKey": null
      }, v2 = {
        "alias": null,
        "args": null,
        "kind": "ScalarField",
        "name": "url",
        "storageKey": null
      };
      return {
        "argumentDefinitions": [
          {
            "defaultValue": 10,
            "kind": "LocalArgument",
            "name": "count"
          },
          {
            "defaultValue": null,
            "kind": "LocalArgument",
            "name": "createdFrom"
          },
          {
            "defaultValue": null,
            "kind": "LocalArgument",
            "name": "createdTo"
          },
          {
            "defaultValue": null,
            "kind": "LocalArgument",
            "name": "cursor"
          },
          {
            "defaultValue": null,
            "kind": "LocalArgument",
            "name": "userName"
          }
        ],
        "kind": "Fragment",
        "metadata": {
          "connection": [
            {
              "count": "count",
              "cursor": "cursor",
              "direction": "forward",
              "path": v0
            }
          ],
          "refetch": {
            "connection": {
              "forward": {
                "count": "count",
                "cursor": "cursor"
              },
              "backward": null,
              "path": v0
            },
            "fragmentPathInResult": [],
            "operation": ActivityLogsPaginationQuery_graphql_default
          }
        },
        "name": "ActivityLogsFragment",
        "selections": [
          {
            "alias": "activityLogs",
            "args": [
              {
                "kind": "Variable",
                "name": "createdFrom",
                "variableName": "createdFrom"
              },
              {
                "kind": "Variable",
                "name": "createdTo",
                "variableName": "createdTo"
              },
              {
                "kind": "Variable",
                "name": "userName",
                "variableName": "userName"
              }
            ],
            "concreteType": "ActivityLogConnection",
            "kind": "LinkedField",
            "name": "__ActivityLogs_activityLogs_connection",
            "plural": false,
            "selections": [
              {
                "alias": null,
                "args": null,
                "concreteType": "ActivityLogEdge",
                "kind": "LinkedField",
                "name": "edges",
                "plural": true,
                "selections": [
                  {
                    "alias": null,
                    "args": null,
                    "concreteType": "ActivityLog",
                    "kind": "LinkedField",
                    "name": "node",
                    "plural": false,
                    "selections": [
                      v1,
                      {
                        "alias": null,
                        "args": null,
                        "kind": "ScalarField",
                        "name": "createdAt",
                        "storageKey": null
                      },
                      {
                        "alias": null,
                        "args": null,
                        "concreteType": "NodeLogEventConnection",
                        "kind": "LinkedField",
                        "name": "events",
                        "plural": false,
                        "selections": [
                          {
                            "alias": null,
                            "args": null,
                            "concreteType": "NodeLogEventEdge",
                            "kind": "LinkedField",
                            "name": "edges",
                            "plural": true,
                            "selections": [
                              {
                                "alias": null,
                                "args": null,
                                "concreteType": "NodeLogEvent",
                                "kind": "LinkedField",
                                "name": "node",
                                "plural": false,
                                "selections": [
                                  {
                                    "alias": null,
                                    "args": null,
                                    "kind": "ScalarField",
                                    "name": "label",
                                    "storageKey": null
                                  },
                                  {
                                    "alias": null,
                                    "args": null,
                                    "kind": "ScalarField",
                                    "name": "diff",
                                    "storageKey": null
                                  }
                                ],
                                "storageKey": null
                              }
                            ],
                            "storageKey": null
                          }
                        ],
                        "storageKey": null
                      },
                      {
                        "alias": null,
                        "args": null,
                        "kind": "ScalarField",
                        "name": "verb",
                        "storageKey": null
                      },
                      v2,
                      {
                        "alias": null,
                        "args": null,
                        "concreteType": "User",
                        "kind": "LinkedField",
                        "name": "user",
                        "plural": false,
                        "selections": [
                          v1,
                          {
                            "alias": null,
                            "args": null,
                            "kind": "ScalarField",
                            "name": "fullName",
                            "storageKey": null
                          },
                          {
                            "alias": null,
                            "args": null,
                            "kind": "ScalarField",
                            "name": "email",
                            "storageKey": null
                          },
                          {
                            "alias": null,
                            "args": [
                              {
                                "kind": "Literal",
                                "name": "height",
                                "value": 48
                              },
                              {
                                "kind": "Literal",
                                "name": "width",
                                "value": 48
                              }
                            ],
                            "concreteType": "File",
                            "kind": "LinkedField",
                            "name": "avatar",
                            "plural": false,
                            "selections": [
                              v2
                            ],
                            "storageKey": "avatar(height:48,width:48)"
                          }
                        ],
                        "storageKey": null
                      },
                      {
                        "alias": null,
                        "args": null,
                        "kind": "ScalarField",
                        "name": "__typename",
                        "storageKey": null
                      }
                    ],
                    "storageKey": null
                  },
                  {
                    "alias": null,
                    "args": null,
                    "kind": "ScalarField",
                    "name": "cursor",
                    "storageKey": null
                  }
                ],
                "storageKey": null
              },
              {
                "alias": null,
                "args": null,
                "concreteType": "PageInfo",
                "kind": "LinkedField",
                "name": "pageInfo",
                "plural": false,
                "selections": [
                  {
                    "alias": null,
                    "args": null,
                    "kind": "ScalarField",
                    "name": "endCursor",
                    "storageKey": null
                  },
                  {
                    "alias": null,
                    "args": null,
                    "kind": "ScalarField",
                    "name": "hasNextPage",
                    "storageKey": null
                  }
                ],
                "storageKey": null
              }
            ],
            "storageKey": null
          }
        ],
        "type": "Query",
        "abstractKey": null
      };
    }();
    node2.hash = "331e3d4312fbe40053110fe98844df70";
    ActivityLogsFragment_graphql_default = node2;
  }
});

// tmp-babel/activity-log/common/graphql/queries/ActivityLogsFragment.js
var _react = require('react');
var _reactrelay = require('react-relay');
var _ActivityLogsFragment;
var ActivityLogsFragmentQuery = _ActivityLogsFragment !== void 0 ? _ActivityLogsFragment : (_ActivityLogsFragment = (init_ActivityLogsFragment_graphql(), _chunk4CV4JOE5js.__toCommonJS.call(void 0, ActivityLogsFragment_graphql_exports)), _ActivityLogsFragment.hash && _ActivityLogsFragment.hash !== "331e3d4312fbe40053110fe98844df70" && console.error("The definition of 'ActivityLogsFragment' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ActivityLogsFragment);
var useActivityLogs = function useActivityLogs2(targetRef) {
  var _usePaginationFragmen = _reactrelay.usePaginationFragment.call(void 0, ActivityLogsFragmentQuery, targetRef), data = _usePaginationFragmen.data, loadNext = _usePaginationFragmen.loadNext, isLoadingNext = _usePaginationFragmen.isLoadingNext, hasNext = _usePaginationFragmen.hasNext, refetch = _usePaginationFragmen.refetch;
  var logGroups = _react.useMemo.call(void 0, function() {
    var _data$activityLogs;
    var groupedLogs = {};
    data === null || data === void 0 || (_data$activityLogs = data.activityLogs) === null || _data$activityLogs === void 0 || (_data$activityLogs = _data$activityLogs.edges) === null || _data$activityLogs === void 0 || _data$activityLogs.forEach(function(edge) {
      var _log$user;
      var log = edge === null || edge === void 0 ? void 0 : edge.node;
      if (!log) return;
      var userId = (_log$user = log.user) === null || _log$user === void 0 ? void 0 : _log$user.id;
      var timestamp = new Date(log.createdAt).getTime();
      if (!groupedLogs[userId]) {
        groupedLogs[userId] = [];
      }
      var userLogGroups = groupedLogs[userId];
      if (!userLogGroups) return;
      var lastGroup = userLogGroups[userLogGroups.length - 1];
      if (!lastGroup || timestamp - new Date(lastGroup.lastActivityTimestamp).getTime() > 15 * 60 * 1e3) {
        userLogGroups.push({
          lastActivityTimestamp: log.createdAt,
          logs: [log]
        });
      } else {
        lastGroup.logs.unshift(log);
        lastGroup.lastActivityTimestamp = log.createdAt;
      }
    });
    var result = Object.values(groupedLogs).flat();
    result.sort(function(a, b) {
      return new Date(b.lastActivityTimestamp).getTime() - new Date(a.lastActivityTimestamp).getTime();
    });
    return result;
  }, [data]);
  return {
    logGroups,
    loadNext,
    isLoadingNext,
    hasNext,
    refetch
  };
};




exports.ActivityLogsFragmentQuery = ActivityLogsFragmentQuery; exports.useActivityLogs = useActivityLogs;
//# sourceMappingURL=chunk-RYSJFIPT.js.map