claude-web/node_modules/@primeuix/utils/dist/dom/index.mjs

14 lines
18 KiB
JavaScript

function R(t,e){return t?t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className):!1}function W(t,e){if(t&&e){let o=n=>{R(t,n)||(t.classList?t.classList.add(n):t.className+=" "+n)};[e].flat().filter(Boolean).forEach(n=>n.split(" ").forEach(o))}}function F(){return window.innerWidth-document.documentElement.offsetWidth}function st(t){typeof t=="string"?W(document.body,t||"p-overflow-hidden"):(t!=null&&t.variableName&&document.body.style.setProperty(t.variableName,F()+"px"),W(document.body,(t==null?void 0:t.className)||"p-overflow-hidden"))}function B(t){if(t){let e=document.createElement("a");if(e.download!==void 0){let{name:o,src:n}=t;return e.setAttribute("href",n),e.setAttribute("download",o),e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e),!0}}return!1}function at(t,e){let o=new Blob([t],{type:"application/csv;charset=utf-8;"});window.navigator.msSaveOrOpenBlob?navigator.msSaveOrOpenBlob(o,e+".csv"):B({name:e+".csv",src:URL.createObjectURL(o)})||(t="data:text/csv;charset=utf-8,"+t,window.open(encodeURI(t)))}function P(t,e){if(t&&e){let o=n=>{t.classList?t.classList.remove(n):t.className=t.className.replace(new RegExp("(^|\\b)"+n.split(" ").join("|")+"(\\b|$)","gi")," ")};[e].flat().filter(Boolean).forEach(n=>n.split(" ").forEach(o))}}function dt(t){typeof t=="string"?P(document.body,t||"p-overflow-hidden"):(t!=null&&t.variableName&&document.body.style.removeProperty(t.variableName),P(document.body,(t==null?void 0:t.className)||"p-overflow-hidden"))}function x(t){for(let e of document==null?void 0:document.styleSheets)try{for(let o of e==null?void 0:e.cssRules)for(let n of o==null?void 0:o.style)if(t.test(n))return{name:n,value:o.style.getPropertyValue(n).trim()}}catch(o){}return null}function w(t){let e={width:0,height:0};if(t){let[o,n]=[t.style.visibility,t.style.display],r=t.getBoundingClientRect();t.style.visibility="hidden",t.style.display="block",e.width=r.width||t.offsetWidth,e.height=r.height||t.offsetHeight,t.style.display=n,t.style.visibility=o}return e}function h(){let t=window,e=document,o=e.documentElement,n=e.getElementsByTagName("body")[0],r=t.innerWidth||o.clientWidth||n.clientWidth,i=t.innerHeight||o.clientHeight||n.clientHeight;return{width:r,height:i}}function E(t){return t?Math.abs(t.scrollLeft):0}function k(){let t=document.documentElement;return(window.pageXOffset||E(t))-(t.clientLeft||0)}function $(){let t=document.documentElement;return(window.pageYOffset||t.scrollTop)-(t.clientTop||0)}function V(t){return t?getComputedStyle(t).direction==="rtl":!1}function D(t,e,o=!0){var n,r,i,l;if(t){let d=t.offsetParent?{width:t.offsetWidth,height:t.offsetHeight}:w(t),s=d.height,a=d.width,u=e.offsetHeight,p=e.offsetWidth,f=e.getBoundingClientRect(),g=$(),it=k(),lt=h(),L,N,ot="top";f.top+u+s>lt.height?(L=f.top+g-s,ot="bottom",L<0&&(L=g)):L=u+f.top+g,f.left+a>lt.width?N=Math.max(0,f.left+it+p-a):N=f.left+it,V(t)?t.style.insetInlineEnd=N+"px":t.style.insetInlineStart=N+"px",t.style.top=L+"px",t.style.transformOrigin=ot,o&&(t.style.marginTop=ot==="bottom"?`calc(${(r=(n=x(/-anchor-gutter$/))==null?void 0:n.value)!=null?r:"2px"} * -1)`:(l=(i=x(/-anchor-gutter$/))==null?void 0:i.value)!=null?l:"")}}function S(t,e){t&&(typeof e=="string"?t.style.cssText=e:Object.entries(e||{}).forEach(([o,n])=>t.style[o]=n))}function v(t,e){if(t instanceof HTMLElement){let o=t.offsetWidth;if(e){let n=getComputedStyle(t);o+=parseFloat(n.marginLeft)+parseFloat(n.marginRight)}return o}return 0}function I(t,e,o=!0,n=void 0){var r;if(t){let i=t.offsetParent?{width:t.offsetWidth,height:t.offsetHeight}:w(t),l=e.offsetHeight,d=e.getBoundingClientRect(),s=h(),a,u,p=n!=null?n:"top";if(!n&&d.top+l+i.height>s.height?(a=-1*i.height,p="bottom",d.top+a<0&&(a=-1*d.top)):a=l,i.width>s.width?u=d.left*-1:d.left+i.width>s.width?u=(d.left+i.width-s.width)*-1:u=0,t.style.top=a+"px",t.style.insetInlineStart=u+"px",t.style.transformOrigin=p,o){let f=(r=x(/-anchor-gutter$/))==null?void 0:r.value;t.style.marginTop=p==="bottom"?`calc(${f!=null?f:"2px"} * -1)`:f!=null?f:""}}}function ft(t,e,o,n=!0){t&&e&&(o==="self"?I(t,e):(n&&(t.style.minWidth=v(e)+"px"),D(t,e)))}function y(t){if(t){let e=t.parentNode;return e&&e instanceof ShadowRoot&&e.host&&(e=e.host),e}return null}function T(t){return!!(t!==null&&typeof t!="undefined"&&t.nodeName&&y(t))}function c(t){return typeof Element!="undefined"?t instanceof Element:t!==null&&typeof t=="object"&&t.nodeType===1&&typeof t.nodeName=="string"}function H(t){let e=t;return t&&typeof t=="object"&&(Object.hasOwn(t,"current")?e=t.current:Object.hasOwn(t,"el")&&(Object.hasOwn(t.el,"nativeElement")?e=t.el.nativeElement:e=t.el)),c(e)?e:void 0}function j(t,e){var o,n,r;if(t)switch(t){case"document":return document;case"window":return window;case"body":return document.body;case"@next":return e==null?void 0:e.nextElementSibling;case"@prev":return e==null?void 0:e.previousElementSibling;case"@first":return e==null?void 0:e.firstElementChild;case"@last":return e==null?void 0:e.lastElementChild;case"@child":return(o=e==null?void 0:e.children)==null?void 0:o[0];case"@parent":return e==null?void 0:e.parentElement;case"@grandparent":return(n=e==null?void 0:e.parentElement)==null?void 0:n.parentElement;default:{if(typeof t=="string"){let s=t.match(/^@child\[(\d+)]/);return s?((r=e==null?void 0:e.children)==null?void 0:r[parseInt(s[1],10)])||null:document.querySelector(t)||null}let l=(s=>typeof s=="function"&&"call"in s&&"apply"in s)(t)?t():t,d=H(l);return T(d)?d:(l==null?void 0:l.nodeType)===9?l:void 0}}}function ut(t,e){let o=j(t,e);if(o)o.appendChild(e);else throw new Error("Cannot append "+e+" to "+t)}var nt;function ct(t){if(t){let e=getComputedStyle(t);return t.offsetHeight-t.clientHeight-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth)}else{if(nt!=null)return nt;let e=document.createElement("div");S(e,{width:"100px",height:"100px",overflow:"scroll",position:"absolute",top:"-9999px"}),document.body.appendChild(e);let o=e.offsetHeight-e.clientHeight;return document.body.removeChild(e),nt=o,o}}var rt;function O(t){if(t){let e=getComputedStyle(t);return t.offsetWidth-t.clientWidth-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)}else{if(rt!=null)return rt;let e=document.createElement("div");S(e,{width:"100px",height:"100px",overflow:"scroll",position:"absolute",top:"-9999px"}),document.body.appendChild(e);let o=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),rt=o,o}}function pt(){if(window.getSelection){let t=window.getSelection()||{};t.empty?t.empty():t.removeAllRanges&&t.rangeCount>0&&t.getRangeAt(0).getClientRects().length>0&&t.removeAllRanges()}}function A(t,e={}){if(c(t)){let o=(n,r)=>{var l,d;let i=(l=t==null?void 0:t.$attrs)!=null&&l[n]?[(d=t==null?void 0:t.$attrs)==null?void 0:d[n]]:[];return[r].flat().reduce((s,a)=>{if(a!=null){let u=typeof a;if(u==="string"||u==="number")s.push(a);else if(u==="object"){let p=Array.isArray(a)?o(n,a):Object.entries(a).map(([f,g])=>n==="style"&&(g||g===0)?`${f.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}:${g}`:g?f:void 0);s=p.length?s.concat(p.filter(f=>!!f)):s}}return s},i)};Object.entries(e).forEach(([n,r])=>{if(r!=null){let i=n.match(/^on(.+)/);i?t.addEventListener(i[1].toLowerCase(),r):n==="p-bind"||n==="pBind"?A(t,r):(r=n==="class"?[...new Set(o("class",r))].join(" ").trim():n==="style"?o("style",r).join(";").trim():r,(t.$attrs=t.$attrs||{})&&(t.$attrs[n]=r),t.setAttribute(n,r))}})}}function U(t,e={},...o){if(t){let n=document.createElement(t);return A(n,e),n.append(...o),n}}function q(t,e={}){return t?`<style${Object.entries(e).reduce((o,[n,r])=>o+` ${n}="${r}"`,"")}>${t}</style>`:""}function mt(t,e={}){return q(t,e)}function X(t,e={},o){let n=U("style",e,t);return o==null||o.appendChild(n),n}function gt(t={},e){return X("",t,e||document.head)}function ht(t,e){if(t){t.style.opacity="0";let o=+new Date,n="0",r=function(){n=`${+t.style.opacity+(new Date().getTime()-o)/e}`,t.style.opacity=n,o=+new Date,+n<1&&("requestAnimationFrame"in window?requestAnimationFrame(r):setTimeout(r,16))};r()}}function yt(t,e){if(t){let o=1,n=50,r=n/e,i=setInterval(()=>{o-=r,o<=0&&(o=0,clearInterval(i)),t.style.opacity=o.toString()},n)}}function Y(t,e){return c(t)?Array.from(t.querySelectorAll(e)):[]}function z(t,e){return c(t)?t.matches(e)?t:t.querySelector(e):null}function bt(t,e){t&&document.activeElement!==t&&t.focus(e)}function Q(t,e){if(c(t)){let o=t.getAttribute(e);return isNaN(o)?o==="true"||o==="false"?o==="true":o:+o}}function Z(){let t=navigator.userAgent.toLowerCase(),e=/(chrome)[ ]([\w.]+)/.exec(t)||/(webkit)[ ]([\w.]+)/.exec(t)||/(opera)(?:.*version|)[ ]([\w.]+)/.exec(t)||/(msie) ([\w.]+)/.exec(t)||t.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(t)||[];return{browser:e[1]||"",version:e[2]||"0"}}var m=null;function xt(){if(!m){m={};let t=Z();t.browser&&(m[t.browser]=!0,m.version=t.version),m.chrome?m.webkit=!0:m.webkit&&(m.safari=!0)}return m}function Et(){return navigator.languages&&navigator.languages.length&&navigator.languages[0]||navigator.language||"en"}function wt(t,e,o){var n;return t&&e?o?(n=t==null?void 0:t.style)==null?void 0:n.getPropertyValue(e):getComputedStyle(t).getPropertyValue(e):null}function St(t,e,o,n){if(t){let r=getComputedStyle(t),i=document.createElement("div");i.style.position="absolute",i.style.top="0px",i.style.left="0px",i.style.visibility="hidden",i.style.pointerEvents="none",i.style.overflow=r.overflow,i.style.width=r.width,i.style.height=r.height,i.style.padding=r.padding,i.style.border=r.border,i.style.overflowWrap=r.overflowWrap,i.style.whiteSpace=r.whiteSpace,i.style.lineHeight=r.lineHeight,i.innerHTML=e.replace(/\r\n|\r|\n/g,"<br />");let l=document.createElement("span");l.textContent=n,i.appendChild(l);let d=document.createTextNode(o);i.appendChild(d),document.body.appendChild(i);let{offsetLeft:s,offsetTop:a,clientHeight:u}=l;return document.body.removeChild(i),{left:Math.abs(s-t.scrollLeft),top:Math.abs(a-t.scrollTop)+u}}return{top:"auto",left:"auto"}}function b(t,e=""){let o=Y(t,`button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[href]:not([tabindex = "-1"]):not([style*="display:none"]):not([hidden])${e},
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e}`),n=[];for(let r of o)getComputedStyle(r).display!="none"&&getComputedStyle(r).visibility!="hidden"&&n.push(r);return n}function vt(t,e){let o=b(t,e);return o.length>0?o[0]:null}function Tt(t){if(t){let e=t.offsetHeight,o=getComputedStyle(t);return e-=parseFloat(o.paddingTop)+parseFloat(o.paddingBottom)+parseFloat(o.borderTopWidth)+parseFloat(o.borderBottomWidth),e}return 0}function G(t){if(t){let[e,o]=[t.style.visibility,t.style.display];t.style.visibility="hidden",t.style.display="block";let n=t.offsetHeight;return t.style.display=o,t.style.visibility=e,n}return 0}function J(t){if(t){let[e,o]=[t.style.visibility,t.style.display];t.style.visibility="hidden",t.style.display="block";let n=t.offsetWidth;return t.style.display=o,t.style.visibility=e,n}return 0}function Ht(t){var e;if(t){let o=(e=y(t))==null?void 0:e.childNodes,n=0;if(o)for(let r=0;r<o.length;r++){if(o[r]===t)return n;o[r].nodeType===1&&n++}}return-1}function Ct(t){if(t){let e=t.offsetWidth,o=getComputedStyle(t);return e-=parseFloat(o.borderLeft)+parseFloat(o.borderRight),e}return 0}function Lt(t,e){let o=b(t,e);return o.length>0?o[o.length-1]:null}function Wt(t,e){let o=t.nextElementSibling;for(;o;){if(o.matches(e))return o;o=o.nextElementSibling}return null}function Pt(t,e,o){let n=b(t,o),r=n.length>0?n.findIndex(l=>l===e):-1,i=r>-1&&n.length>=r+1?r+1:-1;return i>-1?n[i]:null}function K(t){if(t){let e=t.getBoundingClientRect();return{top:e.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),left:e.left+(window.pageXOffset||E(document.documentElement)||E(document.body)||0)}}return{top:"auto",left:"auto"}}function C(t,e){if(t){let o=t.offsetHeight;if(e){let n=getComputedStyle(t);o+=parseFloat(n.marginTop)+parseFloat(n.marginBottom)}return o}return 0}function M(t,e=[]){let o=y(t);return o===null?e:M(o,e.concat([o]))}function Ot(t,e){let o=t.previousElementSibling;for(;o;){if(o.matches(e))return o;o=o.previousElementSibling}return null}function At(t){let e=[];if(t){let o=M(t),n=/(auto|scroll)/,r=i=>{try{let l=window.getComputedStyle(i,null);return n.test(l.getPropertyValue("overflow"))||n.test(l.getPropertyValue("overflowX"))||n.test(l.getPropertyValue("overflowY"))}catch(l){return!1}};for(let i of o){let l=i.nodeType===1&&i.dataset.scrollselectors;if(l){let d=l.split(",");for(let s of d){let a=z(i,s);a&&r(a)&&e.push(a)}}i.nodeType!==9&&r(i)&&e.push(i)}}return e}function Mt(){if(window.getSelection)return window.getSelection().toString();if(document.getSelection)return document.getSelection().toString()}function Nt(){return navigator.userAgent}function Rt(t){if(t){let e=t.offsetWidth,o=getComputedStyle(t);return e-=parseFloat(o.paddingLeft)+parseFloat(o.paddingRight)+parseFloat(o.borderLeftWidth)+parseFloat(o.borderRightWidth),e}return 0}function Ft(t){if(t){let e=getComputedStyle(t);return parseFloat(e.getPropertyValue("animation-duration")||"0")>0}return!1}function Bt(t){if(t){let e=getComputedStyle(t);return parseFloat(e.getPropertyValue("transition-duration")||"0")>0}return!1}function kt(t,e,o){let n=t[e];typeof n=="function"&&n.apply(t,o!=null?o:[])}function $t(){return/(android)/i.test(navigator.userAgent)}function _(t,e,o){return c(t)?Q(t,e)===o:!1}function Vt(t,e,o){return!_(t,e,o)}function Dt(t){if(t){let e=t.nodeName,o=t.parentElement&&t.parentElement.nodeName;return e==="INPUT"||e==="TEXTAREA"||e==="BUTTON"||e==="A"||o==="INPUT"||o==="TEXTAREA"||o==="BUTTON"||o==="A"||!!t.closest(".p-button, .p-checkbox, .p-radiobutton")}return!1}function tt(){return!!(typeof window!="undefined"&&window.document&&window.document.createElement)}function It(t,e=""){return c(t)?t.matches(`button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e}`):!1}function et(t){return!!(t&&t.offsetParent!=null)}function jt(t){return!et(t)}function Ut(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!("MSStream"in window)}function qt(){return typeof window=="undefined"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Xt(){return!tt()}function Yt(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function zt(t,e){var o,n;if(t){let r=t.parentElement,i=K(r),l=h(),d=t.offsetParent?t.offsetWidth:J(t),s=t.offsetParent?t.offsetHeight:G(t),a=v((o=r==null?void 0:r.children)==null?void 0:o[0]),u=C((n=r==null?void 0:r.children)==null?void 0:n[0]),p="",f="";i.left+a+d>l.width-O()?i.left<d?e%2===1?p=i.left?"-"+i.left+"px":"100%":e%2===0&&(p=l.width-d-O()+"px"):p="-100%":p="100%",t.getBoundingClientRect().top+u+s>l.height?f=`-${s-u}px`:f="0px",t.style.top=f,t.style.insetInlineStart=p}}function Qt(){return new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(t)})})}function Zt(t){var e;t&&("remove"in Element.prototype?t.remove():(e=t.parentNode)==null||e.removeChild(t))}function Gt(t,e){let o=H(t);if(o)o.removeChild(e);else throw new Error("Cannot remove "+e+" from "+t)}function Jt(t){var e;if(T(t)){try{(e=t.parentNode)==null||e.removeChild(t)}catch(o){}return null}return t}function Kt(t,e){let o=getComputedStyle(t).getPropertyValue("borderTopWidth"),n=o?parseFloat(o):0,r=getComputedStyle(t).getPropertyValue("paddingTop"),i=r?parseFloat(r):0,l=t.getBoundingClientRect(),s=e.getBoundingClientRect().top+document.body.scrollTop-(l.top+document.body.scrollTop)-n-i,a=t.scrollTop,u=t.clientHeight,p=C(e);s<0?t.scrollTop=a+s:s+p>u&&(t.scrollTop=a+s-u+p)}function _t(t,e="",o){c(t)&&o!==null&&o!==void 0&&t.setAttribute(e,o)}function te(t,e,o=null,n){var r;e&&((r=t==null?void 0:t.style)==null||r.setProperty(e,o,n))}export{D as absolutePosition,W as addClass,S as addStyle,ft as alignOverlay,ut as appendChild,st as blockBodyScroll,F as calculateBodyScrollbarWidth,ct as calculateScrollbarHeight,O as calculateScrollbarWidth,pt as clearSelection,U as createElement,mt as createStyleAsString,X as createStyleElement,q as createStyleMarkup,gt as createStyleTag,at as exportCSV,ht as fadeIn,yt as fadeOut,Y as find,z as findSingle,bt as focus,Q as getAttribute,xt as getBrowser,Et as getBrowserLanguage,wt as getCSSProperty,x as getCSSVariableByRegex,St as getCursorOffset,vt as getFirstFocusableElement,b as getFocusableElements,Tt as getHeight,w as getHiddenElementDimensions,G as getHiddenElementOuterHeight,J as getHiddenElementOuterWidth,Ht as getIndex,Ct as getInnerWidth,Lt as getLastFocusableElement,Wt as getNextElementSibling,Pt as getNextFocusableElement,K as getOffset,C as getOuterHeight,v as getOuterWidth,y as getParentNode,M as getParents,Ot as getPreviousElementSibling,E as getScrollLeft,At as getScrollableParents,Mt as getSelection,j as getTargetElement,Nt as getUserAgent,h as getViewport,Rt as getWidth,k as getWindowScrollLeft,$ as getWindowScrollTop,Ft as hasCSSAnimation,Bt as hasCSSTransition,R as hasClass,kt as invokeElementMethod,$t as isAndroid,_ as isAttributeEquals,Vt as isAttributeNotEquals,Dt as isClickable,tt as isClient,c as isElement,T as isExist,It as isFocusableElement,jt as isHidden,Ut as isIOS,qt as isPrefersReducedMotion,V as isRTL,Xt as isServer,Yt as isTouchDevice,et as isVisible,zt as nestedPosition,Qt as nextFrame,I as relativePosition,Zt as remove,Gt as removeChild,P as removeClass,Jt as removeStyleTag,Z as resolveUserAgent,B as saveAs,Kt as scrollInView,_t as setAttribute,A as setAttributes,te as setCSSProperty,H as toElement,dt as unblockBodyScroll};
//# sourceMappingURL=index.mjs.map