"use strict";

exports.__esModule = true;
exports.kanbanStaticStagesData = exports.kanbanStaticLoadMoreCardsData = exports.kanbanStaticInitialCardsData = exports.getKanbanMockStages = exports.getKanbanMockItemsCount = exports.getKanbanMockItems = exports.getKanbanMockInitialData = void 0;
const kanbanStaticStagesData = exports.kanbanStaticStagesData = [{
  id: 'stage-1',
  name: 'Empty Stage'
}, {
  id: 'stage-2',
  name: 'Only one card'
}, {
  id: 'stage-3',
  name: '50 cards for paging'
}, {
  id: 'stage-4',
  name: 'Done - 100 cards',
  isDone: true
}];
const kanbanStaticInitialCardsData = exports.kanbanStaticInitialCardsData = [
// stage-1: 'Empty Stage' - no cards
// stage-2: 'Only one card'
{
  id: 'card-2-1',
  name: 'Only Card',
  stageId: 'stage-2'
},
// stage-3: '50 cards for paging'
...Array.from({
  length: 10
}, (_, i) => ({
  id: `card-3-${i + 1}`,
  name: `Card ${i + 1}`,
  stageId: 'stage-3'
})),
// stage-4: 'Done - 100 cards'
...Array.from({
  length: 10
}, (_, i) => ({
  id: `card-4-${i + 1}`,
  name: `Done Card ${i + 1}`,
  stageId: 'stage-4'
}))];
const kanbanStaticLoadMoreCardsData = exports.kanbanStaticLoadMoreCardsData = [
// stage-1: 'Empty Stage' - no cards
// stage-2: 'Only one card - no more cards'
// stage-3: '50 cards for paging'
...Array.from({
  length: 30
}, (_, i) => ({
  id: `card-3-${i + 1 + 10}`,
  name: `Card ${i + 1 + 10}`,
  stageId: 'stage-3'
})),
// stage-4: 'Done - 100 cards'
...Array.from({
  length: 90
}, (_, i) => ({
  id: `card-4-${i + 1 + 10}`,
  name: `Done Card ${i + 1 + 10}`,
  stageId: 'stage-4'
}))];
const getKanbanMockInitialData = async ({
  ids,
  filters,
  search
}) => {
  var _filters$tags;
  // Prepare search terms if search is provided
  const searchTerms = search ? search.toLowerCase().split(/\s+/).filter(term => term.length > 0) : null;

  // Get tag IDs from filters if provided
  const filterTagIds = (filters == null || (_filters$tags = filters.tags) == null ? void 0 : _filters$tags.map(tag => tag.id)) ?? null;
  return Object.fromEntries(ids.map(id => {
    let items = kanbanStaticInitialCardsData.filter(card => card.stageId === id).slice(0, 10);
    if (searchTerms) {
      items = items.filter(card => {
        const cardName = card.name.toLowerCase();
        return searchTerms.every(term => cardName.includes(term));
      });
    }
    // Filter by tags - cards in mock data don't have tags, so if tags filter is applied, return empty
    if (filterTagIds && filterTagIds.length > 0) {
      items = items.filter(card => {
        const cardTags = card.tagIds;
        if (!cardTags) {
          return false;
        }
        return filterTagIds.some(tagId => cardTags.includes(tagId));
      });
    }
    return [id, {
      items,
      total: items.length,
      cursor: kanbanStaticLoadMoreCardsData.filter(card => card.stageId === id).length > 0 ? 'cursor' : null,
      summaryData: {}
    }];
  }));
};
exports.getKanbanMockInitialData = getKanbanMockInitialData;
const getKanbanMockItems = async query => {
  var _query$filters;
  const stageId = (_query$filters = query.filters) == null ? void 0 : _query$filters.stageId;
  const filtered = stageId ? kanbanStaticLoadMoreCardsData.filter(card => card.stageId === stageId) : null;
  return {
    items: filtered,
    total: (filtered == null ? void 0 : filtered.length) ?? 0,
    cursor: null
  };
};
exports.getKanbanMockItems = getKanbanMockItems;
const getKanbanMockItemsCount = stageId => {
  const filtered = stageId ? kanbanStaticLoadMoreCardsData.filter(card => card.stageId === stageId) : null;
  return (filtered == null ? void 0 : filtered.length) ?? 0;
};
exports.getKanbanMockItemsCount = getKanbanMockItemsCount;
const getKanbanMockStages = async () => {
  return {
    items: kanbanStaticStagesData,
    total: (kanbanStaticStagesData == null ? void 0 : kanbanStaticStagesData.length) ?? 0,
    cursor: null
  };
};
exports.getKanbanMockStages = getKanbanMockStages;
//# sourceMappingURL=kanbanStaticData.js.map