import React, { useMemo } from "react";
import Survey from "material-survey/components/Survey";
import { setIn } from "seamless-immutable";
var form = {
  questions: [{
    name: "entityLabels",
    title: "Entity Labels",
    type: "matrixdynamic",
    columns: [{
      cellType: "text",
      name: "id",
      title: "ID"
    }, {
      cellType: "text",
      name: "displayName",
      title: "Display Name"
    }, {
      cellType: "text",
      name: "description",
      title: "Description"
    }]
  }, {
    name: "relationLabels",
    title: "Relation Labels",
    type: "matrixdynamic",
    columns: [{
      cellType: "text",
      name: "id",
      title: "ID"
    }, {
      cellType: "text",
      name: "displayName",
      title: "Display Name"
    }, {
      cellType: "text",
      name: "description",
      title: "Description"
    }]
  }]
};
export default (function (_ref) {
  var iface = _ref.iface,
      onChange = _ref.onChange;
  var defaultAnswers = useMemo(function () {
    return {
      entityLabels: (iface.entityLabels || []).map(function (column) {
        return typeof column === "string" ? {
          id: column,
          displayName: column,
          description: column
        } : column;
      }),
      relationLabels: (iface.relationLabels || []).map(function (column) {
        return typeof column === "string" ? {
          id: column,
          displayName: column,
          description: column
        } : column;
      })
    };
  }, [iface]);
  return /*#__PURE__*/React.createElement(Survey, {
    noActions: true,
    variant: "flat",
    onQuestionChange: function onQuestionChange(questionId, newValue, answers) {
      onChange(setIn(iface, [questionId], newValue));
    },
    form: form,
    defaultAnswers: defaultAnswers
  });
});