@vsleem-realsee-viewer/shared 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.Shared={}))})(this,function(l){"use strict";var $t=Object.defineProperty;var _t=(l,m,x)=>m in l?$t(l,m,{enumerable:!0,configurable:!0,writable:!0,value:x}):l[m]=x;var o=(l,m,x)=>_t(l,typeof m!="symbol"?m+"":m,x);class m extends Error{constructor(t,e,s){super(e),this.code=t,this.message=e,this.details=s,this.name="Apprror",Object.setPrototypeOf(this,m.prototype)}toJSON(){return{code:this.code,message:this.message,details:this.details,timestamp:new Date().toISOString()}}}var x=(i=>(i[i.CADModel=5]="CADModel",i[i.BIMModel=6]="BIMModel",i[i.ForgeModel=7]="ForgeModel",i[i.ThreeDModel=8]="ThreeDModel",i[i.SkyMapModel=9]="SkyMapModel",i[i.ScaleModel=10]="ScaleModel",i))(x||{}),G=(i=>(i[i.Global=0]="Global",i))(G||{}),b=(i=>(i[i.Space=0]="Space",i[i.Model=1]="Model",i[i.Data=2]="Data",i))(b||{}),R=(i=>(i[i.Used=0]="Used",i[i.Enabled=1]="Enabled",i[i.Disabled=2]="Disabled",i))(R||{}),L=(i=>(i[i.SUCCESS=200]="SUCCESS",i[i.ERROR=-1]="ERROR",i[i.TIMEOUT=401]="TIMEOUT",i))(L||{}),M=(i=>(i.GET="GET",i.POST="POST",i))(M||{}),O=(i=>(i.JSON="application/json",i.FORM_URLENCODED="application/x-www-form-urlencoded;charset=UTF-8",i.FORM_DATA="multipart/form-data;charset=UTF-8",i.OCTET_STREAM="'application/octet-stream",i))(O||{}),B=(i=>(i.Hw="huawei",i.Ali="aliyun",i.Hs="hs",i.Aws="amazon",i.Minio="minio",i))(B||{}),g=(i=>(i[i.GeoPointNoPlane=9e3]="GeoPointNoPlane",i[i.PointUnmappedGIS=9010]="PointUnmappedGIS",i[i.PointNoXYZ=9011]="PointNoXYZ",i[i.PointNoPlane=9012]="PointNoPlane",i[i.RelativePlaneUnmatch=9020]="RelativePlaneUnmatch",i[i.RelativeNoPlane=9021]="RelativeNoPlane",i[i.RelativeJsonError=9022]="RelativeJsonError",i[i.RequestCodeError=9030]="RequestCodeError",i[i.RequestResultError=9031]="RequestResultError",i[i.RequestUnknownError=9032]="RequestUnknownError",i))(g||{});const $={baseUrl:"https://vsleem.com/api",obsType:"hs"},ot={isTransformResponse:!0,joinBaseUrl:!0,withAuthorize:!0},at={url:"",method:M.GET,headers:{}},_={...$};function ht(i){Object.assign(_,i)}async function S(i,t){const e={...ot,...t},s={...at,...i};try{const n=ct(s,e),{url:r,...a}=n,c=await(await window.fetch(r,a)).json();return lt(c,e)}catch(n){return ut(n)}}function ct(i,t){const{baseUrl:e,authorizeCode:s}=_,{joinBaseUrl:n,withAuthorize:r}=t;let{url:a,method:h,headers:c={},params:f,data:d}=i;n&&e&&(a=`${e}${a}`),h=h==null?void 0:h.toUpperCase();const u={...c};if(/^https?:\/\/.+$/i.test(e??"")?u.PlatForm=new URL(e??"").host:u.PlatForm=new URL(window.location.href).host,r&&s&&(u.AuthorizationCode=s),h===M.POST&&!u["Content-Type"]&&(u["Content-Type"]=O.JSON),h===M.GET&&f){const P=new URLSearchParams(f);a+=`?${P.toString()}`}let y;return h===M.POST&&(y=u["Content-Type"]===O.JSON?JSON.stringify(d||{}):d),{url:a,method:h,headers:u,body:y}}function lt(i,t){if(!t.isTransformResponse)return i;if(!i)throw new m(g.RequestResultError,"请求返回的结果错误");const{code:e,data:s,msg:n}=i;if(e===L.SUCCESS)return s;throw new m(g.RequestCodeError,n||"请求返回的Code错误")}function ut(i){throw i instanceof Error?i:new m(g.RequestUnknownError,typeof i=="string"?i:"未知的请求错误")}const ft=Object.freeze(Object.defineProperty({__proto__:null,request:S,setRequestGlobalConfig:ht},Symbol.toStringTag,{value:"Module"}));function q(i,t){return S({url:"/project/jssdk/cs/list",method:M.GET,params:i},t)}function Z(i,t){return S({url:"/project/jssdk/cs/bind",method:M.POST,data:i},t)}function j(i,t){return S({url:"/project/jssdk/cs/save",method:M.POST,data:i},t)}function J(i,t){return S({url:"/project/jssdk/cs/delete",method:M.POST,data:i},t)}function H(i,t){return S({url:"/project/jssdk/cs/mapping",method:M.POST,data:i},t)}function V(i,t){return S({url:"/project/jssdk/cs/mapping/query",method:M.GET,params:i},t)}function dt(i,t={isTransformResponse:!1,joinBaseUrl:!1,withAuthorize:!1}){return S({url:i,method:M.GET},t)}const mt=Object.freeze(Object.defineProperty({__proto__:null,bindCoordinate:Z,getCoordinateList:q,getImageInfo:dt,getMappingRelation:V,mapingCoordinate:H,removeCoordinate:J,saveCoordinate:j},Symbol.toStringTag,{value:"Module"})),yt=typeof window<"u",wt=Object.prototype.toString;function T(i,t){return wt.call(i)===`[object ${t}]`}function W(i){return typeof i<"u"}function Q(i){return!W(i)}function k(i){return i!==null&&T(i,"Object")}function K(i){return i===null}function gt(i){return T(i,"Date")}function pt(i){return T(i,"String")}function A(i){return typeof i=="function"}function Mt(i){return T(i,"Boolean")}function vt(i){return T(i,"RegExp")}function N(i){return i&&Array.isArray(i)}function xt(i){return typeof window<"u"&&T(i,"Window")}function bt(i){return k(i)&&!!i.tagName}function Tt(i){return typeof i=="number"||/^\d+(\.\d+)?$/.test(i)}function D(i){return T(Number(i),"Number")}function St(i,t){return JSON.stringify(i)===JSON.stringify(t)}function Pt(i){return Q(i)||K(i)}function Et(i){return T(i,"Promise")&&k(i)&&A(i.then)&&A(i.catch)}function tt(i){return z(i,new WeakMap)}function z(i,t){if(typeof i!="object"||i===null)return i;if(t.has(i))return t.get(i);let e;if(i instanceof Date)return e=new Date(i),t.set(i,e),e;if(i instanceof RegExp)return e=new RegExp(i),t.set(i,e),e;if(i instanceof Map)return e=new Map,t.set(i,e),i.forEach((n,r)=>{e.set(r,z(n,t))}),e;if(i instanceof Set)return e=new Set,t.set(i,e),i.forEach(n=>{e.add(z(n,t))}),e;if(ArrayBuffer.isView(i))return e=new i.constructor(i.buffer.slice(0),i.byteOffset,i.byteLength),t.set(i,e),e;if(i instanceof ArrayBuffer)return e=i.slice(0),t.set(i,e),e;if(Array.isArray(i)){e=[],t.set(i,e);for(let n=0;n<i.length;n++)n in i&&(e[n]=z(i[n],t));return e}e=Object.create(Object.getPrototypeOf(i)),t.set(i,e);for(const n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=z(i[n],t));const s=Object.getOwnPropertySymbols(i);for(const n of s)Object.prototype.propertyIsEnumerable.call(i,n)&&(e[n]=z(i[n],t));return e}function Nt(i,t,e=!1){let s;const n=function(...r){const a=this,h=e&&!s;s&&clearTimeout(s),s=setTimeout(()=>{s=void 0,e||i.apply(a,r)},t),h&&i.apply(a,r)};return n.cancel=()=>{s&&clearTimeout(s),s=void 0},n}function zt(i,t,e=!1){let s,n;const r=function(...a){const h=this;n?(clearTimeout(s),s=setTimeout(()=>{Date.now()-n>=t&&(i.apply(h,a),n=Date.now())},t-(Date.now()-n))):(e&&i.apply(h,a),n=Date.now())};return r.cancel=()=>{clearTimeout(s),s=void 0,n=void 0},r}function X(i,...t){if(!t.length)return i;const e=t.shift();return e===void 0?i:(C(i)&&C(e)&&Object.keys(e).forEach(s=>{const n=i[s],r=e[s];Array.isArray(n)&&Array.isArray(r)?i[s]=[...n,...r]:C(n)&&C(r)?i[s]=X({...n},r):r!==void 0&&(i[s]=r)}),X(i,...t))}function C(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function et(i,...t){if(!t.length)return i;for(const e of t)e!=null&&typeof e=="object"&&Object.keys(e).forEach(s=>{const n=e[s],r=i[s];n!==null&&typeof n=="object"&&!Array.isArray(n)?((!r||typeof r!="object")&&(i[s]={}),et(i[s],n)):i[s]=n});return i}function It(i,t={}){return new Promise((e,s)=>{const n=F(i);if(Dt(n)){e(!0);return}const r=document.createElement("script");r.src=i,Object.entries(t).forEach(([a,h])=>{h!==!1&&r.setAttribute(a,h===!0?"":String(h))}),r.onload=()=>{e(!0)},r.onerror=()=>{document.head.removeChild(r),s(new Error(`Failed to load script: ${i}`))},document.head.appendChild(r)})}function Dt(i){const t=F(i);return Array.from(document.scripts).some(e=>F(e.src)===t)}function F(i){try{const t=new URL(i,window.location.href);return`${t.origin}${t.pathname}`}catch{return i}}function Rt(i,t,e,s){const n=Math.min(i/e,t/s),r=e*n,a=s*n;return{scale:n,x:(i-r)/2,y:(t-a)/2,sw:r,sh:a}}function Ot(i,t,e){return{x:i*e.scale+e.x,y:t*e.scale+e.y}}function Ct(i,t,e){return{x:(i-e.x)/e.scale,y:(t-e.y)/e.scale}}function Lt(i){console.warn(`[warn]:${i}`)}function jt(i){throw new Error(`[error]:${i}`)}const kt=Object.freeze(Object.defineProperty({__proto__:null,cloneDeep:tt,debounce:Nt,deepMerge:X,deepMergeProps:et,error:jt,getImageTransform:Rt,inBrowser:yt,is:T,isArray:N,isBoolean:Mt,isDate:gt,isDef:W,isElement:bt,isFunction:A,isNull:K,isNullOrUnDef:Pt,isNumber:D,isNumeric:Tt,isObject:k,isPromise:Et,isRegExp:vt,isSameValue:St,isString:pt,isUnDef:Q,isWindow:xt,loadScript:It,throttle:zt,toCanvasCoord:Ot,toModelCoord:Ct,warn:Lt},Symbol.toStringTag,{value:"Module"}));class w{constructor(t){o(this,"x",0);o(this,"y",0);o(this,"z",0);o(this,"lat",0);o(this,"lon",0);o(this,"alt",0);o(this,"yaw",0);o(this,"pitch",0);o(this,"roll",0);o(this,"hasXYZ",!1);o(this,"hasGeo",!1);o(this,"hasAngle",!1);o(this,"plane","xy");const{x:e,y:s,z:n,lat:r,lon:a,alt:h,yaw:c,pitch:f,roll:d,plane:u="xy"}=t||{};D(e)&&D(s)&&(this.x=Number(e)||0,this.y=Number(s)||0,this.z=Number(n)||0,this.plane=u,this.hasXYZ=!0),D(r)&&D(a)&&Number(r)!==0&&Number(a)!==0&&(this.lat=Number(r)||0,this.lon=Number(a)||0,this.alt=Number(h)||0,this.hasGeo=!0),(c!==void 0||f!==void 0||d!==void 0)&&(this.yaw=Number(c)||0,this.pitch=Number(f)||0,this.roll=Number(d)||0,this.hasAngle=!0)}static dist(t,e){return Math.hypot(t.x-e.x,t.y-e.y,t.z-e.z)}static distXZ(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}static distXY(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}static toRadians(t){return(Number(t)||0)*Math.PI/180}static toDegrees(t){return(Number(t)||0)*180/Math.PI}static angleXZ(t,e,s){const n={x:t.x-e.x,z:t.z-e.z},r={x:s.x-e.x,z:s.z-e.z},a=n.x*r.x+n.z*r.z,h=Math.sqrt(n.x**2+n.z**2),c=Math.sqrt(r.x**2+r.z**2),f=Math.max(-1,Math.min(1,a/(h*c))),u=Math.acos(f)*180/Math.PI;return Math.min(u,360-u)}static toParse(t){if(t){const e=t==null?void 0:t.split(",").map(s=>Number(s)||0);return new w({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}projection(t,e,s){try{if((e==null?void 0:e.id)===(s==null?void 0:s.id))return new w(this);if((e==null?void 0:e.modelType)===x.SkyMapModel){const{refPoint:n}=(e==null?void 0:e.relativeMap)||{};if(this.hasGeo&&n){const r=I.LLHToXYZ(this,n);return this.x=r.x,this.y=r.y,this.z=r.z,this.hasXYZ=!0,this.project(t)}throw new m(g.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}if((s==null?void 0:s.modelType)===x.SkyMapModel){const{refPoint:n}=(s==null?void 0:s.relativeMap)||{},r=this.project(t);if(r!=null&&r.hasXYZ&&n){const a=I.XYZToLLH(r,n);return r.lat=a.lat,r.lon=a.lon,r.alt=a.alt,r.hasGeo=!0,r}throw new m(g.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}return this.project(t)}catch{return}}project(t){if(!this.hasXYZ)throw new m(g.PointNoXYZ,"点没有xxz坐标信息");if(this.plane==="xz")return this.projectXZ(t);if(this.plane==="xy")return this.projectXY(t);throw new m(g.PointNoPlane,"点的plane应为xz或xy")}projectXZ(t){const e=new w(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const s=e.x*Math.cos(t.yaw)-e.z*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.z*Math.cos(t.yaw);return e.x=s+t.x,e.y+=t.y,e.z=n+t.z,e}projectXY(t){const e=new w(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const s=e.x*Math.cos(t.yaw)-e.y*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.y*Math.cos(t.yaw);return e.x=s+t.x,e.y=n+t.y,e.z+=t.z,e}}class I{constructor(t){o(this,"lat",0);o(this,"lon",0);o(this,"alt",0);const{lat:e=0,lon:s=0,alt:n=0}=t||{};this.lat=e,this.lon=s,this.alt=n}static XYZToLLH(t,e){const n=.0033528106647474805,r=n*(2-n),a=w.toRadians(e.lat),h=6378137/Math.sqrt(1-r*Math.sin(a)**2)+e.alt;let c,f,d;if(t.plane==="xz"){const u=t.x/1e3/(h*Math.cos(a)),y=t.z/1e3/h;c=e.lon+w.toDegrees(u),f=e.lat-w.toDegrees(y),d=e.alt+t.y/1e3}else if(t.plane==="xy"){const u=t.x/1e3/(h*Math.cos(a)),y=t.y/1e3/h;c=e.lon+w.toDegrees(u),f=e.lat-w.toDegrees(y),d=e.alt+t.z/1e3}else throw new m(g.GeoPointNoPlane,"点的plane应为xz或xy");return new I({lat:f,lon:c,alt:d})}static LLHToXYZ(t,e){const n=.0033528106647474805,r=n*(2-n),a=w.toRadians(e.lat),h=6378137/Math.sqrt(1-r*Math.sin(a)**2)+e.alt,c=w.toRadians(t.lon-e.lon),f=w.toRadians(e.lat-t.lat),d=h*c*Math.cos(a),u=h*f;if(t.plane==="xz")return new w({x:d*1e3,y:(t.alt-e.alt)*1e3,z:u*1e3,plane:"xz"});if(t.plane==="xy")return new w({x:d*1e3,y:u*1e3,z:(t.alt-e.alt)*1e3,plane:"xy"});throw new m(g.GeoPointNoPlane,"点的plane应为xz或xy")}}class v{constructor(t){o(this,"scale",1);o(this,"yaw",0);o(this,"x",0);o(this,"y",0);o(this,"z",0);o(this,"start",0);o(this,"end",-1);o(this,"plane","xy");o(this,"refPoint");const{refPoint:e,...s}=t||{};e&&(this.refPoint=new I(e)),Object.assign(this,s)}static addRelativeMap(t,e){if(t.plane!==e.plane)throw new m(g.RelativePlaneUnmatch,"两个映射关系的plane应该相同");const s=t.scale*e.scale,n=t.yaw+e.yaw,r=Math.cos(e.yaw),a=Math.sin(e.yaw);let h=0,c=0,f=0;if(t.plane==="xz"){const d=t.x*r-t.z*a,u=t.y,y=t.x*a+t.z*r;h=e.x+d*e.scale,c=e.y+u*e.scale,f=e.z+y*e.scale}else if(t.plane==="xy"){const d=t.x*r-t.y*a,u=t.x*a+t.y*r,y=t.z;h=e.x+d*e.scale,c=e.y+u*e.scale,f=e.z+y*e.scale}else throw new m(g.RelativeNoPlane,"映射关系的plane应为xz或xy");return new v({scale:s,yaw:n,x:h,y:c,z:f,start:t.start,end:t.end,plane:t.plane})}static inverseRelativeMap(t){const e=1/t.scale,s=-t.yaw,n=Math.cos(-s),r=Math.sin(-s);let a=0,h=0,c=0;if(t.plane==="xz")a=-(t.x*n+t.z*r)*e,h=-t.y*e,c=-(t.z*n-t.x*r)*e;else if(t.plane==="xy")a=-(t.x*n+t.y*r)*e,h=-(t.y*n-t.x*r)*e,c=-t.z*e;else throw new m(g.RelativeNoPlane,"映射关系的plane应为xz或xy");return new v({scale:e,yaw:s,x:a,y:h,z:c,start:t.start,end:t.end,plane:t.plane})}static toParse(t){try{let e=t?JSON.parse(t):void 0;const{reference_point:s}=e||{};return s&&(e={refPoint:s}),e?new v(e):void 0}catch{throw new m(g.RelativeJsonError,"relativeMap格式化失败")}}static toStringify(t){return t?JSON.stringify(t):void 0}}class p{static async getCoordinateTree(t){const e=await q({projectId:t});if(e.length){const s=p.handleCoordinateList(e);return p.buildCoordinateTree(s,0)}}static async addCoordinate(t,e){const{projectId:s,id:n}=t,r=e.map(h=>{const{type:c,modelType:f,relativeMap:d,level:u,...y}=h,P=d?JSON.stringify(d):void 0;return{...y,projectId:s,parentId:n,coordinateType:c,renderType:f,relativePosition:P}}),a=await j(r);return p.handleCoordinateList(a)}static async removeCoordinate(t,e){const s=e.map(n=>n.id??-1);return await J(s)}static async updateCoordinate(t,e){const{projectId:s,id:n}=t,r=e.map(h=>{const{type:c,relativeMap:f,level:d,...u}=h,y=v.toStringify(f);return{...u,relativePosition:y,projectId:s,parentId:n}}),a=await j(r);return p.handleCoordinateList(a)}static async bindCoordinate(t,e){const{projectId:s,id:n}=t,r=e.map(h=>{const{modelId:c}=h;return{modelId:c,parentId:n,projectId:s}}),a=await Z(r);return p.handleCoordinateList(a)}static handleCoordinateList(t){return t==null?void 0:t.map(e=>{const{coordinateType:s,modelKey:n,renderType:r,relativePosition:a,...h}=e,c=v.toParse(a);return new st({...h,type:s,modelType:r,modelValue:n,relativeMap:c})})}static buildCoordinateTree(t,e){const s=new Map,n=[];return t.forEach(r=>{s.set(String(r.id),r)}),t.forEach(r=>{var h;const a=s.get(String(r.id));if(a)if(r.parentId===e)a.level=0,n.push(a);else{const c=s.get(String(r.parentId??-1));c&&(a.level=(Number(c.level)||0)+1,a.parent=c,(h=c.children)==null||h.push(a))}}),n.forEach(p.sortCoordinateTree),n[0]}static sortCoordinateTree(t){t.children&&(t.children.sort((e,s)=>{var n,r;if(e.type===b.Space){const a=Number((n=s==null?void 0:s.relativeMap)==null?void 0:n.z)-Number((r=e==null?void 0:e.relativeMap)==null?void 0:r.z);return a!==0?a:Number(s.createTime)-Number(e.createTime)}else return e.status===0&&s.status!==0?-1:s.status===0&&e.status!==0?1:Number(s.createTime)-Number(e.createTime)}),t.children.forEach(p.sortCoordinateTree))}static filterSpaceTree(t){const e=[];return t.forEach(s=>{const n=p.filterSpaceTree(s.children);s.children=n,s.disabled=s.disabled??!1,s.type!==b.Model&&e.push(s)}),e}}class st{constructor(t){o(this,"id",0);o(this,"type",0);o(this,"children",[]);o(this,"level");o(this,"relativeMap");o(this,"no");o(this,"name");o(this,"shortName");o(this,"status");o(this,"modelId");o(this,"modelType");o(this,"modelValue");o(this,"projectId");o(this,"parentId");o(this,"parent");o(this,"groupUuid");o(this,"z");o(this,"createTime");o(this,"disabled");this.setOptions(t)}get spaceList(){return this.children.filter(t=>t.type===b.Space)}get modelList(){return this.children.filter(t=>t.type===b.Model)}get fullName(){const t=this.name?`(${this.name})`:"";return this.shortName?`${this.shortName}${t}`:this.name??""}setOptions(t){const{relativeMap:e,parent:s,children:n,...r}=t||{};e&&(this.relativeMap=new v(e)),s&&(this.parent=s),n!=null&&n.length&&(this.children=n),Object.assign(this,r)}async addChild(t){const e=N(t)?t:[t],s=await p.addCoordinate(this,e);this.mergeChild(s)}async removeChild(t){const e=N(t)?t:[t];await p.removeCoordinate(this,e);for(const s of e){const n=this.children.findIndex(r=>r.id===s.id);n!==-1&&this.children.splice(n,1)}}async updateChild(t){const e=N(t)?t:[t],s=await p.updateCoordinate(this,e);this.mergeChild(s)}async bindChild(t){const e=N(t)?t:[t],s=await p.bindCoordinate(this,e);this.mergeChild(s)}async mergeChild(t){t!=null&&t.length&&t.forEach(e=>{const s=this.children.find(n=>n.id===e.id);if(s){const{relativeMap:n,no:r,name:a,shortName:h,status:c,modelId:f,modelValue:d}=e;Object.assign(s,{relativeMap:n,no:r,name:a,shortName:h,status:c,modelId:f,modelValue:d})}else this.id===e.parentId&&(e.parent=this,this.children.unshift(e))})}async mappingTo(t){await H(t)}async fromMapping(){const t=await V({srcCsId:this.id});return t[t.length-1]}findRoot(t=!1){let e=this;for(;e.parent&&!(t&&!e.relativeMap);)e=e.parent;return e}findChildModel(t=[x.CADModel,x.SkyMapModel],e=!0){var h,c;const s=N(t)?t:[t];if(s.includes(this.modelType??-1)&&this.status!==R.Disabled)return this;const r=[b.Data,b.Model].includes(this.type)?this.findParentSpace():this,a=(c=(h=r==null?void 0:r.modelList)==null?void 0:h.filter(f=>s.includes(f.modelType??-1)?e?!!f.relativeMap:!0:!1))==null?void 0:c.sort((f,d)=>Number(f.status)-Number(d.status));return a==null?void 0:a[0]}findClosestModel(t=x.CADModel,e){var f;const s=new Set;for(const d of e??[])s.add(String(d.id));const n=[{node:this,distance:0}],r=N(t)?t:[t],a=new Set;let h,c=1/0;for(;n.length>0;){const d=n.shift();if(!d)break;const{node:u,distance:y}=d;if(s.has(String(u.id)))continue;if(r.includes(u.modelType??-1)){if(y<c&&(h=u,c=y,y<=1))break;continue}a.add(u);const P=[];if((f=u.parent)!=null&&f.children)for(const E of u.parent.children)E!==u&&!a.has(E)&&P.push(E);if(u.children)for(const E of u.children)a.has(E)||P.push(E);u.parent&&!a.has(u.parent)&&P.push(u.parent);for(const E of P)n.push({node:E,distance:y+1})}return h}findParentSpace(){let t=this;for(;t&&t.type!==b.Space;)t=t.parent;return t}findParentSpaceNames(t=2){const e=[];let s=this;for(;s&&t>0;)s.type===b.Space&&(e.unshift(s.fullName),t--),s=s.parent;return e}findCsGroup(){var s;const{groupUuid:t,parent:e}=this;return t?((s=e==null?void 0:e.children)==null?void 0:s.filter(n=>n.groupUuid===t))||[]:[this]}findCsByLevel(t){if(this.level===t)return this;if(this.children.length)for(const e of this.children){const s=e.findCsByLevel(t);if(s)return s}}findCsById(t){if(t){if(this.id===t)return this;for(const e of this.children){const s=e.findCsById(t);if(s)return s}}}getCsRoutes(t=!1){let e=this;const s=[e];for(;e!=null&&e.parent&&!(t&&!e.relativeMap);)e=e.parent,e&&s.push(e);return s}getMappedCsTree(){function t(n){var r;return(r=n.children)!=null&&r.length&&(n.children=n.children.filter(a=>!!(a!=null&&a.relativeMap)&&a.status!==R.Disabled).map(a=>t(a))),n}const e=tt(this.findRoot(!0)),s=t(e);return s.parentId=0,s.parent=void 0,s}getDestRelativeMap(t){var r;if(this.id===t.id)return new v;const e=this.getRelativeMaps(),s=t.getRelativeMaps();let n=new v;return e==null||e.forEach(a=>{n=v.addRelativeMap(n,a)}),(r=s==null?void 0:s.reverse())==null||r.forEach(a=>{n=v.addRelativeMap(n,v.inverseRelativeMap(a))}),n}getRelativeMaps(){let t=this;const e=[];for(;t!=null&&t.parent&&t.relativeMap;)e.push(t.relativeMap),t=t.parent;return e}static filterCoordinateTree(t,e=[],s=[]){var r;if(s.includes(t.id)||e.includes(t.type))return;const n=(r=t.children)==null?void 0:r.map(a=>this.filterCoordinateTree(a,e,s)).filter(a=>a!==void 0);return{...t,children:n}}static getCommonCoordinate(t){let e;const s=t.map(n=>n.getCsRoutes(!0).filter(a=>a.id&&a.type===b.Space));for(;this.checkSameCoordinate(s);){const r=s.shift();r!=null&&r.length&&(e=r[0])}return e}static checkSameCoordinate(t){if(t.length){if(t.length===1)return!0;for(let e=0;e<t.length-1;e++){const s=t[e];if(!(s!=null&&s.length))return!1;const n=t[e+1];if(!(n!=null&&n.length)||s[0].id!==n[0].id)return!1}return!0}else return!1}}class U{constructor(t){o(this,"yaw",0);o(this,"pitch",0);o(this,"roll",0);const{yaw:e=0,pitch:s=0,roll:n=0}=t||{};this.yaw=Number(e)||0,this.pitch=Number(s)||0,this.roll=Number(n)||0}static toParse(t){if(t){const e=t==null?void 0:t.split(",").map(s=>Number(s)||0);return new U({yaw:e[0],pitch:e[1],roll:e[2]})}}static toStringify(t){return t?`${t.yaw},${t.pitch},${t.roll}`:""}}class Y{constructor(t){o(this,"x",0);o(this,"y",0);o(this,"z",0);const{x:e=0,y:s=0,z:n=0}=t||{};this.x=Number(e)||0,this.y=Number(s)||0,this.z=Number(n)||0}static toParse(t){if(t){const e=t==null?void 0:t.split(",").map(s=>Number(s)||0);return new Y({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}}class At{constructor(t){o(this,"canvas");o(this,"ctx");o(this,"options");o(this,"offset",{x:0,y:0});o(this,"curOffset",{x:0,y:0});o(this,"mousePosition",{x:-1,y:-1});o(this,"MAX_SCALE",60);o(this,"MIN_SCALE",1);o(this,"STEP_SCALE",.5);o(this,"scale",1);o(this,"preScale",1);o(this,"width",0);o(this,"height",0);o(this,"x",0);o(this,"y",0);o(this,"timeout",0);o(this,"lastTouch");o(this,"initialDistance",0);o(this,"touchMode",0);o(this,"isMouseover",!1);o(this,"isBindEvent",!0);o(this,"isDrawAssist",!1);o(this,"customDrawAssist");o(this,"isMoveRedrawing");o(this,"afterDraw");o(this,"screenPos",{screenX:0,screenY:0});const{container:e,width:s=300,height:n=300,isBindEvent:r=!0,isDrawAssist:a=!1,isMoveRedrawing:h,customDrawAssist:c,afterDraw:f,...d}=t;this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.width=s,this.height=n,this.canvas.width=s,this.canvas.height=n,this.isBindEvent=r,this.isDrawAssist=a,this.customDrawAssist=c,this.isMoveRedrawing=h??a,this.options=d,this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMousemoveTemp=this.onMousemoveTemp.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onDblclick=this.onDblclick.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onMouseout=this.onMouseout.bind(this),this.afterDraw=this.afterDraw,r&&(this.canvas.addEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.addEventListener("mousewheel",this.onMousewheel),this.canvas.addEventListener("mousedown",this.onMousedown),this.canvas.addEventListener("mousemove",this.onMousemove),this.canvas.addEventListener("mouseout",this.onMouseout),this.canvas.addEventListener("dblclick",this.onDblclick),this.canvas.addEventListener("touchstart",this.onTouchstart))}onClick(t){const{screenX:e,screenY:s}=t;this.timeout&&clearTimeout(this.timeout);const n=this.getPos(t);this.x=n.x,this.y=n.y,this.screenPos={screenX:e,screenY:s},this.options.onClick&&(this.timeout=setTimeout(()=>{const r=parseFloat(((this.x-this.offset.x)/this.scale).toFixed(2)),a=parseFloat(((this.y-this.offset.y)/this.scale).toFixed(2));this.options.onClick(r,a)},200))}onMouseout(t){this.isMouseover=!1,this.draw()}onTouchstart(t){t.preventDefault(),t.touches.length==1?this.touchMode===0&&(this.touchMode=1):t.touches.length>=2&&this.touchMode<2&&(this.touchMode=2),this.touchMode==1&&t.touches.length==1?this.onTouch(t.touches[0]):this.touchMode==2&&t.touches.length==2&&this.onBothTouchstart(t),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend)}onMousedown(t){this.onClick(t),this.canvas.addEventListener("mousemove",this.onMousemoveTemp),this.canvas.addEventListener("mouseup",this.onMouseup)}onBothTouchstart(t){t.preventDefault();const e={x:t.touches[0].clientX,y:t.touches[0].clientY},s={x:t.touches[1].clientX,y:t.touches[1].clientY},n=this.getPos({clientX:(e.x+s.x)/2,clientY:(e.y+s.y)/2});this.x=n.x,this.y=n.y,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.initialDistance=Math.sqrt(Math.pow(s.x-e.x,2)+Math.pow(s.y-e.y,2))}onTouchmove(t){t.preventDefault(),this.touchMode==1&&t.touches.length==1?(this.onMousemoveTemp(t.touches[0]),this.onMousemove(t.touches[0])):this.touchMode==2&&t.touches.length==2&&this.onBothTouchmove(t)}onMousemove(t){const e=this.getPos(t);this.mousePosition.x=e.x,this.mousePosition.y=e.y,this.isMouseover=!0,this.isMoveRedrawing&&this.draw()}onMousemoveTemp(t){const{screenX:e,screenY:s}=this.screenPos;(Math.abs(e-t.screenX)>10||Math.abs(s-t.screenY)>10)&&(this.timeout&&clearTimeout(this.timeout),this.offset.x=this.curOffset.x+(this.mousePosition.x-this.x),this.offset.y=this.curOffset.y+(this.mousePosition.y-this.y),!this.isMoveRedrawing&&this.draw())}onBothTouchmove(t){if(t.preventDefault(),this.initialDistance){const e={x:t.touches[0].clientX,y:t.touches[0].clientY},s={x:t.touches[1].clientX,y:t.touches[1].clientY},n=Math.sqrt(Math.pow(s.x-e.x,2)+Math.pow(s.y-e.y,2));if(this.scale+=(n-this.initialDistance)/30*this.STEP_SCALE,this.initialDistance=n,this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}}onTouchend(){this.touchMode=0,this.onMouseup()}onMouseup(){this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.canvas.removeEventListener("mousemove",this.onMousemoveTemp),this.canvas.removeEventListener("mouseup",this.onMouseup),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend)}onMousewheel(t){this.timeout&&clearTimeout(this.timeout),t.preventDefault();const e=this.getPos(t);this.x=e.x,this.y=e.y;const s=t.wheelDelta>0||t.detail<0?this.STEP_SCALE:-this.STEP_SCALE;if(this.scale=parseFloat((this.scale+s).toFixed(2)),this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}onTouch(t){const e=Date.now(),{lastTouchTime:s=0,lastTouchX:n=0,lastTouchY:r=0}=this.lastTouch||{};e-s<300&&Math.abs(t.clientX-n)<30&&Math.abs(t.clientY-r)<30?(this.onDblclick(t),this.lastTouch={lastTouchTime:0,lastTouchX:0,lastTouchY:0}):(this.onClick(t),this.lastTouch={lastTouchTime:e,lastTouchX:t.clientX,lastTouchY:t.clientY})}onDblclick(t){this.timeout&&clearTimeout(this.timeout),this.reset(),this.draw()}zoom(){this.offset.x=this.x-(this.x-this.offset.x)*this.scale/this.preScale,this.offset.y=this.y-(this.y-this.offset.y)*this.scale/this.preScale,this.draw(),this.preScale=this.scale,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y}reset(t){const{width:e=this.width,height:s=this.height,scale:n=1,preScale:r=1,offset:a={x:0,y:0},curOffset:h={x:0,y:0}}=t||{};this.width=e,this.height=s,this.canvas.width=e,this.canvas.height=s,this.scale=n,this.preScale=r,this.offset=a,this.curOffset=h}drawAssist(){const t=this.ctx;t.save(),t.beginPath(),t.lineWidth=1,t.strokeStyle="#C656D5",t.moveTo(0,this.mousePosition.y),t.lineTo(this.width,this.mousePosition.y),t.closePath(),t.stroke(),t.beginPath(),t.moveTo(this.mousePosition.x,0),t.lineTo(this.mousePosition.x,this.height),t.closePath(),t.stroke(),t.restore()}draw(){var t;this.ctx.clearRect(0,0,this.width,this.height),this.ctx.save(),this.ctx.translate(this.offset.x,this.offset.y),this.ctx.scale(this.scale,this.scale),this.options.draw(this.ctx,this),this.ctx.restore(),this.isDrawAssist&&this.isMouseover&&(this.customDrawAssist?this.customDrawAssist():this.drawAssist()),(t=this.afterDraw)==null||t.call(this,this.ctx,this)}getPos(t){const e=this.canvas.getBoundingClientRect();let s=parseFloat((t.clientX-e.left).toFixed(2)),n=parseFloat((t.clientY-e.top).toFixed(2));return s=s<0?0:s,n=n<0?0:n,{x:s,y:n}}unBindEvent(){this.isBindEvent&&(this.canvas.removeEventListener("mousemove",this.onMousemove),this.canvas.removeEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.removeEventListener("mousewheel",this.onMousewheel),this.canvas.removeEventListener("mousedown",this.onMousedown),this.canvas.removeEventListener("mouseout",this.onMouseout),this.canvas.removeEventListener("dblclick",this.onDblclick))}}const it={};class Xt{constructor(t){o(this,"type","image");o(this,"x");o(this,"y");o(this,"width");o(this,"height");o(this,"img");o(this,"src");o(this,"redraw");this.x=t.x||0,this.y=t.y||0,this.width=t.width||0,this.height=t.height||0,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=it[this.src];if(e)return queueMicrotask(()=>{var s;t==null||t(e),(s=this.redraw)==null||s.call(this)}),e;{const s=new Image;return s.crossOrigin="anonymous",s.src=this.src,s.onload=()=>{var n;it[this.src]=s,t==null||t(s),(n=this.redraw)==null||n.call(this)},s}}draw(t){try{if(!this.img.complete)return;t.save(),t.drawImage(this.img,this.x,this.y,this.width,this.height),t.restore()}catch(e){console.error(e)}}}class Ft{constructor(t){o(this,"id","");o(this,"type","point");o(this,"x");o(this,"y");o(this,"r");o(this,"text");o(this,"backgroundColor");o(this,"index");o(this,"pIndex");o(this,"parentId");this.id=t.id,this.x=t.x,this.y=t.y,this.r=t.r||15,this.text=t.text||"",this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.backgroundColor=t.backgroundColor||"rgba(91, 179, 111, 0.8)"}draw(t,e){t.save();const s=1/e.scale;t.beginPath(),t.arc(this.x,this.y,this.r*s,0,2*Math.PI),t.fillStyle=this.backgroundColor,t.fill(),t.font=`${this.r*s}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.text,this.x,this.y+this.r*s/3),t.restore()}}const nt={};class Ut{constructor(t){o(this,"id","");o(this,"type","issue");o(this,"x");o(this,"y");o(this,"width");o(this,"height");o(this,"src");o(this,"img");o(this,"index");o(this,"pIndex");o(this,"parentId");o(this,"count");o(this,"badgeR");o(this,"redraw");this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width||0,this.height=t.height||0,this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.count=t.count||0,this.badgeR=3,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=nt[this.src];if(e)return queueMicrotask(()=>{var s;t==null||t(e),(s=this.redraw)==null||s.call(this)}),e;{const s=new Image;return s.src=this.src,s.crossOrigin="anonymous",s.onload=()=>{var n;nt[this.src]=s,t==null||t(s),(n=this.redraw)==null||n.call(this)},s}}draw(t,e){if(!this.img.complete)return;const s=1/e.scale,n=this.width*s,r=this.height*s,a=this.x-n/2,h=this.y-r,c=this.badgeR*s,f=c*1.5;t.save(),t.drawImage(this.img,a,h,n,r),t.beginPath(),this.count>1&&(t.arc(this.x+n*.3,this.y-r*.8,c,0,2*Math.PI),t.fillStyle="red",t.fill(),t.font=`${f}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.count.toString(),this.x+n*.3,this.y-r*.8+c/2)),t.restore()}}const rt={};class Yt{constructor(t){o(this,"type","marker");o(this,"x");o(this,"y");o(this,"url");o(this,"width");o(this,"height");o(this,"anchor");o(this,"img");o(this,"scale");o(this,"redraw");o(this,"beforeDraw");this.x=t.x,this.y=t.y,this.url=t.url,this.width=t.width??0,this.height=t.height??0,this.anchor=t.anchor,this.scale=t.scale??1,t.redraw&&(this.redraw=t.redraw),t.beforeDraw&&(this.beforeDraw=t.beforeDraw),this.img=this.loadImage(t.onload)}loadImage(t){const e=rt[this.url];if(e)return queueMicrotask(()=>{var s;t==null||t(e),(s=this.redraw)==null||s.call(this)}),e;{const s=new Image;return s.src=this.url,s.crossOrigin="anonymous",s.onload=()=>{var n;rt[this.url]=s,t==null||t(s),(n=this.redraw)==null||n.call(this)},s}}calculateIconPosition(){var s,n;const t=((s=this.anchor)==null?void 0:s.x)??this.width/2,e=((n=this.anchor)==null?void 0:n.y)??this.height/2;return{iconStartX:this.x-t*this.scale,iconStartY:this.y-e*this.scale}}draw(t,e){var r,a;if((r=this.beforeDraw)==null||r.call(this,t,e),!((a=this.img)!=null&&a.complete))return;const{iconStartX:s,iconStartY:n}=this.calculateIconPosition();t.save();try{t.drawImage(this.img,s,n,this.width*this.scale,this.height*this.scale)}catch(h){console.error("绘制标记时出错:",h)}finally{t.restore()}}}class Gt{constructor(t){o(this,"type","radar");o(this,"x");o(this,"y");o(this,"r");o(this,"angle");o(this,"text");o(this,"hFov",90);o(this,"beforeDraw");this.x=t.x,this.y=t.y,this.r=t.r||15,this.angle=t.angle||0,this.text=t.text||"",this.hFov=t.fovh||90,this.beforeDraw=t.beforeDraw}draw(t,e){var h;(h=this.beforeDraw)==null||h.call(this,t,e);const s=1/e.scale,[n,r]=[(this.angle-this.hFov/2)/180*Math.PI,(this.angle+this.hFov/2)/180*Math.PI];t.save();const a=t.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r*s);a.addColorStop(0,"rgba(180, 42, 42, 1)"),a.addColorStop(1,"rgba(180, 42, 42, 0.5)"),t.beginPath(),t.moveTo(this.x,this.y),t.arc(this.x,this.y,this.r*s,n,r),t.closePath(),t.fillStyle=a,t.fill(),t.restore()}}class Bt{constructor(t){o(this,"type","region");o(this,"x");o(this,"y");o(this,"shape");o(this,"areaPoints");o(this,"backgroundColor");if(this.x=t.x,this.y=t.y,this.shape=t.shape||"",this.backgroundColor=t.backgroundColor,t.areaPoints.length===2){const[{x:e,y:s},{},{x:n,y:r}]=t.areaPoints;this.areaPoints=[{x:Math.min(e,n),y:Math.min(s,r)},{x:Math.max(e,n),y:Math.min(s,r)},{x:Math.max(e,n),y:Math.max(s,r)},{x:Math.min(e,n),y:Math.max(s,r)}]}else this.areaPoints=t.areaPoints}draw(t,e){if(t.save(),t.beginPath(),t.globalAlpha=.3,t.fillStyle=this.backgroundColor,this.shape==="circle"){const[{x:s,y:n},{},{x:r,y:a}]=this.areaPoints,h=Math.abs(r-s)/2,c=s+(r-s)/2,f=n+(a-n)/2;t.arc(c,f,h,0,2*Math.PI)}else this.areaPoints.forEach((s,n)=>{const{x:r,y:a}=s;n===0?t.moveTo(r,a):t.lineTo(r,a)});t.fill(),t.restore()}}l.APP_SETTING=$,l.AppError=m,l.AppErrorCode=g,l.AppObsType=B,l.CanvasElement=At,l.CanvasImageElement=Xt,l.CanvasIssueElement=Ut,l.CanvasMarkerElement=Yt,l.CanvasPointElement=Ft,l.CanvasRadarElement=Gt,l.CanvasRegionElement=Bt,l.Coordinate=st,l.CoordinateLevel=G,l.CoordinateModelType=x,l.CoordinateStatus=R,l.CoordinateType=b,l.DataSource=p,l.GeoPoint=I,l.Point=w,l.Position=U,l.RelativeMap=v,l.RequestContentType=O,l.RequestMethod=M,l.RequestResultCode=L,l.Vector3=Y,l.api=mt,l.http=ft,l.utils=kt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.Shared={}))})(this,(function(l){"use strict";var $t=Object.defineProperty;var _t=(l,m,x)=>m in l?$t(l,m,{enumerable:!0,configurable:!0,writable:!0,value:x}):l[m]=x;var o=(l,m,x)=>_t(l,typeof m!="symbol"?m+"":m,x);class m extends Error{constructor(t,e,s){super(e),this.code=t,this.message=e,this.details=s,this.name="Apprror",Object.setPrototypeOf(this,m.prototype)}toJSON(){return{code:this.code,message:this.message,details:this.details,timestamp:new Date().toISOString()}}}var x=(i=>(i[i.CADModel=5]="CADModel",i[i.BIMModel=6]="BIMModel",i[i.ForgeModel=7]="ForgeModel",i[i.ThreeDModel=8]="ThreeDModel",i[i.SkyMapModel=9]="SkyMapModel",i[i.ScaleModel=10]="ScaleModel",i))(x||{}),G=(i=>(i[i.Global=0]="Global",i))(G||{}),b=(i=>(i[i.Space=0]="Space",i[i.Model=1]="Model",i[i.Data=2]="Data",i))(b||{}),R=(i=>(i[i.Used=0]="Used",i[i.Enabled=1]="Enabled",i[i.Disabled=2]="Disabled",i))(R||{}),L=(i=>(i[i.SUCCESS=200]="SUCCESS",i[i.ERROR=-1]="ERROR",i[i.TIMEOUT=401]="TIMEOUT",i))(L||{}),M=(i=>(i.GET="GET",i.POST="POST",i))(M||{}),O=(i=>(i.JSON="application/json",i.FORM_URLENCODED="application/x-www-form-urlencoded;charset=UTF-8",i.FORM_DATA="multipart/form-data;charset=UTF-8",i.OCTET_STREAM="'application/octet-stream",i))(O||{}),B=(i=>(i.Hw="huawei",i.Ali="aliyun",i.Hs="hs",i.Aws="amazon",i.Minio="minio",i))(B||{}),g=(i=>(i[i.GeoPointNoPlane=9e3]="GeoPointNoPlane",i[i.PointUnmappedGIS=9010]="PointUnmappedGIS",i[i.PointNoXYZ=9011]="PointNoXYZ",i[i.PointNoPlane=9012]="PointNoPlane",i[i.RelativePlaneUnmatch=9020]="RelativePlaneUnmatch",i[i.RelativeNoPlane=9021]="RelativeNoPlane",i[i.RelativeJsonError=9022]="RelativeJsonError",i[i.RequestCodeError=9030]="RequestCodeError",i[i.RequestResultError=9031]="RequestResultError",i[i.RequestUnknownError=9032]="RequestUnknownError",i))(g||{});const $={baseUrl:"https://vsleem.com/api",obsType:"hs"},ot={isTransformResponse:!0,joinBaseUrl:!0,withAuthorize:!0},at={url:"",method:M.GET,headers:{}},_={...$};function ht(i){Object.assign(_,i)}async function S(i,t){const e={...ot,...t},s={...at,...i};try{const n=ct(s,e),{url:r,...a}=n,c=await(await window.fetch(r,a)).json();return lt(c,e)}catch(n){return ut(n)}}function ct(i,t){const{baseUrl:e,authorizeCode:s}=_,{joinBaseUrl:n,withAuthorize:r}=t;let{url:a,method:h,headers:c={},params:f,data:d}=i;n&&e&&(a=`${e}${a}`),h=h==null?void 0:h.toUpperCase();const u={...c};if(/^https?:\/\/.+$/i.test(e??"")?u.PlatForm=new URL(e??"").host:u.PlatForm=new URL(window.location.href).host,r&&s&&(u.AuthorizationCode=s),h===M.POST&&!u["Content-Type"]&&(u["Content-Type"]=O.JSON),h===M.GET&&f){const P=new URLSearchParams(f);a+=`?${P.toString()}`}let y;return h===M.POST&&(y=u["Content-Type"]===O.JSON?JSON.stringify(d||{}):d),{url:a,method:h,headers:u,body:y}}function lt(i,t){if(!t.isTransformResponse)return i;if(!i)throw new m(g.RequestResultError,"请求返回的结果错误");const{code:e,data:s,msg:n}=i;if(e===L.SUCCESS)return s;throw new m(g.RequestCodeError,n||"请求返回的Code错误")}function ut(i){throw i instanceof Error?i:new m(g.RequestUnknownError,typeof i=="string"?i:"未知的请求错误")}const ft=Object.freeze(Object.defineProperty({__proto__:null,request:S,setRequestGlobalConfig:ht},Symbol.toStringTag,{value:"Module"}));function q(i,t){return S({url:"/project/jssdk/cs/list",method:M.GET,params:i},t)}function Z(i,t){return S({url:"/project/jssdk/cs/bind",method:M.POST,data:i},t)}function j(i,t){return S({url:"/project/jssdk/cs/save",method:M.POST,data:i},t)}function J(i,t){return S({url:"/project/jssdk/cs/delete",method:M.POST,data:i},t)}function H(i,t){return S({url:"/project/jssdk/cs/mapping",method:M.POST,data:i},t)}function V(i,t){return S({url:"/project/jssdk/cs/mapping/query",method:M.GET,params:i},t)}function dt(i,t={isTransformResponse:!1,joinBaseUrl:!1,withAuthorize:!1}){return S({url:i,method:M.GET},t)}const mt=Object.freeze(Object.defineProperty({__proto__:null,bindCoordinate:Z,getCoordinateList:q,getImageInfo:dt,getMappingRelation:V,mapingCoordinate:H,removeCoordinate:J,saveCoordinate:j},Symbol.toStringTag,{value:"Module"})),yt=typeof window<"u",wt=Object.prototype.toString;function T(i,t){return wt.call(i)===`[object ${t}]`}function W(i){return typeof i<"u"}function Q(i){return!W(i)}function k(i){return i!==null&&T(i,"Object")}function K(i){return i===null}function gt(i){return T(i,"Date")}function pt(i){return T(i,"String")}function A(i){return typeof i=="function"}function Mt(i){return T(i,"Boolean")}function vt(i){return T(i,"RegExp")}function N(i){return i&&Array.isArray(i)}function xt(i){return typeof window<"u"&&T(i,"Window")}function bt(i){return k(i)&&!!i.tagName}function Tt(i){return typeof i=="number"||/^\d+(\.\d+)?$/.test(i)}function D(i){return T(Number(i),"Number")}function St(i,t){return JSON.stringify(i)===JSON.stringify(t)}function Pt(i){return Q(i)||K(i)}function Et(i){return T(i,"Promise")&&k(i)&&A(i.then)&&A(i.catch)}function tt(i){return z(i,new WeakMap)}function z(i,t){if(typeof i!="object"||i===null)return i;if(t.has(i))return t.get(i);let e;if(i instanceof Date)return e=new Date(i),t.set(i,e),e;if(i instanceof RegExp)return e=new RegExp(i),t.set(i,e),e;if(i instanceof Map)return e=new Map,t.set(i,e),i.forEach((n,r)=>{e.set(r,z(n,t))}),e;if(i instanceof Set)return e=new Set,t.set(i,e),i.forEach(n=>{e.add(z(n,t))}),e;if(ArrayBuffer.isView(i))return e=new i.constructor(i.buffer.slice(0),i.byteOffset,i.byteLength),t.set(i,e),e;if(i instanceof ArrayBuffer)return e=i.slice(0),t.set(i,e),e;if(Array.isArray(i)){e=[],t.set(i,e);for(let n=0;n<i.length;n++)n in i&&(e[n]=z(i[n],t));return e}e=Object.create(Object.getPrototypeOf(i)),t.set(i,e);for(const n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=z(i[n],t));const s=Object.getOwnPropertySymbols(i);for(const n of s)Object.prototype.propertyIsEnumerable.call(i,n)&&(e[n]=z(i[n],t));return e}function Nt(i,t,e=!1){let s;const n=function(...r){const a=this,h=e&&!s;s&&clearTimeout(s),s=setTimeout(()=>{s=void 0,e||i.apply(a,r)},t),h&&i.apply(a,r)};return n.cancel=()=>{s&&clearTimeout(s),s=void 0},n}function zt(i,t,e=!1){let s,n;const r=function(...a){const h=this;n?(clearTimeout(s),s=setTimeout(()=>{Date.now()-n>=t&&(i.apply(h,a),n=Date.now())},t-(Date.now()-n))):(e&&i.apply(h,a),n=Date.now())};return r.cancel=()=>{clearTimeout(s),s=void 0,n=void 0},r}function X(i,...t){if(!t.length)return i;const e=t.shift();return e===void 0?i:(C(i)&&C(e)&&Object.keys(e).forEach(s=>{const n=i[s],r=e[s];Array.isArray(n)&&Array.isArray(r)?i[s]=[...n,...r]:C(n)&&C(r)?i[s]=X({...n},r):r!==void 0&&(i[s]=r)}),X(i,...t))}function C(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function et(i,...t){if(!t.length)return i;for(const e of t)e!=null&&typeof e=="object"&&Object.keys(e).forEach(s=>{const n=e[s],r=i[s];n!==null&&typeof n=="object"&&!Array.isArray(n)?((!r||typeof r!="object")&&(i[s]={}),et(i[s],n)):i[s]=n});return i}function It(i,t={}){return new Promise((e,s)=>{const n=F(i);if(Dt(n)){e(!0);return}const r=document.createElement("script");r.src=i,Object.entries(t).forEach(([a,h])=>{h!==!1&&r.setAttribute(a,h===!0?"":String(h))}),r.onload=()=>{e(!0)},r.onerror=()=>{document.head.removeChild(r),s(new Error(`Failed to load script: ${i}`))},document.head.appendChild(r)})}function Dt(i){const t=F(i);return Array.from(document.scripts).some(e=>F(e.src)===t)}function F(i){try{const t=new URL(i,window.location.href);return`${t.origin}${t.pathname}`}catch{return i}}function Rt(i,t,e,s){const n=Math.min(i/e,t/s),r=e*n,a=s*n;return{scale:n,x:(i-r)/2,y:(t-a)/2,sw:r,sh:a}}function Ot(i,t,e){return{x:i*e.scale+e.x,y:t*e.scale+e.y}}function Ct(i,t,e){return{x:(i-e.x)/e.scale,y:(t-e.y)/e.scale}}function Lt(i){console.warn(`[warn]:${i}`)}function jt(i){throw new Error(`[error]:${i}`)}const kt=Object.freeze(Object.defineProperty({__proto__:null,cloneDeep:tt,debounce:Nt,deepMerge:X,deepMergeProps:et,error:jt,getImageTransform:Rt,inBrowser:yt,is:T,isArray:N,isBoolean:Mt,isDate:gt,isDef:W,isElement:bt,isFunction:A,isNull:K,isNullOrUnDef:Pt,isNumber:D,isNumeric:Tt,isObject:k,isPromise:Et,isRegExp:vt,isSameValue:St,isString:pt,isUnDef:Q,isWindow:xt,loadScript:It,throttle:zt,toCanvasCoord:Ot,toModelCoord:Ct,warn:Lt},Symbol.toStringTag,{value:"Module"}));class w{constructor(t){o(this,"x",0);o(this,"y",0);o(this,"z",0);o(this,"lat",0);o(this,"lon",0);o(this,"alt",0);o(this,"yaw",0);o(this,"pitch",0);o(this,"roll",0);o(this,"hasXYZ",!1);o(this,"hasGeo",!1);o(this,"hasAngle",!1);o(this,"plane","xy");const{x:e,y:s,z:n,lat:r,lon:a,alt:h,yaw:c,pitch:f,roll:d,plane:u="xy"}=t||{};D(e)&&D(s)&&(this.x=Number(e)||0,this.y=Number(s)||0,this.z=Number(n)||0,this.plane=u,this.hasXYZ=!0),D(r)&&D(a)&&Number(r)!==0&&Number(a)!==0&&(this.lat=Number(r)||0,this.lon=Number(a)||0,this.alt=Number(h)||0,this.hasGeo=!0),(c!==void 0||f!==void 0||d!==void 0)&&(this.yaw=Number(c)||0,this.pitch=Number(f)||0,this.roll=Number(d)||0,this.hasAngle=!0)}static dist(t,e){return Math.hypot(t.x-e.x,t.y-e.y,t.z-e.z)}static distXZ(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}static distXY(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}static toRadians(t){return(Number(t)||0)*Math.PI/180}static toDegrees(t){return(Number(t)||0)*180/Math.PI}static angleXZ(t,e,s){const n={x:t.x-e.x,z:t.z-e.z},r={x:s.x-e.x,z:s.z-e.z},a=n.x*r.x+n.z*r.z,h=Math.sqrt(n.x**2+n.z**2),c=Math.sqrt(r.x**2+r.z**2),f=Math.max(-1,Math.min(1,a/(h*c))),u=Math.acos(f)*180/Math.PI;return Math.min(u,360-u)}static toParse(t){if(t){const e=t==null?void 0:t.split(",").map(s=>Number(s)||0);return new w({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}projection(t,e,s){try{if((e==null?void 0:e.id)===(s==null?void 0:s.id))return new w(this);if((e==null?void 0:e.modelType)===x.SkyMapModel){const{refPoint:n}=(e==null?void 0:e.relativeMap)||{};if(this.hasGeo&&n){const r=I.LLHToXYZ(this,n);return this.x=r.x,this.y=r.y,this.z=r.z,this.hasXYZ=!0,this.project(t)}throw new m(g.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}if((s==null?void 0:s.modelType)===x.SkyMapModel){const{refPoint:n}=(s==null?void 0:s.relativeMap)||{},r=this.project(t);if(r!=null&&r.hasXYZ&&n){const a=I.XYZToLLH(r,n);return r.lat=a.lat,r.lon=a.lon,r.alt=a.alt,r.hasGeo=!0,r}throw new m(g.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}return this.project(t)}catch{return}}project(t){if(!this.hasXYZ)throw new m(g.PointNoXYZ,"点没有xxz坐标信息");if(this.plane==="xz")return this.projectXZ(t);if(this.plane==="xy")return this.projectXY(t);throw new m(g.PointNoPlane,"点的plane应为xz或xy")}projectXZ(t){const e=new w(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const s=e.x*Math.cos(t.yaw)-e.z*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.z*Math.cos(t.yaw);return e.x=s+t.x,e.y+=t.y,e.z=n+t.z,e}projectXY(t){const e=new w(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const s=e.x*Math.cos(t.yaw)-e.y*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.y*Math.cos(t.yaw);return e.x=s+t.x,e.y=n+t.y,e.z+=t.z,e}}class I{constructor(t){o(this,"lat",0);o(this,"lon",0);o(this,"alt",0);const{lat:e=0,lon:s=0,alt:n=0}=t||{};this.lat=e,this.lon=s,this.alt=n}static XYZToLLH(t,e){const n=.0033528106647474805,r=n*(2-n),a=w.toRadians(e.lat),h=6378137/Math.sqrt(1-r*Math.sin(a)**2)+e.alt;let c,f,d;if(t.plane==="xz"){const u=t.x/1e3/(h*Math.cos(a)),y=t.z/1e3/h;c=e.lon+w.toDegrees(u),f=e.lat-w.toDegrees(y),d=e.alt+t.y/1e3}else if(t.plane==="xy"){const u=t.x/1e3/(h*Math.cos(a)),y=t.y/1e3/h;c=e.lon+w.toDegrees(u),f=e.lat-w.toDegrees(y),d=e.alt+t.z/1e3}else throw new m(g.GeoPointNoPlane,"点的plane应为xz或xy");return new I({lat:f,lon:c,alt:d})}static LLHToXYZ(t,e){const n=.0033528106647474805,r=n*(2-n),a=w.toRadians(e.lat),h=6378137/Math.sqrt(1-r*Math.sin(a)**2)+e.alt,c=w.toRadians(t.lon-e.lon),f=w.toRadians(e.lat-t.lat),d=h*c*Math.cos(a),u=h*f;if(t.plane==="xz")return new w({x:d*1e3,y:(t.alt-e.alt)*1e3,z:u*1e3,plane:"xz"});if(t.plane==="xy")return new w({x:d*1e3,y:u*1e3,z:(t.alt-e.alt)*1e3,plane:"xy"});throw new m(g.GeoPointNoPlane,"点的plane应为xz或xy")}}class v{constructor(t){o(this,"scale",1);o(this,"yaw",0);o(this,"x",0);o(this,"y",0);o(this,"z",0);o(this,"start",0);o(this,"end",-1);o(this,"plane","xy");o(this,"refPoint");const{refPoint:e,...s}=t||{};e&&(this.refPoint=new I(e)),Object.assign(this,s)}static addRelativeMap(t,e){if(t.plane!==e.plane)throw new m(g.RelativePlaneUnmatch,"两个映射关系的plane应该相同");const s=t.scale*e.scale,n=t.yaw+e.yaw,r=Math.cos(e.yaw),a=Math.sin(e.yaw);let h=0,c=0,f=0;if(t.plane==="xz"){const d=t.x*r-t.z*a,u=t.y,y=t.x*a+t.z*r;h=e.x+d*e.scale,c=e.y+u*e.scale,f=e.z+y*e.scale}else if(t.plane==="xy"){const d=t.x*r-t.y*a,u=t.x*a+t.y*r,y=t.z;h=e.x+d*e.scale,c=e.y+u*e.scale,f=e.z+y*e.scale}else throw new m(g.RelativeNoPlane,"映射关系的plane应为xz或xy");return new v({scale:s,yaw:n,x:h,y:c,z:f,start:t.start,end:t.end,plane:t.plane})}static inverseRelativeMap(t){const e=1/t.scale,s=-t.yaw,n=Math.cos(-s),r=Math.sin(-s);let a=0,h=0,c=0;if(t.plane==="xz")a=-(t.x*n+t.z*r)*e,h=-t.y*e,c=-(t.z*n-t.x*r)*e;else if(t.plane==="xy")a=-(t.x*n+t.y*r)*e,h=-(t.y*n-t.x*r)*e,c=-t.z*e;else throw new m(g.RelativeNoPlane,"映射关系的plane应为xz或xy");return new v({scale:e,yaw:s,x:a,y:h,z:c,start:t.start,end:t.end,plane:t.plane})}static toParse(t){try{let e=t?JSON.parse(t):void 0;const{reference_point:s}=e||{};return s&&(e={refPoint:s}),e?new v(e):void 0}catch{throw new m(g.RelativeJsonError,"relativeMap格式化失败")}}static toStringify(t){return t?JSON.stringify(t):void 0}}class p{static async getCoordinateTree(t){const e=await q({projectId:t});if(e.length){const s=p.handleCoordinateList(e);return p.buildCoordinateTree(s,0)}}static async addCoordinate(t,e){const{projectId:s,id:n}=t,r=e.map(h=>{const{type:c,modelType:f,relativeMap:d,level:u,...y}=h,P=d?JSON.stringify(d):void 0;return{...y,projectId:s,parentId:n,coordinateType:c,renderType:f,relativePosition:P}}),a=await j(r);return p.handleCoordinateList(a)}static async removeCoordinate(t,e){const s=e.map(n=>n.id??-1);return await J(s)}static async updateCoordinate(t,e){const{projectId:s,id:n}=t,r=e.map(h=>{const{type:c,relativeMap:f,level:d,...u}=h,y=v.toStringify(f);return{...u,relativePosition:y,projectId:s,parentId:n}}),a=await j(r);return p.handleCoordinateList(a)}static async bindCoordinate(t,e){const{projectId:s,id:n}=t,r=e.map(h=>{const{modelId:c}=h;return{modelId:c,parentId:n,projectId:s}}),a=await Z(r);return p.handleCoordinateList(a)}static handleCoordinateList(t){return t==null?void 0:t.map(e=>{const{coordinateType:s,modelKey:n,renderType:r,relativePosition:a,...h}=e,c=v.toParse(a);return new st({...h,type:s,modelType:r,modelValue:n,relativeMap:c})})}static buildCoordinateTree(t,e){const s=new Map,n=[];return t.forEach(r=>{s.set(String(r.id),r)}),t.forEach(r=>{var h;const a=s.get(String(r.id));if(a)if(r.parentId===e)a.level=0,n.push(a);else{const c=s.get(String(r.parentId??-1));c&&(a.level=(Number(c.level)||0)+1,a.parent=c,(h=c.children)==null||h.push(a))}}),n.forEach(p.sortCoordinateTree),n[0]}static sortCoordinateTree(t){t.children&&(t.children.sort((e,s)=>{var n,r;if(e.type===b.Space){const a=Number((n=s==null?void 0:s.relativeMap)==null?void 0:n.z)-Number((r=e==null?void 0:e.relativeMap)==null?void 0:r.z);return a!==0?a:Number(s.createTime)-Number(e.createTime)}else return e.status===0&&s.status!==0?-1:s.status===0&&e.status!==0?1:Number(s.createTime)-Number(e.createTime)}),t.children.forEach(p.sortCoordinateTree))}static filterSpaceTree(t){const e=[];return t.forEach(s=>{const n=p.filterSpaceTree(s.children);s.children=n,s.disabled=s.disabled??!1,s.type!==b.Model&&e.push(s)}),e}}class st{constructor(t){o(this,"id",0);o(this,"type",0);o(this,"children",[]);o(this,"level");o(this,"relativeMap");o(this,"no");o(this,"name");o(this,"shortName");o(this,"status");o(this,"modelId");o(this,"modelType");o(this,"modelValue");o(this,"projectId");o(this,"parentId");o(this,"parent");o(this,"groupUuid");o(this,"z");o(this,"createTime");o(this,"disabled");this.setOptions(t)}get spaceList(){return this.children.filter(t=>t.type===b.Space)}get modelList(){return this.children.filter(t=>t.type===b.Model)}get fullName(){const t=this.name?`(${this.name})`:"";return this.shortName?`${this.shortName}${t}`:this.name??""}setOptions(t){const{relativeMap:e,parent:s,children:n,...r}=t||{};e&&(this.relativeMap=new v(e)),s&&(this.parent=s),n!=null&&n.length&&(this.children=n),Object.assign(this,r)}async addChild(t){const e=N(t)?t:[t],s=await p.addCoordinate(this,e);this.mergeChild(s)}async removeChild(t){const e=N(t)?t:[t];await p.removeCoordinate(this,e);for(const s of e){const n=this.children.findIndex(r=>r.id===s.id);n!==-1&&this.children.splice(n,1)}}async updateChild(t){const e=N(t)?t:[t],s=await p.updateCoordinate(this,e);this.mergeChild(s)}async bindChild(t){const e=N(t)?t:[t],s=await p.bindCoordinate(this,e);this.mergeChild(s)}async mergeChild(t){t!=null&&t.length&&t.forEach(e=>{const s=this.children.find(n=>n.id===e.id);if(s){const{relativeMap:n,no:r,name:a,shortName:h,status:c,modelId:f,modelValue:d}=e;Object.assign(s,{relativeMap:n,no:r,name:a,shortName:h,status:c,modelId:f,modelValue:d})}else this.id===e.parentId&&(e.parent=this,this.children.unshift(e))})}async mappingTo(t){await H(t)}async fromMapping(){const t=await V({srcCsId:this.id});return t[t.length-1]}findRoot(t=!1){let e=this;for(;e.parent&&!(t&&!e.relativeMap);)e=e.parent;return e}findChildModel(t=[x.CADModel,x.SkyMapModel],e=!0){var h,c;const s=N(t)?t:[t];if(s.includes(this.modelType??-1)&&this.status!==R.Disabled)return this;const r=[b.Data,b.Model].includes(this.type)?this.findParentSpace():this,a=(c=(h=r==null?void 0:r.modelList)==null?void 0:h.filter(f=>s.includes(f.modelType??-1)?e?!!f.relativeMap:!0:!1))==null?void 0:c.sort((f,d)=>Number(f.status)-Number(d.status));return a==null?void 0:a[0]}findClosestModel(t=x.CADModel,e){var f;const s=new Set;for(const d of e??[])s.add(String(d.id));const n=[{node:this,distance:0}],r=N(t)?t:[t],a=new Set;let h,c=1/0;for(;n.length>0;){const d=n.shift();if(!d)break;const{node:u,distance:y}=d;if(s.has(String(u.id)))continue;if(r.includes(u.modelType??-1)){if(y<c&&(h=u,c=y,y<=1))break;continue}a.add(u);const P=[];if((f=u.parent)!=null&&f.children)for(const E of u.parent.children)E!==u&&!a.has(E)&&P.push(E);if(u.children)for(const E of u.children)a.has(E)||P.push(E);u.parent&&!a.has(u.parent)&&P.push(u.parent);for(const E of P)n.push({node:E,distance:y+1})}return h}findParentSpace(){let t=this;for(;t&&t.type!==b.Space;)t=t.parent;return t}findParentSpaceNames(t=2){const e=[];let s=this;for(;s&&t>0;)s.type===b.Space&&(e.unshift(s.fullName),t--),s=s.parent;return e}findCsGroup(){var s;const{groupUuid:t,parent:e}=this;return t?((s=e==null?void 0:e.children)==null?void 0:s.filter(n=>n.groupUuid===t))||[]:[this]}findCsByLevel(t){if(this.level===t)return this;if(this.children.length)for(const e of this.children){const s=e.findCsByLevel(t);if(s)return s}}findCsById(t){if(t){if(this.id===t)return this;for(const e of this.children){const s=e.findCsById(t);if(s)return s}}}getCsRoutes(t=!1){let e=this;const s=[e];for(;e!=null&&e.parent&&!(t&&!e.relativeMap);)e=e.parent,e&&s.push(e);return s}getMappedCsTree(){function t(n){var r;return(r=n.children)!=null&&r.length&&(n.children=n.children.filter(a=>!!(a!=null&&a.relativeMap)&&a.status!==R.Disabled).map(a=>t(a))),n}const e=tt(this.findRoot(!0)),s=t(e);return s.parentId=0,s.parent=void 0,s}getDestRelativeMap(t){var r;if(this.id===t.id)return new v;const e=this.getRelativeMaps(),s=t.getRelativeMaps();let n=new v;return e==null||e.forEach(a=>{n=v.addRelativeMap(n,a)}),(r=s==null?void 0:s.reverse())==null||r.forEach(a=>{n=v.addRelativeMap(n,v.inverseRelativeMap(a))}),n}getRelativeMaps(){let t=this;const e=[];for(;t!=null&&t.parent&&t.relativeMap;)e.push(t.relativeMap),t=t.parent;return e}static filterCoordinateTree(t,e=[],s=[]){var r;if(s.includes(t.id)||e.includes(t.type))return;const n=(r=t.children)==null?void 0:r.map(a=>this.filterCoordinateTree(a,e,s)).filter(a=>a!==void 0);return{...t,children:n}}static getCommonCoordinate(t){let e;const s=t.map(n=>n.getCsRoutes(!0).filter(a=>a.id&&a.type===b.Space));for(;this.checkSameCoordinate(s);){const r=s.shift();r!=null&&r.length&&(e=r[0])}return e}static checkSameCoordinate(t){if(t.length){if(t.length===1)return!0;for(let e=0;e<t.length-1;e++){const s=t[e];if(!(s!=null&&s.length))return!1;const n=t[e+1];if(!(n!=null&&n.length)||s[0].id!==n[0].id)return!1}return!0}else return!1}}class U{constructor(t){o(this,"yaw",0);o(this,"pitch",0);o(this,"roll",0);const{yaw:e=0,pitch:s=0,roll:n=0}=t||{};this.yaw=Number(e)||0,this.pitch=Number(s)||0,this.roll=Number(n)||0}static toParse(t){if(t){const e=t==null?void 0:t.split(",").map(s=>Number(s)||0);return new U({yaw:e[0],pitch:e[1],roll:e[2]})}}static toStringify(t){return t?`${t.yaw},${t.pitch},${t.roll}`:""}}class Y{constructor(t){o(this,"x",0);o(this,"y",0);o(this,"z",0);const{x:e=0,y:s=0,z:n=0}=t||{};this.x=Number(e)||0,this.y=Number(s)||0,this.z=Number(n)||0}static toParse(t){if(t){const e=t==null?void 0:t.split(",").map(s=>Number(s)||0);return new Y({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}}class At{constructor(t){o(this,"canvas");o(this,"ctx");o(this,"options");o(this,"offset",{x:0,y:0});o(this,"curOffset",{x:0,y:0});o(this,"mousePosition",{x:-1,y:-1});o(this,"MAX_SCALE",60);o(this,"MIN_SCALE",1);o(this,"STEP_SCALE",.5);o(this,"scale",1);o(this,"preScale",1);o(this,"width",0);o(this,"height",0);o(this,"x",0);o(this,"y",0);o(this,"timeout",0);o(this,"lastTouch");o(this,"initialDistance",0);o(this,"touchMode",0);o(this,"isMouseover",!1);o(this,"isBindEvent",!0);o(this,"isDrawAssist",!1);o(this,"customDrawAssist");o(this,"isMoveRedrawing");o(this,"afterDraw");o(this,"screenPos",{screenX:0,screenY:0});const{container:e,width:s=300,height:n=300,isBindEvent:r=!0,isDrawAssist:a=!1,isMoveRedrawing:h,customDrawAssist:c,afterDraw:f,...d}=t;this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.width=s,this.height=n,this.canvas.width=s,this.canvas.height=n,this.isBindEvent=r,this.isDrawAssist=a,this.customDrawAssist=c,this.isMoveRedrawing=h??a,this.options=d,this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMousemoveTemp=this.onMousemoveTemp.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onDblclick=this.onDblclick.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onMouseout=this.onMouseout.bind(this),this.afterDraw=this.afterDraw,r&&(this.canvas.addEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.addEventListener("mousewheel",this.onMousewheel),this.canvas.addEventListener("mousedown",this.onMousedown),this.canvas.addEventListener("mousemove",this.onMousemove),this.canvas.addEventListener("mouseout",this.onMouseout),this.canvas.addEventListener("dblclick",this.onDblclick),this.canvas.addEventListener("touchstart",this.onTouchstart))}onClick(t){const{screenX:e,screenY:s}=t;this.timeout&&clearTimeout(this.timeout);const n=this.getPos(t);this.x=n.x,this.y=n.y,this.screenPos={screenX:e,screenY:s},this.options.onClick&&(this.timeout=setTimeout(()=>{const r=parseFloat(((this.x-this.offset.x)/this.scale).toFixed(2)),a=parseFloat(((this.y-this.offset.y)/this.scale).toFixed(2));this.options.onClick(r,a)},200))}onMouseout(t){this.isMouseover=!1,this.draw()}onTouchstart(t){t.preventDefault(),t.touches.length==1?this.touchMode===0&&(this.touchMode=1):t.touches.length>=2&&this.touchMode<2&&(this.touchMode=2),this.touchMode==1&&t.touches.length==1?this.onTouch(t.touches[0]):this.touchMode==2&&t.touches.length==2&&this.onBothTouchstart(t),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend)}onMousedown(t){this.onClick(t),this.canvas.addEventListener("mousemove",this.onMousemoveTemp),this.canvas.addEventListener("mouseup",this.onMouseup)}onBothTouchstart(t){t.preventDefault();const e={x:t.touches[0].clientX,y:t.touches[0].clientY},s={x:t.touches[1].clientX,y:t.touches[1].clientY},n=this.getPos({clientX:(e.x+s.x)/2,clientY:(e.y+s.y)/2});this.x=n.x,this.y=n.y,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.initialDistance=Math.sqrt(Math.pow(s.x-e.x,2)+Math.pow(s.y-e.y,2))}onTouchmove(t){t.preventDefault(),this.touchMode==1&&t.touches.length==1?(this.onMousemoveTemp(t.touches[0]),this.onMousemove(t.touches[0])):this.touchMode==2&&t.touches.length==2&&this.onBothTouchmove(t)}onMousemove(t){const e=this.getPos(t);this.mousePosition.x=e.x,this.mousePosition.y=e.y,this.isMouseover=!0,this.isMoveRedrawing&&this.draw()}onMousemoveTemp(t){const{screenX:e,screenY:s}=this.screenPos;(Math.abs(e-t.screenX)>10||Math.abs(s-t.screenY)>10)&&(this.timeout&&clearTimeout(this.timeout),this.offset.x=this.curOffset.x+(this.mousePosition.x-this.x),this.offset.y=this.curOffset.y+(this.mousePosition.y-this.y),!this.isMoveRedrawing&&this.draw())}onBothTouchmove(t){if(t.preventDefault(),this.initialDistance){const e={x:t.touches[0].clientX,y:t.touches[0].clientY},s={x:t.touches[1].clientX,y:t.touches[1].clientY},n=Math.sqrt(Math.pow(s.x-e.x,2)+Math.pow(s.y-e.y,2));if(this.scale+=(n-this.initialDistance)/30*this.STEP_SCALE,this.initialDistance=n,this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}}onTouchend(){this.touchMode=0,this.onMouseup()}onMouseup(){this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.canvas.removeEventListener("mousemove",this.onMousemoveTemp),this.canvas.removeEventListener("mouseup",this.onMouseup),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend)}onMousewheel(t){this.timeout&&clearTimeout(this.timeout),t.preventDefault();const e=this.getPos(t);this.x=e.x,this.y=e.y;const s=t.wheelDelta>0||t.detail<0?this.STEP_SCALE:-this.STEP_SCALE;if(this.scale=parseFloat((this.scale+s).toFixed(2)),this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}onTouch(t){const e=Date.now(),{lastTouchTime:s=0,lastTouchX:n=0,lastTouchY:r=0}=this.lastTouch||{};e-s<300&&Math.abs(t.clientX-n)<30&&Math.abs(t.clientY-r)<30?(this.onDblclick(t),this.lastTouch={lastTouchTime:0,lastTouchX:0,lastTouchY:0}):(this.onClick(t),this.lastTouch={lastTouchTime:e,lastTouchX:t.clientX,lastTouchY:t.clientY})}onDblclick(t){this.timeout&&clearTimeout(this.timeout),this.reset(),this.draw()}zoom(){this.offset.x=this.x-(this.x-this.offset.x)*this.scale/this.preScale,this.offset.y=this.y-(this.y-this.offset.y)*this.scale/this.preScale,this.draw(),this.preScale=this.scale,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y}reset(t){const{width:e=this.width,height:s=this.height,scale:n=1,preScale:r=1,offset:a={x:0,y:0},curOffset:h={x:0,y:0}}=t||{};this.width=e,this.height=s,this.canvas.width=e,this.canvas.height=s,this.scale=n,this.preScale=r,this.offset=a,this.curOffset=h}drawAssist(){const t=this.ctx;t.save(),t.beginPath(),t.lineWidth=1,t.strokeStyle="#C656D5",t.moveTo(0,this.mousePosition.y),t.lineTo(this.width,this.mousePosition.y),t.closePath(),t.stroke(),t.beginPath(),t.moveTo(this.mousePosition.x,0),t.lineTo(this.mousePosition.x,this.height),t.closePath(),t.stroke(),t.restore()}draw(){var t;this.ctx.clearRect(0,0,this.width,this.height),this.ctx.save(),this.ctx.translate(this.offset.x,this.offset.y),this.ctx.scale(this.scale,this.scale),this.options.draw(this.ctx,this),this.ctx.restore(),this.isDrawAssist&&this.isMouseover&&(this.customDrawAssist?this.customDrawAssist():this.drawAssist()),(t=this.afterDraw)==null||t.call(this,this.ctx,this)}getPos(t){const e=this.canvas.getBoundingClientRect();let s=parseFloat((t.clientX-e.left).toFixed(2)),n=parseFloat((t.clientY-e.top).toFixed(2));return s=s<0?0:s,n=n<0?0:n,{x:s,y:n}}unBindEvent(){this.isBindEvent&&(this.canvas.removeEventListener("mousemove",this.onMousemove),this.canvas.removeEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.removeEventListener("mousewheel",this.onMousewheel),this.canvas.removeEventListener("mousedown",this.onMousedown),this.canvas.removeEventListener("mouseout",this.onMouseout),this.canvas.removeEventListener("dblclick",this.onDblclick))}}const it={};class Xt{constructor(t){o(this,"type","image");o(this,"x");o(this,"y");o(this,"width");o(this,"height");o(this,"img");o(this,"src");o(this,"redraw");this.x=t.x||0,this.y=t.y||0,this.width=t.width||0,this.height=t.height||0,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=it[this.src];if(e)return queueMicrotask(()=>{var s;t==null||t(e),(s=this.redraw)==null||s.call(this)}),e;{const s=new Image;return s.crossOrigin="anonymous",s.src=this.src,s.onload=()=>{var n;it[this.src]=s,t==null||t(s),(n=this.redraw)==null||n.call(this)},s}}draw(t){try{if(!this.img.complete)return;t.save(),t.drawImage(this.img,this.x,this.y,this.width,this.height),t.restore()}catch(e){console.error(e)}}}class Ft{constructor(t){o(this,"id","");o(this,"type","point");o(this,"x");o(this,"y");o(this,"r");o(this,"text");o(this,"backgroundColor");o(this,"index");o(this,"pIndex");o(this,"parentId");this.id=t.id,this.x=t.x,this.y=t.y,this.r=t.r||15,this.text=t.text||"",this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.backgroundColor=t.backgroundColor||"rgba(91, 179, 111, 0.8)"}draw(t,e){t.save();const s=1/e.scale;t.beginPath(),t.arc(this.x,this.y,this.r*s,0,2*Math.PI),t.fillStyle=this.backgroundColor,t.fill(),t.font=`${this.r*s}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.text,this.x,this.y+this.r*s/3),t.restore()}}const nt={};class Ut{constructor(t){o(this,"id","");o(this,"type","issue");o(this,"x");o(this,"y");o(this,"width");o(this,"height");o(this,"src");o(this,"img");o(this,"index");o(this,"pIndex");o(this,"parentId");o(this,"count");o(this,"badgeR");o(this,"redraw");this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width||0,this.height=t.height||0,this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.count=t.count||0,this.badgeR=3,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=nt[this.src];if(e)return queueMicrotask(()=>{var s;t==null||t(e),(s=this.redraw)==null||s.call(this)}),e;{const s=new Image;return s.src=this.src,s.crossOrigin="anonymous",s.onload=()=>{var n;nt[this.src]=s,t==null||t(s),(n=this.redraw)==null||n.call(this)},s}}draw(t,e){if(!this.img.complete)return;const s=1/e.scale,n=this.width*s,r=this.height*s,a=this.x-n/2,h=this.y-r,c=this.badgeR*s,f=c*1.5;t.save(),t.drawImage(this.img,a,h,n,r),t.beginPath(),this.count>1&&(t.arc(this.x+n*.3,this.y-r*.8,c,0,2*Math.PI),t.fillStyle="red",t.fill(),t.font=`${f}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.count.toString(),this.x+n*.3,this.y-r*.8+c/2)),t.restore()}}const rt={};class Yt{constructor(t){o(this,"type","marker");o(this,"x");o(this,"y");o(this,"url");o(this,"width");o(this,"height");o(this,"anchor");o(this,"img");o(this,"scale");o(this,"redraw");o(this,"beforeDraw");this.x=t.x,this.y=t.y,this.url=t.url,this.width=t.width??0,this.height=t.height??0,this.anchor=t.anchor,this.scale=t.scale??1,t.redraw&&(this.redraw=t.redraw),t.beforeDraw&&(this.beforeDraw=t.beforeDraw),this.img=this.loadImage(t.onload)}loadImage(t){const e=rt[this.url];if(e)return queueMicrotask(()=>{var s;t==null||t(e),(s=this.redraw)==null||s.call(this)}),e;{const s=new Image;return s.src=this.url,s.crossOrigin="anonymous",s.onload=()=>{var n;rt[this.url]=s,t==null||t(s),(n=this.redraw)==null||n.call(this)},s}}calculateIconPosition(){var s,n;const t=((s=this.anchor)==null?void 0:s.x)??this.width/2,e=((n=this.anchor)==null?void 0:n.y)??this.height/2;return{iconStartX:this.x-t*this.scale,iconStartY:this.y-e*this.scale}}draw(t,e){var r,a;if((r=this.beforeDraw)==null||r.call(this,t,e),!((a=this.img)!=null&&a.complete))return;const{iconStartX:s,iconStartY:n}=this.calculateIconPosition();t.save();try{t.drawImage(this.img,s,n,this.width*this.scale,this.height*this.scale)}catch(h){console.error("绘制标记时出错:",h)}finally{t.restore()}}}class Gt{constructor(t){o(this,"type","radar");o(this,"x");o(this,"y");o(this,"r");o(this,"angle");o(this,"text");o(this,"hFov",90);o(this,"beforeDraw");this.x=t.x,this.y=t.y,this.r=t.r||15,this.angle=t.angle||0,this.text=t.text||"",this.hFov=t.fovh||90,this.beforeDraw=t.beforeDraw}draw(t,e){var h;(h=this.beforeDraw)==null||h.call(this,t,e);const s=1/e.scale,[n,r]=[(this.angle-this.hFov/2)/180*Math.PI,(this.angle+this.hFov/2)/180*Math.PI];t.save();const a=t.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r*s);a.addColorStop(0,"rgba(180, 42, 42, 1)"),a.addColorStop(1,"rgba(180, 42, 42, 0.5)"),t.beginPath(),t.moveTo(this.x,this.y),t.arc(this.x,this.y,this.r*s,n,r),t.closePath(),t.fillStyle=a,t.fill(),t.restore()}}class Bt{constructor(t){o(this,"type","region");o(this,"x");o(this,"y");o(this,"shape");o(this,"areaPoints");o(this,"backgroundColor");if(this.x=t.x,this.y=t.y,this.shape=t.shape||"",this.backgroundColor=t.backgroundColor,t.areaPoints.length===2){const[{x:e,y:s},{},{x:n,y:r}]=t.areaPoints;this.areaPoints=[{x:Math.min(e,n),y:Math.min(s,r)},{x:Math.max(e,n),y:Math.min(s,r)},{x:Math.max(e,n),y:Math.max(s,r)},{x:Math.min(e,n),y:Math.max(s,r)}]}else this.areaPoints=t.areaPoints}draw(t,e){if(t.save(),t.beginPath(),t.globalAlpha=.3,t.fillStyle=this.backgroundColor,this.shape==="circle"){const[{x:s,y:n},{},{x:r,y:a}]=this.areaPoints,h=Math.abs(r-s)/2,c=s+(r-s)/2,f=n+(a-n)/2;t.arc(c,f,h,0,2*Math.PI)}else this.areaPoints.forEach((s,n)=>{const{x:r,y:a}=s;n===0?t.moveTo(r,a):t.lineTo(r,a)});t.fill(),t.restore()}}l.APP_SETTING=$,l.AppError=m,l.AppErrorCode=g,l.AppObsType=B,l.CanvasElement=At,l.CanvasImageElement=Xt,l.CanvasIssueElement=Ut,l.CanvasMarkerElement=Yt,l.CanvasPointElement=Ft,l.CanvasRadarElement=Gt,l.CanvasRegionElement=Bt,l.Coordinate=st,l.CoordinateLevel=G,l.CoordinateModelType=x,l.CoordinateStatus=R,l.CoordinateType=b,l.DataSource=p,l.GeoPoint=I,l.Point=w,l.Position=U,l.RelativeMap=v,l.RequestContentType=O,l.RequestMethod=M,l.RequestResultCode=L,l.Vector3=Y,l.api=mt,l.http=ft,l.utils=kt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vsleem-realsee-viewer/shared",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "private": false,
5
5
  "description": "Shared utilities for VSLeem RealSee Viewer",
6
6
  "main": "./dist/index.umd.js",