minutool 1.0.26 → 1.0.27

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=0;i<e.length;i++)n.push(e[i][t]);return n},Xe=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n]===t)return n;return null},Qe=(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})},Ze=(e,t,n)=>{if(!e||!e.length)return e;let i={};if(e.forEach(a=>{let s=a[t];i[s]||(i[s]=[]),i[s].push(a)}),!n)return i;let o={};for(let a in i)o[a]=i[a][0];return o},et=e=>Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{}),tt=(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 s=1;s<=o;s++)i.push(e.splice(0,t));return a&&i.push(e.splice(0,a)),i},nt=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,it=()=>window.innerWidth>window.innerHeight,ot=()=>window.innerHeight>window.innerWidth,ae=e=>{const t=e;if(e.requestFullscreen)return e.requestFullscreen();if(t.webkitRequestFullScreen)return t.webkitRequestFullScreen();throw t.mozRequestFullScreen&&t.mozRequestFullScreen(),t.msRequestFullScreen&&t.msRequestFullScreen(),"Browser no allow full screen"},ce=()=>document.exitFullscreen(),rt=e=>new Promise((t,n)=>{le()?ce().then(t).catch(n):ae(e).then(t).catch(n)}),le=()=>!!document.fullscreenElement,at=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]},ct=()=>navigator.userAgent.toLowerCase().indexOf("firefox")>-1,lt=(1+Math.sqrt(5))/2-1,F=96,st=(e,t=F)=>e/25.4*t,ut=e=>Math.round(e*56.6929),pt=e=>e*2.83464566929,mt=e=>e/2.83464566929,dt=(e,t=F)=>25.4*e/t,ft=(e,t,n)=>Math.min(Math.max(e,t),n),v=(e,t,n,i=!0)=>i?e>=t&&e<=n:e>t&&e<n,gt=(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),ht=(...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},Et=e=>(e=Math.abs(Number(e)),e===0?1:Math.floor(Math.log10(e))+1);function ue(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 s=n.dpi||re;if(a===t)return o;const c={mm:1,cm:10,in:25.4,px:25.4/s,pt:25.4/72,pc:25.4/6},l={mm:1,cm:1/10,in:1/25.4,px:s/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]},pe=(e,t=0)=>_(e)?parseFloat(String(e)):t,wt=e=>(e+"").replace(/\\(.?)/g,function(t,n){switch(n){case"\\":return"\\";case"0":return"\0";case"":return"";default:return n}}),Tt=(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},vt=(e,t)=>{const n=Object.keys(t),i=Object.values(t);return new Function(...n,`return \`${e}\`;`)(...i)};function bt(e){return e.replace(/[-_](.)/g,(t,n)=>n.toUpperCase())}function yt(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function Mt(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},At=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},St="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890",de=(e=6,t=St)=>{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},_t=(e=1,t=8)=>{let n=[];const i="bcdfghjklmnpqrstvwxyz",o="aeiou";for(;e-- >0;){let a="";for(let s=0;s<t;s=s+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},Ct=(e,t=!1)=>{let n=[];return e.replace(/[-_\s+]/g," ").split(" ").forEach((i,o)=>{n.push(o===0&&!t?i:ue(i))}),n.join("")},$=0,Y=1,fe=2,Nt=(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()},Dt=(e,t)=>{let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n},Ot=e=>/[\u4e00-\u9fa5]/.test(e),Rt=(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)},y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",It=e=>{let t="",n,i,o,a,s,c,l,u=0;for(e=e.replace(/\+\+[++^A-Za-z0-9+/=]/g,"");u<e.length;)a=y.indexOf(e.charAt(u++)),s=y.indexOf(e.charAt(u++)),c=y.indexOf(e.charAt(u++)),l=y.indexOf(e.charAt(u++)),n=a<<2|s>>4,i=(s&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},Lt=e=>B(e).replace("+","-").replace("/","_"),xt=e=>{let t="",n,i,o,a,s,c,l,u=0;for(e=B(e);u<e.length;)n=e.charCodeAt(u++),i=e.charCodeAt(u++),o=e.charCodeAt(u++),a=n>>2,s=(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+y.charAt(a)+y.charAt(s)+y.charAt(c)+y.charAt(l);return t},ge=async e=>await kt(e),kt=e=>new Promise((t,n)=>{const i=new FileReader;i.readAsDataURL(e),i.onload=()=>t(i.result),i.onerror=o=>n(o)}),Ht=(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 s=e+"="+(t||"")+a+"; path="+i;o&&(s+="; domain="+o),document.cookie=s},Pt=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},L=(e,t="/",n)=>{let i=e+"=; Path="+t+"; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";n&&(i+=" Domain="+n+";"),document.cookie=i},Ft=(e,t)=>{const n=(t||(location==null?void 0:location.hostname)).split(".");for(;n.length>1;)L(e,"/",n.join(".")),L(e,"/","."+n.join(".")),n.shift();L(e)};let Ut=0;const he=(e="")=>"guid_"+(e||de(6))+ ++Ut,Bt=(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)}},$t=(e,t)=>{let n,i,o=0,a=!1;return function(){if(a)return;let s=+new Date;n=this,i=arguments;let c=t-(s-o);c<=0?(e.apply(n,i),o=s):(a=!0,setTimeout(()=>{e.apply(n,i),a=!1,o=s},c))}},Yt=(e,t)=>{let n;return function(){let i=this,o=arguments;clearTimeout(n),n=setTimeout(function(){e.apply(i,o)},t)}},jt=e=>e&&typeof e=="object"&&e.then&&typeof e.then=="function",zt=e=>{let t=!1;try{JSON.parse(e),t=!0}catch{}return t},Gt=e=>e&&typeof e=="object"&&!Array.isArray(e),Kt=e=>e?Object.prototype.toString.call(e)==="[object Function]"||typeof e=="function"||e instanceof Function:!1,Ee=e=>typeof e!="string"||e.trim()===""?!1:/^(https?:\/\/|\/\/|\/|\.\.?\/*)/i.test(e),qt=e=>{let t=!1;try{JSON.parse(e),t=!0}catch{}return t},Wt=()=>{let e=new Error().stack;console.log(e)},j=new EventTarget,Vt=new Map,z=new Map;let Jt=0;const Xt="__MINUTOOL_SYM_EVENT__";function G(e){if(!z.has(e)){const t=`${Xt}${++Jt}`;z.set(e,t),Vt.set(t,e)}return z.get(e)}const Qt=(e,t)=>{const n=e.map(i=>we(i,t));return()=>n.forEach(i=>i())},we=(e,t)=>(j.addEventListener(typeof e=="symbol"?G(e):e,t),()=>Te(e,t)),Te=(e,t)=>{j.removeEventListener(typeof e=="symbol"?G(e):e,t)},Zt=(e,t)=>{j.dispatchEvent(new CustomEvent(typeof e=="symbol"?G(e):e,{detail:t}))},en=e=>{if(document.readyState==="complete"||document.readyState==="interactive")e();else{const t=()=>{e(),document.removeEventListener("DOMContentLoaded",t)};document.addEventListener("DOMContentLoaded",t)}},tn=(e,t,n,i)=>M(e,n,a=>{var l;const s=a.target,c=(l=s==null?void 0:s.closest)==null?void 0:l.call(s,t);c&&i(a,c)}),nn=(e,t)=>M(e,"click",t),on=(e,t)=>M(e,"keyup",t),rn=(e,t)=>M(e,"keydown",t),an=(e,t)=>M(e,"dblclick",t),M=(e,t,n)=>{const i=a=>{n(a)},o=typeof e=="string"?b(e):e;if(!o)throw new Error(`EventTarget not found for selector: ${e}`);return o.addEventListener(t,i),()=>{o.removeEventListener(t,i)}},cn=(e,t,n=300)=>{let i=!1,o=null,a=null,s=null;const c=w=>{let E=w.target.value;a!==E&&(a=E,t(E,w))},l=w=>{const m=w;m.isComposing||i||(s=m,o&&clearTimeout(o),o=window.setTimeout(()=>{o=null,!(i||!s)&&(c(s),s=null)},n))},u=()=>{i=!0},p=()=>{i=!1};return e.addEventListener("input",l),e.addEventListener("compositionstart",u),e.addEventListener("compositionend",p),()=>{e.removeEventListener("input",l),e.removeEventListener("compositionstart",u),e.removeEventListener("compositionend",p),o&&(clearTimeout(o),o=null),s=null}},ln=(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())},sn=e=>{const t=b(e);t&&(t.style.display="none")},un=e=>{const t=b(e);t&&(t.style.display="")},pn=e=>{let t=b(e);return t&&t.parentNode&&t.parentNode.removeChild(t)},K="disabled",ve=(e,t="")=>q(e,t,!1),be=(e,t="")=>q(e,t,!0),q=(e,t="",n=null)=>{let i=b(e),o=n===null?!i.classList.contains(K):!n;o&&Me(`.${K} {pointer-event:none !important;}`,"__element_lock_style__"),i.classList.toggle(K,o),i[o?"setAttribute":"removeAttribute"]("disabled","disabled"),i[o?"setAttribute":"removeAttribute"]("data-disabled","disabled"),t&&i.classList.toggle(t,o)},mn=(e,t,n)=>{e=b(e);let i=!1;const o=[];return o.push(M(e,"mouseenter",()=>{i||(i=!0,t&&t())})),o.push(M(e,"mouseleave",()=>{i&&(i=!1,n&&n())})),()=>{o.forEach(a=>a())}},dn=(e,t)=>{ve(e),t(()=>{be(e)})},fn=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},b=(e,t=document)=>typeof e=="string"?t.querySelector(e):e,gn=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},hn=(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,s=new MutationObserver(()=>{if(a)return;let c=i-(Date.now()-o);c>0?(a=!0,setTimeout(()=>{a=!1,o=Date.now(),n(s)},c)):(o=Date.now(),n(s))});s.observe(e,t)},En=(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},wn=(e,t)=>e.left<=t.left?e.left+e.width>=t.left&&(v(t.top,e.top,e.top+e.height)||v(t.top+t.height,e.top,e.top+e.height)||t.top>=e.top&&t.height>=e.height):t.left+t.width>=e.left&&(v(e.top,t.top,t.top+t.height)||v(e.top+e.height,t.top,t.top+t.height)||e.top>=t.top&&e.height>=t.height),Tn=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 A={};const vn=(e,t=!1)=>(!t&&e in A||(A[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)})),A[e]),bn=(e,t=!1)=>(!t&&e in A||(A[e]=new Promise((n,i)=>{let o=document.createElement("script");o.src=e,o.onload=()=>{n()},o.onerror=()=>{i()},document.head.append(o)})),A[e]),yn=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},Mn=(e,t)=>v(e.top,t.top,t.top+t.height)&&v(e.left,t.left,t.left+t.width)&&v(e.top+e.height,t.top,t.top+t.height)&&v(e.left+e.width,t.left,t.left+t.width),An=e=>Math.pow(10,-e),Sn=(e,t)=>{try{return new URL(e,t).href}catch{return e}},_n=(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}},Cn=e=>{let t={};for(let n in e){const i=e[n];i!=null&&(t[`--${n}`]=`${i}`)}return t};function Nn(e,t=null){const n=b(e);t=b(t||n);const i=n.style.position,o=n.style.left,a=n.style.top,s=n.style.transform;let c=!1,l=0,u=0;const p=E=>{c&&(n.style.position="fixed",n.style.transform="none",n.style.left=`${E.clientX-l}px`,n.style.top=`${E.clientY-u}px`)},w=()=>{c=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",w)},m=E=>{if(E.button!==0)return;c=!0;const P=n.getBoundingClientRect();l=E.clientX-P.left,u=E.clientY-P.top,document.addEventListener("mousemove",p),document.addEventListener("mouseup",w),E.preventDefault()};return t.addEventListener("mousedown",m),()=>{w(),t.removeEventListener("mousedown",m),n.style.position=i,n.style.left=o,n.style.top=a,n.style.transform=s}}const Dn=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,On=async e=>{if(!e)return null;if(typeof e=="string"&&e.startsWith("data:"))return e;try{if(typeof e=="string"&&Ee(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}},Rn=(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"],In=["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),Ln=["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"],xn=(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,s,c){return typeof n=="function"?n(s,c):n}),e=e.replace(/<img[^>]*alt=["']([^"']*)["'][^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,s,c){return typeof n=="function"?n(c,s):n}),e=e.replace(/<img[^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,s){return typeof n=="function"?n(s,""):n});const i=t.videoReplacer!==void 0?t.videoReplacer:"[Video]";return e=e.replace(/<video[^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,s){return typeof i=="function"?i(s,""):i}),e=e.replace(/<video[^>]*>[\s\S]*?<source[^>]*src=["']([^"']*)["'][^>]*>[\s\S]*?<\/video>/gi,function(a,s){return typeof i=="function"?i(s,""):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,s,c){return X.includes(s.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=0;i<e.length;i++)n.push(e[i][t]);return n},Xe=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n]===t)return n;return null},Qe=(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})},Ze=(e,t,n)=>{if(!e||!e.length)return e;let i={};if(e.forEach(a=>{let s=a[t];i[s]||(i[s]=[]),i[s].push(a)}),!n)return i;let o={};for(let a in i)o[a]=i[a][0];return o},et=e=>Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{}),tt=(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 s=1;s<=o;s++)i.push(e.splice(0,t));return a&&i.push(e.splice(0,a)),i},nt=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,it=()=>window.innerWidth>window.innerHeight,ot=()=>window.innerHeight>window.innerWidth,ae=e=>{const t=e;if(e.requestFullscreen)return e.requestFullscreen();if(t.webkitRequestFullScreen)return t.webkitRequestFullScreen();throw t.mozRequestFullScreen&&t.mozRequestFullScreen(),t.msRequestFullScreen&&t.msRequestFullScreen(),"Browser no allow full screen"},ce=()=>document.exitFullscreen(),rt=e=>new Promise((t,n)=>{le()?ce().then(t).catch(n):ae(e).then(t).catch(n)}),le=()=>!!document.fullscreenElement,at=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]},ct=()=>navigator.userAgent.toLowerCase().indexOf("firefox")>-1,lt=(1+Math.sqrt(5))/2-1,F=96,st=(e,t=F)=>e/25.4*t,ut=e=>Math.round(e*56.6929),pt=e=>e*2.83464566929,mt=e=>e/2.83464566929,dt=(e,t=F)=>25.4*e/t,ft=(e,t,n)=>Math.min(Math.max(e,t),n),v=(e,t,n,i=!0)=>i?e>=t&&e<=n:e>t&&e<n,gt=(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),ht=(...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},Et=e=>(e=Math.abs(Number(e)),e===0?1:Math.floor(Math.log10(e))+1);function ue(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 s=n.dpi||re;if(a===t)return o;const c={mm:1,cm:10,in:25.4,px:25.4/s,pt:25.4/72,pc:25.4/6},l={mm:1,cm:1/10,in:1/25.4,px:s/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]},pe=(e,t=0)=>_(e)?parseFloat(String(e)):t,wt=e=>(e+"").replace(/\\(.?)/g,function(t,n){switch(n){case"\\":return"\\";case"0":return"\0";case"":return"";default:return n}}),Tt=(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},vt=(e,t)=>{const n=Object.keys(t),i=Object.values(t);return new Function(...n,`return \`${e}\`;`)(...i)};function bt(e){return e.replace(/[-_](.)/g,(t,n)=>n.toUpperCase())}function yt(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function Mt(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},At=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},St="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890",de=(e=6,t=St)=>{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},_t=(e=1,t=8)=>{let n=[];const i="bcdfghjklmnpqrstvwxyz",o="aeiou";for(;e-- >0;){let a="";for(let s=0;s<t;s=s+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},Ct=(e,t=!1)=>{let n=[];return e.replace(/[-_\s+]/g," ").split(" ").forEach((i,o)=>{n.push(o===0&&!t?i:ue(i))}),n.join("")},$=0,Y=1,fe=2,Nt=(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()},Dt=(e,t)=>{let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n},Ot=e=>/[\u4e00-\u9fa5]/.test(e),Rt=(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)},y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",It=e=>{let t="",n,i,o,a,s,c,l,u=0;for(e=e.replace(/\+\+[++^A-Za-z0-9+/=]/g,"");u<e.length;)a=y.indexOf(e.charAt(u++)),s=y.indexOf(e.charAt(u++)),c=y.indexOf(e.charAt(u++)),l=y.indexOf(e.charAt(u++)),n=a<<2|s>>4,i=(s&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},Lt=e=>B(e).replace("+","-").replace("/","_"),xt=e=>{let t="",n,i,o,a,s,c,l,u=0;for(e=B(e);u<e.length;)n=e.charCodeAt(u++),i=e.charCodeAt(u++),o=e.charCodeAt(u++),a=n>>2,s=(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+y.charAt(a)+y.charAt(s)+y.charAt(c)+y.charAt(l);return t},ge=async e=>await kt(e),kt=e=>new Promise((t,n)=>{const i=new FileReader;i.readAsDataURL(e),i.onload=()=>t(i.result),i.onerror=o=>n(o)}),Ht=(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 s=e+"="+(t||"")+a+"; path="+i;o&&(s+="; domain="+o),document.cookie=s},Pt=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},L=(e,t="/",n)=>{let i=e+"=; Path="+t+"; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";n&&(i+=" Domain="+n+";"),document.cookie=i},Ft=(e,t)=>{const n=(t||(location==null?void 0:location.hostname)).split(".");for(;n.length>1;)L(e,"/",n.join(".")),L(e,"/","."+n.join(".")),n.shift();L(e)};let Ut=0;const he=(e="")=>"guid_"+(e||de(6))+ ++Ut,Bt=(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)}},$t=(e,t)=>{let n,i,o=0,a=!1;return function(){if(a)return;let s=+new Date;n=this,i=arguments;let c=t-(s-o);c<=0?(e.apply(n,i),o=s):(a=!0,setTimeout(()=>{e.apply(n,i),a=!1,o=s},c))}},Yt=(e,t)=>{let n;return function(){let i=this,o=arguments;clearTimeout(n),n=setTimeout(function(){e.apply(i,o)},t)}},jt=e=>e&&typeof e=="object"&&e.then&&typeof e.then=="function",zt=e=>{let t=!1;try{JSON.parse(e),t=!0}catch{}return t},Gt=e=>e&&typeof e=="object"&&!Array.isArray(e),Kt=e=>e?Object.prototype.toString.call(e)==="[object Function]"||typeof e=="function"||e instanceof Function:!1,Ee=e=>typeof e!="string"||e.trim()===""?!1:/^(https?:\/\/|\/\/|\/|\.\.?\/*)/i.test(e),qt=e=>{let t=!1;try{JSON.parse(e),t=!0}catch{}return t},Wt=()=>{let e=new Error().stack;console.log(e)},j=new EventTarget,Vt=new Map,z=new Map;let Jt=0;const Xt="__MINUTOOL_SYM_EVENT__";function G(e){if(!z.has(e)){const t=`${Xt}${++Jt}`;z.set(e,t),Vt.set(t,e)}return z.get(e)}const Qt=(e,t)=>{const n=e.map(i=>we(i,t));return()=>n.forEach(i=>i())},we=(e,t)=>(j.addEventListener(typeof e=="symbol"?G(e):e,t),()=>Te(e,t)),Te=(e,t)=>{j.removeEventListener(typeof e=="symbol"?G(e):e,t)},Zt=(e,t)=>{j.dispatchEvent(new CustomEvent(typeof e=="symbol"?G(e):e,{detail:t}))},en=e=>{if(document.readyState==="complete"||document.readyState==="interactive")e();else{const t=()=>{e(),document.removeEventListener("DOMContentLoaded",t)};document.addEventListener("DOMContentLoaded",t)}},tn=(e,t,n,i)=>M(e,n,a=>{var l;const s=a.target,c=(l=s==null?void 0:s.closest)==null?void 0:l.call(s,t);c&&i(a,c)}),nn=(e,t)=>M(e,"click",t),on=(e,t)=>M(e,"keyup",t),rn=(e,t)=>M(e,"keydown",t),an=(e,t)=>M(e,"dblclick",t),M=(e,t,n,i)=>{const o=s=>{n(s)},a=typeof e=="string"?b(e):e;if(!a)throw new Error(`EventTarget not found for selector: ${e}`);return a.addEventListener(t,o,i),()=>{a.removeEventListener(t,o,i)}},cn=(e,t,n=50)=>{let i=!1,o=null,a=null,s=null;const c=w=>{let E=w.target.value;a!==E&&(a=E,t(E,w))},l=w=>{const m=w;m.isComposing||i||(s=m,o&&clearTimeout(o),o=window.setTimeout(()=>{o=null,!(i||!s)&&(c(s),s=null)},n))},u=()=>{i=!0},p=()=>{i=!1};return e.addEventListener("input",l),e.addEventListener("compositionstart",u),e.addEventListener("compositionend",p),()=>{e.removeEventListener("input",l),e.removeEventListener("compositionstart",u),e.removeEventListener("compositionend",p),o&&(clearTimeout(o),o=null),s=null}},ln=(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())},sn=e=>{const t=b(e);t&&(t.style.display="none")},un=e=>{const t=b(e);t&&(t.style.display="")},pn=e=>{let t=b(e);return t&&t.parentNode&&t.parentNode.removeChild(t)},K="disabled",ve=(e,t="")=>q(e,t,!1),be=(e,t="")=>q(e,t,!0),q=(e,t="",n=null)=>{let i=b(e),o=n===null?!i.classList.contains(K):!n;o&&Me(`.${K} {pointer-event:none !important;}`,"__element_lock_style__"),i.classList.toggle(K,o),i[o?"setAttribute":"removeAttribute"]("disabled","disabled"),i[o?"setAttribute":"removeAttribute"]("data-disabled","disabled"),t&&i.classList.toggle(t,o)},mn=(e,t,n)=>{e=b(e);let i=!1;const o=[];return o.push(M(e,"mouseenter",()=>{i||(i=!0,t&&t())})),o.push(M(e,"mouseleave",()=>{i&&(i=!1,n&&n())})),()=>{o.forEach(a=>a())}},dn=(e,t)=>{ve(e),t(()=>{be(e)})},fn=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},b=(e,t=document)=>typeof e=="string"?t.querySelector(e):e,gn=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},hn=(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,s=new MutationObserver(()=>{if(a)return;let c=i-(Date.now()-o);c>0?(a=!0,setTimeout(()=>{a=!1,o=Date.now(),n(s)},c)):(o=Date.now(),n(s))});s.observe(e,t)},En=(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},wn=(e,t)=>e.left<=t.left?e.left+e.width>=t.left&&(v(t.top,e.top,e.top+e.height)||v(t.top+t.height,e.top,e.top+e.height)||t.top>=e.top&&t.height>=e.height):t.left+t.width>=e.left&&(v(e.top,t.top,t.top+t.height)||v(e.top+e.height,t.top,t.top+t.height)||e.top>=t.top&&e.height>=t.height),Tn=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 A={};const vn=(e,t=!1)=>(!t&&e in A||(A[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)})),A[e]),bn=(e,t=!1)=>(!t&&e in A||(A[e]=new Promise((n,i)=>{let o=document.createElement("script");o.src=e,o.onload=()=>{n()},o.onerror=()=>{i()},document.head.append(o)})),A[e]),yn=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},Mn=(e,t)=>v(e.top,t.top,t.top+t.height)&&v(e.left,t.left,t.left+t.width)&&v(e.top+e.height,t.top,t.top+t.height)&&v(e.left+e.width,t.left,t.left+t.width),An=e=>Math.pow(10,-e),Sn=(e,t)=>{try{return new URL(e,t).href}catch{return e}},_n=(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}},Cn=e=>{let t={};for(let n in e){const i=e[n];i!=null&&(t[`--${n}`]=`${i}`)}return t};function Nn(e,t=null){const n=b(e);t=b(t||n);const i=n.style.position,o=n.style.left,a=n.style.top,s=n.style.transform;let c=!1,l=0,u=0;const p=E=>{c&&(n.style.position="fixed",n.style.transform="none",n.style.left=`${E.clientX-l}px`,n.style.top=`${E.clientY-u}px`)},w=()=>{c=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",w)},m=E=>{if(E.button!==0)return;c=!0;const P=n.getBoundingClientRect();l=E.clientX-P.left,u=E.clientY-P.top,document.addEventListener("mousemove",p),document.addEventListener("mouseup",w),E.preventDefault()};return t.addEventListener("mousedown",m),()=>{w(),t.removeEventListener("mousedown",m),n.style.position=i,n.style.left=o,n.style.top=a,n.style.transform=s}}const Dn=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,On=async e=>{if(!e)return null;if(typeof e=="string"&&e.startsWith("data:"))return e;try{if(typeof e=="string"&&Ee(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}},Rn=(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"],In=["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),Ln=["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"],xn=(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,s,c){return typeof n=="function"?n(s,c):n}),e=e.replace(/<img[^>]*alt=["']([^"']*)["'][^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,s,c){return typeof n=="function"?n(c,s):n}),e=e.replace(/<img[^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,s){return typeof n=="function"?n(s,""):n});const i=t.videoReplacer!==void 0?t.videoReplacer:"[Video]";return e=e.replace(/<video[^>]*src=["']([^"']*)["'][^>]*>/gi,function(a,s){return typeof i=="function"?i(s,""):i}),e=e.replace(/<video[^>]*>[\s\S]*?<source[^>]*src=["']([^"']*)["'][^>]*>[\s\S]*?<\/video>/gi,function(a,s){return typeof i=="function"?i(s,""):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,s,c){return X.includes(s.toUpperCase())?`
2
2
  `:""}),e=e.replace(/<\/(\w+)([^>]*)>/g,function(a,s,c){return""}),e=e.replace(/<[^>]+>/g,""),[[/&nbsp;/gi," "],[/&lt;/gi,"<"],[/&gt;/gi,">"],[/&quot;/gi,'"'],[/&apos;/gi,"'"]].forEach(([a,s])=>{e=e.replace(a,s)}),e=e.replace(/&#(\d+);/g,function(a,s){return String.fromCharCode(parseInt(s))}),e=e.replace(/&amp;/gi,"&"),t.keepLineBreak||(e=e.replace(/\n+/g," ")),e=e.trim(),e},kn=e=>Ce(e,0,!1).replace(/\n/g,"<br/>"),Hn=e=>window.CSS&&CSS.escape?CSS.escape(e):e.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g,"\\$&"),Pn=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 Fn=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),Un=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},Bn=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
  `),$n=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,s)=>{const c=a.split("|").slice(1,-1);if(/^\s*-+\s*$/.test(c[0]))return;const l=s===0?"th":"td";o+="<tr>",c.forEach(u=>{o+=`<${l}>${u.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;":`