"use strict";const i=require("query-string");function _interopNamespaceCompat(e){if(e&&typeof e=="object"&&"default"in e)return e;const r=Object.create(null);if(e)for(const n in e)r[n]=e[n];return r.default=e,r}const i__namespace=_interopNamespaceCompat(i);function attempt(e,...r){try{return e(...r)}catch(n){console.error(n)}}attempt.async=async(e,...r)=>{try{return await e(...r)}catch(n){console.error(n)}};var HttpStatus=(e=>(e[e.CONTINUE=100]="CONTINUE",e[e.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",e[e.PROCESSING=102]="PROCESSING",e[e.EARLY_HINTS=103]="EARLY_HINTS",e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.ACCEPTED=202]="ACCEPTED",e[e.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.RESET_CONTENT=205]="RESET_CONTENT",e[e.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",e[e.AMBIGUOUS=300]="AMBIGUOUS",e[e.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",e[e.FOUND=302]="FOUND",e[e.SEE_OTHER=303]="SEE_OTHER",e[e.NOT_MODIFIED=304]="NOT_MODIFIED",e[e.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",e[e.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.UNAUTHORIZED=401]="UNAUTHORIZED",e[e.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",e[e.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",e[e.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",e[e.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",e[e.CONFLICT=409]="CONFLICT",e[e.GONE=410]="GONE",e[e.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",e[e.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",e[e.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",e[e.URI_TOO_LONG=414]="URI_TOO_LONG",e[e.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",e[e.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",e[e.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",e[e.MISDIRECTED=421]="MISDIRECTED",e[e.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",e[e.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",e[e.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",e[e.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",e[e.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",e[e.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",e[e.BAD_GATEWAY=502]="BAD_GATEWAY",e[e.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",e[e.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",e[e.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",e))(HttpStatus||{}),OpenType=(e=>(e.AppLaunch="appLaunch",e.AutoReLaunch="autoReLaunch",e.NavigateTo="navigateTo",e.NavigateBack="navigateBack",e.RedirectTo="redirectTo",e))(OpenType||{});function debounce(e,r=0,n={leading:!1,trailing:!0}){let c,o,N=0,E,s,A,R=0,U=!1,p=!1,P=!0;const C=!r&&r!==0&&typeof requestAnimationFrame=="function";if(typeof e!="function")throw new TypeError("Expected a function");r=r||0,n&&(U=!!n.leading,p="maxWait"in n,N=p?Math.max(n.maxWait||0,r):N,P="trailing"in n?!!n.trailing:P);function S(T){const _=c,I=o;return c=o=void 0,R=T,E=e.apply(I,_),E}function f(T,_){return C?(cancelAnimationFrame(s),requestAnimationFrame(T)):setTimeout(T,_)}function x(T){if(C)return cancelAnimationFrame(T);clearTimeout(T)}function b(T){return R=T,s=f(D,r),U?S(T):E}function F(T){const _=T-A,I=T-R,y=r-_;return p?Math.min(y,N-I):y}function L(T){const _=T-A,I=T-R;return A===void 0||_>=r||_<0||p&&I>=N}function D(){const T=Date.now();if(L(T))return g(T);s=f(D,F(T))}function g(T){return s=void 0,P&&c?S(T):(c=o=void 0,E)}function h(){s!==void 0&&x(s),R=0,c=o=s=void 0,A=0}function H(){return s===void 0?E:g(Date.now())}function Y(){return s!==void 0}function l(...T){const _=Date.now(),I=L(_);if(c=T,o=this,A=_,I){if(s===void 0)return b(A);if(p)return s=f(D,r),S(A)}return s===void 0&&(s=f(D,r)),E}return l.cancel=h,l.flush=H,l.pending=Y,l}const MAX_Z_DEPTH=999999,MIN_Z_DEPTH=999;let t=998;const getZDepth=()=>++t,getTag=e=>Object.prototype.toString.call(e);function defineProperty(e,r,n){return Object.defineProperty(e,r,{enumerable:!0,...n})}const defineProperties=Object.defineProperties,isString=e=>typeof e=="string",isNumber=e=>typeof e=="number"&&!Number.isNaN(e),isBoolean=e=>typeof e=="boolean",isFunction=e=>typeof e=="function",isError=e=>getTag(e)==="[object Error]";function isPlainObject(e){if(getTag(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let r=e;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function isEmpty(e){if(e==null)return!0;if(isString(e))return!e;if(isBoolean(e)||isNumber(e))return!1;if(Array.isArray(e))return!e.length;const r=getTag(e);return r==="[object Map]"||r==="[object Set]"?!e.size:isPlainObject(e)?!Object.keys(e).length:!0}function promisify(e){return r=>new Promise((n,c)=>{e({...r,success:n,fail:c})})}function px(e){return e+"px"}px.of=e=>Object.keys(e).reduce((r,n)=>(r[n]=px(e[n]),r),{});class Route{constructor(){}static ensure(r){return r.startsWith("/")?r:"/"+r}static generate(r,n,c){const o=Route.ensure(r);return n?isString(n)?o+(o.includes("?")?"&":"?")+n:i__namespace.stringifyUrl({url:o,query:n},c):o}static parse(r){const n=i__namespace.parseUrl(r);return{path:Route.ensure(n.url),query:n.query}}static extract(r){return Route.ensure(r.split("?")[0])}static equals(r,n){return Route.extract(r)===Route.extract(n)}static includes(r,n,c){if(this.equals(r,n))return!1;const o=E=>{const s=Route.extract(E);return s.endsWith("/")?s:s+"/"},N=c?o(r).replace(/index\/$/,""):o(r).replace(/index\//g,"");return o(n).includes(N)}}const sleep=e=>new Promise(r=>setTimeout(r,e));function throttle(e,r=0,n={leading:!0,trailing:!0}){let c=!0,o=!0;if(typeof e!="function")throw new TypeError("Expected a function");return n&&(c="leading"in n?!!n.leading:c,o="trailing"in n?!!n.trailing:o),debounce(e,r,{leading:c,trailing:o,maxWait:r})}const a={subscription:{source:"subscription"},shareFriends:{source:"share",medium:"friends"},shareTimeline:{source:"share",medium:"timeline"},qrcode:{source:"qr",medium:"qr"},wxacode:{source:"qr",medium:"wxa"}},u=[["source","utm_source","cs"],["medium","utm_medium","cm"],["campaign","utm_campaign","cn"],["content","utm_content","cc"],["keyword","utm_term","ck"]];function d(e){const r={};return u.forEach(([n,...c])=>{for(const o of c){const N=e[o];if(N&&isString(N)){r[n]=N;break}}}),r}function m(e,r=!0){return Object.entries(e).reduce((n,[c,o])=>{const[,N,E]=u.find(([A])=>A===c)??[],s=r?E:N;return isString(o)&&s?n[s]=o:n[c]=o,n},{})}function M(e,r=!0){return i__namespace.stringify(m(e,r))}function O(e,r){for(const n of Object.keys(e))if(e[n]!==r[n])return!1;return!0}const UTM={Sources:a,parse:d,generate:m,stringify:M,from:O};exports.qs=i__namespace,exports.HttpStatus=HttpStatus,exports.MAX_Z_DEPTH=MAX_Z_DEPTH,exports.MIN_Z_DEPTH=MIN_Z_DEPTH,exports.OpenType=OpenType,exports.Route=Route,exports.UTM=UTM,exports.attempt=attempt,exports.debounce=debounce,exports.defineProperties=defineProperties,exports.defineProperty=defineProperty,exports.getTag=getTag,exports.getZDepth=getZDepth,exports.isBoolean=isBoolean,exports.isEmpty=isEmpty,exports.isError=isError,exports.isFunction=isFunction,exports.isNumber=isNumber,exports.isPlainObject=isPlainObject,exports.isString=isString,exports.promisify=promisify,exports.px=px,exports.sleep=sleep,exports.throttle=throttle;