@nocobase/plugin-map 0.16.0-alpha.6 → 0.17.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,94 +1,2 @@
1
- export declare const MapActionInitializers: {
2
- title: string;
3
- icon: string;
4
- style: {
5
- marginLeft: number;
6
- };
7
- items: ({
8
- type: string;
9
- title: string;
10
- children: ({
11
- type: string;
12
- title: string;
13
- component: string;
14
- schema: {
15
- 'x-align': string;
16
- 'x-decorator'?: undefined;
17
- 'x-acl-action-props'?: undefined;
18
- };
19
- visible?: undefined;
20
- } | {
21
- type: string;
22
- title: string;
23
- component: string;
24
- schema: {
25
- 'x-align': string;
26
- 'x-decorator': string;
27
- 'x-acl-action-props': {
28
- skipScopeCheck: boolean;
29
- };
30
- };
31
- visible: () => boolean;
32
- })[];
33
- visible?: undefined;
34
- } | {
35
- type: string;
36
- visible: () => boolean;
37
- title?: undefined;
38
- children?: undefined;
39
- } | {
40
- type: string;
41
- title: string;
42
- children: ({
43
- type: string;
44
- title: string;
45
- component: string;
46
- schema: {
47
- type: string;
48
- title: string;
49
- 'x-component': string;
50
- 'x-align': string;
51
- 'x-acl-action': string;
52
- 'x-decorator': string;
53
- 'x-acl-action-props': {
54
- skipScopeCheck: boolean;
55
- };
56
- 'x-action': string;
57
- 'x-designer': string;
58
- 'x-action-settings': {
59
- assignedValues: {};
60
- updateMode: string;
61
- onSuccess: {
62
- manualClose: boolean;
63
- redirecting: boolean;
64
- successMessage: string;
65
- };
66
- };
67
- 'x-component-props': {
68
- icon: string;
69
- useProps: string;
70
- };
71
- };
72
- } | {
73
- type: string;
74
- title: string;
75
- component: string;
76
- schema: {
77
- 'x-align': string;
78
- 'x-decorator': string;
79
- 'x-acl-action': string;
80
- 'x-acl-action-props': {
81
- skipScopeCheck: boolean;
82
- };
83
- type?: undefined;
84
- title?: undefined;
85
- 'x-component'?: undefined;
86
- 'x-action'?: undefined;
87
- 'x-designer'?: undefined;
88
- 'x-action-settings'?: undefined;
89
- 'x-component-props'?: undefined;
90
- };
91
- })[];
92
- visible: () => boolean;
93
- })[];
94
- };
1
+ import { SchemaInitializer } from '@nocobase/client';
2
+ export declare const mapActionInitializers: SchemaInitializer<import("antd").ButtonProps, {}>;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const MapBlockInitializer: (props: any) => React.JSX.Element;
2
+ export declare const MapBlockInitializer: () => React.JSX.Element;
@@ -1,43 +1,43 @@
1
- (function(F,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("react-i18next"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-router-dom"),require("lodash"),require("@formily/shared"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","react-i18next","@ant-design/icons","@formily/react","ahooks","antd","react-router-dom","lodash","@formily/shared","@formily/antd-v5"],r):(F=typeof globalThis!="undefined"?globalThis:F||self,r(F["@nocobase/plugin-map"]={},F.jsxRuntime,F["@nocobase/client"],F.react,F["react-i18next"],F["@ant-design/icons"],F["@formily/react"],F.ahooks,F.antd,F["react-router-dom"],F.lodash,F["@formily/shared"],F["@formily/antd-v5"]))})(this,function(F,r,s,f,pe,te,X,j,w,ie,xe,_e,Je){"use strict";var Ut=Object.defineProperty,Nt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var me=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var je=(F,r,s)=>r in F?Ut(F,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):F[r]=s,P=(F,r)=>{for(var s in r||(r={}))Ve.call(r,s)&&je(F,s,r[s]);if(me)for(var s of me(r))We.call(r,s)&&je(F,s,r[s]);return F},J=(F,r)=>Nt(F,Gt(r));var Ye=(F,r)=>{var s={};for(var f in F)Ve.call(F,f)&&r.indexOf(f)<0&&(s[f]=F[f]);if(F!=null&&me)for(var f of me(F))r.indexOf(f)<0&&We.call(F,f)&&(s[f]=F[f]);return s};var he=(F,r,s)=>new Promise((f,pe)=>{var te=w=>{try{j(s.next(w))}catch(ie){pe(ie)}},X=w=>{try{j(s.throw(w))}catch(ie){pe(ie)}},j=w=>w.done?f(w.value):Promise.resolve(w.value).then(te,X);j((s=s.apply(F,r)).next())});const de="map";function $(e){return`{{t('${e}', { ns: '${de}', nsMode: 'fallback' })}}`}function Q(){return pe.useTranslation(de,{nsMode:"fallback"})}const Xe={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",children:[{type:"item",title:"{{t('Filter')}}",component:"FilterActionInitializer",schema:{"x-align":"left"}},{type:"item",title:"{{t('Add new')}}",component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},visible:function(){return s.useCollection().template!=="sql"}},{type:"item",title:"{{t('Refresh')}}",component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{type:"divider",visible:function(){return s.useCollection().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',children:[{type:"item",title:'{{t("Bulk update")}}',component:"CustomizeActionInitializer",schema:{type:"void",title:'{{ t("Bulk update") }}',"x-component":"Action","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-action":"customize:bulkUpdate","x-designer":"Action.Designer","x-action-settings":{assignedValues:{},updateMode:"selected",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-component-props":{icon:"EditOutlined",useProps:"{{ useCustomizeBulkUpdateActionProps }}"}}},{type:"item",title:'{{t("Bulk edit")}}',component:"CustomizeBulkEditActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"update","x-acl-action-props":{skipScopeCheck:!0}}}],visible:function(){return s.useCollection().template!=="sql"}}]},we=[{label:$("AMap"),value:"amap"},{label:$("Google Maps"),value:"google"}],ye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ce="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV3iEaCDnQ8F/MTgZ4h2d4ljNgmZ4pFszDpmIRIuFP57YWDMcFu7uHMziLMyEKxJBl2MbbM6DZub2NQ3sUZ3K2vkMMGIdNKbi1ADqcZe1q2i7VKzibd8BCEE8GUQ3PQ4ez3KWcGNCbeAfv0neKm85hWRvqo+Hu1LJ2HuwTvAt3tkAciKbDIDO/7iE4l7X9rpqCA30pa3uLwt3nYRAIuIfV5mcWN6msnapf8G405IGQMGry+prB0DiloqPfwng3G3SLDltXnTt5S6PK3NnRr9jAFhDJyLsZAJcz8SGcjOr+xAa0XGGTpOfeSMrYUKcyKlx+gS1oSkbY9VXpm2+rjHKXX2ALm2TS2qq96duaVHp5u19gC5skbc3V05N23FWT8NIfsIVNkra6siGttE2llbX7h9JWhaZ6mfj+lfaJZW3Kn6DJJRNWXWqbgN+Y39jRqtDUKKkrL15PxfdjammrfyhpVmiqlNQVfx9KwX/cFJT6A7awSVLeu1CeUlinxu9o8QsphbUKTWUyfvn5Wcm511QSXvoDtrBJkpedewzaE/E58wdsYZMopSQ55+z+pKK6fo9KKqpXaDkAIgxLWnomK3H1JZVQ0tyv2ICW6XAvLHHJ6QD4K6GgRsVjQ3/g3WzQLffCKGHJqfHgisOXaNy2f/oU7+TdukGIUW5xJ0vic6+oWGzsS7yTd4NoncPiF594GC7FFlSrcVub+gTv4p36btE6h1Fc9nFn7IpzKmZrY5/gXbwTxI0O8xD77rGPYtZeVtE42Jt4B+8C8WAcNu6dPwZDzVh8PYzdcqdXcDbvgMdBPDHEOG7R0Xkxqy6oKAzpDZzNO0AMmIfFvH1kABwZk1epIotv9yjOxOyj+g4xYB4W/dbvlAAdozGsJ3Gmni0mzMPGLvyN6IMo/NojNt/qEZyFmR+CWLAIW3CYaDDUR+D/TTgGdwdncJaeKRbMw8bM/9XdosjlZ5VjU0O3cAZngXTBPCzqzV/cPQAXHeuqVBgu8IVj/TXFGXqWdME8LHLez55mRSw9qUI31fuEZzFjNogNFmFvHPQUACfC8IUbUlTvlbDcSsWzeobYYB42+vWfjDwbnn3c6zCewdnnQGwyD4t47UcjAXA2JO+qCi6ss4V7eUafFZuswn4wM8ex+LgKwqV2cC/OzAXxgnlY+KvfmxkIVaPyr6tRhbWWuId79RnxgnmYY+53VlaHLj2lRm6stRSSc0ph7xoQL1mEzfnWyhPQNrKgGgE1hrjGPTAExEvmYWGvfNOVPUErz6vhiDDCNez5GMQHVmFfd2Vq6MLD6smCGkNc4x4QH5iHPfXyV125H64NX1eFkOpO+I5reo/4wDws9KUDdhSPxFdNIGLc8R3XQHxkFfalHYnB8w6qYRuqO+E7roH4yDws5MX9dtwHlYF5lQi6qYjPfKfXxEcWYbO/sKtsBP50QxFFI/D/De8qQLrBPCwYizY9M2r+of/D+Mx3ID6zDJv1uaVwGfAIBDqGJsbhZ9eQ/BuK+OwYlhzPNe7hXh9Yhe0zwqBB4IAYouCZn1wIXH5GEZ/d1sjBMzzrBfOwoBf2GWFYBMS4C03JWRA087OaoBmf3uCz5zrP8Kx9lmF7jXiE2RbBs95ghB0MIo8/pS0OeJAzvOBLmKY//BAGURBN+jmMa3qPkLdh/wKOL8SpLbnYFgAAAABJRU5ErkJggg==";var Ze=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function He(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se={exports:{}};(function(e,n){(function(t,o){e.exports=o()})(Ze,function(){function t(c){var y=[];return c.AMapUI&&y.push(o(c.AMapUI)),c.Loca&&y.push(a(c.Loca)),Promise.all(y)}function o(c){return new Promise(function(y,u){var d=[];if(c.plugins)for(var v=0;v<c.plugins.length;v+=1)l.AMapUI.plugins.indexOf(c.plugins[v])==-1&&d.push(c.plugins[v]);if(h.AMapUI===i.failed)u("前次请求 AMapUI 失败");else if(h.AMapUI===i.notload){h.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,v=l.AMapUI.version;var z=document.body||document.head,D=document.createElement("script");D.type="text/javascript",D.src="https://webapi.amap.com/ui/"+v+"/main.js",D.onerror=function(I){h.AMapUI=i.failed,u("请求 AMapUI 失败")},D.onload=function(){if(h.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,U=d.length;I<U;I++){var V=d[I].split("/").slice(-1)[0];window.AMapUI[V]=arguments[I]}for(y();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()});else for(y();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()},z.appendChild(D)}else h.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,U=d.length;I<U;I++){var V=d[I].split("/").slice(-1)[0];window.AMapUI[V]=arguments[I]}y()}):y():c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):b.AMapUI.push(function(I){I?u(I):d.length?window.AMapUI.loadUI(d,function(){for(var U=0,V=d.length;U<V;U++){var K=d[U].split("/").slice(-1)[0];window.AMapUI[K]=arguments[U]}y()}):y()})})}function a(c){return new Promise(function(y,u){if(h.Loca===i.failed)u("前次请求 Loca 失败");else if(h.Loca===i.notload){h.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,v=l.AMap.version.startsWith("2"),z=d.startsWith("2");if(v&&!z||!v&&z)u("JSAPI 与 Loca 版本不对应!!");else{v=l.key,z=document.body||document.head;var D=document.createElement("script");D.type="text/javascript",D.src="https://webapi.amap.com/loca?v="+d+"&key="+v,D.onerror=function(I){h.Loca=i.failed,u("请求 AMapUI 失败")},D.onload=function(){for(h.Loca=i.loaded,y();b.Loca.length;)b.Loca.splice(0,1)[0]()},z.appendChild(D)}}else h.Loca===i.loaded?c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):y():c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):b.Loca.push(function(I){I?u(I):u()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var i;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(i||(i={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},h={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},b={AMap:[],AMapUI:[],Loca:[]},x=[],C=function(c){typeof c=="function"&&(h.AMap===i.loaded?c(window.AMap):x.push(c))};return{load:function(c){return new Promise(function(y,u){if(h.AMap==i.failed)u("");else if(h.AMap==i.notload){var d=c.key,v=c.version,z=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&u("禁止多种API加载方式混用"),l.key=d,l.AMap.version=v||l.AMap.version,l.AMap.plugins=z||l.AMap.plugins,h.AMap=i.loading,v=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)h.AMap=i.failed,u(I);else for(h.AMap=i.loaded,t(c).then(function(){y(window.AMap)}).catch(u);x.length;)x.splice(0,1)[0]()},z=document.createElement("script"),z.type="text/javascript",z.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),z.onerror=function(I){h.AMap=i.failed,u(I)},v.appendChild(z)):u("请填写key")}else if(h.AMap==i.loaded)if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(v=0;v<c.plugins.length;v+=1)l.AMap.plugins.indexOf(c.plugins[v])==-1&&d.push(c.plugins[v]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){y(window.AMap)}).catch(u)}):t(c).then(function(){y(window.AMap)}).catch(u)}else if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{var D=[];if(c.plugins)for(v=0;v<c.plugins.length;v+=1)l.AMap.plugins.indexOf(c.plugins[v])==-1&&D.push(c.plugins[v]);C(function(){D.length?window.AMap.plugin(D,function(){t(c).then(function(){y(window.AMap)}).catch(u)}):t(c).then(function(){y(window.AMap)}).catch(u)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},h={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},b={AMap:[],AMapUI:[],Loca:[]}}}})})(Se);var Qe=Se.exports;const $e=He(Qe),Ie="map-configuration",Ae=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,ve=e=>{const n=f.useMemo(()=>{const o=sessionStorage.getItem(Ae(e));return o&&JSON.parse(o)},[e]),{data:t}=s.useRequest({resource:Ie,action:"get",params:{type:e}},{onSuccess(o){sessionStorage.setItem(Ae(e),JSON.stringify(o==null?void 0:o.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!n});return n||(t==null?void 0:t.data)},Re=e=>{const{aMap:n,toCenter:t}=e,{t:o}=Q(),a=f.useRef(),[i,l]=f.useState([]);f.useEffect(()=>{n==null||n.plugin("AMap.PlaceSearch",()=>{a.current=new n.PlaceSearch({city:"全国",pageSize:30})})},[n]);const{run:h}=j.useDebounceFn(x=>{a.current&&a.current.search(x||" ",(C,c)=>{if(C==="complete")l(c.poiList.pois.map(y=>J(P({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(C==="no_data"){l([]);return}w.message.error(o("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),b=x=>{const C=i.find(c=>c.value===x);C!=null&&C.location&&t(C.location)};return r.jsx("div",{className:s.css`
1
+ (function(F,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-i18next"),require("react-router-dom"),require("lodash"),require("@formily/shared"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@ant-design/icons","@formily/react","ahooks","antd","react-i18next","react-router-dom","lodash","@formily/shared","@formily/antd-v5"],n):(F=typeof globalThis!="undefined"?globalThis:F||self,n(F["@nocobase/plugin-map"]={},F.jsxRuntime,F["@nocobase/client"],F.react,F["@ant-design/icons"],F["@formily/react"],F.ahooks,F.antd,F["react-i18next"],F["react-router-dom"],F.lodash,F["@formily/shared"],F["@formily/antd-v5"]))})(this,function(F,n,s,f,ee,J,W,I,ne,ae,xe,_e,Je){"use strict";var Kt=Object.defineProperty,Nt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var me=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var je=(F,n,s)=>n in F?Kt(F,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):F[n]=s,P=(F,n)=>{for(var s in n||(n={}))Ve.call(n,s)&&je(F,s,n[s]);if(me)for(var s of me(n))We.call(n,s)&&je(F,s,n[s]);return F},X=(F,n)=>Nt(F,Gt(n));var Ye=(F,n)=>{var s={};for(var f in F)Ve.call(F,f)&&n.indexOf(f)<0&&(s[f]=F[f]);if(F!=null&&me)for(var f of me(F))n.indexOf(f)<0&&We.call(F,f)&&(s[f]=F[f]);return s};var he=(F,n,s)=>new Promise((f,ee)=>{var J=ne=>{try{I(s.next(ne))}catch(ae){ee(ae)}},W=ne=>{try{I(s.throw(ne))}catch(ae){ee(ae)}},I=ne=>ne.done?f(ne.value):Promise.resolve(ne.value).then(J,W);I((s=s.apply(F,n)).next())});const de="map";function $(e){return`{{t('${e}', { ns: '${de}', nsMode: 'fallback' })}}`}function Q(){return ne.useTranslation(de,{nsMode:"fallback"})}const we=[{label:$("AMap"),value:"amap"},{label:$("Google Maps"),value:"google"}],ye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV3iEaCDnQ8F/MTgZ4h2d4ljNgmZ4pFszDpmIRIuFP57YWDMcFu7uHMziLMyEKxJBl2MbbM6DZub2NQ3sUZ3K2vkMMGIdNKbi1ADqcZe1q2i7VKzibd8BCEE8GUQ3PQ4ez3KWcGNCbeAfv0neKm85hWRvqo+Hu1LJ2HuwTvAt3tkAciKbDIDO/7iE4l7X9rpqCA30pa3uLwt3nYRAIuIfV5mcWN6msnapf8G405IGQMGry+prB0DiloqPfwng3G3SLDltXnTt5S6PK3NnRr9jAFhDJyLsZAJcz8SGcjOr+xAa0XGGTpOfeSMrYUKcyKlx+gS1oSkbY9VXpm2+rjHKXX2ALm2TS2qq96duaVHp5u19gC5skbc3V05N23FWT8NIfsIVNkra6siGttE2llbX7h9JWhaZ6mfj+lfaJZW3Kn6DJJRNWXWqbgN+Y39jRqtDUKKkrL15PxfdjammrfyhpVmiqlNQVfx9KwX/cFJT6A7awSVLeu1CeUlinxu9o8QsphbUKTWUyfvn5Wcm511QSXvoDtrBJkpedewzaE/E58wdsYZMopSQ55+z+pKK6fo9KKqpXaDkAIgxLWnomK3H1JZVQ0tyv2ICW6XAvLHHJ6QD4K6GgRsVjQ3/g3WzQLffCKGHJqfHgisOXaNy2f/oU7+TdukGIUW5xJ0vic6+oWGzsS7yTd4NoncPiF594GC7FFlSrcVub+gTv4p36btE6h1Fc9nFn7IpzKmZrY5/gXbwTxI0O8xD77rGPYtZeVtE42Jt4B+8C8WAcNu6dPwZDzVh8PYzdcqdXcDbvgMdBPDHEOG7R0Xkxqy6oKAzpDZzNO0AMmIfFvH1kABwZk1epIotv9yjOxOyj+g4xYB4W/dbvlAAdozGsJ3Gmni0mzMPGLvyN6IMo/NojNt/qEZyFmR+CWLAIW3CYaDDUR+D/TTgGdwdncJaeKRbMw8bM/9XdosjlZ5VjU0O3cAZngXTBPCzqzV/cPQAXHeuqVBgu8IVj/TXFGXqWdME8LHLez55mRSw9qUI31fuEZzFjNogNFmFvHPQUACfC8IUbUlTvlbDcSsWzeobYYB42+vWfjDwbnn3c6zCewdnnQGwyD4t47UcjAXA2JO+qCi6ss4V7eUafFZuswn4wM8ex+LgKwqV2cC/OzAXxgnlY+KvfmxkIVaPyr6tRhbWWuId79RnxgnmYY+53VlaHLj2lRm6stRSSc0ph7xoQL1mEzfnWyhPQNrKgGgE1hrjGPTAExEvmYWGvfNOVPUErz6vhiDDCNez5GMQHVmFfd2Vq6MLD6smCGkNc4x4QH5iHPfXyV125H64NX1eFkOpO+I5reo/4wDws9KUDdhSPxFdNIGLc8R3XQHxkFfalHYnB8w6qYRuqO+E7roH4yDws5MX9dtwHlYF5lQi6qYjPfKfXxEcWYbO/sKtsBP50QxFFI/D/De8qQLrBPCwYizY9M2r+of/D+Mx3ID6zDJv1uaVwGfAIBDqGJsbhZ9eQ/BuK+OwYlhzPNe7hXh9Yhe0zwqBB4IAYouCZn1wIXH5GEZ/d1sjBMzzrBfOwoBf2GWFYBMS4C03JWRA087OaoBmf3uCz5zrP8Kx9lmF7jXiE2RbBs95ghB0MIo8/pS0OeJAzvOBLmKY//BAGURBN+jmMa3qPkLdh/wKOL8SpLbnYFgAAAABJRU5ErkJggg==";var Xe=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ze(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se={exports:{}};(function(e,r){(function(t,o){e.exports=o()})(Xe,function(){function t(c){var y=[];return c.AMapUI&&y.push(o(c.AMapUI)),c.Loca&&y.push(a(c.Loca)),Promise.all(y)}function o(c){return new Promise(function(y,u){var d=[];if(c.plugins)for(var v=0;v<c.plugins.length;v+=1)l.AMapUI.plugins.indexOf(c.plugins[v])==-1&&d.push(c.plugins[v]);if(h.AMapUI===i.failed)u("前次请求 AMapUI 失败");else if(h.AMapUI===i.notload){h.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,v=l.AMapUI.version;var z=document.body||document.head,D=document.createElement("script");D.type="text/javascript",D.src="https://webapi.amap.com/ui/"+v+"/main.js",D.onerror=function(S){h.AMapUI=i.failed,u("请求 AMapUI 失败")},D.onload=function(){if(h.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var S=0,K=d.length;S<K;S++){var j=d[S].split("/").slice(-1)[0];window.AMapUI[j]=arguments[S]}for(y();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()});else for(y();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()},z.appendChild(D)}else h.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var S=0,K=d.length;S<K;S++){var j=d[S].split("/").slice(-1)[0];window.AMapUI[j]=arguments[S]}y()}):y():c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):b.AMapUI.push(function(S){S?u(S):d.length?window.AMapUI.loadUI(d,function(){for(var K=0,j=d.length;K<j;K++){var U=d[K].split("/").slice(-1)[0];window.AMapUI[U]=arguments[K]}y()}):y()})})}function a(c){return new Promise(function(y,u){if(h.Loca===i.failed)u("前次请求 Loca 失败");else if(h.Loca===i.notload){h.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,v=l.AMap.version.startsWith("2"),z=d.startsWith("2");if(v&&!z||!v&&z)u("JSAPI 与 Loca 版本不对应!!");else{v=l.key,z=document.body||document.head;var D=document.createElement("script");D.type="text/javascript",D.src="https://webapi.amap.com/loca?v="+d+"&key="+v,D.onerror=function(S){h.Loca=i.failed,u("请求 AMapUI 失败")},D.onload=function(){for(h.Loca=i.loaded,y();b.Loca.length;)b.Loca.splice(0,1)[0]()},z.appendChild(D)}}else h.Loca===i.loaded?c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):y():c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):b.Loca.push(function(S){S?u(S):u()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var i;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(i||(i={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},h={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},b={AMap:[],AMapUI:[],Loca:[]},x=[],C=function(c){typeof c=="function"&&(h.AMap===i.loaded?c(window.AMap):x.push(c))};return{load:function(c){return new Promise(function(y,u){if(h.AMap==i.failed)u("");else if(h.AMap==i.notload){var d=c.key,v=c.version,z=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&u("禁止多种API加载方式混用"),l.key=d,l.AMap.version=v||l.AMap.version,l.AMap.plugins=z||l.AMap.plugins,h.AMap=i.loading,v=document.body||document.head,window.___onAPILoaded=function(S){if(delete window.___onAPILoaded,S)h.AMap=i.failed,u(S);else for(h.AMap=i.loaded,t(c).then(function(){y(window.AMap)}).catch(u);x.length;)x.splice(0,1)[0]()},z=document.createElement("script"),z.type="text/javascript",z.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),z.onerror=function(S){h.AMap=i.failed,u(S)},v.appendChild(z)):u("请填写key")}else if(h.AMap==i.loaded)if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(v=0;v<c.plugins.length;v+=1)l.AMap.plugins.indexOf(c.plugins[v])==-1&&d.push(c.plugins[v]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){y(window.AMap)}).catch(u)}):t(c).then(function(){y(window.AMap)}).catch(u)}else if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{var D=[];if(c.plugins)for(v=0;v<c.plugins.length;v+=1)l.AMap.plugins.indexOf(c.plugins[v])==-1&&D.push(c.plugins[v]);C(function(){D.length?window.AMap.plugin(D,function(){t(c).then(function(){y(window.AMap)}).catch(u)}):t(c).then(function(){y(window.AMap)}).catch(u)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},h={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},b={AMap:[],AMapUI:[],Loca:[]}}}})})(Se);var He=Se.exports;const Qe=Ze(He),Ie="map-configuration",Ae=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,ve=e=>{const r=f.useMemo(()=>{const o=sessionStorage.getItem(Ae(e));return o&&JSON.parse(o)},[e]),{data:t}=s.useRequest({resource:Ie,action:"get",params:{type:e}},{onSuccess(o){sessionStorage.setItem(Ae(e),JSON.stringify(o==null?void 0:o.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!r});return r||(t==null?void 0:t.data)},$e=e=>{const{aMap:r,toCenter:t}=e,{t:o}=Q(),a=f.useRef(),[i,l]=f.useState([]);f.useEffect(()=>{r==null||r.plugin("AMap.PlaceSearch",()=>{a.current=new r.PlaceSearch({city:"全国",pageSize:30})})},[r]);const{run:h}=W.useDebounceFn(x=>{a.current&&a.current.search(x||" ",(C,c)=>{if(C==="complete")l(c.poiList.pois.map(y=>X(P({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(C==="no_data"){l([]);return}I.message.error(o("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),b=x=>{const C=i.find(c=>c.value===x);C!=null&&C.location&&t(C.location)};return n.jsx("div",{className:s.css`
2
2
  position: absolute;
3
3
  top: 10px;
4
4
  left: 10px;
5
5
  z-index: 10;
6
6
  width: calc(100% - 20px);
7
- `,children:r.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:o("Enter keywords to search"),filterOption:!1,onSearch:h,onSelect:b,options:i,popupMatchSelectWidth:!1})})},be={point:{mouseTool:"marker",propertyKey:"position",overlay:"Marker"},polygon:{mouseTool:"polygon",editor:"PolygonEditor",propertyKey:"path",overlay:"Polygon"},lineString:{mouseTool:"polyline",editor:"PolylineEditor",propertyKey:"path",overlay:"Polyline"},circle:{mouseTool:"circle",editor:"CircleEditor",transformOptions(e){return{center:e.slice(0,2),radius:e[2]}},overlay:"Circle"}},Pe=f.forwardRef((e,n)=>{const{accessKey:t,securityJsCode:o}=ve(e.mapType)||{},{value:a,onChange:i,block:l=!1,readonly:h,disabled:b=l,zoom:x=13,overlayCommonOptions:C}=e,{t:c}=Q(),y=X.useFieldSchema(),u=f.useRef(),d=f.useRef(),v=f.useRef(),[z,D]=f.useState([]),[I,U]=f.useState(""),{getField:V}=s.useCollection(),K=f.useMemo(()=>{if(e.type)return e.type;const g=V(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),L=f.useRef(),k=f.useRef(null),W=ie.useNavigate(),Z=f.useRef(`nocobase-map-${K||""}-${Date.now().toString(32)}`),{modal:H}=w.App.useApp(),[_]=f.useState(P({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},C)),ee=j.useMemoizedFn(()=>{L.current&&L.current.remove()}),oe=j.useMemoizedFn(()=>{(!b||l)&&K!=="point"&&k.current&&(k.current.setTarget(L.current),k.current.open())}),O=j.useMemoizedFn((g,p=!1)=>{let m=null;if(K==="point"){const{lat:M,lng:N}=g.getPosition();m=[N,M]}else if(K==="polygon"||K==="lineString"){if(m=g.getPath().map(M=>[M.lng,M.lat]),m.length<2)return}else if(K==="circle"){const M=g.getCenter(),N=g.getRadius();m=[M.lng,M.lat,N]}p||(ee(),L.current=g,oe()),i==null||i(m)}),Y=j.useMemoizedFn((g=K)=>{const p=be[g];if(p&&"editor"in p&&!k.current)return k.current=new u.current[p.editor](d.current,null,{createOptions:_,editOptions:_,controlPoint:J(P({},_),{strokeWeight:3}),midControlPoint:J(P({},_),{strokeWeight:2,fillColor:"#fff"})}),k.current.on("adjust",function({target:m}){O(m,!0)}),k.current.on("move",function({target:m}){O(m,!0)}),k.current}),T=j.useMemoizedFn((g=K)=>{var m;if(!v.current||(m=k.current)!=null&&m.getTarget())return;const p=be[g];p&&v.current[p.mouseTool](P({},_))}),R=j.useMemoizedFn((g=K)=>{v.current||(v.current=new u.current.MouseTool(d.current),v.current.on("draw",function({obj:p}){O(p)}),T(g))}),S=(g,p)=>{d.current&&d.current.setZoomAndCenter(18,g,p)},B=()=>{const g=()=>{ee(),k.current&&(k.current.setTarget(),k.current.close()),i==null||i(null)};H.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById(Z.current),onOk(){g()}})},A=()=>{L.current&&d.current.setFitView([L.current])},E=f.useCallback((g=K,p=a,m)=>{const M=be[g];if(!M)return;const N=P(P({},_),m);return"transformOptions"in M?Object.assign(N,M.transformOptions(p)):"propertyKey"in M&&(N[M.propertyKey]=p),new u.current[M.overlay](N)},[_]),G=(g=K,p=a,m)=>{if(!u.current)return;const M=E(g,p,m);return M.setMap(d.current),M};f.useEffect(()=>{if(!u.current||!a||!h&&L.current)return;const g=G();d.current.setFitView([g]),L.current=g,b||(Y(),oe())},[a,z,K,_,b,h]),f.useEffect(()=>{var g,p,m;v.current&&(b?((g=v.current)==null||g.close(),(p=k.current)==null||p.close()):(T(),(m=k.current)==null||m.open()))},[b]),f.useEffect(()=>{!u.current||!K||b||(R(),Y())},[b,z,K]),f.useEffect(()=>{var p,m;if(!a&&(v.current||k.current)&&(ee(),k.current&&(k.current.setTarget(),k.current.close()),i==null||i(null)),!v.current||!k.current)return;k.current.getTarget()?(m=(p=v.current).close)==null||m.call(p):T()},[K,a]),f.useEffect(()=>{if(!t||d.current)return;o&&(window._AMapSecurityConfig={[o.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:o});const g=window.define;return window.define=void 0,$e.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(p=>(window.define=g,requestIdleCallback(()=>{d.current=new p.Map(Z.current,{resizeEnable:!0,zoom:x}),u.current=p,U(""),D([])}))).catch(p=>{typeof p=="string"?p.includes("多个不一致的 key")?U(c("The AccessKey is incorrect, please check it")):U(p):(p==null?void 0:p.type)==="error"&&U("Something went wrong, please refresh the page and try again")}),()=>{var p;(p=d.current)==null||p.destroy(),u.current=null,d.current=null,v.current=null,k.current=null}},[t,K,o]),f.useImperativeHandle(n,()=>({setOverlay:G,getOverlay:E,createMouseTool:R,createEditor:Y,executeMouseTool:T,aMap:u.current,map:d.current,overlay:L.current,mouseTool:()=>v.current,editor:()=>k.current,errMessage:I}));const q=s.useApp();return!t||I?r.jsx(w.Alert,{action:r.jsx(w.Button,{type:"primary",onClick:()=>W(q.pluginSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:I||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):r.jsxs("div",{className:s.css`
7
+ `,children:n.jsx(I.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:o("Enter keywords to search"),filterOption:!1,onSearch:h,onSelect:b,options:i,popupMatchSelectWidth:!1})})},be={point:{mouseTool:"marker",propertyKey:"position",overlay:"Marker"},polygon:{mouseTool:"polygon",editor:"PolygonEditor",propertyKey:"path",overlay:"Polygon"},lineString:{mouseTool:"polyline",editor:"PolylineEditor",propertyKey:"path",overlay:"Polyline"},circle:{mouseTool:"circle",editor:"CircleEditor",transformOptions(e){return{center:e.slice(0,2),radius:e[2]}},overlay:"Circle"}},Pe=f.forwardRef((e,r)=>{const{accessKey:t,securityJsCode:o}=ve(e.mapType)||{},{value:a,onChange:i,block:l=!1,readonly:h,disabled:b=l,zoom:x=13,overlayCommonOptions:C}=e,{t:c}=Q(),y=J.useFieldSchema(),u=f.useRef(),d=f.useRef(),v=f.useRef(),[z,D]=f.useState([]),[S,K]=f.useState(""),{getField:j}=s.useCollection(),U=f.useMemo(()=>{if(e.type)return e.type;const g=j(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),L=f.useRef(),k=f.useRef(null),V=ae.useNavigate(),Z=f.useRef(`nocobase-map-${U||""}-${Date.now().toString(32)}`),{modal:H}=I.App.useApp(),[_]=f.useState(P({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},C)),te=W.useMemoizedFn(()=>{L.current&&L.current.remove()}),oe=W.useMemoizedFn(()=>{(!b||l)&&U!=="point"&&k.current&&(k.current.setTarget(L.current),k.current.open())}),O=W.useMemoizedFn((g,p=!1)=>{let m=null;if(U==="point"){const{lat:M,lng:N}=g.getPosition();m=[N,M]}else if(U==="polygon"||U==="lineString"){if(m=g.getPath().map(M=>[M.lng,M.lat]),m.length<2)return}else if(U==="circle"){const M=g.getCenter(),N=g.getRadius();m=[M.lng,M.lat,N]}p||(te(),L.current=g,oe()),i==null||i(m)}),Y=W.useMemoizedFn((g=U)=>{const p=be[g];if(p&&"editor"in p&&!k.current)return k.current=new u.current[p.editor](d.current,null,{createOptions:_,editOptions:_,controlPoint:X(P({},_),{strokeWeight:3}),midControlPoint:X(P({},_),{strokeWeight:2,fillColor:"#fff"})}),k.current.on("adjust",function({target:m}){O(m,!0)}),k.current.on("move",function({target:m}){O(m,!0)}),k.current}),T=W.useMemoizedFn((g=U)=>{var m;if(!v.current||(m=k.current)!=null&&m.getTarget())return;const p=be[g];p&&v.current[p.mouseTool](P({},_))}),R=W.useMemoizedFn((g=U)=>{v.current||(v.current=new u.current.MouseTool(d.current),v.current.on("draw",function({obj:p}){O(p)}),T(g))}),w=(g,p)=>{d.current&&d.current.setZoomAndCenter(18,g,p)},B=()=>{const g=()=>{te(),k.current&&(k.current.setTarget(),k.current.close()),i==null||i(null)};H.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById(Z.current),onOk(){g()}})},A=()=>{L.current&&d.current.setFitView([L.current])},E=f.useCallback((g=U,p=a,m)=>{const M=be[g];if(!M)return;const N=P(P({},_),m);return"transformOptions"in M?Object.assign(N,M.transformOptions(p)):"propertyKey"in M&&(N[M.propertyKey]=p),new u.current[M.overlay](N)},[_]),G=(g=U,p=a,m)=>{if(!u.current)return;const M=E(g,p,m);return M.setMap(d.current),M};f.useEffect(()=>{if(!u.current||!a||!h&&L.current)return;const g=G();d.current.setFitView([g]),L.current=g,b||(Y(),oe())},[a,z,U,_,b,h]),f.useEffect(()=>{var g,p,m;v.current&&(b?((g=v.current)==null||g.close(),(p=k.current)==null||p.close()):(T(),(m=k.current)==null||m.open()))},[b]),f.useEffect(()=>{!u.current||!U||b||(R(),Y())},[b,z,U]),f.useEffect(()=>{var p,m;if(!a&&(v.current||k.current)&&(te(),k.current&&(k.current.setTarget(),k.current.close()),i==null||i(null)),!v.current||!k.current)return;k.current.getTarget()?(m=(p=v.current).close)==null||m.call(p):T()},[U,a]),f.useEffect(()=>{if(!t||d.current)return;o&&(window._AMapSecurityConfig={[o.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:o});const g=window.define;return window.define=void 0,Qe.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(p=>(window.define=g,requestIdleCallback(()=>{d.current=new p.Map(Z.current,{resizeEnable:!0,zoom:x}),u.current=p,K(""),D([])}))).catch(p=>{typeof p=="string"?p.includes("多个不一致的 key")?K(c("The AccessKey is incorrect, please check it")):K(p):(p==null?void 0:p.type)==="error"&&K("Something went wrong, please refresh the page and try again")}),()=>{var p;(p=d.current)==null||p.destroy(),u.current=null,d.current=null,v.current=null,k.current=null}},[t,U,o]),f.useImperativeHandle(r,()=>({setOverlay:G,getOverlay:E,createMouseTool:R,createEditor:Y,executeMouseTool:T,aMap:u.current,map:d.current,overlay:L.current,mouseTool:()=>v.current,editor:()=>k.current,errMessage:S}));const q=s.useApp();return!t||S?n.jsx(I.Alert,{action:n.jsx(I.Button,{type:"primary",onClick:()=>V(q.pluginSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:S||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):n.jsxs("div",{className:s.css`
8
8
  position: relative;
9
9
  height: 500px;
10
- `,id:Z.current,style:e==null?void 0:e.style,children:[!u.current&&r.jsx("div",{className:s.css`
10
+ `,id:Z.current,style:e==null?void 0:e.style,children:[!u.current&&n.jsx("div",{className:s.css`
11
11
  position: absolute;
12
12
  inset: 0;
13
13
  display: flex;
14
14
  align-items: center;
15
15
  justify-content: center;
16
- `,children:r.jsx(w.Spin,{})}),b?null:r.jsxs(r.Fragment,{children:[r.jsx(Re,{toCenter:S,aMap:u.current}),r.jsx("div",{className:s.css`
16
+ `,children:n.jsx(I.Spin,{})}),b?null:n.jsxs(n.Fragment,{children:[n.jsx($e,{toCenter:w,aMap:u.current}),n.jsx("div",{className:s.css`
17
17
  position: absolute;
18
18
  bottom: 80px;
19
19
  right: 20px;
20
20
  z-index: 10;
21
- `,children:r.jsx(w.Button,{onClick:A,disabled:!L.current,type:"primary",shape:"round",size:"large",icon:r.jsx(te.SyncOutlined,{})})}),K!=="point"?r.jsx("div",{className:s.css`
21
+ `,children:n.jsx(I.Button,{onClick:A,disabled:!L.current,type:"primary",shape:"round",size:"large",icon:n.jsx(ee.SyncOutlined,{})})}),U!=="point"?n.jsx("div",{className:s.css`
22
22
  position: absolute;
23
23
  bottom: 20px;
24
24
  left: 10px;
25
25
  z-index: 2;
26
26
  pointer-events: none;
27
- `,children:r.jsx(w.Alert,{message:c("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,r.jsx("div",{className:s.css`
27
+ `,children:n.jsx(I.Alert,{message:c("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,n.jsx("div",{className:s.css`
28
28
  position: absolute;
29
29
  bottom: 20px;
30
30
  right: 20px;
31
31
  z-index: 2;
32
- `,children:r.jsx(w.Button,{disabled:!a,style:{height:"40px"},onClick:B,type:"primary",danger:!0,children:c("Clear")})})]})]})}),ke=(e,n,t)=>{const o=n==null?void 0:n.reduce((a,i,l)=>l===n.length-1&&(t==="o2m"||t==="m2m")?a==null?void 0:a.map(h=>h[i]).filter(h=>h!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?o:[o]},et=e=>{var O,Y,T,R;const{collectionField:n,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:h}=s.useProps(e),{name:b,getPrimaryKey:x}=s.useCollection(),{getCollectionJoinField:C}=s.useCollectionManager(),c=x(),[y,u]=f.useState(!1),d=f.useRef(),v=(Y=(O=d.current)==null?void 0:O.aMap)==null?void 0:Y.GeometryUtil,[z,D]=f.useState(),[I,U]=f.useState(""),{t:V}=Q(),K=s.useCompile(),{isConnected:L,doFilter:k}=s.useFilterAPI(),[,W]=f.useState(null),Z=f.useRef(I);Z.current=I;const H=(S,B)=>{const A=S.getExtData(),E=typeof B=="undefined"?A.selected:!B;A.selected=!E,"setIcon"in S&&S.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:E?ce:ye})),S.setOptions(P({extData:A},E?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},_=()=>{var S,B,A;d.current&&((S=d.current)==null||S.mouseTool().close(!0),(B=d.current)==null||B.editor().setTarget(null),(A=d.current)==null||A.editor().close())};f.useEffect(()=>{var S,B,A,E;if(I==="selection")return(S=d.current)!=null&&S.editor()?(E=d.current)==null||E.executeMouseTool("polygon"):((B=d.current)==null||B.createEditor("polygon"),(A=d.current)==null||A.createMouseTool("polygon")),()=>{_()}},[I]),f.useEffect(()=>{if(I)return()=>{var S;Z.current||(S=d.current)==null||S.map.getAllOverlays().forEach(B=>{H(B,!1)})}},[I]);const ee=j.useMemoizedFn(()=>{var G,q,g;const S=(G=d.current)==null?void 0:G.editor().getTarget(),B=(q=d.current)==null?void 0:q.map.getAllOverlays(),A=B==null?void 0:B.filter(p=>{if(!(p===S||p.getExtData().id===void 0))return"getPosition"in p?v.isPointInRing(p.getPosition(),S==null?void 0:S.getPath()):v.doesRingRingIntersect(p.getPath(),S==null?void 0:S.getPath())}),E=A==null?void 0:A.map(p=>(H(p,!0),p.getExtData().id));l(p=>E==null?void 0:E.concat(p)),S==null||S.remove(),(g=d.current)==null||g.editor().close()});f.useEffect(()=>{var G,q,g;if(!n||!d.current||!o)return;const S=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,B=C([b,...S].flat().join(".")),A=o.map(p=>{var M;const m=(M=ke(p,t==null?void 0:t.field,B==null?void 0:B.interface))==null?void 0:M.filter(Boolean);return m!=null&&m.length?m.map(N=>{var ne;return(ne=d.current)==null?void 0:ne.setOverlay(n.type,N,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?K(p[t.marker]):void 0},extData:{id:p[c]}})}):[]}).flat().filter(Boolean);(q=(G=d.current)==null?void 0:G.map)==null||q.setFitView(A);const E=A.map(p=>{const m=M=>{const N=M.target,re=N.getExtData();if(!re)return;if(Z.current){Z.current==="click"&&(l(se=>re.selected?se.filter(Ce=>Ce!==re.id):[...se,re.id]),H(N));return}const ne=o.find(se=>re.id===se[c]);if(L){W(se=>(se&&Oe(se),se===p?(Oe(p),k(null),null):(ot(p),k(ne[c],Ce=>Ce.field||c,"$eq"),p)));return}ne&&D(ne)};return p.on("click",m),()=>p.off("click",m)});if(n.type==="point"&&(h!=null&&h.length)&&(A==null?void 0:A.length)>1){const p=A.map(M=>M.getPosition());A[0].setzIndex(13),A[A.length-1].setzIndex(13);const m=(M=!0)=>{var N,re;if((N=d.current)!=null&&N.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:V(M?"Start point":"End point")},position:p[M?0:p.length-1],map:(re=d.current)==null?void 0:re.map})};A.push(...[(g=d.current)==null?void 0:g.setOverlay("lineString",p,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),m(),m(!1)].filter(Boolean))}return()=>{A.forEach(p=>{p.remove()}),E.forEach(p=>p())}},[o,y,t,b,c,n.type,L,h]),f.useEffect(()=>{setTimeout(()=>{l([])})},[o]);const oe=S=>{d.current=S,u(!!(S!=null&&S.map)&&!S.errMessage)};return r.jsxs("div",{className:s.css`
32
+ `,children:n.jsx(I.Button,{disabled:!a,style:{height:"40px"},onClick:B,type:"primary",danger:!0,children:c("Clear")})})]})]})}),ke=(e,r,t)=>{const o=r==null?void 0:r.reduce((a,i,l)=>l===r.length-1&&(t==="o2m"||t==="m2m")?a==null?void 0:a.map(h=>h[i]).filter(h=>h!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?o:[o]},Re=e=>{var O,Y,T,R;const{collectionField:r,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:h}=s.useProps(e),{name:b,getPrimaryKey:x}=s.useCollection(),{getCollectionJoinField:C}=s.useCollectionManager(),c=x(),[y,u]=f.useState(!1),d=f.useRef(),v=(Y=(O=d.current)==null?void 0:O.aMap)==null?void 0:Y.GeometryUtil,[z,D]=f.useState(),[S,K]=f.useState(""),{t:j}=Q(),U=s.useCompile(),{isConnected:L,doFilter:k}=s.useFilterAPI(),[,V]=f.useState(null),Z=f.useRef(S);Z.current=S;const H=(w,B)=>{const A=w.getExtData(),E=typeof B=="undefined"?A.selected:!B;A.selected=!E,"setIcon"in w&&w.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:E?ue:ye})),w.setOptions(P({extData:A},E?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},_=()=>{var w,B,A;d.current&&((w=d.current)==null||w.mouseTool().close(!0),(B=d.current)==null||B.editor().setTarget(null),(A=d.current)==null||A.editor().close())};f.useEffect(()=>{var w,B,A,E;if(S==="selection")return(w=d.current)!=null&&w.editor()?(E=d.current)==null||E.executeMouseTool("polygon"):((B=d.current)==null||B.createEditor("polygon"),(A=d.current)==null||A.createMouseTool("polygon")),()=>{_()}},[S]),f.useEffect(()=>{if(S)return()=>{var w;Z.current||(w=d.current)==null||w.map.getAllOverlays().forEach(B=>{H(B,!1)})}},[S]);const te=W.useMemoizedFn(()=>{var G,q,g;const w=(G=d.current)==null?void 0:G.editor().getTarget(),B=(q=d.current)==null?void 0:q.map.getAllOverlays(),A=B==null?void 0:B.filter(p=>{if(!(p===w||p.getExtData().id===void 0))return"getPosition"in p?v.isPointInRing(p.getPosition(),w==null?void 0:w.getPath()):v.doesRingRingIntersect(p.getPath(),w==null?void 0:w.getPath())}),E=A==null?void 0:A.map(p=>(H(p,!0),p.getExtData().id));l(p=>E==null?void 0:E.concat(p)),w==null||w.remove(),(g=d.current)==null||g.editor().close()});f.useEffect(()=>{var G,q,g;if(!r||!d.current||!o)return;const w=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,B=C([b,...w].flat().join(".")),A=o.map(p=>{var M;const m=(M=ke(p,t==null?void 0:t.field,B==null?void 0:B.interface))==null?void 0:M.filter(Boolean);return m!=null&&m.length?m.map(N=>{var se;return(se=d.current)==null?void 0:se.setOverlay(r.type,N,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?U(p[t.marker]):void 0},extData:{id:p[c]}})}):[]}).flat().filter(Boolean);(q=(G=d.current)==null?void 0:G.map)==null||q.setFitView(A);const E=A.map(p=>{const m=M=>{const N=M.target,re=N.getExtData();if(!re)return;if(Z.current){Z.current==="click"&&(l(ie=>re.selected?ie.filter(Ce=>Ce!==re.id):[...ie,re.id]),H(N));return}const se=o.find(ie=>re.id===ie[c]);if(L){V(ie=>(ie&&Oe(ie),ie===p?(Oe(p),k(null),null):(tt(p),k(se[c],Ce=>Ce.field||c,"$eq"),p)));return}se&&D(se)};return p.on("click",m),()=>p.off("click",m)});if(r.type==="point"&&(h!=null&&h.length)&&(A==null?void 0:A.length)>1){const p=A.map(M=>M.getPosition());A[0].setzIndex(13),A[A.length-1].setzIndex(13);const m=(M=!0)=>{var N,re;if((N=d.current)!=null&&N.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:j(M?"Start point":"End point")},position:p[M?0:p.length-1],map:(re=d.current)==null?void 0:re.map})};A.push(...[(g=d.current)==null?void 0:g.setOverlay("lineString",p,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),m(),m(!1)].filter(Boolean))}return()=>{A.forEach(p=>{p.remove()}),E.forEach(p=>p())}},[o,y,t,b,c,r.type,L,h]),f.useEffect(()=>{setTimeout(()=>{l([])})},[o]);const oe=w=>{d.current=w,u(!!(w!=null&&w.map)&&!w.errMessage)};return n.jsxs("div",{className:s.css`
33
33
  position: relative;
34
34
  height: 100%;
35
- `,children:[r.jsx("div",{className:s.css`
35
+ `,children:[n.jsx("div",{className:s.css`
36
36
  position: absolute;
37
37
  left: 10px;
38
38
  top: 10px;
39
39
  z-index: 999;
40
- `,children:y&&!((T=d.current)!=null&&T.errMessage)?r.jsxs(w.Space,{direction:"vertical",children:[r.jsx(w.Button,{style:{color:I?void 0:"#F18b62",borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),U("")},icon:r.jsx(te.EnvironmentOutlined,{})}),r.jsx(w.Button,{style:{color:I==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),U("selection")},icon:r.jsx(te.ExpandOutlined,{})}),I==="selection"?r.jsx(w.Button,{type:"primary",icon:r.jsx(te.CheckOutlined,{}),title:V("Confirm selection"),onClick:ee}):null]}):null}),r.jsx(tt,{record:z,setVisible:D}),r.jsx(Pe,J(P({},(R=n==null?void 0:n.uiSchema)==null?void 0:R["x-component-props"]),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},tt=e=>{const{setVisible:n,record:t}=e,o=X.useFieldSchema(),a=f.useMemo(()=>o.reduceProperties((i,l)=>l.name==="drawer"?l:i,null),[o]);return a&&r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:n},children:r.jsx(s.RecordProvider,{record:t,children:r.jsx(X.RecursionField,{schema:a,name:a.name})})})};function Oe(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function ot(e){e.dom?e.dom.style.filter="brightness(1.2) contrast(1.2) hue-rotate(180deg)":e.setOptions&&e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const Fe=({type:e,children:n})=>{const{t}=Q(),[o,a]=j.useBoolean(!1),i=s.useAPIClient(),[l]=w.Form.useForm(),h=ve(e);f.useEffect(()=>{h&&(l.setFieldsValue(h),a.toggle())},[h]);const b=f.useMemo(()=>i.resource(Ie),[i]),x=C=>{b.set(J(P({},C),{type:e})).then(c=>{sessionStorage.removeItem(Ae(e)),a.toggle(),w.message.success(t("Saved successfully"))}).catch(c=>{w.message.success(t("Saved failed"))})};return r.jsxs(w.Form,{disabled:o,form:l,layout:"vertical",onFinish:x,children:[n,o?r.jsx(w.Button,{disabled:!1,onClick:a.toggle,children:t("Edit")}):r.jsx(w.Form.Item,{children:r.jsx(w.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},rt={amap:()=>{const{t:e}=Q();return r.jsxs(Fe,{type:"amap",children:[r.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:r.jsx(w.Input,{})}),r.jsx(w.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:r.jsx(w.Input,{})})]})},google:()=>{const{t:e}=Q();return r.jsx(Fe,{type:"google",children:r.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:r.jsx(w.Input,{})})})}},nt=we.map(e=>J(P({},e),{component:rt[e.value]})),st=()=>{const e=s.useCompile(),n=ie.useLocation(),t=new URLSearchParams(n.search);return r.jsx(w.Card,{bordered:!0,children:r.jsx(w.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:nt.map(o=>r.jsx(w.Tabs.TabPane,{tab:e(o.label),children:r.jsx(o.component,{type:o.value})},o.value))})})};/*! *****************************************************************************
40
+ `,children:y&&!((T=d.current)!=null&&T.errMessage)?n.jsxs(I.Space,{direction:"vertical",children:[n.jsx(I.Button,{style:{color:S?void 0:"#F18b62",borderColor:"currentcolor"},onClick:w=>{w.stopPropagation(),K("")},icon:n.jsx(ee.EnvironmentOutlined,{})}),n.jsx(I.Button,{style:{color:S==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:w=>{w.stopPropagation(),K("selection")},icon:n.jsx(ee.ExpandOutlined,{})}),S==="selection"?n.jsx(I.Button,{type:"primary",icon:n.jsx(ee.CheckOutlined,{}),title:j("Confirm selection"),onClick:te}):null]}):null}),n.jsx(et,{record:z,setVisible:D}),n.jsx(Pe,X(P({},(R=r==null?void 0:r.uiSchema)==null?void 0:R["x-component-props"]),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},et=e=>{const{setVisible:r,record:t}=e,o=J.useFieldSchema(),a=f.useMemo(()=>o.reduceProperties((i,l)=>l.name==="drawer"?l:i,null),[o]);return a&&n.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:r},children:n.jsx(s.RecordProvider,{record:t,children:n.jsx(J.RecursionField,{schema:a,name:a.name})})})};function Oe(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function tt(e){e.dom?e.dom.style.filter="brightness(1.2) contrast(1.2) hue-rotate(180deg)":e.setOptions&&e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const Fe=({type:e,children:r})=>{const{t}=Q(),[o,a]=W.useBoolean(!1),i=s.useAPIClient(),[l]=I.Form.useForm(),h=ve(e);f.useEffect(()=>{h&&(l.setFieldsValue(h),a.toggle())},[h]);const b=f.useMemo(()=>i.resource(Ie),[i]),x=C=>{b.set(X(P({},C),{type:e})).then(c=>{sessionStorage.removeItem(Ae(e)),a.toggle(),I.message.success(t("Saved successfully"))}).catch(c=>{I.message.success(t("Saved failed"))})};return n.jsxs(I.Form,{disabled:o,form:l,layout:"vertical",onFinish:x,children:[r,o?n.jsx(I.Button,{disabled:!1,onClick:a.toggle,children:t("Edit")}):n.jsx(I.Form.Item,{children:n.jsx(I.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},ot={amap:()=>{const{t:e}=Q();return n.jsxs(Fe,{type:"amap",children:[n.jsx(I.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:n.jsx(I.Input,{})}),n.jsx(I.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:n.jsx(I.Input,{})})]})},google:()=>{const{t:e}=Q();return n.jsx(Fe,{type:"google",children:n.jsx(I.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:n.jsx(I.Input,{})})})}},rt=we.map(e=>X(P({},e),{component:ot[e.value]})),nt=()=>{const e=s.useCompile(),r=ae.useLocation(),t=new URLSearchParams(r.search);return n.jsx(I.Card,{bordered:!0,children:n.jsx(I.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:rt.map(o=>n.jsx(I.Tabs.TabPane,{tab:e(o.label),children:n.jsx(o.component,{type:o.value})},o.value))})})};/*! *****************************************************************************
41
41
  Copyright (c) Microsoft Corporation.
42
42
 
43
43
  Permission to use, copy, modify, and/or distribute this software for any
@@ -50,62 +50,62 @@
50
50
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
51
51
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
52
52
  PERFORMANCE OF THIS SOFTWARE.
53
- ***************************************************************************** */function it(e,n,t,o){function a(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function h(C){try{x(o.next(C))}catch(c){l(c)}}function b(C){try{x(o.throw(C))}catch(c){l(c)}}function x(C){C.done?i(C.value):a(C.value).then(h,b)}x((o=o.apply(e,n||[])).next())})}var at=function e(n,t){if(n===t)return!0;if(n&&t&&typeof n=="object"&&typeof t=="object"){if(n.constructor!==t.constructor)return!1;var o,a,i;if(Array.isArray(n)){if(o=n.length,o!=t.length)return!1;for(a=o;a--!==0;)if(!e(n[a],t[a]))return!1;return!0}if(n.constructor===RegExp)return n.source===t.source&&n.flags===t.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===t.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===t.toString();if(i=Object.keys(n),o=i.length,o!==Object.keys(t).length)return!1;for(a=o;a--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[a]))return!1;for(a=o;a--!==0;){var l=i[a];if(!e(n[l],t[l]))return!1}return!0}return n!==n&&t!==t};const Ee="__googleMapsScriptId";var ue;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(ue||(ue={}));class ae{constructor({apiKey:n,authReferrerPolicy:t,channel:o,client:a,id:i=Ee,language:l,libraries:h=[],mapIds:b,nonce:x,region:C,retries:c=3,url:y="https://maps.googleapis.com/maps/api/js",version:u}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=n,this.authReferrerPolicy=t,this.channel=o,this.client=a,this.id=i||Ee,this.language=l,this.libraries=h,this.mapIds=b,this.nonce=x,this.region=C,this.retries=c,this.url=y,this.version=u,ae.instance){if(!at(this.options,ae.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ae.instance.options)}`);return ae.instance}ae.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?ue.FAILURE:this.done?ue.SUCCESS:this.loading?ue.LOADING:ue.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let n=this.url;return n+="?callback=__googleMapsCallback",this.apiKey&&(n+=`&key=${this.apiKey}`),this.channel&&(n+=`&channel=${this.channel}`),this.client&&(n+=`&client=${this.client}`),this.libraries.length>0&&(n+=`&libraries=${this.libraries.join(",")}`),this.language&&(n+=`&language=${this.language}`),this.region&&(n+=`&region=${this.region}`),this.version&&(n+=`&v=${this.version}`),this.mapIds&&(n+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(n+=`&auth_referrer_policy=${this.authReferrerPolicy}`),n}deleteScript(){const n=document.getElementById(this.id);n&&n.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((n,t)=>{this.loadCallback(o=>{o?t(o.error):n(window.google)})})}importLibrary(n){return this.execute(),google.maps.importLibrary(n)}loadCallback(n){this.callbacks.push(n),this.execute()}setScript(){var n,t;if(document.getElementById(this.id)){this.callback();return}const o={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(o).forEach(i=>!o[i]&&delete o[i]),!((t=(n=window==null?void 0:window.google)===null||n===void 0?void 0:n.maps)===null||t===void 0)&&t.importLibrary||(i=>{let l,h,b,x="The Google Maps JavaScript API",C="google",c="importLibrary",y="__ib__",u=document,d=window;d=d[C]||(d[C]={});const v=d.maps||(d.maps={}),z=new Set,D=new URLSearchParams,I=()=>l||(l=new Promise((U,V)=>it(this,void 0,void 0,function*(){var K;yield h=u.createElement("script"),h.id=this.id,D.set("libraries",[...z]+"");for(b in i)D.set(b.replace(/[A-Z]/g,L=>"_"+L[0].toLowerCase()),i[b]);D.set("callback",C+".maps."+y),h.src=this.url+"?"+D,v[y]=U,h.onerror=()=>l=V(Error(x+" could not load.")),h.nonce=this.nonce||((K=u.querySelector("script[nonce]"))===null||K===void 0?void 0:K.nonce)||"",u.head.append(h)})));v[c]?console.warn(x+" only loads once. Ignoring:",i):v[c]=(U,...V)=>z.add(U)&&I().then(()=>v[c](U,...V))})(o);const a=this.libraries.map(i=>this.importLibrary(i));a.length||a.push(this.importLibrary("core")),Promise.all(a).then(()=>this.callback(),i=>{const l=new ErrorEvent("error",{error:i});this.loadErrorCallback(l)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(n){if(this.errors.push(n),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=n,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(n=>{n(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading||(this.loading=!0,this.setScript())}}}const lt=e=>{const{toCenter:n,mapRef:t}=e,{t:o}=Q(),a=f.useRef(),[i,l]=f.useState([]);f.useEffect(()=>{google.maps.importLibrary("places").then(x=>{a.current=new x.AutocompleteService}).catch(()=>{w.message.error("Please configure the Google API Key correctly")})},[t]);const{run:h}=j.useDebounceFn(x=>{a.current&&a.current.getPlacePredictions({input:x||" "},(C,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)l(C.map(y=>{const u=y.structured_formatting;return J(P({},y),{label:`${u.main_text}${u.secondary_text?" "+u.secondary_text:""}`,value:y.place_id})}));else{l([]);return}})},{wait:300}),b=x=>{const C=i.find(y=>y.value===x);new google.maps.places.PlacesService(t.current).getDetails({placeId:C.place_id,fields:["geometry"]},(y,u)=>{u===google.maps.places.PlacesServiceStatus.OK&&n(y.geometry.location)})};return r.jsx("div",{className:s.css`
53
+ ***************************************************************************** */function st(e,r,t,o){function a(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function h(C){try{x(o.next(C))}catch(c){l(c)}}function b(C){try{x(o.throw(C))}catch(c){l(c)}}function x(C){C.done?i(C.value):a(C.value).then(h,b)}x((o=o.apply(e,r||[])).next())})}var it=function e(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){if(r.constructor!==t.constructor)return!1;var o,a,i;if(Array.isArray(r)){if(o=r.length,o!=t.length)return!1;for(a=o;a--!==0;)if(!e(r[a],t[a]))return!1;return!0}if(r.constructor===RegExp)return r.source===t.source&&r.flags===t.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===t.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===t.toString();if(i=Object.keys(r),o=i.length,o!==Object.keys(t).length)return!1;for(a=o;a--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[a]))return!1;for(a=o;a--!==0;){var l=i[a];if(!e(r[l],t[l]))return!1}return!0}return r!==r&&t!==t};const Ee="__googleMapsScriptId";var pe;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(pe||(pe={}));class le{constructor({apiKey:r,authReferrerPolicy:t,channel:o,client:a,id:i=Ee,language:l,libraries:h=[],mapIds:b,nonce:x,region:C,retries:c=3,url:y="https://maps.googleapis.com/maps/api/js",version:u}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=r,this.authReferrerPolicy=t,this.channel=o,this.client=a,this.id=i||Ee,this.language=l,this.libraries=h,this.mapIds=b,this.nonce=x,this.region=C,this.retries=c,this.url=y,this.version=u,le.instance){if(!it(this.options,le.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(le.instance.options)}`);return le.instance}le.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?pe.FAILURE:this.done?pe.SUCCESS:this.loading?pe.LOADING:pe.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let r=this.url;return r+="?callback=__googleMapsCallback",this.apiKey&&(r+=`&key=${this.apiKey}`),this.channel&&(r+=`&channel=${this.channel}`),this.client&&(r+=`&client=${this.client}`),this.libraries.length>0&&(r+=`&libraries=${this.libraries.join(",")}`),this.language&&(r+=`&language=${this.language}`),this.region&&(r+=`&region=${this.region}`),this.version&&(r+=`&v=${this.version}`),this.mapIds&&(r+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(r+=`&auth_referrer_policy=${this.authReferrerPolicy}`),r}deleteScript(){const r=document.getElementById(this.id);r&&r.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((r,t)=>{this.loadCallback(o=>{o?t(o.error):r(window.google)})})}importLibrary(r){return this.execute(),google.maps.importLibrary(r)}loadCallback(r){this.callbacks.push(r),this.execute()}setScript(){var r,t;if(document.getElementById(this.id)){this.callback();return}const o={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(o).forEach(i=>!o[i]&&delete o[i]),!((t=(r=window==null?void 0:window.google)===null||r===void 0?void 0:r.maps)===null||t===void 0)&&t.importLibrary||(i=>{let l,h,b,x="The Google Maps JavaScript API",C="google",c="importLibrary",y="__ib__",u=document,d=window;d=d[C]||(d[C]={});const v=d.maps||(d.maps={}),z=new Set,D=new URLSearchParams,S=()=>l||(l=new Promise((K,j)=>st(this,void 0,void 0,function*(){var U;yield h=u.createElement("script"),h.id=this.id,D.set("libraries",[...z]+"");for(b in i)D.set(b.replace(/[A-Z]/g,L=>"_"+L[0].toLowerCase()),i[b]);D.set("callback",C+".maps."+y),h.src=this.url+"?"+D,v[y]=K,h.onerror=()=>l=j(Error(x+" could not load.")),h.nonce=this.nonce||((U=u.querySelector("script[nonce]"))===null||U===void 0?void 0:U.nonce)||"",u.head.append(h)})));v[c]?console.warn(x+" only loads once. Ignoring:",i):v[c]=(K,...j)=>z.add(K)&&S().then(()=>v[c](K,...j))})(o);const a=this.libraries.map(i=>this.importLibrary(i));a.length||a.push(this.importLibrary("core")),Promise.all(a).then(()=>this.callback(),i=>{const l=new ErrorEvent("error",{error:i});this.loadErrorCallback(l)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(r){if(this.errors.push(r),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=r,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(r=>{r(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading||(this.loading=!0,this.setScript())}}}const at=e=>{const{toCenter:r,mapRef:t}=e,{t:o}=Q(),a=f.useRef(),[i,l]=f.useState([]);f.useEffect(()=>{google.maps.importLibrary("places").then(x=>{a.current=new x.AutocompleteService}).catch(()=>{I.message.error("Please configure the Google API Key correctly")})},[t]);const{run:h}=W.useDebounceFn(x=>{a.current&&a.current.getPlacePredictions({input:x||" "},(C,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)l(C.map(y=>{const u=y.structured_formatting;return X(P({},y),{label:`${u.main_text}${u.secondary_text?" "+u.secondary_text:""}`,value:y.place_id})}));else{l([]);return}})},{wait:300}),b=x=>{const C=i.find(y=>y.value===x);new google.maps.places.PlacesService(t.current).getDetails({placeId:C.place_id,fields:["geometry"]},(y,u)=>{u===google.maps.places.PlacesServiceStatus.OK&&r(y.geometry.location)})};return n.jsx("div",{className:s.css`
54
54
  position: absolute;
55
55
  top: 10px;
56
56
  left: 10px;
57
57
  z-index: 10;
58
58
  width: calc(100% - 20px);
59
- `,children:r.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:o("Enter keywords to search"),filterOption:!1,onSearch:h,onSelect:b,options:i})})},le=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,32+10)}),ct=()=>new Promise(e=>{const n=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:o,longitude:a}=t.coords;e({lat:o,lng:a})},()=>{n()}):n()}),ut=e=>e==="point"?"marker":e==="lineString"?"polyline":e,pt={point:{propertyKey:"position",overlay:"Marker"},polygon:{propertyKey:"paths",overlay:"Polygon"},lineString:{propertyKey:"path",overlay:"Polyline"},circle:{transformOptions(e){return{center:new google.maps.LatLng(e[1],e[0]),radius:e[2]}},overlay:"Circle"}},ze=f.forwardRef((e,n)=>{const{value:t,onChange:o,block:a=!1,readonly:i,disabled:l=a,zoom:h=13,overlayCommonOptions:b}=e,{accessKey:x}=ve(e.mapType)||{},{t:C}=Q(),{getField:c}=s.useCollection(),y=X.useFieldSchema(),u=f.useRef(),d=f.useRef(),v=f.useRef(),[z,D]=f.useState([]),[I,U]=f.useState(""),V=s.useAPIClient(),{modal:K}=w.App.useApp(),L=f.useMemo(()=>{if(e.type)return e.type;const g=c(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),k=f.useRef(ut(L)),[W]=f.useState(P({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},b)),Z=ie.useNavigate(),H=f.useRef(),_=f.useRef(new Set),ee=j.useMemoizedFn(g=>{if(_.current.forEach(p=>{_.current.delete(p)}),"getPath"in g){const p=g.getPath();["insert_at","remove_at","set_at"].forEach(m=>{_.current.add(p.addListener(m,()=>{S(g,!0)}).remove)})}else g instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(p=>{_.current.add(g.addListener(p,()=>{S(g,!0)}).remove)})}),oe=j.useMemoizedFn(()=>{var g;v.current&&(v.current.unbindAll(),v.current.setMap(null)),L!=="point"&&((g=u.current)==null||g.setDrawingMode(null))}),O=j.useMemoizedFn(g=>{d.current&&(d.current.setCenter(g),d.current.setZoom(h))}),Y=j.useMemoizedFn(g=>{oe(),ee(g),v.current=g}),T=j.useMemoizedFn(g=>{const p=new google.maps.LatLngBounds;g.forEach(m=>{if(m instanceof google.maps.Marker)p.extend(m.getPosition());else if(m instanceof google.maps.Polyline||m instanceof google.maps.Polygon){const M=m.getPath();for(let N=0;N<M.getLength();N++)p.extend(M.getAt(N))}else m instanceof google.maps.Circle&&p.union(m.getBounds())}),d.current.setCenter(p.getCenter())}),R=()=>{v.current&&T([v.current])},S=j.useMemoizedFn((g,p=!1)=>{let m=null;if(L==="point"){const{lat:M,lng:N}=g.getPosition();m=[N(),M()]}else if(L==="polygon"||L==="lineString"){if(m=g.getPath().getArray().map(M=>[M.lng(),M.lat()]),m.length<2)return}else if(L==="circle"){const M=g.getCenter(),N=g.getRadius();m=[M.lng(),M.lat(),N]}p||Y(g),o==null||o(m)}),B=j.useMemoizedFn((g=!1,p)=>{const m=J(P(P({},W),p),{map:d.current});return u.current=new google.maps.drawing.DrawingManager({drawingMode:k.current,drawingControl:!1,markerOptions:J(P({},m),{icon:le(ce)}),polygonOptions:m,polylineOptions:m,circleOptions:m,map:d.current}),g||u.current.addListener("overlaycomplete",M=>{const N=M.overlay;S(N)}),u.current}),A=j.useMemoizedFn((g=L,p=t,m)=>{const M=pt[g];if(!M)return;const N=P(J(P({},W),{icon:le(ce)}),m);return"transformOptions"in M?Object.assign(N,M.transformOptions(p)):"propertyKey"in M&&(N[M.propertyKey]=Array.isArray(p[0])?p.map(ne=>new google.maps.LatLng(ne[1],ne[0])):new google.maps.LatLng(p[1],p[0])),new google.maps[M.overlay](N)}),E=j.useMemoizedFn((g=L,p=t,m)=>d.current?A(g,p,J(P({},m),{map:d.current})):void 0);f.useEffect(()=>{var p,m;if(!t&&d.current&&(oe(),(m=(p=u==null?void 0:u.current)==null?void 0:p.setDrawingMode)==null||m.call(p,k.current),o==null||o(null)),!d.current||!t||!i&&v.current)return;const g=E();Y(g),T([g])},[t,z,L,l,i,E,T,Y]),f.useEffect(()=>{if(!x||d.current||!H.current)return;let g;try{g=new ae({apiKey:x,version:"weekly",language:V.auth.getLocale()})}catch(m){U(C("Load google maps failed, Please check the Api key and refresh the page"));return}const p=console.error;return console.error=(m,...M)=>{m!=null&&m.includes("InvalidKeyMapError")&&U(C("Load google maps failed, Please check the Api key and refresh the page")),p(m,...M)},Promise.all([g.importLibrary("drawing"),g.importLibrary("core"),g.importLibrary("geometry")]).then(m=>he(this,null,function*(){const M=yield ct();d.current=new google.maps.Map(H.current,{zoom:h,center:M,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),U(""),D([])})).catch(m=>{if(m instanceof Error){U(m.message);return}}),()=>{var m,M;(m=d.current)==null||m.unbindAll(),d.current=null,(M=u.current)==null||M.unbindAll()}},[x,V.auth,L,h]),f.useEffect(()=>{!d.current||!L||l||u.current||B()},[B,l,z,L]),f.useImperativeHandle(n,()=>({setOverlay:E,getOverlay:A,setFitView:T,createDraw:B,map:d.current,overlay:v.current,drawingManager:u.current,errMessage:I}));const G=j.useMemoizedFn(()=>{const g=()=>{oe(),u.current.setDrawingMode(k.current),o==null||o(null)};K.confirm({title:C("Clear the canvas"),content:C("Are you sure to clear the canvas?"),okText:C("Confirm"),cancelText:C("Cancel"),getContainer:()=>H.current,onOk(){g()}})}),q=s.useApp();return!x||I?r.jsx(w.Alert,{action:r.jsx(w.Button,{type:"primary",onClick:()=>Z(q.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:C("Go to the configuration page")}),message:I||C("Please configure the Api key first"),type:"error"}):r.jsxs("div",{className:s.css`
59
+ `,children:n.jsx(I.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:o("Enter keywords to search"),filterOption:!1,onSearch:h,onSelect:b,options:i})})},ce=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,32+10)}),lt=()=>new Promise(e=>{const r=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:o,longitude:a}=t.coords;e({lat:o,lng:a})},()=>{r()}):r()}),ct=e=>e==="point"?"marker":e==="lineString"?"polyline":e,ut={point:{propertyKey:"position",overlay:"Marker"},polygon:{propertyKey:"paths",overlay:"Polygon"},lineString:{propertyKey:"path",overlay:"Polyline"},circle:{transformOptions(e){return{center:new google.maps.LatLng(e[1],e[0]),radius:e[2]}},overlay:"Circle"}},ze=f.forwardRef((e,r)=>{const{value:t,onChange:o,block:a=!1,readonly:i,disabled:l=a,zoom:h=13,overlayCommonOptions:b}=e,{accessKey:x}=ve(e.mapType)||{},{t:C}=Q(),{getField:c}=s.useCollection(),y=J.useFieldSchema(),u=f.useRef(),d=f.useRef(),v=f.useRef(),[z,D]=f.useState([]),[S,K]=f.useState(""),j=s.useAPIClient(),{modal:U}=I.App.useApp(),L=f.useMemo(()=>{if(e.type)return e.type;const g=c(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),k=f.useRef(ct(L)),[V]=f.useState(P({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},b)),Z=ae.useNavigate(),H=f.useRef(),_=f.useRef(new Set),te=W.useMemoizedFn(g=>{if(_.current.forEach(p=>{_.current.delete(p)}),"getPath"in g){const p=g.getPath();["insert_at","remove_at","set_at"].forEach(m=>{_.current.add(p.addListener(m,()=>{w(g,!0)}).remove)})}else g instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(p=>{_.current.add(g.addListener(p,()=>{w(g,!0)}).remove)})}),oe=W.useMemoizedFn(()=>{var g;v.current&&(v.current.unbindAll(),v.current.setMap(null)),L!=="point"&&((g=u.current)==null||g.setDrawingMode(null))}),O=W.useMemoizedFn(g=>{d.current&&(d.current.setCenter(g),d.current.setZoom(h))}),Y=W.useMemoizedFn(g=>{oe(),te(g),v.current=g}),T=W.useMemoizedFn(g=>{const p=new google.maps.LatLngBounds;g.forEach(m=>{if(m instanceof google.maps.Marker)p.extend(m.getPosition());else if(m instanceof google.maps.Polyline||m instanceof google.maps.Polygon){const M=m.getPath();for(let N=0;N<M.getLength();N++)p.extend(M.getAt(N))}else m instanceof google.maps.Circle&&p.union(m.getBounds())}),d.current.setCenter(p.getCenter())}),R=()=>{v.current&&T([v.current])},w=W.useMemoizedFn((g,p=!1)=>{let m=null;if(L==="point"){const{lat:M,lng:N}=g.getPosition();m=[N(),M()]}else if(L==="polygon"||L==="lineString"){if(m=g.getPath().getArray().map(M=>[M.lng(),M.lat()]),m.length<2)return}else if(L==="circle"){const M=g.getCenter(),N=g.getRadius();m=[M.lng(),M.lat(),N]}p||Y(g),o==null||o(m)}),B=W.useMemoizedFn((g=!1,p)=>{const m=X(P(P({},V),p),{map:d.current});return u.current=new google.maps.drawing.DrawingManager({drawingMode:k.current,drawingControl:!1,markerOptions:X(P({},m),{icon:ce(ue)}),polygonOptions:m,polylineOptions:m,circleOptions:m,map:d.current}),g||u.current.addListener("overlaycomplete",M=>{const N=M.overlay;w(N)}),u.current}),A=W.useMemoizedFn((g=L,p=t,m)=>{const M=ut[g];if(!M)return;const N=P(X(P({},V),{icon:ce(ue)}),m);return"transformOptions"in M?Object.assign(N,M.transformOptions(p)):"propertyKey"in M&&(N[M.propertyKey]=Array.isArray(p[0])?p.map(se=>new google.maps.LatLng(se[1],se[0])):new google.maps.LatLng(p[1],p[0])),new google.maps[M.overlay](N)}),E=W.useMemoizedFn((g=L,p=t,m)=>d.current?A(g,p,X(P({},m),{map:d.current})):void 0);f.useEffect(()=>{var p,m;if(!t&&d.current&&(oe(),(m=(p=u==null?void 0:u.current)==null?void 0:p.setDrawingMode)==null||m.call(p,k.current),o==null||o(null)),!d.current||!t||!i&&v.current)return;const g=E();Y(g),T([g])},[t,z,L,l,i,E,T,Y]),f.useEffect(()=>{if(!x||d.current||!H.current)return;let g;try{g=new le({apiKey:x,version:"weekly",language:j.auth.getLocale()})}catch(m){K(C("Load google maps failed, Please check the Api key and refresh the page"));return}const p=console.error;return console.error=(m,...M)=>{m!=null&&m.includes("InvalidKeyMapError")&&K(C("Load google maps failed, Please check the Api key and refresh the page")),p(m,...M)},Promise.all([g.importLibrary("drawing"),g.importLibrary("core"),g.importLibrary("geometry")]).then(m=>he(this,null,function*(){const M=yield lt();d.current=new google.maps.Map(H.current,{zoom:h,center:M,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),K(""),D([])})).catch(m=>{if(m instanceof Error){K(m.message);return}}),()=>{var m,M;(m=d.current)==null||m.unbindAll(),d.current=null,(M=u.current)==null||M.unbindAll()}},[x,j.auth,L,h]),f.useEffect(()=>{!d.current||!L||l||u.current||B()},[B,l,z,L]),f.useImperativeHandle(r,()=>({setOverlay:E,getOverlay:A,setFitView:T,createDraw:B,map:d.current,overlay:v.current,drawingManager:u.current,errMessage:S}));const G=W.useMemoizedFn(()=>{const g=()=>{oe(),u.current.setDrawingMode(k.current),o==null||o(null)};U.confirm({title:C("Clear the canvas"),content:C("Are you sure to clear the canvas?"),okText:C("Confirm"),cancelText:C("Cancel"),getContainer:()=>H.current,onOk(){g()}})}),q=s.useApp();return!x||S?n.jsx(I.Alert,{action:n.jsx(I.Button,{type:"primary",onClick:()=>Z(q.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:C("Go to the configuration page")}),message:S||C("Please configure the Api key first"),type:"error"}):n.jsxs("div",{className:s.css`
60
60
  position: relative;
61
61
  height: 500px;
62
- `,children:[!d.current&&r.jsx("div",{className:s.css`
62
+ `,children:[!d.current&&n.jsx("div",{className:s.css`
63
63
  position: absolute;
64
64
  inset: 0;
65
65
  display: flex;
66
66
  align-items: center;
67
67
  justify-content: center;
68
- `,children:r.jsx(w.Spin,{})}),l?null:r.jsxs(r.Fragment,{children:[d.current&&r.jsx(lt,{toCenter:O,mapRef:d}),r.jsx("div",{className:s.css`
68
+ `,children:n.jsx(I.Spin,{})}),l?null:n.jsxs(n.Fragment,{children:[d.current&&n.jsx(at,{toCenter:O,mapRef:d}),n.jsx("div",{className:s.css`
69
69
  position: absolute;
70
70
  bottom: 80px;
71
71
  right: 20px;
72
72
  z-index: 10;
73
- `,children:r.jsx(w.Button,{onClick:R,disabled:!v.current,type:"primary",shape:"round",size:"large",icon:r.jsx(te.SyncOutlined,{})})}),L==="lineString"||L==="polygon"?r.jsx("div",{className:s.css`
73
+ `,children:n.jsx(I.Button,{onClick:R,disabled:!v.current,type:"primary",shape:"round",size:"large",icon:n.jsx(ee.SyncOutlined,{})})}),L==="lineString"||L==="polygon"?n.jsx("div",{className:s.css`
74
74
  position: absolute;
75
75
  bottom: 20px;
76
76
  left: 10px;
77
77
  z-index: 2;
78
78
  pointer-events: none;
79
- `,children:r.jsx(w.Alert,{message:C("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,r.jsx("div",{className:s.css`
79
+ `,children:n.jsx(I.Alert,{message:C("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,n.jsx("div",{className:s.css`
80
80
  position: absolute;
81
81
  bottom: 20px;
82
82
  right: 20px;
83
83
  z-index: 2;
84
- `,children:r.jsx(w.Button,{disabled:!t,style:{height:"40px"},onClick:G,type:"primary",danger:!0,children:C("Clear")})})]}),r.jsx("div",{ref:H,className:s.css`
84
+ `,children:n.jsx(I.Button,{disabled:!t,style:{height:"40px"},onClick:G,type:"primary",danger:!0,children:C("Clear")})})]}),n.jsx("div",{ref:H,className:s.css`
85
85
  width: 100%;
86
86
  height: 100%;
87
- `,style:e==null?void 0:e.style})]})}),fe="google-maps-overlay-id",Le="google-maps-overlay-selected",dt=s.css`
87
+ `,style:e==null?void 0:e.style})]})}),fe="google-maps-overlay-id",Le="google-maps-overlay-selected",pt=s.css`
88
88
  margin-top: 6px;
89
89
  padding: 2px 4px;
90
90
  background: #fff;
91
91
  border: 1px solid #0000f5;
92
- `,ft=s.css`
92
+ `,dt=s.css`
93
93
  margin-top: -64px;
94
94
  padding: 2px 4px;
95
95
  background: #fff;
96
96
  border: 1px solid #0000f5;
97
- `,gt=e=>{const{collectionField:n,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:h}=s.useProps(e),{getPrimaryKey:b}=s.useCollection(),x=b(),{marker:C="id"}=t,[c,y]=f.useState(!1),u=f.useRef(),[d,v]=f.useState(),[z,D]=f.useState(""),{t:I}=Q(),U=s.useCompile(),{isConnected:V,doFilter:K}=s.useFilterAPI(),[,L]=f.useState(null),k=f.useRef(z),W=f.useRef(null),Z=f.useRef([]);k.current=z;const{getCollectionJoinField:H}=s.useCollectionManager(),_=(O,Y)=>{const T=typeof Y!="undefined"?!Y:O.get(Le);O.set(Le,!T),O.setOptions(P({},T?{icon:le(ce),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:le(ye),strokeColor:"#F18b62",fillColor:"#F18b62"}))};f.useEffect(()=>{var Y,T,R,S;if(z!=="selection")return;u.current&&!((Y=u.current)!=null&&Y.drawingManager)&&(u.current.drawingManager=(T=u.current)==null?void 0:T.createDraw(!0,{editable:!0,draggable:!0}));const O=new Set;return(R=u.current)==null||R.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(S=u.current)==null||S.drawingManager.addListener("overlaycomplete",B=>{var G;const A=B.overlay;(G=u.current)==null||G.drawingManager.setDrawingMode(null),W.current=A;const E=A.getPath();["insert_at","remove_at","set_at"].forEach(q=>{O.add(E.addListener(q,()=>{}).remove)})}),()=>{var B,A,E,G;O.forEach(q=>{q()}),u.current&&((B=W.current)==null||B.unbindAll(),(A=W.current)==null||A.setMap(null),W.current=null,(E=u.current)==null||E.drawingManager.setDrawingMode(null),(G=u.current)==null||G.drawingManager.unbindAll())}},[z]),f.useEffect(()=>{if(z)return()=>{k.current||Z.current.forEach(O=>{_(O,!1)})}},[z]);const ee=j.useMemoizedFn(()=>{var B;const O=W.current,Y=Z.current,T=google.maps.geometry.poly,S=Y.filter(A=>{if(!(A===O||A.get(fe)===void 0))return A instanceof google.maps.Marker?T.containsLocation(A.getPosition(),O):A instanceof google.maps.Circle?T.containsLocation(A.getCenter(),O):A.getPath().getArray().some(E=>T.containsLocation(E,O))}).map(A=>(_(A,!0),A.get(fe)));l(A=>S.concat(A)),O==null||O.unbindAll(),O==null||O.setMap(null),(B=u.current)==null||B.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});f.useEffect(()=>{var S,B;if(!n||!(o!=null&&o.length)||!((S=u.current)!=null&&S.map))return;const O=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,Y=H([name,...O].flat().join(".")),T=o.map(A=>{const E=ke(A,t==null?void 0:t.field,Y==null?void 0:Y.interface);return E!=null&&E.length?E==null?void 0:E.filter(Boolean).map(G=>{var g;if(!E)return;const q=(g=u.current)==null?void 0:g.setOverlay(n.type,G,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:dt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?U(A[C]):void 0}});return q==null||q.set(fe,A[x]),q}):[]}).flat().filter(Boolean);Z.current=T;const R=T.map(A=>{const E=G=>{const q=A,g=q.get(fe);if(!g)return;const p=o==null?void 0:o.find(m=>g===m[x]);if(V){L(m=>(m&&Te(q),m===A?(Te(q),K(null),null):(ht(q),K(p[x],M=>M.field||x,"$eq"),q)));return}p&&v(p)};return A.addListener("click",E),()=>A.unbindAll()});if(n.type==="point"&&(h!=null&&h.length)&&(T==null?void 0:T.length)>1){const A=T.map(G=>G.getPosition());T[0].setZIndex(138),T[T.length-1].setZIndex(138);const E=(G=!0)=>{var q;if((q=u.current)!=null&&q.map)return new google.maps.Marker({label:{className:ft,fontFamily:"inherit",fontSize:"13px",color:"#333",text:I(G?"Start point":"End point")},icon:le(ce),position:G?A[0]:A[A.length-1],map:u.current.map})};T.push(...[u.current.setOverlay("lineString",A.map(G=>[G.lng(),G.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),E(),E(!1)].filter(Boolean))}return(B=u.current)==null||B.setFitView(T),()=>{T.forEach(A=>{A.setMap(null),A.unbindAll()}),R.forEach(A=>A())}},[o,c,C,n.type,V]),f.useEffect(()=>{setTimeout(()=>{l([])})},[o]);const oe=O=>{u.current=O,y(!!(O!=null&&O.map)&&!O.errMessage)};return r.jsxs("div",{className:s.css`
97
+ `,ft=e=>{const{collectionField:r,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:h}=s.useProps(e),{getPrimaryKey:b}=s.useCollection(),x=b(),{marker:C="id"}=t,[c,y]=f.useState(!1),u=f.useRef(),[d,v]=f.useState(),[z,D]=f.useState(""),{t:S}=Q(),K=s.useCompile(),{isConnected:j,doFilter:U}=s.useFilterAPI(),[,L]=f.useState(null),k=f.useRef(z),V=f.useRef(null),Z=f.useRef([]);k.current=z;const{getCollectionJoinField:H}=s.useCollectionManager(),_=(O,Y)=>{const T=typeof Y!="undefined"?!Y:O.get(Le);O.set(Le,!T),O.setOptions(P({},T?{icon:ce(ue),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:ce(ye),strokeColor:"#F18b62",fillColor:"#F18b62"}))};f.useEffect(()=>{var Y,T,R,w;if(z!=="selection")return;u.current&&!((Y=u.current)!=null&&Y.drawingManager)&&(u.current.drawingManager=(T=u.current)==null?void 0:T.createDraw(!0,{editable:!0,draggable:!0}));const O=new Set;return(R=u.current)==null||R.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(w=u.current)==null||w.drawingManager.addListener("overlaycomplete",B=>{var G;const A=B.overlay;(G=u.current)==null||G.drawingManager.setDrawingMode(null),V.current=A;const E=A.getPath();["insert_at","remove_at","set_at"].forEach(q=>{O.add(E.addListener(q,()=>{}).remove)})}),()=>{var B,A,E,G;O.forEach(q=>{q()}),u.current&&((B=V.current)==null||B.unbindAll(),(A=V.current)==null||A.setMap(null),V.current=null,(E=u.current)==null||E.drawingManager.setDrawingMode(null),(G=u.current)==null||G.drawingManager.unbindAll())}},[z]),f.useEffect(()=>{if(z)return()=>{k.current||Z.current.forEach(O=>{_(O,!1)})}},[z]);const te=W.useMemoizedFn(()=>{var B;const O=V.current,Y=Z.current,T=google.maps.geometry.poly,w=Y.filter(A=>{if(!(A===O||A.get(fe)===void 0))return A instanceof google.maps.Marker?T.containsLocation(A.getPosition(),O):A instanceof google.maps.Circle?T.containsLocation(A.getCenter(),O):A.getPath().getArray().some(E=>T.containsLocation(E,O))}).map(A=>(_(A,!0),A.get(fe)));l(A=>w.concat(A)),O==null||O.unbindAll(),O==null||O.setMap(null),(B=u.current)==null||B.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});f.useEffect(()=>{var w,B;if(!r||!(o!=null&&o.length)||!((w=u.current)!=null&&w.map))return;const O=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,Y=H([name,...O].flat().join(".")),T=o.map(A=>{const E=ke(A,t==null?void 0:t.field,Y==null?void 0:Y.interface);return E!=null&&E.length?E==null?void 0:E.filter(Boolean).map(G=>{var g;if(!E)return;const q=(g=u.current)==null?void 0:g.setOverlay(r.type,G,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:pt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?K(A[C]):void 0}});return q==null||q.set(fe,A[x]),q}):[]}).flat().filter(Boolean);Z.current=T;const R=T.map(A=>{const E=G=>{const q=A,g=q.get(fe);if(!g)return;const p=o==null?void 0:o.find(m=>g===m[x]);if(j){L(m=>(m&&Te(q),m===A?(Te(q),U(null),null):(mt(q),U(p[x],M=>M.field||x,"$eq"),q)));return}p&&v(p)};return A.addListener("click",E),()=>A.unbindAll()});if(r.type==="point"&&(h!=null&&h.length)&&(T==null?void 0:T.length)>1){const A=T.map(G=>G.getPosition());T[0].setZIndex(138),T[T.length-1].setZIndex(138);const E=(G=!0)=>{var q;if((q=u.current)!=null&&q.map)return new google.maps.Marker({label:{className:dt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:S(G?"Start point":"End point")},icon:ce(ue),position:G?A[0]:A[A.length-1],map:u.current.map})};T.push(...[u.current.setOverlay("lineString",A.map(G=>[G.lng(),G.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),E(),E(!1)].filter(Boolean))}return(B=u.current)==null||B.setFitView(T),()=>{T.forEach(A=>{A.setMap(null),A.unbindAll()}),R.forEach(A=>A())}},[o,c,C,r.type,j]),f.useEffect(()=>{setTimeout(()=>{l([])})},[o]);const oe=O=>{u.current=O,y(!!(O!=null&&O.map)&&!O.errMessage)};return n.jsxs("div",{className:s.css`
98
98
  position: relative;
99
99
  height: 100%;
100
- `,children:[c&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:s.css`
100
+ `,children:[c&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:s.css`
101
101
  position: absolute;
102
102
  left: 10px;
103
103
  top: 10px;
104
104
  z-index: 999;
105
- `,children:r.jsxs(w.Space,{direction:"vertical",children:[r.jsx(w.Button,{style:{color:z?void 0:"#F18b62",borderColor:"currentcolor"},onClick:O=>{O.stopPropagation(),D("")},icon:r.jsx(te.EnvironmentOutlined,{})}),r.jsx(w.Button,{style:{color:z==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:O=>{O.stopPropagation(),D("selection")},icon:r.jsx(te.ExpandOutlined,{})}),z==="selection"?r.jsx(w.Button,{type:"primary",icon:r.jsx(te.CheckOutlined,{}),title:I("Confirm selection"),onClick:ee}):null]})}),r.jsx(mt,{record:d,setVisible:v})]}),r.jsx(ze,J(P({},e),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},mt=e=>{const{setVisible:n,record:t}=e,o=X.useFieldSchema(),a=f.useMemo(()=>o.reduceProperties((i,l)=>l.name==="drawer"?l:i,null),[o]);return a&&r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:n},children:r.jsx(s.RecordProvider,{record:t,children:r.jsx(X.RecursionField,{schema:a,name:a.name})})})};function Te(e){if(e instanceof google.maps.Marker)return e.setIcon(le(ce));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function ht(e){if(e instanceof google.maps.Marker)return e.setIcon(le(ye));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const yt=()=>{var c;const{getCollectionJoinField:e}=s.useCollectionManager(),{getField:n}=s.useCollection(),{form:t}=s.useFormBlockContext(),o=X.useField(),a=X.useFieldSchema(),{t:i}=Q(),{dn:l,refresh:h}=s.useDesignable(),b=n(a.name)||e(a["x-collection-field"]),x=(c=b==null?void 0:b.uiSchema)==null?void 0:c.title;o.title===x||o.title,o.readPretty||o.required;let C="editable";return a["x-disabled"]===!0&&(C="readonly"),a["x-read-pretty"]===!0&&(C="read-pretty"),r.jsxs(s.GeneralSchemaDesigner,{children:[r.jsx(s.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!s.isPatternDisabled(a)&&r.jsx(s.SchemaSettings.SelectItem,{title:i("Pattern"),options:[{label:i("Editable"),value:"editable"},{label:i("Readonly"),value:"readonly"},{label:i("Easy-reading"),value:"read-pretty"}],value:C,onChange:y=>{const u={"x-uid":a["x-uid"]};switch(y){case"readonly":{a["x-read-pretty"]=!1,a["x-disabled"]=!0,u["x-read-pretty"]=!1,u["x-disabled"]=!0,o.readPretty=!1,o.disabled=!0;break}case"read-pretty":{a["x-read-pretty"]=!0,a["x-disabled"]=!1,u["x-read-pretty"]=!0,u["x-disabled"]=!1,o.readPretty=!0;break}default:{a["x-read-pretty"]=!1,a["x-disabled"]=!1,u["x-read-pretty"]=!1,u["x-disabled"]=!1,o.readPretty=!1,o.disabled=!1;break}}l.emit("patch",{schema:u}),l.refresh()}},"pattern"),r.jsx(s.SchemaSettings.ModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:o.componentProps.zoom||13,description:i("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:y})=>{y&&(xe.set(a,"x-component-props.zoom",y),Object.assign(o.componentProps,a["x-component-props"]),l.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":o.componentProps}})),l.refresh()}},"map-zoom"),r.jsx(s.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},At={amap:Pe,google:ze},Be=f.forwardRef((e,n)=>{const{t}=Q(),{mapType:o}=e,a=f.useMemo(()=>At[o],[o]);return a?r.jsx(a,P({ref:n},e)):r.jsx("div",{children:t(`The ${o} cannot found`)})}),vt=e=>{var h,b;const{value:n}=e,t=X.useFieldSchema(),{getField:o}=s.useCollection(),a=o(t.name),i=e.mapType||((h=a==null?void 0:a.uiSchema["x-component-props"])==null?void 0:h.mapType),l=X.useForm();return s.useFieldTitle(),l.readPretty?r.jsx(Be,P({readonly:!0,mapType:i},e)):r.jsx("div",{children:r.jsx(s.EllipsisWithTooltip,{ellipsis:!0,children:(b=n==null?void 0:n.map)==null?void 0:b.call(n,x=>Array.isArray(x)?`(${x.join(",")})`:x).join(",")})})},De=X.connect(e=>r.jsx("div",{className:s.css`
105
+ `,children:n.jsxs(I.Space,{direction:"vertical",children:[n.jsx(I.Button,{style:{color:z?void 0:"#F18b62",borderColor:"currentcolor"},onClick:O=>{O.stopPropagation(),D("")},icon:n.jsx(ee.EnvironmentOutlined,{})}),n.jsx(I.Button,{style:{color:z==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:O=>{O.stopPropagation(),D("selection")},icon:n.jsx(ee.ExpandOutlined,{})}),z==="selection"?n.jsx(I.Button,{type:"primary",icon:n.jsx(ee.CheckOutlined,{}),title:S("Confirm selection"),onClick:te}):null]})}),n.jsx(gt,{record:d,setVisible:v})]}),n.jsx(ze,X(P({},e),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},gt=e=>{const{setVisible:r,record:t}=e,o=J.useFieldSchema(),a=f.useMemo(()=>o.reduceProperties((i,l)=>l.name==="drawer"?l:i,null),[o]);return a&&n.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:r},children:n.jsx(s.RecordProvider,{record:t,children:n.jsx(J.RecursionField,{schema:a,name:a.name})})})};function Te(e){if(e instanceof google.maps.Marker)return e.setIcon(ce(ue));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function mt(e){if(e instanceof google.maps.Marker)return e.setIcon(ce(ye));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const ht=()=>{var c;const{getCollectionJoinField:e}=s.useCollectionManager(),{getField:r}=s.useCollection(),{form:t}=s.useFormBlockContext(),o=J.useField(),a=J.useFieldSchema(),{t:i}=Q(),{dn:l,refresh:h}=s.useDesignable(),b=r(a.name)||e(a["x-collection-field"]),x=(c=b==null?void 0:b.uiSchema)==null?void 0:c.title;o.title===x||o.title,o.readPretty||o.required;let C="editable";return a["x-disabled"]===!0&&(C="readonly"),a["x-read-pretty"]===!0&&(C="read-pretty"),n.jsxs(s.GeneralSchemaDesigner,{children:[n.jsx(s.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!s.isPatternDisabled(a)&&n.jsx(s.SchemaSettingsSelectItem,{title:i("Pattern"),options:[{label:i("Editable"),value:"editable"},{label:i("Readonly"),value:"readonly"},{label:i("Easy-reading"),value:"read-pretty"}],value:C,onChange:y=>{const u={"x-uid":a["x-uid"]};switch(y){case"readonly":{a["x-read-pretty"]=!1,a["x-disabled"]=!0,u["x-read-pretty"]=!1,u["x-disabled"]=!0,o.readPretty=!1,o.disabled=!0;break}case"read-pretty":{a["x-read-pretty"]=!0,a["x-disabled"]=!1,u["x-read-pretty"]=!0,u["x-disabled"]=!1,o.readPretty=!0;break}default:{a["x-read-pretty"]=!1,a["x-disabled"]=!1,u["x-read-pretty"]=!1,u["x-disabled"]=!1,o.readPretty=!1,o.disabled=!1;break}}l.emit("patch",{schema:u}),l.refresh()}},"pattern"),n.jsx(s.SchemaSettingsModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:o.componentProps.zoom||13,description:i("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:y})=>{y&&(xe.set(a,"x-component-props.zoom",y),Object.assign(o.componentProps,a["x-component-props"]),l.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":o.componentProps}})),l.refresh()}},"map-zoom"),n.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},yt={amap:Pe,google:ze},Be=f.forwardRef((e,r)=>{const{t}=Q(),{mapType:o}=e,a=f.useMemo(()=>yt[o],[o]);return a?n.jsx(a,P({ref:r},e)):n.jsx("div",{children:t(`The ${o} cannot found`)})}),At=e=>{var h,b;const{value:r}=e,t=J.useFieldSchema(),{getField:o}=s.useCollection(),a=o(t.name),i=e.mapType||((h=a==null?void 0:a.uiSchema["x-component-props"])==null?void 0:h.mapType),l=J.useForm();return s.useFieldTitle(),l.readPretty?n.jsx(Be,P({readonly:!0,mapType:i},e)):n.jsx("div",{children:n.jsx(s.EllipsisWithTooltip,{ellipsis:!0,children:(b=r==null?void 0:r.map)==null?void 0:b.call(r,x=>Array.isArray(x)?`(${x.join(",")})`:x).join(",")})})},De=J.connect(e=>n.jsx("div",{className:s.css`
106
106
  height: 100%;
107
107
  border: 1px solid transparent;
108
108
  .ant-formily-item-error & {
109
109
  border: 1px solid #ff4d4f;
110
110
  }
111
- `,children:r.jsx(Be,P({},e))}),X.mapReadPretty(vt));De.Designer=yt;const bt={amap:et,google:gt},Mt=e=>{const{t:n}=Q(),{mapType:t}=e,o=f.useMemo(()=>bt[t],[t]);return o?r.jsx(o,P({},e)):r.jsx("div",{children:n(`The ${t} cannot found`)})},Ct=e=>{var l;const{fieldNames:n}=s.useProps(e),{getCollectionJoinField:t}=s.useCollectionManager(),{name:o}=s.useCollection(),a=f.useMemo(()=>t([o,n==null?void 0:n.field].flat().join(".")),[o,n==null?void 0:n.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return r.jsx(Mt,J(P(P({},i),e),{collectionField:a}))},Ke=f.createContext({}),xt=e=>{var b;const{fieldNames:n}=e,t=X.useFieldSchema(),o=X.useField(),{resource:a,service:i}=s.useBlockRequestContext(),[l,h]=f.useState([]);return r.jsx(s.FixedBlockWrapper,{children:r.jsx(s.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:r.jsx(Ke.Provider,{value:{field:o,service:i,resource:a,fieldNames:n,fixedBlock:(b=t==null?void 0:t["x-decorator-props"])==null?void 0:b.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:h},children:e.children})})})},wt=e=>{const n=X.useField(),{params:t,fieldNames:o}=e,a=t.appends||[],{field:i}=o||{};return Array.isArray(i)&&i.length>1&&a.push(i[0]),r.jsx(s.BlockProvider,J(P({name:"map"},e),{runWhenParamsChanged:!0,params:J(P({},t),{appends:a,paginate:!1,sort:n.componentProps.lineSort}),children:r.jsx(xt,P({},e))}))},Ue=()=>f.useContext(Ke),St=()=>{var n,t,o,a,i,l;const e=Ue();return J(P({},e),{dataSource:(t=(n=e==null?void 0:e.service)==null?void 0:n.data)==null?void 0:t.data,zoom:((a=(o=e==null?void 0:e.field)==null?void 0:o.componentProps)==null?void 0:a.zoom)||13,lineSort:(l=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:l.lineSort})},It=e=>{const l=e,{collection:n,resource:t,fieldNames:o}=l,a=Ye(l,["collection","resource","fieldNames"]);return{type:"void","x-acl-action":`${t||n}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":P({collection:n,resource:t||n,action:"list",fieldNames:o,params:{paginate:!1}},a),"x-designer":"MapBlockDesigner","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"MapActionInitializers","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},[_e.uid()]:{type:"void","x-component":"MapBlock","x-component-props":{useProps:"{{ useMapBlockProps }}"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"RecordBlockInitializers",properties:{}}}}}}}}}}}}},Ne=(e,n=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,o,a)=>{const i=t==null?void 0:t.find(l=>l.value===o);return a===e.length-1?i:i==null?void 0:i.children},n)),Pt=()=>{var D,I,U,V,K,L;const{name:e,title:n}=s.useCollection(),t=X.useField(),o=X.useFieldSchema(),{form:a}=s.useFormBlockContext(),{service:i}=Ue(),{t:l}=Q(),{dn:h}=s.useDesignable(),{getCollectionFieldsOptions:b}=s.useCollectionManager(),x=s.useCollection(),C=(D=o==null?void 0:o["x-decorator-props"])==null?void 0:D.resource,c=((I=o==null?void 0:o["x-decorator-props"])==null?void 0:I.fieldNames)||{},y=((U=o==null?void 0:o["x-component-props"])==null?void 0:U.zoom)||13,u=s.useSchemaTemplate(),d=b(x==null?void 0:x.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),v=b(x==null?void 0:x.name,"string"),z=((V=Ne(c.field,d))==null?void 0:V.type)==="point";return r.jsxs(s.GeneralSchemaDesigner,{template:u,title:n||e,children:[r.jsx(s.SchemaSettings.BlockTitleItem,{}),r.jsx(s.FixedBlockDesignerItem,{}),r.jsx(s.SchemaSettings.CascaderItem,{title:l("Map field"),value:c.field,options:d,allowClear:!1,onChange:k=>{const W=t.decoratorProps.fieldNames||{};W.field=k,t.decoratorProps.fieldNames=W,o["x-decorator-props"].fieldNames=W,i.refresh(),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),h.refresh()}}),z?r.jsx(s.SchemaSettings.SelectItem,{title:l("Marker field"),value:c.marker,options:v,onChange:k=>{const W=t.decoratorProps.fieldNames||{};W.marker=k,t.decoratorProps.fieldNames=W,o["x-decorator-props"].fieldNames=W,i.refresh(),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),h.refresh()}}):null,r.jsx(s.SchemaSettings.DefaultSortingRules,{path:"x-component-props.lineSort",title:l("Concatenation order field")}),r.jsx(s.SchemaSettings.ModalItem,{title:l("The default zoom level of the map"),schema:{type:"object",title:l("Set default zoom level"),properties:{zoom:{title:l("Zoom"),default:y,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:k})=>{xe.set(o,"x-component-props.zoom",k),Object.assign(t.componentProps,o["x-component-props"]),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),h.refresh()}}),r.jsx(s.SchemaSettings.DataScope,{collectionName:e,defaultFilter:((L=(K=o==null?void 0:o["x-decorator-props"])==null?void 0:K.params)==null?void 0:L.filter)||{},form:a,onSubmit:({filter:k})=>{var H,_,ee;const W=t.decoratorProps.params||{};W.filter=k,t.decoratorProps.params=W,o["x-decorator-props"].params=W;const Z=((_=(H=i.params)==null?void 0:H[1])==null?void 0:_.filters)||{};i.run(J(P({},(ee=i.params)==null?void 0:ee[0]),{filter:s.mergeFilter([...Object.values(Z),k]),page:1}),{filters:Z}),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}),r.jsx(s.SchemaSettings.ConnectDataBlocks,{type:s.FilterBlockType.TABLE,emptyDescription:l("No blocks to connect")}),r.jsx(s.SchemaSettings.Divider,{}),r.jsx(s.SchemaSettings.Template,{componentName:"Map",collectionName:e,resourceName:C}),r.jsx(s.SchemaSettings.Divider,{}),r.jsx(s.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},kt=e=>{const{insert:n}=e,t=f.useContext(X.SchemaOptionsContext),{getCollectionFieldsOptions:o}=s.useCollectionManager(),{t:a}=Q(),{theme:i}=s.useGlobalTheme();return r.jsx(s.DataBlockInitializer,J(P({},e),{componentType:"Map",icon:r.jsx(te.TableOutlined,{}),onCreateBlockSchema:h=>he(this,[h],function*({item:l}){const b=o(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),x=o(l.name,"string"),C=yield s.FormDialog(a("Create map block"),()=>{var c;return r.jsx(s.SchemaComponentOptions,{scope:t.scope,components:P({},t.components),children:r.jsx(Je.FormLayout,{layout:"vertical",children:r.jsx(s.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:b,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:b.length?[b[0].value,(c=b[0].children)==null?void 0:c[0].value].filter(y=>y!=null):[]},marker:{title:a("Marker field"),enum:x,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const u=y.form.values.field;if(!(u!=null&&u.length))return;const d=Ne(u,b);d&&(y.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});n(It({collection:l.name,fieldNames:P({},C)}))}),title:a("Map block")}))},Ot=e=>{const t=f.useContext(s.SchemaInitializerContext).BlockInitializers.items[0].children;return f.useEffect(()=>{t.find(o=>o.component==="MapBlockInitializer")||t.push({key:"mapBlock",type:"item",title:$("Map"),component:"MapBlockInitializer"})},[]),r.jsx(s.SchemaInitializerProvider,{initializers:{MapActionInitializers:Xe},children:r.jsx(s.SchemaComponentOptions,{scope:{useMapBlockProps:St},components:{MapBlockInitializer:kt,MapBlockDesigner:Pt,MapBlockProvider:wt,MapBlock:Ct},children:e.children})})},{defaultProps:Ft}=s.interfacesProperties;Array.isArray(s.interfacesProperties.type.enum)&&s.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});const ge={properties:J(P({},Ft),{"uiSchema.x-component-props.mapType":{title:$("Map type"),type:"string",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1},"x-disabled":"{{ isOverride || !createOnly }}",default:"amap",enum:we}}),schemaInitialize(e,{block:n}){n==="Form"&&Object.assign(e,{"x-designer":"Map.Designer"})}},Et=P({name:"circle",type:"object",group:"map",order:3,title:$("Circle"),availableTypes:["circle"],description:$("Circle"),sortable:!0,default:{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),zt=P({name:"lineString",type:"object",group:"map",order:2,title:$("Line"),description:$("Line"),availableTypes:["lineString"],sortable:!0,default:{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Lt=P({name:"point",type:"object",group:"map",order:1,title:$("Point"),description:$("Point"),availableTypes:["point"],sortable:!0,default:{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Tt=P({name:"polygon",type:"object",group:"map",order:4,title:$("Polygon"),description:$("Polygon"),availableTypes:["polygon"],sortable:!0,default:{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Me=[Lt,Tt,zt,Et],Bt=Me.reduce((e,n)=>(e[n.name]=n,e),{}),Dt=()=>{const{data:e}=s.useCurrentAppInfo()||{};f.useEffect(()=>{const n=e==null?void 0:e.database.dialect;n&&(s.registerGroup(Me[0].group,{label:$("Map-based geometry"),order:51}),Me.forEach(t=>{Array.isArray(t.dialects)&&!t.dialects.includes(n)||s.registerField(t.group,t.name,t)}))},[e])},Kt=e=>(Dt(),r.jsx(f.Fragment,{children:e.children})),Ge=f.memo(e=>{const n=f.useContext(s.CollectionManagerContext);return r.jsx(s.CurrentAppInfoProvider,{children:r.jsx(Kt,{children:r.jsx(s.SchemaComponentOptions,{components:{Map:De},children:r.jsx(Ot,{children:r.jsx(s.CollectionManagerContext.Provider,{value:J(P({},n),{interfaces:P(P({},n.interfaces),Bt)}),children:e.children})})})})})});Ge.displayName="MapProvider";class qe extends s.Plugin{load(){return he(this,null,function*(){this.app.use(Ge),this.app.pluginSettingsManager.add(de,{title:`{{t("Map Manager", { ns: "${de}" })}}`,icon:"EnvironmentOutlined",Component:st,aclSnippet:"pm.map.configuration"})})}}F.MapPlugin=qe,F.default=qe,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
111
+ `,children:n.jsx(Be,P({},e))}),J.mapReadPretty(At));De.Designer=ht;const vt={amap:Re,google:ft},bt=e=>{const{t:r}=Q(),{mapType:t}=e,o=f.useMemo(()=>vt[t],[t]);return o?n.jsx(o,P({},e)):n.jsx("div",{children:r(`The ${t} cannot found`)})},Mt=e=>{var l;const{fieldNames:r}=s.useProps(e),{getCollectionJoinField:t}=s.useCollectionManager(),{name:o}=s.useCollection(),a=f.useMemo(()=>t([o,r==null?void 0:r.field].flat().join(".")),[o,r==null?void 0:r.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return n.jsx(bt,X(P(P({},i),e),{collectionField:a}))},Ue=f.createContext({}),Ct=e=>{var b;const{fieldNames:r}=e,t=J.useFieldSchema(),o=J.useField(),{resource:a,service:i}=s.useBlockRequestContext(),[l,h]=f.useState([]);return n.jsx(s.FixedBlockWrapper,{children:n.jsx(s.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:n.jsx(Ue.Provider,{value:{field:o,service:i,resource:a,fieldNames:r,fixedBlock:(b=t==null?void 0:t["x-decorator-props"])==null?void 0:b.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:h},children:e.children})})})},xt=e=>{const r=J.useField(),{params:t,fieldNames:o}=e,a=t.appends||[],{field:i}=o||{};return Array.isArray(i)&&i.length>1&&a.push(i[0]),n.jsx(s.BlockProvider,X(P({name:"map"},e),{runWhenParamsChanged:!0,params:X(P({},t),{appends:a,paginate:!1,sort:r.componentProps.lineSort}),children:n.jsx(Ct,P({},e))}))},Ke=()=>f.useContext(Ue),wt=()=>{var r,t,o,a,i,l;const e=Ke();return X(P({},e),{dataSource:(t=(r=e==null?void 0:e.service)==null?void 0:r.data)==null?void 0:t.data,zoom:((a=(o=e==null?void 0:e.field)==null?void 0:o.componentProps)==null?void 0:a.zoom)||13,lineSort:(l=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:l.lineSort})},St=e=>{const l=e,{collection:r,resource:t,fieldNames:o}=l,a=Ye(l,["collection","resource","fieldNames"]);return{type:"void","x-acl-action":`${t||r}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":P({collection:r,resource:t||r,action:"list",fieldNames:o,params:{paginate:!1}},a),"x-designer":"MapBlockDesigner","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"MapActionInitializers","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},[_e.uid()]:{type:"void","x-component":"MapBlock","x-component-props":{useProps:"{{ useMapBlockProps }}"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"RecordBlockInitializers",properties:{}}}}}}}}}}}}},Ne=(e,r=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,o,a)=>{const i=t==null?void 0:t.find(l=>l.value===o);return a===e.length-1?i:i==null?void 0:i.children},r)),It=()=>{var D,S,K,j,U,L;const{name:e,title:r}=s.useCollection(),t=J.useField(),o=J.useFieldSchema(),{form:a}=s.useFormBlockContext(),{service:i}=Ke(),{t:l}=Q(),{dn:h}=s.useDesignable(),{getCollectionFieldsOptions:b}=s.useCollectionManager(),x=s.useCollection(),C=(D=o==null?void 0:o["x-decorator-props"])==null?void 0:D.resource,c=((S=o==null?void 0:o["x-decorator-props"])==null?void 0:S.fieldNames)||{},y=((K=o==null?void 0:o["x-component-props"])==null?void 0:K.zoom)||13,u=s.useSchemaTemplate(),d=b(x==null?void 0:x.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),v=b(x==null?void 0:x.name,"string"),z=((j=Ne(c.field,d))==null?void 0:j.type)==="point";return n.jsxs(s.GeneralSchemaDesigner,{template:u,title:r||e,children:[n.jsx(s.SchemaSettingsBlockTitleItem,{}),n.jsx(s.FixedBlockDesignerItem,{}),n.jsx(s.SchemaSettingsCascaderItem,{title:l("Map field"),value:c.field,options:d,allowClear:!1,onChange:k=>{const V=t.decoratorProps.fieldNames||{};V.field=k,t.decoratorProps.fieldNames=V,o["x-decorator-props"].fieldNames=V,i.refresh(),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),h.refresh()}}),z?n.jsx(s.SchemaSettingsSelectItem,{title:l("Marker field"),value:c.marker,options:v,onChange:k=>{const V=t.decoratorProps.fieldNames||{};V.marker=k,t.decoratorProps.fieldNames=V,o["x-decorator-props"].fieldNames=V,i.refresh(),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),h.refresh()}}):null,n.jsx(s.SchemaSettingsDefaultSortingRules,{path:"x-component-props.lineSort",title:l("Concatenation order field")}),n.jsx(s.SchemaSettingsModalItem,{title:l("The default zoom level of the map"),schema:{type:"object",title:l("Set default zoom level"),properties:{zoom:{title:l("Zoom"),default:y,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:k})=>{xe.set(o,"x-component-props.zoom",k),Object.assign(t.componentProps,o["x-component-props"]),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),h.refresh()}}),n.jsx(s.SchemaSettingsDataScope,{collectionName:e,defaultFilter:((L=(U=o==null?void 0:o["x-decorator-props"])==null?void 0:U.params)==null?void 0:L.filter)||{},form:a,onSubmit:({filter:k})=>{var H,_,te;const V=t.decoratorProps.params||{};V.filter=k,t.decoratorProps.params=V,o["x-decorator-props"].params=V;const Z=((_=(H=i.params)==null?void 0:H[1])==null?void 0:_.filters)||{};i.run(X(P({},(te=i.params)==null?void 0:te[0]),{filter:s.mergeFilter([...Object.values(Z),k]),page:1}),{filters:Z}),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}),n.jsx(s.SchemaSettingsConnectDataBlocks,{type:s.FilterBlockType.TABLE,emptyDescription:l("No blocks to connect")}),n.jsx(s.SchemaSettingsDivider,{}),n.jsx(s.SchemaSettingsTemplate,{componentName:"Map",collectionName:e,resourceName:C}),n.jsx(s.SchemaSettingsDivider,{}),n.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},Pt=()=>{const e=s.useSchemaInitializerItem(),{insert:r}=s.useSchemaInitializer(),t=f.useContext(J.SchemaOptionsContext),{getCollectionFieldsOptions:o}=s.useCollectionManager(),{t:a}=Q(),{theme:i}=s.useGlobalTheme();return n.jsx(s.DataBlockInitializer,P({componentType:"Map",icon:n.jsx(ee.TableOutlined,{}),onCreateBlockSchema:h=>he(this,[h],function*({item:l}){const b=o(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),x=o(l.name,"string"),C=yield s.FormDialog(a("Create map block"),()=>{var c;return n.jsx(s.SchemaComponentOptions,{scope:t.scope,components:P({},t.components),children:n.jsx(Je.FormLayout,{layout:"vertical",children:n.jsx(s.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:b,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:b.length?[b[0].value,(c=b[0].children)==null?void 0:c[0].value].filter(y=>y!=null):[]},marker:{title:a("Marker field"),enum:x,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const u=y.form.values.field;if(!(u!=null&&u.length))return;const d=Ne(u,b);d&&(y.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});r(St({collection:l.name,fieldNames:P({},C)}))}),title:a("Map block")},e))},kt=e=>n.jsx(s.SchemaComponentOptions,{scope:{useMapBlockProps:wt},components:{MapBlockInitializer:Pt,MapBlockDesigner:It,MapBlockProvider:xt,MapBlock:Mt},children:e.children}),Ot=new s.SchemaInitializer({name:"MapActionInitializers",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){return s.useCollection().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return s.useCollection().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[{name:"bulkUpdate",title:'{{t("Bulk update")}}',Component:"CustomizeActionInitializer",schema:{type:"void",title:'{{ t("Bulk update") }}',"x-component":"Action","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-action":"customize:bulkUpdate","x-designer":"Action.Designer","x-action-settings":{assignedValues:{},updateMode:"selected",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-component-props":{icon:"EditOutlined",useProps:"{{ useCustomizeBulkUpdateActionProps }}"}}},{name:"bulkEdit",title:'{{t("Bulk edit")}}',Component:"CustomizeBulkEditActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"update","x-acl-action-props":{skipScopeCheck:!0}}}],useVisible(){return s.useCollection().template!=="sql"}}]}),{defaultProps:Ft}=s.interfacesProperties;Array.isArray(s.interfacesProperties.type.enum)&&s.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});const ge={properties:X(P({},Ft),{"uiSchema.x-component-props.mapType":{title:$("Map type"),type:"string",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1},"x-disabled":"{{ isOverride || !createOnly }}",default:"amap",enum:we}}),schemaInitialize(e,{block:r}){r==="Form"&&Object.assign(e,{"x-designer":"Map.Designer"})}},Et=P({name:"circle",type:"object",group:"map",order:3,title:$("Circle"),availableTypes:["circle"],description:$("Circle"),sortable:!0,default:{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),zt=P({name:"lineString",type:"object",group:"map",order:2,title:$("Line"),description:$("Line"),availableTypes:["lineString"],sortable:!0,default:{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Lt=P({name:"point",type:"object",group:"map",order:1,title:$("Point"),description:$("Point"),availableTypes:["point"],sortable:!0,default:{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Tt=P({name:"polygon",type:"object",group:"map",order:4,title:$("Polygon"),description:$("Polygon"),availableTypes:["polygon"],sortable:!0,default:{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Me=[Lt,Tt,zt,Et],Bt=Me.reduce((e,r)=>(e[r.name]=r,e),{}),Dt=()=>{const{data:e}=s.useCurrentAppInfo()||{};f.useEffect(()=>{const r=e==null?void 0:e.database.dialect;r&&(s.registerGroup(Me[0].group,{label:$("Map-based geometry"),order:51}),Me.forEach(t=>{Array.isArray(t.dialects)&&!t.dialects.includes(r)||s.registerField(t.group,t.name,t)}))},[e])},Ut=e=>(Dt(),n.jsx(f.Fragment,{children:e.children})),Ge=f.memo(e=>{const r=f.useContext(s.CollectionManagerContext);return n.jsx(s.CurrentAppInfoProvider,{children:n.jsx(Ut,{children:n.jsx(s.SchemaComponentOptions,{components:{Map:De},children:n.jsx(kt,{children:n.jsx(s.CollectionManagerContext.Provider,{value:X(P({},r),{interfaces:P(P({},r.interfaces),Bt)}),children:e.children})})})})})});Ge.displayName="MapProvider";class qe extends s.Plugin{load(){return he(this,null,function*(){this.app.use(Ge),this.app.schemaInitializerManager.add(Ot);const r=this.app.schemaInitializerManager.get("BlockInitializers");r==null||r.add("dataBlocks.map",{title:$("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(de,{title:`{{t("Map Manager", { ns: "${de}" })}}`,icon:"EnvironmentOutlined",Component:nt,aclSnippet:"pm.map.configuration"})})}}F.MapPlugin=qe,F.default=qe,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.16.0-alpha.6",
2
+ "@nocobase/client": "0.17.0-alpha.2",
3
3
  "react": "18.2.0",
4
- "@nocobase/server": "0.16.0-alpha.6",
4
+ "@nocobase/server": "0.17.0-alpha.2",
5
5
  "@formily/react": "2.2.27",
6
6
  "lodash": "4.17.21",
7
7
  "@ant-design/icons": "5.1.4",
@@ -12,6 +12,6 @@ module.exports = {
12
12
  "react-router-dom": "6.14.1",
13
13
  "@formily/core": "2.2.27",
14
14
  "react-i18next": "11.18.6",
15
- "@nocobase/actions": "0.16.0-alpha.6",
16
- "@nocobase/database": "0.16.0-alpha.6"
15
+ "@nocobase/actions": "0.17.0-alpha.2",
16
+ "@nocobase/database": "0.17.0-alpha.2"
17
17
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@nocobase/plugin-map",
3
3
  "displayName": "Map",
4
4
  "displayName.zh-CN": "地图",
5
- "version": "0.16.0-alpha.6",
5
+ "version": "0.17.0-alpha.2",
6
6
  "description": "Provides map fields and blocks",
7
7
  "description.zh-CN": "提供地图字段和区块",
8
8
  "license": "AGPL-3.0",
@@ -34,5 +34,5 @@
34
34
  "@nocobase/test": "0.x",
35
35
  "@nocobase/utils": "0.x"
36
36
  },
37
- "gitHead": "e8ad2328a8f85289cb19a7994d3fd726c7ae1720"
37
+ "gitHead": "c4d4383a1fde1058011e2f1fd1d9272812e6daeb"
38
38
  }