UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

1 lines • 24.5 kB
import{g as getElementDir}from"./dom-d9ba1da4.js";var top="top";var bottom="bottom";var right="right";var left="left";var auto="auto";var basePlacements=[top,bottom,right,left];var start="start";var end="end";var clippingParents="clippingParents";var viewport="viewport";var popper="popper";var reference="reference";var variationPlacements=basePlacements.reduce((function(e,t){return e.concat([t+"-"+start,t+"-"+end])}),[]);var placements=[].concat(basePlacements,[auto]).reduce((function(e,t){return e.concat([t,t+"-"+start,t+"-"+end])}),[]);var beforeRead="beforeRead";var read="read";var afterRead="afterRead";var beforeMain="beforeMain";var main="main";var afterMain="afterMain";var beforeWrite="beforeWrite";var write="write";var afterWrite="afterWrite";var modifierPhases=[beforeRead,read,afterRead,beforeMain,main,afterMain,beforeWrite,write,afterWrite];function getNodeName(e){return e?(e.nodeName||"").toLowerCase():null}function getWindow(e){if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t?t.defaultView||window:window}return e}function isElement(e){var t=getWindow(e).Element;return e instanceof t||e instanceof Element}function isHTMLElement(e){var t=getWindow(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function isShadowRoot(e){var t=getWindow(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function applyStyles(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var r=t.styles[e]||{};var n=t.attributes[e]||{};var a=t.elements[e];if(!isHTMLElement(a)||!getNodeName(a)){return}Object.assign(a.style,r);Object.keys(n).forEach((function(e){var t=n[e];if(t===false){a.removeAttribute(e)}else{a.setAttribute(e,t===true?"":t)}}))}))}function effect(e){var t=e.state;var r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,r.popper);if(t.elements.arrow){Object.assign(t.elements.arrow.style,r.arrow)}return function(){Object.keys(t.elements).forEach((function(e){var n=t.elements[e];var a=t.attributes[e]||{};var i=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:r[e]);var o=i.reduce((function(e,t){e[t]="";return e}),{});if(!isHTMLElement(n)||!getNodeName(n)){return}Object.assign(n.style,o);Object.keys(a).forEach((function(e){n.removeAttribute(e)}))}))}}var applyStyles$1={name:"applyStyles",enabled:true,phase:"write",fn:applyStyles,effect:effect,requires:["computeStyles"]};function getBasePlacement(e){return e.split("-")[0]}function getLayoutRect(e){return{x:e.offsetLeft,y:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight}}function contains(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t)){return true}else if(r&&isShadowRoot(r)){var n=t;do{if(n&&e.isSameNode(n)){return true}n=n.parentNode||n.host}while(n)}return false}function getComputedStyle(e){return getWindow(e).getComputedStyle(e)}function isTableElement(e){return["table","td","th"].indexOf(getNodeName(e))>=0}function getDocumentElement(e){return((isElement(e)?e.ownerDocument:e.document)||window.document).documentElement}function getParentNode(e){if(getNodeName(e)==="html"){return e}return e.assignedSlot||e.parentNode||e.host||getDocumentElement(e)}function getTrueOffsetParent(e){if(!isHTMLElement(e)||getComputedStyle(e).position==="fixed"){return null}var t=e.offsetParent;if(t){var r=getDocumentElement(t);if(getNodeName(t)==="body"&&getComputedStyle(t).position==="static"&&getComputedStyle(r).position!=="static"){return r}}return t}function getContainingBlock(e){var t=getParentNode(e);while(isHTMLElement(t)&&["html","body"].indexOf(getNodeName(t))<0){var r=getComputedStyle(t);if(r.transform!=="none"||r.perspective!=="none"||r.willChange&&r.willChange!=="auto"){return t}else{t=t.parentNode}}return null}function getOffsetParent(e){var t=getWindow(e);var r=getTrueOffsetParent(e);while(r&&isTableElement(r)&&getComputedStyle(r).position==="static"){r=getTrueOffsetParent(r)}if(r&&getNodeName(r)==="body"&&getComputedStyle(r).position==="static"){return t}return r||getContainingBlock(e)||t}function getMainAxisFromPlacement(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function within(e,t,r){return Math.max(e,Math.min(t,r))}function getFreshSideObject(){return{top:0,right:0,bottom:0,left:0}}function mergePaddingObject(e){return Object.assign(Object.assign({},getFreshSideObject()),e)}function expandToHashMap(e,t){return t.reduce((function(t,r){t[r]=e;return t}),{})}function arrow(e){var t;var r=e.state,n=e.name;var a=r.elements.arrow;var i=r.modifiersData.popperOffsets;var o=getBasePlacement(r.placement);var s=getMainAxisFromPlacement(o);var f=[left,right].indexOf(o)>=0;var c=f?"height":"width";if(!a||!i){return}var l=r.modifiersData[n+"#persistent"].padding;var p=getLayoutRect(a);var u=s==="y"?top:left;var d=s==="y"?bottom:right;var v=r.rects.reference[c]+r.rects.reference[s]-i[s]-r.rects.popper[c];var m=i[s]-r.rects.reference[s];var g=getOffsetParent(a);var h=g?s==="y"?g.clientHeight||0:g.clientWidth||0:0;var b=v/2-m/2;var y=l[u];var O=h-p[c]-l[d];var w=h/2-p[c]/2+b;var P=within(y,w,O);var x=s;r.modifiersData[n]=(t={},t[x]=P,t.centerOffset=P-w,t)}function effect$1(e){var t=e.state,r=e.options,n=e.name;var a=r.element,i=a===void 0?"[data-popper-arrow]":a,o=r.padding,s=o===void 0?0:o;if(i==null){return}if(typeof i==="string"){i=t.elements.popper.querySelector(i);if(!i){return}}if(!contains(t.elements.popper,i)){return}t.elements.arrow=i;t.modifiersData[n+"#persistent"]={padding:mergePaddingObject(typeof s!=="number"?s:expandToHashMap(s,basePlacements))}}var arrow$1={name:"arrow",enabled:true,phase:"main",fn:arrow,effect:effect$1,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};var unsetSides={top:"auto",right:"auto",bottom:"auto",left:"auto"};function roundOffsetsByDPR(e){var t=e.x,r=e.y;var n=window;var a=n.devicePixelRatio||1;return{x:Math.round(t*a)/a||0,y:Math.round(r*a)/a||0}}function mapToStyles(e){var t;var r=e.popper,n=e.popperRect,a=e.placement,i=e.offsets,o=e.position,s=e.gpuAcceleration,f=e.adaptive,c=e.roundOffsets;var l=c?roundOffsetsByDPR(i):i,p=l.x,u=p===void 0?0:p,d=l.y,v=d===void 0?0:d;var m=i.hasOwnProperty("x");var g=i.hasOwnProperty("y");var h=left;var b=top;var y=window;if(f){var O=getOffsetParent(r);if(O===getWindow(r)){O=getDocumentElement(r)}if(a===top){b=bottom;v-=O.clientHeight-n.height;v*=s?1:-1}if(a===left){h=right;u-=O.clientWidth-n.width;u*=s?1:-1}}var w=Object.assign({position:o},f&&unsetSides);if(s){var P;return Object.assign(Object.assign({},w),{},(P={},P[b]=g?"0":"",P[h]=m?"0":"",P.transform=(y.devicePixelRatio||1)<2?"translate("+u+"px, "+v+"px)":"translate3d("+u+"px, "+v+"px, 0)",P))}return Object.assign(Object.assign({},w),{},(t={},t[b]=g?v+"px":"",t[h]=m?u+"px":"",t.transform="",t))}function computeStyles(e){var t=e.state,r=e.options;var n=r.gpuAcceleration,a=n===void 0?true:n,i=r.adaptive,o=i===void 0?true:i,s=r.roundOffsets,f=s===void 0?true:s;var c={placement:getBasePlacement(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:a};if(t.modifiersData.popperOffsets!=null){t.styles.popper=Object.assign(Object.assign({},t.styles.popper),mapToStyles(Object.assign(Object.assign({},c),{},{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:f})))}if(t.modifiersData.arrow!=null){t.styles.arrow=Object.assign(Object.assign({},t.styles.arrow),mapToStyles(Object.assign(Object.assign({},c),{},{offsets:t.modifiersData.arrow,position:"absolute",adaptive:false,roundOffsets:f})))}t.attributes.popper=Object.assign(Object.assign({},t.attributes.popper),{},{"data-popper-placement":t.placement})}var computeStyles$1={name:"computeStyles",enabled:true,phase:"beforeWrite",fn:computeStyles,data:{}};var passive={passive:true};function effect$2(e){var t=e.state,r=e.instance,n=e.options;var a=n.scroll,i=a===void 0?true:a,o=n.resize,s=o===void 0?true:o;var f=getWindow(t.elements.popper);var c=[].concat(t.scrollParents.reference,t.scrollParents.popper);if(i){c.forEach((function(e){e.addEventListener("scroll",r.update,passive)}))}if(s){f.addEventListener("resize",r.update,passive)}return function(){if(i){c.forEach((function(e){e.removeEventListener("scroll",r.update,passive)}))}if(s){f.removeEventListener("resize",r.update,passive)}}}var eventListeners={name:"eventListeners",enabled:true,phase:"write",fn:function e(){},effect:effect$2,data:{}};var hash={left:"right",right:"left",bottom:"top",top:"bottom"};function getOppositePlacement(e){return e.replace(/left|right|bottom|top/g,(function(e){return hash[e]}))}var hash$1={start:"end",end:"start"};function getOppositeVariationPlacement(e){return e.replace(/start|end/g,(function(e){return hash$1[e]}))}function getBoundingClientRect(e){var t=e.getBoundingClientRect();return{width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left,x:t.left,y:t.top}}function getWindowScroll(e){var t=getWindow(e);var r=t.pageXOffset;var n=t.pageYOffset;return{scrollLeft:r,scrollTop:n}}function getWindowScrollBarX(e){return getBoundingClientRect(getDocumentElement(e)).left+getWindowScroll(e).scrollLeft}function getViewportRect(e){var t=getWindow(e);var r=getDocumentElement(e);var n=t.visualViewport;var a=r.clientWidth;var i=r.clientHeight;var o=0;var s=0;if(n){a=n.width;i=n.height;if(!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)){o=n.offsetLeft;s=n.offsetTop}}return{width:a,height:i,x:o+getWindowScrollBarX(e),y:s}}function getDocumentRect(e){var t=getDocumentElement(e);var r=getWindowScroll(e);var n=e.ownerDocument.body;var a=Math.max(t.scrollWidth,t.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0);var i=Math.max(t.scrollHeight,t.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0);var o=-r.scrollLeft+getWindowScrollBarX(e);var s=-r.scrollTop;if(getComputedStyle(n||t).direction==="rtl"){o+=Math.max(t.clientWidth,n?n.clientWidth:0)-a}return{width:a,height:i,x:o,y:s}}function isScrollParent(e){var t=getComputedStyle(e),r=t.overflow,n=t.overflowX,a=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+a+n)}function getScrollParent(e){if(["html","body","#document"].indexOf(getNodeName(e))>=0){return e.ownerDocument.body}if(isHTMLElement(e)&&isScrollParent(e)){return e}return getScrollParent(getParentNode(e))}function listScrollParents(e,t){if(t===void 0){t=[]}var r=getScrollParent(e);var n=getNodeName(r)==="body";var a=getWindow(r);var i=n?[a].concat(a.visualViewport||[],isScrollParent(r)?r:[]):r;var o=t.concat(i);return n?o:o.concat(listScrollParents(getParentNode(i)))}function rectToClientRect(e){return Object.assign(Object.assign({},e),{},{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function getInnerBoundingClientRect(e){var t=getBoundingClientRect(e);t.top=t.top+e.clientTop;t.left=t.left+e.clientLeft;t.bottom=t.top+e.clientHeight;t.right=t.left+e.clientWidth;t.width=e.clientWidth;t.height=e.clientHeight;t.x=t.left;t.y=t.top;return t}function getClientRectFromMixedType(e,t){return t===viewport?rectToClientRect(getViewportRect(e)):isHTMLElement(t)?getInnerBoundingClientRect(t):rectToClientRect(getDocumentRect(getDocumentElement(e)))}function getClippingParents(e){var t=listScrollParents(getParentNode(e));var r=["absolute","fixed"].indexOf(getComputedStyle(e).position)>=0;var n=r&&isHTMLElement(e)?getOffsetParent(e):e;if(!isElement(n)){return[]}return t.filter((function(e){return isElement(e)&&contains(e,n)&&getNodeName(e)!=="body"}))}function getClippingRect(e,t,r){var n=t==="clippingParents"?getClippingParents(e):[].concat(t);var a=[].concat(n,[r]);var i=a[0];var o=a.reduce((function(t,r){var n=getClientRectFromMixedType(e,r);t.top=Math.max(n.top,t.top);t.right=Math.min(n.right,t.right);t.bottom=Math.min(n.bottom,t.bottom);t.left=Math.max(n.left,t.left);return t}),getClientRectFromMixedType(e,i));o.width=o.right-o.left;o.height=o.bottom-o.top;o.x=o.left;o.y=o.top;return o}function getVariation(e){return e.split("-")[1]}function computeOffsets(e){var t=e.reference,r=e.element,n=e.placement;var a=n?getBasePlacement(n):null;var i=n?getVariation(n):null;var o=t.x+t.width/2-r.width/2;var s=t.y+t.height/2-r.height/2;var f;switch(a){case top:f={x:o,y:t.y-r.height};break;case bottom:f={x:o,y:t.y+t.height};break;case right:f={x:t.x+t.width,y:s};break;case left:f={x:t.x-r.width,y:s};break;default:f={x:t.x,y:t.y}}var c=a?getMainAxisFromPlacement(a):null;if(c!=null){var l=c==="y"?"height":"width";switch(i){case start:f[c]=f[c]-(t[l]/2-r[l]/2);break;case end:f[c]=f[c]+(t[l]/2-r[l]/2);break}}return f}function detectOverflow(e,t){if(t===void 0){t={}}var r=t,n=r.placement,a=n===void 0?e.placement:n,i=r.boundary,o=i===void 0?clippingParents:i,s=r.rootBoundary,f=s===void 0?viewport:s,c=r.elementContext,l=c===void 0?popper:c,p=r.altBoundary,u=p===void 0?false:p,d=r.padding,v=d===void 0?0:d;var m=mergePaddingObject(typeof v!=="number"?v:expandToHashMap(v,basePlacements));var g=l===popper?reference:popper;var h=e.elements.reference;var b=e.rects.popper;var y=e.elements[u?g:l];var O=getClippingRect(isElement(y)?y:y.contextElement||getDocumentElement(e.elements.popper),o,f);var w=getBoundingClientRect(h);var P=computeOffsets({reference:w,element:b,strategy:"absolute",placement:a});var x=rectToClientRect(Object.assign(Object.assign({},b),P));var S=l===popper?x:w;var E={top:O.top-S.top+m.top,bottom:S.bottom-O.bottom+m.bottom,left:O.left-S.left+m.left,right:S.right-O.right+m.right};var M=e.modifiersData.offset;if(l===popper&&M){var j=M[a];Object.keys(E).forEach((function(e){var t=[right,bottom].indexOf(e)>=0?1:-1;var r=[top,bottom].indexOf(e)>=0?"y":"x";E[e]+=j[r]*t}))}return E}function computeAutoPlacement(e,t){if(t===void 0){t={}}var r=t,n=r.placement,a=r.boundary,i=r.rootBoundary,o=r.padding,s=r.flipVariations,f=r.allowedAutoPlacements,c=f===void 0?placements:f;var l=getVariation(n);var p=l?s?variationPlacements:variationPlacements.filter((function(e){return getVariation(e)===l})):basePlacements;var u=p.filter((function(e){return c.indexOf(e)>=0}));if(u.length===0){u=p}var d=u.reduce((function(t,r){t[r]=detectOverflow(e,{placement:r,boundary:a,rootBoundary:i,padding:o})[getBasePlacement(r)];return t}),{});return Object.keys(d).sort((function(e,t){return d[e]-d[t]}))}function getExpandedFallbackPlacements(e){if(getBasePlacement(e)===auto){return[]}var t=getOppositePlacement(e);return[getOppositeVariationPlacement(e),t,getOppositeVariationPlacement(t)]}function flip(e){var t=e.state,r=e.options,n=e.name;if(t.modifiersData[n]._skip){return}var a=r.mainAxis,i=a===void 0?true:a,o=r.altAxis,s=o===void 0?true:o,f=r.fallbackPlacements,c=r.padding,l=r.boundary,p=r.rootBoundary,u=r.altBoundary,d=r.flipVariations,v=d===void 0?true:d,m=r.allowedAutoPlacements;var g=t.options.placement;var h=getBasePlacement(g);var b=h===g;var y=f||(b||!v?[getOppositePlacement(g)]:getExpandedFallbackPlacements(g));var O=[g].concat(y).reduce((function(e,r){return e.concat(getBasePlacement(r)===auto?computeAutoPlacement(t,{placement:r,boundary:l,rootBoundary:p,padding:c,flipVariations:v,allowedAutoPlacements:m}):r)}),[]);var w=t.rects.reference;var P=t.rects.popper;var x=new Map;var S=true;var E=O[0];for(var M=0;M<O.length;M++){var j=O[M];var T=getBasePlacement(j);var D=getVariation(j)===start;var C=[top,bottom].indexOf(T)>=0;var R=C?"width":"height";var B=detectOverflow(t,{placement:j,boundary:l,rootBoundary:p,altBoundary:u,padding:c});var N=C?D?right:left:D?bottom:top;if(w[R]>P[R]){N=getOppositePlacement(N)}var L=getOppositePlacement(N);var W=[];if(i){W.push(B[T]<=0)}if(s){W.push(B[N]<=0,B[L]<=0)}if(W.every((function(e){return e}))){E=j;S=false;break}x.set(j,W)}if(S){var A=v?3:1;var H=function e(t){var r=O.find((function(e){var r=x.get(e);if(r){return r.slice(0,t).every((function(e){return e}))}}));if(r){E=r;return"break"}};for(var k=A;k>0;k--){var $=H(k);if($==="break")break}}if(t.placement!==E){t.modifiersData[n]._skip=true;t.placement=E;t.reset=true}}var flip$1={name:"flip",enabled:true,phase:"main",fn:flip,requiresIfExists:["offset"],data:{_skip:false}};function getSideOffsets(e,t,r){if(r===void 0){r={x:0,y:0}}return{top:e.top-t.height-r.y,right:e.right-t.width+r.x,bottom:e.bottom-t.height+r.y,left:e.left-t.width-r.x}}function isAnySideFullyClipped(e){return[top,right,bottom,left].some((function(t){return e[t]>=0}))}function hide(e){var t=e.state,r=e.name;var n=t.rects.reference;var a=t.rects.popper;var i=t.modifiersData.preventOverflow;var o=detectOverflow(t,{elementContext:"reference"});var s=detectOverflow(t,{altBoundary:true});var f=getSideOffsets(o,n);var c=getSideOffsets(s,a,i);var l=isAnySideFullyClipped(f);var p=isAnySideFullyClipped(c);t.modifiersData[r]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:l,hasPopperEscaped:p};t.attributes.popper=Object.assign(Object.assign({},t.attributes.popper),{},{"data-popper-reference-hidden":l,"data-popper-escaped":p})}var hide$1={name:"hide",enabled:true,phase:"main",requiresIfExists:["preventOverflow"],fn:hide};function distanceAndSkiddingToXY(e,t,r){var n=getBasePlacement(e);var a=[left,top].indexOf(n)>=0?-1:1;var i=typeof r==="function"?r(Object.assign(Object.assign({},t),{},{placement:e})):r,o=i[0],s=i[1];o=o||0;s=(s||0)*a;return[left,right].indexOf(n)>=0?{x:s,y:o}:{x:o,y:s}}function offset(e){var t=e.state,r=e.options,n=e.name;var a=r.offset,i=a===void 0?[0,0]:a;var o=placements.reduce((function(e,r){e[r]=distanceAndSkiddingToXY(r,t.rects,i);return e}),{});var s=o[t.placement],f=s.x,c=s.y;if(t.modifiersData.popperOffsets!=null){t.modifiersData.popperOffsets.x+=f;t.modifiersData.popperOffsets.y+=c}t.modifiersData[n]=o}var offset$1={name:"offset",enabled:true,phase:"main",requires:["popperOffsets"],fn:offset};function popperOffsets(e){var t=e.state,r=e.name;t.modifiersData[r]=computeOffsets({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}var popperOffsets$1={name:"popperOffsets",enabled:true,phase:"read",fn:popperOffsets,data:{}};function getAltAxis(e){return e==="x"?"y":"x"}function preventOverflow(e){var t=e.state,r=e.options,n=e.name;var a=r.mainAxis,i=a===void 0?true:a,o=r.altAxis,s=o===void 0?false:o,f=r.boundary,c=r.rootBoundary,l=r.altBoundary,p=r.padding,u=r.tether,d=u===void 0?true:u,v=r.tetherOffset,m=v===void 0?0:v;var g=detectOverflow(t,{boundary:f,rootBoundary:c,padding:p,altBoundary:l});var h=getBasePlacement(t.placement);var b=getVariation(t.placement);var y=!b;var O=getMainAxisFromPlacement(h);var w=getAltAxis(O);var P=t.modifiersData.popperOffsets;var x=t.rects.reference;var S=t.rects.popper;var E=typeof m==="function"?m(Object.assign(Object.assign({},t.rects),{},{placement:t.placement})):m;var M={x:0,y:0};if(!P){return}if(i){var j=O==="y"?top:left;var T=O==="y"?bottom:right;var D=O==="y"?"height":"width";var C=P[O];var R=P[O]+g[j];var B=P[O]-g[T];var N=d?-S[D]/2:0;var L=b===start?x[D]:S[D];var W=b===start?-S[D]:-x[D];var A=t.elements.arrow;var H=d&&A?getLayoutRect(A):{width:0,height:0};var k=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:getFreshSideObject();var $=k[j];var F=k[T];var V=within(0,x[D],H[D]);var q=y?x[D]/2-N-V-$-E:L-V-$-E;var I=y?-x[D]/2+N+V+F+E:W+V+F+E;var X=t.elements.arrow&&getOffsetParent(t.elements.arrow);var U=X?O==="y"?X.clientTop||0:X.clientLeft||0:0;var z=t.modifiersData.offset?t.modifiersData.offset[t.placement][O]:0;var _=P[O]+q-z-U;var Y=P[O]+I-z;var G=within(d?Math.min(R,_):R,C,d?Math.max(B,Y):B);P[O]=G;M[O]=G-C}if(s){var J=O==="x"?top:left;var K=O==="x"?bottom:right;var Q=P[w];var Z=Q+g[J];var ee=Q-g[K];var te=within(Z,Q,ee);P[w]=te;M[w]=te-Q}t.modifiersData[n]=M}var preventOverflow$1={name:"preventOverflow",enabled:true,phase:"main",fn:preventOverflow,requiresIfExists:["offset"]};function getHTMLElementScroll(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function getNodeScroll(e){if(e===getWindow(e)||!isHTMLElement(e)){return getWindowScroll(e)}else{return getHTMLElementScroll(e)}}function getCompositeRect(e,t,r){if(r===void 0){r=false}var n=getDocumentElement(t);var a=getBoundingClientRect(e);var i=isHTMLElement(t);var o={scrollLeft:0,scrollTop:0};var s={x:0,y:0};if(i||!i&&!r){if(getNodeName(t)!=="body"||isScrollParent(n)){o=getNodeScroll(t)}if(isHTMLElement(t)){s=getBoundingClientRect(t);s.x+=t.clientLeft;s.y+=t.clientTop}else if(n){s.x=getWindowScrollBarX(n)}}return{x:a.left+o.scrollLeft-s.x,y:a.top+o.scrollTop-s.y,width:a.width,height:a.height}}function order(e){var t=new Map;var r=new Set;var n=[];e.forEach((function(e){t.set(e.name,e)}));function a(e){r.add(e.name);var i=[].concat(e.requires||[],e.requiresIfExists||[]);i.forEach((function(e){if(!r.has(e)){var n=t.get(e);if(n){a(n)}}}));n.push(e)}e.forEach((function(e){if(!r.has(e.name)){a(e)}}));return n}function orderModifiers(e){var t=order(e);return modifierPhases.reduce((function(e,r){return e.concat(t.filter((function(e){return e.phase===r})))}),[])}function debounce(e){var t;return function(){if(!t){t=new Promise((function(r){Promise.resolve().then((function(){t=undefined;r(e())}))}))}return t}}function mergeByName(e){var t=e.reduce((function(e,t){var r=e[t.name];e[t.name]=r?Object.assign(Object.assign(Object.assign({},r),t),{},{options:Object.assign(Object.assign({},r.options),t.options),data:Object.assign(Object.assign({},r.data),t.data)}):t;return e}),{});return Object.keys(t).map((function(e){return t[e]}))}var DEFAULT_OPTIONS={placement:"bottom",modifiers:[],strategy:"absolute"};function areValidElements(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return!t.some((function(e){return!(e&&typeof e.getBoundingClientRect==="function")}))}function popperGenerator(e){if(e===void 0){e={}}var t=e,r=t.defaultModifiers,n=r===void 0?[]:r,a=t.defaultOptions,i=a===void 0?DEFAULT_OPTIONS:a;return function e(t,r,a){if(a===void 0){a=i}var o={placement:"bottom",orderedModifiers:[],options:Object.assign(Object.assign({},DEFAULT_OPTIONS),i),modifiersData:{},elements:{reference:t,popper:r},attributes:{},styles:{}};var s=[];var f=false;var c={state:o,setOptions:function e(a){p();o.options=Object.assign(Object.assign(Object.assign({},i),o.options),a);o.scrollParents={reference:isElement(t)?listScrollParents(t):t.contextElement?listScrollParents(t.contextElement):[],popper:listScrollParents(r)};var s=orderModifiers(mergeByName([].concat(n,o.options.modifiers)));o.orderedModifiers=s.filter((function(e){return e.enabled}));l();return c.update()},forceUpdate:function e(){if(f){return}var t=o.elements,r=t.reference,n=t.popper;if(!areValidElements(r,n)){return}o.rects={reference:getCompositeRect(r,getOffsetParent(n),o.options.strategy==="fixed"),popper:getLayoutRect(n)};o.reset=false;o.placement=o.options.placement;o.orderedModifiers.forEach((function(e){return o.modifiersData[e.name]=Object.assign({},e.data)}));for(var a=0;a<o.orderedModifiers.length;a++){if(o.reset===true){o.reset=false;a=-1;continue}var i=o.orderedModifiers[a],s=i.fn,l=i.options,p=l===void 0?{}:l,u=i.name;if(typeof s==="function"){o=s({state:o,options:p,name:u,instance:c})||o}}},update:debounce((function(){return new Promise((function(e){c.forceUpdate();e(o)}))})),destroy:function e(){p();f=true}};if(!areValidElements(t,r)){return c}c.setOptions(a).then((function(e){if(!f&&a.onFirstUpdate){a.onFirstUpdate(e)}}));function l(){o.orderedModifiers.forEach((function(e){var t=e.name,r=e.options,n=r===void 0?{}:r,a=e.effect;if(typeof a==="function"){var i=a({state:o,name:t,instance:c,options:n});var f=function e(){};s.push(i||f)}}))}function p(){s.forEach((function(e){return e()}));s=[]}return c}}var defaultModifiers=[eventListeners,popperOffsets$1,computeStyles$1,applyStyles$1,offset$1,flip$1,preventOverflow$1,arrow$1,hide$1];var createPopper=popperGenerator({defaultModifiers:defaultModifiers});var CSS={animation:"calcite-popper-anim",animationActive:"calcite-popper-anim--active"};function getPlacement(e,t){var r=["left","right"];if(getElementDir(e)==="rtl"){r.reverse()}return t.replace(/leading/gi,r[0]).replace(/trailing/gi,r[1])}function createPopper$1(e){var t=e.referenceEl,r=e.el,n=e.placement,a=e.modifiers;if(!t){return null}return createPopper(t,r,{placement:getPlacement(r,n),modifiers:a})}function updatePopper(e){var t=e.el,r=e.modifiers,n=e.placement,a=e.popper;var i=getPlacement(t,n);a.setOptions({modifiers:r,placement:i})}function hypotenuse(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}var visiblePointerSize=4;var defaultOffsetDistance=Math.ceil(hypotenuse(visiblePointerSize,visiblePointerSize));export{CSS as C,createPopper$1 as c,defaultOffsetDistance as d,updatePopper as u};