"use strict";const t=require("../../common/vendor.js"),e=require("./test.js"),n=require("./digit.js");function r(n,r=!1){return e.test.number(n)?r?`${n}px`:Number(n):/(rpx|upx)$/.test(n)?r?`${t.index.upx2px(parseInt(n))}px`:Number(t.index.upx2px(parseInt(n))):r?`${parseInt(n)}px`:parseInt(n)}function o(t=30){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}function i(){return t.index.getSystemInfoSync().platform.toLowerCase()}function s(){return t.index.getSystemInfoSync()}function c(t=32,e=!0,n=null){const r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(n=n||r.length,t)for(let i=0;i=t)return String(n);const r=t-n.length;let o=Math.ceil(r/e.length);for(;o>>=1;)e+=e,1===o&&(e+=e);return e.slice(0,r)+n});const y={range:function(t=0,e=0,n=0){return Math.max(t,Math.min(e,Number(n)))},getPx:r,sleep:o,os:i,sys:s,random:function(t,e){if(t>=0&&e>0&&e>=t){const n=e-t+1;return Math.floor(Math.random()*n+t)}return 0},guid:c,$parent:a,addStyle:u,addUnit:p,deepClone:f,deepMerge:l,error:function(t){},randomArray:function(t=[]){return t.sort((()=>Math.random()-.5))},timeFormat:g,timeFrom:function(t=null,e="yyyy-mm-dd"){null==t&&(t=Number(new Date)),10==(t=parseInt(t)).toString().length&&(t*=1e3);let n=(new Date).getTime()-t;n=parseInt(n/1e3);let r="";switch(!0){case n<300:r="刚刚";break;case n>=300&&n<3600:r=`${parseInt(n/60)}分钟前`;break;case n>=3600&&n<86400:r=`${parseInt(n/3600)}小时前`;break;case n>=86400&&n<2592e3:r=`${parseInt(n/86400)}天前`;break;default:r=!1===e?n>=2592e3&&n<31536e3?`${parseInt(n/2592e3)}个月前`:`${parseInt(n/31536e3)}年前`:g(t,e)}return r},trim:d,queryParams:function(t={},e=!0,n="brackets"){const r=e?"?":"",o=[];-1==["indices","brackets","repeat","comma"].indexOf(n)&&(n="brackets");for(const i in t){const e=t[i];if(!(["",void 0,null].indexOf(e)>=0))if(e.constructor===Array)switch(n){case"indices":for(let n=0;n{o.push(`${i}[]=${t}`)}));break;case"repeat":e.forEach((t=>{o.push(`${i}=${t}`)}));break;case"comma":let t="";e.forEach((e=>{t+=(t?",":"")+e})),o.push(`${i}=${t}`)}else o.push(`${i}=${e}`)}return o.length?r+o.join("&"):""},toast:h,type2icon:function(t="success",e=!1){-1==["primary","info","error","warning","success"].indexOf(t)&&(t="success");let n="";switch(t){case"primary":case"info":n="info-circle";break;case"error":n="close-circle";break;case"warning":n="error-circle";break;default:n="checkmark-circle"}return e&&(n+="-fill"),n},priceFormat:function(t,e=0,r=".",o=","){t=`${t}`.replace(/[^0-9+-Ee.]/g,"");const i=isFinite(+t)?+t:0,s=isFinite(+e)?Math.abs(e):0,c=void 0===o?",":o,a=void 0===r?".":r;let u="";u=(s?n.round(i,s)+"":`${Math.round(i)}`).split(".");const p=/(-?\d+)(\d{3})/;for(;p.test(u[0]);)u[0]=u[0].replace(p,`$1${c}$2`);return(u[1]||"").length30?`${t}ms`:`${t}s`:/ms$/.test(t)?n:/s$/.test(t)?n>30?n:1e3*n:n},padZero:function(t){return`00${t}`.slice(-2)},getProperty:function(t,e){if(t){if("string"!=typeof e||""===e)return"";if(-1!==e.indexOf(".")){const n=e.split(".");let r=t[n[0]]||{};for(let t=1;t1;){const o=e[0];t[o]&&"object"==typeof t[o]||(t[o]={}),e.shift(),r(t[o],e,n)}else t[e[0]]=n};if("string"!=typeof e||""===e);else if(-1!==e.indexOf(".")){const o=e.split(".");r(t,o,n)}else t[e]=n},page:function(){var t,e;const n=getCurrentPages();return`/${null!=(e=null==(t=n[n.length-1])?void 0:t.route)?e:""}`},pages:function(){return getCurrentPages()},test:e.test,getRootUrl:function(){return""},copyText:function(e){t.index.setClipboardData({data:e,success:function(){h("复制成功!")},fail:function(){h("复制失败!")}})}};exports.$helper=y,exports.$parent=a,exports.addStyle=u,exports.addUnit=p,exports.deepMerge=l,exports.getPx=r,exports.guid=c,exports.os=i,exports.sleep=o,exports.sys=s;