"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
var SuggestedFriends_stories_exports = {};
__export(SuggestedFriends_stories_exports, {
  EmptyState: () => EmptyState,
  WithDefaultFriends: () => WithDefaultFriends,
  WithManyFriends: () => WithManyFriends,
  default: () => SuggestedFriends_stories_default
});
module.exports = __toCommonJS(SuggestedFriends_stories_exports);
var import_react_relay = require("react-relay");
var import_relay = require("@nova/react-test-utils/relay");
var import_test = require("@storybook/test");
var import_schema = require("../../../testing-utils/schema");
var import_SuggestedFriends = require("./SuggestedFriends");
const novaDecorator = (0, import_relay.getNovaDecorator)(import_schema.schema, {
  getEnvironmentOptions: () => ({
    storeOptions: {}
  })
});
const meta = {
  component: import_SuggestedFriends.SuggestedFriendsComponent,
  decorators: [novaDecorator],
  parameters: {
    novaEnvironment: {
      query: import_react_relay.graphql`
        query SuggestedFriendsStoryQuery @relay_test_operation {
          viewer {
            ...SuggestedFriends_suggestedFriendsFragment
          }
        }
      `,
      referenceEntries: {
        viewer: (data) => data == null ? void 0 : data.viewer
      },
      resolvers: {
        Viewer: () => ({
          suggestedFriends: [
            {
              id: "friend-1",
              name: {
                firstName: "Alice",
                lastName: "Johnson"
              }
            },
            {
              id: "friend-2",
              name: {
                firstName: "Bob",
                lastName: "Smith"
              }
            },
            {
              id: "friend-3",
              name: {
                firstName: "Carol",
                lastName: "Williams"
              }
            }
          ]
        })
      }
    }
  }
};
var SuggestedFriends_stories_default = meta;
const WithDefaultFriends = {
  play: (context) => __async(void 0, null, function* () {
    const container = (0, import_test.within)(context.canvasElement);
    yield container.findByText("Alice Johnson");
    yield container.findByText("Bob Smith");
    yield container.findByText("Carol Williams");
  })
};
const EmptyState = {
  parameters: {
    novaEnvironment: {
      resolvers: {
        Viewer: () => ({
          suggestedFriends: []
        })
      }
    }
  },
  play: (context) => __async(void 0, null, function* () {
    const container = (0, import_test.within)(context.canvasElement);
    yield container.findByText("No suggested friends available.");
  })
};
const WithManyFriends = {
  parameters: {
    novaEnvironment: {
      resolvers: {
        Viewer: () => ({
          suggestedFriends: Array.from({ length: 10 }, (_, i) => ({
            id: `friend-${i + 1}`,
            name: {
              firstName: `Friend${i + 1}`,
              lastName: `TestUser${i + 1}`
            }
          }))
        })
      }
    }
  },
  play: (context) => __async(void 0, null, function* () {
    const container = (0, import_test.within)(context.canvasElement);
    yield container.findByText("Friend1 TestUser1");
    yield container.findByText("Friend10 TestUser10");
    const listItems = container.getAllByRole("listitem");
    (0, import_test.expect)(listItems).toHaveLength(10);
  })
};
