2 lines
22 KiB
JavaScript
2 lines
22 KiB
JavaScript
|
|
(()=>{var M=Math.min,L=Math.max,B=Math.round,W=Math.floor,S=e=>({x:e,y:e});function J(e,t,i){return L(e,M(t,i))}function j(e,t){return typeof e=="function"?e(t):e}function H(e){return e.split("-")[0]}function Q(e){return e.split("-")[1]}function Z(e){return e==="x"?"y":"x"}function oe(e){return e==="y"?"height":"width"}var Pe=new Set(["top","bottom"]);function z(e){return Pe.has(H(e))?"y":"x"}function se(e){return Z(z(e))}function De(e){return{top:0,right:0,bottom:0,left:0,...e}}function re(e){return typeof e!="number"?De(e):{top:e,right:e,bottom:e,left:e}}function E(e){let{x:t,y:i,width:n,height:s}=e;return{width:n,height:s,top:i,left:t,right:t+n,bottom:i+s,x:t,y:i}}function le(e,t,i){let{reference:n,floating:s}=e,l=z(t),o=se(t),r=oe(o),c=H(t),a=l==="y",f=n.x+n.width/2-s.width/2,d=n.y+n.height/2-s.height/2,h=n[r]/2-s[r]/2,u;switch(c){case"top":u={x:f,y:n.y-s.height};break;case"bottom":u={x:f,y:n.y+n.height};break;case"right":u={x:n.x+n.width,y:d};break;case"left":u={x:n.x-s.width,y:d};break;default:u={x:n.x,y:n.y}}switch(Q(t)){case"start":u[o]-=h*(i&&a?-1:1);break;case"end":u[o]+=h*(i&&a?-1:1);break}return u}var ce=async(e,t,i)=>{let{placement:n="bottom",strategy:s="absolute",middleware:l=[],platform:o}=i,r=l.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),a=await o.getElementRects({reference:e,floating:t,strategy:s}),{x:f,y:d}=le(a,n,c),h=n,u={},m=0;for(let p=0;p<r.length;p++){let{name:w,fn:g}=r[p],{x,y,data:A,reset:b}=await g({x:f,y:d,initialPlacement:n,placement:h,strategy:s,middlewareData:u,rects:a,platform:o,elements:{reference:e,floating:t}});f=x??f,d=y??d,u={...u,[w]:{...u[w],...A}},b&&m<=50&&(m++,typeof b=="object"&&(b.placement&&(h=b.placement),b.rects&&(a=b.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:s}):b.rects),{x:f,y:d}=le(a,h,c)),p=-1)}return{x:f,y:d,placement:h,strategy:s,middlewareData:u}};async function ae(e,t){var i;t===void 0&&(t={});let{x:n,y:s,platform:l,rects:o,elements:r,strategy:c}=e,{boundary:a="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:h=!1,padding:u=0}=j(t,e),m=re(u),w=r[h?d==="floating"?"reference":"floating":d],g=E(await l.getClippingRect({element:(i=await(l.isElement==null?void 0:l.isElement(w)))==null||i?w:w.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(r.floating)),boundary:a,rootBoundary:f,strategy:c})),x=d==="floating"?{x:n,y:s,width:o.floating.width,height:o.floating.height}:o.reference,y=await(l.getOffsetParent==null?void 0:l.getOffsetParent(r.floating)),A=await(l.isElement==null?void 0:l.isElement(y))?await(l.getScale==null?void 0:l.getScale(y))||{x:1,y:1}:{x:1,y:1},b=E(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:x,offsetParent:y,strategy:c}):x);return{top:(g.top-b.top+m.top)/A.y,bottom:(b.bottom-g.bottom+m.bottom)/A.y,left:(g.left-b.left+m.left)/A.x,right:(b.right-g.right+m.right)/A.x}}var Fe=new Set(["left","top"]);async function Me(e,t){let{placement:i,platform:n,elements:s}=e,l=await(n.isRTL==null?void 0:n.isRTL(s.floating)),o=H(i),r=Q(i),c=z(i)==="y",a=Fe.has(o)?-1:1,f=l&&c?-1:1,d=j(t,e),{mainAxis:h,crossAxis:u,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return r&&typeof m=="number"&&(u=r==="end"?m*-1:m),c?{x:u*f,y:h*a}:{x:h*a,y:u*f}}var fe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var i,n;let{x:s,y:l,placement:o,middlewareData:r}=t,c=await Me(t,e);return o===((i=r.offset)==null?void 0:i.placement)&&(n=r.arrow)!=null&&n.alignmentOffset?{}:{x:s+c.x,y:l+c.y,data:{...c,placement:o}}}}},de=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:i,y:n,placement:s}=t,{mainAxis:l=!0,crossAxis:o=!1,limiter:r={fn:w=>{let{x:g,y:x}=w;return{x:g,y:x}}},...c}=j(e,t),a={x:i,y:n},f=await ae(t,c),d=z(H(s)),h=Z(d),u=a[h],m=a[d];if(l){let w=h==="y"?"top":"left",g=h==="y"?"bottom":"right",x=u+f[w],y=u-f[g];u=J(x,u,y)}if(o){let w=d===
|