Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@formbricks/js

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formbricks/js - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

./dist/index.js

0

dist/App.d.ts

@@ -0,0 +0,0 @@ import { VNode } from "preact";

@@ -0,0 +0,0 @@ import { h } from "preact";

@@ -0,0 +0,0 @@ import { h, VNode } from "preact";

@@ -0,0 +0,0 @@ import { h } from "preact";

@@ -0,0 +0,0 @@ import { h } from "preact";

@@ -0,0 +0,0 @@ import { h } from "preact";

@@ -0,0 +0,0 @@ import { h } from "preact";

@@ -0,0 +0,0 @@ import { h } from "preact";

@@ -0,0 +0,0 @@ import { InitConfig } from "@formbricks/types/js";

2

dist/index.js

@@ -1,2 +0,2 @@

function e(n,r,o){if(!n.s){if(o instanceof t){if(!o.s)return void(o.o=e.bind(null,n,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(e.bind(null,n,r),e.bind(null,n,2));n.s=r,n.v=o;var i=n.o;i&&i(n)}}var t=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(n,r){var o=new t,i=this.s;if(i){var s=1&i?n:r;if(s){try{e(o,1,s(this.v))}catch(t){e(o,2,t)}return o}return this}return this.o=function(t){try{var i=t.v;1&t.s?e(o,1,n?n(i):i):r?e(o,1,r(i)):e(o,2,i)}catch(t){e(o,2,t)}},o},t}();function n(e){return e instanceof t&&1&e.s}var r=/*#__PURE__*/function(){function r(){this.queue=[],this.running=!1}var o=r.prototype;return o.add=function(e){this.queue.push(e),this.running||this.run()},o.run=function(){try{var r=function(){o.running=!1},o=this;o.running=!0;var i=function(r,o,i){for(var s;;){var a=r();if(n(a)&&(a=a.v),!a)return f;if(a.then){s=0;break}var f=i();if(f&&f.then){if(!n(f)){s=1;break}f=f.s}}var l=new t,u=e.bind(null,l,2);return(0===s?a.then(d):1===s?f.then(c):(void 0).then(function(){(a=r())?a.then?a.then(d).then(void 0,u):d(a):e(l,1,f)})).then(void 0,u),l;function c(t){f=t;do{if(!(a=r())||n(a)&&!a.v)return void e(l,1,f);if(a.then)return void a.then(d).then(void 0,u);n(f=i())&&(f=f.v)}while(!f||!f.then);f.then(c).then(void 0,u)}function d(t){t?(f=i())&&f.then?f.then(c).then(void 0,u):c(f):e(l,1,f)}}(function(){return o.queue.length>0},0,function(){var e=o.queue.shift(),t=function(t,n){try{var r=Promise.resolve(e()).then(function(){})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){console.error(e)});if(t&&t.then)return t.then(function(){})});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},r}();function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,f,l,u,c,d={},b=[],p=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function h(e,t){for(var n in t)e[n]=t[n];return e}function g(e){var t=e.parentNode;t&&t.removeChild(e)}function _(e,t,n){var r,o,i,s=arguments,a={};for(i in t)"key"==i?r=t[i]:"ref"==i?o=t[i]:a[i]=t[i];if(arguments.length>3)for(n=[n],i=3;i<arguments.length;i++)n.push(s[i]);if(null!=n&&(a.children=n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===a[i]&&(a[i]=e.defaultProps[i]);return v(e,a,r,o,null)}function v(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++a.__v:o};return null!=a.vnode&&a.vnode(i),i}function m(e){return e.children}function w(e,t){this.props=e,this.context=t}function y(e,t){if(null==t)return e.__?y(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?y(e):null}function j(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return j(e)}}function x(e){(!e.__d&&(e.__d=!0)&&f.push(e)&&!k.__r++||u!==a.debounceRendering)&&((u=a.debounceRendering)||l)(k)}function k(){for(var e;k.__r=f.length;)e=f.sort(function(e,t){return e.__v.__b-t.__v.__b}),f=[],e.some(function(e){var t,n,r,o,i,s,a;e.__d&&(s=(i=(t=e).__v).__e,(a=t.__P)&&(n=[],(r=h({},i)).__v=i.__v+1,o=H(a,i,r,t.__n,void 0!==a.ownerSVGElement,null!=i.__h?[s]:null,n,null==s?y(i):s,i.__h),z(n,i),o!=s&&j(i)))})}function P(e,t,n,r,o,i,s,a,f,l){var u,c,p,h,_,w,j,x=r&&r.__k||b,k=x.length;for(f==d&&(f=null!=s?s[0]:k?y(r,0):null),n.__k=[],u=0;u<t.length;u++)if(null!=(h=n.__k[u]=null==(h=t[u])||"boolean"==typeof h?null:"string"==typeof h||"number"==typeof h?v(null,h,null,null,h):Array.isArray(h)?v(m,{children:h},null,null,null):null!=h.__e||null!=h.__c?v(h.type,h.props,h.key,null,h.__v):h)){if(h.__=n,h.__b=n.__b+1,null===(p=x[u])||p&&h.key==p.key&&h.type===p.type)x[u]=void 0;else for(c=0;c<k;c++){if((p=x[c])&&h.key==p.key&&h.type===p.type){x[c]=void 0;break}p=null}_=H(e,h,p=p||d,o,i,s,a,f,l),(c=h.ref)&&p.ref!=c&&(j||(j=[]),p.ref&&j.push(p.ref,null,h),j.push(c,h.__c||_,h)),null!=_?(null==w&&(w=_),f=S(e,h,p,x,s,_,f),l||"option"!=n.type?"function"==typeof n.type&&(n.__d=f):e.value=""):f&&p.__e==f&&f.parentNode!=e&&(f=y(p))}if(n.__e=w,null!=s&&"function"!=typeof n.type)for(u=s.length;u--;)null!=s[u]&&g(s[u]);for(u=k;u--;)null!=x[u]&&q(x[u],x[u]);if(j)for(u=0;u<j.length;u++)F(j[u],j[++u],j[++u])}function S(e,t,n,r,o,i,s){var a,f,l;if(void 0!==t.__d)a=t.__d,t.__d=void 0;else if(o==n||i!=s||null==i.parentNode)e:if(null==s||s.parentNode!==e)e.appendChild(i),a=null;else{for(f=s,l=0;(f=f.nextSibling)&&l<r.length;l+=2)if(f==i)break e;e.insertBefore(i,s),a=s}return void 0!==a?a:i.nextSibling}function I(e,t,n){"-"===t[0]?e.setProperty(t,n):e[t]=null==n?"":"number"!=typeof n||p.test(t)?n:n+"px"}function C(e,t,n,r,o){var i,s,a;if(o&&"className"==t&&(t="class"),"style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||I(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||I(e.style,t,n[t])}else"o"===t[0]&&"n"===t[1]?(i=t!==(t=t.replace(/Capture$/,"")),(s=t.toLowerCase())in e&&(t=s),t=t.slice(2),e.l||(e.l={}),e.l[t+i]=n,a=i?N:E,n?r||e.addEventListener(t,a,i):e.removeEventListener(t,a,i)):"list"!==t&&"tagName"!==t&&"form"!==t&&"type"!==t&&"size"!==t&&"download"!==t&&"href"!==t&&!o&&t in e?e[t]=null==n?"":n:"function"!=typeof n&&"dangerouslySetInnerHTML"!==t&&(t!==(t=t.replace(/xlink:?/,""))?null==n||!1===n?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),n):null==n||!1===n&&!/^ar/.test(t)?e.removeAttribute(t):e.setAttribute(t,n))}function E(e){this.l[e.type+!1](a.event?a.event(e):e)}function N(e){this.l[e.type+!0](a.event?a.event(e):e)}function T(e,t,n){var r,o;for(r=0;r<e.__k.length;r++)(o=e.__k[r])&&(o.__=e,o.__e&&("function"==typeof o.type&&o.__k.length>1&&T(o,t,n),t=S(n,o,o,e.__k,null,o.__e,t),"function"==typeof e.type&&(e.__d=t)))}function H(e,t,n,r,o,i,s,f,l){var u,c,p,g,_,v,y,j,x,k,S,I=t.type;if(void 0!==t.constructor)return null;null!=n.__h&&(l=n.__h,f=t.__e=n.__e,t.__h=null,i=[f]),(u=a.__b)&&u(t);try{e:if("function"==typeof I){if(j=t.props,x=(u=I.contextType)&&r[u.__c],k=u?x?x.props.value:u.__:r,n.__c?y=(c=t.__c=n.__c).__=c.__E:("prototype"in I&&I.prototype.render?t.__c=c=new I(j,k):(t.__c=c=new w(j,k),c.constructor=I,c.render=L),x&&x.sub(c),c.props=j,c.state||(c.state={}),c.context=k,c.__n=r,p=c.__d=!0,c.__h=[]),null==c.__s&&(c.__s=c.state),null!=I.getDerivedStateFromProps&&(c.__s==c.state&&(c.__s=h({},c.__s)),h(c.__s,I.getDerivedStateFromProps(j,c.__s))),g=c.props,_=c.state,p)null==I.getDerivedStateFromProps&&null!=c.componentWillMount&&c.componentWillMount(),null!=c.componentDidMount&&c.__h.push(c.componentDidMount);else{if(null==I.getDerivedStateFromProps&&j!==g&&null!=c.componentWillReceiveProps&&c.componentWillReceiveProps(j,k),!c.__e&&null!=c.shouldComponentUpdate&&!1===c.shouldComponentUpdate(j,c.__s,k)||t.__v===n.__v){c.props=j,c.state=c.__s,t.__v!==n.__v&&(c.__d=!1),c.__v=t,t.__e=n.__e,t.__k=n.__k,c.__h.length&&s.push(c),T(t,f,e);break e}null!=c.componentWillUpdate&&c.componentWillUpdate(j,c.__s,k),null!=c.componentDidUpdate&&c.__h.push(function(){c.componentDidUpdate(g,_,v)})}c.context=k,c.props=j,c.state=c.__s,(u=a.__r)&&u(t),c.__d=!1,c.__v=t,c.__P=e,u=c.render(c.props,c.state,c.context),c.state=c.__s,null!=c.getChildContext&&(r=h(h({},r),c.getChildContext())),p||null==c.getSnapshotBeforeUpdate||(v=c.getSnapshotBeforeUpdate(g,_)),S=null!=u&&u.type==m&&null==u.key?u.props.children:u,P(e,Array.isArray(S)?S:[S],t,n,r,o,i,s,f,l),c.base=t.__e,t.__h=null,c.__h.length&&s.push(c),y&&(c.__E=c.__=null),c.__e=!1}else null==i&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,r,o,i,s,a){var f,l,u,c,p,h=n.props,g=t.props;if(o="svg"===t.type||o,null!=i)for(f=0;f<i.length;f++)if(null!=(l=i[f])&&((null===t.type?3===l.nodeType:l.localName===t.type)||e==l)){e=l,i[f]=null;break}if(null==e){if(null===t.type)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",t.type):document.createElement(t.type,g.is&&{is:g.is}),i=null,a=!1}if(null===t.type)h===g||a&&e.data===g||(e.data=g);else{if(null!=i&&(i=b.slice.call(e.childNodes)),u=(h=n.props||d).dangerouslySetInnerHTML,c=g.dangerouslySetInnerHTML,!a){if(null!=i)for(h={},p=0;p<e.attributes.length;p++)h[e.attributes[p].name]=e.attributes[p].value;(c||u)&&(c&&(u&&c.__html==u.__html||c.__html===e.innerHTML)||(e.innerHTML=c&&c.__html||""))}(function(e,t,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in t||C(e,i,null,n[i],r);for(i in t)o&&"function"!=typeof t[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===t[i]||C(e,i,t[i],n[i],r)})(e,g,h,o,a),c?t.__k=[]:(f=t.props.children,P(e,Array.isArray(f)?f:[f],t,n,r,"foreignObject"!==t.type&&o,i,s,d,a)),a||("value"in g&&void 0!==(f=g.value)&&(f!==e.value||"progress"===t.type&&!f)&&C(e,"value",f,h.value,!1),"checked"in g&&void 0!==(f=g.checked)&&f!==e.checked&&C(e,"checked",f,h.checked,!1))}return e}(n.__e,t,n,r,o,i,s,l);(u=a.diffed)&&u(t)}catch(e){t.__v=null,(l||null!=i)&&(t.__e=f,t.__h=!!l,i[i.indexOf(f)]=null),a.__e(e,t,n)}return t.__e}function z(e,t){a.__c&&a.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){a.__e(e,t.__v)}})}function F(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){a.__e(e,n)}}function q(e,t,n){var r,o,i;if(a.unmount&&a.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||F(r,null,t)),n||"function"==typeof e.type||(n=null!=(o=e.__e)),e.__e=e.__d=void 0,null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){a.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&q(r[i],t,n);null!=o&&g(o)}function L(e,t,n){return this.constructor(e,n)}a={__e:function(e,t){for(var n,r,o,i=t.__h;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e),o=n.__d),o)return t.__h=i,n.__E=n}catch(t){e=t}throw e},__v:0},w.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(h({},n),this.props)),e&&h(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),x(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),x(this))},w.prototype.render=m,f=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,k.__r=0,c=d;var O,A,U,M=0,D=[],W=a.__b,J=a.__r,B=a.diffed,R=a.__c,Q=a.unmount;function G(e,t){a.__h&&a.__h(A,e,M||t),M=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return M=1,function(e,t,n){var r=G(O++,2);return r.t=e,r.__c||(r.__=[ee(void 0,t),function(e){var t=r.t(r.__[0],e);r.__[0]!==t&&(r.__=[t,r.__[1]],r.__c.setState({}))}],r.__c=A),r.__}(ee,e)}function $(e,t){var n=G(O++,3);!a.__s&&function(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}(n.__H,t)&&(n.__=e,n.__H=t,A.__H.__h.push(n))}function V(){D.forEach(function(e){if(e.__P)try{e.__H.__h.forEach(K),e.__H.__h.forEach(Z),e.__H.__h=[]}catch(t){e.__H.__h=[],a.__e(t,e.__v)}}),D=[]}a.__b=function(e){A=null,W&&W(e)},a.__r=function(e){J&&J(e),O=0;var t=(A=e.__c).__H;t&&(t.__h.forEach(K),t.__h.forEach(Z),t.__h=[])},a.diffed=function(e){B&&B(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==D.push(t)&&U===a.requestAnimationFrame||((U=a.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),X&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);X&&(t=requestAnimationFrame(n))})(V)),A=void 0},a.__c=function(e,t){t.some(function(e){try{e.__h.forEach(K),e.__h=e.__h.filter(function(e){return!e.__||Z(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],a.__e(n,e.__v)}}),R&&R(e,t)},a.unmount=function(e){Q&&Q(e);var t=e.__c;if(t&&t.__H)try{t.__H.__.forEach(K)}catch(e){a.__e(e,t.__v)}};var X="function"==typeof requestAnimationFrame;function K(e){var t=A;"function"==typeof e.__c&&e.__c(),A=t}function Z(e){var t=A;e.__c=e.__(),A=t}function ee(e,t){return"function"==typeof t?t(e):t}var te=function(){return[].slice.call(arguments).filter(Boolean).join(" ")};function ne(e){var t=e.children,n=e.isOpen,r=e.close,o=Y(!1),i=o[0],s=o[1];return $(function(){s(n)},[n]),_("div",{"aria-live":"assertive",className:"fb-pointer-events-none fb-fixed fb-inset-0 fb-flex fb-items-end fb-px-4 fb-py-6 sm:fb-p-6"},_("div",{className:"fb-flex fb-w-full fb-flex-col fb-items-center fb-space-y-4 sm:fb-items-end"},_("div",{className:te(i?"fb-translate-x-0 fb-opacity-100":"fb-translate-x-28 fb-opacity-0","fb-pointer-events-auto fb-relative fb-w-full fb-max-w-sm fb-overflow-hidden fb-rounded-lg fb-bg-white fb-shadow-lg fb-ring-1 fb-ring-black fb-ring-opacity-5 fb-transition-all fb-duration-500 fb-ease-in-out")},_("div",{class:"fb-absolute fb-top-0 fb-right-0 fb-hidden fb-pt-4 fb-pr-4 sm:fb-block"},_("button",{type:"button",onClick:r,class:"fb-rounded-md fb-bg-white focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 fb-text-slate-400 hover:fb-text-slate-500 focus:ring-slate-500"},_("span",{class:"fb-sr-only"},"Close"),_("svg",{class:"fb-h-6 fb-w-6",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},_("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})))),_("div",{className:""},t))))}var re=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays/"+e+"/responded",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){if(!e.ok)throw new Error("Could not update display")})}catch(e){return Promise.reject(e)}},oe=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/responses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function ie(e){return _("label",{htmlFor:e.questionId,className:"fb-block fb-text-base fb-font-semibold fb-leading-6 fb-mr-8 text-slate-900"},e.headline)}function se(e){return _("label",{for:e.questionId,className:"fb-block fb-text-sm fb-font-normal fb-leading-6 text-slate-600"},e.subheader)}function ae(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor;return _("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},_(ie,{headline:t.headline,questionId:t.id}),_(se,{subheader:t.subheader,questionId:t.id}),_("div",{className:"fb-mt-4"},_("textarea",{rows:3,name:t.id,id:t.id,placeholder:t.placeholder,required:t.required,className:"fb-block fb-w-full fb-rounded-md fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm fb-bg-slate-50 fb-border-slate-100 focus:fb-border-slate-500"})),_("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},_("div",null),_("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:fb-ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function fe(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor,i=Y(null),s=i[0],a=i[1];return _("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},_(ie,{headline:t.headline,questionId:t.id}),_(se,{subheader:t.subheader,questionId:t.id}),_("div",{className:"fb-mt-4"},_("fieldset",null,_("legend",{className:"fb-sr-only"},"Choices"),_("div",{className:"fb-relative fb-space-y-2 fb-rounded-md fb-bg-white"},t.choices&&t.choices.map(function(e){return _("label",{key:e.id,className:te(s===e.label?"fb-z-10 fb-bg-slate-50 fb-border-slate-400":"fb-border-gray-200","fb-relative fb-flex fb-cursor-pointer fb-flex-col fb-rounded-md fb-border fb-p-4 focus:fb-outline-none hover:bg-slate-50")},_("span",{className:"fb-flex fb-items-center fb-text-sm"},_("input",{type:"radio",id:e.id,name:t.id,value:e.label,className:"fb-h-4 fb-w-4 fb-border fb-border-slate-300 focus:fb-ring-0 focus:fb-ring-offset-0","aria-labelledby":e.id+"-label",onChange:function(e){a(e.currentTarget.value)},style:{borderColor:o,color:o}}),_("span",{id:e.id+"-label",className:"fb-ml-3 fb-font-medium"},e.label)))})))),_("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},_("div",null),_("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function le(e){return _("div",{className:"fb-h-1 fb-w-full fb-rounded-full bg-slate-200"},_("div",{className:"fb-h-1 fb-rounded-full",style:{backgroundColor:e.brandColor,width:Math.floor(100*e.progress)+"%"}}))}function ue(e){var t=e.config,n=e.survey,r=e.close,o=e.brandColor,i=Y(n.questions[0]),s=i[0],a=i[1],f=Y(0),l=f[0],u=f[1],c=Y(null),d=c[0],b=c[1],p=Y(null),h=p[0],g=p[1],v=Y(!1),m=v[0],w=v[1];$(function(){!function(){try{Promise.resolve(function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create display");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}({surveyId:n.id,personId:t.person.id},t)).then(function(e){g(e.id)})}catch(e){return Promise.reject(e)}}()},[t,n]),$(function(){var e;u((e=n.questions.findIndex(function(e){return e.id===s.id}),e/n.questions.length))},[s,n]);var y=function(e){try{var o=function(){w(!1),f?(u(100),r()):a(n.questions[i+1])};w(!0);var i=n.questions.findIndex(function(e){return e.id===s.id}),f=i===n.questions.length-1,l={surveyId:n.id,personId:t.person.id,response:{finished:f,data:e}},c=d?Promise.resolve(function(e,t,n){try{return Promise.resolve(fetch(n.apiHost+"/api/v1/client/environments/"+n.environmentId+"/responses/"+t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw new Error("Could not update response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}(l,d,t)).then(function(){}):Promise.resolve(Promise.all([oe(l,t),re(h,t)])).then(function(e){b(e[0].id)});return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}};return _("div",null,_("div",{className:te(m?"fb-animate-pulse fb-opacity-60":"","fb-p-4 fb-text-slate-800 fb-font-sans")},"multipleChoiceSingle"===s.type?_(fe,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):"openText"===s.type?_(ae,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):null),_("div",{className:"fb-mt-2"},_(le,{progress:l,brandColor:o})))}function ce(e){var t,n=e.config,r=e.survey,o=e.closeSurvey,i=Y(!0),s=i[1],a=function(){s(!1),setTimeout(function(){o()},1e3)};return _("div",{id:"fbjs"},_(ne,{isOpen:i[0],close:a},_(ue,{config:n,survey:r,close:a,brandColor:null==(t=n.settings)?void 0:t.brandColor})))}var de=/*#__PURE__*/function(){function e(){this.config=this.loadFromLocalStorage()}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.update=function(e){e&&(this.config=o({},this.config,e),this.saveToLocalStorage())},t.get=function(){return this.config},t.loadFromLocalStorage=function(){if("undefined"!=typeof window){var e=localStorage.getItem("config");if(e)return JSON.parse(e)}return{apiHost:null,environmentId:null}},t.saveToLocalStorage=function(){localStorage.setItem("config",JSON.stringify(this.config))},e}();de.instance=void 0;var be=/*#__PURE__*/function(){function e(){this.logLevel="error"}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.configure=function(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)},t.logger=function(e,t){if("debug"!==t||"debug"===this.logLevel){var n="🧱 Formbricks - "+(new Date).toISOString()+" ["+t.toUpperCase()+"] - "+e;"error"===t?console.error(n):console.log(n)}},t.debug=function(e){this.logger(e,"debug")},t.error=function(e){this.logger(e,"error")},e}();be.instance=void 0;var pe=be.getInstance(),he=de.getInstance(),ge=function(){try{return Promise.resolve(fetch(he.get().apiHost+"/api/v1/client/environments/"+he.get().environmentId+"/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:he.get().person.id})})).then(function(e){if(!e.ok)throw pe.error("Error getting settings"),Error("Error getting settings");return e.json()})}catch(e){return Promise.reject(e)}},_e="formbricks-web-container",ve=de.getInstance(),me=be.getInstance(),we=!1,ye=function(e){we?me.debug("A survey is already running. Skipping."):(we=!0,function(e,t,n){var r,o,i;a.__&&a.__(e,t),o=(r=void 0===c)?null:t.__k,e=_(m,null,[e]),i=[],H(t,t.__k=e,o||d,d,void 0!==t.ownerSVGElement,o?null:t.childNodes.length?b.slice.call(t.childNodes):null,i,d,r),z(i,e)}(_(ce,{config:ve.get(),survey:e,closeSurvey:je}),document.getElementById(_e)))},je=function(){try{return console.log("close survey called"),document.getElementById(_e).remove(),xe(),Promise.resolve(ge()).then(function(e){ve.update({settings:e}),we=!1})}catch(e){return Promise.reject(e)}},xe=function(){var e=document.createElement("div");e.id=_e,document.body.appendChild(e)},ke=be.getInstance(),Pe=de.getInstance(),Se=function(e,t){try{return Promise.resolve(fetch(Pe.get().apiHost+"/api/v1/client/environments/"+Pe.get().environmentId+"/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Pe.get().session.id,eventName:e,properties:t})})).then(function(t){var n;function r(t){if(n)return t;ke.debug('Formbricks: Event "'+e+'" tracked'),Ie(e)}var o=function(){if(!t.ok)return Promise.resolve(t.json()).then(function(e){ke.error("Formbricks: Error tracking event: "+JSON.stringify(e)),n=1})}();return o&&o.then?o.then(r):r(o)})}catch(e){return Promise.reject(e)}},Ie=function(e){for(var t,n=s(null==(r=Pe.get().settings)?void 0:r.surveys);!(t=n()).done;)for(var r,o,i=t.value,a=s(i.triggers);!(o=a()).done;){var f;if((null==(f=o.value.eventClass)?void 0:f.name)===e)return ke.debug("Formbricks: survey "+i.id+' triggered by event "'+e+'"'),void ye(i)}},Ce=de.getInstance(),Ee=be.getInstance(),Ne=function(){try{return Ee.debug("Creating new person"),Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){return e.ok?Promise.resolve(e.json()):(console.error("Formbricks: Error fetching person"),null)})}catch(e){return Promise.reject(e)}},Te=function(e,t){var n=Ce.get().person.attributes.find(function(t){var n;return(null==(n=t.attributeClass)?void 0:n.name)===e});return!(!n||n.value!==t)},He=be.getInstance(),ze=de.getInstance(),Fe=function(){try{return ze.get().person?Promise.resolve(fetch(ze.get().apiHost+"/api/v1/client/environments/"+ze.get().environmentId+"/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:ze.get().person.id})})).then(function(e){if(e.ok)return Promise.resolve(e.json());He.error("Error creating session")}):(He.error("Formbricks: Unable to create session. No person found"),Promise.resolve())}catch(e){return Promise.reject(e)}},qe=function(e){He.debug("Session expired. Creating new session.");var t=o({},e);return t.expiresAt=Date.now()+36e5,t},Le=function(e){return e.expiresAt<=Date.now()},Oe=de.getInstance(),Ae=be.getInstance(),Ue=function(){var e;Ae.debug("checking page url");var t=null==(e=Oe.get().settings)?void 0:e.noCodeEvents.filter(function(e){var t;return"pageUrl"===(null==(t=e.noCodeConfig)?void 0:t.type)});if(0!==t.length)for(var n,r=s(t);!(n=r()).done;){var o=n.value,i=o.noCodeConfig.pageUrl;i&&Me(window.location.href,i.value,i.rule)&&Se(o.name)}};function Me(e,t,n){switch(n){case"exactMatch":return e===t;case"contains":return e.includes(t);case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"notMatch":return e!==t;case"notContains":return!e.includes(t);default:throw new Error("Invalid match type")}}var De=de.getInstance(),We=be.getInstance(),Je=function(){if(!(De.get().apiHost&&De.get().environmentId&&De.get().person&&De.get().session&&De.get().settings))throw Error("Formbricks: Formbricks not initialized. Call initialize() first.")},Be=new r,Re=function(e,t){Be.add(function(){try{return Je(),Promise.resolve(function(e,t){try{return Ee.debug("setting attribute: "+e+" to value: "+t),Te(e,t)?(Ee.debug("attribute already set to this value. Skipping update."),Promise.resolve()):Promise.resolve(function(e,t){try{return Ce.get().person&&Ce.get().person.id?Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people/"+Ce.get().person.id+"/attribute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:t})})).then(function(e){return Promise.resolve(e.json()).then(function(t){if(!e.ok)throw Ee.error("Error updating person"),Error("Error updating person");return t})}):(console.error("Formbricks: Unable to update attribute. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e,t)).then(function(e){var t=e.person,n=e.settings;if(!t||!n)throw Ee.error("Error updating attribute"),new Error("Formbricks: Error updating attribute");Ce.update({person:t,settings:n})})}catch(e){return Promise.reject(e)}}(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},Qe={init:function(e){Be.add(function(){try{return function(e){try{var t,n=function(e){if(t)return e;(function(){if("undefined"!=typeof window){var e=window.setInterval(function(){try{return Promise.resolve(function(){try{var e=function(e){He.debug("Session not expired, extending session"),ze.update({session:qe(ze.get().session)})};He.debug("Checking session");var t=function(){if(Le(ze.get().session))return He.debug("Session expired, creating new session"),Promise.resolve(Fe()).then(function(e){var t=e.session,n=e.settings;if(!t||!n)throw He.error("Error creating new session"),Error("Error creating new session");ze.update({session:t,settings:n}),Se("New Session")})}();return Promise.resolve(t&&t.then?t.then(e):e())}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}},3e5);window.addEventListener("beforeunload",function(){clearInterval(e)})}})(),"undefined"!=typeof window&&(window.addEventListener("hashchange",Ue),window.addEventListener("popstate",Ue),window.addEventListener("pushstate",Ue),window.addEventListener("replacestate",Ue),window.addEventListener("load",Ue)),We.debug("Initialized")};if(!e.environmentId)throw Error("Formbricks: environmentId is required");if(!e.apiHost)throw Error("Formbricks: apiHost is required");e.logLevel&&We.configure({logLevel:e.logLevel}),xe(),function(){if(null===document.getElementById("formbricks__css")){var e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :after,#fbjs :before{border:0 solid #e5e7eb;box-sizing:border-box}#fbjs :after,#fbjs :before{--tw-content:""}#fbjs html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#fbjs body{line-height:inherit;margin:0}#fbjs hr{border-top-width:1px;color:inherit;height:0}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs pre,#fbjs samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{border-collapse:collapse;border-color:inherit;text-indent:0}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit],#fbjs button{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dd,#fbjs dl,#fbjs figure,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs menu,#fbjs ol,#fbjs ul{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{color:#9ca3af;opacity:1}#fbjs input::placeholder,#fbjs textarea::placeholder{color:#9ca3af;opacity:1}#fbjs [role=button],#fbjs button{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs audio,#fbjs canvas,#fbjs embed,#fbjs iframe,#fbjs img,#fbjs object,#fbjs svg,#fbjs video{display:block;vertical-align:middle}#fbjs img,#fbjs video{height:auto;max-width:100%}#fbjs [hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#fbjs .fb-sr-only{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}#fbjs .fb-pointer-events-none{pointer-events:none}#fbjs .fb-pointer-events-auto{pointer-events:auto}#fbjs .fb-fixed{position:fixed}#fbjs .fb-absolute{position:absolute}#fbjs .fb-relative{position:relative}#fbjs .fb-inset-0{bottom:0;left:0;right:0;top:0}#fbjs .fb-right-0{right:0}#fbjs .fb-top-0{top:0}#fbjs .fb-z-10{z-index:10}#fbjs .fb-ml-3{margin-left:.75rem}#fbjs .fb-mr-8{margin-right:2rem}#fbjs .fb-mt-2{margin-top:.5rem}#fbjs .fb-mt-4{margin-top:1rem}#fbjs .fb-block{display:block}#fbjs .fb-flex{display:flex}#fbjs .fb-hidden{display:none}#fbjs .fb-h-1{height:.25rem}#fbjs .fb-h-4{height:1rem}#fbjs .fb-h-6{height:1.5rem}#fbjs .fb-w-4{width:1rem}#fbjs .fb-w-6{width:1.5rem}#fbjs .fb-w-full{width:100%}#fbjs .fb-max-w-sm{max-width:24rem}#fbjs .fb-translate-x-0{--tw-translate-x:0px}#fbjs .fb-translate-x-0,#fbjs .fb-translate-x-28{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs .fb-translate-x-28{--tw-translate-x:7rem}@keyframes fb-pulse{50%{opacity:.5}}#fbjs .fb-animate-pulse{animation:fb-pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs .fb-cursor-pointer{cursor:pointer}#fbjs .fb-flex-col{flex-direction:column}#fbjs .fb-items-end{align-items:flex-end}#fbjs .fb-items-center{align-items:center}#fbjs .fb-justify-between{justify-content:space-between}#fbjs .fb-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}#fbjs .fb-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}#fbjs .fb-overflow-hidden{overflow:hidden}#fbjs .fb-rounded-full{border-radius:9999px}#fbjs .fb-rounded-lg{border-radius:.5rem}#fbjs .fb-rounded-md{border-radius:.375rem}#fbjs .fb-border{border-width:1px}#fbjs .fb-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}#fbjs .fb-border-slate-100{--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity))}#fbjs .fb-border-slate-300{--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}#fbjs .fb-border-slate-400{--tw-border-opacity:1;border-color:rgb(148 163 184/var(--tw-border-opacity))}#fbjs .fb-border-transparent{border-color:transparent}#fbjs .fb-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}#fbjs .fb-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}#fbjs .fb-p-2{padding:.5rem}#fbjs .fb-p-4{padding:1rem}#fbjs .fb-px-3{padding-left:.75rem;padding-right:.75rem}#fbjs .fb-px-4{padding-left:1rem;padding-right:1rem}#fbjs .fb-py-3{padding-bottom:.75rem;padding-top:.75rem}#fbjs .fb-py-6{padding-bottom:1.5rem;padding-top:1.5rem}#fbjs .fb-pr-4{padding-right:1rem}#fbjs .fb-pt-4{padding-top:1rem}#fbjs .fb-font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}#fbjs .fb-text-base{font-size:1rem;line-height:1.5rem}#fbjs .fb-text-sm{font-size:.875rem;line-height:1.25rem}#fbjs .fb-font-medium{font-weight:500}#fbjs .fb-font-normal{font-weight:400}#fbjs .fb-font-semibold{font-weight:600}#fbjs .fb-leading-4{line-height:1rem}#fbjs .fb-leading-6{line-height:1.5rem}#fbjs .fb-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}#fbjs .fb-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity))}#fbjs .fb-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}#fbjs .fb-opacity-0{opacity:0}#fbjs .fb-opacity-100{opacity:1}#fbjs .fb-opacity-60{opacity:.6}#fbjs .fb-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}#fbjs .fb-shadow-lg,#fbjs .fb-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs .fb-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}#fbjs .fb-ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs .fb-ring-black{--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity))}#fbjs .fb-ring-opacity-5{--tw-ring-opacity:0.05}#fbjs .fb-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs .fb-duration-500{transition-duration:.5s}#fbjs .fb-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs .hover\\:fb-text-slate-500:hover{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}#fbjs .hover\\:fb-opacity-90:hover{opacity:.9}#fbjs .focus\\:fb-border-slate-500:focus{--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity))}#fbjs .focus\\:fb-outline-none:focus{outline:2px solid transparent;outline-offset:2px}#fbjs .focus\\:fb-ring-0:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color)}#fbjs .focus\\:fb-ring-0:focus,#fbjs .focus\\:fb-ring-2:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs .focus\\:fb-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}#fbjs .focus\\:fb-ring-slate-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(100 116 139/var(--tw-ring-opacity))}#fbjs .focus\\:fb-ring-offset-0:focus{--tw-ring-offset-width:0px}#fbjs .focus\\:fb-ring-offset-2:focus{--tw-ring-offset-width:2px}@media (min-width:640px){#fbjs .sm\\:fb-block{display:block}#fbjs .sm\\:fb-items-end{align-items:flex-end}#fbjs .sm\\:fb-p-6{padding:1.5rem}#fbjs .sm\\:fb-text-sm{font-size:.875rem;line-height:1.25rem}}',document.head.appendChild(e)}}();var r=De&&De.get().environmentId===e.environmentId&&De.get().apiHost===e.apiHost?De.get().session&&Le(De.get().session)?Promise.resolve(Fe()).then(function(e){var t=e.settings;De.update({session:qe(e.session),settings:t}),Se("New Session")}):De.get().session?void 0:(We.error("Unable to initialize. No session found"),void(t=1)):(De.update({environmentId:e.environmentId,apiHost:e.apiHost}),Promise.resolve(Ne()).then(function(e){var t=e.settings;De.update({person:e.person,session:qe(e.session),settings:t}),Se("New Session")}));Promise.resolve(r&&r.then?r.then(n):n(r))}catch(e){return Promise.reject(e)}}(e),Promise.resolve()}catch(e){return Promise.reject(e)}})},setUserId:function(e){Be.add(function(){try{return Je(),Promise.resolve(function(e){try{return Ee.debug("setting userId: "+e),Te("userId",e)?(Ee.debug("userId already set to this value. Skipping update."),Promise.resolve()):(t=Ce.get().person.attributes.find(function(e){var t;return"userId"===(null==(t=e.attributeClass)?void 0:t.name)}),t?(Ee.error("userId cannot be changed after it has been set. You need to reset first"),Promise.resolve()):Promise.resolve(function(e){try{return Ce.get().person&&Ce.get().person.id?Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people/"+Ce.get().person.id+"/user-id",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,sessionId:Ce.get().session.id})})).then(function(e){if(!e.ok)throw Ee.error("Formbricks: Error updating person"),Error("Error updating person");return Promise.resolve(e.json())}):(console.error("Formbricks: Unable to update userId. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e)).then(function(e){Ce.update({person:e.person,settings:e.settings})}))}catch(e){return Promise.reject(e)}var t}(e)).then(function(){})}catch(e){return Promise.reject(e)}})},setEmail:function(e){Re("email",e)},setAttribute:Re,track:function(e,t){void 0===t&&(t={}),Be.add(function(){try{return Je(),Promise.resolve(Se(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},logout:function(){Be.add(function(){try{return Je(),Promise.resolve(function(){try{return Ee.debug("Resetting person. Getting new person, session and settings from backend"),Promise.resolve(Ne()).then(function(e){var t=e.person,n=e.session,r=e.settings;if(!t||!n||!r)throw Ee.error("Error resetting user"),new Error("Formbricks: Error resetting user");Ce.update({person:t,session:n,settings:r})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},refresh:function(){Be.add(function(){try{return Je(),Promise.resolve(function(){try{return pe.debug("Refreshing - getting settings from backend"),Promise.resolve(ge()).then(function(e){he.update({settings:e})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},registerRouteChange:function(){Be.add(function(){try{return Je(),Ue(),Promise.resolve()}catch(e){return Promise.reject(e)}})}};module.exports=Qe;
function e(n,r,o){if(!n.s){if(o instanceof t){if(!o.s)return void(o.o=e.bind(null,n,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(e.bind(null,n,r),e.bind(null,n,2));n.s=r,n.v=o;var i=n.o;i&&i(n)}}var t=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(n,r){var o=new t,i=this.s;if(i){var s=1&i?n:r;if(s){try{e(o,1,s(this.v))}catch(t){e(o,2,t)}return o}return this}return this.o=function(t){try{var i=t.v;1&t.s?e(o,1,n?n(i):i):r?e(o,1,r(i)):e(o,2,i)}catch(t){e(o,2,t)}},o},t}();function n(e){return e instanceof t&&1&e.s}var r=/*#__PURE__*/function(){function r(){this.queue=[],this.running=!1}var o=r.prototype;return o.add=function(e){this.queue.push(e),this.running||this.run()},o.run=function(){try{var r=function(){o.running=!1},o=this;o.running=!0;var i=function(r,o,i){for(var s;;){var a=r();if(n(a)&&(a=a.v),!a)return f;if(a.then){s=0;break}var f=i();if(f&&f.then){if(!n(f)){s=1;break}f=f.s}}var l=new t,c=e.bind(null,l,2);return(0===s?a.then(d):1===s?f.then(u):(void 0).then(function(){(a=r())?a.then?a.then(d).then(void 0,c):d(a):e(l,1,f)})).then(void 0,c),l;function u(t){f=t;do{if(!(a=r())||n(a)&&!a.v)return void e(l,1,f);if(a.then)return void a.then(d).then(void 0,c);n(f=i())&&(f=f.v)}while(!f||!f.then);f.then(u).then(void 0,c)}function d(t){t?(f=i())&&f.then?f.then(u).then(void 0,c):u(f):e(l,1,f)}}(function(){return o.queue.length>0},0,function(){var e=o.queue.shift(),t=function(t,n){try{var r=Promise.resolve(e()).then(function(){})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){console.error(e)});if(t&&t.then)return t.then(function(){})});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},r}();function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,f,l,c,u,d,b,p={},_=[],h=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function g(e,t){for(var n in t)e[n]=t[n];return e}function v(e){var t=e.parentNode;t&&t.removeChild(e)}function m(e,t,n){var r,o,i,s={};for(i in t)"key"==i?r=t[i]:"ref"==i?o=t[i]:s[i]=t[i];if(arguments.length>2&&(s.children=arguments.length>3?a.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===s[i]&&(s[i]=e.defaultProps[i]);return w(e,s,r,o,null)}function w(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++l:o};return null==o&&null!=f.vnode&&f.vnode(i),i}function y(e){return e.children}function j(e,t){this.props=e,this.context=t}function x(e,t){if(null==t)return e.__?x(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?x(e):null}function k(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return k(e)}}function P(e){(!e.__d&&(e.__d=!0)&&c.push(e)&&!S.__r++||u!==f.debounceRendering)&&((u=f.debounceRendering)||d)(S)}function S(){var e,t,n,r,o,i,s,a;for(c.sort(b);e=c.shift();)e.__d&&(t=c.length,r=void 0,o=void 0,s=(i=(n=e).__v).__e,(a=n.__P)&&(r=[],(o=g({},i)).__v=i.__v+1,L(a,i,o,n.__n,void 0!==a.ownerSVGElement,null!=i.__h?[s]:null,r,null==s?x(i):s,i.__h),q(r,i),i.__e!=s&&k(i)),c.length>t&&c.sort(b));S.__r=0}function C(e,t,n,r,o,i,s,a,f,l){var c,u,d,b,h,g,v,m=r&&r.__k||_,j=m.length;for(n.__k=[],c=0;c<t.length;c++)if(null!=(b=n.__k[c]=null==(b=t[c])||"boolean"==typeof b||"function"==typeof b?null:"string"==typeof b||"number"==typeof b||"bigint"==typeof b?w(null,b,null,null,b):Array.isArray(b)?w(y,{children:b},null,null,null):b.__b>0?w(b.type,b.props,b.key,b.ref?b.ref:null,b.__v):b)){if(b.__=n,b.__b=n.__b+1,null===(d=m[c])||d&&b.key==d.key&&b.type===d.type)m[c]=void 0;else for(u=0;u<j;u++){if((d=m[u])&&b.key==d.key&&b.type===d.type){m[u]=void 0;break}d=null}L(e,b,d=d||p,o,i,s,a,f,l),h=b.__e,(u=b.ref)&&d.ref!=u&&(v||(v=[]),d.ref&&v.push(d.ref,null,b),v.push(u,b.__c||h,b)),null!=h?(null==g&&(g=h),"function"==typeof b.type&&b.__k===d.__k?b.__d=f=I(b,f,e):f=E(e,b,d,m,h,f),"function"==typeof n.type&&(n.__d=f)):f&&d.__e==f&&f.parentNode!=e&&(f=x(d))}for(n.__e=g,c=j;c--;)null!=m[c]&&("function"==typeof n.type&&null!=m[c].__e&&m[c].__e==n.__d&&(n.__d=N(r).nextSibling),A(m[c],m[c]));if(v)for(c=0;c<v.length;c++)U(v[c],v[++c],v[++c])}function I(e,t,n){for(var r,o=e.__k,i=0;o&&i<o.length;i++)(r=o[i])&&(r.__=e,t="function"==typeof r.type?I(r,t,n):E(n,r,r,o,r.__e,t));return t}function E(e,t,n,r,o,i){var s,a,f;if(void 0!==t.__d)s=t.__d,t.__d=void 0;else if(null==n||o!=i||null==o.parentNode)e:if(null==i||i.parentNode!==e)e.appendChild(o),s=null;else{for(a=i,f=0;(a=a.nextSibling)&&f<r.length;f+=1)if(a==o)break e;e.insertBefore(o,i),s=i}return void 0!==s?s:o.nextSibling}function N(e){var t,n,r;if(null==e.type||"string"==typeof e.type)return e.__e;if(e.__k)for(t=e.__k.length-1;t>=0;t--)if((n=e.__k[t])&&(r=N(n)))return r;return null}function H(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||h.test(t)?n:n+"px"}function T(e,t,n,r,o){var i;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||H(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||H(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])i=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r||e.addEventListener(t,i?F:z,i):e.removeEventListener(t,i?F:z,i);else if("dangerouslySetInnerHTML"!==t){if(o)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function z(e){return this.l[e.type+!1](f.event?f.event(e):e)}function F(e){return this.l[e.type+!0](f.event?f.event(e):e)}function L(e,t,n,r,o,i,s,a,l){var c,u,d,b,p,_,h,v,m,w,x,k,P,S,I,E=t.type;if(void 0!==t.constructor)return null;null!=n.__h&&(l=n.__h,a=t.__e=n.__e,t.__h=null,i=[a]),(c=f.__b)&&c(t);try{e:if("function"==typeof E){if(v=t.props,m=(c=E.contextType)&&r[c.__c],w=c?m?m.props.value:c.__:r,n.__c?h=(u=t.__c=n.__c).__=u.__E:("prototype"in E&&E.prototype.render?t.__c=u=new E(v,w):(t.__c=u=new j(v,w),u.constructor=E,u.render=M),m&&m.sub(u),u.props=v,u.state||(u.state={}),u.context=w,u.__n=r,d=u.__d=!0,u.__h=[],u._sb=[]),null==u.__s&&(u.__s=u.state),null!=E.getDerivedStateFromProps&&(u.__s==u.state&&(u.__s=g({},u.__s)),g(u.__s,E.getDerivedStateFromProps(v,u.__s))),b=u.props,p=u.state,u.__v=t,d)null==E.getDerivedStateFromProps&&null!=u.componentWillMount&&u.componentWillMount(),null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(null==E.getDerivedStateFromProps&&v!==b&&null!=u.componentWillReceiveProps&&u.componentWillReceiveProps(v,w),!u.__e&&null!=u.shouldComponentUpdate&&!1===u.shouldComponentUpdate(v,u.__s,w)||t.__v===n.__v){for(t.__v!==n.__v&&(u.props=v,u.state=u.__s,u.__d=!1),u.__e=!1,t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(e){e&&(e.__=t)}),x=0;x<u._sb.length;x++)u.__h.push(u._sb[x]);u._sb=[],u.__h.length&&s.push(u);break e}null!=u.componentWillUpdate&&u.componentWillUpdate(v,u.__s,w),null!=u.componentDidUpdate&&u.__h.push(function(){u.componentDidUpdate(b,p,_)})}if(u.context=w,u.props=v,u.__P=e,k=f.__r,P=0,"prototype"in E&&E.prototype.render){for(u.state=u.__s,u.__d=!1,k&&k(t),c=u.render(u.props,u.state,u.context),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[]}else do{u.__d=!1,k&&k(t),c=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++P<25);u.state=u.__s,null!=u.getChildContext&&(r=g(g({},r),u.getChildContext())),d||null==u.getSnapshotBeforeUpdate||(_=u.getSnapshotBeforeUpdate(b,p)),I=null!=c&&c.type===y&&null==c.key?c.props.children:c,C(e,Array.isArray(I)?I:[I],t,n,r,o,i,s,a,l),u.base=t.__e,t.__h=null,u.__h.length&&s.push(u),h&&(u.__E=u.__=null),u.__e=!1}else null==i&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=O(n.__e,t,n,r,o,i,s,l);(c=f.diffed)&&c(t)}catch(e){t.__v=null,(l||null!=i)&&(t.__e=a,t.__h=!!l,i[i.indexOf(a)]=null),f.__e(e,t,n)}}function q(e,t){f.__c&&f.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){f.__e(e,t.__v)}})}function O(e,t,n,r,o,i,s,f){var l,c,u,d=n.props,b=t.props,_=t.type,h=0;if("svg"===_&&(o=!0),null!=i)for(;h<i.length;h++)if((l=i[h])&&"setAttribute"in l==!!_&&(_?l.localName===_:3===l.nodeType)){e=l,i[h]=null;break}if(null==e){if(null===_)return document.createTextNode(b);e=o?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,b.is&&b),i=null,f=!1}if(null===_)d===b||f&&e.data===b||(e.data=b);else{if(i=i&&a.call(e.childNodes),c=(d=n.props||p).dangerouslySetInnerHTML,u=b.dangerouslySetInnerHTML,!f){if(null!=i)for(d={},h=0;h<e.attributes.length;h++)d[e.attributes[h].name]=e.attributes[h].value;(u||c)&&(u&&(c&&u.__html==c.__html||u.__html===e.innerHTML)||(e.innerHTML=u&&u.__html||""))}if(function(e,t,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in t||T(e,i,null,n[i],r);for(i in t)o&&"function"!=typeof t[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===t[i]||T(e,i,t[i],n[i],r)}(e,b,d,o,f),u)t.__k=[];else if(h=t.props.children,C(e,Array.isArray(h)?h:[h],t,n,r,o&&"foreignObject"!==_,i,s,i?i[0]:n.__k&&x(n,0),f),null!=i)for(h=i.length;h--;)null!=i[h]&&v(i[h]);f||("value"in b&&void 0!==(h=b.value)&&(h!==e.value||"progress"===_&&!h||"option"===_&&h!==d.value)&&T(e,"value",h,d.value,!1),"checked"in b&&void 0!==(h=b.checked)&&h!==e.checked&&T(e,"checked",h,d.checked,!1))}return e}function U(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){f.__e(e,n)}}function A(e,t,n){var r,o;if(f.unmount&&f.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||U(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){f.__e(e,t)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&A(r[o],t,n||"function"!=typeof e.type);n||null==e.__e||v(e.__e),e.__=e.__e=e.__d=void 0}function M(e,t,n){return this.constructor(e,n)}a=_.slice,f={__e:function(e,t,n,r){for(var o,i,s;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&null!=i.getDerivedStateFromError&&(o.setState(i.getDerivedStateFromError(e)),s=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,r||{}),s=o.__d),s)return o.__E=o}catch(t){e=t}throw e}},l=0,j.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=g({},this.state),"function"==typeof e&&(e=e(g({},n),this.props)),e&&g(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),P(this))},j.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),P(this))},j.prototype.render=y,c=[],d="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,b=function(e,t){return e.__v.__b-t.__v.__b},S.__r=0;var D,W,J,B,R=0,V=[],Y=[],Q=f.__b,X=f.__r,$=f.diffed,G=f.__c,K=f.unmount;function Z(e,t){f.__h&&f.__h(W,e,R||t),R=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:Y}),n.__[e]}function ee(e){return R=1,function(e,t,n){var r=Z(D++,2);if(r.t=e,!r.__c&&(r.__=[ae(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.u)){var o=function(e,t,n){if(!r.__c.__H)return!0;var o=r.__c.__H.__.filter(function(e){return e.__c});if(o.every(function(e){return!e.__N}))return!i||i.call(this,e,t,n);var s=!1;return o.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}}),!(!s&&r.__c.props===e)&&(!i||i.call(this,e,t,n))};W.u=!0;var i=W.shouldComponentUpdate,s=W.componentWillUpdate;W.componentWillUpdate=function(e,t,n){if(this.__e){var r=i;i=void 0,o(e,t,n),i=r}s&&s.call(this,e,t,n)},W.shouldComponentUpdate=o}return r.__N||r.__}(ae,e)}function te(e,t){var n=Z(D++,3);!f.__s&&function(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}(n.__H,t)&&(n.__=e,n.i=t,W.__H.__h.push(n))}function ne(){for(var e;e=V.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ie),e.__H.__h.forEach(se),e.__H.__h=[]}catch(t){e.__H.__h=[],f.__e(t,e.__v)}}f.__b=function(e){W=null,Q&&Q(e)},f.__r=function(e){X&&X(e),D=0;var t=(W=e.__c).__H;t&&(J===W?(t.__h=[],W.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.__V=Y,e.__N=e.i=void 0})):(t.__h.forEach(ie),t.__h.forEach(se),t.__h=[])),J=W},f.diffed=function(e){$&&$(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==V.push(t)&&B===f.requestAnimationFrame||((B=f.requestAnimationFrame)||oe)(ne)),t.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.__V!==Y&&(e.__=e.__V),e.i=void 0,e.__V=Y})),J=W=null},f.__c=function(e,t){t.some(function(e){try{e.__h.forEach(ie),e.__h=e.__h.filter(function(e){return!e.__||se(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],f.__e(n,e.__v)}}),G&&G(e,t)},f.unmount=function(e){K&&K(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{ie(e)}catch(e){t=e}}),n.__H=void 0,t&&f.__e(t,n.__v))};var re="function"==typeof requestAnimationFrame;function oe(e){var t,n=function(){clearTimeout(r),re&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);re&&(t=requestAnimationFrame(n))}function ie(e){var t=W,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),W=t}function se(e){var t=W;e.__c=e.__(),W=t}function ae(e,t){return"function"==typeof t?t(e):t}var fe=function(){return[].slice.call(arguments).filter(Boolean).join(" ")};function le(e){var t=e.children,n=e.isOpen,r=e.close,o=ee(!1),i=o[0],s=o[1];return te(function(){s(n)},[n]),m("div",{"aria-live":"assertive",className:"fb-pointer-events-none fb-fixed fb-inset-0 fb-flex fb-items-end fb-px-4 fb-py-6 sm:fb-p-6"},m("div",{className:"fb-flex fb-w-full fb-flex-col fb-items-center fb-space-y-4 sm:fb-items-end"},m("div",{className:fe(i?"fb-translate-x-0 fb-opacity-100":"fb-translate-x-28 fb-opacity-0","fb-pointer-events-auto fb-relative fb-w-full fb-max-w-sm fb-overflow-hidden fb-rounded-lg fb-bg-white fb-shadow-lg fb-ring-1 fb-ring-black fb-ring-opacity-5 fb-transition-all fb-duration-500 fb-ease-in-out")},m("div",{class:"fb-absolute fb-top-0 fb-right-0 fb-hidden fb-pt-4 fb-pr-4 sm:fb-block"},m("button",{type:"button",onClick:r,class:"fb-rounded-md fb-bg-white focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 fb-text-slate-400 hover:fb-text-slate-500 focus:ring-slate-500"},m("span",{class:"fb-sr-only"},"Close"),m("svg",{class:"fb-h-6 fb-w-6",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},m("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})))),m("div",{className:""},t))))}var ce=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays/"+e+"/responded",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){if(!e.ok)throw new Error("Could not update display")})}catch(e){return Promise.reject(e)}},ue=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/responses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function de(e){return m("label",{htmlFor:e.questionId,className:"fb-block fb-text-base fb-font-semibold fb-leading-6 fb-mr-8 text-slate-900"},e.headline)}function be(e){return m("label",{for:e.questionId,className:"fb-block fb-text-sm fb-font-normal fb-leading-6 text-slate-600"},e.subheader)}function pe(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor;return m("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},m(de,{headline:t.headline,questionId:t.id}),m(be,{subheader:t.subheader,questionId:t.id}),m("div",{className:"fb-mt-4"},m("textarea",{rows:3,name:t.id,id:t.id,placeholder:t.placeholder,required:t.required,className:"fb-block fb-w-full fb-rounded-md fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm fb-bg-slate-50 fb-border-slate-100 focus:fb-border-slate-500"})),m("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},m("div",null),m("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:fb-ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function _e(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor,i=ee(null),s=i[0],a=i[1];return m("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},m(de,{headline:t.headline,questionId:t.id}),m(be,{subheader:t.subheader,questionId:t.id}),m("div",{className:"fb-mt-4"},m("fieldset",null,m("legend",{className:"fb-sr-only"},"Choices"),m("div",{className:"fb-relative fb-space-y-2 fb-rounded-md fb-bg-white"},t.choices&&t.choices.map(function(e){return m("label",{key:e.id,className:fe(s===e.label?"fb-z-10 fb-bg-slate-50 fb-border-slate-400":"fb-border-gray-200","fb-relative fb-flex fb-cursor-pointer fb-flex-col fb-rounded-md fb-border fb-p-4 focus:fb-outline-none hover:bg-slate-50")},m("span",{className:"fb-flex fb-items-center fb-text-sm"},m("input",{type:"radio",id:e.id,name:t.id,value:e.label,className:"fb-h-4 fb-w-4 fb-border fb-border-slate-300 focus:fb-ring-0 focus:fb-ring-offset-0","aria-labelledby":e.id+"-label",onChange:function(e){a(e.currentTarget.value)},style:{borderColor:o,color:o}}),m("span",{id:e.id+"-label",className:"fb-ml-3 fb-font-medium"},e.label)))})))),m("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},m("div",null),m("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function he(e){return m("div",{className:"fb-h-1 fb-w-full fb-rounded-full bg-slate-200"},m("div",{className:"fb-h-1 fb-rounded-full",style:{backgroundColor:e.brandColor,width:Math.floor(100*e.progress)+"%"}}))}function ge(e){var t=e.config,n=e.survey,r=e.close,o=e.brandColor,i=ee(n.questions[0]),s=i[0],a=i[1],f=ee(0),l=f[0],c=f[1],u=ee(null),d=u[0],b=u[1],p=ee(null),_=p[0],h=p[1],g=ee(!1),v=g[0],w=g[1];te(function(){!function(){try{Promise.resolve(function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create display");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}({surveyId:n.id,personId:t.person.id},t)).then(function(e){h(e.id)})}catch(e){return Promise.reject(e)}}()},[t,n]),te(function(){var e;c((e=n.questions.findIndex(function(e){return e.id===s.id}),e/n.questions.length))},[s,n]);var y=function(e){try{var o=function(){w(!1),f?(c(100),r()):a(n.questions[i+1])};w(!0);var i=n.questions.findIndex(function(e){return e.id===s.id}),f=i===n.questions.length-1,l={surveyId:n.id,personId:t.person.id,response:{finished:f,data:e}},u=d?Promise.resolve(function(e,t,n){try{return Promise.resolve(fetch(n.apiHost+"/api/v1/client/environments/"+n.environmentId+"/responses/"+t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw new Error("Could not update response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}(l,d,t)).then(function(){}):Promise.resolve(Promise.all([ue(l,t),ce(_,t)])).then(function(e){b(e[0].id)});return Promise.resolve(u&&u.then?u.then(o):o())}catch(e){return Promise.reject(e)}};return m("div",null,m("div",{className:fe(v?"fb-animate-pulse fb-opacity-60":"","fb-p-4 fb-text-slate-800 fb-font-sans")},"multipleChoiceSingle"===s.type?m(_e,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):"openText"===s.type?m(pe,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):null),m("div",{className:"fb-mt-2"},m(he,{progress:l,brandColor:o})))}function ve(e){var t,n=e.config,r=e.survey,o=e.closeSurvey,i=ee(!0),s=i[1],a=function(){s(!1),setTimeout(function(){o()},1e3)};return m("div",{id:"fbjs"},m(le,{isOpen:i[0],close:a},m(ge,{config:n,survey:r,close:a,brandColor:null==(t=n.settings)?void 0:t.brandColor})))}var me=/*#__PURE__*/function(){function e(){this.config=this.loadFromLocalStorage()}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.update=function(e){e&&(this.config=o({},this.config,e),this.saveToLocalStorage())},t.get=function(){return this.config},t.loadFromLocalStorage=function(){if("undefined"!=typeof window){var e=localStorage.getItem("config");if(e)return JSON.parse(e)}return{apiHost:null,environmentId:null}},t.saveToLocalStorage=function(){localStorage.setItem("config",JSON.stringify(this.config))},e}();me.instance=void 0;var we=/*#__PURE__*/function(){function e(){this.logLevel="error"}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.configure=function(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)},t.logger=function(e,t){if("debug"!==t||"debug"===this.logLevel){var n="🧱 Formbricks - "+(new Date).toISOString()+" ["+t.toUpperCase()+"] - "+e;"error"===t?console.error(n):console.log(n)}},t.debug=function(e){this.logger(e,"debug")},t.error=function(e){this.logger(e,"error")},e}();we.instance=void 0;var ye=we.getInstance(),je=me.getInstance(),xe=function(){try{return Promise.resolve(fetch(je.get().apiHost+"/api/v1/client/environments/"+je.get().environmentId+"/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:je.get().person.id})})).then(function(e){if(!e.ok)throw ye.error("Error getting settings"),Error("Error getting settings");return e.json()})}catch(e){return Promise.reject(e)}},ke="formbricks-web-container",Pe=me.getInstance(),Se=we.getInstance(),Ce=!1,Ie=function(e){Ce?Se.debug("A survey is already running. Skipping."):(Ce=!0,function(e,t,n){var r,o;f.__&&f.__(e,t),r=t.__k,o=[],L(t,e=t.__k=m(y,null,[e]),r||p,p,void 0!==t.ownerSVGElement,r?null:t.firstChild?a.call(t.childNodes):null,o,r?r.__e:t.firstChild,!1),q(o,e)}(m(ve,{config:Pe.get(),survey:e,closeSurvey:Ee}),document.getElementById(ke)))},Ee=function(){try{return document.getElementById(ke).remove(),Ne(),Promise.resolve(xe()).then(function(e){Pe.update({settings:e}),Ce=!1})}catch(e){return Promise.reject(e)}},Ne=function(){var e=document.createElement("div");e.id=ke,document.body.appendChild(e)},He=we.getInstance(),Te=me.getInstance(),ze=function(e,t){try{return Promise.resolve(fetch(Te.get().apiHost+"/api/v1/client/environments/"+Te.get().environmentId+"/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Te.get().session.id,eventName:e,properties:t})})).then(function(t){var n;function r(t){if(n)return t;He.debug('Formbricks: Event "'+e+'" tracked'),Fe(e)}var o=function(){if(!t.ok)return Promise.resolve(t.json()).then(function(e){He.error("Formbricks: Error tracking event: "+JSON.stringify(e)),n=1})}();return o&&o.then?o.then(r):r(o)})}catch(e){return Promise.reject(e)}},Fe=function(e){for(var t,n=s(null==(r=Te.get().settings)?void 0:r.surveys);!(t=n()).done;)for(var r,o,i=t.value,a=s(i.triggers);!(o=a()).done;){var f;if((null==(f=o.value.eventClass)?void 0:f.name)===e)return He.debug("Formbricks: survey "+i.id+' triggered by event "'+e+'"'),void Ie(i)}},Le=me.getInstance(),qe=we.getInstance(),Oe=function(){try{return qe.debug("Creating new person"),Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){return e.ok?Promise.resolve(e.json()):(console.error("Formbricks: Error fetching person"),null)})}catch(e){return Promise.reject(e)}},Ue=function(e,t){var n=Le.get().person.attributes.find(function(t){var n;return(null==(n=t.attributeClass)?void 0:n.name)===e});return!(!n||n.value!==t)},Ae=we.getInstance(),Me=me.getInstance(),De=function(){try{return Me.get().person?Promise.resolve(fetch(Me.get().apiHost+"/api/v1/client/environments/"+Me.get().environmentId+"/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:Me.get().person.id})})).then(function(e){if(e.ok)return Promise.resolve(e.json());Ae.error("Error creating session")}):(Ae.error("Formbricks: Unable to create session. No person found"),Promise.resolve())}catch(e){return Promise.reject(e)}},We=function(e){Ae.debug("Session expired. Creating new session.");var t=o({},e);return t.expiresAt=Date.now()+36e5,t},Je=function(e){return e.expiresAt<=Date.now()},Be=me.getInstance(),Re=we.getInstance(),Ve=function(){var e=Be.get().settings,t=null==e?void 0:e.noCodeEvents.filter(function(e){var t;return"pageUrl"===(null==(t=e.noCodeConfig)?void 0:t.type)});if(Re.debug("checking page url"),0!==t.length)for(var n,r=s(t);!(n=r()).done;){var o=n.value,i=o.noCodeConfig.pageUrl;i&&Ye(window.location.href,i.value,i.rule)&&ze(o.name)}};function Ye(e,t,n){switch(n){case"exactMatch":return e===t;case"contains":return e.includes(t);case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"notMatch":return e!==t;case"notContains":return!e.includes(t);default:throw new Error("Invalid match type")}}var Qe=function(e){var t=Be.get().settings,n=null==t?void 0:t.noCodeEvents.filter(function(e){var t;return"innerHtml"===(null==(t=e.noCodeConfig)?void 0:t.type)}),r=null==t?void 0:t.noCodeEvents.filter(function(e){var t;return"cssSelector"===(null==(t=e.noCodeConfig)?void 0:t.type)}),o=e.target;n.forEach(function(e){var t,n=null==(t=e.noCodeConfig)?void 0:t.innerHtml;n&&o.innerHTML===n.value&&ze(e.name)}),r.forEach(function(e){var t,n=null==(t=e.noCodeConfig)?void 0:t.cssSelector;n&&o.matches(n.value)&&ze(e.name)})},Xe=me.getInstance(),$e=we.getInstance(),Ge=function(){if(!(Xe.get().apiHost&&Xe.get().environmentId&&Xe.get().person&&Xe.get().session&&Xe.get().settings))throw Error("Formbricks: Formbricks not initialized. Call initialize() first.")},Ke=new r,Ze=function(e,t){Ke.add(function(){try{return Ge(),Promise.resolve(function(e,t){try{return qe.debug("setting attribute: "+e+" to value: "+t),Ue(e,t)?(qe.debug("attribute already set to this value. Skipping update."),Promise.resolve()):Promise.resolve(function(e,t){try{return Le.get().person&&Le.get().person.id?Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people/"+Le.get().person.id+"/attribute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:t})})).then(function(e){return Promise.resolve(e.json()).then(function(t){if(!e.ok)throw qe.error("Error updating person"),Error("Error updating person");return t})}):(console.error("Formbricks: Unable to update attribute. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e,t)).then(function(e){var t=e.person,n=e.settings;if(!t||!n)throw qe.error("Error updating attribute"),new Error("Formbricks: Error updating attribute");Le.update({person:t,settings:n})})}catch(e){return Promise.reject(e)}}(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},et={init:function(e){Ke.add(function(){try{return function(e){try{var t,n=function(e){if(t)return e;(function(){if("undefined"!=typeof window){var e=window.setInterval(function(){try{return Promise.resolve(function(){try{var e=function(e){Ae.debug("Session not expired, extending session"),Me.update({session:We(Me.get().session)})};Ae.debug("Checking session");var t=function(){if(Je(Me.get().session))return Ae.debug("Session expired, creating new session"),Promise.resolve(De()).then(function(e){var t=e.session,n=e.settings;if(!t||!n)throw Ae.error("Error creating new session"),Error("Error creating new session");Me.update({session:t,settings:n}),ze("New Session")})}();return Promise.resolve(t&&t.then?t.then(e):e())}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}},3e5);window.addEventListener("beforeunload",function(){clearInterval(e)})}})(),"undefined"!=typeof window&&(window.addEventListener("hashchange",Ve),window.addEventListener("popstate",Ve),window.addEventListener("pushstate",Ve),window.addEventListener("replacestate",Ve),window.addEventListener("load",Ve)),"undefined"!=typeof window&&document.addEventListener("click",Qe),$e.debug("Initialized")};if(!e.environmentId)throw Error("Formbricks: environmentId is required");if(!e.apiHost)throw Error("Formbricks: apiHost is required");e.logLevel&&$e.configure({logLevel:e.logLevel}),Ne(),function(){if(null===document.getElementById("formbricks__css")){var e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :after,#fbjs :before{border:0 solid #e5e7eb;box-sizing:border-box}#fbjs :after,#fbjs :before{--tw-content:""}#fbjs html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#fbjs body{line-height:inherit;margin:0}#fbjs hr{border-top-width:1px;color:inherit;height:0}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs pre,#fbjs samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{border-collapse:collapse;border-color:inherit;text-indent:0}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit],#fbjs button{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dd,#fbjs dl,#fbjs figure,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs menu,#fbjs ol,#fbjs ul{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{color:#9ca3af;opacity:1}#fbjs input::placeholder,#fbjs textarea::placeholder{color:#9ca3af;opacity:1}#fbjs [role=button],#fbjs button{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs audio,#fbjs canvas,#fbjs embed,#fbjs iframe,#fbjs img,#fbjs object,#fbjs svg,#fbjs video{display:block;vertical-align:middle}#fbjs img,#fbjs video{height:auto;max-width:100%}#fbjs [hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#fbjs :is(.fb-sr-only){clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}#fbjs :is(.fb-pointer-events-none){pointer-events:none}#fbjs :is(.fb-pointer-events-auto){pointer-events:auto}#fbjs :is(.fb-fixed){position:fixed}#fbjs :is(.fb-absolute){position:absolute}#fbjs :is(.fb-relative){position:relative}#fbjs :is(.fb-inset-0){inset:0}#fbjs :is(.fb-right-0){right:0}#fbjs :is(.fb-top-0){top:0}#fbjs :is(.fb-z-10){z-index:10}#fbjs :is(.fb-ml-3){margin-left:.75rem}#fbjs :is(.fb-mr-8){margin-right:2rem}#fbjs :is(.fb-mt-2){margin-top:.5rem}#fbjs :is(.fb-mt-4){margin-top:1rem}#fbjs :is(.fb-block){display:block}#fbjs :is(.fb-flex){display:flex}#fbjs :is(.fb-hidden){display:none}#fbjs :is(.fb-h-1){height:.25rem}#fbjs :is(.fb-h-4){height:1rem}#fbjs :is(.fb-h-6){height:1.5rem}#fbjs :is(.fb-w-4){width:1rem}#fbjs :is(.fb-w-6){width:1.5rem}#fbjs :is(.fb-w-full){width:100%}#fbjs :is(.fb-max-w-sm){max-width:24rem}#fbjs :is(.fb-translate-x-0){--tw-translate-x:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.fb-translate-x-28){--tw-translate-x:7rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes fb-pulse{50%{opacity:.5}}#fbjs :is(.fb-animate-pulse){animation:fb-pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs :is(.fb-cursor-pointer){cursor:pointer}#fbjs :is(.fb-flex-col){flex-direction:column}#fbjs :is(.fb-items-end){align-items:flex-end}#fbjs :is(.fb-items-center){align-items:center}#fbjs :is(.fb-justify-between){justify-content:space-between}#fbjs :is(.fb-space-y-2>:not([hidden])~:not([hidden])){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}#fbjs :is(.fb-space-y-4>:not([hidden])~:not([hidden])){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}#fbjs :is(.fb-overflow-hidden){overflow:hidden}#fbjs :is(.fb-rounded-full){border-radius:9999px}#fbjs :is(.fb-rounded-lg){border-radius:.5rem}#fbjs :is(.fb-rounded-md){border-radius:.375rem}#fbjs :is(.fb-border){border-width:1px}#fbjs :is(.fb-border-gray-200){--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-100){--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-300){--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-400){--tw-border-opacity:1;border-color:rgb(148 163 184/var(--tw-border-opacity))}#fbjs :is(.fb-border-transparent){border-color:transparent}#fbjs :is(.fb-bg-slate-50){--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}#fbjs :is(.fb-bg-white){--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}#fbjs :is(.fb-p-2){padding:.5rem}#fbjs :is(.fb-p-4){padding:1rem}#fbjs :is(.fb-px-3){padding-left:.75rem;padding-right:.75rem}#fbjs :is(.fb-px-4){padding-left:1rem;padding-right:1rem}#fbjs :is(.fb-py-3){padding-bottom:.75rem;padding-top:.75rem}#fbjs :is(.fb-py-6){padding-bottom:1.5rem;padding-top:1.5rem}#fbjs :is(.fb-pr-4){padding-right:1rem}#fbjs :is(.fb-pt-4){padding-top:1rem}#fbjs :is(.fb-font-sans){font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}#fbjs :is(.fb-text-base){font-size:1rem;line-height:1.5rem}#fbjs :is(.fb-text-sm){font-size:.875rem;line-height:1.25rem}#fbjs :is(.fb-font-medium){font-weight:500}#fbjs :is(.fb-font-normal){font-weight:400}#fbjs :is(.fb-font-semibold){font-weight:600}#fbjs :is(.fb-leading-4){line-height:1rem}#fbjs :is(.fb-leading-6){line-height:1.5rem}#fbjs :is(.fb-text-slate-400){--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}#fbjs :is(.fb-text-slate-800){--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity))}#fbjs :is(.fb-text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}#fbjs :is(.fb-opacity-0){opacity:0}#fbjs :is(.fb-opacity-100){opacity:1}#fbjs :is(.fb-opacity-60){opacity:.6}#fbjs :is(.fb-shadow-lg){--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs :is(.fb-shadow-sm){--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs :is(.fb-ring-1){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.fb-ring-black){--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity))}#fbjs :is(.fb-ring-opacity-5){--tw-ring-opacity:0.05}#fbjs :is(.fb-transition-all){transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs :is(.fb-duration-500){transition-duration:.5s}#fbjs :is(.fb-ease-in-out){transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs :is(.hover\\:fb-text-slate-500:hover){--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}#fbjs :is(.hover\\:fb-opacity-90:hover){opacity:.9}#fbjs :is(.focus\\:fb-border-slate-500:focus){--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity))}#fbjs :is(.focus\\:fb-outline-none:focus){outline:2px solid transparent;outline-offset:2px}#fbjs :is(.focus\\:fb-ring-0:focus){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.focus\\:fb-ring-2:focus){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.focus\\:fb-ring-slate-500:focus){--tw-ring-opacity:1;--tw-ring-color:rgb(100 116 139/var(--tw-ring-opacity))}#fbjs :is(.focus\\:fb-ring-offset-0:focus){--tw-ring-offset-width:0px}#fbjs :is(.focus\\:fb-ring-offset-2:focus){--tw-ring-offset-width:2px}@media (min-width:640px){#fbjs :is(.sm\\:fb-block){display:block}#fbjs :is(.sm\\:fb-items-end){align-items:flex-end}#fbjs :is(.sm\\:fb-p-6){padding:1.5rem}#fbjs :is(.sm\\:fb-text-sm){font-size:.875rem;line-height:1.25rem}}',document.head.appendChild(e)}}();var r=Xe&&Xe.get().environmentId===e.environmentId&&Xe.get().apiHost===e.apiHost?Xe.get().session&&Je(Xe.get().session)?Promise.resolve(De()).then(function(e){var t=e.settings;Xe.update({session:We(e.session),settings:t}),ze("New Session")}):Xe.get().session?void 0:($e.error("Unable to initialize. No session found"),void(t=1)):(Xe.update({environmentId:e.environmentId,apiHost:e.apiHost}),Promise.resolve(Oe()).then(function(e){var t=e.settings;Xe.update({person:e.person,session:We(e.session),settings:t}),ze("New Session")}));Promise.resolve(r&&r.then?r.then(n):n(r))}catch(e){return Promise.reject(e)}}(e),Promise.resolve()}catch(e){return Promise.reject(e)}})},setUserId:function(e){Ke.add(function(){try{return Ge(),Promise.resolve(function(e){try{return qe.debug("setting userId: "+e),Ue("userId",e)?(qe.debug("userId already set to this value. Skipping update."),Promise.resolve()):(t=Le.get().person.attributes.find(function(e){var t;return"userId"===(null==(t=e.attributeClass)?void 0:t.name)}),t?(qe.error("userId cannot be changed after it has been set. You need to reset first"),Promise.resolve()):Promise.resolve(function(e){try{return Le.get().person&&Le.get().person.id?Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people/"+Le.get().person.id+"/user-id",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,sessionId:Le.get().session.id})})).then(function(e){if(!e.ok)throw qe.error("Formbricks: Error updating person"),Error("Error updating person");return Promise.resolve(e.json())}):(console.error("Formbricks: Unable to update userId. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e)).then(function(e){Le.update({person:e.person,settings:e.settings})}))}catch(e){return Promise.reject(e)}var t}(e)).then(function(){})}catch(e){return Promise.reject(e)}})},setEmail:function(e){Ze("email",e)},setAttribute:Ze,track:function(e,t){void 0===t&&(t={}),Ke.add(function(){try{return Ge(),Promise.resolve(ze(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},logout:function(){Ke.add(function(){try{return Ge(),Promise.resolve(function(){try{return qe.debug("Resetting person. Getting new person, session and settings from backend"),Promise.resolve(Oe()).then(function(e){var t=e.person,n=e.session,r=e.settings;if(!t||!n||!r)throw qe.error("Error resetting user"),new Error("Formbricks: Error resetting user");Le.update({person:t,session:n,settings:r})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},refresh:function(){Ke.add(function(){try{return Ge(),Promise.resolve(function(){try{return ye.debug("Refreshing - getting settings from backend"),Promise.resolve(xe()).then(function(e){je.update({settings:e})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},registerRouteChange:function(){Ke.add(function(){try{return Ge(),Ve(),Promise.resolve()}catch(e){return Promise.reject(e)}})}};module.exports=et;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

var e,t,n,o,r,s={},i=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function f(e,t){for(var n in t)e[n]=t[n];return e}function l(e){var t=e.parentNode;t&&t.removeChild(e)}function c(e,t,n){var o,r,s,i=arguments,a={};for(s in t)"key"==s?o=t[s]:"ref"==s?r=t[s]:a[s]=t[s];if(arguments.length>3)for(n=[n],s=3;s<arguments.length;s++)n.push(i[s]);if(null!=n&&(a.children=n),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===a[s]&&(a[s]=e.defaultProps[s]);return d(e,a,o,r,null)}function d(t,n,o,r,s){var i={type:t,props:n,key:o,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==s?++e.__v:s};return null!=e.vnode&&e.vnode(i),i}function b(e){return e.children}function u(e,t){this.props=e,this.context=t}function p(e,t){if(null==t)return e.__?p(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?p(e):null}function g(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return g(e)}}function _(r){(!r.__d&&(r.__d=!0)&&t.push(r)&&!h.__r++||o!==e.debounceRendering)&&((o=e.debounceRendering)||n)(h)}function h(){for(var e;h.__r=t.length;)e=t.sort(function(e,t){return e.__v.__b-t.__v.__b}),t=[],e.some(function(e){var t,n,o,r,s,i,a;e.__d&&(i=(s=(t=e).__v).__e,(a=t.__P)&&(n=[],(o=f({},s)).__v=s.__v+1,r=S(a,s,o,t.__n,void 0!==a.ownerSVGElement,null!=s.__h?[i]:null,n,null==i?p(s):i,s.__h),I(n,s),r!=i&&g(s)))})}function w(e,t,n,o,r,a,f,c,u,g){var _,h,w,v,y,j,x,k=o&&o.__k||i,I=k.length;for(u==s&&(u=null!=f?f[0]:I?p(o,0):null),n.__k=[],_=0;_<t.length;_++)if(null!=(v=n.__k[_]=null==(v=t[_])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v?d(null,v,null,null,v):Array.isArray(v)?d(b,{children:v},null,null,null):null!=v.__e||null!=v.__c?d(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(w=k[_])||w&&v.key==w.key&&v.type===w.type)k[_]=void 0;else for(h=0;h<I;h++){if((w=k[h])&&v.key==w.key&&v.type===w.type){k[h]=void 0;break}w=null}y=S(e,v,w=w||s,r,a,f,c,u,g),(h=v.ref)&&w.ref!=h&&(x||(x=[]),w.ref&&x.push(w.ref,null,v),x.push(h,v.__c||y,v)),null!=y?(null==j&&(j=y),u=m(e,v,w,k,f,y,u),g||"option"!=n.type?"function"==typeof n.type&&(n.__d=u):e.value=""):u&&w.__e==u&&u.parentNode!=e&&(u=p(w))}if(n.__e=j,null!=f&&"function"!=typeof n.type)for(_=f.length;_--;)null!=f[_]&&l(f[_]);for(_=I;_--;)null!=k[_]&&E(k[_],k[_]);if(x)for(_=0;_<x.length;_++)C(x[_],x[++_],x[++_])}function m(e,t,n,o,r,s,i){var a,f,l;if(void 0!==t.__d)a=t.__d,t.__d=void 0;else if(r==n||s!=i||null==s.parentNode)e:if(null==i||i.parentNode!==e)e.appendChild(s),a=null;else{for(f=i,l=0;(f=f.nextSibling)&&l<o.length;l+=2)if(f==s)break e;e.insertBefore(s,i),a=i}return void 0!==a?a:s.nextSibling}function v(e,t,n){"-"===t[0]?e.setProperty(t,n):e[t]=null==n?"":"number"!=typeof n||a.test(t)?n:n+"px"}function y(e,t,n,o,r){var s,i,a;if(r&&"className"==t&&(t="class"),"style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof o&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||v(e.style,t,"");if(n)for(t in n)o&&n[t]===o[t]||v(e.style,t,n[t])}else"o"===t[0]&&"n"===t[1]?(s=t!==(t=t.replace(/Capture$/,"")),(i=t.toLowerCase())in e&&(t=i),t=t.slice(2),e.l||(e.l={}),e.l[t+s]=n,a=s?x:j,n?o||e.addEventListener(t,a,s):e.removeEventListener(t,a,s)):"list"!==t&&"tagName"!==t&&"form"!==t&&"type"!==t&&"size"!==t&&"download"!==t&&"href"!==t&&!r&&t in e?e[t]=null==n?"":n:"function"!=typeof n&&"dangerouslySetInnerHTML"!==t&&(t!==(t=t.replace(/xlink:?/,""))?null==n||!1===n?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),n):null==n||!1===n&&!/^ar/.test(t)?e.removeAttribute(t):e.setAttribute(t,n))}function j(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function k(e,t,n){var o,r;for(o=0;o<e.__k.length;o++)(r=e.__k[o])&&(r.__=e,r.__e&&("function"==typeof r.type&&r.__k.length>1&&k(r,t,n),t=m(n,r,r,e.__k,null,r.__e,t),"function"==typeof e.type&&(e.__d=t)))}function S(t,n,o,r,a,l,c,d,p){var g,_,h,m,v,j,x,S,I,C,E,T=n.type;if(void 0!==n.constructor)return null;null!=o.__h&&(p=o.__h,d=n.__e=o.__e,n.__h=null,l=[d]),(g=e.__b)&&g(n);try{e:if("function"==typeof T){if(S=n.props,I=(g=T.contextType)&&r[g.__c],C=g?I?I.props.value:g.__:r,o.__c?x=(_=n.__c=o.__c).__=_.__E:("prototype"in T&&T.prototype.render?n.__c=_=new T(S,C):(n.__c=_=new u(S,C),_.constructor=T,_.render=N),I&&I.sub(_),_.props=S,_.state||(_.state={}),_.context=C,_.__n=r,h=_.__d=!0,_.__h=[]),null==_.__s&&(_.__s=_.state),null!=T.getDerivedStateFromProps&&(_.__s==_.state&&(_.__s=f({},_.__s)),f(_.__s,T.getDerivedStateFromProps(S,_.__s))),m=_.props,v=_.state,h)null==T.getDerivedStateFromProps&&null!=_.componentWillMount&&_.componentWillMount(),null!=_.componentDidMount&&_.__h.push(_.componentDidMount);else{if(null==T.getDerivedStateFromProps&&S!==m&&null!=_.componentWillReceiveProps&&_.componentWillReceiveProps(S,C),!_.__e&&null!=_.shouldComponentUpdate&&!1===_.shouldComponentUpdate(S,_.__s,C)||n.__v===o.__v){_.props=S,_.state=_.__s,n.__v!==o.__v&&(_.__d=!1),_.__v=n,n.__e=o.__e,n.__k=o.__k,_.__h.length&&c.push(_),k(n,d,t);break e}null!=_.componentWillUpdate&&_.componentWillUpdate(S,_.__s,C),null!=_.componentDidUpdate&&_.__h.push(function(){_.componentDidUpdate(m,v,j)})}_.context=C,_.props=S,_.state=_.__s,(g=e.__r)&&g(n),_.__d=!1,_.__v=n,_.__P=t,g=_.render(_.props,_.state,_.context),_.state=_.__s,null!=_.getChildContext&&(r=f(f({},r),_.getChildContext())),h||null==_.getSnapshotBeforeUpdate||(j=_.getSnapshotBeforeUpdate(m,v)),E=null!=g&&g.type==b&&null==g.key?g.props.children:g,w(t,Array.isArray(E)?E:[E],n,o,r,a,l,c,d,p),_.base=n.__e,n.__h=null,_.__h.length&&c.push(_),x&&(_.__E=_.__=null),_.__e=!1}else null==l&&n.__v===o.__v?(n.__k=o.__k,n.__e=o.__e):n.__e=function(e,t,n,o,r,a,f,l){var c,d,b,u,p,g=n.props,_=t.props;if(r="svg"===t.type||r,null!=a)for(c=0;c<a.length;c++)if(null!=(d=a[c])&&((null===t.type?3===d.nodeType:d.localName===t.type)||e==d)){e=d,a[c]=null;break}if(null==e){if(null===t.type)return document.createTextNode(_);e=r?document.createElementNS("http://www.w3.org/2000/svg",t.type):document.createElement(t.type,_.is&&{is:_.is}),a=null,l=!1}if(null===t.type)g===_||l&&e.data===_||(e.data=_);else{if(null!=a&&(a=i.slice.call(e.childNodes)),b=(g=n.props||s).dangerouslySetInnerHTML,u=_.dangerouslySetInnerHTML,!l){if(null!=a)for(g={},p=0;p<e.attributes.length;p++)g[e.attributes[p].name]=e.attributes[p].value;(u||b)&&(u&&(b&&u.__html==b.__html||u.__html===e.innerHTML)||(e.innerHTML=u&&u.__html||""))}(function(e,t,n,o,r){var s;for(s in n)"children"===s||"key"===s||s in t||y(e,s,null,n[s],o);for(s in t)r&&"function"!=typeof t[s]||"children"===s||"key"===s||"value"===s||"checked"===s||n[s]===t[s]||y(e,s,t[s],n[s],o)})(e,_,g,r,l),u?t.__k=[]:(c=t.props.children,w(e,Array.isArray(c)?c:[c],t,n,o,"foreignObject"!==t.type&&r,a,f,s,l)),l||("value"in _&&void 0!==(c=_.value)&&(c!==e.value||"progress"===t.type&&!c)&&y(e,"value",c,g.value,!1),"checked"in _&&void 0!==(c=_.checked)&&c!==e.checked&&y(e,"checked",c,g.checked,!1))}return e}(o.__e,n,o,r,a,l,c,p);(g=e.diffed)&&g(n)}catch(t){n.__v=null,(p||null!=l)&&(n.__e=d,n.__h=!!p,l[l.indexOf(d)]=null),e.__e(t,n,o)}return n.__e}function I(t,n){e.__c&&e.__c(n,t),t.some(function(n){try{t=n.__h,n.__h=[],t.some(function(e){e.call(n)})}catch(t){e.__e(t,n.__v)}})}function C(t,n,o){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,o)}}function E(t,n,o){var r,s,i;if(e.unmount&&e.unmount(t),(r=t.ref)&&(r.current&&r.current!==t.__e||C(r,null,n)),o||"function"==typeof t.type||(o=null!=(s=t.__e)),t.__e=t.__d=void 0,null!=(r=t.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(t){e.__e(t,n)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&E(r[i],n,o);null!=s&&l(s)}function N(e,t,n){return this.constructor(e,n)}e={__e:function(e,t){for(var n,o,r,s=t.__h;t=t.__;)if((n=t.__c)&&!n.__)try{if((o=n.constructor)&&null!=o.getDerivedStateFromError&&(n.setState(o.getDerivedStateFromError(e)),r=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e),r=n.__d),r)return t.__h=s,n.__E=n}catch(t){e=t}throw e},__v:0},u.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=f({},this.state),"function"==typeof e&&(e=e(f({},n),this.props)),e&&f(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),_(this))},u.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),_(this))},u.prototype.render=b,t=[],n="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,h.__r=0,r=s;var T,H,$,z=0,F=[],q=e.__b,L=e.__r,O=e.diffed,P=e.__c,U=e.unmount;function A(t,n){e.__h&&e.__h(H,t,z||n),z=0;var o=H.__H||(H.__H={__:[],__h:[]});return t>=o.__.length&&o.__.push({}),o.__[t]}function M(e){return z=1,function(e,t,n){var o=A(T++,2);return o.t=e,o.__c||(o.__=[Q(void 0,t),function(e){var t=o.t(o.__[0],e);o.__[0]!==t&&(o.__=[t,o.__[1]],o.__c.setState({}))}],o.__c=H),o.__}(Q,e)}function D(t,n){var o=A(T++,3);!e.__s&&function(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}(o.__H,n)&&(o.__=t,o.__H=n,H.__H.__h.push(o))}function W(){F.forEach(function(t){if(t.__P)try{t.__H.__h.forEach(B),t.__H.__h.forEach(R),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}),F=[]}e.__b=function(e){H=null,q&&q(e)},e.__r=function(e){L&&L(e),T=0;var t=(H=e.__c).__H;t&&(t.__h.forEach(B),t.__h.forEach(R),t.__h=[])},e.diffed=function(t){O&&O(t);var n=t.__c;n&&n.__H&&n.__H.__h.length&&(1!==F.push(n)&&$===e.requestAnimationFrame||(($=e.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(o),J&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,100);J&&(t=requestAnimationFrame(n))})(W)),H=void 0},e.__c=function(t,n){n.some(function(t){try{t.__h.forEach(B),t.__h=t.__h.filter(function(e){return!e.__||R(e)})}catch(o){n.some(function(e){e.__h&&(e.__h=[])}),n=[],e.__e(o,t.__v)}}),P&&P(t,n)},e.unmount=function(t){U&&U(t);var n=t.__c;if(n&&n.__H)try{n.__H.__.forEach(B)}catch(t){e.__e(t,n.__v)}};var J="function"==typeof requestAnimationFrame;function B(e){var t=H;"function"==typeof e.__c&&e.__c(),H=t}function R(e){var t=H;e.__c=e.__(),H=t}function Q(e,t){return"function"==typeof t?t(e):t}const G=(...e)=>e.filter(Boolean).join(" ");function Y({children:e,isOpen:t,close:n}){const[o,r]=M(!1);return D(()=>{r(t)},[t]),c("div",{"aria-live":"assertive",className:"fb-pointer-events-none fb-fixed fb-inset-0 fb-flex fb-items-end fb-px-4 fb-py-6 sm:fb-p-6"},c("div",{className:"fb-flex fb-w-full fb-flex-col fb-items-center fb-space-y-4 sm:fb-items-end"},c("div",{className:G(o?"fb-translate-x-0 fb-opacity-100":"fb-translate-x-28 fb-opacity-0","fb-pointer-events-auto fb-relative fb-w-full fb-max-w-sm fb-overflow-hidden fb-rounded-lg fb-bg-white fb-shadow-lg fb-ring-1 fb-ring-black fb-ring-opacity-5 fb-transition-all fb-duration-500 fb-ease-in-out")},c("div",{class:"fb-absolute fb-top-0 fb-right-0 fb-hidden fb-pt-4 fb-pr-4 sm:fb-block"},c("button",{type:"button",onClick:n,class:"fb-rounded-md fb-bg-white focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 fb-text-slate-400 hover:fb-text-slate-500 focus:ring-slate-500"},c("span",{class:"fb-sr-only"},"Close"),c("svg",{class:"fb-h-6 fb-w-6",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},c("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})))),c("div",{className:""},e))))}const V=async(e,t)=>{if(!(await fetch(`${t.apiHost}/api/v1/client/environments/${t.environmentId}/displays/${e}/responded`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Could not update display")},X=async(e,t)=>{const n=await fetch(`${t.apiHost}/api/v1/client/environments/${t.environmentId}/responses`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw console.error(n.text),new Error("Could not create response");return await n.json()};function K({headline:e,questionId:t}){return c("label",{htmlFor:t,className:"fb-block fb-text-base fb-font-semibold fb-leading-6 fb-mr-8 text-slate-900"},e)}function Z({subheader:e,questionId:t}){return c("label",{for:t,className:"fb-block fb-text-sm fb-font-normal fb-leading-6 text-slate-600"},e)}function ee({question:e,onSubmit:t,lastQuestion:n,brandColor:o}){return c("form",{onSubmit:n=>{n.preventDefault();const o={[e.id]:n.currentTarget[e.id].value};n.currentTarget[e.id].value="",t(o)}},c(K,{headline:e.headline,questionId:e.id}),c(Z,{subheader:e.subheader,questionId:e.id}),c("div",{className:"fb-mt-4"},c("textarea",{rows:3,name:e.id,id:e.id,placeholder:e.placeholder,required:e.required,className:"fb-block fb-w-full fb-rounded-md fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm fb-bg-slate-50 fb-border-slate-100 focus:fb-border-slate-500"})),c("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},c("div",null),c("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:fb-ring-slate-500",style:{backgroundColor:o}},e.buttonLabel||(n?"Finish":"Next"))))}function te({question:e,onSubmit:t,lastQuestion:n,brandColor:o}){const[r,s]=M(null);return c("form",{onSubmit:n=>{n.preventDefault();const o={[e.id]:n.currentTarget[e.id].value};n.currentTarget[e.id].value="",t(o)}},c(K,{headline:e.headline,questionId:e.id}),c(Z,{subheader:e.subheader,questionId:e.id}),c("div",{className:"fb-mt-4"},c("fieldset",null,c("legend",{className:"fb-sr-only"},"Choices"),c("div",{className:"fb-relative fb-space-y-2 fb-rounded-md fb-bg-white"},e.choices&&e.choices.map(t=>c("label",{key:t.id,className:G(r===t.label?"fb-z-10 fb-bg-slate-50 fb-border-slate-400":"fb-border-gray-200","fb-relative fb-flex fb-cursor-pointer fb-flex-col fb-rounded-md fb-border fb-p-4 focus:fb-outline-none hover:bg-slate-50")},c("span",{className:"fb-flex fb-items-center fb-text-sm"},c("input",{type:"radio",id:t.id,name:e.id,value:t.label,className:"fb-h-4 fb-w-4 fb-border fb-border-slate-300 focus:fb-ring-0 focus:fb-ring-offset-0","aria-labelledby":`${t.id}-label`,onChange:e=>{s(e.currentTarget.value)},style:{borderColor:o,color:o}}),c("span",{id:`${t.id}-label`,className:"fb-ml-3 fb-font-medium"},t.label))))))),c("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},c("div",null),c("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:ring-slate-500",style:{backgroundColor:o}},e.buttonLabel||(n?"Finish":"Next"))))}function ne({progress:e,brandColor:t}){return c("div",{className:"fb-h-1 fb-w-full fb-rounded-full bg-slate-200"},c("div",{className:"fb-h-1 fb-rounded-full",style:{backgroundColor:t,width:`${Math.floor(100*e)}%`}}))}function oe({config:e,survey:t,close:n,brandColor:o}){const[r,s]=M(t.questions[0]),[i,a]=M(0),[f,l]=M(null),[d,b]=M(null),[u,p]=M(!1);D(()=>{!async function(){const n=await(async(e,t)=>{const n=await fetch(`${t.apiHost}/api/v1/client/environments/${t.environmentId}/displays`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw console.error(n.text),new Error("Could not create display");return await n.json()})({surveyId:t.id,personId:e.person.id},e);b(n.id)}()},[e,t]),D(()=>{a(function(){const e=t.questions.findIndex(e=>e.id===r.id);return e/t.questions.length}())},[r,t]);const g=async o=>{p(!0);const i=t.questions.findIndex(e=>e.id===r.id),c=i===t.questions.length-1,b={surveyId:t.id,personId:e.person.id,response:{finished:c,data:o}};if(f)await(async(e,t,n)=>{const o=await fetch(`${n.apiHost}/api/v1/client/environments/${n.environmentId}/responses/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error("Could not update response");return await o.json()})(b,f,e);else{const[t,n]=await Promise.all([X(b,e),V(d,e)]);l(t.id)}p(!1),c?(a(100),n()):s(t.questions[i+1])};return c("div",null,c("div",{className:G(u?"fb-animate-pulse fb-opacity-60":"","fb-p-4 fb-text-slate-800 fb-font-sans")},"multipleChoiceSingle"===r.type?c(te,{question:r,onSubmit:g,lastQuestion:t.questions.findIndex(e=>e.id===r.id)===t.questions.length-1,brandColor:o}):"openText"===r.type?c(ee,{question:r,onSubmit:g,lastQuestion:t.questions.findIndex(e=>e.id===r.id)===t.questions.length-1,brandColor:o}):null),c("div",{className:"fb-mt-2"},c(ne,{progress:i,brandColor:o})))}function re({config:e,survey:t,closeSurvey:n}){var o;const[r,s]=M(!0),i=()=>{s(!1),setTimeout(()=>{n()},1e3)};return c("div",{id:"fbjs"},c(Y,{isOpen:r,close:i},c(oe,{config:e,survey:t,close:i,brandColor:null==(o=e.settings)?void 0:o.brandColor})))}function se(){return se=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},se.apply(this,arguments)}class ie{constructor(){this.config=this.loadFromLocalStorage()}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}update(e){e&&(this.config=se({},this.config,e),this.saveToLocalStorage())}get(){return this.config}loadFromLocalStorage(){if("undefined"!=typeof window){const e=localStorage.getItem("config");if(e)return JSON.parse(e)}return{apiHost:null,environmentId:null}}saveToLocalStorage(){localStorage.setItem("config",JSON.stringify(this.config))}}ie.instance=void 0;class ae{constructor(){this.logLevel="error"}static getInstance(){return ae.instance||(ae.instance=new ae),ae.instance}configure(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)}logger(e,t){if("debug"===t&&"debug"!==this.logLevel)return;const n=`🧱 Formbricks - ${(new Date).toISOString()} [${t.toUpperCase()}] - ${e}`;"error"===t?console.error(n):console.log(n)}debug(e){this.logger(e,"debug")}error(e){this.logger(e,"error")}}ae.instance=void 0;const fe=ae.getInstance(),le=ie.getInstance(),ce=async()=>{const e=await fetch(`${le.get().apiHost}/api/v1/client/environments/${le.get().environmentId}/settings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:le.get().person.id})});if(!e.ok)throw fe.error("Error getting settings"),Error("Error getting settings");return e.json()},de="formbricks-web-container",be=ie.getInstance(),ue=ae.getInstance();let pe=!1;const ge=t=>{pe?ue.debug("A survey is already running. Skipping."):(pe=!0,function(t,n,o){var a,f,l;e.__&&e.__(t,n),f=(a=void 0===r)?null:n.__k,t=c(b,null,[t]),l=[],S(n,n.__k=t,f||s,s,void 0!==n.ownerSVGElement,f?null:n.childNodes.length?i.slice.call(n.childNodes):null,l,s,a),I(l,t)}(c(re,{config:be.get(),survey:t,closeSurvey:_e}),document.getElementById(de)))},_e=async()=>{console.log("close survey called"),document.getElementById(de).remove(),he();const e=await ce();be.update({settings:e}),pe=!1},he=()=>{const e=document.createElement("div");e.id=de,document.body.appendChild(e)},we=ae.getInstance(),me=ie.getInstance(),ve=async(e,t)=>{const n=await fetch(`${me.get().apiHost}/api/v1/client/environments/${me.get().environmentId}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:me.get().session.id,eventName:e,properties:t})});if(n.ok)we.debug(`Formbricks: Event "${e}" tracked`),ye(e);else{const e=await n.json();we.error(`Formbricks: Error tracking event: ${JSON.stringify(e)}`)}},ye=e=>{for(const o of null==(t=me.get().settings)?void 0:t.surveys){var t;for(const t of o.triggers){var n;if((null==(n=t.eventClass)?void 0:n.name)===e)return we.debug(`Formbricks: survey ${o.id} triggered by event "${e}"`),void ge(o)}}},je=ie.getInstance(),xe=ae.getInstance(),ke=async()=>{xe.debug("Creating new person");const e=await fetch(`${je.get().apiHost}/api/v1/client/environments/${je.get().environmentId}/people`,{method:"POST",headers:{"Content-Type":"application/json"}});return e.ok?await e.json():(console.error("Formbricks: Error fetching person"),null)},Se=(e,t)=>{const n=je.get().person.attributes.find(t=>{var n;return(null==(n=t.attributeClass)?void 0:n.name)===e});return!(!n||n.value!==t)},Ie=ae.getInstance(),Ce=ie.getInstance(),Ee=async()=>{if(!Ce.get().person)return void Ie.error("Formbricks: Unable to create session. No person found");const e=await fetch(`${Ce.get().apiHost}/api/v1/client/environments/${Ce.get().environmentId}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:Ce.get().person.id})});if(e.ok)return await e.json();Ie.error("Error creating session")},Ne=e=>{Ie.debug("Session expired. Creating new session.");const t=se({},e);return t.expiresAt=Date.now()+36e5,t},Te=e=>e.expiresAt<=Date.now(),He=ie.getInstance(),$e=ae.getInstance(),ze=()=>{var e;$e.debug("checking page url");const t=null==(e=He.get().settings)?void 0:e.noCodeEvents.filter(e=>{var t;return"pageUrl"===(null==(t=e.noCodeConfig)?void 0:t.type)});if(0!==t.length)for(const e of t){const{noCodeConfig:{pageUrl:t}}=e;t&&Fe(window.location.href,t.value,t.rule)&&ve(e.name)}};function Fe(e,t,n){switch(n){case"exactMatch":return e===t;case"contains":return e.includes(t);case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"notMatch":return e!==t;case"notContains":return!e.includes(t);default:throw new Error("Invalid match type")}}const qe=ie.getInstance(),Le=ae.getInstance(),Oe=()=>{if(!(qe.get().apiHost&&qe.get().environmentId&&qe.get().person&&qe.get().session&&qe.get().settings))throw Error("Formbricks: Formbricks not initialized. Call initialize() first.")},Pe=new class{constructor(){this.queue=[],this.running=!1}add(e){this.queue.push(e),this.running||this.run()}async run(){for(this.running=!0;this.queue.length>0;){const e=this.queue.shift();try{await e()}catch(e){console.error(e)}}this.running=!1}},Ue=(e,t)=>{Pe.add(async()=>{Oe(),await(async(e,t)=>{if(xe.debug("setting attribute: "+e+" to value: "+t),Se(e,t))return void xe.debug("attribute already set to this value. Skipping update.");const{person:n,settings:o}=await(async(e,t)=>{if(!je.get().person||!je.get().person.id)return void console.error("Formbricks: Unable to update attribute. No person set.");const n=await fetch(`${je.get().apiHost}/api/v1/client/environments/${je.get().environmentId}/people/${je.get().person.id}/attribute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:t})}),o=await n.json();if(!n.ok)throw xe.error("Error updating person"),Error("Error updating person");return o})(e,t);if(!n||!o)throw xe.error("Error updating attribute"),new Error("Formbricks: Error updating attribute");je.update({person:n,settings:o})})(e,t)})},Ae={init:e=>{Pe.add(async()=>{(async e=>{if(!e.environmentId)throw Error("Formbricks: environmentId is required");if(!e.apiHost)throw Error("Formbricks: apiHost is required");if(e.logLevel&&Le.configure({logLevel:e.logLevel}),he(),(()=>{if(null===document.getElementById("formbricks__css")){const e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :after,#fbjs :before{border:0 solid #e5e7eb;box-sizing:border-box}#fbjs :after,#fbjs :before{--tw-content:""}#fbjs html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#fbjs body{line-height:inherit;margin:0}#fbjs hr{border-top-width:1px;color:inherit;height:0}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs pre,#fbjs samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{border-collapse:collapse;border-color:inherit;text-indent:0}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit],#fbjs button{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dd,#fbjs dl,#fbjs figure,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs menu,#fbjs ol,#fbjs ul{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{color:#9ca3af;opacity:1}#fbjs input::placeholder,#fbjs textarea::placeholder{color:#9ca3af;opacity:1}#fbjs [role=button],#fbjs button{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs audio,#fbjs canvas,#fbjs embed,#fbjs iframe,#fbjs img,#fbjs object,#fbjs svg,#fbjs video{display:block;vertical-align:middle}#fbjs img,#fbjs video{height:auto;max-width:100%}#fbjs [hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#fbjs .fb-sr-only{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}#fbjs .fb-pointer-events-none{pointer-events:none}#fbjs .fb-pointer-events-auto{pointer-events:auto}#fbjs .fb-fixed{position:fixed}#fbjs .fb-absolute{position:absolute}#fbjs .fb-relative{position:relative}#fbjs .fb-inset-0{bottom:0;left:0;right:0;top:0}#fbjs .fb-right-0{right:0}#fbjs .fb-top-0{top:0}#fbjs .fb-z-10{z-index:10}#fbjs .fb-ml-3{margin-left:.75rem}#fbjs .fb-mr-8{margin-right:2rem}#fbjs .fb-mt-2{margin-top:.5rem}#fbjs .fb-mt-4{margin-top:1rem}#fbjs .fb-block{display:block}#fbjs .fb-flex{display:flex}#fbjs .fb-hidden{display:none}#fbjs .fb-h-1{height:.25rem}#fbjs .fb-h-4{height:1rem}#fbjs .fb-h-6{height:1.5rem}#fbjs .fb-w-4{width:1rem}#fbjs .fb-w-6{width:1.5rem}#fbjs .fb-w-full{width:100%}#fbjs .fb-max-w-sm{max-width:24rem}#fbjs .fb-translate-x-0{--tw-translate-x:0px}#fbjs .fb-translate-x-0,#fbjs .fb-translate-x-28{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs .fb-translate-x-28{--tw-translate-x:7rem}@keyframes fb-pulse{50%{opacity:.5}}#fbjs .fb-animate-pulse{animation:fb-pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs .fb-cursor-pointer{cursor:pointer}#fbjs .fb-flex-col{flex-direction:column}#fbjs .fb-items-end{align-items:flex-end}#fbjs .fb-items-center{align-items:center}#fbjs .fb-justify-between{justify-content:space-between}#fbjs .fb-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}#fbjs .fb-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}#fbjs .fb-overflow-hidden{overflow:hidden}#fbjs .fb-rounded-full{border-radius:9999px}#fbjs .fb-rounded-lg{border-radius:.5rem}#fbjs .fb-rounded-md{border-radius:.375rem}#fbjs .fb-border{border-width:1px}#fbjs .fb-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}#fbjs .fb-border-slate-100{--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity))}#fbjs .fb-border-slate-300{--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}#fbjs .fb-border-slate-400{--tw-border-opacity:1;border-color:rgb(148 163 184/var(--tw-border-opacity))}#fbjs .fb-border-transparent{border-color:transparent}#fbjs .fb-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}#fbjs .fb-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}#fbjs .fb-p-2{padding:.5rem}#fbjs .fb-p-4{padding:1rem}#fbjs .fb-px-3{padding-left:.75rem;padding-right:.75rem}#fbjs .fb-px-4{padding-left:1rem;padding-right:1rem}#fbjs .fb-py-3{padding-bottom:.75rem;padding-top:.75rem}#fbjs .fb-py-6{padding-bottom:1.5rem;padding-top:1.5rem}#fbjs .fb-pr-4{padding-right:1rem}#fbjs .fb-pt-4{padding-top:1rem}#fbjs .fb-font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}#fbjs .fb-text-base{font-size:1rem;line-height:1.5rem}#fbjs .fb-text-sm{font-size:.875rem;line-height:1.25rem}#fbjs .fb-font-medium{font-weight:500}#fbjs .fb-font-normal{font-weight:400}#fbjs .fb-font-semibold{font-weight:600}#fbjs .fb-leading-4{line-height:1rem}#fbjs .fb-leading-6{line-height:1.5rem}#fbjs .fb-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}#fbjs .fb-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity))}#fbjs .fb-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}#fbjs .fb-opacity-0{opacity:0}#fbjs .fb-opacity-100{opacity:1}#fbjs .fb-opacity-60{opacity:.6}#fbjs .fb-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}#fbjs .fb-shadow-lg,#fbjs .fb-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs .fb-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}#fbjs .fb-ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs .fb-ring-black{--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity))}#fbjs .fb-ring-opacity-5{--tw-ring-opacity:0.05}#fbjs .fb-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs .fb-duration-500{transition-duration:.5s}#fbjs .fb-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs .hover\\:fb-text-slate-500:hover{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}#fbjs .hover\\:fb-opacity-90:hover{opacity:.9}#fbjs .focus\\:fb-border-slate-500:focus{--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity))}#fbjs .focus\\:fb-outline-none:focus{outline:2px solid transparent;outline-offset:2px}#fbjs .focus\\:fb-ring-0:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color)}#fbjs .focus\\:fb-ring-0:focus,#fbjs .focus\\:fb-ring-2:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs .focus\\:fb-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}#fbjs .focus\\:fb-ring-slate-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(100 116 139/var(--tw-ring-opacity))}#fbjs .focus\\:fb-ring-offset-0:focus{--tw-ring-offset-width:0px}#fbjs .focus\\:fb-ring-offset-2:focus{--tw-ring-offset-width:2px}@media (min-width:640px){#fbjs .sm\\:fb-block{display:block}#fbjs .sm\\:fb-items-end{align-items:flex-end}#fbjs .sm\\:fb-p-6{padding:1.5rem}#fbjs .sm\\:fb-text-sm{font-size:.875rem;line-height:1.25rem}}',document.head.appendChild(e)}})(),qe&&qe.get().environmentId===e.environmentId&&qe.get().apiHost===e.apiHost){if(qe.get().session&&Te(qe.get().session)){const{session:e,settings:t}=await Ee();qe.update({session:Ne(e),settings:t}),ve("New Session")}else if(!qe.get().session)return void Le.error("Unable to initialize. No session found")}else{qe.update({environmentId:e.environmentId,apiHost:e.apiHost});const{person:t,session:n,settings:o}=await ke();qe.update({person:t,session:Ne(n),settings:o}),ve("New Session")}(()=>{if("undefined"!=typeof window){const e=window.setInterval(async()=>{await(async()=>{if(Ie.debug("Checking session"),Te(Ce.get().session)){Ie.debug("Session expired, creating new session");const{session:e,settings:t}=await Ee();if(!e||!t)throw Ie.error("Error creating new session"),Error("Error creating new session");Ce.update({session:e,settings:t}),ve("New Session")}Ie.debug("Session not expired, extending session"),Ce.update({session:Ne(Ce.get().session)})})()},3e5);window.addEventListener("beforeunload",()=>{clearInterval(e)})}})(),"undefined"!=typeof window&&(window.addEventListener("hashchange",ze),window.addEventListener("popstate",ze),window.addEventListener("pushstate",ze),window.addEventListener("replacestate",ze),window.addEventListener("load",ze)),Le.debug("Initialized")})(e)})},setUserId:e=>{Pe.add(async()=>{Oe(),await(async e=>{if(xe.debug("setting userId: "+e),Se("userId",e))return void xe.debug("userId already set to this value. Skipping update.");if((e=>{const t=je.get().person.attributes.find(e=>{var t;return"userId"===(null==(t=e.attributeClass)?void 0:t.name)});return!!t})())return void xe.error("userId cannot be changed after it has been set. You need to reset first");const{person:t,settings:n}=await(async e=>{if(!je.get().person||!je.get().person.id)return void console.error("Formbricks: Unable to update userId. No person set.");const t=await fetch(`${je.get().apiHost}/api/v1/client/environments/${je.get().environmentId}/people/${je.get().person.id}/user-id`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,sessionId:je.get().session.id})});if(!t.ok)throw xe.error("Formbricks: Error updating person"),Error("Error updating person");return await t.json()})(e);je.update({person:t,settings:n})})(e)})},setEmail:e=>{Ue("email",e)},setAttribute:Ue,track:(e,t={})=>{Pe.add(async()=>{Oe(),await ve(e,t)})},logout:()=>{Pe.add(async()=>{Oe(),await(async()=>{xe.debug("Resetting person. Getting new person, session and settings from backend");const{person:e,session:t,settings:n}=await ke();if(!e||!t||!n)throw xe.error("Error resetting user"),new Error("Formbricks: Error resetting user");je.update({person:e,session:t,settings:n})})()})},refresh:()=>{Pe.add(async()=>{Oe(),await(async()=>{fe.debug("Refreshing - getting settings from backend");const e=await ce();le.update({settings:e})})()})},registerRouteChange:()=>{Pe.add(async()=>{Oe(),ze()})}};export{Ae as default};
var e,t,n,o,r,s,i,a={},f=[],l=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(e,t){for(var n in t)e[n]=t[n];return e}function d(e){var t=e.parentNode;t&&t.removeChild(e)}function b(t,n,o){var r,s,i,a={};for(i in n)"key"==i?r=n[i]:"ref"==i?s=n[i]:a[i]=n[i];if(arguments.length>2&&(a.children=arguments.length>3?e.call(arguments,2):o),"function"==typeof t&&null!=t.defaultProps)for(i in t.defaultProps)void 0===a[i]&&(a[i]=t.defaultProps[i]);return u(t,a,r,s,null)}function u(e,o,r,s,i){var a={type:e,props:o,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==i?++n:i};return null==i&&null!=t.vnode&&t.vnode(a),a}function p(e){return e.children}function _(e,t){this.props=e,this.context=t}function g(e,t){if(null==t)return e.__?g(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?g(e):null}function h(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return h(e)}}function w(e){(!e.__d&&(e.__d=!0)&&o.push(e)&&!m.__r++||r!==t.debounceRendering)&&((r=t.debounceRendering)||s)(m)}function m(){var e,t,n,r,s,a,f,l;for(o.sort(i);e=o.shift();)e.__d&&(t=o.length,r=void 0,s=void 0,f=(a=(n=e).__v).__e,(l=n.__P)&&(r=[],(s=c({},a)).__v=a.__v+1,E(l,a,s,n.__n,void 0!==l.ownerSVGElement,null!=a.__h?[f]:null,r,null==f?g(a):f,a.__h),N(r,a),a.__e!=f&&h(a)),o.length>t&&o.sort(i));m.__r=0}function v(e,t,n,o,r,s,i,l,c,d){var b,_,h,w,m,v,k,C=o&&o.__k||f,S=C.length;for(n.__k=[],b=0;b<t.length;b++)if(null!=(w=n.__k[b]=null==(w=t[b])||"boolean"==typeof w||"function"==typeof w?null:"string"==typeof w||"number"==typeof w||"bigint"==typeof w?u(null,w,null,null,w):Array.isArray(w)?u(p,{children:w},null,null,null):w.__b>0?u(w.type,w.props,w.key,w.ref?w.ref:null,w.__v):w)){if(w.__=n,w.__b=n.__b+1,null===(h=C[b])||h&&w.key==h.key&&w.type===h.type)C[b]=void 0;else for(_=0;_<S;_++){if((h=C[_])&&w.key==h.key&&w.type===h.type){C[_]=void 0;break}h=null}E(e,w,h=h||a,r,s,i,l,c,d),m=w.__e,(_=w.ref)&&h.ref!=_&&(k||(k=[]),h.ref&&k.push(h.ref,null,w),k.push(_,w.__c||m,w)),null!=m?(null==v&&(v=m),"function"==typeof w.type&&w.__k===h.__k?w.__d=c=y(w,c,e):c=j(e,w,h,C,m,c),"function"==typeof n.type&&(n.__d=c)):c&&h.__e==c&&c.parentNode!=e&&(c=g(h))}for(n.__e=v,b=S;b--;)null!=C[b]&&("function"==typeof n.type&&null!=C[b].__e&&C[b].__e==n.__d&&(n.__d=x(o).nextSibling),$(C[b],C[b]));if(k)for(b=0;b<k.length;b++)T(k[b],k[++b],k[++b])}function y(e,t,n){for(var o,r=e.__k,s=0;r&&s<r.length;s++)(o=r[s])&&(o.__=e,t="function"==typeof o.type?y(o,t,n):j(n,o,o,r,o.__e,t));return t}function j(e,t,n,o,r,s){var i,a,f;if(void 0!==t.__d)i=t.__d,t.__d=void 0;else if(null==n||r!=s||null==r.parentNode)e:if(null==s||s.parentNode!==e)e.appendChild(r),i=null;else{for(a=s,f=0;(a=a.nextSibling)&&f<o.length;f+=1)if(a==r)break e;e.insertBefore(r,s),i=s}return void 0!==i?i:r.nextSibling}function x(e){var t,n,o;if(null==e.type||"string"==typeof e.type)return e.__e;if(e.__k)for(t=e.__k.length-1;t>=0;t--)if((n=e.__k[t])&&(o=x(n)))return o;return null}function k(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||l.test(t)?n:n+"px"}function C(e,t,n,o,r){var s;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof o&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||k(e.style,t,"");if(n)for(t in n)o&&n[t]===o[t]||k(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])s=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?o||e.addEventListener(t,s?I:S,s):e.removeEventListener(t,s?I:S,s);else if("dangerouslySetInnerHTML"!==t){if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function S(e){return this.l[e.type+!1](t.event?t.event(e):e)}function I(e){return this.l[e.type+!0](t.event?t.event(e):e)}function E(e,n,o,r,s,i,a,f,l){var d,b,u,g,h,w,m,y,j,x,k,C,S,I,E,N=n.type;if(void 0!==n.constructor)return null;null!=o.__h&&(l=o.__h,f=n.__e=o.__e,n.__h=null,i=[f]),(d=t.__b)&&d(n);try{e:if("function"==typeof N){if(y=n.props,j=(d=N.contextType)&&r[d.__c],x=d?j?j.props.value:d.__:r,o.__c?m=(b=n.__c=o.__c).__=b.__E:("prototype"in N&&N.prototype.render?n.__c=b=new N(y,x):(n.__c=b=new _(y,x),b.constructor=N,b.render=z),j&&j.sub(b),b.props=y,b.state||(b.state={}),b.context=x,b.__n=r,u=b.__d=!0,b.__h=[],b._sb=[]),null==b.__s&&(b.__s=b.state),null!=N.getDerivedStateFromProps&&(b.__s==b.state&&(b.__s=c({},b.__s)),c(b.__s,N.getDerivedStateFromProps(y,b.__s))),g=b.props,h=b.state,b.__v=n,u)null==N.getDerivedStateFromProps&&null!=b.componentWillMount&&b.componentWillMount(),null!=b.componentDidMount&&b.__h.push(b.componentDidMount);else{if(null==N.getDerivedStateFromProps&&y!==g&&null!=b.componentWillReceiveProps&&b.componentWillReceiveProps(y,x),!b.__e&&null!=b.shouldComponentUpdate&&!1===b.shouldComponentUpdate(y,b.__s,x)||n.__v===o.__v){for(n.__v!==o.__v&&(b.props=y,b.state=b.__s,b.__d=!1),b.__e=!1,n.__e=o.__e,n.__k=o.__k,n.__k.forEach(function(e){e&&(e.__=n)}),k=0;k<b._sb.length;k++)b.__h.push(b._sb[k]);b._sb=[],b.__h.length&&a.push(b);break e}null!=b.componentWillUpdate&&b.componentWillUpdate(y,b.__s,x),null!=b.componentDidUpdate&&b.__h.push(function(){b.componentDidUpdate(g,h,w)})}if(b.context=x,b.props=y,b.__P=e,C=t.__r,S=0,"prototype"in N&&N.prototype.render){for(b.state=b.__s,b.__d=!1,C&&C(n),d=b.render(b.props,b.state,b.context),I=0;I<b._sb.length;I++)b.__h.push(b._sb[I]);b._sb=[]}else do{b.__d=!1,C&&C(n),d=b.render(b.props,b.state,b.context),b.state=b.__s}while(b.__d&&++S<25);b.state=b.__s,null!=b.getChildContext&&(r=c(c({},r),b.getChildContext())),u||null==b.getSnapshotBeforeUpdate||(w=b.getSnapshotBeforeUpdate(g,h)),E=null!=d&&d.type===p&&null==d.key?d.props.children:d,v(e,Array.isArray(E)?E:[E],n,o,r,s,i,a,f,l),b.base=n.__e,n.__h=null,b.__h.length&&a.push(b),m&&(b.__E=b.__=null),b.__e=!1}else null==i&&n.__v===o.__v?(n.__k=o.__k,n.__e=o.__e):n.__e=H(o.__e,n,o,r,s,i,a,l);(d=t.diffed)&&d(n)}catch(e){n.__v=null,(l||null!=i)&&(n.__e=f,n.__h=!!l,i[i.indexOf(f)]=null),t.__e(e,n,o)}}function N(e,n){t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){t.__e(e,n.__v)}})}function H(t,n,o,r,s,i,f,l){var c,b,u,p=o.props,_=n.props,h=n.type,w=0;if("svg"===h&&(s=!0),null!=i)for(;w<i.length;w++)if((c=i[w])&&"setAttribute"in c==!!h&&(h?c.localName===h:3===c.nodeType)){t=c,i[w]=null;break}if(null==t){if(null===h)return document.createTextNode(_);t=s?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,_.is&&_),i=null,l=!1}if(null===h)p===_||l&&t.data===_||(t.data=_);else{if(i=i&&e.call(t.childNodes),b=(p=o.props||a).dangerouslySetInnerHTML,u=_.dangerouslySetInnerHTML,!l){if(null!=i)for(p={},w=0;w<t.attributes.length;w++)p[t.attributes[w].name]=t.attributes[w].value;(u||b)&&(u&&(b&&u.__html==b.__html||u.__html===t.innerHTML)||(t.innerHTML=u&&u.__html||""))}if(function(e,t,n,o,r){var s;for(s in n)"children"===s||"key"===s||s in t||C(e,s,null,n[s],o);for(s in t)r&&"function"!=typeof t[s]||"children"===s||"key"===s||"value"===s||"checked"===s||n[s]===t[s]||C(e,s,t[s],n[s],o)}(t,_,p,s,l),u)n.__k=[];else if(w=n.props.children,v(t,Array.isArray(w)?w:[w],n,o,r,s&&"foreignObject"!==h,i,f,i?i[0]:o.__k&&g(o,0),l),null!=i)for(w=i.length;w--;)null!=i[w]&&d(i[w]);l||("value"in _&&void 0!==(w=_.value)&&(w!==t.value||"progress"===h&&!w||"option"===h&&w!==p.value)&&C(t,"value",w,p.value,!1),"checked"in _&&void 0!==(w=_.checked)&&w!==t.checked&&C(t,"checked",w,p.checked,!1))}return t}function T(e,n,o){try{"function"==typeof e?e(n):e.current=n}catch(e){t.__e(e,o)}}function $(e,n,o){var r,s;if(t.unmount&&t.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||T(r,null,n)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){t.__e(e,n)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(s=0;s<r.length;s++)r[s]&&$(r[s],n,o||"function"!=typeof e.type);o||null==e.__e||d(e.__e),e.__=e.__e=e.__d=void 0}function z(e,t,n){return this.constructor(e,n)}e=f.slice,t={__e:function(e,t,n,o){for(var r,s,i;t=t.__;)if((r=t.__c)&&!r.__)try{if((s=r.constructor)&&null!=s.getDerivedStateFromError&&(r.setState(s.getDerivedStateFromError(e)),i=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,o||{}),i=r.__d),i)return r.__E=r}catch(t){e=t}throw e}},n=0,_.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof e&&(e=e(c({},n),this.props)),e&&c(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),w(this))},_.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),w(this))},_.prototype.render=p,o=[],s="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,i=function(e,t){return e.__v.__b-t.__v.__b},m.__r=0;var F,L,q,O,U=0,P=[],A=[],M=t.__b,D=t.__r,W=t.diffed,J=t.__c,B=t.unmount;function R(e,n){t.__h&&t.__h(L,e,U||n),U=0;var o=L.__H||(L.__H={__:[],__h:[]});return e>=o.__.length&&o.__.push({__V:A}),o.__[e]}function V(e){return U=1,function(e,t,n){var o=R(F++,2);if(o.t=e,!o.__c&&(o.__=[ee(void 0,t),function(e){var t=o.__N?o.__N[0]:o.__[0],n=o.t(t,e);t!==n&&(o.__N=[n,o.__[1]],o.__c.setState({}))}],o.__c=L,!L.u)){var r=function(e,t,n){if(!o.__c.__H)return!0;var r=o.__c.__H.__.filter(function(e){return e.__c});if(r.every(function(e){return!e.__N}))return!s||s.call(this,e,t,n);var i=!1;return r.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(i=!0)}}),!(!i&&o.__c.props===e)&&(!s||s.call(this,e,t,n))};L.u=!0;var s=L.shouldComponentUpdate,i=L.componentWillUpdate;L.componentWillUpdate=function(e,t,n){if(this.__e){var o=s;s=void 0,r(e,t,n),s=o}i&&i.call(this,e,t,n)},L.shouldComponentUpdate=r}return o.__N||o.__}(ee,e)}function Y(e,n){var o=R(F++,3);!t.__s&&function(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}(o.__H,n)&&(o.__=e,o.i=n,L.__H.__h.push(o))}function Q(){for(var e;e=P.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(K),e.__H.__h.forEach(Z),e.__H.__h=[]}catch(n){e.__H.__h=[],t.__e(n,e.__v)}}t.__b=function(e){L=null,M&&M(e)},t.__r=function(e){D&&D(e),F=0;var t=(L=e.__c).__H;t&&(q===L?(t.__h=[],L.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.__V=A,e.__N=e.i=void 0})):(t.__h.forEach(K),t.__h.forEach(Z),t.__h=[])),q=L},t.diffed=function(e){W&&W(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==P.push(n)&&O===t.requestAnimationFrame||((O=t.requestAnimationFrame)||G)(Q)),n.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.__V!==A&&(e.__=e.__V),e.i=void 0,e.__V=A})),q=L=null},t.__c=function(e,n){n.some(function(e){try{e.__h.forEach(K),e.__h=e.__h.filter(function(e){return!e.__||Z(e)})}catch(o){n.some(function(e){e.__h&&(e.__h=[])}),n=[],t.__e(o,e.__v)}}),J&&J(e,n)},t.unmount=function(e){B&&B(e);var n,o=e.__c;o&&o.__H&&(o.__H.__.forEach(function(e){try{K(e)}catch(e){n=e}}),o.__H=void 0,n&&t.__e(n,o.__v))};var X="function"==typeof requestAnimationFrame;function G(e){var t,n=function(){clearTimeout(o),X&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,100);X&&(t=requestAnimationFrame(n))}function K(e){var t=L,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),L=t}function Z(e){var t=L;e.__c=e.__(),L=t}function ee(e,t){return"function"==typeof t?t(e):t}const te=(...e)=>e.filter(Boolean).join(" ");function ne({children:e,isOpen:t,close:n}){const[o,r]=V(!1);return Y(()=>{r(t)},[t]),b("div",{"aria-live":"assertive",className:"fb-pointer-events-none fb-fixed fb-inset-0 fb-flex fb-items-end fb-px-4 fb-py-6 sm:fb-p-6"},b("div",{className:"fb-flex fb-w-full fb-flex-col fb-items-center fb-space-y-4 sm:fb-items-end"},b("div",{className:te(o?"fb-translate-x-0 fb-opacity-100":"fb-translate-x-28 fb-opacity-0","fb-pointer-events-auto fb-relative fb-w-full fb-max-w-sm fb-overflow-hidden fb-rounded-lg fb-bg-white fb-shadow-lg fb-ring-1 fb-ring-black fb-ring-opacity-5 fb-transition-all fb-duration-500 fb-ease-in-out")},b("div",{class:"fb-absolute fb-top-0 fb-right-0 fb-hidden fb-pt-4 fb-pr-4 sm:fb-block"},b("button",{type:"button",onClick:n,class:"fb-rounded-md fb-bg-white focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 fb-text-slate-400 hover:fb-text-slate-500 focus:ring-slate-500"},b("span",{class:"fb-sr-only"},"Close"),b("svg",{class:"fb-h-6 fb-w-6",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},b("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})))),b("div",{className:""},e))))}const oe=async(e,t)=>{if(!(await fetch(`${t.apiHost}/api/v1/client/environments/${t.environmentId}/displays/${e}/responded`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Could not update display")},re=async(e,t)=>{const n=await fetch(`${t.apiHost}/api/v1/client/environments/${t.environmentId}/responses`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw console.error(n.text),new Error("Could not create response");return await n.json()};function se({headline:e,questionId:t}){return b("label",{htmlFor:t,className:"fb-block fb-text-base fb-font-semibold fb-leading-6 fb-mr-8 text-slate-900"},e)}function ie({subheader:e,questionId:t}){return b("label",{for:t,className:"fb-block fb-text-sm fb-font-normal fb-leading-6 text-slate-600"},e)}function ae({question:e,onSubmit:t,lastQuestion:n,brandColor:o}){return b("form",{onSubmit:n=>{n.preventDefault();const o={[e.id]:n.currentTarget[e.id].value};n.currentTarget[e.id].value="",t(o)}},b(se,{headline:e.headline,questionId:e.id}),b(ie,{subheader:e.subheader,questionId:e.id}),b("div",{className:"fb-mt-4"},b("textarea",{rows:3,name:e.id,id:e.id,placeholder:e.placeholder,required:e.required,className:"fb-block fb-w-full fb-rounded-md fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm fb-bg-slate-50 fb-border-slate-100 focus:fb-border-slate-500"})),b("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},b("div",null),b("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:fb-ring-slate-500",style:{backgroundColor:o}},e.buttonLabel||(n?"Finish":"Next"))))}function fe({question:e,onSubmit:t,lastQuestion:n,brandColor:o}){const[r,s]=V(null);return b("form",{onSubmit:n=>{n.preventDefault();const o={[e.id]:n.currentTarget[e.id].value};n.currentTarget[e.id].value="",t(o)}},b(se,{headline:e.headline,questionId:e.id}),b(ie,{subheader:e.subheader,questionId:e.id}),b("div",{className:"fb-mt-4"},b("fieldset",null,b("legend",{className:"fb-sr-only"},"Choices"),b("div",{className:"fb-relative fb-space-y-2 fb-rounded-md fb-bg-white"},e.choices&&e.choices.map(t=>b("label",{key:t.id,className:te(r===t.label?"fb-z-10 fb-bg-slate-50 fb-border-slate-400":"fb-border-gray-200","fb-relative fb-flex fb-cursor-pointer fb-flex-col fb-rounded-md fb-border fb-p-4 focus:fb-outline-none hover:bg-slate-50")},b("span",{className:"fb-flex fb-items-center fb-text-sm"},b("input",{type:"radio",id:t.id,name:e.id,value:t.label,className:"fb-h-4 fb-w-4 fb-border fb-border-slate-300 focus:fb-ring-0 focus:fb-ring-offset-0","aria-labelledby":`${t.id}-label`,onChange:e=>{s(e.currentTarget.value)},style:{borderColor:o,color:o}}),b("span",{id:`${t.id}-label`,className:"fb-ml-3 fb-font-medium"},t.label))))))),b("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},b("div",null),b("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:ring-slate-500",style:{backgroundColor:o}},e.buttonLabel||(n?"Finish":"Next"))))}function le({progress:e,brandColor:t}){return b("div",{className:"fb-h-1 fb-w-full fb-rounded-full bg-slate-200"},b("div",{className:"fb-h-1 fb-rounded-full",style:{backgroundColor:t,width:`${Math.floor(100*e)}%`}}))}function ce({config:e,survey:t,close:n,brandColor:o}){const[r,s]=V(t.questions[0]),[i,a]=V(0),[f,l]=V(null),[c,d]=V(null),[u,p]=V(!1);Y(()=>{!async function(){const n=await(async(e,t)=>{const n=await fetch(`${t.apiHost}/api/v1/client/environments/${t.environmentId}/displays`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw console.error(n.text),new Error("Could not create display");return await n.json()})({surveyId:t.id,personId:e.person.id},e);d(n.id)}()},[e,t]),Y(()=>{a(function(){const e=t.questions.findIndex(e=>e.id===r.id);return e/t.questions.length}())},[r,t]);const _=async o=>{p(!0);const i=t.questions.findIndex(e=>e.id===r.id),d=i===t.questions.length-1,b={surveyId:t.id,personId:e.person.id,response:{finished:d,data:o}};if(f)await(async(e,t,n)=>{const o=await fetch(`${n.apiHost}/api/v1/client/environments/${n.environmentId}/responses/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error("Could not update response");return await o.json()})(b,f,e);else{const[t,n]=await Promise.all([re(b,e),oe(c,e)]);l(t.id)}p(!1),d?(a(100),n()):s(t.questions[i+1])};return b("div",null,b("div",{className:te(u?"fb-animate-pulse fb-opacity-60":"","fb-p-4 fb-text-slate-800 fb-font-sans")},"multipleChoiceSingle"===r.type?b(fe,{question:r,onSubmit:_,lastQuestion:t.questions.findIndex(e=>e.id===r.id)===t.questions.length-1,brandColor:o}):"openText"===r.type?b(ae,{question:r,onSubmit:_,lastQuestion:t.questions.findIndex(e=>e.id===r.id)===t.questions.length-1,brandColor:o}):null),b("div",{className:"fb-mt-2"},b(le,{progress:i,brandColor:o})))}function de({config:e,survey:t,closeSurvey:n}){var o;const[r,s]=V(!0),i=()=>{s(!1),setTimeout(()=>{n()},1e3)};return b("div",{id:"fbjs"},b(ne,{isOpen:r,close:i},b(ce,{config:e,survey:t,close:i,brandColor:null==(o=e.settings)?void 0:o.brandColor})))}function be(){return be=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},be.apply(this,arguments)}class ue{constructor(){this.config=this.loadFromLocalStorage()}static getInstance(){return ue.instance||(ue.instance=new ue),ue.instance}update(e){e&&(this.config=be({},this.config,e),this.saveToLocalStorage())}get(){return this.config}loadFromLocalStorage(){if("undefined"!=typeof window){const e=localStorage.getItem("config");if(e)return JSON.parse(e)}return{apiHost:null,environmentId:null}}saveToLocalStorage(){localStorage.setItem("config",JSON.stringify(this.config))}}ue.instance=void 0;class pe{constructor(){this.logLevel="error"}static getInstance(){return pe.instance||(pe.instance=new pe),pe.instance}configure(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)}logger(e,t){if("debug"===t&&"debug"!==this.logLevel)return;const n=`🧱 Formbricks - ${(new Date).toISOString()} [${t.toUpperCase()}] - ${e}`;"error"===t?console.error(n):console.log(n)}debug(e){this.logger(e,"debug")}error(e){this.logger(e,"error")}}pe.instance=void 0;const _e=pe.getInstance(),ge=ue.getInstance(),he=async()=>{const e=await fetch(`${ge.get().apiHost}/api/v1/client/environments/${ge.get().environmentId}/settings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:ge.get().person.id})});if(!e.ok)throw _e.error("Error getting settings"),Error("Error getting settings");return e.json()},we="formbricks-web-container",me=ue.getInstance(),ve=pe.getInstance();let ye=!1;const je=n=>{ye?ve.debug("A survey is already running. Skipping."):(ye=!0,function(n,o,r){var s,i;t.__&&t.__(n,o),s=o.__k,i=[],E(o,n=o.__k=b(p,null,[n]),s||a,a,void 0!==o.ownerSVGElement,s?null:o.firstChild?e.call(o.childNodes):null,i,s?s.__e:o.firstChild,!1),N(i,n)}(b(de,{config:me.get(),survey:n,closeSurvey:xe}),document.getElementById(we)))},xe=async()=>{document.getElementById(we).remove(),ke();const e=await he();me.update({settings:e}),ye=!1},ke=()=>{const e=document.createElement("div");e.id=we,document.body.appendChild(e)},Ce=pe.getInstance(),Se=ue.getInstance(),Ie=async(e,t)=>{const n=await fetch(`${Se.get().apiHost}/api/v1/client/environments/${Se.get().environmentId}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Se.get().session.id,eventName:e,properties:t})});if(n.ok)Ce.debug(`Formbricks: Event "${e}" tracked`),Ee(e);else{const e=await n.json();Ce.error(`Formbricks: Error tracking event: ${JSON.stringify(e)}`)}},Ee=e=>{for(const o of null==(t=Se.get().settings)?void 0:t.surveys){var t;for(const t of o.triggers){var n;if((null==(n=t.eventClass)?void 0:n.name)===e)return Ce.debug(`Formbricks: survey ${o.id} triggered by event "${e}"`),void je(o)}}},Ne=ue.getInstance(),He=pe.getInstance(),Te=async()=>{He.debug("Creating new person");const e=await fetch(`${Ne.get().apiHost}/api/v1/client/environments/${Ne.get().environmentId}/people`,{method:"POST",headers:{"Content-Type":"application/json"}});return e.ok?await e.json():(console.error("Formbricks: Error fetching person"),null)},$e=(e,t)=>{const n=Ne.get().person.attributes.find(t=>{var n;return(null==(n=t.attributeClass)?void 0:n.name)===e});return!(!n||n.value!==t)},ze=pe.getInstance(),Fe=ue.getInstance(),Le=async()=>{if(!Fe.get().person)return void ze.error("Formbricks: Unable to create session. No person found");const e=await fetch(`${Fe.get().apiHost}/api/v1/client/environments/${Fe.get().environmentId}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:Fe.get().person.id})});if(e.ok)return await e.json();ze.error("Error creating session")},qe=e=>{ze.debug("Session expired. Creating new session.");const t=be({},e);return t.expiresAt=Date.now()+36e5,t},Oe=e=>e.expiresAt<=Date.now(),Ue=ue.getInstance(),Pe=pe.getInstance(),Ae=()=>{const{settings:e}=Ue.get(),t=null==e?void 0:e.noCodeEvents.filter(e=>{var t;return"pageUrl"===(null==(t=e.noCodeConfig)?void 0:t.type)});if(Pe.debug("checking page url"),0!==t.length)for(const e of t){const{noCodeConfig:{pageUrl:t}}=e;t&&Me(window.location.href,t.value,t.rule)&&Ie(e.name)}};function Me(e,t,n){switch(n){case"exactMatch":return e===t;case"contains":return e.includes(t);case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"notMatch":return e!==t;case"notContains":return!e.includes(t);default:throw new Error("Invalid match type")}}const De=e=>{const{settings:t}=Ue.get(),n=null==t?void 0:t.noCodeEvents.filter(e=>{var t;return"innerHtml"===(null==(t=e.noCodeConfig)?void 0:t.type)}),o=null==t?void 0:t.noCodeEvents.filter(e=>{var t;return"cssSelector"===(null==(t=e.noCodeConfig)?void 0:t.type)}),r=e.target;n.forEach(e=>{var t;const n=null==(t=e.noCodeConfig)?void 0:t.innerHtml;n&&r.innerHTML===n.value&&Ie(e.name)}),o.forEach(e=>{var t;const n=null==(t=e.noCodeConfig)?void 0:t.cssSelector;n&&r.matches(n.value)&&Ie(e.name)})},We=ue.getInstance(),Je=pe.getInstance(),Be=()=>{if(!(We.get().apiHost&&We.get().environmentId&&We.get().person&&We.get().session&&We.get().settings))throw Error("Formbricks: Formbricks not initialized. Call initialize() first.")},Re=new class{constructor(){this.queue=[],this.running=!1}add(e){this.queue.push(e),this.running||this.run()}async run(){for(this.running=!0;this.queue.length>0;){const e=this.queue.shift();try{await e()}catch(e){console.error(e)}}this.running=!1}},Ve=(e,t)=>{Re.add(async()=>{Be(),await(async(e,t)=>{if(He.debug("setting attribute: "+e+" to value: "+t),$e(e,t))return void He.debug("attribute already set to this value. Skipping update.");const{person:n,settings:o}=await(async(e,t)=>{if(!Ne.get().person||!Ne.get().person.id)return void console.error("Formbricks: Unable to update attribute. No person set.");const n=await fetch(`${Ne.get().apiHost}/api/v1/client/environments/${Ne.get().environmentId}/people/${Ne.get().person.id}/attribute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:t})}),o=await n.json();if(!n.ok)throw He.error("Error updating person"),Error("Error updating person");return o})(e,t);if(!n||!o)throw He.error("Error updating attribute"),new Error("Formbricks: Error updating attribute");Ne.update({person:n,settings:o})})(e,t)})},Ye={init:e=>{Re.add(async()=>{(async e=>{if(!e.environmentId)throw Error("Formbricks: environmentId is required");if(!e.apiHost)throw Error("Formbricks: apiHost is required");if(e.logLevel&&Je.configure({logLevel:e.logLevel}),ke(),(()=>{if(null===document.getElementById("formbricks__css")){const e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :after,#fbjs :before{border:0 solid #e5e7eb;box-sizing:border-box}#fbjs :after,#fbjs :before{--tw-content:""}#fbjs html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#fbjs body{line-height:inherit;margin:0}#fbjs hr{border-top-width:1px;color:inherit;height:0}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs pre,#fbjs samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{border-collapse:collapse;border-color:inherit;text-indent:0}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit],#fbjs button{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dd,#fbjs dl,#fbjs figure,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs menu,#fbjs ol,#fbjs ul{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{color:#9ca3af;opacity:1}#fbjs input::placeholder,#fbjs textarea::placeholder{color:#9ca3af;opacity:1}#fbjs [role=button],#fbjs button{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs audio,#fbjs canvas,#fbjs embed,#fbjs iframe,#fbjs img,#fbjs object,#fbjs svg,#fbjs video{display:block;vertical-align:middle}#fbjs img,#fbjs video{height:auto;max-width:100%}#fbjs [hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#fbjs :is(.fb-sr-only){clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}#fbjs :is(.fb-pointer-events-none){pointer-events:none}#fbjs :is(.fb-pointer-events-auto){pointer-events:auto}#fbjs :is(.fb-fixed){position:fixed}#fbjs :is(.fb-absolute){position:absolute}#fbjs :is(.fb-relative){position:relative}#fbjs :is(.fb-inset-0){inset:0}#fbjs :is(.fb-right-0){right:0}#fbjs :is(.fb-top-0){top:0}#fbjs :is(.fb-z-10){z-index:10}#fbjs :is(.fb-ml-3){margin-left:.75rem}#fbjs :is(.fb-mr-8){margin-right:2rem}#fbjs :is(.fb-mt-2){margin-top:.5rem}#fbjs :is(.fb-mt-4){margin-top:1rem}#fbjs :is(.fb-block){display:block}#fbjs :is(.fb-flex){display:flex}#fbjs :is(.fb-hidden){display:none}#fbjs :is(.fb-h-1){height:.25rem}#fbjs :is(.fb-h-4){height:1rem}#fbjs :is(.fb-h-6){height:1.5rem}#fbjs :is(.fb-w-4){width:1rem}#fbjs :is(.fb-w-6){width:1.5rem}#fbjs :is(.fb-w-full){width:100%}#fbjs :is(.fb-max-w-sm){max-width:24rem}#fbjs :is(.fb-translate-x-0){--tw-translate-x:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.fb-translate-x-28){--tw-translate-x:7rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes fb-pulse{50%{opacity:.5}}#fbjs :is(.fb-animate-pulse){animation:fb-pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs :is(.fb-cursor-pointer){cursor:pointer}#fbjs :is(.fb-flex-col){flex-direction:column}#fbjs :is(.fb-items-end){align-items:flex-end}#fbjs :is(.fb-items-center){align-items:center}#fbjs :is(.fb-justify-between){justify-content:space-between}#fbjs :is(.fb-space-y-2>:not([hidden])~:not([hidden])){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}#fbjs :is(.fb-space-y-4>:not([hidden])~:not([hidden])){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}#fbjs :is(.fb-overflow-hidden){overflow:hidden}#fbjs :is(.fb-rounded-full){border-radius:9999px}#fbjs :is(.fb-rounded-lg){border-radius:.5rem}#fbjs :is(.fb-rounded-md){border-radius:.375rem}#fbjs :is(.fb-border){border-width:1px}#fbjs :is(.fb-border-gray-200){--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-100){--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-300){--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-400){--tw-border-opacity:1;border-color:rgb(148 163 184/var(--tw-border-opacity))}#fbjs :is(.fb-border-transparent){border-color:transparent}#fbjs :is(.fb-bg-slate-50){--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}#fbjs :is(.fb-bg-white){--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}#fbjs :is(.fb-p-2){padding:.5rem}#fbjs :is(.fb-p-4){padding:1rem}#fbjs :is(.fb-px-3){padding-left:.75rem;padding-right:.75rem}#fbjs :is(.fb-px-4){padding-left:1rem;padding-right:1rem}#fbjs :is(.fb-py-3){padding-bottom:.75rem;padding-top:.75rem}#fbjs :is(.fb-py-6){padding-bottom:1.5rem;padding-top:1.5rem}#fbjs :is(.fb-pr-4){padding-right:1rem}#fbjs :is(.fb-pt-4){padding-top:1rem}#fbjs :is(.fb-font-sans){font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}#fbjs :is(.fb-text-base){font-size:1rem;line-height:1.5rem}#fbjs :is(.fb-text-sm){font-size:.875rem;line-height:1.25rem}#fbjs :is(.fb-font-medium){font-weight:500}#fbjs :is(.fb-font-normal){font-weight:400}#fbjs :is(.fb-font-semibold){font-weight:600}#fbjs :is(.fb-leading-4){line-height:1rem}#fbjs :is(.fb-leading-6){line-height:1.5rem}#fbjs :is(.fb-text-slate-400){--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}#fbjs :is(.fb-text-slate-800){--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity))}#fbjs :is(.fb-text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}#fbjs :is(.fb-opacity-0){opacity:0}#fbjs :is(.fb-opacity-100){opacity:1}#fbjs :is(.fb-opacity-60){opacity:.6}#fbjs :is(.fb-shadow-lg){--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs :is(.fb-shadow-sm){--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs :is(.fb-ring-1){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.fb-ring-black){--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity))}#fbjs :is(.fb-ring-opacity-5){--tw-ring-opacity:0.05}#fbjs :is(.fb-transition-all){transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs :is(.fb-duration-500){transition-duration:.5s}#fbjs :is(.fb-ease-in-out){transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs :is(.hover\\:fb-text-slate-500:hover){--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}#fbjs :is(.hover\\:fb-opacity-90:hover){opacity:.9}#fbjs :is(.focus\\:fb-border-slate-500:focus){--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity))}#fbjs :is(.focus\\:fb-outline-none:focus){outline:2px solid transparent;outline-offset:2px}#fbjs :is(.focus\\:fb-ring-0:focus){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.focus\\:fb-ring-2:focus){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.focus\\:fb-ring-slate-500:focus){--tw-ring-opacity:1;--tw-ring-color:rgb(100 116 139/var(--tw-ring-opacity))}#fbjs :is(.focus\\:fb-ring-offset-0:focus){--tw-ring-offset-width:0px}#fbjs :is(.focus\\:fb-ring-offset-2:focus){--tw-ring-offset-width:2px}@media (min-width:640px){#fbjs :is(.sm\\:fb-block){display:block}#fbjs :is(.sm\\:fb-items-end){align-items:flex-end}#fbjs :is(.sm\\:fb-p-6){padding:1.5rem}#fbjs :is(.sm\\:fb-text-sm){font-size:.875rem;line-height:1.25rem}}',document.head.appendChild(e)}})(),We&&We.get().environmentId===e.environmentId&&We.get().apiHost===e.apiHost){if(We.get().session&&Oe(We.get().session)){const{session:e,settings:t}=await Le();We.update({session:qe(e),settings:t}),Ie("New Session")}else if(!We.get().session)return void Je.error("Unable to initialize. No session found")}else{We.update({environmentId:e.environmentId,apiHost:e.apiHost});const{person:t,session:n,settings:o}=await Te();We.update({person:t,session:qe(n),settings:o}),Ie("New Session")}(()=>{if("undefined"!=typeof window){const e=window.setInterval(async()=>{await(async()=>{if(ze.debug("Checking session"),Oe(Fe.get().session)){ze.debug("Session expired, creating new session");const{session:e,settings:t}=await Le();if(!e||!t)throw ze.error("Error creating new session"),Error("Error creating new session");Fe.update({session:e,settings:t}),Ie("New Session")}ze.debug("Session not expired, extending session"),Fe.update({session:qe(Fe.get().session)})})()},3e5);window.addEventListener("beforeunload",()=>{clearInterval(e)})}})(),"undefined"!=typeof window&&(window.addEventListener("hashchange",Ae),window.addEventListener("popstate",Ae),window.addEventListener("pushstate",Ae),window.addEventListener("replacestate",Ae),window.addEventListener("load",Ae)),"undefined"!=typeof window&&document.addEventListener("click",De),Je.debug("Initialized")})(e)})},setUserId:e=>{Re.add(async()=>{Be(),await(async e=>{if(He.debug("setting userId: "+e),$e("userId",e))return void He.debug("userId already set to this value. Skipping update.");if((e=>{const t=Ne.get().person.attributes.find(e=>{var t;return"userId"===(null==(t=e.attributeClass)?void 0:t.name)});return!!t})())return void He.error("userId cannot be changed after it has been set. You need to reset first");const{person:t,settings:n}=await(async e=>{if(!Ne.get().person||!Ne.get().person.id)return void console.error("Formbricks: Unable to update userId. No person set.");const t=await fetch(`${Ne.get().apiHost}/api/v1/client/environments/${Ne.get().environmentId}/people/${Ne.get().person.id}/user-id`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,sessionId:Ne.get().session.id})});if(!t.ok)throw He.error("Formbricks: Error updating person"),Error("Error updating person");return await t.json()})(e);Ne.update({person:t,settings:n})})(e)})},setEmail:e=>{Ve("email",e)},setAttribute:Ve,track:(e,t={})=>{Re.add(async()=>{Be(),await Ie(e,t)})},logout:()=>{Re.add(async()=>{Be(),await(async()=>{He.debug("Resetting person. Getting new person, session and settings from backend");const{person:e,session:t,settings:n}=await Te();if(!e||!t||!n)throw He.error("Error resetting user"),new Error("Formbricks: Error resetting user");Ne.update({person:e,session:t,settings:n})})()})},refresh:()=>{Re.add(async()=>{Be(),await(async()=>{_e.debug("Refreshing - getting settings from backend");const e=await he();ge.update({settings:e})})()})},registerRouteChange:()=>{Re.add(async()=>{Be(),Ae()})}};export{Ye as default};
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

function e(n,r,o){if(!n.s){if(o instanceof t){if(!o.s)return void(o.o=e.bind(null,n,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(e.bind(null,n,r),e.bind(null,n,2));n.s=r,n.v=o;var i=n.o;i&&i(n)}}var t=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(n,r){var o=new t,i=this.s;if(i){var s=1&i?n:r;if(s){try{e(o,1,s(this.v))}catch(t){e(o,2,t)}return o}return this}return this.o=function(t){try{var i=t.v;1&t.s?e(o,1,n?n(i):i):r?e(o,1,r(i)):e(o,2,i)}catch(t){e(o,2,t)}},o},t}();function n(e){return e instanceof t&&1&e.s}var r=/*#__PURE__*/function(){function r(){this.queue=[],this.running=!1}var o=r.prototype;return o.add=function(e){this.queue.push(e),this.running||this.run()},o.run=function(){try{var r=function(){o.running=!1},o=this;o.running=!0;var i=function(r,o,i){for(var s;;){var a=r();if(n(a)&&(a=a.v),!a)return f;if(a.then){s=0;break}var f=i();if(f&&f.then){if(!n(f)){s=1;break}f=f.s}}var l=new t,u=e.bind(null,l,2);return(0===s?a.then(d):1===s?f.then(c):(void 0).then(function(){(a=r())?a.then?a.then(d).then(void 0,u):d(a):e(l,1,f)})).then(void 0,u),l;function c(t){f=t;do{if(!(a=r())||n(a)&&!a.v)return void e(l,1,f);if(a.then)return void a.then(d).then(void 0,u);n(f=i())&&(f=f.v)}while(!f||!f.then);f.then(c).then(void 0,u)}function d(t){t?(f=i())&&f.then?f.then(c).then(void 0,u):c(f):e(l,1,f)}}(function(){return o.queue.length>0},0,function(){var e=o.queue.shift(),t=function(t,n){try{var r=Promise.resolve(e()).then(function(){})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){console.error(e)});if(t&&t.then)return t.then(function(){})});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},r}();function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,f,l,u,c,d={},b=[],p=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function h(e,t){for(var n in t)e[n]=t[n];return e}function g(e){var t=e.parentNode;t&&t.removeChild(e)}function _(e,t,n){var r,o,i,s=arguments,a={};for(i in t)"key"==i?r=t[i]:"ref"==i?o=t[i]:a[i]=t[i];if(arguments.length>3)for(n=[n],i=3;i<arguments.length;i++)n.push(s[i]);if(null!=n&&(a.children=n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===a[i]&&(a[i]=e.defaultProps[i]);return v(e,a,r,o,null)}function v(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++a.__v:o};return null!=a.vnode&&a.vnode(i),i}function m(e){return e.children}function w(e,t){this.props=e,this.context=t}function y(e,t){if(null==t)return e.__?y(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?y(e):null}function j(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return j(e)}}function x(e){(!e.__d&&(e.__d=!0)&&f.push(e)&&!k.__r++||u!==a.debounceRendering)&&((u=a.debounceRendering)||l)(k)}function k(){for(var e;k.__r=f.length;)e=f.sort(function(e,t){return e.__v.__b-t.__v.__b}),f=[],e.some(function(e){var t,n,r,o,i,s,a;e.__d&&(s=(i=(t=e).__v).__e,(a=t.__P)&&(n=[],(r=h({},i)).__v=i.__v+1,o=H(a,i,r,t.__n,void 0!==a.ownerSVGElement,null!=i.__h?[s]:null,n,null==s?y(i):s,i.__h),z(n,i),o!=s&&j(i)))})}function P(e,t,n,r,o,i,s,a,f,l){var u,c,p,h,_,w,j,x=r&&r.__k||b,k=x.length;for(f==d&&(f=null!=s?s[0]:k?y(r,0):null),n.__k=[],u=0;u<t.length;u++)if(null!=(h=n.__k[u]=null==(h=t[u])||"boolean"==typeof h?null:"string"==typeof h||"number"==typeof h?v(null,h,null,null,h):Array.isArray(h)?v(m,{children:h},null,null,null):null!=h.__e||null!=h.__c?v(h.type,h.props,h.key,null,h.__v):h)){if(h.__=n,h.__b=n.__b+1,null===(p=x[u])||p&&h.key==p.key&&h.type===p.type)x[u]=void 0;else for(c=0;c<k;c++){if((p=x[c])&&h.key==p.key&&h.type===p.type){x[c]=void 0;break}p=null}_=H(e,h,p=p||d,o,i,s,a,f,l),(c=h.ref)&&p.ref!=c&&(j||(j=[]),p.ref&&j.push(p.ref,null,h),j.push(c,h.__c||_,h)),null!=_?(null==w&&(w=_),f=S(e,h,p,x,s,_,f),l||"option"!=n.type?"function"==typeof n.type&&(n.__d=f):e.value=""):f&&p.__e==f&&f.parentNode!=e&&(f=y(p))}if(n.__e=w,null!=s&&"function"!=typeof n.type)for(u=s.length;u--;)null!=s[u]&&g(s[u]);for(u=k;u--;)null!=x[u]&&q(x[u],x[u]);if(j)for(u=0;u<j.length;u++)F(j[u],j[++u],j[++u])}function S(e,t,n,r,o,i,s){var a,f,l;if(void 0!==t.__d)a=t.__d,t.__d=void 0;else if(o==n||i!=s||null==i.parentNode)e:if(null==s||s.parentNode!==e)e.appendChild(i),a=null;else{for(f=s,l=0;(f=f.nextSibling)&&l<r.length;l+=2)if(f==i)break e;e.insertBefore(i,s),a=s}return void 0!==a?a:i.nextSibling}function I(e,t,n){"-"===t[0]?e.setProperty(t,n):e[t]=null==n?"":"number"!=typeof n||p.test(t)?n:n+"px"}function C(e,t,n,r,o){var i,s,a;if(o&&"className"==t&&(t="class"),"style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||I(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||I(e.style,t,n[t])}else"o"===t[0]&&"n"===t[1]?(i=t!==(t=t.replace(/Capture$/,"")),(s=t.toLowerCase())in e&&(t=s),t=t.slice(2),e.l||(e.l={}),e.l[t+i]=n,a=i?N:E,n?r||e.addEventListener(t,a,i):e.removeEventListener(t,a,i)):"list"!==t&&"tagName"!==t&&"form"!==t&&"type"!==t&&"size"!==t&&"download"!==t&&"href"!==t&&!o&&t in e?e[t]=null==n?"":n:"function"!=typeof n&&"dangerouslySetInnerHTML"!==t&&(t!==(t=t.replace(/xlink:?/,""))?null==n||!1===n?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),n):null==n||!1===n&&!/^ar/.test(t)?e.removeAttribute(t):e.setAttribute(t,n))}function E(e){this.l[e.type+!1](a.event?a.event(e):e)}function N(e){this.l[e.type+!0](a.event?a.event(e):e)}function T(e,t,n){var r,o;for(r=0;r<e.__k.length;r++)(o=e.__k[r])&&(o.__=e,o.__e&&("function"==typeof o.type&&o.__k.length>1&&T(o,t,n),t=S(n,o,o,e.__k,null,o.__e,t),"function"==typeof e.type&&(e.__d=t)))}function H(e,t,n,r,o,i,s,f,l){var u,c,p,g,_,v,y,j,x,k,S,I=t.type;if(void 0!==t.constructor)return null;null!=n.__h&&(l=n.__h,f=t.__e=n.__e,t.__h=null,i=[f]),(u=a.__b)&&u(t);try{e:if("function"==typeof I){if(j=t.props,x=(u=I.contextType)&&r[u.__c],k=u?x?x.props.value:u.__:r,n.__c?y=(c=t.__c=n.__c).__=c.__E:("prototype"in I&&I.prototype.render?t.__c=c=new I(j,k):(t.__c=c=new w(j,k),c.constructor=I,c.render=L),x&&x.sub(c),c.props=j,c.state||(c.state={}),c.context=k,c.__n=r,p=c.__d=!0,c.__h=[]),null==c.__s&&(c.__s=c.state),null!=I.getDerivedStateFromProps&&(c.__s==c.state&&(c.__s=h({},c.__s)),h(c.__s,I.getDerivedStateFromProps(j,c.__s))),g=c.props,_=c.state,p)null==I.getDerivedStateFromProps&&null!=c.componentWillMount&&c.componentWillMount(),null!=c.componentDidMount&&c.__h.push(c.componentDidMount);else{if(null==I.getDerivedStateFromProps&&j!==g&&null!=c.componentWillReceiveProps&&c.componentWillReceiveProps(j,k),!c.__e&&null!=c.shouldComponentUpdate&&!1===c.shouldComponentUpdate(j,c.__s,k)||t.__v===n.__v){c.props=j,c.state=c.__s,t.__v!==n.__v&&(c.__d=!1),c.__v=t,t.__e=n.__e,t.__k=n.__k,c.__h.length&&s.push(c),T(t,f,e);break e}null!=c.componentWillUpdate&&c.componentWillUpdate(j,c.__s,k),null!=c.componentDidUpdate&&c.__h.push(function(){c.componentDidUpdate(g,_,v)})}c.context=k,c.props=j,c.state=c.__s,(u=a.__r)&&u(t),c.__d=!1,c.__v=t,c.__P=e,u=c.render(c.props,c.state,c.context),c.state=c.__s,null!=c.getChildContext&&(r=h(h({},r),c.getChildContext())),p||null==c.getSnapshotBeforeUpdate||(v=c.getSnapshotBeforeUpdate(g,_)),S=null!=u&&u.type==m&&null==u.key?u.props.children:u,P(e,Array.isArray(S)?S:[S],t,n,r,o,i,s,f,l),c.base=t.__e,t.__h=null,c.__h.length&&s.push(c),y&&(c.__E=c.__=null),c.__e=!1}else null==i&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,r,o,i,s,a){var f,l,u,c,p,h=n.props,g=t.props;if(o="svg"===t.type||o,null!=i)for(f=0;f<i.length;f++)if(null!=(l=i[f])&&((null===t.type?3===l.nodeType:l.localName===t.type)||e==l)){e=l,i[f]=null;break}if(null==e){if(null===t.type)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",t.type):document.createElement(t.type,g.is&&{is:g.is}),i=null,a=!1}if(null===t.type)h===g||a&&e.data===g||(e.data=g);else{if(null!=i&&(i=b.slice.call(e.childNodes)),u=(h=n.props||d).dangerouslySetInnerHTML,c=g.dangerouslySetInnerHTML,!a){if(null!=i)for(h={},p=0;p<e.attributes.length;p++)h[e.attributes[p].name]=e.attributes[p].value;(c||u)&&(c&&(u&&c.__html==u.__html||c.__html===e.innerHTML)||(e.innerHTML=c&&c.__html||""))}(function(e,t,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in t||C(e,i,null,n[i],r);for(i in t)o&&"function"!=typeof t[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===t[i]||C(e,i,t[i],n[i],r)})(e,g,h,o,a),c?t.__k=[]:(f=t.props.children,P(e,Array.isArray(f)?f:[f],t,n,r,"foreignObject"!==t.type&&o,i,s,d,a)),a||("value"in g&&void 0!==(f=g.value)&&(f!==e.value||"progress"===t.type&&!f)&&C(e,"value",f,h.value,!1),"checked"in g&&void 0!==(f=g.checked)&&f!==e.checked&&C(e,"checked",f,h.checked,!1))}return e}(n.__e,t,n,r,o,i,s,l);(u=a.diffed)&&u(t)}catch(e){t.__v=null,(l||null!=i)&&(t.__e=f,t.__h=!!l,i[i.indexOf(f)]=null),a.__e(e,t,n)}return t.__e}function z(e,t){a.__c&&a.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){a.__e(e,t.__v)}})}function F(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){a.__e(e,n)}}function q(e,t,n){var r,o,i;if(a.unmount&&a.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||F(r,null,t)),n||"function"==typeof e.type||(n=null!=(o=e.__e)),e.__e=e.__d=void 0,null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){a.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&q(r[i],t,n);null!=o&&g(o)}function L(e,t,n){return this.constructor(e,n)}a={__e:function(e,t){for(var n,r,o,i=t.__h;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e),o=n.__d),o)return t.__h=i,n.__E=n}catch(t){e=t}throw e},__v:0},w.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(h({},n),this.props)),e&&h(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),x(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),x(this))},w.prototype.render=m,f=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,k.__r=0,c=d;var O,A,U,M=0,D=[],W=a.__b,J=a.__r,B=a.diffed,R=a.__c,Q=a.unmount;function G(e,t){a.__h&&a.__h(A,e,M||t),M=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return M=1,function(e,t,n){var r=G(O++,2);return r.t=e,r.__c||(r.__=[ee(void 0,t),function(e){var t=r.t(r.__[0],e);r.__[0]!==t&&(r.__=[t,r.__[1]],r.__c.setState({}))}],r.__c=A),r.__}(ee,e)}function $(e,t){var n=G(O++,3);!a.__s&&function(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}(n.__H,t)&&(n.__=e,n.__H=t,A.__H.__h.push(n))}function V(){D.forEach(function(e){if(e.__P)try{e.__H.__h.forEach(K),e.__H.__h.forEach(Z),e.__H.__h=[]}catch(t){e.__H.__h=[],a.__e(t,e.__v)}}),D=[]}a.__b=function(e){A=null,W&&W(e)},a.__r=function(e){J&&J(e),O=0;var t=(A=e.__c).__H;t&&(t.__h.forEach(K),t.__h.forEach(Z),t.__h=[])},a.diffed=function(e){B&&B(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==D.push(t)&&U===a.requestAnimationFrame||((U=a.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),X&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);X&&(t=requestAnimationFrame(n))})(V)),A=void 0},a.__c=function(e,t){t.some(function(e){try{e.__h.forEach(K),e.__h=e.__h.filter(function(e){return!e.__||Z(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],a.__e(n,e.__v)}}),R&&R(e,t)},a.unmount=function(e){Q&&Q(e);var t=e.__c;if(t&&t.__H)try{t.__H.__.forEach(K)}catch(e){a.__e(e,t.__v)}};var X="function"==typeof requestAnimationFrame;function K(e){var t=A;"function"==typeof e.__c&&e.__c(),A=t}function Z(e){var t=A;e.__c=e.__(),A=t}function ee(e,t){return"function"==typeof t?t(e):t}var te=function(){return[].slice.call(arguments).filter(Boolean).join(" ")};function ne(e){var t=e.children,n=e.isOpen,r=e.close,o=Y(!1),i=o[0],s=o[1];return $(function(){s(n)},[n]),_("div",{"aria-live":"assertive",className:"fb-pointer-events-none fb-fixed fb-inset-0 fb-flex fb-items-end fb-px-4 fb-py-6 sm:fb-p-6"},_("div",{className:"fb-flex fb-w-full fb-flex-col fb-items-center fb-space-y-4 sm:fb-items-end"},_("div",{className:te(i?"fb-translate-x-0 fb-opacity-100":"fb-translate-x-28 fb-opacity-0","fb-pointer-events-auto fb-relative fb-w-full fb-max-w-sm fb-overflow-hidden fb-rounded-lg fb-bg-white fb-shadow-lg fb-ring-1 fb-ring-black fb-ring-opacity-5 fb-transition-all fb-duration-500 fb-ease-in-out")},_("div",{class:"fb-absolute fb-top-0 fb-right-0 fb-hidden fb-pt-4 fb-pr-4 sm:fb-block"},_("button",{type:"button",onClick:r,class:"fb-rounded-md fb-bg-white focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 fb-text-slate-400 hover:fb-text-slate-500 focus:ring-slate-500"},_("span",{class:"fb-sr-only"},"Close"),_("svg",{class:"fb-h-6 fb-w-6",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},_("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})))),_("div",{className:""},t))))}var re=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays/"+e+"/responded",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){if(!e.ok)throw new Error("Could not update display")})}catch(e){return Promise.reject(e)}},oe=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/responses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function ie(e){return _("label",{htmlFor:e.questionId,className:"fb-block fb-text-base fb-font-semibold fb-leading-6 fb-mr-8 text-slate-900"},e.headline)}function se(e){return _("label",{for:e.questionId,className:"fb-block fb-text-sm fb-font-normal fb-leading-6 text-slate-600"},e.subheader)}function ae(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor;return _("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},_(ie,{headline:t.headline,questionId:t.id}),_(se,{subheader:t.subheader,questionId:t.id}),_("div",{className:"fb-mt-4"},_("textarea",{rows:3,name:t.id,id:t.id,placeholder:t.placeholder,required:t.required,className:"fb-block fb-w-full fb-rounded-md fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm fb-bg-slate-50 fb-border-slate-100 focus:fb-border-slate-500"})),_("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},_("div",null),_("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:fb-ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function fe(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor,i=Y(null),s=i[0],a=i[1];return _("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},_(ie,{headline:t.headline,questionId:t.id}),_(se,{subheader:t.subheader,questionId:t.id}),_("div",{className:"fb-mt-4"},_("fieldset",null,_("legend",{className:"fb-sr-only"},"Choices"),_("div",{className:"fb-relative fb-space-y-2 fb-rounded-md fb-bg-white"},t.choices&&t.choices.map(function(e){return _("label",{key:e.id,className:te(s===e.label?"fb-z-10 fb-bg-slate-50 fb-border-slate-400":"fb-border-gray-200","fb-relative fb-flex fb-cursor-pointer fb-flex-col fb-rounded-md fb-border fb-p-4 focus:fb-outline-none hover:bg-slate-50")},_("span",{className:"fb-flex fb-items-center fb-text-sm"},_("input",{type:"radio",id:e.id,name:t.id,value:e.label,className:"fb-h-4 fb-w-4 fb-border fb-border-slate-300 focus:fb-ring-0 focus:fb-ring-offset-0","aria-labelledby":e.id+"-label",onChange:function(e){a(e.currentTarget.value)},style:{borderColor:o,color:o}}),_("span",{id:e.id+"-label",className:"fb-ml-3 fb-font-medium"},e.label)))})))),_("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},_("div",null),_("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function le(e){return _("div",{className:"fb-h-1 fb-w-full fb-rounded-full bg-slate-200"},_("div",{className:"fb-h-1 fb-rounded-full",style:{backgroundColor:e.brandColor,width:Math.floor(100*e.progress)+"%"}}))}function ue(e){var t=e.config,n=e.survey,r=e.close,o=e.brandColor,i=Y(n.questions[0]),s=i[0],a=i[1],f=Y(0),l=f[0],u=f[1],c=Y(null),d=c[0],b=c[1],p=Y(null),h=p[0],g=p[1],v=Y(!1),m=v[0],w=v[1];$(function(){!function(){try{Promise.resolve(function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create display");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}({surveyId:n.id,personId:t.person.id},t)).then(function(e){g(e.id)})}catch(e){return Promise.reject(e)}}()},[t,n]),$(function(){var e;u((e=n.questions.findIndex(function(e){return e.id===s.id}),e/n.questions.length))},[s,n]);var y=function(e){try{var o=function(){w(!1),f?(u(100),r()):a(n.questions[i+1])};w(!0);var i=n.questions.findIndex(function(e){return e.id===s.id}),f=i===n.questions.length-1,l={surveyId:n.id,personId:t.person.id,response:{finished:f,data:e}},c=d?Promise.resolve(function(e,t,n){try{return Promise.resolve(fetch(n.apiHost+"/api/v1/client/environments/"+n.environmentId+"/responses/"+t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw new Error("Could not update response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}(l,d,t)).then(function(){}):Promise.resolve(Promise.all([oe(l,t),re(h,t)])).then(function(e){b(e[0].id)});return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}};return _("div",null,_("div",{className:te(m?"fb-animate-pulse fb-opacity-60":"","fb-p-4 fb-text-slate-800 fb-font-sans")},"multipleChoiceSingle"===s.type?_(fe,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):"openText"===s.type?_(ae,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):null),_("div",{className:"fb-mt-2"},_(le,{progress:l,brandColor:o})))}function ce(e){var t,n=e.config,r=e.survey,o=e.closeSurvey,i=Y(!0),s=i[1],a=function(){s(!1),setTimeout(function(){o()},1e3)};return _("div",{id:"fbjs"},_(ne,{isOpen:i[0],close:a},_(ue,{config:n,survey:r,close:a,brandColor:null==(t=n.settings)?void 0:t.brandColor})))}var de=/*#__PURE__*/function(){function e(){this.config=this.loadFromLocalStorage()}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.update=function(e){e&&(this.config=o({},this.config,e),this.saveToLocalStorage())},t.get=function(){return this.config},t.loadFromLocalStorage=function(){if("undefined"!=typeof window){var e=localStorage.getItem("config");if(e)return JSON.parse(e)}return{apiHost:null,environmentId:null}},t.saveToLocalStorage=function(){localStorage.setItem("config",JSON.stringify(this.config))},e}();de.instance=void 0;var be=/*#__PURE__*/function(){function e(){this.logLevel="error"}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.configure=function(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)},t.logger=function(e,t){if("debug"!==t||"debug"===this.logLevel){var n="🧱 Formbricks - "+(new Date).toISOString()+" ["+t.toUpperCase()+"] - "+e;"error"===t?console.error(n):console.log(n)}},t.debug=function(e){this.logger(e,"debug")},t.error=function(e){this.logger(e,"error")},e}();be.instance=void 0;var pe=be.getInstance(),he=de.getInstance(),ge=function(){try{return Promise.resolve(fetch(he.get().apiHost+"/api/v1/client/environments/"+he.get().environmentId+"/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:he.get().person.id})})).then(function(e){if(!e.ok)throw pe.error("Error getting settings"),Error("Error getting settings");return e.json()})}catch(e){return Promise.reject(e)}},_e="formbricks-web-container",ve=de.getInstance(),me=be.getInstance(),we=!1,ye=function(e){we?me.debug("A survey is already running. Skipping."):(we=!0,function(e,t,n){var r,o,i;a.__&&a.__(e,t),o=(r=void 0===c)?null:t.__k,e=_(m,null,[e]),i=[],H(t,t.__k=e,o||d,d,void 0!==t.ownerSVGElement,o?null:t.childNodes.length?b.slice.call(t.childNodes):null,i,d,r),z(i,e)}(_(ce,{config:ve.get(),survey:e,closeSurvey:je}),document.getElementById(_e)))},je=function(){try{return console.log("close survey called"),document.getElementById(_e).remove(),xe(),Promise.resolve(ge()).then(function(e){ve.update({settings:e}),we=!1})}catch(e){return Promise.reject(e)}},xe=function(){var e=document.createElement("div");e.id=_e,document.body.appendChild(e)},ke=be.getInstance(),Pe=de.getInstance(),Se=function(e,t){try{return Promise.resolve(fetch(Pe.get().apiHost+"/api/v1/client/environments/"+Pe.get().environmentId+"/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Pe.get().session.id,eventName:e,properties:t})})).then(function(t){var n;function r(t){if(n)return t;ke.debug('Formbricks: Event "'+e+'" tracked'),Ie(e)}var o=function(){if(!t.ok)return Promise.resolve(t.json()).then(function(e){ke.error("Formbricks: Error tracking event: "+JSON.stringify(e)),n=1})}();return o&&o.then?o.then(r):r(o)})}catch(e){return Promise.reject(e)}},Ie=function(e){for(var t,n=s(null==(r=Pe.get().settings)?void 0:r.surveys);!(t=n()).done;)for(var r,o,i=t.value,a=s(i.triggers);!(o=a()).done;){var f;if((null==(f=o.value.eventClass)?void 0:f.name)===e)return ke.debug("Formbricks: survey "+i.id+' triggered by event "'+e+'"'),void ye(i)}},Ce=de.getInstance(),Ee=be.getInstance(),Ne=function(){try{return Ee.debug("Creating new person"),Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){return e.ok?Promise.resolve(e.json()):(console.error("Formbricks: Error fetching person"),null)})}catch(e){return Promise.reject(e)}},Te=function(e,t){var n=Ce.get().person.attributes.find(function(t){var n;return(null==(n=t.attributeClass)?void 0:n.name)===e});return!(!n||n.value!==t)},He=be.getInstance(),ze=de.getInstance(),Fe=function(){try{return ze.get().person?Promise.resolve(fetch(ze.get().apiHost+"/api/v1/client/environments/"+ze.get().environmentId+"/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:ze.get().person.id})})).then(function(e){if(e.ok)return Promise.resolve(e.json());He.error("Error creating session")}):(He.error("Formbricks: Unable to create session. No person found"),Promise.resolve())}catch(e){return Promise.reject(e)}},qe=function(e){He.debug("Session expired. Creating new session.");var t=o({},e);return t.expiresAt=Date.now()+36e5,t},Le=function(e){return e.expiresAt<=Date.now()},Oe=de.getInstance(),Ae=be.getInstance(),Ue=function(){var e;Ae.debug("checking page url");var t=null==(e=Oe.get().settings)?void 0:e.noCodeEvents.filter(function(e){var t;return"pageUrl"===(null==(t=e.noCodeConfig)?void 0:t.type)});if(0!==t.length)for(var n,r=s(t);!(n=r()).done;){var o=n.value,i=o.noCodeConfig.pageUrl;i&&Me(window.location.href,i.value,i.rule)&&Se(o.name)}};function Me(e,t,n){switch(n){case"exactMatch":return e===t;case"contains":return e.includes(t);case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"notMatch":return e!==t;case"notContains":return!e.includes(t);default:throw new Error("Invalid match type")}}var De=de.getInstance(),We=be.getInstance(),Je=function(){if(!(De.get().apiHost&&De.get().environmentId&&De.get().person&&De.get().session&&De.get().settings))throw Error("Formbricks: Formbricks not initialized. Call initialize() first.")},Be=new r,Re=function(e,t){Be.add(function(){try{return Je(),Promise.resolve(function(e,t){try{return Ee.debug("setting attribute: "+e+" to value: "+t),Te(e,t)?(Ee.debug("attribute already set to this value. Skipping update."),Promise.resolve()):Promise.resolve(function(e,t){try{return Ce.get().person&&Ce.get().person.id?Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people/"+Ce.get().person.id+"/attribute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:t})})).then(function(e){return Promise.resolve(e.json()).then(function(t){if(!e.ok)throw Ee.error("Error updating person"),Error("Error updating person");return t})}):(console.error("Formbricks: Unable to update attribute. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e,t)).then(function(e){var t=e.person,n=e.settings;if(!t||!n)throw Ee.error("Error updating attribute"),new Error("Formbricks: Error updating attribute");Ce.update({person:t,settings:n})})}catch(e){return Promise.reject(e)}}(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},Qe={init:function(e){Be.add(function(){try{return function(e){try{var t,n=function(e){if(t)return e;(function(){if("undefined"!=typeof window){var e=window.setInterval(function(){try{return Promise.resolve(function(){try{var e=function(e){He.debug("Session not expired, extending session"),ze.update({session:qe(ze.get().session)})};He.debug("Checking session");var t=function(){if(Le(ze.get().session))return He.debug("Session expired, creating new session"),Promise.resolve(Fe()).then(function(e){var t=e.session,n=e.settings;if(!t||!n)throw He.error("Error creating new session"),Error("Error creating new session");ze.update({session:t,settings:n}),Se("New Session")})}();return Promise.resolve(t&&t.then?t.then(e):e())}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}},3e5);window.addEventListener("beforeunload",function(){clearInterval(e)})}})(),"undefined"!=typeof window&&(window.addEventListener("hashchange",Ue),window.addEventListener("popstate",Ue),window.addEventListener("pushstate",Ue),window.addEventListener("replacestate",Ue),window.addEventListener("load",Ue)),We.debug("Initialized")};if(!e.environmentId)throw Error("Formbricks: environmentId is required");if(!e.apiHost)throw Error("Formbricks: apiHost is required");e.logLevel&&We.configure({logLevel:e.logLevel}),xe(),function(){if(null===document.getElementById("formbricks__css")){var e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :after,#fbjs :before{border:0 solid #e5e7eb;box-sizing:border-box}#fbjs :after,#fbjs :before{--tw-content:""}#fbjs html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#fbjs body{line-height:inherit;margin:0}#fbjs hr{border-top-width:1px;color:inherit;height:0}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs pre,#fbjs samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{border-collapse:collapse;border-color:inherit;text-indent:0}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit],#fbjs button{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dd,#fbjs dl,#fbjs figure,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs menu,#fbjs ol,#fbjs ul{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{color:#9ca3af;opacity:1}#fbjs input::placeholder,#fbjs textarea::placeholder{color:#9ca3af;opacity:1}#fbjs [role=button],#fbjs button{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs audio,#fbjs canvas,#fbjs embed,#fbjs iframe,#fbjs img,#fbjs object,#fbjs svg,#fbjs video{display:block;vertical-align:middle}#fbjs img,#fbjs video{height:auto;max-width:100%}#fbjs [hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#fbjs .fb-sr-only{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}#fbjs .fb-pointer-events-none{pointer-events:none}#fbjs .fb-pointer-events-auto{pointer-events:auto}#fbjs .fb-fixed{position:fixed}#fbjs .fb-absolute{position:absolute}#fbjs .fb-relative{position:relative}#fbjs .fb-inset-0{bottom:0;left:0;right:0;top:0}#fbjs .fb-right-0{right:0}#fbjs .fb-top-0{top:0}#fbjs .fb-z-10{z-index:10}#fbjs .fb-ml-3{margin-left:.75rem}#fbjs .fb-mr-8{margin-right:2rem}#fbjs .fb-mt-2{margin-top:.5rem}#fbjs .fb-mt-4{margin-top:1rem}#fbjs .fb-block{display:block}#fbjs .fb-flex{display:flex}#fbjs .fb-hidden{display:none}#fbjs .fb-h-1{height:.25rem}#fbjs .fb-h-4{height:1rem}#fbjs .fb-h-6{height:1.5rem}#fbjs .fb-w-4{width:1rem}#fbjs .fb-w-6{width:1.5rem}#fbjs .fb-w-full{width:100%}#fbjs .fb-max-w-sm{max-width:24rem}#fbjs .fb-translate-x-0{--tw-translate-x:0px}#fbjs .fb-translate-x-0,#fbjs .fb-translate-x-28{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs .fb-translate-x-28{--tw-translate-x:7rem}@keyframes fb-pulse{50%{opacity:.5}}#fbjs .fb-animate-pulse{animation:fb-pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs .fb-cursor-pointer{cursor:pointer}#fbjs .fb-flex-col{flex-direction:column}#fbjs .fb-items-end{align-items:flex-end}#fbjs .fb-items-center{align-items:center}#fbjs .fb-justify-between{justify-content:space-between}#fbjs .fb-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}#fbjs .fb-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}#fbjs .fb-overflow-hidden{overflow:hidden}#fbjs .fb-rounded-full{border-radius:9999px}#fbjs .fb-rounded-lg{border-radius:.5rem}#fbjs .fb-rounded-md{border-radius:.375rem}#fbjs .fb-border{border-width:1px}#fbjs .fb-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}#fbjs .fb-border-slate-100{--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity))}#fbjs .fb-border-slate-300{--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}#fbjs .fb-border-slate-400{--tw-border-opacity:1;border-color:rgb(148 163 184/var(--tw-border-opacity))}#fbjs .fb-border-transparent{border-color:transparent}#fbjs .fb-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}#fbjs .fb-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}#fbjs .fb-p-2{padding:.5rem}#fbjs .fb-p-4{padding:1rem}#fbjs .fb-px-3{padding-left:.75rem;padding-right:.75rem}#fbjs .fb-px-4{padding-left:1rem;padding-right:1rem}#fbjs .fb-py-3{padding-bottom:.75rem;padding-top:.75rem}#fbjs .fb-py-6{padding-bottom:1.5rem;padding-top:1.5rem}#fbjs .fb-pr-4{padding-right:1rem}#fbjs .fb-pt-4{padding-top:1rem}#fbjs .fb-font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}#fbjs .fb-text-base{font-size:1rem;line-height:1.5rem}#fbjs .fb-text-sm{font-size:.875rem;line-height:1.25rem}#fbjs .fb-font-medium{font-weight:500}#fbjs .fb-font-normal{font-weight:400}#fbjs .fb-font-semibold{font-weight:600}#fbjs .fb-leading-4{line-height:1rem}#fbjs .fb-leading-6{line-height:1.5rem}#fbjs .fb-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}#fbjs .fb-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity))}#fbjs .fb-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}#fbjs .fb-opacity-0{opacity:0}#fbjs .fb-opacity-100{opacity:1}#fbjs .fb-opacity-60{opacity:.6}#fbjs .fb-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}#fbjs .fb-shadow-lg,#fbjs .fb-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs .fb-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}#fbjs .fb-ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs .fb-ring-black{--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity))}#fbjs .fb-ring-opacity-5{--tw-ring-opacity:0.05}#fbjs .fb-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs .fb-duration-500{transition-duration:.5s}#fbjs .fb-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs .hover\\:fb-text-slate-500:hover{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}#fbjs .hover\\:fb-opacity-90:hover{opacity:.9}#fbjs .focus\\:fb-border-slate-500:focus{--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity))}#fbjs .focus\\:fb-outline-none:focus{outline:2px solid transparent;outline-offset:2px}#fbjs .focus\\:fb-ring-0:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color)}#fbjs .focus\\:fb-ring-0:focus,#fbjs .focus\\:fb-ring-2:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs .focus\\:fb-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}#fbjs .focus\\:fb-ring-slate-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(100 116 139/var(--tw-ring-opacity))}#fbjs .focus\\:fb-ring-offset-0:focus{--tw-ring-offset-width:0px}#fbjs .focus\\:fb-ring-offset-2:focus{--tw-ring-offset-width:2px}@media (min-width:640px){#fbjs .sm\\:fb-block{display:block}#fbjs .sm\\:fb-items-end{align-items:flex-end}#fbjs .sm\\:fb-p-6{padding:1.5rem}#fbjs .sm\\:fb-text-sm{font-size:.875rem;line-height:1.25rem}}',document.head.appendChild(e)}}();var r=De&&De.get().environmentId===e.environmentId&&De.get().apiHost===e.apiHost?De.get().session&&Le(De.get().session)?Promise.resolve(Fe()).then(function(e){var t=e.settings;De.update({session:qe(e.session),settings:t}),Se("New Session")}):De.get().session?void 0:(We.error("Unable to initialize. No session found"),void(t=1)):(De.update({environmentId:e.environmentId,apiHost:e.apiHost}),Promise.resolve(Ne()).then(function(e){var t=e.settings;De.update({person:e.person,session:qe(e.session),settings:t}),Se("New Session")}));Promise.resolve(r&&r.then?r.then(n):n(r))}catch(e){return Promise.reject(e)}}(e),Promise.resolve()}catch(e){return Promise.reject(e)}})},setUserId:function(e){Be.add(function(){try{return Je(),Promise.resolve(function(e){try{return Ee.debug("setting userId: "+e),Te("userId",e)?(Ee.debug("userId already set to this value. Skipping update."),Promise.resolve()):(t=Ce.get().person.attributes.find(function(e){var t;return"userId"===(null==(t=e.attributeClass)?void 0:t.name)}),t?(Ee.error("userId cannot be changed after it has been set. You need to reset first"),Promise.resolve()):Promise.resolve(function(e){try{return Ce.get().person&&Ce.get().person.id?Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people/"+Ce.get().person.id+"/user-id",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,sessionId:Ce.get().session.id})})).then(function(e){if(!e.ok)throw Ee.error("Formbricks: Error updating person"),Error("Error updating person");return Promise.resolve(e.json())}):(console.error("Formbricks: Unable to update userId. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e)).then(function(e){Ce.update({person:e.person,settings:e.settings})}))}catch(e){return Promise.reject(e)}var t}(e)).then(function(){})}catch(e){return Promise.reject(e)}})},setEmail:function(e){Re("email",e)},setAttribute:Re,track:function(e,t){void 0===t&&(t={}),Be.add(function(){try{return Je(),Promise.resolve(Se(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},logout:function(){Be.add(function(){try{return Je(),Promise.resolve(function(){try{return Ee.debug("Resetting person. Getting new person, session and settings from backend"),Promise.resolve(Ne()).then(function(e){var t=e.person,n=e.session,r=e.settings;if(!t||!n||!r)throw Ee.error("Error resetting user"),new Error("Formbricks: Error resetting user");Ce.update({person:t,session:n,settings:r})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},refresh:function(){Be.add(function(){try{return Je(),Promise.resolve(function(){try{return pe.debug("Refreshing - getting settings from backend"),Promise.resolve(ge()).then(function(e){he.update({settings:e})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},registerRouteChange:function(){Be.add(function(){try{return Je(),Ue(),Promise.resolve()}catch(e){return Promise.reject(e)}})}};export{Qe as default};
function e(n,r,o){if(!n.s){if(o instanceof t){if(!o.s)return void(o.o=e.bind(null,n,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(e.bind(null,n,r),e.bind(null,n,2));n.s=r,n.v=o;var i=n.o;i&&i(n)}}var t=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(n,r){var o=new t,i=this.s;if(i){var s=1&i?n:r;if(s){try{e(o,1,s(this.v))}catch(t){e(o,2,t)}return o}return this}return this.o=function(t){try{var i=t.v;1&t.s?e(o,1,n?n(i):i):r?e(o,1,r(i)):e(o,2,i)}catch(t){e(o,2,t)}},o},t}();function n(e){return e instanceof t&&1&e.s}var r=/*#__PURE__*/function(){function r(){this.queue=[],this.running=!1}var o=r.prototype;return o.add=function(e){this.queue.push(e),this.running||this.run()},o.run=function(){try{var r=function(){o.running=!1},o=this;o.running=!0;var i=function(r,o,i){for(var s;;){var a=r();if(n(a)&&(a=a.v),!a)return f;if(a.then){s=0;break}var f=i();if(f&&f.then){if(!n(f)){s=1;break}f=f.s}}var l=new t,c=e.bind(null,l,2);return(0===s?a.then(d):1===s?f.then(u):(void 0).then(function(){(a=r())?a.then?a.then(d).then(void 0,c):d(a):e(l,1,f)})).then(void 0,c),l;function u(t){f=t;do{if(!(a=r())||n(a)&&!a.v)return void e(l,1,f);if(a.then)return void a.then(d).then(void 0,c);n(f=i())&&(f=f.v)}while(!f||!f.then);f.then(u).then(void 0,c)}function d(t){t?(f=i())&&f.then?f.then(u).then(void 0,c):u(f):e(l,1,f)}}(function(){return o.queue.length>0},0,function(){var e=o.queue.shift(),t=function(t,n){try{var r=Promise.resolve(e()).then(function(){})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){console.error(e)});if(t&&t.then)return t.then(function(){})});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},r}();function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,f,l,c,u,d,b,p={},_=[],h=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function g(e,t){for(var n in t)e[n]=t[n];return e}function v(e){var t=e.parentNode;t&&t.removeChild(e)}function m(e,t,n){var r,o,i,s={};for(i in t)"key"==i?r=t[i]:"ref"==i?o=t[i]:s[i]=t[i];if(arguments.length>2&&(s.children=arguments.length>3?a.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===s[i]&&(s[i]=e.defaultProps[i]);return w(e,s,r,o,null)}function w(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++l:o};return null==o&&null!=f.vnode&&f.vnode(i),i}function y(e){return e.children}function j(e,t){this.props=e,this.context=t}function x(e,t){if(null==t)return e.__?x(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?x(e):null}function k(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return k(e)}}function P(e){(!e.__d&&(e.__d=!0)&&c.push(e)&&!S.__r++||u!==f.debounceRendering)&&((u=f.debounceRendering)||d)(S)}function S(){var e,t,n,r,o,i,s,a;for(c.sort(b);e=c.shift();)e.__d&&(t=c.length,r=void 0,o=void 0,s=(i=(n=e).__v).__e,(a=n.__P)&&(r=[],(o=g({},i)).__v=i.__v+1,L(a,i,o,n.__n,void 0!==a.ownerSVGElement,null!=i.__h?[s]:null,r,null==s?x(i):s,i.__h),q(r,i),i.__e!=s&&k(i)),c.length>t&&c.sort(b));S.__r=0}function C(e,t,n,r,o,i,s,a,f,l){var c,u,d,b,h,g,v,m=r&&r.__k||_,j=m.length;for(n.__k=[],c=0;c<t.length;c++)if(null!=(b=n.__k[c]=null==(b=t[c])||"boolean"==typeof b||"function"==typeof b?null:"string"==typeof b||"number"==typeof b||"bigint"==typeof b?w(null,b,null,null,b):Array.isArray(b)?w(y,{children:b},null,null,null):b.__b>0?w(b.type,b.props,b.key,b.ref?b.ref:null,b.__v):b)){if(b.__=n,b.__b=n.__b+1,null===(d=m[c])||d&&b.key==d.key&&b.type===d.type)m[c]=void 0;else for(u=0;u<j;u++){if((d=m[u])&&b.key==d.key&&b.type===d.type){m[u]=void 0;break}d=null}L(e,b,d=d||p,o,i,s,a,f,l),h=b.__e,(u=b.ref)&&d.ref!=u&&(v||(v=[]),d.ref&&v.push(d.ref,null,b),v.push(u,b.__c||h,b)),null!=h?(null==g&&(g=h),"function"==typeof b.type&&b.__k===d.__k?b.__d=f=I(b,f,e):f=E(e,b,d,m,h,f),"function"==typeof n.type&&(n.__d=f)):f&&d.__e==f&&f.parentNode!=e&&(f=x(d))}for(n.__e=g,c=j;c--;)null!=m[c]&&("function"==typeof n.type&&null!=m[c].__e&&m[c].__e==n.__d&&(n.__d=N(r).nextSibling),A(m[c],m[c]));if(v)for(c=0;c<v.length;c++)U(v[c],v[++c],v[++c])}function I(e,t,n){for(var r,o=e.__k,i=0;o&&i<o.length;i++)(r=o[i])&&(r.__=e,t="function"==typeof r.type?I(r,t,n):E(n,r,r,o,r.__e,t));return t}function E(e,t,n,r,o,i){var s,a,f;if(void 0!==t.__d)s=t.__d,t.__d=void 0;else if(null==n||o!=i||null==o.parentNode)e:if(null==i||i.parentNode!==e)e.appendChild(o),s=null;else{for(a=i,f=0;(a=a.nextSibling)&&f<r.length;f+=1)if(a==o)break e;e.insertBefore(o,i),s=i}return void 0!==s?s:o.nextSibling}function N(e){var t,n,r;if(null==e.type||"string"==typeof e.type)return e.__e;if(e.__k)for(t=e.__k.length-1;t>=0;t--)if((n=e.__k[t])&&(r=N(n)))return r;return null}function H(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||h.test(t)?n:n+"px"}function T(e,t,n,r,o){var i;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||H(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||H(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])i=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r||e.addEventListener(t,i?F:z,i):e.removeEventListener(t,i?F:z,i);else if("dangerouslySetInnerHTML"!==t){if(o)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function z(e){return this.l[e.type+!1](f.event?f.event(e):e)}function F(e){return this.l[e.type+!0](f.event?f.event(e):e)}function L(e,t,n,r,o,i,s,a,l){var c,u,d,b,p,_,h,v,m,w,x,k,P,S,I,E=t.type;if(void 0!==t.constructor)return null;null!=n.__h&&(l=n.__h,a=t.__e=n.__e,t.__h=null,i=[a]),(c=f.__b)&&c(t);try{e:if("function"==typeof E){if(v=t.props,m=(c=E.contextType)&&r[c.__c],w=c?m?m.props.value:c.__:r,n.__c?h=(u=t.__c=n.__c).__=u.__E:("prototype"in E&&E.prototype.render?t.__c=u=new E(v,w):(t.__c=u=new j(v,w),u.constructor=E,u.render=M),m&&m.sub(u),u.props=v,u.state||(u.state={}),u.context=w,u.__n=r,d=u.__d=!0,u.__h=[],u._sb=[]),null==u.__s&&(u.__s=u.state),null!=E.getDerivedStateFromProps&&(u.__s==u.state&&(u.__s=g({},u.__s)),g(u.__s,E.getDerivedStateFromProps(v,u.__s))),b=u.props,p=u.state,u.__v=t,d)null==E.getDerivedStateFromProps&&null!=u.componentWillMount&&u.componentWillMount(),null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(null==E.getDerivedStateFromProps&&v!==b&&null!=u.componentWillReceiveProps&&u.componentWillReceiveProps(v,w),!u.__e&&null!=u.shouldComponentUpdate&&!1===u.shouldComponentUpdate(v,u.__s,w)||t.__v===n.__v){for(t.__v!==n.__v&&(u.props=v,u.state=u.__s,u.__d=!1),u.__e=!1,t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(e){e&&(e.__=t)}),x=0;x<u._sb.length;x++)u.__h.push(u._sb[x]);u._sb=[],u.__h.length&&s.push(u);break e}null!=u.componentWillUpdate&&u.componentWillUpdate(v,u.__s,w),null!=u.componentDidUpdate&&u.__h.push(function(){u.componentDidUpdate(b,p,_)})}if(u.context=w,u.props=v,u.__P=e,k=f.__r,P=0,"prototype"in E&&E.prototype.render){for(u.state=u.__s,u.__d=!1,k&&k(t),c=u.render(u.props,u.state,u.context),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[]}else do{u.__d=!1,k&&k(t),c=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++P<25);u.state=u.__s,null!=u.getChildContext&&(r=g(g({},r),u.getChildContext())),d||null==u.getSnapshotBeforeUpdate||(_=u.getSnapshotBeforeUpdate(b,p)),I=null!=c&&c.type===y&&null==c.key?c.props.children:c,C(e,Array.isArray(I)?I:[I],t,n,r,o,i,s,a,l),u.base=t.__e,t.__h=null,u.__h.length&&s.push(u),h&&(u.__E=u.__=null),u.__e=!1}else null==i&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=O(n.__e,t,n,r,o,i,s,l);(c=f.diffed)&&c(t)}catch(e){t.__v=null,(l||null!=i)&&(t.__e=a,t.__h=!!l,i[i.indexOf(a)]=null),f.__e(e,t,n)}}function q(e,t){f.__c&&f.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){f.__e(e,t.__v)}})}function O(e,t,n,r,o,i,s,f){var l,c,u,d=n.props,b=t.props,_=t.type,h=0;if("svg"===_&&(o=!0),null!=i)for(;h<i.length;h++)if((l=i[h])&&"setAttribute"in l==!!_&&(_?l.localName===_:3===l.nodeType)){e=l,i[h]=null;break}if(null==e){if(null===_)return document.createTextNode(b);e=o?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,b.is&&b),i=null,f=!1}if(null===_)d===b||f&&e.data===b||(e.data=b);else{if(i=i&&a.call(e.childNodes),c=(d=n.props||p).dangerouslySetInnerHTML,u=b.dangerouslySetInnerHTML,!f){if(null!=i)for(d={},h=0;h<e.attributes.length;h++)d[e.attributes[h].name]=e.attributes[h].value;(u||c)&&(u&&(c&&u.__html==c.__html||u.__html===e.innerHTML)||(e.innerHTML=u&&u.__html||""))}if(function(e,t,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in t||T(e,i,null,n[i],r);for(i in t)o&&"function"!=typeof t[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===t[i]||T(e,i,t[i],n[i],r)}(e,b,d,o,f),u)t.__k=[];else if(h=t.props.children,C(e,Array.isArray(h)?h:[h],t,n,r,o&&"foreignObject"!==_,i,s,i?i[0]:n.__k&&x(n,0),f),null!=i)for(h=i.length;h--;)null!=i[h]&&v(i[h]);f||("value"in b&&void 0!==(h=b.value)&&(h!==e.value||"progress"===_&&!h||"option"===_&&h!==d.value)&&T(e,"value",h,d.value,!1),"checked"in b&&void 0!==(h=b.checked)&&h!==e.checked&&T(e,"checked",h,d.checked,!1))}return e}function U(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){f.__e(e,n)}}function A(e,t,n){var r,o;if(f.unmount&&f.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||U(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){f.__e(e,t)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&A(r[o],t,n||"function"!=typeof e.type);n||null==e.__e||v(e.__e),e.__=e.__e=e.__d=void 0}function M(e,t,n){return this.constructor(e,n)}a=_.slice,f={__e:function(e,t,n,r){for(var o,i,s;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&null!=i.getDerivedStateFromError&&(o.setState(i.getDerivedStateFromError(e)),s=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,r||{}),s=o.__d),s)return o.__E=o}catch(t){e=t}throw e}},l=0,j.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=g({},this.state),"function"==typeof e&&(e=e(g({},n),this.props)),e&&g(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),P(this))},j.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),P(this))},j.prototype.render=y,c=[],d="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,b=function(e,t){return e.__v.__b-t.__v.__b},S.__r=0;var D,W,J,B,R=0,V=[],Y=[],Q=f.__b,X=f.__r,$=f.diffed,G=f.__c,K=f.unmount;function Z(e,t){f.__h&&f.__h(W,e,R||t),R=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:Y}),n.__[e]}function ee(e){return R=1,function(e,t,n){var r=Z(D++,2);if(r.t=e,!r.__c&&(r.__=[ae(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.u)){var o=function(e,t,n){if(!r.__c.__H)return!0;var o=r.__c.__H.__.filter(function(e){return e.__c});if(o.every(function(e){return!e.__N}))return!i||i.call(this,e,t,n);var s=!1;return o.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}}),!(!s&&r.__c.props===e)&&(!i||i.call(this,e,t,n))};W.u=!0;var i=W.shouldComponentUpdate,s=W.componentWillUpdate;W.componentWillUpdate=function(e,t,n){if(this.__e){var r=i;i=void 0,o(e,t,n),i=r}s&&s.call(this,e,t,n)},W.shouldComponentUpdate=o}return r.__N||r.__}(ae,e)}function te(e,t){var n=Z(D++,3);!f.__s&&function(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}(n.__H,t)&&(n.__=e,n.i=t,W.__H.__h.push(n))}function ne(){for(var e;e=V.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ie),e.__H.__h.forEach(se),e.__H.__h=[]}catch(t){e.__H.__h=[],f.__e(t,e.__v)}}f.__b=function(e){W=null,Q&&Q(e)},f.__r=function(e){X&&X(e),D=0;var t=(W=e.__c).__H;t&&(J===W?(t.__h=[],W.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.__V=Y,e.__N=e.i=void 0})):(t.__h.forEach(ie),t.__h.forEach(se),t.__h=[])),J=W},f.diffed=function(e){$&&$(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==V.push(t)&&B===f.requestAnimationFrame||((B=f.requestAnimationFrame)||oe)(ne)),t.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.__V!==Y&&(e.__=e.__V),e.i=void 0,e.__V=Y})),J=W=null},f.__c=function(e,t){t.some(function(e){try{e.__h.forEach(ie),e.__h=e.__h.filter(function(e){return!e.__||se(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],f.__e(n,e.__v)}}),G&&G(e,t)},f.unmount=function(e){K&&K(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{ie(e)}catch(e){t=e}}),n.__H=void 0,t&&f.__e(t,n.__v))};var re="function"==typeof requestAnimationFrame;function oe(e){var t,n=function(){clearTimeout(r),re&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);re&&(t=requestAnimationFrame(n))}function ie(e){var t=W,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),W=t}function se(e){var t=W;e.__c=e.__(),W=t}function ae(e,t){return"function"==typeof t?t(e):t}var fe=function(){return[].slice.call(arguments).filter(Boolean).join(" ")};function le(e){var t=e.children,n=e.isOpen,r=e.close,o=ee(!1),i=o[0],s=o[1];return te(function(){s(n)},[n]),m("div",{"aria-live":"assertive",className:"fb-pointer-events-none fb-fixed fb-inset-0 fb-flex fb-items-end fb-px-4 fb-py-6 sm:fb-p-6"},m("div",{className:"fb-flex fb-w-full fb-flex-col fb-items-center fb-space-y-4 sm:fb-items-end"},m("div",{className:fe(i?"fb-translate-x-0 fb-opacity-100":"fb-translate-x-28 fb-opacity-0","fb-pointer-events-auto fb-relative fb-w-full fb-max-w-sm fb-overflow-hidden fb-rounded-lg fb-bg-white fb-shadow-lg fb-ring-1 fb-ring-black fb-ring-opacity-5 fb-transition-all fb-duration-500 fb-ease-in-out")},m("div",{class:"fb-absolute fb-top-0 fb-right-0 fb-hidden fb-pt-4 fb-pr-4 sm:fb-block"},m("button",{type:"button",onClick:r,class:"fb-rounded-md fb-bg-white focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 fb-text-slate-400 hover:fb-text-slate-500 focus:ring-slate-500"},m("span",{class:"fb-sr-only"},"Close"),m("svg",{class:"fb-h-6 fb-w-6",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},m("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})))),m("div",{className:""},t))))}var ce=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays/"+e+"/responded",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){if(!e.ok)throw new Error("Could not update display")})}catch(e){return Promise.reject(e)}},ue=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/responses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function de(e){return m("label",{htmlFor:e.questionId,className:"fb-block fb-text-base fb-font-semibold fb-leading-6 fb-mr-8 text-slate-900"},e.headline)}function be(e){return m("label",{for:e.questionId,className:"fb-block fb-text-sm fb-font-normal fb-leading-6 text-slate-600"},e.subheader)}function pe(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor;return m("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},m(de,{headline:t.headline,questionId:t.id}),m(be,{subheader:t.subheader,questionId:t.id}),m("div",{className:"fb-mt-4"},m("textarea",{rows:3,name:t.id,id:t.id,placeholder:t.placeholder,required:t.required,className:"fb-block fb-w-full fb-rounded-md fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm fb-bg-slate-50 fb-border-slate-100 focus:fb-border-slate-500"})),m("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},m("div",null),m("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:fb-ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function _e(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor,i=ee(null),s=i[0],a=i[1];return m("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},m(de,{headline:t.headline,questionId:t.id}),m(be,{subheader:t.subheader,questionId:t.id}),m("div",{className:"fb-mt-4"},m("fieldset",null,m("legend",{className:"fb-sr-only"},"Choices"),m("div",{className:"fb-relative fb-space-y-2 fb-rounded-md fb-bg-white"},t.choices&&t.choices.map(function(e){return m("label",{key:e.id,className:fe(s===e.label?"fb-z-10 fb-bg-slate-50 fb-border-slate-400":"fb-border-gray-200","fb-relative fb-flex fb-cursor-pointer fb-flex-col fb-rounded-md fb-border fb-p-4 focus:fb-outline-none hover:bg-slate-50")},m("span",{className:"fb-flex fb-items-center fb-text-sm"},m("input",{type:"radio",id:e.id,name:t.id,value:e.label,className:"fb-h-4 fb-w-4 fb-border fb-border-slate-300 focus:fb-ring-0 focus:fb-ring-offset-0","aria-labelledby":e.id+"-label",onChange:function(e){a(e.currentTarget.value)},style:{borderColor:o,color:o}}),m("span",{id:e.id+"-label",className:"fb-ml-3 fb-font-medium"},e.label)))})))),m("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},m("div",null),m("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function he(e){return m("div",{className:"fb-h-1 fb-w-full fb-rounded-full bg-slate-200"},m("div",{className:"fb-h-1 fb-rounded-full",style:{backgroundColor:e.brandColor,width:Math.floor(100*e.progress)+"%"}}))}function ge(e){var t=e.config,n=e.survey,r=e.close,o=e.brandColor,i=ee(n.questions[0]),s=i[0],a=i[1],f=ee(0),l=f[0],c=f[1],u=ee(null),d=u[0],b=u[1],p=ee(null),_=p[0],h=p[1],g=ee(!1),v=g[0],w=g[1];te(function(){!function(){try{Promise.resolve(function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create display");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}({surveyId:n.id,personId:t.person.id},t)).then(function(e){h(e.id)})}catch(e){return Promise.reject(e)}}()},[t,n]),te(function(){var e;c((e=n.questions.findIndex(function(e){return e.id===s.id}),e/n.questions.length))},[s,n]);var y=function(e){try{var o=function(){w(!1),f?(c(100),r()):a(n.questions[i+1])};w(!0);var i=n.questions.findIndex(function(e){return e.id===s.id}),f=i===n.questions.length-1,l={surveyId:n.id,personId:t.person.id,response:{finished:f,data:e}},u=d?Promise.resolve(function(e,t,n){try{return Promise.resolve(fetch(n.apiHost+"/api/v1/client/environments/"+n.environmentId+"/responses/"+t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw new Error("Could not update response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}(l,d,t)).then(function(){}):Promise.resolve(Promise.all([ue(l,t),ce(_,t)])).then(function(e){b(e[0].id)});return Promise.resolve(u&&u.then?u.then(o):o())}catch(e){return Promise.reject(e)}};return m("div",null,m("div",{className:fe(v?"fb-animate-pulse fb-opacity-60":"","fb-p-4 fb-text-slate-800 fb-font-sans")},"multipleChoiceSingle"===s.type?m(_e,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):"openText"===s.type?m(pe,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):null),m("div",{className:"fb-mt-2"},m(he,{progress:l,brandColor:o})))}function ve(e){var t,n=e.config,r=e.survey,o=e.closeSurvey,i=ee(!0),s=i[1],a=function(){s(!1),setTimeout(function(){o()},1e3)};return m("div",{id:"fbjs"},m(le,{isOpen:i[0],close:a},m(ge,{config:n,survey:r,close:a,brandColor:null==(t=n.settings)?void 0:t.brandColor})))}var me=/*#__PURE__*/function(){function e(){this.config=this.loadFromLocalStorage()}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.update=function(e){e&&(this.config=o({},this.config,e),this.saveToLocalStorage())},t.get=function(){return this.config},t.loadFromLocalStorage=function(){if("undefined"!=typeof window){var e=localStorage.getItem("config");if(e)return JSON.parse(e)}return{apiHost:null,environmentId:null}},t.saveToLocalStorage=function(){localStorage.setItem("config",JSON.stringify(this.config))},e}();me.instance=void 0;var we=/*#__PURE__*/function(){function e(){this.logLevel="error"}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.configure=function(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)},t.logger=function(e,t){if("debug"!==t||"debug"===this.logLevel){var n="🧱 Formbricks - "+(new Date).toISOString()+" ["+t.toUpperCase()+"] - "+e;"error"===t?console.error(n):console.log(n)}},t.debug=function(e){this.logger(e,"debug")},t.error=function(e){this.logger(e,"error")},e}();we.instance=void 0;var ye=we.getInstance(),je=me.getInstance(),xe=function(){try{return Promise.resolve(fetch(je.get().apiHost+"/api/v1/client/environments/"+je.get().environmentId+"/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:je.get().person.id})})).then(function(e){if(!e.ok)throw ye.error("Error getting settings"),Error("Error getting settings");return e.json()})}catch(e){return Promise.reject(e)}},ke="formbricks-web-container",Pe=me.getInstance(),Se=we.getInstance(),Ce=!1,Ie=function(e){Ce?Se.debug("A survey is already running. Skipping."):(Ce=!0,function(e,t,n){var r,o;f.__&&f.__(e,t),r=t.__k,o=[],L(t,e=t.__k=m(y,null,[e]),r||p,p,void 0!==t.ownerSVGElement,r?null:t.firstChild?a.call(t.childNodes):null,o,r?r.__e:t.firstChild,!1),q(o,e)}(m(ve,{config:Pe.get(),survey:e,closeSurvey:Ee}),document.getElementById(ke)))},Ee=function(){try{return document.getElementById(ke).remove(),Ne(),Promise.resolve(xe()).then(function(e){Pe.update({settings:e}),Ce=!1})}catch(e){return Promise.reject(e)}},Ne=function(){var e=document.createElement("div");e.id=ke,document.body.appendChild(e)},He=we.getInstance(),Te=me.getInstance(),ze=function(e,t){try{return Promise.resolve(fetch(Te.get().apiHost+"/api/v1/client/environments/"+Te.get().environmentId+"/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Te.get().session.id,eventName:e,properties:t})})).then(function(t){var n;function r(t){if(n)return t;He.debug('Formbricks: Event "'+e+'" tracked'),Fe(e)}var o=function(){if(!t.ok)return Promise.resolve(t.json()).then(function(e){He.error("Formbricks: Error tracking event: "+JSON.stringify(e)),n=1})}();return o&&o.then?o.then(r):r(o)})}catch(e){return Promise.reject(e)}},Fe=function(e){for(var t,n=s(null==(r=Te.get().settings)?void 0:r.surveys);!(t=n()).done;)for(var r,o,i=t.value,a=s(i.triggers);!(o=a()).done;){var f;if((null==(f=o.value.eventClass)?void 0:f.name)===e)return He.debug("Formbricks: survey "+i.id+' triggered by event "'+e+'"'),void Ie(i)}},Le=me.getInstance(),qe=we.getInstance(),Oe=function(){try{return qe.debug("Creating new person"),Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){return e.ok?Promise.resolve(e.json()):(console.error("Formbricks: Error fetching person"),null)})}catch(e){return Promise.reject(e)}},Ue=function(e,t){var n=Le.get().person.attributes.find(function(t){var n;return(null==(n=t.attributeClass)?void 0:n.name)===e});return!(!n||n.value!==t)},Ae=we.getInstance(),Me=me.getInstance(),De=function(){try{return Me.get().person?Promise.resolve(fetch(Me.get().apiHost+"/api/v1/client/environments/"+Me.get().environmentId+"/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:Me.get().person.id})})).then(function(e){if(e.ok)return Promise.resolve(e.json());Ae.error("Error creating session")}):(Ae.error("Formbricks: Unable to create session. No person found"),Promise.resolve())}catch(e){return Promise.reject(e)}},We=function(e){Ae.debug("Session expired. Creating new session.");var t=o({},e);return t.expiresAt=Date.now()+36e5,t},Je=function(e){return e.expiresAt<=Date.now()},Be=me.getInstance(),Re=we.getInstance(),Ve=function(){var e=Be.get().settings,t=null==e?void 0:e.noCodeEvents.filter(function(e){var t;return"pageUrl"===(null==(t=e.noCodeConfig)?void 0:t.type)});if(Re.debug("checking page url"),0!==t.length)for(var n,r=s(t);!(n=r()).done;){var o=n.value,i=o.noCodeConfig.pageUrl;i&&Ye(window.location.href,i.value,i.rule)&&ze(o.name)}};function Ye(e,t,n){switch(n){case"exactMatch":return e===t;case"contains":return e.includes(t);case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"notMatch":return e!==t;case"notContains":return!e.includes(t);default:throw new Error("Invalid match type")}}var Qe=function(e){var t=Be.get().settings,n=null==t?void 0:t.noCodeEvents.filter(function(e){var t;return"innerHtml"===(null==(t=e.noCodeConfig)?void 0:t.type)}),r=null==t?void 0:t.noCodeEvents.filter(function(e){var t;return"cssSelector"===(null==(t=e.noCodeConfig)?void 0:t.type)}),o=e.target;n.forEach(function(e){var t,n=null==(t=e.noCodeConfig)?void 0:t.innerHtml;n&&o.innerHTML===n.value&&ze(e.name)}),r.forEach(function(e){var t,n=null==(t=e.noCodeConfig)?void 0:t.cssSelector;n&&o.matches(n.value)&&ze(e.name)})},Xe=me.getInstance(),$e=we.getInstance(),Ge=function(){if(!(Xe.get().apiHost&&Xe.get().environmentId&&Xe.get().person&&Xe.get().session&&Xe.get().settings))throw Error("Formbricks: Formbricks not initialized. Call initialize() first.")},Ke=new r,Ze=function(e,t){Ke.add(function(){try{return Ge(),Promise.resolve(function(e,t){try{return qe.debug("setting attribute: "+e+" to value: "+t),Ue(e,t)?(qe.debug("attribute already set to this value. Skipping update."),Promise.resolve()):Promise.resolve(function(e,t){try{return Le.get().person&&Le.get().person.id?Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people/"+Le.get().person.id+"/attribute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:t})})).then(function(e){return Promise.resolve(e.json()).then(function(t){if(!e.ok)throw qe.error("Error updating person"),Error("Error updating person");return t})}):(console.error("Formbricks: Unable to update attribute. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e,t)).then(function(e){var t=e.person,n=e.settings;if(!t||!n)throw qe.error("Error updating attribute"),new Error("Formbricks: Error updating attribute");Le.update({person:t,settings:n})})}catch(e){return Promise.reject(e)}}(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},et={init:function(e){Ke.add(function(){try{return function(e){try{var t,n=function(e){if(t)return e;(function(){if("undefined"!=typeof window){var e=window.setInterval(function(){try{return Promise.resolve(function(){try{var e=function(e){Ae.debug("Session not expired, extending session"),Me.update({session:We(Me.get().session)})};Ae.debug("Checking session");var t=function(){if(Je(Me.get().session))return Ae.debug("Session expired, creating new session"),Promise.resolve(De()).then(function(e){var t=e.session,n=e.settings;if(!t||!n)throw Ae.error("Error creating new session"),Error("Error creating new session");Me.update({session:t,settings:n}),ze("New Session")})}();return Promise.resolve(t&&t.then?t.then(e):e())}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}},3e5);window.addEventListener("beforeunload",function(){clearInterval(e)})}})(),"undefined"!=typeof window&&(window.addEventListener("hashchange",Ve),window.addEventListener("popstate",Ve),window.addEventListener("pushstate",Ve),window.addEventListener("replacestate",Ve),window.addEventListener("load",Ve)),"undefined"!=typeof window&&document.addEventListener("click",Qe),$e.debug("Initialized")};if(!e.environmentId)throw Error("Formbricks: environmentId is required");if(!e.apiHost)throw Error("Formbricks: apiHost is required");e.logLevel&&$e.configure({logLevel:e.logLevel}),Ne(),function(){if(null===document.getElementById("formbricks__css")){var e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :after,#fbjs :before{border:0 solid #e5e7eb;box-sizing:border-box}#fbjs :after,#fbjs :before{--tw-content:""}#fbjs html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#fbjs body{line-height:inherit;margin:0}#fbjs hr{border-top-width:1px;color:inherit;height:0}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs pre,#fbjs samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{border-collapse:collapse;border-color:inherit;text-indent:0}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit],#fbjs button{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dd,#fbjs dl,#fbjs figure,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs menu,#fbjs ol,#fbjs ul{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{color:#9ca3af;opacity:1}#fbjs input::placeholder,#fbjs textarea::placeholder{color:#9ca3af;opacity:1}#fbjs [role=button],#fbjs button{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs audio,#fbjs canvas,#fbjs embed,#fbjs iframe,#fbjs img,#fbjs object,#fbjs svg,#fbjs video{display:block;vertical-align:middle}#fbjs img,#fbjs video{height:auto;max-width:100%}#fbjs [hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#fbjs :is(.fb-sr-only){clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}#fbjs :is(.fb-pointer-events-none){pointer-events:none}#fbjs :is(.fb-pointer-events-auto){pointer-events:auto}#fbjs :is(.fb-fixed){position:fixed}#fbjs :is(.fb-absolute){position:absolute}#fbjs :is(.fb-relative){position:relative}#fbjs :is(.fb-inset-0){inset:0}#fbjs :is(.fb-right-0){right:0}#fbjs :is(.fb-top-0){top:0}#fbjs :is(.fb-z-10){z-index:10}#fbjs :is(.fb-ml-3){margin-left:.75rem}#fbjs :is(.fb-mr-8){margin-right:2rem}#fbjs :is(.fb-mt-2){margin-top:.5rem}#fbjs :is(.fb-mt-4){margin-top:1rem}#fbjs :is(.fb-block){display:block}#fbjs :is(.fb-flex){display:flex}#fbjs :is(.fb-hidden){display:none}#fbjs :is(.fb-h-1){height:.25rem}#fbjs :is(.fb-h-4){height:1rem}#fbjs :is(.fb-h-6){height:1.5rem}#fbjs :is(.fb-w-4){width:1rem}#fbjs :is(.fb-w-6){width:1.5rem}#fbjs :is(.fb-w-full){width:100%}#fbjs :is(.fb-max-w-sm){max-width:24rem}#fbjs :is(.fb-translate-x-0){--tw-translate-x:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.fb-translate-x-28){--tw-translate-x:7rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes fb-pulse{50%{opacity:.5}}#fbjs :is(.fb-animate-pulse){animation:fb-pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs :is(.fb-cursor-pointer){cursor:pointer}#fbjs :is(.fb-flex-col){flex-direction:column}#fbjs :is(.fb-items-end){align-items:flex-end}#fbjs :is(.fb-items-center){align-items:center}#fbjs :is(.fb-justify-between){justify-content:space-between}#fbjs :is(.fb-space-y-2>:not([hidden])~:not([hidden])){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}#fbjs :is(.fb-space-y-4>:not([hidden])~:not([hidden])){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}#fbjs :is(.fb-overflow-hidden){overflow:hidden}#fbjs :is(.fb-rounded-full){border-radius:9999px}#fbjs :is(.fb-rounded-lg){border-radius:.5rem}#fbjs :is(.fb-rounded-md){border-radius:.375rem}#fbjs :is(.fb-border){border-width:1px}#fbjs :is(.fb-border-gray-200){--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-100){--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-300){--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-400){--tw-border-opacity:1;border-color:rgb(148 163 184/var(--tw-border-opacity))}#fbjs :is(.fb-border-transparent){border-color:transparent}#fbjs :is(.fb-bg-slate-50){--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}#fbjs :is(.fb-bg-white){--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}#fbjs :is(.fb-p-2){padding:.5rem}#fbjs :is(.fb-p-4){padding:1rem}#fbjs :is(.fb-px-3){padding-left:.75rem;padding-right:.75rem}#fbjs :is(.fb-px-4){padding-left:1rem;padding-right:1rem}#fbjs :is(.fb-py-3){padding-bottom:.75rem;padding-top:.75rem}#fbjs :is(.fb-py-6){padding-bottom:1.5rem;padding-top:1.5rem}#fbjs :is(.fb-pr-4){padding-right:1rem}#fbjs :is(.fb-pt-4){padding-top:1rem}#fbjs :is(.fb-font-sans){font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}#fbjs :is(.fb-text-base){font-size:1rem;line-height:1.5rem}#fbjs :is(.fb-text-sm){font-size:.875rem;line-height:1.25rem}#fbjs :is(.fb-font-medium){font-weight:500}#fbjs :is(.fb-font-normal){font-weight:400}#fbjs :is(.fb-font-semibold){font-weight:600}#fbjs :is(.fb-leading-4){line-height:1rem}#fbjs :is(.fb-leading-6){line-height:1.5rem}#fbjs :is(.fb-text-slate-400){--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}#fbjs :is(.fb-text-slate-800){--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity))}#fbjs :is(.fb-text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}#fbjs :is(.fb-opacity-0){opacity:0}#fbjs :is(.fb-opacity-100){opacity:1}#fbjs :is(.fb-opacity-60){opacity:.6}#fbjs :is(.fb-shadow-lg){--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs :is(.fb-shadow-sm){--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs :is(.fb-ring-1){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.fb-ring-black){--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity))}#fbjs :is(.fb-ring-opacity-5){--tw-ring-opacity:0.05}#fbjs :is(.fb-transition-all){transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs :is(.fb-duration-500){transition-duration:.5s}#fbjs :is(.fb-ease-in-out){transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs :is(.hover\\:fb-text-slate-500:hover){--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}#fbjs :is(.hover\\:fb-opacity-90:hover){opacity:.9}#fbjs :is(.focus\\:fb-border-slate-500:focus){--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity))}#fbjs :is(.focus\\:fb-outline-none:focus){outline:2px solid transparent;outline-offset:2px}#fbjs :is(.focus\\:fb-ring-0:focus){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.focus\\:fb-ring-2:focus){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.focus\\:fb-ring-slate-500:focus){--tw-ring-opacity:1;--tw-ring-color:rgb(100 116 139/var(--tw-ring-opacity))}#fbjs :is(.focus\\:fb-ring-offset-0:focus){--tw-ring-offset-width:0px}#fbjs :is(.focus\\:fb-ring-offset-2:focus){--tw-ring-offset-width:2px}@media (min-width:640px){#fbjs :is(.sm\\:fb-block){display:block}#fbjs :is(.sm\\:fb-items-end){align-items:flex-end}#fbjs :is(.sm\\:fb-p-6){padding:1.5rem}#fbjs :is(.sm\\:fb-text-sm){font-size:.875rem;line-height:1.25rem}}',document.head.appendChild(e)}}();var r=Xe&&Xe.get().environmentId===e.environmentId&&Xe.get().apiHost===e.apiHost?Xe.get().session&&Je(Xe.get().session)?Promise.resolve(De()).then(function(e){var t=e.settings;Xe.update({session:We(e.session),settings:t}),ze("New Session")}):Xe.get().session?void 0:($e.error("Unable to initialize. No session found"),void(t=1)):(Xe.update({environmentId:e.environmentId,apiHost:e.apiHost}),Promise.resolve(Oe()).then(function(e){var t=e.settings;Xe.update({person:e.person,session:We(e.session),settings:t}),ze("New Session")}));Promise.resolve(r&&r.then?r.then(n):n(r))}catch(e){return Promise.reject(e)}}(e),Promise.resolve()}catch(e){return Promise.reject(e)}})},setUserId:function(e){Ke.add(function(){try{return Ge(),Promise.resolve(function(e){try{return qe.debug("setting userId: "+e),Ue("userId",e)?(qe.debug("userId already set to this value. Skipping update."),Promise.resolve()):(t=Le.get().person.attributes.find(function(e){var t;return"userId"===(null==(t=e.attributeClass)?void 0:t.name)}),t?(qe.error("userId cannot be changed after it has been set. You need to reset first"),Promise.resolve()):Promise.resolve(function(e){try{return Le.get().person&&Le.get().person.id?Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people/"+Le.get().person.id+"/user-id",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,sessionId:Le.get().session.id})})).then(function(e){if(!e.ok)throw qe.error("Formbricks: Error updating person"),Error("Error updating person");return Promise.resolve(e.json())}):(console.error("Formbricks: Unable to update userId. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e)).then(function(e){Le.update({person:e.person,settings:e.settings})}))}catch(e){return Promise.reject(e)}var t}(e)).then(function(){})}catch(e){return Promise.reject(e)}})},setEmail:function(e){Ze("email",e)},setAttribute:Ze,track:function(e,t){void 0===t&&(t={}),Ke.add(function(){try{return Ge(),Promise.resolve(ze(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},logout:function(){Ke.add(function(){try{return Ge(),Promise.resolve(function(){try{return qe.debug("Resetting person. Getting new person, session and settings from backend"),Promise.resolve(Oe()).then(function(e){var t=e.person,n=e.session,r=e.settings;if(!t||!n||!r)throw qe.error("Error resetting user"),new Error("Formbricks: Error resetting user");Le.update({person:t,session:n,settings:r})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},refresh:function(){Ke.add(function(){try{return Ge(),Promise.resolve(function(){try{return ye.debug("Refreshing - getting settings from backend"),Promise.resolve(xe()).then(function(e){je.update({settings:e})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},registerRouteChange:function(){Ke.add(function(){try{return Ge(),Ve(),Promise.resolve()}catch(e){return Promise.reject(e)}})}};export{et as default};
//# sourceMappingURL=index.module.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).js=t()}(this,function(){function e(n,r,o){if(!n.s){if(o instanceof t){if(!o.s)return void(o.o=e.bind(null,n,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(e.bind(null,n,r),e.bind(null,n,2));n.s=r,n.v=o;var i=n.o;i&&i(n)}}var t=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(n,r){var o=new t,i=this.s;if(i){var s=1&i?n:r;if(s){try{e(o,1,s(this.v))}catch(t){e(o,2,t)}return o}return this}return this.o=function(t){try{var i=t.v;1&t.s?e(o,1,n?n(i):i):r?e(o,1,r(i)):e(o,2,i)}catch(t){e(o,2,t)}},o},t}();function n(e){return e instanceof t&&1&e.s}var r=/*#__PURE__*/function(){function r(){this.queue=[],this.running=!1}var o=r.prototype;return o.add=function(e){this.queue.push(e),this.running||this.run()},o.run=function(){try{var r=function(){o.running=!1},o=this;o.running=!0;var i=function(r,o,i){for(var s;;){var a=r();if(n(a)&&(a=a.v),!a)return f;if(a.then){s=0;break}var f=i();if(f&&f.then){if(!n(f)){s=1;break}f=f.s}}var l=new t,u=e.bind(null,l,2);return(0===s?a.then(d):1===s?f.then(c):(void 0).then(function(){(a=r())?a.then?a.then(d).then(void 0,u):d(a):e(l,1,f)})).then(void 0,u),l;function c(t){f=t;do{if(!(a=r())||n(a)&&!a.v)return void e(l,1,f);if(a.then)return void a.then(d).then(void 0,u);n(f=i())&&(f=f.v)}while(!f||!f.then);f.then(c).then(void 0,u)}function d(t){t?(f=i())&&f.then?f.then(c).then(void 0,u):c(f):e(l,1,f)}}(function(){return o.queue.length>0},0,function(){var e=o.queue.shift(),t=function(t,n){try{var r=Promise.resolve(e()).then(function(){})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){console.error(e)});if(t&&t.then)return t.then(function(){})});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},r}();function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,f,l,u,c,d={},b=[],p=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function h(e,t){for(var n in t)e[n]=t[n];return e}function g(e){var t=e.parentNode;t&&t.removeChild(e)}function _(e,t,n){var r,o,i,s=arguments,a={};for(i in t)"key"==i?r=t[i]:"ref"==i?o=t[i]:a[i]=t[i];if(arguments.length>3)for(n=[n],i=3;i<arguments.length;i++)n.push(s[i]);if(null!=n&&(a.children=n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===a[i]&&(a[i]=e.defaultProps[i]);return v(e,a,r,o,null)}function v(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++a.__v:o};return null!=a.vnode&&a.vnode(i),i}function m(e){return e.children}function w(e,t){this.props=e,this.context=t}function y(e,t){if(null==t)return e.__?y(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?y(e):null}function j(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return j(e)}}function x(e){(!e.__d&&(e.__d=!0)&&f.push(e)&&!k.__r++||u!==a.debounceRendering)&&((u=a.debounceRendering)||l)(k)}function k(){for(var e;k.__r=f.length;)e=f.sort(function(e,t){return e.__v.__b-t.__v.__b}),f=[],e.some(function(e){var t,n,r,o,i,s,a;e.__d&&(s=(i=(t=e).__v).__e,(a=t.__P)&&(n=[],(r=h({},i)).__v=i.__v+1,o=H(a,i,r,t.__n,void 0!==a.ownerSVGElement,null!=i.__h?[s]:null,n,null==s?y(i):s,i.__h),z(n,i),o!=s&&j(i)))})}function P(e,t,n,r,o,i,s,a,f,l){var u,c,p,h,_,w,j,x=r&&r.__k||b,k=x.length;for(f==d&&(f=null!=s?s[0]:k?y(r,0):null),n.__k=[],u=0;u<t.length;u++)if(null!=(h=n.__k[u]=null==(h=t[u])||"boolean"==typeof h?null:"string"==typeof h||"number"==typeof h?v(null,h,null,null,h):Array.isArray(h)?v(m,{children:h},null,null,null):null!=h.__e||null!=h.__c?v(h.type,h.props,h.key,null,h.__v):h)){if(h.__=n,h.__b=n.__b+1,null===(p=x[u])||p&&h.key==p.key&&h.type===p.type)x[u]=void 0;else for(c=0;c<k;c++){if((p=x[c])&&h.key==p.key&&h.type===p.type){x[c]=void 0;break}p=null}_=H(e,h,p=p||d,o,i,s,a,f,l),(c=h.ref)&&p.ref!=c&&(j||(j=[]),p.ref&&j.push(p.ref,null,h),j.push(c,h.__c||_,h)),null!=_?(null==w&&(w=_),f=S(e,h,p,x,s,_,f),l||"option"!=n.type?"function"==typeof n.type&&(n.__d=f):e.value=""):f&&p.__e==f&&f.parentNode!=e&&(f=y(p))}if(n.__e=w,null!=s&&"function"!=typeof n.type)for(u=s.length;u--;)null!=s[u]&&g(s[u]);for(u=k;u--;)null!=x[u]&&q(x[u],x[u]);if(j)for(u=0;u<j.length;u++)F(j[u],j[++u],j[++u])}function S(e,t,n,r,o,i,s){var a,f,l;if(void 0!==t.__d)a=t.__d,t.__d=void 0;else if(o==n||i!=s||null==i.parentNode)e:if(null==s||s.parentNode!==e)e.appendChild(i),a=null;else{for(f=s,l=0;(f=f.nextSibling)&&l<r.length;l+=2)if(f==i)break e;e.insertBefore(i,s),a=s}return void 0!==a?a:i.nextSibling}function I(e,t,n){"-"===t[0]?e.setProperty(t,n):e[t]=null==n?"":"number"!=typeof n||p.test(t)?n:n+"px"}function C(e,t,n,r,o){var i,s,a;if(o&&"className"==t&&(t="class"),"style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||I(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||I(e.style,t,n[t])}else"o"===t[0]&&"n"===t[1]?(i=t!==(t=t.replace(/Capture$/,"")),(s=t.toLowerCase())in e&&(t=s),t=t.slice(2),e.l||(e.l={}),e.l[t+i]=n,a=i?N:E,n?r||e.addEventListener(t,a,i):e.removeEventListener(t,a,i)):"list"!==t&&"tagName"!==t&&"form"!==t&&"type"!==t&&"size"!==t&&"download"!==t&&"href"!==t&&!o&&t in e?e[t]=null==n?"":n:"function"!=typeof n&&"dangerouslySetInnerHTML"!==t&&(t!==(t=t.replace(/xlink:?/,""))?null==n||!1===n?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),n):null==n||!1===n&&!/^ar/.test(t)?e.removeAttribute(t):e.setAttribute(t,n))}function E(e){this.l[e.type+!1](a.event?a.event(e):e)}function N(e){this.l[e.type+!0](a.event?a.event(e):e)}function T(e,t,n){var r,o;for(r=0;r<e.__k.length;r++)(o=e.__k[r])&&(o.__=e,o.__e&&("function"==typeof o.type&&o.__k.length>1&&T(o,t,n),t=S(n,o,o,e.__k,null,o.__e,t),"function"==typeof e.type&&(e.__d=t)))}function H(e,t,n,r,o,i,s,f,l){var u,c,p,g,_,v,y,j,x,k,S,I=t.type;if(void 0!==t.constructor)return null;null!=n.__h&&(l=n.__h,f=t.__e=n.__e,t.__h=null,i=[f]),(u=a.__b)&&u(t);try{e:if("function"==typeof I){if(j=t.props,x=(u=I.contextType)&&r[u.__c],k=u?x?x.props.value:u.__:r,n.__c?y=(c=t.__c=n.__c).__=c.__E:("prototype"in I&&I.prototype.render?t.__c=c=new I(j,k):(t.__c=c=new w(j,k),c.constructor=I,c.render=L),x&&x.sub(c),c.props=j,c.state||(c.state={}),c.context=k,c.__n=r,p=c.__d=!0,c.__h=[]),null==c.__s&&(c.__s=c.state),null!=I.getDerivedStateFromProps&&(c.__s==c.state&&(c.__s=h({},c.__s)),h(c.__s,I.getDerivedStateFromProps(j,c.__s))),g=c.props,_=c.state,p)null==I.getDerivedStateFromProps&&null!=c.componentWillMount&&c.componentWillMount(),null!=c.componentDidMount&&c.__h.push(c.componentDidMount);else{if(null==I.getDerivedStateFromProps&&j!==g&&null!=c.componentWillReceiveProps&&c.componentWillReceiveProps(j,k),!c.__e&&null!=c.shouldComponentUpdate&&!1===c.shouldComponentUpdate(j,c.__s,k)||t.__v===n.__v){c.props=j,c.state=c.__s,t.__v!==n.__v&&(c.__d=!1),c.__v=t,t.__e=n.__e,t.__k=n.__k,c.__h.length&&s.push(c),T(t,f,e);break e}null!=c.componentWillUpdate&&c.componentWillUpdate(j,c.__s,k),null!=c.componentDidUpdate&&c.__h.push(function(){c.componentDidUpdate(g,_,v)})}c.context=k,c.props=j,c.state=c.__s,(u=a.__r)&&u(t),c.__d=!1,c.__v=t,c.__P=e,u=c.render(c.props,c.state,c.context),c.state=c.__s,null!=c.getChildContext&&(r=h(h({},r),c.getChildContext())),p||null==c.getSnapshotBeforeUpdate||(v=c.getSnapshotBeforeUpdate(g,_)),S=null!=u&&u.type==m&&null==u.key?u.props.children:u,P(e,Array.isArray(S)?S:[S],t,n,r,o,i,s,f,l),c.base=t.__e,t.__h=null,c.__h.length&&s.push(c),y&&(c.__E=c.__=null),c.__e=!1}else null==i&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,r,o,i,s,a){var f,l,u,c,p,h=n.props,g=t.props;if(o="svg"===t.type||o,null!=i)for(f=0;f<i.length;f++)if(null!=(l=i[f])&&((null===t.type?3===l.nodeType:l.localName===t.type)||e==l)){e=l,i[f]=null;break}if(null==e){if(null===t.type)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",t.type):document.createElement(t.type,g.is&&{is:g.is}),i=null,a=!1}if(null===t.type)h===g||a&&e.data===g||(e.data=g);else{if(null!=i&&(i=b.slice.call(e.childNodes)),u=(h=n.props||d).dangerouslySetInnerHTML,c=g.dangerouslySetInnerHTML,!a){if(null!=i)for(h={},p=0;p<e.attributes.length;p++)h[e.attributes[p].name]=e.attributes[p].value;(c||u)&&(c&&(u&&c.__html==u.__html||c.__html===e.innerHTML)||(e.innerHTML=c&&c.__html||""))}(function(e,t,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in t||C(e,i,null,n[i],r);for(i in t)o&&"function"!=typeof t[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===t[i]||C(e,i,t[i],n[i],r)})(e,g,h,o,a),c?t.__k=[]:(f=t.props.children,P(e,Array.isArray(f)?f:[f],t,n,r,"foreignObject"!==t.type&&o,i,s,d,a)),a||("value"in g&&void 0!==(f=g.value)&&(f!==e.value||"progress"===t.type&&!f)&&C(e,"value",f,h.value,!1),"checked"in g&&void 0!==(f=g.checked)&&f!==e.checked&&C(e,"checked",f,h.checked,!1))}return e}(n.__e,t,n,r,o,i,s,l);(u=a.diffed)&&u(t)}catch(e){t.__v=null,(l||null!=i)&&(t.__e=f,t.__h=!!l,i[i.indexOf(f)]=null),a.__e(e,t,n)}return t.__e}function z(e,t){a.__c&&a.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){a.__e(e,t.__v)}})}function F(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){a.__e(e,n)}}function q(e,t,n){var r,o,i;if(a.unmount&&a.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||F(r,null,t)),n||"function"==typeof e.type||(n=null!=(o=e.__e)),e.__e=e.__d=void 0,null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){a.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&q(r[i],t,n);null!=o&&g(o)}function L(e,t,n){return this.constructor(e,n)}a={__e:function(e,t){for(var n,r,o,i=t.__h;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e),o=n.__d),o)return t.__h=i,n.__E=n}catch(t){e=t}throw e},__v:0},w.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(h({},n),this.props)),e&&h(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),x(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),x(this))},w.prototype.render=m,f=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,k.__r=0,c=d;var O,A,U,M=0,D=[],W=a.__b,J=a.__r,B=a.diffed,R=a.__c,Q=a.unmount;function G(e,t){a.__h&&a.__h(A,e,M||t),M=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return M=1,function(e,t,n){var r=G(O++,2);return r.t=e,r.__c||(r.__=[ee(void 0,t),function(e){var t=r.t(r.__[0],e);r.__[0]!==t&&(r.__=[t,r.__[1]],r.__c.setState({}))}],r.__c=A),r.__}(ee,e)}function $(e,t){var n=G(O++,3);!a.__s&&function(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}(n.__H,t)&&(n.__=e,n.__H=t,A.__H.__h.push(n))}function V(){D.forEach(function(e){if(e.__P)try{e.__H.__h.forEach(K),e.__H.__h.forEach(Z),e.__H.__h=[]}catch(t){e.__H.__h=[],a.__e(t,e.__v)}}),D=[]}a.__b=function(e){A=null,W&&W(e)},a.__r=function(e){J&&J(e),O=0;var t=(A=e.__c).__H;t&&(t.__h.forEach(K),t.__h.forEach(Z),t.__h=[])},a.diffed=function(e){B&&B(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==D.push(t)&&U===a.requestAnimationFrame||((U=a.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),X&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);X&&(t=requestAnimationFrame(n))})(V)),A=void 0},a.__c=function(e,t){t.some(function(e){try{e.__h.forEach(K),e.__h=e.__h.filter(function(e){return!e.__||Z(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],a.__e(n,e.__v)}}),R&&R(e,t)},a.unmount=function(e){Q&&Q(e);var t=e.__c;if(t&&t.__H)try{t.__H.__.forEach(K)}catch(e){a.__e(e,t.__v)}};var X="function"==typeof requestAnimationFrame;function K(e){var t=A;"function"==typeof e.__c&&e.__c(),A=t}function Z(e){var t=A;e.__c=e.__(),A=t}function ee(e,t){return"function"==typeof t?t(e):t}var te=function(){return[].slice.call(arguments).filter(Boolean).join(" ")};function ne(e){var t=e.children,n=e.isOpen,r=e.close,o=Y(!1),i=o[0],s=o[1];return $(function(){s(n)},[n]),_("div",{"aria-live":"assertive",className:"fb-pointer-events-none fb-fixed fb-inset-0 fb-flex fb-items-end fb-px-4 fb-py-6 sm:fb-p-6"},_("div",{className:"fb-flex fb-w-full fb-flex-col fb-items-center fb-space-y-4 sm:fb-items-end"},_("div",{className:te(i?"fb-translate-x-0 fb-opacity-100":"fb-translate-x-28 fb-opacity-0","fb-pointer-events-auto fb-relative fb-w-full fb-max-w-sm fb-overflow-hidden fb-rounded-lg fb-bg-white fb-shadow-lg fb-ring-1 fb-ring-black fb-ring-opacity-5 fb-transition-all fb-duration-500 fb-ease-in-out")},_("div",{class:"fb-absolute fb-top-0 fb-right-0 fb-hidden fb-pt-4 fb-pr-4 sm:fb-block"},_("button",{type:"button",onClick:r,class:"fb-rounded-md fb-bg-white focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 fb-text-slate-400 hover:fb-text-slate-500 focus:ring-slate-500"},_("span",{class:"fb-sr-only"},"Close"),_("svg",{class:"fb-h-6 fb-w-6",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},_("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})))),_("div",{className:""},t))))}var re=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays/"+e+"/responded",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){if(!e.ok)throw new Error("Could not update display")})}catch(e){return Promise.reject(e)}},oe=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/responses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function ie(e){return _("label",{htmlFor:e.questionId,className:"fb-block fb-text-base fb-font-semibold fb-leading-6 fb-mr-8 text-slate-900"},e.headline)}function se(e){return _("label",{for:e.questionId,className:"fb-block fb-text-sm fb-font-normal fb-leading-6 text-slate-600"},e.subheader)}function ae(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor;return _("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},_(ie,{headline:t.headline,questionId:t.id}),_(se,{subheader:t.subheader,questionId:t.id}),_("div",{className:"fb-mt-4"},_("textarea",{rows:3,name:t.id,id:t.id,placeholder:t.placeholder,required:t.required,className:"fb-block fb-w-full fb-rounded-md fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm fb-bg-slate-50 fb-border-slate-100 focus:fb-border-slate-500"})),_("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},_("div",null),_("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:fb-ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function fe(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor,i=Y(null),s=i[0],a=i[1];return _("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},_(ie,{headline:t.headline,questionId:t.id}),_(se,{subheader:t.subheader,questionId:t.id}),_("div",{className:"fb-mt-4"},_("fieldset",null,_("legend",{className:"fb-sr-only"},"Choices"),_("div",{className:"fb-relative fb-space-y-2 fb-rounded-md fb-bg-white"},t.choices&&t.choices.map(function(e){return _("label",{key:e.id,className:te(s===e.label?"fb-z-10 fb-bg-slate-50 fb-border-slate-400":"fb-border-gray-200","fb-relative fb-flex fb-cursor-pointer fb-flex-col fb-rounded-md fb-border fb-p-4 focus:fb-outline-none hover:bg-slate-50")},_("span",{className:"fb-flex fb-items-center fb-text-sm"},_("input",{type:"radio",id:e.id,name:t.id,value:e.label,className:"fb-h-4 fb-w-4 fb-border fb-border-slate-300 focus:fb-ring-0 focus:fb-ring-offset-0","aria-labelledby":e.id+"-label",onChange:function(e){a(e.currentTarget.value)},style:{borderColor:o,color:o}}),_("span",{id:e.id+"-label",className:"fb-ml-3 fb-font-medium"},e.label)))})))),_("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},_("div",null),_("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function le(e){return _("div",{className:"fb-h-1 fb-w-full fb-rounded-full bg-slate-200"},_("div",{className:"fb-h-1 fb-rounded-full",style:{backgroundColor:e.brandColor,width:Math.floor(100*e.progress)+"%"}}))}function ue(e){var t=e.config,n=e.survey,r=e.close,o=e.brandColor,i=Y(n.questions[0]),s=i[0],a=i[1],f=Y(0),l=f[0],u=f[1],c=Y(null),d=c[0],b=c[1],p=Y(null),h=p[0],g=p[1],v=Y(!1),m=v[0],w=v[1];$(function(){!function(){try{Promise.resolve(function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create display");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}({surveyId:n.id,personId:t.person.id},t)).then(function(e){g(e.id)})}catch(e){return Promise.reject(e)}}()},[t,n]),$(function(){var e;u((e=n.questions.findIndex(function(e){return e.id===s.id}),e/n.questions.length))},[s,n]);var y=function(e){try{var o=function(){w(!1),f?(u(100),r()):a(n.questions[i+1])};w(!0);var i=n.questions.findIndex(function(e){return e.id===s.id}),f=i===n.questions.length-1,l={surveyId:n.id,personId:t.person.id,response:{finished:f,data:e}},c=d?Promise.resolve(function(e,t,n){try{return Promise.resolve(fetch(n.apiHost+"/api/v1/client/environments/"+n.environmentId+"/responses/"+t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw new Error("Could not update response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}(l,d,t)).then(function(){}):Promise.resolve(Promise.all([oe(l,t),re(h,t)])).then(function(e){b(e[0].id)});return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}};return _("div",null,_("div",{className:te(m?"fb-animate-pulse fb-opacity-60":"","fb-p-4 fb-text-slate-800 fb-font-sans")},"multipleChoiceSingle"===s.type?_(fe,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):"openText"===s.type?_(ae,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):null),_("div",{className:"fb-mt-2"},_(le,{progress:l,brandColor:o})))}function ce(e){var t,n=e.config,r=e.survey,o=e.closeSurvey,i=Y(!0),s=i[1],a=function(){s(!1),setTimeout(function(){o()},1e3)};return _("div",{id:"fbjs"},_(ne,{isOpen:i[0],close:a},_(ue,{config:n,survey:r,close:a,brandColor:null==(t=n.settings)?void 0:t.brandColor})))}var de=/*#__PURE__*/function(){function e(){this.config=this.loadFromLocalStorage()}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.update=function(e){e&&(this.config=o({},this.config,e),this.saveToLocalStorage())},t.get=function(){return this.config},t.loadFromLocalStorage=function(){if("undefined"!=typeof window){var e=localStorage.getItem("config");if(e)return JSON.parse(e)}return{apiHost:null,environmentId:null}},t.saveToLocalStorage=function(){localStorage.setItem("config",JSON.stringify(this.config))},e}();de.instance=void 0;var be=/*#__PURE__*/function(){function e(){this.logLevel="error"}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.configure=function(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)},t.logger=function(e,t){if("debug"!==t||"debug"===this.logLevel){var n="🧱 Formbricks - "+(new Date).toISOString()+" ["+t.toUpperCase()+"] - "+e;"error"===t?console.error(n):console.log(n)}},t.debug=function(e){this.logger(e,"debug")},t.error=function(e){this.logger(e,"error")},e}();be.instance=void 0;var pe=be.getInstance(),he=de.getInstance(),ge=function(){try{return Promise.resolve(fetch(he.get().apiHost+"/api/v1/client/environments/"+he.get().environmentId+"/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:he.get().person.id})})).then(function(e){if(!e.ok)throw pe.error("Error getting settings"),Error("Error getting settings");return e.json()})}catch(e){return Promise.reject(e)}},_e="formbricks-web-container",ve=de.getInstance(),me=be.getInstance(),we=!1,ye=function(e){we?me.debug("A survey is already running. Skipping."):(we=!0,function(e,t,n){var r,o,i;a.__&&a.__(e,t),o=(r=void 0===c)?null:t.__k,e=_(m,null,[e]),i=[],H(t,t.__k=e,o||d,d,void 0!==t.ownerSVGElement,o?null:t.childNodes.length?b.slice.call(t.childNodes):null,i,d,r),z(i,e)}(_(ce,{config:ve.get(),survey:e,closeSurvey:je}),document.getElementById(_e)))},je=function(){try{return console.log("close survey called"),document.getElementById(_e).remove(),xe(),Promise.resolve(ge()).then(function(e){ve.update({settings:e}),we=!1})}catch(e){return Promise.reject(e)}},xe=function(){var e=document.createElement("div");e.id=_e,document.body.appendChild(e)},ke=be.getInstance(),Pe=de.getInstance(),Se=function(e,t){try{return Promise.resolve(fetch(Pe.get().apiHost+"/api/v1/client/environments/"+Pe.get().environmentId+"/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Pe.get().session.id,eventName:e,properties:t})})).then(function(t){var n;function r(t){if(n)return t;ke.debug('Formbricks: Event "'+e+'" tracked'),Ie(e)}var o=function(){if(!t.ok)return Promise.resolve(t.json()).then(function(e){ke.error("Formbricks: Error tracking event: "+JSON.stringify(e)),n=1})}();return o&&o.then?o.then(r):r(o)})}catch(e){return Promise.reject(e)}},Ie=function(e){for(var t,n=s(null==(r=Pe.get().settings)?void 0:r.surveys);!(t=n()).done;)for(var r,o,i=t.value,a=s(i.triggers);!(o=a()).done;){var f;if((null==(f=o.value.eventClass)?void 0:f.name)===e)return ke.debug("Formbricks: survey "+i.id+' triggered by event "'+e+'"'),void ye(i)}},Ce=de.getInstance(),Ee=be.getInstance(),Ne=function(){try{return Ee.debug("Creating new person"),Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){return e.ok?Promise.resolve(e.json()):(console.error("Formbricks: Error fetching person"),null)})}catch(e){return Promise.reject(e)}},Te=function(e,t){var n=Ce.get().person.attributes.find(function(t){var n;return(null==(n=t.attributeClass)?void 0:n.name)===e});return!(!n||n.value!==t)},He=be.getInstance(),ze=de.getInstance(),Fe=function(){try{return ze.get().person?Promise.resolve(fetch(ze.get().apiHost+"/api/v1/client/environments/"+ze.get().environmentId+"/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:ze.get().person.id})})).then(function(e){if(e.ok)return Promise.resolve(e.json());He.error("Error creating session")}):(He.error("Formbricks: Unable to create session. No person found"),Promise.resolve())}catch(e){return Promise.reject(e)}},qe=function(e){He.debug("Session expired. Creating new session.");var t=o({},e);return t.expiresAt=Date.now()+36e5,t},Le=function(e){return e.expiresAt<=Date.now()},Oe=de.getInstance(),Ae=be.getInstance(),Ue=function(){var e;Ae.debug("checking page url");var t=null==(e=Oe.get().settings)?void 0:e.noCodeEvents.filter(function(e){var t;return"pageUrl"===(null==(t=e.noCodeConfig)?void 0:t.type)});if(0!==t.length)for(var n,r=s(t);!(n=r()).done;){var o=n.value,i=o.noCodeConfig.pageUrl;i&&Me(window.location.href,i.value,i.rule)&&Se(o.name)}};function Me(e,t,n){switch(n){case"exactMatch":return e===t;case"contains":return e.includes(t);case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"notMatch":return e!==t;case"notContains":return!e.includes(t);default:throw new Error("Invalid match type")}}var De=de.getInstance(),We=be.getInstance(),Je=function(){if(!(De.get().apiHost&&De.get().environmentId&&De.get().person&&De.get().session&&De.get().settings))throw Error("Formbricks: Formbricks not initialized. Call initialize() first.")},Be=new r,Re=function(e,t){Be.add(function(){try{return Je(),Promise.resolve(function(e,t){try{return Ee.debug("setting attribute: "+e+" to value: "+t),Te(e,t)?(Ee.debug("attribute already set to this value. Skipping update."),Promise.resolve()):Promise.resolve(function(e,t){try{return Ce.get().person&&Ce.get().person.id?Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people/"+Ce.get().person.id+"/attribute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:t})})).then(function(e){return Promise.resolve(e.json()).then(function(t){if(!e.ok)throw Ee.error("Error updating person"),Error("Error updating person");return t})}):(console.error("Formbricks: Unable to update attribute. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e,t)).then(function(e){var t=e.person,n=e.settings;if(!t||!n)throw Ee.error("Error updating attribute"),new Error("Formbricks: Error updating attribute");Ce.update({person:t,settings:n})})}catch(e){return Promise.reject(e)}}(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},Qe={init:function(e){Be.add(function(){try{return function(e){try{var t,n=function(e){if(t)return e;(function(){if("undefined"!=typeof window){var e=window.setInterval(function(){try{return Promise.resolve(function(){try{var e=function(e){He.debug("Session not expired, extending session"),ze.update({session:qe(ze.get().session)})};He.debug("Checking session");var t=function(){if(Le(ze.get().session))return He.debug("Session expired, creating new session"),Promise.resolve(Fe()).then(function(e){var t=e.session,n=e.settings;if(!t||!n)throw He.error("Error creating new session"),Error("Error creating new session");ze.update({session:t,settings:n}),Se("New Session")})}();return Promise.resolve(t&&t.then?t.then(e):e())}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}},3e5);window.addEventListener("beforeunload",function(){clearInterval(e)})}})(),"undefined"!=typeof window&&(window.addEventListener("hashchange",Ue),window.addEventListener("popstate",Ue),window.addEventListener("pushstate",Ue),window.addEventListener("replacestate",Ue),window.addEventListener("load",Ue)),We.debug("Initialized")};if(!e.environmentId)throw Error("Formbricks: environmentId is required");if(!e.apiHost)throw Error("Formbricks: apiHost is required");e.logLevel&&We.configure({logLevel:e.logLevel}),xe(),function(){if(null===document.getElementById("formbricks__css")){var e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :after,#fbjs :before{border:0 solid #e5e7eb;box-sizing:border-box}#fbjs :after,#fbjs :before{--tw-content:""}#fbjs html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#fbjs body{line-height:inherit;margin:0}#fbjs hr{border-top-width:1px;color:inherit;height:0}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs pre,#fbjs samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{border-collapse:collapse;border-color:inherit;text-indent:0}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit],#fbjs button{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dd,#fbjs dl,#fbjs figure,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs menu,#fbjs ol,#fbjs ul{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{color:#9ca3af;opacity:1}#fbjs input::placeholder,#fbjs textarea::placeholder{color:#9ca3af;opacity:1}#fbjs [role=button],#fbjs button{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs audio,#fbjs canvas,#fbjs embed,#fbjs iframe,#fbjs img,#fbjs object,#fbjs svg,#fbjs video{display:block;vertical-align:middle}#fbjs img,#fbjs video{height:auto;max-width:100%}#fbjs [hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#fbjs .fb-sr-only{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}#fbjs .fb-pointer-events-none{pointer-events:none}#fbjs .fb-pointer-events-auto{pointer-events:auto}#fbjs .fb-fixed{position:fixed}#fbjs .fb-absolute{position:absolute}#fbjs .fb-relative{position:relative}#fbjs .fb-inset-0{bottom:0;left:0;right:0;top:0}#fbjs .fb-right-0{right:0}#fbjs .fb-top-0{top:0}#fbjs .fb-z-10{z-index:10}#fbjs .fb-ml-3{margin-left:.75rem}#fbjs .fb-mr-8{margin-right:2rem}#fbjs .fb-mt-2{margin-top:.5rem}#fbjs .fb-mt-4{margin-top:1rem}#fbjs .fb-block{display:block}#fbjs .fb-flex{display:flex}#fbjs .fb-hidden{display:none}#fbjs .fb-h-1{height:.25rem}#fbjs .fb-h-4{height:1rem}#fbjs .fb-h-6{height:1.5rem}#fbjs .fb-w-4{width:1rem}#fbjs .fb-w-6{width:1.5rem}#fbjs .fb-w-full{width:100%}#fbjs .fb-max-w-sm{max-width:24rem}#fbjs .fb-translate-x-0{--tw-translate-x:0px}#fbjs .fb-translate-x-0,#fbjs .fb-translate-x-28{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs .fb-translate-x-28{--tw-translate-x:7rem}@keyframes fb-pulse{50%{opacity:.5}}#fbjs .fb-animate-pulse{animation:fb-pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs .fb-cursor-pointer{cursor:pointer}#fbjs .fb-flex-col{flex-direction:column}#fbjs .fb-items-end{align-items:flex-end}#fbjs .fb-items-center{align-items:center}#fbjs .fb-justify-between{justify-content:space-between}#fbjs .fb-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}#fbjs .fb-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}#fbjs .fb-overflow-hidden{overflow:hidden}#fbjs .fb-rounded-full{border-radius:9999px}#fbjs .fb-rounded-lg{border-radius:.5rem}#fbjs .fb-rounded-md{border-radius:.375rem}#fbjs .fb-border{border-width:1px}#fbjs .fb-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}#fbjs .fb-border-slate-100{--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity))}#fbjs .fb-border-slate-300{--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}#fbjs .fb-border-slate-400{--tw-border-opacity:1;border-color:rgb(148 163 184/var(--tw-border-opacity))}#fbjs .fb-border-transparent{border-color:transparent}#fbjs .fb-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}#fbjs .fb-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}#fbjs .fb-p-2{padding:.5rem}#fbjs .fb-p-4{padding:1rem}#fbjs .fb-px-3{padding-left:.75rem;padding-right:.75rem}#fbjs .fb-px-4{padding-left:1rem;padding-right:1rem}#fbjs .fb-py-3{padding-bottom:.75rem;padding-top:.75rem}#fbjs .fb-py-6{padding-bottom:1.5rem;padding-top:1.5rem}#fbjs .fb-pr-4{padding-right:1rem}#fbjs .fb-pt-4{padding-top:1rem}#fbjs .fb-font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}#fbjs .fb-text-base{font-size:1rem;line-height:1.5rem}#fbjs .fb-text-sm{font-size:.875rem;line-height:1.25rem}#fbjs .fb-font-medium{font-weight:500}#fbjs .fb-font-normal{font-weight:400}#fbjs .fb-font-semibold{font-weight:600}#fbjs .fb-leading-4{line-height:1rem}#fbjs .fb-leading-6{line-height:1.5rem}#fbjs .fb-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}#fbjs .fb-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity))}#fbjs .fb-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}#fbjs .fb-opacity-0{opacity:0}#fbjs .fb-opacity-100{opacity:1}#fbjs .fb-opacity-60{opacity:.6}#fbjs .fb-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}#fbjs .fb-shadow-lg,#fbjs .fb-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs .fb-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}#fbjs .fb-ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs .fb-ring-black{--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity))}#fbjs .fb-ring-opacity-5{--tw-ring-opacity:0.05}#fbjs .fb-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs .fb-duration-500{transition-duration:.5s}#fbjs .fb-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs .hover\\:fb-text-slate-500:hover{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}#fbjs .hover\\:fb-opacity-90:hover{opacity:.9}#fbjs .focus\\:fb-border-slate-500:focus{--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity))}#fbjs .focus\\:fb-outline-none:focus{outline:2px solid transparent;outline-offset:2px}#fbjs .focus\\:fb-ring-0:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color)}#fbjs .focus\\:fb-ring-0:focus,#fbjs .focus\\:fb-ring-2:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs .focus\\:fb-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}#fbjs .focus\\:fb-ring-slate-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(100 116 139/var(--tw-ring-opacity))}#fbjs .focus\\:fb-ring-offset-0:focus{--tw-ring-offset-width:0px}#fbjs .focus\\:fb-ring-offset-2:focus{--tw-ring-offset-width:2px}@media (min-width:640px){#fbjs .sm\\:fb-block{display:block}#fbjs .sm\\:fb-items-end{align-items:flex-end}#fbjs .sm\\:fb-p-6{padding:1.5rem}#fbjs .sm\\:fb-text-sm{font-size:.875rem;line-height:1.25rem}}',document.head.appendChild(e)}}();var r=De&&De.get().environmentId===e.environmentId&&De.get().apiHost===e.apiHost?De.get().session&&Le(De.get().session)?Promise.resolve(Fe()).then(function(e){var t=e.settings;De.update({session:qe(e.session),settings:t}),Se("New Session")}):De.get().session?void 0:(We.error("Unable to initialize. No session found"),void(t=1)):(De.update({environmentId:e.environmentId,apiHost:e.apiHost}),Promise.resolve(Ne()).then(function(e){var t=e.settings;De.update({person:e.person,session:qe(e.session),settings:t}),Se("New Session")}));Promise.resolve(r&&r.then?r.then(n):n(r))}catch(e){return Promise.reject(e)}}(e),Promise.resolve()}catch(e){return Promise.reject(e)}})},setUserId:function(e){Be.add(function(){try{return Je(),Promise.resolve(function(e){try{return Ee.debug("setting userId: "+e),Te("userId",e)?(Ee.debug("userId already set to this value. Skipping update."),Promise.resolve()):(t=Ce.get().person.attributes.find(function(e){var t;return"userId"===(null==(t=e.attributeClass)?void 0:t.name)}),t?(Ee.error("userId cannot be changed after it has been set. You need to reset first"),Promise.resolve()):Promise.resolve(function(e){try{return Ce.get().person&&Ce.get().person.id?Promise.resolve(fetch(Ce.get().apiHost+"/api/v1/client/environments/"+Ce.get().environmentId+"/people/"+Ce.get().person.id+"/user-id",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,sessionId:Ce.get().session.id})})).then(function(e){if(!e.ok)throw Ee.error("Formbricks: Error updating person"),Error("Error updating person");return Promise.resolve(e.json())}):(console.error("Formbricks: Unable to update userId. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e)).then(function(e){Ce.update({person:e.person,settings:e.settings})}))}catch(e){return Promise.reject(e)}var t}(e)).then(function(){})}catch(e){return Promise.reject(e)}})},setEmail:function(e){Re("email",e)},setAttribute:Re,track:function(e,t){void 0===t&&(t={}),Be.add(function(){try{return Je(),Promise.resolve(Se(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},logout:function(){Be.add(function(){try{return Je(),Promise.resolve(function(){try{return Ee.debug("Resetting person. Getting new person, session and settings from backend"),Promise.resolve(Ne()).then(function(e){var t=e.person,n=e.session,r=e.settings;if(!t||!n||!r)throw Ee.error("Error resetting user"),new Error("Formbricks: Error resetting user");Ce.update({person:t,session:n,settings:r})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},refresh:function(){Be.add(function(){try{return Je(),Promise.resolve(function(){try{return pe.debug("Refreshing - getting settings from backend"),Promise.resolve(ge()).then(function(e){he.update({settings:e})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},registerRouteChange:function(){Be.add(function(){try{return Je(),Ue(),Promise.resolve()}catch(e){return Promise.reject(e)}})}};return Qe});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).js=t()}(this,function(){function e(n,r,o){if(!n.s){if(o instanceof t){if(!o.s)return void(o.o=e.bind(null,n,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(e.bind(null,n,r),e.bind(null,n,2));n.s=r,n.v=o;var i=n.o;i&&i(n)}}var t=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(n,r){var o=new t,i=this.s;if(i){var s=1&i?n:r;if(s){try{e(o,1,s(this.v))}catch(t){e(o,2,t)}return o}return this}return this.o=function(t){try{var i=t.v;1&t.s?e(o,1,n?n(i):i):r?e(o,1,r(i)):e(o,2,i)}catch(t){e(o,2,t)}},o},t}();function n(e){return e instanceof t&&1&e.s}var r=/*#__PURE__*/function(){function r(){this.queue=[],this.running=!1}var o=r.prototype;return o.add=function(e){this.queue.push(e),this.running||this.run()},o.run=function(){try{var r=function(){o.running=!1},o=this;o.running=!0;var i=function(r,o,i){for(var s;;){var a=r();if(n(a)&&(a=a.v),!a)return f;if(a.then){s=0;break}var f=i();if(f&&f.then){if(!n(f)){s=1;break}f=f.s}}var l=new t,u=e.bind(null,l,2);return(0===s?a.then(d):1===s?f.then(c):(void 0).then(function(){(a=r())?a.then?a.then(d).then(void 0,u):d(a):e(l,1,f)})).then(void 0,u),l;function c(t){f=t;do{if(!(a=r())||n(a)&&!a.v)return void e(l,1,f);if(a.then)return void a.then(d).then(void 0,u);n(f=i())&&(f=f.v)}while(!f||!f.then);f.then(c).then(void 0,u)}function d(t){t?(f=i())&&f.then?f.then(c).then(void 0,u):c(f):e(l,1,f)}}(function(){return o.queue.length>0},0,function(){var e=o.queue.shift(),t=function(t,n){try{var r=Promise.resolve(e()).then(function(){})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){console.error(e)});if(t&&t.then)return t.then(function(){})});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},r}();function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,f,l,u,c,d,b,p={},_=[],h=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function g(e,t){for(var n in t)e[n]=t[n];return e}function v(e){var t=e.parentNode;t&&t.removeChild(e)}function m(e,t,n){var r,o,i,s={};for(i in t)"key"==i?r=t[i]:"ref"==i?o=t[i]:s[i]=t[i];if(arguments.length>2&&(s.children=arguments.length>3?a.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===s[i]&&(s[i]=e.defaultProps[i]);return w(e,s,r,o,null)}function w(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++l:o};return null==o&&null!=f.vnode&&f.vnode(i),i}function y(e){return e.children}function j(e,t){this.props=e,this.context=t}function x(e,t){if(null==t)return e.__?x(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?x(e):null}function k(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return k(e)}}function P(e){(!e.__d&&(e.__d=!0)&&u.push(e)&&!S.__r++||c!==f.debounceRendering)&&((c=f.debounceRendering)||d)(S)}function S(){var e,t,n,r,o,i,s,a;for(u.sort(b);e=u.shift();)e.__d&&(t=u.length,r=void 0,o=void 0,s=(i=(n=e).__v).__e,(a=n.__P)&&(r=[],(o=g({},i)).__v=i.__v+1,L(a,i,o,n.__n,void 0!==a.ownerSVGElement,null!=i.__h?[s]:null,r,null==s?x(i):s,i.__h),q(r,i),i.__e!=s&&k(i)),u.length>t&&u.sort(b));S.__r=0}function C(e,t,n,r,o,i,s,a,f,l){var u,c,d,b,h,g,v,m=r&&r.__k||_,j=m.length;for(n.__k=[],u=0;u<t.length;u++)if(null!=(b=n.__k[u]=null==(b=t[u])||"boolean"==typeof b||"function"==typeof b?null:"string"==typeof b||"number"==typeof b||"bigint"==typeof b?w(null,b,null,null,b):Array.isArray(b)?w(y,{children:b},null,null,null):b.__b>0?w(b.type,b.props,b.key,b.ref?b.ref:null,b.__v):b)){if(b.__=n,b.__b=n.__b+1,null===(d=m[u])||d&&b.key==d.key&&b.type===d.type)m[u]=void 0;else for(c=0;c<j;c++){if((d=m[c])&&b.key==d.key&&b.type===d.type){m[c]=void 0;break}d=null}L(e,b,d=d||p,o,i,s,a,f,l),h=b.__e,(c=b.ref)&&d.ref!=c&&(v||(v=[]),d.ref&&v.push(d.ref,null,b),v.push(c,b.__c||h,b)),null!=h?(null==g&&(g=h),"function"==typeof b.type&&b.__k===d.__k?b.__d=f=I(b,f,e):f=E(e,b,d,m,h,f),"function"==typeof n.type&&(n.__d=f)):f&&d.__e==f&&f.parentNode!=e&&(f=x(d))}for(n.__e=g,u=j;u--;)null!=m[u]&&("function"==typeof n.type&&null!=m[u].__e&&m[u].__e==n.__d&&(n.__d=N(r).nextSibling),A(m[u],m[u]));if(v)for(u=0;u<v.length;u++)U(v[u],v[++u],v[++u])}function I(e,t,n){for(var r,o=e.__k,i=0;o&&i<o.length;i++)(r=o[i])&&(r.__=e,t="function"==typeof r.type?I(r,t,n):E(n,r,r,o,r.__e,t));return t}function E(e,t,n,r,o,i){var s,a,f;if(void 0!==t.__d)s=t.__d,t.__d=void 0;else if(null==n||o!=i||null==o.parentNode)e:if(null==i||i.parentNode!==e)e.appendChild(o),s=null;else{for(a=i,f=0;(a=a.nextSibling)&&f<r.length;f+=1)if(a==o)break e;e.insertBefore(o,i),s=i}return void 0!==s?s:o.nextSibling}function N(e){var t,n,r;if(null==e.type||"string"==typeof e.type)return e.__e;if(e.__k)for(t=e.__k.length-1;t>=0;t--)if((n=e.__k[t])&&(r=N(n)))return r;return null}function H(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||h.test(t)?n:n+"px"}function T(e,t,n,r,o){var i;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||H(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||H(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])i=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r||e.addEventListener(t,i?F:z,i):e.removeEventListener(t,i?F:z,i);else if("dangerouslySetInnerHTML"!==t){if(o)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function z(e){return this.l[e.type+!1](f.event?f.event(e):e)}function F(e){return this.l[e.type+!0](f.event?f.event(e):e)}function L(e,t,n,r,o,i,s,a,l){var u,c,d,b,p,_,h,v,m,w,x,k,P,S,I,E=t.type;if(void 0!==t.constructor)return null;null!=n.__h&&(l=n.__h,a=t.__e=n.__e,t.__h=null,i=[a]),(u=f.__b)&&u(t);try{e:if("function"==typeof E){if(v=t.props,m=(u=E.contextType)&&r[u.__c],w=u?m?m.props.value:u.__:r,n.__c?h=(c=t.__c=n.__c).__=c.__E:("prototype"in E&&E.prototype.render?t.__c=c=new E(v,w):(t.__c=c=new j(v,w),c.constructor=E,c.render=M),m&&m.sub(c),c.props=v,c.state||(c.state={}),c.context=w,c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),null==c.__s&&(c.__s=c.state),null!=E.getDerivedStateFromProps&&(c.__s==c.state&&(c.__s=g({},c.__s)),g(c.__s,E.getDerivedStateFromProps(v,c.__s))),b=c.props,p=c.state,c.__v=t,d)null==E.getDerivedStateFromProps&&null!=c.componentWillMount&&c.componentWillMount(),null!=c.componentDidMount&&c.__h.push(c.componentDidMount);else{if(null==E.getDerivedStateFromProps&&v!==b&&null!=c.componentWillReceiveProps&&c.componentWillReceiveProps(v,w),!c.__e&&null!=c.shouldComponentUpdate&&!1===c.shouldComponentUpdate(v,c.__s,w)||t.__v===n.__v){for(t.__v!==n.__v&&(c.props=v,c.state=c.__s,c.__d=!1),c.__e=!1,t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(e){e&&(e.__=t)}),x=0;x<c._sb.length;x++)c.__h.push(c._sb[x]);c._sb=[],c.__h.length&&s.push(c);break e}null!=c.componentWillUpdate&&c.componentWillUpdate(v,c.__s,w),null!=c.componentDidUpdate&&c.__h.push(function(){c.componentDidUpdate(b,p,_)})}if(c.context=w,c.props=v,c.__P=e,k=f.__r,P=0,"prototype"in E&&E.prototype.render){for(c.state=c.__s,c.__d=!1,k&&k(t),u=c.render(c.props,c.state,c.context),S=0;S<c._sb.length;S++)c.__h.push(c._sb[S]);c._sb=[]}else do{c.__d=!1,k&&k(t),u=c.render(c.props,c.state,c.context),c.state=c.__s}while(c.__d&&++P<25);c.state=c.__s,null!=c.getChildContext&&(r=g(g({},r),c.getChildContext())),d||null==c.getSnapshotBeforeUpdate||(_=c.getSnapshotBeforeUpdate(b,p)),I=null!=u&&u.type===y&&null==u.key?u.props.children:u,C(e,Array.isArray(I)?I:[I],t,n,r,o,i,s,a,l),c.base=t.__e,t.__h=null,c.__h.length&&s.push(c),h&&(c.__E=c.__=null),c.__e=!1}else null==i&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=O(n.__e,t,n,r,o,i,s,l);(u=f.diffed)&&u(t)}catch(e){t.__v=null,(l||null!=i)&&(t.__e=a,t.__h=!!l,i[i.indexOf(a)]=null),f.__e(e,t,n)}}function q(e,t){f.__c&&f.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){f.__e(e,t.__v)}})}function O(e,t,n,r,o,i,s,f){var l,u,c,d=n.props,b=t.props,_=t.type,h=0;if("svg"===_&&(o=!0),null!=i)for(;h<i.length;h++)if((l=i[h])&&"setAttribute"in l==!!_&&(_?l.localName===_:3===l.nodeType)){e=l,i[h]=null;break}if(null==e){if(null===_)return document.createTextNode(b);e=o?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,b.is&&b),i=null,f=!1}if(null===_)d===b||f&&e.data===b||(e.data=b);else{if(i=i&&a.call(e.childNodes),u=(d=n.props||p).dangerouslySetInnerHTML,c=b.dangerouslySetInnerHTML,!f){if(null!=i)for(d={},h=0;h<e.attributes.length;h++)d[e.attributes[h].name]=e.attributes[h].value;(c||u)&&(c&&(u&&c.__html==u.__html||c.__html===e.innerHTML)||(e.innerHTML=c&&c.__html||""))}if(function(e,t,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in t||T(e,i,null,n[i],r);for(i in t)o&&"function"!=typeof t[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===t[i]||T(e,i,t[i],n[i],r)}(e,b,d,o,f),c)t.__k=[];else if(h=t.props.children,C(e,Array.isArray(h)?h:[h],t,n,r,o&&"foreignObject"!==_,i,s,i?i[0]:n.__k&&x(n,0),f),null!=i)for(h=i.length;h--;)null!=i[h]&&v(i[h]);f||("value"in b&&void 0!==(h=b.value)&&(h!==e.value||"progress"===_&&!h||"option"===_&&h!==d.value)&&T(e,"value",h,d.value,!1),"checked"in b&&void 0!==(h=b.checked)&&h!==e.checked&&T(e,"checked",h,d.checked,!1))}return e}function U(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){f.__e(e,n)}}function A(e,t,n){var r,o;if(f.unmount&&f.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||U(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){f.__e(e,t)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&A(r[o],t,n||"function"!=typeof e.type);n||null==e.__e||v(e.__e),e.__=e.__e=e.__d=void 0}function M(e,t,n){return this.constructor(e,n)}a=_.slice,f={__e:function(e,t,n,r){for(var o,i,s;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&null!=i.getDerivedStateFromError&&(o.setState(i.getDerivedStateFromError(e)),s=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,r||{}),s=o.__d),s)return o.__E=o}catch(t){e=t}throw e}},l=0,j.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=g({},this.state),"function"==typeof e&&(e=e(g({},n),this.props)),e&&g(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),P(this))},j.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),P(this))},j.prototype.render=y,u=[],d="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,b=function(e,t){return e.__v.__b-t.__v.__b},S.__r=0;var D,W,J,B,R=0,V=[],Y=[],Q=f.__b,X=f.__r,$=f.diffed,G=f.__c,K=f.unmount;function Z(e,t){f.__h&&f.__h(W,e,R||t),R=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:Y}),n.__[e]}function ee(e){return R=1,function(e,t,n){var r=Z(D++,2);if(r.t=e,!r.__c&&(r.__=[ae(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.u)){var o=function(e,t,n){if(!r.__c.__H)return!0;var o=r.__c.__H.__.filter(function(e){return e.__c});if(o.every(function(e){return!e.__N}))return!i||i.call(this,e,t,n);var s=!1;return o.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}}),!(!s&&r.__c.props===e)&&(!i||i.call(this,e,t,n))};W.u=!0;var i=W.shouldComponentUpdate,s=W.componentWillUpdate;W.componentWillUpdate=function(e,t,n){if(this.__e){var r=i;i=void 0,o(e,t,n),i=r}s&&s.call(this,e,t,n)},W.shouldComponentUpdate=o}return r.__N||r.__}(ae,e)}function te(e,t){var n=Z(D++,3);!f.__s&&function(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}(n.__H,t)&&(n.__=e,n.i=t,W.__H.__h.push(n))}function ne(){for(var e;e=V.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ie),e.__H.__h.forEach(se),e.__H.__h=[]}catch(t){e.__H.__h=[],f.__e(t,e.__v)}}f.__b=function(e){W=null,Q&&Q(e)},f.__r=function(e){X&&X(e),D=0;var t=(W=e.__c).__H;t&&(J===W?(t.__h=[],W.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.__V=Y,e.__N=e.i=void 0})):(t.__h.forEach(ie),t.__h.forEach(se),t.__h=[])),J=W},f.diffed=function(e){$&&$(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==V.push(t)&&B===f.requestAnimationFrame||((B=f.requestAnimationFrame)||oe)(ne)),t.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.__V!==Y&&(e.__=e.__V),e.i=void 0,e.__V=Y})),J=W=null},f.__c=function(e,t){t.some(function(e){try{e.__h.forEach(ie),e.__h=e.__h.filter(function(e){return!e.__||se(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],f.__e(n,e.__v)}}),G&&G(e,t)},f.unmount=function(e){K&&K(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{ie(e)}catch(e){t=e}}),n.__H=void 0,t&&f.__e(t,n.__v))};var re="function"==typeof requestAnimationFrame;function oe(e){var t,n=function(){clearTimeout(r),re&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);re&&(t=requestAnimationFrame(n))}function ie(e){var t=W,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),W=t}function se(e){var t=W;e.__c=e.__(),W=t}function ae(e,t){return"function"==typeof t?t(e):t}var fe=function(){return[].slice.call(arguments).filter(Boolean).join(" ")};function le(e){var t=e.children,n=e.isOpen,r=e.close,o=ee(!1),i=o[0],s=o[1];return te(function(){s(n)},[n]),m("div",{"aria-live":"assertive",className:"fb-pointer-events-none fb-fixed fb-inset-0 fb-flex fb-items-end fb-px-4 fb-py-6 sm:fb-p-6"},m("div",{className:"fb-flex fb-w-full fb-flex-col fb-items-center fb-space-y-4 sm:fb-items-end"},m("div",{className:fe(i?"fb-translate-x-0 fb-opacity-100":"fb-translate-x-28 fb-opacity-0","fb-pointer-events-auto fb-relative fb-w-full fb-max-w-sm fb-overflow-hidden fb-rounded-lg fb-bg-white fb-shadow-lg fb-ring-1 fb-ring-black fb-ring-opacity-5 fb-transition-all fb-duration-500 fb-ease-in-out")},m("div",{class:"fb-absolute fb-top-0 fb-right-0 fb-hidden fb-pt-4 fb-pr-4 sm:fb-block"},m("button",{type:"button",onClick:r,class:"fb-rounded-md fb-bg-white focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 fb-text-slate-400 hover:fb-text-slate-500 focus:ring-slate-500"},m("span",{class:"fb-sr-only"},"Close"),m("svg",{class:"fb-h-6 fb-w-6",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true"},m("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})))),m("div",{className:""},t))))}var ue=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays/"+e+"/responded",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){if(!e.ok)throw new Error("Could not update display")})}catch(e){return Promise.reject(e)}},ce=function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/responses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function de(e){return m("label",{htmlFor:e.questionId,className:"fb-block fb-text-base fb-font-semibold fb-leading-6 fb-mr-8 text-slate-900"},e.headline)}function be(e){return m("label",{for:e.questionId,className:"fb-block fb-text-sm fb-font-normal fb-leading-6 text-slate-600"},e.subheader)}function pe(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor;return m("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},m(de,{headline:t.headline,questionId:t.id}),m(be,{subheader:t.subheader,questionId:t.id}),m("div",{className:"fb-mt-4"},m("textarea",{rows:3,name:t.id,id:t.id,placeholder:t.placeholder,required:t.required,className:"fb-block fb-w-full fb-rounded-md fb-border fb-p-2 fb-shadow-sm focus:fb-ring-0 sm:fb-text-sm fb-bg-slate-50 fb-border-slate-100 focus:fb-border-slate-500"})),m("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},m("div",null),m("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:fb-ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function _e(e){var t=e.question,n=e.onSubmit,r=e.lastQuestion,o=e.brandColor,i=ee(null),s=i[0],a=i[1];return m("form",{onSubmit:function(e){var r;e.preventDefault();var o=((r={})[t.id]=e.currentTarget[t.id].value,r);e.currentTarget[t.id].value="",n(o)}},m(de,{headline:t.headline,questionId:t.id}),m(be,{subheader:t.subheader,questionId:t.id}),m("div",{className:"fb-mt-4"},m("fieldset",null,m("legend",{className:"fb-sr-only"},"Choices"),m("div",{className:"fb-relative fb-space-y-2 fb-rounded-md fb-bg-white"},t.choices&&t.choices.map(function(e){return m("label",{key:e.id,className:fe(s===e.label?"fb-z-10 fb-bg-slate-50 fb-border-slate-400":"fb-border-gray-200","fb-relative fb-flex fb-cursor-pointer fb-flex-col fb-rounded-md fb-border fb-p-4 focus:fb-outline-none hover:bg-slate-50")},m("span",{className:"fb-flex fb-items-center fb-text-sm"},m("input",{type:"radio",id:e.id,name:t.id,value:e.label,className:"fb-h-4 fb-w-4 fb-border fb-border-slate-300 focus:fb-ring-0 focus:fb-ring-offset-0","aria-labelledby":e.id+"-label",onChange:function(e){a(e.currentTarget.value)},style:{borderColor:o,color:o}}),m("span",{id:e.id+"-label",className:"fb-ml-3 fb-font-medium"},e.label)))})))),m("div",{className:"fb-mt-4 fb-flex fb-w-full fb-justify-between"},m("div",null),m("button",{type:"submit",className:"fb-flex fb-items-center fb-rounded-md fb-border fb-border-transparent fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 fb-text-white fb-shadow-sm hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2 focus:ring-slate-500",style:{backgroundColor:o}},t.buttonLabel||(r?"Finish":"Next"))))}function he(e){return m("div",{className:"fb-h-1 fb-w-full fb-rounded-full bg-slate-200"},m("div",{className:"fb-h-1 fb-rounded-full",style:{backgroundColor:e.brandColor,width:Math.floor(100*e.progress)+"%"}}))}function ge(e){var t=e.config,n=e.survey,r=e.close,o=e.brandColor,i=ee(n.questions[0]),s=i[0],a=i[1],f=ee(0),l=f[0],u=f[1],c=ee(null),d=c[0],b=c[1],p=ee(null),_=p[0],h=p[1],g=ee(!1),v=g[0],w=g[1];te(function(){!function(){try{Promise.resolve(function(e,t){try{return Promise.resolve(fetch(t.apiHost+"/api/v1/client/environments/"+t.environmentId+"/displays",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw console.error(e.text),new Error("Could not create display");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}({surveyId:n.id,personId:t.person.id},t)).then(function(e){h(e.id)})}catch(e){return Promise.reject(e)}}()},[t,n]),te(function(){var e;u((e=n.questions.findIndex(function(e){return e.id===s.id}),e/n.questions.length))},[s,n]);var y=function(e){try{var o=function(){w(!1),f?(u(100),r()):a(n.questions[i+1])};w(!0);var i=n.questions.findIndex(function(e){return e.id===s.id}),f=i===n.questions.length-1,l={surveyId:n.id,personId:t.person.id,response:{finished:f,data:e}},c=d?Promise.resolve(function(e,t,n){try{return Promise.resolve(fetch(n.apiHost+"/api/v1/client/environments/"+n.environmentId+"/responses/"+t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).then(function(e){if(!e.ok)throw new Error("Could not update response");return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}}(l,d,t)).then(function(){}):Promise.resolve(Promise.all([ce(l,t),ue(_,t)])).then(function(e){b(e[0].id)});return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}};return m("div",null,m("div",{className:fe(v?"fb-animate-pulse fb-opacity-60":"","fb-p-4 fb-text-slate-800 fb-font-sans")},"multipleChoiceSingle"===s.type?m(_e,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):"openText"===s.type?m(pe,{question:s,onSubmit:y,lastQuestion:n.questions.findIndex(function(e){return e.id===s.id})===n.questions.length-1,brandColor:o}):null),m("div",{className:"fb-mt-2"},m(he,{progress:l,brandColor:o})))}function ve(e){var t,n=e.config,r=e.survey,o=e.closeSurvey,i=ee(!0),s=i[1],a=function(){s(!1),setTimeout(function(){o()},1e3)};return m("div",{id:"fbjs"},m(le,{isOpen:i[0],close:a},m(ge,{config:n,survey:r,close:a,brandColor:null==(t=n.settings)?void 0:t.brandColor})))}var me=/*#__PURE__*/function(){function e(){this.config=this.loadFromLocalStorage()}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.update=function(e){e&&(this.config=o({},this.config,e),this.saveToLocalStorage())},t.get=function(){return this.config},t.loadFromLocalStorage=function(){if("undefined"!=typeof window){var e=localStorage.getItem("config");if(e)return JSON.parse(e)}return{apiHost:null,environmentId:null}},t.saveToLocalStorage=function(){localStorage.setItem("config",JSON.stringify(this.config))},e}();me.instance=void 0;var we=/*#__PURE__*/function(){function e(){this.logLevel="error"}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.configure=function(e){e&&void 0!==e.logLevel&&(this.logLevel=e.logLevel)},t.logger=function(e,t){if("debug"!==t||"debug"===this.logLevel){var n="🧱 Formbricks - "+(new Date).toISOString()+" ["+t.toUpperCase()+"] - "+e;"error"===t?console.error(n):console.log(n)}},t.debug=function(e){this.logger(e,"debug")},t.error=function(e){this.logger(e,"error")},e}();we.instance=void 0;var ye=we.getInstance(),je=me.getInstance(),xe=function(){try{return Promise.resolve(fetch(je.get().apiHost+"/api/v1/client/environments/"+je.get().environmentId+"/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:je.get().person.id})})).then(function(e){if(!e.ok)throw ye.error("Error getting settings"),Error("Error getting settings");return e.json()})}catch(e){return Promise.reject(e)}},ke="formbricks-web-container",Pe=me.getInstance(),Se=we.getInstance(),Ce=!1,Ie=function(e){Ce?Se.debug("A survey is already running. Skipping."):(Ce=!0,function(e,t,n){var r,o;f.__&&f.__(e,t),r=t.__k,o=[],L(t,e=t.__k=m(y,null,[e]),r||p,p,void 0!==t.ownerSVGElement,r?null:t.firstChild?a.call(t.childNodes):null,o,r?r.__e:t.firstChild,!1),q(o,e)}(m(ve,{config:Pe.get(),survey:e,closeSurvey:Ee}),document.getElementById(ke)))},Ee=function(){try{return document.getElementById(ke).remove(),Ne(),Promise.resolve(xe()).then(function(e){Pe.update({settings:e}),Ce=!1})}catch(e){return Promise.reject(e)}},Ne=function(){var e=document.createElement("div");e.id=ke,document.body.appendChild(e)},He=we.getInstance(),Te=me.getInstance(),ze=function(e,t){try{return Promise.resolve(fetch(Te.get().apiHost+"/api/v1/client/environments/"+Te.get().environmentId+"/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Te.get().session.id,eventName:e,properties:t})})).then(function(t){var n;function r(t){if(n)return t;He.debug('Formbricks: Event "'+e+'" tracked'),Fe(e)}var o=function(){if(!t.ok)return Promise.resolve(t.json()).then(function(e){He.error("Formbricks: Error tracking event: "+JSON.stringify(e)),n=1})}();return o&&o.then?o.then(r):r(o)})}catch(e){return Promise.reject(e)}},Fe=function(e){for(var t,n=s(null==(r=Te.get().settings)?void 0:r.surveys);!(t=n()).done;)for(var r,o,i=t.value,a=s(i.triggers);!(o=a()).done;){var f;if((null==(f=o.value.eventClass)?void 0:f.name)===e)return He.debug("Formbricks: survey "+i.id+' triggered by event "'+e+'"'),void Ie(i)}},Le=me.getInstance(),qe=we.getInstance(),Oe=function(){try{return qe.debug("Creating new person"),Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people",{method:"POST",headers:{"Content-Type":"application/json"}})).then(function(e){return e.ok?Promise.resolve(e.json()):(console.error("Formbricks: Error fetching person"),null)})}catch(e){return Promise.reject(e)}},Ue=function(e,t){var n=Le.get().person.attributes.find(function(t){var n;return(null==(n=t.attributeClass)?void 0:n.name)===e});return!(!n||n.value!==t)},Ae=we.getInstance(),Me=me.getInstance(),De=function(){try{return Me.get().person?Promise.resolve(fetch(Me.get().apiHost+"/api/v1/client/environments/"+Me.get().environmentId+"/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personId:Me.get().person.id})})).then(function(e){if(e.ok)return Promise.resolve(e.json());Ae.error("Error creating session")}):(Ae.error("Formbricks: Unable to create session. No person found"),Promise.resolve())}catch(e){return Promise.reject(e)}},We=function(e){Ae.debug("Session expired. Creating new session.");var t=o({},e);return t.expiresAt=Date.now()+36e5,t},Je=function(e){return e.expiresAt<=Date.now()},Be=me.getInstance(),Re=we.getInstance(),Ve=function(){var e=Be.get().settings,t=null==e?void 0:e.noCodeEvents.filter(function(e){var t;return"pageUrl"===(null==(t=e.noCodeConfig)?void 0:t.type)});if(Re.debug("checking page url"),0!==t.length)for(var n,r=s(t);!(n=r()).done;){var o=n.value,i=o.noCodeConfig.pageUrl;i&&Ye(window.location.href,i.value,i.rule)&&ze(o.name)}};function Ye(e,t,n){switch(n){case"exactMatch":return e===t;case"contains":return e.includes(t);case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"notMatch":return e!==t;case"notContains":return!e.includes(t);default:throw new Error("Invalid match type")}}var Qe=function(e){var t=Be.get().settings,n=null==t?void 0:t.noCodeEvents.filter(function(e){var t;return"innerHtml"===(null==(t=e.noCodeConfig)?void 0:t.type)}),r=null==t?void 0:t.noCodeEvents.filter(function(e){var t;return"cssSelector"===(null==(t=e.noCodeConfig)?void 0:t.type)}),o=e.target;n.forEach(function(e){var t,n=null==(t=e.noCodeConfig)?void 0:t.innerHtml;n&&o.innerHTML===n.value&&ze(e.name)}),r.forEach(function(e){var t,n=null==(t=e.noCodeConfig)?void 0:t.cssSelector;n&&o.matches(n.value)&&ze(e.name)})},Xe=me.getInstance(),$e=we.getInstance(),Ge=function(){if(!(Xe.get().apiHost&&Xe.get().environmentId&&Xe.get().person&&Xe.get().session&&Xe.get().settings))throw Error("Formbricks: Formbricks not initialized. Call initialize() first.")},Ke=new r,Ze=function(e,t){Ke.add(function(){try{return Ge(),Promise.resolve(function(e,t){try{return qe.debug("setting attribute: "+e+" to value: "+t),Ue(e,t)?(qe.debug("attribute already set to this value. Skipping update."),Promise.resolve()):Promise.resolve(function(e,t){try{return Le.get().person&&Le.get().person.id?Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people/"+Le.get().person.id+"/attribute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,value:t})})).then(function(e){return Promise.resolve(e.json()).then(function(t){if(!e.ok)throw qe.error("Error updating person"),Error("Error updating person");return t})}):(console.error("Formbricks: Unable to update attribute. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e,t)).then(function(e){var t=e.person,n=e.settings;if(!t||!n)throw qe.error("Error updating attribute"),new Error("Formbricks: Error updating attribute");Le.update({person:t,settings:n})})}catch(e){return Promise.reject(e)}}(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},et={init:function(e){Ke.add(function(){try{return function(e){try{var t,n=function(e){if(t)return e;(function(){if("undefined"!=typeof window){var e=window.setInterval(function(){try{return Promise.resolve(function(){try{var e=function(e){Ae.debug("Session not expired, extending session"),Me.update({session:We(Me.get().session)})};Ae.debug("Checking session");var t=function(){if(Je(Me.get().session))return Ae.debug("Session expired, creating new session"),Promise.resolve(De()).then(function(e){var t=e.session,n=e.settings;if(!t||!n)throw Ae.error("Error creating new session"),Error("Error creating new session");Me.update({session:t,settings:n}),ze("New Session")})}();return Promise.resolve(t&&t.then?t.then(e):e())}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}},3e5);window.addEventListener("beforeunload",function(){clearInterval(e)})}})(),"undefined"!=typeof window&&(window.addEventListener("hashchange",Ve),window.addEventListener("popstate",Ve),window.addEventListener("pushstate",Ve),window.addEventListener("replacestate",Ve),window.addEventListener("load",Ve)),"undefined"!=typeof window&&document.addEventListener("click",Qe),$e.debug("Initialized")};if(!e.environmentId)throw Error("Formbricks: environmentId is required");if(!e.apiHost)throw Error("Formbricks: apiHost is required");e.logLevel&&$e.configure({logLevel:e.logLevel}),Ne(),function(){if(null===document.getElementById("formbricks__css")){var e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :after,#fbjs :before{border:0 solid #e5e7eb;box-sizing:border-box}#fbjs :after,#fbjs :before{--tw-content:""}#fbjs html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#fbjs body{line-height:inherit;margin:0}#fbjs hr{border-top-width:1px;color:inherit;height:0}#fbjs abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6{font-size:inherit;font-weight:inherit}#fbjs a{color:inherit;text-decoration:inherit}#fbjs b,#fbjs strong{font-weight:bolder}#fbjs code,#fbjs kbd,#fbjs pre,#fbjs samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}#fbjs small{font-size:80%}#fbjs sub,#fbjs sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}#fbjs sub{bottom:-.25em}#fbjs sup{top:-.5em}#fbjs table{border-collapse:collapse;border-color:inherit;text-indent:0}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit],#fbjs button{-webkit-appearance:button;background-color:transparent;background-image:none}#fbjs :-moz-focusring{outline:auto}#fbjs :-moz-ui-invalid{box-shadow:none}#fbjs progress{vertical-align:baseline}#fbjs ::-webkit-inner-spin-button,#fbjs ::-webkit-outer-spin-button{height:auto}#fbjs [type=search]{-webkit-appearance:textfield;outline-offset:-2px}#fbjs ::-webkit-search-decoration{-webkit-appearance:none}#fbjs ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}#fbjs summary{display:list-item}#fbjs blockquote,#fbjs dd,#fbjs dl,#fbjs figure,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs menu,#fbjs ol,#fbjs ul{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{color:#9ca3af;opacity:1}#fbjs input::placeholder,#fbjs textarea::placeholder{color:#9ca3af;opacity:1}#fbjs [role=button],#fbjs button{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs audio,#fbjs canvas,#fbjs embed,#fbjs iframe,#fbjs img,#fbjs object,#fbjs svg,#fbjs video{display:block;vertical-align:middle}#fbjs img,#fbjs video{height:auto;max-width:100%}#fbjs [hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#fbjs :is(.fb-sr-only){clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}#fbjs :is(.fb-pointer-events-none){pointer-events:none}#fbjs :is(.fb-pointer-events-auto){pointer-events:auto}#fbjs :is(.fb-fixed){position:fixed}#fbjs :is(.fb-absolute){position:absolute}#fbjs :is(.fb-relative){position:relative}#fbjs :is(.fb-inset-0){inset:0}#fbjs :is(.fb-right-0){right:0}#fbjs :is(.fb-top-0){top:0}#fbjs :is(.fb-z-10){z-index:10}#fbjs :is(.fb-ml-3){margin-left:.75rem}#fbjs :is(.fb-mr-8){margin-right:2rem}#fbjs :is(.fb-mt-2){margin-top:.5rem}#fbjs :is(.fb-mt-4){margin-top:1rem}#fbjs :is(.fb-block){display:block}#fbjs :is(.fb-flex){display:flex}#fbjs :is(.fb-hidden){display:none}#fbjs :is(.fb-h-1){height:.25rem}#fbjs :is(.fb-h-4){height:1rem}#fbjs :is(.fb-h-6){height:1.5rem}#fbjs :is(.fb-w-4){width:1rem}#fbjs :is(.fb-w-6){width:1.5rem}#fbjs :is(.fb-w-full){width:100%}#fbjs :is(.fb-max-w-sm){max-width:24rem}#fbjs :is(.fb-translate-x-0){--tw-translate-x:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.fb-translate-x-28){--tw-translate-x:7rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes fb-pulse{50%{opacity:.5}}#fbjs :is(.fb-animate-pulse){animation:fb-pulse 2s cubic-bezier(.4,0,.6,1) infinite}#fbjs :is(.fb-cursor-pointer){cursor:pointer}#fbjs :is(.fb-flex-col){flex-direction:column}#fbjs :is(.fb-items-end){align-items:flex-end}#fbjs :is(.fb-items-center){align-items:center}#fbjs :is(.fb-justify-between){justify-content:space-between}#fbjs :is(.fb-space-y-2>:not([hidden])~:not([hidden])){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}#fbjs :is(.fb-space-y-4>:not([hidden])~:not([hidden])){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}#fbjs :is(.fb-overflow-hidden){overflow:hidden}#fbjs :is(.fb-rounded-full){border-radius:9999px}#fbjs :is(.fb-rounded-lg){border-radius:.5rem}#fbjs :is(.fb-rounded-md){border-radius:.375rem}#fbjs :is(.fb-border){border-width:1px}#fbjs :is(.fb-border-gray-200){--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-100){--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-300){--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}#fbjs :is(.fb-border-slate-400){--tw-border-opacity:1;border-color:rgb(148 163 184/var(--tw-border-opacity))}#fbjs :is(.fb-border-transparent){border-color:transparent}#fbjs :is(.fb-bg-slate-50){--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity))}#fbjs :is(.fb-bg-white){--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}#fbjs :is(.fb-p-2){padding:.5rem}#fbjs :is(.fb-p-4){padding:1rem}#fbjs :is(.fb-px-3){padding-left:.75rem;padding-right:.75rem}#fbjs :is(.fb-px-4){padding-left:1rem;padding-right:1rem}#fbjs :is(.fb-py-3){padding-bottom:.75rem;padding-top:.75rem}#fbjs :is(.fb-py-6){padding-bottom:1.5rem;padding-top:1.5rem}#fbjs :is(.fb-pr-4){padding-right:1rem}#fbjs :is(.fb-pt-4){padding-top:1rem}#fbjs :is(.fb-font-sans){font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}#fbjs :is(.fb-text-base){font-size:1rem;line-height:1.5rem}#fbjs :is(.fb-text-sm){font-size:.875rem;line-height:1.25rem}#fbjs :is(.fb-font-medium){font-weight:500}#fbjs :is(.fb-font-normal){font-weight:400}#fbjs :is(.fb-font-semibold){font-weight:600}#fbjs :is(.fb-leading-4){line-height:1rem}#fbjs :is(.fb-leading-6){line-height:1.5rem}#fbjs :is(.fb-text-slate-400){--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}#fbjs :is(.fb-text-slate-800){--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity))}#fbjs :is(.fb-text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}#fbjs :is(.fb-opacity-0){opacity:0}#fbjs :is(.fb-opacity-100){opacity:1}#fbjs :is(.fb-opacity-60){opacity:.6}#fbjs :is(.fb-shadow-lg){--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs :is(.fb-shadow-sm){--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}#fbjs :is(.fb-ring-1){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.fb-ring-black){--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity))}#fbjs :is(.fb-ring-opacity-5){--tw-ring-opacity:0.05}#fbjs :is(.fb-transition-all){transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs :is(.fb-duration-500){transition-duration:.5s}#fbjs :is(.fb-ease-in-out){transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs :is(.hover\\:fb-text-slate-500:hover){--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}#fbjs :is(.hover\\:fb-opacity-90:hover){opacity:.9}#fbjs :is(.focus\\:fb-border-slate-500:focus){--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity))}#fbjs :is(.focus\\:fb-outline-none:focus){outline:2px solid transparent;outline-offset:2px}#fbjs :is(.focus\\:fb-ring-0:focus){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.focus\\:fb-ring-2:focus){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}#fbjs :is(.focus\\:fb-ring-slate-500:focus){--tw-ring-opacity:1;--tw-ring-color:rgb(100 116 139/var(--tw-ring-opacity))}#fbjs :is(.focus\\:fb-ring-offset-0:focus){--tw-ring-offset-width:0px}#fbjs :is(.focus\\:fb-ring-offset-2:focus){--tw-ring-offset-width:2px}@media (min-width:640px){#fbjs :is(.sm\\:fb-block){display:block}#fbjs :is(.sm\\:fb-items-end){align-items:flex-end}#fbjs :is(.sm\\:fb-p-6){padding:1.5rem}#fbjs :is(.sm\\:fb-text-sm){font-size:.875rem;line-height:1.25rem}}',document.head.appendChild(e)}}();var r=Xe&&Xe.get().environmentId===e.environmentId&&Xe.get().apiHost===e.apiHost?Xe.get().session&&Je(Xe.get().session)?Promise.resolve(De()).then(function(e){var t=e.settings;Xe.update({session:We(e.session),settings:t}),ze("New Session")}):Xe.get().session?void 0:($e.error("Unable to initialize. No session found"),void(t=1)):(Xe.update({environmentId:e.environmentId,apiHost:e.apiHost}),Promise.resolve(Oe()).then(function(e){var t=e.settings;Xe.update({person:e.person,session:We(e.session),settings:t}),ze("New Session")}));Promise.resolve(r&&r.then?r.then(n):n(r))}catch(e){return Promise.reject(e)}}(e),Promise.resolve()}catch(e){return Promise.reject(e)}})},setUserId:function(e){Ke.add(function(){try{return Ge(),Promise.resolve(function(e){try{return qe.debug("setting userId: "+e),Ue("userId",e)?(qe.debug("userId already set to this value. Skipping update."),Promise.resolve()):(t=Le.get().person.attributes.find(function(e){var t;return"userId"===(null==(t=e.attributeClass)?void 0:t.name)}),t?(qe.error("userId cannot be changed after it has been set. You need to reset first"),Promise.resolve()):Promise.resolve(function(e){try{return Le.get().person&&Le.get().person.id?Promise.resolve(fetch(Le.get().apiHost+"/api/v1/client/environments/"+Le.get().environmentId+"/people/"+Le.get().person.id+"/user-id",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,sessionId:Le.get().session.id})})).then(function(e){if(!e.ok)throw qe.error("Formbricks: Error updating person"),Error("Error updating person");return Promise.resolve(e.json())}):(console.error("Formbricks: Unable to update userId. No person set."),Promise.resolve())}catch(e){return Promise.reject(e)}}(e)).then(function(e){Le.update({person:e.person,settings:e.settings})}))}catch(e){return Promise.reject(e)}var t}(e)).then(function(){})}catch(e){return Promise.reject(e)}})},setEmail:function(e){Ze("email",e)},setAttribute:Ze,track:function(e,t){void 0===t&&(t={}),Ke.add(function(){try{return Ge(),Promise.resolve(ze(e,t)).then(function(){})}catch(e){return Promise.reject(e)}})},logout:function(){Ke.add(function(){try{return Ge(),Promise.resolve(function(){try{return qe.debug("Resetting person. Getting new person, session and settings from backend"),Promise.resolve(Oe()).then(function(e){var t=e.person,n=e.session,r=e.settings;if(!t||!n||!r)throw qe.error("Error resetting user"),new Error("Formbricks: Error resetting user");Le.update({person:t,session:n,settings:r})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},refresh:function(){Ke.add(function(){try{return Ge(),Promise.resolve(function(){try{return ye.debug("Refreshing - getting settings from backend"),Promise.resolve(xe()).then(function(e){je.update({settings:e})})}catch(e){return Promise.reject(e)}}()).then(function(){})}catch(e){return Promise.reject(e)}})},registerRouteChange:function(){Ke.add(function(){try{return Ge(),Ve(),Promise.resolve()}catch(e){return Promise.reject(e)}})}};return et});
//# sourceMappingURL=index.umd.js.map

@@ -0,0 +0,0 @@ export declare class CommandQueue {

@@ -0,0 +0,0 @@ import { JsConfig } from "@formbricks/types/js";

import { Response, DisplayCreateRequest } from "@formbricks/types/js";
export declare const createDisplay: (displayCreateRequest: DisplayCreateRequest, config: any) => Promise<Response>;
export declare const markDisplayResponded: (displayId: any, config: any) => Promise<void>;
export declare const trackEvent: (eventName: string, properties?: any) => Promise<void>;
export declare const triggerSurvey: (eventName: string) => void;
import { InitConfig } from "@formbricks/types/js";
export declare const initialize: (c: InitConfig) => Promise<void>;
export declare const checkInitialized: () => void;

@@ -0,0 +0,0 @@ type LogLevel = "debug" | "error";

@@ -5,1 +5,3 @@ import type { MatchType } from "@formbricks/types/js";

export declare function checkUrlMatch(url: string, pageUrlValue: string, pageUrlRule: MatchType): boolean;
export declare const checkClickMatch: (event: MouseEvent) => void;
export declare const addClickEventListener: () => void;

@@ -0,0 +0,0 @@ import type { Person } from "@formbricks/types/js";

import { Response, ResponseCreateRequest, ResponseUpdateRequest } from "@formbricks/types/js";
export declare const createResponse: (responseRequest: ResponseCreateRequest, config: any) => Promise<Response>;
export declare const updateResponse: (responseRequest: ResponseUpdateRequest, responseId: any, config: any) => Promise<Response>;

@@ -0,0 +0,0 @@ import type { Session, Settings } from "@formbricks/types/js";

import type { Settings } from "@formbricks/types/js";
export declare const getSettings: () => Promise<Settings>;
export declare const refreshSettings: () => Promise<void>;
export declare const addStylesToDom: () => void;
export declare const cn: (...classes: any[]) => string;

@@ -0,0 +0,0 @@ import { Survey } from "@formbricks/types/js";

{
"name": "@formbricks/js",
"version": "0.1.5",
"version": "0.1.6",
"description": "",
"source": "src/index.ts",
"main": "./dist/index.cjs",
"main": "./dist/index.js",
"module": "./dist/index.module.js",

@@ -12,3 +12,3 @@ "unpkg": "./dist/index.umd.js",

"types": "./dist/src/index.d.ts",
"require": "./dist/index.cjs",
"require": "./dist/index.js",
"default": "./dist/index.modern.js"

@@ -32,21 +32,21 @@ },

"devDependencies": {
"@types/enzyme": "^3.10.8",
"@types/jest": "^27.0.2",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"autoprefixer": "^10.4.13",
"@types/enzyme": "^3.10.12",
"@types/jest": "^29.5.0",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"autoprefixer": "^10.4.14",
"cross-env": "^7.0.3",
"enzyme": "^3.11.0",
"enzyme-adapter-preact-pure": "^3.3.0",
"eslint": "^7.32.0",
"eslint-config-preact": "^1.1.3",
"jest": "^27.3.1",
"jest-preset-preact": "^4.0.2",
"enzyme-adapter-preact-pure": "^4.1.0",
"eslint": "^8.37.0",
"eslint-config-preact": "^1.3.0",
"jest": "^29.5.0",
"jest-preset-preact": "^4.0.5",
"microbundle": "^0.14.1",
"postcss": "^8.4.21",
"preact": "10.5.7",
"preact-cli": "^3.0.5",
"preact-render-to-string": "^5.1.11",
"tailwindcss": "^3.2.7",
"typescript": "^4.1.3",
"preact": "10.13.2",
"preact-cli": "^3.4.5",
"preact-render-to-string": "^6.0.2",
"tailwindcss": "^3.3.1",
"typescript": "^5.0.3",
"@formbricks/types": "0.0.0",

@@ -53,0 +53,0 @@ "eslint-config-formbricks": "1.0.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc