var R=Object.defineProperty,A=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var h=(e,t,n)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))$.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))_.call(t,n)&&h(e,n,t[n]);return e},N=(e,t)=>A(e,Y(t));var l=(e,t,n)=>new Promise((r,a)=>{var g=c=>{try{s(n.next(c))}catch(k){a(k)}},y=c=>{try{s(n.throw(c))}catch(k){a(k)}},s=c=>c.done?r(c.value):Promise.resolve(c.value).then(g,y);s((n=n.apply(e,t)).next())});import{r as E,n as p}from"./index-a1b5e9c0-1784132792831.js";const w="/jsyApi",o="/openApi",S=new Date().getFullYear();function F(e,t){return/^https?:\/\//.test(t)?t:`${e}${t.startsWith("/")?t:`/${t}`}`}function C(e){if((e==null?void 0:e.success)===!1&&(e==null?void 0:e.code)!==void 0&&![0,200,"0","200"].includes(e.code))throw new Error((e==null?void 0:e.msg)||(e==null?void 0:e.message)||"接口请求失败");return p(e)}function i(e,t,n,r={}){return E(F(e,t),{params:n,timeout:r.timeout||18e3}).then(C)}function T(){return i(w,"/api/yak/distribution").then(e=>m(e))}function x(){return i(w,"/api/yak/structure").then(e=>m(e))}function z(){return i(w,"/api/yak/forecast").then(e=>m(e))}function D(e=S){return i(o,"/yak/trade/overview",typeof e=="object"?e:{year:e}).then(n=>n||{})}function V(){return i(o,"/yak/trade/options").then(e=>e||{})}function I(e={}){return i(o,"/yak/trade/records",e).then(t=>t||{})}function J(e={}){return i(o,"/yak/epidemic/analysis",e).then(t=>t||{})}function q(e={}){return i(o,"/yak/epidemic/records",e).then(t=>t||{})}function L(e={}){return i(o,"/yak/epidemic/stats",e).then(t=>t||{})}function U(e={}){return i(o,"/yak/epidemic/village-stats",e).then(t=>t||{})}function W(e){return i(o,"/yak/epidemic/detail",{earTag:e}).then(t=>t||null)}function G(){return l(this,null,function*(){return(yield T()).map((t,n)=>({key:u(t,["areaCode","area_code","code","id"],`yak-town-${n}`),name:u(t,["areaName","area_name","zoneName","townName","name"],`区域${n+1}`),value:f(u(t,["number","yakCount","yak_count","count","value"])),unit:"头"})).filter(t=>t.name&&Number.isFinite(t.value)).sort((t,n)=>n.value-t.value)})}function H(){return l(this,null,function*(){const t=(yield x()).map((n,r)=>{const a=u(n,["sex","gender"],""),g=B(a),y=u(n,["ageRange","age_range","age","name","type"],""),s=[g,y].filter(Boolean).join(" ")||`结构${r+1}`;return{key:u(n,["id","key"],`${s}-${r}`),name:s,value:f(u(n,["number","count","value"])),unit:"头"}}).filter(n=>n.name&&Number.isFinite(n.value));return j(t)})}function K(){return l(this,null,function*(){return(yield z()).map((t,n)=>{const r=u(t,["month","date","name","time"],`预测${n+1}`);return{key:`${r}-${n}`,name:M(r),value:f(u(t,["number","count","yakCount","value"])),unit:"头",extra:b("增速",u(t,["speed","growth","growthRate","rate"]))}}).filter(t=>t.name&&Number.isFinite(t.value))})}function Q(){return l(this,null,function*(){const e=yield D(),t=m(e.usageCounts||e.usage_counts);return(t.length?t:m(e.startTownCounts||e.start_town_counts)).map((r,a)=>({key:u(r,["name","label"],`trade-${a}`),name:u(r,["name","label"],`类型${a+1}`),value:f(u(r,["headCount","head_count","amount","value","count"])),unit:"头",extra:b("记录",u(r,["recordCount","record_count"]))})).filter(r=>r.name&&Number.isFinite(r.value)).sort((r,a)=>a.value-r.value)})}function m(e){return Array.isArray(e)?e:Array.isArray(e==null?void 0:e.rows)?e.rows:Array.isArray(e==null?void 0:e.list)?e.list:Array.isArray(e==null?void 0:e.records)?e.records:Array.isArray(e==null?void 0:e.data)?e.data:[]}function j(e=[]){const t=new Map;return e.forEach(n=>{const r=t.get(n.name)||N(v({},n),{value:0});r.value+=n.value,t.set(n.name,r)}),[...t.values()].sort((n,r)=>r.value-n.value)}function u(e,t,n=""){for(const r of t){const a=e==null?void 0:e[r];if(a!=null&&a!=="")return a}return n}function B(e){return["boy","male","公","公牛"].includes(e)?"公牛":["girl","female","母","母牛"].includes(e)?"母牛":e||""}function M(e){const t=String(e||""),n=t.match(/(?:^|\D)(1[0-2]|0?[1-9])(?:月|$|-)/);return n?`${Number(n[1])}月`:t}function b(e,t){const n=f(t);return Number.isFinite(n)?`${e}:${n.toLocaleString("zh-CN",{maximumFractionDigits:2})}`:""}function f(e){if(e==null||e==="")return NaN;const t=Number(String(e).replace(/,/g,"").replace(/%/g,""));return Number.isFinite(t)?t:NaN}export{G as a,K as b,H as c,V as d,I as e,J as f,D as g,q as h,L as i,U as j,W as k,Q as l};