UNPKG

finpro

Version:
3 lines (2 loc) 16.4 kB
function q(t){return t.split("-")[1]}function st(t){return t==="y"?"height":"width"}function B(t){return t.split("-")[0]}function X(t){return["top","bottom"].includes(B(t))?"x":"y"}function mt(t,e,n){let{reference:o,floating:c}=t,r=o.x+o.width/2-c.width/2,i=o.y+o.height/2-c.height/2,l=X(e),a=st(l),f=o[a]/2-c[a]/2,d=l==="x",s;switch(B(e)){case"top":s={x:r,y:o.y-c.height};break;case"bottom":s={x:r,y:o.y+o.height};break;case"right":s={x:o.x+o.width,y:i};break;case"left":s={x:o.x-c.width,y:i};break;default:s={x:o.x,y:o.y}}switch(q(e)){case"start":s[l]-=f*(n&&d?-1:1);break;case"end":s[l]+=f*(n&&d?-1:1)}return s}var pt=async(t,e,n)=>{let{placement:o="bottom",strategy:c="absolute",middleware:r=[],platform:i}=n,l=r.filter(Boolean),a=await(i.isRTL==null?void 0:i.isRTL(e)),f=await i.getElementRects({reference:t,floating:e,strategy:c}),{x:d,y:s}=mt(f,o,a),m=o,u={},p=0;for(let h=0;h<l.length;h++){let{name:g,fn:y}=l[h],{x,y:w,data:b,reset:v}=await y({x:d,y:s,initialPlacement:o,placement:m,strategy:c,middlewareData:u,rects:f,platform:i,elements:{reference:t,floating:e}});d=x!=null?x:d,s=w!=null?w:s,u={...u,[g]:{...u[g],...b}},v&&p<=50&&(p++,typeof v=="object"&&(v.placement&&(m=v.placement),v.rects&&(f=v.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:c}):v.rects),{x:d,y:s}=mt(f,m,a)),h=-1)}return{x:d,y:s,placement:m,strategy:c,middlewareData:u}};function ct(t){return typeof t!="number"?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(t):{top:t,right:t,bottom:t,left:t}}function j(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function $(t,e){var n;e===void 0&&(e={});let{x:o,y:c,platform:r,rects:i,elements:l,strategy:a}=t,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:s="floating",altBoundary:m=!1,padding:u=0}=e,p=ct(u),h=l[m?s==="floating"?"reference":"floating":s],g=j(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(h)))==null||n?h:h.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(l.floating)),boundary:f,rootBoundary:d,strategy:a})),y=s==="floating"?{...i.floating,x:o,y:c}:i.reference,x=await(r.getOffsetParent==null?void 0:r.getOffsetParent(l.floating)),w=await(r.isElement==null?void 0:r.isElement(x))&&await(r.getScale==null?void 0:r.getScale(x))||{x:1,y:1},b=j(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:y,offsetParent:x,strategy:a}):y);return{top:(g.top-b.top+p.top)/w.y,bottom:(b.bottom-g.bottom+p.bottom)/w.y,left:(g.left-b.left+p.left)/w.x,right:(b.right-g.right+p.right)/w.x}}var _=Math.min,F=Math.max;function lt(t,e,n){return F(t,_(e,n))}var Ht=t=>({name:"arrow",options:t,async fn(e){let{element:n,padding:o=0}=t||{},{x:c,y:r,placement:i,rects:l,platform:a,elements:f}=e;if(n==null)return{};let d=ct(o),s={x:c,y:r},m=X(i),u=st(m),p=await a.getDimensions(n),h=m==="y",g=h?"top":"left",y=h?"bottom":"right",x=h?"clientHeight":"clientWidth",w=l.reference[u]+l.reference[m]-s[m]-l.floating[u],b=s[m]-l.reference[m],v=await(a.getOffsetParent==null?void 0:a.getOffsetParent(n)),R=v?v[x]:0;R&&await(a.isElement==null?void 0:a.isElement(v))||(R=f.floating[x]||l.floating[u]);let E=w/2-b/2,L=d[g],C=R-p[u]-d[y],T=R/2-p[u]/2+E,A=lt(L,T,C),k=q(i)!=null&&T!=A&&l.reference[u]/2-(T<L?d[g]:d[y])-p[u]/2<0;return{[m]:s[m]-(k?T<L?L-T:C-T:0),data:{[m]:A,centerOffset:T-A}}}}),St=["top","right","bottom","left"],Ut=St.reduce((t,e)=>t.concat(e,e+"-start",e+"-end"),[]),Ft={left:"right",right:"left",bottom:"top",top:"bottom"};function Z(t){return t.replace(/left|right|bottom|top/g,e=>Ft[e])}function Bt(t,e,n){n===void 0&&(n=!1);let o=q(t),c=X(t),r=st(c),i=c==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(i=Z(i)),{main:i,cross:Z(i)}}var Wt={start:"end",end:"start"};function rt(t){return t.replace(/start|end/g,e=>Wt[e])}var Vt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n;let{placement:o,middlewareData:c,rects:r,initialPlacement:i,platform:l,elements:a}=e,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:s,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:u="none",flipAlignment:p=!0,...h}=t,g=B(o),y=B(i)===i,x=await(l.isRTL==null?void 0:l.isRTL(a.floating)),w=s||(y||!p?[Z(i)]:function(A){let k=Z(A);return[rt(A),k,rt(k)]}(i));s||u==="none"||w.push(...function(A,k,N,V){let W=q(A),O=function(I,it,Ot){let ut=["left","right"],dt=["right","left"],Ct=["top","bottom"],kt=["bottom","top"];switch(I){case"top":case"bottom":return Ot?it?dt:ut:it?ut:dt;case"left":case"right":return it?Ct:kt;default:return[]}}(B(A),N==="start",V);return W&&(O=O.map(I=>I+"-"+W),k&&(O=O.concat(O.map(rt)))),O}(i,p,u,x));let b=[i,...w],v=await $(e,h),R=[],E=((n=c.flip)==null?void 0:n.overflows)||[];if(f&&R.push(v[g]),d){let{main:A,cross:k}=Bt(o,r,x);R.push(v[A],v[k])}if(E=[...E,{placement:o,overflows:R}],!R.every(A=>A<=0)){var L,C;let A=(((L=c.flip)==null?void 0:L.index)||0)+1,k=b[A];if(k)return{data:{index:A,overflows:E},reset:{placement:k}};let N=(C=E.filter(V=>V.overflows[0]<=0).sort((V,W)=>V.overflows[1]-W.overflows[1])[0])==null?void 0:C.placement;if(!N)switch(m){case"bestFit":{var T;let V=(T=E.map(W=>[W.placement,W.overflows.filter(O=>O>0).reduce((O,I)=>O+I,0)]).sort((W,O)=>W[1]-O[1])[0])==null?void 0:T[0];V&&(N=V);break}case"initialPlacement":N=i}if(o!==N)return{reset:{placement:N}}}return{}}}};function ht(t){let e=_(...t.map(o=>o.left)),n=_(...t.map(o=>o.top));return{x:e,y:n,width:F(...t.map(o=>o.right))-e,height:F(...t.map(o=>o.bottom))-n}}var zt=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){let{placement:n,elements:o,rects:c,platform:r,strategy:i}=e,{padding:l=2,x:a,y:f}=t,d=Array.from(await(r.getClientRects==null?void 0:r.getClientRects(o.reference))||[]),s=function(h){let g=h.slice().sort((w,b)=>w.y-b.y),y=[],x=null;for(let w=0;w<g.length;w++){let b=g[w];!x||b.y-x.y>x.height/2?y.push([b]):y[y.length-1].push(b),x=b}return y.map(w=>j(ht(w)))}(d),m=j(ht(d)),u=ct(l),p=await r.getElementRects({reference:{getBoundingClientRect:function(){if(s.length===2&&s[0].left>s[1].right&&a!=null&&f!=null)return s.find(h=>a>h.left-u.left&&a<h.right+u.right&&f>h.top-u.top&&f<h.bottom+u.bottom)||m;if(s.length>=2){if(X(n)==="x"){let v=s[0],R=s[s.length-1],E=B(n)==="top",L=v.top,C=R.bottom,T=E?v.left:R.left,A=E?v.right:R.right;return{top:L,bottom:C,left:T,right:A,width:A-T,height:C-L,x:T,y:L}}let h=B(n)==="left",g=F(...s.map(v=>v.right)),y=_(...s.map(v=>v.left)),x=s.filter(v=>h?v.left===y:v.right===g),w=x[0].top,b=x[x.length-1].bottom;return{top:w,bottom:b,left:y,right:g,width:g-y,height:b-w,x:y,y:w}}return m}},floating:o.floating,strategy:i});return c.reference.x!==p.reference.x||c.reference.y!==p.reference.y||c.reference.width!==p.reference.width||c.reference.height!==p.reference.height?{reset:{rects:p}}:{}}}},Mt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:n,y:o}=e,c=await async function(r,i){let{placement:l,platform:a,elements:f}=r,d=await(a.isRTL==null?void 0:a.isRTL(f.floating)),s=B(l),m=q(l),u=X(l)==="x",p=["left","top"].includes(s)?-1:1,h=d&&u?-1:1,g=typeof i=="function"?i(r):i,{mainAxis:y,crossAxis:x,alignmentAxis:w}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...g};return m&&typeof w=="number"&&(x=m==="end"?-1*w:w),u?{x:x*h,y:y*p}:{x:y*p,y:x*h}}(e,t);return{x:n+c.x,y:o+c.y,data:c}}}};function Nt(t){return t==="x"?"y":"x"}var jt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:o,placement:c}=e,{mainAxis:r=!0,crossAxis:i=!1,limiter:l={fn:g=>{let{x:y,y:x}=g;return{x:y,y:x}}},...a}=t,f={x:n,y:o},d=await $(e,a),s=X(B(c)),m=Nt(s),u=f[s],p=f[m];if(r){let g=s==="y"?"bottom":"right";u=lt(u+d[s==="y"?"top":"left"],u,u-d[g])}if(i){let g=m==="y"?"bottom":"right";p=lt(p+d[m==="y"?"top":"left"],p,p-d[g])}let h=l.fn({...e,[s]:u,[m]:p});return{...h,data:{x:h.x-n,y:h.y-o}}}}};var Xt=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){let{placement:n,rects:o,platform:c,elements:r}=e,{apply:i=()=>{},...l}=t,a=await $(e,l),f=B(n),d=q(n),s=X(n)==="x",{width:m,height:u}=o.floating,p,h;f==="top"||f==="bottom"?(p=f,h=d===(await(c.isRTL==null?void 0:c.isRTL(r.floating))?"start":"end")?"left":"right"):(h=f,p=d==="end"?"top":"bottom");let g=u-a[p],y=m-a[h],x=!e.middlewareData.shift,w=g,b=y;if(s){let R=m-a.left-a.right;b=d||x?_(y,R):R}else{let R=u-a.top-a.bottom;w=d||x?_(g,R):R}if(x&&!d){let R=F(a.left,0),E=F(a.right,0),L=F(a.top,0),C=F(a.bottom,0);s?b=m-2*(R!==0||E!==0?R+E:F(a.left,a.right)):w=u-2*(L!==0||C!==0?L+C:F(a.top,a.bottom))}await i({...e,availableWidth:b,availableHeight:w});let v=await c.getDimensions(r.floating);return m!==v.width||u!==v.height?{reset:{rects:!0}}:{}}}};function P(t){var e;return((e=t.ownerDocument)==null?void 0:e.defaultView)||window}function H(t){return P(t).getComputedStyle(t)}function bt(t){return t instanceof P(t).Node}function M(t){return bt(t)?(t.nodeName||"").toLowerCase():""}var tt;function Rt(){if(tt)return tt;let t=navigator.userAgentData;return t&&Array.isArray(t.brands)?(tt=t.brands.map(e=>e.brand+"/"+e.version).join(" "),tt):navigator.userAgent}function S(t){return t instanceof P(t).HTMLElement}function D(t){return t instanceof P(t).Element}function gt(t){return typeof ShadowRoot>"u"?!1:t instanceof P(t).ShadowRoot||t instanceof ShadowRoot}function Q(t){let{overflow:e,overflowX:n,overflowY:o,display:c}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(c)}function Yt(t){return["table","td","th"].includes(M(t))}function at(t){let e=/firefox/i.test(Rt()),n=H(t),o=n.backdropFilter||n.WebkitBackdropFilter;return n.transform!=="none"||n.perspective!=="none"||!!o&&o!=="none"||e&&n.willChange==="filter"||e&&!!n.filter&&n.filter!=="none"||["transform","perspective"].some(c=>n.willChange.includes(c))||["paint","layout","strict","content"].some(c=>{let r=n.contain;return r!=null&&r.includes(c)})}function ft(){return/^((?!chrome|android).)*safari/i.test(Rt())}function nt(t){return["html","body","#document"].includes(M(t))}var yt=Math.min,J=Math.max,et=Math.round;function At(t){let e=H(t),n=parseFloat(e.width)||0,o=parseFloat(e.height)||0,c=S(t),r=c?t.offsetWidth:n,i=c?t.offsetHeight:o,l=et(n)!==r||et(o)!==i;return l&&(n=r,o=i),{width:n,height:o,fallback:l}}function Lt(t){return D(t)?t:t.contextElement}var Tt={x:1,y:1};function U(t){let e=Lt(t);if(!S(e))return Tt;let n=e.getBoundingClientRect(),{width:o,height:c,fallback:r}=At(e),i=(r?et(n.width):n.width)/o,l=(r?et(n.height):n.height)/c;return i&&Number.isFinite(i)||(i=1),l&&Number.isFinite(l)||(l=1),{x:i,y:l}}function Y(t,e,n,o){var c,r;e===void 0&&(e=!1),n===void 0&&(n=!1);let i=t.getBoundingClientRect(),l=Lt(t),a=Tt;e&&(o?D(o)&&(a=U(o)):a=U(t));let f=l?P(l):window,d=ft()&&n,s=(i.left+(d&&((c=f.visualViewport)==null?void 0:c.offsetLeft)||0))/a.x,m=(i.top+(d&&((r=f.visualViewport)==null?void 0:r.offsetTop)||0))/a.y,u=i.width/a.x,p=i.height/a.y;if(l){let h=P(l),g=o&&D(o)?P(o):o,y=h.frameElement;for(;y&&o&&g!==h;){let x=U(y),w=y.getBoundingClientRect(),b=getComputedStyle(y);w.x+=(y.clientLeft+parseFloat(b.paddingLeft))*x.x,w.y+=(y.clientTop+parseFloat(b.paddingTop))*x.y,s*=x.x,m*=x.y,u*=x.x,p*=x.y,s+=w.x,m+=w.y,y=P(y).frameElement}}return j({width:u,height:p,x:s,y:m})}function z(t){return((bt(t)?t.ownerDocument:t.document)||window.document).documentElement}function ot(t){return D(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Et(t){return Y(z(t)).left+ot(t).scrollLeft}function G(t){if(M(t)==="html")return t;let e=t.assignedSlot||t.parentNode||gt(t)&&t.host||z(t);return gt(e)?e.host:e}function Pt(t){let e=G(t);return nt(e)?e.ownerDocument.body:S(e)&&Q(e)?e:Pt(e)}function K(t,e){var n;e===void 0&&(e=[]);let o=Pt(t),c=o===((n=t.ownerDocument)==null?void 0:n.body),r=P(o);return c?e.concat(r,r.visualViewport||[],Q(o)?o:[]):e.concat(o,K(o))}function xt(t,e,n){let o;if(e==="viewport")o=function(i,l){let a=P(i),f=z(i),d=a.visualViewport,s=f.clientWidth,m=f.clientHeight,u=0,p=0;if(d){s=d.width,m=d.height;let h=ft();(!h||h&&l==="fixed")&&(u=d.offsetLeft,p=d.offsetTop)}return{width:s,height:m,x:u,y:p}}(t,n);else if(e==="document")o=function(i){let l=z(i),a=ot(i),f=i.ownerDocument.body,d=J(l.scrollWidth,l.clientWidth,f.scrollWidth,f.clientWidth),s=J(l.scrollHeight,l.clientHeight,f.scrollHeight,f.clientHeight),m=-a.scrollLeft+Et(i),u=-a.scrollTop;return H(f).direction==="rtl"&&(m+=J(l.clientWidth,f.clientWidth)-d),{width:d,height:s,x:m,y:u}}(z(t));else if(D(e))o=function(i,l){let a=Y(i,!0,l==="fixed"),f=a.top+i.clientTop,d=a.left+i.clientLeft,s=S(i)?U(i):{x:1,y:1};return{width:i.clientWidth*s.x,height:i.clientHeight*s.y,x:d*s.x,y:f*s.y}}(e,n);else{let i={...e};if(ft()){var c,r;let l=P(t);i.x-=((c=l.visualViewport)==null?void 0:c.offsetLeft)||0,i.y-=((r=l.visualViewport)==null?void 0:r.offsetTop)||0}o=i}return j(o)}function Dt(t,e){let n=G(t);return!(n===e||!D(n)||nt(n))&&(H(n).position==="fixed"||Dt(n,e))}function wt(t,e){return S(t)&&H(t).position!=="fixed"?e?e(t):t.offsetParent:null}function vt(t,e){let n=P(t);if(!S(t))return n;let o=wt(t,e);for(;o&&Yt(o)&&H(o).position==="static";)o=wt(o,e);return o&&(M(o)==="html"||M(o)==="body"&&H(o).position==="static"&&!at(o))?n:o||function(c){let r=G(c);for(;S(r)&&!nt(r);){if(at(r))return r;r=G(r)}return null}(t)||n}function _t(t,e,n){let o=S(e),c=z(e),r=Y(t,!0,n==="fixed",e),i={scrollLeft:0,scrollTop:0},l={x:0,y:0};if(o||!o&&n!=="fixed")if((M(e)!=="body"||Q(c))&&(i=ot(e)),S(e)){let a=Y(e,!0);l.x=a.x+e.clientLeft,l.y=a.y+e.clientTop}else c&&(l.x=Et(c));return{x:r.left+i.scrollLeft-l.x,y:r.top+i.scrollTop-l.y,width:r.width,height:r.height}}var qt={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:c}=t,r=n==="clippingAncestors"?function(f,d){let s=d.get(f);if(s)return s;let m=K(f).filter(g=>D(g)&&M(g)!=="body"),u=null,p=H(f).position==="fixed",h=p?G(f):f;for(;D(h)&&!nt(h);){let g=H(h),y=at(h);y||g.position!=="fixed"||(u=null),(p?!y&&!u:!y&&g.position==="static"&&u&&["absolute","fixed"].includes(u.position)||Q(h)&&!y&&Dt(f,h))?m=m.filter(x=>x!==h):u=g,h=G(h)}return d.set(f,m),m}(e,this._c):[].concat(n),i=[...r,o],l=i[0],a=i.reduce((f,d)=>{let s=xt(e,d,c);return f.top=J(s.top,f.top),f.right=yt(s.right,f.right),f.bottom=yt(s.bottom,f.bottom),f.left=J(s.left,f.left),f},xt(e,l,c));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t,c=S(n),r=z(n);if(n===r)return e;let i={scrollLeft:0,scrollTop:0},l={x:1,y:1},a={x:0,y:0};if((c||!c&&o!=="fixed")&&((M(n)!=="body"||Q(r))&&(i=ot(n)),S(n))){let f=Y(n);l=U(n),a.x=f.x+n.clientLeft,a.y=f.y+n.clientTop}return{width:e.width*l.x,height:e.height*l.y,x:e.x*l.x-i.scrollLeft*l.x+a.x,y:e.y*l.y-i.scrollTop*l.y+a.y}},isElement:D,getDimensions:function(t){return At(t)},getOffsetParent:vt,getDocumentElement:z,getScale:U,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t,c=this.getOffsetParent||vt,r=this.getDimensions;return{reference:_t(e,await c(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>H(t).direction==="rtl"};function Zt(t,e,n,o){o===void 0&&(o={});let{ancestorScroll:c=!0,ancestorResize:r=!0,elementResize:i=!0,animationFrame:l=!1}=o,a=c||r?[...D(t)?K(t):t.contextElement?K(t.contextElement):[],...K(e)]:[];a.forEach(m=>{let u=!D(m)&&m.toString().includes("V");!c||l&&!u||m.addEventListener("scroll",n,{passive:!0}),r&&m.addEventListener("resize",n)});let f,d=null;i&&(d=new ResizeObserver(()=>{n()}),D(t)&&!l&&d.observe(t),D(t)||!t.contextElement||l||d.observe(t.contextElement),d.observe(e));let s=l?Y(t):null;return l&&function m(){let u=Y(t);!s||u.x===s.x&&u.y===s.y&&u.width===s.width&&u.height===s.height||n(),s=u,f=requestAnimationFrame(m)}(),n(),()=>{var m;a.forEach(u=>{c&&u.removeEventListener("scroll",n),r&&u.removeEventListener("resize",n)}),(m=d)==null||m.disconnect(),d=null,l&&cancelAnimationFrame(f)}}var $t=(t,e,n)=>{let o=new Map,c={platform:qt,...n},r={...c.platform,_c:o};return pt(t,e,{...c,platform:r})};export{Ht as a,Vt as b,zt as c,Mt as d,jt as e,Xt as f,Zt as g,$t as h}; //# sourceMappingURL=chunk-MZYIQ6EQ.js.map