import _extends from "@babel/runtime/helpers/extends";
import { t } from "../../src/locale";
import snippets from "./snippets";
import loopData from "../_com-props/loopData";
import { VideoMade } from "../_utils/formKeyType";
import { CVideoStepsSetter, CVideoUploadSetter, CUploadBatchSetter } from "../_setters";
import componentKey from "../_com-props/componentKey";
import componentName from "../_com-props/componentName";
var Meta = {
  componentName: "ToolVideo",
  title: "ToolVideo",
  docUrl: "",
  screenshot: "",
  devMode: "proCode",
  group: t("tool-video.key_0LG8nlYw0f50"),
  category: "Element",
  configure: {
    props: [loopData, componentKey, componentName, {
      name: "display",
      title: {
        label: t("page.display"),
        tip: t("page.displayTip")
      },
      propType: {
        type: "oneOf",
        value: [VideoMade.Video, VideoMade.VideoFrames]
      },
      setter: [{
        componentName: "RadioGroupSetter",
        props: {
          options: [{
            title: t("tool-video.key_YlYhW2fvideo"),
            value: VideoMade.Video
          }, {
            title: t("tool-video.key_YlYhW2frames"),
            value: VideoMade.VideoFrames
          }]
        }
      }, "VariableSetter"],
      defaultValue: VideoMade.Video,
      extraProps: {
        setValue: function setValue(target, value) {
          target.parent.setPropValue("stepsVideo", []);
          // let val = target.getValue();
          // if (target.node.propsData.stepsVideo.length > 0) {
          //   Dialog.show({
          //     v2: true,
          //     title: t("tool-video.key_YlYhW2fititle"),
          //     content: t("tool-video.key_YlYhW2content"),
          //     onOk: () => {

          //     },
          //     onCancel: () => {
          //       if (val === "video") {
          //         target.parent.setPropValue("display", "videoframes");
          //       } else {
          //         target.parent.setPropValue("display", "video");
          //       }
          //     },
          //   });
          // }
        }
      }
    }, {
      display: "block",
      type: "group",
      items: [{
        name: "videoUrl",
        title: {
          label: "Web Link",
          tip: "url | Web Link"
        },
        propType: "string",
        setter: "StringSetter",
        condition: function condition(target) {
          var type = target.parent.getPropValue("display");
          return type === VideoMade.Video;
        }
      }, {
        name: "uploadUrl",
        title: {
          label: t("tool-video.key_YlYhgW2xUplo"),
          tip: t("tool-video.key_YlYhgW2xUpfe")
        },
        propType: "string",
        setter: CVideoUploadSetter,
        extraProps: {
          setValue: function setValue(target, value) {
            if (value !== undefined && value !== "" && value.length !== 0) {
              target.parent.setPropValue("videoUrl", value);
              target.parent.setPropValue("uploadUrl", "");
            }
          }
        },
        condition: function condition(target) {
          var type = target.parent.getPropValue("display");
          return type === VideoMade.Video;
        }
      }, {
        name: "controls",
        title: {
          label: t("tool-video.key_Tv3ar0I2Bf90"),
          tip: t("tool-video.key_U10uPHbV1qtm")
        },
        defaultValue: true,
        propType: "bool",
        setter: "BoolSetter",
        condition: function condition(target) {
          var type = target.parent.getPropValue("display");
          return type === VideoMade.Video;
        }
      }]
    }, {
      display: "block",
      type: "group",
      items: [{
        name: "imgArrList",
        title: {
          label: t("tool-video.key_YlYhW2fimage"),
          tip: t("tool-video.key_YlYhW2fvidfr")
        },
        propType: "string",
        setter: CUploadBatchSetter,
        condition: function condition(target) {
          var type = target.parent.getPropValue("display");
          return type === VideoMade.VideoFrames;
        }
      }, {
        name: "showRule",
        title: t("typographyText.key_7pYhGvcVjrOp"),
        display: "accordion",
        setter: {
          componentName: "ObjectSetter",
          props: {
            config: {
              items: [{
                name: "type",
                title: {
                  label: t("typographyText.key_IrNMKZtH0OR6"),
                  tip: t("typographyText.key_NlQnbupasWgL")
                },
                mode: "tag",
                defaultValue: function defaultValue() {
                  return "singular";
                },
                setter: {
                  componentName: "SelectSetter",
                  props: {
                    options: [{
                      title: t("tool-video.key_YlYhW2fimsece"),
                      value: "singular"
                    }, {
                      title: t("tool-video.key_YlYhW2fimrate"),
                      value: "total"
                    }]
                  },
                  initialValue: "singular"
                }
              }, {
                name: "secondsFrame",
                title: {
                  label: t("tool-video.key_YlYhW2fimsece"),
                  tip: t("tool-video.key_YlYhW2fimsece")
                },
                setter: {
                  componentName: "NumberSetter",
                  props: {
                    precision: 3
                  }
                },
                condition: function condition(target) {
                  var type = target.parent.getPropValue("type");
                  return type === "singular";
                }
              }, {
                name: "frameRate",
                title: {
                  label: t("tool-video.key_YlYhW2fimrate"),
                  tip: t("tool-video.key_YlYhW2fimrate")
                },
                setter: {
                  componentName: "NumberSetter",
                  props: {
                    precision: 3
                  }
                },
                condition: function condition(target) {
                  var type = target.parent.getPropValue("type");
                  return type === "total";
                }
              }]
            }
          }
        },
        condition: function condition(target) {
          var type = target.parent.getPropValue("display");
          return type === VideoMade.VideoFrames;
        }
      }]
    }, {
      name: "coverSrc",
      title: {
        label: t("tool-video.key_FA0tRqqnGsie"),
        tip: t("tool-video.key_n2KfKMt16aBP")
      },
      propType: {
        type: "string",
        isRequired: true
      },
      setter: "StringSetter"
    }, {
      name: "updateSrc",
      title: {
        label: t("tool-video.key_US8tWvo4Wj5v"),
        tip: t("tool-video.key_4eynr37JiIF3")
      },
      setter: "CUploadImageDefaultSetter",
      extraProps: {
        setValue: function setValue(target, value) {
          if (value !== undefined && value !== "") {
            target.parent.setPropValue("coverSrc", value);
          }
        }
      }
    }, {
      name: "stepsVideo",
      title: {
        label: t("tool-video.groupManager"),
        tip: t("tool-video.groupManagerTip")
      },
      setter: CVideoStepsSetter
    }],
    supports: {
      style: true,
      events: false,
      loop: false,
      condition: false
    },
    component: {}
  },
  snippets: snippets
};
export default _extends({}, Meta, {
  snippets: snippets
});