-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformbricks.js
12 lines (12 loc) · 187 KB
/
formbricks.js
1
2
3
4
5
6
7
8
9
10
11
12
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).formbricks=t()}(this,(function(){"use strict";const e=e=>({ok:!1,error:e});async function t(t,n,r,i){const s=new URL(n,t),o=JSON.stringify(i),a=(l=fetch,(...e)=>{try{return{ok:!0,data:l(...e)}}catch(t){return{ok:!1,error:t}}})(s.toString(),{method:r,headers:{"Content-Type":"application/json"},body:o});var l;if(!1===a.ok)return e(a.error);const d=await a.data,{data:c}=await d.json();return d.ok?(e=>({ok:!0,data:e}))(c):e({code:"network_error",message:d.statusText,status:d.status,url:s})}class n{constructor(e,t){this.apiHost=e,this.environmentId=t}async create(e){return t(this.apiHost,`/api/v1/client/${this.environmentId}/actions`,"POST",e)}}class r{constructor(e,t){this.apiHost=e,this.environmentId=t}async create(e){return t(this.apiHost,`/api/v1/client/${this.environmentId}/displays`,"POST",e)}async update(e,n){return t(this.apiHost,`/api/v1/client/${this.environmentId}/displays/${e}`,"PUT",n)}}class i{constructor(e,t){this.apiHost=e,this.environmentId=t}async create(e){return t(this.apiHost,`/api/v1/client/${this.environmentId}/people`,"POST",{environmentId:this.environmentId,userId:e})}async update(e,n){return t(this.apiHost,`/api/v1/client/${this.environmentId}/people/${e}`,"POST",n)}}class s{constructor(e,t){this.apiHost=e,this.environmentId=t}async create(e){return t(this.apiHost,`/api/v1/client/${this.environmentId}/responses`,"POST",e)}async update({responseId:e,finished:n,data:r,ttc:i}){return t(this.apiHost,`/api/v1/client/${this.environmentId}/responses/${e}`,"PUT",{finished:n,data:r,ttc:i})}}class o{constructor(e,t){this.apiHost=e,this.environmentId=t}async uploadFile(e,{allowedFileExtensions:t,surveyId:n}={}){if(!(e instanceof Blob&&e instanceof File))throw new Error("Invalid file type. Expected Blob or File, but received "+typeof e);const r={fileName:e.name,fileType:e.type,allowedFileExtensions:t,surveyId:n},i=await fetch(`${this.apiHost}/api/v1/client/${this.environmentId}/storage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw new Error(`Upload failed with status: ${i.status}`);const s=await i.json(),{data:o}=s,{signedUrl:a,fileUrl:l,signingData:d,presignedFields:c}=o;let u={};if(d){const{signature:t,timestamp:r,uuid:i}=d;u={"X-File-Type":e.type,"X-File-Name":encodeURIComponent(e.name),"X-Survey-ID":n??"","X-Signature":t,"X-Timestamp":String(r),"X-UUID":i}}const p=new FormData;c&&Object.keys(c).forEach((e=>{p.append(e,c[e])})),p.append("file",e);const h=await fetch(a,{method:"POST",...d?{headers:u}:{},body:p});if(!h.ok){const e=await h.json();throw new Error(`${e.message}`)}return l}}class a{constructor(e){const{apiHost:t,environmentId:a}=e;this.response=new s(t,a),this.display=new r(t,a),this.action=new n(t,a),this.people=new i(t,a),this.storage=new o(t,a)}}class l{constructor(e){this.client=new a(e)}}class d{constructor(){this.logLevel="error"}static getInstance(){return d.instance||(d.instance=new d),d.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")}}const c=e=>({ok:!0,value:e}),u=e=>({ok:!1,error:e});const p=e=>(...t)=>{try{return{ok:!0,value:e(...t)}}catch(n){return{ok:!1,error:n}}},h=d.getInstance(),f=class e{constructor(e){this.customized=!1,e?(this.handleError=e,this.customized=!0):this.handleError=e=>d.getInstance().error(JSON.stringify(e))}static getInstance(){return e.instance||(e.instance=new e),e.instance}static init(t){this.initialized=!0,e.instance=new e(t)}printStatus(){h.debug("Custom error handler: "+(this.customized?"yes":"no"))}handle(e){this.handleError(e)}};f.initialized=!1;let m=f;const b="formbricks-js";class g{constructor(){this.config=null;const e=this.loadFromLocalStorage();e.ok&&(this.config=e.value)}static getInstance(){return g.instance||(g.instance=new g),g.instance}update(e){if(e){const t=new Date((new Date).getTime()+9e5);this.config={...this.config,...e,expiresAt:t},this.saveToLocalStorage()}}get(){if(!this.config)throw new Error("config is null, maybe the init function was not called?");return this.config}loadFromLocalStorage(){if("undefined"!=typeof window){const e=localStorage.getItem(b);if(e){const t=JSON.parse(e);return t.expiresAt&&new Date(t.expiresAt)<=new Date?u(new Error("Config in local storage has expired")):c(JSON.parse(e))}}return u(new Error("No or invalid config in local storage"))}saveToLocalStorage(){return p((()=>localStorage.setItem(b,JSON.stringify(this.config))))()}resetConfig(){return this.config=null,p((()=>localStorage.removeItem(b)))()}}class _{constructor(e,t){this.queue=[],this.isRequestInProgress=!1,this.config=e,this.surveyState=t,this.api=new l({apiHost:e.apiHost,environmentId:e.environmentId})}add(e){this.surveyState.accumulateResponse(e),this.config.setSurveyState&&this.config.setSurveyState(this.surveyState),this.queue.push(e),this.processQueue()}async processQueue(){if(this.isRequestInProgress)return;if(0===this.queue.length)return;this.isRequestInProgress=!0;const e=this.queue[0];let t=0;for(;t<this.config.retryAttempts;){if(await this.sendResponse(e)){this.queue.shift();break}console.error("Formbricks: Failed to send response. Retrying...",t),t++}t>=this.config.retryAttempts&&(console.error("Failed to send response after 2 attempts."),this.surveyState.responseAcc.finished&&this.config.onResponseSendingFailed&&this.config.onResponseSendingFailed(this.surveyState.responseAcc),this.queue.shift()),this.isRequestInProgress=!1,this.processQueue()}async sendResponse(e){try{if(null!==this.surveyState.responseId)await this.api.client.response.update({...e,responseId:this.surveyState.responseId});else{const t=await this.api.client.response.create({...e,surveyId:this.surveyState.surveyId,userId:this.surveyState.userId||null,singleUseId:this.surveyState.singleUseId||null});if(!t.ok)throw new Error("Could not create response");this.surveyState.displayId&&await this.api.client.display.update(this.surveyState.displayId,{responseId:t.data.id}),this.surveyState.updateResponseId(t.data.id),this.config.setSurveyState&&this.config.setSurveyState(this.surveyState)}return!0}catch(t){return console.error(t),!1}}updateSurveyState(e){this.surveyState=e}}class v{constructor(e,t,n,r){this.responseId=null,this.displayId=null,this.userId=null,this.responseAcc={finished:!1,data:{},ttc:{}},this.surveyId=e,this.userId=r??null,this.singleUseId=t??null,this.responseId=n??null}setSurveyId(e){this.surveyId=e,this.clear()}copy(){const e=new v(this.surveyId,this.singleUseId??void 0,this.responseId??void 0,this.userId??void 0);return e.responseId=this.responseId,e.responseAcc=this.responseAcc,e}updateResponseId(e){this.responseId=e}updateDisplayId(e){this.displayId=e}updateUserId(e){this.userId=e}accumulateResponse(e){this.responseAcc={finished:e.finished,ttc:e.ttc,data:{...this.responseAcc.data,...e.data}}}isResponseFinished(){return this.responseAcc.finished}clear(){this.responseId=null,this.responseAcc={finished:!1,data:{},ttc:{}}}}const y=v;var w,k,x,j,C,I,S,N={},E=[],L=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,T=Array.isArray;function A(e,t){for(var n in t)e[n]=t[n];return e}function O(e){var t=e.parentNode;t&&t.removeChild(e)}function M(e,t,n){var r,i,s,o={};for(s in t)"key"==s?r=t[s]:"ref"==s?i=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?w.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===o[s]&&(o[s]=e.defaultProps[s]);return q(e,o,r,i,null)}function q(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==i?++x:i,__i:-1,__u:0};return null==i&&null!=k.vnode&&k.vnode(s),s}function U(e){return e.children}function D(e,t){this.props=e,this.context=t}function P(e,t){if(null==t)return e.__?P(e.__,e.__i+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 Z(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 Z(e)}}function R(e){(!e.__d&&(e.__d=!0)&&j.push(e)&&!F.__r++||C!==k.debounceRendering)&&((C=k.debounceRendering)||I)(F)}function F(){var e,t,n,r,i,s,o,a,l;for(j.sort(S);e=j.shift();)e.__d&&(t=j.length,r=void 0,s=(i=(n=e).__v).__e,a=[],l=[],(o=n.__P)&&((r=A({},i)).__v=i.__v+1,k.vnode&&k.vnode(r),Y(o,r,i,n.__n,void 0!==o.ownerSVGElement,32&i.__u?[s]:null,a,null==s?P(i):s,!!(32&i.__u),l),r.__.__k[r.__i]=r,G(a,r,l),r.__e!=s&&Z(r)),j.length>t&&j.sort(S));F.__r=0}function B(e,t,n,r,i,s,o,a,l,d,c){var u,p,h,f,m,b=r&&r.__k||E,g=t.length;for(n.__d=l,function(e,t,n){var r,i,s,o,a,l=t.length,d=n.length,c=d,u=0;for(e.__k=[],r=0;r<l;r++)null!=(i=e.__k[r]=null==(i=t[r])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?q(null,i,null,null,i):T(i)?q(U,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?q(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=e,i.__b=e.__b+1,a=H(i,n,o=r+u,c),i.__i=a,s=null,-1!==a&&(c--,(s=n[a])&&(s.__u|=131072)),null==s||null===s.__v?(-1==a&&u--,"function"!=typeof i.type&&(i.__u|=65536)):a!==o&&(a===o+1?u++:a>o?c>l-o?u+=a-o:u--:u=a<o&&a==o-1?a-o:0,a!==r+u&&(i.__u|=65536))):(s=n[r])&&null==s.key&&s.__e&&(s.__e==e.__d&&(e.__d=P(s)),J(s,s,!1),n[r]=null,c--);if(c)for(r=0;r<d;r++)null!=(s=n[r])&&0==(131072&s.__u)&&(s.__e==e.__d&&(e.__d=P(s)),J(s,s))}(n,t,b),l=n.__d,u=0;u<g;u++)null!=(h=n.__k[u])&&"boolean"!=typeof h&&"function"!=typeof h&&(p=-1===h.__i?N:b[h.__i]||N,h.__i=u,Y(e,h,p,i,s,o,a,l,d,c),f=h.__e,h.ref&&p.ref!=h.ref&&(p.ref&&X(p.ref,null,h),c.push(h.ref,h.__c||f,h)),null==m&&null!=f&&(m=f),65536&h.__u||p.__k===h.__k?l=z(h,l,e):"function"==typeof h.type&&void 0!==h.__d?l=h.__d:f&&(l=f.nextSibling),h.__d=void 0,h.__u&=-196609);n.__d=l,n.__e=m}function z(e,t,n){var r,i;if("function"==typeof e.type){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=z(r[i],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function $(e,t){return t=t||[],null==e||"boolean"==typeof e||(T(e)?e.some((function(e){$(e,t)})):t.push(e)),t}function H(e,t,n,r){var i=e.key,s=e.type,o=n-1,a=n+1,l=t[n];if(null===l||l&&i==l.key&&s===l.type)return n;if(r>(null!=l&&0==(131072&l.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((l=t[o])&&0==(131072&l.__u)&&i==l.key&&s===l.type)return o;o--}if(a<t.length){if((l=t[a])&&0==(131072&l.__u)&&i==l.key&&s===l.type)return a;a++}}return-1}function W(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 V(e,t,n,r,i){var s;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||W(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||W(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])s=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=Date.now(),e.addEventListener(t,s?K:Q,s)):e.removeEventListener(t,s?K:Q,s);else{if(i)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&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(o){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function Q(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(k.event?k.event(e):e)}function K(e){return this.l[e.type+!0](k.event?k.event(e):e)}function Y(e,t,n,r,i,s,o,a,l,d){var c,u,p,h,f,m,b,g,_,v,y,x,j,C,I,S=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(l=!!(32&n.__u),s=[a=t.__e=n.__e]),(c=k.__b)&&c(t);e:if("function"==typeof S)try{if(g=t.props,_=(c=S.contextType)&&r[c.__c],v=c?_?_.props.value:c.__:r,n.__c?b=(u=t.__c=n.__c).__=u.__E:("prototype"in S&&S.prototype.render?t.__c=u=new S(g,v):(t.__c=u=new D(g,v),u.constructor=S,u.render=ee),_&&_.sub(u),u.props=g,u.state||(u.state={}),u.context=v,u.__n=r,p=u.__d=!0,u.__h=[],u._sb=[]),null==u.__s&&(u.__s=u.state),null!=S.getDerivedStateFromProps&&(u.__s==u.state&&(u.__s=A({},u.__s)),A(u.__s,S.getDerivedStateFromProps(g,u.__s))),h=u.props,f=u.state,u.__v=t,p)null==S.getDerivedStateFromProps&&null!=u.componentWillMount&&u.componentWillMount(),null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(null==S.getDerivedStateFromProps&&g!==h&&null!=u.componentWillReceiveProps&&u.componentWillReceiveProps(g,v),!u.__e&&(null!=u.shouldComponentUpdate&&!1===u.shouldComponentUpdate(g,u.__s,v)||t.__v===n.__v)){for(t.__v!==n.__v&&(u.props=g,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach((function(e){e&&(e.__=t)})),y=0;y<u._sb.length;y++)u.__h.push(u._sb[y]);u._sb=[],u.__h.length&&o.push(u);break e}null!=u.componentWillUpdate&&u.componentWillUpdate(g,u.__s,v),null!=u.componentDidUpdate&&u.__h.push((function(){u.componentDidUpdate(h,f,m)}))}if(u.context=v,u.props=g,u.__P=e,u.__e=!1,x=k.__r,j=0,"prototype"in S&&S.prototype.render){for(u.state=u.__s,u.__d=!1,x&&x(t),c=u.render(u.props,u.state,u.context),C=0;C<u._sb.length;C++)u.__h.push(u._sb[C]);u._sb=[]}else do{u.__d=!1,x&&x(t),c=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++j<25);u.state=u.__s,null!=u.getChildContext&&(r=A(A({},r),u.getChildContext())),p||null==u.getSnapshotBeforeUpdate||(m=u.getSnapshotBeforeUpdate(h,f)),B(e,T(I=null!=c&&c.type===U&&null==c.key?c.props.children:c)?I:[I],t,n,r,i,s,o,a,l,d),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),b&&(u.__E=u.__=null)}catch(E){t.__v=null,l||null!=s?(t.__e=a,t.__u|=l?160:32,s[s.indexOf(a)]=null):(t.__e=n.__e,t.__k=n.__k),k.__e(E,t,n)}else null==s&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,r,i,s,o,a,l){var d,c,u,p,h,f,m,b=n.props,g=t.props,_=t.type;if("svg"===_&&(i=!0),null!=s)for(d=0;d<s.length;d++)if((h=s[d])&&"setAttribute"in h==!!_&&(_?h.localName===_:3===h.nodeType)){e=h,s[d]=null;break}if(null==e){if(null===_)return document.createTextNode(g);e=i?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,g.is&&g),s=null,a=!1}if(null===_)b===g||a&&e.data===g||(e.data=g);else{if(s=s&&w.call(e.childNodes),b=n.props||N,!a&&null!=s)for(b={},d=0;d<e.attributes.length;d++)b[(h=e.attributes[d]).name]=h.value;for(d in b)h=b[d],"children"==d||("dangerouslySetInnerHTML"==d?u=h:"key"===d||d in g||V(e,d,null,h,i));for(d in g)h=g[d],"children"==d?p=h:"dangerouslySetInnerHTML"==d?c=h:"value"==d?f=h:"checked"==d?m=h:"key"===d||a&&"function"!=typeof h||b[d]===h||V(e,d,h,b[d],i);if(c)a||u&&(c.__html===u.__html||c.__html===e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(u&&(e.innerHTML=""),B(e,T(p)?p:[p],t,n,r,i&&"foreignObject"!==_,s,o,s?s[0]:n.__k&&P(n,0),a,l),null!=s)for(d=s.length;d--;)null!=s[d]&&O(s[d]);a||(d="value",void 0!==f&&(f!==e[d]||"progress"===_&&!f||"option"===_&&f!==b[d])&&V(e,d,f,b[d],!1),d="checked",void 0!==m&&m!==e[d]&&V(e,d,m,b[d],!1))}return e}(n.__e,t,n,r,i,s,o,l,d);(c=k.diffed)&&c(t)}function G(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)X(n[r],n[++r],n[++r]);k.__c&&k.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(n){k.__e(n,t.__v)}}))}function X(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(r){k.__e(r,n)}}function J(e,t,n){var r,i;if(k.unmount&&k.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||X(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){k.__e(s,t)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&J(r[i],t,n||"function"!=typeof e.type);n||null==e.__e||O(e.__e),e.__=e.__e=e.__d=void 0}function ee(e,t,n){return this.constructor(e,n)}w=E.slice,k={__e:function(e,t,n,r){for(var i,s,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&null!=s.getDerivedStateFromError&&(i.setState(s.getDerivedStateFromError(e)),o=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(a){e=a}throw e}},x=0,D.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=A({},this.state),"function"==typeof e&&(e=e(A({},n),this.props)),e&&A(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),R(this))},D.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),R(this))},D.prototype.render=U,j=[],I="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,S=function(e,t){return e.__v.__b-t.__v.__b},F.__r=0;var te=0;function ne(e,t,n,r,i,s){var o,a,l={};for(a in t)"ref"==a?o=t[a]:l[a]=t[a];var d={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--te,__i:-1,__u:0,__source:i,__self:s};if("function"==typeof e&&(o=e.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return k.vnode&&k.vnode(d),d}function re(){return ne("a",{href:"https://formbricks.com?utm_source=survey_branding",target:"_blank",tabIndex:-1,className:"mb-5 mt-2 flex justify-center",children:ne("p",{className:"text-signature text-xs",children:["Powered by"," ",ne("b",{children:ne("span",{className:"text-info-text hover:text-heading",children:"Formbricks"})})]})})}const ie=(...e)=>e.filter(Boolean).join(" ");const se=e=>{for(let t=0;t<e.length;t++){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}},oe=(e,t)=>{const n=[...e],r=n.findIndex((e=>"other"===e.id)),i=-1!==r?n.splice(r,1)[0]:null;if("all"===t)se(n);else if("exceptLast"===t){const e=n.pop();se(n),n.push(e)}return i&&n.push(i),n},ae=(e,t)=>{var n;const r=e.questions[t],i=e.questions.length,s=Math.floor(i/2),o=(null==(n=null==r?void 0:r.logic)?void 0:n.map((e=>e.destination)))||[];let a=t||.5;const l=(()=>{const t=e.questions.filter((e=>o.includes(e.id))).sort(((t,n)=>e.questions.indexOf(t)-e.questions.indexOf(n))).pop();return e.questions.findIndex((e=>e.id===(null==t?void 0:t.id)))})();return l>0&&(a=Math.min(s,l-1)),o.includes("end")&&(a=s),a};var le,de,ce,ue,pe=0,he=[],fe=[],me=k.__b,be=k.__r,ge=k.diffed,_e=k.__c,ve=k.unmount;function ye(e,t){k.__h&&k.__h(de,e,pe||t),pe=0;var n=de.__H||(de.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:fe}),n.__[e]}function we(e){return pe=1,function(e,t,n){var r=ye(le++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):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=de,!de.u)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter((function(e){return e.__c}));if(i.every((function(e){return!e.__N})))return!s||s.call(this,e,t,n);var o=!1;return i.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}})),!(!o&&r.__c.props===e)&&(!s||s.call(this,e,t,n))};de.u=!0;var s=de.shouldComponentUpdate,o=de.componentWillUpdate;de.componentWillUpdate=function(e,t,n){if(this.__e){var r=s;s=void 0,i(e,t,n),s=r}o&&o.call(this,e,t,n)},de.shouldComponentUpdate=i}return r.__N||r.__}(Ae,e)}function ke(e,t){var n=ye(le++,3);!k.__s&&Te(n.__H,t)&&(n.__=e,n.i=t,de.__H.__h.push(n))}function xe(e){return pe=5,je((function(){return{current:e}}),[])}function je(e,t){var n=ye(le++,7);return Te(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function Ce(e,t){return pe=8,je((function(){return e}),t)}function Ie(){for(var e;e=he.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ee),e.__H.__h.forEach(Le),e.__H.__h=[]}catch(t){e.__H.__h=[],k.__e(t,e.__v)}}k.__b=function(e){de=null,me&&me(e)},k.__r=function(e){be&&be(e),le=0;var t=(de=e.__c).__H;t&&(ce===de?(t.__h=[],de.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.__V=fe,e.__N=e.i=void 0}))):(t.__h.forEach(Ee),t.__h.forEach(Le),t.__h=[],le=0)),ce=de},k.diffed=function(e){ge&&ge(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==he.push(t)&&ue===k.requestAnimationFrame||((ue=k.requestAnimationFrame)||Ne)(Ie)),t.__H.__.forEach((function(e){e.i&&(e.__H=e.i),e.__V!==fe&&(e.__=e.__V),e.i=void 0,e.__V=fe}))),ce=de=null},k.__c=function(e,t){t.some((function(e){try{e.__h.forEach(Ee),e.__h=e.__h.filter((function(e){return!e.__||Le(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],k.__e(n,e.__v)}})),_e&&_e(e,t)},k.unmount=function(e){ve&&ve(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{Ee(e)}catch(n){t=n}})),n.__H=void 0,t&&k.__e(t,n.__v))};var Se="function"==typeof requestAnimationFrame;function Ne(e){var t,n=function(){clearTimeout(r),Se&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);Se&&(t=requestAnimationFrame(n))}function Ee(e){var t=de,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),de=t}function Le(e){var t=de;e.__c=e.__(),de=t}function Te(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function Ae(e,t){return"function"==typeof t?t(e):t}function Oe({progress:e}){return ne("div",{className:"bg-accent-bg h-2 w-full overflow-hidden rounded-full",children:ne("div",{className:"transition-width bg-brand z-20 h-2 rounded-full duration-500",style:{width:`${Math.floor(100*e)}%`}})})}function Me({survey:e,questionId:t}){const n=je((()=>e.questions.findIndex((e=>e.id===t))),[e,t]),r=Ce(((e,t,n)=>{if(0===t.questions.length)return 0;let r=t.questions.findIndex((t=>t.id===e));-1===r&&(r=0);const i=ae(t,r)/t.questions.length;let s=n;return i>n?s=i:i<=n&&n+.1<=1&&(s=n+.1),s}),[]),i=je((()=>{let t=0,n=[];return e.questions.forEach((i=>{t=r(i.id,e,t),n.push(t)})),n}),[r,e]);return ne(Oe,{progress:"end"===t?1:i[n]})}function qe({survey:e,onClose:t,children:n}){const[r,i]=we(100),[s,o]=we(!1),a=xe(performance.now()),l=xe(null),d=()=>{null!==l.current&&(o(!0),cancelAnimationFrame(l.current),l.current=null)};return ke((()=>{if(!e.autoClose)return;const n=()=>{const r=1e3*e.autoClose,s=performance.now()-a.current,o=Math.max(0,r-s);i(o/r),o>0?l.current=requestAnimationFrame(n):(d(),t())};return i(1),l.current=requestAnimationFrame(n),()=>d()}),[e.autoClose,t]),ne(U,{children:[!s&&e.autoClose&&ne(Oe,{progress:r}),ne("div",{onClick:d,onMouseOver:d,className:"h-full w-full",children:n})]})}function Ue(e,t){switch(e.condition){case"equals":return Array.isArray(t)&&1===t.length&&t.includes(e.value)||(null==t?void 0:t.toString())===e.value;case"notEquals":return t!==e.value;case"lessThan":return void 0!==e.value&&t<e.value;case"lessEqual":return void 0!==e.value&&t<=e.value;case"greaterThan":return void 0!==e.value&&t>e.value;case"greaterEqual":return void 0!==e.value&&t>=e.value;case"includesAll":return Array.isArray(t)&&Array.isArray(e.value)&&e.value.every((e=>t.includes(e)));case"includesOne":return Array.isArray(t)&&Array.isArray(e.value)&&e.value.some((e=>t.includes(e)));case"accepted":return"accepted"===t;case"clicked":return"clicked"===t;case"submitted":return"string"==typeof t?"dismissed"!==t&&""!==t&&null!==t:Array.isArray(t)?t.length>0:"number"==typeof t&&null!==t;case"skipped":return Array.isArray(t)&&0===t.length||""===t||null==t||"dismissed"===t;case"uploaded":return Array.isArray(t)?t.length>0:"skipped"!==t&&""!==t&&null!==t;case"notUploaded":return Array.isArray(t)&&0===t.length||""===t||null===t||"skipped"===t;default:return!1}}function De({onClick:e,backButtonLabel:t,tabIndex:n=2}){return ne("button",{tabIndex:n,type:"button",className:ie("border-back-button-border text-heading focus:ring-focus flex items-center rounded-md border px-3 py-3 text-base font-medium leading-4 shadow-sm hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2"),onClick:e,children:t||"Back"})}function Pe({buttonLabel:e,isLastQuestion:t,onClick:n,tabIndex:r=1,focus:i=!1,type:s="submit"}){return ne("button",{ref:Ce((e=>{e&&i&&setTimeout((()=>{e.focus()}),200)}),[i]),type:s,tabIndex:r,autoFocus:i,className:"bg-brand border-submit-button-border text-on-brand focus:ring-focus flex items-center rounded-md border px-3 py-3 text-base font-medium leading-4 shadow-sm hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2",onClick:n,children:e||(t?"Finish":"Next")})}function Ze({headline:e,questionId:t,required:n=!0,alignTextCenter:r=!1}){return ne("label",{htmlFor:t,className:"text-heading mb-1.5 block text-base font-semibold leading-6",children:ne("div",{className:"flex items-center "+(r?"justify-center":"justify-between"),children:[e,!n&&ne("span",{className:"text-info-text ml-2 self-start text-sm font-normal leading-7",tabIndex:-1,children:"Optional"})]})})}
/*!
* Sanitize an HTML string
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
* @param {String} str The HTML string to sanitize
* @return {String} The sanitized string
*/function Re(e){function t(e,t){let n=t.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!n.includes("javascript:")&&!n.includes("data:"))||!!e.startsWith("on")}function n(e){let n=e.attributes;for(let{name:r,value:i}of n)t(r,i)&&e.removeAttribute(r)}let r=(new DOMParser).parseFromString(e,"text/html").body||document.createElement("body");return function(e){let t=e.querySelectorAll("script");for(let n of t)n.remove()}(r),function e(t){let r=t.children;for(let i of r)n(i),e(i)}(r),r.innerHTML}function Fe({htmlString:e,questionId:t}){return e?ne("label",{htmlFor:t,className:"fb-htmlbody",dangerouslySetInnerHTML:{__html:Re(e)}}):null}function Be({imgUrl:e,altText:t="Image"}){return ne("div",{className:"mb-4 rounded-md",children:ne("img",{src:e,alt:t,className:"mb-4 rounded-md"})})}function ze(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var r in t)if("__source"!==r&&e[r]!==t[r])return!0;return!1}function $e(e){this.props=e}($e.prototype=new D).isPureReactComponent=!0,$e.prototype.shouldComponentUpdate=function(e,t){return ze(this.props,e)||ze(this.state,t)};var He=k.__b;k.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),He&&He(e)};var We=k.__e;k.__e=function(e,t,n,r){if(e.then)for(var i,s=t;s=s.__;)if((i=s.__c)&&i.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t);We(e,t,n,r)};var Ve=k.unmount;function Qe(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(e){"function"==typeof e.__c&&e.__c()})),e.__c.__H=null),null!=(e=function(e,t){for(var n in t)e[n]=t[n];return e}({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return Qe(e,t,n)}))),e}function Ke(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return Ke(e,t,n)})),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Ye(){this.__u=0,this.t=null,this.__b=null}function Ge(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Xe(){this.u=null,this.o=null}k.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ve&&Ve(e)},(Ye.prototype=new D).__c=function(e,t){var n=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(n);var i=Ge(r.__v),s=!1,o=function(){s||(s=!0,n.__R=null,i?i(a):a())};n.__R=o;var a=function(){if(! --r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ke(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.t.pop();)t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Ye.prototype.componentWillUnmount=function(){this.t=[]},Ye.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=Qe(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&M(U,null,e.fallback);return i&&(i.__u&=-33),[M(U,null,t.__a?null:e.children),i]};var Je=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.u=n=n[2]}};(Xe.prototype=new D).__a=function(e){var t=this,n=Ge(t.__v),r=t.o.get(e);return r[0]++,function(i){var s=function(){t.props.revealOrder?(r.push(i),Je(t,e,r)):i()};n?n(s):s()}},Xe.prototype.render=function(e){this.u=null,this.o=new Map;var t=$(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.o.set(t[n],this.u=[1,0,this.u]);return e.children},Xe.prototype.componentDidUpdate=Xe.prototype.componentDidMount=function(){var e=this;this.o.forEach((function(t,n){Je(e,n,t)}))};var et="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,tt=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,nt=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,rt=/[A-Z0-9]/g,it="undefined"!=typeof document,st=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};D.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(e){Object.defineProperty(D.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})}));var ot=k.event;function at(){}function lt(){return this.cancelBubble}function dt(){return this.defaultPrevented}k.event=function(e){return ot&&(e=ot(e)),e.persist=at,e.isPropagationStopped=lt,e.isDefaultPrevented=dt,e.nativeEvent=e};var ct={enumerable:!1,configurable:!0,get:function(){return this.class}},ut=k.vnode;k.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,r={};for(var i in t){var s=t[i];if(!("value"===i&&"defaultValue"in t&&null==s||it&&"children"===i&&"noscript"===n||"class"===i||"className"===i)){var o=i.toLowerCase();"defaultValue"===i&&"value"in t&&null==t.value?i="value":"download"===i&&!0===s?s="":"ondoubleclick"===o?i="ondblclick":"onchange"!==o||"input"!==n&&"textarea"!==n||st(t.type)?"onfocus"===o?i="onfocusin":"onblur"===o?i="onfocusout":nt.test(i)?i=o:-1===n.indexOf("-")&&tt.test(i)?i=i.replace(rt,"-$&").toLowerCase():null===s&&(s=void 0):o=i="oninput","oninput"===o&&r[i=o]&&(i="oninputCapture"),r[i]=s}}"select"==n&&r.multiple&&Array.isArray(r.value)&&(r.value=$(t.children).forEach((function(e){e.props.selected=-1!=r.value.indexOf(e.props.value)}))),"select"==n&&null!=r.defaultValue&&(r.value=$(t.children).forEach((function(e){e.props.selected=r.multiple?-1!=r.defaultValue.indexOf(e.props.value):r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",ct)):(t.className&&!t.class||t.class&&t.className)&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=et,ut&&ut(e)};var pt=k.__r;k.__r=function(e){pt&&pt(e),e.__c};var ht=k.diffed;k.diffed=function(e){ht&&ht(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};const ft=(e,t,n)=>e.hasOwnProperty(t)?{...e,[t]:e[t]+n}:{...e,[t]:n},mt=(e,t,n,r,i)=>{ke((()=>{i(performance.now())}),[e]),ke((()=>{const s=()=>{if("visible"===document.visibilityState)i(performance.now());else{const i=ft(t,e,performance.now()-r);n(i)}};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}}),[])};function bt({question:e,onSubmit:t,onBack:n,isFirstQuestion:r,isLastQuestion:i,ttc:s,setTtc:o}){const[a,l]=we(performance.now());return mt(e.id,s,o,a,l),ne("div",{children:[e.imageUrl&&ne(Be,{imgUrl:e.imageUrl}),ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(Fe,{htmlString:e.html,questionId:e.id}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!r&&ne(De,{backButtonLabel:e.backButtonLabel,onClick:()=>{const r=ft(s,e.id,performance.now()-a);o(r),t({[e.id]:""},r),n()}}),ne("div",{className:"flex w-full justify-end",children:[!e.required&&ne("button",{tabIndex:0,type:"button",onClick:()=>{const n=ft(s,e.id,performance.now()-a);o(n),t({[e.id]:"dismissed"},n)},className:"text-heading focus:ring-focus mr-4 flex items-center rounded-md px-3 py-3 text-base font-medium leading-4 hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2",children:e.dismissButtonLabel||"Skip"}),ne(Pe,{buttonLabel:e.buttonLabel,isLastQuestion:i,focus:!0,onClick:()=>{var n;e.buttonExternal&&e.buttonUrl&&(null==(n=null==window?void 0:window.open(e.buttonUrl,"_blank"))||n.focus());const r=ft(s,e.id,performance.now()-a);o(r),t({[e.id]:"clicked"},r)},type:"button"})]})]})]})}const gt="https://app.cal.com/embed/embed.js";function _t(e=gt){
/*! Copying ends here. */
return function(e,t,n){let r=function(e,t){e.q.push(t)},i=e.document;e.Cal=e.Cal||function(){let n=e.Cal,s=arguments;if(n.loaded||(n.ns={},n.q=n.q||[],i.head.appendChild(i.createElement("script")).src=t,n.loaded=!0),"init"===s[0]){const e=function(){r(e,arguments)},t=s[1];return e.q=e.q||[],void("string"==typeof t?(n.ns[t]=e)&&r(e,s):r(n,s))}r(n,s)}}(window,
//! Replace it with "https://cal.com/embed.js" or the URL where you have embed.js installed
e),window.Cal}function vt({question:e,onSuccessfulBooking:t}){const n=je((()=>{const e=_t("https://cal.com/embed.js"),n={"cal-border-subtle":"transparent","cal-border-booker":"transparent"};return e("ui",{theme:"light",cssVarsPerTheme:{light:{...n},dark:{"cal-bg-muted":"transparent","cal-bg":"transparent",...n}}}),e("on",{action:"bookingSuccessful",callback:()=>{t()}}),e}),[t]);return ke((()=>{document.querySelectorAll("cal-inline").forEach((e=>e.remove())),n("inline",{elementOrSelector:"#fb-cal-embed",calLink:e.calUserName})}),[n,e.calUserName]),ne("div",{className:"relative mt-4",children:ne("div",{id:"fb-cal-embed",className:ie("h-96 overflow-auto rounded-lg border border-slate-200")})})}function yt({subheader:e,questionId:t}){return ne("label",{htmlFor:t,className:"text-subheading block text-sm font-normal leading-6",children:e})}function wt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=we(performance.now());mt(e.id,a,l,d,c);const[u,p]=we(""),h=Ce((()=>{n({[e.id]:"booked"});const t=ft(a,e.id,performance.now()-d);l(t),r({[e.id]:"booked"},t)}),[n,r,e.id,l,d,a]);return ne("form",{onSubmit:i=>{if(i.preventDefault(),e.required&&!t)return void p("Please book an appointment");const s=ft(a,e.id,performance.now()-d);l(s),n({[e.id]:t}),r({[e.id]:t},s)},className:"w-full",children:[ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne(U,{children:[u&&ne("span",{className:"text-red-500",children:u}),ne(vt,{question:e,onSuccessfulBooking:h},e.id)]}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{backButtonLabel:e.backButtonLabel,onClick:()=>{i()}}),ne("div",{}),!e.required&&ne(Pe,{buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function kt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=we(performance.now());return mt(e.id,a,l,d,c),ne("div",{children:[e.imageUrl&&ne(Be,{imgUrl:e.imageUrl}),ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(Fe,{htmlString:e.html||"",questionId:e.id}),ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-d);l(i),r({[e.id]:t},i)},children:[ne("label",{tabIndex:1,onKeyDown:t=>{"Enter"==t.key&&n({[e.id]:"accepted"})},className:"border-border bg-survey-bg text-heading hover:bg-accent-bg focus:bg-accent-bg focus:ring-border-highlight relative z-10 mt-4 flex w-full cursor-pointer items-center rounded-md border p-4 text-sm focus:outline-none focus:ring-2 focus:ring-offset-2",children:[ne("input",{type:"checkbox",id:e.id,name:e.id,value:e.label,onChange:t=>{t.target instanceof HTMLInputElement&&t.target.checked?n({[e.id]:"accepted"}):n({[e.id]:"dismissed"})},checked:"accepted"===t,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${e.id}-label`,required:e.required}),ne("span",{id:`${e.id}-label`,className:"ml-3 font-medium",children:e.label})]}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{tabIndex:3,backButtonLabel:e.backButtonLabel,onClick:()=>{const n=ft(a,e.id,performance.now()-d);l(n),r({[e.id]:t},n),i()}}),ne("div",{}),ne(Pe,{tabIndex:2,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})]})}_t.toString();var xt={SURVEYS_PACKAGE_BUILD:"surveys",NVM_INC:"/Users/matthiasnannt/.nvm/versions/node/v20.10.0/include/node",MANPATH:"/Users/matthiasnannt/.nvm/versions/node/v20.10.0/share/man:/opt/homebrew/share/man:/usr/share/man:/usr/local/share/man:/Users/matthiasnannt/.nvm/versions/node/v20.10.0/share/man:/opt/homebrew/share/man::",npm_config_legacy_peer_deps:"true",TERM_PROGRAM:"vscode",NODE:"/Users/matthiasnannt/Library/pnpm/pnpm",npm_package_homepage:"https://formbricks.com",INIT_CWD:"/Users/matthiasnannt/Developer/formbricks/packages/surveys",NVM_CD_FLAGS:"-q",TURBO_INVOCATION_DIR:"/Users/matthiasnannt/Developer/formbricks",_P9K_TTY:"/dev/ttys001",npm_package_devDependencies_vite:"^5.0.10",SHELL:"/bin/zsh",TERM:"xterm-256color",npm_config_shamefully_hoist:"true",HOMEBREW_REPOSITORY:"/opt/homebrew",TMPDIR:"/var/folders/zk/_n2g5c910zzccj1m8q1mg58h0000gn/T/",npm_package_devDependencies_eslint_config_turbo:"latest",npm_package_scripts_lint:"eslint . --ext .ts,.js,.tsx,.jsx",CONDA_SHLVL:"1",npm_package_devDependencies_concurrently:"8.2.2",CONDA_PROMPT_MODIFIER:"(base) ",TERM_PROGRAM_VERSION:"1.85.1",npm_package_scripts_dev:"SURVEYS_PACKAGE_MODE=development vite build --watch",MallocNanoZone:"0",ORIGINAL_XDG_CURRENT_DESKTOP:"undefined",ZDOTDIR:"/Users/matthiasnannt",npm_package_devDependencies__formbricks_types:"workspace:*",npm_config_registry:"https://registry.npmjs.org/",npm_package_sideEffects:"false",npm_package_devDependencies__formbricks_lib:"workspace:*",npm_package_repository_url:"https://github.com/formbricks/formbricks",PNPM_HOME:"/Users/matthiasnannt/Library/pnpm",ZSH:"/Users/matthiasnannt/.oh-my-zsh",npm_package_scripts_build_question_date:"tsc && SURVEYS_PACKAGE_BUILD=question-date vite build",npm_package_description:"Formbricks-surveys is a helper library to embed surveys into your application",NVM_DIR:"/Users/matthiasnannt/.nvm",USER:"matthiasnannt",npm_package_license:"MIT",COMMAND_MODE:"unix2003",npm_package_exports___import:"./dist/index.mjs",CONDA_EXE:"/Users/matthiasnannt/anaconda3/bin/conda",PNPM_SCRIPT_SRC_DIR:"/Users/matthiasnannt/Developer/formbricks/packages/surveys",npm_package_devDependencies_vite_tsconfig_paths:"^4.2.2",SSH_AUTH_SOCK:"/private/tmp/com.apple.launchd.0aMot443u0/Listeners",npm_package_devDependencies_postcss:"^8.4.32",__CF_USER_TEXT_ENCODING:"0x1F5:0x0:0x0",npm_execpath:"/Users/matthiasnannt/Library/pnpm/pnpm",npm_package_scripts_go:'concurrently "pnpm dev" "serve dist -p 3003"',npm_package_devDependencies_preact:"^10.19.3",npm_package_module:"./dist/index.mjs",PAGER:"less",npm_config_frozen_lockfile:"",LSCOLORS:"Gxfxcxdxbxegedabagacad",_CE_CONDA:"",npm_config_access:"public",npm_package_devDependencies_react_date_picker:"^10.6.0",npm_package_devDependencies__preact_preset_vite:"^2.7.0",PATH:"/Users/matthiasnannt/Developer/formbricks/packages/surveys/node_modules/.bin:/snapshot/dist/node-gyp-bin:/Users/matthiasnannt/Developer/formbricks/node_modules/.bin:/Users/matthiasnannt/Developer/formbricks/packages/surveys/node_modules/.bin:/snapshot/dist/node-gyp-bin:/Users/matthiasnannt/Developer/formbricks/node_modules/.bin:/Users/matthiasnannt/Developer/formbricks/node_modules/.bin:/snapshot/dist/node-gyp-bin:/Users/matthiasnannt/Developer/formbricks/node_modules/.bin:/Users/matthiasnannt/.docker/bin:/Users/matthiasnannt/Library/pnpm:/Users/matthiasnannt/.yarn/bin:/Users/matthiasnannt/.config/yarn/global/node_modules/.bin:/Users/matthiasnannt/anaconda3/bin:/Users/matthiasnannt/.nvm/versions/node/v20.10.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin",npm_config_auto_install_peers:"true",CONDA_PREFIX:"/Users/matthiasnannt/anaconda3",USER_ZDOTDIR:"/Users/matthiasnannt",__CFBundleIdentifier:"com.microsoft.VSCode",npm_command:"run-script",npm_package_devDependencies_terser:"^5.26.0",npm_package_devDependencies_tailwindcss:"^3.4.0",PWD:"/Users/matthiasnannt/Developer/formbricks/packages/surveys",npm_package_scripts_preview:"vite preview",npm_lifecycle_event:"build:surveys",P9K_SSH:"0",npm_package_types:"./dist/index.d.ts",npm_package_repository_type:"git",npm_package_name:"@formbricks/surveys",LANG:"en_US.UTF-8",P9K_TTY:"old",npm_package_scripts_build:"pnpm run build:surveys && pnpm run build:question-date",npm_config_node_linker:"hoisted",TURBO_HASH:"e4ed64ec13240bab",VSCODE_GIT_ASKPASS_EXTRA_ARGS:"--ms-enable-electron-run-as-node",XPC_FLAGS:"0x0",npm_package_devDependencies_vite_plugin_dts:"^3.6.4",npm_package_devDependencies_eslint_config_prettier:"^9.1.0",npm_package_main:"./dist/index.js",npm_package_version:"1.4.0",XPC_SERVICE_NAME:"0",_CE_M:"",npm_package_devDependencies_autoprefixer:"^10.4.16",VSCODE_INJECTION:"1",HOME:"/Users/matthiasnannt",SHLVL:"4",npm_package_source:"./src/index.ts",VSCODE_GIT_ASKPASS_MAIN:"/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass-main.js",npm_config_enable_pre_post_scripts:"true",npm_package_devDependencies__calcom_embed_snippet:"1.1.2",HOMEBREW_PREFIX:"/opt/homebrew",CONDA_PYTHON_EXE:"/Users/matthiasnannt/anaconda3/bin/python",LESS:"-R",LOGNAME:"matthiasnannt",npm_lifecycle_script:"tsc && SURVEYS_PACKAGE_BUILD=surveys vite build",npm_package_exports___require:"./dist/index.umd.js",VSCODE_GIT_IPC_HANDLE:"/var/folders/zk/_n2g5c910zzccj1m8q1mg58h0000gn/T/vscode-git-4d21f99dcc.sock",npm_config_shared_workspace_shrinkwrap:"true",npm_package_devDependencies__formbricks_tsconfig:"workspace:*",CONDA_DEFAULT_ENV:"base",NVM_BIN:"/Users/matthiasnannt/.nvm/versions/node/v20.10.0/bin",npm_config_user_agent:"pnpm/8.12.0 npm/? node/v18.5.0 darwin arm64",GIT_ASKPASS:"/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass.sh",HOMEBREW_CELLAR:"/opt/homebrew/Cellar",INFOPATH:"/opt/homebrew/share/info:/opt/homebrew/share/info:",VSCODE_GIT_ASKPASS_NODE:"/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)",npm_config_link_workspace_packages:"true",npm_package_files_0:"dist",npm_config_init_author_name:"Matthias Nannt",npm_package_devDependencies_serve:"14.2.1",npm_package_scripts_clean:"rimraf .turbo node_modules dist",npm_package_scripts_build_surveys:"tsc && SURVEYS_PACKAGE_BUILD=surveys vite build",npm_node_execpath:"/Users/matthiasnannt/Library/pnpm/pnpm",COLORTERM:"truecolor",_:"/Users/matthiasnannt/Developer/formbricks/node_modules/.bin/vite",NODE_ENV:"production"};function jt({question:e,value:t,onSubmit:n,onBack:r,isFirstQuestion:i,isLastQuestion:s,onChange:o,setTtc:a,ttc:l}){const[d,c]=we(performance.now()),[u,p]=we(""),[h,f]=we(!0);mt(e.id,l,a,d,c);const m=t?new Date(t):void 0;return ke((()=>{if(!window.initDatePicker){const t=document.createElement("script");return t.src="development"===xt.SURVEYS_PACKAGE_MODE?"http://localhost:3003/question-date.umd.js":"https://unpkg.com/@formbricks/surveys@^1.4.0/dist/question-date.umd.js",t.async=!0,document.body.appendChild(t),t.onload=()=>{window.initDatePicker(document.getElementById("date-picker-root"),m,e.format),f(!1)},()=>{document.body.removeChild(t)}}{f(!1);const t=document.getElementById("datePickerContainer");t&&t.remove(),window.initDatePicker(document.getElementById("date-picker-root"),m,e.format)}return()=>{}}),[e.format,e.id]),ke((()=>{window.addEventListener("dateChange",(t=>{const n=t.detail,r=6e4*n.getTimezoneOffset(),i=new Date(n.getTime()-r).toISOString().split("T")[0];o({[e.id]:i})}))}),[o,e.id]),ke((()=>{t&&u&&p("")}),[t]),ne("form",{onSubmit:r=>{if(r.preventDefault(),e.required&&!t)return void p("Please select a date.");const i=ft(l,e.id,performance.now()-d);a(i),n({[e.id]:t},i)},className:"w-full",children:[ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"text-red-600",children:ne("span",{children:u})}),ne("div",{className:ie("my-4",u&&"rounded-lg border-2 border-red-500"),id:"date-picker-root",children:h&&ne("div",{className:"relative flex h-12 w-full cursor-pointer appearance-none items-center justify-center rounded-lg border border-slate-300 bg-white text-left text-base font-normal text-slate-900 hover:bg-slate-50 focus:outline-none focus:ring-2 focus:ring-neutral-900 focus:ring-offset-1",children:ne("span",{className:"h-6 w-6 animate-spin rounded-full border-b-2 border-neutral-900",style:{borderTopColor:"transparent"}})})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[ne("div",{children:!i&&ne(De,{backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(l,e.id,performance.now()-d);a(t),r()}})}),ne(Pe,{isLastQuestion:s,onClick:()=>{},buttonLabel:e.buttonLabel})]})]})}function Ct({allowedFileExtensions:e,surveyId:t,onUploadCallback:n,onFileUpload:r,fileUrls:i,maxSizeInMB:s,allowMultipleFiles:o}){const[a,l]=we([]),[d,c]=we(!1),u=je((()=>!d&&(!!o||!(i&&i.length>0))),[o,i,d]);return ne("div",{className:"items-left relative mt-3 flex w-full cursor-pointer flex-col justify-center rounded-lg border-2 border-dashed border-slate-300 bg-slate-50 hover:bg-slate-100 dark:border-slate-600 dark:bg-slate-700 dark:hover:border-slate-500 dark:hover:bg-slate-800",children:[ne("div",{children:i&&(null==i?void 0:i.map(((e,t)=>ne("div",{className:"relative m-2 rounded-md bg-slate-200",children:[ne("div",{className:"absolute right-0 top-0 m-2",children:ne("div",{className:"flex h-5 w-5 items-center justify-center rounded-md bg-slate-100 hover:bg-slate-50",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 26 26",strokeWidth:1,stroke:"currentColor",className:"h-5 text-slate-700 hover:text-slate-900",onClick:e=>((e,t)=>{if(t.stopPropagation(),i){const t=[...a];t.splice(e,1),l(t);const r=[...i];r.splice(e,1),n(r)}})(t,e),children:ne("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9l10 10m0-10L9 19"})})})}),ne("div",{className:"flex flex-col items-center justify-center p-2",children:[ne("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-file",className:"h-6 text-slate-500",children:[ne("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),ne("polyline",{points:"14 2 14 8 20 8"})]}),ne("p",{className:"mt-1 text-sm text-slate-600 dark:text-slate-400",children:decodeURIComponent(e).split("/").pop()})]})]},t))))}),ne("div",{children:[d&&ne("div",{className:"inset-0 flex animate-pulse items-center justify-center rounded-lg bg-slate-100 py-4",children:ne("label",{htmlFor:"selectedFile",className:"text-sm font-medium text-slate-500",children:"Uploading..."})}),ne("label",{htmlFor:"selectedFile",onDragOver:e=>(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy"})(e),onDrop:d=>(async d=>{d.preventDefault(),d.stopPropagation();const u=Array.from(d.dataTransfer.files);if(!o&&u.length>1)alert("Only one file can be uploaded at a time.");else if(u.length>0){const o=u.filter((t=>!(e&&e.length>0)||e.includes(t.type.substring(t.type.lastIndexOf("/")+1))));if(o.length>0){const d=[];for(const n of o)if(s)if((await n.arrayBuffer()).byteLength/1024>1024*s)alert(`File should be less than ${s} MB`);else{c(!0);try{const i=await r(n,{allowedFileExtensions:e,surveyId:t});l([...a,n]),d.push(i)}catch(p){c(!1),"File size exceeds the 10 MB limit"===p.message?alert(p.message):alert("Upload failed! Please try again.")}}else{c(!0);try{const i=await r(n,{allowedFileExtensions:e,surveyId:t});l([...a,n]),d.push(i)}catch(p){c(!1),"File size exceeds the 10 MB limit"===p.message?alert(p.message):alert("Upload failed! Please try again.")}}c(!1),n(i?[...i,...d]:d)}else alert("no selected files are valid")}})(d),children:u&&ne("div",{className:"flex flex-col items-center justify-center py-6",children:[ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-6 text-slate-500",children:ne("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),ne("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:ne("span",{className:"font-medium",children:"Click or drag to upload files."})}),ne("input",{type:"file",id:"selectedFile",name:"selectedFile",accept:null==e?void 0:e.map((e=>`.${e}`)).join(","),className:"hidden",onChange:o=>{const d=o.target;d.files&&(async o=>{if(o)if(s)if((await o.arrayBuffer()).byteLength/1024>1024*s)alert(`File should be less than ${s} MB`);else{c(!0);try{const s=await r(o,{allowedFileExtensions:e,surveyId:t});l([...a,o]),c(!1),n(i?[...i,s]:[s])}catch(d){c(!1),"File size exceeds the 10 MB limit"===d.message?alert(d.message):alert("Upload failed! Please try again.")}}else{c(!0);try{const s=await r(o,{allowedFileExtensions:e,surveyId:t});l([...a,o]),c(!1),n(i?[...i,s]:[s])}catch(d){c(!1),"File size exceeds the 10 MB limit"===d.message?alert(d.message):alert("Upload failed! Please try again.")}}else alert("Please select a file")})(d.files[0])}})]})})]})]})}function It({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,surveyId:a,onFileUpload:l,ttc:d,setTtc:c}){const[u,p]=we(performance.now());return mt(e.id,d,c,u,p),ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(d,e.id,performance.now()-u);c(i),e.required?t&&("string"==typeof t||Array.isArray(t))&&t.length>0?r({[e.id]:"string"==typeof t?[t]:t},i):alert("Please upload a file"):r(t?{[e.id]:"string"==typeof t?[t]:t}:{[e.id]:"skipped"},i)},className:"w-full",children:[ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne(Ct,{surveyId:a,onFileUpload:l,onUploadCallback:t=>{n(t?{[e.id]:t}:{[e.id]:"skipped"})},fileUrls:t,allowMultipleFiles:e.allowMultipleFiles,...e.allowedFileExtensions?{allowedFileExtensions:e.allowedFileExtensions}:{},...e.maxSizeInMB?{maxSizeInMB:e.maxSizeInMB}:{}}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{backButtonLabel:e.backButtonLabel,onClick:()=>{i()}}),ne("div",{}),ne(Pe,{buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function St({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=we(performance.now());mt(e.id,a,l,d,c);const u=Ce((()=>e.choices.filter((e=>"other"!==e.id)).map((e=>e.label))),[e]),[p,h]=we(!!t&&(Array.isArray(t)?t:[t]).some((e=>!1===u().includes(e)))),[f,m]=we(Array.isArray(t)&&t.filter((t=>!e.choices.find((e=>e.label===t))))[0]||""),b=je((()=>{if(!e.choices)return[];const t=e.choices.filter((e=>"other"!==e.id));return e.shuffleOption?oe(t,e.shuffleOption):t}),[e.choices,e.shuffleOption]),g=je((()=>e.choices.find((e=>"other"===e.id))),[e.choices]),_=xe(null);ke((()=>{var e;p&&(null==(e=_.current)||e.focus())}),[p]);const v=r=>Array.isArray(t)?n({[e.id]:[...t,r]}):n({[e.id]:[r]}),y=r=>Array.isArray(t)?n({[e.id]:t.filter((e=>e!==r))}):n({[e.id]:[]});return ne("form",{onSubmit:i=>{i.preventDefault();const s=null==t?void 0:t.filter((e=>u().includes(e)||e===f));n({[e.id]:s});const o=ft(a,e.id,performance.now()-d);l(o),r({[e.id]:t},o)},className:"w-full",children:[e.imageUrl&&ne(Be,{imgUrl:e.imageUrl}),ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mt-4",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Options"}),ne("div",{className:"bg-survey-bg relative max-h-[42vh] space-y-2 overflow-y-auto rounded-md py-0.5 pr-2",children:[b.map(((n,r)=>ne("label",{tabIndex:r+1,onKeyDown:e=>{"Enter"==e.key&&(Array.isArray(t)&&t.includes(n.label)?y(n.label):v(n.label))},className:ie(t===n.label?"border-border-highlight bg-accent-selected-bg z-10":"border-border","text-heading focus-within:border-border-highlight hover:bg-accent-bg focus:bg-accent-bg relative flex cursor-pointer flex-col rounded-md border p-4 focus:outline-none"),children:ne("span",{className:"flex items-center text-sm",children:[ne("input",{type:"checkbox",id:n.id,name:e.id,tabIndex:-1,value:n.label,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${n.id}-label`,onChange:e=>{var t;(null==(t=e.target)?void 0:t.checked)?v(n.label):y(n.label)},checked:Array.isArray(t)&&t.includes(n.label),required:!(e.required&&Array.isArray(t)&&t.length)&&e.required}),ne("span",{id:`${n.id}-label`,className:"ml-3 font-medium",children:n.label})]})},n.id))),g&&ne("label",{tabIndex:b.length+1,className:ie(t===g.label?"border-border-highlight bg-accent-selected-bg z-10":"border-border","text-heading focus-within:border-border-highlight focus-within:bg-accent-bg hover:bg-accent-bg relative flex cursor-pointer flex-col rounded-md border p-4 focus:outline-none"),onKeyDown:e=>{"Enter"==e.key&&h(!p)},children:[ne("span",{className:"flex items-center text-sm",children:[ne("input",{type:"checkbox",tabIndex:-1,id:g.id,name:e.id,value:g.label,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${g.id}-label`,onChange:e=>{var t;if(h(!p),null==(t=e.target)?void 0:t.checked){if(!f)return;v(f)}else y(f)},checked:p}),ne("span",{id:`${g.id}-label`,className:"ml-3 font-medium",children:g.label})]}),p&&ne("input",{ref:_,id:`${g.id}-label`,name:e.id,tabIndex:b.length+1,value:f,onChange:e=>{m(e.currentTarget.value),v(e.currentTarget.value)},onKeyDown:n=>{if("Enter"==n.key){const n=ft(a,e.id,performance.now()-d);l(n),setTimeout((()=>{r({[e.id]:t},n)}),100)}},placeholder:"Please specify",className:"placeholder:text-placeholder border-border bg-survey-bg text-heading focus:ring-focus mt-3 flex h-10 w-full rounded-md border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",required:e.required,"aria-labelledby":`${g.id}-label`})]})]})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{tabIndex:b.length+3,backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(a,e.id,performance.now()-d);l(t),i()}}),ne("div",{}),ne(Pe,{tabIndex:b.length+2,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function Nt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=we(performance.now());mt(e.id,a,l,d,c);const[u,p]=we(!!t&&!e.choices.find((e=>e.label===t))),h=je((()=>{if(!e.choices)return[];const t=e.choices.filter((e=>"other"!==e.id));return e.shuffleOption?oe(t,e.shuffleOption):t}),[e.choices,e.shuffleOption]),f=je((()=>e.choices.find((e=>"other"===e.id))),[e.choices]),m=xe(null);return ke((()=>{var e;u&&(null==(e=m.current)||e.focus())}),[u]),ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-d);l(i),r({[e.id]:t},i)},className:"w-full",children:[e.imageUrl&&ne(Be,{imgUrl:e.imageUrl}),ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mt-4",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Options"}),ne("div",{className:"bg-survey-bg relative max-h-[42vh] space-y-2 overflow-y-auto rounded-md py-0.5 pr-2",role:"radiogroup",children:[h.map(((i,s)=>ne("label",{tabIndex:s+1,onKeyDown:t=>{if("Enter"==t.key){n({[e.id]:i.label});const t=ft(a,e.id,performance.now()-d);l(t),setTimeout((()=>{r({[e.id]:i.label},t)}),350)}},className:ie(t===i.label?"border-border-highlight bg-accent-selected-bg z-10":"border-border","text-heading focus-within:border-border-highlight focus-within:bg-accent-bg hover:bg-accent-bg relative flex cursor-pointer flex-col rounded-md border p-4 focus:outline-none"),children:ne("span",{className:"flex items-center text-sm",children:[ne("input",{tabIndex:-1,type:"radio",id:i.id,name:e.id,value:i.label,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${i.id}-label`,onChange:()=>{p(!1),n({[e.id]:i.label})},checked:t===i.label,required:e.required&&0===s}),ne("span",{id:`${i.id}-label`,className:"ml-3 font-medium",children:i.label})]})},i.id))),f&&ne("label",{tabIndex:h.length+1,className:ie(t===f.label?"border-border-highlight bg-accent-selected-bg z-10":"border-border","text-heading focus-within:border-border-highlight focus-within:bg-accent-bg hover:bg-accent-bg relative flex cursor-pointer flex-col rounded-md border p-4 focus:outline-none"),onKeyDown:t=>{"Enter"==t.key&&(p(!u),u||n({[e.id]:""}))},children:[ne("span",{className:"flex items-center text-sm",children:[ne("input",{type:"radio",id:f.id,tabIndex:-1,name:e.id,value:f.label,className:"border-brand text-brand h-4 w-4 border focus:ring-0 focus:ring-offset-0","aria-labelledby":`${f.id}-label`,onChange:()=>{p(!u),n({[e.id]:""})},checked:u}),ne("span",{id:`${f.id}-label`,className:"ml-3 font-medium",children:f.label})]}),u&&ne("input",{ref:m,tabIndex:h.length+1,id:`${f.id}-label`,name:e.id,value:t,onChange:t=>{n({[e.id]:t.currentTarget.value})},onKeyDown:n=>{if("Enter"==n.key){const n=ft(a,e.id,performance.now()-d);l(n),setTimeout((()=>{r({[e.id]:t},n)}),100)}},placeholder:"Please specify",className:"placeholder:text-placeholder border-border bg-survey-bg text-heading focus:ring-focus mt-3 flex h-10 w-full rounded-md border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",required:e.required,"aria-labelledby":`${f.id}-label`})]})]})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{backButtonLabel:e.backButtonLabel,tabIndex:h.length+3,onClick:()=>{const t=ft(a,e.id,performance.now()-d);l(t),i()}}),ne("div",{}),ne(Pe,{tabIndex:h.length+2,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function Et({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=we(performance.now());return mt(e.id,a,l,d,c),ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-d);l(i),r({[e.id]:t},i)},children:[e.imageUrl&&ne(Be,{imgUrl:e.imageUrl}),ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"my-4",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Options"}),ne("div",{className:"flex",children:Array.from({length:11},((e,t)=>t)).map(((i,s)=>ne("label",{tabIndex:s+1,onKeyDown:t=>{if("Enter"==t.key){const t=ft(a,e.id,performance.now()-d);l(t),r({[e.id]:i},t)}},className:ie(t===i?"border-border-highlight bg-accent-selected-bg z-10":"border-border","bg-survey-bg text-heading hover:bg-accent-bg relative h-10 flex-1 cursor-pointer border text-center text-sm leading-10 first:rounded-l-md last:rounded-r-md focus:outline-none"),children:[ne("input",{type:"radio",name:"nps",value:i,checked:t===i,className:"absolute h-full w-full cursor-pointer opacity-0",onClick:()=>{if(e.required){const t=ft(a,e.id,performance.now()-d);l(t),r({[e.id]:i},t)}n({[e.id]:i})},required:e.required}),i]},i)))}),ne("div",{className:"text-info-text flex justify-between px-1.5 text-xs leading-6",children:[ne("p",{children:e.lowerLabel}),ne("p",{children:e.upperLabel})]})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{tabIndex:o?12:13,backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(a,e.id,performance.now()-d);l(t),i()}}),ne("div",{}),!e.required&&ne(Pe,{tabIndex:12,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function Lt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,autoFocus:a=!0,ttc:l,setTtc:d}){const[c,u]=we(performance.now());mt(e.id,l,d,c,u);const p=t=>{n({[e.id]:t})},h=Ce((e=>{e&&a&&e.focus()}),[e.id]);return ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(l,e.id,performance.now()-c);d(i),r({[e.id]:t,inputType:e.inputType},i)},className:"w-full",children:[e.imageUrl&&ne(Be,{imgUrl:e.imageUrl}),ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mt-4",children:!1===e.longAnswer?ne("input",{ref:h,tabIndex:1,name:e.id,id:e.id,placeholder:e.placeholder,required:e.required,value:t||"",type:e.inputType,onInput:e=>p(e.currentTarget.value),autoFocus:a,className:"border-border bg-survey-bg focus:border-border-highlight block w-full rounded-md border p-2 shadow-sm focus:outline-none focus:ring-0 sm:text-sm",onKeyDown:n=>{if("Enter"===n.key&&(i=t,e.required&&!(null==i?void 0:i.trim())))n.preventDefault();else if("Enter"===n.key){const n=ft(l,e.id,performance.now()-c);d(n),r({[e.id]:t,inputType:e.inputType},n)}var i},pattern:"phone"===e.inputType?"[+][0-9 ]+":".*",title:"phone"===e.inputType?"Enter a valid phone number":void 0}):ne("textarea",{ref:h,rows:3,name:e.id,tabIndex:1,id:e.id,placeholder:e.placeholder,required:e.required,value:t,type:e.inputType,onInput:e=>p(e.currentTarget.value),autoFocus:a,className:"border-border bg-survey-bg text-subheading focus:border-border-highlight block w-full rounded-md border p-2 shadow-sm focus:ring-0 sm:text-sm",pattern:"phone"===e.inputType?"[+][0-9 ]+":".*",title:"phone"===e.inputType?"Please enter a valid phone number":void 0})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(l,e.id,performance.now()-c);d(t),i()}}),ne("div",{}),ne(Pe,{buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function Tt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=we(performance.now());mt(e.id,a,l,d,c);const u=r=>{Array.isArray(t)&&t.includes(r)?(r=>{let i=[];i=e.allowMulti&&Array.isArray(t)?t.filter((e=>e!==r)):[],n({[e.id]:i})})(r):(r=>{let i=[];i=e.allowMulti&&Array.isArray(t)?[...t,r]:[r],n({[e.id]:i})})(r)};ke((()=>{!e.allowMulti&&Array.isArray(t)&&t.length>1&&n({[e.id]:[]})}),[e.allowMulti]);const p=e.choices;return ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-d);l(i),r({[e.id]:t},i)},className:"w-full",children:[e.imageUrl&&ne(Be,{imgUrl:e.imageUrl}),ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mt-4",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Options"}),ne("div",{className:"rounded-m bg-survey-bg relative grid max-h-[42vh] grid-cols-2 gap-x-5 gap-y-4 overflow-y-auto pr-2.5",children:p.map(((n,r)=>ne("label",{tabIndex:r+1,htmlFor:n.id,onKeyDown:e=>{"Enter"==e.key&&u(n.id)},onClick:()=>u(n.id),className:ie(Array.isArray(t)&&t.includes(n.id)?"border-brand text-brand z-10 border-4 shadow-xl focus:border-4":"","border-border focus:border-border-highlight focus:bg-accent-selected-bg relative box-border inline-block h-28 w-full overflow-hidden rounded-xl border focus:outline-none"),children:[ne("img",{src:n.imageUrl,id:n.id,alt:n.imageUrl.split("/").pop(),className:"h-full w-full object-cover"}),e.allowMulti?ne("input",{id:`${n.id}-checked`,name:`${n.id}-checkbox`,type:"checkbox",tabIndex:-1,checked:Array.isArray(t)&&t.includes(n.id),className:ie("border-border pointer-events-none absolute right-2 top-2 z-20 h-5 w-5 rounded border",Array.isArray(t)&&t.includes(n.id)?"border-brand text-brand":""),required:!(e.required&&Array.isArray(t)&&t.length)&&e.required}):ne("input",{id:`${n.id}-radio`,name:`${n.id}-radio`,type:"radio",tabIndex:-1,checked:Array.isArray(t)&&t.includes(n.id),className:ie("border-border pointer-events-none absolute right-2 top-2 z-20 h-5 w-5 rounded-full border",Array.isArray(t)&&t.includes(n.id)?"border-brand text-brand":""),required:!(e.required&&Array.isArray(t)&&t.length)&&e.required})]},n.id)))})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{tabIndex:p.length+3,backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(a,e.id,performance.now()-d);l(t),i()}}),ne("div",{}),ne(Pe,{tabIndex:p.length+2,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}const At=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m21.88 23.92c5.102-0.06134 7.273-1.882 8.383-3.346"}),ne("path",{stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",d:"m46.24 47.56c0-2.592-2.867-7.121-10.25-6.93-6.974 0.1812-10.22 4.518-10.22 7.111s4.271-1.611 10.05-1.492c6.317 0.13 10.43 3.903 10.43 1.311z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m23.16 28.47c5.215 1.438 5.603 0.9096 8.204 1.207 1.068 0.1221-2.03 2.67-7.282 4.397"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m50.12 23.92c-5.102-0.06134-7.273-1.882-8.383-3.346"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m48.84 28.47c-5.215 1.438-5.603 0.9096-8.204 1.207-1.068 0.1221 2.03 2.67 7.282 4.397"})]})}),Ot=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m22.88 23.92c5.102-0.06134 7.273-1.882 8.383-3.346"}),ne("path",{stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",d:"m46.24 47.56c0-2.592-2.867-7.121-10.25-6.93-6.974 0.1812-10.22 4.518-10.22 7.111s4.271-1.611 10.05-1.492c6.317 0.13 10.43 3.903 10.43 1.311z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m49.12 23.92c-5.102-0.06134-7.273-1.882-8.383-3.346"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m48.24 30.51c-6.199 1.47-7.079 1.059-8.868-1.961"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"m23.76 30.51c6.199 1.47 7.079 1.059 8.868-1.961"})]})}),Mt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("line",{x1:"44.5361",x2:"50.9214",y1:"21.4389",y2:"24.7158",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2"}),ne("line",{x1:"26.9214",x2:"20.5361",y1:"21.4389",y2:"24.7158",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M24,28c2.3334,1.3333,4.6666,2.6667,7,4c-2.3334,1.3333-4.6666,2.6667-7,4"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M48,28c-2.3334,1.3333-4.6666,2.6667-7,4c2.3334,1.3333,4.6666,2.6667,7,4"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M28,51c0.2704-0.3562,1-8,8.4211-8.0038C43,42.9929,43.6499,50.5372,44,51C38.6667,51,33.3333,51,28,51z"})]})}),qt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M26.5,48c1.8768-3.8326,5.8239-6.1965,10-6c3.8343,0.1804,7.2926,2.4926,9,6"}),ne("path",{d:"M30,31c0,1.6568-1.3448,3-3,3c-1.6553,0-3-1.3433-3-3c0-1.6552,1.3447-3,3-3C28.6552,28,30,29.3448,30,31"}),ne("path",{d:"M48,31c0,1.6568-1.3447,3-3,3s-3-1.3433-3-3c0-1.6552,1.3447-3,3-3S48,29.3448,48,31"})]})}),Ut=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m44.7 43.92c-6.328-1.736-11.41-0.906-17.4 1.902"}),ne("path",{d:"M30,31c0,1.6568-1.3448,3-3,3c-1.6553,0-3-1.3433-3-3c0-1.6552,1.3447-3,3-3C28.6552,28,30,29.3448,30,31"}),ne("path",{d:"M48,31c0,1.6568-1.3447,3-3,3s-3-1.3433-3-3c0-1.6552,1.3447-3,3-3S48,29.3448,48,31"})]})}),Dt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeWidth:"2",...e}),ne("line",{x1:"27",x2:"45",y1:"43",y2:"43",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"10",strokeWidth:"2"}),ne("path",{d:"M30,31c0,1.6568-1.3448,3-3,3c-1.6553,0-3-1.3433-3-3c0-1.6552,1.3447-3,3-3C28.6552,28,30,29.3448,30,31"}),ne("path",{d:"M48,31c0,1.6568-1.3447,3-3,3s-3-1.3433-3-3c0-1.6552,1.3447-3,3-3S48,29.3448,48,31"})]})}),Pt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M45.8149,44.9293 c-2.8995,1.6362-6.2482,2.5699-9.8149,2.5699s-6.9153-0.9336-9.8149-2.5699"}),ne("path",{d:"M30,31c0,1.6568-1.3448,3-3,3c-1.6553,0-3-1.3433-3-3c0-1.6552,1.3447-3,3-3C28.6552,28,30,29.3448,30,31"}),ne("path",{d:"M48,31c0,1.6568-1.3447,3-3,3s-3-1.3433-3-3c0-1.6552,1.3447-3,3-3S48,29.3448,48,31"})]})}),Zt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M45.8147,45.2268a15.4294,15.4294,0,0,1-19.6294,0"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M31.6941,33.4036a4.7262,4.7262,0,0,0-8.6382,0"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M48.9441,33.4036a4.7262,4.7262,0,0,0-8.6382,0"})]})}),Rt=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",...e}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M50.595,41.64a11.5554,11.5554,0,0,1-.87,4.49c-12.49,3.03-25.43.34-27.49-.13a11.4347,11.4347,0,0,1-.83-4.36h.11s14.8,3.59,28.89.07Z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M49.7251,46.13c-1.79,4.27-6.35,7.23-13.69,7.23-7.41,0-12.03-3.03-13.8-7.36C24.2951,46.47,37.235,49.16,49.7251,46.13Z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M31.6941,32.4036a4.7262,4.7262,0,0,0-8.6382,0"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M48.9441,32.4036a4.7262,4.7262,0,0,0-8.6382,0"})]})}),Ft=e=>ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36,children:ne("g",{id:"line",children:[ne("circle",{cx:"36",cy:"36",r:"23",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",...e}),ne("polyline",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",points:"25.168 27.413 31.755 31.427 25.168 35.165"}),ne("polyline",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",points:"46.832 27.413 40.245 31.427 46.832 35.165"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M50.595,41.64a11.5554,11.5554,0,0,1-.87,4.49c-12.49,3.03-25.43.34-27.49-.13a11.4347,11.4347,0,0,1-.83-4.36h.11s14.8,3.59,28.89.07Z"}),ne("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M49.7251,46.13c-1.79,4.27-6.35,7.23-13.69,7.23-7.41,0-12.03-3.03-13.8-7.36C24.2951,46.47,37.235,49.16,49.7251,46.13Z"})]})});function Bt({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:a,setTtc:l}){const[d,c]=we(0),[u,p]=we(performance.now());mt(e.id,a,l,u,p);const h=t=>{if(n({[e.id]:t}),e.required){const n=ft(a,e.id,performance.now()-u);l(n),r({[e.id]:t},n)}},f=({number:n})=>ne("input",{type:"radio",name:"rating",value:n,className:"absolute left-0 h-full w-full cursor-pointer opacity-0",onChange:()=>h(n),required:e.required,checked:t===n});return ne("form",{onSubmit:n=>{n.preventDefault();const i=ft(a,e.id,performance.now()-u);l(i),r({[e.id]:t},i)},className:"w-full",children:[e.imageUrl&&ne(Be,{imgUrl:e.imageUrl}),ne(Ze,{headline:e.headline,questionId:e.id,required:e.required}),ne(yt,{subheader:e.subheader,questionId:e.id}),ne("div",{className:"mb-4 mt-8",children:ne("fieldset",{children:[ne("legend",{className:"sr-only",children:"Choices"}),ne("div",{className:"flex",children:Array.from({length:e.range},((e,t)=>t+1)).map(((n,r,i)=>ne("span",{onMouseOver:()=>c(n),onMouseLeave:()=>c(0),className:"bg-survey-bg relative max-h-10 max-w-10 flex-1 cursor-pointer text-center text-sm leading-10",children:"number"===e.scale?ne("label",{tabIndex:r+1,onKeyDown:e=>{"Enter"==e.key&&h(n)},className:ie(t===n?"bg-accent-selected-bg border-border-highlight z-10":"",i.length===n?"rounded-r-md":"",1===n?"rounded-l-md":"","text-heading hover:bg-accent-bg focus:bg-accent-bg block h-full w-full border focus:outline-none"),children:[ne(f,{number:n}),n]}):"star"===e.scale?ne("label",{tabIndex:r+1,onKeyDown:e=>{"Enter"==e.key&&h(n)},className:ie(n<=d?"text-rating-focus":"text-heading","focus:text-rating-focus flex h-full w-full justify-center focus:outline-none"),onFocus:()=>c(n),onBlur:()=>c(0),children:[ne(f,{number:n}),"number"==typeof t&&t>=n?ne("span",{className:"text-rating-fill",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"h-8 max-h-full w-8 ",children:ne("path",{fillRule:"evenodd",d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z",clipRule:"evenodd"})})}):ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",className:"h-8 max-h-full w-8",children:ne("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})})]}):ne("label",{className:ie("flex h-full w-full justify-center",t===n||d===n?"stroke-rating-selected text-rating-selected":"stroke-heading text-heading"),tabIndex:r+1,onKeyDown:e=>{"Enter"==e.key&&h(n)},onFocus:()=>c(n),onBlur:()=>c(0),children:[ne(f,{number:n}),ne(zt,{active:t===n||d===n,idx:r,range:e.range})]})},n)))}),ne("div",{className:"text-subheading flex justify-between px-1.5 text-xs leading-6",children:[ne("p",{className:"w-1/2 text-left",children:e.lowerLabel}),ne("p",{className:"w-1/2 text-right",children:e.upperLabel})]})]})}),ne("div",{className:"mt-4 flex w-full justify-between",children:[!s&&ne(De,{tabIndex:!e.required||t?e.range+2:e.range+1,backButtonLabel:e.backButtonLabel,onClick:()=>{const t=ft(a,e.id,performance.now()-u);l(t),i()}}),ne("div",{}),(!e.required||t)&&ne(Pe,{tabIndex:e.range+1,buttonLabel:e.buttonLabel,isLastQuestion:o,onClick:()=>{}})]})]})}function zt({active:e,idx:t,range:n}){const r="fill-rating-fill",i="fill-none";let s=[ne(At,{className:e?r:i}),ne(Ot,{className:e?r:i}),ne(Mt,{className:e?r:i}),ne(qt,{className:e?r:i}),ne(Ut,{className:e?r:i}),ne(Dt,{className:e?r:i}),ne(Pt,{className:e?r:i}),ne(Zt,{className:e?r:i}),ne(Rt,{className:e?r:i}),ne(Ft,{className:e?r:i})];return 7==n?s=[s[1],s[3],s[4],s[5],s[6],s[8],s[9]]:5==n?s=[s[3],s[4],s[5],s[6],s[7]]:4==n?s=[s[4],s[5],s[6],s[7]]:3==n&&(s=[s[4],s[5],s[7]]),s[t]}var $t,Ht,Wt;ne("svg",{viewBox:"0 0 72 72",xmlns:"http://www.w3.org/2000/svg",width:36,height:36}),(Ht=$t||($t={})).assertEqual=e=>e,Ht.assertIs=function(e){},Ht.assertNever=function(e){throw new Error},Ht.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},Ht.getValidEnumValues=e=>{const t=Ht.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),n={};for(const r of t)n[r]=e[r];return Ht.objectValues(n)},Ht.objectValues=e=>Ht.objectKeys(e).map((function(t){return e[t]})),Ht.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},Ht.find=(e,t)=>{for(const n of e)if(t(n))return n},Ht.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,Ht.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},Ht.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(Wt||(Wt={})).mergeShapes=(e,t)=>({...e,...t});const Vt=$t.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Qt=e=>{switch(typeof e){case"undefined":return Vt.undefined;case"string":return Vt.string;case"number":return isNaN(e)?Vt.nan:Vt.number;case"boolean":return Vt.boolean;case"function":return Vt.function;case"bigint":return Vt.bigint;case"symbol":return Vt.symbol;case"object":return Array.isArray(e)?Vt.array:null===e?Vt.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?Vt.promise:"undefined"!=typeof Map&&e instanceof Map?Vt.map:"undefined"!=typeof Set&&e instanceof Set?Vt.set:"undefined"!=typeof Date&&e instanceof Date?Vt.date:Vt.object;default:return Vt.unknown}},Kt=$t.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Yt extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(const i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(r);else if("invalid_return_type"===i.code)r(i.returnTypeError);else if("invalid_arguments"===i.code)r(i.argumentsError);else if(0===i.path.length)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){const n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,$t.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Yt.create=e=>new Yt(e);const Gt=(e,t)=>{let n;switch(e.code){case Kt.invalid_type:n=e.received===Vt.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case Kt.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,$t.jsonStringifyReplacer)}`;break;case Kt.unrecognized_keys:n=`Unrecognized key(s) in object: ${$t.joinValues(e.keys,", ")}`;break;case Kt.invalid_union:n="Invalid input";break;case Kt.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${$t.joinValues(e.options)}`;break;case Kt.invalid_enum_value:n=`Invalid enum value. Expected ${$t.joinValues(e.options)}, received '${e.received}'`;break;case Kt.invalid_arguments:n="Invalid function arguments";break;case Kt.invalid_return_type:n="Invalid function return type";break;case Kt.invalid_date:n="Invalid date";break;case Kt.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:$t.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case Kt.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case Kt.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case Kt.custom:n="Invalid input";break;case Kt.invalid_intersection_types:n="Intersection results could not be merged";break;case Kt.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Kt.not_finite:n="Number must be finite";break;default:n=t.defaultError,$t.assertNever(e)}return{message:n}};let Xt=Gt;function Jt(){return Xt}const en=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};let a="";const l=r.filter((e=>!!e)).slice().reverse();for(const d of l)a=d(o,{data:t,defaultError:a}).message;return{...i,path:s,message:i.message||a}};function tn(e,t){const n=en({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Jt(),Gt].filter((e=>!!e))});e.common.issues.push(n)}class nn{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if("aborted"===r.status)return rn;"dirty"===r.status&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return nn.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:t,value:i}=r;if("aborted"===t.status)return rn;if("aborted"===i.status)return rn;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"===t.value||void 0===i.value&&!r.alwaysSet||(n[t.value]=i.value)}return{status:e.value,value:n}}}const rn=Object.freeze({status:"aborted"}),sn=e=>({status:"dirty",value:e}),on=e=>({status:"valid",value:e}),an=e=>"aborted"===e.status,ln=e=>"dirty"===e.status,dn=e=>"valid"===e.status,cn=e=>"undefined"!=typeof Promise&&e instanceof Promise;var un,pn;(pn=un||(un={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},pn.toString=e=>"string"==typeof e?e:null==e?void 0:e.message;class hn{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const fn=(e,t)=>{if(dn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Yt(e.common.issues);return this._error=t,this._error}}};function mn(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:i};return{errorMap:(e,t)=>"invalid_type"!==e.code?{message:t.defaultError}:void 0===t.data?{message:null!=r?r:t.defaultError}:{message:null!=n?n:t.defaultError},description:i}}class bn{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Qt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Qt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nn,ctx:{common:e.parent.common,data:e.data,parsedType:Qt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(cn(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:null!==(n=null==t?void 0:t.async)&&void 0!==n&&n,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qt(e)},i=this._parseSync({data:e,path:r.path,parent:r});return fn(r,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qt(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(cn(r)?r:Promise.resolve(r));return fn(n,i)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,r)=>{const i=e(t),s=()=>r.addIssue({code:Kt.custom,...n(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then((e=>!!e||(s(),!1))):!!i||(s(),!1)}))}refinement(e,t){return this._refinement(((n,r)=>!!e(n)||(r.addIssue("function"==typeof t?t(n,r):t),!1)))}_refinement(e){return new rr({schema:this,typeName:mr.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ir.create(this,this._def)}nullable(){return sr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Pn.create(this,this._def)}promise(){return nr.create(this,this._def)}or(e){return Fn.create([this,e],this._def)}and(e){return Hn.create(this,e,this._def)}transform(e){return new rr({...mn(this._def),schema:this,typeName:mr.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new or({...mn(this._def),innerType:this,defaultValue:t,typeName:mr.ZodDefault})}brand(){return new cr({typeName:mr.ZodBranded,type:this,...mn(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ar({...mn(this._def),innerType:this,catchValue:t,typeName:mr.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return ur.create(this,e)}readonly(){return pr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const gn=/^c[^\s-]{8,}$/i,_n=/^[a-z][a-z0-9]*$/,vn=/^[0-9A-HJKMNP-TV-Z]{26}$/,yn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,wn=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let kn;const xn=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,jn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;class Cn extends bn{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==Vt.string){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.string,received:t.parsedType}),rn}const t=new nn;let n;for(const a of this._def.checks)if("min"===a.kind)e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),tn(n,{code:Kt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("max"===a.kind)e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),tn(n,{code:Kt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("length"===a.kind){const r=e.data.length>a.value,i=e.data.length<a.value;(r||i)&&(n=this._getOrReturnCtx(e,n),r?tn(n,{code:Kt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&tn(n,{code:Kt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if("email"===a.kind)wn.test(e.data)||(n=this._getOrReturnCtx(e,n),tn(n,{validation:"email",code:Kt.invalid_string,message:a.message}),t.dirty());else if("emoji"===a.kind)kn||(kn=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),kn.test(e.data)||(n=this._getOrReturnCtx(e,n),tn(n,{validation:"emoji",code:Kt.invalid_string,message:a.message}),t.dirty());else if("uuid"===a.kind)yn.test(e.data)||(n=this._getOrReturnCtx(e,n),tn(n,{validation:"uuid",code:Kt.invalid_string,message:a.message}),t.dirty());else if("cuid"===a.kind)gn.test(e.data)||(n=this._getOrReturnCtx(e,n),tn(n,{validation:"cuid",code:Kt.invalid_string,message:a.message}),t.dirty());else if("cuid2"===a.kind)_n.test(e.data)||(n=this._getOrReturnCtx(e,n),tn(n,{validation:"cuid2",code:Kt.invalid_string,message:a.message}),t.dirty());else if("ulid"===a.kind)vn.test(e.data)||(n=this._getOrReturnCtx(e,n),tn(n,{validation:"ulid",code:Kt.invalid_string,message:a.message}),t.dirty());else if("url"===a.kind)try{new URL(e.data)}catch(o){n=this._getOrReturnCtx(e,n),tn(n,{validation:"url",code:Kt.invalid_string,message:a.message}),t.dirty()}else if("regex"===a.kind){a.regex.lastIndex=0;a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),tn(n,{validation:"regex",code:Kt.invalid_string,message:a.message}),t.dirty())}else if("trim"===a.kind)e.data=e.data.trim();else if("includes"===a.kind)e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),tn(n,{code:Kt.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.dirty());else if("toLowerCase"===a.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===a.kind)e.data=e.data.toUpperCase();else if("startsWith"===a.kind)e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),tn(n,{code:Kt.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty());else if("endsWith"===a.kind)e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),tn(n,{code:Kt.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty());else if("datetime"===a.kind){((s=a).precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):0===s.precision?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$")).test(e.data)||(n=this._getOrReturnCtx(e,n),tn(n,{code:Kt.invalid_string,validation:"datetime",message:a.message}),t.dirty())}else"ip"===a.kind?(r=e.data,("v4"!==(i=a.version)&&i||!xn.test(r))&&("v6"!==i&&i||!jn.test(r))&&(n=this._getOrReturnCtx(e,n),tn(n,{validation:"ip",code:Kt.invalid_string,message:a.message}),t.dirty())):$t.assertNever(a);var r,i,s;return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement((t=>e.test(t)),{validation:t,code:Kt.invalid_string,...un.errToObj(n)})}_addCheck(e){return new Cn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...un.errToObj(e)})}url(e){return this._addCheck({kind:"url",...un.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...un.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...un.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...un.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...un.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...un.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...un.errToObj(e)})}datetime(e){var t;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,...un.errToObj(null==e?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...un.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...un.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...un.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...un.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...un.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...un.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...un.errToObj(t)})}nonempty(e){return this.min(1,un.errToObj(e))}trim(){return new Cn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Cn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Cn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function In(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r;return parseInt(e.toFixed(i).replace(".",""))%parseInt(t.toFixed(i).replace(".",""))/Math.pow(10,i)}Cn.create=e=>{var t;return new Cn({checks:[],typeName:mr.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...mn(e)})};class Sn extends bn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==Vt.number){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.number,received:t.parsedType}),rn}let t;const n=new nn;for(const r of this._def.checks)if("int"===r.kind)$t.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),tn(t,{code:Kt.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),tn(t,{code:Kt.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),tn(t,{code:Kt.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else"multipleOf"===r.kind?0!==In(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),tn(t,{code:Kt.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),tn(t,{code:Kt.not_finite,message:r.message}),n.dirty()):$t.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,un.toString(t))}gt(e,t){return this.setLimit("min",e,!1,un.toString(t))}lte(e,t){return this.setLimit("max",e,!0,un.toString(t))}lt(e,t){return this.setLimit("max",e,!1,un.toString(t))}setLimit(e,t,n,r){return new Sn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:un.toString(r)}]})}_addCheck(e){return new Sn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:un.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:un.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:un.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:un.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:un.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:un.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:un.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:un.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:un.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&$t.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Sn.create=e=>new Sn({checks:[],typeName:mr.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...mn(e)});class Nn extends bn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==Vt.bigint){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.bigint,received:t.parsedType}),rn}let t;const n=new nn;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),tn(t,{code:Kt.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),tn(t,{code:Kt.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),tn(t,{code:Kt.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):$t.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,un.toString(t))}gt(e,t){return this.setLimit("min",e,!1,un.toString(t))}lte(e,t){return this.setLimit("max",e,!0,un.toString(t))}lt(e,t){return this.setLimit("max",e,!1,un.toString(t))}setLimit(e,t,n,r){return new Nn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:un.toString(r)}]})}_addCheck(e){return new Nn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:un.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:un.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:un.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:un.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:un.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}Nn.create=e=>{var t;return new Nn({checks:[],typeName:mr.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...mn(e)})};class En extends bn{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==Vt.boolean){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.boolean,received:t.parsedType}),rn}return on(e.data)}}En.create=e=>new En({typeName:mr.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...mn(e)});class Ln extends bn{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==Vt.date){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.date,received:t.parsedType}),rn}if(isNaN(e.data.getTime())){return tn(this._getOrReturnCtx(e),{code:Kt.invalid_date}),rn}const t=new nn;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),tn(n,{code:Kt.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),tn(n,{code:Kt.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):$t.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ln({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:un.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:un.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Ln.create=e=>new Ln({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:mr.ZodDate,...mn(e)});class Tn extends bn{_parse(e){if(this._getType(e)!==Vt.symbol){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.symbol,received:t.parsedType}),rn}return on(e.data)}}Tn.create=e=>new Tn({typeName:mr.ZodSymbol,...mn(e)});class An extends bn{_parse(e){if(this._getType(e)!==Vt.undefined){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.undefined,received:t.parsedType}),rn}return on(e.data)}}An.create=e=>new An({typeName:mr.ZodUndefined,...mn(e)});class On extends bn{_parse(e){if(this._getType(e)!==Vt.null){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.null,received:t.parsedType}),rn}return on(e.data)}}On.create=e=>new On({typeName:mr.ZodNull,...mn(e)});class Mn extends bn{constructor(){super(...arguments),this._any=!0}_parse(e){return on(e.data)}}Mn.create=e=>new Mn({typeName:mr.ZodAny,...mn(e)});class qn extends bn{constructor(){super(...arguments),this._unknown=!0}_parse(e){return on(e.data)}}qn.create=e=>new qn({typeName:mr.ZodUnknown,...mn(e)});class Un extends bn{_parse(e){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.never,received:t.parsedType}),rn}}Un.create=e=>new Un({typeName:mr.ZodNever,...mn(e)});class Dn extends bn{_parse(e){if(this._getType(e)!==Vt.undefined){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.void,received:t.parsedType}),rn}return on(e.data)}}Dn.create=e=>new Dn({typeName:mr.ZodVoid,...mn(e)});class Pn extends bn{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==Vt.array)return tn(t,{code:Kt.invalid_type,expected:Vt.array,received:t.parsedType}),rn;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(tn(t,{code:e?Kt.too_big:Kt.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(tn(t,{code:Kt.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(tn(t,{code:Kt.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map(((e,n)=>r.type._parseAsync(new hn(t,e,t.path,n))))).then((e=>nn.mergeArray(n,e)));const i=[...t.data].map(((e,n)=>r.type._parseSync(new hn(t,e,t.path,n))));return nn.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Pn({...this._def,minLength:{value:e,message:un.toString(t)}})}max(e,t){return new Pn({...this._def,maxLength:{value:e,message:un.toString(t)}})}length(e,t){return new Pn({...this._def,exactLength:{value:e,message:un.toString(t)}})}nonempty(e){return this.min(1,e)}}function Zn(e){if(e instanceof Rn){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ir.create(Zn(r))}return new Rn({...e._def,shape:()=>t})}return e instanceof Pn?new Pn({...e._def,type:Zn(e.element)}):e instanceof ir?ir.create(Zn(e.unwrap())):e instanceof sr?sr.create(Zn(e.unwrap())):e instanceof Wn?Wn.create(e.items.map((e=>Zn(e)))):e}Pn.create=(e,t)=>new Pn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:mr.ZodArray,...mn(t)});class Rn extends bn{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=$t.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Vt.object){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.object,received:t.parsedType}),rn}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Un&&"strip"===this._def.unknownKeys))for(const a in n.data)i.includes(a)||s.push(a);const o=[];for(const a of i){const e=r[a],t=n.data[a];o.push({key:{status:"valid",value:a},value:e._parse(new hn(n,t,n.path,a)),alwaysSet:a in n.data})}if(this._def.catchall instanceof Un){const e=this._def.unknownKeys;if("passthrough"===e)for(const t of s)o.push({key:{status:"valid",value:t},value:{status:"valid",value:n.data[t]}});else if("strict"===e)s.length>0&&(tn(n,{code:Kt.unrecognized_keys,keys:s}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of s){const r=n.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new hn(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of o){const n=await t.key;e.push({key:n,value:await t.value,alwaysSet:t.alwaysSet})}return e})).then((e=>nn.mergeObjectSync(t,e))):nn.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return un.errToObj,new Rn({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{var r,i,s,o;const a=null!==(s=null===(i=(r=this._def).errorMap)||void 0===i?void 0:i.call(r,t,n).message)&&void 0!==s?s:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(o=un.errToObj(e).message)&&void 0!==o?o:a}:{message:a}}}:{}})}strip(){return new Rn({...this._def,unknownKeys:"strip"})}passthrough(){return new Rn({...this._def,unknownKeys:"passthrough"})}extend(e){return new Rn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Rn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:mr.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Rn({...this._def,catchall:e})}pick(e){const t={};return $t.objectKeys(e).forEach((n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])})),new Rn({...this._def,shape:()=>t})}omit(e){const t={};return $t.objectKeys(this.shape).forEach((n=>{e[n]||(t[n]=this.shape[n])})),new Rn({...this._def,shape:()=>t})}deepPartial(){return Zn(this)}partial(e){const t={};return $t.objectKeys(this.shape).forEach((n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()})),new Rn({...this._def,shape:()=>t})}required(e){const t={};return $t.objectKeys(this.shape).forEach((n=>{if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof ir;)e=e._def.innerType;t[n]=e}})),new Rn({...this._def,shape:()=>t})}keyof(){return Jn($t.objectKeys(this.shape))}}Rn.create=(e,t)=>new Rn({shape:()=>e,unknownKeys:"strip",catchall:Un.create(),typeName:mr.ZodObject,...mn(t)}),Rn.strictCreate=(e,t)=>new Rn({shape:()=>e,unknownKeys:"strict",catchall:Un.create(),typeName:mr.ZodObject,...mn(t)}),Rn.lazycreate=(e,t)=>new Rn({shape:e,unknownKeys:"strip",catchall:Un.create(),typeName:mr.ZodObject,...mn(t)});class Fn extends bn{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map((async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;const n=e.map((e=>new Yt(e.ctx.common.issues)));return tn(t,{code:Kt.invalid_union,unionErrors:n}),rn}));{let e;const r=[];for(const s of n){const n={...t,common:{...t.common,issues:[]},parent:null},i=s._parseSync({data:t.data,path:t.path,parent:n});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=r.map((e=>new Yt(e)));return tn(t,{code:Kt.invalid_union,unionErrors:i}),rn}}get options(){return this._def.options}}Fn.create=(e,t)=>new Fn({options:e,typeName:mr.ZodUnion,...mn(t)});const Bn=e=>e instanceof Gn?Bn(e.schema):e instanceof rr?Bn(e.innerType()):e instanceof Xn?[e.value]:e instanceof er?e.options:e instanceof tr?Object.keys(e.enum):e instanceof or?Bn(e._def.innerType):e instanceof An?[void 0]:e instanceof On?[null]:null;class zn extends bn{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Vt.object)return tn(t,{code:Kt.invalid_type,expected:Vt.object,received:t.parsedType}),rn;const n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(tn(t,{code:Kt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),rn)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const i of t){const t=Bn(i.shape[e]);if(!t)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(r.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);r.set(n,i)}}return new zn({typeName:mr.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...mn(n)})}}function $n(e,t){const n=Qt(e),r=Qt(t);if(e===t)return{valid:!0,data:e};if(n===Vt.object&&r===Vt.object){const n=$t.objectKeys(t),r=$t.objectKeys(e).filter((e=>-1!==n.indexOf(e))),i={...e,...t};for(const s of r){const n=$n(e[s],t[s]);if(!n.valid)return{valid:!1};i[s]=n.data}return{valid:!0,data:i}}if(n===Vt.array&&r===Vt.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let r=0;r<e.length;r++){const i=$n(e[r],t[r]);if(!i.valid)return{valid:!1};n.push(i.data)}return{valid:!0,data:n}}return n===Vt.date&&r===Vt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Hn extends bn{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(an(e)||an(r))return rn;const i=$n(e.value,r.value);return i.valid?((ln(e)||ln(r))&&t.dirty(),{status:t.value,value:i.data}):(tn(n,{code:Kt.invalid_intersection_types}),rn)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((([e,t])=>r(e,t))):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Hn.create=(e,t,n)=>new Hn({left:e,right:t,typeName:mr.ZodIntersection,...mn(n)});class Wn extends bn{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Vt.array)return tn(n,{code:Kt.invalid_type,expected:Vt.array,received:n.parsedType}),rn;if(n.data.length<this._def.items.length)return tn(n,{code:Kt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),rn;!this._def.rest&&n.data.length>this._def.items.length&&(tn(n,{code:Kt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map(((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new hn(n,e,n.path,t)):null})).filter((e=>!!e));return n.common.async?Promise.all(r).then((e=>nn.mergeArray(t,e))):nn.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Wn({...this._def,rest:e})}}Wn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Wn({items:e,typeName:mr.ZodTuple,rest:null,...mn(t)})};class Vn extends bn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Vt.object)return tn(n,{code:Kt.invalid_type,expected:Vt.object,received:n.parsedType}),rn;const r=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)r.push({key:i._parse(new hn(n,o,n.path,o)),value:s._parse(new hn(n,n.data[o],n.path,o))});return n.common.async?nn.mergeObjectAsync(t,r):nn.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return new Vn(t instanceof bn?{keyType:e,valueType:t,typeName:mr.ZodRecord,...mn(n)}:{keyType:Cn.create(),valueType:e,typeName:mr.ZodRecord,...mn(t)})}}class Qn extends bn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Vt.map)return tn(n,{code:Kt.invalid_type,expected:Vt.map,received:n.parsedType}),rn;const r=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map((([e,t],s)=>({key:r._parse(new hn(n,e,n.path,[s,"key"])),value:i._parse(new hn(n,t,n.path,[s,"value"]))})));if(n.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const n of s){const r=await n.key,i=await n.value;if("aborted"===r.status||"aborted"===i.status)return rn;"dirty"!==r.status&&"dirty"!==i.status||t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const n of s){const r=n.key,i=n.value;if("aborted"===r.status||"aborted"===i.status)return rn;"dirty"!==r.status&&"dirty"!==i.status||t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}}Qn.create=(e,t,n)=>new Qn({valueType:t,keyType:e,typeName:mr.ZodMap,...mn(n)});class Kn extends bn{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Vt.set)return tn(n,{code:Kt.invalid_type,expected:Vt.set,received:n.parsedType}),rn;const r=this._def;null!==r.minSize&&n.data.size<r.minSize.value&&(tn(n,{code:Kt.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&n.data.size>r.maxSize.value&&(tn(n,{code:Kt.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function s(e){const n=new Set;for(const r of e){if("aborted"===r.status)return rn;"dirty"===r.status&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}const o=[...n.data.values()].map(((e,t)=>i._parse(new hn(n,e,n.path,t))));return n.common.async?Promise.all(o).then((e=>s(e))):s(o)}min(e,t){return new Kn({...this._def,minSize:{value:e,message:un.toString(t)}})}max(e,t){return new Kn({...this._def,maxSize:{value:e,message:un.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Kn.create=(e,t)=>new Kn({valueType:e,minSize:null,maxSize:null,typeName:mr.ZodSet,...mn(t)});class Yn extends bn{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Vt.function)return tn(t,{code:Kt.invalid_type,expected:Vt.function,received:t.parsedType}),rn;function n(e,n){return en({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Jt(),Gt].filter((e=>!!e)),issueData:{code:Kt.invalid_arguments,argumentsError:n}})}function r(e,n){return en({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Jt(),Gt].filter((e=>!!e)),issueData:{code:Kt.invalid_return_type,returnTypeError:n}})}const i={errorMap:t.common.contextualErrorMap},s=t.data;if(this._def.returns instanceof nr){const e=this;return on((async function(...t){const o=new Yt([]),a=await e._def.args.parseAsync(t,i).catch((e=>{throw o.addIssue(n(t,e)),o})),l=await Reflect.apply(s,this,a);return await e._def.returns._def.type.parseAsync(l,i).catch((e=>{throw o.addIssue(r(l,e)),o}))}))}{const e=this;return on((function(...t){const o=e._def.args.safeParse(t,i);if(!o.success)throw new Yt([n(t,o.error)]);const a=Reflect.apply(s,this,o.data),l=e._def.returns.safeParse(a,i);if(!l.success)throw new Yt([r(a,l.error)]);return l.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Yn({...this._def,args:Wn.create(e).rest(qn.create())})}returns(e){return new Yn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Yn({args:e||Wn.create([]).rest(qn.create()),returns:t||qn.create(),typeName:mr.ZodFunction,...mn(n)})}}class Gn extends bn{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Gn.create=(e,t)=>new Gn({getter:e,typeName:mr.ZodLazy,...mn(t)});class Xn extends bn{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return tn(t,{received:t.data,code:Kt.invalid_literal,expected:this._def.value}),rn}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Jn(e,t){return new er({values:e,typeName:mr.ZodEnum,...mn(t)})}Xn.create=(e,t)=>new Xn({value:e,typeName:mr.ZodLiteral,...mn(t)});class er extends bn{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return tn(t,{expected:$t.joinValues(n),received:t.parsedType,code:Kt.invalid_type}),rn}if(-1===this._def.values.indexOf(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return tn(t,{received:t.data,code:Kt.invalid_enum_value,options:n}),rn}return on(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return er.create(e)}exclude(e){return er.create(this.options.filter((t=>!e.includes(t))))}}er.create=Jn;class tr extends bn{_parse(e){const t=$t.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Vt.string&&n.parsedType!==Vt.number){const e=$t.objectValues(t);return tn(n,{expected:$t.joinValues(e),received:n.parsedType,code:Kt.invalid_type}),rn}if(-1===t.indexOf(e.data)){const e=$t.objectValues(t);return tn(n,{received:n.data,code:Kt.invalid_enum_value,options:e}),rn}return on(e.data)}get enum(){return this._def.values}}tr.create=(e,t)=>new tr({values:e,typeName:mr.ZodNativeEnum,...mn(t)});class nr extends bn{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Vt.promise&&!1===t.common.async)return tn(t,{code:Kt.invalid_type,expected:Vt.promise,received:t.parsedType}),rn;const n=t.parsedType===Vt.promise?t.data:Promise.resolve(t.data);return on(n.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}nr.create=(e,t)=>new nr({type:e,typeName:mr.ZodPromise,...mn(t)});class rr extends bn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===mr.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{tn(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===r.type){const e=r.transform(n.data,i);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(e).then((e=>this._def.schema._parseAsync({data:e,path:n.path,parent:n}))):this._def.schema._parseSync({data:e,path:n.path,parent:n})}if("refinement"===r.type){const e=e=>{const t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===r.status?rn:("dirty"===r.status&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((n=>"aborted"===n.status?rn:("dirty"===n.status&&t.dirty(),e(n.value).then((()=>({status:t.value,value:n.value}))))))}if("transform"===r.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!dn(e))return e;const s=r.transform(e.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((e=>dn(e)?Promise.resolve(r.transform(e.value,i)).then((e=>({status:t.value,value:e}))):e))}$t.assertNever(r)}}rr.create=(e,t,n)=>new rr({schema:e,typeName:mr.ZodEffects,effect:t,...mn(n)}),rr.createWithPreprocess=(e,t,n)=>new rr({schema:t,effect:{type:"preprocess",transform:e},typeName:mr.ZodEffects,...mn(n)});class ir extends bn{_parse(e){return this._getType(e)===Vt.undefined?on(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ir.create=(e,t)=>new ir({innerType:e,typeName:mr.ZodOptional,...mn(t)});class sr extends bn{_parse(e){return this._getType(e)===Vt.null?on(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}sr.create=(e,t)=>new sr({innerType:e,typeName:mr.ZodNullable,...mn(t)});class or extends bn{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===Vt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}or.create=(e,t)=>new or({innerType:e,typeName:mr.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...mn(t)});class ar extends bn{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return cn(r)?r.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new Yt(n.common.issues)},input:n.data})}))):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new Yt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ar.create=(e,t)=>new ar({innerType:e,typeName:mr.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...mn(t)});class lr extends bn{_parse(e){if(this._getType(e)!==Vt.nan){const t=this._getOrReturnCtx(e);return tn(t,{code:Kt.invalid_type,expected:Vt.nan,received:t.parsedType}),rn}return{status:"valid",value:e.data}}}lr.create=e=>new lr({typeName:mr.ZodNaN,...mn(e)});const dr=Symbol("zod_brand");class cr extends bn{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ur extends bn{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?rn:"dirty"===e.status?(t.dirty(),sn(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?rn:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new ur({in:e,out:t,typeName:mr.ZodPipeline})}}class pr extends bn{_parse(e){const t=this._def.innerType._parse(e);return dn(t)&&(t.value=Object.freeze(t.value)),t}}pr.create=(e,t)=>new pr({innerType:e,typeName:mr.ZodReadonly,...mn(t)});const hr=(e,t={},n)=>e?Mn.create().superRefine(((r,i)=>{var s,o;if(!e(r)){const e="function"==typeof t?t(r):"string"==typeof t?{message:t}:t,a=null===(o=null!==(s=e.fatal)&&void 0!==s?s:n)||void 0===o||o,l="string"==typeof e?{message:e}:e;i.addIssue({code:"custom",...l,fatal:a})}})):Mn.create(),fr={object:Rn.lazycreate};var mr,br;(br=mr||(mr={})).ZodString="ZodString",br.ZodNumber="ZodNumber",br.ZodNaN="ZodNaN",br.ZodBigInt="ZodBigInt",br.ZodBoolean="ZodBoolean",br.ZodDate="ZodDate",br.ZodSymbol="ZodSymbol",br.ZodUndefined="ZodUndefined",br.ZodNull="ZodNull",br.ZodAny="ZodAny",br.ZodUnknown="ZodUnknown",br.ZodNever="ZodNever",br.ZodVoid="ZodVoid",br.ZodArray="ZodArray",br.ZodObject="ZodObject",br.ZodUnion="ZodUnion",br.ZodDiscriminatedUnion="ZodDiscriminatedUnion",br.ZodIntersection="ZodIntersection",br.ZodTuple="ZodTuple",br.ZodRecord="ZodRecord",br.ZodMap="ZodMap",br.ZodSet="ZodSet",br.ZodFunction="ZodFunction",br.ZodLazy="ZodLazy",br.ZodLiteral="ZodLiteral",br.ZodEnum="ZodEnum",br.ZodEffects="ZodEffects",br.ZodNativeEnum="ZodNativeEnum",br.ZodOptional="ZodOptional",br.ZodNullable="ZodNullable",br.ZodDefault="ZodDefault",br.ZodCatch="ZodCatch",br.ZodPromise="ZodPromise",br.ZodBranded="ZodBranded",br.ZodPipeline="ZodPipeline",br.ZodReadonly="ZodReadonly";const gr=Cn.create,_r=Sn.create,vr=lr.create,yr=Nn.create,wr=En.create,kr=Ln.create,xr=Tn.create,jr=An.create,Cr=On.create,Ir=Mn.create,Sr=qn.create,Nr=Un.create,Er=Dn.create,Lr=Pn.create,Tr=Rn.create,Ar=Rn.strictCreate,Or=Fn.create,Mr=zn.create,qr=Hn.create,Ur=Wn.create,Dr=Vn.create,Pr=Qn.create,Zr=Kn.create,Rr=Yn.create,Fr=Gn.create,Br=Xn.create,zr=er.create,$r=tr.create,Hr=nr.create,Wr=rr.create,Vr=ir.create,Qr=sr.create,Kr=rr.createWithPreprocess,Yr=ur.create,Gr={string:e=>Cn.create({...e,coerce:!0}),number:e=>Sn.create({...e,coerce:!0}),boolean:e=>En.create({...e,coerce:!0}),bigint:e=>Nn.create({...e,coerce:!0}),date:e=>Ln.create({...e,coerce:!0})},Xr=rn;var Jr=Object.freeze({__proto__:null,defaultErrorMap:Gt,setErrorMap:function(e){Xt=e},getErrorMap:Jt,makeIssue:en,EMPTY_PATH:[],addIssueToContext:tn,ParseStatus:nn,INVALID:rn,DIRTY:sn,OK:on,isAborted:an,isDirty:ln,isValid:dn,isAsync:cn,get util(){return $t},get objectUtil(){return Wt},ZodParsedType:Vt,getParsedType:Qt,ZodType:bn,ZodString:Cn,ZodNumber:Sn,ZodBigInt:Nn,ZodBoolean:En,ZodDate:Ln,ZodSymbol:Tn,ZodUndefined:An,ZodNull:On,ZodAny:Mn,ZodUnknown:qn,ZodNever:Un,ZodVoid:Dn,ZodArray:Pn,ZodObject:Rn,ZodUnion:Fn,ZodDiscriminatedUnion:zn,ZodIntersection:Hn,ZodTuple:Wn,ZodRecord:Vn,ZodMap:Qn,ZodSet:Kn,ZodFunction:Yn,ZodLazy:Gn,ZodLiteral:Xn,ZodEnum:er,ZodNativeEnum:tr,ZodPromise:nr,ZodEffects:rr,ZodTransformer:rr,ZodOptional:ir,ZodNullable:sr,ZodDefault:or,ZodCatch:ar,ZodNaN:lr,BRAND:dr,ZodBranded:cr,ZodPipeline:ur,ZodReadonly:pr,custom:hr,Schema:bn,ZodSchema:bn,late:fr,get ZodFirstPartyTypeKind(){return mr},coerce:Gr,any:Ir,array:Lr,bigint:yr,boolean:wr,date:kr,discriminatedUnion:Mr,effect:Wr,enum:zr,function:Rr,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>hr((t=>t instanceof e),t),intersection:qr,lazy:Fr,literal:Br,map:Pr,nan:vr,nativeEnum:$r,never:Nr,null:Cr,nullable:Qr,number:_r,object:Tr,oboolean:()=>wr().optional(),onumber:()=>_r().optional(),optional:Vr,ostring:()=>gr().optional(),pipeline:Yr,preprocess:Kr,promise:Hr,record:Dr,set:Zr,strictObject:Ar,string:gr,symbol:xr,transformer:Wr,tuple:Ur,undefined:jr,union:Or,unknown:Sr,void:Er,NEVER:Xr,ZodIssueCode:Kt,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:Yt});Jr.string(),Jr.number(),Jr.number().optional();const ei=Jr.string().regex(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/),ti=Jr.enum(["bottomLeft","bottomRight","topLeft","topRight","center"]),ni=Jr.enum(["png","jpeg","jpg","pdf","doc","docx","xls","xlsx","ppt","pptx","plain","csv","mp4","mov","avi","mkv","webm","zip","rar","7z","tar"]),ri=Jr.object({enabled:Jr.boolean(),headline:Jr.optional(Jr.string()),subheader:Jr.optional(Jr.string())});var ii=(e=>(e.FileUpload="fileUpload",e.OpenText="openText",e.MultipleChoiceSingle="multipleChoiceSingle",e.MultipleChoiceMulti="multipleChoiceMulti",e.NPS="nps",e.CTA="cta",e.Rating="rating",e.Consent="consent",e.PictureSelection="pictureSelection",e.Cal="cal",e.Date="date",e))(ii||{});const si=Jr.object({enabled:Jr.boolean(),headline:Jr.optional(Jr.string()),html:Jr.string().optional(),fileUrl:Jr.string().optional(),buttonLabel:Jr.string().optional(),timeToFinish:Jr.boolean().default(!0),showResponseCount:Jr.boolean().default(!1)}),oi=Jr.object({enabled:Jr.boolean(),fieldIds:Jr.optional(Jr.array(Jr.string()))}),ai=Jr.object({brandColor:ei.nullish(),highlightBorderColor:ei.nullish(),placement:ti.nullish(),clickOutsideClose:Jr.boolean().nullish(),darkOverlay:Jr.boolean().nullish()});Jr.enum(["animation","color","image"]);const li=Jr.object({bg:Jr.string().nullish(),bgType:Jr.enum(["animation","color","image"]).nullish(),brightness:Jr.number().nullish()}),di=Jr.object({background:li.nullish()}),ci=Jr.object({enabled:Jr.boolean().optional(),heading:Jr.string().optional(),subheading:Jr.string().optional()}).nullable().optional(),ui=Jr.object({enabled:Jr.boolean(),heading:Jr.optional(Jr.string()),subheading:Jr.optional(Jr.string()),isEncrypted:Jr.boolean()}).nullable(),pi=Jr.object({name:Jr.optional(Jr.string()),subheading:Jr.optional(Jr.string())}).optional(),hi=Jr.object({id:Jr.string(),label:Jr.string()}),fi=Jr.object({id:Jr.string(),imageUrl:Jr.string()}),mi=Jr.enum(["accepted","clicked","submitted","skipped","equals","notEquals","lessThan","lessEqual","greaterThan","greaterEqual","includesAll","includesOne","uploaded","notUploaded","booked"]),bi=Jr.object({condition:mi.optional(),value:Jr.union([Jr.string(),Jr.array(Jr.string())]).optional(),destination:Jr.union([Jr.string(),Jr.literal("end")]).optional()}),gi=bi.extend({condition:Jr.enum(["uploaded","notUploaded"]).optional(),value:Jr.undefined()}),_i=bi.extend({condition:Jr.enum(["submitted","skipped"]).optional(),value:Jr.undefined()}),vi=bi.extend({condition:Jr.enum(["skipped","accepted"]).optional(),value:Jr.undefined()}),yi=bi.extend({condition:Jr.enum(["submitted","skipped","equals","notEquals"]).optional(),value:Jr.string().optional()}),wi=bi.extend({condition:Jr.enum(["submitted","skipped","includesAll","includesOne","equals"]).optional(),value:Jr.union([Jr.array(Jr.string()),Jr.string()]).optional()}),ki=bi.extend({condition:Jr.enum(["equals","notEquals","lessThan","lessEqual","greaterThan","greaterEqual","submitted","skipped"]).optional(),value:Jr.union([Jr.string(),Jr.number()]).optional()}),xi=bi.extend({condition:Jr.enum(["clicked","submitted","skipped"]).optional(),value:Jr.undefined()}),ji=bi.extend({condition:Jr.enum(["equals","notEquals","lessThan","lessEqual","greaterThan","greaterEqual","submitted","skipped"]).optional(),value:Jr.union([Jr.string(),Jr.number()]).optional()}),Ci=bi.extend({condition:Jr.enum(["submitted","skipped"]).optional(),value:Jr.undefined()}),Ii=bi.extend({condition:Jr.enum(["booked","skipped"]).optional(),value:Jr.undefined()}),Si=Jr.union([_i,vi,yi,wi,ki,xi,ji,Ci,gi,Ii]),Ni=Jr.object({id:Jr.string(),type:Jr.string(),headline:Jr.string(),subheader:Jr.string().optional(),imageUrl:Jr.string().optional(),required:Jr.boolean(),buttonLabel:Jr.string().optional(),backButtonLabel:Jr.string().optional(),scale:Jr.enum(["number","smiley","star"]).optional(),range:Jr.union([Jr.literal(5),Jr.literal(3),Jr.literal(4),Jr.literal(7),Jr.literal(10)]).optional(),logic:Jr.array(Si).optional(),isDraft:Jr.boolean().optional()}),Ei=Jr.enum(["text","email","url","number","phone"]),Li=Ni.extend({type:Jr.literal("openText"),placeholder:Jr.string().optional(),longAnswer:Jr.boolean().optional(),logic:Jr.array(_i).optional(),inputType:Ei.optional().default("text")}),Ti=Ni.extend({type:Jr.literal("consent"),html:Jr.string().optional(),label:Jr.string(),dismissButtonLabel:Jr.string().optional(),placeholder:Jr.string().optional(),logic:Jr.array(vi).optional()}),Ai=Ni.extend({type:Jr.literal("multipleChoiceSingle"),choices:Jr.array(hi),logic:Jr.array(yi).optional(),shuffleOption:Jr.enum(["none","all","exceptLast"]).optional()}),Oi=Ni.extend({type:Jr.literal("multipleChoiceMulti"),choices:Jr.array(hi),logic:Jr.array(wi).optional(),shuffleOption:Jr.enum(["none","all","exceptLast"]).optional()}),Mi=Ni.extend({type:Jr.literal("nps"),lowerLabel:Jr.string(),upperLabel:Jr.string(),logic:Jr.array(ki).optional()}),qi=Ni.extend({type:Jr.literal("cta"),html:Jr.string().optional(),buttonUrl:Jr.string().optional(),buttonExternal:Jr.boolean(),dismissButtonLabel:Jr.string().optional(),logic:Jr.array(xi).optional()}),Ui=Ni.extend({type:Jr.literal("rating"),scale:Jr.enum(["number","smiley","star"]),range:Jr.union([Jr.literal(5),Jr.literal(3),Jr.literal(4),Jr.literal(7),Jr.literal(10)]),lowerLabel:Jr.string(),upperLabel:Jr.string(),logic:Jr.array(ji).optional()}),Di=Ni.extend({type:Jr.literal("date"),html:Jr.string().optional(),format:Jr.enum(["M-d-y","d-M-y","y-M-d"])}),Pi=Ni.extend({type:Jr.literal("pictureSelection"),allowMulti:Jr.boolean().optional().default(!1),choices:Jr.array(fi),logic:Jr.array(Ci).optional()}),Zi=Ni.extend({type:Jr.literal("fileUpload"),allowMultipleFiles:Jr.boolean(),maxSizeInMB:Jr.number().optional(),allowedFileExtensions:Jr.array(ni).optional(),logic:Jr.array(gi).optional()}),Ri=Ni.extend({type:Jr.literal("cal"),calUserName:Jr.string(),logic:Jr.array(Ii).optional()}),Fi=Jr.union([Li,Ti,Ai,Oi,Mi,qi,Ui,Pi,Di,Zi,Ri]),Bi=Jr.array(Fi),zi=Jr.object({attributeClassId:Jr.string().cuid2(),condition:Jr.enum(["equals","notEquals"]),value:Jr.string()}),$i=Jr.enum(["displayOnce","displayMultiple","respondMultiple"]),Hi=Jr.enum(["web","email","link","mobile"]),Wi=Jr.enum(["draft","inProgress","paused","completed"]);function Vi({question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,autoFocus:a=!0,ttc:l,setTtc:d,surveyId:c,onFileUpload:u}){return e.type===ii.OpenText?ne(Lt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,autoFocus:a,ttc:l,setTtc:d}):e.type===ii.MultipleChoiceSingle?ne(Nt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===ii.MultipleChoiceMulti?ne(St,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===ii.NPS?ne(Et,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===ii.CTA?ne(bt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===ii.Rating?ne(Bt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===ii.Consent?ne(kt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===ii.Date?ne(jt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===ii.PictureSelection?ne(Tt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):e.type===ii.FileUpload?ne(It,{surveyId:c,question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,onFileUpload:u,ttc:l,setTtc:d}):e.type===ii.Cal?ne(wt,{question:e,value:t,onChange:n,onSubmit:r,onBack:i,isFirstQuestion:s,isLastQuestion:o,ttc:l,setTtc:d}):null}Jr.object({id:Jr.string().cuid2(),createdAt:Jr.date(),updatedAt:Jr.date(),name:Jr.string(),type:Hi,environmentId:Jr.string(),status:Wi,attributeFilters:Jr.array(zi),displayOption:$i,autoClose:Jr.number().nullable(),triggers:Jr.array(Jr.string()),redirectUrl:Jr.string().url().nullable(),recontactDays:Jr.number().nullable(),welcomeCard:si,questions:Bi,thankYouCard:ri,hiddenFields:oi,delay:Jr.number(),autoComplete:Jr.number().nullable(),closeOnDate:Jr.date().nullable(),productOverwrites:ai.nullable(),styling:di.nullable(),surveyClosedMessage:ci.nullable(),singleUse:ui.nullable(),verifyEmail:pi.nullable(),pin:Jr.string().nullable().optional()}),Jr.object({name:Jr.string(),type:Hi.optional(),status:Wi.optional(),displayOption:$i.optional(),autoClose:Jr.number().optional(),redirectUrl:Jr.string().url().optional(),recontactDays:Jr.number().optional(),welcomeCard:si.optional(),questions:Bi.optional(),thankYouCard:ri.optional(),hiddenFields:oi,delay:Jr.number().optional(),autoComplete:Jr.number().optional(),closeOnDate:Jr.date().optional(),surveyClosedMessage:ci.optional(),verifyEmail:pi.optional(),attributeFilters:Jr.array(zi).optional(),triggers:Jr.array(Jr.string()).optional()}),Jr.union([Jr.literal("fileUpload"),Jr.literal("openText"),Jr.literal("multipleChoiceSingle"),Jr.literal("multipleChoiceMulti"),Jr.literal("nps"),Jr.literal("cta"),Jr.literal("rating"),Jr.literal("consent"),Jr.literal("pictureSelection"),Jr.literal("cal"),Jr.literal("date")]);const Qi=5;function Ki({redirectUrl:e,isRedirectDisabled:t}){const[n,r]=we(Qi);return ke((()=>{if(e){const n=setInterval((()=>{r((r=>r<=0?(clearInterval(n),t||(window.location.href=e),0):r-1))}),1e3)}return()=>clearInterval(undefined)}),[e,t]),e?ne("div",{children:ne("div",{className:"bg-accent-bg text-subheading mt-10 rounded-md p-2 text-sm",children:[ne("span",{children:"You're redirected in "}),ne("span",{children:n})]})}):null}function Yi({headline:e,subheader:t,redirectUrl:n,isRedirectDisabled:r}){return ne("div",{className:"text-center",children:[ne("div",{className:"text-brand flex items-center justify-center",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"h-24 w-24",children:ne("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),ne("span",{className:"bg-shadow mb-[10px] inline-block h-1 w-16 rounded-[100%]"}),ne("div",{children:[ne(Ze,{alignTextCenter:!0,headline:e,questionId:"thankYouCard"}),ne(yt,{subheader:t,questionId:"thankYouCard"}),ne(Ki,{redirectUrl:n,isRedirectDisabled:r})]})]})}const Gi=()=>ne("div",{className:"mr-1",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",class:"bi bi-stopwatch",viewBox:"0 0 16 16",children:[ne("path",{d:"M8.5 5.6a.5.5 0 1 0-1 0v2.9h-3a.5.5 0 0 0 0 1H8a.5.5 0 0 0 .5-.5V5.6z"}),ne("path",{d:"M6.5 1A.5.5 0 0 1 7 .5h2a.5.5 0 0 1 0 1v.57c1.36.196 2.594.78 3.584 1.64a.715.715 0 0 1 .012-.013l.354-.354-.354-.353a.5.5 0 0 1 .707-.708l1.414 1.415a.5.5 0 1 1-.707.707l-.353-.354-.354.354a.512.512 0 0 1-.013.012A7 7 0 1 1 7 2.071V1.5a.5.5 0 0 1-.5-.5zM8 3a6 6 0 1 0 .001 12A6 6 0 0 0 8 3z"})]})}),Xi=()=>ne("div",{className:"mr-1",children:ne("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"h-4 w-4",children:ne("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"})})});function Ji({headline:e,html:t,fileUrl:n,buttonLabel:r,onSubmit:i,survey:s,responseCount:o}){const a=()=>{let e=ae(s,0);.5===e&&(e=1);const t=s.questions.length/e*15;if(t>360)return"6+ minutes";const n=Math.floor(t/60);return t%60>0?0===n?"less than 1 minute":`less than ${n+1} minutes`:`${n} minutes`},l=s.welcomeCard.timeToFinish,d=s.welcomeCard.showResponseCount;return ne("div",{children:[n&&ne("img",{src:n,className:"mb-8 max-h-96 w-1/3 rounded-lg object-contain",alt:"Company Logo"}),ne(Ze,{headline:e,questionId:"welcomeCard"}),ne(Fe,{htmlString:t,questionId:"welcomeCard"}),ne("div",{className:"mt-10 flex w-full justify-between",children:ne("div",{className:"flex w-full justify-start gap-4",children:[ne(Pe,{buttonLabel:r,isLastQuestion:!1,focus:!0,onClick:()=>{i({welcomeCard:"clicked"},{})},type:"button"}),ne("div",{className:"text-subheading flex items-center text-xs",children:"Press Enter ↵"})]})}),l&&!d?ne("div",{className:"item-center mt-4 flex text-slate-500",children:[ne(Gi,{}),ne("p",{className:"pt-1 text-xs",children:ne("span",{children:[" Takes ",a()," "]})})]}):d&&!l&&o&&o>3?ne("div",{className:"item-center mt-4 flex text-slate-500",children:[ne(Xi,{}),ne("p",{className:"pt-1 text-xs",children:ne("span",{children:`${o} people responded`})})]}):l&&d?ne("div",{className:"item-center mt-4 flex text-slate-500",children:[ne(Gi,{}),ne("p",{className:"pt-1 text-xs",children:[ne("span",{children:[" Takes ",a()," "]}),ne("span",{children:o&&o>3?`⋅ ${o} people responded`:""})]})]}):null]})}function es({survey:e,isBrandingEnabled:t,activeQuestionId:n,onDisplay:r=(()=>{}),onActiveQuestionChange:i=(()=>{}),onResponse:s=(()=>{}),onClose:o=(()=>{}),onFinished:a=(()=>{}),isRedirectDisabled:l=!1,prefillResponseData:d,onFileUpload:c,responseCount:u}){var p;const[h,f]=we(n||(e.welcomeCard.enabled?"start":null==(p=null==e?void 0:e.questions[0])?void 0:p.id)),[m,b]=we(!1),[g,_]=we([]),[v,y]=we({}),w=e.questions.findIndex((e=>e.id===h)),k=e.questions[w],x=xe(null),[j,C]=we({});ke((()=>{var t,r;"hidden"!==n&&("start"!==n||e.welcomeCard.enabled?f(n||(e.welcomeCard.enabled?"start":null==(r=null==e?void 0:e.questions[0])?void 0:r.id)):f(null==(t=null==e?void 0:e.questions[0])?void 0:t.id))}),[n,e.questions,e.welcomeCard.enabled]),ke((()=>{x.current&&(x.current.scrollTop=0)}),[h]),ke((()=>{r(),d&&E(d,{},!0)}),[]);let I=w,S=k;const N=e=>{const t={...v,...e};y(t)},E=(t,n,r=!1)=>{const o=Object.keys(t)[0];b(!0);const l=function(t,n=!1){var r,i;const s=e.questions,o=t[h];if("start"===h){if(!n)return(null==(r=s[0])?void 0:r.id)||"end";I=0,S=s[0]}if(-1===I)throw new Error("Question not found");if((null==S?void 0:S.logic)&&(null==S?void 0:S.logic.length)>0)for(let e of S.logic)if(e.destination&&Ue(e,o))return e.destination;return(null==(i=s[I+1])?void 0:i.id)||"end"}(t,r),d="end"===l;s({data:t,ttc:n,finished:d}),d&&a(),f(l),_([...g,o]),b(!1),i(l)},L=()=>{var t;let n;if((null==g?void 0:g.length)>0){const t=[...g];if(n=t.pop(),d&&n===e.questions[0].id)return;_(t)}else n=null==(t=e.questions[I-1])?void 0:t.id;if(!n)throw new Error("Question not found");f(n),i(n)};return ne(U,{children:ne(qe,{survey:e,onClose:o,children:ne("div",{className:"no-scrollbar flex h-full w-full flex-col justify-between rounded-lg bg-[--fb-survey-background-color] px-6 pb-3 pt-6",children:[ne("div",{ref:x,className:ie(m?"animate-pulse opacity-60":"","my-auto"),children:0!==e.questions.length||e.welcomeCard.enabled||e.thankYouCard.enabled?function(){var t;if("start"===h&&e.welcomeCard.enabled)return ne(Ji,{headline:e.welcomeCard.headline,html:e.welcomeCard.html,fileUrl:e.welcomeCard.fileUrl,buttonLabel:e.welcomeCard.buttonLabel,onSubmit:E,survey:e,responseCount:u});if("end"===h&&e.thankYouCard.enabled)return ne(Yi,{headline:e.thankYouCard.headline,subheader:e.thankYouCard.subheader,redirectUrl:e.redirectUrl,isRedirectDisabled:l});{const n=e.questions.find((e=>e.id===h));return n&&ne(Vi,{surveyId:e.id,question:n,value:v[n.id],onChange:N,onSubmit:E,onBack:L,ttc:j,setTtc:C,onFileUpload:c,isFirstQuestion:g&&d?g[g.length-1]===e.questions[0].id:n.id===(null==(t=null==e?void 0:e.questions[0])?void 0:t.id),isLastQuestion:n.id===e.questions[e.questions.length-1].id})}}():ne("div",{children:"No questions available."})}),ne("div",{className:"mt-8",children:[t&&ne(re,{}),ne(Me,{survey:e,questionId:h})]})]})})})}function ts({children:e,isOpen:t,placement:n,clickOutside:r,darkOverlay:i,highlightBorderColor:s,onClose:o}){const[a,l]=we(!1),d="center"===n,c=xe(null);ke((()=>{l(t)}),[t]),ke((()=>{if(d)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)};function e(e){r&&a&&c.current&&!c.current.contains(e.target)&&o()}}),[a,r,o,d]);const u=je((()=>s?{borderRadius:"8px",border:"2px solid",borderColor:s}:{overflow:"visible"}),[s]);return a?ne("div",{"aria-live":"assertive",className:ie(d?"pointer-events-auto":"pointer-events-none","z-999999 fixed inset-0 flex items-end"),children:ne("div",{className:ie("relative h-full w-full",d?i?"bg-gray-700/80":"bg-white/50":"bg-none transition-all duration-500 ease-in-out"),children:ne("div",{ref:c,className:ie((e=>{switch(e){case"bottomRight":default:return"sm:bottom-3 sm:right-3";case"topRight":return"sm:top-3 sm:right-3 sm:bottom-3";case"topLeft":return"sm:top-3 sm:left-3 sm:bottom-3";case"bottomLeft":return"sm:bottom-3 sm:left-3";case"center":return"sm:top-1/2 sm:left-1/2 sm:transform sm:-translate-x-1/2 sm:-translate-y-1/2"}})(n),a?"opacity-100":"opacity-0","border-border pointer-events-auto absolute bottom-0 h-fit w-full overflow-visible rounded-lg border bg-white shadow-lg transition-all duration-500 ease-in-out sm:m-4 sm:max-w-sm"),children:[!d&&ne("div",{class:"absolute right-0 top-0 block pr-2 pt-2",children:ne("button",{type:"button",onClick:o,class:"text-close-button hover:text-close-button-focus focus:ring-close-button-focus relative h-5 w-5 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2",children:[ne("span",{class:"sr-only",children:"Close survey"}),ne("svg",{class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor","aria-hidden":"true",children:ne("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4 4L20 20M4 20L20 4"})})]})}),ne("div",{style:u,children:e})]})})}):null}function ns({survey:e,isBrandingEnabled:t,activeQuestionId:n,placement:r,clickOutside:i,darkOverlay:s,highlightBorderColor:o,onDisplay:a=(()=>{}),onActiveQuestionChange:l=(()=>{}),onResponse:d=(()=>{}),onClose:c=(()=>{}),onFinished:u=(()=>{}),onFileUpload:p,isRedirectDisabled:h=!1,responseCount:f}){const[m,b]=we(!0),g=()=>{b(!1),setTimeout((()=>{c()}),1e3)};return ne("div",{id:"fbjs",className:"formbricks-form",children:ne(ts,{placement:r,clickOutside:i,darkOverlay:s,highlightBorderColor:o,isOpen:m,onClose:g,children:ne(es,{survey:e,isBrandingEnabled:t,activeQuestionId:n,onDisplay:a,onActiveQuestionChange:l,onResponse:d,onClose:g,onFinished:()=>{u(),setTimeout((()=>{e.redirectUrl||g()}),4e3)},onFileUpload:p,isRedirectDisabled:h,responseCount:f})})})}const rs=({brandColor:e})=>{if(null===document.getElementById("formbricks__css"))return;const t=document.createElement("style");t.id="formbricks__css__custom",t.innerHTML=`\n :root {\n --fb-brand-color: ${e};\n ${function(e){let t,n,r;if(4===e.length?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):7===e.length&&(t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16)),void 0===t||void 0===n||void 0===r)throw new Error("Invalid color");return.299*t+.587*n+.114*r>128}(e)?"--fb-brand-text-color: black;":"--fb-brand-text-color: white;"}\n }\n `,document.head.appendChild(t)},is=e=>{(()=>{if(null===document.getElementById("formbricks__css")){const e=document.createElement("style");e.id="formbricks__css",e.innerHTML='#fbjs *,#fbjs :before,#fbjs :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}#fbjs :before,#fbjs :after{--tw-content: ""}#fbjs html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}#fbjs body{margin:0;line-height:inherit}#fbjs hr{height:0;color:inherit;border-top-width:1px}#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 samp,#fbjs pre{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{text-indent:0;border-color:inherit;border-collapse:collapse}#fbjs button,#fbjs input,#fbjs optgroup,#fbjs select,#fbjs textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}#fbjs button,#fbjs select{text-transform:none}#fbjs button,#fbjs [type=button],#fbjs [type=reset],#fbjs [type=submit]{-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 dl,#fbjs dd,#fbjs h1,#fbjs h2,#fbjs h3,#fbjs h4,#fbjs h5,#fbjs h6,#fbjs hr,#fbjs figure,#fbjs p,#fbjs pre{margin:0}#fbjs fieldset{margin:0;padding:0}#fbjs legend{padding:0}#fbjs ol,#fbjs ul,#fbjs menu{list-style:none;margin:0;padding:0}#fbjs textarea{resize:vertical}#fbjs input::-moz-placeholder,#fbjs textarea::-moz-placeholder{opacity:1;color:#9ca3af}#fbjs input::placeholder,#fbjs textarea::placeholder{opacity:1;color:#9ca3af}#fbjs button,#fbjs [role=button]{cursor:pointer}#fbjs :disabled{cursor:default}#fbjs img,#fbjs svg,#fbjs video,#fbjs canvas,#fbjs audio,#fbjs iframe,#fbjs embed,#fbjs object{display:block;vertical-align:middle}#fbjs img,#fbjs video{max-width:100%;height:auto}#fbjs [hidden]{display:none}*,:before,:after{--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-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--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: rgb(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-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--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: rgb(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: }.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}#fbjs :is(.sr-only){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}#fbjs :is(.pointer-events-none){pointer-events:none}#fbjs :is(.pointer-events-auto){pointer-events:auto}#fbjs :is(.visible){visibility:visible}#fbjs :is(.fixed){position:fixed}#fbjs :is(.absolute){position:absolute}#fbjs :is(.relative){position:relative}#fbjs :is(.inset-0){top:0;right:0;bottom:0;left:0}#fbjs :is(.bottom-0){bottom:0}#fbjs :is(.left-0){left:0}#fbjs :is(.right-0){right:0}#fbjs :is(.right-2){right:.5em}#fbjs :is(.top-0){top:0}#fbjs :is(.top-2){top:.5em}#fbjs :is(.z-10){z-index:10}#fbjs :is(.z-20){z-index:20}#fbjs :is(.z-999999){z-index:999999}#fbjs :is(.m-2){margin:.5em}#fbjs :is(.my-4){margin-top:1em;margin-bottom:1em}#fbjs :is(.my-auto){margin-top:auto;margin-bottom:auto}#fbjs :is(.mb-1){margin-bottom:.25em}#fbjs :is(.mb-1\\.5){margin-bottom:.375em}#fbjs :is(.mb-4){margin-bottom:1em}#fbjs :is(.mb-5){margin-bottom:1.25em}#fbjs :is(.mb-8){margin-bottom:2em}#fbjs :is(.mb-\\[10px\\]){margin-bottom:10px}#fbjs :is(.ml-2){margin-left:.5em}#fbjs :is(.ml-3){margin-left:.75em}#fbjs :is(.mr-1){margin-right:.25em}#fbjs :is(.mr-4){margin-right:1em}#fbjs :is(.mt-1){margin-top:.25em}#fbjs :is(.mt-10){margin-top:2.5em}#fbjs :is(.mt-2){margin-top:.5em}#fbjs :is(.mt-3){margin-top:.75em}#fbjs :is(.mt-4){margin-top:1em}#fbjs :is(.mt-8){margin-top:2em}#fbjs :is(.box-border){box-sizing:border-box}#fbjs :is(.block){display:block}#fbjs :is(.inline-block){display:inline-block}#fbjs :is(.inline){display:inline}#fbjs :is(.flex){display:flex}#fbjs :is(.grid){display:grid}#fbjs :is(.hidden){display:none}#fbjs :is(.h-1){height:.25em}#fbjs :is(.h-10){height:2.5em}#fbjs :is(.h-12){height:3em}#fbjs :is(.h-2){height:.5em}#fbjs :is(.h-24){height:6em}#fbjs :is(.h-28){height:7em}#fbjs :is(.h-4){height:1em}#fbjs :is(.h-5){height:1.25em}#fbjs :is(.h-6){height:1.5em}#fbjs :is(.h-8){height:2em}#fbjs :is(.h-9){height:2.25em}#fbjs :is(.h-96){height:24em}#fbjs :is(.h-fit){height:-moz-fit-content;height:fit-content}#fbjs :is(.h-full){height:100%}#fbjs :is(.max-h-10){max-height:2.5em}#fbjs :is(.max-h-96){max-height:24em}#fbjs :is(.max-h-\\[42vh\\]){max-height:42vh}#fbjs :is(.max-h-full){max-height:100%}#fbjs :is(.w-1\\/2){width:50%}#fbjs :is(.w-1\\/3){width:33.333333%}#fbjs :is(.w-16){width:4em}#fbjs :is(.w-24){width:6em}#fbjs :is(.w-4){width:1em}#fbjs :is(.w-5){width:1.25em}#fbjs :is(.w-6){width:1.5em}#fbjs :is(.w-8){width:2em}#fbjs :is(.w-80){width:20em}#fbjs :is(.w-full){width:100%}#fbjs :is(.max-w-10){max-width:2.5em}#fbjs :is(.flex-1){flex:1 1 0%}@keyframes pulse{50%{opacity:.5}}#fbjs :is(.animate-pulse){animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}#fbjs :is(.animate-spin){animation:spin 1s linear infinite}#fbjs :is(.cursor-pointer){cursor:pointer}#fbjs :is(.appearance-none){-webkit-appearance:none;-moz-appearance:none;appearance:none}#fbjs :is(.grid-cols-2){grid-template-columns:repeat(2,minmax(0,1fr))}#fbjs :is(.flex-col){flex-direction:column}#fbjs :is(.items-end){align-items:flex-end}#fbjs :is(.items-center){align-items:center}#fbjs :is(.justify-start){justify-content:flex-start}#fbjs :is(.justify-end){justify-content:flex-end}#fbjs :is(.justify-center){justify-content:center}#fbjs :is(.justify-between){justify-content:space-between}#fbjs :is(.gap-2){gap:.5em}#fbjs :is(.gap-4){gap:1em}#fbjs :is(.gap-x-5){-moz-column-gap:1.25em;column-gap:1.25em}#fbjs :is(.gap-y-4){row-gap:1em}#fbjs :is(.space-y-2>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(.5em * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5em * var(--tw-space-y-reverse))}#fbjs :is(.self-start){align-self:flex-start}#fbjs :is(.overflow-auto){overflow:auto}#fbjs :is(.overflow-hidden){overflow:hidden}#fbjs :is(.overflow-visible){overflow:visible}#fbjs :is(.overflow-y-auto){overflow-y:auto}#fbjs :is(.rounded){border-radius:.25em}#fbjs :is(.rounded-\\[100\\%\\]){border-radius:100%}#fbjs :is(.rounded-full){border-radius:9999px}#fbjs :is(.rounded-lg){border-radius:.5em}#fbjs :is(.rounded-md){border-radius:.375em}#fbjs :is(.rounded-xl){border-radius:.75em}#fbjs :is(.rounded-l-md){border-top-left-radius:.375em;border-bottom-left-radius:.375em}#fbjs :is(.rounded-r-md){border-top-right-radius:.375em;border-bottom-right-radius:.375em}#fbjs :is(.border){border-width:1px}#fbjs :is(.border-2){border-width:2px}#fbjs :is(.border-4){border-width:4px}#fbjs :is(.border-b-2){border-bottom-width:2px}#fbjs :is(.border-dashed){border-style:dashed}#fbjs :is(.border-\\[\\#e5e7eb\\]){--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity))}#fbjs :is(.border-back-button-border){border-color:var(--fb-back-btn-border)}#fbjs :is(.border-border){border-color:var(--fb-border-color)}#fbjs :is(.border-border-highlight){border-color:var(--fb-border-color-highlight)}#fbjs :is(.border-brand){border-color:var(--fb-brand-color)}#fbjs :is(.border-neutral-900){--tw-border-opacity: 1;border-color:rgb(23 23 23 / var(--tw-border-opacity))}#fbjs :is(.border-red-500){--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity))}#fbjs :is(.border-slate-200){--tw-border-opacity: 1;border-color:rgb(226 232 240 / var(--tw-border-opacity))}#fbjs :is(.border-slate-300){--tw-border-opacity: 1;border-color:rgb(203 213 225 / var(--tw-border-opacity))}#fbjs :is(.border-submit-button-border){border-color:var(--fb-submit-btn-border)}#fbjs :is(.\\!bg-slate-900){--tw-bg-opacity: 1 !important;background-color:rgb(15 23 42 / var(--tw-bg-opacity))!important}#fbjs :is(.bg-\\[--fb-survey-background-color\\]){background-color:var(--fb-survey-background-color)}#fbjs :is(.bg-accent-bg){background-color:var(--fb-accent-background-color)}#fbjs :is(.bg-accent-selected-bg){background-color:var(--fb-accent-background-color-selected)}#fbjs :is(.bg-brand){background-color:var(--fb-brand-color)}#fbjs :is(.bg-gray-700\\/80){background-color:#374151cc}#fbjs :is(.bg-shadow){background-color:var(--fb-shadow-color)}#fbjs :is(.bg-slate-100){--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}#fbjs :is(.bg-slate-200){--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity))}#fbjs :is(.bg-slate-50){--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity))}#fbjs :is(.bg-survey-bg){background-color:var(--fb-survey-background-color)}#fbjs :is(.bg-white){--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}#fbjs :is(.bg-white\\/50){background-color:#ffffff80}#fbjs :is(.bg-none){background-image:none}#fbjs :is(.fill-none){fill:none}#fbjs :is(.fill-rating-fill){fill:var(--fb-rating-fill)}#fbjs :is(.stroke-heading){stroke:var(--fb-heading-color)}#fbjs :is(.stroke-rating-selected){stroke:var(--fb-rating-selected)}#fbjs :is(.object-contain){-o-object-fit:contain;object-fit:contain}#fbjs :is(.object-cover){-o-object-fit:cover;object-fit:cover}#fbjs :is(.p-0){padding:0}#fbjs :is(.p-2){padding:.5em}#fbjs :is(.p-3){padding:.75em}#fbjs :is(.p-4){padding:1em}#fbjs :is(.px-1){padding-left:.25em;padding-right:.25em}#fbjs :is(.px-1\\.5){padding-left:.375em;padding-right:.375em}#fbjs :is(.px-3){padding-left:.75em;padding-right:.75em}#fbjs :is(.px-6){padding-left:1.5em;padding-right:1.5em}#fbjs :is(.py-0){padding-top:0;padding-bottom:0}#fbjs :is(.py-0\\.5){padding-top:.125em;padding-bottom:.125em}#fbjs :is(.py-2){padding-top:.5em;padding-bottom:.5em}#fbjs :is(.py-3){padding-top:.75em;padding-bottom:.75em}#fbjs :is(.py-4){padding-top:1em;padding-bottom:1em}#fbjs :is(.py-6){padding-top:1.5em;padding-bottom:1.5em}#fbjs :is(.pb-3){padding-bottom:.75em}#fbjs :is(.pr-2){padding-right:.5em}#fbjs :is(.pr-2\\.5){padding-right:.625em}#fbjs :is(.pt-1){padding-top:.25em}#fbjs :is(.pt-2){padding-top:.5em}#fbjs :is(.pt-6){padding-top:1.5em}#fbjs :is(.text-left){text-align:left}#fbjs :is(.text-center){text-align:center}#fbjs :is(.text-right){text-align:right}#fbjs :is(.text-base){font-size:1em;line-height:1.5em}#fbjs :is(.text-sm){font-size:.875em;line-height:1.25em}#fbjs :is(.text-xs){font-size:.75em;line-height:1em}#fbjs :is(.font-medium){font-weight:500}#fbjs :is(.font-normal){font-weight:400}#fbjs :is(.font-semibold){font-weight:600}#fbjs :is(.leading-10){line-height:2.5em}#fbjs :is(.leading-4){line-height:1em}#fbjs :is(.leading-6){line-height:1.5em}#fbjs :is(.leading-7){line-height:1.75em}#fbjs :is(.\\!text-slate-100){--tw-text-opacity: 1 !important;color:rgb(241 245 249 / var(--tw-text-opacity))!important}#fbjs :is(.text-brand){color:var(--fb-brand-color)}#fbjs :is(.text-close-button){color:var(--fb-close-btn-color)}#fbjs :is(.text-heading){color:var(--fb-heading-color)}#fbjs :is(.text-info-text){color:var(--fb-info-text-color)}#fbjs :is(.text-on-brand){color:var(--fb-brand-text-color)}#fbjs :is(.text-rating-fill){color:var(--fb-rating-fill)}#fbjs :is(.text-rating-focus){color:var(--fb-rating-hover)}#fbjs :is(.text-rating-selected){color:var(--fb-rating-selected)}#fbjs :is(.text-red-500){--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity))}#fbjs :is(.text-red-600){--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity))}#fbjs :is(.text-signature){color:var(--fb-signature-text-color)}#fbjs :is(.text-slate-500){--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity))}#fbjs :is(.text-slate-600){--tw-text-opacity: 1;color:rgb(71 85 105 / var(--tw-text-opacity))}#fbjs :is(.text-slate-700){--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity))}#fbjs :is(.text-slate-900){--tw-text-opacity: 1;color:rgb(15 23 42 / var(--tw-text-opacity))}#fbjs :is(.text-subheading){color:var(--fb-subheading-color)}#fbjs :is(.opacity-0){opacity:0}#fbjs :is(.opacity-100){opacity:1}#fbjs :is(.opacity-60){opacity:.6}#fbjs :is(.shadow-lg){--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(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(.shadow-md){--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px 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(.shadow-sm){--tw-shadow: 0 1px 2px 0 rgb(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(.shadow-xl){--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px 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(.filter){filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}#fbjs :is(.transition-all){transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}#fbjs :is(.duration-500){transition-duration:.5s}#fbjs :is(.ease-in-out){transition-timing-function:cubic-bezier(.4,0,.2,1)}#fbjs{font-size:16px}#fbjs *{scrollbar-width:thin;scrollbar-color:#e2e8f0}#fbjs *::-webkit-scrollbar{width:8px;border-radius:99px}#fbjs *::-webkit-scrollbar-track{background:#e2e8f0;border-radius:99px}#fbjs *::-webkit-scrollbar-thumb{background-color:#cbd5e1;border:3px solid #cbd5e1;border-radius:99px}.fb-htmlbody{display:block;font-size:.875em;font-weight:400;line-height:1.5em;color:var(--fb-subheading-color)!important}p.fb-editor-paragraph{color:var(--fb-subheading-color)!important}:root{--slate-50: rgb(248 250 252);--slate-100: rgb(241 245 249);--slate-200: rgb(226 232 240);--slate-300: rgb(203 213 225);--slate-400: rgb(148 163 184);--slate-500: rgb(100 116 139);--slate-600: rgb(71 85 105);--slate-700: rgb(51 65 85);--slate-800: rgb(30 41 59);--slate-900: rgb(15 23 42);--gray-100: rgb(243 244 246);--gray-200: rgb(229 231 235);--yellow-300: rgb(253 224 71);--yellow-500: rgb(234 179 8);--fb-brand-color: rgb(255, 255, 255);--fb-brand-text-color: black;--fb-border-color: var(--slate-300);--fb-border-color-highlight: var(--slate-500);--fb-focus-color: var(--slate-500);--fb-heading-color: var(--slate-900);--fb-subheading-color: var(--slate-700);--fb-info-text-color: var(--slate-500);--fb-signature-text-color: var(--slate-400);--fb-survey-background-color: white;--fb-accent-background-color: var(--slate-200);--fb-accent-background-color-selected: var(--slate-100);--fb-placeholder-color: var(--slate-400);--fb-shadow-color: var(--slate-300);--fb-rating-fill: var(--yellow-300);--fb-rating-hover: var(--yellow-500);--fb-back-btn-border: transparent;--fb-submit-btn-border: transparent;--fb-rating-selected: black;--fb-close-btn-color: var(--slate-500);--fb-close-btn-color-hover: var(--slate-700)}#fbjs :is(.placeholder\\:text-placeholder)::-moz-placeholder{color:var(--fb-placeholder-color)}#fbjs :is(.placeholder\\:text-placeholder)::placeholder{color:var(--fb-placeholder-color)}#fbjs :is(.first\\:rounded-l-md:first-child){border-top-left-radius:.375em;border-bottom-left-radius:.375em}#fbjs :is(.last\\:rounded-r-md:last-child){border-top-right-radius:.375em;border-bottom-right-radius:.375em}#fbjs :is(.focus-within\\:border-border-highlight:focus-within){border-color:var(--fb-border-color-highlight)}#fbjs :is(.focus-within\\:bg-accent-bg:focus-within){background-color:var(--fb-accent-background-color)}#fbjs :is(.hover\\:bg-accent-bg:hover){background-color:var(--fb-accent-background-color)}#fbjs :is(.hover\\:bg-slate-100:hover){--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}#fbjs :is(.hover\\:bg-slate-200:hover){--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity))}#fbjs :is(.hover\\:bg-slate-50:hover){--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity))}#fbjs :is(.hover\\:text-close-button-focus:hover){color:var(--fb-close-btn-hover-color)}#fbjs :is(.hover\\:text-heading:hover){color:var(--fb-heading-color)}#fbjs :is(.hover\\:text-slate-900:hover){--tw-text-opacity: 1;color:rgb(15 23 42 / var(--tw-text-opacity))}#fbjs :is(.hover\\:opacity-90:hover){opacity:.9}#fbjs :is(.focus\\:border-4:focus){border-width:4px}#fbjs :is(.focus\\:border-border-highlight:focus){border-color:var(--fb-border-color-highlight)}#fbjs :is(.focus\\:bg-accent-bg:focus){background-color:var(--fb-accent-background-color)}#fbjs :is(.focus\\:bg-accent-selected-bg:focus){background-color:var(--fb-accent-background-color-selected)}#fbjs :is(.focus\\:text-rating-focus:focus){color:var(--fb-rating-hover)}#fbjs :is(.focus\\:outline-none:focus){outline:2px solid transparent;outline-offset:2px}#fbjs :is(.focus\\: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(0px + 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\\: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\\:ring-border-highlight:focus){--tw-ring-color: var(--fb-border-color-highlight)}#fbjs :is(.focus\\:ring-close-button-focus:focus){--tw-ring-color: var(--fb-close-btn-hover-color)}#fbjs :is(.focus\\:ring-focus:focus){--tw-ring-color: var(--fb-focus-color)}#fbjs :is(.focus\\:ring-neutral-900:focus){--tw-ring-opacity: 1;--tw-ring-color: rgb(23 23 23 / var(--tw-ring-opacity))}#fbjs :is(.focus\\:ring-offset-0:focus){--tw-ring-offset-width: 0px}#fbjs :is(.focus\\:ring-offset-1:focus){--tw-ring-offset-width: 1px}#fbjs :is(.focus\\:ring-offset-2:focus){--tw-ring-offset-width: 2px}#fbjs :is(.disabled\\:cursor-not-allowed:disabled){cursor:not-allowed}#fbjs :is(.disabled\\:opacity-50:disabled){opacity:.5}#fbjs :is(.aria-selected\\:opacity-100[aria-selected=true]){opacity:1}@media (min-width: 640px){#fbjs :is(.sm\\:bottom-3){bottom:.75em}#fbjs :is(.sm\\:left-1\\/2){left:50%}#fbjs :is(.sm\\:left-3){left:.75em}#fbjs :is(.sm\\:right-3){right:.75em}#fbjs :is(.sm\\:top-1\\/2){top:50%}#fbjs :is(.sm\\:top-3){top:.75em}#fbjs :is(.sm\\:m-4){margin:1em}#fbjs :is(.sm\\:max-w-sm){max-width:24em}#fbjs :is(.sm\\:-translate-x-1\\/2){--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.sm\\:-translate-y-1\\/2){--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.sm\\:transform){transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}#fbjs :is(.sm\\:text-sm){font-size:.875em;line-height:1.25em}}#fbjs :is(:where(.dark) .dark\\:border-slate-600){--tw-border-opacity: 1;border-color:rgb(71 85 105 / var(--tw-border-opacity))}#fbjs :is(:where(.dark) .dark\\:bg-slate-700){--tw-bg-opacity: 1;background-color:rgb(51 65 85 / var(--tw-bg-opacity))}#fbjs :is(:where(.dark) .dark\\:text-slate-400){--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity))}#fbjs :is(:where(.dark) .dark\\:hover\\:border-slate-500:hover){--tw-border-opacity: 1;border-color:rgb(100 116 139 / var(--tw-border-opacity))}#fbjs :is(:where(.dark) .dark\\:hover\\:bg-slate-800:hover){--tw-bg-opacity: 1;background-color:rgb(30 41 59 / var(--tw-bg-opacity))}.fb-editor-text-bold{font-weight:700!important}.fb-editor-text-italic{font-style:italic!important}.fb-editor-link{color:#334155!important;text-decoration:underline!important}.editor-tokenFunction{color:#dd4a68!important}.fb-editor-paragraph{margin:0!important;position:relative!important;color:#334155!important}.fb-editor-paragraph:last-child{margin-bottom:0!important}.fb-editor-heading-h1{font-size:25px!important;font-weight:400!important;margin-bottom:20px!important;font-weight:700!important}.fb-editor-heading-h2{font-size:20px!important;font-weight:700!important;margin-bottom:20px!important}.fb-editor-list-ul,.fb-editor-list-ol{margin-bottom:12px!important}.fb-editor-listitem{margin:0 32px!important}.fb-editor-nested-listitem{list-style-type:none!important}',document.head.appendChild(e)}})(),rs({brandColor:e.brandColor});const t=document.createElement("div");var n,r,i,s,o,a,l;t.id="formbricks-modal-container",document.body.appendChild(t),n=M(ns,e),r=t,k.__&&k.__(n,r),o=(s="function"==typeof i)?null:i&&i.__k||r.__k,a=[],l=[],Y(r,n=(!s&&i||r).__k=M(U,null,[n]),o||N,N,void 0!==r.ownerSVGElement,!s&&i?[i]:o?null:r.firstChild?w.call(r.childNodes):null,a,!s&&i?i:o?o.__e:r.firstChild,s,l),G(a,n,l)},ss=(e,t)=>{const n=Math.abs(t.getTime()-e.getTime());return Math.floor(n/864e5)},os=g.getInstance(),as=d.getInstance();let ls=null;const ds=async e=>{try{const n=await(async({apiHost:e,environmentId:t,userId:n})=>{const r=`${e}/api/v1/client/${t}/in-app/sync/${n}`,i=`${e}/api/v1/client/${t}/in-app/sync`;if(!n){const e=await fetch(i);if(!e.ok){const t=await e.json();return u({code:"network_error",status:e.status,message:"Error syncing with backend",url:r,responseMessage:t.message})}return c((await e.json()).data)}const s=await fetch(r);if(!s.ok){const e=await s.json();return u({code:"network_error",status:s.status,message:"Error syncing with backend",url:r,responseMessage:e.message})}const o=await s.json(),{data:a}=o;return c(a)})(e);if(!0!==(null==n?void 0:n.ok))throw as.error(`Sync failed: ${JSON.stringify(n.error)}`),n.error;let r;try{r=os.get().state}catch(t){}let i={surveys:n.value.surveys,noCodeActionClasses:n.value.noCodeActionClasses,product:n.value.product,attributes:(null==r?void 0:r.attributes)||{}};if(e.userId){const e=i.surveys.map((e=>e.name));as.debug("Fetched "+e.length+" surveys during sync: "+e.join(", "))}else{i={...i,displays:(null==r?void 0:r.displays)||[]},i=cs(i);const e=i.surveys.map((e=>e.name));as.debug("Fetched "+e.length+" surveys during sync: "+e.join(", "))}os.update({apiHost:e.apiHost,environmentId:e.environmentId,userId:e.userId,state:i})}catch(n){throw as.error(`Error during sync: ${n}`),n}},cs=e=>{const{displays:t,product:n}=e;let{surveys:r}=e;if(!t)return e;let i=r.filter((e=>{if("respondMultiple"===e.displayOption)return!0;if("displayOnce"===e.displayOption)return 0===t.filter((t=>t.surveyId===e.id)).length;if("displayMultiple"===e.displayOption)return 0===t.filter((t=>t.surveyId===e.id&&t.responded)).length;throw Error("Invalid displayOption")}));const s=t.length>0?t[t.length-1]:void 0;return i=i.filter((e=>{if(s){if(null!==e.recontactDays){const n=t.filter((t=>t.surveyId===e.id))[0];return!n||ss(new Date,new Date(n.createdAt))>=e.recontactDays}return null===n.recontactDays||ss(new Date,new Date(s.createdAt))>=n.recontactDays}return!0})),{...e,surveys:i}},us=()=>{"undefined"!=typeof window&&null!==ls&&(window.clearInterval(ls),ls=null)},ps="formbricks-web-container",hs=g.getInstance(),fs=d.getInstance(),ms=m.getInstance();let bs=!1;const gs=e=>{if(bs)return void fs.debug("A survey is already running. Skipping.");bs=!0,e.delay&&fs.debug(`Delaying survey by ${e.delay} seconds.`);const t=hs.get().state.product,n=new y(e.id,null,null,hs.get().userId),r=new _({apiHost:hs.get().apiHost,environmentId:hs.get().environmentId,retryAttempts:2,onResponseSendingFailed:e=>{alert(`Failed to send response: ${JSON.stringify(e,null,2)}`)}},n),i=e.productOverwrites??{},s=i.brandColor??t.brandColor,o=i.highlightBorderColor??t.highlightBorderColor,a=i.clickOutsideClose??t.clickOutsideClose,d=i.darkOverlay??t.darkOverlay,c=i.placement??t.placement,u=t.inAppSurveyBranding;setTimeout((()=>{is({survey:e,brandColor:s,isBrandingEnabled:u,clickOutside:a,darkOverlay:d,highlightBorderColor:o,placement:c,onDisplay:async()=>{const{userId:t}=hs.get();if(!t){const t={createdAt:new Date,surveyId:e.id,responded:!1},n=hs.get().state.displays,r=n?[...n,t]:[t],i=hs.get();let s=cs({...i.state,displays:r});hs.update({...i,state:s})}const i=new l({apiHost:hs.get().apiHost,environmentId:hs.get().environmentId}),s=await i.client.display.create({surveyId:e.id,userId:t});if(!s.ok)throw new Error("Could not create display");const{id:o}=s.data;n.updateDisplayId(o),r.updateSurveyState(n)},onResponse:e=>{const{userId:t}=hs.get();if(!t){const e=hs.get().state.displays,t=e&&e[e.length-1];if(!t)throw new Error("No lastDisplay found");if(!t.responded){t.responded=!0;const n=hs.get();let r=cs({...n.state,displays:e});hs.update({...n,state:r})}}t&&n.updateUserId(t),r.updateSurveyState(n),r.add({data:e.data,ttc:e.ttc,finished:e.finished})},onClose:_s,onFileUpload:async(e,t)=>{const n=new l({apiHost:hs.get().apiHost,environmentId:hs.get().environmentId});return await n.client.storage.uploadFile(e,t)}})}),1e3*e.delay)},_s=async()=>{var e;if(null==(e=document.getElementById(ps))||e.remove(),vs(),!hs.get().userId){const e=hs.get().state,t=cs(e);return hs.update({...hs.get(),state:t}),void(bs=!1)}try{await ds({apiHost:hs.get().apiHost,environmentId:hs.get().environmentId,userId:hs.get().userId}),bs=!1}catch(t){ms.handle(t)}},vs=()=>{const e=document.createElement("div");e.id=ps,document.body.appendChild(e)},ys=d.getInstance(),ws=g.getInstance(),ks=["Exit Intent (Desktop)","50% Scroll"],xs=async(e,t={})=>{var n;const{userId:r}=ws.get(),i={environmentId:ws.get().environmentId,userId:r,name:e,properties:t||{}};if(r&&!ks.includes(e)){ys.debug(`Sending action "${e}" to backend`);const t=new l({apiHost:ws.get().apiHost,environmentId:ws.get().environmentId}),n=await t.client.action.create({...i,userId:r});if(!n.ok)return u({code:"network_error",message:`Error tracking action ${e}`,status:500,url:`${ws.get().apiHost}/api/v1/client/${ws.get().environmentId}/actions`,responseMessage:n.error.message})}ys.debug(`Formbricks: Action "${e}" tracked`);const s=null==(n=ws.get().state)?void 0:n.surveys;return s&&s.length>0?js(e,s):ys.debug("No active surveys to display"),{ok:!0,value:void 0}},js=(e,t)=>{for(const n of t)for(const t of n.triggers)if(t===e)return ys.debug(`Formbricks: survey ${n.id} triggered by action "${e}"`),void gs(n)};let Cs=!1,Is=async function(e){if(e.clientY<=0){const e=await xs("Exit Intent (Desktop)");if(!0!==e.ok)return u(e.error)}};const Ss=()=>{Cs&&(document.removeEventListener("mouseleave",Is),Cs=!1)};let Ns=!1,Es=!1,Ls=async()=>{const e=window.scrollY,t=window.innerHeight,n=document.documentElement.scrollHeight;if(0===e&&(Es=!1),!Es&&e/(n-t)>=.5){Es=!0;const e=await xs("50% Scroll");if(!0!==e.ok)return u(e.error)}};const Ts=()=>{Ns&&(window.removeEventListener("scroll",Ls),Ns=!1)},As=g.getInstance(),Os=d.getInstance(),Ms=m.getInstance(),qs=async()=>{var e;Os.debug(`Checking page url: ${window.location.href}`);const{state:t}=As.get();if(void 0===(null==t?void 0:t.noCodeActionClasses))return{ok:!0,value:void 0};const n=((null==t?void 0:t.noCodeActionClasses)||[]).filter((e=>{const{innerHtml:t,cssSelector:n,pageUrl:r}=e.noCodeConfig||{};return r&&!t&&!n}));if(0===n.length)return{ok:!0,value:void 0};for(const r of n){if(!(null==(e=r.noCodeConfig)?void 0:e.pageUrl))continue;const{noCodeConfig:{pageUrl:t}}=r,n=Zs(window.location.href,t.value,t.rule);if(!0!==n.ok)return u(n.error);if(!1===n.value)continue;const i=await xs(r.name);if(!0!==i.ok)return u(i.error)}return{ok:!0,value:void 0}};let Us=!1;const Ds=()=>qs(),Ps=()=>{"undefined"!=typeof window&&Us&&(window.removeEventListener("hashchange",Ds),window.removeEventListener("popstate",Ds),window.removeEventListener("pushstate",Ds),window.removeEventListener("replacestate",Ds),window.removeEventListener("load",Ds),Us=!1)};function Zs(e,t,n){switch(n){case"exactMatch":return c(e===t);case"contains":return c(e.includes(t));case"startsWith":return c(e.startsWith(t));case"endsWith":return c(e.endsWith(t));case"notMatch":return c(e!==t);case"notContains":return c(!e.includes(t));default:return u({code:"invalid_match_type",message:"Invalid match type"})}}let Rs=!1;const Fs=e=>(e=>{const{state:t}=As.get();if(!t)return;const n=e.target;((null==t?void 0:t.noCodeActionClasses)||[]).forEach((e=>{var t,r,i,s,o,a,l,d;const c=null==(r=null==(t=e.noCodeConfig)?void 0:t.innerHtml)?void 0:r.value,u=null==(s=null==(i=e.noCodeConfig)?void 0:i.cssSelector)?void 0:s.value,p=null==(a=null==(o=e.noCodeConfig)?void 0:o.pageUrl)?void 0:a.value,h=null==(d=null==(l=e.noCodeConfig)?void 0:l.pageUrl)?void 0:d.rule;if((c||u||p)&&(!c||n.innerHTML===c)){if(u){const e=u.split(/\s*(?=[.#])/);for(let t of e)if(!n.matches(t))return}if(p&&h){const e=Zs(window.location.href,p,h);if(!e.ok||!e.value)return}xs(e.name).then((e=>{var t,n,r;n=e=>{},r=e=>{Ms.handle(e)},!0===(t=e).ok?n(t.value):r(t.error)}))}}))})(e),Bs=()=>{Rs&&(document.removeEventListener("click",Fs),Rs=!1)};let zs=!1;const $s=()=>{"undefined"!=typeof window&&null===ls&&(ls=window.setInterval((async()=>{os.get().expiresAt&&new Date(os.get().expiresAt)>=new Date||(as.debug("Config has expired. Starting sync."),await ds({apiHost:os.get().apiHost,environmentId:os.get().environmentId,userId:os.get().userId}))}),6e4)),"undefined"==typeof window||Us||(window.addEventListener("hashchange",Ds),window.addEventListener("popstate",Ds),window.addEventListener("pushstate",Ds),window.addEventListener("replacestate",Ds),window.addEventListener("load",Ds),Us=!0),"undefined"==typeof window||Rs||(document.addEventListener("click",Fs),Rs=!0),"undefined"==typeof document||Cs||(document.querySelector("body").addEventListener("mouseleave",Is),Cs=!0),"undefined"==typeof window||Ns||(window.addEventListener("load",(()=>{window.addEventListener("scroll",Ls)})),Ns=!0)},Hs=()=>{us(),Ps(),Bs(),Ss(),Ts(),zs&&(window.removeEventListener("beforeunload",(()=>{us(),Ps(),Bs(),Ss(),Ts()})),zs=!1)},Ws=g.getInstance(),Vs=d.getInstance(),Qs=async()=>(Vs.error("'setUserId' is no longer supported. Please set the userId in the init call instead."),{ok:!0,value:void 0}),Ks=async(e,t)=>{if(Vs.debug("Setting attribute: "+e+" to value: "+t),((e,t)=>Ws.get().state.attributes[e]===t)(e,t.toString()))return Vs.debug("Attribute already set to this value. Skipping update."),{ok:!0,value:void 0};const n=await(async(e,t)=>{const{apiHost:n,environmentId:r,userId:i}=Ws.get();if(!i)return u({code:"missing_person",message:"Unable to update attribute. User identification deactivated. No userId set."});const s={attributes:{[e]:t}},o=new l({apiHost:Ws.get().apiHost,environmentId:Ws.get().environmentId}),a=await o.client.people.update(i,s);return a.ok?(Vs.debug("Attribute updated. Syncing..."),await ds({environmentId:r,apiHost:n,userId:i}),{ok:!0,value:void 0}):u({code:"network_error",status:500,message:`Error updating person with userId ${i}`,url:`${Ws.get().apiHost}/api/v1/client/${r}/people/${i}`,responseMessage:a.error.message})})(e,t.toString());return n.ok?(Ws.update({environmentId:Ws.get().environmentId,apiHost:Ws.get().apiHost,userId:Ws.get().userId,state:{...Ws.get().state,attributes:{...Ws.get().state.attributes,[e]:t.toString()}}}),{ok:!0,value:void 0}):u(n.error)},Ys=async()=>{no()},Gs=async()=>{Vs.debug("Resetting state & getting new state from backend"),_s();const e={environmentId:Ws.get().environmentId,apiHost:Ws.get().apiHost,userId:Ws.get().userId};await Ys();try{return await to(e),{ok:!0,value:void 0}}catch(t){return u(t)}},Xs=g.getInstance(),Js=d.getInstance();let eo=!1;const to=async e=>{if(eo)return Js.debug("Already initialized, skipping initialization."),{ok:!0,value:void 0};if((e=>{e.debug&&(Js.debug("Setting log level to debug"),Js.configure({logLevel:"debug"}))})(e),m.getInstance().printStatus(),Js.debug("Start initialize"),!e.environmentId)return Js.debug("No environmentId provided"),u({code:"missing_field",field:"environmentId"});if(!e.apiHost)return Js.debug("No apiHost provided"),u({code:"missing_field",field:"apiHost"});if(Js.debug("Adding widget container to DOM"),vs(),!e.userId&&e.attributes)return Js.error("No userId provided but attributes. Cannot update attributes without userId."),u({code:"missing_field",field:"userId"});let t,n=null;if(e.userId&&e.attributes){const t=await(async(e,t,n,r)=>{var i,s;if(!n)return u({code:"missing_person",message:"Unable to update attribute. User identification deactivated. No userId set."});const o={...r};try{const e=null==(s=null==(i=Ws.get())?void 0:i.state)?void 0:s.attributes;if(e)for(const[t,n]of Object.entries(e))o[t]===n&&delete o[t]}catch(h){Vs.debug("config not set; sending all attributes to backend")}if(0===Object.keys(o).length)return Vs.debug("No attributes to update. Skipping update."),c(o);Vs.debug("Updating attributes: "+JSON.stringify(o));const a={attributes:o},d=new l({apiHost:e,environmentId:t}),p=await d.client.people.update(n,a);return p.ok?c(o):u({code:"network_error",status:500,message:`Error updating person with userId ${n}`,url:`${e}/api/v1/client/${t}/people/${n}`,responseMessage:p.error.message})})(e.apiHost,e.environmentId,e.userId,e.attributes);if(!0!==t.ok)return u(t.error);n=t.value}try{t=Xs.get()}catch(r){Js.debug("No existing configuration found.")}return t&&t.state&&t.environmentId===e.environmentId&&t.apiHost===e.apiHost&&t.userId===e.userId&&t.expiresAt?(Js.debug("Found existing configuration."),t.expiresAt<new Date?(Js.debug("Configuration expired."),await ds({apiHost:e.apiHost,environmentId:e.environmentId,userId:e.userId})):(Js.debug("Configuration not expired. Extending expiration."),Xs.update(t))):(Js.debug("No valid configuration found or it has been expired. Creating new config."),Js.debug("Syncing."),await ds({apiHost:e.apiHost,environmentId:e.environmentId,userId:e.userId}),await xs("New Session")),n&&Object.keys(n).length>0&&Xs.update({environmentId:Xs.get().environmentId,apiHost:Xs.get().apiHost,userId:Xs.get().userId,state:{...Xs.get().state,attributes:{...Xs.get().state.attributes,...e.attributes}}}),Js.debug("Adding event listeners"),$s(),zs||(window.addEventListener("beforeunload",(()=>{us(),Ps(),Bs(),Ss(),Ts()})),zs=!0),eo=!0,Js.debug("Initialized"),qs(),{ok:!0,value:void 0}},no=()=>{Js.debug("Deinitializing"),_s(),Hs(),Xs.resetConfig(),eo=!1};d.getInstance().debug("Create command queue");const ro=new class{constructor(){this.queue=[],this.running=!1,this.resolvePromise=null,this.commandPromise=null}add(e=!0,t,...n){this.queue.push({command:t,checkInitialized:e,commandArgs:n}),this.running||(this.commandPromise=new Promise((e=>{this.resolvePromise=e,this.run()})))}async wait(){this.running&&await this.commandPromise}async run(){for(this.running=!0;this.queue.length>0;){const e=m.getInstance(),t=this.queue.shift();if(!t)continue;if(t.checkInitialized){const t=(Js.debug("Check if initialized"),eo&&m.initialized?{ok:!0,value:void 0}:u({code:"not_initialized",message:"Formbricks not initialized. Call initialize() first."}));t&&!0!==t.ok&&e.handle(t.error)}const n=await(null==t?void 0:t.command.apply(null,null==t?void 0:t.commandArgs));n&&(!0!==n.ok&&e.handle(n.error))}this.running=!1,this.resolvePromise&&(this.resolvePromise(),this.resolvePromise=null,this.commandPromise=null)}},io=async(e,t)=>{ro.add(!0,Ks,e,t),await ro.wait()};return{init:async e=>{m.init(e.errorHandler),ro.add(!1,to,e),await ro.wait()},setUserId:async()=>{ro.add(!0,Qs),await ro.wait()},setEmail:async e=>{io("email",e),await ro.wait()},setAttribute:io,track:async(e,t={})=>{ro.add(!0,xs,e,t),await ro.wait()},logout:async()=>{ro.add(!0,Ys),await ro.wait()},reset:async()=>{ro.add(!0,Gs),await ro.wait()},registerRouteChange:async()=>{ro.add(!0,qs),await ro.wait()},getApi:()=>{const e=g.getInstance(),{environmentId:t,apiHost:n}=e.get();if(!t||!n)throw new Error("formbricks.init() must be called before getApi()");return new l({apiHost:n,environmentId:t})}}}));
//# sourceMappingURL=index.umd.js.ma