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.

1 line
2.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import{t as e}from"./axios-CiYFffbI.js";function t(){return(`https://hik.pdc.langye.net:18080/api/people-counting`?.trim()??``).replace(/\/+$/,``)}function n(){let e=t();return e?e.replace(/\/api\/people-counting$/i,``):``}var r=2e4,i=45e3;function a(t,n=r){return e.create({baseURL:t.replace(/\/+$/,``),timeout:n,headers:{Accept:`application/json`,"Content-Type":`application/json`}})}async function o(e,n){let r=t();if(!r)throw Error(`未配置 VITE_PEOPLE_COUNTING_URL海康客流 people-counting 完整地址)`);let i=a(r.replace(/\/api\/people-counting$/i,``)),o=(e||``).trim(),s=(n||``).trim(),c={};o&&/^\d{4}-\d{2}-\d{2}$/.test(o)&&(c.date=o),s&&/^\d{4}-\d{2}-\d{2}$/.test(s)&&(c.end_date=s);let{data:l}=await i.get(`/api/people-counting`,{params:Object.keys(c).length?c:void 0});return l}async function s(){let e=n();if(!e)throw Error(`未配置 VITE_PEOPLE_COUNTING_URL无法推导 /api/health 基址`);let{data:t}=await a(e).get(`/api/health`);return t}async function c(e,t){let r=n();if(!r)throw Error(`未配置 VITE_PEOPLE_COUNTING_URL无法请求 /api/venues/hourly`);let{data:i}=await a(r).get(`/api/venues/hourly`,{params:{date:e.trim(),...t&&String(t).trim()?{venueId:String(t).trim()}:{}}});return i}async function l(e){let t=n();if(!t)throw Error(`未配置 VITE_PEOPLE_COUNTING_URL无法请求 /api/device-links`);let o=a(t,e?.probe||e?.live?i:r),s={};e?.probe&&(s.probe=`true`),e?.live&&(s.live=`1`),e?.tcpTimeoutMs!=null&&Number.isFinite(e.tcpTimeoutMs)&&(s.tcpTimeoutMs=Math.min(3e4,Math.max(300,Math.floor(e.tcpTimeoutMs))));let{data:c}=await o.get(`/api/device-links`,{params:s});return c}async function u(e){let t=n();if(!t)throw Error(`未配置 VITE_PEOPLE_COUNTING_URL无法请求重试接口`);let{data:i}=await a(t,r*2).post(`/api/device-links/retry`,e);return i}function d(e){return Math.max(0,Number(e.enter??0)-Number(e.exit??0))}function f(e){return e==null?``:Array.isArray(e)?e.filter(Boolean).join(``):String(e).trim()}function p(e){let t=String(e||``).toUpperCase();return t===`UP`?`green`:t===`DEGRADED`?`orangered`:`red`}export{f as a,d as c,c as i,u as l,s as n,t as o,o as r,p as s,l as t};