minutool 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(r,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(r=typeof globalThis<"u"?globalThis:r||self,D(r.Minutool={}))})(this,function(r){"use strict";const D=(e,t)=>{let n=[];for(let i in e)n.push(e[i][t]);return n},Je=(e,t)=>{for(let n in e)if(e[n]===t)return n;return null},Xe=(e,t)=>{let n=new Map;return e.filter((i,o)=>{let a=t?t(i,o):i;if(!n.has(a))return n.set(a,!0),!0})},Qe=(e,t,n)=>{if(!e||!e.length)return e;let i={};if(e.forEach(a=>{let u=a[t];i[u]||(i[u]=[]),i[u].push(a)}),!n)return i;let o={};for(let a in i)o[a]=i[a][0];return o},Ze=e=>Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{}),et=(e,t)=>{let n=e.length;if(t<1||!n)return[];if(t>n)return[e];let i=[],o=Math.floor(n/t),a=n%t;for(let u=1;u<=o;u++)i.push(e.splice(0,t));return a&&i.push(e.splice(0,a)),i},tt=e=>{let t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]){t=n;break}return e.slice(0,t+1)},re=window.devicePixelRatio*96,nt=()=>window.innerWidth>window.innerHeight,it=()=>window.innerHeight>window.innerWidth,ae=e=>{if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullScreen)return e.webkitRequestFullScreen();throw e.mozRequestFullScreen&&e.mozRequestFullScreen(),e.msRequestFullScreen&&e.msRequestFullScreen(),"Browser no allow full screen"},ce=()=>document.exitFullscreen(),ot=e=>new Promise((t,n)=>{le()?ce().then(t).catch(n):ae(e).then(t).catch(n)}),le=()=>!!document.fullscreenElement,rt=e=>{const t=navigator.language||navigator.userLanguage;if(e.includes(t))return t;const n=t.split("-")[0],i=e.find(o=>o.startsWith(n));return i||e[0]},at=()=>navigator.userAgent.toLowerCase().indexOf("firefox")>-1,ct=(1+Math.sqrt(5))/2-1,F=96,lt=(e,t=F)=>e/25.4*t,st=e=>Math.round(e*56.6929),pt=e=>e*2.83464566929,ut=e=>e/2.83464566929,mt=(e,t=F)=>25.4*e/t,dt=(e,t,n)=>Math.min(Math.max(e,t),n),T=(e,t,n,i=!0)=>i?e>=t&&e<=n:e>t&&e<n,ft=(e,t)=>Math.floor(Math.random()*(t+1-e))+e,se=(e,t=2)=>{let n=Math.pow(10,t);return Math.round(e*n)/n},_=e=>typeof e=="number"?isFinite(e):typeof e!="string"?!1:/^[+-]?(\d+\.?\d*|\.\d+)$/.test(e),gt=(...e)=>{let t=0;return e.forEach(n=>{if(typeof n=="number"&&_(n)){const i=n.toString().split(".")[1];i&&(t=Math.max(t,i.length))}}),t},ht=e=>(e=Math.abs(Number(e)),e===0?1:Math.floor(Math.log10(e))+1);function pe(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}const R=(e,t="")=>{if(typeof e=="number")return{val:e,unit:t};if(_(e))return{val:parseFloat(e),unit:t};const n=/^(-?[\d.]+)([a-z%]+)$/i,i=e.trim().match(n);if(!i)throw new Error("unit parse fail:"+e);return{val:parseFloat(i[1]),unit:i[2].toLowerCase()}},U=(e,t,n={})=>{const i=R(e);if(!i)throw new Error(`Invalid value: ${e}`);const o=i.val,a=i.unit;if(!_(o))throw new Error(`Invalid number in value: ${e}`);const u=n.dpi||re;if(a===t)return o;const c={mm:1,cm:10,in:25.4,px:25.4/u,pt:25.4/72,pc:25.4/6},l={mm:1,cm:1/10,in:1/25.4,px:u/25.4,pt:72/25.4,pc:6/25.4};if(!c[a])throw new Error(`Unsupported source unit: ${a}`);if(!l[t])throw new Error(`Unsupported target unit: ${t}`);return o*c[a]*l[t]},ue=(e,t=0)=>_(e)?parseFloat(e):t,wt=e=>(e+"").replace(/\\(.?)/g,function(t,n){switch(n){case"\\":return"\\";case"0":return"\0";case"":return"";default:return n}}),Et=(e,t,n="...")=>{let i=/[^\x00-\xff]/g;if(e.replace(i,"mm").length<=t)return e;let o=Math.floor(t/2);for(let a=o;a<e.length;a++)if(e.substr(0,a).replace(i,"mm").length>=t)return e.substr(0,a)+n;return e},Tt=(e,t)=>{const n=Object.keys(t),i=Object.values(t);return new Function(...n,`return \`${e}\`;`)(...i)};function vt(e){return e.replace(/[-_](.)/g,(t,n)=>n.toUpperCase())}function bt(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function yt(e,t,n="..."){return e.length<=t?e:e.slice(0,t)+n}const I=e=>(e+"").replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g,"\\$1"),me=e=>{let t="",n=0,i=0,o=0,a=0;for(;n<e.length;)i=e.charCodeAt(n),i<128?(t+=String.fromCharCode(i),n++):i>191&&i<224?(o=e.charCodeAt(n+1),t+=String.fromCharCode((i&31)<<6|o&63),n+=2):(o=e.charCodeAt(n+1),a=e.charCodeAt(n+2),t+=String.fromCharCode((i&15)<<12|(o&63)<<6|a&63),n+=3);return t},B=e=>{e=e.replace(/\r\n/g,"n");let t="";for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);i<128?t+=String.fromCharCode(i):i>127&&i<2048?(t+=String.fromCharCode(i>>6|192),t+=String.fromCharCode(i&63|128)):(t+=String.fromCharCode(i>>12|224),t+=String.fromCharCode(i>>6&63|128),t+=String.fromCharCode(i&63|128))}return t},Mt=e=>{let t=0,n=e.length,i=-1;for(let o=0;o<n;o++)i=e.charCodeAt(o),i>=0&&i<=128?t+=1:t+=3;return t},At="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890",de=(e=6,t=At)=>{let n="";for(let i=0;i<e;i++){let o=Math.round(Math.random()*(t.length-1));n+=t.substring(o,o+1)}return n},St=(e=1,t=8)=>{let n=[];const i="bcdfghjklmnpqrstvwxyz",o="aeiou";for(;e-- >0;){let a="";for(let u=0;u<t;u=u+3)a+=i[Math.floor(Math.random()*i.length)],a+=o[Math.floor(Math.random()*o.length)],a+=i[Math.floor(Math.random()*i.length)];n.push(a)}return n},_t=(e,t=!1)=>{let n=[];return e.replace(/[-_\s+]/g," ").split(" ").forEach((i,o)=>{n.push(o===0&&!t?i:pe(i))}),n.join("")},$=0,Y=1,fe=2,Ct=(e,t="",n=$)=>{if(t.length){let i=new RegExp("^["+I(t)+"]+"),o=new RegExp("["+I(t)+"]+$");return n===Y?e.replace(i,""):n===fe?e.replace(o,""):e.replace(i,"").replace(o,"")}else return n===$?e.trim():n===Y?e.trimStart():e.trimEnd()},Nt=(e,t)=>{let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n},Dt=e=>/[\u4e00-\u9fa5]/.test(e),Ot=(e,t="B",n=2)=>{const i=["B","KB","MB","GB","TB","PB"];let o=i.indexOf(t.toUpperCase());if(o===-1)throw new Error(`Unsupported unit: ${t}`);for(;e>=1024&&o<i.length-1;)e/=1024,o++;return se(e,n)},b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Rt=e=>{let t="",n,i,o,a,u,c,l,s=0;for(e=e.replace(/\+\+[++^A-Za-z0-9+/=]/g,"");s<e.length;)a=b.indexOf(e.charAt(s++)),u=b.indexOf(e.charAt(s++)),c=b.indexOf(e.charAt(s++)),l=b.indexOf(e.charAt(s++)),n=a<<2|u>>4,i=(u&15)<<4|c>>2,o=(c&3)<<6|l,t=t+String.fromCharCode(n),c!==64&&(t=t+String.fromCharCode(i)),l!==64&&(t=t+String.fromCharCode(o));return t=me(t),t},It=e=>B(e).replace("+","-").replace("/","_"),xt=e=>{let t="",n,i,o,a,u,c,l,s=0;for(e=B(e);s<e.length;)n=e.charCodeAt(s++),i=e.charCodeAt(s++),o=e.charCodeAt(s++),a=n>>2,u=(n&3)<<4|i>>4,c=(i&15)<<2|o>>6,l=o&63,isNaN(i)?c=l=64:isNaN(o)&&(l=64),t=t+b.charAt(a)+b.charAt(u)+b.charAt(c)+b.charAt(l);return t},ge=async e=>await Lt(e),Lt=e=>new Promise((t,n)=>{const i=new FileReader;i.readAsDataURL(e),i.onload=()=>t(i.result),i.onerror=o=>n(o)}),kt=(e,t,n,i="/",o)=>{let a="";if(n){let c=new Date;c.setTime(Date.now()+n*24*60*60*1e3),a="; expires="+c.toUTCString()}let u=e+"="+(t||"")+a+"; path="+i;o&&(u+="; domain="+o),document.cookie=u},Ht=e=>{let t=e+"=",n=document.cookie.split(";");for(let i=0;i<n.length;i++){let o=n[i];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return o.substring(t.length,o.length)}return null},x=(e,t="/",n)=>{let i=e+"=; Path="+t+"; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";n&&(i+=" Domain="+n+";"),document.cookie=i},Pt=(e,t)=>{const n=(t||(location==null?void 0:location.hostname)).split(".");for(;n.length>1;)x(e,"/",n.join(".")),x(e,"/","."+n.join(".")),n.shift();x(e)};let Ft=0;const he=(e="")=>"guid_"+(e||de(6))+ ++Ft,Ut=(e,t)=>{let n,i,o=0;return function(){let a=+new Date;n=this,i=arguments,a-o>t&&(e.apply(n,i),o=a)}},Bt=(e,t)=>{let n,i,o=0,a=!1;return function(){if(a)return;let u=+new Date;n=this,i=arguments;let c=t-(u-o);c<=0?(e.apply(n,i),o=u):(a=!0,setTimeout(()=>{e.apply(n,i),a=!1,o=u},c))}},$t=(e,t)=>{let n;return function(){let i=this,o=arguments;clearTimeout(n),n=setTimeout(function(){e.apply(i,o)},t)}},Yt=e=>e&&typeof e=="object"&&e.then&&typeof e.then=="function",jt=e=>{let t=!1;try{JSON.parse(e),t=!0}catch{}return t},zt=e=>e&&typeof e=="object"&&!Array.isArray(e),qt=e=>e?Object.prototype.toString.call(e)==="[object Function]"||typeof e=="function"||e instanceof Function:!1,we=e=>typeof e!="string"||e.trim()===""?!1:/^(https?:\/\/|\/\/|\/|\.\.?\/*)/i.test(e),Gt=e=>{let t=!1;try{JSON.parse(e),t=!0}catch{}return t},Kt=()=>{let e=new Error().stack;console.log(e)},j=new EventTarget,Wt=new Map,z=new Map;let Vt=0;const Jt="__MINUTOOL_SYM_EVENT__";function q(e){if(!z.has(e)){const t=`${Jt}${++Vt}`;z.set(e,t),Wt.set(t,e)}return z.get(e)}const Xt=(e,t)=>{const n=e.map(i=>Ee(i,t));return()=>n.forEach(i=>i())},Ee=(e,t)=>(j.addEventListener(typeof e=="symbol"?q(e):e,t),()=>Te(e,t)),Te=(e,t)=>{j.removeEventListener(typeof e=="symbol"?q(e):e,t)},Qt=(e,t=null)=>{j.dispatchEvent(new CustomEvent(typeof e=="symbol"?q(e):e,{detail:t}))},Zt=e=>{if(document.readyState==="complete"||document.readyState==="interactive")e();else{const t=()=>{e(),document.removeEventListener("DOMContentLoaded",t)};document.addEventListener("DOMContentLoaded",t)}},en=(e,t,n,i)=>y(e,n,a=>{var l;const u=a.target,c=(l=u==null?void 0:u.closest)==null?void 0:l.call(u,t);c&&i(a,c)}),tn=(e,t)=>y(e,"click",t),nn=(e,t)=>y(e,"keyup",t),on=(e,t)=>y(e,"keydown",t),rn=(e,t)=>y(e,"dblclick",t),y=(e,t,n)=>{const i=a=>{n(a)},o=typeof e=="string"?v(e):e;if(!o)throw new Error(`EventTarget not found for selector: ${e}`);return o.addEventListener(t,i),()=>{o.removeEventListener(t,i)}},an=(e,t)=>{if("createEvent"in document){let n=document.createEvent("HTMLEvents");n.initEvent(t.toLowerCase(),!1,!0),e.dispatchEvent(n)}else e.fireEvent("on"+t.toLowerCase())},cn=e=>{const t=v(e);t&&(t.style.display="none")},ln=e=>{const t=v(e);t&&(t.style.display="")},sn=e=>{let t=v(e);return t&&t.parentNode&&t.parentNode.removeChild(t)},G="disabled",ve=(e,t="")=>K(e,t,!1),be=(e,t="")=>K(e,t,!0),K=(e,t="",n=null)=>{let i=v(e),o=n===null?!i.classList.contains(G):!n;o&&Me(`.${G} {pointer-event:none !important;}`,"__element_lock_style__"),i.classList.toggle(G,o),i[o?"setAttribute":"removeAttribute"]("disabled","disabled"),i[o?"setAttribute":"removeAttribute"]("data-disabled","disabled"),t&&i.classList.toggle(t,o)},pn=(e,t,n)=>{e=v(e);let i=!1;const o=[];return o.push(y(e,"mouseenter",()=>{i||(i=!0,t&&t())})),o.push(y(e,"mouseleave",()=>{i&&(i=!1,n&&n())})),()=>{o.forEach(a=>a())}},un=(e,t)=>{ve(e),t(()=>{be(e)})},mn=e=>e.parentNode?Array.prototype.indexOf.call(e.parentNode.children,e):-1,W=(e,t=document)=>{if(typeof e=="string")return e=e.trim(),e.indexOf(":scope")!==0&&(e=":scope "+e),Array.from(t.querySelectorAll(e));if(Array.isArray(e)){let n=[];return e.forEach(i=>{n.push(...W(i))}),n}else return NodeList.prototype.isPrototypeOf(e)||HTMLCollection.prototype.isPrototypeOf(e)?Array.from(e):e instanceof HTMLElement?[e]:e},v=(e,t=document)=>typeof e=="string"?t.querySelector(e):e,dn=e=>{let t=document.getElementsByTagName("*"),n=[];for(n=[];e&&e.nodeType===1;e=e.parentNode)if(e.hasAttribute("id")){let i=0;for(let o=0;o<t.length&&(t[o].hasAttribute("id")&&t[o].id===e.id&&i++,!(i>1));o++);if(i===1)return n.unshift('id("'+e.getAttribute("id")+'")'),n.join("/");n.unshift(e.localName.toLowerCase()+'[@id="'+e.getAttribute("id")+'"]')}else if(e.hasAttribute("class"))n.unshift(e.localName.toLowerCase()+'[@class="'+e.getAttribute("class")+'"]');else{let i,o;for(i=1,o=e.previousSibling;o;o=o.previousSibling)o.localName===e.localName&&i++;n.unshift(e.localName.toLowerCase()+"["+i+"]")}return n.length?"/"+n.join("/"):null},fn=(e,t,n=!0)=>{const i="ON_DOM_TREE_CHANGE_BIND_"+he();let o=()=>{W(`input:not([${i}]), textarea:not([${i}]), select:not([${i}])`,e).forEach(a=>{a.setAttribute(i,"1"),a.addEventListener("change",t)})};ye(e,{attributes:!0,subtree:!0,childList:!0},()=>{n&&o(),t()},10),n&&o()},ye=(e,t,n,i=10)=>{let o=0,a=!1,u=new MutationObserver(()=>{if(a)return;let c=i-(Date.now()-o);c>0?(a=!0,setTimeout(()=>{a=!1,o=Date.now(),n(u)},c)):(o=Date.now(),n(u))});u.observe(e,t)},gn=(e,t={left:0,top:0,width:window.innerWidth,height:window.innerHeight})=>{let n={left:e.left,top:e.top};return e.width>t.width||e.height>t.height||(e.width+e.left>t.width+t.left&&(n.left=e.left-(e.width+e.left-(t.width+t.left))),e.height+e.top>t.height+t.top&&(n.top=e.top-(e.height+e.top-(t.height+t.top))),e.left<t.left&&(n.left=t.left),e.top<t.top&&(n.top=t.top)),n},hn=(e,t)=>e.left<=t.left?e.left+e.width>=t.left&&(T(t.top,e.top,e.top+e.height)||T(t.top+t.height,e.top,e.top+e.height)||t.top>=e.top&&t.height>=e.height):t.left+t.width>=e.left&&(T(e.top,t.top,t.top+t.height)||T(e.top+e.height,t.top,t.top+t.height)||e.top>=t.top&&e.height>=t.height),wn=e=>e?!!(e.tabIndex>=0||e instanceof HTMLAnchorElement&&e.href||e instanceof HTMLButtonElement&&!e.disabled||e instanceof HTMLInputElement&&!e.disabled||e instanceof HTMLTextAreaElement&&!e.disabled):!1;let M={};const En=(e,t=!1)=>(!t&&e in M||(M[e]=new Promise((n,i)=>{let o=document.createElement("link");o.rel="stylesheet",o.href=e,o.onload=()=>{n()},o.onerror=()=>{i()},document.head.append(o)})),M[e]),Tn=(e,t=!1)=>(!t&&e in M||(M[e]=new Promise((n,i)=>{let o=document.createElement("script");o.src=e,o.onload=()=>{n()},o.onerror=()=>{i()},document.head.append(o)})),M[e]),vn=e=>{let t=e.style.visibility,n=e.style.display,i,o;return e.style.visibility="hidden",e.style.display="block",i=e.clientWidth,o=e.clientHeight,e.style.visibility=t,e.style.display=n,{width:i,height:o}},Me=(e,t="",n=document)=>{if(t&&n.querySelector(`#${t}`))return n.querySelector(`#${t}`);let i=n.createElement("style");return n.head.appendChild(i),i.innerHTML=e,t&&(i.id=t),i},bn=(e,t)=>T(e.top,t.top,t.top+t.height)&&T(e.left,t.left,t.left+t.width)&&T(e.top+e.height,t.top,t.top+t.height)&&T(e.left+e.width,t.left,t.left+t.width),yn=e=>Math.pow(10,-e),Mn=(e,t)=>{try{return new URL(e,t).href}catch{return e}},An=(e,t=null)=>{let n=document.createElement("template");e=e.trim(),n.innerHTML=e;let i=[];return t?n.content.childNodes.forEach(o=>{i.push(t.appendChild(o))}):i=Array.from(n.content.childNodes),i.length===1?i[0]:i},Ae=(e,t=!1)=>{if(!e)throw new Error("el is null");const n=e.getBoundingClientRect();if(t&&!n.height){const i=e.style.visibility,o=e.style.display;e.style.visibility="hidden",e.style.display="block";const a=Ae(e);return e.style.visibility=i,e.style.display=o,a}return{top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height}},Sn=e=>{let t={};for(let n in e){const i=e[n];i!=null&&(t[`--${n}`]=`${i}`)}return t};function _n(e,t=null){const n=v(e);t=v(t||n);const i=n.style.position,o=n.style.left,a=n.style.top,u=n.style.transform;let c=!1,l=0,s=0;const p=w=>{c&&(n.style.position="fixed",n.style.transform="none",n.style.left=`${w.clientX-l}px`,n.style.top=`${w.clientY-s}px`)},S=()=>{c=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",S)},h=w=>{if(w.button!==0)return;c=!0;const P=n.getBoundingClientRect();l=w.clientX-P.left,s=w.clientY-P.top,document.addEventListener("mousemove",p),document.addEventListener("mouseup",S),w.preventDefault()};return t.addEventListener("mousedown",h),()=>{S(),t.removeEventListener("mousedown",h),n.style.position=i,n.style.left=o,n.style.top=a,n.style.transform=u}}const Cn=e=>e.replace(/[\\/:*?"<>|]/g,"_").replace(/[\0-\x1F]/g,"_").replace(/\s+/g," ").replace(/^\.+/,"").replace(/\.+$/,"").trim(),V=e=>new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=o=>n(o),i.readAsDataURL(e)}),Se={},J=(e,t=null)=>t!==null?(Se[e]=t,null):Se[e]||null,Nn=async e=>{if(!e)return null;if(typeof e=="string"&&e.startsWith("data:"))return e;try{if(typeof e=="string"&&we(e)){const t=await fetch(e);if(!t.ok)throw new Error(`Fetch failed: ${t.status}`);const n=await t.blob();return await V(n)}return e instanceof Blob?await V(e):null}catch(t){return console.warn("file2Base64DataURL failed:",t),null}},Dn=(e,t)=>{const n=document.createElement("a");n.rel="noopener noreferrer",n.href=e,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)},X=["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","CANVAS","DD","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","NOSCRIPT","OL","P","PRE","SECTION","TABLE","TFOOT","UL","VIDEO"],On=["A","ABBR","ACRONYM","B","BDO","BIG","BUTTON","CITE","CODE","DFN","EM","I","KBD","LABEL","MAP","OBJECT","OUTPUT","Q","S","SAMP","SCRIPT","SELECT","SMALL","SPAN","STRONG","SUB","SUP","TEXTAREA","TIME","TT","U","VAR"].concat(...X),Rn=["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"],_e=["STYLE","COMMENT","SELECT","OPTION","SCRIPT","TITLE","HEAD","BUTTON","META","LINK","PARAM","SOURCE"],In=(e,t={})=>{t.keepLineBreak=t.keepLineBreak!==!1;const n=t.imgReplacer!==void 0?t.imgReplacer:"[Image]";e=e.replace(/<img[^>]*src=["']([^"']*)["'][^>]*alt=["']([^"']*)["'][^>]*>/gi,function(a,u,c){return typeof n=="function"?n(u,c):n}),e=e.replace(/<img[^>]*alt=["']([^"']*)["'][^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,u,c){return typeof n=="function"?n(c,u):n}),e=e.replace(/<img[^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,u){return typeof n=="function"?n(u,""):n});const i=t.videoReplacer!==void 0?t.videoReplacer:"[Video]";return e=e.replace(/<video[^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,u){return typeof i=="function"?i(u,""):i}),e=e.replace(/<video[^>]*>[\s\S]*?<source[^>]*src=["']([^"']*)["'][^>]*>[\s\S]*?<\/video>/gi,function(a,u){return typeof i=="function"?i(u,""):i}),_e.forEach(a=>{e=e.replace(new RegExp(`<${a}[^>]*>([\\s\\S]*?)<\\/${a}>`,"gi"),""),e=e.replace(new RegExp(`<${a}[^>]*>`,"gi"),"")}),e=e.replace(/[\r|\n]/g,""),e=e.replace(/<(\w+)([^>]*)>/g,function(a,u,c){return X.includes(u.toUpperCase())?`
1
+ (function(r,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(r=typeof globalThis<"u"?globalThis:r||self,D(r.Minutool={}))})(this,function(r){"use strict";const D=(e,t)=>{let n=[];for(let i in e)n.push(e[i][t]);return n},Je=(e,t)=>{for(let n in e)if(e[n]===t)return n;return null},Xe=(e,t)=>{let n=new Map;return e.filter((i,o)=>{let a=t?t(i,o):i;if(!n.has(a))return n.set(a,!0),!0})},Qe=(e,t,n)=>{if(!e||!e.length)return e;let i={};if(e.forEach(a=>{let u=a[t];i[u]||(i[u]=[]),i[u].push(a)}),!n)return i;let o={};for(let a in i)o[a]=i[a][0];return o},Ze=e=>Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{}),et=(e,t)=>{let n=e.length;if(t<1||!n)return[];if(t>n)return[e];let i=[],o=Math.floor(n/t),a=n%t;for(let u=1;u<=o;u++)i.push(e.splice(0,t));return a&&i.push(e.splice(0,a)),i},tt=e=>{let t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]){t=n;break}return e.slice(0,t+1)},re=window.devicePixelRatio*96,nt=()=>window.innerWidth>window.innerHeight,it=()=>window.innerHeight>window.innerWidth,ae=e=>{if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullScreen)return e.webkitRequestFullScreen();throw e.mozRequestFullScreen&&e.mozRequestFullScreen(),e.msRequestFullScreen&&e.msRequestFullScreen(),"Browser no allow full screen"},ce=()=>document.exitFullscreen(),ot=e=>new Promise((t,n)=>{le()?ce().then(t).catch(n):ae(e).then(t).catch(n)}),le=()=>!!document.fullscreenElement,rt=e=>{const t=navigator.language||navigator.userLanguage;if(e.includes(t))return t;const n=t.split("-")[0],i=e.find(o=>o.startsWith(n));return i||e[0]},at=()=>navigator.userAgent.toLowerCase().indexOf("firefox")>-1,ct=(1+Math.sqrt(5))/2-1,F=96,lt=(e,t=F)=>e/25.4*t,st=e=>Math.round(e*56.6929),pt=e=>e*2.83464566929,ut=e=>e/2.83464566929,mt=(e,t=F)=>25.4*e/t,dt=(e,t,n)=>Math.min(Math.max(e,t),n),T=(e,t,n,i=!0)=>i?e>=t&&e<=n:e>t&&e<n,ft=(e,t)=>Math.floor(Math.random()*(t+1-e))+e,se=(e,t=2)=>{let n=Math.pow(10,t);return Math.round(e*n)/n},_=e=>typeof e=="number"?isFinite(e):typeof e!="string"?!1:/^[+-]?(\d+\.?\d*|\.\d+)$/.test(e),gt=(...e)=>{let t=0;return e.forEach(n=>{if(typeof n=="number"&&_(n)){const i=n.toString().split(".")[1];i&&(t=Math.max(t,i.length))}}),t},ht=e=>(e=Math.abs(Number(e)),e===0?1:Math.floor(Math.log10(e))+1);function pe(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}const R=(e,t="")=>{if(typeof e=="number")return{val:e,unit:t};if(_(e))return{val:parseFloat(e),unit:t};const n=/^(-?[\d.]+)([a-z%]+)$/i,i=e.trim().match(n);if(!i)throw new Error("unit parse fail:"+e);return{val:parseFloat(i[1]),unit:i[2].toLowerCase()}},U=(e,t,n={})=>{const i=R(e);if(!i)throw new Error(`Invalid value: ${e}`);const o=i.val,a=i.unit;if(!_(o))throw new Error(`Invalid number in value: ${e}`);const u=n.dpi||re;if(a===t)return o;const c={mm:1,cm:10,in:25.4,px:25.4/u,pt:25.4/72,pc:25.4/6},l={mm:1,cm:1/10,in:1/25.4,px:u/25.4,pt:72/25.4,pc:6/25.4};if(!c[a])throw new Error(`Unsupported source unit: ${a}`);if(!l[t])throw new Error(`Unsupported target unit: ${t}`);return o*c[a]*l[t]},ue=(e,t=0)=>_(e)?parseFloat(e):t,wt=e=>(e+"").replace(/\\(.?)/g,function(t,n){switch(n){case"\\":return"\\";case"0":return"\0";case"":return"";default:return n}}),Et=(e,t,n="...")=>{let i=/[^\x00-\xff]/g;if(e.replace(i,"mm").length<=t)return e;let o=Math.floor(t/2);for(let a=o;a<e.length;a++)if(e.substr(0,a).replace(i,"mm").length>=t)return e.substr(0,a)+n;return e},Tt=(e,t)=>{const n=Object.keys(t),i=Object.values(t);return new Function(...n,`return \`${e}\`;`)(...i)};function vt(e){return e.replace(/[-_](.)/g,(t,n)=>n.toUpperCase())}function bt(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function yt(e,t,n="..."){return e.length<=t?e:e.slice(0,t)+n}const I=e=>(e+"").replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g,"\\$1"),me=e=>{let t="",n=0,i=0,o=0,a=0;for(;n<e.length;)i=e.charCodeAt(n),i<128?(t+=String.fromCharCode(i),n++):i>191&&i<224?(o=e.charCodeAt(n+1),t+=String.fromCharCode((i&31)<<6|o&63),n+=2):(o=e.charCodeAt(n+1),a=e.charCodeAt(n+2),t+=String.fromCharCode((i&15)<<12|(o&63)<<6|a&63),n+=3);return t},B=e=>{e=e.replace(/\r\n/g,"n");let t="";for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);i<128?t+=String.fromCharCode(i):i>127&&i<2048?(t+=String.fromCharCode(i>>6|192),t+=String.fromCharCode(i&63|128)):(t+=String.fromCharCode(i>>12|224),t+=String.fromCharCode(i>>6&63|128),t+=String.fromCharCode(i&63|128))}return t},Mt=e=>{let t=0,n=e.length,i=-1;for(let o=0;o<n;o++)i=e.charCodeAt(o),i>=0&&i<=128?t+=1:t+=3;return t},At="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890",de=(e=6,t=At)=>{let n="";for(let i=0;i<e;i++){let o=Math.round(Math.random()*(t.length-1));n+=t.substring(o,o+1)}return n},St=(e=1,t=8)=>{let n=[];const i="bcdfghjklmnpqrstvwxyz",o="aeiou";for(;e-- >0;){let a="";for(let u=0;u<t;u=u+3)a+=i[Math.floor(Math.random()*i.length)],a+=o[Math.floor(Math.random()*o.length)],a+=i[Math.floor(Math.random()*i.length)];n.push(a)}return n},_t=(e,t=!1)=>{let n=[];return e.replace(/[-_\s+]/g," ").split(" ").forEach((i,o)=>{n.push(o===0&&!t?i:pe(i))}),n.join("")},$=0,Y=1,fe=2,Ct=(e,t="",n=$)=>{if(t.length){let i=new RegExp("^["+I(t)+"]+"),o=new RegExp("["+I(t)+"]+$");return n===Y?e.replace(i,""):n===fe?e.replace(o,""):e.replace(i,"").replace(o,"")}else return n===$?e.trim():n===Y?e.trimStart():e.trimEnd()},Nt=(e,t)=>{let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n},Dt=e=>/[\u4e00-\u9fa5]/.test(e),Ot=(e,t="B",n=2)=>{const i=["B","KB","MB","GB","TB","PB"];let o=i.indexOf(t.toUpperCase());if(o===-1)throw new Error(`Unsupported unit: ${t}`);for(;e>=1024&&o<i.length-1;)e/=1024,o++;return se(e,n)},b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Rt=e=>{let t="",n,i,o,a,u,c,l,s=0;for(e=e.replace(/\+\+[++^A-Za-z0-9+/=]/g,"");s<e.length;)a=b.indexOf(e.charAt(s++)),u=b.indexOf(e.charAt(s++)),c=b.indexOf(e.charAt(s++)),l=b.indexOf(e.charAt(s++)),n=a<<2|u>>4,i=(u&15)<<4|c>>2,o=(c&3)<<6|l,t=t+String.fromCharCode(n),c!==64&&(t=t+String.fromCharCode(i)),l!==64&&(t=t+String.fromCharCode(o));return t=me(t),t},It=e=>B(e).replace("+","-").replace("/","_"),xt=e=>{let t="",n,i,o,a,u,c,l,s=0;for(e=B(e);s<e.length;)n=e.charCodeAt(s++),i=e.charCodeAt(s++),o=e.charCodeAt(s++),a=n>>2,u=(n&3)<<4|i>>4,c=(i&15)<<2|o>>6,l=o&63,isNaN(i)?c=l=64:isNaN(o)&&(l=64),t=t+b.charAt(a)+b.charAt(u)+b.charAt(c)+b.charAt(l);return t},ge=async e=>await Lt(e),Lt=e=>new Promise((t,n)=>{const i=new FileReader;i.readAsDataURL(e),i.onload=()=>t(i.result),i.onerror=o=>n(o)}),kt=(e,t,n,i="/",o)=>{let a="";if(n){let c=new Date;c.setTime(Date.now()+n*24*60*60*1e3),a="; expires="+c.toUTCString()}let u=e+"="+(t||"")+a+"; path="+i;o&&(u+="; domain="+o),document.cookie=u},Ht=e=>{let t=e+"=",n=document.cookie.split(";");for(let i=0;i<n.length;i++){let o=n[i];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return o.substring(t.length,o.length)}return null},x=(e,t="/",n)=>{let i=e+"=; Path="+t+"; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";n&&(i+=" Domain="+n+";"),document.cookie=i},Pt=(e,t)=>{const n=(t||(location==null?void 0:location.hostname)).split(".");for(;n.length>1;)x(e,"/",n.join(".")),x(e,"/","."+n.join(".")),n.shift();x(e)};let Ft=0;const he=(e="")=>"guid_"+(e||de(6))+ ++Ft,Ut=(e,t)=>{let n,i,o=0;return function(){let a=+new Date;n=this,i=arguments,a-o>t&&(e.apply(n,i),o=a)}},Bt=(e,t)=>{let n,i,o=0,a=!1;return function(){if(a)return;let u=+new Date;n=this,i=arguments;let c=t-(u-o);c<=0?(e.apply(n,i),o=u):(a=!0,setTimeout(()=>{e.apply(n,i),a=!1,o=u},c))}},$t=(e,t)=>{let n;return function(){let i=this,o=arguments;clearTimeout(n),n=setTimeout(function(){e.apply(i,o)},t)}},Yt=e=>e&&typeof e=="object"&&e.then&&typeof e.then=="function",jt=e=>{let t=!1;try{JSON.parse(e),t=!0}catch{}return t},zt=e=>e&&typeof e=="object"&&!Array.isArray(e),qt=e=>e?Object.prototype.toString.call(e)==="[object Function]"||typeof e=="function"||e instanceof Function:!1,we=e=>typeof e!="string"||e.trim()===""?!1:/^(https?:\/\/|\/\/|\/|\.\.?\/*)/i.test(e),Gt=e=>{let t=!1;try{JSON.parse(e),t=!0}catch{}return t},Kt=()=>{let e=new Error().stack;console.log(e)},j=new EventTarget,Wt=new Map,z=new Map;let Vt=0;const Jt="__MINUTOOL_SYM_EVENT__";function q(e){if(!z.has(e)){const t=`${Jt}${++Vt}`;z.set(e,t),Wt.set(t,e)}return z.get(e)}const Xt=(e,t)=>{const n=e.map(i=>Ee(i,t));return()=>n.forEach(i=>i())},Ee=(e,t)=>(j.addEventListener(typeof e=="symbol"?q(e):e,t),()=>Te(e,t)),Te=(e,t)=>{j.removeEventListener(typeof e=="symbol"?q(e):e,t)},Qt=(e,t=null)=>{j.dispatchEvent(new CustomEvent(typeof e=="symbol"?q(e):e,{detail:t}))},Zt=e=>{if(document.readyState==="complete"||document.readyState==="interactive")e();else{const t=()=>{e(),document.removeEventListener("DOMContentLoaded",t)};document.addEventListener("DOMContentLoaded",t)}},en=(e,t,n,i)=>y(e,n,a=>{var l;const u=a.target,c=(l=u==null?void 0:u.closest)==null?void 0:l.call(u,t);c&&i(a,c)}),tn=(e,t)=>y(e,"click",t),nn=(e,t)=>y(e,"keyup",t),on=(e,t)=>y(e,"keydown",t),rn=(e,t)=>y(e,"dblclick",t),y=(e,t,n)=>{const i=a=>{n(a)},o=typeof e=="string"?v(e):e;if(!o)throw new Error(`EventTarget not found for selector: ${e}`);return o.addEventListener(t,i),()=>{o.removeEventListener(t,i)}},an=(e,t)=>{if("createEvent"in document){let n=document.createEvent("HTMLEvents");n.initEvent(t.toLowerCase(),!1,!0),e.dispatchEvent(n)}else e.fireEvent("on"+t.toLowerCase())},cn=e=>{const t=v(e);t&&(t.style.display="none")},ln=e=>{const t=v(e);t&&(t.style.display="")},sn=e=>{let t=v(e);return t&&t.parentNode&&t.parentNode.removeChild(t)},G="disabled",ve=(e,t="")=>K(e,t,!1),be=(e,t="")=>K(e,t,!0),K=(e,t="",n=null)=>{let i=v(e),o=n===null?!i.classList.contains(G):!n;o&&Me(`.${G} {pointer-event:none !important;}`,"__element_lock_style__"),i.classList.toggle(G,o),i[o?"setAttribute":"removeAttribute"]("disabled","disabled"),i[o?"setAttribute":"removeAttribute"]("data-disabled","disabled"),t&&i.classList.toggle(t,o)},pn=(e,t,n)=>{e=v(e);let i=!1;const o=[];return o.push(y(e,"mouseenter",()=>{i||(i=!0,t&&t())})),o.push(y(e,"mouseleave",()=>{i&&(i=!1,n&&n())})),()=>{o.forEach(a=>a())}},un=(e,t)=>{ve(e),t(()=>{be(e)})},mn=e=>e.parentNode?Array.prototype.indexOf.call(e.parentNode.children,e):-1,W=(e,t=document)=>{if(typeof e=="string")return e=e.trim(),e.indexOf(":scope")!==0&&(e=":scope "+e),Array.from(t.querySelectorAll(e));if(Array.isArray(e)){let n=[];return e.forEach(i=>{n.push(...W(i))}),n}else return NodeList.prototype.isPrototypeOf(e)||HTMLCollection.prototype.isPrototypeOf(e)?Array.from(e):e instanceof HTMLElement?[e]:e},v=(e,t=document)=>typeof e=="string"?t.querySelector(e):e,dn=e=>{let t=document.getElementsByTagName("*"),n=[];for(n=[];e&&e.nodeType===1;e=e.parentNode)if(e.hasAttribute("id")){let i=0;for(let o=0;o<t.length&&(t[o].hasAttribute("id")&&t[o].id===e.id&&i++,!(i>1));o++);if(i===1)return n.unshift('id("'+e.getAttribute("id")+'")'),n.join("/");n.unshift(e.localName.toLowerCase()+'[@id="'+e.getAttribute("id")+'"]')}else if(e.hasAttribute("class"))n.unshift(e.localName.toLowerCase()+'[@class="'+e.getAttribute("class")+'"]');else{let i,o;for(i=1,o=e.previousSibling;o;o=o.previousSibling)o.localName===e.localName&&i++;n.unshift(e.localName.toLowerCase()+"["+i+"]")}return n.length?"/"+n.join("/"):null},fn=(e,t,n=!0)=>{const i="ON_DOM_TREE_CHANGE_BIND_"+he();let o=()=>{W(`input:not([${i}]), textarea:not([${i}]), select:not([${i}])`,e).forEach(a=>{a.setAttribute(i,"1"),a.addEventListener("change",t)})};ye(e,{attributes:!0,subtree:!0,childList:!0},()=>{n&&o(),t()},10),n&&o()},ye=(e,t,n,i=10)=>{let o=0,a=!1,u=new MutationObserver(()=>{if(a)return;let c=i-(Date.now()-o);c>0?(a=!0,setTimeout(()=>{a=!1,o=Date.now(),n(u)},c)):(o=Date.now(),n(u))});u.observe(e,t)},gn=(e,t={left:0,top:0,width:window.innerWidth,height:window.innerHeight})=>{let n={left:e.left,top:e.top};return e.width>t.width||e.height>t.height||(e.width+e.left>t.width+t.left&&(n.left=e.left-(e.width+e.left-(t.width+t.left))),e.height+e.top>t.height+t.top&&(n.top=e.top-(e.height+e.top-(t.height+t.top))),e.left<t.left&&(n.left=t.left),e.top<t.top&&(n.top=t.top)),n},hn=(e,t)=>e.left<=t.left?e.left+e.width>=t.left&&(T(t.top,e.top,e.top+e.height)||T(t.top+t.height,e.top,e.top+e.height)||t.top>=e.top&&t.height>=e.height):t.left+t.width>=e.left&&(T(e.top,t.top,t.top+t.height)||T(e.top+e.height,t.top,t.top+t.height)||e.top>=t.top&&e.height>=t.height),wn=e=>e?!!(e.tabIndex>=0||e instanceof HTMLAnchorElement&&e.href||e instanceof HTMLButtonElement&&!e.disabled||e instanceof HTMLInputElement&&!e.disabled||e instanceof HTMLTextAreaElement&&!e.disabled):!1;let M={};const En=(e,t=!1)=>(!t&&e in M||(M[e]=new Promise((n,i)=>{let o=document.createElement("link");o.rel="stylesheet",o.href=e,o.onload=()=>{n()},o.onerror=()=>{i()},document.head.append(o)})),M[e]),Tn=(e,t=!1)=>(!t&&e in M||(M[e]=new Promise((n,i)=>{let o=document.createElement("script");o.src=e,o.onload=()=>{n()},o.onerror=()=>{i()},document.head.append(o)})),M[e]),vn=e=>{let t=e.style.visibility,n=e.style.display,i,o;return e.style.visibility="hidden",e.style.display="block",i=e.clientWidth,o=e.clientHeight,e.style.visibility=t,e.style.display=n,{width:i,height:o}},Me=(e,t="",n=document)=>{if(t&&n.querySelector(`#${t}`))return n.querySelector(`#${t}`);let i=n.createElement("style");return n.head.appendChild(i),i.innerHTML=e,t&&(i.id=t),i},bn=(e,t)=>T(e.top,t.top,t.top+t.height)&&T(e.left,t.left,t.left+t.width)&&T(e.top+e.height,t.top,t.top+t.height)&&T(e.left+e.width,t.left,t.left+t.width),yn=e=>Math.pow(10,-e),Mn=(e,t)=>{try{return new URL(e,t).href}catch{return e}},An=(e,t=null)=>{const n=document.createElement("template");e=e.trim(),n.innerHTML=e;let i=[];return t?Array.from(n.content.children).forEach(o=>{i.push(t.appendChild(o))}):i=Array.from(n.content.children),i.length===1?i[0]:i},Ae=(e,t=!1)=>{if(!e)throw new Error("el is null");const n=e.getBoundingClientRect();if(t&&!n.height){const i=e.style.visibility,o=e.style.display;e.style.visibility="hidden",e.style.display="block";const a=Ae(e);return e.style.visibility=i,e.style.display=o,a}return{top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height}},Sn=e=>{let t={};for(let n in e){const i=e[n];i!=null&&(t[`--${n}`]=`${i}`)}return t};function _n(e,t=null){const n=v(e);t=v(t||n);const i=n.style.position,o=n.style.left,a=n.style.top,u=n.style.transform;let c=!1,l=0,s=0;const p=w=>{c&&(n.style.position="fixed",n.style.transform="none",n.style.left=`${w.clientX-l}px`,n.style.top=`${w.clientY-s}px`)},S=()=>{c=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",S)},h=w=>{if(w.button!==0)return;c=!0;const P=n.getBoundingClientRect();l=w.clientX-P.left,s=w.clientY-P.top,document.addEventListener("mousemove",p),document.addEventListener("mouseup",S),w.preventDefault()};return t.addEventListener("mousedown",h),()=>{S(),t.removeEventListener("mousedown",h),n.style.position=i,n.style.left=o,n.style.top=a,n.style.transform=u}}const Cn=e=>e.replace(/[\\/:*?"<>|]/g,"_").replace(/[\0-\x1F]/g,"_").replace(/\s+/g," ").replace(/^\.+/,"").replace(/\.+$/,"").trim(),V=e=>new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=o=>n(o),i.readAsDataURL(e)}),Se={},J=(e,t=null)=>t!==null?(Se[e]=t,null):Se[e]||null,Nn=async e=>{if(!e)return null;if(typeof e=="string"&&e.startsWith("data:"))return e;try{if(typeof e=="string"&&we(e)){const t=await fetch(e);if(!t.ok)throw new Error(`Fetch failed: ${t.status}`);const n=await t.blob();return await V(n)}return e instanceof Blob?await V(e):null}catch(t){return console.warn("file2Base64DataURL failed:",t),null}},Dn=(e,t)=>{const n=document.createElement("a");n.rel="noopener noreferrer",n.href=e,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)},X=["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","CANVAS","DD","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","NOSCRIPT","OL","P","PRE","SECTION","TABLE","TFOOT","UL","VIDEO"],On=["A","ABBR","ACRONYM","B","BDO","BIG","BUTTON","CITE","CODE","DFN","EM","I","KBD","LABEL","MAP","OBJECT","OUTPUT","Q","S","SAMP","SCRIPT","SELECT","SMALL","SPAN","STRONG","SUB","SUP","TEXTAREA","TIME","TT","U","VAR"].concat(...X),Rn=["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"],_e=["STYLE","COMMENT","SELECT","OPTION","SCRIPT","TITLE","HEAD","BUTTON","META","LINK","PARAM","SOURCE"],In=(e,t={})=>{t.keepLineBreak=t.keepLineBreak!==!1;const n=t.imgReplacer!==void 0?t.imgReplacer:"[Image]";e=e.replace(/<img[^>]*src=["']([^"']*)["'][^>]*alt=["']([^"']*)["'][^>]*>/gi,function(a,u,c){return typeof n=="function"?n(u,c):n}),e=e.replace(/<img[^>]*alt=["']([^"']*)["'][^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,u,c){return typeof n=="function"?n(c,u):n}),e=e.replace(/<img[^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,u){return typeof n=="function"?n(u,""):n});const i=t.videoReplacer!==void 0?t.videoReplacer:"[Video]";return e=e.replace(/<video[^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,u){return typeof i=="function"?i(u,""):i}),e=e.replace(/<video[^>]*>[\s\S]*?<source[^>]*src=["']([^"']*)["'][^>]*>[\s\S]*?<\/video>/gi,function(a,u){return typeof i=="function"?i(u,""):i}),_e.forEach(a=>{e=e.replace(new RegExp(`<${a}[^>]*>([\\s\\S]*?)<\\/${a}>`,"gi"),""),e=e.replace(new RegExp(`<${a}[^>]*>`,"gi"),"")}),e=e.replace(/[\r|\n]/g,""),e=e.replace(/<(\w+)([^>]*)>/g,function(a,u,c){return X.includes(u.toUpperCase())?`
2
2
  `:""}),e=e.replace(/<\/(\w+)([^>]*)>/g,function(a,u,c){return""}),e=e.replace(/<[^>]+>/g,""),[[/&nbsp;/gi," "],[/&lt;/gi,"<"],[/&gt;/gi,">"],[/&quot;/gi,'"'],[/&apos;/gi,"'"]].forEach(([a,u])=>{e=e.replace(a,u)}),e=e.replace(/&#(\d+);/g,function(a,u){return String.fromCharCode(parseInt(u))}),e=e.replace(/&amp;/gi,"&"),t.keepLineBreak||(e=e.replace(/\n+/g," ")),e=e.trim(),e},xn=e=>Ce(e,0,!1).replace(/\n/g,"<br/>"),Ln=e=>window.CSS&&CSS.escape?CSS.escape(e):e.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g,"\\$&"),kn=e=>{let t=e.split(";");return t.pop(),t.map(n=>String.fromCharCode(n[2]==="x"?parseInt(n.slice(3),16):parseInt(n.slice(2)))).join("")};let O;const Hn=e=>(O||(O=document.createElement("div")),e=e.replace(/<script[^>]*>([\S\s]*?)<\/script>/gim,""),e=e.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gim,""),O.innerHTML=e,e=O.textContent||"",O.textContent="",e),Pn=e=>{let t="";for(let n in e){let i=e[n]===null?"":e[n];t+=`<input type="hidden" name="${Q(n)}" value="${Q(i)}"/>`}return t},Ce=(e,t=2,n=!0)=>{let i=String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;");return n&&(i=i.replace(/[\r\n]/g,"<br/>")),t&&(i=i.replace(/\t/g,"&nbsp;".repeat(t))),i=i.replace(/\s/g,"&nbsp;"),i},Fn=e=>String(e).replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/<br.*>/,`
3
3
  `),Un=e=>{if(!e)return"";let t=e;return t=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),t=t.replace(/^###### (.*$)/gim,"<h6>$1</h6>"),t=t.replace(/^##### (.*$)/gim,"<h5>$1</h5>"),t=t.replace(/^#### (.*$)/gim,"<h4>$1</h4>"),t=t.replace(/^### (.*$)/gim,"<h3>$1</h3>"),t=t.replace(/^## (.*$)/gim,"<h2>$1</h2>"),t=t.replace(/^# (.*$)/gim,"<h1>$1</h1>"),t=t.replace(/\*\*(.*?)\*\*/gim,"<strong>$1</strong>"),t=t.replace(/\*(.*?)\*/gim,"<em>$1</em>"),t=t.replace(/`(.*?)`/gim,"<code>$1</code>"),t=t.replace(/!\[(.*?)\]\((.*?)\)/gim,'<img src="$2" alt="$1" />'),t=t.replace(/\[(.*?)\]\((.*?)\)/gim,'<a href="$2" target="_blank">$1</a>'),t=t.replace(/((\|.*\|\n)+)/g,n=>{const i=n.trim().split(`
4
4
  `);if(i.length<2)return n;let o="<table>";return i.forEach((a,u)=>{const c=a.split("|").slice(1,-1);if(/^\s*-+\s*$/.test(c[0]))return;const l=u===0?"th":"td";o+="<tr>",c.forEach(s=>{o+=`<${l}>${s.trim()}</${l}>`}),o+="</tr>"}),o+="</table>",o}),t=t.replace(/^\s*-\s+(.*)/gim,"<li>$1</li>"),t=t.replace(/(<li>.*<\/li>)/gims,"<ul>$1</ul>"),t=t.replace(/\n/g,"<br />"),t.trim()},Q=(e,t="")=>(t=t?"&#13;":`