var m=(c,M,d)=>new Promise((g,i)=>{var A=t=>{try{p(d.next(t))}catch(u){i(u)}},r=t=>{try{p(d.throw(t))}catch(u){i(u)}},p=t=>t.done?g(t.value):Promise.resolve(t.value).then(A,r);p((d=d.apply(c,M)).next())});import{a as R,B as P}from"./index.3ccc18ac.js";import{u as x}from"./useScript.4db96cee.js";import{fV as E,fW as F,a as O,r as f,aV as H,ae as L,h,o as V,Q as z,x as G,f as n,ag as N,R as U}from"./index.ae52ebae.js";import"./useWindowSizeFn.d176b3a5.js";import"./FullscreenOutlined.b9fd5be6.js";const I=new E({timeout:5*60*1e3,headers:{"Content-Type":F.JSON}});function j(c){return I.get({url:"https://restapi.amap.com/v3/geocode/regeo?parameters&key=366b85886fad6f1869ebfc3c41049bf0&radius=1000&extensions=base&location="+c})}const D=n("div",{id:"myPageTop"},[n("table",null,[n("tr",null,[n("td",null,[n("label",null,"\u8BF7\u8F93\u5165\u5173\u952E\u5B57\uFF1A")])]),n("tr",null,[n("td",null,[n("input",{id:"tipinput"})])])])],-1),X=O({__name:"MapModal",props:{width:{type:String,default:"100%"},height:{type:String,default:"calc(100vh - 78px)"}},emits:["set-coor","register"],setup(c,{emit:M}){const d="https://webapi.amap.com/maps?v=2.0&key=e8fedff93ed93cd2fecad645db3de514&plugin=AMap.Scale,AMap.HawkEye,AMap.ToolBar,AMap.ControlBar,AMap.MapType,AMap.Geocoder,AMap.PlaceSearch,AMap.Autocomplete",[g,{setModalProps:i,closeModal:A}]=R(o=>m(this,null,function*(){var l;const e=(l=o.data)==null?void 0:l.coordinate.split(",").map(a=>Number(a));k.value=o.isUpdate,r.value=e||[116.405467,39.907761],S(),i({confirmLoading:!1})})),r=f([]),p=f(""),t=f(""),{toPromise:u}=x({src:d}),w=f(null),k=f(!1),C=H({});function b(){return m(this,null,function*(){try{M("set-coor",{coor:r.value,address:p.value,areaCode:t.value}),i({confirmLoading:!0}),A()}finally{i({confirmLoading:!1})}})}const B={input:"tipinput"};function S(){return m(this,null,function*(){yield u(),yield L();const o=h(w);if(!o)return;const e=window.AMap;let l={zoom:11,viewMode:"3D"};const a=new e.Map(o,l);let s=y(e);e.plugin(["AMap.ToolBar","AMap.Scale","AMap.HawkEye","AMap.MapType","AMap.Geolocation","AMap.Autocomplete","AMap.PlaceSearch"],function(){a.addControl(new e.ToolBar),a.addControl(new e.Scale),a.addControl(new e.HawkEye({isOpen:!0})),a.addControl(new e.MapType),a.addControl(new e.Geolocation({enableHighAccuracy:!0,timeout:1e4,offset:[10,20],zoomToAccuracy:!0,position:"RB"})),a.addControl(new e.Autocomplete(B))}),a.add(s),a.on("click",_=>{let v=_.lnglat;a.remove(s),r.value=[v.lng,v.lat],s=y(e),a.add(s),C.value=a})})}function y(o){return T(),new o.Marker({icon:"https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",position:r.value,anchor:"bottom-center"})}function T(){let o=r.value.join(",");j(o).then(e=>{var l,a,s;p.value=(l=e.data.regeocode)==null?void 0:l.formatted_address,t.value=(s=(a=e.data.regeocode)==null?void 0:a.addressComponent)==null?void 0:s.adcode})}return(o,e)=>(V(),z(h(P),U(o.$attrs,{destroyOnClose:"",onRegister:h(g),title:"\u9009\u62E9\u5730\u5740",onOk:b,defaultFullscreen:!0}),{default:G(()=>[n("div",{ref_key:"wrapRef",ref:w,style:N({height:c.height,width:c.width})},null,4),D]),_:1},16,["onRegister"]))}});export{X as default};