"use strict";const t=require("../../../../common/vendor.js"),e=require("./AbortablePromise.js");function r(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function n(t){return"[object Object]"===Object.prototype.toString.call(t)||"object"==typeof t}function o(t){const e=Object.prototype.toString.call(t).match(/\[object (\w+)\]/);return e&&e.length?e[1].toLowerCase():""}const i=t=>null!=t;function s(t,e,r){const n=(t<<16|e<<8|r).toString(16);return"#"+"0".repeat(Math.max(0,6-n.length))+n}function u(t){const e=[];for(let r=1;r<7;r+=2)e.push(parseInt("0x"+t.slice(r,r+2),16));return e}function c(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}function a(t){return"function"===o(t)||"asyncfunction"===o(t)}function p(t){return"string"===o(t)}function l(t,e=new Map){if(null===t||"object"!=typeof t)return t;if(f(t))return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(t instanceof Error){const e=new Error(t.message);return e.stack=t.stack,e}if(e.has(t))return e.get(t);const r=Array.isArray(t)?[]:{};e.set(t,r);for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=l(t[n],e));return r}const f=t=>"[object Date]"===Object.prototype.toString.call(t)&&!Number.isNaN(t.getTime());const g=(()=>!1)();exports.addUnit=function(t){return Number.isNaN(Number(t))?`${t}`:`${t}px`},exports.camelCase=function(t){return t.replace(/-(\w)/g,((t,e)=>e.toUpperCase()))},exports.context={id:1e3},exports.debounce=function(t,e,r={}){let n,o,s,u=null;const c=!!i(r.leading)&&r.leading,a=!i(r.trailing)||r.trailing;function p(){void 0!==n&&(s=t.apply(o,n),n=void 0)}function l(){u=setTimeout((()=>{u=null,a&&p()}),e)}return function(...t){return n=t,o=this,null===u?(c&&p(),l()):a&&(null!==u&&(clearTimeout(u),u=null),l()),s}},exports.deepAssign=function t(e,r){return Object.keys(r).forEach((o=>{const i=e[o],s=r[o];n(i)&&n(s)?t(i,s):e[o]=s})),e},exports.deepClone=l,exports.deepMerge=function(t,e){if("object"!=typeof(t=l(t))||"object"!=typeof e)throw new Error("Both target and source must be objects.");for(const r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t},exports.defaultDisplayFormat=function(t,e){const r=(null==e?void 0:e.labelKey)||"value";return Array.isArray(t)?t.map((t=>t[r])).join(", "):t[r]},exports.getPropByPath=(t,e)=>{const r=e.split(".");try{return r.reduce(((t,e)=>null!=t?t[e]:void 0),t)}catch(n){return}},exports.getRect=function(e,r,n,o){return new Promise(((i,s)=>{let u=null;u=n?t.index.createSelectorQuery().in(n):t.index.createSelectorQuery();const a=r?"selectAll":"select",p=t=>{r&&c(t)&&t.length>0||!r&&t?i(t):s(new Error("No nodes found"))};o?u[a](e).fields({size:!0,node:!0},p).exec():u[a](e).boundingClientRect(p).exec()}))},exports.getType=o,exports.gradient=(t,e,r=2)=>{const n=u(t),o=u(e),i=(o[0]-n[0])/r,c=(o[1]-n[1])/r,a=(o[2]-n[2])/r,p=[];for(let u=0;u<r;u++)p.push(s(parseInt(String(i*u+n[0])),parseInt(String(c*u+n[1])),parseInt(String(a*u+n[2]))));return p},exports.isArray=c,exports.isDef=i,exports.isEqual=(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0},exports.isFunction=a,exports.isH5=g,exports.isImageUrl=function(t){return/\.(xbm|tif|pjp|apng|svgz|jpeg|jpg|heif|ico|tiff|heic|pjpeg|avif|gif|png|svg|webp|jfif|bmp|dpg|image)(?=$|[?#])/i.test(t)},exports.isNumber=function(t){return"number"===o(t)},exports.isObj=n,exports.isPromise=function(t){return!(!n(t)||!i(t))&&(a(t.then)&&a(t.catch))},exports.isString=p,exports.isUndefined=function(t){return void 0===t},exports.isVideoUrl=function(t){return/\.(ogm|webm|ogv|asx|m4v|mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|video)(?=$|[?#])/i.test(t)},exports.objToStyle=function t(e){if(c(e)){const r=e.filter((function(t){return null!=t&&""!==t})).map((function(e){return t(e)})).join(";");return r?r.endsWith(";")?r:r+";":""}if(p(e))return e?e.endsWith(";")?e:e+";":"";if(n(e)){const t=Object.keys(e).filter((function(t){return null!=e[t]&&""!==e[t]})).map((function(t){return[(r=t,r.replace(/[A-Z]/g,(function(t){return"-"+t})).toLowerCase()),e[t]].join(":");var r})).join(";");return t?t.endsWith(";")?t:t+";":""}return""},exports.omitBy=function(t,e){const r=l(t);return Object.keys(r).forEach((t=>e(r[t],t)&&delete r[t])),r},exports.padZero=(t,e=2)=>{let r=t.toString();for(;r.length<e;)r="0"+r;return r},exports.pause=(t=1e3/30)=>new e.AbortablePromise((e=>{const r=setTimeout((()=>{clearTimeout(r),e(!0)}),t)})),exports.range=(t,e,r)=>Math.min(Math.max(t,e),r),exports.uuid=function(){return r()+r()+r()+r()+r()+r()+r()+r()};
