"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _arguments = typeof arguments === "undefined" ? void 0 : arguments;
var _default = {
  group: '原子组件',
  componentName: 'Breadcrumb',
  title: '面包屑',
  docUrl: '',
  screenshot: '',
  npm: {
    "package": '@alilc/lowcode-materials',
    version: '{{version}}',
    exportName: 'Breadcrumb',
    main: '',
    destructuring: true,
    subName: ''
  },
  props: [{
    name: 'prefix',
    propType: 'string',
    description: '样式类名的品牌前缀',
    defaultValue: 'next-'
  }, {
    name: 'rtl',
    propType: 'bool'
  }, {
    name: 'children',
    propType: {
      type: 'instanceOf',
      value: 'node'
    },
    description: '面包屑子节点，需传入 Breadcrumb.Item'
  }, {
    name: 'maxNode',
    propType: {
      type: 'oneOfType',
      value: ['number', {
        type: 'oneOf',
        value: ['auto']
      }]
    },
    description: '面包屑最多显示个数，超出部分会被隐藏, 设置为 auto 会自动根据父元素的宽度适配。',
    defaultValue: 100
  }, {
    name: 'separator',
    propType: {
      type: 'instanceOf',
      value: 'node'
    },
    description: '分隔符，可以是文本或 Icon'
  }, {
    name: 'component',
    propType: {
      type: 'oneOfType',
      value: ['string', 'func']
    },
    description: '设置标签类型',
    defaultValue: 'nav'
  }, {
    name: 'className',
    propType: 'any'
  }, {
    name: 'style',
    propType: 'object'
  }],
  configure: {
    component: {
      isContainer: true,
      nestingRule: {
        childWhitelist: ['Breadcrumb.Item']
      }
    },
    props: [{
      name: 'maxNode',
      title: {
        label: '最大节点数',
        tip: '默认 100'
      },
      setter: 'NumberSetter'
    }, {
      name: '!items',
      title: '内容',
      setter: {
        componentName: 'ArraySetter',
        props: {
          itemSetter: {
            componentName: 'ObjectSetter',
            props: {
              config: {
                items: [{
                  name: 'primaryKey',
                  title: '面包屑项编号',
                  condition: function condition() {
                    return false;
                  },
                  initialValue: function initialValue(val) {
                    if (val) return val;
                    return String(Math.floor(Math.random() * 10000));
                  },
                  setter: 'StringSetter',
                  supportVariable: true
                }, {
                  name: 'children',
                  title: '标题',
                  important: true,
                  initialValue: {
                    zh_CN: '',
                    en_US: '',
                    type: 'i18n'
                  },
                  setter: 'StringSetter'
                }, {
                  name: 'link',
                  title: '链接',
                  initialValue: {
                    zh_CN: '',
                    en_US: '',
                    type: 'i18n'
                  },
                  setter: 'StringSetter',
                  supportVariable: true
                }, {
                  name: 'target',
                  title: '打开方式',
                  initialValue: {
                    zh_CN: '',
                    en_US: '',
                    type: 'i18n'
                  },
                  setter: {
                    componentName: 'RadioGroupSetter',
                    initialValue: '_self',
                    props: {
                      options: [{
                        title: '新开页面',
                        value: '_blank'
                      }, {
                        title: '当前页面',
                        value: '_self'
                      }]
                    }
                  }
                }]
              }
            },
            initialValue: function initialValue() {
              return {
                primaryKey: String(Math.floor(Math.random() * 10000)),
                children: 'Title',
                target: '_self'
              };
            }
          }
        }
      },
      extraProps: {
        virtual: function virtual() {
          return true;
        },
        getValue: function getValue(target, value) {
          console.log('getValue: ', target, value);
          return target.node.children.map(function (child) {
            return {
              primaryKey: String(child.getPropValue('primaryKey')),
              children: child.getPropValue('children'),
              link: child.getPropValue('link'),
              target: child.getPropValue('target')
            };
          });
        },
        setValue: function setValue(target, value) {
          console.log('setValue: ', target, value);
          var node = target.node;
          var map = {};
          if (!Array.isArray(value)) {
            value = [];
          }
          value.forEach(function (item) {
            var BreadcrumbItem = Object.assign({}, item);
            map[item.primaryKey] = BreadcrumbItem;
          });
          node.children.mergeChildren(function (child) {
            var primaryKey = String(child.getPropValue('primaryKey'));
            console.log(child.id + "----" + primaryKey);
            if (Object.hasOwnProperty.call(map, primaryKey)) {
              child.setPropValue('children', map[primaryKey].children);
              child.setPropValue('link', map[primaryKey].link);
              child.setPropValue('target', map[primaryKey].target);
              delete map[primaryKey];
              return false;
            }
            return true;
          }, function () {
            var items = [];
            for (var primaryKey in map) {
              if (Object.hasOwnProperty.call(map, primaryKey)) {
                items.push({
                  componentName: 'Breadcrumb.Item',
                  props: map[primaryKey]
                });
              }
            }
            console.log('adder: ', items);
            return items;
          }, function (child1, child2) {
            var a = value.findIndex(function (item) {
              return String(item.primaryKey) === String(child1.getPropValue('primaryKey'));
            });
            var b = value.findIndex(function (item) {
              return String(item.primaryKey) === String(child2.getPropValue('primaryKey'));
            });
            console.log('a: ', a);
            console.log('b: ', b);
            return a - b;
          });
        },
        onChange: function onChange() {
          console.log('onChange: ', _arguments);
        }
      }
    }],
    supports: {
      style: true
    }
  },
  icon: '',
  category: '导航',
  snippets: require("./snippets")
};
exports["default"] = _default;