@tachybase/plugin-block-map 0.23.8

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.
Files changed (91) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/LICENSE +201 -0
  3. package/README.md +13 -0
  4. package/README.zh-CN.md +13 -0
  5. package/client.d.ts +2 -0
  6. package/client.js +1 -0
  7. package/dist/client/block/MapActionInitializers.d.ts +2 -0
  8. package/dist/client/block/MapBlock.Settings.d.ts +2 -0
  9. package/dist/client/block/MapBlock.d.ts +2 -0
  10. package/dist/client/block/MapBlockDesigner.d.ts +2 -0
  11. package/dist/client/block/MapBlockInitializer.d.ts +2 -0
  12. package/dist/client/block/MapBlockProvider.d.ts +5 -0
  13. package/dist/client/block/createMapBlockUISchema.d.ts +6 -0
  14. package/dist/client/block/index.d.ts +2 -0
  15. package/dist/client/block/utils.d.ts +1 -0
  16. package/dist/client/components/AMap/Block.d.ts +2 -0
  17. package/dist/client/components/AMap/Map.d.ts +39 -0
  18. package/dist/client/components/AMap/Search.d.ts +7 -0
  19. package/dist/client/components/AMap/index.d.ts +2 -0
  20. package/dist/client/components/Configuration.d.ts +2 -0
  21. package/dist/client/components/Designer.d.ts +3 -0
  22. package/dist/client/components/GoogleMaps/Block.d.ts +2 -0
  23. package/dist/client/components/GoogleMaps/Map.d.ts +30 -0
  24. package/dist/client/components/GoogleMaps/Search.d.ts +7 -0
  25. package/dist/client/components/GoogleMaps/index.d.ts +2 -0
  26. package/dist/client/components/GoogleMaps/utils.d.ts +5 -0
  27. package/dist/client/components/Map.d.ts +8 -0
  28. package/dist/client/components/MapBlock.d.ts +2 -0
  29. package/dist/client/components/MapComponent.d.ts +2 -0
  30. package/dist/client/components/ReadPretty.d.ts +3 -0
  31. package/dist/client/components/index.d.ts +6 -0
  32. package/dist/client/constants.d.ts +6 -0
  33. package/dist/client/fields/circle.d.ts +20 -0
  34. package/dist/client/fields/index.d.ts +2 -0
  35. package/dist/client/fields/lineString.d.ts +20 -0
  36. package/dist/client/fields/point.d.ts +20 -0
  37. package/dist/client/fields/polygon.d.ts +20 -0
  38. package/dist/client/fields/schema.d.ts +43 -0
  39. package/dist/client/hooks/index.d.ts +1 -0
  40. package/dist/client/hooks/useMapConfiguration.d.ts +3 -0
  41. package/dist/client/index.d.ts +5 -0
  42. package/dist/client/index.js +98 -0
  43. package/dist/client/locale/index.d.ts +4 -0
  44. package/dist/client/types.d.ts +1 -0
  45. package/dist/client/utils.d.ts +1 -0
  46. package/dist/externalVersion.js +14 -0
  47. package/dist/index.d.ts +2 -0
  48. package/dist/index.js +39 -0
  49. package/dist/locale/en-US.json +51 -0
  50. package/dist/locale/ko_KR.json +51 -0
  51. package/dist/locale/pt-BR.json +45 -0
  52. package/dist/locale/zh-CN.json +51 -0
  53. package/dist/server/actions/index.d.ts +3 -0
  54. package/dist/server/actions/index.js +65 -0
  55. package/dist/server/collections/mapConfiguration.d.ts +2 -0
  56. package/dist/server/collections/mapConfiguration.js +51 -0
  57. package/dist/server/constants.d.ts +1 -0
  58. package/dist/server/constants.js +27 -0
  59. package/dist/server/fields/circle.d.ts +12 -0
  60. package/dist/server/fields/circle.js +67 -0
  61. package/dist/server/fields/index.d.ts +4 -0
  62. package/dist/server/fields/index.js +27 -0
  63. package/dist/server/fields/lineString.d.ts +12 -0
  64. package/dist/server/fields/lineString.js +74 -0
  65. package/dist/server/fields/point.d.ts +12 -0
  66. package/dist/server/fields/point.js +77 -0
  67. package/dist/server/fields/polygon.d.ts +12 -0
  68. package/dist/server/fields/polygon.js +73 -0
  69. package/dist/server/helpers/index.d.ts +6 -0
  70. package/dist/server/helpers/index.js +56 -0
  71. package/dist/server/index.d.ts +1 -0
  72. package/dist/server/index.js +33 -0
  73. package/dist/server/plugin.d.ts +11 -0
  74. package/dist/server/plugin.js +86 -0
  75. package/dist/server/value-parsers/index.d.ts +13 -0
  76. package/dist/server/value-parsers/index.js +77 -0
  77. package/dist/swagger/index.d.ts +77 -0
  78. package/dist/swagger/index.js +100 -0
  79. package/docs/en-US/changelog.md +1 -0
  80. package/docs/en-US/index.md +1 -0
  81. package/docs/en-US/installation.md +1 -0
  82. package/docs/en-US/tabs.json +18 -0
  83. package/docs/en-US/usage.md +1 -0
  84. package/docs/zh-CN/changelog.md +1 -0
  85. package/docs/zh-CN/index.md +1 -0
  86. package/docs/zh-CN/installation.md +1 -0
  87. package/docs/zh-CN/tabs.json +18 -0
  88. package/docs/zh-CN/usage.md +1 -0
  89. package/package.json +42 -0
  90. package/server.d.ts +2 -0
  91. package/server.js +1 -0
@@ -0,0 +1,98 @@
1
+ (function(B,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("react"),require("@tachybase/client"),require("@tachybase/schema"),require("@ant-design/icons"),require("ahooks"),require("antd"),require("react-router-dom"),require("lodash"),require("@tachybase/components")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tachybase/client","@tachybase/schema","@ant-design/icons","ahooks","antd","react-router-dom","lodash","@tachybase/components"],n):(B=typeof globalThis!="undefined"?globalThis:B||self,n(B["@tachybase/plugin-block-map"]={},B.jsxRuntime,B.react,B["@tachybase/client"],B["@tachybase/schema"],B["@ant-design/icons"],B.ahooks,B.antd,B["react-router-dom"],B.lodash,B["@tachybase/components"]))})(this,function(B,n,f,a,K,te,V,w,oe,pe,qe){"use strict";var Tt=Object.defineProperty,zt=Object.defineProperties;var Bt=Object.getOwnPropertyDescriptors;var je=Object.getOwnPropertySymbols;var Kt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable;var Pe=(B,n,f)=>n in B?Tt(B,n,{enumerable:!0,configurable:!0,writable:!0,value:f}):B[n]=f,O=(B,n)=>{for(var f in n||(n={}))Kt.call(n,f)&&Pe(B,f,n[f]);if(je)for(var f of je(n))Ut.call(n,f)&&Pe(B,f,n[f]);return B},J=(B,n)=>zt(B,Bt(n));var F=(B,n,f)=>Pe(B,typeof n!="symbol"?n+"":n,f);var he=(B,n,f)=>new Promise((a,K)=>{var te=oe=>{try{w(f.next(oe))}catch(pe){K(pe)}},V=oe=>{try{w(f.throw(oe))}catch(pe){K(pe)}},w=oe=>oe.done?a(oe.value):Promise.resolve(oe.value).then(te,V);w((f=f.apply(B,n)).next())});const ye="block-map";function H(e){return a.tval(e,{ns:[ye,"core"]})}function Z(){return a.useTranslation([ye,"core"])}const ke=[{label:H("AMap"),value:"amap"},{label:H("Google Maps"),value:"google"}],be="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV2iEaCDnQ8F/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==",Fe=(e,o,t)=>{const r=o==null?void 0:o.reduce((i,s,l)=>l===o.length-1&&(t==="o2m"||t==="m2m")?i==null?void 0:i.map(m=>m[s]).filter(m=>m!=null):i==null?void 0:i[s],e);return t==="o2m"||t==="m2m"?r:[r]};var Ve=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function We(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Oe={exports:{}};(function(e,o){(function(t,r){e.exports=r()})(Ve,function(){function t(c){var y=[];return c.AMapUI&&y.push(r(c.AMapUI)),c.Loca&&y.push(i(c.Loca)),Promise.all(y)}function r(c){return new Promise(function(y,p){var d=[];if(c.plugins)for(var M=0;M<c.plugins.length;M+=1)l.AMapUI.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);if(m.AMapUI===s.failed)p("前次请求 AMapUI 失败");else if(m.AMapUI===s.notload){m.AMapUI=s.loading,l.AMapUI.version=c.version||l.AMapUI.version,M=l.AMapUI.version;var D=document.body||document.head,U=document.createElement("script");U.type="text/javascript",U.src="https://webapi.amap.com/ui/"+M+"/main.js",U.onerror=function(I){m.AMapUI=s.failed,p("请求 AMapUI 失败")},U.onload=function(){if(m.AMapUI=s.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,_=d.length;I<_;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}for(y();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()});else for(y();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()},D.appendChild(U)}else m.AMapUI===s.loaded?c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,_=d.length;I<_;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}y()}):y():c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):v.AMapUI.push(function(I){I?p(I):d.length?window.AMapUI.loadUI(d,function(){for(var _=0,Y=d.length;_<Y;_++){var N=d[_].split("/").slice(-1)[0];window.AMapUI[N]=arguments[_]}y()}):y()})})}function i(c){return new Promise(function(y,p){if(m.Loca===s.failed)p("前次请求 Loca 失败");else if(m.Loca===s.notload){m.Loca=s.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,M=l.AMap.version.startsWith("2"),D=d.startsWith("2");if(M&&!D||!M&&D)p("JSAPI 与 Loca 版本不对应!!");else{M=l.key,D=document.body||document.head;var U=document.createElement("script");U.type="text/javascript",U.src="https://webapi.amap.com/loca?v="+d+"&key="+M,U.onerror=function(I){m.Loca=s.failed,p("请求 AMapUI 失败")},U.onload=function(){for(m.Loca=s.loaded,y();v.Loca.length;)v.Loca.splice(0,1)[0]()},D.appendChild(U)}}else m.Loca===s.loaded?c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):y():c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):v.Loca.push(function(I){I?p(I):p()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var s;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(s||(s={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:s.notload,AMapUI:s.notload,Loca:s.notload},v={AMap:[],AMapUI:[],Loca:[]},S=[],A=function(c){typeof c=="function"&&(m.AMap===s.loaded?c(window.AMap):S.push(c))};return{load:function(c){return new Promise(function(y,p){if(m.AMap==s.failed)p("");else if(m.AMap==s.notload){var d=c.key,M=c.version,D=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&p("禁止多种API加载方式混用"),l.key=d,l.AMap.version=M||l.AMap.version,l.AMap.plugins=D||l.AMap.plugins,m.AMap=s.loading,M=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)m.AMap=s.failed,p(I);else for(m.AMap=s.loaded,t(c).then(function(){y(window.AMap)}).catch(p);S.length;)S.splice(0,1)[0]()},D=document.createElement("script"),D.type="text/javascript",D.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),D.onerror=function(I){m.AMap=s.failed,p(I)},M.appendChild(D)):p("请填写key")}else if(m.AMap==s.loaded)if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){y(window.AMap)}).catch(p)}):t(c).then(function(){y(window.AMap)}).catch(p)}else if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 JSAPI 混用");else{var U=[];if(c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&U.push(c.plugins[M]);A(function(){U.length?window.AMap.plugin(U,function(){t(c).then(function(){y(window.AMap)}).catch(p)}):t(c).then(function(){y(window.AMap)}).catch(p)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:s.notload,AMapUI:s.notload,Loca:s.notload},v={AMap:[],AMapUI:[],Loca:[]}}}})})(Oe);var Ye=Oe.exports;const Je=We(Ye),Ee="map-configuration",ve=e=>`TACHYBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Ae=e=>{const o=f.useMemo(()=>{const r=sessionStorage.getItem(ve(e));return r&&JSON.parse(r)},[e]),{data:t}=a.useRequest({resource:Ee,action:"get",params:{type:e}},{onSuccess(r){sessionStorage.setItem(ve(e),JSON.stringify(r==null?void 0:r.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},Ze=e=>{const{aMap:o,toCenter:t}=e,{t:r}=Z(),i=f.useRef(),[s,l]=f.useState([]);f.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{i.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=V.useDebounceFn(S=>{i.current&&i.current.search(S||" ",(A,c)=>{if(A==="complete")l(c.poiList.pois.map(y=>J(O({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(A==="no_data"){l([]);return}w.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),v=S=>{const A=s.find(c=>c.value===S);A!=null&&A.location&&t(A.location)};return n.jsx("div",{className:a.css`
2
+ position: absolute;
3
+ top: 10px;
4
+ left: 10px;
5
+ z-index: 10;
6
+ width: calc(100% - 20px);
7
+ `,children:n.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:v,options:s,popupMatchSelectWidth:!1})})},Me={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"}},Ce=f.forwardRef((e,o)=>{const{accessKey:t,securityJsCode:r}=Ae(e.mapType)||{},{value:i,onChange:s,block:l=!1,readonly:m,disabled:v=l,zoom:S=13,overlayCommonOptions:A}=e,{t:c}=Z(),y=K.useFieldSchema(),p=f.useRef(),d=f.useRef(),M=f.useRef(),[D,U]=f.useState([]),[I,_]=f.useState(""),{getField:Y}=a.useCollection_deprecated(),N=f.useMemo(()=>{if(e.type)return e.type;const g=Y(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),T=f.useRef(),z=f.useRef(null),R=oe.useNavigate(),Q=f.useRef(`tachybase-map-${N||""}-${Date.now().toString(32)}`),{modal:ee}=w.App.useApp(),[X]=f.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},A)),se=V.useMemoizedFn(()=>{T.current&&T.current.remove()}),re=V.useMemoizedFn(()=>{(!v||l)&&N!=="point"&&z.current&&(z.current.setTarget(T.current),z.current.open())}),P=V.useMemoizedFn((g,u=!1)=>{let h=null;if(N==="point"){const{lat:C,lng:G}=g.getPosition();h=[G,C]}else if(N==="polygon"||N==="lineString"){if(h=g.getPath().map(C=>[C.lng,C.lat]),h.length<2)return}else if(N==="circle"){const C=g.getCenter(),G=g.getRadius();h=[C.lng,C.lat,G]}u||(se(),T.current=g,re()),s==null||s(h)}),W=V.useMemoizedFn((g=N)=>{const u=Me[g];if(u&&"editor"in u&&!z.current)return z.current=new p.current[u.editor](d.current,null,{createOptions:X,editOptions:X,controlPoint:J(O({},X),{strokeWeight:3}),midControlPoint:J(O({},X),{strokeWeight:2,fillColor:"#fff"})}),z.current.on("adjust",function({target:h}){P(h,!0)}),z.current.on("move",function({target:h}){P(h,!0)}),z.current}),E=V.useMemoizedFn((g=N)=>{var h;if(!M.current||(h=z.current)!=null&&h.getTarget())return;const u=Me[g];u&&M.current[u.mouseTool](O({},X))}),$=V.useMemoizedFn((g=N)=>{M.current||(M.current=new p.current.MouseTool(d.current),M.current.on("draw",function({obj:u}){P(u)}),E(g))}),x=(g,u)=>{d.current&&d.current.setZoomAndCenter(18,g,u)},L=()=>{const g=()=>{se(),z.current&&(z.current.setTarget(),z.current.close()),s==null||s(null)};ee.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById(Q.current),onOk(){g()}})},b=()=>{T.current&&d.current.setFitView([T.current])},k=f.useCallback((g=N,u=i,h)=>{const C=Me[g];if(!C)return;const G=O(O({},X),h);return"transformOptions"in C?Object.assign(G,C.transformOptions(u)):"propertyKey"in C&&(G[C.propertyKey]=u),new p.current[C.overlay](G)},[X]),j=(g=N,u=i,h)=>{if(!p.current)return;const C=k(g,u,h);return C.setMap(d.current),C};f.useEffect(()=>{if(!p.current||!i||!m&&T.current)return;const g=j();d.current.setFitView([g]),T.current=g,v||(W(),re())},[i,D,N,X,v,m]),f.useEffect(()=>{var g,u,h;M.current&&(v?((g=M.current)==null||g.close(),(u=z.current)==null||u.close()):(E(),(h=z.current)==null||h.open()))},[v]),f.useEffect(()=>{!p.current||!N||v||($(),W())},[v,D,N]),f.useEffect(()=>{var u,h;if(!i&&(M.current||z.current)&&(se(),z.current&&(z.current.setTarget(),z.current.close()),s==null||s(null)),!M.current||!z.current)return;z.current.getTarget()?(h=(u=M.current).close)==null||h.call(u):E()},[N,i]),f.useEffect(()=>{if(!t||d.current)return;r&&(window._AMapSecurityConfig={[r.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:r});const g=window.define;return window.define=void 0,Je.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(u=>(window.define=g,requestIdleCallback(()=>{d.current=new u.Map(Q.current,{resizeEnable:!0,zoom:S}),p.current=u,_(""),U([])}))).catch(u=>{typeof u=="string"?u.includes("多个不一致的 key")?_(c("The AccessKey is incorrect, please check it")):_(u):(u==null?void 0:u.type)==="error"&&_("Something went wrong, please refresh the page and try again")}),()=>{var u;(u=d.current)==null||u.destroy(),p.current=null,d.current=null,M.current=null,z.current=null}},[t,N,r]),f.useImperativeHandle(o,()=>({setOverlay:j,getOverlay:k,createMouseTool:$,createEditor:W,executeMouseTool:E,aMap:p.current,map:d.current,overlay:T.current,mouseTool:()=>M.current,editor:()=>z.current,errMessage:I}));const q=a.useApp();return!t||I?n.jsx(w.Alert,{action:n.jsx(w.Button,{type:"primary",onClick:()=>R(q.systemSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:I||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):n.jsxs("div",{className:a.css`
8
+ position: relative;
9
+ height: 500px;
10
+ `,id:Q.current,style:e==null?void 0:e.style,children:[!p.current&&n.jsx("div",{className:a.css`
11
+ position: absolute;
12
+ inset: 0;
13
+ display: flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ `,children:n.jsx(w.Spin,{})}),v?null:n.jsxs(n.Fragment,{children:[n.jsx(Ze,{toCenter:x,aMap:p.current}),n.jsx("div",{className:a.css`
17
+ position: absolute;
18
+ bottom: 80px;
19
+ right: 20px;
20
+ z-index: 10;
21
+ `,children:n.jsx(w.Button,{onClick:b,disabled:!T.current,type:"primary",shape:"round",size:"large",icon:n.jsx(te.SyncOutlined,{})})}),N!=="point"?n.jsx("div",{className:a.css`
22
+ position: absolute;
23
+ bottom: 20px;
24
+ left: 10px;
25
+ z-index: 2;
26
+ pointer-events: none;
27
+ `,children:n.jsx(w.Alert,{message:c("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,n.jsx("div",{className:a.css`
28
+ position: absolute;
29
+ bottom: 20px;
30
+ right: 20px;
31
+ z-index: 2;
32
+ `,children:n.jsx(w.Button,{disabled:!i,style:{height:"40px"},onClick:L,type:"primary",danger:!0,children:c("Clear")})})]})]})});Ce.displayName="AMapComponent";const Xe=e=>{var P,W,E,$;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:i,zoom:s,setSelectedRecordKeys:l,lineSort:m}=a.useProps(e),{name:v,getPrimaryKey:S}=a.useCollection_deprecated(),{getCollectionJoinField:A}=a.useCollectionManager_deprecated(),c=S(),[y,p]=f.useState(!1),d=f.useRef(),M=(W=(P=d.current)==null?void 0:P.aMap)==null?void 0:W.GeometryUtil,[D,U]=f.useState(),[I,_]=f.useState(""),{t:Y}=Z(),N=a.useCompile(),{isConnected:T,doFilter:z}=a.useFilterAPI(),[,R]=f.useState(null),Q=f.useRef(I);Q.current=I;const ee=(x,L)=>{const b=x.getExtData(),k=typeof L=="undefined"?b.selected:!L;b.selected=!k,"setIcon"in x&&x.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:k?ue:be})),x.setOptions(O({extData:b},k?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},X=()=>{var x,L,b;d.current&&((x=d.current)==null||x.mouseTool().close(!0),(L=d.current)==null||L.editor().setTarget(null),(b=d.current)==null||b.editor().close())};f.useEffect(()=>{var x,L,b,k;if(I==="selection")return(x=d.current)!=null&&x.editor()?(k=d.current)==null||k.executeMouseTool("polygon"):((L=d.current)==null||L.createEditor("polygon"),(b=d.current)==null||b.createMouseTool("polygon")),()=>{X()}},[I]),f.useEffect(()=>{if(I)return()=>{var x;Q.current||(x=d.current)==null||x.map.getAllOverlays().forEach(L=>{ee(L,!1)})}},[I]);const se=V.useMemoizedFn(()=>{var j,q,g;const x=(j=d.current)==null?void 0:j.editor().getTarget(),L=(q=d.current)==null?void 0:q.map.getAllOverlays(),b=L==null?void 0:L.filter(u=>{if(!(u===x||u.getExtData().id===void 0))return"getPosition"in u?M.isPointInRing(u.getPosition(),x==null?void 0:x.getPath()):M.doesRingRingIntersect(u.getPath(),x==null?void 0:x.getPath())}),k=b==null?void 0:b.map(u=>(ee(u,!0),u.getExtData().id));l(u=>k==null?void 0:k.concat(u)),x==null||x.remove(),(g=d.current)==null||g.editor().close()});f.useEffect(()=>{var j,q,g;if(!o||!d.current||!r)return;const x=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,L=A([v,...x].flat().join(".")),b=r.map(u=>{var C;const h=(C=Fe(u,t==null?void 0:t.field,L==null?void 0:L.interface))==null?void 0:C.filter(Boolean);return h!=null&&h.length?h.map(G=>{var ie;return(ie=d.current)==null?void 0:ie.setOverlay(o.type,G,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?N(u[t.marker]):void 0},extData:{id:u[c]}})}):[]}).flat().filter(Boolean);(q=(j=d.current)==null?void 0:j.map)==null||q.setFitView(b);const k=b.map(u=>{const h=C=>{const G=C.target,ne=G.getExtData();if(!ne)return;if(Q.current){Q.current==="click"&&(l(ae=>ne.selected?ae.filter(Ie=>Ie!==ne.id):[...ae,ne.id]),ee(G));return}const ie=r.find(ae=>ne.id===ae[c]);if(T){R(ae=>(ae&&Le(ae),ae===u?(Le(u),z(null),null):(Qe(u),z(ie[c],Ie=>Ie.field||c,"$eq"),u)));return}ie&&U(ie)};return u.on("click",h),()=>u.off("click",h)});if(o.type==="point"&&(m!=null&&m.length)&&(b==null?void 0:b.length)>1){const u=b.map(C=>C.getPosition());b[0].setzIndex(13),b[b.length-1].setzIndex(13);const h=(C=!0)=>{var G,ne;if((G=d.current)!=null&&G.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:Y(C?"Start point":"End point")},position:u[C?0:u.length-1],map:(ne=d.current)==null?void 0:ne.map})};b.push(...[(g=d.current)==null?void 0:g.setOverlay("lineString",u,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),h(),h(!1)].filter(Boolean))}return()=>{b.forEach(u=>{u.remove()}),k.forEach(u=>u())}},[r,y,t,v,c,o.type,T,m]),f.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const re=x=>{d.current=x,p(!!(x!=null&&x.map)&&!x.errMessage)};return n.jsxs("div",{className:a.css`
33
+ position: relative;
34
+ height: 100%;
35
+ `,children:[n.jsx("div",{className:a.css`
36
+ position: absolute;
37
+ left: 10px;
38
+ top: 10px;
39
+ z-index: 999;
40
+ `,children:y&&!((E=d.current)!=null&&E.errMessage)?n.jsxs(w.Space,{direction:"vertical",children:[n.jsx(w.Button,{style:{color:I?void 0:"#F18b62",borderColor:"currentcolor"},onClick:x=>{x.stopPropagation(),_("")},icon:n.jsx(te.EnvironmentOutlined,{})}),n.jsx(w.Button,{style:{color:I==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:x=>{x.stopPropagation(),_("selection")},icon:n.jsx(te.ExpandOutlined,{})}),I==="selection"?n.jsx(w.Button,{type:"primary",icon:n.jsx(te.CheckOutlined,{}),title:Y("Confirm selection"),onClick:se}):null]}):null}),n.jsx(He,{record:D,setVisible:U}),n.jsx(Ce,J(O({},($=o==null?void 0:o.uiSchema)==null?void 0:$["x-component-props"]),{ref:re,style:{height:i?"100%":null},zoom:s,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},He=e=>{const{setVisible:o,record:t}=e,r=a.useCollectionParentRecordData(),i=K.useFieldSchema(),s=f.useMemo(()=>i.reduceProperties((l,m)=>m.name==="drawer"?m:l,null),[i]);return s&&n.jsx(a.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.jsx(a.RecordProvider,{record:t,parent:r,children:n.jsx(K.RecursionField,{schema:s,name:s.name})})})};function Le(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function Qe(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 De=({type:e,children:o})=>{const{t}=Z(),[r,i]=V.useBoolean(!1),s=a.useAPIClient(),[l]=w.Form.useForm(),m=Ae(e);f.useEffect(()=>{m&&(l.setFieldsValue(m),i.toggle())},[m]);const v=f.useMemo(()=>s.resource(Ee),[s]),S=A=>{v.set(J(O({},A),{type:e})).then(c=>{sessionStorage.removeItem(ve(e)),i.toggle(),w.message.success(t("Saved successfully"))}).catch(c=>{w.message.success(t("Saved failed"))})};return n.jsxs(w.Form,{disabled:r,form:l,layout:"vertical",onFinish:S,children:[o,r?n.jsx(w.Button,{disabled:!1,onClick:i.toggle,children:t("Edit")}):n.jsx(w.Form.Item,{children:n.jsx(w.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},$e={amap:()=>{const{t:e}=Z();return n.jsxs(De,{type:"amap",children:[n.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:n.jsx(w.Input,{})}),n.jsx(w.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:n.jsx(w.Input,{})})]})},google:()=>{const{t:e}=Z();return n.jsx(De,{type:"google",children:n.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:n.jsx(w.Input,{})})})}},Re=ke.map(e=>J(O({},e),{component:$e[e.value]})),et=()=>{const e=a.useCompile(),o=oe.useLocation(),t=new URLSearchParams(o.search);return n.jsx(w.Card,{bordered:!0,children:n.jsx(w.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:Re.map(r=>n.jsx(w.Tabs.TabPane,{tab:e(r.label),children:n.jsx(r.component,{type:r.value})},r.value))})})};function tt(e,o,t,r){function i(s){return s instanceof t?s:new t(function(l){l(s)})}return new(t||(t=Promise))(function(s,l){function m(A){try{S(r.next(A))}catch(c){l(c)}}function v(A){try{S(r.throw(A))}catch(c){l(c)}}function S(A){A.done?s(A.value):i(A.value).then(m,v)}S((r=r.apply(e,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;function ot(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var rt=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 r,i,s;if(Array.isArray(o)){if(r=o.length,r!=t.length)return!1;for(i=r;i--!==0;)if(!e(o[i],t[i]))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(s=Object.keys(o),r=s.length,r!==Object.keys(t).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[i]))return!1;for(i=r;i--!==0;){var l=s[i];if(!e(o[l],t[l]))return!1}return!0}return o!==o&&t!==t},nt=ot(rt);const Te="__googleMapsScriptId";var de;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(de||(de={}));class le{constructor({apiKey:o,authReferrerPolicy:t,channel:r,client:i,id:s=Te,language:l,libraries:m=[],mapIds:v,nonce:S,region:A,retries:c=3,url:y="https://maps.googleapis.com/maps/api/js",version:p}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=o,this.authReferrerPolicy=t,this.channel=r,this.client=i,this.id=s||Te,this.language=l,this.libraries=m,this.mapIds=v,this.nonce=S,this.region=A,this.retries=c,this.url=y,this.version=p,le.instance){if(!nt(this.options,le.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(le.instance.options)}`);return le.instance}le.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?de.FAILURE:this.done?de.SUCCESS:this.loading?de.LOADING:de.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let o=this.url;return o+="?callback=__googleMapsCallback&loading=async",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+=`&region=${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(r=>{r?t(r.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 r={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(r).forEach(s=>!r[s]&&delete r[s]),!((t=(o=window==null?void 0:window.google)===null||o===void 0?void 0:o.maps)===null||t===void 0)&&t.importLibrary||(s=>{let l,m,v,S="The Google Maps JavaScript API",A="google",c="importLibrary",y="__ib__",p=document,d=window;d=d[A]||(d[A]={});const M=d.maps||(d.maps={}),D=new Set,U=new URLSearchParams,I=()=>l||(l=new Promise((_,Y)=>tt(this,void 0,void 0,function*(){var N;yield m=p.createElement("script"),m.id=this.id,U.set("libraries",[...D]+"");for(v in s)U.set(v.replace(/[A-Z]/g,T=>"_"+T[0].toLowerCase()),s[v]);U.set("callback",A+".maps."+y),m.src=this.url+"?"+U,M[y]=_,m.onerror=()=>l=Y(Error(S+" could not load.")),m.nonce=this.nonce||((N=p.querySelector("script[nonce]"))===null||N===void 0?void 0:N.nonce)||"",p.head.append(m)})));M[c]?console.warn(S+" only loads once. Ignoring:",s):M[c]=(_,...Y)=>D.add(_)&&I().then(()=>M[c](_,...Y))})(r);const i=this.libraries.map(s=>this.importLibrary(s));i.length||i.push(this.importLibrary("core")),Promise.all(i).then(()=>this.callback(),s=>{const l=new ErrorEvent("error",{error:s});this.loadErrorCallback(l)})}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.loading)if(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=!0,this.setScript()}}}const st=e=>{const{toCenter:o,mapRef:t}=e,{t:r}=Z(),i=f.useRef(),[s,l]=f.useState([]);f.useEffect(()=>{google.maps.importLibrary("places").then(S=>{i.current=new S.AutocompleteService}).catch(()=>{w.message.error("Please configure the Google API Key correctly")})},[t]);const{run:m}=V.useDebounceFn(S=>{i.current&&i.current.getPlacePredictions({input:S||" "},(A,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)l(A.map(y=>{const p=y.structured_formatting;return J(O({},y),{label:`${p.main_text}${p.secondary_text?" "+p.secondary_text:""}`,value:y.place_id})}));else{l([]);return}})},{wait:300}),v=S=>{const A=s.find(y=>y.value===S);new google.maps.places.PlacesService(t.current).getDetails({placeId:A.place_id,fields:["geometry"]},(y,p)=>{p===google.maps.places.PlacesServiceStatus.OK&&o(y.geometry.location)})};return n.jsx("div",{className:a.css`
41
+ position: absolute;
42
+ top: 10px;
43
+ left: 10px;
44
+ z-index: 10;
45
+ width: calc(100% - 20px);
46
+ `,children:n.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:v,options:s})})},ce=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),it=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:r,longitude:i}=t.coords;e({lat:r,lng:i})},()=>{o()}):o()}),at=e=>e==="point"?"marker":e==="lineString"?"polyline":e,lt={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"}},Se=f.forwardRef((e,o)=>{const{value:t,onChange:r,block:i=!1,readonly:s,disabled:l=i,zoom:m=13,overlayCommonOptions:v}=e,{accessKey:S}=Ae(e.mapType)||{},{t:A}=Z(),{getField:c}=a.useCollection_deprecated(),y=K.useFieldSchema(),p=f.useRef(),d=f.useRef(),M=f.useRef(),[D,U]=f.useState([]),[I,_]=f.useState(""),Y=a.useAPIClient(),{modal:N}=w.App.useApp(),T=f.useMemo(()=>{if(e.type)return e.type;const g=c(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),z=f.useRef(at(T)),[R]=f.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},v)),Q=oe.useNavigate(),ee=f.useRef(),X=f.useRef(new Set),se=V.useMemoizedFn(g=>{if(X.current.forEach(u=>{X.current.delete(u)}),"getPath"in g){const u=g.getPath();["insert_at","remove_at","set_at"].forEach(h=>{X.current.add(u.addListener(h,()=>{x(g,!0)}).remove)})}else g instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(u=>{X.current.add(g.addListener(u,()=>{x(g,!0)}).remove)})}),re=V.useMemoizedFn(()=>{var g;M.current&&(M.current.unbindAll(),M.current.setMap(null)),T!=="point"&&((g=p.current)==null||g.setDrawingMode(null))}),P=V.useMemoizedFn(g=>{d.current&&(d.current.setCenter(g),d.current.setZoom(m))}),W=V.useMemoizedFn(g=>{re(),se(g),M.current=g}),E=V.useMemoizedFn(g=>{const u=new google.maps.LatLngBounds;g.forEach(h=>{if(h instanceof google.maps.Marker)u.extend(h.getPosition());else if(h instanceof google.maps.Polyline||h instanceof google.maps.Polygon){const C=h.getPath();for(let G=0;G<C.getLength();G++)u.extend(C.getAt(G))}else h instanceof google.maps.Circle&&u.union(h.getBounds())}),d.current.setCenter(u.getCenter())}),$=()=>{M.current&&E([M.current])},x=V.useMemoizedFn((g,u=!1)=>{let h=null;if(T==="point"){const{lat:C,lng:G}=g.getPosition();h=[G(),C()]}else if(T==="polygon"||T==="lineString"){if(h=g.getPath().getArray().map(C=>[C.lng(),C.lat()]),h.length<2)return}else if(T==="circle"){const C=g.getCenter(),G=g.getRadius();h=[C.lng(),C.lat(),G]}u||W(g),r==null||r(h)}),L=V.useMemoizedFn((g=!1,u)=>{const h=J(O(O({},R),u),{map:d.current});return p.current=new google.maps.drawing.DrawingManager({drawingMode:z.current,drawingControl:!1,markerOptions:J(O({},h),{icon:ce(ue)}),polygonOptions:h,polylineOptions:h,circleOptions:h,map:d.current}),g||p.current.addListener("overlaycomplete",C=>{const G=C.overlay;x(G)}),p.current}),b=V.useMemoizedFn((g=T,u=t,h)=>{const C=lt[g];if(!C)return;const G=O(J(O({},R),{icon:ce(ue)}),h);return"transformOptions"in C?Object.assign(G,C.transformOptions(u)):"propertyKey"in C&&(G[C.propertyKey]=Array.isArray(u[0])?u.map(ie=>new google.maps.LatLng(ie[1],ie[0])):new google.maps.LatLng(u[1],u[0])),new google.maps[C.overlay](G)}),k=V.useMemoizedFn((g=T,u=t,h)=>d.current?b(g,u,J(O({},h),{map:d.current})):void 0);f.useEffect(()=>{var u,h;if(!t&&d.current&&(re(),(h=(u=p==null?void 0:p.current)==null?void 0:u.setDrawingMode)==null||h.call(u,z.current),r==null||r(null)),!d.current||!t||!s&&M.current)return;const g=k();W(g),E([g])},[t,D,T,l,s,k,E,W]),f.useEffect(()=>{if(!S||d.current||!ee.current)return;let g;try{g=new le({apiKey:S,version:"weekly",language:Y.auth.getLocale()})}catch(h){_(A("Load google maps failed, Please check the Api key and refresh the page"));return}const u=console.error;return console.error=(h,...C)=>{h!=null&&h.includes("InvalidKeyMapError")&&_(A("Load google maps failed, Please check the Api key and refresh the page")),u(h,...C)},Promise.all([g.importLibrary("drawing"),g.importLibrary("core"),g.importLibrary("geometry")]).then(h=>he(this,null,function*(){const C=yield it();d.current=new google.maps.Map(ee.current,{zoom:m,center:C,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),_(""),U([])})).catch(h=>{if(h instanceof Error){_(h.message);return}}),()=>{var h,C;(h=d.current)==null||h.unbindAll(),d.current=null,(C=p.current)==null||C.unbindAll()}},[S,Y.auth,T,m]),f.useEffect(()=>{!d.current||!T||l||p.current||L()},[L,l,D,T]),f.useImperativeHandle(o,()=>({setOverlay:k,getOverlay:b,setFitView:E,createDraw:L,map:d.current,overlay:M.current,drawingManager:p.current,errMessage:I}));const j=V.useMemoizedFn(()=>{const g=()=>{re(),p.current.setDrawingMode(z.current),r==null||r(null)};N.confirm({title:A("Clear the canvas"),content:A("Are you sure to clear the canvas?"),okText:A("Confirm"),cancelText:A("Cancel"),getContainer:()=>ee.current,onOk(){g()}})}),q=a.useApp();return!S||I?n.jsx(w.Alert,{action:n.jsx(w.Button,{type:"primary",onClick:()=>Q(q.systemSettingsManager.getRoutePath("map")+"?tab=google"),children:A("Go to the configuration page")}),message:I||A("Please configure the Api key first"),type:"error"}):n.jsxs("div",{className:a.css`
47
+ position: relative;
48
+ height: 500px;
49
+ `,children:[!d.current&&n.jsx("div",{className:a.css`
50
+ position: absolute;
51
+ inset: 0;
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: center;
55
+ `,children:n.jsx(w.Spin,{})}),l?null:n.jsxs(n.Fragment,{children:[d.current&&n.jsx(st,{toCenter:P,mapRef:d}),n.jsx("div",{className:a.css`
56
+ position: absolute;
57
+ bottom: 80px;
58
+ right: 20px;
59
+ z-index: 10;
60
+ `,children:n.jsx(w.Button,{onClick:$,disabled:!M.current,type:"primary",shape:"round",size:"large",icon:n.jsx(te.SyncOutlined,{})})}),T==="lineString"||T==="polygon"?n.jsx("div",{className:a.css`
61
+ position: absolute;
62
+ bottom: 20px;
63
+ left: 10px;
64
+ z-index: 2;
65
+ pointer-events: none;
66
+ `,children:n.jsx(w.Alert,{message:A("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,n.jsx("div",{className:a.css`
67
+ position: absolute;
68
+ bottom: 20px;
69
+ right: 20px;
70
+ z-index: 2;
71
+ `,children:n.jsx(w.Button,{disabled:!t,style:{height:"40px"},onClick:j,type:"primary",danger:!0,children:A("Clear")})})]}),n.jsx("div",{ref:ee,className:a.css`
72
+ width: 100%;
73
+ height: 100%;
74
+ `,style:e==null?void 0:e.style})]})});Se.displayName="GoogleMapsComponent";const fe="google-maps-overlay-id",ze="google-maps-overlay-selected",ct=a.css`
75
+ margin-top: 6px;
76
+ padding: 2px 4px;
77
+ background: #fff;
78
+ border: 1px solid #0000f5;
79
+ `,pt=a.css`
80
+ margin-top: -64px;
81
+ padding: 2px 4px;
82
+ background: #fff;
83
+ border: 1px solid #0000f5;
84
+ `,ut=e=>{const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:i,zoom:s,setSelectedRecordKeys:l,lineSort:m}=a.useProps(e),{getPrimaryKey:v}=a.useCollection_deprecated(),S=v(),{marker:A="id"}=t,[c,y]=f.useState(!1),p=f.useRef(),[d,M]=f.useState(),[D,U]=f.useState(""),{t:I}=Z(),_=a.useCompile(),{isConnected:Y,doFilter:N}=a.useFilterAPI(),[,T]=f.useState(null),z=f.useRef(D),R=f.useRef(null),Q=f.useRef([]);z.current=D;const{getCollectionJoinField:ee}=a.useCollectionManager_deprecated(),X=(P,W)=>{const E=typeof W!="undefined"?!W:P.get(ze);P.set(ze,!E),P.setOptions(O({},E?{icon:ce(ue),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:ce(be),strokeColor:"#F18b62",fillColor:"#F18b62"}))};f.useEffect(()=>{var W,E,$,x;if(D!=="selection")return;p.current&&!((W=p.current)!=null&&W.drawingManager)&&(p.current.drawingManager=(E=p.current)==null?void 0:E.createDraw(!0,{editable:!0,draggable:!0}));const P=new Set;return($=p.current)==null||$.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(x=p.current)==null||x.drawingManager.addListener("overlaycomplete",L=>{var j;const b=L.overlay;(j=p.current)==null||j.drawingManager.setDrawingMode(null),R.current=b;const k=b.getPath();["insert_at","remove_at","set_at"].forEach(q=>{P.add(k.addListener(q,()=>{}).remove)})}),()=>{var L,b,k,j;P.forEach(q=>{q()}),p.current&&((L=R.current)==null||L.unbindAll(),(b=R.current)==null||b.setMap(null),R.current=null,(k=p.current)==null||k.drawingManager.setDrawingMode(null),(j=p.current)==null||j.drawingManager.unbindAll())}},[D]),f.useEffect(()=>{if(D)return()=>{z.current||Q.current.forEach(P=>{X(P,!1)})}},[D]);const se=V.useMemoizedFn(()=>{var L;const P=R.current,W=Q.current,E=google.maps.geometry.poly,x=W.filter(b=>{if(!(b===P||b.get(fe)===void 0))return b instanceof google.maps.Marker?E.containsLocation(b.getPosition(),P):b instanceof google.maps.Circle?E.containsLocation(b.getCenter(),P):b.getPath().getArray().some(k=>E.containsLocation(k,P))}).map(b=>(X(b,!0),b.get(fe)));l(b=>x.concat(b)),P==null||P.unbindAll(),P==null||P.setMap(null),(L=p.current)==null||L.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});f.useEffect(()=>{var x,L;if(!o||!(r!=null&&r.length)||!((x=p.current)!=null&&x.map))return;const P=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,W=ee([name,...P].flat().join(".")),E=r.map(b=>{const k=Fe(b,t==null?void 0:t.field,W==null?void 0:W.interface);return k!=null&&k.length?k==null?void 0:k.filter(Boolean).map(j=>{var g;if(!k)return;const q=(g=p.current)==null?void 0:g.setOverlay(o.type,j,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:ct,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?_(b[A]):void 0}});return q==null||q.set(fe,b[S]),q}):[]}).flat().filter(Boolean);Q.current=E;const $=E.map(b=>{const k=j=>{const q=b,g=q.get(fe);if(!g)return;const u=r==null?void 0:r.find(h=>g===h[S]);if(Y){T(h=>(h&&Be(q),h===b?(Be(q),N(null),null):(ft(q),N(u[S],C=>C.field||S,"$eq"),q)));return}u&&M(u)};return b.addListener("click",k),()=>b.unbindAll()});if(o.type==="point"&&(m!=null&&m.length)&&(E==null?void 0:E.length)>1){const b=E.map(j=>j.getPosition());E[0].setZIndex(138),E[E.length-1].setZIndex(138);const k=(j=!0)=>{var q;if((q=p.current)!=null&&q.map)return new google.maps.Marker({label:{className:pt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:I(j?"Start point":"End point")},icon:ce(ue),position:j?b[0]:b[b.length-1],map:p.current.map})};E.push(...[p.current.setOverlay("lineString",b.map(j=>[j.lng(),j.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),k(),k(!1)].filter(Boolean))}return(L=p.current)==null||L.setFitView(E),()=>{E.forEach(b=>{b.setMap(null),b.unbindAll()}),$.forEach(b=>b())}},[r,c,A,o.type,Y]),f.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const re=P=>{p.current=P,y(!!(P!=null&&P.map)&&!P.errMessage)};return n.jsxs("div",{className:a.css`
85
+ position: relative;
86
+ height: 100%;
87
+ `,children:[c&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:a.css`
88
+ position: absolute;
89
+ left: 10px;
90
+ top: 10px;
91
+ z-index: 999;
92
+ `,children:n.jsxs(w.Space,{direction:"vertical",children:[n.jsx(w.Button,{style:{color:D?void 0:"#F18b62",borderColor:"currentcolor"},onClick:P=>{P.stopPropagation(),U("")},icon:n.jsx(te.EnvironmentOutlined,{})}),n.jsx(w.Button,{style:{color:D==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:P=>{P.stopPropagation(),U("selection")},icon:n.jsx(te.ExpandOutlined,{})}),D==="selection"?n.jsx(w.Button,{type:"primary",icon:n.jsx(te.CheckOutlined,{}),title:I("Confirm selection"),onClick:se}):null]})}),n.jsx(dt,{record:d,setVisible:M})]}),n.jsx(Se,J(O({},e),{ref:re,style:{height:i?"100%":null},zoom:s,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},dt=e=>{const{setVisible:o,record:t}=e,r=a.useCollectionParentRecordData(),i=K.useFieldSchema(),s=f.useMemo(()=>i.reduceProperties((l,m)=>m.name==="drawer"?m:l,null),[i]);return s&&n.jsx(a.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.jsx(a.RecordProvider,{record:t,parent:r,children:n.jsx(K.RecursionField,{schema:s,name:s.name})})})};function Be(e){if(e instanceof google.maps.Marker)return e.setIcon(ce(ue));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function ft(e){if(e instanceof google.maps.Marker)return e.setIcon(ce(be));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const gt=()=>{var c;const{getCollectionJoinField:e}=a.useCollectionManager_deprecated(),{getField:o}=a.useCollection_deprecated(),{form:t}=a.useFormBlockContext(),r=K.useField(),i=K.useFieldSchema(),{t:s}=Z(),{dn:l,refresh:m}=a.useDesignable(),v=o(i.name)||e(i["x-collection-field"]),S=(c=v==null?void 0:v.uiSchema)==null?void 0:c.title;r.title===S||r.title,r.readPretty||r.required;let A="editable";return i["x-disabled"]===!0&&(A="readonly"),i["x-read-pretty"]===!0&&(A="read-pretty"),n.jsxs(a.GeneralSchemaDesigner,{children:[n.jsx(a.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!a.isPatternDisabled(i)&&n.jsx(a.SchemaSettingsSelectItem,{title:s("Pattern"),options:[{label:s("Editable"),value:"editable"},{label:s("Readonly"),value:"readonly"},{label:s("Easy-reading"),value:"read-pretty"}],value:A,onChange:y=>{const p={"x-uid":i["x-uid"]};switch(y){case"readonly":{i["x-read-pretty"]=!1,i["x-disabled"]=!0,p["x-read-pretty"]=!1,p["x-disabled"]=!0,r.readPretty=!1,r.disabled=!0;break}case"read-pretty":{i["x-read-pretty"]=!0,i["x-disabled"]=!1,p["x-read-pretty"]=!0,p["x-disabled"]=!1,r.readPretty=!0;break}default:{i["x-read-pretty"]=!1,i["x-disabled"]=!1,p["x-read-pretty"]=!1,p["x-disabled"]=!1,r.readPretty=!1,r.disabled=!1;break}}l.emit("patch",{schema:p}),l.refresh()}},"pattern"),n.jsx(a.SchemaSettingsModalItem,{title:s("Set default zoom level"),schema:{type:"object",title:s("Set default zoom level"),properties:{zoom:{title:s("Zoom"),default:r.componentProps.zoom||13,description:s("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:y})=>{y&&(pe.set(i,"x-component-props.zoom",y),Object.assign(r.componentProps,i["x-component-props"]),l.emit("patch",{schema:{"x-uid":i["x-uid"],"x-component-props":r.componentProps}})),l.refresh()}},"map-zoom"),n.jsx(a.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:s("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},mt={amap:Ce,google:Se},xe=f.forwardRef((e,o)=>{const{t}=Z(),{mapType:r}=e,i=f.useMemo(()=>mt[r],[r]);return i?n.jsx(i,O({ref:o},e)):n.jsx("div",{children:t(`The ${r} cannot found`)})});xe.displayName="MapComponent";const ht=e=>{var m,v;const{value:o}=e,t=K.useFieldSchema(),{getField:r}=a.useCollection_deprecated(),i=r(t.name),s=e.mapType||((m=i==null?void 0:i.uiSchema["x-component-props"])==null?void 0:m.mapType),l=K.useForm();return a.useFieldTitle(),l.readPretty?n.jsx(xe,O({readonly:!0,mapType:s},e)):n.jsx("div",{children:n.jsx(a.EllipsisWithTooltip,{ellipsis:!0,children:(v=o==null?void 0:o.map)==null?void 0:v.call(o,S=>Array.isArray(S)?`(${S.join(",")})`:S).join(",")})})},Ke=K.connect(e=>n.jsx("div",{className:a.css`
93
+ height: 100%;
94
+ border: 1px solid transparent;
95
+ .ant-formily-item-error & {
96
+ border: 1px solid #ff4d4f;
97
+ }
98
+ `,children:n.jsx(xe,O({},e))}),K.mapReadPretty(ht));Ke.Designer=gt;const yt={amap:Xe,google:ut},bt=e=>{const{t:o}=Z(),{mapType:t}=e,r=f.useMemo(()=>yt[t],[t]);return r?n.jsx(r,O({},e)):n.jsx("div",{children:o(`The ${t} cannot found`)})},vt=a.withDynamicSchemaProps(e=>{var l;const{fieldNames:o}=a.useProps(e),{getCollectionJoinField:t}=a.useCollectionManager_deprecated(),{name:r}=a.useCollection_deprecated(),i=f.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),s=(l=i==null?void 0:i.uiSchema)==null?void 0:l["x-component-props"];return n.jsx(bt,J(O(O({},s),e),{collectionField:i}))}),At=()=>{const{name:e,title:o}=a.useCollection(),t=a.useSchemaTemplate();return n.jsx(a.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Mt=e=>{const{collectionName:o,fieldNames:t,dataSource:r}=e;return{type:"void","x-acl-action":`${o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:r,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":{style:{marginBottom:16}}},[K.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}},Ue=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,i)=>{const s=t==null?void 0:t.find(l=>l.value===r);return i===e.length-1?s:s==null?void 0:s.children},o)),Ct=()=>{const e=a.useSchemaInitializerItem(),{insert:o}=a.useSchemaInitializer(),t=f.useContext(K.SchemaOptionsContext),{getCollectionFieldsOptions:r}=a.useCollectionManager_deprecated(),{t:i}=Z(),{theme:s}=a.useGlobalTheme();return n.jsx(a.DataBlockInitializer,O({componentType:"Map",icon:n.jsx(te.TableOutlined,{}),onCreateBlockSchema:m=>he(this,[m],function*({item:l}){const v=r(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:l.dataSource}),S=r(l.name,"string",{dataSource:l.dataSource}),A=yield a.FormDialog(i("Create map block"),()=>{var c;return n.jsx(a.SchemaComponentOptions,{scope:t.scope,components:O({},t.components),children:n.jsx(qe.FormLayout,{layout:"vertical",children:n.jsx(a.SchemaComponent,{schema:{properties:{field:{title:i("Map field"),enum:v,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:v.length?[v[0].value,(c=v[0].children)==null?void 0:c[0].value].filter(y=>y!=null):[]},marker:{title:i("Marker field"),enum:S,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const p=y.form.values.field;if(!(p!=null&&p.length))return;const d=Ue(p,v);d&&(y.hidden=d.type!=="point")}}}}})})})},s).open({initialValues:{}});o(Mt({collectionName:l.name,dataSource:l.dataSource,fieldNames:O({},A)}))}),title:i("Map block")},e))},we=f.createContext({});we.displayName="MapBlockContext";const St=e=>{var v;const{fieldNames:o}=e,t=K.useFieldSchema(),r=K.useField(),{resource:i,service:s}=a.useBlockRequestContext(),[l,m]=f.useState([]);return n.jsx(a.FixedBlockWrapper,{children:n.jsx(a.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:n.jsx(we.Provider,{value:{field:r,service:s,resource:i,fieldNames:o,fixedBlock:(v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:m},children:e.children})})})},xt=e=>{const o=K.useField(),{params:t,fieldNames:r}=e,i=t.appends||[],{field:s}=r||{};return Array.isArray(s)&&s.length>1&&i.push(s[0]),n.jsx(a.BlockProvider,J(O({name:"map"},e),{runWhenParamsChanged:!0,params:J(O({},t),{appends:i,paginate:!1,sort:o.componentProps.lineSort}),children:n.jsx(St,O({},e))}))},ge=()=>f.useContext(we),Ne=()=>{var o,t,r,i,s,l;const e=ge();return J(O({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((i=(r=e==null?void 0:e.field)==null?void 0:r.componentProps)==null?void 0:i.zoom)||13,lineSort:(l=(s=e==null?void 0:e.field)==null?void 0:s.componentProps)==null?void 0:l.lineSort})},wt=e=>n.jsx(a.SchemaComponentOptions,{scope:{useMapBlockProps:Ne},components:{MapBlockInitializer:Ct,MapBlockDesigner:At,MapBlockProvider:xt,MapBlock:vt},children:e.children}),It=new a.SchemaInitializer({name:"map:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){return a.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return a.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return a.useCollection_deprecated().template!=="sql"}}]}),Pt=new a.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:a.SchemaSettingsBlockTitleItem},{name:"fixBlock",Component:a.FixedBlockDesignerItem},{name:"mapField",Component:a.SchemaSettingsCascaderItem,useComponentProps(){var S;const{getCollectionFieldsOptions:e}=a.useCollectionManager_deprecated(),{t:o}=Z(),t=K.useFieldSchema(),r=((S=t==null?void 0:t["x-decorator-props"])==null?void 0:S.fieldNames)||{},i=K.useField(),{dn:s}=a.useDesignable(),{service:l}=ge(),{name:m}=a.useCollection(),v=e(m,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:r.field,options:v,allowClear:!1,onChange:A=>{const c=i.decoratorProps.fieldNames||{};c.field=A,i.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,l.refresh(),s.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":i.decoratorProps}}),s.refresh()}}}},{name:"markerField",Component:a.SchemaSettingsSelectItem,useComponentProps(){var S;const{t:e}=Z(),o=K.useFieldSchema(),t=((S=o==null?void 0:o["x-decorator-props"])==null?void 0:S.fieldNames)||{},{service:r}=ge(),i=K.useField(),{dn:s}=a.useDesignable(),{getCollectionFieldsOptions:l}=a.useCollectionManager_deprecated(),{name:m}=a.useCollection(),v=l(m,"string");return{title:e("Marker field"),value:t.marker,options:v,onChange:A=>{const c=i.decoratorProps.fieldNames||{};c.marker=A,i.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,r.refresh(),s.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":i.decoratorProps}}),s.refresh()}}},useVisible(){var l,m;const e=K.useFieldSchema(),{getCollectionFieldsOptions:o}=a.useCollectionManager_deprecated(),{name:t}=a.useCollection(),r=((l=e==null?void 0:e["x-decorator-props"])==null?void 0:l.fieldNames)||{},i=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=Ue(r.field,i))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:a.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=Z();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},a.setDataLoadingModeSettingsItem,{name:"defaultZoomLevel",Component:a.SchemaSettingsModalItem,useComponentProps(){var s;const{t:e}=Z(),o=K.useFieldSchema(),t=K.useField(),{dn:r}=a.useDesignable(),i=((s=o==null?void 0:o["x-component-props"])==null?void 0:s.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:i,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:l})=>{pe.set(o,"x-component-props.zoom",l),Object.assign(t.componentProps,o["x-component-props"]),r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),r.refresh()}}}},{name:"dataScope",Component:a.SchemaSettingsDataScope,useComponentProps(){var m,v;const{name:e}=a.useCollection(),o=K.useFieldSchema(),{form:t}=a.useFormBlockContext(),r=K.useField(),{service:i}=ge(),{dn:s}=a.useDesignable(),l=a.useDataLoadingMode();return{collectionName:e,defaultFilter:((v=(m=o==null?void 0:o["x-decorator-props"])==null?void 0:m.params)==null?void 0:v.filter)||{},form:t,onSubmit:({filter:S})=>{var y,p,d;const A=r.decoratorProps.params||{};A.filter=S,r.decoratorProps.params=A,o["x-decorator-props"].params=A;const c=((p=(y=i.params)==null?void 0:y[1])==null?void 0:p.filters)||{};l==="auto"&&i.run(J(O({},(d=i.params)==null?void 0:d[0]),{filter:a.mergeFilter([...Object.values(c),S]),page:1}),{filters:c}),s.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:a.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=Z();return{type:a.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:a.SchemaSettingsTemplate,useComponentProps(){var r,i;const{name:e}=a.useCollection(),o=K.useFieldSchema(),t=((r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.resource)||((i=o==null?void 0:o["x-decorator-props"])==null?void 0:i.association);return{componentName:"Map",collectionName:e,resourceName:t}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:kt}=a.interfacesProperties;Array.isArray(a.interfacesProperties.type.enum)&&a.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class me extends a.CollectionFieldInterface{constructor(){super(...arguments);F(this,"properties",J(O({},kt),{"uiSchema.x-component-props.mapType":{title:H("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:ke}}))}schemaInitialize(t,{block:r}){r==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Ft extends me{constructor(){super(...arguments);F(this,"name","circle");F(this,"type","object");F(this,"group","map");F(this,"order",3);F(this,"title",H("Circle"));F(this,"availableTypes",["circle"]);F(this,"description",H("Circle"));F(this,"sortable",!0);F(this,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Ot extends me{constructor(){super(...arguments);F(this,"name","lineString");F(this,"type","object");F(this,"group","map");F(this,"order",2);F(this,"title",H("Line"));F(this,"description",H("Line"));F(this,"availableTypes",["lineString"]);F(this,"sortable",!0);F(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Et extends me{constructor(){super(...arguments);F(this,"name","point");F(this,"type","object");F(this,"group","map");F(this,"order",1);F(this,"title",H("Point"));F(this,"description",H("Point"));F(this,"availableTypes",["point"]);F(this,"sortable",!0);F(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Lt extends me{constructor(){super(...arguments);F(this,"name","polygon");F(this,"type","object");F(this,"group","map");F(this,"order",4);F(this,"title",H("Polygon"));F(this,"description",H("Polygon"));F(this,"availableTypes",["polygon"]);F(this,"sortable",!0);F(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const Dt=[Et,Lt,Ot,Ft],Ge=f.memo(e=>n.jsx(a.SchemaComponentOptions,{components:{Map:Ke},children:n.jsx(wt,{children:e.children})}));Ge.displayName="MapProvider";class _e extends a.Plugin{load(){return he(this,null,function*(){this.app.use(Ge),this.app.dataSourceManager.addFieldInterfaces(Dt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:H("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(It),this.schemaSettingsManager.add(Pt);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:H("Map"),Component:"MapBlockInitializer"}),this.app.systemSettingsManager.add("business-components."+ye,{title:H("Map Manager"),icon:"EnvironmentOutlined",Component:et,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:Ne})})}}B.MapPlugin=_e,B.default=_e,Object.defineProperties(B,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,4 @@
1
+ export declare const NAMESPACE = "block-map";
2
+ export declare function lang(key: string): string;
3
+ export declare function generateNTemplate(key: string): string;
4
+ export declare function useMapTranslation(): import("react-i18next").UseTranslationResponse<[string, string], undefined>;
@@ -0,0 +1 @@
1
+ export type MapEditorType = 'point' | 'polygon' | 'lineString' | 'circle';
@@ -0,0 +1 @@
1
+ export declare const getSource: (data: Record<string, any>, fields?: string[], type?: string) => any;
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ "react": "18.3.1",
3
+ "@tachybase/client": "0.23.8",
4
+ "@tachybase/server": "0.23.8",
5
+ "@tachybase/schema": "0.23.8",
6
+ "lodash": "4.17.21",
7
+ "@tachybase/components": "0.23.8",
8
+ "@ant-design/icons": "5.3.7",
9
+ "ahooks": "3.8.4",
10
+ "antd": "5.22.5",
11
+ "react-router-dom": "6.28.1",
12
+ "@tachybase/actions": "0.23.8",
13
+ "@tachybase/database": "0.23.8"
14
+ };
@@ -0,0 +1,2 @@
1
+ export * from './server';
2
+ export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => import_server.default
32
+ });
33
+ module.exports = __toCommonJS(src_exports);
34
+ __reExport(src_exports, require("./server"), module.exports);
35
+ var import_server = __toESM(require("./server"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ ...require("./server")
39
+ });
@@ -0,0 +1,51 @@
1
+ {
2
+ "AMap": "AMap",
3
+ "Access key": "Access key",
4
+ "Are you sure to clear the canvas?": "Are you sure to clear the canvas?",
5
+ "Cancel": "Cancel",
6
+ "Circle": "Circle",
7
+ "Clear": "Clear",
8
+ "Clear the canvas": "Clear the canvas",
9
+ "Click to select the starting point and double-click to end the drawing": "Click to select the starting point and double-click to end the drawing",
10
+ "Concatenation order field": "Concatenation order field",
11
+ "Configuration": "Configuration",
12
+ "Confirm": "Confirm",
13
+ "Create map block": "Create map block",
14
+ "Delete field": "Delete field",
15
+ "Easy-reading": "Easy-reading",
16
+ "Edit": "Edit",
17
+ "Edit description": "Edit description",
18
+ "Edit field title": "Edit field title",
19
+ "Edit tooltip": "Edit tooltip",
20
+ "Editable": "Editable",
21
+ "End point": "End point",
22
+ "Enter keywords to search": "Enter keywords to search",
23
+ "Field title": "Field title",
24
+ "Go to the configuration page": "Go to the configuration page",
25
+ "Google Maps": "Google Maps",
26
+ "Line": "Line",
27
+ "Load google maps failed, Please check the Api key and refresh the page": "Load google maps failed, Please check the Api key and refresh the page",
28
+ "Map": "Map",
29
+ "Map Manager": "Map Manager",
30
+ "Map field": "Map field",
31
+ "Map type": "Map type",
32
+ "Map-based geometry": "Map-based geometry",
33
+ "Marker field": "Marker field",
34
+ "Operator": "Operator",
35
+ "Pattern": "Pattern",
36
+ "Please configure the AMap securityCode or serviceHost correctly": "Please configure the AMap securityCode or serviceHost correctly",
37
+ "Please configure the AccessKey and SecurityJsCode first": "Please configure the AccessKey and SecurityJsCode first",
38
+ "Point": "Point",
39
+ "Polygon": "Polygon",
40
+ "Readonly": "Readonly",
41
+ "Required": "Required",
42
+ "Save": "Save",
43
+ "Saved failed": "Saved failed",
44
+ "Saved successfully": "Saved successfully",
45
+ "Set default zoom level": "Set default zoom level",
46
+ "Start point": "Start point",
47
+ "The AccessKey is incorrect, please check it": "The AccessKey is incorrect, please check it",
48
+ "The default zoom level of the map": "The default zoom level of the map",
49
+ "Zoom": "Zoom",
50
+ "securityJsCode or serviceHost": "securityJsCode or serviceHost"
51
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "AMap": "AMap",
3
+ "Access key": "액세스 키",
4
+ "Are you sure to clear the canvas?": "캔버스를 지우시겠습니까?",
5
+ "Cancel": "취소",
6
+ "Circle": "원",
7
+ "Clear": "지우기",
8
+ "Clear the canvas": "캔버스 지우기",
9
+ "Click to select the starting point and double-click to end the drawing": "시작점을 선택하려면 클릭하고 그리기를 종료하려면 두 번 클릭하십시오",
10
+ "Concatenation order field": "연결 순서 필드",
11
+ "Configuration": "구성",
12
+ "Confirm": "확인",
13
+ "Create map block": "지도 블록 생성",
14
+ "Delete field": "필드 삭제",
15
+ "Easy-reading": "읽기 전용 (읽기 전용 모드)",
16
+ "Edit": "편집",
17
+ "Edit description": "설명 편집",
18
+ "Edit field title": "필드 제목 편집",
19
+ "Edit tooltip": "툴팁 편집",
20
+ "Editable": "편집 가능",
21
+ "End point": "끝점",
22
+ "Enter keywords to search": "검색할 키워드 입력 (시/도를 반드시 포함해야 함)",
23
+ "Field title": "필드 제목",
24
+ "Go to the configuration page": "구성 페이지로 이동",
25
+ "Google Maps": "Google 지도",
26
+ "Line": "선",
27
+ "Load google maps failed, Please check the Api key and refresh the page": "Google 지도 로드 실패, Api 키를 확인하고 페이지를 새로 고침하세요",
28
+ "Map": "지도",
29
+ "Map Manager": "지도 관리자",
30
+ "Map field": "지도 필드",
31
+ "Map type": "지도 유형",
32
+ "Map-based geometry": "지도 기반 지오메트리",
33
+ "Marker field": "마커 필드",
34
+ "Operator": "연산자",
35
+ "Pattern": "패턴",
36
+ "Please configure the AMap securityCode or serviceHost correctly": "AMap securityCode 또는 serviceHost를 올바르게 구성해 주세요",
37
+ "Please configure the AccessKey and SecurityJsCode first": "먼저 AccessKey 및 SecurityJsCode를 구성하세요",
38
+ "Point": "점",
39
+ "Polygon": "다각형",
40
+ "Readonly": "읽기 전용",
41
+ "Required": "필수",
42
+ "Save": "저장",
43
+ "Saved failed": "저장 실패",
44
+ "Saved successfully": "성공적으로 저장되었습니다",
45
+ "Set default zoom level": "기본 확대/축소 수준 설정",
46
+ "Start point": "시작점",
47
+ "The AccessKey is incorrect, please check it": "액세스 키가 올바르지 않습니다. 확인해 주세요",
48
+ "The default zoom level of the map": "지도의 기본 확대/축소 수준",
49
+ "Zoom": "확대/축소",
50
+ "securityJsCode or serviceHost": "securityJsCode 또는 serviceHost"
51
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "AMap": "AMap",
3
+ "Access key": "Chave de acesso",
4
+ "Are you sure to clear the canvas?": "Tem certeza de que deseja limpar a tela?",
5
+ "Cancel": "Cancelar",
6
+ "Circle": "Círculo",
7
+ "Clear": "Limpar",
8
+ "Clear the canvas": "Limpar a tela",
9
+ "Click to select the starting point and double-click to end the drawing": "Clique para selecionar o ponto de partida e dê um duplo clique para terminar a criação",
10
+ "Configuration": "Configuração",
11
+ "Confirm": "Confirmar",
12
+ "Delete field": "Excluir campo",
13
+ "Easy-reading": "Apenas leitura (Modo de Leitura)",
14
+ "Edit": "Editar",
15
+ "Edit description": "Editar descrição",
16
+ "Edit field title": "Editar título do campo",
17
+ "Edit tooltip": "Editar dica de ferramenta",
18
+ "Editable": "Editável",
19
+ "Enter keywords to search": "Digite palavras-chave para buscar",
20
+ "Field title": "Título do campo",
21
+ "Go to the configuration page": "Ir para a página de configuração",
22
+ "Google Maps": "Google Maps",
23
+ "Line": "Linha",
24
+ "Map Manager": "Gerenciador de Mapa",
25
+ "Map field": "Campo de mapa",
26
+ "Map type": "Tipo de mapa",
27
+ "Map-based geometry": "Geometria baseada em mapa",
28
+ "Marker field": "Campo de marcador",
29
+ "Operator": "Operador",
30
+ "Pattern": "Padrão",
31
+ "Please configure the AMap securityCode or serviceHost correctly": "Por favor, configure o securityCode ou serviceHost do AMap corretamente",
32
+ "Please configure the AccessKey and SecurityJsCode first": "Por favor, configure a AccessKey e o SecurityJsCode primeiro",
33
+ "Point": "Ponto",
34
+ "Polygon": "Polígono",
35
+ "Readonly": "Somente leitura",
36
+ "Required": "Obrigatório",
37
+ "Save": "Salvar",
38
+ "Saved failed": "Falha ao salvar",
39
+ "Saved successfully": "Salvo com sucesso",
40
+ "Set default zoom level": "Definir nível de zoom padrão",
41
+ "The AccessKey is incorrect, please check it": "A chave de acesso está incorreta, por favor verifique",
42
+ "The default zoom level of the map": "O nível de zoom padrão do mapa",
43
+ "Zoom": "Zoom",
44
+ "securityJsCode or serviceHost": "securityJsCode ou serviceHost"
45
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "AMap": "高德地图",
3
+ "Access key": "访问密钥",
4
+ "Are you sure to clear the canvas?": "您确定要清空画布吗?",
5
+ "Cancel": "取消",
6
+ "Circle": "圆",
7
+ "Clear": "清空",
8
+ "Clear the canvas": "清空画布",
9
+ "Click to select the starting point and double-click to end the drawing": "点击选择起点,双击结束绘制",
10
+ "Concatenation order field": "连接顺序字段",
11
+ "Configuration": "配置",
12
+ "Confirm": "确定",
13
+ "Create map block": "创建地图卡片",
14
+ "Delete field": "删除字段",
15
+ "Easy-reading": "只读(阅读模式)",
16
+ "Edit": "编辑",
17
+ "Edit description": "编辑描述",
18
+ "Edit field title": "编辑字段标题",
19
+ "Edit tooltip": "编辑提示信息",
20
+ "Editable": "可编辑",
21
+ "End point": "终点",
22
+ "Enter keywords to search": "输入地方名关键字搜索(必须包含省/市)",
23
+ "Field title": "字段标题",
24
+ "Go to the configuration page": "前往配置页面",
25
+ "Google Maps": "谷歌地图",
26
+ "Line": "线",
27
+ "Load google maps failed, Please check the Api key and refresh the page": "加载谷歌地图失败,请检查 Api key 并刷新页面",
28
+ "Map": "地图",
29
+ "Map Manager": "地图管理",
30
+ "Map field": "地图字段",
31
+ "Map type": "地图类型",
32
+ "Map-based geometry": "基于地图的几何图形",
33
+ "Marker field": "标记字段",
34
+ "Operator": "运算符",
35
+ "Pattern": "模式",
36
+ "Please configure the AMap securityCode or serviceHost correctly": "请正确配置高德地图 securityCode 或 serviceHost",
37
+ "Please configure the AccessKey and SecurityJsCode first": "请先配置 AccessKey 和 SecurityJsCode",
38
+ "Point": "点",
39
+ "Polygon": "多边形",
40
+ "Readonly": "只读(禁止编辑)",
41
+ "Required": "必填",
42
+ "Save": "保存",
43
+ "Saved failed": "保存失败",
44
+ "Saved successfully": "保存成功",
45
+ "Set default zoom level": "设置默认缩放级别",
46
+ "Start point": "起点",
47
+ "The AccessKey is incorrect, please check it": "访问密钥不正确,请检查",
48
+ "The default zoom level of the map": "地图默认缩放级别",
49
+ "Zoom": "缩放",
50
+ "securityJsCode or serviceHost": "securityJsCode 或 serviceHost"
51
+ }
@@ -0,0 +1,3 @@
1
+ import { Context } from '@tachybase/actions';
2
+ export declare const getConfiguration: (ctx: Context, next: any) => Promise<any>;
3
+ export declare const setConfiguration: (ctx: Context, next: any) => Promise<any>;
@@ -0,0 +1,65 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var actions_exports = {};
19
+ __export(actions_exports, {
20
+ getConfiguration: () => getConfiguration,
21
+ setConfiguration: () => setConfiguration
22
+ });
23
+ module.exports = __toCommonJS(actions_exports);
24
+ var import_constants = require("../constants");
25
+ const getConfiguration = async (ctx, next) => {
26
+ const {
27
+ params: { type }
28
+ } = ctx.action;
29
+ const repo = ctx.db.getRepository(import_constants.MapConfigurationCollectionName);
30
+ const record = await repo.findOne({
31
+ filter: {
32
+ type
33
+ }
34
+ });
35
+ ctx.body = record;
36
+ return next();
37
+ };
38
+ const setConfiguration = async (ctx, next) => {
39
+ const { params: values } = ctx.action;
40
+ const repo = ctx.db.getRepository(import_constants.MapConfigurationCollectionName);
41
+ const record = await repo.findOne({
42
+ filter: {
43
+ type: values.type
44
+ }
45
+ });
46
+ if (record) {
47
+ await repo.update({
48
+ values,
49
+ filter: {
50
+ type: values.type
51
+ }
52
+ });
53
+ } else {
54
+ await repo.create({
55
+ values
56
+ });
57
+ }
58
+ ctx.body = "ok";
59
+ return next();
60
+ };
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ getConfiguration,
64
+ setConfiguration
65
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@tachybase/database").CollectionOptions;
2
+ export default _default;