You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hy-screen-2.0/docs/assets/index-d5f4c71b-178680784825...

116 lines
288 KiB

var Hu=Object.defineProperty,qu=Object.defineProperties;var Uu=Object.getOwnPropertyDescriptors;var Ls=Object.getOwnPropertySymbols;var Ku=Object.prototype.hasOwnProperty,Zu=Object.prototype.propertyIsEnumerable;var $a=Math.pow,Ts=(m,e,t)=>e in m?Hu(m,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):m[e]=t,I=(m,e)=>{for(var t in e||(e={}))Ku.call(e,t)&&Ts(m,t,e[t]);if(Ls)for(var t of Ls(e))Zu.call(e,t)&&Ts(m,t,e[t]);return m},E=(m,e)=>qu(m,Uu(e));var oe=(m,e,t)=>new Promise((a,i)=>{var o=h=>{try{u(t.next(h))}catch(p){i(p)}},l=h=>{try{u(t.throw(h))}catch(p){i(p)}},u=h=>h.done?a(h.value):Promise.resolve(h.value).then(o,l);u((t=t.apply(m,e)).next())});import{k as ro,q as io,h as so,w as oa,o as P,c as N,a as d,d as _,a7 as Xu,A as ia,g as S,a9 as Ae,s as Ie,v as Qu,C as Yt,u as O,j as pe,n as Se,t as T,F as U,y as ee,K as nt,b as j,x as Q,B as Rt,e as ma,H as jt,f as Ea,ab as It}from"./index-1786807848259.js";import{H as ve}from"./index.esm.min-024ee703-1786807848259.js";import{_ as te}from"./index-0eddac6c-1786807848259.js";import{t as jr,S as Ta,u as zn,v as ja,w as Ju,V as le,F as ec,C as Tt,G as Ce,c as tc,d as ac,f as nc,g as $r,L as ga,D as Ee,a as ke,h as xn,R as ct,A as Ve,N as Ss,b as Qe,P as Ht,o as ya,n as va,x as rc,T as ic,B as sc,i as oc,j as lc,k as uc,l as cc,m as dc,y as hc,z as Va,E as ks,H as Ms,I as pc,J as Cs,q as Ps,r as fc,s as Er,K as Da,U as za,W as Ns,M as mc}from"./screen2Standard-03f7f908-1786807848259.js";import{g as sa,M as gc,h as yc,L as vc,B as Oa,a as ba,E as Fs,G as Rn,D as bc,b as wc,l as Lc,P as xs,c as Rs,e as Tc,f as Sc,i as kc,j as Mc,k as Is,m as _s,n as Gs,o as Cc,d as In,p as Pc,q as Vr,r as Nc,s as Fc,t as xc}from"./yakApi-0d53b9e4-1786807848259.js";import{g as wa}from"./index-db918426-1786807848259.js";import{h as Rc,a as oo,k as q,W as St,S as Ic,l as Dr,m as _c,n as zr,M as Gc,o as Ac}from"./index-80cb981f-1786807848259.js";import{_ as Bc}from"./TopicSwitcher-c91bad20-1786807848259.js";import{_ as $c}from"./LayerPanel-e92912ff-1786807848259.js";import{A as Ec}from"./assets-8728b943-1786807848259.js";import"./_plugin-vue_export-helper-c27b6911-1786807848259.js";const Vc=Rc.map(m=>I({},m)),As=oo.map(m=>I({},m)),Dc=oo.map(m=>{var e,t;return{name:m.name,value:m.value,lng:(e=m.center)==null?void 0:e[0],lat:(t=m.center)==null?void 0:t[1]}}),zc=[{name:"邛溪镇",level:"县城驻地",value:895.94,lng:102.60242339873115,lat:32.83022561372293},{name:"瓦切镇",level:"北部牧区",value:991,lng:102.71535664604494,lat:33.12869670968013},{name:"刷经寺镇",level:"南部通道",value:986.44,lng:102.55651980382184,lat:32.204097908180216},{name:"色地镇",level:"东部片区",value:1199.06,lng:103.12540730227074,lat:33.010462261362875}],ka=256,Hr="/external/satellite/{z}/{x}/{y}.png",Oc=900,Wc=10,la=new Map,Ma={west:101.852492,south:31.851389,east:103.347518,north:33.319796};function Or(m,e,t){const a=$a(2,t),i=Math.sin(e*Math.PI/180);return{x:(m+180)/360*a,y:(.5-Math.log((1+i)/(1-i))/(4*Math.PI))*a}}function Bs(m,e,t){const a=$a(2,t),i=m/a*360-180,o=Math.PI-2*Math.PI*e/a,l=180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)));return[i,l]}function _n(m,e,t){return Math.max(e,Math.min(t,m))}function lo(m,e,{centerLngLat:t,maxCols:a,maxRows:i}={}){const o=Or(m.west,m.north,e),l=Or(m.east,m.south,e),u=Math.floor(o.x),h=Math.floor(l.x),p=Math.floor(o.y),y=Math.floor(l.y);let g=u,w=h,C=p,F=y,x=Math.floor((u+h)/2),G=Math.floor((p+y)/2);if(t&&Number.isFinite(a)&&Number.isFinite(i)){const H=_n(Number(t[0]),m.west,m.east),J=_n(Number(t[1]),m.south,m.north),ne=Or(H,J,e);x=Math.floor(ne.x),G=Math.floor(ne.y);const K=Math.max(1,Math.min(Math.floor(a),h-u+1)),V=Math.max(1,Math.min(Math.floor(i),y-p+1));g=_n(x-Math.floor(K/2),u,h-K+1),C=_n(G-Math.floor(V/2),p,y-V+1),w=g+K-1,F=C+V-1}return{zoom:e,minX:g,maxX:w,minY:C,maxY:F,centerX:x,centerY:G,cols:w-g+1,rows:F-C+1}}function Yc({zoom:m=11,centerLngLat:e,maxCols:t,maxRows:a,bounds:i=Ma}={}){return lo(i,m,{centerLngLat:e,maxCols:t,maxRows:a})}function jc(m,e){const[t,a]=Bs(m.minX,m.minY,m.zoom),[i,o]=Bs(m.maxX+1,m.maxY+1,m.zoom),[l]=e([t,Ma.south]),[u]=e([i,Ma.south]),[,h]=e([Ma.west,a]),[,p]=e([Ma.west,o]);return{left:l,right:u,bottom:-p,top:-h}}function Hc(m,e){const{width:t,height:a}=e;m.save(),m.globalCompositeOperation="multiply",m.fillStyle="rgba(5, 24, 34, 0.22)",m.fillRect(0,0,t,a),m.globalCompositeOperation="screen";const i=m.createRadialGradient(t*.5,a*.48,t*.1,t*.5,a*.5,t*.72);i.addColorStop(0,"rgba(80, 230, 255, 0.16)"),i.addColorStop(1,"rgba(0, 18, 36, 0.03)"),m.fillStyle=i,m.fillRect(0,0,t,a),m.restore()}function qc(m,e){const t=m.createLinearGradient(0,0,e.width,e.height);t.addColorStop(0,"#061927"),t.addColorStop(.5,"#0b2c3c"),t.addColorStop(1,"#07131f"),m.fillStyle=t,m.fillRect(0,0,e.width,e.height)}function Uc(m){const e=la.get(m);return e||new Promise(t=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>t(a),a.onerror=()=>{la.delete(m),t(null)},a.src=m})}function Kc(m){const e=la.get(m);if(e)return e;const t=Uc(m);for(la.set(m,t);la.size>Oc;){const a=la.keys().next().value;if(!a)break;la.delete(a)}return t}function Zc(m,e,t,a=Hr){return String(a||Hr).replace(/\{x\}/g,m).replace(/\{y\}/g,e).replace(/\{z\}/g,t)}function Xc(u,h,p,y){return oe(this,arguments,function*(m,e,t,a,{tileUrlTemplate:i,onTileStatus:o,applyTone:l=!0}={}){const g=[],w=a.cols*a.rows;let C=0,F=0;o==null||o({type:"loading",text:`正在加载${a.zoom}级影像底图`,loaded:C,failed:F,total:w,zoom:a.zoom,tileRange:a,tileUrlTemplate:i}),m.save(),m.filter="brightness(0.92) contrast(1.22) saturate(1.06)";for(let K=a.minX;K<=a.maxX;K+=1)for(let V=a.minY;V<=a.maxY;V+=1)g.push({x:K,y:V});g.sort((K,V)=>Math.abs(K.x-a.centerX)+Math.abs(K.y-a.centerY)-(Math.abs(V.x-a.centerX)+Math.abs(V.y-a.centerY)));let x=0;function G(){return oe(this,null,function*(){for(;x<g.length;){const K=g[x];x+=1;const V=yield Kc(Zc(K.x,K.y,a.zoom,i));V?(C+=1,m.drawImage(V,(K.x-a.minX)*ka,(K.y-a.minY)*ka,ka,ka),t.needsUpdate=!0):F+=1,o==null||o({type:"loading",text:`正在加载${a.zoom}级影像底图`,loaded:C,failed:F,total:w,zoom:a.zoom,tileRange:a,tileUrlTemplate:i})}})}yield Promise.all(Array.from({length:Math.min(Wc,g.length)},G)),m.restore(),l&&Hc(m,e),t.needsUpdate=!0;const H=w>0?C/w:0,J=C===0?"error":H>=.75?"success":"warning",ne=C===w?`${a.zoom}级影像底图已加载`:C>0?`${a.zoom}级影像底图已加载(${C}/${w}张有效瓦片)`:`${a.zoom}级影像底图加载失败`;o==null||o({type:J,text:ne,loaded:C,failed:F,total:w,zoom:a.zoom,tileRange:a,tileUrlTemplate:i})})}function $s({geoProjectionCenter:m,geoProjectionScale:e,zoom:t=11,tileUrlTemplate:a=Hr,onTileStatus:i,centerLngLat:o,maxCols:l,maxRows:u,transparentBackground:h=!1,applyTone:p=!0}={}){const y=lo(Ma,t,{centerLngLat:o,maxCols:l,maxRows:u}),g=document.createElement("canvas");g.width=y.cols*ka,g.height=y.rows*ka;const w=g.getContext("2d");h?w.clearRect(0,0,g.width,g.height):qc(w,g);const C=new jr(g);C.colorSpace=Ta,C.wrapS=zn,C.wrapT=zn,C.minFilter=ja,C.magFilter=ja,C.needsUpdate=!0;const F=sa().center(m).scale(e).translate([0,0]),x=jc(y,F);return Xc(w,g,C,y,{tileUrlTemplate:a,onTileStatus:i,applyTone:p}).catch(G=>{console.warn("load satellite tiles failed:",G),i==null||i({type:"error",text:`${y.zoom}级影像底图加载失败`,loaded:0,failed:y.cols*y.rows,total:y.cols*y.rows,zoom:y.zoom,tileRange:y,tileUrlTemplate:a})}),{texture:C,uvBounds:x,tileRange:y}}function Es(m,e){const t=e.right-e.left,a=e.top-e.bottom;m.mapGroup.traverse(i=>{var u,h;const o=(h=(u=i.geometry)==null?void 0:u.attributes)==null?void 0:h.position;if(!i.isMesh||!o)return;const l=new Float32Array(o.count*2);for(let p=0;p<o.count;p+=1){const y=o.getX(p),g=o.getY(p);l[p*2]=(y-e.left)/t,l[p*2+1]=(g-e.bottom)/a}i.geometry.setAttribute("uv",new Ju(l,2)),i.geometry.attributes.uv.needsUpdate=!0})}const Kr={}.VITE_GEOSERVER_WMS_URL||"/geoserver/v3/wms",Qc={}.VITE_GEOSERVER_WFS_URL||Kr.replace(/\/wms$/i,"/wfs"),Jc={}.VITE_GEOSERVER_WMTS_URL||"/geoserver/gwc/service/wmts";function On(m,e){const t=new URLSearchParams;return Object.entries(e).forEach(([a,i])=>{i!=null&&i!==""&&t.append(a,i)}),`${m}${m.includes("?")?"&":"?"}${t.toString()}`}function ed(m,e={}){const t=e.bounds||q,a=e.size||St;return On(e.url||Kr,{service:"WMS",version:"1.1.1",request:"GetMap",layers:m.layerName,styles:m.styles||"",format:"image/png",transparent:!0,tiled:!0,srs:"EPSG:4326",bbox:[t.west,t.south,t.east,t.north].join(","),width:a.width,height:a.height,CQL_FILTER:e.cqlFilter||m.cqlFilter,SLD_BODY:e.sldBody||m.sldBody,_:Date.now()})}function td(m,e={}){var o,l,u,h,p;const t=m.tileMatrixSetID||m.tileMatrixSet||"EPSG:900913",a=Number((h=(u=(l=(o=e.z)!=null?o:e.zoom)!=null?l:m.wmtsZoom)!=null?u:m.homeWmtsZoom)!=null?h:0),i=e.tileMatrix||((p=m.tileMatrixLabels)==null?void 0:p[a])||`${t}:${a}`;return On(e.url||m.url||Jc,{service:"WMTS",version:"1.0.0",request:"GetTile",layer:m.layerName,style:m.style||m.styles||"",format:m.format||"image/png",tileMatrixSet:t,tileMatrix:i,tileRow:e.y,tileCol:e.x})}function ad(m,e,t={}){var o,l;const a=t.bounds||q,i=t.size||St;return On(t.url||Kr,{service:"WMS",version:"1.1.1",request:"GetFeatureInfo",layers:m.layerName,query_layers:m.layerName,styles:m.styles||"",info_format:"application/json",feature_count:5,srs:"EPSG:4326",bbox:[a.west,a.south,a.east,a.north].join(","),width:i.width,height:i.height,x:Math.round(e.x),y:Math.round(e.y),buffer:(l=(o=t.buffer)!=null?o:m.queryBuffer)!=null?l:8,CQL_FILTER:t.cqlFilter||m.cqlFilter,SLD_BODY:t.sldBody||m.sldBody})}function Vs(a,i){return oe(this,arguments,function*(m,e,t={}){const o=ad(m,e,t);return ro(o,{credentials:"include"})})}function nd(m,e={}){return On(e.url||Qc,{service:"WFS",version:e.version||"1.0.0",request:"GetFeature",typeName:m,outputFormat:"json",propertyName:Array.isArray(e.propertyName)?e.propertyName.join(","):e.propertyName,CQL_FILTER:e.cqlFilter,maxFeatures:e.maxFeatures||2e5})}function Ds(t){return oe(this,arguments,function*(m,e={}){const a=nd(m,e);return ro(a,{credentials:"include",timeout:e.timeout||2e4})})}const rd=new le(-.17427287762525134,13.678992786206543,20.688611202093714),id=new le(0,0,0),sd=new le(-13.767695123014105,12.990152163077308,39.28228164159694),Gn=21,od=9,ld=260,ud=12,cd=700,La=new Map,zs="#30DCFF",dd="#F2FFFF",hd="#8BF7FF",Os=3202303,pd=15925247,Ws=9172991,Ys={"family-pasture":"pasture","artificial-grassland":"grass","scale-breeding":"breeding","forage-storage":"storage","slaughter-processing":"processing","farm-equipment":"equipment","social-service":"service"};function js(m){return m.sort((e,t)=>t.value-e.value),m}function dt(m){return String(m||"").replace(/\s+/g,"").trim()}function de(m,e=0){const t=Number(m);return Number.isFinite(t)?t:e}function na(m,e,t){const a=Number(m);return Number.isFinite(a)?Math.max(e,Math.min(t,a)):e}function Pe(m){return String(m!=null?m:"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function Hs(m){return(m==null?void 0:m.scope)==="village"||(m==null?void 0:m.labelMode)==="village"}function qs(m){return(m==null?void 0:m.scope)==="trade-flow"||(m==null?void 0:m.labelMode)==="trade-flow"}function fd(m){return(m==null?void 0:m.showFlowLines)!==!1}function Us(m){return!!(m!=null&&m.hideTownNames||(m==null?void 0:m.showTownNames)===!1)}function Wa(m){return!!(m!=null&&m.hideMapLabels||(m==null?void 0:m.showMapLabels)===!1)}function md(m){return(m==null?void 0:m.displayMode)==="callout"||(m==null?void 0:m.labelMode)==="callout"}function An(m){return["wkt-api","geojson","wfs"].includes(String((m==null?void 0:m.sourceType)||"").toLowerCase())}function gd(m){return(m==null?void 0:m.interactive)===!1||(m==null?void 0:m.key)==="yak-recognition-layer"}function Ks(m){return String((m==null?void 0:m.sourceType)||"").toLowerCase()==="wmts"}function Zs(m,e,t){const a=$a(2,t),i=Math.sin(e*Math.PI/180);return{x:(m+180)/360*a,y:(.5-Math.log((1+i)/(1-i))/(4*Math.PI))*a}}function Xs(m,e,t){const a=$a(2,t),i=m/a*360-180,o=Math.PI-2*Math.PI*e/a,l=180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)));return[i,l]}function yd(m,e){const t=Zs(m.west,m.north,e),a=Zs(m.east,m.south,e);return{minX:Math.floor(t.x),maxX:Math.floor(a.x),minY:Math.floor(t.y),maxY:Math.floor(a.y)}}function vd(m,e,t,a){const[i,o]=Xs(m,e,t),[l,u]=Xs(m+1,e+1,t),h=q.east-q.west,p=q.north-q.south;return{x:(i-q.west)/h*a.width,y:(q.north-o)/p*a.height,width:(l-i)/h*a.width,height:(o-u)/p*a.height}}function bd(m){const e=La.get(m);if(e)return e;const t=new Promise(a=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>a(i),i.onerror=()=>{La.delete(m),a(null)},i.src=m});for(La.set(m,t);La.size>cd;){const a=La.keys().next().value;if(!a)break;La.delete(a)}return t}function Qs(m){return m?/^https?:\/\//.test(m)||m.startsWith("/")?m:`./${m}`:""}function wd(m){if(!m)return null;if(typeof m=="string")try{return JSON.parse(m)}catch(e){return console.warn("地图 GeoJSON 解析失败",e),null}return m}function Ya(m){const e=wd(m);return e!=null&&e.features&&e.features.forEach(t=>{var a;((a=t.geometry)==null?void 0:a.type)==="Polygon"&&(t.geometry.coordinates=[t.geometry.coordinates])}),e}function Js(m){var e,t,a;return m!=null&&m.coordinates?m.type==="Polygon"?Array.isArray((a=(t=(e=m.coordinates)==null?void 0:e[0])==null?void 0:t[0])==null?void 0:a[0])?m.coordinates:[m.coordinates]:m.type==="MultiPolygon"?m.coordinates:[]:[]}class Ld extends gc{constructor(e,t,a={}){var u,h,p,y;super(e),this.geoProjectionCenter=[102.6305459723107,32.72169252326339],this.geoProjectionScale=650,this.tradeGeoProjectionCenter=[104,36],this.tradeGeoProjectionScale=11.4,this.tradeNationalDepth=.24,this.depth=.5,this.clicked=!1,this.scene.fog=new ec(466735,1,50),this.scene.background=new Tt(466735),this.camera.instance.position.copy(sd),this.camera.instance.near=1,this.camera.instance.far=1e4,this.camera.instance.updateProjectionMatrix(),this.defaultMapCameraPosition=rd.clone(),this.defaultMapTarget=id.clone(),this.camera.controls.target.copy(this.defaultMapTarget),this.camera.controls.update(),this.activeMapViewTweens=[],this.sceneTweens=[],this.sceneTimers=[],this.interactionManager=new yc(this.renderer.instance,this.camera.instance,this.canvas),this.assets=t,this.callbacks=a,this.useSatelliteBase=a.useSatelliteBase!==!1,this.showNationalBackdrop=a.showNationalBackdrop===!0,this.topicLayerPresentation=a.topicLayerPresentation||"default",this.hideTownLabelStatsByDefault=a.hideTownLabelStats===!0,this.tileUrlTemplate=a.tileUrlTemplate||"",this.usesCustomSatelliteTiles=this.useSatelliteBase&&!!this.tileUrlTemplate;const i=Math.round(Number(a.satelliteTextureZoom));this.satelliteTextureZoom=Number.isFinite(i)&&i>0?Math.min(Gn,i):Ic;const o=Math.round(Number(a.satelliteMaxZoom)),l=Number.isFinite(o)&&o>0?Math.min(Gn,Math.max(this.satelliteTextureZoom,o)):Gn;this.adminBoundaryLineScale=this.normalizeAdminBoundaryLineScale(a.adminBoundaryLineScale),this.mapBoundaryEmphasisMaterial=null,this.dynamicSatelliteMaxZoom=l,this.dynamicSatelliteTileWindow=od,this.dynamicSatelliteOverlay=null,this.dynamicSatelliteMaterial=null,this.dynamicSatelliteTexture=null,this.dynamicSatelliteCurrentKey="",this.dynamicSatelliteLoadingKey="",this.dynamicSatelliteRequestId=0,this.dynamicSatelliteLastCheck=0,this.topicLayerLoadId=0,this.visibleTopicLayers=[],this.mapAnimationComplete=!1,this.showTownRankingBars=!1,this.showTownRankingPointMarkers=!1,this.currentTownRanking=null,this.villageRankingGroup=null,this.villageRankingLabels=[],this.tradeFlowGroup=null,this.tradeFlowMeshGroup=null,this.tradeFlowLabelGroup=null,this.tradeFlowLabels=[],this.tradeFlowMaterials=[],this.tradeFlowPulseSprites=[],this.isTradeNationalMapActive=!1,this.selectedFeatureGroup=null,this.selectedVectorFeatures=[],this.analysisBoundaryFeature=null,this.analysisMatchedFeatures=[],this.boundaryDrawingEnabled=!1,this.boundaryDrawPoints=[],this.lastBoundaryDrawPoint=null,this.currentVectorFeatures=[],this.yakIndustryPointLabelGroup=null,this.yakIndustryPointLabels=[],this.yakIndustryPointMarkerGroup=null,this.yakIndustryPointMarkers=[],this.yakIndustryMarkerMaterialCache=new Map,this.hongyuanBoundaryPolygons=[],this.townMetaByName=new Map(As.map(g=>[dt(g.name),g])),this.staticMapData={china:Ya(this.assets.instance.getResource("china")),mapJson:Ya(this.assets.instance.getResource("mapJson")),mapStroke:Ya(this.assets.instance.getResource("mapStroke"))},this.handleCanvasBoundaryPointerDown=this.handleCanvasBoundaryPointerDown.bind(this),this.handleCanvasBoundaryDoubleClick=this.handleCanvasBoundaryDoubleClick.bind(this),(h=(u=this.canvas)==null?void 0:u.addEventListener)==null||h.call(u,"pointerdown",this.handleCanvasBoundaryPointerDown,!0),(y=(p=this.canvas)==null?void 0:p.addEventListener)==null||y.call(p,"dblclick",this.handleCanvasBoundaryDoubleClick,!0),this.initEnvironment(),this.init()}init(){this.labelGroup=new Ce,this.label3d=new vc(this),this.labelGroup.rotation.x=-Math.PI/2,this.scene.add(this.labelGroup),this.flyLineFocusGroup=new Ce,this.flyLineFocusGroup.visible=!1,this.flyLineFocusGroup.rotation.x=-Math.PI/2,this.scene.add(this.flyLineFocusGroup),this.eventElement=[],this.defaultMaterial=null,this.defaultLightMaterial=null,this.createBottomBg(),this.createChinaBlurLine(),this.createGrid(),this.createRotateBorder(),this.createLabel(),this.createMap(),this.createEvent(),this.createFlyLine(),this.createFocus(),this.createParticles(),this.createScatter(),this.createInfoPoint(),this.createStorke();let e=wa.timeline({onComplete:()=>{var a;if(this.mapAnimationComplete=!0,this.applyLayerMapView(this.currentTopicLayer,{force:!0}),this.setTradeNationalMapVisible(!!((a=this.currentTownRanking)!=null&&a.nationalFlow)),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.updateYakIndustryPointLabels(this.currentTopicLayer,this.currentVectorFeatures),Wa(this.currentTownRanking)){this.hideAllMapStatisticLabels();return}this.updateVillageRankingLabels(this.currentTownRanking),this.updateTradeFlowLayer(this.currentTownRanking),this.updateInfoPointStats()}});e.pause(),this.animateTl=e,e.addLabel("focusMap",1.5),e.addLabel("focusMapOpacity",2),e.addLabel("bar",3),e.to(this.camera.instance.position,{duration:2,x:this.defaultMapCameraPosition.x,y:this.defaultMapCameraPosition.y,z:this.defaultMapCameraPosition.z,ease:"circ.out",onStart:()=>{this.flyLineFocusGroup.visible=!1}}),e.to(this.focusMapGroup.position,{duration:1,x:0,y:0,z:0},"focusMap"),e.to(this.focusMapGroup.scale,{duration:1,x:1,y:1,z:1,ease:"circ.out",onComplete:()=>{if(this.flyLineGroup.visible=!0,this.scatterGroup.visible=!0,this.InfoPointGroup.visible=!Wa(this.currentTownRanking)&&this.showTownRankingPointMarkers&&this.hasTownRankingRows(),this.setTradeNationalMapVisible(!1),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.updateYakIndustryPointLabels(this.currentTopicLayer,this.currentVectorFeatures),Wa(this.currentTownRanking)){this.hideAllMapStatisticLabels();return}this.updateVillageRankingLabels(this.currentTownRanking),this.updateTradeFlowLayer(this.currentTownRanking),this.updateInfoPointStats()}},"focusMap"),e.to(this.focusMapTopMaterial,{duration:1,opacity:this.getFocusMapTopOpacity(),ease:"circ.out"},"focusMapOpacity"),e.to(this.focusMapSideMaterial,{duration:1,opacity:1,ease:"circ.out",onComplete:()=>{this.focusMapSideMaterial.transparent=!1}},"focusMapOpacity"),this.otherLabel.map((a,i)=>{let o=a.element.querySelector(".other-label");e.to(o,{duration:1,delay:.1*i,translateY:0,opacity:1,ease:"circ.out"},"focusMapOpacity")}),e.to(this.mapLineMaterial,{duration:.5,delay:.3,opacity:1},"focusMapOpacity"),this.mapBoundaryEmphasisMaterial&&e.to(this.mapBoundaryEmphasisMaterial,{duration:.5,delay:.3,opacity:this.getAdminBoundaryEmphasisOpacity()},"focusMapOpacity"),e.to(this.rotateBorder1.scale,{delay:.3,duration:1,x:1,y:1,z:1,ease:"circ.out"},"focusMapOpacity"),e.to(this.rotateBorder2.scale,{duration:1,delay:.5,x:1,y:1,z:1,ease:"circ.out",onComplete:()=>{var a,i;this.flyLineFocusGroup.visible=!0,(i=(a=this.callbacks).onPlayComplete)==null||i.call(a)}},"focusMapOpacity"),this.showTownRankingBars&&(this.allBar.map((a,i)=>{e.to(a.scale,{duration:1,delay:.1*i,x:1,y:1,z:1,ease:"circ.out"},"bar")}),this.allBarMaterial.map((a,i)=>{e.to(a,{duration:1,delay:.1*i,opacity:1,ease:"circ.out"},"bar")}));const t=this;this.allProvinceLabel.map((a,i)=>{let o=a.element.querySelector(".provinces-label-wrap"),l=a.element.querySelector(".number .value"),u={progress:0};e.to(o,{duration:1,delay:.2*i,translateY:0,opacity:1,ease:"circ.out"},"bar"),e.to(u,{duration:1,delay:.2*i,progress:1,onStart:()=>{u.progress=0},onUpdate:h},"bar");function h(){var y,g;const p=de((g=(y=a.userData)==null?void 0:y.targetValue)!=null?g:l.dataset.targetValue);l.innerText=t.formatMapRankingValue(p*u.progress)}}),this.showTownRankingBars&&this.allGuangquan.map((a,i)=>{e.to(a.children[0].scale,{duration:1,delay:.1*i,x:1,y:1,z:1,ease:"circ.out"},"bar"),e.to(a.children[1].scale,{duration:1,delay:.1*i,x:1,y:1,z:1,ease:"circ.out"},"bar")})}initEnvironment(){let e=new tc(13171711,4.2);this.scene.add(e);let t=new ac(14679295,5.8);t.position.set(-30,6,-8),t.castShadow=!0,t.shadow.radius=20,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,this.scene.add(t),this.createPointLight({color:"#1fd6df",intensity:680,distance:1e4,x:-9,y:3,z:-3}),this.createPointLight({color:"#2af0c6",intensity:260,distance:1e4,x:0,y:2,z:5})}createPointLight(e){const t=new nc(1924702,e.intensity,e.distance);t.position.set(e.x,e.y,e.z),this.scene.add(t)}createMap(){let e=new Ce,t=new Ce;this.mapGroup=e,this.focusMapGroup=t;let{china:a,chinaTopLine:i}=this.createChina(),{map:o,mapTop:l,mapLine:u,mapBoundaryEmphasis:h}=this.createProvince();this.createNationalBackdrop(),a.setParent(e),i.setParent(e),this.createDiffuse(),o.setParent(t),l.setParent(t),u.setParent(t),h==null||h.setParent(t),t.position.set(0,0,-.01),t.scale.set(1,1,0),e.add(t),this.createTopicLayer(),e.rotation.x=-Math.PI/2,e.position.set(0,.2,0),this.scene.add(e),this.createBar()}createChina(){let e={chinaBgMaterialColor:"#0d3349",lineColor:"#39c7ef"},t=this.staticMapData.china,a=new $r({color:new Tt(e.chinaBgMaterialColor),transparent:!0,opacity:.72}),i=new Oa(this,{data:t,geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,merge:!0,material:a,renderOrder:2}),o=new ga({color:e.lineColor,transparent:!0,opacity:.58}),l=new ba(this,{data:t,geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,material:o,renderOrder:3});return l.lineGroup.position.z+=.01,{china:i,chinaTopLine:l}}createNationalBackdrop(){var p;if(!this.showNationalBackdrop||this.nationalBackdropGroup)return!1;let e=null;try{e=Ya(this.assets.instance.getResource("chinaMap"))}catch(y){return console.warn("首页全国底图资源未加载",y),!1}if(!((p=e==null?void 0:e.features)!=null&&p.length))return!1;const t=this.geoProjectionCenter,a=120,i=new le(0,0,-.08),o=new $r({color:new Tt("#152c47"),transparent:!0,opacity:.72,depthWrite:!1,fog:!1,side:Ee}),l=new Oa(this,{data:e,geoProjectionCenter:t,geoProjectionScale:a,merge:!0,position:i,material:o,renderOrder:0});l.mapGroup.name="home-national-backdrop-fill",l.setParent(this.mapGroup);const u=new ga({color:new Tt("#3f82cd"),transparent:!0,opacity:.46,depthWrite:!1,fog:!1}),h=new ba(this,{data:e,geoProjectionCenter:t,geoProjectionScale:a,position:new le(i.x,i.y,i.z+.01),material:u,renderOrder:1});return h.lineGroup.name="home-national-backdrop-line",h.setParent(this.mapGroup),this.nationalBackdropGroup=l.mapGroup,this.nationalBackdropLineGroup=h.lineGroup,!0}createTradeNationalMap(){var g;if(this.tradeNationalMapGroup)return!0;let e=null;try{e=Ya(this.assets.instance.getResource("chinaMap"))}catch(w){return console.warn("牦牛交易全国地图资源未加载",w),!1}const t=e;if(!e||!((g=t==null?void 0:t.features)!=null&&g.length))return!1;const a=new Ce;a.name="trade-national-map",a.visible=!1,a.rotation.x=-Math.PI/2,a.position.set(0,.04,0);const i=new ke({color:403001,transparent:!0,opacity:.14,side:Ee,depthWrite:!1,fog:!1});new Oa(this,{data:e,geoProjectionCenter:this.tradeGeoProjectionCenter,geoProjectionScale:this.tradeGeoProjectionScale,position:new le(.05,-.05,-.03),material:i,renderOrder:17}).setParent(a);const{topMaterial:l,sideMaterial:u}=this.createTradeNationalMaterials(),h=new Fs(this,{data:e,geoProjectionCenter:this.tradeGeoProjectionCenter,geoProjectionScale:this.tradeGeoProjectionScale,position:new le(0,0,0),depth:this.tradeNationalDepth,topFaceMaterial:l,sideMaterial:u,renderOrder:20,bevelThickness:.024,bevelSegments:1});h.mapGroup.traverse(w=>{w.isMesh&&(w.renderOrder=20)}),h.setParent(a);const p=new ga({color:4777983,transparent:!0,opacity:.52,fog:!1,depthTest:!1}),y=new ba(this,{data:e,geoProjectionCenter:this.tradeGeoProjectionCenter,geoProjectionScale:this.tradeGeoProjectionScale,material:p,renderOrder:21});return y.lineGroup.position.z+=this.tradeNationalDepth+.055,y.setParent(a),this.scene.add(a),this.tradeNationalMapGroup=a,this.createTradeNationalLabels(t),!0}createTradeNationalMaterials(){const e=new xn({color:16777215,transparent:!0,opacity:.54,roughness:.84,metalness:.08,side:Ee,fog:!1});new Rn(e,{uColor1:827317,uColor2:403515,size:6.8,dir:"x"});const t=this.assets.instance.getResource("side").clone();t.wrapS=ct,t.wrapT=ct,t.repeat.set(1,1.2),t.needsUpdate=!0;const a=new xn({color:1485501,map:t,transparent:!0,opacity:.58,roughness:.78,metalness:.04,side:Ee,fog:!1});return new Rn(a,{uColor1:1354174,uColor2:134940,size:Math.max(this.tradeNationalDepth,.1),dir:"y"}),this.time.on("tick",()=>{t.offset.y+=.004}),{topMaterial:e,sideMaterial:a}}createTradeNationalLabels(e){this.tradeNationalLabelGroup=new Ce,this.tradeNationalLabelGroup.name="trade-national-label",this.tradeNationalLabelGroup.rotation.x=-Math.PI/2,this.tradeNationalLabelGroup.visible=!1,this.scene.add(this.tradeNationalLabelGroup),this.tradeNationalLabels=[],this.tradeProvinceCenterByName=new Map;const t=new Set(["四川","青海","甘肃","陕西","重庆","云南","西藏","新疆"]);(e.features||[]).forEach(a=>{var h;const i=((h=a.properties)==null?void 0:h.name)||"",o=this.normalizeTradeProvinceName(i),l=this.getFeatureCenterLngLat(a);if(!l||(this.tradeProvinceCenterByName.set(o,l),!t.has(o)))return;const u=this.label3d.create("","trade-national-label",!0);u.init(`<div class="trade-national-name">${Pe(o)}</div>`,this.getTradeLocalPoint(l.lng,l.lat,.82)),this.label3d.setLabelStyle(u,.012,"x"),u.setParent(this.tradeNationalLabelGroup),u.visible=!0,this.tradeNationalLabels.push(u)})}normalizeTradeProvinceName(e=""){return String(e).replace(/省|市|自治区|壮族|回族|维吾尔|特别行政区/g,"").replace(/区$/,"").trim()}getFeatureCenterLngLat(e){var o,l,u;const t=((o=e==null?void 0:e.properties)==null?void 0:o.cp)||((l=e==null?void 0:e.properties)==null?void 0:l.centroid)||((u=e==null?void 0:e.properties)==null?void 0:u.center);if(Array.isArray(t)&&Number.isFinite(Number(t[0]))&&Number.isFinite(Number(t[1])))return{lng:Number(t[0]),lat:Number(t[1])};const a=this.getGeometryCoordinateList(e==null?void 0:e.geometry);if(!a.length)return null;const i=a.reduce((h,p)=>({minLng:Math.min(h.minLng,Number(p[0])),maxLng:Math.max(h.maxLng,Number(p[0])),minLat:Math.min(h.minLat,Number(p[1])),maxLat:Math.max(h.maxLat,Number(p[1]))}),{minLng:1/0,maxLng:-1/0,minLat:1/0,maxLat:-1/0});return{lng:(i.minLng+i.maxLng)/2,lat:(i.minLat+i.maxLat)/2}}isHomeTopicPresentation(){return this.topicLayerPresentation==="home"}createProvince(){let e=this.staticMapData.mapJson;this.mapJsonData=e;const t=this.useSatelliteBase?$s({geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,zoom:this.satelliteTextureZoom,tileUrlTemplate:this.tileUrlTemplate,onTileStatus:g=>{var w,C;return(C=(w=this.callbacks).onTileStatus)==null?void 0:C.call(w,g)}}):null;t!=null&&t.texture&&this.enhanceTexture(t.texture);let[a,i]=this.createProvinceMaterial();this.focusMapTopMaterial=a,this.focusMapSideMaterial=i;let o=new Fs(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,position:new le(0,0,.11),data:e,depth:this.depth,topFaceMaterial:a,sideMaterial:i,renderOrder:9}),l=new xn({color:this.useSatelliteBase?16777215:13172735,map:(t==null?void 0:t.texture)||null,transparent:!0,opacity:this.useSatelliteBase?this.usesCustomSatelliteTiles?1:.94:this.isHomeTopicPresentation()?.58:.88,roughness:this.useSatelliteBase?this.usesCustomSatelliteTiles?.7:.82:.66,metalness:this.useSatelliteBase?0:.08});this.usesCustomSatelliteTiles||new Rn(l,{uColor1:this.useSatelliteBase?1629410:this.isHomeTopicPresentation()?683906:1227744,uColor2:this.useSatelliteBase?757673:this.isHomeTopicPresentation()?406090:38069,size:this.useSatelliteBase?15:8.6}),this.defaultMaterial=l,this.defaultLightMaterial=this.defaultMaterial.clone(),this.defaultLightMaterial.color=new Tt("rgba(128,244,255,1)"),this.defaultLightMaterial.opacity=.9;let u=new Oa(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,position:new le(0,0,this.depth+.22),data:e,material:l,renderOrder:this.usesCustomSatelliteTiles?14:8});this.satelliteMapTop=u,this.satelliteMaterial=l,t!=null&&t.uvBounds&&Es(u,t.uvBounds),u.mapGroup.children.map(g=>{g.children.map(w=>{w.type==="Mesh"&&this.eventElement.push(w)})}),this.mapLineMaterial=new ga({color:12254463,opacity:0,transparent:!0,linewidth:this.adminBoundaryLineScale,fog:!1});let h=new ba(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,data:e,material:this.mapLineMaterial,renderOrder:this.isHomeTopicPresentation()?34:26});h.lineGroup.position.z+=this.depth+(this.isHomeTopicPresentation()?.315:.285);let p=null;const y=this.getAdminBoundaryEmphasisRadius();return y>0&&(this.mapBoundaryEmphasisMaterial=new ke({color:9632767,transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1,blending:Ve}),p=new ba(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,data:e,material:this.mapBoundaryEmphasisMaterial,renderOrder:this.usesCustomSatelliteTiles?24:18,type:"Line3",tubeRadius:y}),p.lineGroup.position.z+=this.depth+.255),{map:o,mapTop:u,mapLine:h,mapBoundaryEmphasis:p}}normalizeAdminBoundaryLineScale(e){const t=Number(e);return Number.isFinite(t)?Math.min(4,Math.max(1,t)):1}getAdminBoundaryEmphasisRadius(){return this.adminBoundaryLineScale<=1?0:Math.min(.04,.011*this.adminBoundaryLineScale)}getAdminBoundaryEmphasisOpacity(){return this.adminBoundaryLineScale<=1?0:Math.min(.5,.2+this.adminBoundaryLineScale*.08)}createTopicLayer(){if(!this.mapJsonData)return;this.initHongyuanBoundaryPolygons();const e=document.createElement("canvas");e.width=St.width,e.height=St.height;const t=e.getContext("2d");t.clearRect(0,0,e.width,e.height);const a=new jr(e);a.colorSpace=Ta,a.wrapS=zn,a.wrapT=zn,a.minFilter=ja,a.magFilter=ja,this.enhanceTexture(a),a.needsUpdate=!0;const i=new ke({map:a,transparent:!0,opacity:0,depthWrite:!1,depthTest:!this.isHomeTopicPresentation(),side:Ee,fog:!1}),o=this.createLayerUvBounds(),l=new Oa(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,position:new le(0,0,this.depth+(this.isHomeTopicPresentation()?.272:.255)),data:this.mapJsonData,material:i,renderOrder:this.isHomeTopicPresentation()?24:18});Es(l,o),l.setParent(this.focusMapGroup),this.topicLayerUvBounds=o,this.topicLayerCanvas=e,this.topicLayerContext=t,this.topicLayerTexture=a,this.topicLayerMaterial=i,this.topicLayerMap=l}initHongyuanBoundaryPolygons(){var t,a,i;if((t=this.hongyuanBoundaryPolygons)!=null&&t.length)return;const e=this.staticMapData.mapStroke;this.hongyuanBoundaryPolygons=Js((i=(a=e==null?void 0:e.features)==null?void 0:a[0])==null?void 0:i.geometry)}createSelectedFeatureGroup(){var e;this.selectedFeatureGroup||(this.selectedFeatureGroup=new Ce,this.selectedFeatureGroup.name="selected-feature-highlight",this.selectedFeatureGroup.position.z=this.depth+.31,(e=this.focusMapGroup)==null||e.add(this.selectedFeatureGroup))}createLayerUvBounds(){const e=sa().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0]),[t]=e([q.west,q.south]),[a]=e([q.east,q.south]),[,i]=e([q.west,q.north]),[,o]=e([q.west,q.south]);return{left:t,right:a,bottom:-o,top:-i}}setTopicLayer(e){var a,i;if(!e||!this.topicLayerContext||!this.topicLayerTexture)return;this.currentTopicLayer=e,this.visibleTopicLayers=[e],this.clearSelectedFeature(),this.applyLayerMapView(e);const t=++this.topicLayerLoadId;if(this.currentVectorFeatures=[],this.clearYakIndustryPointMarkers(),this.clearYakIndustryPointLabels(),this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(i=(a=this.callbacks).onLayerStatus)==null||i.call(a,{type:"loading",text:`正在加载 ${e.name}`}),An(e)){this.loadVectorTopicLayer(e,t);return}this.loadTopicLayerImage(e).then(o=>{var l,u,h,p;if(t===this.topicLayerLoadId){if(!(o!=null&&o.image)){this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(u=(l=this.callbacks).onLayerStatus)==null||u.call(l,{type:"error",text:"GeoServer 图层加载失败"});return}this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.drawTopicRasterImage(o.image,o.layer||e),this.topicLayerTexture.needsUpdate=!0,this.updateTopicLayerTextureSampling(e),this.topicLayerMaterial.opacity=this.getTopicLayerMaterialOpacity(e,.84),(p=(h=this.callbacks).onLayerStatus)==null||p.call(h,{type:"success",text:"GeoServer 图层已加载"})}}).catch(()=>{var o,l;t===this.topicLayerLoadId&&(this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(l=(o=this.callbacks).onLayerStatus)==null||l.call(o,{type:"error",text:"GeoServer 图层加载失败"}))})}setTopicLayers(e=[],t=e[0]){var o,l,u,h;if(!this.topicLayerContext||!this.topicLayerTexture)return;const a=e.filter(Boolean);if(!a.length){this.topicLayerLoadId+=1,this.visibleTopicLayers=[],this.currentTopicLayer=null,this.currentVectorFeatures=[],this.clearYakIndustryPointMarkers(),this.clearYakIndustryPointLabels(),this.clearSelectedFeature(),this.applyLayerMapView(null),this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(l=(o=this.callbacks).onLayerStatus)==null||l.call(o,{type:"success",text:"图层已关闭"});return}if(a.length===1){this.setTopicLayer(I(I({},a[0]),(t==null?void 0:t.key)===a[0].key?t:{}));return}this.currentTopicLayer=t||a[a.length-1],this.visibleTopicLayers=a,this.clearSelectedFeature(),this.clearYakIndustryPointMarkers(),this.clearYakIndustryPointLabels(),this.applyLayerMapView(this.currentTopicLayer);const i=++this.topicLayerLoadId;this.currentVectorFeatures=[],this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(h=(u=this.callbacks).onLayerStatus)==null||h.call(u,{type:"loading",text:`正在加载 ${a.length} 个地图图层`}),Promise.all(a.map(p=>this.loadCompositeTopicLayerItem(p))).then(p=>{var w,C,F;if(i!==this.topicLayerLoadId)return;const y=p.filter(Boolean),g=y.find(x=>{var G,H;return x.type==="vector"&&((G=x.layer)==null?void 0:G.key)===((H=this.currentTopicLayer)==null?void 0:H.key)});this.currentVectorFeatures=((w=g==null?void 0:g.geojson)==null?void 0:w.features)||[],this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),y.forEach((x,G)=>{var H,J;if(x.type==="image"){this.topicLayerContext.save();const ne=G===y.length-1?Math.max(.78,(H=x.layer.opacity)!=null?H:.9):Math.min(.52,(J=x.layer.opacity)!=null?J:.52);this.topicLayerContext.globalAlpha=Math.min(1,Math.max(.28,ne)),this.drawTopicRasterImage(x.image,x.layer),this.topicLayerContext.restore();return}this.drawVectorTopicLayer(x.layer,x.geojson.features||[],{clear:!1})}),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.updateYakIndustryPointLabels(this.currentTopicLayer,this.currentVectorFeatures),this.topicLayerTexture.needsUpdate=!0,this.updateTopicLayerTextureSampling(this.currentTopicLayer),this.topicLayerMaterial.opacity=y.length?this.getTopicLayerMaterialOpacity(this.currentTopicLayer,1):0,(F=(C=this.callbacks).onLayerStatus)==null||F.call(C,{type:y.length?"success":"error",text:y.length?`已加载 ${y.length} 个地图图层`:"地图图层加载失败"})})}loadCompositeTopicLayerItem(e){return oe(this,null,function*(){if(An(e))try{const t=yield this.fetchVectorLayerGeojson(e);return{type:"vector",layer:e,geojson:t}}catch(t){return null}return this.loadTopicLayerImage(e).then(t=>t?I({type:"image"},t):null)})}loadTopicLayerImage(e){return Ks(e)?this.loadWmtsTopicLayerImage(e):new Promise(t=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>t({image:a,layer:e}),a.onerror=()=>t(null),a.src=ed(e)})}loadWmtsTopicLayerImage(e){return oe(this,null,function*(){const t=document.createElement("canvas");t.width=St.width,t.height=St.height;const a=t.getContext("2d");if(!a)return null;a.clearRect(0,0,t.width,t.height);const i=this.getWmtsTopicZoom(e),o=Array.isArray(e==null?void 0:e.bounds)&&e.bounds.length>=4?e.bounds.map(Number):null,l=o!=null&&o.every(Number.isFinite)?{west:o[0],south:o[1],east:o[2],north:o[3]}:q,u=yd(l,i),h=[];for(let w=u.minX;w<=u.maxX;w+=1)for(let C=u.minY;C<=u.maxY;C+=1)h.push({x:w,y:C});let p=0,y=0;const g=()=>oe(this,null,function*(){for(;y<h.length;){const w=h[y];y+=1;const C=yield bd(td(e,{x:w.x,y:w.y,z:i}));if(!C)continue;const F=vd(w.x,w.y,i,t);a.drawImage(C,F.x,F.y,F.width,F.height),p+=1}});return yield Promise.all(Array.from({length:Math.min(ud,h.length)},g)),p?(this.enhanceWmtsTopicCanvas(t,e),{image:t,layer:e,loaded:p}):null})}enhanceWmtsTopicCanvas(e,t={}){var h,p;if(t.homeWmtsEnhance===!1)return;const a=e.getContext("2d");if(!a)return;const i=document.createElement("canvas");i.width=e.width,i.height=e.height;const o=i.getContext("2d");if(!o)return;o.drawImage(e,0,0);const l=na((h=t.homeWmtsPointSpread)!=null?h:0,0,4),u=na((p=t.homeWmtsGlowRadius)!=null?p:0,0,6);if(a.clearRect(0,0,e.width,e.height),u>0&&(a.save(),a.globalAlpha=.58,a.filter=`blur(${u}px)`,a.drawImage(i,0,0),a.restore()),l>0){const y=[[-l,0],[l,0],[0,-l],[0,l],[-l,-l],[l,-l],[-l,l],[l,l]];a.save(),a.globalAlpha=.72,y.forEach(([g,w])=>a.drawImage(i,g,w)),a.restore()}a.drawImage(i,0,0)}getWmtsTopicZoom(e={}){var l,u,h;const t=Math.round(Number(e.maximumLevel)),a=Number.isFinite(t)&&t>0?t:21,i=Number((h=(u=(l=e.homeWmtsZoom)!=null?l:e.wmtsZoom)!=null?u:e.tileZoom)!=null?h:this.satelliteTextureZoom),o=Number.isFinite(i)&&i>0?Math.round(i):11;return na(o,3,Math.min(a,Gn))}updateTopicLayerTextureSampling(e={}){if(!this.topicLayerTexture)return;const t=Ks(e)?Ss:ja;this.topicLayerTexture.minFilter=t,this.topicLayerTexture.magFilter=t,this.topicLayerTexture.needsUpdate=!0}drawTopicRasterImage(e,t={}){const a=this.topicLayerCanvas,i=this.topicLayerContext;if(!a||!i)return;if(!t.softMask){this.drawHomeTopicRasterGlow(e,t),i.drawImage(e,0,0,a.width,a.height);return}const o=Math.min(1,Math.max(.08,Number(t.softMaskScale)||.18)),l=document.createElement("canvas");l.width=Math.max(96,Math.round(a.width*o)),l.height=Math.max(96,Math.round(a.height*o));const u=l.getContext("2d");if(!u){i.drawImage(e,0,0,a.width,a.height);return}u.clearRect(0,0,l.width,l.height),u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(e,0,0,l.width,l.height),i.save(),i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high",i.drawImage(l,0,0,a.width,a.height),i.restore()}drawHomeTopicRasterGlow(e,t={}){var h,p;if(!this.isHomeTopicPresentation())return;const a=this.topicLayerCanvas,i=this.topicLayerContext;if(!a||!i)return;const o=na((h=t.homeGlowOpacity)!=null?h:0,0,.8),l=na((p=t.homeGlowBlur)!=null?p:0,0,32);if(!o||!l)return;const u=t.homeGlowColor||"#E5FCFF";i.save(),i.globalAlpha=o,i.filter=`drop-shadow(0 0 ${l}px ${u})`,i.drawImage(e,0,0,a.width,a.height),i.restore()}applyLayerMapView(e,t={}){var h,p;if(!((h=this.camera)!=null&&h.instance)||!((p=this.camera)!=null&&p.controls)||!this.mapAnimationComplete&&!t.force)return;const a=e?null:this.currentTownRanking,i=(e==null?void 0:e.mapView)||(e!=null&&e.cameraPosition?{cameraPosition:e.cameraPosition}:null)||(a==null?void 0:a.mapView)||(a!=null&&a.cameraPosition?{cameraPosition:a.cameraPosition}:null),o=i?this.getLayerMapViewTarget(i):this.defaultMapTarget.clone(),l=i?this.getLayerMapViewCameraPosition(i,o):this.defaultMapCameraPosition.clone(),u=i&&Number.isFinite(i.duration)?i.duration:.75;this.animateMapCamera(l,o,u)}getFocusMapTopOpacity(){return this.useSatelliteBase?this.usesCustomSatelliteTiles?.16:1:.78}getTopicLayerMaterialOpacity(e,t=.84){const a=Number(e==null?void 0:e.opacity),i=Number.isFinite(a)?a:t;if(!this.isHomeTopicPresentation())return i;const o=Number(e==null?void 0:e.homePresentationMaxOpacity),l=Number.isFinite(o)?o:.56;return na(i,0,l)}getDynamicSatelliteZoom(e){return this.usesCustomSatelliteTiles?e<=4.2?Math.min(this.dynamicSatelliteMaxZoom,21):e<=6.4?Math.min(this.dynamicSatelliteMaxZoom,19):e<=8.4?Math.min(this.dynamicSatelliteMaxZoom,17):e<=11?Math.min(this.dynamicSatelliteMaxZoom,15):e<=14.5?Math.min(this.dynamicSatelliteMaxZoom,13):e<=18?Math.min(this.dynamicSatelliteMaxZoom,11):this.satelliteTextureZoom:this.satelliteTextureZoom}getCameraTargetLngLat(){var o,l,u,h,p,y,g;const e=(h=(u=(l=(o=this.camera)==null?void 0:o.controls)==null?void 0:l.target)==null?void 0:u.clone)==null?void 0:h.call(u);if(!e)return[102.58,32.72];(y=(p=this.focusMapGroup)==null?void 0:p.updateWorldMatrix)==null||y.call(p,!0,!1);const t=this.focusMapGroup?this.focusMapGroup.worldToLocal(e):e,a=sa().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0]),i=((g=a.invert)==null?void 0:g.call(a,[t.x,-t.y]))||[102.58,32.72];return[Math.max(q.west,Math.min(q.east,Number(i[0])||102.58)),Math.max(q.south,Math.min(q.north,Number(i[1])||32.72))]}getDynamicSatelliteTileWindow(e){return e>=21?3:e>=19?5:e>=17?7:e>=15?this.dynamicSatelliteTileWindow:e>=13?Math.min(11,this.dynamicSatelliteTileWindow+2):Math.min(11,this.dynamicSatelliteTileWindow+2)}getDynamicSatelliteKey(e,t){return t?`${e}:${t.minX}-${t.maxX}:${t.minY}-${t.maxY}`:""}updateDynamicSatelliteTiles(e=!1){if(!this.usesCustomSatelliteTiles||!this.mapAnimationComplete)return;const t=Date.now();if(!e&&t-this.dynamicSatelliteLastCheck<ld)return;this.dynamicSatelliteLastCheck=t;const a=this.camera.instance.position.distanceTo(this.camera.controls.target),i=this.getDynamicSatelliteZoom(a);if(i<=this.satelliteTextureZoom){this.hideDynamicSatelliteOverlay();return}const o=this.getCameraTargetLngLat(),l=this.getDynamicSatelliteTileWindow(i),u=Yc({zoom:i,centerLngLat:o,maxCols:l,maxRows:l}),h=this.getDynamicSatelliteKey(i,u);!h||h===this.dynamicSatelliteCurrentKey||h===this.dynamicSatelliteLoadingKey||this.loadDynamicSatelliteOverlay({zoom:i,centerLngLat:o,maxTiles:l,key:h})}loadDynamicSatelliteOverlay({zoom:e,centerLngLat:t,maxTiles:a,key:i}){const o=++this.dynamicSatelliteRequestId;this.dynamicSatelliteLoadingKey=i;let l;l=$s({geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,zoom:e,centerLngLat:t,maxCols:a,maxRows:a,tileUrlTemplate:this.tileUrlTemplate,transparentBackground:!0,applyTone:!1,onTileStatus:u=>{var h,p,y,g,w;if((y=(p=this.callbacks).onTileStatus)==null||y.call(p,E(I({},u),{text:((h=u.text)==null?void 0:h.replace("影像底图","高清影像底图"))||u.text})),u.type!=="loading"){if(o!==this.dynamicSatelliteRequestId){(w=(g=l==null?void 0:l.texture)==null?void 0:g.dispose)==null||w.call(g);return}if(this.dynamicSatelliteLoadingKey="",Number(u.loaded||0)<=0){this.dynamicSatelliteCurrentKey===i&&this.hideDynamicSatelliteOverlay();return}this.applyDynamicSatelliteOverlay(l,i)}}}),this.applyDynamicSatelliteOverlay(l,i)}ensureDynamicSatelliteOverlay(){var a;if(this.dynamicSatelliteOverlay)return;const e=new ke({transparent:!0,opacity:0,depthWrite:!1,depthTest:!0,side:Ee,fog:!1}),t=new Qe(new Ht(1,1),e);t.name="dynamic-satellite-overlay",t.renderOrder=15,t.visible=!1,t.position.z=this.depth+.248,(a=this.focusMapGroup)==null||a.add(t),this.dynamicSatelliteOverlay=t,this.dynamicSatelliteMaterial=e}applyDynamicSatelliteOverlay(e,t){var l,u;if(!(e!=null&&e.texture)||!(e!=null&&e.uvBounds))return;this.ensureDynamicSatelliteOverlay();const a=e.uvBounds,i=Math.max(1e-4,a.right-a.left),o=Math.max(1e-4,a.top-a.bottom);this.dynamicSatelliteOverlay.position.set((a.left+a.right)/2,(a.bottom+a.top)/2,this.depth+.248),this.dynamicSatelliteOverlay.scale.set(i,o,1),this.dynamicSatelliteOverlay.visible=!0,this.dynamicSatelliteTexture&&this.dynamicSatelliteTexture!==e.texture&&((u=(l=this.dynamicSatelliteTexture).dispose)==null||u.call(l)),this.dynamicSatelliteTexture=e.texture,this.dynamicSatelliteMaterial.map=e.texture,this.dynamicSatelliteMaterial.opacity=1,this.dynamicSatelliteMaterial.needsUpdate=!0,this.dynamicSatelliteCurrentKey=t}hideDynamicSatelliteOverlay(){this.dynamicSatelliteOverlay&&(this.dynamicSatelliteOverlay.visible=!1),this.dynamicSatelliteLoadingKey&&(this.dynamicSatelliteRequestId+=1,this.dynamicSatelliteLoadingKey=""),this.dynamicSatelliteCurrentKey=""}ensureMapRevealed(){var e,t,a,i,o;if(!this.mapAnimationComplete){if((t=(e=this.animateTl)==null?void 0:e.progress)==null||t.call(e,1,!1),(i=(a=this.animateTl)==null?void 0:a.pause)==null||i.call(a),this.mapAnimationComplete=!0,this.focusMapGroup&&(this.focusMapGroup.position.set(0,0,0),this.focusMapGroup.scale.set(1,1,1)),this.focusMapTopMaterial&&(this.focusMapTopMaterial.opacity=this.getFocusMapTopOpacity()),this.focusMapSideMaterial&&(this.focusMapSideMaterial.opacity=1,this.focusMapSideMaterial.transparent=!1),this.mapGroup&&(this.mapGroup.visible=!0),this.labelGroup&&(this.labelGroup.visible=!0),this.flyLineGroup&&(this.flyLineGroup.visible=!0),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=!0),this.scatterGroup&&(this.scatterGroup.visible=!0),this.InfoPointGroup&&(this.InfoPointGroup.visible=this.showTownRankingPointMarkers&&this.hasTownRankingRows()),this.applyLayerMapView(this.currentTopicLayer,{force:!0}),this.updateDynamicSatelliteTiles(!0),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.updateYakIndustryPointLabels(this.currentTopicLayer,this.currentVectorFeatures),Wa(this.currentTownRanking)){this.hideAllMapStatisticLabels();return}this.updateVillageRankingLabels(this.currentTownRanking),this.setTradeNationalMapVisible(!!((o=this.currentTownRanking)!=null&&o.nationalFlow)),this.updateTradeFlowLayer(this.currentTownRanking),this.updateInfoPointStats()}}getLayerMapViewTarget(e){var t;return e!=null&&e.targetLngLat?this.lngLatToWorldPoint(e.targetLngLat,(t=e.targetLocalZ)!=null?t:.72):e!=null&&e.target?this.toVector3(e.target,this.defaultMapTarget):this.defaultMapTarget.clone()}getLayerMapViewCameraPosition(e,t){if(e!=null&&e.cameraPosition)return this.toVector3(e.cameraPosition,this.defaultMapCameraPosition);const a=Number.isFinite(e==null?void 0:e.distanceScale)?e.distanceScale:1,i=this.defaultMapCameraPosition.clone().sub(this.defaultMapTarget).multiplyScalar(a),o=t.clone().add(i);return e!=null&&e.cameraOffset&&o.add(this.toVector3(e.cameraOffset,new le(0,0,0))),o}lngLatToWorldPoint(e,t=0){const a=Array.isArray(e)?e:[e==null?void 0:e.lng,e==null?void 0:e.lat],i=Number(a==null?void 0:a[0]),o=Number(a==null?void 0:a[1]);if(!Number.isFinite(i)||!Number.isFinite(o))return this.defaultMapTarget.clone();const[l,u]=this.geoProjection([i,o]),h=new le(l,-u,Number(t)||0);return this.focusMapGroup?this.focusMapGroup.localToWorld(h):h}toVector3(e,t){if(Array.isArray(e)){const[l,u,h]=e.map(Number);return[l,u,h].every(Number.isFinite)?new le(l,u,h):t.clone()}const a=Number(e==null?void 0:e.x),i=Number(e==null?void 0:e.y),o=Number(e==null?void 0:e.z);return[a,i,o].every(Number.isFinite)?new le(a,i,o):t.clone()}animateMapCamera(e,t,a=.75){this.activeMapViewTweens.forEach(l=>{var u;return(u=l==null?void 0:l.kill)==null?void 0:u.call(l)}),this.activeMapViewTweens=[];const i=this.camera.controls,o=()=>i.update();this.activeMapViewTweens.push(wa.to(this.camera.instance.position,{duration:a,x:e.x,y:e.y,z:e.z,ease:"power2.out",onUpdate:o}),wa.to(i.target,{duration:a,x:t.x,y:t.y,z:t.z,ease:"power2.out",onUpdate:o}))}addSceneTween(e){var t;return e&&(this.sceneTweens.push(e),this.scenePaused&&((t=e.pause)==null||t.call(e)),e)}addSceneTimer(e){return e&&this.sceneTimers.push(e),e}focusTownByName(e,t={}){var u,h,p;const a=this.townMetaByName.get(dt(e)),i=t.select?this.selectTownFeatureByName(e,t):!1;if(t.preserveCamera)return i||!!(a!=null&&a.center);if(!(a!=null&&a.center))return i;const o=this.lngLatToWorldPoint(a.center,(u=t.targetLocalZ)!=null?u:.82),l=this.getLayerMapViewCameraPosition({distanceScale:(h=t.distanceScale)!=null?h:.82,cameraOffset:t.cameraOffset||{x:0,y:1.2,z:0}},o);return this.animateMapCamera(l,o,(p=t.duration)!=null?p:.75),!0}isNationalParkTownSelectionActive(){var e;return((e=this.currentTopicLayer)==null?void 0:e.key)==="national-park-zoning"&&this.getTownRankingMeta().onlyRankedTownLabels}getTownNameFromMapEvent(e){var a,i,o,l,u,h,p,y,g,w;return[(o=(i=(a=e==null?void 0:e.target)==null?void 0:a.parent)==null?void 0:i.userData)==null?void 0:o.name,(u=(l=e==null?void 0:e.target)==null?void 0:l.userData)==null?void 0:u.name,(y=(p=(h=e==null?void 0:e.target)==null?void 0:h.parent)==null?void 0:p.userData)==null?void 0:y.townName,(w=(g=e==null?void 0:e.target)==null?void 0:g.userData)==null?void 0:w.townName].find(C=>String(C||"").trim())||""}findTownFeatureByName(e){var i,o,l,u;const t=dt(e);if(!t)return null;const a=(((i=this.mapJsonData)==null?void 0:i.features)||((l=(o=this.staticMapData)==null?void 0:o.mapJson)==null?void 0:l.features)||[]).find(h=>{const p=(h==null?void 0:h.properties)||{};return[p.name,p.fullName,p.full_name,p.townName].some(g=>dt(g)===t)});return a!=null&&a.geometry?{type:"Feature",properties:E(I({},a.properties||{}),{name:((u=a.properties)==null?void 0:u.name)||e,feature_role:"乡镇范围"}),geometry:a.geometry}:null}selectTownFeatureByName(e,t={}){var i,o,l,u,h;const a=this.findTownFeatureByName(e);return a?(this.showSelectedFeature(a,{mode:"town"}),t.silentStatus!==!0&&((h=(u=this.callbacks).onLayerStatus)==null||h.call(u,{type:"success",text:t.statusText||`已选中${((l=a.properties)==null?void 0:l.name)||e}`})),!0):(t.showMissingStatus!==!1&&((o=(i=this.callbacks).onLayerStatus)==null||o.call(i,{type:"warning",text:"未找到对应乡镇边界"})),!1)}handleTownRankingSelect(e,t={}){var u,h;if(!this.isNationalParkTownSelectionActive())return!1;const a=dt(e);if(!a||!this.getTownRankingRows(this.currentTownRanking,Number.POSITIVE_INFINITY,!1).some(p=>dt(p.name)===a))return!1;const l=this.focusTownByName(e,I({select:!0,preserveCamera:!0,statusText:`已选中${e}`},t));return l&&((h=(u=this.callbacks).onFeatureInfo)==null||h.call(u,{feature:null})),l}focusYakIndustryPoint(e={}){var o,l;const t=this.getYakIndustryPayloadCoordinate(e);if(!t)return(l=(o=this.callbacks).onLayerStatus)==null||l.call(o,{type:"warning",text:"当前主体暂无可定位坐标"}),{focused:!1,screen:null};const a=this.findYakIndustryPointFeature(e,t);return a?this.setSelectedVectorFeatures([a]):this.clearSelectedFeature(),{focused:this.flyToLngLat(t,{span:.035,duration:.72,statusText:"已定位产业主体"}),screen:this.getYakIndustryPointScreen(e),feature:a}}focusVectorFeature(e={}){var p,y;const t=this.getVisibleVectorFeatures(this.currentTopicLayer,this.currentVectorFeatures||[]),a=String(e.id||e.key||""),i=String(e.fullName||e.name||"").trim(),o=t.find(g=>{const w=(g==null?void 0:g.properties)||{};return a&&String(w.id||"")===a||i&&String(w.name||w.plot_name||"").trim()===i});if(!o)return(y=(p=this.callbacks).onLayerStatus)==null||y.call(p,{type:"warning",text:"当前图斑尚未加载"}),{focused:!1,screen:null,feature:null};this.setSelectedVectorFeatures([o]);const l=this.getGeometryLngLatBounds(o.geometry);if(!l)return{focused:!1,screen:null,feature:o};const u=[(l.minLng+l.maxLng)/2,(l.minLat+l.maxLat)/2];return{focused:this.flyToLngLat(u,{span:Math.max(l.maxLng-l.minLng,l.maxLat-l.minLat),duration:.75,statusText:"已定位种草图斑"}),screen:this.getVectorFeatureScreen(o),feature:o}}getVectorFeatureScreen(e={}){let t=(e==null?void 0:e.feature)||e;if(!(t!=null&&t.geometry)){const o=this.getVisibleVectorFeatures(this.currentTopicLayer,this.currentVectorFeatures||[]),l=String((e==null?void 0:e.id)||(e==null?void 0:e.key)||"");t=o.find(u=>{var h;return String(((h=u==null?void 0:u.properties)==null?void 0:h.id)||"")===l})||null}const a=this.getGeometryLngLatBounds(t==null?void 0:t.geometry);if(!a)return null;const i=[(a.minLng+a.maxLng)/2,(a.minLat+a.maxLat)/2];return this.lngLatToLayerScreenPoint(i,this.depth+.34)||this.lngLatToScreenPoint(i,this.depth+.32)}getYakIndustryPointScreen(e={}){const t=this.getYakIndustryPayloadCoordinate(e);return t?this.lngLatToLayerScreenPoint(t,this.depth+.36)||this.lngLatToScreenPoint(t,this.depth+.32):null}getYakIndustryPayloadCoordinate(e={}){var o,l,u,h,p;const t=((o=e.geometry)==null?void 0:o.coordinates)||e.coordinates,a=Number((u=(l=e.longitude)!=null?l:e.lng)!=null?u:t==null?void 0:t[0]),i=Number((p=(h=e.latitude)!=null?h:e.lat)!=null?p:t==null?void 0:t[1]);return!Number.isFinite(a)||!Number.isFinite(i)?null:[a,i]}findYakIndustryPointFeature(e={},t=this.getYakIndustryPayloadCoordinate(e)){const a=this.getVisibleVectorFeatures(this.currentTopicLayer,this.currentVectorFeatures||[]),i=String(e.id||e.key||""),o=String(e.fullName||e.name||"").trim(),l=String(e.stageKey||""),u=t&&a.find(p=>{var g;if(((g=p==null?void 0:p.geometry)==null?void 0:g.type)!=="Point")return!1;const y=p.properties||{};return l&&String(y.stageKey||"")!==l?!1:this.getCoordinateDistance(p.geometry.coordinates,t)<=8e-4})||null;if(e.preferCoordinateMatch)return u;const h=a.find(p=>{const y=(p==null?void 0:p.properties)||{};return!!(i&&String(y.id||"")===i||o&&String(y.name||y.fullName||"").trim()===o)});return h||u}loadVectorTopicLayer(e,t){return oe(this,null,function*(){var a,i,o,l;try{const u=yield this.fetchVectorLayerGeojson(e);if(t!==this.topicLayerLoadId)return;this.currentVectorFeatures=u.features||[],this.drawVectorTopicLayer(e,this.currentVectorFeatures),this.updateYakIndustryPointMarkers(e,this.currentVectorFeatures),this.updateYakIndustryPointLabels(e,this.currentVectorFeatures),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=this.getTopicLayerMaterialOpacity(e,.9),(i=(a=this.callbacks).onLayerStatus)==null||i.call(a,{type:"success",text:"真实矢量图层已加载"})}catch(u){if(t!==this.topicLayerLoadId)return;this.currentVectorFeatures=[],this.clearYakIndustryPointMarkers(),this.clearYakIndustryPointLabels(),this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(l=(o=this.callbacks).onLayerStatus)==null||l.call(o,{type:"error",text:"真实矢量图层加载失败"})}})}fetchVectorLayerGeojson(e){return oe(this,null,function*(){var o,l;if(e.sourceType==="geojson"){if(((o=e.geojsonData)==null?void 0:o.type)==="FeatureCollection")return e.geojsonData;const u=yield fetch(Qs(e.dataPath),{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}`);return yield u.json()}if(e.sourceType==="wfs"){const u=yield Ds(e.layerName,{cqlFilter:e.cqlFilter,maxFeatures:e.maxFeatures||1200,timeout:e.timeout||18e3});return(u==null?void 0:u.type)==="FeatureCollection"?u:{type:"FeatureCollection",features:(u==null?void 0:u.features)||[]}}let t=[],a=null;try{const u=yield fetch(e.apiUrl,{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}`);const h=yield u.json();t=Array.isArray(h==null?void 0:h.data)?h.data:Array.isArray((l=h==null?void 0:h.data)==null?void 0:l.rows)?h.data.rows:[]}catch(u){a=u}let i=this.buildWktLayerFeatures(t);if((!t.length||!i.length)&&e.fallbackPath){const u=yield fetch(Qs(e.fallbackPath),{credentials:"include"});if(!u.ok)throw a||new Error(`HTTP ${u.status}`);const h=yield u.json();t=Array.isArray(h==null?void 0:h.rows)?h.rows:[],i=this.buildWktLayerFeatures(t)}return{type:"FeatureCollection",features:i}})}buildWktLayerFeatures(e=[]){return(e||[]).map(t=>({type:"Feature",properties:{id:t.id,type:t.type,totalAcreage:t.totalAcreage,cdAcreage:t.cdAcreage,sdAcreage:t.sdAcreage,cdScl:t.cdScl,sdScl:t.sdScl},geometry:this.parseWktGeometry(this.pickWktValue(t))})).filter(t=>t.geometry)}pickWktValue(e={}){return e.wkt||e.WKT||e.geom||e.geometry||e.the_geom||e.theGeom||e.shape||e.Shape}drawVectorTopicLayer(e,t,a={}){const i=this.topicLayerContext;a.clear!==!1&&i.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),i.save(),i.lineJoin="round",i.lineCap="round",this.clipVectorLayerContext(i,e);const l=this.getVisibleVectorFeatures(e,t).filter(u=>{var h;return!(e!=null&&e.hidePointFeatures)||((h=u==null?void 0:u.geometry)==null?void 0:h.type)!=="Point"}).sort((u,h)=>{var g,w;const p=this.getGeometryDrawRank((g=u.geometry)==null?void 0:g.type),y=this.getGeometryDrawRank((w=h.geometry)==null?void 0:w.type);return p-y});l.forEach(u=>{const h=this.getVectorFeatureStyle(e,u);this.drawVectorFeature(i,u.geometry,h)}),this.drawNationalParkBoundaryOverlay(i,e,l),this.drawSelectedVectorOverlay(i),i.restore()}drawNationalParkBoundaryOverlay(e,t,a=[]){(t==null?void 0:t.key)!=="national-park-zoning"||!a.length||a.forEach(i=>{const o=this.getVectorFeatureStyle(t,i);this.drawVectorFeature(e,i.geometry,E(I({},o),{fill:"#071A20",stroke:"#071A20",polygonAlpha:0,lineAlpha:.34,lineWidth:7,glow:!0})),this.drawVectorFeature(e,i.geometry,E(I({},o),{fill:"#E7FFF6",stroke:"#E7FFF6",polygonAlpha:0,lineAlpha:.68,lineWidth:2.1,glow:!1})),this.drawVectorFeature(e,i.geometry,E(I({},o),{fill:o.stroke,stroke:o.stroke,polygonAlpha:0,lineAlpha:.86,lineWidth:1.2,glow:!1}))})}drawSelectedVectorOverlay(e){const t=this.selectedVectorFeatures||[],a=this.analysisMatchedFeatures||[],i=this.analysisBoundaryFeature,o=this.boundaryDrawPoints||[];if(!t.length&&!a.length&&!i&&!o.length)return;const l=this.isEcologicalProjectLayer(this.currentTopicLayer),u={fill:zs,stroke:hd,polygonAlpha:l?.2:.28,lineAlpha:l?.78:.98,lineWidth:l?6:12,pointRadius:11,glow:!l,halo:!l},h={fill:zs,stroke:dd,polygonAlpha:l?.34:.52,lineAlpha:l?.94:1,lineWidth:l?3.2:5,pointRadius:6.5,glow:!1,halo:!1};if(e.save(),t.forEach(p=>{var g;const y=(p==null?void 0:p.geometry)||((g=p==null?void 0:p.feature)==null?void 0:g.geometry);this.drawVectorFeature(e,y,u),this.drawVectorFeature(e,y,h)}),a.forEach(p=>{var g;const y=(p==null?void 0:p.geometry)||((g=p==null?void 0:p.feature)==null?void 0:g.geometry);this.drawVectorFeature(e,y,{fill:"#30DCFF",stroke:"#C9FBFF",polygonAlpha:l?.22:.28,lineAlpha:l?.88:.98,lineWidth:l?2.8:5,pointRadius:6,glow:!l})}),i!=null&&i.geometry&&this.drawVectorFeature(e,i.geometry,{fill:"#24F6C4",stroke:"#FFFFFF",polygonAlpha:l?.12:.18,lineAlpha:l?.92:1,lineWidth:l?3:4,pointRadius:6,glow:!l}),o.length){const p=o.map(g=>[g.lng,g.lat]),y={type:"LineString",coordinates:this.boundaryDrawingEnabled?p:[...p,p[0]].filter(Boolean)};this.drawVectorFeature(e,y,{fill:"#24F6C4",stroke:"#24F6C4",polygonAlpha:l?.08:.12,lineAlpha:1,lineWidth:l?3:4,pointRadius:6,glow:!l}),p.forEach(g=>{this.drawVectorFeature(e,{type:"Point",coordinates:g},{fill:"#FFFFFF",stroke:"#24F6C4",polygonAlpha:.2,lineAlpha:1,lineWidth:l?2.4:3,pointRadius:5.5,glow:!l})})}e.restore()}redrawVectorTopicLayer(){!this.topicLayerContext||!this.topicLayerTexture||!this.currentTopicLayer||!An(this.currentTopicLayer)||(this.drawVectorTopicLayer(this.currentTopicLayer,this.currentVectorFeatures||[]),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.topicLayerTexture.needsUpdate=!0)}featureMatchesLegend(e={},t={}){var o;const a=Array.isArray(t==null?void 0:t.matches)?t.matches.filter(l=>l==null?void 0:l.field):[];if(a.length)return a.some(l=>{var u;return String((u=e[l.field])!=null?u:"")===String(l.value)});const i=t==null?void 0:t.match;return i!=null&&i.field?String((o=e[i.field])!=null?o:"")===String(i.value):!0}getVisibleVectorFeatures(e,t){var u,h;const a=Array.isArray(e==null?void 0:e.activeLegends)?e.activeLegends.filter(p=>{var y,g;return((y=p==null?void 0:p.matches)==null?void 0:y.length)||((g=p==null?void 0:p.match)==null?void 0:g.field)}):[];if(a.length)return(t||[]).filter(p=>a.some(y=>this.featureMatchesLegend((p==null?void 0:p.properties)||{},y)));const i=e==null?void 0:e.activeLegend;if((u=i==null?void 0:i.matches)!=null&&u.length||(h=i==null?void 0:i.match)!=null&&h.field)return(t||[]).filter(p=>this.featureMatchesLegend((p==null?void 0:p.properties)||{},i));const l=String((e==null?void 0:e.cqlFilter)||"").trim().match(/^([a-zA-Z0-9_]+)\s*=\s*'((?:''|[^'])*)'$/);if(l){const[,p,y]=l,g=y.replace(/''/g,"'");return(t||[]).filter(w=>{var C,F;return String((F=(C=w==null?void 0:w.properties)==null?void 0:C[p])!=null?F:"")===g})}return[...t||[]]}updateYakIndustryPointLabels(e=this.currentTopicLayer,t=this.currentVectorFeatures){if(this.clearYakIndustryPointLabels(),(e==null?void 0:e.showPointLabels)===!1||e!=null&&e.hidePointFeatures||(e==null?void 0:e.key)!=="yak-industry-points"||!this.label3d)return;const a=this.getYakIndustryLabelFeatures(e,t);a.length&&(this.ensureYakIndustryPointLabelGroup(),a.forEach((i,o)=>{var u;let l=this.yakIndustryPointLabels[o];l||(l=this.label3d.create("","yak-industry-point-label",!0),this.label3d.setLabelStyle(l,.012,"x"),l.setParent(this.yakIndustryPointLabelGroup),this.yakIndustryPointLabels.push(l)),l.element.className="yak-industry-point-label",l.init(this.getYakIndustryPointLabelHtml(i),this.getYakIndustryPointLabelPosition(i,o)),l.visible=!0,(u=l.show)==null||u.call(l),l.userData={feature:i}}),this.yakIndustryPointLabels.slice(a.length).forEach(i=>{var o;i.visible=!1,(o=i.hide)==null||o.call(i),i.userData=null}),this.yakIndustryPointLabelGroup.visible=!!this.mapAnimationComplete)}updateYakIndustryPointMarkers(e=this.currentTopicLayer,t=this.currentVectorFeatures){if(this.clearYakIndustryPointMarkers(),(e==null?void 0:e.key)!=="yak-industry-points"||e!=null&&e.hidePointMarkers)return;const a=this.getVisibleVectorFeatures(e,t).filter(i=>{var o;return((o=i==null?void 0:i.geometry)==null?void 0:o.type)==="Point"});a.length&&(this.ensureYakIndustryPointMarkerGroup(),a.forEach((i,o)=>{let l=this.yakIndustryPointMarkers[o];const u=this.getVectorFeatureStyle(e,i),h=this.getYakIndustryMarkerMaterial(u,i),p=this.lngLatToLayerLocalPoint(i.geometry.coordinates,this.depth+.36),y=Number(e==null?void 0:e.pointSpriteScale)||.34,g=this.getYakIndustryMarkerType(i);l||(l=new ya(h),l.name="yak-industry-point-marker",l.renderOrder=42,this.bindYakIndustryPointMarkerEvents(l),this.interactionManager.add(l),this.yakIndustryPointMarkerGroup.add(l),this.yakIndustryPointMarkers.push(l)),l.material=h,l.center.set(.5,.5),l.position.copy(p),l.scale.set(y*.88,y*.88,1),l.visible=!0,l.userData={feature:i,layer:e,index:o,markerType:g}}),this.yakIndustryPointMarkers.slice(a.length).forEach(i=>{i.visible=!1,i.userData=null}),this.yakIndustryPointMarkerGroup.visible=!!this.mapAnimationComplete)}ensureYakIndustryPointMarkerGroup(){var e;this.yakIndustryPointMarkerGroup||(this.yakIndustryPointMarkerGroup=new Ce,this.yakIndustryPointMarkerGroup.name="yak-industry-point-markers",this.yakIndustryPointMarkerGroup.visible=!1,(e=this.focusMapGroup)==null||e.add(this.yakIndustryPointMarkerGroup))}clearYakIndustryPointMarkers(){var e;this.yakIndustryPointMarkerGroup&&(this.yakIndustryPointMarkerGroup.visible=!1),(e=this.yakIndustryPointMarkers)==null||e.forEach(t=>{t.visible=!1})}bindYakIndustryPointMarkerEvents(e){e.addEventListener("mousedown",t=>{var o,l,u,h,p,y,g,w,C;if(this.clicked||!((o=this.yakIndustryPointMarkerGroup)!=null&&o.visible))return!1;const a=(u=(l=t.target)==null?void 0:l.userData)==null?void 0:u.feature;if(!a)return!1;this.clicked=!0;const i=((h=a.geometry)==null?void 0:h.coordinates)||[];this.setSelectedVectorFeatures([a]),(C=(w=this.callbacks).onFeatureInfo)==null||C.call(w,{feature:{id:((p=a.properties)==null?void 0:p.id)||((y=a.properties)==null?void 0:y.feature_id)||((g=a.properties)==null?void 0:g.project_name),properties:a.properties||{},feature:a,layer:this.currentTopicLayer,lngLat:{lng:Number(i[0]),lat:Number(i[1])}},screen:this.getPointFeatureScreenPoint(a)})}),e.addEventListener("mouseup",()=>{this.clicked=!1}),e.addEventListener("mouseover",()=>{e.visible&&(document.body.style.cursor="pointer")}),e.addEventListener("mouseout",()=>{document.body.style.cursor="default"})}getYakIndustryMarkerMaterial(e,t){const a=e.markerType||this.getYakIndustryMarkerType(t),i=`${e.fill||"#24F6C4"}-${e.stroke||"#B7FFF2"}-${a}`,o=this.yakIndustryMarkerMaterialCache.get(i);if(o)return o;const l=this.createYakIndustryMarkerTexture(e.fill,e.stroke,a),u=new va({map:l,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1});return this.yakIndustryMarkerMaterialCache.set(i,u),u}getYakIndustryMarkerType(e={}){var a;const t=String(((a=e==null?void 0:e.properties)==null?void 0:a.stageKey)||"");return Ys[t]||"point"}createYakIndustryMarkerTexture(e="#24F6C4",t="#B7FFF2",a="point"){const i=document.createElement("canvas");i.width=112,i.height=112;const o=i.getContext("2d"),l=56,u=56;o.clearRect(0,0,i.width,i.height),o.beginPath(),o.arc(l,u,42,0,Math.PI*2),o.fillStyle=this.hexToRgba(e,.18),o.shadowColor=e,o.shadowBlur=20,o.fill(),this.drawYakIndustryMarkerFrame(o,a,l,u,e,t||e),o.save(),o.shadowBlur=0,o.beginPath(),o.arc(l,u,19,0,Math.PI*2),o.fillStyle="rgba(3, 23, 34, 0.64)",o.fill(),o.strokeStyle=this.hexToRgba("#FFFFFF",.32),o.lineWidth=2,o.stroke(),o.restore(),this.drawYakIndustryMarkerGlyph(o,a,l,u,"#FFFFFF");const h=new jr(i);return h.colorSpace=Ta,h.needsUpdate=!0,h}drawYakIndustryMarkerFrame(e,t,a,i,o="#24F6C4",l="#B7FFF2"){if(e.save(),e.translate(a,i),e.fillStyle=this.hexToRgba(o,.92),e.strokeStyle=this.hexToRgba(l||o,.98),e.lineWidth=4,e.shadowColor=l||o,e.shadowBlur=14,t==="pasture")e.beginPath(),e.moveTo(-34,-9),e.lineTo(0,-38),e.lineTo(34,-9),e.lineTo(28,-9),e.lineTo(28,24),e.quadraticCurveTo(28,31,21,31),e.lineTo(-21,31),e.quadraticCurveTo(-28,31,-28,24),e.lineTo(-28,-9),e.closePath();else if(t==="grass")e.beginPath(),e.moveTo(0,-38),e.bezierCurveTo(31,-22,34,18,0,38),e.bezierCurveTo(-34,18,-31,-22,0,-38),e.closePath();else if(t==="breeding"){e.beginPath();for(let u=0;u<6;u+=1){const h=-Math.PI/2+Math.PI*2*u/6,p=Math.cos(h)*35,y=Math.sin(h)*35;u===0?e.moveTo(p,y):e.lineTo(p,y)}e.closePath()}else if(t==="storage")e.beginPath(),e.moveTo(-34,-25),e.lineTo(25,-25),e.lineTo(35,-13),e.lineTo(35,27),e.lineTo(-25,27),e.lineTo(-35,15),e.lineTo(-35,-25),e.closePath();else if(t==="processing"){e.beginPath();for(let u=0;u<10;u+=1){const h=-Math.PI/2+Math.PI*2*u/10,p=u%2===0?38:30,y=Math.cos(h)*p,g=Math.sin(h)*p;u===0?e.moveTo(y,g):e.lineTo(y,g)}e.closePath()}else if(t==="equipment"){e.beginPath();for(let u=0;u<16;u+=1){const h=-Math.PI/2+Math.PI*2*u/16,p=u%2===0?38:30,y=Math.cos(h)*p,g=Math.sin(h)*p;u===0?e.moveTo(y,g):e.lineTo(y,g)}e.closePath()}else t==="service"?(e.beginPath(),e.moveTo(0,-39),e.lineTo(31,-24),e.lineTo(25,14),e.quadraticCurveTo(0,39,-25,14),e.lineTo(-31,-24),e.closePath()):(e.beginPath(),e.arc(0,0,34,0,Math.PI*2));e.fill(),e.stroke(),e.restore()}drawYakIndustryMarkerGlyph(e,t,a,i,o="#24F6C4"){if(e.save(),e.translate(a,i),e.lineCap="round",e.lineJoin="round",e.shadowBlur=0,e.fillStyle=this.hexToRgba(o,.98),e.strokeStyle=this.hexToRgba(o,.98),e.lineWidth=3,t==="pasture")e.beginPath(),e.moveTo(-12,-2),e.lineTo(0,-11),e.lineTo(12,-2),e.stroke(),e.fillRect(-9,-2,18,12),e.clearRect(-3,2,6,8);else if(t==="grass")e.beginPath(),e.moveTo(0,10),e.quadraticCurveTo(-10,1,-7,-10),e.moveTo(0,10),e.quadraticCurveTo(10,1,7,-10),e.moveTo(0,10),e.quadraticCurveTo(0,0,1,-12),e.stroke();else if(t==="breeding")e.beginPath(),e.moveTo(-8,-5),e.quadraticCurveTo(-15,-12,-18,-4),e.moveTo(8,-5),e.quadraticCurveTo(15,-12,18,-4),e.stroke(),e.beginPath(),e.ellipse(0,1,11,12,0,0,Math.PI*2),e.fill(),e.fillStyle=this.hexToRgba("#08202D",.85),e.fillRect(-5,-2,3,3),e.fillRect(2,-2,3,3);else if(t==="storage")e.beginPath(),e.moveTo(-13,-3),e.lineTo(0,-11),e.lineTo(13,-3),e.lineTo(13,9),e.lineTo(-13,9),e.closePath(),e.fill(),e.strokeStyle=this.hexToRgba("#08202D",.72),e.lineWidth=2,e.beginPath(),e.moveTo(-8,0),e.lineTo(8,0),e.moveTo(-8,5),e.lineTo(8,5),e.stroke();else if(t==="processing")e.beginPath(),e.moveTo(-13,8),e.lineTo(-13,-1),e.lineTo(-5,-6),e.lineTo(-5,-1),e.lineTo(3,-6),e.lineTo(3,-1),e.lineTo(12,-6),e.lineTo(12,8),e.closePath(),e.fill(),e.fillRect(-13,-11,5,7),e.fillStyle=this.hexToRgba("#08202D",.72),e.fillRect(-8,2,4,3),e.fillRect(0,2,4,3),e.fillRect(7,2,4,3);else if(t==="equipment"){for(let l=0;l<8;l+=1)e.save(),e.rotate(Math.PI*2*l/8),e.fillRect(8,-2,5,4),e.restore();e.beginPath(),e.arc(0,0,9,0,Math.PI*2),e.fill(),e.fillStyle=this.hexToRgba("#FFFFFF",.98),e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill()}else t==="service"?(e.beginPath(),e.moveTo(0,-13),e.lineTo(12,-7),e.lineTo(9,6),e.quadraticCurveTo(0,14,-9,6),e.lineTo(-12,-7),e.closePath(),e.fill(),e.strokeStyle=this.hexToRgba("#FFFFFF",.94),e.lineWidth=2.4,e.beginPath(),e.moveTo(0,-7),e.lineTo(0,6),e.moveTo(-6,-1),e.lineTo(6,-1),e.stroke()):(e.beginPath(),e.arc(0,0,7,0,Math.PI*2),e.fill());e.restore()}ensureYakIndustryPointLabelGroup(){this.yakIndustryPointLabelGroup||(this.yakIndustryPointLabelGroup=new Ce,this.yakIndustryPointLabelGroup.name="yak-industry-point-labels",this.yakIndustryPointLabelGroup.rotation.x=-Math.PI/2,this.yakIndustryPointLabelGroup.visible=!1,this.scene.add(this.yakIndustryPointLabelGroup))}clearYakIndustryPointLabels(){var e;this.yakIndustryPointLabelGroup&&(this.yakIndustryPointLabelGroup.visible=!1),(e=this.yakIndustryPointLabels)==null||e.forEach(t=>{var a;t.visible=!1,(a=t.hide)==null||a.call(t)})}getYakIndustryLabelFeatures(e,t){const a=this.getVisibleVectorFeatures(e,t).filter(h=>{var p;return((p=h==null?void 0:h.geometry)==null?void 0:p.type)==="Point"}),i=Number(e==null?void 0:e.pointLabelLimit)||(a.length>36?12:Math.min(a.length,16)),o=a.map(h=>{var p;return{feature:h,score:this.getYakIndustryFeatureScore(h),town:dt((p=h.properties)==null?void 0:p.town)}}).sort((h,p)=>{var y,g;return p.score-h.score||String(((y=h.feature.properties)==null?void 0:y.name)||"").localeCompare(String(((g=p.feature.properties)==null?void 0:g.name)||""),"zh-CN")}),l=[],u=new Set;return o.forEach(h=>{l.length>=i||!h.town||u.has(h.town)||(l.push(h.feature),u.add(h.town))}),o.forEach(h=>{l.length>=i||l.includes(h.feature)||l.push(h.feature)}),l}getYakIndustryFeatureScore(e){const t=(e==null?void 0:e.properties)||{},a=[t.outputValue,t.capacity,t.value,t.count,t["年产值 (万元)"],t["年总产值 (万元)"],t["设计存栏量 (头)"],t["总库容 (吨)"]].map(i=>this.parseMapMetricNumber(i));return Math.max(...a,0)}parseMapMetricNumber(e){if(typeof e=="number")return Number.isFinite(e)?e:0;const t=String(e!=null?e:"").replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);return t&&Number(t[0])||0}getYakIndustryPointLabelPosition(e,t=0){var i;const a=this.lngLatToLayerLocalPoint((i=e==null?void 0:e.geometry)==null?void 0:i.coordinates,this.depth+.42+Math.min(t,5)*.01);return a.x+=(t%3-1)*.08,a.y+=t%2===0?.07:-.06,a}getYakIndustryPointLabelHtml(e){const t=(e==null?void 0:e.properties)||{},a=this.compactYakIndustryLabelName(t.name||t.fullName||"产业主体"),i=this.formatYakIndustryLabelText(t.categoryName||t.stageName||"产业主体"),o=t.town||t.village||"红原县",l=this.getYakIndustryPointMetricText(t),u=this.getYakIndustryLabelColor(t);return`<div class="yak-industry-point-label-wrap" style="--yak-point-color:${Pe(u)}">
<div class="yak-industry-point-label-head"><i></i><span>${Pe(i)}</span></div>
<div class="yak-industry-point-label-name">${Pe(a)}</div>
<div class="yak-industry-point-label-meta">
<span>${Pe(o)}</span>
${l?`<strong>${Pe(l)}</strong>`:""}
</div>
</div>`}compactYakIndustryLabelName(e=""){const t=String(e).replace(/^四川红原/,"").replace(/^红原县/,"").replace(/有限责任公司$/,"").replace(/农民专业合作社$/,"合作社").replace(/\s+/g," ").trim();return t.length>16?`${t.slice(0,15)}…`:t}formatYakIndustryLabelText(e=""){return String(e).replace(/\bcxpt[-_./\s]*/gi,"").replace(/^cxpt/i,"").replace(/\s+/g," ").trim()}getYakIndustryPointMetricText(e={}){return e.capacity!==void 0&&e.capacity!==null&&e.capacity!==""&&this.parseMapMetricNumber(e.capacity)>0?this.formatYakIndustryMetricText(e.capacity,e.capacityUnit):this.parseMapMetricNumber(e.outputValue)>0?`${this.formatMapRankingValue(e.outputValue)}万元`:this.isMeaningfulMapText(e.locationType)?e.locationType:this.isMeaningfulMapText(e.status)?e.status:""}isMeaningfulMapText(e){const t=String(e!=null?e:"").trim();return!!(t&&t!=="0"&&t!=="无"&&t!=="待完善")}formatYakIndustryMetricText(e,t=""){const a=String(e!=null?e:"").trim();return!a||a==="0"?"":typeof e=="string"&&/[^\d.,\s-]/.test(a)?a:`${this.formatMapRankingValue(e)}${t||""}`}getYakIndustryLabelColor(e={}){var i,o,l,u,h,p;const t=String(e.stageKey||""),a=(((i=this.currentTopicLayer)==null?void 0:i.legends)||[]).find(y=>{var g;return String(((g=y.match)==null?void 0:g.value)||"")===t})||(String(((u=(l=(o=this.currentTopicLayer)==null?void 0:o.activeLegend)==null?void 0:l.match)==null?void 0:u.value)||"")===t?this.currentTopicLayer.activeLegend:null);return(a==null?void 0:a.fillColor)||((p=(h=this.currentTopicLayer)==null?void 0:h.activeLegend)==null?void 0:p.fillColor)||"#24F6C4"}clipVectorLayerContext(e,t){if(this.shouldClipLayerToHongyuanBoundary(t)&&this.clipContextToHongyuanBoundary(e),!this.shouldClipLayerToLayerBounds(t))return;const a=this.getLayerClipBounds(t);if(!a)return;const i=this.lngLatToLayerCanvasPoint([a.west,a.north]),o=this.lngLatToLayerCanvasPoint([a.east,a.south]),l=Math.min(i.x,o.x),u=Math.min(i.y,o.y),h=Math.abs(o.x-i.x),p=Math.abs(o.y-i.y);!h||!p||(e.beginPath(),e.rect(l,u,h,p),e.clip())}clipContextToHongyuanBoundary(e){const t=this.hongyuanBoundaryPolygons||[];t.length&&(e.beginPath(),t.forEach(a=>{a.forEach(i=>{i.forEach((o,l)=>{const u=this.lngLatToLayerCanvasPoint(o);l===0?e.moveTo(u.x,u.y):e.lineTo(u.x,u.y)}),e.closePath()})}),e.clip("evenodd"))}shouldClipLayerToHongyuanBoundary(e=this.currentTopicLayer){if(!e||e.clipToHongyuanBoundary===!1)return!1;if(e.clipToHongyuanBoundary===!0)return!0;const t=String((e==null?void 0:e.key)||"");return!!(t==="national-park-zoning"||t.startsWith("yak-"))}shouldClipLayerToLayerBounds(e=this.currentTopicLayer){return!!(e!=null&&e.clipBounds&&(e==null?void 0:e.clipToLayerBounds)!==!1)}isLngLatInHongyuanBoundary(e){const t=this.hongyuanBoundaryPolygons||[];return t.length?t.some(a=>this.isLngLatInPolygon(e,a)):!0}isLngLatInLayerClipBounds(e,t=this.currentTopicLayer){const a=this.getLayerClipBounds(t);return a?e.lng>=a.west&&e.lng<=a.east&&e.lat>=a.south&&e.lat<=a.north:!0}getLayerClipBounds(e){const t=e==null?void 0:e.clipBounds;if(!t)return null;const a=Math.max(Number(t.west),q.west),i=Math.max(Number(t.south),q.south),o=Math.min(Number(t.east),q.east),l=Math.min(Number(t.north),q.north);return![a,i,o,l].every(Number.isFinite)||a>=o||i>=l?null:{west:a,south:i,east:o,north:l}}getGeometryDrawRank(e){return String(e).includes("Polygon")?1:String(e).includes("LineString")?2:3}isEcologicalProjectLayer(e=this.currentTopicLayer){return["restoration-projects","engineering-analysis-projects"].includes(e==null?void 0:e.key)}getVectorFeatureStyle(e,t){var h,p,y;const a=t.properties||{},o=(e.legends||[]).find(g=>{var w,C;return(((w=g==null?void 0:g.matches)==null?void 0:w.length)||((C=g==null?void 0:g.match)==null?void 0:C.field))&&this.featureMatchesLegend(a,g)})||e.activeLegend||((h=e.legends)==null?void 0:h[0])||{},l=String(((p=t.geometry)==null?void 0:p.type)||"").includes("LineString"),u=((y=t.geometry)==null?void 0:y.type)==="Point";if(this.isEcologicalProjectLayer(e)){const g=l||String(a.feature_role||"")==="线性设施";return{fill:g||u?o.strokeColor||o.fillColor||"#D2EA78":o.fillColor||"#75AD49",stroke:o.strokeColor||o.fillColor||"#D2EA78",polygonAlpha:g?.08:.22,lineAlpha:g?.9:.82,lineWidth:g?3:1.85,pointRadius:u?3.8:4,glow:!1}}return(e==null?void 0:e.key)==="yak-epidemic-village-boundary"?{fill:o.fillColor||"#24F6C4",stroke:o.strokeColor||"#C9FBFF",polygonAlpha:.16,lineAlpha:1,lineWidth:3.2,pointRadius:4.5,glow:!0}:(e==null?void 0:e.key)==="artificial-grassland-plots"?{fill:o.fillColor||"#24F6C4",stroke:o.strokeColor||"#A7F8FF",polygonAlpha:.2,lineAlpha:.94,lineWidth:1.6,pointRadius:4.5,glow:!0}:(e==null?void 0:e.key)==="yak-industry-points"?{fill:o.fillColor||"#24F6C4",stroke:o.strokeColor||o.fillColor||"#B7FFF2",polygonAlpha:.36,lineAlpha:.82,lineWidth:1.6,pointRadius:this.getVectorPointRadius(e,t),glow:!0,halo:!0,marker:!0,markerType:Ys[String(a.stageKey||"")]||"point"}:(e==null?void 0:e.key)==="national-park-zoning"?{fill:o.fillColor||"#30DCFF",stroke:o.strokeColor||"#F2FFFF",polygonAlpha:.38,lineAlpha:.96,lineWidth:2.7,pointRadius:4.5,glow:!1}:e!=null&&e.boundaryOnly?{fill:o.fillColor||"#24F6C4",stroke:o.strokeColor||o.fillColor||"#18F8FF",polygonAlpha:.04,lineAlpha:.96,lineWidth:10,pointRadius:4.5,glow:!0}:{fill:l||u?o.strokeColor||o.fillColor||"#30DCFF":o.fillColor||"#30DCFF",stroke:o.strokeColor||o.fillColor||"#30DCFF",polygonAlpha:.36,lineAlpha:l?.92:.9,lineWidth:l?5:2.4,pointRadius:u?this.getVectorPointRadius(e,t):4.5,glow:!0}}getVectorPointRadius(e,t){var i,o;const a=Number(((i=t==null?void 0:t.properties)==null?void 0:i.count)||((o=t==null?void 0:t.properties)==null?void 0:o.value)||0);return(e==null?void 0:e.key)==="yak-recognition-layer"?Math.max(3.8,Math.min(8.6,3.6+Math.sqrt(a)/68)):(e==null?void 0:e.key)==="yak-industry-points"?10.4:4.5}drawVectorFeature(e,t,a){if(t!=null&&t.coordinates){if(t.type==="Polygon"){this.drawPolygonPath(e,t.coordinates,a);return}if(t.type==="MultiPolygon"){t.coordinates.forEach(i=>this.drawPolygonPath(e,i,a));return}if(t.type==="LineString"){this.drawLinePath(e,t.coordinates,a);return}if(t.type==="MultiLineString"){t.coordinates.forEach(i=>this.drawLinePath(e,i,a));return}t.type==="Point"&&this.drawPointPath(e,t.coordinates,a)}}drawPolygonPath(e,t,a){Array.isArray(t==null?void 0:t[0])&&(e.save(),e.beginPath(),t.forEach(i=>{i.forEach((o,l)=>{const u=this.lngLatToLayerCanvasPoint(o);l===0?e.moveTo(u.x,u.y):e.lineTo(u.x,u.y)}),e.closePath()}),e.fillStyle=this.hexToRgba(a.fill,a.polygonAlpha),e.strokeStyle=this.hexToRgba(a.stroke,a.lineAlpha),e.lineWidth=a.lineWidth,a.glow&&(e.shadowColor=a.stroke,e.shadowBlur=14),e.fill("evenodd"),e.stroke(),e.restore())}drawLinePath(e,t,a){!Array.isArray(t)||t.length<2||(e.save(),e.beginPath(),t.forEach((i,o)=>{const l=this.lngLatToLayerCanvasPoint(i);o===0?e.moveTo(l.x,l.y):e.lineTo(l.x,l.y)}),e.strokeStyle=this.hexToRgba(a.stroke,a.lineAlpha),e.lineWidth=a.lineWidth,e.shadowColor=a.stroke,e.shadowBlur=12,e.stroke(),e.restore())}drawPointPath(e,t,a){var o;if(a.marker){this.drawMarkerPointPath(e,t,a);return}const i=this.lngLatToLayerCanvasPoint(t);e.save(),a.halo&&(e.beginPath(),e.arc(i.x,i.y,a.pointRadius*2.35,0,Math.PI*2),e.fillStyle=this.hexToRgba(a.fill,.18),e.shadowColor=a.fill,e.shadowBlur=18,e.fill()),e.beginPath(),e.arc(i.x,i.y,a.pointRadius,0,Math.PI*2),e.fillStyle=this.hexToRgba(a.fill,.96),e.shadowColor=a.stroke,e.shadowBlur=a.halo?8:12,e.fill(),a.lineWidth&&(e.lineWidth=a.lineWidth,e.strokeStyle=this.hexToRgba(a.stroke,(o=a.lineAlpha)!=null?o:.9),e.stroke()),e.restore()}drawMarkerPointPath(e,t,a){const i=this.lngLatToLayerCanvasPoint(t),o=a.pointRadius||6;e.save(),e.beginPath(),e.arc(i.x,i.y+o*.22,o*2.55,0,Math.PI*2),e.fillStyle=this.hexToRgba(a.fill,.16),e.shadowColor=a.fill,e.shadowBlur=24,e.fill(),e.beginPath(),e.moveTo(i.x,i.y+o*2.05),e.bezierCurveTo(i.x+o*1.46,i.y+o*.62,i.x+o*1.34,i.y-o*1.34,i.x,i.y-o*1.62),e.bezierCurveTo(i.x-o*1.34,i.y-o*1.34,i.x-o*1.46,i.y+o*.62,i.x,i.y+o*2.05),e.closePath(),e.fillStyle=this.hexToRgba(a.fill,.94),e.strokeStyle=this.hexToRgba(a.stroke,.98),e.lineWidth=Math.max(2,a.lineWidth||2),e.shadowColor=a.stroke,e.shadowBlur=14,e.fill(),e.stroke(),e.beginPath(),e.arc(i.x,i.y-o*.34,o*.52,0,Math.PI*2),e.fillStyle=this.hexToRgba("#FFFFFF",.96),e.shadowBlur=0,e.fill(),e.beginPath(),e.arc(i.x,i.y-o*.34,o*.82,0,Math.PI*2),e.lineWidth=Math.max(1.2,o*.14),e.strokeStyle=this.hexToRgba("#FFFFFF",.42),e.stroke(),e.restore()}lngLatToLayerCanvasPoint(e){const t=Number(e==null?void 0:e[0]),a=Number(e==null?void 0:e[1]);return{x:(t-q.west)/(q.east-q.west)*this.topicLayerCanvas.width,y:(q.north-a)/(q.north-q.south)*this.topicLayerCanvas.height}}hexToRgba(e,t=1){const a=String(e||"#30DCFF").replace("#",""),i=a.length===3?a.split("").map(p=>p+p).join(""):a,o=Number.parseInt(i,16);if(!Number.isFinite(o))return`rgba(48, 220, 255, ${t})`;const l=o>>16&255,u=o>>8&255,h=o&255;return`rgba(${l}, ${u}, ${h}, ${t})`}parseWktGeometry(e){var l;const t=String(e||"").trim();if(!t)return null;const a=t.match(/^([A-Z]+)(?:\s+[A-Z]+)?\s*\(/i),i=(l=a==null?void 0:a[1])==null?void 0:l.toUpperCase();if(!i)return null;const o=t.slice(t.indexOf("("));return i==="POLYGON"?{type:"Polygon",coordinates:this.parseWktPolygonBody(o)}:i==="MULTIPOLYGON"?{type:"MultiPolygon",coordinates:this.parseWktMultiPolygonBody(o)}:i==="POINT"?{type:"Point",coordinates:this.parseWktPoint(o)}:i==="MULTIPOINT"?{type:"MultiPoint",coordinates:this.getWktChildGroups(o).map(u=>this.parseWktPoint(u)).filter(Boolean)}:i==="LINESTRING"?{type:"LineString",coordinates:this.parseWktRing(o)}:i==="MULTILINESTRING"?{type:"MultiLineString",coordinates:this.getWktChildGroups(o).map(u=>this.parseWktRing(u)).filter(u=>u.length)}:null}parseWktMultiPolygonBody(e){return this.getWktChildGroups(e).map(t=>this.parseWktPolygonBody(t)).filter(t=>t.length)}parseWktPolygonBody(e){return this.getWktChildGroups(e).map(t=>this.parseWktRing(t)).filter(t=>t.length>=3)}getWktChildGroups(e){const t=String(e||"").trim(),a=t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1):t,i=[];let o=0,l=-1;for(let u=0;u<a.length;u+=1){const h=a[u];h==="("?(o===0&&(l=u),o+=1):h===")"&&(o-=1,o===0&&l>=0&&(i.push(a.slice(l,u+1)),l=-1))}return i.length?i:[a]}parseWktRing(e){return String(e||"").replace(/^\(+|\)+$/g,"").split(",").map(a=>a.trim().split(/\s+/).slice(0,2).map(Number)).filter(([a,i])=>Number.isFinite(a)&&Number.isFinite(i))}parseWktPoint(e){const t=String(e||"").replace(/^\(+|\)+$/g,"").trim().split(/\s+/).slice(0,2).map(Number);return t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1])?[t[0],t[1]]:null}createProvinceMaterial(){const e=!this.useSatelliteBase;let t=new $r({color:16777215,transparent:!0,opacity:0,depthWrite:!this.usesCustomSatelliteTiles,fog:!1,side:Ee});t.onBeforeCompile=o=>{o.uniforms=E(I({},o.uniforms),{uColor1:{value:new Tt(e?2780818:2152676)},uColor2:{value:new Tt(e?1058614:475482)}}),o.vertexShader=o.vertexShader.replace("void main() {",`
attribute float alpha;
varying vec3 vPosition;
varying float vAlpha;
void main() {
vAlpha = alpha;
vPosition = position;
`),o.fragmentShader=o.fragmentShader.replace("void main() {",`
varying vec3 vPosition;
varying float vAlpha;
uniform vec3 uColor1;
uniform vec3 uColor2;
void main() {
`),o.fragmentShader=o.fragmentShader.replace("#include <opaque_fragment>",`
#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
vec3 gradient = mix(uColor1, uColor2, vPosition.x/15.78);
${e?`outgoingLight = outgoingLight * gradient;
float topAlpha = 0.56;`:`outgoingLight = mix(outgoingLight * vec3(1.18), outgoingLight * gradient, 0.32);
float topAlpha = 0.92;`}
if(vPosition.z>0.3){
diffuseColor.a *= topAlpha;
}
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
`)};let a=this.assets.instance.getResource("side");a.wrapS=ct,a.wrapT=ct,a.repeat.set(1,1.8),a.offset.y+=.065;let i=new xn({color:2148829,map:a,fog:!1,opacity:0,side:Ee,roughness:.58,metalness:.08});return this.time.on("tick",()=>{a.offset.y+=.005}),i.onBeforeCompile=o=>{o.uniforms=E(I({},o.uniforms),{uColor1:{value:new Tt(1629410)},uColor2:{value:new Tt(205365)}}),o.vertexShader=o.vertexShader.replace("void main() {",`
attribute float alpha;
varying vec3 vPosition;
varying float vAlpha;
void main() {
vAlpha = alpha;
vPosition = position;
`),o.fragmentShader=o.fragmentShader.replace("void main() {",`
varying vec3 vPosition;
varying float vAlpha;
uniform vec3 uColor1;
uniform vec3 uColor2;
void main() {
`),o.fragmentShader=o.fragmentShader.replace("#include <opaque_fragment>",`
#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
vec3 gradient = mix(uColor1, uColor2, vPosition.z/1.2);
outgoingLight = outgoingLight*gradient*vec3(1.12);
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
`)},[t,i]}getDefaultTownRanking(){return{title:"乡镇统计加载中",unit:"",rows:As.map(e=>({name:e.name,value:0,unit:""}))}}getTownRankingMeta(e=this.currentTownRanking){var i,o,l,u;const t=this.getDefaultTownRanking(),a=md(e);return{title:(e==null?void 0:e.title)||t.title,unit:(e==null?void 0:e.unit)||t.unit,metricLabel:(e==null?void 0:e.metricLabel)||(e==null?void 0:e.legendName)||"",note:(e==null?void 0:e.note)||"",hideTownNames:Us(e),hideMapLabels:Wa(e),hideTownLabelStats:(i=e==null?void 0:e.hideTownLabelStats)!=null?i:this.hideTownLabelStatsByDefault,calloutMode:a,showBars:(o=e==null?void 0:e.showBars)!=null?o:!1,showPointMarkers:(l=e==null?void 0:e.showPointMarkers)!=null?l:a,onlyRankedTownLabels:(u=e==null?void 0:e.onlyRankedTownLabels)!=null?u:!1,showMissingTownStats:(e==null?void 0:e.showMissingTownStats)===!0}}getTownRankingRows(e=this.currentTownRanking,t=7,a=!0){var h;const i=this.getDefaultTownRanking(),o=(h=e==null?void 0:e.rows)!=null&&h.length?e.rows:a?i.rows:[],l=this.getTownRankingMeta(e),u=o.map(p=>{const y=this.townMetaByName.get(dt(p.name));return y?E(I(I({},y),p),{name:y.name,enName:y.enName,center:y.center,centroid:y.centroid,value:de(p.value),unit:p.unit||l.unit,metricTitle:l.title}):null}).filter(Boolean).sort((p,y)=>y.value-p.value).map((p,y)=>E(I({},p),{rank:y+1}));return Number.isFinite(t)?u.slice(0,t):u}getVillageRankingRows(e=this.currentTownRanking){const t=this.getTownRankingMeta(e);return((e==null?void 0:e.rows)||[]).map((a,i)=>{var p,y,g,w,C,F,x,G;const o=de((p=a.lng)!=null?p:a.longitude,NaN),l=de((y=a.lat)!=null?y:a.latitude,NaN);if(!Number.isFinite(o)||!Number.isFinite(l))return null;const u=de((g=a.displayValue)!=null?g:a.value),h=de((F=(C=(w=a.rawValue)!=null?w:a.earTagCount)!=null?C:a.ear_tag_count)!=null?F:a.value);return E(I({},a),{key:a.key||`${a.town||""}-${a.village||a.name||i}`,name:a.name||a.village||`村${i+1}`,town:a.town||"",lng:o,lat:l,value:u,rawValue:h,recordCount:de((x=a.recordCount)!=null?x:a.record_count,0),imageRate:de((G=a.imageRate)!=null?G:a.image_rate,0),unit:a.displayUnit||a.unit||t.unit,metricTitle:t.title,metricLabel:a.metricLabel||t.metricLabel||""})}).filter(Boolean).sort((a,i)=>i.rawValue-a.rawValue).map((a,i)=>E(I({},a),{rank:i+1}))}getVillageRankingHtml(e,t){const a=t.hideTownNames?"":`<span>${Pe(e.town||"红原县")}</span>`;return e.displayMode==="park-village"||t.displayMode==="park-village"?`<div class="epidemic-village-card is-park-village ${e.rank>8?"is-small":""}">
<div class="village-card-head">
<strong>${Pe(e.name)}</strong>
${a}
</div>
<div class="village-card-body">
<span class="metric">${Pe(e.metricLabel||t.metricLabel||"")}</span>
<span class="number">${this.formatMapRankingValue(e.value)}</span>
<span class="unit">${Pe(e.unit||t.unit||"")}</span>
</div>
</div>`:`<div class="epidemic-village-card ${e.rank>8?"is-small":""}">
<div class="village-card-head">
<strong>${Pe(e.name)}</strong>
${a}
</div>
<div class="village-card-body">
<span class="metric">${Pe(e.metricLabel||"防疫")}</span>
<span class="number">${this.formatMapRankingValue(e.value)}</span>
<span class="unit">${Pe(e.unit||t.unit||"")}</span>
</div>
<div class="village-card-foot">
<span>台账 ${this.formatMapCompactValue(e.recordCount)}条</span>
<span>耳标 ${this.formatMapCompactValue(e.rawValue)}头</span>
</div>
</div>`}ensureVillageRankingGroup(){this.villageRankingGroup||(this.villageRankingGroup=new Ce,this.villageRankingGroup.rotation.x=-Math.PI/2,this.villageRankingGroup.visible=!1,this.scene.add(this.villageRankingGroup),this.villageRankingLabels=[])}hideVillageRankingLabels(){var e;this.villageRankingGroup&&(this.villageRankingGroup.visible=!1),(e=this.villageRankingLabels)==null||e.forEach(t=>{t.visible=!1})}hideAllMapStatisticLabels(){var e,t,a,i;this.updateTownNameLabelStats(null),this.setTownNameLabelsVisible(!1),this.hideVillageRankingLabels(),this.hideTradeFlowLayer(),this.clearInfoPointStats(),(e=this.allProvinceLabel)==null||e.forEach(o=>{o.visible=!1}),(t=this.allBar)==null||t.forEach(o=>{o.visible=!1,o.scale.set(1,1,0)}),(a=this.allBarMaterial)==null||a.forEach(o=>{o.opacity=0}),(i=this.allGuangquan)==null||i.forEach(o=>{o.visible=!1})}setTownNameLabelsVisible(e=!0){var t;(t=this.townNameLabels)==null||t.forEach(a=>{a.visible=e})}updateVillageRankingLabels(e=this.currentTownRanking){if(this.ensureVillageRankingGroup(),!Hs(e)){this.hideVillageRankingLabels();return}const t=this.getVillageRankingRows(e),a=this.getTownRankingMeta(e);if(!t.length){this.hideVillageRankingLabels();return}this.villageRankingGroup.visible=this.mapAnimationComplete,t.forEach((i,o)=>{let l=this.villageRankingLabels[o];l||(l=this.label3d.create("","epidemic-village-label",!0),this.label3d.setLabelStyle(l,.0135,"x"),l.setParent(this.villageRankingGroup),this.villageRankingLabels.push(l));const[u,h]=this.geoProjection([i.lng,i.lat]),p=(o%3-1)*.06,y=Math.floor(o/3)%2*.04;l.init(this.getVillageRankingHtml(i,a),new le(u+p,-h+y,this.depth+1.55+Math.min(o,6)*.015)),l.visible=!0,l.userData=I({},i)}),this.villageRankingLabels.slice(t.length).forEach(i=>{i.visible=!1})}ensureTradeFlowGroup(){this.tradeFlowGroup||(this.tradeFlowGroup=new Ce,this.tradeFlowGroup.name="yak-trade-flow",this.tradeFlowGroup.visible=!1,this.tradeFlowMeshGroup=new Ce,this.tradeFlowMeshGroup.name="yak-trade-flow-mesh",this.tradeFlowMeshGroup.rotation.x=-Math.PI/2,this.tradeFlowLabelGroup=new Ce,this.tradeFlowLabelGroup.name="yak-trade-flow-label",this.tradeFlowLabelGroup.rotation.x=-Math.PI/2,this.tradeFlowGroup.add(this.tradeFlowMeshGroup,this.tradeFlowLabelGroup),this.scene.add(this.tradeFlowGroup))}hideTradeFlowLayer(){var e,t;this.tradeFlowGroup&&(this.tradeFlowGroup.visible=!1),(e=this.tradeFlowLabels)==null||e.forEach(a=>{a.visible=!1}),(t=this.tradeFlowPulseSprites)==null||t.forEach(a=>{a.visible=!1})}clearTradeFlowLayer(){this.tradeFlowMeshGroup&&(this.tradeFlowMeshGroup.children.forEach(e=>{var t;(t=e.traverse)==null||t.call(e,a=>this.disposeObject3D(a))}),this.tradeFlowMeshGroup.clear(),this.tradeFlowMaterials=[],this.tradeFlowPulseSprites=[])}getTradeFlowSource(e=this.currentTownRanking){var o,l,u,h;const t=(e==null?void 0:e.source)||{},a=de((o=t.lng)!=null?o:t.longitude,NaN),i=de((l=t.lat)!=null?l:t.latitude,NaN);return!Number.isFinite(a)||!Number.isFinite(i)?null:{name:t.name||"红原牦牛交易市场",lng:a,lat:i,total:de((h=(u=t.total)!=null?u:t.headCount)!=null?h:t.value,NaN)}}getTradeFlowRows(e=this.currentTownRanking){const t=this.getTownRankingMeta(e),a=!!(e!=null&&e.nationalFlow);return((e==null?void 0:e.rows)||[]).map((i,o)=>{var x,G,H,J,ne,K,V;const l=de((x=i.lng)!=null?x:i.longitude,NaN),u=de((G=i.lat)!=null?G:i.latitude,NaN),h=de((ne=(J=(H=i.headCount)!=null?H:i.head_count)!=null?J:i.rawValue)!=null?ne:i.value),p=i.displayName||i.display_name||i.name,y=i.mapTownName||i.map_town_name||i.town||i.startTown||i.start_town||p,g=i.destinationProvince||i.destination_province||i.provinceName||i.province_name||p,w=a?null:this.townMetaByName.get(dt(y)),C=a?(K=this.tradeProvinceCenterByName)==null?void 0:K.get(this.normalizeTradeProvinceName(g)):null,F=Number.isFinite(l)&&Number.isFinite(u)?{lng:l,lat:u}:C?{lng:C.lng,lat:C.lat}:w!=null&&w.center?{lng:w.center[0],lat:w.center[1]}:null;return!F||!Number.isFinite(h)?null:E(I(I({},i),w),{key:i.key||`${(w==null?void 0:w.name)||p||y||"trade-source"}-${o}`,name:p||y||(w==null?void 0:w.name)||`来源${o+1}`,townName:(w==null?void 0:w.name)||y,provinceName:g,lng:F.lng,lat:F.lat,labelSide:i.labelSide||i.label_side||(a?this.getTradeNationalLabelSide(F,o):this.getTradeSourceLabelSide(w,o)),value:h,headCount:h,recordCount:de((V=i.recordCount)!=null?V:i.record_count,0),unit:i.unit||t.unit||"头"})}).filter(Boolean).sort((i,o)=>o.value-i.value).map((i,o)=>E(I({},i),{rank:o+1}))}getTradeMarketHtml(e,t){const a=Number.isFinite(e.total)?e.total:t.reduce((i,o)=>i+de(o.value),0);return`<div class="trade-market-card">
<div class="market-title">${Pe(e.name)}</div>
<div class="market-total"><span>${this.formatMapIntegerValue(a)}</span><em>头</em></div>
</div>`}getTradeFlowDisplayName(e=""){const t=String(e||"").replace(/^.*红原县/,"").replace(/\s+/g,"");return t.length>7?`${t.slice(0,7)}…`:t||"来源区域"}getTradeFlowLabelHtml(e){return`<div class="trade-flow-card${e.labelSide?` is-${String(e.labelSide).replace(/[^a-z0-9-]/gi,"")}`:""}">
<div class="flow-head"><span>${String(e.rank).padStart(2,"0")}</span><strong>${Pe(this.getTradeFlowDisplayName(e.name))}</strong></div>
<div class="flow-body"><em>${this.formatMapIntegerValue(e.value)}</em><b>${Pe(e.unit||"头")}</b></div>
</div>`}getTradeFlowLabelOffset(e,t){return new le(0,0,0)}getTradeSourceLabelSide(e,t=0){var o,l;const a=Number((o=e==null?void 0:e.center)==null?void 0:o[0]),i=Number((l=e==null?void 0:e.center)==null?void 0:l[1]);return Number.isFinite(a)&&a<this.geoProjectionCenter[0]-.18?"left":Number.isFinite(a)&&a>this.geoProjectionCenter[0]+.2?"right":Number.isFinite(i)&&i>this.geoProjectionCenter[1]+.22?"top":Number.isFinite(i)&&i<this.geoProjectionCenter[1]-.26?"bottom":["right","left","top","bottom"][t%4]}getTradeNationalLabelSide(e,t=0){return Number(e==null?void 0:e.lng)<this.tradeGeoProjectionCenter[0]-8?"left":Number(e==null?void 0:e.lng)>this.tradeGeoProjectionCenter[0]+8?"right":Number(e==null?void 0:e.lat)>this.tradeGeoProjectionCenter[1]+6?"top":Number(e==null?void 0:e.lat)<this.tradeGeoProjectionCenter[1]-6?"bottom":["right","left","top","bottom"][t%4]}getTradeLocalPoint(e,t,a=0){var h;const i=!!((h=this.currentTownRanking)!=null&&h.nationalFlow),[o,l]=i?this.tradeGeoProjection([e,t]):this.geoProjection([e,t]),u=i?this.tradeNationalDepth:this.depth;return new le(o,-l,u+a)}getTradeFlowPoint(e,t=0){return this.getTradeLocalPoint(e.lng,e.lat,t)}getLocalTradeFlowCurve(e,t,a){var w;const i=!!((w=this.currentTownRanking)!=null&&w.nationalFlow),o=this.getTradeLocalPoint(t.lng,t.lat,.86),l=this.getTradeFlowPoint(e,.76),u=i?o:l,h=i?l:o,p=u.clone().lerp(h,.5),y=u.distanceTo(h);p.z+=Math.max(.32,Math.min(.82,y*.22+a*.012));const g=new le(-(h.y-u.y),h.x-u.x,0);return g.lengthSq()>0&&(g.normalize().multiplyScalar((a%2===0?1:-1)*Math.min(.18,.05+y*.02)),p.add(g)),new rc([u,p,h])}tradeGeoProjection(e){return sa().center(this.tradeGeoProjectionCenter).scale(this.tradeGeoProjectionScale).translate([0,0])(e)}setTradeNationalMapVisible(e){const t=!!e;if(!(!t&&!this.isTradeNationalMapActive&&!this.tradeNationalMapGroup&&!this.tradeFlowGroup)){if(t&&!this.createTradeNationalMap()){this.isTradeNationalMapActive=!1;return}this.isTradeNationalMapActive=t,this.tradeNationalMapGroup&&(this.tradeNationalMapGroup.visible=t&&this.mapAnimationComplete),this.tradeNationalLabelGroup&&(this.tradeNationalLabelGroup.visible=t&&this.mapAnimationComplete),this.mapGroup&&(this.mapGroup.visible=!t),this.labelGroup&&(this.labelGroup.visible=!t),this.flyLineGroup&&(this.flyLineGroup.visible=!t&&this.mapAnimationComplete),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=!t&&this.mapAnimationComplete),this.scatterGroup&&(this.scatterGroup.visible=!t&&this.mapAnimationComplete),this.topicLayerMaterial&&t&&(this.topicLayerMaterial.opacity=0),t&&this.mapAnimationComplete?this.animateMapCamera(new le(0,11.4,16.2),new le(0,-.05,0),.65):!t&&this.mapAnimationComplete&&this.applyLayerMapView(this.currentTopicLayer,{force:!0})}}createTradeSourceMarker(e,t,a,i,o=!0){const l=new Tt(t%3===1?16766828:t%3===2?2617536:3202303),u=this.getTradeFlowPoint(e,.72);if(i&&o){const x=this.getLocalTradeFlowCurve(e,i,t),G=new ke({color:l,transparent:!0,opacity:.42,depthWrite:!1,depthTest:!1,fog:!1,blending:Ve}),H=.012+Math.min(.012,de(e.value)/Math.max(a,1)*.01),J=new Qe(new ic(x,48,H,8,!1),G);J.renderOrder=31,this.tradeFlowMeshGroup.add(J),this.tradeFlowMaterials.push(G);const ne=new va({map:this.assets.instance.getResource("point"),color:l,transparent:!0,opacity:.92,depthWrite:!1,depthTest:!1,fog:!1,blending:Ve}),K=new ya(ne),V=.12+Math.min(.08,de(e.value)/Math.max(a,1)*.06);K.renderOrder=36,K.scale.set(V,V,V),K.userData={curve:x,phase:t*.13%1,speed:.16+Math.min(.16,de(e.value)/Math.max(a,1)*.12)},K.position.copy(x.getPointAt(K.userData.phase)),this.tradeFlowPulseSprites.push(K),this.tradeFlowMeshGroup.add(K)}const h=new va({map:this.assets.instance.getResource("point"),color:l,transparent:!0,opacity:.95,depthWrite:!1,depthTest:!1,fog:!1,blending:Ve}),p=new ya(h),y=.22+Math.min(.34,de(e.value)/Math.max(a,1)*.28);p.renderOrder=34,p.scale.set(y,y,y),p.position.copy(u),this.tradeFlowMeshGroup.add(p);const g=this.assets.instance.getResource("guangquan1"),w=new ke({map:g,alphaMap:g,color:l,transparent:!0,opacity:.52,depthWrite:!1,depthTest:!1,fog:!1,blending:Ve,side:Ee}),C=.38+Math.min(.36,de(e.value)/Math.max(a,1)*.28),F=new Qe(new Ht(C,C),w);F.renderOrder=29,F.position.copy(this.getTradeFlowPoint(e,.5)),this.tradeFlowMeshGroup.add(F)}createTradeMarketMarker(e){const t=this.assets.instance.getResource("point"),a=this.assets.instance.getResource("guangquan1"),i=this.getTradeLocalPoint(e.lng,e.lat,.82),o=new va({map:t,color:16773997,transparent:!0,opacity:1,depthWrite:!1,depthTest:!1,fog:!1,blending:Ve}),l=new ya(o);l.renderOrder=35,l.scale.set(.34,.34,.34),l.position.copy(i),this.tradeFlowMeshGroup.add(l);const u=new ke({map:a,alphaMap:a,color:16773997,transparent:!0,opacity:.72,depthWrite:!1,depthTest:!1,fog:!1,blending:Ve,side:Ee}),h=new Qe(new Ht(.58,.58),u);h.renderOrder=29,h.position.copy(this.getTradeLocalPoint(e.lng,e.lat,.58)),this.tradeFlowMeshGroup.add(h)}disposeObject3D(e){var t,a,i,o;(a=(t=e.geometry)==null?void 0:t.dispose)==null||a.call(t),Array.isArray(e.material)?e.material.forEach(l=>{var u;return(u=l==null?void 0:l.dispose)==null?void 0:u.call(l)}):(o=(i=e.material)==null?void 0:i.dispose)==null||o.call(i)}updateTradeFlowPulses(e=.016){var t,a;!((t=this.tradeFlowGroup)!=null&&t.visible)||!((a=this.tradeFlowPulseSprites)!=null&&a.length)||this.tradeFlowPulseSprites.forEach(i=>{var u;const o=(u=i.userData)==null?void 0:u.curve;if(!o)return;const l=(de(i.userData.phase)+de(i.userData.speed,.16)*e)%1;i.userData.phase=l,i.position.copy(o.getPointAt(l))})}updateTradeFlowLayer(e=this.currentTownRanking){if(!qs(e)){this.hideTradeFlowLayer();return}this.ensureTradeFlowGroup();const t=this.getTradeFlowSource(e),a=this.getTradeFlowRows(e);if(!t||!a.length){this.clearTradeFlowLayer(),this.hideTradeFlowLayer();return}this.clearTradeFlowLayer(),this.tradeFlowGroup.visible=this.mapAnimationComplete;const i=fd(e);this.createTradeMarketMarker(t);const o=Math.max(...a.map(h=>h.value),1);a.forEach((h,p)=>{this.createTradeSourceMarker(h,p,o,t,i)});const l=a.length+1;for(let h=this.tradeFlowLabels.length;h<l;h+=1){const p=this.label3d.create("",h===0?"trade-market-label":"trade-flow-label",!0);this.label3d.setLabelStyle(p,h===0?.014:.0125,"x"),p.setParent(this.tradeFlowLabelGroup),this.tradeFlowLabels.push(p)}const u=this.tradeFlowLabels[0];u.element.className="trade-market-label",u.init(this.getTradeMarketHtml(t,a),this.getTradeLocalPoint(t.lng,t.lat,.9)),u.visible=!0,u.userData=E(I({},t),{rows:a.length}),a.forEach((h,p)=>{const y=this.tradeFlowLabels[p+1];y.element.className="trade-flow-label",y.init(this.getTradeFlowLabelHtml(h),this.getTradeFlowPoint(h,.78).add(this.getTradeFlowLabelOffset(h,p))),y.visible=!0,y.userData=I({},h)}),this.tradeFlowLabels.slice(l).forEach(h=>{h.visible=!1})}hasTownRankingRows(e=this.currentTownRanking){return this.getTownRankingRows(e,Number.POSITIVE_INFINITY,!1).length>0}formatMapRankingValue(e){const t=de(e);return Math.abs(t)>=100?String(Math.round(t)):Math.abs(t)>=10?String(Number(t.toFixed(1))):String(Number(t.toFixed(2)))}formatMapCompactValue(e){const t=de(e);return Math.abs(t)>=1e4?`${Number((t/1e4).toFixed(Math.abs(t)>=1e5?1:2))}万`:Math.abs(t)>=1e3?`${Number((t/1e3).toFixed(1))}千`:this.formatMapRankingValue(t)}formatMapIntegerValue(e){const t=de(e);return Math.round(t).toLocaleString("zh-CN")}getBarHeight(e,t){return t?Math.max(2.8*.12,2.8*(de(e)/t)):2.8*.25}createBarGeometry(e){const a=new sc(.06999999999999999,.06999999999999999,e);return a.translate(0,0,e/2),a}getProvinceLabelHtml(e,t,a){return`<div class="provinces-label ${t>4?"yellow":""}">
<div class="provinces-label-wrap">
<div class="label-main">
<div class="label-title">${a.title}</div>
<div class="number"><span class="value" data-target-value="${e.value}">${this.formatMapRankingValue(e.value)}</span><span class="unit">${e.unit||a.unit}</span></div>
<div class="name">${e.name}</div>
</div>
<div class="no">${t+1}</div>
</div>
</div>`}updateBarItem(e,t,a,i,o=!0){var p,y;const l=this.getBarHeight(t.value,i),[u,h]=this.geoProjection(t.centroid);return e.visible=!0,(y=(p=e.geometry)==null?void 0:p.dispose)==null||y.call(p),e.geometry=this.createBarGeometry(l),e.position.set(u,-h,this.depth+.45),e.userData=E(I({},t),{targetValue:t.value,geoHeight:l}),e.children.forEach(g=>{var w,C,F,x;(C=(w=g.geometry)==null?void 0:w.dispose)==null||C.call(w),Array.isArray(g.material)?g.material.forEach(G=>{var H;return(H=G==null?void 0:G.dispose)==null?void 0:H.call(G)}):(x=(F=g.material)==null?void 0:F.dispose)==null||x.call(F)}),e.clear(),e.add(...this.createHUIGUANG(l,a>3?16776948:7863285)),o?wa.to(e.scale,{duration:.45,x:1,y:1,z:1,ease:"power2.out"}):this.mapAnimationComplete&&e.scale.set(1,1,1),{x:u,y:h,geoHeight:l}}updateProvinceLabel(e,t,a,i,o,l=!0){var F;const u=de((F=e.userData)==null?void 0:F.targetValue,t.value);e.visible=!0,e.userData=E(I({},t),{targetValue:t.value}),e.position.copy(i);const h=e.element.querySelector(".label-title"),p=e.element.querySelector(".number .value"),y=e.element.querySelector(".number .unit"),g=e.element.querySelector(".name"),w=e.element.querySelector(".no");!h||!p||!y||!g||!w?e.element.innerHTML=this.getProvinceLabelHtml(t,a,o):(h.innerText=o.title,p.dataset.targetValue=String(t.value),p.innerText=this.formatMapRankingValue(t.value),y.innerText=t.unit||o.unit,g.innerText=t.name,w.innerText=a+1);const C=e.element.querySelector(".provinces-label-wrap");if(this.mapAnimationComplete&&(C.style.opacity="1",C.style.transform="translate3d(0, 0, 0)"),l&&this.mapAnimationComplete){const x=e.element.querySelector(".number .value"),H={value:u};wa.to(H,{value:t.value,duration:.45,ease:"power2.out",onUpdate:()=>{x.innerText=this.formatMapRankingValue(H.value)},onComplete:()=>{x.dataset.previousValue=String(t.value),x.innerText=this.formatMapRankingValue(t.value)}})}}clearTownNameLabelStat(e){const t=e.element.querySelector(".town-stat-label"),a=e.element.querySelector(".town-stat-value"),i=e.element.querySelector(".town-stat-unit"),o=e.element.querySelector(".town-rank"),l=e.element.querySelector(".town-stat-metric");t==null||t.classList.remove("has-stat"),e.element.style.pointerEvents="none",e.element.style.cursor="",a&&(a.innerText=""),i&&(i.innerText=""),o&&(o.innerText=""),l&&(l.innerText="")}updateTownNameLabelStats(e=this.currentTownRanking){var l;if(!((l=this.townNameLabels)!=null&&l.length))return;const t=this.getTownRankingRows(e,Number.POSITIVE_INFINITY,!1),a=this.getTownRankingMeta(e);if(a.hideTownLabelStats){this.townNameLabels.forEach(u=>{var y,g;const h=((y=u.userData)==null?void 0:y.townName)||((g=u.userData)==null?void 0:g.name),p=u.element.querySelector(".town-name");p&&(p.innerText=h||""),this.clearTownNameLabelStat(u),u.visible=!a.hideTownNames});return}const i=new Map(t.map(u=>[dt(u.name),u])),o=!!(a.showMissingTownStats&&e&&t.length&&(a.metricLabel||a.unit||a.title));this.townNameLabels.forEach(u=>{var J,ne;const h=((J=u.userData)==null?void 0:J.townName)||((ne=u.userData)==null?void 0:ne.name),p=i.get(dt(h));if(a.onlyRankedTownLabels&&!p){this.clearTownNameLabelStat(u),u.element.style.pointerEvents="none",u.element.style.cursor="",u.visible=!1;return}const y=p||(o?{name:h,value:0,unit:a.unit,metricLabel:a.metricLabel,rank:null}:null);if(!y){this.clearTownNameLabelStat(u),u.element.style.pointerEvents="none",u.element.style.cursor="";return}const g=u.element.querySelector(".town-stat-label"),w=u.element.querySelector(".town-name"),C=u.element.querySelector(".town-stat-value"),F=u.element.querySelector(".town-stat-unit"),x=u.element.querySelector(".town-rank"),G=u.element.querySelector(".town-stat-metric");g==null||g.classList.add("has-stat"),w&&(w.innerText=h),G&&(G.innerText=y.metricLabel||a.metricLabel||""),C&&(C.innerText=this.formatMapRankingValue(y.value)),F&&(F.innerText=y.unit||a.unit||""),x&&(x.innerText=y.rank?`第${y.rank}名`:"");const H=this.isNationalParkTownSelectionActive()&&!!p;u.element.style.pointerEvents=H?"auto":"none",u.element.style.cursor=H?"pointer":"",u.userData=E(I(I({},u.userData),y),{townName:h,targetValue:y.value})})}getInfoPointHtml(e,t=this.getTownRankingMeta()){const a=String(e.metricLabel||t.metricLabel||t.title||"统计指标").replace(/排行$/,""),i=Number(e.rank),o=Number.isFinite(i)?String(i).padStart(2,"0"):"--";return`<div class="info-point-wrap ${i<=3?"is-prime":""}">
<div class="info-point-wrap-inner">
<div class="info-point-head">
<span class="rank">${o}</span>
<strong>${Pe(e.name||"红原县")}</strong>
</div>
<div class="info-point-metric">${Pe(a)}</div>
<div class="info-point-value">
<span>${this.formatMapRankingValue(e.value)}</span>
<em>${Pe(e.unit||t.unit||"")}</em>
</div>
</div>
</div>`}updateInfoPointStats(){var l,u;if(!((l=this.infoPointSprites)!=null&&l.length)||!((u=this.infoLabelElement)!=null&&u.length))return;if(!this.showTownRankingPointMarkers){this.clearInfoPointStats();return}const e=this.getTownRankingRows(this.currentTownRanking,Number.POSITIVE_INFINITY,!1);if(!e.length){this.clearInfoPointStats();return}const t=this.getTownRankingMeta(),a=e.slice(0,this.infoPointSprites.length),i=Math.max(...a.map(h=>h.value),1);this.infoPointSprites.forEach((h,p)=>{const y=a[p],g=this.infoLabelElement[p];if(!y){h.visible=!1,h.scale.set(0,0,0),g&&(g.visible=!1);return}const[w,C]=this.geoProjection(y.centroid||y.center),F=[w,-C,this.depth+.72];h.userData=E(I(I({},h.userData),y),{position:F,value:y.value,unit:y.unit||t.unit,rank:y.rank,metricTitle:t.title,index:p}),h.position.set(...F),h.visible=this.showTownRankingPointMarkers;const x=.78+y.value/i*.44;if(h.scale.set(x,x,x),g){const G=(p%2===0?.22:-.18)+(p===0?.12:0),H=p%3===0?.08:-.04;g.position.set(w+G,-C+H,this.depth+1.88+Math.min(p,4)*.03),g.userData=E(I({},y),{index:p}),g.element.innerHTML=this.getInfoPointHtml(y,t)}});const o=this.infoLabelElement[this.infoPointIndex];o&&this.showTownRankingPointMarkers&&this.mapAnimationComplete&&(o.visible=!0),this.showTownRankingPointMarkers&&this.mapAnimationComplete&&!this.infoPointLabelTime&&this.createInfoPointLabelLoop()}clearInfoPointStats(){var e,t;clearInterval(this.infoPointLabelTime),this.infoPointLabelTime=null,this.infoPointIndex=0,this.InfoPointGroup&&(this.InfoPointGroup.visible=!1),(e=this.infoLabelElement)==null||e.forEach(a=>{a.visible=!1}),(t=this.infoPointSprites)==null||t.forEach(a=>{a.visible=!1,a.scale.set(0,0,0)})}createBar(){const e=this.getTownRankingRows();this.getTownRankingMeta();const t=new Ce;this.barGroup=t;const a=Math.max(...e.map(i=>i.value),1);this.allBar=[],this.allBarMaterial=[],this.allGuangquan=[],this.allProvinceLabel=[],e.map((i,o)=>{const l=this.getBarHeight(i.value,a),u=new ke({color:16777215,transparent:!0,opacity:0,depthTest:!1,fog:!1});new Rn(u,{uColor1:o>3?16506760:5291006,uColor2:o>3?16776948:7863285,size:l,dir:"y"});const h=new Qe(this.createBarGeometry(l),u);h.renderOrder=5;const[p,y]=this.geoProjection(i.centroid);h.position.set(p,-y,this.depth+.45),h.scale.set(1,1,0),h.userData=E(I({},i),{targetValue:i.value,geoHeight:l});const g=this.createQuan(new le(p,this.depth+.44,y),o);h.add(...this.createHUIGUANG(l,o>3?16776948:7863285)),t.add(h),t.rotation.x=-Math.PI/2,this.allBar.push(h),this.allBarMaterial.push(u),this.allGuangquan.push(g)}),this.scene.add(t),this.updateTownNameLabelStats(this.currentTownRanking)}setTownRanking(e){var o,l,u,h,p,y,g,w,C,F,x,G,H,J,ne,K;this.currentTownRanking=e;const t=this.getTownRankingMeta(e);if(this.showTownRankingBars=!!t.showBars,this.showTownRankingPointMarkers=!!t.showPointMarkers,t.hideMapLabels){this.hideAllMapStatisticLabels(),this.mapGroup&&(this.mapGroup.visible=!0),this.labelGroup&&(this.labelGroup.visible=!0),this.flyLineGroup&&(this.flyLineGroup.visible=this.mapAnimationComplete),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=this.mapAnimationComplete),this.scatterGroup&&(this.scatterGroup.visible=this.mapAnimationComplete);return}if(qs(e)){const V=!!(e!=null&&e.nationalFlow);this.setTradeNationalMapVisible(V),this.updateTownNameLabelStats(null),this.setTownNameLabelsVisible(!1),this.hideVillageRankingLabels(),this.clearInfoPointStats(),this.mapGroup&&(this.mapGroup.visible=!V),this.labelGroup&&(this.labelGroup.visible=!1),this.flyLineGroup&&(this.flyLineGroup.visible=!1),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=!1),this.scatterGroup&&(this.scatterGroup.visible=!1),(o=this.allBar)!=null&&o.length&&(this.allBar.forEach(se=>{se.visible=!1,se.scale.set(1,1,0)}),(l=this.allBarMaterial)==null||l.forEach(se=>{se.opacity=0}),(u=this.allProvinceLabel)==null||u.forEach(se=>{se.visible=!1}),(h=this.allGuangquan)==null||h.forEach(se=>{se.visible=!1})),this.updateTradeFlowLayer(e),(e!=null&&e.mapView||e!=null&&e.cameraPosition)&&this.applyLayerMapView(null);return}if(this.setTradeNationalMapVisible(!1),this.hideTradeFlowLayer(),this.mapGroup&&(this.mapGroup.visible=!0),this.labelGroup&&(this.labelGroup.visible=!0),this.flyLineGroup&&(this.flyLineGroup.visible=this.mapAnimationComplete),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=this.mapAnimationComplete),this.scatterGroup&&(this.scatterGroup.visible=this.mapAnimationComplete),Hs(e)){this.updateTownNameLabelStats(null),this.setTownNameLabelsVisible(!Us(e)),this.clearInfoPointStats(),this.updateVillageRankingLabels(e),(p=this.allBar)!=null&&p.length&&(this.allBar.forEach(V=>{V.visible=!1,V.scale.set(1,1,0)}),(y=this.allBarMaterial)==null||y.forEach(V=>{V.opacity=0}),(g=this.allProvinceLabel)==null||g.forEach(V=>{V.visible=!1}),(w=this.allGuangquan)==null||w.forEach(V=>{V.visible=!1}));return}if(this.setTownNameLabelsVisible(!t.calloutMode&&!t.hideTownNames),this.hideVillageRankingLabels(),t.calloutMode?this.updateTownNameLabelStats(null):this.updateTownNameLabelStats(e),!((C=this.allBar)!=null&&C.length))return;if(!this.showTownRankingBars){this.allBar.forEach(V=>{V.visible=!1,V.scale.set(1,1,0)}),(F=this.allBarMaterial)==null||F.forEach(V=>{V.opacity=0}),(x=this.allProvinceLabel)==null||x.forEach(V=>{V.visible=!1}),(G=this.allGuangquan)==null||G.forEach(V=>{V.visible=!1}),this.showTownRankingPointMarkers?(this.InfoPointGroup&&(this.InfoPointGroup.visible=this.mapAnimationComplete&&this.hasTownRankingRows(e)),this.updateInfoPointStats()):this.clearInfoPointStats();return}const a=this.getTownRankingRows(e,7,!1);if(!a.length){this.allBar.forEach(V=>{V.visible=!1,V.scale.set(1,1,0)}),(H=this.allProvinceLabel)==null||H.forEach(V=>{V.visible=!1}),(J=this.allGuangquan)==null||J.forEach(V=>{V.visible=!1}),this.clearInfoPointStats();return}this.InfoPointGroup&&(this.InfoPointGroup.visible=this.showTownRankingPointMarkers&&this.mapAnimationComplete),(ne=this.infoPointSprites)==null||ne.forEach(V=>{V.visible=this.showTownRankingPointMarkers});const i=Math.max(...a.map(V=>V.value),1);this.allBar.forEach((V,se)=>{const Ye=se<a.length;V.visible=Ye,Ye||V.scale.set(1,1,0)}),(K=this.allProvinceLabel)==null||K.forEach(V=>{V.visible=!1}),this.allGuangquan.forEach((V,se)=>{V.visible=se<a.length}),a.forEach((V,se)=>{const Ye=this.allBar[se],rt=this.allGuangquan[se];if(!Ye)return;const{x:At,y:kt}=this.updateBarItem(Ye,V,se,i,this.mapAnimationComplete);rt&&(rt.visible=!0,rt.position.set(0,0,0),rt.children.forEach(z=>{z.position.set(At,this.depth+.44,kt),this.mapAnimationComplete&&z.scale.set(1,1,1)}))}),this.updateInfoPointStats()}createEvent(){let e=[];const t=i=>{i.traverse(o=>{o.isMesh&&(o.material=this.defaultMaterial)})},a=i=>{i.traverse(o=>{o.isMesh&&(o.material=this.defaultLightMaterial)})};this.eventElement.map(i=>{this.interactionManager.add(i),i.addEventListener("mousedown",o=>{this.handleMapClick(o)}),i.addEventListener("mouseover",o=>{e.includes(o.target.parent)||e.push(o.target.parent),document.body.style.cursor="pointer",a(o.target.parent)}),i.addEventListener("mouseout",o=>{e=e.filter(l=>l.userData.name!==o.target.parent.userData.name),e.length>0&&e[e.length-1],t(o.target.parent),document.body.style.cursor="default"})})}createHUIGUANG(e,t){let a=new Ht(.35,e);a.translate(0,e/2,0);const i=this.assets.instance.getResource("huiguang");i.colorSpace=Ta,i.wrapS=ct,i.wrapT=ct;let o=new ke({color:t,map:i,transparent:!0,opacity:.4,depthWrite:!1,side:Ee,blending:Ve}),l=new Qe(a,o);l.renderOrder=10,l.rotateX(Math.PI/2);let u=l.clone(),h=l.clone();return u.rotateY(Math.PI/180*60),h.rotateY(Math.PI/180*120),[l,u,h]}createQuan(e,t){const a=this.assets.instance.getResource("guangquan1"),i=this.assets.instance.getResource("guangquan2");let o=new Ht(.5,.5),l=new ke({color:16777215,map:a,alphaMap:a,opacity:1,transparent:!0,depthTest:!1,fog:!1,blending:Ve}),u=new ke({color:16777215,map:i,alphaMap:i,opacity:1,transparent:!0,depthTest:!1,fog:!1,blending:Ve}),h=new Qe(o,l),p=new Qe(o,u);return h.renderOrder=6,p.renderOrder=6,h.rotateX(-Math.PI/2),p.rotateX(-Math.PI/2),h.position.copy(e),p.position.copy(e),p.position.y-=.001,h.scale.set(0,0,0),p.scale.set(0,0,0),this.quanGroup=new Ce,this.quanGroup.add(h,p),this.scene.add(this.quanGroup),this.time.on("tick",()=>{h.rotation.z+=.05}),this.quanGroup}createDiffuse(){let e=new Ht(200,200),t=new ke({color:0,depthWrite:!1,transparent:!0,blending:oc});t.blendEquation=lc,t.blendSrc=uc,t.blendDst=cc,new bc({material:t,time:this.time,size:60,diffuseSpeed:8,diffuseColor:7442830,diffuseWidth:2,callback:i=>{const o=setTimeout(()=>{this.addSceneTween(wa.to(i.uniforms.uTime,{value:4,repeat:-1,duration:6,ease:"power1.easeIn"}))},3);this.addSceneTimer(o)}});let a=new Qe(e,t);a.renderOrder=3,a.rotation.x=-Math.PI/2,a.position.set(0,.21,0),this.scene.add(a)}createGrid(){new wc(this,{gridSize:54,gridDivision:24,gridColor:1990543,shapeSize:.55,shapeColor:3309487,pointSize:.085,pointColor:1993891,pointBlending:Ve})}createBottomBg(){let e=new Ht(24,24);const t=this.assets.instance.getResource("ocean");t.colorSpace=Ta,t.wrapS=ct,t.wrapT=ct,t.repeat.set(1,1);let a=new ke({map:t,opacity:.92,fog:!1}),i=new Qe(e,a);i.rotation.x=-Math.PI/2,i.position.set(0,-.7,0),this.scene.add(i)}createChinaBlurLine(){let e=new Ht(154,154);const t=this.assets.instance.getResource("chinaBlurLine");t.colorSpace=Ta,t.wrapS=ct,t.wrapT=ct,t.generateMipmaps=!1,t.minFilter=Ss,t.repeat.set(1,1);let a=new ke({color:4162253,alphaMap:t,transparent:!0,opacity:.62}),i=new Qe(e,a);i.rotateX(-Math.PI/2),i.position.set(-19.3,-.5,-19.7),this.scene.add(i)}createLabel(){let e=this,t=this.labelGroup,a=this.label3d,i=[],o=[];Vc.map(u=>{if(u.hide==!0)return!1;let h=l(u,a,t);i.push(h),o.push(h)}),this.otherLabel=i,this.townNameLabels=o;function l(u,h,p){let y=h.create("",`china-label ${u.blur?" blur":""}`,!0);const[g,w]=e.geoProjection(u.center);return y.init(`<div class="other-label town-stat-label">
<div class="town-name-row"><img class="label-icon" src="${Lc}"><span class="town-name">${u.name}</span><span class="town-rank"></span></div>
<div class="town-stat-row"><span class="town-stat-metric"></span><span class="town-stat-value"></span><span class="town-stat-unit"></span></div>
</div>`,new le(g,-w,e.depth+.85)),h.setLabelStyle(y,.018,"x"),y.setParent(p),y.userData=E(I({},u),{labelType:"town-label",baseScale:.018,townName:u.name}),y.element.addEventListener("pointerdown",C=>{e.handleTownRankingSelect(u.name,{preserveCamera:!0,statusText:`已选中${u.name}`})&&(C.preventDefault(),C.stopPropagation())}),y}}createRotateBorder(){let e=13.2,t=this.assets.instance.getResource("rotationBorder1"),a=this.assets.instance.getResource("rotationBorder2"),i=new xs(this,{width:e*1.178,needRotate:!0,rotateSpeed:.001,material:new ke({map:t,color:4763647,transparent:!0,opacity:.26,side:Ee,depthWrite:!1,blending:Ve}),position:new le(0,.31,0)});i.instance.rotation.x=-Math.PI/2,i.instance.renderOrder=6,i.instance.scale.set(0,0,0),i.setParent(this.scene);let o=new xs(this,{width:e*1.116,needRotate:!0,rotateSpeed:-.004,material:new ke({map:a,color:4763647,transparent:!0,opacity:.5,side:Ee,depthWrite:!1,blending:Ve}),position:new le(0,.33,0)});o.instance.rotation.x=-Math.PI/2,o.instance.renderOrder=6,o.instance.scale.set(0,0,0),o.setParent(this.scene),this.rotateBorder1=i.instance,this.rotateBorder2=o.instance}createFlyLine(){this.flyLineGroup=new Ce,this.flyLineGroup.visible=!1,this.scene.add(this.flyLineGroup)}createFocus(){this.flyLineFocusGroup.clear()}createParticles(){this.particles=new Rs(this,{num:10,range:30,dir:"up",speed:.05,material:new dc({map:Rs.createTexture(),size:1,color:61166,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1,vertexColors:!0,blending:Ve,sizeAttenuation:!0})}),this.particleGroup=new Ce,this.scene.add(this.particleGroup),this.particleGroup.rotation.x=-Math.PI/2,this.particles.setParent(this.particleGroup),this.particles.enable=!0,this.particleGroup.visible=!0}createScatter(){this.scatterGroup=new Ce,this.scatterGroup.visible=!1,this.scatterGroup.rotation.x=-Math.PI/2,this.scene.add(this.scatterGroup);const e=this.assets.instance.getResource("arrow"),t=new va({map:e,color:16776948,fog:!1,transparent:!0,depthTest:!1});let a=js(Dc),i=a[0].value;a.map(o=>{const l=new ya(t);l.renderOrder=23;let u=.1+o.value/i*.2;l.scale.set(u,u,u);let[h,p]=this.geoProjection([o.lng,o.lat]);l.position.set(h,-p,this.depth+.45),l.userData.position=[h,-p,this.depth+.45],this.scatterGroup.add(l)})}createInfoPoint(){let e=this;this.InfoPointGroup=new Ce,this.scene.add(this.InfoPointGroup),this.InfoPointGroup.visible=!1,this.InfoPointGroup.rotation.x=-Math.PI/2,this.infoPointIndex=0,this.infoPointLabelTime=null,this.infoLabelElement=[],this.infoPointSprites=[];let t=this.label3d;const a=this.assets.instance.getResource("point");let i=[16776948,7863285],o=js(zc),l=o[0].value;o.map((h,p)=>{const y=new va({map:a,color:i[p%i.length],fog:!1,transparent:!0,depthTest:!1}),g=new ya(y);g.renderOrder=23;let w=.7+h.value/l*.4;g.scale.set(w,w,w);let[C,F]=this.geoProjection([h.lng,h.lat]),x=[C,-F,this.depth+.7];g.position.set(...x),g.userData.position=[...x],g.userData={position:[C,-F,this.depth+.7],name:h.name,value:h.value,level:h.level,index:p},this.InfoPointGroup.add(g);let G=u(h,t,this.InfoPointGroup,p);this.infoLabelElement.push(G),this.infoPointSprites.push(g),this.interactionManager.add(g),g.addEventListener("mousedown",H=>{var J,ne;if(this.clicked||!this.InfoPointGroup.visible)return!1;this.clicked=!0,this.infoPointIndex=H.target.userData.index,this.infoLabelElement.map(K=>{K.visible=!1}),G.visible=!0,this.handleTownRankingSelect(((J=H.target.userData)==null?void 0:J.name)||((ne=H.target.userData)==null?void 0:ne.townName)),this.createInfoPointLabelLoop()}),g.addEventListener("mouseup",H=>{this.clicked=!1}),g.addEventListener("mouseover",H=>{document.body.style.cursor="pointer"}),g.addEventListener("mouseout",H=>{document.body.style.cursor="default"})});function u(h,p,y,g){let w=p.create("","info-point",!0);const[C,F]=e.geoProjection([h.lng,h.lat]);return w.init(e.getInfoPointHtml(E(I({},h),{value:0,rank:g+1,unit:""}),e.getTownRankingMeta()),new le(C,-F,e.depth+1.9)),p.setLabelStyle(w,.015,"x"),w.setParent(y),w.visible=!1,w}}createInfoPointLabelLoop(){var e;this.scenePaused||!((e=this.infoLabelElement)!=null&&e.length)||(clearInterval(this.infoPointLabelTime),this.infoPointLabelTime=setInterval(()=>{this.infoPointIndex++,this.infoPointIndex>=this.infoLabelElement.length&&(this.infoPointIndex=0),this.infoLabelElement.map((t,a)=>{this.infoPointIndex===a?t.visible=!0:t.visible=!1})},3e3))}createStorke(){const e=this.staticMapData.mapStroke,t=this.assets.instance.getResource("pathLine3");t.wrapS=t.wrapT=ct,t.repeat.set(2,1);let a=new ba(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,position:new le(0,0,this.depth+.24),data:e,material:new ke({color:2868444,map:t,alphaMap:t,fog:!1,transparent:!0,opacity:1,blending:Ve}),type:"Line3",renderOrder:22,tubeRadius:.03});this.focusMapGroup.add(a.lineGroup),this.time.on("tick",()=>{t.offset.x+=.005})}handleMapClick(e){return oe(this,null,function*(){var o,l,u,h,p,y,g,w,C,F,x,G,H,J,ne,K,V,se,Ye,rt,At,kt,z,ht,Mt,Bt,pt,$t,ft,Ne,it,Me,qe,_e,Fe,Et,Ct,De,ze,Be,M;if(!this.currentTopicLayer)return;const t=this.getScreenPointFromEvent(e),a=this.getLngLatFromEvent(e);if(!a){this.clearSelectedFeature(),(l=(o=this.callbacks).onFeatureInfo)==null||l.call(o,{feature:null});return}if(this.boundaryDrawingEnabled){const L=((u=e==null?void 0:e.data)==null?void 0:u.originalEvent)||(e==null?void 0:e.originalEvent)||e;if(L!=null&&L.__analysisBoundaryHandled)return;this.addBoundaryDrawPoint(a);return}if(this.shouldClipLayerToHongyuanBoundary(this.currentTopicLayer)&&!this.isLngLatInHongyuanBoundary(a)){this.clearSelectedFeature(),(p=(h=this.callbacks).onFeatureInfo)==null||p.call(h,{feature:null}),(g=(y=this.callbacks).onLayerStatus)==null||g.call(y,{type:"success",text:"当前点击位置不在红原县边界内"});return}if(this.shouldClipLayerToLayerBounds(this.currentTopicLayer)&&!this.isLngLatInLayerClipBounds(a,this.currentTopicLayer)){this.clearSelectedFeature(),(C=(w=this.callbacks).onFeatureInfo)==null||C.call(w,{feature:null}),(x=(F=this.callbacks).onLayerStatus)==null||x.call(F,{type:"success",text:"当前点击位置不在图层显示范围内"});return}if(gd(this.currentTopicLayer)){this.clearSelectedFeature(),(H=(G=this.callbacks).onFeatureInfo)==null||H.call(G,{feature:null});return}if(An(this.currentTopicLayer)){const L=this.pickVectorFeatureAtPoint(a,t),A=(L==null?void 0:L.feature)||L;let D=(L==null?void 0:L.screen)||t;if(A)this.shouldClipLayerToHongyuanBoundary(this.currentTopicLayer)?(this.clearSelectedGeometryGroup(),this.setSelectedVectorFeatures([A])):this.showSelectedFeature(A),((J=this.currentTopicLayer)==null?void 0:J.key)==="yak-industry-points"&&(this.setSelectedVectorFeatures([A]),D=this.getPointFeatureScreenPoint(A)||D),(Ye=(se=this.callbacks).onFeatureInfo)==null||Ye.call(se,{feature:{id:((ne=A.properties)==null?void 0:ne.id)||((K=A.properties)==null?void 0:K.feature_id)||((V=A.properties)==null?void 0:V.project_name),properties:A.properties||{},feature:A,layer:this.currentTopicLayer,lngLat:a},screen:D}),(At=(rt=this.callbacks).onLayerStatus)==null||At.call(rt,{type:"success",text:"真实矢量要素已选中"});else{const Z=this.getTownNameFromMapEvent(e);if(this.handleTownRankingSelect(Z))return;this.clearSelectedFeature(),(z=(kt=this.callbacks).onFeatureInfo)==null||z.call(kt,{feature:null}),(Mt=(ht=this.callbacks).onLayerStatus)==null||Mt.call(ht,{type:"success",text:"当前点击位置无生态保护要素"})}return}const i=this.lngLatToWmsPixel(a);(pt=(Bt=this.callbacks).onFeatureInfo)==null||pt.call(Bt,{feature:null}),(ft=($t=this.callbacks).onFeatureLoading)==null||ft.call($t,!0);try{const L=yield Vs(this.currentTopicLayer,i,{size:St,buffer:10}),A=this.normalizeFeatureInfoAtPoint(L,a),D=A?null:yield this.queryFallbackFeatureInfo(a),Z=A||(D==null?void 0:D.feature);if(Z){const re=yield this.enrichFeatureInfo(Z,i,a);this.showSelectedFeature(re.feature||re),(it=(Ne=this.callbacks).onFeatureInfo)==null||it.call(Ne,{feature:E(I({},re),{layer:(D==null?void 0:D.layer)||this.currentTopicLayer,lngLat:a}),screen:t})}else this.clearSelectedFeature(),(qe=(Me=this.callbacks).onFeatureInfo)==null||qe.call(Me,{feature:null});Z||(Fe=(_e=this.callbacks).onLayerStatus)==null||Fe.call(_e,{type:"success",text:"当前点击位置无图斑"})}catch(L){this.clearSelectedFeature(),(Ct=(Et=this.callbacks).onFeatureInfo)==null||Ct.call(Et,{feature:null}),(ze=(De=this.callbacks).onLayerStatus)==null||ze.call(De,{type:"error",text:"图斑信息查询失败"})}finally{(M=(Be=this.callbacks).onFeatureLoading)==null||M.call(Be,!1)}})}handleCanvasBoundaryPointerDown(e){var a,i;if(!this.boundaryDrawingEnabled)return;const t=this.getLngLatFromCanvasEvent(e);t&&this.addBoundaryDrawPoint(t)&&(e.__analysisBoundaryHandled=!0),(a=e.preventDefault)==null||a.call(e),(i=e.stopPropagation)==null||i.call(e)}handleCanvasBoundaryDoubleClick(e){var a,i;if(!this.boundaryDrawingEnabled)return;const t=this.getLngLatFromCanvasEvent(e);(this.boundaryDrawPoints||[]).length<3&&t&&this.addBoundaryDrawPoint(t),(this.boundaryDrawPoints||[]).length>=3&&(this.finishBoundaryDrawing(),e.__analysisBoundaryHandled=!0),(a=e.preventDefault)==null||a.call(e),(i=e.stopPropagation)==null||i.call(e)}getLngLatFromCanvasEvent(e){var w,C,F;if(!((w=this.camera)!=null&&w.instance)||!this.focusMapGroup||!this.canvas)return null;const t=this.canvas.getBoundingClientRect();if(!t.width||!t.height)return null;const a=(C=this.interactionManager)==null?void 0:C.raycaster;if(!(a!=null&&a.setFromCamera))return null;const i={x:(e.clientX-t.left)/t.width*2-1,y:-((e.clientY-t.top)/t.height)*2+1};a.setFromCamera(i,this.camera.instance);const l=((F=a.intersectObjects(this.eventElement||[],!0)[0])==null?void 0:F.point)||this.getRayMapPlaneIntersection(a.ray);if(!l)return null;const u=this.focusMapGroup.worldToLocal(l.clone()),p=sa().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0]).invert([u.x,-u.y]);if(!p)return null;const y=Number(p[0]),g=Number(p[1]);return!Number.isFinite(y)||!Number.isFinite(g)?null:y<q.west-.03||y>q.east+.03||g<q.south-.03||g>q.north+.03?this.getFallbackLngLatFromPointer(e,t):{lng:y,lat:g}}getFallbackLngLatFromPointer(e,t=(i=>(i=(a=>(a=this.canvas)==null?void 0:a.getBoundingClientRect)())==null?void 0:i.call(a))()){if(!(t!=null&&t.width)||!(t!=null&&t.height))return null;const o=Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),l=Math.min(1,Math.max(0,(e.clientY-t.top)/t.height)),u=q.west+(q.east-q.west)*o,h=q.north-(q.north-q.south)*l;return{lng:u,lat:h}}getRayMapPlaneIntersection(e){if(!(e!=null&&e.origin)||!(e!=null&&e.direction)||!this.focusMapGroup)return null;const t=this.focusMapGroup.worldToLocal(e.origin.clone()),i=this.focusMapGroup.worldToLocal(e.origin.clone().add(e.direction.clone())).sub(t),o=this.depth+.22;if(Math.abs(i.z)<1e-8)return null;const l=(o-t.z)/i.z;if(!Number.isFinite(l)||l<0)return null;const u=t.add(i.multiplyScalar(l));return this.focusMapGroup.localToWorld(u)}enrichFeatureInfo(e,t,a){return oe(this,null,function*(){const i=this.getLayerTopicKey(this.currentTopicLayer);if(!["grassland","wetland","woodland"].includes(i))return e;const l=(Dr[i]||[]).find(g=>g.key===`${i}-distribution`),u=(this.visibleTopicLayers||[]).filter(g=>this.getLayerTopicKey(g)===i).slice(0,5),h=[l,this.currentTopicLayer,...u].filter(g=>g==null?void 0:g.layerName).filter((g,w,C)=>C.findIndex(F=>this.getLayerQueryKey(F)===this.getLayerQueryKey(g))===w);if(!h.length)return e;const p=yield Promise.allSettled([...h.filter(g=>this.getLayerQueryKey(g)!==this.getLayerQueryKey(this.currentTopicLayer)).map(g=>oe(this,null,function*(){const w=yield Vs(g,t,{size:St,buffer:10}),C=this.normalizeFeatureInfoAtPoint(w,a);return C?{layer:g,feature:C,source:"wms"}:null})),...h.map(g=>oe(this,null,function*(){const w=yield this.queryLayerFeatureByPoint(g,a);return w?{layer:g,feature:w,source:"wfs"}:null}))]),y=I({},e.properties||{});return p.forEach(g=>{var w,C;g.status!=="fulfilled"||!((C=(w=g.value)==null?void 0:w.feature)!=null&&C.properties)||this.mergeBusinessProperties(y,g.value.feature.properties,g.value.layer)}),E(I({},e),{properties:y,relatedFeatures:p.filter(g=>{var w;return g.status==="fulfilled"&&((w=g.value)==null?void 0:w.feature)}).map(g=>g.value),feature:E(I({},e.feature||{}),{properties:y})})})}queryFallbackFeatureInfo(e){return oe(this,null,function*(){const t=this.getLayerTopicKey(this.currentTopicLayer);if(!["grassland","wetland","woodland"].includes(t))return null;const i=[(Dr[t]||[]).find(o=>o.key===`${t}-distribution`),this.currentTopicLayer,...(this.visibleTopicLayers||[]).filter(o=>this.getLayerTopicKey(o)===t)].filter((o,l,u)=>(o==null?void 0:o.layerName)&&u.findIndex(h=>this.getLayerQueryKey(h)===this.getLayerQueryKey(o))===l);for(const o of i){const l=yield this.queryLayerFeatureByPoint(o,e,{requireContainment:!0});if(l)return{layer:o,feature:l}}return null})}normalizeFeatureInfoAtPoint(e,t){const a=Array.isArray(e==null?void 0:e.features)?e.features:[];if(!a.length)return null;const i=this.pickFeatureAtPoint(a,t,{requireContainment:!0});if(!i)return null;const o=i.properties||{};return{id:i.id||o.gid||o.objectid||o.OBJECTID,properties:o,feature:i}}queryLayerFeatureByPoint(i,o){return oe(this,arguments,function*(e,t,a={}){var F,x,G;if(!(e!=null&&e.layerName)||!Number.isFinite(t==null?void 0:t.lng)||!Number.isFinite(t==null?void 0:t.lat))return null;const l=e.pointQueryTolerance||.0015,u=e.geometryField||"geom",h=t.lng-l,p=t.lat-l,y=t.lng+l,g=t.lat+l,w=yield Ds(e.layerName,{cqlFilter:`BBOX(${u},${h},${p},${y},${g})`,maxFeatures:8,timeout:12e3}),C=this.pickFeatureAtPoint((w==null?void 0:w.features)||[],t,a);return C?{id:C.id||((F=C.properties)==null?void 0:F.gid)||((x=C.properties)==null?void 0:x.objectid)||((G=C.properties)==null?void 0:G.OBJECTID),properties:C.properties||{},feature:C}:null})}pickFeatureAtPoint(e,t,a={}){var o;if(!Array.isArray(e)||!e.length)return null;const i=e.filter(l=>this.isLngLatInGeometry(t,l.geometry)).sort((l,u)=>this.getGeometryAreaScore(l.geometry)-this.getGeometryAreaScore(u.geometry));return i.length?i[0]:a.requireContainment?null:((o=e.map(l=>({feature:l,distance:this.getGeometryDistanceScore(l.geometry,t)})).sort((l,u)=>l.distance-u.distance)[0])==null?void 0:o.feature)||null}isLngLatInGeometry(e,t){return!e||!(t!=null&&t.coordinates)?!1:t.type==="Polygon"?this.isLngLatInPolygon(e,t.coordinates):t.type==="MultiPolygon"?t.coordinates.some(a=>this.isLngLatInPolygon(e,a)):!1}isLngLatInPolygon(e,t=[]){return!t.length||!this.isLngLatInRing(e,t[0])?!1:!t.slice(1).some(i=>this.isLngLatInRing(e,i))}isLngLatInRing(e,t=[]){if(t.length<3)return!1;let a=!1;const i=e.lng,o=e.lat;for(let l=0,u=t.length-1;l<t.length;u=l++){const h=t[l],p=t[u],y=Number(h==null?void 0:h[0]),g=Number(h==null?void 0:h[1]),w=Number(p==null?void 0:p[0]),C=Number(p==null?void 0:p[1]);if(this.isPointOnSegment(i,o,y,g,w,C))return!0;g>o!=C>o&&i<(w-y)*(o-g)/(C-g)+y&&(a=!a)}return a}isPointOnSegment(e,t,a,i,o,l){const u=(e-a)*(l-i)-(t-i)*(o-a);return Math.abs(u)>1e-10?!1:(e-a)*(e-o)+(t-i)*(t-l)<=1e-10}getGeometryAreaScore(e){return e!=null&&e.coordinates?e.type==="Polygon"?this.getLngLatPolygonAreaScore(e.coordinates):e.type==="MultiPolygon"?e.coordinates.reduce((t,a)=>t+this.getLngLatPolygonAreaScore(a),0):Number.POSITIVE_INFINITY:Number.POSITIVE_INFINITY}getLngLatPolygonAreaScore(e=[]){const t=e[0]||[];if(t.length<3)return Number.POSITIVE_INFINITY;let a=0;for(let i=0;i<t.length;i++){const o=t[i],l=t[(i+1)%t.length];a+=Number((o==null?void 0:o[0])||0)*Number((l==null?void 0:l[1])||0)-Number((l==null?void 0:l[0])||0)*Number((o==null?void 0:o[1])||0)}return Math.abs(a)}getGeometryDistanceScore(e,t){const a=this.getGeometryLngLatBounds(e);if(!a)return Number.POSITIVE_INFINITY;const i=(a.minLng+a.maxLng)/2,o=(a.minLat+a.maxLat)/2;return Math.hypot(i-t.lng,o-t.lat)}getGeometryLngLatBounds(e){const t=this.getGeometryCoordinateList(e);return t.length?t.reduce((a,i)=>({minLng:Math.min(a.minLng,Number((i==null?void 0:i[0])||0)),minLat:Math.min(a.minLat,Number((i==null?void 0:i[1])||0)),maxLng:Math.max(a.maxLng,Number((i==null?void 0:i[0])||0)),maxLat:Math.max(a.maxLat,Number((i==null?void 0:i[1])||0))}),{minLng:Number.POSITIVE_INFINITY,minLat:Number.POSITIVE_INFINITY,maxLng:Number.NEGATIVE_INFINITY,maxLat:Number.NEGATIVE_INFINITY}):null}getGeometryCoordinateList(e){const t=[],a=i=>{if(Array.isArray(i)){if(typeof i[0]=="number"&&typeof i[1]=="number"){t.push(i);return}i.forEach(a)}};return a(e==null?void 0:e.coordinates),t}pickVectorFeatureAtPoint(e,t){var l;const a=this.getVisibleVectorFeatures(this.currentTopicLayer,this.currentVectorFeatures||[]);if(((l=this.currentTopicLayer)==null?void 0:l.key)==="yak-industry-points"){const u=this.pickPointFeatureAtScreenPoint(a,t);if(u)return u}const i=a.filter(u=>this.isLngLatInGeometry(e,u.geometry)).sort((u,h)=>this.getGeometryAreaScore(u.geometry)-this.getGeometryAreaScore(h.geometry));if(i.length)return i[0];const o=a.find(u=>this.isPointOrLineNearLngLat(u.geometry,e));return o||null}pickPointFeatureAtScreenPoint(e,t){var o;if(!t||!((o=this.camera)!=null&&o.instance)||!this.focusMapGroup||!this.canvas)return null;const i=(e||[]).filter(l=>{var u;return((u=l==null?void 0:l.geometry)==null?void 0:u.type)==="Point"}).map(l=>{const u=this.getPointFeatureScreenPoint(l);return u?{feature:l,screen:u,distance:Math.hypot(u.x-t.x,u.y-t.y)}:null}).filter(Boolean).sort((l,u)=>l.distance-u.distance)[0];return(i==null?void 0:i.distance)<=22?{feature:i.feature,screen:i.screen}:null}getPointFeatureScreenPoint(e){var a,i;const t=(e==null?void 0:e.geometry)||((a=e==null?void 0:e.feature)==null?void 0:a.geometry);return(t==null?void 0:t.type)!=="Point"?null:((i=this.currentTopicLayer)==null?void 0:i.key)==="yak-industry-points"?this.lngLatToLayerScreenPoint(t.coordinates,this.depth+.36):this.lngLatToScreenPoint(t.coordinates,this.depth+.32)}lngLatToLayerLocalPoint(e,t=0){const a=()=>{const p=Number(e==null?void 0:e[0]),y=Number(e==null?void 0:e[1]);if(!Number.isFinite(p)||!Number.isFinite(y))return new le(0,0,Number(t)||0);const[g,w]=this.geoProjection([p,y]);return new le(g,-w,Number(t)||0)},i=this.topicLayerUvBounds;if(!i)return a();const o=this.lngLatToLayerCanvasPoint(e),l=this.topicLayerCanvas;if(!(l!=null&&l.width)||!(l!=null&&l.height))return a();const u=i.left+o.x/l.width*(i.right-i.left),h=i.bottom+(l.height-o.y)/l.height*(i.top-i.bottom);return new le(u,h,Number(t)||0)}lngLatToLayerScreenPoint(e,t=0){return this.localMapPointToScreenPoint(this.lngLatToLayerLocalPoint(e,t))}lngLatToScreenPoint(e,t=0){const a=Number(e==null?void 0:e[0]),i=Number(e==null?void 0:e[1]);if(!Number.isFinite(a)||!Number.isFinite(i))return null;const o=this.lngLatToWorldPoint([a,i],t);return this.worldPointToScreenPoint(o)}localMapPointToScreenPoint(e){const t=this.focusMapGroup?this.focusMapGroup.localToWorld(e):e;return this.worldPointToScreenPoint(t)}worldPointToScreenPoint(e){var i;if(!((i=this.camera)!=null&&i.instance)||!this.canvas||!e)return null;const t=this.canvas.getBoundingClientRect();if(!t.width||!t.height)return null;const a=e.clone().project(this.camera.instance);return!Number.isFinite(a.x)||!Number.isFinite(a.y)?null:{x:t.left+(a.x+1)/2*t.width,y:t.top+(1-a.y)/2*t.height}}focusProject(e){var w,C,F,x;const t=String(e||"").trim();if(!t)return!1;const a=(this.currentVectorFeatures||[]).filter(G=>{var H;return String(((H=G==null?void 0:G.properties)==null?void 0:H.project_name)||"").trim()===t});if(!a.length)return(C=(w=this.callbacks).onLayerStatus)==null||C.call(w,{type:"success",text:"当前项目图斑尚未加载"}),!1;const i=this.getFeatureListLngLatBounds(a);if(!i)return!1;const o=this.getProjectHighlightFeatures(a);o.length?(this.showSelectedFeatures(o),this.setSelectedVectorFeatures(o)):this.clearSelectedFeature();const l=[(i.minLng+i.maxLng)/2,(i.minLat+i.maxLat)/2],u=Math.max(i.maxLng-i.minLng,i.maxLat-i.minLat),h=Math.max(.22,Math.min(.55,u*1.25)),p=this.lngLatToWorldPoint(l,.72),y=this.defaultMapCameraPosition.clone().sub(this.defaultMapTarget).multiplyScalar(h),g=p.clone().add(y);return this.animateMapCamera(g,p,.75),(x=(F=this.callbacks).onLayerStatus)==null||x.call(F,{type:"success",text:"已定位项目"}),!0}setBoundaryDrawing(e){var t,a,i,o;this.boundaryDrawingEnabled=!!e,this.boundaryDrawingEnabled?(this.boundaryDrawPoints=[],this.lastBoundaryDrawPoint=null,this.analysisBoundaryFeature=null,this.analysisMatchedFeatures=[],this.clearSelectedFeature(),(a=(t=this.callbacks).onLayerStatus)==null||a.call(t,{type:"success",text:"请在地图上依次点击绘制分析边界"})):(o=(i=this.callbacks).onLayerStatus)==null||o.call(i,{type:"success",text:"已退出边界绘制"}),this.redrawVectorTopicLayer()}addBoundaryDrawPoint(e){var o,l,u,h;if(!Number.isFinite(e==null?void 0:e.lng)||!Number.isFinite(e==null?void 0:e.lat))return!1;const t=Date.now(),a=this.lastBoundaryDrawPoint;return a&&t-a.time<350&&Math.hypot(e.lng-a.lng,e.lat-a.lat)<8e-4?!1:(this.lastBoundaryDrawPoint={lng:e.lng,lat:e.lat,time:t},this.boundaryDrawPoints=[...this.boundaryDrawPoints||[],{lng:e.lng,lat:e.lat}],(l=(o=this.callbacks).onDrawBoundary)==null||l.call(o,{status:"drawing",points:this.boundaryDrawPoints,pointCount:this.boundaryDrawPoints.length}),(h=(u=this.callbacks).onLayerStatus)==null||h.call(u,{type:"success",text:`已添加边界点 ${this.boundaryDrawPoints.length} 个`}),this.redrawVectorTopicLayer(),!0)}undoBoundaryPoint(){var e,t,a;return(e=this.boundaryDrawPoints)!=null&&e.length?(this.boundaryDrawPoints=this.boundaryDrawPoints.slice(0,-1),(a=(t=this.callbacks).onDrawBoundary)==null||a.call(t,{status:"drawing",points:this.boundaryDrawPoints,pointCount:this.boundaryDrawPoints.length}),this.redrawVectorTopicLayer(),!0):!1}finishBoundaryDrawing(){var l,u,h,p,y,g;const e=this.boundaryDrawPoints||[];if(e.length<3)return(u=(l=this.callbacks).onLayerStatus)==null||u.call(l,{type:"error",text:"至少需要 3 个点才能形成分析边界"}),null;const t=e.map(w=>[w.lng,w.lat]),a=t[0],i=t[t.length-1];(a[0]!==i[0]||a[1]!==i[1])&&t.push([...a]);const o={type:"Feature",properties:{source:"draw",pointCount:e.length},geometry:{type:"Polygon",coordinates:[t]}};return this.boundaryDrawingEnabled=!1,this.boundaryDrawPoints=[],this.lastBoundaryDrawPoint=null,this.analysisBoundaryFeature=o,(p=(h=this.callbacks).onDrawBoundary)==null||p.call(h,{status:"complete",feature:o,points:e,pointCount:e.length}),(g=(y=this.callbacks).onLayerStatus)==null||g.call(y,{type:"success",text:"分析边界已生成"}),this.redrawVectorTopicLayer(),o}clearAnalysisBoundary(){var e,t;return this.boundaryDrawingEnabled=!1,this.boundaryDrawPoints=[],this.lastBoundaryDrawPoint=null,this.analysisBoundaryFeature=null,this.analysisMatchedFeatures=[],this.redrawVectorTopicLayer(),(t=(e=this.callbacks).onDrawBoundary)==null||t.call(e,{status:"clear",points:[],pointCount:0}),!0}showAnalysisResult(e={}){var o;const t=Object.prototype.hasOwnProperty.call(e,"boundary")||Object.prototype.hasOwnProperty.call(e,"boundaryFeature")||Object.prototype.hasOwnProperty.call(e,"feature"),a=e.boundary||e.boundaryFeature||e.feature||null,i=Array.isArray(e.matches)?e.matches:[];return t&&(this.analysisBoundaryFeature=(a==null?void 0:a.type)==="Feature"?a:a!=null&&a.geometry?{type:"Feature",properties:a.properties||{},geometry:a.geometry}:null),this.analysisMatchedFeatures=i.map(l=>(l==null?void 0:l.feature)||l).filter(l=>l==null?void 0:l.geometry),e.preserveView||(!t&&this.analysisMatchedFeatures.length?this.focusAnalysisFeatures(this.analysisMatchedFeatures):(o=this.analysisBoundaryFeature)!=null&&o.geometry&&this.focusAnalysisGeometry(this.analysisBoundaryFeature.geometry)),this.redrawVectorTopicLayer(),!0}focusAnalysisFeatures(e=[]){const t=this.getFeatureListLngLatBounds(e);if(!t)return!1;const a=[(t.minLng+t.maxLng)/2,(t.minLat+t.maxLat)/2];return this.flyToLngLat(a,{span:Math.max(t.maxLng-t.minLng,t.maxLat-t.minLat),statusText:"已定位命中项目"})}focusAnalysisGeometry(e){const t=this.getGeometryLngLatBounds(e);if(!t)return!1;const a=[(t.minLng+t.maxLng)/2,(t.minLat+t.maxLat)/2];return this.flyToLngLat(a,{span:Math.max(t.maxLng-t.minLng,t.maxLat-t.minLat),statusText:"已定位分析边界"})}focusPasture(e={}){var i,o;const a=[...this.normalizePastureGrasslandRows(e==null?void 0:e.grasslands),...this.normalizePastureGrasslandRows(e==null?void 0:e.wkt)].map((l,u)=>{const h=this.normalizePastureGrasslandGeometry(l);if(!h)return null;const p=this.normalizePastureGrasslandProperties(l);return{type:"Feature",properties:E(I({},p),{id:p.id||p.gid||`${(e==null?void 0:e.name)||"pasture"}-${u}`,pasture_name:(e==null?void 0:e.name)||p.pastureName||p.name}),geometry:h}}).filter(Boolean);if(a.length){const l=this.getFeatureListLngLatBounds(a);if(!l)return!1;this.showSelectedFeatures(a,{mode:"pasture"}),this.setSelectedVectorFeatures(a);const u=[(l.minLng+l.maxLng)/2,(l.minLat+l.maxLat)/2];return this.flyToLngLat(u,{span:Math.max(l.maxLng-l.minLng,l.maxLat-l.minLat),statusText:"已定位具体草场"}),!0}return(o=(i=this.callbacks).onLayerStatus)==null||o.call(i,{type:"warning",text:"当前牧户暂无可定位数据"}),!1}normalizePastureGrasslandRows(e){return e?typeof e=="string"?[e]:Array.isArray(e)?e:(e==null?void 0:e.type)==="FeatureCollection"&&Array.isArray(e.features)?e.features:(e==null?void 0:e.type)==="Feature"||this.isGeoJsonGeometry(e)?[e]:Array.isArray(e==null?void 0:e.rows)?e.rows:Array.isArray(e==null?void 0:e.data)?e.data:e!=null&&e.data?this.normalizePastureGrasslandRows(e.data):Array.isArray(e==null?void 0:e.list)?e.list:Array.isArray(e==null?void 0:e.features)?e.features:e!=null&&e.wkt||e!=null&&e.geo||e!=null&&e.geom||e!=null&&e.geometryWkt||e!=null&&e.geometry_wkt||e!=null&&e.shape||e!=null&&e.location||e!=null&&e.geometry?[e]:[]:[]}normalizePastureGrasslandGeometry(e){var t;return typeof e=="string"?this.parseGeometryText(e):(e==null?void 0:e.type)==="Feature"?this.normalizePastureGrasslandGeometry(e.geometry):this.isGeoJsonGeometry(e)?e:typeof(e==null?void 0:e.geometry)=="string"?this.parseGeometryText(e.geometry):((t=e==null?void 0:e.geometry)==null?void 0:t.type)==="Feature"?this.normalizePastureGrasslandGeometry(e.geometry.geometry):this.isGeoJsonGeometry(e==null?void 0:e.geometry)?e.geometry:this.parseGeometryText((e==null?void 0:e.wkt)||(e==null?void 0:e.geo)||(e==null?void 0:e.geom)||(e==null?void 0:e.geometryWkt)||(e==null?void 0:e.geometry_wkt)||(e==null?void 0:e.shape)||(e==null?void 0:e.location))}normalizePastureGrasslandProperties(e){return!e||typeof e!="object"||Array.isArray(e)?{wkt:e}:e.type==="Feature"?e.properties||{}:e}parseGeometryText(e){const t=String(e||"").trim();if(!t)return null;if(t.startsWith("{")||t.startsWith("["))try{const a=JSON.parse(t);if((a==null?void 0:a.type)==="Feature")return this.normalizePastureGrasslandGeometry(a);if(this.isGeoJsonGeometry(a))return a}catch(a){return null}return this.parseWktGeometry(t)}isGeoJsonGeometry(e){return!!(e&&["Polygon","MultiPolygon","LineString","MultiLineString","Point"].includes(e.type)&&e.coordinates)}flyToLngLat(e,t={}){var g,w;const a=Array.isArray(e)?e:[e==null?void 0:e.lng,e==null?void 0:e.lat],i=Number(a==null?void 0:a[0]),o=Number(a==null?void 0:a[1]);if(!Number.isFinite(i)||!Number.isFinite(o))return!1;const l=Number(t.span),u=Number.isFinite(l)?Math.max(.2,Math.min(.55,l*1.25)):.32,h=this.lngLatToWorldPoint([i,o],.72),p=this.defaultMapCameraPosition.clone().sub(this.defaultMapTarget).multiplyScalar(u),y=h.clone().add(p);return this.animateMapCamera(y,h,t.duration||.75),(w=(g=this.callbacks).onLayerStatus)==null||w.call(g,{type:"success",text:t.statusText||"已定位"}),!0}getProjectHighlightFeatures(e){const t=e.filter(i=>{var l;const o=String(((l=i==null?void 0:i.geometry)==null?void 0:l.type)||"");return o.includes("Polygon")||o.includes("LineString")}),a=t.filter(i=>{var o;return((o=i==null?void 0:i.properties)==null?void 0:o.feature_role)==="工程范围"});return a.length?a:t}getFeatureListLngLatBounds(e){return e.reduce((t,a)=>{const i=this.getGeometryLngLatBounds(a.geometry);return i?t?{minLng:Math.min(t.minLng,i.minLng),minLat:Math.min(t.minLat,i.minLat),maxLng:Math.max(t.maxLng,i.maxLng),maxLat:Math.max(t.maxLat,i.maxLat)}:I({},i):t},null)}isPointOrLineNearLngLat(e,t){return e!=null&&e.coordinates?e.type==="Point"?this.getCoordinateDistance(e.coordinates,[t.lng,t.lat])<=.02:e.type==="LineString"?this.isCoordinateNearLine(e.coordinates,t,.004):e.type==="MultiLineString"?e.coordinates.some(a=>this.isCoordinateNearLine(a,t,.004)):!1:!1}isCoordinateNearLine(e,t,a){if(!Array.isArray(e)||e.length<2)return!1;const i=[t.lng,t.lat];for(let o=1;o<e.length;o+=1)if(this.getCoordinateSegmentDistance(i,e[o-1],e[o])<=a)return!0;return!1}getCoordinateDistance(e,t){return Math.hypot(Number(e==null?void 0:e[0])-Number(t==null?void 0:t[0]),Number(e==null?void 0:e[1])-Number(t==null?void 0:t[1]))}getCoordinateSegmentDistance(e,t,a){const i=Number(t==null?void 0:t[0]),o=Number(t==null?void 0:t[1]),l=Number(a==null?void 0:a[0])-i,u=Number(a==null?void 0:a[1])-o;if(!Number.isFinite(l)||!Number.isFinite(u))return Number.POSITIVE_INFINITY;if(!l&&!u)return this.getCoordinateDistance(e,t);const h=Math.max(0,Math.min(1,((e[0]-i)*l+(e[1]-o)*u)/(l*l+u*u)));return this.getCoordinateDistance(e,[i+h*l,o+h*u])}getLayerTopicKey(e){const t=e==null?void 0:e.layerName,a=e==null?void 0:e.key,i=Object.entries(I(I({},Dr),_c)).find(([,o])=>o.some(l=>l.key===a||l.layerName===t));return(i==null?void 0:i[0])||""}getLayerQueryKey(e){return[(e==null?void 0:e.layerName)||"",(e==null?void 0:e.styles)||"",(e==null?void 0:e.cqlFilter)||"",(e==null?void 0:e.key)||""].join("|")}mergeBusinessProperties(e,t,a){const i=(a==null?void 0:a.key)||"";if(Object.entries(t||{}).forEach(([o,l])=>{l==null||l===""||(e[o]===void 0||e[o]===null||e[o]==="")&&(e[o]=l)}),i==="basic-grassland"){const o=(t==null?void 0:t.basic_type_name)||(t==null?void 0:t.grassland_category_name)||(t==null?void 0:t.land_class_name)||(t==null?void 0:t.land_use_name)||(t==null?void 0:t.base_grass);o!=null&&o!==""&&(e.basic_type_name=o)}if(i==="grassland-level"){const o=(t==null?void 0:t.grassland_level)||(t==null?void 0:t.level)||(t==null?void 0:t.grassland_level_name)||(t==null?void 0:t.level_name);o!=null&&o!==""&&(e.grassland_level=o)}if(i==="grassland-type"||i==="wetland-type"){const o=(t==null?void 0:t.grass_min_type)||(t==null?void 0:t.grass_type)||(t==null?void 0:t.grassland_type)||(t==null?void 0:t.type_name)||(t==null?void 0:t.type);o!=null&&o!==""&&(e.grass_min_type=o)}if(i==="grassland-yield"||i==="wetland-yield"){const o=(t==null?void 0:t.yield)||(t==null?void 0:t.xc_yield)||(t==null?void 0:t.xb_xc_yield)||(t==null?void 0:t.fresh_grass_yield)||(t==null?void 0:t.value),l=(t==null?void 0:t.mu_yield)||(t==null?void 0:t.xc_mu_yield)||(t==null?void 0:t.xb_xc_mu_yield)||(t==null?void 0:t.yield_per_mu);o!=null&&o!==""&&(e.fresh_grass_yield=o),l!=null&&l!==""&&(e.mu_yield=l)}if(i==="grassland-health"){const o=(t==null?void 0:t.health_level)||(t==null?void 0:t.health_level_name)||(t==null?void 0:t.ndvi_level)||(t==null?void 0:t.level)||(t==null?void 0:t.level_name),l=(t==null?void 0:t.ndvi)||(t==null?void 0:t.NDVI)||(t==null?void 0:t.value);o!=null&&o!==""&&(e.health_level=o),l!=null&&l!==""&&(e.ndvi=l);const u=(t==null?void 0:t.degradation_level)||(t==null?void 0:t.degradation_level_name)||(t==null?void 0:t.level)||(t==null?void 0:t.level_name);u!=null&&u!==""&&(e.degradation_level=u)}}getScreenPointFromEvent(e){var a;const t=((a=e==null?void 0:e.data)==null?void 0:a.originalEvent)||(e==null?void 0:e.originalEvent)||e;return(t==null?void 0:t.clientX)!==void 0&&(t==null?void 0:t.clientY)!==void 0?{x:t.clientX,y:t.clientY}:null}getLngLatFromEvent(e){var u,h,p;const a=(p=(((h=(u=this.interactionManager)==null?void 0:u.raycaster)==null?void 0:h.intersectObject(e.target,!1))||[])[0])==null?void 0:p.point;if(!a)return null;const i=this.focusMapGroup.worldToLocal(a.clone()),l=sa().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0]).invert([i.x,-i.y]);return l?{lng:l[0],lat:l[1]}:null}lngLatToWmsPixel({lng:e,lat:t}){const a=(e-q.west)/(q.east-q.west)*St.width,i=(q.north-t)/(q.north-q.south)*St.height;return{x:a,y:i}}showSelectedFeature(e,t={}){var i;const a=(e==null?void 0:e.geometry)||((i=e==null?void 0:e.feature)==null?void 0:i.geometry);this.clearSelectedFeature(),this.createSelectedFeatureGroup(),this.addSelectedGeometry(a,t),this.selectedFeatureGroup.children.length||this.clearSelectedFeature()}showSelectedFeatures(e=[],t={}){this.clearSelectedFeature(),this.createSelectedFeatureGroup(),e.forEach(a=>{var o;const i=(a==null?void 0:a.geometry)||((o=a==null?void 0:a.feature)==null?void 0:o.geometry);this.addSelectedGeometry(i,t)}),this.selectedFeatureGroup.children.length||this.clearSelectedFeature()}setSelectedVectorFeatures(e=[]){this.selectedVectorFeatures=[...e],this.redrawVectorTopicLayer()}getSelectedFeatureStyle(e={}){const t=e.mode==="pasture",a=e.mode==="town";return{fillColor:Os,fillOpacity:t?.46:a?.24:.54,lineColor:pd,lineOpacity:.98,glowColor:Ws,glowOpacity:t?.92:.96,renderOrderBase:t?42:a?40:35,boundary:t||a,boundaryColor:Os,boundaryGlowColor:Ws,boundaryWidth:a?.012:.018,boundaryGlowWidth:a?.045:.06,boundaryOpacity:.95,boundaryGlowOpacity:a?.34:.42}}addSelectedGeometry(e,t={}){if(!(e!=null&&e.coordinates)||!this.selectedFeatureGroup)return;const a=this.getSelectedFeatureStyle(t),i=this.getDisplayFeaturePolygons(e),o=new ke({color:a.fillColor,transparent:!0,opacity:a.fillOpacity,side:Ee,depthWrite:!1,fog:!1}),l=new ga({color:a.lineColor,transparent:!0,opacity:a.lineOpacity,linewidth:2,depthTest:!1,depthWrite:!1,fog:!1}),u=new ga({color:a.glowColor,transparent:!0,opacity:a.glowOpacity,linewidth:3,depthTest:!1,depthWrite:!1,fog:!1}),h=a.boundary?new ke({color:a.boundaryColor,transparent:!0,opacity:a.boundaryOpacity,side:Ee,depthTest:!1,depthWrite:!1,fog:!1}):null,p=a.boundary?new ke({color:a.boundaryGlowColor,transparent:!0,opacity:a.boundaryGlowOpacity,side:Ee,depthTest:!1,depthWrite:!1,fog:!1,blending:Ve}):null;i.length&&i.forEach(g=>{const w=this.createProjectedShape(g);if(!w)return;const C=new hc(w),F=new Qe(C,o);F.renderOrder=a.renderOrderBase,this.selectedFeatureGroup.add(F),g.forEach(x=>{const G=this.createProjectedRingPoints(x);if(G.length<3)return;a.boundary&&(this.addSelectedBoundaryBand(G,p,a.boundaryGlowWidth,a.renderOrderBase+1,!0),this.addSelectedBoundaryBand(G,h,a.boundaryWidth,a.renderOrderBase+4,!0));const H=new Va().setFromPoints(G),J=new ks(H,l);J.renderOrder=a.renderOrderBase+5,this.selectedFeatureGroup.add(J);const ne=new Va().setFromPoints(G),K=new ks(ne,u);K.renderOrder=a.renderOrderBase+3,K.scale.set(1.004,1.004,1),this.selectedFeatureGroup.add(K)})});const y=this.normalizeFeatureLineStrings(e);y.length&&y.forEach(g=>{const w=this.createProjectedRingPoints(g);if(w.length<2)return;a.boundary&&(this.addSelectedBoundaryBand(w,p,a.boundaryGlowWidth,a.renderOrderBase+1,!1),this.addSelectedBoundaryBand(w,h,a.boundaryWidth,a.renderOrderBase+4,!1));const C=new Va().setFromPoints(w),F=new Ms(C,u);F.renderOrder=a.renderOrderBase+3,F.scale.set(1.004,1.004,1),this.selectedFeatureGroup.add(F);const x=new Va().setFromPoints(w),G=new Ms(x,l);G.renderOrder=a.renderOrderBase+5,this.selectedFeatureGroup.add(G)})}addSelectedBoundaryBand(e,t,a,i,o=!0){if(!t||!this.selectedFeatureGroup)return;const l=this.createPathBandGeometry(e,a,o);if(!l)return;const u=new Qe(l,t);u.renderOrder=i,this.selectedFeatureGroup.add(u)}createPathBandGeometry(e,t,a=!0){const i=this.normalizePathBandPoints(e,a);if(i.length<(a?3:2))return null;const o=Math.max(Number(t)||0,0)/2;if(!o)return null;const l=[],u=a?i.length:i.length-1;for(let p=0;p<u;p+=1){const y=i[p],g=i[(p+1)%i.length],w=g.x-y.x,C=g.y-y.y,F=Math.hypot(w,C);if(!F)continue;const x=-C/F*o,G=w/F*o,H=[y.x+x,y.y+G,.006],J=[y.x-x,y.y-G,.006],ne=[g.x+x,g.y+G,.006],K=[g.x-x,g.y-G,.006];l.push(...H,...J,...ne,...ne,...J,...K)}if(!l.length)return null;const h=new Va;return h.setAttribute("position",new pc(l,3)),h.computeVertexNormals(),h}normalizePathBandPoints(e,t){const a=(e||[]).filter(i=>Number.isFinite(i==null?void 0:i.x)&&Number.isFinite(i==null?void 0:i.y)).map(i=>i.clone());if(t&&a.length>2){const i=a[0],o=a[a.length-1];i.distanceToSquared(o)<1e-10&&a.pop()}return a}clearSelectedFeature(){var t;const e=!!((t=this.selectedVectorFeatures)!=null&&t.length);this.selectedVectorFeatures=[],e&&this.redrawVectorTopicLayer(),this.clearSelectedGeometryGroup()}clearSelectedGeometryGroup(){var t,a;if(!this.selectedFeatureGroup)return;const e=new Set;for(;this.selectedFeatureGroup.children.length;){const i=this.selectedFeatureGroup.children.pop();(a=(t=i.geometry)==null?void 0:t.dispose)==null||a.call(t),Array.isArray(i.material)?i.material.forEach(o=>e.add(o)):e.add(i.material)}e.forEach(i=>{var o;return(o=i==null?void 0:i.dispose)==null?void 0:o.call(i)})}normalizeFeaturePolygons(e){return Js(e)}normalizeFeatureLineStrings(e){return e!=null&&e.coordinates?e.type==="LineString"?[e.coordinates]:e.type==="MultiLineString"?e.coordinates:[]:[]}getDisplayFeaturePolygons(e){const t=this.normalizeFeaturePolygons(e),a=this.getLayerClipBounds(this.currentTopicLayer);return a?t.map(i=>{const o=this.clipRingToBounds(i==null?void 0:i[0],a);if(o.length<3)return null;const l=i.slice(1).map(u=>this.clipRingToBounds(u,a)).filter(u=>u.length>=3);return[o,...l]}).filter(Boolean):t}clipRingToBounds(e=[],t){let a=e.map(o=>[Number(o==null?void 0:o[0]),Number(o==null?void 0:o[1])]).filter(([o,l])=>Number.isFinite(o)&&Number.isFinite(l));return[{inside:([o])=>o>=t.west,intersect:(o,l)=>this.getLngLatLineIntersection(o,l,"lng",t.west)},{inside:([o])=>o<=t.east,intersect:(o,l)=>this.getLngLatLineIntersection(o,l,"lng",t.east)},{inside:([,o])=>o>=t.south,intersect:(o,l)=>this.getLngLatLineIntersection(o,l,"lat",t.south)},{inside:([,o])=>o<=t.north,intersect:(o,l)=>this.getLngLatLineIntersection(o,l,"lat",t.north)}].forEach(o=>{const l=a;a=[],l.length&&l.forEach((u,h)=>{const p=l[(h+l.length-1)%l.length],y=o.inside(u),g=o.inside(p);y?(g||a.push(o.intersect(p,u)),a.push(u)):g&&a.push(o.intersect(p,u))})}),a}getLngLatLineIntersection(e,t,a,i){const o=a==="lng"?0:1,l=a==="lng"?1:0,u=t[o]-e[o];if(!u)return[...e];const h=(i-e[o])/u,p=[...e];return p[o]=i,p[l]=e[l]+(t[l]-e[l])*h,p}createProjectedShape(e){const t=e==null?void 0:e[0];if(!Array.isArray(t)||t.length<3)return null;const a=new Cs;return this.createProjectedRingPoints(t).forEach((o,l)=>{l===0?a.moveTo(o.x,o.y):a.lineTo(o.x,o.y)}),e.slice(1).forEach(o=>{const l=this.createProjectedRingPoints(o);if(l.length<3)return;const u=new Cs;l.forEach((h,p)=>{p===0?u.moveTo(h.x,h.y):u.lineTo(h.x,h.y)}),a.holes.push(u)}),a}createProjectedRingPoints(e){if(!Array.isArray(e))return[];const t=[];return e.forEach(a=>{if(!Array.isArray(a)||a.length<2)return;const i=Number(a[0]),o=Number(a[1]);if(!Number.isFinite(i)||!Number.isFinite(o))return;const[l,u]=this.geoProjection([i,o]);t.push(new le(l,-u,0))}),t}enhanceTexture(e){var a,i,o;const t=(i=(a=this.renderer)==null?void 0:a.instance)==null?void 0:i.capabilities;e.anisotropy=((o=t==null?void 0:t.getMaxAnisotropy)==null?void 0:o.call(t))||1,e.needsUpdate=!0}geoProjection(e){return sa().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0])(e)}updateTownLabelScale(){var u,h,p;const e=this.townNameLabels||this.otherLabel||[],t=(u=this.camera)==null?void 0:u.instance,a=(p=(h=this.camera)==null?void 0:h.controls)==null?void 0:p.target;if(!e.length||!t||!a)return;const i=t.position.distanceTo(a),o=na(i*72e-5,.011,.026),l=i>45?"0.76":i<22?"0.94":"1";e.forEach(y=>{var w,C,F;if(((w=y==null?void 0:y.userData)==null?void 0:w.labelType)!=="town-label")return;y.scale.set(o,o,o);const g=(F=(C=y.element)==null?void 0:C.querySelector)==null?void 0:F.call(C,".other-label");g&&(g.style.opacity=l)})}update(e){super.update(e),this.updateDynamicSatelliteTiles(),this.updateTownLabelScale(),this.updateTradeFlowPulses(e),this.interactionManager&&this.interactionManager.update()}pauseScene(){var e,t;this.scenePaused=!0,(t=(e=this.time)==null?void 0:e.pause)==null||t.call(e),this.sceneTweens.forEach(a=>{var i;return(i=a==null?void 0:a.pause)==null?void 0:i.call(a)}),clearInterval(this.infoPointLabelTime),this.infoPointLabelTime=null}resumeScene(){var e,t;this.scenePaused=!1,(t=(e=this.time)==null?void 0:e.resume)==null||t.call(e),this.sceneTweens.forEach(a=>{var i;return(i=a==null?void 0:a.resume)==null?void 0:i.call(a)}),this.showTownRankingPointMarkers&&this.mapAnimationComplete&&!this.infoPointLabelTime&&this.createInfoPointLabelLoop()}destroy(){var e,t,a,i;this.pauseScene(),this.sceneTimers.forEach(o=>clearTimeout(o)),this.sceneTimers=[],this.sceneTweens.forEach(o=>{var l;return(l=o==null?void 0:o.kill)==null?void 0:l.call(o)}),this.sceneTweens=[],this.callbacks={},(t=(e=this.canvas)==null?void 0:e.removeEventListener)==null||t.call(e,"pointerdown",this.handleCanvasBoundaryPointerDown,!0),(i=(a=this.canvas)==null?void 0:a.removeEventListener)==null||i.call(a,"dblclick",this.handleCanvasBoundaryDoubleClick,!0),this.clearTradeFlowLayer(),this.clearSelectedFeature(),super.destroy(),this.label3d&&this.label3d.destroy()}}const Td={class:"map"},Sd={__name:"map",props:{activeLayer:{type:Object,default:null},mapRanking:{type:Object,default:null},tileUrlTemplate:{type:String,default:""},satelliteTextureZoom:{type:Number,default:0},satelliteMaxZoom:{type:Number,default:21},adminBoundaryLineScale:{type:Number,default:1},useSatelliteBase:{type:Boolean,default:!0},showNationalBackdrop:{type:Boolean,default:!1},topicLayerPresentation:{type:String,default:"default"},hideTownLabelStats:{type:Boolean,default:!1}},emits:["feature-loading","feature-info","layer-status","tile-status","draw-boundary","scene-mounted"],setup(m,{expose:e,emit:t}){const a=m,i=t,o=_(null),l=Xu(null);let u=null,h=null,p=null,y=null,g=null,w="",C="",F=!1;io(()=>{i("scene-mounted")}),so(()=>{ft()});function x(M){return l.value?!0:o.value?(l.value=new Ld(o.value,M,{onFeatureLoading:L=>i("feature-loading",L),onFeatureInfo:L=>i("feature-info",L),onLayerStatus:L=>i("layer-status",L),onTileStatus:L=>i("tile-status",L),onDrawBoundary:L=>i("draw-boundary",L),tileUrlTemplate:a.tileUrlTemplate,satelliteTextureZoom:a.satelliteTextureZoom,satelliteMaxZoom:a.satelliteMaxZoom,adminBoundaryLineScale:a.adminBoundaryLineScale,useSatelliteBase:a.useSatelliteBase,showNationalBackdrop:a.showNationalBackdrop,topicLayerPresentation:a.topicLayerPresentation,hideTownLabelStats:a.hideTownLabelStats}),l.value.time.pause(),w=De(a.activeLayer),C=Be(a.mapRanking),l.value.setTopicLayers(ze(a.activeLayer),a.activeLayer),l.value.setTownRanking(a.mapRanking),qe(),Me(),!0):!1}function G(){return!!l.value}function H(){return oe(this,null,function*(){var M,L,A,D,Z,re;if(l.value&&(J(),!l.value.mapAnimationComplete)){if(F){(L=(M=l.value.animateTl)==null?void 0:M.play)==null||L.call(M),Ne();return}F=!0,(D=(A=l.value.animateTl)==null?void 0:A.timeScale)==null||D.call(A,1),(re=(Z=l.value.animateTl)==null?void 0:Z.play)==null||re.call(Z),Ne()}})}function J(){var M,L;l.value&&(qe(),Me(),window.requestAnimationFrame(()=>{var A,D,Z,re,fe,Le;(Z=(D=(A=l.value)==null?void 0:A.label3d)==null?void 0:D.resize)==null||Z.call(D),(Le=(fe=(re=l.value)==null?void 0:re.label3d)==null?void 0:fe.update)==null||Le.call(fe)}),(L=(M=l.value).resumeScene)==null||L.call(M),l.value.resumeScene||l.value.time.resume())}function ne(){var M,L,A,D,Z,re;l.value&&(it(),(L=(M=l.value.animateTl)==null?void 0:M.pause)==null||L.call(M),(D=(A=l.value).pauseScene)==null||D.call(A),l.value.pauseScene||(re=(Z=l.value.time)==null?void 0:Z.pause)==null||re.call(Z),Fe())}function K(){var M,L;(L=(M=l.value)==null?void 0:M.clearSelectedFeature)==null||L.call(M)}function V(M){var L,A;(A=(L=l.value)==null?void 0:L.focusProject)==null||A.call(L,M)}function se(M){var L,A;(A=(L=l.value)==null?void 0:L.focusPasture)==null||A.call(L,M)}function Ye(M,L){var A,D;return(D=(A=l.value)==null?void 0:A.focusTownByName)==null?void 0:D.call(A,M,L)}function rt(M){var L,A;return(A=(L=l.value)==null?void 0:L.focusYakIndustryPoint)==null?void 0:A.call(L,M)}function At(M){var L,A;return(A=(L=l.value)==null?void 0:L.focusVectorFeature)==null?void 0:A.call(L,M)}function kt(M){var L,A;return(A=(L=l.value)==null?void 0:L.getVectorFeatureScreen)==null?void 0:A.call(L,M)}function z(M){var L,A;return(A=(L=l.value)==null?void 0:L.getYakIndustryPointScreen)==null?void 0:A.call(L,M)}function ht(M){var L,A;(A=(L=l.value)==null?void 0:L.setBoundaryDrawing)==null||A.call(L,M)}function Mt(){var M,L;return(L=(M=l.value)==null?void 0:M.finishBoundaryDrawing)==null?void 0:L.call(M)}function Bt(){var M,L;(L=(M=l.value)==null?void 0:M.undoBoundaryPoint)==null||L.call(M)}function pt(){var M,L;(L=(M=l.value)==null?void 0:M.clearAnalysisBoundary)==null||L.call(M)}function $t(M){var L,A;(A=(L=l.value)==null?void 0:L.showAnalysisResult)==null||A.call(L,M)}function ft(){var M,L;it(),Fe(),(L=(M=l.value)==null?void 0:M.destroy)==null||L.call(M),l.value=null}function Ne(){it(),g=window.setTimeout(()=>{var M,L;g=null,(L=(M=l.value)==null?void 0:M.ensureMapRevealed)==null||L.call(M)},5200)}function it(){g&&(window.clearTimeout(g),g=null)}function Me(){h&&window.cancelAnimationFrame(h),h=window.requestAnimationFrame(()=>{var M,L,A,D,Z;h=null,(A=(L=(M=l.value)==null?void 0:M.sizes)==null?void 0:L.init)==null||A.call(L),(Z=(D=l.value)==null?void 0:D.resize)==null||Z.call(D)}),p&&window.clearTimeout(p),p=window.setTimeout(()=>{var M,L,A,D,Z;p=null,(A=(L=(M=l.value)==null?void 0:M.sizes)==null?void 0:L.init)==null||A.call(L),(Z=(D=l.value)==null?void 0:D.resize)==null||Z.call(D)},180)}function qe(){var L;Fe();const M=(L=o.value)==null?void 0:L.parentNode;M&&window.ResizeObserver&&(u=new ResizeObserver(()=>Me()),u.observe(M)),y=window.setInterval(_e,1e3),ia(Me)}function _e(){var fe;if(!l.value||!o.value)return;const M=o.value.parentNode,L=(M==null?void 0:M.offsetWidth)||window.innerWidth||1,A=(M==null?void 0:M.offsetHeight)||window.innerHeight||1,D=((fe=l.value.sizes)==null?void 0:fe.pixelRatio)||1,Z=Math.floor(L*D),re=Math.floor(A*D);(o.value.width!==Z||o.value.height!==re)&&Me()}function Fe(){u&&(u.disconnect(),u=null),h&&(window.cancelAnimationFrame(h),h=null),p&&(window.clearTimeout(p),p=null),y&&(window.clearInterval(y),y=null)}function Et(){if(!l.value)return;qe();const M=()=>{var L,A,D,Z,re,fe,Le,je,Je,Oe,Ge,Ue,He,st,me,ge,ie,mt,Vt,be,qt;l.value&&((A=(L=l.value)==null?void 0:L.resumeScene)==null||A.call(L),l.value.resumeScene||(Z=(D=l.value.time)==null?void 0:D.resume)==null||Z.call(D),(Le=(fe=(re=l.value)==null?void 0:re.sizes)==null?void 0:fe.init)==null||Le.call(fe),(Je=(je=l.value)==null?void 0:je.resize)==null||Je.call(je),(Ue=(Ge=(Oe=l.value)==null?void 0:Oe.label3d)==null?void 0:Ge.resize)==null||Ue.call(Ge),(me=(st=(He=l.value)==null?void 0:He.label3d)==null?void 0:st.update)==null||me.call(st),(ie=(ge=l.value)==null?void 0:ge.setTopicLayers)==null||ie.call(ge,ze(a.activeLayer),a.activeLayer),(Vt=(mt=l.value)==null?void 0:mt.setTownRanking)==null||Vt.call(mt,a.mapRanking),(qt=(be=l.value)==null?void 0:be.ensureMapRevealed)==null||qt.call(be))};Me(),window.requestAnimationFrame(M),window.setTimeout(()=>{M()},80),window.setTimeout(()=>{M()},220)}function Ct(){if(!l.value)return;qe();const M=()=>{var A,D,Z,re,fe,Le,je,Je,Oe,Ge,Ue,He,st,me,ge,ie;const L=l.value;L&&((A=L.resumeScene)==null||A.call(L),L.resumeScene||(Z=(D=L.time)==null?void 0:D.resume)==null||Z.call(D),(fe=(re=L.sizes)==null?void 0:re.init)==null||fe.call(re),(Le=L.resize)==null||Le.call(L),(je=L.ensureMapRevealed)==null||je.call(L),(Je=L.setTradeNationalMapVisible)==null||Je.call(L,!1),(Oe=L.setTopicLayers)==null||Oe.call(L,ze(a.activeLayer),a.activeLayer),(Ge=L.setTownRanking)==null||Ge.call(L,a.mapRanking),(Ue=L.applyLayerMapView)==null||Ue.call(L,L.currentTopicLayer||a.activeLayer||null,{force:!0}),(st=(He=L.label3d)==null?void 0:He.resize)==null||st.call(He),(ge=(me=L.label3d)==null?void 0:me.update)==null||ge.call(me),(ie=L.updateDynamicSatelliteTiles)==null||ie.call(L,!0))};Me(),window.requestAnimationFrame(M),window.setTimeout(M,100),window.setTimeout(M,260)}oa(()=>a.activeLayer,M=>{const L=De(M);L!==w&&(w=L,l.value&&l.value.setTopicLayers(ze(M),M))},{deep:!0}),oa(()=>a.mapRanking,M=>{const L=Be(M);L!==C&&(C=L,l.value&&l.value.setTownRanking(M))},{deep:!0}),e({loadMap:x,hasMap:G,play:H,resume:J,pause:ne,clearSelectedFeature:K,focusProject:V,focusPasture:se,focusTown:Ye,focusYakIndustryPoint:rt,focusVectorFeature:At,getVectorFeatureScreen:kt,getYakIndustryPointScreen:z,setBoundaryDrawing:ht,finishBoundaryDrawing:Mt,undoBoundaryPoint:Bt,clearAnalysisBoundary:pt,showAnalysisResult:$t,refreshView:Et,resetView:Ct,destroyMap:ft,canvasMap:l});function De(M){return M?ze(M).map(L=>{var A,D;return[L.key||"",L.layerName||"",L.styles||"",L.sldBody||"",L.cqlFilter||"",((A=L.activeLegend)==null?void 0:A.key)||"",Array.isArray(L.activeLegends)?L.activeLegends.map(Z=>(Z==null?void 0:Z.key)||"").join(","):"",L.timelineDate||"",((D=L.timelineItem)==null?void 0:D.key)||"",L.sourceType||"",L.dataPath||"",L.fallbackPath||""].join("|")}).join("||"):""}function ze(M){if(!M)return[];const L=Array.isArray(M.overlayLayers)?M.overlayLayers.filter(Boolean):[];return[M,...L]}function Be(M){var L,A,D,Z,re,fe,Le,je,Je,Oe,Ge;return M?[M.status||"",M.topicKey||"",M.layerKey||"",M.title||"",M.metricLabel||"",M.scope||"",M.displayMode||"",(L=M.showPointMarkers)!=null?L:"",(A=M.showBars)!=null?A:"",(D=M.showTownNames)!=null?D:"",(Z=M.showMapLabels)!=null?Z:"",(re=M.hideTownLabelStats)!=null?re:"",(fe=M.showFlowLines)!=null?fe:"",(Le=M.nationalFlow)!=null?Le:"",(je=M.onlyRankedTownLabels)!=null?je:"",(Je=M.showMissingTownStats)!=null?Je:"",((Oe=M.rows)==null?void 0:Oe.length)||0,((Ge=M.rows)==null?void 0:Ge.map(Ue=>{var He;return`${Ue.key||Ue.name||""}:${(He=Ue.value)!=null?He:""}`}).join(","))||""].join("|"):""}return(M,L)=>(P(),N("div",Td,[d("canvas",{ref_key:"canvasRef",ref:o},null,512)]))}};let uo=0,co=0,ho=0,_t=0;const po=[],Sa=[],qr=[],Vn=[],Gt=[],Ur=[],fo=[];function kd(m={}){const e=new Map((m.metrics||[]).map(t=>[t.key,Number(t.value||0)]));uo=e.get("recognition_count")||0,co=e.get("expert_correction")||0,ho=e.get("trade_deduction")||0,_t=e.get("estimated_stock")||0,ra(po,m.towns,t=>{var a,i;return{key:t.key,name:t.name,count:Number((i=(a=t.count)!=null?a:t.value)!=null?i:0),recognitionCount:Number(t.recognitionCount||0),devices:Number(t.devices||0)}}),ra(Sa,m.structure,t=>{var a,i;return{key:t.key,name:t.name,count:Number((i=(a=t.count)!=null?a:t.value)!=null?i:0),ratio:Number(t.ratio||0)}}),ra(Vn,m.genderAge,t=>({age:t.age,cow:Number(t.cow||0),bull:Number(t.bull||0)})),ra(Gt,m.forecastPeriods,t=>E(I({},t),{key:String(t.key),shortLabel:t.shortLabel||String(t.key),months:Number(t.months||0),stock:Number(t.stock||0),births:Number(t.births||0),outflow:Number(t.outflow||0),correction:Number(t.correction||0)})),ra(Ur,m.forecastFactors,t=>E(I({},t),{value:Number(t.value||0)})),ra(qr,m.tradeImpacts,(t,a)=>E(I({},t),{value:Number(t.value||0),yoy:Number(t.yoy||0),color:["#48cfff","#30dcff","#8bf7ff","#48cfff"][a%4]})),ra(fo,m.forecastMonths,t=>({month:t.month,count:Number(t.count||0),speed:Number(t.speed||0)}))}function ra(m,e,t){m.splice(0,m.length,...Array.isArray(e)?e.map(t):[])}function Dn(m){return String(m||"").trim()}function Md(m){return Gt.find(e=>e.key===m)||Gt[1]||Gt[0]||{key:String(m||""),label:"暂无预测",shortLabel:"--",months:1,stock:_t,births:0,outflow:0,correction:0,structure:{}}}function Cd(m){return(Array.isArray(m==null?void 0:m.structureRows)?m.structureRows:[]).map(e=>E(I({},e),{count:Number(e.count||0),ratio:Number(e.ratio||0)}))}function Pd(m){return(Array.isArray(m==null?void 0:m.townRows)?m.townRows:[]).map(e=>E(I({},e),{count:Number(e.count||0),forecast:Number(e.forecast||0),change:Number(e.change||0)}))}function Nd(m){var t;const e=((t=m==null?void 0:m.series)==null?void 0:t.month)||{};return{labels:Array.isArray(e.labels)?e.labels:[],stock:Array.isArray(e.stock)?e.stock.map(Number):[],births:Array.isArray(e.births)?e.births.map(Number):[],outflow:Array.isArray(e.outflow)?e.outflow.map(Number):[]}}function Fd(m){const e=new Map;return m.forEach(t=>{const a=Dn(t.name),i=e.get(a)||{name:a,count:0};i.count+=Number(t.count||0),e.set(a,i)}),[...e.values()].sort((t,a)=>a.count-t.count)}const xd={class:"yak-management"},Rd={key:0},Id={class:"yak-management-ui"},_d={key:0,class:"trade-year-switcher","aria-label":"交易年份切换"},Gd=["onClick"],Ad={key:1,class:"slaughter-year-switcher","aria-label":"出栏年份切换"},Bd=["aria-pressed","onClick"],$d={key:2,class:"epidemic-year-switcher","aria-label":"防疫年份切换"},Ed=["onClick"],Vd={key:3,class:"forecast-year-switcher","aria-label":"预测年份切换"},Dd=["onClick"],zd={class:"slaughter-realtime-status"},Od={class:"slaughter-realtime-viewport"},Wd={class:"yak-left"},Yd={class:"yak-side-stack is-left"},jd={class:"breeding-health-card"},Hd={class:"breeding-health-head"},qd={class:"breeding-health-grid"},Ud={class:"structure-chart-card"},Kd={class:"structure-ratio-card"},Zd={class:"structure-ratio-chart"},Xd={viewBox:"0 0 150 150",preserveAspectRatio:"xMidYMid meet","aria-hidden":"true"},Qd={class:"structure-rose-segments"},Jd=["d","fill","stroke"],eh={class:"structure-ratio-list"},th={key:0,class:"yak-data-status"},ah={key:1,class:"yak-data-status is-warning"},nh={class:"forecast-waterfall-card"},rh={class:"forecast-waterfall-head"},ih={class:"forecast-waterfall-list"},sh={class:"forecast-trend-card"},oh={class:"forecast-density-switcher","aria-label":"预测粒度切换"},lh=["onClick"],uh={key:0,class:"epidemic-three-pie-card"},ch={class:"epidemic-three-pie-visual"},dh={class:"epidemic-three-pie-center"},hh={class:"epidemic-three-pie-legend"},ph={key:1,class:"epidemic-empty"},fh={class:"trade-risk-card"},mh={class:"trade-risk-head"},gh={class:"trade-risk-list"},yh={key:1,class:"epidemic-empty"},vh={key:1,class:"epidemic-empty"},bh={key:1,class:"epidemic-empty"},wh={key:0,class:"slaughter-direction-card"},Lh={class:"slaughter-direction-track","aria-label":"省内、省外流向占比"},Th={class:"slaughter-direction-total"},Sh={class:"slaughter-direction-list"},kh={key:1,class:"epidemic-empty"},Mh={class:"yak-right"},Ch={class:"yak-side-stack is-right"},Ph={class:"structure-chart-card"},Nh={class:"structure-summary-card"},Fh={key:0,class:"yak-data-status"},xh={key:1,class:"yak-data-status is-warning"},Rh={class:"forecast-heat-list"},Ih=["title"],_h={class:"epidemic-record-table is-full"},Gh={class:"epidemic-record-toolbar"},Ah={class:"epidemic-record-rows"},Bh=["onClick"],$h={key:0,class:"epidemic-empty"},Eh={class:"epidemic-record-pager"},Vh=["disabled"],Dh=["disabled"],zh={class:"trade-cert-card"},Oh={class:"trade-cert-main"},Wh={class:"trade-dest-list"},Yh={key:0,class:"epidemic-empty"},jh={class:"trade-ledger-table"},Hh={class:"trade-ledger-toolbar"},qh={class:"trade-ledger-rows"},Uh=["onClick"],Kh={key:0,class:"epidemic-empty"},Zh={class:"trade-ledger-pager"},Xh=["disabled"],Qh=["disabled"],Jh={key:1,class:"epidemic-empty"},ep={class:"slaughter-destination-list"},tp={key:0,class:"epidemic-empty"},ap={class:"slaughter-ledger-table"},np={class:"slaughter-ledger-toolbar"},rp={class:"slaughter-ledger-rows"},ip=["onClick"],sp={key:0,class:"epidemic-empty"},op={class:"slaughter-ledger-pager"},lp=["disabled"],up=["disabled"],cp={class:"yak-bottom-topic"},dp={key:5,class:"yak-map-layer-tools"},hp={class:"epidemic-ledger-dialog"},pp={class:"epidemic-ledger-dialog-head"},fp={class:"epidemic-ledger-filters"},mp=["value"],gp=["value"],yp={class:"epidemic-ledger-workspace"},vp={class:"epidemic-ledger-list"},bp=["onClick"],wp={key:0,class:"epidemic-empty"},Lp={class:"epidemic-ledger-detail trade-ledger-detail epidemic-ledger-record-detail"},Tp={class:"epidemic-detail-head trade-detail-head"},Sp={class:"epidemic-detail-grid is-modal trade-detail-grid epidemic-detail-flat-grid"},kp={key:0,class:"epidemic-detail-photos"},Mp={class:"epidemic-modal-photo-strip"},Cp=["onClick"],Pp=["src"],Np={class:"epidemic-ledger-pager"},Fp=["disabled"],xp=["disabled"],Rp={class:"epidemic-ledger-dialog trade-ledger-dialog"},Ip={class:"epidemic-ledger-dialog-head"},_p={class:"epidemic-ledger-filters trade-ledger-filters"},Gp=["value"],Ap=["value"],Bp=["value"],$p={class:"epidemic-ledger-workspace trade-ledger-workspace"},Ep={class:"epidemic-ledger-list trade-ledger-modal-list"},Vp=["onClick"],Dp={key:0,class:"epidemic-empty"},zp={class:"epidemic-ledger-detail trade-ledger-detail"},Op={class:"epidemic-detail-head trade-detail-head"},Wp={class:"epidemic-detail-grid is-modal trade-detail-grid"},Yp={class:"is-wide"},jp={class:"is-wide"},Hp={class:"is-wide"},qp={class:"is-wide"},Up=["disabled"],Kp={class:"epidemic-ledger-pager"},Zp=["disabled"],Xp=["disabled"],Qp={class:"epidemic-ledger-dialog trade-ledger-dialog slaughter-ledger-dialog"},Jp={class:"epidemic-ledger-dialog-head"},ef={class:"epidemic-ledger-filters slaughter-ledger-filters"},tf=["value"],af=["value"],nf=["value"],rf={class:"epidemic-ledger-workspace trade-ledger-workspace slaughter-ledger-workspace"},sf={class:"epidemic-ledger-list slaughter-ledger-modal-list"},of=["onClick"],lf={key:0,class:"epidemic-empty"},uf={class:"epidemic-ledger-detail trade-ledger-detail"},cf={class:"epidemic-detail-head trade-detail-head"},df={class:"epidemic-detail-grid is-modal trade-detail-grid"},hf={class:"is-wide"},pf={class:"is-wide"},ff={class:"is-wide"},mf={class:"epidemic-ledger-pager"},gf=["disabled"],yf=["disabled"],vf={class:"epidemic-image-preview-dialog"},bf={class:"epidemic-image-preview-head"},wf={class:"epidemic-image-preview-body"},Lf={class:"epidemic-image-preview-frame"},Tf=["src"],Sf="",kf="/external/satellite/{z}/{x}/{y}.png",Mf=9,Cf="oss-satellite-dynamic-zoom21-v5",Bn="#43d9e8",$n=8,eo=14,Wr=8,to=14,Yr=8,ao=14,En=6,Pf=4200,Nf=6e4,no="#FFE600",zf={__name:"index",props:{active:{type:Boolean,default:!0},viewKey:{type:String,default:"structure"}},emits:["module-stats","view-change"],setup(m,{expose:e,emit:t}){const a=m,i=t,o=Ps.sideCardWidth;Ps.sideCardGap;const l=_(typeof window=="undefined"?1080:window.innerHeight),u=S(()=>fc(l.value)),h=S(()=>Er(u.value,2)),p=S(()=>u.value),y=S(()=>Er(u.value,2)),g=S(()=>Er(u.value,2)),w=Da.textPrimary,C=Da.textStrong,F=Da.textSecondary,x=Da.textMuted,G=Da.chartGridLine,H=zr,J=H,ne=H,K=Ac,V={targetLngLat:[102.6,32.59],targetLocalZ:.72,distanceScale:1.05,duration:.75},se=["#30dcff","#8bf7ff","#58d9ff","#28e8d6","#7bdfff","#9efcff"],Ye=["#30dcff","#8bf7ff","#58d9ff","#28e8d6","#7bdfff","#9efcff"],rt=["#30dcff","#8bf7ff","#58d9ff","#28e8d6","#7bdfff","#9efcff","#48cfff"],At={name:"红原牦牛交易市场",lng:102.562157,lat:32.820484},kt=[{key:"structure",name:"畜群结构",color:"#30dcff"},{key:"forecast",name:"畜群预测",color:"#8bf7ff"},{key:"epidemic",name:"牦牛防疫",color:"#8bf7ff"},{key:"trade",name:"牦牛交易",color:"#63d7ff"},{key:"slaughter",name:"牦牛出栏",color:"#ffd76c"}],z=_(Br(a.viewKey)),ht=_([]),Mt=_("2027"),Bt=_("month"),pt=_(0),$t=_([]),ft=_([]),Ne=_(0),it=_(!1),Me=_(""),qe=[2025,2026],_e=_(2026),Fe=_({metrics:{}}),Et=_({rows:[],year:null}),Ct=_({rows:[]}),De=_([]),ze=_(0),Be=_(1),M=_(""),L=_(""),A=_(!1),D=_(""),Z=_(!1),re=_([]),fe=_(0),Le=_(1),je=_(!1),Je=_(""),Oe=_(null),Ge=_(null),Ue=_(!1),He=_(!1),st=_(""),me=_(gn()),ge=_({years:[],latestYear:null}),ie=_({metrics:{},hasData:!1}),mt=_([]),Vt=_(0),be=_(null),qt=_(!1),ua=_(""),Pt=_(1),Ha=_(""),Wn=_(""),Yn=_(!1),Ut=_([]),qa=_(0),Kt=_(1),jn=_(!1),Hn=_(""),Ua=_(null),gt=_({keyword:"",startTown:"",usageType:"",certType:""}),xe=_({metrics:{},hasData:!1}),ca=_({towns:[],destinations:[],usages:[],certificateTypes:[]}),he=_(null),Ca=_([]),Ka=_([]),da=_(0),ot=_(1),Za=_(""),Xa=_(""),Nt=_(!1),lt=_(""),Qa=_(!1),Zt=_([]),Ja=_(0),Xt=_(1),qn=_(!1),Un=_(""),Pa=_(null),Ke=_(Mr()),$e=_(null),Na=_(null),ha=_(!1),Fa=_(!1),Ze=_(!1),Zr=_(0),Xr=_(0),en=_({type:"idle",text:""}),tn=_({type:"idle",text:""});let Kn=null,an=!1,Qr=!1,Dt=!1,Ft=null,pa=!1,nn=null,rn=null,Zn=0,Xn=0,sn=0,Jr=!1,ei=!1,ti=!1,ai=!1;const Qn=[{key:"day",label:"日",unit:"日",stepDays:1},{key:"week",label:"周",unit:"周",stepDays:7},{key:"month",label:"月",unit:"月",stepDays:30}],et=S(()=>(Ne.value,Md(Mt.value))),mo=new Set(["epidemic","trade","slaughter"]),Jn=S(()=>!mo.has(z.value)),ni=S(()=>Jn.value?kf:""),go=S(()=>Jn.value?"oss-satellite":"solid-3d"),yo=S(()=>`yak-management-map-${go.value}-${Cf}-${Zr.value}`),vo=S(()=>(Ne.value,co+ho)),er=S(()=>et.value.stock-_t),bo=S(()=>Yu(et.value)),on=S(()=>(Ne.value,Bu(ft.value,Sa))),wo=S(()=>on.value.reduce((r,n)=>r+Number(n.count||0),0));S(()=>{const r=wo.value||1;return on.value.map((n,s)=>{const c=Number(n.count||0),f=Number(n.ratio);return E(I({},n),{count:c,color:se[s%se.length],percent:Number.isFinite(f)?f:c/r*100})})});const Lo=S(()=>ys(on.value,Sa)),ln=S(()=>Lo.value),ri=S(()=>Vu(ln.value)),ii=S(()=>Du(on.value,Sa)),si=S(()=>Ou(ii.value)),To=S(()=>Math.max(...ri.value.map(r=>Number(r.count||0)),1)),tr=S(()=>ln.value.length?0:-1),So=S(()=>{const r=ln.value,n=r.length;if(!n)return[];const s=Math.max(...r.map(v=>Number(v.count||0)),1),c=360/n,f=Math.min(8,c*.16);return r.map((v,b)=>{const k=Number(v.count||0),R=b===tr.value,B=36+Math.sqrt(k/s)*31+(R?5:0),$=17,X=-90+b*c+f/2,ue=-90+(b+1)*c-f/2,ce=(X+ue)/2,we=ta(75,75,B+3,ce),We=ta(75,75,B+15,ce),Lt=ta(75,75,B+20,ce);return{key:v.key||v.name||b,index:b,item:v,color:v.color||se[b%se.length],path:Eu(75,75,$,B,X,ue),lineStart:we,lineEnd:We,label:Lt,anchor:Math.cos(ce*Math.PI/180)>=0?"start":"end"}})}),oi=S(()=>ms(["fertileCow","overageCow"])),li=S(()=>ms(["femaleCalf","maleCalf"])),zt=S(()=>(Ne.value,($t.value.length?$t.value:po).map(r=>E(I({},r),{name:Dn(r.name),count:Number(r.count||0)})).filter(r=>r.name&&Number.isFinite(r.count)&&r.count>=0))),ar=S(()=>(Ne.value,fo)),nr=S(()=>(Ne.value,Pd(et.value))),ko=S(()=>(Ne.value,Cd(et.value))),xa=S(()=>{var r;return((r=Fe.value)==null?void 0:r.metrics)||{}}),rr=S(()=>{var r;return xt((r=Fe.value)==null?void 0:r.dateTrend).sort(eu)}),un=S(()=>{var r;return xt((r=Fe.value)==null?void 0:r.medicineCounts)}),cn=S(()=>un.value.filter(r=>r.value>0).map((r,n)=>E(I({},r),{key:r.key||`${r.name}-${n}`,unit:"条"}))),Mo=S(()=>cn.value.map(r=>`${r.name}:${r.value}`).join("|")||"epidemic-medicine-empty"),Co=S(()=>{var r;return xt((r=Fe.value)==null?void 0:r.ownerRanks).slice(0,8)}),Ot=S(()=>ea(xa.value,["vaccineTypes"])||Ni(Fe.value)),Po=S(()=>{var r;return((r=un.value.find(n=>n.name&&n.name!=="未填写"))==null?void 0:r.name)||"-"}),yt=S(()=>ea(xa.value,["total","vaccine"]));S(()=>ea(xa.value,["owners"]));const No=S(()=>ea(xa.value,["villages"])),ir=S(()=>Qt.value.length),Fo=S(()=>{var r;return((r=Qt.value[0])==null?void 0:r.name)||"-"}),ui=S(()=>{const r=De.value.map(n=>n.operateTime).filter(Boolean).sort();return r.length?ut(r[r.length-1]):"-"}),sr=S(()=>{const r=ea(xa.value,["earTags"]);if(r>0)return r;const n=Math.max(...un.value.map(s=>Number(s.value||0)),0);return n>0?n:Math.round(yt.value/Ot.value)}),or=S(()=>{var n;const r=Kl((n=Et.value)==null?void 0:n.rows);return r.length?r:Qt.value.map(s=>({name:s.name,recordCount:Number(s.recordCount||0),earTagCount:Number(s.earTagCount||0),ratio:s.ratio,source:"ledger"}))}),ci=S(()=>{var n;const r=new Set;return Nr((n=Ct.value)==null?void 0:n.rows).filter(s=>Number.isFinite(s.lng)&&Number.isFinite(s.lat)).map((s,c)=>{const f=`${s.lng.toFixed(4)},${s.lat.toFixed(4)}`,v=r.has(f)?(c%3-1)*.012:0;return r.add(f),E(I({},s),{name:s.village,value:s.earTagCount,unit:"万头",lng:s.lng+v,lat:s.lat-v*.65,displayValue:Number((s.earTagCount/1e4).toFixed(2)),displayUnit:"万头",rankLabel:`第${c+1}名`})})}),Qt=S(()=>{var n;const r=new Map;return xt((n=Fe.value)==null?void 0:n.townCounts).forEach(s=>{var v,b;const c=at(s.name);if(!c)return;const f=r.get(c)||{recordCount:0,earTagCount:0};f.recordCount+=Number((b=(v=s.recordCount)!=null?v:s.value)!=null?b:0),f.earTagCount+=Number(s.earTagCount||0),r.set(c,f)}),[...r.entries()].map(([s,c])=>{const f=Number(c.recordCount||0),v=Number(c.earTagCount||0)||Math.round(f/Ot.value),b=yt.value?f/yt.value*100:0;return{name:s,recordCount:f,earTagCount:v,ratio:b}}).sort((s,c)=>Number(c.recordCount||0)-Number(s.recordCount||0))}),xo=S(()=>Math.max(zt.value.length,ir.value)),Ro=S(()=>new Set(Qt.value.map(r=>at(r.name)).filter(Boolean))),Wt=S(()=>{const r=Ro.value;return zt.value.map(n=>at(n.name)).filter(n=>n&&!r.has(n))}),Io=S(()=>{const r=xo.value||ir.value||1;return ir.value/r*100});S(()=>_t?sr.value/_t*100:0);const dn=S(()=>nu());S(()=>yt.value?Wt.value.length?Wt.value.length:dn.value.name&&dn.value.name!=="暂无"?1:0:0);const _o=S(()=>ru()),Go=S(()=>iu()),Ao=S(()=>su());S(()=>ou());const Bo=S(()=>lu());S(()=>Bo.value.slice(0,3)),S(()=>yt.value?Wt.value.length?"年度免疫进度需核查":dn.value.desc:"年度计划待核查");const lr=S(()=>Math.max(Math.ceil(ze.value/$n),1)),$o=S(()=>De.value.slice(0,$n)),di=S(()=>Math.max(Math.ceil(fe.value/eo),1)),Jt=S(()=>Ge.value||Oe.value||{}),hi=S(()=>Rr(Jt.value)),Eo=S(()=>{const r=Jt.value||{};return[Re("台账编号",r.epidemicId,{wide:!0}),Re("养殖户",r.owner,{wide:!0}),Re("联系电话",Bi(r.phone)),Re("证件类型",r.idType),Re("证件号码",hu(r.idNo)),Re("镇/乡",r.town),Re("村",r.village),Re("详细地址",r.location,{wide:!0}),Re("畜种",r.livestockType),Re("性别",r.sex),Re("畜龄",r.age),Re("体重",pu(r.weight)),Re("疫苗/药品",r.medicine),Re("防疫类型",r.preventionType),Re("免疫方式",r.method),Re("剂量",fu(r.dose)),Re("免疫时间",ut(r.operateTime)),Re("操作员",r.operator)].filter(Boolean)}),Vo=S(()=>{var r;return xt((r=Fe.value)==null?void 0:r.townCounts).map(n=>n.name)}),Do=S(()=>un.value.map(r=>r.name).filter(r=>r&&r!=="未填写")),pi=S(()=>{var r;return((r=ie.value)==null?void 0:r.metrics)||{}}),fi=S(()=>{var r,n,s,c,f,v,b,k;return Cr((r=ge.value)==null?void 0:r.years,(n=ie.value)==null?void 0:n.availableYears,(s=ie.value)==null?void 0:s.available_years,(c=ie.value)==null?void 0:c.yearSummary,(f=ie.value)==null?void 0:f.year_summary,(v=ie.value)==null?void 0:v.latestYear,(b=ie.value)==null?void 0:b.latest_year,(k=ie.value)==null?void 0:k.year)}),zo=S(()=>{var r,n;return bn(((r=ie.value)==null?void 0:r.monthTrend)||((n=ie.value)==null?void 0:n.month_trend),"name")});S(()=>{var r,n;return ql(((r=ie.value)==null?void 0:r.yearSummary)||((n=ie.value)==null?void 0:n.year_summary))});const hn=S(()=>{var r,n;return bn(((r=ie.value)==null?void 0:r.startTownCounts)||((n=ie.value)==null?void 0:n.start_town_counts),"name")}),mi=S(()=>{var r,n;return bn(((r=ie.value)==null?void 0:r.usageCounts)||((n=ie.value)==null?void 0:n.usage_counts),"name")});S(()=>{var r,n,s,c,f,v;return bn(((r=ie.value)==null?void 0:r.transportNumberCounts)||((n=ie.value)==null?void 0:n.transport_number_counts)||((s=ie.value)==null?void 0:s.vehicleCounts)||((c=ie.value)==null?void 0:c.vehicle_counts)||((f=ie.value)==null?void 0:f.transportCounts)||((v=ie.value)==null?void 0:v.transport_counts),"transportNumber")});const ur=S(()=>{const r=hn.value.map(s=>{const c=String(s.name||"").trim(),f=at(c),v=jl(f||c);return E(I({},s),{rawName:c,name:v,displayName:v,town:f,mapTownName:f})}).filter(s=>s.name&&s.name!=="未填写").slice(0,10),n=Math.max(...r.map(s=>s.headCount),1);return r.map((s,c)=>E(I({},s),{key:s.key||`${s.mapTownName||s.name}-${c}`,value:s.headCount,unit:"头",ratio:Math.max(8,Math.round(s.headCount/n*100))}))}),gi=S(()=>mt.value.slice(0,Wr)),cr=S(()=>Math.max(Math.ceil(Vt.value/Wr),1)),dr=S(()=>Math.max(Math.ceil(qa.value/to),1)),Te=S(()=>Ua.value||{}),Oo=S(()=>Te.value.certId||Te.value.factoryCode||""),Wo=S(()=>{var n,s;const r=fa(((n=ge.value)==null?void 0:n.startTowns)||((s=ge.value)==null?void 0:s.start_towns));return r.length?r:Pr(hn.value.map(c=>c.name))}),Yo=S(()=>{var n,s;const r=fa(((n=ge.value)==null?void 0:n.usageTypes)||((s=ge.value)==null?void 0:s.usage_types));return r.length?r:Pr(mi.value.map(c=>c.name))}),jo=S(()=>{var n,s,c,f;const r=Ul(((n=ge.value)==null?void 0:n.certTypeOptions)||((s=ge.value)==null?void 0:s.cert_type_options));return r.length?r:fa(((c=ge.value)==null?void 0:c.certTypes)||((f=ge.value)==null?void 0:f.cert_types)).map(v=>({value:v,label:v}))}),Ho=S(()=>ur.value.map((r,n)=>({key:r.key||`${r.name}-${n}`,name:r.displayName||r.name,displayName:r.displayName||r.name,rawName:r.rawName,town:r.mapTownName||r.town||at(r.name),mapTownName:r.mapTownName||r.town||at(r.name),value:r.headCount,headCount:r.headCount,recordCount:r.recordCount,ratio:r.ratio,unit:"头"}))),yi=S(()=>{var r;return uu((r=ie.value)==null?void 0:r.riskItems)}),qo=S(()=>{const r=yi.value.filter(n=>n.level==="high");return r.length>=2?`${r.length}项重点`:r.length===1?`重点:${r[0].name}`:"整体平稳"}),hr=S(()=>{var r,n,s,c;return Cr((r=xe.value)==null?void 0:r.availableYears,(n=xe.value)==null?void 0:n.available_years,(s=xe.value)==null?void 0:s.latestYear,(c=xe.value)==null?void 0:c.latest_year)}),vi=S(()=>[{key:"all",value:null,label:"全部"},...hr.value.map(r=>({key:String(r),value:r,label:String(r)}))]),Uo=S(()=>{var r,n;return Number(((r=xe.value)==null?void 0:r.latestYear)||((n=xe.value)==null?void 0:n.latest_year)||hr.value[hr.value.length-1]||0)}),pr=S(()=>he.value==null||Number(he.value)===Uo.value),Ko=S(()=>pr.value?"实时出栏":`${he.value}年动态`),fr=S(()=>Ka.value.slice(0,12)),Zo=S(()=>Math.max(28,fr.value.length*5.2)),pn=S(()=>{var r;return((r=xe.value)==null?void 0:r.metrics)||{}}),Xo=S(()=>{var R,B;const r=he.value,n=String(((R=pn.value)==null?void 0:R.referenceDate)||((B=pn.value)==null?void 0:B.reference_date)||""),s=n.match(/^\d{4}-(\d{2})-(\d{2})$/),c=new Date,f=`${c.getFullYear()}-${String(c.getMonth()+1).padStart(2,"0")}-${String(c.getDate()).padStart(2,"0")}`,v=n===f,b=r&&s&&!v?`${Number(s[1])}月${Number(s[2])}日出栏`:"今日出栏",k=r&&s&&!v?`${Number(s[1])}月出栏`:"本月出栏";return[{zh:b,value:Ia("todayHeadCount"),unit:"头"},{zh:k,value:Ia("monthHeadCount"),unit:"头"},{zh:r?`${r}年出栏`:"累计出栏",value:Ia("cumulativeHeadCount"),unit:"头"}]}),bi=S(()=>{var r;return Hl((r=xe.value)==null?void 0:r.townHistory)}),wi=S(()=>{var r;return yn((r=xe.value)==null?void 0:r.breedStructure)}),Li=S(()=>{var r;return yn((r=xe.value)==null?void 0:r.usageStructure)}),mr=S(()=>{var r;return yn((r=xe.value)==null?void 0:r.certificateRanking)}),gr=S(()=>{var s;const r=yn((s=xe.value)==null?void 0:s.directionStructure),n=r.reduce((c,f)=>c+f.headCount,0)||1;return r.map(c=>E(I({},c),{key:c.name==="省内"?"inside":c.name==="省外"?"outside":"unknown",percent:Number((c.headCount/n*100).toFixed(1))}))}),yr=S(()=>{var s;const r=(Array.isArray((s=xe.value)==null?void 0:s.destinationRanking)?xe.value.destinationRanking:[]).map((c,f)=>({key:c.provinceName||c.province_name||c.name||`destination-${f}`,name:c.provinceName||c.province_name||c.name||"未标注",provinceName:c.provinceName||c.province_name||c.name||"未标注",certificateCount:Number(c.certificateCount||c.certificate_count||0),headCount:Number(c.headCount||c.head_count||c.value||0)})).filter(c=>c.headCount>0).slice(0,8),n=Math.max(...r.map(c=>c.headCount),1);return r.map(c=>E(I({},c),{value:c.headCount,unit:"头",ratio:Math.max(6,Math.round(c.headCount/n*100))}))}),Qo=S(()=>yr.value.filter(r=>r.name!=="未标注").map(r=>E(I({},r),{displayName:r.name,destinationProvince:r.provinceName}))),Ti=S(()=>Ca.value.slice(0,Yr)),vr=S(()=>Math.max(Math.ceil(da.value/Yr),1)),br=S(()=>Math.max(Math.ceil(Ja.value/ao),1)),Xe=S(()=>Pa.value||{}),Jo=S(()=>{var r;return fa((r=ca.value)==null?void 0:r.towns)}),el=S(()=>{var r;return fa((r=ca.value)==null?void 0:r.destinations)}),tl=S(()=>{var r;return fa((r=ca.value)==null?void 0:r.usages)}),al=S(()=>zt.value.map(r=>E(I({},r),{breedingCowRatio:oi.value,calfRatio:li.value,breedingCow:Math.round(r.count*oi.value/100),calf:Math.round(r.count*li.value/100)}))),fn=S(()=>{const r=al.value,n=r.length,s=Math.max(Math.ceil(n/En),1),c=pt.value%s,f=c*En,v=Math.min(f+En,n);return{page:c,pageCount:s,start:f,end:v,total:n,rows:r.slice(f,v)}}),nl=S(()=>z.value==="forecast"?nr.value:zt.value),rl=S(()=>z.value==="forecast"?"forecast":"count"),il=S(()=>_u(nl.value,rl.value)),Ra=S(()=>({key:"yak-marks-layer",sourceType:"wmts",layerName:"v3:yak_recognition",style:"v3:yak_recognition",styles:"v3:yak_recognition",format:"image/png",tileMatrixSetID:"EPSG:900913",minimumLevel:7,maximumLevel:21,bounds:[101.88735023598684,32.187424325001956,103.32644952301061,33.27125655371905],url:"/geoserver/gwc/service/wmts",name:"牦牛识别",opacity:.92,queryBuffer:10,geometryField:"geom",fillColor:"rgba(255, 230, 0, 0)",strokeColor:no,glowColor:"rgba(255, 230, 0, 0.42)",lineWidth:1.4,mapView:{targetLngLat:H,distanceScale:.82,targetLocalZ:.76,duration:.85},legends:[{key:"yak-marks",name:"牦牛",fillColor:no,strokeColor:"#FFF58A",selectable:!1}]})),sl=S(()=>[Ra.value]),ol=S(()=>{const r=Array.isArray(ht.value)?ht.value:[ht.value];return new Set(r.map(String).filter(Boolean))}),wr=S(()=>ol.value.has(Ra.value.key)),ll=S(()=>wr.value?Ra.value.legends||[]:[]),ul=S(()=>wr.value?202:172),cl=S(()=>{var s;const n=Nr((s=Ct.value)==null?void 0:s.rows).map(c=>Ql(c.town,c.village)).filter(Boolean);return{key:"yak-epidemic-village-boundary",sourceType:"wms",url:"/geoserver/v3/wms",layerName:"v3:yak_epidemic_village",styles:"v3:yak_epidemic_village",name:"防疫村边界",opacity:.86,queryBuffer:8,cqlFilter:n.length?n.join(" OR "):"EXCLUDE",legends:[{key:"yak-epidemic-village-boundary",name:"防疫村边界",fillColor:"#30DCFF",strokeColor:"#C9FBFF",selectable:!1}]}}),dl=S(()=>({key:"yak-trade-town",sourceType:"wms",url:"/geoserver/v3/wms",layerName:"v3:yak_trade_town",name:"交易乡镇",cqlFilter:`record_year=${Number(be.value||0)}`,fillColor:"rgba(48, 220, 255, 0.12)",strokeColor:"#30DCFF",opacity:.84,overlayLayers:[{key:"yak-trade-market",sourceType:"wms",url:"/geoserver/v3/wms",layerName:"v3:yak_trade_market",name:"牦牛交易市场",fillColor:"#FFE600",strokeColor:"#FFF58A",opacity:.96}]})),Si=S(()=>z.value==="epidemic"?cl.value:z.value==="trade"?dl.value:z.value==="slaughter"?null:tt.value?wr.value?Ra.value:null:Ra.value),tt=S(()=>z.value==="structure"||z.value==="forecast"),hl=S(()=>z.value==="forecast"?ne:J),pl=S(()=>tt.value?null:Si.value),fl=S(()=>tt.value?null:ki.value),ml=S(()=>tt.value?!Fa.value:!ha.value),gl=S(()=>tt.value?"地图加载中":"3D 地图加载中"),ki=S(()=>z.value==="slaughter"?{scope:"trade-flow",nationalFlow:!0,title:he.value?`${he.value}年牦牛出栏销售流向`:"牦牛出栏销售流向",metricLabel:"目的地",unit:"头",source:{name:"红原县",lng:zr[0],lat:zr[1],total:Ia("cumulativeHeadCount")},rows:Qo.value,showFlowLines:!0}:z.value==="trade"?{scope:"trade-flow",title:`${be.value||""}出栏来源`,metricLabel:"来源",unit:"头",source:E(I({},At),{total:bt("headCount")}),rows:Ho.value,showFlowLines:!1,mapView:V}:{scope:z.value==="epidemic"?"village":"town",hideTownNames:z.value==="epidemic",hideTownLabelStats:z.value==="structure"||z.value==="forecast",title:z.value==="forecast"?`${et.value.shortLabel}预测存栏`:z.value==="epidemic"?`${_e.value}年村级防疫信息`:"乡镇估算存栏",metricLabel:z.value==="forecast"?"预测":z.value==="epidemic"?"防疫":"存栏",unit:"万头",rows:z.value==="epidemic"?ci.value:il.value.map(r=>({name:r.name,value:Number((r.value/1e4).toFixed(2)),unit:"万头"}))}),yl=S(()=>(Ne.value,{color:["#8bf7ff","#30dcff"],tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(r){const n=r.map(s=>`${s.marker}${s.seriesName}:${Y(Math.abs(s.value))}头`);return`${r[0].name}<br/>${n.join("<br/>")}`}}),legend:{top:4,right:12,itemWidth:12,itemHeight:8,textStyle:{color:F,fontSize:11}},grid:{left:22,right:22,top:32,bottom:12,containLabel:!0},xAxis:{type:"value",axisLabel:{color:x,fontSize:10,formatter:r=>ae(Math.abs(r))},splitLine:{lineStyle:{color:G,type:"dashed"}},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"category",data:Vn.map(r=>r.age),axisLabel:{color:w,fontSize:11,fontWeight:700},axisLine:{show:!1},axisTick:{show:!1}},series:[{name:"母牛",type:"bar",stack:"gender",barWidth:12,data:Vn.map(r=>-r.cow),itemStyle:{borderRadius:[7,0,0,7]}},{name:"公牛",type:"bar",stack:"gender",barWidth:12,data:Vn.map(r=>r.bull),itemStyle:{borderRadius:[0,7,7,0]}}]})),vl=S(()=>{const r=zt.value,n=r.map(s=>s.count);return{color:se,tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(s){const c=s.map(f=>`${f.marker}${f.seriesName}:${Y(f.value)}头`);return`${s[0].name}<br/>${c.join("<br/>")}<br/>估算存栏:${Y(n[s[0].dataIndex])}头<br/>结构依据:畜群结构比例表`}}),legend:{top:-2,right:0,itemWidth:8,itemHeight:6,itemGap:6,textStyle:{color:F,fontSize:10}},grid:{left:54,right:30,top:22,bottom:8},xAxis:{type:"value",axisLabel:{color:x,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:G,type:"dashed"}},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"category",inverse:!0,data:r.map(s=>s.name),axisLabel:{color:w,fontSize:10,fontWeight:700,interval:0},axisLine:{show:!1},axisTick:{show:!1}},series:Sa.map(s=>({name:s.name,type:"bar",stack:"town",barWidth:r.length>8?6:11,data:r.map(c=>Math.round(c.count*s.ratio/100))}))}}),bl=S(()=>Pn(zt.value,"count","头",{style:"ladder",tooltipFormatter(r){const n=zt.value[r.dataIndex];return`${n.name}<br/>估算存栏:${Y(n.count)}头<br/>来源:无人机识别`}})),wl=S(()=>{const r=fn.value,n=r.rows,s=Math.max(...n.map(c=>c.breedingCow+c.calf),1);return{color:["#30dcff","#8bf7ff"],animationDurationUpdate:700,animationEasingUpdate:"cubicOut",tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(c){const f=n[c[0].dataIndex],v=c.filter(b=>["能繁母牛","犊牛合计"].includes(b.seriesName)).map(b=>`${b.marker}${b.seriesName}:${Y(b.value)}头`);return`${f.name}<br/>母犊合计:${Y(f.breedingCow+f.calf)}头<br/>${v.join("<br/>")}<br/>依据:无人机识别 + 畜群结构比例表`}}),legend:{data:["能繁母牛","犊牛合计"],top:2,left:2,itemWidth:10,itemHeight:7,itemGap:9,textStyle:{color:F,fontSize:10}},graphic:r.total>En?{type:"text",right:4,top:3,silent:!0,style:{text:`${r.start+1}-${r.end} / ${r.total}`,fill:x,fontSize:10,fontWeight:600}}:void 0,grid:{left:18,right:18,top:42,bottom:44,containLabel:!1},xAxis:{type:"category",data:n.map(c=>c.name),axisLabel:{color:x,fontSize:10,lineHeight:12,interval:0,margin:8,formatter:Jl},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",max:Math.ceil(s*1.28),axisLabel:{show:!1},axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:G,type:"dashed"}}},series:[{name:"基础群规模",type:"bar",barWidth:15,barGap:"-100%",data:n.map(c=>c.breedingCow+c.calf),tooltip:{show:!1},itemStyle:{borderRadius:[8,8,1,1],color:"rgba(48, 220, 255, 0.07)"},silent:!0},{name:"能繁母牛",type:"bar",stack:"foundation",barWidth:15,data:n.map(c=>c.breedingCow),itemStyle:{borderRadius:[1,1,0,0],color:new Ae(0,0,0,1,[{offset:0,color:"rgba(48, 220, 255, 0.34)"},{offset:1,color:"#30dcff"}])}},{name:"犊牛合计",type:"bar",stack:"foundation",barWidth:15,data:n.map(c=>c.calf),itemStyle:{borderRadius:[8,8,1,1],color:new Ae(0,0,0,1,[{offset:0,color:"#8bf7ff"},{offset:1,color:"rgba(139, 247, 255, 0.2)"}])},label:{show:!0,position:"top",formatter:({dataIndex:c})=>ae(n[c].breedingCow+n[c].calf),color:"#ffffff",fontSize:10,fontWeight:700}}]}}),Ll=S(()=>{Ne.value;const r=qr.slice().sort((c,f)=>f.value-c.value),n=qr.reduce((c,f)=>c+f.value,0),s=r.map(c=>c.yoy||0);return{color:[Bn,"#8bf7ff"],tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(c){const f=r[c[0].dataIndex];return`${f.label}<br/>数量:${Y(f.value)}头<br/>占比:${wt(f.value/n*100)}<br/>同比:${f.yoy>0?"+":""}${f.yoy}%`}}),grid:{left:36,right:30,top:20,bottom:34},xAxis:{type:"category",data:r.map(c=>c.label),axisLabel:{color:w,fontSize:10,fontWeight:700,interval:0,margin:10},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.24)"}},axisTick:{show:!1}},yAxis:[{type:"value",axisLabel:{color:x,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:G,type:"dashed"}}},{type:"value",min:Math.min(-2,Math.floor(Math.min(...s)-1)),max:Math.max(8,Math.ceil(Math.max(...s)+1)),axisLabel:{color:F,fontSize:10,formatter:"{value}%"},splitLine:{show:!1},axisLine:{show:!1},axisTick:{show:!1}}],series:[{name:"数量",type:"bar",barWidth:16,data:r.map(c=>({value:c.value,itemStyle:{borderRadius:[2,2,1,1],color:new Ae(0,0,0,1,[{offset:0,color:Bn},{offset:.58,color:"rgba(67, 217, 232, 0.72)"},{offset:1,color:"rgba(67, 217, 232, 0.16)"}]),shadowBlur:2,shadowColor:"rgba(48, 220, 255, 0.16)"},label:{show:!0,position:"top",color:C,fontSize:10,fontFamily:za.number,fontWeight:700,formatter:({value:f})=>ae(f)}}))},{name:"同比",type:"line",yAxisIndex:1,smooth:!0,symbol:"circle",symbolSize:6,data:s,lineStyle:{width:2,color:"#8bf7ff"},itemStyle:{color:"#8bf7ff",borderColor:"rgba(3, 18, 28, 0.9)",borderWidth:2},label:{show:!0,position:"top",color:"#8bf7ff",fontSize:10,formatter:({value:c})=>`${c>0?"+":""}${c}%`}}]}}),Tl=S(()=>{const r=Nu(Bt.value),n=Fu(et.value,r.key),s=Iu(n),c=xu(s.length,r.key);return{color:["#30dcff","#8bf7ff","#48cfff"],tooltip:E(I({},ye()),{trigger:"axis",triggerOn:"mousemove|click",axisPointer:{type:"cross",crossStyle:{color:"rgba(126, 251, 246, 0.42)"},label:{color:"#eaffff",backgroundColor:"rgba(5, 31, 51, 0.96)"}},formatter(f){var B,$,X;const v=Array.isArray(f)?f:[f],b=v.find(ue=>ue.seriesType==="candlestick"),k=(b==null?void 0:b.data)||s[(X=($=b==null?void 0:b.dataIndex)!=null?$:(B=v[0])==null?void 0:B.dataIndex)!=null?X:0];if(!k)return"";const R=k.close-k.open;return[`${k.label}|${r.unit}度预测`,`预测存栏:${Y(k.close)}头`,`较上期:${Fn(R)}头`,`新生牛犊:${Y(k.birth)}头`,`出栏扣减:${Y(k.outflow)}头`].join("<br/>")}}),legend:{top:4,right:8,data:["预测存栏","新生牛犊","出栏扣减"],itemWidth:12,itemHeight:8,textStyle:{color:F,fontSize:10}},grid:{left:44,right:40,top:34,bottom:28},xAxis:{type:"category",boundaryGap:!0,data:n.labels,axisLabel:{color:x,fontSize:10,interval:c},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.28)"}},axisTick:{show:!1}},yAxis:[{type:"value",scale:!0,axisLabel:{color:x,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:G,type:"dashed"}}},{type:"value",axisLabel:{color:F,fontSize:10,formatter:ae},splitLine:{show:!1}}],series:[{name:"预测存栏",type:"candlestick",yAxisIndex:0,barWidth:Ru(s.length,r.key),data:s,itemStyle:{color:"rgba(48, 220, 255, 0.82)",color0:"rgba(72, 207, 255, 0.82)",borderColor:"#30dcff",borderColor0:"#48cfff",borderWidth:1.4}},{name:"预测存栏线",type:"line",yAxisIndex:0,smooth:!0,symbol:"circle",symbolSize:4,data:s.map(f=>f.close),lineStyle:{width:1.8,color:"rgba(48, 220, 255, 0.86)"},itemStyle:{color:"#30dcff",borderColor:"rgba(3, 18, 28, 0.9)",borderWidth:1},tooltip:{show:!1}},ps("新生牛犊",n.births,"#8bf7ff",1),ps("出栏扣减",n.outflow,"#48cfff",1)]}}),Sl=S(()=>({color:["#30dcff","#8bf7ff"],tooltip:E(I({},ye()),{trigger:"axis"}),legend:{top:4,right:12,itemWidth:12,itemHeight:8,textStyle:{color:F,fontSize:10}},grid:{left:52,right:42,top:34,bottom:28},xAxis:{type:"category",data:ar.value.map(r=>r.month||r.name),axisLabel:{color:x,fontSize:10,interval:1},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.26)"}},axisTick:{show:!1}},yAxis:[{type:"value",axisLabel:{color:x,fontSize:10,formatter:r=>{const n=Number(r);return Number.isFinite(n)?Math.abs(n)>=1e4?`${Number((n/1e4).toFixed(1))}万`:`${n}`:r}},splitLine:{lineStyle:{color:G,type:"dashed"}}},{type:"value",axisLabel:{color:F,fontSize:10},splitLine:{show:!1}}],series:[{name:"数量",type:"bar",barWidth:12,data:ar.value.map(r=>r.count||r.value),itemStyle:{borderRadius:[8,8,0,0],color:new Ae(0,0,0,1,[{offset:0,color:"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.08)"}])}},{name:"增速",type:"line",yAxisIndex:1,smooth:!0,symbolSize:5,data:ar.value.map(r=>r.speed||r.growthRate||0),lineStyle:{width:2.4,color:"#8bf7ff"},itemStyle:{color:"#8bf7ff"}}]})),kl=S(()=>(Ne.value,{tooltip:ye(),radar:{center:["50%","54%"],radius:"68%",splitNumber:4,indicator:Ur.map(r=>({name:r.name,max:100})),axisName:{color:"rgba(223, 250, 255, 0.76)",fontSize:11},splitLine:{lineStyle:{color:"rgba(48, 220, 255, 0.22)"}},splitArea:{areaStyle:{color:["rgba(48, 220, 255, 0.04)","rgba(139, 247, 255, 0.018)"]}},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.18)"}}},series:[{type:"radar",data:[{name:"预测因子",value:Ur.map(r=>r.value),areaStyle:{color:"rgba(48, 220, 255, 0.22)"},lineStyle:{color:"#30dcff",width:2},itemStyle:{color:"#8bf7ff"}}]}]})),Ml=S(()=>Pn(nr.value,"forecast","头")),Cl=S(()=>{const r=ko.value,n=r.reduce((s,c,f)=>{const v=c.color||se[f%se.length];return s[`name${f}`]={color:v,fontSize:10,fontWeight:800},s[`percent${f}`]={color:v,fontSize:10,fontFamily:"D-DIN, Arial, sans-serif",fontWeight:800},s},{});return{color:se,tooltip:ye(s=>{var f;const c=r.find(v=>v.name===s.name);return`${s.name}<br/>预测占比:${wt((f=c==null?void 0:c.ratio)!=null?f:s.percent)}<br/>预测数量:${Y((c==null?void 0:c.count)||0)}头`}),legend:{orient:"vertical",right:4,top:"middle",itemWidth:8,itemHeight:8,itemGap:6,formatter(s){const c=r.findIndex(v=>v.name===s),f=r[c];return f?`{name${c}|${s}} {percent${c}|${wt(f.ratio)}}`:s},textStyle:{color:F,fontSize:10,rich:n}},series:[{name:"期末结构预测",type:"pie",radius:["38%","66%"],center:["32%","54%"],startAngle:118,avoidLabelOverlap:!1,label:{show:!1},labelLine:{show:!1},itemStyle:{borderColor:"rgba(3, 18, 31, 0.92)",borderWidth:3},data:r.map(s=>({name:s.name,value:s.count}))}]}}),Pl=S(()=>(Ne.value,{color:["#8bf7ff","#48cfff","#48cfff"],tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"}}),legend:{top:4,right:8,itemWidth:12,itemHeight:8,textStyle:{color:F,fontSize:10}},grid:{left:44,right:26,top:34,bottom:28},xAxis:{type:"category",data:Gt.map(r=>r.shortLabel),axisLabel:{color:w,fontSize:11,fontWeight:700},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.26)"}},axisTick:{show:!1}},yAxis:{type:"value",axisLabel:{color:x,fontSize:10,formatter:r=>Nn(r,1)},splitLine:{lineStyle:{color:G,type:"dashed"}}},series:[{name:"新生牛犊",type:"bar",barWidth:12,data:Gt.map(r=>r.births),itemStyle:{borderRadius:[7,7,0,0]}},{name:"出栏流出",type:"bar",barWidth:12,data:Gt.map(r=>-r.outflow),itemStyle:{borderRadius:[0,0,7,7]}},{name:"稳态校正",type:"line",smooth:!0,symbolSize:6,data:Gt.map(r=>r.correction),lineStyle:{width:2.4}}]})),Nl=S(()=>{const r=nr.value,n=Math.max(...r.map(s=>Math.abs(s.change)),1);return r.map(s=>E(I({},s),{width:Math.max(8,Math.round(Math.abs(s.change)/n*100))}))});function Fl(r){const n=Number((r==null?void 0:r.change)||0)>=0;return{"--heat-width":`${r.width}%`,"--heat-color":n?"#30dcff":"#8bf7ff","--heat-color-soft":n?"rgba(48, 220, 255, 0.24)":"rgba(139, 247, 255, 0.22)","--heat-color-dim":n?"rgba(48, 220, 255, 0.07)":"rgba(139, 247, 255, 0.07)"}}function xl(r){return`${r.name}:${Fn(r.change)}头`}const Rl=S(()=>{const r=rr.value,n=r.map(c=>c.value),s=Math.max(...n,1);return{color:["#30dcff","#8bf7ff"],tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"line",lineStyle:{color:"rgba(48, 220, 255, 0.28)"}},formatter(c){const f=c[0];return`${f.name}<br/>防疫记录:${Y(f.value)}条`}}),grid:{left:42,right:24,top:20,bottom:28},xAxis:{type:"category",data:r.map(c=>c.name),axisLabel:{color:x,fontSize:10,interval:Math.max(Math.floor(r.length/7),0)},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.22)"}},axisTick:{show:!1}},yAxis:{type:"value",axisLabel:{color:x,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:G,type:"dashed"}}},series:[{name:"防疫记录",type:"bar",barMaxWidth:12,data:n,itemStyle:{borderRadius:[7,7,0,0],color:new Ae(0,0,0,1,[{offset:0,color:"#8bf7ff"},{offset:.45,color:"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.08)"}])},label:{show:!0,position:"top",color:"rgba(230, 255, 249, 0.92)",fontSize:10,formatter:({value:c})=>c>=s*.42?ae(c):""}},{name:"作业趋势",type:"line",smooth:!0,showSymbol:!1,data:n,lineStyle:{width:2.4,color:"#8bf7ff"}}]}});S(()=>{const r=rr.value.length?rr.value.slice(-6):[{name:"待开展",value:0}],n=r.map(b=>Number(b.value||0)),s=_o.value,c=s.map(b=>Number(b.value||0)),f=Math.max(...n,1),v=b=>String(b||"").replace(/(镇|乡|村)$/,"");return{color:["#30dcff","#8bf7ff"],title:[{text:"作业节奏",left:4,top:0,textStyle:{color:"rgba(226, 252, 255, 0.82)",fontSize:11,fontWeight:800}},{text:"补免关注",left:"55%",top:0,textStyle:{color:"rgba(226, 252, 255, 0.82)",fontSize:11,fontWeight:800}}],tooltip:E(I({},ye()),{trigger:"axis",formatter(b){const k=Array.isArray(b)?b[0]:b;if((k==null?void 0:k.axisIndex)===1){const B=s[k.dataIndex]||{};return`${B.name}<br/>补免关注:${B.label||k.value}`}const R=r[k.dataIndex]||{};return`${R.name}<br/>防疫记录:${Y(R.value)}条`}}),grid:[{left:6,right:"52%",top:26,bottom:15},{left:"56%",right:12,top:26,bottom:15}],xAxis:[{type:"category",gridIndex:0,data:r.map(b=>b.name),axisLabel:{color:"rgba(226, 252, 255, 0.56)",fontSize:9,interval:0,formatter:b=>String(b||"").replace(/^(\d{1,2})\D+(\d{1,2}).*$/,"$1/$2")},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.22)"}},axisTick:{show:!1}},{type:"value",gridIndex:1,min:0,max:Math.max(...c,100),show:!1}],yAxis:[{type:"value",gridIndex:0,show:!1},{type:"category",gridIndex:1,inverse:!0,data:s.map(b=>b.name),axisLabel:{color:"rgba(226, 252, 255, 0.68)",fontSize:9,formatter:b=>v(b)},axisLine:{show:!1},axisTick:{show:!1}}],series:[{name:"防疫记录",type:"bar",xAxisIndex:0,yAxisIndex:0,barMaxWidth:9,data:n,itemStyle:{borderRadius:[6,6,0,0],color:new Ae(0,0,0,1,[{offset:0,color:"#8bf7ff"},{offset:.45,color:"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.1)"}])},label:{show:!0,position:"top",color:"rgba(230, 255, 249, 0.86)",fontSize:8,formatter:({value:b})=>b>=f*.55?ae(b):""}},{name:"节奏线",type:"line",xAxisIndex:0,yAxisIndex:0,smooth:!0,showSymbol:!1,data:n,lineStyle:{width:1.8,color:"#8bf7ff"},tooltip:{show:!1}},{name:"补免关注",type:"bar",xAxisIndex:1,yAxisIndex:1,barWidth:8,data:c,itemStyle:{borderRadius:[0,7,7,0],color:new Ae(0,0,1,0,[{offset:0,color:"rgba(139, 247, 255, 0.24)"},{offset:1,color:"#8bf7ff"}])},label:{show:!0,position:"right",color:"rgba(201, 251, 255, 0.9)",fontSize:8,formatter:({dataIndex:b})=>{var k;return((k=s[b])==null?void 0:k.label)||""}}}]}}),S(()=>{const r=Go.value,n=r.map(v=>Number(v.value||0)),s=Math.max(...n,1),c=n.filter(Boolean).reduce((v,b)=>v+b,0)/Math.max(n.filter(Boolean).length,1),f=Math.ceil(s*1.18);return{color:["#30dcff","#8bf7ff"],tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(v){var k;const b=r[(k=v[0])==null?void 0:k.dataIndex]||{};return b.isMissing?`${b.name}<br/>年度防疫:待补强`:`${b.name}<br/>覆盖量:${Y(b.value)}头<br/>防疫记录:${Y(b.recordCount)}条`}}),grid:{left:56,right:46,top:16,bottom:12},xAxis:{type:"value",min:0,max:f,show:!1},yAxis:{type:"category",inverse:!0,data:r.map(v=>v.name),axisLabel:{color:"rgba(226, 252, 255, 0.82)",fontSize:11,interval:0,formatter:v=>String(v||"").replace(/(镇|乡)$/,"")},axisLine:{show:!1},axisTick:{show:!1}},series:[{name:"均衡参照",type:"bar",barWidth:11,silent:!0,barGap:"-100%",data:r.map(()=>f),itemStyle:{borderRadius:[0,8,8,0],borderColor:"rgba(48, 220, 255, 0.12)",borderWidth:1,color:"rgba(48, 220, 255, 0.045)"}},{name:"覆盖量",type:"bar",barWidth:11,barGap:"-100%",z:3,data:r.map(v=>{const b=Number(v.value||0);return{value:b>0?b:Math.max(f*.035,1),rawValue:b,itemStyle:{borderRadius:[0,8,8,0],color:new Ae(0,0,1,0,[{offset:0,color:v.isMissing?"rgba(72, 207, 255, 0.2)":"rgba(48, 220, 255, 0.14)"},{offset:.72,color:v.isMissing?"#48cfff":"#30dcff"},{offset:1,color:v.isMissing?"#8bf7ff":"#9efcff"}]),shadowBlur:v.isMissing?4:5,shadowColor:v.isMissing?"rgba(72, 207, 255, 0.18)":"rgba(48, 220, 255, 0.16)"}}}),label:{show:!0,position:"right",color:"rgba(239, 255, 255, 0.92)",fontSize:11,fontWeight:800,formatter:({dataIndex:v})=>{const b=r[v]||{};return b.isMissing?"待补强":`${ae(b.value)}头`}},markLine:c>0?{symbol:"none",silent:!0,lineStyle:{color:"rgba(139, 247, 255, 0.46)",type:"dashed",width:1},label:{color:"rgba(201, 251, 255, 0.8)",fontSize:10,formatter:"均衡线"},data:[{xAxis:c}]}:void 0}]}}),S(()=>{const r=Ao.value,n=["#30dcff","#8bf7ff","#58d9ff","#28e8d6","#7bdfff","#9efcff","#48cfff","#40b8ff","#8bf7ff"],s=r.length?r.map((c,f)=>({name:String(c.name||"").replace(/(村|社区|牧委会)$/,""),value:Math.max(Number(c.value||0),1),rawValue:Number(c.value||0),town:c.town||"",itemStyle:{color:new Ae(0,0,1,1,[{offset:0,color:n[f%n.length]},{offset:1,color:"rgba(17, 70, 92, 0.38)"}])}})):[{name:"待形成",value:1,rawValue:0,town:"",itemStyle:{color:"rgba(48, 220, 255, 0.14)"}}];return{tooltip:E(I({},ye()),{formatter(c){const f=c.data||{};return f.rawValue?`${f.town?`${f.town} `:""}${f.name}<br/>覆盖量:${Y(f.rawValue)}头`:`${f.name}<br/>暂无村级覆盖量`}}),series:[{type:"treemap",roam:!1,nodeClick:!1,breadcrumb:{show:!1},left:6,right:6,top:7,bottom:5,visibleMin:1,data:s,label:{show:!0,color:"rgba(235, 254, 255, 0.9)",fontSize:10,fontWeight:800,lineHeight:14,formatter(c){var v;const f=Number(((v=c.data)==null?void 0:v.rawValue)||0);return f?`${c.name}
${ae(f)}头`:c.name}},upperLabel:{show:!1},itemStyle:{borderColor:"rgba(4, 24, 36, 0.88)",borderWidth:2,gapWidth:2},emphasis:{label:{color:"#ffffff"},itemStyle:{shadowBlur:6,shadowColor:"rgba(48, 220, 255, 0.18)"}},levels:[{itemStyle:{borderColor:"rgba(14, 75, 98, 0.72)",borderWidth:1,gapWidth:2}}]}]}});const Il=S(()=>{const r=or.value,n=r.length>8?10:12,s=n+8,c=r.map(B=>Number(B.recordCount||0)),f=r.map(B=>Number(B.earTagCount||0)),v=Math.max(...c,1),b=r.map(()=>Math.ceil(v*1.08)),k=new Ae(0,0,0,1,[{offset:0,color:"rgba(48, 220, 255, 0.18)"},{offset:.48,color:"rgba(48, 220, 255, 0.06)"},{offset:1,color:"rgba(48, 220, 255, 0.02)"}]),R=new Ae(0,0,0,1,[{offset:0,color:"#31f7ff"},{offset:.36,color:"#1cbcff"},{offset:1,color:"#266dff"}]);return{color:["#31f7ff","#8bf7ff"],title:{text:`台账总量:{value|${ae(yt.value)}条}`,right:0,top:0,textStyle:{color:"#fff",fontSize:12,fontWeight:500,rich:{value:{color:"#22f1ff",borderColor:"#14bdf4",borderWidth:1,borderRadius:2,padding:[2,6,3,6],fontSize:12,fontWeight:700}}}},tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(B){const $=r[B[0].dataIndex];return[`${$.name}`,`防疫记录:${Y($.recordCount)}条`,`耳标数量:${Y($.earTagCount)}头`,"数据来源:防疫台账"].join("<br/>")}}),legend:[{data:["防疫记录"],top:0,left:0,itemWidth:10,itemHeight:10,icon:"circle",textStyle:{color:w,fontSize:11},selectedMode:!1},{data:["耳标数"],top:0,left:82,itemWidth:10,itemHeight:10,icon:"circle",textStyle:{color:w,fontSize:11},selectedMode:!1}],grid:{left:42,right:12,top:46,bottom:68},xAxis:{type:"category",data:r.map(B=>B.name),axisLabel:{color:w,fontSize:10,interval:0,lineHeight:11,margin:8,formatter:Fr},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!1}},yAxis:{type:"value",name:"数量/条",max:Math.ceil(v*1.2),nameTextStyle:{color:x,fontSize:10,align:"left"},axisLabel:{color:x,fontSize:10,formatter:ae},axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:G,type:"dashed"}}},series:[{name:"统计底柱",type:"bar",barWidth:s,barGap:"-100%",data:b,tooltip:{show:!1},silent:!0,z:1,itemStyle:{borderRadius:[8,8,1,1],borderColor:"rgba(48, 220, 255, 0.22)",borderWidth:1,color:k}},{name:"防疫记录",type:"bar",barGap:"-100%",barWidth:n,barMinHeight:2,z:3,data:c.map(B=>({value:B,itemStyle:{borderRadius:[8,8,1,1],borderColor:"rgba(200, 252, 255, 0.22)",borderWidth:1,color:R,shadowBlur:10,shadowColor:"rgba(49, 247, 255, 0.28)"}}))},{name:"耳标数",type:"line",smooth:!0,showSymbol:!1,z:9,data:f,lineStyle:{width:1.6,color:"#8bf7ff",shadowBlur:0,shadowColor:"transparent"},itemStyle:{color:"#8bf7ff"}}]}}),_l=S(()=>{const r=Co.value;return{tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(n){const s=r[n[0].dataIndex];return`${s.name}<br/>防疫记录:${Y(s.value)}条`}}),grid:{left:74,right:42,top:12,bottom:8},xAxis:{type:"value",axisLabel:{color:x,fontSize:10,formatter:ae},axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:G,type:"dashed"}}},yAxis:{type:"category",inverse:!0,data:r.map(n=>n.name),axisLabel:{color:w,fontSize:10,fontWeight:700,interval:0},axisLine:{show:!1},axisTick:{show:!1}},series:[{name:"记录",type:"bar",barWidth:9,data:r.map(n=>({value:n.value,itemStyle:{borderRadius:[1,2,2,1],color:new Ae(0,0,1,0,[{offset:0,color:"rgba(67, 217, 232, 0.14)"},{offset:.58,color:"rgba(67, 217, 232, 0.7)"},{offset:1,color:Bn}])}})),label:{show:!0,position:"right",color:"#eaffff",fontSize:10,formatter:({value:n})=>ae(n)}}]}}),Gl=S(()=>{const r=zo.value;return{color:["#30dcff","#8bf7ff"],tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(n){const s=n.find(f=>f.seriesName==="流通头数"),c=n.find(f=>f.seriesName==="出证记录");return`${(s==null?void 0:s.axisValue)||""}<br/>流通头数:${Y((s==null?void 0:s.value)||0)}头<br/>出证记录:${Y((c==null?void 0:c.value)||0)}条`}}),legend:{top:4,right:10,itemWidth:12,itemHeight:8,textStyle:{color:F,fontSize:10}},grid:{left:42,right:38,top:34,bottom:28},xAxis:{type:"category",data:r.map(n=>n.name),axisLabel:{color:x,fontSize:10,interval:1},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.24)"}},axisTick:{show:!1}},yAxis:[{type:"value",axisLabel:{color:x,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:G,type:"dashed"}}},{type:"value",axisLabel:{color:F,fontSize:10,formatter:ae},splitLine:{show:!1}}],series:[{name:"流通头数",type:"bar",barMaxWidth:13,data:r.map(n=>n.headCount),itemStyle:{borderRadius:[7,7,0,0],color:new Ae(0,0,0,1,[{offset:0,color:"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.08)"}])}},{name:"出证记录",type:"line",yAxisIndex:1,smooth:!0,symbolSize:5,data:r.map(n=>n.recordCount),lineStyle:{width:2.2,color:"#8bf7ff"},itemStyle:{color:"#8bf7ff",borderColor:"rgba(3, 18, 28, 0.9)",borderWidth:2}}]}}),Al=S(()=>Pn(hn.value.slice(0,10),"headCount","头",{style:"ladder",axisTextColor:"rgba(255, 255, 255, 0.88)",dimAxisTextColor:"rgba(255, 255, 255, 0.74)",tooltipFormatter(r){const n=hn.value[r.dataIndex];return`${n.name}<br/>流通头数:${Y(n.headCount)}头<br/>出证记录:${Y(n.recordCount)}条`}})),Bl=S(()=>{const r=mi.value;return{color:rt,tooltip:ye(n=>{const s=r.find(c=>c.name===n.name);return`${n.name}<br/>占比:${n.percent}%<br/>流通头数:${Y(n.value)}头<br/>出证记录:${Y((s==null?void 0:s.recordCount)||0)}条`}),legend:{orient:"vertical",right:4,top:"middle",itemWidth:8,itemHeight:8,itemGap:6,textStyle:{color:F,fontSize:10},formatter(n){const s=r.find(c=>c.name===n);return s?`${n} ${ae(s.headCount)}头`:n}},series:[{name:"用途结构",type:"pie",radius:["38%","64%"],center:["32%","54%"],startAngle:110,label:{show:!1},labelLine:{show:!1},itemStyle:{borderColor:"rgba(3, 18, 31, 0.92)",borderWidth:3},data:r.map(n=>({name:n.name,value:n.headCount}))}]}}),$l=S(()=>{const r=[{name:"省外A证",value:bt("outProvinceHeads","aCertHeads")},{name:"省内B证",value:bt("inProvinceHeads","bCertHeads")}];return{color:["#8bf7ff","#30dcff"],tooltip:ye(n=>`${n.name}<br/>流通头数:${Y(n.value)}头<br/>占比:${n.percent}%`),series:[{type:"pie",radius:["48%","72%"],center:["50%","52%"],label:{show:!1},labelLine:{show:!1},itemStyle:{borderColor:"rgba(3, 18, 31, 0.92)",borderWidth:3},data:r}]}}),El=S(()=>{const r=bi.value,n=[...new Set(r.map(f=>f.recordYear))].sort(),s=[...new Set(r.map(f=>f.townName))].map(f=>({name:f,total:r.filter(v=>v.townName===f).reduce((v,b)=>v+b.headCount,0)})).sort((f,v)=>v.total-f.total).slice(0,10).map(f=>f.name),c=["#30dcff","#ffd76c","#27f0c0","#8bf7ff"];return{color:c,tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},valueFormatter:f=>`${Y(f)}头`}),legend:{top:2,right:6,itemWidth:10,itemHeight:6,textStyle:{color:F,fontSize:10}},grid:{left:44,right:10,top:32,bottom:54},xAxis:{type:"category",data:s,axisLabel:{color:w,fontSize:9,interval:0,formatter:Fr},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.24)"}},axisTick:{show:!1}},yAxis:{type:"value",name:"头",nameTextStyle:{color:x,fontSize:10},axisLabel:{color:x,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:G,type:"dashed"}}},series:n.map((f,v)=>({name:`${f}年`,type:"bar",barMaxWidth:10,data:s.map(b=>{var k;return((k=r.find(R=>R.recordYear===f&&R.townName===b))==null?void 0:k.headCount)||0}),itemStyle:{borderRadius:[5,5,0,0],color:new Ae(0,0,0,1,[{offset:0,color:c[v%c.length]},{offset:1,color:"rgba(5, 29, 42, 0.12)"}])}}))}}),Vl=S(()=>{const r=wi.value;return{color:["#30dcff","#ffd76c","#27f0c0","#8bf7ff"],tooltip:ye(n=>`${n.name}<br/>出栏:${Y(n.value)}头<br/>占比:${n.percent}%`),legend:{orient:"vertical",right:4,top:"middle",itemWidth:8,itemHeight:8,itemGap:9,textStyle:{color:F,fontSize:10},formatter(n){const s=r.find(c=>c.name===n);return s?`${n} ${ae(s.headCount)}头`:n}},graphic:[{type:"text",left:"28%",top:"44%",style:{text:"检疫畜种",fill:F,font:`10px ${za.ui}`}},{type:"text",left:"28%",top:"54%",style:{text:`${r.length}类`,fill:C,font:`700 16px ${za.number}`}}],series:[{type:"pie",radius:["42%","68%"],center:["34%","52%"],startAngle:110,label:{show:!1},labelLine:{show:!1},itemStyle:{borderColor:"rgba(3, 18, 31, 0.92)",borderWidth:3},data:r.map(n=>({name:n.name,value:n.headCount}))}]}}),Dl=S(()=>{const r=Li.value.slice(0,7);return{tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(n){var c;const s=r[(c=n[0])==null?void 0:c.dataIndex];return`${(s==null?void 0:s.name)||""}<br/>出栏:${Y((s==null?void 0:s.headCount)||0)}头<br/>检疫票:${Y((s==null?void 0:s.certificateCount)||0)}张`}}),grid:{left:40,right:12,top:12,bottom:54},xAxis:{type:"category",data:r.map(n=>n.name),axisLabel:{color:w,fontSize:9,interval:0,formatter:Fr},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.24)"}},axisTick:{show:!1}},yAxis:{type:"value",axisLabel:{color:x,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:G,type:"dashed"}}},series:[{type:"bar",barMaxWidth:18,data:r.map((n,s)=>({value:n.headCount,itemStyle:{borderRadius:[9,9,0,0],color:new Ae(0,0,0,1,[{offset:0,color:s===0?"#ffd76c":"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.08)"}])}}))}]}}),zl=S(()=>Pn(mr.value.slice(0,10),"certificateCount","张",{style:"ladder",axisTextColor:"rgba(255, 255, 255, 0.9)",dimAxisTextColor:"rgba(255, 255, 255, 0.72)",tooltipFormatter(r){const n=mr.value[r.dataIndex];return`${n.name}<br/>检疫票:${Y(n.certificateCount)}张<br/>出栏:${Y(n.headCount)}头`}}));function Lr(){l.value=typeof window=="undefined"?1080:window.innerHeight}function Mi(){var r,n,s,c,f,v;if(tt.value){(n=(r=Na.value)==null?void 0:r.refreshView)==null||n.call(r);return}(c=(s=$e.value)==null?void 0:s.resume)==null||c.call(s),(v=(f=$e.value)==null?void 0:f.refreshView)==null||v.call(f)}function Ci(){Ft&&(window.clearTimeout(Ft),Ft=null)}function Pi(){var r,n,s,c,f,v;if(Ze.value=!1,en.value={type:"loading",text:"地图正在复位"},tn.value={type:"idle",text:""},tt.value){(n=(r=Na.value)==null?void 0:r.hasMap)!=null&&n.call(r)?(Fa.value=!0,(c=(s=Na.value)==null?void 0:s.resetView)==null||c.call(s)):(Fa.value=!1,Xr.value+=1,ia(()=>{window.setTimeout(()=>{var b,k;return(k=(b=Na.value)==null?void 0:b.refreshView)==null?void 0:k.call(b)},160)}));return}if((v=(f=$e.value)==null?void 0:f.hasMap)!=null&&v.call(f)){ha.value=!0,Mi();return}Ci(),ha.value=!1,Dt=!1,Zr.value+=1,ia(()=>{Cn()})}function Ol(){Ze.value=!1,Pi()}e({refreshMapView:Mi,resetMap:Pi,setActiveView(r){z.value=Br(r)}}),io(()=>{Lr(),window.addEventListener("resize",Lr),ls(),us(z.value),mn()}),so(()=>{var r,n;pa=!0,window.removeEventListener("resize",Lr),Ft&&window.clearTimeout(Ft),Tr(),Sn(),(n=(r=$e.value)==null?void 0:r.destroyMap)==null||n.call(r)}),oa([z,et,zt,sr,yt,_e,be,he,pi,pn],()=>{Cu()},{immediate:!0}),oa(z,(r,n)=>{i("view-change",r),us(r);const s=r==="structure"||r==="forecast",c=n==="structure"||n==="forecast",f=new Set(["trade","slaughter"]),v=!s&&!c&&(f.has(r)||f.has(n));s&&!c&&(Ze.value=!1,Fa.value=!1,en.value={type:"idle",text:""},tn.value={type:"idle",text:""}),!s&&c&&(ls(),Ci(),Ze.value=!1,ha.value=!1,Dt=!1,en.value={type:"idle",text:""},tn.value={type:"idle",text:""},ia(()=>{var b,k,R,B;Cn(),(k=(b=$e.value)==null?void 0:b.resume)==null||k.call(b),(B=(R=$e.value)==null?void 0:R.refreshView)==null||B.call(R),window.setTimeout(()=>{var $,X;return(X=($=$e.value)==null?void 0:$.refreshView)==null?void 0:X.call($)},180)})),v&&ia(()=>{var b,k,R,B;(k=(b=$e.value)==null?void 0:b.resume)==null||k.call(b),(B=(R=$e.value)==null?void 0:R.refreshView)==null||B.call(R)}),mn(),Ar()}),oa(()=>a.viewKey,r=>{const n=Br(r);n!==z.value&&(z.value=n)}),oa(()=>a.active,r=>{var n,s,c,f;r?(Cn(),(s=(n=$e.value)==null?void 0:n.resume)==null||s.call(n),mn(),Ar()):((f=(c=$e.value)==null?void 0:c.pause)==null||f.call(c),Tr(),Sn())}),oa(fn,r=>{pt.value>=r.pageCount&&(pt.value=0),mn()});function Wl(r){r!==Mt.value&&(Mt.value=r)}function mn(){Tr(),!(!a.active||z.value!=="structure"||pa||fn.value.pageCount<=1)&&(nn=window.setInterval(Yl,Pf))}function Yl(){const r=fn.value.pageCount;r<=1||(pt.value=(pt.value+1)%r)}function Tr(){nn&&(window.clearInterval(nn),nn=null)}function jl(r){return Dn(r||"")}function at(r){return String(r||"").trim()}function Sr(r){const n=Number(r);return Number.isFinite(n)&&qe.includes(n)?n:qe[qe.length-1]}function kr(r=_e.value){const n=Sr(r);return{startDate:`${n}-01-01`,endDate:`${n}-12-31`}}function gn(){return{keyword:"",town:"",medicine:"",startDate:"",endDate:""}}function Mr(){return{keyword:"",town:"",destination:"",usage:"",certType:"",direction:""}}function Hl(r=[]){return Array.isArray(r)?r.map((n,s)=>({key:`${n.recordYear||n.record_year}-${n.townName||n.town_name||s}`,recordYear:Number(n.recordYear||n.record_year),townName:String(n.townName||n.town_name||"未标注"),certificateCount:Number(n.certificateCount||n.certificate_count||0),headCount:Number(n.headCount||n.head_count||0)})).filter(n=>Number.isFinite(n.recordYear)&&n.townName&&Number.isFinite(n.headCount)):[]}function yn(r=[]){return Array.isArray(r)?r.map((n,s)=>({key:n.key||n.name||`${s}`,name:String(n.name||n.townName||n.town_name||"未标注"),certificateCount:Number(n.certificateCount||n.certificate_count||n.recordCount||n.record_count||0),headCount:Number(n.headCount||n.head_count||n.value||0)})).filter(n=>n.name&&Number.isFinite(n.headCount)):[]}function vn(r=[]){return Array.isArray(r)?r.map((n,s)=>{const c=n.destinationProvinceName||n.destination_province_name||"未标注",f=n.destinationCityName||n.destination_city_name||"未标注",v=[c,f].filter((b,k,R)=>b&&b!=="未标注"&&R.indexOf(b)===k);return{recordKey:n.recordKey||n.record_key||`slaughter-${s}`,certificateDisplay:n.certificateDisplay||n.certificate_display||"--",ownerDisplay:n.ownerDisplay||n.owner_display||"--",vehicleDisplay:n.vehicleDisplay||n.vehicle_display||"--",certificateType:n.certificateType||n.certificate_type||"--",issueTime:n.issueTime||n.issue_time||"",animalTypeName:n.animalTypeName||n.animal_type_name||"--",animalQuantity:Number(n.animalQuantity||n.animal_quantity||0),quantityUnit:n.quantityUnit||n.quantity_unit||"头",movementPurposeName:n.movementPurposeName||n.movement_purpose_name||"未标注",originTownName:n.originTownName||n.origin_town_name||"未标注",destinationProvinceName:c,destinationCityName:f,destinationName:v.join(" ")||"未标注",destinationDirection:n.destinationDirection||n.destination_direction||"未标注",recordStatusName:n.recordStatusName||n.record_status_name||"未标注"}}):[]}function xt(r=[]){return Array.isArray(r)?r.map((n,s)=>{var c,f,v,b,k,R,B,$,X;return{key:n.key||n.id||`${n.name||n.label||"item"}-${s}`,name:String(n.name||n.label||n.town||n.village||"未填写"),value:Number((v=(f=(c=n.value)!=null?c:n.count)!=null?f:n.total)!=null?v:0),recordCount:Number((B=(R=(k=(b=n.recordCount)!=null?b:n.record_count)!=null?k:n.value)!=null?R:n.count)!=null?B:0),earTagCount:Number((X=($=n.earTagCount)!=null?$:n.ear_tag_count)!=null?X:0)}}).filter(n=>n.name&&Number.isFinite(n.value)):[]}function Ni(r={}){const n=xt(r==null?void 0:r.medicineCounts);return Math.max(n.filter(s=>s.name!=="未填写").length,1)}function Cr(...r){const n=r.flatMap(s=>Array.isArray(s)?s:[s]).map(s=>{var c,f,v;return s&&typeof s=="object"?(v=(f=(c=s.year)!=null?c:s.value)!=null?f:s.latestYear)!=null?v:s.latest_year:s}).map(Number).filter(s=>Number.isFinite(s)&&s>0);return[...new Set(n)].sort((s,c)=>s-c)}function bn(r=[],n="name"){return Array.isArray(r)?r.map((s,c)=>{var f,v,b,k,R,B,$,X,ue,ce,we,We,Lt,aa,Ga,Aa,Ba;return{key:s.key||s.id||`${s[n]||s.name||s.label||"trade"}-${c}`,name:String(s[n]||s.name||s.label||s.town||"未填写"),recordCount:Number((b=(v=(f=s.recordCount)!=null?f:s.record_count)!=null?v:s.count)!=null?b:0),headCount:Number(($=(B=(R=(k=s.headCount)!=null?k:s.head_count)!=null?R:s.amount)!=null?B:s.value)!=null?$:0),lng:vt((We=(we=(ce=(ue=(X=s.lng)!=null?X:s.longitude)!=null?ue:s.destLng)!=null?ce:s.dest_lng)!=null?we:s.destLongitude)!=null?We:s.dest_longitude),lat:vt((Ba=(Aa=(Ga=(aa=(Lt=s.lat)!=null?Lt:s.latitude)!=null?aa:s.destLat)!=null?Ga:s.dest_lat)!=null?Aa:s.destLatitude)!=null?Ba:s.dest_latitude)}}).filter(s=>s.name&&Number.isFinite(s.headCount)):[]}function ql(r=[]){return Array.isArray(r)?r.map(n=>{var s,c,f,v,b,k;return{year:Number(n.year),recordCount:Number((c=(s=n.recordCount)!=null?s:n.record_count)!=null?c:0),headCount:Number((k=(b=(v=(f=n.headCount)!=null?f:n.head_count)!=null?v:n.amount)!=null?b:n.value)!=null?k:0)}}).filter(n=>Number.isFinite(n.year)&&Number.isFinite(n.headCount)):[]}function fa(r=[]){return Array.isArray(r)?Pr(r.map(n=>{var s,c,f;return n&&typeof n=="object"?(f=(c=(s=n.value)!=null?s:n.label)!=null?c:n.name)!=null?f:"":n})):[]}function Ul(r=[]){return Array.isArray(r)?r.map(n=>{var s,c,f,v,b,k;if(n&&typeof n=="object"){const R=(f=(c=(s=n.value)!=null?s:n.name)!=null?c:n.label)!=null?f:"",B=(k=(b=(v=n.label)!=null?v:n.name)!=null?b:n.value)!=null?k:R;return R?{value:String(R),label:String(B||R)}:null}return n?{value:String(n),label:String(n)}:null}).filter(Boolean):[]}function Pr(r=[]){return[...new Set(r.map(n=>String(n||"").trim()).filter(Boolean))]}function Kl(r=[]){if(!Array.isArray(r))return[];const n=new Map;r.forEach((c,f)=>{var B,$,X,ue,ce,we;const v=at(c.name||c.areaName||c.area_name||c.town||c.label||"");if(!v)return;const b=vt((X=($=(B=c.value)!=null?B:c.number)!=null?$:c.count)!=null?X:c.total);if(!Number.isFinite(b))return;const k=n.get(v)||{key:c.areaCode||c.area_code||`${v}-${f}`,name:v,recordCount:0,earTagCount:0,source:"stats"};k.recordCount+=b;const R=vt((we=(ce=(ue=c.earTagCount)!=null?ue:c.ear_tag_count)!=null?ce:c.headCount)!=null?we:c.head_count);k.earTagCount+=Number.isFinite(R)?R:0,n.set(v,k)});const s=[...n.values()].reduce((c,f)=>c+Number(f.recordCount||0),0);return[...n.values()].map(c=>E(I({},c),{earTagCount:c.earTagCount||Math.round(Number(c.recordCount||0)/Ot.value),ratio:s?Number(c.recordCount||0)/s*100:0})).sort((c,f)=>Number(f.recordCount||0)-Number(c.recordCount||0))}function Zl(r={}){var f,v;const n=Array.isArray(r)?{rows:r}:r||{},s=n.result||{};return{rows:n.rows||n.data||n.list||n.records||[],year:(v=(f=n.year)!=null?f:s.year)!=null?v:null}}function Nr(r=[]){return Array.isArray(r)?r.map((n,s)=>{var X,ue,ce,we,We,Lt,aa,Ga,Aa,Ba,bs,ws;const c=at(n.town||n.townName||n.town_name||""),f=String(n.village||n.villageName||n.village_name||n.name||"").trim(),v=vt((ce=(ue=(X=n.recordCount)!=null?X:n.record_count)!=null?ue:n.records)!=null?ce:n.total),b=vt((aa=(Lt=(We=(we=n.earTagCount)!=null?we:n.ear_tag_count)!=null?We:n.headCount)!=null?Lt:n.head_count)!=null?aa:n.value),k=vt((Aa=(Ga=n.imageCount)!=null?Ga:n.image_count)!=null?Aa:n.images),R=vt((Ba=n.imageRate)!=null?Ba:n.image_rate),B=vt((bs=n.lng)!=null?bs:n.longitude),$=vt((ws=n.lat)!=null?ws:n.latitude);return{key:n.key||n.id||`${c}-${f}-${s}`,town:c,village:f,recordCount:Number.isFinite(v)?v:0,earTagCount:Number.isFinite(b)?b:0,imageCount:Number.isFinite(k)?k:0,imageRate:Number.isFinite(R)?R:0,lng:B,lat:$}}).filter(n=>n.town&&n.village&&Number.isFinite(n.earTagCount)).sort((n,s)=>Number(s.earTagCount||0)-Number(n.earTagCount||0)):[]}function Xl(r={},n={}){const s=Array.isArray(n)?{rows:n}:n||{},c=s.result||{},f=Nr(s.rows||s.data||s.list||s.records||c.rows||[]),v=new Map;f.forEach($=>{Fi($.village).forEach(X=>{v.has(X)||v.set(X,$)})});const b=xt(r==null?void 0:r.townCounts),k=b.length===1?at(b[0].name):"",R=Ni(r),B=xt(r==null?void 0:r.villageCounts).map(($,X)=>{var We,Lt;const ue=String($.name||"").trim(),ce=Fi(ue).map(aa=>v.get(aa)).find(Boolean)||{},we=Number((Lt=(We=$.recordCount)!=null?We:$.value)!=null?Lt:0);return{key:ce.key||`${ce.town||k||"防疫"}-${ue}-${X}`,town:ce.town||k,village:ue,recordCount:we,earTagCount:Number($.earTagCount||0)||Math.round(we/R),imageCount:ce.imageCount||0,imageRate:ce.imageRate||0,lng:ce.lng,lat:ce.lat}}).filter($=>$.village&&$.recordCount>0);return E(I({},s),{rows:B})}function Fi(r){const n=String(r||"").trim(),s=n.replace(/(村|社区|牧委会)$/,"");return[...new Set([n,s].filter(Boolean))]}function vt(r){if(r==null||r==="")return NaN;const n=Number(String(r).replace(/,/g,"").replace(/%/g,""));return Number.isFinite(n)?n:NaN}function xi(r){return String(r||"").replace(/'/g,"''").replace(/%/g,"\\%").replace(/_/g,"\\_")}function Ql(r,n){const s=at(r),c=String(n||"").trim();if(!s||!c)return"";const f=xi(s),v=xi(c);return`(town_name = '${f}' AND village_name = '${v}')`}function Fr(r){const n=String(r||"").trim().replace(/\s+/g,"");return n?Array.from(n).join(`
`):""}function Jl(r){const n=String(r||"").trim();if(!n)return"";const s=n.match(/^(.+)(镇|乡|村)$/);return s?`${s[1]}
${s[2]}`:n}function eu(r,n){return Ri(r.name)-Ri(n.name)}function Ri(r){const n=String(r||"").match(/(\d{1,2})\D+(\d{1,2})/);return n?Number(n[1])*100+Number(n[2]):Number.MAX_SAFE_INTEGER}function xr(r=[]){return Array.isArray(r)?r.map(Ii).filter(Boolean):[]}function Ii(r){return r?{epidemicId:r.epidemicId||r.epidemic_id||r.id||"",earTag:r.earTag||r.ear_tag||"",owner:r.owner||"",idType:r.idType||r.id_type||"",idNo:r.idNo||r.id_no||"",phone:r.phone||"",town:r.town||"",village:r.village||"",location:r.location||"",livestockType:r.livestockType||r.livestock_type||"",age:r.age||"",sex:r.sex||"",weight:r.weight||r.weightKg||r.weight_kg||"",preventionType:r.preventionType||r.prevention_type||"",method:r.method||"",medicine:r.medicine||"",dose:r.dose||"",operator:r.operator||"",operateTime:r.operateTime||r.operate_time||"",imagePaths:r.imagePaths||r.image_paths||""}:null}function _i(r=[]){return Array.isArray(r)?r.map(tu).filter(Boolean):[]}function tu(r){var n,s,c,f;return r?{certId:r.certId||r.cert_id||r.id||"",certType:r.certType||r.cert_type||"",certScopeName:r.certScopeName||r.cert_scope_name||"",factoryCode:r.factoryCode||r.factory_code||"",ownerName:r.ownerName||r.owner_name||"",ownerPhone:r.ownerPhone||r.owner_phone||"",transportNumber:r.transportNumber||r.transport_number||"",amount:Number((f=(c=(s=(n=r.amount)!=null?n:r.headCount)!=null?s:r.head_count)!=null?c:r.value)!=null?f:0),unitName:r.unitName||r.unit_name||"头",animalTypeName:r.animalTypeName||r.animal_type_name||"",usageTypeName:r.usageTypeName||r.usage_type_name||"",startTown:r.startTown||r.start_town||"",startRegionFullName:r.startRegionFullName||r.start_region_full_name||"",destProvince:r.destProvince||r.dest_province||"",destRegionFullName:r.destRegionFullName||r.dest_region_full_name||"",quarantineOfficerName:r.quarantineOfficerName||r.quarantine_officer_name||"",issueTime:r.issueTime||r.issue_time||"",statusName:r.statusName||r.status_name||""}:null}function ea(r,n){for(const s of n){const c=Number(r==null?void 0:r[s]);if(Number.isFinite(c))return c}return 0}function bt(...r){return ea(pi.value,r)}function Ia(...r){return ea(pn.value,r)}function au(r){const n=String(r||"").trim();if(!n)return"--";const s=n.match(/^\d{4}-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}))?/);return s?`${s[1]}-${s[2]}${s[3]?` ${s[3]}:${s[4]}`:""}`:n}function Gi(r=[],n=2){const s=[...new Set(r.map(c=>String(c||"").trim()).filter(Boolean))];return s.length?s.length<=n?s.join("、"):`${s.slice(0,n).join("、")}等${s.length}个乡镇`:"暂无"}function nu(){const r=Wt.value;if(r.length)return{name:Gi(r,1),desc:"年度防疫覆盖需补强",level:"watch"};const n=Qt.value.filter(c=>Number(c.earTagCount||c.recordCount||0)>0).sort((c,f)=>Number(c.earTagCount||c.recordCount||0)-Number(f.earTagCount||f.recordCount||0)),s=n[0];return s?{name:s.name,desc:`${ae(s.earTagCount||s.recordCount)}头,建议补免回访`,level:n.length>=2?"watch":"normal"}:{name:"暂无",desc:"等待年度防疫记录形成",level:"normal"}}function ru(){const r=Wt.value;if(r.length)return r.slice(0,4).map((c,f)=>({key:`missing-${c}`,name:c,value:Math.max(25,100-f*12),label:"待补免",level:"watch"}));const n=Qt.value.filter(c=>Number(c.earTagCount||c.recordCount||0)>0);if(!n.length)return[{key:"empty",name:"暂无",value:0,label:"待开展",level:"watch"}];const s=n.reduce((c,f)=>c+Number(f.earTagCount||0),0)/n.length||1;return[...n].sort((c,f)=>Number(c.earTagCount||0)-Number(f.earTagCount||0)).slice(0,4).map(c=>{const f=Number(c.earTagCount||c.recordCount||0),v=Math.max(8,Math.round((s-f)/s*100));return{key:`weak-${c.name}`,name:c.name,value:Math.min(100,v),label:`${ae(f)}头`,level:v>=35?"watch":"normal"}})}function iu(){const n=(or.value.length?or.value:Qt.value).map((f,v)=>{const b=at(f.name),k=Number(f.earTagCount||0),R=Number(f.recordCount||f.value||0),B=k||Math.round(R/Ot.value);return{key:f.key||`${b}-${v}`,name:b,value:B,recordCount:R,isMissing:!1}}).filter(f=>f.name&&Number.isFinite(f.value)),c=[...Wt.value.map((f,v)=>({key:`missing-${f}-${v}`,name:f,value:0,recordCount:0,isMissing:!0})),...n];return c.length?c.sort((f,v)=>f.isMissing!==v.isMissing?f.isMissing?-1:1:Number(f.value||0)-Number(v.value||0)).slice(0,7):[{key:"empty",name:"待开展",value:0,recordCount:0,isMissing:!0}]}function su(){var n;const r=ci.value.map((s,c)=>({key:s.key||`${s.town}-${s.village}-${c}`,name:s.village||s.name,town:s.town,value:Number(s.earTagCount||s.value||0)})).filter(s=>s.name&&Number.isFinite(s.value)&&s.value>0);return r.length?r.sort((s,c)=>c.value-s.value).slice(0,9):xt((n=Fe.value)==null?void 0:n.villageCounts).map((s,c)=>({key:s.key||`${s.name}-${c}`,name:s.name,town:"",value:Math.round(Number(s.value||0)/Ot.value)})).filter(s=>s.name&&Number.isFinite(s.value)&&s.value>0).sort((s,c)=>c.value-s.value).slice(0,9)}function ou(){if(!yt.value)return{level:"watch",title:"年度待开展",desc:"年度免疫记录暂未形成",advice:"建议先核查年度免疫计划与乡镇推进节奏。"};const r=Io.value,n=dn.value;return Wt.value.length?{level:"watch",title:"补免待核查",desc:`乡镇覆盖${wt(r)},${n.name}需补强`,advice:`优先核查${Gi(Wt.value,1)}免疫进度。`}:r>=90&&Ot.value>=4?{level:"stable",title:"运行平稳",desc:`乡镇覆盖${wt(r)},疫苗谱较完整`,advice:"建议保持当前免疫节奏,持续跟踪补免回访。"}:{level:"normal",title:"均衡回访",desc:`${n.name}相对偏低,适合继续跟进`,advice:`关注${n.name}补免回访,保持覆盖均衡。`}}function lu(){return[{key:"latest",name:"最近免疫",value:ui.value,desc:"最后作业时间",level:ui.value==="-"?"watch":"stable",color:"#8bf7ff"},{key:"top-town",name:"高频乡镇",value:Fo.value,desc:"年度作业集中区",level:"normal",color:"#30dcff"},{key:"vaccine",name:"主用疫苗",value:Po.value,desc:`${Ot.value}类疫苗`,level:"normal",color:"#8bf7ff"}]}function uu(r=[]){if(!Array.isArray(r))return[];const n=["#63d7ff","#30dcff","#48cfff","#48cfff"];return r.map((s,c)=>{const f=s.level==="重点"?"high":s.level==="关注"?"watch":"normal";return{key:s.key||`risk-${c}`,name:s.name||"监管线索",value:s.detail||"暂无",desc:s.level==="重点"?"重点关注":s.level==="关注"?"持续关注":"运行平稳",level:f,badge:s.level||"平稳",color:n[c%n.length]}})}function Rr(r={}){return String(r.imagePaths||"").split(";").map(n=>n.trim()).filter(Boolean)}function Ai(r){const s=String(r||"").replace(/^images\//,"").split("/").map(encodeURIComponent).join("/");return`${Sf}/${s}`}function cu(r){st.value=Ai(r),He.value=!0}function Ir(){He.value=!1,st.value=""}function W(r){return r==null||r===""?"-":r}function du(r){const n=String(r!=null?r:"").trim();return!!(n&&n!=="-")}function Re(r,n,s={}){return du(n)?I({label:r,value:n},s):null}function ut(r){return r?String(r).slice(0,10):"-"}function Bi(r){const n=String(r||"").trim();return n?n.length<7?n:`${n.slice(0,3)}****${n.slice(-4)}`:"-"}function hu(r){const n=String(r||"").trim();return n?n.length<=4?n:`****${n.slice(-4)}`:"-"}function pu(r){const n=String(r!=null?r:"").trim();if(!n)return"-";if(/kg|公斤|千克/i.test(n))return n;const s=Number(n);return Number.isFinite(s)?`${Y(s)}kg`:n}function fu(r){return String(r!=null?r:"").trim()||"-"}function $i(r={}){return r.certScopeName||r.certType||"-"}function mu(){return oe(this,null,function*(){var c;it.value=!0,Me.value="";const[r,n,s]=yield Promise.allSettled([Tc(),Sc(),kc()]);r.status==="fulfilled"?(kd(r.value),Ne.value+=1):Me.value="牦牛管理基础数据接口异常",n.status==="fulfilled"&&((c=n.value)!=null&&c.length)&&($t.value=Fd(n.value.map(f=>({name:Dn(f.name),count:Number(f.value)})).filter(f=>f.name&&Number.isFinite(f.count)))),s.status==="fulfilled"?(ft.value=Au(s.value),ft.value.length||(Me.value="结构数据暂无数据")):(Me.value=$u(s.reason,"结构数据异常"),ft.value=[]),it.value=!1})}function Ei(){return oe(this,arguments,function*(r=be.value){var n,s,c,f,v,b;qt.value=!0,ua.value="";try{(s=(n=ge.value)==null?void 0:n.years)!=null&&s.length||(ge.value=yield Mc());const k=Cr((c=ge.value)==null?void 0:c.years),R=Number(((f=ge.value)==null?void 0:f.latestYear)||((v=ge.value)==null?void 0:v.latest_year)||k[k.length-1]),B=Number(r||be.value||R||k[k.length-1]);be.value=B;let $=yield Is({year:B});const X=(b=$==null?void 0:$.hasData)!=null?b:$==null?void 0:$.has_data,ue=Number(($==null?void 0:$.latestYear)||($==null?void 0:$.latest_year)||R);X===!1&&ue&&ue!==B&&(be.value=ue,$=yield Is({year:ue})),ie.value=$||{metrics:{},hasData:!1},yield _r(1)}catch(k){ua.value="交易数据接口异常",ie.value={metrics:{},hasData:!1},mt.value=[],Vt.value=0}finally{qt.value=!1}})}function _r(){return oe(this,arguments,function*(r=Pt.value){var s,c;if(!be.value)return;const n={year:be.value,page:r,pageSize:Wr,keyword:Wn.value};try{const f=yield _s(n);mt.value=_i(f.rows),Vt.value=Number(((s=f.page)==null?void 0:s.totalCount)||f.totalCount||mt.value.length||0),Pt.value=Number(((c=f.page)==null?void 0:c.page)||r||1)}catch(f){ua.value=ua.value||"交易台账接口异常",mt.value=[],Vt.value=0}})}function gu(r){const n=Number(r);!Number.isFinite(n)||n===Number(be.value)||(be.value=n,Pt.value=1,Ha.value="",Wn.value="",Ei(n))}function yu(r){const n=Sr(r);n!==Number(_e.value)&&(_e.value=n,Be.value=1,M.value="",L.value="",Le.value=1,me.value=gn(),Ji(n))}function Vi(){Wn.value=Ha.value.trim(),_r(1)}function Di(r){const n=Math.min(Math.max(Number(r)||1,1),cr.value);_r(n)}function zi(r=null){Yn.value=!0,r&&(Ua.value=r),wn(r?Pt.value:1,r)}function Oi(){Yn.value=!1}function Wi(){wn(1)}function vu(){gt.value={keyword:"",startTown:"",usageType:"",certType:""},wn(1)}function Yi(r){const n=Math.min(Math.max(Number(r)||1,1),dr.value);wn(n)}function wn(){return oe(this,arguments,function*(r=Kt.value,n=null){var f,v;if(!be.value)return;jn.value=!0,Hn.value="";const s=gt.value,c={year:be.value,page:r,pageSize:to,keyword:s.keyword.trim(),startTown:s.startTown,usageType:s.usageType,certType:s.certType};try{const b=yield _s(c);Ut.value=_i(b.rows),qa.value=Number(((f=b.page)==null?void 0:f.totalCount)||b.totalCount||Ut.value.length||0),Kt.value=Number(((v=b.page)==null?void 0:v.page)||r||1);const k=n?n.certId||n.factoryCode:"",R=k?Ut.value.find(B=>(B.certId||B.factoryCode)===k)||n:Ut.value[0]||null;ji(R)}catch(b){Hn.value="交易台账接口异常",Ut.value=[],qa.value=0,Ua.value=null}finally{jn.value=!1}})}function ji(r){Ua.value=r||null}function bu(r){r!=null&&r.startTown&&(z.value="trade",ia(()=>{var n,s,c,f,v,b;(s=(n=$e.value)==null?void 0:n.resume)==null||s.call(n),(f=(c=$e.value)==null?void 0:c.refreshView)==null||f.call(c),(b=(v=$e.value)==null?void 0:v.focusTown)==null||b.call(v,at(r.startTown),{distanceScale:.78,duration:.8})}))}function _a(r){if(r==null||r===""||r==="all")return null;const n=Number(r);return Number.isFinite(n)&&n>0?n:null}function Ln(r,n){return _a(r)===_a(n)}function Tn(r=he.value){const n=_a(r);return n==null?{}:{year:n}}function Hi(){return oe(this,arguments,function*(r=he.value){var k,R,B;const n=_a(r),s=++Zn;Sn(),Nt.value=!0,lt.value="";const c=Tn(n),[f,v,b]=yield Promise.allSettled([Gs(c),Cc(),In(E(I({},c),{page:1,pageSize:12}))]);s===Zn&&(he.value=n,f.status==="fulfilled"?xe.value=f.value||{metrics:{},hasData:!1}:(xe.value={metrics:{},hasData:!1},lt.value="出栏统计接口异常"),v.status==="fulfilled"?ca.value=v.value||{towns:[],destinations:[],usages:[]}:(R=(k=ca.value)==null?void 0:k.towns)!=null&&R.length||(ca.value={towns:[],destinations:[],usages:[]}),b.status==="fulfilled"?Ka.value=vn((B=b.value)==null?void 0:B.rows):Ka.value=[],yield Gr(1),s===Zn&&(Nt.value=!1,Ar()))})}function Gr(){return oe(this,arguments,function*(r=ot.value){var f,v;const n=++Xn,s=he.value,c=E(I({},Tn(s)),{page:r,pageSize:Yr,keyword:Xa.value});try{const b=yield In(c);if(n!==Xn||!Ln(s,he.value))return;Ca.value=vn(b.rows),da.value=Number(((f=b.page)==null?void 0:f.totalCount)||b.totalCount||Ca.value.length||0),ot.value=Number(((v=b.page)==null?void 0:v.page)||r||1)}catch(b){if(n!==Xn||!Ln(s,he.value))return;lt.value=lt.value||"出栏台账接口异常",Ca.value=[],da.value=0,ot.value=1}})}function wu(r){const n=_a(r);Ln(n,he.value)||(he.value=n,ot.value=1,Za.value="",Xa.value="",Qa.value=!1,Ke.value=Mr(),Hi(n))}function Lu(){return oe(this,null,function*(){var f,v,b,k;const r=he.value,n=Tn(r),[s,c]=yield Promise.allSettled([Gs(n),In(E(I({},n),{page:1,pageSize:12}))]);if(!(pa||z.value!=="slaughter"||!Ln(r,he.value))&&(s.status==="fulfilled"&&(xe.value=s.value||xe.value),c.status==="fulfilled")){const R=vn((f=c.value)==null?void 0:f.rows);Ka.value=R,ot.value===1&&!Xa.value&&(Ca.value=R,da.value=Number(((b=(v=c.value)==null?void 0:v.page)==null?void 0:b.totalCount)||((k=c.value)==null?void 0:k.totalCount)||da.value))}})}function Ar(){Sn(),!(!a.active||pa||z.value!=="slaughter"||!pr.value)&&(rn=window.setInterval(Lu,Nf))}function Sn(){rn&&(window.clearInterval(rn),rn=null)}function qi(){Xa.value=Za.value.trim(),Gr(1)}function Ui(r){const n=Math.min(Math.max(Number(r)||1,1),vr.value);Gr(n)}function Ki(r=null){Qa.value=!0,r&&(Pa.value=r),kn(r?ot.value:1,r)}function Zi(){Qa.value=!1}function Xi(){kn(1)}function Tu(){Ke.value=Mr(),kn(1)}function Qi(r){const n=Math.min(Math.max(Number(r)||1,1),br.value);kn(n)}function kn(){return oe(this,arguments,function*(r=Xt.value,n=null){var c,f;qn.value=!0,Un.value="";const s=Ke.value;try{const v=yield In(E(I({},Tn()),{page:r,pageSize:ao,keyword:s.keyword.trim(),town:s.town,destination:s.destination,usage:s.usage,certType:s.certType,direction:s.direction}));Zt.value=vn(v.rows),Ja.value=Number(((c=v.page)==null?void 0:c.totalCount)||v.totalCount||Zt.value.length||0),Xt.value=Number(((f=v.page)==null?void 0:f.page)||r||1);const b=n==null?void 0:n.recordKey;Pa.value=b?Zt.value.find(k=>k.recordKey===b)||n:Zt.value[0]||null}catch(v){Un.value="出栏台账接口异常",Zt.value=[],Ja.value=0,Pa.value=null}finally{qn.value=!1}})}function Su(r){Pa.value=r||null}function Ji(){return oe(this,arguments,function*(r=_e.value){var k;const n=Sr(r),s=kr(n);_e.value=n,A.value=!0,D.value="";const[c,f,v,b]=yield Promise.allSettled([Pc(s),Vr(I({page:Be.value,pageSize:$n,keyword:L.value},s)),Nc({year:n}),Fc({year:n})]);if(c.status==="fulfilled"?Fe.value=c.value||{metrics:{}}:(D.value="防疫统计接口异常",Fe.value={metrics:{}}),f.status==="fulfilled"){const R=f.value||{};De.value=xr(R.rows),ze.value=Number(((k=R.page)==null?void 0:k.totalCount)||R.totalCount||De.value.length||0)}else D.value=D.value||"防疫台账接口异常",De.value=[],ze.value=0;v.status==="fulfilled"?Et.value=Zl(v.value):Et.value={rows:[],year:null},b.status==="fulfilled"?Ct.value=Xl(Fe.value,b.value):Ct.value={rows:[]},A.value=!1})}function es(){return oe(this,arguments,function*(r=Be.value){var c,f;A.value=!0,D.value="";const n=Math.min(Math.max(Number(r)||1,1),lr.value),s=kr(_e.value);try{const v=yield Vr(I({page:n,pageSize:$n,keyword:L.value},s));De.value=xr(v.rows),ze.value=Number(((c=v.page)==null?void 0:c.totalCount)||v.totalCount||De.value.length||0),Be.value=Number(((f=v.page)==null?void 0:f.page)||n||1)}catch(v){D.value="防疫台账接口异常",De.value=[],ze.value=0,Be.value=1}finally{A.value=!1}})}function ts(){L.value=M.value.trim(),me.value=E(I({},gn()),{keyword:L.value}),es(1)}function as(r){es(r)}function ns(r=null){Z.value=!0,r&&(Oe.value=r,Ge.value=null),Mn(1,r)}function rs(){Z.value=!1,Ir()}function is(){Mn(1)}function ku(){me.value=gn(),Mn(1)}function ss(r){Mn(r)}function Mn(){return oe(this,arguments,function*(r=Le.value,n=null){var v,b;je.value=!0,Je.value="";const s=me.value,c=kr(_e.value),f={keyword:s.keyword.trim(),town:s.town,medicine:s.medicine,startDate:s.startDate||c.startDate,endDate:s.endDate||c.endDate,page:r,pageSize:eo};try{const k=yield Vr(f);re.value=xr(k.rows),fe.value=Number(((v=k.page)==null?void 0:v.totalCount)||k.totalCount||re.value.length||0),Le.value=Number(((b=k.page)==null?void 0:b.page)||r||1);const R=n||re.value[0]||null;R?os(R):(Oe.value=null,Ge.value=null)}catch(k){Je.value="台账接口异常",re.value=[],fe.value=0}finally{je.value=!1}})}function os(r){return oe(this,null,function*(){if(Oe.value=r,Ge.value=null,!(r!=null&&r.earTag)&&!(r!=null&&r.epidemicId))return;const n=++sn;Ue.value=!0;try{const s=yield xc(r.earTag||r.epidemicId);n===sn&&(Ge.value=Ii(s)||r)}catch(s){n===sn&&(Ge.value=r)}finally{n===sn&&(Ue.value=!1)}})}function ls(){var r;Qr||an||(Qr=!0,Kn=new Ec({includeChinaMap:!0}),an=!1,(r=Kn.ready)==null||r.then(()=>{an=!0,Ze.value=!1,Cn()}).catch(n=>{console.warn("[yakManagement] map assets unavailable",n),ha.value=!1,Ze.value=!0}))}function us(r){(r==="structure"||r==="forecast")&&!Jr&&(Jr=!0,mu()),r==="epidemic"&&!ei&&(ei=!0,Ji()),r==="trade"&&!ti&&(ti=!0,Ei()),r==="slaughter"&&!ai&&(ai=!0,Hi())}function Cn(){pa||!a.active||!an||Dt||(Ze.value=!1,Dt=!0,Ft&&window.clearTimeout(Ft),Ft=window.setTimeout(()=>{Ft=null,cs()},600))}function cs(r=0){return oe(this,null,function*(){var s,c;if(pa)return;if(!a.active){Dt=!1;return}if(yield ia(),!a.active){Dt=!1;return}const n=$e.value;if((s=n==null?void 0:n.loadMap)==null||s.call(n,Kn),n!=null&&n.canvasMap){Dt=!1,ha.value=!0,Ze.value=!1,(c=n.play)==null||c.call(n);return}if(r<24){window.setTimeout(()=>cs(r+1),120);return}Dt=!1,Ze.value=!0})}function ds(r={}){tn.value={type:r.type||"idle",text:r.text||""}}function Mu(){Fa.value=!0,Ze.value=!1}function hs(r={}){en.value={type:r.type||"idle",text:r.text||"",loaded:r.loaded,failed:r.failed,total:r.total,zoom:r.zoom,tileUrlTemplate:r.tileUrlTemplate}}function Cu(){if(z.value==="epidemic"){i("module-stats",{moduleKey:"yak-management",items:[{zh:"防疫记录",value:yt.value,unit:"条"},{zh:"防疫耳标",value:sr.value,unit:"头"},{zh:"疫苗类型",value:Ot.value,unit:"类"},{zh:"涉及村数",value:No.value,unit:"个"}]});return}if(z.value==="forecast"){const r=et.value.stock-_t;i("module-stats",{moduleKey:"yak-management",items:[{zh:"预测期末存栏",value:et.value.stock,unit:"头"},{zh:"新生牛犊",value:et.value.births,unit:"头"},{zh:"出栏流出",value:et.value.outflow,unit:"头"},{zh:"预测净变化",value:r,unit:"头"}]});return}if(z.value==="trade"){i("module-stats",{moduleKey:"yak-management",items:[{zh:"流通总量",value:bt("headCount"),unit:"头"},{zh:"出证记录",value:bt("recordCount"),unit:"条"},{zh:"运输车辆",value:bt("vehicleCount"),unit:"辆"}]});return}if(z.value==="slaughter"){i("module-stats",{moduleKey:"yak-management",items:Xo.value});return}i("module-stats",{moduleKey:"yak-management",items:[{zh:"图像识别总数",value:uo,unit:"头"},{zh:"模型修正总数",value:vo.value,unit:"头"},{zh:"当前存栏数量",value:_t,unit:"头"}]})}function Pn(r,n,s,c={}){const f=c.labelKey||"name",v=r.length>8,b=c.style==="ladder",k=v?b?7:6:r.length>6?11:13,R=c.axisTextColor||w,B=c.dimAxisTextColor||x;return{tooltip:E(I({},ye()),{trigger:"axis",axisPointer:{type:"shadow"},formatter($){if(c.tooltipFormatter)return c.tooltipFormatter($[0]);const X=r[$[0].dataIndex];return`${X[f]}<br/>数值:${Y(X[n])}${s}`}}),grid:{left:v?58:74,right:v?54:58,top:v?6:16,bottom:v?8:14},xAxis:{type:"value",axisLabel:{color:B,fontSize:10,formatter:s==="%"?"{value}%":ae},axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:G,type:"dashed"}}},yAxis:{type:"category",inverse:!0,data:r.map($=>$[f]),axisLabel:{color:R,fontSize:v?10:11,fontWeight:700,interval:0},axisLine:{show:!1},axisTick:{show:!1}},series:[{type:"bar",barWidth:k,barGap:"-100%",data:r.map($=>({value:$[n],itemStyle:{borderRadius:[1,2,2,1],color:Pu(Bn),shadowBlur:2,shadowColor:"rgba(48, 220, 255, 0.12)"}})),showBackground:!0,backgroundStyle:{color:b?"rgba(48, 220, 255, 0.05)":"rgba(48, 220, 255, 0.07)",borderRadius:[1,2,2,1]},label:{show:!0,position:"right",color:C,fontFamily:za.number,fontSize:v?10:Ns.chartLabel,fontWeight:700,formatter:({value:$})=>`${s==="%"?wt($):ae($)}`}}]}}function Pu(r){return new Ae(0,0,1,0,[{offset:0,color:"rgba(67, 217, 232, 0.14)"},{offset:.58,color:"rgba(67, 217, 232, 0.7)"},{offset:1,color:r}])}function ps(r,n,s,c=0,f=!1){return{name:r,type:"line",yAxisIndex:c,smooth:!0,symbolSize:5,data:n,lineStyle:{width:2.5,color:s},itemStyle:{color:s},areaStyle:f?{color:new Ae(0,0,0,1,[{offset:0,color:`${s}44`},{offset:1,color:`${s}05`}])}:void 0}}function Nu(r){return Qn.find(n=>n.key===r)||Qn[2]}function Fu(r,n="month"){var c;if(n==="month")return Nd(r);const s=((c=r==null?void 0:r.series)==null?void 0:c[n])||{};return{labels:Array.isArray(s.labels)?s.labels:[],stock:Array.isArray(s.stock)?s.stock.map(Number):[],births:Array.isArray(s.births)?s.births.map(Number):[],outflow:Array.isArray(s.outflow)?s.outflow.map(Number):[]}}function xu(r,n){return n==="day"?Math.max(10,Math.ceil(r/6)):n==="week"?Math.max(2,Math.ceil(r/7)):r>24?4:r>14?2:1}function Ru(r,n){return n==="day"?r>700?2:r>360?3:4:n==="week"?r>110?4:6:r>24?7:10}function Iu(r){return(r.labels||[]).map((n,s)=>{var $,X,ue,ce,we,We;const c=Number((($=r.stock)==null?void 0:$[Math.max(s-1,0)])||0),f=Number(((X=r.stock)==null?void 0:X[s])||c),v=Math.max(0,Number(((ue=r.births)==null?void 0:ue[s])||0)-Number(((ce=r.births)==null?void 0:ce[Math.max(s-1,0)])||0)),b=Math.max(0,Number(((we=r.outflow)==null?void 0:we[s])||0)-Number(((We=r.outflow)==null?void 0:We[Math.max(s-1,0)])||0)),k=Math.max(120,Math.round((v+b)*.18)),R=Math.max(c,f)+Math.max(k,Math.round(v*.32)),B=Math.max(0,Math.min(c,f)-Math.max(k,Math.round(b*.32)));return{label:n,open:c,close:f,low:B,high:R,birth:v,outflow:b,value:[c,f,B,R]}})}function _u(r,n){const s=new Map;return r.forEach(c=>{const f=Gu(c.name);if(!f)return;const v=s.get(f)||{name:f,value:0};v.value+=Number(c[n]||0),s.set(f,v)}),[...s.values()].sort((c,f)=>f.value-c.value)}function Gu(r){return{色地镇:"色地镇",瓦切镇:"瓦切镇",安曲镇:"安曲镇",龙日镇:"龙日镇",邛溪镇:"邛溪镇",刷经寺镇:"刷经寺镇",阿木乡:"阿木乡",查尔玛乡:"查尔玛乡",江茸乡:"江茸乡",麦洼乡:"麦洼乡"}[r]||""}function ye(r){return{trigger:"item",backgroundColor:"rgba(5, 31, 51, 0.96)",borderColor:"rgba(0, 210, 255, 0.54)",borderWidth:1,padding:[7,10],textStyle:{color:w,fontFamily:za.ui,fontSize:Ns.tooltip,lineHeight:18},extraCssText:"box-shadow:0 0 10px rgba(0,210,255,.12);",formatter:r}}function Br(r){return kt.some(n=>n.key===r)?r:"structure"}function Au(r=[]){return r.map((n,s)=>{var v,b,k,R;const c=String(n.name||n.label||n.type||`结构${s+1}`).trim(),f=fs((b=(v=n.value)!=null?v:n.count)!=null?b:n.number);return{key:n.key||n.id||`${c}-${s}`,name:c,count:f,ratio:Number((R=(k=n.ratio)!=null?k:n.percent)!=null?R:0),source:n.source||"结构统计"}}).filter(n=>n.name&&n.count>0)}function Bu(r=[],n=[]){const s=r.some(f=>vs(f))?r:n;return ys(s,n).map((f,v)=>{var R,B;const b=String(f.name||f.label||`结构${v+1}`).trim(),k=fs((B=(R=f.count)!=null?R:f.value)!=null?B:f.number);return E(I({},f),{key:f.key||`${b}-${v}`,name:b,count:k})}).filter(f=>f.name&&f.count>0)}function fs(r){const n=Number(String(r!=null?r:"").replace(/,/g,"").replace(/%/g,""));return Number.isFinite(n)&&n>0?Math.round(n):0}function $u(r,n){const s=String((r==null?void 0:r.message)||r||"");return/未登录|401|HTTP_401/.test(s)?"结构数据未就绪":/超时|timeout/i.test(s)?"结构数据加载超时":n}function Y(r){const n=Number(r);return Number.isFinite(n)?n.toLocaleString("zh-CN",{maximumFractionDigits:Number.isInteger(n)?0:2}):"--"}function ae(r){const n=Number(r);return Number.isFinite(n)?Math.abs(n)>=1e4?`${(n/1e4).toFixed(Math.abs(n)>=1e5?0:1)}万`:Math.round(n).toLocaleString("zh-CN"):"--"}function Nn(r,n=2){const s=Number(r);return Number.isFinite(s)?`${(s/1e4).toFixed(n)}万`:"--"}function wt(r){const n=Number(r);return Number.isFinite(n)?`${Number.isInteger(n)?n:n.toFixed(1)}%`:"--"}function ta(r,n,s,c){const f=c*Math.PI/180;return{x:Number((r+s*Math.cos(f)).toFixed(2)),y:Number((n+s*Math.sin(f)).toFixed(2))}}function Eu(r,n,s,c,f,v){const b=ta(r,n,c,f),k=ta(r,n,c,v),R=ta(r,n,s,v),B=ta(r,n,s,f),$=v-f>180?1:0;return[`M ${b.x} ${b.y}`,`A ${c} ${c} 0 ${$} 1 ${k.x} ${k.y}`,`L ${R.x} ${R.y}`,`A ${s} ${s} 0 ${$} 0 ${B.x} ${B.y}`,"Z"].join(" ")}function ms(r=[]){return r.reduce((n,s)=>{const c=Sa.find(f=>f.key===s);return n+Number((c==null?void 0:c.ratio)||0)},0)}function gs(){return[{key:"fertileCow",name:"适龄能繁母牛",color:"#3ed9e7",matcher:(r,n)=>r==="fertileCow"||n.includes("适龄能繁母牛")},{key:"meatBull",name:"麦洼公牦牛",color:"#5b8ff9",matcher:(r,n)=>r==="meatBull"||n.includes("肉公牛")||n.includes("麦洼公牦牛")},{key:"breedingBull",name:"种公牛",color:"#f6bd16",matcher:(r,n)=>r==="breedingBull"||n.includes("种公牛")},{key:"femaleCalf",name:"母犊牛",color:"#5ad8a6",matcher:(r,n)=>r==="femaleCalf"||n.includes("母犊牛")},{key:"maleCalf",name:"公犊牛",color:"#9270ca",matcher:(r,n)=>r==="maleCalf"||n.includes("公犊牛")},{key:"overageCow",name:"过龄能繁母牛",color:"#e8684a",matcher:(r,n)=>r==="overageCow"||n.includes("过龄能繁母牛")}]}function Vu(r=[]){const n=r.reduce((c,f)=>c+Number(f.count||0),0)||1;return[{key:"female",group:"性别",name:"母牛合计",color:"#8bf7ff",matcher:(c,f)=>["fertileCow","femaleCalf","overageCow"].includes(c)||f.includes("母")},{key:"male",group:"性别",name:"公牛合计",color:"#30dcff",matcher:(c,f)=>["meatBull","breedingBull","maleCalf"].includes(c)||f.includes("公")||f.includes("肉牛")},{key:"calf",group:"阶段",name:"犊牛合计",color:"#8bf7ff",matcher:(c,f)=>["femaleCalf","maleCalf"].includes(c)||f.includes("犊牛")},{key:"breeding-cow",group:"阶段",name:"能繁母牛",color:"#48cfff",matcher:(c,f)=>["fertileCow","overageCow"].includes(c)||f.includes("能繁母牛")}].map(c=>{const f=r.filter(v=>c.matcher(String(v.key||""),String(v.name||""))).reduce((v,b)=>v+Number(b.count||0),0);return{key:c.key,group:c.group,name:c.name,color:c.color,count:f,percent:f/n*100}})}function ys(r=[],n=[]){const c=r.some(b=>vs(b))?r:n,f=c.reduce((b,k)=>b+Number(k.count||0),0)||_t||1;return gs().map(b=>{const k=c.filter($=>b.matcher(String($.key||""),String($.name||""))),R=k.reduce(($,X)=>$+Number(X.count||0),0),B=k.length===1?Number(k[0].ratio):Number.NaN;return{key:b.key,name:b.name,color:b.color,count:R,percent:Number.isFinite(B)&&B>0?B:R/f*100}}).filter(b=>b.count>0||b.percent>0)}function vs(r={}){const n=String(r.key||""),s=String(r.name||"");return gs().some(c=>c.matcher(n,s))}function Du(r=[],n=[]){const c=r.some(b=>zu(b))?r:n,f=c.reduce((b,k)=>b+Number(k.count||0),0)||1,v=(b,k,R,B,$)=>{const X=c.filter(we=>B(String(we.key||""),String(we.name||""))),ue=X.reduce((we,We)=>we+Number(We.count||0),0),ce=X.length===1?Number(X[0].ratio):Number.NaN;return{key:b,name:k,color:R,count:ue,percent:Number.isFinite(ce)&&ce>0?ce:ue/f*100,desc:$}};return[v("fertile-cow","适龄能繁母牛","#30dcff",(b,k)=>b==="fertileCow"||k.includes("适龄能繁母牛"),"繁殖基础"),v("calf","犊牛合计","#8bf7ff",(b,k)=>["femaleCalf","maleCalf"].includes(b)||k.includes("犊牛"),"新生补充"),v("overage-cow","过龄能繁母牛","#30dcff",(b,k)=>b==="overageCow"||k.includes("过龄能繁母牛"),"更新压力"),v("breeding-bull","种公牛配比","#48cfff",(b,k)=>b==="breedingBull"||k.includes("种公牛"),"配种支撑")]}function zu(r={}){const n=String(r.key||""),s=String(r.name||"");return["fertileCow","femaleCalf","maleCalf","overageCow","breedingBull"].includes(n)||s.includes("适龄能繁母牛")||s.includes("犊牛")||s.includes("过龄能繁母牛")||s.includes("种公牛")}function Ou(r=[]){const n=b=>{var k;return Number(((k=r.find(R=>R.key===b))==null?void 0:k.percent)||0)},s=n("fertile-cow"),c=n("calf"),f=n("overage-cow"),v=n("breeding-bull");return s>=40&&c>=25&&v>=2&&v<=5&&f<=10?{label:"结构健康",title:"繁殖基础稳定",summary:"适龄母牛足,犊牛补充稳",note:"保持适龄能繁母牛、犊牛补充与种公牛配置稳定。"}:c<25?{label:"结构健康",title:"犊牛补充需关注",summary:"繁殖基础稳定,补充端可优化",note:"关注犊牛成活和季节性补栏,保持生产连续性。"}:v<2?{label:"结构健康",title:"繁殖基础总体稳定",summary:"适龄母牛基础较稳",note:"结合实际配种需求,平稳优化公牛配置。"}:{label:"结构健康",title:"生产阶段较均衡",summary:"繁殖群和犊牛补充连续支撑",note:"延续结构管理,优先保障适龄母牛与犊牛质量。"}}function Wu(r){const n=Number((r==null?void 0:r.count)||0);return Math.max(8,Math.min(100,n/To.value*100))}function Yu(r={}){const n=_t,s=[{key:"births",name:"新生牛犊",delta:Number(r.births||0),color:"#30dcff"},{key:"outflow",name:"出栏流出",delta:-Number(r.outflow||0),color:"#48cfff"},{key:"correction",name:"修正损耗",delta:Number(r.correction||0),color:"#8bf7ff"}];let c=n;const f=[{key:"current",name:"当前存栏",type:"anchor",value:n,magnitude:n,from:n,to:n,color:"#30dcff",display:`${Nn(n,2)}头`}];s.forEach(k=>{const R=c,B=c+k.delta;c=B,f.push(E(I({},k),{name:`${k.delta>=0?"+":"-"}${k.name}`,type:"delta",from:R,to:B,value:k.delta,magnitude:Math.abs(k.delta),display:`${ju(k.delta)}头`}))});const v=Number(r.stock||c);f.push({key:"final",name:"=期末预测",type:"final",value:v,magnitude:v,from:v,to:v,color:"#48cfff",display:`${Nn(v,2)}头`});const b=Math.max(...f.map(k=>Number(k.magnitude)||0),1);return f.map(k=>{const R=(Number(k.magnitude)||0)/b*100;return E(I({},k),{left:0,width:Math.max(k.type==="delta"?5:10,Math.min(100,R))})})}function Fn(r){const n=Number(r);return Number.isFinite(n)?`${n>=0?"+":"-"}${Y(Math.abs(n))}`:"--"}function ju(r){const n=Number(r);return Number.isFinite(n)?`${n>=0?"+":"-"}${Nn(Math.abs(n))}`:"--"}return(r,n)=>(P(),N("div",xd,[Ie((P(),Yt(Sd,{key:yo.value,ref_key:"mapSceneRef",ref:$e,class:"yak-map-scene","active-layer":pl.value,"map-ranking":fl.value,"tile-url-template":ni.value,"use-satellite-base":Jn.value,"satellite-max-zoom":21,"admin-boundary-line-scale":1.35,onLayerStatus:ds,onTileStatus:hs},null,8,["active-layer","map-ranking","tile-url-template","use-satellite-base"])),[[Qu,!tt.value]]),tt.value?(P(),Yt(Gc,{key:Xr.value,ref_key:"yakOlMapRef",ref:Na,class:"yak-ol-map-layer",active:a.active&&tt.value,"tile-url-template":ni.value,center:hl.value,"initial-zoom":Mf,"minimum-zoom-distance":1,"county-view-target-offset":O(K),"admin-boundary-line-scale":1.65,"auto-apply-layer-map-view":!1,"max-zoom":21,"map-ranking":ki.value,"overlay-layer":Si.value,onReady:Mu,onLayerStatus:ds,onTileStatus:hs},null,8,["active","tile-url-template","center","county-view-target-offset","map-ranking","overlay-layer"])):pe("",!0),d("div",{class:Se(["yak-map-scrim",{"is-ol-map":tt.value}])},null,2),ml.value?(P(),N("div",{key:1,class:Se(["yak-map-loading",{"is-timeout":Ze.value}]),role:"status","aria-live":"polite"},[d("strong",null,T(Ze.value?"地图暂未加载完成":gl.value),1),Ze.value?(P(),N(U,{key:1},[n[35]||(n[35]=d("span",null,"其余业务数据仍可查看,您可以重新加载地图。",-1)),d("button",{type:"button",onClick:Ol},"重新加载地图")],64)):(P(),N("span",Rd,"正在准备地图资源,请稍候"))],2)):pe("",!0),d("div",Id,[z.value==="trade"&&fi.value.length?(P(),N("div",_d,[n[36]||(n[36]=d("span",null,"交易年份",-1)),(P(!0),N(U,null,ee(fi.value,s=>(P(),N("button",{key:s,type:"button",class:Se({active:Number(s)===Number(be.value)}),onClick:c=>gu(s)},T(s),11,Gd))),128))])):pe("",!0),z.value==="slaughter"&&vi.value.length?(P(),N("div",Ad,[n[37]||(n[37]=d("span",null,"出栏年份",-1)),(P(!0),N(U,null,ee(vi.value,s=>(P(),N("button",{key:s.key,type:"button",class:Se({active:s.value===he.value}),"aria-pressed":s.value===he.value,onClick:c=>wu(s.value)},T(s.label),11,Bd))),128))])):pe("",!0),z.value==="epidemic"&&qe.length?(P(),N("div",$d,[n[38]||(n[38]=d("span",null,"防疫年份",-1)),(P(),N(U,null,ee(qe,s=>d("button",{key:s,type:"button",class:Se({active:Number(s)===Number(_e.value)}),onClick:c=>yu(s)},T(s),11,Ed)),64))])):pe("",!0),z.value==="forecast"?(P(),N("div",Vd,[n[39]||(n[39]=d("span",null,"预测年份",-1)),(P(!0),N(U,null,ee(O(Gt),s=>(P(),N("button",{key:s.key,type:"button",class:Se({active:s.key===Mt.value}),onClick:c=>Wl(s.key)},T(s.shortLabel),11,Dd))),128))])):pe("",!0),z.value==="slaughter"&&fr.value.length?(P(),N("div",{key:4,class:Se(["slaughter-realtime-ticker",{"is-live":pr.value}]),"aria-label":"最新牦牛出栏动态"},[d("div",zd,[n[40]||(n[40]=d("i",null,null,-1)),d("strong",null,T(Ko.value),1)]),d("div",Od,[d("div",{class:"slaughter-realtime-track",style:nt({"--ticker-duration":`${Zo.value}s`})},[(P(),N(U,null,ee(2,s=>d("div",{key:s,class:"slaughter-realtime-group"},[(P(!0),N(U,null,ee(fr.value,c=>(P(),N("span",{key:`${s}-${c.recordKey}`,class:"slaughter-realtime-item"},[d("b",null,T(au(c.issueTime)),1),d("em",null,T(W(c.originTownName)),1),d("strong",null,T(W(c.animalTypeName))+" "+T(Y(c.animalQuantity))+"头",1),n[41]||(n[41]=d("i",null,"→",-1)),d("span",null,T(W(c.destinationProvinceName)),1)]))),128))])),64))],4)])],2)):pe("",!0),d("div",Wd,[d("div",Yd,[z.value==="structure"?(P(),N(U,{key:0},[j(te,{class:"yak-side-card left-card",title:"繁殖基础评估",width:O(o),height:u.value},{default:Q(()=>[d("div",jd,[d("div",Hd,[d("strong",null,T(si.value.title)+","+T(si.value.summary),1)]),d("div",qd,[(P(!0),N(U,null,ee(ii.value,s=>(P(),N("div",{key:s.key,class:"breeding-health-item",style:nt({"--health-color":s.color,"--health-width":`${Math.max(5,Math.min(100,s.percent))}%`})},[d("span",null,T(s.name),1),d("strong",null,T(wt(s.percent)),1),n[42]||(n[42]=d("i",null,[d("b")],-1)),d("em",null,T(s.desc),1)],4))),128))])])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"畜群结构占比",width:O(o),height:u.value},{default:Q(()=>[d("div",Ud,[d("div",Kd,[d("div",Zd,[(P(),N("svg",Xd,[d("g",Qd,[(P(!0),N(U,null,ee(So.value,s=>(P(),N("path",{key:s.key,class:Se(["structure-rose-segment",{"is-active":s.index===tr.value}]),d:s.path,fill:s.color,stroke:s.color},null,10,Jd))),128))]),n[43]||(n[43]=d("circle",{class:"structure-rose-glow",cx:"75",cy:"75",r:"24"},null,-1)),n[44]||(n[44]=d("circle",{class:"structure-rose-hole",cx:"75",cy:"75",r:"16"},null,-1)),n[45]||(n[45]=d("text",{class:"structure-rose-center",x:"75",y:"72","text-anchor":"middle"},"结构",-1)),n[46]||(n[46]=d("text",{class:"structure-rose-center is-sub",x:"75",y:"83","text-anchor":"middle"},"占比",-1))]))]),d("div",eh,[(P(!0),N(U,null,ee(ln.value,(s,c)=>(P(),N("div",{key:s.key||s.name,class:Se(["structure-ratio-row",{"is-active":c===tr.value}]),style:nt({"--row-color":s.color,"--row-percent":`${Math.max(4,s.percent)}%`})},[d("i",{style:nt({background:s.color,color:s.color})},null,4),d("span",null,[Rt(T(s.name),1),d("small",null,T(wt(s.percent)),1)]),d("strong",null,T(ae(s.count)),1),n[47]||(n[47]=d("em",null,"头",-1))],6))),128))])]),it.value?(P(),N("div",th,"结构数据加载中")):Me.value?(P(),N("div",ah,T(Me.value),1)):pe("",!0)])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"母牛/公牛年龄结构",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:yl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"牦牛乡镇分布",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:vl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"])],64)):z.value==="forecast"?(P(),N(U,{key:1},[j(te,{class:"yak-side-card left-card",title:"存栏变化拆解",width:O(o),height:u.value},{default:Q(()=>[d("div",nh,[d("div",rh,[d("span",null,T(et.value.label)+"变化路径",1),d("strong",{class:Se({positive:er.value>0,negative:er.value<0})},[Rt(" 净变化 "+T(Fn(er.value)),1),n[48]||(n[48]=d("em",null,"头",-1))],2)]),d("div",ih,[(P(!0),N(U,null,ee(bo.value,s=>(P(),N("div",{key:s.key,class:Se(["forecast-waterfall-row",[`is-${s.type}`,{positive:s.delta>0,negative:s.delta<0}]]),style:nt({"--waterfall-left":`${s.left}%`,"--waterfall-width":`${s.width}%`,"--waterfall-color":s.color})},[d("span",null,T(s.name),1),n[49]||(n[49]=d("i",null,[d("b")],-1)),d("strong",null,T(s.display),1)],6))),128))])])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"未来存栏趋势",width:O(o),height:u.value},{default:Q(()=>[d("div",sh,[d("div",oh,[(P(),N(U,null,ee(Qn,s=>d("button",{key:s.key,type:"button",class:Se({active:s.key===Bt.value}),onClick:c=>Bt.value=s.key},T(s.label),11,lh)),64))]),j(O(ve),{class:"yak-chart forecast-kline-chart",option:Tl.value,autoresize:!0},null,8,["option"])])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"月度数量预测",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Sl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"预测因子雷达",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:kl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"])],64)):z.value==="epidemic"?(P(),N(U,{key:2},[j(te,{class:"yak-side-card left-card",title:"防疫统计",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Il.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"养殖户防疫排行",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:_l.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"防疫作业趋势",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Rl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"疫苗类型分布",width:O(o),height:u.value},{default:Q(()=>[cn.value.length?(P(),N("div",uh,[d("div",ch,[(P(),Yt(mc,{key:Mo.value,data:cn.value,delay:3e3,colors:Ye,opacity:.62,class:"epidemic-three-pie"},{default:Q(({data:s})=>[d("div",dh,[d("strong",null,T(ae((s==null?void 0:s.count)||yt.value)),1),d("span",null,T((s==null?void 0:s.name)||"疫苗类型"),1)])]),_:1},8,["data"]))]),d("div",hh,[(P(!0),N(U,null,ee(cn.value,(s,c)=>(P(),N("div",{key:s.key||s.name,class:"epidemic-three-pie-row"},[d("i",{style:nt({borderColor:Ye[c%Ye.length]})},null,4),d("span",null,T(s.name),1),d("strong",null,T(ae(s.value)),1),d("em",null,T(s.unit),1)]))),128))])])):(P(),N("div",ph,"暂无疫苗类型数据"))]),_:1},8,["width","height"])],64)):z.value==="trade"?(P(),N(U,{key:3},[j(te,{class:"yak-side-card left-card",title:"交易异常关注",width:O(o),height:u.value},{default:Q(()=>[d("div",fh,[d("div",mh,[d("span",null,T(be.value)+"年流通监管线索",1),d("strong",null,T(qo.value),1)]),d("div",gh,[(P(!0),N(U,null,ee(yi.value,s=>(P(),N("div",{key:s.key,class:Se(["trade-risk-row",`is-${s.level}`]),style:nt({"--risk-color":s.color})},[n[50]||(n[50]=d("i",null,null,-1)),d("span",null,[d("em",null,[d("b",null,T(s.badge),1),Rt(T(s.name),1)]),d("small",null,T(s.value)+"|"+T(s.desc),1)])],6))),128))])])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"交易流通趋势",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Gl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"来源乡镇分布",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Al.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"用途结构统计",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Bl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"])],64)):z.value==="slaughter"?(P(),N(U,{key:4},[j(te,{class:"yak-side-card left-card",title:he.value?`${he.value}年各乡镇出栏`:"各乡镇历史出栏",width:O(o),height:u.value},{default:Q(()=>[bi.value.length?(P(),Yt(O(ve),{key:0,class:"yak-chart",option:El.value,autoresize:!0},null,8,["option"])):(P(),N("div",yh,T(Nt.value?"出栏历史读取中":lt.value||"暂无乡镇历史数据"),1))]),_:1},8,["title","width","height"]),j(te,{class:"yak-side-card left-card",title:"出栏品种占比",width:O(o),height:u.value},{default:Q(()=>[wi.value.length?(P(),Yt(O(ve),{key:0,class:"yak-chart",option:Vl.value,autoresize:!0},null,8,["option"])):(P(),N("div",vh,T(Nt.value?"品种数据读取中":lt.value||"暂无品种数据"),1))]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"销售用途分析",width:O(o),height:u.value},{default:Q(()=>[Li.value.length?(P(),Yt(O(ve),{key:0,class:"yak-chart",option:Dl.value,autoresize:!0},null,8,["option"])):(P(),N("div",bh,T(Nt.value?"用途数据读取中":lt.value||"暂无销售用途数据"),1))]),_:1},8,["width","height"]),j(te,{class:"yak-side-card left-card",title:"省内、省外流向占比",width:O(o),height:u.value},{default:Q(()=>[gr.value.length?(P(),N("div",wh,[d("div",Lh,[(P(!0),N(U,null,ee(gr.value,s=>(P(),N("span",{key:s.name,class:Se(`is-${s.key}`),style:nt({width:`${s.percent}%`})},null,6))),128))]),d("div",Th,[d("span",null,T(he.value?`${he.value}年流向`:"累计流向"),1),d("strong",null,[Rt(T(Y(Ia("cumulativeHeadCount"))),1),n[51]||(n[51]=d("em",null,"头",-1))])]),d("div",Sh,[(P(!0),N(U,null,ee(gr.value,s=>(P(),N("div",{key:s.name,class:Se(`is-${s.key}`)},[n[52]||(n[52]=d("i",null,null,-1)),d("span",null,[Rt(T(s.name),1),d("small",null,T(Y(s.certificateCount))+"张检疫票",1)]),d("strong",null,T(wt(s.percent)),1),d("em",null,T(ae(s.headCount))+"头",1)],2))),128))])])):(P(),N("div",kh,T(Nt.value?"流向占比读取中":lt.value||"暂无省内外流向数据"),1))]),_:1},8,["width","height"])],64)):pe("",!0)])]),d("div",Mh,[d("div",Ch,[z.value==="structure"?(P(),N(U,{key:0},[j(te,{class:"yak-side-card right-card",title:"乡镇存栏排行",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:bl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card",title:"能繁母牛与犊牛分布",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:wl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card",title:"出栏/交易影响",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Ll.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card",title:"性别与生产阶段汇总",width:O(o),height:u.value},{default:Q(()=>[d("div",Ph,[d("div",Nh,[(P(!0),N(U,null,ee(ri.value,s=>(P(),N("div",{key:s.key||s.name,class:"structure-summary-row",style:nt({"--structure-color":s.color,"--structure-width":`${Wu(s)}%`})},[d("span",null,[n[53]||(n[53]=d("i",null,null,-1)),Rt(T(s.name),1)]),n[55]||(n[55]=d("b",null,[d("em")],-1)),d("strong",null,[Rt(T(ae(s.count)),1),n[54]||(n[54]=d("em",null,"头",-1))]),d("small",null,T(wt(s.percent)),1)],4))),128))]),it.value?(P(),N("div",Fh,"结构数据加载中")):Me.value?(P(),N("div",xh,T(Me.value),1)):pe("",!0)])]),_:1},8,["width","height"])],64)):z.value==="forecast"?(P(),N(U,{key:1},[j(te,{class:"yak-side-card right-card",title:"乡镇预测排行",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Ml.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card",title:"期末结构预测",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Cl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card",title:"补充/流出对比",width:O(o),height:u.value},{default:Q(()=>[j(O(ve),{class:"yak-chart",option:Pl.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card",title:"预测变化热力",width:O(o),height:u.value},{default:Q(()=>[d("div",Rh,[(P(!0),N(U,null,ee(Nl.value,s=>(P(),N("div",{key:s.name,class:Se(["heat-row",{"is-negative":s.change<0}]),style:nt(Fl(s)),title:xl(s)},[d("span",null,T(s.name),1),n[56]||(n[56]=d("b",null,[d("i")],-1)),d("strong",null,T(Fn(s.change)),1)],14,Ih))),128))])]),_:1},8,["width","height"])],64)):z.value==="epidemic"?(P(),Yt(te,{key:2,class:"yak-side-card right-card epidemic-ledger-card",title:"防疫记录台账",width:O(o),height:h.value},{default:Q(()=>[d("div",_h,[d("div",Gh,[d("span",null,T(_e.value)+"年 共 "+T(Y(ze.value))+" 条",1),d("div",null,[Ie(d("input",{"onUpdate:modelValue":n[0]||(n[0]=s=>M.value=s),type:"search",placeholder:"耳标/养殖户/疫苗",onKeyup:ma(ts,["enter"])},null,544),[[jt,M.value]]),d("button",{type:"button",onClick:ts},"搜索"),d("button",{type:"button",class:"is-more",onClick:n[1]||(n[1]=s=>ns())},"查看更多")])]),n[57]||(n[57]=d("div",{class:"epidemic-record-header"},[d("span",null,"电子耳标"),d("span",null,"养殖户"),d("span",null,"镇/乡"),d("span",null,"疫苗"),d("span",null,"时间")],-1)),d("div",Ah,[(P(!0),N(U,null,ee($o.value,s=>(P(),N("button",{key:s.epidemicId||s.earTag,type:"button",onClick:c=>ns(s)},[d("span",null,T(W(s.earTag)),1),d("span",null,T(W(s.owner)),1),d("span",null,T(W(s.town)),1),d("strong",null,T(W(s.medicine)),1),d("span",null,T(ut(s.operateTime)),1)],8,Bh))),128)),De.value.length?pe("",!0):(P(),N("div",$h,T(A.value?"防疫台账读取中":D.value||"暂无防疫记录"),1))]),d("div",Eh,[d("span",null,"第 "+T(Be.value)+" / "+T(lr.value)+" 页",1),d("button",{type:"button",disabled:Be.value<=1,onClick:n[2]||(n[2]=s=>as(Be.value-1))},"上一页",8,Vh),d("button",{type:"button",disabled:Be.value>=lr.value,onClick:n[3]||(n[3]=s=>as(Be.value+1))},"下一页",8,Dh)])])]),_:1},8,["width","height"])):z.value==="trade"?(P(),N(U,{key:3},[j(te,{class:"yak-side-card right-card",title:"出证结构统计",width:O(o),height:u.value},{default:Q(()=>[d("div",zh,[d("div",Oh,[d("span",null,[n[59]||(n[59]=d("em",null,"省外流通 A证",-1)),d("strong",null,[Rt(T(Y(bt("outProvinceHeads","aCertHeads"))),1),n[58]||(n[58]=d("b",null,"头",-1))]),d("small",null,T(Y(bt("outProvinceCount","aCertCount")))+"条记录",1)]),d("span",null,[n[61]||(n[61]=d("em",null,"省内流通 B证",-1)),d("strong",null,[Rt(T(Y(bt("inProvinceHeads","bCertHeads"))),1),n[60]||(n[60]=d("b",null,"头",-1))]),d("small",null,T(Y(bt("inProvinceCount","bCertCount")))+"条记录",1)])]),j(O(ve),{class:"trade-cert-chart",option:$l.value,autoresize:!0},null,8,["option"])])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card trade-source-card",title:"出栏来源排行",width:O(o),height:p.value},{default:Q(()=>[d("div",Wh,[(P(!0),N(U,null,ee(ur.value,(s,c)=>(P(),N("div",{key:s.name,class:"trade-dest-row",style:nt({"--trade-ratio":`${s.ratio}%`})},[d("span",null,T(c+1),1),d("strong",null,T(s.name),1),d("em",null,T(ae(s.headCount))+"头",1)],4))),128)),ur.value.length?pe("",!0):(P(),N("div",Yh,T(qt.value?"交易数据读取中":ua.value||"暂无出栏来源数据"),1))])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card trade-ledger-card",title:"交易出证台账",width:O(o),height:y.value},{default:Q(()=>[d("div",jh,[d("div",Hh,[d("span",null,"共 "+T(Y(Vt.value))+" 条",1),d("div",null,[Ie(d("input",{"onUpdate:modelValue":n[4]||(n[4]=s=>Ha.value=s),type:"search",placeholder:"货主/车辆/检疫号/地区",onKeyup:ma(Vi,["enter"])},null,544),[[jt,Ha.value]]),d("button",{type:"button",onClick:Vi},"搜索"),d("button",{type:"button",class:"is-more",onClick:n[5]||(n[5]=s=>zi())},"查看更多")])]),n[62]||(n[62]=d("div",{class:"trade-ledger-header"},[d("span",null,"货主"),d("span",null,"车牌"),d("span",null,"数量"),d("span",null,"来源"),d("span",null,"用途"),d("span",null,"时间")],-1)),d("div",qh,[(P(!0),N(U,null,ee(gi.value,s=>(P(),N("button",{key:s.certId,type:"button",onClick:c=>zi(s)},[d("span",null,T(W(s.ownerName)),1),d("span",null,T(W(s.transportNumber)),1),d("strong",null,T(Y(s.amount))+"头",1),d("span",null,T(W(s.startTown)),1),d("span",null,T(W(s.usageTypeName)),1),d("span",null,T(ut(s.issueTime)),1)],8,Uh))),128)),gi.value.length?pe("",!0):(P(),N("div",Kh,T(qt.value?"交易台账读取中":ua.value||"暂无交易记录"),1))]),d("div",Zh,[d("span",null,"第 "+T(Pt.value)+" / "+T(cr.value)+" 页",1),d("button",{type:"button",disabled:Pt.value<=1,onClick:n[6]||(n[6]=s=>Di(Pt.value-1))},"上一页",8,Xh),d("button",{type:"button",disabled:Pt.value>=cr.value,onClick:n[7]||(n[7]=s=>Di(Pt.value+1))},"下一页",8,Qh)])])]),_:1},8,["width","height"])],64)):z.value==="slaughter"?(P(),N(U,{key:4},[j(te,{class:"yak-side-card right-card",title:"检疫票数量排行",width:O(o),height:u.value},{default:Q(()=>[mr.value.length?(P(),Yt(O(ve),{key:0,class:"yak-chart",option:zl.value,autoresize:!0},null,8,["option"])):(P(),N("div",Jh,T(Nt.value?"检疫票数据读取中":lt.value||"暂无检疫票排行"),1))]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card",title:"销售目的地排行",width:O(o),height:u.value},{default:Q(()=>[d("div",ep,[(P(!0),N(U,null,ee(yr.value,(s,c)=>(P(),N("div",{key:s.name,class:"slaughter-destination-row",style:nt({"--destination-width":`${s.ratio}%`})},[d("span",null,T(String(c+1).padStart(2,"0")),1),d("strong",null,T(s.name),1),n[63]||(n[63]=d("i",null,[d("b")],-1)),d("em",null,T(ae(s.headCount))+"头",1)],4))),128)),yr.value.length?pe("",!0):(P(),N("div",tp,T(Nt.value?"目的地数据读取中":lt.value||"暂无销售目的地数据"),1))])]),_:1},8,["width","height"]),j(te,{class:"yak-side-card right-card slaughter-ledger-card",title:"出栏数据台账",width:O(o),height:g.value},{default:Q(()=>[d("div",ap,[d("div",np,[d("span",null,"共 "+T(Y(da.value))+" 条",1),d("div",null,[Ie(d("input",{"onUpdate:modelValue":n[8]||(n[8]=s=>Za.value=s),type:"search",placeholder:"检疫证/货主/车辆/地区",onKeyup:ma(qi,["enter"])},null,544),[[jt,Za.value]]),d("button",{type:"button",onClick:qi},"搜索"),d("button",{type:"button",class:"is-more",onClick:n[9]||(n[9]=s=>Ki())},"查看更多")])]),n[64]||(n[64]=d("div",{class:"slaughter-ledger-header"},[d("span",null,"检疫证号"),d("span",null,"货主"),d("span",null,"数量"),d("span",null,"来源"),d("span",null,"目的地"),d("span",null,"时间")],-1)),d("div",rp,[(P(!0),N(U,null,ee(Ti.value,s=>(P(),N("button",{key:s.recordKey,type:"button",onClick:c=>Ki(s)},[d("span",null,T(W(s.certificateDisplay)),1),d("span",null,T(W(s.ownerDisplay)),1),d("strong",null,T(Y(s.animalQuantity))+"头",1),d("span",null,T(W(s.originTownName)),1),d("span",null,T(W(s.destinationName)),1),d("span",null,T(ut(s.issueTime)),1)],8,ip))),128)),Ti.value.length?pe("",!0):(P(),N("div",sp,T(Nt.value?"出栏台账读取中":lt.value||"暂无出栏记录"),1))]),d("div",op,[d("span",null,"第 "+T(ot.value)+" / "+T(vr.value)+" 页",1),d("button",{type:"button",disabled:ot.value<=1,onClick:n[10]||(n[10]=s=>Ui(ot.value-1))},"上一页",8,lp),d("button",{type:"button",disabled:ot.value>=vr.value,onClick:n[11]||(n[11]=s=>Ui(ot.value+1))},"下一页",8,up)])])]),_:1},8,["width","height"])],64)):pe("",!0)])]),d("div",cp,[j(Bc,{"model-value":z.value,topics:kt,"onUpdate:modelValue":n[12]||(n[12]=s=>z.value=s)},null,8,["model-value"])]),tt.value?(P(),N("div",dp,[j($c,{modelValue:ht.value,"onUpdate:modelValue":n[13]||(n[13]=s=>ht.value=s),"topic-key":"yak-management",layers:sl.value,legends:ll.value,multiple:"",compact:"",width:248,height:ul.value},null,8,["modelValue","layers","legends","height"])])):pe("",!0)]),Z.value?(P(),N("div",{key:2,class:"epidemic-ledger-modal",onClick:Ea(rs,["self"])},[d("div",hp,[d("div",pp,[d("div",null,[n[65]||(n[65]=d("span",null,"牦牛防疫台账",-1)),d("strong",null,T(_e.value)+"年 "+T(Y(fe.value))+" 条记录",1)]),d("button",{type:"button",onClick:rs},"关闭")]),d("div",fp,[Ie(d("input",{"onUpdate:modelValue":n[14]||(n[14]=s=>me.value.keyword=s),type:"search",placeholder:"耳标 / 养殖户 / 药品","aria-label":"耳标 / 养殖户 / 药品",onKeyup:ma(is,["enter"])},null,544),[[jt,me.value.keyword]]),Ie(d("select",{"onUpdate:modelValue":n[15]||(n[15]=s=>me.value.town=s)},[n[66]||(n[66]=d("option",{value:""},"全部镇/乡",-1)),(P(!0),N(U,null,ee(Vo.value,s=>(P(),N("option",{key:s,value:s},T(s),9,mp))),128))],512),[[It,me.value.town]]),Ie(d("select",{"onUpdate:modelValue":n[16]||(n[16]=s=>me.value.medicine=s)},[n[67]||(n[67]=d("option",{value:""},"全部疫苗",-1)),(P(!0),N(U,null,ee(Do.value,s=>(P(),N("option",{key:s,value:s},T(s),9,gp))),128))],512),[[It,me.value.medicine]]),Ie(d("input",{"onUpdate:modelValue":n[17]||(n[17]=s=>me.value.startDate=s),type:"date"},null,512),[[jt,me.value.startDate]]),Ie(d("input",{"onUpdate:modelValue":n[18]||(n[18]=s=>me.value.endDate=s),type:"date"},null,512),[[jt,me.value.endDate]]),d("button",{type:"button",onClick:is},"检索"),d("button",{type:"button",class:"is-ghost",onClick:ku},"重置")]),d("div",yp,[d("div",vp,[n[68]||(n[68]=d("div",{class:"epidemic-ledger-table-head"},[d("span",null,"电子耳标"),d("span",null,"养殖户"),d("span",null,"镇/乡"),d("span",null,"村"),d("span",null,"疫苗"),d("span",null,"免疫时间"),d("span",null,"图片")],-1)),(P(!0),N(U,null,ee(re.value,s=>{var c,f;return P(),N("button",{key:s.epidemicId||s.earTag,type:"button",class:Se({active:(((c=Oe.value)==null?void 0:c.epidemicId)||((f=Oe.value)==null?void 0:f.earTag))===(s.epidemicId||s.earTag)}),onClick:v=>os(s)},[d("span",null,T(W(s.earTag)),1),d("span",null,T(W(s.owner)),1),d("span",null,T(W(s.town)),1),d("span",null,T(W(s.village)),1),d("strong",null,T(W(s.medicine)),1),d("span",null,T(ut(s.operateTime)),1),d("span",null,T(Rr(s).length?`${Rr(s).length}张`:"无"),1)],10,bp)}),128)),re.value.length?pe("",!0):(P(),N("div",wp,T(je.value?"台账读取中":Je.value||"暂无匹配记录"),1))]),d("div",Lp,[d("div",Tp,[d("div",null,[d("span",null,T(W(Jt.value.earTag)),1),d("em",null,T(W(Jt.value.medicine||Jt.value.preventionType)),1)]),d("strong",null,T(Ue.value?"加载中":ut(Jt.value.operateTime)),1)]),d("div",Sp,[(P(!0),N(U,null,ee(Eo.value,s=>(P(),N("span",{key:s.label,class:Se({"is-wide":s.wide})},[d("em",null,T(s.label),1),d("strong",null,T(s.value),1)],2))),128))]),hi.value.length?(P(),N("div",kp,[n[69]||(n[69]=d("div",{class:"epidemic-detail-photo-title"},"现场照片",-1)),d("div",Mp,[(P(!0),N(U,null,ee(hi.value.slice(0,6),s=>(P(),N("button",{key:s,type:"button",class:"epidemic-modal-photo-thumb",onClick:Ea(c=>cu(s),["stop"])},[d("img",{src:Ai(s),alt:"防疫照片"},null,8,Pp)],8,Cp))),128))])])):pe("",!0)])]),d("div",Np,[d("span",null,"第 "+T(Le.value)+" / "+T(di.value)+" 页",1),d("button",{type:"button",disabled:Le.value<=1,onClick:n[19]||(n[19]=s=>ss(Le.value-1))},"上一页",8,Fp),d("button",{type:"button",disabled:Le.value>=di.value,onClick:n[20]||(n[20]=s=>ss(Le.value+1))},"下一页",8,xp)])])])):pe("",!0),Yn.value?(P(),N("div",{key:3,class:"epidemic-ledger-modal trade-ledger-modal",onClick:Ea(Oi,["self"])},[d("div",Rp,[d("div",Ip,[d("div",null,[n[70]||(n[70]=d("span",null,"牦牛交易出证台账",-1)),d("strong",null,T(be.value)+"年 "+T(Y(qa.value))+" 条记录",1)]),d("button",{type:"button",onClick:Oi},"关闭")]),d("div",_p,[Ie(d("input",{"onUpdate:modelValue":n[21]||(n[21]=s=>gt.value.keyword=s),type:"search",placeholder:"货主 / 车辆 / 检疫号 / 地区",onKeyup:ma(Wi,["enter"])},null,544),[[jt,gt.value.keyword]]),Ie(d("select",{"onUpdate:modelValue":n[22]||(n[22]=s=>gt.value.startTown=s)},[n[71]||(n[71]=d("option",{value:""},"全部来源乡镇",-1)),(P(!0),N(U,null,ee(Wo.value,s=>(P(),N("option",{key:s,value:s},T(s),9,Gp))),128))],512),[[It,gt.value.startTown]]),Ie(d("select",{"onUpdate:modelValue":n[23]||(n[23]=s=>gt.value.usageType=s)},[n[72]||(n[72]=d("option",{value:""},"全部用途",-1)),(P(!0),N(U,null,ee(Yo.value,s=>(P(),N("option",{key:s,value:s},T(s),9,Ap))),128))],512),[[It,gt.value.usageType]]),Ie(d("select",{"onUpdate:modelValue":n[24]||(n[24]=s=>gt.value.certType=s)},[n[73]||(n[73]=d("option",{value:""},"全部证书",-1)),(P(!0),N(U,null,ee(jo.value,s=>(P(),N("option",{key:s.value,value:s.value},T(s.label),9,Bp))),128))],512),[[It,gt.value.certType]]),d("button",{type:"button",onClick:Wi},"检索"),d("button",{type:"button",class:"is-ghost",onClick:vu},"重置")]),d("div",$p,[d("div",Ep,[n[74]||(n[74]=d("div",{class:"trade-ledger-modal-table-head"},[d("span",null,"货主"),d("span",null,"证书"),d("span",null,"车牌号"),d("span",null,"数量"),d("span",null,"来源"),d("span",null,"用途"),d("span",null,"出证时间"),d("span",null,"状态")],-1)),(P(!0),N(U,null,ee(Ut.value,s=>(P(),N("button",{key:s.certId||s.factoryCode,type:"button",class:Se({active:Oo.value===(s.certId||s.factoryCode)}),onClick:c=>ji(s)},[d("span",null,T(W(s.ownerName)),1),d("span",null,T(W(s.certType||s.certScopeName)),1),d("span",null,T(W(s.transportNumber)),1),d("strong",null,T(Y(s.amount))+"头",1),d("span",null,T(W(s.startTown)),1),d("span",null,T(W(s.usageTypeName)),1),d("span",null,T(ut(s.issueTime)),1),d("span",null,T(W(s.statusName)),1)],10,Vp))),128)),Ut.value.length?pe("",!0):(P(),N("div",Dp,T(jn.value?"交易台账读取中":Hn.value||"暂无匹配记录"),1))]),d("div",zp,[d("div",Op,[d("div",null,[d("span",null,T(W(Te.value.factoryCode||Te.value.certId)),1),d("em",null,T($i(Te.value)),1)]),d("strong",null,T(ut(Te.value.issueTime)),1)]),d("div",Wp,[d("span",Yp,[n[75]||(n[75]=d("em",null,"货主",-1)),d("strong",null,T(W(Te.value.ownerName)),1)]),d("span",null,[n[76]||(n[76]=d("em",null,"联系方式",-1)),d("strong",null,T(Bi(Te.value.ownerPhone)),1)]),d("span",null,[n[77]||(n[77]=d("em",null,"证书类型",-1)),d("strong",null,T($i(Te.value)),1)]),d("span",null,[n[78]||(n[78]=d("em",null,"车牌号",-1)),d("strong",null,T(W(Te.value.transportNumber)),1)]),d("span",null,[n[79]||(n[79]=d("em",null,"牦牛数量",-1)),d("strong",null,T(Y(Te.value.amount))+"头",1)]),d("span",null,[n[80]||(n[80]=d("em",null,"用途",-1)),d("strong",null,T(W(Te.value.usageTypeName)),1)]),d("span",null,[n[81]||(n[81]=d("em",null,"来源乡镇",-1)),d("strong",null,T(W(Te.value.startTown)),1)]),d("span",null,[n[82]||(n[82]=d("em",null,"目的省份",-1)),d("strong",null,T(W(Te.value.destProvince)),1)]),d("span",null,[n[83]||(n[83]=d("em",null,"检疫员",-1)),d("strong",null,T(W(Te.value.quarantineOfficerName)),1)]),d("span",jp,[n[84]||(n[84]=d("em",null,"状态",-1)),d("strong",null,T(W(Te.value.statusName)),1)]),d("span",Hp,[n[85]||(n[85]=d("em",null,"来源地区",-1)),d("strong",null,T(W(Te.value.startRegionFullName)),1)]),d("span",qp,[n[86]||(n[86]=d("em",null,"目的地",-1)),d("strong",null,T(W(Te.value.destRegionFullName)),1)])]),d("button",{type:"button",class:"trade-detail-locate",disabled:!Te.value.startTown,onClick:n[25]||(n[25]=s=>bu(Te.value))}," 查看乡镇位置 ",8,Up)])]),d("div",Kp,[d("span",null,"第 "+T(Kt.value)+" / "+T(dr.value)+" 页",1),d("button",{type:"button",disabled:Kt.value<=1,onClick:n[26]||(n[26]=s=>Yi(Kt.value-1))},"上一页",8,Zp),d("button",{type:"button",disabled:Kt.value>=dr.value,onClick:n[27]||(n[27]=s=>Yi(Kt.value+1))},"下一页",8,Xp)])])])):pe("",!0),Qa.value?(P(),N("div",{key:4,class:"epidemic-ledger-modal trade-ledger-modal",onClick:Ea(Zi,["self"])},[d("div",Qp,[d("div",Jp,[d("div",null,[n[87]||(n[87]=d("span",null,"牦牛出栏数据台账",-1)),d("strong",null,T(he.value?`${he.value}年 `:"")+T(Y(Ja.value))+" 条记录",1)]),d("button",{type:"button",onClick:Zi},"关闭")]),d("div",ef,[Ie(d("input",{"onUpdate:modelValue":n[28]||(n[28]=s=>Ke.value.keyword=s),type:"search",placeholder:"检疫证 / 货主 / 车辆 / 地区",onKeyup:ma(Xi,["enter"])},null,544),[[jt,Ke.value.keyword]]),Ie(d("select",{"onUpdate:modelValue":n[29]||(n[29]=s=>Ke.value.town=s)},[n[88]||(n[88]=d("option",{value:""},"全部来源乡镇",-1)),(P(!0),N(U,null,ee(Jo.value,s=>(P(),N("option",{key:s,value:s},T(s),9,tf))),128))],512),[[It,Ke.value.town]]),Ie(d("select",{"onUpdate:modelValue":n[30]||(n[30]=s=>Ke.value.destination=s)},[n[89]||(n[89]=d("option",{value:""},"全部目的省份",-1)),(P(!0),N(U,null,ee(el.value,s=>(P(),N("option",{key:s,value:s},T(s),9,af))),128))],512),[[It,Ke.value.destination]]),Ie(d("select",{"onUpdate:modelValue":n[31]||(n[31]=s=>Ke.value.usage=s)},[n[90]||(n[90]=d("option",{value:""},"全部用途",-1)),(P(!0),N(U,null,ee(tl.value,s=>(P(),N("option",{key:s,value:s},T(s),9,nf))),128))],512),[[It,Ke.value.usage]]),Ie(d("select",{"onUpdate:modelValue":n[32]||(n[32]=s=>Ke.value.direction=s)},[...n[91]||(n[91]=[d("option",{value:""},"全部流向",-1),d("option",{value:"省内"},"省内",-1),d("option",{value:"省外"},"省外",-1),d("option",{value:"未标注"},"未标注",-1)])],512),[[It,Ke.value.direction]]),d("button",{type:"button",onClick:Xi},"检索"),d("button",{type:"button",class:"is-ghost",onClick:Tu},"重置")]),d("div",rf,[d("div",sf,[n[92]||(n[92]=d("div",{class:"slaughter-ledger-modal-table-head"},[d("span",null,"检疫证号"),d("span",null,"货主"),d("span",null,"畜种"),d("span",null,"数量"),d("span",null,"来源"),d("span",null,"目的地"),d("span",null,"用途"),d("span",null,"出证时间")],-1)),(P(!0),N(U,null,ee(Zt.value,s=>(P(),N("button",{key:s.recordKey,type:"button",class:Se({active:Xe.value.recordKey===s.recordKey}),onClick:c=>Su(s)},[d("span",null,T(W(s.certificateDisplay)),1),d("span",null,T(W(s.ownerDisplay)),1),d("span",null,T(W(s.animalTypeName)),1),d("strong",null,T(Y(s.animalQuantity))+"头",1),d("span",null,T(W(s.originTownName)),1),d("span",null,T(W(s.destinationName)),1),d("span",null,T(W(s.movementPurposeName)),1),d("span",null,T(ut(s.issueTime)),1)],10,of))),128)),Zt.value.length?pe("",!0):(P(),N("div",lf,T(qn.value?"出栏台账读取中":Un.value||"暂无匹配记录"),1))]),d("div",uf,[d("div",cf,[d("div",null,[d("span",null,T(W(Xe.value.certificateDisplay)),1),d("em",null,T(W(Xe.value.certificateType)),1)]),d("strong",null,T(ut(Xe.value.issueTime)),1)]),d("div",df,[d("span",null,[n[93]||(n[93]=d("em",null,"货主",-1)),d("strong",null,T(W(Xe.value.ownerDisplay)),1)]),d("span",null,[n[94]||(n[94]=d("em",null,"运输车辆",-1)),d("strong",null,T(W(Xe.value.vehicleDisplay)),1)]),d("span",null,[n[95]||(n[95]=d("em",null,"出栏品种",-1)),d("strong",null,T(W(Xe.value.animalTypeName)),1)]),d("span",null,[n[96]||(n[96]=d("em",null,"出栏数量",-1)),d("strong",null,T(Y(Xe.value.animalQuantity))+"头",1)]),d("span",null,[n[97]||(n[97]=d("em",null,"来源乡镇",-1)),d("strong",null,T(W(Xe.value.originTownName)),1)]),d("span",null,[n[98]||(n[98]=d("em",null,"流向类型",-1)),d("strong",null,T(W(Xe.value.destinationDirection)),1)]),d("span",hf,[n[99]||(n[99]=d("em",null,"销售目的地",-1)),d("strong",null,T(W(Xe.value.destinationName)),1)]),d("span",pf,[n[100]||(n[100]=d("em",null,"销售用途",-1)),d("strong",null,T(W(Xe.value.movementPurposeName)),1)]),d("span",ff,[n[101]||(n[101]=d("em",null,"证书状态",-1)),d("strong",null,T(W(Xe.value.recordStatusName)),1)])])])]),d("div",mf,[d("span",null,"第 "+T(Xt.value)+" / "+T(br.value)+" 页",1),d("button",{type:"button",disabled:Xt.value<=1,onClick:n[33]||(n[33]=s=>Qi(Xt.value-1))},"上一页",8,gf),d("button",{type:"button",disabled:Xt.value>=br.value,onClick:n[34]||(n[34]=s=>Qi(Xt.value+1))},"下一页",8,yf)])])])):pe("",!0),He.value?(P(),N("div",{key:5,class:"epidemic-image-preview-modal",onClick:Ea(Ir,["self"])},[d("div",vf,[d("div",bf,[d("div",null,[n[102]||(n[102]=d("span",null,"防疫照片",-1)),d("strong",null,T(W(Jt.value.earTag)),1)]),d("button",{type:"button",onClick:Ir},"关闭")]),d("div",wf,[d("div",Lf,[d("img",{src:st.value,alt:"防疫照片预览"},null,8,Tf)])])])])):pe("",!0)]))}};export{zf as default};