var I=(U,g,u)=>new Promise((b,V)=>{var n=d=>{try{o(u.next(d))}catch(i){V(i)}},D=d=>{try{o(u.throw(d))}catch(i){V(i)}},o=d=>d.done?b(d.value):Promise.resolve(d.value).then(n,D);o((u=u.apply(U,g)).next())});import{ai as k,d as Y,r as h,aj as S,a2 as E,u as q,o as J,c as K,w as l,a as r,b as t,Z as Q,$ as C,n as c,S as W,ak as ee,V as F,ad as A,af as ae,ah as M,e as m,l as y,j as f,h as te,al as G,a8 as T,am as le,a4 as L,an as N,a5 as se,ao as ue}from"./index.6c36cb53.js";import{M as oe}from"./index.a696a3d7.js";import{g as P}from"./math.58b544d2.js";const ne=k.sendStringToExecute.bind(k),de={class:"px-3"},ie=r("span",{class:""},[c(" \u540D\u79F0("),r("span",{class:"text-decoration-underline"},"N"),c(") ")],-1),me=r("span",{class:""}," X:",-1),re=r("span",{class:""}," Y:",-1),ce=r("span",{class:""}," \u5BBD\u5EA6:",-1),pe=r("span",{class:""}," \u9AD8\u5EA6:",-1),fe=r("span",{class:""}," \u89D2\u5EA6:",-1),we=Y({__name:"index",setup(U){const g=h([]),u=h(""),b=(s=u.value)=>{s&&(g.value=Array.from(new Set([...g.value,u.value])))},V=()=>{const s=document.createElement("input");s.type="file",s.style.display="none",s.accept="image/*",document.body.appendChild(s);const e=le();s.click(),B(!0),window.addEventListener("focus",()=>{setTimeout(()=>{e&&ne("MxFullscreen")},100)},{once:!0}),s.onchange=()=>{s.files&&s.files[0]&&(u.value=URL.createObjectURL(s.files[0]),D(u.value))},s.remove()},n=S({width:0,height:0}),D=(s=u.value)=>{const e=G.getCurrentMxCAD();try{e.loadImage(s,a=>{if(!a){console.log("loadImage failed"),u.value="",T().error("\u52A0\u8F7D\u56FE\u7247\u5931\u8D25");return}n.width=a.width,n.height=a.height,b(s)})}catch(a){console.log("loadImage failed",a),u.value="",T().error("\u52A0\u8F7D\u56FE\u7247\u5931\u8D25")}},o=S({x:0,y:0}),d=E(!1,"Mx_AttachPictureDialog_isGetPt"),i=E(!1,"Mx_AttachPictureDialog_isGetZoomRatio"),v=E(!1,"Mx_AttachPictureDialog_isGetRotationAngle"),x=h(1),w=h(0),j=()=>I(this,null,function*(){B(!1);const s=G.getCurrentMxCAD();if(d.value){const e=new L;e.setMessage("\u6307\u5B9A\u63D2\u5165\u70B9");const a=yield e.go();if(!a)return;o.x=a.x,o.y=a.y}if(i.value){const e=new L,a=new N(o.x,o.y);e.setBasePt(a),e.setMessage("\u6307\u5B9A\u7F29\u653E\u6BD4\u4F8B"),e.setUserDraw(($,z)=>{const R=$.distanceTo(a)/n.width,H=n.width*R,O=n.height*R,X=new THREE.Vector3(a.x+H,a.y+O);z.drawRect(a.toVector3(),X)});const p=yield e.go();if(!p)return;x.value=P(p.distanceTo(a)/n.width,3)}if(v.value){const e=new se;e.setMessage("\u6307\u5B9A\u65CB\u8F6C\u89D2\u5EA6");const a=new N(o.x,o.y);e.setBasePt(a);const p=yield e.go();if(!p)return;e.getDetailedResult()===ue.kCoordIn?w.value=P(p,3):w.value=P(p/(Math.PI/180),3)}s.drawImage(o.x,o.y,n.width*x.value,n.height*x.value,w.value,u.value)}),{isShow:_,showDialog:B}=q(!1,"_InsertImage",()=>{_.value||V()}),Z=[{name:"\u786E\u5B9A",fun:j,primary:!0},{name:"\u5173\u95ED",fun:()=>B(!1)}];return(s,e)=>(J(),K(oe,{title:"\u9644\u7740\u56FE\u7247",modelValue:m(_),"onUpdate:modelValue":e[11]||(e[11]=a=>y(_)?_.value=a:null),"max-width":"600",footerBtnList:Z},{default:l(()=>[r("div",de,[t(ee,{class:"mt-2 w-75",items:g.value,modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=a=>u.value=a),onChange:e[1]||(e[1]=a=>D())},{prepend:l(()=>[ie]),append:l(()=>[t(Q,{onClick:V},{default:l(()=>[t(C,{"key-name":"B"},{default:l(()=>[c("\u6D4F\u89C8")]),_:1}),c(),t(W,{icon:"class:iconfont more"})]),_:1})]),_:1},8,["items","modelValue"]),t(te,{"align-stretch":"",class:"mt-2"},{default:l(()=>[t(F,{cols:4,"align-self":"auto"},{default:l(()=>[t(A,{title:"\u9884\u89C8",class:"h-100"},{default:l(()=>[t(ae,{src:u.value,cover:"",crossorigin:"anonymous"},null,8,["src"])]),_:1})]),_:1}),t(F,{cols:4},{default:l(()=>[t(A,{title:"\u63D2\u5165\u70B9"},{default:l(()=>[t(M,{modelValue:m(d),"onUpdate:modelValue":e[2]||(e[2]=a=>y(d)?d.value=a:null)},{label:l(()=>[t(C,{"key-name":"S"},{default:l(()=>[c("\u5728\u5C4F\u5E55\u4E0A\u6307\u5B9A")]),_:1})]),_:1},8,["modelValue"]),t(f,{class:"mt-1",modelValue:o.x,"onUpdate:modelValue":e[3]||(e[3]=a=>o.x=a),disabled:m(d)},{prepend:l(()=>[me]),_:1},8,["modelValue","disabled"]),t(f,{class:"mt-1",modelValue:o.y,"onUpdate:modelValue":e[4]||(e[4]=a=>o.y=a),disabled:m(d)},{prepend:l(()=>[re]),_:1},8,["modelValue","disabled"])]),_:1}),t(A,{title:"\u7F29\u653E\u6BD4\u4F8B"},{default:l(()=>[t(M,{modelValue:m(i),"onUpdate:modelValue":e[5]||(e[5]=a=>y(i)?i.value=a:null)},{label:l(()=>[t(C,{"key-name":"S"},{default:l(()=>[c("\u5728\u5C4F\u5E55\u4E0A\u6307\u5B9A")]),_:1})]),_:1},8,["modelValue"]),t(f,{class:"mt-1 ml-1",type:"number",disabled:m(i),modelValue:x.value,"onUpdate:modelValue":e[6]||(e[6]=a=>x.value=a)},null,8,["disabled","modelValue"])]),_:1})]),_:1}),t(F,{cols:4,"align-self":"auto"},{default:l(()=>[t(A,{title:"\u56FE\u50CF\u9AD8\u5EA6",class:"h-50"},{default:l(()=>[t(f,{class:"mt-1",type:"number",modelValue:n.width,"onUpdate:modelValue":e[7]||(e[7]=a=>n.width=a)},{prepend:l(()=>[ce]),_:1},8,["modelValue"]),t(f,{class:"mt-1",type:"number",modelValue:n.height,"onUpdate:modelValue":e[8]||(e[8]=a=>n.height=a)},{prepend:l(()=>[pe]),_:1},8,["modelValue"])]),_:1}),t(A,{title:"\u65CB\u8F6C\u89D2\u5EA6",class:"h-50"},{default:l(()=>[t(M,{class:"",modelValue:m(v),"onUpdate:modelValue":e[9]||(e[9]=a=>y(v)?v.value=a:null)},{label:l(()=>[t(C,{"key-name":"S"},{default:l(()=>[c("\u5728\u5C4F\u5E55\u4E0A\u6307\u5B9A")]),_:1})]),_:1},8,["modelValue"]),t(f,{class:"mt-1",type:"number",modelValue:w.value,"onUpdate:modelValue":e[10]||(e[10]=a=>w.value=a),disabled:m(v)},{prepend:l(()=>[fe]),_:1},8,["modelValue","disabled"])]),_:1})]),_:1})]),_:1})])]),_:1},8,["modelValue"]))}});export{we as default};