!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).feedbackfin=t()}(this,function(){function e(){return e=Object.assign||function(e){for(var t=1;tf[e])}const u={start:"end",end:"start"};function m(e){return e.replace(/start|end/g,e=>u[e])}const Z=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(c){var o;const{placement:r,middlewareData:l,rects:d,initialPlacement:f,platform:u,elements:Z}=c,{mainAxis:g=!0,crossAxis:W=!0,fallbackPlacements:p,fallbackStrategy:G="bestFit",flipAlignment:x=!0,...k}=e,Q=t(r),I=p||(Q!==f&&x?function(e){const t=s(e);return[m(e),t,m(t)]}(f):[s(f)]),h=[f,...I],F=await b(c,k),Y=[];let y=(null==(o=l.flip)?void 0:o.overflows)||[];if(g&&Y.push(F[Q]),W){const{main:e,cross:t}=function(e,t,c){void 0===c&&(c=!1);const o=i(e),b=a(e),r=n(b);let l="x"===b?o===(c?"end":"start")?"right":"left":"start"===o?"bottom":"top";return t.reference[r]>t.floating[r]&&(l=s(l)),{main:l,cross:s(l)}}(r,d,await(null==u.isRTL?void 0:u.isRTL(Z.floating)));Y.push(F[e],F[t])}if(y=[...y,{placement:r,overflows:Y}],!Y.every(e=>e<=0)){var B,N;const e=(null!=(B=null==(N=l.flip)?void 0:N.index)?B:0)+1,t=h[e];if(t)return{data:{index:e,overflows:y},reset:{placement:t}};let i="bottom";switch(G){case"bestFit":{var X;const e=null==(X=y.slice().sort((e,t)=>e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)-t.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0))[0])?void 0:X.placement;e&&(i=e);break}case"initialPlacement":i=f}if(r!==i)return{reset:{placement:i}}}return{}}}};function g(e){return e&&e.document&&e.location&&e.alert&&e.setInterval}function W(e){if(null==e)return window;if(!g(e)){const t=e.ownerDocument;return t&&t.defaultView||window}return e}function p(e){return W(e).getComputedStyle(e)}function G(e){return g(e)?"":e?(e.nodeName||"").toLowerCase():""}function x(e){return e instanceof W(e).HTMLElement}function k(e){return e instanceof W(e).Element}function Q(e){return e instanceof W(e).ShadowRoot||e instanceof ShadowRoot}function I(e){const{overflow:t,overflowX:i,overflowY:a}=p(e);return/auto|scroll|overlay|hidden/.test(t+a+i)}function h(e){return["table","td","th"].includes(G(e))}function F(e){const t=navigator.userAgent.toLowerCase().includes("firefox"),i=p(e);return"none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||["transform","perspective"].includes(i.willChange)||t&&"filter"===i.willChange||t&&!!i.filter&&"none"!==i.filter}function Y(){return!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}const y=Math.min,B=Math.max,N=Math.round;function X(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=!1);const a=e.getBoundingClientRect();let n=1,c=1;t&&x(e)&&(n=e.offsetWidth>0&&N(a.width)/e.offsetWidth||1,c=e.offsetHeight>0&&N(a.height)/e.offsetHeight||1);const o=k(e)?W(e):window,b=!Y()&&i,r=(a.left+(b?o.visualViewport.offsetLeft:0))/n,l=(a.top+(b?o.visualViewport.offsetTop:0))/c,d=a.width/n,f=a.height/c;return{width:d,height:f,top:l,right:r+d,bottom:l+f,left:r,x:r,y:l}}function L(e){return(t=e,(t instanceof W(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function v(e){return k(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function C(e){return X(L(e)).left+v(e).scrollLeft}function R(e,t,i){const a=x(t),n=L(t),c=X(e,a&&function(e){const t=X(e);return N(t.width)!==e.offsetWidth||N(t.height)!==e.offsetHeight}(t),"fixed"===i);let o={scrollLeft:0,scrollTop:0};const b={x:0,y:0};if(a||!a&&"fixed"!==i)if(("body"!==G(t)||I(n))&&(o=v(t)),x(t)){const e=X(t,!0);b.x=e.x+t.clientLeft,b.y=e.y+t.clientTop}else n&&(b.x=C(n));return{x:c.left+o.scrollLeft-b.x,y:c.top+o.scrollTop-b.y,width:c.width,height:c.height}}function D(e){return"html"===G(e)?e:e.assignedSlot||e.parentNode||(Q(e)?e.host:null)||L(e)}function V(e){return x(e)&&"fixed"!==getComputedStyle(e).position?e.offsetParent:null}function U(e){const t=W(e);let i=V(e);for(;i&&h(i)&&"static"===getComputedStyle(i).position;)i=V(i);return i&&("html"===G(i)||"body"===G(i)&&"static"===getComputedStyle(i).position&&!F(i))?t:i||function(e){let t=D(e);for(Q(t)&&(t=t.host);x(t)&&!["html","body"].includes(G(t));){if(F(t))return t;t=t.parentNode}return null}(e)||t}function w(e){if(x(e))return{width:e.offsetWidth,height:e.offsetHeight};const t=X(e);return{width:t.width,height:t.height}}function A(e){const t=D(e);return["html","body","#document"].includes(G(t))?e.ownerDocument.body:x(t)&&I(t)?t:A(t)}function j(e,t){var i;void 0===t&&(t=[]);const a=A(e),n=a===(null==(i=e.ownerDocument)?void 0:i.body),c=W(a),o=n?[c].concat(c.visualViewport||[],I(a)?a:[]):a,b=t.concat(o);return n?b:b.concat(j(D(o)))}function _(e,t,i){return"viewport"===t?o(function(e,t){const i=W(e),a=L(e),n=i.visualViewport;let c=a.clientWidth,o=a.clientHeight,b=0,r=0;if(n){c=n.width,o=n.height;const e=Y();(e||!e&&"fixed"===t)&&(b=n.offsetLeft,r=n.offsetTop)}return{width:c,height:o,x:b,y:r}}(e,i)):k(t)?function(e,t){const i=X(e,!1,"fixed"===t),a=i.top+e.clientTop,n=i.left+e.clientLeft;return{top:a,left:n,x:n,y:a,right:n+e.clientWidth,bottom:a+e.clientHeight,width:e.clientWidth,height:e.clientHeight}}(t,i):o(function(e){var t;const i=L(e),a=v(e),n=null==(t=e.ownerDocument)?void 0:t.body,c=B(i.scrollWidth,i.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),o=B(i.scrollHeight,i.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0);let b=-a.scrollLeft+C(e);const r=-a.scrollTop;return"rtl"===p(n||i).direction&&(b+=B(i.clientWidth,n?n.clientWidth:0)-c),{width:c,height:o,x:b,y:r}}(L(e)))}function J(e){const t=j(e),i=["absolute","fixed"].includes(p(e).position)&&x(e)?U(e):e;return k(i)?t.filter(e=>k(e)&&function(e,t){const i=null==t.getRootNode?void 0:t.getRootNode();if(e.contains(t))return!0;if(i&&Q(i)){let i=t;do{if(i&&e===i)return!0;i=i.parentNode||i.host}while(i)}return!1}(e,i)&&"body"!==G(e)):[]}const E={getClippingRect:function(e){let{element:t,boundary:i,rootBoundary:a,strategy:n}=e;const c=[..."clippingAncestors"===i?J(t):[].concat(i),a],o=c.reduce((e,i)=>{const a=_(t,i,n);return e.top=B(a.top,e.top),e.right=y(a.right,e.right),e.bottom=y(a.bottom,e.bottom),e.left=B(a.left,e.left),e},_(t,c[0],n));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{rect:t,offsetParent:i,strategy:a}=e;const n=x(i),c=L(i);if(i===c)return t;let o={scrollLeft:0,scrollTop:0};const b={x:0,y:0};if((n||!n&&"fixed"!==a)&&(("body"!==G(i)||I(c))&&(o=v(i)),x(i))){const e=X(i,!0);b.x=e.x+i.clientLeft,b.y=e.y+i.clientTop}return{...t,x:t.x-o.scrollLeft+b.x,y:t.y-o.scrollTop+b.y}},isElement:k,getDimensions:w,getOffsetParent:U,getDocumentElement:L,getElementRects:e=>{let{reference:t,floating:i,strategy:a}=e;return{reference:R(t,U(i),a),floating:{...w(i),x:0,y:0}}},getClientRects:e=>Array.from(e.getClientRects()),isRTL:e=>"rtl"===p(e).direction};var H=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],O=/* #__PURE__ */H.join(","),S="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,M=function(e,t,i){var a=Array.prototype.slice.apply(e.querySelectorAll(O));return t&&S.call(e,O)&&a.unshift(e),a.filter(i)},T=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?function(e){return"true"===e.contentEditable}(e)?0:"AUDIO"!==e.nodeName&&"VIDEO"!==e.nodeName&&"DETAILS"!==e.nodeName||null!==e.getAttribute("tabindex")?e.tabIndex:0:t},z=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},K=function(e){return"INPUT"===e.tagName},P=function(e,t){return!(t.disabled||function(e){return K(e)&&"hidden"===e.type}(t)||function(e,t){if("hidden"===getComputedStyle(e).visibility)return!0;var i=S.call(e,"details>summary:first-of-type");if(S.call(i?e.parentElement:e,"details:not([open]) *"))return!0;if(t&&"full"!==t){if("non-zero-area"===t){var a=e.getBoundingClientRect();return 0===a.width&&0===a.height}}else for(;e;){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(t,e.displayCheck)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(e){return"SUMMARY"===e.tagName})}(t)||function(e){if(K(e)||"SELECT"===e.tagName||"TEXTAREA"===e.tagName||"BUTTON"===e.tagName)for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var i=0;i0){var t=ne[ne.length-1];t!==e&&t.pause()}var i=ne.indexOf(e);-1===i||ne.splice(i,1),ne.push(e)},deactivateTrap:function(e){var t=ne.indexOf(e);-1!==t&&ne.splice(t,1),ne.length>0&&ne[ne.length-1].unpause()}}),be=function(e){return setTimeout(e,0)},re=function(e,t){var i=-1;return e.every(function(e,a){return!t(e)||(i=a,!1)}),i},le=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),a=1;a1?i-1:0),o=1;o0)return{container:e,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1],nextTabbableNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=c.findIndex(function(t){return t===e});return t?c.slice(i+1).find(function(e){return $(e)}):c.slice(0,i).reverse().find(function(e){return $(e)})}}}).filter(function(e){return!!e}),c.tabbableGroups.length<=0&&!r("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},f=function e(t){!1!==t&&t!==a.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!n.preventScroll}),c.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(l()))},s=function(e){var t=r("setReturnFocus",e);return t||!1!==t&&e},u=function(e){var t=de(e);b(t)||(le(n.clickOutsideDeactivates,e)?i.deactivate({returnFocus:n.returnFocusOnDeactivate&&!te(t)}):le(n.allowOutsideClick,e)||e.preventDefault())},m=function(e){var t=de(e),i=b(t);i||t instanceof Document?i&&(c.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),f(c.mostRecentlyFocusedNode||l()))},Z=function(e){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e)&&!1!==le(n.escapeDeactivates,e))return e.preventDefault(),void i.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){var t=de(e);d();var i=null;if(c.tabbableGroups.length>0){var a=re(c.tabbableGroups,function(e){return e.container.contains(t)}),n=a>=0?c.tabbableGroups[a]:void 0;if(a<0)i=e.shiftKey?c.tabbableGroups[c.tabbableGroups.length-1].lastTabbableNode:c.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var o=re(c.tabbableGroups,function(e){return t===e.firstTabbableNode});o<0&&(n.container===t||te(t)&&!$(t)&&!n.nextTabbableNode(t,!1))&&(o=a),o>=0&&(i=c.tabbableGroups[0===o?c.tabbableGroups.length-1:o-1].lastTabbableNode)}else{var b=re(c.tabbableGroups,function(e){return t===e.lastTabbableNode});b<0&&(n.container===t||te(t)&&!$(t)&&!n.nextTabbableNode(t))&&(b=a),b>=0&&(i=c.tabbableGroups[b===c.tabbableGroups.length-1?0:b+1].firstTabbableNode)}}else i=r("fallbackFocus");i&&(e.preventDefault(),f(i))}(e)},g=function(e){if(!le(n.clickOutsideDeactivates,e)){var t=de(e);b(t)||le(n.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},W=function(){if(c.active)return oe.activateTrap(i),c.delayInitialFocusTimer=n.delayInitialFocus?be(function(){f(l())}):f(l()),a.addEventListener("focusin",m,!0),a.addEventListener("mousedown",u,{capture:!0,passive:!1}),a.addEventListener("touchstart",u,{capture:!0,passive:!1}),a.addEventListener("click",g,{capture:!0,passive:!1}),a.addEventListener("keydown",Z,{capture:!0,passive:!1}),i},p=function(){if(c.active)return a.removeEventListener("focusin",m,!0),a.removeEventListener("mousedown",u,!0),a.removeEventListener("touchstart",u,!0),a.removeEventListener("click",g,!0),a.removeEventListener("keydown",Z,!0),i};return(i={activate:function(e){if(c.active)return this;var t=o(e,"onActivate"),i=o(e,"onPostActivate"),n=o(e,"checkCanFocusTrap");n||d(),c.active=!0,c.paused=!1,c.nodeFocusedBeforeActivation=a.activeElement,t&&t();var b=function(){n&&d(),W(),i&&i()};return n?(n(c.containers.concat()).then(b,b),this):(b(),this)},deactivate:function(e){if(!c.active)return this;clearTimeout(c.delayInitialFocusTimer),c.delayInitialFocusTimer=void 0,p(),c.active=!1,c.paused=!1,oe.deactivateTrap(i);var t=o(e,"onDeactivate"),a=o(e,"onPostDeactivate"),n=o(e,"checkCanReturnFocus");t&&t();var b=o(e,"returnFocus","returnFocusOnDeactivate"),r=function(){be(function(){b&&f(s(c.nodeFocusedBeforeActivation)),a&&a()})};return b&&n?(n(s(c.nodeFocusedBeforeActivation)).then(r,r),this):(r(),this)},pause:function(){return c.paused||!c.active||(c.paused=!0,p()),this},unpause:function(){return c.paused&&c.active?(c.paused=!1,d(),W(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return c.containers=t.map(function(e){return"string"==typeof e?a.querySelector(e):e}),c.active&&d(),this}}).updateContainerElements(e),i}(ue,{initialFocus:"#feedbackfin__radio--issue",allowOutsideClick:!0});function Ze(e){var i;document.body.appendChild(ue),ue.innerHTML="nps"===fe.mode?'

How satisfied are you with your experience?

Thanks for your feedback!
':'

Send feedback

Thanks for your feedback!
',ue.style.display="block",((e,t,i)=>(async(e,t,i)=>{const{placement:a="bottom",strategy:n="absolute",middleware:o=[],platform:b}=i,r=await(null==b.isRTL?void 0:b.isRTL(t));let l=await b.getElementRects({reference:e,floating:t,strategy:n}),{x:d,y:f}=c(l,a,r),s=a,u={};for(let i=0;i{let{x:t,y:i}=e;return{x:t,y:i}}},...s}=i,u={x:n,y:c},m=await b(e,s),Z=a(t(o)),g="x"===Z?"y":"x";let W=u[Z],p=u[g];r&&(W=d(W+m["y"===Z?"top":"left"],W,W-m["y"===Z?"bottom":"right"])),l&&(p=d(p+m["y"===g?"top":"left"],p,p-m["y"===g?"bottom":"right"]));const G=f.fn({...e,[Z]:W,[g]:p});return{...G,data:{x:G.x-n,y:G.y-c}}}})],strategy:"fixed"}).then(function(e){Object.assign(ue.style,{left:e.x+"px",top:e.y+"px"})}),me.activate(),document.getElementById("feedbackfin__close").addEventListener("click",ge),Array.from(ue.getElementsByClassName("feedbackfin__radio")).forEach(function(e){e.addEventListener("change",We)}),document.getElementById("feedbackfin__form").addEventListener("submit",Ge),document.getElementById("feedbackfin__back").addEventListener("click",pe)}function ge(){me.deactivate(),ue.innerHTML="",ue.remove(),ue.removeAttribute("data-feedback-type"),ue.removeAttribute("data-success")}function We(e){var t,i,a=e.target.value;ue.setAttribute("data-feedback-type",a),i="issue"===a?"I’m having an issue with…":"idea"===a?"I’d like to see…":"Anything else you'd like to share?",null==(t=document.getElementById("feedbackfin__message"))||t.setAttribute("placeholder",i)}function pe(){ue.removeAttribute("data-feedback-type")}function Ge(t){t.preventDefault();var i=t.target;if(!fe.url)return console.error("Feedback Fin: No URL provided"),void(fe.disableErrorAlert||alert("Could not send feedback: No URL provided"));var a=document.getElementById("feedbackfin__submit");a.setAttribute("disabled",""),a.innerHTML="Sending…";var n=new Headers;n.append("Content-Type","application/json");var c=e({},fe.user,{feedbackType:i.elements.feedbackType.value,message:i.elements.message.value,timestamp:Date.now()});return fetch(fe.url,{method:"POST",headers:n,body:JSON.stringify(c)}).then(function(){ue.setAttribute("data-success","")}).catch(function(e){console.error("Feedback Fin:",e),fe.disableErrorAlert||alert("Could not send feedback: "+e.message)}),!1}var xe={init:se,open:Ze,changeType:We,close:ge,submit:Ge,config:fe};return window.feedbackfin=xe,xe}); //# sourceMappingURL=index.umd.js.map