@nocobase/plugin-map 1.5.0-beta.1 → 1.6.0-alpha.1
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.
- package/dist/client/index.js +1 -115
- package/dist/externalVersion.js +5 -5
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -7,118 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(D,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("lodash"),require("@ant-design/icons"),require("ahooks"),require("antd"),require("react-i18next"),require("@formily/react"),require("@formily/antd-v5"),require("@formily/shared"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","lodash","@ant-design/icons","ahooks","antd","react-i18next","@formily/react","@formily/antd-v5","@formily/shared","@emotion/css"],i):(D=typeof globalThis!="undefined"?globalThis:D||self,i(D["@nocobase/plugin-map"]={},D.jsxRuntime,D["@nocobase/client"],D.react,D.lodash,D["@ant-design/icons"],D.ahooks,D.antd,D["react-i18next"],D["@formily/react"],D["@formily/antd-v5"],D["@formily/shared"],D["@emotion/css"]))})(this,function(D,i,r,h,me,ee,G,x,le,z,et,tt,ot){"use strict";var Vt=Object.defineProperty,Wt=Object.defineProperties;var Yt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var De=(D,i,r)=>i in D?Vt(D,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):D[i]=r,O=(D,i)=>{for(var r in i||(i={}))Ht.call(i,r)&&De(D,r,i[r]);if(Re)for(var r of Re(i))Jt.call(i,r)&&De(D,r,i[r]);return D},W=(D,i)=>Wt(D,Yt(i));var E=(D,i,r)=>(De(D,typeof i!="symbol"?i+"":i,r),r);var Ce=(D,i,r)=>new Promise((h,me)=>{var ee=le=>{try{x(r.next(le))}catch(z){me(z)}},G=le=>{try{x(r.throw(le))}catch(z){me(z)}},x=le=>le.done?h(le.value):Promise.resolve(le.value).then(ee,G);x((r=r.apply(D,i)).next())});const be="map";function X(e){return`{{t('${e}', { ns: '${be}', nsMode: 'fallback' })}}`}function Y(){return le.useTranslation([be,"client"],{nsMode:"fallback"})}const Te=[{label:X("AMap"),value:"amap"},{label:X("Google Maps"),value:"google"}],Se="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ge="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==",ze=(e,o,t)=>{const n=o==null?void 0:o.reduce((l,a,c)=>c===o.length-1&&(t==="o2m"||t==="m2m")?l==null?void 0:l.map(g=>g[a]).filter(g=>g!=null):l==null?void 0:l[a],e);return t==="o2m"||t==="m2m"?n:[n]},xe=e=>{const o=r.useCollectionRecordData(),t=r.useCollection(),n=z.useFieldSchema(),l=h.useMemo(()=>n.reduceProperties((a,c)=>c.name==="drawer"?c:a,null),[n]);return l?i.jsx(r.VariablePopupRecordProvider,{recordData:o,collection:t,children:i.jsx(z.RecursionField,{schema:l,name:l.name})}):null};var rt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function nt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Be={exports:{}};(function(e,o){(function(t,n){e.exports=n()})(rt,function(){function t(p){var y=[];return p.AMapUI&&y.push(n(p.AMapUI)),p.Loca&&y.push(l(p.Loca)),Promise.all(y)}function n(p){return new Promise(function(y,d){var f=[];if(p.plugins)for(var C=0;C<p.plugins.length;C+=1)c.AMapUI.plugins.indexOf(p.plugins[C])==-1&&f.push(p.plugins[C]);if(g.AMapUI===a.failed)d("前次请求 AMapUI 失败");else if(g.AMapUI===a.notload){g.AMapUI=a.loading,c.AMapUI.version=p.version||c.AMapUI.version,C=c.AMapUI.version;var L=document.body||document.head,B=document.createElement("script");B.type="text/javascript",B.src="https://webapi.amap.com/ui/"+C+"/main.js",B.onerror=function(w){g.AMapUI=a.failed,d("请求 AMapUI 失败")},B.onload=function(){if(g.AMapUI=a.loaded,f.length)window.AMapUI.loadUI(f,function(){for(var w=0,U=f.length;w<U;w++){var q=f[w].split("/").slice(-1)[0];window.AMapUI[q]=arguments[w]}for(y();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()});else for(y();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()},L.appendChild(B)}else g.AMapUI===a.loaded?p.version&&p.version!==c.AMapUI.version?d("不允许多个版本 AMapUI 混用"):f.length?window.AMapUI.loadUI(f,function(){for(var w=0,U=f.length;w<U;w++){var q=f[w].split("/").slice(-1)[0];window.AMapUI[q]=arguments[w]}y()}):y():p.version&&p.version!==c.AMapUI.version?d("不允许多个版本 AMapUI 混用"):A.AMapUI.push(function(w){w?d(w):f.length?window.AMapUI.loadUI(f,function(){for(var U=0,q=f.length;U<q;U++){var K=f[U].split("/").slice(-1)[0];window.AMapUI[K]=arguments[U]}y()}):y()})})}function l(p){return new Promise(function(y,d){if(g.Loca===a.failed)d("前次请求 Loca 失败");else if(g.Loca===a.notload){g.Loca=a.loading,c.Loca.version=p.version||c.Loca.version;var f=c.Loca.version,C=c.AMap.version.startsWith("2"),L=f.startsWith("2");if(C&&!L||!C&&L)d("JSAPI 与 Loca 版本不对应!!");else{C=c.key,L=document.body||document.head;var B=document.createElement("script");B.type="text/javascript",B.src="https://webapi.amap.com/loca?v="+f+"&key="+C,B.onerror=function(w){g.Loca=a.failed,d("请求 AMapUI 失败")},B.onload=function(){for(g.Loca=a.loaded,y();A.Loca.length;)A.Loca.splice(0,1)[0]()},L.appendChild(B)}}else g.Loca===a.loaded?p.version&&p.version!==c.Loca.version?d("不允许多个版本 Loca 混用"):y():p.version&&p.version!==c.Loca.version?d("不允许多个版本 Loca 混用"):A.Loca.push(function(w){w?d(w):d()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var a;(function(p){p.notload="notload",p.loading="loading",p.loaded="loaded",p.failed="failed"})(a||(a={}));var c={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},g={AMap:a.notload,AMapUI:a.notload,Loca:a.notload},A={AMap:[],AMapUI:[],Loca:[]},v=[],b=function(p){typeof p=="function"&&(g.AMap===a.loaded?p(window.AMap):v.push(p))};return{load:function(p){return new Promise(function(y,d){if(g.AMap==a.failed)d("");else if(g.AMap==a.notload){var f=p.key,C=p.version,L=p.plugins;f?(window.AMap&&location.host!=="lbs.amap.com"&&d("禁止多种API加载方式混用"),c.key=f,c.AMap.version=C||c.AMap.version,c.AMap.plugins=L||c.AMap.plugins,g.AMap=a.loading,C=document.body||document.head,window.___onAPILoaded=function(w){if(delete window.___onAPILoaded,w)g.AMap=a.failed,d(w);else for(g.AMap=a.loaded,t(p).then(function(){y(window.AMap)}).catch(d);v.length;)v.splice(0,1)[0]()},L=document.createElement("script"),L.type="text/javascript",L.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+c.AMap.version+"&key="+f+"&plugin="+c.AMap.plugins.join(","),L.onerror=function(w){g.AMap=a.failed,d(w)},C.appendChild(L)):d("请填写key")}else if(g.AMap==a.loaded)if(p.key&&p.key!==c.key)d("多个不一致的 key");else if(p.version&&p.version!==c.AMap.version)d("不允许多个版本 JSAPI 混用");else{if(f=[],p.plugins)for(C=0;C<p.plugins.length;C+=1)c.AMap.plugins.indexOf(p.plugins[C])==-1&&f.push(p.plugins[C]);f.length?window.AMap.plugin(f,function(){t(p).then(function(){y(window.AMap)}).catch(d)}):t(p).then(function(){y(window.AMap)}).catch(d)}else if(p.key&&p.key!==c.key)d("多个不一致的 key");else if(p.version&&p.version!==c.AMap.version)d("不允许多个版本 JSAPI 混用");else{var B=[];if(p.plugins)for(C=0;C<p.plugins.length;C+=1)c.AMap.plugins.indexOf(p.plugins[C])==-1&&B.push(p.plugins[C]);b(function(){B.length?window.AMap.plugin(B,function(){t(p).then(function(){y(window.AMap)}).catch(d)}):t(p).then(function(){y(window.AMap)}).catch(d)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,c={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},g={AMap:a.notload,AMapUI:a.notload,Loca:a.notload},A={AMap:[],AMapUI:[],Loca:[]}}}})})(Be);var st=Be.exports;const Ue=nt(st),Ke="map-configuration",we=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Pe=e=>{const o=h.useMemo(()=>{const n=sessionStorage.getItem(we(e));return n&&JSON.parse(n)},[e]),{data:t}=r.useRequest({resource:Ke,action:"get",params:{type:e}},{onSuccess(n){sessionStorage.setItem(we(e),JSON.stringify(n==null?void 0:n.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},Ne=()=>{var b,p;const e=r.useDataBlockHeight(),{token:o}=x.theme.useToken(),{designable:t}=r.useDesignable(),{heightProps:n}=r.useBlockHeightProps()||{},{title:l}=n||{},a=z.useFieldSchema();if(!e)return;const c=Object.keys(((p=(b=a.parent)==null?void 0:b.properties.actions)==null?void 0:p.properties)||{}).length>0,g=t||c?o.paddingLG+o.controlHeight+o.margin:o.paddingLG+o.margin,A=o.paddingLG,v=l?o.fontSizeLG*o.lineHeightLG+o.padding*2-1:0;return e-g-A-v},it=e=>{const{aMap:o,toCenter:t}=e,{t:n}=Y(),l=h.useRef(),[a,c]=h.useState([]);h.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{l.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:g}=G.useDebounceFn(v=>{l.current&&l.current.search(v||" ",(b,p)=>{if(b==="complete")c(p.poiList.pois.map(y=>W(O({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(b==="no_data"){c([]);return}x.message.error(n("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),A=v=>{const b=a.find(p=>p.value===v);b!=null&&b.location&&t(b.location)};return i.jsx("div",{className:r.css`
|
|
11
|
-
position: absolute;
|
|
12
|
-
top: 10px;
|
|
13
|
-
left: 10px;
|
|
14
|
-
z-index: 10;
|
|
15
|
-
width: calc(100% - 20px);
|
|
16
|
-
`,children:i.jsx(x.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:n("Enter keywords to search"),filterOption:!1,onSearch:g,onSelect:A,options:a,popupMatchSelectWidth:!1})})},Ie={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"}},ke=h.forwardRef((e,o)=>{const{accessKey:t,securityJsCode:n}=Pe(e.mapType)||{},{value:l,onChange:a,block:c=!1,readonly:g,disabled:A=c,zoom:v=13,overlayCommonOptions:b}=e,{t:p}=Y(),y=z.useFieldSchema(),d=h.useRef(),f=h.useRef(),C=h.useRef(),[L,B]=h.useState([]),[w,U]=h.useState(""),{getField:q}=r.useCollection_deprecated(),K=h.useMemo(()=>{if(e.type)return e.type;const s=q(y==null?void 0:y.name);return s==null?void 0:s.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),V=h.useRef(),P=h.useRef(null),Q=r.useNavigateNoUpdate(),J=h.useRef(`nocobase-map-${K||""}-${Date.now().toString(32)}`),{modal:fe}=x.App.useApp(),re=Ne(),[H]=h.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},b));h.useEffect(()=>{f.current&&f.current.setZoom(v)},[v]);const ce=G.useMemoizedFn(()=>{V.current&&V.current.remove()}),$=G.useMemoizedFn(()=>{(!A||c)&&K!=="point"&&P.current&&(P.current.setTarget(V.current),P.current.open())}),ne=G.useMemoizedFn((s,u=!1)=>{let m=null;if(K==="point"){const{lat:M,lng:F}=s.getPosition();m=[F,M]}else if(K==="polygon"||K==="lineString"){if(m=s.getPath().map(M=>[M.lng,M.lat]),m.length<2)return}else if(K==="circle"){const M=s.getCenter(),F=s.getRadius();m=[M.lng,M.lat,F]}u||(ce(),V.current=s,$()),a==null||a(m)}),te=G.useMemoizedFn((s=K)=>{const u=Ie[s];if(u&&"editor"in u&&!P.current)return P.current=new d.current[u.editor](f.current,null,{createOptions:H,editOptions:H,controlPoint:W(O({},H),{strokeWeight:3}),midControlPoint:W(O({},H),{strokeWeight:2,fillColor:"#fff"})}),P.current.on("adjust",function({target:m}){ne(m,!0)}),P.current.on("move",function({target:m}){ne(m,!0)}),P.current}),R=G.useMemoizedFn((s=K)=>{var m;if(!C.current||(m=P.current)!=null&&m.getTarget())return;const u=Ie[s];u&&C.current[u.mouseTool](O({},H))}),se=G.useMemoizedFn((s=K)=>{C.current||(C.current=new d.current.MouseTool(f.current),C.current.on("draw",function({obj:u}){ne(u)}),R(s))}),I=(s,u)=>{f.current&&f.current.setZoomAndCenter(18,s,u)},_=()=>{const s=()=>{ce(),P.current&&(P.current.setTarget(),P.current.close()),a==null||a(null)};fe.confirm({title:p("Clear the canvas"),content:p("Are you sure to clear the canvas?"),okText:p("Confirm"),cancelText:p("Cancel"),getContainer:()=>document.getElementById(J.current),onOk(){s()}})},N=()=>{V.current&&f.current.setFitView([V.current])},Z=h.useCallback((s=K,u=l,m)=>{const M=Ie[s];if(!M)return;const F=O(O({},H),m);return"transformOptions"in M?Object.assign(F,M.transformOptions(u)):"propertyKey"in M&&(F[M.propertyKey]=u),new d.current[M.overlay](F)},[H]),S=(s=K,u=l,m)=>{if(!d.current)return;const M=Z(s,u,m);return M.setMap(f.current),M};h.useEffect(()=>{if(!d.current||!l||!g&&V.current)return;const s=S();f.current.setFitView([s]),V.current=s,A||(te(),$())},[l,L,K,H,A,g]),h.useEffect(()=>{var s,u,m;C.current&&(A?((s=C.current)==null||s.close(),(u=P.current)==null||u.close()):(R(),(m=P.current)==null||m.open()))},[A]),h.useEffect(()=>{!d.current||!K||A||(se(),te())},[A,L,K]),h.useEffect(()=>{var u,m;if(!l&&(C.current||P.current)&&(ce(),P.current&&(P.current.setTarget(),P.current.close()),a==null||a(null)),!C.current||!P.current)return;P.current.getTarget()?(m=(u=C.current).close)==null||m.call(u):R()},[K,l]),h.useEffect(()=>{if(!t||f.current)return;n&&(window._AMapSecurityConfig={[n.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:n});const s=window.define;if(window.define=void 0,window.AMap)try{requestIdleCallback(()=>{f.current=new AMap.Map(J.current,{resizeEnable:!0,zoom:v}),d.current=AMap,U(""),B([])});return}catch(u){U(u)}return Ue.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(u=>(window.define=s,requestIdleCallback(()=>{f.current=new u.Map(J.current,{resizeEnable:!0,zoom:v}),d.current=u,U(""),B([])}))).catch(u=>{typeof u=="string"?u.includes("多个不一致的 key")?U(p("The AccessKey is incorrect, please check it")):U(u):(u==null?void 0:u.type)==="error"&&U("Something went wrong, please refresh the page and try again")}),()=>{var u;(u=f.current)==null||u.destroy(),d.current=null,f.current=null,C.current=null,P.current=null,Ue.reset()}},[t,K,n]),h.useImperativeHandle(o,()=>({setOverlay:S,getOverlay:Z,createMouseTool:se,createEditor:te,executeMouseTool:R,aMap:d.current,map:f.current,overlay:V.current,mouseTool:()=>C.current,editor:()=>P.current,errMessage:w}));const T=r.useApp();return!t||w?i.jsx(x.Alert,{action:i.jsx(x.Button,{type:"primary",onClick:()=>Q(T.pluginSettingsManager.getRoutePath("map")),children:p("Go to the configuration page")}),message:w||p("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):i.jsxs("div",{className:r.css`
|
|
17
|
-
position: relative;
|
|
18
|
-
height: ${re||500}px !important;
|
|
19
|
-
`,id:J.current,style:e==null?void 0:e.style,children:[!d.current&&i.jsx("div",{className:r.css`
|
|
20
|
-
position: absolute;
|
|
21
|
-
inset: 0;
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
`,children:i.jsx(x.Spin,{})}),A?null:i.jsxs(i.Fragment,{children:[i.jsx(it,{toCenter:I,aMap:d.current}),i.jsx("div",{className:r.css`
|
|
26
|
-
position: absolute;
|
|
27
|
-
bottom: 80px;
|
|
28
|
-
right: 20px;
|
|
29
|
-
z-index: 10;
|
|
30
|
-
`,children:i.jsx(x.Button,{onClick:N,disabled:!V.current,type:"primary",shape:"round",size:"large",icon:i.jsx(ee.SyncOutlined,{})})}),K!=="point"?i.jsx("div",{className:r.css`
|
|
31
|
-
position: absolute;
|
|
32
|
-
bottom: 20px;
|
|
33
|
-
left: 10px;
|
|
34
|
-
z-index: 2;
|
|
35
|
-
pointer-events: none;
|
|
36
|
-
`,children:i.jsx(x.Alert,{message:p("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,i.jsx("div",{className:r.css`
|
|
37
|
-
position: absolute;
|
|
38
|
-
bottom: 20px;
|
|
39
|
-
right: 20px;
|
|
40
|
-
z-index: 2;
|
|
41
|
-
`,children:i.jsx(x.Button,{disabled:!l,style:{height:"40px"},onClick:_,type:"primary",danger:!0,children:p("Clear")})})]})]})});ke.displayName="AMapComponent";const at=e=>{var se,I,_,N,Z;const{collectionField:o,fieldNames:t,dataSource:n,fixedBlock:l,zoom:a,setSelectedRecordKeys:c,lineSort:g}=r.useProps(e),{name:A,getPrimaryKey:v}=r.useCollection_deprecated(),{getCollectionJoinField:b}=r.useCollectionManager_deprecated(),p=v(),[y,d]=h.useState(!1),f=h.useRef(),C=(I=(se=f.current)==null?void 0:se.aMap)==null?void 0:I.GeometryUtil,[L,B]=h.useState(),[w,U]=h.useState(""),{t:q}=Y(),K=r.useCompile(),{isConnected:V,doFilter:P}=r.useFilterAPI(),[,Q]=h.useState(null),J=h.useRef(w);J.current=w;const{fields:fe}=r.useCollection(),re=r.useCollectionParentRecordData(),{openPopup:H}=r.usePopupUtils(),ce=(_=fe.find(S=>S.name===(t==null?void 0:t.marker)))==null?void 0:_.uiSchema,$=(S,T)=>{const s=S.getExtData(),u=typeof T=="undefined"?s.selected:!T;s.selected=!u,"setIcon"in S&&S.setIcon(new f.current.aMap.Icon({imageSize:[19,32],image:u?ge:Se})),S.setOptions(O({extData:s},u?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},ne=()=>{var S,T,s;f.current&&((S=f.current)==null||S.mouseTool().close(!0),(T=f.current)==null||T.editor().setTarget(null),(s=f.current)==null||s.editor().close())};h.useEffect(()=>{var S,T,s,u;if(w==="selection")return(S=f.current)!=null&&S.editor()?(u=f.current)==null||u.executeMouseTool("polygon"):((T=f.current)==null||T.createEditor("polygon"),(s=f.current)==null||s.createMouseTool("polygon")),()=>{ne()}},[w]),h.useEffect(()=>{if(w)return()=>{var S;J.current||(S=f.current)==null||S.map.getAllOverlays().forEach(T=>{$(T,!1)})}},[w]);const te=G.useMemoizedFn(()=>{var m,M,F;const S=(m=f.current)==null?void 0:m.editor().getTarget(),T=(M=f.current)==null?void 0:M.map.getAllOverlays(),s=T==null?void 0:T.filter(k=>{if(!(k===S||k.getExtData().id===void 0))return"getPosition"in k?C.isPointInRing(k.getPosition(),S==null?void 0:S.getPath()):C.doesRingRingIntersect(k.getPath(),S==null?void 0:S.getPath())}),u=s==null?void 0:s.map(k=>($(k,!0),k.getExtData().id));c(k=>u==null?void 0:u.concat(k)),S==null||S.remove(),(F=f.current)==null||F.editor().close()});h.useEffect(()=>{var m,M,F;if(!o||!f.current||!n)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,T=b([A,...S].flat().join(".")),s=n.map(k=>{var pe;const j=(pe=ze(k,t==null?void 0:t.field,T==null?void 0:T.interface))==null?void 0:pe.filter(Boolean),ie=r.getLabelFormatValue(ce,k[t.marker]);return j!=null&&j.length?j.map(ae=>{var oe;return(oe=f.current)==null?void 0:oe.setOverlay(o.type,ae,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?K(ie):void 0},extData:{id:k[p]}})}):[]}).flat().filter(Boolean);(M=(m=f.current)==null?void 0:m.map)==null||M.setFitView(s);const u=s.map(k=>{const j=ie=>{const pe=ie.target,ae=pe.getExtData();if(!ae)return;if(J.current){J.current==="click"&&(c(oe=>ae.selected?oe.filter(Le=>Le!==ae.id):[...oe,ae.id]),$(pe));return}const ye=n.find(oe=>ae.id===oe[p]);if(V){Q(oe=>(oe&&Ge(oe),oe===k?(Ge(k),P(null),null):(lt(k),P(ye[p],Le=>Le.field||p,"$eq"),k)));return}ye&&(B(ye),H({recordData:ye}))};return k.on("click",j),()=>k.off("click",j)});if(o.type==="point"&&(g!=null&&g.length)&&(s==null?void 0:s.length)>1){const k=s.map(ie=>ie.getPosition());s[0].setzIndex(13),s[s.length-1].setzIndex(13);const j=(ie=!0)=>{var pe,ae;if((pe=f.current)!=null&&pe.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:q(ie?"Start point":"End point")},position:k[ie?0:k.length-1],map:(ae=f.current)==null?void 0:ae.map})};s.push(...[(F=f.current)==null?void 0:F.setOverlay("lineString",k,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),j(),j(!1)].filter(Boolean))}return()=>{s.forEach(k=>{k.remove()}),u.forEach(k=>k())}},[n,y,t,A,p,o.type,V,g,H]),h.useEffect(()=>{setTimeout(()=>{c([])})},[n]);const R=S=>{f.current=S,d(!!(S!=null&&S.map)&&!S.errMessage)};return i.jsxs("div",{className:r.css`
|
|
42
|
-
position: relative;
|
|
43
|
-
height: 100%;
|
|
44
|
-
`,children:[i.jsx("div",{className:r.css`
|
|
45
|
-
position: absolute;
|
|
46
|
-
left: 10px;
|
|
47
|
-
top: 10px;
|
|
48
|
-
z-index: 999;
|
|
49
|
-
`,children:y&&!((N=f.current)!=null&&N.errMessage)?i.jsxs(x.Space,{direction:"vertical",children:[i.jsx(x.Button,{style:{color:w?void 0:"#F18b62",borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),U("")},icon:i.jsx(ee.EnvironmentOutlined,{})}),i.jsx(x.Button,{style:{color:w==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),U("selection")},icon:i.jsx(ee.ExpandOutlined,{})}),w==="selection"?i.jsx(x.Button,{type:"primary",icon:i.jsx(ee.CheckOutlined,{}),title:q("Confirm selection"),onClick:te}):null]}):null}),i.jsx(r.RecordProvider,{record:L,parent:re,children:i.jsx(xe,{})}),i.jsx(ke,W(O({},(Z=o==null?void 0:o.uiSchema)==null?void 0:Z["x-component-props"]),{ref:R,style:{height:l?"100%":null},zoom:a,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})};function Ge(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function lt(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 je=({type:e,children:o})=>{const{t}=Y(),[n,l]=G.useBoolean(!1),a=r.useAPIClient(),[c]=x.Form.useForm(),g=Pe(e);h.useEffect(()=>{g&&(c.setFieldsValue(g),l.toggle())},[g]);const A=h.useMemo(()=>a.resource(Ke),[a]),v=b=>{A.set(W(O({},b),{type:e})).then(p=>{sessionStorage.removeItem(we(e)),l.toggle(),x.message.success(t("Saved successfully"))}).catch(p=>{x.message.success(t("Saved failed"))})};return i.jsxs(x.Form,{disabled:n,form:c,layout:"vertical",onFinish:v,children:[o,n?i.jsx(x.Button,{disabled:!1,onClick:l.toggle,children:t("Edit")}):i.jsx(x.Form.Item,{children:i.jsx(x.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},ct={amap:()=>{const{t:e}=Y();return i.jsxs(je,{type:"amap",children:[i.jsx(x.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:i.jsx(x.Input,{})}),i.jsx(x.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:i.jsx(x.Input,{})})]})},google:()=>{const{t:e}=Y();return i.jsx(je,{type:"google",children:i.jsx(x.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:i.jsx(x.Input,{})})})}},pt=Te.map(e=>W(O({},e),{component:ct[e.value]})),ut=()=>{const e=r.useCompile(),o=r.useLocationSearch(),t=new URLSearchParams(o);return i.jsx(x.Card,{bordered:!0,children:i.jsx(x.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:pt.map(n=>i.jsx(x.Tabs.TabPane,{tab:e(n.label),children:i.jsx(n.component,{type:n.value})},n.value))})})};/*! *****************************************************************************
|
|
50
|
-
Copyright (c) Microsoft Corporation.
|
|
51
|
-
|
|
52
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
53
|
-
purpose with or without fee is hereby granted.
|
|
54
|
-
|
|
55
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
56
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
57
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
58
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
59
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
60
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
61
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
62
|
-
***************************************************************************** */function dt(e,o,t,n){function l(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function g(b){try{v(n.next(b))}catch(p){c(p)}}function A(b){try{v(n.throw(b))}catch(p){c(p)}}function v(b){b.done?a(b.value):l(b.value).then(g,A)}v((n=n.apply(e,[])).next())})}var ft=function e(o,t){if(o===t)return!0;if(o&&t&&typeof o=="object"&&typeof t=="object"){if(o.constructor!==t.constructor)return!1;var n,l,a;if(Array.isArray(o)){if(n=o.length,n!=t.length)return!1;for(l=n;l--!==0;)if(!e(o[l],t[l]))return!1;return!0}if(o.constructor===RegExp)return o.source===t.source&&o.flags===t.flags;if(o.valueOf!==Object.prototype.valueOf)return o.valueOf()===t.valueOf();if(o.toString!==Object.prototype.toString)return o.toString()===t.toString();if(a=Object.keys(o),n=a.length,n!==Object.keys(t).length)return!1;for(l=n;l--!==0;)if(!Object.prototype.hasOwnProperty.call(t,a[l]))return!1;for(l=n;l--!==0;){var c=a[l];if(!e(o[c],t[c]))return!1}return!0}return o!==o&&t!==t};const qe="__googleMapsScriptId";var he;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(he||(he={}));class ue{constructor({apiKey:o,authReferrerPolicy:t,channel:n,client:l,id:a=qe,language:c,libraries:g=[],mapIds:A,nonce:v,region:b,retries:p=3,url:y="https://maps.googleapis.com/maps/api/js",version:d}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=o,this.authReferrerPolicy=t,this.channel=n,this.client=l,this.id=a||qe,this.language=c,this.libraries=g,this.mapIds=A,this.nonce=v,this.region=b,this.retries=p,this.url=y,this.version=d,ue.instance){if(!ft(this.options,ue.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ue.instance.options)}`);return ue.instance}ue.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?he.FAILURE:this.done?he.SUCCESS:this.loading?he.LOADING:he.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let o=this.url;return o+="?callback=__googleMapsCallback",this.apiKey&&(o+=`&key=${this.apiKey}`),this.channel&&(o+=`&channel=${this.channel}`),this.client&&(o+=`&client=${this.client}`),this.libraries.length>0&&(o+=`&libraries=${this.libraries.join(",")}`),this.language&&(o+=`&language=${this.language}`),this.region&&(o+=`®ion=${this.region}`),this.version&&(o+=`&v=${this.version}`),this.mapIds&&(o+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(o+=`&auth_referrer_policy=${this.authReferrerPolicy}`),o}deleteScript(){const o=document.getElementById(this.id);o&&o.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((o,t)=>{this.loadCallback(n=>{n?t(n.error):o(window.google)})})}importLibrary(o){return this.execute(),google.maps.importLibrary(o)}loadCallback(o){this.callbacks.push(o),this.execute()}setScript(){var o,t;if(document.getElementById(this.id)){this.callback();return}const n={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(n).forEach(a=>!n[a]&&delete n[a]),!((t=(o=window==null?void 0:window.google)===null||o===void 0?void 0:o.maps)===null||t===void 0)&&t.importLibrary||(a=>{let c,g,A,v="The Google Maps JavaScript API",b="google",p="importLibrary",y="__ib__",d=document,f=window;f=f[b]||(f[b]={});const C=f.maps||(f.maps={}),L=new Set,B=new URLSearchParams,w=()=>c||(c=new Promise((U,q)=>dt(this,void 0,void 0,function*(){var K;yield g=d.createElement("script"),g.id=this.id,B.set("libraries",[...L]+"");for(A in a)B.set(A.replace(/[A-Z]/g,V=>"_"+V[0].toLowerCase()),a[A]);B.set("callback",b+".maps."+y),g.src=this.url+"?"+B,C[y]=U,g.onerror=()=>c=q(Error(v+" could not load.")),g.nonce=this.nonce||((K=d.querySelector("script[nonce]"))===null||K===void 0?void 0:K.nonce)||"",d.head.append(g)})));C[p]?console.warn(v+" only loads once. Ignoring:",a):C[p]=(U,...q)=>L.add(U)&&w().then(()=>C[p](U,...q))})(n);const l=this.libraries.map(a=>this.importLibrary(a));l.length||l.push(this.importLibrary("core")),Promise.all(l).then(()=>this.callback(),a=>{const c=new ErrorEvent("error",{error:a});this.loadErrorCallback(c)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(o){if(this.errors.push(o),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=o,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(o=>{o(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 mt=e=>{const{toCenter:o,mapRef:t}=e,{t:n}=Y(),l=h.useRef(),[a,c]=h.useState([]);h.useEffect(()=>{google.maps.importLibrary("places").then(v=>{l.current=new v.AutocompleteService}).catch(()=>{x.message.error("Please configure the Google API Key correctly")})},[t]);const{run:g}=G.useDebounceFn(v=>{l.current&&l.current.getPlacePredictions({input:v||" "},(b,p)=>{if(p===google.maps.places.PlacesServiceStatus.OK)c(b.map(y=>{const d=y.structured_formatting;return W(O({},y),{label:`${d.main_text}${d.secondary_text?" "+d.secondary_text:""}`,value:y.place_id})}));else{c([]);return}})},{wait:300}),A=v=>{const b=a.find(y=>y.value===v);new google.maps.places.PlacesService(t.current).getDetails({placeId:b.place_id,fields:["geometry"]},(y,d)=>{d===google.maps.places.PlacesServiceStatus.OK&&o(y.geometry.location)})};return i.jsx("div",{className:r.css`
|
|
63
|
-
position: absolute;
|
|
64
|
-
top: 10px;
|
|
65
|
-
left: 10px;
|
|
66
|
-
z-index: 10;
|
|
67
|
-
width: calc(100% - 20px);
|
|
68
|
-
`,children:i.jsx(x.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:n("Enter keywords to search"),filterOption:!1,onSearch:g,onSelect:A,options:a})})},de=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),gt=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:n,longitude:l}=t.coords;e({lat:n,lng:l})},()=>{o()},{timeout:2e3,maximumAge:0}):o()}),ht=e=>e==="point"?"marker":e==="lineString"?"polyline":e,yt={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"}},Fe=h.forwardRef((e,o)=>{const{value:t,onChange:n,block:l=!1,readonly:a,disabled:c=l,zoom:g=13,overlayCommonOptions:A}=e,{accessKey:v}=Pe(e.mapType)||{},{t:b}=Y(),{getField:p}=r.useCollection_deprecated(),y=z.useFieldSchema(),d=h.useRef(),f=h.useRef(),C=h.useRef(),[L,B]=h.useState([]),[w,U]=h.useState(""),q=r.useAPIClient(),{modal:K}=x.App.useApp(),V=Ne();h.useEffect(()=>{f.current&&f.current.setZoom(g)},[g]);const P=h.useMemo(()=>{if(e.type)return e.type;const s=p(y==null?void 0:y.name);return s==null?void 0:s.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),Q=h.useRef(ht(P)),[J]=h.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!c,draggable:!c},A)),fe=r.useNavigateNoUpdate(),re=h.useRef(),H=h.useRef(new Set),ce=G.useMemoizedFn(s=>{if(H.current.forEach(u=>{H.current.delete(u)}),"getPath"in s){const u=s.getPath();["insert_at","remove_at","set_at"].forEach(m=>{H.current.add(u.addListener(m,()=>{I(s,!0)}).remove)})}else s instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(u=>{H.current.add(s.addListener(u,()=>{I(s,!0)}).remove)})}),$=G.useMemoizedFn(()=>{var s;C.current&&(C.current.unbindAll(),C.current.setMap(null)),P!=="point"&&((s=d.current)==null||s.setDrawingMode(null))}),ne=G.useMemoizedFn(s=>{var u,m;f.current&&s&&((u=f.current)==null||u.setCenter(s),(m=f.current)==null||m.setZoom(g))}),te=G.useMemoizedFn(s=>{$(),ce(s),C.current=s}),R=G.useMemoizedFn(s=>{var m,M;const u=new google.maps.LatLngBounds;s.forEach(F=>{if(F instanceof google.maps.Marker)u.extend(F.getPosition());else if(F instanceof google.maps.Polyline||F instanceof google.maps.Polygon){const k=F.getPath();for(let j=0;j<k.getLength();j++)u.extend(k.getAt(j))}else F instanceof google.maps.Circle&&u.union(F.getBounds())}),(M=(m=f.current)==null?void 0:m.setCenter)==null||M.call(m,u.getCenter())}),se=()=>{C.current&&R([C.current])},I=G.useMemoizedFn((s,u=!1)=>{let m=null;if(P==="point"){const{lat:M,lng:F}=s.getPosition();m=[F(),M()]}else if(P==="polygon"||P==="lineString"){if(m=s.getPath().getArray().map(M=>[M.lng(),M.lat()]),m.length<2)return}else if(P==="circle"){const M=s.getCenter(),F=s.getRadius();m=[M.lng(),M.lat(),F]}u||te(s),n==null||n(m)}),_=G.useMemoizedFn((s=!1,u)=>{const m=W(O(O({},J),u),{map:f.current});return d.current=new google.maps.drawing.DrawingManager({drawingMode:Q.current,drawingControl:!1,markerOptions:W(O({},m),{icon:de(ge)}),polygonOptions:m,polylineOptions:m,circleOptions:m,map:f.current}),s||d.current.addListener("overlaycomplete",M=>{const F=M.overlay;I(F)}),d.current}),N=G.useMemoizedFn((s=P,u=t,m)=>{const M=yt[s];if(!M)return;const F=O(W(O({},J),{icon:de(ge)}),m);return"transformOptions"in M?Object.assign(F,M.transformOptions(u)):"propertyKey"in M&&(F[M.propertyKey]=Array.isArray(u[0])?u.map(j=>new google.maps.LatLng(j[1],j[0])):new google.maps.LatLng(u[1],u[0])),new google.maps[M.overlay](F)}),Z=G.useMemoizedFn((s=P,u=t,m)=>f.current?N(s,u,W(O({},m),{map:f.current})):void 0);h.useEffect(()=>{var u,m;if(!t&&f.current&&($(),(m=(u=d==null?void 0:d.current)==null?void 0:u.setDrawingMode)==null||m.call(u,Q.current),n==null||n(null)),!f.current||!t||!a&&C.current)return;const s=Z();te(s),R([s])},[t,L,P,c,a,Z,R,te]),h.useEffect(()=>{if(!v||f.current||!re.current)return;let s;try{s=new ue({apiKey:v,version:"weekly",language:q.auth.getLocale()})}catch(m){U(b("Load google maps failed, Please check the Api key and refresh the page"));return}const u=console.error;return console.error=(m,...M)=>{m!=null&&m.includes("InvalidKeyMapError")&&U(b("Load google maps failed, Please check the Api key and refresh the page")),u(m,...M)},Promise.all([s.importLibrary("drawing"),s.importLibrary("core"),s.importLibrary("geometry")]).then(m=>Ce(this,null,function*(){const M=yield gt();f.current=new google.maps.Map(re.current,{zoom:g,center:M,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),U(""),B([])})).catch(m=>{if(m instanceof Error){U(m.message);return}}),()=>{var m,M;(m=f.current)==null||m.unbindAll(),f.current=null,(M=d.current)==null||M.unbindAll()}},[v,q.auth,P,g]),h.useEffect(()=>{!f.current||!P||c||d.current||_()},[_,c,L,P]),h.useImperativeHandle(o,()=>({setOverlay:Z,getOverlay:N,setFitView:R,createDraw:_,map:f.current,overlay:C.current,drawingManager:d.current,errMessage:w}));const S=G.useMemoizedFn(()=>{const s=()=>{$(),d.current.setDrawingMode(Q.current),n==null||n(null)};K.confirm({title:b("Clear the canvas"),content:b("Are you sure to clear the canvas?"),okText:b("Confirm"),cancelText:b("Cancel"),getContainer:()=>re.current,onOk(){s()}})}),T=r.useApp();return!v||w?i.jsx(x.Alert,{action:i.jsx(x.Button,{type:"primary",onClick:()=>fe(T.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:b("Go to the configuration page")}),message:w||b("Please configure the Api key first"),type:"error"}):i.jsxs("div",{className:r.css`
|
|
69
|
-
position: relative;
|
|
70
|
-
height: ${V||500}px !important;
|
|
71
|
-
`,children:[!f.current&&i.jsx("div",{className:r.css`
|
|
72
|
-
position: absolute;
|
|
73
|
-
inset: 0;
|
|
74
|
-
display: flex;
|
|
75
|
-
align-items: center;
|
|
76
|
-
justify-content: center;
|
|
77
|
-
`,children:i.jsx(x.Spin,{})}),c?null:i.jsxs(i.Fragment,{children:[f.current&&i.jsx(mt,{toCenter:ne,mapRef:f}),i.jsx("div",{className:r.css`
|
|
78
|
-
position: absolute;
|
|
79
|
-
bottom: 80px;
|
|
80
|
-
right: 20px;
|
|
81
|
-
z-index: 10;
|
|
82
|
-
`,children:i.jsx(x.Button,{onClick:se,disabled:!C.current,type:"primary",shape:"round",size:"large",icon:i.jsx(ee.SyncOutlined,{})})}),P==="lineString"||P==="polygon"?i.jsx("div",{className:r.css`
|
|
83
|
-
position: absolute;
|
|
84
|
-
bottom: 20px;
|
|
85
|
-
left: 10px;
|
|
86
|
-
z-index: 2;
|
|
87
|
-
pointer-events: none;
|
|
88
|
-
`,children:i.jsx(x.Alert,{message:b("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,i.jsx("div",{className:r.css`
|
|
89
|
-
position: absolute;
|
|
90
|
-
bottom: 20px;
|
|
91
|
-
right: 20px;
|
|
92
|
-
z-index: 2;
|
|
93
|
-
`,children:i.jsx(x.Button,{disabled:!t,style:{height:"40px"},onClick:S,type:"primary",danger:!0,children:b("Clear")})})]}),i.jsx("div",{ref:re,className:r.css`
|
|
94
|
-
width: 100%;
|
|
95
|
-
height: 100%;
|
|
96
|
-
`,style:e==null?void 0:e.style})]})});Fe.displayName="GoogleMapsComponent";const Me="google-maps-overlay-id",_e="google-maps-overlay-selected",bt=r.css`
|
|
97
|
-
margin-top: 6px;
|
|
98
|
-
padding: 2px 4px;
|
|
99
|
-
background: #fff;
|
|
100
|
-
border: 1px solid #0000f5;
|
|
101
|
-
`,Mt=r.css`
|
|
102
|
-
margin-top: -64px;
|
|
103
|
-
padding: 2px 4px;
|
|
104
|
-
background: #fff;
|
|
105
|
-
border: 1px solid #0000f5;
|
|
106
|
-
`,At=e=>{var se;const{collectionField:o,fieldNames:t,dataSource:n,fixedBlock:l,zoom:a,setSelectedRecordKeys:c,lineSort:g}=r.useProps(e),{getPrimaryKey:A}=r.useCollection_deprecated(),v=A(),{marker:b="id"}=t,[p,y]=h.useState(!1),d=h.useRef(),[f,C]=h.useState(),[L,B]=h.useState(""),{t:w}=Y(),U=r.useCompile(),{isConnected:q,doFilter:K}=r.useFilterAPI(),[,V]=h.useState(null),P=h.useRef(L),Q=h.useRef(null),J=h.useRef([]);P.current=L;const{fields:fe}=r.useCollection(),re=r.useCollectionParentRecordData(),H=(se=fe.find(I=>I.name===(t==null?void 0:t.marker)))==null?void 0:se.uiSchema,{getCollectionJoinField:ce}=r.useCollectionManager_deprecated(),{openPopup:$}=r.usePopupUtils(),ne=(I,_)=>{const N=typeof _!="undefined"?!_:I.get(_e);I.set(_e,!N),I.setOptions(O({},N?{icon:de(ge),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:de(Se),strokeColor:"#F18b62",fillColor:"#F18b62"}))};h.useEffect(()=>{var _,N,Z,S;if(L!=="selection")return;d.current&&!((_=d.current)!=null&&_.drawingManager)&&(d.current.drawingManager=(N=d.current)==null?void 0:N.createDraw(!0,{editable:!0,draggable:!0}));const I=new Set;return(Z=d.current)==null||Z.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(S=d.current)==null||S.drawingManager.addListener("overlaycomplete",T=>{var m;const s=T.overlay;(m=d.current)==null||m.drawingManager.setDrawingMode(null),Q.current=s;const u=s.getPath();["insert_at","remove_at","set_at"].forEach(M=>{I.add(u.addListener(M,()=>{}).remove)})}),()=>{var T,s,u,m;I.forEach(M=>{M()}),d.current&&((T=Q.current)==null||T.unbindAll(),(s=Q.current)==null||s.setMap(null),Q.current=null,(u=d.current)==null||u.drawingManager.setDrawingMode(null),(m=d.current)==null||m.drawingManager.unbindAll())}},[L]),h.useEffect(()=>{if(L)return()=>{P.current||J.current.forEach(I=>{ne(I,!1)})}},[L]);const te=G.useMemoizedFn(()=>{var T;const I=Q.current,_=J.current,N=google.maps.geometry.poly,S=_.filter(s=>{if(!(s===I||s.get(Me)===void 0))return s instanceof google.maps.Marker?N.containsLocation(s.getPosition(),I):s instanceof google.maps.Circle?N.containsLocation(s.getCenter(),I):s.getPath().getArray().some(u=>N.containsLocation(u,I))}).map(s=>(ne(s,!0),s.get(Me)));c(s=>S.concat(s)),I==null||I.unbindAll(),I==null||I.setMap(null),(T=d.current)==null||T.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});h.useEffect(()=>{var S,T;if(!o||!(n!=null&&n.length)||!((S=d.current)!=null&&S.map))return;const I=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,_=ce([name,...I].flat().join(".")),N=n.map(s=>{const u=ze(s,t==null?void 0:t.field,_==null?void 0:_.interface),m=r.getLabelFormatValue(H,s[t.marker]);return u!=null&&u.length?u==null?void 0:u.filter(Boolean).map(M=>{var k;if(!u)return;const F=(k=d.current)==null?void 0:k.setOverlay(o.type,M,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:bt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?U(m):void 0}});return F==null||F.set(Me,s[v]),F}):[]}).flat().filter(Boolean);J.current=N;const Z=N.map(s=>{const u=m=>{const M=s,F=M.get(Me);if(!F)return;const k=n==null?void 0:n.find(j=>F===j[v]);if(q){V(j=>(j&&Ve(M),j===s?(Ve(M),K(null),null):(vt(M),K(k[v],ie=>ie.field||v,"$eq"),M)));return}k&&(C(k),$({recordData:k}))};return s.addListener("click",u),()=>s.unbindAll()});if(o.type==="point"&&(g!=null&&g.length)&&(N==null?void 0:N.length)>1){const s=N.map(m=>m.getPosition());N[0].setZIndex(138),N[N.length-1].setZIndex(138);const u=(m=!0)=>{var M;if((M=d.current)!=null&&M.map)return new google.maps.Marker({label:{className:Mt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:w(m?"Start point":"End point")},icon:de(ge),position:m?s[0]:s[s.length-1],map:d.current.map})};N.push(...[d.current.setOverlay("lineString",s.map(m=>[m.lng(),m.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),u(),u(!1)].filter(Boolean))}return(T=d.current)==null||T.setFitView(N),()=>{N.forEach(s=>{s.setMap(null),s.unbindAll()}),Z.forEach(s=>s())}},[n,p,b,o.type,q,$]),h.useEffect(()=>{setTimeout(()=>{c([])})},[n]);const R=I=>{d.current=I,y(!!(I!=null&&I.map)&&!I.errMessage)};return i.jsxs("div",{className:r.css`
|
|
107
|
-
position: relative;
|
|
108
|
-
height: 100%;
|
|
109
|
-
`,children:[p&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:r.css`
|
|
110
|
-
position: absolute;
|
|
111
|
-
left: 10px;
|
|
112
|
-
top: 10px;
|
|
113
|
-
z-index: 999;
|
|
114
|
-
`,children:i.jsxs(x.Space,{direction:"vertical",children:[i.jsx(x.Button,{style:{color:L?void 0:"#F18b62",borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),B("")},icon:i.jsx(ee.EnvironmentOutlined,{})}),i.jsx(x.Button,{style:{color:L==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),B("selection")},icon:i.jsx(ee.ExpandOutlined,{})}),L==="selection"?i.jsx(x.Button,{type:"primary",icon:i.jsx(ee.CheckOutlined,{}),title:w("Confirm selection"),onClick:te}):null]})}),i.jsx(r.RecordProvider,{record:f,parent:re,children:i.jsx(xe,{})})]}),i.jsx(Fe,W(O({},e),{ref:R,style:{height:l?"100%":null},zoom:a,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})};function Ve(e){if(e instanceof google.maps.Marker)return e.setIcon(de(ge));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function vt(e){if(e instanceof google.maps.Marker)return e.setIcon(de(Se));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const Ct=()=>{var p;const{getCollectionJoinField:e}=r.useCollectionManager_deprecated(),{getField:o}=r.useCollection_deprecated(),{form:t}=r.useFormBlockContext(),n=z.useField(),l=z.useFieldSchema(),{t:a}=Y(),{dn:c,refresh:g}=r.useDesignable(),A=o(l.name)||e(l["x-collection-field"]),v=(p=A==null?void 0:A.uiSchema)==null?void 0:p.title;n.title===v||n.title,n.readPretty||n.required;let b="editable";return l["x-disabled"]===!0&&(b="readonly"),l["x-read-pretty"]===!0&&(b="read-pretty"),i.jsxs(r.GeneralSchemaDesigner,{children:[i.jsx(r.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!r.isPatternDisabled(l)&&i.jsx(r.SchemaSettingsSelectItem,{title:a("Pattern"),options:[{label:a("Editable"),value:"editable"},{label:a("Readonly"),value:"readonly"},{label:a("Easy-reading"),value:"read-pretty"}],value:b,onChange:y=>{const d={"x-uid":l["x-uid"]};switch(y){case"readonly":{l["x-read-pretty"]=!1,l["x-disabled"]=!0,d["x-read-pretty"]=!1,d["x-disabled"]=!0,n.readPretty=!1,n.disabled=!0;break}case"read-pretty":{l["x-read-pretty"]=!0,l["x-disabled"]=!1,d["x-read-pretty"]=!0,d["x-disabled"]=!1,n.readPretty=!0;break}default:{l["x-read-pretty"]=!1,l["x-disabled"]=!1,d["x-read-pretty"]=!1,d["x-disabled"]=!1,n.readPretty=!1,n.disabled=!1;break}}c.emit("patch",{schema:d}),c.refresh()}},"pattern"),i.jsx(r.SchemaSettingsModalItem,{title:a("Set default zoom level"),schema:{type:"object",title:a("Set default zoom level"),properties:{zoom:{title:a("Zoom"),default:n.componentProps.zoom||13,description:a("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:y})=>{y&&(me.set(l,"x-component-props.zoom",y),Object.assign(n.componentProps,l["x-component-props"]),c.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":n.componentProps}})),c.refresh()}},"map-zoom"),i.jsx(r.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:a("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},St={amap:ke,google:Fe},Oe=h.forwardRef((e,o)=>{const{t}=Y(),{mapType:n}=e,l=h.useMemo(()=>St[n],[n]);return l?i.jsx(l,O({ref:o},e)):i.jsx("div",{children:t(`The ${n} cannot found`)})});Oe.displayName="MapComponent";const xt=e=>{var A,v;const{value:o}=e,t=z.useFieldSchema(),l=r.useCollection().getField(t.name),a=e.mapType||((A=l==null?void 0:l.uiSchema["x-component-props"])==null?void 0:A.mapType),c=z.useForm(),g=z.useField();return r.useFieldTitle(),!c.readPretty||g.readPretty?i.jsx("div",{children:i.jsx(r.EllipsisWithTooltip,{ellipsis:!0,children:(v=o==null?void 0:o.map)==null?void 0:v.call(o,b=>Array.isArray(b)?`(${b.join(",")})`:b).join(",")})}):i.jsx(Oe,O({readonly:!0,mapType:a},e))},We=z.connect(e=>i.jsx("div",{className:r.css`
|
|
115
|
-
height: 100%;
|
|
116
|
-
border: 1px solid transparent;
|
|
117
|
-
.ant-formily-item-error & {
|
|
118
|
-
border: 1px solid #ff4d4f;
|
|
119
|
-
}
|
|
120
|
-
`,children:i.jsx(Oe,O({},e))}),z.mapReadPretty(xt));We.Designer=Ct;const wt={amap:at,google:At},Pt=e=>{const{t:o}=Y(),{mapType:t}=e,n=h.useMemo(()=>wt[t],[t]);return n?i.jsx(r.PopupContextProvider,{children:i.jsx(n,O({},e))}):i.jsx("div",{children:o(`The ${t} cannot found`)})},It=r.withDynamicSchemaProps(e=>{var g,A;const{context:o}=r.usePopupUtils();if(o.currentLevel&&!me.isNil((g=o.params)==null?void 0:g.filterbytk))return i.jsx(r.PopupContextProvider,{children:i.jsx(xe,{})});const{fieldNames:t}=r.useProps(e),{getCollectionJoinField:n}=r.useCollectionManager_deprecated(),{name:l}=r.useCollection_deprecated(),a=h.useMemo(()=>n([l,t==null?void 0:t.field].flat().join(".")),[l,t==null?void 0:t.field]),c=(A=a==null?void 0:a.uiSchema)==null?void 0:A["x-component-props"];return i.jsx(Pt,W(O(O({},c),e),{collectionField:a}))}),kt=()=>{const{name:e,title:o}=r.useCollection(),t=r.useSchemaTemplate();return i.jsx(r.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Ft=e=>{const{collectionName:o,fieldNames:t,dataSource:n}=e;return{type:"void","x-acl-action":`${o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:n,action:"list",fieldNames:t,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:map","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"map:configureActions","x-component":"ActionBar","x-component-props":{}},[tt.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",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":"popup:common:addBlock"}}}}}}}}}}}},Ye=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,n,l)=>{const a=t==null?void 0:t.find(c=>c.value===n);return l===e.length-1?a:a==null?void 0:a.children},o)),Ot=()=>{const e=r.useSchemaInitializerItem(),{insert:o}=r.useSchemaInitializer(),t=h.useContext(z.SchemaOptionsContext),{getCollectionFieldsOptions:n}=r.useCollectionManager_deprecated(),{t:l}=Y(),{theme:a}=r.useGlobalTheme();return i.jsx(r.DataBlockInitializer,O({componentType:"Map",icon:i.jsx(ee.TableOutlined,{}),onCreateBlockSchema:g=>Ce(this,[g],function*({item:c}){const A=n(c.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:c.dataSource}),v=n(c.name,"string",{dataSource:c.dataSource}),b=yield r.FormDialog(l("Create map block"),()=>{var p;return i.jsx(r.SchemaComponentOptions,{scope:t.scope,components:O({},t.components),children:i.jsx(et.FormLayout,{layout:"vertical",children:i.jsx(r.SchemaComponent,{schema:{properties:{field:{title:l("Map field"),enum:A,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:A.length?[A[0].value,(p=A[0].children)==null?void 0:p[0].value].filter(y=>y!=null):[]},marker:{title:l("Marker field"),enum:v,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const d=y.form.values.field;if(!(d!=null&&d.length))return;const f=Ye(d,A);f&&(y.hidden=f.type!=="point")}}}}})})})},a).open({initialValues:{}});o(Ft({collectionName:c.name,dataSource:c.dataSource,fieldNames:O({},b)}))}),title:l("Map block")},e))},Ee=h.createContext({});Ee.displayName="MapBlockContext";const Et=e=>{var v;const{fieldNames:o}=e,t=z.useFieldSchema(),n=z.useField(),{resource:l,service:a}=r.useBlockRequestContext(),[c,g]=h.useState([]),{token:A}=x.theme.useToken();return i.jsx(r.FixedBlockWrapper,{children:i.jsx(r.SchemaComponentOptions,{scope:{selectedRecordKeys:c},children:i.jsxs(Ee.Provider,{value:{field:n,service:a,resource:l,fieldNames:o,fixedBlock:(v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fixedBlock,selectedRecordKeys:c,setSelectedRecordKeys:g},children:[" ",i.jsx("div",{className:ot.css`
|
|
121
|
-
.nb-action-bar {
|
|
122
|
-
margin-bottom: ${A.margin}px;
|
|
123
|
-
}
|
|
124
|
-
`,children:e.children})]})})})},Lt=e=>{const{filter:o,parseVariableLoading:t}=r.useParsedFilter({filterOption:e==null?void 0:e.filter});return{params:W(O({},e),{filter:o}),parseVariableLoading:t}},Dt=e=>{const o=z.useField(),{fieldNames:t}=e,{params:n,parseVariableLoading:l}=Lt(e.params);if(l)return null;const a=n.appends||[],{field:c}=t||{};return Array.isArray(c)&&c.length>1&&a.push(c[0]),i.jsx(r.BlockProvider,W(O({name:"map"},e),{runWhenParamsChanged:!0,params:W(O({},n),{appends:a,paginate:!1,sort:o.componentProps.lineSort}),children:i.jsx(Et,O({},e))}))},Ae=()=>h.useContext(Ee),He=()=>{var o,t,n,l,a,c;const e=Ae();return W(O({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((l=(n=e==null?void 0:e.field)==null?void 0:n.componentProps)==null?void 0:l.zoom)||13,lineSort:(c=(a=e==null?void 0:e.field)==null?void 0:a.componentProps)==null?void 0:c.lineSort})},Tt=e=>i.jsx(r.SchemaComponentOptions,{scope:{useMapBlockProps:He},components:{MapBlockInitializer:Ot,MapBlockDesigner:kt,MapBlockProvider:Dt,MapBlock:It},children:e.children}),Je={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{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:()=>r.useActionAvailable("create")},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}},{name:"customRequest",title:'{{t("Custom request")}}',Component:"CustomRequestInitializer",schema:{"x-action":"customize:table:request:global"}}]},Ze=new r.CompatibleSchemaInitializer(O({name:"MapActionInitializers"},Je)),zt=new r.CompatibleSchemaInitializer(O({name:"map:configureActions"},Je),Ze),Xe={name:"defaultZoomLevel",Component:r.SchemaSettingsModalItem,useComponentProps(){var a;const{t:e}=Y(),o=z.useFieldSchema(),t=z.useField(),{dn:n}=r.useDesignable(),l=((a=o==null?void 0:o["x-component-props"])==null?void 0:a.zoom)||13;return{title:e("The default zoom level of the map"),schema:{type:"object",title:e("Set default zoom level"),properties:{zoom:{title:e("Zoom"),default:l,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:c})=>{me.set(o,"x-component-props.zoom",c),t.componentProps.zoom=c,n.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}}),n.refresh()}}},useVisible(){const{fieldSchema:e}=r.useColumnSchema();return!e}},Bt=new r.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:r.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:r.SchemaSettingsBlockHeightItem},{name:"mapField",Component:r.SchemaSettingsCascaderItem,useComponentProps(){var v;const{getCollectionFieldsOptions:e}=r.useCollectionManager_deprecated(),{t:o}=Y(),t=z.useFieldSchema(),n=((v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fieldNames)||{},l=z.useField(),{dn:a}=r.useDesignable(),{service:c}=Ae(),{name:g}=r.useCollection(),A=e(g,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:n.field,options:A,allowClear:!1,onChange:b=>{const p=l.decoratorProps.fieldNames||{};p.field=b,l.decoratorProps.fieldNames=p,t["x-decorator-props"].fieldNames=p,c.refresh(),a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":l.decoratorProps}}),a.refresh()}}}},{name:"markerField",Component:r.SchemaSettingsSelectItem,useComponentProps(){var v;const{t:e}=Y(),o=z.useFieldSchema(),t=((v=o==null?void 0:o["x-decorator-props"])==null?void 0:v.fieldNames)||{},{service:n}=Ae(),l=z.useField(),{dn:a}=r.useDesignable(),{getCollectionFieldsOptions:c}=r.useCollectionManager_deprecated(),{name:g}=r.useCollection(),A=c(g,"string");return{title:e("Marker field"),value:t.marker,options:A,onChange:b=>{const p=l.decoratorProps.fieldNames||{};p.marker=b,l.decoratorProps.fieldNames=p,o["x-decorator-props"].fieldNames=p,n.refresh(),a.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":l.decoratorProps}}),a.refresh()}}},useVisible(){var c,g;const e=z.useFieldSchema(),{getCollectionFieldsOptions:o}=r.useCollectionManager_deprecated(),{name:t}=r.useCollection(),n=((c=e==null?void 0:e["x-decorator-props"])==null?void 0:c.fieldNames)||{},l=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((g=Ye(n.field,l))==null?void 0:g.type)==="point"}},{name:"setDefaultSortingRules",Component:r.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=Y();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},r.setDataLoadingModeSettingsItem,Xe,{name:"dataScope",Component:r.SchemaSettingsDataScope,useComponentProps(){var c,g;const{name:e}=r.useCollection(),o=z.useFieldSchema(),{form:t}=r.useFormBlockContext(),n=z.useField(),{service:l}=Ae(),{dn:a}=r.useDesignable();return{collectionName:e,defaultFilter:((g=(c=o==null?void 0:o["x-decorator-props"])==null?void 0:c.params)==null?void 0:g.filter)||{},form:t,onSubmit:({filter:A})=>{var b,p;const v=n.decoratorProps.params||{};v.filter=A,n.decoratorProps.params=v,o["x-decorator-props"].params=v,(p=(b=l.params)==null?void 0:b[1])!=null&&p.filters,a.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:r.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=Y();return{type:r.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:r.SchemaSettingsTemplate,useComponentProps(){var l,a;const{name:e}=r.useCollection(),o=z.useFieldSchema(),{componentNamePrefix:t}=r.useBlockTemplateContext(),n=((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.resource)||((a=o==null?void 0:o["x-decorator-props"])==null?void 0:a.association);return{componentName:`${t}Map`,collectionName:e,resourceName:n}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:Ut}=r.interfacesProperties;Array.isArray(r.interfacesProperties.type.enum)&&r.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class ve extends r.CollectionFieldInterface{constructor(){super(...arguments);E(this,"properties",W(O({},Ut),{"uiSchema.x-component-props.mapType":{title:X("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:Te}}))}schemaInitialize(t,{block:n}){n==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Kt extends ve{constructor(){super(...arguments);E(this,"name","circle");E(this,"type","object");E(this,"group","map");E(this,"order",3);E(this,"title",X("Circle"));E(this,"availableTypes",["circle","json"]);E(this,"description",X("Circle"));E(this,"sortable",!0);E(this,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Nt extends ve{constructor(){super(...arguments);E(this,"name","lineString");E(this,"type","object");E(this,"group","map");E(this,"order",2);E(this,"title",X("Line"));E(this,"description",X("Line"));E(this,"availableTypes",["lineString","json"]);E(this,"sortable",!0);E(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Gt extends ve{constructor(){super(...arguments);E(this,"name","point");E(this,"type","object");E(this,"group","map");E(this,"order",1);E(this,"title",X("Point"));E(this,"description",X("Point"));E(this,"availableTypes",["point","json"]);E(this,"sortable",!0);E(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class jt extends ve{constructor(){super(...arguments);E(this,"name","polygon");E(this,"type","object");E(this,"group","map");E(this,"order",4);E(this,"title",X("Polygon"));E(this,"description",X("Polygon"));E(this,"availableTypes",["polygon","json"]);E(this,"sortable",!0);E(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const qt=[Gt,jt,Nt,Kt],_t=new r.SchemaSettings({name:"fieldSettings:component:Map",items:[Xe]}),Qe=h.memo(e=>i.jsx(r.SchemaComponentOptions,{components:{Map:We},children:i.jsx(Tt,{children:e.children})}));Qe.displayName="MapProvider";class $e extends r.Plugin{load(){return Ce(this,null,function*(){this.app.use(Qe),this.app.dataSourceManager.addFieldInterfaces(qt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:X("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(Ze),this.app.schemaInitializerManager.add(zt),this.schemaSettingsManager.add(Bt),this.schemaSettingsManager.add(_t);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:X("Map"),Component:"MapBlockInitializer"}),this.app.schemaInitializerManager.addItem("mobile:addBlock","dataBlocks.map",{title:X("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(be,{title:`{{t("Map Manager", { ns: "${be}" })}}`,icon:"EnvironmentOutlined",Component:ut,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:He})})}}D.PluginMapClient=$e,D.default=$e,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("react"),require("@formily/antd-v5"),require("react-i18next"),require("lodash"),require("ahooks"),require("antd"),require("@formily/shared"),require("@emotion/css")):"function"==typeof define&&define.amd?define("@nocobase/plugin-map",["@nocobase/client","@ant-design/icons","@formily/react","react","@formily/antd-v5","react-i18next","lodash","ahooks","antd","@formily/shared","@emotion/css"],t):"object"==typeof exports?exports["@nocobase/plugin-map"]=t(require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("react"),require("@formily/antd-v5"),require("react-i18next"),require("lodash"),require("ahooks"),require("antd"),require("@formily/shared"),require("@emotion/css")):e["@nocobase/plugin-map"]=t(e["@nocobase/client"],e["@ant-design/icons"],e["@formily/react"],e.react,e["@formily/antd-v5"],e["react-i18next"],e.lodash,e.ahooks,e.antd,e["@formily/shared"],e["@emotion/css"])}(self,function(e,t,n,r,o,i,a,l,c,u,s){return function(){var p={49:function(e){"use strict";var t,n;t=0,n=function(){function e(e){var t=[];return e.AMapUI&&t.push(function(e){return new Promise(function(t,a){var l=[];if(e.plugins)for(var c=0;c<e.plugins.length;c+=1)-1==r.AMapUI.plugins.indexOf(e.plugins[c])&&l.push(e.plugins[c]);if(o.AMapUI===n.failed)a("前次请求 AMapUI 失败");else if(o.AMapUI===n.notload){o.AMapUI=n.loading,r.AMapUI.version=e.version||r.AMapUI.version,c=r.AMapUI.version;var u=document.body||document.head,s=document.createElement("script");s.type="text/javascript",s.src="https://webapi.amap.com/ui/"+c+"/main.js",s.onerror=function(e){o.AMapUI=n.failed,a("请求 AMapUI 失败")},s.onload=function(){if(o.AMapUI=n.loaded,l.length)window.AMapUI.loadUI(l,function(){for(var e=0,n=l.length;e<n;e++){var r=l[e].split("/").slice(-1)[0];window.AMapUI[r]=arguments[e]}for(t();i.AMapUI.length;)i.AMapUI.splice(0,1)[0]()});else for(t();i.AMapUI.length;)i.AMapUI.splice(0,1)[0]()},u.appendChild(s)}else o.AMapUI===n.loaded?e.version&&e.version!==r.AMapUI.version?a("不允许多个版本 AMapUI 混用"):l.length?window.AMapUI.loadUI(l,function(){for(var e=0,n=l.length;e<n;e++){var r=l[e].split("/").slice(-1)[0];window.AMapUI[r]=arguments[e]}t()}):t():e.version&&e.version!==r.AMapUI.version?a("不允许多个版本 AMapUI 混用"):i.AMapUI.push(function(e){e?a(e):l.length?window.AMapUI.loadUI(l,function(){for(var e=0,n=l.length;e<n;e++){var r=l[e].split("/").slice(-1)[0];window.AMapUI[r]=arguments[e]}t()}):t()})})}(e.AMapUI)),e.Loca&&t.push(function(e){return new Promise(function(t,a){if(o.Loca===n.failed)a("前次请求 Loca 失败");else if(o.Loca===n.notload){o.Loca=n.loading,r.Loca.version=e.version||r.Loca.version;var l=r.Loca.version,c=r.AMap.version.startsWith("2"),u=l.startsWith("2");if(c&&!u||!c&&u)a("JSAPI 与 Loca 版本不对应!!");else{c=r.key,u=document.body||document.head;var s=document.createElement("script");s.type="text/javascript",s.src="https://webapi.amap.com/loca?v="+l+"&key="+c,s.onerror=function(e){o.Loca=n.failed,a("请求 AMapUI 失败")},s.onload=function(){for(o.Loca=n.loaded,t();i.Loca.length;)i.Loca.splice(0,1)[0]()},u.appendChild(s)}}else o.Loca===n.loaded?e.version&&e.version!==r.Loca.version?a("不允许多个版本 Loca 混用"):t():e.version&&e.version!==r.Loca.version?a("不允许多个版本 Loca 混用"):i.Loca.push(function(e){e?a(e):a()})})}(e.Loca)),Promise.all(t)}if(!window)throw Error("AMap JSAPI can only be used in Browser.");(t=n||(n={})).notload="notload",t.loading="loading",t.loaded="loaded",t.failed="failed";var t,n,r={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},o={AMap:n.notload,AMapUI:n.notload,Loca:n.notload},i={AMap:[],AMapUI:[],Loca:[]},a=[],l=function(e){"function"==typeof e&&(o.AMap===n.loaded?e(window.AMap):a.push(e))};return{load:function(t){return new Promise(function(i,c){if(o.AMap==n.failed)c("");else if(o.AMap==n.notload){var u=t.key,s=t.version,p=t.plugins;u?(window.AMap&&"lbs.amap.com"!==location.host&&c("禁止多种API加载方式混用"),r.key=u,r.AMap.version=s||r.AMap.version,r.AMap.plugins=p||r.AMap.plugins,o.AMap=n.loading,s=document.body||document.head,window.___onAPILoaded=function(r){if(delete window.___onAPILoaded,r)o.AMap=n.failed,c(r);else for(o.AMap=n.loaded,e(t).then(function(){i(window.AMap)}).catch(c);a.length;)a.splice(0,1)[0]()},(p=document.createElement("script")).type="text/javascript",p.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+r.AMap.version+"&key="+u+"&plugin="+r.AMap.plugins.join(","),p.onerror=function(e){o.AMap=n.failed,c(e)},s.appendChild(p)):c("请填写key")}else if(o.AMap==n.loaded){if(t.key&&t.key!==r.key)c("多个不一致的 key");else if(t.version&&t.version!==r.AMap.version)c("不允许多个版本 JSAPI 混用");else{if(u=[],t.plugins)for(s=0;s<t.plugins.length;s+=1)-1==r.AMap.plugins.indexOf(t.plugins[s])&&u.push(t.plugins[s]);u.length?window.AMap.plugin(u,function(){e(t).then(function(){i(window.AMap)}).catch(c)}):e(t).then(function(){i(window.AMap)}).catch(c)}}else if(t.key&&t.key!==r.key)c("多个不一致的 key");else if(t.version&&t.version!==r.AMap.version)c("不允许多个版本 JSAPI 混用");else{var f=[];if(t.plugins)for(s=0;s<t.plugins.length;s+=1)-1==r.AMap.plugins.indexOf(t.plugins[s])&&f.push(t.plugins[s]);l(function(){f.length?window.AMap.plugin(f,function(){e(t).then(function(){i(window.AMap)}).catch(c)}):e(t).then(function(){i(window.AMap)}).catch(c)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,r={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},o={AMap:n.notload,AMapUI:n.notload,Loca:n.notload},i={AMap:[],AMapUI:[],Loca:[]}}}},e.exports=n()},603:function(e){e.exports={}},700:function(e,t,n){"use strict";n.d(t,{I:function(){return l}});var r=n(505),o=n(772),i=n(156),a=n.n(i),l=function(e){var t=(0,o.useCollectionRecordData)(),n=(0,o.useCollection)(),l=(0,r.useFieldSchema)(),c=(0,i.useMemo)(function(){return l.reduceProperties(function(e,t){return"drawer"===t.name?t:e},null)},[l]);return c?a().createElement(o.VariablePopupRecordProvider,{recordData:t,collection:n},a().createElement(r.RecursionField,{schema:c,name:c.name})):null}},747:function(e,t,n){"use strict";n.r(t),n.d(t,{GoogleMapsBlock:function(){return eN},Configuration:function(){return et},getDrawingMode:function(){return eP},Map:function(){return eZ},AMapComponent:function(){return B},GoogleMapsComponent:function(){return ej},MapComponent:function(){return eW},MapBlockComponent:function(){return eH},AMapBlock:function(){return W}});var r,o,i=n("482"),a=n("772"),l=n("749"),c=n("721"),u=n("156"),s=n.n(u),p=n("130"),f=n("573"),d=function(e,t,n){var r=null==t?void 0:t.reduce(function(e,r,o){return o===t.length-1&&("o2m"===n||"m2m"===n)?null==e?void 0:e.map(function(e){return e[r]}).filter(function(e){return null!=e}):null==e?void 0:e[r]},e);return"o2m"===n||"m2m"===n?r:[r]},m=n("700"),y=n("49"),v=n.n(y);n("603");var g=n("505"),b="map-configuration",h=function(e){return"NOCOBASE_PLUGIN_MAP_CONFIGURATION_".concat(e)},O=function(e){var t=(0,u.useMemo)(function(){var t=sessionStorage.getItem(h(e));return t?JSON.parse(t):t},[e]),n=(0,a.useRequest)({resource:b,action:"get",params:{type:e}},{onSuccess:function(t){sessionStorage.setItem(h(e),JSON.stringify(null==t?void 0:t.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!t}).data;return t?t:null==n?void 0:n.data},w=function(){var e,t,n=(0,a.useDataBlockHeight)(),r=c.theme.useToken().token,o=(0,a.useDesignable)().designable,i=(((0,a.useBlockHeightProps)()||{}).heightProps||{}).title,l=(0,g.useFieldSchema)();if(!!n){var u=Object.keys((null===(t=l.parent)||void 0===t?void 0:null===(e=t.properties.actions)||void 0===e?void 0:e.properties)||{}).length>0;return n-(o||u?r.paddingLG+r.controlHeight+r.margin:r.paddingLG+r.margin)-r.paddingLG-(i?r.fontSizeLG*r.lineHeightLG+2*r.padding-1:0)}};function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function P(){var e,t,n=(e=["\n position: absolute;\n top: 10px;\n left: 10px;\n z-index: 10;\n width: calc(100% - 20px);\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return P=function(){return n},n}var A=function(e){var t,n,r=e.aMap,o=e.toCenter,i=(0,f.jD)().t,p=(0,u.useRef)();var d=(t=(0,u.useState)([]),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(e,t)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=d[0],y=d[1];(0,u.useEffect)(function(){null==r||r.plugin("AMap.PlaceSearch",function(){p.current=new r.PlaceSearch({city:"全国",pageSize:30})})},[r]);var v=(0,l.useDebounceFn)(function(e){if(!!p.current)p.current.search(e||" ",function(e,t){if("complete"===e)y(t.poiList.pois.map(function(e){var t,n;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={label:"".concat(e.name,"-").concat(e.address),value:e.id},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t}));else{if("no_data"===e){y([]);return}c.message.error(i("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}).run;return s().createElement("div",{className:(0,a.css)(P())},s().createElement(c.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:i("Enter keywords to search"),filterOption:!1,onSearch:v,onSelect:function(e){var t=m.find(function(t){return t.value===e});(null==t?void 0:t.location)&&o(t.location)},options:m,popupMatchSelectWidth:!1}))};function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){C(e,t,n[t])})}return e}function x(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function I(){var e=k(["\n position: relative;\n height: ","px !important;\n "]);return I=function(){return e},e}function F(){var e=k(["\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n "]);return F=function(){return e},e}function D(){var e=k(["\n position: absolute;\n bottom: 80px;\n right: 20px;\n z-index: 10;\n "]);return D=function(){return e},e}function z(){var e=k(["\n position: absolute;\n bottom: 20px;\n left: 10px;\n z-index: 2;\n pointer-events: none;\n "]);return z=function(){return e},e}function T(){var e=k(["\n position: absolute;\n bottom: 20px;\n right: 20px;\n z-index: 2;\n "]);return T=function(){return e},e}var L={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:function(e){return{center:e.slice(0,2),radius:e[2]}},overlay:"Circle"}},B=s().forwardRef(function(e,t){var n=O(e.mapType)||{},r=n.accessKey,o=n.securityJsCode,p=e.value,d=e.onChange,m=e.block,y=void 0!==m&&m,b=e.readonly,h=e.disabled,S=void 0===h?y:h,P=e.zoom,j=void 0===P?13:P,k=e.overlayCommonOptions,B=(0,f.jD)().t,R=(0,g.useFieldSchema)(),U=(0,u.useRef)(),_=(0,u.useRef)(),N=(0,u.useRef)(),K=E((0,u.useState)([]),2),G=K[0],q=K[1],V=E((0,u.useState)(""),2),W=V[0],Y=V[1],J=(0,a.useCollection_deprecated)().getField,Z=(0,u.useMemo)(function(){if(e.type)return e.type;var t=J(null==R?void 0:R.name);return null==t?void 0:t.interface},[null==e?void 0:e.type,null==R?void 0:R.name]),X=(0,u.useRef)(),H=(0,u.useRef)(null),Q=(0,a.useNavigateNoUpdate)(),$=(0,u.useRef)("nocobase-map-".concat(Z||"","-").concat(Date.now().toString(32))),ee=c.App.useApp().modal,et=w(),en=E((0,u.useState)(M({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},k)),1)[0];(0,u.useEffect)(function(){_.current&&_.current.setZoom(j)},[j]);var er=(0,l.useMemoizedFn)(function(){X.current&&X.current.remove()}),eo=(0,l.useMemoizedFn)(function(){(!S||y)&&"point"!==Z&&H.current&&(H.current.setTarget(X.current),H.current.open())}),ei=(0,l.useMemoizedFn)(function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=null;if("point"===Z){var r=e.getPosition(),o=r.lat;n=[r.lng,o]}else if("polygon"===Z||"lineString"===Z){if((n=e.getPath().map(function(e){return[e.lng,e.lat]})).length<2)return}else if("circle"===Z){var i=e.getCenter(),a=e.getRadius();n=[i.lng,i.lat,a]}!t&&(er(),X.current=e,eo()),null==d||d(n)}),ea=(0,l.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z,t=L[e];if(t&&"editor"in t&&!H.current)return H.current=new U.current[t.editor](_.current,null,{createOptions:en,editOptions:en,controlPoint:x(M({},en),{strokeWeight:3}),midControlPoint:x(M({},en),{strokeWeight:2,fillColor:"#fff"})}),H.current.on("adjust",function(e){ei(e.target,!0)}),H.current.on("move",function(e){ei(e.target,!0)}),H.current}),el=(0,l.useMemoizedFn)(function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z;if(!(!N.current||(null===(e=H.current)||void 0===e?void 0:e.getTarget()))){var n=L[t];if(!n)return;N.current[n.mouseTool](M({},en))}}),ec=(0,l.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z;!N.current&&(N.current=new U.current.MouseTool(_.current),N.current.on("draw",function(e){ei(e.obj)}),el(e))}),eu=(0,u.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p,n=arguments.length>2?arguments[2]:void 0,r=L[e];if(!!r){var o=M({},en,n);return"transformOptions"in r?Object.assign(o,r.transformOptions(t)):"propertyKey"in r&&(o[r.propertyKey]=t),new U.current[r.overlay](o)}},[en]),es=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p,n=arguments.length>2?arguments[2]:void 0;if(U.current){var r=eu(e,t,n);return r.setMap(_.current),r}};(0,u.useEffect)(function(){if(U.current){if(!!p&&(!!b||!X.current)){var e=es();_.current.setFitView([e]),X.current=e,!S&&(ea(),eo())}}},[p,G,Z,en,S,b]),(0,u.useEffect)(function(){var e,t,n;N.current&&(S?(null===(e=N.current)||void 0===e||e.close(),null===(t=H.current)||void 0===t||t.close()):(el(),null===(n=H.current)||void 0===n||n.open()))},[S]),(0,u.useEffect)(function(){U.current&&Z&&!S&&(ec(),ea())},[S,G,Z]),(0,u.useEffect)(function(){if(!p&&(N.current||H.current)&&(er(),H.current&&(H.current.setTarget(),H.current.close()),null==d||d(null)),N.current&&H.current){var e,t;H.current.getTarget()?null===(e=(t=N.current).close)||void 0===e||e.call(t):el()}},[Z,p]),(0,u.useEffect)(function(){if(r&&!_.current){o&&(window._AMapSecurityConfig=C({},o.endsWith("_AMapService")?"serviceHOST":"securityJsCode",o));var e=window.define;if(window.define=void 0,window.AMap)try{requestIdleCallback(function(){_.current=new AMap.Map($.current,{resizeEnable:!0,zoom:j}),U.current=AMap,Y(""),q([])});return}catch(e){Y(e)}return v().load({key:r,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(function(t){return window.define=e,requestIdleCallback(function(){_.current=new t.Map($.current,{resizeEnable:!0,zoom:j}),U.current=t,Y(""),q([])})}).catch(function(e){"string"==typeof e?e.includes("多个不一致的 key")?Y(B("The AccessKey is incorrect, please check it")):Y(e):(null==e?void 0:e.type)==="error"&&Y("Something went wrong, please refresh the page and try again")}),function(){var e;null===(e=_.current)||void 0===e||e.destroy(),U.current=null,_.current=null,N.current=null,H.current=null,v().reset()}}},[r,Z,o]),(0,u.useImperativeHandle)(t,function(){return{setOverlay:es,getOverlay:eu,createMouseTool:ec,createEditor:ea,executeMouseTool:el,aMap:U.current,map:_.current,overlay:X.current,mouseTool:function(){return N.current},editor:function(){return H.current},errMessage:W}});var ep=(0,a.useApp)();return!r||W?s().createElement(c.Alert,{action:s().createElement(c.Button,{type:"primary",onClick:function(){return Q(ep.pluginSettingsManager.getRoutePath("map"))}},B("Go to the configuration page")),message:W||B("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):s().createElement("div",{className:(0,a.css)(I(),et||500),id:$.current,style:null==e?void 0:e.style},!U.current&&s().createElement("div",{className:(0,a.css)(F())},s().createElement(c.Spin,null)),S?null:s().createElement(s().Fragment,null,s().createElement(A,{toCenter:function(e,t){_.current&&_.current.setZoomAndCenter(18,e,t)},aMap:U.current}),s().createElement("div",{className:(0,a.css)(D())},s().createElement(c.Button,{onClick:function(){X.current&&_.current.setFitView([X.current])},disabled:!X.current,type:"primary",shape:"round",size:"large",icon:s().createElement(i.SyncOutlined,null)})),"point"!==Z?s().createElement("div",{className:(0,a.css)(z())},s().createElement(c.Alert,{message:B("Click to select the starting point and double-click to end the drawing"),type:"info"})):null,s().createElement("div",{className:(0,a.css)(T())},s().createElement(c.Button,{disabled:!p,style:{height:"40px"},onClick:function(){var e=function(){er(),H.current&&(H.current.setTarget(),H.current.close()),null==d||d(null)};ee.confirm({title:B("Clear the canvas"),content:B("Are you sure to clear the canvas?"),okText:B("Confirm"),cancelText:B("Cancel"),getContainer:function(){return document.getElementById($.current)},onOk:function(){e()}})},type:"primary",danger:!0},B("Clear")))))});function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}B.displayName="AMapComponent";function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||G(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function K(e){return function(e){if(Array.isArray(e))return R(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||G(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return R(e,t)}}function q(){var e=N(["\n position: relative;\n height: 100%;\n "]);return q=function(){return e},e}function V(){var e=N(["\n position: absolute;\n left: 10px;\n top: 10px;\n z-index: 999;\n "]);return V=function(){return e},e}var W=function(e){var t,n,r,o,y,v,g,b=(0,a.useProps)(e),h=b.collectionField,O=b.fieldNames,w=b.dataSource,S=b.fixedBlock,P=b.zoom,A=b.setSelectedRecordKeys,j=b.lineSort,C=(0,a.useCollection_deprecated)(),M=C.name,x=C.getPrimaryKey,E=(0,a.useCollectionManager_deprecated)().getCollectionJoinField,k=x(),I=_((0,u.useState)(!1),2),F=I[0],D=I[1],z=(0,u.useRef)(),T=null===(o=z.current)||void 0===o?void 0:null===(r=o.aMap)||void 0===r?void 0:r.GeometryUtil,L=_((0,u.useState)(),2),R=L[0],N=L[1],G=_((0,u.useState)(""),2),W=G[0],J=G[1],Z=(0,f.jD)().t,X=(0,a.useCompile)(),H=(0,a.useFilterAPI)(),Q=H.isConnected,$=H.doFilter,ee=_((0,u.useState)(null),2)[1],et=(0,u.useRef)(W);et.current=W;var en=(0,a.useCollection)().fields,er=(0,a.useCollectionParentRecordData)(),eo=(0,a.usePopupUtils)().openPopup,ei=null===(y=en.find(function(e){return e.name===(null==O?void 0:O.marker)}))||void 0===y?void 0:y.uiSchema,ea=function(e,t){var n=e.getExtData(),r=void 0===t?n.selected:!t;n.selected=!r,"setIcon"in e&&e.setIcon(new z.current.aMap.Icon({imageSize:[19,32],image:r?p.FM:p.F6})),e.setOptions(U({extData:n},r?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},el=function(){var e,t,n;z.current&&(null===(e=z.current)||void 0===e||e.mouseTool().close(!0),null===(t=z.current)||void 0===t||t.editor().setTarget(null),null===(n=z.current)||void 0===n||n.editor().close())};(0,u.useEffect)(function(){var e,t,n,r;if("selection"===W)return(null===(e=z.current)||void 0===e?void 0:e.editor())?null===(r=z.current)||void 0===r||r.executeMouseTool("polygon"):(null===(t=z.current)||void 0===t||t.createEditor("polygon"),null===(n=z.current)||void 0===n||n.createMouseTool("polygon")),function(){el()}},[W]),(0,u.useEffect)(function(){if(W)return function(){if(!et.current){var e;null===(e=z.current)||void 0===e||e.map.getAllOverlays().forEach(function(e){ea(e,!1)})}}},[W]);var ec=(0,l.useMemoizedFn)(function(){var e,t,n,r=null===(e=z.current)||void 0===e?void 0:e.editor().getTarget(),o=null===(t=z.current)||void 0===t?void 0:t.map.getAllOverlays(),i=null==o?void 0:o.filter(function(e){if(e!==r&&void 0!==e.getExtData().id)return"getPosition"in e?T.isPointInRing(e.getPosition(),null==r?void 0:r.getPath()):T.doesRingRingIntersect(e.getPath(),null==r?void 0:r.getPath())}),a=null==i?void 0:i.map(function(e){return ea(e,!0),e.getExtData().id});A(function(e){return null==a?void 0:a.concat(e)}),null==r||r.remove(),null===(n=z.current)||void 0===n||n.editor().close()});(0,u.useEffect)(function(){if(h&&z.current&&w){var e=E([M].concat(K(Array.isArray(null==O?void 0:O.field)&&(null==O?void 0:O.field.length)>1?null==O?void 0:O.field.slice(0,-1):null==O?void 0:O.field)).flat().join(".")),t=w.map(function(t){var n,r=null===(n=d(t,null==O?void 0:O.field,null==e?void 0:e.interface))||void 0===n?void 0:n.filter(Boolean),o=(0,a.getLabelFormatValue)(ei,t[O.marker]);return(null==r?void 0:r.length)?r.map(function(e){var n;return null===(n=z.current)||void 0===n?void 0:n.setOverlay(h.type,e,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:(null==O?void 0:O.marker)?X(o):void 0},extData:{id:t[k]}})}):[]}).flat().filter(Boolean);null===(o=z.current)||void 0===o||null===(r=o.map)||void 0===r||r.setFitView(t);var n=t.map(function(e){var t=function(t){var n=t.target,r=n.getExtData();if(r){if(et.current){"click"===et.current&&(A(function(e){return r.selected?e.filter(function(e){return e!==r.id}):K(e).concat([r.id])}),ea(n));return}var o=w.find(function(e){return r.id===e[k]});if(Q){ee(function(t){return(t&&Y(t),t===e)?(Y(e),$(null),null):(function(e){e.dom?e.dom.style.filter="brightness(1.2) contrast(1.2) hue-rotate(180deg)":e.setOptions&&e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}(e),$(o[k],function(e){return e.field||k},"$eq"),e)});return}o&&(N(o),eo({recordData:o}))}};return e.on("click",t),function(){return e.off("click",t)}});if("point"===h.type&&(null==j?void 0:j.length)&&(null==t?void 0:t.length)>1){var r,o,i,l=t.map(function(e){return e.getPosition()});t[0].setzIndex(13),t[t.length-1].setzIndex(13);var c=function(){var e,t,n=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if(null===(e=z.current)||void 0===e?void 0:e.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:n?Z("Start point"):Z("End point")},position:l[n?0:l.length-1],map:null===(t=z.current)||void 0===t?void 0:t.map})};t.push.apply(t,K([null===(i=z.current)||void 0===i?void 0:i.setOverlay("lineString",l,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),c(),c(!1)].filter(Boolean)))}return function(){t.forEach(function(e){e.remove()}),n.forEach(function(e){return e()})}}},[w,F,O,M,k,h.type,Q,j,eo]),(0,u.useEffect)(function(){setTimeout(function(){A([])})},[w]);return s().createElement("div",{className:(0,a.css)(q())},s().createElement("div",{className:(0,a.css)(V())},!F||(null===(v=z.current)||void 0===v?void 0:v.errMessage)?null:s().createElement(c.Space,{direction:"vertical"},s().createElement(c.Button,{style:{color:W?void 0:"#F18b62",borderColor:"currentcolor"},onClick:function(e){e.stopPropagation(),J("")},icon:s().createElement(i.EnvironmentOutlined,null)}),s().createElement(c.Button,{style:{color:"selection"===W?"#F18b62":void 0,borderColor:"currentcolor"},onClick:function(e){e.stopPropagation(),J("selection")},icon:s().createElement(i.ExpandOutlined,null)}),"selection"===W?s().createElement(c.Button,{type:"primary",icon:s().createElement(i.CheckOutlined,null),title:Z("Confirm selection"),onClick:ec}):null)),s().createElement(a.RecordProvider,{record:R,parent:er},s().createElement(m.I,null)),s().createElement(B,(t=U({},null==h?void 0:null===(g=h.uiSchema)||void 0===g?void 0:g["x-component-props"]),n=(n={ref:function(e){z.current=e,D(!!(null==e?void 0:e.map)&&!e.errMessage)},style:{height:S?"100%":null},zoom:P,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)))};function Y(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function X(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function H(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return J(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return J(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Q=function(e){var t=e.type,n=e.children,r=(0,f.jD)().t,o=H((0,l.useBoolean)(!1),2),i=o[0],p=o[1],d=(0,a.useAPIClient)(),m=H(c.Form.useForm(),1)[0],y=O(t);(0,u.useEffect)(function(){y&&(m.setFieldsValue(y),p.toggle())},[y]);var v=(0,u.useMemo)(function(){return d.resource(b)},[d]);return s().createElement(c.Form,{disabled:i,form:m,layout:"vertical",onFinish:function(e){v.set(X(Z({},e),{type:t})).then(function(e){sessionStorage.removeItem(h(t)),p.toggle(),c.message.success(r("Saved successfully"))}).catch(function(e){c.message.success(r("Saved failed"))})}},n,i?s().createElement(c.Button,{disabled:!1,onClick:p.toggle},r("Edit")):s().createElement(c.Form.Item,null,s().createElement(c.Button,{disabled:!1,type:"primary",htmlType:"submit"},r("Save"))))},$={amap:function(){var e=(0,f.jD)().t;return s().createElement(Q,{type:"amap"},s().createElement(c.Form.Item,{required:!0,name:"accessKey",label:e("Access key")},s().createElement(c.Input,null)),s().createElement(c.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost")},s().createElement(c.Input,null)))},google:function(){var e=(0,f.jD)().t;return s().createElement(Q,{type:"google"},s().createElement(c.Form.Item,{required:!0,name:"accessKey",label:e("Api key")},s().createElement(c.Input,null)))}},ee=p.je.map(function(e){return X(Z({},e),{component:$[e.value]})}),et=function(){var e=(0,a.useCompile)(),t=new URLSearchParams((0,a.useLocationSearch)());return s().createElement(c.Card,{bordered:!0},s().createElement(c.Tabs,{type:"card",defaultActiveKey:t.get("tab")},ee.map(function(t){return s().createElement(c.Tabs.TabPane,{key:t.value,tab:e(t.label)},s().createElement(t.component,{type:t.value}))})))},en=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;0!=o--;){var r,o,i,a=i[o];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n};let er="__googleMapsScriptId";(r=o||(o={}))[r.INITIALIZED=0]="INITIALIZED",r[r.LOADING=1]="LOADING",r[r.SUCCESS=2]="SUCCESS",r[r.FAILURE=3]="FAILURE";class eo{constructor({apiKey:e,authReferrerPolicy:t,channel:n,client:r,id:o=er,language:i,libraries:a=[],mapIds:l,nonce:c,region:u,retries:s=3,url:p="https://maps.googleapis.com/maps/api/js",version:f}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=e,this.authReferrerPolicy=t,this.channel=n,this.client=r,this.id=o||er,this.language=i,this.libraries=a,this.mapIds=l,this.nonce=c,this.region=u,this.retries=s,this.url=p,this.version=f,eo.instance){if(!en(this.options,eo.instance.options))throw Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(eo.instance.options)}`);return eo.instance}eo.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?o.FAILURE:this.done?o.SUCCESS:this.loading?o.LOADING:o.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+="?callback=__googleMapsCallback",this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`®ion=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(e+=`&auth_referrer_policy=${this.authReferrerPolicy}`),e}deleteScript(){let e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(n=>{n?t(n.error):e(window.google)})})}importLibrary(e){return this.execute(),google.maps.importLibrary(e)}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){var e,t;if(document.getElementById(this.id)){this.callback();return}let n={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(n).forEach(e=>!n[e]&&delete n[e]),!(null===(t=null===(e=null==window?void 0:window.google)||void 0===e?void 0:e.maps)||void 0===t?void 0:t.importLibrary)&&(e=>{let t,n,r,o="The Google Maps JavaScript API",i="google",a="importLibrary",l="__ib__",c=document,u=window,s=(u=u[i]||(u[i]={})).maps||(u.maps={}),p=new Set,f=new URLSearchParams,d=()=>t||(t=new Promise((a,u)=>{var d,m,y,v;return d=this,m=void 0,y=void 0,v=function*(){var d;for(r in yield n=c.createElement("script"),n.id=this.id,f.set("libraries",[...p]+""),e)f.set(r.replace(/[A-Z]/g,e=>"_"+e[0].toLowerCase()),e[r]);f.set("callback",i+".maps."+l),n.src=this.url+"?"+f,s[l]=a,n.onerror=()=>t=u(Error(o+" could not load.")),n.nonce=this.nonce||(null===(d=c.querySelector("script[nonce]"))||void 0===d?void 0:d.nonce)||"",c.head.append(n)},new(y||(y=Promise))(function(e,t){function n(e){try{o(v.next(e))}catch(e){t(e)}}function r(e){try{o(v.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):((o=t.value)instanceof y?o:new y(function(e){e(o)})).then(n,r)}o((v=v.apply(d,m||[])).next())})}));s[a]?console.warn(o+" only loads once. Ignoring:",e):s[a]=(e,...t)=>p.add(e)&&d().then(()=>s[a](e,...t))})(n);let r=this.libraries.map(e=>this.importLibrary(e));!r.length&&r.push(this.importLibrary("core")),Promise.all(r).then(()=>this.callback(),e=>{let t=new ErrorEvent("error",{error:e});this.loadErrorCallback(t)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){let e=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${e} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},e)}else this.onerrorEvent=e,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(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())}}}function ei(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ea(){var e,t,n=(e=["\n position: absolute;\n top: 10px;\n left: 10px;\n z-index: 10;\n width: calc(100% - 20px);\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return ea=function(){return n},n}var el=function(e){var t,n,r=e.toCenter,o=e.mapRef,i=(0,f.jD)().t,p=(0,u.useRef)();var d=(t=(0,u.useState)([]),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return ei(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ei(e,t)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=d[0],y=d[1];(0,u.useEffect)(function(){google.maps.importLibrary("places").then(function(e){p.current=new e.AutocompleteService}).catch(function(){c.message.error("Please configure the Google API Key correctly")})},[o]);var v=(0,l.useDebounceFn)(function(e){if(!!p.current)p.current.getPlacePredictions({input:e||" "},function(e,t){if(t===google.maps.places.PlacesServiceStatus.OK)y(e.map(function(e){var t,n,r=e.structured_formatting;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={label:"".concat(r.main_text).concat(r.secondary_text?" "+r.secondary_text:""),value:e.place_id},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t}));else{y([]);return}})},{wait:300}).run;return s().createElement("div",{className:(0,a.css)(ea())},s().createElement(c.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:i("Enter keywords to search"),filterOption:!1,onSearch:v,onSelect:function(e){var t=m.find(function(t){return t.value===e});new google.maps.places.PlacesService(o.current).getDetails({placeId:t.place_id,fields:["geometry"]},function(e,t){t===google.maps.places.PlacesServiceStatus.OK&&r(e.geometry.location)})},options:m}))},ec=function(e){return{url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(9.5,42)}};function eu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function es(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function ep(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function ef(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function ed(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function em(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||ev(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ey(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function ev(e,t){if(e){if("string"==typeof e)return eu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eu(e,t)}}function eg(){var e=ey(["\n position: relative;\n height: ","px !important;\n "]);return eg=function(){return e},e}function eb(){var e=ey(["\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n "]);return eb=function(){return e},e}function eh(){var e=ey(["\n position: absolute;\n bottom: 80px;\n right: 20px;\n z-index: 10;\n "]);return eh=function(){return e},e}function eO(){var e=ey(["\n position: absolute;\n bottom: 20px;\n left: 10px;\n z-index: 2;\n pointer-events: none;\n "]);return eO=function(){return e},e}function ew(){var e=ey(["\n position: absolute;\n bottom: 20px;\n right: 20px;\n z-index: 2;\n "]);return ew=function(){return e},e}function eS(){var e=ey(["\n width: 100%;\n height: 100%;\n "]);return eS=function(){return e},e}var eP=function(e){return"point"===e?"marker":"lineString"===e?"polyline":e},eA={point:{propertyKey:"position",overlay:"Marker"},polygon:{propertyKey:"paths",overlay:"Polygon"},lineString:{propertyKey:"path",overlay:"Polyline"},circle:{transformOptions:function(e){return{center:new google.maps.LatLng(e[1],e[0]),radius:e[2]}},overlay:"Circle"}},ej=s().forwardRef(function(e,t){var n=e.value,r=e.onChange,o=e.block,d=e.readonly,m=e.disabled,y=void 0===m?void 0!==o&&o:m,v=e.zoom,b=void 0===v?13:v,h=e.overlayCommonOptions,S=(O(e.mapType)||{}).accessKey,P=(0,f.jD)().t,A=(0,a.useCollection_deprecated)().getField,j=(0,g.useFieldSchema)(),C=(0,u.useRef)(),M=(0,u.useRef)(),x=(0,u.useRef)(),E=em((0,u.useState)([]),2),k=E[0],I=E[1],F=em((0,u.useState)(""),2),D=F[0],z=F[1],T=(0,a.useAPIClient)(),L=c.App.useApp().modal,B=w();(0,u.useEffect)(function(){M.current&&M.current.setZoom(b)},[b]);var R=(0,u.useMemo)(function(){if(e.type)return e.type;var t=A(null==j?void 0:j.name);return null==t?void 0:t.interface},[null==e?void 0:e.type,null==j?void 0:j.name]),U=(0,u.useRef)(eP(R)),_=em((0,u.useState)(ef({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!y,draggable:!y},h)),1)[0],N=(0,a.useNavigateNoUpdate)(),K=(0,u.useRef)(),G=(0,u.useRef)(new Set),q=(0,l.useMemoizedFn)(function(e){if(G.current.forEach(function(e){G.current.delete(e)}),"getPath"in e){var t=e.getPath();["insert_at","remove_at","set_at"].forEach(function(n){G.current.add(t.addListener(n,function(){Z(e,!0)}).remove)})}else ep(e,google.maps.Circle)&&["center_changed","radius_changed"].forEach(function(t){G.current.add(e.addListener(t,function(){Z(e,!0)}).remove)})}),V=(0,l.useMemoizedFn)(function(){if(x.current&&(x.current.unbindAll(),x.current.setMap(null)),"point"!==R){var e;null===(e=C.current)||void 0===e||e.setDrawingMode(null)}}),W=(0,l.useMemoizedFn)(function(e){if(M.current&&e){var t,n;null===(t=M.current)||void 0===t||t.setCenter(e),null===(n=M.current)||void 0===n||n.setZoom(b)}}),Y=(0,l.useMemoizedFn)(function(e){V(),q(e),x.current=e}),J=(0,l.useMemoizedFn)(function(e){var t,n,r=new google.maps.LatLngBounds;e.forEach(function(e){if(ep(e,google.maps.Marker))r.extend(e.getPosition());else if(ep(e,google.maps.Polyline)||ep(e,google.maps.Polygon)){for(var t=e.getPath(),n=0;n<t.getLength();n++)r.extend(t.getAt(n))}else ep(e,google.maps.Circle)&&r.union(e.getBounds())}),null===(n=M.current)||void 0===n||null===(t=n.setCenter)||void 0===t||t.call(n,r.getCenter())}),Z=(0,l.useMemoizedFn)(function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=null;if("point"===R){var o=e.getPosition(),i=o.lat;n=[(0,o.lng)(),i()]}else if("polygon"===R||"lineString"===R){if((n=e.getPath().getArray().map(function(e){return[e.lng(),e.lat()]})).length<2)return}else if("circle"===R){var a=e.getCenter(),l=e.getRadius();n=[a.lng(),a.lat(),l]}!t&&Y(e),null==r||r(n)}),X=(0,l.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0,n=ed(ef({},_,t),{map:M.current});return C.current=new google.maps.drawing.DrawingManager({drawingMode:U.current,drawingControl:!1,markerOptions:ed(ef({},n),{icon:ec(p.FM)}),polygonOptions:n,polylineOptions:n,circleOptions:n,map:M.current}),!e&&C.current.addListener("overlaycomplete",function(e){Z(e.overlay)}),C.current}),H=(0,l.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:R,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n,r=arguments.length>2?arguments[2]:void 0,o=eA[e];if(!!o){var i=ef(ed(ef({},_),{icon:ec(p.FM)}),r);return"transformOptions"in o?Object.assign(i,o.transformOptions(t)):"propertyKey"in o&&(i[o.propertyKey]=Array.isArray(t[0])?t.map(function(e){return new google.maps.LatLng(e[1],e[0])}):new google.maps.LatLng(t[1],t[0])),new google.maps[o.overlay](i)}}),Q=(0,l.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:R,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n,r=arguments.length>2?arguments[2]:void 0;if(M.current)return H(e,t,ed(ef({},r),{map:M.current}))});(0,u.useEffect)(function(){if(!n&&M.current){var e,t;V(),null==C||null===(t=C.current)||void 0===t||null===(e=t.setDrawingMode)||void 0===e||e.call(t,U.current),null==r||r(null)}if(M.current){if(!n||!d&&x.current)return;var o=Q();Y(o),J([o])}},[n,k,R,y,d,Q,J,Y]),(0,u.useEffect)(function(){if(S&&!M.current&&K.current){try{n=new eo({apiKey:S,version:"weekly",language:T.auth.getLocale()})}catch(e){z(P("Load google maps failed, Please check the Api key and refresh the page"));return}var e,t,n,r=console.error;return console.error=function(e){for(var t,n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];(null==e?void 0:e.includes("InvalidKeyMapError"))&&z(P("Load google maps failed, Please check the Api key and refresh the page")),r.apply(void 0,[e].concat(function(e){if(Array.isArray(e))return eu(e)}(t=o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||ev(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))},Promise.all([n.importLibrary("drawing"),n.importLibrary("core"),n.importLibrary("geometry")]).then((t=(e=function(e){var t;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e){var t=function(){e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(function(t){var n=t.coords;e({lat:n.latitude,lng:n.longitude})},function(){t()},{timeout:2e3,maximumAge:0}):t()})];case 1:return t=e.sent(),M.current=new google.maps.Map(K.current,{zoom:b,center:t,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),z(""),I([]),[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){es(i,r,o,a,l,"next",e)}function l(e){es(i,r,o,a,l,"throw",e)}a(void 0)})}),function(e){return t.apply(this,arguments)})).catch(function(e){if(ep(e,Error)){z(e.message);return}}),function(){var e,t;null===(e=M.current)||void 0===e||e.unbindAll(),M.current=null,null===(t=C.current)||void 0===t||t.unbindAll()}}},[S,T.auth,R,b]),(0,u.useEffect)(function(){M.current&&R&&!y&&!C.current&&X()},[X,y,k,R]),(0,u.useImperativeHandle)(t,function(){return{setOverlay:Q,getOverlay:H,setFitView:J,createDraw:X,map:M.current,overlay:x.current,drawingManager:C.current,errMessage:D}});var $=(0,l.useMemoizedFn)(function(){var e=function(){V(),C.current.setDrawingMode(U.current),null==r||r(null)};L.confirm({title:P("Clear the canvas"),content:P("Are you sure to clear the canvas?"),okText:P("Confirm"),cancelText:P("Cancel"),getContainer:function(){return K.current},onOk:function(){e()}})}),ee=(0,a.useApp)();return!S||D?s().createElement(c.Alert,{action:s().createElement(c.Button,{type:"primary",onClick:function(){return N(ee.pluginSettingsManager.getRoutePath("map")+"?tab=google")}},P("Go to the configuration page")),message:D||P("Please configure the Api key first"),type:"error"}):s().createElement("div",{className:(0,a.css)(eg(),B||500)},!M.current&&s().createElement("div",{className:(0,a.css)(eb())},s().createElement(c.Spin,null)),y?null:s().createElement(s().Fragment,null,M.current&&s().createElement(el,{toCenter:W,mapRef:M}),s().createElement("div",{className:(0,a.css)(eh())},s().createElement(c.Button,{onClick:function(){x.current&&J([x.current])},disabled:!x.current,type:"primary",shape:"round",size:"large",icon:s().createElement(i.SyncOutlined,null)})),"lineString"===R||"polygon"===R?s().createElement("div",{className:(0,a.css)(eO())},s().createElement(c.Alert,{message:P("Click to select the starting point and double-click to end the drawing"),type:"info"})):null,s().createElement("div",{className:(0,a.css)(ew())},s().createElement(c.Button,{disabled:!n,style:{height:"40px"},onClick:$,type:"primary",danger:!0},P("Clear")))),s().createElement("div",{ref:K,className:(0,a.css)(eS()),style:null==e?void 0:e.style}))});function eC(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}ej.displayName="GoogleMapsComponent";function eM(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function ex(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function eE(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||eF(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ek(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eI(e){return function(e){if(Array.isArray(e))return eC(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eF(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eF(e,t){if(e){if("string"==typeof e)return eC(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eC(e,t)}}function eD(){var e=ek(["\n margin-top: 6px;\n padding: 2px 4px;\n background: #fff;\n border: 1px solid #0000f5;\n"]);return eD=function(){return e},e}function ez(){var e=ek(["\n margin-top: -64px;\n padding: 2px 4px;\n background: #fff;\n border: 1px solid #0000f5;\n"]);return ez=function(){return e},e}function eT(){var e=ek(["\n position: relative;\n height: 100%;\n "]);return eT=function(){return e},e}function eL(){var e=ek(["\n position: absolute;\n left: 10px;\n top: 10px;\n z-index: 999;\n "]);return eL=function(){return e},e}var eB="google-maps-overlay-id",eR="google-maps-overlay-selected",eU=(0,a.css)(eD()),e_=(0,a.css)(ez()),eN=function(e){var t,n,r,o=(0,a.useProps)(e),y=o.collectionField,v=o.fieldNames,g=o.dataSource,b=o.fixedBlock,h=o.zoom,O=o.setSelectedRecordKeys,w=o.lineSort,S=(0,(0,a.useCollection_deprecated)().getPrimaryKey)(),P=v.marker,A=eE((0,u.useState)(!1),2),j=A[0],C=A[1],M=(0,u.useRef)(),x=eE((0,u.useState)(),2),E=x[0],k=x[1],I=eE((0,u.useState)(""),2),F=I[0],D=I[1],z=(0,f.jD)().t,T=(0,a.useCompile)(),L=(0,a.useFilterAPI)(),B=L.isConnected,R=L.doFilter,U=eE((0,u.useState)(null),2)[1],_=(0,u.useRef)(F),N=(0,u.useRef)(null),K=(0,u.useRef)([]);_.current=F;var G=(0,a.useCollection)().fields,q=(0,a.useCollectionParentRecordData)(),V=null===(r=G.find(function(e){return e.name===(null==v?void 0:v.marker)}))||void 0===r?void 0:r.uiSchema,W=(0,a.useCollectionManager_deprecated)().getCollectionJoinField,Y=(0,a.usePopupUtils)().openPopup,J=function(e,t){var n=void 0!==t?!t:e.get(eR);e.set(eR,!n),e.setOptions(ex({},n?{icon:ec(p.FM),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:ec(p.F6),strokeColor:"#F18b62",fillColor:"#F18b62"}))};(0,u.useEffect)(function(){if("selection"===F){M.current&&!(null===(e=M.current)||void 0===e?void 0:e.drawingManager)&&(M.current.drawingManager=null===(r=M.current)||void 0===r?void 0:r.createDraw(!0,{editable:!0,draggable:!0}));var e,t,n,r,o=new Set;return null===(t=M.current)||void 0===t||t.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),null===(n=M.current)||void 0===n||n.drawingManager.addListener("overlaycomplete",function(e){var t,n=e.overlay;null===(t=M.current)||void 0===t||t.drawingManager.setDrawingMode(null),N.current=n;var r=n.getPath();["insert_at","remove_at","set_at"].forEach(function(e){o.add(r.addListener(e,function(){}).remove)})}),function(){var e,t,n,r;o.forEach(function(e){e()}),M.current&&(null===(e=N.current)||void 0===e||e.unbindAll(),null===(t=N.current)||void 0===t||t.setMap(null),N.current=null,null===(n=M.current)||void 0===n||n.drawingManager.setDrawingMode(null),null===(r=M.current)||void 0===r||r.drawingManager.unbindAll())}}},[F]),(0,u.useEffect)(function(){if(F)return function(){!_.current&&K.current.forEach(function(e){J(e,!1)})}},[F]);var Z=(0,l.useMemoizedFn)(function(){var e,t=N.current,n=K.current,r=google.maps.geometry.poly,o=n.filter(function(e){if(e!==t&&void 0!==e.get(eB)){if(eM(e,google.maps.Marker))return r.containsLocation(e.getPosition(),t);else if(eM(e,google.maps.Circle))return r.containsLocation(e.getCenter(),t);else return e.getPath().getArray().some(function(e){return r.containsLocation(e,t)})}}).map(function(e){return J(e,!0),e.get(eB)});O(function(e){return o.concat(e)}),null==t||t.unbindAll(),null==t||t.setMap(null),null===(e=M.current)||void 0===e||e.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});(0,u.useEffect)(function(){if(y&&(null==g?void 0:g.length)&&(null===(r=M.current)||void 0===r?void 0:r.map)){var e=W([name].concat(eI(Array.isArray(null==v?void 0:v.field)&&(null==v?void 0:v.field.length)>1?null==v?void 0:v.field.slice(0,-1):null==v?void 0:v.field)).flat().join(".")),t=g.map(function(t){var n=d(t,null==v?void 0:v.field,null==e?void 0:e.interface),r=(0,a.getLabelFormatValue)(V,t[v.marker]);return(null==n?void 0:n.length)?null==n?void 0:n.filter(Boolean).map(function(e){if(n){var o,i=null===(o=M.current)||void 0===o?void 0:o.setOverlay(y.type,e,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:eU,fontFamily:"inherit",fontSize:"13px",color:"#333",text:(null==v?void 0:v.marker)?T(r):void 0}});return null==i||i.set(eB,t[S]),i}}):[]}).flat().filter(Boolean);K.current=t;var n=t.map(function(e){return e.addListener("click",function(t){var n=e.get(eB);if(n){var r=null==g?void 0:g.find(function(e){return n===e[S]});if(B){U(function(t){return(t&&eK(e),t===e)?(eK(e),R(null),null):(function(e){if(eM(e,google.maps.Marker))return e.setIcon(ec(p.F6));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}(e),R(r[S],function(e){return e.field||S},"$eq"),e)});return}r&&(k(r),Y({recordData:r}))}}),function(){return e.unbindAll()}});if("point"===y.type&&(null==w?void 0:w.length)&&(null==t?void 0:t.length)>1){var r,o,i=t.map(function(e){return e.getPosition()});t[0].setZIndex(138),t[t.length-1].setZIndex(138);var l=function(){var e,t=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if(null===(e=M.current)||void 0===e?void 0:e.map)return new google.maps.Marker({label:{className:e_,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t?z("Start point"):z("End point")},icon:ec(p.FM),position:t?i[0]:i[i.length-1],map:M.current.map})};t.push.apply(t,eI([M.current.setOverlay("lineString",i.map(function(e){return[e.lng(),e.lat()]}),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),l(),l(!1)].filter(Boolean)))}return null===(o=M.current)||void 0===o||o.setFitView(t),function(){t.forEach(function(e){e.setMap(null),e.unbindAll()}),n.forEach(function(e){return e()})}}},[g,j,void 0===P?"id":P,y.type,B,Y]),(0,u.useEffect)(function(){setTimeout(function(){O([])})},[g]);return s().createElement("div",{className:(0,a.css)(eT())},j&&s().createElement(s().Fragment,null,s().createElement("div",{className:(0,a.css)(eL())},s().createElement(c.Space,{direction:"vertical"},s().createElement(c.Button,{style:{color:F?void 0:"#F18b62",borderColor:"currentcolor"},onClick:function(e){e.stopPropagation(),D("")},icon:s().createElement(i.EnvironmentOutlined,null)}),s().createElement(c.Button,{style:{color:"selection"===F?"#F18b62":void 0,borderColor:"currentcolor"},onClick:function(e){e.stopPropagation(),D("selection")},icon:s().createElement(i.ExpandOutlined,null)}),"selection"===F?s().createElement(c.Button,{type:"primary",icon:s().createElement(i.CheckOutlined,null),title:z("Confirm selection"),onClick:Z}):null)),s().createElement(a.RecordProvider,{record:E,parent:q},s().createElement(m.I,null))),s().createElement(ej,(t=ex({},e),n=(n={ref:function(e){M.current=e,C(!!(null==e?void 0:e.map)&&!e.errMessage)},style:{height:b?"100%":null},zoom:h,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)))};function eK(e){if(eM(e,google.maps.Marker))return e.setIcon(ec(p.FM));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}var eG=n("467"),eq=n.n(eG),eV={amap:B,google:ej},eW=s().forwardRef(function(e,t){var n=(0,f.jD)().t,r=e.mapType,o=(0,u.useMemo)(function(){return eV[r]},[r]);return o?s().createElement(o,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({ref:t},e)):s().createElement("div",null,n("The ".concat(r," cannot found")))});eW.displayName="MapComponent";function eY(){var e,t,n=(e=["\n height: 100%;\n border: 1px solid transparent;\n .ant-formily-item-error & {\n border: 1px solid #ff4d4f;\n }\n"],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eY=function(){return n},n}var eJ=(0,a.css)(eY()),eZ=(0,g.connect)(function(e){return s().createElement("div",{className:eJ},s().createElement(eW,e))},(0,g.mapReadPretty)(function(e){var t,n,r=e.value,o=(0,g.useFieldSchema)(),i=(0,a.useCollection)().getField(o.name),l=e.mapType||(null==i?void 0:null===(t=i.uiSchema["x-component-props"])||void 0===t?void 0:t.mapType),c=(0,g.useForm)(),u=(0,g.useField)();return((0,a.useFieldTitle)(),!c.readPretty||u.readPretty)?s().createElement("div",null,s().createElement(a.EllipsisWithTooltip,{ellipsis:!0},null==r?void 0:null===(n=r.map)||void 0===n?void 0:n.call(r,function(e){return Array.isArray(e)?"(".concat(e.join(","),")"):e}).join(","))):s().createElement(eW,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({readonly:!0,mapType:l},e))}));eZ.Designer=function(){var e,t=(0,a.useCollectionManager_deprecated)().getCollectionJoinField,n=(0,a.useCollection_deprecated)().getField,r=(0,a.useFormBlockContext)().form,o=(0,g.useField)(),i=(0,g.useFieldSchema)(),l=(0,f.jD)().t,c=(0,a.useDesignable)(),u=c.dn;c.refresh;var p=n(i.name)||t(i["x-collection-field"]),d=null==p?void 0:null===(e=p.uiSchema)||void 0===e?void 0:e.title,m={title:o.title===d?void 0:o.title};!o.readPretty&&(m.required=o.required);var y="editable";return!0===i["x-disabled"]&&(y="readonly"),!0===i["x-read-pretty"]&&(y="read-pretty"),s().createElement(a.GeneralSchemaDesigner,null,s().createElement(a.GeneralSchemaItems,null),r&&!(null==r?void 0:r.readPretty)&&!(0,a.isPatternDisabled)(i)&&s().createElement(a.SchemaSettingsSelectItem,{key:"pattern",title:l("Pattern"),options:[{label:l("Editable"),value:"editable"},{label:l("Readonly"),value:"readonly"},{label:l("Easy-reading"),value:"read-pretty"}],value:y,onChange:function(e){var t,n,r,a=(t={},n="x-uid",r=i["x-uid"],n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t);switch(e){case"readonly":i["x-read-pretty"]=!1,i["x-disabled"]=!0,a["x-read-pretty"]=!1,a["x-disabled"]=!0,o.readPretty=!1,o.disabled=!0;break;case"read-pretty":i["x-read-pretty"]=!0,i["x-disabled"]=!1,a["x-read-pretty"]=!0,a["x-disabled"]=!1,o.readPretty=!0;break;default:i["x-read-pretty"]=!1,i["x-disabled"]=!1,a["x-read-pretty"]=!1,a["x-disabled"]=!1,o.readPretty=!1,o.disabled=!1}u.emit("patch",{schema:a}),u.refresh()}}),s().createElement(a.SchemaSettingsModalItem,{key:"map-zoom",title:l("Set default zoom level"),schema:{type:"object",title:l("Set default zoom level"),properties:{zoom:{title:l("Zoom"),default:o.componentProps.zoom||13,description:l("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:function(e){var t=e.zoom;t&&(eq().set(i,"x-component-props.zoom",t),Object.assign(o.componentProps,i["x-component-props"]),u.emit("patch",{schema:{"x-uid":i["x-uid"],"x-component-props":o.componentProps}})),u.refresh()}}),s().createElement(a.SchemaSettingsRemove,{key:"remove",removeParentsIfNoChildren:!0,confirm:{title:l("Delete field")},breakRemoveOn:{"x-component":"Grid"}}))};var eX={amap:W,google:eN},eH=(0,a.withSkeletonComponent)(function(e){var t=(0,f.jD)().t,n=e.mapType,r=(0,u.useMemo)(function(){return eX[n]},[n]);return r?s().createElement(a.PopupContextProvider,null,s().createElement(r,e)):s().createElement("div",null,t("The ".concat(n," cannot found")))},{displayName:"MapBlockComponent"})},130:function(e,t,n){"use strict";n.d(t,{F6:function(){return i},FM:function(){return a},je:function(){return o}});var r=n(573),o=[{label:(0,r.Ul)("AMap"),value:"amap"},{label:(0,r.Ul)("Google Maps"),value:"google"}],i="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",a="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=="},573:function(e,t,n){"use strict";n.d(t,{A7:function(){return o},Ul:function(){return i},jD:function(){return a}}),n(772);var r=n(238),o="map";function i(e){return"{{t('".concat(e,"', { ns: '").concat(o,"', nsMode: 'fallback' })}}")}function a(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=t},964:function(e){"use strict";e.exports=s},632:function(e){"use strict";e.exports=o},505:function(e){"use strict";e.exports=n},875:function(e){"use strict";e.exports=u},772:function(t){"use strict";t.exports=e},749:function(e){"use strict";e.exports=l},721:function(e){"use strict";e.exports=c},467:function(e){"use strict";e.exports=a},156:function(e){"use strict";e.exports=r},238:function(e){"use strict";e.exports=i}},f={};function d(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return p[e].call(n.exports,n,n.exports,d),n.exports}d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var m={};return!function(){"use strict";d.r(m),d.d(m,{PluginMapClient:function(){return ex},default:function(){return eE}});var e=d("772"),t=d("156"),n=d.n(t),r=d("467"),o=d.n(r),i=d("747"),a=d("700"),l=(0,e.withDynamicSchemaProps)(function(r){var l,c,u,s,p=(0,e.usePopupUtils)().context;if(p.currentLevel&&!o().isNil(null===(u=p.params)||void 0===u?void 0:u.filterbytk))return n().createElement(e.PopupContextProvider,null,n().createElement(a.I,null));var f=(0,e.useProps)(r).fieldNames,d=(0,e.useCollectionManager)(),m=((0,e.useCollection)()||{}).name,y=(0,t.useMemo)(function(){return null==d?void 0:d.getCollectionField([m,null==f?void 0:f.field].flat().join("."))},[m,null==f?void 0:f.field]),v=null==y?void 0:null===(s=y.uiSchema)||void 0===s?void 0:s["x-component-props"];return n().createElement(i.MapBlockComponent,(l=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},v,r),c=(c={collectionField:y},c),Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(c)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(c)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(c,e))}),l))}),c=function(){var t=(0,e.useCollection)(),r=t.name,o=t.title,i=(0,e.useSchemaTemplate)();return n().createElement(e.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:i,title:o||r})},u=d("482"),s=d("632"),p=d("505"),f=d("573"),y=d("875"),v=function(e){var t,n,r,o=e.collectionName,i=e.fieldNames,a=e.dataSource;return{type:"void","x-acl-action":"".concat(o,":list"),"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:a,action:"list",fieldNames:i,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:map","x-component":"CardItem","x-filter-targets":[],properties:(t={actions:{type:"void","x-initializer":"map:configureActions","x-component":"ActionBar","x-component-props":{}}},n=(0,y.uid)(),r={type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",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":"popup:common:addBlock"}}}}}}}}},n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t)}},g=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return"string"==typeof e&&(e=[e]),null==e?void 0:e.reduce(function(t,n,r){var o=null==t?void 0:t.find(function(e){return e.value===n});return r===e.length-1?o:null==o?void 0:o.children},t)};function b(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}var O=function(){var r,o,i=(0,e.useSchemaInitializerItem)(),a=(0,e.useSchemaInitializer)().insert,l=(0,t.useContext)(p.SchemaOptionsContext),c=(0,e.useCollectionManager_deprecated)().getCollectionFieldsOptions,d=(0,f.jD)().t,m=(0,e.useGlobalTheme)().theme;return n().createElement(e.DataBlockInitializer,h({componentType:"Map",icon:n().createElement(u.TableOutlined,null),onCreateBlockSchema:(o=(r=function(t){var r,o,i,u;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(p){switch(p.label){case 0:return o=c((r=t.item).name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:r.dataSource}),i=c(r.name,"string",{dataSource:r.dataSource}),[4,(0,e.FormDialog)(d("Create map block"),function(){var t;return n().createElement(e.SchemaComponentOptions,{scope:l.scope,components:h({},l.components)},n().createElement(s.FormLayout,{layout:"vertical"},n().createElement(e.SchemaComponent,{schema:{properties:{field:{title:d("Map field"),enum:o,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:o.length?[o[0].value,null===(t=o[0].children)||void 0===t?void 0:t[0].value].filter(function(e){return null!=e}):[]},marker:{title:d("Marker field"),enum:i,"x-component":"Select","x-decorator":"FormItem","x-reactions":function(e){var t=e.form.values.field;if(!!(null==t?void 0:t.length)){var n=g(t,o);n&&(e.hidden="point"!==n.type)}}}}}})))},m).open({initialValues:{}})];case 1:return u=p.sent(),a(v({collectionName:r.name,dataSource:r.dataSource,fieldNames:h({},u)})),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var i=r.apply(e,t);function a(e){b(i,n,o,a,l,"next",e)}function l(e){b(i,n,o,a,l,"throw",e)}a(void 0)})}),function(e){return o.apply(this,arguments)}),title:d("Map block")},i))},w=d("964"),S=d("721");function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function A(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function C(){var e,t,n=(e=["\n .nb-action-bar {\n margin-bottom: ","px;\n }\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return C=function(){return n},n}var M=(0,t.createContext)({});M.displayName="MapBlockContext";var x=function(r){var o,i,a,l=r.fieldNames,c=(0,p.useFieldSchema)(),u=(0,p.useField)(),s=(0,e.useBlockRequestContext)(),f=s.resource,d=s.service;var m=(o=(0,t.useState)([]),i=2,function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(o,2)||function(e,t){if(e){if("string"==typeof e)return P(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return P(e,t)}}(o,i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),y=m[0],v=m[1],g=S.theme.useToken().token;return n().createElement(e.SchemaComponentOptions,{scope:{selectedRecordKeys:y}},n().createElement(M.Provider,{value:{field:u,service:d,resource:f,fieldNames:l,fixedBlock:null==c?void 0:null===(a=c["x-decorator-props"])||void 0===a?void 0:a.fixedBlock,selectedRecordKeys:y,setSelectedRecordKeys:v}}," ",n().createElement("div",{className:(0,w.css)(C(),g.margin)},r.children)))},E=function(t){var n=(0,e.useParsedFilter)({filterOption:null==t?void 0:t.filter}),r=n.filter,o=n.parseVariableLoading;return{params:j(A({},t),{filter:r}),parseVariableLoading:o}},k=function(t){var r=(0,p.useField)(),o=t.fieldNames,i=E(t.params),a=i.params;if(i.parseVariableLoading)return null;var l=a.appends||[],c=(o||{}).field;return Array.isArray(c)&&c.length>1&&l.push(c[0]),n().createElement(e.BlockProvider,j(A({name:"map"},t),{runWhenParamsChanged:!0,params:j(A({},a),{appends:l,paginate:!1,sort:r.componentProps.lineSort})}),n().createElement(x,t))},I=function(){return(0,t.useContext)(M)},F=function(){var e,t,n,r,o,i,a=I();return j(A({},a),{dataSource:null==a?void 0:null===(t=a.service)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.data,zoom:(null==a?void 0:null===(r=a.field)||void 0===r?void 0:null===(n=r.componentProps)||void 0===n?void 0:n.zoom)||13,lineSort:null==a?void 0:null===(i=a.field)||void 0===i?void 0:null===(o=i.componentProps)||void 0===o?void 0:o.lineSort})},D=function(t){return n().createElement(e.SchemaComponentOptions,{scope:{useMapBlockProps:F},components:{MapBlockInitializer:O,MapBlockDesigner:c,MapBlockProvider:k,MapBlock:l}},t.children)};function z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}var T={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{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:function(){return(0,e.useActionAvailable)("create")}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}},{name:"customRequest",title:'{{t("Custom request")}}',Component:"CustomRequestInitializer",schema:{"x-action":"customize:table:request:global"}}]},L=new e.CompatibleSchemaInitializer(z({name:"MapActionInitializers"},T)),B=new e.CompatibleSchemaInitializer(z({name:"map:configureActions"},T),L);function R(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var U={name:"defaultZoomLevel",Component:e.SchemaSettingsModalItem,useComponentProps:function(){var t,n=(0,f.jD)().t,r=(0,p.useFieldSchema)(),i=(0,p.useField)(),a=(0,e.useDesignable)().dn,l=(null==r?void 0:null===(t=r["x-component-props"])||void 0===t?void 0:t.zoom)||13;return{title:n("The default zoom level of the map"),schema:{type:"object",title:n("Set default zoom level"),properties:{zoom:{title:n("Zoom"),default:l,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:function(e){var t=e.zoom;o().set(r,"x-component-props.zoom",t),i.componentProps.zoom=t,a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}}),a.refresh()}}},useVisible:function(){return!(0,e.useColumnSchema)().fieldSchema}},_=new e.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:e.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:e.SchemaSettingsBlockHeightItem},{name:"mapField",Component:e.SchemaSettingsCascaderItem,useComponentProps:function(){var t,n=(0,e.useCollectionManager_deprecated)().getCollectionFieldsOptions,r=(0,f.jD)().t,o=(0,p.useFieldSchema)(),i=(null==o?void 0:null===(t=o["x-decorator-props"])||void 0===t?void 0:t.fieldNames)||{},a=(0,p.useField)(),l=(0,e.useDesignable)().dn,c=I().service,u=n((0,e.useCollection)().name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:r("Map field"),value:i.field,options:u,allowClear:!1,onChange:function(e){var t,n=a.decoratorProps.fieldNames||{};n.field=e,a.decoratorProps.fieldNames=n,o["x-decorator-props"].fieldNames=n,c.refresh(),l.emit("patch",{schema:(R(t={},"x-uid",o["x-uid"]),R(t,"x-decorator-props",a.decoratorProps),t)}),l.refresh()}}}},{name:"markerField",Component:e.SchemaSettingsSelectItem,useComponentProps:function(){var t,n=(0,f.jD)().t,r=(0,p.useFieldSchema)(),o=(null==r?void 0:null===(t=r["x-decorator-props"])||void 0===t?void 0:t.fieldNames)||{},i=I().service,a=(0,p.useField)(),l=(0,e.useDesignable)().dn,c=(0,(0,e.useCollectionManager_deprecated)().getCollectionFieldsOptions)((0,e.useCollection)().name,"string");return{title:n("Marker field"),value:o.marker,options:c,onChange:function(e){var t,n=a.decoratorProps.fieldNames||{};n.marker=e,a.decoratorProps.fieldNames=n,r["x-decorator-props"].fieldNames=n,i.refresh(),l.emit("patch",{schema:(R(t={},"x-uid",r["x-uid"]),R(t,"x-decorator-props",a.decoratorProps),t)}),l.refresh()}}},useVisible:function(){var t,n,r=(0,p.useFieldSchema)(),o=(0,e.useCollectionManager_deprecated)().getCollectionFieldsOptions,i=(0,e.useCollection)().name,a=(null==r?void 0:null===(t=r["x-decorator-props"])||void 0===t?void 0:t.fieldNames)||{},l=o(i,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return(null===(n=g(a.field,l))||void 0===n?void 0:n.type)==="point"}},{name:"setDefaultSortingRules",Component:e.SchemaSettingsDefaultSortingRules,useComponentProps:function(){return{path:"x-component-props.lineSort",title:(0,(0,f.jD)().t)("Concatenation order field")}}},e.setDataLoadingModeSettingsItem,U,{name:"dataScope",Component:e.SchemaSettingsDataScope,useComponentProps:function(){var t,n,r=(0,e.useCollection)().name,o=(0,p.useFieldSchema)(),i=(0,e.useFormBlockContext)().form,a=(0,p.useField)(),l=I().service,c=(0,e.useDesignable)().dn;return{collectionName:r,defaultFilter:(null==o?void 0:null===(n=o["x-decorator-props"])||void 0===n?void 0:null===(t=n.params)||void 0===t?void 0:t.filter)||{},form:i,onSubmit:function(e){var t,n,r,i=e.filter,u=a.decoratorProps.params||{};u.filter=i,a.decoratorProps.params=u,o["x-decorator-props"].params=u,null===(n=l.params)||void 0===n||null===(t=n[1])||void 0===t||t.filters,c.emit("patch",{schema:(R(r={},"x-uid",o["x-uid"]),R(r,"x-decorator-props",o["x-decorator-props"]),r)})}}}},{name:"ConnectDataBlocks",Component:e.SchemaSettingsConnectDataBlocks,useComponentProps:function(){var t=(0,f.jD)().t;return{type:e.FilterBlockType.TABLE,emptyDescription:t("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:e.SchemaSettingsTemplate,useComponentProps:function(){var t,n,r=(0,e.useCollection)().name,o=(0,p.useFieldSchema)(),i=(0,e.useBlockTemplateContext)().componentNamePrefix,a=(null==o?void 0:null===(t=o["x-decorator-props"])||void 0===t?void 0:t.resource)||(null==o?void 0:null===(n=o["x-decorator-props"])||void 0===n?void 0:n.association);return{componentName:"".concat(i,"Map"),collectionName:r,resourceName:a}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),N=d("130");function K(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function G(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function V(e,t){return(V=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function W(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(W=function(){return!!e})()}var Y=e.interfacesProperties.defaultProps;Array.isArray(e.interfacesProperties.type.enum)&&e.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});var J=function(e){var t,n,r;function o(){var e,t,n,r,i,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=q(n),G(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,W()?Reflect.construct(n,r||[],q(t).constructor):n.apply(t,r)),"properties",(i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){G(e,t,n[t])})}return e}({},Y),a=(a={"uiSchema.x-component-props.mapType":{title:(0,f.Ul)("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:N.je}},a),Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))}),i)),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&V(e,t)}(o,e),t=o,n=[{key:"schemaInitialize",value:function(e,t){"Form"===t.block&&Object.assign(e,{"x-designer":"Map.Designer"})}}],K(t.prototype,n),o}(e.CollectionFieldInterface);function Z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function X(e){return(X=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function H(e,t){return(H=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Q(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Q=function(){return!!e})()}var $=function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=X(r),Z(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,Q()?Reflect.construct(r,o||[],X(n).constructor):r.apply(n,o)),"name","circle"),Z(e,"type","object"),Z(e,"group","map"),Z(e,"order",3),Z(e,"title",(0,f.Ul)("Circle")),Z(e,"availableTypes",["circle","json"]),Z(e,"description",(0,f.Ul)("Circle")),Z(e,"sortable",!0),Z(e,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&H(e,t)}(t,e),t}(J);function ee(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function et(e){return(et=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function en(e,t){return(en=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function er(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(er=function(){return!!e})()}var eo=function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=et(r),ee(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,er()?Reflect.construct(r,o||[],et(n).constructor):r.apply(n,o)),"name","lineString"),ee(e,"type","object"),ee(e,"group","map"),ee(e,"order",2),ee(e,"title",(0,f.Ul)("Line")),ee(e,"description",(0,f.Ul)("Line")),ee(e,"availableTypes",["lineString","json"]),ee(e,"sortable",!0),ee(e,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&en(e,t)}(t,e),t}(J);function ei(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ea(e){return(ea=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function el(e,t){return(el=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ec(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ec=function(){return!!e})()}var eu=function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=ea(r),ei(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,ec()?Reflect.construct(r,o||[],ea(n).constructor):r.apply(n,o)),"name","point"),ei(e,"type","object"),ei(e,"group","map"),ei(e,"order",1),ei(e,"title",(0,f.Ul)("Point")),ei(e,"description",(0,f.Ul)("Point")),ei(e,"availableTypes",["point","json"]),ei(e,"sortable",!0),ei(e,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&el(e,t)}(t,e),t}(J);function es(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ep(e){return(ep=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ef(e,t){return(ef=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ed(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ed=function(){return!!e})()}var em=[eu,function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=ep(r),es(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,ed()?Reflect.construct(r,o||[],ep(n).constructor):r.apply(n,o)),"name","polygon"),es(e,"type","object"),es(e,"group","map"),es(e,"order",4),es(e,"title",(0,f.Ul)("Polygon")),es(e,"description",(0,f.Ul)("Polygon")),es(e,"availableTypes",["polygon","json"]),es(e,"sortable",!0),es(e,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ef(e,t)}(t,e),t}(J),eo,$],ey=new e.SchemaSettings({name:"fieldSettings:component:Map",items:[U]}),ev=d(581);function eg(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eb(e,t,n){return(eb=eP()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&ew(o,n.prototype),o}).apply(null,arguments)}function eh(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function eO(e){return(eO=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ew(e,t){return(ew=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eS(e){var t="function"==typeof Map?new Map:void 0;return(eS=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return eb(e,arguments,eO(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ew(r,e)})(e)}function eP(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eP=function(){return!!e})()}var eA=(0,e.lazy)(function(){return ev("imported_-1vhic9u_component",Promise.resolve().then(d.bind(d,747)))},"Configuration","Map"),ej=eA.Configuration,eC=eA.Map,eM=n().memo(function(t){return n().createElement(e.SchemaComponentOptions,{components:{Map:eC}},n().createElement(D,null,t.children))});eM.displayName="MapProvider";var ex=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=eO(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,eP()?Reflect.construct(t,n||[],eO(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ew(e,t)}(o,e),t=o,n=[{key:"load",value:function(){var e,t=this;return(e=function(){var e;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(n){return t.app.use(eM),t.app.dataSourceManager.addFieldInterfaces(em),t.app.dataSourceManager.addFieldInterfaceGroups({map:{label:(0,f.Ul)("Map-based geometry"),order:51}}),t.app.schemaInitializerManager.add(L),t.app.schemaInitializerManager.add(B),t.schemaSettingsManager.add(_),t.schemaSettingsManager.add(ey),null==(e=t.app.schemaInitializerManager.get("page:addBlock"))||e.add("dataBlocks.map",{title:(0,f.Ul)("Map"),Component:"MapBlockInitializer"}),t.app.schemaInitializerManager.addItem("mobile:addBlock","dataBlocks.map",{title:(0,f.Ul)("Map"),Component:"MapBlockInitializer"}),t.app.pluginSettingsManager.add(f.A7,{title:'{{t("Map Manager", { ns: "'.concat(f.A7,'" })}}'),icon:"EnvironmentOutlined",Component:ej,aclSnippet:"pm.map.configuration"}),t.app.addScopes({useMapBlockProps:F}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eg(i,r,o,a,l,"next",e)}function l(e){eg(i,r,o,a,l,"throw",e)}a(void 0)})})()}}],eh(t.prototype,n),o}(eS(e.Plugin)),eE=ex}(),m}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.
|
|
11
|
+
"@nocobase/client": "1.6.0-alpha.1",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/server": "1.
|
|
14
|
-
"@nocobase/test": "1.
|
|
13
|
+
"@nocobase/server": "1.6.0-alpha.1",
|
|
14
|
+
"@nocobase/test": "1.6.0-alpha.1",
|
|
15
15
|
"@formily/react": "2.3.0",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
@@ -22,6 +22,6 @@ module.exports = {
|
|
|
22
22
|
"ahooks": "3.7.8",
|
|
23
23
|
"@formily/core": "2.3.0",
|
|
24
24
|
"react-i18next": "11.18.6",
|
|
25
|
-
"@nocobase/actions": "1.
|
|
26
|
-
"@nocobase/database": "1.
|
|
25
|
+
"@nocobase/actions": "1.6.0-alpha.1",
|
|
26
|
+
"@nocobase/database": "1.6.0-alpha.1"
|
|
27
27
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-map",
|
|
3
3
|
"displayName": "Block: Map",
|
|
4
4
|
"displayName.zh-CN": "区块:地图",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.6.0-alpha.1",
|
|
6
6
|
"description": "Map block, support Gaode map and Google map, you can also extend more map types.",
|
|
7
7
|
"description.zh-CN": "地图区块,支持高德地图和 Google 地图,你也可以扩展更多地图类型。",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@nocobase/test": "1.x",
|
|
37
37
|
"@nocobase/utils": "1.x"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "a4c91015e34ec0c9a427451b5fbdfb5fedc4f3d7",
|
|
40
40
|
"keywords": [
|
|
41
41
|
"Blocks"
|
|
42
42
|
]
|