import { v as i18n$1, af as apiMediaFunc, s as __assign, ag as OmniMediaViewGetMediaTypeEnum, m as getSignatureUrl, a3 as Input, ah as MAP_DRAG_MODEL, l as getOssUrl } from './MapEditView-67426f04.js';
import * as React from 'react';
import { observer, useLocalStore } from 'mobx-react';
import { filter, map, get } from 'lodash';
import { useMount } from 'ahooks';
import $ from 'jquery';
import { v4 } from 'uuid';
import 'maptalks';
import 'mobx';
import 'lz-string';
import 'dayjs';
import 'react-dom';
import 'classnames';
import 'react-is';
import '@loadable/component';
import 'js-beautify';
import 'axios';
import 'superstruct';
import '@tanem/react-nprogress';
import 'chroma-js';
import 'js-cookie';
import 'is-email';
import 'is-uuid';
import 'is-url';
import 'anymatch';
import 'perf-request';
import '@syncpoint/wkx';
import 'buffer';
import '@turf/turf';
import '@mapbox/polylabel';
import 'turf-multipolygon';
import 'turf-polygon';
import 'gcoord';
import 'eventemitter2';
import 'geobuf';
import 'localforage';
import 'rc-menu';
import 'perfect-scrollbar';
import 'jszip';
import 'file-saver';
import 'screenfull';
import 'sql-formatter-fork';
import 'array-move';
import 'turf-multilinestring';
import 'copy-to-clipboard';
import 'maptalks.three';
import 'ajv';
import 'spark-md5';
import 'react-draggable';
import 'react-virtualized';
import 'turf-point';
import 'decamelize';
import 'rbush';
import 'qs';
import 'maptalks.snap';
import 'react-use';
import 'react-rnd';
import 'react-beautiful-dnd';

var i18n = i18n$1.mapEdit;
var prefixCls = 'map-data-model-list';
var DataModelList = observer(function (_a) {
    var projectOption = _a.projectOption;
    var store = useLocalStore(function () {
        return {
            searchText: '',
            renderList: [],
        };
    });
    useMount(function () {
        apiMediaFunc()
            .getOmniMedia(__assign({ pageSize: 5000 }, ((projectOption === null || projectOption === void 0 ? void 0 : projectOption.version)
            ? { versionId: projectOption === null || projectOption === void 0 ? void 0 : projectOption.version, targetApp: projectOption === null || projectOption === void 0 ? void 0 : projectOption.targetApp }
            : {})))
            .then(function (res) {
            var _res = res.data.result;
            if (_res) {
                var renderList_1 = filter(_res, function (li) { return li.mediaType === OmniMediaViewGetMediaTypeEnum.Model; });
                Promise.all(renderList_1.map(function (r) { return getSignatureUrl(r === null || r === void 0 ? void 0 : r.preview); })).then(function (urls) {
                    store.renderList = renderList_1.map(function (t, index) {
                        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
                        // @ts-ignore
                        t.displayUrl = urls[index];
                        return t;
                    });
                });
            }
        });
    });
    var renderList = store.renderList, searchText = store.searchText;
    // 素材库数据
    return (React.createElement("div", { className: prefixCls },
        React.createElement("div", { className: 'mb4' }, i18n.modelList),
        React.createElement(Input, { className: "".concat(prefixCls, "-input mb8"), block: true, placeholder: i18n.modelSearch, size: "compact", type: 'assist-bg', value: searchText, onChange: function (e) {
                var target = e.target;
                store.searchText = target.value;
            } }),
        React.createElement("div", { className: "".concat(prefixCls, "-list-wrapper") }, map(renderList, function (li) {
            var _a;
            if (searchText) {
                if (((_a = li.name) === null || _a === void 0 ? void 0 : _a.indexOf(searchText)) === -1) {
                    return null;
                }
            }
            return (React.createElement("div", { key: li.id, className: "".concat(prefixCls, "-li mb8"), draggable: true, onDragStart: function () {
                    console.log(li, 'li');
                    var node = {
                        name: li.name,
                        id: v4(),
                        url: get(li, 'url') || get(li, 'extra.url'),
                    };
                    var nodeStr = JSON.stringify(node);
                    sessionStorage.setItem(MAP_DRAG_MODEL, nodeStr);
                    $('.dm-map-models-config-li').addClass('can-dragover');
                }, onDragEnd: function () {
                    $('.dm-map-models-config-li').removeClass('can-dragover');
                    $('.dm-map-models-config-li').removeClass('can-dragover');
                } },
                React.createElement("img", { src: getOssUrl(li.displayUrl), alt: li.name }),
                li.name));
        }))));
});
var DataModelList$1 = DataModelList;

export { DataModelList$1 as default };
