import{M as ne}from"./index-AOcxwHT9.js";import{ag as I,af as ue,a$ as re,e as de,a7 as me,N as h,aL as pe,bk as fe,b2 as ce,a6 as be,a2 as ge,c as Ve,b as Z,J as j,bl as q,a1 as ye,k as ve,n as H,m as xe,aK as Q,a as ke,ae as Me,aR as Pe,ah as ee,ai as a,aj as l,ak as B,al as te,am as b,an as s,ao as z,az as w,at as _,ap as p,aP as De,aO as we,bm as _e,bn as Ue,av as Be,as as le,aC as J,aG as S,au as C}from"./index-D68iA7pN.js";import{V as Ce}from"./VAutocomplete-14RBtvAN.js";const Ie=()=>{const F=I(),P=I(!1),{isShow:G,showDialog:L}=ue(!1,"Mx_Insert",i=>{L(),i&&(F.value={name:i.name||"",filePath:i.filePath,id:i.id??i.filePath},P.value=!!i.isBlockLibrary)}),N=I([]);re(G,i=>{i&&(N.value=ce().map(u=>({name:u,id:u})))}),de("Mx_add_insert_blocks_list",i=>{const u=i.type,x=i.hash,k=i.file;let o="";if(x){let{mxfilepath:e=""}=be()||{};o=me()+e+x+"."+u+".mxweb"}else u==="mxweb"&&(o=URL.createObjectURL(k.source.source));const t={name:k.name,filePath:o,id:x||o};N.value.unshift(t),F.value=t});const f=async()=>{{const i=ke();await ge(!1,"Mx_add_insert_blocks_list"),i&&Ve("MxFullscreen")}},T=h(!0,"Mx_InsertDialog_is_get_insertion_point"),r=h(!0,"Mx_InsertDialog_is_get_proportion"),g=h(!0,"Mx_InsertDialog_is_uniform_proportion"),d=h(!0,"Mx_InsertDialog_is_get_rotation"),V=h(!1,"Mx_InsertDialog_is_decomposition"),c=h(!1,"Mx_InsertDialog_is_auto_compute_origin"),y=I(!1),A=I(!0),v=pe({x:0,y:0,z:0}),D=fe({x:1,y:1,z:1},"Mx_InsertDialog_proportion"),U=I(0);function O(i,u,x,k){const o=i-x,t=u-k;let e=0;return o==0?e=Math.PI/2:e=Math.atan(Math.abs(t/o)),o<0&&t>=0?e=Math.PI-e:o<0&&t<0?e=Math.PI+e:o>=0&&t<0&&(e=Math.PI*2-e),e+Math.PI}return{isShow:G,showDialog:L,insertBlock:async()=>{let i=Z.App.getCurrentMxCAD();const{filePath:u,hash:x,name:k}=F.value||{},o=i.getDatabase().getBlockTable();let t;if(k)t=o.get(k);else if(!u)return j().warning("请选择正确的图块");if((!t||!t.isValid())&&u&&(q().showLoading(),j().info("图块加载中..."),t=await i.insertBlock(u,x||u),q().hideLoading(),!t.isValid())){j().error("图块加载失败");return}if(P.value?A.value:c.value){let n=t.getMcDbBlockTableRecord();if(!n)return;let m=n.getBoundingBox();if(m.ret){let E=m.minPt.addvec(m.maxPt.sub(m.minPt).mult(.5));n.origin=E}}let e=new ye;e.blockTableRecordId=t;let R=e.getBoundingBox(),Y=0;if(R.ret){let n=R.maxPt.distanceTo(R.minPt);n>1e-5&&(Y=i.getMxDrawObject().screenCoordLong2Doc(100)/n,e.setScale(Y))}let M=new ve;if(L(!1),T.value){M.setMessage(` 指定插入基点`),M.setUserDraw((m,E)=>{e.position=m,E.drawMcDbEntity(e)});let n=await M.go();if(!n)return;e.position=n}else e.position=new H(v.x,v.y,v.z);if(r.value){const n=R.minPt,m=R.maxPt;let E=m.x-n.x,se=m.y-n.y,$=(E+se)/3;$<1e-5&&($=1),M.setMessage(` 输入比例因子<1.00>`),e.setScale(-Y),M.setUserDraw((oe,ie)=>{const K=oe.distanceTo(e.position);if(K<1e-5)return;let W=K/$;W>1e5&&(W=1e5),e.setScale(W),ie.drawMcDbEntity(e)}),await M.go()}else g.value?e.setScale(D.x):e.scaleFactors=new H(D.x,D.y,D.z);d.value?(M.setBasePt(e.position),M.setUserDraw((n,m)=>{e.rotation=O(e.position.x,e.position.y,n.x,n.y),m.drawMcDbEntity(e)}),await M.go()):e.rotation=U.value;const ae=i.drawEntity(e);(P.value?y.value:V.value)&&setTimeout(()=>{let n=new xe;Z.App.MxCADAssist.MxExplode(n.imp),n.copyFormAryId([ae]),Z.App.MxCADAssist.MxExplode(n.imp),Q()}),Q(),j().success("插入图块成功!")},list:N,currentItem:F,openFile:f,isGetInsertionPoint:T,insertionPoint:v,isGetProportion:r,proportion:D,isUniformProportion:g,isGetRotation:d,rotation:U,isDecomposition:V,isAutoComputeOrigin:c,isBlockLibrary:P,isBlockLibraryDecomposition:y,isBlockLibraryAutoComputeOrigin:A}},Le={class:"px-3"},Ae={class:"d-flex"},Re={class:""},Ne=Me({__name:"index",setup(F){const{isShow:P,showDialog:G,insertBlock:L,list:N,currentItem:f,openFile:T,isGetInsertionPoint:r,insertionPoint:g,isGetProportion:d,proportion:V,isUniformProportion:c,isGetRotation:y,rotation:A,isDecomposition:v,isAutoComputeOrigin:D,isBlockLibrary:U,isBlockLibraryDecomposition:O,isBlockLibraryAutoComputeOrigin:X}=Ie(),i=I(),u=[{name:"确定",fun:L,primary:!0},{name:"关闭",fun:()=>G(!1)}],x={n:()=>{(i.value?.$el).getElementsByTagName("input")[0]?.focus()},b:T,s:()=>{r.value=!r.value},e:()=>{d.value=!d.value},c:()=>{y.value=!y.value},u:()=>{c.value=!c.value},d:()=>{v.value=!v.value},enter:()=>{L()}},k=Pe(()=>f.value?.filePath?new URL(f.value.filePath).pathname.split("/").pop():"");return(o,t)=>(te(),ee(ne,{title:o.t("593"),modelValue:l(P),"onUpdate:modelValue":t[14]||(t[14]=e=>B(P)?P.value=e:null),"max-width":"470",footerBtnList:u,keys:x},{default:a(()=>[b("div",Le,[s(le,null,{default:a(()=>[s(z,{class:"mt-1"},{default:a(()=>[b("div",Ae,[s(l(Ce),{class:"mt-1",ref_key:"autocomplete",ref:i,items:l(N),"item-title":"name","return-object":"",modelValue:l(f),"onUpdate:modelValue":t[0]||(t[0]=e=>B(f)?f.value=e:null)},{prepend:a(()=>[s(w,{class:"","key-name":"N"},{default:a(()=>[_(p(o.t("138")),1)]),_:1})]),_:1},8,["items","modelValue"]),s(De,{onClick:l(T),class:"ml-1"},{default:a(()=>[s(w,{"key-name":"B"},{default:a(()=>[_(p(o.t("139")),1)]),_:1}),s(we,{icon:"class:iconfont more"})]),_:1},8,["onClick"])]),l(f)&&l(f).filePath?(te(),ee(_e,{key:0,text:l(f).filePath},{activator:a(({props:e})=>[b("p",Ue({class:"mt-1 text-truncate"},e),p(o.t("594"))+": "+p(k.value),17)]),_:1},8,["text"])):Be("",!0)]),_:1}),s(z,{cols:3,class:"h-100"})]),_:1}),s(le,{"align-stretch":""},{default:a(()=>[s(z,{cols:"4","align-self":"stretch"},{default:a(()=>[s(J,{title:o.t("541"),class:"h-100"},{default:a(()=>[s(S,{class:"",modelValue:l(r),"onUpdate:modelValue":t[1]||(t[1]=e=>B(r)?r.value=e:null)},{label:a(()=>[s(w,{"key-name":"S"},{default:a(()=>[_(p(o.t("144")),1)]),_:1})]),_:1},8,["modelValue"]),s(C,{class:"mt-1",type:"number",modelValue:l(g).x,"onUpdate:modelValue":t[2]||(t[2]=e=>l(g).x=e),disabled:l(r)},{prepend:a(()=>t[15]||(t[15]=[b("span",{class:""}," X:",-1)])),_:1},8,["modelValue","disabled"]),s(C,{class:"mt-1",type:"number",modelValue:l(g).y,"onUpdate:modelValue":t[3]||(t[3]=e=>l(g).y=e),disabled:l(r)},{prepend:a(()=>t[16]||(t[16]=[b("span",{class:""}," Y:",-1)])),_:1},8,["modelValue","disabled"]),s(C,{class:"mt-1",type:"number",modelValue:l(g).z,"onUpdate:modelValue":t[4]||(t[4]=e=>l(g).z=e),disabled:l(r)},{prepend:a(()=>t[17]||(t[17]=[b("span",{class:""}," Z:",-1)])),_:1},8,["modelValue","disabled"])]),_:1},8,["title"])]),_:1}),s(z,{cols:"4","align-self":"stretch"},{default:a(()=>[s(J,{title:o.t("169"),class:"h-100"},{default:a(()=>[s(S,{class:"",modelValue:l(d),"onUpdate:modelValue":t[5]||(t[5]=e=>B(d)?d.value=e:null)},{label:a(()=>[s(w,{"key-name":"E"},{default:a(()=>[_(p(o.t("144")),1)]),_:1})]),_:1},8,["modelValue"]),s(C,{class:"mt-1",type:"number",step:"0.001",modelValue:l(V).x,"onUpdate:modelValue":t[6]||(t[6]=e=>l(V).x=e),disabled:l(d)},{prepend:a(()=>t[18]||(t[18]=[b("span",{class:""}," X:",-1)])),_:1},8,["modelValue","disabled"]),s(C,{class:"mt-1",type:"number",modelValue:l(V).y,"onUpdate:modelValue":t[7]||(t[7]=e=>l(V).y=e),step:"0.001",disabled:l(d)||l(c)},{prepend:a(()=>t[19]||(t[19]=[b("span",{class:""}," Y:",-1)])),_:1},8,["modelValue","disabled"]),s(C,{class:"mt-1",type:"number",modelValue:l(V).z,"onUpdate:modelValue":t[8]||(t[8]=e=>l(V).z=e),step:"0.001",disabled:l(d)||l(c)},{prepend:a(()=>t[20]||(t[20]=[b("span",{class:""}," Z:",-1)])),_:1},8,["modelValue","disabled"]),s(S,{class:"ml-4 mt-1",modelValue:l(c),"onUpdate:modelValue":t[9]||(t[9]=e=>B(c)?c.value=e:null)},{label:a(()=>[s(w,{"key-name":"U"},{default:a(()=>[_(p(o.t("595")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["title"])]),_:1}),s(z,{cols:"4","align-self":"stretch"},{default:a(()=>[s(J,{title:o.t("414"),class:"h-100"},{default:a(()=>[s(S,{class:"",modelValue:l(y),"onUpdate:modelValue":t[10]||(t[10]=e=>B(y)?y.value=e:null)},{label:a(()=>[s(w,{"key-name":"C"},{default:a(()=>[_(p(o.t("144")),1)]),_:1})]),_:1},8,["modelValue"]),s(C,{class:"mt-1",type:"number",modelValue:l(A),"onUpdate:modelValue":t[11]||(t[11]=e=>B(A)?A.value=e:null),disabled:l(y)},{prepend:a(()=>[b("span",Re,p(o.t("235"))+":",1)]),_:1},8,["modelValue","disabled"])]),_:1},8,["title"])]),_:1})]),_:1}),s(S,{class:"mt-2","model-value":l(U)?l(O):l(v),"onUpdate:modelValue":t[12]||(t[12]=e=>{l(U)?O.value=!!e:v.value=!!e})},{label:a(()=>[s(w,{"key-name":"D"},{default:a(()=>[_(p(o.t("596")),1)]),_:1})]),_:1},8,["model-value"]),s(S,{class:"mt-2","model-value":l(U)?l(X):l(D),"onUpdate:modelValue":t[13]||(t[13]=e=>{l(U)?X.value=!!e:D.value=!!e})},{label:a(()=>[s(w,{"key-name":"D"},{default:a(()=>[_(p(o.t("597")),1)]),_:1})]),_:1},8,["model-value"])])]),_:1},8,["title","modelValue"]))}});export{Ne as default};